@vite-hub/schedule 0.3.1 → 0.5.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/README.md +24 -19
- package/dist/{console-wEhr0LWn.d.ts → console-DueeEBcM.d.ts} +2 -0
- package/dist/cron-C1l3TquN.js +70 -0
- package/dist/definition.js +1 -2
- package/dist/{due-BVMRQ93v.js → due-n120-_nz.js} +22 -7
- package/dist/durability.d.ts +2 -2
- package/dist/durability.js +5 -5
- package/dist/{error-diagnostics-DSkCJC_L.js → error-diagnostics-C0KyI408.js} +10 -2
- package/dist/{error-diagnostics-Mpeks7J0.js → error-diagnostics-DTmP6baC.js} +5 -5
- package/dist/index.d.ts +19 -5
- package/dist/index.js +34 -6
- package/dist/{kv-storage-iJChCS5A.js → kv-storage-2kZtP2CC.js} +2 -2
- package/dist/{kv-storage-C0KZZB6v.d.ts → kv-storage-Bm9aYLfZ.d.ts} +5 -1
- package/dist/{operation-definition-8gOe-ubD.d.ts → operation-definition-CI2PJGqu.d.ts} +13 -2
- package/dist/{operations-DwZWFIUX.js → operations-DlrK9mlH.js} +29 -9
- package/dist/operations.d.ts +10 -1
- package/dist/operations.js +13 -10
- package/dist/os.d.ts +0 -1
- package/dist/os.js +12 -84
- package/dist/out-BbXG-yVX.js +21755 -0
- package/dist/rolldown-runtime-CMFfr-1z.js +26 -0
- package/dist/runtime/console.d.ts +1 -1
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/kv.d.ts +1 -1
- package/dist/runtime/kv.js +1 -1
- package/dist/runtime/process.js +24 -45
- package/dist/runtime/state.d.ts +2 -2
- package/dist/runtime/state.js +2 -2
- package/dist/runtime/static.d.ts +2 -73
- package/dist/runtime/static.js +3 -2
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +5 -5
- package/dist/{started-Bx7MDbrl.js → started-BWWr7Ufw.js} +3 -4
- package/dist/{started-BuGmnus4.js → started-BXdWMdji.js} +24 -6
- package/dist/{started-errors-p7cu_rI7.js → started-errors-BMg04lL3.js} +73 -26
- package/dist/started-name-DudQ0fsR.js +5 -0
- package/dist/{state-B-Fuyfb4.js → state-BjWnxyhv.js} +79 -118
- package/dist/{state-Do2wV4Tx.d.ts → state-CJKAhskJ.d.ts} +12 -2
- package/dist/static-BgoOCoe5.js +610 -0
- package/dist/static-CcBWx1kU.d.ts +96 -0
- package/dist/{store-Df0-fzCl.d.ts → store-CZHZfttA.d.ts} +3 -7
- package/dist/vite.d.ts +5 -3
- package/dist/vite.js +2963 -590
- package/package.json +6 -6
- package/dist/invariant-DolT9EEx.js +0 -22
- package/dist/static-DQwzzvPg.js +0 -266
- package/dist/wait-until-Dy4Bn3ZN.js +0 -112
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { a as ScheduleDefinitionRegistry, n as ScheduleDefinition, u as ScheduleRunContext } from "./types-Cw5LjPuc.js";
|
|
2
|
+
//#region src/runtime/due.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns `cron` with its weekday field written as names, such as `0 4 * * MON,FRI`. Cloudflare and Deno number
|
|
5
|
+
* weekdays 1-7 from Sunday, so standard 0-6 numbers fire one day early or fail to deploy. Names have one meaning on
|
|
6
|
+
* every host.
|
|
7
|
+
*/
|
|
8
|
+
declare function cronWithWeekdayNames(cron: string): string;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/runtime/static.d.ts
|
|
11
|
+
interface ExecuteStaticScheduleOptions {
|
|
12
|
+
cron: string;
|
|
13
|
+
definition: ScheduleDefinition;
|
|
14
|
+
name: string;
|
|
15
|
+
scheduledAt?: Date;
|
|
16
|
+
waitUntil?: (promise: PromiseLike<unknown>) => void;
|
|
17
|
+
/** Called when the run's evlog event has the failure, so the caller does not log it again. */
|
|
18
|
+
onRunLogged?: () => void;
|
|
19
|
+
}
|
|
20
|
+
interface ExecuteMatchingStaticSchedulesOptions {
|
|
21
|
+
cron: string;
|
|
22
|
+
/** Cron per Schedule name that the host registered in place of the Definition's cron. */
|
|
23
|
+
cronOverrides?: Readonly<Record<string, string>>;
|
|
24
|
+
registry: ScheduleDefinitionRegistry;
|
|
25
|
+
scheduledAt?: Date;
|
|
26
|
+
/**
|
|
27
|
+
* UTC cron that the host registered for each Schedule with a `timeZone`. A wake runs such a Schedule only when its
|
|
28
|
+
* own cron is due in its time zone at that minute. `cronOverrides` wins over this map.
|
|
29
|
+
*/
|
|
30
|
+
timeZoneCrons?: Readonly<Record<string, string>>;
|
|
31
|
+
waitUntil?: (promise: PromiseLike<unknown>) => void;
|
|
32
|
+
}
|
|
33
|
+
interface ExecuteCloudflareStaticSchedulesOptions {
|
|
34
|
+
/** Cron per Schedule name that the host registered in place of the Definition's cron. */
|
|
35
|
+
cronOverrides?: Readonly<Record<string, string>>;
|
|
36
|
+
registry: ScheduleDefinitionRegistry;
|
|
37
|
+
/** UTC cron that the host registered for each Schedule with a `timeZone`. */
|
|
38
|
+
timeZoneCrons?: Readonly<Record<string, string>>;
|
|
39
|
+
/** Generated Cloudflare trigger per Schedule name, separate from the standard cron passed to the handler. */
|
|
40
|
+
triggerCrons?: Readonly<Record<string, string>>;
|
|
41
|
+
waitUntil?: (promise: PromiseLike<unknown>) => void;
|
|
42
|
+
}
|
|
43
|
+
interface CloudflareScheduledEventLike {
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
controller?: {
|
|
46
|
+
cron?: string;
|
|
47
|
+
scheduledTime?: number | string | Date;
|
|
48
|
+
};
|
|
49
|
+
cron?: string;
|
|
50
|
+
scheduledTime?: number | string | Date;
|
|
51
|
+
}
|
|
52
|
+
interface StaticScheduleRun extends ScheduleRunContext {
|
|
53
|
+
cron: string;
|
|
54
|
+
scheduleId: string;
|
|
55
|
+
}
|
|
56
|
+
declare function missingScheduleDefinitionError(name: string): Error;
|
|
57
|
+
/**
|
|
58
|
+
* Checks the `Authorization` header of a Vercel Cron request against `CRON_SECRET` in constant time.
|
|
59
|
+
*/
|
|
60
|
+
declare function isScheduleCronAuthorized(authorization: string | null | undefined, cronSecret: string): boolean;
|
|
61
|
+
declare function normalizeCron(cron: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Logs a failure that the Process Runtime reports: as an evlog event `{ schedule: { op: "runtime" } }`, else on the
|
|
64
|
+
* console. A failed run that has its run event is not logged again.
|
|
65
|
+
*/
|
|
66
|
+
declare function logScheduleRuntimeError(error: unknown, runtimeError: Error): void;
|
|
67
|
+
/**
|
|
68
|
+
* Notes that a log event has `error`, and returns it to throw on. A thrown value that is not an object cannot be
|
|
69
|
+
* noted, so it becomes the Error that `normalizeScheduleRuntimeError()` makes of it anyway.
|
|
70
|
+
*/
|
|
71
|
+
declare function markLoggedScheduleError(error: unknown): unknown;
|
|
72
|
+
declare function normalizeScheduleRuntimeError(error: unknown): Error;
|
|
73
|
+
/**
|
|
74
|
+
* Estimates a wake minute from callback time when the host supplies no scheduled timestamp. This is the newest UTC
|
|
75
|
+
* cron match within one day, or the current minute when none matches. It cannot identify a delayed or retried wake
|
|
76
|
+
* after another cron match; callers must not treat it as the provider's occurrence identity.
|
|
77
|
+
*/
|
|
78
|
+
declare function scheduledWakeTime(cron: string, now?: Date): Date;
|
|
79
|
+
/**
|
|
80
|
+
* Returns `true` when a host wake at `scheduledAt` is an occurrence of the Definition's cron in its `timeZone`. The host
|
|
81
|
+
* runs a wider UTC cron for a time-zoned Schedule, so the runtime skips the wakes that are not local occurrences.
|
|
82
|
+
*/
|
|
83
|
+
declare function isTimeZoneWakeDue(definition: ScheduleDefinition & {
|
|
84
|
+
cron: string;
|
|
85
|
+
}, name: string, scheduledAt: Date): boolean;
|
|
86
|
+
declare function createStaticScheduleRun(options: Omit<ExecuteStaticScheduleOptions, "definition" | "waitUntil"> & {
|
|
87
|
+
waitUntil: NonNullable<ExecuteStaticScheduleOptions["waitUntil"]>;
|
|
88
|
+
}): StaticScheduleRun;
|
|
89
|
+
declare function executeStaticSchedule(options: ExecuteStaticScheduleOptions): Promise<unknown>;
|
|
90
|
+
declare function executeMatchingStaticSchedules(options: ExecuteMatchingStaticSchedulesOptions): Promise<unknown[]>;
|
|
91
|
+
declare function executeCloudflareStaticSchedules(event: CloudflareScheduledEventLike, options: ExecuteCloudflareStaticSchedulesOptions): Promise<unknown[]>;
|
|
92
|
+
declare function unwrapScheduleDefinition(loaded: unknown): (ScheduleDefinition & {
|
|
93
|
+
cron: string;
|
|
94
|
+
}) | undefined;
|
|
95
|
+
//#endregion
|
|
96
|
+
export { unwrapScheduleDefinition as _, createStaticScheduleRun as a, executeStaticSchedule as c, logScheduleRuntimeError as d, markLoggedScheduleError as f, scheduledWakeTime as g, normalizeScheduleRuntimeError as h, StaticScheduleRun as i, isScheduleCronAuthorized as l, normalizeCron as m, ExecuteMatchingStaticSchedulesOptions as n, executeCloudflareStaticSchedules as o, missingScheduleDefinitionError as p, ExecuteStaticScheduleOptions as r, executeMatchingStaticSchedules as s, ExecuteCloudflareStaticSchedulesOptions as t, isTimeZoneWakeDue as u, cronWithWeekdayNames as v };
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { a as ScheduleDefinitionRegistry, g as ScheduleRunStore, n as ScheduleDefinition, p as ScheduleRunRecord } from "./types-Cw5LjPuc.js";
|
|
2
|
-
import { t as ScheduleKVStorage } from "./kv-storage-
|
|
2
|
+
import { t as ScheduleKVStorage } from "./kv-storage-Bm9aYLfZ.js";
|
|
3
3
|
//#region src/runtime/execute.d.ts
|
|
4
4
|
interface ExecuteScheduleOptions {
|
|
5
|
-
/** Return the persisted failed run when the handler throws. Guards still throw. */
|
|
6
5
|
captureHandlerFailure?: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* The caller holds the claim on this occurrence, so a run that is still pending or running belongs to a process that
|
|
9
|
-
* stopped. Such a run gets a new attempt, and its unfinished attempts are marked as failed.
|
|
10
|
-
*/
|
|
11
6
|
claimed?: boolean;
|
|
12
7
|
definition: ScheduleDefinition;
|
|
13
|
-
/** Signals that the handler can start, or an existing run already consumed this occurrence. */
|
|
14
8
|
onExecution?: () => void;
|
|
9
|
+
onRunLogged?: () => void;
|
|
15
10
|
runStore?: ScheduleRunStore;
|
|
16
11
|
runIdSuffix?: string;
|
|
17
12
|
scheduleId: string;
|
|
@@ -26,6 +21,7 @@ interface ExecuteStaticScheduleOptions {
|
|
|
26
21
|
definition: ScheduleDefinition;
|
|
27
22
|
name: string;
|
|
28
23
|
onExecution?: () => void;
|
|
24
|
+
onRunLogged?: () => void;
|
|
29
25
|
scheduledAt?: Date;
|
|
30
26
|
waitUntil?: (promise: PromiseLike<unknown>) => void;
|
|
31
27
|
}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as DiscoveredScheduleDefinition } from "./types-Cw5LjPuc.js";
|
|
2
|
-
import { n as OperationContributionEntry } from "./operation-definition-
|
|
3
|
-
import { i as ViteHubInspectionPluginMetadata, n as ViteHubConsoleRuntimeRecordTableSection, r as ViteHubDefinitionSummary } from "./console-
|
|
2
|
+
import { n as OperationContributionEntry } from "./operation-definition-CI2PJGqu.js";
|
|
3
|
+
import { i as ViteHubInspectionPluginMetadata, n as ViteHubConsoleRuntimeRecordTableSection, r as ViteHubDefinitionSummary } from "./console-DueeEBcM.js";
|
|
4
4
|
//#region ../internal/src/deployment.d.ts
|
|
5
5
|
/** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
|
|
6
6
|
type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
|
|
@@ -90,6 +90,8 @@ interface ContributionContext {
|
|
|
90
90
|
projectRoot: string;
|
|
91
91
|
/** Server directories that the host forwards, for example Nuxt's `serverDir` and the server directories of layers. */
|
|
92
92
|
serverDirs?: readonly string[];
|
|
93
|
+
/** The flat list of Vite plugins, so a factory can read what sibling plugins declare. */
|
|
94
|
+
plugins?: readonly unknown[];
|
|
93
95
|
}
|
|
94
96
|
/**
|
|
95
97
|
* Returns the contributions of a plugin. It runs once per discovery pass, so it must be idempotent and must not depend
|
|
@@ -182,7 +184,7 @@ export declare function inspectScheduleDefinitions(options: ScheduleInspectionOp
|
|
|
182
184
|
/**
|
|
183
185
|
* Console section for Schedules. Records list discovered Schedule Definitions. When the server runs the Process Runtime,
|
|
184
186
|
* the cron and time zone come from the loaded Definitions, so any expression shows its real value.
|
|
185
|
-
* `vitehub inspect definitions` reads the same Definitions from source, and `vitehub schedule runs <name>` lists the runs
|
|
187
|
+
* `vitehub inspect definitions` reads the same Definitions from source, and `vitehub schedule runs list <name>` lists the runs
|
|
186
188
|
* that a runtime recorded.
|
|
187
189
|
*/
|
|
188
190
|
export declare const scheduleConsoleSection: ViteHubConsoleRuntimeRecordTableSection<ScheduleInspectionOptions>;
|