export type RestVariable = {name?: string | undefined, type?: string | undefined, value?: Record | undefined, valueUrl?: string | undefined, scope?: string | undefined}; export type TaskActionRequest = {action: string, assignee?: string | undefined, formDefinitionId?: string | undefined, outcome?: string | undefined, variables?: Array | undefined, transientVariables?: Array | undefined}; export type CreateApiCmmnRuntimeTasksTaskIdArgs = {taskId: string, body: TaskActionRequest}; export type CreateApiCmmnRuntimeTasksTaskIdOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Tasks actions * * POST /cmmn-runtime/tasks/{taskId} */ export const createApiCmmnRuntimeTasksTaskId = async (args: CreateApiCmmnRuntimeTasksTaskIdArgs, options: CreateApiCmmnRuntimeTasksTaskIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/cmmn-runtime/tasks/${encodeURIComponent(String(args.taskId))}${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 };