export type RerunWorkflowRequest = {correlationId?: string | undefined, reRunFromTaskId?: string | undefined, reRunFromWorkflowId?: string | undefined, taskInput?: {[key: string]: Record} | undefined, workflowInput?: {[key: string]: Record} | undefined}; export type CreateApiApiWorkflowWorkflowIdRerunArgs = {workflowId: string, body: RerunWorkflowRequest}; export type CreateApiApiWorkflowWorkflowIdRerunOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Reruns the workflow from a specific task * * POST /api/workflow/{workflowId}/rerun */ export const createApiApiWorkflowWorkflowIdRerun = async (args: CreateApiApiWorkflowWorkflowIdRerunArgs, options?: CreateApiApiWorkflowWorkflowIdRerunOptions) => { 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', "text/plain") if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/workflow/${encodeURIComponent(String(args.workflowId))}/rerun${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.text() };