@vite-hub/schedule 0.1.0 → 0.3.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.
- package/README.md +114 -96
- package/dist/console-wEhr0LWn.d.ts +330 -0
- package/dist/definition.d.ts +6 -2
- package/dist/definition.js +47 -1
- package/dist/due-BVMRQ93v.js +144 -0
- package/dist/durability.d.ts +14 -0
- package/dist/durability.js +23 -0
- package/dist/error-diagnostics-DSkCJC_L.js +266 -0
- package/dist/error-diagnostics-Mpeks7J0.js +166 -0
- package/dist/index.d.ts +59 -5
- package/dist/index.js +27 -2
- package/dist/invariant-DolT9EEx.js +22 -0
- package/dist/{kv-storage-Bv9ocZT-.d.ts → kv-storage-C0KZZB6v.d.ts} +2 -2
- package/dist/{kv-storage-DWinmLLy.js → kv-storage-iJChCS5A.js} +2 -2
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/{operations-tNUdj3G4.d.ts → operation-definition-8gOe-ubD.d.ts} +37 -15
- package/dist/{operations-gk2qzhYV.js → operations-DwZWFIUX.js} +75 -22
- package/dist/operations.d.ts +27 -4
- package/dist/operations.js +127 -730
- package/dist/os.d.ts +167 -0
- package/dist/os.js +1659 -0
- package/dist/runtime/console.d.ts +12 -0
- package/dist/runtime/console.js +85 -0
- package/dist/runtime/kv.d.ts +1 -1
- package/dist/runtime/kv.js +1 -1
- package/dist/runtime/process.d.ts +32 -5
- package/dist/runtime/process.js +401 -413
- package/dist/runtime/state.d.ts +2 -9
- package/dist/runtime/state.js +2 -2
- package/dist/runtime/static.d.ts +28 -2
- package/dist/runtime/static.js +2 -2
- package/dist/runtime.d.ts +34 -32
- package/dist/runtime.js +6 -5
- package/dist/started-BuGmnus4.js +201 -0
- package/dist/started-Bx7MDbrl.js +146 -0
- package/dist/{execute-BJrgNgQ0.js → started-errors-p7cu_rI7.js} +69 -20
- package/dist/{state-DSxmHPn3.js → state-B-Fuyfb4.js} +42 -22
- package/dist/state-Do2wV4Tx.d.ts +49 -0
- package/dist/{static-6g82xguw.js → static-DQwzzvPg.js} +63 -42
- package/dist/store-Df0-fzCl.d.ts +53 -0
- package/dist/time-zone-SBldrUgt.js +59 -0
- package/dist/{types-CHdV9FQU.d.ts → types-Cw5LjPuc.d.ts} +62 -8
- package/dist/vite.d.ts +255 -2
- package/dist/vite.js +5876 -2
- package/dist/{wait-until-BmIqRo4x.js → wait-until-Dy4Bn3ZN.js} +26 -1
- package/package.json +19 -24
- package/dist/definition-CMiOg1lg.js +0 -111
- package/dist/error-diagnostics-A_8Kp-48.js +0 -116
- package/dist/error-diagnostics-in7mif5s.js +0 -45
- package/dist/nuxt.d.ts +0 -17
- package/dist/nuxt.js +0 -27
- package/dist/store-QAOd8bxm.d.ts +0 -11
- package/dist/vite-BAVyZ8hZ.d.ts +0 -474
- package/dist/vite-BJwZkMrn.js +0 -5193
|
@@ -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
|
|
25
|
+
/** Allows `runSchedule()`, the Console, and `vitehub schedule run` to start a Definition with `cron` outside its cron. */
|
|
18
26
|
manual?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
|
|
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"`.
|
|
24
|
-
*
|
|
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
|
|
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
|
-
|
|
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 {
|
|
2
|
-
|
|
1
|
+
import { t as DiscoveredScheduleDefinition } from "./types-Cw5LjPuc.js";
|
|
2
|
+
import { n as OperationContributionEntry } from "./operation-definition-8gOe-ubD.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 };
|