export type EventSource = 'DATABASE' | 'LIVE' | 'HYBRID'; export type GetApiV1WorkflowsExecutionsExecutionIdStreamArgs = {execution_id: string, event_source?: (EventSource | null) | undefined, last_event_id?: (string | null) | undefined}; export type GetApiV1WorkflowsExecutionsExecutionIdStreamOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream * * GET /v1/workflows/executions/{execution_id}/stream */ export const getApiV1WorkflowsExecutionsExecutionIdStream = async (args: GetApiV1WorkflowsExecutionsExecutionIdStreamArgs, options?: GetApiV1WorkflowsExecutionsExecutionIdStreamOptions) => { const {baseUrl = "https://api.mistral.ai", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/event-stream") if (args.event_source != null) query.append("event_source", String(args.event_source)) if (args.last_event_id != null) query.append("last_event_id", String(args.last_event_id)) if (ApiKey !== undefined) headers.set('authorization', `Bearer ${ApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/workflows/executions/${encodeURIComponent(String(args.execution_id))}/stream${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() };