@wabot-dev/framework 0.4.0-beta.2 → 0.4.0-beta.3

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 (44) hide show
  1. package/dist/src/_virtual/CronDate.js +3 -0
  2. package/dist/src/_virtual/CronDayOfMonth.js +3 -0
  3. package/dist/src/_virtual/CronDayOfWeek.js +3 -0
  4. package/dist/src/_virtual/CronExpression.js +3 -0
  5. package/dist/src/_virtual/CronExpressionParser.js +3 -0
  6. package/dist/src/_virtual/CronField.js +3 -0
  7. package/dist/src/_virtual/CronFieldCollection.js +3 -0
  8. package/dist/src/_virtual/CronFileParser.js +3 -0
  9. package/dist/src/_virtual/CronHour.js +3 -0
  10. package/dist/src/_virtual/CronMinute.js +3 -0
  11. package/dist/src/_virtual/CronMonth.js +3 -0
  12. package/dist/src/_virtual/CronSecond.js +3 -0
  13. package/dist/src/_virtual/index.js +5 -0
  14. package/dist/src/_virtual/index2.js +3 -0
  15. package/dist/src/_virtual/index3.js +3 -0
  16. package/dist/src/_virtual/luxon.js +3 -0
  17. package/dist/src/_virtual/random.js +3 -0
  18. package/dist/src/_virtual/types.js +3 -0
  19. package/dist/src/addon/async/pg/PgJobRepository.js +1 -0
  20. package/dist/src/feature/async/@cron.js +17 -0
  21. package/dist/src/feature/async/CronJob.js +67 -0
  22. package/dist/src/feature/async/CronJobRepository.js +19 -0
  23. package/dist/src/feature/async/CronScheduler.js +165 -0
  24. package/dist/src/feature/async/runCronHandlers.js +18 -0
  25. package/dist/src/index.d.ts +11 -1
  26. package/dist/src/index.js +2 -0
  27. package/dist/src/node_modules/cron-parser/dist/CronDate.js +510 -0
  28. package/dist/src/node_modules/cron-parser/dist/CronExpression.js +420 -0
  29. package/dist/src/node_modules/cron-parser/dist/CronExpressionParser.js +396 -0
  30. package/dist/src/node_modules/cron-parser/dist/CronFieldCollection.js +382 -0
  31. package/dist/src/node_modules/cron-parser/dist/CronFileParser.js +122 -0
  32. package/dist/src/node_modules/cron-parser/dist/fields/CronDayOfMonth.js +55 -0
  33. package/dist/src/node_modules/cron-parser/dist/fields/CronDayOfWeek.js +62 -0
  34. package/dist/src/node_modules/cron-parser/dist/fields/CronField.js +193 -0
  35. package/dist/src/node_modules/cron-parser/dist/fields/CronHour.js +51 -0
  36. package/dist/src/node_modules/cron-parser/dist/fields/CronMinute.js +51 -0
  37. package/dist/src/node_modules/cron-parser/dist/fields/CronMonth.js +56 -0
  38. package/dist/src/node_modules/cron-parser/dist/fields/CronSecond.js +51 -0
  39. package/dist/src/node_modules/cron-parser/dist/fields/index.js +44 -0
  40. package/dist/src/node_modules/cron-parser/dist/fields/types.js +12 -0
  41. package/dist/src/node_modules/cron-parser/dist/index.js +49 -0
  42. package/dist/src/node_modules/cron-parser/dist/utils/random.js +48 -0
  43. package/dist/src/node_modules/luxon/build/node/luxon.js +7802 -0
  44. package/package.json +1 -1
@@ -0,0 +1,382 @@
1
+ import { __exports as CronFieldCollection } from '../../../_virtual/CronFieldCollection.js';
2
+ import { __require as requireFields } from './fields/index.js';
3
+
4
+ var hasRequiredCronFieldCollection;
5
+
6
+ function requireCronFieldCollection () {
7
+ if (hasRequiredCronFieldCollection) return CronFieldCollection;
8
+ hasRequiredCronFieldCollection = 1;
9
+ Object.defineProperty(CronFieldCollection, "__esModule", { value: true });
10
+ CronFieldCollection.CronFieldCollection = void 0;
11
+ const fields_1 = requireFields();
12
+ /**
13
+ * Represents a complete set of cron fields.
14
+ * @class CronFieldCollection
15
+ */
16
+ let CronFieldCollection$1 = class CronFieldCollection {
17
+ #second;
18
+ #minute;
19
+ #hour;
20
+ #dayOfMonth;
21
+ #month;
22
+ #dayOfWeek;
23
+ /**
24
+ * Creates a new CronFieldCollection instance by partially overriding fields from an existing one.
25
+ * @param {CronFieldCollection} base - The base CronFieldCollection to copy fields from
26
+ * @param {CronFieldOverride} fields - The fields to override, can be CronField instances or raw values
27
+ * @returns {CronFieldCollection} A new CronFieldCollection instance
28
+ * @example
29
+ * const base = new CronFieldCollection({
30
+ * second: new CronSecond([0]),
31
+ * minute: new CronMinute([0]),
32
+ * hour: new CronHour([12]),
33
+ * dayOfMonth: new CronDayOfMonth([1]),
34
+ * month: new CronMonth([1]),
35
+ * dayOfWeek: new CronDayOfWeek([1])
36
+ * });
37
+ *
38
+ * // Using CronField instances
39
+ * const modified1 = CronFieldCollection.from(base, {
40
+ * hour: new CronHour([15]),
41
+ * minute: new CronMinute([30])
42
+ * });
43
+ *
44
+ * // Using raw values
45
+ * const modified2 = CronFieldCollection.from(base, {
46
+ * hour: [15], // Will create new CronHour
47
+ * minute: [30] // Will create new CronMinute
48
+ * });
49
+ */
50
+ static from(base, fields) {
51
+ return new CronFieldCollection({
52
+ second: this.resolveField(fields_1.CronSecond, base.second, fields.second),
53
+ minute: this.resolveField(fields_1.CronMinute, base.minute, fields.minute),
54
+ hour: this.resolveField(fields_1.CronHour, base.hour, fields.hour),
55
+ dayOfMonth: this.resolveField(fields_1.CronDayOfMonth, base.dayOfMonth, fields.dayOfMonth),
56
+ month: this.resolveField(fields_1.CronMonth, base.month, fields.month),
57
+ dayOfWeek: this.resolveField(fields_1.CronDayOfWeek, base.dayOfWeek, fields.dayOfWeek),
58
+ });
59
+ }
60
+ /**
61
+ * Resolves a field value, either using the provided CronField instance or creating a new one from raw values.
62
+ * @param constructor - The constructor for creating new field instances
63
+ * @param baseField - The base field to use if no override is provided
64
+ * @param fieldValue - The override value, either a CronField instance or raw values
65
+ * @returns The resolved CronField instance
66
+ * @private
67
+ */
68
+ static resolveField(constructor, baseField, fieldValue) {
69
+ if (!fieldValue) {
70
+ return baseField;
71
+ }
72
+ if (fieldValue instanceof fields_1.CronField) {
73
+ return fieldValue;
74
+ }
75
+ return new constructor(fieldValue);
76
+ }
77
+ /**
78
+ * CronFieldCollection constructor. Initializes the cron fields with the provided values.
79
+ * @param {CronFields} param0 - The cron fields values
80
+ * @throws {Error} if validation fails
81
+ * @example
82
+ * const cronFields = new CronFieldCollection({
83
+ * second: new CronSecond([0]),
84
+ * minute: new CronMinute([0, 30]),
85
+ * hour: new CronHour([9]),
86
+ * dayOfMonth: new CronDayOfMonth([15]),
87
+ * month: new CronMonth([1]),
88
+ * dayOfWeek: new CronDayOfTheWeek([1, 2, 3, 4, 5]),
89
+ * })
90
+ *
91
+ * console.log(cronFields.second.values); // [0]
92
+ * console.log(cronFields.minute.values); // [0, 30]
93
+ * console.log(cronFields.hour.values); // [9]
94
+ * console.log(cronFields.dayOfMonth.values); // [15]
95
+ * console.log(cronFields.month.values); // [1]
96
+ * console.log(cronFields.dayOfWeek.values); // [1, 2, 3, 4, 5]
97
+ */
98
+ constructor({ second, minute, hour, dayOfMonth, month, dayOfWeek }) {
99
+ if (!second) {
100
+ throw new Error('Validation error, Field second is missing');
101
+ }
102
+ if (!minute) {
103
+ throw new Error('Validation error, Field minute is missing');
104
+ }
105
+ if (!hour) {
106
+ throw new Error('Validation error, Field hour is missing');
107
+ }
108
+ if (!dayOfMonth) {
109
+ throw new Error('Validation error, Field dayOfMonth is missing');
110
+ }
111
+ if (!month) {
112
+ throw new Error('Validation error, Field month is missing');
113
+ }
114
+ if (!dayOfWeek) {
115
+ throw new Error('Validation error, Field dayOfWeek is missing');
116
+ }
117
+ if (month.values.length === 1 && !dayOfMonth.hasLastChar) {
118
+ if (!(parseInt(dayOfMonth.values[0], 10) <= fields_1.CronMonth.daysInMonth[month.values[0] - 1])) {
119
+ throw new Error('Invalid explicit day of month definition');
120
+ }
121
+ }
122
+ this.#second = second;
123
+ this.#minute = minute;
124
+ this.#hour = hour;
125
+ this.#month = month;
126
+ this.#dayOfWeek = dayOfWeek;
127
+ this.#dayOfMonth = dayOfMonth;
128
+ }
129
+ /**
130
+ * Returns the second field.
131
+ * @returns {CronSecond}
132
+ */
133
+ get second() {
134
+ return this.#second;
135
+ }
136
+ /**
137
+ * Returns the minute field.
138
+ * @returns {CronMinute}
139
+ */
140
+ get minute() {
141
+ return this.#minute;
142
+ }
143
+ /**
144
+ * Returns the hour field.
145
+ * @returns {CronHour}
146
+ */
147
+ get hour() {
148
+ return this.#hour;
149
+ }
150
+ /**
151
+ * Returns the day of the month field.
152
+ * @returns {CronDayOfMonth}
153
+ */
154
+ get dayOfMonth() {
155
+ return this.#dayOfMonth;
156
+ }
157
+ /**
158
+ * Returns the month field.
159
+ * @returns {CronMonth}
160
+ */
161
+ get month() {
162
+ return this.#month;
163
+ }
164
+ /**
165
+ * Returns the day of the week field.
166
+ * @returns {CronDayOfWeek}
167
+ */
168
+ get dayOfWeek() {
169
+ return this.#dayOfWeek;
170
+ }
171
+ /**
172
+ * Returns a string representation of the cron fields.
173
+ * @param {(number | CronChars)[]} input - The cron fields values
174
+ * @static
175
+ * @returns {FieldRange[]} - The compacted cron fields
176
+ */
177
+ static compactField(input) {
178
+ if (input.length === 0) {
179
+ return [];
180
+ }
181
+ // Initialize the output array and current IFieldRange
182
+ const output = [];
183
+ let current = undefined;
184
+ input.forEach((item, i, arr) => {
185
+ // If the current FieldRange is undefined, create a new one with the current item as the start.
186
+ if (current === undefined) {
187
+ current = { start: item, count: 1 };
188
+ return;
189
+ }
190
+ // Cache the previous and next items in the array.
191
+ const prevItem = arr[i - 1] || current.start;
192
+ const nextItem = arr[i + 1];
193
+ // If the current item is 'L' or 'W', push the current FieldRange to the output and
194
+ // create a new FieldRange with the current item as the start.
195
+ // 'L' and 'W' characters are special cases that need to be handled separately.
196
+ if (item === 'L' || item === 'W') {
197
+ output.push(current);
198
+ output.push({ start: item, count: 1 });
199
+ current = undefined;
200
+ return;
201
+ }
202
+ // If the current step is undefined and there is a next item, update the current IFieldRange.
203
+ // This block checks if the current step needs to be updated and does so if needed.
204
+ if (current.step === undefined && nextItem !== undefined) {
205
+ const step = item - prevItem;
206
+ const nextStep = nextItem - item;
207
+ // If the current step is less or equal to the next step, update the current FieldRange to include the current item.
208
+ if (step <= nextStep) {
209
+ current = { ...current, count: 2, end: item, step };
210
+ return;
211
+ }
212
+ current.step = 1;
213
+ }
214
+ // If the difference between the current item and the current end is equal to the current step,
215
+ // update the current IFieldRange's count and end.
216
+ // This block checks if the current item is part of the current range and updates the range accordingly.
217
+ if (item - (current.end ?? 0) === current.step) {
218
+ current.count++;
219
+ current.end = item;
220
+ }
221
+ else {
222
+ // If the count is 1, push a new FieldRange with the current start.
223
+ // This handles the case where the current range has only one element.
224
+ if (current.count === 1) {
225
+ // If the count is 2, push two separate IFieldRanges, one for each element.
226
+ output.push({ start: current.start, count: 1 });
227
+ }
228
+ else if (current.count === 2) {
229
+ output.push({ start: current.start, count: 1 });
230
+ // current.end can never be undefined here but typescript doesn't know that
231
+ // this is why we ?? it and then ignore the prevItem in the coverage
232
+ output.push({
233
+ start: current.end ?? /* istanbul ignore next - see above */ prevItem,
234
+ count: 1,
235
+ });
236
+ }
237
+ else {
238
+ // Otherwise, push the current FieldRange to the output.
239
+ output.push(current);
240
+ }
241
+ // Reset the current FieldRange with the current item as the start.
242
+ current = { start: item, count: 1 };
243
+ }
244
+ });
245
+ // Push the final IFieldRange, if any, to the output array.
246
+ if (current) {
247
+ output.push(current);
248
+ }
249
+ return output;
250
+ }
251
+ /**
252
+ * Handles a single range.
253
+ * @param {CronField} field - The cron field to stringify
254
+ * @param {FieldRange} range {start: number, end: number, step: number, count: number} The range to handle.
255
+ * @param {number} max The maximum value for the field.
256
+ * @returns {string | null} The stringified range or null if it cannot be stringified.
257
+ * @private
258
+ */
259
+ static #handleSingleRange(field, range, max) {
260
+ const step = range.step;
261
+ if (!step) {
262
+ return null;
263
+ }
264
+ if (step === 1 && range.start === field.min && range.end && range.end >= max) {
265
+ return field.hasQuestionMarkChar ? '?' : '*';
266
+ }
267
+ if (step !== 1 && range.start === field.min && range.end && range.end >= max - step + 1) {
268
+ return `*/${step}`;
269
+ }
270
+ return null;
271
+ }
272
+ /**
273
+ * Handles multiple ranges.
274
+ * @param {FieldRange} range {start: number, end: number, step: number, count: number} The range to handle.
275
+ * @param {number} max The maximum value for the field.
276
+ * @returns {string} The stringified range.
277
+ * @private
278
+ */
279
+ static #handleMultipleRanges(range, max) {
280
+ const step = range.step;
281
+ if (step === 1) {
282
+ return `${range.start}-${range.end}`;
283
+ }
284
+ const multiplier = range.start === 0 ? range.count - 1 : range.count;
285
+ /* istanbul ignore if */
286
+ if (!step) {
287
+ throw new Error('Unexpected range step');
288
+ }
289
+ /* istanbul ignore if */
290
+ if (!range.end) {
291
+ throw new Error('Unexpected range end');
292
+ }
293
+ if (step * multiplier > range.end) {
294
+ const mapFn = (_, index) => {
295
+ /* istanbul ignore if */
296
+ if (typeof range.start !== 'number') {
297
+ throw new Error('Unexpected range start');
298
+ }
299
+ return index % step === 0 ? range.start + index : null;
300
+ };
301
+ /* istanbul ignore if */
302
+ if (typeof range.start !== 'number') {
303
+ throw new Error('Unexpected range start');
304
+ }
305
+ const seed = { length: range.end - range.start + 1 };
306
+ return Array.from(seed, mapFn)
307
+ .filter((value) => value !== null)
308
+ .join(',');
309
+ }
310
+ return range.end === max - step + 1 ? `${range.start}/${step}` : `${range.start}-${range.end}/${step}`;
311
+ }
312
+ /**
313
+ * Returns a string representation of the cron fields.
314
+ * @param {CronField} field - The cron field to stringify
315
+ * @static
316
+ * @returns {string} - The stringified cron field
317
+ */
318
+ stringifyField(field) {
319
+ let max = field.max;
320
+ let values = field.values;
321
+ if (field instanceof fields_1.CronDayOfWeek) {
322
+ max = 6;
323
+ const dayOfWeek = this.#dayOfWeek.values;
324
+ values = dayOfWeek[dayOfWeek.length - 1] === 7 ? dayOfWeek.slice(0, -1) : dayOfWeek;
325
+ }
326
+ if (field instanceof fields_1.CronDayOfMonth) {
327
+ max = this.#month.values.length === 1 ? fields_1.CronMonth.daysInMonth[this.#month.values[0] - 1] : field.max;
328
+ }
329
+ const ranges = CronFieldCollection.compactField(values);
330
+ if (ranges.length === 1) {
331
+ const singleRangeResult = CronFieldCollection.#handleSingleRange(field, ranges[0], max);
332
+ if (singleRangeResult) {
333
+ return singleRangeResult;
334
+ }
335
+ }
336
+ return ranges
337
+ .map((range) => {
338
+ const value = range.count === 1 ? range.start.toString() : CronFieldCollection.#handleMultipleRanges(range, max);
339
+ if (field instanceof fields_1.CronDayOfWeek && field.nthDay > 0) {
340
+ return `${value}#${field.nthDay}`;
341
+ }
342
+ return value;
343
+ })
344
+ .join(',');
345
+ }
346
+ /**
347
+ * Returns a string representation of the cron field values.
348
+ * @param {boolean} includeSeconds - Whether to include seconds in the output
349
+ * @returns {string} The formatted cron string
350
+ */
351
+ stringify(includeSeconds = false) {
352
+ const arr = [];
353
+ if (includeSeconds) {
354
+ arr.push(this.stringifyField(this.#second)); // second
355
+ }
356
+ arr.push(this.stringifyField(this.#minute), // minute
357
+ this.stringifyField(this.#hour), // hour
358
+ this.stringifyField(this.#dayOfMonth), // dayOfMonth
359
+ this.stringifyField(this.#month), // month
360
+ this.stringifyField(this.#dayOfWeek));
361
+ return arr.join(' ');
362
+ }
363
+ /**
364
+ * Returns a serialized representation of the cron fields values.
365
+ * @returns {SerializedCronFields} An object containing the cron field values
366
+ */
367
+ serialize() {
368
+ return {
369
+ second: this.#second.serialize(),
370
+ minute: this.#minute.serialize(),
371
+ hour: this.#hour.serialize(),
372
+ dayOfMonth: this.#dayOfMonth.serialize(),
373
+ month: this.#month.serialize(),
374
+ dayOfWeek: this.#dayOfWeek.serialize(),
375
+ };
376
+ }
377
+ };
378
+ CronFieldCollection.CronFieldCollection = CronFieldCollection$1;
379
+ return CronFieldCollection;
380
+ }
381
+
382
+ export { requireCronFieldCollection as __require };
@@ -0,0 +1,122 @@
1
+ import { __exports as CronFileParser } from '../../../_virtual/CronFileParser.js';
2
+ import { __require as requireCronExpressionParser } from './CronExpressionParser.js';
3
+ import require$$1 from 'fs/promises';
4
+ import fs__default from 'fs';
5
+
6
+ var hasRequiredCronFileParser;
7
+
8
+ function requireCronFileParser () {
9
+ if (hasRequiredCronFileParser) return CronFileParser;
10
+ hasRequiredCronFileParser = 1;
11
+ var __createBinding = (CronFileParser && CronFileParser.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (CronFileParser && CronFileParser.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (CronFileParser && CronFileParser.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ Object.defineProperty(CronFileParser, "__esModule", { value: true });
45
+ CronFileParser.CronFileParser = void 0;
46
+ const CronExpressionParser_1 = requireCronExpressionParser();
47
+ /**
48
+ * Parser for crontab files that handles both synchronous and asynchronous operations.
49
+ */
50
+ let CronFileParser$1 = class CronFileParser {
51
+ /**
52
+ * Parse a crontab file asynchronously
53
+ * @param filePath Path to crontab file
54
+ * @returns Promise resolving to parse results
55
+ * @throws If file cannot be read
56
+ */
57
+ static async parseFile(filePath) {
58
+ const { readFile } = await Promise.resolve().then(() => __importStar(require$$1));
59
+ const data = await readFile(filePath, 'utf8');
60
+ return CronFileParser.#parseContent(data);
61
+ }
62
+ /**
63
+ * Parse a crontab file synchronously
64
+ * @param filePath Path to crontab file
65
+ * @returns Parse results
66
+ * @throws If file cannot be read
67
+ */
68
+ static parseFileSync(filePath) {
69
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
70
+ const { readFileSync } = fs__default;
71
+ const data = readFileSync(filePath, 'utf8');
72
+ return CronFileParser.#parseContent(data);
73
+ }
74
+ /**
75
+ * Internal method to parse crontab file content
76
+ * @private
77
+ */
78
+ static #parseContent(data) {
79
+ const blocks = data.split('\n');
80
+ const result = {
81
+ variables: {},
82
+ expressions: [],
83
+ errors: {},
84
+ };
85
+ for (const block of blocks) {
86
+ const entry = block.trim();
87
+ if (entry.length === 0 || entry.startsWith('#')) {
88
+ continue;
89
+ }
90
+ const variableMatch = entry.match(/^(.*)=(.*)$/);
91
+ if (variableMatch) {
92
+ const [, key, value] = variableMatch;
93
+ result.variables[key] = value.replace(/["']/g, ''); // Remove quotes
94
+ continue;
95
+ }
96
+ try {
97
+ const parsedEntry = CronFileParser.#parseEntry(entry);
98
+ result.expressions.push(parsedEntry.interval);
99
+ }
100
+ catch (err) {
101
+ result.errors[entry] = err;
102
+ }
103
+ }
104
+ return result;
105
+ }
106
+ /**
107
+ * Parse a single crontab entry
108
+ * @private
109
+ */
110
+ static #parseEntry(entry) {
111
+ const atoms = entry.split(' ');
112
+ return {
113
+ interval: CronExpressionParser_1.CronExpressionParser.parse(atoms.slice(0, 5).join(' ')),
114
+ command: atoms.slice(5, atoms.length),
115
+ };
116
+ }
117
+ };
118
+ CronFileParser.CronFileParser = CronFileParser$1;
119
+ return CronFileParser;
120
+ }
121
+
122
+ export { requireCronFileParser as __require };
@@ -0,0 +1,55 @@
1
+ import { __exports as CronDayOfMonth } from '../../../../_virtual/CronDayOfMonth.js';
2
+ import { __require as requireCronField } from './CronField.js';
3
+
4
+ var hasRequiredCronDayOfMonth;
5
+
6
+ function requireCronDayOfMonth () {
7
+ if (hasRequiredCronDayOfMonth) return CronDayOfMonth;
8
+ hasRequiredCronDayOfMonth = 1;
9
+ Object.defineProperty(CronDayOfMonth, "__esModule", { value: true });
10
+ CronDayOfMonth.CronDayOfMonth = void 0;
11
+ const CronField_1 = requireCronField();
12
+ const MIN_DAY = 1;
13
+ const MAX_DAY = 31;
14
+ const DAY_CHARS = Object.freeze(['L']);
15
+ /**
16
+ * Represents the "day of the month" field within a cron expression.
17
+ * @class CronDayOfMonth
18
+ * @extends CronField
19
+ */
20
+ let CronDayOfMonth$1 = class CronDayOfMonth extends CronField_1.CronField {
21
+ static get min() {
22
+ return MIN_DAY;
23
+ }
24
+ static get max() {
25
+ return MAX_DAY;
26
+ }
27
+ static get chars() {
28
+ return DAY_CHARS;
29
+ }
30
+ static get validChars() {
31
+ return /^[?,*\dLH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/;
32
+ }
33
+ /**
34
+ * CronDayOfMonth constructor. Initializes the "day of the month" field with the provided values.
35
+ * @param {DayOfMonthRange[]} values - Values for the "day of the month" field
36
+ * @param {CronFieldOptions} [options] - Options provided by the parser
37
+ * @throws {Error} if validation fails
38
+ */
39
+ constructor(values, options) {
40
+ super(values, options);
41
+ this.validate();
42
+ }
43
+ /**
44
+ * Returns an array of allowed values for the "day of the month" field.
45
+ * @returns {DayOfMonthRange[]}
46
+ */
47
+ get values() {
48
+ return super.values;
49
+ }
50
+ };
51
+ CronDayOfMonth.CronDayOfMonth = CronDayOfMonth$1;
52
+ return CronDayOfMonth;
53
+ }
54
+
55
+ export { requireCronDayOfMonth as __require };
@@ -0,0 +1,62 @@
1
+ import { __exports as CronDayOfWeek } from '../../../../_virtual/CronDayOfWeek.js';
2
+ import { __require as requireCronField } from './CronField.js';
3
+
4
+ var hasRequiredCronDayOfWeek;
5
+
6
+ function requireCronDayOfWeek () {
7
+ if (hasRequiredCronDayOfWeek) return CronDayOfWeek;
8
+ hasRequiredCronDayOfWeek = 1;
9
+ Object.defineProperty(CronDayOfWeek, "__esModule", { value: true });
10
+ CronDayOfWeek.CronDayOfWeek = void 0;
11
+ const CronField_1 = requireCronField();
12
+ const MIN_DAY = 0;
13
+ const MAX_DAY = 7;
14
+ const DAY_CHARS = Object.freeze(['L']);
15
+ /**
16
+ * Represents the "day of the week" field within a cron expression.
17
+ * @class CronDayOfTheWeek
18
+ * @extends CronField
19
+ */
20
+ let CronDayOfWeek$1 = class CronDayOfWeek extends CronField_1.CronField {
21
+ static get min() {
22
+ return MIN_DAY;
23
+ }
24
+ static get max() {
25
+ return MAX_DAY;
26
+ }
27
+ static get chars() {
28
+ return DAY_CHARS;
29
+ }
30
+ static get validChars() {
31
+ return /^[?,*\dLH#/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/;
32
+ }
33
+ /**
34
+ * CronDayOfTheWeek constructor. Initializes the "day of the week" field with the provided values.
35
+ * @param {DayOfWeekRange[]} values - Values for the "day of the week" field
36
+ * @param {CronFieldOptions} [options] - Options provided by the parser
37
+ */
38
+ constructor(values, options) {
39
+ super(values, options);
40
+ this.validate();
41
+ }
42
+ /**
43
+ * Returns an array of allowed values for the "day of the week" field.
44
+ * @returns {DayOfWeekRange[]}
45
+ */
46
+ get values() {
47
+ return super.values;
48
+ }
49
+ /**
50
+ * Returns the nth day of the week if specified in the cron expression.
51
+ * This is used for the '#' character in the cron expression.
52
+ * @returns {number} The nth day of the week (1-5) or 0 if not specified.
53
+ */
54
+ get nthDay() {
55
+ return this.options.nthDayOfWeek ?? 0;
56
+ }
57
+ };
58
+ CronDayOfWeek.CronDayOfWeek = CronDayOfWeek$1;
59
+ return CronDayOfWeek;
60
+ }
61
+
62
+ export { requireCronDayOfWeek as __require };