@n8n/engine 0.11.1 → 0.13.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.
- package/dist/admittance/admittance-rejected.error.d.ts +4 -0
- package/dist/admittance/admittance-rejected.error.js +13 -0
- package/dist/admittance/admittance-rejected.error.js.map +1 -0
- package/dist/admittance/admittance.types.d.ts +12 -0
- package/dist/admittance/admittance.types.js +3 -0
- package/dist/admittance/admittance.types.js.map +1 -0
- package/dist/admittance/allow-all-admittance.d.ts +4 -0
- package/dist/admittance/allow-all-admittance.js +10 -0
- package/dist/admittance/allow-all-admittance.js.map +1 -0
- package/dist/admittance/index.d.ts +3 -0
- package/dist/admittance/index.js +8 -0
- package/dist/admittance/index.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -1
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +3 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/json.d.ts +4 -0
- package/dist/common/json.js +3 -0
- package/dist/common/json.js.map +1 -0
- package/dist/database/data-source.d.ts +3 -0
- package/dist/database/data-source.js +19 -0
- package/dist/database/data-source.js.map +1 -0
- package/dist/database/entities/index.d.ts +5 -0
- package/dist/database/entities/index.js +9 -0
- package/dist/database/entities/index.js.map +1 -0
- package/dist/database/entities/workflow-execution.entity.d.ts +15 -0
- package/dist/database/entities/workflow-execution.entity.js +78 -0
- package/dist/database/entities/workflow-execution.entity.js.map +1 -0
- package/dist/database/entities/workflow-step-execution.entity.d.ts +10 -0
- package/dist/database/entities/workflow-step-execution.entity.js +62 -0
- package/dist/database/entities/workflow-step-execution.entity.js.map +1 -0
- package/dist/database/generate-id.d.ts +1 -0
- package/dist/database/generate-id.js +8 -0
- package/dist/database/generate-id.js.map +1 -0
- package/dist/database/index.d.ts +4 -0
- package/dist/database/index.js +13 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/migrations/1778529600000-CreateWorkflowExecution.d.ts +5 -0
- package/dist/database/migrations/1778529600000-CreateWorkflowExecution.js +48 -0
- package/dist/database/migrations/1778529600000-CreateWorkflowExecution.js.map +1 -0
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.d.ts +5 -0
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js +52 -0
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js.map +1 -0
- package/dist/database/migrations/index.d.ts +2 -0
- package/dist/database/migrations/index.js +10 -0
- package/dist/database/migrations/index.js.map +1 -0
- package/dist/database/typeorm-execution-store.d.ts +10 -0
- package/dist/database/typeorm-execution-store.js +16 -0
- package/dist/database/typeorm-execution-store.js.map +1 -0
- package/dist/database/typeorm-step-store.d.ts +10 -0
- package/dist/database/typeorm-step-store.js +16 -0
- package/dist/database/typeorm-step-store.js.map +1 -0
- package/dist/dependencies/external-dependencies.d.ts +23 -0
- package/dist/dependencies/external-dependencies.js +3 -0
- package/dist/dependencies/external-dependencies.js.map +1 -0
- package/dist/dependencies/index.d.ts +1 -0
- package/dist/dependencies/index.js +3 -0
- package/dist/dependencies/index.js.map +1 -0
- package/dist/execution/execution-store.d.ts +15 -0
- package/dist/execution/execution-store.js +3 -0
- package/dist/execution/execution-store.js.map +1 -0
- package/dist/execution/execution.types.d.ts +3 -0
- package/dist/execution/execution.types.js +3 -0
- package/dist/execution/execution.types.js.map +1 -0
- package/dist/execution/index.d.ts +5 -0
- package/dist/execution/index.js +6 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/start-execution.service.d.ts +22 -0
- package/dist/execution/start-execution.service.js +34 -0
- package/dist/execution/start-execution.service.js.map +1 -0
- package/dist/execution/step-store.d.ts +11 -0
- package/dist/execution/step-store.js +3 -0
- package/dist/execution/step-store.js.map +1 -0
- package/dist/graph/index.d.ts +1 -0
- package/dist/graph/index.js +3 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/workflow-graph.d.ts +19 -0
- package/dist/graph/workflow-graph.js +3 -0
- package/dist/graph/workflow-graph.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/queue/in-memory-work-queue.d.ts +5 -0
- package/dist/queue/in-memory-work-queue.js +11 -0
- package/dist/queue/in-memory-work-queue.js.map +1 -0
- package/dist/queue/index.d.ts +2 -0
- package/dist/queue/index.js +6 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/queue/work-queue.types.d.ts +8 -0
- package/dist/queue/work-queue.types.js +3 -0
- package/dist/queue/work-queue.types.js.map +1 -0
- package/dist/serve.js +48 -19
- package/dist/serve.js.map +1 -1
- package/dist/server/create-engine-server.d.ts +9 -1
- package/dist/server/create-engine-server.js +10 -1
- package/dist/server/create-engine-server.js.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/routes/workflow-executions.d.ts +3 -0
- package/dist/server/routes/workflow-executions.js +65 -0
- package/dist/server/routes/workflow-executions.js.map +1 -0
- package/dist/testing/start-engine-server.d.ts +2 -1
- package/dist/testing/start-engine-server.js +2 -2
- package/dist/testing/start-engine-server.js.map +1 -1
- package/package.json +15 -8
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type AdmittanceService } from '../admittance';
|
|
2
|
+
import type { JsonObject } from '../common';
|
|
3
|
+
import type { WorkflowGraph } from '../graph';
|
|
4
|
+
import type { WorkQueue } from '../queue';
|
|
5
|
+
import type { ExecutionStore } from './execution-store';
|
|
6
|
+
import type { ExecutionMode } from './execution.types';
|
|
7
|
+
export interface StartExecutionRequest {
|
|
8
|
+
workflowId: string;
|
|
9
|
+
graph: WorkflowGraph;
|
|
10
|
+
triggerPayload?: JsonObject | null;
|
|
11
|
+
mode?: ExecutionMode;
|
|
12
|
+
}
|
|
13
|
+
export interface StartExecutionResult {
|
|
14
|
+
executionId: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class StartExecutionService {
|
|
17
|
+
private readonly admittance;
|
|
18
|
+
private readonly executionStore;
|
|
19
|
+
private readonly workQueue;
|
|
20
|
+
constructor(admittance: AdmittanceService, executionStore: ExecutionStore, workQueue: WorkQueue);
|
|
21
|
+
start(request: StartExecutionRequest): Promise<StartExecutionResult>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StartExecutionService = void 0;
|
|
4
|
+
const admittance_1 = require("../admittance");
|
|
5
|
+
class StartExecutionService {
|
|
6
|
+
admittance;
|
|
7
|
+
executionStore;
|
|
8
|
+
workQueue;
|
|
9
|
+
constructor(admittance, executionStore, workQueue) {
|
|
10
|
+
this.admittance = admittance;
|
|
11
|
+
this.executionStore = executionStore;
|
|
12
|
+
this.workQueue = workQueue;
|
|
13
|
+
}
|
|
14
|
+
async start(request) {
|
|
15
|
+
const decision = await this.admittance.evaluate({ workflowId: request.workflowId });
|
|
16
|
+
if (!decision.accept) {
|
|
17
|
+
throw new admittance_1.AdmittanceRejectedError(decision.reason);
|
|
18
|
+
}
|
|
19
|
+
const { id } = await this.executionStore.createExecution({
|
|
20
|
+
workflowId: request.workflowId,
|
|
21
|
+
status: 'queued',
|
|
22
|
+
mode: request.mode ?? 'production',
|
|
23
|
+
graph: request.graph,
|
|
24
|
+
triggerPayload: request.triggerPayload ?? null,
|
|
25
|
+
});
|
|
26
|
+
await this.workQueue.publish({
|
|
27
|
+
type: 'execution:enqueued',
|
|
28
|
+
executionId: id,
|
|
29
|
+
});
|
|
30
|
+
return { executionId: id };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.StartExecutionService = StartExecutionService;
|
|
34
|
+
//# sourceMappingURL=start-execution.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-execution.service.js","sourceRoot":"","sources":["../../src/execution/start-execution.service.ts"],"names":[],"mappings":";;;AAAA,8CAAgF;AAkBhF;IAEmB,UAAU;IACV,cAAc;IACd,SAAS;IAH3B,YACkB,UAA6B,EAC7B,cAA8B,EAC9B,SAAoB;0BAFpB,UAAU;8BACV,cAAc;yBACd,SAAS;IACxB,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,OAA8B;QACzC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QACpF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,IAAI,oCAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC;YACxD,UAAU,EAAE,OAAO,CAAC,UAAU;YAE9B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,YAAY;YAClC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,IAAI;SAC9C,CAAC,CAAC;QAKH,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5B,IAAI,EAAE,oBAAoB;YAC1B,WAAW,EAAE,EAAE;SACf,CAAC,CAAC;QAEH,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAC5B,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-store.js","sourceRoot":"","sources":["../../src/execution/step-store.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { GraphEdge, GraphNode, StepConfig, StepType, WorkflowGraph, } from './workflow-graph';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graph/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type StepType = 'trigger' | 'v1-node' | 'wait' | 'subworkflow' | 'batch';
|
|
2
|
+
export type StepConfig = unknown;
|
|
3
|
+
export interface GraphNode {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: StepType;
|
|
7
|
+
config?: StepConfig;
|
|
8
|
+
}
|
|
9
|
+
export interface GraphEdge {
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
outputIndex?: number;
|
|
13
|
+
inputIndex?: number;
|
|
14
|
+
isBackEdge?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface WorkflowGraph {
|
|
17
|
+
nodes: GraphNode[];
|
|
18
|
+
edges: GraphEdge[];
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-graph.js","sourceRoot":"","sources":["../../src/graph/workflow-graph.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
1
|
export { createEngineServer } from './server';
|
|
2
|
+
export type { EngineServerDeps } from './server';
|
|
3
|
+
export type { JsonObject, JsonValue } from './common';
|
|
4
|
+
export type { GraphEdge, GraphNode, StepConfig, StepType, WorkflowGraph, } from './graph';
|
|
5
|
+
export type { ExternalDependencies, IStepExecutor, StepExecutionContext, StepExecutionRequest, StepExecutionResult, } from './dependencies';
|
|
6
|
+
export { AllowAllAdmittance, AdmittanceRejectedError } from './admittance';
|
|
7
|
+
export type { AdmittanceDecision, AdmittanceRequest, AdmittanceService, } from './admittance';
|
|
8
|
+
export { InMemoryWorkQueue } from './queue';
|
|
9
|
+
export type { ExecutionEnqueuedEvent, WorkQueue, WorkQueueMessage, } from './queue';
|
|
10
|
+
export type { ExecutionMode, ExecutionStatus, ExecutionStore, NewExecutionRecord, NewStepRecord, StepStatus, StepStore, } from './execution';
|
|
11
|
+
export { createDataSource, TypeOrmExecutionStore, TypeOrmStepStore } from './database';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createEngineServer = void 0;
|
|
3
|
+
exports.TypeOrmStepStore = exports.TypeOrmExecutionStore = exports.createDataSource = exports.InMemoryWorkQueue = exports.AdmittanceRejectedError = exports.AllowAllAdmittance = exports.createEngineServer = void 0;
|
|
4
4
|
var server_1 = require("./server");
|
|
5
5
|
Object.defineProperty(exports, "createEngineServer", { enumerable: true, get: function () { return server_1.createEngineServer; } });
|
|
6
|
+
var admittance_1 = require("./admittance");
|
|
7
|
+
Object.defineProperty(exports, "AllowAllAdmittance", { enumerable: true, get: function () { return admittance_1.AllowAllAdmittance; } });
|
|
8
|
+
Object.defineProperty(exports, "AdmittanceRejectedError", { enumerable: true, get: function () { return admittance_1.AdmittanceRejectedError; } });
|
|
9
|
+
var queue_1 = require("./queue");
|
|
10
|
+
Object.defineProperty(exports, "InMemoryWorkQueue", { enumerable: true, get: function () { return queue_1.InMemoryWorkQueue; } });
|
|
11
|
+
var database_1 = require("./database");
|
|
12
|
+
Object.defineProperty(exports, "createDataSource", { enumerable: true, get: function () { return database_1.createDataSource; } });
|
|
13
|
+
Object.defineProperty(exports, "TypeOrmExecutionStore", { enumerable: true, get: function () { return database_1.TypeOrmExecutionStore; } });
|
|
14
|
+
Object.defineProperty(exports, "TypeOrmStepStore", { enumerable: true, get: function () { return database_1.TypeOrmStepStore; } });
|
|
6
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA;AAqB3B,2CAA2E;AAAlE,gHAAA,kBAAkB,OAAA;AAAE,qHAAA,uBAAuB,OAAA;AAOpD,iCAA4C;AAAnC,0GAAA,iBAAiB,OAAA;AAiB1B,uCAAuF;AAA9E,4GAAA,gBAAgB,OAAA;AAAE,iHAAA,qBAAqB,OAAA;AAAE,4GAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryWorkQueue = void 0;
|
|
4
|
+
class InMemoryWorkQueue {
|
|
5
|
+
messages = [];
|
|
6
|
+
async publish(message) {
|
|
7
|
+
this.messages.push(message);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.InMemoryWorkQueue = InMemoryWorkQueue;
|
|
11
|
+
//# sourceMappingURL=in-memory-work-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-work-queue.js","sourceRoot":"","sources":["../../src/queue/in-memory-work-queue.ts"],"names":[],"mappings":";;;AASA;IACU,QAAQ,GAAuB,EAAE,CAAC;IAG3C,KAAK,CAAC,OAAO,CAAC,OAAyB;QACtC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;CACD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryWorkQueue = void 0;
|
|
4
|
+
var in_memory_work_queue_1 = require("./in-memory-work-queue");
|
|
5
|
+
Object.defineProperty(exports, "InMemoryWorkQueue", { enumerable: true, get: function () { return in_memory_work_queue_1.InMemoryWorkQueue; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/queue/index.ts"],"names":[],"mappings":";;;AAKA,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work-queue.types.js","sourceRoot":"","sources":["../../src/queue/work-queue.types.ts"],"names":[],"mappings":""}
|
package/dist/serve.js
CHANGED
|
@@ -2,26 +2,55 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config_1 = require("@n8n/config");
|
|
4
4
|
const di_1 = require("@n8n/di");
|
|
5
|
+
const admittance_1 = require("./admittance");
|
|
6
|
+
const database_1 = require("./database");
|
|
7
|
+
const queue_1 = require("./queue");
|
|
5
8
|
const server_1 = require("./server");
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
async function main() {
|
|
10
|
+
const config = di_1.Container.get(config_1.EngineConfig);
|
|
11
|
+
let dataSource;
|
|
12
|
+
if (config.databaseUrl) {
|
|
13
|
+
dataSource = (0, database_1.createDataSource)(config.databaseUrl);
|
|
14
|
+
await dataSource.initialize();
|
|
15
|
+
await dataSource.runMigrations();
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.warn('engine: N8N_ENGINE_DATABASE_URL not set; running in healthcheck-only mode (workflow execution endpoints disabled)');
|
|
19
|
+
}
|
|
20
|
+
const { app } = (0, server_1.createEngineServer)(dataSource
|
|
21
|
+
? {
|
|
22
|
+
dataSource,
|
|
23
|
+
admittance: new admittance_1.AllowAllAdmittance(),
|
|
24
|
+
workQueue: new queue_1.InMemoryWorkQueue(),
|
|
21
25
|
}
|
|
22
|
-
|
|
26
|
+
: undefined);
|
|
27
|
+
const server = app.listen(config.port, config.host, () => {
|
|
28
|
+
console.log(`engine: listening on http://${config.host}:${config.port}`);
|
|
23
29
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
let shuttingDown = false;
|
|
31
|
+
const shutdown = async (signal) => {
|
|
32
|
+
if (shuttingDown)
|
|
33
|
+
return;
|
|
34
|
+
shuttingDown = true;
|
|
35
|
+
console.log(`engine: received ${signal}, shutting down`);
|
|
36
|
+
await new Promise((resolve, reject) => {
|
|
37
|
+
server.close((error) => (error ? reject(error) : resolve()));
|
|
38
|
+
});
|
|
39
|
+
if (dataSource?.isInitialized)
|
|
40
|
+
await dataSource.destroy();
|
|
41
|
+
process.exit(0);
|
|
42
|
+
};
|
|
43
|
+
const onSignal = (signal) => {
|
|
44
|
+
shutdown(signal).catch((error) => {
|
|
45
|
+
console.error('engine: error during shutdown', error);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
process.on('SIGTERM', () => onSignal('SIGTERM'));
|
|
50
|
+
process.on('SIGINT', () => onSignal('SIGINT'));
|
|
51
|
+
}
|
|
52
|
+
main().catch((error) => {
|
|
53
|
+
console.error('engine: failed to start', error);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
});
|
|
27
56
|
//# sourceMappingURL=serve.js.map
|
package/dist/serve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":";;AAAA,wCAA2C;AAC3C,gCAAoC;
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":";;AAAA,wCAA2C;AAC3C,gCAAoC;AAGpC,6CAAkD;AAClD,yCAA8C;AAC9C,mCAA4C;AAC5C,qCAA8C;AAE9C,KAAK,UAAU,IAAI;IAClB,MAAM,MAAM,GAAG,cAAS,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC;IAE3C,IAAI,UAAkC,CAAC;IACvC,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACxB,UAAU,GAAG,IAAA,2BAAgB,EAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAClD,MAAM,UAAU,CAAC,UAAU,EAAE,CAAC;QAC9B,MAAM,UAAU,CAAC,aAAa,EAAE,CAAC;I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AAC,KAAc,EAAE,EAAE;YACzC,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC/B,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import type { DataSource } from '@n8n/typeorm';
|
|
1
2
|
import { type Application } from 'express';
|
|
2
|
-
|
|
3
|
+
import type { AdmittanceService } from '../admittance';
|
|
4
|
+
import type { WorkQueue } from '../queue';
|
|
5
|
+
export interface EngineServerDeps {
|
|
6
|
+
dataSource: DataSource;
|
|
7
|
+
admittance: AdmittanceService;
|
|
8
|
+
workQueue: WorkQueue;
|
|
9
|
+
}
|
|
10
|
+
export declare function createEngineServer(deps?: EngineServerDeps): {
|
|
3
11
|
app: Application;
|
|
4
12
|
};
|
|
@@ -5,11 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createEngineServer = createEngineServer;
|
|
7
7
|
const express_1 = __importDefault(require("express"));
|
|
8
|
-
|
|
8
|
+
const database_1 = require("../database");
|
|
9
|
+
const start_execution_service_1 = require("../execution/start-execution.service");
|
|
10
|
+
const workflow_executions_1 = require("./routes/workflow-executions");
|
|
11
|
+
function createEngineServer(deps) {
|
|
9
12
|
const app = (0, express_1.default)();
|
|
13
|
+
app.use(express_1.default.json());
|
|
10
14
|
app.get('/healthz', (_req, res) => {
|
|
11
15
|
res.status(200).json({ status: 'ok' });
|
|
12
16
|
});
|
|
17
|
+
if (deps) {
|
|
18
|
+
const executionStore = new database_1.TypeOrmExecutionStore(deps.dataSource.getRepository(database_1.WorkflowExecution));
|
|
19
|
+
const startExecution = new start_execution_service_1.StartExecutionService(deps.admittance, executionStore, deps.workQueue);
|
|
20
|
+
app.use('/api/workflow-executions', (0, workflow_executions_1.createWorkflowExecutionsRouter)(startExecution));
|
|
21
|
+
}
|
|
13
22
|
return { app };
|
|
14
23
|
}
|
|
15
24
|
//# sourceMappingURL=create-engine-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-engine-server.js","sourceRoot":"","sources":["../../src/server/create-engine-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-engine-server.js","sourceRoot":"","sources":["../../src/server/create-engine-server.ts"],"names":[],"mappings":";;;;;;AACA,sDAAoD;AAGpD,0CAAuE;AACvE,kFAA6E;AAE7E,sEAA8E;AAa9E,4BAAmC,IAAuB;IACzD,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAExB,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QACjC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,IAAI,IAAI,EAAE,CAAC;QACV,MAAM,cAAc,GAAG,IAAI,gCAAqB,CAC/C,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,4BAAiB,CAAC,CAChD,CAAC;QACF,MAAM,cAAc,GAAG,IAAI,+CAAqB,CAC/C,IAAI,CAAC,UAAU,EACf,cAAc,EACd,IAAI,CAAC,SAAS,CACd,CAAC;QACF,GAAG,CAAC,GAAG,CAAC,0BAA0B,EAAE,IAAA,oDAA8B,EAAC,cAAc,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,CAAC;AAChB,CAAC"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWorkflowExecutionsRouter = createWorkflowExecutionsRouter;
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const admittance_1 = require("../../admittance");
|
|
7
|
+
const jsonValueSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
8
|
+
zod_1.z.string(),
|
|
9
|
+
zod_1.z.number(),
|
|
10
|
+
zod_1.z.boolean(),
|
|
11
|
+
zod_1.z.null(),
|
|
12
|
+
zod_1.z.array(jsonValueSchema),
|
|
13
|
+
zod_1.z.record(jsonValueSchema),
|
|
14
|
+
]));
|
|
15
|
+
const jsonObjectSchema = zod_1.z.record(jsonValueSchema);
|
|
16
|
+
const StepTypeSchema = zod_1.z.enum(['trigger', 'v1-node', 'wait', 'subworkflow', 'batch']);
|
|
17
|
+
const GraphNodeSchema = zod_1.z.object({
|
|
18
|
+
id: zod_1.z.string(),
|
|
19
|
+
name: zod_1.z.string(),
|
|
20
|
+
type: StepTypeSchema,
|
|
21
|
+
config: zod_1.z.unknown().optional(),
|
|
22
|
+
});
|
|
23
|
+
const GraphEdgeSchema = zod_1.z.object({
|
|
24
|
+
from: zod_1.z.string(),
|
|
25
|
+
to: zod_1.z.string(),
|
|
26
|
+
outputIndex: zod_1.z.number().int().nonnegative().optional(),
|
|
27
|
+
inputIndex: zod_1.z.number().int().nonnegative().optional(),
|
|
28
|
+
isBackEdge: zod_1.z.boolean().optional(),
|
|
29
|
+
});
|
|
30
|
+
const WorkflowGraphSchema = zod_1.z.object({
|
|
31
|
+
nodes: zod_1.z.array(GraphNodeSchema),
|
|
32
|
+
edges: zod_1.z.array(GraphEdgeSchema),
|
|
33
|
+
});
|
|
34
|
+
const StartExecutionBody = zod_1.z.object({
|
|
35
|
+
workflowId: zod_1.z.string().min(1),
|
|
36
|
+
graph: WorkflowGraphSchema,
|
|
37
|
+
triggerPayload: jsonObjectSchema.nullable().optional(),
|
|
38
|
+
mode: zod_1.z.enum(['production', 'manual']).optional(),
|
|
39
|
+
});
|
|
40
|
+
function createWorkflowExecutionsRouter(startExecution) {
|
|
41
|
+
const router = (0, express_1.Router)();
|
|
42
|
+
router.post('/', async (req, res) => {
|
|
43
|
+
const parsed = StartExecutionBody.safeParse(req.body);
|
|
44
|
+
if (!parsed.success) {
|
|
45
|
+
res.status(400).json({
|
|
46
|
+
error: 'invalid_request',
|
|
47
|
+
details: parsed.error.flatten(),
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const result = await startExecution.start(parsed.data);
|
|
53
|
+
res.status(201).json(result);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error instanceof admittance_1.AdmittanceRejectedError) {
|
|
57
|
+
res.status(429).json({ error: 'admittance_rejected', reason: error.reason });
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return router;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=workflow-executions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-executions.js","sourceRoot":"","sources":["../../../src/server/routes/workflow-executions.ts"],"names":[],"mappings":";;;AAAA,qCAA4D;AAC5D,6BAAwB;AAExB,iDAA2D;AAI3D,MAAM,eAAe,GAAyB,OAAC,CAAC,IAAI,CAAC,GAAG,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AAM,EAAE,CAAC,CAAC;gBAC7E,OAAO;YACR,CAAC;YACD,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.startEngineServer = startEngineServer;
|
|
4
4
|
const server_1 = require("../server");
|
|
5
|
-
async function startEngineServer() {
|
|
6
|
-
const { app } = (0, server_1.createEngineServer)();
|
|
5
|
+
async function startEngineServer(deps) {
|
|
6
|
+
const { app } = (0, server_1.createEngineServer)(deps);
|
|
7
7
|
const server = await new Promise((resolve, reject) => {
|
|
8
8
|
const s = app.listen(0, '127.0.0.1', () => resolve(s));
|
|
9
9
|
s.on('error', reject);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-engine-server.js","sourceRoot":"","sources":["../../src/testing/start-engine-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start-engine-server.js","sourceRoot":"","sources":["../../src/testing/start-engine-server.ts"],"names":[],"mappings":";;;AAEA,sCAAsE;AAE/D,KAAK,4BAA4B,IAAuB;IAI9D,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC;IAEzC,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC5D,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IACjC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,GAAG,GAAG,oBAAoB,OAAO,CAAC,IAAI,EAAE,CAAC;IAE/C,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;QACtC,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtB,IAAI,KAAK;oBAAE,MAAM,CAAC,KAAK,CAAC,CAAC;;oBACpB,OAAO,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "n8n workflow execution engine (v2)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist/**/*",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"LICENSE_EE.md",
|
|
10
|
+
"LICENSE.md"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"express": "5.1.0",
|
|
14
|
+
"pg": "8.21.0",
|
|
14
15
|
"reflect-metadata": "0.2.2",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
16
|
+
"uuid": "11.1.1",
|
|
17
|
+
"zod": "3.25.67",
|
|
18
|
+
"@n8n/config": "2.31.0",
|
|
19
|
+
"@n8n/di": "0.16.0",
|
|
20
|
+
"@n8n/typeorm": "0.7.0"
|
|
17
21
|
},
|
|
18
22
|
"devDependencies": {
|
|
23
|
+
"@testcontainers/postgresql": "^11.13.0",
|
|
19
24
|
"@types/express": "^5.0.1",
|
|
25
|
+
"@types/pg": "^8.15.6",
|
|
20
26
|
"@types/supertest": "^6.0.3",
|
|
21
27
|
"supertest": "^7.1.1",
|
|
22
|
-
"
|
|
28
|
+
"testcontainers": "^11.13.0",
|
|
29
|
+
"typescript": "7.0.2",
|
|
23
30
|
"vitest": "^4.1.9",
|
|
24
|
-
"@n8n/
|
|
25
|
-
"@n8n/
|
|
31
|
+
"@n8n/typescript-config": "1.9.0",
|
|
32
|
+
"@n8n/vitest-config": "1.19.0"
|
|
26
33
|
},
|
|
27
34
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
28
35
|
"homepage": "https://n8n.io",
|