@lunora/codegen 1.0.0-alpha.77 → 1.0.0-alpha.79
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 +308 -21
- package/dist/index.d.ts +308 -21
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/DEFAULT_TARGET-BYPEwgZu.mjs +1 -0
- package/dist/packem_shared/GENERATED_HEADER-bdSyaxCS.mjs +1 -0
- package/dist/packem_shared/{OPENRPC_VERSION-67sJ7JrS.mjs → OPENRPC_VERSION-BPT6vyLU.mjs} +1 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-FjKlVIV5.mjs +5 -0
- package/dist/packem_shared/{buildOpenApiDocument-DeMEuKaw.mjs → buildOpenApiDocument-D6xm3JqM.mjs} +1 -1
- package/dist/packem_shared/discover-queries-LfER8HbK.mjs +1 -0
- package/dist/packem_shared/discoverQueries-B_2Ciq7P.mjs +1 -0
- package/dist/packem_shared/{emit-sQzv_a8t.mjs → emit-BtiV37rG.mjs} +190 -183
- package/dist/packem_shared/{emitApp-D5X1S54W.mjs → emitApp-Bc3G4eki.mjs} +1 -1
- package/dist/packem_shared/formatAdvisories-BCEfzLT0.mjs +2 -0
- package/package.json +7 -5
- package/dist/packem_shared/GENERATED_HEADER-CQRdzwf9.mjs +0 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-x_pw6Agi.mjs +0 -3
- package/dist/packem_shared/discoverQueries-DENx_T6c.mjs +0 -1
- package/dist/packem_shared/formatAdvisories-DZvv-0MG.mjs +0 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding } from '@lunora/advisor';
|
|
1
|
+
import { AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext, AdvisorProcedureProtection } from '@lunora/advisor';
|
|
2
2
|
export type { Finding } from '@lunora/advisor';
|
|
3
3
|
import { LunoraError } from '@lunora/errors';
|
|
4
4
|
export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, type Solution as LunoraSolution, type SolutionRule as LunoraSolutionRule, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
|
|
5
5
|
import { Node, Project } from 'ts-morph';
|
|
6
|
-
import { StudioFeaturesResult } from '@lunora/
|
|
6
|
+
import { StudioFeaturesResult } from '@lunora/shard-engine';
|
|
7
|
+
import '@lunora/platform';
|
|
7
8
|
import { Schema } from '@lunora/server';
|
|
8
9
|
import { JsonSchema } from '@lunora/values';
|
|
9
10
|
/**
|
|
@@ -803,6 +804,8 @@ interface WorkflowCallIR {
|
|
|
803
804
|
* `query(...)` argument is not a string literal (a dynamic table — not lintable).
|
|
804
805
|
*/
|
|
805
806
|
interface QueryReadIR {
|
|
807
|
+
/** Exported procedure the read sits in, or `""` at module scope. */
|
|
808
|
+
exportName: string;
|
|
806
809
|
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
807
810
|
file: string;
|
|
808
811
|
/** The chain calls `.filter(...)`. */
|
|
@@ -1115,12 +1118,20 @@ interface HttpRouteIR {
|
|
|
1115
1118
|
interface ProcedureMiddlewareIR {
|
|
1116
1119
|
/** `true` when the handler (or a helper inside it) references `ctx.mail` / `ctx.email`. */
|
|
1117
1120
|
callsMail: boolean;
|
|
1121
|
+
/** `true` when the handler emits a structured observability event (`ctx.log` / `ctx.span` / `ctx.trace`). */
|
|
1122
|
+
emitsEvent: boolean;
|
|
1123
|
+
/** `true` when a `// lunora-advisor-exempt` directive sits above the export. */
|
|
1124
|
+
exempt: boolean;
|
|
1125
|
+
/** The `-- reason` from that directive, or `""`. */
|
|
1126
|
+
exemptReason: string;
|
|
1118
1127
|
/** Export binding name of the procedure (e.g. `signUp`). */
|
|
1119
1128
|
exportName: string;
|
|
1120
1129
|
/** `true` when the handler fans work out to a privileged, cost-bearing dispatch surface (scheduler `runAfter`/`runAt`, a queue producer send, or a workflow create). Feeds the privileged-fanout lint. */
|
|
1121
1130
|
fanOut: boolean;
|
|
1122
1131
|
/** Source file relative to `<projectRoot>/lunora/`, without extension. */
|
|
1123
1132
|
file: string;
|
|
1133
|
+
/** `true` when the handler wraps work in `try`/`catch`. */
|
|
1134
|
+
handlesErrors: boolean;
|
|
1124
1135
|
/**
|
|
1125
1136
|
* `true` when the procedure declares an email-shaped argument (`email`,
|
|
1126
1137
|
* `emailAddress`, `userEmail`, …), `false` when it provably declares none,
|
|
@@ -1132,8 +1143,13 @@ interface ProcedureMiddlewareIR {
|
|
|
1132
1143
|
* registration that may well expose one.
|
|
1133
1144
|
*/
|
|
1134
1145
|
hasEmailArg?: boolean;
|
|
1135
|
-
/** Registration kind — only `mutation`/`action` are write-shaped; `query` is read-only. */
|
|
1136
1146
|
kind: "action" | "mutation" | "query";
|
|
1147
|
+
/** `true` when the handler reaches an outbound surface (`ctx.fetch`, mail, queues, storage, sql, ai, …) that can fail. */
|
|
1148
|
+
reachesOutbound: boolean;
|
|
1149
|
+
/** `true` when the handler runs any AI generation, bounded or not. */
|
|
1150
|
+
runsAiGeneration: boolean;
|
|
1151
|
+
/** `true` when the handler throws a bare `new Error(...)` rather than a coded `LunoraError`. */
|
|
1152
|
+
throwsBareError: boolean;
|
|
1137
1153
|
/** `true` when the handler runs an AI generation (`generateText`/`streamText`/`generateObject`/`streamObject`) with no `maxOutputTokens` bound in its config literal. Feeds the `ai_unbounded_generation_public` lint. */
|
|
1138
1154
|
unboundedAiGeneration: boolean;
|
|
1139
1155
|
/** `true` when the chain carries `.use(verifyTurnstile(...))` or a `protectPublic({ captcha })` bundle. */
|
|
@@ -1888,22 +1904,6 @@ interface ProjectIR {
|
|
|
1888
1904
|
migrations: ReadonlyArray<MigrationIR>;
|
|
1889
1905
|
schema: SchemaIR;
|
|
1890
1906
|
}
|
|
1891
|
-
/**
|
|
1892
|
-
* Run the static lints against a discovered {@link SchemaIR} and the reads/writes/calls
|
|
1893
|
-
* found in function bodies: query reads feed `filter_without_index`, insert writes
|
|
1894
|
-
* feed `table_without_insert`, authApi calls feed `auth_api_call_without_headers`,
|
|
1895
|
-
* rls procedure snapshots feed `rls_uncovered_table`, mask procedure
|
|
1896
|
-
* snapshots feed `mask_uncovered_pii_column`, and per-column mask strategies
|
|
1897
|
-
* feed `mask_weak_hash_strategy_on_pii`; declared containers
|
|
1898
|
-
* feed the `container_*` lints; declared workflows (with their durable step labels)
|
|
1899
|
-
* + `ctx.workflows.get(...)` call sites feed the `workflow_unused` /
|
|
1900
|
-
* `workflow_unknown_target` / duplicate-step-name lints; non-deterministic
|
|
1901
|
-
* calls inside query/mutation handlers feed the `nondeterministic_query_mutation` lint
|
|
1902
|
-
* (all default empty for callers that don't analyze functions/containers/workflows).
|
|
1903
|
-
* The IR types are structurally identical to the advisor's evidence types so they
|
|
1904
|
-
* pass straight through without conversion. Returns the findings; surfacing them
|
|
1905
|
-
* (console, error overlay, studio Advisors table) is the caller's choice.
|
|
1906
|
-
*/
|
|
1907
1907
|
/**
|
|
1908
1908
|
* Named inputs for {@link lintSchema}. Every feeder is a discrete key rather than
|
|
1909
1909
|
* a positional argument: the feeder list grows every few releases and many IR
|
|
@@ -1968,6 +1968,38 @@ interface LintSchemaOptions {
|
|
|
1968
1968
|
workflows?: ReadonlyArray<WorkflowIR>;
|
|
1969
1969
|
wranglerVariables?: ReadonlyArray<WranglerVariableIR>;
|
|
1970
1970
|
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Normalize feeder options into the advisor's {@link LintContext} — the input
|
|
1973
|
+
* both `runAdvisor` and `scoreAdvisor` take. Shared by {@link lintSchema} so the
|
|
1974
|
+
* lint run and the scored map always see byte-identical evidence.
|
|
1975
|
+
*
|
|
1976
|
+
* Exported instead of a `mapSchema(options)` convenience that lints *and* scores:
|
|
1977
|
+
* such a wrapper would either re-run every rule or need a `findings` escape hatch
|
|
1978
|
+
* nothing could validate against its `options`, so mismatched findings would
|
|
1979
|
+
* silently produce a wrong map. Two lines at the call site buys that away:
|
|
1980
|
+
*
|
|
1981
|
+
* ```ts
|
|
1982
|
+
* const context = toAdvisorContext(options);
|
|
1983
|
+
* const map = scoreAdvisor(context.procedureProtections ?? [], runAdvisor(context, { source: "static" }));
|
|
1984
|
+
* ```
|
|
1985
|
+
*/
|
|
1986
|
+
declare const toAdvisorContext: (options: LintSchemaOptions) => LintContext;
|
|
1987
|
+
/**
|
|
1988
|
+
* Run the static lints against a discovered {@link SchemaIR} and the reads/writes/calls
|
|
1989
|
+
* found in function bodies: query reads feed `filter_without_index`, insert writes
|
|
1990
|
+
* feed `table_without_insert`, authApi calls feed `auth_api_call_without_headers`,
|
|
1991
|
+
* rls procedure snapshots feed `rls_uncovered_table`, mask procedure
|
|
1992
|
+
* snapshots feed `mask_uncovered_pii_column`, and per-column mask strategies
|
|
1993
|
+
* feed `mask_weak_hash_strategy_on_pii`; declared containers
|
|
1994
|
+
* feed the `container_*` lints; declared workflows (with their durable step labels)
|
|
1995
|
+
* + `ctx.workflows.get(...)` call sites feed the `workflow_unused` /
|
|
1996
|
+
* `workflow_unknown_target` / duplicate-step-name lints; non-deterministic
|
|
1997
|
+
* calls inside query/mutation handlers feed the `nondeterministic_query_mutation` lint
|
|
1998
|
+
* (all default empty for callers that don't analyze functions/containers/workflows).
|
|
1999
|
+
* The IR types are structurally identical to the advisor's evidence types so they
|
|
2000
|
+
* pass straight through without conversion. Returns the findings; surfacing them
|
|
2001
|
+
* (console, error overlay, studio Advisors table) is the caller's choice.
|
|
2002
|
+
*/
|
|
1971
2003
|
declare const lintSchema: (options: LintSchemaOptions) => Finding[];
|
|
1972
2004
|
/**
|
|
1973
2005
|
* Render advisor findings as a single multi-line string for console surfacing:
|
|
@@ -2379,6 +2411,8 @@ declare const emitWorkflows: (workflows: ReadonlyArray<WorkflowIR>) => string;
|
|
|
2379
2411
|
declare const emitAgents: (agents: ReadonlyArray<AgentIR>) => string;
|
|
2380
2412
|
interface EmitShardOptions {
|
|
2381
2413
|
advisories?: ReadonlyArray<Finding>;
|
|
2414
|
+
/** Every declared procedure — the health map's denominator, served via `getAdvisorProcedures`. */
|
|
2415
|
+
advisorProcedures?: ReadonlyArray<AdvisorProcedureProtection>;
|
|
2382
2416
|
/** Agents declared via `defineAgent` exports in `lunora/agents.ts` — wires the typed `ctx.agents` producers. */
|
|
2383
2417
|
agents?: ReadonlyArray<AgentIR>;
|
|
2384
2418
|
containers?: ReadonlyArray<ContainerIR>;
|
|
@@ -2436,7 +2470,7 @@ interface EmitShardOptions {
|
|
|
2436
2470
|
useUmbrella?: boolean;
|
|
2437
2471
|
workflows?: ReadonlyArray<WorkflowIR>;
|
|
2438
2472
|
}
|
|
2439
|
-
declare const emitShard: ({ advisories, agents, containers, env, flagKeys, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasNotify, hasPayments, hasPipelines, hasR2sql, hasX402, maskMetadata, mutators, queues, rlsMetadata, schema, schemaSnapshot, shapes, storageRules, studioFeatures, useUmbrella, workflows }: EmitShardOptions) => string;
|
|
2473
|
+
declare const emitShard: ({ advisories, advisorProcedures, agents, containers, env, flagKeys, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasNotify, hasPayments, hasPipelines, hasR2sql, hasX402, maskMetadata, mutators, queues, rlsMetadata, schema, schemaSnapshot, shapes, storageRules, studioFeatures, useUmbrella, workflows }: EmitShardOptions) => string;
|
|
2440
2474
|
/**
|
|
2441
2475
|
* Emit drizzle `sqliteTable` definitions for the project schema, split into
|
|
2442
2476
|
* `global` (D1-backed) and `shard` (DO-SQLite-backed) buckets. Tables marked
|
|
@@ -2668,6 +2702,231 @@ declare const emitOpenRpc: (input: OpenRpcEmitInput) => string;
|
|
|
2668
2702
|
* the object returned by {@link buildOpenRpcDocument} (reused, never recomputed).
|
|
2669
2703
|
*/
|
|
2670
2704
|
declare const emitOpenRpcModule: (document_: Record<string, unknown>) => string;
|
|
2705
|
+
/**
|
|
2706
|
+
* The canonical capability list. **Order is load-bearing** for the `emit-app.ts`
|
|
2707
|
+
* long-tail: the fluent methods are emitted in the order the `appMethod`-bearing
|
|
2708
|
+
* rows appear here, so this array is ordered to reproduce the original
|
|
2709
|
+
* `LONG_TAIL` sequence (ai, analytics, browser, hyperdrive, images, kv, payment,
|
|
2710
|
+
* r2sql, vectors). The `serverCtxField` rows are referenced by name in the ctx
|
|
2711
|
+
* interface templates, so their order here is not output-affecting.
|
|
2712
|
+
*/
|
|
2713
|
+
declare const CAPABILITY_ROWS: readonly [{
|
|
2714
|
+
readonly contextProperty: "access";
|
|
2715
|
+
readonly key: "access";
|
|
2716
|
+
readonly moduleSpecifier: "@lunora/cloudflare-access";
|
|
2717
|
+
}, {
|
|
2718
|
+
readonly appMethod: {
|
|
2719
|
+
readonly configKey: "ai";
|
|
2720
|
+
readonly doc: "Override the Workers AI binding backing `ctx.ai` (defaults to `env.AI`).";
|
|
2721
|
+
readonly method: "ai";
|
|
2722
|
+
};
|
|
2723
|
+
readonly contextProperty: "ai";
|
|
2724
|
+
readonly key: "ai";
|
|
2725
|
+
readonly moduleSpecifier: "@lunora/ai";
|
|
2726
|
+
}, {
|
|
2727
|
+
readonly appMethod: {
|
|
2728
|
+
readonly configKey: "analytics";
|
|
2729
|
+
readonly doc: "Override the Analytics Engine dataset backing `ctx.analytics` (defaults to `env.ANALYTICS`).";
|
|
2730
|
+
readonly method: "analytics";
|
|
2731
|
+
};
|
|
2732
|
+
readonly contextProperty: "analytics";
|
|
2733
|
+
readonly key: "analytics";
|
|
2734
|
+
readonly moduleSpecifier: "@lunora/bindings/analytics";
|
|
2735
|
+
readonly serverCtxField: {
|
|
2736
|
+
readonly field: "\n /** Analytics Engine telemetry sink. Fire-and-forget and sampled; do not read it back in-handler. */\n readonly analytics: import(\"@lunora/bindings/analytics\").AnalyticsClient;";
|
|
2737
|
+
readonly tier: "every";
|
|
2738
|
+
};
|
|
2739
|
+
}, {
|
|
2740
|
+
readonly appMethod: {
|
|
2741
|
+
readonly configKey: "browser";
|
|
2742
|
+
readonly doc: "Override the Browser Rendering binding backing `ctx.browser` (defaults to `env.BROWSER`).";
|
|
2743
|
+
readonly method: "browser";
|
|
2744
|
+
};
|
|
2745
|
+
readonly contextProperty: "browser";
|
|
2746
|
+
readonly key: "browser";
|
|
2747
|
+
readonly moduleSpecifier: "@lunora/browser";
|
|
2748
|
+
readonly serverCtxField: {
|
|
2749
|
+
readonly field: "\n /** Browser Rendering (screenshots/PDF/scrape). Non-deterministic — available only in actions. */\n readonly browser: import(\"@lunora/browser\").Browser;";
|
|
2750
|
+
readonly tier: "action";
|
|
2751
|
+
};
|
|
2752
|
+
}, {
|
|
2753
|
+
readonly contextProperty: "containers";
|
|
2754
|
+
readonly key: "container";
|
|
2755
|
+
readonly moduleSpecifier: "@lunora/container";
|
|
2756
|
+
}, {
|
|
2757
|
+
readonly contextProperty: "flags";
|
|
2758
|
+
readonly key: "flags";
|
|
2759
|
+
readonly moduleSpecifier: "@lunora/flags";
|
|
2760
|
+
}, {
|
|
2761
|
+
readonly appMethod: {
|
|
2762
|
+
readonly configKey: "sql";
|
|
2763
|
+
readonly doc: "Wire the Hyperdrive SQL client backing `ctx.sql` — build it with `createHyperdrive` + `fromPostgresJs`/`fromNodePg`/`fromMysql2`.";
|
|
2764
|
+
readonly method: "hyperdrive";
|
|
2765
|
+
};
|
|
2766
|
+
readonly contextProperty: "sql";
|
|
2767
|
+
readonly key: "hyperdrive";
|
|
2768
|
+
readonly moduleSpecifier: "@lunora/hyperdrive";
|
|
2769
|
+
readonly serverCtxField: {
|
|
2770
|
+
readonly field: "\n /**\n * External database access via Hyperdrive. Non-deterministic — available only in actions. Writes here are NOT tracked by Lunora live queries; subscriptions will not re-run on external DB changes.\n */\n readonly sql: import(\"@lunora/hyperdrive\").SqlClient;";
|
|
2771
|
+
readonly tier: "action";
|
|
2772
|
+
};
|
|
2773
|
+
}, {
|
|
2774
|
+
readonly appMethod: {
|
|
2775
|
+
readonly configKey: "images";
|
|
2776
|
+
readonly doc: "Override the Images binding backing `ctx.images` (defaults to `env.IMAGES`).";
|
|
2777
|
+
readonly method: "images";
|
|
2778
|
+
};
|
|
2779
|
+
readonly contextProperty: "images";
|
|
2780
|
+
readonly key: "images";
|
|
2781
|
+
readonly moduleSpecifier: "@lunora/bindings/images";
|
|
2782
|
+
readonly serverCtxField: {
|
|
2783
|
+
readonly field: "\n /** Cloudflare Images transforms (resize/format/optimize). Non-deterministic — available only in actions. */\n readonly images: import(\"@lunora/bindings/images\").Images;";
|
|
2784
|
+
readonly tier: "action";
|
|
2785
|
+
};
|
|
2786
|
+
}, {
|
|
2787
|
+
readonly appMethod: {
|
|
2788
|
+
readonly configKey: "kv";
|
|
2789
|
+
readonly doc: "Override the Workers KV binding backing `ctx.kv` (defaults to `env.KV`).";
|
|
2790
|
+
readonly method: "kv";
|
|
2791
|
+
};
|
|
2792
|
+
readonly contextProperty: "kv";
|
|
2793
|
+
readonly key: "kv";
|
|
2794
|
+
readonly moduleSpecifier: "@lunora/bindings/kv";
|
|
2795
|
+
readonly serverCtxField: {
|
|
2796
|
+
readonly field: "\n readonly kv: import(\"@lunora/bindings/kv\").Kv;";
|
|
2797
|
+
readonly tier: "every";
|
|
2798
|
+
};
|
|
2799
|
+
}, {
|
|
2800
|
+
readonly key: "mail";
|
|
2801
|
+
readonly moduleSpecifier: "@lunora/mail";
|
|
2802
|
+
}, {
|
|
2803
|
+
readonly contextProperty: "notify";
|
|
2804
|
+
readonly key: "notify";
|
|
2805
|
+
readonly moduleSpecifier: "@lunora/notify";
|
|
2806
|
+
}, {
|
|
2807
|
+
readonly appMethod: {
|
|
2808
|
+
readonly configKey: "payment";
|
|
2809
|
+
readonly doc: "Wire the payment options backing `ctx.payments`.";
|
|
2810
|
+
readonly method: "payment";
|
|
2811
|
+
};
|
|
2812
|
+
readonly contextProperty: "payments";
|
|
2813
|
+
readonly key: "payments";
|
|
2814
|
+
readonly moduleSpecifier: "@lunora/payment";
|
|
2815
|
+
}, {
|
|
2816
|
+
readonly appMethod: {
|
|
2817
|
+
readonly configKey: "x402";
|
|
2818
|
+
readonly doc: "Wire the x402 agent-wallet pay rail backing `ctx.x402` — a payment-enabled `fetch` that answers `402` challenges under a mandatory spend policy (ActionCtx-only; spends real funds).";
|
|
2819
|
+
readonly method: "x402";
|
|
2820
|
+
};
|
|
2821
|
+
readonly contextProperty: "x402";
|
|
2822
|
+
readonly key: "x402";
|
|
2823
|
+
readonly moduleSpecifier: "@lunora/x402/pay";
|
|
2824
|
+
}, {
|
|
2825
|
+
readonly contextProperty: "pipelines";
|
|
2826
|
+
readonly key: "pipelines";
|
|
2827
|
+
readonly moduleSpecifier: "@lunora/bindings/pipelines";
|
|
2828
|
+
readonly serverCtxField: {
|
|
2829
|
+
readonly field: "\n /** Pipelines ingestion sink (durable, R2-backed). Fire-and-forget and batched; do not read it back in-handler. */\n readonly pipelines: import(\"@lunora/bindings/pipelines\").PipelineClient;";
|
|
2830
|
+
readonly tier: "action";
|
|
2831
|
+
};
|
|
2832
|
+
}, {
|
|
2833
|
+
readonly appMethod: {
|
|
2834
|
+
readonly configKey: "r2sql";
|
|
2835
|
+
readonly doc: "Wire the R2 SQL client backing `ctx.r2sql` — build it with `createR2Sql({ accountId, apiToken, bucket })` (defaults to env `R2_SQL_TOKEN` / `R2_SQL_ACCOUNT_ID` / `R2_SQL_BUCKET`).";
|
|
2836
|
+
readonly method: "r2sql";
|
|
2837
|
+
};
|
|
2838
|
+
readonly contextProperty: "r2sql";
|
|
2839
|
+
readonly key: "r2sql";
|
|
2840
|
+
readonly moduleSpecifier: "@lunora/bindings/r2sql";
|
|
2841
|
+
readonly serverCtxField: {
|
|
2842
|
+
readonly field: "\n /**\n * R2 SQL over Apache Iceberg tables (window functions, DISTINCT, set operations). Non-deterministic — available only in actions. Reads here are NOT tracked by Lunora live queries.\n */\n readonly r2sql: import(\"@lunora/bindings/r2sql\").R2SqlClient;";
|
|
2843
|
+
readonly tier: "action";
|
|
2844
|
+
};
|
|
2845
|
+
}, {
|
|
2846
|
+
readonly contextProperty: "scheduler";
|
|
2847
|
+
readonly key: "scheduler";
|
|
2848
|
+
readonly moduleSpecifier: "@lunora/scheduler";
|
|
2849
|
+
}, {
|
|
2850
|
+
readonly contextProperty: "storage";
|
|
2851
|
+
readonly key: "storage";
|
|
2852
|
+
readonly moduleSpecifier: "@lunora/storage";
|
|
2853
|
+
}, {
|
|
2854
|
+
readonly appMethod: {
|
|
2855
|
+
readonly configKey: "vectors";
|
|
2856
|
+
readonly doc: "Wire the Vectorize index map backing `ctx.vectors`.";
|
|
2857
|
+
readonly method: "vectors";
|
|
2858
|
+
};
|
|
2859
|
+
readonly contextProperty: "vectors";
|
|
2860
|
+
readonly key: "vectors";
|
|
2861
|
+
readonly moduleSpecifier: "@lunora/bindings/vectors";
|
|
2862
|
+
}, {
|
|
2863
|
+
readonly contextProperty: "workflows";
|
|
2864
|
+
readonly key: "workflows";
|
|
2865
|
+
readonly moduleSpecifier: "@lunora/workflow";
|
|
2866
|
+
}];
|
|
2867
|
+
/** The literal union of every capability id — the single source of truth for `FeatureUsage`'s keys (so they cannot drift). */
|
|
2868
|
+
type CapabilityKey = (typeof CAPABILITY_ROWS)[number]["key"];
|
|
2869
|
+
/** The default codegen target — today's behavior, byte-identical goldens. */
|
|
2870
|
+
declare const DEFAULT_TARGET = "cloudflare";
|
|
2871
|
+
/**
|
|
2872
|
+
* Read `target` from `<projectRoot>/lunora.json`.
|
|
2873
|
+
*
|
|
2874
|
+
* This lives in `@lunora/codegen` rather than `@lunora/config` — where the rest
|
|
2875
|
+
* of the `lunora.json` reading lives — because `@lunora/config` depends on
|
|
2876
|
+
* `@lunora/codegen`, not the reverse. Putting it there and importing it here
|
|
2877
|
+
* would invert that edge, so config delegates to this instead and there is
|
|
2878
|
+
* still exactly one parser for the key.
|
|
2879
|
+
*
|
|
2880
|
+
* Best-effort and deliberately unvalidated: a missing file, malformed JSONC, or
|
|
2881
|
+
* a non-string value all collapse to `undefined`, because those are shape
|
|
2882
|
+
* errors rather than a name the user meant. An unrecognized *name* is returned
|
|
2883
|
+
* as-is so the caller's registry lookup rejects it — swallowing a typo into the
|
|
2884
|
+
* default would ship an app to the wrong provider.
|
|
2885
|
+
* @param projectRoot Directory containing `lunora.json`.
|
|
2886
|
+
* @returns the declared target, or `undefined` when none is usable.
|
|
2887
|
+
*/
|
|
2888
|
+
declare const readProjectTarget: (projectRoot: string) => string | undefined;
|
|
2889
|
+
/**
|
|
2890
|
+
* The target codegen should emit for: an explicit option wins, then
|
|
2891
|
+
* `lunora.json`, then the default.
|
|
2892
|
+
*
|
|
2893
|
+
* `runCodegen` applies this itself so a caller that forgets to pass a target
|
|
2894
|
+
* still emits the surface the project declared. That default matters more than
|
|
2895
|
+
* it looks: a call site that silently omits the target emits the *default*
|
|
2896
|
+
* surface with no diagnostic to notice, and the mismatch only shows up at
|
|
2897
|
+
* runtime on the deployed app.
|
|
2898
|
+
* @param projectRoot Directory containing `lunora.json`.
|
|
2899
|
+
* @param explicit A caller-supplied target, if any.
|
|
2900
|
+
* @returns the resolved target id — not guaranteed to be registered.
|
|
2901
|
+
*/
|
|
2902
|
+
declare const resolveCodegenTarget: (projectRoot: string, explicit?: string) => string;
|
|
2903
|
+
/**
|
|
2904
|
+
* The target ids codegen can gate against.
|
|
2905
|
+
*
|
|
2906
|
+
* Exported so `@lunora/config` can assert that its driver registry and this
|
|
2907
|
+
* capability-matrix registry name the same targets. They are two id spaces for one
|
|
2908
|
+
* concept: a target that ships a driver but no matrix passes the CLI's
|
|
2909
|
+
* validation and then emits an un-gated surface, and one with a matrix but no
|
|
2910
|
+
* driver gates a surface nothing can deploy. Today both hold exactly
|
|
2911
|
+
* `cloudflare`, which is why nothing has noticed.
|
|
2912
|
+
* @returns the registered matrix ids, sorted.
|
|
2913
|
+
*/
|
|
2914
|
+
declare const platformMatrixIds: () => ReadonlyArray<string>;
|
|
2915
|
+
/** An advisor-style diagnostic about a target's platform capabilities. */
|
|
2916
|
+
interface PlatformDiagnostic {
|
|
2917
|
+
/** The codegen capability this concerns, when it is feature-specific. */
|
|
2918
|
+
feature?: CapabilityKey;
|
|
2919
|
+
/** Severity. `platform_unsupported_feature` and `platform_unknown_target` are both errors — each drops or misdirects an emitted surface. */
|
|
2920
|
+
level: "error" | "warn";
|
|
2921
|
+
/** Human-readable explanation of the gap. */
|
|
2922
|
+
message: string;
|
|
2923
|
+
/** The lint id: `platform_unsupported_feature` or `platform_unknown_target`. */
|
|
2924
|
+
name: "platform_unknown_target" | "platform_unsupported_feature";
|
|
2925
|
+
/** How to resolve it. */
|
|
2926
|
+
remediation: string;
|
|
2927
|
+
/** The requested deploy target. */
|
|
2928
|
+
target: string;
|
|
2929
|
+
}
|
|
2671
2930
|
/**
|
|
2672
2931
|
* Committed, tracked baseline file holding the blessed structural schema
|
|
2673
2932
|
* snapshot the pre-deploy drift gate diffs against. Lives in `lunora/` (NOT the
|
|
@@ -2751,6 +3010,17 @@ interface CodegenOptions {
|
|
|
2751
3010
|
project?: Project;
|
|
2752
3011
|
/** Project root containing the `lunora/` directory. */
|
|
2753
3012
|
projectRoot: string;
|
|
3013
|
+
/**
|
|
3014
|
+
* The deploy target codegen tailors the emitted `ctx.*` surface to.
|
|
3015
|
+
* Defaults to `"cloudflare"` — whose capability matrix marks every feature
|
|
3016
|
+
* native or emulated, so the default output is unchanged (byte-identical
|
|
3017
|
+
* goldens). A target that marks a used feature unsupported omits its
|
|
3018
|
+
* `ctx.*` surface and reports it in {@link CodegenResult.platformDiagnostics}.
|
|
3019
|
+
* Only `"cloudflare"` is registered until other per-target `@lunora/platform`
|
|
3020
|
+
* matrices land; an unknown target emits the full surface un-gated and a
|
|
3021
|
+
* `platform_unknown_target` diagnostic.
|
|
3022
|
+
*/
|
|
3023
|
+
target?: string;
|
|
2754
3024
|
/**
|
|
2755
3025
|
* Re-bless the committed schema-drift baseline (`lunora/.lunora-schema.json`)
|
|
2756
3026
|
* with the current structural snapshot. The baseline is ALWAYS written on
|
|
@@ -2769,6 +3039,15 @@ interface CodegenOptions {
|
|
|
2769
3039
|
wranglerVariables?: ReadonlyArray<WranglerVariableIR>;
|
|
2770
3040
|
}
|
|
2771
3041
|
interface CodegenResult {
|
|
3042
|
+
/**
|
|
3043
|
+
* The normalized advisor evidence the findings were produced from, so a
|
|
3044
|
+
* caller can score it into a health map (`scoreAdvisor`) without re-running
|
|
3045
|
+
* discovery. `undefined` under `lint: false`.
|
|
3046
|
+
*
|
|
3047
|
+
* Deliberately not scored here: the map carries a `generatedAt` stamp, and
|
|
3048
|
+
* codegen's result stays a pure function of the sources.
|
|
3049
|
+
*/
|
|
3050
|
+
advisorContext?: LintContext;
|
|
2772
3051
|
/**
|
|
2773
3052
|
* Static schema advisor findings (e.g. unindexed foreign keys) produced
|
|
2774
3053
|
* this run. Empty when `lint` is `false` or the schema is clean. Codegen
|
|
@@ -2842,6 +3121,14 @@ interface CodegenResult {
|
|
|
2842
3121
|
workflows: string;
|
|
2843
3122
|
};
|
|
2844
3123
|
outputDirectory: string;
|
|
3124
|
+
/**
|
|
3125
|
+
* Portability diagnostics for the requested {@link CodegenOptions.target}:
|
|
3126
|
+
* `ctx.*` features the app uses that the target does not support (omitted
|
|
3127
|
+
* from the emitted surface), or an unknown target. Empty for a
|
|
3128
|
+
* fully-supported app on the default Cloudflare target. Presentation is the
|
|
3129
|
+
* caller's job, like {@link CodegenResult.advisories}.
|
|
3130
|
+
*/
|
|
3131
|
+
platformDiagnostics: ReadonlyArray<PlatformDiagnostic>;
|
|
2845
3132
|
/**
|
|
2846
3133
|
* Queues discovered from `defineQueue` exports in `lunora/queues.ts` — the
|
|
2847
3134
|
* list the config layer reconciles into wrangler's `queues.producers[]` /
|
|
@@ -2956,4 +3243,4 @@ declare const secretKindOf: (value: string) => string | undefined;
|
|
|
2956
3243
|
/** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
|
|
2957
3244
|
declare const redact: (value: string) => string;
|
|
2958
3245
|
declare const VERSION = "0.0.0";
|
|
2959
|
-
export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type DriftScope, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type R2sqlCallIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, redact, refreshCodegenProject, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, validatorIrToJsonSchema };
|
|
3246
|
+
export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, DEFAULT_TARGET, type DriftChange, type DriftScope, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type PlatformDiagnostic, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type R2sqlCallIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, platformMatrixIds, readProjectTarget, redact, refreshCodegenProject, resolveCodegenTarget, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, toAdvisorContext, validatorIrToJsonSchema };
|