@lunora/config 1.0.0-alpha.283 → 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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveAdminToken as A}from"./parseDevVariable-teAAahVD.mjs";import{sendStudioDocument as I,applyStudioAssetCache as O}from"./applyStudioAssetCache-DHQEJuuv.mjs";import{isStandaloneModulePath as _,studioAssetsStamp as H,loadStudioAssets as N,readStandaloneAsset as C,assetContentType as D}from"./assetContentType-CUb5bpbI.mjs";import{detectAgentRules as E}from"./AGENT_RULES_DIR-C54Ta_vz.mjs";import{handlePolicyScaffoldRequest as v,POLICY_SCAFFOLD_ENDPOINT as L}from"./POLICY_SCAFFOLD_ENDPOINT-0QiGKazX.mjs";import R from"./renderStudioHtml-ByowDtMl.mjs";import{handleSchemaEditRequest as b,SCHEMA_EDIT_ENDPOINT as x}from"./SCHEMA_EDIT_ENDPOINT-Dbt0faMd.mjs";import{handleSeedRequest as k,SEED_ENDPOINT as $}from"./SEED_ENDPOINT-2B56PN_H.mjs";import{serveJsonHandler as g}from"./serveJsonHandler-Dv0EdCb9.mjs";import{transportRejectionReason as j}from"./ALLOW_FORWARDED_ENV-BUndghJx.mjs";const d="/__lunora",M=`${d}/studio.js`,m=`${d}/styles.css`,p=/\/$/,U={[L]:v,[x]:b,[$]:k},q=new Set(["127.0.0.1","::1","localhost"]),X=t=>t!==void 0&&t!==!1&&!q.has(t),y=t=>t===void 0||t==="/"?"":t.replace(p,""),Z=t=>`${y(t)}${d}`,T=(t,n,c)=>{t.statusCode=200,t.setHeader("Content-Type",c),t.end(n)},w=t=>{try{return new URL(t,"http://localhost").pathname}catch{const n=t.indexOf("?");return n===-1?t:t.slice(0,n)}},tt=t=>{const{logger:n,projectRoot:c}=t,u=y(t.base);let l,f,S;const P=(o,s,e)=>{const i=H();if((l===void 0||i!==f)&&(l=N(n),f=i),l===void 0){e.statusCode=501,e.setHeader("Content-Type","text/plain"),e.end("Lunora studio assets not found — install and build @lunora/studio.");return}const a=o===m,r=o.slice(o.lastIndexOf("/")+1);if(O(s,e,r,i))return;if(a){T(e,l.styles,"text/css; charset=utf-8");return}const h=C(r);if(h===void 0){e.statusCode=404,e.setHeader("Content-Type","text/plain"),e.end("Not found");return}T(e,h,D(r))};return(o,s,e)=>{const i=w(o.url??"").replace(p,""),a=u!==""&&i.startsWith(u)?i.slice(u.length):i;if(a!==d&&!a.startsWith(`${d}/`)){e();return}if(t.isNonLoopbackBind||j(o,n)!==void 0){s.statusCode=403,s.setHeader("Content-Type","text/plain"),s.end("Lunora studio is only available on loopback hosts in dev.");return}const r=U[a];if(r!==void 0){g(o,s,r,c,{apiSpec:t.apiSpec,schemaDirectory:t.schemaDirectory});return}if(a===m||_(a)){P(a,o,s);return}S??=R({adminToken:A(c),basePath:d,dataEditable:!0,rulesInstalled:E(c).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:M,styleHref:m}),I(s,S)}};export{d as STUDIO_PATH,M as STUDIO_SCRIPT_PATH,m as STUDIO_STYLE_PATH,tt as createStudioMiddleware,X as isNonLoopbackHost,w as requestPathname,Z as studioMountPath};
|
|
@@ -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 };
|
|
@@ -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 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseDevVariable as t,resolveAdminToken as r}from"../packem_shared/parseDevVariable-teAAahVD.mjs";import{applyStudioAssetCache as s,sendStudioDocument as d}from"../packem_shared/applyStudioAssetCache-DHQEJuuv.mjs";import{assetContentType as
|
|
1
|
+
import{parseDevVariable as t,resolveAdminToken as r}from"../packem_shared/parseDevVariable-teAAahVD.mjs";import{applyStudioAssetCache as s,sendStudioDocument as d}from"../packem_shared/applyStudioAssetCache-DHQEJuuv.mjs";import{assetContentType as S,isStandaloneModulePath as l,loadStudioAssets as p,readStandaloneAsset as i,resolveStandaloneDirectory as m,studioAssetsStamp as u}from"../packem_shared/assetContentType-CUb5bpbI.mjs";import{STUDIO_PATH as T,STUDIO_SCRIPT_PATH as f,STUDIO_STYLE_PATH as A,createStudioMiddleware as P,isNonLoopbackHost as _,requestPathname as E,studioMountPath as c}from"../packem_shared/STUDIO_PATH-BZI8go9A.mjs";import{POLICY_SCAFFOLD_ENDPOINT as O,handlePolicyScaffoldRequest as h}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-0QiGKazX.mjs";import{default as N}from"../packem_shared/renderStudioHtml-ByowDtMl.mjs";import{SCHEMA_EDIT_ENDPOINT as H,handleSchemaEditRequest as L}from"../packem_shared/SCHEMA_EDIT_ENDPOINT-Dbt0faMd.mjs";import{SEED_ENDPOINT as q,handleSeedRequest as v}from"../packem_shared/SEED_ENDPOINT-2B56PN_H.mjs";import{serveJsonHandler as M}from"../packem_shared/serveJsonHandler-Dv0EdCb9.mjs";import{ALLOW_FORWARDED_ENV as k,headerValue as F,isLoopbackAddress as U,transportRejectionReason as V}from"../packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs";export{k as ALLOW_FORWARDED_ENV,O as POLICY_SCAFFOLD_ENDPOINT,H as SCHEMA_EDIT_ENDPOINT,q as SEED_ENDPOINT,T as STUDIO_PATH,f as STUDIO_SCRIPT_PATH,A as STUDIO_STYLE_PATH,s as applyStudioAssetCache,S as assetContentType,P as createStudioMiddleware,h as handlePolicyScaffoldRequest,L as handleSchemaEditRequest,v as handleSeedRequest,F as headerValue,U as isLoopbackAddress,_ as isNonLoopbackHost,l as isStandaloneModulePath,p as loadStudioAssets,t as parseDevVariable,i as readStandaloneAsset,N as renderStudioHtml,E as requestPathname,r as resolveAdminToken,m as resolveStandaloneDirectory,d as sendStudioDocument,M as serveJsonHandler,u as studioAssetsStamp,c as studioMountPath,V as transportRejectionReason};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/config",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.284",
|
|
4
4
|
"description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bindings",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.239",
|
|
58
58
|
"@lunora/container": "1.0.0-alpha.63",
|
|
59
59
|
"@lunora/errors": "1.0.0-alpha.47",
|
|
60
60
|
"@lunora/seed": "1.0.0-alpha.169",
|