UNPKG

@n8n-plus/n8n-plus

Version:

n8n Workflow Automation Tool (plus edition)

252 lines (251 loc) 7.74 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"; nodeName: string; parameters: Record<string, unknown>; replace?: boolean | undefined; }, { type: "updateNodeParameters"; nodeName: string; parameters: Record<string, unknown>; 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; nodeName: string; credentialId: string; credentialKey: string; }, { type: "setNodeCredential"; credentialName: string; nodeName: string; credentialId: 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"; nodeName: string; position: [number, number]; }, { type: "setNodePosition"; nodeName: string; position: number[]; }>, 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<"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 {};