@n8n/engine 0.13.0 → 0.14.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.
Files changed (57) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/common/errors.d.ts +3 -0
  3. package/dist/common/errors.js +11 -0
  4. package/dist/common/errors.js.map +1 -0
  5. package/dist/common/index.d.ts +1 -0
  6. package/dist/common/index.js +3 -0
  7. package/dist/common/index.js.map +1 -1
  8. package/dist/database/entities/workflow-step-execution.entity.d.ts +4 -0
  9. package/dist/database/entities/workflow-step-execution.entity.js +11 -1
  10. package/dist/database/entities/workflow-step-execution.entity.js.map +1 -1
  11. package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js +16 -1
  12. package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js.map +1 -1
  13. package/dist/database/typeorm-execution-store.d.ts +4 -1
  14. package/dist/database/typeorm-execution-store.js +12 -1
  15. package/dist/database/typeorm-execution-store.js.map +1 -1
  16. package/dist/database/typeorm-step-store.d.ts +11 -4
  17. package/dist/database/typeorm-step-store.js +39 -4
  18. package/dist/database/typeorm-step-store.js.map +1 -1
  19. package/dist/execution/execution-start-handler.d.ts +10 -0
  20. package/dist/execution/execution-start-handler.js +43 -0
  21. package/dist/execution/execution-start-handler.js.map +1 -0
  22. package/dist/execution/execution-store.d.ts +14 -0
  23. package/dist/execution/execution-store.js +10 -0
  24. package/dist/execution/execution-store.js.map +1 -1
  25. package/dist/execution/index.d.ts +6 -2
  26. package/dist/execution/index.js +9 -1
  27. package/dist/execution/index.js.map +1 -1
  28. package/dist/execution/orchestration-worker.d.ts +9 -0
  29. package/dist/execution/orchestration-worker.js +28 -0
  30. package/dist/execution/orchestration-worker.js.map +1 -0
  31. package/dist/execution/start-execution.service.d.ts +2 -2
  32. package/dist/execution/start-execution.service.js.map +1 -1
  33. package/dist/execution/step-store.d.ts +26 -2
  34. package/dist/execution/step-store.js +10 -0
  35. package/dist/execution/step-store.js.map +1 -1
  36. package/dist/graph/index.d.ts +1 -0
  37. package/dist/graph/index.js +4 -0
  38. package/dist/graph/index.js.map +1 -1
  39. package/dist/graph/workflow-graph-queries.d.ts +3 -0
  40. package/dist/graph/workflow-graph-queries.js +17 -0
  41. package/dist/graph/workflow-graph-queries.js.map +1 -0
  42. package/dist/graph/workflow-graph.d.ts +2 -2
  43. package/dist/index.d.ts +3 -2
  44. package/dist/index.js +6 -1
  45. package/dist/index.js.map +1 -1
  46. package/dist/queue/in-memory-work-queue.d.ts +11 -4
  47. package/dist/queue/in-memory-work-queue.js +44 -2
  48. package/dist/queue/in-memory-work-queue.js.map +1 -1
  49. package/dist/queue/index.d.ts +1 -1
  50. package/dist/queue/index.js.map +1 -1
  51. package/dist/queue/work-queue.types.d.ts +11 -3
  52. package/dist/serve.js +13 -5
  53. package/dist/serve.js.map +1 -1
  54. package/dist/server/create-engine-server.d.ts +2 -2
  55. package/dist/server/routes/workflow-executions.js +2 -2
  56. package/dist/server/routes/workflow-executions.js.map +1 -1
  57. package/package.json +6 -6
@@ -0,0 +1,3 @@
1
+ export declare class UnimplementedError extends Error {
2
+ constructor(message: string);
3
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ 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
+ //# 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"}
@@ -1 +1,2 @@
1
1
  export type { JsonObject, JsonValue } from './json';
2
+ export { UnimplementedError } from './errors';
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnimplementedError = void 0;
4
+ var errors_1 = require("./errors");
5
+ Object.defineProperty(exports, "UnimplementedError", { enumerable: true, get: function () { return errors_1.UnimplementedError; } });
3
6
  //# sourceMappingURL=index.js.map
@@ -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,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA"}
@@ -1,9 +1,13 @@
1
+ import type { JsonValue } from '../../common';
1
2
  import type { StepStatus } from '../../execution/execution.types';
3
+ import type { StepError } from '../../execution/step-store';
2
4
  export declare class WorkflowStepExecution {
3
5
  id: string;
4
6
  executionId: string;
5
7
  nodeId: string;
6
8
  status: StepStatus;
9
+ outputs: JsonValue | null;
10
+ error: StepError | null;
7
11
  createdAt: Date;
8
12
  updatedAt: Date;
9
13
  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,6 @@ __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)('idx_workflow_step_execution_execution_id', ['executionId'])
70
+ (0, typeorm_1.Index)('idx_workflow_step_execution_execution_id_node_id', ['executionId', 'nodeId'])
61
71
  ], WorkflowStepExecution);
62
72
  //# 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;AAGtB,gDAA4C;AAIrC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEjC,EAAE,CAAU;IAGZ,WAAW,CAAU;IAGrB,MAAM,CAAU;IAGhB,MAAM,CAAc;IAGpB,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;;AArBA;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,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;gCAtBW,qBAAqB;IAFjC,IAAA,gBAAM,EAAC,yBAAyB,CAAC;IACjC,IAAA,eAAK,EAAC,0CAA0C,EAAE,CAAC,aAAa,CAAC,CAAC;GACtD,qBAAqB,CAuBjC"}
1
+ {"version":3,"file":"workflow-step-execution.entity.js","sourceRoot":"","sources":["../../../src/database/entities/workflow-step-execution.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAQsB;AAKtB,gDAA4C;AAIrC,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;IAFjC,IAAA,gBAAM,EAAC,yBAAyB,CAAC;IACjC,IAAA,eAAK,EAAC,kDAAkD,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;GACxE,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,10 @@ class CreateWorkflowStepExecution1784890100000 {
26
38
  },
27
39
  ],
28
40
  indices: [
29
- { name: 'idx_workflow_step_execution_execution_id', columnNames: ['execution_id'] },
41
+ {
42
+ name: 'idx_workflow_step_execution_execution_id_node_id',
43
+ columnNames: ['execution_id', 'node_id'],
44
+ },
30
45
  ],
31
46
  foreignKeys: [
32
47
  {
@@ -1 +1 @@
1
- {"version":3,"file":"1784890100000-CreateWorkflowStepExecution.js","source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M,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACD"}
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,kDAAkD;oBACxD,WAAW,EAAE,CAAC,cAAc,EAAE,SAAS,CAAC;iBACxC;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,13 @@
1
1
  import type { Repository } from '@n8n/typeorm';
2
2
  import type { WorkflowExecution } from './entities';
3
- import type { ExecutionStore, NewExecutionRecord } from '../execution/execution-store';
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>;
10
13
  }
@@ -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,19 @@ class TypeOrmExecutionStore {
8
9
  }
9
10
  async createExecution(record) {
10
11
  const execution = this.repo.create({ ...record, finishedAt: null });
11
- await this.repo.save(execution);
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
+ }
14
25
  }
15
26
  exports.TypeOrmExecutionStore = TypeOrmExecutionStore;
16
27
  //# 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":";;;AAMA;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;QACpE,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChC,OAAO,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;IAC7B,CAAC;CACD"}
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;CACD"}
@@ -1,10 +1,17 @@
1
- import type { Repository } from '@n8n/typeorm';
1
+ import { type Repository } from '@n8n/typeorm';
2
2
  import type { WorkflowStepExecution } from './entities';
3
- import type { NewStepRecord, StepStore } from '../execution/step-store';
3
+ import type { JsonValue } from '../common';
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
- createStep(record: NewStepRecord): Promise<{
8
+ createSteps(records: NewStepRecord[]): Promise<Array<{
8
9
  id: string;
9
- }>;
10
+ }>>;
11
+ loadStep(id: string): Promise<StepRecord>;
12
+ claimStep(id: string): Promise<boolean>;
13
+ completeStep(id: string, outputs: JsonValue): Promise<boolean>;
14
+ failStep(id: string, error: StepError): Promise<boolean>;
15
+ private transition;
16
+ loadStepOutputs(executionId: string, nodeIds: string[]): Promise<Record<string, JsonValue | null>>;
10
17
  }
@@ -1,15 +1,50 @@
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 step_store_1 = require("../execution/step-store");
4
6
  class TypeOrmStepStore {
5
7
  repo;
6
8
  constructor(repo) {
7
9
  this.repo = repo;
8
10
  }
9
- async createStep(record) {
10
- const step = this.repo.create(record);
11
- await this.repo.save(step);
12
- return { id: step.id };
11
+ async createSteps(records) {
12
+ const steps = records.map((record) => this.repo.create(record));
13
+ await this.repo.insert(steps);
14
+ return steps.map(({ id }) => ({ id }));
15
+ }
16
+ async loadStep(id) {
17
+ const row = await this.repo.findOne({ where: { id } });
18
+ if (!row)
19
+ throw new step_store_1.StepNotFoundError(id);
20
+ return row;
21
+ }
22
+ async claimStep(id) {
23
+ return await this.transition(id, 'queued', 'running');
24
+ }
25
+ async completeStep(id, outputs) {
26
+ return await this.transition(id, 'running', 'completed', { outputs });
27
+ }
28
+ async failStep(id, error) {
29
+ return await this.transition(id, 'running', 'failed', { error });
30
+ }
31
+ async transition(id, from, to, fields = {}) {
32
+ const result = await this.repo.update({ id, status: from }, { ...fields, status: to });
33
+ return result.affected === 1;
34
+ }
35
+ async loadStepOutputs(executionId, nodeIds) {
36
+ const outputsByNodeId = {};
37
+ for (const nodeId of nodeIds)
38
+ outputsByNodeId[nodeId] = null;
39
+ if (nodeIds.length === 0)
40
+ return outputsByNodeId;
41
+ const rows = await this.repo.find({
42
+ where: { executionId, nodeId: (0, typeorm_1.In)(nodeIds), status: 'completed' },
43
+ select: ['nodeId', 'outputs'],
44
+ });
45
+ for (const row of rows)
46
+ outputsByNodeId[row.nodeId] = row.outputs;
47
+ return outputsByNodeId;
13
48
  }
14
49
  }
15
50
  exports.TypeOrmStepStore = TypeOrmStepStore;
@@ -1 +1 @@
1
- {"version":3,"file":"typeorm-step-store.js","sourceRoot":"","sources":["../../src/database/typeorm-step-store.ts"],"names":[],"mappings":";;;AAMA;IAC8B,IAAI;IAAjC,YAA6B,IAAuC;oBAAvC,IAAI;IAAsC,CAAC;IAExE,KAAK,CAAC,UAAU,CAAC,MAAqB;QACrC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xB,CAAC;CACD"}
@@ -0,0 +1,10 @@
1
+ import type { ExecutionEnqueuedEvent, StepMessage, 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 stepQueue;
8
+ constructor(executionStore: ExecutionStore, stepStore: StepStore, stepQueue: WorkQueue<StepMessage>);
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 graph_1 = require("../graph");
5
+ class ExecutionStartHandler {
6
+ executionStore;
7
+ stepStore;
8
+ stepQueue;
9
+ constructor(executionStore, stepStore, stepQueue) {
10
+ this.executionStore = executionStore;
11
+ this.stepStore = stepStore;
12
+ this.stepQueue = stepQueue;
13
+ }
14
+ async handle(event) {
15
+ const claimed = await this.executionStore.transitionStatus(event.executionId, 'queued', 'running');
16
+ if (!claimed)
17
+ return;
18
+ const execution = await this.executionStore.loadExecution(event.executionId);
19
+ const trigger = (0, graph_1.findTriggerNode)(execution.graph);
20
+ if (!trigger) {
21
+ await this.executionStore.transitionStatus(event.executionId, 'running', 'failed');
22
+ return;
23
+ }
24
+ const successorNodeIds = (0, graph_1.getSuccessorNodeIds)(execution.graph, trigger.id);
25
+ const [, ...successorSteps] = await this.stepStore.createSteps([
26
+ { executionId: event.executionId, nodeId: trigger.id, status: 'completed' },
27
+ ...successorNodeIds.map((nodeId) => ({
28
+ executionId: event.executionId,
29
+ nodeId,
30
+ status: 'queued',
31
+ })),
32
+ ]);
33
+ for (const { id: stepId } of successorSteps) {
34
+ await this.stepQueue.publish({
35
+ type: 'step:ready',
36
+ executionId: event.executionId,
37
+ stepId,
38
+ });
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,oCAAgE;AAUhE;IAEmB,cAAc;IACd,SAAS;IACT,SAAS;IAH3B,YACkB,cAA8B,EAC9B,SAAoB,EACpB,SAAiC;8BAFjC,cAAc;yBACd,SAAS;yBACT,SAAS;IACxB,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;YAEd,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;YACnF,OAAO;QACR,CAAC;QAKD,MAAM,gBAAgB,GAAG,IAAA,2BAAmB,EAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;QAC1E,MAAM,CAAC,EAAE,GAAG,cAAc,CAAC,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;YAC9D,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;YAC3E,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBACpC,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,MAAM;gBACN,MAAM,EAAE,QAAiB;aACzB,CAAC,CAAC;SACH,CAAC,CAAC;QAGH,KAAK,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,cAAc,EAAE,CAAC;YAC7C,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBAC5B,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,MAAM;aACN,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD"}
@@ -8,8 +8,22 @@ 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>;
15
29
  }
@@ -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,5 +1,9 @@
1
1
  export { StartExecutionService } from './start-execution.service';
2
2
  export type { StartExecutionRequest, StartExecutionResult, } from './start-execution.service';
3
3
  export type { ExecutionMode, ExecutionStatus, StepStatus } from './execution.types';
4
- export type { ExecutionStore, NewExecutionRecord } from './execution-store';
5
- export type { NewStepRecord, StepStore } from './step-store';
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';
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StartExecutionService = void 0;
3
+ 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; } });
6
14
  //# 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"}
@@ -0,0 +1,9 @@
1
+ import type { OrchestrationMessage, WorkQueue } from '../queue';
2
+ import type { ExecutionStartHandler } from './execution-start-handler';
3
+ export declare class OrchestrationWorker {
4
+ private readonly orchestrationQueue;
5
+ private readonly startHandler;
6
+ constructor(orchestrationQueue: WorkQueue<OrchestrationMessage>, startHandler: ExecutionStartHandler);
7
+ start(): void;
8
+ stop(): Promise<void>;
9
+ }
@@ -0,0 +1,28 @@
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
+ constructor(orchestrationQueue, startHandler) {
9
+ this.orchestrationQueue = orchestrationQueue;
10
+ this.startHandler = startHandler;
11
+ }
12
+ start() {
13
+ this.orchestrationQueue.start(async (message) => {
14
+ switch (message.type) {
15
+ case 'execution:enqueued':
16
+ await this.startHandler.handle(message);
17
+ break;
18
+ default:
19
+ throw new common_1.UnimplementedError(`orchestration worker received an unimplemented message type: ${String(message.type)}`);
20
+ }
21
+ });
22
+ }
23
+ async stop() {
24
+ await this.orchestrationQueue.stop();
25
+ }
26
+ }
27
+ exports.OrchestrationWorker = OrchestrationWorker;
28
+ //# 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;AAO/C;IAEmB,kBAAkB;IAClB,YAAY;IAF9B,YACkB,kBAAmD,EACnD,YAAmC;kCADnC,kBAAkB;4BAClB,YAAY;IAC3B,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;oBACC,MAAM,IAAI,2BAAkB,CAC3B,gEAAgE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CACtF,CAAC;YACJ,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
3
  import type { WorkflowGraph } from '../graph';
4
- import type { WorkQueue } from '../queue';
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,6 @@ export declare class StartExecutionService {
17
17
  private readonly admittance;
18
18
  private readonly executionStore;
19
19
  private readonly workQueue;
20
- constructor(admittance: AdmittanceService, executionStore: ExecutionStore, workQueue: WorkQueue);
20
+ constructor(admittance: AdmittanceService, executionStore: ExecutionStore, workQueue: WorkQueue<OrchestrationMessage>);
21
21
  start(request: StartExecutionRequest): Promise<StartExecutionResult>;
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"start-execution.service.js","sourceRoot":"","sources":["../../src/execution/start-execution.service.ts"],"names":[],"mappings":";;;AAAA,8CAAgF;AAkBhF;IAEmB,UAAU;IACV,cAAc;IACd,SAAS;IAH3B,YACkB,UAA6B,EAC7B,cAA8B,EAC9B,SAAoB;0BAFpB,UAAU;8BACV,cAAc;yBACd,SAAS;IACxB,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,OAA8B;QACzC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QACpF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,IAAI,oCAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC;YACxD,UAAU,EAAE,OAAO,CAAC,UAAU;YAE9B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,YAAY;YAClC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,IAAI;SAC9C,CAAC,CAAC;QAKH,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5B,IAAI,EAAE,oBAAoB;YAC1B,WAAW,EAAE,EAAE;SACf,CAAC,CAAC;QAEH,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAC5B,CAAC;CACD"}
1
+ {"version":3,"file":"start-execution.service.js","sourceRoot":"","sources":["../../src/execution/start-execution.service.ts"],"names":[],"mappings":";;;AAAA,8CAAgF;AAkBhF;IAEmB,UAAU;IACV,cAAc;IACd,SAAS;IAH3B,YACkB,UAA6B,EAC7B,cAA8B,EAC9B,SAA0C;0BAF1C,UAAU;8BACV,cAAc;yBACd,SAAS;IACxB,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,OAA8B;QACzC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QACpF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,IAAI,oCAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC;YACxD,UAAU,EAAE,OAAO,CAAC,UAAU;YAE9B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,YAAY;YAClC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,IAAI;SAC9C,CAAC,CAAC;QAKH,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5B,IAAI,EAAE,oBAAoB;YAC1B,WAAW,EAAE,EAAE;SACf,CAAC,CAAC;QAEH,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAC5B,CAAC;CACD"}
@@ -1,11 +1,35 @@
1
+ import type { JsonValue } from '../common';
1
2
  import type { StepStatus } from './execution.types';
2
3
  export interface NewStepRecord {
3
4
  executionId: string;
4
5
  nodeId: string;
5
6
  status: StepStatus;
6
7
  }
8
+ export interface StepError {
9
+ name: string;
10
+ message: string;
11
+ stack?: string;
12
+ details?: JsonValue;
13
+ }
14
+ export interface StepRecord {
15
+ id: string;
16
+ executionId: string;
17
+ nodeId: string;
18
+ status: StepStatus;
19
+ outputs: JsonValue | null;
20
+ error: StepError | null;
21
+ }
22
+ export declare class StepNotFoundError extends Error {
23
+ readonly stepId: string;
24
+ constructor(stepId: string);
25
+ }
7
26
  export interface StepStore {
8
- createStep(record: NewStepRecord): Promise<{
27
+ createSteps(records: NewStepRecord[]): Promise<Array<{
9
28
  id: string;
10
- }>;
29
+ }>>;
30
+ loadStep(id: string): Promise<StepRecord>;
31
+ claimStep(id: string): Promise<boolean>;
32
+ completeStep(id: string, outputs: JsonValue): Promise<boolean>;
33
+ failStep(id: string, error: StepError): Promise<boolean>;
34
+ loadStepOutputs(executionId: string, nodeIds: string[]): Promise<Record<string, JsonValue | null>>;
11
35
  }
@@ -1,3 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StepNotFoundError = void 0;
4
+ class StepNotFoundError extends Error {
5
+ stepId;
6
+ constructor(stepId) {
7
+ super(`Step not found: ${stepId}`);
8
+ this.stepId = stepId;
9
+ this.name = 'StepNotFoundError';
10
+ }
11
+ }
12
+ exports.StepNotFoundError = StepNotFoundError;
3
13
  //# sourceMappingURL=step-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"step-store.js","sourceRoot":"","sources":["../../src/execution/step-store.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"step-store.js","sourceRoot":"","sources":["../../src/execution/step-store.ts"],"names":[],"mappings":";;;AAoCA,uBAA+B,SAAQ,KAAK;IACtB,MAAM;IAA3B,YAAqB,MAAc;QAClC,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;sBADf,MAAM;QAE1B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACjC,CAAC;CACD"}
@@ -1 +1,2 @@
1
1
  export type { GraphEdge, GraphNode, StepConfig, StepType, WorkflowGraph, } from './workflow-graph';
2
+ export { findTriggerNode, getSuccessorNodeIds } from './workflow-graph-queries';
@@ -1,3 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSuccessorNodeIds = exports.findTriggerNode = void 0;
4
+ var workflow_graph_queries_1 = require("./workflow-graph-queries");
5
+ Object.defineProperty(exports, "findTriggerNode", { enumerable: true, get: function () { return workflow_graph_queries_1.findTriggerNode; } });
6
+ Object.defineProperty(exports, "getSuccessorNodeIds", { enumerable: true, get: function () { return workflow_graph_queries_1.getSuccessorNodeIds; } });
3
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graph/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graph/index.ts"],"names":[],"mappings":";;;AAOA,mEAAgF;AAAvE,yHAAA,eAAe,OAAA;AAAE,6HAAA,mBAAmB,OAAA"}
@@ -0,0 +1,3 @@
1
+ import type { GraphNode, WorkflowGraph } from './workflow-graph';
2
+ export declare function findTriggerNode(graph: WorkflowGraph): GraphNode | undefined;
3
+ export declare function getSuccessorNodeIds(graph: WorkflowGraph, nodeId: string): string[];
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findTriggerNode = findTriggerNode;
4
+ exports.getSuccessorNodeIds = getSuccessorNodeIds;
5
+ function findTriggerNode(graph) {
6
+ return graph.nodes.find((node) => node.type === 'trigger');
7
+ }
8
+ function getSuccessorNodeIds(graph, nodeId) {
9
+ const successors = [];
10
+ for (const edge of graph.edges) {
11
+ if (edge.from === nodeId && !successors.includes(edge.to)) {
12
+ successors.push(edge.to);
13
+ }
14
+ }
15
+ return successors;
16
+ }
17
+ //# sourceMappingURL=workflow-graph-queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-graph-queries.js","sourceRoot":"","sources":["../../src/graph/workflow-graph-queries.ts"],"names":[],"mappings":";;;;AAGA,yBAAgC,KAAoB;IACnD,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;AAC5D,CAAC;AAOD,6BAAoC,KAAoB,EAAE,MAAc;IACvE,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAC3D,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC"}
@@ -9,8 +9,8 @@ export interface GraphNode {
9
9
  export interface GraphEdge {
10
10
  from: string;
11
11
  to: string;
12
- outputIndex?: number;
13
- inputIndex?: number;
12
+ outputIndex: number;
13
+ inputIndex: number;
14
14
  isBackEdge?: boolean;
15
15
  }
16
16
  export interface WorkflowGraph {
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export type { ExternalDependencies, IStepExecutor, StepExecutionContext, StepExe
6
6
  export { AllowAllAdmittance, AdmittanceRejectedError } from './admittance';
7
7
  export type { AdmittanceDecision, AdmittanceRequest, AdmittanceService, } from './admittance';
8
8
  export { InMemoryWorkQueue } from './queue';
9
- export type { ExecutionEnqueuedEvent, WorkQueue, WorkQueueMessage, } from './queue';
10
- export type { ExecutionMode, ExecutionStatus, ExecutionStore, NewExecutionRecord, NewStepRecord, StepStatus, StepStore, } from './execution';
9
+ export type { ExecutionEnqueuedEvent, OrchestrationMessage, StepMessage, StepReadyEvent, WorkQueue, } from './queue';
10
+ export { ExecutionNotFoundError, ExecutionStartHandler, OrchestrationWorker, StepNotFoundError, } from './execution';
11
+ export type { ExecutionMode, ExecutionRecord, ExecutionStatus, ExecutionStore, NewExecutionRecord, NewStepRecord, StepError, StepRecord, StepStatus, StepStore, } from './execution';
11
12
  export { createDataSource, TypeOrmExecutionStore, TypeOrmStepStore } from './database';