UNPKG

n8n

Version:

n8n Workflow Automation Tool

313 lines (312 loc) • 10.4 kB
import type { IConnections, INode, IWorkflowBase } from 'n8n-workflow'; import { z } from 'zod'; export declare const partialUpdateOperationSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{ type: z.ZodLiteral<"updateNodeParameters">; nodeName: z.ZodString; parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>; replace: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { type: "updateNodeParameters"; parameters: Record<string, unknown>; nodeName: string; replace?: boolean | undefined; }, { type: "updateNodeParameters"; parameters: Record<string, unknown>; nodeName: string; replace?: boolean | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"setNodeParameter">; nodeName: z.ZodString; path: z.ZodString; value: z.ZodEffects<z.ZodUnknown, {} | null, unknown>; }, "strip", z.ZodTypeAny, { value: {} | null; path: string; type: "setNodeParameter"; nodeName: string; }, { path: string; type: "setNodeParameter"; nodeName: string; value?: unknown; }>, z.ZodObject<{ type: z.ZodLiteral<"addNode">; node: z.ZodObject<{ name: z.ZodString; type: z.ZodString; typeVersion: z.ZodNumber; parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; position: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, [number, number], number[]>>; credentials: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{ id: z.ZodOptional<z.ZodString>; name: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; id?: string | undefined; }, { name: string; id?: string | undefined; }>>>; disabled: z.ZodOptional<z.ZodBoolean>; notes: z.ZodOptional<z.ZodString>; id: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; type: string; typeVersion: number; id?: string | undefined; credentials?: Record<string, { name: string; id?: string | undefined; }> | undefined; disabled?: boolean | undefined; position?: [number, number] | undefined; notes?: string | undefined; parameters?: Record<string, unknown> | undefined; }, { name: string; type: string; typeVersion: number; id?: string | undefined; credentials?: Record<string, { name: string; id?: string | undefined; }> | undefined; disabled?: boolean | undefined; position?: number[] | undefined; notes?: string | undefined; parameters?: Record<string, unknown> | undefined; }>; }, "strip", z.ZodTypeAny, { type: "addNode"; node: { name: string; type: string; typeVersion: number; id?: string | undefined; credentials?: Record<string, { name: string; id?: string | undefined; }> | undefined; disabled?: boolean | undefined; position?: [number, number] | undefined; notes?: string | undefined; parameters?: Record<string, unknown> | undefined; }; }, { type: "addNode"; node: { name: string; type: string; typeVersion: number; id?: string | undefined; credentials?: Record<string, { name: string; id?: string | undefined; }> | undefined; disabled?: boolean | undefined; position?: number[] | undefined; notes?: string | undefined; parameters?: Record<string, unknown> | undefined; }; }>, z.ZodObject<{ type: z.ZodLiteral<"removeNode">; nodeName: z.ZodString; }, "strip", z.ZodTypeAny, { type: "removeNode"; nodeName: string; }, { type: "removeNode"; nodeName: string; }>, z.ZodObject<{ type: z.ZodLiteral<"renameNode">; oldName: z.ZodString; newName: z.ZodString; }, "strip", z.ZodTypeAny, { type: "renameNode"; oldName: string; newName: string; }, { type: "renameNode"; oldName: string; newName: string; }>, z.ZodObject<{ type: z.ZodLiteral<"addConnection">; source: z.ZodString; target: z.ZodString; sourceIndex: z.ZodOptional<z.ZodNumber>; targetIndex: z.ZodOptional<z.ZodNumber>; connectionType: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: "addConnection"; source: string; target: string; connectionType?: string | undefined; sourceIndex?: number | undefined; targetIndex?: number | undefined; }, { type: "addConnection"; source: string; target: string; connectionType?: string | undefined; sourceIndex?: number | undefined; targetIndex?: number | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"removeConnection">; source: z.ZodString; target: z.ZodString; sourceIndex: z.ZodOptional<z.ZodNumber>; targetIndex: z.ZodOptional<z.ZodNumber>; connectionType: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: "removeConnection"; source: string; target: string; connectionType?: string | undefined; sourceIndex?: number | undefined; targetIndex?: number | undefined; }, { type: "removeConnection"; source: string; target: string; connectionType?: string | undefined; sourceIndex?: number | undefined; targetIndex?: number | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"setNodeCredential">; nodeName: z.ZodString; credentialKey: z.ZodString; credentialId: z.ZodString; credentialName: z.ZodString; }, "strip", z.ZodTypeAny, { type: "setNodeCredential"; credentialName: string; credentialId: string; nodeName: string; credentialKey: string; }, { type: "setNodeCredential"; credentialName: string; credentialId: string; nodeName: string; credentialKey: string; }>, z.ZodObject<{ type: z.ZodLiteral<"setNodePosition">; nodeName: z.ZodString; position: z.ZodEffects<z.ZodArray<z.ZodNumber, "many">, [number, number], number[]>; }, "strip", z.ZodTypeAny, { type: "setNodePosition"; position: [number, number]; nodeName: string; }, { type: "setNodePosition"; position: number[]; nodeName: string; }>, z.ZodObject<{ type: z.ZodLiteral<"setNodeDisabled">; nodeName: z.ZodString; disabled: z.ZodBoolean; }, "strip", z.ZodTypeAny, { type: "setNodeDisabled"; disabled: boolean; nodeName: string; }, { type: "setNodeDisabled"; disabled: boolean; nodeName: string; }>, z.ZodObject<{ type: z.ZodLiteral<"setNodeSettings">; nodeName: z.ZodString; settings: z.ZodEffects<z.ZodObject<{ onError: z.ZodOptional<z.ZodEnum<["stopWorkflow", "continueRegularOutput", "continueErrorOutput"]>>; retryOnFail: z.ZodOptional<z.ZodBoolean>; maxTries: z.ZodOptional<z.ZodNumber>; waitBetweenTries: z.ZodOptional<z.ZodNumber>; alwaysOutputData: z.ZodOptional<z.ZodBoolean>; executeOnce: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { retryOnFail?: boolean | undefined; maxTries?: number | undefined; waitBetweenTries?: number | undefined; alwaysOutputData?: boolean | undefined; executeOnce?: boolean | undefined; onError?: "continueErrorOutput" | "continueRegularOutput" | "stopWorkflow" | undefined; }, { retryOnFail?: boolean | undefined; maxTries?: number | undefined; waitBetweenTries?: number | undefined; alwaysOutputData?: boolean | undefined; executeOnce?: boolean | undefined; onError?: "continueErrorOutput" | "continueRegularOutput" | "stopWorkflow" | undefined; }>, { retryOnFail?: boolean | undefined; maxTries?: number | undefined; waitBetweenTries?: number | undefined; alwaysOutputData?: boolean | undefined; executeOnce?: boolean | undefined; onError?: "continueErrorOutput" | "continueRegularOutput" | "stopWorkflow" | undefined; }, { retryOnFail?: boolean | undefined; maxTries?: number | undefined; waitBetweenTries?: number | undefined; alwaysOutputData?: boolean | undefined; executeOnce?: boolean | undefined; onError?: "continueErrorOutput" | "continueRegularOutput" | "stopWorkflow" | undefined; }>; }, "strip", z.ZodTypeAny, { settings: { retryOnFail?: boolean | undefined; maxTries?: number | undefined; waitBetweenTries?: number | undefined; alwaysOutputData?: boolean | undefined; executeOnce?: boolean | undefined; onError?: "continueErrorOutput" | "continueRegularOutput" | "stopWorkflow" | undefined; }; type: "setNodeSettings"; nodeName: string; }, { settings: { retryOnFail?: boolean | undefined; maxTries?: number | undefined; waitBetweenTries?: number | undefined; alwaysOutputData?: boolean | undefined; executeOnce?: boolean | undefined; onError?: "continueErrorOutput" | "continueRegularOutput" | "stopWorkflow" | undefined; }; type: "setNodeSettings"; nodeName: string; }>, z.ZodObject<{ type: z.ZodLiteral<"setWorkflowMetadata">; name: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: "setWorkflowMetadata"; description?: string | undefined; name?: string | undefined; }, { type: "setWorkflowMetadata"; description?: string | undefined; name?: string | undefined; }>]>; export type PartialUpdateOperation = z.infer<typeof partialUpdateOperationSchema>; interface WorkflowSlice { name: string; description?: string; nodes: INode[]; connections: IConnections; } export interface ApplyOperationsSuccess { success: true; workflow: WorkflowSlice; addedNodeNames: string[]; } export interface ApplyOperationsFailure { success: false; error: string; opIndex: number; } export type ApplyOperationsResult = ApplyOperationsSuccess | ApplyOperationsFailure; export declare function applyOperations(input: WorkflowSlice, operations: PartialUpdateOperation[]): ApplyOperationsResult; export declare function toWorkflowSlice(workflow: IWorkflowBase): WorkflowSlice; export {};