export type CreateApiApiOrgIdSearchStreamArgs = {org_id: string, is_ui_histogram: boolean, is_multi_stream_search: boolean, body: string}; export type CreateApiApiOrgIdSearchStreamOptions = {baseUrl: string, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream search results * * POST /api/{org_id}/_search_stream */ export const createApiApiOrgIdSearchStream = async (args: CreateApiApiOrgIdSearchStreamArgs, options: CreateApiApiOrgIdSearchStreamOptions) => { 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 (args.is_ui_histogram != null) query.append("is_ui_histogram", String(args.is_ui_histogram)) if (args.is_multi_stream_search != null) query.append("is_multi_stream_search", String(args.is_multi_stream_search)) if (Authorization !== undefined) headers.set("Authorization", Authorization) const url = `${baseUrl.replace(/\/+$/, '')}/api/${encodeURIComponent(String(args.org_id))}/_search_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() };