litedbmodel 2.0.2 → 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 (193) 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 +127 -24
  15. package/dist/decorators.js.map +1 -1
  16. package/dist/drivers/mysql.d.ts.map +1 -1
  17. package/dist/drivers/mysql.js +12 -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 +13 -2
  21. package/dist/drivers/postgres.js.map +1 -1
  22. package/dist/drivers/sqlite.d.ts +2 -0
  23. package/dist/drivers/sqlite.d.ts.map +1 -1
  24. package/dist/drivers/sqlite.js +49 -4
  25. package/dist/drivers/sqlite.js.map +1 -1
  26. package/dist/index.cjs +10741 -0
  27. package/dist/index.d.cts +1 -0
  28. package/dist/scp/coltype.d.ts +108 -0
  29. package/dist/scp/coltype.d.ts.map +1 -1
  30. package/dist/scp/coltype.js +293 -6
  31. package/dist/scp/coltype.js.map +1 -1
  32. package/dist/scp/connection-routing.d.ts +312 -0
  33. package/dist/scp/connection-routing.d.ts.map +1 -0
  34. package/dist/scp/connection-routing.js +394 -0
  35. package/dist/scp/connection-routing.js.map +1 -0
  36. package/dist/scp/dbmodel-runtime.d.ts +101 -0
  37. package/dist/scp/dbmodel-runtime.d.ts.map +1 -0
  38. package/dist/scp/dbmodel-runtime.js +174 -0
  39. package/dist/scp/dbmodel-runtime.js.map +1 -0
  40. package/dist/scp/decorator-adapter.d.ts +196 -0
  41. package/dist/scp/decorator-adapter.d.ts.map +1 -0
  42. package/dist/scp/decorator-adapter.js +286 -0
  43. package/dist/scp/decorator-adapter.js.map +1 -0
  44. package/dist/scp/emit/emitter.d.ts +108 -0
  45. package/dist/scp/emit/emitter.d.ts.map +1 -0
  46. package/dist/scp/emit/emitter.js +782 -0
  47. package/dist/scp/emit/emitter.js.map +1 -0
  48. package/dist/scp/emit/endpoint.d.ts +248 -0
  49. package/dist/scp/emit/endpoint.d.ts.map +1 -0
  50. package/dist/scp/emit/endpoint.js +20 -0
  51. package/dist/scp/emit/endpoint.js.map +1 -0
  52. package/dist/scp/emit/index.d.ts +11 -0
  53. package/dist/scp/emit/index.d.ts.map +1 -0
  54. package/dist/scp/emit/index.js +13 -0
  55. package/dist/scp/emit/index.js.map +1 -0
  56. package/dist/scp/errors.d.ts +45 -1
  57. package/dist/scp/errors.d.ts.map +1 -1
  58. package/dist/scp/errors.js +47 -1
  59. package/dist/scp/errors.js.map +1 -1
  60. package/dist/scp/exec-context.d.ts +390 -0
  61. package/dist/scp/exec-context.d.ts.map +1 -0
  62. package/dist/scp/exec-context.js +540 -0
  63. package/dist/scp/exec-context.js.map +1 -0
  64. package/dist/scp/grouping.d.ts +32 -0
  65. package/dist/scp/grouping.d.ts.map +1 -0
  66. package/dist/scp/grouping.js +0 -0
  67. package/dist/scp/grouping.js.map +1 -0
  68. package/dist/scp/index.cjs +6432 -17579
  69. package/dist/scp/index.d.cts +1 -0
  70. package/dist/scp/index.d.mts +1 -0
  71. package/dist/scp/index.d.ts +51 -52
  72. package/dist/scp/index.d.ts.map +1 -1
  73. package/dist/scp/index.js +189 -152
  74. package/dist/scp/index.js.map +1 -1
  75. package/dist/scp/index.mjs +6067 -3659
  76. package/dist/scp/leaf-transport.d.ts +50 -0
  77. package/dist/scp/leaf-transport.d.ts.map +1 -0
  78. package/dist/scp/leaf-transport.js +92 -0
  79. package/dist/scp/leaf-transport.js.map +1 -0
  80. package/dist/scp/leaves.d.ts +174 -0
  81. package/dist/scp/leaves.d.ts.map +1 -0
  82. package/dist/scp/leaves.js +287 -0
  83. package/dist/scp/leaves.js.map +1 -0
  84. package/dist/scp/limit-config.d.ts +118 -0
  85. package/dist/scp/limit-config.d.ts.map +1 -0
  86. package/dist/scp/limit-config.js +126 -0
  87. package/dist/scp/limit-config.js.map +1 -0
  88. package/dist/scp/makesql/compile-relation.d.ts +49 -23
  89. package/dist/scp/makesql/compile-relation.d.ts.map +1 -1
  90. package/dist/scp/makesql/compile-relation.js +101 -76
  91. package/dist/scp/makesql/compile-relation.js.map +1 -1
  92. package/dist/scp/makesql/compile-select.d.ts +45 -10
  93. package/dist/scp/makesql/compile-select.d.ts.map +1 -1
  94. package/dist/scp/makesql/compile-select.js +50 -10
  95. package/dist/scp/makesql/compile-select.js.map +1 -1
  96. package/dist/scp/makesql/handler.d.ts +1 -1
  97. package/dist/scp/makesql/handler.d.ts.map +1 -1
  98. package/dist/scp/makesql/index.d.ts +7 -10
  99. package/dist/scp/makesql/index.d.ts.map +1 -1
  100. package/dist/scp/makesql/index.js +19 -30
  101. package/dist/scp/makesql/index.js.map +1 -1
  102. package/dist/scp/makesql/json-array.d.ts +65 -0
  103. package/dist/scp/makesql/json-array.d.ts.map +1 -1
  104. package/dist/scp/makesql/json-array.js +99 -10
  105. package/dist/scp/makesql/json-array.js.map +1 -1
  106. package/dist/scp/makesql/json-batch.d.ts.map +1 -1
  107. package/dist/scp/makesql/json-batch.js +21 -19
  108. package/dist/scp/makesql/json-batch.js.map +1 -1
  109. package/dist/scp/makesql/makesql.d.ts +1 -1
  110. package/dist/scp/makesql/makesql.d.ts.map +1 -1
  111. package/dist/scp/makesql/mysql-returning.d.ts +93 -0
  112. package/dist/scp/makesql/mysql-returning.d.ts.map +1 -0
  113. package/dist/scp/makesql/mysql-returning.js +215 -0
  114. package/dist/scp/makesql/mysql-returning.js.map +1 -0
  115. package/dist/scp/makesql/outtype.d.ts +75 -34
  116. package/dist/scp/makesql/outtype.d.ts.map +1 -1
  117. package/dist/scp/makesql/outtype.js +91 -118
  118. package/dist/scp/makesql/outtype.js.map +1 -1
  119. package/dist/scp/makesql/pool-executor.d.ts +135 -13
  120. package/dist/scp/makesql/pool-executor.d.ts.map +1 -1
  121. package/dist/scp/makesql/pool-executor.js +229 -21
  122. package/dist/scp/makesql/pool-executor.js.map +1 -1
  123. package/dist/scp/makesql/tx.d.ts +107 -22
  124. package/dist/scp/makesql/tx.d.ts.map +1 -1
  125. package/dist/scp/makesql/tx.js +451 -97
  126. package/dist/scp/makesql/tx.js.map +1 -1
  127. package/dist/scp/makesql/writeouttype.d.ts +7 -8
  128. package/dist/scp/makesql/writeouttype.d.ts.map +1 -1
  129. package/dist/scp/makesql/writeouttype.js +8 -7
  130. package/dist/scp/makesql/writeouttype.js.map +1 -1
  131. package/dist/scp/middleware.d.ts +287 -0
  132. package/dist/scp/middleware.d.ts.map +1 -0
  133. package/dist/scp/middleware.js +358 -0
  134. package/dist/scp/middleware.js.map +1 -0
  135. package/dist/scp/relation.d.ts +80 -9
  136. package/dist/scp/relation.d.ts.map +1 -1
  137. package/dist/scp/relation.js +198 -78
  138. package/dist/scp/relation.js.map +1 -1
  139. package/dist/scp/tx-options.d.ts +136 -0
  140. package/dist/scp/tx-options.d.ts.map +1 -0
  141. package/dist/scp/tx-options.js +184 -0
  142. package/dist/scp/tx-options.js.map +1 -0
  143. package/dist/scp/write-bundle.d.ts +131 -0
  144. package/dist/scp/write-bundle.d.ts.map +1 -0
  145. package/dist/scp/write-bundle.js +160 -0
  146. package/dist/scp/write-bundle.js.map +1 -0
  147. package/dist/types.d.ts +7 -0
  148. package/dist/types.d.ts.map +1 -1
  149. package/dist/types.js.map +1 -1
  150. package/docs/BENCHMARK.md +58 -56
  151. package/docs/benchmark-chart.svg +166 -166
  152. package/docs/design/phase-a-execution-context.md +139 -0
  153. package/package.json +16 -9
  154. package/dist/scp/authoring-sql.d.ts +0 -134
  155. package/dist/scp/authoring-sql.d.ts.map +0 -1
  156. package/dist/scp/authoring-sql.js +0 -191
  157. package/dist/scp/authoring-sql.js.map +0 -1
  158. package/dist/scp/authoring.d.ts +0 -155
  159. package/dist/scp/authoring.d.ts.map +0 -1
  160. package/dist/scp/authoring.js +0 -162
  161. package/dist/scp/authoring.js.map +0 -1
  162. package/dist/scp/catalog.d.ts +0 -94
  163. package/dist/scp/catalog.d.ts.map +0 -1
  164. package/dist/scp/catalog.js +0 -234
  165. package/dist/scp/catalog.js.map +0 -1
  166. package/dist/scp/codegen.d.ts +0 -189
  167. package/dist/scp/codegen.d.ts.map +0 -1
  168. package/dist/scp/codegen.js +0 -421
  169. package/dist/scp/codegen.js.map +0 -1
  170. package/dist/scp/find-filter-guard.d.ts +0 -68
  171. package/dist/scp/find-filter-guard.d.ts.map +0 -1
  172. package/dist/scp/find-filter-guard.js +0 -88
  173. package/dist/scp/find-filter-guard.js.map +0 -1
  174. package/dist/scp/guard.d.ts +0 -43
  175. package/dist/scp/guard.d.ts.map +0 -1
  176. package/dist/scp/guard.js +0 -134
  177. package/dist/scp/guard.js.map +0 -1
  178. package/dist/scp/makesql/authoring-compile.d.ts +0 -90
  179. package/dist/scp/makesql/authoring-compile.d.ts.map +0 -1
  180. package/dist/scp/makesql/authoring-compile.js +0 -494
  181. package/dist/scp/makesql/authoring-compile.js.map +0 -1
  182. package/dist/scp/makesql/ir.d.ts +0 -42
  183. package/dist/scp/makesql/ir.d.ts.map +0 -1
  184. package/dist/scp/makesql/ir.js +0 -66
  185. package/dist/scp/makesql/ir.js.map +0 -1
  186. package/dist/scp/makesql/static-bundle.d.ts +0 -187
  187. package/dist/scp/makesql/static-bundle.d.ts.map +0 -1
  188. package/dist/scp/makesql/static-bundle.js +0 -1113
  189. package/dist/scp/makesql/static-bundle.js.map +0 -1
  190. package/dist/scp/runtime.d.ts +0 -242
  191. package/dist/scp/runtime.d.ts.map +0 -1
  192. package/dist/scp/runtime.js +0 -400
  193. package/dist/scp/runtime.js.map +0 -1
@@ -1,400 +0,0 @@
1
- "use strict";
2
- /**
3
- * litedbmodel v2 SCP — the thin TS runtime on the STATIC makeSQL bundle (WS3, #23; makeSQL
4
- * flip, epic #43/#45 Phase B; spec §3 / §10 / §11).
5
- *
6
- * makeSQL is the SOLE SCP compile/execute path. A behavior method compiles (SYMBOLICALLY — no
7
- * concrete input) to a {@link SqlBundle}:
8
- * - a READ bundle carries a {@link ReadGraph} — the surrogate bc `ComponentGraphIR` (each SQL
9
- * node → a `makeSQL` node) + per-node static statement templates. bc `runBehavior` drives
10
- * map iteration / wire binding / Φ output; the makeSQL handler renders each node's statements
11
- * (value-specs + skip evaluated per-input) and executes real SQL ("bc composes, makeSQL
12
- * executes"). Read-relation batch ops ride the bundle too.
13
- * - a WRITE bundle carries a single `makeSQL` statement (the base write) + the derived gate-first
14
- * {@link TransactionPlan} for a Command with write-time relations.
15
- *
16
- * The reduced spine (`CompiledOperation` + `FragmentTree` + `renderOperation`) is RETIRED — this
17
- * module carries no reduced IR. Reads execute via {@link import('./makesql/static-bundle')} (bc
18
- * `runBehavior` + makeSQL handler); writes via {@link import('./makesql/tx')} (gate-first tx-DAG).
19
- *
20
- * ## Input normalization (SSoT — defaults live in the schema, not code)
21
- *
22
- * An OPTIONAL input head the caller omits is normalized to `null` (present-as-null) so a SKIP
23
- * presence expression drops its fragment (absent-key SKIP). "Optional" comes from the bundle's
24
- * `optionalHeads` (schema-optional + SKIP-guarded + every `refOpt` head) — the SSoT.
25
- */
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.SqlFailure = void 0;
28
- exports.executeBehavior = executeBehavior;
29
- exports.compileBundle = compileBundle;
30
- exports.executeBundle = executeBundle;
31
- exports.executeBundleAsync = executeBundleAsync;
32
- exports.executeBehaviorAsync = executeBehaviorAsync;
33
- exports.compileWriteBundle = compileWriteBundle;
34
- exports.compileCompositeWriteBundle = compileCompositeWriteBundle;
35
- exports.compileCreateManyBundle = compileCreateManyBundle;
36
- exports.compileUpdateManyBundle = compileUpdateManyBundle;
37
- exports.compileDeleteManyBundle = compileDeleteManyBundle;
38
- exports.executeCompositeCommand = executeCompositeCommand;
39
- exports.executeCommand = executeCommand;
40
- exports.executeTransactionBundle = executeTransactionBundle;
41
- exports.read = read;
42
- exports.readBundle = readBundle;
43
- const errors_1 = require("./errors");
44
- Object.defineProperty(exports, "SqlFailure", { enumerable: true, get: function () { return errors_1.SqlFailure; } });
45
- const relation_1 = require("./relation");
46
- const typed_object_1 = require("./typed-object");
47
- const static_bundle_1 = require("./makesql/static-bundle");
48
- const tx_1 = require("./makesql/tx");
49
- const compile_crud_1 = require("./makesql/compile-crud");
50
- const makesql_1 = require("./makesql/makesql");
51
- const writeouttype_1 = require("./makesql/writeouttype");
52
- const writes_1 = require("./writes");
53
- /** The primary catalog node of a component (the first non-cond, non-map body node). */
54
- function primaryNodeOf(component) {
55
- for (const n of component.body) {
56
- if ('cond' in n)
57
- continue;
58
- if ('map' in n)
59
- continue;
60
- return n;
61
- }
62
- return undefined;
63
- }
64
- /** Is a component's primary catalog node a write (Insert/Update/Delete)? */
65
- function isWriteComponent(component) {
66
- const p = primaryNodeOf(component);
67
- if (p === undefined || 'map' in p)
68
- return false;
69
- const c = p.component;
70
- return c === 'Insert' || c === 'Update' || c === 'Delete';
71
- }
72
- /**
73
- * Execute a published behavior contract (WS2 {@link BehaviorModelContract}) end-to-end via the
74
- * static makeSQL bundle. Returns the component's output (a read Φ output / row list, or a write's
75
- * RETURNING rows / `[{changes, lastInsertRowid}]` summary).
76
- *
77
- * @throws {SqlFailure} a mapped driver failure re-surfaced at the boundary.
78
- */
79
- function executeBehavior(contract, input, options) {
80
- return executeBundle(compileBundle(contract, options.entry, options.relations, options.dialect), input, options);
81
- }
82
- /**
83
- * Compile ONE behavior method into the serializable STATIC {@link SqlBundle} (spec §8) — the
84
- * published multi-language artifact. SYMBOLIC (no concrete input). A read method compiles to a
85
- * {@link ReadGraph}; a single-write method to a `makeSQL` statement. Pure JSON throughout.
86
- */
87
- function compileBundle(contract, entry, relations = [], dialectName = 'sqlite', findFilterModel, resolveColumnType) {
88
- const component = entry ? contract.components.find((c) => c.name === entry) : contract.components[0];
89
- if (component === undefined)
90
- throw new Error(`scp runtime: entry component '${entry ?? '<first>'}' not found in contract`);
91
- const relationOps = {};
92
- for (const decl of relations) {
93
- if (relationOps[decl.name] !== undefined) {
94
- throw new Error(`scp runtime: duplicate relation declaration '${decl.name}'`);
95
- }
96
- relationOps[decl.name] = (0, relation_1.compileRelationOp)({ ...decl, dialect: decl.dialect ?? dialectName });
97
- }
98
- if (isWriteComponent(component)) {
99
- const writeNode = primaryNodeOf(component);
100
- const op = (0, tx_1.compileWriteNode)(writeNode, dialectName);
101
- return {
102
- dialect: dialectName,
103
- name: component.name,
104
- statement: { sql: op.sql, params: op.params },
105
- optionalHeads: [],
106
- relations: relationOps,
107
- };
108
- }
109
- const readGraph = (0, static_bundle_1.compileReadGraph)(contract, dialectName, entry, findFilterModel, resolveColumnType);
110
- return {
111
- dialect: dialectName,
112
- name: readGraph.name,
113
- readGraph,
114
- optionalHeads: readGraph.optionalHeads,
115
- relations: relationOps,
116
- };
117
- }
118
- /**
119
- * Execute a {@link SqlBundle} (the §8 published artifact) end-to-end via the static makeSQL
120
- * runtime + REAL SQLite. Read bundles run the read graph via bc `runBehavior`; single-statement
121
- * write bundles run the write (RETURNING rows / summary). The SAME code path a thin per-language
122
- * runtime follows — it consumes ONLY the serialized bundle + bc, never re-running the compile.
123
- *
124
- * @throws {SqlFailure} a mapped driver failure re-surfaced at the boundary.
125
- */
126
- function executeBundle(bundle, input, options) {
127
- if (bundle.statement !== undefined && bundle.transaction === undefined) {
128
- const view = {
129
- dialect: bundle.dialect,
130
- name: bundle.name,
131
- statements: [bundle.statement],
132
- optionalHeads: bundle.optionalHeads,
133
- };
134
- return (0, static_bundle_1.executeStaticWrite)(view, input, options.db);
135
- }
136
- if (bundle.readGraph === undefined) {
137
- throw new Error(`scp runtime: bundle '${bundle.name}' carries neither a read graph nor a write statement`);
138
- }
139
- return (0, static_bundle_1.executeReadGraph)(bundle.readGraph, input, options.db);
140
- }
141
- /**
142
- * Execute a READ {@link SqlBundle} end-to-end via the ASYNC PG / MySQL execution model (#40): bc
143
- * `runBehaviorAsync` drives map iteration / wire binding / Φ output and dispatches independent
144
- * sibling read nodes in bounded parallel against the pooled async executor. This is the PRODUCTION
145
- * live-DB read entry point — the async twin of {@link executeBundle} for read bundles.
146
- *
147
- * Byte-identical composition (SAME IR, SAME per-node SQL text + params, SAME Φ output) to the
148
- * serial `executeBundle`; concurrency changes only the wall-clock. A single-relation (zero-sibling)
149
- * read graph runs exactly one query, so it is identical to the serial path either way.
150
- *
151
- * A single-statement WRITE bundle is NOT accepted here — the write-tx path stays sync + serial
152
- * (`executeBundle` / `executeTransactionBundle`); this async path is READ-only.
153
- *
154
- * @throws {SqlFailure} a mapped driver failure re-surfaced at the boundary.
155
- */
156
- async function executeBundleAsync(bundle, input, options) {
157
- if (bundle.readGraph === undefined) {
158
- throw new Error(`scp runtime: executeBundleAsync requires a READ bundle ('${bundle.name}' carries no read graph); ` +
159
- `the write-tx path stays synchronous + serial (use executeBundle / executeTransactionBundle).`);
160
- }
161
- return (0, static_bundle_1.executeReadGraphAsync)(bundle.readGraph, input, options.exec);
162
- }
163
- /**
164
- * Compile + execute a READ behavior method via the ASYNC PG / MySQL execution model (#40). The
165
- * async twin of {@link executeBehavior} for reads: compile the contract to a {@link SqlBundle}
166
- * (SYMBOLIC), then run its read graph through {@link executeBundleAsync}.
167
- *
168
- * @throws {SqlFailure} a mapped driver failure re-surfaced at the boundary.
169
- */
170
- async function executeBehaviorAsync(contract, input, options) {
171
- return executeBundleAsync(compileBundle(contract, options.entry, options.relations, options.dialect), input, options);
172
- }
173
- // ── Write-time relations: Command bundle + 1-tx execution (WS5, #25 — spec §6) ──
174
- /**
175
- * Find the single base-write catalog node (`Insert`/`Update`/`Delete`) of a Command component.
176
- * WS5 initial scope is a single-statement Command (spec §6/§13). More than one write node ⇒ the
177
- * multi-write DAG derivation (WS8, rejected loudly here).
178
- */
179
- function baseWriteNodeOf(component) {
180
- const writes = component.body.filter((n) => !('cond' in n) && !('map' in n) && (n.component === 'Insert' || n.component === 'Update' || n.component === 'Delete'));
181
- if (writes.length === 0) {
182
- throw new Error(`scp write: Command '${component.name}' has no base write (Insert/Update/Delete) node`);
183
- }
184
- if (writes.length > 1) {
185
- throw new Error(`scp write: Command '${component.name}' has ${writes.length} base write nodes; WS5 initial ` +
186
- `scope is a SINGLE-statement Command + write-time relations (multi-write DAG is WS8, spec §6/§13).`);
187
- }
188
- return writes[0];
189
- }
190
- /**
191
- * Compile a Command method + its `entityWrites` save contract into a {@link SqlBundle} carrying
192
- * the derived, gate-first write-time-relations {@link TransactionPlan} (spec §6/§8). The base
193
- * write op is compiled ONCE (the SAME `compileWriteNode` — complete tuned SQL + deferred
194
- * Expression-IR params); {@link deriveTransactionPlan} lowers the lifecycle's §6 effect arrays
195
- * around it into the ordered statement list. Pure JSON; a WS7 runtime honors the SAME plan.
196
- */
197
- function compileWriteBundle(contract, entry, writes, phase, dialectName = 'sqlite', resolveColumnType) {
198
- const component = contract.components.find((c) => c.name === entry);
199
- if (component === undefined)
200
- throw new Error(`scp write: entry component '${entry}' not found in contract`);
201
- const lifecycle = (0, writes_1.lifecycleFor)(writes, phase);
202
- if (lifecycle === undefined) {
203
- throw new Error(`scp write: the '${phase}' lifecycle is not declared in the entityWrites save contract`);
204
- }
205
- const writeNode = baseWriteNodeOf(component);
206
- // MySQL has no native RETURNING; when the base write is an INSERT…RETURNING carrying a PK
207
- // descriptor, annotate it with the strip-before-execute PK hint so the mysql emulation re-selects
208
- // by the REAL PK (not a hardcoded `id`). PG/SQLite keep the op verbatim (native RETURNING).
209
- const baseOp = dialectName === 'mysql' ? (0, tx_1.mysqlPkHint)((0, tx_1.compileWriteNode)(writeNode, dialectName)) : (0, tx_1.compileWriteNode)(writeNode, dialectName);
210
- const base = { op: baseOp, label: `${writeNode.component}` };
211
- const plan = (0, tx_1.deriveTransactionPlan)(phase, [base], lifecycle, dialectName);
212
- const bundle = {
213
- dialect: dialectName,
214
- name: component.name,
215
- statement: { sql: baseOp.sql, params: baseOp.params },
216
- optionalHeads: [],
217
- relations: {},
218
- transaction: plan,
219
- };
220
- // Codegen typed de-box (spec §4.1/§9): when the schema/DDL column-type SoT is supplied, annotate
221
- // the write bundle with the TransactionResult `outputType` (entity/returnedRows rows typed via the
222
- // resolver + the write's target/RETURNING) so bc's typed(-raw) emitters materialize a concrete
223
- // struct for the result. Fail-closed inside `annotateWriteBundleOutType`. Absent resolver → the
224
- // bundle stays un-annotated (interpret/boxed only, back-compat).
225
- return resolveColumnType === undefined ? bundle : (0, writeouttype_1.annotateWriteBundleOutType)(bundle, resolveColumnType);
226
- }
227
- /**
228
- * Compile a COMPOSITE (multi-write) Command into a {@link SqlBundle} carrying ONE derived,
229
- * gate-first, TOPOLOGICALLY-ORDERED transaction plan (spec §6 nested write / §14). Each entry
230
- * contributes a named base write + its effects; a later member depends on an earlier via
231
- * `$.ref.<name>.*`. {@link deriveTransactionPlan} builds the DAG + gate-first constraint and
232
- * derives the ordered plan; a cycle / dangling ref is ESCALATED. Pure JSON.
233
- */
234
- function compileCompositeWriteBundle(contract, entries, phase, dialectName = 'sqlite') {
235
- if (entries.length < 2) {
236
- throw new Error('scp write: a composite write bundle needs at least 2 named write members (use compileWriteBundle for a single write).');
237
- }
238
- const bases = [];
239
- let firstBaseOp;
240
- let firstName = '';
241
- for (const e of entries) {
242
- const component = contract.components.find((c) => c.name === e.entry);
243
- if (component === undefined)
244
- throw new Error(`scp write: entry component '${e.entry}' not found in contract`);
245
- if (firstBaseOp === undefined)
246
- firstName = component.name;
247
- const writeNode = baseWriteNodeOf(component);
248
- const baseOp = (0, tx_1.compileWriteNode)(writeNode, dialectName);
249
- if (firstBaseOp === undefined)
250
- firstBaseOp = baseOp;
251
- bases.push({ op: baseOp, label: `${writeNode.component} ${e.name}`, name: e.name, effects: e.lifecycle.effects });
252
- }
253
- const plan = (0, tx_1.deriveTransactionPlan)(phase, bases, { effects: {} }, dialectName);
254
- return {
255
- dialect: dialectName,
256
- name: firstName,
257
- statement: { sql: firstBaseOp.sql, params: firstBaseOp.params },
258
- optionalHeads: [],
259
- relations: {},
260
- transaction: plan,
261
- };
262
- }
263
- // ── Batch writes: createMany / updateMany / deleteMany (a v1→v2 regression fix) ──
264
- //
265
- // A batch write is ONE LOGICAL operation that produces N grouped SQL statements (createMany with a
266
- // heterogeneous column-set groups records into one INSERT per group, mirroring `DBModel._insert`;
267
- // updateMany is one UNNEST/JSON/CASE statement; deleteMany is a PK-set IN-list DELETE). This is
268
- // DISTINCT from the deferred composite multi-write DAG (`baseWriteNodeOf` still rejects >1 authored
269
- // base write). The batch compilers (`compileInsertMany`/`compileUpdateMany`/`compileDeleteMany`) copy
270
- // the v1 builders byte-for-byte; here they are lowered into a gate-free {@link TransactionPlan} of
271
- // body statements ({@link deriveBatchPlan}), so ALL FIVE runtimes execute the multi-statement batch
272
- // through the SAME per-statement tx loop with no runtime change (concrete params are literalized to
273
- // bc IR so they survive the render pass — see `deriveBatchPlan`/`literalize`).
274
- /** Flatten a batch compiler's `MakeSQL` component to a concrete `{ sql, params }` op. */
275
- function flattenBatchOp(node, label) {
276
- const assembled = (0, makesql_1.assembleMakeSQL)(node);
277
- return { sql: assembled.sql, params: assembled.params, label };
278
- }
279
- /**
280
- * Compile a `createMany` into a batch write {@link SqlBundle} carrying a gate-free
281
- * {@link TransactionPlan}. Heterogeneous column-set groups become MULTIPLE ordered INSERT
282
- * statements — byte-identical to what `DBModel._insert` emits per group (via `compileInsertMany`).
283
- *
284
- * `pk` (the target PK descriptor) is REQUIRED when the createMany carries a RETURNING clause on the
285
- * MySQL dialect: a batch INSERT persists N rows, so the MySQL RETURNING emulation must re-select ALL
286
- * N (a range on the AUTO_INCREMENT column, or the client-supplied PK values), not a single `id`.
287
- */
288
- function compileCreateManyBundle(name, options, dialectName = 'sqlite', resolveColumnType) {
289
- const components = (0, compile_crud_1.compileInsertMany)(dialectName, options);
290
- const ops = components.map((c, i) => {
291
- const flat = flattenBatchOp(c, `createMany group ${i}`);
292
- // On MySQL, annotate a RETURNING batch INSERT with the PK hint so the driver emulation
293
- // re-selects every inserted row of the group by the real PK.
294
- if (dialectName === 'mysql' && options.pk !== undefined && options.returning !== undefined) {
295
- return { ...flat, ...(0, tx_1.mysqlPkHint)({ sql: flat.sql, params: flat.params, pk: options.pk }) };
296
- }
297
- return flat;
298
- });
299
- const plan = (0, tx_1.deriveBatchPlan)('create', ops);
300
- // `ops` is never empty here: `deriveBatchPlan` throws on zero ops, and a `createMany` always groups
301
- // into >=1 INSERT. Fail LOUDLY rather than emitting an empty `sql` fallback (an empty-ops bundle is a
302
- // compile bug, not a default — 'defaults in schema, not code'). The `statement` mirrors the batch plan's
303
- // first (group-0) statement, matching the updateMany/deleteMany bundle shape below.
304
- const head = ops[0];
305
- if (head === undefined) {
306
- throw new Error(`scp write: compileCreateManyBundle('${name}') produced no INSERT statements (empty createMany grouping) — an empty-ops batch bundle is a compile bug, not a silent empty-SQL default.`);
307
- }
308
- const bundle = { dialect: dialectName, name, statement: { sql: head.sql, params: head.params }, optionalHeads: [], relations: {}, transaction: plan };
309
- // Codegen typed de-box (spec §4.1/§9): annotate the batch write with the TransactionResult
310
- // `outputType` when the schema SoT resolver is supplied (returnedRows rows typed via the RETURNING
311
- // + target table). Fail-closed. Absent resolver → un-annotated (back-compat).
312
- return resolveColumnType === undefined ? bundle : (0, writeouttype_1.annotateWriteBundleOutType)(bundle, resolveColumnType);
313
- }
314
- /**
315
- * Compile an `updateMany` into a batch write {@link SqlBundle} (one UNNEST/JSON/CASE statement,
316
- * byte-identical to `compileUpdateMany` driving the v1 `buildUpdateMany` / JSON-batch builder).
317
- */
318
- function compileUpdateManyBundle(name, options, dialectName = 'sqlite') {
319
- const op = flattenBatchOp((0, compile_crud_1.compileUpdateMany)(dialectName, options), 'updateMany');
320
- const plan = (0, tx_1.deriveBatchPlan)('update', [op]);
321
- return { dialect: dialectName, name, statement: { sql: op.sql, params: op.params }, optionalHeads: [], relations: {}, transaction: plan };
322
- }
323
- /**
324
- * Compile a `deleteMany` into a batch write {@link SqlBundle} — a PK-set IN-list DELETE (single-key)
325
- * or one DELETE per composite-key group, driven by the v1 `DBConditions` builder (`compileDeleteMany`).
326
- */
327
- function compileDeleteManyBundle(name, options, dialectName = 'sqlite') {
328
- const components = (0, compile_crud_1.compileDeleteMany)({ dialect: dialectName, ...options });
329
- const ops = components.map((c, i) => flattenBatchOp(c, `deleteMany group ${i}`));
330
- if (ops.length === 0) {
331
- // Empty key set: nothing to delete. Emit a no-op plan (zero statements is rejected by
332
- // deriveBatchPlan, so surface a single always-false DELETE keyed by the v1 empty IN-list is
333
- // NOT needed — an empty deleteMany simply has no statements). Represent as an empty transaction.
334
- return { dialect: dialectName, name, statement: { sql: '', params: [] }, optionalHeads: [], relations: {}, transaction: { phase: 'remove', entityFrom: null, statements: [], onIdempotentHit: 'rollback' } };
335
- }
336
- const plan = (0, tx_1.deriveBatchPlan)('remove', ops);
337
- return { dialect: dialectName, name, statement: { sql: ops[0].sql, params: ops[0].params }, optionalHeads: [], relations: {}, transaction: plan };
338
- }
339
- /**
340
- * Execute a COMPOSITE (multi-write) Command end-to-end as ONE real SQLite transaction with gate-
341
- * first short-circuit + DAG-ordered statements (spec §6 / §14).
342
- */
343
- function executeCompositeCommand(contract, entries, phase, input, options) {
344
- const bundle = compileCompositeWriteBundle(contract, entries, phase, options.dialect);
345
- return executeTransactionBundle(bundle, input, options);
346
- }
347
- /**
348
- * Execute a Command end-to-end as ONE real SQLite transaction with gate-first short-circuit
349
- * (spec §6): compile the Command + its save contract into a {@link SqlBundle} with a transaction
350
- * plan, then run {@link executeTransactionBundle}. The v2 public write path.
351
- *
352
- * @throws {SqlFailure} a mapped driver failure (the transaction ROLLBACKs first).
353
- */
354
- function executeCommand(contract, writes, phase, input, options) {
355
- const bundle = compileWriteBundle(contract, options.entry, writes, phase, options.dialect);
356
- return executeTransactionBundle(bundle, input, options);
357
- }
358
- /**
359
- * Execute a {@link SqlBundle}'s derived transaction plan (spec §6/§8) as ONE real SQLite
360
- * transaction. The SAME code path a thin per-language runtime follows: it consumes ONLY the
361
- * serialized {@link TransactionPlan} (pure JSON) + a SQL driver, never re-deriving the plan.
362
- *
363
- * @throws if the bundle carries no transaction plan, or {@link SqlFailure} on a driver failure.
364
- */
365
- function executeTransactionBundle(bundle, input, options) {
366
- if (bundle.transaction === undefined) {
367
- throw new Error('scp write: this bundle carries no transaction plan (not a write-time-relations Command bundle)');
368
- }
369
- return (0, tx_1.executeTransaction)(options.db, bundle.transaction, input, bundle.dialect);
370
- }
371
- /**
372
- * The v2 typed-object read surface (spec §4/§5/§12): run a read behavior whose output is a row
373
- * list (a Select), then wrap each raw row in a plain TYPED-OBJECT with read relations attached.
374
- * A relation named in `options.with` is declaratively batch-prefetched; every other declared
375
- * relation is lazy (a prototype getter firing the SAME compiled op over the sibling set). Both
376
- * surfaces share the ONE compiled relation op in the bundle.
377
- *
378
- * @throws if the behavior output is not a row list (the typed-object read surface is for reads).
379
- */
380
- function read(contract, input, options) {
381
- return readBundle(compileBundle(contract, options.entry, options.relations, options.dialect), input, options);
382
- }
383
- /** {@link read} against an already-compiled {@link SqlBundle} (the published §8 artifact). */
384
- function readBundle(bundle, input, options) {
385
- const out = executeBundle(bundle, input, options);
386
- if (!Array.isArray(out)) {
387
- throw new Error(`scp read: the read behavior output is not a row list (got ${out === null ? 'null' : typeof out}); ` +
388
- `the typed-object read surface expects a Select-shaped output`);
389
- }
390
- const rawRows = out;
391
- const readOpts = {
392
- ...(options.with !== undefined ? { with: options.with } : {}),
393
- ...(options.hydrate !== undefined ? { hydrate: options.hydrate } : {}),
394
- // CROSS-DB relations (V0 R1): forward the connection registry so a tagged relation routes to
395
- // its target DB. Absent for a single-DB read (every relation runs on the primary `db`).
396
- ...(options.connections !== undefined ? { connections: options.connections } : {}),
397
- };
398
- return (0, typed_object_1.buildResultSet)(rawRows, bundle.relations, options.db, readOpts);
399
- }
400
- //# sourceMappingURL=runtime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/scp/runtime.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAsIH,0CAMC;AAOD,sCAuCC;AAUD,sCAcC;AA2CD,gDAYC;AASD,oDAMC;AAgCD,gDAoCC;AAoBD,kEA+BC;AA6BD,0DA8BC;AAMD,0DAQC;AAMD,0DAeC;AAMD,0DASC;AASD,wCASC;AASD,4DAKC;AAgBD,oBAMC;AAGD,gCAqBC;AAtkBD,qCAAsC;AAwkB7B,2FAxkBA,mBAAU,OAwkBA;AAvkBnB,yCAIoB;AACpB,iDAAkE;AAIlE,2DAUiC;AACjC,qCASsB;AACtB,yDAKgC;AAChC,+CAAkE;AAClE,yDAAoE;AAEpE,qCAKkB;AA4DlB,uFAAuF;AACvF,SAAS,aAAa,CAAC,SAAoB;IACzC,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,MAAM,IAAI,CAAC;YAAE,SAAS;QAC1B,IAAI,KAAK,IAAI,CAAC;YAAE,SAAS;QACzB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,4EAA4E;AAC5E,SAAS,gBAAgB,CAAC,SAAoB;IAC5C,MAAM,CAAC,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK,SAAS,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAChD,MAAM,CAAC,GAAI,CAA2B,CAAC,SAAS,CAAC;IACjD,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,QAAQ,CAAC;AAC5D,CAAC;AA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