@ac-kit/format-cron 0.1.0
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/LICENSE +28 -0
- package/README.md +37 -0
- package/dist/ast.d.ts +31 -0
- package/dist/ast.d.ts.map +1 -0
- package/dist/ast.js +2 -0
- package/dist/ast.js.map +1 -0
- package/dist/codec.d.ts +51 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +104 -0
- package/dist/codec.js.map +1 -0
- package/dist/field-spec.d.ts +13 -0
- package/dist/field-spec.d.ts.map +1 -0
- package/dist/field-spec.js +44 -0
- package/dist/field-spec.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/lexer.d.ts +12 -0
- package/dist/lexer.d.ts.map +1 -0
- package/dist/lexer.js +75 -0
- package/dist/lexer.js.map +1 -0
- package/dist/parser.d.ts +15 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +105 -0
- package/dist/parser.js.map +1 -0
- package/dist/printer.d.ts +6 -0
- package/dist/printer.d.ts.map +1 -0
- package/dist/printer.js +29 -0
- package/dist/printer.js.map +1 -0
- package/dist/token.d.ts +16 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +11 -0
- package/dist/token.js.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Anthony Champagne and contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @ac-kit/format-cron
|
|
2
|
+
|
|
3
|
+
A cron expression lexer, parser, printer, and scheduling codec.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import {
|
|
7
|
+
parseCron,
|
|
8
|
+
printCron,
|
|
9
|
+
cronMatches,
|
|
10
|
+
nextRun,
|
|
11
|
+
} from "@ac-kit/format-cron";
|
|
12
|
+
|
|
13
|
+
const schedule = parseCron("*/15 9-17 * * MON-FRI");
|
|
14
|
+
|
|
15
|
+
printCron(schedule); // "*/15 9-17 * * 1-5"
|
|
16
|
+
|
|
17
|
+
cronMatches(schedule, new Date()); // true/false
|
|
18
|
+
|
|
19
|
+
nextRun(schedule, new Date()); // next matching Date
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Supported field syntax: `*`, `*/step`, `value`, `value-value`,
|
|
23
|
+
`value-value/step`, `value/step` (shorthand for `value-max/step`), and
|
|
24
|
+
comma-separated lists of the above. Month and day-of-week names (`JAN`–`DEC`,
|
|
25
|
+
`SUN`–`SAT`, case-insensitive) are accepted where numbers are.
|
|
26
|
+
|
|
27
|
+
Out of scope: seconds and year fields, and the Quartz-style `L`, `W` and `#`
|
|
28
|
+
extensions. This parses the five-field Vixie-cron dialect that crontab itself
|
|
29
|
+
accepts, not a superset one particular scheduler added.
|
|
30
|
+
|
|
31
|
+
When both day-of-month and day-of-week are restricted (neither is `*`), a date
|
|
32
|
+
matches if it satisfies _either_ field, per standard Vixie-cron semantics.
|
|
33
|
+
`nextRun` reads and returns dates in local time.
|
|
34
|
+
|
|
35
|
+
See the
|
|
36
|
+
[generated API docs](https://anthochamp.github.io/node-essentials/api/format-cron/)
|
|
37
|
+
for the full reference.
|
package/dist/ast.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Which of the five standard cron fields a node belongs to. */
|
|
2
|
+
export type CronFieldKind = "minute" | "hour" | "dayOfMonth" | "month" | "dayOfWeek";
|
|
3
|
+
/** A single explicit value, e.g. `5`. */
|
|
4
|
+
export interface CronValue {
|
|
5
|
+
readonly kind: "value";
|
|
6
|
+
readonly value: number;
|
|
7
|
+
}
|
|
8
|
+
/** An inclusive range, optionally stepped, e.g. `1-5` or `1-10/2`. */
|
|
9
|
+
export interface CronRange {
|
|
10
|
+
readonly kind: "range";
|
|
11
|
+
readonly from: number;
|
|
12
|
+
readonly to: number;
|
|
13
|
+
readonly step?: number;
|
|
14
|
+
}
|
|
15
|
+
/** The full field range (`*`), optionally stepped, e.g. `*` or `*\/3`. */
|
|
16
|
+
export interface CronWildcard {
|
|
17
|
+
readonly kind: "wildcard";
|
|
18
|
+
readonly step?: number;
|
|
19
|
+
}
|
|
20
|
+
export type CronFieldItem = CronValue | CronRange | CronWildcard;
|
|
21
|
+
/** A comma-separated list of items — the AST for one cron field. */
|
|
22
|
+
export type CronField = readonly CronFieldItem[];
|
|
23
|
+
/** The AST for a full 5-field cron expression. */
|
|
24
|
+
export interface CronSchedule {
|
|
25
|
+
readonly minute: CronField;
|
|
26
|
+
readonly hour: CronField;
|
|
27
|
+
readonly dayOfMonth: CronField;
|
|
28
|
+
readonly month: CronField;
|
|
29
|
+
readonly dayOfWeek: CronField;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,MAAM,aAAa,GACtB,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,OAAO,GACP,WAAW,CAAC;AAEf,yCAAyC;AACzC,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,sEAAsE;AACtE,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,0EAA0E;AAC1E,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC;AAEjE,oEAAoE;AACpE,MAAM,MAAM,SAAS,GAAG,SAAS,aAAa,EAAE,CAAC;AAEjD,kDAAkD;AAClD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC9B"}
|
package/dist/ast.js
ADDED
package/dist/ast.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":""}
|
package/dist/codec.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CronSchedule } from "./ast.js";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link CronSchedule}, pre-expanded into per-field membership sets.
|
|
4
|
+
*
|
|
5
|
+
* Expanding is O(field range); building it once and reusing it is what keeps
|
|
6
|
+
* {@link nextRun}'s per-minute search O(1) per candidate instead of re-expanding
|
|
7
|
+
* all five fields on every minute it tries.
|
|
8
|
+
*/
|
|
9
|
+
export interface ExpandedCronSchedule {
|
|
10
|
+
readonly minuteSet: ReadonlySet<number>;
|
|
11
|
+
readonly hourSet: ReadonlySet<number>;
|
|
12
|
+
readonly dayOfMonthSet: ReadonlySet<number>;
|
|
13
|
+
readonly monthSet: ReadonlySet<number>;
|
|
14
|
+
readonly dayOfWeekSet: ReadonlySet<number>;
|
|
15
|
+
readonly dayOfMonthRestricted: boolean;
|
|
16
|
+
readonly dayOfWeekRestricted: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Pre-expands `schedule` for repeated matching — see
|
|
20
|
+
* {@link ExpandedCronSchedule}.
|
|
21
|
+
*/
|
|
22
|
+
export declare function expandSchedule(schedule: CronSchedule): ExpandedCronSchedule;
|
|
23
|
+
/**
|
|
24
|
+
* Whether `date` (read in local time) matches an
|
|
25
|
+
* already-{@link expandSchedule}d schedule.
|
|
26
|
+
*
|
|
27
|
+
* When both day-of-month and day-of-week are restricted (not `*`), a date
|
|
28
|
+
* matches if it satisfies _either_ field — standard Vixie-cron semantics, not a
|
|
29
|
+
* plain AND of all five fields.
|
|
30
|
+
*/
|
|
31
|
+
export declare function matchesExpanded(expanded: ExpandedCronSchedule, date: Date): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether `date` (read in local time) matches `schedule`. See
|
|
34
|
+
* {@link matchesExpanded}.
|
|
35
|
+
*/
|
|
36
|
+
export declare function cronMatches(schedule: CronSchedule, date: Date): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Upper bound on how far `nextRun` searches before giving up (~4 years of
|
|
39
|
+
* minutes).
|
|
40
|
+
*/
|
|
41
|
+
export declare const MAX_NEXT_RUN_SEARCH_MINUTES: number;
|
|
42
|
+
/**
|
|
43
|
+
* Finds the next minute (strictly after `from`, read/returned in local time)
|
|
44
|
+
* that matches `schedule`.
|
|
45
|
+
*
|
|
46
|
+
* @throws {Error} If no match is found within
|
|
47
|
+
* {@link MAX_NEXT_RUN_SEARCH_MINUTES} (e.g. `31` for a dayOfMonth in February
|
|
48
|
+
* only).
|
|
49
|
+
*/
|
|
50
|
+
export declare function nextRun(schedule: CronSchedule, from: Date): Date;
|
|
51
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,YAAY,EAAE,MAAM,UAAU,CAAC;AAwCxD;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CAa3E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,QAAQ,EAAE,oBAAoB,EAC9B,IAAI,EAAE,IAAI,GACR,OAAO,CAoBT;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAEvE;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,QAAoB,CAAC;AAE7D;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAahE"}
|
package/dist/codec.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { CRON_FIELD_SPECS } from "./field-spec.js";
|
|
2
|
+
function isWildcardOnly(field) {
|
|
3
|
+
return (field.length === 1 &&
|
|
4
|
+
field[0].kind === "wildcard" &&
|
|
5
|
+
field[0].step === undefined);
|
|
6
|
+
}
|
|
7
|
+
function expandField(field, spec) {
|
|
8
|
+
const values = new Set();
|
|
9
|
+
for (const item of field) {
|
|
10
|
+
switch (item.kind) {
|
|
11
|
+
case "wildcard": {
|
|
12
|
+
const step = item.step ?? 1;
|
|
13
|
+
for (let value = spec.min; value <= spec.max; value += step) {
|
|
14
|
+
values.add(value);
|
|
15
|
+
}
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
case "value":
|
|
19
|
+
values.add(item.value);
|
|
20
|
+
break;
|
|
21
|
+
case "range": {
|
|
22
|
+
const step = item.step ?? 1;
|
|
23
|
+
for (let value = item.from; value <= item.to; value += step) {
|
|
24
|
+
values.add(value);
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return values;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Pre-expands `schedule` for repeated matching — see
|
|
34
|
+
* {@link ExpandedCronSchedule}.
|
|
35
|
+
*/
|
|
36
|
+
export function expandSchedule(schedule) {
|
|
37
|
+
return {
|
|
38
|
+
minuteSet: expandField(schedule.minute, CRON_FIELD_SPECS.minute),
|
|
39
|
+
hourSet: expandField(schedule.hour, CRON_FIELD_SPECS.hour),
|
|
40
|
+
dayOfMonthSet: expandField(schedule.dayOfMonth, CRON_FIELD_SPECS.dayOfMonth),
|
|
41
|
+
monthSet: expandField(schedule.month, CRON_FIELD_SPECS.month),
|
|
42
|
+
dayOfWeekSet: expandField(schedule.dayOfWeek, CRON_FIELD_SPECS.dayOfWeek),
|
|
43
|
+
dayOfMonthRestricted: !isWildcardOnly(schedule.dayOfMonth),
|
|
44
|
+
dayOfWeekRestricted: !isWildcardOnly(schedule.dayOfWeek),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether `date` (read in local time) matches an
|
|
49
|
+
* already-{@link expandSchedule}d schedule.
|
|
50
|
+
*
|
|
51
|
+
* When both day-of-month and day-of-week are restricted (not `*`), a date
|
|
52
|
+
* matches if it satisfies _either_ field — standard Vixie-cron semantics, not a
|
|
53
|
+
* plain AND of all five fields.
|
|
54
|
+
*/
|
|
55
|
+
export function matchesExpanded(expanded, date) {
|
|
56
|
+
if (!expanded.minuteSet.has(date.getMinutes()) ||
|
|
57
|
+
!expanded.hourSet.has(date.getHours()) ||
|
|
58
|
+
!expanded.monthSet.has(date.getMonth() + 1)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
const { dayOfMonthRestricted, dayOfWeekRestricted } = expanded;
|
|
62
|
+
if (!dayOfMonthRestricted && !dayOfWeekRestricted)
|
|
63
|
+
return true;
|
|
64
|
+
if (dayOfMonthRestricted && dayOfWeekRestricted) {
|
|
65
|
+
return (expanded.dayOfMonthSet.has(date.getDate()) ||
|
|
66
|
+
expanded.dayOfWeekSet.has(date.getDay()));
|
|
67
|
+
}
|
|
68
|
+
return dayOfMonthRestricted
|
|
69
|
+
? expanded.dayOfMonthSet.has(date.getDate())
|
|
70
|
+
: expanded.dayOfWeekSet.has(date.getDay());
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether `date` (read in local time) matches `schedule`. See
|
|
74
|
+
* {@link matchesExpanded}.
|
|
75
|
+
*/
|
|
76
|
+
export function cronMatches(schedule, date) {
|
|
77
|
+
return matchesExpanded(expandSchedule(schedule), date);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Upper bound on how far `nextRun` searches before giving up (~4 years of
|
|
81
|
+
* minutes).
|
|
82
|
+
*/
|
|
83
|
+
export const MAX_NEXT_RUN_SEARCH_MINUTES = 4 * 365 * 24 * 60;
|
|
84
|
+
/**
|
|
85
|
+
* Finds the next minute (strictly after `from`, read/returned in local time)
|
|
86
|
+
* that matches `schedule`.
|
|
87
|
+
*
|
|
88
|
+
* @throws {Error} If no match is found within
|
|
89
|
+
* {@link MAX_NEXT_RUN_SEARCH_MINUTES} (e.g. `31` for a dayOfMonth in February
|
|
90
|
+
* only).
|
|
91
|
+
*/
|
|
92
|
+
export function nextRun(schedule, from) {
|
|
93
|
+
const expanded = expandSchedule(schedule);
|
|
94
|
+
const candidate = new Date(from.getTime());
|
|
95
|
+
candidate.setSeconds(0, 0);
|
|
96
|
+
candidate.setMinutes(candidate.getMinutes() + 1);
|
|
97
|
+
for (let minute = 0; minute < MAX_NEXT_RUN_SEARCH_MINUTES; minute++) {
|
|
98
|
+
if (matchesExpanded(expanded, candidate))
|
|
99
|
+
return candidate;
|
|
100
|
+
candidate.setMinutes(candidate.getMinutes() + 1);
|
|
101
|
+
}
|
|
102
|
+
throw new Error(`nextRun: no matching run found within ${MAX_NEXT_RUN_SEARCH_MINUTES} minutes`);
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;AAEvE,SAAS,cAAc,CAAC,KAAgB;IACvC,OAAO,CACN,KAAK,CAAC,MAAM,KAAK,CAAC;QAClB,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,KAAK,UAAU;QAC7B,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,KAAK,SAAS,CAC5B,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CACnB,KAAgB,EAChB,IAAmB;IAEnB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,UAAU,EAAE,CAAC;gBACjB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;gBAC5B,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;oBAC7D,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC;gBACD,MAAM;YACP,CAAC;YACD,KAAK,OAAO;gBACX,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,MAAM;YACP,KAAK,OAAO,EAAE,CAAC;gBACd,MAAM,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AG,CAAC,CAAC,CAAC;IAEjD,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,2BAA2B,EAAE,MAAM,EAAE,EAAE,CAAC;QACrE,IAAI,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QAC3D,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,IAAI,KAAK,CACd,yCAAyC,2BAA2B,UAAU,CAC9E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CronFieldKind } from "./ast.js";
|
|
2
|
+
/** Bounds and optional name table for one cron field. */
|
|
3
|
+
export interface CronFieldSpec {
|
|
4
|
+
readonly min: number;
|
|
5
|
+
readonly max: number;
|
|
6
|
+
readonly names?: ReadonlyMap<string, number>;
|
|
7
|
+
/** Whether `max + 1` (e.g. day-of-week `7`) is accepted as an alias for `min`. */
|
|
8
|
+
readonly wrapMaxPlusOneToMin?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const CRON_FIELD_SPECS: Readonly<Record<CronFieldKind, CronFieldSpec>>;
|
|
11
|
+
/** Order the five fields appear in a cron expression. */
|
|
12
|
+
export declare const CRON_FIELD_ORDER: readonly CronFieldKind[];
|
|
13
|
+
//# sourceMappingURL=field-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-spec.d.ts","sourceRoot":"","sources":["../src/field-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,kFAAkF;IAClF,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACvC;AA2BD,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAY1E,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,gBAAgB,EAAE,SAAS,aAAa,EAMpD,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const MONTH_NAMES = new Map([
|
|
2
|
+
["JAN", 1],
|
|
3
|
+
["FEB", 2],
|
|
4
|
+
["MAR", 3],
|
|
5
|
+
["APR", 4],
|
|
6
|
+
["MAY", 5],
|
|
7
|
+
["JUN", 6],
|
|
8
|
+
["JUL", 7],
|
|
9
|
+
["AUG", 8],
|
|
10
|
+
["SEP", 9],
|
|
11
|
+
["OCT", 10],
|
|
12
|
+
["NOV", 11],
|
|
13
|
+
["DEC", 12],
|
|
14
|
+
]);
|
|
15
|
+
const DAY_OF_WEEK_NAMES = new Map([
|
|
16
|
+
["SUN", 0],
|
|
17
|
+
["MON", 1],
|
|
18
|
+
["TUE", 2],
|
|
19
|
+
["WED", 3],
|
|
20
|
+
["THU", 4],
|
|
21
|
+
["FRI", 5],
|
|
22
|
+
["SAT", 6],
|
|
23
|
+
]);
|
|
24
|
+
export const CRON_FIELD_SPECS = {
|
|
25
|
+
minute: { min: 0, max: 59 },
|
|
26
|
+
hour: { min: 0, max: 23 },
|
|
27
|
+
dayOfMonth: { min: 1, max: 31 },
|
|
28
|
+
month: { min: 1, max: 12, names: MONTH_NAMES },
|
|
29
|
+
dayOfWeek: {
|
|
30
|
+
min: 0,
|
|
31
|
+
max: 6,
|
|
32
|
+
names: DAY_OF_WEEK_NAMES,
|
|
33
|
+
wrapMaxPlusOneToMin: true,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
/** Order the five fields appear in a cron expression. */
|
|
37
|
+
export const CRON_FIELD_ORDER = [
|
|
38
|
+
"minute",
|
|
39
|
+
"hour",
|
|
40
|
+
"dayOfMonth",
|
|
41
|
+
"month",
|
|
42
|
+
"dayOfWeek",
|
|
43
|
+
];
|
|
44
|
+
//# sourceMappingURL=field-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-spec.js","sourceRoot":"","sources":["../src/field-spec.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,GAAgC,IAAI,GAAG,CAAC;IACxD,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,EAAE,CAAC;IACX,CAAC,KAAK,EAAE,EAAE,CAAC;IACX,CAAC,KAAK,EAAE,EAAE,CAAC;CACX,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAgC,IAAI,GAAG,CAAC;IAC9D,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;IACV,CAAC,KAAK,EAAE,CAAC,CAAC;CACV,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAC5B;IACC,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAC3B,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IACzB,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAC/B,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE;IAC9C,SAAS,EAAE;QACV,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,CAAC;QACN,KAAK,EAAE,iBAAiB;QACxB,mBAAmB,EAAE,IAAI;KACzB;CACD,CAAC;AAEH,yDAAyD;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAA6B;IACzD,QAAQ;IACR,MAAM;IACN,YAAY;IACZ,OAAO;IACP,WAAW;CACX,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/lexer.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Span } from "@ac-kit/core";
|
|
2
|
+
import { Token } from "./token.js";
|
|
3
|
+
export declare class CronLexerError extends Error {
|
|
4
|
+
readonly span: Span;
|
|
5
|
+
constructor(message: string, span: Span);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Tokenizes a single cron field (one of the five whitespace-separated segments
|
|
9
|
+
* of a cron expression — fields never contain whitespace themselves).
|
|
10
|
+
*/
|
|
11
|
+
export declare function lexCronField(field: string): Token[];
|
|
12
|
+
//# sourceMappingURL=lexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexer.d.ts","sourceRoot":"","sources":["../src/lexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAErE,OAAO,EAAE,KAAK,EAAa,MAAM,YAAY,CAAC;AAE9C,qBAAa,cAAe,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,YAAY,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAItC;CACD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,CA8DnD"}
|
package/dist/lexer.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { isAsciiAlpha, isAsciiDigit } from "@ac-kit/core";
|
|
2
|
+
import { TokenKind } from "./token.js";
|
|
3
|
+
export class CronLexerError extends Error {
|
|
4
|
+
span;
|
|
5
|
+
constructor(message, span) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "CronLexerError";
|
|
8
|
+
this.span = span;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Tokenizes a single cron field (one of the five whitespace-separated segments
|
|
13
|
+
* of a cron expression — fields never contain whitespace themselves).
|
|
14
|
+
*/
|
|
15
|
+
export function lexCronField(field) {
|
|
16
|
+
const tokens = [];
|
|
17
|
+
let pos = 0;
|
|
18
|
+
while (pos < field.length) {
|
|
19
|
+
const cc = field.charCodeAt(pos);
|
|
20
|
+
const start = pos;
|
|
21
|
+
if (isAsciiDigit(cc)) {
|
|
22
|
+
while (pos < field.length && isAsciiDigit(field.charCodeAt(pos)))
|
|
23
|
+
pos++;
|
|
24
|
+
tokens.push({
|
|
25
|
+
kind: TokenKind.Number,
|
|
26
|
+
text: field.slice(start, pos),
|
|
27
|
+
span: { start, end: pos },
|
|
28
|
+
});
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (isAsciiAlpha(cc)) {
|
|
32
|
+
while (pos < field.length && isAsciiAlpha(field.charCodeAt(pos)))
|
|
33
|
+
pos++;
|
|
34
|
+
tokens.push({
|
|
35
|
+
kind: TokenKind.Name,
|
|
36
|
+
text: field.slice(start, pos),
|
|
37
|
+
span: { start, end: pos },
|
|
38
|
+
});
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const char = field[pos];
|
|
42
|
+
const single = (kind) => ({
|
|
43
|
+
kind,
|
|
44
|
+
text: char,
|
|
45
|
+
span: { start, end: start + 1 },
|
|
46
|
+
});
|
|
47
|
+
switch (char) {
|
|
48
|
+
case "*":
|
|
49
|
+
tokens.push(single(TokenKind.Asterisk));
|
|
50
|
+
break;
|
|
51
|
+
case "-":
|
|
52
|
+
tokens.push(single(TokenKind.Hyphen));
|
|
53
|
+
break;
|
|
54
|
+
case "/":
|
|
55
|
+
tokens.push(single(TokenKind.Slash));
|
|
56
|
+
break;
|
|
57
|
+
case ",":
|
|
58
|
+
tokens.push(single(TokenKind.Comma));
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
throw new CronLexerError(`Unexpected character '${char}'`, {
|
|
62
|
+
start,
|
|
63
|
+
end: start + 1,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
pos++;
|
|
67
|
+
}
|
|
68
|
+
tokens.push({
|
|
69
|
+
kind: TokenKind.EndOfField,
|
|
70
|
+
text: "",
|
|
71
|
+
span: { start: pos, end: pos },
|
|
72
|
+
});
|
|
73
|
+
return tokens;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=lexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexer.js","sourceRoot":"","s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,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;KAC9B,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC"}
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Span } from "@ac-kit/core";
|
|
2
|
+
import type { CronField, CronSchedule } from "./ast.js";
|
|
3
|
+
import { type CronFieldSpec } from "./field-spec.js";
|
|
4
|
+
export declare class CronParseError extends Error {
|
|
5
|
+
readonly span: Span;
|
|
6
|
+
constructor(message: string, span: Span);
|
|
7
|
+
}
|
|
8
|
+
/** Parses one cron field (already split out of the full expression). */
|
|
9
|
+
export declare function parseCronField(field: string, spec: CronFieldSpec): CronField;
|
|
10
|
+
/**
|
|
11
|
+
* Parses a full 5-field cron expression (`minute hour dayOfMonth month
|
|
12
|
+
* dayOfWeek`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseCron(source: string): CronSchedule;
|
|
15
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAiB,YAAY,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAGN,KAAK,aAAa,EAClB,MAAM,iBAAiB,CAAC;AAIzB,qBAAa,cAAe,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,YAAY,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAItC;CACD;AA+BD,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,SAAS,CAoE5E;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAetD"}
|
package/dist/parser.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { CRON_FIELD_ORDER, CRON_FIELD_SPECS, } from "./field-spec.js";
|
|
2
|
+
import { lexCronField } from "./lexer.js";
|
|
3
|
+
import { TokenKind } from "./token.js";
|
|
4
|
+
export class CronParseError extends Error {
|
|
5
|
+
span;
|
|
6
|
+
constructor(message, span) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "CronParseError";
|
|
9
|
+
this.span = span;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function resolveValue(token, spec) {
|
|
13
|
+
let value;
|
|
14
|
+
if (token.kind === TokenKind.Number) {
|
|
15
|
+
value = Number.parseInt(token.text, 10);
|
|
16
|
+
}
|
|
17
|
+
else if (token.kind === TokenKind.Name) {
|
|
18
|
+
const resolved = spec.names?.get(token.text.toUpperCase());
|
|
19
|
+
if (resolved === undefined) {
|
|
20
|
+
throw new CronParseError(`Unknown name '${token.text}'`, token.span);
|
|
21
|
+
}
|
|
22
|
+
value = resolved;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw new CronParseError(`Expected a number or name, got '${token.text}'`, token.span);
|
|
26
|
+
}
|
|
27
|
+
if (spec.wrapMaxPlusOneToMin && value === spec.max + 1) {
|
|
28
|
+
value = spec.min;
|
|
29
|
+
}
|
|
30
|
+
if (value < spec.min || value > spec.max) {
|
|
31
|
+
throw new CronParseError(`Value ${value} out of range [${spec.min}, ${spec.max}]`, token.span);
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
/** Parses one cron field (already split out of the full expression). */
|
|
36
|
+
export function parseCronField(field, spec) {
|
|
37
|
+
const tokens = lexCronField(field);
|
|
38
|
+
let index = 0;
|
|
39
|
+
const peek = () => tokens[index];
|
|
40
|
+
const advance = () => tokens[index++];
|
|
41
|
+
function parseOptionalStep() {
|
|
42
|
+
if (peek().kind !== TokenKind.Slash)
|
|
43
|
+
return undefined;
|
|
44
|
+
advance();
|
|
45
|
+
const token = advance();
|
|
46
|
+
if (token.kind !== TokenKind.Number) {
|
|
47
|
+
throw new CronParseError(`Expected a step number, got '${token.text}'`, token.span);
|
|
48
|
+
}
|
|
49
|
+
const step = Number.parseInt(token.text, 10);
|
|
50
|
+
if (step <= 0) {
|
|
51
|
+
throw new CronParseError(`Step must be positive, got ${step}`, token.span);
|
|
52
|
+
}
|
|
53
|
+
return step;
|
|
54
|
+
}
|
|
55
|
+
function parseItem() {
|
|
56
|
+
if (peek().kind === TokenKind.Asterisk) {
|
|
57
|
+
advance();
|
|
58
|
+
const step = parseOptionalStep();
|
|
59
|
+
return step === undefined
|
|
60
|
+
? { kind: "wildcard" }
|
|
61
|
+
: { kind: "wildcard", step };
|
|
62
|
+
}
|
|
63
|
+
const from = resolveValue(advance(), spec);
|
|
64
|
+
if (peek().kind === TokenKind.Hyphen) {
|
|
65
|
+
advance();
|
|
66
|
+
const to = resolveValue(advance(), spec);
|
|
67
|
+
const step = parseOptionalStep();
|
|
68
|
+
return step === undefined
|
|
69
|
+
? { kind: "range", from, to }
|
|
70
|
+
: { kind: "range", from, to, step };
|
|
71
|
+
}
|
|
72
|
+
const step = parseOptionalStep();
|
|
73
|
+
if (step !== undefined) {
|
|
74
|
+
// `value/step` is shorthand for "from value through the field's
|
|
75
|
+
// maximum, stepped" (Vixie cron semantics).
|
|
76
|
+
return { kind: "range", from, to: spec.max, step };
|
|
77
|
+
}
|
|
78
|
+
return { kind: "value", value: from };
|
|
79
|
+
}
|
|
80
|
+
const items = [parseItem()];
|
|
81
|
+
while (peek().kind === TokenKind.Comma) {
|
|
82
|
+
advance();
|
|
83
|
+
items.push(parseItem());
|
|
84
|
+
}
|
|
85
|
+
if (peek().kind !== TokenKind.EndOfField) {
|
|
86
|
+
throw new CronParseError(`Unexpected trailing input '${peek().text}'`, peek().span);
|
|
87
|
+
}
|
|
88
|
+
return items;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Parses a full 5-field cron expression (`minute hour dayOfMonth month
|
|
92
|
+
* dayOfWeek`).
|
|
93
|
+
*/
|
|
94
|
+
export function parseCron(source) {
|
|
95
|
+
const fields = source.trim().split(/\s+/);
|
|
96
|
+
if (fields.length !== 5) {
|
|
97
|
+
throw new CronParseError(`Expected 5 fields, got ${fields.length}`, {
|
|
98
|
+
start: 0,
|
|
99
|
+
end: source.length,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const [minute, hour, dayOfMonth, month, dayOfWeek] = CRON_FIELD_ORDER.map((kind, position) => parseCronField(fields[position], CRON_FIELD_SPECS[kind]));
|
|
103
|
+
return { minute, hour, dayOfMonth, month, dayOfWeek };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAS,SAAS,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC/B,IAAI,CAAO;IACpB,YAAY,OAAe,EAAE,IAAU;QACtC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAED,SAAS,YAAY,CAAC,KAAY,EAAE,IAAmB;IACtD,IAAI,KAAa,CAAC;IAClB,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;QACrC,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACzC,CAAC;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,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AC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG,gBAAgB,CAAC,GAAG,CACxE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAClB,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC,CACC,CAAC;IAE7D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CronField, CronSchedule } from "./ast.js";
|
|
2
|
+
/** Prints one cron field in canonical (numeric, as-parsed order) form. */
|
|
3
|
+
export declare function printCronField(field: CronField): string;
|
|
4
|
+
/** Prints a full cron expression in canonical form. */
|
|
5
|
+
export declare function printCron(schedule: CronSchedule): string;
|
|
6
|
+
//# sourceMappingURL=printer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,YAAY,EAAE,MAAM,UAAU,CAAC;AAevE,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAEvD;AAED,uDAAuD;AACvD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAUxD"}
|
package/dist/printer.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function printItem(item) {
|
|
2
|
+
switch (item.kind) {
|
|
3
|
+
case "wildcard":
|
|
4
|
+
return item.step === undefined ? "*" : `*/${item.step}`;
|
|
5
|
+
case "value":
|
|
6
|
+
return String(item.value);
|
|
7
|
+
case "range":
|
|
8
|
+
return item.step === undefined
|
|
9
|
+
? `${item.from}-${item.to}`
|
|
10
|
+
: `${item.from}-${item.to}/${item.step}`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Prints one cron field in canonical (numeric, as-parsed order) form. */
|
|
14
|
+
export function printCronField(field) {
|
|
15
|
+
return field.map(printItem).join(",");
|
|
16
|
+
}
|
|
17
|
+
/** Prints a full cron expression in canonical form. */
|
|
18
|
+
export function printCron(schedule) {
|
|
19
|
+
return [
|
|
20
|
+
schedule.minute,
|
|
21
|
+
schedule.hour,
|
|
22
|
+
schedule.dayOfMonth,
|
|
23
|
+
schedule.month,
|
|
24
|
+
schedule.dayOfWeek,
|
|
25
|
+
]
|
|
26
|
+
.map(printCronField)
|
|
27
|
+
.join(" ");
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=printer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"printer.js","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAEA,SAAS,SAAS,CAAC,IAAmB;IACrC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,UAAU;YACd,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QACzD,KAAK,OAAO;YACX,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,KAAK,OAAO;YACX,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS;gBAC7B,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE;gBAC3B,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5C,CAAC;AACF,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,cAAc,CAAC,KAAgB;IAC9C,OAAO,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,SAAS,CAAC,QAAsB;IAC/C,OAAO;QACN,QAAQ,CAAC,MAAM;QACf,QAAQ,CAAC,IAAI;QACb,QAAQ,CAAC,UAAU;QACnB,QAAQ,CAAC,KAAK;QACd,QAAQ,CAAC,SAAS;KAClB;SACC,GAAG,CAAC,cAAc,CAAC;SACnB,IAAI,CAAC,GAAG,CAAC,CAAC;AACb,CAAC"}
|
package/dist/token.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Span } from "@ac-kit/core";
|
|
2
|
+
export declare enum TokenKind {
|
|
3
|
+
Number = 0,
|
|
4
|
+
Name = 1,
|
|
5
|
+
Asterisk = 2,
|
|
6
|
+
Hyphen = 3,
|
|
7
|
+
Slash = 4,
|
|
8
|
+
Comma = 5,
|
|
9
|
+
EndOfField = 6
|
|
10
|
+
}
|
|
11
|
+
export interface Token {
|
|
12
|
+
readonly kind: TokenKind;
|
|
13
|
+
readonly text: string;
|
|
14
|
+
readonly span: Span;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,oBAAY,SAAS;IACpB,MAAM,IAAA;IACN,IAAI,IAAA;IACJ,QAAQ,IAAA;IACR,MAAM,IAAA;IACN,KAAK,IAAA;IACL,KAAK,IAAA;IACL,UAAU,IAAA;CACV;AAED,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACpB"}
|
package/dist/token.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var TokenKind;
|
|
2
|
+
(function (TokenKind) {
|
|
3
|
+
TokenKind[TokenKind["Number"] = 0] = "Number";
|
|
4
|
+
TokenKind[TokenKind["Name"] = 1] = "Name";
|
|
5
|
+
TokenKind[TokenKind["Asterisk"] = 2] = "Asterisk";
|
|
6
|
+
TokenKind[TokenKind["Hyphen"] = 3] = "Hyphen";
|
|
7
|
+
TokenKind[TokenKind["Slash"] = 4] = "Slash";
|
|
8
|
+
TokenKind[TokenKind["Comma"] = 5] = "Comma";
|
|
9
|
+
TokenKind[TokenKind["EndOfField"] = 6] = "EndOfField";
|
|
10
|
+
})(TokenKind || (TokenKind = {}));
|
|
11
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,SAQX;AARD,WAAY,SAAS;IACpB,6CAAM,CAAA;IACN,yCAAI,CAAA;IACJ,iDAAQ,CAAA;IACR,6CAAM,CAAA;IACN,2CAAK,CAAA;IACL,2CAAK,CAAA;IACL,qDAAU,CAAA;AACX,CAAC,EARW,SAAS,KAAT,SAAS,QAQpB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ac-kit/format-cron",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Cron expressions: lexer, parser, printer and a scheduling codec.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cron",
|
|
7
|
+
"crontab",
|
|
8
|
+
"parser",
|
|
9
|
+
"schedule"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://anthochamp.github.io/node-essentials/api/format-cron/",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/anthochamp/node-essentials/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "BSD-3-Clause",
|
|
16
|
+
"author": "Anthony Champagne <dev@anthonychampagne.fr>",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/anthochamp/node-essentials.git",
|
|
20
|
+
"directory": "packages/format-cron"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"compile": "tsc -p ./tsconfig.build.json -outDir dist",
|
|
40
|
+
"compile:check": "tsc -noEmit -p ./tsconfig.json",
|
|
41
|
+
"clean": "rimraf dist",
|
|
42
|
+
"build": "yarn clean && yarn compile",
|
|
43
|
+
"test": "yarn run -T vitest run",
|
|
44
|
+
"prepack": "yarn build"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@ac-kit/core": "^0.1.0",
|
|
48
|
+
"@types/node": "^26.5.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@ac-kit/tsconfig": "0.1.0",
|
|
52
|
+
"@ac-kit/typedoc-config": "0.1.0",
|
|
53
|
+
"@ac-kit/vitest-config": "0.1.0",
|
|
54
|
+
"@typescript/native": "typescript@7.0.2",
|
|
55
|
+
"rimraf": "6.1.3",
|
|
56
|
+
"typedoc": "0.28.20",
|
|
57
|
+
"typescript": "@typescript/typescript6@6.0.2"
|
|
58
|
+
},
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=24"
|
|
61
|
+
}
|
|
62
|
+
}
|