@lunora/codegen 1.0.0-alpha.1 → 1.0.0-alpha.10
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/__assets__/package-og.svg +1 -1
- package/dist/index.d.mts +96 -7
- package/dist/index.d.ts +96 -7
- package/dist/index.mjs +23 -22
- package/dist/packem_shared/{CONTAINERS_FILENAME-0K-pjNb8.mjs → CONTAINERS_FILENAME-DlP6YM_Q.mjs} +1 -1
- package/dist/packem_shared/{CodegenDiagnosticError-54jWDxA9.mjs → CodegenDiagnosticError-DeblMkzO.mjs} +3 -2
- package/dist/packem_shared/{emitApi-hRVC-kE7.mjs → GENERATED_HEADER-BiFXNUvo.mjs} +285 -19
- package/dist/packem_shared/{buildOpenRpcDocument-BZGY1-jT.mjs → OPENRPC_VERSION-B4i9Qp3v.mjs} +1 -1
- package/dist/packem_shared/{createCodegenProject-DGJm0_Pk.mjs → SCHEMA_SNAPSHOT_FILENAME-Bvv7qa_u.mjs} +81 -37
- package/dist/packem_shared/{buildSchemaSnapshot-DzLDbWk3.mjs → SCHEMA_SNAPSHOT_VERSION-wWGP2_5E.mjs} +12 -0
- package/dist/packem_shared/{discoverWorkflows-DRDQdhfq.mjs → WORKFLOWS_FILENAME-D62dcBGg.mjs} +1 -1
- package/dist/packem_shared/{buildOpenApiDocument-yHVN66Xd.mjs → buildOpenApiDocument-Cu3mZl-8.mjs} +1 -1
- package/dist/packem_shared/{discoverAuthApiCalls-C35R6z0T.mjs → discoverAuthApiCalls-CoirYbg6.mjs} +1 -1
- package/dist/packem_shared/{discoverCrons-BL6iGuJ3.mjs → discoverCrons-Cev7RRAf.mjs} +20 -17
- package/dist/packem_shared/{discoverFunctions-DEgAcRuD.mjs → discoverFunctions-BWMczzBx.mjs} +7 -2
- package/dist/packem_shared/{discoverHttpRoutes-C978pBiG.mjs → discoverHttpRoutes-CfP6cMzt.mjs} +2 -2
- package/dist/packem_shared/{discoverInserts-CRQdXvHO.mjs → discoverInserts-C7zxXkUf.mjs} +24 -2
- package/dist/packem_shared/{discoverMaskProcedures-B64zA740.mjs → discoverMaskProcedures-Cm81kwrb.mjs} +1 -1
- package/dist/packem_shared/{discoverMigrations-Doj_-BAA.mjs → discoverMigrations-Bi5nJ0mJ.mjs} +10 -4
- package/dist/packem_shared/{discoverNondeterministicCalls-4KiPQxQU.mjs → discoverNondeterministicCalls-C4M8AXmQ.mjs} +1 -1
- package/dist/packem_shared/{discoverQueries-BkIi0dBD.mjs → discoverQueries-B0wGT-xe.mjs} +1 -1
- package/dist/packem_shared/discoverR2sqlCalls-BVNMd428.mjs +80 -0
- package/dist/packem_shared/{discoverRlsMetadata-DpRB1HMe.mjs → discoverRlsMetadata-BS9GOGC5.mjs} +1 -1
- package/dist/packem_shared/{discoverSchema-BBulgGbH.mjs → discoverSchema-BnWHHJ4T.mjs} +296 -16
- package/dist/packem_shared/{discoverStorageRulesMetadata-DAqJUxUv.mjs → discoverStorageRulesMetadata-Da8BKXcI.mjs} +1 -1
- package/dist/packem_shared/{emitApp-CzZ6GbrD.mjs → emitApp-KfMaKXWe.mjs} +12 -2
- package/dist/packem_shared/{lintSchema-DicbOHvH.mjs → formatAdvisories-8NIv1k0I.mjs} +2 -1
- package/dist/packem_shared/{parse-validator-tuQtHrsr.mjs → parse-validator-Cabb60UV.mjs} +2 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -25,6 +25,15 @@ interface ValidatorIR {
|
|
|
25
25
|
bucket?: string;
|
|
26
26
|
/** Column modifiers (`.unique()`, `.default()`, `.nullable()`, …) when present. */
|
|
27
27
|
column?: ColumnMetaIR;
|
|
28
|
+
/**
|
|
29
|
+
* `true` when this validator carries a `.check(...)` refinement. The predicate
|
|
30
|
+
* is a runtime closure the AST→IR step can't represent, so the node keeps its
|
|
31
|
+
* base `kind` but records the refinement's presence here. The AOT args-validator
|
|
32
|
+
* compiler declines any node with this flag (compiling it would silently skip
|
|
33
|
+
* the predicate). `.meta(...)` is pure metadata with no parse effect and does
|
|
34
|
+
* NOT set this.
|
|
35
|
+
*/
|
|
36
|
+
hasRefinement?: boolean;
|
|
28
37
|
/** For `v.optional(inner)` / `v.array(inner)`. */
|
|
29
38
|
inner?: ValidatorIR;
|
|
30
39
|
/** For `v.record(key, value)`. */
|
|
@@ -126,10 +135,23 @@ interface TableIR {
|
|
|
126
135
|
field: string;
|
|
127
136
|
kind: "shardBy";
|
|
128
137
|
};
|
|
138
|
+
/** Set when the chain carried `.softDelete()` — the marker column's name (default `deletedAt`). The column is injected into `shape` so `Doc_*` carries it. */
|
|
139
|
+
softDelete?: {
|
|
140
|
+
field: string;
|
|
141
|
+
};
|
|
129
142
|
/** Vector indexes declared inline via `.vectorize()` (DSL Shape A). */
|
|
130
143
|
vectorIndexes: ReadonlyArray<VectorIndexIR>;
|
|
131
144
|
}
|
|
145
|
+
/** The Cloudflare DO data-residency jurisdictions the schema may declare. Canonical literal set for the codegen package. */
|
|
146
|
+
type JurisdictionIR = "eu" | "fedramp" | "us";
|
|
132
147
|
interface SchemaIR {
|
|
148
|
+
/**
|
|
149
|
+
* Cloudflare data-residency jurisdiction declared via
|
|
150
|
+
* `defineSchema(...).jurisdiction("…")`. Emitted into the generated worker's
|
|
151
|
+
* `createWorker({ jurisdiction })` (and `ctx.scheduler` / `ctx.containers`).
|
|
152
|
+
* Absent ⇒ un-pinned.
|
|
153
|
+
*/
|
|
154
|
+
jurisdiction?: JurisdictionIR;
|
|
133
155
|
tables: ReadonlyArray<TableIR>;
|
|
134
156
|
/** All vector indexes (inline Shape A hoisted + standalone Shape B), flattened. */
|
|
135
157
|
vectorIndexes: ReadonlyArray<VectorIndexIR>;
|
|
@@ -384,6 +406,26 @@ interface NondeterministicCallIR {
|
|
|
384
406
|
line: number;
|
|
385
407
|
}
|
|
386
408
|
/**
|
|
409
|
+
* One `ctx.r2sql` access lexically inside a `query`/`mutation` handler — the
|
|
410
|
+
* `r2sql_outside_action` advisor lint input. Structurally identical to the
|
|
411
|
+
* advisor's `AdvisorR2sqlCall` (same field set) so values pass straight through
|
|
412
|
+
* `lintSchema` without conversion, exactly as `NondeterministicCallIR` does.
|
|
413
|
+
* Only `query`/`mutation` handlers are recorded; `action(...)` is the intended
|
|
414
|
+
* home for `ctx.r2sql` and is skipped.
|
|
415
|
+
*/
|
|
416
|
+
interface R2sqlCallIR {
|
|
417
|
+
/** The accessed `ctx.r2sql` surface, e.g. `ctx.r2sql.query` / `ctx.r2sql.from`. */
|
|
418
|
+
callee: string;
|
|
419
|
+
/** Export binding name of the function performing the access. */
|
|
420
|
+
exportName: string;
|
|
421
|
+
/** Source file relative to the lunora dir, without extension (the api namespace). */
|
|
422
|
+
file: string;
|
|
423
|
+
/** Which procedure kind the access lives in — only `query`/`mutation` handlers are recorded. */
|
|
424
|
+
kind: "mutation" | "query";
|
|
425
|
+
/** 1-based line of the access, or `0` when unknown. */
|
|
426
|
+
line: number;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
387
429
|
* Per-procedure RLS usage snapshot, produced by `discoverRlsProcedures` for the
|
|
388
430
|
* `rls_uncovered_table` advisor lint. Structurally identical to
|
|
389
431
|
* `AdvisorRlsProcedure` (they share the same field set) so values pass straight
|
|
@@ -686,7 +728,7 @@ interface ProjectIR {
|
|
|
686
728
|
* pass straight through without conversion. Returns the findings; surfacing them
|
|
687
729
|
* (console, error overlay, studio Advisors table) is the caller's choice.
|
|
688
730
|
*/
|
|
689
|
-
declare const lintSchema: (schema: SchemaIR, queries?: ReadonlyArray<QueryReadIR>, inserts?: ReadonlyArray<InsertWriteIR>, authApiCalls?: ReadonlyArray<AuthApiCallIR>, rlsProcedures?: ReadonlyArray<RlsProcedureIR>, containers?: ReadonlyArray<ContainerIR>, workflows?: ReadonlyArray<WorkflowIR>, workflowCalls?: ReadonlyArray<WorkflowCallIR>, maskProcedures?: ReadonlyArray<MaskProcedureIR>, nondeterministicCalls?: ReadonlyArray<NondeterministicCallIR>, procedureProtections?: ReadonlyArray<ProcedureMiddlewareIR>, argumentValidators?: ReadonlyArray<ArgumentValidatorIR>, secretLiterals?: ReadonlyArray<SecretLiteralIR>, sqlInterpolations?: ReadonlyArray<SqlInterpolationIR>, adminRoutes?: ReadonlyArray<AdminRouteIR>) => Finding[];
|
|
731
|
+
declare const lintSchema: (schema: SchemaIR, queries?: ReadonlyArray<QueryReadIR>, inserts?: ReadonlyArray<InsertWriteIR>, authApiCalls?: ReadonlyArray<AuthApiCallIR>, rlsProcedures?: ReadonlyArray<RlsProcedureIR>, containers?: ReadonlyArray<ContainerIR>, workflows?: ReadonlyArray<WorkflowIR>, workflowCalls?: ReadonlyArray<WorkflowCallIR>, maskProcedures?: ReadonlyArray<MaskProcedureIR>, nondeterministicCalls?: ReadonlyArray<NondeterministicCallIR>, procedureProtections?: ReadonlyArray<ProcedureMiddlewareIR>, argumentValidators?: ReadonlyArray<ArgumentValidatorIR>, secretLiterals?: ReadonlyArray<SecretLiteralIR>, sqlInterpolations?: ReadonlyArray<SqlInterpolationIR>, adminRoutes?: ReadonlyArray<AdminRouteIR>, r2sqlCalls?: ReadonlyArray<R2sqlCallIR>) => Finding[];
|
|
690
732
|
/**
|
|
691
733
|
* Render advisor findings as a single multi-line string for console surfacing:
|
|
692
734
|
* a one-line summary header followed by one `[LEVEL] name: detail` line per
|
|
@@ -711,8 +753,14 @@ declare class CodegenDiagnosticError extends Error {
|
|
|
711
753
|
* ts-morph `Node`'s position in its source file.
|
|
712
754
|
*
|
|
713
755
|
* Message format: `@lunora/codegen: <detail> (<file>:<line>:<column>)`
|
|
756
|
+
*
|
|
757
|
+
* `meta` is merged onto the returned error for callers that also carry the
|
|
758
|
+
* project-wide `LunoraError` envelope (`code`/`name`/`status`) — it never
|
|
759
|
+
* touches `file`/`line`/`column`, and the error stays an instance of
|
|
760
|
+
* {@link CodegenDiagnosticError} so the Vite overlay's `instanceof` location
|
|
761
|
+
* lookup is unaffected.
|
|
714
762
|
*/
|
|
715
|
-
declare const diagnosticAt: (node: Node, detail: string) => CodegenDiagnosticError;
|
|
763
|
+
declare const diagnosticAt: (node: Node, detail: string, meta?: Record<string, unknown>) => CodegenDiagnosticError;
|
|
716
764
|
/**
|
|
717
765
|
* Discover `ctx.authApi.<method>(...)` (and bare `authApi.<method>(...)`) calls
|
|
718
766
|
* under the lunora source directory and attribute each to the exported function
|
|
@@ -803,6 +851,19 @@ declare const discoverNondeterministicCalls: (project: Project, lunoraDirectory:
|
|
|
803
851
|
* dropping the rest keeps the lint input small.
|
|
804
852
|
*/
|
|
805
853
|
declare const discoverQueries: (project: Project, lunoraDirectory: string) => QueryReadIR[];
|
|
854
|
+
/**
|
|
855
|
+
* Discover `ctx.r2sql` accesses lexically inside the handler body of every
|
|
856
|
+
* exported `query(...)` / `mutation(...)` registration under the lunora source
|
|
857
|
+
* directory — the `r2sql_outside_action` lint input. `action(...)` (and
|
|
858
|
+
* `stream(...)`) registrations are intentionally skipped: R2 SQL is the
|
|
859
|
+
* external, non-reactive surface that belongs in actions.
|
|
860
|
+
*
|
|
861
|
+
* Traversal is scoped to the handler node (not the whole declaration), mirroring
|
|
862
|
+
* `discoverNondeterministicCalls` — so a `ctx.r2sql` touch in a sibling helper
|
|
863
|
+
* outside the handler is not attributed to the query/mutation. One
|
|
864
|
+
* {@link R2sqlCallIR} is produced per access site.
|
|
865
|
+
*/
|
|
866
|
+
declare const discoverR2sqlCalls: (project: Project, lunoraDirectory: string) => R2sqlCallIR[];
|
|
806
867
|
declare const discoverRlsProcedures: (project: Project, lunoraDirectory: string) => RlsProcedureIR[];
|
|
807
868
|
/**
|
|
808
869
|
* Aggregate the schema-wide RLS metadata the studio's read-only inspector reads:
|
|
@@ -822,7 +883,7 @@ declare const discoverRlsMetadata: (project: Project, lunoraDirectory: string) =
|
|
|
822
883
|
* Load `<projectRoot>/lunora/schema.ts`, find `defineSchema({...})`, and
|
|
823
884
|
* return a structural IR. Throws if the file or call cannot be found.
|
|
824
885
|
*/
|
|
825
|
-
declare const discoverSchema: (project: Project, schemaPath: string) => SchemaIR;
|
|
886
|
+
declare const discoverSchema: (project: Project, schemaPath: string, projectRoot?: string) => SchemaIR;
|
|
826
887
|
/**
|
|
827
888
|
* Aggregate the schema-wide storage-rule metadata the studio's inspector reads:
|
|
828
889
|
* every statically-discovered `(bucket, on, prefix, procedure)` entry across all
|
|
@@ -877,6 +938,8 @@ interface EmitServerOptions {
|
|
|
877
938
|
hasPayments?: boolean;
|
|
878
939
|
/** A `lunora/` source uses `@lunora/pipelines` / `ctx.pipelines` — wires `ctx.pipelines` onto ActionCtx only. */
|
|
879
940
|
hasPipelines?: boolean;
|
|
941
|
+
/** A `lunora/` source uses `@lunora/r2sql` / `ctx.r2sql` — wires `ctx.r2sql` onto ActionCtx only. */
|
|
942
|
+
hasR2sql?: boolean;
|
|
880
943
|
schema?: SchemaIR;
|
|
881
944
|
storageRuleBuckets?: ReadonlyArray<string>;
|
|
882
945
|
/** The project depends on the `lunora` umbrella — import base packages via its subpaths. */
|
|
@@ -893,12 +956,13 @@ declare const emitServer: ({
|
|
|
893
956
|
hasKv,
|
|
894
957
|
hasPayments,
|
|
895
958
|
hasPipelines,
|
|
959
|
+
hasR2sql,
|
|
896
960
|
schema,
|
|
897
961
|
storageRuleBuckets,
|
|
898
962
|
useUmbrella,
|
|
899
963
|
workflows
|
|
900
964
|
}?: EmitServerOptions) => string;
|
|
901
|
-
declare const emitFunctions: (functions: ReadonlyArray<FunctionIR>, migrations?: ReadonlyArray<MigrationIR
|
|
965
|
+
declare const emitFunctions: (functions: ReadonlyArray<FunctionIR>, migrations?: ReadonlyArray<MigrationIR>, useUmbrella?: boolean) => string;
|
|
902
966
|
/**
|
|
903
967
|
* Storage-column map per table for the file browser: `{ table: [field, …] }` for
|
|
904
968
|
* every field declared `v.storage(...)` (unwrapping `v.optional(...)`). The
|
|
@@ -916,7 +980,7 @@ declare const emitFunctions: (functions: ReadonlyArray<FunctionIR>, migrations?:
|
|
|
916
980
|
* `containers[].class_name` to be exported by the deployed worker. Returns ""
|
|
917
981
|
* when the project declares no containers (the file is not written then).
|
|
918
982
|
*/
|
|
919
|
-
declare const emitContainers: (containers: ReadonlyArray<ContainerIR
|
|
983
|
+
declare const emitContainers: (containers: ReadonlyArray<ContainerIR>, jurisdiction?: JurisdictionIR) => string;
|
|
920
984
|
/**
|
|
921
985
|
* Emit `_generated/workflows.ts` — one `WorkflowEntrypoint` class per
|
|
922
986
|
* `defineWorkflow` export, each a thin subclass of `LunoraWorkflow`
|
|
@@ -941,6 +1005,8 @@ interface EmitShardOptions {
|
|
|
941
1005
|
/** A `lunora/` source reads `ctx.kv` — wires `ctx.kv` onto every ctx. */
|
|
942
1006
|
hasKv?: boolean;
|
|
943
1007
|
hasPayments?: boolean;
|
|
1008
|
+
/** A `lunora/` source reads `ctx.r2sql` (R2 SQL) — wires `ctx.r2sql` onto the ActionCtx only. */
|
|
1009
|
+
hasR2sql?: boolean;
|
|
944
1010
|
maskMetadata?: MaskMetadataIR;
|
|
945
1011
|
rlsMetadata?: RlsMetadataIR;
|
|
946
1012
|
schema: SchemaIR;
|
|
@@ -960,6 +1026,7 @@ declare const emitShard: ({
|
|
|
960
1026
|
hasImages,
|
|
961
1027
|
hasKv,
|
|
962
1028
|
hasPayments,
|
|
1029
|
+
hasR2sql,
|
|
963
1030
|
maskMetadata,
|
|
964
1031
|
rlsMetadata,
|
|
965
1032
|
schema,
|
|
@@ -1049,6 +1116,8 @@ interface EmitAppOptions {
|
|
|
1049
1116
|
hasKv: boolean;
|
|
1050
1117
|
/** App uses `@lunora/payment` / `ctx.payments` → emit `.payment()`. */
|
|
1051
1118
|
hasPayments: boolean;
|
|
1119
|
+
/** App uses `@lunora/r2sql` / `ctx.r2sql` → emit `.r2sql()`. */
|
|
1120
|
+
hasR2sql: boolean;
|
|
1052
1121
|
/** App imports `@lunora/scheduler` / declares crons → emit `.scheduler()`. */
|
|
1053
1122
|
hasScheduler: boolean;
|
|
1054
1123
|
/** App uses `@lunora/storage` → emit `.storage()` (DO `ctx.storage` + studio file browser). */
|
|
@@ -1057,6 +1126,8 @@ interface EmitAppOptions {
|
|
|
1057
1126
|
hasVectors: boolean;
|
|
1058
1127
|
/** App declares Cloudflare Workflows (`defineWorkflow`) → wire `options.workflowsClient` so the studio's workflow-instance proxy can reach the CF REST API. */
|
|
1059
1128
|
hasWorkflow: boolean;
|
|
1129
|
+
/** Schema declares `.jurisdiction("…")` → pin every DO the worker reaches (shards, fan-out, scheduler, containers) to the Cloudflare data-residency jurisdiction. */
|
|
1130
|
+
jurisdiction?: JurisdictionIR;
|
|
1060
1131
|
/** Project depends on the unscoped `lunorash` umbrella → import the runtime via `lunorash/runtime` instead of `@lunora/runtime`. */
|
|
1061
1132
|
useUmbrella: boolean;
|
|
1062
1133
|
/** An OpenAPI spec is emitted (`openapi.ts`) → wire `openApiSpec` into the worker. */
|
|
@@ -1201,6 +1272,19 @@ interface TableSnapshot {
|
|
|
1201
1272
|
}
|
|
1202
1273
|
/** The committed baseline — a deterministic structural view of the whole schema. */
|
|
1203
1274
|
interface SchemaSnapshot {
|
|
1275
|
+
/**
|
|
1276
|
+
* Cloudflare DO data-residency jurisdiction declared via `.jurisdiction("…")`,
|
|
1277
|
+
* or absent. Tracked because changing it strands all existing Durable Object
|
|
1278
|
+
* data (a DO name maps to a different ID per jurisdiction). Optional, so old
|
|
1279
|
+
* baselines written before this field parse cleanly (absent ⇒ undefined).
|
|
1280
|
+
*
|
|
1281
|
+
* Typed as a plain `string` (not the authoring union) on purpose: this is
|
|
1282
|
+
* STORED data that a newer Lunora may have written with a jurisdiction this
|
|
1283
|
+
* version doesn't yet know. Preserving the raw value keeps the breaking
|
|
1284
|
+
* `changedJurisdiction` diff correct under a downgrade — coercing an unknown
|
|
1285
|
+
* value to `undefined` would fail OPEN and hide the most destructive change.
|
|
1286
|
+
*/
|
|
1287
|
+
jurisdiction?: string;
|
|
1204
1288
|
/** Sorted list of every declared `defineMigration` id at capture time. */
|
|
1205
1289
|
migrationIds: ReadonlyArray<string>;
|
|
1206
1290
|
/** Table name → {@link TableSnapshot}, keys sorted for stable serialization. */
|
|
@@ -1214,7 +1298,7 @@ interface DriftChange {
|
|
|
1214
1298
|
/** Human-readable, actionable description (used in the gate message). */
|
|
1215
1299
|
summary: string;
|
|
1216
1300
|
/** A machine-readable change discriminator. */
|
|
1217
|
-
type: "addedIndex" | "addedOptionalField" | "addedRelation" | "addedRequiredField" | "addedTable" | "changedFieldKind" | "changedIndex" | "changedShardMode" | "fieldOptionalToRequired" | "fieldRequiredToOptional" | "removedField" | "removedIndex" | "removedRelation" | "removedTable";
|
|
1301
|
+
type: "addedIndex" | "addedOptionalField" | "addedRelation" | "addedRequiredField" | "addedTable" | "changedJurisdiction" | "changedFieldKind" | "changedIndex" | "changedShardMode" | "fieldOptionalToRequired" | "fieldRequiredToOptional" | "removedField" | "removedIndex" | "removedRelation" | "removedTable";
|
|
1218
1302
|
}
|
|
1219
1303
|
/** The result of diffing two snapshots: every classified change. */
|
|
1220
1304
|
interface SchemaDrift {
|
|
@@ -1316,6 +1400,11 @@ declare const refreshCodegenProject: (project: Project, lunoraDirectory: string)
|
|
|
1316
1400
|
* Top-level codegen entry. Parses `<projectRoot>/lunora/schema.ts` and every
|
|
1317
1401
|
* function file under `<projectRoot>/lunora/`, then writes
|
|
1318
1402
|
* `_generated/{api,server,dataModel}.ts` next to them.
|
|
1403
|
+
*
|
|
1404
|
+
* When `LUNORA_CODEGEN_TIMING` is set (truthy), a single diagnostic summary
|
|
1405
|
+
* line is written to stderr with the total wall time and the discovery-vs-emit
|
|
1406
|
+
* split — opt-in instrumentation that is otherwise zero-cost and side-effect-free
|
|
1407
|
+
* on the returned {@link CodegenResult}.
|
|
1319
1408
|
*/
|
|
1320
1409
|
declare const runCodegen: (options: CodegenOptions) => CodegenResult;
|
|
1321
1410
|
interface CodegenOptions {
|
|
@@ -1470,4 +1559,4 @@ declare const validatorIrToJsonSchema: (validator: ValidatorIR) => JsonSchema;
|
|
|
1470
1559
|
*/
|
|
1471
1560
|
declare const LUNORA_ERROR_CODES: ReadonlyArray<string>;
|
|
1472
1561
|
declare const VERSION = "0.0.0";
|
|
1473
|
-
export { type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, type FieldSnapshot, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type MaskProcedureIR, type MigrationIR, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type ProjectIR, type QueryReadIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverNondeterministicCalls, discoverQueries, discoverRlsMetadata, discoverRlsProcedures, discoverSchema, discoverStorageRulesMetadata, discoverWorkflows, emitApi, emitApp, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, refreshCodegenProject, runCodegen, schemaFromIr, serializeSchemaSnapshot, validatorIrToJsonSchema };
|
|
1562
|
+
export { type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, type FieldSnapshot, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type MaskProcedureIR, type MigrationIR, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type ProjectIR, type QueryReadIR, type R2sqlCallIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverNondeterministicCalls, discoverQueries, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSchema, discoverStorageRulesMetadata, discoverWorkflows, emitApi, emitApp, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, refreshCodegenProject, runCodegen, schemaFromIr, serializeSchemaSnapshot, validatorIrToJsonSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,15 @@ interface ValidatorIR {
|
|
|
25
25
|
bucket?: string;
|
|
26
26
|
/** Column modifiers (`.unique()`, `.default()`, `.nullable()`, …) when present. */
|
|
27
27
|
column?: ColumnMetaIR;
|
|
28
|
+
/**
|
|
29
|
+
* `true` when this validator carries a `.check(...)` refinement. The predicate
|
|
30
|
+
* is a runtime closure the AST→IR step can't represent, so the node keeps its
|
|
31
|
+
* base `kind` but records the refinement's presence here. The AOT args-validator
|
|
32
|
+
* compiler declines any node with this flag (compiling it would silently skip
|
|
33
|
+
* the predicate). `.meta(...)` is pure metadata with no parse effect and does
|
|
34
|
+
* NOT set this.
|
|
35
|
+
*/
|
|
36
|
+
hasRefinement?: boolean;
|
|
28
37
|
/** For `v.optional(inner)` / `v.array(inner)`. */
|
|
29
38
|
inner?: ValidatorIR;
|
|
30
39
|
/** For `v.record(key, value)`. */
|
|
@@ -126,10 +135,23 @@ interface TableIR {
|
|
|
126
135
|
field: string;
|
|
127
136
|
kind: "shardBy";
|
|
128
137
|
};
|
|
138
|
+
/** Set when the chain carried `.softDelete()` — the marker column's name (default `deletedAt`). The column is injected into `shape` so `Doc_*` carries it. */
|
|
139
|
+
softDelete?: {
|
|
140
|
+
field: string;
|
|
141
|
+
};
|
|
129
142
|
/** Vector indexes declared inline via `.vectorize()` (DSL Shape A). */
|
|
130
143
|
vectorIndexes: ReadonlyArray<VectorIndexIR>;
|
|
131
144
|
}
|
|
145
|
+
/** The Cloudflare DO data-residency jurisdictions the schema may declare. Canonical literal set for the codegen package. */
|
|
146
|
+
type JurisdictionIR = "eu" | "fedramp" | "us";
|
|
132
147
|
interface SchemaIR {
|
|
148
|
+
/**
|
|
149
|
+
* Cloudflare data-residency jurisdiction declared via
|
|
150
|
+
* `defineSchema(...).jurisdiction("…")`. Emitted into the generated worker's
|
|
151
|
+
* `createWorker({ jurisdiction })` (and `ctx.scheduler` / `ctx.containers`).
|
|
152
|
+
* Absent ⇒ un-pinned.
|
|
153
|
+
*/
|
|
154
|
+
jurisdiction?: JurisdictionIR;
|
|
133
155
|
tables: ReadonlyArray<TableIR>;
|
|
134
156
|
/** All vector indexes (inline Shape A hoisted + standalone Shape B), flattened. */
|
|
135
157
|
vectorIndexes: ReadonlyArray<VectorIndexIR>;
|
|
@@ -384,6 +406,26 @@ interface NondeterministicCallIR {
|
|
|
384
406
|
line: number;
|
|
385
407
|
}
|
|
386
408
|
/**
|
|
409
|
+
* One `ctx.r2sql` access lexically inside a `query`/`mutation` handler — the
|
|
410
|
+
* `r2sql_outside_action` advisor lint input. Structurally identical to the
|
|
411
|
+
* advisor's `AdvisorR2sqlCall` (same field set) so values pass straight through
|
|
412
|
+
* `lintSchema` without conversion, exactly as `NondeterministicCallIR` does.
|
|
413
|
+
* Only `query`/`mutation` handlers are recorded; `action(...)` is the intended
|
|
414
|
+
* home for `ctx.r2sql` and is skipped.
|
|
415
|
+
*/
|
|
416
|
+
interface R2sqlCallIR {
|
|
417
|
+
/** The accessed `ctx.r2sql` surface, e.g. `ctx.r2sql.query` / `ctx.r2sql.from`. */
|
|
418
|
+
callee: string;
|
|
419
|
+
/** Export binding name of the function performing the access. */
|
|
420
|
+
exportName: string;
|
|
421
|
+
/** Source file relative to the lunora dir, without extension (the api namespace). */
|
|
422
|
+
file: string;
|
|
423
|
+
/** Which procedure kind the access lives in — only `query`/`mutation` handlers are recorded. */
|
|
424
|
+
kind: "mutation" | "query";
|
|
425
|
+
/** 1-based line of the access, or `0` when unknown. */
|
|
426
|
+
line: number;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
387
429
|
* Per-procedure RLS usage snapshot, produced by `discoverRlsProcedures` for the
|
|
388
430
|
* `rls_uncovered_table` advisor lint. Structurally identical to
|
|
389
431
|
* `AdvisorRlsProcedure` (they share the same field set) so values pass straight
|
|
@@ -686,7 +728,7 @@ interface ProjectIR {
|
|
|
686
728
|
* pass straight through without conversion. Returns the findings; surfacing them
|
|
687
729
|
* (console, error overlay, studio Advisors table) is the caller's choice.
|
|
688
730
|
*/
|
|
689
|
-
declare const lintSchema: (schema: SchemaIR, queries?: ReadonlyArray<QueryReadIR>, inserts?: ReadonlyArray<InsertWriteIR>, authApiCalls?: ReadonlyArray<AuthApiCallIR>, rlsProcedures?: ReadonlyArray<RlsProcedureIR>, containers?: ReadonlyArray<ContainerIR>, workflows?: ReadonlyArray<WorkflowIR>, workflowCalls?: ReadonlyArray<WorkflowCallIR>, maskProcedures?: ReadonlyArray<MaskProcedureIR>, nondeterministicCalls?: ReadonlyArray<NondeterministicCallIR>, procedureProtections?: ReadonlyArray<ProcedureMiddlewareIR>, argumentValidators?: ReadonlyArray<ArgumentValidatorIR>, secretLiterals?: ReadonlyArray<SecretLiteralIR>, sqlInterpolations?: ReadonlyArray<SqlInterpolationIR>, adminRoutes?: ReadonlyArray<AdminRouteIR>) => Finding[];
|
|
731
|
+
declare const lintSchema: (schema: SchemaIR, queries?: ReadonlyArray<QueryReadIR>, inserts?: ReadonlyArray<InsertWriteIR>, authApiCalls?: ReadonlyArray<AuthApiCallIR>, rlsProcedures?: ReadonlyArray<RlsProcedureIR>, containers?: ReadonlyArray<ContainerIR>, workflows?: ReadonlyArray<WorkflowIR>, workflowCalls?: ReadonlyArray<WorkflowCallIR>, maskProcedures?: ReadonlyArray<MaskProcedureIR>, nondeterministicCalls?: ReadonlyArray<NondeterministicCallIR>, procedureProtections?: ReadonlyArray<ProcedureMiddlewareIR>, argumentValidators?: ReadonlyArray<ArgumentValidatorIR>, secretLiterals?: ReadonlyArray<SecretLiteralIR>, sqlInterpolations?: ReadonlyArray<SqlInterpolationIR>, adminRoutes?: ReadonlyArray<AdminRouteIR>, r2sqlCalls?: ReadonlyArray<R2sqlCallIR>) => Finding[];
|
|
690
732
|
/**
|
|
691
733
|
* Render advisor findings as a single multi-line string for console surfacing:
|
|
692
734
|
* a one-line summary header followed by one `[LEVEL] name: detail` line per
|
|
@@ -711,8 +753,14 @@ declare class CodegenDiagnosticError extends Error {
|
|
|
711
753
|
* ts-morph `Node`'s position in its source file.
|
|
712
754
|
*
|
|
713
755
|
* Message format: `@lunora/codegen: <detail> (<file>:<line>:<column>)`
|
|
756
|
+
*
|
|
757
|
+
* `meta` is merged onto the returned error for callers that also carry the
|
|
758
|
+
* project-wide `LunoraError` envelope (`code`/`name`/`status`) — it never
|
|
759
|
+
* touches `file`/`line`/`column`, and the error stays an instance of
|
|
760
|
+
* {@link CodegenDiagnosticError} so the Vite overlay's `instanceof` location
|
|
761
|
+
* lookup is unaffected.
|
|
714
762
|
*/
|
|
715
|
-
declare const diagnosticAt: (node: Node, detail: string) => CodegenDiagnosticError;
|
|
763
|
+
declare const diagnosticAt: (node: Node, detail: string, meta?: Record<string, unknown>) => CodegenDiagnosticError;
|
|
716
764
|
/**
|
|
717
765
|
* Discover `ctx.authApi.<method>(...)` (and bare `authApi.<method>(...)`) calls
|
|
718
766
|
* under the lunora source directory and attribute each to the exported function
|
|
@@ -803,6 +851,19 @@ declare const discoverNondeterministicCalls: (project: Project, lunoraDirectory:
|
|
|
803
851
|
* dropping the rest keeps the lint input small.
|
|
804
852
|
*/
|
|
805
853
|
declare const discoverQueries: (project: Project, lunoraDirectory: string) => QueryReadIR[];
|
|
854
|
+
/**
|
|
855
|
+
* Discover `ctx.r2sql` accesses lexically inside the handler body of every
|
|
856
|
+
* exported `query(...)` / `mutation(...)` registration under the lunora source
|
|
857
|
+
* directory — the `r2sql_outside_action` lint input. `action(...)` (and
|
|
858
|
+
* `stream(...)`) registrations are intentionally skipped: R2 SQL is the
|
|
859
|
+
* external, non-reactive surface that belongs in actions.
|
|
860
|
+
*
|
|
861
|
+
* Traversal is scoped to the handler node (not the whole declaration), mirroring
|
|
862
|
+
* `discoverNondeterministicCalls` — so a `ctx.r2sql` touch in a sibling helper
|
|
863
|
+
* outside the handler is not attributed to the query/mutation. One
|
|
864
|
+
* {@link R2sqlCallIR} is produced per access site.
|
|
865
|
+
*/
|
|
866
|
+
declare const discoverR2sqlCalls: (project: Project, lunoraDirectory: string) => R2sqlCallIR[];
|
|
806
867
|
declare const discoverRlsProcedures: (project: Project, lunoraDirectory: string) => RlsProcedureIR[];
|
|
807
868
|
/**
|
|
808
869
|
* Aggregate the schema-wide RLS metadata the studio's read-only inspector reads:
|
|
@@ -822,7 +883,7 @@ declare const discoverRlsMetadata: (project: Project, lunoraDirectory: string) =
|
|
|
822
883
|
* Load `<projectRoot>/lunora/schema.ts`, find `defineSchema({...})`, and
|
|
823
884
|
* return a structural IR. Throws if the file or call cannot be found.
|
|
824
885
|
*/
|
|
825
|
-
declare const discoverSchema: (project: Project, schemaPath: string) => SchemaIR;
|
|
886
|
+
declare const discoverSchema: (project: Project, schemaPath: string, projectRoot?: string) => SchemaIR;
|
|
826
887
|
/**
|
|
827
888
|
* Aggregate the schema-wide storage-rule metadata the studio's inspector reads:
|
|
828
889
|
* every statically-discovered `(bucket, on, prefix, procedure)` entry across all
|
|
@@ -877,6 +938,8 @@ interface EmitServerOptions {
|
|
|
877
938
|
hasPayments?: boolean;
|
|
878
939
|
/** A `lunora/` source uses `@lunora/pipelines` / `ctx.pipelines` — wires `ctx.pipelines` onto ActionCtx only. */
|
|
879
940
|
hasPipelines?: boolean;
|
|
941
|
+
/** A `lunora/` source uses `@lunora/r2sql` / `ctx.r2sql` — wires `ctx.r2sql` onto ActionCtx only. */
|
|
942
|
+
hasR2sql?: boolean;
|
|
880
943
|
schema?: SchemaIR;
|
|
881
944
|
storageRuleBuckets?: ReadonlyArray<string>;
|
|
882
945
|
/** The project depends on the `lunora` umbrella — import base packages via its subpaths. */
|
|
@@ -893,12 +956,13 @@ declare const emitServer: ({
|
|
|
893
956
|
hasKv,
|
|
894
957
|
hasPayments,
|
|
895
958
|
hasPipelines,
|
|
959
|
+
hasR2sql,
|
|
896
960
|
schema,
|
|
897
961
|
storageRuleBuckets,
|
|
898
962
|
useUmbrella,
|
|
899
963
|
workflows
|
|
900
964
|
}?: EmitServerOptions) => string;
|
|
901
|
-
declare const emitFunctions: (functions: ReadonlyArray<FunctionIR>, migrations?: ReadonlyArray<MigrationIR
|
|
965
|
+
declare const emitFunctions: (functions: ReadonlyArray<FunctionIR>, migrations?: ReadonlyArray<MigrationIR>, useUmbrella?: boolean) => string;
|
|
902
966
|
/**
|
|
903
967
|
* Storage-column map per table for the file browser: `{ table: [field, …] }` for
|
|
904
968
|
* every field declared `v.storage(...)` (unwrapping `v.optional(...)`). The
|
|
@@ -916,7 +980,7 @@ declare const emitFunctions: (functions: ReadonlyArray<FunctionIR>, migrations?:
|
|
|
916
980
|
* `containers[].class_name` to be exported by the deployed worker. Returns ""
|
|
917
981
|
* when the project declares no containers (the file is not written then).
|
|
918
982
|
*/
|
|
919
|
-
declare const emitContainers: (containers: ReadonlyArray<ContainerIR
|
|
983
|
+
declare const emitContainers: (containers: ReadonlyArray<ContainerIR>, jurisdiction?: JurisdictionIR) => string;
|
|
920
984
|
/**
|
|
921
985
|
* Emit `_generated/workflows.ts` — one `WorkflowEntrypoint` class per
|
|
922
986
|
* `defineWorkflow` export, each a thin subclass of `LunoraWorkflow`
|
|
@@ -941,6 +1005,8 @@ interface EmitShardOptions {
|
|
|
941
1005
|
/** A `lunora/` source reads `ctx.kv` — wires `ctx.kv` onto every ctx. */
|
|
942
1006
|
hasKv?: boolean;
|
|
943
1007
|
hasPayments?: boolean;
|
|
1008
|
+
/** A `lunora/` source reads `ctx.r2sql` (R2 SQL) — wires `ctx.r2sql` onto the ActionCtx only. */
|
|
1009
|
+
hasR2sql?: boolean;
|
|
944
1010
|
maskMetadata?: MaskMetadataIR;
|
|
945
1011
|
rlsMetadata?: RlsMetadataIR;
|
|
946
1012
|
schema: SchemaIR;
|
|
@@ -960,6 +1026,7 @@ declare const emitShard: ({
|
|
|
960
1026
|
hasImages,
|
|
961
1027
|
hasKv,
|
|
962
1028
|
hasPayments,
|
|
1029
|
+
hasR2sql,
|
|
963
1030
|
maskMetadata,
|
|
964
1031
|
rlsMetadata,
|
|
965
1032
|
schema,
|
|
@@ -1049,6 +1116,8 @@ interface EmitAppOptions {
|
|
|
1049
1116
|
hasKv: boolean;
|
|
1050
1117
|
/** App uses `@lunora/payment` / `ctx.payments` → emit `.payment()`. */
|
|
1051
1118
|
hasPayments: boolean;
|
|
1119
|
+
/** App uses `@lunora/r2sql` / `ctx.r2sql` → emit `.r2sql()`. */
|
|
1120
|
+
hasR2sql: boolean;
|
|
1052
1121
|
/** App imports `@lunora/scheduler` / declares crons → emit `.scheduler()`. */
|
|
1053
1122
|
hasScheduler: boolean;
|
|
1054
1123
|
/** App uses `@lunora/storage` → emit `.storage()` (DO `ctx.storage` + studio file browser). */
|
|
@@ -1057,6 +1126,8 @@ interface EmitAppOptions {
|
|
|
1057
1126
|
hasVectors: boolean;
|
|
1058
1127
|
/** App declares Cloudflare Workflows (`defineWorkflow`) → wire `options.workflowsClient` so the studio's workflow-instance proxy can reach the CF REST API. */
|
|
1059
1128
|
hasWorkflow: boolean;
|
|
1129
|
+
/** Schema declares `.jurisdiction("…")` → pin every DO the worker reaches (shards, fan-out, scheduler, containers) to the Cloudflare data-residency jurisdiction. */
|
|
1130
|
+
jurisdiction?: JurisdictionIR;
|
|
1060
1131
|
/** Project depends on the unscoped `lunorash` umbrella → import the runtime via `lunorash/runtime` instead of `@lunora/runtime`. */
|
|
1061
1132
|
useUmbrella: boolean;
|
|
1062
1133
|
/** An OpenAPI spec is emitted (`openapi.ts`) → wire `openApiSpec` into the worker. */
|
|
@@ -1201,6 +1272,19 @@ interface TableSnapshot {
|
|
|
1201
1272
|
}
|
|
1202
1273
|
/** The committed baseline — a deterministic structural view of the whole schema. */
|
|
1203
1274
|
interface SchemaSnapshot {
|
|
1275
|
+
/**
|
|
1276
|
+
* Cloudflare DO data-residency jurisdiction declared via `.jurisdiction("…")`,
|
|
1277
|
+
* or absent. Tracked because changing it strands all existing Durable Object
|
|
1278
|
+
* data (a DO name maps to a different ID per jurisdiction). Optional, so old
|
|
1279
|
+
* baselines written before this field parse cleanly (absent ⇒ undefined).
|
|
1280
|
+
*
|
|
1281
|
+
* Typed as a plain `string` (not the authoring union) on purpose: this is
|
|
1282
|
+
* STORED data that a newer Lunora may have written with a jurisdiction this
|
|
1283
|
+
* version doesn't yet know. Preserving the raw value keeps the breaking
|
|
1284
|
+
* `changedJurisdiction` diff correct under a downgrade — coercing an unknown
|
|
1285
|
+
* value to `undefined` would fail OPEN and hide the most destructive change.
|
|
1286
|
+
*/
|
|
1287
|
+
jurisdiction?: string;
|
|
1204
1288
|
/** Sorted list of every declared `defineMigration` id at capture time. */
|
|
1205
1289
|
migrationIds: ReadonlyArray<string>;
|
|
1206
1290
|
/** Table name → {@link TableSnapshot}, keys sorted for stable serialization. */
|
|
@@ -1214,7 +1298,7 @@ interface DriftChange {
|
|
|
1214
1298
|
/** Human-readable, actionable description (used in the gate message). */
|
|
1215
1299
|
summary: string;
|
|
1216
1300
|
/** A machine-readable change discriminator. */
|
|
1217
|
-
type: "addedIndex" | "addedOptionalField" | "addedRelation" | "addedRequiredField" | "addedTable" | "changedFieldKind" | "changedIndex" | "changedShardMode" | "fieldOptionalToRequired" | "fieldRequiredToOptional" | "removedField" | "removedIndex" | "removedRelation" | "removedTable";
|
|
1301
|
+
type: "addedIndex" | "addedOptionalField" | "addedRelation" | "addedRequiredField" | "addedTable" | "changedJurisdiction" | "changedFieldKind" | "changedIndex" | "changedShardMode" | "fieldOptionalToRequired" | "fieldRequiredToOptional" | "removedField" | "removedIndex" | "removedRelation" | "removedTable";
|
|
1218
1302
|
}
|
|
1219
1303
|
/** The result of diffing two snapshots: every classified change. */
|
|
1220
1304
|
interface SchemaDrift {
|
|
@@ -1316,6 +1400,11 @@ declare const refreshCodegenProject: (project: Project, lunoraDirectory: string)
|
|
|
1316
1400
|
* Top-level codegen entry. Parses `<projectRoot>/lunora/schema.ts` and every
|
|
1317
1401
|
* function file under `<projectRoot>/lunora/`, then writes
|
|
1318
1402
|
* `_generated/{api,server,dataModel}.ts` next to them.
|
|
1403
|
+
*
|
|
1404
|
+
* When `LUNORA_CODEGEN_TIMING` is set (truthy), a single diagnostic summary
|
|
1405
|
+
* line is written to stderr with the total wall time and the discovery-vs-emit
|
|
1406
|
+
* split — opt-in instrumentation that is otherwise zero-cost and side-effect-free
|
|
1407
|
+
* on the returned {@link CodegenResult}.
|
|
1319
1408
|
*/
|
|
1320
1409
|
declare const runCodegen: (options: CodegenOptions) => CodegenResult;
|
|
1321
1410
|
interface CodegenOptions {
|
|
@@ -1470,4 +1559,4 @@ declare const validatorIrToJsonSchema: (validator: ValidatorIR) => JsonSchema;
|
|
|
1470
1559
|
*/
|
|
1471
1560
|
declare const LUNORA_ERROR_CODES: ReadonlyArray<string>;
|
|
1472
1561
|
declare const VERSION = "0.0.0";
|
|
1473
|
-
export { type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, type FieldSnapshot, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type MaskProcedureIR, type MigrationIR, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type ProjectIR, type QueryReadIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverNondeterministicCalls, discoverQueries, discoverRlsMetadata, discoverRlsProcedures, discoverSchema, discoverStorageRulesMetadata, discoverWorkflows, emitApi, emitApp, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, refreshCodegenProject, runCodegen, schemaFromIr, serializeSchemaSnapshot, validatorIrToJsonSchema };
|
|
1562
|
+
export { type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, type FieldSnapshot, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type MaskProcedureIR, type MigrationIR, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type ProjectIR, type QueryReadIR, type R2sqlCallIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverNondeterministicCalls, discoverQueries, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSchema, discoverStorageRulesMetadata, discoverWorkflows, emitApi, emitApp, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, refreshCodegenProject, runCodegen, schemaFromIr, serializeSchemaSnapshot, validatorIrToJsonSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
export { formatAdvisories, lintSchema } from './packem_shared/
|
|
2
|
-
export { CodegenDiagnosticError, diagnosticAt } from './packem_shared/CodegenDiagnosticError-
|
|
3
|
-
export { default as discoverAuthApiCalls } from './packem_shared/discoverAuthApiCalls-
|
|
4
|
-
export { CONTAINERS_FILENAME, discoverContainers } from './packem_shared/CONTAINERS_FILENAME-
|
|
5
|
-
export { default as discoverCrons } from './packem_shared/discoverCrons-
|
|
6
|
-
export { discoverFunctions } from './packem_shared/discoverFunctions-
|
|
7
|
-
export { default as discoverHttpRoutes } from './packem_shared/discoverHttpRoutes-
|
|
8
|
-
export { default as discoverInserts } from './packem_shared/discoverInserts-
|
|
9
|
-
export { default as discoverMaskProcedures } from './packem_shared/discoverMaskProcedures-
|
|
10
|
-
export { default as discoverMigrations } from './packem_shared/discoverMigrations-
|
|
11
|
-
export { default as discoverNondeterministicCalls } from './packem_shared/discoverNondeterministicCalls-
|
|
12
|
-
export { default as discoverQueries } from './packem_shared/discoverQueries-
|
|
13
|
-
export {
|
|
14
|
-
export { default as
|
|
15
|
-
export { default as
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
1
|
+
export { formatAdvisories, lintSchema } from './packem_shared/formatAdvisories-8NIv1k0I.mjs';
|
|
2
|
+
export { CodegenDiagnosticError, diagnosticAt } from './packem_shared/CodegenDiagnosticError-DeblMkzO.mjs';
|
|
3
|
+
export { default as discoverAuthApiCalls } from './packem_shared/discoverAuthApiCalls-CoirYbg6.mjs';
|
|
4
|
+
export { CONTAINERS_FILENAME, discoverContainers } from './packem_shared/CONTAINERS_FILENAME-DlP6YM_Q.mjs';
|
|
5
|
+
export { default as discoverCrons } from './packem_shared/discoverCrons-Cev7RRAf.mjs';
|
|
6
|
+
export { discoverFunctions } from './packem_shared/discoverFunctions-BWMczzBx.mjs';
|
|
7
|
+
export { default as discoverHttpRoutes } from './packem_shared/discoverHttpRoutes-CfP6cMzt.mjs';
|
|
8
|
+
export { default as discoverInserts } from './packem_shared/discoverInserts-C7zxXkUf.mjs';
|
|
9
|
+
export { default as discoverMaskProcedures } from './packem_shared/discoverMaskProcedures-Cm81kwrb.mjs';
|
|
10
|
+
export { default as discoverMigrations } from './packem_shared/discoverMigrations-Bi5nJ0mJ.mjs';
|
|
11
|
+
export { default as discoverNondeterministicCalls } from './packem_shared/discoverNondeterministicCalls-C4M8AXmQ.mjs';
|
|
12
|
+
export { default as discoverQueries } from './packem_shared/discoverQueries-B0wGT-xe.mjs';
|
|
13
|
+
export { default as discoverR2sqlCalls } from './packem_shared/discoverR2sqlCalls-BVNMd428.mjs';
|
|
14
|
+
export { discoverRlsMetadata, default as discoverRlsProcedures } from './packem_shared/discoverRlsMetadata-BS9GOGC5.mjs';
|
|
15
|
+
export { default as discoverSchema } from './packem_shared/discoverSchema-BnWHHJ4T.mjs';
|
|
16
|
+
export { default as discoverStorageRulesMetadata } from './packem_shared/discoverStorageRulesMetadata-Da8BKXcI.mjs';
|
|
17
|
+
export { WORKFLOWS_FILENAME, discoverWorkflows } from './packem_shared/WORKFLOWS_FILENAME-D62dcBGg.mjs';
|
|
18
|
+
export { GENERATED_HEADER, emitApi, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers } from './packem_shared/GENERATED_HEADER-BiFXNUvo.mjs';
|
|
19
|
+
export { emitApp } from './packem_shared/emitApp-KfMaKXWe.mjs';
|
|
20
|
+
export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-Cu3mZl-8.mjs';
|
|
21
|
+
export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-B4i9Qp3v.mjs';
|
|
22
|
+
export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-Bvv7qa_u.mjs';
|
|
23
|
+
export { SCHEMA_SNAPSHOT_VERSION, SchemaSnapshotParseError, buildSchemaSnapshot, diffSchemaSnapshots, evaluateSchemaDrift, parseSchemaSnapshot, serializeSchemaSnapshot } from './packem_shared/SCHEMA_SNAPSHOT_VERSION-wWGP2_5E.mjs';
|
|
23
24
|
export { schemaFromIr } from './packem_shared/schemaFromIr-DTYsLBaA.mjs';
|
|
24
25
|
export { LUNORA_ERROR_CODES, validatorIrToJsonSchema } from './packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs';
|
|
25
26
|
|
package/dist/packem_shared/{CONTAINERS_FILENAME-0K-pjNb8.mjs → CONTAINERS_FILENAME-DlP6YM_Q.mjs}
RENAMED
|
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { containerClassName, containerBindingName, normalizeContainerImage } from '@lunora/container';
|
|
4
4
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
5
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
5
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DeblMkzO.mjs';
|
|
6
6
|
|
|
7
7
|
const CONTAINERS_FILENAME = "containers.ts";
|
|
8
8
|
const isDefineContainer = (identifier) => {
|
|
@@ -10,13 +10,14 @@ class CodegenDiagnosticError extends Error {
|
|
|
10
10
|
this.column = column;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
const diagnosticAt = (node, detail) => {
|
|
13
|
+
const diagnosticAt = (node, detail, meta) => {
|
|
14
14
|
const sourceFile = node.getSourceFile();
|
|
15
15
|
const file = sourceFile.getFilePath();
|
|
16
16
|
const line = node.getStartLineNumber();
|
|
17
17
|
const { column } = sourceFile.getLineAndColumnAtPos(node.getStart());
|
|
18
18
|
const message = `@lunora/codegen: ${detail} (${file}:${line.toString()}:${column.toString()})`;
|
|
19
|
-
|
|
19
|
+
const error = new CodegenDiagnosticError(message, file, line, column);
|
|
20
|
+
return meta ? Object.assign(error, meta) : error;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
export { CodegenDiagnosticError, diagnosticAt };
|