@teammy/server 0.2.19 → 0.2.21

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