export type CreateApiWorkflowIdSignalSignalArgs = {id: string, signal: string, body: {payload?: Record | undefined}}; export type CreateApiWorkflowIdSignalSignalOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send a signal to an workflow * * POST /workflow/{id}/signal/{signal} */ export const createApiWorkflowIdSignalSignal = async (args: CreateApiWorkflowIdSignalSignalArgs, options?: CreateApiWorkflowIdSignalSignalOptions) => { 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))}/signal/${encodeURIComponent(String(args.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 };