@vite-hub/schedule 0.4.1 → 0.5.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 (53) hide show
  1. package/README.md +12 -7
  2. package/dist/{console-wEhr0LWn.d.ts → console-DFI1QBkP.d.ts} +2 -4
  3. package/dist/cron-BT3ef48f.js +68 -0
  4. package/dist/definition.d.ts +2 -4
  5. package/dist/definition.js +4 -6
  6. package/dist/{due-sOJvF_6Z.js → due-D-0trD1g.js} +23 -9
  7. package/dist/durability.d.ts +3 -5
  8. package/dist/durability.js +6 -7
  9. package/dist/{error-diagnostics-BBtYYl8j.js → error-diagnostics-B1AaIGWP.js} +2 -7
  10. package/dist/{error-diagnostics-CQ4BUqRe.js → error-diagnostics-kKXseq8d.js} +10 -3
  11. package/dist/index.d.ts +3 -13
  12. package/dist/index.js +5 -8
  13. package/dist/{started-name-ruCM1EtQ.js → inspect-CW0qwt9p.js} +3 -9
  14. package/dist/{kv-storage-2kZtP2CC.js → kv-storage-Dsr3TL9c.js} +1 -2
  15. package/dist/{kv-storage-Bm9aYLfZ.d.ts → kv-storage-hI2IOjb5.d.ts} +0 -2
  16. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  17. package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CqZkx1Rm.d.ts} +8 -6
  18. package/dist/{operations-DqwmJ8MN.js → operations-BTUQeba1.js} +7 -11
  19. package/dist/operations.d.ts +2 -6
  20. package/dist/operations.js +11 -16
  21. package/dist/os.d.ts +0 -9
  22. package/dist/os.js +23 -104
  23. package/dist/out-By90R-Bo.js +22706 -0
  24. package/dist/rolldown-runtime-DegdyBIC.js +25 -0
  25. package/dist/runtime/console.d.ts +2 -4
  26. package/dist/runtime/console.js +3 -4
  27. package/dist/runtime/kv.d.ts +2 -4
  28. package/dist/runtime/kv.js +2 -3
  29. package/dist/runtime/process.d.ts +1 -3
  30. package/dist/runtime/process.js +28 -52
  31. package/dist/runtime/state.d.ts +1 -1
  32. package/dist/runtime/state.js +1 -2
  33. package/dist/runtime/static.d.ts +2 -73
  34. package/dist/runtime/static.js +3 -2
  35. package/dist/runtime.d.ts +5 -7
  36. package/dist/runtime.js +5 -5
  37. package/dist/{started-B0pc3JY0.js → started-B1Se_Iwo.js} +6 -8
  38. package/dist/{started-Bk2Icknk.js → started-Bzvr4t5f.js} +26 -9
  39. package/dist/{started-errors-DEmYH-vp.js → started-errors-IG9DlT2A.js} +49 -12
  40. package/dist/started-name-w6n9uDdt.js +4 -0
  41. package/dist/{state-CPd10SXq.d.ts → state-BDEDVlyr.d.ts} +3 -6
  42. package/dist/{state-D4SZH6zk.js → state-BZLy46UJ.js} +73 -122
  43. package/dist/static-Bg7Jj92L.js +603 -0
  44. package/dist/static-DeRvJqcQ.d.ts +92 -0
  45. package/dist/{store-DeMojnXM.d.ts → store-CEv3cScg.d.ts} +4 -12
  46. package/dist/{time-zone-SBldrUgt.js → time-zone-pMp_g8Uu.js} +1 -2
  47. package/dist/{types-Cw5LjPuc.d.ts → types-DTVPVY5O.d.ts} +0 -2
  48. package/dist/vite.d.ts +6 -20
  49. package/dist/vite.js +2943 -297
  50. package/package.json +9 -9
  51. package/dist/invariant-DolT9EEx.js +0 -22
  52. package/dist/static-7JCga3Iu.js +0 -281
  53. package/dist/wait-until-Dy4Bn3ZN.js +0 -112
@@ -1,17 +1,11 @@
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
1
+ import { a as ScheduleDefinitionRegistry, g as ScheduleRunStore, n as ScheduleDefinition, p as ScheduleRunRecord } from "./types-DTVPVY5O.js";
2
+ import { t as ScheduleKVStorage } from "./kv-storage-hI2IOjb5.js";
4
3
  interface ExecuteScheduleOptions {
5
- /** Return the persisted failed run when the handler throws. Guards still throw. */
6
4
  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
5
  claimed?: boolean;
12
6
  definition: ScheduleDefinition;
13
- /** Signals that the handler can start, or an existing run already consumed this occurrence. */
14
7
  onExecution?: () => void;
8
+ onRunLogged?: () => void;
15
9
  runStore?: ScheduleRunStore;
16
10
  runIdSuffix?: string;
17
11
  scheduleId: string;
@@ -26,6 +20,7 @@ interface ExecuteStaticScheduleOptions {
26
20
  definition: ScheduleDefinition;
27
21
  name: string;
28
22
  onExecution?: () => void;
23
+ onRunLogged?: () => void;
29
24
  scheduledAt?: Date;
30
25
  waitUntil?: (promise: PromiseLike<unknown>) => void;
31
26
  }
@@ -41,13 +36,10 @@ declare function executeSchedule(options: ExecuteScheduleOptions): Promise<Sched
41
36
  declare function executeStaticSchedule(options: ExecuteStaticScheduleOptions): Promise<ScheduleRunRecord>;
42
37
  /** Runs a manually dispatchable static Schedule Definition of `registry` immediately. */
43
38
  declare function runScheduleFrom(registry: ScheduleDefinitionRegistry, name: string, options?: RunScheduleOptions): Promise<ScheduleRunRecord>;
44
- //#endregion
45
- //#region src/runtime/store.d.ts
46
39
  interface KVScheduleStoreOptions {
47
40
  kvStore: ScheduleKVStorage;
48
41
  prefix?: string;
49
42
  }
50
43
  declare function createMemoryScheduleRunStore(): ScheduleRunStore;
51
44
  declare function createKVScheduleRunStore(options: KVScheduleStoreOptions): ScheduleRunStore;
52
- //#endregion
53
45
  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 };
@@ -1,4 +1,4 @@
1
- //#region ../internal/src/runtime/time-zone.ts
1
+ // ../internal/src/runtime/time-zone.ts
2
2
  const slashlessIanaTimeZones = /* @__PURE__ */ new Set([
3
3
  "CET",
4
4
  "CST6CDT",
@@ -55,5 +55,4 @@ function isIanaTimeZone(timeZone) {
55
55
  return false;
56
56
  }
57
57
  }
58
- //#endregion
59
58
  export { isIanaTimeZone as t };
@@ -1,5 +1,4 @@
1
1
  import { SerializedResponse } from "@vite-hub/runtime";
2
- //#region src/types.d.ts
3
2
  interface ScheduleRunContext {
4
3
  id: string;
5
4
  attemptId?: string;
@@ -163,5 +162,4 @@ interface StartedScheduleStore {
163
162
  list: () => Promise<StartedSchedule[]>;
164
163
  put: (schedule: StartedSchedule) => Promise<void>;
165
164
  }
166
- //#endregion
167
165
  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,11 +1,8 @@
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
1
+ import { i as ViteHubInspectionPluginMetadata, n as ViteHubConsoleRuntimeRecordTableSection, r as ViteHubDefinitionSummary } from "./console-DFI1QBkP.js";
2
+ import { n as OperationContributionEntry } from "./operation-definition-CqZkx1Rm.js";
3
+ import { t as DiscoveredScheduleDefinition } from "./types-DTVPVY5O.js";
5
4
  /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
6
5
  type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
7
- //#endregion
8
- //#region ../internal/src/build/deployment-plan-output.d.ts
9
6
  /**
10
7
  * One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
11
8
  * a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
@@ -35,8 +32,6 @@ interface DeploymentEnvContext {
35
32
  * Return names only, never values.
36
33
  */
37
34
  type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
38
- //#endregion
39
- //#region ../internal/src/durability.d.ts
40
35
  /**
41
36
  * One durability reporter that a primitive's Vite plugin contributes through `vitehub.durability`. The Node server
42
37
  * imports `export` from `module` at boot and calls it with `input` and the server environment. It returns the
@@ -59,8 +54,6 @@ interface DurabilityPluginMetadata {
59
54
  /** Called after Vite resolves the config. Return an empty list when the primitive is off. */
60
55
  durability?: () => readonly DurabilityContribution[];
61
56
  }
62
- //#endregion
63
- //#region ../internal/src/contributions.d.ts
64
57
  /** Module and export that hold a contributed Definition. */
65
58
  interface ContributionDefinition {
66
59
  /**
@@ -90,6 +83,8 @@ interface ContributionContext {
90
83
  projectRoot: string;
91
84
  /** Server directories that the host forwards, for example Nuxt's `serverDir` and the server directories of layers. */
92
85
  serverDirs?: readonly string[];
86
+ /** The flat list of Vite plugins, so a factory can read what sibling plugins declare. */
87
+ plugins?: readonly unknown[];
93
88
  }
94
89
  /**
95
90
  * Returns the contributions of a plugin. It runs once per discovery pass, so it must be idempotent and must not depend
@@ -113,8 +108,6 @@ interface CollectedContribution {
113
108
  /** Name of the contributing Vite plugin. */
114
109
  plugin: string;
115
110
  }
116
- //#endregion
117
- //#region src/contributions.d.ts
118
111
  /**
119
112
  * A Schedule Definition that another package adds from its Vite plugin. The Schedule plugin merges it with the
120
113
  * discovered files, so provider wake output, the Process Runtime, `vitehub schedule run`, inspection,
@@ -137,8 +130,6 @@ type CollectedScheduleContribution = CollectedContribution;
137
130
  * `SCHEDULE_B0006`. Invalid entries fail with `SCHEDULE_B0007`.
138
131
  */
139
132
  export declare function collectScheduleContributions(plugins: readonly unknown[] | undefined, context: ScheduleContributionContext): Promise<CollectedScheduleContribution[]>;
140
- //#endregion
141
- //#region src/discovery.d.ts
142
133
  /** Discovery source of Schedule Definitions that Vite plugins contribute through `vitehub.schedules`. */
143
134
  export declare const contributedScheduleSource = "vite-plugin-contribution";
144
135
  interface ScheduleDiscoveryOptions {
@@ -162,8 +153,6 @@ type DiscoverScheduleDefinitionsOptions = ScheduleDiscoveryOptions | {
162
153
  export declare function discoverScheduleDefinitions(options: DiscoverScheduleDefinitionsOptions): DiscoveredScheduleDefinition[];
163
154
  /** Discovers the Schedule Definitions without `cron`. Only `startSchedule()` runs them. */
164
155
  export declare function discoverStartableScheduleDefinitions(options: DiscoverScheduleDefinitionsOptions): DiscoveredScheduleDefinition[];
165
- //#endregion
166
- //#region src/inspect.d.ts
167
156
  interface ScheduleInspectionOptions {
168
157
  /** Cron per Schedule name that this build's host runs in place of the declared cron. */
169
158
  cron?: Readonly<Record<string, string>>;
@@ -182,12 +171,10 @@ export declare function inspectScheduleDefinitions(options: ScheduleInspectionOp
182
171
  /**
183
172
  * Console section for Schedules. Records list discovered Schedule Definitions. When the server runs the Process Runtime,
184
173
  * 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
174
+ * `vitehub inspect definitions` reads the same Definitions from source, and `vitehub schedule runs list <name>` lists the runs
186
175
  * that a runtime recorded.
187
176
  */
188
177
  export declare const scheduleConsoleSection: ViteHubConsoleRuntimeRecordTableSection<ScheduleInspectionOptions>;
189
- //#endregion
190
- //#region src/vite.d.ts
191
178
  export declare function readScheduleDefinitionCrons(definitions: DiscoveredScheduleDefinition[]): Promise<Map<string, string>>;
192
179
  export interface ScheduleProcessRuntimeOptions {
193
180
  catchUpMs?: number;
@@ -251,5 +238,4 @@ type NitroConfig = Record<string, unknown> & {
251
238
  };
252
239
  export declare function createScheduleNitroConfig(options?: ScheduleNitroConfigOptions): Promise<NitroConfig | null>;
253
240
  export declare function hubSchedule(options?: ScheduleOptions): ScheduleVitePlugin;
254
- //#endregion
255
241
  export type { CollectedScheduleContribution, ScheduleContributingPlugin, ScheduleContribution, ScheduleContributionContext, ScheduleContributionFactory, ScheduleDiscoveryOptions, ScheduleInspectionOptions };