litedbmodel 2.0.1 → 2.0.2
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/scp/catalog.d.ts +4 -1
- package/dist/scp/catalog.d.ts.map +1 -1
- package/dist/scp/catalog.js +5 -1
- package/dist/scp/catalog.js.map +1 -1
- package/dist/scp/codegen.d.ts +118 -24
- package/dist/scp/codegen.d.ts.map +1 -1
- package/dist/scp/codegen.js +360 -33
- package/dist/scp/codegen.js.map +1 -1
- package/dist/scp/coltype.d.ts +41 -0
- package/dist/scp/coltype.d.ts.map +1 -0
- package/dist/scp/coltype.js +188 -0
- package/dist/scp/coltype.js.map +1 -0
- package/dist/scp/dialect.d.ts +12 -3
- package/dist/scp/dialect.d.ts.map +1 -1
- package/dist/scp/dialect.js +12 -3
- package/dist/scp/dialect.js.map +1 -1
- package/dist/scp/fragment/assemble.d.ts.map +1 -1
- package/dist/scp/fragment/assemble.js +10 -2
- package/dist/scp/fragment/assemble.js.map +1 -1
- package/dist/scp/fragment/compile-pg.js +4 -4
- package/dist/scp/index.cjs +8132 -816
- package/dist/scp/index.d.ts +3 -1
- package/dist/scp/index.d.ts.map +1 -1
- package/dist/scp/index.js +17 -6
- package/dist/scp/index.js.map +1 -1
- package/dist/scp/index.mjs +660 -81
- package/dist/scp/makesql/compile-select.d.ts +8 -1
- package/dist/scp/makesql/compile-select.d.ts.map +1 -1
- package/dist/scp/makesql/compile-select.js +1 -1
- package/dist/scp/makesql/compile-select.js.map +1 -1
- package/dist/scp/makesql/outtype.d.ts +44 -0
- package/dist/scp/makesql/outtype.d.ts.map +1 -0
- package/dist/scp/makesql/outtype.js +197 -0
- package/dist/scp/makesql/outtype.js.map +1 -0
- package/dist/scp/makesql/static-bundle.d.ts +3 -1
- package/dist/scp/makesql/static-bundle.d.ts.map +1 -1
- package/dist/scp/makesql/static-bundle.js +95 -6
- package/dist/scp/makesql/static-bundle.js.map +1 -1
- package/dist/scp/makesql/tx.d.ts +1 -1
- package/dist/scp/makesql/tx.d.ts.map +1 -1
- package/dist/scp/makesql/tx.js +48 -3
- package/dist/scp/makesql/tx.js.map +1 -1
- package/dist/scp/makesql/writeouttype.d.ts +66 -0
- package/dist/scp/makesql/writeouttype.d.ts.map +1 -0
- package/dist/scp/makesql/writeouttype.js +195 -0
- package/dist/scp/makesql/writeouttype.js.map +1 -0
- package/dist/scp/runtime.d.ts +14 -3
- package/dist/scp/runtime.d.ts.map +1 -1
- package/dist/scp/runtime.js +28 -9
- package/dist/scp/runtime.js.map +1 -1
- package/docs/proposal/litedbmodel-v2-scp-architecture.md +51 -0
- package/package.json +2 -2
package/dist/scp/catalog.d.ts
CHANGED
|
@@ -62,7 +62,10 @@ export declare const WRITE_CATALOG_NAMES: readonly CatalogName[];
|
|
|
62
62
|
/**
|
|
63
63
|
* The dynamic per-field write-port families (`<group>.<field>` — the flattened record
|
|
64
64
|
* convention; longest-prefix wins). A `values.<field>` (Insert) or `set.<field>`
|
|
65
|
-
* (Update) port carries the field's Expression IR value
|
|
65
|
+
* (Update) port carries the field's Expression IR value; a `sqlCast.<field>` port carries
|
|
66
|
+
* the field's PostgreSQL cast type (a literal string, e.g. `jsonb`/`uuid`/`int[]`) that drives
|
|
67
|
+
* the v1 per-column `?::<sqlCast>` on Postgres (`DBModel._insert`/`_update`). `sqlCast.` ports are
|
|
68
|
+
* INERT on MySQL/SQLite (v1's dialect-aware cast formatter is identity there).
|
|
66
69
|
*/
|
|
67
70
|
export declare const WRITE_PORT_FAMILIES: readonly string[];
|
|
68
71
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/scp/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAA0B,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAmB,MAAM,oBAAoB,CAAC;AAE9H;;;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AAE,GAAG,IAAI,CA4BhF;AAGD,mFAAmF;AACnF,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,CAEzE"}
|
package/dist/scp/catalog.js
CHANGED
|
@@ -167,11 +167,15 @@ const WRITE_SET = new Set(exports.WRITE_CATALOG_NAMES);
|
|
|
167
167
|
/**
|
|
168
168
|
* The dynamic per-field write-port families (`<group>.<field>` — the flattened record
|
|
169
169
|
* convention; longest-prefix wins). A `values.<field>` (Insert) or `set.<field>`
|
|
170
|
-
* (Update) port carries the field's Expression IR value
|
|
170
|
+
* (Update) port carries the field's Expression IR value; a `sqlCast.<field>` port carries
|
|
171
|
+
* the field's PostgreSQL cast type (a literal string, e.g. `jsonb`/`uuid`/`int[]`) that drives
|
|
172
|
+
* the v1 per-column `?::<sqlCast>` on Postgres (`DBModel._insert`/`_update`). `sqlCast.` ports are
|
|
173
|
+
* INERT on MySQL/SQLite (v1's dialect-aware cast formatter is identity there).
|
|
171
174
|
*/
|
|
172
175
|
exports.WRITE_PORT_FAMILIES = [
|
|
173
176
|
'values.',
|
|
174
177
|
'set.',
|
|
178
|
+
'sqlCast.',
|
|
175
179
|
];
|
|
176
180
|
/**
|
|
177
181
|
* The emitter's catalog validation (loud; a violation is a BUILD error), mirrored from
|
package/dist/scp/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/scp/catalog.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;AA2HH,oCAEC;
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/scp/catalog.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;AA2HH,oCAEC;AAsDD,8DA4BC;AAYD,o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,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,CAAC,MAAM,aAAa,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChJ,CAAC;AACH,CAAC;AAMD;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,SAAoB;IACvD,OAAO,IAAA,2CAAsB,EAAC,SAAS,EAAE,2BAAmB,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;AACpG,CAAC"}
|
package/dist/scp/codegen.d.ts
CHANGED
|
@@ -1,25 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* litedbmodel v2 SCP — mode-3 codegen (WS7f, #35; spec §9 exec-mode 3 / §10 / §11; makeSQL flip,
|
|
3
|
-
* epic #43/#45 Phase B).
|
|
3
|
+
* epic #43/#45 Phase B; #60 milestone 1 — typed-NATIVE READ codegen, bc#77/#90).
|
|
4
4
|
*
|
|
5
5
|
* The static-codegen execution mode ("Codegen・静的(全言語)— IR → 各言語ソース生成 runtime≈0,
|
|
6
6
|
* 入力は可搬IRのみ, bc#13 共有 generator に SQL catalog を供給" — spec §9). It takes a §8 STATIC
|
|
7
7
|
* makeSQL {@link SqlBundle} and, per target language, emits:
|
|
8
8
|
*
|
|
9
|
-
* 1. **Behavior module** — bc's SHARED generator
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `
|
|
9
|
+
* 1. **Behavior module** — bc's SHARED generator run over the bundle's portable IR through bc's
|
|
10
|
+
* de-interpreted, RUNTIME-FREE emitter. For a READ bundle covered by bc's typed-NATIVE
|
|
11
|
+
* endpoint (`rust-typed-native` / `go-typed-native`, bc#77/#90 — the 1.0 read de-box: fully
|
|
12
|
+
* concrete `HandlerNR<Comp>`/`InNR<Comp>`/`PortsNR<Comp><node>`/`RawRowNR<Comp><node>` structs,
|
|
13
|
+
* ZERO boxed `Value`/`RawValue`, ZERO IR baked into the module), the CODEGEN-ONLY lowering
|
|
14
|
+
* below ({@link lowerReadGraphForTypedNative}) makes the read's shape structurally ELIGIBLE
|
|
15
|
+
* (splits the surrogate `__scope` boxed-obj port into individual scalar ref ports + types the
|
|
16
|
+
* component's `inputPorts` from the schema) before handing it to bc. For a WRITE bundle, or a
|
|
17
|
+
* READ shape typed-native does not (yet) cover, codegen uses bc's existing de-interpreted
|
|
18
|
+
* STRAIGHT-LINE endpoint (`<lang>-straightline`, bc#75) — see {@link typedEmitterFor}.
|
|
13
19
|
* 2. **SQL catalog companion** — the pure-JSON STATIC makeSQL catalog (per-node statement
|
|
14
20
|
* templates / relations / transaction). A codegen consumer's thin SQL layer reads it to
|
|
15
21
|
* evaluate skip + value-specs → assemble → render → execute (identically to the mode-2 runtime).
|
|
16
22
|
*
|
|
17
|
-
* ##
|
|
23
|
+
* ## #60 milestone 1 scope (CODEGEN-PATH ONLY)
|
|
18
24
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
25
|
+
* This lowering exists SOLELY for the codegen emitter call — it builds a NEW, separate
|
|
26
|
+
* `ComponentGraphIR` from the bundle's `readGraph`; it never mutates `SqlBundle`/`ReadGraph` and
|
|
27
|
+
* never touches the shared `readGraph`/`executeReadGraph` the ir/interpret exec surface (and the
|
|
28
|
+
* frozen conformance corpus) depend on. Those keep consuming the ORIGINAL boxed-`__scope`-port
|
|
29
|
+
* surrogate IR ({@link bundleToPortableIR}), completely unaffected by anything in this file.
|
|
30
|
+
*
|
|
31
|
+
* ## Behavior-identical to the thin-runtime (mode-2), by construction
|
|
32
|
+
*
|
|
33
|
+
* The generated module is observationally equivalent to `runBehavior` (same values, same emitted
|
|
34
|
+
* op sequence, same Failure code/message), and the companion IS the bundle, so a codegen runtime
|
|
35
|
+
* that drives it follows the IDENTICAL static-makeSQL render/execute path {@link executeBundle}
|
|
36
|
+
* uses — SQL text (all dialects) and results are identical, not approximately equal. The TS leg
|
|
37
|
+
* PROVES this by executing via the artifact and asserting exact equality vs {@link executeBundle}
|
|
38
|
+
* (see {@link codegenExecuteBundleForTest}).
|
|
39
|
+
*
|
|
40
|
+
* ## No literal-bake / no boxed fallback
|
|
41
|
+
*
|
|
42
|
+
* typed-native fails CLOSED on an uncovered shape (a `map`/`cond` relation kind it does not cover,
|
|
43
|
+
* or an input head that cannot lower to a native scalar — e.g. an IN-list's array-typed head).
|
|
44
|
+
* Such a shape is NOT silently regenerated on the boxed `-typed`/`-typed-raw` emitter — it THROWS,
|
|
45
|
+
* naming the exact gap, so it can be tracked as a bc coverage gap (bc#86) rather than masked.
|
|
23
46
|
*/
|
|
24
47
|
import { type ComponentGraphIR, type GeneratedModule, type Scope, type Value } from 'behavior-contracts';
|
|
25
48
|
import type { SqlBundle, SqliteDb } from './runtime';
|
|
@@ -27,13 +50,41 @@ import type { DialectName } from './dialect';
|
|
|
27
50
|
import type { RelationOp } from './relation';
|
|
28
51
|
import type { ReadGraph } from './makesql/static-bundle';
|
|
29
52
|
import type { TransactionPlan } from './makesql/tx';
|
|
53
|
+
import { type ColumnTypeResolver } from './coltype';
|
|
30
54
|
/**
|
|
31
55
|
* The languages litedbmodel mode-3 codegen supports — exactly the set bc's shared generator
|
|
32
|
-
* registers (bc#13 SP1 typescript/python + SP2 go/rust/php). {@link
|
|
56
|
+
* registers (bc#13 SP1 typescript/python + SP2 go/rust/php). {@link codegenEmitterFor}
|
|
33
57
|
* verifies against the LIVE registry so a bc capability drift is caught loudly.
|
|
34
58
|
*/
|
|
35
59
|
export declare const CODEGEN_LANGUAGES: readonly ["typescript", "python", "go", "rust", "php"];
|
|
36
60
|
export type CodegenLanguage = (typeof CODEGEN_LANGUAGES)[number];
|
|
61
|
+
/**
|
|
62
|
+
* The bc READ emitter litedbmodel drives for each codegen target (#60 milestone 1): the
|
|
63
|
+
* **de-interpreted, RUNTIME-FREE typed-NATIVE** endpoint (bc#77/#90) for go/rust — ZERO boxed
|
|
64
|
+
* `Value`/`RawValue`, ZERO IR baked into the module, concrete `HandlerNR`/`InNR`/`PortsNR`/
|
|
65
|
+
* `RawRowNR` structs. There is **NO literal / straight-line / boxed-typed fallback** for a read: an
|
|
66
|
+
* unspec'd fallback is INVALID (it silently swallows the "this shape can't be natively codegen'd"
|
|
67
|
+
* signal) — a read shape typed-native does not cover MUST fail loudly at generation, naming the gap
|
|
68
|
+
* (report it as a bc#86 coverage gap), never silently regenerate on `-typed`/`-typed-raw`.
|
|
69
|
+
*
|
|
70
|
+
* `-typed-raw` (bc#76, the boxed-wire intermediate) and `-typed` (the boxed-Value intermediate) are
|
|
71
|
+
* RETIRED from litedbmodel's codegen surface entirely (#60 milestone 1) — typed-native supersedes
|
|
72
|
+
* both for every read shape it covers (bc#77/#90: single-componentRef reads AND the `map`
|
|
73
|
+
* relationKind:single|connection shape, bc#86 part 2).
|
|
74
|
+
*
|
|
75
|
+
* - ts: **no typed-native endpoint registered yet** (bc has not shipped `typescript-typed-native`).
|
|
76
|
+
* TS stays on its existing `typescript-typed` (boxed) endpoint until bc adds one — a DECLARED,
|
|
77
|
+
* reported gap (not silently mirrored to go/rust's retirement), tracked as a bc#77 TS follow-up.
|
|
78
|
+
* - **python/php: NOT present.** bc registers no de-boxed typed endpoint for them (capability limit).
|
|
79
|
+
* litedbmodel does NOT substitute the literal (≈ir) emitter — that would be an unspec'd fallback.
|
|
80
|
+
* Codegen for py/php is a bc capability gap that ERRORS (ESCALATE to bc), never a silent literal.
|
|
81
|
+
*
|
|
82
|
+
* WRITES (batchInsert / gate-first tx) are NOT reads — they are NOT routed through this table at
|
|
83
|
+
* all (#60 milestone 1): a write bundle stays on the existing write/tx execution path
|
|
84
|
+
* (`executeTransactionBundle` / the native adapter's hand-written tx mirror), never a codegen
|
|
85
|
+
* module, boxed or typed-raw. {@link generateCodegenArtifact} throws if asked to codegen a write.
|
|
86
|
+
*/
|
|
87
|
+
export declare const CODEGEN_EMITTER: Partial<Record<CodegenLanguage, string>>;
|
|
37
88
|
/**
|
|
38
89
|
* The SQL catalog companion (spec §9): the STATIC makeSQL bundle fields the codegen consumer's
|
|
39
90
|
* thin SQL layer reads to evaluate + render + execute. Pure JSON — round-trips losslessly.
|
|
@@ -55,39 +106,82 @@ export interface SqlCatalogCompanion {
|
|
|
55
106
|
readonly relations: Record<string, RelationOp>;
|
|
56
107
|
/** Derived gate-first write-time-relations transaction plan (spec §6/§8), for a Command bundle. */
|
|
57
108
|
readonly transaction?: TransactionPlan;
|
|
109
|
+
/**
|
|
110
|
+
* WRITE bundles: the codegen typed-de-box `outputType` (the TransactionResult typed shape). Rides
|
|
111
|
+
* the companion so a codegen consumer that reassembles the bundle from the artifact round-trips it
|
|
112
|
+
* losslessly (the read de-box carries its outType/outputType inside `readGraph.ir` instead).
|
|
113
|
+
*/
|
|
114
|
+
readonly outputType?: unknown;
|
|
58
115
|
}
|
|
59
116
|
/** The full codegen artifact for one bundle × one language. */
|
|
60
117
|
export interface CodegenArtifact {
|
|
61
118
|
/** The target language. */
|
|
62
119
|
readonly language: CodegenLanguage;
|
|
63
|
-
/** The generated behavior module (bc's
|
|
120
|
+
/** The generated behavior module (bc's SHARED STRAIGHT-LINE generator output — real static code). */
|
|
64
121
|
readonly module: GeneratedModule;
|
|
65
122
|
/** The SQL catalog companion sidecar (the STATIC makeSQL execution catalog). */
|
|
66
123
|
readonly companion: SqlCatalogCompanion;
|
|
67
|
-
/** The portable IR baked into {@link module}. */
|
|
68
|
-
readonly ir: ComponentGraphIR;
|
|
69
124
|
/** The originating bundle (so the equivalence leg re-executes the SAME static bundle). */
|
|
70
125
|
readonly bundle: SqlBundle;
|
|
71
126
|
}
|
|
72
127
|
/**
|
|
73
128
|
* The portable {@link ComponentGraphIR} view of a §8 bundle: a read bundle's surrogate IR (each
|
|
74
|
-
* SQL node → a `makeSQL` node), or the single `makeSQL` component IR for a write.
|
|
75
|
-
*
|
|
129
|
+
* SQL node → a `makeSQL` node), or the single `makeSQL` component IR for a write. This is the
|
|
130
|
+
* ORIGINAL boxed-`__scope`-port form the ir/interpret exec surface's `executeReadGraph` also
|
|
131
|
+
* consumes (via `bundle.readGraph.ir` directly) — {@link generateCodegenArtifact} does NOT use
|
|
132
|
+
* this for a READ bundle (it uses the codegen-only lowered form, {@link lowerReadGraphForTypedNative});
|
|
133
|
+
* this function is kept for callers that want the untouched portable IR (e.g. diagnostics, the
|
|
134
|
+
* write path, or a future straight-line fallback caller).
|
|
76
135
|
*/
|
|
77
136
|
export declare function bundleToPortableIR(bundle: SqlBundle): ComponentGraphIR;
|
|
137
|
+
/** A head could not be typed for typed-native codegen — the read is NOT typed-native-coverable. */
|
|
138
|
+
export declare class TypedNativeCoverageError extends Error {
|
|
139
|
+
readonly component: string;
|
|
140
|
+
readonly reasons: readonly string[];
|
|
141
|
+
constructor(component: string, reasons: readonly string[]);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Lower a read bundle's surrogate `ComponentGraphIR` into a NEW, CODEGEN-ONLY IR eligible for bc's
|
|
145
|
+
* typed-native endpoint (#60 milestone 1): split the single `__scope: {obj:{...}}` boxed port into
|
|
146
|
+
* individual scalar `{ref:[head]}` ports, and type the component's `inputPorts` from the schema
|
|
147
|
+
* (via {@link deriveHeadTypesFromStatements}). Throws {@link TypedNativeCoverageError} if any
|
|
148
|
+
* referenced head cannot be natively typed (e.g. an IN-list's array head) — NO silent `unknown`
|
|
149
|
+
* port, NO fallback. Does NOT mutate `bundle`/`bundle.readGraph` (a fresh IR object is returned);
|
|
150
|
+
* the ir/interpret exec surface's `executeReadGraph` keeps consuming the ORIGINAL `readGraph.ir`.
|
|
151
|
+
*
|
|
152
|
+
* Scope: bc's typed-native predicate itself still governs `map`/`cond`/relationKind/policy
|
|
153
|
+
* coverage (this lowering does not special-case those — `generateModule` fails closed on them with
|
|
154
|
+
* its own detailed diagnostic, which this function does not need to duplicate).
|
|
155
|
+
*/
|
|
156
|
+
export declare function lowerReadGraphForTypedNative(readGraph: ReadGraph, resolveColumnType: ColumnTypeResolver): ComponentGraphIR;
|
|
157
|
+
/**
|
|
158
|
+
* Resolve the READ codegen emitter for a target language, or throw. No fallback: a language
|
|
159
|
+
* without a registered endpoint is a bc capability gap that fails LOUDLY (never a silent
|
|
160
|
+
* substitution of the literal/interpreter/boxed emitter — an unspec'd fallback is invalid).
|
|
161
|
+
*/
|
|
162
|
+
export declare function typedEmitterFor(language: string, registered: readonly string[]): string;
|
|
78
163
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
164
|
+
* Shape-INDEPENDENT emitter resolution — identical to {@link typedEmitterFor} now that there is
|
|
165
|
+
* exactly one READ endpoint per language (kept as a distinct export for callers that historically
|
|
166
|
+
* used the shape-independent form; both resolve the SAME table).
|
|
81
167
|
*/
|
|
82
|
-
export declare function
|
|
168
|
+
export declare function codegenEmitterFor(language: string, registered: readonly string[]): string;
|
|
83
169
|
/**
|
|
84
|
-
* Generate the mode-3 codegen artifact for ONE §8 bundle in ONE target language
|
|
85
|
-
*
|
|
86
|
-
*
|
|
170
|
+
* Generate the mode-3 READ codegen artifact for ONE §8 READ bundle in ONE target language. For a
|
|
171
|
+
* typed-NATIVE target (go/rust, bc#77/#90), lowers the bundle's surrogate read graph into the
|
|
172
|
+
* typed-native-eligible IR ({@link lowerReadGraphForTypedNative}) first — REAL static native
|
|
173
|
+
* source, RUNTIME-FREE, no baked-IR interpret path. For any OTHER registered endpoint (currently
|
|
174
|
+
* only TS's boxed `typescript-typed`, which has no typed-native counterpart yet), the ORIGINAL
|
|
175
|
+
* portable IR ({@link bundleToPortableIR}) is used unchanged — the lowering is typed-native-only
|
|
176
|
+
* and would needlessly narrow a boxed endpoint's existing coverage. litedbmodel supplies the
|
|
177
|
+
* input (portable IR + catalog); bc owns the emitter.
|
|
178
|
+
*
|
|
179
|
+
* WRITE bundles are OUT OF SCOPE (#60 milestone 1: writes stay on the existing write/tx execution
|
|
180
|
+
* path, never a codegen module) — throws if `bundle.readGraph` is absent.
|
|
87
181
|
*/
|
|
88
|
-
export declare function generateCodegenArtifact(bundle: SqlBundle, language: string, registeredLanguages: readonly string[], runtimeImport?: string): CodegenArtifact;
|
|
182
|
+
export declare function generateCodegenArtifact(bundle: SqlBundle, language: string, registeredLanguages: readonly string[], resolveColumnType: ColumnTypeResolver, runtimeImport?: string): CodegenArtifact;
|
|
89
183
|
/**
|
|
90
|
-
* The TS codegen EXECUTION path used to PROVE
|
|
184
|
+
* The TS codegen EXECUTION path used to PROVE behavior-identity: a codegen runtime reads the SQL
|
|
91
185
|
* catalog companion (the STATIC makeSQL bundle) and evaluates skip + value-specs → assemble →
|
|
92
186
|
* render → execute — which is EXACTLY {@link executeBundle} over the SAME bundle.
|
|
93
187
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/scp/codegen.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/scp/codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAkC,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,KAAK,EAAE,KAAK,KAAK,EAAmB,MAAM,oBAAoB,CAAC;AAC1J,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEtF;;;;G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