@vite-hub/env 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.
Files changed (57) hide show
  1. package/README.md +288 -23
  2. package/dist/access-B8lSDip4.js +54 -0
  3. package/dist/bridge-Cs9YfQWk.d.ts +447 -0
  4. package/dist/bridge-error-BhJ77age.js +66 -0
  5. package/dist/bridge.d.ts +2 -0
  6. package/dist/bridge.js +354 -0
  7. package/dist/cli-BPp7rdcA.d.ts +159 -0
  8. package/dist/cli-DLpY0QAo.js +669 -0
  9. package/dist/cli.d.ts +41 -0
  10. package/dist/cli.js +2 -0
  11. package/dist/database.d.ts +47 -0
  12. package/dist/database.js +274 -0
  13. package/dist/declarations-C5XR3aKw.d.ts +58 -0
  14. package/dist/error-diagnostics-B8RFjQ1V.js +56 -0
  15. package/dist/index.d.ts +146 -11
  16. package/dist/index.js +240 -7
  17. package/dist/internal/agent.d.ts +5 -0
  18. package/dist/internal/agent.js +22 -0
  19. package/dist/internal/connections.d.ts +18 -0
  20. package/dist/internal/connections.js +31 -0
  21. package/dist/internal/server.d.ts +3 -0
  22. package/dist/internal/server.js +2 -0
  23. package/dist/object-_dlsZ4lP.js +276 -0
  24. package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
  25. package/dist/operations-X1w--wds.js +30 -0
  26. package/dist/operations.d.ts +37 -0
  27. package/dist/operations.js +833 -0
  28. package/dist/runtime/public-env.d.ts +5 -0
  29. package/dist/runtime/public-env.js +8 -0
  30. package/dist/runtime/server-env.d.ts +22 -0
  31. package/dist/runtime/server-env.js +35 -0
  32. package/dist/schema-DMZ1_yhY.js +360 -0
  33. package/dist/seal.d.ts +17 -0
  34. package/dist/seal.js +52 -0
  35. package/dist/{secret.js → secret-DJd-fy5T.js} +1 -1
  36. package/dist/server-ChNL_Xc3.js +1279 -0
  37. package/dist/server-Dd8bjIKd.d.ts +145 -0
  38. package/dist/server.d.ts +3 -8
  39. package/dist/server.js +2 -3
  40. package/dist/virtual-module.d.ts +9 -5
  41. package/dist/virtual.d.ts +1 -1
  42. package/dist/vite.d.ts +79 -21
  43. package/dist/vite.js +1095 -339
  44. package/package.json +81 -28
  45. package/dist/declarations-CoMmvRqH.js +0 -159
  46. package/dist/declarations-U6P3rvxC.d.ts +0 -24
  47. package/dist/errors-C4Xcs6Fi.js +0 -121
  48. package/dist/presets.d.ts +0 -11
  49. package/dist/presets.js +0 -25
  50. package/dist/provider.d.ts +0 -6
  51. package/dist/provider.js +0 -7
  52. package/dist/schema.d.ts +0 -16
  53. package/dist/schema.js +0 -37
  54. package/dist/secret-C2191nAa.d.ts +0 -11
  55. package/dist/secret.d.ts +0 -2
  56. package/dist/server-C16sFc1E.js +0 -303
  57. package/dist/types-CsB6DTGE.d.ts +0 -190
package/dist/bridge.js ADDED
@@ -0,0 +1,354 @@
1
+ import { t as SecretEnv } from "./secret-DJd-fy5T.js";
2
+ import { n as envBridgeErrorBody, r as sanitizeEnvBridgeError, t as envBridgeError } from "./bridge-error-BhJ77age.js";
3
+ import { i as validateEnvActor, n as envIdentifier, r as grantEnvAccess, t as envAccessAuthority } from "./access-B8lSDip4.js";
4
+ //#region src/auth.ts
5
+ const permissions$1 = [
6
+ "inspect",
7
+ "preview",
8
+ "replace",
9
+ "use"
10
+ ];
11
+ function identifier(value) {
12
+ return typeof value === "string" && value.length > 0 && value.length <= 512 && !/[\u0000-\u001f]/.test(value);
13
+ }
14
+ /** Authenticate management requests without coupling Env to a particular Better Auth plugin version. */
15
+ function createEnvAuthenticator(options) {
16
+ return async (request) => {
17
+ try {
18
+ const authorization = request.headers.get("authorization");
19
+ if (authorization !== null) {
20
+ if (!/^Bearer\s+\S+$/i.test(authorization) || !options.agents) return null;
21
+ const session = await options.agents.getSession({ headers: request.headers });
22
+ if (!session || !identifier(session.agent.id)) return null;
23
+ const scope = await options.agents.scope(session);
24
+ if (!Array.isArray(scope) || scope.some((grant) => !identifier(grant.key) || !Array.isArray(grant.permissions) || grant.permissions.some((permission) => !permissions$1.includes(permission)))) return null;
25
+ return grantEnvAccess({ actor: {
26
+ kind: "agent",
27
+ id: session.agent.id
28
+ } }, {
29
+ kind: "actor",
30
+ scope
31
+ });
32
+ }
33
+ const session = await options.getSession({ headers: request.headers });
34
+ if (!session || !identifier(session.user.id)) return null;
35
+ const actor = {
36
+ kind: "user",
37
+ id: session.user.id
38
+ };
39
+ return grantEnvAccess({ actor }, await options.isAdmin(session) === true ? { kind: "admin" } : { kind: "actor" });
40
+ } catch {
41
+ return null;
42
+ }
43
+ };
44
+ }
45
+ //#endregion
46
+ //#region src/http.ts
47
+ function record(value) {
48
+ return value !== null && typeof value === "object" && !Array.isArray(value);
49
+ }
50
+ function actor(value) {
51
+ if (!record(value) || typeof value.id !== "string" || value.kind !== "user" && value.kind !== "agent" && value.kind !== "service") throw envBridgeError("invalid");
52
+ return {
53
+ id: value.id,
54
+ kind: value.kind
55
+ };
56
+ }
57
+ const permissions = [
58
+ "inspect",
59
+ "preview",
60
+ "replace",
61
+ "use"
62
+ ];
63
+ async function body(request) {
64
+ const reader = request.body?.getReader();
65
+ if (!reader) throw envBridgeError("invalid");
66
+ const decoder = new TextDecoder();
67
+ let size = 0;
68
+ let text = "";
69
+ try {
70
+ while (true) {
71
+ const chunk = await reader.read();
72
+ if (chunk.done) break;
73
+ size += chunk.value.byteLength;
74
+ if (size > 65536) {
75
+ await reader.cancel();
76
+ throw envBridgeError("invalid");
77
+ }
78
+ text += decoder.decode(chunk.value, { stream: true });
79
+ }
80
+ const value = JSON.parse(text + decoder.decode());
81
+ if (!record(value)) throw envBridgeError("invalid");
82
+ return value;
83
+ } catch {
84
+ throw envBridgeError("invalid");
85
+ } finally {
86
+ reader.releaseLock();
87
+ }
88
+ }
89
+ function response(value, status = 200) {
90
+ return Response.json(value, {
91
+ status,
92
+ headers: {
93
+ "cache-control": "no-store",
94
+ "x-content-type-options": "nosniff",
95
+ "x-robots-tag": "noindex, nofollow"
96
+ }
97
+ });
98
+ }
99
+ /** Mount only on a server route. resolve selects declared credentials, never arbitrary store keys. */
100
+ function createEnvBridgeHandler(resolve) {
101
+ return async (request, options = {}) => {
102
+ if (request.method !== "POST") return response({ message: "Method not allowed." }, 405);
103
+ const origin = request.headers.get("origin");
104
+ if (origin ? origin !== new URL(request.url).origin && origin !== options.allowedOrigin : !/^Bearer\s+\S+$/i.test(request.headers.get("authorization") ?? "")) return response({ message: "Request origin is not allowed." }, 403);
105
+ try {
106
+ const input = await body(request);
107
+ if (typeof input.path !== "string" || input.path.length > 256) throw envBridgeError("invalid");
108
+ const target = resolve(input.path);
109
+ if (!target) return response({ message: "This variable is not managed." }, 404);
110
+ const context = await target.management.authenticate(request);
111
+ if (!context) return response({ message: "Authentication required." }, 401);
112
+ const { bridge } = target.management;
113
+ const key = target.key;
114
+ switch (input.action) {
115
+ case "permissions": return response({
116
+ permissions: await bridge.permissions(context, key),
117
+ admin: Boolean(context.admin && !context.scope)
118
+ });
119
+ case "inspect": return response({
120
+ metadata: await bridge.inspect(context, key) ?? null,
121
+ permissions: await bridge.permissions(context, key),
122
+ admin: Boolean(context.admin && !context.scope)
123
+ });
124
+ case "preview": {
125
+ const metadata = await bridge.preview(context, key);
126
+ return response({ metadata: metadata ? { preview: metadata.preview } : null });
127
+ }
128
+ case "replace": {
129
+ if (typeof input.value !== "string" || !(input.expectedRevision === null || typeof input.expectedRevision === "string")) throw envBridgeError("invalid");
130
+ const result = await bridge.replace(context, {
131
+ key,
132
+ value: input.value,
133
+ expectedRevision: input.expectedRevision
134
+ });
135
+ return response({
136
+ revision: result.revision,
137
+ updatedAt: result.updatedAt,
138
+ activation: result.activation
139
+ });
140
+ }
141
+ case "activity":
142
+ if (input.before !== void 0 && typeof input.before !== "string") throw envBridgeError("invalid");
143
+ return response({ events: await bridge.activity(context, key, input.before) });
144
+ case "grants": return response({ grants: await bridge.grants(context, key) });
145
+ case "grant":
146
+ if (!Array.isArray(input.permissions) || input.permissions.some((value) => !permissions.includes(value))) throw envBridgeError("invalid");
147
+ await bridge.grant(context, {
148
+ actor: actor(input.actor),
149
+ key,
150
+ permissions: input.permissions
151
+ });
152
+ return response({ ok: true });
153
+ case "revoke":
154
+ await bridge.revoke(context, actor(input.actor), key);
155
+ return response({ ok: true });
156
+ default: throw envBridgeError("invalid");
157
+ }
158
+ } catch (error) {
159
+ const safe = sanitizeEnvBridgeError(error);
160
+ const status = safe.code === "ENV_BRIDGE_DENIED" ? 403 : safe.code === "ENV_BRIDGE_CONFLICT" ? 409 : safe.code === "ENV_BRIDGE_INVALID" ? 400 : 503;
161
+ return response(envBridgeErrorBody(safe), status);
162
+ }
163
+ };
164
+ }
165
+ //#endregion
166
+ //#region src/bridge.ts
167
+ async function safe(run) {
168
+ try {
169
+ return await run();
170
+ } catch (error) {
171
+ throw sanitizeEnvBridgeError(error);
172
+ }
173
+ }
174
+ function createEnvBridge(options) {
175
+ async function persist(event) {
176
+ try {
177
+ await options.access.append(event);
178
+ } catch {
179
+ throw envBridgeError("audit_failed");
180
+ }
181
+ try {
182
+ await options.emit?.(structuredClone(event));
183
+ } catch {}
184
+ }
185
+ async function allowed(context, key, permission) {
186
+ const authority = envAccessAuthority(context);
187
+ envIdentifier(key);
188
+ validateEnvActor(context.actor);
189
+ if (authority.kind === "admin") return true;
190
+ if (authority.bridge && authority.bridge !== bridge) return false;
191
+ if (authority.kind === "key") return authority.key === key && permission !== "admin" && authority.permissions.includes(permission);
192
+ if (permission === "admin" || permission === "activity") return false;
193
+ if (authority.scope && !authority.scope.some((grant) => grant.key === key && grant.permissions.includes(permission))) return false;
194
+ return await safe(async () => {
195
+ const grants = await options.access.grants(key);
196
+ if (!Array.isArray(grants)) throw envBridgeError("operation_failed");
197
+ for (const grant of grants) {
198
+ if (!grant || typeof grant !== "object" || typeof grant.key !== "string" || !grant.actor || typeof grant.actor !== "object" || typeof grant.actor.id !== "string" || ![
199
+ "user",
200
+ "agent",
201
+ "service"
202
+ ].includes(grant.actor.kind) || !Array.isArray(grant.permissions) || !grant.permissions.every((value) => [
203
+ "inspect",
204
+ "preview",
205
+ "replace",
206
+ "use"
207
+ ].includes(value))) throw envBridgeError("operation_failed");
208
+ if (grant.key === key && grant.actor.id === context.actor.id && grant.actor.kind === context.actor.kind && grant.permissions.includes(permission)) return true;
209
+ }
210
+ return false;
211
+ });
212
+ }
213
+ async function audited(context, key, action, permission, run, operation, metadata) {
214
+ envAccessAuthority(context);
215
+ envIdentifier(key);
216
+ validateEnvActor(context.actor);
217
+ const base = {
218
+ operationId: crypto.randomUUID(),
219
+ actor: {
220
+ id: context.actor.id,
221
+ kind: context.actor.kind
222
+ },
223
+ key,
224
+ action,
225
+ ...context.traceId ? { traceId: context.traceId } : {},
226
+ ...context.invocationId ? { invocationId: context.invocationId } : {},
227
+ ...operation ? { operation } : {},
228
+ ...metadata?.target ? { target: metadata.target } : {},
229
+ ...metadata?.permissions ? { permissions: metadata.permissions } : {}
230
+ };
231
+ const event = (outcome) => ({
232
+ ...base,
233
+ id: crypto.randomUUID(),
234
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
235
+ outcome
236
+ });
237
+ if (!await allowed(context, key, permission)) {
238
+ await persist(event("denied"));
239
+ throw envBridgeError("denied");
240
+ }
241
+ await persist(event("started"));
242
+ let value;
243
+ try {
244
+ value = await run();
245
+ } catch (error) {
246
+ const revision = metadata?.revision?.();
247
+ await persist({
248
+ ...event("failed"),
249
+ ...revision ? { revision } : {}
250
+ });
251
+ throw sanitizeEnvBridgeError(error);
252
+ }
253
+ const revision = metadata?.revision?.();
254
+ await persist({
255
+ ...event("succeeded"),
256
+ ...revision ? { revision } : {}
257
+ });
258
+ return value;
259
+ }
260
+ const bridge = {
261
+ async permissions(context, key) {
262
+ return (await Promise.all([
263
+ "inspect",
264
+ "preview",
265
+ "replace",
266
+ "use"
267
+ ].map(async (permission) => await allowed(context, key, permission) ? permission : void 0))).filter((permission) => permission !== void 0);
268
+ },
269
+ async read({ keys, signal, access }) {
270
+ const context = access ?? grantEnvAccess({
271
+ ...await options.runtimeAttribution?.(),
272
+ actor: options.runtimeActor
273
+ }, {
274
+ kind: "actor",
275
+ bridge
276
+ });
277
+ const values = [];
278
+ for (const key of keys) {
279
+ signal?.throwIfAborted();
280
+ let revision;
281
+ const secret = await audited(context, key, "resolve", "use", async () => {
282
+ const secret = await options.secrets.read(key);
283
+ revision = secret?.revision;
284
+ return secret;
285
+ }, void 0, { revision: () => revision });
286
+ signal?.throwIfAborted();
287
+ values.push([key, secret?.value]);
288
+ }
289
+ return Object.fromEntries(values);
290
+ },
291
+ inspect: (context, key) => audited(context, key, "inspect", "inspect", async () => {
292
+ const value = await options.secrets.inspect(key);
293
+ return value ? {
294
+ revision: value.revision,
295
+ updatedAt: value.updatedAt
296
+ } : void 0;
297
+ }),
298
+ preview: (context, key) => audited(context, key, "preview", "preview", async () => {
299
+ const value = await options.secrets.inspect(key);
300
+ return value?.preview ? { preview: value.preview } : void 0;
301
+ }),
302
+ replace: (context, input) => {
303
+ let revision;
304
+ return audited(context, input.key, "replace", "replace", async () => {
305
+ if (!input.value || new TextEncoder().encode(input.value).length > 32768) throw envBridgeError("invalid");
306
+ const replacement = await options.secrets.replace(input);
307
+ revision = replacement.revision;
308
+ return replacement;
309
+ }, void 0, { revision: () => revision });
310
+ },
311
+ use: (context, key, operation, run) => {
312
+ envIdentifier(operation);
313
+ let revision;
314
+ return audited(context, key, "use", "use", async () => {
315
+ const secret = await options.secrets.read(key);
316
+ if (!secret) throw envBridgeError("missing");
317
+ revision = secret.revision;
318
+ return await run(new SecretEnv(secret.value), { revision });
319
+ }, operation, { revision: () => revision });
320
+ },
321
+ async activity(context, key, before) {
322
+ if (!await allowed(context, key, "activity")) throw envBridgeError("denied");
323
+ return await safe(() => options.access.activity({
324
+ key,
325
+ before,
326
+ limit: 100
327
+ }));
328
+ },
329
+ async grants(context, key) {
330
+ if (!await allowed(context, key, "admin")) throw envBridgeError("denied");
331
+ return await safe(() => options.access.grants(key));
332
+ },
333
+ async grant(context, grant) {
334
+ validateEnvActor(grant.actor);
335
+ if (!Array.isArray(grant.permissions) || !grant.permissions.length || grant.permissions.some((permission) => ![
336
+ "inspect",
337
+ "preview",
338
+ "replace",
339
+ "use"
340
+ ].includes(permission))) throw envBridgeError("invalid");
341
+ return audited(context, grant.key, "grant", "admin", () => options.access.setGrant(grant), void 0, {
342
+ target: grant.actor,
343
+ permissions: grant.permissions
344
+ });
345
+ },
346
+ async revoke(context, actor, key) {
347
+ validateEnvActor(actor);
348
+ return audited(context, key, "revoke", "admin", () => options.access.revokeGrant(actor, key), void 0, { target: actor });
349
+ }
350
+ };
351
+ return bridge;
352
+ }
353
+ //#endregion
354
+ export { createEnvAuthenticator, createEnvBridge, createEnvBridgeHandler };
@@ -0,0 +1,159 @@
1
+ import { Diagnostic } from "nostics";
2
+ //#region ../internal/src/host-credentials.d.ts
3
+ interface HostCliRunResult {
4
+ exitCode: number | null;
5
+ stdout: string;
6
+ }
7
+ /** Runs a host CLI with an argument array and no shell, and returns its stdout. */
8
+ type HostCliRun = (command: string, args: readonly string[], options: {
9
+ cwd?: string;
10
+ env: NodeJS.ProcessEnv;
11
+ signal?: AbortSignal;
12
+ }) => Promise<HostCliRunResult>;
13
+ //#endregion
14
+ //#region ../internal/src/provision.d.ts
15
+ type ProvisionProvider = "cloudflare" | "vercel";
16
+ interface ProvisionLogger {
17
+ log: (message: string) => void;
18
+ warn: (message: string) => void;
19
+ }
20
+ interface ProvisionContext {
21
+ env: Record<string, string | undefined>;
22
+ fetch: typeof globalThis.fetch;
23
+ logger: ProvisionLogger;
24
+ markPlanUnchecked?: () => void;
25
+ }
26
+ interface ProvisionState {
27
+ cloudflare?: Record<string, Record<string, string>>;
28
+ vercel?: Record<string, Record<string, string>>;
29
+ }
30
+ interface ProvisionResult {
31
+ ids?: ProvisionState;
32
+ }
33
+ interface ProvisionAction {
34
+ kind: string;
35
+ name: string;
36
+ exists: boolean;
37
+ pending?: boolean;
38
+ /** Describes the change that `apply()` makes to an existing resource, for example `read replication: disabled -> auto`. */
39
+ update?: string;
40
+ apply: () => Promise<ProvisionResult>;
41
+ }
42
+ /** One Provision State category that a step records, with the keys that current Definitions use. */
43
+ interface ProvisionStateCategory {
44
+ category: string;
45
+ declared: readonly string[];
46
+ /** Provider resource identity for shared-resource checks. Return undefined when the recorded id lacks enough information. Defaults to the recorded id. */
47
+ resourceIdentity?: (entry: {
48
+ id: string;
49
+ key: string;
50
+ }) => string | undefined;
51
+ /** Identity expected by current config for a declared key. Omit when it cannot be established without provider access. */
52
+ declaredResourceIdentity?: (key: string) => string | undefined;
53
+ /** Tells a developer how to delete the resource of a recorded entry that no Definition declares. ViteHub never runs it. */
54
+ deleteHint: (entry: {
55
+ id: string;
56
+ key: string;
57
+ }) => string;
58
+ }
59
+ interface ProvisionStep {
60
+ id: string;
61
+ provider: ProvisionProvider;
62
+ plan: (context: ProvisionContext) => Promise<ProvisionAction[]>;
63
+ /** Describes the Provision State this step records. Runs without network access, also without credentials. */
64
+ recordedState?: (context: Pick<ProvisionContext, "env">) => ProvisionStateCategory[];
65
+ }
66
+ //#endregion
67
+ //#region ../internal/src/cli.d.ts
68
+ interface ViteHubCliStreams {
69
+ stderr: {
70
+ write: (chunk: string | Uint8Array, encoding?: BufferEncoding | StdoutWriteCallback, callback?: StdoutWriteCallback) => unknown;
71
+ };
72
+ stdout: {
73
+ write: (chunk: string | Uint8Array) => unknown;
74
+ };
75
+ }
76
+ interface ViteHubCliSpawnResult {
77
+ exitCode: number | null;
78
+ signal?: NodeJS.Signals | null;
79
+ /** The output of the child when `stdout` is `pipe`. */
80
+ stdout?: string;
81
+ }
82
+ interface ViteHubCliSpawnOptions {
83
+ cwd?: string;
84
+ env?: NodeJS.ProcessEnv;
85
+ stderr?: "inherit" | "pipe";
86
+ /** `ignore` gives the child no terminal input, so a tool that asks questions on a terminal does not ask. */
87
+ stdin?: "ignore" | "inherit";
88
+ /** `stderr` sends the child's stdout to the parent's stderr, so the parent's stdout keeps only its own output. */
89
+ stdout?: "inherit" | "pipe" | "stderr";
90
+ }
91
+ type ViteHubCliSpawn = (command: string, args: string[], options?: ViteHubCliSpawnOptions) => Promise<ViteHubCliSpawnResult>;
92
+ interface ViteHubCliContext extends ViteHubCliStreams {
93
+ cwd: string;
94
+ env: NodeJS.ProcessEnv;
95
+ /** Replaces `fetch` for commands that call a running app, so tests need no server. */
96
+ fetch?: typeof fetch;
97
+ /**
98
+ * Loads the project config for a build on `host` and returns the Provision Steps of its plugins, with the config root
99
+ * that holds `.vitehub/provision.json`. Setup commands, such as `vitehub deploy`, call it only when they need the
100
+ * steps, so they still run on a config that throws.
101
+ */
102
+ loadProvision?: (host: ProvisionProvider) => Promise<ViteHubCliProvision>;
103
+ /** The deployed app's public origin from `vitehub({ publicUrl })`, when it is one string. */
104
+ publicUrl?: string;
105
+ rootDir: string;
106
+ /** Replaces the host CLI runner, such as for `wrangler auth token`, so tests need no real host CLI. */
107
+ runHostCli?: HostCliRun;
108
+ spawn: ViteHubCliSpawn;
109
+ }
110
+ interface ViteHubCliProvision {
111
+ rootDir: string;
112
+ steps: readonly ProvisionStep[];
113
+ }
114
+ interface ViteHubCliFeature {
115
+ description?: string;
116
+ name: string;
117
+ run: (args: string[], context: ViteHubCliContext) => Promise<number | void> | number | void;
118
+ usage?: string;
119
+ }
120
+ interface ViteHubCliCommandNamespace {
121
+ /** The feature that `vitehub <name>` runs when the next argument names no other feature. It gets every argument after `<name>`. */
122
+ defaultFeature?: string;
123
+ description?: string;
124
+ features: ViteHubCliFeature[];
125
+ name: string;
126
+ }
127
+ /** The flags of `vitehub seed` that every seed gets. */
128
+ interface ViteHubCliSeedOptions {
129
+ /** `--database <name>`: seed only this Database. Only the Database seed runs. */
130
+ database?: string;
131
+ /** The process environment with the env files of `--stage`. */
132
+ env: NodeJS.ProcessEnv;
133
+ /** `--remote`: write the deployed stores. Without it, a seed writes only local data. */
134
+ remote: boolean;
135
+ /** `--timeout <ms>` of each call to the app. */
136
+ timeout?: number;
137
+ /** The deployed app with `--remote`: `--url`, or `vitehub({ publicUrl })`. */
138
+ url?: string;
139
+ }
140
+ /** The seed files of one primitive, which `vitehub seed` writes. */
141
+ interface ViteHubCliSeed {
142
+ /** Where the seed files are, such as `server/seed/kv/`. `vitehub seed` names it when it finds no seed files. */
143
+ files: string;
144
+ /** The primitive, such as `database` or `kv`. `vitehub seed <name>` runs only this seed. */
145
+ name: string;
146
+ /** Writes the seed files and returns the exit code, or `undefined` when the project has no seed files for this primitive. */
147
+ run: (options: ViteHubCliSeedOptions, context: ViteHubCliContext) => Promise<number | undefined>;
148
+ }
149
+ interface ViteHubCliContributor {
150
+ namespaces: ViteHubCliCommandNamespace[];
151
+ provision?: ProvisionStep[];
152
+ /** The seed files that `vitehub seed` writes. */
153
+ seeds?: ViteHubCliSeed[];
154
+ /** The deployed app's public origin. Commands receive it as `context.publicUrl`. */
155
+ publicUrl?: string;
156
+ }
157
+ type StdoutWriteCallback = (error?: Error | null) => void;
158
+ //#endregion
159
+ export { ViteHubCliContributor as n, ViteHubCliContext as t };