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,422 +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
- // ALWAYS-ON read de-box (issue #59), STATIC: the FAIL-CLOSED materialize resolver is precomputed
81
- // ONCE from the model's INLINE `static columns` declaration at registration and carried on the
82
- // contract — pure in-memory map lookups, ZERO per-read DB introspection. Coverage is enforced at
83
- // registration (a typed read whose projected columns aren't declared cannot be published), so
84
- // INT→number / BIGINT→string / DATE→string / BOOLEAN→boolean fires for every read — never a silent
85
- // raw (rounded i64) result from an undeclared column.
86
- return executeBundle(compileBundle(contract, options.entry, options.relations, options.dialect, undefined, contract.resolveColumnType), input, options);
87
- }
88
- /**
89
- * Compile ONE behavior method into the serializable STATIC {@link SqlBundle} (spec §8) — the
90
- * published multi-language artifact. SYMBOLIC (no concrete input). A read method compiles to a
91
- * {@link ReadGraph}; a single-write method to a `makeSQL` statement. Pure JSON throughout.
92
- */
93
- function compileBundle(contract, entry, relations = [], dialectName = 'sqlite', findFilterModel, resolveColumnType) {
94
- const component = entry ? contract.components.find((c) => c.name === entry) : contract.components[0];
95
- if (component === undefined)
96
- throw new Error(`scp runtime: entry component '${entry ?? '<first>'}' not found in contract`);
97
- const relationOps = {};
98
- for (const decl of relations) {
99
- if (relationOps[decl.name] !== undefined) {
100
- throw new Error(`scp runtime: duplicate relation declaration '${decl.name}'`);
101
- }
102
- // Bake the child column materializers (issue #59) from the SINGLE static column-type resolver at
103
- // compile — the relation batch's child rows then de-box with ZERO introspection, via the SAME
104
- // resolution the primary read uses (no separate materializer pass).
105
- relationOps[decl.name] = (0, relation_1.compileRelationOp)({ ...decl, dialect: decl.dialect ?? dialectName }, resolveColumnType);
106
- }
107
- if (isWriteComponent(component)) {
108
- const writeNode = primaryNodeOf(component);
109
- const op = (0, tx_1.compileWriteNode)(writeNode, dialectName);
110
- return {
111
- dialect: dialectName,
112
- name: component.name,
113
- statement: { sql: op.sql, params: op.params },
114
- optionalHeads: [],
115
- relations: relationOps,
116
- };
117
- }
118
- const readGraph = (0, static_bundle_1.compileReadGraph)(contract, dialectName, entry, findFilterModel, resolveColumnType);
119
- return {
120
- dialect: dialectName,
121
- name: readGraph.name,
122
- readGraph,
123
- optionalHeads: readGraph.optionalHeads,
124
- relations: relationOps,
125
- };
126
- }
127
- /**
128
- * Execute a {@link SqlBundle} (the §8 published artifact) end-to-end via the static makeSQL
129
- * runtime + REAL SQLite. Read bundles run the read graph via bc `runBehavior`; single-statement
130
- * write bundles run the write (RETURNING rows / summary). The SAME code path a thin per-language
131
- * runtime follows — it consumes ONLY the serialized bundle + bc, never re-running the compile.
132
- *
133
- * @throws {SqlFailure} a mapped driver failure re-surfaced at the boundary.
134
- */
135
- function executeBundle(bundle, input, options) {
136
- if (bundle.statement !== undefined && bundle.transaction === undefined) {
137
- const view = {
138
- dialect: bundle.dialect,
139
- name: bundle.name,
140
- statements: [bundle.statement],
141
- optionalHeads: bundle.optionalHeads,
142
- };
143
- return (0, static_bundle_1.executeStaticWrite)(view, input, options.db);
144
- }
145
- if (bundle.readGraph === undefined) {
146
- throw new Error(`scp runtime: bundle '${bundle.name}' carries neither a read graph nor a write statement`);
147
- }
148
- return (0, static_bundle_1.executeReadGraph)(bundle.readGraph, input, options.db);
149
- }
150
- /**
151
- * Execute a READ {@link SqlBundle} end-to-end via the ASYNC PG / MySQL execution model (#40): bc
152
- * `runBehaviorAsync` drives map iteration / wire binding / Φ output and dispatches independent
153
- * sibling read nodes in bounded parallel against the pooled async executor. This is the PRODUCTION
154
- * live-DB read entry point — the async twin of {@link executeBundle} for read bundles.
155
- *
156
- * Byte-identical composition (SAME IR, SAME per-node SQL text + params, SAME Φ output) to the
157
- * serial `executeBundle`; concurrency changes only the wall-clock. A single-relation (zero-sibling)
158
- * read graph runs exactly one query, so it is identical to the serial path either way.
159
- *
160
- * A single-statement WRITE bundle is NOT accepted here — the write-tx path stays sync + serial
161
- * (`executeBundle` / `executeTransactionBundle`); this async path is READ-only.
162
- *
163
- * @throws {SqlFailure} a mapped driver failure re-surfaced at the boundary.
164
- */
165
- async function executeBundleAsync(bundle, input, options) {
166
- if (bundle.readGraph === undefined) {
167
- throw new Error(`scp runtime: executeBundleAsync requires a READ bundle ('${bundle.name}' carries no read graph); ` +
168
- `the write-tx path stays synchronous + serial (use executeBundle / executeTransactionBundle).`);
169
- }
170
- return (0, static_bundle_1.executeReadGraphAsync)(bundle.readGraph, input, options.exec);
171
- }
172
- /**
173
- * Compile + execute a READ behavior method via the ASYNC PG / MySQL execution model (#40). The
174
- * async twin of {@link executeBehavior} for reads: compile the contract to a {@link SqlBundle}
175
- * (SYMBOLIC), then run its read graph through {@link executeBundleAsync}.
176
- *
177
- * @throws {SqlFailure} a mapped driver failure re-surfaced at the boundary.
178
- */
179
- async function executeBehaviorAsync(contract, input, options) {
180
- // ALWAYS-ON read de-box (issue #59), live PG/MySQL, STATIC: the materialize resolver is precomputed
181
- // from the model's DDL at registration and carried on the contract — ZERO per-read introspection
182
- // (no information_schema round-trips). PAIR with the per-CONNECTION driver de-box config, set ONCE
183
- // at pool creation (mysql2 supportBigNumbers+bigNumberStrings+dateStrings; pg date type parsers) —
184
- // see `pgDeboxExecutor` / `mysqlDeboxExecutor`.
185
- return executeBundleAsync(compileBundle(contract, options.entry, options.relations, options.dialect, undefined, contract.resolveColumnType), input, options);
186
- }
187
- // ── Write-time relations: Command bundle + 1-tx execution (WS5, #25 — spec §6) ──
188
- /**
189
- * Find the single base-write catalog node (`Insert`/`Update`/`Delete`) of a Command component.
190
- * WS5 initial scope is a single-statement Command (spec §6/§13). More than one write node ⇒ the
191
- * multi-write DAG derivation (WS8, rejected loudly here).
192
- */
193
- function baseWriteNodeOf(component) {
194
- const writes = component.body.filter(
195
- // `fanout` (bc 0.7.3+ FanoutNode) is excluded from narrowing here: litedbmodel never emits
196
- // it, and it carries no base write op, so it can never be a write node.
197
- (n) => !('cond' in n) &&
198
- !('map' in n) &&
199
- !('fanout' in n) &&
200
- (n.component === 'Insert' || n.component === 'Update' || n.component === 'Delete'));
201
- if (writes.length === 0) {
202
- throw new Error(`scp write: Command '${component.name}' has no base write (Insert/Update/Delete) node`);
203
- }
204
- if (writes.length > 1) {
205
- throw new Error(`scp write: Command '${component.name}' has ${writes.length} base write nodes; WS5 initial ` +
206
- `scope is a SINGLE-statement Command + write-time relations (multi-write DAG is WS8, spec §6/§13).`);
207
- }
208
- return writes[0];
209
- }
210
- /**
211
- * Compile a Command method + its `entityWrites` save contract into a {@link SqlBundle} carrying
212
- * the derived, gate-first write-time-relations {@link TransactionPlan} (spec §6/§8). The base
213
- * write op is compiled ONCE (the SAME `compileWriteNode` — complete tuned SQL + deferred
214
- * Expression-IR params); {@link deriveTransactionPlan} lowers the lifecycle's §6 effect arrays
215
- * around it into the ordered statement list. Pure JSON; a WS7 runtime honors the SAME plan.
216
- */
217
- function compileWriteBundle(contract, entry, writes, phase, dialectName = 'sqlite', resolveColumnType) {
218
- const component = contract.components.find((c) => c.name === entry);
219
- if (component === undefined)
220
- throw new Error(`scp write: entry component '${entry}' not found in contract`);
221
- const lifecycle = (0, writes_1.lifecycleFor)(writes, phase);
222
- if (lifecycle === undefined) {
223
- throw new Error(`scp write: the '${phase}' lifecycle is not declared in the entityWrites save contract`);
224
- }
225
- const writeNode = baseWriteNodeOf(component);
226
- // MySQL has no native RETURNING; when the base write is an INSERT…RETURNING carrying a PK
227
- // descriptor, annotate it with the strip-before-execute PK hint so the mysql emulation re-selects
228
- // by the REAL PK (not a hardcoded `id`). PG/SQLite keep the op verbatim (native RETURNING).
229
- const baseOp = dialectName === 'mysql' ? (0, tx_1.mysqlPkHint)((0, tx_1.compileWriteNode)(writeNode, dialectName)) : (0, tx_1.compileWriteNode)(writeNode, dialectName);
230
- const base = { op: baseOp, label: `${writeNode.component}` };
231
- const plan = (0, tx_1.deriveTransactionPlan)(phase, [base], lifecycle, dialectName);
232
- const bundle = {
233
- dialect: dialectName,
234
- name: component.name,
235
- statement: { sql: baseOp.sql, params: baseOp.params },
236
- optionalHeads: [],
237
- relations: {},
238
- transaction: plan,
239
- };
240
- // Codegen typed de-box (spec §4.1/§9): when the schema/DDL column-type SoT is supplied, annotate
241
- // the write bundle with the TransactionResult `outputType` (entity/returnedRows rows typed via the
242
- // resolver + the write's target/RETURNING) so bc's typed(-raw) emitters materialize a concrete
243
- // struct for the result. Fail-closed inside `annotateWriteBundleOutType`. Absent resolver → the
244
- // bundle stays un-annotated (interpret/boxed only, back-compat).
245
- return resolveColumnType === undefined ? bundle : (0, writeouttype_1.annotateWriteBundleOutType)(bundle, resolveColumnType);
246
- }
247
- /**
248
- * Compile a COMPOSITE (multi-write) Command into a {@link SqlBundle} carrying ONE derived,
249
- * gate-first, TOPOLOGICALLY-ORDERED transaction plan (spec §6 nested write / §14). Each entry
250
- * contributes a named base write + its effects; a later member depends on an earlier via
251
- * `$.ref.<name>.*`. {@link deriveTransactionPlan} builds the DAG + gate-first constraint and
252
- * derives the ordered plan; a cycle / dangling ref is ESCALATED. Pure JSON.
253
- */
254
- function compileCompositeWriteBundle(contract, entries, phase, dialectName = 'sqlite') {
255
- if (entries.length < 2) {
256
- throw new Error('scp write: a composite write bundle needs at least 2 named write members (use compileWriteBundle for a single write).');
257
- }
258
- const bases = [];
259
- let firstBaseOp;
260
- let firstName = '';
261
- for (const e of entries) {
262
- const component = contract.components.find((c) => c.name === e.entry);
263
- if (component === undefined)
264
- throw new Error(`scp write: entry component '${e.entry}' not found in contract`);
265
- if (firstBaseOp === undefined)
266
- firstName = component.name;
267
- const writeNode = baseWriteNodeOf(component);
268
- const baseOp = (0, tx_1.compileWriteNode)(writeNode, dialectName);
269
- if (firstBaseOp === undefined)
270
- firstBaseOp = baseOp;
271
- bases.push({ op: baseOp, label: `${writeNode.component} ${e.name}`, name: e.name, effects: e.lifecycle.effects });
272
- }
273
- const plan = (0, tx_1.deriveTransactionPlan)(phase, bases, { effects: {} }, dialectName);
274
- return {
275
- dialect: dialectName,
276
- name: firstName,
277
- statement: { sql: firstBaseOp.sql, params: firstBaseOp.params },
278
- optionalHeads: [],
279
- relations: {},
280
- transaction: plan,
281
- };
282
- }
283
- // ── Batch writes: createMany / updateMany / deleteMany (a v1→v2 regression fix) ──
284
- //
285
- // A batch write is ONE LOGICAL operation that produces N grouped SQL statements (createMany with a
286
- // heterogeneous column-set groups records into one INSERT per group, mirroring `DBModel._insert`;
287
- // updateMany is one UNNEST/JSON/CASE statement; deleteMany is a PK-set IN-list DELETE). This is
288
- // DISTINCT from the deferred composite multi-write DAG (`baseWriteNodeOf` still rejects >1 authored
289
- // base write). The batch compilers (`compileInsertMany`/`compileUpdateMany`/`compileDeleteMany`) copy
290
- // the v1 builders byte-for-byte; here they are lowered into a gate-free {@link TransactionPlan} of
291
- // body statements ({@link deriveBatchPlan}), so ALL FIVE runtimes execute the multi-statement batch
292
- // through the SAME per-statement tx loop with no runtime change (concrete params are literalized to
293
- // bc IR so they survive the render pass — see `deriveBatchPlan`/`literalize`).
294
- /** Flatten a batch compiler's `MakeSQL` component to a concrete `{ sql, params }` op. */
295
- function flattenBatchOp(node, label) {
296
- const assembled = (0, makesql_1.assembleMakeSQL)(node);
297
- return { sql: assembled.sql, params: assembled.params, label };
298
- }
299
- /**
300
- * Compile a `createMany` into a batch write {@link SqlBundle} carrying a gate-free
301
- * {@link TransactionPlan}. Heterogeneous column-set groups become MULTIPLE ordered INSERT
302
- * statements — byte-identical to what `DBModel._insert` emits per group (via `compileInsertMany`).
303
- *
304
- * `pk` (the target PK descriptor) is REQUIRED when the createMany carries a RETURNING clause on the
305
- * MySQL dialect: a batch INSERT persists N rows, so the MySQL RETURNING emulation must re-select ALL
306
- * N (a range on the AUTO_INCREMENT column, or the client-supplied PK values), not a single `id`.
307
- */
308
- function compileCreateManyBundle(name, options, dialectName = 'sqlite', resolveColumnType) {
309
- const components = (0, compile_crud_1.compileInsertMany)(dialectName, options);
310
- const ops = components.map((c, i) => {
311
- const flat = flattenBatchOp(c, `createMany group ${i}`);
312
- // On MySQL, annotate a RETURNING batch INSERT with the PK hint so the driver emulation
313
- // re-selects every inserted row of the group by the real PK.
314
- if (dialectName === 'mysql' && options.pk !== undefined && options.returning !== undefined) {
315
- return { ...flat, ...(0, tx_1.mysqlPkHint)({ sql: flat.sql, params: flat.params, pk: options.pk }) };
316
- }
317
- return flat;
318
- });
319
- const plan = (0, tx_1.deriveBatchPlan)('create', ops);
320
- // `ops` is never empty here: `deriveBatchPlan` throws on zero ops, and a `createMany` always groups
321
- // into >=1 INSERT. Fail LOUDLY rather than emitting an empty `sql` fallback (an empty-ops bundle is a
322
- // compile bug, not a default — 'defaults in schema, not code'). The `statement` mirrors the batch plan's
323
- // first (group-0) statement, matching the updateMany/deleteMany bundle shape below.
324
- const head = ops[0];
325
- if (head === undefined) {
326
- 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.`);
327
- }
328
- const bundle = { dialect: dialectName, name, statement: { sql: head.sql, params: head.params }, optionalHeads: [], relations: {}, transaction: plan };
329
- // Codegen typed de-box (spec §4.1/§9): annotate the batch write with the TransactionResult
330
- // `outputType` when the schema SoT resolver is supplied (returnedRows rows typed via the RETURNING
331
- // + target table). Fail-closed. Absent resolver → un-annotated (back-compat).
332
- return resolveColumnType === undefined ? bundle : (0, writeouttype_1.annotateWriteBundleOutType)(bundle, resolveColumnType);
333
- }
334
- /**
335
- * Compile an `updateMany` into a batch write {@link SqlBundle} (one UNNEST/JSON/CASE statement,
336
- * byte-identical to `compileUpdateMany` driving the v1 `buildUpdateMany` / JSON-batch builder).
337
- */
338
- function compileUpdateManyBundle(name, options, dialectName = 'sqlite') {
339
- const op = flattenBatchOp((0, compile_crud_1.compileUpdateMany)(dialectName, options), 'updateMany');
340
- const plan = (0, tx_1.deriveBatchPlan)('update', [op]);
341
- return { dialect: dialectName, name, statement: { sql: op.sql, params: op.params }, optionalHeads: [], relations: {}, transaction: plan };
342
- }
343
- /**
344
- * Compile a `deleteMany` into a batch write {@link SqlBundle} — a PK-set IN-list DELETE (single-key)
345
- * or one DELETE per composite-key group, driven by the v1 `DBConditions` builder (`compileDeleteMany`).
346
- */
347
- function compileDeleteManyBundle(name, options, dialectName = 'sqlite') {
348
- const components = (0, compile_crud_1.compileDeleteMany)({ dialect: dialectName, ...options });
349
- const ops = components.map((c, i) => flattenBatchOp(c, `deleteMany group ${i}`));
350
- if (ops.length === 0) {
351
- // Empty key set: nothing to delete. Emit a no-op plan (zero statements is rejected by
352
- // deriveBatchPlan, so surface a single always-false DELETE keyed by the v1 empty IN-list is
353
- // NOT needed — an empty deleteMany simply has no statements). Represent as an empty transaction.
354
- return { dialect: dialectName, name, statement: { sql: '', params: [] }, optionalHeads: [], relations: {}, transaction: { phase: 'remove', entityFrom: null, statements: [], onIdempotentHit: 'rollback' } };
355
- }
356
- const plan = (0, tx_1.deriveBatchPlan)('remove', ops);
357
- return { dialect: dialectName, name, statement: { sql: ops[0].sql, params: ops[0].params }, optionalHeads: [], relations: {}, transaction: plan };
358
- }
359
- /**
360
- * Execute a COMPOSITE (multi-write) Command end-to-end as ONE real SQLite transaction with gate-
361
- * first short-circuit + DAG-ordered statements (spec §6 / §14).
362
- */
363
- function executeCompositeCommand(contract, entries, phase, input, options) {
364
- const bundle = compileCompositeWriteBundle(contract, entries, phase, options.dialect);
365
- return executeTransactionBundle(bundle, input, options);
366
- }
367
- /**
368
- * Execute a Command end-to-end as ONE real SQLite transaction with gate-first short-circuit
369
- * (spec §6): compile the Command + its save contract into a {@link SqlBundle} with a transaction
370
- * plan, then run {@link executeTransactionBundle}. The v2 public write path.
371
- *
372
- * @throws {SqlFailure} a mapped driver failure (the transaction ROLLBACKs first).
373
- */
374
- function executeCommand(contract, writes, phase, input, options) {
375
- const bundle = compileWriteBundle(contract, options.entry, writes, phase, options.dialect);
376
- return executeTransactionBundle(bundle, input, options);
377
- }
378
- /**
379
- * Execute a {@link SqlBundle}'s derived transaction plan (spec §6/§8) as ONE real SQLite
380
- * transaction. The SAME code path a thin per-language runtime follows: it consumes ONLY the
381
- * serialized {@link TransactionPlan} (pure JSON) + a SQL driver, never re-deriving the plan.
382
- *
383
- * @throws if the bundle carries no transaction plan, or {@link SqlFailure} on a driver failure.
384
- */
385
- function executeTransactionBundle(bundle, input, options) {
386
- if (bundle.transaction === undefined) {
387
- throw new Error('scp write: this bundle carries no transaction plan (not a write-time-relations Command bundle)');
388
- }
389
- return (0, tx_1.executeTransaction)(options.db, bundle.transaction, input, bundle.dialect);
390
- }
391
- /**
392
- * The v2 typed-object read surface (spec §4/§5/§12): run a read behavior whose output is a row
393
- * list (a Select), then wrap each raw row in a plain TYPED-OBJECT with read relations attached.
394
- * A relation named in `options.with` is declaratively batch-prefetched; every other declared
395
- * relation is lazy (a prototype getter firing the SAME compiled op over the sibling set). Both
396
- * surfaces share the ONE compiled relation op in the bundle.
397
- *
398
- * @throws if the behavior output is not a row list (the typed-object read surface is for reads).
399
- */
400
- function read(contract, input, options) {
401
- // ALWAYS-ON read de-box (issue #59), STATIC: the resolver is precomputed from the model's DDL at
402
- // registration and carried on the contract — ZERO per-read introspection.
403
- return readBundle(compileBundle(contract, options.entry, options.relations, options.dialect, undefined, contract.resolveColumnType), input, options);
404
- }
405
- /** {@link read} against an already-compiled {@link SqlBundle} (the published §8 artifact). */
406
- function readBundle(bundle, input, options) {
407
- const out = executeBundle(bundle, input, options);
408
- if (!Array.isArray(out)) {
409
- throw new Error(`scp read: the read behavior output is not a row list (got ${out === null ? 'null' : typeof out}); ` +
410
- `the typed-object read surface expects a Select-shaped output`);
411
- }
412
- const rawRows = out;
413
- const readOpts = {
414
- ...(options.with !== undefined ? { with: options.with } : {}),
415
- ...(options.hydrate !== undefined ? { hydrate: options.hydrate } : {}),
416
- // CROSS-DB relations (V0 R1): forward the connection registry so a tagged relation routes to
417
- // its target DB. Absent for a single-DB read (every relation runs on the primary `db`).
418
- ...(options.connections !== undefined ? { connections: options.connections } : {}),
419
- };
420
- return (0, typed_object_1.buildResultSet)(rawRows, bundle.relations, options.db, readOpts);
421
- }
422
- //# sourceMappingURL=runtime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/scp/runtime.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAuIH,0CAgBC;AAOD,sCA0CC;AAUD,sCAcC;AA2CD,gDAYC;AASD,oDAeC;AAsCD,gDAoCC;AAoBD,kEA+BC;AA6BD,0DA8BC;AAMD,0DAQC;AAMD,0DAeC;AAMD,0DASC;AASD,wCASC;AASD,4DAKC;AAgBD,oBAYC;AAGD,gCAqBC;AAzmBD,qCAAsC;AA2mB7B,2FA3mBA,mBAAU,OA2mBA;AA1mBnB,yCAIoB;AACpB,iDAAkE;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