@n8n/engine 0.13.1 → 0.15.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/build.tsbuildinfo +1 -1
- package/dist/common/errors.d.ts +6 -0
- package/dist/common/errors.js +18 -0
- package/dist/common/errors.js.map +1 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +4 -0
- package/dist/common/index.js.map +1 -1
- package/dist/database/entities/workflow-step-execution.entity.d.ts +4 -1
- package/dist/database/entities/workflow-step-execution.entity.js +13 -1
- package/dist/database/entities/workflow-step-execution.entity.js.map +1 -1
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js +17 -1
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js.map +1 -1
- package/dist/database/typeorm-execution-store.d.ts +5 -1
- package/dist/database/typeorm-execution-store.js +16 -1
- package/dist/database/typeorm-execution-store.js.map +1 -1
- package/dist/database/typeorm-step-store.d.ts +16 -4
- package/dist/database/typeorm-step-store.js +91 -4
- package/dist/database/typeorm-step-store.js.map +1 -1
- package/dist/dependencies/external-dependencies.d.ts +3 -4
- package/dist/execution/execution-start-handler.d.ts +10 -0
- package/dist/execution/execution-start-handler.js +43 -0
- package/dist/execution/execution-start-handler.js.map +1 -0
- package/dist/execution/execution-store.d.ts +15 -0
- package/dist/execution/execution-store.js +10 -0
- package/dist/execution/execution-store.js.map +1 -1
- package/dist/execution/execution.types.d.ts +2 -0
- package/dist/execution/index.d.ts +10 -3
- package/dist/execution/index.js +15 -1
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/orchestration-worker.d.ts +11 -0
- package/dist/execution/orchestration-worker.js +35 -0
- package/dist/execution/orchestration-worker.js.map +1 -0
- package/dist/execution/start-execution.service.d.ts +4 -3
- package/dist/execution/start-execution.service.js +5 -1
- package/dist/execution/start-execution.service.js.map +1 -1
- package/dist/execution/step-completed-handler.d.ts +13 -0
- package/dist/execution/step-completed-handler.js +74 -0
- package/dist/execution/step-completed-handler.js.map +1 -0
- package/dist/execution/step-ready-handler.d.ts +16 -0
- package/dist/execution/step-ready-handler.js +112 -0
- package/dist/execution/step-ready-handler.js.map +1 -0
- package/dist/execution/step-store.d.ts +33 -3
- package/dist/execution/step-store.js +10 -0
- package/dist/execution/step-store.js.map +1 -1
- package/dist/execution/step-worker.d.ts +9 -0
- package/dist/execution/step-worker.js +30 -0
- package/dist/execution/step-worker.js.map +1 -0
- package/dist/execution/validate-step-context.d.ts +4 -0
- package/dist/execution/validate-step-context.js +15 -0
- package/dist/execution/validate-step-context.js.map +1 -0
- package/dist/graph/index.d.ts +2 -0
- package/dist/graph/index.js +8 -0
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/validate-executable-graph.d.ts +5 -0
- package/dist/graph/validate-executable-graph.js +41 -0
- package/dist/graph/validate-executable-graph.js.map +1 -0
- package/dist/graph/workflow-graph-queries.d.ts +4 -0
- package/dist/graph/workflow-graph-queries.js +27 -0
- package/dist/graph/workflow-graph-queries.js.map +1 -0
- package/dist/graph/workflow-graph.d.ts +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/queue/in-memory-work-queue.d.ts +11 -4
- package/dist/queue/in-memory-work-queue.js +44 -2
- package/dist/queue/in-memory-work-queue.js.map +1 -1
- package/dist/queue/index.d.ts +1 -1
- package/dist/queue/index.js.map +1 -1
- package/dist/queue/work-queue.types.d.ts +16 -3
- package/dist/serve.js +18 -5
- package/dist/serve.js.map +1 -1
- package/dist/server/create-engine-server.d.ts +2 -2
- package/dist/server/routes/workflow-executions.js +12 -2
- package/dist/server/routes/workflow-executions.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnexpectedError = exports.UnimplementedError = void 0;
|
|
4
|
+
class UnimplementedError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'UnimplementedError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.UnimplementedError = UnimplementedError;
|
|
11
|
+
class UnexpectedError extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'UnexpectedError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.UnexpectedError = UnexpectedError;
|
|
18
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/common/errors.ts"],"names":[],"mappings":";;;AAMA,wBAAgC,SAAQ,KAAK;IAC5C,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IAClC,CAAC;CACD;;AAMD,qBAA6B,SAAQ,KAAK;IACzC,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD"}
|
package/dist/common/index.d.ts
CHANGED
package/dist/common/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnimplementedError = exports.UnexpectedError = void 0;
|
|
4
|
+
var errors_1 = require("./errors");
|
|
5
|
+
Object.defineProperty(exports, "UnexpectedError", { enumerable: true, get: function () { return errors_1.UnexpectedError; } });
|
|
6
|
+
Object.defineProperty(exports, "UnimplementedError", { enumerable: true, get: function () { return errors_1.UnimplementedError; } });
|
|
3
7
|
//# sourceMappingURL=index.js.map
|
package/dist/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;AACA,mCAA+D;AAAtD,yGAAA,eAAe,OAAA;AAAE,4GAAA,kBAAkB,OAAA"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { StepStatus } from '../../execution/execution.types';
|
|
1
|
+
import type { StepSlots, StepStatus } from '../../execution/execution.types';
|
|
2
|
+
import type { StepError } from '../../execution/step-store';
|
|
2
3
|
export declare class WorkflowStepExecution {
|
|
3
4
|
id: string;
|
|
4
5
|
executionId: string;
|
|
5
6
|
nodeId: string;
|
|
6
7
|
status: StepStatus;
|
|
8
|
+
outputs: StepSlots | null;
|
|
9
|
+
error: StepError | null;
|
|
7
10
|
createdAt: Date;
|
|
8
11
|
updatedAt: Date;
|
|
9
12
|
setId(): void;
|
|
@@ -17,6 +17,8 @@ let WorkflowStepExecution = class WorkflowStepExecution {
|
|
|
17
17
|
executionId;
|
|
18
18
|
nodeId;
|
|
19
19
|
status;
|
|
20
|
+
outputs;
|
|
21
|
+
error;
|
|
20
22
|
createdAt;
|
|
21
23
|
updatedAt;
|
|
22
24
|
setId() {
|
|
@@ -41,6 +43,14 @@ __decorate([
|
|
|
41
43
|
(0, typeorm_1.Column)('varchar', { length: 32 }),
|
|
42
44
|
__metadata("design:type", String)
|
|
43
45
|
], WorkflowStepExecution.prototype, "status", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)('jsonb', { nullable: true }),
|
|
48
|
+
__metadata("design:type", Object)
|
|
49
|
+
], WorkflowStepExecution.prototype, "outputs", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)('jsonb', { nullable: true }),
|
|
52
|
+
__metadata("design:type", Object)
|
|
53
|
+
], WorkflowStepExecution.prototype, "error", void 0);
|
|
44
54
|
__decorate([
|
|
45
55
|
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz', precision: 3 }),
|
|
46
56
|
__metadata("design:type", Date)
|
|
@@ -57,6 +67,8 @@ __decorate([
|
|
|
57
67
|
], WorkflowStepExecution.prototype, "setId", null);
|
|
58
68
|
exports.WorkflowStepExecution = WorkflowStepExecution = __decorate([
|
|
59
69
|
(0, typeorm_1.Entity)('workflow_step_execution'),
|
|
60
|
-
(0, typeorm_1.Index)('
|
|
70
|
+
(0, typeorm_1.Index)('uniq_workflow_step_execution_execution_id_node_id', ['executionId', 'nodeId'], {
|
|
71
|
+
unique: true,
|
|
72
|
+
})
|
|
61
73
|
], WorkflowStepExecution);
|
|
62
74
|
//# sourceMappingURL=workflow-step-execution.entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-step-execution.entity.js","sourceRoot":"","sources":["../../../src/database/entities/workflow-step-execution.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAQsB;
|
|
1
|
+
{"version":3,"file":"workflow-step-execution.entity.js","sourceRoot":"","sources":["../../../src/database/entities/workflow-step-execution.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAQsB;AAItB,gDAA4C;AAMrC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEjC,EAAE,CAAU;IAGZ,WAAW,CAAU;IAGrB,MAAM,CAAU;IAGhB,MAAM,CAAc;IAGpB,OAAO,CAAoB;IAG3B,KAAK,CAAoB;IAGzB,SAAS,CAAQ;IAGjB,SAAS,CAAQ;IAGjB,KAAK;QACJ,IAAI,CAAC,IAAI,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAU,GAAE,CAAC;IACtC,CAAC;CACD,CAAA;;AA3BA;IADC,IAAA,uBAAa,EAAC,MAAM,CAAC;;iDACV;AAGZ;IADC,IAAA,gBAAM,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;;0DACpB;AAGrB;IADC,IAAA,gBAAM,EAAC,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;qDACvB;AAGhB;IADC,IAAA,gBAAM,EAAC,SAAS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;qDACd;AAGpB;IADC,IAAA,gBAAM,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACT;AAG3B;IADC,IAAA,gBAAM,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACX;AAGzB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;8BAChE,IAAI;wDAAC;AAGjB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;8BAChE,IAAI;wDAAC;AAGjB;IADC,IAAA,sBAAY,GAAE;;;;kDAGd;gCA5BW,qBAAqB;IAJjC,IAAA,gBAAM,EAAC,yBAAyB,CAAC;IACjC,IAAA,eAAK,EAAC,mDAAmD,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE;QACtF,MAAM,EAAE,IAAI;KACZ,CAAC;GACW,qBAAqB,CA6BjC"}
|
|
@@ -12,6 +12,18 @@ class CreateWorkflowStepExecution1784890100000 {
|
|
|
12
12
|
{ name: 'execution_id', type: 'uuid' },
|
|
13
13
|
{ name: 'node_id', type: 'varchar' },
|
|
14
14
|
{ name: 'status', type: 'varchar', length: '32' },
|
|
15
|
+
{
|
|
16
|
+
name: 'outputs',
|
|
17
|
+
type: 'jsonb',
|
|
18
|
+
isNullable: true,
|
|
19
|
+
comment: 'Step outputs, persisted without inspection and reloaded as downstream inputs. Shape is step-type-specific.',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'error',
|
|
23
|
+
type: 'jsonb',
|
|
24
|
+
isNullable: true,
|
|
25
|
+
comment: 'Name and message of the error that failed this step.',
|
|
26
|
+
},
|
|
15
27
|
{
|
|
16
28
|
name: 'created_at',
|
|
17
29
|
type: 'timestamptz',
|
|
@@ -26,7 +38,11 @@ class CreateWorkflowStepExecution1784890100000 {
|
|
|
26
38
|
},
|
|
27
39
|
],
|
|
28
40
|
indices: [
|
|
29
|
-
{
|
|
41
|
+
{
|
|
42
|
+
name: 'uniq_workflow_step_execution_execution_id_node_id',
|
|
43
|
+
columnNames: ['execution_id', 'node_id'],
|
|
44
|
+
isUnique: true,
|
|
45
|
+
},
|
|
30
46
|
],
|
|
31
47
|
foreignKeys: [
|
|
32
48
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1784890100000-CreateWorkflowStepExecution.js","sourceRoot":"","sources":["../../../src/database/migrations/1784890100000-CreateWorkflowStepExecution.ts"],"names":[],"mappings":";;;AAAA,0CAAqC;AAGrC,MAAM,KAAK,GAAG,yBAAyB,CAAC;AAExC;IACC,KAAK,CAAC,EAAE,CAAC,WAAwB;QAChC,MAAM,WAAW,CAAC,WAAW,CAC5B,IAAI,eAAK,CAAC;YACT,IAAI,EAAE,KAAK;YACX,OAAO,EAAE;gBACR,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE;gBAC7C,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE;gBACtC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;gBACpC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE;gBACjD;oBACC,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,aAAa;oBACnB,SAAS,EAAE,CAAC;oBACZ,OAAO,EAAE,sBAAsB;iBAC/B;gBACD;oBACC,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,aAAa;oBACnB,SAAS,EAAE,CAAC;oBACZ,OAAO,EAAE,sBAAsB;iBAC/B;aACD;YACD,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"1784890100000-CreateWorkflowStepExecution.js","sourceRoot":"","sources":["../../../src/database/migrations/1784890100000-CreateWorkflowStepExecution.ts"],"names":[],"mappings":";;;AAAA,0CAAqC;AAGrC,MAAM,KAAK,GAAG,yBAAyB,CAAC;AAExC;IACC,KAAK,CAAC,EAAE,CAAC,WAAwB;QAChC,MAAM,WAAW,CAAC,WAAW,CAC5B,IAAI,eAAK,CAAC;YACT,IAAI,EAAE,KAAK;YACX,OAAO,EAAE;gBACR,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE;gBAC7C,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE;gBACtC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;gBACpC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE;gBACjD;oBACC,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,OAAO;oBACb,UAAU,EAAE,IAAI;oBAChB,OAAO,EACN,4GAA4G;iBAC7G;gBACD;oBACC,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,OAAO;oBACb,UAAU,EAAE,IAAI;oBAChB,OAAO,EAAE,sDAAsD;iBAC/D;gBACD;oBACC,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,aAAa;oBACnB,SAAS,EAAE,CAAC;oBACZ,OAAO,EAAE,sBAAsB;iBAC/B;gBACD;oBACC,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,aAAa;oBACnB,SAAS,EAAE,CAAC;oBACZ,OAAO,EAAE,sBAAsB;iBAC/B;aACD;YACD,OAAO,EAAE;gBAIR;oBACC,IAAI,EAAE,mDAAmD;oBACzD,WAAW,EAAE,CAAC,cAAc,EAAE,SAAS,CAAC;oBACxC,QAAQ,EAAE,IAAI;iBACd;aACD;YACD,WAAW,EAAE;gBACZ;oBACC,WAAW,EAAE,CAAC,cAAc,CAAC;oBAC7B,mBAAmB,EAAE,oBAAoB;oBACzC,qBAAqB,EAAE,CAAC,IAAI,CAAC;oBAC7B,QAAQ,EAAE,SAAS;iBACnB;aACD;YACD,MAAM,EAAE;gBACP;oBACC,IAAI,EAAE,oCAAoC;oBAC1C,UAAU,EAAE,qEAAqE;iBACjF;aACD;SACD,CAAC,CACF,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,WAAwB;QAClC,MAAM,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACD"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { Repository } from '@n8n/typeorm';
|
|
2
2
|
import type { WorkflowExecution } from './entities';
|
|
3
|
-
import type
|
|
3
|
+
import { type ExecutionRecord, type ExecutionStore, type NewExecutionRecord } from '../execution/execution-store';
|
|
4
|
+
import type { ExecutionStatus } from '../execution/execution.types';
|
|
4
5
|
export declare class TypeOrmExecutionStore implements ExecutionStore {
|
|
5
6
|
private readonly repo;
|
|
6
7
|
constructor(repo: Repository<WorkflowExecution>);
|
|
7
8
|
createExecution(record: NewExecutionRecord): Promise<{
|
|
8
9
|
id: string;
|
|
9
10
|
}>;
|
|
11
|
+
loadExecution(id: string): Promise<ExecutionRecord>;
|
|
12
|
+
transitionStatus(id: string, from: ExecutionStatus, to: ExecutionStatus): Promise<boolean>;
|
|
13
|
+
finishExecution(id: string, status: 'completed' | 'failed'): Promise<boolean>;
|
|
10
14
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeOrmExecutionStore = void 0;
|
|
4
|
+
const execution_store_1 = require("../execution/execution-store");
|
|
4
5
|
class TypeOrmExecutionStore {
|
|
5
6
|
repo;
|
|
6
7
|
constructor(repo) {
|
|
@@ -8,9 +9,23 @@ class TypeOrmExecutionStore {
|
|
|
8
9
|
}
|
|
9
10
|
async createExecution(record) {
|
|
10
11
|
const execution = this.repo.create({ ...record, finishedAt: null });
|
|
11
|
-
await this.repo.
|
|
12
|
+
await this.repo.insert(execution);
|
|
12
13
|
return { id: execution.id };
|
|
13
14
|
}
|
|
15
|
+
async loadExecution(id) {
|
|
16
|
+
const row = await this.repo.findOneBy({ id });
|
|
17
|
+
if (!row)
|
|
18
|
+
throw new execution_store_1.ExecutionNotFoundError(id);
|
|
19
|
+
return row;
|
|
20
|
+
}
|
|
21
|
+
async transitionStatus(id, from, to) {
|
|
22
|
+
const result = await this.repo.update({ id, status: from }, { status: to });
|
|
23
|
+
return result.affected === 1;
|
|
24
|
+
}
|
|
25
|
+
async finishExecution(id, status) {
|
|
26
|
+
const result = await this.repo.update({ id, status: 'running' }, { status, finishedAt: new Date() });
|
|
27
|
+
return result.affected === 1;
|
|
28
|
+
}
|
|
14
29
|
}
|
|
15
30
|
exports.TypeOrmExecutionStore = TypeOrmExecutionStore;
|
|
16
31
|
//# sourceMappingURL=typeorm-execution-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeorm-execution-store.js","sourceRoot":"","sources":["../../src/database/typeorm-execution-store.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"typeorm-execution-store.js","sourceRoot":"","sources":["../../src/database/typeorm-execution-store.ts"],"names":[],"mappings":";;;AAGA,kEAKsC;AAUtC;IAC8B,IAAI;IAAjC,YAA6B,IAAmC;oBAAnC,IAAI;IAAkC,CAAC;IAEpE,KAAK,CAAC,eAAe,CAAC,MAA0B;QAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAIpE,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAyB,CAAC,CAAC;QAClD,OAAO,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU;QAC7B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,wCAAsB,CAAC,EAAE,CAAC,CAAC;QAC/C,OAAO,GAAG,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,EAAU,EAAE,IAAqB,EAAE,EAAmB;QAC5E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5E,OAAO,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,EAAU,EAAE,MAA8B;QAC/D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CACpC,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EACzB,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,IAAI,EAAE,EAAE,CAClC,CAAC;QACF,OAAO,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC;IAC9B,CAAC;CACD"}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Repository } from '@n8n/typeorm';
|
|
2
2
|
import type { WorkflowStepExecution } from './entities';
|
|
3
|
-
import type {
|
|
3
|
+
import type { StepSlots } from '../execution/execution.types';
|
|
4
|
+
import { type NewStepRecord, type StepError, type StepRecord, type StepStore } from '../execution/step-store';
|
|
4
5
|
export declare class TypeOrmStepStore implements StepStore {
|
|
5
6
|
private readonly repo;
|
|
6
7
|
constructor(repo: Repository<WorkflowStepExecution>);
|
|
7
|
-
|
|
8
|
+
createSteps(records: NewStepRecord[]): Promise<Array<{
|
|
8
9
|
id: string;
|
|
9
|
-
|
|
10
|
+
nodeId: string;
|
|
11
|
+
}>>;
|
|
12
|
+
loadStep(id: string): Promise<StepRecord>;
|
|
13
|
+
claimStep(id: string): Promise<StepRecord | null>;
|
|
14
|
+
completeStep(id: string, outputs: StepSlots): Promise<boolean>;
|
|
15
|
+
cancelQueuedSteps(executionId: string): Promise<void>;
|
|
16
|
+
failStep(id: string, error: StepError): Promise<boolean>;
|
|
17
|
+
private transition;
|
|
18
|
+
loadStepOutputs(executionId: string, nodeIds: string[]): Promise<Record<string, StepSlots | null>>;
|
|
19
|
+
loadCompletedNodeIds(executionId: string, nodeIds: string[]): Promise<Set<string>>;
|
|
20
|
+
hasActiveSteps(executionId: string): Promise<boolean>;
|
|
21
|
+
hasFailedSteps(executionId: string): Promise<boolean>;
|
|
10
22
|
}
|
|
@@ -1,15 +1,102 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeOrmStepStore = void 0;
|
|
4
|
+
const typeorm_1 = require("@n8n/typeorm");
|
|
5
|
+
const generate_id_1 = require("./generate-id");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const step_store_1 = require("../execution/step-store");
|
|
4
8
|
class TypeOrmStepStore {
|
|
5
9
|
repo;
|
|
6
10
|
constructor(repo) {
|
|
7
11
|
this.repo = repo;
|
|
8
12
|
}
|
|
9
|
-
async
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
async createSteps(records) {
|
|
14
|
+
if (records.length === 0)
|
|
15
|
+
return [];
|
|
16
|
+
for (const record of records) {
|
|
17
|
+
if (record.outputs && record.status !== 'completed') {
|
|
18
|
+
throw new common_1.UnexpectedError(`step for node ${record.nodeId} carries outputs but is created ${record.status}; only a step created completed may carry outputs`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const rows = records.map((record) => ({ ...record, id: (0, generate_id_1.generateId)() }));
|
|
22
|
+
const result = await this.repo
|
|
23
|
+
.createQueryBuilder()
|
|
24
|
+
.insert()
|
|
25
|
+
.values(rows)
|
|
26
|
+
.orIgnore()
|
|
27
|
+
.returning(['id', 'nodeId'])
|
|
28
|
+
.execute();
|
|
29
|
+
return result.raw.map(({ id, node_id: nodeId }) => ({ id, nodeId }));
|
|
30
|
+
}
|
|
31
|
+
async loadStep(id) {
|
|
32
|
+
const row = await this.repo.findOne({ where: { id } });
|
|
33
|
+
if (!row)
|
|
34
|
+
throw new step_store_1.StepNotFoundError(id);
|
|
35
|
+
return row;
|
|
36
|
+
}
|
|
37
|
+
async claimStep(id) {
|
|
38
|
+
const result = await this.repo
|
|
39
|
+
.createQueryBuilder()
|
|
40
|
+
.update()
|
|
41
|
+
.set({ status: 'running' })
|
|
42
|
+
.where({ id, status: 'queued' })
|
|
43
|
+
.returning(['id', 'executionId', 'nodeId'])
|
|
44
|
+
.execute();
|
|
45
|
+
const [row] = result.raw;
|
|
46
|
+
if (!row)
|
|
47
|
+
return null;
|
|
48
|
+
return {
|
|
49
|
+
id: row.id,
|
|
50
|
+
executionId: row.execution_id,
|
|
51
|
+
nodeId: row.node_id,
|
|
52
|
+
status: 'running',
|
|
53
|
+
outputs: null,
|
|
54
|
+
error: null,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async completeStep(id, outputs) {
|
|
58
|
+
return await this.transition(id, 'running', 'completed', { outputs });
|
|
59
|
+
}
|
|
60
|
+
async cancelQueuedSteps(executionId) {
|
|
61
|
+
await this.repo.update({ executionId, status: 'queued' }, { status: 'cancelled' });
|
|
62
|
+
}
|
|
63
|
+
async failStep(id, error) {
|
|
64
|
+
return await this.transition(id, 'running', 'failed', { error });
|
|
65
|
+
}
|
|
66
|
+
async transition(id, from, to, fields = {}) {
|
|
67
|
+
const result = await this.repo.update({ id, status: from }, { ...fields, status: to });
|
|
68
|
+
return result.affected === 1;
|
|
69
|
+
}
|
|
70
|
+
async loadStepOutputs(executionId, nodeIds) {
|
|
71
|
+
const outputsByNodeId = {};
|
|
72
|
+
for (const nodeId of nodeIds)
|
|
73
|
+
outputsByNodeId[nodeId] = null;
|
|
74
|
+
if (nodeIds.length === 0)
|
|
75
|
+
return outputsByNodeId;
|
|
76
|
+
const rows = await this.repo.find({
|
|
77
|
+
where: { executionId, nodeId: (0, typeorm_1.In)(nodeIds), status: 'completed' },
|
|
78
|
+
select: ['nodeId', 'outputs'],
|
|
79
|
+
});
|
|
80
|
+
for (const row of rows)
|
|
81
|
+
outputsByNodeId[row.nodeId] = row.outputs;
|
|
82
|
+
return outputsByNodeId;
|
|
83
|
+
}
|
|
84
|
+
async loadCompletedNodeIds(executionId, nodeIds) {
|
|
85
|
+
if (nodeIds.length === 0)
|
|
86
|
+
return new Set();
|
|
87
|
+
const rows = await this.repo.find({
|
|
88
|
+
where: { executionId, nodeId: (0, typeorm_1.In)(nodeIds), status: 'completed' },
|
|
89
|
+
select: ['nodeId'],
|
|
90
|
+
});
|
|
91
|
+
return new Set(rows.map((row) => row.nodeId));
|
|
92
|
+
}
|
|
93
|
+
async hasActiveSteps(executionId) {
|
|
94
|
+
return await this.repo.exists({
|
|
95
|
+
where: { executionId, status: (0, typeorm_1.In)(['queued', 'running']) },
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async hasFailedSteps(executionId) {
|
|
99
|
+
return await this.repo.exists({ where: { executionId, status: 'failed' } });
|
|
13
100
|
}
|
|
14
101
|
}
|
|
15
102
|
exports.TypeOrmStepStore = TypeOrmStepStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeorm-step-store.js","sourceRoot":"","sources":["../../src/database/typeorm-step-store.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"typeorm-step-store.js","sourceRoot":"","sources":["../../src/database/typeorm-step-store.ts"],"names":[],"mappings":";;;AAAA,0CAAmD;AAGnD,+CAA2C;AAC3C,sCAA4C;AAE5C,wDAMiC;AAGjC;IAC8B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AE;YAChE,MAAM,EAAE,CAAC,QAAQ,CAAC;SAClB,CAAC,CAAC;QAEH,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,WAAmB;QAEvC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAC7B,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,IAAA,YAAE,EAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,EAAE;SACrE,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,WAAmB;QACvC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC;CACD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ExecutionMode } from '../execution';
|
|
1
|
+
import type { ExecutionMode, StepSlots } from '../execution';
|
|
3
2
|
import type { GraphNode } from '../graph';
|
|
4
3
|
export interface StepExecutionContext {
|
|
5
4
|
executionId: string;
|
|
@@ -9,11 +8,11 @@ export interface StepExecutionContext {
|
|
|
9
8
|
}
|
|
10
9
|
export interface StepExecutionRequest {
|
|
11
10
|
node: GraphNode;
|
|
12
|
-
inputs:
|
|
11
|
+
inputs: StepSlots;
|
|
13
12
|
context: StepExecutionContext;
|
|
14
13
|
}
|
|
15
14
|
export interface StepExecutionResult {
|
|
16
|
-
outputs:
|
|
15
|
+
outputs: StepSlots;
|
|
17
16
|
}
|
|
18
17
|
export interface IStepExecutor {
|
|
19
18
|
execute(request: StepExecutionRequest): Promise<StepExecutionResult>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExecutionEnqueuedEvent, OrchestrationMessage, WorkQueue } from '../queue';
|
|
2
|
+
import type { ExecutionStore } from './execution-store';
|
|
3
|
+
import type { StepStore } from './step-store';
|
|
4
|
+
export declare class ExecutionStartHandler {
|
|
5
|
+
private readonly executionStore;
|
|
6
|
+
private readonly stepStore;
|
|
7
|
+
private readonly orchestrationQueue;
|
|
8
|
+
constructor(executionStore: ExecutionStore, stepStore: StepStore, orchestrationQueue: WorkQueue<OrchestrationMessage>);
|
|
9
|
+
handle(event: ExecutionEnqueuedEvent): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecutionStartHandler = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
5
|
+
const graph_1 = require("../graph");
|
|
6
|
+
class ExecutionStartHandler {
|
|
7
|
+
executionStore;
|
|
8
|
+
stepStore;
|
|
9
|
+
orchestrationQueue;
|
|
10
|
+
constructor(executionStore, stepStore, orchestrationQueue) {
|
|
11
|
+
this.executionStore = executionStore;
|
|
12
|
+
this.stepStore = stepStore;
|
|
13
|
+
this.orchestrationQueue = orchestrationQueue;
|
|
14
|
+
}
|
|
15
|
+
async handle(event) {
|
|
16
|
+
const claimed = await this.executionStore.transitionStatus(event.executionId, 'queued', 'running');
|
|
17
|
+
if (!claimed)
|
|
18
|
+
return;
|
|
19
|
+
const execution = await this.executionStore.loadExecution(event.executionId);
|
|
20
|
+
const trigger = (0, graph_1.findTriggerNode)(execution.graph);
|
|
21
|
+
if (!trigger) {
|
|
22
|
+
throw new common_1.UnexpectedError(`Execution ${event.executionId} has no trigger node in its graph`);
|
|
23
|
+
}
|
|
24
|
+
const [triggerStep] = await this.stepStore.createSteps([
|
|
25
|
+
{
|
|
26
|
+
executionId: event.executionId,
|
|
27
|
+
nodeId: trigger.id,
|
|
28
|
+
status: 'completed',
|
|
29
|
+
outputs: [execution.triggerPayload ?? {}],
|
|
30
|
+
},
|
|
31
|
+
]);
|
|
32
|
+
if (!triggerStep) {
|
|
33
|
+
throw new common_1.UnexpectedError(`Trigger step for execution ${event.executionId} already existed despite the claim`);
|
|
34
|
+
}
|
|
35
|
+
await this.orchestrationQueue.publish({
|
|
36
|
+
type: 'step:completed',
|
|
37
|
+
executionId: event.executionId,
|
|
38
|
+
stepId: triggerStep.id,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.ExecutionStartHandler = ExecutionStartHandler;
|
|
43
|
+
//# sourceMappingURL=execution-start-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-start-handler.js","sourceRoot":"","sources":["../../src/execution/execution-start-handler.ts"],"names":[],"mappings":";;;AAAA,sCAA4C;AAC5C,oCAA2C;AAa3C;IAEmB,cAAc;IACd,SAAS;IACT,kBAAkB;IAHpC,YACkB,cAA8B,EAC9B,SAAoB,EACpB,kBAAmD;8BAFnD,cAAc;yBACd,SAAS;kCACT,kBAAkB;IACjC,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,KAA6B;QAEzC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,CACzD,KAAK,CAAC,WAAW,EACjB,QAAQ,EACR,SAAS,CACT,CAAC;QACF,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAE7E,MAAM,OAAO,GAAG,IAAA,uBAAe,EAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,OAAO,EAAE,CAAC;YAGd,MAAM,IAAI,wBAAe,CAAC,aAAa,KAAK,CAAC,WAAW,mCAAmC,CAAC,CAAC;QAC9F,CAAC;QAQD,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;YACtD;gBACC,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,MAAM,EAAE,OAAO,CAAC,EAAE;gBAClB,MAAM,EAAE,WAAW;gBACnB,OAAO,EAAE,CAAC,SAAS,CAAC,cAAc,IAAI,EAAE,CAAC;aACzC;SACD,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,EAAE,CAAC;YAClB,MAAM,IAAI,wBAAe,CACxB,8BAA8B,KAAK,CAAC,WAAW,oCAAoC,CACnF,CAAC;QACH,CAAC;QAGD,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YACrC,IAAI,EAAE,gBAAgB;YACtB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,MAAM,EAAE,WAAW,CAAC,EAAE;SACtB,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -8,8 +8,23 @@ export interface NewExecutionRecord {
|
|
|
8
8
|
graph: WorkflowGraph;
|
|
9
9
|
triggerPayload: JsonObject | null;
|
|
10
10
|
}
|
|
11
|
+
export interface ExecutionRecord {
|
|
12
|
+
id: string;
|
|
13
|
+
workflowId: string;
|
|
14
|
+
status: ExecutionStatus;
|
|
15
|
+
mode: ExecutionMode;
|
|
16
|
+
graph: WorkflowGraph;
|
|
17
|
+
triggerPayload: JsonObject | null;
|
|
18
|
+
}
|
|
19
|
+
export declare class ExecutionNotFoundError extends Error {
|
|
20
|
+
readonly executionId: string;
|
|
21
|
+
constructor(executionId: string);
|
|
22
|
+
}
|
|
11
23
|
export interface ExecutionStore {
|
|
12
24
|
createExecution(record: NewExecutionRecord): Promise<{
|
|
13
25
|
id: string;
|
|
14
26
|
}>;
|
|
27
|
+
loadExecution(id: string): Promise<ExecutionRecord>;
|
|
28
|
+
transitionStatus(id: string, from: ExecutionStatus, to: ExecutionStatus): Promise<boolean>;
|
|
29
|
+
finishExecution(id: string, status: 'completed' | 'failed'): Promise<boolean>;
|
|
15
30
|
}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecutionNotFoundError = void 0;
|
|
4
|
+
class ExecutionNotFoundError extends Error {
|
|
5
|
+
executionId;
|
|
6
|
+
constructor(executionId) {
|
|
7
|
+
super(`Execution not found: ${executionId}`);
|
|
8
|
+
this.executionId = executionId;
|
|
9
|
+
this.name = 'ExecutionNotFoundError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.ExecutionNotFoundError = ExecutionNotFoundError;
|
|
3
13
|
//# sourceMappingURL=execution-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-store.js","sourceRoot":"","sources":["../../src/execution/execution-store.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"execution-store.js","sourceRoot":"","sources":["../../src/execution/execution-store.ts"],"names":[],"mappings":";;;AAwBA,4BAAoC,SAAQ,KAAK;IAC3B,WAAW;IAAhC,YAAqB,WAAmB;QACvC,KAAK,CAAC,wBAAwB,WAAW,EAAE,CAAC,CAAC;2BADzB,WAAW;QAE/B,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACtC,CAAC;CACD"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { JsonValue } from '../common';
|
|
1
2
|
export type ExecutionStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
2
3
|
export type ExecutionMode = 'production' | 'manual';
|
|
3
4
|
export type StepStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
5
|
+
export type StepSlots = JsonValue[];
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export { StartExecutionService } from './start-execution.service';
|
|
2
2
|
export type { StartExecutionRequest, StartExecutionResult, } from './start-execution.service';
|
|
3
|
-
export type { ExecutionMode, ExecutionStatus, StepStatus } from './execution.types';
|
|
4
|
-
export
|
|
5
|
-
export type {
|
|
3
|
+
export type { ExecutionMode, ExecutionStatus, StepSlots, StepStatus } from './execution.types';
|
|
4
|
+
export { ExecutionNotFoundError } from './execution-store';
|
|
5
|
+
export type { ExecutionRecord, ExecutionStore, NewExecutionRecord } from './execution-store';
|
|
6
|
+
export { StepNotFoundError } from './step-store';
|
|
7
|
+
export type { NewStepRecord, StepError, StepRecord, StepStore } from './step-store';
|
|
8
|
+
export { ExecutionStartHandler } from './execution-start-handler';
|
|
9
|
+
export { OrchestrationWorker } from './orchestration-worker';
|
|
10
|
+
export { StepCompletedHandler } from './step-completed-handler';
|
|
11
|
+
export { StepReadyHandler } from './step-ready-handler';
|
|
12
|
+
export { StepWorker } from './step-worker';
|
package/dist/execution/index.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StartExecutionService = void 0;
|
|
3
|
+
exports.StepWorker = exports.StepReadyHandler = exports.StepCompletedHandler = exports.OrchestrationWorker = exports.ExecutionStartHandler = exports.StepNotFoundError = exports.ExecutionNotFoundError = exports.StartExecutionService = void 0;
|
|
4
4
|
var start_execution_service_1 = require("./start-execution.service");
|
|
5
5
|
Object.defineProperty(exports, "StartExecutionService", { enumerable: true, get: function () { return start_execution_service_1.StartExecutionService; } });
|
|
6
|
+
var execution_store_1 = require("./execution-store");
|
|
7
|
+
Object.defineProperty(exports, "ExecutionNotFoundError", { enumerable: true, get: function () { return execution_store_1.ExecutionNotFoundError; } });
|
|
8
|
+
var step_store_1 = require("./step-store");
|
|
9
|
+
Object.defineProperty(exports, "StepNotFoundError", { enumerable: true, get: function () { return step_store_1.StepNotFoundError; } });
|
|
10
|
+
var execution_start_handler_1 = require("./execution-start-handler");
|
|
11
|
+
Object.defineProperty(exports, "ExecutionStartHandler", { enumerable: true, get: function () { return execution_start_handler_1.ExecutionStartHandler; } });
|
|
12
|
+
var orchestration_worker_1 = require("./orchestration-worker");
|
|
13
|
+
Object.defineProperty(exports, "OrchestrationWorker", { enumerable: true, get: function () { return orchestration_worker_1.OrchestrationWorker; } });
|
|
14
|
+
var step_completed_handler_1 = require("./step-completed-handler");
|
|
15
|
+
Object.defineProperty(exports, "StepCompletedHandler", { enumerable: true, get: function () { return step_completed_handler_1.StepCompletedHandler; } });
|
|
16
|
+
var step_ready_handler_1 = require("./step-ready-handler");
|
|
17
|
+
Object.defineProperty(exports, "StepReadyHandler", { enumerable: true, get: function () { return step_ready_handler_1.StepReadyHandler; } });
|
|
18
|
+
var step_worker_1 = require("./step-worker");
|
|
19
|
+
Object.defineProperty(exports, "StepWorker", { enumerable: true, get: function () { return step_worker_1.StepWorker; } });
|
|
6
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":";;;AAAA,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":";;;AAAA,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAM9B,qDAA2D;AAAlD,yHAAA,sBAAsB,OAAA;AAE/B,2CAAiD;AAAxC,+GAAA,iBAAiB,OAAA;AAE1B,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,+DAA6D;AAApD,2HAAA,mBAAmB,OAAA;AAC5B,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAC7B,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OrchestrationMessage, WorkQueue } from '../queue';
|
|
2
|
+
import type { ExecutionStartHandler } from './execution-start-handler';
|
|
3
|
+
import type { StepCompletedHandler } from './step-completed-handler';
|
|
4
|
+
export declare class OrchestrationWorker {
|
|
5
|
+
private readonly orchestrationQueue;
|
|
6
|
+
private readonly startHandler;
|
|
7
|
+
private readonly completedHandler;
|
|
8
|
+
constructor(orchestrationQueue: WorkQueue<OrchestrationMessage>, startHandler: ExecutionStartHandler, completedHandler: StepCompletedHandler);
|
|
9
|
+
start(): void;
|
|
10
|
+
stop(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrchestrationWorker = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
5
|
+
class OrchestrationWorker {
|
|
6
|
+
orchestrationQueue;
|
|
7
|
+
startHandler;
|
|
8
|
+
completedHandler;
|
|
9
|
+
constructor(orchestrationQueue, startHandler, completedHandler) {
|
|
10
|
+
this.orchestrationQueue = orchestrationQueue;
|
|
11
|
+
this.startHandler = startHandler;
|
|
12
|
+
this.completedHandler = completedHandler;
|
|
13
|
+
}
|
|
14
|
+
start() {
|
|
15
|
+
this.orchestrationQueue.start(async (message) => {
|
|
16
|
+
switch (message.type) {
|
|
17
|
+
case 'execution:enqueued':
|
|
18
|
+
await this.startHandler.handle(message);
|
|
19
|
+
break;
|
|
20
|
+
case 'step:completed':
|
|
21
|
+
await this.completedHandler.handle(message);
|
|
22
|
+
break;
|
|
23
|
+
default: {
|
|
24
|
+
const unhandled = message;
|
|
25
|
+
throw new common_1.UnimplementedError(`orchestration worker received an unimplemented message type: ${JSON.stringify(unhandled)}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async stop() {
|
|
31
|
+
await this.orchestrationQueue.stop();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.OrchestrationWorker = OrchestrationWorker;
|
|
35
|
+
//# sourceMappingURL=orchestration-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration-worker.js","sourceRoot":"","sources":["../../src/execution/orchestration-worker.ts"],"names":[],"mappings":";;;AAAA,sCAA+C;AAQ/C;IAEmB,kBAAkB;IAClB,YAAY;IACZ,gBAAgB;IAHlC,YACkB,kBAAmD,EACnD,YAAmC,EACnC,gBAAsC;kCAFtC,kBAAkB;4BAClB,YAAY;gCACZ,gBAAgB;IAC/B,CAAC;IAEJ,KAAK;QACJ,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC/C,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;gBACtB,KAAK,oBAAoB;oBACxB,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBACxC,MAAM;gBACP,KAAK,gBAAgB;oBACpB,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBAC5C,MAAM;gBACP,SAAS,CAAC;oBAET,MAAM,SAAS,GAAU,OAAO,CAAC;oBACjC,MAAM,IAAI,2BAAkB,CAC3B,gEAAgE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAC3F,CAAC;gBACH,CAAC;YACF,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI;QACT,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;CACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AdmittanceService } from '../admittance';
|
|
2
2
|
import type { JsonObject } from '../common';
|
|
3
|
-
import type
|
|
4
|
-
import type { WorkQueue } from '../queue';
|
|
3
|
+
import { type WorkflowGraph } from '../graph';
|
|
4
|
+
import type { OrchestrationMessage, WorkQueue } from '../queue';
|
|
5
5
|
import type { ExecutionStore } from './execution-store';
|
|
6
6
|
import type { ExecutionMode } from './execution.types';
|
|
7
7
|
export interface StartExecutionRequest {
|
|
@@ -17,6 +17,7 @@ export declare class StartExecutionService {
|
|
|
17
17
|
private readonly admittance;
|
|
18
18
|
private readonly executionStore;
|
|
19
19
|
private readonly workQueue;
|
|
20
|
-
|
|
20
|
+
private readonly validateGraph;
|
|
21
|
+
constructor(admittance: AdmittanceService, executionStore: ExecutionStore, workQueue: WorkQueue<OrchestrationMessage>, validateGraph?: (graph: WorkflowGraph) => void);
|
|
21
22
|
start(request: StartExecutionRequest): Promise<StartExecutionResult>;
|
|
22
23
|
}
|
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StartExecutionService = void 0;
|
|
4
4
|
const admittance_1 = require("../admittance");
|
|
5
|
+
const graph_1 = require("../graph");
|
|
5
6
|
class StartExecutionService {
|
|
6
7
|
admittance;
|
|
7
8
|
executionStore;
|
|
8
9
|
workQueue;
|
|
9
|
-
|
|
10
|
+
validateGraph;
|
|
11
|
+
constructor(admittance, executionStore, workQueue, validateGraph = graph_1.validateExecutableGraph) {
|
|
10
12
|
this.admittance = admittance;
|
|
11
13
|
this.executionStore = executionStore;
|
|
12
14
|
this.workQueue = workQueue;
|
|
15
|
+
this.validateGraph = validateGraph;
|
|
13
16
|
}
|
|
14
17
|
async start(request) {
|
|
18
|
+
this.validateGraph(request.graph);
|
|
15
19
|
const decision = await this.admittance.evaluate({ workflowId: request.workflowId });
|
|
16
20
|
if (!decision.accept) {
|
|
17
21
|
throw new admittance_1.AdmittanceRejectedError(decision.reason);
|