export type GetApiApiParseStatusTaskIdArgs = {taskId: string}; export type GetApiApiParseStatusTaskIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Poll parse task status * * GET /api/parse/status/{taskId} */ export const getApiApiParseStatusTaskId = async (args: GetApiApiParseStatusTaskIdArgs, options?: GetApiApiParseStatusTaskIdOptions) => { const {baseUrl = "https://prismer.cloud", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/parse/status/${encodeURIComponent(String(args.taskId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };