@n8n/expression-runtime 0.22.0 → 0.23.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 (109) hide show
  1. package/dist/cjs/bridge/bridge-messages.d.ts +8 -8
  2. package/dist/cjs/bridge/bridge-messages.js +234 -244
  3. package/dist/cjs/bridge/bridge-messages.js.map +1 -1
  4. package/dist/cjs/bridge/isolated-vm-bridge.d.ts.map +1 -1
  5. package/dist/cjs/bridge/isolated-vm-bridge.js +633 -643
  6. package/dist/cjs/bridge/isolated-vm-bridge.js.map +1 -1
  7. package/dist/cjs/build.tsbuildinfo +1 -1
  8. package/dist/cjs/evaluator/error-classification.js +15 -25
  9. package/dist/cjs/evaluator/error-classification.js.map +1 -1
  10. package/dist/cjs/evaluator/expression-evaluator.d.ts.map +1 -1
  11. package/dist/cjs/evaluator/expression-evaluator.js +152 -162
  12. package/dist/cjs/evaluator/expression-evaluator.js.map +1 -1
  13. package/dist/cjs/evaluator/lru-cache.d.ts.map +1 -1
  14. package/dist/cjs/evaluator/lru-cache.js +35 -45
  15. package/dist/cjs/evaluator/lru-cache.js.map +1 -1
  16. package/dist/cjs/extensions/array-extensions.js +589 -599
  17. package/dist/cjs/extensions/array-extensions.js.map +1 -1
  18. package/dist/cjs/extensions/boolean-extensions.js +38 -48
  19. package/dist/cjs/extensions/boolean-extensions.js.map +1 -1
  20. package/dist/cjs/extensions/date-extensions.js +500 -510
  21. package/dist/cjs/extensions/date-extensions.js.map +1 -1
  22. package/dist/cjs/extensions/expression-extension-error.d.ts.map +1 -1
  23. package/dist/cjs/extensions/expression-extension-error.js +12 -22
  24. package/dist/cjs/extensions/expression-extension-error.js.map +1 -1
  25. package/dist/cjs/extensions/extend.js +162 -172
  26. package/dist/cjs/extensions/extend.js.map +1 -1
  27. package/dist/cjs/extensions/extensions.js +2 -12
  28. package/dist/cjs/extensions/function-extensions.d.ts +10 -18
  29. package/dist/cjs/extensions/function-extensions.d.ts.map +1 -1
  30. package/dist/cjs/extensions/function-extensions.js +78 -88
  31. package/dist/cjs/extensions/function-extensions.js.map +1 -1
  32. package/dist/cjs/extensions/number-extensions.js +225 -235
  33. package/dist/cjs/extensions/number-extensions.js.map +1 -1
  34. package/dist/cjs/extensions/object-extensions.js +286 -296
  35. package/dist/cjs/extensions/object-extensions.js.map +1 -1
  36. package/dist/cjs/extensions/string-extensions.d.ts +1 -1
  37. package/dist/cjs/extensions/string-extensions.d.ts.map +1 -1
  38. package/dist/cjs/extensions/string-extensions.js +758 -768
  39. package/dist/cjs/extensions/string-extensions.js.map +1 -1
  40. package/dist/cjs/extensions/utils.d.ts.map +1 -1
  41. package/dist/cjs/extensions/utils.js +28 -38
  42. package/dist/cjs/extensions/utils.js.map +1 -1
  43. package/dist/cjs/index.js +32 -42
  44. package/dist/cjs/index.js.map +1 -1
  45. package/dist/cjs/observability/metrics.d.ts +27 -27
  46. package/dist/cjs/observability/metrics.d.ts.map +1 -1
  47. package/dist/cjs/observability/metrics.js +59 -69
  48. package/dist/cjs/observability/metrics.js.map +1 -1
  49. package/dist/cjs/observability/noop-provider.js +28 -38
  50. package/dist/cjs/observability/noop-provider.js.map +1 -1
  51. package/dist/cjs/pool/idle-scaling-pool.d.ts.map +1 -1
  52. package/dist/cjs/pool/idle-scaling-pool.js +134 -144
  53. package/dist/cjs/pool/idle-scaling-pool.js.map +1 -1
  54. package/dist/cjs/pool/isolate-pool.d.ts.map +1 -1
  55. package/dist/cjs/pool/isolate-pool.js +101 -111
  56. package/dist/cjs/pool/isolate-pool.js.map +1 -1
  57. package/dist/cjs/runtime/context.js +418 -428
  58. package/dist/cjs/runtime/context.js.map +1 -1
  59. package/dist/cjs/runtime/index.js +26 -36
  60. package/dist/cjs/runtime/index.js.map +1 -1
  61. package/dist/cjs/runtime/jmespath.js +72 -82
  62. package/dist/cjs/runtime/jmespath.js.map +1 -1
  63. package/dist/cjs/runtime/lazy-proxy.js +238 -248
  64. package/dist/cjs/runtime/lazy-proxy.js.map +1 -1
  65. package/dist/cjs/runtime/safe-globals.d.ts.map +1 -1
  66. package/dist/cjs/runtime/safe-globals.js +134 -144
  67. package/dist/cjs/runtime/safe-globals.js.map +1 -1
  68. package/dist/cjs/runtime/serialize.js +54 -64
  69. package/dist/cjs/runtime/serialize.js.map +1 -1
  70. package/dist/cjs/runtime/utils.js +20 -30
  71. package/dist/cjs/runtime/utils.js.map +1 -1
  72. package/dist/cjs/types/bridge.js +15 -25
  73. package/dist/cjs/types/bridge.js.map +1 -1
  74. package/dist/cjs/types/evaluator.d.ts.map +1 -1
  75. package/dist/cjs/types/evaluator.js +35 -45
  76. package/dist/cjs/types/evaluator.js.map +1 -1
  77. package/dist/cjs/types/index.js +14 -24
  78. package/dist/cjs/types/index.js.map +1 -1
  79. package/dist/cjs/types/runtime.d.ts.map +1 -1
  80. package/dist/cjs/types/runtime.js +27 -37
  81. package/dist/cjs/types/runtime.js.map +1 -1
  82. package/dist/esm/bridge/bridge-messages.d.ts +8 -8
  83. package/dist/esm/bridge/isolated-vm-bridge.d.ts.map +1 -1
  84. package/dist/esm/bridge/isolated-vm-bridge.js.map +1 -1
  85. package/dist/esm/build.tsbuildinfo +1 -1
  86. package/dist/esm/evaluator/expression-evaluator.d.ts.map +1 -1
  87. package/dist/esm/evaluator/lru-cache.d.ts.map +1 -1
  88. package/dist/esm/evaluator/lru-cache.js.map +1 -1
  89. package/dist/esm/extensions/expression-extension-error.d.ts.map +1 -1
  90. package/dist/esm/extensions/function-extensions.d.ts +10 -18
  91. package/dist/esm/extensions/function-extensions.d.ts.map +1 -1
  92. package/dist/esm/extensions/number-extensions.js.map +1 -1
  93. package/dist/esm/extensions/string-extensions.d.ts +1 -1
  94. package/dist/esm/extensions/string-extensions.d.ts.map +1 -1
  95. package/dist/esm/extensions/string-extensions.js.map +1 -1
  96. package/dist/esm/extensions/utils.d.ts.map +1 -1
  97. package/dist/esm/observability/metrics.d.ts +27 -27
  98. package/dist/esm/observability/metrics.d.ts.map +1 -1
  99. package/dist/esm/pool/idle-scaling-pool.d.ts.map +1 -1
  100. package/dist/esm/pool/idle-scaling-pool.js.map +1 -1
  101. package/dist/esm/pool/isolate-pool.d.ts.map +1 -1
  102. package/dist/esm/pool/isolate-pool.js.map +1 -1
  103. package/dist/esm/runtime/lazy-proxy.js.map +1 -1
  104. package/dist/esm/runtime/safe-globals.d.ts.map +1 -1
  105. package/dist/esm/types/evaluator.d.ts.map +1 -1
  106. package/dist/esm/types/evaluator.js.map +1 -1
  107. package/dist/esm/types/runtime.d.ts.map +1 -1
  108. package/dist/esm/types/runtime.js.map +1 -1
  109. package/package.json +6 -5
@@ -1,528 +1,518 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dateExtensions = void 0;
4
+ const luxon_1 = require("luxon");
5
+ const expression_extension_error_1 = require("./expression-extension-error");
6
+ const string_extensions_1 = require("./string-extensions");
7
+ const utils_1 = require("./utils");
8
+ const durationUnits = [
9
+ 'milliseconds',
10
+ 'seconds',
11
+ 'minutes',
12
+ 'hours',
13
+ 'days',
14
+ 'weeks',
15
+ 'months',
16
+ 'quarters',
17
+ 'years',
18
+ ];
19
+ const dateParts = [
20
+ 'day',
21
+ 'week',
22
+ 'month',
23
+ 'year',
24
+ 'hour',
25
+ 'minute',
26
+ 'second',
27
+ 'millisecond',
28
+ 'weekNumber',
29
+ 'yearDayNumber',
30
+ 'weekday',
31
+ ];
32
+ const DURATION_MAP = {
33
+ day: 'days',
34
+ month: 'months',
35
+ year: 'years',
36
+ week: 'weeks',
37
+ hour: 'hours',
38
+ minute: 'minutes',
39
+ second: 'seconds',
40
+ millisecond: 'milliseconds',
41
+ ms: 'milliseconds',
42
+ sec: 'seconds',
43
+ secs: 'seconds',
44
+ hr: 'hours',
45
+ hrs: 'hours',
46
+ min: 'minutes',
47
+ mins: 'minutes',
48
+ };
49
+ const DATETIMEUNIT_MAP = {
50
+ days: 'day',
51
+ months: 'month',
52
+ years: 'year',
53
+ hours: 'hour',
54
+ minutes: 'minute',
55
+ seconds: 'second',
56
+ milliseconds: 'millisecond',
57
+ hrs: 'hour',
58
+ hr: 'hour',
59
+ mins: 'minute',
60
+ min: 'minute',
61
+ secs: 'second',
62
+ sec: 'second',
63
+ ms: 'millisecond',
64
+ };
65
+ function isDateTime(date) {
66
+ return date ? luxon_1.DateTime.isDateTime(date) : false;
67
+ }
68
+ function toDateTime(date) {
69
+ if (isDateTime(date))
70
+ return date;
71
+ if (typeof date === 'string') {
72
+ return (0, string_extensions_1.toDateTime)(date);
5
73
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "luxon", "./expression-extension-error", "./string-extensions", "./utils"], factory);
74
+ return luxon_1.DateTime.fromJSDate(date);
75
+ }
76
+ function generateDurationObject(durationValue, unit) {
77
+ const convertedUnit = DURATION_MAP[unit] || unit;
78
+ return { [`${convertedUnit}`]: durationValue };
79
+ }
80
+ function beginningOf(date, extraArgs) {
81
+ const [rawUnit = 'week'] = extraArgs;
82
+ const unit = DATETIMEUNIT_MAP[rawUnit] || rawUnit;
83
+ if (isDateTime(date))
84
+ return date.startOf(unit);
85
+ return luxon_1.DateTime.fromJSDate(date).startOf(unit).toJSDate();
86
+ }
87
+ function endOfMonth(date) {
88
+ if (isDateTime(date))
89
+ return date.endOf('month');
90
+ return luxon_1.DateTime.fromJSDate(date).endOf('month').toJSDate();
91
+ }
92
+ function extract(date, args) {
93
+ let [part = 'week'] = args;
94
+ if (part === 'yearDayNumber') {
95
+ date = isDateTime(date) ? date.toJSDate() : date;
96
+ const firstDayOfTheYear = new Date(date.getFullYear(), 0, 0);
97
+ const diff = date.getTime() -
98
+ firstDayOfTheYear.getTime() +
99
+ (firstDayOfTheYear.getTimezoneOffset() - date.getTimezoneOffset()) * 60 * 1000;
100
+ return Math.floor(diff / (1000 * 60 * 60 * 24));
8
101
  }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.dateExtensions = void 0;
13
- const luxon_1 = require("luxon");
14
- const expression_extension_error_1 = require("./expression-extension-error");
15
- const string_extensions_1 = require("./string-extensions");
16
- const utils_1 = require("./utils");
17
- const durationUnits = [
18
- 'milliseconds',
19
- 'seconds',
20
- 'minutes',
21
- 'hours',
22
- 'days',
23
- 'weeks',
24
- 'months',
25
- 'quarters',
26
- 'years',
27
- ];
28
- const dateParts = [
29
- 'day',
30
- 'week',
31
- 'month',
32
- 'year',
33
- 'hour',
34
- 'minute',
35
- 'second',
36
- 'millisecond',
37
- 'weekNumber',
38
- 'yearDayNumber',
39
- 'weekday',
40
- ];
41
- const DURATION_MAP = {
42
- day: 'days',
43
- month: 'months',
44
- year: 'years',
45
- week: 'weeks',
46
- hour: 'hours',
47
- minute: 'minutes',
48
- second: 'seconds',
49
- millisecond: 'milliseconds',
50
- ms: 'milliseconds',
51
- sec: 'seconds',
52
- secs: 'seconds',
53
- hr: 'hours',
54
- hrs: 'hours',
55
- min: 'minutes',
56
- mins: 'minutes',
57
- };
58
- const DATETIMEUNIT_MAP = {
59
- days: 'day',
60
- months: 'month',
61
- years: 'year',
62
- hours: 'hour',
63
- minutes: 'minute',
64
- seconds: 'second',
65
- milliseconds: 'millisecond',
66
- hrs: 'hour',
67
- hr: 'hour',
68
- mins: 'minute',
69
- min: 'minute',
70
- secs: 'second',
71
- sec: 'second',
72
- ms: 'millisecond',
73
- };
74
- function isDateTime(date) {
75
- return date ? luxon_1.DateTime.isDateTime(date) : false;
102
+ if (part === 'week')
103
+ part = 'weekNumber';
104
+ const unit = DATETIMEUNIT_MAP[part] || part;
105
+ if (isDateTime(date))
106
+ return date.get(unit);
107
+ return luxon_1.DateTime.fromJSDate(date).get(unit);
108
+ }
109
+ function format(date, extraArgs) {
110
+ const [dateFormat, localeOpts = {}] = extraArgs;
111
+ if (isDateTime(date)) {
112
+ return date.toFormat(dateFormat, { ...localeOpts });
76
113
  }
77
- function toDateTime(date) {
78
- if (isDateTime(date))
79
- return date;
80
- if (typeof date === 'string') {
81
- return (0, string_extensions_1.toDateTime)(date);
82
- }
83
- return luxon_1.DateTime.fromJSDate(date);
84
- }
85
- function generateDurationObject(durationValue, unit) {
86
- const convertedUnit = DURATION_MAP[unit] || unit;
87
- return { [`${convertedUnit}`]: durationValue };
88
- }
89
- function beginningOf(date, extraArgs) {
90
- const [rawUnit = 'week'] = extraArgs;
91
- const unit = DATETIMEUNIT_MAP[rawUnit] || rawUnit;
92
- if (isDateTime(date))
93
- return date.startOf(unit);
94
- return luxon_1.DateTime.fromJSDate(date).startOf(unit).toJSDate();
95
- }
96
- function endOfMonth(date) {
97
- if (isDateTime(date))
98
- return date.endOf('month');
99
- return luxon_1.DateTime.fromJSDate(date).endOf('month').toJSDate();
100
- }
101
- function extract(date, args) {
102
- let [part = 'week'] = args;
103
- if (part === 'yearDayNumber') {
104
- date = isDateTime(date) ? date.toJSDate() : date;
105
- const firstDayOfTheYear = new Date(date.getFullYear(), 0, 0);
106
- const diff = date.getTime() -
107
- firstDayOfTheYear.getTime() +
108
- (firstDayOfTheYear.getTimezoneOffset() - date.getTimezoneOffset()) * 60 * 1000;
109
- return Math.floor(diff / (1000 * 60 * 60 * 24));
110
- }
111
- if (part === 'week')
112
- part = 'weekNumber';
113
- const unit = DATETIMEUNIT_MAP[part] || part;
114
- if (isDateTime(date))
115
- return date.get(unit);
116
- return luxon_1.DateTime.fromJSDate(date).get(unit);
117
- }
118
- function format(date, extraArgs) {
119
- const [dateFormat, localeOpts = {}] = extraArgs;
120
- if (isDateTime(date)) {
121
- return date.toFormat(dateFormat, { ...localeOpts });
122
- }
123
- return luxon_1.DateTime.fromJSDate(date).toFormat(dateFormat, { ...localeOpts });
114
+ return luxon_1.DateTime.fromJSDate(date).toFormat(dateFormat, { ...localeOpts });
115
+ }
116
+ function isBetween(date, extraArgs) {
117
+ if (extraArgs.length !== 2) {
118
+ throw new expression_extension_error_1.ExpressionExtensionError('isBetween(): expected exactly two args');
124
119
  }
125
- function isBetween(date, extraArgs) {
126
- if (extraArgs.length !== 2) {
127
- throw new expression_extension_error_1.ExpressionExtensionError('isBetween(): expected exactly two args');
128
- }
129
- const [first, second] = extraArgs;
130
- const firstDate = (0, utils_1.convertToDateTime)(first);
131
- const secondDate = (0, utils_1.convertToDateTime)(second);
132
- if (!firstDate || !secondDate) {
133
- return;
134
- }
135
- if (firstDate > secondDate) {
136
- return secondDate < date && date < firstDate;
137
- }
138
- return secondDate > date && date > firstDate;
120
+ const [first, second] = extraArgs;
121
+ const firstDate = (0, utils_1.convertToDateTime)(first);
122
+ const secondDate = (0, utils_1.convertToDateTime)(second);
123
+ if (!firstDate || !secondDate) {
124
+ return;
139
125
  }
140
- function isDst(date) {
141
- if (isDateTime(date)) {
142
- return date.isInDST;
143
- }
144
- return luxon_1.DateTime.fromJSDate(date).isInDST;
126
+ if (firstDate > secondDate) {
127
+ return secondDate < date && date < firstDate;
145
128
  }
146
- function isInLast(date, extraArgs) {
147
- const [durationValue = 0, unit = 'minutes'] = extraArgs;
148
- const dateInThePast = luxon_1.DateTime.now().minus(generateDurationObject(durationValue, unit));
149
- let thisDate = date;
150
- if (!isDateTime(thisDate)) {
151
- thisDate = luxon_1.DateTime.fromJSDate(thisDate);
152
- }
153
- return dateInThePast <= thisDate && thisDate <= luxon_1.DateTime.now();
129
+ return secondDate > date && date > firstDate;
130
+ }
131
+ function isDst(date) {
132
+ if (isDateTime(date)) {
133
+ return date.isInDST;
154
134
  }
155
- const WEEKEND_DAYS = [6, 7];
156
- function isWeekend(date) {
157
- const { weekday } = isDateTime(date) ? date : luxon_1.DateTime.fromJSDate(date);
158
- return WEEKEND_DAYS.includes(weekday);
135
+ return luxon_1.DateTime.fromJSDate(date).isInDST;
136
+ }
137
+ function isInLast(date, extraArgs) {
138
+ const [durationValue = 0, unit = 'minutes'] = extraArgs;
139
+ const dateInThePast = luxon_1.DateTime.now().minus(generateDurationObject(durationValue, unit));
140
+ let thisDate = date;
141
+ if (!isDateTime(thisDate)) {
142
+ thisDate = luxon_1.DateTime.fromJSDate(thisDate);
159
143
  }
160
- function minus(date, args) {
161
- if (args.length === 1) {
162
- const [arg] = args;
163
- if (isDateTime(date))
164
- return date.minus(arg);
165
- return luxon_1.DateTime.fromJSDate(date).minus(arg).toJSDate();
166
- }
167
- const [durationValue = 0, unit = 'minutes'] = args;
168
- const duration = generateDurationObject(durationValue, unit);
144
+ return dateInThePast <= thisDate && thisDate <= luxon_1.DateTime.now();
145
+ }
146
+ const WEEKEND_DAYS = [6, 7];
147
+ function isWeekend(date) {
148
+ const { weekday } = isDateTime(date) ? date : luxon_1.DateTime.fromJSDate(date);
149
+ return WEEKEND_DAYS.includes(weekday);
150
+ }
151
+ function minus(date, args) {
152
+ if (args.length === 1) {
153
+ const [arg] = args;
169
154
  if (isDateTime(date))
170
- return date.minus(duration);
171
- return luxon_1.DateTime.fromJSDate(date).minus(duration).toJSDate();
155
+ return date.minus(arg);
156
+ return luxon_1.DateTime.fromJSDate(date).minus(arg).toJSDate();
172
157
  }
173
- function plus(date, args) {
174
- if (args.length === 1) {
175
- const [arg] = args;
176
- if (isDateTime(date))
177
- return date.plus(arg);
178
- return luxon_1.DateTime.fromJSDate(date).plus(arg).toJSDate();
179
- }
180
- const [durationValue = 0, unit = 'minutes'] = args;
181
- const duration = generateDurationObject(durationValue, unit);
158
+ const [durationValue = 0, unit = 'minutes'] = args;
159
+ const duration = generateDurationObject(durationValue, unit);
160
+ if (isDateTime(date))
161
+ return date.minus(duration);
162
+ return luxon_1.DateTime.fromJSDate(date).minus(duration).toJSDate();
163
+ }
164
+ function plus(date, args) {
165
+ if (args.length === 1) {
166
+ const [arg] = args;
182
167
  if (isDateTime(date))
183
- return date.plus(duration);
184
- return luxon_1.DateTime.fromJSDate(date).plus(duration).toJSDate();
168
+ return date.plus(arg);
169
+ return luxon_1.DateTime.fromJSDate(date).plus(arg).toJSDate();
185
170
  }
186
- function diffTo(date, args) {
187
- const [otherDate, unit = 'days'] = args;
188
- let units = Array.isArray(unit) ? unit : [unit];
189
- if (units.length === 0) {
190
- units = ['days'];
191
- }
192
- const allowedUnitSet = new Set([...dateParts, ...durationUnits]);
193
- const errorUnit = units.find((u) => !allowedUnitSet.has(u));
194
- if (errorUnit) {
195
- throw new expression_extension_error_1.ExpressionExtensionError(`Unsupported unit '${String(errorUnit)}'. Supported: ${durationUnits
196
- .map((u) => `'${u}'`)
197
- .join(', ')}.`);
198
- }
199
- const diffResult = date.diff(toDateTime(otherDate), units);
200
- if (units.length > 1) {
201
- return diffResult.toObject();
202
- }
203
- return diffResult.as(units[0]);
171
+ const [durationValue = 0, unit = 'minutes'] = args;
172
+ const duration = generateDurationObject(durationValue, unit);
173
+ if (isDateTime(date))
174
+ return date.plus(duration);
175
+ return luxon_1.DateTime.fromJSDate(date).plus(duration).toJSDate();
176
+ }
177
+ function diffTo(date, args) {
178
+ const [otherDate, unit = 'days'] = args;
179
+ let units = Array.isArray(unit) ? unit : [unit];
180
+ if (units.length === 0) {
181
+ units = ['days'];
204
182
  }
205
- function diffToNow(date, args) {
206
- const [unit] = args;
207
- return diffTo(date, [luxon_1.DateTime.now(), unit]);
183
+ const allowedUnitSet = new Set([...dateParts, ...durationUnits]);
184
+ const errorUnit = units.find((u) => !allowedUnitSet.has(u));
185
+ if (errorUnit) {
186
+ throw new expression_extension_error_1.ExpressionExtensionError(`Unsupported unit '${String(errorUnit)}'. Supported: ${durationUnits
187
+ .map((u) => `'${u}'`)
188
+ .join(', ')}.`);
208
189
  }
209
- function toInt(date) {
210
- if (isDateTime(date)) {
211
- return date.toMillis();
212
- }
213
- return date.getTime();
190
+ const diffResult = date.diff(toDateTime(otherDate), units);
191
+ if (units.length > 1) {
192
+ return diffResult.toObject();
214
193
  }
215
- const toFloat = toInt;
216
- function toBoolean() {
217
- return undefined;
194
+ return diffResult.as(units[0]);
195
+ }
196
+ function diffToNow(date, args) {
197
+ const [unit] = args;
198
+ return diffTo(date, [luxon_1.DateTime.now(), unit]);
199
+ }
200
+ function toInt(date) {
201
+ if (isDateTime(date)) {
202
+ return date.toMillis();
218
203
  }
219
- // Only null/undefined return true, this is handled in ExpressionExtension.ts
220
- function isEmpty() {
221
- return false;
222
- }
223
- function isNotEmpty() {
224
- return true;
225
- }
226
- endOfMonth.doc = {
227
- name: 'endOfMonth',
228
- returnType: 'DateTime',
229
- hidden: true,
230
- description: 'Transforms a date to the last possible moment that lies within the month.',
231
- section: 'edit',
232
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-endOfMonth',
233
- };
234
- isDst.doc = {
235
- name: 'isDst',
236
- returnType: 'boolean',
237
- hidden: true,
238
- description: 'Checks if a Date is within Daylight Savings Time.',
239
- section: 'query',
240
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isDst',
241
- };
242
- isWeekend.doc = {
243
- name: 'isWeekend',
244
- returnType: 'boolean',
245
- hidden: true,
246
- description: 'Checks if the Date falls on a Saturday or Sunday.',
247
- section: 'query',
248
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isWeekend',
249
- };
250
- beginningOf.doc = {
251
- name: 'beginningOf',
252
- description: 'Transform a Date to the start of the given time period. Default unit is `week`.',
253
- section: 'edit',
254
- hidden: true,
255
- returnType: 'DateTime',
256
- args: [{ name: 'unit?', type: 'DurationUnit' }],
257
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-beginningOf',
258
- };
259
- extract.doc = {
260
- name: 'extract',
261
- description: 'Extracts a part of the date or time, e.g. the month, as a number. To extract textual names instead, see <code>format()</code>.',
262
- examples: [
263
- { example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.extract('month')", evaluated: '3' },
264
- { example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.extract('hour')", evaluated: '18' },
265
- ],
266
- section: 'query',
267
- returnType: 'number',
268
- args: [
269
- {
270
- name: 'unit',
271
- optional: true,
272
- description: 'The part of the date or time to return. One of: <code>year</code>, <code>month</code>, <code>week</code>, <code>day</code>, <code>hour</code>, <code>minute</code>, <code>second</code>',
273
- default: '"week"',
274
- type: 'string',
275
- },
276
- ],
277
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-extract',
278
- };
279
- format.doc = {
280
- name: 'format',
281
- description: 'Converts the DateTime to a string, using the format specified. <a target="_blank" href="https://moment.github.io/luxon/#/formatting?id=table-of-tokens">Formatting guide</a>. For common formats, <code>toLocaleString()</code> may be easier.',
282
- examples: [
283
- {
284
- example: "dt = '2024-04-30T18:49'.toDateTime()\ndt.format('dd/LL/yyyy')",
285
- evaluated: "'30/04/2024'",
286
- },
287
- {
288
- example: "dt = '2024-04-30T18:49'.toDateTime()\ndt.format('dd LLL yy')",
289
- evaluated: "'30 Apr 24'",
290
- },
291
- {
292
- example: "dt = '2024-04-30T18:49'.toDateTime()\ndt.setLocale('fr').format('dd LLL yyyy')",
293
- evaluated: "'30 avr. 2024'",
294
- },
295
- {
296
- example: "dt = '2024-04-30T18:49'.toDateTime()\ndt.format(\"HH 'hours and' mm 'minutes'\")",
297
- evaluated: "'18 hours and 49 minutes'",
298
- },
299
- ],
300
- returnType: 'string',
301
- section: 'format',
302
- args: [
303
- {
304
- name: 'fmt',
305
- description: 'The <a target="_blank" href="https://moment.github.io/luxon/#/formatting?id=table-of-tokens">format</a> of the string to return ',
306
- default: "'yyyy-MM-dd'",
307
- type: 'string',
308
- },
309
- ],
310
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-format',
311
- };
312
- isBetween.doc = {
313
- name: 'isBetween',
314
- description: 'Returns <code>true</code> if the DateTime lies between the two moments specified',
315
- examples: [
316
- {
317
- example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.isBetween('2020-06-01', '2025-06-01')",
318
- evaluated: 'true',
319
- },
320
- {
321
- example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.isBetween('2020', '2025')",
322
- evaluated: 'true',
323
- },
324
- ],
325
- section: 'compare',
326
- returnType: 'boolean',
327
- args: [
328
- {
329
- name: 'date1',
330
- description: 'The moment that the base DateTime must be after. Can be an ISO date string or a Luxon DateTime.',
331
- type: 'string | DateTime',
332
- },
333
- {
334
- name: 'date2',
335
- description: 'The moment that the base DateTime must be before. Can be an ISO date string or a Luxon DateTime.',
336
- type: 'string | DateTime',
337
- },
338
- ],
339
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isBetween',
340
- };
341
- isInLast.doc = {
342
- name: 'isInLast',
343
- hidden: true,
344
- description: 'Checks if a Date is within a given time period. Default unit is `minute`.',
345
- section: 'query',
346
- returnType: 'boolean',
347
- args: [
348
- { name: 'n', type: 'number' },
349
- { name: 'unit?', type: 'DurationUnit' },
350
- ],
351
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isInLast',
352
- };
353
- toDateTime.doc = {
354
- name: 'toDateTime',
355
- description: 'Converts a JavaScript Date to a Luxon DateTime. The DateTime contains the same information, but is easier to manipulate.',
356
- examples: [
357
- {
358
- example: "jsDate = new Date('2024-03-30T18:49')\njsDate.toDateTime().plus(5, 'days')",
359
- evaluated: '[DateTime: 2024-05-05T18:49:00.000Z]',
360
- },
361
- ],
362
- returnType: 'DateTime',
363
- hidden: true,
364
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-toDateTime',
365
- };
366
- minus.doc = {
367
- name: 'minus',
368
- description: 'Subtracts a given period of time from the DateTime',
369
- examples: [
370
- {
371
- example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.minus(7, 'days')",
372
- evaluated: '[DateTime: 2024-04-23T18:49:00.000Z]',
373
- },
374
- {
375
- example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.minus(4, 'years')",
376
- evaluated: '[DateTime: 2020-04-30T18:49:00.000Z]',
377
- },
378
- ],
379
- section: 'edit',
380
- returnType: 'DateTime',
381
- args: [
382
- {
383
- name: 'n',
384
- description: 'The number of units to subtract. Or use a Luxon <a target="_blank" href="https://moment.github.io/luxon/api-docs/index.html#duration">Duration</a> object to subtract multiple units at once.',
385
- type: 'number | object',
386
- },
387
- {
388
- name: 'unit',
389
- optional: true,
390
- description: 'The units of the number. One of: <code>years</code>, <code>months</code>, <code>weeks</code>, <code>days</code>, <code>hours</code>, <code>minutes</code>, <code>seconds</code>, <code>milliseconds</code>',
391
- default: '"milliseconds"',
392
- type: 'string',
393
- },
394
- ],
395
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-minus',
396
- };
397
- plus.doc = {
398
- name: 'plus',
399
- description: 'Adds a given period of time to the DateTime',
400
- examples: [
401
- {
402
- example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.plus(7, 'days')",
403
- evaluated: '[DateTime: 2024-04-07T18:49:00.000Z]',
404
- },
405
- {
406
- example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.plus(4, 'years')",
407
- evaluated: '[DateTime: 2028-03-30T18:49:00.000Z]',
408
- },
409
- ],
410
- section: 'edit',
411
- returnType: 'DateTime',
412
- args: [
413
- {
414
- name: 'n',
415
- description: 'The number of units to add. Or use a Luxon <a target="_blank" href="https://moment.github.io/luxon/api-docs/index.html#duration">Duration</a> object to add multiple units at once.',
416
- type: 'number | object',
417
- },
418
- {
419
- name: 'unit',
420
- optional: true,
421
- description: 'The units of the number. One of: <code>years</code>, <code>months</code>, <code>weeks</code>, <code>days</code>, <code>hours</code>, <code>minutes</code>, <code>seconds</code>, <code>milliseconds</code>',
422
- default: '"milliseconds"',
423
- type: 'string',
424
- },
425
- ],
426
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-plus',
427
- };
428
- diffTo.doc = {
429
- name: 'diffTo',
430
- description: 'Returns the difference between two DateTimes, in the given unit(s)',
431
- examples: [
432
- {
433
- example: "dt = '2025-01-01'.toDateTime()\ndt.diffTo('2024-03-30T18:49:07.234', 'days')",
434
- evaluated: '276.21',
435
- },
436
- {
437
- example: "dt1 = '2025-01-01T00:00:00.000'.toDateTime();\ndt2 = '2024-03-30T18:49:07.234'.toDateTime();\ndt1.diffTo(dt2, ['months', 'days'])",
438
- evaluated: '{ months: 9, days: 1.21 }',
439
- },
440
- ],
441
- section: 'compare',
442
- returnType: 'number | Record<DurationUnit, number>',
443
- args: [
444
- {
445
- name: 'otherDateTime',
446
- default: '$now',
447
- description: 'The moment to subtract the base DateTime from. Can be an ISO date string or a Luxon DateTime.',
448
- type: 'string | DateTime',
449
- },
450
- {
451
- name: 'unit',
452
- default: "'days'",
453
- description: 'The unit, or array of units, to return the result in. Possible values: <code>years</code>, <code>months</code>, <code>weeks</code>, <code>days</code>, <code>hours</code>, <code>minutes</code>, <code>seconds</code>, <code>milliseconds</code>.',
454
- type: 'string | string[]',
455
- },
456
- ],
457
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-diffTo',
458
- };
459
- diffToNow.doc = {
460
- name: 'diffToNow',
461
- description: 'Returns the difference between the current moment and the DateTime, in the given unit(s). For a textual representation, use <code>toRelative()</code> instead.',
462
- examples: [
463
- {
464
- example: "dt = '2023-03-30T18:49:07.234'.toDateTime()\ndt.diffToNow('days')",
465
- evaluated: '371.9',
466
- },
467
- {
468
- example: "dt = '2023-03-30T18:49:07.234'.toDateTime()\ndt.diffToNow(['months', 'days'])",
469
- evaluated: '{ months: 12, days: 5.9 }',
470
- },
471
- ],
472
- section: 'compare',
473
- returnType: 'number | Record<DurationUnit, number>',
474
- args: [
475
- {
476
- name: 'unit',
477
- description: 'The unit, or array of units, to return the result in. Possible values: <code>years</code>, <code>months</code>, <code>weeks</code>, <code>days</code>, <code>hours</code>, <code>minutes</code>, <code>seconds</code>, <code>milliseconds</code>.',
478
- default: "'days'",
479
- type: 'string | string[]',
480
- },
481
- ],
482
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-diffToNow',
483
- };
484
- isEmpty.doc = {
485
- name: 'isEmpty',
486
- description: 'Returns <code>false</code> for all DateTimes. Returns <code>true</code> for <code>null</code>.',
487
- examples: [
488
- { example: "dt = '2023-03-30T18:49:07.234'.toDateTime()\ndt.isEmpty()", evaluated: 'false' },
489
- { example: 'dt = null\ndt.isEmpty()', evaluated: 'true' },
490
- ],
491
- returnType: 'boolean',
492
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-isEmpty',
493
- };
494
- isNotEmpty.doc = {
495
- name: 'isNotEmpty',
496
- description: 'Returns <code>true</code> for all DateTimes. Returns <code>false</code> for <code>null</code>.',
497
- examples: [
498
- { example: "dt = '2023-03-30T18:49:07.234'.toDateTime()\ndt.isNotEmpty()", evaluated: 'true' },
499
- { example: 'dt = null\ndt.isNotEmpty()', evaluated: 'false' },
500
- ],
501
- returnType: 'boolean',
502
- docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-isNotEmpty',
503
- };
504
- exports.dateExtensions = {
505
- typeName: 'Date',
506
- functions: {
507
- beginningOf,
508
- endOfMonth,
509
- extract,
510
- isBetween,
511
- isDst,
512
- isInLast,
513
- isWeekend,
514
- minus,
515
- plus,
516
- format,
517
- toDateTime,
518
- diffTo,
519
- diffToNow,
520
- toInt,
521
- toFloat,
522
- toBoolean,
523
- isEmpty,
524
- isNotEmpty,
204
+ return date.getTime();
205
+ }
206
+ const toFloat = toInt;
207
+ function toBoolean() {
208
+ return undefined;
209
+ }
210
+ // Only null/undefined return true, this is handled in ExpressionExtension.ts
211
+ function isEmpty() {
212
+ return false;
213
+ }
214
+ function isNotEmpty() {
215
+ return true;
216
+ }
217
+ endOfMonth.doc = {
218
+ name: 'endOfMonth',
219
+ returnType: 'DateTime',
220
+ hidden: true,
221
+ description: 'Transforms a date to the last possible moment that lies within the month.',
222
+ section: 'edit',
223
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-endOfMonth',
224
+ };
225
+ isDst.doc = {
226
+ name: 'isDst',
227
+ returnType: 'boolean',
228
+ hidden: true,
229
+ description: 'Checks if a Date is within Daylight Savings Time.',
230
+ section: 'query',
231
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isDst',
232
+ };
233
+ isWeekend.doc = {
234
+ name: 'isWeekend',
235
+ returnType: 'boolean',
236
+ hidden: true,
237
+ description: 'Checks if the Date falls on a Saturday or Sunday.',
238
+ section: 'query',
239
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isWeekend',
240
+ };
241
+ beginningOf.doc = {
242
+ name: 'beginningOf',
243
+ description: 'Transform a Date to the start of the given time period. Default unit is `week`.',
244
+ section: 'edit',
245
+ hidden: true,
246
+ returnType: 'DateTime',
247
+ args: [{ name: 'unit?', type: 'DurationUnit' }],
248
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-beginningOf',
249
+ };
250
+ extract.doc = {
251
+ name: 'extract',
252
+ description: 'Extracts a part of the date or time, e.g. the month, as a number. To extract textual names instead, see <code>format()</code>.',
253
+ examples: [
254
+ { example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.extract('month')", evaluated: '3' },
255
+ { example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.extract('hour')", evaluated: '18' },
256
+ ],
257
+ section: 'query',
258
+ returnType: 'number',
259
+ args: [
260
+ {
261
+ name: 'unit',
262
+ optional: true,
263
+ description: 'The part of the date or time to return. One of: <code>year</code>, <code>month</code>, <code>week</code>, <code>day</code>, <code>hour</code>, <code>minute</code>, <code>second</code>',
264
+ default: '"week"',
265
+ type: 'string',
266
+ },
267
+ ],
268
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-extract',
269
+ };
270
+ format.doc = {
271
+ name: 'format',
272
+ description: 'Converts the DateTime to a string, using the format specified. <a target="_blank" href="https://moment.github.io/luxon/#/formatting?id=table-of-tokens">Formatting guide</a>. For common formats, <code>toLocaleString()</code> may be easier.',
273
+ examples: [
274
+ {
275
+ example: "dt = '2024-04-30T18:49'.toDateTime()\ndt.format('dd/LL/yyyy')",
276
+ evaluated: "'30/04/2024'",
277
+ },
278
+ {
279
+ example: "dt = '2024-04-30T18:49'.toDateTime()\ndt.format('dd LLL yy')",
280
+ evaluated: "'30 Apr 24'",
281
+ },
282
+ {
283
+ example: "dt = '2024-04-30T18:49'.toDateTime()\ndt.setLocale('fr').format('dd LLL yyyy')",
284
+ evaluated: "'30 avr. 2024'",
285
+ },
286
+ {
287
+ example: "dt = '2024-04-30T18:49'.toDateTime()\ndt.format(\"HH 'hours and' mm 'minutes'\")",
288
+ evaluated: "'18 hours and 49 minutes'",
289
+ },
290
+ ],
291
+ returnType: 'string',
292
+ section: 'format',
293
+ args: [
294
+ {
295
+ name: 'fmt',
296
+ description: 'The <a target="_blank" href="https://moment.github.io/luxon/#/formatting?id=table-of-tokens">format</a> of the string to return ',
297
+ default: "'yyyy-MM-dd'",
298
+ type: 'string',
299
+ },
300
+ ],
301
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-format',
302
+ };
303
+ isBetween.doc = {
304
+ name: 'isBetween',
305
+ description: 'Returns <code>true</code> if the DateTime lies between the two moments specified',
306
+ examples: [
307
+ {
308
+ example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.isBetween('2020-06-01', '2025-06-01')",
309
+ evaluated: 'true',
310
+ },
311
+ {
312
+ example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.isBetween('2020', '2025')",
313
+ evaluated: 'true',
314
+ },
315
+ ],
316
+ section: 'compare',
317
+ returnType: 'boolean',
318
+ args: [
319
+ {
320
+ name: 'date1',
321
+ description: 'The moment that the base DateTime must be after. Can be an ISO date string or a Luxon DateTime.',
322
+ type: 'string | DateTime',
323
+ },
324
+ {
325
+ name: 'date2',
326
+ description: 'The moment that the base DateTime must be before. Can be an ISO date string or a Luxon DateTime.',
327
+ type: 'string | DateTime',
328
+ },
329
+ ],
330
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isBetween',
331
+ };
332
+ isInLast.doc = {
333
+ name: 'isInLast',
334
+ hidden: true,
335
+ description: 'Checks if a Date is within a given time period. Default unit is `minute`.',
336
+ section: 'query',
337
+ returnType: 'boolean',
338
+ args: [
339
+ { name: 'n', type: 'number' },
340
+ { name: 'unit?', type: 'DurationUnit' },
341
+ ],
342
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-isInLast',
343
+ };
344
+ toDateTime.doc = {
345
+ name: 'toDateTime',
346
+ description: 'Converts a JavaScript Date to a Luxon DateTime. The DateTime contains the same information, but is easier to manipulate.',
347
+ examples: [
348
+ {
349
+ example: "jsDate = new Date('2024-03-30T18:49')\njsDate.toDateTime().plus(5, 'days')",
350
+ evaluated: '[DateTime: 2024-05-05T18:49:00.000Z]',
351
+ },
352
+ ],
353
+ returnType: 'DateTime',
354
+ hidden: true,
355
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-toDateTime',
356
+ };
357
+ minus.doc = {
358
+ name: 'minus',
359
+ description: 'Subtracts a given period of time from the DateTime',
360
+ examples: [
361
+ {
362
+ example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.minus(7, 'days')",
363
+ evaluated: '[DateTime: 2024-04-23T18:49:00.000Z]',
364
+ },
365
+ {
366
+ example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.minus(4, 'years')",
367
+ evaluated: '[DateTime: 2020-04-30T18:49:00.000Z]',
368
+ },
369
+ ],
370
+ section: 'edit',
371
+ returnType: 'DateTime',
372
+ args: [
373
+ {
374
+ name: 'n',
375
+ description: 'The number of units to subtract. Or use a Luxon <a target="_blank" href="https://moment.github.io/luxon/api-docs/index.html#duration">Duration</a> object to subtract multiple units at once.',
376
+ type: 'number | object',
377
+ },
378
+ {
379
+ name: 'unit',
380
+ optional: true,
381
+ description: 'The units of the number. One of: <code>years</code>, <code>months</code>, <code>weeks</code>, <code>days</code>, <code>hours</code>, <code>minutes</code>, <code>seconds</code>, <code>milliseconds</code>',
382
+ default: '"milliseconds"',
383
+ type: 'string',
384
+ },
385
+ ],
386
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-minus',
387
+ };
388
+ plus.doc = {
389
+ name: 'plus',
390
+ description: 'Adds a given period of time to the DateTime',
391
+ examples: [
392
+ {
393
+ example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.plus(7, 'days')",
394
+ evaluated: '[DateTime: 2024-04-07T18:49:00.000Z]',
395
+ },
396
+ {
397
+ example: "dt = '2024-03-30T18:49'.toDateTime()\ndt.plus(4, 'years')",
398
+ evaluated: '[DateTime: 2028-03-30T18:49:00.000Z]',
399
+ },
400
+ ],
401
+ section: 'edit',
402
+ returnType: 'DateTime',
403
+ args: [
404
+ {
405
+ name: 'n',
406
+ description: 'The number of units to add. Or use a Luxon <a target="_blank" href="https://moment.github.io/luxon/api-docs/index.html#duration">Duration</a> object to add multiple units at once.',
407
+ type: 'number | object',
408
+ },
409
+ {
410
+ name: 'unit',
411
+ optional: true,
412
+ description: 'The units of the number. One of: <code>years</code>, <code>months</code>, <code>weeks</code>, <code>days</code>, <code>hours</code>, <code>minutes</code>, <code>seconds</code>, <code>milliseconds</code>',
413
+ default: '"milliseconds"',
414
+ type: 'string',
415
+ },
416
+ ],
417
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-plus',
418
+ };
419
+ diffTo.doc = {
420
+ name: 'diffTo',
421
+ description: 'Returns the difference between two DateTimes, in the given unit(s)',
422
+ examples: [
423
+ {
424
+ example: "dt = '2025-01-01'.toDateTime()\ndt.diffTo('2024-03-30T18:49:07.234', 'days')",
425
+ evaluated: '276.21',
426
+ },
427
+ {
428
+ example: "dt1 = '2025-01-01T00:00:00.000'.toDateTime();\ndt2 = '2024-03-30T18:49:07.234'.toDateTime();\ndt1.diffTo(dt2, ['months', 'days'])",
429
+ evaluated: '{ months: 9, days: 1.21 }',
430
+ },
431
+ ],
432
+ section: 'compare',
433
+ returnType: 'number | Record<DurationUnit, number>',
434
+ args: [
435
+ {
436
+ name: 'otherDateTime',
437
+ default: '$now',
438
+ description: 'The moment to subtract the base DateTime from. Can be an ISO date string or a Luxon DateTime.',
439
+ type: 'string | DateTime',
440
+ },
441
+ {
442
+ name: 'unit',
443
+ default: "'days'",
444
+ description: 'The unit, or array of units, to return the result in. Possible values: <code>years</code>, <code>months</code>, <code>weeks</code>, <code>days</code>, <code>hours</code>, <code>minutes</code>, <code>seconds</code>, <code>milliseconds</code>.',
445
+ type: 'string | string[]',
446
+ },
447
+ ],
448
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-diffTo',
449
+ };
450
+ diffToNow.doc = {
451
+ name: 'diffToNow',
452
+ description: 'Returns the difference between the current moment and the DateTime, in the given unit(s). For a textual representation, use <code>toRelative()</code> instead.',
453
+ examples: [
454
+ {
455
+ example: "dt = '2023-03-30T18:49:07.234'.toDateTime()\ndt.diffToNow('days')",
456
+ evaluated: '371.9',
457
+ },
458
+ {
459
+ example: "dt = '2023-03-30T18:49:07.234'.toDateTime()\ndt.diffToNow(['months', 'days'])",
460
+ evaluated: '{ months: 12, days: 5.9 }',
461
+ },
462
+ ],
463
+ section: 'compare',
464
+ returnType: 'number | Record<DurationUnit, number>',
465
+ args: [
466
+ {
467
+ name: 'unit',
468
+ description: 'The unit, or array of units, to return the result in. Possible values: <code>years</code>, <code>months</code>, <code>weeks</code>, <code>days</code>, <code>hours</code>, <code>minutes</code>, <code>seconds</code>, <code>milliseconds</code>.',
469
+ default: "'days'",
470
+ type: 'string | string[]',
525
471
  },
526
- };
527
- });
472
+ ],
473
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/dates/#date-diffToNow',
474
+ };
475
+ isEmpty.doc = {
476
+ name: 'isEmpty',
477
+ description: 'Returns <code>false</code> for all DateTimes. Returns <code>true</code> for <code>null</code>.',
478
+ examples: [
479
+ { example: "dt = '2023-03-30T18:49:07.234'.toDateTime()\ndt.isEmpty()", evaluated: 'false' },
480
+ { example: 'dt = null\ndt.isEmpty()', evaluated: 'true' },
481
+ ],
482
+ returnType: 'boolean',
483
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-isEmpty',
484
+ };
485
+ isNotEmpty.doc = {
486
+ name: 'isNotEmpty',
487
+ description: 'Returns <code>true</code> for all DateTimes. Returns <code>false</code> for <code>null</code>.',
488
+ examples: [
489
+ { example: "dt = '2023-03-30T18:49:07.234'.toDateTime()\ndt.isNotEmpty()", evaluated: 'true' },
490
+ { example: 'dt = null\ndt.isNotEmpty()', evaluated: 'false' },
491
+ ],
492
+ returnType: 'boolean',
493
+ docURL: 'https://docs.n8n.io/code/builtin/data-transformation-functions/arrays/#array-isNotEmpty',
494
+ };
495
+ exports.dateExtensions = {
496
+ typeName: 'Date',
497
+ functions: {
498
+ beginningOf,
499
+ endOfMonth,
500
+ extract,
501
+ isBetween,
502
+ isDst,
503
+ isInLast,
504
+ isWeekend,
505
+ minus,
506
+ plus,
507
+ format,
508
+ toDateTime,
509
+ diffTo,
510
+ diffToNow,
511
+ toInt,
512
+ toFloat,
513
+ toBoolean,
514
+ isEmpty,
515
+ isNotEmpty,
516
+ },
517
+ };
528
518
  //# sourceMappingURL=date-extensions.js.map