export type GetApiWorkflowIdHistoryStreamArgs = {id: string, includePayloads?: boolean | undefined, lastEventId?: number | undefined}; export type GetApiWorkflowIdHistoryStreamOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream workflow history events via Server-Sent Events * * GET /workflow/{id}/history/stream */ export const getApiWorkflowIdHistoryStream = async (args: GetApiWorkflowIdHistoryStreamArgs, options?: GetApiWorkflowIdHistoryStreamOptions) => { const {baseUrl = "http://localhost:3001", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/event-stream") if (args.includePayloads != null) query.append("includePayloads", String(args.includePayloads)) if (args.lastEventId != null) query.append("lastEventId", String(args.lastEventId)) const url = `${baseUrl.replace(/\/+$/, '')}/workflow/${encodeURIComponent(String(args.id))}/history/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() };