litedbmodel 2.2.2 → 2.2.4

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 (180) hide show
  1. package/README.md +2 -1
  2. package/dist/DBModel.d.ts.map +1 -1
  3. package/dist/DBModel.js +3 -0
  4. package/dist/DBModel.js.map +1 -1
  5. package/dist/Middleware.d.ts +19 -2
  6. package/dist/Middleware.d.ts.map +1 -1
  7. package/dist/Middleware.js +1 -0
  8. package/dist/Middleware.js.map +1 -1
  9. package/dist/decorators.d.ts.map +1 -1
  10. package/dist/decorators.js +8 -0
  11. package/dist/decorators.js.map +1 -1
  12. package/dist/drivers/MysqlHelper.d.ts +1 -1
  13. package/dist/drivers/MysqlHelper.d.ts.map +1 -1
  14. package/dist/drivers/MysqlHelper.js.map +1 -1
  15. package/dist/drivers/PostgresHelper.d.ts +1 -1
  16. package/dist/drivers/PostgresHelper.d.ts.map +1 -1
  17. package/dist/drivers/PostgresHelper.js.map +1 -1
  18. package/dist/drivers/SqliteHelper.d.ts +1 -1
  19. package/dist/drivers/SqliteHelper.d.ts.map +1 -1
  20. package/dist/drivers/SqliteHelper.js.map +1 -1
  21. package/dist/index.cjs +105 -74
  22. package/dist/scp/connection-routing.d.ts +38 -1
  23. package/dist/scp/connection-routing.d.ts.map +1 -1
  24. package/dist/scp/connection-routing.js +64 -5
  25. package/dist/scp/connection-routing.js.map +1 -1
  26. package/dist/scp/dbmodel-runtime.d.ts +2 -1
  27. package/dist/scp/dbmodel-runtime.d.ts.map +1 -1
  28. package/dist/scp/dbmodel-runtime.js +2 -1
  29. package/dist/scp/dbmodel-runtime.js.map +1 -1
  30. package/dist/scp/decorator-adapter.d.ts +22 -0
  31. package/dist/scp/decorator-adapter.d.ts.map +1 -1
  32. package/dist/scp/decorator-adapter.js +26 -0
  33. package/dist/scp/decorator-adapter.js.map +1 -1
  34. package/dist/scp/emit/emitter.d.ts +21 -10
  35. package/dist/scp/emit/emitter.d.ts.map +1 -1
  36. package/dist/scp/emit/emitter.js +119 -51
  37. package/dist/scp/emit/emitter.js.map +1 -1
  38. package/dist/scp/emit/endpoint.d.ts +3 -8
  39. package/dist/scp/emit/endpoint.d.ts.map +1 -1
  40. package/dist/scp/exec-context.d.ts +39 -17
  41. package/dist/scp/exec-context.d.ts.map +1 -1
  42. package/dist/scp/exec-context.js +69 -35
  43. package/dist/scp/exec-context.js.map +1 -1
  44. package/dist/scp/grouping.d.ts.map +1 -1
  45. package/dist/scp/grouping.js +0 -0
  46. package/dist/scp/grouping.js.map +1 -1
  47. package/dist/scp/index.cjs +257 -670
  48. package/dist/scp/index.d.ts +6 -11
  49. package/dist/scp/index.d.ts.map +1 -1
  50. package/dist/scp/index.js +10 -28
  51. package/dist/scp/index.js.map +1 -1
  52. package/dist/scp/index.mjs +257 -658
  53. package/dist/scp/leaf-transport.d.ts +127 -39
  54. package/dist/scp/leaf-transport.d.ts.map +1 -1
  55. package/dist/scp/leaf-transport.js +30 -24
  56. package/dist/scp/leaf-transport.js.map +1 -1
  57. package/dist/scp/leaves.d.ts +57 -20
  58. package/dist/scp/leaves.d.ts.map +1 -1
  59. package/dist/scp/leaves.js +224 -65
  60. package/dist/scp/leaves.js.map +1 -1
  61. package/dist/scp/makesql/compile-select.d.ts +28 -1
  62. package/dist/scp/makesql/compile-select.d.ts.map +1 -1
  63. package/dist/scp/makesql/compile-select.js +19 -17
  64. package/dist/scp/makesql/compile-select.js.map +1 -1
  65. package/dist/scp/makesql/index.d.ts +2 -2
  66. package/dist/scp/makesql/index.d.ts.map +1 -1
  67. package/dist/scp/makesql/index.js +4 -6
  68. package/dist/scp/makesql/index.js.map +1 -1
  69. package/dist/scp/makesql/tx.d.ts +43 -89
  70. package/dist/scp/makesql/tx.d.ts.map +1 -1
  71. package/dist/scp/makesql/tx.js +45 -496
  72. package/dist/scp/makesql/tx.js.map +1 -1
  73. package/dist/scp/makesql/writeouttype.d.ts +5 -7
  74. package/dist/scp/makesql/writeouttype.d.ts.map +1 -1
  75. package/dist/scp/makesql/writeouttype.js +13 -19
  76. package/dist/scp/makesql/writeouttype.js.map +1 -1
  77. package/dist/scp/middleware.d.ts +4 -4
  78. package/dist/scp/middleware.d.ts.map +1 -1
  79. package/dist/scp/middleware.js +2 -2
  80. package/dist/scp/middleware.js.map +1 -1
  81. package/dist/scp/relation.d.ts +31 -12
  82. package/dist/scp/relation.d.ts.map +1 -1
  83. package/dist/scp/relation.js +16 -6
  84. package/dist/scp/relation.js.map +1 -1
  85. package/dist/scp/typed-object.d.ts +23 -19
  86. package/dist/scp/typed-object.d.ts.map +1 -1
  87. package/dist/scp/typed-object.js +24 -30
  88. package/dist/scp/typed-object.js.map +1 -1
  89. package/dist/scp/write-bundle.d.ts +21 -70
  90. package/dist/scp/write-bundle.d.ts.map +1 -1
  91. package/dist/scp/write-bundle.js +16 -80
  92. package/dist/scp/write-bundle.js.map +1 -1
  93. package/dist/types.d.ts +12 -0
  94. package/dist/types.d.ts.map +1 -1
  95. package/dist/types.js.map +1 -1
  96. package/docs/BENCHMARK.md +26 -22
  97. package/docs/COMPARISON.md +8 -4
  98. package/docs/api/README.md +1 -1
  99. package/docs/api/classes/Conditions.md +10 -10
  100. package/docs/api/classes/DBHandler.md +17 -17
  101. package/docs/api/classes/DBModel.md +111 -104
  102. package/docs/api/classes/LimitExceededError.md +8 -8
  103. package/docs/api/classes/Middleware.md +18 -18
  104. package/docs/api/classes/SqlRaw.md +6 -6
  105. package/docs/api/classes/SqlRef.md +7 -7
  106. package/docs/api/classes/Values.md +6 -6
  107. package/docs/api/classes/WriteInReadOnlyContextError.md +5 -5
  108. package/docs/api/classes/WriteOutsideTransactionError.md +5 -5
  109. package/docs/api/functions/belongsTo.md +2 -2
  110. package/docs/api/functions/closeAllPools.md +2 -2
  111. package/docs/api/functions/condsToRecord.md +2 -2
  112. package/docs/api/functions/createMiddleware.md +2 -2
  113. package/docs/api/functions/createPostgresDriver.md +2 -2
  114. package/docs/api/functions/createSqliteDriver.md +2 -2
  115. package/docs/api/functions/dbCast.md +3 -3
  116. package/docs/api/functions/dbCastIn.md +2 -2
  117. package/docs/api/functions/dbDynamic.md +3 -3
  118. package/docs/api/functions/dbFalse.md +2 -2
  119. package/docs/api/functions/dbImmediate.md +2 -2
  120. package/docs/api/functions/dbIn.md +2 -2
  121. package/docs/api/functions/dbNotNull.md +2 -2
  122. package/docs/api/functions/dbNow.md +2 -2
  123. package/docs/api/functions/dbNull.md +2 -2
  124. package/docs/api/functions/dbRaw.md +2 -2
  125. package/docs/api/functions/dbTrue.md +2 -2
  126. package/docs/api/functions/dbUuid.md +3 -3
  127. package/docs/api/functions/dbUuidIn.md +2 -2
  128. package/docs/api/functions/formatLocalDate.md +25 -0
  129. package/docs/api/functions/formatUTCDate.md +25 -0
  130. package/docs/api/functions/getDBConfig.md +2 -2
  131. package/docs/api/functions/getDBHandler.md +2 -2
  132. package/docs/api/functions/getTransactionConnection.md +2 -2
  133. package/docs/api/functions/getTransactionContext.md +2 -2
  134. package/docs/api/functions/hasMany.md +2 -2
  135. package/docs/api/functions/hasOne.md +2 -2
  136. package/docs/api/functions/initDBHandler.md +2 -2
  137. package/docs/api/functions/isAnySqlFragment.md +2 -2
  138. package/docs/api/functions/isConnectionError.md +26 -0
  139. package/docs/api/functions/isSqlCondition.md +2 -2
  140. package/docs/api/functions/isSqlFragment.md +2 -2
  141. package/docs/api/functions/isSqlRaw.md +2 -2
  142. package/docs/api/functions/isSqlRef.md +2 -2
  143. package/docs/api/functions/isSqlTypedFragment.md +2 -2
  144. package/docs/api/functions/model.md +6 -42
  145. package/docs/api/functions/parentRef.md +2 -2
  146. package/docs/api/functions/sql.md +7 -7
  147. package/docs/api/globals.md +57 -22
  148. package/docs/api/interfaces/Column.md +31 -31
  149. package/docs/api/interfaces/ColumnOptions.md +5 -4
  150. package/docs/api/interfaces/CreatedMiddlewareClass.md +7 -7
  151. package/docs/api/interfaces/DBConfig.md +13 -11
  152. package/docs/api/interfaces/DBConfigOptions.md +8 -8
  153. package/docs/api/interfaces/DeleteOptions.md +4 -4
  154. package/docs/api/interfaces/InsertOptions.md +8 -8
  155. package/docs/api/interfaces/LimitConfig.md +4 -4
  156. package/docs/api/interfaces/MiddlewareConfig.md +15 -15
  157. package/docs/api/interfaces/ModelOptions.md +8 -7
  158. package/docs/api/interfaces/PkeyResult.md +4 -4
  159. package/docs/api/interfaces/SelectOptions.md +17 -16
  160. package/docs/api/interfaces/SqlCondition.md +6 -6
  161. package/docs/api/interfaces/SqlFragment.md +5 -5
  162. package/docs/api/interfaces/SqlTypedFragment.md +7 -7
  163. package/docs/api/interfaces/TransactionOptions.md +7 -7
  164. package/docs/api/interfaces/UpdateManyOptions.md +4 -4
  165. package/docs/api/interfaces/UpdateOptions.md +4 -4
  166. package/docs/architecture.md +452 -0
  167. package/docs/benchmark-chart.svg +225 -249
  168. package/docs/design/phase-a-execution-context.md +2 -0
  169. package/package.json +20 -5
  170. package/dist/scp/writes.d.ts +0 -251
  171. package/dist/scp/writes.d.ts.map +0 -1
  172. package/dist/scp/writes.js +0 -176
  173. package/dist/scp/writes.js.map +0 -1
  174. package/docs/proposal/contracts-architecture-feasibility.md +0 -328
  175. package/docs/proposal/contracts-architecture.md +0 -579
  176. package/docs/proposal/litedbmodel-v2-scp-architecture.md +0 -433
  177. package/docs/proposal/sql-dynamic-expansion-spec.md +0 -175
  178. package/docs/proposal/v0-coverage-matrix.md +0 -157
  179. package/docs/proposal/v2-completeness-plan.md +0 -90
  180. package/docs/proposal/v2-sql-parity-checklist.md +0 -162
@@ -11,10 +11,11 @@
11
11
  *
12
12
  * - {@link executeSQL} — the SOLE SQL transport. Binds params and runs one statement through the
13
13
  * central {@link import('./exec-context') execute/run seam} (the ONLY driver contact). Read
14
- * (`write:false`) → rows; write (`write:true`) → a one-row `[{changes,lastInsertRowid}]` summary
15
- * (RETURNING writes return their rows via `execute`). It owns the transport-level param shaping a
16
- * relation key-set needs — the dialect array encoding + deferred PG cast resolution + `?`→`$N`
17
- * render — and, when the statement is a GUARDED relation child fetch, the runaway check on its raw
14
+ * (`write:null`) → rows; write (`write:{returning}`) → a one-row `[{changes,lastInsertRowid}]`
15
+ * summary (a RETURNING write returns its rows via `execute` instead). It owns the transport-level
16
+ * param shaping a relation key-set needs — the dialect array encoding + deferred PG cast
17
+ * resolution + `?`→`$N` render — and, when the statement is a GUARDED relation child fetch, the
18
+ * runaway check on its raw
18
19
  * rows ({@link import('./limit-config').assertRelationHardLimit}): the RAW child rows exist only
19
20
  * here, since `group` already sees a nested graph and SCP itself has no throw.
20
21
  * - {@link pluck} — rows + the ordered key-column tuple → the deduped, non-null key array (the
@@ -27,10 +28,14 @@
27
28
  * the IR (C4): {@link leafHandlers} closes over a sync {@link LeafContext} and {@link
28
29
  * leafHandlersAsync} over an {@link AsyncLeafContext}. The same three symbols are what the native
29
30
  * codegen calls directly ({@link LEAF_TRANSPORT_SYMBOLS}).
31
+ *
32
+ * What the statement DOES carry is the NAME of its database (`opts.db`) — a static property of its
33
+ * model, not an environment fact: the factory owns the connection REGISTRY, the statement owns which
34
+ * entry of it it belongs to. The two meet on the {@link StatementIntent} ({@link prepareSql}), which is
35
+ * the only input `connectionFor` routes on.
30
36
  */
31
37
  Object.defineProperty(exports, "__esModule", { value: true });
32
38
  exports.LEAF_TRANSPORT_SYMBOLS = void 0;
33
- exports.spliceWhere = spliceWhere;
34
39
  exports.assembleDynamicWhere = assembleDynamicWhere;
35
40
  exports.prepareSql = prepareSql;
36
41
  exports.executeSQL = executeSQL;
@@ -46,48 +51,49 @@ const json_array_1 = require("./makesql/json-array");
46
51
  const compile_relation_1 = require("./makesql/compile-relation");
47
52
  const grouping_1 = require("./grouping");
48
53
  // ── the DYNAMIC (SKIP) WHERE: assembled by the transport, at execution time ────────────────────
49
- /**
50
- * The SQL keywords that may follow a WHERE clause. The WHERE must be spliced BEFORE the first of
51
- * them, so a dynamic WHERE lands at exactly the position a bounded one occupies.
52
- */
53
- const WHERE_TAIL_RE = /\s+(GROUP BY|ORDER BY|LIMIT|OFFSET|FOR UPDATE|RETURNING)\b/i;
54
- /** Splice a ` WHERE …` clause (leading space included, or `''`) into `baseSql` before its first tail keyword. */
55
- function spliceWhere(baseSql, whereSql) {
56
- if (whereSql === '')
57
- return baseSql;
58
- const tail = WHERE_TAIL_RE.exec(baseSql);
59
- return tail === null ? baseSql + whereSql : baseSql.slice(0, tail.index) + whereSql + baseSql.slice(tail.index);
60
- }
61
54
  /**
62
55
  * Assemble the effective statement from a DYNAMIC WHERE plan: drop the SKIPPED fragments (`skipped`
63
- * true — the per-call SKIP decision the emitter carried as DATA), join the survivors with ` WHERE ` /
64
- * ` AND `, splice the clause into the base `sql` before its first tail keyword ({@link spliceWhere}) —
65
- * the exact position a bounded WHERE occupies — and bind the surviving fragments' params BEFORE the
66
- * base params (the WHERE `?`s precede the tail's).
56
+ * true — the per-call SKIP decision the emitter carried as DATA), join the survivors with ` AND `, and
57
+ * CONCATENATE the three pieces the plan and the ports already hold — the statement's HEAD (`sql`, which
58
+ * ends at its WHERE region), the assembled clause, and the plan's `tail`. The params follow the same
59
+ * three-way order: the head's, the survivors', the tail's.
60
+ *
61
+ * There is nothing to LOCATE here. The emitter's SELECT builder is what puts the WHERE in the statement,
62
+ * so it hands the boundary over ({@link import('./makesql/compile-select').SelectBundle}) instead of
63
+ * leaving the transport to rediscover it: `plan.lead` says whether the head already ends in a WHERE (so
64
+ * the clause CONTINUES it) or not (so it OPENS one), and `plan.tailParams` are the tail's own bound
65
+ * values. That is what removed a lexical scan the five transports each carried a copy of — one that
66
+ * took a NESTED statement's tail keyword for the outer statement's (#198), counted a QUOTED `?` the
67
+ * placeholder render skips (#202), and derived a byte offset that is not the same number in five
68
+ * languages.
67
69
  *
68
70
  * A SKIP predicate's presence is per-CALL, so the FINAL statement can only be determined here, at
69
71
  * execution time — which is also why `?`→`$N` is rendered after this ({@link prepareSql}), never at
70
- * emit time. A statement with NO optional predicate carries no plan at all: its WHERE is spliced into
71
- * the static `sql` at emit time and it never reaches this function.
72
+ * emit time. Only the ACTUALLY-optional predicates are in the plan (CLAUDE.md §2): a read with none
73
+ * carries no plan at all and never reaches this function, and one whose fragments are all skipped
74
+ * leaves the emitted statement exactly as it was compiled (head + tail, no clause).
72
75
  */
73
76
  function assembleDynamicWhere(p) {
74
- const frags = p.whereDynamic.frags.filter((f) => !f.skipped);
75
- let whereSql = '';
76
- const whereParams = [];
77
- frags.forEach((f, i) => {
78
- whereSql += (i === 0 ? ' WHERE ' : ' AND ') + f.sql;
79
- whereParams.push(...f.params);
80
- });
81
- return { sql: spliceWhere(p.sql, whereSql), params: [...whereParams, ...p.params] };
77
+ const plan = dynamicWherePlan(p.whereDynamic);
78
+ const frags = plan.frags.filter((f) => !f.skipped);
79
+ const clause = frags.length === 0 ? '' : ` ${plan.lead} ${frags.map((f) => f.sql).join(' AND ')}`;
80
+ return {
81
+ sql: p.sql + clause + plan.tail,
82
+ params: [...p.params, ...frags.flatMap((f) => f.params), ...plan.tailParams],
83
+ };
82
84
  }
83
85
  /**
84
86
  * The effective `{sql, params}` a statement executes: the dynamic plan assembled when one is present,
85
87
  * the ports verbatim otherwise. The ONE place the two shapes converge — both transports consume it.
86
88
  */
87
89
  function effectiveStatement(p) {
90
+ // The seam's INTENT is the one boolean the statement's `write` mode reduces to (present ⇒ a write),
91
+ // plus the NAMED database it belongs to (absent ⇒ the default connection).
92
+ const write = p.write !== null;
93
+ const db = p.db ?? null;
88
94
  if (p.whereDynamic == null)
89
- return p;
90
- return { ...assembleDynamicWhere({ sql: p.sql, params: p.params, whereDynamic: p.whereDynamic }), write: p.write };
95
+ return { sql: p.sql, params: p.params, write, db };
96
+ return { ...assembleDynamicWhere({ sql: p.sql, params: p.params, whereDynamic: p.whereDynamic }), write, db };
91
97
  }
92
98
  /** Normalize a driver integer (number|bigint) to bc's `int` value model (BigInt). */
93
99
  function toBcInt(v) {
@@ -127,7 +133,14 @@ function encodeParams(params, dialect) {
127
133
  function isTupleSet(param) {
128
134
  return param.length > 0 && Array.isArray(param[0]);
129
135
  }
130
- /** Prepare a statement for the seam: resolve deferred PG cast(s), render `?`→`$N`, encode params. */
136
+ /**
137
+ * Prepare a statement for the seam: resolve deferred PG cast(s), render `?`→`$N`, encode params, and
138
+ * carry the ONE {@link StatementIntent} both seams take. The intent is the statement's RUN MODE
139
+ * ({@link effectiveStatement} — a write mode present ⇒ a write), NOT the branch: the branch picks the
140
+ * SEAM (`returning` ⇒ the row seam), the intent picks the CONNECTION
141
+ * ({@link import('./connection-routing').resolvePool}), so a RETURNING write runs on `execute` and
142
+ * still routes to the WRITER. The four native transports derive it the same way (#207).
143
+ */
131
144
  function prepareSql(p, dialect) {
132
145
  let sql = p.sql;
133
146
  if (dialect === 'postgres') {
@@ -137,7 +150,11 @@ function prepareSql(p, dialect) {
137
150
  }
138
151
  sql = (0, handler_1.renderPlaceholders)(sql, dialect);
139
152
  const bound = encodeParams(p.params, dialect);
140
- const intent = { write: p.write === true };
153
+ // The NAMED database rides on the SAME intent as the write mode, because it is resolved by the same
154
+ // function: `resolvePool` picks the named connection's reader/writer PAIR first, then applies the
155
+ // write/sticky split within it. Absent ⇒ the key is omitted (the default connection), which keeps a
156
+ // single-DB intent identical to the one this seam has always built.
157
+ const intent = { write: p.write, ...(p.db != null ? { db: p.db } : {}) };
141
158
  return { sql, bound, intent };
142
159
  }
143
160
  /**
@@ -161,12 +178,12 @@ function writeSummary(info) {
161
178
  * int and float as DISTINCT kinds, so a column declared `Int` cannot be satisfied by a JS number on any
162
179
  * dialect, and gating exactness per endpoint made SQLite disagree with PostgreSQL and MySQL (whose
163
180
  * integer type parsers are unconditional — `configurePgDeboxTypeParsers`, `mysqlDeboxPoolOptions`),
164
- * which the conformance corpus rejects as dialect-variant. `bigint` is retained as a port because the
165
- * generated modules declare it, but it no longer selects the seam.
181
+ * which the conformance corpus rejects as dialect-variant. There is therefore no exactness port at all
182
+ * (#193 deleted the `bigint` one, which no language read).
166
183
  */
167
184
  function executeSQL(p, ctx) {
168
185
  const prepared = prepareSql(effectiveStatement(p), ctx.dialect);
169
- if (p.write === true && p.returning !== true)
186
+ if (p.write !== null && !p.write.returning)
170
187
  return writeSummary((0, exec_context_1.run)(ctx.exec, prepared.sql, prepared.bound, prepared.intent));
171
188
  const rows = (0, exec_context_1.executeSafe)(ctx.exec, prepared.sql, prepared.bound, prepared.intent);
172
189
  (0, limit_config_1.assertRelationHardLimit)(rows, p.guard);
@@ -175,7 +192,7 @@ function executeSQL(p, ctx) {
175
192
  /** The ASYNC (live PG / MySQL) `executeSQL` body — the twin of {@link executeSQL} over the async seam. */
176
193
  async function executeSQLAsync(p, ctx) {
177
194
  const prepared = prepareSql(effectiveStatement(p), ctx.dialect);
178
- if (p.write === true && p.returning !== true)
195
+ if (p.write !== null && !p.write.returning)
179
196
  return writeSummary(await (0, exec_context_1.runAsync)(ctx.execAsync, prepared.sql, prepared.bound, prepared.intent));
180
197
  const rows = (await (0, exec_context_1.executeAsync)(ctx.execAsync, prepared.sql, prepared.bound, prepared.intent));
181
198
  (0, limit_config_1.assertRelationHardLimit)(rows, p.guard);
@@ -203,54 +220,196 @@ function pluck(p) {
203
220
  */
204
221
  function group(p) {
205
222
  const byKey = (0, grouping_1.groupByKey)(p.children, p.fk);
206
- return p.parents.map((par) => ({ ...par, [p.into]: (0, grouping_1.attachToParent)(par, p.pk, byKey, p.single === true) }));
223
+ return p.parents.map((par) => ({ ...par, [p.into]: (0, grouping_1.attachToParent)(par, p.pk, byKey, p.single) }));
207
224
  }
208
225
  // ── handler maps: the boundary injection a generated module's bind()/bindAsync() consumes ──
209
226
  /**
210
- * Read the OPTIONAL relation `guard` port. Absent (or null) ⇒ the statement is uncapped. The cap
227
+ * The DECLARED type of every leaf PORT and every field of every leaf struct, exactly as the catalog
228
+ * spells it ({@link import('./leaf-transport')}) — the predicate {@link portTyped} confirms. A `|null`
229
+ * suffix marks a NULLABLE field, whose `null` is the declared absence (no write mode / plan / cap /
230
+ * model). `int` is bc's `int` value model, which on this plane is a BigInt and nothing else.
231
+ * `string[]` is the ordered key-column TUPLE (`col` / `pk` / `fk`): every element must be a column
232
+ * NAME, the same element check the go `portStrings` / rust `port_strings` probes make.
233
+ */
234
+ const PORT_TYPES = {
235
+ bool: (v) => typeof v === 'boolean',
236
+ int: (v) => typeof v === 'bigint',
237
+ string: (v) => typeof v === 'string',
238
+ list: (v) => Array.isArray(v),
239
+ 'string[]': (v) => Array.isArray(v) && v.every((e) => typeof e === 'string'),
240
+ record: (v) => typeof v === 'object' && v !== null && !Array.isArray(v),
241
+ };
242
+ /**
243
+ * Confirm ONE unboxed value against its DECLARED type — the ONE wrong-type failure on the TS plane, and
244
+ * the twin of the go `portErr` wrong-variant half / rust `port_mismatch`. A field of the wrong type is
245
+ * the same ABI break as a missing one, for the same reason: the generator emits the literal the port's
246
+ * type says, so nothing else can arrive from a generated module. Coercing it instead ran an INSERT on
247
+ * the read seam (`returning` not a bool), applied a predicate the call SKIPPED (`skipped` not a bool),
248
+ * erased one entirely (`sql` not a string), or FLIPPED a relation's cardinality — `single` cast to a
249
+ * bool turned the one nested child into a LIST, and `into` cast to a string nested it under `"42"`
250
+ * (#213).
251
+ */
252
+ function portTyped(value, what, declared) {
253
+ const kind = (declared.endsWith('|null') ? declared.slice(0, -'|null'.length) : declared);
254
+ if (kind !== declared && value === null)
255
+ return null;
256
+ if (!PORT_TYPES[kind](value)) {
257
+ // bc's `int` value model is a BigInt on this plane, so the rendering has to survive one appearing
258
+ // where another type was declared — a bare JSON.stringify throws on it and would replace the port
259
+ // failure with a serializer failure.
260
+ const got = JSON.stringify(value, (_k, v) => (typeof v === 'bigint' ? `${v}n` : v));
261
+ throw new Error(`scp leaf: ${what} must be ${declared}, got ${got}`);
262
+ }
263
+ return value;
264
+ }
265
+ /**
266
+ * Read ONE DECLARED field out of a payload / struct that is PRESENT — the ONE fail-closed field read on
267
+ * the TS plane, for all THREE leaves, and the twin of the go `optRowField` / rust `take_opt_row`
268
+ * discipline. Presence and the DECLARED type are confirmed at the SAME read, exactly as go's and rust's
269
+ * typed probes confirm both.
270
+ *
271
+ * `null` is a VALUE (the declared absence of a write mode / a plan / a cap / a model); a MISSING KEY is
272
+ * an ABI BREAK. The two are not the same thing and must not collapse: bc types a port by the literal
273
+ * wired into it and REJECTS a partial struct (an omitted field is a different type, not a default —
274
+ * `bc: … the value wired into it has type obj{…}`), so a generated module ALWAYS spells every field of
275
+ * every struct it wires. A key that is not there did not come from one, and reading it as its default
276
+ * would silently downgrade a write to a read, drop a relation cap, erase a SKIP predicate (#205), or —
277
+ * on `group` — nest the children under `"undefined"` so the relation vanishes from the graph (#213).
278
+ */
279
+ function requiredField(record, name, at, declared) {
280
+ if (!(name in record)) {
281
+ throw new Error(`scp leaf: ${at} is missing its '${name}' field — a generated module spells every ` +
282
+ `field of every struct it wires, so an ABSENT key is an ABI break (a null VALUE is how an ` +
283
+ `absent write mode / plan / cap is spelled)`);
284
+ }
285
+ return portTyped(record[name], `${at}'s '${name}'`, declared);
286
+ }
287
+ /**
288
+ * Unbox the WHOLE plan — its FRAGMENTS (every field of every one, skipped included) and the three facts
289
+ * that finish the statement (`lead` / `tail` / `tailParams`) — fail-closed ({@link requiredField}),
290
+ * before any of them is used.
291
+ *
292
+ * A fragment is a PRESENT struct like every other, and the generator spells it in full, so a missing
293
+ * field is an ABI break and NOT a default: without `skipped` the statement applies a predicate the call
294
+ * SKIPPED, without `sql` the predicate is erased entirely, and without `params` a value binds where none
295
+ * belongs — each of them silently returning DIFFERENT ROWS (#209). The plan's own three fields are read
296
+ * the same way and for the same reason: a defaulted `lead` opens a SECOND WHERE on a statement that has
297
+ * one (a syntax error) or continues one that does not (also a syntax error), and a defaulted `tail` /
298
+ * `tailParams` DROPS the statement's ORDER BY and page — returning a different, unbounded row set that
299
+ * still looks like a successful read.
300
+ */
301
+ const PLAN_AT = `the 'whereDynamic' plan`;
302
+ function dynamicWherePlan(port) {
303
+ const plan = port;
304
+ const at = `a 'whereDynamic' fragment`;
305
+ const frags = requiredField(plan, 'frags', PLAN_AT, 'list').map((frag) => {
306
+ const f = portTyped(frag, at, 'record');
307
+ return {
308
+ skipped: requiredField(f, 'skipped', at, 'bool'),
309
+ sql: requiredField(f, 'sql', at, 'string'),
310
+ params: requiredField(f, 'params', at, 'list'),
311
+ };
312
+ });
313
+ return {
314
+ frags,
315
+ lead: requiredField(plan, 'lead', PLAN_AT, 'string'),
316
+ tail: requiredField(plan, 'tail', PLAN_AT, 'string'),
317
+ tailParams: requiredField(plan, 'tailParams', PLAN_AT, 'list'),
318
+ };
319
+ }
320
+ /**
321
+ * Read the relation `guard` field of the control record. `null` ⇒ the statement is uncapped. The cap
211
322
  * arrives in bc's `int` value model, which on the TS plane is a BigInt, so it is normalized to the
212
323
  * `number` {@link RelationGuard} (and {@link import('./errors').LimitExceededError}) declare — the
213
- * SAME numeric type the rust/go/python/php transports hand their own check. A guard that is present
214
- * but not a `{limit, relation}` record is a LOUD port failure, never a silently dropped cap: a guard
215
- * that fails to unbox is a runaway that would otherwise sail through.
324
+ * SAME numeric type the rust/go/python/php transports hand their own check. `model` is the one NULLABLE
325
+ * field: its key is always spelled and "no model" rides as `null`, which the error reports as "unknown".
326
+ * A field that is missing or not the declared type is a LOUD port failure, never a silently dropped cap:
327
+ * a guard that fails to unbox is a runaway that would otherwise sail through.
216
328
  */
217
329
  function relationGuardPort(port) {
218
- if (port === undefined || port === null)
330
+ if (port === null)
219
331
  return null;
220
332
  const g = port;
221
- const limit = typeof g.limit === 'bigint' ? Number(g.limit) : g.limit;
222
- if (typeof limit !== 'number' || !Number.isInteger(limit) || typeof g.relation !== 'string') {
223
- throw new Error(`scp leaf executeSQL: the 'guard' port must be a {limit:int, model?:string, relation:string} ` +
224
- `relation cap, got ${JSON.stringify(port)}`);
225
- }
226
- return { limit, ...(typeof g.model === 'string' ? { model: g.model } : {}), relation: g.relation };
333
+ const at = `the 'guard' cap`;
334
+ const raw = requiredField(g, 'limit', at, 'int');
335
+ const model = requiredField(g, 'model', at, 'string|null');
336
+ return {
337
+ limit: Number(raw),
338
+ ...(model === null ? {} : { model }),
339
+ relation: requiredField(g, 'relation', at, 'string'),
340
+ };
341
+ }
342
+ /**
343
+ * Read one STRUCT field of the control record — a CONCRETE control struct or the `null` that spells its
344
+ * absence. The name is `keyof ExecOptions` MINUS the fields that are not structs, so the reader is tied
345
+ * to the leaf declaration at compile time in BOTH directions: renaming a field there breaks HERE rather
346
+ * than silently reading a key the generator no longer writes, and passing `'db'` — a nullable STRING —
347
+ * fails to compile rather than being confirmed against the wrong declared type.
348
+ */
349
+ const OPTS_AT = `the 'opts' control record`;
350
+ function optsField(opts, name) {
351
+ return requiredField(opts, name, OPTS_AT, 'record|null');
352
+ }
353
+ /**
354
+ * Read the `write` field of the control record — the statement's RUN MODE. `null` ⇒ a READ; a
355
+ * {@link WriteMode} ⇒ a write, carrying its own `returning`. The nesting is what makes "returns rows
356
+ * but is not a write" unrepresentable, so this reader has three outcomes, not four.
357
+ */
358
+ function writeModePort(port) {
359
+ if (port === null)
360
+ return null;
361
+ return { returning: requiredField(port, 'returning', `the 'write' mode`, 'bool') };
227
362
  }
228
363
  /** Read the declared `executeSQL` ports off the evaluated port record (the generated module's Values). */
229
364
  function executeSqlPorts(ports) {
365
+ const at = 'the executeSQL payload';
366
+ const sql = requiredField(ports, 'sql', at, 'string');
367
+ const params = requiredField(ports, 'params', at, 'list');
368
+ // The ONE legitimate absence: no control record at all ⇒ the plain READ a bounded statement declares
369
+ // by OMITTING the port, so its payload is `sql` + `params` and nothing else. Once the port IS there it
370
+ // is read exactly like every field below — its own `null` is the same plain read, anything that is not
371
+ // an {@link ExecOptions} record is an ABI break.
372
+ const opts = 'opts' in ports ? requiredField(ports, 'opts', at, 'record|null') : null;
373
+ if (opts === null)
374
+ return { sql, params, write: null };
230
375
  return {
231
- sql: ports.sql,
232
- params: ports.params,
233
- write: ports.write === true,
234
- returning: ports.returning === true,
235
- bigint: ports.bigint === true,
236
- whereDynamic: (ports.whereDynamic ?? null),
237
- guard: relationGuardPort(ports.guard),
376
+ sql,
377
+ params,
378
+ // The NAMED database — the one control field that is a bare `string|null` rather than a struct, so
379
+ // it is read against its own declared type instead of through `optsField`'s `record|null`.
380
+ db: requiredField(opts, 'db', OPTS_AT, 'string|null'),
381
+ write: writeModePort(optsField(opts, 'write')),
382
+ whereDynamic: optsField(opts, 'whereDynamic'),
383
+ guard: relationGuardPort(optsField(opts, 'guard')),
238
384
  };
239
385
  }
240
386
  /**
241
387
  * The two ENVIRONMENT-FREE relation handlers. `pluck`/`group` are pure in-memory shaping, so the sync
242
388
  * and async maps share this ONE definition (never a second copy per environment).
389
+ *
390
+ * Their ports are read through the SAME fail-closed reader the SQL transport uses
391
+ * ({@link requiredField}) — the flat shape is not a reason to trust it. A raw index + cast turned a
392
+ * MISTYPED `single` into a silently flipped relation CARDINALITY (a `hasOne` nesting a LIST, a `hasMany`
393
+ * nesting one child), a mistyped `into` into a relation nested under `"42"`, and an absent `pk`/`col`
394
+ * into a bare `Cannot read properties of undefined` that names no port at all (#213).
243
395
  */
396
+ const PLUCK_AT = 'the pluck payload';
397
+ const GROUP_AT = 'the group payload';
244
398
  const shapingHandlers = {
245
- pluck: (ports) => ({ ok: pluck({ rows: ports.rows, col: ports.col }) }),
399
+ pluck: (ports) => ({
400
+ ok: pluck({
401
+ rows: requiredField(ports, 'rows', PLUCK_AT, 'list'),
402
+ col: requiredField(ports, 'col', PLUCK_AT, 'string[]'),
403
+ }),
404
+ }),
246
405
  group: (ports) => ({
247
406
  ok: group({
248
- parents: ports.parents,
249
- children: ports.children,
250
- pk: ports.pk,
251
- fk: ports.fk,
252
- into: ports.into,
253
- single: ports.single === true,
407
+ parents: requiredField(ports, 'parents', GROUP_AT, 'list'),
408
+ children: requiredField(ports, 'children', GROUP_AT, 'list'),
409
+ pk: requiredField(ports, 'pk', GROUP_AT, 'string[]'),
410
+ fk: requiredField(ports, 'fk', GROUP_AT, 'string[]'),
411
+ into: requiredField(ports, 'into', GROUP_AT, 'string'),
412
+ single: requiredField(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M,CAAY;SACpE,CAAqB;KACvB,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,SAAgB,YAAY,CAAC,GAAgB;IAC3C,OAAO;QACL,GAAG,eAAe;QAClB,UAAU,EAAE,CAAC,KAAK,EAAe,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,GAAG,CAAqB,EAAE,CAAC;KAC1G,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,GAAqB;IACrD,OAAO;QACL,GAAG,eAAe;QAClB,UAAU,EAAE,KAAK,EAAE,KAAK,EAAwB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,eAAe,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAqB,EAAE,CAAC;KACtI,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACU,QAAA,sBAAsB,GAAqC;IACtE,UAAU,EAAE,aAAa;IACzB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,gBAAgB;CACxB,CAAC"}
@@ -79,9 +79,36 @@ export interface SelectDesc extends RowLockOptions {
79
79
  offset?: number | BoundCount;
80
80
  append?: string;
81
81
  }
82
+ /**
83
+ * A compiled SELECT, SPLIT at the end of its WHERE region — a superset of the `makeSQL` bundle every
84
+ * caller already consumes (`sql` = `head + tail`, `params` = `headParams` then `tailParams`).
85
+ *
86
+ * The split exists because a DYNAMIC (SKIP) WHERE has to be spliced at exactly that boundary at RUN time
87
+ * (CLAUDE.md §2), and this function is where the boundary IS: the WHERE clause is appended here and the
88
+ * `GROUP BY` / `ORDER BY` / page / lock / append tail is appended right after it. Handing the two sides
89
+ * over as text is what lets the five leaf transports CONCATENATE instead of re-DISCOVERING the boundary
90
+ * by scanning the finished statement — a scan that cannot tell a nested statement's tail keyword from the
91
+ * outer one's (#198) and cannot count a quoted `?` the way the placeholder render does (#202).
92
+ */
93
+ export interface SelectBundle extends MakeSQL {
94
+ /** The statement UP TO the end of its WHERE region — where a dynamic clause joins. */
95
+ readonly head: string;
96
+ /** The params bound by `head`'s placeholders (CTE → JOIN → WHERE). */
97
+ readonly headParams: unknown[];
98
+ /** The statement AFTER the WHERE region (`GROUP BY` / `ORDER BY` / page / lock / append), `''` if none. */
99
+ readonly tail: string;
100
+ /** The params bound by `tail`'s placeholders (a bound `LIMIT ?` then `OFFSET ?`). */
101
+ readonly tailParams: unknown[];
102
+ /**
103
+ * How a clause spliced at `head`'s end JOINS: `'AND'` when the statement already carries a static
104
+ * WHERE (the clause CONTINUES it), `'WHERE'` when it carries none (the clause OPENS one). Decided by
105
+ * the `if (whereClause)` guard below — the ONE place that knows whether this statement has a WHERE.
106
+ */
107
+ readonly lead: 'WHERE' | 'AND';
108
+ }
82
109
  /**
83
110
  * Compile a SELECT to a `makeSQL` bundle, byte-identical to `_buildSelectSQL`.
84
111
  * Empty WHERE ⇒ no ` WHERE` (matches the original's `if (whereClause)` guard).
85
112
  */
86
- export declare function compileSelect(desc: SelectDesc): MakeSQL;
113
+ export declare function compileSelect(desc: SelectDesc): SelectBundle;
87
114
  //# sourceMappingURL=compile-select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-select.d.ts","sourceRoot":"","sources":["../../../src/scp/makesql/compile-select.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;CACf;AAOD,yGAAyG;AACzG,MAAM,WAAW,cAAc;IAC7B,0FAA0F;IAC1F,SAAS,CAAC,EA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G;IAC3G,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY,CAuC5D"}
@@ -56,43 +56,45 @@ function lockTail(opts) {
56
56
  * Empty WHERE ⇒ no ` WHERE` (matches the original's `if (whereClause)` guard).
57
57
  */
58
58
  function compileSelect(desc) {
59
- const params = [];
59
+ const headParams = [];
60
60
  const selectCols = desc.select || (desc.selectColumn ?? '*');
61
61
  const formatter = (0, compile_1.formatterFor)(desc.dialect);
62
62
  // Param order (matches SQL order): CTE params → JOIN params → WHERE params.
63
63
  if (desc.cte?.params && desc.cte.params.length > 0)
64
- params.push(...desc.cte.params);
64
+ headParams.push(...desc.cte.params);
65
65
  if (desc.joinParams && desc.joinParams.length > 0)
66
- params.push(...desc.joinParams);
67
- const whereClause = (0, json_array_1.conditionsFor)(desc.conditions ?? {}, desc.dialect).compile(params, formatter);
68
- let sql = '';
66
+ headParams.push(...desc.joinParams);
67
+ const whereClause = (0, json_array_1.conditionsFor)(desc.conditions ?? {}, desc.dialect).compile(headParams, formatter);
68
+ let head = '';
69
69
  if (desc.cte)
70
- sql = `WITH ${desc.cte.name} AS (${desc.cte.sql}) `;
71
- sql += `SELECT ${selectCols} FROM ${desc.tableName}`;
70
+ head = `WITH ${desc.cte.name} AS (${desc.cte.sql}) `;
71
+ head += `SELECT ${selectCols} FROM ${desc.tableName}`;
72
72
  if (desc.join)
73
- sql += ` ${desc.join}`;
73
+ head += ` ${desc.join}`;
74
74
  if (whereClause)
75
- sql += ` WHERE ${whereClause}`;
75
+ head += ` WHERE ${whereClause}`;
76
+ let tail = '';
76
77
  if (desc.group)
77
- sql += ` GROUP BY ${desc.group}`;
78
+ tail += ` GROUP BY ${desc.group}`;
78
79
  const orderClause = typeof desc.order === 'string' ? desc.order : (0, Column_1.orderToString)(desc.order);
79
80
  if (orderClause)
80
- sql += ` ORDER BY ${orderClause}`;
81
+ tail += ` ORDER BY ${orderClause}`;
81
82
  // The page tail: a static count is the original's inline literal; a bound one emits `?` and joins
82
83
  // the value list HERE, after the WHERE params — the order the `?`s occupy in the finished text.
84
+ const tailParams = [];
83
85
  const count = (c) => {
84
86
  if (!isBoundCount(c))
85
87
  return String(c);
86
- params.push(c.bind);
88
+ tailParams.push(c.bind);
87
89
  return '?';
88
90
  };
89
91
  if (desc.limit !== undefined)
90
- sql += ` LIMIT ${count(desc.limit)}`;
92
+ tail += ` LIMIT ${count(desc.limit)}`;
91
93
  if (desc.offset !== undefined)
92
- sql += ` OFFSET ${count(desc.offset)}`;
93
- sql += lockTail(desc);
94
+ tail += ` OFFSET ${count(desc.offset)}`;
95
+ tail += lockTail(desc);
94
96
  if (desc.append)
95
- sql += ` ${desc.append}`;
96
- return { sql, params };
97
+ tail += ` ${desc.append}`;
98
+ return { sql: head + tail, params: [...headParams, ...tailParams], head, headParams, tail, tailParams, lead: whereClause ? 'AND' : 'WHERE' };
97
99
  }
98
100
  //# sourceMappingURL=compile-select.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-select.js","sourceRoot":"","sources":["../../../src/scp/makesql/compile-select.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAgDH,4BAUC;AA8BD,sCAoCC;AAzHD,yCAA6C;AAG7C,uCAAyC;AACzC,6CAA6C;AAe7C,+FAA+F;AAC/F,SAAS,YAAY,CAAC,CAAsB;IAC1C,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,MAAM,IAAI,CAAC,CAAC;AAC5D,CAAC;AAUD;;;;;;;;;;;;GAYG;AACH,SAAgB,QAAQ,CAAC,IAAoB;IAC3C,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CA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,CAAC,KAAK,CAAC,EAAE,CAAC;IACpE,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,IAAI,IAAI,WAAW,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IACvE,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,CAAC,MAAM;QAAE,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;IAE3C,OAAO,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,GAAG,UAAU,EAAE,GAAG,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AAC/I,CAAC"}
@@ -21,10 +21,10 @@ export { inferPgArrayType, resolvePgArrayCast, PG_ARRAY_CAST_TOKEN, compileSingl
21
21
  export type { RelationCompileBase } from './compile-relation';
22
22
  export { inListJson, inListPredicate, encodeJsonArrayParam, JsonArrayConditions, conditionsFor } from './json-array';
23
23
  export { mysqlInsertJson, sqliteInsertJson, mysqlUpdateManyJson, sqliteUpdateManyJson, mysqlJsonTableColumn, rowsHaveDbToken, } from './json-batch';
24
- export { deriveTransactionPlan, deriveBatchPlan, literalize, executeTransaction, executeTransactionAsync, countingDriver, renderTxStatement, compileWriteNode, pgTypeSpecimen, IN_SENTINEL, } from './tx';
24
+ export { deriveBatchPlan, literalize, executeTransactionAsync, renderTxStatement, compileWriteNode, pgTypeSpecimen, ENTITY_ROOT, IN_SENTINEL, } from './tx';
25
25
  export { mysqlPkHint, stripMysqlPkHint, buildMysqlReselect, bindReselect } from './mysql-returning';
26
26
  export type { MysqlReselect, ReselectBind } from './mysql-returning';
27
- export type { TxExpr, TxOp, StatementRole, GateRule, TxStatement, IdempotentHitPolicy, TransactionPlan, BaseWrite, SqliteDb, ShortCircuitReason, TransactionResult, WriteExecOptions, } from './tx';
27
+ export type { TxExpr, TxOp, StatementRole, TxStatement, TransactionPlan, WriteLifecyclePhase, TransactionResult, WriteExecOptions, } from './tx';
28
28
  export { configurePgDeboxTypeParsers, mysqlDeboxPoolOptions, pgConnectionPool, mysqlConnectionPool, pgPoolFactory, mysqlPoolFactory } from './pool-executor';
29
29
  export type { PgPoolLike, MysqlPoolLike, PgTypesLike, PgModuleLike, Mysql2ModuleLike, PgOwnedPoolLike, PgPoolClientLike, MysqlOwnedPoolLike, MysqlPoolConnLike, PgOwnedPoolWithEnd, MysqlOwnedPoolWithEnd, PgFactoryModuleLike } from './pool-executor';
30
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scp/makesql/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,2BAA2B,EAC3B,SAAS,EACT,eAAe,EACf,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGjE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,kBAAkB,GACnB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGvE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EACL,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,YAAY,E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