@n8n/engine 0.14.0 → 0.15.1
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 +3 -0
- package/dist/common/errors.js +8 -1
- package/dist/common/errors.js.map +1 -1
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +2 -1
- package/dist/common/index.js.map +1 -1
- package/dist/database/entities/workflow-step-execution.entity.d.ts +2 -3
- package/dist/database/entities/workflow-step-execution.entity.js +3 -1
- package/dist/database/entities/workflow-step-execution.entity.js.map +1 -1
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js +2 -1
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js.map +1 -1
- package/dist/database/typeorm-execution-store.d.ts +1 -0
- package/dist/database/typeorm-execution-store.js +4 -0
- package/dist/database/typeorm-execution-store.js.map +1 -1
- package/dist/database/typeorm-step-store.d.ts +9 -4
- package/dist/database/typeorm-step-store.js +56 -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 +3 -3
- package/dist/execution/execution-start-handler.js +18 -18
- package/dist/execution/execution-start-handler.js.map +1 -1
- package/dist/execution/execution-store.d.ts +1 -0
- package/dist/execution/execution.types.d.ts +2 -0
- package/dist/execution/index.d.ts +4 -1
- package/dist/execution/index.js +7 -1
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/orchestration-worker.d.ts +3 -1
- package/dist/execution/orchestration-worker.js +10 -3
- package/dist/execution/orchestration-worker.js.map +1 -1
- package/dist/execution/start-execution.service.d.ts +3 -2
- 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 +11 -5
- 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 -1
- package/dist/graph/index.js +5 -1
- 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 +1 -0
- package/dist/graph/workflow-graph-queries.js +10 -0
- package/dist/graph/workflow-graph-queries.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -1
- package/dist/index.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 +6 -1
- package/dist/serve.js +10 -5
- package/dist/serve.js.map +1 -1
- package/dist/server/routes/workflow-executions.js +10 -0
- package/dist/server/routes/workflow-executions.js.map +1 -1
- package/package.json +4 -4
package/dist/common/errors.d.ts
CHANGED
package/dist/common/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnimplementedError = void 0;
|
|
3
|
+
exports.UnexpectedError = exports.UnimplementedError = void 0;
|
|
4
4
|
class UnimplementedError extends Error {
|
|
5
5
|
constructor(message) {
|
|
6
6
|
super(message);
|
|
@@ -8,4 +8,11 @@ class UnimplementedError extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
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;
|
|
11
18
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +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"}
|
|
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
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type { JsonObject, JsonValue } from './json';
|
|
2
|
-
export { UnimplementedError } from './errors';
|
|
2
|
+
export { UnexpectedError, UnimplementedError } from './errors';
|
package/dist/common/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnimplementedError = void 0;
|
|
3
|
+
exports.UnimplementedError = exports.UnexpectedError = void 0;
|
|
4
4
|
var errors_1 = require("./errors");
|
|
5
|
+
Object.defineProperty(exports, "UnexpectedError", { enumerable: true, get: function () { return errors_1.UnexpectedError; } });
|
|
5
6
|
Object.defineProperty(exports, "UnimplementedError", { enumerable: true, get: function () { return errors_1.UnimplementedError; } });
|
|
6
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":";;;AACA,
|
|
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,12 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { StepStatus } from '../../execution/execution.types';
|
|
1
|
+
import type { StepSlots, StepStatus } from '../../execution/execution.types';
|
|
3
2
|
import type { StepError } from '../../execution/step-store';
|
|
4
3
|
export declare class WorkflowStepExecution {
|
|
5
4
|
id: string;
|
|
6
5
|
executionId: string;
|
|
7
6
|
nodeId: string;
|
|
8
7
|
status: StepStatus;
|
|
9
|
-
outputs:
|
|
8
|
+
outputs: StepSlots | null;
|
|
10
9
|
error: StepError | null;
|
|
11
10
|
createdAt: Date;
|
|
12
11
|
updatedAt: Date;
|
|
@@ -67,6 +67,8 @@ __decorate([
|
|
|
67
67
|
], WorkflowStepExecution.prototype, "setId", null);
|
|
68
68
|
exports.WorkflowStepExecution = WorkflowStepExecution = __decorate([
|
|
69
69
|
(0, typeorm_1.Entity)('workflow_step_execution'),
|
|
70
|
-
(0, typeorm_1.Index)('
|
|
70
|
+
(0, typeorm_1.Index)('uniq_workflow_step_execution_execution_id_node_id', ['executionId', 'nodeId'], {
|
|
71
|
+
unique: true,
|
|
72
|
+
})
|
|
71
73
|
], WorkflowStepExecution);
|
|
72
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"}
|
|
@@ -39,8 +39,9 @@ class CreateWorkflowStepExecution1784890100000 {
|
|
|
39
39
|
],
|
|
40
40
|
indices: [
|
|
41
41
|
{
|
|
42
|
-
name: '
|
|
42
|
+
name: 'uniq_workflow_step_execution_execution_id_node_id',
|
|
43
43
|
columnNames: ['execution_id', 'node_id'],
|
|
44
|
+
isUnique: true,
|
|
44
45
|
},
|
|
45
46
|
],
|
|
46
47
|
foreignKeys: [
|
|
@@ -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,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,
|
|
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"}
|
|
@@ -10,4 +10,5 @@ export declare class TypeOrmExecutionStore implements ExecutionStore {
|
|
|
10
10
|
}>;
|
|
11
11
|
loadExecution(id: string): Promise<ExecutionRecord>;
|
|
12
12
|
transitionStatus(id: string, from: ExecutionStatus, to: ExecutionStatus): Promise<boolean>;
|
|
13
|
+
finishExecution(id: string, status: 'completed' | 'failed'): Promise<boolean>;
|
|
13
14
|
}
|
|
@@ -22,6 +22,10 @@ class TypeOrmExecutionStore {
|
|
|
22
22
|
const result = await this.repo.update({ id, status: from }, { status: to });
|
|
23
23
|
return result.affected === 1;
|
|
24
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
|
+
}
|
|
25
29
|
}
|
|
26
30
|
exports.TypeOrmExecutionStore = TypeOrmExecutionStore;
|
|
27
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":";;;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,K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AU,EAAE,IAAI,IAAI,EAAE,EAAE,CAClC,CAAC;QACF,OAAO,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC;IAC9B,CAAC;CACD"}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
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
4
|
import { type NewStepRecord, type StepError, type StepRecord, type StepStore } from '../execution/step-store';
|
|
5
5
|
export declare class TypeOrmStepStore implements StepStore {
|
|
6
6
|
private readonly repo;
|
|
7
7
|
constructor(repo: Repository<WorkflowStepExecution>);
|
|
8
8
|
createSteps(records: NewStepRecord[]): Promise<Array<{
|
|
9
9
|
id: string;
|
|
10
|
+
nodeId: string;
|
|
10
11
|
}>>;
|
|
11
12
|
loadStep(id: string): Promise<StepRecord>;
|
|
12
|
-
claimStep(id: string): Promise<
|
|
13
|
-
completeStep(id: string, outputs:
|
|
13
|
+
claimStep(id: string): Promise<StepRecord | null>;
|
|
14
|
+
completeStep(id: string, outputs: StepSlots): Promise<boolean>;
|
|
15
|
+
cancelQueuedSteps(executionId: string): Promise<void>;
|
|
14
16
|
failStep(id: string, error: StepError): Promise<boolean>;
|
|
15
17
|
private transition;
|
|
16
|
-
loadStepOutputs(executionId: string, nodeIds: string[]): Promise<Record<string,
|
|
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>;
|
|
17
22
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeOrmStepStore = void 0;
|
|
4
4
|
const typeorm_1 = require("@n8n/typeorm");
|
|
5
|
+
const generate_id_1 = require("./generate-id");
|
|
6
|
+
const common_1 = require("../common");
|
|
5
7
|
const step_store_1 = require("../execution/step-store");
|
|
6
8
|
class TypeOrmStepStore {
|
|
7
9
|
repo;
|
|
@@ -9,9 +11,22 @@ class TypeOrmStepStore {
|
|
|
9
11
|
this.repo = repo;
|
|
10
12
|
}
|
|
11
13
|
async createSteps(records) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 }));
|
|
15
30
|
}
|
|
16
31
|
async loadStep(id) {
|
|
17
32
|
const row = await this.repo.findOne({ where: { id } });
|
|
@@ -20,11 +35,31 @@ class TypeOrmStepStore {
|
|
|
20
35
|
return row;
|
|
21
36
|
}
|
|
22
37
|
async claimStep(id) {
|
|
23
|
-
|
|
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
|
+
};
|
|
24
56
|
}
|
|
25
57
|
async completeStep(id, outputs) {
|
|
26
58
|
return await this.transition(id, 'running', 'completed', { outputs });
|
|
27
59
|
}
|
|
60
|
+
async cancelQueuedSteps(executionId) {
|
|
61
|
+
await this.repo.update({ executionId, status: 'queued' }, { status: 'cancelled' });
|
|
62
|
+
}
|
|
28
63
|
async failStep(id, error) {
|
|
29
64
|
return await this.transition(id, 'running', 'failed', { error });
|
|
30
65
|
}
|
|
@@ -46,6 +81,23 @@ class TypeOrmStepStore {
|
|
|
46
81
|
outputsByNodeId[row.nodeId] = row.outputs;
|
|
47
82
|
return outputsByNodeId;
|
|
48
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' } });
|
|
100
|
+
}
|
|
49
101
|
}
|
|
50
102
|
exports.TypeOrmStepStore = TypeOrmStepStore;
|
|
51
103
|
//# sourceMappingURL=typeorm-step-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeorm-step-store.js","sourceRoot":"","sources":["../../src/database/typeorm-step-store.ts"],"names":[],"mappings":";;;AAAA,0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C;QAE3C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACjC,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,IAAA,YAAE,EAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE;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>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExecutionEnqueuedEvent,
|
|
1
|
+
import type { ExecutionEnqueuedEvent, OrchestrationMessage, WorkQueue } from '../queue';
|
|
2
2
|
import type { ExecutionStore } from './execution-store';
|
|
3
3
|
import type { StepStore } from './step-store';
|
|
4
4
|
export declare class ExecutionStartHandler {
|
|
5
5
|
private readonly executionStore;
|
|
6
6
|
private readonly stepStore;
|
|
7
|
-
private readonly
|
|
8
|
-
constructor(executionStore: ExecutionStore, stepStore: StepStore,
|
|
7
|
+
private readonly orchestrationQueue;
|
|
8
|
+
constructor(executionStore: ExecutionStore, stepStore: StepStore, orchestrationQueue: WorkQueue<OrchestrationMessage>);
|
|
9
9
|
handle(event: ExecutionEnqueuedEvent): Promise<void>;
|
|
10
10
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExecutionStartHandler = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
4
5
|
const graph_1 = require("../graph");
|
|
5
6
|
class ExecutionStartHandler {
|
|
6
7
|
executionStore;
|
|
7
8
|
stepStore;
|
|
8
|
-
|
|
9
|
-
constructor(executionStore, stepStore,
|
|
9
|
+
orchestrationQueue;
|
|
10
|
+
constructor(executionStore, stepStore, orchestrationQueue) {
|
|
10
11
|
this.executionStore = executionStore;
|
|
11
12
|
this.stepStore = stepStore;
|
|
12
|
-
this.
|
|
13
|
+
this.orchestrationQueue = orchestrationQueue;
|
|
13
14
|
}
|
|
14
15
|
async handle(event) {
|
|
15
16
|
const claimed = await this.executionStore.transitionStatus(event.executionId, 'queued', 'running');
|
|
@@ -18,25 +19,24 @@ class ExecutionStartHandler {
|
|
|
18
19
|
const execution = await this.executionStore.loadExecution(event.executionId);
|
|
19
20
|
const trigger = (0, graph_1.findTriggerNode)(execution.graph);
|
|
20
21
|
if (!trigger) {
|
|
21
|
-
|
|
22
|
-
return;
|
|
22
|
+
throw new common_1.UnexpectedError(`Execution ${event.executionId} has no trigger node in its graph`);
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
{ executionId: event.executionId, nodeId: trigger.id, status: 'completed' },
|
|
27
|
-
...successorNodeIds.map((nodeId) => ({
|
|
24
|
+
const [triggerStep] = await this.stepStore.createSteps([
|
|
25
|
+
{
|
|
28
26
|
executionId: event.executionId,
|
|
29
|
-
nodeId,
|
|
30
|
-
status: '
|
|
31
|
-
|
|
27
|
+
nodeId: trigger.id,
|
|
28
|
+
status: 'completed',
|
|
29
|
+
outputs: [execution.triggerPayload ?? {}],
|
|
30
|
+
},
|
|
32
31
|
]);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type: 'step:ready',
|
|
36
|
-
executionId: event.executionId,
|
|
37
|
-
stepId,
|
|
38
|
-
});
|
|
32
|
+
if (!triggerStep) {
|
|
33
|
+
throw new common_1.UnexpectedError(`Trigger step for execution ${event.executionId} already existed despite the claim`);
|
|
39
34
|
}
|
|
35
|
+
await this.orchestrationQueue.publish({
|
|
36
|
+
type: 'step:completed',
|
|
37
|
+
executionId: event.executionId,
|
|
38
|
+
stepId: triggerStep.id,
|
|
39
|
+
});
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
exports.ExecutionStartHandler = ExecutionStartHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-start-handler.js","sourceRoot":"","sources":["../../src/execution/execution-start-handler.ts"],"names":[],"mappings":";;;AAAA,
|
|
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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
27
|
loadExecution(id: string): Promise<ExecutionRecord>;
|
|
28
28
|
transitionStatus(id: string, from: ExecutionStatus, to: ExecutionStatus): Promise<boolean>;
|
|
29
|
+
finishExecution(id: string, status: 'completed' | 'failed'): Promise<boolean>;
|
|
29
30
|
}
|
|
@@ -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,9 +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';
|
|
3
|
+
export type { ExecutionMode, ExecutionStatus, StepSlots, StepStatus } from './execution.types';
|
|
4
4
|
export { ExecutionNotFoundError } from './execution-store';
|
|
5
5
|
export type { ExecutionRecord, ExecutionStore, NewExecutionRecord } from './execution-store';
|
|
6
6
|
export { StepNotFoundError } from './step-store';
|
|
7
7
|
export type { NewStepRecord, StepError, StepRecord, StepStore } from './step-store';
|
|
8
8
|
export { ExecutionStartHandler } from './execution-start-handler';
|
|
9
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,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OrchestrationWorker = exports.ExecutionStartHandler = exports.StepNotFoundError = exports.ExecutionNotFoundError = 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
6
|
var execution_store_1 = require("./execution-store");
|
|
@@ -11,4 +11,10 @@ var execution_start_handler_1 = require("./execution-start-handler");
|
|
|
11
11
|
Object.defineProperty(exports, "ExecutionStartHandler", { enumerable: true, get: function () { return execution_start_handler_1.ExecutionStartHandler; } });
|
|
12
12
|
var orchestration_worker_1 = require("./orchestration-worker");
|
|
13
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; } });
|
|
14
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;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"}
|
|
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"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { OrchestrationMessage, WorkQueue } from '../queue';
|
|
2
2
|
import type { ExecutionStartHandler } from './execution-start-handler';
|
|
3
|
+
import type { StepCompletedHandler } from './step-completed-handler';
|
|
3
4
|
export declare class OrchestrationWorker {
|
|
4
5
|
private readonly orchestrationQueue;
|
|
5
6
|
private readonly startHandler;
|
|
6
|
-
|
|
7
|
+
private readonly completedHandler;
|
|
8
|
+
constructor(orchestrationQueue: WorkQueue<OrchestrationMessage>, startHandler: ExecutionStartHandler, completedHandler: StepCompletedHandler);
|
|
7
9
|
start(): void;
|
|
8
10
|
stop(): Promise<void>;
|
|
9
11
|
}
|
|
@@ -5,9 +5,11 @@ const common_1 = require("../common");
|
|
|
5
5
|
class OrchestrationWorker {
|
|
6
6
|
orchestrationQueue;
|
|
7
7
|
startHandler;
|
|
8
|
-
|
|
8
|
+
completedHandler;
|
|
9
|
+
constructor(orchestrationQueue, startHandler, completedHandler) {
|
|
9
10
|
this.orchestrationQueue = orchestrationQueue;
|
|
10
11
|
this.startHandler = startHandler;
|
|
12
|
+
this.completedHandler = completedHandler;
|
|
11
13
|
}
|
|
12
14
|
start() {
|
|
13
15
|
this.orchestrationQueue.start(async (message) => {
|
|
@@ -15,8 +17,13 @@ class OrchestrationWorker {
|
|
|
15
17
|
case 'execution:enqueued':
|
|
16
18
|
await this.startHandler.handle(message);
|
|
17
19
|
break;
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
}
|
|
20
27
|
}
|
|
21
28
|
});
|
|
22
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestration-worker.js","sourceRoot":"","sources":["../../src/execution/orchestration-worker.ts"],"names":[],"mappings":";;;AAAA,sCAA+C;
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { type AdmittanceService } from '../admittance';
|
|
2
2
|
import type { JsonObject } from '../common';
|
|
3
|
-
import type
|
|
3
|
+
import { type WorkflowGraph } from '../graph';
|
|
4
4
|
import type { OrchestrationMessage, WorkQueue } from '../queue';
|
|
5
5
|
import type { ExecutionStore } from './execution-store';
|
|
6
6
|
import type { ExecutionMode } from './execution.types';
|
|
@@ -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);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-execution.service.js","sourceRoot":"","sources":["../../src/execution/start-execution.service.ts"],"names":[],"mappings":";;;AAAA,8CAAgF;
|
|
1
|
+
{"version":3,"file":"start-execution.service.js","sourceRoot":"","sources":["../../src/execution/start-execution.service.ts"],"names":[],"mappings":";;;AAAA,8CAAgF;AAEhF,oCAAuE;AAgBvE;IAEmB,UAAU;IACV,cAAc;IACd,SAAS;IACT,aAAa;IAJ/B,YACkB,UAA6B,EAC7B,cAA8B,EAC9B,SAA0C,EAC1C,aAAa,GAAmC,+BAAuB;0BAHvE,UAAU;8BACV,cAAc;yBACd,SAAS;6BACT,aAAa;IAC5B,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,OAA8B;QAGzC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAElC,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,13 @@
|
|
|
1
|
+
import type { StepCompletedEvent, StepMessage, WorkQueue } from '../queue';
|
|
2
|
+
import type { ExecutionStore } from './execution-store';
|
|
3
|
+
import type { StepStore } from './step-store';
|
|
4
|
+
export declare class StepCompletedHandler {
|
|
5
|
+
private readonly executionStore;
|
|
6
|
+
private readonly stepStore;
|
|
7
|
+
private readonly stepQueue;
|
|
8
|
+
constructor(executionStore: ExecutionStore, stepStore: StepStore, stepQueue: WorkQueue<StepMessage>);
|
|
9
|
+
handle(event: StepCompletedEvent): Promise<void>;
|
|
10
|
+
private finishExecutionIfDone;
|
|
11
|
+
private planSuccessors;
|
|
12
|
+
private readySuccessorNodeIds;
|
|
13
|
+
}
|