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,798 +1,788 @@
1
+ "use strict";
1
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
2
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
3
4
  };
4
- (function (factory) {
5
- if (typeof module === "object" && typeof module.exports === "object") {
6
- var v = factory(require, exports);
7
- if (v !== undefined) module.exports = v;
8
- }
9
- else if (typeof define === "function" && define.amd) {
10
- define(["require", "exports", "js-base64", "jssha", "luxon", "md5", "title-case", "transliteration", "./number-extensions", "../errors/expression-extension.error", "../type-validation"], factory);
11
- }
12
- })(function (require, exports) {
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.stringExtensions = exports.SupportedHashAlgorithms = void 0;
16
- exports.toJsonString = toJsonString;
17
- exports.toDateTime = toDateTime;
18
- // NOTE: This file is intentionally mirrored in @n8n/expression-runtime/src/extensions/
19
- // for use inside the isolated VM. Changes here must be reflected there and vice versa.
20
- // TODO: Eliminate the duplication. The blocker is that @n8n/expression-runtime is
21
- // Vite-stubbed for browser builds (to exclude isolated-vm), which prevents n8n-workflow
22
- // from importing these extension utilities directly from the runtime package. Fix by
23
- // splitting @n8n/expression-runtime into a browser-safe extensions subpath (not stubbed)
24
- // and a node-only VM entry (stubbed).
25
- const js_base64_1 = require("js-base64");
26
- const jssha_1 = __importDefault(require("jssha"));
27
- const luxon_1 = require("luxon");
28
- const md5_1 = __importDefault(require("md5"));
29
- const title_case_1 = require("title-case");
30
- const transliteration_1 = require("transliteration");
31
- const number_extensions_1 = require("./number-extensions");
32
- const expression_extension_error_1 = require("../errors/expression-extension.error");
33
- const type_validation_1 = require("../type-validation");
34
- exports.SupportedHashAlgorithms = [
35
- 'md5',
36
- 'sha1',
37
- 'sha224',
38
- 'sha256',
39
- 'sha384',
40
- 'sha512',
41
- 'sha3',
42
- ];
43
- // All symbols from https://www.xe.com/symbols/ as for 2022/11/09
44
- const CURRENCY_REGEXP = /(\u004c\u0065\u006b|\u060b|\u0024|\u0192|\u20bc|\u0042\u0072|\u0042\u005a\u0024|\u0024\u0062|\u004b\u004d|\u0050|\u043b\u0432|\u0052\u0024|\u17db|\u00a5|\u20a1|\u006b\u006e|\u20b1|\u004b\u010d|\u006b\u0072|\u0052\u0044\u0024|\u00a3|\u20ac|\u00a2|\u0051|\u004c|\u0046\u0074|\u20b9|\u0052\u0070|\ufdfc|\u20aa|\u004a\u0024|\u20a9|\u20ad|\u0434\u0435\u043d|\u0052\u004d|\u20a8|\u20ae|\u004d\u0054|\u0043\u0024|\u20a6|\u0042\u002f\u002e|\u0047\u0073|\u0053\u002f\u002e|\u007a\u0142|\u006c\u0065\u0069|\u20bd|\u0414\u0438\u043d\u002e|\u0053|\u0052|\u0043\u0048\u0046|\u004e\u0054\u0024|\u0e3f|\u0054\u0054\u0024|\u20ba|\u20b4|\u0024\u0055|\u0042\u0073|\u20ab|\u005a\u0024)/gu;
45
- /*
46
- Extract the domain part from various inputs, including URLs, email addresses, and plain domains.
47
-
48
- /^(?:(?:https?|ftp):\/\/)? // Match optional http, https, or ftp protocols
49
- (?:mailto:)? // Match optional mailto:
50
- (?:\/\/)? // Match optional double slashes
51
- (?:www\.)? // Match optional www prefix
52
- (?:[-\w]*\.)? // Match any optional subdomain
53
- ( // Capture the domain part
54
- (?:(?:[-\w]+\.)+ // Match one or more subdomains
55
- (?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+) // Match top-level domain or Punycode encoded IDN(xn--80aswg.xn--p1ai)
56
- |localhost // Match localhost
57
- |\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} // Match IPv4 addresses
58
- )
59
- )
60
- (?::\d+)? // Match optional port number
61
- (?:\/[^\s?]*)? // Match optional path
62
- (?:\?[^\s#]*)? // Match optional query string
63
- (?:#[^\s]*)?$/i; // Match optional hash fragment
64
- */
65
- const DOMAIN_EXTRACT_REGEXP = /^(?:(?:https?|ftp):\/\/)?(?:mailto:)?(?:\/\/)?((?:www\.)?(?:(?:[-\w]+\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::\d+)?(?:\/[^\s?]*)?(?:\?[^\s#]*)?(?:#[^\s]*)?$/i;
66
- /*
67
- Matches domain names without the protocol or optional subdomains
68
-
69
- /^(?:www\.)? // Match optional www prefix
70
- ( // Capture the domain part
71
- (?:(?:[-\w]+\.)+ // Match one or more subdomains
72
- (?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+) // Match top-level domain or Punycode encoded IDN
73
- |localhost // Match localhost
74
- |\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} // Match IPv4 addresses
75
- )
76
- )
77
- (?::\d+)? // Match optional port number
78
- (?:\/[^\s?]*)? // Match optional path
79
- (?:\?[^\s#]*)? // Match optional query string
80
- (?:#[^\s]*)?$/i; // Match optional fragment at the end of the string
81
- */
82
- const DOMAIN_REGEXP = /^(?:www\.)?((?:(?:[-\w]+\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::\d+)?(?:\/[^\s?]*)?(?:\?[^\s#]*)?(?:#[^\s]*)?$/i;
83
- /*
84
- Matches email addresses
85
-
86
- /(
87
- ( // Capture local part of the email address
88
- ([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*) // One or more characters not in the set, followed by
89
- a period, followed by one or more characters not in the set
90
- |(".+") // Or one or more characters inside quotes
91
- )
92
- )
93
- @ // Match @ symbol
94
- (?<domain>( // Capture the domain part of the email address
95
- \[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\] // Match IPv4 address inside brackets
96
- |(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}) // Or match domain with at least two subdomains and TLD
97
- ))/;
98
- */
99
- const EMAIL_REGEXP = /(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@(?<domain>(\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
100
- /*
101
- Matches URLs with strict beginning and end of the string checks
102
-
103
- /^(?:(?:https?|ftp):\/\/) // Match http, https, or ftp protocols at the start of the string
104
- (?:www\.)? // Match optional www prefix
105
- ( // Capture the domain part
106
- (?:(?:[-\w]+\.)+ // Match one or more subdomains
107
- (?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+) // Match top-level domain or Punycode encoded IDN
108
- |localhost // Match localhost
109
- |\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} // Match IPv4 addresses
110
- )
111
- )
112
- (?::\d+)? // Match optional port number
113
- (?:\/[^\s?#]*)? // Match optional path
114
- (?:\?[^\s#]*)? // Match optional query string
115
- (?=([^\s]+#.*)?) // Positive lookahead for the fragment identifier
116
- #?[^\s]*$/i; // Match optional fragment at the end of the string
117
- */
118
- const URL_REGEXP_EXACT = /^(?:(?:https?|ftp):\/\/)(?:www\.)?((?:(?:[-\w]+\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::\d+)?(?:\/[^\s?#]*)?(?:\?[^\s#]*)?(?=([^\s]+#.*)?)#?[^\s]*$/i;
119
- /*
120
- Same as URL_REGEXP_EXACT but without the strict beginning and end of the string checks to allow for
121
- matching URLs in the middle of a string
122
- */
123
- const URL_REGEXP = /(?:(?:https?|ftp):\/\/)(?:www\.)?((?:(?:[-\w]+\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::\d+)?(?:\/[^\s?#]*)?(?:\?[^\s#]*)?(?=([^\s]+#.*)?)#?[^\s]*/i;
124
- const CHAR_TEST_REGEXP = /\p{L}/u;
125
- const PUNC_TEST_REGEXP = /[!?.]/;
126
- function hash(value, extraArgs) {
127
- const algorithm = extraArgs[0]?.toLowerCase() ?? 'md5';
128
- switch (algorithm) {
129
- case 'base64':
130
- return (0, js_base64_1.toBase64)(value);
131
- case 'md5':
132
- return (0, md5_1.default)(value);
133
- case 'sha1':
134
- case 'sha224':
135
- case 'sha256':
136
- case 'sha384':
137
- case 'sha512':
138
- case 'sha3':
139
- const variant = {
140
- sha1: 'SHA-1',
141
- sha224: 'SHA-224',
142
- sha256: 'SHA-256',
143
- sha384: 'SHA-384',
144
- sha512: 'SHA-512',
145
- sha3: 'SHA3-512',
146
- }[algorithm];
147
- return new jssha_1.default(variant, 'TEXT').update(value).getHash('HEX');
148
- default:
149
- throw new expression_extension_error_1.ExpressionExtensionError(`Unknown algorithm ${algorithm}. Available algorithms are: ${exports.SupportedHashAlgorithms.join()}, and Base64.`);
150
- }
151
- }
152
- function isEmpty(value) {
153
- return value === '';
154
- }
155
- function isNotEmpty(value) {
156
- return !isEmpty(value);
157
- }
158
- function length(value) {
159
- return value.length;
160
- }
161
- function toJsonString(value) {
162
- return JSON.stringify(value);
163
- }
164
- function removeMarkdown(value) {
165
- let output = value;
166
- try {
167
- output = output.replace(/^([\s\t]*)([*\-+]|\d\.)\s+/gm, '$1');
168
- output = output
169
- // Header
170
- .replace(/\n={2,}/g, '\n')
171
- // Strikethrough
172
- .replace(/~~/g, '')
173
- // Fenced codeblocks
174
- .replace(/`{3}.*\n/g, '');
175
- output = output
176
- // Remove HTML tags
177
- .replace(/<[\w|\s|=|'|"|:|(|)|,|;|/|0-9|.|-]+[>|\\>]/g, '')
178
- // Remove setext-style headers
179
- .replace(/^[=-]{2,}\s*$/g, '')
180
- // Remove footnotes?
181
- .replace(/\[\^.+?\](: .*?$)?/g, '')
182
- .replace(/\s{0,2}\[.*?\]: .*?$/g, '')
183
- // Remove images
184
- .replace(/!\[.*?\][[(].*?[\])]/g, '')
185
- // Remove inline links
186
- .replace(/\[(.*?)\][[(].*?[\])]/g, '$1')
187
- // Remove Blockquotes
188
- .replace(/>/g, '')
189
- // Remove reference-style links?
190
- .replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, '')
191
- // Remove atx-style headers
192
- .replace(/^#{1,6}\s*([^#]*)\s*(#{1,6})?/gm, '$1')
193
- .replace(/([*_]{1,3})(\S.*?\S)\1/g, '$2')
194
- .replace(/(`{3,})(.*?)\1/gm, '$2')
195
- .replace(/^-{3,}\s*$/g, '')
196
- .replace(/`(.+?)`/g, '$1')
197
- .replace(/\n{2,}/g, '\n\n');
198
- }
199
- catch (e) {
200
- return value;
201
- }
202
- return output;
203
- }
204
- function removeTags(value) {
205
- return value.replace(/<[^>]*>?/gm, '');
206
- }
207
- function toDate(value) {
208
- const date = new Date(Date.parse(value));
209
- if (date.toString() === 'Invalid Date') {
210
- throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to date');
211
- }
212
- // If time component is not specified, force 00:00h
213
- if (!/:/.test(value)) {
214
- date.setHours(0, 0, 0);
215
- }
216
- return date;
217
- }
218
- function toDateTime(value, extraArgs = ['']) {
219
- try {
220
- const [valueFormat] = extraArgs;
221
- if (valueFormat) {
222
- if (valueFormat === 'ms' ||
223
- valueFormat === 's' ||
224
- valueFormat === 'us' ||
225
- valueFormat === 'excel') {
226
- return (0, number_extensions_1.toDateTime)(Number(value), [valueFormat]);
227
- }
228
- return luxon_1.DateTime.fromFormat(value, valueFormat);
229
- }
230
- return (0, type_validation_1.tryToParseDateTime)(value);
231
- }
232
- catch (error) {
233
- throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to Luxon DateTime');
234
- }
235
- }
236
- function urlDecode(value, extraArgs) {
237
- const [entireString = false] = extraArgs;
238
- if (entireString) {
239
- return decodeURI(value.toString());
240
- }
241
- return decodeURIComponent(value.toString());
242
- }
243
- function urlEncode(value, extraArgs) {
244
- const [entireString = false] = extraArgs;
245
- if (entireString) {
246
- return encodeURI(value.toString());
247
- }
248
- return encodeURIComponent(value.toString());
249
- }
250
- function toInt(value, extraArgs) {
251
- const [radix] = extraArgs;
252
- const int = parseInt(value.replace(CURRENCY_REGEXP, ''), radix);
253
- if (isNaN(int)) {
254
- throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to integer');
255
- }
256
- return int;
257
- }
258
- function toFloat(value) {
259
- if (value.includes(',')) {
260
- throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to float, expected . as decimal separator');
261
- }
262
- const float = parseFloat(value.replace(CURRENCY_REGEXP, ''));
263
- if (isNaN(float)) {
264
- throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to float');
265
- }
266
- return float;
267
- }
268
- function toNumber(value) {
269
- const num = Number(value.replace(CURRENCY_REGEXP, ''));
270
- if (isNaN(num)) {
271
- throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to number');
272
- }
273
- return num;
274
- }
275
- function quote(value, extraArgs) {
276
- const [quoteChar = '"'] = extraArgs;
277
- return `${quoteChar}${value
278
- .replace(/\\/g, '\\\\')
279
- .replace(new RegExp(`\\${quoteChar}`, 'g'), `\\${quoteChar}`)}${quoteChar}`;
280
- }
281
- function isNumeric(value) {
282
- if (value.includes(' '))
283
- return false;
284
- return !isNaN(value) && !isNaN(parseFloat(value));
285
- }
286
- function isUrl(value) {
287
- return URL_REGEXP_EXACT.test(value);
288
- }
289
- function isDomain(value) {
290
- return DOMAIN_REGEXP.test(value);
291
- }
292
- function isEmail(value) {
293
- const result = EMAIL_REGEXP.test(value);
294
- // email regex is loose so check manually for now
295
- if (result && value.includes(' ')) {
296
- return false;
297
- }
298
- return result;
299
- }
300
- function toTitleCase(value) {
301
- return (0, title_case_1.titleCase)(value);
302
- }
303
- function replaceSpecialChars(value) {
304
- return (0, transliteration_1.transliterate)(value, { unknown: '?' });
305
- }
306
- function toSentenceCase(value) {
307
- let current = value.slice();
308
- let buffer = '';
309
- while (CHAR_TEST_REGEXP.test(current)) {
310
- const charIndex = current.search(CHAR_TEST_REGEXP);
311
- current =
312
- current.slice(0, charIndex) +
313
- current[charIndex].toLocaleUpperCase() +
314
- current.slice(charIndex + 1).toLocaleLowerCase();
315
- const puncIndex = current.search(PUNC_TEST_REGEXP);
316
- if (puncIndex === -1) {
317
- buffer += current;
318
- current = '';
319
- break;
320
- }
321
- buffer += current.slice(0, puncIndex + 1);
322
- current = current.slice(puncIndex + 1);
323
- }
324
- return buffer + current;
325
- }
326
- function toSnakeCase(value) {
327
- return value
328
- .toLocaleLowerCase()
329
- .replace(/[ \-]/g, '_')
330
- .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g, '');
331
- }
332
- function extractEmail(value) {
333
- const matched = EMAIL_REGEXP.exec(value);
334
- if (!matched) {
335
- return undefined;
336
- }
337
- return matched[0];
338
- }
339
- function extractDomain(value) {
340
- if (isEmail(value)) {
341
- const matched = EMAIL_REGEXP.exec(value);
342
- // This shouldn't happen
343
- if (!matched) {
344
- return undefined;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.stringExtensions = exports.SupportedHashAlgorithms = void 0;
7
+ exports.toJsonString = toJsonString;
8
+ exports.toDateTime = toDateTime;
9
+ // NOTE: This file is intentionally mirrored in @n8n/expression-runtime/src/extensions/
10
+ // for use inside the isolated VM. Changes here must be reflected there and vice versa.
11
+ // TODO: Eliminate the duplication. The blocker is that @n8n/expression-runtime is
12
+ // Vite-stubbed for browser builds (to exclude isolated-vm), which prevents n8n-workflow
13
+ // from importing these extension utilities directly from the runtime package. Fix by
14
+ // splitting @n8n/expression-runtime into a browser-safe extensions subpath (not stubbed)
15
+ // and a node-only VM entry (stubbed).
16
+ const js_base64_1 = require("js-base64");
17
+ const jssha_1 = __importDefault(require("jssha"));
18
+ const luxon_1 = require("luxon");
19
+ const md5_1 = __importDefault(require("md5"));
20
+ const title_case_1 = require("title-case");
21
+ const transliteration_1 = require("transliteration");
22
+ const number_extensions_1 = require("./number-extensions");
23
+ const expression_extension_error_1 = require("../errors/expression-extension.error");
24
+ const type_validation_1 = require("../type-validation");
25
+ exports.SupportedHashAlgorithms = [
26
+ 'md5',
27
+ 'sha1',
28
+ 'sha224',
29
+ 'sha256',
30
+ 'sha384',
31
+ 'sha512',
32
+ 'sha3',
33
+ ];
34
+ // All symbols from https://www.xe.com/symbols/ as for 2022/11/09
35
+ const CURRENCY_REGEXP = /(\u004c\u0065\u006b|\u060b|\u0024|\u0192|\u20bc|\u0042\u0072|\u0042\u005a\u0024|\u0024\u0062|\u004b\u004d|\u0050|\u043b\u0432|\u0052\u0024|\u17db|\u00a5|\u20a1|\u006b\u006e|\u20b1|\u004b\u010d|\u006b\u0072|\u0052\u0044\u0024|\u00a3|\u20ac|\u00a2|\u0051|\u004c|\u0046\u0074|\u20b9|\u0052\u0070|\ufdfc|\u20aa|\u004a\u0024|\u20a9|\u20ad|\u0434\u0435\u043d|\u0052\u004d|\u20a8|\u20ae|\u004d\u0054|\u0043\u0024|\u20a6|\u0042\u002f\u002e|\u0047\u0073|\u0053\u002f\u002e|\u007a\u0142|\u006c\u0065\u0069|\u20bd|\u0414\u0438\u043d\u002e|\u0053|\u0052|\u0043\u0048\u0046|\u004e\u0054\u0024|\u0e3f|\u0054\u0054\u0024|\u20ba|\u20b4|\u0024\u0055|\u0042\u0073|\u20ab|\u005a\u0024)/gu;
36
+ /*
37
+ Extract the domain part from various inputs, including URLs, email addresses, and plain domains.
38
+
39
+ /^(?:(?:https?|ftp):\/\/)? // Match optional http, https, or ftp protocols
40
+ (?:mailto:)? // Match optional mailto:
41
+ (?:\/\/)? // Match optional double slashes
42
+ (?:www\.)? // Match optional www prefix
43
+ (?:[-\w]*\.)? // Match any optional subdomain
44
+ ( // Capture the domain part
45
+ (?:(?:[-\w]+\.)+ // Match one or more subdomains
46
+ (?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+) // Match top-level domain or Punycode encoded IDN(xn--80aswg.xn--p1ai)
47
+ |localhost // Match localhost
48
+ |\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} // Match IPv4 addresses
49
+ )
50
+ )
51
+ (?::\d+)? // Match optional port number
52
+ (?:\/[^\s?]*)? // Match optional path
53
+ (?:\?[^\s#]*)? // Match optional query string
54
+ (?:#[^\s]*)?$/i; // Match optional hash fragment
55
+ */
56
+ const DOMAIN_EXTRACT_REGEXP = /^(?:(?:https?|ftp):\/\/)?(?:mailto:)?(?:\/\/)?((?:www\.)?(?:(?:[-\w]+\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::\d+)?(?:\/[^\s?]*)?(?:\?[^\s#]*)?(?:#[^\s]*)?$/i;
57
+ /*
58
+ Matches domain names without the protocol or optional subdomains
59
+
60
+ /^(?:www\.)? // Match optional www prefix
61
+ ( // Capture the domain part
62
+ (?:(?:[-\w]+\.)+ // Match one or more subdomains
63
+ (?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+) // Match top-level domain or Punycode encoded IDN
64
+ |localhost // Match localhost
65
+ |\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} // Match IPv4 addresses
66
+ )
67
+ )
68
+ (?::\d+)? // Match optional port number
69
+ (?:\/[^\s?]*)? // Match optional path
70
+ (?:\?[^\s#]*)? // Match optional query string
71
+ (?:#[^\s]*)?$/i; // Match optional fragment at the end of the string
72
+ */
73
+ const DOMAIN_REGEXP = /^(?:www\.)?((?:(?:[-\w]+\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::\d+)?(?:\/[^\s?]*)?(?:\?[^\s#]*)?(?:#[^\s]*)?$/i;
74
+ /*
75
+ Matches email addresses
76
+
77
+ /(
78
+ ( // Capture local part of the email address
79
+ ([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*) // One or more characters not in the set, followed by
80
+ a period, followed by one or more characters not in the set
81
+ |(".+") // Or one or more characters inside quotes
82
+ )
83
+ )
84
+ @ // Match @ symbol
85
+ (?<domain>( // Capture the domain part of the email address
86
+ \[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\] // Match IPv4 address inside brackets
87
+ |(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}) // Or match domain with at least two subdomains and TLD
88
+ ))/;
89
+ */
90
+ const EMAIL_REGEXP = /(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@(?<domain>(\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
91
+ /*
92
+ Matches URLs with strict beginning and end of the string checks
93
+
94
+ /^(?:(?:https?|ftp):\/\/) // Match http, https, or ftp protocols at the start of the string
95
+ (?:www\.)? // Match optional www prefix
96
+ ( // Capture the domain part
97
+ (?:(?:[-\w]+\.)+ // Match one or more subdomains
98
+ (?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+) // Match top-level domain or Punycode encoded IDN
99
+ |localhost // Match localhost
100
+ |\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} // Match IPv4 addresses
101
+ )
102
+ )
103
+ (?::\d+)? // Match optional port number
104
+ (?:\/[^\s?#]*)? // Match optional path
105
+ (?:\?[^\s#]*)? // Match optional query string
106
+ (?=([^\s]+#.*)?) // Positive lookahead for the fragment identifier
107
+ #?[^\s]*$/i; // Match optional fragment at the end of the string
108
+ */
109
+ const URL_REGEXP_EXACT = /^(?:(?:https?|ftp):\/\/)(?:www\.)?((?:(?:[-\w]+\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::\d+)?(?:\/[^\s?#]*)?(?:\?[^\s#]*)?(?=([^\s]+#.*)?)#?[^\s]*$/i;
110
+ /*
111
+ Same as URL_REGEXP_EXACT but without the strict beginning and end of the string checks to allow for
112
+ matching URLs in the middle of a string
113
+ */
114
+ const URL_REGEXP = /(?:(?:https?|ftp):\/\/)(?:www\.)?((?:(?:[-\w]+\.)+(?:[a-zA-Z]{2,}|xn--[a-zA-Z0-9]+)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::\d+)?(?:\/[^\s?#]*)?(?:\?[^\s#]*)?(?=([^\s]+#.*)?)#?[^\s]*/i;
115
+ const CHAR_TEST_REGEXP = /\p{L}/u;
116
+ const PUNC_TEST_REGEXP = /[!?.]/;
117
+ function hash(value, extraArgs) {
118
+ const algorithm = extraArgs[0]?.toLowerCase() ?? 'md5';
119
+ switch (algorithm) {
120
+ case 'base64':
121
+ return (0, js_base64_1.toBase64)(value);
122
+ case 'md5':
123
+ return (0, md5_1.default)(value);
124
+ case 'sha1':
125
+ case 'sha224':
126
+ case 'sha256':
127
+ case 'sha384':
128
+ case 'sha512':
129
+ case 'sha3':
130
+ const variant = {
131
+ sha1: 'SHA-1',
132
+ sha224: 'SHA-224',
133
+ sha256: 'SHA-256',
134
+ sha384: 'SHA-384',
135
+ sha512: 'SHA-512',
136
+ sha3: 'SHA3-512',
137
+ }[algorithm];
138
+ return new jssha_1.default(variant, 'TEXT').update(value).getHash('HEX');
139
+ default:
140
+ throw new expression_extension_error_1.ExpressionExtensionError(`Unknown algorithm ${algorithm}. Available algorithms are: ${exports.SupportedHashAlgorithms.join()}, and Base64.`);
141
+ }
142
+ }
143
+ function isEmpty(value) {
144
+ return value === '';
145
+ }
146
+ function isNotEmpty(value) {
147
+ return !isEmpty(value);
148
+ }
149
+ function length(value) {
150
+ return value.length;
151
+ }
152
+ function toJsonString(value) {
153
+ return JSON.stringify(value);
154
+ }
155
+ function removeMarkdown(value) {
156
+ let output = value;
157
+ try {
158
+ output = output.replace(/^([\s\t]*)([*\-+]|\d\.)\s+/gm, '$1');
159
+ output = output
160
+ // Header
161
+ .replace(/\n={2,}/g, '\n')
162
+ // Strikethrough
163
+ .replace(/~~/g, '')
164
+ // Fenced codeblocks
165
+ .replace(/`{3}.*\n/g, '');
166
+ output = output
167
+ // Remove HTML tags
168
+ .replace(/<[\w|\s|=|'|"|:|(|)|,|;|/|0-9|.|-]+[>|\\>]/g, '')
169
+ // Remove setext-style headers
170
+ .replace(/^[=-]{2,}\s*$/g, '')
171
+ // Remove footnotes?
172
+ .replace(/\[\^.+?\](: .*?$)?/g, '')
173
+ .replace(/\s{0,2}\[.*?\]: .*?$/g, '')
174
+ // Remove images
175
+ .replace(/!\[.*?\][[(].*?[\])]/g, '')
176
+ // Remove inline links
177
+ .replace(/\[(.*?)\][[(].*?[\])]/g, '$1')
178
+ // Remove Blockquotes
179
+ .replace(/>/g, '')
180
+ // Remove reference-style links?
181
+ .replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, '')
182
+ // Remove atx-style headers
183
+ .replace(/^#{1,6}\s*([^#]*)\s*(#{1,6})?/gm, '$1')
184
+ .replace(/([*_]{1,3})(\S.*?\S)\1/g, '$2')
185
+ .replace(/(`{3,})(.*?)\1/gm, '$2')
186
+ .replace(/^-{3,}\s*$/g, '')
187
+ .replace(/`(.+?)`/g, '$1')
188
+ .replace(/\n{2,}/g, '\n\n');
189
+ }
190
+ catch (e) {
191
+ return value;
192
+ }
193
+ return output;
194
+ }
195
+ function removeTags(value) {
196
+ return value.replace(/<[^>]*>?/gm, '');
197
+ }
198
+ function toDate(value) {
199
+ const date = new Date(Date.parse(value));
200
+ if (date.toString() === 'Invalid Date') {
201
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to date');
202
+ }
203
+ // If time component is not specified, force 00:00h
204
+ if (!/:/.test(value)) {
205
+ date.setHours(0, 0, 0);
206
+ }
207
+ return date;
208
+ }
209
+ function toDateTime(value, extraArgs = ['']) {
210
+ try {
211
+ const [valueFormat] = extraArgs;
212
+ if (valueFormat) {
213
+ if (valueFormat === 'ms' ||
214
+ valueFormat === 's' ||
215
+ valueFormat === 'us' ||
216
+ valueFormat === 'excel') {
217
+ return (0, number_extensions_1.toDateTime)(Number(value), [valueFormat]);
345
218
  }
346
- return matched.groups?.domain;
219
+ return luxon_1.DateTime.fromFormat(value, valueFormat);
347
220
  }
348
- const domainMatch = value.match(DOMAIN_EXTRACT_REGEXP);
349
- if (domainMatch) {
350
- return domainMatch[1];
221
+ return (0, type_validation_1.tryToParseDateTime)(value);
222
+ }
223
+ catch (error) {
224
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to Luxon DateTime');
225
+ }
226
+ }
227
+ function urlDecode(value, extraArgs) {
228
+ const [entireString = false] = extraArgs;
229
+ if (entireString) {
230
+ return decodeURI(value.toString());
231
+ }
232
+ return decodeURIComponent(value.toString());
233
+ }
234
+ function urlEncode(value, extraArgs) {
235
+ const [entireString = false] = extraArgs;
236
+ if (entireString) {
237
+ return encodeURI(value.toString());
238
+ }
239
+ return encodeURIComponent(value.toString());
240
+ }
241
+ function toInt(value, extraArgs) {
242
+ const [radix] = extraArgs;
243
+ const int = parseInt(value.replace(CURRENCY_REGEXP, ''), radix);
244
+ if (isNaN(int)) {
245
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to integer');
246
+ }
247
+ return int;
248
+ }
249
+ function toFloat(value) {
250
+ if (value.includes(',')) {
251
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to float, expected . as decimal separator');
252
+ }
253
+ const float = parseFloat(value.replace(CURRENCY_REGEXP, ''));
254
+ if (isNaN(float)) {
255
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to float');
256
+ }
257
+ return float;
258
+ }
259
+ function toNumber(value) {
260
+ const num = Number(value.replace(CURRENCY_REGEXP, ''));
261
+ if (isNaN(num)) {
262
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to number');
263
+ }
264
+ return num;
265
+ }
266
+ function quote(value, extraArgs) {
267
+ const [quoteChar = '"'] = extraArgs;
268
+ return `${quoteChar}${value
269
+ .replace(/\\/g, '\\\\')
270
+ .replace(new RegExp(`\\${quoteChar}`, 'g'), `\\${quoteChar}`)}${quoteChar}`;
271
+ }
272
+ function isNumeric(value) {
273
+ if (value.includes(' '))
274
+ return false;
275
+ return !isNaN(value) && !isNaN(parseFloat(value));
276
+ }
277
+ function isUrl(value) {
278
+ return URL_REGEXP_EXACT.test(value);
279
+ }
280
+ function isDomain(value) {
281
+ return DOMAIN_REGEXP.test(value);
282
+ }
283
+ function isEmail(value) {
284
+ const result = EMAIL_REGEXP.test(value);
285
+ // email regex is loose so check manually for now
286
+ if (result && value.includes(' ')) {
287
+ return false;
288
+ }
289
+ return result;
290
+ }
291
+ function toTitleCase(value) {
292
+ return (0, title_case_1.titleCase)(value);
293
+ }
294
+ function replaceSpecialChars(value) {
295
+ return (0, transliteration_1.transliterate)(value, { unknown: '?' });
296
+ }
297
+ function toSentenceCase(value) {
298
+ let current = value.slice();
299
+ let buffer = '';
300
+ while (CHAR_TEST_REGEXP.test(current)) {
301
+ const charIndex = current.search(CHAR_TEST_REGEXP);
302
+ current =
303
+ current.slice(0, charIndex) +
304
+ current[charIndex].toLocaleUpperCase() +
305
+ current.slice(charIndex + 1).toLocaleLowerCase();
306
+ const puncIndex = current.search(PUNC_TEST_REGEXP);
307
+ if (puncIndex === -1) {
308
+ buffer += current;
309
+ current = '';
310
+ break;
351
311
  }
312
+ buffer += current.slice(0, puncIndex + 1);
313
+ current = current.slice(puncIndex + 1);
314
+ }
315
+ return buffer + current;
316
+ }
317
+ function toSnakeCase(value) {
318
+ return value
319
+ .toLocaleLowerCase()
320
+ .replace(/[ \-]/g, '_')
321
+ .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g, '');
322
+ }
323
+ function extractEmail(value) {
324
+ const matched = EMAIL_REGEXP.exec(value);
325
+ if (!matched) {
352
326
  return undefined;
353
327
  }
354
- function extractUrl(value) {
355
- const matched = URL_REGEXP.exec(value);
328
+ return matched[0];
329
+ }
330
+ function extractDomain(value) {
331
+ if (isEmail(value)) {
332
+ const matched = EMAIL_REGEXP.exec(value);
333
+ // This shouldn't happen
356
334
  if (!matched) {
357
335
  return undefined;
358
336
  }
359
- return matched[0];
337
+ return matched.groups?.domain;
360
338
  }
361
- function extractUrlPath(value) {
362
- try {
363
- const url = new URL(value);
364
- return url.pathname;
365
- }
366
- catch (error) {
367
- return undefined;
368
- }
339
+ const domainMatch = value.match(DOMAIN_EXTRACT_REGEXP);
340
+ if (domainMatch) {
341
+ return domainMatch[1];
369
342
  }
370
- function parseJson(value) {
371
- try {
372
- return JSON.parse(value);
373
- }
374
- catch (error) {
375
- if (value.includes("'")) {
376
- throw new expression_extension_error_1.ExpressionExtensionError("Parsing failed. Check you're using double quotes");
377
- }
378
- throw new expression_extension_error_1.ExpressionExtensionError('Parsing failed');
379
- }
343
+ return undefined;
344
+ }
345
+ function extractUrl(value) {
346
+ const matched = URL_REGEXP.exec(value);
347
+ if (!matched) {
348
+ return undefined;
380
349
  }
381
- function toBoolean(value) {
382
- const normalized = value.toLowerCase();
383
- const FALSY = new Set(['false', 'no', '0']);
384
- return normalized.length > 0 && !FALSY.has(normalized);
350
+ return matched[0];
351
+ }
352
+ function extractUrlPath(value) {
353
+ try {
354
+ const url = new URL(value);
355
+ return url.pathname;
385
356
  }
386
- function base64Encode(value) {
387
- return (0, js_base64_1.toBase64)(value);
357
+ catch (error) {
358
+ return undefined;
388
359
  }
389
- function base64Decode(value) {
390
- return (0, js_base64_1.fromBase64)(value);
360
+ }
361
+ function parseJson(value) {
362
+ try {
363
+ return JSON.parse(value);
391
364
  }
392
- removeMarkdown.doc = {
393
- name: 'removeMarkdown',
394
- description: 'Removes any Markdown formatting from the string. Also removes HTML tags.',
395
- section: 'edit',
396
- returnType: 'string',
397
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-removeMarkdown',
398
- examples: [{ example: '"*bold*, [link]()".removeMarkdown()', evaluated: '"bold, link"' }],
399
- };
400
- removeTags.doc = {
401
- name: 'removeTags',
402
- description: 'Removes tags, such as HTML or XML, from the string.',
403
- section: 'edit',
404
- returnType: 'string',
405
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-removeTags',
406
- examples: [{ example: '"<b>bold</b>, <a>link</a>".removeTags()', evaluated: '"bold, link"' }],
407
- };
408
- toDate.doc = {
409
- name: 'toDate',
410
- description: 'Converts a string to a date.',
411
- section: 'cast',
412
- returnType: 'Date',
413
- hidden: true,
414
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toDate',
415
- };
416
- toDateTime.doc = {
417
- name: 'toDateTime',
418
- description: 'Converts the string to a <a target="_blank" href="https://moment.github.io/luxon/api-docs/">Luxon</a> DateTime. Useful for further transformation. Supported formats for the string are ISO 8601, HTTP, RFC2822, SQL and Unix timestamp in milliseconds. To parse other formats, use <a target="_blank" href=”https://moment.github.io/luxon/api-docs/index.html#datetimefromformat”> <code>DateTime.fromFormat()</code></a>.',
419
- section: 'cast',
420
- returnType: 'DateTime',
421
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toDateTime',
422
- examples: [
423
- { example: '"2024-03-29T18:06:31.798+01:00".toDateTime()' },
424
- { example: '"Fri, 29 Mar 2024 18:08:01 +0100".toDateTime()' },
425
- { example: '"20240329".toDateTime()' },
426
- { example: '"1711732132990".toDateTime("ms")' },
427
- { example: '"31-01-2024".toDateTime("dd-MM-yyyy")' },
428
- ],
429
- args: [
430
- {
431
- name: 'format',
432
- optional: true,
433
- description: 'The format of the date string. Options are <code>ms</code> (for Unix timestamp in milliseconds), <code>s</code> (for Unix timestamp in seconds), <code>us</code> (for Unix timestamp in microseconds) or <code>excel</code> (for days since 1900). Custom formats can be specified using <a href="https://moment.github.io/luxon/#/formatting?id=table-of-tokens">Luxon tokens</a>.',
434
- type: 'string',
435
- },
436
- ],
437
- };
438
- toBoolean.doc = {
439
- name: 'toBoolean',
440
- description: 'Converts the string to a boolean value. <code>0</code>, <code>false</code> and <code>no</code> resolve to <code>false</code>, everything else to <code>true</code>. Case-insensitive.',
441
- section: 'cast',
442
- returnType: 'boolean',
443
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toBoolean',
444
- examples: [
445
- { example: '"true".toBoolean()', evaluated: 'true' },
446
- { example: '"false".toBoolean()', evaluated: 'false' },
447
- { example: '"0".toBoolean()', evaluated: 'false' },
448
- { example: '"hello".toBoolean()', evaluated: 'true' },
449
- ],
450
- };
451
- toFloat.doc = {
452
- name: 'toFloat',
453
- description: 'Converts a string to a decimal number.',
454
- section: 'cast',
455
- returnType: 'number',
456
- aliases: ['toDecimalNumber'],
457
- hidden: true,
458
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toDecimalNumber',
459
- };
460
- toInt.doc = {
461
- name: 'toInt',
462
- description: 'Converts a string to an integer.',
463
- section: 'cast',
464
- returnType: 'number',
465
- args: [{ name: 'radix?', type: 'number' }],
466
- aliases: ['toWholeNumber'],
467
- hidden: true,
468
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toInt',
469
- };
470
- toSentenceCase.doc = {
471
- name: 'toSentenceCase',
472
- description: 'Changes the capitalization of the string to sentence case. The first letter of each sentence is capitalized and all others are lowercased.',
473
- examples: [{ example: '"quick! brown FOX".toSentenceCase()', evaluated: '"Quick! Brown fox"' }],
474
- section: 'case',
475
- returnType: 'string',
476
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toSentenceCase',
477
- };
478
- toSnakeCase.doc = {
479
- name: 'toSnakeCase',
480
- description: 'Changes the format of the string to snake case. Spaces and dashes are replaced by <code>_</code>, symbols are removed and all letters are lowercased.',
481
- examples: [{ example: '"quick brown $FOX".toSnakeCase()', evaluated: '"quick_brown_fox"' }],
482
- section: 'case',
483
- returnType: 'string',
484
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toSnakeCase',
485
- };
486
- toTitleCase.doc = {
487
- name: 'toTitleCase',
488
- description: "Changes the capitalization of the string to title case. The first letter of each word is capitalized and the others left unchanged. Short prepositions and conjunctions aren't capitalized (e.g. 'a', 'the').",
489
- examples: [{ example: '"quick a brown FOX".toTitleCase()', evaluated: '"Quick a Brown Fox"' }],
490
- section: 'case',
491
- returnType: 'string',
492
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toTitleCase',
493
- };
494
- urlEncode.doc = {
495
- name: 'urlEncode',
496
- description: 'Encodes the string so that it can be used in a URL. Spaces and special characters are replaced with codes of the form <code>%XX</code>.',
497
- section: 'edit',
498
- args: [
499
- {
500
- name: 'allChars',
501
- optional: true,
502
- description: 'Whether to encode characters that are part of the URI syntax (e.g. <code>=</code>, <code>?</code>)',
503
- default: 'false',
504
- type: 'boolean',
505
- },
506
- ],
507
- returnType: 'string',
508
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-urlEncode',
509
- examples: [
510
- { example: '"name=Nathan Automat".urlEncode()', evaluated: '"name%3DNathan%20Automat"' },
511
- { example: '"name=Nathan Automat".urlEncode(true)', evaluated: '"name=Nathan%20Automat"' },
512
- ],
513
- };
514
- urlDecode.doc = {
515
- name: 'urlDecode',
516
- description: 'Decodes a URL-encoded string. Replaces any character codes in the form of <code>%XX</code> with their corresponding characters.',
517
- args: [
518
- {
519
- name: 'allChars',
520
- optional: true,
521
- description: 'Whether to decode characters that are part of the URI syntax (e.g. <code>=</code>, <code>?</code>)',
522
- default: 'false',
523
- type: 'boolean',
524
- },
525
- ],
526
- section: 'edit',
527
- returnType: 'string',
528
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-urlDecode',
529
- examples: [
530
- { example: '"name%3DNathan%20Automat".urlDecode()', evaluated: '"name=Nathan Automat"' },
531
- { example: '"name%3DNathan%20Automat".urlDecode(true)', evaluated: '"name%3DNathan Automat"' },
532
- ],
533
- };
534
- replaceSpecialChars.doc = {
535
- name: 'replaceSpecialChars',
536
- description: 'Replaces special characters in the string with the closest ASCII character',
537
- section: 'edit',
538
- returnType: 'string',
539
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-replaceSpecialChars',
540
- examples: [{ example: '"déjà".replaceSpecialChars()', evaluated: '"deja"' }],
541
- };
542
- length.doc = {
543
- name: 'length',
544
- section: 'query',
545
- hidden: true,
546
- description: 'Returns the character count of a string.',
547
- returnType: 'number',
548
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings',
549
- };
550
- isDomain.doc = {
551
- name: 'isDomain',
552
- description: 'Returns <code>true</code> if a string is a domain.',
553
- section: 'validation',
554
- returnType: 'boolean',
555
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isDomain',
556
- examples: [
557
- { example: '"n8n.io".isDomain()', evaluated: 'true' },
558
- { example: '"http://n8n.io".isDomain()', evaluated: 'false' },
559
- { example: '"hello".isDomain()', evaluated: 'false' },
560
- ],
561
- };
562
- isEmail.doc = {
563
- name: 'isEmail',
564
- description: 'Returns <code>true</code> if the string is an email.',
565
- section: 'validation',
566
- returnType: 'boolean',
567
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isEmail',
568
- examples: [
569
- { example: '"me@example.com".isEmail()', evaluated: 'true' },
570
- { example: '"It\'s me@example.com".isEmail()', evaluated: 'false' },
571
- { example: '"hello".isEmail()', evaluated: 'false' },
572
- ],
573
- };
574
- isNumeric.doc = {
575
- name: 'isNumeric',
576
- description: 'Returns <code>true</code> if the string represents a number.',
577
- section: 'validation',
578
- returnType: 'boolean',
579
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isNumeric',
580
- examples: [
581
- { example: '"1.2234".isNumeric()', evaluated: 'true' },
582
- { example: '"hello".isNumeric()', evaluated: 'false' },
583
- { example: '"123E23".isNumeric()', evaluated: 'true' },
584
- ],
585
- };
586
- isUrl.doc = {
587
- name: 'isUrl',
588
- description: 'Returns <code>true</code> if a string is a valid URL',
589
- section: 'validation',
590
- returnType: 'boolean',
591
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isUrl',
592
- examples: [
593
- { example: '"https://n8n.io".isUrl()', evaluated: 'true' },
594
- { example: '"n8n.io".isUrl()', evaluated: 'false' },
595
- { example: '"hello".isUrl()', evaluated: 'false' },
596
- ],
597
- };
598
- isEmpty.doc = {
599
- name: 'isEmpty',
600
- description: 'Returns <code>true</code> if the string has no characters or is <code>null</code>',
601
- section: 'validation',
602
- returnType: 'boolean',
603
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isEmpty',
604
- examples: [
605
- { example: '"".isEmpty()', evaluated: 'true' },
606
- { example: '"hello".isEmpty()', evaluated: 'false' },
607
- ],
608
- };
609
- isNotEmpty.doc = {
610
- name: 'isNotEmpty',
611
- description: 'Returns <code>true</code> if the string has at least one character.',
612
- section: 'validation',
613
- returnType: 'boolean',
614
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isNotEmpty',
615
- examples: [
616
- { example: '"hello".isNotEmpty()', evaluated: 'true' },
617
- { example: '"".isNotEmpty()', evaluated: 'false' },
618
- ],
619
- };
620
- toJsonString.doc = {
621
- name: 'toJsonString',
622
- description: 'Prepares the string to be inserted into a JSON object. Escapes any quotes and special characters (e.g. new lines), and wraps the string in quotes.The same as JavaScript’s JSON.stringify().',
623
- section: 'edit',
624
- returnType: 'string',
625
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toJsonString',
626
- examples: [
627
- {
628
- example: 'The "best" colours: red\nbrown.toJsonString()',
629
- evaluated: '"The \\"best\\" colours: red\\nbrown"',
630
- },
631
- { example: 'foo.toJsonString()', evaluated: '"foo"' },
632
- ],
633
- };
634
- extractEmail.doc = {
635
- name: 'extractEmail',
636
- description: 'Extracts the first email found in the string. Returns <code>undefined</code> if none is found.',
637
- section: 'edit',
638
- returnType: 'string',
639
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractEmail',
640
- examples: [
641
- { example: '"My email is me@example.com".extractEmail()', evaluated: "'me@example.com'" },
642
- ],
643
- };
644
- extractDomain.doc = {
645
- name: 'extractDomain',
646
- description: 'If the string is an email address or URL, returns its domain (or <code>undefined</code> if nothing found). If the string also contains other content, try using <code>extractEmail()</code> or <code>extractUrl()</code> first.',
647
- section: 'edit',
648
- returnType: 'string',
649
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractDomain',
650
- examples: [
651
- { example: '"me@example.com".extractDomain()', evaluated: "'example.com'" },
652
- { example: '"http://n8n.io/workflows".extractDomain()', evaluated: "'n8n.io'" },
653
- {
654
- example: '"It\'s me@example.com".extractEmail().extractDomain()',
655
- evaluated: "'example.com'",
656
- },
657
- ],
658
- };
659
- extractUrl.doc = {
660
- name: 'extractUrl',
661
- description: 'Extracts the first URL found in the string. Returns <code>undefined</code> if none is found. Only recognizes full URLs, e.g. those starting with <code>http</code>.',
662
- section: 'edit',
663
- returnType: 'string',
664
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractUrl',
665
- examples: [{ example: '"Check out http://n8n.io".extractUrl()', evaluated: "'http://n8n.io'" }],
666
- };
667
- extractUrlPath.doc = {
668
- name: 'extractUrlPath',
669
- description: 'Returns the part of a URL after the domain, or <code>undefined</code> if no URL found. If the string also contains other content, try using <code>extractUrl()</code> first.',
670
- section: 'edit',
671
- returnType: 'string',
672
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractUrlPath',
673
- examples: [
674
- { example: '"http://n8n.io/workflows".extractUrlPath()', evaluated: "'/workflows'" },
675
- {
676
- example: '"Check out http://n8n.io/workflows".extractUrl().extractUrlPath()',
677
- evaluated: "'/workflows'",
678
- },
679
- ],
680
- };
681
- hash.doc = {
682
- name: 'hash',
683
- description: 'Returns the string hashed with the given algorithm. Defaults to md5 if not specified.',
684
- section: 'edit',
685
- returnType: 'string',
686
- args: [
687
- {
688
- name: 'algo',
689
- optional: true,
690
- description: 'The hashing algorithm to use. One of <code>md5</code>, <code>base64</code>, <code>sha1</code>, <code>sha224</code>, <code>sha256</code>, <code>sha384</code>, <code>sha512</code>, <code>sha3</code>, <code>ripemd160</code>\n ',
691
- default: '"md5"',
692
- type: 'string',
693
- },
694
- ],
695
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-hash',
696
- examples: [{ example: '"hello".hash()', evaluated: "'5d41402abc4b2a76b9719d911017c592'" }],
697
- };
698
- quote.doc = {
699
- name: 'quote',
700
- description: 'Wraps a string in quotation marks, and escapes any quotation marks already in the string. Useful when constructing JSON, SQL, etc.',
701
- section: 'edit',
702
- returnType: 'string',
703
- args: [
704
- {
705
- name: 'mark',
706
- optional: true,
707
- description: 'The type of quotation mark to use',
708
- default: '"',
709
- type: 'string',
710
- },
711
- ],
712
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-quote',
713
- examples: [{ example: '\'Nathan says "hi"\'.quote()', evaluated: '\'"Nathan says \\"hi\\""\'' }],
714
- };
715
- parseJson.doc = {
716
- name: 'parseJson',
717
- aliases: ['fromJson'],
718
- description: "Returns the JavaScript value or object represented by the string, or <code>undefined</code> if the string isn't valid JSON. Single-quoted JSON is not supported.",
719
- section: 'cast',
720
- returnType: 'any',
721
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-parseJson',
722
- examples: [
723
- { example: '\'{"name":"Nathan"}\'.parseJson()', evaluated: '\'{"name":"Nathan"}\'' },
724
- { example: "\"{'name':'Nathan'}\".parseJson()", evaluated: 'undefined' },
725
- { example: "'hello'.parseJson()", evaluated: 'undefined' },
726
- ],
727
- };
728
- base64Encode.doc = {
729
- name: 'base64Encode',
730
- aliases: ['toBase64'],
731
- description: 'Converts plain text to a base64-encoded string',
732
- examples: [{ example: '"hello".base64Encode()', evaluated: '"aGVsbG8="' }],
733
- section: 'edit',
734
- returnType: 'string',
735
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-base64Encode',
736
- };
737
- base64Decode.doc = {
738
- name: 'base64Decode',
739
- aliases: ['fromBase64'],
740
- description: 'Converts a base64-encoded string to plain text',
741
- examples: [{ example: '"aGVsbG8=".base64Decode()', evaluated: '"hello"' }],
742
- section: 'edit',
743
- returnType: 'string',
744
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-base64Decode',
745
- };
746
- toNumber.doc = {
747
- name: 'toNumber',
748
- description: "Converts a string representing a number to a number. Errors if the string doesn't start with a valid number.",
749
- section: 'cast',
750
- returnType: 'number',
751
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toNumber',
752
- examples: [
753
- { example: '"123".toNumber()', evaluated: '123' },
754
- { example: '"1.23E10".toNumber()', evaluated: '12300000000' },
755
- ],
756
- };
757
- const toDecimalNumber = toFloat.bind({});
758
- const toWholeNumber = toInt.bind({});
759
- exports.stringExtensions = {
760
- typeName: 'String',
761
- functions: {
762
- hash,
763
- removeMarkdown,
764
- removeTags,
765
- toDate,
766
- toDateTime,
767
- toBoolean,
768
- toDecimalNumber,
769
- toNumber,
770
- toFloat,
771
- toInt,
772
- toWholeNumber,
773
- toSentenceCase,
774
- toSnakeCase,
775
- toTitleCase,
776
- urlDecode,
777
- urlEncode,
778
- quote,
779
- replaceSpecialChars,
780
- length,
781
- isDomain,
782
- isEmail,
783
- isNumeric,
784
- isUrl,
785
- isEmpty,
786
- isNotEmpty,
787
- toJsonString,
788
- extractEmail,
789
- extractDomain,
790
- extractUrl,
791
- extractUrlPath,
792
- parseJson,
793
- base64Encode,
794
- base64Decode,
365
+ catch (error) {
366
+ if (value.includes("'")) {
367
+ throw new expression_extension_error_1.ExpressionExtensionError("Parsing failed. Check you're using double quotes");
368
+ }
369
+ throw new expression_extension_error_1.ExpressionExtensionError('Parsing failed');
370
+ }
371
+ }
372
+ function toBoolean(value) {
373
+ const normalized = value.toLowerCase();
374
+ const FALSY = new Set(['false', 'no', '0']);
375
+ return normalized.length > 0 && !FALSY.has(normalized);
376
+ }
377
+ function base64Encode(value) {
378
+ return (0, js_base64_1.toBase64)(value);
379
+ }
380
+ function base64Decode(value) {
381
+ return (0, js_base64_1.fromBase64)(value);
382
+ }
383
+ removeMarkdown.doc = {
384
+ name: 'removeMarkdown',
385
+ description: 'Removes any Markdown formatting from the string. Also removes HTML tags.',
386
+ section: 'edit',
387
+ returnType: 'string',
388
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-removeMarkdown',
389
+ examples: [{ example: '"*bold*, [link]()".removeMarkdown()', evaluated: '"bold, link"' }],
390
+ };
391
+ removeTags.doc = {
392
+ name: 'removeTags',
393
+ description: 'Removes tags, such as HTML or XML, from the string.',
394
+ section: 'edit',
395
+ returnType: 'string',
396
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-removeTags',
397
+ examples: [{ example: '"<b>bold</b>, <a>link</a>".removeTags()', evaluated: '"bold, link"' }],
398
+ };
399
+ toDate.doc = {
400
+ name: 'toDate',
401
+ description: 'Converts a string to a date.',
402
+ section: 'cast',
403
+ returnType: 'Date',
404
+ hidden: true,
405
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toDate',
406
+ };
407
+ toDateTime.doc = {
408
+ name: 'toDateTime',
409
+ description: 'Converts the string to a <a target="_blank" href="https://moment.github.io/luxon/api-docs/">Luxon</a> DateTime. Useful for further transformation. Supported formats for the string are ISO 8601, HTTP, RFC2822, SQL and Unix timestamp in milliseconds. To parse other formats, use <a target="_blank" href=”https://moment.github.io/luxon/api-docs/index.html#datetimefromformat”> <code>DateTime.fromFormat()</code></a>.',
410
+ section: 'cast',
411
+ returnType: 'DateTime',
412
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toDateTime',
413
+ examples: [
414
+ { example: '"2024-03-29T18:06:31.798+01:00".toDateTime()' },
415
+ { example: '"Fri, 29 Mar 2024 18:08:01 +0100".toDateTime()' },
416
+ { example: '"20240329".toDateTime()' },
417
+ { example: '"1711732132990".toDateTime("ms")' },
418
+ { example: '"31-01-2024".toDateTime("dd-MM-yyyy")' },
419
+ ],
420
+ args: [
421
+ {
422
+ name: 'format',
423
+ optional: true,
424
+ description: 'The format of the date string. Options are <code>ms</code> (for Unix timestamp in milliseconds), <code>s</code> (for Unix timestamp in seconds), <code>us</code> (for Unix timestamp in microseconds) or <code>excel</code> (for days since 1900). Custom formats can be specified using <a href="https://moment.github.io/luxon/#/formatting?id=table-of-tokens">Luxon tokens</a>.',
425
+ type: 'string',
426
+ },
427
+ ],
428
+ };
429
+ toBoolean.doc = {
430
+ name: 'toBoolean',
431
+ description: 'Converts the string to a boolean value. <code>0</code>, <code>false</code> and <code>no</code> resolve to <code>false</code>, everything else to <code>true</code>. Case-insensitive.',
432
+ section: 'cast',
433
+ returnType: 'boolean',
434
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toBoolean',
435
+ examples: [
436
+ { example: '"true".toBoolean()', evaluated: 'true' },
437
+ { example: '"false".toBoolean()', evaluated: 'false' },
438
+ { example: '"0".toBoolean()', evaluated: 'false' },
439
+ { example: '"hello".toBoolean()', evaluated: 'true' },
440
+ ],
441
+ };
442
+ toFloat.doc = {
443
+ name: 'toFloat',
444
+ description: 'Converts a string to a decimal number.',
445
+ section: 'cast',
446
+ returnType: 'number',
447
+ aliases: ['toDecimalNumber'],
448
+ hidden: true,
449
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toDecimalNumber',
450
+ };
451
+ toInt.doc = {
452
+ name: 'toInt',
453
+ description: 'Converts a string to an integer.',
454
+ section: 'cast',
455
+ returnType: 'number',
456
+ args: [{ name: 'radix?', type: 'number' }],
457
+ aliases: ['toWholeNumber'],
458
+ hidden: true,
459
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toInt',
460
+ };
461
+ toSentenceCase.doc = {
462
+ name: 'toSentenceCase',
463
+ description: 'Changes the capitalization of the string to sentence case. The first letter of each sentence is capitalized and all others are lowercased.',
464
+ examples: [{ example: '"quick! brown FOX".toSentenceCase()', evaluated: '"Quick! Brown fox"' }],
465
+ section: 'case',
466
+ returnType: 'string',
467
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toSentenceCase',
468
+ };
469
+ toSnakeCase.doc = {
470
+ name: 'toSnakeCase',
471
+ description: 'Changes the format of the string to snake case. Spaces and dashes are replaced by <code>_</code>, symbols are removed and all letters are lowercased.',
472
+ examples: [{ example: '"quick brown $FOX".toSnakeCase()', evaluated: '"quick_brown_fox"' }],
473
+ section: 'case',
474
+ returnType: 'string',
475
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toSnakeCase',
476
+ };
477
+ toTitleCase.doc = {
478
+ name: 'toTitleCase',
479
+ description: "Changes the capitalization of the string to title case. The first letter of each word is capitalized and the others left unchanged. Short prepositions and conjunctions aren't capitalized (e.g. 'a', 'the').",
480
+ examples: [{ example: '"quick a brown FOX".toTitleCase()', evaluated: '"Quick a Brown Fox"' }],
481
+ section: 'case',
482
+ returnType: 'string',
483
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toTitleCase',
484
+ };
485
+ urlEncode.doc = {
486
+ name: 'urlEncode',
487
+ description: 'Encodes the string so that it can be used in a URL. Spaces and special characters are replaced with codes of the form <code>%XX</code>.',
488
+ section: 'edit',
489
+ args: [
490
+ {
491
+ name: 'allChars',
492
+ optional: true,
493
+ description: 'Whether to encode characters that are part of the URI syntax (e.g. <code>=</code>, <code>?</code>)',
494
+ default: 'false',
495
+ type: 'boolean',
496
+ },
497
+ ],
498
+ returnType: 'string',
499
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-urlEncode',
500
+ examples: [
501
+ { example: '"name=Nathan Automat".urlEncode()', evaluated: '"name%3DNathan%20Automat"' },
502
+ { example: '"name=Nathan Automat".urlEncode(true)', evaluated: '"name=Nathan%20Automat"' },
503
+ ],
504
+ };
505
+ urlDecode.doc = {
506
+ name: 'urlDecode',
507
+ description: 'Decodes a URL-encoded string. Replaces any character codes in the form of <code>%XX</code> with their corresponding characters.',
508
+ args: [
509
+ {
510
+ name: 'allChars',
511
+ optional: true,
512
+ description: 'Whether to decode characters that are part of the URI syntax (e.g. <code>=</code>, <code>?</code>)',
513
+ default: 'false',
514
+ type: 'boolean',
515
+ },
516
+ ],
517
+ section: 'edit',
518
+ returnType: 'string',
519
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-urlDecode',
520
+ examples: [
521
+ { example: '"name%3DNathan%20Automat".urlDecode()', evaluated: '"name=Nathan Automat"' },
522
+ { example: '"name%3DNathan%20Automat".urlDecode(true)', evaluated: '"name%3DNathan Automat"' },
523
+ ],
524
+ };
525
+ replaceSpecialChars.doc = {
526
+ name: 'replaceSpecialChars',
527
+ description: 'Replaces special characters in the string with the closest ASCII character',
528
+ section: 'edit',
529
+ returnType: 'string',
530
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-replaceSpecialChars',
531
+ examples: [{ example: '"déjà".replaceSpecialChars()', evaluated: '"deja"' }],
532
+ };
533
+ length.doc = {
534
+ name: 'length',
535
+ section: 'query',
536
+ hidden: true,
537
+ description: 'Returns the character count of a string.',
538
+ returnType: 'number',
539
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings',
540
+ };
541
+ isDomain.doc = {
542
+ name: 'isDomain',
543
+ description: 'Returns <code>true</code> if a string is a domain.',
544
+ section: 'validation',
545
+ returnType: 'boolean',
546
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isDomain',
547
+ examples: [
548
+ { example: '"n8n.io".isDomain()', evaluated: 'true' },
549
+ { example: '"http://n8n.io".isDomain()', evaluated: 'false' },
550
+ { example: '"hello".isDomain()', evaluated: 'false' },
551
+ ],
552
+ };
553
+ isEmail.doc = {
554
+ name: 'isEmail',
555
+ description: 'Returns <code>true</code> if the string is an email.',
556
+ section: 'validation',
557
+ returnType: 'boolean',
558
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isEmail',
559
+ examples: [
560
+ { example: '"me@example.com".isEmail()', evaluated: 'true' },
561
+ { example: '"It\'s me@example.com".isEmail()', evaluated: 'false' },
562
+ { example: '"hello".isEmail()', evaluated: 'false' },
563
+ ],
564
+ };
565
+ isNumeric.doc = {
566
+ name: 'isNumeric',
567
+ description: 'Returns <code>true</code> if the string represents a number.',
568
+ section: 'validation',
569
+ returnType: 'boolean',
570
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isNumeric',
571
+ examples: [
572
+ { example: '"1.2234".isNumeric()', evaluated: 'true' },
573
+ { example: '"hello".isNumeric()', evaluated: 'false' },
574
+ { example: '"123E23".isNumeric()', evaluated: 'true' },
575
+ ],
576
+ };
577
+ isUrl.doc = {
578
+ name: 'isUrl',
579
+ description: 'Returns <code>true</code> if a string is a valid URL',
580
+ section: 'validation',
581
+ returnType: 'boolean',
582
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isUrl',
583
+ examples: [
584
+ { example: '"https://n8n.io".isUrl()', evaluated: 'true' },
585
+ { example: '"n8n.io".isUrl()', evaluated: 'false' },
586
+ { example: '"hello".isUrl()', evaluated: 'false' },
587
+ ],
588
+ };
589
+ isEmpty.doc = {
590
+ name: 'isEmpty',
591
+ description: 'Returns <code>true</code> if the string has no characters or is <code>null</code>',
592
+ section: 'validation',
593
+ returnType: 'boolean',
594
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isEmpty',
595
+ examples: [
596
+ { example: '"".isEmpty()', evaluated: 'true' },
597
+ { example: '"hello".isEmpty()', evaluated: 'false' },
598
+ ],
599
+ };
600
+ isNotEmpty.doc = {
601
+ name: 'isNotEmpty',
602
+ description: 'Returns <code>true</code> if the string has at least one character.',
603
+ section: 'validation',
604
+ returnType: 'boolean',
605
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isNotEmpty',
606
+ examples: [
607
+ { example: '"hello".isNotEmpty()', evaluated: 'true' },
608
+ { example: '"".isNotEmpty()', evaluated: 'false' },
609
+ ],
610
+ };
611
+ toJsonString.doc = {
612
+ name: 'toJsonString',
613
+ description: 'Prepares the string to be inserted into a JSON object. Escapes any quotes and special characters (e.g. new lines), and wraps the string in quotes.The same as JavaScript’s JSON.stringify().',
614
+ section: 'edit',
615
+ returnType: 'string',
616
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toJsonString',
617
+ examples: [
618
+ {
619
+ example: 'The "best" colours: red\nbrown.toJsonString()',
620
+ evaluated: '"The \\"best\\" colours: red\\nbrown"',
621
+ },
622
+ { example: 'foo.toJsonString()', evaluated: '"foo"' },
623
+ ],
624
+ };
625
+ extractEmail.doc = {
626
+ name: 'extractEmail',
627
+ description: 'Extracts the first email found in the string. Returns <code>undefined</code> if none is found.',
628
+ section: 'edit',
629
+ returnType: 'string',
630
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractEmail',
631
+ examples: [
632
+ { example: '"My email is me@example.com".extractEmail()', evaluated: "'me@example.com'" },
633
+ ],
634
+ };
635
+ extractDomain.doc = {
636
+ name: 'extractDomain',
637
+ description: 'If the string is an email address or URL, returns its domain (or <code>undefined</code> if nothing found). If the string also contains other content, try using <code>extractEmail()</code> or <code>extractUrl()</code> first.',
638
+ section: 'edit',
639
+ returnType: 'string',
640
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractDomain',
641
+ examples: [
642
+ { example: '"me@example.com".extractDomain()', evaluated: "'example.com'" },
643
+ { example: '"http://n8n.io/workflows".extractDomain()', evaluated: "'n8n.io'" },
644
+ {
645
+ example: '"It\'s me@example.com".extractEmail().extractDomain()',
646
+ evaluated: "'example.com'",
647
+ },
648
+ ],
649
+ };
650
+ extractUrl.doc = {
651
+ name: 'extractUrl',
652
+ description: 'Extracts the first URL found in the string. Returns <code>undefined</code> if none is found. Only recognizes full URLs, e.g. those starting with <code>http</code>.',
653
+ section: 'edit',
654
+ returnType: 'string',
655
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractUrl',
656
+ examples: [{ example: '"Check out http://n8n.io".extractUrl()', evaluated: "'http://n8n.io'" }],
657
+ };
658
+ extractUrlPath.doc = {
659
+ name: 'extractUrlPath',
660
+ description: 'Returns the part of a URL after the domain, or <code>undefined</code> if no URL found. If the string also contains other content, try using <code>extractUrl()</code> first.',
661
+ section: 'edit',
662
+ returnType: 'string',
663
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractUrlPath',
664
+ examples: [
665
+ { example: '"http://n8n.io/workflows".extractUrlPath()', evaluated: "'/workflows'" },
666
+ {
667
+ example: '"Check out http://n8n.io/workflows".extractUrl().extractUrlPath()',
668
+ evaluated: "'/workflows'",
669
+ },
670
+ ],
671
+ };
672
+ hash.doc = {
673
+ name: 'hash',
674
+ description: 'Returns the string hashed with the given algorithm. Defaults to md5 if not specified.',
675
+ section: 'edit',
676
+ returnType: 'string',
677
+ args: [
678
+ {
679
+ name: 'algo',
680
+ optional: true,
681
+ description: 'The hashing algorithm to use. One of <code>md5</code>, <code>base64</code>, <code>sha1</code>, <code>sha224</code>, <code>sha256</code>, <code>sha384</code>, <code>sha512</code>, <code>sha3</code>, <code>ripemd160</code>\n ',
682
+ default: '"md5"',
683
+ type: 'string',
684
+ },
685
+ ],
686
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-hash',
687
+ examples: [{ example: '"hello".hash()', evaluated: "'5d41402abc4b2a76b9719d911017c592'" }],
688
+ };
689
+ quote.doc = {
690
+ name: 'quote',
691
+ description: 'Wraps a string in quotation marks, and escapes any quotation marks already in the string. Useful when constructing JSON, SQL, etc.',
692
+ section: 'edit',
693
+ returnType: 'string',
694
+ args: [
695
+ {
696
+ name: 'mark',
697
+ optional: true,
698
+ description: 'The type of quotation mark to use',
699
+ default: '"',
700
+ type: 'string',
795
701
  },
796
- };
797
- });
702
+ ],
703
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-quote',
704
+ examples: [{ example: '\'Nathan says "hi"\'.quote()', evaluated: '\'"Nathan says \\"hi\\""\'' }],
705
+ };
706
+ parseJson.doc = {
707
+ name: 'parseJson',
708
+ aliases: ['fromJson'],
709
+ description: "Returns the JavaScript value or object represented by the string, or <code>undefined</code> if the string isn't valid JSON. Single-quoted JSON is not supported.",
710
+ section: 'cast',
711
+ returnType: 'any',
712
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-parseJson',
713
+ examples: [
714
+ { example: '\'{"name":"Nathan"}\'.parseJson()', evaluated: '\'{"name":"Nathan"}\'' },
715
+ { example: "\"{'name':'Nathan'}\".parseJson()", evaluated: 'undefined' },
716
+ { example: "'hello'.parseJson()", evaluated: 'undefined' },
717
+ ],
718
+ };
719
+ base64Encode.doc = {
720
+ name: 'base64Encode',
721
+ aliases: ['toBase64'],
722
+ description: 'Converts plain text to a base64-encoded string',
723
+ examples: [{ example: '"hello".base64Encode()', evaluated: '"aGVsbG8="' }],
724
+ section: 'edit',
725
+ returnType: 'string',
726
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-base64Encode',
727
+ };
728
+ base64Decode.doc = {
729
+ name: 'base64Decode',
730
+ aliases: ['fromBase64'],
731
+ description: 'Converts a base64-encoded string to plain text',
732
+ examples: [{ example: '"aGVsbG8=".base64Decode()', evaluated: '"hello"' }],
733
+ section: 'edit',
734
+ returnType: 'string',
735
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-base64Decode',
736
+ };
737
+ toNumber.doc = {
738
+ name: 'toNumber',
739
+ description: "Converts a string representing a number to a number. Errors if the string doesn't start with a valid number.",
740
+ section: 'cast',
741
+ returnType: 'number',
742
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toNumber',
743
+ examples: [
744
+ { example: '"123".toNumber()', evaluated: '123' },
745
+ { example: '"1.23E10".toNumber()', evaluated: '12300000000' },
746
+ ],
747
+ };
748
+ const toDecimalNumber = toFloat.bind({});
749
+ const toWholeNumber = toInt.bind({});
750
+ exports.stringExtensions = {
751
+ typeName: 'String',
752
+ functions: {
753
+ hash,
754
+ removeMarkdown,
755
+ removeTags,
756
+ toDate,
757
+ toDateTime,
758
+ toBoolean,
759
+ toDecimalNumber,
760
+ toNumber,
761
+ toFloat,
762
+ toInt,
763
+ toWholeNumber,
764
+ toSentenceCase,
765
+ toSnakeCase,
766
+ toTitleCase,
767
+ urlDecode,
768
+ urlEncode,
769
+ quote,
770
+ replaceSpecialChars,
771
+ length,
772
+ isDomain,
773
+ isEmail,
774
+ isNumeric,
775
+ isUrl,
776
+ isEmpty,
777
+ isNotEmpty,
778
+ toJsonString,
779
+ extractEmail,
780
+ extractDomain,
781
+ extractUrl,
782
+ extractUrlPath,
783
+ parseJson,
784
+ base64Encode,
785
+ base64Decode,
786
+ },
787
+ };
798
788
  //# sourceMappingURL=string-extensions.js.map