@tachybase/module-cron 1.3.16 → 1.3.18
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.
- package/dist/client/cron-jobs-table/CronJobsTable.schema.d.ts +3 -2
- package/dist/client/index.js +3 -3
- package/dist/externalVersion.js +7 -7
- package/dist/index.js +4 -4
- package/dist/node_modules/cron-parser/LICENSE +1 -1
- package/dist/node_modules/cron-parser/dist/CronDate.js +497 -0
- package/dist/node_modules/cron-parser/dist/CronExpression.js +376 -0
- package/dist/node_modules/cron-parser/dist/CronExpressionParser.js +384 -0
- package/dist/node_modules/cron-parser/dist/CronFieldCollection.js +371 -0
- package/dist/node_modules/cron-parser/dist/CronFileParser.js +109 -0
- package/dist/node_modules/cron-parser/dist/fields/CronDayOfMonth.js +44 -0
- package/dist/node_modules/cron-parser/dist/fields/CronDayOfWeek.js +51 -0
- package/dist/node_modules/cron-parser/dist/fields/CronField.js +183 -0
- package/dist/node_modules/cron-parser/dist/fields/CronHour.js +40 -0
- package/dist/node_modules/cron-parser/dist/fields/CronMinute.js +40 -0
- package/dist/node_modules/cron-parser/dist/fields/CronMonth.js +44 -0
- package/dist/node_modules/cron-parser/dist/fields/CronSecond.js +40 -0
- package/dist/node_modules/cron-parser/dist/fields/index.js +24 -0
- package/dist/node_modules/cron-parser/dist/fields/types.js +2 -0
- package/dist/node_modules/cron-parser/dist/index.js +1 -0
- package/dist/node_modules/cron-parser/dist/types/CronDate.d.ts +273 -0
- package/dist/node_modules/cron-parser/dist/types/CronExpression.d.ts +110 -0
- package/dist/node_modules/cron-parser/dist/types/CronExpressionParser.d.ts +70 -0
- package/dist/node_modules/cron-parser/dist/types/CronFieldCollection.d.ts +153 -0
- package/dist/node_modules/cron-parser/dist/types/CronFileParser.d.ts +30 -0
- package/dist/node_modules/cron-parser/dist/types/fields/CronDayOfMonth.d.ts +25 -0
- package/dist/node_modules/cron-parser/dist/types/fields/CronDayOfWeek.d.ts +30 -0
- package/dist/node_modules/cron-parser/dist/types/fields/CronField.d.ts +114 -0
- package/dist/node_modules/cron-parser/dist/types/fields/CronHour.d.ts +23 -0
- package/dist/node_modules/cron-parser/dist/types/fields/CronMinute.d.ts +23 -0
- package/dist/node_modules/cron-parser/dist/types/fields/CronMonth.d.ts +24 -0
- package/dist/node_modules/cron-parser/dist/types/fields/CronSecond.d.ts +23 -0
- package/dist/node_modules/cron-parser/dist/types/fields/index.d.ts +8 -0
- package/dist/node_modules/cron-parser/dist/types/fields/types.d.ts +18 -0
- package/dist/node_modules/cron-parser/dist/types/index.d.ts +8 -0
- package/dist/node_modules/cron-parser/dist/types/utils/random.d.ts +10 -0
- package/dist/node_modules/cron-parser/dist/utils/random.js +38 -0
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/server/service/StaticScheduleTrigger.d.ts +1 -1
- package/package.json +10 -10
- package/dist/node_modules/cron-parser/lib/date.js +0 -252
- package/dist/node_modules/cron-parser/lib/expression.js +0 -1002
- package/dist/node_modules/cron-parser/lib/field_compactor.js +0 -70
- package/dist/node_modules/cron-parser/lib/field_stringify.js +0 -58
- package/dist/node_modules/cron-parser/lib/parser.js +0 -1
- package/dist/node_modules/cron-parser/types/common.d.ts +0 -131
- package/dist/node_modules/cron-parser/types/index.d.ts +0 -45
- package/dist/node_modules/cron-parser/types/ts3/index.d.ts +0 -28
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CronField = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a field within a cron expression.
|
|
6
|
+
* This is a base class and should not be instantiated directly.
|
|
7
|
+
* @class CronField
|
|
8
|
+
*/
|
|
9
|
+
class CronField {
|
|
10
|
+
#hasLastChar = false;
|
|
11
|
+
#hasQuestionMarkChar = false;
|
|
12
|
+
#wildcard = false;
|
|
13
|
+
#values = [];
|
|
14
|
+
options = { rawValue: '' };
|
|
15
|
+
/**
|
|
16
|
+
* Returns the minimum value allowed for this field.
|
|
17
|
+
*/
|
|
18
|
+
/* istanbul ignore next */ static get min() {
|
|
19
|
+
/* istanbul ignore next */
|
|
20
|
+
throw new Error('min must be overridden');
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the maximum value allowed for this field.
|
|
24
|
+
*/
|
|
25
|
+
/* istanbul ignore next */ static get max() {
|
|
26
|
+
/* istanbul ignore next */
|
|
27
|
+
throw new Error('max must be overridden');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the allowed characters for this field.
|
|
31
|
+
*/
|
|
32
|
+
/* istanbul ignore next */ static get chars() {
|
|
33
|
+
/* istanbul ignore next - this is overridden */
|
|
34
|
+
return Object.freeze([]);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the regular expression used to validate this field.
|
|
38
|
+
*/
|
|
39
|
+
static get validChars() {
|
|
40
|
+
return /^[?,*\dH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the constraints for this field.
|
|
44
|
+
*/
|
|
45
|
+
static get constraints() {
|
|
46
|
+
return { min: this.min, max: this.max, chars: this.chars, validChars: this.validChars };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* CronField constructor. Initializes the field with the provided values.
|
|
50
|
+
* @param {number[] | string[]} values - Values for this field
|
|
51
|
+
* @param {CronFieldOptions} [options] - Options provided by the parser
|
|
52
|
+
* @throws {TypeError} if the constructor is called directly
|
|
53
|
+
* @throws {Error} if validation fails
|
|
54
|
+
*/
|
|
55
|
+
constructor(values, options = { rawValue: '' }) {
|
|
56
|
+
if (!Array.isArray(values)) {
|
|
57
|
+
throw new Error(`${this.constructor.name} Validation error, values is not an array`);
|
|
58
|
+
}
|
|
59
|
+
if (!(values.length > 0)) {
|
|
60
|
+
throw new Error(`${this.constructor.name} Validation error, values contains no values`);
|
|
61
|
+
}
|
|
62
|
+
/* istanbul ignore next */
|
|
63
|
+
this.options = {
|
|
64
|
+
...options,
|
|
65
|
+
rawValue: options.rawValue ?? '',
|
|
66
|
+
};
|
|
67
|
+
this.#values = values.sort(CronField.sorter);
|
|
68
|
+
this.#wildcard = this.options.wildcard !== undefined ? this.options.wildcard : this.#isWildcardValue();
|
|
69
|
+
this.#hasLastChar = this.options.rawValue.includes('L');
|
|
70
|
+
this.#hasQuestionMarkChar = this.options.rawValue.includes('?');
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns the minimum value allowed for this field.
|
|
74
|
+
* @returns {number}
|
|
75
|
+
*/
|
|
76
|
+
get min() {
|
|
77
|
+
// return the static value from the child class
|
|
78
|
+
return this.constructor.min;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns the maximum value allowed for this field.
|
|
82
|
+
* @returns {number}
|
|
83
|
+
*/
|
|
84
|
+
get max() {
|
|
85
|
+
// return the static value from the child class
|
|
86
|
+
return this.constructor.max;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns an array of allowed special characters for this field.
|
|
90
|
+
* @returns {string[]}
|
|
91
|
+
*/
|
|
92
|
+
get chars() {
|
|
93
|
+
// return the frozen static value from the child class
|
|
94
|
+
return this.constructor.chars;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Indicates whether this field has a "last" character.
|
|
98
|
+
* @returns {boolean}
|
|
99
|
+
*/
|
|
100
|
+
get hasLastChar() {
|
|
101
|
+
return this.#hasLastChar;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Indicates whether this field has a "question mark" character.
|
|
105
|
+
* @returns {boolean}
|
|
106
|
+
*/
|
|
107
|
+
get hasQuestionMarkChar() {
|
|
108
|
+
return this.#hasQuestionMarkChar;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Indicates whether this field is a wildcard.
|
|
112
|
+
* @returns {boolean}
|
|
113
|
+
*/
|
|
114
|
+
get isWildcard() {
|
|
115
|
+
return this.#wildcard;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns an array of allowed values for this field.
|
|
119
|
+
* @returns {CronFieldType}
|
|
120
|
+
*/
|
|
121
|
+
get values() {
|
|
122
|
+
return this.#values;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Helper function to sort values in ascending order.
|
|
126
|
+
* @param {number | string} a - First value to compare
|
|
127
|
+
* @param {number | string} b - Second value to compare
|
|
128
|
+
* @returns {number} - A negative, zero, or positive value, depending on the sort order
|
|
129
|
+
*/
|
|
130
|
+
static sorter(a, b) {
|
|
131
|
+
const aIsNumber = typeof a === 'number';
|
|
132
|
+
const bIsNumber = typeof b === 'number';
|
|
133
|
+
if (aIsNumber && bIsNumber)
|
|
134
|
+
return a - b;
|
|
135
|
+
if (!aIsNumber && !bIsNumber)
|
|
136
|
+
return a.localeCompare(b);
|
|
137
|
+
return aIsNumber ? /* istanbul ignore next - A will always be a number until L-2 is supported */ -1 : 1;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Serializes the field to an object.
|
|
141
|
+
* @returns {SerializedCronField}
|
|
142
|
+
*/
|
|
143
|
+
serialize() {
|
|
144
|
+
return {
|
|
145
|
+
wildcard: this.#wildcard,
|
|
146
|
+
values: this.#values,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Validates the field values against the allowed range and special characters.
|
|
151
|
+
* @throws {Error} if validation fails
|
|
152
|
+
*/
|
|
153
|
+
validate() {
|
|
154
|
+
let badValue;
|
|
155
|
+
const charsString = this.chars.length > 0 ? ` or chars ${this.chars.join('')}` : '';
|
|
156
|
+
const charTest = (value) => (char) => new RegExp(`^\\d{0,2}${char}$`).test(value);
|
|
157
|
+
const rangeTest = (value) => {
|
|
158
|
+
badValue = value;
|
|
159
|
+
return typeof value === 'number' ? value >= this.min && value <= this.max : this.chars.some(charTest(value));
|
|
160
|
+
};
|
|
161
|
+
const isValidRange = this.#values.every(rangeTest);
|
|
162
|
+
if (!isValidRange) {
|
|
163
|
+
throw new Error(`${this.constructor.name} Validation error, got value ${badValue} expected range ${this.min}-${this.max}${charsString}`);
|
|
164
|
+
}
|
|
165
|
+
// check for duplicate value in this.#values array
|
|
166
|
+
const duplicate = this.#values.find((value, index) => this.#values.indexOf(value) !== index);
|
|
167
|
+
if (duplicate) {
|
|
168
|
+
throw new Error(`${this.constructor.name} Validation error, duplicate values found: ${duplicate}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Determines if the field is a wildcard based on the values.
|
|
173
|
+
* When options.rawValue is not empty, it checks if the raw value is a wildcard, otherwise it checks if all values in the range are included.
|
|
174
|
+
* @returns {boolean}
|
|
175
|
+
*/
|
|
176
|
+
#isWildcardValue() {
|
|
177
|
+
if (this.options.rawValue.length > 0) {
|
|
178
|
+
return ['*', '?'].includes(this.options.rawValue);
|
|
179
|
+
}
|
|
180
|
+
return Array.from({ length: this.max - this.min + 1 }, (_, i) => i + this.min).every((value) => this.#values.includes(value));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.CronField = CronField;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CronHour = void 0;
|
|
4
|
+
const CronField_1 = require("./CronField");
|
|
5
|
+
const MIN_HOUR = 0;
|
|
6
|
+
const MAX_HOUR = 23;
|
|
7
|
+
const HOUR_CHARS = Object.freeze([]);
|
|
8
|
+
/**
|
|
9
|
+
* Represents the "hour" field within a cron expression.
|
|
10
|
+
* @class CronHour
|
|
11
|
+
* @extends CronField
|
|
12
|
+
*/
|
|
13
|
+
class CronHour extends CronField_1.CronField {
|
|
14
|
+
static get min() {
|
|
15
|
+
return MIN_HOUR;
|
|
16
|
+
}
|
|
17
|
+
static get max() {
|
|
18
|
+
return MAX_HOUR;
|
|
19
|
+
}
|
|
20
|
+
static get chars() {
|
|
21
|
+
return HOUR_CHARS;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* CronHour constructor. Initializes the "hour" field with the provided values.
|
|
25
|
+
* @param {HourRange[]} values - Values for the "hour" field
|
|
26
|
+
* @param {CronFieldOptions} [options] - Options provided by the parser
|
|
27
|
+
*/
|
|
28
|
+
constructor(values, options) {
|
|
29
|
+
super(values, options);
|
|
30
|
+
this.validate();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns an array of allowed values for the "hour" field.
|
|
34
|
+
* @returns {HourRange[]}
|
|
35
|
+
*/
|
|
36
|
+
get values() {
|
|
37
|
+
return super.values;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.CronHour = CronHour;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CronMinute = void 0;
|
|
4
|
+
const CronField_1 = require("./CronField");
|
|
5
|
+
const MIN_MINUTE = 0;
|
|
6
|
+
const MAX_MINUTE = 59;
|
|
7
|
+
const MINUTE_CHARS = Object.freeze([]);
|
|
8
|
+
/**
|
|
9
|
+
* Represents the "second" field within a cron expression.
|
|
10
|
+
* @class CronSecond
|
|
11
|
+
* @extends CronField
|
|
12
|
+
*/
|
|
13
|
+
class CronMinute extends CronField_1.CronField {
|
|
14
|
+
static get min() {
|
|
15
|
+
return MIN_MINUTE;
|
|
16
|
+
}
|
|
17
|
+
static get max() {
|
|
18
|
+
return MAX_MINUTE;
|
|
19
|
+
}
|
|
20
|
+
static get chars() {
|
|
21
|
+
return MINUTE_CHARS;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* CronSecond constructor. Initializes the "second" field with the provided values.
|
|
25
|
+
* @param {SixtyRange[]} values - Values for the "second" field
|
|
26
|
+
* @param {CronFieldOptions} [options] - Options provided by the parser
|
|
27
|
+
*/
|
|
28
|
+
constructor(values, options) {
|
|
29
|
+
super(values, options);
|
|
30
|
+
this.validate();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns an array of allowed values for the "second" field.
|
|
34
|
+
* @returns {SixtyRange[]}
|
|
35
|
+
*/
|
|
36
|
+
get values() {
|
|
37
|
+
return super.values;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.CronMinute = CronMinute;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CronMonth = void 0;
|
|
4
|
+
const CronDate_1 = require("../CronDate");
|
|
5
|
+
const CronField_1 = require("./CronField");
|
|
6
|
+
const MIN_MONTH = 1;
|
|
7
|
+
const MAX_MONTH = 12;
|
|
8
|
+
const MONTH_CHARS = Object.freeze([]);
|
|
9
|
+
/**
|
|
10
|
+
* Represents the "day of the month" field within a cron expression.
|
|
11
|
+
* @class CronDayOfMonth
|
|
12
|
+
* @extends CronField
|
|
13
|
+
*/
|
|
14
|
+
class CronMonth extends CronField_1.CronField {
|
|
15
|
+
static get min() {
|
|
16
|
+
return MIN_MONTH;
|
|
17
|
+
}
|
|
18
|
+
static get max() {
|
|
19
|
+
return MAX_MONTH;
|
|
20
|
+
}
|
|
21
|
+
static get chars() {
|
|
22
|
+
return MONTH_CHARS;
|
|
23
|
+
}
|
|
24
|
+
static get daysInMonth() {
|
|
25
|
+
return CronDate_1.DAYS_IN_MONTH;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* CronDayOfMonth constructor. Initializes the "day of the month" field with the provided values.
|
|
29
|
+
* @param {MonthRange[]} values - Values for the "day of the month" field
|
|
30
|
+
* @param {CronFieldOptions} [options] - Options provided by the parser
|
|
31
|
+
*/
|
|
32
|
+
constructor(values, options) {
|
|
33
|
+
super(values, options);
|
|
34
|
+
this.validate();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns an array of allowed values for the "day of the month" field.
|
|
38
|
+
* @returns {MonthRange[]}
|
|
39
|
+
*/
|
|
40
|
+
get values() {
|
|
41
|
+
return super.values;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.CronMonth = CronMonth;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CronSecond = void 0;
|
|
4
|
+
const CronField_1 = require("./CronField");
|
|
5
|
+
const MIN_SECOND = 0;
|
|
6
|
+
const MAX_SECOND = 59;
|
|
7
|
+
const SECOND_CHARS = Object.freeze([]);
|
|
8
|
+
/**
|
|
9
|
+
* Represents the "second" field within a cron expression.
|
|
10
|
+
* @class CronSecond
|
|
11
|
+
* @extends CronField
|
|
12
|
+
*/
|
|
13
|
+
class CronSecond extends CronField_1.CronField {
|
|
14
|
+
static get min() {
|
|
15
|
+
return MIN_SECOND;
|
|
16
|
+
}
|
|
17
|
+
static get max() {
|
|
18
|
+
return MAX_SECOND;
|
|
19
|
+
}
|
|
20
|
+
static get chars() {
|
|
21
|
+
return SECOND_CHARS;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* CronSecond constructor. Initializes the "second" field with the provided values.
|
|
25
|
+
* @param {SixtyRange[]} values - Values for the "second" field
|
|
26
|
+
* @param {CronFieldOptions} [options] - Options provided by the parser
|
|
27
|
+
*/
|
|
28
|
+
constructor(values, options) {
|
|
29
|
+
super(values, options);
|
|
30
|
+
this.validate();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns an array of allowed values for the "second" field.
|
|
34
|
+
* @returns {SixtyRange[]}
|
|
35
|
+
*/
|
|
36
|
+
get values() {
|
|
37
|
+
return super.values;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.CronSecond = CronSecond;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./CronDayOfMonth"), exports);
|
|
19
|
+
__exportStar(require("./CronDayOfWeek"), exports);
|
|
20
|
+
__exportStar(require("./CronField"), exports);
|
|
21
|
+
__exportStar(require("./CronHour"), exports);
|
|
22
|
+
__exportStar(require("./CronMinute"), exports);
|
|
23
|
+
__exportStar(require("./CronMonth"), exports);
|
|
24
|
+
__exportStar(require("./CronSecond"), exports);
|