export type CancelForDTO = {recipients: Array}; export type CancelWorkflowRunDTO = {cancellationKey: string, cancelFor: CancelForDTO}; export type PatchApiV1WorkflowsWorkflowIdCancelRunArgs = {workflowId: number, body: CancelWorkflowRunDTO}; export type PatchApiV1WorkflowsWorkflowIdCancelRunOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * PATCH /v1/workflows/{workflowId}/cancel-run */ export const patchApiV1WorkflowsWorkflowIdCancelRun = async (args: PatchApiV1WorkflowsWorkflowIdCancelRunArgs, options: PatchApiV1WorkflowsWorkflowIdCancelRunOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/workflows/${encodeURIComponent(String(args.workflowId))}/cancel-run${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };