n8n-workflow 2.31.3 → 2.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (406) hide show
  1. package/dist/cjs/augment-object.js +136 -146
  2. package/dist/cjs/augment-object.js.map +1 -1
  3. package/dist/cjs/build.tsbuildinfo +1 -1
  4. package/dist/cjs/common/find-ai-root-node-names.js +36 -46
  5. package/dist/cjs/common/find-ai-root-node-names.js.map +1 -1
  6. package/dist/cjs/common/get-child-nodes.js +8 -18
  7. package/dist/cjs/common/get-child-nodes.js.map +1 -1
  8. package/dist/cjs/common/get-connected-nodes.js +84 -94
  9. package/dist/cjs/common/get-connected-nodes.js.map +1 -1
  10. package/dist/cjs/common/get-node-by-name.js +16 -26
  11. package/dist/cjs/common/get-node-by-name.js.map +1 -1
  12. package/dist/cjs/common/get-parent-nodes.js +14 -24
  13. package/dist/cjs/common/get-parent-nodes.js.map +1 -1
  14. package/dist/cjs/common/index.js +9 -19
  15. package/dist/cjs/common/index.js.map +1 -1
  16. package/dist/cjs/common/map-connections-by-destination.js +31 -41
  17. package/dist/cjs/common/map-connections-by-destination.js.map +1 -1
  18. package/dist/cjs/common/resolve-variables.d.ts +8 -0
  19. package/dist/cjs/common/resolve-variables.d.ts.map +1 -1
  20. package/dist/cjs/common/resolve-variables.js +46 -33
  21. package/dist/cjs/common/resolve-variables.js.map +1 -1
  22. package/dist/cjs/connections-diff.js +58 -68
  23. package/dist/cjs/connections-diff.js.map +1 -1
  24. package/dist/cjs/constants.d.ts +3 -3
  25. package/dist/cjs/constants.d.ts.map +1 -1
  26. package/dist/cjs/constants.js +157 -166
  27. package/dist/cjs/constants.js.map +1 -1
  28. package/dist/cjs/credential-domain-restrictions.js +153 -163
  29. package/dist/cjs/credential-domain-restrictions.js.map +1 -1
  30. package/dist/cjs/cron.d.ts.map +1 -1
  31. package/dist/cjs/cron.js +25 -35
  32. package/dist/cjs/cron.js.map +1 -1
  33. package/dist/cjs/data-table.types.js +10 -20
  34. package/dist/cjs/data-table.types.js.map +1 -1
  35. package/dist/cjs/dynamic-credentials-helpers.js +93 -103
  36. package/dist/cjs/dynamic-credentials-helpers.js.map +1 -1
  37. package/dist/cjs/errors/abstract/execution-base.error.d.ts.map +1 -1
  38. package/dist/cjs/errors/abstract/execution-base.error.js +41 -51
  39. package/dist/cjs/errors/abstract/execution-base.error.js.map +1 -1
  40. package/dist/cjs/errors/abstract/node.error.d.ts.map +1 -1
  41. package/dist/cjs/errors/abstract/node.error.js +142 -152
  42. package/dist/cjs/errors/abstract/node.error.js.map +1 -1
  43. package/dist/cjs/errors/base/base.error.d.ts.map +1 -1
  44. package/dist/cjs/errors/base/base.error.js +35 -45
  45. package/dist/cjs/errors/base/base.error.js.map +1 -1
  46. package/dist/cjs/errors/base/operational.error.d.ts.map +1 -1
  47. package/dist/cjs/errors/base/operational.error.js +17 -27
  48. package/dist/cjs/errors/base/operational.error.js.map +1 -1
  49. package/dist/cjs/errors/base/unexpected.error.d.ts.map +1 -1
  50. package/dist/cjs/errors/base/unexpected.error.js +17 -27
  51. package/dist/cjs/errors/base/unexpected.error.js.map +1 -1
  52. package/dist/cjs/errors/base/user.error.d.ts.map +1 -1
  53. package/dist/cjs/errors/base/user.error.js +17 -27
  54. package/dist/cjs/errors/base/user.error.js.map +1 -1
  55. package/dist/cjs/errors/cli-subworkflow-operation.error.js +7 -17
  56. package/dist/cjs/errors/cli-subworkflow-operation.error.js.map +1 -1
  57. package/dist/cjs/errors/db-connection-timeout-error.d.ts.map +1 -1
  58. package/dist/cjs/errors/db-connection-timeout-error.js +11 -21
  59. package/dist/cjs/errors/db-connection-timeout-error.js.map +1 -1
  60. package/dist/cjs/errors/execution-cancelled.error.d.ts.map +1 -1
  61. package/dist/cjs/errors/execution-cancelled.error.js +33 -43
  62. package/dist/cjs/errors/execution-cancelled.error.js.map +1 -1
  63. package/dist/cjs/errors/expression-class-extension.error.d.ts.map +1 -1
  64. package/dist/cjs/errors/expression-class-extension.error.js +9 -19
  65. package/dist/cjs/errors/expression-class-extension.error.js.map +1 -1
  66. package/dist/cjs/errors/expression-computed-destructuring.error.d.ts.map +1 -1
  67. package/dist/cjs/errors/expression-computed-destructuring.error.js +9 -19
  68. package/dist/cjs/errors/expression-computed-destructuring.error.js.map +1 -1
  69. package/dist/cjs/errors/expression-destructuring.error.d.ts.map +1 -1
  70. package/dist/cjs/errors/expression-destructuring.error.js +9 -19
  71. package/dist/cjs/errors/expression-destructuring.error.js.map +1 -1
  72. package/dist/cjs/errors/expression-extension.error.js +7 -17
  73. package/dist/cjs/errors/expression-extension.error.js.map +1 -1
  74. package/dist/cjs/errors/expression-reserved-variable.error.d.ts.map +1 -1
  75. package/dist/cjs/errors/expression-reserved-variable.error.js +9 -19
  76. package/dist/cjs/errors/expression-reserved-variable.error.js.map +1 -1
  77. package/dist/cjs/errors/expression-with-statement.error.d.ts.map +1 -1
  78. package/dist/cjs/errors/expression-with-statement.error.js +9 -19
  79. package/dist/cjs/errors/expression-with-statement.error.js.map +1 -1
  80. package/dist/cjs/errors/expression.error.d.ts.map +1 -1
  81. package/dist/cjs/errors/expression.error.js +33 -43
  82. package/dist/cjs/errors/expression.error.js.map +1 -1
  83. package/dist/cjs/errors/index.js +62 -72
  84. package/dist/cjs/errors/index.js.map +1 -1
  85. package/dist/cjs/errors/node-api.error.d.ts.map +1 -1
  86. package/dist/cjs/errors/node-api.error.js +227 -237
  87. package/dist/cjs/errors/node-api.error.js.map +1 -1
  88. package/dist/cjs/errors/node-operation.error.d.ts.map +1 -1
  89. package/dist/cjs/errors/node-operation.error.js +43 -53
  90. package/dist/cjs/errors/node-operation.error.js.map +1 -1
  91. package/dist/cjs/errors/node-ssl.error.d.ts.map +1 -1
  92. package/dist/cjs/errors/node-ssl.error.js +9 -19
  93. package/dist/cjs/errors/node-ssl.error.js.map +1 -1
  94. package/dist/cjs/errors/subworkflow-operation.error.d.ts.map +1 -1
  95. package/dist/cjs/errors/subworkflow-operation.error.js +18 -28
  96. package/dist/cjs/errors/subworkflow-operation.error.js.map +1 -1
  97. package/dist/cjs/errors/trigger-close.error.d.ts.map +1 -1
  98. package/dist/cjs/errors/trigger-close.error.js +11 -21
  99. package/dist/cjs/errors/trigger-close.error.js.map +1 -1
  100. package/dist/cjs/errors/webhook-taken.error.d.ts.map +1 -1
  101. package/dist/cjs/errors/webhook-taken.error.js +9 -19
  102. package/dist/cjs/errors/webhook-taken.error.js.map +1 -1
  103. package/dist/cjs/errors/workflow-activation.error.d.ts.map +1 -1
  104. package/dist/cjs/errors/workflow-activation.error.js +54 -64
  105. package/dist/cjs/errors/workflow-activation.error.js.map +1 -1
  106. package/dist/cjs/errors/workflow-configuration.error.js +10 -20
  107. package/dist/cjs/errors/workflow-configuration.error.js.map +1 -1
  108. package/dist/cjs/errors/workflow-deactivation.error.js +7 -17
  109. package/dist/cjs/errors/workflow-deactivation.error.js.map +1 -1
  110. package/dist/cjs/errors/workflow-operation.error.d.ts.map +1 -1
  111. package/dist/cjs/errors/workflow-operation.error.js +20 -30
  112. package/dist/cjs/errors/workflow-operation.error.js.map +1 -1
  113. package/dist/cjs/evaluation-helpers.js +16 -26
  114. package/dist/cjs/evaluation-helpers.js.map +1 -1
  115. package/dist/cjs/execution-context-establishment-hooks.d.ts.map +1 -1
  116. package/dist/cjs/execution-context-establishment-hooks.js +43 -53
  117. package/dist/cjs/execution-context-establishment-hooks.js.map +1 -1
  118. package/dist/cjs/execution-context.d.ts +14 -14
  119. package/dist/cjs/execution-context.d.ts.map +1 -1
  120. package/dist/cjs/execution-context.js +203 -213
  121. package/dist/cjs/execution-context.js.map +1 -1
  122. package/dist/cjs/execution-status.d.ts +2 -2
  123. package/dist/cjs/execution-status.d.ts.map +1 -1
  124. package/dist/cjs/execution-status.js +27 -37
  125. package/dist/cjs/execution-status.js.map +1 -1
  126. package/dist/cjs/expression-evaluator-proxy.d.ts.map +1 -1
  127. package/dist/cjs/expression-evaluator-proxy.js +18 -28
  128. package/dist/cjs/expression-evaluator-proxy.js.map +1 -1
  129. package/dist/cjs/expression-sandboxing.d.ts.map +1 -1
  130. package/dist/cjs/expression-sandboxing.js +447 -457
  131. package/dist/cjs/expression-sandboxing.js.map +1 -1
  132. package/dist/cjs/expression.d.ts.map +1 -1
  133. package/dist/cjs/expression.js +535 -546
  134. package/dist/cjs/expression.js.map +1 -1
  135. package/dist/cjs/expressions/expression-helpers.d.ts.map +1 -1
  136. package/dist/cjs/expressions/expression-helpers.js +13 -23
  137. package/dist/cjs/expressions/expression-helpers.js.map +1 -1
  138. package/dist/cjs/extensions/array-extensions.js +591 -601
  139. package/dist/cjs/extensions/array-extensions.js.map +1 -1
  140. package/dist/cjs/extensions/boolean-extensions.d.ts +1 -1
  141. package/dist/cjs/extensions/boolean-extensions.js +38 -48
  142. package/dist/cjs/extensions/boolean-extensions.js.map +1 -1
  143. package/dist/cjs/extensions/date-extensions.js +507 -517
  144. package/dist/cjs/extensions/date-extensions.js.map +1 -1
  145. package/dist/cjs/extensions/expression-extension.d.ts.map +1 -1
  146. package/dist/cjs/extensions/expression-extension.js +455 -465
  147. package/dist/cjs/extensions/expression-extension.js.map +1 -1
  148. package/dist/cjs/extensions/expression-parser.d.ts.map +1 -1
  149. package/dist/cjs/extensions/expression-parser.js +82 -92
  150. package/dist/cjs/extensions/expression-parser.js.map +1 -1
  151. package/dist/cjs/extensions/extended-functions.d.ts +10 -18
  152. package/dist/cjs/extensions/extended-functions.d.ts.map +1 -1
  153. package/dist/cjs/extensions/extended-functions.js +80 -90
  154. package/dist/cjs/extensions/extended-functions.js.map +1 -1
  155. package/dist/cjs/extensions/extensions.js +2 -12
  156. package/dist/cjs/extensions/index.js +10 -20
  157. package/dist/cjs/extensions/index.js.map +1 -1
  158. package/dist/cjs/extensions/number-extensions.js +226 -236
  159. package/dist/cjs/extensions/number-extensions.js.map +1 -1
  160. package/dist/cjs/extensions/object-extensions.js +274 -284
  161. package/dist/cjs/extensions/object-extensions.js.map +1 -1
  162. package/dist/cjs/extensions/string-extensions.d.ts +1 -1
  163. package/dist/cjs/extensions/string-extensions.d.ts.map +1 -1
  164. package/dist/cjs/extensions/string-extensions.js +769 -779
  165. package/dist/cjs/extensions/string-extensions.js.map +1 -1
  166. package/dist/cjs/extensions/utils.d.ts.map +1 -1
  167. package/dist/cjs/extensions/utils.js +35 -45
  168. package/dist/cjs/extensions/utils.js.map +1 -1
  169. package/dist/cjs/from-ai-parse-utils.js +393 -403
  170. package/dist/cjs/from-ai-parse-utils.js.map +1 -1
  171. package/dist/cjs/global-state.js +12 -22
  172. package/dist/cjs/global-state.js.map +1 -1
  173. package/dist/cjs/graph/graph-utils.js +166 -176
  174. package/dist/cjs/graph/graph-utils.js.map +1 -1
  175. package/dist/cjs/highlighted-data.js +13 -23
  176. package/dist/cjs/highlighted-data.js.map +1 -1
  177. package/dist/cjs/index.js +105 -115
  178. package/dist/cjs/index.js.map +1 -1
  179. package/dist/cjs/interfaces.d.ts +112 -22
  180. package/dist/cjs/interfaces.d.ts.map +1 -1
  181. package/dist/cjs/interfaces.js +62 -72
  182. package/dist/cjs/interfaces.js.map +1 -1
  183. package/dist/cjs/jmespath-query.js +26 -36
  184. package/dist/cjs/jmespath-query.js.map +1 -1
  185. package/dist/cjs/logger-proxy.d.ts.map +1 -1
  186. package/dist/cjs/logger-proxy.js +15 -25
  187. package/dist/cjs/logger-proxy.js.map +1 -1
  188. package/dist/cjs/mcp-helpers.js +10 -20
  189. package/dist/cjs/mcp-helpers.js.map +1 -1
  190. package/dist/cjs/message-event-bus.d.ts +184 -165
  191. package/dist/cjs/message-event-bus.d.ts.map +1 -1
  192. package/dist/cjs/message-event-bus.js +207 -217
  193. package/dist/cjs/message-event-bus.js.map +1 -1
  194. package/dist/cjs/metadata-utils.js +35 -45
  195. package/dist/cjs/metadata-utils.js.map +1 -1
  196. package/dist/cjs/native-methods/array.methods.js +527 -537
  197. package/dist/cjs/native-methods/array.methods.js.map +1 -1
  198. package/dist/cjs/native-methods/boolean.methods.js +18 -28
  199. package/dist/cjs/native-methods/boolean.methods.js.map +1 -1
  200. package/dist/cjs/native-methods/index.js +16 -26
  201. package/dist/cjs/native-methods/index.js.map +1 -1
  202. package/dist/cjs/native-methods/number.methods.js +79 -89
  203. package/dist/cjs/native-methods/number.methods.js.map +1 -1
  204. package/dist/cjs/native-methods/object.methods.js +7 -17
  205. package/dist/cjs/native-methods/object.methods.js.map +1 -1
  206. package/dist/cjs/native-methods/string.methods.js +474 -484
  207. package/dist/cjs/native-methods/string.methods.js.map +1 -1
  208. package/dist/cjs/node-grouping-validation.d.ts +6 -0
  209. package/dist/cjs/node-grouping-validation.d.ts.map +1 -1
  210. package/dist/cjs/node-grouping-validation.js +165 -144
  211. package/dist/cjs/node-grouping-validation.js.map +1 -1
  212. package/dist/cjs/node-helpers.d.ts.map +1 -1
  213. package/dist/cjs/node-helpers.js +1486 -1493
  214. package/dist/cjs/node-helpers.js.map +1 -1
  215. package/dist/cjs/node-parameters/filter-parameter.d.ts.map +1 -1
  216. package/dist/cjs/node-parameters/filter-parameter.js +315 -325
  217. package/dist/cjs/node-parameters/filter-parameter.js.map +1 -1
  218. package/dist/cjs/node-parameters/node-parameter-value-type-guard.js +105 -115
  219. package/dist/cjs/node-parameters/node-parameter-value-type-guard.js.map +1 -1
  220. package/dist/cjs/node-parameters/parameter-type-validation.js +120 -130
  221. package/dist/cjs/node-parameters/parameter-type-validation.js.map +1 -1
  222. package/dist/cjs/node-parameters/path-utils.js +21 -31
  223. package/dist/cjs/node-parameters/path-utils.js.map +1 -1
  224. package/dist/cjs/node-parameters/rename-node-utils.js +22 -32
  225. package/dist/cjs/node-parameters/rename-node-utils.js.map +1 -1
  226. package/dist/cjs/node-reference-parser-utils.js +472 -482
  227. package/dist/cjs/node-reference-parser-utils.js.map +1 -1
  228. package/dist/cjs/node-validation.js +59 -69
  229. package/dist/cjs/node-validation.js.map +1 -1
  230. package/dist/cjs/observable-object.js +56 -66
  231. package/dist/cjs/observable-object.js.map +1 -1
  232. package/dist/cjs/redaction-channels.js +36 -46
  233. package/dist/cjs/redaction-channels.js.map +1 -1
  234. package/dist/cjs/run-execution-data/run-execution-data.js +15 -25
  235. package/dist/cjs/run-execution-data/run-execution-data.js.map +1 -1
  236. package/dist/cjs/run-execution-data/run-execution-data.v0.js +2 -12
  237. package/dist/cjs/run-execution-data/run-execution-data.v1.js +26 -36
  238. package/dist/cjs/run-execution-data/run-execution-data.v1.js.map +1 -1
  239. package/dist/cjs/run-execution-data-factory.js +113 -123
  240. package/dist/cjs/run-execution-data-factory.js.map +1 -1
  241. package/dist/cjs/schemas.d.ts +13 -13
  242. package/dist/cjs/schemas.d.ts.map +1 -1
  243. package/dist/cjs/schemas.js +351 -360
  244. package/dist/cjs/schemas.js.map +1 -1
  245. package/dist/cjs/sub-workflow-output.js +10 -20
  246. package/dist/cjs/sub-workflow-output.js.map +1 -1
  247. package/dist/cjs/telemetry-helpers.d.ts.map +1 -1
  248. package/dist/cjs/telemetry-helpers.js +716 -726
  249. package/dist/cjs/telemetry-helpers.js.map +1 -1
  250. package/dist/cjs/tool-helpers.js +18 -28
  251. package/dist/cjs/tool-helpers.js.map +1 -1
  252. package/dist/cjs/trigger-identity.js +41 -51
  253. package/dist/cjs/trigger-identity.js.map +1 -1
  254. package/dist/cjs/trimmed-task-data.js +21 -31
  255. package/dist/cjs/trimmed-task-data.js.map +1 -1
  256. package/dist/cjs/type-guards.d.ts +3 -3
  257. package/dist/cjs/type-guards.d.ts.map +1 -1
  258. package/dist/cjs/type-guards.js +74 -84
  259. package/dist/cjs/type-guards.js.map +1 -1
  260. package/dist/cjs/type-validation.d.ts.map +1 -1
  261. package/dist/cjs/type-validation.js +383 -393
  262. package/dist/cjs/type-validation.js.map +1 -1
  263. package/dist/cjs/utils.d.ts +2 -2
  264. package/dist/cjs/utils.d.ts.map +1 -1
  265. package/dist/cjs/utils.js +430 -440
  266. package/dist/cjs/utils.js.map +1 -1
  267. package/dist/cjs/versioned-node-type.d.ts.map +1 -1
  268. package/dist/cjs/versioned-node-type.js +20 -30
  269. package/dist/cjs/versioned-node-type.js.map +1 -1
  270. package/dist/cjs/workflow-checksum.js +67 -77
  271. package/dist/cjs/workflow-checksum.js.map +1 -1
  272. package/dist/cjs/workflow-data-proxy-env-provider.js +58 -68
  273. package/dist/cjs/workflow-data-proxy-env-provider.js.map +1 -1
  274. package/dist/cjs/workflow-data-proxy-helpers.js +8 -18
  275. package/dist/cjs/workflow-data-proxy-helpers.js.map +1 -1
  276. package/dist/cjs/workflow-data-proxy.d.ts.map +1 -1
  277. package/dist/cjs/workflow-data-proxy.js +1162 -1172
  278. package/dist/cjs/workflow-data-proxy.js.map +1 -1
  279. package/dist/cjs/workflow-diff.d.ts +2 -1
  280. package/dist/cjs/workflow-diff.d.ts.map +1 -1
  281. package/dist/cjs/workflow-diff.js +292 -300
  282. package/dist/cjs/workflow-diff.js.map +1 -1
  283. package/dist/cjs/workflow-environments-helper.js +23 -33
  284. package/dist/cjs/workflow-environments-helper.js.map +1 -1
  285. package/dist/cjs/workflow-expression.d.ts.map +1 -1
  286. package/dist/cjs/workflow-expression.js +97 -107
  287. package/dist/cjs/workflow-expression.js.map +1 -1
  288. package/dist/cjs/workflow-structure-validation.d.ts.map +1 -1
  289. package/dist/cjs/workflow-structure-validation.js +140 -150
  290. package/dist/cjs/workflow-structure-validation.js.map +1 -1
  291. package/dist/cjs/workflow-validation.js +40 -50
  292. package/dist/cjs/workflow-validation.js.map +1 -1
  293. package/dist/cjs/workflow.d.ts.map +1 -1
  294. package/dist/cjs/workflow.js +612 -622
  295. package/dist/cjs/workflow.js.map +1 -1
  296. package/dist/esm/common/get-child-nodes.js.map +1 -1
  297. package/dist/esm/common/get-connected-nodes.js.map +1 -1
  298. package/dist/esm/common/get-parent-nodes.js.map +1 -1
  299. package/dist/esm/common/resolve-variables.d.ts +8 -0
  300. package/dist/esm/common/resolve-variables.d.ts.map +1 -1
  301. package/dist/esm/common/resolve-variables.js +22 -0
  302. package/dist/esm/common/resolve-variables.js.map +1 -1
  303. package/dist/esm/constants.d.ts +3 -3
  304. package/dist/esm/constants.d.ts.map +1 -1
  305. package/dist/esm/cron.d.ts.map +1 -1
  306. package/dist/esm/errors/abstract/execution-base.error.d.ts.map +1 -1
  307. package/dist/esm/errors/abstract/execution-base.error.js.map +1 -1
  308. package/dist/esm/errors/abstract/node.error.d.ts.map +1 -1
  309. package/dist/esm/errors/abstract/node.error.js.map +1 -1
  310. package/dist/esm/errors/base/base.error.d.ts.map +1 -1
  311. package/dist/esm/errors/base/base.error.js.map +1 -1
  312. package/dist/esm/errors/base/operational.error.d.ts.map +1 -1
  313. package/dist/esm/errors/base/operational.error.js.map +1 -1
  314. package/dist/esm/errors/base/unexpected.error.d.ts.map +1 -1
  315. package/dist/esm/errors/base/unexpected.error.js.map +1 -1
  316. package/dist/esm/errors/base/user.error.d.ts.map +1 -1
  317. package/dist/esm/errors/base/user.error.js.map +1 -1
  318. package/dist/esm/errors/db-connection-timeout-error.d.ts.map +1 -1
  319. package/dist/esm/errors/execution-cancelled.error.d.ts.map +1 -1
  320. package/dist/esm/errors/expression-class-extension.error.d.ts.map +1 -1
  321. package/dist/esm/errors/expression-computed-destructuring.error.d.ts.map +1 -1
  322. package/dist/esm/errors/expression-destructuring.error.d.ts.map +1 -1
  323. package/dist/esm/errors/expression-reserved-variable.error.d.ts.map +1 -1
  324. package/dist/esm/errors/expression-with-statement.error.d.ts.map +1 -1
  325. package/dist/esm/errors/expression.error.d.ts.map +1 -1
  326. package/dist/esm/errors/node-api.error.d.ts.map +1 -1
  327. package/dist/esm/errors/node-api.error.js.map +1 -1
  328. package/dist/esm/errors/node-operation.error.d.ts.map +1 -1
  329. package/dist/esm/errors/node-operation.error.js.map +1 -1
  330. package/dist/esm/errors/node-ssl.error.d.ts.map +1 -1
  331. package/dist/esm/errors/subworkflow-operation.error.d.ts.map +1 -1
  332. package/dist/esm/errors/trigger-close.error.d.ts.map +1 -1
  333. package/dist/esm/errors/trigger-close.error.js.map +1 -1
  334. package/dist/esm/errors/webhook-taken.error.d.ts.map +1 -1
  335. package/dist/esm/errors/workflow-activation.error.d.ts.map +1 -1
  336. package/dist/esm/errors/workflow-activation.error.js.map +1 -1
  337. package/dist/esm/errors/workflow-operation.error.d.ts.map +1 -1
  338. package/dist/esm/execution-context-establishment-hooks.d.ts.map +1 -1
  339. package/dist/esm/execution-context.d.ts +14 -14
  340. package/dist/esm/execution-context.d.ts.map +1 -1
  341. package/dist/esm/execution-status.d.ts +2 -2
  342. package/dist/esm/execution-status.d.ts.map +1 -1
  343. package/dist/esm/expression-evaluator-proxy.d.ts.map +1 -1
  344. package/dist/esm/expression-sandboxing.d.ts.map +1 -1
  345. package/dist/esm/expression-sandboxing.js.map +1 -1
  346. package/dist/esm/expression.d.ts.map +1 -1
  347. package/dist/esm/expression.js.map +1 -1
  348. package/dist/esm/expressions/expression-helpers.d.ts.map +1 -1
  349. package/dist/esm/extensions/boolean-extensions.d.ts +1 -1
  350. package/dist/esm/extensions/expression-extension.d.ts.map +1 -1
  351. package/dist/esm/extensions/expression-parser.d.ts.map +1 -1
  352. package/dist/esm/extensions/extended-functions.d.ts +10 -18
  353. package/dist/esm/extensions/extended-functions.d.ts.map +1 -1
  354. package/dist/esm/extensions/number-extensions.js.map +1 -1
  355. package/dist/esm/extensions/string-extensions.d.ts +1 -1
  356. package/dist/esm/extensions/string-extensions.d.ts.map +1 -1
  357. package/dist/esm/extensions/string-extensions.js.map +1 -1
  358. package/dist/esm/extensions/utils.d.ts.map +1 -1
  359. package/dist/esm/from-ai-parse-utils.js.map +1 -1
  360. package/dist/esm/interfaces.d.ts +112 -22
  361. package/dist/esm/interfaces.d.ts.map +1 -1
  362. package/dist/esm/interfaces.js.map +1 -1
  363. package/dist/esm/logger-proxy.d.ts.map +1 -1
  364. package/dist/esm/message-event-bus.d.ts +184 -165
  365. package/dist/esm/message-event-bus.d.ts.map +1 -1
  366. package/dist/esm/message-event-bus.js +2 -2
  367. package/dist/esm/message-event-bus.js.map +1 -1
  368. package/dist/esm/node-grouping-validation.d.ts +6 -0
  369. package/dist/esm/node-grouping-validation.d.ts.map +1 -1
  370. package/dist/esm/node-grouping-validation.js +34 -5
  371. package/dist/esm/node-grouping-validation.js.map +1 -1
  372. package/dist/esm/node-helpers.d.ts.map +1 -1
  373. package/dist/esm/node-helpers.js +3 -0
  374. package/dist/esm/node-helpers.js.map +1 -1
  375. package/dist/esm/node-parameters/filter-parameter.d.ts.map +1 -1
  376. package/dist/esm/node-parameters/filter-parameter.js.map +1 -1
  377. package/dist/esm/node-reference-parser-utils.js.map +1 -1
  378. package/dist/esm/run-execution-data-factory.js.map +1 -1
  379. package/dist/esm/schemas.d.ts +13 -13
  380. package/dist/esm/schemas.d.ts.map +1 -1
  381. package/dist/esm/schemas.js +1 -0
  382. package/dist/esm/schemas.js.map +1 -1
  383. package/dist/esm/telemetry-helpers.d.ts.map +1 -1
  384. package/dist/esm/telemetry-helpers.js.map +1 -1
  385. package/dist/esm/type-guards.d.ts +3 -3
  386. package/dist/esm/type-guards.d.ts.map +1 -1
  387. package/dist/esm/type-validation.d.ts.map +1 -1
  388. package/dist/esm/type-validation.js.map +1 -1
  389. package/dist/esm/typecheck.tsbuildinfo +1 -1
  390. package/dist/esm/utils.d.ts +2 -2
  391. package/dist/esm/utils.d.ts.map +1 -1
  392. package/dist/esm/utils.js.map +1 -1
  393. package/dist/esm/versioned-node-type.d.ts.map +1 -1
  394. package/dist/esm/workflow-data-proxy.d.ts.map +1 -1
  395. package/dist/esm/workflow-data-proxy.js.map +1 -1
  396. package/dist/esm/workflow-diff.d.ts +2 -1
  397. package/dist/esm/workflow-diff.d.ts.map +1 -1
  398. package/dist/esm/workflow-diff.js +3 -1
  399. package/dist/esm/workflow-diff.js.map +1 -1
  400. package/dist/esm/workflow-expression.d.ts.map +1 -1
  401. package/dist/esm/workflow-expression.js.map +1 -1
  402. package/dist/esm/workflow-structure-validation.d.ts.map +1 -1
  403. package/dist/esm/workflow-structure-validation.js.map +1 -1
  404. package/dist/esm/workflow.d.ts.map +1 -1
  405. package/dist/esm/workflow.js.map +1 -1
  406. package/package.json +9 -8
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
3
  if (k2 === undefined) k2 = k;
3
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -31,685 +32,674 @@ var __importStar = (this && this.__importStar) || (function () {
31
32
  return result;
32
33
  };
33
34
  })();
34
- (function (factory) {
35
- if (typeof module === "object" && typeof module.exports === "object") {
36
- var v = factory(require, exports);
37
- if (v !== undefined) module.exports = v;
38
- }
39
- else if (typeof define === "function" && define.amd) {
40
- define(["require", "exports", "./common", "./constants", "./errors", "./workflow-expression", "./global-state", "./interfaces", "./node-helpers", "./node-parameters/rename-node-utils", "./node-reference-parser-utils", "./observable-object", "./utils"], factory);
41
- }
42
- })(function (require, exports) {
43
- "use strict";
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.Workflow = void 0;
46
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
47
- /* eslint-disable @typescript-eslint/no-unsafe-return */
48
- /* eslint-disable @typescript-eslint/no-for-in-array */
49
- const common_1 = require("./common");
50
- const constants_1 = require("./constants");
51
- const errors_1 = require("./errors");
52
- const workflow_expression_1 = require("./workflow-expression");
53
- const global_state_1 = require("./global-state");
54
- const interfaces_1 = require("./interfaces");
55
- const NodeHelpers = __importStar(require("./node-helpers"));
56
- const rename_node_utils_1 = require("./node-parameters/rename-node-utils");
57
- const node_reference_parser_utils_1 = require("./node-reference-parser-utils");
58
- const ObservableObject = __importStar(require("./observable-object"));
59
- const utils_1 = require("./utils");
60
- class Workflow {
61
- id;
62
- name;
63
- nodes = {};
64
- connectionsBySourceNode = {};
65
- connectionsByDestinationNode = {};
66
- nodeTypes;
67
- expression;
68
- active;
69
- settings = {};
70
- timezone;
71
- // To save workflow specific static data like for example
72
- // ids of registered webhooks of nodes
73
- staticData;
74
- testStaticData;
75
- pinData;
76
- constructor(parameters) {
77
- this.id = parameters.id; // @tech_debt Ensure this is not optional
78
- this.name = parameters.name;
79
- this.nodeTypes = parameters.nodeTypes;
80
- let nodeType;
81
- for (const node of parameters.nodes) {
82
- nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
83
- if (nodeType === undefined) {
84
- // Go on to next node when its type is not known.
85
- // For now do not error because that causes problems with
86
- // expression resolution also then when the unknown node
87
- // does not get used.
88
- continue;
89
- // throw new ApplicationError(`Node with unknown node type`, {
90
- // tags: { nodeType: node.type },
91
- // extra: { node },
92
- // });
93
- }
94
- // Add default values
95
- const nodeParameters = NodeHelpers.getNodeParameters(nodeType.description.properties, node.parameters, true, false, node, nodeType.description);
96
- node.parameters = nodeParameters !== null ? nodeParameters : {};
97
- }
98
- this.setNodes(parameters.nodes);
99
- this.setConnections(parameters.connections);
100
- this.setPinData(parameters.pinData);
101
- this.setSettings(parameters.settings ?? {});
102
- this.active = parameters.active || false;
103
- this.staticData = ObservableObject.create(parameters.staticData || {}, undefined, {
104
- ignoreEmptyOnFirstChild: true,
105
- });
106
- this.timezone = this.settings.timezone ?? (0, global_state_1.getGlobalState)().defaultTimezone;
107
- this.expression = new workflow_expression_1.WorkflowExpression(this);
108
- }
109
- // Save nodes in workflow as object to be able to get the nodes easily by their name.
110
- setNodes(nodes) {
111
- this.nodes = {};
112
- for (const node of nodes) {
113
- this.nodes[node.name] = node;
114
- }
115
- }
116
- setConnections(connections) {
117
- this.connectionsBySourceNode = connections;
118
- this.connectionsByDestinationNode = (0, common_1.mapConnectionsByDestination)(this.connectionsBySourceNode);
119
- }
120
- setPinData(pinData) {
121
- this.pinData = pinData;
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Workflow = void 0;
37
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
38
+ /* eslint-disable @typescript-eslint/no-unsafe-return */
39
+ /* eslint-disable @typescript-eslint/no-for-in-array */
40
+ const common_1 = require("./common");
41
+ const constants_1 = require("./constants");
42
+ const errors_1 = require("./errors");
43
+ const workflow_expression_1 = require("./workflow-expression");
44
+ const global_state_1 = require("./global-state");
45
+ const interfaces_1 = require("./interfaces");
46
+ const NodeHelpers = __importStar(require("./node-helpers"));
47
+ const rename_node_utils_1 = require("./node-parameters/rename-node-utils");
48
+ const node_reference_parser_utils_1 = require("./node-reference-parser-utils");
49
+ const ObservableObject = __importStar(require("./observable-object"));
50
+ const utils_1 = require("./utils");
51
+ class Workflow {
52
+ id;
53
+ name;
54
+ nodes = {};
55
+ connectionsBySourceNode = {};
56
+ connectionsByDestinationNode = {};
57
+ nodeTypes;
58
+ expression;
59
+ active;
60
+ settings = {};
61
+ timezone;
62
+ // To save workflow specific static data like for example
63
+ // ids of registered webhooks of nodes
64
+ staticData;
65
+ testStaticData;
66
+ pinData;
67
+ constructor(parameters) {
68
+ this.id = parameters.id; // @tech_debt Ensure this is not optional
69
+ this.name = parameters.name;
70
+ this.nodeTypes = parameters.nodeTypes;
71
+ let nodeType;
72
+ for (const node of parameters.nodes) {
73
+ nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
74
+ if (nodeType === undefined) {
75
+ // Go on to next node when its type is not known.
76
+ // For now do not error because that causes problems with
77
+ // expression resolution also then when the unknown node
78
+ // does not get used.
79
+ continue;
80
+ // throw new ApplicationError(`Node with unknown node type`, {
81
+ // tags: { nodeType: node.type },
82
+ // extra: { node },
83
+ // });
84
+ }
85
+ // Add default values
86
+ const nodeParameters = NodeHelpers.getNodeParameters(nodeType.description.properties, node.parameters, true, false, node, nodeType.description);
87
+ node.parameters = nodeParameters !== null ? nodeParameters : {};
122
88
  }
123
- setSettings(settings) {
124
- this.settings = settings;
89
+ this.setNodes(parameters.nodes);
90
+ this.setConnections(parameters.connections);
91
+ this.setPinData(parameters.pinData);
92
+ this.setSettings(parameters.settings ?? {});
93
+ this.active = parameters.active || false;
94
+ this.staticData = ObservableObject.create(parameters.staticData || {}, undefined, {
95
+ ignoreEmptyOnFirstChild: true,
96
+ });
97
+ this.timezone = this.settings.timezone ?? (0, global_state_1.getGlobalState)().defaultTimezone;
98
+ this.expression = new workflow_expression_1.WorkflowExpression(this);
99
+ }
100
+ // Save nodes in workflow as object to be able to get the nodes easily by their name.
101
+ setNodes(nodes) {
102
+ this.nodes = {};
103
+ for (const node of nodes) {
104
+ this.nodes[node.name] = node;
125
105
  }
126
- overrideStaticData(staticData) {
127
- this.staticData = ObservableObject.create(staticData || {}, undefined, {
128
- ignoreEmptyOnFirstChild: true,
129
- });
130
- this.staticData.__dataChanged = true;
131
- }
132
- static getConnectionsByDestination(connections) {
133
- const returnConnection = {};
134
- let connectionInfo;
135
- let maxIndex;
136
- for (const sourceNode in connections) {
137
- if (!connections.hasOwnProperty(sourceNode)) {
106
+ }
107
+ setConnections(connections) {
108
+ this.connectionsBySourceNode = connections;
109
+ this.connectionsByDestinationNode = (0, common_1.mapConnectionsByDestination)(this.connectionsBySourceNode);
110
+ }
111
+ setPinData(pinData) {
112
+ this.pinData = pinData;
113
+ }
114
+ setSettings(settings) {
115
+ this.settings = settings;
116
+ }
117
+ overrideStaticData(staticData) {
118
+ this.staticData = ObservableObject.create(staticData || {}, undefined, {
119
+ ignoreEmptyOnFirstChild: true,
120
+ });
121
+ this.staticData.__dataChanged = true;
122
+ }
123
+ static getConnectionsByDestination(connections) {
124
+ const returnConnection = {};
125
+ let connectionInfo;
126
+ let maxIndex;
127
+ for (const sourceNode in connections) {
128
+ if (!connections.hasOwnProperty(sourceNode)) {
129
+ continue;
130
+ }
131
+ for (const type of Object.keys(connections[sourceNode])) {
132
+ if (!connections[sourceNode].hasOwnProperty(type)) {
138
133
  continue;
139
134
  }
140
- for (const type of Object.keys(connections[sourceNode])) {
141
- if (!connections[sourceNode].hasOwnProperty(type)) {
135
+ for (const inputIndex in connections[sourceNode][type]) {
136
+ if (!connections[sourceNode][type].hasOwnProperty(inputIndex)) {
142
137
  continue;
143
138
  }
144
- for (const inputIndex in connections[sourceNode][type]) {
145
- if (!connections[sourceNode][type].hasOwnProperty(inputIndex)) {
146
- continue;
139
+ for (connectionInfo of connections[sourceNode][type][inputIndex] ?? []) {
140
+ if (!returnConnection.hasOwnProperty(connectionInfo.node)) {
141
+ returnConnection[connectionInfo.node] = {};
142
+ }
143
+ if (!returnConnection[connectionInfo.node].hasOwnProperty(connectionInfo.type)) {
144
+ returnConnection[connectionInfo.node][connectionInfo.type] = [];
147
145
  }
148
- for (connectionInfo of connections[sourceNode][type][inputIndex] ?? []) {
149
- if (!returnConnection.hasOwnProperty(connectionInfo.node)) {
150
- returnConnection[connectionInfo.node] = {};
151
- }
152
- if (!returnConnection[connectionInfo.node].hasOwnProperty(connectionInfo.type)) {
153
- returnConnection[connectionInfo.node][connectionInfo.type] = [];
154
- }
155
- maxIndex = returnConnection[connectionInfo.node][connectionInfo.type].length - 1;
156
- for (let j = maxIndex; j < connectionInfo.index; j++) {
157
- returnConnection[connectionInfo.node][connectionInfo.type].push([]);
158
- }
159
- returnConnection[connectionInfo.node][connectionInfo.type][connectionInfo.index]?.push({
160
- node: sourceNode,
161
- type,
162
- index: parseInt(inputIndex, 10),
163
- });
146
+ maxIndex = returnConnection[connectionInfo.node][connectionInfo.type].length - 1;
147
+ for (let j = maxIndex; j < connectionInfo.index; j++) {
148
+ returnConnection[connectionInfo.node][connectionInfo.type].push([]);
164
149
  }
150
+ returnConnection[connectionInfo.node][connectionInfo.type][connectionInfo.index]?.push({
151
+ node: sourceNode,
152
+ type,
153
+ index: parseInt(inputIndex, 10),
154
+ });
165
155
  }
166
156
  }
167
157
  }
168
- return returnConnection;
169
- }
170
- /**
171
- * Returns the static data of the workflow.
172
- * It gets saved with the workflow and will be the same for
173
- * all workflow-executions.
174
- *
175
- * @param {string} type The type of data to return ("global"|"node")
176
- * @param {INode} [node] If type is set to "node" then the node has to be provided
177
- */
178
- getStaticData(type, node) {
179
- let key;
180
- if (type === 'global') {
181
- key = 'global';
182
- }
183
- else if (type === 'node') {
184
- if (node === undefined) {
185
- throw new errors_1.UnexpectedError('The request data of context type "node" the node parameter has to be set!');
186
- }
187
- key = `node:${node.name}`;
188
- }
189
- else {
190
- throw new errors_1.UnexpectedError('Unknown context type. Only `global` and `node` are supported.', {
191
- extra: { contextType: type },
192
- });
193
- }
194
- if (this.testStaticData?.[key])
195
- return this.testStaticData[key];
196
- if (this.staticData[key] === undefined) {
197
- // Create it as ObservableObject that we can easily check if the data changed
198
- // to know if the workflow with its data has to be saved afterwards or not.
199
- this.staticData[key] = ObservableObject.create({}, this.staticData);
200
- }
201
- return this.staticData[key];
202
- }
203
- setTestStaticData(testStaticData) {
204
- this.testStaticData = testStaticData;
205
- }
206
- /**
207
- * Returns all the trigger nodes in the workflow.
208
- *
209
- */
210
- getTriggerNodes() {
211
- return this.queryNodes((nodeType) => !!nodeType.trigger);
212
- }
213
- /**
214
- * Returns all the poll nodes in the workflow
215
- *
216
- */
217
- getPollNodes() {
218
- return this.queryNodes((nodeType) => !!nodeType.poll);
219
- }
220
- /**
221
- * Returns all the nodes in the workflow for which the given
222
- * checkFunction return true
223
- *
224
- * @param {(nodeType: INodeType) => boolean} checkFunction
225
- */
226
- queryNodes(checkFunction) {
227
- const returnNodes = [];
228
- // Check if it has any of them
229
- let node;
230
- let nodeType;
231
- for (const nodeName of Object.keys(this.nodes)) {
232
- node = this.nodes[nodeName];
233
- if (node.disabled === true) {
234
- continue;
235
- }
236
- nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
237
- if (nodeType !== undefined && checkFunction(nodeType)) {
238
- returnNodes.push(node);
239
- }
240
- }
241
- return returnNodes;
242
- }
243
- /**
244
- * Returns the node with the given name if it exists else null
245
- *
246
- * @param {string} nodeName Name of the node to return
247
- */
248
- getNode(nodeName) {
249
- return this.nodes[nodeName] ?? null;
250
- }
251
- /**
252
- * Returns the nodes with the given names if they exist.
253
- * If a node cannot be found it will be ignored, meaning the returned array
254
- * of nodes can be smaller than the array of names.
255
- */
256
- getNodes(nodeNames) {
257
- const nodes = [];
258
- for (const name of nodeNames) {
259
- const node = this.getNode(name);
260
- if (!node) {
261
- console.warn(`Could not find a node with the name ${name} in the workflow. This was passed in as a dirty node name.`);
262
- continue;
263
- }
264
- nodes.push(node);
265
- }
266
- return nodes;
267
- }
268
- /**
269
- * Returns the pinData of the node with the given name if it exists
270
- *
271
- * @param {string} nodeName Name of the node to return the pinData of
272
- */
273
- getPinDataOfNode(nodeName) {
274
- return this.pinData ? this.pinData[nodeName] : undefined;
275
- }
276
- renameNodeInParameterValue(parameterValue, currentName, newName, { hasRenamableContent } = { hasRenamableContent: false }) {
277
- if (typeof parameterValue !== 'object') {
278
- // Reached the actual value
279
- if (typeof parameterValue === 'string' &&
280
- (parameterValue.charAt(0) === '=' || hasRenamableContent)) {
281
- parameterValue = (0, node_reference_parser_utils_1.applyAccessPatterns)(parameterValue, currentName, newName);
282
- }
283
- return parameterValue;
158
+ }
159
+ return returnConnection;
160
+ }
161
+ /**
162
+ * Returns the static data of the workflow.
163
+ * It gets saved with the workflow and will be the same for
164
+ * all workflow-executions.
165
+ *
166
+ * @param {string} type The type of data to return ("global"|"node")
167
+ * @param {INode} [node] If type is set to "node" then the node has to be provided
168
+ */
169
+ getStaticData(type, node) {
170
+ let key;
171
+ if (type === 'global') {
172
+ key = 'global';
173
+ }
174
+ else if (type === 'node') {
175
+ if (node === undefined) {
176
+ throw new errors_1.UnexpectedError('The request data of context type "node" the node parameter has to be set!');
284
177
  }
285
- if (Array.isArray(parameterValue)) {
286
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
287
- const returnArray = [];
288
- for (const currentValue of parameterValue) {
289
- returnArray.push(this.renameNodeInParameterValue(currentValue, currentName, newName));
290
- }
291
- return returnArray;
178
+ key = `node:${node.name}`;
179
+ }
180
+ else {
181
+ throw new errors_1.UnexpectedError('Unknown context type. Only `global` and `node` are supported.', {
182
+ extra: { contextType: type },
183
+ });
184
+ }
185
+ if (this.testStaticData?.[key])
186
+ return this.testStaticData[key];
187
+ if (this.staticData[key] === undefined) {
188
+ // Create it as ObservableObject that we can easily check if the data changed
189
+ // to know if the workflow with its data has to be saved afterwards or not.
190
+ this.staticData[key] = ObservableObject.create({}, this.staticData);
191
+ }
192
+ return this.staticData[key];
193
+ }
194
+ setTestStaticData(testStaticData) {
195
+ this.testStaticData = testStaticData;
196
+ }
197
+ /**
198
+ * Returns all the trigger nodes in the workflow.
199
+ *
200
+ */
201
+ getTriggerNodes() {
202
+ return this.queryNodes((nodeType) => !!nodeType.trigger);
203
+ }
204
+ /**
205
+ * Returns all the poll nodes in the workflow
206
+ *
207
+ */
208
+ getPollNodes() {
209
+ return this.queryNodes((nodeType) => !!nodeType.poll);
210
+ }
211
+ /**
212
+ * Returns all the nodes in the workflow for which the given
213
+ * checkFunction return true
214
+ *
215
+ * @param {(nodeType: INodeType) => boolean} checkFunction
216
+ */
217
+ queryNodes(checkFunction) {
218
+ const returnNodes = [];
219
+ // Check if it has any of them
220
+ let node;
221
+ let nodeType;
222
+ for (const nodeName of Object.keys(this.nodes)) {
223
+ node = this.nodes[nodeName];
224
+ if (node.disabled === true) {
225
+ continue;
226
+ }
227
+ nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
228
+ if (nodeType !== undefined && checkFunction(nodeType)) {
229
+ returnNodes.push(node);
292
230
  }
231
+ }
232
+ return returnNodes;
233
+ }
234
+ /**
235
+ * Returns the node with the given name if it exists else null
236
+ *
237
+ * @param {string} nodeName Name of the node to return
238
+ */
239
+ getNode(nodeName) {
240
+ return this.nodes[nodeName] ?? null;
241
+ }
242
+ /**
243
+ * Returns the nodes with the given names if they exist.
244
+ * If a node cannot be found it will be ignored, meaning the returned array
245
+ * of nodes can be smaller than the array of names.
246
+ */
247
+ getNodes(nodeNames) {
248
+ const nodes = [];
249
+ for (const name of nodeNames) {
250
+ const node = this.getNode(name);
251
+ if (!node) {
252
+ console.warn(`Could not find a node with the name ${name} in the workflow. This was passed in as a dirty node name.`);
253
+ continue;
254
+ }
255
+ nodes.push(node);
256
+ }
257
+ return nodes;
258
+ }
259
+ /**
260
+ * Returns the pinData of the node with the given name if it exists
261
+ *
262
+ * @param {string} nodeName Name of the node to return the pinData of
263
+ */
264
+ getPinDataOfNode(nodeName) {
265
+ return this.pinData ? this.pinData[nodeName] : undefined;
266
+ }
267
+ renameNodeInParameterValue(parameterValue, currentName, newName, { hasRenamableContent } = { hasRenamableContent: false }) {
268
+ if (typeof parameterValue !== 'object') {
269
+ // Reached the actual value
270
+ if (typeof parameterValue === 'string' &&
271
+ (parameterValue.charAt(0) === '=' || hasRenamableContent)) {
272
+ parameterValue = (0, node_reference_parser_utils_1.applyAccessPatterns)(parameterValue, currentName, newName);
273
+ }
274
+ return parameterValue;
275
+ }
276
+ if (Array.isArray(parameterValue)) {
293
277
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
294
- const returnData = {};
295
- for (const parameterName of Object.keys(parameterValue || {})) {
296
- returnData[parameterName] = this.renameNodeInParameterValue(parameterValue[parameterName], currentName, newName, { hasRenamableContent });
297
- }
298
- return returnData;
299
- }
300
- /**
301
- * Rename a node in the workflow
302
- *
303
- * @param {string} currentName The current name of the node
304
- * @param {string} newName The new name
305
- */
306
- renameNode(currentName, newName) {
307
- // These keys are excluded to prevent accidental modification of inherited properties and
308
- // to avoid any issues related to JavaScript's built-in methods that can cause unexpected behavior
309
- const restrictedKeys = [
310
- 'hasOwnProperty',
311
- 'isPrototypeOf',
312
- 'propertyIsEnumerable',
313
- 'toLocaleString',
314
- 'toString',
315
- 'valueOf',
316
- 'constructor',
317
- 'prototype',
318
- '__proto__',
319
- '__defineGetter__',
320
- '__defineSetter__',
321
- '__lookupGetter__',
322
- '__lookupSetter__',
323
- ];
324
- if (restrictedKeys.map((k) => k.toLowerCase()).includes(newName.toLowerCase())) {
325
- throw new errors_1.UserError(`Node name "${newName}" is a restricted name.`, {
326
- description: `Node names cannot be any of the following: ${restrictedKeys.join(', ')}`,
327
- });
278
+ const returnArray = [];
279
+ for (const currentValue of parameterValue) {
280
+ returnArray.push(this.renameNodeInParameterValue(currentValue, currentName, newName));
328
281
  }
329
- // Rename the node itself
330
- if (this.nodes[currentName] !== undefined) {
331
- this.nodes[newName] = this.nodes[currentName];
332
- this.nodes[newName].name = newName;
333
- delete this.nodes[currentName];
282
+ return returnArray;
283
+ }
284
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
285
+ const returnData = {};
286
+ for (const parameterName of Object.keys(parameterValue || {})) {
287
+ returnData[parameterName] = this.renameNodeInParameterValue(parameterValue[parameterName], currentName, newName, { hasRenamableContent });
288
+ }
289
+ return returnData;
290
+ }
291
+ /**
292
+ * Rename a node in the workflow
293
+ *
294
+ * @param {string} currentName The current name of the node
295
+ * @param {string} newName The new name
296
+ */
297
+ renameNode(currentName, newName) {
298
+ // These keys are excluded to prevent accidental modification of inherited properties and
299
+ // to avoid any issues related to JavaScript's built-in methods that can cause unexpected behavior
300
+ const restrictedKeys = [
301
+ 'hasOwnProperty',
302
+ 'isPrototypeOf',
303
+ 'propertyIsEnumerable',
304
+ 'toLocaleString',
305
+ 'toString',
306
+ 'valueOf',
307
+ 'constructor',
308
+ 'prototype',
309
+ '__proto__',
310
+ '__defineGetter__',
311
+ '__defineSetter__',
312
+ '__lookupGetter__',
313
+ '__lookupSetter__',
314
+ ];
315
+ if (restrictedKeys.map((k) => k.toLowerCase()).includes(newName.toLowerCase())) {
316
+ throw new errors_1.UserError(`Node name "${newName}" is a restricted name.`, {
317
+ description: `Node names cannot be any of the following: ${restrictedKeys.join(', ')}`,
318
+ });
319
+ }
320
+ // Rename the node itself
321
+ if (this.nodes[currentName] !== undefined) {
322
+ this.nodes[newName] = this.nodes[currentName];
323
+ this.nodes[newName].name = newName;
324
+ delete this.nodes[currentName];
325
+ }
326
+ // Update the expressions which reference the node
327
+ // with its old name
328
+ for (const node of Object.values(this.nodes)) {
329
+ node.parameters = this.renameNodeInParameterValue(node.parameters, currentName, newName);
330
+ if (constants_1.NODES_WITH_RENAMABLE_CONTENT.has(node.type)) {
331
+ node.parameters.jsCode = this.renameNodeInParameterValue(node.parameters.jsCode, currentName, newName, { hasRenamableContent: true });
334
332
  }
335
- // Update the expressions which reference the node
336
- // with its old name
337
- for (const node of Object.values(this.nodes)) {
338
- node.parameters = this.renameNodeInParameterValue(node.parameters, currentName, newName);
339
- if (constants_1.NODES_WITH_RENAMABLE_CONTENT.has(node.type)) {
340
- node.parameters.jsCode = this.renameNodeInParameterValue(node.parameters.jsCode, currentName, newName, { hasRenamableContent: true });
341
- }
342
- if (constants_1.NODES_WITH_RENAMEABLE_TOPLEVEL_HTML_CONTENT.has(node.type)) {
343
- node.parameters.html = this.renameNodeInParameterValue(node.parameters.html, currentName, newName, { hasRenamableContent: true });
344
- }
345
- if (constants_1.NODES_WITH_RENAMABLE_FORM_HTML_CONTENT.has(node.type)) {
346
- (0, rename_node_utils_1.renameFormFields)(node, (p) => this.renameNodeInParameterValue(p, currentName, newName, {
347
- hasRenamableContent: true,
348
- }));
349
- }
333
+ if (constants_1.NODES_WITH_RENAMEABLE_TOPLEVEL_HTML_CONTENT.has(node.type)) {
334
+ node.parameters.html = this.renameNodeInParameterValue(node.parameters.html, currentName, newName, { hasRenamableContent: true });
350
335
  }
351
- // Change all source connections
352
- if (this.connectionsBySourceNode.hasOwnProperty(currentName)) {
353
- this.connectionsBySourceNode[newName] = this.connectionsBySourceNode[currentName];
354
- delete this.connectionsBySourceNode[currentName];
336
+ if (constants_1.NODES_WITH_RENAMABLE_FORM_HTML_CONTENT.has(node.type)) {
337
+ (0, rename_node_utils_1.renameFormFields)(node, (p) => this.renameNodeInParameterValue(p, currentName, newName, {
338
+ hasRenamableContent: true,
339
+ }));
355
340
  }
356
- // Change all destination connections
357
- let sourceNode;
358
- let type;
359
- let sourceIndex;
360
- let connectionIndex;
361
- let connectionData;
362
- for (sourceNode of Object.keys(this.connectionsBySourceNode)) {
363
- for (type of Object.keys(this.connectionsBySourceNode[sourceNode])) {
364
- for (sourceIndex of Object.keys(this.connectionsBySourceNode[sourceNode][type])) {
365
- for (connectionIndex of Object.keys(this.connectionsBySourceNode[sourceNode][type][parseInt(sourceIndex, 10)] || [])) {
366
- connectionData =
367
- this.connectionsBySourceNode[sourceNode][type][parseInt(sourceIndex, 10)]?.[parseInt(connectionIndex, 10)];
368
- if (connectionData?.node === currentName) {
369
- connectionData.node = newName;
370
- }
341
+ }
342
+ // Change all source connections
343
+ if (this.connectionsBySourceNode.hasOwnProperty(currentName)) {
344
+ this.connectionsBySourceNode[newName] = this.connectionsBySourceNode[currentName];
345
+ delete this.connectionsBySourceNode[currentName];
346
+ }
347
+ // Change all destination connections
348
+ let sourceNode;
349
+ let type;
350
+ let sourceIndex;
351
+ let connectionIndex;
352
+ let connectionData;
353
+ for (sourceNode of Object.keys(this.connectionsBySourceNode)) {
354
+ for (type of Object.keys(this.connectionsBySourceNode[sourceNode])) {
355
+ for (sourceIndex of Object.keys(this.connectionsBySourceNode[sourceNode][type])) {
356
+ for (connectionIndex of Object.keys(this.connectionsBySourceNode[sourceNode][type][parseInt(sourceIndex, 10)] || [])) {
357
+ connectionData =
358
+ this.connectionsBySourceNode[sourceNode][type][parseInt(sourceIndex, 10)]?.[parseInt(connectionIndex, 10)];
359
+ if (connectionData?.node === currentName) {
360
+ connectionData.node = newName;
371
361
  }
372
362
  }
373
363
  }
374
364
  }
375
365
  }
376
- /**
377
- * Finds the highest parent nodes of the node with the given name
378
- *
379
- * @param {NodeConnectionType} [type='main']
380
- */
381
- getHighestNode(nodeName, nodeConnectionIndex, checkedNodes) {
382
- const currentHighest = [];
383
- if (!(nodeName in this.nodes)) {
384
- // Node is not in the workflow
385
- return currentHighest;
386
- }
387
- if (this.nodes[nodeName].disabled === false) {
388
- // If the current node is not disabled itself is the highest
389
- currentHighest.push(nodeName);
390
- }
391
- if (!this.connectionsByDestinationNode.hasOwnProperty(nodeName)) {
392
- // Node does not have incoming connections
393
- return currentHighest;
394
- }
395
- if (!this.connectionsByDestinationNode[nodeName].hasOwnProperty(interfaces_1.NodeConnectionTypes.Main)) {
396
- // Node does not have incoming connections of given type
397
- return currentHighest;
398
- }
399
- checkedNodes = checkedNodes || [];
400
- if (checkedNodes.includes(nodeName)) {
401
- // Node got checked already before
402
- return currentHighest;
403
- }
404
- checkedNodes.push(nodeName);
405
- const returnNodes = [];
406
- let addNodes;
407
- let connectionsByIndex;
408
- for (let connectionIndex = 0; connectionIndex <
409
- this.connectionsByDestinationNode[nodeName][interfaces_1.NodeConnectionTypes.Main].length; connectionIndex++) {
410
- if (nodeConnectionIndex !== undefined && nodeConnectionIndex !== connectionIndex) {
411
- // If a connection-index is given ignore all other ones
412
- continue;
366
+ }
367
+ /**
368
+ * Finds the highest parent nodes of the node with the given name
369
+ *
370
+ * @param {NodeConnectionType} [type='main']
371
+ */
372
+ getHighestNode(nodeName, nodeConnectionIndex, checkedNodes) {
373
+ const currentHighest = [];
374
+ if (!(nodeName in this.nodes)) {
375
+ // Node is not in the workflow
376
+ return currentHighest;
377
+ }
378
+ if (this.nodes[nodeName].disabled === false) {
379
+ // If the current node is not disabled itself is the highest
380
+ currentHighest.push(nodeName);
381
+ }
382
+ if (!this.connectionsByDestinationNode.hasOwnProperty(nodeName)) {
383
+ // Node does not have incoming connections
384
+ return currentHighest;
385
+ }
386
+ if (!this.connectionsByDestinationNode[nodeName].hasOwnProperty(interfaces_1.NodeConnectionTypes.Main)) {
387
+ // Node does not have incoming connections of given type
388
+ return currentHighest;
389
+ }
390
+ checkedNodes = checkedNodes || [];
391
+ if (checkedNodes.includes(nodeName)) {
392
+ // Node got checked already before
393
+ return currentHighest;
394
+ }
395
+ checkedNodes.push(nodeName);
396
+ const returnNodes = [];
397
+ let addNodes;
398
+ let connectionsByIndex;
399
+ for (let connectionIndex = 0; connectionIndex <
400
+ this.connectionsByDestinationNode[nodeName][interfaces_1.NodeConnectionTypes.Main].length; connectionIndex++) {
401
+ if (nodeConnectionIndex !== undefined && nodeConnectionIndex !== connectionIndex) {
402
+ // If a connection-index is given ignore all other ones
403
+ continue;
404
+ }
405
+ connectionsByIndex =
406
+ this.connectionsByDestinationNode[nodeName][interfaces_1.NodeConnectionTypes.Main][connectionIndex];
407
+ connectionsByIndex?.forEach((connection) => {
408
+ if (checkedNodes.includes(connection.node)) {
409
+ // Node got checked already before
410
+ return;
413
411
  }
414
- connectionsByIndex =
415
- this.connectionsByDestinationNode[nodeName][interfaces_1.NodeConnectionTypes.Main][connectionIndex];
416
- connectionsByIndex?.forEach((connection) => {
417
- if (checkedNodes.includes(connection.node)) {
418
- // Node got checked already before
419
- return;
412
+ // Ignore connections for nodes that don't exist in this workflow
413
+ if (!(connection.node in this.nodes))
414
+ return;
415
+ addNodes = this.getHighestNode(connection.node, undefined, checkedNodes);
416
+ if (addNodes.length === 0) {
417
+ // The checked node does not have any further parents so add it
418
+ // if it is not disabled
419
+ if (this.nodes[connection.node].disabled !== true) {
420
+ addNodes = [connection.node];
420
421
  }
421
- // Ignore connections for nodes that don't exist in this workflow
422
- if (!(connection.node in this.nodes))
423
- return;
424
- addNodes = this.getHighestNode(connection.node, undefined, checkedNodes);
425
- if (addNodes.length === 0) {
426
- // The checked node does not have any further parents so add it
427
- // if it is not disabled
428
- if (this.nodes[connection.node].disabled !== true) {
429
- addNodes = [connection.node];
430
- }
422
+ }
423
+ addNodes.forEach((name) => {
424
+ // Only add if node is not on the list already anyway
425
+ if (returnNodes.indexOf(name) === -1) {
426
+ returnNodes.push(name);
431
427
  }
432
- addNodes.forEach((name) => {
433
- // Only add if node is not on the list already anyway
434
- if (returnNodes.indexOf(name) === -1) {
435
- returnNodes.push(name);
436
- }
437
- });
438
428
  });
439
- }
440
- return returnNodes;
441
- }
442
- /**
443
- * Returns all the after the given one
444
- *
445
- * @param {string} [type='main']
446
- * @param {*} [depth=-1]
447
- */
448
- getChildNodes(nodeName, type = interfaces_1.NodeConnectionTypes.Main, depth = -1) {
449
- return (0, common_1.getChildNodes)(this.connectionsBySourceNode, nodeName, type, depth);
450
- }
451
- /**
452
- * Returns all the nodes before the given one
453
- *
454
- * @param {NodeConnectionType} [type='main']
455
- * @param {*} [depth=-1]
456
- */
457
- getParentNodes(nodeName, type = interfaces_1.NodeConnectionTypes.Main, depth = -1) {
458
- return (0, common_1.getParentNodes)(this.connectionsByDestinationNode, nodeName, type, depth);
459
- }
460
- /**
461
- * Gets all the nodes which are connected nodes starting from
462
- * the given one
463
- *
464
- * @param {NodeConnectionType} [type='main']
465
- * @param {*} [depth=-1]
466
- */
467
- getConnectedNodes(connections, nodeName, connectionType = interfaces_1.NodeConnectionTypes.Main, depth = -1) {
468
- return (0, common_1.getConnectedNodes)(connections, nodeName, connectionType, depth);
469
- }
470
- /**
471
- * Returns all the nodes before the given one
472
- *
473
- * @param {*} [maxDepth=-1]
474
- */
475
- getParentNodesByDepth(nodeName, maxDepth = -1) {
476
- return this.searchNodesBFS(this.connectionsByDestinationNode, nodeName, maxDepth);
477
- }
478
- /**
479
- * Gets all the nodes which are connected nodes starting from
480
- * the given one
481
- * Uses BFS traversal
482
- *
483
- * @param {*} [maxDepth=-1]
484
- */
485
- searchNodesBFS(connections, sourceNode, maxDepth = -1) {
486
- const returnConns = [];
487
- const type = interfaces_1.NodeConnectionTypes.Main;
488
- let queue = [];
489
- queue.push({
490
- name: sourceNode,
491
- depth: 0,
492
- indicies: [],
493
429
  });
494
- const visited = {};
495
- let depth = 0;
496
- while (queue.length > 0) {
497
- if (maxDepth !== -1 && depth > maxDepth) {
498
- break;
430
+ }
431
+ return returnNodes;
432
+ }
433
+ /**
434
+ * Returns all the after the given one
435
+ *
436
+ * @param {string} [type='main']
437
+ * @param {*} [depth=-1]
438
+ */
439
+ getChildNodes(nodeName, type = interfaces_1.NodeConnectionTypes.Main, depth = -1) {
440
+ return (0, common_1.getChildNodes)(this.connectionsBySourceNode, nodeName, type, depth);
441
+ }
442
+ /**
443
+ * Returns all the nodes before the given one
444
+ *
445
+ * @param {NodeConnectionType} [type='main']
446
+ * @param {*} [depth=-1]
447
+ */
448
+ getParentNodes(nodeName, type = interfaces_1.NodeConnectionTypes.Main, depth = -1) {
449
+ return (0, common_1.getParentNodes)(this.connectionsByDestinationNode, nodeName, type, depth);
450
+ }
451
+ /**
452
+ * Gets all the nodes which are connected nodes starting from
453
+ * the given one
454
+ *
455
+ * @param {NodeConnectionType} [type='main']
456
+ * @param {*} [depth=-1]
457
+ */
458
+ getConnectedNodes(connections, nodeName, connectionType = interfaces_1.NodeConnectionTypes.Main, depth = -1) {
459
+ return (0, common_1.getConnectedNodes)(connections, nodeName, connectionType, depth);
460
+ }
461
+ /**
462
+ * Returns all the nodes before the given one
463
+ *
464
+ * @param {*} [maxDepth=-1]
465
+ */
466
+ getParentNodesByDepth(nodeName, maxDepth = -1) {
467
+ return this.searchNodesBFS(this.connectionsByDestinationNode, nodeName, maxDepth);
468
+ }
469
+ /**
470
+ * Gets all the nodes which are connected nodes starting from
471
+ * the given one
472
+ * Uses BFS traversal
473
+ *
474
+ * @param {*} [maxDepth=-1]
475
+ */
476
+ searchNodesBFS(connections, sourceNode, maxDepth = -1) {
477
+ const returnConns = [];
478
+ const type = interfaces_1.NodeConnectionTypes.Main;
479
+ let queue = [];
480
+ queue.push({
481
+ name: sourceNode,
482
+ depth: 0,
483
+ indicies: [],
484
+ });
485
+ const visited = {};
486
+ let depth = 0;
487
+ while (queue.length > 0) {
488
+ if (maxDepth !== -1 && depth > maxDepth) {
489
+ break;
490
+ }
491
+ depth++;
492
+ const toAdd = [...queue];
493
+ queue = [];
494
+ toAdd.forEach((curr) => {
495
+ if (visited[curr.name]) {
496
+ visited[curr.name].indicies = (0, utils_1.dedupe)(visited[curr.name].indicies.concat(curr.indicies));
497
+ return;
499
498
  }
500
- depth++;
501
- const toAdd = [...queue];
502
- queue = [];
503
- toAdd.forEach((curr) => {
504
- if (visited[curr.name]) {
505
- visited[curr.name].indicies = (0, utils_1.dedupe)(visited[curr.name].indicies.concat(curr.indicies));
506
- return;
507
- }
508
- visited[curr.name] = curr;
509
- if (curr.name !== sourceNode) {
510
- returnConns.push(curr);
511
- }
512
- if (!connections.hasOwnProperty(curr.name) ||
513
- !connections[curr.name].hasOwnProperty(type)) {
514
- return;
515
- }
516
- connections[curr.name][type].forEach((connectionsByIndex) => {
517
- connectionsByIndex?.forEach((connection) => {
518
- queue.push({
519
- name: connection.node,
520
- indicies: [connection.index],
521
- depth,
522
- });
499
+ visited[curr.name] = curr;
500
+ if (curr.name !== sourceNode) {
501
+ returnConns.push(curr);
502
+ }
503
+ if (!connections.hasOwnProperty(curr.name) ||
504
+ !connections[curr.name].hasOwnProperty(type)) {
505
+ return;
506
+ }
507
+ connections[curr.name][type].forEach((connectionsByIndex) => {
508
+ connectionsByIndex?.forEach((connection) => {
509
+ queue.push({
510
+ name: connection.node,
511
+ indicies: [connection.index],
512
+ depth,
523
513
  });
524
514
  });
525
515
  });
526
- }
527
- return returnConns;
516
+ });
528
517
  }
529
- getParentMainInputNode(node) {
530
- if (node) {
531
- const nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
532
- if (!nodeType?.description.outputs) {
533
- return node;
534
- }
535
- const outputs = NodeHelpers.getNodeOutputs(this, node, nodeType.description);
536
- const nonMainConnectionTypes = [];
537
- for (const output of outputs) {
538
- const type = typeof output === 'string' ? output : output.type;
539
- if (type !== interfaces_1.NodeConnectionTypes.Main) {
540
- nonMainConnectionTypes.push(type);
541
- }
518
+ return returnConns;
519
+ }
520
+ getParentMainInputNode(node) {
521
+ if (node) {
522
+ const nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
523
+ if (!nodeType?.description.outputs) {
524
+ return node;
525
+ }
526
+ const outputs = NodeHelpers.getNodeOutputs(this, node, nodeType.description);
527
+ const nonMainConnectionTypes = [];
528
+ for (const output of outputs) {
529
+ const type = typeof output === 'string' ? output : output.type;
530
+ if (type !== interfaces_1.NodeConnectionTypes.Main) {
531
+ nonMainConnectionTypes.push(type);
542
532
  }
543
- // Sort for deterministic behavior: prevents non-deterministic selection when multiple
544
- // non-main outputs exist (AI agents with multiple tools). Object.keys() ordering
545
- // can vary across runs, causing inconsistent first-choice selection.
546
- nonMainConnectionTypes.sort();
547
- if (nonMainConnectionTypes.length > 0) {
548
- const nonMainNodesConnected = [];
549
- const nodeConnections = this.connectionsBySourceNode[node.name];
550
- for (const type of nonMainConnectionTypes) {
551
- // Only include connection types that exist in actual execution data
552
- if (nodeConnections?.[type]) {
553
- const childNodes = this.getChildNodes(node.name, type);
554
- if (childNodes.length > 0) {
555
- nonMainNodesConnected.push(...childNodes);
556
- }
533
+ }
534
+ // Sort for deterministic behavior: prevents non-deterministic selection when multiple
535
+ // non-main outputs exist (AI agents with multiple tools). Object.keys() ordering
536
+ // can vary across runs, causing inconsistent first-choice selection.
537
+ nonMainConnectionTypes.sort();
538
+ if (nonMainConnectionTypes.length > 0) {
539
+ const nonMainNodesConnected = [];
540
+ const nodeConnections = this.connectionsBySourceNode[node.name];
541
+ for (const type of nonMainConnectionTypes) {
542
+ // Only include connection types that exist in actual execution data
543
+ if (nodeConnections?.[type]) {
544
+ const childNodes = this.getChildNodes(node.name, type);
545
+ if (childNodes.length > 0) {
546
+ nonMainNodesConnected.push(...childNodes);
557
547
  }
558
548
  }
559
- if (nonMainNodesConnected.length) {
560
- // Sort for deterministic behavior, then get first node
561
- nonMainNodesConnected.sort();
562
- const returnNode = this.getNode(nonMainNodesConnected[0]);
563
- if (!returnNode) {
564
- throw new errors_1.UnexpectedError(`Node "${nonMainNodesConnected[0]}" not found`);
565
- }
566
- return this.getParentMainInputNode(returnNode);
549
+ }
550
+ if (nonMainNodesConnected.length) {
551
+ // Sort for deterministic behavior, then get first node
552
+ nonMainNodesConnected.sort();
553
+ const returnNode = this.getNode(nonMainNodesConnected[0]);
554
+ if (!returnNode) {
555
+ throw new errors_1.UnexpectedError(`Node "${nonMainNodesConnected[0]}" not found`);
567
556
  }
557
+ return this.getParentMainInputNode(returnNode);
568
558
  }
569
559
  }
570
- return node;
571
- }
572
- /**
573
- * Returns via which output of the parent-node and index the current node
574
- * they are connected
575
- *
576
- * @param {string} nodeName The node to check how it is connected with parent node
577
- * @param {string} parentNodeName The parent node to get the output index of
578
- * @param {string} [type='main']
579
- */
580
- getNodeConnectionIndexes(nodeName, parentNodeName, type = interfaces_1.NodeConnectionTypes.Main) {
581
- // This method has been optimized for performance. If you make any changes to it,
582
- // make sure the performance is not degraded.
583
- const parentNode = this.getNode(parentNodeName);
584
- if (parentNode === null) {
585
- return undefined;
586
- }
587
- const visitedNodes = new Set();
588
- const queue = [nodeName];
589
- // Cache the connections by destination node to avoid reference lookups
590
- const connectionsByDest = this.connectionsByDestinationNode;
591
- while (queue.length > 0) {
592
- const currentNodeName = queue.shift();
593
- if (visitedNodes.has(currentNodeName)) {
594
- continue;
595
- }
596
- visitedNodes.add(currentNodeName);
597
- const typeConnections = connectionsByDest[currentNodeName]?.[type];
598
- if (!typeConnections) {
560
+ }
561
+ return node;
562
+ }
563
+ /**
564
+ * Returns via which output of the parent-node and index the current node
565
+ * they are connected
566
+ *
567
+ * @param {string} nodeName The node to check how it is connected with parent node
568
+ * @param {string} parentNodeName The parent node to get the output index of
569
+ * @param {string} [type='main']
570
+ */
571
+ getNodeConnectionIndexes(nodeName, parentNodeName, type = interfaces_1.NodeConnectionTypes.Main) {
572
+ // This method has been optimized for performance. If you make any changes to it,
573
+ // make sure the performance is not degraded.
574
+ const parentNode = this.getNode(parentNodeName);
575
+ if (parentNode === null) {
576
+ return undefined;
577
+ }
578
+ const visitedNodes = new Set();
579
+ const queue = [nodeName];
580
+ // Cache the connections by destination node to avoid reference lookups
581
+ const connectionsByDest = this.connectionsByDestinationNode;
582
+ while (queue.length > 0) {
583
+ const currentNodeName = queue.shift();
584
+ if (visitedNodes.has(currentNodeName)) {
585
+ continue;
586
+ }
587
+ visitedNodes.add(currentNodeName);
588
+ const typeConnections = connectionsByDest[currentNodeName]?.[type];
589
+ if (!typeConnections) {
590
+ continue;
591
+ }
592
+ for (let typedConnectionIdx = 0; typedConnectionIdx < typeConnections.length; typedConnectionIdx++) {
593
+ const connectionsByIndex = typeConnections[typedConnectionIdx];
594
+ if (!connectionsByIndex) {
599
595
  continue;
600
596
  }
601
- for (let typedConnectionIdx = 0; typedConnectionIdx < typeConnections.length; typedConnectionIdx++) {
602
- const connectionsByIndex = typeConnections[typedConnectionIdx];
603
- if (!connectionsByIndex) {
604
- continue;
597
+ for (let destinationIndex = 0; destinationIndex < connectionsByIndex.length; destinationIndex++) {
598
+ const connection = connectionsByIndex[destinationIndex];
599
+ if (parentNodeName === connection.node) {
600
+ return {
601
+ sourceIndex: connection.index,
602
+ destinationIndex,
603
+ };
605
604
  }
606
- for (let destinationIndex = 0; destinationIndex < connectionsByIndex.length; destinationIndex++) {
607
- const connection = connectionsByIndex[destinationIndex];
608
- if (parentNodeName === connection.node) {
609
- return {
610
- sourceIndex: connection.index,
611
- destinationIndex,
612
- };
613
- }
614
- if (!visitedNodes.has(connection.node)) {
615
- queue.push(connection.node);
616
- }
605
+ if (!visitedNodes.has(connection.node)) {
606
+ queue.push(connection.node);
617
607
  }
618
608
  }
619
609
  }
620
- return undefined;
621
610
  }
622
- /**
623
- * Returns from which of the given nodes the workflow should get started from
624
- *
625
- * @param {string[]} nodeNames The potential start nodes
626
- */
627
- __getStartNode(nodeNames) {
628
- // Check if there are any trigger or poll nodes and then return the first one
629
- let node;
630
- let nodeType;
631
- if (nodeNames.length === 1) {
632
- node = this.nodes[nodeNames[0]];
633
- if (node && !node.disabled) {
634
- return node;
635
- }
611
+ return undefined;
612
+ }
613
+ /**
614
+ * Returns from which of the given nodes the workflow should get started from
615
+ *
616
+ * @param {string[]} nodeNames The potential start nodes
617
+ */
618
+ __getStartNode(nodeNames) {
619
+ // Check if there are any trigger or poll nodes and then return the first one
620
+ let node;
621
+ let nodeType;
622
+ if (nodeNames.length === 1) {
623
+ node = this.nodes[nodeNames[0]];
624
+ if (node && !node.disabled) {
625
+ return node;
636
626
  }
637
- for (const nodeName of nodeNames) {
638
- node = this.nodes[nodeName];
639
- nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
640
- // TODO: Identify later differently
641
- if (nodeType.description.name === constants_1.MANUAL_CHAT_TRIGGER_LANGCHAIN_NODE_TYPE) {
627
+ }
628
+ for (const nodeName of nodeNames) {
629
+ node = this.nodes[nodeName];
630
+ nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
631
+ // TODO: Identify later differently
632
+ if (nodeType.description.name === constants_1.MANUAL_CHAT_TRIGGER_LANGCHAIN_NODE_TYPE) {
633
+ continue;
634
+ }
635
+ if (nodeType && (nodeType.trigger !== undefined || nodeType.poll !== undefined)) {
636
+ if (node.disabled === true) {
642
637
  continue;
643
638
  }
644
- if (nodeType && (nodeType.trigger !== undefined || nodeType.poll !== undefined)) {
645
- if (node.disabled === true) {
646
- continue;
647
- }
648
- return node;
649
- }
650
- }
651
- const sortedNodeNames = Object.values(this.nodes)
652
- .sort((a, b) => constants_1.STARTING_NODE_TYPES.indexOf(a.type) - constants_1.STARTING_NODE_TYPES.indexOf(b.type))
653
- .map((n) => n.name);
654
- for (const nodeName of sortedNodeNames) {
655
- node = this.nodes[nodeName];
656
- if (constants_1.STARTING_NODE_TYPES.includes(node.type)) {
657
- if (node.disabled === true) {
658
- continue;
659
- }
660
- return node;
661
- }
639
+ return node;
662
640
  }
663
- return undefined;
664
641
  }
665
- /**
666
- * Returns the start node to start the workflow from
667
- *
668
- */
669
- getStartNode(destinationNode) {
670
- if (destinationNode) {
671
- // Find the highest parent nodes of the given one
672
- const nodeNames = this.getHighestNode(destinationNode);
673
- if (nodeNames.length === 0) {
674
- // If no parent nodes have been found then only the destination-node
675
- // is in the tree so add that one
676
- nodeNames.push(destinationNode);
677
- }
678
- // Check which node to return as start node
679
- const node = this.__getStartNode(nodeNames);
680
- if (node !== undefined) {
681
- return node;
642
+ const sortedNodeNames = Object.values(this.nodes)
643
+ .sort((a, b) => constants_1.STARTING_NODE_TYPES.indexOf(a.type) - constants_1.STARTING_NODE_TYPES.indexOf(b.type))
644
+ .map((n) => n.name);
645
+ for (const nodeName of sortedNodeNames) {
646
+ node = this.nodes[nodeName];
647
+ if (constants_1.STARTING_NODE_TYPES.includes(node.type)) {
648
+ if (node.disabled === true) {
649
+ continue;
682
650
  }
683
- // If none of the above did find anything simply return the
684
- // first parent node in the list
685
- return this.nodes[nodeNames[0]];
651
+ return node;
686
652
  }
687
- return this.__getStartNode(Object.keys(this.nodes));
688
- }
689
- getConnectionsBetweenNodes(sources, targets) {
690
- const result = [];
691
- for (const source of sources) {
692
- for (const type of Object.keys(this.connectionsBySourceNode[source] ?? {})) {
693
- for (const sourceIndex of Object.keys(this.connectionsBySourceNode[source][type])) {
694
- for (const connectionIndex of Object.keys(this.connectionsBySourceNode[source][type][parseInt(sourceIndex, 10)] ?? [])) {
695
- const targetConnectionData = this.connectionsBySourceNode[source][type][parseInt(sourceIndex, 10)]?.[parseInt(connectionIndex, 10)];
696
- if (targetConnectionData && targets.includes(targetConnectionData?.node)) {
697
- result.push([
698
- {
699
- node: source,
700
- index: parseInt(sourceIndex, 10),
701
- type: type,
702
- },
703
- targetConnectionData,
704
- ]);
705
- }
653
+ }
654
+ return undefined;
655
+ }
656
+ /**
657
+ * Returns the start node to start the workflow from
658
+ *
659
+ */
660
+ getStartNode(destinationNode) {
661
+ if (destinationNode) {
662
+ // Find the highest parent nodes of the given one
663
+ const nodeNames = this.getHighestNode(destinationNode);
664
+ if (nodeNames.length === 0) {
665
+ // If no parent nodes have been found then only the destination-node
666
+ // is in the tree so add that one
667
+ nodeNames.push(destinationNode);
668
+ }
669
+ // Check which node to return as start node
670
+ const node = this.__getStartNode(nodeNames);
671
+ if (node !== undefined) {
672
+ return node;
673
+ }
674
+ // If none of the above did find anything simply return the
675
+ // first parent node in the list
676
+ return this.nodes[nodeNames[0]];
677
+ }
678
+ return this.__getStartNode(Object.keys(this.nodes));
679
+ }
680
+ getConnectionsBetweenNodes(sources, targets) {
681
+ const result = [];
682
+ for (const source of sources) {
683
+ for (const type of Object.keys(this.connectionsBySourceNode[source] ?? {})) {
684
+ for (const sourceIndex of Object.keys(this.connectionsBySourceNode[source][type])) {
685
+ for (const connectionIndex of Object.keys(this.connectionsBySourceNode[source][type][parseInt(sourceIndex, 10)] ?? [])) {
686
+ const targetConnectionData = this.connectionsBySourceNode[source][type][parseInt(sourceIndex, 10)]?.[parseInt(connectionIndex, 10)];
687
+ if (targetConnectionData && targets.includes(targetConnectionData?.node)) {
688
+ result.push([
689
+ {
690
+ node: source,
691
+ index: parseInt(sourceIndex, 10),
692
+ type: type,
693
+ },
694
+ targetConnectionData,
695
+ ]);
706
696
  }
707
697
  }
708
698
  }
709
699
  }
710
- return result;
711
700
  }
701
+ return result;
712
702
  }
713
- exports.Workflow = Workflow;
714
- });
703
+ }
704
+ exports.Workflow = Workflow;
715
705
  //# sourceMappingURL=workflow.js.map