@vite-hub/schedule 0.1.0 → 0.4.1

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.
Files changed (56) hide show
  1. package/README.md +118 -100
  2. package/dist/console-wEhr0LWn.d.ts +330 -0
  3. package/dist/definition.d.ts +6 -2
  4. package/dist/definition.js +47 -1
  5. package/dist/due-sOJvF_6Z.js +144 -0
  6. package/dist/durability.d.ts +14 -0
  7. package/dist/durability.js +23 -0
  8. package/dist/error-diagnostics-BBtYYl8j.js +170 -0
  9. package/dist/error-diagnostics-CQ4BUqRe.js +270 -0
  10. package/dist/index.d.ts +73 -5
  11. package/dist/index.js +56 -2
  12. package/dist/invariant-DolT9EEx.js +22 -0
  13. package/dist/{kv-storage-DWinmLLy.js → kv-storage-2kZtP2CC.js} +4 -4
  14. package/dist/{kv-storage-Bv9ocZT-.d.ts → kv-storage-Bm9aYLfZ.d.ts} +7 -3
  15. package/dist/object-Da1zyPCR.js +11 -0
  16. package/dist/{operations-tNUdj3G4.d.ts → operation-definition-nmRu_O3V.d.ts} +42 -15
  17. package/dist/operations-DqwmJ8MN.js +207 -0
  18. package/dist/operations.d.ts +36 -4
  19. package/dist/operations.js +130 -730
  20. package/dist/os.d.ts +167 -0
  21. package/dist/os.js +1659 -0
  22. package/dist/runtime/console.d.ts +12 -0
  23. package/dist/runtime/console.js +85 -0
  24. package/dist/runtime/kv.d.ts +1 -1
  25. package/dist/runtime/kv.js +1 -1
  26. package/dist/runtime/process.d.ts +32 -5
  27. package/dist/runtime/process.js +401 -413
  28. package/dist/runtime/state.d.ts +2 -9
  29. package/dist/runtime/state.js +2 -2
  30. package/dist/runtime/static.d.ts +28 -2
  31. package/dist/runtime/static.js +2 -2
  32. package/dist/runtime.d.ts +34 -32
  33. package/dist/runtime.js +6 -5
  34. package/dist/started-B0pc3JY0.js +146 -0
  35. package/dist/started-Bk2Icknk.js +201 -0
  36. package/dist/{execute-BJrgNgQ0.js → started-errors-DEmYH-vp.js} +94 -38
  37. package/dist/{inspect-DTfAo5gS.js → started-name-ruCM1EtQ.js} +5 -1
  38. package/dist/state-CPd10SXq.d.ts +58 -0
  39. package/dist/{state-DSxmHPn3.js → state-D4SZH6zk.js} +50 -22
  40. package/dist/{static-6g82xguw.js → static-7JCga3Iu.js} +80 -44
  41. package/dist/store-DeMojnXM.d.ts +53 -0
  42. package/dist/time-zone-SBldrUgt.js +59 -0
  43. package/dist/{types-CHdV9FQU.d.ts → types-Cw5LjPuc.d.ts} +62 -8
  44. package/dist/vite.d.ts +255 -2
  45. package/dist/vite.js +6128 -2
  46. package/dist/{wait-until-BmIqRo4x.js → wait-until-Dy4Bn3ZN.js} +26 -1
  47. package/package.json +19 -24
  48. package/dist/definition-CMiOg1lg.js +0 -111
  49. package/dist/error-diagnostics-A_8Kp-48.js +0 -116
  50. package/dist/error-diagnostics-in7mif5s.js +0 -45
  51. package/dist/nuxt.d.ts +0 -17
  52. package/dist/nuxt.js +0 -27
  53. package/dist/operations-gk2qzhYV.js +0 -131
  54. package/dist/store-QAOd8bxm.d.ts +0 -11
  55. package/dist/vite-BAVyZ8hZ.d.ts +0 -474
  56. package/dist/vite-BJwZkMrn.js +0 -5193
@@ -0,0 +1,53 @@
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-Bm9aYLfZ.js";
3
+ //#region src/runtime/execute.d.ts
4
+ interface ExecuteScheduleOptions {
5
+ /** Return the persisted failed run when the handler throws. Guards still throw. */
6
+ 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
+ claimed?: boolean;
12
+ definition: ScheduleDefinition;
13
+ /** Signals that the handler can start, or an existing run already consumed this occurrence. */
14
+ onExecution?: () => void;
15
+ runStore?: ScheduleRunStore;
16
+ runIdSuffix?: string;
17
+ scheduleId: string;
18
+ source?: "direct" | "manual" | "started" | "static";
19
+ scheduledAt?: Date;
20
+ target: string;
21
+ waitUntil?: (promise: PromiseLike<unknown>) => void;
22
+ }
23
+ interface ExecuteStaticScheduleOptions {
24
+ claimed?: boolean;
25
+ cron: string;
26
+ definition: ScheduleDefinition;
27
+ name: string;
28
+ onExecution?: () => void;
29
+ scheduledAt?: Date;
30
+ waitUntil?: (promise: PromiseLike<unknown>) => void;
31
+ }
32
+ interface RunScheduleOptions {
33
+ /**
34
+ * The time the handler receives as `scheduledAt`, as if the cron fired then. A string is an ISO 8601 date-time with a
35
+ * time zone, such as `"2026-01-31T23:59:00Z"`. Defaults to now. The run records this time.
36
+ */
37
+ scheduledAt?: Date | string;
38
+ }
39
+ declare function createScheduleRun(options: Omit<ExecuteScheduleOptions, "definition" | "waitUntil">): Promise<ScheduleRunRecord>;
40
+ declare function executeSchedule(options: ExecuteScheduleOptions): Promise<ScheduleRunRecord>;
41
+ declare function executeStaticSchedule(options: ExecuteStaticScheduleOptions): Promise<ScheduleRunRecord>;
42
+ /** Runs a manually dispatchable static Schedule Definition of `registry` immediately. */
43
+ declare function runScheduleFrom(registry: ScheduleDefinitionRegistry, name: string, options?: RunScheduleOptions): Promise<ScheduleRunRecord>;
44
+ //#endregion
45
+ //#region src/runtime/store.d.ts
46
+ interface KVScheduleStoreOptions {
47
+ kvStore: ScheduleKVStorage;
48
+ prefix?: string;
49
+ }
50
+ declare function createMemoryScheduleRunStore(): ScheduleRunStore;
51
+ declare function createKVScheduleRunStore(options: KVScheduleStoreOptions): ScheduleRunStore;
52
+ //#endregion
53
+ export { createScheduleRun as a, runScheduleFrom as c, RunScheduleOptions as i, createKVScheduleRunStore as n, executeSchedule as o, createMemoryScheduleRunStore as r, executeStaticSchedule as s, KVScheduleStoreOptions as t };
@@ -0,0 +1,59 @@
1
+ //#region ../internal/src/runtime/time-zone.ts
2
+ const slashlessIanaTimeZones = /* @__PURE__ */ new Set([
3
+ "CET",
4
+ "CST6CDT",
5
+ "Cuba",
6
+ "EET",
7
+ "EST",
8
+ "EST5EDT",
9
+ "Egypt",
10
+ "Eire",
11
+ "Factory",
12
+ "GB",
13
+ "GB-Eire",
14
+ "GMT",
15
+ "GMT+0",
16
+ "GMT-0",
17
+ "GMT0",
18
+ "Greenwich",
19
+ "HST",
20
+ "Hongkong",
21
+ "Iceland",
22
+ "Iran",
23
+ "Israel",
24
+ "Jamaica",
25
+ "Japan",
26
+ "Kwajalein",
27
+ "Libya",
28
+ "MET",
29
+ "MST",
30
+ "MST7MDT",
31
+ "NZ",
32
+ "NZ-CHAT",
33
+ "Navajo",
34
+ "PRC",
35
+ "PST8PDT",
36
+ "Poland",
37
+ "Portugal",
38
+ "ROC",
39
+ "ROK",
40
+ "Singapore",
41
+ "Turkey",
42
+ "UCT",
43
+ "UTC",
44
+ "Universal",
45
+ "W-SU",
46
+ "WET",
47
+ "Zulu"
48
+ ]);
49
+ function isIanaTimeZone(timeZone) {
50
+ if (typeof timeZone !== "string" || !timeZone.includes("/") && !slashlessIanaTimeZones.has(timeZone)) return false;
51
+ try {
52
+ new Intl.DateTimeFormat("en-US", { timeZone });
53
+ return true;
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
58
+ //#endregion
59
+ export { isIanaTimeZone as t };
@@ -3,6 +3,14 @@ import { SerializedResponse } from "@vite-hub/runtime";
3
3
  interface ScheduleRunContext {
4
4
  id: string;
5
5
  attemptId?: string;
6
+ /** The `payload` that `startSchedule()` stored. Absent for a run on the Definition's own cron. */
7
+ payload?: unknown;
8
+ /**
9
+ * Key derived from `scheduledAt`: `schedule:<name>:<scheduledAt ISO>`. Cloudflare and the Process Runtime retain
10
+ * occurrence identity. Vercel, Netlify, and Deno estimate it from callback time, so a late delivery or retry across
11
+ * a host cron boundary can have a different key. Pass it to Queue, Email, or a Channel to dedupe the same key.
12
+ */
13
+ idempotencyKey: string;
6
14
  runId?: string;
7
15
  scheduleId?: string;
8
16
  scheduledAt: Date;
@@ -14,25 +22,30 @@ type ScheduleHandler<TResult = unknown> = {
14
22
  bivarianceHack(context: ScheduleRunContext): TResult | Promise<TResult>;
15
23
  }["bivarianceHack"];
16
24
  interface ScheduleDefinitionInput<TResult = unknown> {
17
- /** Allows `runSchedule()`, the Console, and `vitehub schedule run` to start this definition outside its cron. */
25
+ /** Allows `runSchedule()`, the Console, and `vitehub schedule run` to start a Definition with `cron` outside its cron. */
18
26
  manual?: boolean;
19
- /** Five-field cron expression, evaluated in `timeZone`. */
20
- cron: string;
27
+ /**
28
+ * Five-field cron expression, evaluated in `timeZone`. Leave it out for a Schedule that runs only when code starts it
29
+ * with `startSchedule()`.
30
+ */
31
+ cron?: string;
21
32
  handler: ScheduleHandler<TResult>;
22
33
  /**
23
- * IANA time zone of `cron`, such as `"Europe/Madrid"`. Defaults to `"UTC"`. The process driver follows daylight
24
- * saving time. Provider cron output (Cloudflare, Vercel, Netlify, Deno) supports only UTC.
34
+ * IANA time zone of `cron`, such as `"Europe/Madrid"`. Defaults to `"UTC"`. Every host follows daylight saving time:
35
+ * a skipped local time runs once, shifted by the gap, and a repeated local time runs once. For host cron output
36
+ * (Cloudflare, Vercel, Netlify, Deno), write it as a string literal so the build can read it.
25
37
  */
26
38
  timeZone?: string;
27
39
  }
28
40
  interface ScheduleDefinitionOptions {
29
- /** Allows `runSchedule()`, the Console, and `vitehub schedule run` to start this definition outside its cron. */
41
+ /** Allows `runSchedule()`, the Console, and `vitehub schedule run` to start a Definition with `cron` outside its cron. */
30
42
  manual?: boolean;
31
43
  /** IANA time zone of the cron, such as `"Europe/Madrid"`. Defaults to `"UTC"`. */
32
44
  timeZone?: string;
33
45
  }
34
46
  interface ScheduleDefinition<TResult = unknown> {
35
- cron: string;
47
+ /** Absent for a Schedule that runs only when code starts it with `startSchedule()`. */
48
+ cron?: string;
36
49
  handler: ScheduleHandler<TResult>;
37
50
  /** IANA time zone of `cron`. Absent means UTC. */
38
51
  timeZone?: string;
@@ -79,6 +92,8 @@ interface ScheduleRunAttemptRecord {
79
92
  updatedAt: Date;
80
93
  }
81
94
  interface ScheduleRunListOptions {
95
+ /** Only records whose ID starts with this prefix. Applied before `limit`. */
96
+ idPrefix?: string;
82
97
  /** Maximum number of records, newest scheduled occurrence first. */
83
98
  limit?: number;
84
99
  scheduleId?: string;
@@ -101,6 +116,8 @@ interface ScheduleRunStore {
101
116
  }
102
117
  interface DiscoveredScheduleDefinition {
103
118
  manual?: boolean;
119
+ /** True when the Definition declares no `cron`, so it runs only when code starts it with `startSchedule()`. */
120
+ startable?: boolean;
104
121
  /** Plugin that contributed the Definition through `vitehub.schedules`. Only set for contributed Definitions. */
105
122
  contributor?: string;
106
123
  handler: string;
@@ -109,5 +126,42 @@ interface DiscoveredScheduleDefinition {
109
126
  reason?: string;
110
127
  source?: "server-schedules" | "vite-plugin-contribution" | "vite-suffix";
111
128
  }
129
+ /** When a started Schedule runs: once at `at`, or on each occurrence of `cron` until you cancel it. */
130
+ type StartScheduleTiming = {
131
+ /** One run at this time: a `Date`, or an ISO 8601 date-time with a time zone, such as `"2026-11-08T09:00:00Z"`. */
132
+ at: Date | string;
133
+ cron?: never;
134
+ timeZone?: never;
135
+ } | {
136
+ at?: never;
137
+ /** Five-field cron expression. The Schedule runs on each occurrence until you cancel it. */
138
+ cron: string;
139
+ /** IANA time zone of `cron`, such as `"Europe/Madrid"`. Defaults to `"UTC"`. */
140
+ timeZone?: string;
141
+ };
142
+ type StartScheduleOptions = StartScheduleTiming & {
143
+ /** JSON value that the handler receives as `context.payload`. */
144
+ payload?: unknown;
145
+ };
146
+ /** A Schedule that code started with `startSchedule()`. It stays in the store until its last run or `cancelSchedule()`. */
147
+ interface StartedSchedule {
148
+ /** One-time run. Absent for a cron Schedule. */
149
+ at?: Date;
150
+ createdAt: Date;
151
+ cron?: string;
152
+ /** Pass it to `getSchedule()` and `cancelSchedule()`. Its runs use it as `scheduleId`. */
153
+ id: string;
154
+ payload?: unknown;
155
+ /** Name of the Schedule Definition that runs. */
156
+ name: string;
157
+ timeZone?: string;
158
+ }
159
+ /** Stores the Schedules that code started. Records do not change after `put()`. */
160
+ interface StartedScheduleStore {
161
+ delete: (id: string) => Promise<boolean>;
162
+ get: (id: string) => Promise<StartedSchedule | undefined>;
163
+ list: () => Promise<StartedSchedule[]>;
164
+ put: (schedule: StartedSchedule) => Promise<void>;
165
+ }
112
166
  //#endregion
113
- export { ScheduleDefinitionRegistry as a, ScheduleRunAttemptRecord as c, ScheduleRunError as d, ScheduleRunListOptions as f, ScheduleRunStore as g, ScheduleRunStatus as h, ScheduleDefinitionOptions as i, ScheduleRunAttemptStatus as l, ScheduleRunResponse as m, ScheduleDefinition as n, ScheduleHandler as o, ScheduleRunRecord as p, ScheduleDefinitionInput as r, ScheduleRegistryDefinition as s, DiscoveredScheduleDefinition as t, ScheduleRunContext as u };
167
+ export { StartScheduleOptions as _, ScheduleDefinitionRegistry as a, StartedScheduleStore as b, ScheduleRunAttemptRecord as c, ScheduleRunError as d, ScheduleRunListOptions as f, ScheduleRunStore as g, ScheduleRunStatus as h, ScheduleDefinitionOptions as i, ScheduleRunAttemptStatus as l, ScheduleRunResponse as m, ScheduleDefinition as n, ScheduleHandler as o, ScheduleRunRecord as p, ScheduleDefinitionInput as r, ScheduleRegistryDefinition as s, DiscoveredScheduleDefinition as t, ScheduleRunContext as u, StartScheduleTiming as v, StartedSchedule as y };
package/dist/vite.d.ts CHANGED
@@ -1,2 +1,255 @@
1
- import { _ as ScheduleContributionContext, a as createScheduleNitroConfig, c as ScheduleInspectionOptions, d as ScheduleDiscoveryOptions, f as contributedScheduleSource, g as ScheduleContribution, h as ScheduleContributingPlugin, i as ScheduleVitePluginOptions, l as inspectScheduleDefinitions, m as CollectedScheduleContribution, n as ScheduleProcessRuntimeOptions, o as hubSchedule, p as discoverScheduleDefinitions, r as ScheduleVitePlugin, s as readScheduleDefinitionCrons, t as ScheduleNitroConfigOptions, u as scheduleConsoleSection, v as ScheduleContributionFactory, y as collectScheduleContributions } from "./vite-BAVyZ8hZ.js";
2
- export { type CollectedScheduleContribution, type ScheduleContributingPlugin, type ScheduleContribution, type ScheduleContributionContext, type ScheduleContributionFactory, type ScheduleDiscoveryOptions, type ScheduleInspectionOptions, ScheduleNitroConfigOptions, ScheduleProcessRuntimeOptions, ScheduleVitePlugin, ScheduleVitePluginOptions, collectScheduleContributions, contributedScheduleSource, createScheduleNitroConfig, discoverScheduleDefinitions, hubSchedule, inspectScheduleDefinitions, readScheduleDefinitionCrons, scheduleConsoleSection };
1
+ import { t as DiscoveredScheduleDefinition } from "./types-Cw5LjPuc.js";
2
+ import { n as OperationContributionEntry } from "./operation-definition-nmRu_O3V.js";
3
+ import { i as ViteHubInspectionPluginMetadata, n as ViteHubConsoleRuntimeRecordTableSection, r as ViteHubDefinitionSummary } from "./console-wEhr0LWn.js";
4
+ //#region ../internal/src/deployment.d.ts
5
+ /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
6
+ type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
7
+ //#endregion
8
+ //#region ../internal/src/build/deployment-plan-output.d.ts
9
+ /**
10
+ * One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
11
+ * a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
12
+ * It holds names only, so `vitehub deploy` can check the host without booting Vite. It never holds a value.
13
+ */
14
+ interface DeploymentEnvEntry {
15
+ /** The declaration path, such as `env.server.github.token`, when it is safe to show. Primitive entries have none. */
16
+ path?: string;
17
+ /** The host variable names, in read order. The first name that is set supplies the value. */
18
+ names: readonly string[];
19
+ /** Any variable whose name starts with this prefix supplies the value, such as `VITEHUB_CONSOLE_KEY_`. */
20
+ prefix?: string;
21
+ required: boolean;
22
+ secret: boolean;
23
+ /** A default supplies the value when no name is set. */
24
+ hasDefault: boolean;
25
+ /** The primitives that read these names, such as `blob`. Server Env declarations have none. */
26
+ owners?: readonly string[];
27
+ }
28
+ /** What a primitive needs to know to name the variables it reads in the deployed app. */
29
+ interface DeploymentEnvContext {
30
+ host: ViteHubHost;
31
+ }
32
+ /**
33
+ * The host variables that a primitive reads itself, outside the Server Env registry, for one host and its resolved
34
+ * config. A Vite plugin exposes it as `api.deploymentEnv`, and the build writes the result to `deployment.json`.
35
+ * Return names only, never values.
36
+ */
37
+ type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
38
+ //#endregion
39
+ //#region ../internal/src/durability.d.ts
40
+ /**
41
+ * One durability reporter that a primitive's Vite plugin contributes through `vitehub.durability`. The Node server
42
+ * imports `export` from `module` at boot and calls it with `input` and the server environment. It returns the
43
+ * `Durability` lines of `@vite-hub/runtime/durability`.
44
+ */
45
+ interface DurabilityContribution {
46
+ /** The primitive that the reporter describes, such as `kv`. Other reporters find its result by this id. */
47
+ primitive: string;
48
+ /** The absolute file of the reporter module. */
49
+ module: string;
50
+ export: string;
51
+ /**
52
+ * The resolved configuration of the primitive, as plain JSON data. The build writes it into the server with
53
+ * `JSON.stringify`, so do not put credentials here.
54
+ */
55
+ input: unknown;
56
+ }
57
+ /** The `vitehub.durability` field of a primitive's Vite plugin. */
58
+ interface DurabilityPluginMetadata {
59
+ /** Called after Vite resolves the config. Return an empty list when the primitive is off. */
60
+ durability?: () => readonly DurabilityContribution[];
61
+ }
62
+ //#endregion
63
+ //#region ../internal/src/contributions.d.ts
64
+ /** Module and export that hold a contributed Definition. */
65
+ interface ContributionDefinition {
66
+ /**
67
+ * Absolute file path, `file:` URL, or package specifier that the application can import. Relative paths are
68
+ * rejected because they have no stable base.
69
+ */
70
+ module: string;
71
+ /** Named export that holds the Definition. Defaults to `default`. */
72
+ export?: string;
73
+ }
74
+ /**
75
+ * One Definition that a Vite plugin adds to a Server Primitive, for example a Workspace, a Schedule, or Database tables.
76
+ * Every owner package reads this shape from `plugin.vitehub.<key>`. Owners can add fields, such as `database`.
77
+ */
78
+ interface Contribution {
79
+ /** Unique name in the owner, for example the Workspace or Schedule name. */
80
+ name: string;
81
+ definition: ContributionDefinition;
82
+ /** Why the plugin adds the Definition. `vitehub inspect` and the Console show it. */
83
+ reason?: string;
84
+ }
85
+ /** Roots that ViteHub passes to every contribution factory. */
86
+ interface ContributionContext {
87
+ /** Vite root. */
88
+ root: string;
89
+ /** ViteHub project root. It can differ from the Vite root, for example in a Nuxt app with a `srcDir`. */
90
+ projectRoot: string;
91
+ /** Server directories that the host forwards, for example Nuxt's `serverDir` and the server directories of layers. */
92
+ serverDirs?: readonly string[];
93
+ }
94
+ /**
95
+ * Returns the contributions of a plugin. It runs once per discovery pass, so it must be idempotent and must not depend
96
+ * on the order of Vite config hooks.
97
+ */
98
+ type ContributionFactory<TEntry extends Contribution = Contribution> = (context: ContributionContext) => readonly TEntry[] | undefined | Promise<readonly TEntry[] | undefined>;
99
+ type ContributionSource<TEntry extends Contribution = Contribution> = readonly TEntry[] | ContributionFactory<TEntry>;
100
+ /** A Vite plugin that contributes Definitions under `vitehub[TKey]`. */
101
+ type ContributingPlugin<TKey extends string, TEntry extends Contribution = Contribution> = {
102
+ name?: string;
103
+ vitehub?: { [K in TKey]?: ContributionSource<TEntry>; };
104
+ };
105
+ /** A validated contribution with its export resolved and the name of the plugin that added it. */
106
+ interface CollectedContribution {
107
+ name: string;
108
+ definition: {
109
+ module: string;
110
+ export: string;
111
+ };
112
+ reason?: string;
113
+ /** Name of the contributing Vite plugin. */
114
+ plugin: string;
115
+ }
116
+ //#endregion
117
+ //#region src/contributions.d.ts
118
+ /**
119
+ * A Schedule Definition that another package adds from its Vite plugin. The Schedule plugin merges it with the
120
+ * discovered files, so provider wake output, the Process Runtime, `vitehub schedule run`, inspection,
121
+ * and the Console treat it like `server/schedules/<name>.ts`.
122
+ *
123
+ * The build reads the cron and the `manual` option from the source of the Definition module without running it, as it
124
+ * does for discovered files. `definition.module` must therefore be an absolute file path or `file:` URL, and
125
+ * `definition.export` must be `default`: `export default defineSchedule({ cron: "...", handler })` with literal options.
126
+ */
127
+ type ScheduleContribution = Contribution;
128
+ /** Roots that ViteHub passes to contribution factories. `root` is the Vite root. */
129
+ type ScheduleContributionContext = ContributionContext;
130
+ type ScheduleContributionFactory = ContributionFactory<ScheduleContribution>;
131
+ /** A Vite plugin that contributes Schedule Definitions through `vitehub.schedules`. */
132
+ type ScheduleContributingPlugin = ContributingPlugin<"schedules", ScheduleContribution>;
133
+ /** A validated contribution with the name of the plugin that contributed it. */
134
+ type CollectedScheduleContribution = CollectedContribution;
135
+ /**
136
+ * Collects `vitehub.schedules` contributions from Vite plugins. Two contributions with one name fail with
137
+ * `SCHEDULE_B0006`. Invalid entries fail with `SCHEDULE_B0007`.
138
+ */
139
+ export declare function collectScheduleContributions(plugins: readonly unknown[] | undefined, context: ScheduleContributionContext): Promise<CollectedScheduleContribution[]>;
140
+ //#endregion
141
+ //#region src/discovery.d.ts
142
+ /** Discovery source of Schedule Definitions that Vite plugins contribute through `vitehub.schedules`. */
143
+ export declare const contributedScheduleSource = "vite-plugin-contribution";
144
+ interface ScheduleDiscoveryOptions {
145
+ /** Schedule Definitions that Vite plugins contribute. See `collectScheduleContributions()`. */
146
+ contributions?: readonly CollectedScheduleContribution[];
147
+ mode?: "vite-suffix";
148
+ rootDir: string;
149
+ scanDirs?: string[];
150
+ serverDirs?: string[];
151
+ serverRootDir?: string;
152
+ }
153
+ type DiscoverScheduleDefinitionsOptions = ScheduleDiscoveryOptions | {
154
+ mode: "server-schedules";
155
+ scanDirs: string[];
156
+ };
157
+ /**
158
+ * Discovers the Schedule Definitions that run on a cron. When a Definition has no `cron`, it adds the
159
+ * `vitehub/started-schedules` Schedule, which runs the Schedules that code starts with `startSchedule()`.
160
+ * `discoverStartableScheduleDefinitions()` lists the Definitions without `cron`.
161
+ */
162
+ export declare function discoverScheduleDefinitions(options: DiscoverScheduleDefinitionsOptions): DiscoveredScheduleDefinition[];
163
+ /** Discovers the Schedule Definitions without `cron`. Only `startSchedule()` runs them. */
164
+ export declare function discoverStartableScheduleDefinitions(options: DiscoverScheduleDefinitionsOptions): DiscoveredScheduleDefinition[];
165
+ //#endregion
166
+ //#region src/inspect.d.ts
167
+ interface ScheduleInspectionOptions {
168
+ /** Cron per Schedule name that this build's host runs in place of the declared cron. */
169
+ cron?: Readonly<Record<string, string>>;
170
+ /** Vite plugins that can contribute Schedule Definitions through `vitehub.schedules`. */
171
+ plugins?: readonly unknown[];
172
+ projectRoot: string;
173
+ rootDir: string;
174
+ serverDirs?: string[];
175
+ serverRootDir: string;
176
+ }
177
+ /**
178
+ * Lists Schedule Definitions with their static cron when the Definition declares one, or the build's `cron` for it.
179
+ * Contributed Definitions name the plugin that added them and its reason.
180
+ */
181
+ export declare function inspectScheduleDefinitions(options: ScheduleInspectionOptions): Promise<ViteHubDefinitionSummary[]>;
182
+ /**
183
+ * Console section for Schedules. Records list discovered Schedule Definitions. When the server runs the Process Runtime,
184
+ * 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
186
+ * that a runtime recorded.
187
+ */
188
+ export declare const scheduleConsoleSection: ViteHubConsoleRuntimeRecordTableSection<ScheduleInspectionOptions>;
189
+ //#endregion
190
+ //#region src/vite.d.ts
191
+ export declare function readScheduleDefinitionCrons(definitions: DiscoveredScheduleDefinition[]): Promise<Map<string, string>>;
192
+ export interface ScheduleProcessRuntimeOptions {
193
+ catchUpMs?: number;
194
+ concurrency?: number;
195
+ driver: "process";
196
+ intervalMs?: number;
197
+ /** Milliseconds that a server holds an occurrence after it stops, before another server may run it. Defaults to `60000`. */
198
+ leaseTtlMs?: number;
199
+ prefix?: string;
200
+ }
201
+ export interface ScheduleOptions {
202
+ /**
203
+ * Cron per Schedule name for this build's host, in place of the cron that the Schedule declares. Set it in the
204
+ * host's build config, such as `{ cleanup: "0 0 * * *" }` for Vercel Hobby, which runs cron jobs at most once a day.
205
+ */
206
+ cron?: Readonly<Record<string, string>>;
207
+ providerOutput?: "auto" | "standalone" | "nitro" | false;
208
+ projectRoot?: string;
209
+ runtime?: ScheduleProcessRuntimeOptions;
210
+ }
211
+ export interface ScheduleNitroConfigOptions extends ScheduleOptions {
212
+ command?: "build" | "serve";
213
+ /** @internal Resolve generated Nitro registrations from the ViteHub project root. */
214
+ nitroOwnsPaths?: boolean;
215
+ nitro?: unknown;
216
+ /** Vite plugins that can contribute Schedule Definitions through `vitehub.schedules`. */
217
+ plugins?: readonly unknown[];
218
+ root?: string;
219
+ /** @internal Framework-resolved server definition directories. */
220
+ serverDirs?: string[];
221
+ }
222
+ export interface ScheduleVitePlugin {
223
+ name: string;
224
+ /** The variables that Schedules read on the deployed host. See `scheduleDeploymentEnv()`. */
225
+ api?: {
226
+ deploymentEnv: DeploymentEnvContribution;
227
+ };
228
+ [hook: string]: unknown;
229
+ vitehub?: ViteHubInspectionPluginMetadata & DurabilityPluginMetadata & {
230
+ operations?: readonly OperationContributionEntry[];
231
+ };
232
+ }
233
+ type NitroConfig = Record<string, unknown> & {
234
+ cloudflare?: {
235
+ wrangler?: {
236
+ triggers?: {
237
+ crons?: string[];
238
+ } & Record<string, unknown>;
239
+ } & Record<string, unknown>;
240
+ } & Record<string, unknown>;
241
+ modules?: unknown[];
242
+ plugins?: unknown[];
243
+ vercel?: {
244
+ config?: {
245
+ crons?: Array<{
246
+ path: string;
247
+ schedule: string;
248
+ }>;
249
+ } & Record<string, unknown>;
250
+ } & Record<string, unknown>;
251
+ };
252
+ export declare function createScheduleNitroConfig(options?: ScheduleNitroConfigOptions): Promise<NitroConfig | null>;
253
+ export declare function hubSchedule(options?: ScheduleOptions): ScheduleVitePlugin;
254
+ //#endregion
255
+ export type { CollectedScheduleContribution, ScheduleContributingPlugin, ScheduleContribution, ScheduleContributionContext, ScheduleContributionFactory, ScheduleDiscoveryOptions, ScheduleInspectionOptions };