export type CreateApiApiWorkflowNameArgs = {name: string, version?: number | undefined, correlationId?: string | undefined, priority?: number | undefined, 'X-Idempotency-key'?: string | undefined, 'X-on-conflict'?: ('FAIL' | 'RETURN_EXISTING' | 'FAIL_ON_RUNNING') | undefined, body: {[key: string]: Record}}; export type CreateApiApiWorkflowNameOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking * * POST /api/workflow/{name} */ export const createApiApiWorkflowName = async (args: CreateApiApiWorkflowNameArgs, options?: CreateApiApiWorkflowNameOptions) => { 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 (args.version != null) query.append("version", String(args.version)) if (args.correlationId != null) query.append("correlationId", String(args.correlationId)) if (args.priority != null) query.append("priority", String(args.priority)) if (args['X-Idempotency-key'] != null) headers.set("X-Idempotency-key", String(args['X-Idempotency-key'])) if (args['X-on-conflict'] != null) headers.set("X-on-conflict", String(args['X-on-conflict'])) if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/workflow/${encodeURIComponent(String(args.name))}${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() };