n8n 1.78.0 → 1.79.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 (177) hide show
  1. package/dist/active-executions.d.ts +1 -1
  2. package/dist/active-executions.js +36 -17
  3. package/dist/active-executions.js.map +1 -1
  4. package/dist/active-workflow-manager.d.ts +10 -9
  5. package/dist/active-workflow-manager.js +42 -30
  6. package/dist/active-workflow-manager.js.map +1 -1
  7. package/dist/build.tsbuildinfo +1 -1
  8. package/dist/commands/base-command.d.ts +1 -0
  9. package/dist/commands/base-command.js +4 -0
  10. package/dist/commands/base-command.js.map +1 -1
  11. package/dist/commands/execute-batch.d.ts +2 -2
  12. package/dist/commands/execute-batch.js.map +1 -1
  13. package/dist/commands/import/workflow.js +6 -6
  14. package/dist/commands/import/workflow.js.map +1 -1
  15. package/dist/commands/start.js +4 -0
  16. package/dist/commands/start.js.map +1 -1
  17. package/dist/concurrency/concurrency-control.service.d.ts +1 -4
  18. package/dist/concurrency/concurrency-control.service.js +6 -7
  19. package/dist/concurrency/concurrency-control.service.js.map +1 -1
  20. package/dist/controllers/oauth/abstract-oauth.controller.d.ts +4 -2
  21. package/dist/controllers/oauth/abstract-oauth.controller.js +12 -6
  22. package/dist/controllers/oauth/abstract-oauth.controller.js.map +1 -1
  23. package/dist/controllers/oauth/oauth1-credential.controller.js +5 -8
  24. package/dist/controllers/oauth/oauth1-credential.controller.js.map +1 -1
  25. package/dist/controllers/oauth/oauth2-credential.controller.js +10 -12
  26. package/dist/controllers/oauth/oauth2-credential.controller.js.map +1 -1
  27. package/dist/credentials/credentials.service.d.ts +3 -2
  28. package/dist/credentials/credentials.service.js +20 -5
  29. package/dist/credentials/credentials.service.js.map +1 -1
  30. package/dist/databases/entities/folder.d.ts +11 -0
  31. package/dist/databases/entities/folder.js +56 -0
  32. package/dist/databases/entities/folder.js.map +1 -0
  33. package/dist/databases/entities/index.d.ts +2 -0
  34. package/dist/databases/entities/index.js +2 -0
  35. package/dist/databases/entities/index.js.map +1 -1
  36. package/dist/databases/entities/test-case-execution.ee.d.ts +6 -3
  37. package/dist/databases/entities/test-case-execution.ee.js.map +1 -1
  38. package/dist/databases/entities/test-run.ee.d.ts +9 -2
  39. package/dist/databases/entities/test-run.ee.js +12 -0
  40. package/dist/databases/entities/test-run.ee.js.map +1 -1
  41. package/dist/databases/entities/workflow-entity.d.ts +2 -1
  42. package/dist/databases/entities/workflow-entity.js +8 -3
  43. package/dist/databases/entities/workflow-entity.js.map +1 -1
  44. package/dist/databases/migrations/common/1737715421462-AddErrorColumnsToTestRuns.d.ts +5 -0
  45. package/dist/databases/migrations/common/1737715421462-AddErrorColumnsToTestRuns.js +21 -0
  46. package/dist/databases/migrations/common/1737715421462-AddErrorColumnsToTestRuns.js.map +1 -0
  47. package/dist/databases/migrations/common/1738709609940-CreateFolderTable.d.ts +5 -0
  48. package/dist/databases/migrations/common/1738709609940-CreateFolderTable.js +46 -0
  49. package/dist/databases/migrations/common/1738709609940-CreateFolderTable.js.map +1 -0
  50. package/dist/databases/migrations/mysqldb/index.js +4 -0
  51. package/dist/databases/migrations/mysqldb/index.js.map +1 -1
  52. package/dist/databases/migrations/postgresdb/index.js +4 -0
  53. package/dist/databases/migrations/postgresdb/index.js.map +1 -1
  54. package/dist/databases/migrations/sqlite/1738709609940-CreateFolderTable.d.ts +4 -0
  55. package/dist/databases/migrations/sqlite/1738709609940-CreateFolderTable.js +12 -0
  56. package/dist/databases/migrations/sqlite/1738709609940-CreateFolderTable.js.map +1 -0
  57. package/dist/databases/migrations/sqlite/index.js +4 -0
  58. package/dist/databases/migrations/sqlite/index.js.map +1 -1
  59. package/dist/databases/repositories/folder.repository.d.ts +5 -0
  60. package/dist/databases/repositories/folder.repository.js +26 -0
  61. package/dist/databases/repositories/folder.repository.js.map +1 -0
  62. package/dist/databases/repositories/shared-workflow.repository.d.ts +1 -0
  63. package/dist/databases/repositories/tag.repository.d.ts +2 -2
  64. package/dist/databases/repositories/tag.repository.js.map +1 -1
  65. package/dist/databases/repositories/test-case-execution.repository.ee.d.ts +27 -4
  66. package/dist/databases/repositories/test-case-execution.repository.ee.js +18 -6
  67. package/dist/databases/repositories/test-case-execution.repository.ee.js.map +1 -1
  68. package/dist/databases/repositories/test-run.repository.ee.d.ts +26 -1
  69. package/dist/databases/repositories/test-run.repository.ee.js +30 -1
  70. package/dist/databases/repositories/test-run.repository.ee.js.map +1 -1
  71. package/dist/environments.ee/source-control/source-control-export.service.ee.js +3 -2
  72. package/dist/environments.ee/source-control/source-control-export.service.ee.js.map +1 -1
  73. package/dist/environments.ee/source-control/types/exportable-workflow.d.ts +1 -1
  74. package/dist/errors/workflow-missing-id.error.d.ts +2 -3
  75. package/dist/errors/workflow-missing-id.error.js.map +1 -1
  76. package/dist/evaluation.ee/test-definition.service.ee.js +1 -5
  77. package/dist/evaluation.ee/test-definition.service.ee.js.map +1 -1
  78. package/dist/evaluation.ee/test-runner/errors.ee.d.ts +11 -0
  79. package/dist/evaluation.ee/test-runner/errors.ee.js +19 -0
  80. package/dist/evaluation.ee/test-runner/errors.ee.js.map +1 -0
  81. package/dist/evaluation.ee/test-runner/evaluation-metrics.ee.d.ts +7 -1
  82. package/dist/evaluation.ee/test-runner/evaluation-metrics.ee.js +32 -5
  83. package/dist/evaluation.ee/test-runner/evaluation-metrics.ee.js.map +1 -1
  84. package/dist/evaluation.ee/test-runner/test-runner.service.ee.d.ts +1 -0
  85. package/dist/evaluation.ee/test-runner/test-runner.service.ee.js +86 -19
  86. package/dist/evaluation.ee/test-runner/test-runner.service.ee.js.map +1 -1
  87. package/dist/evaluation.ee/test-runner/utils.ee.d.ts +4 -2
  88. package/dist/evaluation.ee/test-runner/utils.ee.js +22 -0
  89. package/dist/evaluation.ee/test-runner/utils.ee.js.map +1 -1
  90. package/dist/evaluation.ee/test-runs.controller.ee.d.ts +18 -2
  91. package/dist/evaluation.ee/test-runs.controller.ee.js +2 -1
  92. package/dist/evaluation.ee/test-runs.controller.ee.js.map +1 -1
  93. package/dist/events/maps/pub-sub.event-map.d.ts +2 -2
  94. package/dist/execution-lifecycle/execution-lifecycle-hooks.d.ts +5 -5
  95. package/dist/execution-lifecycle/execution-lifecycle-hooks.js +258 -313
  96. package/dist/execution-lifecycle/execution-lifecycle-hooks.js.map +1 -1
  97. package/dist/executions/execution-recovery.service.js +2 -2
  98. package/dist/executions/execution-recovery.service.js.map +1 -1
  99. package/dist/executions/execution.service.d.ts +3 -3
  100. package/dist/executions/execution.service.js.map +1 -1
  101. package/dist/interfaces.d.ts +1 -0
  102. package/dist/interfaces.js.map +1 -1
  103. package/dist/manual-execution.service.js +3 -0
  104. package/dist/manual-execution.service.js.map +1 -1
  105. package/dist/node-types.d.ts +4 -2
  106. package/dist/node-types.js +14 -4
  107. package/dist/node-types.js.map +1 -1
  108. package/dist/public-api/v1/handlers/workflows/workflows.handler.js +2 -2
  109. package/dist/public-api/v1/handlers/workflows/workflows.handler.js.map +1 -1
  110. package/dist/public-api/v1/handlers/workflows/workflows.service.d.ts +3 -2
  111. package/dist/public-api/v1/handlers/workflows/workflows.service.js +4 -4
  112. package/dist/public-api/v1/handlers/workflows/workflows.service.js.map +1 -1
  113. package/dist/push/websocket.push.d.ts +1 -0
  114. package/dist/push/websocket.push.js +11 -2
  115. package/dist/push/websocket.push.js.map +1 -1
  116. package/dist/scaling/job-processor.js +12 -13
  117. package/dist/scaling/job-processor.js.map +1 -1
  118. package/dist/security-audit/risk-reporters/credentials-risk-reporter.d.ts +2 -2
  119. package/dist/security-audit/risk-reporters/credentials-risk-reporter.js.map +1 -1
  120. package/dist/security-audit/risk-reporters/database-risk-reporter.d.ts +2 -2
  121. package/dist/security-audit/risk-reporters/database-risk-reporter.js.map +1 -1
  122. package/dist/security-audit/risk-reporters/filesystem-risk-reporter.d.ts +2 -2
  123. package/dist/security-audit/risk-reporters/filesystem-risk-reporter.js.map +1 -1
  124. package/dist/security-audit/risk-reporters/instance-risk-reporter.d.ts +2 -2
  125. package/dist/security-audit/risk-reporters/instance-risk-reporter.js.map +1 -1
  126. package/dist/security-audit/risk-reporters/nodes-risk-reporter.d.ts +2 -2
  127. package/dist/security-audit/risk-reporters/nodes-risk-reporter.js.map +1 -1
  128. package/dist/security-audit/types.d.ts +5 -5
  129. package/dist/security-audit/utils.d.ts +4 -4
  130. package/dist/security-audit/utils.js.map +1 -1
  131. package/dist/server.d.ts +0 -1
  132. package/dist/server.js +1 -1
  133. package/dist/server.js.map +1 -1
  134. package/dist/services/import.service.d.ts +4 -3
  135. package/dist/services/import.service.js.map +1 -1
  136. package/dist/services/redis-client.service.js +3 -1
  137. package/dist/services/redis-client.service.js.map +1 -1
  138. package/dist/user-management/email/user-management-mailer.d.ts +2 -2
  139. package/dist/user-management/email/user-management-mailer.js.map +1 -1
  140. package/dist/webhooks/test-webhook-registrations.service.d.ts +2 -3
  141. package/dist/webhooks/test-webhook-registrations.service.js.map +1 -1
  142. package/dist/webhooks/test-webhooks.d.ts +3 -4
  143. package/dist/webhooks/test-webhooks.js.map +1 -1
  144. package/dist/webhooks/waiting-webhooks.js +2 -0
  145. package/dist/webhooks/waiting-webhooks.js.map +1 -1
  146. package/dist/webhooks/webhook-helpers.d.ts +2 -3
  147. package/dist/webhooks/webhook-helpers.js +1 -0
  148. package/dist/webhooks/webhook-helpers.js.map +1 -1
  149. package/dist/workflow-execute-additional-data.js +5 -1
  150. package/dist/workflow-execute-additional-data.js.map +1 -1
  151. package/dist/workflow-helpers.d.ts +3 -4
  152. package/dist/workflow-helpers.js.map +1 -1
  153. package/dist/workflow-runner.d.ts +3 -2
  154. package/dist/workflow-runner.js +19 -25
  155. package/dist/workflow-runner.js.map +1 -1
  156. package/dist/workflows/workflow-execution.service.d.ts +4 -4
  157. package/dist/workflows/workflow-execution.service.js +4 -1
  158. package/dist/workflows/workflow-execution.service.js.map +1 -1
  159. package/dist/workflows/workflow-history.ee/workflow-history.service.ee.d.ts +2 -2
  160. package/dist/workflows/workflow-history.ee/workflow-history.service.ee.js.map +1 -1
  161. package/dist/workflows/workflow.formatter.d.ts +2 -0
  162. package/dist/workflows/workflow.formatter.js +7 -0
  163. package/dist/workflows/workflow.formatter.js.map +1 -0
  164. package/dist/workflows/workflow.request.d.ts +2 -3
  165. package/dist/workflows/workflow.service.ee.d.ts +7 -7
  166. package/dist/workflows/workflow.service.ee.js +2 -2
  167. package/dist/workflows/workflow.service.ee.js.map +1 -1
  168. package/dist/workflows/workflows.controller.d.ts +4 -2
  169. package/dist/workflows/workflows.controller.js +1 -1
  170. package/dist/workflows/workflows.controller.js.map +1 -1
  171. package/package.json +11 -12
  172. package/dist/controllers/curl.controller.d.ts +0 -9
  173. package/dist/controllers/curl.controller.js +0 -41
  174. package/dist/controllers/curl.controller.js.map +0 -1
  175. package/dist/services/curl.service.d.ts +0 -51
  176. package/dist/services/curl.service.js +0 -334
  177. package/dist/services/curl.service.js.map +0 -1
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWorkflowHooksIntegrated = getWorkflowHooksIntegrated;
4
- exports.getWorkflowHooksWorkerExecuter = getWorkflowHooksWorkerExecuter;
5
- exports.getWorkflowHooksWorkerMain = getWorkflowHooksWorkerMain;
6
- exports.getWorkflowHooksMain = getWorkflowHooksMain;
3
+ exports.getLifecycleHooksForSubExecutions = getLifecycleHooksForSubExecutions;
4
+ exports.getLifecycleHooksForScalingWorker = getLifecycleHooksForScalingWorker;
5
+ exports.getLifecycleHooksForScalingMain = getLifecycleHooksForScalingMain;
6
+ exports.getLifecycleHooksForRegularMain = getLifecycleHooksForRegularMain;
7
7
  const di_1 = require("@n8n/di");
8
8
  const flatted_1 = require("flatted");
9
9
  const n8n_core_1 = require("n8n-core");
10
- const n8n_workflow_1 = require("n8n-workflow");
11
10
  const execution_repository_1 = require("../databases/repositories/execution.repository");
12
11
  const event_service_1 = require("../events/event.service");
13
12
  const external_hooks_1 = require("../external-hooks");
@@ -20,359 +19,305 @@ const restore_binary_data_id_1 = require("./restore-binary-data-id");
20
19
  const save_execution_progress_1 = require("./save-execution-progress");
21
20
  const shared_hook_functions_1 = require("./shared/shared-hook-functions");
22
21
  const to_save_settings_1 = require("./to-save-settings");
23
- function mergeHookFunctions(...hookFunctions) {
24
- const result = {
25
- nodeExecuteBefore: [],
26
- nodeExecuteAfter: [],
27
- workflowExecuteBefore: [],
28
- workflowExecuteAfter: [],
29
- sendResponse: [],
30
- nodeFetchedData: [],
31
- };
32
- for (const hooks of hookFunctions) {
33
- for (const key in hooks) {
34
- if (!result[key] || !hooks[key])
35
- continue;
36
- result[key].push(...hooks[key]);
37
- }
38
- }
39
- return result;
40
- }
41
- function hookFunctionsWorkflowEvents(userId) {
22
+ function hookFunctionsWorkflowEvents(hooks, userId) {
42
23
  const eventService = di_1.Container.get(event_service_1.EventService);
43
- return {
44
- workflowExecuteBefore: [
45
- async function () {
46
- const { executionId, workflowData } = this;
47
- eventService.emit('workflow-pre-execute', { executionId, data: workflowData });
48
- },
49
- ],
50
- workflowExecuteAfter: [
51
- async function (runData) {
52
- if (runData.status === 'waiting')
53
- return;
54
- const { executionId, workflowData: workflow } = this;
55
- eventService.emit('workflow-post-execute', { executionId, runData, workflow, userId });
56
- },
57
- ],
58
- };
24
+ hooks.addHandler('workflowExecuteBefore', function () {
25
+ const { executionId, workflowData } = this;
26
+ eventService.emit('workflow-pre-execute', { executionId, data: workflowData });
27
+ });
28
+ hooks.addHandler('workflowExecuteAfter', function (runData) {
29
+ if (runData.status === 'waiting')
30
+ return;
31
+ const { executionId, workflowData: workflow } = this;
32
+ eventService.emit('workflow-post-execute', { executionId, runData, workflow, userId });
33
+ });
59
34
  }
60
- function hookFunctionsNodeEvents() {
35
+ function hookFunctionsNodeEvents(hooks) {
61
36
  const eventService = di_1.Container.get(event_service_1.EventService);
62
- return {
63
- nodeExecuteBefore: [
64
- async function (nodeName) {
65
- const { executionId, workflowData: workflow } = this;
66
- eventService.emit('node-pre-execute', { executionId, workflow, nodeName });
67
- },
68
- ],
69
- nodeExecuteAfter: [
70
- async function (nodeName) {
71
- const { executionId, workflowData: workflow } = this;
72
- eventService.emit('node-post-execute', { executionId, workflow, nodeName });
73
- },
74
- ],
75
- };
37
+ hooks.addHandler('nodeExecuteBefore', function (nodeName) {
38
+ const { executionId, workflowData: workflow } = this;
39
+ eventService.emit('node-pre-execute', { executionId, workflow, nodeName });
40
+ });
41
+ hooks.addHandler('nodeExecuteAfter', function (nodeName) {
42
+ const { executionId, workflowData: workflow } = this;
43
+ eventService.emit('node-post-execute', { executionId, workflow, nodeName });
44
+ });
76
45
  }
77
- function hookFunctionsPush({ pushRef, retryOf }) {
46
+ function hookFunctionsPush(hooks, { pushRef, retryOf }) {
78
47
  if (!pushRef)
79
- return {};
48
+ return;
80
49
  const logger = di_1.Container.get(n8n_core_1.Logger);
81
50
  const pushInstance = di_1.Container.get(push_1.Push);
82
- return {
83
- nodeExecuteBefore: [
84
- async function (nodeName) {
85
- const { executionId } = this;
86
- logger.debug(`Executing hook on node "${nodeName}" (hookFunctionsPush)`, {
87
- executionId,
88
- pushRef,
89
- workflowId: this.workflowData.id,
90
- });
91
- pushInstance.send({ type: 'nodeExecuteBefore', data: { executionId, nodeName } }, pushRef);
92
- },
93
- ],
94
- nodeExecuteAfter: [
95
- async function (nodeName, data) {
96
- const { executionId } = this;
97
- logger.debug(`Executing hook on node "${nodeName}" (hookFunctionsPush)`, {
98
- executionId,
99
- pushRef,
100
- workflowId: this.workflowData.id,
101
- });
102
- pushInstance.send({ type: 'nodeExecuteAfter', data: { executionId, nodeName, data } }, pushRef);
103
- },
104
- ],
105
- workflowExecuteBefore: [
106
- async function (_workflow, data) {
107
- const { executionId } = this;
108
- const { id: workflowId, name: workflowName } = this.workflowData;
109
- logger.debug('Executing hook (hookFunctionsPush)', {
110
- executionId,
111
- pushRef,
112
- workflowId,
113
- });
114
- pushInstance.send({
115
- type: 'executionStarted',
116
- data: {
117
- executionId,
118
- mode: this.mode,
119
- startedAt: new Date(),
120
- retryOf,
121
- workflowId,
122
- workflowName,
123
- flattedRunData: data?.resultData.runData
124
- ? (0, flatted_1.stringify)(data.resultData.runData)
125
- : (0, flatted_1.stringify)({}),
126
- },
127
- }, pushRef);
128
- },
129
- ],
130
- workflowExecuteAfter: [
131
- async function (fullRunData) {
132
- const { executionId } = this;
133
- const { id: workflowId } = this.workflowData;
134
- logger.debug('Executing hook (hookFunctionsPush)', {
135
- executionId,
136
- pushRef,
137
- workflowId,
138
- });
139
- const { status } = fullRunData;
140
- if (status === 'waiting') {
141
- pushInstance.send({ type: 'executionWaiting', data: { executionId } }, pushRef);
142
- }
143
- else {
144
- const rawData = (0, flatted_1.stringify)(fullRunData.data);
145
- pushInstance.send({ type: 'executionFinished', data: { executionId, workflowId, status, rawData } }, pushRef);
146
- }
51
+ hooks.addHandler('nodeExecuteBefore', function (nodeName) {
52
+ const { executionId } = this;
53
+ logger.debug(`Executing hook on node "${nodeName}" (hookFunctionsPush)`, {
54
+ executionId,
55
+ pushRef,
56
+ workflowId: this.workflowData.id,
57
+ });
58
+ pushInstance.send({ type: 'nodeExecuteBefore', data: { executionId, nodeName } }, pushRef);
59
+ });
60
+ hooks.addHandler('nodeExecuteAfter', function (nodeName, data) {
61
+ const { executionId } = this;
62
+ logger.debug(`Executing hook on node "${nodeName}" (hookFunctionsPush)`, {
63
+ executionId,
64
+ pushRef,
65
+ workflowId: this.workflowData.id,
66
+ });
67
+ pushInstance.send({ type: 'nodeExecuteAfter', data: { executionId, nodeName, data } }, pushRef);
68
+ });
69
+ hooks.addHandler('workflowExecuteBefore', function (_workflow, data) {
70
+ const { executionId } = this;
71
+ const { id: workflowId, name: workflowName } = this.workflowData;
72
+ logger.debug('Executing hook (hookFunctionsPush)', {
73
+ executionId,
74
+ pushRef,
75
+ workflowId,
76
+ });
77
+ pushInstance.send({
78
+ type: 'executionStarted',
79
+ data: {
80
+ executionId,
81
+ mode: this.mode,
82
+ startedAt: new Date(),
83
+ retryOf,
84
+ workflowId,
85
+ workflowName,
86
+ flattedRunData: data?.resultData.runData
87
+ ? (0, flatted_1.stringify)(data.resultData.runData)
88
+ : (0, flatted_1.stringify)({}),
147
89
  },
148
- ],
149
- };
90
+ }, pushRef);
91
+ });
92
+ hooks.addHandler('workflowExecuteAfter', function (fullRunData) {
93
+ const { executionId } = this;
94
+ const { id: workflowId } = this.workflowData;
95
+ logger.debug('Executing hook (hookFunctionsPush)', {
96
+ executionId,
97
+ pushRef,
98
+ workflowId,
99
+ });
100
+ const { status } = fullRunData;
101
+ if (status === 'waiting') {
102
+ pushInstance.send({ type: 'executionWaiting', data: { executionId } }, pushRef);
103
+ }
104
+ else {
105
+ const rawData = (0, flatted_1.stringify)(fullRunData.data);
106
+ pushInstance.send({ type: 'executionFinished', data: { executionId, workflowId, status, rawData } }, pushRef);
107
+ }
108
+ });
150
109
  }
151
- function hookFunctionsExternalHooks() {
110
+ function hookFunctionsExternalHooks(hooks) {
152
111
  const externalHooks = di_1.Container.get(external_hooks_1.ExternalHooks);
153
- return {
154
- workflowExecuteBefore: [
155
- async function (workflow) {
156
- await externalHooks.run('workflow.preExecute', [workflow, this.mode]);
157
- },
158
- ],
159
- workflowExecuteAfter: [
160
- async function (fullRunData) {
161
- await externalHooks.run('workflow.postExecute', [
162
- fullRunData,
163
- this.workflowData,
164
- this.executionId,
165
- ]);
166
- },
167
- ],
168
- };
112
+ hooks.addHandler('workflowExecuteBefore', async function (workflow) {
113
+ await externalHooks.run('workflow.preExecute', [workflow, this.mode]);
114
+ });
115
+ hooks.addHandler('workflowExecuteAfter', async function (fullRunData) {
116
+ await externalHooks.run('workflow.postExecute', [
117
+ fullRunData,
118
+ this.workflowData,
119
+ this.executionId,
120
+ ]);
121
+ });
169
122
  }
170
- function hookFunctionsSaveProgress({ saveSettings }) {
123
+ function hookFunctionsSaveProgress(hooks, { saveSettings }) {
171
124
  if (!saveSettings.progress)
172
- return {};
173
- return {
174
- nodeExecuteAfter: [
175
- async function (nodeName, data, executionData) {
176
- await (0, save_execution_progress_1.saveExecutionProgress)(this.workflowData.id, this.executionId, nodeName, data, executionData);
177
- },
178
- ],
179
- };
125
+ return;
126
+ hooks.addHandler('nodeExecuteAfter', async function (nodeName, data, executionData) {
127
+ await (0, save_execution_progress_1.saveExecutionProgress)(this.workflowData.id, this.executionId, nodeName, data, executionData);
128
+ });
180
129
  }
181
- function hookFunctionsFinalizeExecutionStatus() {
182
- return {
183
- workflowExecuteAfter: [
184
- async function (fullRunData) {
185
- fullRunData.status = (0, shared_hook_functions_1.determineFinalExecutionStatus)(fullRunData);
186
- },
187
- ],
188
- };
130
+ function hookFunctionsFinalizeExecutionStatus(hooks) {
131
+ hooks.addHandler('workflowExecuteAfter', (fullRunData) => {
132
+ fullRunData.status = (0, shared_hook_functions_1.determineFinalExecutionStatus)(fullRunData);
133
+ });
189
134
  }
190
- function hookFunctionsStatistics() {
135
+ function hookFunctionsStatistics(hooks) {
191
136
  const workflowStatisticsService = di_1.Container.get(workflow_statistics_service_1.WorkflowStatisticsService);
192
- return {
193
- nodeFetchedData: [
194
- async (workflowId, node) => {
195
- workflowStatisticsService.emit('nodeFetchedData', { workflowId, node });
196
- },
197
- ],
198
- };
137
+ hooks.addHandler('nodeFetchedData', (workflowId, node) => {
138
+ workflowStatisticsService.emit('nodeFetchedData', { workflowId, node });
139
+ });
199
140
  }
200
- function hookFunctionsSave({ pushRef, retryOf, saveSettings, }) {
141
+ function hookFunctionsSave(hooks, { pushRef, retryOf, saveSettings }) {
201
142
  const logger = di_1.Container.get(n8n_core_1.Logger);
202
143
  const errorReporter = di_1.Container.get(n8n_core_1.ErrorReporter);
203
144
  const executionRepository = di_1.Container.get(execution_repository_1.ExecutionRepository);
204
145
  const workflowStaticDataService = di_1.Container.get(workflow_static_data_service_1.WorkflowStaticDataService);
205
146
  const workflowStatisticsService = di_1.Container.get(workflow_statistics_service_1.WorkflowStatisticsService);
206
- return {
207
- workflowExecuteAfter: [
208
- async function (fullRunData, newStaticData) {
209
- logger.debug('Executing hook (hookFunctionsSave)', {
210
- executionId: this.executionId,
211
- workflowId: this.workflowData.id,
212
- });
213
- await (0, restore_binary_data_id_1.restoreBinaryDataId)(fullRunData, this.executionId, this.mode);
214
- const isManualMode = this.mode === 'manual';
147
+ hooks.addHandler('workflowExecuteAfter', async function (fullRunData, newStaticData) {
148
+ logger.debug('Executing hook (hookFunctionsSave)', {
149
+ executionId: this.executionId,
150
+ workflowId: this.workflowData.id,
151
+ });
152
+ await (0, restore_binary_data_id_1.restoreBinaryDataId)(fullRunData, this.executionId, this.mode);
153
+ const isManualMode = this.mode === 'manual';
154
+ try {
155
+ if (!isManualMode && (0, utils_1.isWorkflowIdValid)(this.workflowData.id) && newStaticData) {
215
156
  try {
216
- if (!isManualMode && (0, utils_1.isWorkflowIdValid)(this.workflowData.id) && newStaticData) {
217
- try {
218
- await workflowStaticDataService.saveStaticDataById(this.workflowData.id, newStaticData);
219
- }
220
- catch (e) {
221
- errorReporter.error(e);
222
- logger.error(`There was a problem saving the workflow with id "${this.workflowData.id}" to save changed staticData: "${e.message}" (hookFunctionsSave)`, { executionId: this.executionId, workflowId: this.workflowData.id });
223
- }
224
- }
225
- if (isManualMode && !saveSettings.manual && !fullRunData.waitTill) {
226
- await executionRepository.softDelete(this.executionId);
227
- return;
228
- }
229
- const shouldNotSave = (fullRunData.status === 'success' && !saveSettings.success) ||
230
- (fullRunData.status !== 'success' && !saveSettings.error);
231
- if (shouldNotSave && !fullRunData.waitTill && !isManualMode) {
232
- (0, execute_error_workflow_1.executeErrorWorkflow)(this.workflowData, fullRunData, this.mode, this.executionId, retryOf);
233
- await executionRepository.hardDelete({
234
- workflowId: this.workflowData.id,
235
- executionId: this.executionId,
236
- });
237
- return;
238
- }
239
- const fullExecutionData = (0, shared_hook_functions_1.prepareExecutionDataForDbUpdate)({
240
- runData: fullRunData,
241
- workflowData: this.workflowData,
242
- workflowStatusFinal: fullRunData.status,
243
- retryOf,
244
- });
245
- if (fullRunData.waitTill && isManualMode) {
246
- fullExecutionData.data.pushRef = pushRef;
247
- }
248
- await (0, shared_hook_functions_1.updateExistingExecution)({
249
- executionId: this.executionId,
250
- workflowId: this.workflowData.id,
251
- executionData: fullExecutionData,
252
- });
253
- if (!isManualMode) {
254
- (0, execute_error_workflow_1.executeErrorWorkflow)(this.workflowData, fullRunData, this.mode, this.executionId, retryOf);
255
- }
157
+ await workflowStaticDataService.saveStaticDataById(this.workflowData.id, newStaticData);
256
158
  }
257
- finally {
258
- workflowStatisticsService.emit('workflowExecutionCompleted', {
259
- workflowData: this.workflowData,
260
- fullRunData,
261
- });
159
+ catch (e) {
160
+ errorReporter.error(e);
161
+ logger.error(`There was a problem saving the workflow with id "${this.workflowData.id}" to save changed staticData: "${e.message}" (hookFunctionsSave)`, { executionId: this.executionId, workflowId: this.workflowData.id });
262
162
  }
263
- },
264
- ],
265
- };
163
+ }
164
+ if (isManualMode && !saveSettings.manual && !fullRunData.waitTill) {
165
+ await executionRepository.softDelete(this.executionId);
166
+ return;
167
+ }
168
+ const shouldNotSave = (fullRunData.status === 'success' && !saveSettings.success) ||
169
+ (fullRunData.status !== 'success' && !saveSettings.error);
170
+ if (shouldNotSave && !fullRunData.waitTill && !isManualMode) {
171
+ (0, execute_error_workflow_1.executeErrorWorkflow)(this.workflowData, fullRunData, this.mode, this.executionId, retryOf);
172
+ await executionRepository.hardDelete({
173
+ workflowId: this.workflowData.id,
174
+ executionId: this.executionId,
175
+ });
176
+ return;
177
+ }
178
+ const fullExecutionData = (0, shared_hook_functions_1.prepareExecutionDataForDbUpdate)({
179
+ runData: fullRunData,
180
+ workflowData: this.workflowData,
181
+ workflowStatusFinal: fullRunData.status,
182
+ retryOf,
183
+ });
184
+ if (fullRunData.waitTill && isManualMode) {
185
+ fullExecutionData.data.pushRef = pushRef;
186
+ }
187
+ await (0, shared_hook_functions_1.updateExistingExecution)({
188
+ executionId: this.executionId,
189
+ workflowId: this.workflowData.id,
190
+ executionData: fullExecutionData,
191
+ });
192
+ if (!isManualMode) {
193
+ (0, execute_error_workflow_1.executeErrorWorkflow)(this.workflowData, fullRunData, this.mode, this.executionId, retryOf);
194
+ }
195
+ }
196
+ finally {
197
+ workflowStatisticsService.emit('workflowExecutionCompleted', {
198
+ workflowData: this.workflowData,
199
+ fullRunData,
200
+ });
201
+ }
202
+ });
266
203
  }
267
- function hookFunctionsSaveWorker({ pushRef, retryOf, }) {
204
+ function hookFunctionsSaveWorker(hooks, { pushRef, retryOf }) {
268
205
  const logger = di_1.Container.get(n8n_core_1.Logger);
269
206
  const errorReporter = di_1.Container.get(n8n_core_1.ErrorReporter);
270
207
  const workflowStaticDataService = di_1.Container.get(workflow_static_data_service_1.WorkflowStaticDataService);
271
208
  const workflowStatisticsService = di_1.Container.get(workflow_statistics_service_1.WorkflowStatisticsService);
272
- return {
273
- workflowExecuteAfter: [
274
- async function (fullRunData, newStaticData) {
275
- logger.debug('Executing hook (hookFunctionsSaveWorker)', {
276
- executionId: this.executionId,
277
- workflowId: this.workflowData.id,
278
- });
279
- const isManualMode = this.mode === 'manual';
209
+ hooks.addHandler('workflowExecuteAfter', async function (fullRunData, newStaticData) {
210
+ logger.debug('Executing hook (hookFunctionsSaveWorker)', {
211
+ executionId: this.executionId,
212
+ workflowId: this.workflowData.id,
213
+ });
214
+ const isManualMode = this.mode === 'manual';
215
+ try {
216
+ if (!isManualMode && (0, utils_1.isWorkflowIdValid)(this.workflowData.id) && newStaticData) {
280
217
  try {
281
- if (!isManualMode && (0, utils_1.isWorkflowIdValid)(this.workflowData.id) && newStaticData) {
282
- try {
283
- await workflowStaticDataService.saveStaticDataById(this.workflowData.id, newStaticData);
284
- }
285
- catch (e) {
286
- errorReporter.error(e);
287
- logger.error(`There was a problem saving the workflow with id "${this.workflowData.id}" to save changed staticData: "${e.message}" (workflowExecuteAfter)`, { workflowId: this.workflowData.id });
288
- }
289
- }
290
- if (!isManualMode &&
291
- fullRunData.status !== 'success' &&
292
- fullRunData.status !== 'waiting') {
293
- (0, execute_error_workflow_1.executeErrorWorkflow)(this.workflowData, fullRunData, this.mode, this.executionId, retryOf);
294
- }
295
- const fullExecutionData = (0, shared_hook_functions_1.prepareExecutionDataForDbUpdate)({
296
- runData: fullRunData,
297
- workflowData: this.workflowData,
298
- workflowStatusFinal: fullRunData.status,
299
- retryOf,
300
- });
301
- if (fullRunData.waitTill && isManualMode) {
302
- fullExecutionData.data.pushRef = pushRef;
303
- }
304
- await (0, shared_hook_functions_1.updateExistingExecution)({
305
- executionId: this.executionId,
306
- workflowId: this.workflowData.id,
307
- executionData: fullExecutionData,
308
- });
218
+ await workflowStaticDataService.saveStaticDataById(this.workflowData.id, newStaticData);
309
219
  }
310
- finally {
311
- workflowStatisticsService.emit('workflowExecutionCompleted', {
312
- workflowData: this.workflowData,
313
- fullRunData,
314
- });
220
+ catch (e) {
221
+ errorReporter.error(e);
222
+ logger.error(`There was a problem saving the workflow with id "${this.workflowData.id}" to save changed staticData: "${e.message}" (workflowExecuteAfter)`, { workflowId: this.workflowData.id });
315
223
  }
316
- },
317
- ],
318
- };
224
+ }
225
+ if (!isManualMode && fullRunData.status !== 'success' && fullRunData.status !== 'waiting') {
226
+ (0, execute_error_workflow_1.executeErrorWorkflow)(this.workflowData, fullRunData, this.mode, this.executionId, retryOf);
227
+ }
228
+ const fullExecutionData = (0, shared_hook_functions_1.prepareExecutionDataForDbUpdate)({
229
+ runData: fullRunData,
230
+ workflowData: this.workflowData,
231
+ workflowStatusFinal: fullRunData.status,
232
+ retryOf,
233
+ });
234
+ if (fullRunData.waitTill && isManualMode) {
235
+ fullExecutionData.data.pushRef = pushRef;
236
+ }
237
+ await (0, shared_hook_functions_1.updateExistingExecution)({
238
+ executionId: this.executionId,
239
+ workflowId: this.workflowData.id,
240
+ executionData: fullExecutionData,
241
+ });
242
+ }
243
+ finally {
244
+ workflowStatisticsService.emit('workflowExecutionCompleted', {
245
+ workflowData: this.workflowData,
246
+ fullRunData,
247
+ });
248
+ }
249
+ });
319
250
  }
320
- function getWorkflowHooksIntegrated(mode, executionId, workflowData, userId) {
251
+ function getLifecycleHooksForSubExecutions(mode, executionId, workflowData, userId) {
252
+ const hooks = new n8n_core_1.ExecutionLifecycleHooks(mode, executionId, workflowData);
321
253
  const saveSettings = (0, to_save_settings_1.toSaveSettings)(workflowData.settings);
322
- const hookFunctions = mergeHookFunctions(hookFunctionsWorkflowEvents(userId), hookFunctionsNodeEvents(), hookFunctionsFinalizeExecutionStatus(), hookFunctionsSave({ saveSettings }), hookFunctionsSaveProgress({ saveSettings }), hookFunctionsStatistics(), hookFunctionsExternalHooks());
323
- return new n8n_workflow_1.WorkflowHooks(hookFunctions, mode, executionId, workflowData);
254
+ hookFunctionsWorkflowEvents(hooks, userId);
255
+ hookFunctionsNodeEvents(hooks);
256
+ hookFunctionsFinalizeExecutionStatus(hooks);
257
+ hookFunctionsSave(hooks, { saveSettings });
258
+ hookFunctionsSaveProgress(hooks, { saveSettings });
259
+ hookFunctionsStatistics(hooks);
260
+ hookFunctionsExternalHooks(hooks);
261
+ return hooks;
324
262
  }
325
- function getWorkflowHooksWorkerExecuter(mode, executionId, workflowData, { pushRef, retryOf } = {}) {
263
+ function getLifecycleHooksForScalingWorker(mode, executionId, workflowData, { pushRef, retryOf } = {}) {
264
+ const hooks = new n8n_core_1.ExecutionLifecycleHooks(mode, executionId, workflowData);
326
265
  const saveSettings = (0, to_save_settings_1.toSaveSettings)(workflowData.settings);
327
266
  const optionalParameters = { pushRef, retryOf, saveSettings };
328
- const toMerge = [
329
- hookFunctionsNodeEvents(),
330
- hookFunctionsFinalizeExecutionStatus(),
331
- hookFunctionsSaveWorker(optionalParameters),
332
- hookFunctionsSaveProgress(optionalParameters),
333
- hookFunctionsStatistics(),
334
- hookFunctionsExternalHooks(),
335
- ];
267
+ hookFunctionsNodeEvents(hooks);
268
+ hookFunctionsFinalizeExecutionStatus(hooks);
269
+ hookFunctionsSaveWorker(hooks, optionalParameters);
270
+ hookFunctionsSaveProgress(hooks, optionalParameters);
271
+ hookFunctionsStatistics(hooks);
272
+ hookFunctionsExternalHooks(hooks);
336
273
  if (mode === 'manual' && di_1.Container.get(n8n_core_1.InstanceSettings).isWorker) {
337
- toMerge.push(hookFunctionsPush(optionalParameters));
274
+ hookFunctionsPush(hooks, optionalParameters);
338
275
  }
339
- const hookFunctions = mergeHookFunctions(...toMerge);
340
- return new n8n_workflow_1.WorkflowHooks(hookFunctions, mode, executionId, workflowData);
276
+ return hooks;
341
277
  }
342
- function getWorkflowHooksWorkerMain(mode, executionId, workflowData, { pushRef, retryOf } = {}) {
278
+ function getLifecycleHooksForScalingMain(mode, executionId, workflowData, { pushRef, retryOf } = {}) {
279
+ const hooks = new n8n_core_1.ExecutionLifecycleHooks(mode, executionId, workflowData);
343
280
  const saveSettings = (0, to_save_settings_1.toSaveSettings)(workflowData.settings);
344
281
  const optionalParameters = { pushRef, retryOf, saveSettings };
345
282
  const executionRepository = di_1.Container.get(execution_repository_1.ExecutionRepository);
346
- const hookFunctions = mergeHookFunctions(hookFunctionsWorkflowEvents(), hookFunctionsSaveProgress(optionalParameters), hookFunctionsExternalHooks(), hookFunctionsFinalizeExecutionStatus(), {
347
- workflowExecuteAfter: [
348
- async function (fullRunData) {
349
- if (!fullRunData.finished)
350
- return;
351
- const isManualMode = this.mode === 'manual';
352
- if (isManualMode && !saveSettings.manual && !fullRunData.waitTill) {
353
- await executionRepository.softDelete(this.executionId);
354
- return;
355
- }
356
- const shouldNotSave = (fullRunData.status === 'success' && !saveSettings.success) ||
357
- (fullRunData.status !== 'success' && !saveSettings.error);
358
- if (!isManualMode && shouldNotSave && !fullRunData.waitTill) {
359
- await executionRepository.hardDelete({
360
- workflowId: this.workflowData.id,
361
- executionId: this.executionId,
362
- });
363
- }
364
- },
365
- ],
283
+ hookFunctionsWorkflowEvents(hooks);
284
+ hookFunctionsSaveProgress(hooks, optionalParameters);
285
+ hookFunctionsExternalHooks(hooks);
286
+ hookFunctionsFinalizeExecutionStatus(hooks);
287
+ hooks.addHandler('workflowExecuteAfter', async function (fullRunData) {
288
+ if (!fullRunData.finished)
289
+ return;
290
+ const isManualMode = this.mode === 'manual';
291
+ if (isManualMode && !saveSettings.manual && !fullRunData.waitTill) {
292
+ await executionRepository.softDelete(this.executionId);
293
+ return;
294
+ }
295
+ const shouldNotSave = (fullRunData.status === 'success' && !saveSettings.success) ||
296
+ (fullRunData.status !== 'success' && !saveSettings.error);
297
+ if (!isManualMode && shouldNotSave && !fullRunData.waitTill) {
298
+ await executionRepository.hardDelete({
299
+ workflowId: this.workflowData.id,
300
+ executionId: this.executionId,
301
+ });
302
+ }
366
303
  });
367
- hookFunctions.nodeExecuteBefore = [];
368
- hookFunctions.nodeExecuteAfter = [];
369
- return new n8n_workflow_1.WorkflowHooks(hookFunctions, mode, executionId, workflowData);
304
+ hooks.handlers.nodeExecuteBefore = [];
305
+ hooks.handlers.nodeExecuteAfter = [];
306
+ return hooks;
370
307
  }
371
- function getWorkflowHooksMain(data, executionId) {
372
- const { pushRef, retryOf } = data;
373
- const saveSettings = (0, to_save_settings_1.toSaveSettings)(data.workflowData.settings);
308
+ function getLifecycleHooksForRegularMain(data, executionId) {
309
+ const { pushRef, retryOf, executionMode, workflowData } = data;
310
+ const hooks = new n8n_core_1.ExecutionLifecycleHooks(executionMode, executionId, workflowData);
311
+ const saveSettings = (0, to_save_settings_1.toSaveSettings)(workflowData.settings);
374
312
  const optionalParameters = { pushRef, retryOf: retryOf ?? undefined, saveSettings };
375
- const hookFunctions = mergeHookFunctions(hookFunctionsWorkflowEvents(), hookFunctionsNodeEvents(), hookFunctionsFinalizeExecutionStatus(), hookFunctionsSave(optionalParameters), hookFunctionsPush(optionalParameters), hookFunctionsSaveProgress(optionalParameters), hookFunctionsStatistics(), hookFunctionsExternalHooks());
376
- return new n8n_workflow_1.WorkflowHooks(hookFunctions, data.executionMode, executionId, data.workflowData);
313
+ hookFunctionsWorkflowEvents(hooks);
314
+ hookFunctionsNodeEvents(hooks);
315
+ hookFunctionsFinalizeExecutionStatus(hooks);
316
+ hookFunctionsSave(hooks, optionalParameters);
317
+ hookFunctionsPush(hooks, optionalParameters);
318
+ hookFunctionsSaveProgress(hooks, optionalParameters);
319
+ hookFunctionsStatistics(hooks);
320
+ hookFunctionsExternalHooks(hooks);
321
+ return hooks;
377
322
  }
378
323
  //# sourceMappingURL=execution-lifecycle-hooks.js.map