@teammy/server 0.2.20 → 0.2.22

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 (106) hide show
  1. package/dist/main.js +8784 -7601
  2. package/dist/web/assets/Assistant-Dm68Y4gs.js +1 -0
  3. package/dist/web/assets/Computers-BtcIsnDD.css +1 -0
  4. package/dist/web/assets/Computers-mf4P8Wjw.js +13 -0
  5. package/dist/web/assets/{Conversation-BjRCD81A.js → Conversation-ClLZZ3fG.js} +1 -1
  6. package/dist/web/assets/{Dashboard-DmtWx-WI.js → Dashboard-pokwbwJV.js} +1 -1
  7. package/dist/web/assets/{Dropdown-DXEtBxVr.js → Dropdown-DGFI68Vd.js} +1 -1
  8. package/dist/web/assets/Files-CtxaCO6n.js +1 -0
  9. package/dist/web/assets/{Help-BeJ09zt7.js → Help-B_1p7Xir.js} +87 -25
  10. package/dist/web/assets/Markdown-gPLWRWEJ.js +29 -0
  11. package/dist/web/assets/{MessageComposer-0eprbRl2.js → MessageComposer-BoOgfyPA.js} +1 -1
  12. package/dist/web/assets/ResourceLibrary-Cr_Emgq2.js +6 -0
  13. package/dist/web/assets/{TerminalPane-CEaXud0k.js → TerminalPane-5Gw9ZNxq.js} +2 -2
  14. package/dist/web/assets/WorkspaceTree-DZ6DN_OX.js +1 -0
  15. package/dist/web/assets/{file-links-Bo7XBz3i.js → file-links-CoVqmrXg.js} +1 -1
  16. package/dist/web/assets/index-BZEKT27U.js +10 -0
  17. package/dist/web/assets/task-links-DTqf18C2.js +1 -0
  18. package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
  19. package/dist/web/downloads/teammy-skill.zip +0 -0
  20. package/dist/web/index.html +2 -2
  21. package/dist/web/notification-worker.js +126 -0
  22. package/node_modules/cron-parser/LICENSE +21 -0
  23. package/node_modules/cron-parser/README.md +437 -0
  24. package/node_modules/cron-parser/dist/CronDate.js +558 -0
  25. package/node_modules/cron-parser/dist/CronExpression.js +531 -0
  26. package/node_modules/cron-parser/dist/CronExpressionParser.js +482 -0
  27. package/node_modules/cron-parser/dist/CronFieldCollection.js +380 -0
  28. package/node_modules/cron-parser/dist/CronFileParser.js +92 -0
  29. package/node_modules/cron-parser/dist/fields/CronDayOfMonth.js +60 -0
  30. package/node_modules/cron-parser/dist/fields/CronDayOfWeek.js +57 -0
  31. package/node_modules/cron-parser/dist/fields/CronField.js +222 -0
  32. package/node_modules/cron-parser/dist/fields/CronHour.js +40 -0
  33. package/node_modules/cron-parser/dist/fields/CronMinute.js +40 -0
  34. package/node_modules/cron-parser/dist/fields/CronMonth.js +44 -0
  35. package/node_modules/cron-parser/dist/fields/CronSecond.js +40 -0
  36. package/node_modules/cron-parser/dist/fields/index.js +24 -0
  37. package/node_modules/cron-parser/dist/fields/types.js +2 -0
  38. package/node_modules/cron-parser/dist/index.js +31 -0
  39. package/node_modules/cron-parser/dist/types/CronDate.d.ts +293 -0
  40. package/node_modules/cron-parser/dist/types/CronExpression.d.ts +118 -0
  41. package/node_modules/cron-parser/dist/types/CronExpressionParser.d.ts +65 -0
  42. package/node_modules/cron-parser/dist/types/CronFieldCollection.d.ts +153 -0
  43. package/node_modules/cron-parser/dist/types/CronFileParser.d.ts +30 -0
  44. package/node_modules/cron-parser/dist/types/fields/CronDayOfMonth.d.ts +33 -0
  45. package/node_modules/cron-parser/dist/types/fields/CronDayOfWeek.d.ts +31 -0
  46. package/node_modules/cron-parser/dist/types/fields/CronField.d.ts +136 -0
  47. package/node_modules/cron-parser/dist/types/fields/CronHour.d.ts +23 -0
  48. package/node_modules/cron-parser/dist/types/fields/CronMinute.d.ts +23 -0
  49. package/node_modules/cron-parser/dist/types/fields/CronMonth.d.ts +24 -0
  50. package/node_modules/cron-parser/dist/types/fields/CronSecond.d.ts +23 -0
  51. package/node_modules/cron-parser/dist/types/fields/index.d.ts +8 -0
  52. package/node_modules/cron-parser/dist/types/fields/types.d.ts +18 -0
  53. package/node_modules/cron-parser/dist/types/index.d.ts +8 -0
  54. package/node_modules/cron-parser/dist/types/utils/random.d.ts +10 -0
  55. package/node_modules/cron-parser/dist/utils/random.js +38 -0
  56. package/node_modules/cron-parser/package.json +117 -0
  57. package/node_modules/luxon/LICENSE.md +7 -0
  58. package/node_modules/luxon/README.md +55 -0
  59. package/node_modules/luxon/build/amd/luxon.js +8741 -0
  60. package/node_modules/luxon/build/amd/luxon.js.map +1 -0
  61. package/node_modules/luxon/build/cjs-browser/luxon.js +8739 -0
  62. package/node_modules/luxon/build/cjs-browser/luxon.js.map +1 -0
  63. package/node_modules/luxon/build/es6/luxon.mjs +8133 -0
  64. package/node_modules/luxon/build/es6/luxon.mjs.map +1 -0
  65. package/node_modules/luxon/build/global/luxon.js +8744 -0
  66. package/node_modules/luxon/build/global/luxon.js.map +1 -0
  67. package/node_modules/luxon/build/global/luxon.min.js +1 -0
  68. package/node_modules/luxon/build/global/luxon.min.js.map +1 -0
  69. package/node_modules/luxon/build/node/luxon.js +7792 -0
  70. package/node_modules/luxon/build/node/luxon.js.map +1 -0
  71. package/node_modules/luxon/package.json +87 -0
  72. package/node_modules/luxon/src/datetime.js +2603 -0
  73. package/node_modules/luxon/src/duration.js +1009 -0
  74. package/node_modules/luxon/src/errors.js +61 -0
  75. package/node_modules/luxon/src/impl/conversions.js +206 -0
  76. package/node_modules/luxon/src/impl/diff.js +95 -0
  77. package/node_modules/luxon/src/impl/digits.js +94 -0
  78. package/node_modules/luxon/src/impl/english.js +233 -0
  79. package/node_modules/luxon/src/impl/formats.js +176 -0
  80. package/node_modules/luxon/src/impl/formatter.js +434 -0
  81. package/node_modules/luxon/src/impl/invalid.js +14 -0
  82. package/node_modules/luxon/src/impl/locale.js +569 -0
  83. package/node_modules/luxon/src/impl/regexParser.js +335 -0
  84. package/node_modules/luxon/src/impl/tokenParser.js +505 -0
  85. package/node_modules/luxon/src/impl/util.js +330 -0
  86. package/node_modules/luxon/src/impl/zoneUtil.js +34 -0
  87. package/node_modules/luxon/src/info.js +205 -0
  88. package/node_modules/luxon/src/interval.js +669 -0
  89. package/node_modules/luxon/src/luxon.js +26 -0
  90. package/node_modules/luxon/src/package.json +4 -0
  91. package/node_modules/luxon/src/settings.js +180 -0
  92. package/node_modules/luxon/src/zone.js +97 -0
  93. package/node_modules/luxon/src/zones/IANAZone.js +235 -0
  94. package/node_modules/luxon/src/zones/fixedOffsetZone.js +150 -0
  95. package/node_modules/luxon/src/zones/invalidZone.js +53 -0
  96. package/node_modules/luxon/src/zones/systemZone.js +61 -0
  97. package/package.json +3 -1
  98. package/dist/web/assets/Assistant-By7rPMl2.js +0 -1
  99. package/dist/web/assets/Computers-B4ZMJ8tu.js +0 -13
  100. package/dist/web/assets/Computers-CBnQX-2p.css +0 -1
  101. package/dist/web/assets/Files-4IxSFpqk.js +0 -1
  102. package/dist/web/assets/Markdown-DGF8VSqv.js +0 -29
  103. package/dist/web/assets/ResourceLibrary-rlrdDWGo.js +0 -6
  104. package/dist/web/assets/WorkspaceTree-CwGvdfr0.js +0 -1
  105. package/dist/web/assets/index-Cr9kdjwc.js +0 -10
  106. package/dist/web/assets/task-links-B7fExlHK.js +0 -1
@@ -0,0 +1,531 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CronExpression = exports.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE = exports.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE = void 0;
4
+ const CronDate_1 = require("./CronDate");
5
+ /**
6
+ * Error message for when the current date is outside the specified time span.
7
+ */
8
+ exports.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE = 'Out of the time span range';
9
+ /**
10
+ * Error message for when the loop limit is exceeded during iteration.
11
+ */
12
+ exports.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE = 'Invalid expression, loop limit exceeded';
13
+ /**
14
+ * Cron iteration loop safety limit
15
+ */
16
+ const LOOP_LIMIT = 10000;
17
+ /**
18
+ * Class representing a Cron expression.
19
+ */
20
+ class CronExpression {
21
+ #options;
22
+ #tz;
23
+ #initialDate;
24
+ #currentDate;
25
+ #startDate;
26
+ #endDate;
27
+ #fields;
28
+ #dstTransitionDayKey = null;
29
+ #isDstTransitionDay = false;
30
+ /**
31
+ * Creates a new CronExpression instance.
32
+ *
33
+ * @param {CronFieldCollection} fields - Cron fields.
34
+ * @param {CronExpressionOptions} options - Parser options.
35
+ */
36
+ constructor(fields, options) {
37
+ this.#options = options;
38
+ this.#tz = options.tz;
39
+ this.#startDate = options.startDate != null ? new CronDate_1.CronDate(options.startDate, this.#tz) : null;
40
+ this.#endDate = options.endDate != null ? new CronDate_1.CronDate(options.endDate, this.#tz) : null;
41
+ let currentDateValue = options.currentDate ?? options.startDate;
42
+ if (currentDateValue != null) {
43
+ const tempCurrentDate = new CronDate_1.CronDate(currentDateValue, this.#tz);
44
+ if (this.#startDate && tempCurrentDate.getTime() < this.#startDate.getTime()) {
45
+ currentDateValue = this.#startDate;
46
+ }
47
+ else if (this.#endDate && tempCurrentDate.getTime() > this.#endDate.getTime()) {
48
+ currentDateValue = this.#endDate;
49
+ }
50
+ }
51
+ this.#initialDate = new CronDate_1.CronDate(currentDateValue, this.#tz);
52
+ this.#currentDate = this.#initialDate;
53
+ this.#fields = fields;
54
+ }
55
+ /**
56
+ * Getter for the cron fields.
57
+ *
58
+ * @returns {CronFieldCollection} Cron fields.
59
+ */
60
+ get fields() {
61
+ return this.#fields;
62
+ }
63
+ /**
64
+ * Converts cron fields back to a CronExpression instance.
65
+ *
66
+ * @public
67
+ * @param {Record<string, number[]>} fields - The input cron fields object.
68
+ * @param {CronExpressionOptions} [options] - Optional parsing options.
69
+ * @returns {CronExpression} - A new CronExpression instance.
70
+ */
71
+ static fieldsToExpression(fields, options) {
72
+ return new CronExpression(fields, options || {});
73
+ }
74
+ /**
75
+ * Checks if the given value matches any element in the sequence.
76
+ *
77
+ * @param {number} value - The value to be matched.
78
+ * @param {number[]} sequence - The sequence to be checked against.
79
+ * @returns {boolean} - True if the value matches an element in the sequence; otherwise, false.
80
+ * @memberof CronExpression
81
+ * @private
82
+ */
83
+ static #matchSchedule(value, sequence) {
84
+ return sequence.some((element) => element === value);
85
+ }
86
+ /**
87
+ * Returns the minimum or maximum value from the given array of numbers.
88
+ *
89
+ * @param {number[]} values - An array of numbers.
90
+ * @param {boolean} reverse - If true, returns the maximum value; otherwise, returns the minimum value.
91
+ * @returns {number} - The minimum or maximum value.
92
+ */
93
+ #getMinOrMax(values, reverse) {
94
+ return values[reverse ? values.length - 1 : 0];
95
+ }
96
+ /**
97
+ * Checks whether the given date falls on a DST transition day in its timezone.
98
+ *
99
+ * This is used to disable certain “direct set” fast paths on DST days, because setting the hour
100
+ * directly may land on a non-existent or repeated local time. We cache the result per calendar day
101
+ * to keep iteration overhead low.
102
+ *
103
+ * @param {CronDate} currentDate - Date to check (in the cron timezone)
104
+ * @returns {boolean} True when the day has a DST transition
105
+ * @private
106
+ */
107
+ #checkDstTransition(currentDate) {
108
+ // Cache per calendar day (in the cron date's timezone) to avoid repeated work inside the iteration loop.
109
+ const key = `${currentDate.getFullYear()}-${currentDate.getMonth() + 1}-${currentDate.getDate()}`;
110
+ if (this.#dstTransitionDayKey === key) {
111
+ return this.#isDstTransitionDay;
112
+ }
113
+ const startOfDay = new CronDate_1.CronDate(currentDate);
114
+ startOfDay.setStartOfDay();
115
+ const endOfDay = new CronDate_1.CronDate(currentDate);
116
+ endOfDay.setEndOfDay();
117
+ this.#dstTransitionDayKey = key;
118
+ this.#isDstTransitionDay = startOfDay.getUTCOffset() !== endOfDay.getUTCOffset();
119
+ return this.#isDstTransitionDay;
120
+ }
121
+ /**
122
+ * Moves the date to the next/previous allowed second value. If there is no remaining allowed second
123
+ * within the current minute, rolls to the next/previous minute and resets seconds to the min/max allowed.
124
+ *
125
+ * @param {CronDate} currentDate - Mutable date being iterated
126
+ * @param {DateMathOp} dateMathVerb - Add/Subtract depending on direction
127
+ * @param {boolean} reverse - When true, iterating backwards
128
+ * @private
129
+ */
130
+ #moveToNextSecond(currentDate, dateMathVerb, reverse) {
131
+ const seconds = this.#fields.second.values;
132
+ const currentSecond = currentDate.getSeconds();
133
+ const nextSecond = this.#fields.second.findNearestValue(currentSecond, reverse);
134
+ if (nextSecond !== null) {
135
+ currentDate.setSeconds(nextSecond);
136
+ return;
137
+ }
138
+ // Roll over to the next/previous minute and start from the min/max allowed second.
139
+ currentDate.applyDateOperation(dateMathVerb, CronDate_1.TimeUnit.Minute, this.#fields.hour.values.length);
140
+ currentDate.setSeconds(this.#getMinOrMax(seconds, reverse));
141
+ }
142
+ /**
143
+ * Moves the date to the next/previous allowed minute value and resets seconds to the min/max allowed.
144
+ * If there is no remaining allowed minute within the current hour, rolls to the next/previous hour and
145
+ * resets minutes/seconds to their extrema.
146
+ *
147
+ * @param {CronDate} currentDate - Mutable date being iterated
148
+ * @param {DateMathOp} dateMathVerb - Add/Subtract depending on direction
149
+ * @param {boolean} reverse - When true, iterating backwards
150
+ * @private
151
+ */
152
+ #moveToNextMinute(currentDate, dateMathVerb, reverse) {
153
+ const minutes = this.#fields.minute.values;
154
+ const seconds = this.#fields.second.values;
155
+ const currentMinute = currentDate.getMinutes();
156
+ const nextMinute = this.#fields.minute.findNearestValue(currentMinute, reverse);
157
+ if (nextMinute !== null) {
158
+ currentDate.setMinutes(nextMinute);
159
+ currentDate.setSeconds(this.#getMinOrMax(seconds, reverse));
160
+ return;
161
+ }
162
+ // Roll over to the next/previous hour and start from the min/max allowed minute/second.
163
+ currentDate.applyDateOperation(dateMathVerb, CronDate_1.TimeUnit.Hour, this.#fields.hour.values.length);
164
+ currentDate.setMinutes(this.#getMinOrMax(minutes, reverse));
165
+ currentDate.setSeconds(this.#getMinOrMax(seconds, reverse));
166
+ }
167
+ /**
168
+ * Determines if the current date matches the last specified weekday of the month.
169
+ *
170
+ * @param {Array<(number|string)>} expressions - An array of expressions containing weekdays and "L" for the last weekday.
171
+ * @param {CronDate} currentDate - The current date object.
172
+ * @returns {boolean} - True if the current date matches the last specified weekday of the month; otherwise, false.
173
+ * @memberof CronExpression
174
+ * @private
175
+ */
176
+ static #isLastWeekdayOfMonthMatch(expressions, currentDate) {
177
+ if (!currentDate.isLastWeekdayOfMonth()) {
178
+ return false;
179
+ }
180
+ const day = currentDate.getDay();
181
+ return expressions.some((expression) => day === parseInt(expression.toString().charAt(0), 10) % 7);
182
+ }
183
+ /**
184
+ * Determines if the current date matches the nth occurrence of a weekday in the month.
185
+ *
186
+ * @param {number} nthDay - The nth occurrence (1-5) from a `#` expression; values <= 0 mean no nth constraint.
187
+ * @param {CronDate} currentDate - The current date object.
188
+ * @returns {boolean} - True if there is no nth constraint, or the current date is the nth occurrence of its weekday; otherwise, false.
189
+ * @memberof CronExpression
190
+ * @private
191
+ */
192
+ static #isNthWeekdayOfMonthMatch(nthDay, currentDate) {
193
+ return nthDay <= 0 || Math.ceil(currentDate.getDate() / 7) === nthDay;
194
+ }
195
+ /**
196
+ * Find the next scheduled date based on the cron expression.
197
+ * @returns {CronDate} - The next scheduled date or an ES6 compatible iterator object.
198
+ * @memberof CronExpression
199
+ * @public
200
+ */
201
+ next() {
202
+ return this.#findSchedule();
203
+ }
204
+ /**
205
+ * Find the previous scheduled date based on the cron expression.
206
+ * @returns {CronDate} - The previous scheduled date or an ES6 compatible iterator object.
207
+ * @memberof CronExpression
208
+ * @public
209
+ */
210
+ prev() {
211
+ return this.#findSchedule(true);
212
+ }
213
+ /**
214
+ * Check if there is a next scheduled date based on the current date and cron expression.
215
+ * @returns {boolean} - Returns true if there is a next scheduled date, false otherwise.
216
+ * @memberof CronExpression
217
+ * @public
218
+ */
219
+ hasNext() {
220
+ const current = this.#currentDate;
221
+ try {
222
+ this.#findSchedule();
223
+ return true;
224
+ }
225
+ catch {
226
+ return false;
227
+ }
228
+ finally {
229
+ this.#currentDate = current;
230
+ }
231
+ }
232
+ /**
233
+ * Check if there is a previous scheduled date based on the current date and cron expression.
234
+ * @returns {boolean} - Returns true if there is a previous scheduled date, false otherwise.
235
+ * @memberof CronExpression
236
+ * @public
237
+ */
238
+ hasPrev() {
239
+ const current = this.#currentDate;
240
+ try {
241
+ this.#findSchedule(true);
242
+ return true;
243
+ }
244
+ catch {
245
+ return false;
246
+ }
247
+ finally {
248
+ this.#currentDate = current;
249
+ }
250
+ }
251
+ /**
252
+ * Iterate over a specified number of steps and optionally execute a callback function for each step.
253
+ * @param {number} steps - The number of steps to iterate. Positive value iterates forward, negative value iterates backward.
254
+ * @returns {CronDate[]} - An array of iterator fields or CronDate objects.
255
+ * @memberof CronExpression
256
+ * @public
257
+ */
258
+ take(limit) {
259
+ const items = [];
260
+ if (limit >= 0) {
261
+ for (let i = 0; i < limit; i++) {
262
+ try {
263
+ items.push(this.next());
264
+ }
265
+ catch {
266
+ return items;
267
+ }
268
+ }
269
+ }
270
+ else {
271
+ for (let i = 0; i > limit; i--) {
272
+ try {
273
+ items.push(this.prev());
274
+ }
275
+ catch {
276
+ return items;
277
+ }
278
+ }
279
+ }
280
+ return items;
281
+ }
282
+ /**
283
+ * Reset the iterator to a new date or its initial date after applying the configured range.
284
+ * @param {Date | CronDate} [newDate] - Optional new date to reset to. If not provided, it will reset to the initial date.
285
+ * @memberof CronExpression
286
+ * @public
287
+ */
288
+ reset(newDate) {
289
+ this.#currentDate = newDate ? new CronDate_1.CronDate(newDate, this.#tz) : this.#initialDate;
290
+ }
291
+ /**
292
+ * Generate a string representation of the cron expression.
293
+ * @param {boolean} [includeSeconds=false] - Whether to include the seconds field in the string representation.
294
+ * @returns {string} - The string representation of the cron expression.
295
+ * @memberof CronExpression
296
+ * @public
297
+ */
298
+ stringify(includeSeconds = false) {
299
+ return this.#fields.stringify(includeSeconds);
300
+ }
301
+ /**
302
+ * Check if the cron expression includes the given date
303
+ * @param {Date|CronDate} date
304
+ * @returns {boolean}
305
+ */
306
+ includesDate(date) {
307
+ const { second, minute, hour, month } = this.#fields;
308
+ const dt = new CronDate_1.CronDate(date, this.#tz);
309
+ // Check basic time fields first
310
+ if (!second.values.includes(dt.getSeconds()) ||
311
+ !minute.values.includes(dt.getMinutes()) ||
312
+ !hour.values.includes(dt.getHours()) ||
313
+ !month.values.includes((dt.getMonth() + 1))) {
314
+ return false;
315
+ }
316
+ // Check day of month and day of week using the same logic as #findSchedule
317
+ if (!this.#matchDayOfMonth(dt)) {
318
+ return false;
319
+ }
320
+ return true;
321
+ }
322
+ /**
323
+ * Returns the string representation of the cron expression.
324
+ * @returns {CronDate} - The next schedule date.
325
+ */
326
+ toString() {
327
+ /* istanbul ignore next - should be impossible under normal use to trigger the or branch */
328
+ return this.#options.expression || this.stringify(true);
329
+ }
330
+ /**
331
+ * Determines if the given date matches the cron expression's day of month and day of week fields.
332
+ *
333
+ * The function checks the following rules:
334
+ * Rule 1: If both "day of month" and "day of week" are restricted (not wildcard), then one or both must match the current day.
335
+ * Rule 2: If "day of month" is restricted and "day of week" is not restricted, then "day of month" must match the current day.
336
+ * Rule 3: If "day of month" is a wildcard, "day of week" is not a wildcard, and "day of week" matches the current day, then the match is accepted.
337
+ * In all rules, a "day of week" match also honors an nth-occurrence (`#`) constraint (e.g. `5#3` = the 3rd Friday) and the last-weekday (`L`) form.
338
+ * If none of the rules match, the match is rejected.
339
+ *
340
+ * @param {CronDate} currentDate - The current date to be evaluated against the cron expression.
341
+ * @returns {boolean} Returns true if the current date matches the cron expression's day of month and day of week fields, otherwise false.
342
+ * @memberof CronExpression
343
+ * @private
344
+ */
345
+ #matchDayOfMonth(currentDate) {
346
+ // Check if day of month and day of week fields are wildcards or restricted (not wildcard).
347
+ const isDayOfMonthWildcardMatch = this.#fields.dayOfMonth.isWildcard;
348
+ const isRestrictedDayOfMonth = !isDayOfMonthWildcardMatch;
349
+ const isDayOfWeekWildcardMatch = this.#fields.dayOfWeek.isWildcard;
350
+ const isRestrictedDayOfWeek = !isDayOfWeekWildcardMatch;
351
+ // Calculate if the current date matches the day of month and day of week fields.
352
+ const matchedDOM = CronExpression.#matchSchedule(currentDate.getDate(), this.#fields.dayOfMonth.values) ||
353
+ (this.#fields.dayOfMonth.hasLastChar && currentDate.isLastDayOfMonth());
354
+ const nthDay = this.#fields.dayOfWeek.nthDay;
355
+ const matchedDOW = (CronExpression.#matchSchedule(currentDate.getDay(), this.#fields.dayOfWeek.values) &&
356
+ CronExpression.#isNthWeekdayOfMonthMatch(nthDay, currentDate)) ||
357
+ (this.#fields.dayOfWeek.hasLastChar &&
358
+ CronExpression.#isLastWeekdayOfMonthMatch(this.#fields.dayOfWeek.values, currentDate));
359
+ // Rule 1: Both "day of month" and "day of week" are restricted; one or both must match the current day.
360
+ if (isRestrictedDayOfMonth && isRestrictedDayOfWeek && (matchedDOM || matchedDOW)) {
361
+ return true;
362
+ }
363
+ // Rule 2: "day of month" restricted and "day of week" not restricted; "day of month" must match the current day.
364
+ if (matchedDOM && !isRestrictedDayOfWeek) {
365
+ return true;
366
+ }
367
+ // Rule 3: "day of month" is a wildcard, "day of week" is not a wildcard, and "day of week" matches the current day.
368
+ if (isDayOfMonthWildcardMatch && !isDayOfWeekWildcardMatch && matchedDOW) {
369
+ return true;
370
+ }
371
+ // If none of the rules match, the match is rejected.
372
+ return false;
373
+ }
374
+ /**
375
+ * Determines if the current hour matches the cron expression.
376
+ *
377
+ * @param {CronDate} currentDate - The current date object.
378
+ * @param {DateMathOp} dateMathVerb - The date math operation enumeration value.
379
+ * @param {boolean} reverse - A flag indicating whether the matching should be done in reverse order.
380
+ * @returns {boolean} - True if the current hour matches the cron expression; otherwise, false.
381
+ */
382
+ #matchHour(currentDate, dateMathVerb, reverse) {
383
+ const hourValues = this.#fields.hour.values;
384
+ const hours = hourValues;
385
+ const currentHour = currentDate.getHours();
386
+ const isMatch = CronExpression.#matchSchedule(currentHour, hourValues);
387
+ const isDstEnd = currentDate.dstEnd === currentHour;
388
+ // DST start: accept the landing hour when a skipped hour was scheduled.
389
+ // The walk is modular because a gap can wrap midnight, and confined to the
390
+ // landing hour so it stops once the clock moves past the window.
391
+ if (currentDate.dstStart !== null && currentDate.dstStartLandingHour === currentHour) {
392
+ for (let skipped = currentDate.dstStart; skipped !== currentHour; skipped = (skipped + 1) % 24) {
393
+ if (CronExpression.#matchSchedule(skipped, hourValues)) {
394
+ return true;
395
+ }
396
+ }
397
+ }
398
+ // DST end: avoid returning the repeated hour twice when searching forward.
399
+ if (isDstEnd && !reverse) {
400
+ currentDate.dstEnd = null;
401
+ currentDate.applyDateOperation(CronDate_1.DateMathOp.Add, CronDate_1.TimeUnit.Hour, hours.length);
402
+ return false;
403
+ }
404
+ if (isMatch) {
405
+ return true;
406
+ }
407
+ // Normal mismatch: if there's no remaining matching hour in this day, jump a whole day first
408
+ // to avoid scanning hour-by-hour across the day boundary.
409
+ currentDate.clearDstStart();
410
+ const nextHour = this.#fields.hour.findNearestValue(currentHour, reverse);
411
+ if (nextHour === null) {
412
+ currentDate.applyDateOperation(dateMathVerb, CronDate_1.TimeUnit.Day, hours.length);
413
+ return false;
414
+ }
415
+ // Fast path: jump directly to the next/previous matching hour and reset lower units.
416
+ //
417
+ // On DST transition days, setting the hour directly can land on a non-existent/repeated local time,
418
+ // which breaks the existing DST handling that relies on `applyDateOperation()` to set `dstStart/dstEnd`.
419
+ // For those days, fall back to stepping hour-by-hour to preserve correctness.
420
+ if (this.#checkDstTransition(currentDate)) {
421
+ const steps = reverse ? currentHour - nextHour : nextHour - currentHour;
422
+ for (let i = 0; i < steps; i++) {
423
+ currentDate.applyDateOperation(dateMathVerb, CronDate_1.TimeUnit.Hour, hours.length);
424
+ // Overshoot protection: a spring-forward step can jump 2 wall-clock hours.
425
+ if (!reverse && currentDate.getHours() >= nextHour)
426
+ break;
427
+ if (reverse && currentDate.getHours() <= nextHour)
428
+ break;
429
+ }
430
+ }
431
+ else {
432
+ currentDate.setHours(nextHour);
433
+ }
434
+ currentDate.setMinutes(this.#getMinOrMax(this.#fields.minute.values, reverse));
435
+ currentDate.setSeconds(this.#getMinOrMax(this.#fields.second.values, reverse));
436
+ return false;
437
+ }
438
+ /**
439
+ * Validates the current date against the start and end dates of the cron expression.
440
+ * If the current date is outside the specified time span, an error is thrown.
441
+ *
442
+ * @param currentDate {CronDate} - The current date to validate.
443
+ * @throws {Error} If the current date is outside the specified time span.
444
+ * @private
445
+ */
446
+ #validateTimeSpan(currentDate) {
447
+ if (!this.#startDate && !this.#endDate) {
448
+ return;
449
+ }
450
+ const currentTime = currentDate.getTime();
451
+ if (this.#startDate && currentTime < this.#startDate.getTime()) {
452
+ throw new Error(exports.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE);
453
+ }
454
+ if (this.#endDate && currentTime > this.#endDate.getTime()) {
455
+ throw new Error(exports.TIME_SPAN_OUT_OF_BOUNDS_ERROR_MESSAGE);
456
+ }
457
+ }
458
+ /**
459
+ * Finds the next or previous schedule based on the cron expression.
460
+ *
461
+ * @param {boolean} [reverse=false] - If true, finds the previous schedule; otherwise, finds the next schedule.
462
+ * @returns {CronDate} - The next or previous schedule date.
463
+ * @private
464
+ */
465
+ #findSchedule(reverse = false) {
466
+ const dateMathVerb = reverse ? CronDate_1.DateMathOp.Subtract : CronDate_1.DateMathOp.Add;
467
+ const currentDate = new CronDate_1.CronDate(this.#currentDate);
468
+ const startTimestamp = currentDate.getTime();
469
+ if (currentDate.getMilliseconds() > 0) {
470
+ currentDate.setMilliseconds(0);
471
+ if (!reverse) {
472
+ currentDate.applyDateOperation(CronDate_1.DateMathOp.Add, CronDate_1.TimeUnit.Second, this.#fields.hour.values.length);
473
+ }
474
+ }
475
+ let stepCount = 0;
476
+ while (++stepCount < LOOP_LIMIT) {
477
+ this.#validateTimeSpan(currentDate);
478
+ if (!CronExpression.#matchSchedule(currentDate.getMonth() + 1, this.#fields.month.values)) {
479
+ currentDate.applyDateOperation(dateMathVerb, CronDate_1.TimeUnit.Month, this.#fields.hour.values.length);
480
+ continue;
481
+ }
482
+ if (!this.#matchDayOfMonth(currentDate)) {
483
+ currentDate.applyDateOperation(dateMathVerb, CronDate_1.TimeUnit.Day, this.#fields.hour.values.length);
484
+ continue;
485
+ }
486
+ if (!this.#matchHour(currentDate, dateMathVerb, reverse)) {
487
+ continue;
488
+ }
489
+ if (!CronExpression.#matchSchedule(currentDate.getMinutes(), this.#fields.minute.values)) {
490
+ this.#moveToNextMinute(currentDate, dateMathVerb, reverse);
491
+ continue;
492
+ }
493
+ if (!CronExpression.#matchSchedule(currentDate.getSeconds(), this.#fields.second.values)) {
494
+ this.#moveToNextSecond(currentDate, dateMathVerb, reverse);
495
+ continue;
496
+ }
497
+ if (startTimestamp === currentDate.getTime()) {
498
+ currentDate.applyDateOperation(dateMathVerb, CronDate_1.TimeUnit.Second, this.#fields.hour.values.length);
499
+ continue;
500
+ }
501
+ break;
502
+ }
503
+ if (stepCount >= LOOP_LIMIT) {
504
+ throw new Error(exports.LOOPS_LIMIT_EXCEEDED_ERROR_MESSAGE);
505
+ }
506
+ this.#currentDate = currentDate;
507
+ return currentDate;
508
+ }
509
+ /**
510
+ * Returns an iterator for iterating through future CronDate instances
511
+ *
512
+ * @name Symbol.iterator
513
+ * @memberof CronExpression
514
+ * @returns {Iterator<CronDate>} An iterator object for CronExpression that returns CronDate values.
515
+ */
516
+ [Symbol.iterator]() {
517
+ return {
518
+ next: () => {
519
+ try {
520
+ const schedule = this.#findSchedule();
521
+ return { value: schedule, done: false };
522
+ }
523
+ catch {
524
+ return { value: undefined, done: true };
525
+ }
526
+ },
527
+ };
528
+ }
529
+ }
530
+ exports.CronExpression = CronExpression;
531
+ exports.default = CronExpression;