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,12 +1,12 @@
1
1
  "use strict";
2
2
  /**
3
- * litedbmodel v2 SCP — pooled async `SqlExecutorAsync` factories for PG / MySQL (#40).
3
+ * litedbmodel v2 SCP — pooled async `SqlExecutor` factories for PG / MySQL (#40).
4
4
  *
5
5
  * The read-graph async execution model (`executeReadGraphAsync`) dispatches independent sibling
6
6
  * relations in bounded parallel via bc `runBehaviorAsync`. For that concurrency to become REAL
7
7
  * parallel DB I/O the driver seam must be an async CONNECTION POOL — each concurrent `exec` call
8
8
  * checks out a DISTINCT pooled connection. These factories adapt a `pg.Pool` / `mysql2` pool to the
9
- * {@link SqlExecutorAsync} seam.
9
+ * {@link SqlExecutor} seam.
10
10
  *
11
11
  * The read graph already renders the dialect placeholder form (`$N` for postgres, `?` for
12
12
  * MySQL/SQLite, via `renderPlaceholders`) and flattens params 1:1, so each executor is a THIN
@@ -20,10 +20,12 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.mysqlDeboxPoolOptions = void 0;
22
22
  exports.configurePgDeboxTypeParsers = configurePgDeboxTypeParsers;
23
- exports.pgPoolExecutor = pgPoolExecutor;
24
- exports.pgDeboxExecutor = pgDeboxExecutor;
25
- exports.mysqlDeboxExecutor = mysqlDeboxExecutor;
26
- exports.mysqlPoolExecutor = mysqlPoolExecutor;
23
+ exports.pgConnectionPool = pgConnectionPool;
24
+ exports.mysqlConnectionPool = mysqlConnectionPool;
25
+ exports.pgPoolFactory = pgPoolFactory;
26
+ exports.mysqlPoolFactory = mysqlPoolFactory;
27
+ // MySQL parses no RETURNING — the write→re-select derivation lives in ONE place for all five runtimes.
28
+ const mysql_returning_1 = require("./mysql-returning");
27
29
  // ── TS read-path driver de-box config (issue #59) ─────────────────────────────
28
30
  // The read-path materializer (`materializeCell`) coerces each driver cell to the JS form its SQL
29
31
  // column type declares (BIGINT→bigint, DATE→string, …). For that to be LOSSLESS the driver must
@@ -36,13 +38,13 @@ exports.mysqlPoolExecutor = mysqlPoolExecutor;
36
38
  // - MySQL: BIGINT arrives as a rounded JS number by default (LOSSY). The pool MUST be built with
37
39
  // `mysqlDeboxPoolOptions` (`supportBigNumbers + bigNumberStrings` so BIGINT→string, and
38
40
  // `dateStrings` so the date family→string). `mysqlDeboxPoolOptions` is those options.
39
- /** PG type OIDs for the date/time family + int8 (bigint). */
40
- const PG_OID = { INT8: 20, DATE: 1082, TIMESTAMP: 1114, TIMESTAMPTZ: 1184, TIME: 1083, TIMETZ: 1266 };
41
+ /** PG type OIDs for the integer family + the date/time family. */
42
+ const PG_OID = { INT2: 21, INT4: 23, INT8: 20, DATE: 1082, TIMESTAMP: 1114, TIMESTAMPTZ: 1184, TIME: 1083, TIMETZ: 1266 };
41
43
  /**
42
44
  * Register `pg` type parsers so the read-path de-box (issue #59) gets coercible values: the
43
45
  * DATE/TIMESTAMP/TIMESTAMPTZ/TIME family is returned as its NATIVE TEXTUAL string (NOT a JS Date),
44
- * honoring the `date→string` outType and carrying the TZ for timestamptz. int8 already arrives as a
45
- * string (pg default), so it needs no parser. Idempotent. Call ONCE, before building the pool, from
46
+ * honoring the `date→string` outType and carrying the TZ for timestamptz; and the int2/int4/int8 family
47
+ * as a BigInt, the TS plane's `int` value model. Idempotent. Call ONCE, before building the pool, from
46
48
  * the consumer that owns the `pg` module (`import { types } from 'pg'; configurePgDeboxTypeParsers(types)`).
47
49
  *
48
50
  * WHY the GLOBAL parser (a documented, deliberate exception): `pg`'s default DATE parser builds a JS
@@ -56,6 +58,16 @@ const PG_OID = { INT8: 20, DATE: 1082, TIMESTAMP: 1114, TIMESTAMPTZ: 1184, TIME:
56
58
  */
57
59
  function configurePgDeboxTypeParsers(types) {
58
60
  const asString = (v) => v; // identity: keep the driver's native textual form
61
+ // An INTEGER column must arrive in bc's `int` value model, which on the TS plane is a BigInt. `pg`'s
62
+ // defaults hand back a JS number for int2/int4 and a string for int8, and bc classifies a JS number as
63
+ // FLOAT — so a column declared `Int` failed its outType check with `expected int, got float` on every
64
+ // read. The OID says the column is an integer, so nothing is guessed from the value: a REAL column
65
+ // whose value happens to be integral still arrives as a float. sqlite gets the same guarantee from
66
+ // better-sqlite3's `safeIntegers`, MySQL from {@link mysqlDeboxPoolOptions}'s integer typeCast.
67
+ const asBigInt = (v) => BigInt(v);
68
+ types.setTypeParser(PG_OID.INT2, asBigInt);
69
+ types.setTypeParser(PG_OID.INT4, asBigInt);
70
+ types.setTypeParser(PG_OID.INT8, asBigInt);
59
71
  types.setTypeParser(PG_OID.DATE, asString);
60
72
  types.setTypeParser(PG_OID.TIMESTAMP, asString);
61
73
  types.setTypeParser(PG_OID.TIMESTAMPTZ, asString);
@@ -72,47 +84,175 @@ exports.mysqlDeboxPoolOptions = {
72
84
  supportBigNumbers: true,
73
85
  bigNumberStrings: true,
74
86
  dateStrings: true,
87
+ /**
88
+ * An INTEGER column must arrive in bc's `int` value model — a BigInt on the TS plane. `mysql2` hands
89
+ * back a JS number for TINY/SHORT/INT24/LONG (only BIGINT becomes a string, via `bigNumberStrings`),
90
+ * and bc classifies a JS number as FLOAT, so a column declared `Int` failed its outType check with
91
+ * `expected int, got float`. The FIELD TYPE decides, never the value: a DOUBLE/DECIMAL column whose
92
+ * value happens to be integral still arrives as a float. sqlite gets the same guarantee from
93
+ * better-sqlite3's `safeIntegers`, PostgreSQL from {@link configurePgDeboxTypeParsers}'s int OIDs.
94
+ */
95
+ typeCast(field, next) {
96
+ if (MYSQL_INT_TYPES.has(field.type)) {
97
+ const raw = field.string();
98
+ return raw === null ? null : BigInt(raw);
99
+ }
100
+ return next();
101
+ },
75
102
  };
76
103
  /**
77
- * Adapt a `pg.Pool` to the async executor seam. Each `exec` runs `pool.query`, which acquires a
78
- * pooled connection, runs the query, and releases it — so N concurrent siblings run on N pooled
79
- * connections in parallel. The graph renders `$N` placeholders for the `postgres` dialect, so the
80
- * `sql` is already in `pg`'s native form.
104
+ * `mysql2`'s field-type names for the INTEGER family. NEWDECIMAL / DOUBLE / FLOAT are deliberately
105
+ * absent — they are float columns, whatever their values look like.
106
+ */
107
+ const MYSQL_INT_TYPES = new Set(['TINY', 'SHORT', 'INT24', 'LONG', 'LONGLONG']);
108
+ /** Adapt a pg `PoolClient` to the {@link AsyncConnection} seam (one owned connection). */
109
+ function pgConnection(client) {
110
+ return {
111
+ async execute(sql, params) {
112
+ const r = await client.query(sql, params);
113
+ return r.rows;
114
+ },
115
+ async run(sql, params) {
116
+ const r = await client.query(sql, params);
117
+ return { changes: r.rowCount ?? 0, lastInsertRowid: 0 };
118
+ },
119
+ };
120
+ }
121
+ /**
122
+ * Adapt a pg `Pool` to the {@link AsyncConnectionPool} contract — `acquire` checks out an owned
123
+ * `PoolClient`, `release` returns it (destroyed on a poisoned tx). Feed this to
124
+ * `withTransactionAsync` for per-execution connection ownership.
125
+ */
126
+ function pgConnectionPool(pool) {
127
+ const handles = new WeakMap();
128
+ return {
129
+ async acquire() {
130
+ const client = await pool.connect();
131
+ const conn = pgConnection(client);
132
+ handles.set(conn, client);
133
+ return conn;
134
+ },
135
+ async release(conn, destroy) {
136
+ handles.get(conn)?.release(destroy === true);
137
+ },
138
+ };
139
+ }
140
+ /**
141
+ * Adapt a mysql2 pooled connection to the {@link AsyncConnection} seam (one owned connection).
81
142
  *
82
- * Recommend constructing the pool with `max` ≥ the plan's `concurrency` (default 16).
143
+ * `execute` also carries the **MySQL RETURNING emulation** ({@link buildMysqlReselect}): MySQL parses
144
+ * no `RETURNING`, so a write that declares one is run stripped and its written rows recovered by a
145
+ * SELECT on THIS connection (before the write for a DELETE, after it otherwise). Placing it on the
146
+ * connection — the mysql analogue of the rust/go/py/php driver wrappers — is what makes the mode-2
147
+ * plan executor and a generated (codegen) write return the SAME rows: both reach the DB here.
83
148
  */
84
- function pgPoolExecutor(pool) {
85
- return async (sql, params) => {
86
- const result = await pool.query(sql, params);
87
- return result.rows;
149
+ function mysqlConnection(conn) {
150
+ const rowsOf = (raw) => (Array.isArray(raw) ? raw : []);
151
+ return {
152
+ async execute(sql, params) {
153
+ const reselect = (0, mysql_returning_1.buildMysqlReselect)(sql);
154
+ if (reselect === null)
155
+ return rowsOf((await conn.query(sql, params))[0]);
156
+ const bound = params;
157
+ if (reselect.before) {
158
+ // DELETE…RETURNING: the pre-image IS the written row set — capture it, THEN delete.
159
+ const [pre] = await conn.query(reselect.selectSql, (0, mysql_returning_1.bindReselect)(reselect.binds, bound, 0, 0));
160
+ await conn.query(reselect.writeSql, bound);
161
+ return rowsOf(pre);
162
+ }
163
+ const [res] = await conn.query(reselect.writeSql, bound);
164
+ const h = res;
165
+ const [rows] = await conn.query(reselect.selectSql, (0, mysql_returning_1.bindReselect)(reselect.binds, bound, Number(h?.insertId ?? 0), Number(h?.affectedRows ?? 0)));
166
+ return rowsOf(rows);
167
+ },
168
+ async run(sql, params) {
169
+ const [res] = await conn.query(sql, params);
170
+ const h = res;
171
+ return { changes: h?.affectedRows ?? 0, lastInsertRowid: h?.insertId ?? 0 };
172
+ },
88
173
  };
89
174
  }
90
175
  /**
91
- * Build a PG pool + executor with the read-path de-box wired IN (issue #59): registers the pg date
92
- * type parsers (DATE/TIMESTAMP family → native textual string) globally, then builds the pool.
93
- * int8 already arrives as a string on pg. Returns `{ pool, exec }` — pass `exec` to
94
- * `executeBehaviorAsync`. This is the production async path's de-box-correct entry (no hand-spread
95
- * options).
176
+ * Adapt a mysql2/promise `Pool` to the {@link AsyncConnectionPool} contract — `acquire` checks out
177
+ * an owned connection, `release` returns it (or `destroy`s a poisoned one). Feed this to
178
+ * `withTransactionAsync` for per-execution connection ownership.
96
179
  */
97
- function pgDeboxExecutor(pg, config) {
98
- configurePgDeboxTypeParsers(pg.types);
99
- const pool = new pg.Pool(config);
100
- return { pool, exec: pgPoolExecutor(pool) };
180
+ function mysqlConnectionPool(pool) {
181
+ const handles = new WeakMap();
182
+ return {
183
+ async acquire() {
184
+ const raw = await pool.getConnection();
185
+ const conn = mysqlConnection(raw);
186
+ handles.set(conn, raw);
187
+ return conn;
188
+ },
189
+ async release(conn, destroy) {
190
+ const raw = handles.get(conn);
191
+ if (raw === undefined)
192
+ return;
193
+ if (destroy === true)
194
+ raw.destroy();
195
+ else
196
+ raw.release();
197
+ },
198
+ };
101
199
  }
102
200
  /**
103
- * Build a MySQL pool + executor with the read-path de-box wired IN (issue #59): the pool carries
104
- * {@link mysqlDeboxPoolOptions} (`supportBigNumbers + bigNumberStrings` so BIGINT → exact string,
105
- * `dateStrings` so the date family → string) — options that MUST be set at pool construction (a
106
- * rounded BIGINT cannot be un-rounded post-hoc). Returns `{ pool, exec }` for `executeBehaviorAsync`.
201
+ * A {@link PoolFactory} for `pg`: constructs a `new pg.Pool(...)` from a {@link ResolvedConnectionConfig},
202
+ * applying the pool SIZING (`max` = `maxPool`, `min` = `minPool`) and `keepAlive` /
203
+ * `keepAliveInitialDelayMillis` AT CONSTRUCTION — the config is the sole source of the cap. Connection
204
+ * params (host/port/database/user/password) also flow from the config. Registers the read-path de-box
205
+ * type parsers (issue #59, global, idempotent) once. Returns the owned-connection adapter + closer.
206
+ *
207
+ * `role` is accepted for the reader/writer replica split; the caller may vary host per role via the
208
+ * config it passes. `Pool` is the `pg.Pool` ctor (peer dep, passed in — this module imports no driver).
107
209
  */
108
- function mysqlDeboxExecutor(mysql2, config) {
109
- const pool = mysql2.createPool({ ...config, ...exports.mysqlDeboxPoolOptions });
110
- return { pool, exec: mysqlPoolExecutor(pool) };
210
+ function pgPoolFactory(pg) {
211
+ return (config, _role) => {
212
+ configurePgDeboxTypeParsers(pg.types);
213
+ const pool = new pg.Pool({
214
+ ...(config.host !== undefined ? { host: config.host } : {}),
215
+ ...(config.port !== undefined ? { port: config.port } : {}),
216
+ ...(config.database !== undefined ? { database: config.database } : {}),
217
+ ...(config.user !== undefined ? { user: config.user } : {}),
218
+ ...(config.password !== undefined ? { password: config.password } : {}),
219
+ // SIZING (construction knob): the config is the sole source of the cap.
220
+ max: config.maxPool,
221
+ min: config.minPool,
222
+ // keepAlive (construction knob): TCP keepalive for serverless/long-idle connections.
223
+ keepAlive: config.keepAlive,
224
+ ...(config.keepAlive ? { keepAliveInitialDelayMillis: config.keepAliveInitialDelayMillis } : {}),
225
+ });
226
+ return { pool: pgConnectionPool(pool), close: () => pool.end() };
227
+ };
111
228
  }
112
- function mysqlPoolExecutor(pool) {
113
- return async (sql, params) => {
114
- const [rows] = await pool.query(sql, params);
115
- return rows;
229
+ /**
230
+ * A {@link PoolFactory} for `mysql2/promise`: constructs a `mysql2.createPool(...)` from a
231
+ * {@link ResolvedConnectionConfig}, applying the pool SIZING (`connectionLimit` = `maxPool`) +
232
+ * `enableKeepAlive` / `keepAliveInitialDelay` AT CONSTRUCTION (the config is the sole source of the
233
+ * cap) plus the read-path de-box options ({@link mysqlDeboxPoolOptions}). Connection params flow from
234
+ * the config. Returns the owned-connection adapter + closer.
235
+ *
236
+ * NB: mysql2 has no `min` idle floor — `minPool` is a no-op there (a documented per-driver deviation;
237
+ * the SIZING CAP that matters — `maxPool` → `connectionLimit` — is honored). `createPool` is the
238
+ * `mysql2/promise` factory (peer dep, passed in).
239
+ */
240
+ function mysqlPoolFactory(mysql2) {
241
+ return (config, _role) => {
242
+ const pool = mysql2.createPool({
243
+ ...(config.host !== undefined ? { host: config.host } : {}),
244
+ ...(config.port !== undefined ? { port: config.port } : {}),
245
+ ...(config.database !== undefined ? { database: config.database } : {}),
246
+ ...(config.user !== undefined ? { user: config.user } : {}),
247
+ ...(config.password !== undefined ? { password: config.password } : {}),
248
+ // SIZING (construction knob): connectionLimit = maxPool (the sole source of the cap).
249
+ connectionLimit: config.maxPool,
250
+ // keepAlive (construction knob).
251
+ enableKeepAlive: config.keepAlive,
252
+ ...(config.keepAlive ? { keepAliveInitialDelay: config.keepAliveInitialDelayMillis } : {}),
253
+ ...exports.mysqlDeboxPoolOptions,
254
+ });
255
+ return { pool: mysqlConnectionPool(pool), close: () => pool.end() };
116
256
  };
117
257
  }
118
258
  //# sourceMappingURL=pool-executor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pool-executor.js","sourceRoot":"","sources":["../../../src/scp/makesql/pool-executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAyCH,kEAOC;AAgCD,wCAKC;AAkCD,0CAIC;AAQD,gDAGC;AAED,8CAKC;AAzID,iFAAiF;AACjF,iGAA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,eAAe,EAAE,MAAM,CAAC,OAAO;YAC/B,iCAAiC;YACjC,eAAe,EAAE,MAAM,CAAC,SAAS;YACjC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,qBAAqB,EAAE,MAAM,CAAC,2BAA2B,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1F,GAAG,6BAAqB;SACzB,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,mBAAmB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IACtE,CAAC,CAAC;AACJ,CAAC"}
@@ -31,8 +31,11 @@
31
31
  * Underivable shapes (cycle, dangling `$.ref`, referenced write without RETURNING, duplicate
32
32
  * bind, composite `$.entity`) are LOUD rejects — never a silently mis-ordered plan.
33
33
  */
34
- import { type Scope } from 'behavior-contracts';
34
+ import { type Scope } from 'behavior-contracts/runtime';
35
+ import { type ColumnTypeResolver } from '../coltype';
35
36
  import { type Dialect as MakeSQLDialect } from './handler';
37
+ import { type ExecutionContext, type PooledAsyncContext, type SqliteDriver } from '../exec-context';
38
+ import { type TransactionOptions } from '../tx-options';
36
39
  import { type LifecycleContract, type LifecycleEffects, type WriteLifecyclePhase } from '../writes';
37
40
  /** A closed-set bc Expression IR node used as a `makeSQL` deferred param (ref / literal / obj). */
38
41
  export type TxExpr = unknown;
@@ -79,6 +82,29 @@ export interface TxOp {
79
82
  readonly columns: readonly string[];
80
83
  readonly autoInc: string | null;
81
84
  };
85
+ /**
86
+ * NATIVE-CODEGEN typing metadata (E5/#120 — the RETURNING-chained tx chain). Additive: the runtime
87
+ * tx ({@link executeTransaction}) IGNORES it; the bc native-codegen chain lowering
88
+ * (bc's rust/go typed-native emitter) reads it to type each statement's
89
+ * native param ports + its produced-row struct WITHOUT re-parsing the rendered SQL. The SHARED
90
+ * {@link compileWriteNode} emits it from the structured ports it already has (one compiler feeds both
91
+ * the runtime and the codegen chain). Present on a single-statement Insert/Update/Delete op; absent
92
+ * on a batch op (its `?` binds a `{__batchRows}` marker, not a column). `bindColumns[i]` is the table
93
+ * column the i-th `?` binds (parallel to `params`; `null` when the param is not a plain column value).
94
+ */
95
+ readonly writeMeta?: {
96
+ readonly table: string;
97
+ readonly bindColumns: readonly (string | null)[];
98
+ readonly returning: readonly string[];
99
+ /** The upsert conflict-target column list (`onConflict` port), when this write is an upsert — lets a
100
+ * downstream mysql RETURNING re-select recover the upserted row by its conflict key. Absent otherwise. */
101
+ readonly onConflict?: string;
102
+ /** True for a batch op (createMany/updateMany/upsertMany — its `?` binds a `{__batchRows}` marker,
103
+ * not per-column values). The native tx-chain lowering rejects a batch op (it types per-column); the
104
+ * flag lets it detect batch even though the op now carries `pk`/`onConflict` for the mysql RETURNING
105
+ * re-select (which the batch write, like the single write, must honor). */
106
+ readonly batch?: boolean;
107
+ };
82
108
  }
83
109
  /** The role a transaction statement plays (drives the runtime's gate-first interpretation). */
84
110
  export type StatementRole = 'gate:requires' | 'gate:idempotency' | 'gate:unique' | 'body' | 'derive' | 'edge' | 'emit';
@@ -117,22 +143,34 @@ interface WriteNodeLike {
117
143
  readonly ports: Record<string, unknown>;
118
144
  }
119
145
  /**
120
- * Serialize a {@link TxOp.pk} descriptor into a strip-before-execute SQL comment appended to an
121
- * INSERT…RETURNING op, so the MySQL driver emulation can re-select by the REAL primary key. The
122
- * comment is STRIPPED (with the RETURNING clause) before the INSERT executes, so the executed SQL
123
- * stays byte-clean; it is emitted ONLY into the mysql-dialect bundle (PG/SQLite keep native
124
- * RETURNING and never see it). Format: ` /*scp:pk=col1,col2;ai=<autoIncCol|>* /`.
146
+ * A per-column raw VALUE SPECIMEN whose {@link import('../../drivers/PostgresSqlBuilder').inferPgType}
147
+ * matches the column's SCHEMA SQL type, so the PG batch UNNEST cast (`?::<pgType>[]`) the original
148
+ * `buildInsert`/`buildUpdateMany` emits is derived from the schema SoT — NOT from the runtime values
149
+ * the symbolic codegen path never sees. int32→number / int64→bigint / bool→boolean / date→Date /
150
+ * float→non-integer number / string(+decimal/uuid/json)→string, reproducing each `inferPgType` branch.
151
+ * Ambiguous only for a REAL column whose live value is integer-valued (v1 would infer `int`, not
152
+ * `numeric`); the bench columns (text/int/bigint) are unambiguous. Unknown SQL types are a hard error
153
+ * (fail-closed) via the §4.1 classifiers.
125
154
  */
126
- export declare function mysqlPkHint(op: TxOp): TxOp;
127
- /** Strip a trailing MySQL PK-hint comment from a rendered SQL (defensive; runtimes strip too). */
128
- export declare function stripMysqlPkHint(sql: string): string;
155
+ export declare function pgTypeSpecimen(sqlType: string): unknown;
156
+ /**
157
+ * Read the optional PRIMARY KEY descriptor ports of an Insert node (for the MySQL RETURNING
158
+ * emulation). `pk` is a comma-separated column list (`'doc_id'` / `'order_id,line_no'`); `autoInc`
159
+ * names the single AUTO_INCREMENT column, or is absent for a client-supplied PK. Absent `pk`
160
+ * defaults to null (the emulation then keeps its legacy `WHERE id`/`LAST_INSERT_ID` path, so the
161
+ * existing auto-increment-`id` corpus is unchanged).
162
+ */
163
+ export declare function pkPort(ports: Record<string, unknown>): {
164
+ columns: readonly string[];
165
+ autoInc: string | null;
166
+ } | undefined;
129
167
  /**
130
168
  * Compile ONE authored catalog write node (`Insert`/`Update`/`Delete`) into a makeSQL {@link TxOp}
131
169
  * — complete tuned SQL text + DEFERRED Expression-IR params. This is the makeSQL re-expression of
132
170
  * the reduced bridge's `compileNode` for the write path (the tx-DAG base writes). INSERT columns
133
171
  * are CANONICAL (alphabetical) sorted — the v2 write-path SSoT (matches `DBModel._insert`).
134
172
  */
135
- export declare function compileWriteNode(node: WriteNodeLike, dialect?: MakeSQLDialect): TxOp;
173
+ export declare function compileWriteNode(node: WriteNodeLike, dialect?: MakeSQLDialect, resolveColumnType?: ColumnTypeResolver): TxOp;
136
174
  /** The base write op the Command declares (`Insert`/`Update`/`Delete` with `onWrite`). */
137
175
  export interface BaseWrite {
138
176
  /** The compiled base write makeSQL op (complete `sql` + deferred Expression-IR `params`). */
@@ -167,16 +205,15 @@ export declare function deriveBatchPlan(phase: WriteLifecyclePhase, ops: readonl
167
205
  params: readonly unknown[];
168
206
  label?: string;
169
207
  }[]): TransactionPlan;
170
- /** The minimal synchronous SQLite driver surface the tx runtime needs (better-sqlite3). */
171
- export interface SqliteDb {
172
- prepare(sql: string): {
173
- all(...params: unknown[]): unknown[];
174
- run(...params: unknown[]): {
175
- changes: number;
176
- lastInsertRowid: number | bigint;
177
- };
178
- };
179
- }
208
+ /**
209
+ * The minimal synchronous SQLite driver surface the tx runtime needs (better-sqlite3) — the
210
+ * backward-compat public seam. Internally the tx runs through the {@link ExecutionContext} seam
211
+ * (`../exec-context`); a raw driver passed here is wrapped via {@link contextForDriver}. Aliased to
212
+ * {@link SqliteDriver}.
213
+ */
214
+ export type SqliteDb = SqliteDriver;
215
+ /** A tx entry accepts either a raw {@link SqliteDb} or a full {@link ExecutionContext}. */
216
+ export type DbOrContext = SqliteDb | ExecutionContext;
180
217
  /** Why a transaction did not commit (a gate short-circuit outcome; not a driver error). */
181
218
  export type ShortCircuitReason = 'requires_absent' | 'unique_collision' | 'idempotent_duplicate';
182
219
  /** The structured outcome of executing a {@link TransactionPlan}. */
@@ -197,8 +234,16 @@ export interface TransactionResult {
197
234
  */
198
235
  readonly returnedRows?: readonly (readonly Record<string, unknown>[])[];
199
236
  }
200
- /** Execute a derived {@link TransactionPlan} as ONE real SQLite transaction with gate-first. */
201
- export declare function executeTransaction(db: SqliteDb, plan: TransactionPlan, input: Scope, dialect?: MakeSQLDialect): TransactionResult;
237
+ /**
238
+ * Execute a derived {@link TransactionPlan} as ONE real SQLite transaction with gate-first
239
+ * short-circuit. Accepts a raw {@link SqliteDb} (wrapped via {@link contextForDriver}) or a full
240
+ * {@link ExecutionContext}. The transaction derives a tx-scoped ctx (`withConnection(conn, true)`)
241
+ * that PINS one connection so BEGIN, every body statement, and COMMIT/ROLLBACK all run on the SAME
242
+ * connection (§3, per-execution ownership). For the single-DB SQLite driver the pinned connection
243
+ * is the sole connection; the ownership shows its teeth on the pooled async path
244
+ * ({@link import('../exec-context').withTransactionAsync}), which this mirrors.
245
+ */
246
+ export declare function executeTransaction(db: DbOrContext, plan: TransactionPlan, input: Scope, dialect?: MakeSQLDialect): TransactionResult;
202
247
  /**
203
248
  * A counting {@link SqliteDb} wrapper: forwards every call to the wrapped driver but records
204
249
  * each PREPARED SQL string. Tests use it to PROVE gate-first short-circuit.
@@ -212,5 +257,45 @@ export declare function renderTxStatement(op: TxOp, scope: Scope, dialect?: Make
212
257
  sql: string;
213
258
  params: unknown[];
214
259
  };
260
+ /**
261
+ * Options for the live async write entry {@link executeTransactionAsync} — the tx {@link
262
+ * TransactionOptions} plus the write=tx `guard` policy (#86).
263
+ */
264
+ export interface WriteExecOptions extends TransactionOptions {
265
+ /**
266
+ * Enforce the write=tx guard (#86 / #81 `checkWriteAllowed`): a write issued OUTSIDE a user
267
+ * `transaction(fn)` throws {@link WriteOutsideTransactionError}; a write in a {@link
268
+ * import('../tx-options').withReadOnly} scope throws {@link WriteInReadOnlyContextError}. This is
269
+ * the DEFAULT for the public write path — writes require an explicit transaction (v1 parity,
270
+ * `DBModel.ts:886`). Set `false` ONLY for the internal per-execution-ownership plane (the Phase A
271
+ * ownership proofs that drive the plan executor as its OWN auto-tx). @default true
272
+ */
273
+ readonly guard?: boolean;
274
+ }
275
+ /**
276
+ * Execute a derived {@link TransactionPlan} on a live PG / MySQL connection with gate-first
277
+ * short-circuit and **per-execution connection ownership** (§3). The live-DB WRITE entry (#86).
278
+ *
279
+ * ## Ambient-tx JOIN vs. its own envelope (the #86 core)
280
+ *
281
+ * `withTransactionAsync` (:495) decides the envelope:
282
+ * - **inside a user `transaction(fn)`** (an outer connection is pinned in the ALS) → the write
283
+ * JOINS the outer: its statements run on the outer's owned connection with NO new BEGIN/COMMIT,
284
+ * so N writes in one boundary are ONE physical transaction (one BEGIN, one COMMIT, one conn);
285
+ * - **outside any transaction** → it opens its OWN BEGIN…COMMIT on a freshly-acquired owned
286
+ * connection (the per-execution auto-tx; concurrent calls each own a DISTINCT connection ⇒
287
+ * isolated).
288
+ *
289
+ * ## write=tx guard (#86, wired here — fires at runtime, not a standalone helper)
290
+ *
291
+ * With `options.guard` (DEFAULT true), a write with NO ambient user tx is REJECTED via {@link
292
+ * checkWriteAllowed} BEFORE any SQL: `WriteOutsideTransactionError` (no active tx) /
293
+ * `WriteInReadOnlyContextError` (read-only scope). The check runs at ENTRY — before
294
+ * `withTransactionAsync` would open the write's own envelope — so it sees the CALLER's scope, exactly
295
+ * mirroring v1 `DBModel._checkWriteAllowed` (:886, called at the public write entry, not the plan
296
+ * executor). Inside a `transaction(fn)` the ambient marker is set ⇒ the guard passes and the write
297
+ * joins. The structured {@link TransactionResult} is identical to the sync {@link executeTransaction}.
298
+ */
299
+ export declare function executeTransactionAsync(ctx: PooledAsyncContext, plan: TransactionPlan, input: Scope, dialect?: MakeSQLDialect, options?: WriteExecOptions): Promise<TransactionResult>;
215
300
  export {};
216
301
  //# sourceMappingURL=tx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../src/scp/makesql/tx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAsB,KAAK,KAAK,EAAc,MAAM,oBAAoB,CAAC;AAEhF,OAAO,EAAsB,KAAK,OAAO,IAAI,cAAc,EAAE,MAAM,WAAW,CAAC;AAI/E,OAAO,EAOL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAGrB,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAC;AAInB,mGAAmG;AACnG,MAAM,MAAM,MAAM,GAAG,OAAO,CAAC;AAE7B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CASjD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,IAAI;IACnB,kDAAkD;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