@vite-hub/workspace 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +164 -107
  2. package/dist/abort-BCwpdrN0.js +32 -0
  3. package/dist/blob-database.d.ts +70 -117
  4. package/dist/blob-database.js +48 -41
  5. package/dist/checkout.d.ts +128 -0
  6. package/dist/checkout.js +849 -0
  7. package/dist/cloudflare.d.ts +2 -2
  8. package/dist/cloudflare.js +1 -1
  9. package/dist/config-B-863EgC.js +15 -0
  10. package/dist/{config-B7dmzDX3.js → config-BAgL2dtB.js} +48 -84
  11. package/dist/{config-DLKdaFWN.d.ts → config-BQKcPawI.d.ts} +1 -1
  12. package/dist/discard-CNNtCozM.js +8 -0
  13. package/dist/durability.d.ts +22 -0
  14. package/dist/durability.js +70 -0
  15. package/dist/error-diagnostics-CtKjGtGb.js +188 -0
  16. package/dist/error-diagnostics-DSkCJC_L.js +266 -0
  17. package/dist/file-2pFYNtsU.js +22 -0
  18. package/dist/{files-C7Px8uaC.js → files-BOo4SbwE.js} +2 -2
  19. package/dist/files.d.ts +38 -0
  20. package/dist/files.js +6 -0
  21. package/dist/{github-CPxHtFB7.js → github-CrYp4v8k.js} +32 -5
  22. package/dist/{glob--XcLlcml.js → glob-B8YGvTrZ.js} +4 -5
  23. package/dist/{glob--kNYDbfU.js → glob-Cjxms1t7.js} +1 -1
  24. package/dist/{host-CFnrTXTK.js → host-BFBpXn0N.js} +58 -47
  25. package/dist/{hosted-acMA5XyL.js → hosted-KcUR_jPv.js} +216 -93
  26. package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
  27. package/dist/hosted-vercel-blob.d.ts +2 -2
  28. package/dist/hosted-vercel-blob.js +1 -1
  29. package/dist/hosted.d.ts +5 -3
  30. package/dist/hosted.js +2 -2
  31. package/dist/index.d.ts +9 -51
  32. package/dist/index.js +21 -91
  33. package/dist/{lifecycle-BwZ7c9hb.js → lifecycle-B-enk_4A.js} +8 -8
  34. package/dist/lineage.d.ts +26 -0
  35. package/dist/lineage.js +76 -0
  36. package/dist/loader.d.ts +1 -1
  37. package/dist/loader.js +2 -2
  38. package/dist/{mcp-resources-BREFCmtn.js → mcp-resources-DF0F5rcL.js} +2 -2
  39. package/dist/{memory-BbwOqDXl.js → memory-BOexthyW.js} +3 -4
  40. package/dist/{metadata-target-DZEZQGHA.js → metadata-target-CWz6KHKq.js} +17 -16
  41. package/dist/object-Da1zyPCR.js +11 -0
  42. package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
  43. package/dist/operations-C6FpR8Rr.js +389 -0
  44. package/dist/operations-CE2drFih.js +1234 -0
  45. package/dist/operations.d.ts +41 -4
  46. package/dist/operations.js +3 -2
  47. package/dist/{path-CNAwN7pw.js → path--wrT_Azm.js} +2 -3
  48. package/dist/path-AxMho1wo.d.ts +7 -0
  49. package/dist/{plugins-DqQ8b4T5.d.ts → plugins-C8C0auoW.d.ts} +1 -1
  50. package/dist/{provider-kXjfli9u.js → provider-9s4Ufkm5.js} +104 -82
  51. package/dist/providers/github/store.d.ts +1 -1
  52. package/dist/providers/github/store.js +1 -1
  53. package/dist/registry-B3BBm4Ts.d.ts +19 -0
  54. package/dist/{registry-Bp-8UUfG.js → registry-CNphafBx.js} +55 -20
  55. package/dist/registry-CYNN623b.d.ts +9 -0
  56. package/dist/request-scope-Dw5n8bMC.js +83 -0
  57. package/dist/results-DgkZUmTL.js +8 -0
  58. package/dist/{rolldown-runtime-B4iAMlE-.js → rolldown-runtime-rQ84J-ij.js} +2 -3
  59. package/dist/runtime/assets.d.ts +1 -1
  60. package/dist/runtime/assets.js +3 -3
  61. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  62. package/dist/runtime/empty-registry.d.ts +2 -1
  63. package/dist/runtime/registry.d.ts +2 -0
  64. package/dist/runtime/registry.js +23 -0
  65. package/dist/runtime/request.d.ts +4 -0
  66. package/dist/runtime/request.js +8 -0
  67. package/dist/runtime/state.d.ts +5 -4
  68. package/dist/runtime/state.js +8 -18
  69. package/dist/runtime/workspace.d.ts +1 -1
  70. package/dist/runtime/workspace.js +1 -1
  71. package/dist/runtime.d.ts +9 -8
  72. package/dist/runtime.js +23 -26
  73. package/dist/{search-CrTmXj5h.js → search-C_RfoM2j.js} +2 -2
  74. package/dist/{server-BNQ-Nbjj.js → server-8tGltlGz.js} +53 -40
  75. package/dist/server.d.ts +17 -8
  76. package/dist/server.js +1 -1
  77. package/dist/shared-B3_EUk89.js +848 -0
  78. package/dist/source-metadata.d.ts +6 -2
  79. package/dist/source-metadata.js +8 -8
  80. package/dist/state-BISnUf1s.d.ts +35 -0
  81. package/dist/{ai-BZyLwULx.js → state-DbrW-njQ.js} +96 -54
  82. package/dist/{store-CXgmu-uw.js → store-ybhyD38Z.js} +250 -106
  83. package/dist/{sync-CN6ec-5M.js → sync-CCD_VYC8.js} +4 -4
  84. package/dist/target-jWhTdIuF.js +89 -0
  85. package/dist/test.d.ts +1 -1
  86. package/dist/test.js +1 -1
  87. package/dist/{types-DeK9GIxy.d.ts → types-BbtwmBZ5.d.ts} +68 -14
  88. package/dist/use-C6lV3-wC.d.ts +321 -0
  89. package/dist/{use-BQj7nSz6.js → use-CSpT5W87.js} +75 -82
  90. package/dist/{utils-Blrh4N2n.js → utils-CgMZCHsX.js} +112 -41
  91. package/dist/vite.d.ts +585 -2
  92. package/dist/vite.js +21368 -1
  93. package/dist/{workspace-BWJQBK1u.d.ts → workspace-CYB2xZ1T.d.ts} +1 -1
  94. package/dist/{workspace-6pxkOuxr.js → workspace-sPWn2Jxj.js} +125 -40
  95. package/package.json +46 -55
  96. package/dist/ai-BW2ZhizI.d.ts +0 -177
  97. package/dist/ai.d.ts +0 -3
  98. package/dist/ai.js +0 -2
  99. package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +0 -19
  100. package/dist/error-diagnostics-A_8Kp-48.js +0 -116
  101. package/dist/error-diagnostics-DY5GP47p.js +0 -96
  102. package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +0 -354
  103. package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +0 -214
  104. package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +0 -527
  105. package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +0 -248
  106. package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +0 -179
  107. package/dist/file-C0_aPWSS.js +0 -26
  108. package/dist/file-metadata-CxDy-E2H.js +0 -58
  109. package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +0 -2278
  110. package/dist/github-DtncTfmv-Du2S8lGF.js +0 -4159
  111. package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +0 -2530
  112. package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +0 -489
  113. package/dist/hosted-vercel-blob-DKntsHaf.js +0 -12603
  114. package/dist/inspect-BoObD2cJ.js +0 -167
  115. package/dist/mountx.d.ts +0 -8
  116. package/dist/mountx.js +0 -145
  117. package/dist/nitro.d.ts +0 -2
  118. package/dist/nitro.js +0 -2
  119. package/dist/nuxt.d.ts +0 -27
  120. package/dist/nuxt.js +0 -38
  121. package/dist/operations-BcpWr41m.js +0 -159
  122. package/dist/operations-CGqY1XeG.js +0 -965
  123. package/dist/operations-DnOwKsJT.d.ts +0 -136
  124. package/dist/registry-Cg1TJVVZ.d.ts +0 -10
  125. package/dist/request-execution-Dk9rY-Yh.js +0 -84
  126. package/dist/shared-DalXdP0i.js +0 -2158
  127. package/dist/state-B8zbLi5t.d.ts +0 -26
  128. package/dist/target-D4Bqb1eH.js +0 -11
  129. package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +0 -125
  130. package/dist/token-CO62GglH.js +0 -61
  131. package/dist/use-DhwhbAVV.d.ts +0 -108
  132. package/dist/vite-BEvgU2GY.js +0 -20909
  133. package/dist/vite-CcZmMQ7S.d.ts +0 -476
  134. package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +0 -1565
package/dist/vite.d.ts CHANGED
@@ -1,2 +1,585 @@
1
- import { _ as createWorkspaceNitroConfig, a as ViteWorkspaceDiscoveryOptions, c as WorkspaceContributingPlugin, d as WorkspaceContributionFactory, f as collectWorkspaceContributions, g as WorkspaceVitePluginAPI, h as WorkspaceVitePlugin, i as DiscoveredWorkspaceDefinition, l as WorkspaceContribution, m as WorkspaceNitroConfigOptions, n as inspectWorkspaceDefinitions, o as discoverViteWorkspaceDefinitions, p as NitroConfig, r as workspaceConsoleSection, s as CollectedWorkspaceContribution, t as WorkspaceInspectionOptions, u as WorkspaceContributionContext, v as hubWorkspace } from "./vite-CcZmMQ7S.js";
2
- export { type CollectedWorkspaceContribution, type DiscoveredWorkspaceDefinition, type NitroConfig, type ViteWorkspaceDiscoveryOptions, type WorkspaceContributingPlugin, type WorkspaceContribution, type WorkspaceContributionContext, type WorkspaceContributionFactory, type WorkspaceInspectionOptions, type WorkspaceNitroConfigOptions, type WorkspaceVitePlugin, type WorkspaceVitePluginAPI, collectWorkspaceContributions, createWorkspaceNitroConfig, discoverViteWorkspaceDefinitions, hubWorkspace, inspectWorkspaceDefinitions, workspaceConsoleSection };
1
+ import { Tt as WorkspaceOptions } from "./types-BbtwmBZ5.js";
2
+ import { n as OperationContributionEntry } from "./operation-definition-8gOe-ubD.js";
3
+ import { Plugin } from "vite";
4
+ //#region ../internal/src/durability.d.ts
5
+ /**
6
+ * One durability reporter that a primitive's Vite plugin contributes through `vitehub.durability`. The Node server
7
+ * imports `export` from `module` at boot and calls it with `input` and the server environment. It returns the
8
+ * `Durability` lines of `@vite-hub/runtime/durability`.
9
+ */
10
+ interface DurabilityContribution {
11
+ /** The primitive that the reporter describes, such as `kv`. Other reporters find its result by this id. */
12
+ primitive: string;
13
+ /** The absolute file of the reporter module. */
14
+ module: string;
15
+ export: string;
16
+ /**
17
+ * The resolved configuration of the primitive, as plain JSON data. The build writes it into the server with
18
+ * `JSON.stringify`, so do not put credentials here.
19
+ */
20
+ input: unknown;
21
+ }
22
+ /** The `vitehub.durability` field of a primitive's Vite plugin. */
23
+ interface DurabilityPluginMetadata {
24
+ /** Called after Vite resolves the config. Return an empty list when the primitive is off. */
25
+ durability?: () => readonly DurabilityContribution[];
26
+ }
27
+ //#endregion
28
+ //#region ../internal/src/inspect.d.ts
29
+ interface ViteHubDefinitionField {
30
+ label: string;
31
+ value: string;
32
+ }
33
+ /** Serializable summary of one discovered Definition. Files are relative to the project root. */
34
+ interface ViteHubDefinitionSummary {
35
+ fields: readonly ViteHubDefinitionField[];
36
+ file: string;
37
+ name: string;
38
+ source: string;
39
+ }
40
+ /** Lists the Definitions that one owner package discovered for the resolved Vite config. */
41
+ interface ViteHubDefinitionInspector {
42
+ /** Stable singular kind, for example `queue` or `rate-limit`. */
43
+ kind: string;
44
+ label: string;
45
+ list: () => Promise<readonly ViteHubDefinitionSummary[]> | readonly ViteHubDefinitionSummary[];
46
+ }
47
+ /** One generated Provider Output file or directory that an owner package can write. */
48
+ interface ViteHubProviderOutputEntry {
49
+ description: string;
50
+ owner: string;
51
+ /** Absolute path. */
52
+ path: string;
53
+ }
54
+ /**
55
+ * Where an inspected resource id came from. `name` means the host binds the resource by its name and needs no id.
56
+ * The CLI sets `provider-output` when only a generated Wrangler config names the id.
57
+ */
58
+ type ViteHubResourceIdSource = "config" | "env" | "name" | "provider-output" | "provision-state";
59
+ /** One host resource that a Definition or store maps to. Owner packages read only local config and Provision State. */
60
+ interface ViteHubResourceSummary {
61
+ /** Cloudflare binding name, so the CLI can find the id in generated Wrangler config. */
62
+ binding?: string;
63
+ /** Definition or store name. */
64
+ definition: string;
65
+ /** Env variable that supplied the id when `source` is `env`. */
66
+ env?: string;
67
+ host: "cloudflare" | "vercel";
68
+ id?: string;
69
+ /** Same resource kind names as Provision actions, for example `cloudflare-d1`. */
70
+ kind: string;
71
+ /** Resource name on the host, when the config names it. */
72
+ name?: string;
73
+ /** Explains how the host finds the resource when no id or name is known locally. */
74
+ note?: string;
75
+ owner: string;
76
+ /** Absent when no id is known yet. */
77
+ source?: ViteHubResourceIdSource;
78
+ }
79
+ interface ViteHubInspectionContributor {
80
+ definitions?: readonly ViteHubDefinitionInspector[];
81
+ providerOutput?: readonly ViteHubProviderOutputEntry[];
82
+ resources?: () => readonly ViteHubResourceSummary[] | Promise<readonly ViteHubResourceSummary[]>;
83
+ }
84
+ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor | undefined | Promise<ViteHubInspectionContributor | undefined>;
85
+ interface ViteHubInspectionPluginMetadata {
86
+ inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
87
+ }
88
+ //#endregion
89
+ //#region src/hosts/vite/plugin.d.ts
90
+ interface WorkspaceNitroConfigOptions {
91
+ aliases?: Record<string, string>;
92
+ command?: "build" | "serve";
93
+ env?: Record<string, string | undefined>;
94
+ hosting?: string;
95
+ nitro?: unknown;
96
+ /** Vite plugins that can contribute Workspace Definitions through `vitehub.workspaces`. */
97
+ plugins?: readonly unknown[];
98
+ serverDirs?: string[];
99
+ viteRoot?: string;
100
+ workspace?: false | WorkspaceOptions;
101
+ }
102
+ type NitroConfig = {
103
+ cloudflare?: {
104
+ wrangler?: {
105
+ artifacts?: Array<{
106
+ binding: string;
107
+ namespace: string;
108
+ }>;
109
+ compatibility_flags?: string[];
110
+ } & Record<string, unknown>;
111
+ } & Record<string, unknown>;
112
+ plugins?: unknown[];
113
+ rollupConfig?: {
114
+ external?: unknown;
115
+ } & Record<string, unknown>;
116
+ } & Record<string, unknown>;
117
+ export declare function createWorkspaceNitroConfig(options?: WorkspaceNitroConfigOptions): Promise<NitroConfig | null>;
118
+ interface WorkspaceVitePluginAPI {
119
+ getWorkspaces: () => Array<{
120
+ name: string;
121
+ }>;
122
+ }
123
+ interface WorkspaceCliContributingPlugin {
124
+ vitehub?: ViteHubInspectionPluginMetadata & DurabilityPluginMetadata & {
125
+ cli?: () => unknown | Promise<unknown>;
126
+ operations?: readonly OperationContributionEntry[];
127
+ };
128
+ }
129
+ declare const setWorkspacePluginHosting: unique symbol;
130
+ type WorkspacePluginHosting = string | (() => string | undefined);
131
+ type WorkspaceVitePlugin = Plugin & WorkspaceCliContributingPlugin & {
132
+ [setWorkspacePluginHosting]?: (hosting: WorkspacePluginHosting) => void;
133
+ api: WorkspaceVitePluginAPI;
134
+ };
135
+ export declare function hubWorkspace(options?: WorkspaceOptions | false): WorkspaceVitePlugin;
136
+ //#endregion
137
+ //#region ../internal/src/contributions.d.ts
138
+ /** Module and export that hold a contributed Definition. */
139
+ interface ContributionDefinition {
140
+ /**
141
+ * Absolute file path, `file:` URL, or package specifier that the application can import. Relative paths are
142
+ * rejected because they have no stable base.
143
+ */
144
+ module: string;
145
+ /** Named export that holds the Definition. Defaults to `default`. */
146
+ export?: string;
147
+ }
148
+ /**
149
+ * One Definition that a Vite plugin adds to a Server Primitive, for example a Workspace, a Schedule, or Database tables.
150
+ * Every owner package reads this shape from `plugin.vitehub.<key>`. Owners can add fields, such as `database`.
151
+ */
152
+ interface Contribution {
153
+ /** Unique name in the owner, for example the Workspace or Schedule name. */
154
+ name: string;
155
+ definition: ContributionDefinition;
156
+ /** Why the plugin adds the Definition. `vitehub inspect` and the Console show it. */
157
+ reason?: string;
158
+ }
159
+ /** Roots that ViteHub passes to every contribution factory. */
160
+ interface ContributionContext {
161
+ /** Vite root. */
162
+ root: string;
163
+ /** ViteHub project root. It can differ from the Vite root, for example in a Nuxt app with a `srcDir`. */
164
+ projectRoot: string;
165
+ /** Server directories that the host forwards, for example Nuxt's `serverDir` and the server directories of layers. */
166
+ serverDirs?: readonly string[];
167
+ }
168
+ /**
169
+ * Returns the contributions of a plugin. It runs once per discovery pass, so it must be idempotent and must not depend
170
+ * on the order of Vite config hooks.
171
+ */
172
+ type ContributionFactory<TEntry extends Contribution = Contribution> = (context: ContributionContext) => readonly TEntry[] | undefined | Promise<readonly TEntry[] | undefined>;
173
+ type ContributionSource<TEntry extends Contribution = Contribution> = readonly TEntry[] | ContributionFactory<TEntry>;
174
+ /** A Vite plugin that contributes Definitions under `vitehub[TKey]`. */
175
+ type ContributingPlugin<TKey extends string, TEntry extends Contribution = Contribution> = {
176
+ name?: string;
177
+ vitehub?: { [K in TKey]?: ContributionSource<TEntry>; };
178
+ };
179
+ /** A validated contribution with its export resolved and the name of the plugin that added it. */
180
+ interface CollectedContribution {
181
+ name: string;
182
+ definition: {
183
+ module: string;
184
+ export: string;
185
+ };
186
+ reason?: string;
187
+ /** Name of the contributing Vite plugin. */
188
+ plugin: string;
189
+ }
190
+ //#endregion
191
+ //#region src/build/contributions.d.ts
192
+ /**
193
+ * A Workspace Definition that another package registers from its Vite plugin. The Workspace plugin adds it to the
194
+ * generated registry next to the discovered files, so `useWorkspace(name)`, typegen, inspection, and the Console
195
+ * treat it like `server/workspaces/<name>.ts`. `definition.export` names the export that holds the `defineWorkspace()`
196
+ * result.
197
+ */
198
+ type WorkspaceContribution = Contribution;
199
+ /**
200
+ * Roots that ViteHub passes to contribution factories. `root` is the Vite root. `plugins` holds the Vite plugins, so a
201
+ * factory can read sibling plugins, for example the Database plugin.
202
+ */
203
+ interface WorkspaceContributionContext extends ContributionContext {
204
+ plugins?: readonly unknown[];
205
+ }
206
+ type WorkspaceContributionFactory = (context: WorkspaceContributionContext) => ReturnType<ContributionFactory<WorkspaceContribution>>;
207
+ /** A Vite plugin that contributes Workspace Definitions through `vitehub.workspaces`. */
208
+ type WorkspaceContributingPlugin = ContributingPlugin<"workspaces", WorkspaceContribution>;
209
+ /** A validated contribution with its export resolved and the name of the plugin that contributed it. */
210
+ type CollectedWorkspaceContribution = CollectedContribution;
211
+ /**
212
+ * Collects `vitehub.workspaces` contributions from Vite plugins. Invalid entries fail with `WORKSPACE_B0004`. Two
213
+ * contributions with one name fail with `WORKSPACE_B0003`.
214
+ */
215
+ export declare function collectWorkspaceContributions(plugins: readonly unknown[] | undefined, context: WorkspaceContributionContext): Promise<CollectedWorkspaceContribution[]>;
216
+ //#endregion
217
+ //#region src/build/discovery.d.ts
218
+ interface DiscoveredWorkspaceDefinition {
219
+ /** Plugin that contributed the definition. Only set for contributed definitions. */
220
+ contributor?: string;
221
+ /** Named export that holds the definition. Discovered files always use `default`. */
222
+ export?: string;
223
+ handler: string;
224
+ name: string;
225
+ /** Absolute file path, or the package specifier of a contributed definition. */
226
+ path: string;
227
+ /** Why the plugin contributed the definition. Only set for contributed definitions. */
228
+ reason?: string;
229
+ source?: string;
230
+ sourceRootDir?: string;
231
+ }
232
+ interface ViteWorkspaceDiscoveryOptions {
233
+ /** Workspace Definitions that Vite plugins contribute. See `collectWorkspaceContributions()`. */
234
+ contributions?: readonly CollectedWorkspaceContribution[];
235
+ serverDirs?: string[];
236
+ serverRootDir?: string;
237
+ }
238
+ export declare function discoverViteWorkspaceDefinitions(rootDir: string, options?: ViteWorkspaceDiscoveryOptions): DiscoveredWorkspaceDefinition[];
239
+ //#endregion
240
+ //#region ../internal/src/console.d.ts
241
+ type MaybePromise<T> = T | Promise<T>;
242
+ /** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
243
+ interface ViteHubConsoleDefinitionCatalogView {
244
+ kind: "definition-catalog";
245
+ /** States which runtime data this catalog does not include. */
246
+ notice: string;
247
+ }
248
+ /** Lists Workspace Definitions like a catalog, and browses the refs, revisions, and files of the selected one. */
249
+ interface ViteHubConsoleWorkspaceBrowserView {
250
+ kind: "workspace-browser";
251
+ /** States which runtime data the browser does not include. */
252
+ notice: string;
253
+ }
254
+ interface ViteHubConsoleRecordColumn {
255
+ /** Set it for a column with few values, such as a status. The Console then filters the table by its values. */
256
+ filter?: boolean;
257
+ /** Key in `ViteHubConsoleRecord.cells`. */
258
+ key: string;
259
+ label: string;
260
+ }
261
+ /** Shows records in a table and the selected record's fields in a detail panel. */
262
+ interface ViteHubConsoleRecordTableView {
263
+ columns: readonly ViteHubConsoleRecordColumn[];
264
+ kind: "record-table";
265
+ /** States the source and limits of the records. */
266
+ notice: string;
267
+ }
268
+ /**
269
+ * Lists the collections and documents of an owner runtime and edits them with owner actions: a form generated from each
270
+ * collection's JSON Schema, a Markdown body, save, publish, and revision history.
271
+ */
272
+ interface ViteHubConsoleDocumentEditorView {
273
+ kind: "document-editor";
274
+ /** States where documents are stored and what the editor does not do. */
275
+ notice: string;
276
+ }
277
+ interface ViteHubConsoleOperationColumn {
278
+ /** Dot path into each item of the result, such as `author.name` or `messages.0.body`. */
279
+ key: string;
280
+ label: string;
281
+ /**
282
+ * `datetime` shows a time in milliseconds since the epoch as a relative date, such as `5m ago`. `excerpt` cuts a long
283
+ * text. `status` shows the value as a status with a colored dot, such as `Open`. `tones` picks the color of each value.
284
+ * `switch` shows a boolean as a switch that calls the `switch` operation.
285
+ */
286
+ format?: "datetime" | "excerpt" | "status" | "switch";
287
+ /** The color of each value of a `status` column, such as `{ open: "info", resolved: "success" }`. Other values are neutral. */
288
+ tones?: Readonly<Record<string, "error" | "info" | "neutral" | "success" | "warning">>;
289
+ /**
290
+ * What a `switch` column calls when the user flips it: `operation` with an input that maps each key of `input` to a
291
+ * dot path of the item, and the column `key` to the new value. `{ operation: "skills.set", input: { name: "name" } }`
292
+ * on the column `enabled` calls `skills.set` with `{ name, enabled }`, then loads the list again. A user who may only
293
+ * read the section sees the switch disabled.
294
+ */
295
+ switch?: {
296
+ operation: string;
297
+ input: Readonly<Record<string, string>>;
298
+ };
299
+ }
300
+ /**
301
+ * A button on each row that calls `operation` with the Console user, then loads the list again. `input` maps each input
302
+ * key to a dot path of the item, as a `switch` column does.
303
+ */
304
+ interface ViteHubConsoleOperationAction {
305
+ label: string;
306
+ operation: string;
307
+ input: Readonly<Record<string, string>>;
308
+ /**
309
+ * 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
310
+ * the list again when the person comes back. The URL must be `https:`, or `http:` on a loopback host.
311
+ */
312
+ tab?: true;
313
+ /** Show the button only on rows where each dot path holds one of the listed values. */
314
+ when?: Readonly<Record<string, readonly string[]>>;
315
+ /** Ask this question before the call. `{path}` takes a value from the item. */
316
+ confirm?: string;
317
+ }
318
+ /** A chip above the list. Choosing it merges `input` into the operation input. The first chip is the default. */
319
+ interface ViteHubConsoleOperationFilter {
320
+ id: string;
321
+ label: string;
322
+ input: Readonly<Record<string, unknown>>;
323
+ }
324
+ /**
325
+ * Lists the items that an operation returns, called over the Console RPC with the signed-in Console user. The operation
326
+ * checks the access of that user for each item, so the view shows only what the user may read. `operation` must return an
327
+ * array of objects with an `id`. A failure of the operation, with its `fix`, shows where the list would be.
328
+ */
329
+ interface ViteHubConsoleOperationView {
330
+ /** Buttons on each row. A user who may only read the section does not see them. */
331
+ actions?: readonly ViteHubConsoleOperationAction[];
332
+ columns: readonly ViteHubConsoleOperationColumn[];
333
+ /**
334
+ * Opens the item of a row in a side panel. `comment-thread` shows an item of `comments.list` as a comment thread
335
+ * where the user reads, replies, resolves, reopens, and mentions people. The panel calls the `comments.*` operations
336
+ * with the Console user, and `?thread=<id>` in the URL opens it.
337
+ */
338
+ detail?: {
339
+ kind: "comment-thread";
340
+ };
341
+ filters?: readonly ViteHubConsoleOperationFilter[];
342
+ kind: "operation-view";
343
+ /**
344
+ * Makes each row a link: `{path}` placeholders take values from the item and are URL-encoded, and `{path:path}` takes an
345
+ * app path and encodes each segment (a value that is not an app path, such as `//evil.com/x`, gives no link).
346
+ * `{path:href}` takes an app URL that is already encoded, with its query, as it is. Rows where `when.path` is not
347
+ * `when.equals` get none.
348
+ */
349
+ link?: {
350
+ label?: string;
351
+ template: string;
352
+ when?: {
353
+ equals: string;
354
+ path: string;
355
+ };
356
+ };
357
+ notice: string;
358
+ /** Operation name, such as `comments.list`. */
359
+ operation: string;
360
+ /** Fetch every page with `limit` and a `before` object whose keys read these dot paths from the last item. */
361
+ pagination?: {
362
+ limit: number;
363
+ cursor: Readonly<Record<string, string>>;
364
+ };
365
+ }
366
+ interface ViteHubConsoleAuthView {
367
+ kind: "auth-management";
368
+ notice: string;
369
+ }
370
+ interface ViteHubConsoleAuthSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleAuthView> {}
371
+ /**
372
+ * The webhooks of the app, their pending debounce timers, and their delivery log. The Console calls the `webhooks.*`
373
+ * operations of `@vite-hub/webhooks` with the Console user to list them, send a test, send a pending delivery now,
374
+ * cancel it, and redeliver. It has no build-time data.
375
+ */
376
+ interface ViteHubConsoleWebhooksView {
377
+ kind: "webhooks";
378
+ notice: string;
379
+ }
380
+ interface ViteHubConsoleWebhooksSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleWebhooksView> {}
381
+ type ViteHubConsoleSectionView = ViteHubConsoleOperationView | ViteHubConsoleAuthView | ViteHubConsoleWebhooksView | ViteHubConsoleDefinitionCatalogView | ViteHubConsoleRecordTableView | ViteHubConsoleDocumentEditorView | ViteHubConsoleWorkspaceBrowserView;
382
+ /**
383
+ * The overview of a document editor section: document counts by state, the changes that wait for a publish, recent
384
+ * activity, and a New button per collection. It reads the owner `overview` action.
385
+ */
386
+ interface ViteHubConsoleDocumentDashboardView {
387
+ kind: "document-dashboard";
388
+ }
389
+ /**
390
+ * The media library of a document editor section: folders, uploads, alt text, focal points, and crops of the Blob Store
391
+ * that `blob.serve` serves. The owner decides who may use it with `mediaAccess`, and finds the documents that use a file
392
+ * with `references`. The page needs the Blob section, so declare it with `requires: ["blob"]`.
393
+ */
394
+ interface ViteHubConsoleMediaLibraryView {
395
+ kind: "media-library";
396
+ }
397
+ /**
398
+ * The singletons of a document editor section, such as site settings: one row per singleton that opens it in the
399
+ * editor. Singletons appear here instead of among the collections, and the Console hides the page when the section has
400
+ * none.
401
+ */
402
+ interface ViteHubConsoleDocumentSettingsView {
403
+ kind: "document-settings";
404
+ }
405
+ /** A view that the Console UI in `vite-hub` renders for a section page. */
406
+ type ViteHubConsoleSectionPageView = ViteHubConsoleDocumentDashboardView | ViteHubConsoleDocumentSettingsView | ViteHubConsoleMediaLibraryView;
407
+ /**
408
+ * A page of a section next to its main view, such as the Content dashboard or media library. The section sidebar lists
409
+ * the pages, and each page has its own URL:
410
+ *
411
+ * - `/_vitehub/<section>` serves the `index` page, or the main view when the section has none.
412
+ * - `/_vitehub/<section>/-/<page>` serves every other page. The `-` segment keeps page URLs apart from the main view's
413
+ * own segments, such as a collection name.
414
+ *
415
+ * Pages share the access of their section: `console.authorize` that allows the section allows every page of it.
416
+ */
417
+ interface ViteHubConsoleSectionPage {
418
+ /** Lowercase route segment, for example `media`. */
419
+ id: string;
420
+ /** Display name, for example `Media`. */
421
+ label: string;
422
+ /** Iconify class name, for example `i-lucide-image`. */
423
+ icon: string;
424
+ view: ViteHubConsoleSectionPageView;
425
+ /**
426
+ * Serve this page at the section root. At most one page sets it, and `/_vitehub/<section>/-/<id>` then redirects to
427
+ * the root.
428
+ */
429
+ index?: boolean;
430
+ /**
431
+ * Sidebar heading, for example `Assets`. Pages without a group lead the sidebar, above the main view's navigation.
432
+ * Grouped pages follow it, in the order their group first appears.
433
+ */
434
+ group?: string;
435
+ /** Section ids that the project must enable, such as `["blob"]`. The Console leaves the page out otherwise. */
436
+ requires?: readonly string[];
437
+ }
438
+ /** One entry of a record's activity, such as a comment in a thread. `at` is an ISO 8601 timestamp. */
439
+ interface ViteHubConsoleRecordActivity {
440
+ author: string;
441
+ at: string;
442
+ text: string;
443
+ }
444
+ /** One serializable record row. Values are display strings. Do not put credentials in records. */
445
+ interface ViteHubConsoleRecord {
446
+ cells: Readonly<Record<string, string>>;
447
+ fields: readonly ViteHubDefinitionField[];
448
+ id: string;
449
+ /** The Console can run this record when it represents a runnable Schedule Definition. */
450
+ runnable?: boolean;
451
+ /**
452
+ * Where the record lives in the app, such as the page of a comment thread. `href` is an app path that starts with one
453
+ * `/`, or an `https:` URL. The Console opens it in a new tab.
454
+ */
455
+ link?: {
456
+ href: string;
457
+ label: string;
458
+ };
459
+ /** Entries in time order, such as the comments of a thread. The Console shows them as a conversation. */
460
+ activity?: readonly ViteHubConsoleRecordActivity[];
461
+ }
462
+ /** Serializable description of a Console section. The Console UI in `vite-hub` renders the view. */
463
+ interface ViteHubConsoleSectionDescriptor<TView extends ViteHubConsoleSectionView = ViteHubConsoleSectionView> {
464
+ description: string;
465
+ /**
466
+ * Iconify class name, for example `i-lucide-inbox`. The Console draws with Lucide; `ph` also resolves. The
467
+ * Console build bundles the icon of every section in the `vite-hub` Console registry and fails if it cannot resolve one.
468
+ */
469
+ icon: string;
470
+ /** Lowercase route segment, for example `queues`. The Console serves the section at `/_vitehub/<id>`. */
471
+ id: string;
472
+ /** Plural display name, for example `Queues`. */
473
+ label: string;
474
+ view: TView;
475
+ /** Pages next to the main view, in sidebar order. Only document editor sections render pages today. */
476
+ pages?: readonly ViteHubConsoleSectionPage[];
477
+ }
478
+ interface ViteHubConsoleDefinitionCatalogSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleDefinitionCatalogView> {
479
+ /** Reads the section data on the server. The Console never runs it in the browser. */
480
+ read: (options: TOptions) => MaybePromise<readonly ViteHubDefinitionSummary[]>;
481
+ }
482
+ interface ViteHubConsoleRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
483
+ /** Reads the section data on the server. The Console never runs it in the browser. */
484
+ read: (options: TOptions) => MaybePromise<readonly ViteHubConsoleRecord[]>;
485
+ }
486
+ /** A named export of an owner package server module that the host imports in its generated server code. */
487
+ interface ViteHubConsoleServerExport {
488
+ /** Named export of `module`. */
489
+ export: string;
490
+ /**
491
+ * Absolute path of the owner module, such as `ownModule(import.meta.url, "runtime/console")`, or an owner package
492
+ * specifier that the host maps to a module path that the application can import.
493
+ */
494
+ module: string;
495
+ }
496
+ /**
497
+ * Server module export that returns records on each Console request. The export must be a
498
+ * {@link ViteHubConsoleRuntimeRecordReader}.
499
+ */
500
+ interface ViteHubConsoleRuntimeReader extends ViteHubConsoleServerExport {}
501
+ /**
502
+ * A record table that also reads records at request time. The Console shows the build-time records of `read` first,
503
+ * then the records of the `runtime` reader. A runtime record updates the build-time record with the same id: its cells
504
+ * and fields replace the build-time ones with the same key or label.
505
+ */
506
+ interface ViteHubConsoleRuntimeRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
507
+ /** Reads build-time records on the server. When omitted, the section has only runtime records. */
508
+ read?: (options: TOptions) => MaybePromise<readonly ViteHubConsoleRecord[]>;
509
+ runtime: ViteHubConsoleRuntimeReader;
510
+ /**
511
+ * Returns the absolute path of the application module that turns the section on, such as `server/comments.ts`, or
512
+ * `undefined` when the project has none. With it, the host shows the section only when the module exists; without
513
+ * it, a Vite option enables the section.
514
+ */
515
+ entry?: (options: TOptions) => MaybePromise<string | undefined>;
516
+ }
517
+ /** A section whose list comes from an operation, called with the Console user on each visit. It has no build-time data. */
518
+ interface ViteHubConsoleOperationSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleOperationView> {}
519
+ /**
520
+ * A document editor section. The owner finds the application module that holds its runtime, such as `server/content.ts`,
521
+ * and names the server export that turns that module into {@link ViteHubConsoleDocumentActions}. The host shows the
522
+ * section only when `entry` finds a module, imports the module on the first Console request, and checks the Console
523
+ * section before it calls an action. The owner actions check their own access policy for the signed-in user.
524
+ */
525
+ interface ViteHubConsoleDocumentEditorSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleDocumentEditorView> {
526
+ /** Returns the absolute path of the application module, or `undefined` when the project has none. */
527
+ entry: (options: TOptions) => MaybePromise<string | undefined>;
528
+ /**
529
+ * Reads, at build time and without running the application, what the project lacks for some editor features, such as
530
+ * a runner for scheduled publishes. The Console merges it with the owner `setup` action on each request.
531
+ */
532
+ inspect?: (options: TOptions, entry: string) => MaybePromise<ViteHubConsoleDocumentSetup>;
533
+ /** Owner export that must be a {@link ViteHubConsoleDocumentActionsFactory}. */
534
+ actions: ViteHubConsoleServerExport;
535
+ }
536
+ /**
537
+ * A Console section that an owner package contributes. The owner defines the label, icon, view, and data reader.
538
+ * `TOptions` is the discovery context that the host passes to `read`.
539
+ */
540
+ type ViteHubConsoleSectionContribution<TOptions = void> = ViteHubConsoleAuthSection | ViteHubConsoleWebhooksSection | ViteHubConsoleDefinitionCatalogSection<TOptions> | ViteHubConsoleRecordTableSection<TOptions> | ViteHubConsoleRuntimeRecordTableSection<TOptions> | ViteHubConsoleDocumentEditorSection<TOptions> | ViteHubConsoleOperationSection;
541
+ /** A fix that the owner names for a feature the project lacks, such as `Add authorize to defineContent().` */
542
+ interface ViteHubConsoleDocumentHint {
543
+ /** One sentence that names the fix. Text in backticks shows as code. */
544
+ message: string;
545
+ /** Absolute URL of the documentation for the fix. */
546
+ docs?: string;
547
+ }
548
+ /**
549
+ * What the project lacks for some editor features. The editor names each fix where the feature would be, instead of
550
+ * failing without a reason.
551
+ */
552
+ interface ViteHubConsoleDocumentSetup {
553
+ /** Present when no user can read anything because the owner has no access policy. */
554
+ access?: ViteHubConsoleDocumentHint;
555
+ /**
556
+ * Live co-editing. `definition` names the Realtime Definition whose rooms are `<collection>/<id>`; the editor joins
557
+ * the room of a Markdown document instead of taking the edit lease. `unavailable` names why the owner wanted live
558
+ * editing and the host cannot run it, such as a host without a Realtime authority. Absent when live editing is off.
559
+ */
560
+ live?: {
561
+ definition: string;
562
+ } | {
563
+ unavailable: string;
564
+ };
565
+ /**
566
+ * Present when nothing runs scheduled publishes. The editor disables Schedule, and overdue schedules name the fix.
567
+ */
568
+ schedule?: ViteHubConsoleDocumentHint;
569
+ }
570
+ //#endregion
571
+ //#region src/inspect.d.ts
572
+ interface WorkspaceInspectionOptions {
573
+ /** Vite plugins that can contribute Workspace Definitions through `vitehub.workspaces`. */
574
+ plugins?: readonly unknown[];
575
+ projectRoot: string;
576
+ rootDir: string;
577
+ serverDirs?: string[];
578
+ serverRootDir: string;
579
+ }
580
+ /** Lists Workspace Definitions, Agent workspaces, and contributed Workspaces as serializable inspection summaries. */
581
+ export declare function inspectWorkspaceDefinitions(options: WorkspaceInspectionOptions): Promise<ViteHubDefinitionSummary[]>;
582
+ /** Console section that lists discovered Workspace Definitions. `vitehub inspect definitions` reads the same data. */
583
+ export declare const workspaceConsoleSection: ViteHubConsoleSectionContribution<WorkspaceInspectionOptions>;
584
+ //#endregion
585
+ export type { CollectedWorkspaceContribution, DiscoveredWorkspaceDefinition, NitroConfig, ViteWorkspaceDiscoveryOptions, WorkspaceContributingPlugin, WorkspaceContribution, WorkspaceContributionContext, WorkspaceContributionFactory, WorkspaceInspectionOptions, WorkspaceNitroConfigOptions, WorkspaceVitePlugin, WorkspaceVitePluginAPI };