export type CreateApiApiTasksWorkflowIdStatusSignalArgs = {workflowId: string, status: 'IN_PROGRESS' | 'FAILED' | 'FAILED_WITH_TERMINAL_ERROR' | 'COMPLETED' | 'CANCELED', body: {[key: string]: Record}}; export type CreateApiApiTasksWorkflowIdStatusSignalOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Signal the workflow's blocking task asynchronously * * POST /api/tasks/{workflowId}/{status}/signal */ export const createApiApiTasksWorkflowIdStatusSignal = async (args: CreateApiApiTasksWorkflowIdStatusSignalArgs, options?: CreateApiApiTasksWorkflowIdStatusSignalOptions) => { const {baseUrl = "https://developer.orkescloud.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/tasks/${encodeURIComponent(String(args.workflowId))}/${encodeURIComponent(String(args.status))}/signal${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 };