@n8n/expression-runtime 0.3.0 → 0.4.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 (219) hide show
  1. package/README.md +3 -3
  2. package/dist/bundle/runtime.esm.js +2 -2
  3. package/dist/bundle/runtime.esm.js.map +3 -3
  4. package/dist/bundle/runtime.iife.js +2 -2
  5. package/dist/bundle/runtime.iife.js.map +3 -3
  6. package/dist/cjs/bridge/isolated-vm-bridge.d.ts.map +1 -0
  7. package/dist/cjs/bridge/isolated-vm-bridge.js +500 -0
  8. package/dist/cjs/bridge/isolated-vm-bridge.js.map +1 -0
  9. package/dist/cjs/build.tsbuildinfo +1 -0
  10. package/dist/cjs/evaluator/expression-evaluator.d.ts +23 -0
  11. package/dist/cjs/evaluator/expression-evaluator.d.ts.map +1 -0
  12. package/dist/cjs/evaluator/expression-evaluator.js +87 -0
  13. package/dist/cjs/evaluator/expression-evaluator.js.map +1 -0
  14. package/dist/cjs/extensions/array-extensions.d.ts.map +1 -0
  15. package/dist/cjs/extensions/array-extensions.js +632 -0
  16. package/dist/cjs/extensions/array-extensions.js.map +1 -0
  17. package/dist/cjs/extensions/boolean-extensions.d.ts.map +1 -0
  18. package/dist/cjs/extensions/boolean-extensions.js +49 -0
  19. package/dist/cjs/extensions/boolean-extensions.js.map +1 -0
  20. package/dist/cjs/extensions/date-extensions.d.ts.map +1 -0
  21. package/dist/cjs/extensions/date-extensions.js +528 -0
  22. package/dist/cjs/extensions/date-extensions.js.map +1 -0
  23. package/dist/cjs/extensions/expression-extension-error.d.ts.map +1 -0
  24. package/dist/cjs/extensions/expression-extension-error.js +25 -0
  25. package/dist/cjs/extensions/expression-extension-error.js.map +1 -0
  26. package/dist/cjs/extensions/extend.d.ts.map +1 -0
  27. package/dist/cjs/extensions/extend.js +149 -0
  28. package/dist/cjs/extensions/extend.js.map +1 -0
  29. package/dist/cjs/extensions/extensions.d.ts.map +1 -0
  30. package/dist/cjs/extensions/extensions.js +13 -0
  31. package/dist/cjs/extensions/extensions.js.map +1 -0
  32. package/dist/cjs/extensions/number-extensions.d.ts.map +1 -0
  33. package/dist/cjs/extensions/number-extensions.js +235 -0
  34. package/dist/cjs/extensions/number-extensions.js.map +1 -0
  35. package/dist/cjs/extensions/object-extensions.d.ts.map +1 -0
  36. package/dist/cjs/extensions/object-extensions.js +297 -0
  37. package/dist/cjs/extensions/object-extensions.js.map +1 -0
  38. package/dist/cjs/extensions/string-extensions.d.ts.map +1 -0
  39. package/dist/cjs/extensions/string-extensions.js +753 -0
  40. package/dist/cjs/extensions/string-extensions.js.map +1 -0
  41. package/dist/cjs/extensions/utils.d.ts.map +1 -0
  42. package/dist/cjs/extensions/utils.js +42 -0
  43. package/dist/cjs/extensions/utils.js.map +1 -0
  44. package/dist/cjs/index.d.ts +7 -0
  45. package/dist/cjs/index.d.ts.map +1 -0
  46. package/dist/cjs/index.js +34 -0
  47. package/dist/cjs/index.js.map +1 -0
  48. package/dist/cjs/runtime/index.d.ts.map +1 -0
  49. package/dist/cjs/runtime/index.js +35 -0
  50. package/dist/cjs/runtime/index.js.map +1 -0
  51. package/dist/{runtime → cjs/runtime}/lazy-proxy.d.ts +4 -0
  52. package/dist/cjs/runtime/lazy-proxy.d.ts.map +1 -0
  53. package/dist/cjs/runtime/lazy-proxy.js +179 -0
  54. package/dist/cjs/runtime/lazy-proxy.js.map +1 -0
  55. package/dist/cjs/runtime/reset.d.ts.map +1 -0
  56. package/dist/cjs/runtime/reset.js +137 -0
  57. package/dist/cjs/runtime/reset.js.map +1 -0
  58. package/dist/cjs/runtime/safe-globals.d.ts.map +1 -0
  59. package/dist/cjs/runtime/safe-globals.js +125 -0
  60. package/dist/cjs/runtime/safe-globals.js.map +1 -0
  61. package/dist/{types → cjs/types}/bridge.d.ts +2 -0
  62. package/dist/cjs/types/bridge.d.ts.map +1 -0
  63. package/dist/cjs/types/bridge.js +26 -0
  64. package/dist/cjs/types/bridge.js.map +1 -0
  65. package/dist/{types → cjs/types}/evaluator.d.ts +1 -4
  66. package/dist/cjs/types/evaluator.d.ts.map +1 -0
  67. package/dist/cjs/types/evaluator.js +47 -0
  68. package/dist/cjs/types/evaluator.js.map +1 -0
  69. package/dist/{types → cjs/types}/index.d.ts +2 -1
  70. package/dist/cjs/types/index.d.ts.map +1 -0
  71. package/dist/cjs/types/index.js +30 -0
  72. package/dist/cjs/types/index.js.map +1 -0
  73. package/dist/cjs/types/runtime.d.ts.map +1 -0
  74. package/dist/cjs/types/runtime.js +39 -0
  75. package/dist/cjs/types/runtime.js.map +1 -0
  76. package/dist/esm/bridge/isolated-vm-bridge.d.ts +132 -0
  77. package/dist/esm/bridge/isolated-vm-bridge.d.ts.map +1 -0
  78. package/dist/{bridge → esm/bridge}/isolated-vm-bridge.js +34 -11
  79. package/dist/esm/bridge/isolated-vm-bridge.js.map +1 -0
  80. package/dist/esm/build.tsbuildinfo +1 -0
  81. package/dist/esm/evaluator/expression-evaluator.d.ts +23 -0
  82. package/dist/esm/evaluator/expression-evaluator.d.ts.map +1 -0
  83. package/dist/esm/evaluator/expression-evaluator.js +73 -0
  84. package/dist/esm/evaluator/expression-evaluator.js.map +1 -0
  85. package/dist/esm/extensions/array-extensions.d.ts +34 -0
  86. package/dist/esm/extensions/array-extensions.d.ts.map +1 -0
  87. package/dist/esm/extensions/array-extensions.js.map +1 -0
  88. package/dist/esm/extensions/boolean-extensions.d.ts +6 -0
  89. package/dist/esm/extensions/boolean-extensions.d.ts.map +1 -0
  90. package/dist/esm/extensions/boolean-extensions.js.map +1 -0
  91. package/dist/esm/extensions/date-extensions.d.ts +3 -0
  92. package/dist/esm/extensions/date-extensions.d.ts.map +1 -0
  93. package/dist/esm/extensions/date-extensions.js.map +1 -0
  94. package/dist/esm/extensions/expression-extension-error.d.ts +7 -0
  95. package/dist/esm/extensions/expression-extension-error.d.ts.map +1 -0
  96. package/dist/esm/extensions/expression-extension-error.js.map +1 -0
  97. package/dist/esm/extensions/extend.d.ts +12 -0
  98. package/dist/esm/extensions/extend.d.ts.map +1 -0
  99. package/dist/esm/extensions/extend.js.map +1 -0
  100. package/dist/esm/extensions/extensions.d.ts +43 -0
  101. package/dist/esm/extensions/extensions.d.ts.map +1 -0
  102. package/dist/esm/extensions/extensions.js.map +1 -0
  103. package/dist/esm/extensions/number-extensions.d.ts +27 -0
  104. package/dist/esm/extensions/number-extensions.d.ts.map +1 -0
  105. package/dist/esm/extensions/number-extensions.js.map +1 -0
  106. package/dist/esm/extensions/object-extensions.d.ts +46 -0
  107. package/dist/esm/extensions/object-extensions.d.ts.map +1 -0
  108. package/dist/esm/extensions/object-extensions.js.map +1 -0
  109. package/dist/esm/extensions/string-extensions.d.ts +38 -0
  110. package/dist/esm/extensions/string-extensions.d.ts.map +1 -0
  111. package/dist/esm/extensions/string-extensions.js.map +1 -0
  112. package/dist/esm/extensions/utils.d.ts +4 -0
  113. package/dist/esm/extensions/utils.d.ts.map +1 -0
  114. package/dist/esm/extensions/utils.js.map +1 -0
  115. package/dist/esm/index.d.ts +7 -0
  116. package/dist/esm/index.d.ts.map +1 -0
  117. package/dist/esm/index.js +10 -0
  118. package/dist/esm/index.js.map +1 -0
  119. package/dist/esm/runtime/index.d.ts +17 -0
  120. package/dist/esm/runtime/index.d.ts.map +1 -0
  121. package/dist/esm/runtime/index.js.map +1 -0
  122. package/dist/esm/runtime/lazy-proxy.d.ts +22 -0
  123. package/dist/esm/runtime/lazy-proxy.d.ts.map +1 -0
  124. package/dist/{runtime → esm/runtime}/lazy-proxy.js +20 -6
  125. package/dist/esm/runtime/lazy-proxy.js.map +1 -0
  126. package/dist/esm/runtime/reset.d.ts +16 -0
  127. package/dist/esm/runtime/reset.d.ts.map +1 -0
  128. package/dist/esm/runtime/reset.js.map +1 -0
  129. package/dist/esm/runtime/safe-globals.d.ts +21 -0
  130. package/dist/esm/runtime/safe-globals.d.ts.map +1 -0
  131. package/dist/esm/runtime/safe-globals.js.map +1 -0
  132. package/dist/esm/types/bridge.d.ts +63 -0
  133. package/dist/esm/types/bridge.d.ts.map +1 -0
  134. package/dist/{types → esm/types}/bridge.js +6 -1
  135. package/dist/esm/types/bridge.js.map +1 -0
  136. package/dist/esm/types/evaluator.d.ts +194 -0
  137. package/dist/esm/types/evaluator.d.ts.map +1 -0
  138. package/dist/esm/types/evaluator.js.map +1 -0
  139. package/dist/esm/types/index.d.ts +11 -0
  140. package/dist/esm/types/index.d.ts.map +1 -0
  141. package/dist/{types → esm/types}/index.js +1 -0
  142. package/dist/esm/types/index.js.map +1 -0
  143. package/dist/esm/types/runtime.d.ts +20 -0
  144. package/dist/esm/types/runtime.d.ts.map +1 -0
  145. package/dist/esm/types/runtime.js.map +1 -0
  146. package/package.json +16 -5
  147. package/dist/bridge/isolated-vm-bridge.d.ts.map +0 -1
  148. package/dist/bridge/isolated-vm-bridge.js.map +0 -1
  149. package/dist/build.tsbuildinfo +0 -1
  150. package/dist/extensions/array-extensions.d.ts.map +0 -1
  151. package/dist/extensions/array-extensions.js.map +0 -1
  152. package/dist/extensions/boolean-extensions.d.ts.map +0 -1
  153. package/dist/extensions/boolean-extensions.js.map +0 -1
  154. package/dist/extensions/date-extensions.d.ts.map +0 -1
  155. package/dist/extensions/date-extensions.js.map +0 -1
  156. package/dist/extensions/expression-extension-error.d.ts.map +0 -1
  157. package/dist/extensions/expression-extension-error.js.map +0 -1
  158. package/dist/extensions/extend.d.ts.map +0 -1
  159. package/dist/extensions/extend.js.map +0 -1
  160. package/dist/extensions/extensions.d.ts.map +0 -1
  161. package/dist/extensions/extensions.js.map +0 -1
  162. package/dist/extensions/number-extensions.d.ts.map +0 -1
  163. package/dist/extensions/number-extensions.js.map +0 -1
  164. package/dist/extensions/object-extensions.d.ts.map +0 -1
  165. package/dist/extensions/object-extensions.js.map +0 -1
  166. package/dist/extensions/string-extensions.d.ts.map +0 -1
  167. package/dist/extensions/string-extensions.js.map +0 -1
  168. package/dist/extensions/utils.d.ts.map +0 -1
  169. package/dist/extensions/utils.js.map +0 -1
  170. package/dist/index.d.ts +0 -3
  171. package/dist/index.d.ts.map +0 -1
  172. package/dist/index.js +0 -2
  173. package/dist/index.js.map +0 -1
  174. package/dist/runtime/index.d.ts.map +0 -1
  175. package/dist/runtime/index.js.map +0 -1
  176. package/dist/runtime/lazy-proxy.d.ts.map +0 -1
  177. package/dist/runtime/lazy-proxy.js.map +0 -1
  178. package/dist/runtime/reset.d.ts.map +0 -1
  179. package/dist/runtime/reset.js.map +0 -1
  180. package/dist/runtime/safe-globals.d.ts.map +0 -1
  181. package/dist/runtime/safe-globals.js.map +0 -1
  182. package/dist/types/bridge.d.ts.map +0 -1
  183. package/dist/types/bridge.js.map +0 -1
  184. package/dist/types/evaluator.d.ts.map +0 -1
  185. package/dist/types/evaluator.js.map +0 -1
  186. package/dist/types/index.d.ts.map +0 -1
  187. package/dist/types/index.js.map +0 -1
  188. package/dist/types/runtime.d.ts.map +0 -1
  189. package/dist/types/runtime.js.map +0 -1
  190. /package/dist/{bridge → cjs/bridge}/isolated-vm-bridge.d.ts +0 -0
  191. /package/dist/{extensions → cjs/extensions}/array-extensions.d.ts +0 -0
  192. /package/dist/{extensions → cjs/extensions}/boolean-extensions.d.ts +0 -0
  193. /package/dist/{extensions → cjs/extensions}/date-extensions.d.ts +0 -0
  194. /package/dist/{extensions → cjs/extensions}/expression-extension-error.d.ts +0 -0
  195. /package/dist/{extensions → cjs/extensions}/extend.d.ts +0 -0
  196. /package/dist/{extensions → cjs/extensions}/extensions.d.ts +0 -0
  197. /package/dist/{extensions → cjs/extensions}/number-extensions.d.ts +0 -0
  198. /package/dist/{extensions → cjs/extensions}/object-extensions.d.ts +0 -0
  199. /package/dist/{extensions → cjs/extensions}/string-extensions.d.ts +0 -0
  200. /package/dist/{extensions → cjs/extensions}/utils.d.ts +0 -0
  201. /package/dist/{runtime → cjs/runtime}/index.d.ts +0 -0
  202. /package/dist/{runtime → cjs/runtime}/reset.d.ts +0 -0
  203. /package/dist/{runtime → cjs/runtime}/safe-globals.d.ts +0 -0
  204. /package/dist/{types → cjs/types}/runtime.d.ts +0 -0
  205. /package/dist/{extensions → esm/extensions}/array-extensions.js +0 -0
  206. /package/dist/{extensions → esm/extensions}/boolean-extensions.js +0 -0
  207. /package/dist/{extensions → esm/extensions}/date-extensions.js +0 -0
  208. /package/dist/{extensions → esm/extensions}/expression-extension-error.js +0 -0
  209. /package/dist/{extensions → esm/extensions}/extend.js +0 -0
  210. /package/dist/{extensions → esm/extensions}/extensions.js +0 -0
  211. /package/dist/{extensions → esm/extensions}/number-extensions.js +0 -0
  212. /package/dist/{extensions → esm/extensions}/object-extensions.js +0 -0
  213. /package/dist/{extensions → esm/extensions}/string-extensions.js +0 -0
  214. /package/dist/{extensions → esm/extensions}/utils.js +0 -0
  215. /package/dist/{runtime → esm/runtime}/index.js +0 -0
  216. /package/dist/{runtime → esm/runtime}/reset.js +0 -0
  217. /package/dist/{runtime → esm/runtime}/safe-globals.js +0 -0
  218. /package/dist/{types → esm/types}/evaluator.js +0 -0
  219. /package/dist/{types → esm/types}/runtime.js +0 -0
@@ -0,0 +1,753 @@
1
+ var __importDefault = (this && this.__importDefault) || function (mod) {
2
+ return (mod && mod.__esModule) ? mod : { "default": mod };
3
+ };
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", "./expression-extension-error", "./number-extensions"], 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
+ const js_base64_1 = require("js-base64");
19
+ const jssha_1 = __importDefault(require("jssha"));
20
+ const luxon_1 = require("luxon");
21
+ const md5_1 = __importDefault(require("md5"));
22
+ const title_case_1 = require("title-case");
23
+ const transliteration_1 = require("transliteration");
24
+ const expression_extension_error_1 = require("./expression-extension-error");
25
+ const number_extensions_1 = require("./number-extensions");
26
+ exports.SupportedHashAlgorithms = [
27
+ 'md5',
28
+ 'sha1',
29
+ 'sha224',
30
+ 'sha256',
31
+ 'sha384',
32
+ 'sha512',
33
+ 'sha3',
34
+ ];
35
+ // All symbols from https://www.xe.com/symbols/ as for 2022/11/09
36
+ const CURRENCY_REGEXP = /(\u004c\u0065\u006b|\u060b|\u0024|\u0192|\u20bc|\u0042\u0072|\u0042\u005a\u0024|\u0024\u0062|\u004b\u004d|\u0050|\u043b\u0432|\u0052\u0062|\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;
37
+ 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;
38
+ 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;
39
+ 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,}))/;
40
+ 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;
41
+ 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;
42
+ const CHAR_TEST_REGEXP = /\p{L}/u;
43
+ const PUNC_TEST_REGEXP = /[!?.]/;
44
+ /**
45
+ * Inline version of tryToParseDateTime from n8n-workflow/type-validation.ts
46
+ * Avoids circular dependency.
47
+ */
48
+ function tryToParseDateTime(value, defaultZone) {
49
+ if (luxon_1.DateTime.isDateTime(value) && value.isValid) {
50
+ return value;
51
+ }
52
+ if (value instanceof Date) {
53
+ const fromJSDate = luxon_1.DateTime.fromJSDate(value, { zone: defaultZone });
54
+ if (fromJSDate.isValid) {
55
+ return fromJSDate;
56
+ }
57
+ }
58
+ const dateString = String(value).trim();
59
+ const isoDate = luxon_1.DateTime.fromISO(dateString, { zone: defaultZone, setZone: true });
60
+ if (isoDate.isValid) {
61
+ return isoDate;
62
+ }
63
+ const httpDate = luxon_1.DateTime.fromHTTP(dateString, { zone: defaultZone, setZone: true });
64
+ if (httpDate.isValid) {
65
+ return httpDate;
66
+ }
67
+ const rfc2822Date = luxon_1.DateTime.fromRFC2822(dateString, { zone: defaultZone, setZone: true });
68
+ if (rfc2822Date.isValid) {
69
+ return rfc2822Date;
70
+ }
71
+ const sqlDate = luxon_1.DateTime.fromSQL(dateString, { zone: defaultZone, setZone: true });
72
+ if (sqlDate.isValid) {
73
+ return sqlDate;
74
+ }
75
+ const parsedDateTime = luxon_1.DateTime.fromMillis(Date.parse(dateString), { zone: defaultZone });
76
+ if (parsedDateTime.isValid) {
77
+ return parsedDateTime;
78
+ }
79
+ throw new expression_extension_error_1.ExpressionExtensionError('Value is not a valid date');
80
+ }
81
+ function hash(value, extraArgs) {
82
+ const algorithm = extraArgs[0]?.toLowerCase() ?? 'md5';
83
+ switch (algorithm) {
84
+ case 'base64':
85
+ return (0, js_base64_1.toBase64)(value);
86
+ case 'md5':
87
+ return (0, md5_1.default)(value);
88
+ case 'sha1':
89
+ case 'sha224':
90
+ case 'sha256':
91
+ case 'sha384':
92
+ case 'sha512':
93
+ case 'sha3':
94
+ const variant = {
95
+ sha1: 'SHA-1',
96
+ sha224: 'SHA-224',
97
+ sha256: 'SHA-256',
98
+ sha384: 'SHA-384',
99
+ sha512: 'SHA-512',
100
+ sha3: 'SHA3-512',
101
+ }[algorithm];
102
+ return new jssha_1.default(variant, 'TEXT').update(value).getHash('HEX');
103
+ default:
104
+ throw new expression_extension_error_1.ExpressionExtensionError(`Unknown algorithm ${algorithm}. Available algorithms are: ${exports.SupportedHashAlgorithms.join()}, and Base64.`);
105
+ }
106
+ }
107
+ function isEmpty(value) {
108
+ return value === '';
109
+ }
110
+ function isNotEmpty(value) {
111
+ return !isEmpty(value);
112
+ }
113
+ function length(value) {
114
+ return value.length;
115
+ }
116
+ function toJsonString(value) {
117
+ return JSON.stringify(value);
118
+ }
119
+ function removeMarkdown(value) {
120
+ let output = value;
121
+ try {
122
+ output = output.replace(/^([\s\t]*)([*\-+]|\d\.)\s+/gm, '$1');
123
+ output = output
124
+ // Header
125
+ .replace(/\n={2,}/g, '\n')
126
+ // Strikethrough
127
+ .replace(/~~/g, '')
128
+ // Fenced codeblocks
129
+ .replace(/`{3}.*\n/g, '');
130
+ output = output
131
+ // Remove HTML tags
132
+ .replace(/<[\w|\s|=|'|"|:|(|)|,|;|/|0-9|.|-]+[>|\\>]/g, '')
133
+ // Remove setext-style headers
134
+ .replace(/^[=-]{2,}\s*$/g, '')
135
+ // Remove footnotes?
136
+ .replace(/\[\^.+?\](: .*?$)?/g, '')
137
+ .replace(/\s{0,2}\[.*?\]: .*?$/g, '')
138
+ // Remove images
139
+ .replace(/!\[.*?\][[(].*?[\])]/g, '')
140
+ // Remove inline links
141
+ .replace(/\[(.*?)\][[(].*?[\])]/g, '$1')
142
+ // Remove Blockquotes
143
+ .replace(/>/g, '')
144
+ // Remove reference-style links?
145
+ .replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, '')
146
+ // Remove atx-style headers
147
+ .replace(/^#{1,6}\s*([^#]*)\s*(#{1,6})?/gm, '$1')
148
+ .replace(/([*_]{1,3})(\S.*?\S)\1/g, '$2')
149
+ .replace(/(`{3,})(.*?)\1/gm, '$2')
150
+ .replace(/^-{3,}\s*$/g, '')
151
+ .replace(/`(.+?)`/g, '$1')
152
+ .replace(/\n{2,}/g, '\n\n');
153
+ }
154
+ catch (e) {
155
+ return value;
156
+ }
157
+ return output;
158
+ }
159
+ function removeTags(value) {
160
+ return value.replace(/<[^>]*>?/gm, '');
161
+ }
162
+ function toDate(value) {
163
+ const date = new Date(Date.parse(value));
164
+ if (date.toString() === 'Invalid Date') {
165
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to date');
166
+ }
167
+ // If time component is not specified, force 00:00h
168
+ if (!/:/.test(value)) {
169
+ date.setHours(0, 0, 0);
170
+ }
171
+ return date;
172
+ }
173
+ function toDateTime(value, extraArgs = ['']) {
174
+ try {
175
+ const [valueFormat] = extraArgs;
176
+ if (valueFormat) {
177
+ if (valueFormat === 'ms' ||
178
+ valueFormat === 's' ||
179
+ valueFormat === 'us' ||
180
+ valueFormat === 'excel') {
181
+ return (0, number_extensions_1.toDateTime)(Number(value), [valueFormat]);
182
+ }
183
+ return luxon_1.DateTime.fromFormat(value, valueFormat);
184
+ }
185
+ return tryToParseDateTime(value);
186
+ }
187
+ catch (error) {
188
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to Luxon DateTime');
189
+ }
190
+ }
191
+ function urlDecode(value, extraArgs) {
192
+ const [entireString = false] = extraArgs;
193
+ if (entireString) {
194
+ return decodeURI(value.toString());
195
+ }
196
+ return decodeURIComponent(value.toString());
197
+ }
198
+ function urlEncode(value, extraArgs) {
199
+ const [entireString = false] = extraArgs;
200
+ if (entireString) {
201
+ return encodeURI(value.toString());
202
+ }
203
+ return encodeURIComponent(value.toString());
204
+ }
205
+ function toInt(value, extraArgs) {
206
+ const [radix] = extraArgs;
207
+ const int = parseInt(value.replace(CURRENCY_REGEXP, ''), radix);
208
+ if (isNaN(int)) {
209
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to integer');
210
+ }
211
+ return int;
212
+ }
213
+ function toFloat(value) {
214
+ if (value.includes(',')) {
215
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to float, expected . as decimal separator');
216
+ }
217
+ const float = parseFloat(value.replace(CURRENCY_REGEXP, ''));
218
+ if (isNaN(float)) {
219
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to float');
220
+ }
221
+ return float;
222
+ }
223
+ function toNumber(value) {
224
+ const num = Number(value.replace(CURRENCY_REGEXP, ''));
225
+ if (isNaN(num)) {
226
+ throw new expression_extension_error_1.ExpressionExtensionError('cannot convert to number');
227
+ }
228
+ return num;
229
+ }
230
+ function quote(value, extraArgs) {
231
+ const [quoteChar = '"'] = extraArgs;
232
+ return `${quoteChar}${value
233
+ .replace(/\\/g, '\\\\')
234
+ .replace(new RegExp(`\\${quoteChar}`, 'g'), `\\${quoteChar}`)}${quoteChar}`;
235
+ }
236
+ function isNumeric(value) {
237
+ if (value.includes(' '))
238
+ return false;
239
+ return !isNaN(value) && !isNaN(parseFloat(value));
240
+ }
241
+ function isUrl(value) {
242
+ return URL_REGEXP_EXACT.test(value);
243
+ }
244
+ function isDomain(value) {
245
+ return DOMAIN_REGEXP.test(value);
246
+ }
247
+ function isEmail(value) {
248
+ const result = EMAIL_REGEXP.test(value);
249
+ // email regex is loose so check manually for now
250
+ if (result && value.includes(' ')) {
251
+ return false;
252
+ }
253
+ return result;
254
+ }
255
+ function toTitleCase(value) {
256
+ return (0, title_case_1.titleCase)(value);
257
+ }
258
+ function replaceSpecialChars(value) {
259
+ return (0, transliteration_1.transliterate)(value, { unknown: '?' });
260
+ }
261
+ function toSentenceCase(value) {
262
+ let current = value.slice();
263
+ let buffer = '';
264
+ while (CHAR_TEST_REGEXP.test(current)) {
265
+ const charIndex = current.search(CHAR_TEST_REGEXP);
266
+ current =
267
+ current.slice(0, charIndex) +
268
+ current[charIndex].toLocaleUpperCase() +
269
+ current.slice(charIndex + 1).toLocaleLowerCase();
270
+ const puncIndex = current.search(PUNC_TEST_REGEXP);
271
+ if (puncIndex === -1) {
272
+ buffer += current;
273
+ current = '';
274
+ break;
275
+ }
276
+ buffer += current.slice(0, puncIndex + 1);
277
+ current = current.slice(puncIndex + 1);
278
+ }
279
+ return buffer;
280
+ }
281
+ function toSnakeCase(value) {
282
+ return value
283
+ .toLocaleLowerCase()
284
+ .replace(/[ \-]/g, '_')
285
+ .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g, '');
286
+ }
287
+ function extractEmail(value) {
288
+ const matched = EMAIL_REGEXP.exec(value);
289
+ if (!matched) {
290
+ return undefined;
291
+ }
292
+ return matched[0];
293
+ }
294
+ function extractDomain(value) {
295
+ if (isEmail(value)) {
296
+ const matched = EMAIL_REGEXP.exec(value);
297
+ // This shouldn't happen
298
+ if (!matched) {
299
+ return undefined;
300
+ }
301
+ return matched.groups?.domain;
302
+ }
303
+ const domainMatch = value.match(DOMAIN_EXTRACT_REGEXP);
304
+ if (domainMatch) {
305
+ return domainMatch[1];
306
+ }
307
+ return undefined;
308
+ }
309
+ function extractUrl(value) {
310
+ const matched = URL_REGEXP.exec(value);
311
+ if (!matched) {
312
+ return undefined;
313
+ }
314
+ return matched[0];
315
+ }
316
+ function extractUrlPath(value) {
317
+ try {
318
+ const url = new URL(value);
319
+ return url.pathname;
320
+ }
321
+ catch (error) {
322
+ return undefined;
323
+ }
324
+ }
325
+ function parseJson(value) {
326
+ try {
327
+ return JSON.parse(value);
328
+ }
329
+ catch (error) {
330
+ if (value.includes("'")) {
331
+ throw new expression_extension_error_1.ExpressionExtensionError("Parsing failed. Check you're using double quotes");
332
+ }
333
+ throw new expression_extension_error_1.ExpressionExtensionError('Parsing failed');
334
+ }
335
+ }
336
+ function toBoolean(value) {
337
+ const normalized = value.toLowerCase();
338
+ const FALSY = new Set(['false', 'no', '0']);
339
+ return normalized.length > 0 && !FALSY.has(normalized);
340
+ }
341
+ function base64Encode(value) {
342
+ return (0, js_base64_1.toBase64)(value);
343
+ }
344
+ function base64Decode(value) {
345
+ return (0, js_base64_1.fromBase64)(value);
346
+ }
347
+ removeMarkdown.doc = {
348
+ name: 'removeMarkdown',
349
+ description: 'Removes any Markdown formatting from the string. Also removes HTML tags.',
350
+ section: 'edit',
351
+ returnType: 'string',
352
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-removeMarkdown',
353
+ examples: [{ example: '"*bold*, [link]()".removeMarkdown()', evaluated: '"bold, link"' }],
354
+ };
355
+ removeTags.doc = {
356
+ name: 'removeTags',
357
+ description: 'Removes tags, such as HTML or XML, from the string.',
358
+ section: 'edit',
359
+ returnType: 'string',
360
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-removeTags',
361
+ examples: [{ example: '"<b>bold</b>, <a>link</a>".removeTags()', evaluated: '"bold, link"' }],
362
+ };
363
+ toDate.doc = {
364
+ name: 'toDate',
365
+ description: 'Converts a string to a date.',
366
+ section: 'cast',
367
+ returnType: 'Date',
368
+ hidden: true,
369
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toDate',
370
+ };
371
+ toDateTime.doc = {
372
+ name: 'toDateTime',
373
+ 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>.',
374
+ section: 'cast',
375
+ returnType: 'DateTime',
376
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toDateTime',
377
+ examples: [
378
+ { example: '"2024-03-29T18:06:31.798+01:00".toDateTime()' },
379
+ { example: '"Fri, 29 Mar 2024 18:08:01 +0100".toDateTime()' },
380
+ { example: '"20240329".toDateTime()' },
381
+ { example: '"1711732132990".toDateTime("ms")' },
382
+ { example: '"31-01-2024".toDateTime("dd-MM-yyyy")' },
383
+ ],
384
+ args: [
385
+ {
386
+ name: 'format',
387
+ optional: true,
388
+ 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>.',
389
+ type: 'string',
390
+ },
391
+ ],
392
+ };
393
+ toBoolean.doc = {
394
+ name: 'toBoolean',
395
+ 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.',
396
+ section: 'cast',
397
+ returnType: 'boolean',
398
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toBoolean',
399
+ examples: [
400
+ { example: '"true".toBoolean()', evaluated: 'true' },
401
+ { example: '"false".toBoolean()', evaluated: 'false' },
402
+ { example: '"0".toBoolean()', evaluated: 'false' },
403
+ { example: '"hello".toBoolean()', evaluated: 'true' },
404
+ ],
405
+ };
406
+ toFloat.doc = {
407
+ name: 'toFloat',
408
+ description: 'Converts a string to a decimal number.',
409
+ section: 'cast',
410
+ returnType: 'number',
411
+ aliases: ['toDecimalNumber'],
412
+ hidden: true,
413
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toDecimalNumber',
414
+ };
415
+ toInt.doc = {
416
+ name: 'toInt',
417
+ description: 'Converts a string to an integer.',
418
+ section: 'cast',
419
+ returnType: 'number',
420
+ args: [{ name: 'radix?', type: 'number' }],
421
+ aliases: ['toWholeNumber'],
422
+ hidden: true,
423
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toInt',
424
+ };
425
+ toSentenceCase.doc = {
426
+ name: 'toSentenceCase',
427
+ description: 'Changes the capitalization of the string to sentence case. The first letter of each sentence is capitalized and all others are lowercased.',
428
+ examples: [{ example: '"quick! brown FOX".toSentenceCase()', evaluated: '"Quick! Brown fox"' }],
429
+ section: 'case',
430
+ returnType: 'string',
431
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toSentenceCase',
432
+ };
433
+ toSnakeCase.doc = {
434
+ name: 'toSnakeCase',
435
+ 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.',
436
+ examples: [{ example: '"quick brown $FOX".toSnakeCase()', evaluated: '"quick_brown_fox"' }],
437
+ section: 'case',
438
+ returnType: 'string',
439
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toSnakeCase',
440
+ };
441
+ toTitleCase.doc = {
442
+ name: 'toTitleCase',
443
+ 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').",
444
+ examples: [{ example: '"quick a brown FOX".toTitleCase()', evaluated: '"Quick a Brown Fox"' }],
445
+ section: 'case',
446
+ returnType: 'string',
447
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toTitleCase',
448
+ };
449
+ urlEncode.doc = {
450
+ name: 'urlEncode',
451
+ 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>.',
452
+ section: 'edit',
453
+ args: [
454
+ {
455
+ name: 'allChars',
456
+ optional: true,
457
+ description: 'Whether to encode characters that are part of the URI syntax (e.g. <code>=</code>, <code>?</code>)',
458
+ default: 'false',
459
+ type: 'boolean',
460
+ },
461
+ ],
462
+ returnType: 'string',
463
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-urlEncode',
464
+ examples: [
465
+ { example: '"name=Nathan Automat".urlEncode()', evaluated: '"name%3DNathan%20Automat"' },
466
+ { example: '"name=Nathan Automat".urlEncode(true)', evaluated: '"name=Nathan%20Automat"' },
467
+ ],
468
+ };
469
+ urlDecode.doc = {
470
+ name: 'urlDecode',
471
+ description: 'Decodes a URL-encoded string. Replaces any character codes in the form of <code>%XX</code> with their corresponding characters.',
472
+ args: [
473
+ {
474
+ name: 'allChars',
475
+ optional: true,
476
+ description: 'Whether to decode characters that are part of the URI syntax (e.g. <code>=</code>, <code>?</code>)',
477
+ default: 'false',
478
+ type: 'boolean',
479
+ },
480
+ ],
481
+ section: 'edit',
482
+ returnType: 'string',
483
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-urlDecode',
484
+ examples: [
485
+ { example: '"name%3DNathan%20Automat".urlDecode()', evaluated: '"name=Nathan Automat"' },
486
+ { example: '"name%3DNathan%20Automat".urlDecode(true)', evaluated: '"name%3DNathan Automat"' },
487
+ ],
488
+ };
489
+ replaceSpecialChars.doc = {
490
+ name: 'replaceSpecialChars',
491
+ description: 'Replaces special characters in the string with the closest ASCII character',
492
+ section: 'edit',
493
+ returnType: 'string',
494
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-replaceSpecialChars',
495
+ examples: [{ example: '"déjà".replaceSpecialChars()', evaluated: '"deja"' }],
496
+ };
497
+ length.doc = {
498
+ name: 'length',
499
+ section: 'query',
500
+ hidden: true,
501
+ description: 'Returns the character count of a string.',
502
+ returnType: 'number',
503
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings',
504
+ };
505
+ isDomain.doc = {
506
+ name: 'isDomain',
507
+ description: 'Returns <code>true</code> if a string is a domain.',
508
+ section: 'validation',
509
+ returnType: 'boolean',
510
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isDomain',
511
+ examples: [
512
+ { example: '"n8n.io".isDomain()', evaluated: 'true' },
513
+ { example: '"http://n8n.io".isDomain()', evaluated: 'false' },
514
+ { example: '"hello".isDomain()', evaluated: 'false' },
515
+ ],
516
+ };
517
+ isEmail.doc = {
518
+ name: 'isEmail',
519
+ description: 'Returns <code>true</code> if the string is an email.',
520
+ section: 'validation',
521
+ returnType: 'boolean',
522
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isEmail',
523
+ examples: [
524
+ { example: '"me@example.com".isEmail()', evaluated: 'true' },
525
+ { example: '"It\'s me@example.com".isEmail()', evaluated: 'false' },
526
+ { example: '"hello".isEmail()', evaluated: 'false' },
527
+ ],
528
+ };
529
+ isNumeric.doc = {
530
+ name: 'isNumeric',
531
+ description: 'Returns <code>true</code> if the string represents a number.',
532
+ section: 'validation',
533
+ returnType: 'boolean',
534
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isNumeric',
535
+ examples: [
536
+ { example: '"1.2234".isNumeric()', evaluated: 'true' },
537
+ { example: '"hello".isNumeric()', evaluated: 'false' },
538
+ { example: '"123E23".isNumeric()', evaluated: 'true' },
539
+ ],
540
+ };
541
+ isUrl.doc = {
542
+ name: 'isUrl',
543
+ description: 'Returns <code>true</code> if a string is a valid URL',
544
+ section: 'validation',
545
+ returnType: 'boolean',
546
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isUrl',
547
+ examples: [
548
+ { example: '"https://n8n.io".isUrl()', evaluated: 'true' },
549
+ { example: '"n8n.io".isUrl()', evaluated: 'false' },
550
+ { example: '"hello".isUrl()', evaluated: 'false' },
551
+ ],
552
+ };
553
+ isEmpty.doc = {
554
+ name: 'isEmpty',
555
+ description: 'Returns <code>true</code> if the string has no characters or is <code>null</code>',
556
+ section: 'validation',
557
+ returnType: 'boolean',
558
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isEmpty',
559
+ examples: [
560
+ { example: '"".isEmpty()', evaluated: 'true' },
561
+ { example: '"hello".isEmpty()', evaluated: 'false' },
562
+ ],
563
+ };
564
+ isNotEmpty.doc = {
565
+ name: 'isNotEmpty',
566
+ description: 'Returns <code>true</code> if the string has at least one character.',
567
+ section: 'validation',
568
+ returnType: 'boolean',
569
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-isNotEmpty',
570
+ examples: [
571
+ { example: '"hello".isNotEmpty()', evaluated: 'true' },
572
+ { example: '"".isNotEmpty()', evaluated: 'false' },
573
+ ],
574
+ };
575
+ toJsonString.doc = {
576
+ name: 'toJsonString',
577
+ 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().",
578
+ section: 'edit',
579
+ returnType: 'string',
580
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toJsonString',
581
+ examples: [
582
+ {
583
+ example: 'The "best" colours: red\nbrown.toJsonString()',
584
+ evaluated: '"The \\"best\\" colours: red\\nbrown"',
585
+ },
586
+ { example: 'foo.toJsonString()', evaluated: '"foo"' },
587
+ ],
588
+ };
589
+ extractEmail.doc = {
590
+ name: 'extractEmail',
591
+ description: 'Extracts the first email found in the string. Returns <code>undefined</code> if none is found.',
592
+ section: 'edit',
593
+ returnType: 'string',
594
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractEmail',
595
+ examples: [
596
+ { example: '"My email is me@example.com".extractEmail()', evaluated: "'me@example.com'" },
597
+ ],
598
+ };
599
+ extractDomain.doc = {
600
+ name: 'extractDomain',
601
+ 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.',
602
+ section: 'edit',
603
+ returnType: 'string',
604
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractDomain',
605
+ examples: [
606
+ { example: '"me@example.com".extractDomain()', evaluated: "'example.com'" },
607
+ { example: '"http://n8n.io/workflows".extractDomain()', evaluated: "'n8n.io'" },
608
+ {
609
+ example: '"It\'s me@example.com".extractEmail().extractDomain()',
610
+ evaluated: "'example.com'",
611
+ },
612
+ ],
613
+ };
614
+ extractUrl.doc = {
615
+ name: 'extractUrl',
616
+ 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>.',
617
+ section: 'edit',
618
+ returnType: 'string',
619
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractUrl',
620
+ examples: [{ example: '"Check out http://n8n.io".extractUrl()', evaluated: "'http://n8n.io'" }],
621
+ };
622
+ extractUrlPath.doc = {
623
+ name: 'extractUrlPath',
624
+ 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.',
625
+ section: 'edit',
626
+ returnType: 'string',
627
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-extractUrlPath',
628
+ examples: [
629
+ { example: '"http://n8n.io/workflows".extractUrlPath()', evaluated: "'/workflows'" },
630
+ {
631
+ example: '"Check out http://n8n.io/workflows".extractUrl().extractUrlPath()',
632
+ evaluated: "'/workflows'",
633
+ },
634
+ ],
635
+ };
636
+ hash.doc = {
637
+ name: 'hash',
638
+ description: 'Returns the string hashed with the given algorithm. Defaults to md5 if not specified.',
639
+ section: 'edit',
640
+ returnType: 'string',
641
+ args: [
642
+ {
643
+ name: 'algo',
644
+ optional: true,
645
+ 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 ',
646
+ default: '"md5"',
647
+ type: 'string',
648
+ },
649
+ ],
650
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-hash',
651
+ examples: [{ example: '"hello".hash()', evaluated: "'5d41402abc4b2a76b9719d911017c592'" }],
652
+ };
653
+ quote.doc = {
654
+ name: 'quote',
655
+ description: 'Wraps a string in quotation marks, and escapes any quotation marks already in the string. Useful when constructing JSON, SQL, etc.',
656
+ section: 'edit',
657
+ returnType: 'string',
658
+ args: [
659
+ {
660
+ name: 'mark',
661
+ optional: true,
662
+ description: 'The type of quotation mark to use',
663
+ default: '"',
664
+ type: 'string',
665
+ },
666
+ ],
667
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-quote',
668
+ examples: [{ example: '\'Nathan says "hi"\'.quote()', evaluated: '\'"Nathan says \\"hi\\""\'' }],
669
+ };
670
+ parseJson.doc = {
671
+ name: 'parseJson',
672
+ aliases: ['fromJson'],
673
+ 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.",
674
+ section: 'cast',
675
+ returnType: 'any',
676
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-parseJson',
677
+ examples: [
678
+ { example: '\'{"name":"Nathan"}\'.parseJson()', evaluated: '\'{"name":"Nathan"}\'' },
679
+ { example: "\"{'name':'Nathan'}\".parseJson()", evaluated: 'undefined' },
680
+ { example: "'hello'.parseJson()", evaluated: 'undefined' },
681
+ ],
682
+ };
683
+ base64Encode.doc = {
684
+ name: 'base64Encode',
685
+ aliases: ['toBase64'],
686
+ description: 'Converts plain text to a base64-encoded string',
687
+ examples: [{ example: '"hello".base64Encode()', evaluated: '"aGVsbG8="' }],
688
+ section: 'edit',
689
+ returnType: 'string',
690
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-base64Encode',
691
+ };
692
+ base64Decode.doc = {
693
+ name: 'base64Decode',
694
+ aliases: ['fromBase64'],
695
+ description: 'Converts a base64-encoded string to plain text',
696
+ examples: [{ example: '"aGVsbG8=".base64Decode()', evaluated: '"hello"' }],
697
+ section: 'edit',
698
+ returnType: 'string',
699
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-base64Decode',
700
+ };
701
+ toNumber.doc = {
702
+ name: 'toNumber',
703
+ description: "Converts a string representing a number to a number. Errors if the string doesn't start with a valid number.",
704
+ section: 'cast',
705
+ returnType: 'number',
706
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/strings/#string-toNumber',
707
+ examples: [
708
+ { example: '"123".toNumber()', evaluated: '123' },
709
+ { example: '"1.23E10".toNumber()', evaluated: '12300000000' },
710
+ ],
711
+ };
712
+ const toDecimalNumber = toFloat.bind({});
713
+ const toWholeNumber = toInt.bind({});
714
+ exports.stringExtensions = {
715
+ typeName: 'String',
716
+ functions: {
717
+ hash,
718
+ removeMarkdown,
719
+ removeTags,
720
+ toDate,
721
+ toDateTime,
722
+ toBoolean,
723
+ toDecimalNumber,
724
+ toNumber,
725
+ toFloat,
726
+ toInt,
727
+ toWholeNumber,
728
+ toSentenceCase,
729
+ toSnakeCase,
730
+ toTitleCase,
731
+ urlDecode,
732
+ urlEncode,
733
+ quote,
734
+ replaceSpecialChars,
735
+ length,
736
+ isDomain,
737
+ isEmail,
738
+ isNumeric,
739
+ isUrl,
740
+ isEmpty,
741
+ isNotEmpty,
742
+ toJsonString,
743
+ extractEmail,
744
+ extractDomain,
745
+ extractUrl,
746
+ extractUrlPath,
747
+ parseJson,
748
+ base64Encode,
749
+ base64Decode,
750
+ },
751
+ };
752
+ });
753
+ //# sourceMappingURL=string-extensions.js.map