@n8n/node-engine-compatibility 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ import { UserError } from 'n8n-workflow';
2
+ export declare class UnsupportedWorkflowError extends UserError {
3
+ }
4
+ export declare class UnsupportedTriggerError extends UserError {
5
+ constructor(nodeName: string, nodeType: string);
6
+ }
7
+ export declare class UnsupportedStepTypeError extends UserError {
8
+ constructor(stepType: string);
9
+ }
10
+ export declare class MalformedStepConfigError extends UserError {
11
+ constructor(stepName: string);
12
+ }
13
+ export declare class UnknownNodeTypeError extends UserError {
14
+ constructor(nodeType: string);
15
+ }
16
+ export declare class UnsupportedNodeTypeError extends UserError {
17
+ constructor(nodeType: string);
18
+ }
19
+ export declare class EngineRequestNotSupportedError extends UserError {
20
+ constructor(nodeType: string);
21
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EngineRequestNotSupportedError = exports.UnsupportedNodeTypeError = exports.UnknownNodeTypeError = exports.MalformedStepConfigError = exports.UnsupportedStepTypeError = exports.UnsupportedTriggerError = exports.UnsupportedWorkflowError = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class UnsupportedWorkflowError extends n8n_workflow_1.UserError {
6
+ }
7
+ exports.UnsupportedWorkflowError = UnsupportedWorkflowError;
8
+ class UnsupportedTriggerError extends n8n_workflow_1.UserError {
9
+ constructor(nodeName, nodeType) {
10
+ super(`Trigger node "${nodeName}" (${nodeType}) is not supported yet; only the Manual Trigger is currently supported.`);
11
+ }
12
+ }
13
+ exports.UnsupportedTriggerError = UnsupportedTriggerError;
14
+ class UnsupportedStepTypeError extends n8n_workflow_1.UserError {
15
+ constructor(stepType) {
16
+ super(`V1StepExecutor only handles 'v1-node' steps, got '${stepType}'`);
17
+ }
18
+ }
19
+ exports.UnsupportedStepTypeError = UnsupportedStepTypeError;
20
+ class MalformedStepConfigError extends n8n_workflow_1.UserError {
21
+ constructor(stepName) {
22
+ super(`Step "${stepName}" has a missing or malformed v1-node config`);
23
+ }
24
+ }
25
+ exports.MalformedStepConfigError = MalformedStepConfigError;
26
+ class UnknownNodeTypeError extends n8n_workflow_1.UserError {
27
+ constructor(nodeType) {
28
+ super(`Unknown node type "${nodeType}"`);
29
+ }
30
+ }
31
+ exports.UnknownNodeTypeError = UnknownNodeTypeError;
32
+ class UnsupportedNodeTypeError extends n8n_workflow_1.UserError {
33
+ constructor(nodeType) {
34
+ super(`Node type "${nodeType}" has no execute method and cannot run as a step`);
35
+ }
36
+ }
37
+ exports.UnsupportedNodeTypeError = UnsupportedNodeTypeError;
38
+ class EngineRequestNotSupportedError extends n8n_workflow_1.UserError {
39
+ constructor(nodeType) {
40
+ super(`Node type "${nodeType}" returned an engine request, but sub-node execution is not supported`);
41
+ }
42
+ }
43
+ exports.EngineRequestNotSupportedError = EngineRequestNotSupportedError;
44
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAMzC,8BAAsC,SAAQ,wBAAS;CAAG;;AAE1D,6BAAqC,SAAQ,wBAAS;IACrD,YAAY,QAAgB,EAAE,QAAgB;QAC7C,KAAK,CACJ,iBAAiB,QAAQ,MAAM,QAAQ,yEAAyE,CAChH,CAAC;IACH,CAAC;CACD;;AAED,8BAAsC,SAAQ,wBAAS;IACtD,YAAY,QAAgB;QAC3B,KAAK,CAAC,qDAAqD,QAAQ,GAAG,CAAC,CAAC;IACzE,CAAC;CACD;;AAED,8BAAsC,SAAQ,wBAAS;IACtD,YAAY,QAAgB;QAC3B,KAAK,CAAC,SAAS,QAAQ,6CAA6C,CAAC,CAAC;IACvE,CAAC;CACD;;AAED,0BAAkC,SAAQ,wBAAS;IAClD,YAAY,QAAgB;QAC3B,KAAK,CAAC,sBAAsB,QAAQ,GAAG,CAAC,CAAC;IAC1C,CAAC;CACD;;AAED,8BAAsC,SAAQ,wBAAS;IACtD,YAAY,QAAgB;QAC3B,KAAK,CAAC,cAAc,QAAQ,kDAAkD,CAAC,CAAC;IACjF,CAAC;CACD;;AAED,oCAA4C,SAAQ,wBAAS;IAC5D,YAAY,QAAgB;QAC3B,KAAK,CACJ,cAAc,QAAQ,uEAAuE,CAC7F,CAAC;IACH,CAAC;CACD"}
@@ -0,0 +1,3 @@
1
+ import type { V1NodeStepConfig } from './types';
2
+ export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
3
+ export declare function isV1NodeStepConfig(config: unknown): config is V1NodeStepConfig;
package/dist/guards.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRecord = void 0;
4
+ exports.isV1NodeStepConfig = isV1NodeStepConfig;
5
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
6
+ exports.isRecord = isRecord;
7
+ function isV1NodeStepConfig(config) {
8
+ if (!(0, exports.isRecord)(config))
9
+ return false;
10
+ return (typeof config.nodeType === 'string' &&
11
+ config.nodeType.length > 0 &&
12
+ typeof config.typeVersion === 'number' &&
13
+ (0, exports.isRecord)(config.parameters) &&
14
+ typeof config.continueOnFail === 'boolean');
15
+ }
16
+ //# sourceMappingURL=guards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":";;;;AAEO,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAC5E,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AADzD,QAAA,QAAQ,GAAR,QAAQ,CACiD;AAEtE,4BAAmC,MAAe;IACjD,IAAI,CAAC,IAAA,QAAA,QAAQ,EAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,OAAO,CACN,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ;QACnC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC1B,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ;QACtC,IAAA,QAAA,QAAQ,EAAC,MAAM,CAAC,UAAU,CAAC;QAC3B,OAAO,MAAM,CAAC,cAAc,KAAK,SAAS,CAC1C,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { V1WorkflowConverter } from './v1-workflow-converter';
2
+ export { V1StepExecutor } from './v1-step-executor';
3
+ export { UnsupportedTriggerError, UnsupportedWorkflowError } from './errors';
4
+ export type { V1StepExecutorDeps } from './types';
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnsupportedWorkflowError = exports.UnsupportedTriggerError = exports.V1StepExecutor = exports.V1WorkflowConverter = void 0;
4
+ var v1_workflow_converter_1 = require("./v1-workflow-converter");
5
+ Object.defineProperty(exports, "V1WorkflowConverter", { enumerable: true, get: function () { return v1_workflow_converter_1.V1WorkflowConverter; } });
6
+ var v1_step_executor_1 = require("./v1-step-executor");
7
+ Object.defineProperty(exports, "V1StepExecutor", { enumerable: true, get: function () { return v1_step_executor_1.V1StepExecutor; } });
8
+ var errors_1 = require("./errors");
9
+ Object.defineProperty(exports, "UnsupportedTriggerError", { enumerable: true, get: function () { return errors_1.UnsupportedTriggerError; } });
10
+ Object.defineProperty(exports, "UnsupportedWorkflowError", { enumerable: true, get: function () { return errors_1.UnsupportedWorkflowError; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,uDAAoD;AAA3C,kHAAA,cAAc,OAAA;AACvB,mCAA6E;AAApE,iHAAA,uBAAuB,OAAA;AAAE,kHAAA,wBAAwB,OAAA"}
package/dist/io.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { JsonValue } from '@n8n/engine';
2
+ import type { INodeExecutionData } from 'n8n-workflow';
3
+ export declare function fromStepInputs(value: JsonValue): INodeExecutionData[][];
4
+ export declare function toStepOutputs(outputs: INodeExecutionData[][]): JsonValue;
package/dist/io.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromStepInputs = fromStepInputs;
4
+ exports.toStepOutputs = toStepOutputs;
5
+ const guards_1 = require("./guards");
6
+ function fromStepInputs(value) {
7
+ if (!Array.isArray(value))
8
+ return [[]];
9
+ return value.map((items) => {
10
+ if (!Array.isArray(items))
11
+ return [];
12
+ return items.map((item) => {
13
+ if ((0, guards_1.isRecord)(item) && (0, guards_1.isRecord)(item.json))
14
+ return item;
15
+ if ((0, guards_1.isRecord)(item))
16
+ return { json: item };
17
+ return { json: { value: item } };
18
+ });
19
+ });
20
+ }
21
+ function toStepOutputs(outputs) {
22
+ return outputs;
23
+ }
24
+ //# sourceMappingURL=io.js.map
package/dist/io.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":";;;;AAGA,qCAAoC;AAEpC,wBAA+B,KAAgB;IAC9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAEvC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAsB,EAAE;YAC7C,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC,IAAI,CAAC;gBAAE,OAAO,IAAqC,CAAC;YACxF,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC;gBAAE,OAAO,EAAE,IAAI,EAAE,IAAmB,EAAE,CAAC;YACzD,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAiB,EAAE,CAAC;QACjD,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,uBAA8B,OAA+B;IAC5D,OAAO,OAA+B,CAAC;AACxC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { StepExecutionContext } from '@n8n/engine';
2
+ import type { ExecuteContext } from 'n8n-core';
3
+ import type { INodeExecutionData, INodeParameters, INodeType, INodeTypes, IWorkflowExecuteAdditionalData } from 'n8n-workflow';
4
+ export interface V1NodeStepConfig {
5
+ nodeType: string;
6
+ typeVersion: number;
7
+ parameters: INodeParameters;
8
+ continueOnFail: boolean;
9
+ }
10
+ export interface V1StepExecutorDeps {
11
+ nodeTypes: INodeTypes;
12
+ additionalDataFactory: (executionId: string) => Promise<IWorkflowExecuteAdditionalData>;
13
+ }
14
+ export type ExecutableNodeType = INodeType & {
15
+ execute: NonNullable<INodeType['execute']>;
16
+ };
17
+ export type NodeRunResult = {
18
+ ok: true;
19
+ value: unknown;
20
+ } | {
21
+ ok: false;
22
+ error: unknown;
23
+ };
24
+ export interface CreateNodeExecuteContextParams {
25
+ nodeId: string;
26
+ nodeName: string;
27
+ stepConfig: V1NodeStepConfig;
28
+ itemsByConnection: INodeExecutionData[][];
29
+ stepContext: StepExecutionContext;
30
+ }
31
+ export interface RunNodeParams {
32
+ nodeType: ExecutableNodeType;
33
+ nodeExecuteContext: ExecuteContext;
34
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { IStepExecutor, StepExecutionRequest, StepExecutionResult } from '@n8n/engine';
2
+ import type { V1StepExecutorDeps } from './types';
3
+ export declare class V1StepExecutor implements IStepExecutor {
4
+ private readonly deps;
5
+ constructor(deps: V1StepExecutorDeps);
6
+ execute(request: StepExecutionRequest): Promise<StepExecutionResult>;
7
+ private validateStepConfig;
8
+ private resolveNodeType;
9
+ private createNodeExecuteContext;
10
+ private runNode;
11
+ }
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V1StepExecutor = void 0;
4
+ const n8n_core_1 = require("n8n-core");
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ const errors_1 = require("./errors");
7
+ const guards_1 = require("./guards");
8
+ const io_1 = require("./io");
9
+ class V1StepExecutor {
10
+ deps;
11
+ constructor(deps) {
12
+ this.deps = deps;
13
+ }
14
+ async execute(request) {
15
+ const stepConfig = this.validateStepConfig(request.node);
16
+ const nodeType = this.resolveNodeType(stepConfig);
17
+ const nodeExecuteContext = await this.createNodeExecuteContext({
18
+ nodeId: request.node.id,
19
+ nodeName: request.node.name,
20
+ stepContext: request.context,
21
+ stepConfig,
22
+ itemsByConnection: (0, io_1.fromStepInputs)(request.inputs),
23
+ });
24
+ const nodeResult = await this.runNode({ nodeType, nodeExecuteContext });
25
+ return { outputs: (0, io_1.toStepOutputs)(nodeResult) };
26
+ }
27
+ validateStepConfig({ type, name, config }) {
28
+ if (type !== 'v1-node')
29
+ throw new errors_1.UnsupportedStepTypeError(type);
30
+ if (!(0, guards_1.isV1NodeStepConfig)(config))
31
+ throw new errors_1.MalformedStepConfigError(name);
32
+ return config;
33
+ }
34
+ resolveNodeType({ nodeType: typeName, typeVersion, }) {
35
+ const nodeType = this.deps.nodeTypes.getByNameAndVersion(typeName, typeVersion);
36
+ if (!nodeType)
37
+ throw new errors_1.UnknownNodeTypeError(typeName);
38
+ if (typeof nodeType.execute !== 'function')
39
+ throw new errors_1.UnsupportedNodeTypeError(typeName);
40
+ return nodeType;
41
+ }
42
+ async createNodeExecuteContext({ nodeId, nodeName, stepConfig, stepContext: stepCtx, itemsByConnection, }) {
43
+ const node = {
44
+ id: nodeId,
45
+ name: nodeName,
46
+ type: stepConfig.nodeType,
47
+ typeVersion: stepConfig.typeVersion,
48
+ position: [0, 0],
49
+ parameters: stepConfig.parameters,
50
+ continueOnFail: stepConfig.continueOnFail,
51
+ };
52
+ const workflow = new n8n_workflow_1.Workflow({
53
+ id: stepCtx.workflowId,
54
+ nodes: [node],
55
+ connections: {},
56
+ active: false,
57
+ nodeTypes: this.deps.nodeTypes,
58
+ });
59
+ const firstInput = itemsByConnection[0] ?? [];
60
+ const connectionInputData = firstInput.length > 0 ? firstInput : [{ json: {} }];
61
+ const inputData = {
62
+ main: [connectionInputData, ...itemsByConnection.slice(1)],
63
+ };
64
+ const runExecutionData = (0, n8n_workflow_1.createRunExecutionData)({
65
+ startData: {},
66
+ resultData: { runData: {} },
67
+ executionData: {
68
+ contextData: {},
69
+ nodeExecutionStack: [],
70
+ metadata: {},
71
+ waitingExecution: {},
72
+ waitingExecutionSource: null,
73
+ },
74
+ });
75
+ const executeData = { node, data: inputData, source: null };
76
+ const mode = stepCtx.mode === 'production' ? 'trigger' : 'manual';
77
+ const additionalData = await this.deps.additionalDataFactory(stepCtx.executionId);
78
+ return new n8n_core_1.ExecuteContext(workflow, node, additionalData, mode, runExecutionData, 0, connectionInputData, inputData, executeData, []);
79
+ }
80
+ async runNode({ nodeType, nodeExecuteContext, }) {
81
+ let result;
82
+ try {
83
+ const value = (0, n8n_workflow_1.isNodeClassInstance)(nodeType)
84
+ ? await nodeType.execute(nodeExecuteContext)
85
+ : await nodeType.execute.call(nodeExecuteContext);
86
+ result = { ok: true, value };
87
+ }
88
+ catch (error) {
89
+ result = { ok: false, error };
90
+ }
91
+ const { closeFunctions } = nodeExecuteContext;
92
+ if (closeFunctions.length > 0) {
93
+ const closeResults = await Promise.allSettled(closeFunctions.map(async (fn) => await fn()));
94
+ if (result.ok) {
95
+ const rejected = closeResults.find((closeResult) => closeResult.status === 'rejected');
96
+ if (rejected) {
97
+ throw rejected.reason instanceof Error
98
+ ? rejected.reason
99
+ : new n8n_workflow_1.UnexpectedError("Error on node's close function", {
100
+ extra: { nodeName: nodeExecuteContext.getNode().name },
101
+ });
102
+ }
103
+ }
104
+ }
105
+ if (!result.ok) {
106
+ if (!nodeExecuteContext.continueOnFail())
107
+ throw result.error;
108
+ return [nodeExecuteContext.getInputData()];
109
+ }
110
+ if (result.value === null || result.value === undefined)
111
+ return [];
112
+ if (Array.isArray(result.value))
113
+ return result.value;
114
+ throw new errors_1.EngineRequestNotSupportedError(nodeExecuteContext.getNode().type);
115
+ }
116
+ }
117
+ exports.V1StepExecutor = V1StepExecutor;
118
+ //# sourceMappingURL=v1-step-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v1-step-executor.js","sourceRoot":"","sources":["../src/v1-step-executor.ts"],"names":[],"mappings":";;;AAMA,uCAA0C;AAQ1C,+CAKsB;AAEtB,qCAMkB;AAClB,qCAA8C;AAC9C,6BAAqD;AAiBrD;IAC8B,IAAI;IAAjC,YAA6B,IAAwB;oBAAxB,IAAI;IAAuB,CAAC;IAEzD,KAAK,CAAC,OAAO,CAAC,OAA6B;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAElD,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC;YAC9D,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE;YACvB,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;YAC3B,WAAW,EAAE,OAAO,CAAC,OAAO;YAC5B,UAAU;YACV,iBAAiB,EAAE,IAAA,mBAAc,E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AAe,CAAC,gCAAgC,EAAE;4BACtD,KAAK,EAAE,EAAE,QAAQ,EAAE,kBAAkB,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE;yBACtD,CAAC,CAAC;gBACN,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YAChB,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE;gBAAE,MAAM,MAAM,CAAC,KAAK,CAAC;YAC7D,OAAO,CAAC,kBAAkB,CAAC,YAAY,EAAE,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QAEnE,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC,KAA+B,CAAC;QAE/E,MAAM,IAAI,uCAA8B,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC;CACD"}
@@ -0,0 +1,7 @@
1
+ import type { WorkflowGraph } from '@n8n/engine';
2
+ import type { IWorkflowBase } from 'n8n-workflow';
3
+ export declare class V1WorkflowConverter {
4
+ convert(workflow: IWorkflowBase): WorkflowGraph;
5
+ private toGraphNode;
6
+ private isTriggerNode;
7
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V1WorkflowConverter = void 0;
4
+ const errors_1 = require("./errors");
5
+ const MANUAL_TRIGGER_TYPE = 'n8n-nodes-base.manualTrigger';
6
+ const KNOWN_TRIGGER_TYPES = new Set(['n8n-nodes-base.webhook', 'n8n-nodes-base.cron']);
7
+ class V1WorkflowConverter {
8
+ convert(workflow) {
9
+ const nodes = workflow.nodes.map((node) => this.toGraphNode(node));
10
+ return { nodes, edges: [] };
11
+ }
12
+ toGraphNode(node) {
13
+ if (node.type === MANUAL_TRIGGER_TYPE) {
14
+ return { id: node.id, name: node.name, type: 'trigger' };
15
+ }
16
+ if (this.isTriggerNode(node)) {
17
+ throw new errors_1.UnsupportedTriggerError(node.name, node.type);
18
+ }
19
+ if (node.onError === 'continueErrorOutput') {
20
+ throw new errors_1.UnsupportedWorkflowError(`Node "${node.name}" uses onError=continueErrorOutput, which is not supported yet.`);
21
+ }
22
+ const config = {
23
+ nodeType: node.type,
24
+ typeVersion: node.typeVersion,
25
+ parameters: node.parameters,
26
+ continueOnFail: node.continueOnFail === true || node.onError === 'continueRegularOutput',
27
+ };
28
+ return { id: node.id, name: node.name, type: 'v1-node', config };
29
+ }
30
+ isTriggerNode(node) {
31
+ return (node.type === MANUAL_TRIGGER_TYPE ||
32
+ KNOWN_TRIGGER_TYPES.has(node.type) ||
33
+ node.type.toLowerCase().endsWith('trigger'));
34
+ }
35
+ }
36
+ exports.V1WorkflowConverter = V1WorkflowConverter;
37
+ //# sourceMappingURL=v1-workflow-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v1-workflow-converter.js","sourceRoot":"","sources":["../src/v1-workflow-converter.ts"],"names":[],"mappings":";;;AAGA,qCAA6E;AAG7E,MAAM,mBAAmB,GAAG,8BAA8B,CAAC;AAQ3D,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,wBAAwB,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAUvF;IACC,OAAO,CAAC,QAAuB;QAC9B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QACnE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC7B,CAAC;IAEO,WAAW,CAAC,IAAW;QAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YACvC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC1D,CAAC;QAED,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,gCAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,KAAK,qBAAqB,EAAE,CAAC;YAC5C,MAAM,IAAI,iCAAwB,CACjC,SAAS,IAAI,CAAC,IAAI,iEAAiE,CACnF,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAqB;YAChC,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,cAAc,EAAE,IAAI,CAAC,cAAc,KAAK,IAAI,IAAI,IAAI,CAAC,OAAO,KAAK,uBAAuB;SACxF,CAAC;QAEF,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAClE,CAAC;IAGO,aAAa,CAAC,IAAW;QAChC,OAAO,CACN,IAAI,CAAC,IAAI,KAAK,mBAAmB;YACjC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAC3C,CAAC;IACH,CAAC;CACD"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@n8n/node-engine-compatibility",
3
+ "version": "0.1.0",
4
+ "description": "Adapts v1 nodes and workflows to the Engine 2.0 execution model",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*"
9
+ ],
10
+ "dependencies": {
11
+ "n8n-core": "2.33.0",
12
+ "@n8n/engine": "0.13.0",
13
+ "n8n-workflow": "2.33.0"
14
+ },
15
+ "devDependencies": {
16
+ "typescript": "7.0.2",
17
+ "vitest": "^4.1.9",
18
+ "@n8n/typescript-config": "1.9.0",
19
+ "@n8n/vitest-config": "1.19.0",
20
+ "n8n-nodes-base": "2.33.0"
21
+ },
22
+ "license": "LicenseRef-n8n-sustainable-use",
23
+ "scripts": {
24
+ "clean": "rimraf dist .turbo",
25
+ "typecheck": "tsc --noEmit",
26
+ "build": "tsc -p tsconfig.build.json",
27
+ "build:unchecked": "tsc -p tsconfig.build.json --noCheck",
28
+ "format": "biome format --write src",
29
+ "format:check": "biome ci src",
30
+ "lint": "eslint . --quiet",
31
+ "lint:fix": "eslint . --fix",
32
+ "test": "vitest run --passWithNoTests",
33
+ "test:dev": "vitest --watch",
34
+ "watch": "tsc -p tsconfig.build.json --watch"
35
+ }
36
+ }