@namzu/sdk 44.3.0 → 45.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/CHANGELOG.md +94 -0
- package/dist/authorization/command-line.d.ts +66 -19
- package/dist/authorization/command-line.d.ts.map +1 -1
- package/dist/authorization/command-line.js +130 -270
- package/dist/authorization/command-line.js.map +1 -1
- package/dist/authorization/gate.d.ts +7 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +13 -3
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/rules.d.ts +10 -1
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +55 -8
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +152 -0
- package/dist/authorization/shell-lexer.d.ts.map +1 -0
- package/dist/authorization/shell-lexer.js +2156 -0
- package/dist/authorization/shell-lexer.js.map +1 -0
- package/dist/authorization/skill-grant.d.ts +182 -0
- package/dist/authorization/skill-grant.d.ts.map +1 -0
- package/dist/authorization/skill-grant.js +314 -0
- package/dist/authorization/skill-grant.js.map +1 -0
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +2 -0
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +1 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/directory/types.d.ts +2 -0
- package/dist/directory/types.d.ts.map +1 -1
- package/dist/directory/types.js.map +1 -1
- package/dist/manager/resident/outbox.d.ts +4 -4
- package/dist/persona/assembler.d.ts.map +1 -1
- package/dist/persona/assembler.js +5 -2
- package/dist/persona/assembler.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +1 -0
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/public-runtime.d.ts +5 -1
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +15 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +4 -0
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +12 -1
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +9 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +2 -2
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +6 -2
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/declined.d.ts +12 -0
- package/dist/runtime/query/declined.d.ts.map +1 -0
- package/dist/runtime/query/declined.js +12 -0
- package/dist/runtime/query/declined.js.map +1 -0
- package/dist/runtime/query/executor.d.ts +36 -40
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +95 -53
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +8 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +13 -0
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +13 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/handoff.d.ts +22 -0
- package/dist/runtime/query/iteration/phases/handoff.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/handoff.js +65 -0
- package/dist/runtime/query/iteration/phases/handoff.js.map +1 -0
- package/dist/runtime/query/iteration/phases/index.d.ts +1 -0
- package/dist/runtime/query/iteration/phases/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/index.js +1 -0
- package/dist/runtime/query/iteration/phases/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +56 -3
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +3 -2
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +11 -0
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +36 -3
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +3 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +1 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/schedules/cron.d.ts +21 -0
- package/dist/schedules/cron.d.ts.map +1 -0
- package/dist/schedules/cron.js +167 -0
- package/dist/schedules/cron.js.map +1 -0
- package/dist/schedules/describe.d.ts +14 -0
- package/dist/schedules/describe.d.ts.map +1 -0
- package/dist/schedules/describe.js +133 -0
- package/dist/schedules/describe.js.map +1 -0
- package/dist/schedules/errors.d.ts +11 -0
- package/dist/schedules/errors.d.ts.map +1 -0
- package/dist/schedules/errors.js +15 -0
- package/dist/schedules/errors.js.map +1 -0
- package/dist/schedules/evaluate.d.ts +35 -0
- package/dist/schedules/evaluate.d.ts.map +1 -0
- package/dist/schedules/evaluate.js +158 -0
- package/dist/schedules/evaluate.js.map +1 -0
- package/dist/schedules/index.d.ts +11 -0
- package/dist/schedules/index.d.ts.map +1 -0
- package/dist/schedules/index.js +8 -0
- package/dist/schedules/index.js.map +1 -0
- package/dist/schedules/next-fire.d.ts +50 -0
- package/dist/schedules/next-fire.d.ts.map +1 -0
- package/dist/schedules/next-fire.js +250 -0
- package/dist/schedules/next-fire.js.map +1 -0
- package/dist/schedules/spec.d.ts +30 -0
- package/dist/schedules/spec.d.ts.map +1 -0
- package/dist/schedules/spec.js +169 -0
- package/dist/schedules/spec.js.map +1 -0
- package/dist/schedules/types.d.ts +144 -0
- package/dist/schedules/types.d.ts.map +1 -0
- package/dist/schedules/types.js +11 -0
- package/dist/schedules/types.js.map +1 -0
- package/dist/schedules/tz.d.ts +44 -0
- package/dist/schedules/tz.d.ts.map +1 -0
- package/dist/schedules/tz.js +141 -0
- package/dist/schedules/tz.js.map +1 -0
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/loader.d.ts +21 -0
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +51 -1
- package/dist/skills/loader.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +18 -6
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser-url.d.ts +83 -0
- package/dist/tools/builtins/browser-url.d.ts.map +1 -0
- package/dist/tools/builtins/browser-url.js +240 -0
- package/dist/tools/builtins/browser-url.js.map +1 -0
- package/dist/tools/builtins/browser.d.ts +367 -0
- package/dist/tools/builtins/browser.d.ts.map +1 -0
- package/dist/tools/builtins/browser.js +704 -0
- package/dist/tools/builtins/browser.js.map +1 -0
- package/dist/tools/builtins/skill.d.ts +2 -9
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +74 -51
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/command-shell.d.ts +90 -0
- package/dist/tools/command-shell.d.ts.map +1 -0
- package/dist/tools/command-shell.js +129 -0
- package/dist/tools/command-shell.js.map +1 -0
- package/dist/tools/defineTool.d.ts +13 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +30 -1
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/schedules/index.d.ts +5 -0
- package/dist/tools/schedules/index.d.ts.map +1 -0
- package/dist/tools/schedules/index.js +4 -0
- package/dist/tools/schedules/index.js.map +1 -0
- package/dist/tools/schedules/loop-tool.d.ts +14 -0
- package/dist/tools/schedules/loop-tool.d.ts.map +1 -0
- package/dist/tools/schedules/loop-tool.js +81 -0
- package/dist/tools/schedules/loop-tool.js.map +1 -0
- package/dist/tools/schedules/present.d.ts +16 -0
- package/dist/tools/schedules/present.d.ts.map +1 -0
- package/dist/tools/schedules/present.js +69 -0
- package/dist/tools/schedules/present.js.map +1 -0
- package/dist/tools/schedules/prompt-scan.d.ts +17 -0
- package/dist/tools/schedules/prompt-scan.d.ts.map +1 -0
- package/dist/tools/schedules/prompt-scan.js +92 -0
- package/dist/tools/schedules/prompt-scan.js.map +1 -0
- package/dist/tools/schedules/schedule-tool.d.ts +16 -0
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -0
- package/dist/tools/schedules/schedule-tool.js +327 -0
- package/dist/tools/schedules/schedule-tool.js.map +1 -0
- package/dist/tools/schedules/types.d.ts +184 -0
- package/dist/tools/schedules/types.d.ts.map +1 -0
- package/dist/tools/schedules/types.js +11 -0
- package/dist/tools/schedules/types.js.map +1 -0
- package/dist/types/authorization/index.d.ts +86 -9
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +11 -1
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/browser/index.d.ts +280 -0
- package/dist/types/browser/index.d.ts.map +1 -0
- package/dist/types/browser/index.js +12 -0
- package/dist/types/browser/index.js.map +1 -0
- package/dist/types/hitl/index.d.ts +23 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/session/events.d.ts +6 -0
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/session/records.d.ts +23 -0
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +9 -0
- package/dist/types/session/records.js.map +1 -1
- package/dist/types/tool/index.d.ts +108 -5
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/presentation.d.ts +7 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/dist/utils/frontmatter.d.ts +35 -3
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +45 -5
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/id.d.ts +8 -0
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +12 -0
- package/dist/utils/id.js.map +1 -1
- package/package.json +1 -1
- package/src/authorization/command-line.ts +148 -293
- package/src/authorization/gate.ts +22 -2
- package/src/authorization/rules.ts +67 -8
- package/src/authorization/shell-lexer.ts +2349 -0
- package/src/authorization/skill-grant.ts +400 -0
- package/src/bridge/a2a/mapper.ts +2 -0
- package/src/bridge/sse/mapper.ts +1 -0
- package/src/directory/types.ts +2 -0
- package/src/persona/assembler.ts +5 -2
- package/src/prompt/coding-agent-doctrine.ts +1 -0
- package/src/public-runtime.ts +37 -0
- package/src/public-tools.ts +37 -1
- package/src/public-types.ts +57 -0
- package/src/runtime/jobs/registry.ts +19 -11
- package/src/runtime/query/declined.ts +12 -0
- package/src/runtime/query/executor.ts +116 -56
- package/src/runtime/query/index.ts +8 -0
- package/src/runtime/query/iteration/index.ts +13 -0
- package/src/runtime/query/iteration/phases/context.ts +13 -0
- package/src/runtime/query/iteration/phases/handoff.ts +74 -0
- package/src/runtime/query/iteration/phases/index.ts +1 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +55 -3
- package/src/runtime/query/resume-pending.ts +3 -2
- package/src/runtime/query/review-policy.ts +57 -3
- package/src/runtime/query/tooling.ts +4 -0
- package/src/schedules/cron.ts +202 -0
- package/src/schedules/describe.ts +138 -0
- package/src/schedules/errors.ts +15 -0
- package/src/schedules/evaluate.ts +178 -0
- package/src/schedules/index.ts +18 -0
- package/src/schedules/next-fire.ts +257 -0
- package/src/schedules/spec.ts +210 -0
- package/src/schedules/types.ts +163 -0
- package/src/schedules/tz.ts +155 -0
- package/src/skills/index.ts +1 -1
- package/src/skills/loader.ts +59 -1
- package/src/tools/builtins/bash.ts +24 -6
- package/src/tools/builtins/browser-url.ts +251 -0
- package/src/tools/builtins/browser.ts +817 -0
- package/src/tools/builtins/skill.ts +92 -53
- package/src/tools/command-shell.ts +166 -0
- package/src/tools/defineTool.ts +36 -1
- package/src/tools/schedules/index.ts +4 -0
- package/src/tools/schedules/loop-tool.ts +85 -0
- package/src/tools/schedules/present.ts +86 -0
- package/src/tools/schedules/prompt-scan.ts +96 -0
- package/src/tools/schedules/schedule-tool.ts +376 -0
- package/src/tools/schedules/types.ts +197 -0
- package/src/types/authorization/index.ts +60 -2
- package/src/types/browser/index.ts +341 -0
- package/src/types/hitl/index.ts +21 -0
- package/src/types/session/events.ts +6 -0
- package/src/types/session/records.ts +10 -0
- package/src/types/tool/index.ts +109 -5
- package/src/types/tool/presentation.ts +7 -0
- package/src/utils/frontmatter.ts +81 -5
- package/src/utils/id.ts +14 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a spec fires: the next instant, the previous one, and how many fall
|
|
3
|
+
* in a window.
|
|
4
|
+
*
|
|
5
|
+
* Cron is walked a local DAY at a time — never a minute at a time over years
|
|
6
|
+
* — and a day with no DST change is computed arithmetically from one offset.
|
|
7
|
+
* Only a day whose offset changes is examined slot by slot, and that is where
|
|
8
|
+
* cronie's rule is applied:
|
|
9
|
+
*
|
|
10
|
+
* - a fixed-time expression (`30 2 * * *`) whose time falls in a
|
|
11
|
+
* spring-forward gap fires once, at the first instant after the gap;
|
|
12
|
+
* whose time is repeated by a fall-back fires once, at the first of the two;
|
|
13
|
+
* - a wildcard or step expression (`0 * * * *`, `*\/15 * * * *`) fires at
|
|
14
|
+
* every instant whose wall time matches: the repeated hour runs twice and
|
|
15
|
+
* slots inside the gap do not exist.
|
|
16
|
+
*/
|
|
17
|
+
import type { CronExpression, OccurrenceCount, ScheduleSpec } from './types.js';
|
|
18
|
+
/** How far ahead a cron search looks before deciding the expression never fires. */
|
|
19
|
+
export declare const CRON_HORIZON_DAYS: number;
|
|
20
|
+
/**
|
|
21
|
+
* Occurrence counts stop here. Counting a day without a DST change costs one
|
|
22
|
+
* multiplication, so the cap bounds the pathological case (a years-long gap
|
|
23
|
+
* on a per-minute job) rather than the ordinary one.
|
|
24
|
+
*/
|
|
25
|
+
export declare const OCCURRENCE_COUNT_CAP = 100000;
|
|
26
|
+
/**
|
|
27
|
+
* Every instant the expression fires on one local day (`dayWall` is that
|
|
28
|
+
* day's midnight as a wall value), ascending.
|
|
29
|
+
*/
|
|
30
|
+
export declare function cronInstantsOnDay(expr: CronExpression, tz: string, dayWall: number): number[];
|
|
31
|
+
/**
|
|
32
|
+
* The first instant strictly after `afterExclusive` at which `spec` fires,
|
|
33
|
+
* or `null` when there is none (a past `at`, or a cron expression with no
|
|
34
|
+
* occurrence in the next five years).
|
|
35
|
+
*/
|
|
36
|
+
export declare function nextFireTime(spec: ScheduleSpec, afterExclusive: Date): Date | null;
|
|
37
|
+
/**
|
|
38
|
+
* The last instant at or before `atOrBefore` at which `spec` fired, or
|
|
39
|
+
* `null` if none within the horizon (or before the anchor / the `at`).
|
|
40
|
+
*/
|
|
41
|
+
export declare function previousFireTime(spec: ScheduleSpec, atOrBefore: Date): Date | null;
|
|
42
|
+
/**
|
|
43
|
+
* How many times `spec` fires in `(fromExclusive, toInclusive]`, with the
|
|
44
|
+
* first and latest of them. Stops counting at `cap` (default 100 000) and
|
|
45
|
+
* says so, without enumerating beyond it; the latest is exact either way.
|
|
46
|
+
*/
|
|
47
|
+
export declare function countOccurrences(spec: ScheduleSpec, fromExclusive: Date, toInclusive: Date, cap?: number): OccurrenceCount;
|
|
48
|
+
/** Validate a spec as a whole: its zone, its expression, and that it can ever fire after `now`. */
|
|
49
|
+
export declare function assertSpecFires(spec: ScheduleSpec, now: Date): void;
|
|
50
|
+
//# sourceMappingURL=next-fire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-fire.d.ts","sourceRoot":"","sources":["../../src/schedules/next-fire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAM/E,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,QAAc,CAAA;AAC5C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,SAAU,CAAA;AAmB3C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAoC7F;AAgBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAwBlF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CA0BlF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,YAAY,EAClB,aAAa,EAAE,IAAI,EACnB,WAAW,EAAE,IAAI,EACjB,GAAG,GAAE,MAA6B,GAChC,eAAe,CA4DjB;AAED,mGAAmG;AACnG,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI,CAanE"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a spec fires: the next instant, the previous one, and how many fall
|
|
3
|
+
* in a window.
|
|
4
|
+
*
|
|
5
|
+
* Cron is walked a local DAY at a time — never a minute at a time over years
|
|
6
|
+
* — and a day with no DST change is computed arithmetically from one offset.
|
|
7
|
+
* Only a day whose offset changes is examined slot by slot, and that is where
|
|
8
|
+
* cronie's rule is applied:
|
|
9
|
+
*
|
|
10
|
+
* - a fixed-time expression (`30 2 * * *`) whose time falls in a
|
|
11
|
+
* spring-forward gap fires once, at the first instant after the gap;
|
|
12
|
+
* whose time is repeated by a fall-back fires once, at the first of the two;
|
|
13
|
+
* - a wildcard or step expression (`0 * * * *`, `*\/15 * * * *`) fires at
|
|
14
|
+
* every instant whose wall time matches: the repeated hour runs twice and
|
|
15
|
+
* slots inside the gap do not exist.
|
|
16
|
+
*/
|
|
17
|
+
import { cronMatchesDay, parseCronExpression } from './cron.js';
|
|
18
|
+
import { ScheduleValidationError } from './errors.js';
|
|
19
|
+
import { civil, firstInstantAfterGap, instantsForWall, offsetAt, validateTimeZone } from './tz.js';
|
|
20
|
+
const MINUTE = 60_000;
|
|
21
|
+
const HOUR = 60 * MINUTE;
|
|
22
|
+
const DAY = 24 * HOUR;
|
|
23
|
+
/** How far ahead a cron search looks before deciding the expression never fires. */
|
|
24
|
+
export const CRON_HORIZON_DAYS = 366 * 5 + 2;
|
|
25
|
+
/**
|
|
26
|
+
* Occurrence counts stop here. Counting a day without a DST change costs one
|
|
27
|
+
* multiplication, so the cap bounds the pathological case (a years-long gap
|
|
28
|
+
* on a per-minute job) rather than the ordinary one.
|
|
29
|
+
*/
|
|
30
|
+
export const OCCURRENCE_COUNT_CAP = 100_000;
|
|
31
|
+
const parsedCache = new Map();
|
|
32
|
+
function cronOf(expr) {
|
|
33
|
+
let parsed = parsedCache.get(expr);
|
|
34
|
+
if (!parsed) {
|
|
35
|
+
parsed = parseCronExpression(expr);
|
|
36
|
+
if (parsedCache.size > 256)
|
|
37
|
+
parsedCache.clear();
|
|
38
|
+
parsedCache.set(expr, parsed);
|
|
39
|
+
}
|
|
40
|
+
return parsed;
|
|
41
|
+
}
|
|
42
|
+
/** The local-midnight wall value of the day containing `wall`. */
|
|
43
|
+
function dayStart(wall) {
|
|
44
|
+
return Math.floor(wall / DAY) * DAY;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Every instant the expression fires on one local day (`dayWall` is that
|
|
48
|
+
* day's midnight as a wall value), ascending.
|
|
49
|
+
*/
|
|
50
|
+
export function cronInstantsOnDay(expr, tz, dayWall) {
|
|
51
|
+
const c = civil(dayWall);
|
|
52
|
+
if (!cronMatchesDay(expr, c.month, c.day, c.weekday))
|
|
53
|
+
return [];
|
|
54
|
+
const before = offsetAt(dayWall - 14 * HOUR, tz);
|
|
55
|
+
const after = offsetAt(dayWall + DAY + 14 * HOUR, tz);
|
|
56
|
+
const out = [];
|
|
57
|
+
if (before === after) {
|
|
58
|
+
for (const h of expr.hours)
|
|
59
|
+
for (const m of expr.minutes)
|
|
60
|
+
out.push(dayWall + h * HOUR + m * MINUTE - before);
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
// A day the offset changes on (or next to): slot by slot.
|
|
64
|
+
const seen = new Set();
|
|
65
|
+
for (const h of expr.hours) {
|
|
66
|
+
for (const m of expr.minutes) {
|
|
67
|
+
const wall = dayWall + h * HOUR + m * MINUTE;
|
|
68
|
+
const instants = instantsForWall(wall, tz);
|
|
69
|
+
if (instants.length === 0) {
|
|
70
|
+
if (expr.fixedTime) {
|
|
71
|
+
const shifted = firstInstantAfterGap(wall, tz);
|
|
72
|
+
if (!seen.has(shifted)) {
|
|
73
|
+
seen.add(shifted);
|
|
74
|
+
out.push(shifted);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const chosen = expr.fixedTime ? instants.slice(0, 1) : instants;
|
|
80
|
+
for (const t of chosen) {
|
|
81
|
+
if (seen.has(t))
|
|
82
|
+
continue;
|
|
83
|
+
seen.add(t);
|
|
84
|
+
out.push(t);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return out.sort((a, b) => a - b);
|
|
89
|
+
}
|
|
90
|
+
function validEvery(spec) {
|
|
91
|
+
const anchor = Date.parse(spec.anchorAt);
|
|
92
|
+
if (!Number.isFinite(anchor)) {
|
|
93
|
+
throw new ScheduleValidationError(`anchor "${spec.anchorAt}" is not a date`, spec.anchorAt);
|
|
94
|
+
}
|
|
95
|
+
if (!Number.isSafeInteger(spec.everyMs) || spec.everyMs < MINUTE || spec.everyMs % MINUTE !== 0) {
|
|
96
|
+
throw new ScheduleValidationError('an interval must be a whole number of minutes, at least one', String(spec.everyMs));
|
|
97
|
+
}
|
|
98
|
+
return anchor;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The first instant strictly after `afterExclusive` at which `spec` fires,
|
|
102
|
+
* or `null` when there is none (a past `at`, or a cron expression with no
|
|
103
|
+
* occurrence in the next five years).
|
|
104
|
+
*/
|
|
105
|
+
export function nextFireTime(spec, afterExclusive) {
|
|
106
|
+
const after = afterExclusive.getTime();
|
|
107
|
+
switch (spec.kind) {
|
|
108
|
+
case 'at': {
|
|
109
|
+
const at = Date.parse(spec.at);
|
|
110
|
+
return Number.isFinite(at) && at > after ? new Date(at) : null;
|
|
111
|
+
}
|
|
112
|
+
case 'every': {
|
|
113
|
+
const anchor = validEvery(spec);
|
|
114
|
+
const k = after < anchor ? 1 : Math.floor((after - anchor) / spec.everyMs) + 1;
|
|
115
|
+
return new Date(anchor + Math.max(1, k) * spec.everyMs);
|
|
116
|
+
}
|
|
117
|
+
case 'cron': {
|
|
118
|
+
const expr = cronOf(spec.expr);
|
|
119
|
+
const tz = spec.tz;
|
|
120
|
+
// A day early: a gap-shifted or offset-crossing instant of the
|
|
121
|
+
// previous local day can still lie after `after`.
|
|
122
|
+
let day = dayStart(after + offsetAt(after, tz)) - DAY;
|
|
123
|
+
for (let i = 0; i <= CRON_HORIZON_DAYS; i++, day += DAY) {
|
|
124
|
+
for (const t of cronInstantsOnDay(expr, tz, day))
|
|
125
|
+
if (t > after)
|
|
126
|
+
return new Date(t);
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The last instant at or before `atOrBefore` at which `spec` fired, or
|
|
134
|
+
* `null` if none within the horizon (or before the anchor / the `at`).
|
|
135
|
+
*/
|
|
136
|
+
export function previousFireTime(spec, atOrBefore) {
|
|
137
|
+
const before = atOrBefore.getTime();
|
|
138
|
+
switch (spec.kind) {
|
|
139
|
+
case 'at': {
|
|
140
|
+
const at = Date.parse(spec.at);
|
|
141
|
+
return Number.isFinite(at) && at <= before ? new Date(at) : null;
|
|
142
|
+
}
|
|
143
|
+
case 'every': {
|
|
144
|
+
const anchor = validEvery(spec);
|
|
145
|
+
const k = Math.floor((before - anchor) / spec.everyMs);
|
|
146
|
+
return k >= 1 ? new Date(anchor + k * spec.everyMs) : null;
|
|
147
|
+
}
|
|
148
|
+
case 'cron': {
|
|
149
|
+
const expr = cronOf(spec.expr);
|
|
150
|
+
const tz = spec.tz;
|
|
151
|
+
let day = dayStart(before + offsetAt(before, tz)) + DAY;
|
|
152
|
+
for (let i = 0; i <= CRON_HORIZON_DAYS; i++, day -= DAY) {
|
|
153
|
+
const instants = cronInstantsOnDay(expr, tz, day);
|
|
154
|
+
for (let j = instants.length - 1; j >= 0; j--) {
|
|
155
|
+
const t = instants[j];
|
|
156
|
+
if (t <= before)
|
|
157
|
+
return new Date(t);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* How many times `spec` fires in `(fromExclusive, toInclusive]`, with the
|
|
166
|
+
* first and latest of them. Stops counting at `cap` (default 100 000) and
|
|
167
|
+
* says so, without enumerating beyond it; the latest is exact either way.
|
|
168
|
+
*/
|
|
169
|
+
export function countOccurrences(spec, fromExclusive, toInclusive, cap = OCCURRENCE_COUNT_CAP) {
|
|
170
|
+
const from = fromExclusive.getTime();
|
|
171
|
+
const to = toInclusive.getTime();
|
|
172
|
+
if (to <= from)
|
|
173
|
+
return { count: 0, capped: false };
|
|
174
|
+
switch (spec.kind) {
|
|
175
|
+
case 'at': {
|
|
176
|
+
const at = Date.parse(spec.at);
|
|
177
|
+
return at > from && at <= to
|
|
178
|
+
? { count: 1, capped: false, first: new Date(at), latest: new Date(at) }
|
|
179
|
+
: { count: 0, capped: false };
|
|
180
|
+
}
|
|
181
|
+
case 'every': {
|
|
182
|
+
const anchor = validEvery(spec);
|
|
183
|
+
const firstK = from < anchor ? 1 : Math.floor((from - anchor) / spec.everyMs) + 1;
|
|
184
|
+
const lastK = Math.floor((to - anchor) / spec.everyMs);
|
|
185
|
+
if (lastK < Math.max(1, firstK))
|
|
186
|
+
return { count: 0, capped: false };
|
|
187
|
+
const k0 = Math.max(1, firstK);
|
|
188
|
+
const total = lastK - k0 + 1;
|
|
189
|
+
return {
|
|
190
|
+
count: Math.min(total, cap),
|
|
191
|
+
capped: total > cap,
|
|
192
|
+
first: new Date(anchor + k0 * spec.everyMs),
|
|
193
|
+
latest: new Date(anchor + lastK * spec.everyMs),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
case 'cron': {
|
|
197
|
+
const expr = cronOf(spec.expr);
|
|
198
|
+
const tz = spec.tz;
|
|
199
|
+
const latest = previousFireTime(spec, toInclusive);
|
|
200
|
+
if (!latest || latest.getTime() <= from)
|
|
201
|
+
return { count: 0, capped: false };
|
|
202
|
+
const perUniformDay = expr.hours.length * expr.minutes.length;
|
|
203
|
+
let count = 0;
|
|
204
|
+
let first;
|
|
205
|
+
const lastDay = dayStart(to + offsetAt(to, tz)) + DAY;
|
|
206
|
+
for (let day = dayStart(from + offsetAt(from, tz)) - DAY; day <= lastDay; day += DAY) {
|
|
207
|
+
const c = civil(day);
|
|
208
|
+
if (!cronMatchesDay(expr, c.month, c.day, c.weekday))
|
|
209
|
+
continue;
|
|
210
|
+
const o1 = offsetAt(day - 14 * HOUR, tz);
|
|
211
|
+
const o2 = offsetAt(day + DAY + 14 * HOUR, tz);
|
|
212
|
+
const dayFirst = day - o1;
|
|
213
|
+
const dayLast = day + DAY - o1;
|
|
214
|
+
if (first !== undefined && o1 === o2 && dayFirst > from && dayLast <= to) {
|
|
215
|
+
count += perUniformDay;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
for (const t of cronInstantsOnDay(expr, tz, day)) {
|
|
219
|
+
if (t <= from || t > to)
|
|
220
|
+
continue;
|
|
221
|
+
if (first === undefined)
|
|
222
|
+
first = t;
|
|
223
|
+
count++;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (count > cap)
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
count: Math.min(count, cap),
|
|
231
|
+
capped: count > cap,
|
|
232
|
+
...(first !== undefined ? { first: new Date(first) } : {}),
|
|
233
|
+
latest,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/** Validate a spec as a whole: its zone, its expression, and that it can ever fire after `now`. */
|
|
239
|
+
export function assertSpecFires(spec, now) {
|
|
240
|
+
if (spec.kind === 'cron') {
|
|
241
|
+
validateTimeZone(spec.tz);
|
|
242
|
+
cronOf(spec.expr);
|
|
243
|
+
}
|
|
244
|
+
if (nextFireTime(spec, now) === null) {
|
|
245
|
+
throw new ScheduleValidationError(spec.kind === 'at'
|
|
246
|
+
? `${spec.at} is in the past`
|
|
247
|
+
: `"${spec.kind === 'cron' ? spec.expr : ''}" never fires in the next five years`, spec.kind === 'cron' ? spec.expr : spec.kind === 'at' ? spec.at : undefined);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=next-fire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-fire.js","sourceRoot":"","sources":["../../src/schedules/next-fire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,QAAQ,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C,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAC3E,CAAA;IACF,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words an operator or a model types for a schedule, turned into a spec.
|
|
3
|
+
*
|
|
4
|
+
* | Input | Spec |
|
|
5
|
+
* |---|---|
|
|
6
|
+
* | `at 2026-09-24T09:00`, `at 2026-09-24 09:00`, `at 09:00`, `in 30m` | `at` |
|
|
7
|
+
* | an ISO instant with `Z` or an offset, with or without `at` | `at` |
|
|
8
|
+
* | `every 30m`, `every 2h`, `every 1d`, `every 90m` | `every` |
|
|
9
|
+
* | five-field cron, `@hourly`, `@daily`, `@weekly`, `@monthly`, `@yearly` | `cron` |
|
|
10
|
+
*
|
|
11
|
+
* A local time is read in `tz`. Nothing is rounded silently: `every 30s` is
|
|
12
|
+
* refused and the refusal names the nearest interval that is allowed.
|
|
13
|
+
*/
|
|
14
|
+
import type { ScheduleSpec } from './types.js';
|
|
15
|
+
export interface ParseScheduleOptions {
|
|
16
|
+
/** "Now", for `in …`, `at HH:MM` and the anchor of `every`. Default: the clock. */
|
|
17
|
+
readonly now?: Date;
|
|
18
|
+
/** Zone a local time and a cron expression are read in. Default: the host's. */
|
|
19
|
+
readonly tz?: string;
|
|
20
|
+
}
|
|
21
|
+
/** `90m` → 5 400 000. Throws on anything else. */
|
|
22
|
+
export declare function parseDuration(text: string): number;
|
|
23
|
+
/**
|
|
24
|
+
* Parse schedule words into a spec, validated: the zone exists, the
|
|
25
|
+
* expression parses, and the spec fires at least once after `now`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseScheduleSpec(input: string, options?: ParseScheduleOptions): ScheduleSpec;
|
|
28
|
+
/** The next `count` fire times after `after`. */
|
|
29
|
+
export declare function upcomingFireTimes(spec: ScheduleSpec, after: Date, count?: number): Date[];
|
|
30
|
+
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../src/schedules/spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AA4B9C,MAAM,WAAW,oBAAoB;IACpC,mFAAmF;IACnF,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAA;IACnB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,kDAAkD;AAClD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUlD;AAmGD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,YAAY,CA8BjG;AAED,iDAAiD;AACjD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,SAAI,GAAG,IAAI,EAAE,CAUpF"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words an operator or a model types for a schedule, turned into a spec.
|
|
3
|
+
*
|
|
4
|
+
* | Input | Spec |
|
|
5
|
+
* |---|---|
|
|
6
|
+
* | `at 2026-09-24T09:00`, `at 2026-09-24 09:00`, `at 09:00`, `in 30m` | `at` |
|
|
7
|
+
* | an ISO instant with `Z` or an offset, with or without `at` | `at` |
|
|
8
|
+
* | `every 30m`, `every 2h`, `every 1d`, `every 90m` | `every` |
|
|
9
|
+
* | five-field cron, `@hourly`, `@daily`, `@weekly`, `@monthly`, `@yearly` | `cron` |
|
|
10
|
+
*
|
|
11
|
+
* A local time is read in `tz`. Nothing is rounded silently: `every 30s` is
|
|
12
|
+
* refused and the refusal names the nearest interval that is allowed.
|
|
13
|
+
*/
|
|
14
|
+
import { parseCronExpression } from './cron.js';
|
|
15
|
+
import { ScheduleValidationError } from './errors.js';
|
|
16
|
+
import { assertSpecFires, nextFireTime } from './next-fire.js';
|
|
17
|
+
import { civil, hostTimeZone, instantsForWall, validateTimeZone, wallOf } from './tz.js';
|
|
18
|
+
const MINUTE = 60_000;
|
|
19
|
+
const UNIT_MS = {
|
|
20
|
+
s: 1_000,
|
|
21
|
+
sec: 1_000,
|
|
22
|
+
secs: 1_000,
|
|
23
|
+
second: 1_000,
|
|
24
|
+
seconds: 1_000,
|
|
25
|
+
m: MINUTE,
|
|
26
|
+
min: MINUTE,
|
|
27
|
+
mins: MINUTE,
|
|
28
|
+
minute: MINUTE,
|
|
29
|
+
minutes: MINUTE,
|
|
30
|
+
h: 60 * MINUTE,
|
|
31
|
+
hr: 60 * MINUTE,
|
|
32
|
+
hrs: 60 * MINUTE,
|
|
33
|
+
hour: 60 * MINUTE,
|
|
34
|
+
hours: 60 * MINUTE,
|
|
35
|
+
d: 24 * 60 * MINUTE,
|
|
36
|
+
day: 24 * 60 * MINUTE,
|
|
37
|
+
days: 24 * 60 * MINUTE,
|
|
38
|
+
w: 7 * 24 * 60 * MINUTE,
|
|
39
|
+
week: 7 * 24 * 60 * MINUTE,
|
|
40
|
+
weeks: 7 * 24 * 60 * MINUTE,
|
|
41
|
+
};
|
|
42
|
+
/** `90m` → 5 400 000. Throws on anything else. */
|
|
43
|
+
export function parseDuration(text) {
|
|
44
|
+
const match = /^(\d+)\s*([a-z]+)$/i.exec(text.trim());
|
|
45
|
+
const unit = match ? UNIT_MS[(match[2] ?? '').toLowerCase()] : undefined;
|
|
46
|
+
if (!match || unit === undefined) {
|
|
47
|
+
throw new ScheduleValidationError(`"${text}" is not a duration (write it like 30m, 2h, 1d)`, text);
|
|
48
|
+
}
|
|
49
|
+
return Number(match[1]) * unit;
|
|
50
|
+
}
|
|
51
|
+
function formatInterval(ms) {
|
|
52
|
+
if (ms % (24 * 60 * MINUTE) === 0)
|
|
53
|
+
return `${ms / (24 * 60 * MINUTE)}d`;
|
|
54
|
+
if (ms % (60 * MINUTE) === 0)
|
|
55
|
+
return `${ms / (60 * MINUTE)}h`;
|
|
56
|
+
return `${ms / MINUTE}m`;
|
|
57
|
+
}
|
|
58
|
+
function everySpec(text, now) {
|
|
59
|
+
const ms = parseDuration(text);
|
|
60
|
+
if (ms < MINUTE) {
|
|
61
|
+
throw new ScheduleValidationError(`every ${text} is shorter than the minimum interval; the nearest allowed is every 1m`, text);
|
|
62
|
+
}
|
|
63
|
+
if (ms % MINUTE !== 0) {
|
|
64
|
+
const down = Math.floor(ms / MINUTE) * MINUTE;
|
|
65
|
+
const up = down + MINUTE;
|
|
66
|
+
throw new ScheduleValidationError(`every ${text} is not a whole number of minutes; the nearest allowed are every ${formatInterval(down)} and every ${formatInterval(up)}`, text);
|
|
67
|
+
}
|
|
68
|
+
const anchor = new Date(Math.floor(now.getTime() / MINUTE) * MINUTE);
|
|
69
|
+
return { kind: 'every', everyMs: ms, anchorAt: anchor.toISOString() };
|
|
70
|
+
}
|
|
71
|
+
/** Resolve a local `YYYY-MM-DD HH:MM` in `tz` to one instant (the earlier of two). */
|
|
72
|
+
function localToInstant(y, mo, d, h, mi, tz, token) {
|
|
73
|
+
const wall = Date.UTC(y, mo - 1, d, h, mi);
|
|
74
|
+
const c = civil(wall);
|
|
75
|
+
if (c.year !== y || c.month !== mo || c.day !== d || h > 23 || mi > 59) {
|
|
76
|
+
throw new ScheduleValidationError(`"${token}" is not a real date and time`, token);
|
|
77
|
+
}
|
|
78
|
+
const instants = instantsForWall(wall, tz);
|
|
79
|
+
if (instants.length === 0) {
|
|
80
|
+
throw new ScheduleValidationError(`"${token}" does not exist in ${tz} (the clocks skip it); pick a time outside the change`, token);
|
|
81
|
+
}
|
|
82
|
+
return instants[0];
|
|
83
|
+
}
|
|
84
|
+
function atSpec(text, now, tz) {
|
|
85
|
+
const t = text.trim();
|
|
86
|
+
// An instant with its own offset: taken as written.
|
|
87
|
+
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})$/i.test(t)) {
|
|
88
|
+
const at = Date.parse(t);
|
|
89
|
+
if (!Number.isFinite(at))
|
|
90
|
+
throw new ScheduleValidationError(`"${t}" is not a date`, t);
|
|
91
|
+
return { kind: 'at', at: new Date(at).toISOString() };
|
|
92
|
+
}
|
|
93
|
+
const full = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{1,2}):(\d{2})$/.exec(t);
|
|
94
|
+
if (full) {
|
|
95
|
+
const [, y, mo, d, h, mi] = full.map(Number);
|
|
96
|
+
const at = localToInstant(y, mo, d, h, mi, tz, t);
|
|
97
|
+
return { kind: 'at', at: new Date(at).toISOString() };
|
|
98
|
+
}
|
|
99
|
+
const clock = /^(\d{1,2}):(\d{2})$/.exec(t);
|
|
100
|
+
if (clock) {
|
|
101
|
+
const h = Number(clock[1]);
|
|
102
|
+
const mi = Number(clock[2]);
|
|
103
|
+
if (h > 23 || mi > 59)
|
|
104
|
+
throw new ScheduleValidationError(`"${t}" is not a time of day`, t);
|
|
105
|
+
// The next time the wall clock reads HH:MM, today or tomorrow.
|
|
106
|
+
const today = civil(wallOf(now.getTime(), tz));
|
|
107
|
+
for (let add = 0; add < 3; add++) {
|
|
108
|
+
const day = new Date(Date.UTC(today.year, today.month - 1, today.day + add));
|
|
109
|
+
const instants = instantsForWall(Date.UTC(day.getUTCFullYear(), day.getUTCMonth(), day.getUTCDate(), h, mi), tz);
|
|
110
|
+
const first = instants.find((i) => i > now.getTime());
|
|
111
|
+
if (first !== undefined)
|
|
112
|
+
return { kind: 'at', at: new Date(first).toISOString() };
|
|
113
|
+
}
|
|
114
|
+
throw new ScheduleValidationError(`"${t}" does not occur in ${tz} in the next two days`, t);
|
|
115
|
+
}
|
|
116
|
+
throw new ScheduleValidationError(`"${t}" is not a time (write 2026-09-24 09:00, 09:00, or an ISO instant)`, t);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Parse schedule words into a spec, validated: the zone exists, the
|
|
120
|
+
* expression parses, and the spec fires at least once after `now`.
|
|
121
|
+
*/
|
|
122
|
+
export function parseScheduleSpec(input, options = {}) {
|
|
123
|
+
const now = options.now ?? new Date();
|
|
124
|
+
const tz = validateTimeZone(options.tz ?? hostTimeZone());
|
|
125
|
+
const text = input.trim();
|
|
126
|
+
if (text === '')
|
|
127
|
+
throw new ScheduleValidationError('a schedule is required', '');
|
|
128
|
+
let spec;
|
|
129
|
+
const lower = text.toLowerCase();
|
|
130
|
+
if (lower.startsWith('every ')) {
|
|
131
|
+
spec = everySpec(text.slice(6).trim(), now);
|
|
132
|
+
}
|
|
133
|
+
else if (lower.startsWith('in ')) {
|
|
134
|
+
const ms = parseDuration(text.slice(3).trim());
|
|
135
|
+
if (ms < MINUTE) {
|
|
136
|
+
throw new ScheduleValidationError(`in ${text.slice(3).trim()} is less than a minute away; the nearest allowed is in 1m`, text.slice(3).trim());
|
|
137
|
+
}
|
|
138
|
+
spec = { kind: 'at', at: new Date(now.getTime() + ms).toISOString() };
|
|
139
|
+
}
|
|
140
|
+
else if (lower.startsWith('at ')) {
|
|
141
|
+
spec = atSpec(text.slice(3), now, tz);
|
|
142
|
+
}
|
|
143
|
+
else if (/^\d{4}-\d{2}-\d{2}T/i.test(text)) {
|
|
144
|
+
spec = atSpec(text, now, tz);
|
|
145
|
+
}
|
|
146
|
+
else if (lower === '@reboot') {
|
|
147
|
+
throw new ScheduleValidationError('@reboot is not supported: a job runs on a schedule', text);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const expr = parseCronExpression(text);
|
|
151
|
+
spec = { kind: 'cron', expr: expr.source, tz };
|
|
152
|
+
}
|
|
153
|
+
assertSpecFires(spec, now);
|
|
154
|
+
return spec;
|
|
155
|
+
}
|
|
156
|
+
/** The next `count` fire times after `after`. */
|
|
157
|
+
export function upcomingFireTimes(spec, after, count = 3) {
|
|
158
|
+
const out = [];
|
|
159
|
+
let cursor = after;
|
|
160
|
+
for (let i = 0; i < count; i++) {
|
|
161
|
+
const next = nextFireTime(spec, cursor);
|
|
162
|
+
if (!next)
|
|
163
|
+
break;
|
|
164
|
+
out.push(next);
|
|
165
|
+
cursor = next;
|
|
166
|
+
}
|
|
167
|
+
return out;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/schedules/spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE9D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAExF,MAAM,MAAM,GAAG,MAAM,CAAA;AACrB,MAAM,OAAO,GAAqC;IACjD,CAAC,EAAE,KAAK;IACR,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,KAAK;IACd,CAAC,EAAE,MAAM;IACT,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,MAAM;IACf,CAAC,EAAE,EAAE,GAAG,MAAM;IACd,EAAE,EAAE,EAAE,GAAG,MAAM;IACf,GAAG,EAAE,EAAE,GAAG,MAAM;IAChB,IAAI,EAAE,EAAE,GAAG,MAAM;IACjB,KAAK,EAAE,EAAE,GAAG,MAAM;IAClB,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,MAAM;IACnB,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,MAAM;IACrB,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,MAAM;IACtB,CAAC,EAAE,CAAC,GA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