@lunora/config 1.0.0-alpha.7 → 1.0.0-alpha.71

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 (39) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/index.d.mts +885 -461
  4. package/dist/index.d.ts +885 -461
  5. package/dist/index.mjs +18 -10
  6. package/dist/packem_shared/AGENT_MODE_ENV-B5R7jpY7.mjs +17 -0
  7. package/dist/packem_shared/DEV_DAEMON_ENV-FIEtW7Fz.mjs +163 -0
  8. package/dist/packem_shared/{LUNORA_EVENT_SOURCE-D2fDeGB6.mjs → LUNORA_EVENT_SOURCE-M1KM9_pR.mjs} +28 -2
  9. package/dist/packem_shared/{PACKAGE_SECRETS_REGISTRY-CySy5vR_.mjs → PACKAGE_SECRETS_REGISTRY-BeRSvrl5.mjs} +45 -1
  10. package/dist/packem_shared/{POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs → POLICY_SCAFFOLD_ENDPOINT-CvTZpaZF.mjs} +7 -10
  11. package/dist/packem_shared/{REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs → REMOTE_ELIGIBLE_KEYS-C-F_Flgy.mjs} +1 -6
  12. package/dist/packem_shared/{REQUIRED_COMPATIBILITY_DATE-ycqievRl.mjs → REQUIRED_COMPATIBILITY_DATE-DP0SFVy9.mjs} +135 -4
  13. package/dist/packem_shared/{SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs → SCHEMA_EDIT_ENDPOINT-Bt2SNkpV.mjs} +4 -8
  14. package/dist/packem_shared/{SEED_ENDPOINT-DVCjaGO-.mjs → SEED_ENDPOINT-7izz_Jao.mjs} +1 -1
  15. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-CaXbS7CX.mjs +11 -0
  16. package/dist/packem_shared/assetContentType-ByZjeV3D.mjs +72 -0
  17. package/dist/packem_shared/{buildPackageSecretsBlock-S74dgmwy.mjs → buildPackageSecretsBlock-B-dWb-Sa.mjs} +115 -21
  18. package/dist/packem_shared/collectWranglerSecretVariables-p4ezBYQ4.mjs +56 -0
  19. package/dist/packem_shared/{createConfirm-fvpdgJ9s.mjs → createConfirm-BMikeJC9.mjs} +22 -5
  20. package/dist/packem_shared/{detectFramework-Br-BcPBq.mjs → detectFramework-U08038Yp.mjs} +3 -3
  21. package/dist/packem_shared/discoverAgentInfo-eXA3hF4v.mjs +19 -0
  22. package/dist/packem_shared/{discoverSchemaInfo-DWtypqpP.mjs → discoverSchemaInfo-BB-CKlTK.mjs} +1 -1
  23. package/dist/packem_shared/{inferLunoraBindings-XNJH4pup.mjs → inferLunoraBindings-BcvvtpSG.mjs} +146 -51
  24. package/dist/packem_shared/jsonc-edit-SbcD7MAe.mjs +9 -0
  25. package/dist/packem_shared/parseDevVariable-B0FEvfHC.mjs +21 -0
  26. package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.ts → policy-scaffold.d-CFd2FlqG.d.mts} +22 -22
  27. package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.mts → policy-scaffold.d-CFd2FlqG.d.ts} +22 -22
  28. package/dist/packem_shared/{reconcileWranglerBindings-DTHmqTbL.mjs → reconcileWranglerBindings-2Cww5VLa.mjs} +114 -29
  29. package/dist/packem_shared/reconcileWranglerCompatibilityDate-C8c497ag.mjs +31 -0
  30. package/dist/packem_shared/reconcileWranglerCrons-DvsceVFz.mjs +29 -0
  31. package/dist/packem_shared/{serveJsonHandler-B4OLTGLS.mjs → serveJsonHandler-Cl2Wqkv8.mjs} +2 -2
  32. package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +157 -0
  33. package/dist/packem_shared/write-atomic-B2REqapi.mjs +14 -0
  34. package/dist/studio-host/index.d.mts +134 -92
  35. package/dist/studio-host/index.d.ts +134 -92
  36. package/dist/studio-host/index.mjs +6 -6
  37. package/package.json +11 -8
  38. package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
  39. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
@@ -1,14 +1,20 @@
1
- import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-DCmwn7zQ.mjs";
1
+ import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-CFd2FlqG.mjs";
2
2
  import { IncomingMessage, ServerResponse } from 'node:http';
3
- /** Parse a single `KEY=value` (optionally quoted) out of a `.dev.vars` body. */
3
+ /**
4
+ * Parse a single `KEY=value` (optionally quoted) out of a `.dev.vars` body,
5
+ * returning `undefined` when the key is absent or its value is empty. A thin
6
+ * wrapper over {@link parseDevVariableEntries} — the single owner of the
7
+ * `.dev.vars` line grammar — so the key-validation, comment-skip, and quote-strip
8
+ * rules can't drift from every other reader/writer of the file.
9
+ */
4
10
  declare const parseDevVariable: (contents: string, key: string) => string | undefined;
5
11
  /**
6
- * Resolve the worker's admin token so the studio can auto-authenticate in
7
- * dev. Prefers the `LUNORA_ADMIN_TOKEN` env var, then the project's `.dev.vars`
8
- * — the same file `@cloudflare/vite-plugin` / `wrangler dev` feed the worker, so
9
- * the token the studio sends matches the one the worker's admin gate
10
- * verifies. Returns `undefined` when neither is set (the studio then prompts).
11
- */
12
+ * Resolve the worker's admin token so the studio can auto-authenticate in
13
+ * dev. Prefers the `LUNORA_ADMIN_TOKEN` env var, then the project's `.dev.vars`
14
+ * — the same file `@cloudflare/vite-plugin` / `wrangler dev` feed the worker, so
15
+ * the token the studio sends matches the one the worker's admin gate
16
+ * verifies. Returns `undefined` when neither is set (the studio then prompts).
17
+ */
12
18
  declare const resolveAdminToken: (root: string) => string | undefined;
13
19
  /** Config injected into the studio document before the bundle loads. */
14
20
  interface StudioHtmlConfig {
@@ -17,34 +23,34 @@ interface StudioHtmlConfig {
17
23
  /** Router basepath the studio mounts under (e.g. `/__lunora`, or `/` for a root server). */
18
24
  readonly basePath: string;
19
25
  /**
20
- * Make the data browser editable (insert/edit/delete rows). Injected as
21
- * `window.__LUNORA_DATA_EDITABLE__` for the bundle to read. The loopback-only
22
- * dev hosts (the Vite `/__lunora` route, the CLI studio server) set this so a
23
- * developer can edit; a static deploy leaves it off (read-only) by default.
24
- */
26
+ * Make the data browser editable (insert/edit/delete rows). Injected as
27
+ * `window.__LUNORA_DATA_EDITABLE__` for the bundle to read. The loopback-only
28
+ * dev hosts (the Vite `/__lunora` route, the CLI studio server) set this so a
29
+ * developer can edit; a static deploy leaves it off (read-only) by default.
30
+ */
25
31
  readonly dataEditable?: boolean;
26
32
  /**
27
- * Whether the project's Lunora agent skills ("rules") are installed. Injected
28
- * as `window.__LUNORA_RULES_INSTALLED__` **only when `false`**, so the studio
29
- * shows a "rules not installed" banner on the loopback dev hosts (which detect
30
- * it) and stays quiet on a static deploy (which leaves it unset).
31
- */
33
+ * Whether the project's Lunora agent skills ("rules") are installed. Injected
34
+ * as `window.__LUNORA_RULES_INSTALLED__` **only when `false`**, so the studio
35
+ * shows a "rules not installed" banner on the loopback dev hosts (which detect
36
+ * it) and stays quiet on a static deploy (which leaves it unset).
37
+ */
32
38
  readonly rulesInstalled?: boolean;
33
39
  /**
34
- * Enable the function runner's "Run as identity" tool (execute a function as a
35
- * chosen user to test auth/RLS). Injected as `window.__LUNORA_RUN_AS_IDENTITY__`.
36
- * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts set
37
- * this — forging an identity is a developer-only affordance; a static deploy
38
- * leaves it off so the control never renders.
39
- */
40
+ * Enable the function runner's "Run as identity" tool (execute a function as a
41
+ * chosen user to test auth/RLS). Injected as `window.__LUNORA_RUN_AS_IDENTITY__`.
42
+ * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts set
43
+ * this — forging an identity is a developer-only affordance; a static deploy
44
+ * leaves it off so the control never renders.
45
+ */
40
46
  readonly runAsIdentity?: boolean;
41
47
  /**
42
- * Enable the visual schema editor (add table / column / index, written back to
43
- * `lunora/schema.ts` + codegen). Injected as `window.__LUNORA_SCHEMA_EDITABLE__`.
44
- * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts
45
- * set this — editing source + running codegen needs the project's filesystem and
46
- * toolchain, so a static deploy leaves it off and the diagram stays read-only.
47
- */
48
+ * Enable the visual schema editor (add table / column / index, written back to
49
+ * `lunora/schema.ts` + codegen). Injected as `window.__LUNORA_SCHEMA_EDITABLE__`.
50
+ * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts
51
+ * set this — editing source + running codegen needs the project's filesystem and
52
+ * toolchain, so a static deploy leaves it off and the diagram stays read-only.
53
+ */
48
54
  readonly schemaEditable?: boolean;
49
55
  /** URL the studio bundle is served from (absolute, host-relative). */
50
56
  readonly scriptSrc: string;
@@ -61,30 +67,62 @@ interface StudioAssets {
61
67
  readonly styles: Buffer;
62
68
  }
63
69
  /**
64
- * Read the prebuilt static studio files shipped by `@lunora/studio`
65
- * (`dist/standalone/studio.js` + `dist/styles.css`). Returns `undefined` —
66
- * with a one-time warning — when the optional package isn't installed or hasn't
67
- * been built, so a missing studio never breaks the dev server.
68
- *
69
- * `resolveFrom` controls where `@lunora/studio` is resolved from. It defaults
70
- * to this module's own location, which is correct once this code is inlined into
71
- * a host package (`@lunora/vite` / `@lunora/cli`) that has `@lunora/studio`
72
- * installed — node walks up from the host's `dist` to find it.
73
- */
70
+ * Read the prebuilt static studio files shipped by `@lunora/studio`
71
+ * (`dist/standalone/studio.js` + `dist/styles.css`). Returns `undefined` —
72
+ * with a one-time warning — when the optional package isn't installed or hasn't
73
+ * been built, so a missing studio never breaks the dev server.
74
+ *
75
+ * `resolveFrom` controls where `@lunora/studio` is resolved from. It defaults
76
+ * to this module's own location, which is correct once this code is inlined into
77
+ * a host package (`@lunora/vite` / `@lunora/cli`) that has `@lunora/studio`
78
+ * installed — node walks up from the host's `dist` to find it.
79
+ */
74
80
  declare const loadStudioAssets: (logger?: WarnLogger, resolveFrom?: string) => StudioAssets | undefined;
75
81
  /**
76
- * A freshness stamp for the studio assets: the latest mtime (ms) of the resolved
77
- * `studio.js` / `styles.css`, or `undefined` when they can't be resolved. Hosts
78
- * cache {@link loadStudioAssets} for the dev session but compare this stamp per
79
- * request, so a `@lunora/studio` rebuild mid-session is picked up live — no dev
80
- * server restart needed.
81
- */
82
+ * A freshness stamp for the studio assets: the latest mtime (ms) of the resolved
83
+ * `studio.js` / `styles.css`, or `undefined` when they can't be resolved. Hosts
84
+ * cache {@link loadStudioAssets} for the dev session but compare this stamp per
85
+ * request, so a `@lunora/studio` rebuild mid-session is picked up live — no dev
86
+ * server restart needed.
87
+ */
82
88
  declare const studioAssetsStamp: (resolveFrom?: string) => number | undefined;
83
89
  /**
84
- * Endpoint path both dev hosts mount the handler at. A sibling of the schema
85
- * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
86
- * CLI's `/_lunora/*` worker proxy (single underscore).
87
- */
90
+ * Absolute path of the built standalone directory — `@lunora/studio`'s
91
+ * `dist/standalone`, where the `studio.js` entry and its code-split `chunk-*.js`
92
+ * siblings live — or `undefined` when the studio isn't installed/built. The
93
+ * standalone bundle is emitted with esbuild `splitting`, so the hosts must serve
94
+ * the whole directory (not two fixed paths); this resolves its root.
95
+ */
96
+ declare const resolveStandaloneDirectory: (resolveFrom?: string) => string | undefined;
97
+ /**
98
+ * Read a single file from the standalone directory by its plain filename (the
99
+ * `studio.js` entry, a `chunk-*.js`, or a `.map`). **Path-traversal-safe** via
100
+ * {@link resolveContainedFile}: only a lone filename resolving to a direct child
101
+ * of the standalone directory is served — any separator, `..`, NUL, or absolute
102
+ * path is rejected — so a request like `../../etc/passwd` can never escape it.
103
+ * Returns the bytes, or `undefined` when the studio isn't built or the name
104
+ * doesn't resolve to a file inside the directory (the host answers that 404).
105
+ */
106
+ declare const readStandaloneAsset: (fileName: string, resolveFrom?: string) => Buffer | undefined;
107
+ /**
108
+ * True when `pathname` addresses a standalone JS module — the `studio.js` entry
109
+ * or one of its code-split `chunk-*.js` siblings (and their `.map`s). Shared by
110
+ * the CLI and Vite hosts so both route the same request shapes to the directory
111
+ * server; the stylesheet is matched separately at each host's own style path.
112
+ */
113
+ declare const isStandaloneModulePath: (pathname: string) => boolean;
114
+ /**
115
+ * Content-Type for a served standalone asset, by extension: `.css` → CSS,
116
+ * `.map` → JSON (a source map), everything else (the `.js` entry + chunks) →
117
+ * JavaScript. Shared by the CLI and Vite hosts so the MIME decision lives in one
118
+ * place.
119
+ */
120
+ declare const assetContentType: (fileName: string) => string;
121
+ /**
122
+ * Endpoint path both dev hosts mount the handler at. A sibling of the schema
123
+ * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
124
+ * CLI's `/_lunora/*` worker proxy (single underscore).
125
+ */
88
126
  declare const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
89
127
  /** A `wireRls` request additionally carries the procedure's source-file path. */
90
128
  interface WirePolicyEdit extends WireRlsEdit {
@@ -110,26 +148,26 @@ interface PolicyScaffoldResponse {
110
148
  readonly status: number;
111
149
  }
112
150
  /**
113
- * Handle a policy-scaffold request. Pure over its inputs apart from the file
114
- * I/O + codegen it performs on an applied edit; safe to unit-test against a
115
- * temp project directory.
116
- */
151
+ * Handle a policy-scaffold request. Pure over its inputs apart from the file
152
+ * I/O + codegen it performs on an applied edit; safe to unit-test against a
153
+ * temp project directory.
154
+ */
117
155
  declare const handlePolicyScaffoldRequest: (request: PolicyScaffoldRequest) => PolicyScaffoldResponse;
118
156
  /**
119
- * Render the single-page document that boots the studio. Emitted verbatim —
120
- * never through a bundler/transform — so the studio stays a static tool,
121
- * decoupled from the host project's build. A small inline script publishes the
122
- * per-server config on `globalThis` before the bundle loads: the mount basepath
123
- * (so the router stays under its mount), the admin token when present (so the
124
- * studio auto-authenticates instead of prompting), and an editable flag when the
125
- * host is a loopback dev server (so the data browser allows edits).
126
- */
157
+ * Render the single-page document that boots the studio. Emitted verbatim —
158
+ * never through a bundler/transform — so the studio stays a static tool,
159
+ * decoupled from the host project's build. A small inline script publishes the
160
+ * per-server config on `globalThis` before the bundle loads: the mount basepath
161
+ * (so the router stays under its mount), the admin token when present (so the
162
+ * studio auto-authenticates instead of prompting), and an editable flag when the
163
+ * host is a loopback dev server (so the data browser allows edits).
164
+ */
127
165
  declare const renderStudioHtml: (config: StudioHtmlConfig) => string;
128
166
  /**
129
- * Endpoint path both dev hosts mount the handler at. Distinct from the CLI's
130
- * `/_lunora/*` worker proxy (single underscore), so a schema edit is never
131
- * forwarded to the worker.
132
- */
167
+ * Endpoint path both dev hosts mount the handler at. Distinct from the CLI's
168
+ * `/_lunora/*` worker proxy (single underscore), so a schema edit is never
169
+ * forwarded to the worker.
170
+ */
133
171
  declare const SCHEMA_EDIT_ENDPOINT = "/__lunora/schema-edit";
134
172
  /** A request adapted from the host transport. */
135
173
  interface SchemaEditRequest {
@@ -148,28 +186,28 @@ interface SchemaEditResponse {
148
186
  readonly status: number;
149
187
  }
150
188
  /**
151
- * Handle a schema-edit request. Pure over its inputs apart from the file I/O +
152
- * codegen it performs on a `POST` additive edit; safe to unit-test against a
153
- * temp project directory.
154
- */
189
+ * Handle a schema-edit request. Pure over its inputs apart from the file I/O +
190
+ * codegen it performs on a `POST` additive edit; safe to unit-test against a
191
+ * temp project directory.
192
+ */
155
193
  declare const handleSchemaEditRequest: (request: SchemaEditRequest) => SchemaEditResponse;
156
194
  /**
157
- * Endpoint path both dev hosts mount the handler at. A sibling of the schema
158
- * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
159
- * CLI's `/_lunora/*` worker proxy (single underscore).
160
- */
195
+ * Endpoint path both dev hosts mount the handler at. A sibling of the schema
196
+ * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
197
+ * CLI's `/_lunora/*` worker proxy (single underscore).
198
+ */
161
199
  declare const SEED_ENDPOINT = "/__lunora/seed";
162
200
  /** Body the host transport adapts from a `POST` — one generate-rows request. */
163
201
  interface SeedRequestBody {
164
202
  /** How many rows to generate (clamped to `[1, MAX_SEED_ROWS]`). */
165
203
  readonly count?: number;
166
204
  /**
167
- * Ids of rows that already exist in the live DB, keyed by referenced table.
168
- * Foreign keys resolve against these, and every referenced parent table
169
- * present here is treated as covered — so the generator links to existing
170
- * rows instead of fabricating new parent rows. The studio samples these from
171
- * the target table's FK columns before calling.
172
- */
205
+ * Ids of rows that already exist in the live DB, keyed by referenced table.
206
+ * Foreign keys resolve against these, and every referenced parent table
207
+ * present here is treated as covered — so the generator links to existing
208
+ * rows instead of fabricating new parent rows. The studio samples these from
209
+ * the target table's FK columns before calling.
210
+ */
173
211
  readonly existingIds?: Readonly<Record<string, ReadonlyArray<string>>>;
174
212
  /** Deterministic mapping selector — same value yields identical rows. */
175
213
  readonly seed?: number;
@@ -193,10 +231,10 @@ interface SeedResponse {
193
231
  readonly status: number;
194
232
  }
195
233
  /**
196
- * Handle a generate-rows request: statically lift the schema, generate `count`
197
- * rows for `table` (linking foreign keys to the supplied existing ids rather
198
- * than fabricating parents), and return them JSON-safe for the client to insert.
199
- */
234
+ * Handle a generate-rows request: statically lift the schema, generate `count`
235
+ * rows for `table` (linking foreign keys to the supplied existing ids rather
236
+ * than fabricating parents), and return them JSON-safe for the client to insert.
237
+ */
200
238
  declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
201
239
  /** A request adapted from a host transport, passed to a local-dev handler. */
202
240
  interface LocalEndpointRequest {
@@ -217,11 +255,15 @@ interface LocalEndpointResponse {
217
255
  /** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
218
256
  type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse;
219
257
  /**
220
- * Adapt a `node:http` request/response pair to a transport-agnostic local-dev
221
- * handler. `GET` carries no body (the schema editor uses it to read the parsed
222
- * schema); every other method has its body read + JSON-parsed first. The
223
- * handler's `{ status, body }` is serialised back as JSON. A malformed body is a
224
- * `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
225
- */
226
- declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string) => void;
227
- export { 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, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, loadStudioAssets, parseDevVariable, renderStudioHtml, resolveAdminToken, serveJsonHandler, studioAssetsStamp };
258
+ * Adapt a `node:http` request/response pair to a transport-agnostic local-dev
259
+ * handler. `GET` carries no body (the schema editor uses it to read the parsed
260
+ * schema); every other method has its body read + JSON-parsed first. The
261
+ * handler's `{ status, body }` is serialised back as JSON. A malformed body is a
262
+ * `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
263
+ *
264
+ * `schemaDirectory` (when the host configures a custom `schemaDir`) is forwarded
265
+ * to the handler so the schema/seed/policy endpoints target the right directory
266
+ * instead of always defaulting to `"lunora"`.
267
+ */
268
+ declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string, schemaDirectory?: string) => void;
269
+ export { 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, assetContentType, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, isStandaloneModulePath, loadStudioAssets, parseDevVariable, readStandaloneAsset, renderStudioHtml, resolveAdminToken, resolveStandaloneDirectory, serveJsonHandler, studioAssetsStamp };
@@ -1,14 +1,20 @@
1
- import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-DCmwn7zQ.js";
1
+ import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-CFd2FlqG.js";
2
2
  import { IncomingMessage, ServerResponse } from 'node:http';
3
- /** Parse a single `KEY=value` (optionally quoted) out of a `.dev.vars` body. */
3
+ /**
4
+ * Parse a single `KEY=value` (optionally quoted) out of a `.dev.vars` body,
5
+ * returning `undefined` when the key is absent or its value is empty. A thin
6
+ * wrapper over {@link parseDevVariableEntries} — the single owner of the
7
+ * `.dev.vars` line grammar — so the key-validation, comment-skip, and quote-strip
8
+ * rules can't drift from every other reader/writer of the file.
9
+ */
4
10
  declare const parseDevVariable: (contents: string, key: string) => string | undefined;
5
11
  /**
6
- * Resolve the worker's admin token so the studio can auto-authenticate in
7
- * dev. Prefers the `LUNORA_ADMIN_TOKEN` env var, then the project's `.dev.vars`
8
- * — the same file `@cloudflare/vite-plugin` / `wrangler dev` feed the worker, so
9
- * the token the studio sends matches the one the worker's admin gate
10
- * verifies. Returns `undefined` when neither is set (the studio then prompts).
11
- */
12
+ * Resolve the worker's admin token so the studio can auto-authenticate in
13
+ * dev. Prefers the `LUNORA_ADMIN_TOKEN` env var, then the project's `.dev.vars`
14
+ * — the same file `@cloudflare/vite-plugin` / `wrangler dev` feed the worker, so
15
+ * the token the studio sends matches the one the worker's admin gate
16
+ * verifies. Returns `undefined` when neither is set (the studio then prompts).
17
+ */
12
18
  declare const resolveAdminToken: (root: string) => string | undefined;
13
19
  /** Config injected into the studio document before the bundle loads. */
14
20
  interface StudioHtmlConfig {
@@ -17,34 +23,34 @@ interface StudioHtmlConfig {
17
23
  /** Router basepath the studio mounts under (e.g. `/__lunora`, or `/` for a root server). */
18
24
  readonly basePath: string;
19
25
  /**
20
- * Make the data browser editable (insert/edit/delete rows). Injected as
21
- * `window.__LUNORA_DATA_EDITABLE__` for the bundle to read. The loopback-only
22
- * dev hosts (the Vite `/__lunora` route, the CLI studio server) set this so a
23
- * developer can edit; a static deploy leaves it off (read-only) by default.
24
- */
26
+ * Make the data browser editable (insert/edit/delete rows). Injected as
27
+ * `window.__LUNORA_DATA_EDITABLE__` for the bundle to read. The loopback-only
28
+ * dev hosts (the Vite `/__lunora` route, the CLI studio server) set this so a
29
+ * developer can edit; a static deploy leaves it off (read-only) by default.
30
+ */
25
31
  readonly dataEditable?: boolean;
26
32
  /**
27
- * Whether the project's Lunora agent skills ("rules") are installed. Injected
28
- * as `window.__LUNORA_RULES_INSTALLED__` **only when `false`**, so the studio
29
- * shows a "rules not installed" banner on the loopback dev hosts (which detect
30
- * it) and stays quiet on a static deploy (which leaves it unset).
31
- */
33
+ * Whether the project's Lunora agent skills ("rules") are installed. Injected
34
+ * as `window.__LUNORA_RULES_INSTALLED__` **only when `false`**, so the studio
35
+ * shows a "rules not installed" banner on the loopback dev hosts (which detect
36
+ * it) and stays quiet on a static deploy (which leaves it unset).
37
+ */
32
38
  readonly rulesInstalled?: boolean;
33
39
  /**
34
- * Enable the function runner's "Run as identity" tool (execute a function as a
35
- * chosen user to test auth/RLS). Injected as `window.__LUNORA_RUN_AS_IDENTITY__`.
36
- * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts set
37
- * this — forging an identity is a developer-only affordance; a static deploy
38
- * leaves it off so the control never renders.
39
- */
40
+ * Enable the function runner's "Run as identity" tool (execute a function as a
41
+ * chosen user to test auth/RLS). Injected as `window.__LUNORA_RUN_AS_IDENTITY__`.
42
+ * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts set
43
+ * this — forging an identity is a developer-only affordance; a static deploy
44
+ * leaves it off so the control never renders.
45
+ */
40
46
  readonly runAsIdentity?: boolean;
41
47
  /**
42
- * Enable the visual schema editor (add table / column / index, written back to
43
- * `lunora/schema.ts` + codegen). Injected as `window.__LUNORA_SCHEMA_EDITABLE__`.
44
- * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts
45
- * set this — editing source + running codegen needs the project's filesystem and
46
- * toolchain, so a static deploy leaves it off and the diagram stays read-only.
47
- */
48
+ * Enable the visual schema editor (add table / column / index, written back to
49
+ * `lunora/schema.ts` + codegen). Injected as `window.__LUNORA_SCHEMA_EDITABLE__`.
50
+ * Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts
51
+ * set this — editing source + running codegen needs the project's filesystem and
52
+ * toolchain, so a static deploy leaves it off and the diagram stays read-only.
53
+ */
48
54
  readonly schemaEditable?: boolean;
49
55
  /** URL the studio bundle is served from (absolute, host-relative). */
50
56
  readonly scriptSrc: string;
@@ -61,30 +67,62 @@ interface StudioAssets {
61
67
  readonly styles: Buffer;
62
68
  }
63
69
  /**
64
- * Read the prebuilt static studio files shipped by `@lunora/studio`
65
- * (`dist/standalone/studio.js` + `dist/styles.css`). Returns `undefined` —
66
- * with a one-time warning — when the optional package isn't installed or hasn't
67
- * been built, so a missing studio never breaks the dev server.
68
- *
69
- * `resolveFrom` controls where `@lunora/studio` is resolved from. It defaults
70
- * to this module's own location, which is correct once this code is inlined into
71
- * a host package (`@lunora/vite` / `@lunora/cli`) that has `@lunora/studio`
72
- * installed — node walks up from the host's `dist` to find it.
73
- */
70
+ * Read the prebuilt static studio files shipped by `@lunora/studio`
71
+ * (`dist/standalone/studio.js` + `dist/styles.css`). Returns `undefined` —
72
+ * with a one-time warning — when the optional package isn't installed or hasn't
73
+ * been built, so a missing studio never breaks the dev server.
74
+ *
75
+ * `resolveFrom` controls where `@lunora/studio` is resolved from. It defaults
76
+ * to this module's own location, which is correct once this code is inlined into
77
+ * a host package (`@lunora/vite` / `@lunora/cli`) that has `@lunora/studio`
78
+ * installed — node walks up from the host's `dist` to find it.
79
+ */
74
80
  declare const loadStudioAssets: (logger?: WarnLogger, resolveFrom?: string) => StudioAssets | undefined;
75
81
  /**
76
- * A freshness stamp for the studio assets: the latest mtime (ms) of the resolved
77
- * `studio.js` / `styles.css`, or `undefined` when they can't be resolved. Hosts
78
- * cache {@link loadStudioAssets} for the dev session but compare this stamp per
79
- * request, so a `@lunora/studio` rebuild mid-session is picked up live — no dev
80
- * server restart needed.
81
- */
82
+ * A freshness stamp for the studio assets: the latest mtime (ms) of the resolved
83
+ * `studio.js` / `styles.css`, or `undefined` when they can't be resolved. Hosts
84
+ * cache {@link loadStudioAssets} for the dev session but compare this stamp per
85
+ * request, so a `@lunora/studio` rebuild mid-session is picked up live — no dev
86
+ * server restart needed.
87
+ */
82
88
  declare const studioAssetsStamp: (resolveFrom?: string) => number | undefined;
83
89
  /**
84
- * Endpoint path both dev hosts mount the handler at. A sibling of the schema
85
- * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
86
- * CLI's `/_lunora/*` worker proxy (single underscore).
87
- */
90
+ * Absolute path of the built standalone directory — `@lunora/studio`'s
91
+ * `dist/standalone`, where the `studio.js` entry and its code-split `chunk-*.js`
92
+ * siblings live — or `undefined` when the studio isn't installed/built. The
93
+ * standalone bundle is emitted with esbuild `splitting`, so the hosts must serve
94
+ * the whole directory (not two fixed paths); this resolves its root.
95
+ */
96
+ declare const resolveStandaloneDirectory: (resolveFrom?: string) => string | undefined;
97
+ /**
98
+ * Read a single file from the standalone directory by its plain filename (the
99
+ * `studio.js` entry, a `chunk-*.js`, or a `.map`). **Path-traversal-safe** via
100
+ * {@link resolveContainedFile}: only a lone filename resolving to a direct child
101
+ * of the standalone directory is served — any separator, `..`, NUL, or absolute
102
+ * path is rejected — so a request like `../../etc/passwd` can never escape it.
103
+ * Returns the bytes, or `undefined` when the studio isn't built or the name
104
+ * doesn't resolve to a file inside the directory (the host answers that 404).
105
+ */
106
+ declare const readStandaloneAsset: (fileName: string, resolveFrom?: string) => Buffer | undefined;
107
+ /**
108
+ * True when `pathname` addresses a standalone JS module — the `studio.js` entry
109
+ * or one of its code-split `chunk-*.js` siblings (and their `.map`s). Shared by
110
+ * the CLI and Vite hosts so both route the same request shapes to the directory
111
+ * server; the stylesheet is matched separately at each host's own style path.
112
+ */
113
+ declare const isStandaloneModulePath: (pathname: string) => boolean;
114
+ /**
115
+ * Content-Type for a served standalone asset, by extension: `.css` → CSS,
116
+ * `.map` → JSON (a source map), everything else (the `.js` entry + chunks) →
117
+ * JavaScript. Shared by the CLI and Vite hosts so the MIME decision lives in one
118
+ * place.
119
+ */
120
+ declare const assetContentType: (fileName: string) => string;
121
+ /**
122
+ * Endpoint path both dev hosts mount the handler at. A sibling of the schema
123
+ * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
124
+ * CLI's `/_lunora/*` worker proxy (single underscore).
125
+ */
88
126
  declare const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
89
127
  /** A `wireRls` request additionally carries the procedure's source-file path. */
90
128
  interface WirePolicyEdit extends WireRlsEdit {
@@ -110,26 +148,26 @@ interface PolicyScaffoldResponse {
110
148
  readonly status: number;
111
149
  }
112
150
  /**
113
- * Handle a policy-scaffold request. Pure over its inputs apart from the file
114
- * I/O + codegen it performs on an applied edit; safe to unit-test against a
115
- * temp project directory.
116
- */
151
+ * Handle a policy-scaffold request. Pure over its inputs apart from the file
152
+ * I/O + codegen it performs on an applied edit; safe to unit-test against a
153
+ * temp project directory.
154
+ */
117
155
  declare const handlePolicyScaffoldRequest: (request: PolicyScaffoldRequest) => PolicyScaffoldResponse;
118
156
  /**
119
- * Render the single-page document that boots the studio. Emitted verbatim —
120
- * never through a bundler/transform — so the studio stays a static tool,
121
- * decoupled from the host project's build. A small inline script publishes the
122
- * per-server config on `globalThis` before the bundle loads: the mount basepath
123
- * (so the router stays under its mount), the admin token when present (so the
124
- * studio auto-authenticates instead of prompting), and an editable flag when the
125
- * host is a loopback dev server (so the data browser allows edits).
126
- */
157
+ * Render the single-page document that boots the studio. Emitted verbatim —
158
+ * never through a bundler/transform — so the studio stays a static tool,
159
+ * decoupled from the host project's build. A small inline script publishes the
160
+ * per-server config on `globalThis` before the bundle loads: the mount basepath
161
+ * (so the router stays under its mount), the admin token when present (so the
162
+ * studio auto-authenticates instead of prompting), and an editable flag when the
163
+ * host is a loopback dev server (so the data browser allows edits).
164
+ */
127
165
  declare const renderStudioHtml: (config: StudioHtmlConfig) => string;
128
166
  /**
129
- * Endpoint path both dev hosts mount the handler at. Distinct from the CLI's
130
- * `/_lunora/*` worker proxy (single underscore), so a schema edit is never
131
- * forwarded to the worker.
132
- */
167
+ * Endpoint path both dev hosts mount the handler at. Distinct from the CLI's
168
+ * `/_lunora/*` worker proxy (single underscore), so a schema edit is never
169
+ * forwarded to the worker.
170
+ */
133
171
  declare const SCHEMA_EDIT_ENDPOINT = "/__lunora/schema-edit";
134
172
  /** A request adapted from the host transport. */
135
173
  interface SchemaEditRequest {
@@ -148,28 +186,28 @@ interface SchemaEditResponse {
148
186
  readonly status: number;
149
187
  }
150
188
  /**
151
- * Handle a schema-edit request. Pure over its inputs apart from the file I/O +
152
- * codegen it performs on a `POST` additive edit; safe to unit-test against a
153
- * temp project directory.
154
- */
189
+ * Handle a schema-edit request. Pure over its inputs apart from the file I/O +
190
+ * codegen it performs on a `POST` additive edit; safe to unit-test against a
191
+ * temp project directory.
192
+ */
155
193
  declare const handleSchemaEditRequest: (request: SchemaEditRequest) => SchemaEditResponse;
156
194
  /**
157
- * Endpoint path both dev hosts mount the handler at. A sibling of the schema
158
- * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
159
- * CLI's `/_lunora/*` worker proxy (single underscore).
160
- */
195
+ * Endpoint path both dev hosts mount the handler at. A sibling of the schema
196
+ * editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
197
+ * CLI's `/_lunora/*` worker proxy (single underscore).
198
+ */
161
199
  declare const SEED_ENDPOINT = "/__lunora/seed";
162
200
  /** Body the host transport adapts from a `POST` — one generate-rows request. */
163
201
  interface SeedRequestBody {
164
202
  /** How many rows to generate (clamped to `[1, MAX_SEED_ROWS]`). */
165
203
  readonly count?: number;
166
204
  /**
167
- * Ids of rows that already exist in the live DB, keyed by referenced table.
168
- * Foreign keys resolve against these, and every referenced parent table
169
- * present here is treated as covered — so the generator links to existing
170
- * rows instead of fabricating new parent rows. The studio samples these from
171
- * the target table's FK columns before calling.
172
- */
205
+ * Ids of rows that already exist in the live DB, keyed by referenced table.
206
+ * Foreign keys resolve against these, and every referenced parent table
207
+ * present here is treated as covered — so the generator links to existing
208
+ * rows instead of fabricating new parent rows. The studio samples these from
209
+ * the target table's FK columns before calling.
210
+ */
173
211
  readonly existingIds?: Readonly<Record<string, ReadonlyArray<string>>>;
174
212
  /** Deterministic mapping selector — same value yields identical rows. */
175
213
  readonly seed?: number;
@@ -193,10 +231,10 @@ interface SeedResponse {
193
231
  readonly status: number;
194
232
  }
195
233
  /**
196
- * Handle a generate-rows request: statically lift the schema, generate `count`
197
- * rows for `table` (linking foreign keys to the supplied existing ids rather
198
- * than fabricating parents), and return them JSON-safe for the client to insert.
199
- */
234
+ * Handle a generate-rows request: statically lift the schema, generate `count`
235
+ * rows for `table` (linking foreign keys to the supplied existing ids rather
236
+ * than fabricating parents), and return them JSON-safe for the client to insert.
237
+ */
200
238
  declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
201
239
  /** A request adapted from a host transport, passed to a local-dev handler. */
202
240
  interface LocalEndpointRequest {
@@ -217,11 +255,15 @@ interface LocalEndpointResponse {
217
255
  /** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
218
256
  type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse;
219
257
  /**
220
- * Adapt a `node:http` request/response pair to a transport-agnostic local-dev
221
- * handler. `GET` carries no body (the schema editor uses it to read the parsed
222
- * schema); every other method has its body read + JSON-parsed first. The
223
- * handler's `{ status, body }` is serialised back as JSON. A malformed body is a
224
- * `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
225
- */
226
- declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string) => void;
227
- export { 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, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, loadStudioAssets, parseDevVariable, renderStudioHtml, resolveAdminToken, serveJsonHandler, studioAssetsStamp };
258
+ * Adapt a `node:http` request/response pair to a transport-agnostic local-dev
259
+ * handler. `GET` carries no body (the schema editor uses it to read the parsed
260
+ * schema); every other method has its body read + JSON-parsed first. The
261
+ * handler's `{ status, body }` is serialised back as JSON. A malformed body is a
262
+ * `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
263
+ *
264
+ * `schemaDirectory` (when the host configures a custom `schemaDir`) is forwarded
265
+ * to the handler so the schema/seed/policy endpoints target the right directory
266
+ * instead of always defaulting to `"lunora"`.
267
+ */
268
+ declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string, schemaDirectory?: string) => void;
269
+ export { 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, assetContentType, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, isStandaloneModulePath, loadStudioAssets, parseDevVariable, readStandaloneAsset, renderStudioHtml, resolveAdminToken, resolveStandaloneDirectory, serveJsonHandler, studioAssetsStamp };
@@ -1,7 +1,7 @@
1
- export { parseDevVariable, resolveAdminToken } from '../packem_shared/parseDevVariable-CJiq2IwE.mjs';
2
- export { default as loadStudioAssets, studioAssetsStamp } from '../packem_shared/loadStudioAssets-Csk5RS4E.mjs';
3
- export { POLICY_SCAFFOLD_ENDPOINT, handlePolicyScaffoldRequest } from '../packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs';
1
+ export { parseDevVariable, resolveAdminToken } from '../packem_shared/parseDevVariable-B0FEvfHC.mjs';
2
+ export { assetContentType, isStandaloneModulePath, loadStudioAssets, readStandaloneAsset, resolveStandaloneDirectory, studioAssetsStamp } from '../packem_shared/assetContentType-ByZjeV3D.mjs';
3
+ export { POLICY_SCAFFOLD_ENDPOINT, handlePolicyScaffoldRequest } from '../packem_shared/POLICY_SCAFFOLD_ENDPOINT-CvTZpaZF.mjs';
4
4
  export { default as renderStudioHtml } from '../packem_shared/renderStudioHtml-449Ysn75.mjs';
5
- export { SCHEMA_EDIT_ENDPOINT, handleSchemaEditRequest } from '../packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs';
6
- export { SEED_ENDPOINT, handleSeedRequest } from '../packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs';
7
- export { serveJsonHandler } from '../packem_shared/serveJsonHandler-B4OLTGLS.mjs';
5
+ export { SCHEMA_EDIT_ENDPOINT, handleSchemaEditRequest } from '../packem_shared/SCHEMA_EDIT_ENDPOINT-Bt2SNkpV.mjs';
6
+ export { SEED_ENDPOINT, handleSeedRequest } from '../packem_shared/SEED_ENDPOINT-7izz_Jao.mjs';
7
+ export { serveJsonHandler } from '../packem_shared/serveJsonHandler-Cl2Wqkv8.mjs';