@n8n/engine 0.15.1 → 0.16.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/database/create-stores.d.ts +7 -0
- package/dist/database/create-stores.js +13 -0
- package/dist/database/create-stores.js.map +1 -0
- package/dist/database/index.d.ts +1 -0
- package/dist/database/index.js +3 -1
- package/dist/database/index.js.map +1 -1
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js +1 -1
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js.map +1 -1
- package/dist/database/typeorm-step-store.d.ts +7 -7
- package/dist/database/typeorm-step-store.js +96 -56
- package/dist/database/typeorm-step-store.js.map +1 -1
- package/dist/execution/execution-start-handler.js +2 -3
- package/dist/execution/execution-start-handler.js.map +1 -1
- package/dist/execution/execution.types.d.ts +3 -1
- package/dist/execution/execution.types.js +11 -0
- package/dist/execution/execution.types.js.map +1 -1
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.js +3 -3
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/orchestration-worker.d.ts +3 -3
- package/dist/execution/orchestration-worker.js +5 -5
- package/dist/execution/orchestration-worker.js.map +1 -1
- package/dist/execution/settlement.d.ts +7 -0
- package/dist/execution/settlement.js +31 -0
- package/dist/execution/settlement.js.map +1 -0
- package/dist/execution/step-ready-handler.d.ts +0 -1
- package/dist/execution/step-ready-handler.js +29 -28
- package/dist/execution/step-ready-handler.js.map +1 -1
- package/dist/execution/step-settled-handler.d.ts +17 -0
- package/dist/execution/step-settled-handler.js +97 -0
- package/dist/execution/step-settled-handler.js.map +1 -0
- package/dist/execution/step-store.d.ts +18 -9
- package/dist/execution/step-store.js.map +1 -1
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/index.js +2 -1
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/validate-executable-graph.js +15 -4
- package/dist/graph/validate-executable-graph.js.map +1 -1
- package/dist/graph/workflow-graph-queries.d.ts +1 -0
- package/dist/graph/workflow-graph-queries.js +14 -0
- package/dist/graph/workflow-graph-queries.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/queue/index.d.ts +1 -1
- package/dist/queue/work-queue.types.d.ts +3 -3
- package/dist/serve.js +2 -3
- package/dist/serve.js.map +1 -1
- package/package.json +6 -5
- package/dist/execution/step-completed-handler.d.ts +0 -13
- package/dist/execution/step-completed-handler.js +0 -74
- package/dist/execution/step-completed-handler.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DataSource } from '@n8n/typeorm';
|
|
2
|
+
import type { ExecutionStore } from '../execution/execution-store';
|
|
3
|
+
import type { StepStore } from '../execution/step-store';
|
|
4
|
+
export declare function createStores(dataSource: DataSource): {
|
|
5
|
+
executionStore: ExecutionStore;
|
|
6
|
+
stepStore: StepStore;
|
|
7
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStores = createStores;
|
|
4
|
+
const entities_1 = require("./entities");
|
|
5
|
+
const typeorm_execution_store_1 = require("./typeorm-execution-store");
|
|
6
|
+
const typeorm_step_store_1 = require("./typeorm-step-store");
|
|
7
|
+
function createStores(dataSource) {
|
|
8
|
+
return {
|
|
9
|
+
executionStore: new typeorm_execution_store_1.TypeOrmExecutionStore(dataSource.getRepository(entities_1.WorkflowExecution)),
|
|
10
|
+
stepStore: new typeorm_step_store_1.TypeOrmStepStore(dataSource.getRepository(entities_1.WorkflowStepExecution)),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=create-stores.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-stores.js","sourceRoot":"","sources":["../../src/database/create-stores.ts"],"names":[],"mappings":";;;AAEA,yCAAsE;AACtE,uEAAkE;AAClE,6DAAwD;AAIxD,sBAA6B,UAAsB;IAIlD,OAAO;QACN,cAAc,EAAE,IAAI,+CAAqB,CAAC,UAAU,CAAC,aAAa,CAAC,4BAAiB,CAAC,CAAC;QACtF,SAAS,EAAE,IAAI,qCAAgB,CAAC,UAAU,CAAC,aAAa,CAAC,gCAAqB,CAAC,CAAC;KAChF,CAAC;AACH,CAAC"}
|
package/dist/database/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createDataSource } from './data-source';
|
|
2
|
+
export { createStores } from './create-stores';
|
|
2
3
|
export { WorkflowExecution, WorkflowStepExecution } from './entities';
|
|
3
4
|
export { TypeOrmExecutionStore } from './typeorm-execution-store';
|
|
4
5
|
export { TypeOrmStepStore } from './typeorm-step-store';
|
package/dist/database/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypeOrmStepStore = exports.TypeOrmExecutionStore = exports.WorkflowStepExecution = exports.WorkflowExecution = exports.createDataSource = void 0;
|
|
3
|
+
exports.TypeOrmStepStore = exports.TypeOrmExecutionStore = exports.WorkflowStepExecution = exports.WorkflowExecution = exports.createStores = exports.createDataSource = void 0;
|
|
4
4
|
var data_source_1 = require("./data-source");
|
|
5
5
|
Object.defineProperty(exports, "createDataSource", { enumerable: true, get: function () { return data_source_1.createDataSource; } });
|
|
6
|
+
var create_stores_1 = require("./create-stores");
|
|
7
|
+
Object.defineProperty(exports, "createStores", { enumerable: true, get: function () { return create_stores_1.createStores; } });
|
|
6
8
|
var entities_1 = require("./entities");
|
|
7
9
|
Object.defineProperty(exports, "WorkflowExecution", { enumerable: true, get: function () { return entities_1.WorkflowExecution; } });
|
|
8
10
|
Object.defineProperty(exports, "WorkflowStepExecution", { enumerable: true, get: function () { return entities_1.WorkflowStepExecution; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":";;;AAAA,6CAAiD;AAAxC,+GAAA,gBAAgB,OAAA;AACzB,uCAAsE;AAA7D,6GAAA,iBAAiB,OAAA;AAAE,iHAAA,qBAAqB,OAAA;AACjD,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":";;;AAAA,6CAAiD;AAAxC,+GAAA,gBAAgB,OAAA;AACzB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,uCAAsE;AAA7D,6GAAA,iBAAiB,OAAA;AAAE,iHAAA,qBAAqB,OAAA;AACjD,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA"}
|
|
@@ -55,7 +55,7 @@ class CreateWorkflowStepExecution1784890100000 {
|
|
|
55
55
|
checks: [
|
|
56
56
|
{
|
|
57
57
|
name: 'chk_workflow_step_execution_status',
|
|
58
|
-
expression: "status IN ('queued', 'running', 'completed', 'failed', 'cancelled')",
|
|
58
|
+
expression: "status IN ('queued', 'running', 'completed', 'failed', 'skipped', 'cancelled')",
|
|
59
59
|
},
|
|
60
60
|
],
|
|
61
61
|
}));
|
|
@@ -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,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,
|
|
1
|
+
{"version":3,"file":"1784890100000-CreateWorkflowStepExecution.js","sourceRoot":"","sources":["../../../src/database/migrations/1784890100000-CreateWorkflowStepExecution.ts"],"names":[],"mappings":";;;AAAA,0CAAqC;AAGrC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nB;aACD;YACD,MAAM,EAAE;gBACP;oBACC,IAAI,EAAE,oCAAoC;oBAC1C,UAAU,EACT,gFAAgF;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,11 +1,11 @@
|
|
|
1
1
|
import { type Repository } from '@n8n/typeorm';
|
|
2
|
-
import
|
|
3
|
-
import type
|
|
4
|
-
import { type NewStepRecord, type StepError, type StepRecord, type StepStore } from '../execution/step-store';
|
|
2
|
+
import { WorkflowStepExecution } from './entities';
|
|
3
|
+
import { type StepSlots } from '../execution/execution.types';
|
|
4
|
+
import { type NewStepRecord, type StepError, type StepRecord, type StepStore, type StepSummary } from '../execution/step-store';
|
|
5
5
|
export declare class TypeOrmStepStore implements StepStore {
|
|
6
6
|
private readonly repo;
|
|
7
7
|
constructor(repo: Repository<WorkflowStepExecution>);
|
|
8
|
-
createSteps(records: NewStepRecord[]): Promise<Array<{
|
|
8
|
+
createSteps(executionId: string, records: NewStepRecord[]): Promise<Array<{
|
|
9
9
|
id: string;
|
|
10
10
|
nodeId: string;
|
|
11
11
|
}>>;
|
|
@@ -15,8 +15,8 @@ export declare class TypeOrmStepStore implements StepStore {
|
|
|
15
15
|
cancelQueuedSteps(executionId: string): Promise<void>;
|
|
16
16
|
failStep(id: string, error: StepError): Promise<boolean>;
|
|
17
17
|
private transition;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
loadStepsByNodeIds(executionId: string, nodeIds: string[]): Promise<Record<string, StepRecord>>;
|
|
19
|
+
loadStepSummaries(executionId: string, nodeIds: string[]): Promise<Record<string, StepSummary>>;
|
|
20
|
+
countSettledSteps(executionId: string): Promise<number>;
|
|
21
21
|
hasFailedSteps(executionId: string): Promise<boolean>;
|
|
22
22
|
}
|
|
@@ -2,31 +2,41 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeOrmStepStore = void 0;
|
|
4
4
|
const typeorm_1 = require("@n8n/typeorm");
|
|
5
|
+
const entities_1 = require("./entities");
|
|
5
6
|
const generate_id_1 = require("./generate-id");
|
|
6
7
|
const common_1 = require("../common");
|
|
8
|
+
const execution_types_1 = require("../execution/execution.types");
|
|
7
9
|
const step_store_1 = require("../execution/step-store");
|
|
8
10
|
class TypeOrmStepStore {
|
|
9
11
|
repo;
|
|
10
12
|
constructor(repo) {
|
|
11
13
|
this.repo = repo;
|
|
12
14
|
}
|
|
13
|
-
async createSteps(records) {
|
|
15
|
+
async createSteps(executionId, records) {
|
|
14
16
|
if (records.length === 0)
|
|
15
17
|
return [];
|
|
16
|
-
for (const record of records)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
for (const record of records)
|
|
19
|
+
assertCreatableRecord(record);
|
|
20
|
+
const rows = records.map((record) => ({ ...record, executionId, id: (0, generate_id_1.generateId)() }));
|
|
21
|
+
return await this.repo.manager.transaction(async (manager) => {
|
|
22
|
+
await manager.query('SELECT id FROM workflow_execution WHERE id = $1 FOR SHARE', [
|
|
23
|
+
executionId,
|
|
24
|
+
]);
|
|
25
|
+
const [failed] = await manager.query(`SELECT id FROM workflow_step_execution
|
|
26
|
+
WHERE execution_id = $1 AND status = 'failed'
|
|
27
|
+
LIMIT 1`, [executionId]);
|
|
28
|
+
if (failed)
|
|
29
|
+
return [];
|
|
30
|
+
const result = await manager
|
|
31
|
+
.createQueryBuilder()
|
|
32
|
+
.insert()
|
|
33
|
+
.into(entities_1.WorkflowStepExecution)
|
|
34
|
+
.values(rows)
|
|
35
|
+
.orIgnore()
|
|
36
|
+
.returning(['id', 'nodeId'])
|
|
37
|
+
.execute();
|
|
38
|
+
return result.raw.map(({ id, node_id: nodeId }) => ({ id, nodeId }));
|
|
39
|
+
});
|
|
30
40
|
}
|
|
31
41
|
async loadStep(id) {
|
|
32
42
|
const row = await this.repo.findOne({ where: { id } });
|
|
@@ -35,24 +45,35 @@ class TypeOrmStepStore {
|
|
|
35
45
|
return row;
|
|
36
46
|
}
|
|
37
47
|
async claimStep(id) {
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
return await this.repo.manager.transaction(async (manager) => {
|
|
49
|
+
const [execution] = await manager.query(`SELECT id FROM workflow_execution
|
|
50
|
+
WHERE id = (SELECT execution_id FROM workflow_step_execution WHERE id = $1)
|
|
51
|
+
FOR SHARE`, [id]);
|
|
52
|
+
if (!execution)
|
|
53
|
+
return null;
|
|
54
|
+
const result = await manager
|
|
55
|
+
.createQueryBuilder()
|
|
56
|
+
.update(entities_1.WorkflowStepExecution)
|
|
57
|
+
.set({ status: 'running' })
|
|
58
|
+
.where({ id, status: 'queued' })
|
|
59
|
+
.andWhere(`NOT EXISTS (
|
|
60
|
+
SELECT 1 FROM workflow_step_execution sibling
|
|
61
|
+
WHERE sibling.execution_id = :executionId AND sibling.status = 'failed'
|
|
62
|
+
)`, { executionId: execution.id })
|
|
63
|
+
.returning(['id', 'executionId', 'nodeId'])
|
|
64
|
+
.execute();
|
|
65
|
+
const [row] = result.raw;
|
|
66
|
+
if (!row)
|
|
67
|
+
return null;
|
|
68
|
+
return {
|
|
69
|
+
id: row.id,
|
|
70
|
+
executionId: row.execution_id,
|
|
71
|
+
nodeId: row.node_id,
|
|
72
|
+
status: 'running',
|
|
73
|
+
outputs: null,
|
|
74
|
+
error: null,
|
|
75
|
+
};
|
|
76
|
+
});
|
|
56
77
|
}
|
|
57
78
|
async completeStep(id, outputs) {
|
|
58
79
|
return await this.transition(id, 'running', 'completed', { outputs });
|
|
@@ -61,38 +82,45 @@ class TypeOrmStepStore {
|
|
|
61
82
|
await this.repo.update({ executionId, status: 'queued' }, { status: 'cancelled' });
|
|
62
83
|
}
|
|
63
84
|
async failStep(id, error) {
|
|
64
|
-
return await this.
|
|
85
|
+
return await this.repo.manager.transaction(async (manager) => {
|
|
86
|
+
await manager.query(`SELECT id FROM workflow_execution
|
|
87
|
+
WHERE id = (SELECT execution_id FROM workflow_step_execution WHERE id = $1)
|
|
88
|
+
FOR NO KEY UPDATE`, [id]);
|
|
89
|
+
const result = await manager.update(entities_1.WorkflowStepExecution, { id, status: 'running' }, { error, status: 'failed' });
|
|
90
|
+
return result.affected === 1;
|
|
91
|
+
});
|
|
65
92
|
}
|
|
66
93
|
async transition(id, from, to, fields = {}) {
|
|
67
94
|
const result = await this.repo.update({ id, status: from }, { ...fields, status: to });
|
|
68
95
|
return result.affected === 1;
|
|
69
96
|
}
|
|
70
|
-
async
|
|
71
|
-
const outputsByNodeId = {};
|
|
72
|
-
for (const nodeId of nodeIds)
|
|
73
|
-
outputsByNodeId[nodeId] = null;
|
|
97
|
+
async loadStepsByNodeIds(executionId, nodeIds) {
|
|
74
98
|
if (nodeIds.length === 0)
|
|
75
|
-
return
|
|
76
|
-
const rows = await this.repo.find({
|
|
77
|
-
|
|
78
|
-
select: ['nodeId', 'outputs'],
|
|
79
|
-
});
|
|
80
|
-
for (const row of rows)
|
|
81
|
-
outputsByNodeId[row.nodeId] = row.outputs;
|
|
82
|
-
return outputsByNodeId;
|
|
99
|
+
return {};
|
|
100
|
+
const rows = await this.repo.find({ where: { executionId, nodeId: (0, typeorm_1.In)(nodeIds) } });
|
|
101
|
+
return Object.fromEntries(rows.map((row) => [row.nodeId, row]));
|
|
83
102
|
}
|
|
84
|
-
async
|
|
103
|
+
async loadStepSummaries(executionId, nodeIds) {
|
|
85
104
|
if (nodeIds.length === 0)
|
|
86
|
-
return
|
|
87
|
-
const rows = await this.repo
|
|
88
|
-
|
|
89
|
-
select
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
return {};
|
|
106
|
+
const rows = await this.repo
|
|
107
|
+
.createQueryBuilder('step')
|
|
108
|
+
.select('step.id', 'id')
|
|
109
|
+
.addSelect('step.node_id', 'nodeId')
|
|
110
|
+
.addSelect('step.status', 'status')
|
|
111
|
+
.addSelect(`COALESCE(
|
|
112
|
+
(SELECT array_agg(jsonb_typeof(slot.value) <> 'null' ORDER BY slot.ordinality)
|
|
113
|
+
FROM jsonb_array_elements(step.outputs) WITH ORDINALITY AS slot),
|
|
114
|
+
'{}'
|
|
115
|
+
)`, 'filledOutputSlots')
|
|
116
|
+
.where('step.execution_id = :executionId', { executionId })
|
|
117
|
+
.andWhere('step.node_id IN (:...nodeIds)', { nodeIds })
|
|
118
|
+
.getRawMany();
|
|
119
|
+
return Object.fromEntries(rows.map((row) => [row.nodeId, row]));
|
|
92
120
|
}
|
|
93
|
-
async
|
|
94
|
-
return await this.repo.
|
|
95
|
-
where: { executionId, status: (0, typeorm_1.In)([
|
|
121
|
+
async countSettledSteps(executionId) {
|
|
122
|
+
return await this.repo.count({
|
|
123
|
+
where: { executionId, status: (0, typeorm_1.In)([...execution_types_1.SETTLED_STEP_STATUSES]) },
|
|
96
124
|
});
|
|
97
125
|
}
|
|
98
126
|
async hasFailedSteps(executionId) {
|
|
@@ -100,4 +128,16 @@ class TypeOrmStepStore {
|
|
|
100
128
|
}
|
|
101
129
|
}
|
|
102
130
|
exports.TypeOrmStepStore = TypeOrmStepStore;
|
|
131
|
+
const CREATION_STATUSES = ['queued', 'completed', 'skipped'];
|
|
132
|
+
function assertCreatableRecord(record) {
|
|
133
|
+
if (!CREATION_STATUSES.includes(record.status)) {
|
|
134
|
+
throw new common_1.UnexpectedError(`step for node ${record.nodeId} is created ${record.status}, a status only reachable through its transition method`);
|
|
135
|
+
}
|
|
136
|
+
if (record.outputs !== undefined && record.status !== 'completed') {
|
|
137
|
+
throw new common_1.UnexpectedError(`step for node ${record.nodeId} is created ${record.status} with outputs, which only a step created completed may carry`);
|
|
138
|
+
}
|
|
139
|
+
if (record.status === 'completed' && !Array.isArray(record.outputs)) {
|
|
140
|
+
throw new common_1.UnexpectedError(`step for node ${record.nodeId} is created completed without a slot list, which persists as NULL and reads as every slot dead (pass [] for a step that fired nothing)`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
103
143
|
//# 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,0CAAmD;
|
|
1
|
+
{"version":3,"file":"typeorm-step-store.js","sourceRoot":"","sources":["../../src/database/typeorm-step-store.ts"],"names":[],"mappings":";;;AAAA,0CAAmD;AAEnD,yCAAmD;AACnD,+CAA2C;AAC3C,sCAA4C;AAC5C,kEAIsC;AACtC,wDAOiC;AAOjC;IAC8B,IAAI;IAAjC,YAA6B,IAAuC;oBAAvC,IAAI;IAAsC,CAAC;IAExE,KAAK,CAAC,WAAW,CAChB,WAAmB,EACnB,OAAwB;QAExB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAEpC,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAI5D,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,IAAA,wBAAU,GAAE,EAAE,CAAC,CAAC,CAAC;QAKrF,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC5D,MAAM,OAAO,CAAC,KAAK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MAAM,eAAe,MAAM,CAAC,MAAM,yDAAyD,CACnH,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACnE,MAAM,IAAI,wBAAe,CACxB,iBAAiB,MAAM,CAAC,MAAM,eAAe,MAAM,CAAC,MAAM,8DAA8D,CACxH,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,wBAAe,CACxB,iBAAiB,MAAM,CAAC,MAAM,wIAAwI,CACtK,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -21,9 +21,8 @@ class ExecutionStartHandler {
|
|
|
21
21
|
if (!trigger) {
|
|
22
22
|
throw new common_1.UnexpectedError(`Execution ${event.executionId} has no trigger node in its graph`);
|
|
23
23
|
}
|
|
24
|
-
const [triggerStep] = await this.stepStore.createSteps([
|
|
24
|
+
const [triggerStep] = await this.stepStore.createSteps(event.executionId, [
|
|
25
25
|
{
|
|
26
|
-
executionId: event.executionId,
|
|
27
26
|
nodeId: trigger.id,
|
|
28
27
|
status: 'completed',
|
|
29
28
|
outputs: [execution.triggerPayload ?? {}],
|
|
@@ -33,7 +32,7 @@ class ExecutionStartHandler {
|
|
|
33
32
|
throw new common_1.UnexpectedError(`Trigger step for execution ${event.executionId} already existed despite the claim`);
|
|
34
33
|
}
|
|
35
34
|
await this.orchestrationQueue.publish({
|
|
36
|
-
type: 'step:
|
|
35
|
+
type: 'step:settled',
|
|
37
36
|
executionId: event.executionId,
|
|
38
37
|
stepId: triggerStep.id,
|
|
39
38
|
});
|
|
@@ -1 +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
|
|
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,KAAK,CAAC,WAAW,EAAE;YACzE;gBACC,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,cAAc;YACpB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,MAAM,EAAE,WAAW,CAAC,EAAE;SACtB,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { JsonValue } from '../common';
|
|
2
2
|
export type ExecutionStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
3
3
|
export type ExecutionMode = 'production' | 'manual';
|
|
4
|
-
export type StepStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
4
|
+
export type StepStatus = 'queued' | 'running' | 'completed' | 'failed' | 'skipped' | 'cancelled';
|
|
5
|
+
export declare const SETTLED_STEP_STATUSES: readonly StepStatus[];
|
|
6
|
+
export declare function isSettledStatus(status: StepStatus): boolean;
|
|
5
7
|
export type StepSlots = JsonValue[];
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SETTLED_STEP_STATUSES = void 0;
|
|
4
|
+
exports.isSettledStatus = isSettledStatus;
|
|
5
|
+
exports.SETTLED_STEP_STATUSES = [
|
|
6
|
+
'completed',
|
|
7
|
+
'failed',
|
|
8
|
+
'skipped',
|
|
9
|
+
'cancelled',
|
|
10
|
+
];
|
|
11
|
+
function isSettledStatus(status) {
|
|
12
|
+
return exports.SETTLED_STEP_STATUSES.includes(status);
|
|
13
|
+
}
|
|
3
14
|
//# sourceMappingURL=execution.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.types.js","sourceRoot":"","sources":["../../src/execution/execution.types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"execution.types.js","sourceRoot":"","sources":["../../src/execution/execution.types.ts"],"names":[],"mappings":";;;;AAoBa,QAAA,qBAAqB,GAA0B;IAC3D,WAAW;IACX,QAAQ;IACR,SAAS;IACT,WAAW;CACX,CAAC;AAEF,yBAAgC,MAAkB;IACjD,OAAO,QAAA,qBAAqB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -7,6 +7,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 {
|
|
10
|
+
export { StepSettledHandler } from './step-settled-handler';
|
|
11
11
|
export { StepReadyHandler } from './step-ready-handler';
|
|
12
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.StepWorker = exports.StepReadyHandler = exports.
|
|
3
|
+
exports.StepWorker = exports.StepReadyHandler = exports.StepSettledHandler = 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,8 +11,8 @@ 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
|
|
15
|
-
Object.defineProperty(exports, "
|
|
14
|
+
var step_settled_handler_1 = require("./step-settled-handler");
|
|
15
|
+
Object.defineProperty(exports, "StepSettledHandler", { enumerable: true, get: function () { return step_settled_handler_1.StepSettledHandler; } });
|
|
16
16
|
var step_ready_handler_1 = require("./step-ready-handler");
|
|
17
17
|
Object.defineProperty(exports, "StepReadyHandler", { enumerable: true, get: function () { return step_ready_handler_1.StepReadyHandler; } });
|
|
18
18
|
var step_worker_1 = require("./step-worker");
|
|
@@ -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;AAC5B
|
|
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,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { OrchestrationMessage, WorkQueue } from '../queue';
|
|
2
2
|
import type { ExecutionStartHandler } from './execution-start-handler';
|
|
3
|
-
import type {
|
|
3
|
+
import type { StepSettledHandler } from './step-settled-handler';
|
|
4
4
|
export declare class OrchestrationWorker {
|
|
5
5
|
private readonly orchestrationQueue;
|
|
6
6
|
private readonly startHandler;
|
|
7
|
-
private readonly
|
|
8
|
-
constructor(orchestrationQueue: WorkQueue<OrchestrationMessage>, startHandler: ExecutionStartHandler,
|
|
7
|
+
private readonly settledHandler;
|
|
8
|
+
constructor(orchestrationQueue: WorkQueue<OrchestrationMessage>, startHandler: ExecutionStartHandler, settledHandler: StepSettledHandler);
|
|
9
9
|
start(): void;
|
|
10
10
|
stop(): Promise<void>;
|
|
11
11
|
}
|
|
@@ -5,11 +5,11 @@ const common_1 = require("../common");
|
|
|
5
5
|
class OrchestrationWorker {
|
|
6
6
|
orchestrationQueue;
|
|
7
7
|
startHandler;
|
|
8
|
-
|
|
9
|
-
constructor(orchestrationQueue, startHandler,
|
|
8
|
+
settledHandler;
|
|
9
|
+
constructor(orchestrationQueue, startHandler, settledHandler) {
|
|
10
10
|
this.orchestrationQueue = orchestrationQueue;
|
|
11
11
|
this.startHandler = startHandler;
|
|
12
|
-
this.
|
|
12
|
+
this.settledHandler = settledHandler;
|
|
13
13
|
}
|
|
14
14
|
start() {
|
|
15
15
|
this.orchestrationQueue.start(async (message) => {
|
|
@@ -17,8 +17,8 @@ class OrchestrationWorker {
|
|
|
17
17
|
case 'execution:enqueued':
|
|
18
18
|
await this.startHandler.handle(message);
|
|
19
19
|
break;
|
|
20
|
-
case 'step:
|
|
21
|
-
await this.
|
|
20
|
+
case 'step:settled':
|
|
21
|
+
await this.settledHandler.handle(message);
|
|
22
22
|
break;
|
|
23
23
|
default: {
|
|
24
24
|
const unhandled = message;
|
|
@@ -1 +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,
|
|
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,cAAc;IAHhC,YACkB,kBAAmD,EACnD,YAAmC,EACnC,cAAkC;kCAFlC,kBAAkB;4BAClB,YAAY;8BACZ,cAAc;IAC7B,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,cAAc;oBAClB,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBAC1C,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type WorkflowGraph } from '../graph';
|
|
2
|
+
import type { StepSummary } from './step-store';
|
|
3
|
+
export interface SuccessorDecisions {
|
|
4
|
+
toQueue: string[];
|
|
5
|
+
toSkip: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function decideSuccessors(graph: WorkflowGraph, settledNodeId: string, steps: Record<string, StepSummary>): SuccessorDecisions;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decideSuccessors = decideSuccessors;
|
|
4
|
+
const graph_1 = require("../graph");
|
|
5
|
+
const execution_types_1 = require("./execution.types");
|
|
6
|
+
function decideSuccessors(graph, settledNodeId, steps) {
|
|
7
|
+
const decisions = { toQueue: [], toSkip: [] };
|
|
8
|
+
for (const successor of (0, graph_1.getSuccessorNodeIds)(graph, settledNodeId)) {
|
|
9
|
+
if (steps[successor])
|
|
10
|
+
continue;
|
|
11
|
+
const fate = decideNodeFate(graph, successor, steps);
|
|
12
|
+
if (fate === 'queued')
|
|
13
|
+
decisions.toQueue.push(successor);
|
|
14
|
+
else if (fate === 'skipped')
|
|
15
|
+
decisions.toSkip.push(successor);
|
|
16
|
+
}
|
|
17
|
+
return decisions;
|
|
18
|
+
}
|
|
19
|
+
function decideNodeFate(graph, nodeId, steps) {
|
|
20
|
+
const incoming = graph.edges.filter((edge) => edge.to === nodeId && !edge.isBackEdge);
|
|
21
|
+
const predecessors = [...new Set(incoming.map((edge) => edge.from))];
|
|
22
|
+
const settled = predecessors.every((id) => steps[id] !== undefined && (0, execution_types_1.isSettledStatus)(steps[id].status));
|
|
23
|
+
if (!settled)
|
|
24
|
+
return 'undecidable';
|
|
25
|
+
return incoming.some((edge) => isLiveEdge(edge, steps)) ? 'queued' : 'skipped';
|
|
26
|
+
}
|
|
27
|
+
function isLiveEdge(edge, steps) {
|
|
28
|
+
const source = steps[edge.from];
|
|
29
|
+
return source?.status === 'completed' && Boolean(source.filledOutputSlots[edge.outputIndex]);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=settlement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlement.js","sourceRoot":"","sources":["../../src/execution/settlement.ts"],"names":[],"mappings":";;;AAAA,oCAAmF;AACnF,uDAAoD;AAwCpD,0BACC,KAAoB,EACpB,aAAqB,EACrB,KAAkC;IAElC,MAAM,SAAS,GAAuB,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAClE,KAAK,MAAM,SAAS,IAAI,IAAA,2BAAmB,EAAC,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC;QAEnE,IAAI,KAAK,CAAC,SAAS,CAAC;YAAE,SAAS;QAC/B,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACrD,IAAI,IAAI,KAAK,QAAQ;YAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACpD,IAAI,IAAI,KAAK,SAAS;YAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAGD,SAAS,cAAc,CACtB,KAAoB,EACpB,MAAc,EACd,KAAkC;IAGlC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACtF,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrE,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CACjC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,SAAS,IAAI,IAAA,iCAAe,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CACpE,CAAC;IACF,IAAI,CAAC,OAAO;QAAE,OAAO,aAAa,CAAC;IACnC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC;AAGD,SAAS,UAAU,CAAC,IAAe,EAAE,KAAkC;IACtE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,MAAM,EAAE,MAAM,KAAK,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -10,7 +10,6 @@ export declare class StepReadyHandler {
|
|
|
10
10
|
constructor(executionStore: ExecutionStore, stepStore: StepStore, orchestrationQueue: WorkQueue<OrchestrationMessage>, dependencies: ExternalDependencies);
|
|
11
11
|
handle(event: StepReadyEvent): Promise<void>;
|
|
12
12
|
private runStep;
|
|
13
|
-
private assertOutputFiredForSuccessors;
|
|
14
13
|
private gatherInputs;
|
|
15
14
|
private executorFor;
|
|
16
15
|
}
|