export type CreateApiApiOrgIdValuesStreamArgs = {org_id: string, body: string}; export type CreateApiApiOrgIdValuesStreamOptions = {baseUrl: string, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get field values with HTTP/2 streaming * * POST /api/{org_id}/_values_stream */ export const createApiApiOrgIdValuesStream = async (args: CreateApiApiOrgIdValuesStreamArgs, options: CreateApiApiOrgIdValuesStreamOptions) => { const {baseUrl, fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/event-stream") if (Authorization !== undefined) headers.set("Authorization", Authorization) const url = `${baseUrl.replace(/\/+$/, '')}/api/${encodeURIComponent(String(args.org_id))}/_values_stream${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };