export type CreateApiWorkflowIdQueryQueryArgs = {id: string, query: string, body: {payload?: Record | undefined}}; export type CreateApiWorkflowIdQueryQueryOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send a query to an workflow * * POST /workflow/{id}/query/{query} */ export const createApiWorkflowIdQueryQuery = async (args: CreateApiWorkflowIdQueryQueryArgs, options?: CreateApiWorkflowIdQueryQueryOptions) => { const {baseUrl = "http://localhost:3001", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/workflow/${encodeURIComponent(String(args.id))}/query/${encodeURIComponent(String(args.query))}${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 undefined };