export type DuplicateWorkflowDTO = {name: string, appId?: number | undefined, categoryId?: number | undefined, identifier?: string | undefined}; export type CreateApiV1WorkflowsWorkflowIdDuplicateArgs = {workflowId: number, body: DuplicateWorkflowDTO}; export type CreateApiV1WorkflowsWorkflowIdDuplicateOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /v1/workflows/{workflowId}/duplicate */ export const createApiV1WorkflowsWorkflowIdDuplicate = async (args: CreateApiV1WorkflowsWorkflowIdDuplicateArgs, options: CreateApiV1WorkflowsWorkflowIdDuplicateOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/workflows/${encodeURIComponent(String(args.workflowId))}/duplicate${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 };