litedbmodel 2.1.0 → 2.2.0

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.
Files changed (186) hide show
  1. package/README.md +7 -0
  2. package/dist/DBConditions.d.ts.map +1 -1
  3. package/dist/DBConditions.js +16 -1
  4. package/dist/DBConditions.js.map +1 -1
  5. package/dist/DBHandler.d.ts.map +1 -1
  6. package/dist/DBHandler.js +6 -0
  7. package/dist/DBHandler.js.map +1 -1
  8. package/dist/DBModel.d.ts +84 -2
  9. package/dist/DBModel.d.ts.map +1 -1
  10. package/dist/DBModel.js +312 -29
  11. package/dist/DBModel.js.map +1 -1
  12. package/dist/decorators.d.ts +52 -0
  13. package/dist/decorators.d.ts.map +1 -1
  14. package/dist/decorators.js +83 -0
  15. package/dist/decorators.js.map +1 -1
  16. package/dist/drivers/mysql.d.ts.map +1 -1
  17. package/dist/drivers/mysql.js +6 -2
  18. package/dist/drivers/mysql.js.map +1 -1
  19. package/dist/drivers/postgres.d.ts.map +1 -1
  20. package/dist/drivers/postgres.js +6 -2
  21. package/dist/drivers/postgres.js.map +1 -1
  22. package/dist/drivers/sqlite.d.ts.map +1 -1
  23. package/dist/drivers/sqlite.js +12 -2
  24. package/dist/drivers/sqlite.js.map +1 -1
  25. package/dist/index.cjs +10741 -0
  26. package/dist/index.d.cts +1 -0
  27. package/dist/scp/coltype.d.ts +26 -1
  28. package/dist/scp/coltype.d.ts.map +1 -1
  29. package/dist/scp/coltype.js +82 -15
  30. package/dist/scp/coltype.js.map +1 -1
  31. package/dist/scp/connection-routing.d.ts +312 -0
  32. package/dist/scp/connection-routing.d.ts.map +1 -0
  33. package/dist/scp/connection-routing.js +394 -0
  34. package/dist/scp/connection-routing.js.map +1 -0
  35. package/dist/scp/dbmodel-runtime.d.ts +101 -0
  36. package/dist/scp/dbmodel-runtime.d.ts.map +1 -0
  37. package/dist/scp/dbmodel-runtime.js +174 -0
  38. package/dist/scp/dbmodel-runtime.js.map +1 -0
  39. package/dist/scp/decorator-adapter.d.ts +196 -0
  40. package/dist/scp/decorator-adapter.d.ts.map +1 -0
  41. package/dist/scp/decorator-adapter.js +286 -0
  42. package/dist/scp/decorator-adapter.js.map +1 -0
  43. package/dist/scp/emit/emitter.d.ts +108 -0
  44. package/dist/scp/emit/emitter.d.ts.map +1 -0
  45. package/dist/scp/emit/emitter.js +782 -0
  46. package/dist/scp/emit/emitter.js.map +1 -0
  47. package/dist/scp/emit/endpoint.d.ts +248 -0
  48. package/dist/scp/emit/endpoint.d.ts.map +1 -0
  49. package/dist/scp/emit/endpoint.js +20 -0
  50. package/dist/scp/emit/endpoint.js.map +1 -0
  51. package/dist/scp/emit/index.d.ts +11 -0
  52. package/dist/scp/emit/index.d.ts.map +1 -0
  53. package/dist/scp/emit/index.js +13 -0
  54. package/dist/scp/emit/index.js.map +1 -0
  55. package/dist/scp/errors.d.ts +45 -1
  56. package/dist/scp/errors.d.ts.map +1 -1
  57. package/dist/scp/errors.js +47 -1
  58. package/dist/scp/errors.js.map +1 -1
  59. package/dist/scp/exec-context.d.ts +390 -0
  60. package/dist/scp/exec-context.d.ts.map +1 -0
  61. package/dist/scp/exec-context.js +540 -0
  62. package/dist/scp/exec-context.js.map +1 -0
  63. package/dist/scp/grouping.d.ts +32 -0
  64. package/dist/scp/grouping.d.ts.map +1 -0
  65. package/dist/scp/grouping.js +0 -0
  66. package/dist/scp/grouping.js.map +1 -0
  67. package/dist/scp/index.cjs +6814 -15731
  68. package/dist/scp/index.d.cts +1 -0
  69. package/dist/scp/index.d.mts +1 -0
  70. package/dist/scp/index.d.ts +47 -49
  71. package/dist/scp/index.d.ts.map +1 -1
  72. package/dist/scp/index.js +174 -152
  73. package/dist/scp/index.js.map +1 -1
  74. package/dist/scp/index.mjs +5561 -3704
  75. package/dist/scp/leaf-transport.d.ts +50 -0
  76. package/dist/scp/leaf-transport.d.ts.map +1 -0
  77. package/dist/scp/leaf-transport.js +92 -0
  78. package/dist/scp/leaf-transport.js.map +1 -0
  79. package/dist/scp/leaves.d.ts +174 -0
  80. package/dist/scp/leaves.d.ts.map +1 -0
  81. package/dist/scp/leaves.js +287 -0
  82. package/dist/scp/leaves.js.map +1 -0
  83. package/dist/scp/limit-config.d.ts +118 -0
  84. package/dist/scp/limit-config.d.ts.map +1 -0
  85. package/dist/scp/limit-config.js +126 -0
  86. package/dist/scp/limit-config.js.map +1 -0
  87. package/dist/scp/makesql/compile-relation.d.ts +49 -23
  88. package/dist/scp/makesql/compile-relation.d.ts.map +1 -1
  89. package/dist/scp/makesql/compile-relation.js +101 -76
  90. package/dist/scp/makesql/compile-relation.js.map +1 -1
  91. package/dist/scp/makesql/compile-select.d.ts +45 -10
  92. package/dist/scp/makesql/compile-select.d.ts.map +1 -1
  93. package/dist/scp/makesql/compile-select.js +50 -10
  94. package/dist/scp/makesql/compile-select.js.map +1 -1
  95. package/dist/scp/makesql/handler.d.ts +1 -1
  96. package/dist/scp/makesql/handler.d.ts.map +1 -1
  97. package/dist/scp/makesql/index.d.ts +7 -9
  98. package/dist/scp/makesql/index.d.ts.map +1 -1
  99. package/dist/scp/makesql/index.js +17 -28
  100. package/dist/scp/makesql/index.js.map +1 -1
  101. package/dist/scp/makesql/json-array.d.ts +65 -0
  102. package/dist/scp/makesql/json-array.d.ts.map +1 -1
  103. package/dist/scp/makesql/json-array.js +99 -10
  104. package/dist/scp/makesql/json-array.js.map +1 -1
  105. package/dist/scp/makesql/json-batch.d.ts.map +1 -1
  106. package/dist/scp/makesql/json-batch.js +15 -18
  107. package/dist/scp/makesql/json-batch.js.map +1 -1
  108. package/dist/scp/makesql/makesql.d.ts +1 -1
  109. package/dist/scp/makesql/makesql.d.ts.map +1 -1
  110. package/dist/scp/makesql/mysql-returning.d.ts +93 -0
  111. package/dist/scp/makesql/mysql-returning.d.ts.map +1 -0
  112. package/dist/scp/makesql/mysql-returning.js +215 -0
  113. package/dist/scp/makesql/mysql-returning.js.map +1 -0
  114. package/dist/scp/makesql/outtype.d.ts +40 -54
  115. package/dist/scp/makesql/outtype.d.ts.map +1 -1
  116. package/dist/scp/makesql/outtype.js +46 -204
  117. package/dist/scp/makesql/outtype.js.map +1 -1
  118. package/dist/scp/makesql/pool-executor.d.ts +86 -34
  119. package/dist/scp/makesql/pool-executor.d.ts.map +1 -1
  120. package/dist/scp/makesql/pool-executor.js +179 -39
  121. package/dist/scp/makesql/pool-executor.js.map +1 -1
  122. package/dist/scp/makesql/tx.d.ts +107 -22
  123. package/dist/scp/makesql/tx.d.ts.map +1 -1
  124. package/dist/scp/makesql/tx.js +451 -97
  125. package/dist/scp/makesql/tx.js.map +1 -1
  126. package/dist/scp/makesql/writeouttype.d.ts +4 -4
  127. package/dist/scp/makesql/writeouttype.d.ts.map +1 -1
  128. package/dist/scp/makesql/writeouttype.js +5 -3
  129. package/dist/scp/makesql/writeouttype.js.map +1 -1
  130. package/dist/scp/middleware.d.ts +287 -0
  131. package/dist/scp/middleware.d.ts.map +1 -0
  132. package/dist/scp/middleware.js +358 -0
  133. package/dist/scp/middleware.js.map +1 -0
  134. package/dist/scp/relation.d.ts +65 -8
  135. package/dist/scp/relation.d.ts.map +1 -1
  136. package/dist/scp/relation.js +154 -93
  137. package/dist/scp/relation.js.map +1 -1
  138. package/dist/scp/tx-options.d.ts +136 -0
  139. package/dist/scp/tx-options.d.ts.map +1 -0
  140. package/dist/scp/tx-options.js +184 -0
  141. package/dist/scp/tx-options.js.map +1 -0
  142. package/dist/scp/write-bundle.d.ts +131 -0
  143. package/dist/scp/write-bundle.d.ts.map +1 -0
  144. package/dist/scp/write-bundle.js +160 -0
  145. package/dist/scp/write-bundle.js.map +1 -0
  146. package/dist/types.d.ts +7 -0
  147. package/dist/types.d.ts.map +1 -1
  148. package/dist/types.js.map +1 -1
  149. package/docs/design/phase-a-execution-context.md +139 -0
  150. package/package.json +14 -13
  151. package/dist/scp/authoring-sql.d.ts +0 -134
  152. package/dist/scp/authoring-sql.d.ts.map +0 -1
  153. package/dist/scp/authoring-sql.js +0 -191
  154. package/dist/scp/authoring-sql.js.map +0 -1
  155. package/dist/scp/authoring.d.ts +0 -218
  156. package/dist/scp/authoring.d.ts.map +0 -1
  157. package/dist/scp/authoring.js +0 -351
  158. package/dist/scp/authoring.js.map +0 -1
  159. package/dist/scp/catalog.d.ts +0 -95
  160. package/dist/scp/catalog.d.ts.map +0 -1
  161. package/dist/scp/catalog.js +0 -245
  162. package/dist/scp/catalog.js.map +0 -1
  163. package/dist/scp/codegen.d.ts +0 -201
  164. package/dist/scp/codegen.d.ts.map +0 -1
  165. package/dist/scp/codegen.js +0 -605
  166. package/dist/scp/codegen.js.map +0 -1
  167. package/dist/scp/find-filter-guard.d.ts +0 -68
  168. package/dist/scp/find-filter-guard.d.ts.map +0 -1
  169. package/dist/scp/find-filter-guard.js +0 -88
  170. package/dist/scp/find-filter-guard.js.map +0 -1
  171. package/dist/scp/guard.d.ts +0 -43
  172. package/dist/scp/guard.d.ts.map +0 -1
  173. package/dist/scp/guard.js +0 -140
  174. package/dist/scp/guard.js.map +0 -1
  175. package/dist/scp/makesql/authoring-compile.d.ts +0 -90
  176. package/dist/scp/makesql/authoring-compile.d.ts.map +0 -1
  177. package/dist/scp/makesql/authoring-compile.js +0 -505
  178. package/dist/scp/makesql/authoring-compile.js.map +0 -1
  179. package/dist/scp/makesql/static-bundle.d.ts +0 -196
  180. package/dist/scp/makesql/static-bundle.d.ts.map +0 -1
  181. package/dist/scp/makesql/static-bundle.js +0 -1244
  182. package/dist/scp/makesql/static-bundle.js.map +0 -1
  183. package/dist/scp/runtime.d.ts +0 -243
  184. package/dist/scp/runtime.d.ts.map +0 -1
  185. package/dist/scp/runtime.js +0 -422
  186. package/dist/scp/runtime.js.map +0 -1
@@ -1,605 +0,0 @@
1
- "use strict";
2
- /**
3
- * litedbmodel v2 SCP — mode-3 codegen (WS7f, #35; spec §9 exec-mode 3 / §10 / §11; makeSQL flip,
4
- * epic #43/#45 Phase B; #60 milestone 1 — typed-NATIVE READ codegen, bc#77/#90).
5
- *
6
- * The static-codegen execution mode ("Codegen・静的(全言語)— IR → 各言語ソース生成 runtime≈0,
7
- * 入力は可搬IRのみ, bc#13 共有 generator に SQL catalog を供給" — spec §9). It takes a §8 STATIC
8
- * makeSQL {@link SqlBundle} and, per target language, emits:
9
- *
10
- * 1. **Behavior module** — bc's SHARED generator run over the bundle's portable IR through bc's
11
- * de-interpreted, RUNTIME-FREE emitter. For a READ bundle covered by bc's typed-NATIVE
12
- * endpoint (`rust-typed-native` / `go-typed-native`, bc#77/#90 — the 1.0 read de-box: fully
13
- * concrete `HandlerNR<Comp>`/`InNR<Comp>`/`PortsNR<Comp><node>`/`RawRowNR<Comp><node>` structs,
14
- * ZERO boxed `Value`/`RawValue`, ZERO IR baked into the module), the CODEGEN-ONLY lowering
15
- * below ({@link lowerReadGraphForTypedNative}) makes the read's shape structurally ELIGIBLE
16
- * (derives each real Select-node's referenced heads from its statements → individual scalar ref
17
- * ports + types the component's `inputPorts` from the schema) before handing it to bc. For a WRITE bundle, or a
18
- * READ shape typed-native does not (yet) cover, codegen uses bc's existing de-interpreted
19
- * STRAIGHT-LINE endpoint (`<lang>-straightline`, bc#75) — see {@link typedEmitterFor}.
20
- * 2. **SQL catalog companion** — the pure-JSON STATIC makeSQL catalog (per-node statement
21
- * templates / relations / transaction). A codegen consumer's thin SQL layer reads it to
22
- * evaluate skip + value-specs → assemble → render → execute (identically to the mode-2 runtime).
23
- *
24
- * ## #60 milestone 1 scope (CODEGEN-PATH ONLY)
25
- *
26
- * This lowering exists SOLELY for the codegen emitter call — it builds a NEW, separate
27
- * `ComponentGraphIR` from the bundle's `readGraph`; it never mutates `SqlBundle`/`ReadGraph` and
28
- * never touches the shared `readGraph`/`executeReadGraph` the native exec surface (and the
29
- * frozen conformance corpus) depend on. Those keep consuming the REAL Select-node
30
- * `readGraph.ir`, completely unaffected by anything in this file.
31
- *
32
- * ## Behavior-identical to the thin-runtime (mode-2), by construction
33
- *
34
- * The generated module is observationally equivalent to `runBehavior` (same values, same emitted
35
- * op sequence, same Failure code/message), and the companion IS the bundle, so a codegen runtime
36
- * that drives it follows the IDENTICAL static-makeSQL render/execute path {@link executeBundle}
37
- * uses — SQL text (all dialects) and results are identical, not approximately equal. The TS leg
38
- * PROVES this by executing via the artifact and asserting exact equality vs {@link executeBundle}
39
- * (see {@link codegenExecuteBundleForTest}).
40
- *
41
- * ## No literal-bake / no boxed fallback
42
- *
43
- * typed-native fails CLOSED on an uncovered shape (a `map`/`cond` relation kind it does not cover,
44
- * or an input head that cannot lower to a native port). Such a shape is NOT silently regenerated on
45
- * the boxed `-typed`/`-typed-raw` emitter — it THROWS, naming the exact gap, so it can be tracked as
46
- * a bc coverage gap rather than masked.
47
- *
48
- * IN-list / array-bound WHERE heads (the `whereIn` `{__jsonArray:{ref:[head]},dialect}` param) are
49
- * now COVERED via bc#110 (native array/list port for a componentRef input port): the lowering
50
- * resolves the IN-list column's element scalar and emits a native ARRAY input port
51
- * (`{type:'array', elemType}` → `Vec<ElemT>`/`[]ElemT`), so `complexWhere`/`inList` reach the
52
- * zero-boxing native hot path (no serde_json/encoding-json, no boxed `Value`). They no longer
53
- * fail closed as a bc#86/coverage gap.
54
- */
55
- Object.defineProperty(exports, "__esModule", { value: true });
56
- exports.TypedNativeCoverageError = exports.CODEGEN_EMITTER = exports.CODEGEN_LANGUAGES = void 0;
57
- exports.bundleToPortableIR = bundleToPortableIR;
58
- exports.lowerReadGraphForTypedNative = lowerReadGraphForTypedNative;
59
- exports.typedEmitterFor = typedEmitterFor;
60
- exports.codegenEmitterFor = codegenEmitterFor;
61
- exports.generateCodegenArtifact = generateCodegenArtifact;
62
- exports.codegenExecuteBundleForTest = codegenExecuteBundleForTest;
63
- const behavior_contracts_1 = require("behavior-contracts");
64
- const runtime_1 = require("./runtime");
65
- const coltype_1 = require("./coltype");
66
- /**
67
- * The languages litedbmodel mode-3 codegen supports — exactly the set bc's shared generator
68
- * registers (bc#13 SP1 typescript/python + SP2 go/rust/php). {@link codegenEmitterFor}
69
- * verifies against the LIVE registry so a bc capability drift is caught loudly.
70
- */
71
- exports.CODEGEN_LANGUAGES = ['typescript', 'python', 'go', 'rust', 'php'];
72
- /**
73
- * The bc READ emitter litedbmodel drives for each codegen target (#60 milestone 1): the
74
- * **de-interpreted, RUNTIME-FREE typed-NATIVE** endpoint (bc#77/#90) for go/rust — ZERO boxed
75
- * `Value`/`RawValue`, ZERO IR baked into the module, concrete `HandlerNR`/`InNR`/`PortsNR`/
76
- * `RawRowNR` structs. There is **NO literal / straight-line / boxed-typed fallback** for a read: an
77
- * unspec'd fallback is INVALID (it silently swallows the "this shape can't be natively codegen'd"
78
- * signal) — a read shape typed-native does not cover MUST fail loudly at generation, naming the gap
79
- * (report it as a bc#86 coverage gap), never silently regenerate on `-typed`/`-typed-raw`.
80
- *
81
- * `-typed-raw` (bc#76, the boxed-wire intermediate) and `-typed` (the boxed-Value intermediate) are
82
- * RETIRED from litedbmodel's codegen surface entirely (#60 milestone 1) — typed-native supersedes
83
- * both for every read shape it covers (bc#77/#90: single-componentRef reads AND the `map`
84
- * relationKind:single|connection shape, bc#86 part 2).
85
- *
86
- * - ts: **no typed-native endpoint registered yet** (bc has not shipped `typescript-typed-native`).
87
- * TS stays on its existing `typescript-typed` (boxed) endpoint until bc adds one — a DECLARED,
88
- * reported gap (not silently mirrored to go/rust's retirement), tracked as a bc#77 TS follow-up.
89
- * - **python/php: NOT present.** bc registers no de-boxed typed endpoint for them (capability limit).
90
- * litedbmodel does NOT substitute the literal (≈ir) emitter — that would be an unspec'd fallback.
91
- * Codegen for py/php is a bc capability gap that ERRORS (ESCALATE to bc), never a silent literal.
92
- *
93
- * WRITES (batchInsert / gate-first tx) are NOT reads — they are NOT routed through this table at
94
- * all (#60 milestone 1): a write bundle stays on the existing write/tx execution path
95
- * (`executeTransactionBundle` / the native adapter's hand-written tx mirror), never a codegen
96
- * module, boxed or typed-raw. {@link generateCodegenArtifact} throws if asked to codegen a write.
97
- */
98
- exports.CODEGEN_EMITTER = {
99
- typescript: 'typescript-typed',
100
- go: 'go-typed-native',
101
- rust: 'rust-typed-native',
102
- };
103
- /**
104
- * The portable {@link ComponentGraphIR} view of a §8 READ bundle: `compileBehaviors`' real-node
105
- * read-graph IR (the de-surrogated `Select`/`Count`/map nodes; #12) — the SAME IR the native exec
106
- * surface (`executeReadGraph`) walks (via `bundle.readGraph.ir` directly). litedbmodel constructs NO
107
- * `ComponentGraphIR` literal here; it returns the compiler's own output. {@link generateCodegenArtifact}
108
- * does NOT use this for a typed-native READ target (that uses the codegen-only lowered form,
109
- * {@link lowerReadGraphForTypedNative}); this is the portable IR for a boxed READ endpoint / fingerprint.
110
- *
111
- * WRITE bundles have NO portable component-graph IR (they carry a single compiled `statement`, not a
112
- * component graph — and are NOT codegen-module cases: {@link generateCodegenArtifact} rejects them).
113
- * There is therefore no hand-built `makeSQL` write surrogate anymore (#12) — a write bundle throws.
114
- */
115
- function bundleToPortableIR(bundle) {
116
- if (bundle.readGraph !== undefined)
117
- return bundle.readGraph.ir;
118
- throw new Error(`litedbmodel codegen: bundle '${bundle.name}' has no readGraph — a WRITE bundle carries a single ` +
119
- `compiled makeSQL statement, not a portable component-graph IR, and is not a codegen-module case ` +
120
- `(#12: the hand-built makeSQL write surrogate IR is eliminated; writes ride the write/tx exec path).`);
121
- }
122
- /** The STATIC makeSQL execution catalog carried alongside the generated module. */
123
- function companionOf(bundle) {
124
- const base = {
125
- dialect: bundle.dialect,
126
- optionalHeads: bundle.optionalHeads,
127
- relations: bundle.relations,
128
- ...(bundle.readGraph !== undefined ? { readGraph: bundle.readGraph } : {}),
129
- ...(bundle.statement !== undefined ? { statement: bundle.statement } : {}),
130
- ...(bundle.outputType !== undefined ? { outputType: bundle.outputType } : {}),
131
- };
132
- return bundle.transaction === undefined ? base : { ...base, transaction: bundle.transaction };
133
- }
134
- // ═══════════════════════════════════════════════════════════════════════════════════════════
135
- // #60 milestone 1 — CODEGEN-ONLY typed-native lowering (#12: from the real-node read graph).
136
- //
137
- // bc's typed-native coverage predicate (`coverageRejectReason`, bc#86/#89) requires EVERY
138
- // componentRef port to be STATICALLY resolvable to a native scalar/string-array/number-literal.
139
- // The de-surrogated read graph's real `Select`/`Count`/map nodes carry boxed authoring ports
140
- // (`where:{arr:[…]}`, `table`, `select`) that are not that shape, so bc would hard-fail on them.
141
- // This lowering rebuilds a NEW, CODEGEN-ONLY component whose body nodes carry ONLY individual
142
- // native-scalar `{ref:[head]}` ports (one per input head the node's compiled statements bind,
143
- // derived from `statementsById`) + typed `inputPorts` — the shape bc's typed-native emitter needs.
144
- //
145
- // This is a NEW, throwaway `ComponentGraphIR` built FROM the bundle's `readGraph` fields
146
- // (`ir` topology + `statementsById`, both already computed by the EXISTING `compileReadGraph` —
147
- // untouched here) — it is never written back onto `SqlBundle`/`ReadGraph`, never serialized, and
148
- // the native exec surface (`executeReadGraph`) never sees it (it walks the real-node `readGraph.ir`
149
- // directly). Purely a generation-time input to `generateModule`.
150
- // ═══════════════════════════════════════════════════════════════════════════════════════════
151
- /** A head could not be typed for typed-native codegen — the read is NOT typed-native-coverable. */
152
- class TypedNativeCoverageError extends Error {
153
- component;
154
- reasons;
155
- constructor(component, reasons) {
156
- super(`litedbmodel codegen (#60 m1): component '${component}' is not typed-native-coverable:\n` +
157
- reasons.map((r) => ` - ${r}`).join('\n') +
158
- `\n\nbc's typed-native endpoint (bc#77/#90) fails closed on an uncovered shape — this is NOT ` +
159
- `regenerated on the boxed '-typed'/'-typed-raw' emitter (retired from litedbmodel's codegen ` +
160
- `surface, #60 milestone 1). Report this as a bc#86 coverage gap (array-typed / non-scalar ` +
161
- `input heads have no native port type yet), or exclude this case from native-codegen benching.`);
162
- this.component = component;
163
- this.reasons = reasons;
164
- this.name = 'TypedNativeCoverageError';
165
- }
166
- }
167
- exports.TypedNativeCoverageError = TypedNativeCoverageError;
168
- /** Extract the `{table, column}` a where-fragment statement's leading SQL token names, for the
169
- * closed set of fragment shapes `compileSelectNode`/`lowerWhereMember` emit: `<col> <op> ?`
170
- * (eq/cmp/LIKE/ILIKE). Returns undefined for any other shape (head-count / SQL text mismatch) —
171
- * the caller treats that head as NOT resolvable (fail-closed), never guesses. */
172
- const WHERE_FRAGMENT_COLUMN = /^([A-Za-z_][A-Za-z0-9_]*)\s+(?:=|<>|<=|>=|<|>|LIKE|ILIKE)\s*\?$/;
173
- /** Extract the table name from the head `SELECT … FROM <table>` statement (dialect-tuned, but the
174
- * `FROM <table>` token is stable across dialects/CTEs — `compileSelectNode`'s head always ends
175
- * ` FROM <table>[ …]`; a JOIN/CTE-shaped head is out of scope for this narrow codegen deriver and
176
- * reported as unresolvable rather than mis-parsed). */
177
- const SELECT_FROM_TABLE = /\bFROM\s+([A-Za-z_][A-Za-z0-9_]*)\b/i;
178
- /** Extract the LHS column of an IN-list / array-bound WHERE fragment — the closed set of texts
179
- * {@link inListFragment} emits across dialects, all of the form `<col> IN (…)` (sqlite `json_each`,
180
- * mysql `JSON_TABLE`) or `<col> = ANY(?)` (postgres). The single array param binds a `?` inside; the
181
- * column names the type to resolve the ELEMENT scalar from (spec §4.1 schema SoT). Any other shape
182
- * returns undefined (fail-closed). */
183
- const IN_LIST_COLUMN = /^([A-Za-z_][A-Za-z0-9_]*)\s+(?:IN\s*\(|=\s*ANY\s*\()/i;
184
- /**
185
- * Derive each input head's bc scalar type from a read node's compiled {@link StaticStatement}s
186
- * (spec §4.1 schema SoT), for bc's typed-native codegen (#60 m1). Works from the ALREADY-COMPILED
187
- * statement templates (available on `ReadGraph.statementsById`, which codegen already carries)
188
- * instead of re-walking the authored component — so this lowering needs NO extra input beyond
189
- * what `SqlBundle`/`ReadGraph` already expose (no change to `compileReadGraph`/`ReadGraph`).
190
- *
191
- * Returns three sets:
192
- * - `byHead` — heads bound by a bare single-segment `{ref:[head]}` scalar param, typed to their
193
- * column's bc scalar (`int`/`float`/`string`/`bool`).
194
- * - `arrayHeads` — heads bound by an IN-list / array param (`whereIn`'s
195
- * `{__jsonArray:{ref:[head]},dialect}`), typed to their column's ELEMENT scalar. bc#110 gives
196
- * typed-native a native array port (`Vec<ElemT>`/`[]ElemT`) for such a head, so it is now
197
- * COVERED (no longer fail-closed) — the caller emits it as a native array input port.
198
- * - `unresolved` — heads whose owning fragment's SQL text isn't a shape this deriver covers (the
199
- * closed `<col> <op> ?` scalar shape or the `<col> IN (…)`/`<col> = ANY(?)` array shape). A
200
- * non-empty `unresolved` means the read is NOT typed-native-coverable (fail-closed at the caller).
201
- *
202
- * `elementVar` (map nodes only): the map's `as` binding (`$e0`). A param whose ref's FIRST segment
203
- * is the element var (`{ref:['$e0','author_id']}`) is a map-ELEMENT field access, NOT a component
204
- * input head — bc types it from the map's `over` element struct (the prior node's row), so this
205
- * deriver neither types nor rejects it (it is fully covered by bc's `coveredMapNode` element typing).
206
- */
207
- function deriveHeadTypesFromStatements(statements, resolveColumnType, elementVar) {
208
- const byHead = new Map();
209
- const arrayHeads = new Map();
210
- const unresolved = new Map();
211
- // The head statement (`SELECT … FROM <table>`) — always statements[0] (compileSelectNode always
212
- // pushes it first); its table name resolves every WHERE fragment's column type.
213
- const head = statements[0];
214
- const tableMatch = head === undefined ? null : SELECT_FROM_TABLE.exec(head.sql);
215
- const table = tableMatch?.[1];
216
- for (const stmt of statements) {
217
- // The LIMIT clause (` LIMIT ?`) is NOT a whereFragment — its param is `coalesce(refOpt(limit), N)`
218
- // (optional head + a static default). bc's typed-native emitter binds `limit` as a native scalar
219
- // port (its `portIsStatic` accepts the bare ref + number-literal default), so type the head from
220
- // the schema-less LIMIT contract: `limit`-family heads are always an integer row count. The
221
- // element-var guard applies here too (a map child never has a LIMIT-bound element ref today, but
222
- // stay uniform). Anything OTHER than the closed `coalesce([refOpt([head]), <int>])` shape is left
223
- // untyped here (the surrogate-scope reconciliation below fail-closes on an un-typed referenced head).
224
- if (stmt.whereFragment !== true) {
225
- for (const param of stmt.params) {
226
- const lh = limitHeadNameOf(param);
227
- if (lh === undefined)
228
- continue;
229
- if (elementVar !== undefined && lh === elementVar)
230
- continue;
231
- const prior = byHead.get(lh);
232
- if (prior !== undefined && prior !== 'int') {
233
- unresolved.set(lh, `input head '${lh}' resolves to conflicting scalar types ('${prior}' vs 'int' from a LIMIT clause) across statements`);
234
- continue;
235
- }
236
- byHead.set(lh, 'int');
237
- }
238
- continue;
239
- }
240
- for (const param of stmt.params) {
241
- const path = refPathOf(param);
242
- // A map-ELEMENT field access (`{ref:['$e0','author_id']}`, first segment = the map `as` var) is
243
- // NOT a component input head — bc types it from the map's `over` element struct. Neither type
244
- // nor reject it here (fully covered by bc's `coveredMapNode` element-field lowering).
245
- if (path !== undefined && elementVar !== undefined && path[0] === elementVar)
246
- continue;
247
- if (path === undefined || path.length !== 1) {
248
- // An IN-list / array-bound WHERE head — `whereIn`'s `{__jsonArray:{ref:[head]},dialect}`
249
- // param (single-array param, one `?` inside the `IN (…)`/`= ANY(?)` subquery). bc#110 gives
250
- // typed-native a native ARRAY port for this shape (`Vec<ElemT>`/`[]ElemT`), so resolve the
251
- // column's ELEMENT scalar (spec §4.1 SoT) and record it as an array head — no longer
252
- // fail-closed. Any other non-scalar/nested-literal param stays unresolved (fail-closed).
253
- const arrHead = arrayHeadNameOf(param);
254
- if (arrHead !== undefined) {
255
- if (table === undefined) {
256
- unresolved.set(arrHead, `input head '${arrHead}': could not resolve the owning table from the SELECT head SQL ('${head?.sql ?? '<none>'}')`);
257
- continue;
258
- }
259
- const cm = IN_LIST_COLUMN.exec(stmt.sql.trim());
260
- if (cm === null) {
261
- unresolved.set(arrHead, `input head '${arrHead}': IN-list WHERE fragment SQL '${stmt.sql}' is not the closed '<col> IN (…)'/'<col> = ANY(?)' shape this codegen-only deriver covers`);
262
- continue;
263
- }
264
- const elemType = (0, coltype_1.sqlTypeToBcScalar)(resolveColumnType(table, cm[1]));
265
- const priorElem = arrayHeads.get(arrHead);
266
- if (priorElem !== undefined && priorElem !== elemType) {
267
- unresolved.set(arrHead, `input head '${arrHead}' resolves to conflicting array element scalar types ('${priorElem}' vs '${elemType}') across statements`);
268
- continue;
269
- }
270
- arrayHeads.set(arrHead, elemType);
271
- continue;
272
- }
273
- // Not a bare single-segment ref and not a recognized array head (e.g. a nested literal): if
274
- // it names a head at all, surface it; otherwise it simply isn't head-typable here.
275
- const named = headNameOf(param);
276
- if (named !== undefined) {
277
- unresolved.set(named, `input head '${named}' is bound by a non-scalar param shape (${JSON.stringify(param)}) — bc's ` +
278
- `typed-native emitter has no native port type for it (string/int/float/bool scalars only).`);
279
- }
280
- continue;
281
- }
282
- const headName = path[0];
283
- if (table === undefined) {
284
- unresolved.set(headName, `input head '${headName}': could not resolve the owning table from the SELECT head SQL ('${head?.sql ?? '<none>'}')`);
285
- continue;
286
- }
287
- const m = WHERE_FRAGMENT_COLUMN.exec(stmt.sql.trim());
288
- if (m === null) {
289
- unresolved.set(headName, `input head '${headName}': WHERE fragment SQL '${stmt.sql}' is not the closed '<col> <op> ?' shape this codegen-only deriver covers`);
290
- continue;
291
- }
292
- const column = m[1];
293
- const sqlType = resolveColumnType(table, column);
294
- const scalar = (0, coltype_1.sqlTypeToBcScalar)(sqlType);
295
- const prior = byHead.get(headName);
296
- if (prior !== undefined && prior !== scalar) {
297
- unresolved.set(headName, `input head '${headName}' resolves to conflicting scalar types ('${prior}' vs '${scalar}') across statements`);
298
- continue;
299
- }
300
- byHead.set(headName, scalar);
301
- }
302
- }
303
- // A head bound BOTH as a scalar and as an array across fragments is not a coherent native port —
304
- // fail-closed rather than silently pick one (never occurs for the covered shapes, defensive).
305
- for (const head of arrayHeads.keys()) {
306
- if (byHead.has(head)) {
307
- unresolved.set(head, `input head '${head}' is bound both as a scalar and as an array param — no single native port type`);
308
- }
309
- }
310
- return { byHead, arrayHeads, unresolved };
311
- }
312
- /** A statement param's bare ref path (`{ref:[…]}`/`{refOpt:[…]}`), or undefined if it isn't one. */
313
- function refPathOf(param) {
314
- if (param === null || typeof param !== 'object' || Array.isArray(param))
315
- return undefined;
316
- const keys = Object.keys(param);
317
- if (keys.length !== 1 || (keys[0] !== 'ref' && keys[0] !== 'refOpt'))
318
- return undefined;
319
- const path = param[keys[0]];
320
- if (!Array.isArray(path) || path.length === 0 || !path.every((s) => typeof s === 'string'))
321
- return undefined;
322
- return path;
323
- }
324
- /** The head name a non-bare-ref param shape still names (e.g. `{__jsonArray:{ref:[head]},…}`), for
325
- * a clearer diagnostic — undefined when no head can be identified at all (a plain literal). */
326
- function headNameOf(param) {
327
- if (param === null || typeof param !== 'object' || Array.isArray(param))
328
- return undefined;
329
- const obj = param;
330
- if ('__jsonArray' in obj) {
331
- const inner = refPathOf(obj.__jsonArray);
332
- return inner?.[0];
333
- }
334
- return undefined;
335
- }
336
- /** The distinct map-ELEMENT field names a node's statements bind via `{ref:[elementVar, field]}`
337
- * (first-seen order). These are the map child's element-field ports (`$e0.author_id`): bc's
338
- * typed-native map lowering types each from the `over` element struct's field. Only single-field
339
- * accesses (`[elementVar, field]`, length 2) are collected — a deeper element path is not a covered
340
- * native port here (fail-closed downstream if one appears). */
341
- function elementFieldRefs(statements, elementVar) {
342
- const out = [];
343
- const seen = new Set();
344
- for (const stmt of statements) {
345
- for (const param of stmt.params) {
346
- const path = refPathOf(param);
347
- if (path === undefined || path.length !== 2 || path[0] !== elementVar)
348
- continue;
349
- const field = path[1];
350
- if (!seen.has(field)) {
351
- seen.add(field);
352
- out.push(field);
353
- }
354
- }
355
- }
356
- return out;
357
- }
358
- /** The head a LIMIT param (`coalesce([{refOpt:[head]}, <int-literal>])`) binds — the closed shape
359
- * `compileSelectNode` emits for an optional `limit` with a static default (`coalesce(opt($.limit), N)`).
360
- * Returns the head name for that exact shape, else undefined (any other shape is not a LIMIT head this
361
- * deriver types). bc's typed-native emitter binds it as a native scalar port (bare ref + number literal
362
- * default are both `portIsStatic`). */
363
- function limitHeadNameOf(param) {
364
- if (param === null || typeof param !== 'object' || Array.isArray(param))
365
- return undefined;
366
- const obj = param;
367
- const args = obj.coalesce;
368
- if (!Array.isArray(args) || args.length !== 2)
369
- return undefined;
370
- const [refPart, dflt] = args;
371
- // The default must be a static integer literal (`coalesce(opt($.limit), 20)`).
372
- if (typeof dflt !== 'number' || !Number.isInteger(dflt))
373
- return undefined;
374
- if (refPart === null || typeof refPart !== 'object' || Array.isArray(refPart))
375
- return undefined;
376
- const rp = refPart;
377
- const keys = Object.keys(rp);
378
- if (keys.length !== 1 || (keys[0] !== 'ref' && keys[0] !== 'refOpt'))
379
- return undefined;
380
- const path = rp[keys[0]];
381
- if (!Array.isArray(path) || path.length !== 1 || typeof path[0] !== 'string')
382
- return undefined;
383
- return path[0];
384
- }
385
- /** The head an IN-list / array param (`{__jsonArray:{ref:[head]},dialect}`) binds — ONLY the covered
386
- * single-segment `{ref:[head]}` inner shape (bc#110's native array port requires a single-segment,
387
- * non-opt ref). A multi-segment / opt / non-ref inner is NOT this covered array shape → undefined
388
- * (the caller then treats it as an unresolved non-scalar param, fail-closed). */
389
- function arrayHeadNameOf(param) {
390
- if (param === null || typeof param !== 'object' || Array.isArray(param))
391
- return undefined;
392
- const obj = param;
393
- if (!('__jsonArray' in obj))
394
- return undefined;
395
- const inner = refPathOf(obj.__jsonArray);
396
- return inner !== undefined && inner.length === 1 ? inner[0] : undefined;
397
- }
398
- /**
399
- * Lower a read bundle's REAL Select-node `ComponentGraphIR` into a NEW, CODEGEN-ONLY IR eligible
400
- * for bc's typed-native endpoint (#60 milestone 1): derive each node's referenced heads from its
401
- * `statementsById` fragments and emit individual native-scalar `{ref:[head]}` ports, typing the
402
- * component's `inputPorts` from the schema (via {@link deriveHeadTypesFromStatements}). Throws
403
- * {@link TypedNativeCoverageError} if any referenced head cannot be natively typed (e.g. an IN-list's
404
- * array head) — NO silent `unknown` port, NO fallback. Does NOT mutate `bundle`/`bundle.readGraph`
405
- * (a fresh IR object is returned); the native `executeReadGraph` keeps consuming the real `readGraph.ir`.
406
- *
407
- * Scope: bc's typed-native predicate itself still governs `map`/`cond`/relationKind/policy
408
- * coverage (this lowering does not special-case those — `generateModule` fails closed on them with
409
- * its own detailed diagnostic, which this function does not need to duplicate).
410
- */
411
- function lowerReadGraphForTypedNative(readGraph, resolveColumnType) {
412
- const ir = readGraph.ir;
413
- const reasons = [];
414
- const components = ir.components.map((c) => {
415
- const inputPortTypes = new Map();
416
- // IN-list / array-bound heads (bc#110): the head's native ELEMENT scalar (the port lowers to
417
- // `Vec<ElemT>`/`[]ElemT`, fed natively — NO json.Marshal/serde_json on the hot path).
418
- const inputPortElemTypes = new Map();
419
- const body = c.body.map((n) => {
420
- if ('cond' in n)
421
- return n;
422
- const isMapNode = 'map' in n;
423
- const stmts = readGraph.statementsById[n.id] ?? [];
424
- // A map node binds an ELEMENT var (`as: '$e0'`) — its child statements reference the mapped
425
- // parent row via `{ref:['$e0', <field>]}`. That is a map-element field access (bc types it from
426
- // the map's `over` element struct), NOT a component input head, so hand the element var to the
427
- // deriver to exclude it from head typing/rejection.
428
- const elementVar = isMapNode
429
- ? (n.map.as ?? undefined)
430
- : undefined;
431
- const { byHead, arrayHeads, unresolved } = deriveHeadTypesFromStatements(stmts, resolveColumnType, elementVar);
432
- for (const [, reason] of unresolved)
433
- reasons.push(`node '${n.id}': ${reason}`);
434
- for (const [head, scalar] of byHead) {
435
- const prior = inputPortTypes.get(head);
436
- if (prior !== undefined && prior !== scalar) {
437
- reasons.push(`input head '${head}' resolves to conflicting scalar types ('${prior}' vs '${scalar}') across nodes`);
438
- continue;
439
- }
440
- inputPortTypes.set(head, scalar);
441
- }
442
- for (const [head, elem] of arrayHeads) {
443
- const prior = inputPortElemTypes.get(head);
444
- if (prior !== undefined && prior !== elem) {
445
- reasons.push(`input head '${head}' resolves to conflicting array element scalar types ('${prior}' vs '${elem}') across nodes`);
446
- continue;
447
- }
448
- inputPortElemTypes.set(head, elem);
449
- }
450
- // #12 (de-surrogated): the codegen IR is rebuilt from the real node's `statementsById`-derived
451
- // head set (`byHead` ∪ `arrayHeads`) — the SAME native-scalar `{ref:[head]}` port shape bc's
452
- // typed-native emitter consumes. There is no `__scope` obj to walk anymore; the referenced-head
453
- // set IS what `deriveHeadTypesFromStatements` found (an `unresolved` head already pushed a
454
- // reason above, fail-closed). A covered array head is emitted as the SAME single-segment
455
- // `{ref:[head]}` port (bc#110's array-port lowering keys off the inputPorts array schema).
456
- const newPorts = {};
457
- // A map node's child statements reference the mapped parent row via `{ref:['$e0', <field>]}`.
458
- // bc's typed-native map lowering types a port `{ref:['$e0', <field>]}` from the OVER element
459
- // struct's FIELD (a native scalar) — so emit one native-scalar element-FIELD port per field the
460
- // child statements bind (`{ref:['$e0', author_id]}` → port `author_id`). Non-element component
461
- // heads (if any) are typed/emitted normally below.
462
- if (isMapNode && elementVar !== undefined) {
463
- const fields = elementFieldRefs(stmts, elementVar);
464
- for (const field of fields)
465
- newPorts[field] = { ref: [elementVar, field] };
466
- }
467
- for (const head of [...byHead.keys(), ...arrayHeads.keys()]) {
468
- newPorts[head] = { ref: [head] };
469
- }
470
- return isMapNode
471
- ? { ...n, map: { ...n.map, ports: newPorts } }
472
- : { ...n, ports: newPorts };
473
- });
474
- if (reasons.length > 0)
475
- throw new TypedNativeCoverageError(c.name, reasons);
476
- // Only emit an `inputPorts` entry for a head the COVERED plane actually references (a
477
- // native-scalar port on some node's lowered ports). bc's authoring layer registers an
478
- // `inputPorts` entry for every `$.head` the authored method SOURCE accesses — including a
479
- // head used ONLY as a WHERE-fragment's LHS COLUMN-name marker (e.g. `whereGe($.created_at,
480
- // $.since)` accesses `$.created_at` to name the column, never as a bound RHS value), which
481
- // never appears in the surrogate `__scope` obj at all. Keeping such a stray entry with its
482
- // original `unknown` schema type would emit an unresolvable `InNR<Comp>.field: Value` (bc's
483
- // typed-native `InNR` struct declares a field for EVERY declared inputPort) — a compile error,
484
- // since the covered module imports no `Value` type. Dropping it is sound: the covered plane
485
- // never reads it (no lowered port references it), so omitting the `InNR` field changes nothing
486
- // observable — every REAL WHERE-bound head is still typed + present (typed above, in `byHead`).
487
- const inputPorts = {};
488
- for (const [name, scalar] of inputPortTypes) {
489
- const schema = (c.inputPorts ?? {})[name];
490
- inputPorts[name] = schema === undefined ? { required: true, type: scalar } : { ...schema, type: scalar };
491
- }
492
- // IN-list / array-bound heads (bc#110): a native ARRAY input port carrying the ELEMENT scalar as
493
- // `elemType`. bc's typed-native emitter lowers this to `Vec<ElemT>`/`[]ElemT` fed natively from
494
- // the input struct field — NO boxed `Value`, NO serde_json/encoding-json on the read hot path.
495
- // bc does NOT infer element types (consumer-interface C3), so litedbmodel supplies `elemType`
496
- // from the schema SoT (the IN-list column's resolved scalar).
497
- for (const [name, elem] of inputPortElemTypes) {
498
- const schema = (c.inputPorts ?? {})[name];
499
- inputPorts[name] = { ...(schema ?? { required: true }), type: 'array', elemType: elem };
500
- }
501
- return { ...c, body, inputPorts };
502
- });
503
- return { ...ir, components };
504
- }
505
- /**
506
- * Resolve the READ codegen emitter for a target language, or throw. No fallback: a language
507
- * without a registered endpoint is a bc capability gap that fails LOUDLY (never a silent
508
- * substitution of the literal/interpreter/boxed emitter — an unspec'd fallback is invalid).
509
- */
510
- function typedEmitterFor(language, registered) {
511
- if (!exports.CODEGEN_LANGUAGES.includes(language)) {
512
- throw new Error(`litedbmodel codegen: language '${language}' is not a supported target (supported: ${exports.CODEGEN_LANGUAGES.join(', ')})`);
513
- }
514
- const emitter = exports.CODEGEN_EMITTER[language];
515
- if (emitter === undefined) {
516
- throw new Error(`litedbmodel codegen: no READ codegen endpoint for '${language}'. litedbmodel codegen is STATIC ` +
517
- `de-interpreted codegen (spec §9) with NO literal/interpreter/boxed fallback (an unspec'd fallback ` +
518
- `is invalid). bc registers a READ endpoint only for ${Object.keys(exports.CODEGEN_EMITTER).join('/')} — a ` +
519
- `'${language}' endpoint is a bc capability gap. ESCALATE to bc (bc#22 pattern); never substitute ` +
520
- `the literal emitter.`);
521
- }
522
- if (!registered.includes(emitter)) {
523
- throw new Error(`litedbmodel codegen: bc's shared generator does not register the '${emitter}' emitter for '${language}' ` +
524
- `(bc registered: ${[...registered].sort().join(', ')}). ESCALATE to bc (bc#22 pattern), never fork locally.`);
525
- }
526
- return emitter;
527
- }
528
- /**
529
- * Shape-INDEPENDENT emitter resolution — identical to {@link typedEmitterFor} now that there is
530
- * exactly one READ endpoint per language (kept as a distinct export for callers that historically
531
- * used the shape-independent form; both resolve the SAME table).
532
- */
533
- function codegenEmitterFor(language, registered) {
534
- return typedEmitterFor(language, registered);
535
- }
536
- /**
537
- * Every litedbmodel READ codegen endpoint consumes the SAME native-scalar-port lowering — NOT
538
- * just the `-typed-native` (go/rust) ones. Rationale (#12 regression fix):
539
- *
540
- * Post-#12 the read graph is the REAL de-surrogated `Select`-node IR, whose `where` port array
541
- * carries a fragment for EVERY authored `whereX($.col, …)` — including one whose LHS `$.col` is a
542
- * WHERE COLUMN-NAME MARKER, never a bound input value (`whereGe($.created_at, $.since)` accesses
543
- * `$.created_at` only to NAME the column; only `$.since` is bound). Handing that raw IR to bc's
544
- * emitter emits a `ref(["created_at"], scope)` read + a `created_at` input-struct field, so the
545
- * bound module throws `unknown binding: created_at` at execution (the scope has no `created_at`).
546
- * The go/rust `-typed-native` path never hit this because it is fed
547
- * {@link lowerReadGraphForTypedNative}, which rebuilds each node's ports from the GENUINE bound
548
- * heads (`statementsById`), dropping the column-name markers. TS was on the raw IR
549
- * ({@link bundleToPortableIR}) → it kept the marker → it broke.
550
- *
551
- * The lowering is therefore the correct input for the boxed `typescript-typed` endpoint too: it
552
- * feeds bc EXACTLY the genuine bound heads (equivalent-in-spirit to what go/rust consume), and
553
- * bc#110's native array port means the array-typed heads (`complexWhere`/`inList`) lower cleanly —
554
- * the old "lowering would narrow TS's array coverage" concern is stale. Only WRITE bundles (no
555
- * `readGraph`) never reach this path. */
556
- function needsHeadLowering(_emitter) {
557
- return true;
558
- }
559
- /**
560
- * Generate the mode-3 READ codegen artifact for ONE §8 READ bundle in ONE target language. Lowers
561
- * the bundle's real Select-node read graph into the native-scalar-port IR
562
- * ({@link lowerReadGraphForTypedNative}) FIRST — for go/rust's typed-NATIVE endpoint (bc#77/#90,
563
- * RUNTIME-FREE) AND for TS's boxed `typescript-typed` endpoint alike. Both consume the SAME
564
- * genuine-bound-head shape: the lowering derives each node's ports from its compiled
565
- * `statementsById` fragments, so a WHERE COLUMN-NAME MARKER head (`whereGe($.created_at, $.since)`
566
- * — `$.created_at` names the column, is never bound) is EXCLUDED from the emitted ports/input
567
- * struct, exactly as go/rust already handled it (#12 regression: TS previously fed the raw IR and
568
- * emitted a stray `created_at` binding → `unknown binding: created_at` at execution).
569
- *
570
- * WRITE bundles are OUT OF SCOPE (#60 milestone 1: writes stay on the existing write/tx execution
571
- * path, never a codegen module) — throws if `bundle.readGraph` is absent.
572
- */
573
- function generateCodegenArtifact(bundle, language, registeredLanguages, resolveColumnType, runtimeImport) {
574
- if (bundle.readGraph === undefined) {
575
- throw new Error(`litedbmodel codegen (#60 m1): bundle '${bundle.name}' has no readGraph — WRITE bundles are not ` +
576
- `codegen-module cases (they stay on the existing write/tx execution path). Only READ bundles ` +
577
- `are generated through generateCodegenArtifact.`);
578
- }
579
- const emitter = typedEmitterFor(language, registeredLanguages);
580
- // The portable IR exists ONLY transiently here as the generator's input — it is NOT part of the
581
- // codegen OUTPUT (no artifact field, no file, no binary; the codegen path never reads IR data).
582
- // ALL read endpoints (go/rust typed-native AND TS boxed typescript-typed) are fed the SAME
583
- // genuine-bound-head lowering (#12 regression fix — see needsHeadLowering).
584
- const ir = needsHeadLowering(emitter)
585
- ? lowerReadGraphForTypedNative(bundle.readGraph, resolveColumnType)
586
- : bundleToPortableIR(bundle);
587
- // bc 0.8.0 (scp-only-authoring, SA3/SA7): `generateModule` fail-closes on un-tokened IR
588
- // (`NON_COMPILED_IR`). This `ir` is DERIVED from `compileBehaviors`' real read graph (additively
589
- // lowered/annotated), so it carries no in-process provenance token. Re-adopt it at this generation
590
- // boundary via `loadCompiledIR` — the sanctioned seam that recomputes the canonical fingerprint once
591
- // and mints the token (the derived graph IS the compiler's output transformed, never hand-forged raw
592
- // IR). This is exactly bc's "codegen fixture / derived IR" boundary case.
593
- const compiled = (0, behavior_contracts_1.loadCompiledIR)(ir);
594
- const module = (0, behavior_contracts_1.generateModule)(compiled, runtimeImport === undefined ? { language: emitter } : { language: emitter, runtimeImport });
595
- return { language: language, module, companion: companionOf(bundle), bundle };
596
- }
597
- /**
598
- * The TS codegen EXECUTION path used to PROVE behavior-identity: a codegen runtime reads the SQL
599
- * catalog companion (the STATIC makeSQL bundle) and evaluates skip + value-specs → assemble →
600
- * render → execute — which is EXACTLY {@link executeBundle} over the SAME bundle.
601
- */
602
- function codegenExecuteBundleForTest(artifact, input, db) {
603
- return (0, runtime_1.executeBundle)(artifact.bundle, input, { db });
604
- }
605
- //# sourceMappingURL=codegen.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/scp/codegen.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;;;AAyGH,gDAOC;AA8SD,oEAyFC;AAOD,0CAuBC;AAOD,8CAEC;AAwCD,0DA+BC;AAOD,kEAEC;AA5mBD,2DAAmI;AAOnI,uCAA0C;AAK1C,uCAAsF;AAEtF;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AAGxF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACU,QAAA,eAAe,GAA6C;IACvE,UAAU,EAAE,kBAAkB;IAC9B,EAAE,EAAE,iBAAiB;IACrB,IAAI,EAAE,mBAAmB;CAC1B,CAAC;AAuCF;;;;;;;;;;;GAWG;AACH,SAAgB,kBAAkB,CAAC,MAAiB;IAClD,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;IAC/D,MAAM,IAAI,KAAK,CACb,gCAAgC,MAAM,CAAC,IAAI,uDAAuD;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