@vite-hub/sandbox 0.0.4 → 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.
- package/README.md +395 -37
- package/dist/abortable-CR01hzfi.js +57 -0
- package/dist/cloudflare-Cog_r2Me.js +910 -0
- package/dist/cloudflare-env-lookup-DzI6Xv1Y.js +16 -0
- package/dist/cloudflare-failure-CFQhalfh.js +50 -0
- package/dist/container-CqfD8yuE.js +868 -0
- package/dist/crabbox-sbV3Zjuo.js +1110 -0
- package/dist/error-diagnostics-5QT_BjbQ.js +354 -0
- package/dist/error-diagnostics-BJtLRL9w.js +536 -0
- package/dist/file-listing-CHtRrfo1.js +26 -0
- package/dist/file-lock-D0-XPogS.js +74 -0
- package/dist/index-DsoQAUb7.d.ts +594 -0
- package/dist/index.d.ts +2 -69
- package/dist/index.js +281 -1182
- package/dist/internal/cloudflare.d.ts +176 -0
- package/dist/internal/cloudflare.js +8 -0
- package/dist/internal/host-toolchain.d.ts +22 -0
- package/dist/internal/host-toolchain.js +96 -0
- package/dist/internal/vercel.d.ts +4 -0
- package/dist/internal/vercel.js +8 -0
- package/dist/invariant-DolT9EEx.js +22 -0
- package/dist/module-types-B0LQ5H2S.js +7 -0
- package/dist/module-types-DCeJbS9Z.d.ts +110 -0
- package/dist/process-sweep-CMaujWE5.js +33 -0
- package/dist/provider-resolution-C6AQzuFG.js +133 -0
- package/dist/remote-70ZVZZlq.js +265 -0
- package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
- package/dist/runtime-DHp6ImeP.js +32 -0
- package/dist/runtime-type-Deo4qzxN.js +9 -0
- package/dist/session-e0lyzjJ3.js +338 -0
- package/dist/shell-quote-Q3u3plif.js +6 -0
- package/dist/size-7AkVwGZb.js +118 -0
- package/dist/ssh.d.ts +63 -0
- package/dist/ssh.js +286 -0
- package/dist/task/index.d.ts +69 -0
- package/dist/task/index.js +1414 -0
- package/dist/task/runtime/empty-registry.d.ts +6 -0
- package/dist/{runtime → task/runtime}/empty-registry.js +2 -2
- package/dist/task/runtime/provider-loader.d.ts +18 -0
- package/dist/task/runtime/provider-loader.js +16 -0
- package/dist/task/runtime/providers/cloudflare.d.ts +14 -0
- package/dist/task/runtime/providers/cloudflare.js +27 -0
- package/dist/task/runtime/providers/vercel.d.ts +12 -0
- package/dist/task/runtime/providers/vercel.js +85 -0
- package/dist/task/runtime/state.d.ts +27 -0
- package/dist/task/runtime/state.js +82 -0
- package/dist/task/vite.d.ts +486 -0
- package/dist/task/vite.js +3966 -0
- package/dist/toolchain-BIVGMRty.js +528 -0
- package/dist/trusted-host-kxkpaQcs.js +714 -0
- package/dist/vercel-BGGrNpza.js +352 -0
- package/package.json +105 -51
- package/dist/cloudflare-env-QQV4uzCT.js +0 -14
- package/dist/module-types-DKYItiOu.d.ts +0 -93
- package/dist/module-types-Dj1MFmHT.js +0 -7
- package/dist/provider-loader-D0UihePq.d.ts +0 -21
- package/dist/runtime/empty-registry.d.ts +0 -6
- package/dist/runtime/provider-loader.d.ts +0 -2
- package/dist/runtime/provider-loader.js +0 -15
- package/dist/runtime/providers/cloudflare.d.ts +0 -29
- package/dist/runtime/providers/cloudflare.js +0 -25
- package/dist/runtime/providers/vercel.d.ts +0 -121
- package/dist/runtime/providers/vercel.js +0 -51
- package/dist/runtime/state.d.ts +0 -26
- package/dist/runtime/state.js +0 -72
- package/dist/vite.d.ts +0 -48
- package/dist/vite.js +0 -3324
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import { t as AgentSandboxTaskConfig } from "../module-types-DCeJbS9Z.js";
|
|
2
|
+
import { Plugin } from "vite";
|
|
3
|
+
//#region ../internal/src/deployment.d.ts
|
|
4
|
+
/** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
|
|
5
|
+
type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region ../internal/src/inspect.d.ts
|
|
8
|
+
interface ViteHubDefinitionField {
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
/** Serializable summary of one discovered Definition. Files are relative to the project root. */
|
|
13
|
+
interface ViteHubDefinitionSummary {
|
|
14
|
+
fields: readonly ViteHubDefinitionField[];
|
|
15
|
+
file: string;
|
|
16
|
+
name: string;
|
|
17
|
+
source: string;
|
|
18
|
+
}
|
|
19
|
+
/** Lists the Definitions that one owner package discovered for the resolved Vite config. */
|
|
20
|
+
interface ViteHubDefinitionInspector {
|
|
21
|
+
/** Stable singular kind, for example `queue` or `rate-limit`. */
|
|
22
|
+
kind: string;
|
|
23
|
+
label: string;
|
|
24
|
+
list: () => Promise<readonly ViteHubDefinitionSummary[]> | readonly ViteHubDefinitionSummary[];
|
|
25
|
+
}
|
|
26
|
+
/** One generated Provider Output file or directory that an owner package can write. */
|
|
27
|
+
interface ViteHubProviderOutputEntry {
|
|
28
|
+
description: string;
|
|
29
|
+
owner: string;
|
|
30
|
+
/** Absolute path. */
|
|
31
|
+
path: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Where an inspected resource id came from. `name` means the host binds the resource by its name and needs no id.
|
|
35
|
+
* The CLI sets `provider-output` when only a generated Wrangler config names the id.
|
|
36
|
+
*/
|
|
37
|
+
type ViteHubResourceIdSource = "config" | "env" | "name" | "provider-output" | "provision-state";
|
|
38
|
+
/** One host resource that a Definition or store maps to. Owner packages read only local config and Provision State. */
|
|
39
|
+
interface ViteHubResourceSummary {
|
|
40
|
+
/** Cloudflare binding name, so the CLI can find the id in generated Wrangler config. */
|
|
41
|
+
binding?: string;
|
|
42
|
+
/** Definition or store name. */
|
|
43
|
+
definition: string;
|
|
44
|
+
/** Env variable that supplied the id when `source` is `env`. */
|
|
45
|
+
env?: string;
|
|
46
|
+
host: "cloudflare" | "vercel";
|
|
47
|
+
id?: string;
|
|
48
|
+
/** Same resource kind names as Provision actions, for example `cloudflare-d1`. */
|
|
49
|
+
kind: string;
|
|
50
|
+
/** Resource name on the host, when the config names it. */
|
|
51
|
+
name?: string;
|
|
52
|
+
/** Explains how the host finds the resource when no id or name is known locally. */
|
|
53
|
+
note?: string;
|
|
54
|
+
owner: string;
|
|
55
|
+
/** Absent when no id is known yet. */
|
|
56
|
+
source?: ViteHubResourceIdSource;
|
|
57
|
+
}
|
|
58
|
+
interface ViteHubInspectionContributor {
|
|
59
|
+
definitions?: readonly ViteHubDefinitionInspector[];
|
|
60
|
+
providerOutput?: readonly ViteHubProviderOutputEntry[];
|
|
61
|
+
resources?: () => readonly ViteHubResourceSummary[] | Promise<readonly ViteHubResourceSummary[]>;
|
|
62
|
+
}
|
|
63
|
+
type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor | undefined | Promise<ViteHubInspectionContributor | undefined>;
|
|
64
|
+
interface ViteHubInspectionPluginMetadata {
|
|
65
|
+
inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region ../internal/src/build/deployment-plan-output.d.ts
|
|
69
|
+
/**
|
|
70
|
+
* One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
|
|
71
|
+
* a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
|
|
72
|
+
* It holds names only, so `vitehub deploy` can check the host without booting Vite. It never holds a value.
|
|
73
|
+
*/
|
|
74
|
+
interface DeploymentEnvEntry {
|
|
75
|
+
/** The declaration path, such as `env.server.github.token`, when it is safe to show. Primitive entries have none. */
|
|
76
|
+
path?: string;
|
|
77
|
+
/** The host variable names, in read order. The first name that is set supplies the value. */
|
|
78
|
+
names: readonly string[];
|
|
79
|
+
/** Any variable whose name starts with this prefix supplies the value, such as `VITEHUB_CONSOLE_KEY_`. */
|
|
80
|
+
prefix?: string;
|
|
81
|
+
required: boolean;
|
|
82
|
+
secret: boolean;
|
|
83
|
+
/** A default supplies the value when no name is set. */
|
|
84
|
+
hasDefault: boolean;
|
|
85
|
+
/** The primitives that read these names, such as `blob`. Server Env declarations have none. */
|
|
86
|
+
owners?: readonly string[];
|
|
87
|
+
}
|
|
88
|
+
/** What a primitive needs to know to name the variables it reads in the deployed app. */
|
|
89
|
+
interface DeploymentEnvContext {
|
|
90
|
+
host: ViteHubHost;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The host variables that a primitive reads itself, outside the Server Env registry, for one host and its resolved
|
|
94
|
+
* config. A Vite plugin exposes it as `api.deploymentEnv`, and the build writes the result to `deployment.json`.
|
|
95
|
+
* Return names only, never values.
|
|
96
|
+
*/
|
|
97
|
+
type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/task/internal/shared/feature-definitions.d.ts
|
|
100
|
+
interface ScannedDefinition {
|
|
101
|
+
name: string;
|
|
102
|
+
handler: string;
|
|
103
|
+
_meta: {
|
|
104
|
+
filename: string;
|
|
105
|
+
sourcePath: string;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/task/discovery.d.ts
|
|
110
|
+
interface DiscoveredSandboxTaskDefinition extends ScannedDefinition {
|
|
111
|
+
kind: 'definition' | 'package-entry';
|
|
112
|
+
source: 'server-sandbox-tasks' | 'vite-suffix';
|
|
113
|
+
}
|
|
114
|
+
export declare function discoverSandboxTaskDefinitions(options: {
|
|
115
|
+
mode?: 'vite-suffix';
|
|
116
|
+
rootDir: string;
|
|
117
|
+
scanDirs?: string[];
|
|
118
|
+
} | {
|
|
119
|
+
mode: 'server-sandbox-tasks';
|
|
120
|
+
scanDirs: string[];
|
|
121
|
+
}): DiscoveredSandboxTaskDefinition[];
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region ../internal/src/console.d.ts
|
|
124
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
125
|
+
/** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
|
|
126
|
+
interface ViteHubConsoleDefinitionCatalogView {
|
|
127
|
+
kind: "definition-catalog";
|
|
128
|
+
/** States which runtime data this catalog does not include. */
|
|
129
|
+
notice: string;
|
|
130
|
+
}
|
|
131
|
+
/** Lists Workspace Definitions like a catalog, and browses the refs, revisions, and files of the selected one. */
|
|
132
|
+
interface ViteHubConsoleWorkspaceBrowserView {
|
|
133
|
+
kind: "workspace-browser";
|
|
134
|
+
/** States which runtime data the browser does not include. */
|
|
135
|
+
notice: string;
|
|
136
|
+
}
|
|
137
|
+
interface ViteHubConsoleRecordColumn {
|
|
138
|
+
/** Set it for a column with few values, such as a status. The Console then filters the table by its values. */
|
|
139
|
+
filter?: boolean;
|
|
140
|
+
/** Key in `ViteHubConsoleRecord.cells`. */
|
|
141
|
+
key: string;
|
|
142
|
+
label: string;
|
|
143
|
+
}
|
|
144
|
+
/** Shows records in a table and the selected record's fields in a detail panel. */
|
|
145
|
+
interface ViteHubConsoleRecordTableView {
|
|
146
|
+
columns: readonly ViteHubConsoleRecordColumn[];
|
|
147
|
+
kind: "record-table";
|
|
148
|
+
/** States the source and limits of the records. */
|
|
149
|
+
notice: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Lists the collections and documents of an owner runtime and edits them with owner actions: a form generated from each
|
|
153
|
+
* collection's JSON Schema, a Markdown body, save, publish, and revision history.
|
|
154
|
+
*/
|
|
155
|
+
interface ViteHubConsoleDocumentEditorView {
|
|
156
|
+
kind: "document-editor";
|
|
157
|
+
/** States where documents are stored and what the editor does not do. */
|
|
158
|
+
notice: string;
|
|
159
|
+
}
|
|
160
|
+
interface ViteHubConsoleOperationColumn {
|
|
161
|
+
/** Dot path into each item of the result, such as `author.name` or `messages.0.body`. */
|
|
162
|
+
key: string;
|
|
163
|
+
label: string;
|
|
164
|
+
/**
|
|
165
|
+
* `datetime` shows a time in milliseconds since the epoch as a relative date, such as `5m ago`. `excerpt` cuts a long
|
|
166
|
+
* text. `status` shows the value as a status with a colored dot, such as `Open`. `tones` picks the color of each value.
|
|
167
|
+
* `switch` shows a boolean as a switch that calls the `switch` operation.
|
|
168
|
+
*/
|
|
169
|
+
format?: "datetime" | "excerpt" | "status" | "switch";
|
|
170
|
+
/** The color of each value of a `status` column, such as `{ open: "info", resolved: "success" }`. Other values are neutral. */
|
|
171
|
+
tones?: Readonly<Record<string, "error" | "info" | "neutral" | "success" | "warning">>;
|
|
172
|
+
/**
|
|
173
|
+
* What a `switch` column calls when the user flips it: `operation` with an input that maps each key of `input` to a
|
|
174
|
+
* dot path of the item, and the column `key` to the new value. `{ operation: "skills.set", input: { name: "name" } }`
|
|
175
|
+
* on the column `enabled` calls `skills.set` with `{ name, enabled }`, then loads the list again. A user who may only
|
|
176
|
+
* read the section sees the switch disabled.
|
|
177
|
+
*/
|
|
178
|
+
switch?: {
|
|
179
|
+
operation: string;
|
|
180
|
+
input: Readonly<Record<string, string>>;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* A button on each row that calls `operation` with the Console user, then loads the list again. `input` maps each input
|
|
185
|
+
* key to a dot path of the item, as a `switch` column does.
|
|
186
|
+
*/
|
|
187
|
+
interface ViteHubConsoleOperationAction {
|
|
188
|
+
label: string;
|
|
189
|
+
operation: string;
|
|
190
|
+
input: Readonly<Record<string, string>>;
|
|
191
|
+
/**
|
|
192
|
+
* 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
|
|
193
|
+
* the list again when the person comes back. The URL must be `https:`, or `http:` on a loopback host.
|
|
194
|
+
*/
|
|
195
|
+
tab?: true;
|
|
196
|
+
/** Show the button only on rows where each dot path holds one of the listed values. */
|
|
197
|
+
when?: Readonly<Record<string, readonly string[]>>;
|
|
198
|
+
/** Ask this question before the call. `{path}` takes a value from the item. */
|
|
199
|
+
confirm?: string;
|
|
200
|
+
}
|
|
201
|
+
/** A chip above the list. Choosing it merges `input` into the operation input. The first chip is the default. */
|
|
202
|
+
interface ViteHubConsoleOperationFilter {
|
|
203
|
+
id: string;
|
|
204
|
+
label: string;
|
|
205
|
+
input: Readonly<Record<string, unknown>>;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Lists the items that an operation returns, called over the Console RPC with the signed-in Console user. The operation
|
|
209
|
+
* checks the access of that user for each item, so the view shows only what the user may read. `operation` must return an
|
|
210
|
+
* array of objects with an `id`. A failure of the operation, with its `fix`, shows where the list would be.
|
|
211
|
+
*/
|
|
212
|
+
interface ViteHubConsoleOperationView {
|
|
213
|
+
/** Buttons on each row. A user who may only read the section does not see them. */
|
|
214
|
+
actions?: readonly ViteHubConsoleOperationAction[];
|
|
215
|
+
columns: readonly ViteHubConsoleOperationColumn[];
|
|
216
|
+
/**
|
|
217
|
+
* Opens the item of a row in a side panel. `comment-thread` shows an item of `comments.list` as a comment thread
|
|
218
|
+
* where the user reads, replies, resolves, reopens, and mentions people. The panel calls the `comments.*` operations
|
|
219
|
+
* with the Console user, and `?thread=<id>` in the URL opens it.
|
|
220
|
+
*/
|
|
221
|
+
detail?: {
|
|
222
|
+
kind: "comment-thread";
|
|
223
|
+
};
|
|
224
|
+
filters?: readonly ViteHubConsoleOperationFilter[];
|
|
225
|
+
kind: "operation-view";
|
|
226
|
+
/**
|
|
227
|
+
* Makes each row a link: `{path}` placeholders take values from the item and are URL-encoded, and `{path:path}` takes an
|
|
228
|
+
* app path and encodes each segment (a value that is not an app path, such as `//evil.com/x`, gives no link).
|
|
229
|
+
* `{path:href}` takes an app URL that is already encoded, with its query, as it is. Rows where `when.path` is not
|
|
230
|
+
* `when.equals` get none.
|
|
231
|
+
*/
|
|
232
|
+
link?: {
|
|
233
|
+
label?: string;
|
|
234
|
+
template: string;
|
|
235
|
+
when?: {
|
|
236
|
+
equals: string;
|
|
237
|
+
path: string;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
notice: string;
|
|
241
|
+
/** Operation name, such as `comments.list`. */
|
|
242
|
+
operation: string;
|
|
243
|
+
/** Fetch every page with `limit` and a `before` object whose keys read these dot paths from the last item. */
|
|
244
|
+
pagination?: {
|
|
245
|
+
limit: number;
|
|
246
|
+
cursor: Readonly<Record<string, string>>;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
interface ViteHubConsoleAuthView {
|
|
250
|
+
kind: "auth-management";
|
|
251
|
+
notice: string;
|
|
252
|
+
}
|
|
253
|
+
interface ViteHubConsoleAuthSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleAuthView> {}
|
|
254
|
+
/**
|
|
255
|
+
* The webhooks of the app, their pending debounce timers, and their delivery log. The Console calls the `webhooks.*`
|
|
256
|
+
* operations of `@vite-hub/webhooks` with the Console user to list them, send a test, send a pending delivery now,
|
|
257
|
+
* cancel it, and redeliver. It has no build-time data.
|
|
258
|
+
*/
|
|
259
|
+
interface ViteHubConsoleWebhooksView {
|
|
260
|
+
kind: "webhooks";
|
|
261
|
+
notice: string;
|
|
262
|
+
}
|
|
263
|
+
interface ViteHubConsoleWebhooksSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleWebhooksView> {}
|
|
264
|
+
type ViteHubConsoleSectionView = ViteHubConsoleOperationView | ViteHubConsoleAuthView | ViteHubConsoleWebhooksView | ViteHubConsoleDefinitionCatalogView | ViteHubConsoleRecordTableView | ViteHubConsoleDocumentEditorView | ViteHubConsoleWorkspaceBrowserView;
|
|
265
|
+
/**
|
|
266
|
+
* The overview of a document editor section: document counts by state, the changes that wait for a publish, recent
|
|
267
|
+
* activity, and a New button per collection. It reads the owner `overview` action.
|
|
268
|
+
*/
|
|
269
|
+
interface ViteHubConsoleDocumentDashboardView {
|
|
270
|
+
kind: "document-dashboard";
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The media library of a document editor section: folders, uploads, alt text, focal points, and crops of the Blob Store
|
|
274
|
+
* that `blob.serve` serves. The owner decides who may use it with `mediaAccess`, and finds the documents that use a file
|
|
275
|
+
* with `references`. The page needs the Blob section, so declare it with `requires: ["blob"]`.
|
|
276
|
+
*/
|
|
277
|
+
interface ViteHubConsoleMediaLibraryView {
|
|
278
|
+
kind: "media-library";
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* The singletons of a document editor section, such as site settings: one row per singleton that opens it in the
|
|
282
|
+
* editor. Singletons appear here instead of among the collections, and the Console hides the page when the section has
|
|
283
|
+
* none.
|
|
284
|
+
*/
|
|
285
|
+
interface ViteHubConsoleDocumentSettingsView {
|
|
286
|
+
kind: "document-settings";
|
|
287
|
+
}
|
|
288
|
+
/** A view that the Console UI in `vite-hub` renders for a section page. */
|
|
289
|
+
type ViteHubConsoleSectionPageView = ViteHubConsoleDocumentDashboardView | ViteHubConsoleDocumentSettingsView | ViteHubConsoleMediaLibraryView;
|
|
290
|
+
/**
|
|
291
|
+
* A page of a section next to its main view, such as the Content dashboard or media library. The section sidebar lists
|
|
292
|
+
* the pages, and each page has its own URL:
|
|
293
|
+
*
|
|
294
|
+
* - `/_vitehub/<section>` serves the `index` page, or the main view when the section has none.
|
|
295
|
+
* - `/_vitehub/<section>/-/<page>` serves every other page. The `-` segment keeps page URLs apart from the main view's
|
|
296
|
+
* own segments, such as a collection name.
|
|
297
|
+
*
|
|
298
|
+
* Pages share the access of their section: `console.authorize` that allows the section allows every page of it.
|
|
299
|
+
*/
|
|
300
|
+
interface ViteHubConsoleSectionPage {
|
|
301
|
+
/** Lowercase route segment, for example `media`. */
|
|
302
|
+
id: string;
|
|
303
|
+
/** Display name, for example `Media`. */
|
|
304
|
+
label: string;
|
|
305
|
+
/** Iconify class name, for example `i-lucide-image`. */
|
|
306
|
+
icon: string;
|
|
307
|
+
view: ViteHubConsoleSectionPageView;
|
|
308
|
+
/**
|
|
309
|
+
* Serve this page at the section root. At most one page sets it, and `/_vitehub/<section>/-/<id>` then redirects to
|
|
310
|
+
* the root.
|
|
311
|
+
*/
|
|
312
|
+
index?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Sidebar heading, for example `Assets`. Pages without a group lead the sidebar, above the main view's navigation.
|
|
315
|
+
* Grouped pages follow it, in the order their group first appears.
|
|
316
|
+
*/
|
|
317
|
+
group?: string;
|
|
318
|
+
/** Section ids that the project must enable, such as `["blob"]`. The Console leaves the page out otherwise. */
|
|
319
|
+
requires?: readonly string[];
|
|
320
|
+
}
|
|
321
|
+
/** One entry of a record's activity, such as a comment in a thread. `at` is an ISO 8601 timestamp. */
|
|
322
|
+
interface ViteHubConsoleRecordActivity {
|
|
323
|
+
author: string;
|
|
324
|
+
at: string;
|
|
325
|
+
text: string;
|
|
326
|
+
}
|
|
327
|
+
/** One serializable record row. Values are display strings. Do not put credentials in records. */
|
|
328
|
+
interface ViteHubConsoleRecord {
|
|
329
|
+
cells: Readonly<Record<string, string>>;
|
|
330
|
+
fields: readonly ViteHubDefinitionField[];
|
|
331
|
+
id: string;
|
|
332
|
+
/** The Console can run this record when it represents a runnable Schedule Definition. */
|
|
333
|
+
runnable?: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Where the record lives in the app, such as the page of a comment thread. `href` is an app path that starts with one
|
|
336
|
+
* `/`, or an `https:` URL. The Console opens it in a new tab.
|
|
337
|
+
*/
|
|
338
|
+
link?: {
|
|
339
|
+
href: string;
|
|
340
|
+
label: string;
|
|
341
|
+
};
|
|
342
|
+
/** Entries in time order, such as the comments of a thread. The Console shows them as a conversation. */
|
|
343
|
+
activity?: readonly ViteHubConsoleRecordActivity[];
|
|
344
|
+
}
|
|
345
|
+
/** Serializable description of a Console section. The Console UI in `vite-hub` renders the view. */
|
|
346
|
+
interface ViteHubConsoleSectionDescriptor<TView extends ViteHubConsoleSectionView = ViteHubConsoleSectionView> {
|
|
347
|
+
description: string;
|
|
348
|
+
/**
|
|
349
|
+
* Iconify class name, for example `i-lucide-inbox`. The Console draws with Lucide; `ph` also resolves. The
|
|
350
|
+
* Console build bundles the icon of every section in the `vite-hub` Console registry and fails if it cannot resolve one.
|
|
351
|
+
*/
|
|
352
|
+
icon: string;
|
|
353
|
+
/** Lowercase route segment, for example `queues`. The Console serves the section at `/_vitehub/<id>`. */
|
|
354
|
+
id: string;
|
|
355
|
+
/** Plural display name, for example `Queues`. */
|
|
356
|
+
label: string;
|
|
357
|
+
view: TView;
|
|
358
|
+
/** Pages next to the main view, in sidebar order. Only document editor sections render pages today. */
|
|
359
|
+
pages?: readonly ViteHubConsoleSectionPage[];
|
|
360
|
+
}
|
|
361
|
+
interface ViteHubConsoleDefinitionCatalogSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleDefinitionCatalogView> {
|
|
362
|
+
/** Reads the section data on the server. The Console never runs it in the browser. */
|
|
363
|
+
read: (options: TOptions) => MaybePromise<readonly ViteHubDefinitionSummary[]>;
|
|
364
|
+
}
|
|
365
|
+
interface ViteHubConsoleRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
|
|
366
|
+
/** Reads the section data on the server. The Console never runs it in the browser. */
|
|
367
|
+
read: (options: TOptions) => MaybePromise<readonly ViteHubConsoleRecord[]>;
|
|
368
|
+
}
|
|
369
|
+
/** A named export of an owner package server module that the host imports in its generated server code. */
|
|
370
|
+
interface ViteHubConsoleServerExport {
|
|
371
|
+
/** Named export of `module`. */
|
|
372
|
+
export: string;
|
|
373
|
+
/**
|
|
374
|
+
* Absolute path of the owner module, such as `ownModule(import.meta.url, "runtime/console")`, or an owner package
|
|
375
|
+
* specifier that the host maps to a module path that the application can import.
|
|
376
|
+
*/
|
|
377
|
+
module: string;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Server module export that returns records on each Console request. The export must be a
|
|
381
|
+
* {@link ViteHubConsoleRuntimeRecordReader}.
|
|
382
|
+
*/
|
|
383
|
+
interface ViteHubConsoleRuntimeReader extends ViteHubConsoleServerExport {}
|
|
384
|
+
/**
|
|
385
|
+
* A record table that also reads records at request time. The Console shows the build-time records of `read` first,
|
|
386
|
+
* then the records of the `runtime` reader. A runtime record updates the build-time record with the same id: its cells
|
|
387
|
+
* and fields replace the build-time ones with the same key or label.
|
|
388
|
+
*/
|
|
389
|
+
interface ViteHubConsoleRuntimeRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
|
|
390
|
+
/** Reads build-time records on the server. When omitted, the section has only runtime records. */
|
|
391
|
+
read?: (options: TOptions) => MaybePromise<readonly ViteHubConsoleRecord[]>;
|
|
392
|
+
runtime: ViteHubConsoleRuntimeReader;
|
|
393
|
+
/**
|
|
394
|
+
* Returns the absolute path of the application module that turns the section on, such as `server/comments.ts`, or
|
|
395
|
+
* `undefined` when the project has none. With it, the host shows the section only when the module exists; without
|
|
396
|
+
* it, a Vite option enables the section.
|
|
397
|
+
*/
|
|
398
|
+
entry?: (options: TOptions) => MaybePromise<string | undefined>;
|
|
399
|
+
}
|
|
400
|
+
/** A section whose list comes from an operation, called with the Console user on each visit. It has no build-time data. */
|
|
401
|
+
interface ViteHubConsoleOperationSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleOperationView> {}
|
|
402
|
+
/**
|
|
403
|
+
* A document editor section. The owner finds the application module that holds its runtime, such as `server/content.ts`,
|
|
404
|
+
* and names the server export that turns that module into {@link ViteHubConsoleDocumentActions}. The host shows the
|
|
405
|
+
* section only when `entry` finds a module, imports the module on the first Console request, and checks the Console
|
|
406
|
+
* section before it calls an action. The owner actions check their own access policy for the signed-in user.
|
|
407
|
+
*/
|
|
408
|
+
interface ViteHubConsoleDocumentEditorSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleDocumentEditorView> {
|
|
409
|
+
/** Returns the absolute path of the application module, or `undefined` when the project has none. */
|
|
410
|
+
entry: (options: TOptions) => MaybePromise<string | undefined>;
|
|
411
|
+
/**
|
|
412
|
+
* Reads, at build time and without running the application, what the project lacks for some editor features, such as
|
|
413
|
+
* a runner for scheduled publishes. The Console merges it with the owner `setup` action on each request.
|
|
414
|
+
*/
|
|
415
|
+
inspect?: (options: TOptions, entry: string) => MaybePromise<ViteHubConsoleDocumentSetup>;
|
|
416
|
+
/** Owner export that must be a {@link ViteHubConsoleDocumentActionsFactory}. */
|
|
417
|
+
actions: ViteHubConsoleServerExport;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* A Console section that an owner package contributes. The owner defines the label, icon, view, and data reader.
|
|
421
|
+
* `TOptions` is the discovery context that the host passes to `read`.
|
|
422
|
+
*/
|
|
423
|
+
type ViteHubConsoleSectionContribution<TOptions = void> = ViteHubConsoleAuthSection | ViteHubConsoleWebhooksSection | ViteHubConsoleDefinitionCatalogSection<TOptions> | ViteHubConsoleRecordTableSection<TOptions> | ViteHubConsoleRuntimeRecordTableSection<TOptions> | ViteHubConsoleDocumentEditorSection<TOptions> | ViteHubConsoleOperationSection;
|
|
424
|
+
/** A fix that the owner names for a feature the project lacks, such as `Add authorize to defineContent().` */
|
|
425
|
+
interface ViteHubConsoleDocumentHint {
|
|
426
|
+
/** One sentence that names the fix. Text in backticks shows as code. */
|
|
427
|
+
message: string;
|
|
428
|
+
/** Absolute URL of the documentation for the fix. */
|
|
429
|
+
docs?: string;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* What the project lacks for some editor features. The editor names each fix where the feature would be, instead of
|
|
433
|
+
* failing without a reason.
|
|
434
|
+
*/
|
|
435
|
+
interface ViteHubConsoleDocumentSetup {
|
|
436
|
+
/** Present when no user can read anything because the owner has no access policy. */
|
|
437
|
+
access?: ViteHubConsoleDocumentHint;
|
|
438
|
+
/**
|
|
439
|
+
* Live co-editing. `definition` names the Realtime Definition whose rooms are `<collection>/<id>`; the editor joins
|
|
440
|
+
* the room of a Markdown document instead of taking the edit lease. `unavailable` names why the owner wanted live
|
|
441
|
+
* editing and the host cannot run it, such as a host without a Realtime authority. Absent when live editing is off.
|
|
442
|
+
*/
|
|
443
|
+
live?: {
|
|
444
|
+
definition: string;
|
|
445
|
+
} | {
|
|
446
|
+
unavailable: string;
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Present when nothing runs scheduled publishes. The editor disables Schedule, and overdue schedules name the fix.
|
|
450
|
+
*/
|
|
451
|
+
schedule?: ViteHubConsoleDocumentHint;
|
|
452
|
+
}
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/task/inspect.d.ts
|
|
455
|
+
interface SandboxTaskInspectionOptions {
|
|
456
|
+
projectRoot: string;
|
|
457
|
+
rootDir: string;
|
|
458
|
+
}
|
|
459
|
+
/** Lists Sandbox Task Definitions and package entries as serializable inspection summaries. */
|
|
460
|
+
export declare function inspectSandboxTaskDefinitions(options: SandboxTaskInspectionOptions): ViteHubDefinitionSummary[];
|
|
461
|
+
/** Console section that lists discovered Sandbox Task Definitions. `vitehub inspect definitions` reads the same data. */
|
|
462
|
+
export declare const sandboxTaskConsoleSection: ViteHubConsoleSectionContribution<SandboxTaskInspectionOptions>;
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/task/vite.d.ts
|
|
465
|
+
export type SandboxTaskOptions = AgentSandboxTaskConfig | false;
|
|
466
|
+
export type SandboxTaskVitePlugin = Plugin & {
|
|
467
|
+
/** The variables that Sandbox Tasks read on the deployed host. See `sandboxDeploymentEnv()`. */
|
|
468
|
+
api: {
|
|
469
|
+
deploymentEnv: DeploymentEnvContribution;
|
|
470
|
+
};
|
|
471
|
+
vitehub: ViteHubInspectionPluginMetadata;
|
|
472
|
+
nitro: {
|
|
473
|
+
name: string;
|
|
474
|
+
setup: (nitro: {
|
|
475
|
+
hooks: {
|
|
476
|
+
hook: (name: 'build:before', callback: () => void) => void;
|
|
477
|
+
};
|
|
478
|
+
options: Record<string, unknown>;
|
|
479
|
+
}) => void;
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
/** The path of the Sandbox Task runtime state module. Generated code of other owners imports it by path. */
|
|
483
|
+
export declare const sandboxTaskRuntimeStateModule: string;
|
|
484
|
+
export declare function hubSandboxTask(options?: SandboxTaskOptions): SandboxTaskVitePlugin;
|
|
485
|
+
//#endregion
|
|
486
|
+
export type { DiscoveredSandboxTaskDefinition, SandboxTaskInspectionOptions };
|