@lunora/config 0.0.0 → 1.0.0-alpha.1

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 +105 -0
  2. package/README.md +115 -9
  3. package/__assets__/package-og.svg +14 -0
  4. package/dist/index.d.mts +1075 -0
  5. package/dist/index.d.ts +1075 -0
  6. package/dist/index.mjs +20 -0
  7. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +40 -0
  8. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +37 -0
  9. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +52 -0
  10. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-CySy5vR_.mjs +62 -0
  11. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-Dd1suoit.mjs +476 -0
  12. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +228 -0
  13. package/dist/packem_shared/buildPackageSecretsBlock-S74dgmwy.mjs +187 -0
  14. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +99 -0
  15. package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +100 -0
  16. package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +41 -0
  17. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +19 -0
  18. package/dist/packem_shared/discoverSchemaInfo-DWtypqpP.mjs +25 -0
  19. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +19 -0
  20. package/dist/packem_shared/findWranglerFile-DwSuC-Kn.mjs +25 -0
  21. package/dist/packem_shared/formatLunoraEvent-D2fDeGB6.mjs +86 -0
  22. package/dist/packem_shared/handlePolicyScaffoldRequest-CiC2IGKx.mjs +103 -0
  23. package/dist/packem_shared/handleSchemaEditRequest-Df-Wrix-.mjs +99 -0
  24. package/dist/packem_shared/handleSeedRequest-DVCjaGO-.mjs +61 -0
  25. package/dist/packem_shared/inferLunoraBindings-0W3eRdIP.mjs +302 -0
  26. package/dist/packem_shared/injectRemoteFlags-C-WZAKLY.mjs +105 -0
  27. package/dist/packem_shared/interpretRemote-CtcIcB5-.mjs +34 -0
  28. package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +30 -0
  29. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +107 -0
  30. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +74 -0
  31. package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +74 -0
  32. package/dist/packem_shared/reconcileWranglerBindings-ByJk3yLU.mjs +277 -0
  33. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +37 -0
  34. package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +86 -0
  35. package/dist/packem_shared/studioAssetsStamp-Csk5RS4E.mjs +28 -0
  36. package/dist/studio-host/index.d.mts +227 -0
  37. package/dist/studio-host/index.d.ts +227 -0
  38. package/dist/studio-host/index.mjs +7 -0
  39. package/package.json +57 -17
@@ -0,0 +1,227 @@
1
+ import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-DCmwn7zQ.mjs";
2
+ import { IncomingMessage, ServerResponse } from 'node:http';
3
+ /** Parse a single `KEY=value` (optionally quoted) out of a `.dev.vars` body. */
4
+ declare const parseDevVariable: (contents: string, key: string) => string | undefined;
5
+ /**
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
+ declare const resolveAdminToken: (root: string) => string | undefined;
13
+ /** Config injected into the studio document before the bundle loads. */
14
+ interface StudioHtmlConfig {
15
+ /** Admin token sent with admin requests; omitted (and not injected) when unset. */
16
+ readonly adminToken?: string;
17
+ /** Router basepath the studio mounts under (e.g. `/__lunora`, or `/` for a root server). */
18
+ readonly basePath: string;
19
+ /**
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
+ */
25
+ readonly dataEditable?: boolean;
26
+ /**
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
+ */
32
+ readonly rulesInstalled?: boolean;
33
+ /**
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
+ readonly runAsIdentity?: boolean;
41
+ /**
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
+ readonly schemaEditable?: boolean;
49
+ /** URL the studio bundle is served from (absolute, host-relative). */
50
+ readonly scriptSrc: string;
51
+ /** URL the compiled stylesheet is served from (absolute, host-relative). */
52
+ readonly styleHref: string;
53
+ }
54
+ /** Minimal logger surface both Vite's `Logger` and the CLI's logger satisfy. */
55
+ interface WarnLogger {
56
+ warnOnce?: (message: string) => void;
57
+ }
58
+ /** Prebuilt studio asset bytes, resolved from `@lunora/studio`'s dist. */
59
+ interface StudioAssets {
60
+ readonly script: Buffer;
61
+ readonly styles: Buffer;
62
+ }
63
+ /**
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
+ */
74
+ declare const loadStudioAssets: (logger?: WarnLogger, resolveFrom?: string) => StudioAssets | undefined;
75
+ /**
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
+ declare const studioAssetsStamp: (resolveFrom?: string) => number | undefined;
83
+ /**
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
+ */
88
+ declare const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
89
+ /** A `wireRls` request additionally carries the procedure's source-file path. */
90
+ interface WirePolicyEdit extends WireRlsEdit {
91
+ /** Lunora-relative module path of the procedure file (no extension), e.g. `messages/list`. */
92
+ readonly filePath: string;
93
+ }
94
+ /** Body the host transport adapts from a `POST` — one scaffolder request. */
95
+ type PolicyScaffoldBody = DestructivePolicyEdit | ScaffoldPolicyEdit | WirePolicyEdit;
96
+ /** A request adapted from the host transport. */
97
+ interface PolicyScaffoldRequest {
98
+ /** Parsed JSON body of the `POST`. */
99
+ readonly body?: unknown;
100
+ /** HTTP method — only `POST` is handled. */
101
+ readonly method: string;
102
+ /** Project root containing the `lunora/` directory. */
103
+ readonly projectRoot: string;
104
+ /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
105
+ readonly schemaDirectory?: string;
106
+ }
107
+ /** A response the host transport serialises back as JSON with `status`. */
108
+ interface PolicyScaffoldResponse {
109
+ readonly body: unknown;
110
+ readonly status: number;
111
+ }
112
+ /**
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
+ */
117
+ declare const handlePolicyScaffoldRequest: (request: PolicyScaffoldRequest) => PolicyScaffoldResponse;
118
+ /**
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
+ */
127
+ declare const renderStudioHtml: (config: StudioHtmlConfig) => string;
128
+ /**
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
+ */
133
+ declare const SCHEMA_EDIT_ENDPOINT = "/__lunora/schema-edit";
134
+ /** A request adapted from the host transport. */
135
+ interface SchemaEditRequest {
136
+ /** Parsed JSON body for a `POST`; ignored for `GET`. */
137
+ readonly body?: unknown;
138
+ /** HTTP method (`GET` / `POST`). */
139
+ readonly method: string;
140
+ /** Project root containing the `lunora/` directory. */
141
+ readonly projectRoot: string;
142
+ /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
143
+ readonly schemaDirectory?: string;
144
+ }
145
+ /** A response the host transport serialises back as JSON with `status`. */
146
+ interface SchemaEditResponse {
147
+ readonly body: unknown;
148
+ readonly status: number;
149
+ }
150
+ /**
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
+ */
155
+ declare const handleSchemaEditRequest: (request: SchemaEditRequest) => SchemaEditResponse;
156
+ /**
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
+ */
161
+ declare const SEED_ENDPOINT = "/__lunora/seed";
162
+ /** Body the host transport adapts from a `POST` — one generate-rows request. */
163
+ interface SeedRequestBody {
164
+ /** How many rows to generate (clamped to `[1, MAX_SEED_ROWS]`). */
165
+ readonly count?: number;
166
+ /**
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
+ */
173
+ readonly existingIds?: Readonly<Record<string, ReadonlyArray<string>>>;
174
+ /** Deterministic mapping selector — same value yields identical rows. */
175
+ readonly seed?: number;
176
+ /** The table to generate rows for. */
177
+ readonly table?: string;
178
+ }
179
+ /** A request adapted from the host transport. */
180
+ interface SeedRequest {
181
+ /** Parsed JSON body of the `POST`. */
182
+ readonly body?: unknown;
183
+ /** HTTP method — only `POST` is handled. */
184
+ readonly method: string;
185
+ /** Project root containing the `lunora/` directory. */
186
+ readonly projectRoot: string;
187
+ /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
188
+ readonly schemaDirectory?: string;
189
+ }
190
+ /** A response the host transport serialises back as JSON with `status`. */
191
+ interface SeedResponse {
192
+ readonly body: unknown;
193
+ readonly status: number;
194
+ }
195
+ /**
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
+ */
200
+ declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
201
+ /** A request adapted from a host transport, passed to a local-dev handler. */
202
+ interface LocalEndpointRequest {
203
+ /** Parsed JSON body of the request (`undefined` for `GET` / an empty body). */
204
+ readonly body?: unknown;
205
+ /** HTTP method. */
206
+ readonly method: string;
207
+ /** Project root containing the `lunora/` directory. */
208
+ readonly projectRoot: string;
209
+ /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
210
+ readonly schemaDirectory?: string;
211
+ }
212
+ /** A response a local-dev handler returns, serialised back as JSON with its status. */
213
+ interface LocalEndpointResponse {
214
+ readonly body: unknown;
215
+ readonly status: number;
216
+ }
217
+ /** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
218
+ type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse;
219
+ /**
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 };
@@ -0,0 +1,227 @@
1
+ import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-DCmwn7zQ.js";
2
+ import { IncomingMessage, ServerResponse } from 'node:http';
3
+ /** Parse a single `KEY=value` (optionally quoted) out of a `.dev.vars` body. */
4
+ declare const parseDevVariable: (contents: string, key: string) => string | undefined;
5
+ /**
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
+ declare const resolveAdminToken: (root: string) => string | undefined;
13
+ /** Config injected into the studio document before the bundle loads. */
14
+ interface StudioHtmlConfig {
15
+ /** Admin token sent with admin requests; omitted (and not injected) when unset. */
16
+ readonly adminToken?: string;
17
+ /** Router basepath the studio mounts under (e.g. `/__lunora`, or `/` for a root server). */
18
+ readonly basePath: string;
19
+ /**
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
+ */
25
+ readonly dataEditable?: boolean;
26
+ /**
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
+ */
32
+ readonly rulesInstalled?: boolean;
33
+ /**
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
+ readonly runAsIdentity?: boolean;
41
+ /**
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
+ readonly schemaEditable?: boolean;
49
+ /** URL the studio bundle is served from (absolute, host-relative). */
50
+ readonly scriptSrc: string;
51
+ /** URL the compiled stylesheet is served from (absolute, host-relative). */
52
+ readonly styleHref: string;
53
+ }
54
+ /** Minimal logger surface both Vite's `Logger` and the CLI's logger satisfy. */
55
+ interface WarnLogger {
56
+ warnOnce?: (message: string) => void;
57
+ }
58
+ /** Prebuilt studio asset bytes, resolved from `@lunora/studio`'s dist. */
59
+ interface StudioAssets {
60
+ readonly script: Buffer;
61
+ readonly styles: Buffer;
62
+ }
63
+ /**
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
+ */
74
+ declare const loadStudioAssets: (logger?: WarnLogger, resolveFrom?: string) => StudioAssets | undefined;
75
+ /**
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
+ declare const studioAssetsStamp: (resolveFrom?: string) => number | undefined;
83
+ /**
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
+ */
88
+ declare const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
89
+ /** A `wireRls` request additionally carries the procedure's source-file path. */
90
+ interface WirePolicyEdit extends WireRlsEdit {
91
+ /** Lunora-relative module path of the procedure file (no extension), e.g. `messages/list`. */
92
+ readonly filePath: string;
93
+ }
94
+ /** Body the host transport adapts from a `POST` — one scaffolder request. */
95
+ type PolicyScaffoldBody = DestructivePolicyEdit | ScaffoldPolicyEdit | WirePolicyEdit;
96
+ /** A request adapted from the host transport. */
97
+ interface PolicyScaffoldRequest {
98
+ /** Parsed JSON body of the `POST`. */
99
+ readonly body?: unknown;
100
+ /** HTTP method — only `POST` is handled. */
101
+ readonly method: string;
102
+ /** Project root containing the `lunora/` directory. */
103
+ readonly projectRoot: string;
104
+ /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
105
+ readonly schemaDirectory?: string;
106
+ }
107
+ /** A response the host transport serialises back as JSON with `status`. */
108
+ interface PolicyScaffoldResponse {
109
+ readonly body: unknown;
110
+ readonly status: number;
111
+ }
112
+ /**
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
+ */
117
+ declare const handlePolicyScaffoldRequest: (request: PolicyScaffoldRequest) => PolicyScaffoldResponse;
118
+ /**
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
+ */
127
+ declare const renderStudioHtml: (config: StudioHtmlConfig) => string;
128
+ /**
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
+ */
133
+ declare const SCHEMA_EDIT_ENDPOINT = "/__lunora/schema-edit";
134
+ /** A request adapted from the host transport. */
135
+ interface SchemaEditRequest {
136
+ /** Parsed JSON body for a `POST`; ignored for `GET`. */
137
+ readonly body?: unknown;
138
+ /** HTTP method (`GET` / `POST`). */
139
+ readonly method: string;
140
+ /** Project root containing the `lunora/` directory. */
141
+ readonly projectRoot: string;
142
+ /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
143
+ readonly schemaDirectory?: string;
144
+ }
145
+ /** A response the host transport serialises back as JSON with `status`. */
146
+ interface SchemaEditResponse {
147
+ readonly body: unknown;
148
+ readonly status: number;
149
+ }
150
+ /**
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
+ */
155
+ declare const handleSchemaEditRequest: (request: SchemaEditRequest) => SchemaEditResponse;
156
+ /**
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
+ */
161
+ declare const SEED_ENDPOINT = "/__lunora/seed";
162
+ /** Body the host transport adapts from a `POST` — one generate-rows request. */
163
+ interface SeedRequestBody {
164
+ /** How many rows to generate (clamped to `[1, MAX_SEED_ROWS]`). */
165
+ readonly count?: number;
166
+ /**
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
+ */
173
+ readonly existingIds?: Readonly<Record<string, ReadonlyArray<string>>>;
174
+ /** Deterministic mapping selector — same value yields identical rows. */
175
+ readonly seed?: number;
176
+ /** The table to generate rows for. */
177
+ readonly table?: string;
178
+ }
179
+ /** A request adapted from the host transport. */
180
+ interface SeedRequest {
181
+ /** Parsed JSON body of the `POST`. */
182
+ readonly body?: unknown;
183
+ /** HTTP method — only `POST` is handled. */
184
+ readonly method: string;
185
+ /** Project root containing the `lunora/` directory. */
186
+ readonly projectRoot: string;
187
+ /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
188
+ readonly schemaDirectory?: string;
189
+ }
190
+ /** A response the host transport serialises back as JSON with `status`. */
191
+ interface SeedResponse {
192
+ readonly body: unknown;
193
+ readonly status: number;
194
+ }
195
+ /**
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
+ */
200
+ declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
201
+ /** A request adapted from a host transport, passed to a local-dev handler. */
202
+ interface LocalEndpointRequest {
203
+ /** Parsed JSON body of the request (`undefined` for `GET` / an empty body). */
204
+ readonly body?: unknown;
205
+ /** HTTP method. */
206
+ readonly method: string;
207
+ /** Project root containing the `lunora/` directory. */
208
+ readonly projectRoot: string;
209
+ /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
210
+ readonly schemaDirectory?: string;
211
+ }
212
+ /** A response a local-dev handler returns, serialised back as JSON with its status. */
213
+ interface LocalEndpointResponse {
214
+ readonly body: unknown;
215
+ readonly status: number;
216
+ }
217
+ /** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
218
+ type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse;
219
+ /**
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 };
@@ -0,0 +1,7 @@
1
+ export { parseDevVariable, resolveAdminToken } from '../packem_shared/parseDevVariable-CJiq2IwE.mjs';
2
+ export { default as loadStudioAssets, studioAssetsStamp } from '../packem_shared/studioAssetsStamp-Csk5RS4E.mjs';
3
+ export { POLICY_SCAFFOLD_ENDPOINT, handlePolicyScaffoldRequest } from '../packem_shared/handlePolicyScaffoldRequest-CiC2IGKx.mjs';
4
+ export { default as renderStudioHtml } from '../packem_shared/renderStudioHtml-449Ysn75.mjs';
5
+ export { SCHEMA_EDIT_ENDPOINT, handleSchemaEditRequest } from '../packem_shared/handleSchemaEditRequest-Df-Wrix-.mjs';
6
+ export { SEED_ENDPOINT, handleSeedRequest } from '../packem_shared/handleSeedRequest-DVCjaGO-.mjs';
7
+ export { serveJsonHandler } from '../packem_shared/serveJsonHandler-B4OLTGLS.mjs';
package/package.json CHANGED
@@ -1,31 +1,71 @@
1
1
  {
2
2
  "name": "@lunora/config",
3
- "version": "0.0.0",
3
+ "version": "1.0.0-alpha.1",
4
4
  "description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
5
- "license": "FSL-1.1-Apache-2.0",
5
+ "keywords": [
6
+ "bindings",
7
+ "cloudflare",
8
+ "config",
9
+ "dev-vars",
10
+ "durable-objects",
11
+ "lunora",
12
+ "workers",
13
+ "wrangler"
14
+ ],
6
15
  "homepage": "https://lunora.sh",
16
+ "bugs": "https://github.com/anolilab/lunora/issues",
17
+ "license": "FSL-1.1-Apache-2.0",
18
+ "author": {
19
+ "name": "Daniel Bannert",
20
+ "email": "d.bannert@anolilab.de"
21
+ },
7
22
  "repository": {
8
23
  "type": "git",
9
24
  "url": "git+https://github.com/anolilab/lunora.git",
10
25
  "directory": "packages/config"
11
26
  },
12
- "bugs": {
13
- "url": "https://github.com/anolilab/lunora/issues"
14
- },
15
- "keywords": [
16
- "lunora",
17
- "cloudflare",
18
- "workers",
19
- "durable-objects",
20
- "wrangler",
21
- "config",
22
- "dev-vars",
23
- "bindings"
27
+ "files": [
28
+ "dist",
29
+ "__assets__",
30
+ "README.md",
31
+ "LICENSE.md"
24
32
  ],
33
+ "type": "module",
34
+ "sideEffects": false,
35
+ "main": "./dist/index.mjs",
36
+ "module": "./dist/index.mjs",
37
+ "types": "./dist/index.d.ts",
38
+ "exports": {
39
+ ".": {
40
+ "types": "./dist/index.d.ts",
41
+ "import": "./dist/index.mjs"
42
+ },
43
+ "./studio-host": {
44
+ "types": "./dist/studio-host/index.d.ts",
45
+ "import": "./dist/studio-host/index.mjs"
46
+ },
47
+ "./package.json": "./package.json"
48
+ },
25
49
  "publishConfig": {
26
50
  "access": "public"
27
51
  },
28
- "files": [
29
- "README.md"
30
- ]
52
+ "dependencies": {
53
+ "@lunora/codegen": "1.0.0-alpha.1",
54
+ "@lunora/container": "1.0.0-alpha.1",
55
+ "@lunora/seed": "1.0.0-alpha.1",
56
+ "es-module-lexer": "^2.1.0",
57
+ "jsonc-parser": "^3.3.1",
58
+ "ts-morph": "^28.0.0"
59
+ },
60
+ "peerDependencies": {
61
+ "@lunora/studio": "1.0.0-alpha.1"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "@lunora/studio": {
65
+ "optional": true
66
+ }
67
+ },
68
+ "engines": {
69
+ "node": "^22.15.0 || >=24.11.0"
70
+ }
31
71
  }