export type GetApiApiParseStreamTaskIdArgs = {taskId: string}; export type GetApiApiParseStreamTaskIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream parse progress * * GET /api/parse/stream/{taskId} */ export const getApiApiParseStreamTaskId = async (args: GetApiApiParseStreamTaskIdArgs, options?: GetApiApiParseStreamTaskIdOptions) => { const {baseUrl = "https://prismer.cloud", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/event-stream") if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/parse/stream/${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 res.text() };