export type ExecutionMetadata = {additionalContext?: {[key: string]: Record} | undefined, additionalContextMap?: {[key: string]: Record} | undefined, clientReceiveTime?: number | undefined, clientSendTime?: number | undefined, empty?: boolean | undefined, executionDuration?: number | undefined, executionEndTime?: number | undefined, executionStartTime?: number | undefined, pollNetworkLatency?: number | undefined, serverSendTime?: number | undefined, updateNetworkLatency?: number | undefined}; export type TaskExecLog = {createdTime?: number | undefined, log?: string | undefined, taskId?: string | undefined}; export type TaskResult = {callbackAfterSeconds?: number | undefined, executionMetadata?: ExecutionMetadata | undefined, extendLease?: boolean | undefined, externalOutputPayloadStoragePath?: string | undefined, logs?: Array | undefined, orCreateExecutionMetadata?: ExecutionMetadata | undefined, outputData?: {[key: string]: Record} | undefined, reasonForIncompletion?: string | undefined, status?: ('IN_PROGRESS' | 'FAILED' | 'FAILED_WITH_TERMINAL_ERROR' | 'COMPLETED' | 'CANCELED') | undefined, subWorkflowId?: string | undefined, supportsCancellation?: boolean | undefined, taskId?: string | undefined, workerId?: string | undefined, workflowInstanceId?: string | undefined}; export type WorkflowStateUpdate = {taskReferenceName?: string | undefined, taskResult?: TaskResult | undefined, variables?: {[key: string]: Record} | undefined}; export type CreateApiApiWorkflowWorkflowIdStateArgs = {workflowId: string, requestId: string, waitUntilTaskRef?: string | undefined, waitForSeconds?: number | undefined, body: WorkflowStateUpdate}; export type CreateApiApiWorkflowWorkflowIdStateOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a workflow state by updating variables or in progress task * * POST /api/workflow/{workflowId}/state */ export const createApiApiWorkflowWorkflowIdState = async (args: CreateApiApiWorkflowWorkflowIdStateArgs, options?: CreateApiApiWorkflowWorkflowIdStateOptions) => { 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") headers.set('accept', "*/*") if (args.requestId != null) query.append("requestId", String(args.requestId)) if (args.waitUntilTaskRef != null) query.append("waitUntilTaskRef", String(args.waitUntilTaskRef)) if (args.waitForSeconds != null) query.append("waitForSeconds", String(args.waitForSeconds)) if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/workflow/${encodeURIComponent(String(args.workflowId))}/state${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 res.blob() };