cron 3.4.0 → 3.5.1-beta.1

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 CHANGED
@@ -1,3 +1,36 @@
1
+ ## [3.5.1-beta.1](https://github.com/kelektiv/node-cron/compare/v3.5.0...v3.5.1-beta.1) (2025-02-18)
2
+
3
+ ### 🐛 Bug Fixes
4
+
5
+ * attempt to fix [#805](https://github.com/kelektiv/node-cron/issues/805) ([187dbe5](https://github.com/kelektiv/node-cron/commit/187dbe57ada28217b810b231bf57afdfe3a3b394))
6
+
7
+ ### ♻️ Chores
8
+
9
+ * **action:** update actions/checkout action to v4.2.2 ([#927](https://github.com/kelektiv/node-cron/issues/927)) ([ff1721e](https://github.com/kelektiv/node-cron/commit/ff1721e95f1a0d7291f3809dd89af8a0956b8f7f))
10
+ * **action:** update actions/setup-node action to v4.1.0 ([#928](https://github.com/kelektiv/node-cron/issues/928)) ([3e27773](https://github.com/kelektiv/node-cron/commit/3e277738b4a5d096f5990602c3d7aaff02f5961c))
11
+ * **action:** update actions/upload-artifact action to v4.6.0 ([#931](https://github.com/kelektiv/node-cron/issues/931)) ([8283000](https://github.com/kelektiv/node-cron/commit/82830003bcb375b55ae86b2038305af69f587d33))
12
+ * **action:** update amannn/action-semantic-pull-request action to v5.5.3 ([#929](https://github.com/kelektiv/node-cron/issues/929)) ([f1851d7](https://github.com/kelektiv/node-cron/commit/f1851d7d3f4780ef7f6834f35999f93cae5961cf))
13
+ * **action:** update github/codeql-action action to v3.28.1 ([#922](https://github.com/kelektiv/node-cron/issues/922)) ([eefd476](https://github.com/kelektiv/node-cron/commit/eefd47698bad8da9c9cad15fba9ecc0925b95f49))
14
+ * **deps:** lock file maintenance ([c3af5fc](https://github.com/kelektiv/node-cron/commit/c3af5fc439b822683377abea4a7e957ee7743c5c))
15
+ * **deps:** lock file maintenance ([d689a1c](https://github.com/kelektiv/node-cron/commit/d689a1c489f9576de49da8ee8489cbaf700be3c3))
16
+ * **renovate:** improve schedules & automerging to reduce noise ([#942](https://github.com/kelektiv/node-cron/issues/942)) ([c253032](https://github.com/kelektiv/node-cron/commit/c253032d520edd09f29e111fa181f4977a7f9d53))
17
+ * **runtime:** dirty Node 16 drop, don't cherry-pick ([d6815f3](https://github.com/kelektiv/node-cron/commit/d6815f3ff94799f8157b8ee8daae1897d3fa0cf2))
18
+
19
+ ## [3.5.0](https://github.com/kelektiv/node-cron/compare/v3.4.0...v3.5.0) (2025-01-10)
20
+
21
+ ### ✨ Features
22
+
23
+ * throw instead of silently rewriting invalid cron expressions ([#937](https://github.com/kelektiv/node-cron/issues/937)) ([dcc5b93](https://github.com/kelektiv/node-cron/commit/dcc5b939fb08a806793799019c9f256bd137c33d))
24
+
25
+ ### ⚙️ Continuous Integrations
26
+
27
+ * **action:** update step-security/harden-runner action to v2.10.3 ([#943](https://github.com/kelektiv/node-cron/issues/943)) ([cd7ee9f](https://github.com/kelektiv/node-cron/commit/cd7ee9f62fbdd16ec150e9e5aa69d8852f5b3dcb))
28
+
29
+ ### ♻️ Chores
30
+
31
+ * **deps:** update dependency [@types](https://github.com/types)/node to v20.17.12 ([2a867f9](https://github.com/kelektiv/node-cron/commit/2a867f9c34c216ac04ce8bce34e0e16578f7dd0c))
32
+ * **deps:** update dependency [@types](https://github.com/types)/node to v22 ([#900](https://github.com/kelektiv/node-cron/issues/900)) ([f7548bd](https://github.com/kelektiv/node-cron/commit/f7548bd3b6981514abd174341b39813d0d6f239a))
33
+
1
34
  ## [3.4.0](https://github.com/kelektiv/node-cron/compare/v3.3.2...v3.4.0) (2025-01-09)
2
35
 
3
36
  ### ✨ Features
@@ -22,6 +55,12 @@
22
55
 
23
56
  * fix infinite loop on expressions resolving only inside a DST forward jump ([#938](https://github.com/kelektiv/node-cron/issues/938)) ([efb8df5](https://github.com/kelektiv/node-cron/commit/efb8df53405b4ce2ea2e70be9e4d90c124616a51)), closes [/github.com/kelektiv/node-cron/pull/667/files#diff-c14c2dca8456f15417b39cfbd9758009f8eb4f3a190a415768d6e4ae6ae9dceeL473-L477](https://github.com/kelektiv//github.com/kelektiv/node-cron/pull/667/files/issues/diff-c14c2dca8456f15417b39cfbd9758009f8eb4f3a190a415768d6e4ae6ae9dceeL473-L477) [#919](https://github.com/kelektiv/node-cron/issues/919) [#919](https://github.com/kelektiv/node-cron/issues/919)
24
57
 
58
+ ## [3.3.2-beta.1](https://github.com/kelektiv/node-cron/compare/v3.3.1...v3.3.2-beta.1) (2024-12-27)
59
+
60
+ ### 🐛 Bug Fixes
61
+
62
+ * attempt to fix [#805](https://github.com/kelektiv/node-cron/issues/805) ([187dbe5](https://github.com/kelektiv/node-cron/commit/187dbe57ada28217b810b231bf57afdfe3a3b394))
63
+
25
64
  ### ⚙️ Continuous Integrations
26
65
 
27
66
  * **action:** update marocchino/sticky-pull-request-comment action to v2.9.0 ([#930](https://github.com/kelektiv/node-cron/issues/930)) ([1e7bce9](https://github.com/kelektiv/node-cron/commit/1e7bce9d12a774104f39c1d75b37bdb134e4b270))
@@ -29,7 +68,10 @@
29
68
 
30
69
  ### ♻️ Chores
31
70
 
71
+ <<<<<<< HEAD
72
+ =======
32
73
  * **deps:** lock file maintenance ([70c3339](https://github.com/kelektiv/node-cron/commit/70c333955612d39b692ab9535b36fe33423eb593))
74
+ >>>>>>> main
33
75
  * **deps:** lock file maintenance ([afad454](https://github.com/kelektiv/node-cron/commit/afad454e5e4f52e3da54965a0e10540e035c4f58))
34
76
  * **deps:** lock file maintenance ([b1dbf69](https://github.com/kelektiv/node-cron/commit/b1dbf69104a58022a638d5b68b59f85089fae7c6))
35
77
  * **deps:** pin dependencies ([#915](https://github.com/kelektiv/node-cron/issues/915)) ([dfcbd3c](https://github.com/kelektiv/node-cron/commit/dfcbd3cf7d901415bda5b4929566bd4ad527af62))
package/README.md CHANGED
@@ -6,6 +6,11 @@
6
6
  Perfect for tasks like data backups, notifications, and many more!
7
7
  </p>
8
8
 
9
+ > **⚠️ WARNING**
10
+ >
11
+ > This is a WIP released as beta for testing purposes.
12
+ > For more information, please refer to [issue #805](https://github.com/kelektiv/node-cron/issues/805).
13
+
9
14
  # Cron for Node.js
10
15
 
11
16
  [![Version](https://img.shields.io/npm/v/cron?label=version&logo=npm)](https://www.npmjs.com/package/cron)
@@ -6,20 +6,6 @@ export declare const CONSTRAINTS: Readonly<{
6
6
  readonly month: readonly [1, 12];
7
7
  readonly dayOfWeek: readonly [0, 7];
8
8
  }>;
9
- export declare const MONTH_CONSTRAINTS: Readonly<{
10
- readonly 1: 31;
11
- readonly 2: 29;
12
- readonly 3: 31;
13
- readonly 4: 30;
14
- readonly 5: 31;
15
- readonly 6: 30;
16
- readonly 7: 31;
17
- readonly 8: 31;
18
- readonly 9: 30;
19
- readonly 10: 31;
20
- readonly 11: 30;
21
- readonly 12: 31;
22
- }>;
23
9
  export declare const PARSE_DEFAULTS: Readonly<{
24
10
  readonly second: "0";
25
11
  readonly minute: "*";
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RE_RANGE = exports.RE_WILDCARDS = exports.PRESETS = exports.TIME_UNITS_LEN = exports.TIME_UNITS = exports.TIME_UNITS_MAP = exports.ALIASES = exports.PARSE_DEFAULTS = exports.MONTH_CONSTRAINTS = exports.CONSTRAINTS = void 0;
3
+ exports.RE_RANGE = exports.RE_WILDCARDS = exports.PRESETS = exports.TIME_UNITS_LEN = exports.TIME_UNITS = exports.TIME_UNITS_MAP = exports.ALIASES = exports.PARSE_DEFAULTS = exports.CONSTRAINTS = void 0;
4
4
  exports.CONSTRAINTS = Object.freeze({
5
5
  second: [0, 59],
6
6
  minute: [0, 59],
@@ -9,20 +9,6 @@ exports.CONSTRAINTS = Object.freeze({
9
9
  month: [1, 12],
10
10
  dayOfWeek: [0, 7]
11
11
  });
12
- exports.MONTH_CONSTRAINTS = Object.freeze({
13
- 1: 31,
14
- 2: 29,
15
- 3: 31,
16
- 4: 30,
17
- 5: 31,
18
- 6: 30,
19
- 7: 31,
20
- 8: 31,
21
- 9: 30,
22
- 10: 31,
23
- 11: 30,
24
- 12: 31
25
- });
26
12
  exports.PARSE_DEFAULTS = Object.freeze({
27
13
  second: '0',
28
14
  minute: '*',
package/dist/job.js CHANGED
@@ -183,7 +183,20 @@ class CronJob {
183
183
  setCronTimeout(timeout);
184
184
  }
185
185
  else {
186
- this.stop();
186
+ if (timeout <= 1000) {
187
+ console.warn(`[CRON DEBUG] Executing job with a delay: ${timeout}ms`);
188
+ this.lastExecution = new Date();
189
+ this.running = false;
190
+ if (!this.runOnce)
191
+ this.start();
192
+ void this.fireOnTick();
193
+ }
194
+ else {
195
+ console.error(`[CRON DEBUG] Stopping job due to delay being higher than 1s: ${timeout}ms`);
196
+ this.stop();
197
+ }
198
+ console.debug(`[CRON DEBUG] Current date: ${new Date().toISOString()}`);
199
+ console.debug(`[CRON DEBUG] Source: ${String(this.cronTime.source)}`);
187
200
  }
188
201
  }
189
202
  lastDate() {
package/dist/time.d.ts CHANGED
@@ -14,7 +14,6 @@ export declare class CronTime {
14
14
  constructor(source: CronJobParams['cronTime'], timeZone?: CronJobParams['timeZone'], utcOffset?: null);
15
15
  constructor(source: CronJobParams['cronTime'], timeZone?: null, utcOffset?: CronJobParams['utcOffset']);
16
16
  private _getWeekDay;
17
- private _verifyParse;
18
17
  sendAt(): DateTime;
19
18
  sendAt(i: number): DateTime[];
20
19
  getTimeout(): number;
package/dist/time.js CHANGED
@@ -4,7 +4,6 @@ exports.CronTime = void 0;
4
4
  const luxon_1 = require("luxon");
5
5
  const constants_1 = require("./constants");
6
6
  const errors_1 = require("./errors");
7
- const utils_1 = require("./utils");
8
7
  class CronTime {
9
8
  constructor(source, timeZone, utcOffset) {
10
9
  this.realDate = false;
@@ -35,40 +34,11 @@ class CronTime {
35
34
  else {
36
35
  this.source = source;
37
36
  this._parse(this.source);
38
- this._verifyParse();
39
37
  }
40
38
  }
41
39
  _getWeekDay(date) {
42
40
  return date.weekday === 7 ? 0 : date.weekday;
43
41
  }
44
- _verifyParse() {
45
- const months = (0, utils_1.getRecordKeys)(this.month);
46
- const daysOfMonth = (0, utils_1.getRecordKeys)(this.dayOfMonth);
47
- let isOk = false;
48
- let lastWrongMonth = null;
49
- for (const m of months) {
50
- const con = constants_1.MONTH_CONSTRAINTS[m];
51
- for (const day of daysOfMonth) {
52
- if (day <= con) {
53
- isOk = true;
54
- }
55
- }
56
- if (!isOk) {
57
- lastWrongMonth = m;
58
- console.warn(`Month '${m}' is limited to '${con}' days.`);
59
- }
60
- }
61
- if (!isOk && lastWrongMonth !== null) {
62
- const notOkCon = constants_1.MONTH_CONSTRAINTS[lastWrongMonth];
63
- for (const notOkDay of daysOfMonth) {
64
- if (notOkDay > notOkCon) {
65
- delete this.dayOfMonth[notOkDay];
66
- const fixedDay = (notOkDay % notOkCon);
67
- this.dayOfMonth[fixedDay] = true;
68
- }
69
- }
70
- }
71
- }
72
42
  sendAt(i) {
73
43
  let date = this.realDate && this.source instanceof luxon_1.DateTime
74
44
  ? this.source
@@ -107,7 +77,7 @@ class CronTime {
107
77
  }
108
78
  }
109
79
  getTimeout() {
110
- return Math.max(-1, this.sendAt().toMillis() - luxon_1.DateTime.local().toMillis());
80
+ return this.sendAt().toMillis() - luxon_1.DateTime.local().toMillis();
111
81
  }
112
82
  toString() {
113
83
  return this.toJSON().join(' ');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cron",
3
3
  "description": "Cron jobs for your node",
4
- "version": "3.4.0",
4
+ "version": "3.5.1-beta.1",
5
5
  "author": "Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/kelektiv/node-cron/issues"
@@ -40,7 +40,7 @@
40
40
  "@semantic-release/npm": "12.0.1",
41
41
  "@semantic-release/release-notes-generator": "14.0.3",
42
42
  "@types/jest": "29.5.14",
43
- "@types/node": "20.17.11",
43
+ "@types/node": "22.10.5",
44
44
  "@types/sinon": "17.0.3",
45
45
  "chai": "5.1.2",
46
46
  "eslint": "8.57.1",