export type CreateApiWorkflowTaskArgs = {flowtype?: string | undefined}; export type CreateApiWorkflowTaskOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /workflow/task */ export const createApiWorkflowTask = async (args: CreateApiWorkflowTaskArgs, options: CreateApiWorkflowTaskOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.flowtype != null) query.append("flowtype", String(args.flowtype)) const url = `${baseUrl.replace(/\/+$/, '')}/workflow/task${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };