@lunora/config 1.0.0-alpha.282 → 1.0.0-alpha.284
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/dist/cloudflare/index.d.mts +94 -93
- package/dist/cloudflare/index.d.ts +94 -93
- package/dist/cloudflare/index.mjs +1 -1
- package/dist/index.d.mts +36 -3
- package/dist/index.d.ts +36 -3
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{BINDING_MANIFEST_VERSION-B8dwEKLn.mjs → BINDING_MANIFEST_VERSION-B4Tu8Ytd.mjs} +1 -1
- package/dist/packem_shared/CLOUDFLARE_DRIVER-DUE6r-Pg.mjs +1 -0
- package/dist/packem_shared/COMPOSED_WORKER_ENTRY-5R-BECOC.mjs +1 -0
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-CtEZtsUF.mjs +2 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-g_1F-n2X.mjs +1 -0
- package/dist/packem_shared/STUDIO_PATH-BZI8go9A.mjs +1 -0
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-Bc302QS4.mjs +1 -0
- package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
- package/dist/packem_shared/{assertWranglerSatisfiesSchema-DHITzU7H.mjs → assertWranglerSatisfiesSchema-B24XPKq7.mjs} +1 -1
- package/dist/packem_shared/collectExportGaps-BmEGzQQc.mjs +2 -0
- package/dist/packem_shared/inferLunoraBindings-GaAITuz-.mjs +1 -0
- package/dist/packem_shared/{interpretRemote-CQ06qpjM.mjs → interpretRemote-Da32GcUi.mjs} +1 -1
- package/dist/packem_shared/mergeWranglerEnvironment-BIcLqPfv.mjs +1 -0
- package/dist/packem_shared/reconcileBindingsSafely-DOqY2zb2.mjs +1 -0
- package/dist/packem_shared/{runPostCodegenHook-CVrOTiGB.mjs → runPostCodegenHook-B0T1q2YI.mjs} +1 -1
- package/dist/packem_shared/{schema-info.d-DvKkJ7HJ.d.mts → schema-info.d-C3DeuUmC.d.mts} +111 -51
- package/dist/packem_shared/{schema-info.d-DvKkJ7HJ.d.ts → schema-info.d-C3DeuUmC.d.ts} +111 -51
- package/dist/packem_shared/validate-bindings-D6-vb6if.mjs +1 -0
- package/dist/packem_shared/withTailConsumer-DaP3r6ia.mjs +1 -0
- package/dist/packem_shared/{wranglerToAlchemy-SDoS_XY0.mjs → wranglerToAlchemy-DZOim9As.mjs} +1 -1
- package/dist/studio-host/index.d.mts +106 -57
- package/dist/studio-host/index.d.ts +106 -57
- package/dist/studio-host/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/CLOUDFLARE_DRIVER-Ci9oJMYb.mjs +0 -1
- package/dist/packem_shared/COMPOSED_WORKER_ENTRY-Bj793dir.mjs +0 -1
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-B-e9mqgX.mjs +0 -1
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-SdRHaUwh.mjs +0 -1
- package/dist/packem_shared/addArgsFor-CWb4cPij.mjs +0 -1
- package/dist/packem_shared/collectExportGaps-BJw9LdRV.mjs +0 -2
- package/dist/packem_shared/reconcileBindingsSafely-Ds107djO.mjs +0 -1
|
@@ -14,10 +14,10 @@ import { AgentIR, ContainerIR, QueueIR, WorkflowIR } from '@lunora/codegen';
|
|
|
14
14
|
* `temporary` are concepts, not wrangler flags. A second host maps the same
|
|
15
15
|
* request onto its own CLI without the caller changing.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* which has none — it is a codegen target, and
|
|
20
|
-
* refuse it at selection.
|
|
17
|
+
* Three drivers are registered: Cloudflare (`cloudflare/cloudflare-driver.ts`)
|
|
18
|
+
* and celld (`celld/celld-driver.ts`), which ship toolchains, and Node
|
|
19
|
+
* (`node/node-driver.ts`), which has none — it is a codegen target, and
|
|
20
|
+
* `lunora deploy` / `lunora dev` refuse it at selection.
|
|
21
21
|
*
|
|
22
22
|
* **What this seam deliberately does NOT carry: configuration inference.** It
|
|
23
23
|
* used to, through an `infer`/`provision` pair over a provider-neutral
|
|
@@ -36,17 +36,28 @@ import { AgentIR, ContainerIR, QueueIR, WorkflowIR } from '@lunora/codegen';
|
|
|
36
36
|
* A host CLI invocation, described but not run.
|
|
37
37
|
*
|
|
38
38
|
* `tool` is the binary name only (`"wrangler"`); the caller resolves how to
|
|
39
|
-
* execute it through the project's package manager
|
|
40
|
-
* driver never has to know whether the project uses
|
|
39
|
+
* execute it through the project's package manager (see `toolchainExecArgs`).
|
|
40
|
+
* Keeping that split means a driver never has to know whether the project uses
|
|
41
|
+
* pnpm, npm, yarn, or bun.
|
|
41
42
|
*/
|
|
42
43
|
interface ToolchainCommand {
|
|
43
44
|
/** Arguments for {@link ToolchainCommand.tool}. */
|
|
44
45
|
args: ReadonlyArray<string>;
|
|
46
|
+
/**
|
|
47
|
+
* The tool is a standalone binary installed on `PATH`, not a project
|
|
48
|
+
* dependency: run it directly. Going through the package manager would be
|
|
49
|
+
* wrong for it — `npx --` / `bun x` fetch an npm package of the same name
|
|
50
|
+
* when none is installed locally, which for a non-npm binary is somebody
|
|
51
|
+
* else's code.
|
|
52
|
+
*/
|
|
53
|
+
onPath?: boolean;
|
|
45
54
|
/** The host CLI binary, e.g. `"wrangler"`. */
|
|
46
55
|
tool: string;
|
|
47
56
|
}
|
|
48
57
|
/** Neutral options for a deploy. */
|
|
49
58
|
interface DeployRequest {
|
|
59
|
+
/** Host config file to deploy, when the flow uses a projected one (see {@link DeployDriver.projectConfig}). */
|
|
60
|
+
configPath?: string;
|
|
50
61
|
/** Validate and bundle without publishing — nothing ships. */
|
|
51
62
|
dryRun?: boolean;
|
|
52
63
|
/** Deploy this entry file instead of the host config's default (framework composition). */
|
|
@@ -97,18 +108,53 @@ interface SecretRequest {
|
|
|
97
108
|
* The host's command-line surface. Optional as a whole: a host with no vendor
|
|
98
109
|
* CLI (the Node target; a hypothetical API-driven one) declares none, and
|
|
99
110
|
* `isRunnableTarget` refuses it for the commands that would have to shell out.
|
|
111
|
+
*
|
|
112
|
+
* `deploy` and `dev` are what make a target runnable. The secret and tail
|
|
113
|
+
* commands are optional on their own, because a runnable host can simply not
|
|
114
|
+
* have them — celld keeps configuration in plain `vars` and has no log tail —
|
|
115
|
+
* and the commands that need one say so rather than guessing a substitute.
|
|
100
116
|
*/
|
|
101
117
|
interface DriverToolchain {
|
|
102
118
|
/** The command that deploys the app. */
|
|
103
119
|
deploy: (request: DeployRequest) => ToolchainCommand;
|
|
104
120
|
/** The command that runs a local dev server. */
|
|
105
121
|
dev: (request: DevRequest) => ToolchainCommand;
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Where `lunora dev` runs the worker. `"workerd"`: `wrangler dev`, or the
|
|
124
|
+
* Vite plugin's `@cloudflare/vite-plugin`, whichever flavor the project
|
|
125
|
+
* picks. `"own"`: the host's dev server ({@link DriverToolchain.dev}) on
|
|
126
|
+
* the projected config, always the standalone flavor — neither Vite nor a
|
|
127
|
+
* framework sidecar can serve the worker on that runtime.
|
|
128
|
+
*/
|
|
129
|
+
readonly devServer: "own" | "workerd";
|
|
130
|
+
/**
|
|
131
|
+
* Whether `lunora deploy` builds and pushes container images itself
|
|
132
|
+
* (railpack, into the host's registry) before `deploy`. `false` when the
|
|
133
|
+
* host CLI builds each image from its Dockerfile during the deploy.
|
|
134
|
+
*/
|
|
135
|
+
readonly prebuildsContainerImages: boolean;
|
|
136
|
+
/** The command that lists remote secret names, when the host has a secret store. */
|
|
137
|
+
secretList?: (request: SecretRequest) => ToolchainCommand;
|
|
138
|
+
/** The command that writes one secret, when the host has a secret store. Its value is passed on stdin, never argv. */
|
|
139
|
+
secretPut?: (request: SecretRequest) => ToolchainCommand;
|
|
140
|
+
/** The command that tails live logs, when the host has one. */
|
|
141
|
+
tail?: (request: TailRequest) => ToolchainCommand;
|
|
142
|
+
}
|
|
143
|
+
/** What a {@link DeployDriver.projectConfig} projection is for — a dev server may need a different source than a deploy. */
|
|
144
|
+
type ProjectionPurpose = "deploy" | "dev";
|
|
145
|
+
/**
|
|
146
|
+
* The result of {@link DeployDriver.projectConfig}: a plan, not yet on disk.
|
|
147
|
+
* The caller validates the request it is for (the toolchain's argv builder
|
|
148
|
+
* refuses unsupported options), then calls `write` — so a refused command
|
|
149
|
+
* changes nothing.
|
|
150
|
+
*/
|
|
151
|
+
interface ProjectedConfig {
|
|
152
|
+
/** Where the projection goes, to pass as the request's `configPath`. */
|
|
153
|
+
configPath: string;
|
|
154
|
+
/** Every key removed, as a dotted path (`observability`, `containers[0].rollout_step_percentage`). */
|
|
155
|
+
dropped: ReadonlyArray<string>;
|
|
156
|
+
/** Write the projection (and any build-artifact cleanup it planned). */
|
|
157
|
+
write: () => void;
|
|
112
158
|
}
|
|
113
159
|
/** A deploy target's implementation: an identity the registry resolves, and the host CLI surface (if any) behind it. */
|
|
114
160
|
interface DeployDriver {
|
|
@@ -116,6 +162,18 @@ interface DeployDriver {
|
|
|
116
162
|
readonly id: string;
|
|
117
163
|
/** Human-readable target name, for logs. */
|
|
118
164
|
readonly name: string;
|
|
165
|
+
/**
|
|
166
|
+
* Rewrite the project's wrangler config into the form this host's CLI
|
|
167
|
+
* accepts, and return the file to hand `deploy`/`dev` as `configPath`.
|
|
168
|
+
* Absent when the host reads the project's config as-is (Cloudflare).
|
|
169
|
+
*
|
|
170
|
+
* Needed because Lunora's reconcilers and templates write Cloudflare-only
|
|
171
|
+
* keys (`observability`, `limits`, …) that a Workers-compatible host with a
|
|
172
|
+
* strict config reader refuses outright. `dropped` names what was removed,
|
|
173
|
+
* so the caller can say so instead of silently deploying less than the
|
|
174
|
+
* config describes.
|
|
175
|
+
*/
|
|
176
|
+
readonly projectConfig?: (projectRoot: string, purpose: ProjectionPurpose) => ProjectedConfig;
|
|
119
177
|
/**
|
|
120
178
|
* The host's command-line surface, or `undefined` for a host that has none.
|
|
121
179
|
* Pure: these build argv, they never spawn.
|
|
@@ -126,6 +184,44 @@ interface DurableObjectSpec {
|
|
|
126
184
|
binding: string;
|
|
127
185
|
className: string;
|
|
128
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* The `_generated/` modules that hold a generated Durable Object / Workflow
|
|
189
|
+
* class — one per class kind a project can declare. wrangler validates every
|
|
190
|
+
* `class_name` against the worker's exports, so this is the set a worker entry
|
|
191
|
+
* re-exports (and the set the composed class-A entry star-re-exports for the
|
|
192
|
+
* kinds the project has).
|
|
193
|
+
*
|
|
194
|
+
* Owned here because four places need it and they must not drift:
|
|
195
|
+
* `@lunora/vite` emits one star re-export per entry, the wrangler validator
|
|
196
|
+
* DECIDES the composed entry's exports from it, `reconcile-bindings` types its
|
|
197
|
+
* export-gap `module` field on it, and this module's own `detectClassExports`
|
|
198
|
+
* probes the same names.
|
|
199
|
+
*
|
|
200
|
+
* `scheduler` carries no `define*` declarations of its own — codegen writes it
|
|
201
|
+
* off `hasScheduler` purely so the composed class-A entry has a `SchedulerDO`
|
|
202
|
+
* to forward. Its presence is therefore the ONLY signal the plugin and the
|
|
203
|
+
* validator need, and it is the same signal that decides whether the builder
|
|
204
|
+
* has a `.scheduler()` method at all. `@lunora/vite` depends on `@lunora/config`, so config
|
|
205
|
+
* owning it is the direction the dependency graph allows.
|
|
206
|
+
*/
|
|
207
|
+
declare const GENERATED_CLASS_MODULES: readonly ["agents", "containers", "scheduler", "workflows"];
|
|
208
|
+
/** One {@link GENERATED_CLASS_MODULES} entry. */
|
|
209
|
+
type GeneratedClassModule = (typeof GENERATED_CLASS_MODULES)[number];
|
|
210
|
+
/**
|
|
211
|
+
* The class-B composed entry. `lunora deploy` passes this file to wrangler as
|
|
212
|
+
* the positional script whenever it exists, overriding `wrangler.main` — so it
|
|
213
|
+
* is what actually gets bundled and what wrangler checks its DO/Workflow
|
|
214
|
+
* bindings against. `main` in a class-B project names the framework adapter's
|
|
215
|
+
* build output (`.svelte-kit/cloudflare/_worker.js`, `dist/_worker.js`), which
|
|
216
|
+
* exists after `vite build` and exports only the SSR fetch handler. Lexing that
|
|
217
|
+
* instead read every declared class as unexported: nothing provisioned, plus a
|
|
218
|
+
* "add `export * from …`" warning the user cannot silence.
|
|
219
|
+
*
|
|
220
|
+
* Exported, not documented-as-duplicated: the CLI's `resolveComposedWorkerEntry`
|
|
221
|
+
* imports this constant, so the deploy's positional entry and the file this
|
|
222
|
+
* module lexes for exported classes cannot drift apart.
|
|
223
|
+
*/
|
|
224
|
+
declare const COMPOSED_WORKER_ENTRY = "src/worker.ts";
|
|
129
225
|
/**
|
|
130
226
|
* A `defineContainer` declaration plus whether its generated DO class is
|
|
131
227
|
* exported by the worker entry. Only exported containers are safe to
|
|
@@ -213,6 +309,8 @@ interface InferredBindings {
|
|
|
213
309
|
usesScheduler: boolean;
|
|
214
310
|
/** `@lunora/storage` is imported (R2 bucket binding name is user-defined). */
|
|
215
311
|
usesStorage: boolean;
|
|
312
|
+
/** `jsCodeTool` is imported from `@lunora/agent` in `lunora/` → self-describing `worker_loaders` binding (`LOADER`). */
|
|
313
|
+
usesWorkerLoader: boolean;
|
|
216
314
|
/** `@lunora/x402/charge` is imported — the charge rail settles USDC to a recipient address (a public `[vars]` entry, user-named; hint-only). */
|
|
217
315
|
usesX402Charge: boolean;
|
|
218
316
|
/** `@lunora/x402/pay` is imported — the agent-wallet pay rail signs from a Secrets Store binding paired with a spend policy (ActionCtx-only; hint-only). */
|
|
@@ -227,44 +325,6 @@ interface InferOptions {
|
|
|
227
325
|
/** Lunora source directory holding `schema.ts`. Defaults to `lunora`. */
|
|
228
326
|
schemaDir?: string;
|
|
229
327
|
}
|
|
230
|
-
/**
|
|
231
|
-
* The `_generated/` modules that hold a generated Durable Object / Workflow
|
|
232
|
-
* class — one per class kind a project can declare. wrangler validates every
|
|
233
|
-
* `class_name` against the worker's exports, so this is the set a worker entry
|
|
234
|
-
* re-exports (and the set the composed class-A entry star-re-exports for the
|
|
235
|
-
* kinds the project has).
|
|
236
|
-
*
|
|
237
|
-
* Owned here because four places need it and they must not drift:
|
|
238
|
-
* `@lunora/vite` emits one star re-export per entry, the wrangler validator
|
|
239
|
-
* DECIDES the composed entry's exports from it, `reconcile-bindings` types its
|
|
240
|
-
* export-gap `module` field on it, and this module's own `detectClassExports`
|
|
241
|
-
* probes the same names.
|
|
242
|
-
*
|
|
243
|
-
* `scheduler` carries no `define*` declarations of its own — codegen writes it
|
|
244
|
-
* off `hasScheduler` purely so the composed class-A entry has a `SchedulerDO`
|
|
245
|
-
* to forward. Its presence is therefore the ONLY signal the plugin and the
|
|
246
|
-
* validator need, and it is the same signal that decides whether the builder
|
|
247
|
-
* has a `.scheduler()` method at all. `@lunora/vite` depends on `@lunora/config`, so config
|
|
248
|
-
* owning it is the direction the dependency graph allows.
|
|
249
|
-
*/
|
|
250
|
-
declare const GENERATED_CLASS_MODULES: readonly ["agents", "containers", "scheduler", "workflows"];
|
|
251
|
-
/** One {@link GENERATED_CLASS_MODULES} entry. */
|
|
252
|
-
type GeneratedClassModule = (typeof GENERATED_CLASS_MODULES)[number];
|
|
253
|
-
/**
|
|
254
|
-
* The class-B composed entry. `lunora deploy` passes this file to wrangler as
|
|
255
|
-
* the positional script whenever it exists, overriding `wrangler.main` — so it
|
|
256
|
-
* is what actually gets bundled and what wrangler checks its DO/Workflow
|
|
257
|
-
* bindings against. `main` in a class-B project names the framework adapter's
|
|
258
|
-
* build output (`.svelte-kit/cloudflare/_worker.js`, `dist/_worker.js`), which
|
|
259
|
-
* exists after `vite build` and exports only the SSR fetch handler. Lexing that
|
|
260
|
-
* instead read every declared class as unexported: nothing provisioned, plus a
|
|
261
|
-
* "add `export * from …`" warning the user cannot silence.
|
|
262
|
-
*
|
|
263
|
-
* Exported, not documented-as-duplicated: the CLI's `resolveComposedWorkerEntry`
|
|
264
|
-
* imports this constant, so the deploy's positional entry and the file this
|
|
265
|
-
* module lexes for exported classes cannot drift apart.
|
|
266
|
-
*/
|
|
267
|
-
declare const COMPOSED_WORKER_ENTRY = "src/worker.ts";
|
|
268
328
|
/**
|
|
269
329
|
* Scan a Lunora project and report which Cloudflare bindings its code implies.
|
|
270
330
|
* Read-only: performs no writes. Binding provisioning is driven by the worker
|
|
@@ -328,4 +388,4 @@ interface DiscoverSchemaInfoResult {
|
|
|
328
388
|
* parse failure is a warning (validator) or simply ignorable (inference).
|
|
329
389
|
*/
|
|
330
390
|
declare const discoverSchemaInfo: (projectRoot: string, schemaDirectory: string) => DiscoverSchemaInfoResult;
|
|
331
|
-
export { COMPOSED_WORKER_ENTRY as C, DeployDriver as D, GeneratedClassModule as G, InferredBindings as I, SchemaInfo as S,
|
|
391
|
+
export { COMPOSED_WORKER_ENTRY as C, DeployDriver as D, GeneratedClassModule as G, InferredBindings as I, ProjectionPurpose as P, SchemaInfo as S, ToolchainCommand as T, DeployRequest as a, DevRequest as b, DiscoverSchemaInfoResult as c, DriverToolchain as d, GENERATED_CLASS_MODULES as e, InferOptions as f, InferredAgent as g, InferredContainer as h, InferredWorkflow as i, ProjectedConfig as j, SecretRequest as k, TailRequest as l, discoverSchemaInfo as m, inferLunoraBindings as n, packageNamesFromBindings as p };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const k=(e,s,a)=>{if(s.length===0)return;const n=e.vectorize??[],t=new Set(n.filter(Boolean).map(i=>i?.index_name));for(const i of s)t.has(i)||a.push(`schema declares vector index "${i}"; wrangler "vectorize" must include a binding with index_name "${i}"`)},p=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),h={disk_mb:2e4,memory_mib:12288,vcpu:4},y=(e,s,a)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){p.has(n)||a.push(`${s} has unknown instance_type "${n}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[o,g]of Object.entries(h)){const c=n[o];c!==void 0&&(typeof c!="number"||c<=0||c>g)&&a.push(`${s} custom instance_type ${o} must be a positive number ≤ ${String(g)} (got ${String(c)})`)}const{disk_mb:t,memory_mib:i,vcpu:r}=n;if(typeof r=="number"&&typeof i=="number"&&i<r*3072&&a.push(`${s} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(i)} MiB for ${String(r)} vCPU)`),typeof i=="number"&&typeof t=="number"){const o=Math.floor(i/1024*2e3);t>o&&a.push(`${s} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(o)} MB for ${String(i)} MiB memory; got ${String(t)} MB)`)}},_=(e,s,a)=>{const{boundClasses:n,classKinds:t,errors:i,warnings:r}=a;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){i.push(`${s} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&i.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),n.has(e.class_name)||i.push(`${s} class "${e.class_name}" has no matching durable_objects binding — your dev server auto-reconciles this on startup; add { "name": "...", "class_name": "${e.class_name}" } to fix it by hand`);const o=t.get(e.class_name);o!=="sqlite"&&i.push(o==="classic"?`${s} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${s} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),y(e,`${s} ("${e.class_name}")`,i),e.max_instances===void 0&&r.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},d=e=>typeof e=="string"&&e.length>0,m=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],b=e=>Array.isArray(e)?e.filter(s=>d(s)):[],f=e=>{const s=new Map;for(const a of m(e)){for(const n of b(a.new_classes))s.set(n,"classic");for(const n of b(a.new_sqlite_classes))s.set(n,"sqlite");for(const n of m(a.renamed_classes))if(d(n.from)&&d(n.to)){const t=s.get(n.from)??"sqlite";s.delete(n.from),s.set(n.to,t)}for(const n of b(a.deleted_classes))s.delete(n)}return s},v=e=>new Set(f(e).keys()),E=(e,s)=>{const a=v(e.migrations);for(const n of m(e.durable_objects?.bindings))n.script_name===void 0&&d(n.class_name)&&!a.has(n.class_name)&&s.push(`durable_objects.bindings declares class "${n.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${n.class_name}"] (or "new_classes" for a non-SQLite-backed class), or let the dev server auto-reconcile it on the next start`)},S=(e,s,a)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){s.push("containers must be an array of { class_name, image, ... } entries");return}const n=e.containers;if(n.length===0)return;const t=new Set(m(e.durable_objects?.bindings).map(r=>r.class_name)),i=f(e.migrations);for(const[r,o]of n.entries())_(o,`containers[${String(r)}]`,{boundClasses:t,classKinds:i,errors:s,warnings:a});e.observability?.enabled!==!0&&a.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},u=e=>e,l=(e,s,a,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(a.arrayMessage);return}for(const[t,i]of u(e).entries()){const r=`${s}[${String(t)}]`;if(!i||typeof i!="object"){n.push(a.objectMessage(r));continue}for(const o of a.fields)d(i[o.field])||n.push(o.message(r))}}},j={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},$={arrayMessage:"queues.producers must be an array of { binding, queue } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`},{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the deployed queue`}],objectMessage:e=>`${e} must be a { binding, queue } object`},M={arrayMessage:"queues.consumers must be an array of { queue } entries",fields:[{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the consumed queue`}],objectMessage:e=>`${e} must be a { queue } object`},q=(e,s)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){s.push("queues must be a { producers, consumers } object");return}l(e.queues.producers,"queues.producers",$,s),l(e.queues.consumers,"queues.consumers",M,s)}},w={arrayMessage:"secrets_store_secrets must be an array of { binding, store_id, secret_name } entries",fields:["binding","store_id","secret_name"].map(e=>({field:e,message:s=>`${s} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},R=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,s)=>`${e} ("${s}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,s)=>`${e} ("${s}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,s)=>`${e} ("${s}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],B=(e,s,a,n)=>{const t=e[s.key];if(t!==void 0){if(!Array.isArray(t)){a.push(s.arrayMessage);return}for(const[i,r]of u(t).entries()){const o=`${s.key}[${String(i)}]`;if(!r||typeof r!="object"||!d(r.binding)){a.push(s.bindingMessage(o));continue}(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(c=>d(r[c]))||n.push(s.hintMessage(o,r.binding))}}},D=[{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'}],A=(e,s,a)=>{const n=e[s.key];n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)||!d(n.binding))&&a.push(s.message)},I=[{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`}],x=(e,s,a)=>{s?.hasD1GlobalTable&&!m(e.d1_databases).some(n=>n.binding==="DB")&&a.push('schema declares .global() tables; d1_databases must include a binding named "DB" — your dev server auto-reconciles this on startup, or add the binding manually'),s?.hasHyperdriveGlobalTable&&m(e.hyperdrive).length===0&&a.push('schema declares .global({ backend: "hyperdrive" }) tables; wrangler must declare a hyperdrive binding for `.hyperdriveGlobal({ exec })` to read — run `wrangler hyperdrive create <name> --connection-string=...` and add `"hyperdrive": [{ "binding": "HYPERDRIVE", "id": "<id>" }]` (any binding name works; your `exec` selector picks it)')},U=(e,s)=>{const{d1_databases:a}=e;if(a!==void 0){if(!Array.isArray(a)){s.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[n,t]of u(a).entries()){const i=`d1_databases[${String(n)}]`;if(!t||typeof t!="object"){s.push(`${i} must be a { binding, database_id | database_name } object`);continue}d(t.binding)||s.push(`${i} must have a non-empty "binding" naming the D1 binding`),!d(t.database_id)&&!d(t.database_name)&&s.push(`${i} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}};export{R as H,I as R,D as S,j as W,x as a,U as b,k as c,S as d,l as e,q as f,B as g,A as h,w as i,d as j,m as o,b as s,E as v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as d,o as p}from"./validate-bindings-D6-vb6if.mjs";const b=new Set(["1","enabled","on","true","yes"]),m=s=>typeof s=="string"&&b.has(s.trim().toLowerCase()),g=(s,t,e)=>{const i=s.send_email;if(i===void 0)return;if(!Array.isArray(i)){t.push("send_email must be an array of { name, destination_address? } entries");return}const n=i;for(const[o,a]of n.entries())(!a||typeof a!="object"||typeof a.name!="string"||a.name.length===0)&&e.push(`send_email[${String(o)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},y=(s,t)=>{s.logpush!==void 0&&typeof s.logpush!="boolean"&&t.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},c=3e5,v=(s,t)=>{const{limits:e}=s;if(e===void 0)return;if(typeof e!="object"||Array.isArray(e)){t.push('limits must be an object (e.g. { "cpu_ms": 30000 })');return}const i=e.cpu_ms;if(i!==void 0){if(typeof i!="number"||!Number.isFinite(i)||!Number.isInteger(i)||i<=0){t.push("limits.cpu_ms must be a positive integer number of milliseconds");return}i>c&&t.push(`limits.cpu_ms must be at most ${String(c)} (Cloudflare's per-invocation ceiling)`)}},l=new Set(["off","smart","targeted"]),_=(s,t)=>{const{placement:e}=s;if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e)){t.push('placement must be an object (e.g. { "mode": "smart" })');return}const{mode:i}=e;i!==void 0&&(typeof i!="string"||!l.has(i))&&t.push(`placement.mode must be one of ${[...l].map(n=>`"${n}"`).join(", ")}`)},A=(s,t)=>{const{observability:e}=s;if(e===void 0)return;if(typeof e!="object"||Array.isArray(e)){t.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const i=(n,o)=>{n!==void 0&&(typeof n!="number"||Number.isNaN(n)||n<0||n>1)&&t.push(`${o} must be a number in [0, 1] (the fraction of requests sampled)`)};i(e.head_sampling_rate,"observability.head_sampling_rate"),e.logs!==void 0&&(typeof e.logs!="object"||Array.isArray(e.logs)?t.push("observability.logs must be an object"):(i(e.logs.head_sampling_rate,"observability.logs.head_sampling_rate"),e.logs.invocation_logs!==void 0&&typeof e.logs.invocation_logs!="boolean"&&t.push('observability.logs.invocation_logs must be a boolean (set "invocation_logs": true to keep per-invocation summaries)')))},j=(s,t)=>{const{cache:e}=s;if(e!==void 0){if(typeof e!="object"||e===null||Array.isArray(e)){t.push('cache must be an object (e.g. { "enabled": true })');return}e.enabled!==void 0&&typeof e.enabled!="boolean"&&t.push("cache.enabled must be a boolean (true or false)")}},S=(s,t)=>{const{exports:e}=s;if(e!==void 0){if(typeof e!="object"||e===null||Array.isArray(e)){t.push("exports must be an object keyed by entrypoint name");return}for(const[i,n]of Object.entries(e)){if(typeof n!="object"||n===null){t.push(`exports["${i}"] must be an object`);continue}n.type!==void 0&&typeof n.type!="string"&&t.push(`exports["${i}"].type must be a string`),n.cache!==void 0&&(typeof n.cache!="object"||n.cache===null||Array.isArray(n.cache)?t.push(`exports["${i}"].cache must be an object`):n.cache.enabled!==void 0&&typeof n.cache.enabled!="boolean"&&t.push(`exports["${i}"].cache.enabled must be a boolean`))}}},O=(s,t)=>{const{assets:e}=s;if(e!==void 0){if(typeof e!="object"||Array.isArray(e)){t.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof e.directory!="string"||e.directory.length===0)&&t.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),e.binding!==void 0&&(typeof e.binding!="string"||e.binding.length===0)&&t.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),e.html_handling!==void 0&&typeof e.html_handling!="string"&&t.push("assets.html_handling must be a string"),e.not_found_handling!==void 0&&typeof e.not_found_handling!="string"&&t.push("assets.not_found_handling must be a string")}},E=(s,t)=>{const e=s.tail_consumers;if(e===void 0)return;if(!Array.isArray(e)){t.push("tail_consumers must be an array of { service, environment? } entries");return}const i=e;for(const[n,o]of i.entries())(!o||typeof o!="object"||typeof o.service!="string"||o.service.length===0)&&t.push(`tail_consumers[${String(n)}] must have a non-empty "service" naming the consumer Worker`)},L=(s,t)=>{const e=s.tail_consumers??[];return e.some(n=>!!n&&n?.service===t.service&&n?.environment===t.environment)?s:{...s,tail_consumers:[...e,t]}},N=(s,t)=>{const{vars:e}=s;if(!e||typeof e!="object")return;const i=e.LUNORA_ALLOWED_ORIGINS,n=e.LUNORA_CORS_ALLOW_CREDENTIALS,o=typeof i=="string"&&i.split(",").some(u=>u.trim()==="*"),a=m(n);o&&a&&t.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},f=s=>p(s.durable_objects?.bindings).some(t=>t.class_name==="SchedulerDO"&&t.script_name===void 0),r="LUNORA_ORIGIN_URL",R=(s,t,e)=>{if(!f(s)||d(s.vars?.[r]))return;const i=t===void 0?"vars":`env.${t}.vars`,n=t===void 0?"":` --env ${t}`;e.push(`durable_objects.bindings declares the SchedulerDO but ${i}.${r} is unset — the DO reads its dispatch origin from its own env and refuses to schedule without it, so every ctx.scheduler.runAfter/runAt fails with ORIGIN_NOT_CONFIGURED. Set ${i}.${r} to the worker's public URL, or \`wrangler secret put ${r}${n}\` (ignore this if it is already set as a secret or in the dashboard).`)};export{O as validateAssets,j as validateCache,N as validateCorsVariables,S as validateExports,v as validateLimits,y as validateLogpush,A as validateObservability,_ as validatePlacement,R as validateSchedulerOrigin,g as validateSendEmail,E as validateTailConsumers,L as withTailConsumer};
|
package/dist/packem_shared/{wranglerToAlchemy-SDoS_XY0.mjs → wranglerToAlchemy-DZOim9As.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const o=e=>JSON.stringify(e),$=/^[A-Z_a-z][\w$]*$/u,d=e=>$.test(e),u=e=>d(e)?e:`binding_${e.replaceAll(/\W/gu,"_")}`,m=(e,s=u(e))=>{const n=d(e);return n&&s===e?`${e},`:`${n?e:o(e)}: ${s},`},g=e=>{const s=new Set;for(const n of e.migrations??[])for(const r of n.new_sqlite_classes??[])s.add(r);return s},v=(e,s,n,r,c)=>{for(const a of e.durable_objects?.bindings??[])if(!(a.name===void 0||a.class_name===void 0)){if(a.script_name!==void 0){c.push(`durable_objects.${a.name} (external script_name "${a.script_name}")`);continue}n.add("DurableObjectNamespace"),r.push(m(a.name,`DurableObjectNamespace(${o(a.name)}, { className: ${o(a.class_name)}, sqlite: ${String(s.has(a.class_name))} })`))}},h=(e,s)=>{for(const[n,r]of Object.entries(e.vars??{}))s.push(m(n,o(r)))},
|
|
1
|
+
const o=e=>JSON.stringify(e),$=/^[A-Z_a-z][\w$]*$/u,d=e=>$.test(e),u=e=>d(e)?e:`binding_${e.replaceAll(/\W/gu,"_")}`,m=(e,s=u(e))=>{const n=d(e);return n&&s===e?`${e},`:`${n?e:o(e)}: ${s},`},g=e=>{const s=new Set;for(const n of e.migrations??[])for(const r of n.new_sqlite_classes??[])s.add(r);return s},v=(e,s,n,r,c)=>{for(const a of e.durable_objects?.bindings??[])if(!(a.name===void 0||a.class_name===void 0)){if(a.script_name!==void 0){c.push(`durable_objects.${a.name} (external script_name "${a.script_name}")`);continue}n.add("DurableObjectNamespace"),r.push(m(a.name,`DurableObjectNamespace(${o(a.name)}, { className: ${o(a.class_name)}, sqlite: ${String(s.has(a.class_name))} })`))}},h=(e,s)=>{for(const[n,r]of Object.entries(e.vars??{}))s.push(m(n,o(r)))},w=["ai","analytics_engine_datasets","assets","browser","containers","flagship","hyperdrive","images","pipelines","secrets_store_secrets","send_email","services","tail_consumers","vectorize","worker_loaders","workflows"],f=(e,s)=>{for(const n of w){const r=e[n];r!==void 0&&(!Array.isArray(r)||r.length>0)&&s.push(n)}(e.queues?.consumers?.length??0)>0&&s.push("queues.consumers")},k=e=>{const s=e.name??"worker",n=[],r=new Set(["Worker"]),c=[],a=[],p=g(e),b=[{construct:"D1Database",entries:(e.d1_databases??[]).map(t=>({binding:t.binding,name:t.database_name})),nameKey:"name"},{construct:"R2Bucket",entries:(e.r2_buckets??[]).map(t=>({binding:t.binding,name:t.bucket_name})),nameKey:"name"},{construct:"KVNamespace",entries:(e.kv_namespaces??[]).map(t=>({binding:t.binding,name:t.binding})),nameKey:"title"},{construct:"Queue",entries:(e.queues?.producers??[]).map(t=>({binding:t.binding,name:t.queue})),nameKey:"name"}];for(const{construct:t,entries:l,nameKey:y}of b)for(const i of l)i.binding!==void 0&&(r.add(t),c.push(`const ${u(i.binding)} = await ${t}(${o(i.binding)}, { adopt: true, ${y}: ${o(i.name??i.binding)} });`),a.push(m(i.binding)));v(e,p,r,a,n),h(e,a),f(e,n);const _=["adopt: true,",a.length===0?void 0:`bindings: {
|
|
2
2
|
${a.join(`
|
|
3
3
|
`)}
|
|
4
4
|
},`,e.compatibility_date===void 0?void 0:`compatibilityDate: ${o(e.compatibility_date)},`,e.compatibility_flags===void 0||e.compatibility_flags.length===0?void 0:`compatibilityFlags: ${o([...e.compatibility_flags])},`,e.triggers?.crons===void 0||e.triggers.crons.length===0?void 0:`crons: ${o([...e.triggers.crons])},`,e.main===void 0?void 0:`entrypoint: ${o(e.main)},`,`name: ${o(s)},`].filter(t=>t!==void 0);return{source:["// GENERATED by @lunora/config from wrangler.jsonc — do not edit.","// Re-generated on every `lunora deploy`; edit wrangler.jsonc instead.","",'import alchemy from "alchemy";',`import { ${[...r].toSorted((t,l)=>t.localeCompare(l)).join(", ")} } from "alchemy/cloudflare";`,"",`const app = await alchemy(${o(s)});`,"",...c.length===0?[]:[...c,""],`export const worker = await Worker(${o(s)}, {`,` ${_.join(`
|
|
@@ -150,6 +150,93 @@ declare const isStandaloneModulePath: (pathname: string) => boolean;
|
|
|
150
150
|
* place.
|
|
151
151
|
*/
|
|
152
152
|
declare const assetContentType: (fileName: string) => string;
|
|
153
|
+
/**
|
|
154
|
+
* The host's project configuration, forwarded verbatim to the handler. Separate
|
|
155
|
+
* from `projectRoot` (which every host has) because these two come from the
|
|
156
|
+
* host's own Lunora options.
|
|
157
|
+
*/
|
|
158
|
+
interface LocalEndpointContext {
|
|
159
|
+
/** API-spec mode the host runs codegen with, so a studio edit regenerates the same spec files. */
|
|
160
|
+
readonly apiSpec?: CodegenOptions["apiSpec"];
|
|
161
|
+
/** Override the lunora subdirectory name. Defaults to `"lunora"`. */
|
|
162
|
+
readonly schemaDirectory?: string;
|
|
163
|
+
}
|
|
164
|
+
/** A request adapted from a host transport, passed to a local-dev handler. */
|
|
165
|
+
interface LocalEndpointRequest extends LocalEndpointContext {
|
|
166
|
+
/** Parsed JSON body of the request (`undefined` for `GET` / an empty body). */
|
|
167
|
+
readonly body?: unknown;
|
|
168
|
+
/** HTTP method. */
|
|
169
|
+
readonly method: string;
|
|
170
|
+
/** Project root containing the `lunora/` directory. */
|
|
171
|
+
readonly projectRoot: string;
|
|
172
|
+
}
|
|
173
|
+
/** A response a local-dev handler returns, serialised back as JSON with its status. */
|
|
174
|
+
interface LocalEndpointResponse {
|
|
175
|
+
readonly body: unknown;
|
|
176
|
+
readonly status: number;
|
|
177
|
+
}
|
|
178
|
+
/** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
|
|
179
|
+
type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse;
|
|
180
|
+
/**
|
|
181
|
+
* Adapt a `node:http` request/response pair to a transport-agnostic local-dev
|
|
182
|
+
* handler. `GET` carries no body (the schema editor uses it to read the parsed
|
|
183
|
+
* schema); every other method has its body read + JSON-parsed first. The
|
|
184
|
+
* handler's `{ status, body }` is serialised back as JSON. A malformed body is a
|
|
185
|
+
* `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
|
|
186
|
+
*
|
|
187
|
+
* `context` carries the host's own Lunora options through to the handler: its
|
|
188
|
+
* `schemaDirectory` (so a custom `schemaDir` targets the right directory instead
|
|
189
|
+
* of defaulting to `"lunora"`) and its `apiSpec`, so a studio edit regenerates
|
|
190
|
+
* with the same options the host's own codegen run uses.
|
|
191
|
+
*/
|
|
192
|
+
declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string, context?: LocalEndpointContext) => void;
|
|
193
|
+
/** Dev-server path the studio SPA is served from. */
|
|
194
|
+
declare const STUDIO_PATH = "/__lunora";
|
|
195
|
+
/** Static asset routes the studio document references. */
|
|
196
|
+
declare const STUDIO_SCRIPT_PATH: string;
|
|
197
|
+
declare const STUDIO_STYLE_PATH: string;
|
|
198
|
+
interface StudioMiddlewareOptions extends LocalEndpointContext {
|
|
199
|
+
/**
|
|
200
|
+
* The dev server's base path as configured (`"/"`, `"/app/"`). The studio's
|
|
201
|
+
* mount moves with it. Defaults to `"/"`.
|
|
202
|
+
*/
|
|
203
|
+
base?: string;
|
|
204
|
+
/**
|
|
205
|
+
* The host's config binds beyond loopback — see {@link isNonLoopbackHost},
|
|
206
|
+
* which both bundler hosts derive this from. Refused outright, on top of the
|
|
207
|
+
* per-request transport check.
|
|
208
|
+
*/
|
|
209
|
+
isNonLoopbackBind: boolean;
|
|
210
|
+
logger?: WarnLogger;
|
|
211
|
+
/** Directory holding `lunora/` and `.dev.vars`. */
|
|
212
|
+
projectRoot: string;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* A dev server's CONFIGURED host asks to bind beyond loopback — `--host`
|
|
216
|
+
* (`true`), `0.0.0.0`, a LAN address. `undefined` means the host was never
|
|
217
|
+
* set, which is the bundler's default and not an intent to expose, whatever
|
|
218
|
+
* that default binds.
|
|
219
|
+
*/
|
|
220
|
+
declare const isNonLoopbackHost: (host: unknown) => boolean;
|
|
221
|
+
/** Where the studio is mounted under a dev server's `base` — the path a startup banner announces. */
|
|
222
|
+
declare const studioMountPath: (base?: string) => string;
|
|
223
|
+
/**
|
|
224
|
+
* The pathname of a request's `url`, the way every studio host routes on it:
|
|
225
|
+
* query dropped, and dot segments resolved — so `/_lunora/../x` routes as the
|
|
226
|
+
* `/x` it will reach, not as a `/_lunora` path. A url `URL` cannot parse falls
|
|
227
|
+
* back to a plain query strip.
|
|
228
|
+
*/
|
|
229
|
+
declare const requestPathname: (url: string) => string;
|
|
230
|
+
/**
|
|
231
|
+
* Connect-style middleware that serves the static studio at {@link STUDIO_PATH}.
|
|
232
|
+
* Both bundler dev servers mount it — Vite's `server.middlewares` and Rsbuild's
|
|
233
|
+
* — so the studio lives at the same URL whichever one runs the app.
|
|
234
|
+
*
|
|
235
|
+
* Caches the asset bytes but re-reads them when the built files change on disk
|
|
236
|
+
* (compared via {@link studioAssetsStamp}), so a `@lunora/studio` rebuild is
|
|
237
|
+
* picked up live without a dev server restart.
|
|
238
|
+
*/
|
|
239
|
+
declare const createStudioMiddleware: (options: StudioMiddlewareOptions) => ((request: IncomingMessage, response: ServerResponse, next: () => void) => void);
|
|
153
240
|
/**
|
|
154
241
|
* Endpoint path both dev hosts mount the handler at. A sibling of the schema
|
|
155
242
|
* editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
|
|
@@ -277,46 +364,6 @@ interface SeedResponse {
|
|
|
277
364
|
* rather than hand back children whose parents it just dropped.
|
|
278
365
|
*/
|
|
279
366
|
declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
|
|
280
|
-
/**
|
|
281
|
-
* The host's project configuration, forwarded verbatim to the handler. Separate
|
|
282
|
-
* from `projectRoot` (which every host has) because these two come from the
|
|
283
|
-
* host's own Lunora options.
|
|
284
|
-
*/
|
|
285
|
-
interface LocalEndpointContext {
|
|
286
|
-
/** API-spec mode the host runs codegen with, so a studio edit regenerates the same spec files. */
|
|
287
|
-
readonly apiSpec?: CodegenOptions["apiSpec"];
|
|
288
|
-
/** Override the lunora subdirectory name. Defaults to `"lunora"`. */
|
|
289
|
-
readonly schemaDirectory?: string;
|
|
290
|
-
}
|
|
291
|
-
/** A request adapted from a host transport, passed to a local-dev handler. */
|
|
292
|
-
interface LocalEndpointRequest extends LocalEndpointContext {
|
|
293
|
-
/** Parsed JSON body of the request (`undefined` for `GET` / an empty body). */
|
|
294
|
-
readonly body?: unknown;
|
|
295
|
-
/** HTTP method. */
|
|
296
|
-
readonly method: string;
|
|
297
|
-
/** Project root containing the `lunora/` directory. */
|
|
298
|
-
readonly projectRoot: string;
|
|
299
|
-
}
|
|
300
|
-
/** A response a local-dev handler returns, serialised back as JSON with its status. */
|
|
301
|
-
interface LocalEndpointResponse {
|
|
302
|
-
readonly body: unknown;
|
|
303
|
-
readonly status: number;
|
|
304
|
-
}
|
|
305
|
-
/** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
|
|
306
|
-
type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse;
|
|
307
|
-
/**
|
|
308
|
-
* Adapt a `node:http` request/response pair to a transport-agnostic local-dev
|
|
309
|
-
* handler. `GET` carries no body (the schema editor uses it to read the parsed
|
|
310
|
-
* schema); every other method has its body read + JSON-parsed first. The
|
|
311
|
-
* handler's `{ status, body }` is serialised back as JSON. A malformed body is a
|
|
312
|
-
* `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
|
|
313
|
-
*
|
|
314
|
-
* `context` carries the host's own Lunora options through to the handler: its
|
|
315
|
-
* `schemaDirectory` (so a custom `schemaDir` targets the right directory instead
|
|
316
|
-
* of defaulting to `"lunora"`) and its `apiSpec`, so a studio edit regenerates
|
|
317
|
-
* with the same options the host's own codegen run uses.
|
|
318
|
-
*/
|
|
319
|
-
declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string, context?: LocalEndpointContext) => void;
|
|
320
367
|
/** A single header value, lower-cased and trimmed; `undefined` when absent or array-valued. */
|
|
321
368
|
declare const headerValue: (raw: string | string[] | undefined) => string | undefined;
|
|
322
369
|
/**
|
|
@@ -349,34 +396,36 @@ declare const ALLOW_FORWARDED_ENV = "LUNORA_STUDIO_ALLOW_FORWARDED";
|
|
|
349
396
|
* the dev server, not just as an opaque 403 in the browser.
|
|
350
397
|
*/
|
|
351
398
|
declare const transportRejectionReason: (request: IncomingMessage, logger?: WarnLogger) => string | undefined;
|
|
352
|
-
export { ALLOW_FORWARDED_ENV, type LocalEndpointContext, type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type WarnLogger, type WirePolicyEdit, applyStudioAssetCache, assetContentType, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, headerValue, isLoopbackAddress, isStandaloneModulePath, loadStudioAssets,
|
|
399
|
+
export { ALLOW_FORWARDED_ENV, type LocalEndpointContext, type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, STUDIO_PATH, STUDIO_SCRIPT_PATH, STUDIO_STYLE_PATH, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type StudioMiddlewareOptions, type WarnLogger, type WirePolicyEdit, applyStudioAssetCache, assetContentType, createStudioMiddleware, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, headerValue, isLoopbackAddress, isNonLoopbackHost, isStandaloneModulePath, loadStudioAssets,
|
|
353
400
|
/**
|
|
354
401
|
* `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
|
|
355
402
|
* the prebuilt `@lunora/studio` SPA during local dev.
|
|
356
403
|
*
|
|
357
|
-
*
|
|
404
|
+
* Three dev hosts serve the studio from this code, so it behaves identically
|
|
358
405
|
* regardless of how the project is run:
|
|
359
|
-
* - `@lunora/vite`
|
|
360
|
-
*
|
|
406
|
+
* - `@lunora/vite` and `@lunora/rspack` mount `createStudioMiddleware` on their
|
|
407
|
+
* dev server at `/__lunora` — same routing, same URL.
|
|
408
|
+
* - `@lunora/cli` (`lunora dev`) serves it from a standalone Node HTTP server
|
|
409
|
+
* with its own routing (a root mount, and a read-only shell off loopback).
|
|
361
410
|
*
|
|
362
|
-
*
|
|
363
|
-
* the
|
|
364
|
-
*
|
|
365
|
-
* load the prebuilt asset bytes.
|
|
411
|
+
* The genuinely shared parts live here: render the host HTML with per-server
|
|
412
|
+
* config injected, resolve the admin token the same way the worker does, gate
|
|
413
|
+
* the transport, and load the prebuilt asset bytes.
|
|
366
414
|
*/
|
|
367
|
-
parseDevVariable, readStandaloneAsset, renderStudioHtml,
|
|
415
|
+
parseDevVariable, readStandaloneAsset, renderStudioHtml, requestPathname,
|
|
368
416
|
/**
|
|
369
417
|
* `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
|
|
370
418
|
* the prebuilt `@lunora/studio` SPA during local dev.
|
|
371
419
|
*
|
|
372
|
-
*
|
|
420
|
+
* Three dev hosts serve the studio from this code, so it behaves identically
|
|
373
421
|
* regardless of how the project is run:
|
|
374
|
-
* - `@lunora/vite`
|
|
375
|
-
*
|
|
422
|
+
* - `@lunora/vite` and `@lunora/rspack` mount `createStudioMiddleware` on their
|
|
423
|
+
* dev server at `/__lunora` — same routing, same URL.
|
|
424
|
+
* - `@lunora/cli` (`lunora dev`) serves it from a standalone Node HTTP server
|
|
425
|
+
* with its own routing (a root mount, and a read-only shell off loopback).
|
|
376
426
|
*
|
|
377
|
-
*
|
|
378
|
-
* the
|
|
379
|
-
*
|
|
380
|
-
* load the prebuilt asset bytes.
|
|
427
|
+
* The genuinely shared parts live here: render the host HTML with per-server
|
|
428
|
+
* config injected, resolve the admin token the same way the worker does, gate
|
|
429
|
+
* the transport, and load the prebuilt asset bytes.
|
|
381
430
|
*/
|
|
382
|
-
resolveAdminToken, resolveStandaloneDirectory, sendStudioDocument, serveJsonHandler, studioAssetsStamp, transportRejectionReason };
|
|
431
|
+
resolveAdminToken, resolveStandaloneDirectory, sendStudioDocument, serveJsonHandler, studioAssetsStamp, studioMountPath, transportRejectionReason };
|