@vite-hub/schedule 0.6.1 → 0.8.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 +30 -9
- package/dist/cron-D0mqg3ql.js +22 -0
- package/dist/definition.d.ts +1 -1
- package/dist/definition.js +4 -5
- package/dist/{due-D-0trD1g.js → due-DXgXKgzg.js} +1 -1
- package/dist/{error-diagnostics-kKXseq8d.js → error-diagnostics-CsiNo_oI.js} +3 -3
- package/dist/{error-diagnostics-B1AaIGWP.js → error-diagnostics-KvK9MX6w.js} +14 -2
- package/dist/{started-errors-IG9DlT2A.js → execute-DHApCpbQ.js} +8 -35
- package/dist/index.d.ts +16 -8
- package/dist/index.js +1 -51
- package/dist/{kv-storage-hI2IOjb5.d.ts → kv-storage-CKSSQ6Fk.d.ts} +7 -3
- package/dist/{kv-storage-Dsr3TL9c.js → kv-storage-CszEkof6.js} +2 -2
- package/dist/{object-CAK6UYR5.js → object-DNOrQSl5.js} +5 -1
- package/dist/{operation-definition-CqZkx1Rm.d.ts → operations-Blwi3jQF.d.ts} +1 -0
- package/dist/{operations-BTUQeba1.js → operations-Bog78pOZ.js} +33 -14
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +8 -6
- package/dist/os.js +3 -3
- package/dist/runtime/console.js +25 -11
- package/dist/runtime/kv.d.ts +1 -1
- package/dist/runtime/kv.js +1 -1
- package/dist/runtime/process.d.ts +1 -1
- package/dist/runtime/process.js +41 -22
- package/dist/runtime/state.d.ts +2 -2
- package/dist/runtime/state.js +1 -1
- package/dist/runtime/static.d.ts +1 -1
- package/dist/runtime/static.js +2 -2
- package/dist/runtime.d.ts +6 -6
- package/dist/runtime.js +5 -5
- package/dist/{started-B1Se_Iwo.js → started-Ck0Wu5Oc.js} +55 -10
- package/dist/{started-Bzvr4t5f.js → started-adRbWkWd.js} +7 -5
- package/dist/started-errors-D6CnKMqD.js +32 -0
- package/dist/state-BoDrff6R.js +586 -0
- package/dist/{state-BDEDVlyr.d.ts → state-CRQQfd8h.d.ts} +24 -5
- package/dist/{static-DeRvJqcQ.d.ts → static-BFV4x94g.d.ts} +1 -1
- package/dist/{static-Bg7Jj92L.js → static-D4nN8HTx.js} +8 -6
- package/dist/{store-CEv3cScg.d.ts → store-TOayO0NL.d.ts} +6 -3
- package/dist/{types-DTVPVY5O.d.ts → types-Wllh0U8N.d.ts} +35 -4
- package/dist/vite.d.ts +4 -2
- package/dist/vite.js +561 -187
- package/package.json +11 -4
- package/dist/started-name-w6n9uDdt.js +0 -4
- package/dist/state-BZLy46UJ.js +0 -427
- package/dist/{cron-BT3ef48f.js → cron-imqlBgO-.js} +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { _ as ScheduleRunRecord, b as ScheduleRunStore, o as ScheduleDefinitionRegistry, r as ScheduleDefinition } from "./types-Wllh0U8N.js";
|
|
2
|
+
import { n as ScheduleKVStorage } from "./kv-storage-CKSSQ6Fk.js";
|
|
3
|
+
import { Duration } from "@vite-hub/runtime";
|
|
3
4
|
interface ExecuteScheduleOptions {
|
|
4
5
|
captureHandlerFailure?: boolean;
|
|
5
6
|
claimed?: boolean;
|
|
6
7
|
definition: ScheduleDefinition;
|
|
8
|
+
oneShot?: boolean;
|
|
7
9
|
onExecution?: () => void;
|
|
8
10
|
onRunLogged?: () => void;
|
|
9
11
|
runStore?: ScheduleRunStore;
|
|
@@ -34,11 +36,12 @@ interface RunScheduleOptions {
|
|
|
34
36
|
declare function createScheduleRun(options: Omit<ExecuteScheduleOptions, "definition" | "waitUntil">): Promise<ScheduleRunRecord>;
|
|
35
37
|
declare function executeSchedule(options: ExecuteScheduleOptions): Promise<ScheduleRunRecord>;
|
|
36
38
|
declare function executeStaticSchedule(options: ExecuteStaticScheduleOptions): Promise<ScheduleRunRecord>;
|
|
37
|
-
/** Runs a
|
|
39
|
+
/** Runs a Static Schedule Definition of `registry` immediately, unless it sets `manual: false`. */
|
|
38
40
|
declare function runScheduleFrom(registry: ScheduleDefinitionRegistry, name: string, options?: RunScheduleOptions): Promise<ScheduleRunRecord>;
|
|
39
41
|
interface KVScheduleStoreOptions {
|
|
40
42
|
kvStore: ScheduleKVStorage;
|
|
41
43
|
prefix?: string;
|
|
44
|
+
retention?: Duration;
|
|
42
45
|
}
|
|
43
46
|
declare function createMemoryScheduleRunStore(): ScheduleRunStore;
|
|
44
47
|
declare function createKVScheduleRunStore(options: KVScheduleStoreOptions): ScheduleRunStore;
|
|
@@ -21,7 +21,10 @@ type ScheduleHandler<TResult = unknown> = {
|
|
|
21
21
|
bivarianceHack(context: ScheduleRunContext): TResult | Promise<TResult>;
|
|
22
22
|
}["bivarianceHack"];
|
|
23
23
|
interface ScheduleDefinitionInput<TResult = unknown> {
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Set `false` to stop `runSchedule()`, the Console, and `vitehub schedule run` from starting a Definition with `cron`
|
|
26
|
+
* outside its cron. Defaults to `true`.
|
|
27
|
+
*/
|
|
25
28
|
manual?: boolean;
|
|
26
29
|
/**
|
|
27
30
|
* Five-field cron expression, evaluated in `timeZone`. Leave it out for a Schedule that runs only when code starts it
|
|
@@ -37,7 +40,10 @@ interface ScheduleDefinitionInput<TResult = unknown> {
|
|
|
37
40
|
timeZone?: string;
|
|
38
41
|
}
|
|
39
42
|
interface ScheduleDefinitionOptions {
|
|
40
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Set `false` to stop `runSchedule()`, the Console, and `vitehub schedule run` from starting a Definition with `cron`
|
|
45
|
+
* outside its cron. Defaults to `true`.
|
|
46
|
+
*/
|
|
41
47
|
manual?: boolean;
|
|
42
48
|
/** IANA time zone of the cron, such as `"Europe/Madrid"`. Defaults to `"UTC"`. */
|
|
43
49
|
timeZone?: string;
|
|
@@ -99,7 +105,9 @@ interface ScheduleRunListOptions {
|
|
|
99
105
|
}
|
|
100
106
|
interface ScheduleRunStore {
|
|
101
107
|
createAttempt: (attempt: ScheduleRunAttemptRecord) => Promise<ScheduleRunAttemptRecord> | ScheduleRunAttemptRecord;
|
|
102
|
-
createRun: (run: ScheduleRunRecord
|
|
108
|
+
createRun: (run: ScheduleRunRecord, options?: {
|
|
109
|
+
oneShot?: boolean;
|
|
110
|
+
}) => Promise<ScheduleRunRecord> | ScheduleRunRecord;
|
|
103
111
|
getAttempt: (id: string) => Promise<ScheduleRunAttemptRecord | undefined> | ScheduleRunAttemptRecord | undefined;
|
|
104
112
|
getRun: (id: string) => Promise<ScheduleRunRecord | undefined> | ScheduleRunRecord | undefined;
|
|
105
113
|
listAttempts: (runId: string) => Promise<ScheduleRunAttemptRecord[]> | ScheduleRunAttemptRecord[];
|
|
@@ -114,6 +122,7 @@ interface ScheduleRunStore {
|
|
|
114
122
|
}) => Promise<ScheduleRunRecord | undefined> | ScheduleRunRecord | undefined;
|
|
115
123
|
}
|
|
116
124
|
interface DiscoveredScheduleDefinition {
|
|
125
|
+
/** False when the Definition sets `manual: false` or has no `cron`. Only these Definitions cannot run by name. */
|
|
117
126
|
manual?: boolean;
|
|
118
127
|
/** True when the Definition declares no `cron`, so it runs only when code starts it with `startSchedule()`. */
|
|
119
128
|
startable?: boolean;
|
|
@@ -125,6 +134,28 @@ interface DiscoveredScheduleDefinition {
|
|
|
125
134
|
reason?: string;
|
|
126
135
|
source?: "server-schedules" | "vite-plugin-contribution" | "vite-suffix";
|
|
127
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* The Static Schedule Definitions of the app, by name. ViteHub writes it to `.vitehub/schedule.d.ts` from the files
|
|
139
|
+
* with `cron` in `server/schedules/` and the Schedules that plugins contribute, so `runSchedule()` checks the name.
|
|
140
|
+
*/
|
|
141
|
+
interface ScheduleRegistry {}
|
|
142
|
+
/**
|
|
143
|
+
* The Schedule Definitions without `cron`, by name. ViteHub writes it to `.vitehub/schedule.d.ts`, so
|
|
144
|
+
* `startSchedule()` checks the name.
|
|
145
|
+
*/
|
|
146
|
+
interface StartableScheduleRegistry {}
|
|
147
|
+
/** @internal Augmented when Schedule discovery writes a registry, even if it finds no Definitions. */
|
|
148
|
+
interface ScheduleRegistryState {}
|
|
149
|
+
type RegistryName<TRegistry> = [keyof (TRegistry & ScheduleRegistryState)] extends [never] ? string : Extract<keyof TRegistry, string>;
|
|
150
|
+
/** A Static Schedule name from `ScheduleRegistry`. Any string before ViteHub writes the registry. */
|
|
151
|
+
type ScheduleName = RegistryName<ScheduleRegistry>;
|
|
152
|
+
/** A name of a Schedule Definition without `cron`, from `StartableScheduleRegistry`. Any string before ViteHub writes the registry. */
|
|
153
|
+
type StartableScheduleName = RegistryName<StartableScheduleRegistry>;
|
|
154
|
+
/**
|
|
155
|
+
* A name that the code reads at runtime, such as from a request. It accepts a `string` value but not a string
|
|
156
|
+
* literal, so a typo in a literal name still fails the type check.
|
|
157
|
+
*/
|
|
158
|
+
type DynamicScheduleName<TName extends string> = TName & (string extends TName ? unknown : never);
|
|
128
159
|
/** When a started Schedule runs: once at `at`, or on each occurrence of `cron` until you cancel it. */
|
|
129
160
|
type StartScheduleTiming = {
|
|
130
161
|
/** One run at this time: a `Date`, or an ISO 8601 date-time with a time zone, such as `"2026-11-08T09:00:00Z"`. */
|
|
@@ -162,4 +193,4 @@ interface StartedScheduleStore {
|
|
|
162
193
|
list: () => Promise<StartedSchedule[]>;
|
|
163
194
|
put: (schedule: StartedSchedule) => Promise<void>;
|
|
164
195
|
}
|
|
165
|
-
export {
|
|
196
|
+
export { StartableScheduleName as C, StartedScheduleStore as E, StartScheduleTiming as S, StartedSchedule as T, ScheduleRunRecord as _, ScheduleDefinitionOptions as a, ScheduleRunStore as b, ScheduleName as c, ScheduleRegistryState as d, ScheduleRunAttemptRecord as f, ScheduleRunListOptions as g, ScheduleRunError as h, ScheduleDefinitionInput as i, ScheduleRegistry as l, ScheduleRunContext as m, DynamicScheduleName as n, ScheduleDefinitionRegistry as o, ScheduleRunAttemptStatus as p, ScheduleDefinition as r, ScheduleHandler as s, DiscoveredScheduleDefinition as t, ScheduleRegistryDefinition as u, ScheduleRunResponse as v, StartableScheduleRegistry as w, StartScheduleOptions as x, ScheduleRunStatus as y };
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { i as ViteHubInspectionPluginMetadata, n as ViteHubConsoleRuntimeRecordTableSection, r as ViteHubDefinitionSummary } from "./console-BdlDJUfS.js";
|
|
2
|
-
import { n as OperationContributionEntry } from "./
|
|
3
|
-
import { t as DiscoveredScheduleDefinition } from "./types-
|
|
2
|
+
import { n as OperationContributionEntry } from "./operations-Blwi3jQF.js";
|
|
3
|
+
import { t as DiscoveredScheduleDefinition } from "./types-Wllh0U8N.js";
|
|
4
|
+
import { Duration } from "@vite-hub/runtime";
|
|
4
5
|
/** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
|
|
5
6
|
type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
|
|
6
7
|
/**
|
|
@@ -193,6 +194,7 @@ export interface ScheduleOptions {
|
|
|
193
194
|
cron?: Readonly<Record<string, string>>;
|
|
194
195
|
providerOutput?: "auto" | "standalone" | "nitro" | false;
|
|
195
196
|
projectRoot?: string;
|
|
197
|
+
retention?: Duration;
|
|
196
198
|
runtime?: ScheduleProcessRuntimeOptions;
|
|
197
199
|
}
|
|
198
200
|
export interface ScheduleNitroConfigOptions extends ScheduleOptions {
|