@n8n/engine 0.15.4 → 0.16.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.
Files changed (53) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/database/create-stores.d.ts +7 -0
  3. package/dist/database/create-stores.js +13 -0
  4. package/dist/database/create-stores.js.map +1 -0
  5. package/dist/database/index.d.ts +1 -0
  6. package/dist/database/index.js +3 -1
  7. package/dist/database/index.js.map +1 -1
  8. package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js +1 -1
  9. package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js.map +1 -1
  10. package/dist/database/typeorm-step-store.d.ts +7 -7
  11. package/dist/database/typeorm-step-store.js +96 -56
  12. package/dist/database/typeorm-step-store.js.map +1 -1
  13. package/dist/execution/execution-start-handler.js +2 -3
  14. package/dist/execution/execution-start-handler.js.map +1 -1
  15. package/dist/execution/execution.types.d.ts +3 -1
  16. package/dist/execution/execution.types.js +11 -0
  17. package/dist/execution/execution.types.js.map +1 -1
  18. package/dist/execution/index.d.ts +1 -1
  19. package/dist/execution/index.js +3 -3
  20. package/dist/execution/index.js.map +1 -1
  21. package/dist/execution/orchestration-worker.d.ts +3 -3
  22. package/dist/execution/orchestration-worker.js +5 -5
  23. package/dist/execution/orchestration-worker.js.map +1 -1
  24. package/dist/execution/settlement.d.ts +7 -0
  25. package/dist/execution/settlement.js +31 -0
  26. package/dist/execution/settlement.js.map +1 -0
  27. package/dist/execution/step-ready-handler.d.ts +0 -1
  28. package/dist/execution/step-ready-handler.js +29 -28
  29. package/dist/execution/step-ready-handler.js.map +1 -1
  30. package/dist/execution/step-settled-handler.d.ts +17 -0
  31. package/dist/execution/step-settled-handler.js +97 -0
  32. package/dist/execution/step-settled-handler.js.map +1 -0
  33. package/dist/execution/step-store.d.ts +18 -9
  34. package/dist/execution/step-store.js.map +1 -1
  35. package/dist/graph/index.d.ts +1 -1
  36. package/dist/graph/index.js +2 -1
  37. package/dist/graph/index.js.map +1 -1
  38. package/dist/graph/validate-executable-graph.js +15 -4
  39. package/dist/graph/validate-executable-graph.js.map +1 -1
  40. package/dist/graph/workflow-graph-queries.d.ts +1 -0
  41. package/dist/graph/workflow-graph-queries.js +14 -0
  42. package/dist/graph/workflow-graph-queries.js.map +1 -1
  43. package/dist/index.d.ts +4 -4
  44. package/dist/index.js +6 -4
  45. package/dist/index.js.map +1 -1
  46. package/dist/queue/index.d.ts +1 -1
  47. package/dist/queue/work-queue.types.d.ts +3 -3
  48. package/dist/serve.js +2 -3
  49. package/dist/serve.js.map +1 -1
  50. package/package.json +8 -7
  51. package/dist/execution/step-completed-handler.d.ts +0 -13
  52. package/dist/execution/step-completed-handler.js +0 -74
  53. package/dist/execution/step-completed-handler.js.map +0 -1
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StepCompletedHandler = void 0;
4
- const graph_1 = require("../graph");
5
- const validate_step_context_1 = require("./validate-step-context");
6
- class StepCompletedHandler {
7
- executionStore;
8
- stepStore;
9
- stepQueue;
10
- constructor(executionStore, stepStore, stepQueue) {
11
- this.executionStore = executionStore;
12
- this.stepStore = stepStore;
13
- this.stepQueue = stepQueue;
14
- }
15
- async handle(event) {
16
- const [step, execution] = await Promise.all([
17
- this.stepStore.loadStep(event.stepId),
18
- this.executionStore.loadExecution(event.executionId),
19
- ]);
20
- (0, validate_step_context_1.validateStepContext)(step, execution);
21
- if (step.status === 'failed') {
22
- await this.executionStore.finishExecution(execution.id, 'failed');
23
- await this.stepStore.cancelQueuedSteps(execution.id);
24
- return;
25
- }
26
- if (execution.status !== 'running')
27
- return;
28
- const planned = step.status === 'completed' ? await this.planSuccessors(execution, step.nodeId) : 0;
29
- if (planned > 0)
30
- return;
31
- await this.finishExecutionIfDone(execution.id);
32
- }
33
- async finishExecutionIfDone(executionId) {
34
- if (await this.stepStore.hasActiveSteps(executionId))
35
- return;
36
- const failed = await this.stepStore.hasFailedSteps(executionId);
37
- await this.executionStore.finishExecution(executionId, failed ? 'failed' : 'completed');
38
- }
39
- async planSuccessors(execution, nodeId) {
40
- const readyNodeIds = await this.readySuccessorNodeIds(execution, nodeId);
41
- if (readyNodeIds.length === 0)
42
- return 0;
43
- const created = await this.stepStore.createSteps(readyNodeIds.map((readyNodeId) => ({
44
- executionId: execution.id,
45
- nodeId: readyNodeId,
46
- status: 'queued',
47
- })));
48
- for (const { id: stepId } of created) {
49
- await this.stepQueue.publish({
50
- type: 'step:ready',
51
- executionId: execution.id,
52
- stepId,
53
- });
54
- }
55
- return created.length;
56
- }
57
- async readySuccessorNodeIds(execution, nodeId) {
58
- const successors = (0, graph_1.getSuccessorNodeIds)(execution.graph, nodeId).map((id) => ({
59
- id,
60
- predecessorIds: (0, graph_1.getPredecessorNodeIds)(execution.graph, id),
61
- }));
62
- const predecessorsToCheck = successors
63
- .flatMap(({ predecessorIds }) => predecessorIds)
64
- .filter((id) => id !== nodeId);
65
- const completed = predecessorsToCheck.length === 0
66
- ? new Set()
67
- : await this.stepStore.loadCompletedNodeIds(execution.id, predecessorsToCheck);
68
- return successors
69
- .filter(({ predecessorIds }) => predecessorIds.every((id) => id === nodeId || completed.has(id)))
70
- .map(({ id }) => id);
71
- }
72
- }
73
- exports.StepCompletedHandler = StepCompletedHandler;
74
- //# sourceMappingURL=step-completed-handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"step-completed-handler.js","sourceRoot":"","sources":["../../src/execution/step-completed-handler.ts"],"names":[],"mappings":";;;AAAA,oCAAsE;AAItE,mEAA8D;AAc9D;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,KAAyB;QACrC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,MAAM,OAAO,CAAC,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