@tachybase/module-cron 1.3.18 → 1.3.19

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 (47) hide show
  1. package/dist/client/cron-jobs-table/CronJobsTable.schema.d.ts +2 -3
  2. package/dist/client/index.js +3 -3
  3. package/dist/externalVersion.js +7 -7
  4. package/dist/node_modules/cron-parser/LICENSE +1 -1
  5. package/dist/node_modules/cron-parser/lib/date.js +252 -0
  6. package/dist/node_modules/cron-parser/lib/expression.js +1002 -0
  7. package/dist/node_modules/cron-parser/lib/field_compactor.js +70 -0
  8. package/dist/node_modules/cron-parser/lib/field_stringify.js +58 -0
  9. package/dist/node_modules/cron-parser/lib/parser.js +1 -0
  10. package/dist/node_modules/cron-parser/package.json +1 -1
  11. package/dist/node_modules/cron-parser/types/common.d.ts +131 -0
  12. package/dist/node_modules/cron-parser/types/index.d.ts +45 -0
  13. package/dist/node_modules/cron-parser/types/ts3/index.d.ts +28 -0
  14. package/dist/server/service/StaticScheduleTrigger.d.ts +1 -1
  15. package/package.json +10 -10
  16. package/dist/node_modules/cron-parser/dist/CronDate.js +0 -497
  17. package/dist/node_modules/cron-parser/dist/CronExpression.js +0 -376
  18. package/dist/node_modules/cron-parser/dist/CronExpressionParser.js +0 -384
  19. package/dist/node_modules/cron-parser/dist/CronFieldCollection.js +0 -371
  20. package/dist/node_modules/cron-parser/dist/CronFileParser.js +0 -109
  21. package/dist/node_modules/cron-parser/dist/fields/CronDayOfMonth.js +0 -44
  22. package/dist/node_modules/cron-parser/dist/fields/CronDayOfWeek.js +0 -51
  23. package/dist/node_modules/cron-parser/dist/fields/CronField.js +0 -183
  24. package/dist/node_modules/cron-parser/dist/fields/CronHour.js +0 -40
  25. package/dist/node_modules/cron-parser/dist/fields/CronMinute.js +0 -40
  26. package/dist/node_modules/cron-parser/dist/fields/CronMonth.js +0 -44
  27. package/dist/node_modules/cron-parser/dist/fields/CronSecond.js +0 -40
  28. package/dist/node_modules/cron-parser/dist/fields/index.js +0 -24
  29. package/dist/node_modules/cron-parser/dist/fields/types.js +0 -2
  30. package/dist/node_modules/cron-parser/dist/index.js +0 -1
  31. package/dist/node_modules/cron-parser/dist/types/CronDate.d.ts +0 -273
  32. package/dist/node_modules/cron-parser/dist/types/CronExpression.d.ts +0 -110
  33. package/dist/node_modules/cron-parser/dist/types/CronExpressionParser.d.ts +0 -70
  34. package/dist/node_modules/cron-parser/dist/types/CronFieldCollection.d.ts +0 -153
  35. package/dist/node_modules/cron-parser/dist/types/CronFileParser.d.ts +0 -30
  36. package/dist/node_modules/cron-parser/dist/types/fields/CronDayOfMonth.d.ts +0 -25
  37. package/dist/node_modules/cron-parser/dist/types/fields/CronDayOfWeek.d.ts +0 -30
  38. package/dist/node_modules/cron-parser/dist/types/fields/CronField.d.ts +0 -114
  39. package/dist/node_modules/cron-parser/dist/types/fields/CronHour.d.ts +0 -23
  40. package/dist/node_modules/cron-parser/dist/types/fields/CronMinute.d.ts +0 -23
  41. package/dist/node_modules/cron-parser/dist/types/fields/CronMonth.d.ts +0 -24
  42. package/dist/node_modules/cron-parser/dist/types/fields/CronSecond.d.ts +0 -23
  43. package/dist/node_modules/cron-parser/dist/types/fields/index.d.ts +0 -8
  44. package/dist/node_modules/cron-parser/dist/types/fields/types.d.ts +0 -18
  45. package/dist/node_modules/cron-parser/dist/types/index.d.ts +0 -8
  46. package/dist/node_modules/cron-parser/dist/types/utils/random.d.ts +0 -10
  47. package/dist/node_modules/cron-parser/dist/utils/random.js +0 -38
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-cron",
3
3
  "displayName": "Cron job",
4
- "version": "1.3.18",
4
+ "version": "1.3.19",
5
5
  "description": "Schedule tasks to run at specific times, using a workflow approach",
6
6
  "keywords": [
7
7
  "System management"
@@ -10,18 +10,18 @@
10
10
  "dependencies": {},
11
11
  "devDependencies": {
12
12
  "antd": "5.22.5",
13
- "cron-parser": "5.3.0",
13
+ "cron-parser": "4.9.0",
14
14
  "react-js-cron": "^3.2.0"
15
15
  },
16
16
  "peerDependencies": {
17
- "@tachybase/actions": "1.3.18",
18
- "@tachybase/client": "1.3.18",
19
- "@tachybase/database": "1.3.18",
20
- "@tachybase/module-workflow": "1.3.18",
21
- "@tachybase/schema": "1.3.18",
22
- "@tachybase/server": "1.3.18",
23
- "@tachybase/test": "1.3.18",
24
- "@tachybase/utils": "1.3.18"
17
+ "@tachybase/actions": "1.3.19",
18
+ "@tachybase/client": "1.3.19",
19
+ "@tachybase/database": "1.3.19",
20
+ "@tachybase/module-workflow": "1.3.19",
21
+ "@tachybase/server": "1.3.19",
22
+ "@tachybase/schema": "1.3.19",
23
+ "@tachybase/test": "1.3.19",
24
+ "@tachybase/utils": "1.3.19"
25
25
  },
26
26
  "description.zh-CN": "安排任务在特定时间运行,采用工作流的方式",
27
27
  "displayName.zh-CN": "定时任务",
@@ -1,497 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CronDate = exports.DAYS_IN_MONTH = exports.DateMathOp = exports.TimeUnit = void 0;
4
- const luxon_1 = require("luxon");
5
- var TimeUnit;
6
- (function (TimeUnit) {
7
- TimeUnit["Second"] = "Second";
8
- TimeUnit["Minute"] = "Minute";
9
- TimeUnit["Hour"] = "Hour";
10
- TimeUnit["Day"] = "Day";
11
- TimeUnit["Month"] = "Month";
12
- TimeUnit["Year"] = "Year";
13
- })(TimeUnit || (exports.TimeUnit = TimeUnit = {}));
14
- var DateMathOp;
15
- (function (DateMathOp) {
16
- DateMathOp["Add"] = "Add";
17
- DateMathOp["Subtract"] = "Subtract";
18
- })(DateMathOp || (exports.DateMathOp = DateMathOp = {}));
19
- exports.DAYS_IN_MONTH = Object.freeze([31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]);
20
- /**
21
- * CronDate class that wraps the Luxon DateTime object to provide
22
- * a consistent API for working with dates and times in the context of cron.
23
- */
24
- class CronDate {
25
- #date;
26
- #dstStart = null;
27
- #dstEnd = null;
28
- /**
29
- * Maps the verb to the appropriate method
30
- */
31
- #verbMap = {
32
- add: {
33
- [TimeUnit.Year]: this.addYear.bind(this),
34
- [TimeUnit.Month]: this.addMonth.bind(this),
35
- [TimeUnit.Day]: this.addDay.bind(this),
36
- [TimeUnit.Hour]: this.addHour.bind(this),
37
- [TimeUnit.Minute]: this.addMinute.bind(this),
38
- [TimeUnit.Second]: this.addSecond.bind(this),
39
- },
40
- subtract: {
41
- [TimeUnit.Year]: this.subtractYear.bind(this),
42
- [TimeUnit.Month]: this.subtractMonth.bind(this),
43
- [TimeUnit.Day]: this.subtractDay.bind(this),
44
- [TimeUnit.Hour]: this.subtractHour.bind(this),
45
- [TimeUnit.Minute]: this.subtractMinute.bind(this),
46
- [TimeUnit.Second]: this.subtractSecond.bind(this),
47
- },
48
- };
49
- /**
50
- * Constructs a new CronDate instance.
51
- * @param {CronDate | Date | number | string} [timestamp] - The timestamp to initialize the CronDate with.
52
- * @param {string} [tz] - The timezone to use for the CronDate.
53
- */
54
- constructor(timestamp, tz) {
55
- const dateOpts = { zone: tz };
56
- // Initialize the internal DateTime object based on the type of timestamp provided.
57
- if (!timestamp) {
58
- this.#date = luxon_1.DateTime.local();
59
- }
60
- else if (timestamp instanceof CronDate) {
61
- this.#date = timestamp.#date;
62
- this.#dstStart = timestamp.#dstStart;
63
- this.#dstEnd = timestamp.#dstEnd;
64
- }
65
- else if (timestamp instanceof Date) {
66
- this.#date = luxon_1.DateTime.fromJSDate(timestamp, dateOpts);
67
- }
68
- else if (typeof timestamp === 'number') {
69
- this.#date = luxon_1.DateTime.fromMillis(timestamp, dateOpts);
70
- }
71
- else {
72
- this.#date = luxon_1.DateTime.fromISO(timestamp, dateOpts);
73
- this.#date.isValid || (this.#date = luxon_1.DateTime.fromRFC2822(timestamp, dateOpts));
74
- this.#date.isValid || (this.#date = luxon_1.DateTime.fromSQL(timestamp, dateOpts));
75
- this.#date.isValid || (this.#date = luxon_1.DateTime.fromFormat(timestamp, 'EEE, d MMM yyyy HH:mm:ss', dateOpts));
76
- }
77
- // Check for valid DateTime and throw an error if not valid.
78
- if (!this.#date.isValid) {
79
- throw new Error(`CronDate: unhandled timestamp: ${timestamp}`);
80
- }
81
- // Set the timezone if it is provided and different from the current zone.
82
- if (tz && tz !== this.#date.zoneName) {
83
- this.#date = this.#date.setZone(tz);
84
- }
85
- }
86
- /**
87
- * Determines if the given year is a leap year.
88
- * @param {number} year - The year to check
89
- * @returns {boolean} - True if the year is a leap year, false otherwise
90
- * @private
91
- */
92
- static #isLeapYear(year) {
93
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
94
- }
95
- /**
96
- * Returns daylight savings start time.
97
- * @returns {number | null}
98
- */
99
- get dstStart() {
100
- return this.#dstStart;
101
- }
102
- /**
103
- * Sets daylight savings start time.
104
- * @param {number | null} value
105
- */
106
- set dstStart(value) {
107
- this.#dstStart = value;
108
- }
109
- /**
110
- * Returns daylight savings end time.
111
- * @returns {number | null}
112
- */
113
- get dstEnd() {
114
- return this.#dstEnd;
115
- }
116
- /**
117
- * Sets daylight savings end time.
118
- * @param {number | null} value
119
- */
120
- set dstEnd(value) {
121
- this.#dstEnd = value;
122
- }
123
- /**
124
- * Adds one year to the current CronDate.
125
- */
126
- addYear() {
127
- this.#date = this.#date.plus({ years: 1 });
128
- }
129
- /**
130
- * Adds one month to the current CronDate.
131
- */
132
- addMonth() {
133
- this.#date = this.#date.plus({ months: 1 }).startOf('month');
134
- }
135
- /**
136
- * Adds one day to the current CronDate.
137
- */
138
- addDay() {
139
- this.#date = this.#date.plus({ days: 1 }).startOf('day');
140
- }
141
- /**
142
- * Adds one hour to the current CronDate.
143
- */
144
- addHour() {
145
- this.#date = this.#date.plus({ hours: 1 }).startOf('hour');
146
- }
147
- /**
148
- * Adds one minute to the current CronDate.
149
- */
150
- addMinute() {
151
- this.#date = this.#date.plus({ minutes: 1 }).startOf('minute');
152
- }
153
- /**
154
- * Adds one second to the current CronDate.
155
- */
156
- addSecond() {
157
- this.#date = this.#date.plus({ seconds: 1 });
158
- }
159
- /**
160
- * Subtracts one year from the current CronDate.
161
- */
162
- subtractYear() {
163
- this.#date = this.#date.minus({ years: 1 });
164
- }
165
- /**
166
- * Subtracts one month from the current CronDate.
167
- * If the month is 1, it will subtract one year instead.
168
- */
169
- subtractMonth() {
170
- this.#date = this.#date.minus({ months: 1 }).endOf('month').startOf('second');
171
- }
172
- /**
173
- * Subtracts one day from the current CronDate.
174
- * If the day is 1, it will subtract one month instead.
175
- */
176
- subtractDay() {
177
- this.#date = this.#date.minus({ days: 1 }).endOf('day').startOf('second');
178
- }
179
- /**
180
- * Subtracts one hour from the current CronDate.
181
- * If the hour is 0, it will subtract one day instead.
182
- */
183
- subtractHour() {
184
- this.#date = this.#date.minus({ hours: 1 }).endOf('hour').startOf('second');
185
- }
186
- /**
187
- * Subtracts one minute from the current CronDate.
188
- * If the minute is 0, it will subtract one hour instead.
189
- */
190
- subtractMinute() {
191
- this.#date = this.#date.minus({ minutes: 1 }).endOf('minute').startOf('second');
192
- }
193
- /**
194
- * Subtracts one second from the current CronDate.
195
- * If the second is 0, it will subtract one minute instead.
196
- */
197
- subtractSecond() {
198
- this.#date = this.#date.minus({ seconds: 1 });
199
- }
200
- /**
201
- * Adds a unit of time to the current CronDate.
202
- * @param {TimeUnit} unit
203
- */
204
- addUnit(unit) {
205
- this.#verbMap.add[unit]();
206
- }
207
- /**
208
- * Subtracts a unit of time from the current CronDate.
209
- * @param {TimeUnit} unit
210
- */
211
- subtractUnit(unit) {
212
- this.#verbMap.subtract[unit]();
213
- }
214
- /**
215
- * Handles a math operation.
216
- * @param {DateMathOp} verb - {'add' | 'subtract'}
217
- * @param {TimeUnit} unit - {'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'}
218
- */
219
- invokeDateOperation(verb, unit) {
220
- if (verb === DateMathOp.Add) {
221
- this.addUnit(unit);
222
- return;
223
- }
224
- if (verb === DateMathOp.Subtract) {
225
- this.subtractUnit(unit);
226
- return;
227
- }
228
- /* istanbul ignore next - this would only happen if an end user call the handleMathOp with an invalid verb */
229
- throw new Error(`Invalid verb: ${verb}`);
230
- }
231
- /**
232
- * Returns the day.
233
- * @returns {number}
234
- */
235
- getDate() {
236
- return this.#date.day;
237
- }
238
- /**
239
- * Returns the year.
240
- * @returns {number}
241
- */
242
- getFullYear() {
243
- return this.#date.year;
244
- }
245
- /**
246
- * Returns the day of the week.
247
- * @returns {number}
248
- */
249
- getDay() {
250
- const weekday = this.#date.weekday;
251
- return weekday === 7 ? 0 : weekday;
252
- }
253
- /**
254
- * Returns the month.
255
- * @returns {number}
256
- */
257
- getMonth() {
258
- return this.#date.month - 1;
259
- }
260
- /**
261
- * Returns the hour.
262
- * @returns {number}
263
- */
264
- getHours() {
265
- return this.#date.hour;
266
- }
267
- /**
268
- * Returns the minutes.
269
- * @returns {number}
270
- */
271
- getMinutes() {
272
- return this.#date.minute;
273
- }
274
- /**
275
- * Returns the seconds.
276
- * @returns {number}
277
- */
278
- getSeconds() {
279
- return this.#date.second;
280
- }
281
- /**
282
- * Returns the milliseconds.
283
- * @returns {number}
284
- */
285
- getMilliseconds() {
286
- return this.#date.millisecond;
287
- }
288
- /**
289
- * Returns the time.
290
- * @returns {number}
291
- */
292
- getTime() {
293
- return this.#date.valueOf();
294
- }
295
- /**
296
- * Returns the UTC day.
297
- * @returns {number}
298
- */
299
- getUTCDate() {
300
- return this.#getUTC().day;
301
- }
302
- /**
303
- * Returns the UTC year.
304
- * @returns {number}
305
- */
306
- getUTCFullYear() {
307
- return this.#getUTC().year;
308
- }
309
- /**
310
- * Returns the UTC day of the week.
311
- * @returns {number}
312
- */
313
- getUTCDay() {
314
- const weekday = this.#getUTC().weekday;
315
- return weekday === 7 ? 0 : weekday;
316
- }
317
- /**
318
- * Returns the UTC month.
319
- * @returns {number}
320
- */
321
- getUTCMonth() {
322
- return this.#getUTC().month - 1;
323
- }
324
- /**
325
- * Returns the UTC hour.
326
- * @returns {number}
327
- */
328
- getUTCHours() {
329
- return this.#getUTC().hour;
330
- }
331
- /**
332
- * Returns the UTC minutes.
333
- * @returns {number}
334
- */
335
- getUTCMinutes() {
336
- return this.#getUTC().minute;
337
- }
338
- /**
339
- * Returns the UTC seconds.
340
- * @returns {number}
341
- */
342
- getUTCSeconds() {
343
- return this.#getUTC().second;
344
- }
345
- /**
346
- * Returns the UTC milliseconds.
347
- * @returns {string | null}
348
- */
349
- toISOString() {
350
- return this.#date.toUTC().toISO();
351
- }
352
- /**
353
- * Returns the date as a JSON string.
354
- * @returns {string | null}
355
- */
356
- toJSON() {
357
- return this.#date.toJSON();
358
- }
359
- /**
360
- * Sets the day.
361
- * @param d
362
- */
363
- setDate(d) {
364
- this.#date = this.#date.set({ day: d });
365
- }
366
- /**
367
- * Sets the year.
368
- * @param y
369
- */
370
- setFullYear(y) {
371
- this.#date = this.#date.set({ year: y });
372
- }
373
- /**
374
- * Sets the day of the week.
375
- * @param d
376
- */
377
- setDay(d) {
378
- this.#date = this.#date.set({ weekday: d });
379
- }
380
- /**
381
- * Sets the month.
382
- * @param m
383
- */
384
- setMonth(m) {
385
- this.#date = this.#date.set({ month: m + 1 });
386
- }
387
- /**
388
- * Sets the hour.
389
- * @param h
390
- */
391
- setHours(h) {
392
- this.#date = this.#date.set({ hour: h });
393
- }
394
- /**
395
- * Sets the minutes.
396
- * @param m
397
- */
398
- setMinutes(m) {
399
- this.#date = this.#date.set({ minute: m });
400
- }
401
- /**
402
- * Sets the seconds.
403
- * @param s
404
- */
405
- setSeconds(s) {
406
- this.#date = this.#date.set({ second: s });
407
- }
408
- /**
409
- * Sets the milliseconds.
410
- * @param s
411
- */
412
- setMilliseconds(s) {
413
- this.#date = this.#date.set({ millisecond: s });
414
- }
415
- /**
416
- * Returns the date as a string.
417
- * @returns {string}
418
- */
419
- toString() {
420
- return this.toDate().toString();
421
- }
422
- /**
423
- * Returns the date as a Date object.
424
- * @returns {Date}
425
- */
426
- toDate() {
427
- return this.#date.toJSDate();
428
- }
429
- /**
430
- * Returns true if the day is the last day of the month.
431
- * @returns {boolean}
432
- */
433
- isLastDayOfMonth() {
434
- const { day, month } = this.#date;
435
- // Special handling for February in leap years
436
- if (month === 2) {
437
- const isLeap = CronDate.#isLeapYear(this.#date.year);
438
- return day === exports.DAYS_IN_MONTH[month - 1] - (isLeap ? 0 : 1);
439
- }
440
- // For other months, check against the static map
441
- return day === exports.DAYS_IN_MONTH[month - 1];
442
- }
443
- /**
444
- * Returns true if the day is the last weekday of the month.
445
- * @returns {boolean}
446
- */
447
- isLastWeekdayOfMonth() {
448
- const { day, month } = this.#date;
449
- // Get the last day of the current month
450
- let lastDay;
451
- if (month === 2) {
452
- // Special handling for February
453
- lastDay = exports.DAYS_IN_MONTH[month - 1] - (CronDate.#isLeapYear(this.#date.year) ? 0 : 1);
454
- }
455
- else {
456
- lastDay = exports.DAYS_IN_MONTH[month - 1];
457
- }
458
- // Check if the current day is within 7 days of the end of the month
459
- return day > lastDay - 7;
460
- }
461
- /**
462
- * Primarily for internal use.
463
- * @param {DateMathOp} op - The operation to perform.
464
- * @param {TimeUnit} unit - The unit of time to use.
465
- * @param {number} [hoursLength] - The length of the hours. Required when unit is not month or day.
466
- */
467
- applyDateOperation(op, unit, hoursLength) {
468
- if (unit === TimeUnit.Month || unit === TimeUnit.Day) {
469
- this.invokeDateOperation(op, unit);
470
- return;
471
- }
472
- const previousHour = this.getHours();
473
- this.invokeDateOperation(op, unit);
474
- const currentHour = this.getHours();
475
- const diff = currentHour - previousHour;
476
- if (diff === 2) {
477
- if (hoursLength !== 24) {
478
- this.dstStart = currentHour;
479
- }
480
- }
481
- else if (diff === 0 && this.getMinutes() === 0 && this.getSeconds() === 0) {
482
- if (hoursLength !== 24) {
483
- this.dstEnd = currentHour;
484
- }
485
- }
486
- }
487
- /**
488
- * Returns the UTC date.
489
- * @private
490
- * @returns {DateTime}
491
- */
492
- #getUTC() {
493
- return this.#date.toUTC();
494
- }
495
- }
496
- exports.CronDate = CronDate;
497
- exports.default = CronDate;