n8n-workflow 2.31.1 → 2.32.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 (408) 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 -49
  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-establishment-hooks.js +7 -3
  340. package/dist/esm/execution-context-establishment-hooks.js.map +1 -1
  341. package/dist/esm/execution-context.d.ts +14 -14
  342. package/dist/esm/execution-context.d.ts.map +1 -1
  343. package/dist/esm/execution-status.d.ts +2 -2
  344. package/dist/esm/execution-status.d.ts.map +1 -1
  345. package/dist/esm/expression-evaluator-proxy.d.ts.map +1 -1
  346. package/dist/esm/expression-sandboxing.d.ts.map +1 -1
  347. package/dist/esm/expression-sandboxing.js.map +1 -1
  348. package/dist/esm/expression.d.ts.map +1 -1
  349. package/dist/esm/expression.js.map +1 -1
  350. package/dist/esm/expressions/expression-helpers.d.ts.map +1 -1
  351. package/dist/esm/extensions/boolean-extensions.d.ts +1 -1
  352. package/dist/esm/extensions/expression-extension.d.ts.map +1 -1
  353. package/dist/esm/extensions/expression-parser.d.ts.map +1 -1
  354. package/dist/esm/extensions/extended-functions.d.ts +10 -18
  355. package/dist/esm/extensions/extended-functions.d.ts.map +1 -1
  356. package/dist/esm/extensions/number-extensions.js.map +1 -1
  357. package/dist/esm/extensions/string-extensions.d.ts +1 -1
  358. package/dist/esm/extensions/string-extensions.d.ts.map +1 -1
  359. package/dist/esm/extensions/string-extensions.js.map +1 -1
  360. package/dist/esm/extensions/utils.d.ts.map +1 -1
  361. package/dist/esm/from-ai-parse-utils.js.map +1 -1
  362. package/dist/esm/interfaces.d.ts +112 -22
  363. package/dist/esm/interfaces.d.ts.map +1 -1
  364. package/dist/esm/interfaces.js.map +1 -1
  365. package/dist/esm/logger-proxy.d.ts.map +1 -1
  366. package/dist/esm/message-event-bus.d.ts +184 -165
  367. package/dist/esm/message-event-bus.d.ts.map +1 -1
  368. package/dist/esm/message-event-bus.js +2 -2
  369. package/dist/esm/message-event-bus.js.map +1 -1
  370. package/dist/esm/node-grouping-validation.d.ts +6 -0
  371. package/dist/esm/node-grouping-validation.d.ts.map +1 -1
  372. package/dist/esm/node-grouping-validation.js +34 -5
  373. package/dist/esm/node-grouping-validation.js.map +1 -1
  374. package/dist/esm/node-helpers.d.ts.map +1 -1
  375. package/dist/esm/node-helpers.js +3 -0
  376. package/dist/esm/node-helpers.js.map +1 -1
  377. package/dist/esm/node-parameters/filter-parameter.d.ts.map +1 -1
  378. package/dist/esm/node-parameters/filter-parameter.js.map +1 -1
  379. package/dist/esm/node-reference-parser-utils.js.map +1 -1
  380. package/dist/esm/run-execution-data-factory.js.map +1 -1
  381. package/dist/esm/schemas.d.ts +13 -13
  382. package/dist/esm/schemas.d.ts.map +1 -1
  383. package/dist/esm/schemas.js +1 -0
  384. package/dist/esm/schemas.js.map +1 -1
  385. package/dist/esm/telemetry-helpers.d.ts.map +1 -1
  386. package/dist/esm/telemetry-helpers.js.map +1 -1
  387. package/dist/esm/type-guards.d.ts +3 -3
  388. package/dist/esm/type-guards.d.ts.map +1 -1
  389. package/dist/esm/type-validation.d.ts.map +1 -1
  390. package/dist/esm/type-validation.js.map +1 -1
  391. package/dist/esm/typecheck.tsbuildinfo +1 -1
  392. package/dist/esm/utils.d.ts +2 -2
  393. package/dist/esm/utils.d.ts.map +1 -1
  394. package/dist/esm/utils.js.map +1 -1
  395. package/dist/esm/versioned-node-type.d.ts.map +1 -1
  396. package/dist/esm/workflow-data-proxy.d.ts.map +1 -1
  397. package/dist/esm/workflow-data-proxy.js.map +1 -1
  398. package/dist/esm/workflow-diff.d.ts +2 -1
  399. package/dist/esm/workflow-diff.d.ts.map +1 -1
  400. package/dist/esm/workflow-diff.js +3 -1
  401. package/dist/esm/workflow-diff.js.map +1 -1
  402. package/dist/esm/workflow-expression.d.ts.map +1 -1
  403. package/dist/esm/workflow-expression.js.map +1 -1
  404. package/dist/esm/workflow-structure-validation.d.ts.map +1 -1
  405. package/dist/esm/workflow-structure-validation.js.map +1 -1
  406. package/dist/esm/workflow.d.ts.map +1 -1
  407. package/dist/esm/workflow.js.map +1 -1
  408. package/package.json +9 -8
@@ -1,460 +1,450 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateZodSchema = generateZodSchema;
4
+ exports.extractFromAICalls = extractFromAICalls;
5
+ exports.traverseNodeParameters = traverseNodeParameters;
6
+ exports.traverseNodeParametersWithParamNames = traverseNodeParametersWithParamNames;
7
+ exports.isFromAIOnlyExpression = isFromAIOnlyExpression;
8
+ exports.collectExpressionDefaults = collectExpressionDefaults;
9
+ exports.findDisallowedChatToolExpressions = findDisallowedChatToolExpressions;
10
+ const zod_1 = require("zod");
11
+ const constants_1 = require("./constants");
12
+ const expression_helpers_1 = require("./expressions/expression-helpers");
13
+ const utils_1 = require("./utils");
14
+ class ParseError extends Error {
15
+ }
16
+ /**
17
+ * Generates a Zod schema based on the provided FromAIArgument placeholder.
18
+ * @param placeholder The FromAIArgument object containing key, type, description, and defaultValue.
19
+ * @returns A Zod schema corresponding to the placeholder's type and constraints.
20
+ */
21
+ function generateZodSchema(placeholder) {
22
+ let schema;
23
+ switch (placeholder.type?.toLowerCase()) {
24
+ case 'string':
25
+ schema = zod_1.z.string();
26
+ break;
27
+ case 'number':
28
+ schema = zod_1.z.number();
29
+ break;
30
+ case 'boolean':
31
+ schema = zod_1.z.boolean();
32
+ break;
33
+ case 'json': {
34
+ // Create a custom schema to validate that the incoming data is either a non-empty object or a non-empty array.
35
+ const customSchema = zod_1.z.custom((data) => {
36
+ if (data === null || typeof data !== 'object')
37
+ return false;
38
+ if (Array.isArray(data)) {
39
+ return data.length > 0;
40
+ }
41
+ return Object.keys(data).length > 0;
42
+ }, {
43
+ message: 'Value must be a non-empty object or a non-empty array',
44
+ });
45
+ // Cast the custom schema to a type that includes our JSON metadata.
46
+ const typedSchema = customSchema;
47
+ // Attach the updated `jsonSchema` metadata to the internal definition.
48
+ typedSchema._def.jsonSchema = {
49
+ anyOf: [
50
+ {
51
+ type: 'object',
52
+ minProperties: 1,
53
+ additionalProperties: true,
54
+ },
55
+ {
56
+ type: 'array',
57
+ minItems: 1,
58
+ },
59
+ ],
60
+ };
61
+ schema = typedSchema;
62
+ break;
63
+ }
64
+ default:
65
+ schema = zod_1.z.string();
5
66
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "zod", "./constants", "./expressions/expression-helpers", "./utils"], factory);
67
+ if (placeholder.description) {
68
+ schema = schema.describe(`${schema.description ?? ''} ${placeholder.description}`.trim());
8
69
  }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.generateZodSchema = generateZodSchema;
13
- exports.extractFromAICalls = extractFromAICalls;
14
- exports.traverseNodeParameters = traverseNodeParameters;
15
- exports.traverseNodeParametersWithParamNames = traverseNodeParametersWithParamNames;
16
- exports.isFromAIOnlyExpression = isFromAIOnlyExpression;
17
- exports.collectExpressionDefaults = collectExpressionDefaults;
18
- exports.findDisallowedChatToolExpressions = findDisallowedChatToolExpressions;
19
- const zod_1 = require("zod");
20
- const constants_1 = require("./constants");
21
- const expression_helpers_1 = require("./expressions/expression-helpers");
22
- const utils_1 = require("./utils");
23
- class ParseError extends Error {
70
+ if (placeholder.defaultValue !== undefined) {
71
+ schema = schema.default(placeholder.defaultValue);
24
72
  }
25
- /**
26
- * Generates a Zod schema based on the provided FromAIArgument placeholder.
27
- * @param placeholder The FromAIArgument object containing key, type, description, and defaultValue.
28
- * @returns A Zod schema corresponding to the placeholder's type and constraints.
29
- */
30
- function generateZodSchema(placeholder) {
31
- let schema;
32
- switch (placeholder.type?.toLowerCase()) {
33
- case 'string':
34
- schema = zod_1.z.string();
35
- break;
36
- case 'number':
37
- schema = zod_1.z.number();
38
- break;
39
- case 'boolean':
40
- schema = zod_1.z.boolean();
41
- break;
42
- case 'json': {
43
- // Create a custom schema to validate that the incoming data is either a non-empty object or a non-empty array.
44
- const customSchema = zod_1.z.custom((data) => {
45
- if (data === null || typeof data !== 'object')
46
- return false;
47
- if (Array.isArray(data)) {
48
- return data.length > 0;
49
- }
50
- return Object.keys(data).length > 0;
51
- }, {
52
- message: 'Value must be a non-empty object or a non-empty array',
53
- });
54
- // Cast the custom schema to a type that includes our JSON metadata.
55
- const typedSchema = customSchema;
56
- // Attach the updated `jsonSchema` metadata to the internal definition.
57
- typedSchema._def.jsonSchema = {
58
- anyOf: [
59
- {
60
- type: 'object',
61
- minProperties: 1,
62
- additionalProperties: true,
63
- },
64
- {
65
- type: 'array',
66
- minItems: 1,
67
- },
68
- ],
69
- };
70
- schema = typedSchema;
71
- break;
72
- }
73
- default:
74
- schema = zod_1.z.string();
75
- }
76
- if (placeholder.description) {
77
- schema = schema.describe(`${schema.description ?? ''} ${placeholder.description}`.trim());
78
- }
79
- if (placeholder.defaultValue !== undefined) {
80
- schema = schema.default(placeholder.defaultValue);
81
- }
82
- return schema;
73
+ return schema;
74
+ }
75
+ function isFromAIArgumentType(value) {
76
+ return ['string', 'number', 'boolean', 'json'].includes(value.toLowerCase());
77
+ }
78
+ /**
79
+ * Parses the default value, preserving its original type.
80
+ * @param value The default value as a string.
81
+ * @param type The expected type of the default value.
82
+ * @returns The parsed default value in its appropriate type.
83
+ */
84
+ function parseDefaultValue(value, type = 'string') {
85
+ if (value === undefined)
86
+ return value;
87
+ const lowerValue = value.toLowerCase();
88
+ if (type === 'string') {
89
+ return value.toString();
83
90
  }
84
- function isFromAIArgumentType(value) {
85
- return ['string', 'number', 'boolean', 'json'].includes(value.toLowerCase());
91
+ if (type === 'boolean' && (lowerValue === 'true' || lowerValue === 'false'))
92
+ return lowerValue === 'true';
93
+ if (type === 'number' && !isNaN(Number(value)))
94
+ return Number(value);
95
+ // For type 'json' or any other case, attempt to parse as JSON
96
+ try {
97
+ return (0, utils_1.jsonParse)(value);
86
98
  }
87
- /**
88
- * Parses the default value, preserving its original type.
89
- * @param value The default value as a string.
90
- * @param type The expected type of the default value.
91
- * @returns The parsed default value in its appropriate type.
92
- */
93
- function parseDefaultValue(value, type = 'string') {
94
- if (value === undefined)
95
- return value;
96
- const lowerValue = value.toLowerCase();
97
- if (type === 'string') {
98
- return value.toString();
99
- }
100
- if (type === 'boolean' && (lowerValue === 'true' || lowerValue === 'false'))
101
- return lowerValue === 'true';
102
- if (type === 'number' && !isNaN(Number(value)))
103
- return Number(value);
104
- // For type 'json' or any other case, attempt to parse as JSON
105
- try {
106
- return (0, utils_1.jsonParse)(value);
107
- }
108
- catch {
109
- return value;
110
- }
99
+ catch {
100
+ return value;
111
101
  }
112
- /**
113
- * Parses the arguments of a single $fromAI function call.
114
- * @param argsString The string containing the function arguments.
115
- * @returns A FromAIArgument object.
116
- */
117
- function parseArguments(argsString) {
118
- // Split arguments by commas not inside quotes
119
- const args = [];
120
- let currentArg = '';
121
- let inQuotes = false;
122
- let quoteChar = '';
123
- let escapeNext = false;
124
- for (let i = 0; i < argsString.length; i++) {
125
- const char = argsString[i];
126
- if (escapeNext) {
127
- currentArg += char;
128
- escapeNext = false;
129
- continue;
130
- }
131
- if (char === '\\') {
132
- escapeNext = true;
133
- continue;
134
- }
135
- if (['"', "'", '`'].includes(char)) {
136
- if (!inQuotes) {
137
- inQuotes = true;
138
- quoteChar = char;
139
- currentArg += char;
140
- }
141
- else if (char === quoteChar) {
142
- inQuotes = false;
143
- quoteChar = '';
144
- currentArg += char;
145
- }
146
- else {
147
- currentArg += char;
148
- }
149
- continue;
150
- }
151
- if (char === ',' && !inQuotes) {
152
- args.push(currentArg.trim());
153
- currentArg = '';
154
- continue;
155
- }
102
+ }
103
+ /**
104
+ * Parses the arguments of a single $fromAI function call.
105
+ * @param argsString The string containing the function arguments.
106
+ * @returns A FromAIArgument object.
107
+ */
108
+ function parseArguments(argsString) {
109
+ // Split arguments by commas not inside quotes
110
+ const args = [];
111
+ let currentArg = '';
112
+ let inQuotes = false;
113
+ let quoteChar = '';
114
+ let escapeNext = false;
115
+ for (let i = 0; i < argsString.length; i++) {
116
+ const char = argsString[i];
117
+ if (escapeNext) {
156
118
  currentArg += char;
119
+ escapeNext = false;
120
+ continue;
157
121
  }
158
- if (currentArg) {
159
- args.push(currentArg.trim());
122
+ if (char === '\\') {
123
+ escapeNext = true;
124
+ continue;
160
125
  }
161
- // Remove surrounding quotes if present
162
- const cleanArgs = args.map((arg) => {
163
- const trimmed = arg.trim();
164
- if ((trimmed.startsWith("'") && trimmed.endsWith("'")) ||
165
- (trimmed.startsWith('`') && trimmed.endsWith('`')) ||
166
- (trimmed.startsWith('"') && trimmed.endsWith('"'))) {
167
- return trimmed
168
- .slice(1, -1)
169
- .replace(/\\'/g, "'")
170
- .replace(/\\`/g, '`')
171
- .replace(/\\"/g, '"')
172
- .replace(/\\\\/g, '\\');
173
- }
174
- return trimmed;
175
- });
176
- const type = cleanArgs?.[2] ?? 'string';
177
- if (!isFromAIArgumentType(type)) {
178
- throw new ParseError(`Invalid type: ${type}`);
179
- }
180
- return {
181
- key: cleanArgs[0] || '',
182
- description: cleanArgs[1],
183
- type,
184
- defaultValue: parseDefaultValue(cleanArgs[3], type),
185
- };
186
- }
187
- /**
188
- * Extracts all $fromAI calls from a given string
189
- * @param str The string to search for $fromAI calls.
190
- * @returns An array of FromAIArgument objects.
191
- *
192
- * This method uses a regular expression to find the start of each $fromAI function call
193
- * in the input string. It then employs a character-by-character parsing approach to
194
- * accurately extract the arguments of each call, handling nested parentheses and quoted strings.
195
- *
196
- * The parsing process:
197
- * 1. Finds the starting position of a $fromAI call using regex.
198
- * 2. Iterates through characters, keeping track of parentheses depth and quote status.
199
- * 3. Handles escaped characters within quotes to avoid premature quote closing.
200
- * 4. Builds the argument string until the matching closing parenthesis is found.
201
- * 5. Parses the extracted argument string into a FromAIArgument object.
202
- * 6. Repeats the process for all $fromAI calls in the input string.
203
- *
204
- */
205
- function extractFromAICalls(str) {
206
- const args = [];
207
- // Regular expression to match the start of a $fromAI function call
208
- const pattern = /\$fromAI\s*\(\s*/gi;
209
- let match;
210
- while ((match = pattern.exec(str)) !== null) {
211
- const startIndex = match.index + match[0].length;
212
- let current = startIndex;
213
- let inQuotes = false;
214
- let quoteChar = '';
215
- let parenthesesCount = 1;
216
- let argsString = '';
217
- // Parse the arguments string, handling nested parentheses and quotes
218
- while (current < str.length && parenthesesCount > 0) {
219
- const char = str[current];
220
- if (inQuotes) {
221
- // Handle characters inside quotes, including escaped characters
222
- if (char === '\\' && current + 1 < str.length) {
223
- argsString += char + str[current + 1];
224
- current += 2;
225
- continue;
226
- }
227
- if (char === quoteChar) {
228
- inQuotes = false;
229
- quoteChar = '';
230
- }
231
- argsString += char;
232
- }
233
- else {
234
- // Handle characters outside quotes
235
- if (['"', "'", '`'].includes(char)) {
236
- inQuotes = true;
237
- quoteChar = char;
238
- }
239
- else if (char === '(') {
240
- parenthesesCount++;
241
- }
242
- else if (char === ')') {
243
- parenthesesCount--;
244
- }
245
- // Only add characters if we're still inside the main parentheses
246
- if (parenthesesCount > 0 || char !== ')') {
247
- argsString += char;
248
- }
249
- }
250
- current++;
126
+ if (['"', "'", '`'].includes(char)) {
127
+ if (!inQuotes) {
128
+ inQuotes = true;
129
+ quoteChar = char;
130
+ currentArg += char;
251
131
  }
252
- // If parentheses are balanced, parse the arguments
253
- if (parenthesesCount === 0) {
254
- try {
255
- const parsedArgs = parseArguments(argsString);
256
- args.push(parsedArgs);
257
- }
258
- catch (error) {
259
- // If parsing fails, throw an ParseError with details
260
- throw new ParseError(`Failed to parse $fromAI arguments: ${argsString}: ${String(error)}`);
261
- }
132
+ else if (char === quoteChar) {
133
+ inQuotes = false;
134
+ quoteChar = '';
135
+ currentArg += char;
262
136
  }
263
137
  else {
264
- // Log an error if parentheses are unbalanced
265
- throw new ParseError(`Unbalanced parentheses while parsing $fromAI call: ${str.slice(startIndex)}`);
138
+ currentArg += char;
266
139
  }
140
+ continue;
267
141
  }
268
- return args;
269
- }
270
- /**
271
- * Recursively traverses the nodeParameters object to find all $fromAI calls.
272
- * @param payload The current object or value being traversed.
273
- * @param collectedArgs The array collecting FromAIArgument objects.
274
- */
275
- function traverseNodeParameters(payload, collectedArgs) {
276
- if (typeof payload === 'string') {
277
- const fromAICalls = extractFromAICalls(payload);
278
- fromAICalls.forEach((call) => collectedArgs.push(call));
279
- }
280
- else if (Array.isArray(payload)) {
281
- payload.forEach((item) => traverseNodeParameters(item, collectedArgs));
282
- }
283
- else if (typeof payload === 'object' && payload !== null) {
284
- Object.values(payload).forEach((value) => traverseNodeParameters(value, collectedArgs));
142
+ if (char === ',' && !inQuotes) {
143
+ args.push(currentArg.trim());
144
+ currentArg = '';
145
+ continue;
285
146
  }
147
+ currentArg += char;
286
148
  }
287
- function traverseNodeParametersWithParamNames(payload, collectedArgs, name) {
288
- if (typeof payload === 'string') {
289
- const fromAICalls = extractFromAICalls(payload);
290
- fromAICalls.forEach((call) => collectedArgs.set(name, call));
291
- }
292
- else if (Array.isArray(payload)) {
293
- payload.forEach((item, index) => traverseNodeParametersWithParamNames(item, collectedArgs, name + `[${index}]`));
294
- }
295
- else if (typeof payload === 'object' && payload !== null) {
296
- for (const [key, value] of Object.entries(payload)) {
297
- traverseNodeParametersWithParamNames(value, collectedArgs, name ? name + '.' + key : key);
298
- }
299
- }
149
+ if (currentArg) {
150
+ args.push(currentArg.trim());
300
151
  }
301
- /**
302
- * Checks whether an expression string contains only a single `$fromAI()` call
303
- * with literal arguments and nothing else.
304
- *
305
- * Only `$fromAI()` expressions are supported in chat hub tool parameters.
306
- * Arguments must be literals (strings, numbers, booleans) — nested function
307
- * calls like `$fromAI(evil())` are not supported.
308
- */
309
- function isFromAIOnlyExpression(expr) {
310
- let str = expr;
311
- // Strip leading `=` prefix
312
- if (str.startsWith('=')) {
313
- str = str.slice(1);
314
- }
315
- str = str.trim();
316
- // Strip `{{ }}` delimiters if present
317
- if (str.startsWith('{{') && str.endsWith('}}')) {
318
- str = str.slice(2, -2).trim();
319
- }
320
- // Strip optional auto-generated marker comment
321
- if (str.startsWith(constants_1.FROM_AI_AUTO_GENERATED_MARKER)) {
322
- str = str.slice(constants_1.FROM_AI_AUTO_GENERATED_MARKER.length).trim();
152
+ // Remove surrounding quotes if present
153
+ const cleanArgs = args.map((arg) => {
154
+ const trimmed = arg.trim();
155
+ if ((trimmed.startsWith("'") && trimmed.endsWith("'")) ||
156
+ (trimmed.startsWith('`') && trimmed.endsWith('`')) ||
157
+ (trimmed.startsWith('"') && trimmed.endsWith('"'))) {
158
+ return trimmed
159
+ .slice(1, -1)
160
+ .replace(/\\'/g, "'")
161
+ .replace(/\\`/g, '`')
162
+ .replace(/\\"/g, '"')
163
+ .replace(/\\\\/g, '\\');
323
164
  }
324
- // Must start with $fromAI( (case-insensitive)
325
- const fromAIPattern = /^\$fromAI\s*\(/i;
326
- const match = fromAIPattern.exec(str);
327
- if (!match) {
328
- return false;
329
- }
330
- // Walk character by character from after the opening `(` to find matching `)`
331
- // Reject any nested parentheses outside quotes (indicates function calls)
332
- const startIndex = match[0].length;
165
+ return trimmed;
166
+ });
167
+ const type = cleanArgs?.[2] ?? 'string';
168
+ if (!isFromAIArgumentType(type)) {
169
+ throw new ParseError(`Invalid type: ${type}`);
170
+ }
171
+ return {
172
+ key: cleanArgs[0] || '',
173
+ description: cleanArgs[1],
174
+ type,
175
+ defaultValue: parseDefaultValue(cleanArgs[3], type),
176
+ };
177
+ }
178
+ /**
179
+ * Extracts all $fromAI calls from a given string
180
+ * @param str The string to search for $fromAI calls.
181
+ * @returns An array of FromAIArgument objects.
182
+ *
183
+ * This method uses a regular expression to find the start of each $fromAI function call
184
+ * in the input string. It then employs a character-by-character parsing approach to
185
+ * accurately extract the arguments of each call, handling nested parentheses and quoted strings.
186
+ *
187
+ * The parsing process:
188
+ * 1. Finds the starting position of a $fromAI call using regex.
189
+ * 2. Iterates through characters, keeping track of parentheses depth and quote status.
190
+ * 3. Handles escaped characters within quotes to avoid premature quote closing.
191
+ * 4. Builds the argument string until the matching closing parenthesis is found.
192
+ * 5. Parses the extracted argument string into a FromAIArgument object.
193
+ * 6. Repeats the process for all $fromAI calls in the input string.
194
+ *
195
+ */
196
+ function extractFromAICalls(str) {
197
+ const args = [];
198
+ // Regular expression to match the start of a $fromAI function call
199
+ const pattern = /\$fromAI\s*\(\s*/gi;
200
+ let match;
201
+ while ((match = pattern.exec(str)) !== null) {
202
+ const startIndex = match.index + match[0].length;
333
203
  let current = startIndex;
334
204
  let inQuotes = false;
335
205
  let quoteChar = '';
336
- let depth = 1;
337
- let lastOutsideChar = '';
338
- while (current < str.length && depth > 0) {
206
+ let parenthesesCount = 1;
207
+ let argsString = '';
208
+ // Parse the arguments string, handling nested parentheses and quotes
209
+ while (current < str.length && parenthesesCount > 0) {
339
210
  const char = str[current];
340
211
  if (inQuotes) {
212
+ // Handle characters inside quotes, including escaped characters
341
213
  if (char === '\\' && current + 1 < str.length) {
342
- // Skip escaped character
214
+ argsString += char + str[current + 1];
343
215
  current += 2;
344
216
  continue;
345
217
  }
346
- // Reject template literal interpolation `${...}` inside backtick strings
347
- if (quoteChar === '`' &&
348
- char === '$' &&
349
- current + 1 < str.length &&
350
- str[current + 1] === '{') {
351
- return false;
352
- }
353
218
  if (char === quoteChar) {
354
219
  inQuotes = false;
355
220
  quoteChar = '';
356
221
  }
222
+ argsString += char;
357
223
  }
358
224
  else {
225
+ // Handle characters outside quotes
359
226
  if (['"', "'", '`'].includes(char)) {
360
- // Reject tagged template literals: identifier immediately before backtick
361
- if (char === '`' && /[a-zA-Z0-9_]/.test(lastOutsideChar)) {
362
- return false;
363
- }
364
227
  inQuotes = true;
365
228
  quoteChar = char;
366
229
  }
367
- else if (char === ')') {
368
- depth--;
230
+ else if (char === '(') {
231
+ parenthesesCount++;
369
232
  }
370
- else if (!/[a-zA-Z0-9.,\s-]/.test(char)) {
371
- // Outside quotes, only allow literal-value characters:
372
- // alphanumeric (true/false, numbers), decimal point, minus (negative numbers),
373
- // comma (argument separator), and whitespace.
374
- // This rejects operators (+, *, etc.), $ (variable references like $env),
375
- // brackets, and other expression syntax.
376
- return false;
233
+ else if (char === ')') {
234
+ parenthesesCount--;
377
235
  }
378
- if (!/\s/.test(char)) {
379
- lastOutsideChar = char;
236
+ // Only add characters if we're still inside the main parentheses
237
+ if (parenthesesCount > 0 || char !== ')') {
238
+ argsString += char;
380
239
  }
381
240
  }
382
241
  current++;
383
242
  }
384
- // Unbalanced parentheses
385
- if (depth !== 0) {
386
- return false;
243
+ // If parentheses are balanced, parse the arguments
244
+ if (parenthesesCount === 0) {
245
+ try {
246
+ const parsedArgs = parseArguments(argsString);
247
+ args.push(parsedArgs);
248
+ }
249
+ catch (error) {
250
+ // If parsing fails, throw an ParseError with details
251
+ throw new ParseError(`Failed to parse $fromAI arguments: ${argsString}: ${String(error)}`);
252
+ }
253
+ }
254
+ else {
255
+ // Log an error if parentheses are unbalanced
256
+ throw new ParseError(`Unbalanced parentheses while parsing $fromAI call: ${str.slice(startIndex)}`);
257
+ }
258
+ }
259
+ return args;
260
+ }
261
+ /**
262
+ * Recursively traverses the nodeParameters object to find all $fromAI calls.
263
+ * @param payload The current object or value being traversed.
264
+ * @param collectedArgs The array collecting FromAIArgument objects.
265
+ */
266
+ function traverseNodeParameters(payload, collectedArgs) {
267
+ if (typeof payload === 'string') {
268
+ const fromAICalls = extractFromAICalls(payload);
269
+ fromAICalls.forEach((call) => collectedArgs.push(call));
270
+ }
271
+ else if (Array.isArray(payload)) {
272
+ payload.forEach((item) => traverseNodeParameters(item, collectedArgs));
273
+ }
274
+ else if (typeof payload === 'object' && payload !== null) {
275
+ Object.values(payload).forEach((value) => traverseNodeParameters(value, collectedArgs));
276
+ }
277
+ }
278
+ function traverseNodeParametersWithParamNames(payload, collectedArgs, name) {
279
+ if (typeof payload === 'string') {
280
+ const fromAICalls = extractFromAICalls(payload);
281
+ fromAICalls.forEach((call) => collectedArgs.set(name, call));
282
+ }
283
+ else if (Array.isArray(payload)) {
284
+ payload.forEach((item, index) => traverseNodeParametersWithParamNames(item, collectedArgs, name + `[${index}]`));
285
+ }
286
+ else if (typeof payload === 'object' && payload !== null) {
287
+ for (const [key, value] of Object.entries(payload)) {
288
+ traverseNodeParametersWithParamNames(value, collectedArgs, name ? name + '.' + key : key);
387
289
  }
388
- // Everything after the closing `)` must be whitespace only
389
- const remainder = str.slice(current).trim();
390
- return remainder.length === 0;
391
290
  }
392
- /**
393
- * Recursive helper function to collect default values from node properties and their nested options.
394
- */
395
- function collectDefaults(props, defaults) {
396
- for (const prop of props) {
397
- if (typeof prop.default === 'string' && (0, expression_helpers_1.isExpression)(prop.default)) {
398
- defaults.add(prop.default);
291
+ }
292
+ /**
293
+ * Checks whether an expression string contains only a single `$fromAI()` call
294
+ * with literal arguments and nothing else.
295
+ *
296
+ * Only `$fromAI()` expressions are supported in chat hub tool parameters.
297
+ * Arguments must be literals (strings, numbers, booleans) — nested function
298
+ * calls like `$fromAI(evil())` are not supported.
299
+ */
300
+ function isFromAIOnlyExpression(expr) {
301
+ let str = expr;
302
+ // Strip leading `=` prefix
303
+ if (str.startsWith('=')) {
304
+ str = str.slice(1);
305
+ }
306
+ str = str.trim();
307
+ // Strip `{{ }}` delimiters if present
308
+ if (str.startsWith('{{') && str.endsWith('}}')) {
309
+ str = str.slice(2, -2).trim();
310
+ }
311
+ // Strip optional auto-generated marker comment
312
+ if (str.startsWith(constants_1.FROM_AI_AUTO_GENERATED_MARKER)) {
313
+ str = str.slice(constants_1.FROM_AI_AUTO_GENERATED_MARKER.length).trim();
314
+ }
315
+ // Must start with $fromAI( (case-insensitive)
316
+ const fromAIPattern = /^\$fromAI\s*\(/i;
317
+ const match = fromAIPattern.exec(str);
318
+ if (!match) {
319
+ return false;
320
+ }
321
+ // Walk character by character from after the opening `(` to find matching `)`
322
+ // Reject any nested parentheses outside quotes (indicates function calls)
323
+ const startIndex = match[0].length;
324
+ let current = startIndex;
325
+ let inQuotes = false;
326
+ let quoteChar = '';
327
+ let depth = 1;
328
+ let lastOutsideChar = '';
329
+ while (current < str.length && depth > 0) {
330
+ const char = str[current];
331
+ if (inQuotes) {
332
+ if (char === '\\' && current + 1 < str.length) {
333
+ // Skip escaped character
334
+ current += 2;
335
+ continue;
399
336
  }
400
- if (prop.options) {
401
- for (const option of prop.options) {
402
- // INodePropertyCollection has `values: INodeProperties[]`
403
- if ('values' in option && Array.isArray(option.values)) {
404
- collectDefaults(option.values, defaults);
405
- }
406
- // INodeProperties has `options` and `default`
407
- if ('type' in option && 'default' in option) {
408
- const nested = option;
409
- if (typeof nested.default === 'string' && (0, expression_helpers_1.isExpression)(nested.default)) {
410
- defaults.add(nested.default);
411
- }
412
- if (nested.options) {
413
- collectDefaults([nested], defaults);
414
- }
415
- }
337
+ // Reject template literal interpolation `${...}` inside backtick strings
338
+ if (quoteChar === '`' &&
339
+ char === '$' &&
340
+ current + 1 < str.length &&
341
+ str[current + 1] === '{') {
342
+ return false;
343
+ }
344
+ if (char === quoteChar) {
345
+ inQuotes = false;
346
+ quoteChar = '';
347
+ }
348
+ }
349
+ else {
350
+ if (['"', "'", '`'].includes(char)) {
351
+ // Reject tagged template literals: identifier immediately before backtick
352
+ if (char === '`' && /[a-zA-Z0-9_]/.test(lastOutsideChar)) {
353
+ return false;
416
354
  }
355
+ inQuotes = true;
356
+ quoteChar = char;
357
+ }
358
+ else if (char === ')') {
359
+ depth--;
360
+ }
361
+ else if (!/[a-zA-Z0-9.,\s-]/.test(char)) {
362
+ // Outside quotes, only allow literal-value characters:
363
+ // alphanumeric (true/false, numbers), decimal point, minus (negative numbers),
364
+ // comma (argument separator), and whitespace.
365
+ // This rejects operators (+, *, etc.), $ (variable references like $env),
366
+ // brackets, and other expression syntax.
367
+ return false;
368
+ }
369
+ if (!/\s/.test(char)) {
370
+ lastOutsideChar = char;
417
371
  }
418
372
  }
373
+ current++;
419
374
  }
420
- /**
421
- * Recursively collects all expression default values from node type properties.
422
- * Recurses into `options` (which can be INodeProperties[] or INodePropertyCollection[]).
423
- */
424
- function collectExpressionDefaults(properties) {
425
- const defaults = new Set();
426
- collectDefaults(properties, defaults);
427
- return defaults;
375
+ // Unbalanced parentheses
376
+ if (depth !== 0) {
377
+ return false;
428
378
  }
429
- /**
430
- * Recursively traverses node parameters and finds all string values that are
431
- * expressions other than supported `$fromAI()`-only expressions supported on Chat hub.
432
- * Returns an array of violations with their dot-notation paths.
433
- *
434
- * When `allowedExpressions` is provided, expressions matching a known node-description
435
- * default are not flagged as violations.
436
- */
437
- function findDisallowedChatToolExpressions(payload, path = '', allowedExpressions) {
438
- const violations = [];
439
- if (typeof payload === 'string') {
440
- if ((0, expression_helpers_1.isExpression)(payload) &&
441
- !isFromAIOnlyExpression(payload) &&
442
- !allowedExpressions?.has(payload)) {
443
- violations.push({ path, value: payload });
379
+ // Everything after the closing `)` must be whitespace only
380
+ const remainder = str.slice(current).trim();
381
+ return remainder.length === 0;
382
+ }
383
+ /**
384
+ * Recursive helper function to collect default values from node properties and their nested options.
385
+ */
386
+ function collectDefaults(props, defaults) {
387
+ for (const prop of props) {
388
+ if (typeof prop.default === 'string' && (0, expression_helpers_1.isExpression)(prop.default)) {
389
+ defaults.add(prop.default);
390
+ }
391
+ if (prop.options) {
392
+ for (const option of prop.options) {
393
+ // INodePropertyCollection has `values: INodeProperties[]`
394
+ if ('values' in option && Array.isArray(option.values)) {
395
+ collectDefaults(option.values, defaults);
396
+ }
397
+ // INodeProperties has `options` and `default`
398
+ if ('type' in option && 'default' in option) {
399
+ const nested = option;
400
+ if (typeof nested.default === 'string' && (0, expression_helpers_1.isExpression)(nested.default)) {
401
+ defaults.add(nested.default);
402
+ }
403
+ if (nested.options) {
404
+ collectDefaults([nested], defaults);
405
+ }
406
+ }
444
407
  }
445
408
  }
446
- else if (Array.isArray(payload)) {
447
- payload.forEach((item, index) => {
448
- violations.push(...findDisallowedChatToolExpressions(item, `${path}[${index}]`, allowedExpressions));
449
- });
409
+ }
410
+ }
411
+ /**
412
+ * Recursively collects all expression default values from node type properties.
413
+ * Recurses into `options` (which can be INodeProperties[] or INodePropertyCollection[]).
414
+ */
415
+ function collectExpressionDefaults(properties) {
416
+ const defaults = new Set();
417
+ collectDefaults(properties, defaults);
418
+ return defaults;
419
+ }
420
+ /**
421
+ * Recursively traverses node parameters and finds all string values that are
422
+ * expressions other than supported `$fromAI()`-only expressions supported on Chat hub.
423
+ * Returns an array of violations with their dot-notation paths.
424
+ *
425
+ * When `allowedExpressions` is provided, expressions matching a known node-description
426
+ * default are not flagged as violations.
427
+ */
428
+ function findDisallowedChatToolExpressions(payload, path = '', allowedExpressions) {
429
+ const violations = [];
430
+ if (typeof payload === 'string') {
431
+ if ((0, expression_helpers_1.isExpression)(payload) &&
432
+ !isFromAIOnlyExpression(payload) &&
433
+ !allowedExpressions?.has(payload)) {
434
+ violations.push({ path, value: payload });
450
435
  }
451
- else if (typeof payload === 'object' && payload !== null) {
452
- for (const [key, value] of Object.entries(payload)) {
453
- const newPath = path ? `${path}.${key}` : key;
454
- violations.push(...findDisallowedChatToolExpressions(value, newPath, allowedExpressions));
455
- }
436
+ }
437
+ else if (Array.isArray(payload)) {
438
+ payload.forEach((item, index) => {
439
+ violations.push(...findDisallowedChatToolExpressions(item, `${path}[${index}]`, allowedExpressions));
440
+ });
441
+ }
442
+ else if (typeof payload === 'object' && payload !== null) {
443
+ for (const [key, value] of Object.entries(payload)) {
444
+ const newPath = path ? `${path}.${key}` : key;
445
+ violations.push(...findDisallowedChatToolExpressions(value, newPath, allowedExpressions));
456
446
  }
457
- return violations;
458
447
  }
459
- });
448
+ return violations;
449
+ }
460
450
  //# sourceMappingURL=from-ai-parse-utils.js.map