@lunora/config 1.0.0-alpha.15 → 1.0.0-alpha.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +6 -0
- package/README.md +2 -2
- package/dist/cloudflare/index.d.mts +846 -0
- package/dist/cloudflare/index.d.ts +846 -0
- package/dist/cloudflare/index.mjs +1 -0
- package/dist/index.d.mts +705 -859
- package/dist/index.d.ts +705 -859
- package/dist/index.mjs +1 -22
- package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
- package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
- package/dist/packem_shared/AGENT_RULES_DIR-3-Sx1gHU.mjs +1 -0
- package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-Cd00jVOf.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_DRIVER-6bjm6hSn.mjs +1 -0
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-RDWcFKBe.mjs +1 -0
- package/dist/packem_shared/DEV_DAEMON_ENV-e1mJUd1-.mjs +4 -0
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-DxtfY0DW.mjs +6 -0
- package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
- package/dist/packem_shared/LUNORA_CONFIG_FILE-CBV3C1Hl.mjs +1 -0
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-DYdcDU9G.mjs +1 -0
- package/dist/packem_shared/LUNORA_IGNORED_PATHS-BGbVUqw_.mjs +19 -0
- package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs +1 -0
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-C1gb9ykA.mjs +1 -0
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-DKlqkz1w.mjs +1 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-l78q5ZIV.mjs +1 -0
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-CknH7oga.mjs +1 -0
- package/dist/packem_shared/SEED_ENDPOINT-DVzCYp6l.mjs +1 -0
- package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
- package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
- package/dist/packem_shared/applyAdditiveEdit-DPhNZsf2.mjs +6 -0
- package/dist/packem_shared/applyStudioAssetCache-DHQEJuuv.mjs +1 -0
- package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
- package/dist/packem_shared/buildPackageSecretsBlock-DX6SFs-J.mjs +18 -0
- package/dist/packem_shared/classifyPolicyEdit-BfSiVpv-.mjs +24 -0
- package/dist/packem_shared/cloudflare-driver-CvMyH1Ih.mjs +1 -0
- package/dist/packem_shared/collectExportGaps-B5eIg8p8.mjs +1 -0
- package/dist/packem_shared/collectWranglerSecretVariables-Df_H6ytT.mjs +1 -0
- package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
- package/dist/packem_shared/detectFramework-DOn4PtpP.mjs +1 -0
- package/dist/packem_shared/discover-info-Vj9d4qYt.mjs +1 -0
- package/dist/packem_shared/discoverAgentInfo-CTdCSfYM.mjs +1 -0
- package/dist/packem_shared/discoverContainerInfo-EhZtEBQs.mjs +1 -0
- package/dist/packem_shared/discoverSchemaInfo-Bg2CUZXG.mjs +1 -0
- package/dist/packem_shared/discoverWorkflowInfo-BsPvlo6O.mjs +1 -0
- package/dist/packem_shared/inferLunoraBindings-CEE39hXz.mjs +1 -0
- package/dist/packem_shared/jsonc-edit-BZgQIdAH.mjs +1 -0
- package/dist/packem_shared/parseDevVariable-C0QlCXhO.mjs +1 -0
- package/dist/packem_shared/parseSchema-B4nFDPzZ.mjs +1 -0
- package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.mts → policy-scaffold.d-fV3db0S_.d.mts} +23 -23
- package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.ts → policy-scaffold.d-fV3db0S_.d.ts} +23 -23
- package/dist/packem_shared/reconcileWranglerCompatibilityDate-7OO_xaKR.mjs +1 -0
- package/dist/packem_shared/reconcileWranglerCrons-COMb6ICf.mjs +1 -0
- package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
- package/dist/packem_shared/schema-info.d-DS0bUsWE.d.mts +375 -0
- package/dist/packem_shared/schema-info.d-DS0bUsWE.d.ts +375 -0
- package/dist/packem_shared/serveJsonHandler-CB85A2S9.mjs +1 -0
- package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
- package/dist/packem_shared/wranglerToAlchemy-CX9nCwtu.mjs +6 -0
- package/dist/packem_shared/write-atomic-ooiPzStx.mjs +1 -0
- package/dist/studio-host/index.d.mts +220 -92
- package/dist/studio-host/index.d.ts +220 -92
- package/dist/studio-host/index.mjs +1 -7
- package/package.json +15 -8
- package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
- package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
- package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
- package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
- package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-DRSNSOOp.mjs +0 -476
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
- package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
- package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
- package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
- package/dist/packem_shared/buildPackageSecretsBlock-DWDKHViT.mjs +0 -243
- package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
- package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
- package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
- package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
- package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
- package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
- package/dist/packem_shared/inferLunoraBindings-DIku9mTN.mjs +0 -302
- package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
- package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
- package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
- package/dist/packem_shared/reconcileWranglerBindings-DTHmqTbL.mjs +0 -277
- package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
- package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
|
@@ -1,15 +1,45 @@
|
|
|
1
|
-
import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-DCmwn7zQ.mjs";
|
|
2
1
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
|
|
2
|
+
import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-fV3db0S_.mjs";
|
|
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;
|
|
19
|
+
/**
|
|
20
|
+
* Set the asset cache headers, answering `304` when the request already holds
|
|
21
|
+
* this version. Returns true when the response is finished, false when the
|
|
22
|
+
* caller should go on to write the body.
|
|
23
|
+
*
|
|
24
|
+
* `no-cache` forces revalidation on every load: an unchanged asset costs a
|
|
25
|
+
* cheap `304`, a rebuild (new stamp, new chunk names) is always fetched fresh.
|
|
26
|
+
* The ETag is keyed on the requested file (not just its kind) so each chunk
|
|
27
|
+
* revalidates independently, while the rebuild stamp busts them all at once. No
|
|
28
|
+
* stamp (the studio isn't resolvable) means no ETag and no `304` — `no-cache`
|
|
29
|
+
* alone.
|
|
30
|
+
*
|
|
31
|
+
* `If-None-Match` is compared byte-for-byte, per RFC 7232: entity tags are
|
|
32
|
+
* case-sensitive, and these are keyed on file names that can differ only in
|
|
33
|
+
* case (base64url chunk names), so a case-insensitive compare would cross-match
|
|
34
|
+
* two distinct chunks into a wrong `304`.
|
|
35
|
+
*/
|
|
36
|
+
declare const applyStudioAssetCache: (request: IncomingMessage, response: ServerResponse, fileName: string, stamp: number | undefined) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Send the studio's SPA document. It embeds the admin token, so it is
|
|
39
|
+
* `no-store` — not merely revalidated — and carries no ETag: a cached `304` for
|
|
40
|
+
* a token-bearing document would be its own bug.
|
|
41
|
+
*/
|
|
42
|
+
declare const sendStudioDocument: (response: ServerResponse, body: Buffer | string) => void;
|
|
13
43
|
/** Config injected into the studio document before the bundle loads. */
|
|
14
44
|
interface StudioHtmlConfig {
|
|
15
45
|
/** Admin token sent with admin requests; omitted (and not injected) when unset. */
|
|
@@ -17,34 +47,34 @@ interface StudioHtmlConfig {
|
|
|
17
47
|
/** Router basepath the studio mounts under (e.g. `/__lunora`, or `/` for a root server). */
|
|
18
48
|
readonly basePath: string;
|
|
19
49
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
50
|
+
* Make the data browser editable (insert/edit/delete rows). Injected as
|
|
51
|
+
* `window.__LUNORA_DATA_EDITABLE__` for the bundle to read. The loopback-only
|
|
52
|
+
* dev hosts (the Vite `/__lunora` route, the CLI studio server) set this so a
|
|
53
|
+
* developer can edit; a static deploy leaves it off (read-only) by default.
|
|
54
|
+
*/
|
|
25
55
|
readonly dataEditable?: boolean;
|
|
26
56
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
57
|
+
* Whether the project's Lunora agent skills ("rules") are installed. Injected
|
|
58
|
+
* as `window.__LUNORA_RULES_INSTALLED__` **only when `false`**, so the studio
|
|
59
|
+
* shows a "rules not installed" banner on the loopback dev hosts (which detect
|
|
60
|
+
* it) and stays quiet on a static deploy (which leaves it unset).
|
|
61
|
+
*/
|
|
32
62
|
readonly rulesInstalled?: boolean;
|
|
33
63
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
64
|
+
* Enable the function runner's "Run as identity" tool (execute a function as a
|
|
65
|
+
* chosen user to test auth/RLS). Injected as `window.__LUNORA_RUN_AS_IDENTITY__`.
|
|
66
|
+
* Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts set
|
|
67
|
+
* this — forging an identity is a developer-only affordance; a static deploy
|
|
68
|
+
* leaves it off so the control never renders.
|
|
69
|
+
*/
|
|
40
70
|
readonly runAsIdentity?: boolean;
|
|
41
71
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
72
|
+
* Enable the visual schema editor (add table / column / index, written back to
|
|
73
|
+
* `lunora/schema.ts` + codegen). Injected as `window.__LUNORA_SCHEMA_EDITABLE__`.
|
|
74
|
+
* Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts
|
|
75
|
+
* set this — editing source + running codegen needs the project's filesystem and
|
|
76
|
+
* toolchain, so a static deploy leaves it off and the diagram stays read-only.
|
|
77
|
+
*/
|
|
48
78
|
readonly schemaEditable?: boolean;
|
|
49
79
|
/** URL the studio bundle is served from (absolute, host-relative). */
|
|
50
80
|
readonly scriptSrc: string;
|
|
@@ -61,30 +91,62 @@ interface StudioAssets {
|
|
|
61
91
|
readonly styles: Buffer;
|
|
62
92
|
}
|
|
63
93
|
/**
|
|
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
|
-
*/
|
|
94
|
+
* Read the prebuilt static studio files shipped by `@lunora/studio`
|
|
95
|
+
* (`dist/standalone/studio.js` + `dist/styles.css`). Returns `undefined` —
|
|
96
|
+
* with a one-time warning — when the optional package isn't installed or hasn't
|
|
97
|
+
* been built, so a missing studio never breaks the dev server.
|
|
98
|
+
*
|
|
99
|
+
* `resolveFrom` controls where `@lunora/studio` is resolved from. It defaults
|
|
100
|
+
* to this module's own location, which is correct once this code is inlined into
|
|
101
|
+
* a host package (`@lunora/vite` / `@lunora/cli`) that has `@lunora/studio`
|
|
102
|
+
* installed — node walks up from the host's `dist` to find it.
|
|
103
|
+
*/
|
|
74
104
|
declare const loadStudioAssets: (logger?: WarnLogger, resolveFrom?: string) => StudioAssets | undefined;
|
|
75
105
|
/**
|
|
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
|
-
*/
|
|
106
|
+
* A freshness stamp for the studio assets: the latest mtime (ms) of the resolved
|
|
107
|
+
* `studio.js` / `styles.css`, or `undefined` when they can't be resolved. Hosts
|
|
108
|
+
* cache {@link loadStudioAssets} for the dev session but compare this stamp per
|
|
109
|
+
* request, so a `@lunora/studio` rebuild mid-session is picked up live — no dev
|
|
110
|
+
* server restart needed.
|
|
111
|
+
*/
|
|
82
112
|
declare const studioAssetsStamp: (resolveFrom?: string) => number | undefined;
|
|
83
113
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
|
|
114
|
+
* Absolute path of the built standalone directory — `@lunora/studio`'s
|
|
115
|
+
* `dist/standalone`, where the `studio.js` entry and its code-split `chunk-*.js`
|
|
116
|
+
* siblings live — or `undefined` when the studio isn't installed/built. The
|
|
117
|
+
* standalone bundle is emitted with esbuild `splitting`, so the hosts must serve
|
|
118
|
+
* the whole directory (not two fixed paths); this resolves its root.
|
|
119
|
+
*/
|
|
120
|
+
declare const resolveStandaloneDirectory: (resolveFrom?: string) => string | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Read a single file from the standalone directory by its plain filename (the
|
|
123
|
+
* `studio.js` entry, a `chunk-*.js`, or a `.map`). **Path-traversal-safe** via
|
|
124
|
+
* {@link resolveContainedFile}: only a lone filename resolving to a direct child
|
|
125
|
+
* of the standalone directory is served — any separator, `..`, NUL, or absolute
|
|
126
|
+
* path is rejected — so a request like `../../etc/passwd` can never escape it.
|
|
127
|
+
* Returns the bytes, or `undefined` when the studio isn't built or the name
|
|
128
|
+
* doesn't resolve to a file inside the directory (the host answers that 404).
|
|
129
|
+
*/
|
|
130
|
+
declare const readStandaloneAsset: (fileName: string, resolveFrom?: string) => Buffer | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* True when `pathname` addresses a standalone JS module — the `studio.js` entry
|
|
133
|
+
* or one of its code-split `chunk-*.js` siblings (and their `.map`s). Shared by
|
|
134
|
+
* the CLI and Vite hosts so both route the same request shapes to the directory
|
|
135
|
+
* server; the stylesheet is matched separately at each host's own style path.
|
|
136
|
+
*/
|
|
137
|
+
declare const isStandaloneModulePath: (pathname: string) => boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Content-Type for a served standalone asset, by extension: `.css` → CSS,
|
|
140
|
+
* `.map` → JSON (a source map), everything else (the `.js` entry + chunks) →
|
|
141
|
+
* JavaScript. Shared by the CLI and Vite hosts so the MIME decision lives in one
|
|
142
|
+
* place.
|
|
143
|
+
*/
|
|
144
|
+
declare const assetContentType: (fileName: string) => string;
|
|
145
|
+
/**
|
|
146
|
+
* Endpoint path both dev hosts mount the handler at. A sibling of the schema
|
|
147
|
+
* editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
|
|
148
|
+
* CLI's `/_lunora/*` worker proxy (single underscore).
|
|
149
|
+
*/
|
|
88
150
|
declare const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
|
|
89
151
|
/** A `wireRls` request additionally carries the procedure's source-file path. */
|
|
90
152
|
interface WirePolicyEdit extends WireRlsEdit {
|
|
@@ -110,26 +172,26 @@ interface PolicyScaffoldResponse {
|
|
|
110
172
|
readonly status: number;
|
|
111
173
|
}
|
|
112
174
|
/**
|
|
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
|
-
*/
|
|
175
|
+
* Handle a policy-scaffold request. Pure over its inputs apart from the file
|
|
176
|
+
* I/O + codegen it performs on an applied edit; safe to unit-test against a
|
|
177
|
+
* temp project directory.
|
|
178
|
+
*/
|
|
117
179
|
declare const handlePolicyScaffoldRequest: (request: PolicyScaffoldRequest) => PolicyScaffoldResponse;
|
|
118
180
|
/**
|
|
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
|
-
*/
|
|
181
|
+
* Render the single-page document that boots the studio. Emitted verbatim —
|
|
182
|
+
* never through a bundler/transform — so the studio stays a static tool,
|
|
183
|
+
* decoupled from the host project's build. A small inline script publishes the
|
|
184
|
+
* per-server config on `globalThis` before the bundle loads: the mount basepath
|
|
185
|
+
* (so the router stays under its mount), the admin token when present (so the
|
|
186
|
+
* studio auto-authenticates instead of prompting), and an editable flag when the
|
|
187
|
+
* host is a loopback dev server (so the data browser allows edits).
|
|
188
|
+
*/
|
|
127
189
|
declare const renderStudioHtml: (config: StudioHtmlConfig) => string;
|
|
128
190
|
/**
|
|
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
|
-
*/
|
|
191
|
+
* Endpoint path both dev hosts mount the handler at. Distinct from the CLI's
|
|
192
|
+
* `/_lunora/*` worker proxy (single underscore), so a schema edit is never
|
|
193
|
+
* forwarded to the worker.
|
|
194
|
+
*/
|
|
133
195
|
declare const SCHEMA_EDIT_ENDPOINT = "/__lunora/schema-edit";
|
|
134
196
|
/** A request adapted from the host transport. */
|
|
135
197
|
interface SchemaEditRequest {
|
|
@@ -148,28 +210,28 @@ interface SchemaEditResponse {
|
|
|
148
210
|
readonly status: number;
|
|
149
211
|
}
|
|
150
212
|
/**
|
|
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
|
-
*/
|
|
213
|
+
* Handle a schema-edit request. Pure over its inputs apart from the file I/O +
|
|
214
|
+
* codegen it performs on a `POST` additive edit; safe to unit-test against a
|
|
215
|
+
* temp project directory.
|
|
216
|
+
*/
|
|
155
217
|
declare const handleSchemaEditRequest: (request: SchemaEditRequest) => SchemaEditResponse;
|
|
156
218
|
/**
|
|
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
|
-
*/
|
|
219
|
+
* Endpoint path both dev hosts mount the handler at. A sibling of the schema
|
|
220
|
+
* editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
|
|
221
|
+
* CLI's `/_lunora/*` worker proxy (single underscore).
|
|
222
|
+
*/
|
|
161
223
|
declare const SEED_ENDPOINT = "/__lunora/seed";
|
|
162
224
|
/** Body the host transport adapts from a `POST` — one generate-rows request. */
|
|
163
225
|
interface SeedRequestBody {
|
|
164
226
|
/** How many rows to generate (clamped to `[1, MAX_SEED_ROWS]`). */
|
|
165
227
|
readonly count?: number;
|
|
166
228
|
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
229
|
+
* Ids of rows that already exist in the live DB, keyed by referenced table.
|
|
230
|
+
* Foreign keys resolve against these, and every referenced parent table
|
|
231
|
+
* present here is treated as covered — so the generator links to existing
|
|
232
|
+
* rows instead of fabricating new parent rows. The studio samples these from
|
|
233
|
+
* the target table's FK columns before calling.
|
|
234
|
+
*/
|
|
173
235
|
readonly existingIds?: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
174
236
|
/** Deterministic mapping selector — same value yields identical rows. */
|
|
175
237
|
readonly seed?: number;
|
|
@@ -193,10 +255,10 @@ interface SeedResponse {
|
|
|
193
255
|
readonly status: number;
|
|
194
256
|
}
|
|
195
257
|
/**
|
|
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
|
-
*/
|
|
258
|
+
* Handle a generate-rows request: statically lift the schema, generate `count`
|
|
259
|
+
* rows for `table` (linking foreign keys to the supplied existing ids rather
|
|
260
|
+
* than fabricating parents), and return them JSON-safe for the client to insert.
|
|
261
|
+
*/
|
|
200
262
|
declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
|
|
201
263
|
/** A request adapted from a host transport, passed to a local-dev handler. */
|
|
202
264
|
interface LocalEndpointRequest {
|
|
@@ -217,11 +279,77 @@ interface LocalEndpointResponse {
|
|
|
217
279
|
/** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
|
|
218
280
|
type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse;
|
|
219
281
|
/**
|
|
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
|
-
|
|
227
|
-
|
|
282
|
+
* Adapt a `node:http` request/response pair to a transport-agnostic local-dev
|
|
283
|
+
* handler. `GET` carries no body (the schema editor uses it to read the parsed
|
|
284
|
+
* schema); every other method has its body read + JSON-parsed first. The
|
|
285
|
+
* handler's `{ status, body }` is serialised back as JSON. A malformed body is a
|
|
286
|
+
* `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
|
|
287
|
+
*
|
|
288
|
+
* `schemaDirectory` (when the host configures a custom `schemaDir`) is forwarded
|
|
289
|
+
* to the handler so the schema/seed/policy endpoints target the right directory
|
|
290
|
+
* instead of always defaulting to `"lunora"`.
|
|
291
|
+
*/
|
|
292
|
+
declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string, schemaDirectory?: string) => void;
|
|
293
|
+
/** A single header value, lower-cased and trimmed; `undefined` when absent or array-valued. */
|
|
294
|
+
declare const headerValue: (raw: string | string[] | undefined) => string | undefined;
|
|
295
|
+
/**
|
|
296
|
+
* True for an IPv4/IPv6 loopback peer (`127.0.0.0/8`, `::1`, and the
|
|
297
|
+
* IPv4-mapped `::ffff:127.x`). A missing address means we cannot read the
|
|
298
|
+
* transport (e.g. a mocked request in tests) — treated as loopback so the
|
|
299
|
+
* config-derived gate stays the source of truth there; on a real Vite/Node
|
|
300
|
+
* server `remoteAddress` is always populated.
|
|
301
|
+
*/
|
|
302
|
+
declare const isLoopbackAddress: (remoteAddress: string | undefined) => boolean;
|
|
303
|
+
/**
|
|
304
|
+
* Explicit opt-out for the forwarding-header refusal below — set to `"1"` to
|
|
305
|
+
* allow a proxied request through once you've confirmed the forwarding is
|
|
306
|
+
* your own trusted dev tunnel (Codespaces, devcontainers, Gitpod, Cloud
|
|
307
|
+
* Workstations, ngrok, a Docker reverse proxy, …), not an attacker's relay.
|
|
308
|
+
* Does not relax the socket-peer or `Host` checks — only this one.
|
|
309
|
+
*/
|
|
310
|
+
declare const ALLOW_FORWARDED_ENV = "LUNORA_STUDIO_ALLOW_FORWARDED";
|
|
311
|
+
/**
|
|
312
|
+
* Per-request transport gate, independent of a host's config-derived bind
|
|
313
|
+
* intent (e.g. Vite's `isNonLoopbackBind`, the CLI's `isLoopback`). In Vite
|
|
314
|
+
* middleware mode the real bind belongs to the embedding server (so the
|
|
315
|
+
* config check measures the wrong thing); here we read the actual socket peer
|
|
316
|
+
* and the `Host` header. Returns a refusal reason, or `undefined` when the
|
|
317
|
+
* connection is loopback-local.
|
|
318
|
+
*
|
|
319
|
+
* `logger`, when supplied, gets a `warnOnce` line for a forwarding-header
|
|
320
|
+
* refusal — naming the specific header seen and the {@link ALLOW_FORWARDED_ENV}
|
|
321
|
+
* escape hatch — so the failure points at its cause in the terminal running
|
|
322
|
+
* the dev server, not just as an opaque 403 in the browser.
|
|
323
|
+
*/
|
|
324
|
+
declare const transportRejectionReason: (request: IncomingMessage, logger?: WarnLogger) => string | undefined;
|
|
325
|
+
export { ALLOW_FORWARDED_ENV, 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,
|
|
326
|
+
/**
|
|
327
|
+
* `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
|
|
328
|
+
* the prebuilt `@lunora/studio` SPA during local dev.
|
|
329
|
+
*
|
|
330
|
+
* Two surfaces inline this code so the dev studio behaves identically
|
|
331
|
+
* regardless of how the project is run:
|
|
332
|
+
* - `@lunora/vite` serves the studio from a Vite middleware at `/__lunora`.
|
|
333
|
+
* - `@lunora/cli` (`lunora dev`) serves it from a standalone Node HTTP server.
|
|
334
|
+
*
|
|
335
|
+
* Each owns its own transport (Connect middleware vs `node:http`) and routing;
|
|
336
|
+
* the genuinely shared parts live here: render the host HTML with per-server
|
|
337
|
+
* config injected, resolve the admin token the same way the worker does, and
|
|
338
|
+
* load the prebuilt asset bytes.
|
|
339
|
+
*/
|
|
340
|
+
parseDevVariable, readStandaloneAsset, renderStudioHtml,
|
|
341
|
+
/**
|
|
342
|
+
* `@lunora/config/studio-host` — internal, build-time-shared helpers for hosting
|
|
343
|
+
* the prebuilt `@lunora/studio` SPA during local dev.
|
|
344
|
+
*
|
|
345
|
+
* Two surfaces inline this code so the dev studio behaves identically
|
|
346
|
+
* regardless of how the project is run:
|
|
347
|
+
* - `@lunora/vite` serves the studio from a Vite middleware at `/__lunora`.
|
|
348
|
+
* - `@lunora/cli` (`lunora dev`) serves it from a standalone Node HTTP server.
|
|
349
|
+
*
|
|
350
|
+
* Each owns its own transport (Connect middleware vs `node:http`) and routing;
|
|
351
|
+
* the genuinely shared parts live here: render the host HTML with per-server
|
|
352
|
+
* config injected, resolve the admin token the same way the worker does, and
|
|
353
|
+
* load the prebuilt asset bytes.
|
|
354
|
+
*/
|
|
355
|
+
resolveAdminToken, resolveStandaloneDirectory, sendStudioDocument, serveJsonHandler, studioAssetsStamp, transportRejectionReason };
|