va-claw 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/CONTRIBUTING.md +36 -0
- package/LICENSE +21 -0
- package/README.md +337 -0
- package/bin/va-claw +3 -0
- package/bin/va-claw.mjs +3 -0
- package/docs/README.md +6 -0
- package/index.html +728 -0
- package/package.json +43 -0
- package/packages/channels/discord/dist/.tsbuildinfo +1 -0
- package/packages/channels/discord/dist/cli-runner.d.ts +18 -0
- package/packages/channels/discord/dist/cli-runner.d.ts.map +1 -0
- package/packages/channels/discord/dist/cli-runner.js +58 -0
- package/packages/channels/discord/dist/cli-runner.js.map +1 -0
- package/packages/channels/discord/dist/cli-runner.test.d.ts +2 -0
- package/packages/channels/discord/dist/cli-runner.test.d.ts.map +1 -0
- package/packages/channels/discord/dist/cli-runner.test.js +173 -0
- package/packages/channels/discord/dist/cli-runner.test.js.map +1 -0
- package/packages/channels/discord/dist/discord-client.d.ts +3 -0
- package/packages/channels/discord/dist/discord-client.d.ts.map +1 -0
- package/packages/channels/discord/dist/discord-client.js +49 -0
- package/packages/channels/discord/dist/discord-client.js.map +1 -0
- package/packages/channels/discord/dist/format.d.ts +6 -0
- package/packages/channels/discord/dist/format.d.ts.map +1 -0
- package/packages/channels/discord/dist/format.js +19 -0
- package/packages/channels/discord/dist/format.js.map +1 -0
- package/packages/channels/discord/dist/format.test.d.ts +2 -0
- package/packages/channels/discord/dist/format.test.d.ts.map +1 -0
- package/packages/channels/discord/dist/format.test.js +63 -0
- package/packages/channels/discord/dist/format.test.js.map +1 -0
- package/packages/channels/discord/dist/index.d.ts +3 -0
- package/packages/channels/discord/dist/index.d.ts.map +1 -0
- package/packages/channels/discord/dist/index.js +2 -0
- package/packages/channels/discord/dist/index.js.map +1 -0
- package/packages/channels/discord/dist/prompt.d.ts +4 -0
- package/packages/channels/discord/dist/prompt.d.ts.map +1 -0
- package/packages/channels/discord/dist/prompt.js +28 -0
- package/packages/channels/discord/dist/prompt.js.map +1 -0
- package/packages/channels/discord/dist/prompt.test.d.ts +2 -0
- package/packages/channels/discord/dist/prompt.test.d.ts.map +1 -0
- package/packages/channels/discord/dist/prompt.test.js +130 -0
- package/packages/channels/discord/dist/prompt.test.js.map +1 -0
- package/packages/channels/discord/dist/runtime.d.ts +11 -0
- package/packages/channels/discord/dist/runtime.d.ts.map +1 -0
- package/packages/channels/discord/dist/runtime.js +66 -0
- package/packages/channels/discord/dist/runtime.js.map +1 -0
- package/packages/channels/discord/dist/runtime.test.d.ts +2 -0
- package/packages/channels/discord/dist/runtime.test.d.ts.map +1 -0
- package/packages/channels/discord/dist/runtime.test.js +107 -0
- package/packages/channels/discord/dist/runtime.test.js.map +1 -0
- package/packages/channels/discord/dist/types.d.ts +30 -0
- package/packages/channels/discord/dist/types.d.ts.map +1 -0
- package/packages/channels/discord/dist/types.js +2 -0
- package/packages/channels/discord/dist/types.js.map +1 -0
- package/packages/channels/discord/package.json +21 -0
- package/packages/channels/dist/.tsbuildinfo +1 -0
- package/packages/channels/dist/index.d.ts +14 -0
- package/packages/channels/dist/index.d.ts.map +1 -0
- package/packages/channels/dist/index.js +25 -0
- package/packages/channels/dist/index.js.map +1 -0
- package/packages/channels/package.json +23 -0
- package/packages/channels/slack/dist/.tsbuildinfo +1 -0
- package/packages/channels/slack/dist/cli.d.ts +7 -0
- package/packages/channels/slack/dist/cli.d.ts.map +1 -0
- package/packages/channels/slack/dist/cli.js +53 -0
- package/packages/channels/slack/dist/cli.js.map +1 -0
- package/packages/channels/slack/dist/cli.test.d.ts +2 -0
- package/packages/channels/slack/dist/cli.test.d.ts.map +1 -0
- package/packages/channels/slack/dist/cli.test.js +43 -0
- package/packages/channels/slack/dist/cli.test.js.map +1 -0
- package/packages/channels/slack/dist/index.d.ts +7 -0
- package/packages/channels/slack/dist/index.d.ts.map +1 -0
- package/packages/channels/slack/dist/index.js +28 -0
- package/packages/channels/slack/dist/index.js.map +1 -0
- package/packages/channels/slack/dist/message.d.ts +15 -0
- package/packages/channels/slack/dist/message.d.ts.map +1 -0
- package/packages/channels/slack/dist/message.js +38 -0
- package/packages/channels/slack/dist/message.js.map +1 -0
- package/packages/channels/slack/dist/slack.test.d.ts +2 -0
- package/packages/channels/slack/dist/slack.test.d.ts.map +1 -0
- package/packages/channels/slack/dist/slack.test.js +23 -0
- package/packages/channels/slack/dist/slack.test.js.map +1 -0
- package/packages/channels/slack/dist/types.d.ts +22 -0
- package/packages/channels/slack/dist/types.d.ts.map +1 -0
- package/packages/channels/slack/dist/types.js +2 -0
- package/packages/channels/slack/dist/types.js.map +1 -0
- package/packages/channels/slack/package.json +21 -0
- package/packages/channels/telegram/dist/.tsbuildinfo +1 -0
- package/packages/channels/telegram/dist/cli.d.ts +13 -0
- package/packages/channels/telegram/dist/cli.d.ts.map +1 -0
- package/packages/channels/telegram/dist/cli.js +53 -0
- package/packages/channels/telegram/dist/cli.js.map +1 -0
- package/packages/channels/telegram/dist/cli.test.d.ts +2 -0
- package/packages/channels/telegram/dist/cli.test.d.ts.map +1 -0
- package/packages/channels/telegram/dist/cli.test.js +167 -0
- package/packages/channels/telegram/dist/cli.test.js.map +1 -0
- package/packages/channels/telegram/dist/index.d.ts +7 -0
- package/packages/channels/telegram/dist/index.d.ts.map +1 -0
- package/packages/channels/telegram/dist/index.js +21 -0
- package/packages/channels/telegram/dist/index.js.map +1 -0
- package/packages/channels/telegram/dist/message.d.ts +6 -0
- package/packages/channels/telegram/dist/message.d.ts.map +1 -0
- package/packages/channels/telegram/dist/message.js +33 -0
- package/packages/channels/telegram/dist/message.js.map +1 -0
- package/packages/channels/telegram/dist/telegram.test.d.ts +2 -0
- package/packages/channels/telegram/dist/telegram.test.d.ts.map +1 -0
- package/packages/channels/telegram/dist/telegram.test.js +25 -0
- package/packages/channels/telegram/dist/telegram.test.js.map +1 -0
- package/packages/channels/telegram/dist/types.d.ts +20 -0
- package/packages/channels/telegram/dist/types.d.ts.map +1 -0
- package/packages/channels/telegram/dist/types.js +2 -0
- package/packages/channels/telegram/dist/types.js.map +1 -0
- package/packages/channels/telegram/package.json +21 -0
- package/packages/cli/dist/.tsbuildinfo +1 -0
- package/packages/cli/dist/bin/va-claw.d.mts +3 -0
- package/packages/cli/dist/bin/va-claw.d.mts.map +1 -0
- package/packages/cli/dist/bin/va-claw.mjs +4 -0
- package/packages/cli/dist/bin/va-claw.mjs.map +1 -0
- package/packages/cli/dist/channel-handlers.d.ts +8 -0
- package/packages/cli/dist/channel-handlers.d.ts.map +1 -0
- package/packages/cli/dist/channel-handlers.js +80 -0
- package/packages/cli/dist/channel-handlers.js.map +1 -0
- package/packages/cli/dist/deps-exports.d.ts +3 -0
- package/packages/cli/dist/deps-exports.d.ts.map +1 -0
- package/packages/cli/dist/deps-exports.js +3 -0
- package/packages/cli/dist/deps-exports.js.map +1 -0
- package/packages/cli/dist/deps.d.ts +3 -0
- package/packages/cli/dist/deps.d.ts.map +1 -0
- package/packages/cli/dist/deps.js +81 -0
- package/packages/cli/dist/deps.js.map +1 -0
- package/packages/cli/dist/handlers.d.ts +33 -0
- package/packages/cli/dist/handlers.d.ts.map +1 -0
- package/packages/cli/dist/handlers.js +207 -0
- package/packages/cli/dist/handlers.js.map +1 -0
- package/packages/cli/dist/index.d.ts +10 -0
- package/packages/cli/dist/index.d.ts.map +1 -0
- package/packages/cli/dist/index.js +9 -0
- package/packages/cli/dist/index.js.map +1 -0
- package/packages/cli/dist/install-files.d.ts +11 -0
- package/packages/cli/dist/install-files.d.ts.map +1 -0
- package/packages/cli/dist/install-files.js +72 -0
- package/packages/cli/dist/install-files.js.map +1 -0
- package/packages/cli/dist/memory-status.d.ts +3 -0
- package/packages/cli/dist/memory-status.d.ts.map +1 -0
- package/packages/cli/dist/memory-status.js +45 -0
- package/packages/cli/dist/memory-status.js.map +1 -0
- package/packages/cli/dist/output.d.ts +8 -0
- package/packages/cli/dist/output.d.ts.map +1 -0
- package/packages/cli/dist/output.js +45 -0
- package/packages/cli/dist/output.js.map +1 -0
- package/packages/cli/dist/platform.d.ts +6 -0
- package/packages/cli/dist/platform.d.ts.map +1 -0
- package/packages/cli/dist/platform.js +31 -0
- package/packages/cli/dist/platform.js.map +1 -0
- package/packages/cli/dist/program.d.ts +5 -0
- package/packages/cli/dist/program.d.ts.map +1 -0
- package/packages/cli/dist/program.js +116 -0
- package/packages/cli/dist/program.js.map +1 -0
- package/packages/cli/dist/test-helpers.d.ts +7 -0
- package/packages/cli/dist/test-helpers.d.ts.map +1 -0
- package/packages/cli/dist/test-helpers.js +91 -0
- package/packages/cli/dist/test-helpers.js.map +1 -0
- package/packages/cli/dist/types.d.ts +82 -0
- package/packages/cli/dist/types.d.ts.map +1 -0
- package/packages/cli/dist/types.js +2 -0
- package/packages/cli/dist/types.js.map +1 -0
- package/packages/cli/dist/wait.d.ts +2 -0
- package/packages/cli/dist/wait.d.ts.map +1 -0
- package/packages/cli/dist/wait.js +25 -0
- package/packages/cli/dist/wait.js.map +1 -0
- package/packages/cli/package.json +29 -0
- package/packages/daemon/dist/.tsbuildinfo +1 -0
- package/packages/daemon/dist/cli-adapter.d.ts +14 -0
- package/packages/daemon/dist/cli-adapter.d.ts.map +1 -0
- package/packages/daemon/dist/cli-adapter.js +30 -0
- package/packages/daemon/dist/cli-adapter.js.map +1 -0
- package/packages/daemon/dist/index.d.ts +5 -0
- package/packages/daemon/dist/index.d.ts.map +1 -0
- package/packages/daemon/dist/index.js +4 -0
- package/packages/daemon/dist/index.js.map +1 -0
- package/packages/daemon/dist/runner.d.ts +2 -0
- package/packages/daemon/dist/runner.d.ts.map +1 -0
- package/packages/daemon/dist/runner.js +18 -0
- package/packages/daemon/dist/runner.js.map +1 -0
- package/packages/daemon/dist/runtime.d.ts +24 -0
- package/packages/daemon/dist/runtime.d.ts.map +1 -0
- package/packages/daemon/dist/runtime.js +83 -0
- package/packages/daemon/dist/runtime.js.map +1 -0
- package/packages/daemon/dist/service-files.d.ts +13 -0
- package/packages/daemon/dist/service-files.d.ts.map +1 -0
- package/packages/daemon/dist/service-files.js +84 -0
- package/packages/daemon/dist/service-files.js.map +1 -0
- package/packages/daemon/dist/service.d.ts +4 -0
- package/packages/daemon/dist/service.d.ts.map +1 -0
- package/packages/daemon/dist/service.js +31 -0
- package/packages/daemon/dist/service.js.map +1 -0
- package/packages/daemon/dist/types.d.ts +11 -0
- package/packages/daemon/dist/types.d.ts.map +1 -0
- package/packages/daemon/dist/types.js +2 -0
- package/packages/daemon/dist/types.js.map +1 -0
- package/packages/daemon/dist/wake-cycle.d.ts +17 -0
- package/packages/daemon/dist/wake-cycle.d.ts.map +1 -0
- package/packages/daemon/dist/wake-cycle.js +58 -0
- package/packages/daemon/dist/wake-cycle.js.map +1 -0
- package/packages/daemon/package.json +22 -0
- package/packages/identity/dist/.tsbuildinfo +1 -0
- package/packages/identity/dist/defaults.d.ts +5 -0
- package/packages/identity/dist/defaults.d.ts.map +1 -0
- package/packages/identity/dist/defaults.js +70 -0
- package/packages/identity/dist/defaults.js.map +1 -0
- package/packages/identity/dist/index.d.ts +6 -0
- package/packages/identity/dist/index.d.ts.map +1 -0
- package/packages/identity/dist/index.js +5 -0
- package/packages/identity/dist/index.js.map +1 -0
- package/packages/identity/dist/path.d.ts +3 -0
- package/packages/identity/dist/path.d.ts.map +1 -0
- package/packages/identity/dist/path.js +16 -0
- package/packages/identity/dist/path.js.map +1 -0
- package/packages/identity/dist/render.d.ts +4 -0
- package/packages/identity/dist/render.d.ts.map +1 -0
- package/packages/identity/dist/render.js +34 -0
- package/packages/identity/dist/render.js.map +1 -0
- package/packages/identity/dist/storage.d.ts +4 -0
- package/packages/identity/dist/storage.d.ts.map +1 -0
- package/packages/identity/dist/storage.js +27 -0
- package/packages/identity/dist/storage.js.map +1 -0
- package/packages/identity/dist/types.d.ts +29 -0
- package/packages/identity/dist/types.d.ts.map +1 -0
- package/packages/identity/dist/types.js +2 -0
- package/packages/identity/dist/types.js.map +1 -0
- package/packages/identity/dist/wizard.d.ts +3 -0
- package/packages/identity/dist/wizard.d.ts.map +1 -0
- package/packages/identity/dist/wizard.js +37 -0
- package/packages/identity/dist/wizard.js.map +1 -0
- package/packages/identity/package.json +21 -0
- package/packages/identity/test/identity.test.mjs +71 -0
- package/packages/identity/test/storage.test.mjs +91 -0
- package/packages/identity/vendor/clack-prompts/index.d.ts +10 -0
- package/packages/identity/vendor/clack-prompts/index.js +55 -0
- package/packages/identity/vendor/clack-prompts/package.json +11 -0
- package/packages/memory/dist/.tsbuildinfo +1 -0
- package/packages/memory/dist/default-store.d.ts +21 -0
- package/packages/memory/dist/default-store.d.ts.map +1 -0
- package/packages/memory/dist/default-store.js +52 -0
- package/packages/memory/dist/default-store.js.map +1 -0
- package/packages/memory/dist/embedding.d.ts +6 -0
- package/packages/memory/dist/embedding.d.ts.map +1 -0
- package/packages/memory/dist/embedding.js +56 -0
- package/packages/memory/dist/embedding.js.map +1 -0
- package/packages/memory/dist/forgetting-curve.d.ts +3 -0
- package/packages/memory/dist/forgetting-curve.d.ts.map +1 -0
- package/packages/memory/dist/forgetting-curve.js +21 -0
- package/packages/memory/dist/forgetting-curve.js.map +1 -0
- package/packages/memory/dist/index.d.ts +5 -0
- package/packages/memory/dist/index.d.ts.map +1 -0
- package/packages/memory/dist/index.js +4 -0
- package/packages/memory/dist/index.js.map +1 -0
- package/packages/memory/dist/memory-store.d.ts +39 -0
- package/packages/memory/dist/memory-store.d.ts.map +1 -0
- package/packages/memory/dist/memory-store.js +417 -0
- package/packages/memory/dist/memory-store.js.map +1 -0
- package/packages/memory/dist/sqlite.d.ts +19 -0
- package/packages/memory/dist/sqlite.d.ts.map +1 -0
- package/packages/memory/dist/sqlite.js +195 -0
- package/packages/memory/dist/sqlite.js.map +1 -0
- package/packages/memory/dist/types.d.ts +43 -0
- package/packages/memory/dist/types.d.ts.map +1 -0
- package/packages/memory/dist/types.js +2 -0
- package/packages/memory/dist/types.js.map +1 -0
- package/packages/memory/package.json +18 -0
- package/packages/skills/dist/.tsbuildinfo +1 -0
- package/packages/skills/dist/frontmatter.d.ts +3 -0
- package/packages/skills/dist/frontmatter.d.ts.map +1 -0
- package/packages/skills/dist/frontmatter.js +85 -0
- package/packages/skills/dist/frontmatter.js.map +1 -0
- package/packages/skills/dist/index.d.ts +6 -0
- package/packages/skills/dist/index.d.ts.map +1 -0
- package/packages/skills/dist/index.js +5 -0
- package/packages/skills/dist/index.js.map +1 -0
- package/packages/skills/dist/paths.d.ts +13 -0
- package/packages/skills/dist/paths.d.ts.map +1 -0
- package/packages/skills/dist/paths.js +43 -0
- package/packages/skills/dist/paths.js.map +1 -0
- package/packages/skills/dist/search.d.ts +3 -0
- package/packages/skills/dist/search.d.ts.map +1 -0
- package/packages/skills/dist/search.js +20 -0
- package/packages/skills/dist/search.js.map +1 -0
- package/packages/skills/dist/store.d.ts +8 -0
- package/packages/skills/dist/store.d.ts.map +1 -0
- package/packages/skills/dist/store.js +75 -0
- package/packages/skills/dist/store.js.map +1 -0
- package/packages/skills/dist/types.d.ts +9 -0
- package/packages/skills/dist/types.d.ts.map +1 -0
- package/packages/skills/dist/types.js +2 -0
- package/packages/skills/dist/types.js.map +1 -0
- package/packages/skills/package.json +18 -0
- package/skills/install-va-claw.md +180 -0
- package/vendor/commander/index.d.ts +16 -0
- package/vendor/commander/index.js +110 -0
- package/vendor/commander/package.json +11 -0
- package/vendor/croner/LICENSE +22 -0
- package/vendor/croner/README.md +339 -0
- package/vendor/croner/dist/croner.cjs +1 -0
- package/vendor/croner/dist/croner.d.cts +693 -0
- package/vendor/croner/dist/croner.d.ts +693 -0
- package/vendor/croner/dist/croner.js +1 -0
- package/vendor/croner/dist/croner.umd.js +1 -0
- package/vendor/croner/package.json +73 -0
- package/vendor/discord.js/index.d.ts +22 -0
- package/vendor/discord.js/index.js +37 -0
- package/vendor/discord.js/package.json +7 -0
- package/vendor/grammy/index.d.ts +43 -0
- package/vendor/grammy/index.js +89 -0
- package/vendor/grammy/package.json +7 -0
- package/vendor/slack-bolt/index.d.ts +29 -0
- package/vendor/slack-bolt/index.js +72 -0
- package/vendor/slack-bolt/package.json +7 -0
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cron pattern mode for controlling precision level
|
|
5
|
+
*/
|
|
6
|
+
export type CronMode = "auto" | "5-part" | "6-part" | "7-part" | "5-or-6-parts" | "6-or-7-parts";
|
|
7
|
+
/**
|
|
8
|
+
* Create a CronPattern instance from pattern string ('* * * * * *')
|
|
9
|
+
* @constructor
|
|
10
|
+
* @param {string} pattern - Input pattern
|
|
11
|
+
* @param {string} timezone - Input timezone, used for '?'-substitution
|
|
12
|
+
* @param {object} options - Cron options including mode
|
|
13
|
+
*/
|
|
14
|
+
export declare class CronPattern {
|
|
15
|
+
pattern: string;
|
|
16
|
+
timezone?: string;
|
|
17
|
+
mode: CronMode;
|
|
18
|
+
alternativeWeekdays: boolean;
|
|
19
|
+
sloppyRanges: boolean;
|
|
20
|
+
second: number[];
|
|
21
|
+
minute: number[];
|
|
22
|
+
hour: number[];
|
|
23
|
+
day: number[];
|
|
24
|
+
month: number[];
|
|
25
|
+
dayOfWeek: number[];
|
|
26
|
+
year: number[];
|
|
27
|
+
lastDayOfMonth: boolean;
|
|
28
|
+
lastWeekday: boolean;
|
|
29
|
+
nearestWeekdays: number[];
|
|
30
|
+
starDOM: boolean;
|
|
31
|
+
starDOW: boolean;
|
|
32
|
+
starYear: boolean;
|
|
33
|
+
useAndLogic: boolean;
|
|
34
|
+
constructor(pattern: string, timezone?: string, options?: {
|
|
35
|
+
mode?: CronMode;
|
|
36
|
+
alternativeWeekdays?: boolean;
|
|
37
|
+
sloppyRanges?: boolean;
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Parse current pattern, will throw on any type of failure
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
private parse;
|
|
44
|
+
/**
|
|
45
|
+
* Convert current part (seconds/minutes etc) to an array of 1 or 0 depending on if the part is about to trigger a run or not.
|
|
46
|
+
*/
|
|
47
|
+
private partToArray;
|
|
48
|
+
/**
|
|
49
|
+
* After converting JAN-DEC, SUN-SAT only 0-9 * , / - are allowed, throw if anything else pops up
|
|
50
|
+
* @throws On error
|
|
51
|
+
*/
|
|
52
|
+
private throwAtIllegalCharacters;
|
|
53
|
+
/**
|
|
54
|
+
* Nothing but a number, potentially with a modifier, left - handle that
|
|
55
|
+
*
|
|
56
|
+
* @param conf Current part, expected to be a number, as a string
|
|
57
|
+
* @param type One of "seconds", "minutes" etc
|
|
58
|
+
* @param valueIndexOffset -1 for day of month, and month, as they start at 1. 0 for seconds, hours, minutes
|
|
59
|
+
*/
|
|
60
|
+
private handleNumber;
|
|
61
|
+
/**
|
|
62
|
+
* Set a specific value for a specific part of the CronPattern.
|
|
63
|
+
*
|
|
64
|
+
* @param part The specific part of the CronPattern, e.g., "second", "minute", etc.
|
|
65
|
+
* @param index The index to modify.
|
|
66
|
+
* @param value The value to set, typically 0 or 1, in case of "nth weekday" it will be the weekday number used for further processing
|
|
67
|
+
*/
|
|
68
|
+
private setPart;
|
|
69
|
+
/**
|
|
70
|
+
* Validates that a parsed number is not NaN.
|
|
71
|
+
* Throws a TypeError with a descriptive message if the value is NaN.
|
|
72
|
+
*
|
|
73
|
+
* @param value - The value to validate
|
|
74
|
+
* @param errorMessage - The error message to throw if validation fails
|
|
75
|
+
* @throws {TypeError} If the value is NaN
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
private validateNotNaN;
|
|
79
|
+
/**
|
|
80
|
+
* Validates that a range is valid (lower <= upper) and that steps are valid (> 0 and <= array length).
|
|
81
|
+
*
|
|
82
|
+
* @param lower - Lower bound of range
|
|
83
|
+
* @param upper - Upper bound of range
|
|
84
|
+
* @param steps - Optional step value to validate
|
|
85
|
+
* @param type - The type of pattern part being validated
|
|
86
|
+
* @param conf - The original configuration string for error messages
|
|
87
|
+
* @throws {TypeError} If validation fails
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
private validateRange;
|
|
91
|
+
/**
|
|
92
|
+
* Take care of ranges with stepping (e.g. 3-23/5)
|
|
93
|
+
*
|
|
94
|
+
* @param conf Current part, expected to be a string like 3-23/5
|
|
95
|
+
* @param type One of "seconds", "minutes" etc
|
|
96
|
+
* @param valueIndexOffset -1 for day of month, and month, as they start at 1. 0 for seconds, hours, minutes
|
|
97
|
+
*/
|
|
98
|
+
private handleRangeWithStepping;
|
|
99
|
+
private extractNth;
|
|
100
|
+
/**
|
|
101
|
+
* Take care of ranges (e.g. 1-20)
|
|
102
|
+
*
|
|
103
|
+
* @param conf - Current part, expected to be a string like 1-20, can contain L for last
|
|
104
|
+
* @param type - One of "seconds", "minutes" etc
|
|
105
|
+
* @param valueIndexOffset - -1 for day of month, and month, as they start at 1. 0 for seconds, hours, minutes
|
|
106
|
+
*/
|
|
107
|
+
private handleRange;
|
|
108
|
+
/**
|
|
109
|
+
* Handle stepping (e.g. * / 14)
|
|
110
|
+
*
|
|
111
|
+
* @param conf Current part, expected to be a string like * /20 (without the space)
|
|
112
|
+
* @param type One of "seconds", "minutes" etc
|
|
113
|
+
*/
|
|
114
|
+
private handleStepping;
|
|
115
|
+
/**
|
|
116
|
+
* Replace day name with day numbers
|
|
117
|
+
*
|
|
118
|
+
* @param conf Current part, expected to be a string that might contain sun,mon etc.
|
|
119
|
+
*
|
|
120
|
+
* @returns Conf with 0 instead of sun etc.
|
|
121
|
+
*/
|
|
122
|
+
private replaceAlphaDays;
|
|
123
|
+
/**
|
|
124
|
+
* Replace day name with day numbers (Quartz mode)
|
|
125
|
+
* In Quartz mode: Sunday=1, Monday=2, ..., Saturday=7
|
|
126
|
+
*
|
|
127
|
+
* @param conf Current part, expected to be a string that might contain sun,mon etc.
|
|
128
|
+
*
|
|
129
|
+
* @returns Conf with Quartz-style numbering
|
|
130
|
+
*/
|
|
131
|
+
private replaceAlphaDaysQuartz;
|
|
132
|
+
/**
|
|
133
|
+
* Replace month name with month numbers
|
|
134
|
+
*
|
|
135
|
+
* @param conf Current part, expected to be a string that might contain jan,feb etc.
|
|
136
|
+
*
|
|
137
|
+
* @returns conf with 0 instead of sun etc.
|
|
138
|
+
*/
|
|
139
|
+
private replaceAlphaMonths;
|
|
140
|
+
/**
|
|
141
|
+
* Replace nicknames with actual cron patterns
|
|
142
|
+
*
|
|
143
|
+
* @param pattern Pattern, may contain nicknames, or not
|
|
144
|
+
*
|
|
145
|
+
* @returns Pattern, with cron expression insted of nicknames
|
|
146
|
+
*/
|
|
147
|
+
private handleNicknames;
|
|
148
|
+
/**
|
|
149
|
+
* Handle the nth weekday of the month logic using hash sign (e.g. FRI#2 for the second Friday of the month)
|
|
150
|
+
*
|
|
151
|
+
* @param index Weekday, example: 5 for friday
|
|
152
|
+
* @param nthWeekday bitmask, 2 (0x00010) for 2nd friday, 31 (ANY_OCCURRENCE, 0b100000) for any day
|
|
153
|
+
*/
|
|
154
|
+
private setNthWeekdayOfMonth;
|
|
155
|
+
}
|
|
156
|
+
export type CatchCallbackFn = (e: unknown, job: Cron) => void;
|
|
157
|
+
export type ProtectCallbackFn = (job: Cron) => void;
|
|
158
|
+
/**
|
|
159
|
+
* Options for configuring cron jobs.
|
|
160
|
+
*
|
|
161
|
+
* @interface
|
|
162
|
+
*/
|
|
163
|
+
export interface CronOptions<T = undefined> {
|
|
164
|
+
/**
|
|
165
|
+
* The name of the cron job. If provided, the job will be added to the
|
|
166
|
+
* `scheduledJobs` array, allowing it to be accessed by name.
|
|
167
|
+
*/
|
|
168
|
+
name?: string;
|
|
169
|
+
/**
|
|
170
|
+
* If true, the job will be paused initially.
|
|
171
|
+
* @default false
|
|
172
|
+
*/
|
|
173
|
+
paused?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* If true, the job will be stopped permanently.
|
|
176
|
+
* @default false
|
|
177
|
+
*/
|
|
178
|
+
kill?: boolean;
|
|
179
|
+
/**
|
|
180
|
+
* If true, errors thrown by the job function will be caught.
|
|
181
|
+
* If a function is provided, it will be called with the error and the job instance.
|
|
182
|
+
* @default false
|
|
183
|
+
*/
|
|
184
|
+
catch?: boolean | CatchCallbackFn;
|
|
185
|
+
/**
|
|
186
|
+
* If true, the underlying timer will be unreferenced, allowing the Node.js
|
|
187
|
+
* process to exit even if the job is still running.
|
|
188
|
+
* @default false
|
|
189
|
+
*/
|
|
190
|
+
unref?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* The maximum number of times the job will run.
|
|
193
|
+
* @default Infinity
|
|
194
|
+
*/
|
|
195
|
+
maxRuns?: number;
|
|
196
|
+
/**
|
|
197
|
+
* The minimum interval between job executions, in seconds.
|
|
198
|
+
* @default 1
|
|
199
|
+
*/
|
|
200
|
+
interval?: number;
|
|
201
|
+
/**
|
|
202
|
+
* If true, prevents the job from running if the previous execution is still in progress.
|
|
203
|
+
* If a function is provided, it will be called if the job is blocked.
|
|
204
|
+
* @default false
|
|
205
|
+
*/
|
|
206
|
+
protect?: boolean | ProtectCallbackFn;
|
|
207
|
+
/**
|
|
208
|
+
* The date and time at which the job should start running.
|
|
209
|
+
*/
|
|
210
|
+
startAt?: string | Date | CronDate<T>;
|
|
211
|
+
/**
|
|
212
|
+
* The date and time at which the job should stop running.
|
|
213
|
+
*/
|
|
214
|
+
stopAt?: string | Date | CronDate<T>;
|
|
215
|
+
/**
|
|
216
|
+
* The timezone for the cron job.
|
|
217
|
+
*/
|
|
218
|
+
timezone?: string;
|
|
219
|
+
/**
|
|
220
|
+
* The UTC offset for the cron job, in minutes.
|
|
221
|
+
*/
|
|
222
|
+
utcOffset?: number;
|
|
223
|
+
/**
|
|
224
|
+
* If true, uses AND logic when combining day-of-month and day-of-week.
|
|
225
|
+
* If false, uses OR logic for combining day-of-month and day-of-week (legacy behavior).
|
|
226
|
+
* @default false
|
|
227
|
+
*/
|
|
228
|
+
domAndDow?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated Use domAndDow instead. This option will be removed in a future version.
|
|
231
|
+
* If true, enables legacy mode (OR logic) for compatibility with older cron implementations.
|
|
232
|
+
* Offset the scheduled date by a number of days.
|
|
233
|
+
* Positive values shift the date forward, negative values shift it backward.
|
|
234
|
+
* For example, dayOffset: -1 schedules the job one day before the pattern match.
|
|
235
|
+
* @default 0
|
|
236
|
+
*/
|
|
237
|
+
dayOffset?: number;
|
|
238
|
+
/**
|
|
239
|
+
* If true, enables legacy mode for compatibility with older cron implementations.
|
|
240
|
+
* @default true
|
|
241
|
+
*/
|
|
242
|
+
legacyMode?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Specifies the cron pattern mode to use for parsing and execution.
|
|
245
|
+
*
|
|
246
|
+
* - "auto": Automatically detect pattern format (default behavior)
|
|
247
|
+
* - "5-part": Traditional 5-field cron (minute-level precision, seconds forced to 0, years wildcarded)
|
|
248
|
+
* - "6-part": Extended 6-field cron (second-level precision, years wildcarded)
|
|
249
|
+
* - "7-part": Full 7-field cron (second-level and year-specific precision)
|
|
250
|
+
* - "5-or-6-parts": Accept 5 or 6 field patterns (years wildcarded)
|
|
251
|
+
* - "6-or-7-parts": Accept 6 or 7 field patterns (no additional constraints)
|
|
252
|
+
*
|
|
253
|
+
* @default "auto"
|
|
254
|
+
*/
|
|
255
|
+
mode?: CronMode;
|
|
256
|
+
/**
|
|
257
|
+
* An optional context object that will be passed to the job function.
|
|
258
|
+
*/
|
|
259
|
+
context?: T;
|
|
260
|
+
/**
|
|
261
|
+
* If true, enables alternative weekday numbering (Quartz mode).
|
|
262
|
+
* In standard mode (false): Sunday=0, Monday=1, ..., Saturday=6
|
|
263
|
+
* In Quartz mode (true): Sunday=1, Monday=2, ..., Saturday=7
|
|
264
|
+
* @default false
|
|
265
|
+
*/
|
|
266
|
+
alternativeWeekdays?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* If true, allows non-standard stepping formats for backward compatibility.
|
|
269
|
+
* When false (default), only wildcard (*\/step) or range (min-max\/step) formats are allowed.
|
|
270
|
+
* When true, allows numeric prefix formats like /10, 5/5, 30/30.
|
|
271
|
+
* @default false
|
|
272
|
+
*/
|
|
273
|
+
sloppyRanges?: boolean;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Converts date to CronDate
|
|
277
|
+
*
|
|
278
|
+
* @param d Input date, if using string representation ISO 8001 (2015-11-24T19:40:00) local timezone is expected
|
|
279
|
+
* @param tz String representation of target timezone in Europe/Stockholm format, or a number representing offset in minutes.
|
|
280
|
+
*/
|
|
281
|
+
export declare class CronDate<T = undefined> {
|
|
282
|
+
tz: string | number | undefined;
|
|
283
|
+
/**
|
|
284
|
+
* Current milliseconds
|
|
285
|
+
* @type {number}
|
|
286
|
+
*/
|
|
287
|
+
ms: number;
|
|
288
|
+
/**
|
|
289
|
+
* Current second (0-59), in local time or target timezone specified by `this.tz`
|
|
290
|
+
* @type {number}
|
|
291
|
+
*/
|
|
292
|
+
second: number;
|
|
293
|
+
/**
|
|
294
|
+
* Current minute (0-59), in local time or target timezone specified by `this.tz`
|
|
295
|
+
* @type {number}
|
|
296
|
+
*/
|
|
297
|
+
minute: number;
|
|
298
|
+
/**
|
|
299
|
+
* Current hour (0-23), in local time or target timezone specified by `this.tz`
|
|
300
|
+
* @type {number}
|
|
301
|
+
*/
|
|
302
|
+
hour: number;
|
|
303
|
+
/**
|
|
304
|
+
* Current day (1-31), in local time or target timezone specified by `this.tz`
|
|
305
|
+
* @type {number}
|
|
306
|
+
*/
|
|
307
|
+
day: number;
|
|
308
|
+
/**
|
|
309
|
+
* Current month (1-12), in local time or target timezone specified by `this.tz`
|
|
310
|
+
* @type {number}
|
|
311
|
+
*/
|
|
312
|
+
month: number;
|
|
313
|
+
/**
|
|
314
|
+
* Current full year, in local time or target timezone specified by `this.tz`
|
|
315
|
+
*/
|
|
316
|
+
year: number;
|
|
317
|
+
constructor(d?: CronDate<T> | Date | string | null, tz?: string | number);
|
|
318
|
+
/**
|
|
319
|
+
* Calculates the last day of a given month.
|
|
320
|
+
* Uses a performance optimization for months other than February.
|
|
321
|
+
*
|
|
322
|
+
* @param year The year
|
|
323
|
+
* @param month The month (0-11)
|
|
324
|
+
* @returns The last day of the month (1-31)
|
|
325
|
+
* @private
|
|
326
|
+
*/
|
|
327
|
+
private getLastDayOfMonth;
|
|
328
|
+
/**
|
|
329
|
+
* Calculates the last weekday (Mon-Fri) of a given month.
|
|
330
|
+
*
|
|
331
|
+
* @param year The target year.
|
|
332
|
+
* @param month The target month (0-11).
|
|
333
|
+
* @returns The day of the month (1-31) that is the last weekday.
|
|
334
|
+
* @private
|
|
335
|
+
*/
|
|
336
|
+
private getLastWeekday;
|
|
337
|
+
/**
|
|
338
|
+
* Calculates the nearest weekday (Mon-Fri) to a given day of the month.
|
|
339
|
+
* Handles month boundaries.
|
|
340
|
+
*
|
|
341
|
+
* @param year The target year.
|
|
342
|
+
* @param month The target month (0-11).
|
|
343
|
+
* @param day The target day (1-31).
|
|
344
|
+
* @returns The day of the month (1-31) that is the nearest weekday, or -1 if the day doesn't exist in the month.
|
|
345
|
+
*/
|
|
346
|
+
private getNearestWeekday;
|
|
347
|
+
/**
|
|
348
|
+
* Check if the given date is the nth occurrence of a weekday in its month.
|
|
349
|
+
*
|
|
350
|
+
* @param year The year.
|
|
351
|
+
* @param month The month (0 for January, 11 for December).
|
|
352
|
+
* @param day The day of the month.
|
|
353
|
+
* @param nth The nth occurrence (bitmask).
|
|
354
|
+
*
|
|
355
|
+
* @return True if the date is the nth occurrence of its weekday, false otherwise.
|
|
356
|
+
*/
|
|
357
|
+
private isNthWeekdayOfMonth;
|
|
358
|
+
/**
|
|
359
|
+
* Sets internals using a Date
|
|
360
|
+
*/
|
|
361
|
+
private fromDate;
|
|
362
|
+
/**
|
|
363
|
+
* Sets internals by deep copying another CronDate
|
|
364
|
+
*
|
|
365
|
+
* @param {CronDate} d - Input date
|
|
366
|
+
*/
|
|
367
|
+
private fromCronDate;
|
|
368
|
+
/**
|
|
369
|
+
* Reset internal parameters (seconds, minutes, hours) if any of them have exceeded (or could have exceeded) their normal ranges
|
|
370
|
+
*
|
|
371
|
+
* Will alway return true on february 29th, as that is a date that _could_ be out of bounds
|
|
372
|
+
*/
|
|
373
|
+
private apply;
|
|
374
|
+
/**
|
|
375
|
+
* Sets internals by parsing a string
|
|
376
|
+
*/
|
|
377
|
+
private fromString;
|
|
378
|
+
/**
|
|
379
|
+
* Find next match of current part
|
|
380
|
+
*/
|
|
381
|
+
private findNext;
|
|
382
|
+
/**
|
|
383
|
+
* Internal unified method to find a matching time component in either direction.
|
|
384
|
+
* This method searches through the pattern to find the next or previous valid value
|
|
385
|
+
* for the specified target component (second, minute, hour, day, or month).
|
|
386
|
+
*
|
|
387
|
+
* @param options Cron options
|
|
388
|
+
* @param target Target property (second, minute, hour, day, month)
|
|
389
|
+
* @param pattern Pattern to use
|
|
390
|
+
* @param offset Offset to use
|
|
391
|
+
* @param direction 1 for forward (next), -1 for backward (previous)
|
|
392
|
+
* @returns Status code: 1 = same value matches, 2 = value changed, 3 = no match found
|
|
393
|
+
*
|
|
394
|
+
* @private
|
|
395
|
+
*/
|
|
396
|
+
private _findMatch;
|
|
397
|
+
/**
|
|
398
|
+
* Increment to next run time recursively.
|
|
399
|
+
*
|
|
400
|
+
* This function traverses the date components (year, month, day, hour, minute, second)
|
|
401
|
+
* to find the next date and time that matches the cron pattern. It uses a recursive
|
|
402
|
+
* approach to handle the dependencies between different components. For example,
|
|
403
|
+
* if the day changes, the hour, minute, and second need to be reset.
|
|
404
|
+
*
|
|
405
|
+
* The recursion is limited to the year 10000 to prevent potential
|
|
406
|
+
* infinite loops or excessive stack depth, and to match the maximum supported
|
|
407
|
+
* year in OCPS 1.2 (years 1-9999).
|
|
408
|
+
*
|
|
409
|
+
* @param pattern The cron pattern used to determine the next run time.
|
|
410
|
+
* @param options The cron options that influence the incrementing behavior.
|
|
411
|
+
* @param doing The index of the `RecursionSteps` array indicating the current
|
|
412
|
+
* date component being processed. 0 represents "month", 1 represents "day", etc.
|
|
413
|
+
*
|
|
414
|
+
* @returns This `CronDate` instance for chaining, or null if incrementing
|
|
415
|
+
* was not possible (e.g., reached year 10000 limit or no matching date).
|
|
416
|
+
*
|
|
417
|
+
* @private
|
|
418
|
+
*/
|
|
419
|
+
private recurse;
|
|
420
|
+
/**
|
|
421
|
+
* Increment to next run time
|
|
422
|
+
*
|
|
423
|
+
* @param pattern The pattern used to increment the current date.
|
|
424
|
+
* @param options Cron options used for incrementing.
|
|
425
|
+
* @param hasPreviousRun True if there was a previous run, false otherwise. This is used to determine whether to apply the minimum interval.
|
|
426
|
+
* @returns This CronDate instance for chaining, or null if incrementing was not possible (e.g., reached year 3000 limit).
|
|
427
|
+
*/
|
|
428
|
+
increment(pattern: CronPattern, options: CronOptions<T>, hasPreviousRun: boolean): CronDate<T> | null;
|
|
429
|
+
/**
|
|
430
|
+
* Decrement to previous run time
|
|
431
|
+
*
|
|
432
|
+
* @param pattern The pattern used to decrement the current date.
|
|
433
|
+
* @param options Cron options used for decrementing.
|
|
434
|
+
* @returns This CronDate instance for chaining, or null if decrementing was not possible (e.g., reached year 0).
|
|
435
|
+
*/
|
|
436
|
+
decrement(pattern: CronPattern, options: CronOptions<T>): CronDate<T> | null;
|
|
437
|
+
/**
|
|
438
|
+
* Find previous match by recursively checking pattern parts in reverse.
|
|
439
|
+
*
|
|
440
|
+
* This is the backward equivalent of the recurse() method. It searches backwards
|
|
441
|
+
* through time to find the previous date/time that matches the cron pattern.
|
|
442
|
+
*
|
|
443
|
+
* @param pattern The cron pattern used to determine the previous run time.
|
|
444
|
+
* @param options The cron options that influence the decrementing behavior.
|
|
445
|
+
* @param doing The index of the `RecursionSteps` array indicating the current
|
|
446
|
+
* date component being processed.
|
|
447
|
+
*
|
|
448
|
+
* @returns This `CronDate` instance for chaining, or null if decrementing
|
|
449
|
+
* was not possible (e.g., reached year 0 or no matching date).
|
|
450
|
+
*
|
|
451
|
+
* @private
|
|
452
|
+
*/
|
|
453
|
+
private recurseBackward;
|
|
454
|
+
/**
|
|
455
|
+
* Get the maximum value in a pattern for a given target.
|
|
456
|
+
* Used when resetting components during backward recursion.
|
|
457
|
+
*
|
|
458
|
+
* @param target The target component (second, minute, hour, day, month)
|
|
459
|
+
* @param pattern The cron pattern
|
|
460
|
+
* @param offset The offset to apply
|
|
461
|
+
* @returns The maximum valid value for the target component
|
|
462
|
+
*
|
|
463
|
+
* @private
|
|
464
|
+
*/
|
|
465
|
+
private getMaxPatternValue;
|
|
466
|
+
/**
|
|
467
|
+
* Find previous match for a specific component going backwards in time.
|
|
468
|
+
* This is the backward equivalent of the findNext() method.
|
|
469
|
+
*
|
|
470
|
+
* @param options Cron options
|
|
471
|
+
* @param target Target property (second, minute, hour, day, month)
|
|
472
|
+
* @param pattern Pattern to use
|
|
473
|
+
* @param offset Offset to use
|
|
474
|
+
* @returns Status code: 1 = same value matches, 2 = value changed to earlier value, 3 = no match found
|
|
475
|
+
*
|
|
476
|
+
* @private
|
|
477
|
+
*/
|
|
478
|
+
private findPrevious;
|
|
479
|
+
/**
|
|
480
|
+
* Convert current state back to a javascript Date()
|
|
481
|
+
*
|
|
482
|
+
* @param internal If this is an internal call
|
|
483
|
+
*/
|
|
484
|
+
getDate(internal?: boolean): Date;
|
|
485
|
+
/**
|
|
486
|
+
* Convert current state back to a javascript Date() and return UTC milliseconds
|
|
487
|
+
*/
|
|
488
|
+
getTime(): number;
|
|
489
|
+
/**
|
|
490
|
+
* Check if the current CronDate matches a cron pattern
|
|
491
|
+
*
|
|
492
|
+
* @param pattern The cron pattern to match against
|
|
493
|
+
* @param options The cron options that influence matching
|
|
494
|
+
* @returns true if the date matches the pattern, false otherwise
|
|
495
|
+
*/
|
|
496
|
+
match(pattern: CronPattern, options: CronOptions<T>): boolean;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* An array containing all named cron jobs.
|
|
500
|
+
*/
|
|
501
|
+
export declare const scheduledJobs: Cron<any>[];
|
|
502
|
+
/**
|
|
503
|
+
* Callback function type
|
|
504
|
+
*
|
|
505
|
+
* @param self - Reference to the Cron instance that triggered the callback
|
|
506
|
+
* @param context - Optional context value passed through options.context
|
|
507
|
+
*
|
|
508
|
+
* @returns void or Promise<void> for async callbacks
|
|
509
|
+
*/
|
|
510
|
+
export type CronCallback<T = undefined> = (self: InstanceType<typeof Cron<T>>, context: T) => void | Promise<void>;
|
|
511
|
+
/**
|
|
512
|
+
* Cron entrypoint
|
|
513
|
+
*
|
|
514
|
+
* @constructor
|
|
515
|
+
* @param pattern - Input pattern, input date, or input ISO 8601 time string
|
|
516
|
+
* @param [fnOrOptions1] - Options or function to be run each iteration of pattern
|
|
517
|
+
* @param [fnOrOptions2] - Options or function to be run each iteration of pattern
|
|
518
|
+
*/
|
|
519
|
+
export declare class Cron<T = undefined> {
|
|
520
|
+
name: string | undefined;
|
|
521
|
+
options: CronOptions<T>;
|
|
522
|
+
private _states;
|
|
523
|
+
private fn?;
|
|
524
|
+
/**
|
|
525
|
+
* Internal helper to get the timezone or UTC offset for date operations.
|
|
526
|
+
* Reduces duplication of `this.options.timezone || this.options.utcOffset` throughout the codebase.
|
|
527
|
+
*
|
|
528
|
+
* @returns The timezone string or UTC offset number
|
|
529
|
+
* @private
|
|
530
|
+
*/
|
|
531
|
+
private getTz;
|
|
532
|
+
/**
|
|
533
|
+
* Internal helper to apply dayOffset to a date if configured.
|
|
534
|
+
* Reduces duplication of dayOffset calculation logic.
|
|
535
|
+
*
|
|
536
|
+
* @param date - The base date to apply offset to
|
|
537
|
+
* @returns The date with dayOffset applied, or the original date if no offset is configured
|
|
538
|
+
* @private
|
|
539
|
+
*/
|
|
540
|
+
private applyDayOffset;
|
|
541
|
+
constructor(pattern: string | Date, fnOrOptions1?: CronOptions<T> | CronCallback<T>, fnOrOptions2?: CronOptions<T> | CronCallback<T>);
|
|
542
|
+
/**
|
|
543
|
+
* Find next runtime, based on supplied date. Strips milliseconds.
|
|
544
|
+
*
|
|
545
|
+
* @param prev - Optional. Date to start from. Can be a CronDate, Date object, or a string representing a date.
|
|
546
|
+
* @returns The next run time as a Date object, or null if there is no next run.
|
|
547
|
+
*/
|
|
548
|
+
nextRun(prev?: CronDate<T> | Date | string | null): Date | null;
|
|
549
|
+
/**
|
|
550
|
+
* Find next n runs, based on supplied date. Strips milliseconds.
|
|
551
|
+
*
|
|
552
|
+
* @param n - Number of runs to enumerate
|
|
553
|
+
* @param previous - Date to start from
|
|
554
|
+
* @returns - Next n run times
|
|
555
|
+
*/
|
|
556
|
+
nextRuns(n: number, previous?: Date | string): Date[];
|
|
557
|
+
/**
|
|
558
|
+
* Find previous n runs, based on supplied date. Strips milliseconds.
|
|
559
|
+
*
|
|
560
|
+
* @param n - Number of runs to enumerate
|
|
561
|
+
* @param reference - Date to start from (defaults to now)
|
|
562
|
+
* @returns - Previous n run times in reverse chronological order (most recent first)
|
|
563
|
+
*/
|
|
564
|
+
previousRuns(n: number, reference?: Date | string): Date[];
|
|
565
|
+
/**
|
|
566
|
+
* Internal helper to enumerate runs in either direction.
|
|
567
|
+
*
|
|
568
|
+
* @param n - Number of runs to enumerate
|
|
569
|
+
* @param startDate - Date to start from
|
|
570
|
+
* @param direction - Direction to enumerate ("next" or "previous")
|
|
571
|
+
* @returns Array of run times with dayOffset applied
|
|
572
|
+
* @private
|
|
573
|
+
*/
|
|
574
|
+
private _enumerateRuns;
|
|
575
|
+
/**
|
|
576
|
+
* Check if a given date matches the cron pattern
|
|
577
|
+
*
|
|
578
|
+
* @param date - Date to check. Can be a Date object or a string representing a date.
|
|
579
|
+
* @returns true if the date matches the pattern, false otherwise
|
|
580
|
+
*/
|
|
581
|
+
match(date: Date | string): boolean;
|
|
582
|
+
/**
|
|
583
|
+
* Return the original pattern, if there was one.
|
|
584
|
+
* Returns undefined when the job was created with a Date or ISO 8601 string instead of a cron pattern.
|
|
585
|
+
*
|
|
586
|
+
* @returns Original cron pattern, or undefined for date-based jobs
|
|
587
|
+
*/
|
|
588
|
+
getPattern(): string | undefined;
|
|
589
|
+
/**
|
|
590
|
+
* Return the original run-once date, if there was one
|
|
591
|
+
*
|
|
592
|
+
* @returns Original run-once date, or null if not a run-once job
|
|
593
|
+
*/
|
|
594
|
+
getOnce(): Date | null;
|
|
595
|
+
/**
|
|
596
|
+
* Indicates whether or not the cron job is scheduled and running, e.g. awaiting next trigger
|
|
597
|
+
*
|
|
598
|
+
* @returns Running or not
|
|
599
|
+
*/
|
|
600
|
+
isRunning(): boolean;
|
|
601
|
+
/**
|
|
602
|
+
* Indicates whether or not the cron job is permanently stopped
|
|
603
|
+
*
|
|
604
|
+
* @returns Running or not
|
|
605
|
+
*/
|
|
606
|
+
isStopped(): boolean;
|
|
607
|
+
/**
|
|
608
|
+
* Indicates whether or not the cron job is currently working
|
|
609
|
+
*
|
|
610
|
+
* @returns Running or not
|
|
611
|
+
*/
|
|
612
|
+
isBusy(): boolean;
|
|
613
|
+
/**
|
|
614
|
+
* Return current/previous run start time
|
|
615
|
+
*
|
|
616
|
+
* @returns Current (if running) or previous run time
|
|
617
|
+
*/
|
|
618
|
+
currentRun(): Date | null;
|
|
619
|
+
/**
|
|
620
|
+
* Return previous run start time
|
|
621
|
+
*
|
|
622
|
+
* @returns Previous run time
|
|
623
|
+
*/
|
|
624
|
+
previousRun(): Date | null;
|
|
625
|
+
/**
|
|
626
|
+
* Returns number of milliseconds to next run
|
|
627
|
+
*
|
|
628
|
+
* @param prev Starting date, defaults to now - minimum interval
|
|
629
|
+
*/
|
|
630
|
+
msToNext(prev?: CronDate<T> | Date | string): number | null;
|
|
631
|
+
/**
|
|
632
|
+
* Stop execution
|
|
633
|
+
*
|
|
634
|
+
* Running this will forcefully stop the job, and prevent furter exection. `.resume()` will not work after stopping.
|
|
635
|
+
* It will also be removed from the scheduledJobs array if it were named.
|
|
636
|
+
*/
|
|
637
|
+
stop(): void;
|
|
638
|
+
/**
|
|
639
|
+
* Pause execution
|
|
640
|
+
*
|
|
641
|
+
* @returns Wether pause was successful
|
|
642
|
+
*/
|
|
643
|
+
pause(): boolean;
|
|
644
|
+
/**
|
|
645
|
+
* Resume execution
|
|
646
|
+
*
|
|
647
|
+
* @returns Wether resume was successful
|
|
648
|
+
*/
|
|
649
|
+
resume(): boolean;
|
|
650
|
+
/**
|
|
651
|
+
* Schedule a new job
|
|
652
|
+
*
|
|
653
|
+
* @param func - Function to be run each iteration of pattern
|
|
654
|
+
*/
|
|
655
|
+
schedule(func?: CronCallback<T>): Cron<T>;
|
|
656
|
+
/**
|
|
657
|
+
* Internal function to trigger a run, used by both scheduled and manual trigger
|
|
658
|
+
*/
|
|
659
|
+
private _trigger;
|
|
660
|
+
/**
|
|
661
|
+
* Trigger a run manually
|
|
662
|
+
*/
|
|
663
|
+
trigger(): Promise<void>;
|
|
664
|
+
/**
|
|
665
|
+
* Returns number of runs left, undefined = unlimited
|
|
666
|
+
*/
|
|
667
|
+
runsLeft(): number | undefined;
|
|
668
|
+
/**
|
|
669
|
+
* Called when it's time to trigger.
|
|
670
|
+
* Checks if all conditions are currently met,
|
|
671
|
+
* then instantly triggers the scheduled function.
|
|
672
|
+
*/
|
|
673
|
+
private _checkTrigger;
|
|
674
|
+
/**
|
|
675
|
+
* Internal version of next. Cron needs millseconds internally, hence _next.
|
|
676
|
+
*/
|
|
677
|
+
private _next;
|
|
678
|
+
/**
|
|
679
|
+
* Internal version of previous. Finds the previous scheduled run time.
|
|
680
|
+
*
|
|
681
|
+
* @param referenceDate - Optional reference date to search backwards from (defaults to now)
|
|
682
|
+
* @returns Previous scheduled run time, or null if no previous run exists
|
|
683
|
+
*/
|
|
684
|
+
private _previous;
|
|
685
|
+
/**
|
|
686
|
+
* Calculate the previous run if no previous run is supplied, but startAt and interval are set.
|
|
687
|
+
* This calculation is only necessary if the startAt time is before the current time.
|
|
688
|
+
* Should only be called from the _next function.
|
|
689
|
+
*/
|
|
690
|
+
private _calculatePreviousRun;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export {};
|