@lunora/config 1.0.0-alpha.70 → 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.
- package/dist/index.d.mts +596 -628
- package/dist/index.d.ts +596 -628
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{LUNORA_EVENT_SOURCE-D2fDeGB6.mjs → LUNORA_EVENT_SOURCE-M1KM9_pR.mjs} +28 -2
- package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.mts → policy-scaffold.d-CFd2FlqG.d.mts} +22 -22
- package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.ts → policy-scaffold.d-CFd2FlqG.d.ts} +22 -22
- package/dist/studio-host/index.d.mts +123 -123
- package/dist/studio-host/index.d.ts +123 -123
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ export { DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_ST
|
|
|
8
8
|
export { DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, parseDevVariableEntries } from './packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs';
|
|
9
9
|
export { inferLunoraBindings, packageNamesFromBindings } from './packem_shared/inferLunoraBindings-BcvvtpSG.mjs';
|
|
10
10
|
export { LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, readLinkedProject, writeLinkedProject } from './packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs';
|
|
11
|
-
export { LUNORA_EVENT_SOURCE, formatLunoraEvent } from './packem_shared/LUNORA_EVENT_SOURCE-
|
|
11
|
+
export { LUNORA_EVENT_SOURCE, formatLunoraEvent } from './packem_shared/LUNORA_EVENT_SOURCE-M1KM9_pR.mjs';
|
|
12
12
|
export { default as LunoraReporter } from './packem_shared/LunoraReporter-Ci-bDCK9.mjs';
|
|
13
13
|
export { PACKAGE_SECRETS_REGISTRY, secretsForPackages } from './packem_shared/PACKAGE_SECRETS_REGISTRY-BeRSvrl5.mjs';
|
|
14
14
|
export { LUNORA_CONFIG_FILE, interpretRemote, readProjectRemotePreference } from './packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs';
|
package/dist/packem_shared/{LUNORA_EVENT_SOURCE-D2fDeGB6.mjs → LUNORA_EVENT_SOURCE-M1KM9_pR.mjs}
RENAMED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
const stringifyFieldValue = (value) => {
|
|
2
|
+
if (typeof value === "string") {
|
|
3
|
+
return value;
|
|
4
|
+
}
|
|
5
|
+
try {
|
|
6
|
+
return JSON.stringify(value) ?? String(value);
|
|
7
|
+
} catch {
|
|
8
|
+
return String(value);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const formatLogFields = (fields) => {
|
|
12
|
+
if (typeof fields !== "object" || fields === null || Array.isArray(fields)) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
return Object.entries(fields).map(([key, value]) => `${key}=${stringifyFieldValue(value)}`).join(" ");
|
|
16
|
+
};
|
|
17
|
+
|
|
1
18
|
const LUNORA_EVENT_SOURCE = "lunora";
|
|
2
19
|
const ROOT_SHARD_NAME = "__root__";
|
|
3
20
|
const asString = (value) => typeof value === "string" ? value : "";
|
|
4
21
|
const asStringList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
5
22
|
const formatDuration = (value) => typeof value === "number" && Number.isFinite(value) ? `${String(Math.round(value))}ms` : "?ms";
|
|
6
23
|
const toLineLevel = (rawLevel) => {
|
|
7
|
-
if (rawLevel === "error") {
|
|
24
|
+
if (rawLevel === "error" || rawLevel === "fatal") {
|
|
8
25
|
return "error";
|
|
9
26
|
}
|
|
10
27
|
if (rawLevel === "warn") {
|
|
@@ -72,7 +89,16 @@ const formatLunoraEvent = (line) => {
|
|
|
72
89
|
}
|
|
73
90
|
const functionPath = asString(event.function) || "<unknown>";
|
|
74
91
|
if (event.type === "log") {
|
|
75
|
-
|
|
92
|
+
const parts = [`${labelFor(functionPath, event)} ${asString(event.message)}`.trimEnd()];
|
|
93
|
+
const fields = formatLogFields(event.fields);
|
|
94
|
+
if (fields !== "") {
|
|
95
|
+
parts.push(fields);
|
|
96
|
+
}
|
|
97
|
+
const traceId = asString(event.traceId);
|
|
98
|
+
if (traceId !== "") {
|
|
99
|
+
parts.push(`trace=${traceId.slice(0, 8)}`);
|
|
100
|
+
}
|
|
101
|
+
return { kind: "log", level: toLineLevel(asString(event.level)), text: parts.join(" ") };
|
|
76
102
|
}
|
|
77
103
|
if (event.type === "request") {
|
|
78
104
|
return formatRequest(event, functionPath);
|
package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.mts → policy-scaffold.d-CFd2FlqG.d.mts}
RENAMED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
interface ScaffoldPolicyEdit {
|
|
3
3
|
readonly kind: "scaffoldPolicy";
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
* Base name for the generated file and its exported policy-set identifier,
|
|
6
|
+
* e.g. `invoices` → `lunora/invoices.policies.ts` exporting `invoicesPolicies`.
|
|
7
|
+
*/
|
|
8
8
|
readonly name: string;
|
|
9
9
|
/** Logical table the scaffolded policy guards (used in the stub body). */
|
|
10
10
|
readonly table: string;
|
|
@@ -20,10 +20,10 @@ interface WireRlsEdit {
|
|
|
20
20
|
/** Additive scaffolder edits — the only requests the scaffolder applies. */
|
|
21
21
|
type AdditivePolicyEdit = ScaffoldPolicyEdit | WireRlsEdit;
|
|
22
22
|
/**
|
|
23
|
-
* Destructive scaffolder requests — never applied. Rewriting an existing `when`
|
|
24
|
-
* body changes evaluation semantics silently, so it is refused (STOP condition
|
|
25
|
-
* in plan 025); carried as data so the editor can describe the request.
|
|
26
|
-
*/
|
|
23
|
+
* Destructive scaffolder requests — never applied. Rewriting an existing `when`
|
|
24
|
+
* body changes evaluation semantics silently, so it is refused (STOP condition
|
|
25
|
+
* in plan 025); carried as data so the editor can describe the request.
|
|
26
|
+
*/
|
|
27
27
|
interface DestructivePolicyEdit {
|
|
28
28
|
readonly exportName?: string;
|
|
29
29
|
readonly kind: "rewritePolicyWhen";
|
|
@@ -32,10 +32,10 @@ interface DestructivePolicyEdit {
|
|
|
32
32
|
/** Any request the scaffolder can receive. */
|
|
33
33
|
type PolicyEdit = AdditivePolicyEdit | DestructivePolicyEdit;
|
|
34
34
|
/**
|
|
35
|
-
* Classify a scaffolder request. Additive requests ({@link AdditivePolicyEdit})
|
|
36
|
-
* apply directly; everything else (rewriting an existing predicate) changes
|
|
37
|
-
* evaluation semantics and is destructive.
|
|
38
|
-
*/
|
|
35
|
+
* Classify a scaffolder request. Additive requests ({@link AdditivePolicyEdit})
|
|
36
|
+
* apply directly; everything else (rewriting an existing predicate) changes
|
|
37
|
+
* evaluation semantics and is destructive.
|
|
38
|
+
*/
|
|
39
39
|
declare const classifyPolicyEdit: (edit: PolicyEdit) => "additive" | "destructive";
|
|
40
40
|
/** Failure reasons a scaffolder request can report. */
|
|
41
41
|
type PolicyScaffoldFailureReason = "already-wired" | "destructive" | "invalid-identifier" | "unknown-procedure" | "unsupported-procedure-shape";
|
|
@@ -57,18 +57,18 @@ type WireResult = {
|
|
|
57
57
|
text: string;
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
|
-
* Generate the source of a new policy/role/permission stub file. The `when`
|
|
61
|
-
* predicate is a `() => false` skeleton with a TODO — the scaffolder never
|
|
62
|
-
* authors real logic, the developer fills it in. Pure (no I/O); the handler
|
|
63
|
-
* writes the returned source and refuses to overwrite an existing file.
|
|
64
|
-
*/
|
|
60
|
+
* Generate the source of a new policy/role/permission stub file. The `when`
|
|
61
|
+
* predicate is a `() => false` skeleton with a TODO — the scaffolder never
|
|
62
|
+
* authors real logic, the developer fills it in. Pure (no I/O); the handler
|
|
63
|
+
* writes the returned source and refuses to overwrite an existing file.
|
|
64
|
+
*/
|
|
65
65
|
declare const scaffoldPolicyFile: (edit: ScaffoldPolicyEdit) => ScaffoldFileResult;
|
|
66
66
|
/**
|
|
67
|
-
* Append `.use(rls(<policies>))` to a procedure's builder chain, preserving the
|
|
68
|
-
* terminal `.query(handler)` (and its handler body) byte-for-byte. Only the
|
|
69
|
-
* **builder** form can be wired; the bare-factory form (`query({ handler })`)
|
|
70
|
-
* has no chain and is reported `unsupported-procedure-shape` so the editor can
|
|
71
|
-
* tell the developer to convert it rather than silently rewriting their code.
|
|
72
|
-
*/
|
|
67
|
+
* Append `.use(rls(<policies>))` to a procedure's builder chain, preserving the
|
|
68
|
+
* terminal `.query(handler)` (and its handler body) byte-for-byte. Only the
|
|
69
|
+
* **builder** form can be wired; the bare-factory form (`query({ handler })`)
|
|
70
|
+
* has no chain and is reported `unsupported-procedure-shape` so the editor can
|
|
71
|
+
* tell the developer to convert it rather than silently rewriting their code.
|
|
72
|
+
*/
|
|
73
73
|
declare const wireRlsIntoProcedure: (source: string, edit: WireRlsEdit) => WireResult;
|
|
74
74
|
export { AdditivePolicyEdit as A, DestructivePolicyEdit as D, PolicyEdit as P, ScaffoldPolicyEdit as S, WireRlsEdit as W, PolicyScaffoldFailureReason as a, ScaffoldFileResult as b, WireResult as c, classifyPolicyEdit as d, scaffoldPolicyFile as s, wireRlsIntoProcedure as w };
|
package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.ts → policy-scaffold.d-CFd2FlqG.d.ts}
RENAMED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
interface ScaffoldPolicyEdit {
|
|
3
3
|
readonly kind: "scaffoldPolicy";
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
* Base name for the generated file and its exported policy-set identifier,
|
|
6
|
+
* e.g. `invoices` → `lunora/invoices.policies.ts` exporting `invoicesPolicies`.
|
|
7
|
+
*/
|
|
8
8
|
readonly name: string;
|
|
9
9
|
/** Logical table the scaffolded policy guards (used in the stub body). */
|
|
10
10
|
readonly table: string;
|
|
@@ -20,10 +20,10 @@ interface WireRlsEdit {
|
|
|
20
20
|
/** Additive scaffolder edits — the only requests the scaffolder applies. */
|
|
21
21
|
type AdditivePolicyEdit = ScaffoldPolicyEdit | WireRlsEdit;
|
|
22
22
|
/**
|
|
23
|
-
* Destructive scaffolder requests — never applied. Rewriting an existing `when`
|
|
24
|
-
* body changes evaluation semantics silently, so it is refused (STOP condition
|
|
25
|
-
* in plan 025); carried as data so the editor can describe the request.
|
|
26
|
-
*/
|
|
23
|
+
* Destructive scaffolder requests — never applied. Rewriting an existing `when`
|
|
24
|
+
* body changes evaluation semantics silently, so it is refused (STOP condition
|
|
25
|
+
* in plan 025); carried as data so the editor can describe the request.
|
|
26
|
+
*/
|
|
27
27
|
interface DestructivePolicyEdit {
|
|
28
28
|
readonly exportName?: string;
|
|
29
29
|
readonly kind: "rewritePolicyWhen";
|
|
@@ -32,10 +32,10 @@ interface DestructivePolicyEdit {
|
|
|
32
32
|
/** Any request the scaffolder can receive. */
|
|
33
33
|
type PolicyEdit = AdditivePolicyEdit | DestructivePolicyEdit;
|
|
34
34
|
/**
|
|
35
|
-
* Classify a scaffolder request. Additive requests ({@link AdditivePolicyEdit})
|
|
36
|
-
* apply directly; everything else (rewriting an existing predicate) changes
|
|
37
|
-
* evaluation semantics and is destructive.
|
|
38
|
-
*/
|
|
35
|
+
* Classify a scaffolder request. Additive requests ({@link AdditivePolicyEdit})
|
|
36
|
+
* apply directly; everything else (rewriting an existing predicate) changes
|
|
37
|
+
* evaluation semantics and is destructive.
|
|
38
|
+
*/
|
|
39
39
|
declare const classifyPolicyEdit: (edit: PolicyEdit) => "additive" | "destructive";
|
|
40
40
|
/** Failure reasons a scaffolder request can report. */
|
|
41
41
|
type PolicyScaffoldFailureReason = "already-wired" | "destructive" | "invalid-identifier" | "unknown-procedure" | "unsupported-procedure-shape";
|
|
@@ -57,18 +57,18 @@ type WireResult = {
|
|
|
57
57
|
text: string;
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
|
-
* Generate the source of a new policy/role/permission stub file. The `when`
|
|
61
|
-
* predicate is a `() => false` skeleton with a TODO — the scaffolder never
|
|
62
|
-
* authors real logic, the developer fills it in. Pure (no I/O); the handler
|
|
63
|
-
* writes the returned source and refuses to overwrite an existing file.
|
|
64
|
-
*/
|
|
60
|
+
* Generate the source of a new policy/role/permission stub file. The `when`
|
|
61
|
+
* predicate is a `() => false` skeleton with a TODO — the scaffolder never
|
|
62
|
+
* authors real logic, the developer fills it in. Pure (no I/O); the handler
|
|
63
|
+
* writes the returned source and refuses to overwrite an existing file.
|
|
64
|
+
*/
|
|
65
65
|
declare const scaffoldPolicyFile: (edit: ScaffoldPolicyEdit) => ScaffoldFileResult;
|
|
66
66
|
/**
|
|
67
|
-
* Append `.use(rls(<policies>))` to a procedure's builder chain, preserving the
|
|
68
|
-
* terminal `.query(handler)` (and its handler body) byte-for-byte. Only the
|
|
69
|
-
* **builder** form can be wired; the bare-factory form (`query({ handler })`)
|
|
70
|
-
* has no chain and is reported `unsupported-procedure-shape` so the editor can
|
|
71
|
-
* tell the developer to convert it rather than silently rewriting their code.
|
|
72
|
-
*/
|
|
67
|
+
* Append `.use(rls(<policies>))` to a procedure's builder chain, preserving the
|
|
68
|
+
* terminal `.query(handler)` (and its handler body) byte-for-byte. Only the
|
|
69
|
+
* **builder** form can be wired; the bare-factory form (`query({ handler })`)
|
|
70
|
+
* has no chain and is reported `unsupported-procedure-shape` so the editor can
|
|
71
|
+
* tell the developer to convert it rather than silently rewriting their code.
|
|
72
|
+
*/
|
|
73
73
|
declare const wireRlsIntoProcedure: (source: string, edit: WireRlsEdit) => WireResult;
|
|
74
74
|
export { AdditivePolicyEdit as A, DestructivePolicyEdit as D, PolicyEdit as P, ScaffoldPolicyEdit as S, WireRlsEdit as W, PolicyScaffoldFailureReason as a, ScaffoldFileResult as b, WireResult as c, classifyPolicyEdit as d, scaffoldPolicyFile as s, wireRlsIntoProcedure as w };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-
|
|
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
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
|
+
* 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
|
+
*/
|
|
10
10
|
declare const parseDevVariable: (contents: string, key: string) => string | undefined;
|
|
11
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
|
+
* 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
|
+
*/
|
|
18
18
|
declare const resolveAdminToken: (root: string) => string | undefined;
|
|
19
19
|
/** Config injected into the studio document before the bundle loads. */
|
|
20
20
|
interface StudioHtmlConfig {
|
|
@@ -23,34 +23,34 @@ interface StudioHtmlConfig {
|
|
|
23
23
|
/** Router basepath the studio mounts under (e.g. `/__lunora`, or `/` for a root server). */
|
|
24
24
|
readonly basePath: string;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
*/
|
|
31
31
|
readonly dataEditable?: boolean;
|
|
32
32
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
+
*/
|
|
38
38
|
readonly rulesInstalled?: boolean;
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
+
*/
|
|
46
46
|
readonly runAsIdentity?: boolean;
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
+
*/
|
|
54
54
|
readonly schemaEditable?: boolean;
|
|
55
55
|
/** URL the studio bundle is served from (absolute, host-relative). */
|
|
56
56
|
readonly scriptSrc: string;
|
|
@@ -67,62 +67,62 @@ interface StudioAssets {
|
|
|
67
67
|
readonly styles: Buffer;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
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
|
-
*/
|
|
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
|
+
*/
|
|
80
80
|
declare const loadStudioAssets: (logger?: WarnLogger, resolveFrom?: string) => StudioAssets | undefined;
|
|
81
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
|
+
* 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
|
+
*/
|
|
88
88
|
declare const studioAssetsStamp: (resolveFrom?: string) => number | undefined;
|
|
89
89
|
/**
|
|
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
|
-
*/
|
|
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
96
|
declare const resolveStandaloneDirectory: (resolveFrom?: string) => string | undefined;
|
|
97
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
|
-
*/
|
|
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
106
|
declare const readStandaloneAsset: (fileName: string, resolveFrom?: string) => Buffer | undefined;
|
|
107
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
|
-
*/
|
|
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
113
|
declare const isStandaloneModulePath: (pathname: string) => boolean;
|
|
114
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
|
-
*/
|
|
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
120
|
declare const assetContentType: (fileName: string) => string;
|
|
121
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
|
-
*/
|
|
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
|
+
*/
|
|
126
126
|
declare const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
|
|
127
127
|
/** A `wireRls` request additionally carries the procedure's source-file path. */
|
|
128
128
|
interface WirePolicyEdit extends WireRlsEdit {
|
|
@@ -148,26 +148,26 @@ interface PolicyScaffoldResponse {
|
|
|
148
148
|
readonly status: number;
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
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
|
-
*/
|
|
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
|
+
*/
|
|
155
155
|
declare const handlePolicyScaffoldRequest: (request: PolicyScaffoldRequest) => PolicyScaffoldResponse;
|
|
156
156
|
/**
|
|
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
|
-
*/
|
|
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
|
+
*/
|
|
165
165
|
declare const renderStudioHtml: (config: StudioHtmlConfig) => string;
|
|
166
166
|
/**
|
|
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
|
-
*/
|
|
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
|
+
*/
|
|
171
171
|
declare const SCHEMA_EDIT_ENDPOINT = "/__lunora/schema-edit";
|
|
172
172
|
/** A request adapted from the host transport. */
|
|
173
173
|
interface SchemaEditRequest {
|
|
@@ -186,28 +186,28 @@ interface SchemaEditResponse {
|
|
|
186
186
|
readonly status: number;
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
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
|
-
*/
|
|
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
|
+
*/
|
|
193
193
|
declare const handleSchemaEditRequest: (request: SchemaEditRequest) => SchemaEditResponse;
|
|
194
194
|
/**
|
|
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
|
-
*/
|
|
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
|
+
*/
|
|
199
199
|
declare const SEED_ENDPOINT = "/__lunora/seed";
|
|
200
200
|
/** Body the host transport adapts from a `POST` — one generate-rows request. */
|
|
201
201
|
interface SeedRequestBody {
|
|
202
202
|
/** How many rows to generate (clamped to `[1, MAX_SEED_ROWS]`). */
|
|
203
203
|
readonly count?: number;
|
|
204
204
|
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
+
*/
|
|
211
211
|
readonly existingIds?: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
212
212
|
/** Deterministic mapping selector — same value yields identical rows. */
|
|
213
213
|
readonly seed?: number;
|
|
@@ -231,10 +231,10 @@ interface SeedResponse {
|
|
|
231
231
|
readonly status: number;
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
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
|
-
*/
|
|
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
|
+
*/
|
|
238
238
|
declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
|
|
239
239
|
/** A request adapted from a host transport, passed to a local-dev handler. */
|
|
240
240
|
interface LocalEndpointRequest {
|
|
@@ -255,15 +255,15 @@ interface LocalEndpointResponse {
|
|
|
255
255
|
/** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
|
|
256
256
|
type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse;
|
|
257
257
|
/**
|
|
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
|
-
*/
|
|
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
268
|
declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string, schemaDirectory?: string) => void;
|
|
269
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 };
|