export type GetApiApiV1ContextIdDocumentsIdRawArgs = {context_id: string, id: string}; export type GetApiApiV1ContextIdDocumentsIdRawOptions = {baseUrl: string, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Streams the raw bytes of a document * * GET /api/v1/{context_id}/documents/{id}/raw */ export const getApiApiV1ContextIdDocumentsIdRaw = async (args: GetApiApiV1ContextIdDocumentsIdRawArgs, options: GetApiApiV1ContextIdDocumentsIdRawOptions) => { const {baseUrl, fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/${encodeURIComponent(String(args.context_id))}/documents/${encodeURIComponent(String(args.id))}/raw${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 undefined };