@atom8n/n8n-core 2.2.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 (352) hide show
  1. package/README.md +13 -0
  2. package/bin/common.js +19 -0
  3. package/bin/copy-static-files +24 -0
  4. package/bin/generate-metadata +75 -0
  5. package/bin/generate-translations +99 -0
  6. package/dist/binary-data/binary-data.config.d.ts +15 -0
  7. package/dist/binary-data/binary-data.config.js +62 -0
  8. package/dist/binary-data/binary-data.config.js.map +1 -0
  9. package/dist/binary-data/binary-data.service.d.ts +32 -0
  10. package/dist/binary-data/binary-data.service.js +243 -0
  11. package/dist/binary-data/binary-data.service.js.map +1 -0
  12. package/dist/binary-data/file-system.manager.d.ts +31 -0
  13. package/dist/binary-data/file-system.manager.js +154 -0
  14. package/dist/binary-data/file-system.manager.js.map +1 -0
  15. package/dist/binary-data/index.d.ts +5 -0
  16. package/dist/binary-data/index.js +27 -0
  17. package/dist/binary-data/index.js.map +1 -0
  18. package/dist/binary-data/object-store/object-store.config.d.ts +19 -0
  19. package/dist/binary-data/object-store/object-store.config.js +83 -0
  20. package/dist/binary-data/object-store/object-store.config.js.map +1 -0
  21. package/dist/binary-data/object-store/object-store.service.ee.d.ts +46 -0
  22. package/dist/binary-data/object-store/object-store.service.ee.js +235 -0
  23. package/dist/binary-data/object-store/object-store.service.ee.js.map +1 -0
  24. package/dist/binary-data/object-store/types.d.ts +8 -0
  25. package/dist/binary-data/object-store/types.js +3 -0
  26. package/dist/binary-data/object-store/types.js.map +1 -0
  27. package/dist/binary-data/object-store.manager.d.ts +23 -0
  28. package/dist/binary-data/object-store.manager.js +86 -0
  29. package/dist/binary-data/object-store.manager.js.map +1 -0
  30. package/dist/binary-data/types.d.ts +46 -0
  31. package/dist/binary-data/types.js +3 -0
  32. package/dist/binary-data/types.js.map +1 -0
  33. package/dist/binary-data/utils.d.ts +15 -0
  34. package/dist/binary-data/utils.js +66 -0
  35. package/dist/binary-data/utils.js.map +1 -0
  36. package/dist/build.tsbuildinfo +1 -0
  37. package/dist/constants.d.ts +19 -0
  38. package/dist/constants.js +23 -0
  39. package/dist/constants.js.map +1 -0
  40. package/dist/credentials.d.ts +12 -0
  41. package/dist/credentials.js +99 -0
  42. package/dist/credentials.js.map +1 -0
  43. package/dist/data-deduplication-service.d.ts +16 -0
  44. package/dist/data-deduplication-service.js +95 -0
  45. package/dist/data-deduplication-service.js.map +1 -0
  46. package/dist/encryption/cipher.d.ts +8 -0
  47. package/dist/encryption/cipher.js +57 -0
  48. package/dist/encryption/cipher.js.map +1 -0
  49. package/dist/encryption/index.d.ts +1 -0
  50. package/dist/encryption/index.js +6 -0
  51. package/dist/encryption/index.js.map +1 -0
  52. package/dist/errors/abstract/binary-data.error.d.ts +3 -0
  53. package/dist/errors/abstract/binary-data.error.js +8 -0
  54. package/dist/errors/abstract/binary-data.error.js.map +1 -0
  55. package/dist/errors/abstract/filesystem.error.d.ts +4 -0
  56. package/dist/errors/abstract/filesystem.error.js +11 -0
  57. package/dist/errors/abstract/filesystem.error.js.map +1 -0
  58. package/dist/errors/binary-data-file-not-found.error.d.ts +4 -0
  59. package/dist/errors/binary-data-file-not-found.error.js +11 -0
  60. package/dist/errors/binary-data-file-not-found.error.js.map +1 -0
  61. package/dist/errors/disallowed-filepath.error.d.ts +4 -0
  62. package/dist/errors/disallowed-filepath.error.js +11 -0
  63. package/dist/errors/disallowed-filepath.error.js.map +1 -0
  64. package/dist/errors/error-reporter.d.ts +35 -0
  65. package/dist/errors/error-reporter.js +256 -0
  66. package/dist/errors/error-reporter.js.map +1 -0
  67. package/dist/errors/file-not-found.error.d.ts +4 -0
  68. package/dist/errors/file-not-found.error.js +11 -0
  69. package/dist/errors/file-not-found.error.js.map +1 -0
  70. package/dist/errors/file-too-large.error.d.ts +9 -0
  71. package/dist/errors/file-too-large.error.js +13 -0
  72. package/dist/errors/file-too-large.error.js.map +1 -0
  73. package/dist/errors/index.d.ts +11 -0
  74. package/dist/errors/index.js +26 -0
  75. package/dist/errors/index.js.map +1 -0
  76. package/dist/errors/invalid-execution-metadata.error.d.ts +5 -0
  77. package/dist/errors/invalid-execution-metadata.error.js +12 -0
  78. package/dist/errors/invalid-execution-metadata.error.js.map +1 -0
  79. package/dist/errors/invalid-manager.error.d.ts +4 -0
  80. package/dist/errors/invalid-manager.error.js +11 -0
  81. package/dist/errors/invalid-manager.error.js.map +1 -0
  82. package/dist/errors/invalid-source-type.error.d.ts +4 -0
  83. package/dist/errors/invalid-source-type.error.js +11 -0
  84. package/dist/errors/invalid-source-type.error.js.map +1 -0
  85. package/dist/errors/missing-source-id.error.d.ts +4 -0
  86. package/dist/errors/missing-source-id.error.js +11 -0
  87. package/dist/errors/missing-source-id.error.js.map +1 -0
  88. package/dist/errors/unrecognized-credential-type.error.d.ts +4 -0
  89. package/dist/errors/unrecognized-credential-type.error.js +11 -0
  90. package/dist/errors/unrecognized-credential-type.error.js.map +1 -0
  91. package/dist/errors/unrecognized-node-type.error.d.ts +4 -0
  92. package/dist/errors/unrecognized-node-type.error.js +11 -0
  93. package/dist/errors/unrecognized-node-type.error.js.map +1 -0
  94. package/dist/errors/workflow-has-issues.error.d.ts +4 -0
  95. package/dist/errors/workflow-has-issues.error.js +11 -0
  96. package/dist/errors/workflow-has-issues.error.js.map +1 -0
  97. package/dist/execution-engine/active-workflows.d.ts +23 -0
  98. package/dist/execution-engine/active-workflows.js +153 -0
  99. package/dist/execution-engine/active-workflows.js.map +1 -0
  100. package/dist/execution-engine/execution-context-hook-registry.service.d.ts +12 -0
  101. package/dist/execution-engine/execution-context-hook-registry.service.js +69 -0
  102. package/dist/execution-engine/execution-context-hook-registry.service.js.map +1 -0
  103. package/dist/execution-engine/execution-context.d.ts +2 -0
  104. package/dist/execution-engine/execution-context.js +56 -0
  105. package/dist/execution-engine/execution-context.js.map +1 -0
  106. package/dist/execution-engine/execution-context.service.d.ts +17 -0
  107. package/dist/execution-engine/execution-context.service.js +108 -0
  108. package/dist/execution-engine/execution-context.service.js.map +1 -0
  109. package/dist/execution-engine/execution-lifecycle-hooks.d.ts +20 -0
  110. package/dist/execution-engine/execution-lifecycle-hooks.js +31 -0
  111. package/dist/execution-engine/execution-lifecycle-hooks.js.map +1 -0
  112. package/dist/execution-engine/external-secrets-proxy.d.ts +18 -0
  113. package/dist/execution-engine/external-secrets-proxy.js +38 -0
  114. package/dist/execution-engine/external-secrets-proxy.js.map +1 -0
  115. package/dist/execution-engine/index.d.ts +26 -0
  116. package/dist/execution-engine/index.js +31 -0
  117. package/dist/execution-engine/index.js.map +1 -0
  118. package/dist/execution-engine/interfaces.d.ts +7 -0
  119. package/dist/execution-engine/interfaces.js +3 -0
  120. package/dist/execution-engine/interfaces.js.map +1 -0
  121. package/dist/execution-engine/node-execution-context/base-execute-context.d.ts +47 -0
  122. package/dist/execution-engine/node-execution-context/base-execute-context.js +150 -0
  123. package/dist/execution-engine/node-execution-context/base-execute-context.js.map +1 -0
  124. package/dist/execution-engine/node-execution-context/credentials-test-context.d.ts +7 -0
  125. package/dist/execution-engine/node-execution-context/credentials-test-context.js +37 -0
  126. package/dist/execution-engine/node-execution-context/credentials-test-context.js.map +1 -0
  127. package/dist/execution-engine/node-execution-context/execute-context.d.ts +24 -0
  128. package/dist/execution-engine/node-execution-context/execute-context.js +108 -0
  129. package/dist/execution-engine/node-execution-context/execute-context.js.map +1 -0
  130. package/dist/execution-engine/node-execution-context/execute-single-context.d.ts +15 -0
  131. package/dist/execution-engine/node-execution-context/execute-single-context.js +53 -0
  132. package/dist/execution-engine/node-execution-context/execute-single-context.js.map +1 -0
  133. package/dist/execution-engine/node-execution-context/hook-context.d.ts +13 -0
  134. package/dist/execution-engine/node-execution-context/hook-context.js +35 -0
  135. package/dist/execution-engine/node-execution-context/hook-context.js.map +1 -0
  136. package/dist/execution-engine/node-execution-context/index.d.ts +17 -0
  137. package/dist/execution-engine/node-execution-context/index.js +51 -0
  138. package/dist/execution-engine/node-execution-context/index.js.map +1 -0
  139. package/dist/execution-engine/node-execution-context/load-options-context.d.ts +10 -0
  140. package/dist/execution-engine/node-execution-context/load-options-context.js +43 -0
  141. package/dist/execution-engine/node-execution-context/load-options-context.js.map +1 -0
  142. package/dist/execution-engine/node-execution-context/local-load-options-context.d.ts +10 -0
  143. package/dist/execution-engine/node-execution-context/local-load-options-context.js +51 -0
  144. package/dist/execution-engine/node-execution-context/local-load-options-context.js.map +1 -0
  145. package/dist/execution-engine/node-execution-context/node-execution-context.d.ts +68 -0
  146. package/dist/execution-engine/node-execution-context/node-execution-context.js +324 -0
  147. package/dist/execution-engine/node-execution-context/node-execution-context.js.map +1 -0
  148. package/dist/execution-engine/node-execution-context/poll-context.d.ts +11 -0
  149. package/dist/execution-engine/node-execution-context/poll-context.js +38 -0
  150. package/dist/execution-engine/node-execution-context/poll-context.js.map +1 -0
  151. package/dist/execution-engine/node-execution-context/supply-data-context.d.ts +26 -0
  152. package/dist/execution-engine/node-execution-context/supply-data-context.js +181 -0
  153. package/dist/execution-engine/node-execution-context/supply-data-context.js.map +1 -0
  154. package/dist/execution-engine/node-execution-context/trigger-context.d.ts +11 -0
  155. package/dist/execution-engine/node-execution-context/trigger-context.js +40 -0
  156. package/dist/execution-engine/node-execution-context/trigger-context.js.map +1 -0
  157. package/dist/execution-engine/node-execution-context/utils/binary-helper-functions.d.ts +10 -0
  158. package/dist/execution-engine/node-execution-context/utils/binary-helper-functions.js +213 -0
  159. package/dist/execution-engine/node-execution-context/utils/binary-helper-functions.js.map +1 -0
  160. package/dist/execution-engine/node-execution-context/utils/cleanup-parameter-data.d.ts +2 -0
  161. package/dist/execution-engine/node-execution-context/utils/cleanup-parameter-data.js +27 -0
  162. package/dist/execution-engine/node-execution-context/utils/cleanup-parameter-data.js.map +1 -0
  163. package/dist/execution-engine/node-execution-context/utils/construct-execution-metadata.d.ts +4 -0
  164. package/dist/execution-engine/node-execution-context/utils/construct-execution-metadata.js +11 -0
  165. package/dist/execution-engine/node-execution-context/utils/construct-execution-metadata.js.map +1 -0
  166. package/dist/execution-engine/node-execution-context/utils/copy-input-items.d.ts +2 -0
  167. package/dist/execution-engine/node-execution-context/utils/copy-input-items.js +19 -0
  168. package/dist/execution-engine/node-execution-context/utils/copy-input-items.js.map +1 -0
  169. package/dist/execution-engine/node-execution-context/utils/create-node-as-tool.d.ts +21 -0
  170. package/dist/execution-engine/node-execution-context/utils/create-node-as-tool.js +65 -0
  171. package/dist/execution-engine/node-execution-context/utils/create-node-as-tool.js.map +1 -0
  172. package/dist/execution-engine/node-execution-context/utils/data-table-helper-functions.d.ts +2 -0
  173. package/dist/execution-engine/node-execution-context/utils/data-table-helper-functions.js +13 -0
  174. package/dist/execution-engine/node-execution-context/utils/data-table-helper-functions.js.map +1 -0
  175. package/dist/execution-engine/node-execution-context/utils/deduplication-helper-functions.d.ts +2 -0
  176. package/dist/execution-engine/node-execution-context/utils/deduplication-helper-functions.js +38 -0
  177. package/dist/execution-engine/node-execution-context/utils/deduplication-helper-functions.js.map +1 -0
  178. package/dist/execution-engine/node-execution-context/utils/ensure-type.d.ts +6 -0
  179. package/dist/execution-engine/node-execution-context/utils/ensure-type.js +75 -0
  180. package/dist/execution-engine/node-execution-context/utils/ensure-type.js.map +1 -0
  181. package/dist/execution-engine/node-execution-context/utils/execution-metadata.d.ts +6 -0
  182. package/dist/execution-engine/node-execution-context/utils/execution-metadata.js +57 -0
  183. package/dist/execution-engine/node-execution-context/utils/execution-metadata.js.map +1 -0
  184. package/dist/execution-engine/node-execution-context/utils/extract-value.d.ts +2 -0
  185. package/dist/execution-engine/node-execution-context/utils/extract-value.js +135 -0
  186. package/dist/execution-engine/node-execution-context/utils/extract-value.js.map +1 -0
  187. package/dist/execution-engine/node-execution-context/utils/file-system-helper-functions.d.ts +2 -0
  188. package/dist/execution-engine/node-execution-context/utils/file-system-helper-functions.js +144 -0
  189. package/dist/execution-engine/node-execution-context/utils/file-system-helper-functions.js.map +1 -0
  190. package/dist/execution-engine/node-execution-context/utils/get-additional-keys.d.ts +4 -0
  191. package/dist/execution-engine/node-execution-context/utils/get-additional-keys.js +57 -0
  192. package/dist/execution-engine/node-execution-context/utils/get-additional-keys.js.map +1 -0
  193. package/dist/execution-engine/node-execution-context/utils/get-input-connection-data.d.ts +5 -0
  194. package/dist/execution-engine/node-execution-context/utils/get-input-connection-data.js +211 -0
  195. package/dist/execution-engine/node-execution-context/utils/get-input-connection-data.js.map +1 -0
  196. package/dist/execution-engine/node-execution-context/utils/get-secrets-proxy.d.ts +2 -0
  197. package/dist/execution-engine/node-execution-context/utils/get-secrets-proxy.js +68 -0
  198. package/dist/execution-engine/node-execution-context/utils/get-secrets-proxy.js.map +1 -0
  199. package/dist/execution-engine/node-execution-context/utils/normalize-items.d.ts +2 -0
  200. package/dist/execution-engine/node-execution-context/utils/normalize-items.js +36 -0
  201. package/dist/execution-engine/node-execution-context/utils/normalize-items.js.map +1 -0
  202. package/dist/execution-engine/node-execution-context/utils/parse-incoming-message.d.ts +16 -0
  203. package/dist/execution-engine/node-execution-context/utils/parse-incoming-message.js +57 -0
  204. package/dist/execution-engine/node-execution-context/utils/parse-incoming-message.js.map +1 -0
  205. package/dist/execution-engine/node-execution-context/utils/request-helper-functions.d.ts +18 -0
  206. package/dist/execution-engine/node-execution-context/utils/request-helper-functions.js +1213 -0
  207. package/dist/execution-engine/node-execution-context/utils/request-helper-functions.js.map +1 -0
  208. package/dist/execution-engine/node-execution-context/utils/return-json-array.d.ts +2 -0
  209. package/dist/execution-engine/node-execution-context/utils/return-json-array.js +19 -0
  210. package/dist/execution-engine/node-execution-context/utils/return-json-array.js.map +1 -0
  211. package/dist/execution-engine/node-execution-context/utils/scheduling-helper-functions.d.ts +2 -0
  212. package/dist/execution-engine/node-execution-context/utils/scheduling-helper-functions.js +22 -0
  213. package/dist/execution-engine/node-execution-context/utils/scheduling-helper-functions.js.map +1 -0
  214. package/dist/execution-engine/node-execution-context/utils/ssh-tunnel-helper-functions.d.ts +2 -0
  215. package/dist/execution-engine/node-execution-context/utils/ssh-tunnel-helper-functions.js +14 -0
  216. package/dist/execution-engine/node-execution-context/utils/ssh-tunnel-helper-functions.js.map +1 -0
  217. package/dist/execution-engine/node-execution-context/utils/validate-value-against-schema.d.ts +2 -0
  218. package/dist/execution-engine/node-execution-context/utils/validate-value-against-schema.js +132 -0
  219. package/dist/execution-engine/node-execution-context/utils/validate-value-against-schema.js.map +1 -0
  220. package/dist/execution-engine/node-execution-context/utils/webhook-helper-functions.d.ts +3 -0
  221. package/dist/execution-engine/node-execution-context/utils/webhook-helper-functions.js +31 -0
  222. package/dist/execution-engine/node-execution-context/utils/webhook-helper-functions.js.map +1 -0
  223. package/dist/execution-engine/node-execution-context/webhook-context.d.ts +21 -0
  224. package/dist/execution-engine/node-execution-context/webhook-context.js +87 -0
  225. package/dist/execution-engine/node-execution-context/webhook-context.js.map +1 -0
  226. package/dist/execution-engine/node-execution-context/workflow-node-context.d.ts +6 -0
  227. package/dist/execution-engine/node-execution-context/workflow-node-context.js +14 -0
  228. package/dist/execution-engine/node-execution-context/workflow-node-context.js.map +1 -0
  229. package/dist/execution-engine/partial-execution-utils/clean-run-data.d.ts +3 -0
  230. package/dist/execution-engine/partial-execution-utils/clean-run-data.js +28 -0
  231. package/dist/execution-engine/partial-execution-utils/clean-run-data.js.map +1 -0
  232. package/dist/execution-engine/partial-execution-utils/directed-graph.d.ts +65 -0
  233. package/dist/execution-engine/partial-execution-utils/directed-graph.js +370 -0
  234. package/dist/execution-engine/partial-execution-utils/directed-graph.js.map +1 -0
  235. package/dist/execution-engine/partial-execution-utils/filter-disabled-nodes.d.ts +2 -0
  236. package/dist/execution-engine/partial-execution-utils/filter-disabled-nodes.js +17 -0
  237. package/dist/execution-engine/partial-execution-utils/filter-disabled-nodes.js.map +1 -0
  238. package/dist/execution-engine/partial-execution-utils/find-start-nodes.d.ts +10 -0
  239. package/dist/execution-engine/partial-execution-utils/find-start-nodes.js +74 -0
  240. package/dist/execution-engine/partial-execution-utils/find-start-nodes.js.map +1 -0
  241. package/dist/execution-engine/partial-execution-utils/find-subgraph.d.ts +7 -0
  242. package/dist/execution-engine/partial-execution-utils/find-subgraph.js +59 -0
  243. package/dist/execution-engine/partial-execution-utils/find-subgraph.js.map +1 -0
  244. package/dist/execution-engine/partial-execution-utils/find-trigger-for-partial-execution.d.ts +4 -0
  245. package/dist/execution-engine/partial-execution-utils/find-trigger-for-partial-execution.js +102 -0
  246. package/dist/execution-engine/partial-execution-utils/find-trigger-for-partial-execution.js.map +1 -0
  247. package/dist/execution-engine/partial-execution-utils/get-incoming-data.d.ts +6 -0
  248. package/dist/execution-engine/partial-execution-utils/get-incoming-data.js +21 -0
  249. package/dist/execution-engine/partial-execution-utils/get-incoming-data.js.map +1 -0
  250. package/dist/execution-engine/partial-execution-utils/get-source-data-groups.d.ts +8 -0
  251. package/dist/execution-engine/partial-execution-utils/get-source-data-groups.js +65 -0
  252. package/dist/execution-engine/partial-execution-utils/get-source-data-groups.js.map +1 -0
  253. package/dist/execution-engine/partial-execution-utils/handle-cycles.d.ts +3 -0
  254. package/dist/execution-engine/partial-execution-utils/handle-cycles.js +60 -0
  255. package/dist/execution-engine/partial-execution-utils/handle-cycles.js.map +1 -0
  256. package/dist/execution-engine/partial-execution-utils/index.d.ts +10 -0
  257. package/dist/execution-engine/partial-execution-utils/index.js +25 -0
  258. package/dist/execution-engine/partial-execution-utils/index.js.map +1 -0
  259. package/dist/execution-engine/partial-execution-utils/recreate-node-execution-stack.d.ts +9 -0
  260. package/dist/execution-engine/partial-execution-utils/recreate-node-execution-stack.js +146 -0
  261. package/dist/execution-engine/partial-execution-utils/recreate-node-execution-stack.js.map +1 -0
  262. package/dist/execution-engine/partial-execution-utils/rewire-graph.d.ts +3 -0
  263. package/dist/execution-engine/partial-execution-utils/rewire-graph.js +72 -0
  264. package/dist/execution-engine/partial-execution-utils/rewire-graph.js.map +1 -0
  265. package/dist/execution-engine/partial-execution-utils/run-data-utils.d.ts +2 -0
  266. package/dist/execution-engine/partial-execution-utils/run-data-utils.js +15 -0
  267. package/dist/execution-engine/partial-execution-utils/run-data-utils.js.map +1 -0
  268. package/dist/execution-engine/requests-response.d.ts +23 -0
  269. package/dist/execution-engine/requests-response.js +128 -0
  270. package/dist/execution-engine/requests-response.js.map +1 -0
  271. package/dist/execution-engine/routing-node.d.ts +17 -0
  272. package/dist/execution-engine/routing-node.js +571 -0
  273. package/dist/execution-engine/routing-node.js.map +1 -0
  274. package/dist/execution-engine/scheduled-task-manager.d.ts +27 -0
  275. package/dist/execution-engine/scheduled-task-manager.js +140 -0
  276. package/dist/execution-engine/scheduled-task-manager.js.map +1 -0
  277. package/dist/execution-engine/ssh-clients-manager.d.ts +27 -0
  278. package/dist/execution-engine/ssh-clients-manager.js +170 -0
  279. package/dist/execution-engine/ssh-clients-manager.js.map +1 -0
  280. package/dist/execution-engine/triggers-and-pollers.d.ts +6 -0
  281. package/dist/execution-engine/triggers-and-pollers.js +66 -0
  282. package/dist/execution-engine/triggers-and-pollers.js.map +1 -0
  283. package/dist/execution-engine/workflow-execute.d.ts +46 -0
  284. package/dist/execution-engine/workflow-execute.js +1490 -0
  285. package/dist/execution-engine/workflow-execute.js.map +1 -0
  286. package/dist/html-sandbox.d.ts +3 -0
  287. package/dist/html-sandbox.js +19 -0
  288. package/dist/html-sandbox.js.map +1 -0
  289. package/dist/http-proxy.d.ts +6 -0
  290. package/dist/http-proxy.js +109 -0
  291. package/dist/http-proxy.js.map +1 -0
  292. package/dist/index.d.ts +17 -0
  293. package/dist/index.js +57 -0
  294. package/dist/index.js.map +1 -0
  295. package/dist/instance-settings/index.d.ts +1 -0
  296. package/dist/instance-settings/index.js +6 -0
  297. package/dist/instance-settings/index.js.map +1 -0
  298. package/dist/instance-settings/instance-settings.d.ts +49 -0
  299. package/dist/instance-settings/instance-settings.js +210 -0
  300. package/dist/instance-settings/instance-settings.js.map +1 -0
  301. package/dist/instance-settings/worker-missing-encryption-key.error.d.ts +4 -0
  302. package/dist/instance-settings/worker-missing-encryption-key.error.js +15 -0
  303. package/dist/instance-settings/worker-missing-encryption-key.error.js.map +1 -0
  304. package/dist/interfaces.d.ts +16 -0
  305. package/dist/interfaces.js +3 -0
  306. package/dist/interfaces.js.map +1 -0
  307. package/dist/node-execute-functions.d.ts +3 -0
  308. package/dist/node-execute-functions.js +12 -0
  309. package/dist/node-execute-functions.js.map +1 -0
  310. package/dist/nodes-loader/constants.d.ts +5 -0
  311. package/dist/nodes-loader/constants.js +106 -0
  312. package/dist/nodes-loader/constants.js.map +1 -0
  313. package/dist/nodes-loader/custom-directory-loader.d.ts +6 -0
  314. package/dist/nodes-loader/custom-directory-loader.js +34 -0
  315. package/dist/nodes-loader/custom-directory-loader.js.map +1 -0
  316. package/dist/nodes-loader/directory-loader.d.ts +41 -0
  317. package/dist/nodes-loader/directory-loader.js +371 -0
  318. package/dist/nodes-loader/directory-loader.js.map +1 -0
  319. package/dist/nodes-loader/index.d.ts +5 -0
  320. package/dist/nodes-loader/index.js +12 -0
  321. package/dist/nodes-loader/index.js.map +1 -0
  322. package/dist/nodes-loader/lazy-package-directory-loader.d.ts +4 -0
  323. package/dist/nodes-loader/lazy-package-directory-loader.js +42 -0
  324. package/dist/nodes-loader/lazy-package-directory-loader.js.map +1 -0
  325. package/dist/nodes-loader/load-class-in-isolation.d.ts +1 -0
  326. package/dist/nodes-loader/load-class-in-isolation.js +20 -0
  327. package/dist/nodes-loader/load-class-in-isolation.js.map +1 -0
  328. package/dist/nodes-loader/package-directory-loader.d.ts +12 -0
  329. package/dist/nodes-loader/package-directory-loader.js +86 -0
  330. package/dist/nodes-loader/package-directory-loader.js.map +1 -0
  331. package/dist/nodes-loader/types.d.ts +14 -0
  332. package/dist/nodes-loader/types.js +3 -0
  333. package/dist/nodes-loader/types.js.map +1 -0
  334. package/dist/utils/assertions.d.ts +2 -0
  335. package/dist/utils/assertions.js +16 -0
  336. package/dist/utils/assertions.js.map +1 -0
  337. package/dist/utils/deep-merge.d.ts +1 -0
  338. package/dist/utils/deep-merge.js +33 -0
  339. package/dist/utils/deep-merge.js.map +1 -0
  340. package/dist/utils/index.d.ts +2 -0
  341. package/dist/utils/index.js +19 -0
  342. package/dist/utils/index.js.map +1 -0
  343. package/dist/utils/is-json-compatible.d.ts +7 -0
  344. package/dist/utils/is-json-compatible.js +81 -0
  345. package/dist/utils/is-json-compatible.js.map +1 -0
  346. package/dist/utils/serialized-buffer.d.ts +6 -0
  347. package/dist/utils/serialized-buffer.js +16 -0
  348. package/dist/utils/serialized-buffer.js.map +1 -0
  349. package/dist/utils/signature-helpers.d.ts +2 -0
  350. package/dist/utils/signature-helpers.js +16 -0
  351. package/dist/utils/signature-helpers.js.map +1 -0
  352. package/package.json +81 -0
@@ -0,0 +1,1490 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.WorkflowExecute = void 0;
40
+ const config_1 = require("@n8n/config");
41
+ const constants_1 = require("@n8n/constants");
42
+ const di_1 = require("@n8n/di");
43
+ const assert = __importStar(require("assert/strict"));
44
+ const events_1 = require("events");
45
+ const get_1 = __importDefault(require("lodash/get"));
46
+ const n8n_workflow_1 = require("n8n-workflow");
47
+ const p_cancelable_1 = __importDefault(require("p-cancelable"));
48
+ const error_reporter_1 = require("../errors/error-reporter");
49
+ const workflow_has_issues_error_1 = require("../errors/workflow-has-issues.error");
50
+ const NodeExecuteFunctions = __importStar(require("../node-execute-functions"));
51
+ const assertions_1 = require("../utils/assertions");
52
+ const is_json_compatible_1 = require("../utils/is-json-compatible");
53
+ const execution_context_1 = require("./execution-context");
54
+ const node_execution_context_1 = require("./node-execution-context");
55
+ const partial_execution_utils_1 = require("./partial-execution-utils");
56
+ const requests_response_1 = require("./requests-response");
57
+ const routing_node_1 = require("./routing-node");
58
+ const triggers_and_pollers_1 = require("./triggers-and-pollers");
59
+ class WorkflowExecute {
60
+ constructor(additionalData, mode, runExecutionData = (0, n8n_workflow_1.createRunExecutionData)()) {
61
+ this.additionalData = additionalData;
62
+ this.mode = mode;
63
+ this.runExecutionData = runExecutionData;
64
+ this.status = 'new';
65
+ this.abortController = new AbortController();
66
+ this.timedOut = false;
67
+ }
68
+ run(workflow, startNode, destinationNode, pinData, triggerToStartFrom) {
69
+ this.status = 'running';
70
+ startNode = startNode || workflow.getStartNode(destinationNode?.nodeName);
71
+ if (startNode === undefined) {
72
+ throw new n8n_workflow_1.ApplicationError('No node to start the workflow from could be found');
73
+ }
74
+ let runNodeFilter;
75
+ if (destinationNode) {
76
+ runNodeFilter = workflow.getParentNodes(destinationNode.nodeName);
77
+ if (destinationNode.mode === 'inclusive') {
78
+ runNodeFilter.push(destinationNode.nodeName);
79
+ }
80
+ }
81
+ const nodeExecutionStack = [
82
+ {
83
+ node: startNode,
84
+ data: triggerToStartFrom?.data?.data ?? {
85
+ main: [
86
+ [
87
+ {
88
+ json: {},
89
+ },
90
+ ],
91
+ ],
92
+ },
93
+ source: null,
94
+ },
95
+ ];
96
+ this.runExecutionData = (0, n8n_workflow_1.createRunExecutionData)({
97
+ startData: {
98
+ destinationNode,
99
+ runNodeFilter,
100
+ },
101
+ executionData: {
102
+ nodeExecutionStack,
103
+ },
104
+ resultData: {
105
+ pinData,
106
+ },
107
+ });
108
+ return this.processRunExecutionData(workflow);
109
+ }
110
+ isLegacyExecutionOrder(workflow) {
111
+ return workflow.settings.executionOrder !== 'v1';
112
+ }
113
+ runPartialWorkflow2(workflow, runData, pinData = {}, dirtyNodeNames = [], destinationNode, agentRequest) {
114
+ const originalDestination = { ...destinationNode };
115
+ let destination = workflow.getNode(destinationNode.nodeName);
116
+ assert.ok(destination, `Could not find a node with the name ${destinationNode.nodeName} in the workflow.`);
117
+ let graph = partial_execution_utils_1.DirectedGraph.fromWorkflow(workflow);
118
+ const destinationNodeType = workflow.nodeTypes.getByNameAndVersion(destination.type, destination.typeVersion);
119
+ if (n8n_workflow_1.NodeHelpers.isTool(destinationNodeType.description, destination.parameters)) {
120
+ graph = (0, partial_execution_utils_1.rewireGraph)(destination, graph, agentRequest);
121
+ workflow = graph.toWorkflow({ ...workflow });
122
+ const toolExecutorNode = workflow.getNode(constants_1.TOOL_EXECUTOR_NODE_NAME);
123
+ if (!toolExecutorNode) {
124
+ throw new n8n_workflow_1.OperationalError('ToolExecutor can not be found');
125
+ }
126
+ destination = toolExecutorNode;
127
+ destinationNode = { nodeName: toolExecutorNode.name, mode: 'inclusive' };
128
+ }
129
+ let trigger = (0, partial_execution_utils_1.findTriggerForPartialExecution)(workflow, destinationNode.nodeName, runData);
130
+ if (trigger === undefined) {
131
+ let startNode;
132
+ const parentNodes = workflow.getParentNodes(destinationNode.nodeName);
133
+ for (const nodeName of parentNodes) {
134
+ if (runData[nodeName]) {
135
+ startNode = workflow.getNode(nodeName);
136
+ break;
137
+ }
138
+ }
139
+ if (!startNode) {
140
+ throw new n8n_workflow_1.UserError('Connect a trigger to run this node');
141
+ }
142
+ trigger = startNode;
143
+ }
144
+ graph = (0, partial_execution_utils_1.findSubgraph)({ graph: (0, partial_execution_utils_1.filterDisabledNodes)(graph), destination, trigger });
145
+ const filteredNodes = graph.getNodes();
146
+ const dirtyNodes = graph.getNodesByNames(dirtyNodeNames);
147
+ runData = (0, partial_execution_utils_1.cleanRunData)(runData, graph, dirtyNodes);
148
+ let startNodes = (0, partial_execution_utils_1.findStartNodes)({ graph, trigger, destination, runData, pinData });
149
+ startNodes = (0, partial_execution_utils_1.handleCycles)(graph, startNodes, trigger);
150
+ runData = (0, partial_execution_utils_1.cleanRunData)(runData, graph, startNodes);
151
+ const { nodeExecutionStack, waitingExecution, waitingExecutionSource } = (0, partial_execution_utils_1.recreateNodeExecutionStack)(graph, startNodes, runData, pinData ?? {});
152
+ this.additionalData.currentNodeExecutionIndex = (0, partial_execution_utils_1.getNextExecutionIndex)(runData);
153
+ this.status = 'running';
154
+ this.runExecutionData = (0, n8n_workflow_1.createRunExecutionData)({
155
+ startData: {
156
+ destinationNode,
157
+ originalDestinationNode: originalDestination,
158
+ runNodeFilter: Array.from(filteredNodes.values()).map((node) => node.name),
159
+ },
160
+ resultData: {
161
+ runData,
162
+ pinData,
163
+ },
164
+ executionData: {
165
+ nodeExecutionStack,
166
+ waitingExecution,
167
+ waitingExecutionSource,
168
+ },
169
+ });
170
+ return this.processRunExecutionData(workflow);
171
+ }
172
+ moveNodeMetadata() {
173
+ const metadata = (0, get_1.default)(this.runExecutionData, 'executionData.metadata');
174
+ if (metadata) {
175
+ const runData = (0, get_1.default)(this.runExecutionData, 'resultData.runData');
176
+ let index;
177
+ let metaRunData;
178
+ for (const nodeName of Object.keys(metadata)) {
179
+ for ([index, metaRunData] of metadata[nodeName].entries()) {
180
+ const taskData = runData[nodeName]?.[index];
181
+ if (taskData) {
182
+ taskData.metadata = { ...taskData.metadata, ...metaRunData };
183
+ }
184
+ else {
185
+ di_1.Container.get(error_reporter_1.ErrorReporter).error(new n8n_workflow_1.UnexpectedError('Taskdata missing at the end of an execution'), { extra: { nodeName, index } });
186
+ }
187
+ }
188
+ }
189
+ }
190
+ }
191
+ incomingConnectionIsEmpty(runData, inputConnections, runIndex) {
192
+ for (const inputConnection of inputConnections) {
193
+ const nodeIncomingData = (0, get_1.default)(runData, [
194
+ inputConnection.node,
195
+ runIndex,
196
+ 'data',
197
+ 'main',
198
+ inputConnection.index,
199
+ ]);
200
+ if (nodeIncomingData !== undefined && nodeIncomingData.length !== 0) {
201
+ return false;
202
+ }
203
+ }
204
+ return true;
205
+ }
206
+ prepareWaitingToExecution(nodeName, numberOfConnections, runIndex) {
207
+ const executionData = this.runExecutionData.executionData;
208
+ executionData.waitingExecution ??= {};
209
+ executionData.waitingExecutionSource ??= {};
210
+ const nodeWaiting = (executionData.waitingExecution[nodeName] ??= []);
211
+ const nodeWaitingSource = (executionData.waitingExecutionSource[nodeName] ??= []);
212
+ nodeWaiting[runIndex] = { main: [] };
213
+ nodeWaitingSource[runIndex] = { main: [] };
214
+ for (let i = 0; i < numberOfConnections; i++) {
215
+ nodeWaiting[runIndex].main.push(null);
216
+ nodeWaitingSource[runIndex].main.push(null);
217
+ }
218
+ }
219
+ addNodeToBeExecuted(workflow, connectionData, outputIndex, parentNodeName, nodeSuccessData, runIndex, newRunIndex, metadata) {
220
+ let stillDataMissing = false;
221
+ const enqueueFn = workflow.settings.executionOrder === 'v1' ? 'unshift' : 'push';
222
+ let waitingNodeIndex;
223
+ const numberOfInputs = workflow.connectionsByDestinationNode[connectionData.node]?.main?.length ?? 0;
224
+ if (numberOfInputs > 1) {
225
+ let nodeWasWaiting = true;
226
+ if (!this.runExecutionData.executionData.waitingExecutionSource) {
227
+ this.runExecutionData.executionData.waitingExecutionSource = {};
228
+ }
229
+ if (this.runExecutionData.executionData.waitingExecution[connectionData.node] === undefined) {
230
+ this.runExecutionData.executionData.waitingExecution[connectionData.node] = {};
231
+ this.runExecutionData.executionData.waitingExecutionSource[connectionData.node] = {};
232
+ nodeWasWaiting = false;
233
+ }
234
+ let createNewWaitingEntry = true;
235
+ if (Object.keys(this.runExecutionData.executionData.waitingExecution[connectionData.node])
236
+ .length > 0) {
237
+ for (const index of Object.keys(this.runExecutionData.executionData.waitingExecution[connectionData.node])) {
238
+ if (!this.runExecutionData.executionData.waitingExecution[connectionData.node][parseInt(index)].main[connectionData.index]) {
239
+ createNewWaitingEntry = false;
240
+ waitingNodeIndex = parseInt(index);
241
+ break;
242
+ }
243
+ }
244
+ }
245
+ if (waitingNodeIndex === undefined) {
246
+ waitingNodeIndex = Object.values(this.runExecutionData.executionData.waitingExecution[connectionData.node]).length;
247
+ }
248
+ if (createNewWaitingEntry) {
249
+ this.prepareWaitingToExecution(connectionData.node, workflow.connectionsByDestinationNode[connectionData.node].main.length, waitingNodeIndex);
250
+ }
251
+ if (nodeSuccessData === null) {
252
+ this.runExecutionData.executionData.waitingExecution[connectionData.node][waitingNodeIndex].main[connectionData.index] = null;
253
+ this.runExecutionData.executionData.waitingExecutionSource[connectionData.node][waitingNodeIndex].main[connectionData.index] = null;
254
+ }
255
+ else {
256
+ this.runExecutionData.executionData.waitingExecution[connectionData.node][waitingNodeIndex].main[connectionData.index] = nodeSuccessData[outputIndex];
257
+ this.runExecutionData.executionData.waitingExecutionSource[connectionData.node][waitingNodeIndex].main[connectionData.index] = {
258
+ previousNode: parentNodeName,
259
+ previousNodeOutput: outputIndex || undefined,
260
+ previousNodeRun: runIndex || undefined,
261
+ };
262
+ }
263
+ let thisExecutionData;
264
+ let allDataFound = true;
265
+ for (let i = 0; i <
266
+ this.runExecutionData.executionData.waitingExecution[connectionData.node][waitingNodeIndex]
267
+ .main.length; i++) {
268
+ thisExecutionData =
269
+ this.runExecutionData.executionData.waitingExecution[connectionData.node][waitingNodeIndex].main[i];
270
+ if (thisExecutionData === null) {
271
+ allDataFound = false;
272
+ break;
273
+ }
274
+ }
275
+ if (allDataFound) {
276
+ const executionStackItem = {
277
+ node: workflow.nodes[connectionData.node],
278
+ data: this.runExecutionData.executionData.waitingExecution[connectionData.node][waitingNodeIndex],
279
+ source: this.runExecutionData.executionData.waitingExecutionSource[connectionData.node][waitingNodeIndex],
280
+ };
281
+ if (this.runExecutionData.executionData.waitingExecutionSource !== null &&
282
+ this.runExecutionData.executionData.waitingExecutionSource !== undefined) {
283
+ executionStackItem.source =
284
+ this.runExecutionData.executionData.waitingExecutionSource[connectionData.node][waitingNodeIndex];
285
+ }
286
+ this.runExecutionData.executionData.nodeExecutionStack[enqueueFn](executionStackItem);
287
+ delete this.runExecutionData.executionData.waitingExecution[connectionData.node][waitingNodeIndex];
288
+ delete this.runExecutionData.executionData.waitingExecutionSource[connectionData.node][waitingNodeIndex];
289
+ if (Object.keys(this.runExecutionData.executionData.waitingExecution[connectionData.node])
290
+ .length === 0) {
291
+ delete this.runExecutionData.executionData.waitingExecution[connectionData.node];
292
+ delete this.runExecutionData.executionData.waitingExecutionSource[connectionData.node];
293
+ }
294
+ return;
295
+ }
296
+ stillDataMissing = true;
297
+ if (!nodeWasWaiting) {
298
+ const checkOutputNodes = [];
299
+ for (const outputIndexParent in workflow.connectionsBySourceNode[parentNodeName].main) {
300
+ if (!Object.hasOwn(workflow.connectionsBySourceNode[parentNodeName].main, outputIndexParent)) {
301
+ continue;
302
+ }
303
+ for (const connectionDataCheck of workflow.connectionsBySourceNode[parentNodeName].main[outputIndexParent] ?? []) {
304
+ checkOutputNodes.push(connectionDataCheck.node);
305
+ }
306
+ }
307
+ for (let inputIndex = 0; inputIndex < workflow.connectionsByDestinationNode[connectionData.node].main.length; inputIndex++) {
308
+ for (const inputData of workflow.connectionsByDestinationNode[connectionData.node].main[inputIndex] ?? []) {
309
+ if (inputData.node === parentNodeName) {
310
+ continue;
311
+ }
312
+ const executionStackNodes = this.runExecutionData.executionData.nodeExecutionStack.map((stackData) => stackData.node.name);
313
+ if (inputData.node !== parentNodeName && checkOutputNodes.includes(inputData.node)) {
314
+ if (!this.incomingConnectionIsEmpty(this.runExecutionData.resultData.runData, workflow.connectionsByDestinationNode[inputData.node].main[0] ?? [], runIndex)) {
315
+ continue;
316
+ }
317
+ }
318
+ if (executionStackNodes.includes(inputData.node)) {
319
+ continue;
320
+ }
321
+ if (this.runExecutionData.resultData.runData[inputData.node] !== undefined) {
322
+ continue;
323
+ }
324
+ if (!this.isLegacyExecutionOrder(workflow)) {
325
+ continue;
326
+ }
327
+ const parentNodes = workflow.getParentNodes(inputData.node, n8n_workflow_1.NodeConnectionTypes.Main, -1);
328
+ let nodeToAdd = inputData.node;
329
+ parentNodes.push(inputData.node);
330
+ parentNodes.reverse();
331
+ for (const parentNode of parentNodes) {
332
+ if (inputData.node !== parentNode && checkOutputNodes.includes(parentNode)) {
333
+ nodeToAdd = undefined;
334
+ break;
335
+ }
336
+ if (executionStackNodes.includes(parentNode)) {
337
+ nodeToAdd = undefined;
338
+ break;
339
+ }
340
+ if (this.runExecutionData.resultData.runData[parentNode] !== undefined) {
341
+ break;
342
+ }
343
+ nodeToAdd = parentNode;
344
+ }
345
+ const parentNodesNodeToAdd = workflow.getParentNodes(nodeToAdd);
346
+ if (parentNodesNodeToAdd.includes(parentNodeName) &&
347
+ nodeSuccessData[outputIndex].length === 0) {
348
+ nodeToAdd = undefined;
349
+ }
350
+ if (nodeToAdd === undefined) {
351
+ continue;
352
+ }
353
+ let addEmptyItem = false;
354
+ if (workflow.connectionsByDestinationNode[nodeToAdd] === undefined) {
355
+ addEmptyItem = true;
356
+ }
357
+ else if (this.incomingConnectionIsEmpty(this.runExecutionData.resultData.runData, workflow.connectionsByDestinationNode[nodeToAdd].main[0] ?? [], runIndex)) {
358
+ addEmptyItem = true;
359
+ }
360
+ if (addEmptyItem) {
361
+ this.runExecutionData.executionData.nodeExecutionStack[enqueueFn]({
362
+ node: workflow.getNode(nodeToAdd),
363
+ data: {
364
+ main: [
365
+ [
366
+ {
367
+ json: {},
368
+ },
369
+ ],
370
+ ],
371
+ },
372
+ source: {
373
+ main: [
374
+ {
375
+ previousNode: parentNodeName,
376
+ previousNodeOutput: outputIndex || undefined,
377
+ previousNodeRun: runIndex || undefined,
378
+ },
379
+ ],
380
+ },
381
+ });
382
+ }
383
+ }
384
+ }
385
+ }
386
+ }
387
+ let connectionDataArray = (0, get_1.default)(this.runExecutionData, [
388
+ 'executionData',
389
+ 'waitingExecution',
390
+ connectionData.node,
391
+ waitingNodeIndex,
392
+ n8n_workflow_1.NodeConnectionTypes.Main,
393
+ ], null);
394
+ if (connectionDataArray === null) {
395
+ connectionDataArray = [];
396
+ for (let i = connectionData.index; i >= 0; i--) {
397
+ connectionDataArray[i] = null;
398
+ }
399
+ }
400
+ if (nodeSuccessData === null) {
401
+ connectionDataArray[connectionData.index] = null;
402
+ }
403
+ else {
404
+ connectionDataArray[connectionData.index] = nodeSuccessData[outputIndex];
405
+ }
406
+ if (stillDataMissing) {
407
+ waitingNodeIndex = waitingNodeIndex;
408
+ const waitingExecutionSource = this.runExecutionData.executionData.waitingExecutionSource[connectionData.node][waitingNodeIndex].main;
409
+ this.prepareWaitingToExecution(connectionData.node, workflow.connectionsByDestinationNode[connectionData.node].main.length, waitingNodeIndex);
410
+ this.runExecutionData.executionData.waitingExecution[connectionData.node][waitingNodeIndex] =
411
+ {
412
+ main: connectionDataArray,
413
+ };
414
+ this.runExecutionData.executionData.waitingExecutionSource[connectionData.node][waitingNodeIndex].main = waitingExecutionSource;
415
+ }
416
+ else {
417
+ this.runExecutionData.executionData.nodeExecutionStack[enqueueFn]({
418
+ node: workflow.nodes[connectionData.node],
419
+ data: {
420
+ main: connectionDataArray,
421
+ },
422
+ source: {
423
+ main: [
424
+ {
425
+ previousNode: parentNodeName,
426
+ previousNodeOutput: outputIndex || undefined,
427
+ previousNodeRun: runIndex || undefined,
428
+ },
429
+ ],
430
+ },
431
+ runIndex: newRunIndex,
432
+ metadata,
433
+ });
434
+ }
435
+ }
436
+ checkReadyForExecution(workflow, inputData = {}) {
437
+ const workflowIssues = {};
438
+ let checkNodes = [];
439
+ if (inputData.destinationNode) {
440
+ checkNodes = workflow.getParentNodes(inputData.destinationNode.nodeName);
441
+ if (inputData.destinationNode.mode === 'inclusive') {
442
+ checkNodes.push(inputData.destinationNode.nodeName);
443
+ }
444
+ }
445
+ else if (inputData.startNode) {
446
+ checkNodes = workflow.getChildNodes(inputData.startNode);
447
+ checkNodes.push(inputData.startNode);
448
+ }
449
+ for (const nodeName of checkNodes) {
450
+ let nodeIssues = null;
451
+ const node = workflow.nodes[nodeName];
452
+ if (node.disabled === true) {
453
+ continue;
454
+ }
455
+ const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
456
+ if (nodeType === undefined) {
457
+ nodeIssues = {
458
+ typeUnknown: true,
459
+ };
460
+ }
461
+ else {
462
+ nodeIssues = n8n_workflow_1.NodeHelpers.getNodeParametersIssues(nodeType.description.properties, node, nodeType.description, inputData.pinDataNodeNames);
463
+ }
464
+ if (nodeIssues !== null) {
465
+ workflowIssues[node.name] = nodeIssues;
466
+ }
467
+ }
468
+ if (Object.keys(workflowIssues).length === 0) {
469
+ return null;
470
+ }
471
+ return workflowIssues;
472
+ }
473
+ getCustomOperation(node, type) {
474
+ if (!type.customOperations)
475
+ return undefined;
476
+ if (!node.parameters && !node.forceCustomOperation)
477
+ return undefined;
478
+ const { customOperations } = type;
479
+ const { resource, operation } = node.forceCustomOperation ?? node.parameters;
480
+ if (typeof resource !== 'string' || typeof operation !== 'string')
481
+ return undefined;
482
+ if (!customOperations[resource] || !customOperations[resource][operation])
483
+ return undefined;
484
+ const customOperation = customOperations[resource][operation];
485
+ return customOperation;
486
+ }
487
+ handleDisabledNode(inputData) {
488
+ if (Object.hasOwn(inputData, 'main') && inputData.main.length > 0) {
489
+ if (inputData.main[0] === null) {
490
+ return { data: undefined };
491
+ }
492
+ return { data: [inputData.main[0]] };
493
+ }
494
+ return { data: undefined };
495
+ }
496
+ prepareConnectionInputData(workflow, nodeType, customOperation, inputData) {
497
+ if (nodeType.execute ||
498
+ customOperation ||
499
+ (!nodeType.poll && !nodeType.trigger && !nodeType.webhook)) {
500
+ if (!inputData.main?.length) {
501
+ return null;
502
+ }
503
+ let connectionInputData = inputData.main[0];
504
+ const forceInputNodeExecution = workflow.settings.executionOrder !== 'v1';
505
+ if (!forceInputNodeExecution) {
506
+ for (const mainData of inputData.main) {
507
+ if (mainData?.length) {
508
+ connectionInputData = mainData;
509
+ break;
510
+ }
511
+ }
512
+ }
513
+ if (!connectionInputData || connectionInputData.length === 0) {
514
+ return null;
515
+ }
516
+ return connectionInputData;
517
+ }
518
+ return [];
519
+ }
520
+ rethrowLastNodeError(runExecutionData, node) {
521
+ if (runExecutionData.resultData.lastNodeExecuted === node.name &&
522
+ runExecutionData.resultData.error !== undefined) {
523
+ if (runExecutionData.resultData.error.name === 'NodeOperationError' ||
524
+ runExecutionData.resultData.error.name === 'NodeApiError') {
525
+ throw runExecutionData.resultData.error;
526
+ }
527
+ const error = new Error(runExecutionData.resultData.error.message);
528
+ error.stack = runExecutionData.resultData.error.stack;
529
+ throw error;
530
+ }
531
+ }
532
+ handleExecuteOnce(node, inputData) {
533
+ if (node.executeOnce === true) {
534
+ const newInputData = {};
535
+ for (const connectionType of Object.keys(inputData)) {
536
+ newInputData[connectionType] = inputData[connectionType].map((input) => {
537
+ return input && input.slice(0, 1);
538
+ });
539
+ }
540
+ return newInputData;
541
+ }
542
+ return inputData;
543
+ }
544
+ reportJsonIncompatibleOutput(data, workflow, node) {
545
+ if (di_1.Container.get(config_1.GlobalConfig).sentry.backendDsn) {
546
+ const jsonCompatibleResult = (0, is_json_compatible_1.isJsonCompatible)(data, new Set(['pairedItem']));
547
+ if (!jsonCompatibleResult.isValid) {
548
+ di_1.Container.get(error_reporter_1.ErrorReporter).error('node execution returned incorrect output', {
549
+ shouldBeLogged: false,
550
+ extra: {
551
+ nodeName: node.name,
552
+ nodeType: node.type,
553
+ nodeVersion: node.typeVersion,
554
+ workflowId: workflow.id,
555
+ workflowName: workflow.name ?? 'Unnamed workflow',
556
+ executionId: this.additionalData.executionId ?? 'unsaved-execution',
557
+ errorPath: jsonCompatibleResult.errorPath,
558
+ errorMessage: jsonCompatibleResult.errorMessage,
559
+ },
560
+ });
561
+ }
562
+ }
563
+ }
564
+ async executeNode(workflow, node, nodeType, customOperation, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, executionData, abortSignal, subNodeExecutionResults) {
565
+ const closeFunctions = [];
566
+ const context = new node_execution_context_1.ExecuteContext(workflow, node, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, executionData, closeFunctions, abortSignal, subNodeExecutionResults);
567
+ let data;
568
+ if (customOperation) {
569
+ data = await customOperation.call(context);
570
+ }
571
+ else if (nodeType.execute) {
572
+ data =
573
+ nodeType instanceof n8n_workflow_1.Node
574
+ ? await nodeType.execute(context, subNodeExecutionResults)
575
+ : await nodeType.execute.call(context, subNodeExecutionResults);
576
+ }
577
+ else {
578
+ throw new n8n_workflow_1.UnexpectedError("Can't execute node. There is no custom operation and the node has not execute function.");
579
+ }
580
+ if ((0, requests_response_1.isEngineRequest)(data)) {
581
+ return data;
582
+ }
583
+ this.reportJsonIncompatibleOutput(data, workflow, node);
584
+ const closeFunctionsResults = await Promise.allSettled(closeFunctions.map(async (fn) => await fn()));
585
+ const closingErrors = closeFunctionsResults
586
+ .filter((result) => result.status === 'rejected')
587
+ .map((result) => result.reason);
588
+ if (closingErrors.length > 0) {
589
+ if (closingErrors[0] instanceof Error)
590
+ throw closingErrors[0];
591
+ throw new n8n_workflow_1.ApplicationError("Error on execution node's close function(s)", {
592
+ extra: { nodeName: node.name },
593
+ tags: { nodeType: node.type },
594
+ cause: closingErrors,
595
+ });
596
+ }
597
+ return { data, hints: context.hints };
598
+ }
599
+ async executePollNode(workflow, node, nodeType, additionalData, mode, inputData) {
600
+ if (mode === 'manual') {
601
+ const context = new node_execution_context_1.PollContext(workflow, node, additionalData, mode, 'manual');
602
+ return { data: await nodeType.poll.call(context) };
603
+ }
604
+ return { data: inputData.main };
605
+ }
606
+ async executeTriggerNode(workflow, node, additionalData, mode, inputData, abortSignal) {
607
+ if (mode === 'manual') {
608
+ const triggerResponse = await di_1.Container.get(triggers_and_pollers_1.TriggersAndPollers).runTrigger(workflow, node, NodeExecuteFunctions.getExecuteTriggerFunctions, additionalData, mode, 'manual');
609
+ if (triggerResponse === undefined) {
610
+ return { data: null };
611
+ }
612
+ let closeFunction;
613
+ if (triggerResponse.closeFunction) {
614
+ closeFunction = triggerResponse.closeFunction;
615
+ abortSignal?.addEventListener('abort', closeFunction);
616
+ }
617
+ if (triggerResponse.manualTriggerFunction !== undefined) {
618
+ await triggerResponse.manualTriggerFunction();
619
+ }
620
+ const response = await triggerResponse.manualTriggerResponse;
621
+ if (response.length === 0) {
622
+ return { data: null, closeFunction };
623
+ }
624
+ return { data: response, closeFunction };
625
+ }
626
+ return { data: inputData.main };
627
+ }
628
+ async executeDeclarativeNodeInTest(workflow, node, nodeType, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, executionData) {
629
+ const context = new node_execution_context_1.ExecuteContext(workflow, node, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, executionData, []);
630
+ const routingNode = new routing_node_1.RoutingNode(context, nodeType);
631
+ const data = await routingNode.runNode();
632
+ return { data };
633
+ }
634
+ async runNode(workflow, executionData, runExecutionData, runIndex, additionalData, mode, abortSignal, subNodeExecutionResults) {
635
+ const { node } = executionData;
636
+ let inputData = executionData.data;
637
+ if (node.disabled === true) {
638
+ return this.handleDisabledNode(inputData);
639
+ }
640
+ const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
641
+ const customOperation = this.getCustomOperation(node, nodeType);
642
+ const connectionInputData = this.prepareConnectionInputData(workflow, nodeType, customOperation, inputData);
643
+ if (connectionInputData === null) {
644
+ return { data: undefined };
645
+ }
646
+ this.rethrowLastNodeError(runExecutionData, node);
647
+ inputData = this.handleExecuteOnce(node, inputData);
648
+ if (nodeType.execute || customOperation) {
649
+ return await this.executeNode(workflow, node, nodeType, customOperation, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, executionData, abortSignal, subNodeExecutionResults);
650
+ }
651
+ if (nodeType.poll) {
652
+ return await this.executePollNode(workflow, node, nodeType, additionalData, mode, inputData);
653
+ }
654
+ if (nodeType.trigger) {
655
+ return await this.executeTriggerNode(workflow, node, additionalData, mode, inputData, abortSignal);
656
+ }
657
+ const isDeclarativeNode = nodeType.description.requestDefaults !== undefined;
658
+ if (nodeType.webhook && !isDeclarativeNode) {
659
+ return { data: inputData.main };
660
+ }
661
+ return await this.executeDeclarativeNodeInTest(workflow, node, nodeType, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, executionData);
662
+ }
663
+ handleWaitingState(workflow) {
664
+ if (this.runExecutionData.waitTill) {
665
+ this.runExecutionData.waitTill = undefined;
666
+ (0, assertions_1.assertExecutionDataExists)(this.runExecutionData.executionData, workflow, this.additionalData, this.mode);
667
+ this.runExecutionData.executionData.nodeExecutionStack[0].node.disabled = true;
668
+ const lastNodeExecuted = this.runExecutionData.resultData.lastNodeExecuted;
669
+ this.runExecutionData.resultData.runData[lastNodeExecuted].pop();
670
+ }
671
+ }
672
+ checkForWorkflowIssues(workflow) {
673
+ (0, assertions_1.assertExecutionDataExists)(this.runExecutionData.executionData, workflow, this.additionalData, this.mode);
674
+ const startNode = this.runExecutionData.executionData.nodeExecutionStack.at(0)?.node.name;
675
+ let destinationNode;
676
+ if (this.runExecutionData.startData?.destinationNode) {
677
+ destinationNode = this.runExecutionData.startData.destinationNode;
678
+ }
679
+ const pinDataNodeNames = Object.keys(this.runExecutionData.resultData.pinData ?? {});
680
+ const workflowIssues = this.checkReadyForExecution(workflow, {
681
+ startNode,
682
+ destinationNode,
683
+ pinDataNodeNames,
684
+ });
685
+ if (workflowIssues !== null) {
686
+ throw new workflow_has_issues_error_1.WorkflowHasIssuesError();
687
+ }
688
+ }
689
+ setupExecution() {
690
+ this.status = 'running';
691
+ const { hooks } = this.additionalData;
692
+ assert.ok(hooks, 'Failed to run workflow due to missing execution lifecycle hooks');
693
+ if (this.runExecutionData.startData === undefined) {
694
+ this.runExecutionData.startData = {};
695
+ }
696
+ return { startedAt: new Date(), hooks };
697
+ }
698
+ handleEngineRequest({ workflow, currentNode, request, runIndex, executionData, runData, }) {
699
+ const { nodesToBeExecuted } = (0, requests_response_1.handleRequest)({
700
+ workflow,
701
+ currentNode,
702
+ request,
703
+ runIndex,
704
+ executionData,
705
+ runData,
706
+ });
707
+ for (const nodeData of nodesToBeExecuted) {
708
+ this.addNodeToBeExecuted(workflow, nodeData.inputConnectionData, nodeData.parentOutputIndex, nodeData.parentNode, nodeData.parentOutputData, nodeData.runIndex, nodeData.nodeRunIndex, nodeData.metadata);
709
+ }
710
+ }
711
+ processRunExecutionData(workflow) {
712
+ n8n_workflow_1.LoggerProxy.debug('Workflow execution started', { workflowId: workflow.id });
713
+ const { startedAt, hooks } = this.setupExecution();
714
+ this.checkForWorkflowIssues(workflow);
715
+ this.handleWaitingState(workflow);
716
+ let executionData;
717
+ let subNodeExecutionResults = (0, requests_response_1.makeEngineResponse)();
718
+ let executionError;
719
+ let executionNode;
720
+ let runIndex;
721
+ let currentExecutionTry = '';
722
+ let lastExecutionTry = '';
723
+ let closeFunction;
724
+ return new p_cancelable_1.default(async (resolve, _reject, onCancel) => {
725
+ (0, events_1.setMaxListeners)(Infinity, this.abortController.signal);
726
+ onCancel.shouldReject = false;
727
+ onCancel(() => {
728
+ this.status = 'canceled';
729
+ this.updateTaskStatusesToCancelled();
730
+ this.abortController.abort();
731
+ const fullRunData = this.getFullRunData(startedAt);
732
+ void hooks.runHook('workflowExecuteAfter', [fullRunData]);
733
+ });
734
+ const returnPromise = (async () => {
735
+ try {
736
+ await (0, execution_context_1.establishExecutionContext)(workflow, this.runExecutionData, this.additionalData, this.mode);
737
+ if (!this.additionalData.restartExecutionId) {
738
+ await hooks.runHook('workflowExecuteBefore', [workflow, this.runExecutionData]);
739
+ }
740
+ }
741
+ catch (error) {
742
+ const e = error;
743
+ executionError = {
744
+ ...e,
745
+ message: e.message,
746
+ stack: e.stack,
747
+ };
748
+ executionData = this.runExecutionData.executionData.nodeExecutionStack[0];
749
+ const taskData = {
750
+ startTime: Date.now(),
751
+ executionIndex: 0,
752
+ executionTime: 0,
753
+ data: {
754
+ main: executionData.data.main,
755
+ },
756
+ source: [],
757
+ executionStatus: 'error',
758
+ hints: [],
759
+ };
760
+ this.runExecutionData.resultData = {
761
+ runData: {
762
+ [executionData.node.name]: [taskData],
763
+ },
764
+ lastNodeExecuted: executionData.node.name,
765
+ error: executionError,
766
+ };
767
+ throw error;
768
+ }
769
+ executionLoop: while (this.runExecutionData.executionData.nodeExecutionStack.length !== 0) {
770
+ if (this.additionalData.executionTimeoutTimestamp !== undefined &&
771
+ Date.now() >= this.additionalData.executionTimeoutTimestamp) {
772
+ this.status = 'canceled';
773
+ this.timedOut = true;
774
+ }
775
+ if (this.status === 'canceled') {
776
+ return;
777
+ }
778
+ subNodeExecutionResults = (0, requests_response_1.makeEngineResponse)();
779
+ let nodeSuccessData = null;
780
+ executionError = undefined;
781
+ executionData =
782
+ this.runExecutionData.executionData.nodeExecutionStack.shift();
783
+ executionNode = executionData.node;
784
+ const taskStartedData = {
785
+ startTime: Date.now(),
786
+ executionIndex: this.additionalData.currentNodeExecutionIndex++,
787
+ source: !executionData.source ? [] : executionData.source.main,
788
+ hints: [],
789
+ };
790
+ const newTaskDataConnections = {};
791
+ for (const connectionType of Object.keys(executionData.data)) {
792
+ newTaskDataConnections[connectionType] = executionData.data[connectionType].map((input, inputIndex) => {
793
+ if (input === null) {
794
+ return input;
795
+ }
796
+ return input.map((item, itemIndex) => {
797
+ const isToolExecution = !!executionData.metadata?.preserveSourceOverwrite;
798
+ if (isToolExecution &&
799
+ typeof item.pairedItem === 'object' &&
800
+ 'sourceOverwrite' in item.pairedItem) {
801
+ return {
802
+ ...item,
803
+ pairedItem: {
804
+ item: itemIndex,
805
+ input: inputIndex || undefined,
806
+ sourceOverwrite: item.pairedItem.sourceOverwrite,
807
+ },
808
+ };
809
+ }
810
+ return {
811
+ ...item,
812
+ pairedItem: {
813
+ item: itemIndex,
814
+ input: inputIndex || undefined,
815
+ },
816
+ };
817
+ });
818
+ });
819
+ }
820
+ executionData.data = newTaskDataConnections;
821
+ runIndex = 0;
822
+ if (executionData.runIndex !== undefined) {
823
+ runIndex = executionData.runIndex;
824
+ }
825
+ else if (Object.hasOwn(this.runExecutionData.resultData.runData, executionNode.name)) {
826
+ runIndex = this.runExecutionData.resultData.runData[executionNode.name].length;
827
+ }
828
+ currentExecutionTry = `${executionNode.name}:${runIndex}`;
829
+ if (currentExecutionTry === lastExecutionTry) {
830
+ throw new n8n_workflow_1.ApplicationError('Stopped execution because it seems to be in an endless loop');
831
+ }
832
+ if (this.runExecutionData.startData.runNodeFilter !== undefined &&
833
+ this.runExecutionData.startData.runNodeFilter.indexOf(executionNode.name) === -1) {
834
+ continue;
835
+ }
836
+ const hasInputData = this.ensureInputData(workflow, executionNode, executionData);
837
+ if (!hasInputData) {
838
+ lastExecutionTry = currentExecutionTry;
839
+ continue executionLoop;
840
+ }
841
+ n8n_workflow_1.LoggerProxy.debug(`Start executing node "${executionNode.name}"`, {
842
+ node: executionNode.name,
843
+ workflowId: workflow.id,
844
+ });
845
+ if (!executionData.metadata?.nodeWasResumed) {
846
+ await hooks.runHook('nodeExecuteBefore', [executionNode.name, taskStartedData]);
847
+ }
848
+ let maxTries = 1;
849
+ if (executionData.node.retryOnFail === true) {
850
+ maxTries = Math.min(5, Math.max(2, executionData.node.maxTries || 3));
851
+ }
852
+ let waitBetweenTries = 0;
853
+ if (executionData.node.retryOnFail === true) {
854
+ waitBetweenTries = Math.min(5000, Math.max(0, executionData.node.waitBetweenTries || 1000));
855
+ }
856
+ for (let tryIndex = 0; tryIndex < maxTries; tryIndex++) {
857
+ try {
858
+ if (tryIndex !== 0) {
859
+ executionError = undefined;
860
+ if (waitBetweenTries !== 0) {
861
+ await new Promise((resolve) => {
862
+ setTimeout(() => {
863
+ resolve(undefined);
864
+ }, waitBetweenTries);
865
+ });
866
+ }
867
+ }
868
+ const { pinData } = this.runExecutionData.resultData;
869
+ if (pinData && !executionNode.disabled && pinData[executionNode.name] !== undefined) {
870
+ const nodePinData = pinData[executionNode.name];
871
+ nodeSuccessData = [nodePinData];
872
+ }
873
+ else {
874
+ if (executionData.metadata?.subNodeExecutionData) {
875
+ subNodeExecutionResults.metadata =
876
+ executionData.metadata.subNodeExecutionData.metadata;
877
+ for (const subNode of executionData.metadata.subNodeExecutionData.actions) {
878
+ const nodeRunData = this.runExecutionData.resultData.runData[subNode.nodeName];
879
+ if (nodeRunData && nodeRunData[subNode.runIndex]) {
880
+ const data = nodeRunData[subNode.runIndex];
881
+ subNodeExecutionResults.actionResponses.push({
882
+ data,
883
+ action: subNode.action,
884
+ });
885
+ }
886
+ }
887
+ }
888
+ n8n_workflow_1.LoggerProxy.debug(`Running node "${executionNode.name}" started`, {
889
+ node: executionNode.name,
890
+ workflowId: workflow.id,
891
+ });
892
+ let runNodeData = await this.runNode(workflow, executionData, this.runExecutionData, runIndex, this.additionalData, this.mode, this.abortController.signal, subNodeExecutionResults);
893
+ let nodeFailed = !(0, requests_response_1.isEngineRequest)(runNodeData) &&
894
+ runNodeData.data?.[0]?.[0]?.json?.error !== undefined;
895
+ while (nodeFailed && tryIndex !== maxTries - 1) {
896
+ await (0, n8n_workflow_1.sleep)(waitBetweenTries);
897
+ runNodeData = await this.runNode(workflow, executionData, this.runExecutionData, runIndex, this.additionalData, this.mode, this.abortController.signal);
898
+ nodeFailed =
899
+ !(0, requests_response_1.isEngineRequest)(runNodeData) &&
900
+ runNodeData.data?.[0]?.[0]?.json?.error !== undefined;
901
+ tryIndex++;
902
+ }
903
+ if ((0, requests_response_1.isEngineRequest)(runNodeData)) {
904
+ this.handleEngineRequest({
905
+ workflow,
906
+ currentNode: executionNode,
907
+ request: runNodeData,
908
+ runIndex,
909
+ executionData,
910
+ runData: this.runExecutionData.resultData.runData,
911
+ });
912
+ continue executionLoop;
913
+ }
914
+ nodeSuccessData = runNodeData.data;
915
+ if (runNodeData.hints?.length) {
916
+ taskStartedData.hints.push.apply(taskStartedData.hints, runNodeData.hints);
917
+ }
918
+ if (nodeSuccessData && executionData.node.onError === 'continueErrorOutput') {
919
+ this.handleNodeErrorOutput(workflow, executionData, nodeSuccessData, runIndex);
920
+ }
921
+ if (runNodeData.closeFunction) {
922
+ closeFunction = runNodeData.closeFunction();
923
+ }
924
+ }
925
+ n8n_workflow_1.LoggerProxy.debug(`Running node "${executionNode.name}" finished successfully`, {
926
+ node: executionNode.name,
927
+ workflowId: workflow.id,
928
+ });
929
+ nodeSuccessData = this.assignPairedItems(nodeSuccessData, executionData);
930
+ if (nodeSuccessData) {
931
+ this.runExecutionData.resultData.lastNodeExecuted = executionData.node.name;
932
+ }
933
+ if (!nodeSuccessData?.[0]?.[0]) {
934
+ if (executionData.node.alwaysOutputData === true) {
935
+ const pairedItem = [];
936
+ executionData.data.main.forEach((inputData, inputIndex) => {
937
+ if (!inputData) {
938
+ return;
939
+ }
940
+ inputData.forEach((_item, itemIndex) => {
941
+ pairedItem.push({
942
+ item: itemIndex,
943
+ input: inputIndex,
944
+ });
945
+ });
946
+ });
947
+ nodeSuccessData ??= [];
948
+ nodeSuccessData[0] = [
949
+ {
950
+ json: {},
951
+ pairedItem,
952
+ },
953
+ ];
954
+ }
955
+ }
956
+ if (nodeSuccessData === null && !this.runExecutionData.waitTill) {
957
+ continue executionLoop;
958
+ }
959
+ break;
960
+ }
961
+ catch (error) {
962
+ this.runExecutionData.resultData.lastNodeExecuted = executionData.node.name;
963
+ let toReport;
964
+ if (error instanceof n8n_workflow_1.ApplicationError) {
965
+ if (error.cause instanceof Error)
966
+ toReport = error.cause;
967
+ }
968
+ else {
969
+ toReport = error;
970
+ }
971
+ if (toReport) {
972
+ di_1.Container.get(error_reporter_1.ErrorReporter).error(toReport, {
973
+ extra: {
974
+ nodeName: executionNode.name,
975
+ nodeType: executionNode.type,
976
+ nodeVersion: executionNode.typeVersion,
977
+ workflowId: workflow.id,
978
+ },
979
+ });
980
+ }
981
+ const e = error;
982
+ executionError = { ...e, message: e.message, stack: e.stack };
983
+ n8n_workflow_1.LoggerProxy.debug(`Running node "${executionNode.name}" finished with error`, {
984
+ node: executionNode.name,
985
+ workflowId: workflow.id,
986
+ });
987
+ }
988
+ }
989
+ if (!Object.hasOwn(this.runExecutionData.resultData.runData, executionNode.name)) {
990
+ this.runExecutionData.resultData.runData[executionNode.name] = [];
991
+ }
992
+ const taskData = {
993
+ ...taskStartedData,
994
+ executionTime: Date.now() - taskStartedData.startTime,
995
+ metadata: executionData.metadata,
996
+ executionStatus: this.runExecutionData.waitTill ? 'waiting' : 'success',
997
+ };
998
+ if (executionError !== undefined) {
999
+ taskData.error = executionError;
1000
+ taskData.executionStatus = 'error';
1001
+ await hooks?.runHook('sendChunk', [
1002
+ {
1003
+ type: 'error',
1004
+ content: executionError.description,
1005
+ metadata: {
1006
+ nodeId: executionNode.id,
1007
+ nodeName: executionNode.name,
1008
+ runIndex,
1009
+ itemIndex: 0,
1010
+ },
1011
+ },
1012
+ ]);
1013
+ if (executionData.node.continueOnFail === true ||
1014
+ ['continueRegularOutput', 'continueErrorOutput'].includes(executionData.node.onError || '')) {
1015
+ if (Object.hasOwn(executionData.data, 'main') && executionData.data.main.length > 0) {
1016
+ if (executionData.data.main[0] !== null) {
1017
+ nodeSuccessData = [executionData.data.main[0]];
1018
+ }
1019
+ }
1020
+ }
1021
+ else {
1022
+ if (executionNode.rewireOutputLogTo) {
1023
+ taskData.inputOverride =
1024
+ this.runExecutionData.resultData.runData[executionNode.name][runIndex]
1025
+ ?.inputOverride || {};
1026
+ taskData.data = {
1027
+ [executionNode.rewireOutputLogTo]: [
1028
+ [{ json: { error: executionError.message } }],
1029
+ ],
1030
+ };
1031
+ }
1032
+ const errorRunDataExists = !!this.runExecutionData.resultData.runData[executionNode.name][runIndex];
1033
+ if (errorRunDataExists) {
1034
+ const currentTaskData = this.runExecutionData.resultData.runData[executionNode.name][runIndex];
1035
+ Object.assign(currentTaskData, taskData);
1036
+ }
1037
+ else {
1038
+ this.runExecutionData.resultData.runData[executionNode.name].push(taskData);
1039
+ }
1040
+ this.runExecutionData.executionData.nodeExecutionStack.unshift(executionData);
1041
+ if (!this.isCancelled) {
1042
+ await hooks.runHook('nodeExecuteAfter', [
1043
+ executionNode.name,
1044
+ taskData,
1045
+ this.runExecutionData,
1046
+ ]);
1047
+ }
1048
+ break;
1049
+ }
1050
+ }
1051
+ for (const execution of nodeSuccessData) {
1052
+ for (const lineResult of execution) {
1053
+ if (lineResult.json !== undefined &&
1054
+ lineResult.json.$error !== undefined &&
1055
+ lineResult.json.$json !== undefined) {
1056
+ lineResult.error = lineResult.json.$error;
1057
+ lineResult.json = {
1058
+ error: lineResult.json.$error.message,
1059
+ };
1060
+ }
1061
+ else if (lineResult.error !== undefined) {
1062
+ lineResult.json = { error: lineResult.error.message };
1063
+ }
1064
+ }
1065
+ }
1066
+ taskData.data = {
1067
+ main: nodeSuccessData,
1068
+ };
1069
+ if (executionNode.rewireOutputLogTo) {
1070
+ taskData.inputOverride =
1071
+ this.runExecutionData.resultData.runData[executionNode.name][runIndex]
1072
+ ?.inputOverride || {};
1073
+ taskData.data = {
1074
+ [executionNode.rewireOutputLogTo]: nodeSuccessData,
1075
+ };
1076
+ }
1077
+ const runDataAlreadyExists = !!this.runExecutionData.resultData.runData[executionNode.name][runIndex];
1078
+ if (runDataAlreadyExists) {
1079
+ const currentTaskData = this.runExecutionData.resultData.runData[executionNode.name][runIndex];
1080
+ Object.assign(currentTaskData, taskData);
1081
+ }
1082
+ else {
1083
+ this.runExecutionData.resultData.runData[executionNode.name].push(taskData);
1084
+ }
1085
+ if (this.runExecutionData.waitTill) {
1086
+ await hooks.runHook('nodeExecuteAfter', [
1087
+ executionNode.name,
1088
+ taskData,
1089
+ this.runExecutionData,
1090
+ ]);
1091
+ this.runExecutionData.executionData.nodeExecutionStack.unshift(executionData);
1092
+ break;
1093
+ }
1094
+ if (this.runExecutionData?.startData?.destinationNode?.nodeName === executionNode.name) {
1095
+ await hooks.runHook('nodeExecuteAfter', [
1096
+ executionNode.name,
1097
+ taskData,
1098
+ this.runExecutionData,
1099
+ ]);
1100
+ continue;
1101
+ }
1102
+ if (Object.hasOwn(workflow.connectionsBySourceNode, executionNode.name)) {
1103
+ if (Object.hasOwn(workflow.connectionsBySourceNode[executionNode.name], 'main')) {
1104
+ let outputIndex;
1105
+ let connectionData;
1106
+ const nodesToAdd = [];
1107
+ for (outputIndex in workflow.connectionsBySourceNode[executionNode.name].main) {
1108
+ if (!Object.hasOwn(workflow.connectionsBySourceNode[executionNode.name].main, outputIndex)) {
1109
+ continue;
1110
+ }
1111
+ for (connectionData of workflow.connectionsBySourceNode[executionNode.name].main[outputIndex] ?? []) {
1112
+ if (!Object.hasOwn(workflow.nodes, connectionData.node)) {
1113
+ throw new n8n_workflow_1.ApplicationError('Destination node not found', {
1114
+ extra: {
1115
+ sourceNodeName: executionNode.name,
1116
+ destinationNodeName: connectionData.node,
1117
+ },
1118
+ });
1119
+ }
1120
+ if (nodeSuccessData[outputIndex] &&
1121
+ (nodeSuccessData[outputIndex].length !== 0 ||
1122
+ (connectionData.index > 0 && this.isLegacyExecutionOrder(workflow)))) {
1123
+ if (workflow.settings.executionOrder === 'v1') {
1124
+ const nodeToAdd = workflow.getNode(connectionData.node);
1125
+ nodesToAdd.push({
1126
+ position: nodeToAdd?.position || [0, 0],
1127
+ connection: connectionData,
1128
+ outputIndex: parseInt(outputIndex, 10),
1129
+ });
1130
+ }
1131
+ else {
1132
+ this.addNodeToBeExecuted(workflow, connectionData, parseInt(outputIndex, 10), executionNode.name, nodeSuccessData, runIndex);
1133
+ }
1134
+ }
1135
+ }
1136
+ }
1137
+ if (workflow.settings.executionOrder === 'v1') {
1138
+ nodesToAdd.sort((a, b) => {
1139
+ if (a.position[1] < b.position[1]) {
1140
+ return 1;
1141
+ }
1142
+ if (a.position[1] > b.position[1]) {
1143
+ return -1;
1144
+ }
1145
+ if (a.position[0] > b.position[0]) {
1146
+ return -1;
1147
+ }
1148
+ return 0;
1149
+ });
1150
+ for (const nodeData of nodesToAdd) {
1151
+ this.addNodeToBeExecuted(workflow, nodeData.connection, nodeData.outputIndex, executionNode.name, nodeSuccessData, runIndex);
1152
+ }
1153
+ }
1154
+ }
1155
+ }
1156
+ await hooks.runHook('nodeExecuteAfter', [
1157
+ executionNode.name,
1158
+ taskData,
1159
+ this.runExecutionData,
1160
+ ]);
1161
+ let waitingNodes = Object.keys(this.runExecutionData.executionData.waitingExecution);
1162
+ if (this.runExecutionData.executionData.nodeExecutionStack.length === 0 &&
1163
+ waitingNodes.length) {
1164
+ for (let i = 0; i < waitingNodes.length; i++) {
1165
+ const nodeName = waitingNodes[i];
1166
+ const checkNode = workflow.getNode(nodeName);
1167
+ if (!checkNode) {
1168
+ continue;
1169
+ }
1170
+ const nodeType = workflow.nodeTypes.getByNameAndVersion(checkNode.type, checkNode.typeVersion);
1171
+ let requiredInputs = workflow.settings.executionOrder === 'v1'
1172
+ ? nodeType.description.requiredInputs
1173
+ : undefined;
1174
+ if (requiredInputs !== undefined) {
1175
+ if (typeof requiredInputs === 'string') {
1176
+ requiredInputs = workflow.expression.getSimpleParameterValue(checkNode, requiredInputs, this.mode, { $version: checkNode.typeVersion }, undefined, []);
1177
+ }
1178
+ if ((requiredInputs !== undefined &&
1179
+ Array.isArray(requiredInputs) &&
1180
+ requiredInputs.length === nodeType.description.inputs.length) ||
1181
+ requiredInputs === nodeType.description.inputs.length) {
1182
+ continue;
1183
+ }
1184
+ }
1185
+ const parentNodes = workflow.getParentNodes(nodeName);
1186
+ const parentIsWaiting = parentNodes.some((value) => waitingNodes.includes(value));
1187
+ if (parentIsWaiting) {
1188
+ continue;
1189
+ }
1190
+ const runIndexes = Object.keys(this.runExecutionData.executionData.waitingExecution[nodeName]).sort();
1191
+ const firstRunIndex = parseInt(runIndexes[0]);
1192
+ const inputsWithData = this.runExecutionData
1193
+ .executionData.waitingExecution[nodeName][firstRunIndex].main.map((data, index) => data === null ? null : index)
1194
+ .filter((data) => data !== null);
1195
+ if (requiredInputs !== undefined) {
1196
+ if (Array.isArray(requiredInputs)) {
1197
+ let inputDataMissing = false;
1198
+ for (const requiredInput of requiredInputs) {
1199
+ if (!inputsWithData.includes(requiredInput)) {
1200
+ inputDataMissing = true;
1201
+ break;
1202
+ }
1203
+ }
1204
+ if (inputDataMissing) {
1205
+ continue;
1206
+ }
1207
+ }
1208
+ else {
1209
+ if (inputsWithData.length < requiredInputs) {
1210
+ continue;
1211
+ }
1212
+ }
1213
+ }
1214
+ const taskDataMain = this.runExecutionData.executionData.waitingExecution[nodeName][firstRunIndex].main.map((data) => {
1215
+ return data === null ? [] : data;
1216
+ });
1217
+ if (taskDataMain.filter((data) => data.length).length !== 0) {
1218
+ if (taskDataMain.length < nodeType.description.inputs.length) {
1219
+ for (; taskDataMain.length < nodeType.description.inputs.length;) {
1220
+ taskDataMain.push([]);
1221
+ }
1222
+ }
1223
+ this.runExecutionData.executionData.nodeExecutionStack.push({
1224
+ node: workflow.nodes[nodeName],
1225
+ data: {
1226
+ main: taskDataMain,
1227
+ },
1228
+ source: this.runExecutionData.executionData.waitingExecutionSource[nodeName][firstRunIndex],
1229
+ });
1230
+ }
1231
+ delete this.runExecutionData.executionData.waitingExecution[nodeName][firstRunIndex];
1232
+ delete this.runExecutionData.executionData.waitingExecutionSource[nodeName][firstRunIndex];
1233
+ if (Object.keys(this.runExecutionData.executionData.waitingExecution[nodeName])
1234
+ .length === 0) {
1235
+ delete this.runExecutionData.executionData.waitingExecution[nodeName];
1236
+ delete this.runExecutionData.executionData.waitingExecutionSource[nodeName];
1237
+ }
1238
+ if (taskDataMain.filter((data) => data.length).length !== 0) {
1239
+ break;
1240
+ }
1241
+ else {
1242
+ waitingNodes = Object.keys(this.runExecutionData.executionData.waitingExecution);
1243
+ i = -1;
1244
+ }
1245
+ }
1246
+ }
1247
+ }
1248
+ return;
1249
+ })()
1250
+ .then(async () => {
1251
+ if (this.status === 'canceled' && executionError === undefined) {
1252
+ return await this.processSuccessExecution(startedAt, workflow, this.timedOut
1253
+ ? new n8n_workflow_1.TimeoutExecutionCancelledError(this.additionalData.executionId ?? 'unknown')
1254
+ : new n8n_workflow_1.ManualExecutionCancelledError(this.additionalData.executionId ?? 'unknown'), closeFunction);
1255
+ }
1256
+ return await this.processSuccessExecution(startedAt, workflow, executionError, closeFunction);
1257
+ })
1258
+ .catch(async (error) => {
1259
+ const fullRunData = this.getFullRunData(startedAt);
1260
+ fullRunData.data.resultData.error = {
1261
+ ...error,
1262
+ message: error.message,
1263
+ stack: error.stack,
1264
+ };
1265
+ let newStaticData;
1266
+ if (workflow.staticData.__dataChanged === true) {
1267
+ newStaticData = workflow.staticData;
1268
+ }
1269
+ this.moveNodeMetadata();
1270
+ await hooks
1271
+ .runHook('workflowExecuteAfter', [fullRunData, newStaticData])
1272
+ .catch((error) => {
1273
+ console.error('There was a problem running hook "workflowExecuteAfter"', error);
1274
+ });
1275
+ if (closeFunction) {
1276
+ try {
1277
+ await closeFunction;
1278
+ }
1279
+ catch (errorClose) {
1280
+ n8n_workflow_1.LoggerProxy.error(`There was a problem deactivating trigger of workflow "${workflow.id}": "${errorClose.message}"`, {
1281
+ workflowId: workflow.id,
1282
+ });
1283
+ }
1284
+ }
1285
+ return fullRunData;
1286
+ });
1287
+ return await returnPromise.then(resolve);
1288
+ });
1289
+ }
1290
+ ensureInputData(workflow, executionNode, executionData) {
1291
+ const inputConnections = workflow.connectionsByDestinationNode[executionNode.name]?.main ?? [];
1292
+ for (let connectionIndex = 0; connectionIndex < inputConnections.length; connectionIndex++) {
1293
+ const highestNodes = workflow.getHighestNode(executionNode.name, connectionIndex);
1294
+ if (highestNodes.length === 0) {
1295
+ return true;
1296
+ }
1297
+ if (!Object.hasOwn(executionData.data, 'main')) {
1298
+ this.runExecutionData.executionData.nodeExecutionStack.push(executionData);
1299
+ return false;
1300
+ }
1301
+ if (this.isLegacyExecutionOrder(workflow)) {
1302
+ if (executionData.data.main.length < connectionIndex ||
1303
+ executionData.data.main[connectionIndex] === null) {
1304
+ this.runExecutionData.executionData.nodeExecutionStack.push(executionData);
1305
+ return false;
1306
+ }
1307
+ }
1308
+ }
1309
+ return true;
1310
+ }
1311
+ async processSuccessExecution(startedAt, workflow, executionError, closeFunction) {
1312
+ if (executionError !== undefined) {
1313
+ n8n_workflow_1.LoggerProxy.debug('Workflow execution finished with error', {
1314
+ error: executionError,
1315
+ workflowId: workflow.id,
1316
+ });
1317
+ if (executionError.message?.includes('canceled') ||
1318
+ executionError.name?.includes('Cancelled')) {
1319
+ this.status = 'canceled';
1320
+ }
1321
+ else {
1322
+ this.status = 'error';
1323
+ }
1324
+ }
1325
+ else if (this.runExecutionData.waitTill) {
1326
+ n8n_workflow_1.LoggerProxy.debug(`Workflow execution will wait until ${this.runExecutionData.waitTill}`, {
1327
+ workflowId: workflow.id,
1328
+ });
1329
+ this.status = 'waiting';
1330
+ }
1331
+ else {
1332
+ n8n_workflow_1.LoggerProxy.debug('Workflow execution finished successfully', { workflowId: workflow.id });
1333
+ this.status = 'success';
1334
+ }
1335
+ let newStaticData;
1336
+ if (workflow.staticData.__dataChanged === true) {
1337
+ newStaticData = workflow.staticData;
1338
+ }
1339
+ this.moveNodeMetadata();
1340
+ if (closeFunction) {
1341
+ try {
1342
+ await closeFunction;
1343
+ }
1344
+ catch (error) {
1345
+ n8n_workflow_1.LoggerProxy.error(`There was a problem deactivating trigger of workflow "${workflow.id}": "${error.message}"`, {
1346
+ workflowId: workflow.id,
1347
+ });
1348
+ }
1349
+ }
1350
+ const stoppedAt = new Date();
1351
+ const fullRunData = this.getFullRunData(startedAt, stoppedAt);
1352
+ if (executionError !== undefined) {
1353
+ fullRunData.data.resultData.error = {
1354
+ ...executionError,
1355
+ message: executionError.message,
1356
+ stack: executionError.stack,
1357
+ };
1358
+ }
1359
+ else if (this.runExecutionData.waitTill) {
1360
+ fullRunData.waitTill = this.runExecutionData.waitTill;
1361
+ }
1362
+ else {
1363
+ fullRunData.finished = true;
1364
+ }
1365
+ if (!this.isCancelled) {
1366
+ await this.additionalData.hooks?.runHook('workflowExecuteAfter', [
1367
+ fullRunData,
1368
+ newStaticData,
1369
+ ]);
1370
+ }
1371
+ return fullRunData;
1372
+ }
1373
+ getFullRunData(startedAt, stoppedAt) {
1374
+ return {
1375
+ data: this.runExecutionData,
1376
+ mode: this.mode,
1377
+ startedAt,
1378
+ stoppedAt: stoppedAt ?? new Date(),
1379
+ status: this.status,
1380
+ };
1381
+ }
1382
+ handleNodeErrorOutput(workflow, executionData, nodeSuccessData, runIndex) {
1383
+ const nodeType = workflow.nodeTypes.getByNameAndVersion(executionData.node.type, executionData.node.typeVersion);
1384
+ const outputs = n8n_workflow_1.NodeHelpers.getNodeOutputs(workflow, executionData.node, nodeType.description);
1385
+ const outputTypes = n8n_workflow_1.NodeHelpers.getConnectionTypes(outputs);
1386
+ const mainOutputTypes = outputTypes.filter((output) => output === n8n_workflow_1.NodeConnectionTypes.Main);
1387
+ const errorItems = [];
1388
+ const closeFunctions = [];
1389
+ const executeFunctions = new node_execution_context_1.ExecuteContext(workflow, executionData.node, this.additionalData, this.mode, this.runExecutionData, runIndex, [], executionData.data, executionData, closeFunctions, this.abortController.signal);
1390
+ const dataProxy = executeFunctions.getWorkflowDataProxy(0);
1391
+ for (let outputIndex = 0; outputIndex < mainOutputTypes.length - 1; outputIndex++) {
1392
+ const successItems = [];
1393
+ const items = nodeSuccessData[outputIndex]?.length ? nodeSuccessData[outputIndex] : [];
1394
+ while (items.length) {
1395
+ const item = items.shift();
1396
+ if (item === undefined) {
1397
+ continue;
1398
+ }
1399
+ let errorData;
1400
+ if (item.error) {
1401
+ errorData = item.error;
1402
+ }
1403
+ else if (item.json.error && Object.keys(item.json).length === 1) {
1404
+ errorData = item.json.error;
1405
+ }
1406
+ else if (item.json.error && item.json.message && Object.keys(item.json).length === 2) {
1407
+ errorData = item.json.error;
1408
+ }
1409
+ if (errorData) {
1410
+ const pairedItemData = item.pairedItem && typeof item.pairedItem === 'object'
1411
+ ? Array.isArray(item.pairedItem)
1412
+ ? item.pairedItem[0]
1413
+ : item.pairedItem
1414
+ : undefined;
1415
+ if (executionData.source === null || pairedItemData === undefined) {
1416
+ errorItems.push(item);
1417
+ }
1418
+ else {
1419
+ const pairedItemInputIndex = pairedItemData.input || 0;
1420
+ const sourceData = executionData.source[n8n_workflow_1.NodeConnectionTypes.Main][pairedItemInputIndex];
1421
+ const constPairedItem = dataProxy.$getPairedItem(sourceData.previousNode, sourceData, pairedItemData);
1422
+ if (constPairedItem === null) {
1423
+ errorItems.push(item);
1424
+ }
1425
+ else {
1426
+ errorItems.push({
1427
+ ...item,
1428
+ json: {
1429
+ ...constPairedItem.json,
1430
+ ...item.json,
1431
+ },
1432
+ });
1433
+ }
1434
+ }
1435
+ }
1436
+ else {
1437
+ successItems.push(item);
1438
+ }
1439
+ }
1440
+ nodeSuccessData[outputIndex] = successItems;
1441
+ }
1442
+ nodeSuccessData[mainOutputTypes.length - 1] = errorItems;
1443
+ }
1444
+ assignPairedItems(nodeSuccessData, executionData) {
1445
+ if (nodeSuccessData?.length) {
1446
+ const isSingleInputAndOutput = executionData.data.main.length === 1 && executionData.data.main[0]?.length === 1;
1447
+ const isSameNumberOfItems = nodeSuccessData.length === 1 &&
1448
+ executionData.data.main.length === 1 &&
1449
+ executionData.data.main[0]?.length === nodeSuccessData[0].length;
1450
+ checkOutputData: for (const outputData of nodeSuccessData) {
1451
+ if (outputData === null) {
1452
+ continue;
1453
+ }
1454
+ for (const [index, item] of outputData.entries()) {
1455
+ if (item.pairedItem === undefined) {
1456
+ if (isSingleInputAndOutput) {
1457
+ item.pairedItem = {
1458
+ item: 0,
1459
+ };
1460
+ }
1461
+ else if (isSameNumberOfItems) {
1462
+ item.pairedItem = {
1463
+ item: index,
1464
+ };
1465
+ }
1466
+ else {
1467
+ break checkOutputData;
1468
+ }
1469
+ }
1470
+ }
1471
+ }
1472
+ }
1473
+ return nodeSuccessData ?? null;
1474
+ }
1475
+ updateTaskStatusesToCancelled() {
1476
+ Object.keys(this.runExecutionData.resultData.runData).forEach((nodeName) => {
1477
+ const taskDataArray = this.runExecutionData.resultData.runData[nodeName];
1478
+ taskDataArray.forEach((taskData) => {
1479
+ if (taskData.executionStatus === 'running') {
1480
+ taskData.executionStatus = 'canceled';
1481
+ }
1482
+ });
1483
+ });
1484
+ }
1485
+ get isCancelled() {
1486
+ return this.abortController.signal.aborted;
1487
+ }
1488
+ }
1489
+ exports.WorkflowExecute = WorkflowExecute;
1490
+ //# sourceMappingURL=workflow-execute.js.map