cron 5.0.0-beta.1 → 5.0.0-beta.2
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/CHANGELOG.md +1640 -0
- package/README.md +84 -57
- package/dist/constants.js +0 -1
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +7 -2
- package/dist/index.js +0 -1
- package/dist/job.d.ts +2 -2
- package/dist/job.js +31 -23
- package/dist/time.d.ts +1 -2
- package/dist/time.js +1 -4
- package/dist/types/cron.types.d.ts +1 -0
- package/dist/types/cron.types.js +0 -1
- package/dist/types/utils.js +0 -1
- package/dist/utils.js +0 -1
- package/package.json +28 -25
package/README.md
CHANGED
|
@@ -53,6 +53,44 @@ npm install cron
|
|
|
53
53
|
|
|
54
54
|
## ⬆ Migrating
|
|
55
55
|
|
|
56
|
+
v5 dropped Node v18, v20, and v23; deprecated the parameterized constructor, and removed `child_process`
|
|
57
|
+
|
|
58
|
+
<details>
|
|
59
|
+
<summary>Migrating from v4 to v5</summary>
|
|
60
|
+
|
|
61
|
+
### Dropped Node versions
|
|
62
|
+
|
|
63
|
+
Node v18, v20, and v23 are no longer supported. Upgrade your Node installation to v22, v24, or v26.
|
|
64
|
+
|
|
65
|
+
### Deprecated the parameterized constructor
|
|
66
|
+
|
|
67
|
+
Previously this was the recommended way to create new `CronJob` objects:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
const job = new CronJob('* * * * * *', function () {
|
|
71
|
+
console.log('You will see this message every second');
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
While this method is still officially supported (any bugs or security issues will be fixed) it is deprecated and no longer recommended. You will get a warning that support will be dropped in the next major version of Cron.
|
|
76
|
+
|
|
77
|
+
Instead, create `CronJob` objects like this:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
const job = CronJob.from({
|
|
81
|
+
cronTime: '* * * * * *',
|
|
82
|
+
onTick: function () {
|
|
83
|
+
console.log('You will see this message every second');
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Removed `child_process` dependency and native system command support
|
|
89
|
+
|
|
90
|
+
In anticipation of one day offering browser support, the ability to execute system commands natively with `child_process` has been removed. There are other ways to execute system commands in Node, so this functionality is still possible by other means if you need it, it may just require some refactoring.
|
|
91
|
+
|
|
92
|
+
</details>
|
|
93
|
+
|
|
56
94
|
v4 dropped Node v16 and renamed the `job.running` property:
|
|
57
95
|
|
|
58
96
|
<details>
|
|
@@ -95,36 +133,22 @@ v3 introduced TypeScript and tighter Unix cron pattern alignment:
|
|
|
95
133
|
|
|
96
134
|
## 🛠 Basic Usage
|
|
97
135
|
|
|
98
|
-
```
|
|
136
|
+
```js
|
|
99
137
|
import { CronJob } from 'cron';
|
|
100
138
|
|
|
101
|
-
const job = new CronJob(
|
|
102
|
-
'* * * * * *', // cronTime
|
|
103
|
-
function () {
|
|
104
|
-
console.log('You will see this message every second');
|
|
105
|
-
}, // onTick
|
|
106
|
-
null, // onComplete
|
|
107
|
-
true, // start
|
|
108
|
-
'America/Los_Angeles' // timeZone
|
|
109
|
-
);
|
|
110
|
-
// job.start() is optional here because of the fourth parameter set to true.
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
```javascript
|
|
114
|
-
// equivalent job using the "from" static method, providing parameters as an object
|
|
115
139
|
const job = CronJob.from({
|
|
116
140
|
cronTime: '* * * * * *',
|
|
117
141
|
onTick: function () {
|
|
118
142
|
console.log('You will see this message every second');
|
|
119
143
|
},
|
|
120
|
-
start: true,
|
|
121
|
-
timeZone: 'America/Los_Angeles'
|
|
144
|
+
start: true, // optional
|
|
145
|
+
timeZone: 'America/Los_Angeles' // optional
|
|
122
146
|
});
|
|
123
147
|
```
|
|
124
148
|
|
|
125
|
-
> **Note:** In the
|
|
149
|
+
> **Note:** In the example above, the `start` property set to `true` starts the job automatically. If not provided or set to `false`, you must explicitly start the job using `job.start()`.
|
|
126
150
|
|
|
127
|
-
For more advanced examples, check the [examples directory](https://github.com/kelektiv/node-cron/tree/main/examples).
|
|
151
|
+
See the [API below](#api) for all properties. For more advanced examples, check the [examples directory](https://github.com/kelektiv/node-cron/tree/main/examples).
|
|
128
152
|
|
|
129
153
|
## ⏰ Cron Patterns
|
|
130
154
|
|
|
@@ -140,7 +164,7 @@ Detailed patterns and explanations are available at [crontab.org](http://crontab
|
|
|
140
164
|
|
|
141
165
|
### Supported Ranges
|
|
142
166
|
|
|
143
|
-
Here's a quick reference to the UNIX Cron format this library uses, plus an
|
|
167
|
+
Here's a quick reference to the UNIX Cron format this library uses, plus an additional `second` field:
|
|
144
168
|
|
|
145
169
|
```
|
|
146
170
|
field allowed values
|
|
@@ -158,43 +182,11 @@ day of week 0-7 (0 or 7 is Sunday, or use names)
|
|
|
158
182
|
|
|
159
183
|
## 📖 API
|
|
160
184
|
|
|
161
|
-
### Standalone Functions
|
|
162
|
-
|
|
163
|
-
- `sendAt`: Indicates when a `CronTime` will execute (returns a Luxon `DateTime` object).
|
|
164
|
-
|
|
165
|
-
```javascript
|
|
166
|
-
import * as cron from 'cron';
|
|
167
|
-
|
|
168
|
-
const dt = cron.sendAt('0 0 * * *');
|
|
169
|
-
console.log(`The job would run at: ${dt.toISO()}`);
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
- `timeout`: Indicates the number of milliseconds in the future at which a `CronTime` will execute (returns a number).
|
|
173
|
-
|
|
174
|
-
```javascript
|
|
175
|
-
import * as cron from 'cron';
|
|
176
|
-
|
|
177
|
-
const timeout = cron.timeout('0 0 * * *');
|
|
178
|
-
console.log(`The job would run in ${timeout}ms`);
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
- `validateCronExpression`: Validates if a given cron expression is valid (returns an object with `valid` and `error` properties).
|
|
182
|
-
|
|
183
|
-
```javascript
|
|
184
|
-
import * as cron from 'cron';
|
|
185
|
-
|
|
186
|
-
const validation = cron.validateCronExpression('0 0 * * *');
|
|
187
|
-
console.log(`Is the cron expression valid? ${validation.valid}`);
|
|
188
|
-
if (!validation.valid) {
|
|
189
|
-
console.error(`Validation error: ${validation.error}`);
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
185
|
### CronJob Class
|
|
194
186
|
|
|
195
187
|
#### Constructor
|
|
196
188
|
|
|
197
|
-
`
|
|
189
|
+
`CronJob.from({ ... })`:
|
|
198
190
|
|
|
199
191
|
- `cronTime`: [REQUIRED] - The time to fire off your job. Can be cron syntax, a JS [`Date`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date) object or a Luxon [`DateTime`](https://moment.github.io/luxon/api-docs/index.html#datetime) object.
|
|
200
192
|
|
|
@@ -249,10 +241,13 @@ day of week 0-7 (0 or 7 is Sunday, or use names)
|
|
|
249
241
|
- `isCallbackRunning`: [READ-ONLY] Indicates if a callback is currently executing.
|
|
250
242
|
|
|
251
243
|
```javascript
|
|
252
|
-
const job = new CronJob(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
244
|
+
const job = new CronJob.from({
|
|
245
|
+
cronTime: '* * * * * *',
|
|
246
|
+
onTick: async () => {
|
|
247
|
+
console.log(job.isCallbackRunning); // true during callback execution
|
|
248
|
+
await someAsyncTask();
|
|
249
|
+
console.log(job.isCallbackRunning); // still true until callback completes
|
|
250
|
+
}
|
|
256
251
|
});
|
|
257
252
|
|
|
258
253
|
console.log(job.isCallbackRunning); // false
|
|
@@ -273,6 +268,38 @@ day of week 0-7 (0 or 7 is Sunday, or use names)
|
|
|
273
268
|
|
|
274
269
|
- `utcOffset`: [OPTIONAL] - Analogous to `utcOffset` from `CronJob` parameters.
|
|
275
270
|
|
|
271
|
+
### Standalone Functions
|
|
272
|
+
|
|
273
|
+
- `sendAt`: Indicates when a `CronTime` will execute (returns a Luxon `DateTime` object).
|
|
274
|
+
|
|
275
|
+
```javascript
|
|
276
|
+
import * as cron from 'cron';
|
|
277
|
+
|
|
278
|
+
const dt = cron.sendAt('0 0 * * *');
|
|
279
|
+
console.log(`The job would run at: ${dt.toISO()}`);
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
- `timeout`: Indicates the number of milliseconds in the future at which a `CronTime` will execute (returns a number).
|
|
283
|
+
|
|
284
|
+
```javascript
|
|
285
|
+
import * as cron from 'cron';
|
|
286
|
+
|
|
287
|
+
const timeout = cron.timeout('0 0 * * *');
|
|
288
|
+
console.log(`The job would run in ${timeout}ms`);
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
- `validateCronExpression`: Validates if a given cron expression is valid (returns an object with `valid` and `error` properties).
|
|
292
|
+
|
|
293
|
+
```javascript
|
|
294
|
+
import * as cron from 'cron';
|
|
295
|
+
|
|
296
|
+
const validation = cron.validateCronExpression('0 0 * * *');
|
|
297
|
+
console.log(`Is the cron expression valid? ${validation.valid}`);
|
|
298
|
+
if (!validation.valid) {
|
|
299
|
+
console.error(`Validation error: ${validation.error}`);
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
276
303
|
## 💢 Gotchas
|
|
277
304
|
|
|
278
305
|
- Both JS `Date` and Luxon `DateTime` objects don't guarantee millisecond precision due to computation delays. This module excludes millisecond precision for standard cron syntax but allows execution date specification through JS `Date` or Luxon `DateTime` objects. However, specifying a precise future execution time, such as adding a millisecond to the current time, may not always work due to these computation delays. It's observed that delays less than 4-5 ms might lead to inconsistencies. While we could limit all date granularity to seconds, we've chosen to allow greater precision but advise users of potential issues.
|
package/dist/constants.js
CHANGED
package/dist/errors.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare class CronError extends Error {
|
|
|
3
3
|
export declare class ExclusiveParametersError extends CronError {
|
|
4
4
|
constructor(param1: string, param2: string);
|
|
5
5
|
}
|
|
6
|
+
export declare const assertExclusiveTimeZoneAndUtcOffset: (timeZone?: string | null, utcOffset?: number | null) => void;
|
package/dist/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExclusiveParametersError = exports.CronError = void 0;
|
|
3
|
+
exports.assertExclusiveTimeZoneAndUtcOffset = exports.ExclusiveParametersError = exports.CronError = void 0;
|
|
4
4
|
class CronError extends Error {
|
|
5
5
|
}
|
|
6
6
|
exports.CronError = CronError;
|
|
@@ -10,4 +10,9 @@ class ExclusiveParametersError extends CronError {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
exports.ExclusiveParametersError = ExclusiveParametersError;
|
|
13
|
-
|
|
13
|
+
const assertExclusiveTimeZoneAndUtcOffset = (timeZone, utcOffset) => {
|
|
14
|
+
if (timeZone != null && utcOffset != null) {
|
|
15
|
+
throw new ExclusiveParametersError('timeZone', 'utcOffset');
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.assertExclusiveTimeZoneAndUtcOffset = assertExclusiveTimeZoneAndUtcOffset;
|
package/dist/index.js
CHANGED
package/dist/job.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export declare class CronJob<OC extends CronOnCompleteCommand | null = null, C =
|
|
|
17
17
|
private _callbacks;
|
|
18
18
|
get isActive(): boolean;
|
|
19
19
|
get isCallbackRunning(): boolean;
|
|
20
|
-
constructor(cronTime: CronJobParams<OC, C>['cronTime'], onTick: CronJobParams<OC, C>['onTick'], onComplete?: CronJobParams<OC, C>['onComplete'], start?: CronJobParams<OC, C>['start'], timeZone?: CronJobParams<OC, C>['timeZone'], context?: CronJobParams<OC, C>['context'], runOnInit?: CronJobParams<OC, C>['runOnInit'], utcOffset?: null, unrefTimeout?: CronJobParams<OC, C>['unrefTimeout'], waitForCompletion?: CronJobParams<OC, C>['waitForCompletion'], errorHandler?: CronJobParams<OC, C>['errorHandler'], name?: CronJobParams<OC, C>['name'], threshold?: CronJobParams<OC, C>['threshold']);
|
|
21
|
-
constructor(cronTime: CronJobParams<OC, C>['cronTime'], onTick: CronJobParams<OC, C>['onTick'], onComplete?: CronJobParams<OC, C>['onComplete'], start?: CronJobParams<OC, C>['start'], timeZone?: null, context?: CronJobParams<OC, C>['context'], runOnInit?: CronJobParams<OC, C>['runOnInit'], utcOffset?: CronJobParams<OC, C>['utcOffset'], unrefTimeout?: CronJobParams<OC, C>['unrefTimeout'], waitForCompletion?: CronJobParams<OC, C>['waitForCompletion'], errorHandler?: CronJobParams<OC, C>['errorHandler'], name?: CronJobParams<OC, C>['name'], threshold?: CronJobParams<OC, C>['threshold']);
|
|
20
|
+
constructor(cronTime: CronJobParams<OC, C>['cronTime'], onTick: CronJobParams<OC, C>['onTick'], onComplete?: CronJobParams<OC, C>['onComplete'], start?: CronJobParams<OC, C>['start'], timeZone?: CronJobParams<OC, C>['timeZone'], context?: CronJobParams<OC, C>['context'], runOnInit?: CronJobParams<OC, C>['runOnInit'], utcOffset?: null, unrefTimeout?: CronJobParams<OC, C>['unrefTimeout'], waitForCompletion?: CronJobParams<OC, C>['waitForCompletion'], errorHandler?: CronJobParams<OC, C>['errorHandler'], name?: CronJobParams<OC, C>['name'], threshold?: CronJobParams<OC, C>['threshold'], usedFrom?: CronJobParams<OC, C>['usedFrom']);
|
|
21
|
+
constructor(cronTime: CronJobParams<OC, C>['cronTime'], onTick: CronJobParams<OC, C>['onTick'], onComplete?: CronJobParams<OC, C>['onComplete'], start?: CronJobParams<OC, C>['start'], timeZone?: null, context?: CronJobParams<OC, C>['context'], runOnInit?: CronJobParams<OC, C>['runOnInit'], utcOffset?: CronJobParams<OC, C>['utcOffset'], unrefTimeout?: CronJobParams<OC, C>['unrefTimeout'], waitForCompletion?: CronJobParams<OC, C>['waitForCompletion'], errorHandler?: CronJobParams<OC, C>['errorHandler'], name?: CronJobParams<OC, C>['name'], threshold?: CronJobParams<OC, C>['threshold'], usedFrom?: CronJobParams<OC, C>['usedFrom']);
|
|
22
22
|
static from<OC extends CronOnCompleteCommand | null = null, C = null>(params: CronJobParams<OC, C>): CronJob<OC, C>;
|
|
23
23
|
private isCronOnCompleteCallback;
|
|
24
24
|
addCallback(callback: CronCallback<C, WithOnComplete<OC>>): void;
|
package/dist/job.js
CHANGED
|
@@ -19,7 +19,7 @@ class CronJob {
|
|
|
19
19
|
get isCallbackRunning() {
|
|
20
20
|
return this._isCallbackRunning;
|
|
21
21
|
}
|
|
22
|
-
constructor(cronTime, onTick, onComplete, start, timeZone, context, runOnInit, utcOffset, unrefTimeout, waitForCompletion, errorHandler, name, threshold) {
|
|
22
|
+
constructor(cronTime, onTick, onComplete, start, timeZone, context, runOnInit, utcOffset, unrefTimeout, waitForCompletion, errorHandler, name, threshold, usedFrom) {
|
|
23
23
|
this.unrefTimeout = false;
|
|
24
24
|
this.lastExecution = null;
|
|
25
25
|
this.runOnce = false;
|
|
@@ -28,21 +28,19 @@ class CronJob {
|
|
|
28
28
|
this._isActive = false;
|
|
29
29
|
this._isCallbackRunning = false;
|
|
30
30
|
this._callbacks = [];
|
|
31
|
+
if (!usedFrom) {
|
|
32
|
+
console.warn(`[Cron] Warning: The parameterized constructor is deprecated and will be removed in the next major version of Cron (v6).
|
|
33
|
+
\n Consider updating the instantiation of your CronJob object to use the static 'from' method.
|
|
34
|
+
\n See https://github.com/kelektiv/node-cron#deprecated-the-parameterized-constructor`);
|
|
35
|
+
}
|
|
31
36
|
this.context = (context !== null && context !== void 0 ? context : this);
|
|
32
37
|
this.waitForCompletion = Boolean(waitForCompletion);
|
|
33
38
|
this.errorHandler = errorHandler;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
else if (utcOffset != null) {
|
|
41
|
-
this.cronTime = new time_1.CronTime(cronTime, null, utcOffset);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.cronTime = new time_1.CronTime(cronTime, timeZone, utcOffset);
|
|
45
|
-
}
|
|
39
|
+
(0, errors_1.assertExclusiveTimeZoneAndUtcOffset)(timeZone, utcOffset);
|
|
40
|
+
this.cronTime =
|
|
41
|
+
timeZone != null
|
|
42
|
+
? new time_1.CronTime(cronTime, timeZone, null)
|
|
43
|
+
: new time_1.CronTime(cronTime, null, utcOffset !== null && utcOffset !== void 0 ? utcOffset : null);
|
|
46
44
|
if (unrefTimeout != null) {
|
|
47
45
|
this.unrefTimeout = unrefTimeout;
|
|
48
46
|
}
|
|
@@ -67,17 +65,15 @@ class CronJob {
|
|
|
67
65
|
this.start();
|
|
68
66
|
}
|
|
69
67
|
static from(params) {
|
|
70
|
-
|
|
71
|
-
throw new errors_1.ExclusiveParametersError('timeZone', 'utcOffset');
|
|
72
|
-
}
|
|
68
|
+
(0, errors_1.assertExclusiveTimeZoneAndUtcOffset)(params.timeZone, params.utcOffset);
|
|
73
69
|
if (params.timeZone != null) {
|
|
74
|
-
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, params.timeZone, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion, params.errorHandler, params.name, params.threshold);
|
|
70
|
+
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, params.timeZone, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion, params.errorHandler, params.name, params.threshold, true);
|
|
75
71
|
}
|
|
76
72
|
else if (params.utcOffset != null) {
|
|
77
|
-
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, null, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion, params.errorHandler, params.name, params.threshold);
|
|
73
|
+
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, null, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion, params.errorHandler, params.name, params.threshold, true);
|
|
78
74
|
}
|
|
79
75
|
else {
|
|
80
|
-
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, params.timeZone, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion, params.errorHandler, params.name, params.threshold);
|
|
76
|
+
return new CronJob(params.cronTime, params.onTick, params.onComplete, params.start, params.timeZone, params.context, params.runOnInit, params.utcOffset, params.unrefTimeout, params.waitForCompletion, params.errorHandler, params.name, params.threshold, true);
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
isCronOnCompleteCallback(fn) {
|
|
@@ -111,8 +107,21 @@ class CronJob {
|
|
|
111
107
|
try {
|
|
112
108
|
for (const callback of this._callbacks) {
|
|
113
109
|
const result = callback.call(this.context, this.onComplete);
|
|
114
|
-
if (
|
|
115
|
-
|
|
110
|
+
if (result &&
|
|
111
|
+
typeof result === 'object' &&
|
|
112
|
+
typeof result.then === 'function') {
|
|
113
|
+
if (this.waitForCompletion) {
|
|
114
|
+
yield result;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
result.catch(error => {
|
|
118
|
+
if (this.errorHandler != null)
|
|
119
|
+
this.errorHandler(error);
|
|
120
|
+
else
|
|
121
|
+
console.error('[Cron] error in callback', error);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
116
125
|
}
|
|
117
126
|
}
|
|
118
127
|
catch (error) {
|
|
@@ -139,7 +148,7 @@ class CronJob {
|
|
|
139
148
|
let startTime;
|
|
140
149
|
const setCronTimeout = (t) => {
|
|
141
150
|
startTime = Date.now();
|
|
142
|
-
this._timeout = setTimeout(callbackWrapper, t);
|
|
151
|
+
this._timeout = setTimeout(callbackWrapper, Math.max(t, 1));
|
|
143
152
|
if (this.unrefTimeout && typeof this._timeout.unref === 'function') {
|
|
144
153
|
this._timeout.unref();
|
|
145
154
|
}
|
|
@@ -231,4 +240,3 @@ class CronJob {
|
|
|
231
240
|
}
|
|
232
241
|
}
|
|
233
242
|
exports.CronJob = CronJob;
|
|
234
|
-
//# sourceMappingURL=job.js.map
|
package/dist/time.d.ts
CHANGED
|
@@ -19,8 +19,7 @@ export declare class CronTime {
|
|
|
19
19
|
private dayOfMonth;
|
|
20
20
|
private month;
|
|
21
21
|
private dayOfWeek;
|
|
22
|
-
constructor(source: CronJobParams['cronTime'], timeZone?: CronJobParams['timeZone'], utcOffset?:
|
|
23
|
-
constructor(source: CronJobParams['cronTime'], timeZone?: null, utcOffset?: CronJobParams['utcOffset']);
|
|
22
|
+
constructor(source: CronJobParams['cronTime'], timeZone?: CronJobParams['timeZone'], utcOffset?: CronJobParams['utcOffset']);
|
|
24
23
|
static validateCronExpression(cronExpression: string): {
|
|
25
24
|
valid: boolean;
|
|
26
25
|
error?: CronError;
|
package/dist/time.js
CHANGED
|
@@ -13,9 +13,7 @@ class CronTime {
|
|
|
13
13
|
this.dayOfMonth = {};
|
|
14
14
|
this.month = {};
|
|
15
15
|
this.dayOfWeek = {};
|
|
16
|
-
|
|
17
|
-
throw new errors_1.ExclusiveParametersError('timeZone', 'utcOffset');
|
|
18
|
-
}
|
|
16
|
+
(0, errors_1.assertExclusiveTimeZoneAndUtcOffset)(timeZone, utcOffset);
|
|
19
17
|
if (timeZone) {
|
|
20
18
|
const dt = luxon_1.DateTime.fromObject({}, { zone: timeZone });
|
|
21
19
|
if (!dt.isValid) {
|
|
@@ -308,4 +306,3 @@ class CronTime {
|
|
|
308
306
|
}
|
|
309
307
|
}
|
|
310
308
|
exports.CronTime = CronTime;
|
|
311
|
-
//# sourceMappingURL=time.js.map
|
|
@@ -13,6 +13,7 @@ interface BaseCronJobParams<OC extends CronOnCompleteCommand | null = null, C =
|
|
|
13
13
|
waitForCompletion?: boolean | null;
|
|
14
14
|
errorHandler?: ((error: unknown) => void) | null;
|
|
15
15
|
threshold?: number | null;
|
|
16
|
+
usedFrom?: boolean | null;
|
|
16
17
|
name?: string | null;
|
|
17
18
|
}
|
|
18
19
|
export type CronJobParams<OC extends CronOnCompleteCommand | null = null, C = null> = BaseCronJobParams<OC, C> & ({
|
package/dist/types/cron.types.js
CHANGED
package/dist/types/utils.js
CHANGED
package/dist/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cron",
|
|
3
3
|
"description": "Cron jobs for your node",
|
|
4
|
-
"version": "5.0.0-beta.
|
|
5
|
-
"author": "
|
|
4
|
+
"version": "5.0.0-beta.2",
|
|
5
|
+
"author": "Brandon der Blätter <https://intcreator.com/> (https://github.com/intcreator)",
|
|
6
|
+
"funding": {
|
|
7
|
+
"type": "ko-fi",
|
|
8
|
+
"url": "https://ko-fi.com/intcreator"
|
|
9
|
+
},
|
|
6
10
|
"bugs": {
|
|
7
11
|
"url": "https://github.com/kelektiv/node-cron/issues"
|
|
8
12
|
},
|
|
@@ -24,39 +28,38 @@
|
|
|
24
28
|
"prepare": "husky"
|
|
25
29
|
},
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@types/luxon": "~3.
|
|
28
|
-
"luxon": "~3.
|
|
31
|
+
"@types/luxon": "~3.7.0",
|
|
32
|
+
"luxon": "~3.7.0"
|
|
29
33
|
},
|
|
30
34
|
"devDependencies": {
|
|
31
|
-
"@commitlint/cli": "
|
|
32
|
-
"@eslint/js": "9.
|
|
33
|
-
"@fast-check/jest": "2.
|
|
35
|
+
"@commitlint/cli": "20.5.3",
|
|
36
|
+
"@eslint/js": "9.39.4",
|
|
37
|
+
"@fast-check/jest": "2.2.0",
|
|
34
38
|
"@insurgent/commitlint-config": "20.0.0",
|
|
35
39
|
"@insurgent/conventional-changelog-preset": "10.0.0",
|
|
36
40
|
"@semantic-release/changelog": "6.0.3",
|
|
37
41
|
"@semantic-release/commit-analyzer": "13.0.1",
|
|
38
42
|
"@semantic-release/git": "10.0.1",
|
|
39
|
-
"@semantic-release/github": "
|
|
40
|
-
"@semantic-release/npm": "
|
|
41
|
-
"@semantic-release/release-notes-generator": "14.
|
|
42
|
-
"@swc/core": "1.
|
|
43
|
-
"@swc/jest": "0.2.
|
|
44
|
-
"@types/jest": "
|
|
45
|
-
"@types/node": "
|
|
46
|
-
"@types/sinon": "
|
|
47
|
-
"chai": "5.2.0",
|
|
43
|
+
"@semantic-release/github": "12.0.9",
|
|
44
|
+
"@semantic-release/npm": "13.1.5",
|
|
45
|
+
"@semantic-release/release-notes-generator": "14.1.1",
|
|
46
|
+
"@swc/core": "1.16.1",
|
|
47
|
+
"@swc/jest": "0.2.39",
|
|
48
|
+
"@types/jest": "30.0.0",
|
|
49
|
+
"@types/node": "24.13.3",
|
|
50
|
+
"@types/sinon": "22.0.0",
|
|
48
51
|
"cross-env": "7.0.3",
|
|
49
52
|
"eslint": "8.57.1",
|
|
50
|
-
"eslint-config-prettier": "9.1.
|
|
53
|
+
"eslint-config-prettier": "9.1.2",
|
|
51
54
|
"eslint-plugin-jest": "27.9.0",
|
|
52
|
-
"eslint-plugin-prettier": "5.
|
|
55
|
+
"eslint-plugin-prettier": "5.5.6",
|
|
53
56
|
"husky": "9.1.7",
|
|
54
|
-
"jest": "
|
|
55
|
-
"lint-staged": "15.5.
|
|
56
|
-
"prettier": "3.
|
|
57
|
-
"semantic-release": "
|
|
58
|
-
"sinon": "
|
|
59
|
-
"typescript": "5.
|
|
57
|
+
"jest": "30.4.2",
|
|
58
|
+
"lint-staged": "15.5.2",
|
|
59
|
+
"prettier": "3.8.4",
|
|
60
|
+
"semantic-release": "25.0.9",
|
|
61
|
+
"sinon": "22.1.0",
|
|
62
|
+
"typescript": "5.9.3",
|
|
60
63
|
"typescript-eslint": "7.18.0"
|
|
61
64
|
},
|
|
62
65
|
"keywords": [
|
|
@@ -70,7 +73,7 @@
|
|
|
70
73
|
],
|
|
71
74
|
"license": "MIT",
|
|
72
75
|
"contributors": [
|
|
73
|
-
"
|
|
76
|
+
"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)",
|
|
74
77
|
"Pierre Cavin <me@sherlox.io> (https://github.com/sheerlox)",
|
|
75
78
|
"Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)",
|
|
76
79
|
"James Padolsey <> (https://github.com/jamespadolsey)",
|