@vite-hub/queue 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 (60) hide show
  1. package/README.md +152 -29
  2. package/dist/client-B53_G4ky.js +182 -0
  3. package/dist/{cloudflare-client-COzQ8fHk.js → cloudflare-client-CoISDpIx.js} +28 -21
  4. package/dist/{cloudflare-resource-name-CCuLDvSP.js → cloudflare-resource-name-BIfBglC2.js} +1 -1
  5. package/dist/config-B2eaXaT5.js +105 -0
  6. package/dist/durability.d.ts +13 -0
  7. package/dist/durability.js +47 -0
  8. package/dist/duration-tujyhAKt.js +111 -0
  9. package/dist/error-diagnostics-CQ4BUqRe.js +270 -0
  10. package/dist/error-diagnostics-mJXBjmQx.js +181 -0
  11. package/dist/{handler-response-CBwIkmTS.js → handler-response-B6lz9nCn.js} +9 -4
  12. package/dist/index.d.ts +20 -32
  13. package/dist/index.js +39 -17
  14. package/dist/internal/runtime/cloudflare-client.d.ts +2 -2
  15. package/dist/internal/runtime/cloudflare-client.js +1 -1
  16. package/dist/internal/runtime/cloudflare-vite.d.ts +30 -2
  17. package/dist/internal/runtime/cloudflare-vite.js +111 -1
  18. package/dist/internal/runtime/local-client.d.ts +17 -0
  19. package/dist/internal/runtime/local-client.js +71 -0
  20. package/dist/internal/runtime/postgres-client.d.ts +46 -0
  21. package/dist/internal/runtime/postgres-client.js +570 -0
  22. package/dist/internal/runtime/state.d.ts +11 -4
  23. package/dist/internal/runtime/state.js +2 -2
  24. package/dist/internal/runtime/vercel-client.d.ts +2 -2
  25. package/dist/internal/runtime/vercel-client.js +66 -28
  26. package/dist/internal/runtime/worker-client.d.ts +6 -0
  27. package/dist/internal/runtime/worker-client.js +11 -0
  28. package/dist/invariant-D8_xBqmZ.js +22 -0
  29. package/dist/local-CUaWoRUx.d.ts +23 -0
  30. package/dist/local-Di0FrVUw.js +553 -0
  31. package/dist/object-D8pRdprI.js +15 -0
  32. package/dist/{operations-tNUdj3G4.d.ts → operation-definition-nmRu_O3V.d.ts} +42 -15
  33. package/dist/operations-BVV-9Q0N.js +129 -0
  34. package/dist/operations.d.ts +47 -9
  35. package/dist/operations.js +186 -69
  36. package/dist/runtime/hosted.d.ts +3 -5
  37. package/dist/runtime/hosted.js +21 -45
  38. package/dist/{state-G9s378-e.js → state-DLqTqF6V.js} +59 -47
  39. package/dist/types-CiuSIPR0.d.ts +440 -0
  40. package/dist/types-Dsbb_Pvp.d.ts +10 -0
  41. package/dist/vercel-region-B95MAMXN.js +26 -0
  42. package/dist/virtual.d.ts +4 -0
  43. package/dist/vite.d.ts +366 -49
  44. package/dist/vite.js +2071 -2
  45. package/package.json +39 -46
  46. package/dist/client-CIc3jsj2.js +0 -114
  47. package/dist/cloudflare-vite-BCuJOXcT.js +0 -111
  48. package/dist/cloudflare-vite-CjdP5yBN.d.ts +0 -29
  49. package/dist/config-BINujLv4.js +0 -74
  50. package/dist/enqueue-CnQ0QR3O.js +0 -22
  51. package/dist/error-diagnostics-A_8Kp-48.js +0 -116
  52. package/dist/error-diagnostics-qzRF6IVB.js +0 -109
  53. package/dist/errors-DIFaM9tW.js +0 -42
  54. package/dist/nuxt.d.ts +0 -39
  55. package/dist/nuxt.js +0 -34
  56. package/dist/object-B1NW521B.js +0 -7
  57. package/dist/operations-Cnjbz8kk.js +0 -63
  58. package/dist/types-1GRMYES1.d.ts +0 -180
  59. package/dist/vercel-region-cjskrOKl.js +0 -122
  60. package/dist/vite-ChWLzOVu.js +0 -1512
package/dist/vite.d.ts CHANGED
@@ -1,7 +1,135 @@
1
- import { h as QueueModuleOptions, o as DiscoveredQueueDefinition } from "./types-1GRMYES1.js";
2
- import { n as OperationContributionEntry } from "./operations-tNUdj3G4.js";
3
- import { Diagnostic } from "nostics";
1
+ import { N as QueueOptions, s as DiscoveredQueueDefinition } from "./types-CiuSIPR0.js";
2
+ import { n as OperationContributionEntry } from "./operation-definition-nmRu_O3V.js";
3
+ import "nostics";
4
4
  import { Plugin, UserConfig } from "vite";
5
+ //#region ../internal/src/deployment.d.ts
6
+ /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
7
+ type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
8
+ //#endregion
9
+ //#region ../internal/src/inspect.d.ts
10
+ interface ViteHubDefinitionField {
11
+ label: string;
12
+ value: string;
13
+ }
14
+ /** Serializable summary of one discovered Definition. Files are relative to the project root. */
15
+ interface ViteHubDefinitionSummary {
16
+ fields: readonly ViteHubDefinitionField[];
17
+ file: string;
18
+ name: string;
19
+ source: string;
20
+ }
21
+ /** Lists the Definitions that one owner package discovered for the resolved Vite config. */
22
+ interface ViteHubDefinitionInspector {
23
+ /** Stable singular kind, for example `queue` or `rate-limit`. */
24
+ kind: string;
25
+ label: string;
26
+ list: () => Promise<readonly ViteHubDefinitionSummary[]> | readonly ViteHubDefinitionSummary[];
27
+ }
28
+ /** One generated Provider Output file or directory that an owner package can write. */
29
+ interface ViteHubProviderOutputEntry {
30
+ description: string;
31
+ owner: string;
32
+ /** Absolute path. */
33
+ path: string;
34
+ }
35
+ /**
36
+ * Where an inspected resource id came from. `name` means the host binds the resource by its name and needs no id.
37
+ * The CLI sets `provider-output` when only a generated Wrangler config names the id.
38
+ */
39
+ type ViteHubResourceIdSource = "config" | "env" | "name" | "provider-output" | "provision-state";
40
+ /** One host resource that a Definition or store maps to. Owner packages read only local config and Provision State. */
41
+ interface ViteHubResourceSummary {
42
+ /** Cloudflare binding name, so the CLI can find the id in generated Wrangler config. */
43
+ binding?: string;
44
+ /** Definition or store name. */
45
+ definition: string;
46
+ /** Env variable that supplied the id when `source` is `env`. */
47
+ env?: string;
48
+ host: "cloudflare" | "vercel";
49
+ id?: string;
50
+ /** Same resource kind names as Provision actions, for example `cloudflare-d1`. */
51
+ kind: string;
52
+ /** Resource name on the host, when the config names it. */
53
+ name?: string;
54
+ /** Explains how the host finds the resource when no id or name is known locally. */
55
+ note?: string;
56
+ owner: string;
57
+ /** Absent when no id is known yet. */
58
+ source?: ViteHubResourceIdSource;
59
+ }
60
+ interface ViteHubInspectionContributor {
61
+ definitions?: readonly ViteHubDefinitionInspector[];
62
+ providerOutput?: readonly ViteHubProviderOutputEntry[];
63
+ resources?: () => readonly ViteHubResourceSummary[] | Promise<readonly ViteHubResourceSummary[]>;
64
+ }
65
+ //#endregion
66
+ //#region ../internal/src/build/deployment-plan-output.d.ts
67
+ /**
68
+ * One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
69
+ * a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
70
+ * It holds names only, so `vitehub deploy` can check the host without booting Vite. It never holds a value.
71
+ */
72
+ interface DeploymentEnvEntry {
73
+ /** The declaration path, such as `env.server.github.token`, when it is safe to show. Primitive entries have none. */
74
+ path?: string;
75
+ /** The host variable names, in read order. The first name that is set supplies the value. */
76
+ names: readonly string[];
77
+ /** Any variable whose name starts with this prefix supplies the value, such as `VITEHUB_CONSOLE_KEY_`. */
78
+ prefix?: string;
79
+ required: boolean;
80
+ secret: boolean;
81
+ /** A default supplies the value when no name is set. */
82
+ hasDefault: boolean;
83
+ /** The primitives that read these names, such as `blob`. Server Env declarations have none. */
84
+ owners?: readonly string[];
85
+ }
86
+ /** What a primitive needs to know to name the variables it reads in the deployed app. */
87
+ interface DeploymentEnvContext {
88
+ host: ViteHubHost;
89
+ }
90
+ /**
91
+ * The host variables that a primitive reads itself, outside the Server Env registry, for one host and its resolved
92
+ * config. A Vite plugin exposes it as `api.deploymentEnv`, and the build writes the result to `deployment.json`.
93
+ * Return names only, never values.
94
+ */
95
+ type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
96
+ //#endregion
97
+ //#region ../internal/src/durability.d.ts
98
+ /**
99
+ * One durability reporter that a primitive's Vite plugin contributes through `vitehub.durability`. The Node server
100
+ * imports `export` from `module` at boot and calls it with `input` and the server environment. It returns the
101
+ * `Durability` lines of `@vite-hub/runtime/durability`.
102
+ */
103
+ interface DurabilityContribution {
104
+ /** The primitive that the reporter describes, such as `kv`. Other reporters find its result by this id. */
105
+ primitive: string;
106
+ /** The absolute file of the reporter module. */
107
+ module: string;
108
+ export: string;
109
+ /**
110
+ * The resolved configuration of the primitive, as plain JSON data. The build writes it into the server with
111
+ * `JSON.stringify`, so do not put credentials here.
112
+ */
113
+ input: unknown;
114
+ }
115
+ /** The `vitehub.durability` field of a primitive's Vite plugin. */
116
+ interface DurabilityPluginMetadata {
117
+ /** Called after Vite resolves the config. Return an empty list when the primitive is off. */
118
+ durability?: () => readonly DurabilityContribution[];
119
+ }
120
+ //#endregion
121
+ //#region ../internal/src/host-credentials.d.ts
122
+ interface HostCliRunResult {
123
+ exitCode: number | null;
124
+ stdout: string;
125
+ }
126
+ /** Runs a host CLI with an argument array and no shell, and returns its stdout. */
127
+ type HostCliRun = (command: string, args: readonly string[], options: {
128
+ cwd?: string;
129
+ env: NodeJS.ProcessEnv;
130
+ signal?: AbortSignal;
131
+ }) => Promise<HostCliRunResult>;
132
+ //#endregion
5
133
  //#region ../internal/src/provision.d.ts
6
134
  type ProvisionProvider = "cloudflare" | "vercel";
7
135
  interface ProvisionLogger {
@@ -26,12 +154,33 @@ interface ProvisionAction {
26
154
  name: string;
27
155
  exists: boolean;
28
156
  pending?: boolean;
157
+ /** Describes the change that `apply()` makes to an existing resource, for example `read replication: disabled -> auto`. */
158
+ update?: string;
29
159
  apply: () => Promise<ProvisionResult>;
30
160
  }
161
+ /** One Provision State category that a step records, with the keys that current Definitions use. */
162
+ interface ProvisionStateCategory {
163
+ category: string;
164
+ declared: readonly string[];
165
+ /** Provider resource identity for shared-resource checks. Return undefined when the recorded id lacks enough information. Defaults to the recorded id. */
166
+ resourceIdentity?: (entry: {
167
+ id: string;
168
+ key: string;
169
+ }) => string | undefined;
170
+ /** Identity expected by current config for a declared key. Omit when it cannot be established without provider access. */
171
+ declaredResourceIdentity?: (key: string) => string | undefined;
172
+ /** Tells a developer how to delete the resource of a recorded entry that no Definition declares. ViteHub never runs it. */
173
+ deleteHint: (entry: {
174
+ id: string;
175
+ key: string;
176
+ }) => string;
177
+ }
31
178
  interface ProvisionStep {
32
179
  id: string;
33
180
  provider: ProvisionProvider;
34
181
  plan: (context: ProvisionContext) => Promise<ProvisionAction[]>;
182
+ /** Describes the Provision State this step records. Runs without network access, also without credentials. */
183
+ recordedState?: (context: Pick<ProvisionContext, "env">) => ProvisionStateCategory[];
35
184
  }
36
185
  //#endregion
37
186
  //#region ../internal/src/cli.d.ts
@@ -46,12 +195,17 @@ interface ViteHubCliStreams {
46
195
  interface ViteHubCliSpawnResult {
47
196
  exitCode: number | null;
48
197
  signal?: NodeJS.Signals | null;
198
+ /** The output of the child when `stdout` is `pipe`. */
199
+ stdout?: string;
49
200
  }
50
201
  interface ViteHubCliSpawnOptions {
51
202
  cwd?: string;
52
203
  env?: NodeJS.ProcessEnv;
53
204
  stderr?: "inherit" | "pipe";
54
- stdout?: "inherit" | "pipe";
205
+ /** `ignore` gives the child no terminal input, so a tool that asks questions on a terminal does not ask. */
206
+ stdin?: "ignore" | "inherit";
207
+ /** `stderr` sends the child's stdout to the parent's stderr, so the parent's stdout keeps only its own output. */
208
+ stdout?: "inherit" | "pipe" | "stderr";
55
209
  }
56
210
  type ViteHubCliSpawn = (command: string, args: string[], options?: ViteHubCliSpawnOptions) => Promise<ViteHubCliSpawnResult>;
57
211
  interface ViteHubCliContext extends ViteHubCliStreams {
@@ -59,9 +213,23 @@ interface ViteHubCliContext extends ViteHubCliStreams {
59
213
  env: NodeJS.ProcessEnv;
60
214
  /** Replaces `fetch` for commands that call a running app, so tests need no server. */
61
215
  fetch?: typeof fetch;
216
+ /**
217
+ * Loads the project config for a build on `host` and returns the Provision Steps of its plugins, with the config root
218
+ * that holds `.vitehub/provision.json`. Setup commands, such as `vitehub deploy`, call it only when they need the
219
+ * steps, so they still run on a config that throws.
220
+ */
221
+ loadProvision?: (host: ProvisionProvider) => Promise<ViteHubCliProvision>;
222
+ /** The deployed app's public origin from `vitehub({ publicUrl })`, when it is one string. */
223
+ publicUrl?: string;
62
224
  rootDir: string;
225
+ /** Replaces the host CLI runner, such as for `wrangler auth token`, so tests need no real host CLI. */
226
+ runHostCli?: HostCliRun;
63
227
  spawn: ViteHubCliSpawn;
64
228
  }
229
+ interface ViteHubCliProvision {
230
+ rootDir: string;
231
+ steps: readonly ProvisionStep[];
232
+ }
65
233
  interface ViteHubCliFeature {
66
234
  description?: string;
67
235
  name: string;
@@ -69,57 +237,135 @@ interface ViteHubCliFeature {
69
237
  usage?: string;
70
238
  }
71
239
  interface ViteHubCliCommandNamespace {
72
- /** The feature that `vitehub <name>` runs when no feature is named. */
240
+ /** The feature that `vitehub <name>` runs when the next argument names no other feature. It gets every argument after `<name>`. */
73
241
  defaultFeature?: string;
74
242
  description?: string;
75
243
  features: ViteHubCliFeature[];
76
244
  name: string;
77
245
  }
246
+ /** The flags of `vitehub seed` that every seed gets. */
247
+ interface ViteHubCliSeedOptions {
248
+ /** `--database <name>`: seed only this Database. Only the Database seed runs. */
249
+ database?: string;
250
+ /** The process environment with the env files of `--stage`. */
251
+ env: NodeJS.ProcessEnv;
252
+ /** `--remote`: write the deployed stores. Without it, a seed writes only local data. */
253
+ remote: boolean;
254
+ /** `--timeout <ms>` of each call to the app. */
255
+ timeout?: number;
256
+ /** The deployed app with `--remote`: `--url`, or `vitehub({ publicUrl })`. */
257
+ url?: string;
258
+ }
259
+ /** The seed files of one primitive, which `vitehub seed` writes. */
260
+ interface ViteHubCliSeed {
261
+ /** Where the seed files are, such as `server/seed/kv/`. `vitehub seed` names it when it finds no seed files. */
262
+ files: string;
263
+ /** The primitive, such as `database` or `kv`. `vitehub seed <name>` runs only this seed. */
264
+ name: string;
265
+ /** Writes the seed files and returns the exit code, or `undefined` when the project has no seed files for this primitive. */
266
+ run: (options: ViteHubCliSeedOptions, context: ViteHubCliContext) => Promise<number | undefined>;
267
+ }
78
268
  interface ViteHubCliContributor {
79
269
  namespaces: ViteHubCliCommandNamespace[];
80
270
  provision?: ProvisionStep[];
271
+ /** The seed files that `vitehub seed` writes. */
272
+ seeds?: ViteHubCliSeed[];
273
+ /** The deployed app's public origin. Commands receive it as `context.publicUrl`. */
274
+ publicUrl?: string;
81
275
  }
82
276
  type StdoutWriteCallback = (error?: Error | null) => void;
83
277
  //#endregion
84
- //#region ../internal/src/inspect.d.ts
85
- interface ViteHubDefinitionField {
86
- label: string;
87
- value: string;
278
+ //#region ../internal/src/contributions.d.ts
279
+ /** Module and export that hold a contributed Definition. */
280
+ interface ContributionDefinition {
281
+ /**
282
+ * Absolute file path, `file:` URL, or package specifier that the application can import. Relative paths are
283
+ * rejected because they have no stable base.
284
+ */
285
+ module: string;
286
+ /** Named export that holds the Definition. Defaults to `default`. */
287
+ export?: string;
88
288
  }
89
- /** Serializable summary of one discovered Definition. Files are relative to the project root. */
90
- interface ViteHubDefinitionSummary {
91
- fields: readonly ViteHubDefinitionField[];
92
- file: string;
289
+ /**
290
+ * One Definition that a Vite plugin adds to a Server Primitive, for example a Workspace, a Schedule, or Database tables.
291
+ * Every owner package reads this shape from `plugin.vitehub.<key>`. Owners can add fields, such as `database`.
292
+ */
293
+ interface Contribution {
294
+ /** Unique name in the owner, for example the Workspace or Schedule name. */
93
295
  name: string;
94
- source: string;
296
+ definition: ContributionDefinition;
297
+ /** Why the plugin adds the Definition. `vitehub inspect` and the Console show it. */
298
+ reason?: string;
95
299
  }
96
- /** Lists the Definitions that one owner package discovered for the resolved Vite config. */
97
- interface ViteHubDefinitionInspector {
98
- /** Stable singular kind, for example `queue` or `rate-limit`. */
99
- kind: string;
100
- label: string;
101
- list: () => Promise<readonly ViteHubDefinitionSummary[]> | readonly ViteHubDefinitionSummary[];
102
- }
103
- /** One generated Provider Output file or directory that an owner package can write. */
104
- interface ViteHubProviderOutputEntry {
105
- description: string;
106
- owner: string;
107
- /** Absolute path. */
108
- path: string;
300
+ /** Roots that ViteHub passes to every contribution factory. */
301
+ interface ContributionContext {
302
+ /** Vite root. */
303
+ root: string;
304
+ /** ViteHub project root. It can differ from the Vite root, for example in a Nuxt app with a `srcDir`. */
305
+ projectRoot: string;
306
+ /** Server directories that the host forwards, for example Nuxt's `serverDir` and the server directories of layers. */
307
+ serverDirs?: readonly string[];
109
308
  }
110
- interface ViteHubInspectionContributor {
111
- definitions?: readonly ViteHubDefinitionInspector[];
112
- providerOutput?: readonly ViteHubProviderOutputEntry[];
309
+ /**
310
+ * Returns the contributions of a plugin. It runs once per discovery pass, so it must be idempotent and must not depend
311
+ * on the order of Vite config hooks.
312
+ */
313
+ type ContributionFactory<TEntry extends Contribution = Contribution> = (context: ContributionContext) => readonly TEntry[] | undefined | Promise<readonly TEntry[] | undefined>;
314
+ type ContributionSource<TEntry extends Contribution = Contribution> = readonly TEntry[] | ContributionFactory<TEntry>;
315
+ /** A Vite plugin that contributes Definitions under `vitehub[TKey]`. */
316
+ type ContributingPlugin<TKey extends string, TEntry extends Contribution = Contribution> = {
317
+ name?: string;
318
+ vitehub?: { [K in TKey]?: ContributionSource<TEntry>; };
319
+ };
320
+ /** A validated contribution with its export resolved and the name of the plugin that added it. */
321
+ interface CollectedContribution {
322
+ name: string;
323
+ definition: {
324
+ module: string;
325
+ export: string;
326
+ };
327
+ reason?: string;
328
+ /** Name of the contributing Vite plugin. */
329
+ plugin: string;
113
330
  }
114
331
  //#endregion
332
+ //#region src/contributions.d.ts
333
+ /**
334
+ * A Queue Definition that another package adds from its Vite plugin. The Queue plugin merges it with the discovered
335
+ * files, so the registry, the generated types, Cloudflare bindings, Vercel consumers, inspection, and provisioning
336
+ * treat it like `server/queues/<name>.ts`.
337
+ *
338
+ * The generated registry imports the module by path, so `definition.module` must be an absolute file path or a `file:`
339
+ * URL, and the module must `export default defineQueue(...)`.
340
+ */
341
+ type QueueContribution = Contribution;
342
+ /** Roots that ViteHub passes to contribution factories. `root` is the Vite root. */
343
+ type QueueContributionContext = ContributionContext;
344
+ type QueueContributionFactory = ContributionFactory<QueueContribution>;
345
+ /** A Vite plugin that contributes Queue Definitions through `vitehub.queues`. */
346
+ type QueueContributingPlugin = ContributingPlugin<"queues", QueueContribution>;
347
+ /** A validated contribution with the name of the plugin that contributed it. */
348
+ type CollectedQueueContribution = CollectedContribution;
349
+ /**
350
+ * Collects `vitehub.queues` contributions from Vite plugins. Two contributions with one name fail with
351
+ * `QUEUE_DEFINITION_DUPLICATE`. Invalid entries fail with `QUEUE_CONTRIBUTION_INVALID`.
352
+ */
353
+ export declare function collectQueueContributions(plugins: readonly unknown[] | undefined, context: QueueContributionContext): Promise<CollectedQueueContribution[]>;
354
+ //#endregion
115
355
  //#region src/discovery.d.ts
116
- export declare function discoverQueueDefinitions(options: {
356
+ /** Discovery source of Queue Definitions that Vite plugins contribute through `vitehub.queues`. */
357
+ export declare const contributedQueueSource = "vite-plugin-contribution";
358
+ interface QueueContributionOptions {
359
+ /** Queue Definitions that Vite plugins contribute. See `collectQueueContributions()`. */
360
+ contributions?: readonly CollectedQueueContribution[];
361
+ }
362
+ export declare function discoverQueueDefinitions(options: QueueContributionOptions & {
117
363
  mode?: "vite-suffix";
118
364
  rootDir: string;
119
365
  scanDirs?: string[];
120
366
  serverDirs?: string[];
121
367
  serverRootDirs?: string[];
122
- } | {
368
+ } | QueueContributionOptions & {
123
369
  mode: "server-queues";
124
370
  scanDirs: string[];
125
371
  }): DiscoveredQueueDefinition[];
@@ -132,7 +378,15 @@ interface ViteHubConsoleDefinitionCatalogView {
132
378
  /** States which runtime data this catalog does not include. */
133
379
  notice: string;
134
380
  }
381
+ /** Lists Workspace Definitions like a catalog, and browses the refs, revisions, and files of the selected one. */
382
+ interface ViteHubConsoleWorkspaceBrowserView {
383
+ kind: "workspace-browser";
384
+ /** States which runtime data the browser does not include. */
385
+ notice: string;
386
+ }
135
387
  interface ViteHubConsoleRecordColumn {
388
+ /** Set it for a column with few values, such as a status. The Console then filters the table by its values. */
389
+ filter?: boolean;
136
390
  /** Key in `ViteHubConsoleRecord.cells`. */
137
391
  key: string;
138
392
  label: string;
@@ -157,8 +411,42 @@ interface ViteHubConsoleOperationColumn {
157
411
  /** Dot path into each item of the result, such as `author.name` or `messages.0.body`. */
158
412
  key: string;
159
413
  label: string;
160
- /** `datetime` shows a time in milliseconds since the epoch as a date. `excerpt` cuts a long text. */
161
- format?: "datetime" | "excerpt";
414
+ /**
415
+ * `datetime` shows a time in milliseconds since the epoch as a relative date, such as `5m ago`. `excerpt` cuts a long
416
+ * text. `status` shows the value as a status with a colored dot, such as `Open`. `tones` picks the color of each value.
417
+ * `switch` shows a boolean as a switch that calls the `switch` operation.
418
+ */
419
+ format?: "datetime" | "excerpt" | "status" | "switch";
420
+ /** The color of each value of a `status` column, such as `{ open: "info", resolved: "success" }`. Other values are neutral. */
421
+ tones?: Readonly<Record<string, "error" | "info" | "neutral" | "success" | "warning">>;
422
+ /**
423
+ * What a `switch` column calls when the user flips it: `operation` with an input that maps each key of `input` to a
424
+ * dot path of the item, and the column `key` to the new value. `{ operation: "skills.set", input: { name: "name" } }`
425
+ * on the column `enabled` calls `skills.set` with `{ name, enabled }`, then loads the list again. A user who may only
426
+ * read the section sees the switch disabled.
427
+ */
428
+ switch?: {
429
+ operation: string;
430
+ input: Readonly<Record<string, string>>;
431
+ };
432
+ }
433
+ /**
434
+ * A button on each row that calls `operation` with the Console user, then loads the list again. `input` maps each input
435
+ * key to a dot path of the item, as a `switch` column does.
436
+ */
437
+ interface ViteHubConsoleOperationAction {
438
+ label: string;
439
+ operation: string;
440
+ input: Readonly<Record<string, string>>;
441
+ /**
442
+ * The result is `{ url }`, such as a one-time link or a provider sign-in: the Console opens it in a new tab, and loads
443
+ * the list again when the person comes back. The URL must be `https:`, or `http:` on a loopback host.
444
+ */
445
+ tab?: true;
446
+ /** Show the button only on rows where each dot path holds one of the listed values. */
447
+ when?: Readonly<Record<string, readonly string[]>>;
448
+ /** Ask this question before the call. `{path}` takes a value from the item. */
449
+ confirm?: string;
162
450
  }
163
451
  /** A chip above the list. Choosing it merges `input` into the operation input. The first chip is the default. */
164
452
  interface ViteHubConsoleOperationFilter {
@@ -172,13 +460,24 @@ interface ViteHubConsoleOperationFilter {
172
460
  * array of objects with an `id`. A failure of the operation, with its `fix`, shows where the list would be.
173
461
  */
174
462
  interface ViteHubConsoleOperationView {
463
+ /** Buttons on each row. A user who may only read the section does not see them. */
464
+ actions?: readonly ViteHubConsoleOperationAction[];
175
465
  columns: readonly ViteHubConsoleOperationColumn[];
466
+ /**
467
+ * Opens the item of a row in a side panel. `comment-thread` shows an item of `comments.list` as a comment thread
468
+ * where the user reads, replies, resolves, reopens, and mentions people. The panel calls the `comments.*` operations
469
+ * with the Console user, and `?thread=<id>` in the URL opens it.
470
+ */
471
+ detail?: {
472
+ kind: "comment-thread";
473
+ };
176
474
  filters?: readonly ViteHubConsoleOperationFilter[];
177
475
  kind: "operation-view";
178
476
  /**
179
477
  * Makes each row a link: `{path}` placeholders take values from the item and are URL-encoded, and `{path:path}` takes an
180
- * app path and encodes each segment (a value that is not an app path, such as `//evil.com/x`, gives no link). Rows where
181
- * `when.path` is not `when.equals` get none.
478
+ * app path and encodes each segment (a value that is not an app path, such as `//evil.com/x`, gives no link).
479
+ * `{path:href}` takes an app URL that is already encoded, with its query, as it is. Rows where `when.path` is not
480
+ * `when.equals` get none.
182
481
  */
183
482
  link?: {
184
483
  label?: string;
@@ -202,7 +501,17 @@ interface ViteHubConsoleAuthView {
202
501
  notice: string;
203
502
  }
204
503
  interface ViteHubConsoleAuthSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleAuthView> {}
205
- type ViteHubConsoleSectionView = ViteHubConsoleOperationView | ViteHubConsoleAuthView | ViteHubConsoleDefinitionCatalogView | ViteHubConsoleRecordTableView | ViteHubConsoleDocumentEditorView;
504
+ /**
505
+ * The webhooks of the app, their pending debounce timers, and their delivery log. The Console calls the `webhooks.*`
506
+ * operations of `@vite-hub/webhooks` with the Console user to list them, send a test, send a pending delivery now,
507
+ * cancel it, and redeliver. It has no build-time data.
508
+ */
509
+ interface ViteHubConsoleWebhooksView {
510
+ kind: "webhooks";
511
+ notice: string;
512
+ }
513
+ interface ViteHubConsoleWebhooksSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleWebhooksView> {}
514
+ type ViteHubConsoleSectionView = ViteHubConsoleOperationView | ViteHubConsoleAuthView | ViteHubConsoleWebhooksView | ViteHubConsoleDefinitionCatalogView | ViteHubConsoleRecordTableView | ViteHubConsoleDocumentEditorView | ViteHubConsoleWorkspaceBrowserView;
206
515
  /**
207
516
  * The overview of a document editor section: document counts by state, the changes that wait for a publish, recent
208
517
  * activity, and a New button per collection. It reads the owner `overview` action.
@@ -312,8 +621,8 @@ interface ViteHubConsoleServerExport {
312
621
  /** Named export of `module`. */
313
622
  export: string;
314
623
  /**
315
- * Owner package module specifier, for example `@vite-hub/email/runtime/console`. The host maps it to the module
316
- * path that the application can import.
624
+ * Absolute path of the owner module, such as `ownModule(import.meta.url, "runtime/console")`, or an owner package
625
+ * specifier that the host maps to a module path that the application can import.
317
626
  */
318
627
  module: string;
319
628
  }
@@ -324,7 +633,8 @@ interface ViteHubConsoleServerExport {
324
633
  interface ViteHubConsoleRuntimeReader extends ViteHubConsoleServerExport {}
325
634
  /**
326
635
  * A record table that also reads records at request time. The Console shows the build-time records of `read` first,
327
- * then the records of the `runtime` reader. A runtime record replaces a build-time record with the same id.
636
+ * then the records of the `runtime` reader. A runtime record updates the build-time record with the same id: its cells
637
+ * and fields replace the build-time ones with the same key or label.
328
638
  */
329
639
  interface ViteHubConsoleRuntimeRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
330
640
  /** Reads build-time records on the server. When omitted, the section has only runtime records. */
@@ -360,7 +670,7 @@ interface ViteHubConsoleDocumentEditorSection<TOptions = void> extends ViteHubCo
360
670
  * A Console section that an owner package contributes. The owner defines the label, icon, view, and data reader.
361
671
  * `TOptions` is the discovery context that the host passes to `read`.
362
672
  */
363
- type ViteHubConsoleSectionContribution<TOptions = void> = ViteHubConsoleAuthSection | ViteHubConsoleDefinitionCatalogSection<TOptions> | ViteHubConsoleRecordTableSection<TOptions> | ViteHubConsoleRuntimeRecordTableSection<TOptions> | ViteHubConsoleDocumentEditorSection<TOptions> | ViteHubConsoleOperationSection;
673
+ type ViteHubConsoleSectionContribution<TOptions = void> = ViteHubConsoleAuthSection | ViteHubConsoleWebhooksSection | ViteHubConsoleDefinitionCatalogSection<TOptions> | ViteHubConsoleRecordTableSection<TOptions> | ViteHubConsoleRuntimeRecordTableSection<TOptions> | ViteHubConsoleDocumentEditorSection<TOptions> | ViteHubConsoleOperationSection;
364
674
  /** A fix that the owner names for a feature the project lacks, such as `Add authorize to defineContent().` */
365
675
  interface ViteHubConsoleDocumentHint {
366
676
  /** One sentence that names the fix. Text in backticks shows as code. */
@@ -373,6 +683,8 @@ interface ViteHubConsoleDocumentHint {
373
683
  * failing without a reason.
374
684
  */
375
685
  interface ViteHubConsoleDocumentSetup {
686
+ /** The project has GitHub Sources but no document collections. */
687
+ sourceHeadsOnly?: true;
376
688
  /** Present when no user can read anything because the owner has no access policy. */
377
689
  access?: ViteHubConsoleDocumentHint;
378
690
  /**
@@ -393,6 +705,8 @@ interface ViteHubConsoleDocumentSetup {
393
705
  //#endregion
394
706
  //#region src/inspect.d.ts
395
707
  interface QueueInspectionOptions {
708
+ /** Queue Definitions that Vite plugins contribute through `vitehub.queues`. */
709
+ contributions?: readonly CollectedQueueContribution[];
396
710
  projectRoot: string;
397
711
  rootDir: string;
398
712
  serverDirs?: string[];
@@ -406,6 +720,7 @@ export declare const queueConsoleSection: ViteHubConsoleSectionContribution<Queu
406
720
  interface QueueProvisionContributingPlugin {
407
721
  vitehub?: {
408
722
  cli?: () => Promise<ViteHubCliContributor>;
723
+ durability?: DurabilityPluginMetadata["durability"];
409
724
  inspect?: () => ViteHubInspectionContributor | undefined;
410
725
  operations?: readonly OperationContributionEntry[];
411
726
  queue?: {
@@ -413,7 +728,12 @@ interface QueueProvisionContributingPlugin {
413
728
  };
414
729
  };
415
730
  }
416
- export type QueueVitePlugin = Plugin & QueueProvisionContributingPlugin;
731
+ export type QueueVitePlugin = Plugin & QueueProvisionContributingPlugin & {
732
+ /** The variables that Queue reads on the deployed host. See `queueDeploymentEnv()`. */
733
+ api: {
734
+ deploymentEnv: DeploymentEnvContribution;
735
+ };
736
+ };
417
737
  export interface QueueNitroConfigOptions {
418
738
  development?: boolean;
419
739
  nitro: Record<string, unknown>;
@@ -428,15 +748,12 @@ export interface QueueNitroConfigOptions {
428
748
  }
429
749
  /** Options that a framework distribution passes to `hubQueue()`. */
430
750
  export interface QueueVitePluginInternalOptions {
751
+ /** Module that exports the app's `databases`, for the postgres driver. Defaults to `@vite-hub/database/drizzle`. */
752
+ databaseImport?: string;
431
753
  /** Module that the generated Queue types augment, for example `vite-hub/queue`. Defaults to `@vite-hub/queue`. */
432
754
  importBase?: string;
433
755
  }
434
756
  export declare function createQueueNitroConfig(plugin: QueueVitePlugin, options: QueueNitroConfigOptions): Promise<Record<string, unknown>>;
435
- export declare function hubQueue(options?: QueueModuleOptions, internalOptions?: QueueVitePluginInternalOptions): QueueVitePlugin;
436
- declare module "vite" {
437
- interface UserConfig {
438
- queue?: QueueModuleOptions;
439
- }
440
- }
757
+ export declare function hubQueue(options?: QueueOptions, internalOptions?: QueueVitePluginInternalOptions): QueueVitePlugin;
441
758
  //#endregion
442
- export type { QueueInspectionOptions };
759
+ export type { CollectedQueueContribution, QueueContributingPlugin, QueueContribution, QueueContributionContext, QueueContributionFactory, QueueInspectionOptions };