litedbmodel 2.0.2 → 2.1.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 (80) hide show
  1. package/dist/decorators.d.ts.map +1 -1
  2. package/dist/decorators.js +44 -24
  3. package/dist/decorators.js.map +1 -1
  4. package/dist/drivers/mysql.d.ts.map +1 -1
  5. package/dist/drivers/mysql.js +6 -0
  6. package/dist/drivers/mysql.js.map +1 -1
  7. package/dist/drivers/postgres.d.ts.map +1 -1
  8. package/dist/drivers/postgres.js +7 -0
  9. package/dist/drivers/postgres.js.map +1 -1
  10. package/dist/drivers/sqlite.d.ts +2 -0
  11. package/dist/drivers/sqlite.d.ts.map +1 -1
  12. package/dist/drivers/sqlite.js +37 -2
  13. package/dist/drivers/sqlite.js.map +1 -1
  14. package/dist/scp/authoring.d.ts +66 -3
  15. package/dist/scp/authoring.d.ts.map +1 -1
  16. package/dist/scp/authoring.js +194 -5
  17. package/dist/scp/authoring.js.map +1 -1
  18. package/dist/scp/catalog.d.ts +2 -1
  19. package/dist/scp/catalog.d.ts.map +1 -1
  20. package/dist/scp/catalog.js +12 -1
  21. package/dist/scp/catalog.js.map +1 -1
  22. package/dist/scp/codegen.d.ts +43 -31
  23. package/dist/scp/codegen.d.ts.map +1 -1
  24. package/dist/scp/codegen.js +279 -95
  25. package/dist/scp/codegen.js.map +1 -1
  26. package/dist/scp/coltype.d.ts +83 -0
  27. package/dist/scp/coltype.d.ts.map +1 -1
  28. package/dist/scp/coltype.js +220 -0
  29. package/dist/scp/coltype.js.map +1 -1
  30. package/dist/scp/guard.d.ts +1 -1
  31. package/dist/scp/guard.d.ts.map +1 -1
  32. package/dist/scp/guard.js +6 -0
  33. package/dist/scp/guard.js.map +1 -1
  34. package/dist/scp/index.cjs +7149 -9379
  35. package/dist/scp/index.d.ts +7 -6
  36. package/dist/scp/index.d.ts.map +1 -1
  37. package/dist/scp/index.js +21 -6
  38. package/dist/scp/index.js.map +1 -1
  39. package/dist/scp/index.mjs +729 -178
  40. package/dist/scp/makesql/authoring-compile.d.ts.map +1 -1
  41. package/dist/scp/makesql/authoring-compile.js +11 -0
  42. package/dist/scp/makesql/authoring-compile.js.map +1 -1
  43. package/dist/scp/makesql/index.d.ts +2 -3
  44. package/dist/scp/makesql/index.d.ts.map +1 -1
  45. package/dist/scp/makesql/index.js +6 -6
  46. package/dist/scp/makesql/index.js.map +1 -1
  47. package/dist/scp/makesql/json-batch.d.ts.map +1 -1
  48. package/dist/scp/makesql/json-batch.js +6 -1
  49. package/dist/scp/makesql/json-batch.js.map +1 -1
  50. package/dist/scp/makesql/outtype.d.ts +61 -6
  51. package/dist/scp/makesql/outtype.d.ts.map +1 -1
  52. package/dist/scp/makesql/outtype.js +164 -33
  53. package/dist/scp/makesql/outtype.js.map +1 -1
  54. package/dist/scp/makesql/pool-executor.d.ts +70 -0
  55. package/dist/scp/makesql/pool-executor.d.ts.map +1 -1
  56. package/dist/scp/makesql/pool-executor.js +73 -5
  57. package/dist/scp/makesql/pool-executor.js.map +1 -1
  58. package/dist/scp/makesql/static-bundle.d.ts +39 -30
  59. package/dist/scp/makesql/static-bundle.d.ts.map +1 -1
  60. package/dist/scp/makesql/static-bundle.js +269 -138
  61. package/dist/scp/makesql/static-bundle.js.map +1 -1
  62. package/dist/scp/makesql/writeouttype.d.ts +5 -6
  63. package/dist/scp/makesql/writeouttype.d.ts.map +1 -1
  64. package/dist/scp/makesql/writeouttype.js +5 -6
  65. package/dist/scp/makesql/writeouttype.js.map +1 -1
  66. package/dist/scp/relation.d.ts +15 -1
  67. package/dist/scp/relation.d.ts.map +1 -1
  68. package/dist/scp/relation.js +61 -2
  69. package/dist/scp/relation.js.map +1 -1
  70. package/dist/scp/runtime.d.ts +6 -5
  71. package/dist/scp/runtime.d.ts.map +1 -1
  72. package/dist/scp/runtime.js +27 -5
  73. package/dist/scp/runtime.js.map +1 -1
  74. package/docs/BENCHMARK.md +58 -56
  75. package/docs/benchmark-chart.svg +166 -166
  76. package/package.json +8 -2
  77. package/dist/scp/makesql/ir.d.ts +0 -42
  78. package/dist/scp/makesql/ir.d.ts.map +0 -1
  79. package/dist/scp/makesql/ir.js +0 -66
  80. package/dist/scp/makesql/ir.js.map +0 -1
@@ -19,7 +19,9 @@
19
19
  * THROWS. It is NEVER degraded to a boxed/untyped output; that would silently defeat the de-box.
20
20
  */
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.parseProjectionColumn = parseProjectionColumn;
22
23
  exports.nodeOutType = nodeOutType;
24
+ exports.crudNodeAsType = crudNodeAsType;
23
25
  exports.deriveReadOutTypes = deriveReadOutTypes;
24
26
  const coltype_1 = require("../coltype");
25
27
  const tx_1 = require("./tx");
@@ -71,12 +73,59 @@ function stringArrayPort(ports, name) {
71
73
  throw new Error(`outtype: port '${name}' must be an {arr:[…]} literal in the IR (got ${JSON.stringify(v)})`);
72
74
  }
73
75
  /**
74
- * The row `obj` type of a SELECT projection: `{obj:{col: <bcScalar>, …}}`. Each column is typed by
75
- * resolving its SQL type from the schema SoT and mapping via {@link sqlTypeToBcScalar}. A `*` or
76
- * absent projection, a computed/aliased/qualified column, or a duplicate column is a HARD ERROR —
77
- * such a projection cannot be de-boxed into a concrete struct (no-assume, no-fallback).
76
+ * The SINGLE projection-column parser (issue #59) — shared by BOTH the codegen `outType` derivation
77
+ * and the TS read-path materializer derivation so the two CANNOT diverge (the recurring source of
78
+ * silent-rounding leaks). Classifies ONE `select`-list entry:
79
+ * - bare `col` → `{ kind:'column', underlying:'col', outputKey:'col' }`.
80
+ * - qualified `t.col` → strip qualifier → `underlying:'col', outputKey:'col'`.
81
+ * - aliased `col AS b` / `t.col AS b` → `underlying:'col', outputKey:'b'` (the driver row key).
82
+ * - computed `COUNT(*)`, `NOW()`, `x::uuid`, `x+1`, aliased or not → `{ kind:'computed', text }`.
83
+ * - `*` / `t.*` → HARD ERROR (the concrete column list is unknown).
84
+ * A SCHEMA-column entry MUST be typed against the declaration (a caller resolves + fail-closes on an
85
+ * undeclared column → never a silent rounded-i64 leak). A COMPUTED entry has no schema column to
86
+ * round: the read path leaves it raw; the codegen path (which needs every struct field typed) rejects
87
+ * it. This ONE parser guarantees every shape is classified identically for both paths.
78
88
  */
79
- function rowObjType(table, projection, resolveColumnType, at) {
89
+ function parseProjectionColumn(col, table, at) {
90
+ const raw = col.trim();
91
+ if (raw === '*' || raw.endsWith('.*')) {
92
+ throw new Error(`outtype: ${at}: SELECT on '${table}' projects '${raw}' (a wildcard). A typed de-box needs the ` +
93
+ `concrete column list to build the row struct + type each column — spec §4.1 is column-typed. ` +
94
+ `Project explicit columns (no-assume, no-fallback).`);
95
+ }
96
+ // Split off an `AS <alias>` (case-insensitive; alias must be a bare identifier).
97
+ let expr = raw;
98
+ let alias;
99
+ const asMatch = /^(.*?)\s+AS\s+([A-Za-z_][A-Za-z0-9_]*)$/i.exec(raw);
100
+ if (asMatch !== null) {
101
+ expr = asMatch[1].trim();
102
+ alias = asMatch[2];
103
+ }
104
+ // A bare or qualified column reference — `col` or `qual.col` (identifiers only) — is a SCHEMA
105
+ // column. The qualifier (if present) names the column's OWNER table (a JOIN column), against which
106
+ // its type resolves; without a qualifier the column belongs to the node's base table.
107
+ const refMatch = /^(?:([A-Za-z_][A-Za-z0-9_]*)\.)?([A-Za-z_][A-Za-z0-9_]*)$/.exec(expr);
108
+ if (refMatch !== null) {
109
+ const qualifier = refMatch[1];
110
+ const underlying = refMatch[2];
111
+ return { kind: 'column', underlying, outputKey: alias ?? underlying, ...(qualifier !== undefined ? { qualifier } : {}) };
112
+ }
113
+ // Anything else (a function call `f(x)`, an aggregate `COUNT(*)`, a cast `x::uuid`, arithmetic, a
114
+ // literal) is a COMPUTED expression — no underlying schema column, so it cannot round an i64. The
115
+ // read path leaves it raw; the codegen path rejects it (it needs a concrete field type).
116
+ return { kind: 'computed', text: raw };
117
+ }
118
+ /**
119
+ * The row `obj` type of a SELECT projection: `{obj:{outputKey: <bcScalar>, …}}`. Each column is
120
+ * resolved ONCE via the SHARED {@link parseProjectionColumn} (bare / qualified / aliased) and its SQL
121
+ * type (from the schema SoT) yields BOTH the bc scalar (this outType, for codegen) AND — written into
122
+ * the `materializers` accumulator — the TS read-path {@link MaterializeClass} (INT32/INT64/date/bool).
123
+ * This is the SINGLE column-type resolution the whole read pipeline consumes: codegen reads the
124
+ * `obj`; the runtime read path reads `materializers`. They cannot diverge — they are two projections
125
+ * of the ONE resolution. A `*` / absent projection, a computed column, a duplicate OUTPUT key, or an
126
+ * undeclared underlying column is a HARD ERROR (no-assume, no-fallback) — for BOTH consumers.
127
+ */
128
+ function rowObjType(table, projection, resolveColumnType, at, materializers) {
80
129
  if (projection === undefined || projection.length === 0) {
81
130
  throw new Error(`outtype: ${at}: SELECT on '${table}' has no explicit column projection ('*' / empty). A typed ` +
82
131
  `de-box needs the concrete column list to build the row struct — spec §4.1 is column-typed. ` +
@@ -84,48 +133,60 @@ function rowObjType(table, projection, resolveColumnType, at) {
84
133
  }
85
134
  const obj = {};
86
135
  for (const col of projection) {
87
- // Reject anything that is not a bare column name — an alias (`x AS y`), a qualified name
88
- // (`t.c`), or a computed expression cannot be typed from the schema alone.
89
- if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(col)) {
90
- throw new Error(`outtype: ${at}: projected column '${col}' on '${table}' is not a bare column name (alias / ` +
91
- `qualified / computed). Typed de-box (spec §4.1) requires bare schema columns so each maps ` +
92
- `to a SQL type. No-assume, no-fallback.`);
136
+ const entry = parseProjectionColumn(col, table, at);
137
+ // A computed expression has no concrete struct field type — HARD ERROR (spec §4.1 no-assume).
138
+ // The read path never reaches a separate lenient pass now; `*`/computed fail here for BOTH.
139
+ if (entry.kind === 'computed') {
140
+ throw new Error(`outtype: ${at}: projected expression '${entry.text}' on '${table}' is computed (function / ` +
141
+ `aggregate / cast / literal) and cannot be typed into a concrete row struct field. Typed ` +
142
+ `de-box (spec §4.1) requires bare/qualified/aliased schema columns. No-assume, no-fallback.`);
93
143
  }
94
- if (col in obj)
95
- throw new Error(`outtype: ${at}: duplicate projected column '${col}' on '${table}'`);
96
- // sqlTypeToBcScalar throws on an unknown/ambiguous SQL type — fail-closed by construction.
97
- obj[col] = toPortableScalar((0, coltype_1.sqlTypeToBcScalar)(resolveColumnType(table, col)), table, col);
144
+ const { underlying, outputKey, qualifier } = entry;
145
+ if (outputKey in obj)
146
+ throw new Error(`outtype: ${at}: duplicate projected column key '${outputKey}' on '${table}'`);
147
+ // Resolve against the qualifier's table (a JOIN column) if present, else the node's base table.
148
+ const owner = qualifier ?? table;
149
+ // ONE resolution of the SQL type → both the bc scalar AND the materialize class. resolveColumnType
150
+ // throws on an undeclared column, sqlType* throw on an unknown SQL type — fail-closed by
151
+ // construction on the UNDERLYING column, keyed by the OUTPUT column (the driver's row key).
152
+ const sqlType = resolveColumnType(owner, underlying);
153
+ obj[outputKey] = toPortableScalar((0, coltype_1.sqlTypeToBcScalar)(sqlType), owner, underlying);
154
+ const klass = (0, coltype_1.sqlTypeToMaterializeClass)(sqlType);
155
+ if (klass !== 'passthrough')
156
+ materializers[outputKey] = klass; // omit passthrough (no-op coercion)
98
157
  }
99
158
  return { obj };
100
159
  }
101
160
  /**
102
- * The `outType` of ONE read body node. A `Select` returns a ROW LIST → `{arr:rowObj}`. A `Count`
103
- * returns a single `int`. A `.map` node runs its inner component PER element of the iterated list,
104
- * so its result is `{arr:<per-element outType>}` (the per-element type being the inner node's own
105
- * outType — for a `.map` over a Select-per-element that is `{arr:{arr:rowObj}}`). An unrecognized
106
- * component throws (typed codegen covers only the SQL read catalog).
161
+ * The outType + read-path materializers of ONE read body node — derived from the SINGLE column-type
162
+ * resolution ({@link rowObjType}). A `Select` returns a ROW LIST → `{arr:rowObj}`; a `Count` a single
163
+ * `int` (a scalar, no per-column map). A `.map` node wraps its per-element Select result. An
164
+ * unrecognized component throws (typed read de-box covers only the SQL read catalog).
107
165
  */
108
- function nodeOutType(node, resolveColumnType) {
166
+ function nodeTypes(node, resolveColumnType) {
109
167
  const { component, ports } = nodeRef(node);
110
168
  const at = `node '${node.id}'`;
111
169
  if (component === 'Count')
112
- return 'int';
170
+ return { outType: 'int', materializers: {} };
113
171
  if (component === 'Select') {
114
172
  const table = stringPort(ports, 'table');
115
173
  if (table === undefined)
116
174
  throw new Error(`outtype: ${at}: Select node requires a literal 'table' port`);
117
175
  const projection = stringArrayPort(ports, 'select');
118
- const row = rowObjType(table, projection, resolveColumnType, at);
119
- // A `.map` node iterates a list and invokes the inner component per element; the node result is
120
- // the list of per-element results. Here the inner is a Select → per element a row LIST, so the
121
- // map node's outType is `{arr:{arr:rowObj}}`. A non-map Select node returns the row list `{arr:rowObj}`.
122
- if (isMap(node))
123
- return { arr: { arr: row } };
124
- return { arr: row };
125
- }
126
- throw new Error(`outtype: ${at}: component '${component}' has no typed outType (typed read codegen covers Select/Count only). ` +
176
+ const materializers = {};
177
+ const row = rowObjType(table, projection, resolveColumnType, at, materializers);
178
+ // A `.map` node iterates a list and invokes the inner component per element (row LIST per element
179
+ // → `{arr:{arr:rowObj}}`); a plain Select node returns the row list `{arr:rowObj}`.
180
+ const outType = isMap(node) ? { arr: { arr: row } } : { arr: row };
181
+ return { outType, materializers };
182
+ }
183
+ throw new Error(`outtype: ${at}: component '${component}' has no typed outType (typed read de-box covers Select/Count only). ` +
127
184
  `A write / unknown node cannot be de-boxed here — no-assume, no-fallback.`);
128
185
  }
186
+ /** The outType of ONE read body node (thin wrapper over {@link nodeTypes} for external callers). */
187
+ function nodeOutType(node, resolveColumnType) {
188
+ return nodeTypes(node, resolveColumnType).outType;
189
+ }
129
190
  /**
130
191
  * Derive the component `outputType` by walking the `output` Φ-expression against a `nodeId →
131
192
  * outType` map. `{ref:[id]}` resolves to that node's outType; `{obj:{k:expr,…}}` /
@@ -179,6 +240,71 @@ function outputType(output, byNode, at) {
179
240
  `(ref / obj / arr / opt of node results). The typed de-box path does not build a dynamic ` +
180
241
  `Value output tree — no-assume, no-fallback.`);
181
242
  }
243
+ /**
244
+ * PRE-COMPILE node-output type (bc 0.8.0 SA5 / #12): the determined `PortableType` a litedbmodel CRUD
245
+ * leaf annotates its authored node with, via bc's `.as(t)` recording API, so `compileBehaviors`'
246
+ * all-nodes-typed gate (`UNTYPED_NODE`) passes. Computed from the RAW authored ports (a plain `table`
247
+ * string + a plain `select` / `returning` column list — the same projection SoT `deriveReadOutTypes`
248
+ * reads post-compile, just moved to authoring time) + the model's inline `static columns` resolver.
249
+ *
250
+ * - `Select` → the row LIST `{arr:{obj:{outKey:<scalar>,…}}}` from the `select` projection. This is
251
+ * the value `.as` takes in BOTH positions: a top-level Select node's `outType` is this list; a
252
+ * mapped Select's `.as` records it as the map ELEMENT type (bc convention — the per-parent row list).
253
+ * - `Count` → NOT handled here: its output is the static `int` catalog `elemType` (no `.as`).
254
+ * - `Insert`/`Update`/`Delete` → the RETURNING row list `{arr:{obj:…}}` from the `returning` port
255
+ * (bare-column list). No `returning` → an EMPTY row list `{arr:{obj:{}}}` (the write surfaces rows
256
+ * only via RETURNING; a no-RETURNING write yields empty rows — mirrors `writeouttype.ts`).
257
+ *
258
+ * Schema columns are parsed by the SAME {@link parseProjectionColumn} the read/codegen paths use and
259
+ * typed via the resolver (an undeclared column fails closed here at authoring — earlier than the
260
+ * post-compile derivation). A COMPUTED projected column (`COUNT(*) as n`, a cast, a literal) is OMITTED
261
+ * from the typed row struct — the read path leaves a computed column RAW (#59: "the read path leaves it
262
+ * raw; the codegen path rejects it"), so its field is absent from the de-box row type. This keeps the
263
+ * node's outType DETERMINED (gate passes) while preserving #59's raw-computed read behavior; the typed
264
+ * codegen path independently rejects a computed projection later (it needs every field typed). The
265
+ * value is the OUTPUT-row type only; SQL stays opaque text on the makeSQL leaf (types the node OUTPUT,
266
+ * never the SQL).
267
+ */
268
+ function crudNodeAsType(component, ports, resolveColumnType, at) {
269
+ const table = ports['table'];
270
+ if (typeof table !== 'string') {
271
+ throw new Error(`outtype: ${at}: ${component} node requires a literal 'table' string port to type its output (got ${JSON.stringify(table)})`);
272
+ }
273
+ if (component === 'Select') {
274
+ const select = ports['select'];
275
+ if (!Array.isArray(select) || select.length === 0) {
276
+ throw new Error(`outtype: ${at}: Select has no explicit column projection ('*' / empty). A typed de-box needs the ` +
277
+ `concrete column list to build the row struct — spec §4.1 is column-typed. Project explicit columns.`);
278
+ }
279
+ const obj = {};
280
+ for (const raw of select) {
281
+ if (typeof raw !== 'string')
282
+ throw new Error(`outtype: ${at}: Select 'select' entries must be literal strings (got ${JSON.stringify(raw)})`);
283
+ const parsed = parseProjectionColumn(raw, table, at);
284
+ if (parsed.kind === 'computed')
285
+ continue; // computed column: read raw, omitted from the typed row (SA5-determined without it)
286
+ const { underlying, outputKey, qualifier } = parsed;
287
+ if (outputKey in obj)
288
+ throw new Error(`outtype: ${at}: duplicate projected column key '${outputKey}' on '${table}'`);
289
+ obj[outputKey] = toPortableScalar((0, coltype_1.sqlTypeToBcScalar)(resolveColumnType(qualifier ?? table, underlying)), qualifier ?? table, underlying);
290
+ }
291
+ return { arr: { obj } };
292
+ }
293
+ if (component === 'Insert' || component === 'Update' || component === 'Delete') {
294
+ // The RETURNING port is a single comma-separated bare-column string (`'id, author_id'`) or absent.
295
+ const returning = ports['returning'];
296
+ if (returning === undefined)
297
+ return { arr: { obj: {} } };
298
+ if (typeof returning !== 'string') {
299
+ throw new Error(`outtype: ${at}: ${component} 'returning' port must be a literal string (got ${JSON.stringify(returning)})`);
300
+ }
301
+ const cols = returning.split(',').map((c) => c.trim()).filter((c) => c.length > 0);
302
+ if (cols.length === 0)
303
+ return { arr: { obj: {} } };
304
+ return { arr: rowObjType(table, cols, resolveColumnType, at, {}) };
305
+ }
306
+ throw new Error(`outtype: ${at}: no pre-compile output type for component '${component}' (typed CRUD covers Select/Insert/Update/Delete; Count is static via catalog elemType).`);
307
+ }
182
308
  /**
183
309
  * Per-node `outType` (keyed by body node id) + the component `outputType`, derived for a READ
184
310
  * component (spec §4.1). `cond` nodes are skipped for the per-node map but a `cond` at the OUTPUT
@@ -187,11 +313,16 @@ function outputType(output, byNode, at) {
187
313
  */
188
314
  function deriveReadOutTypes(component, resolveColumnType) {
189
315
  const byNode = new Map();
316
+ const materializersByNode = new Map();
190
317
  for (const n of component.body) {
191
318
  if ('cond' in n)
192
319
  continue; // a cond node carries no SELECT projection; it is typed by its branch
193
- byNode.set(n.id, nodeOutType(n, resolveColumnType));
320
+ // ONE resolution per node → the outType (codegen) AND the read-path materializers (runtime).
321
+ const t = nodeTypes(n, resolveColumnType);
322
+ byNode.set(n.id, t.outType);
323
+ if (Object.keys(t.materializers).length > 0)
324
+ materializersByNode.set(n.id, t.materializers);
194
325
  }
195
- return { byNode, outputType: outputType(component.output, byNode, `component '${component.name}' output`) };
326
+ return { byNode, outputType: outputType(component.output, byNode, `component '${component.name}' output`), materializersByNode };
196
327
  }
197
328
  //# sourceMappingURL=outtype.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"outtype.js","sourceRoot":"","sources":["../../../src/scp/makesql/outtype.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;AAkGH,kCAmBC;AA8DD,gDAUC;AAzLD,wCAAuF;AACvF,6BAAmC;AAEnC;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,MAAgB,EAAE,MAAc,EAAE,OAAe;IACzE,OAAO,MAAM,CAAC;AAChB,CAAC;AAKD,SAAS,KAAK,CAAC,CAA4B;IACzC,OAAO,KAAK,IAAI,CAAC,CAAC;AACpB,CAAC;AAED,qEAAqE;AACrE,SAAS,OAAO,CAAC,CAAU;IACzB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;AACpH,CAAC;AAED,SAAS,KA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pB,iBAAqC;IAErC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC/C,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAA4C,CAAC;IAChF,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,MAAM,IAAI,CAAC;YAAE,SAAS,CAAC,sEAAsE;QACjG,6FAA6F;QAC7F,MAAM,CAAC,GAAG,SAAS,CAAC,CAAY,EAAE,iBAAiB,CAAC,CAAC;QACrD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;QAC5B,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC;IAC9F,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,SAAS,CAAC,IAAI,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAC;AACnI,CAAC"}
@@ -17,6 +17,38 @@
17
17
  * force either into a consumer that only uses the sync better-sqlite3 conformance path.
18
18
  */
19
19
  import type { SqlExecutorAsync } from './static-bundle';
20
+ /** The minimal `pg.types` surface: register a per-OID text parser. */
21
+ export interface PgTypesLike {
22
+ setTypeParser(oid: number, parser: (value: string) => unknown): void;
23
+ }
24
+ /**
25
+ * Register `pg` type parsers so the read-path de-box (issue #59) gets coercible values: the
26
+ * DATE/TIMESTAMP/TIMESTAMPTZ/TIME family is returned as its NATIVE TEXTUAL string (NOT a JS Date),
27
+ * honoring the `date→string` outType and carrying the TZ for timestamptz. int8 already arrives as a
28
+ * string (pg default), so it needs no parser. Idempotent. Call ONCE, before building the pool, from
29
+ * the consumer that owns the `pg` module (`import { types } from 'pg'; configurePgDeboxTypeParsers(types)`).
30
+ *
31
+ * WHY the GLOBAL parser (a documented, deliberate exception): `pg`'s default DATE parser builds a JS
32
+ * `Date` at LOCAL midnight, which shifts the UTC CALENDAR DAY (e.g. `2026-07-14` → a Date whose UTC
33
+ * day is `2026-07-13`). That loss happens INSIDE the driver, BEFORE the materializer sees the value —
34
+ * so materializer-side coercion CANNOT recover the correct calendar day from the already-shifted
35
+ * Date. Reading the native text (this parser) is the only lossless option, and `pg` exposes type
36
+ * parsers only at module (process-global) scope. It is set ONCE at pool creation, not per read. The
37
+ * materializer's `Date → ISO string` path remains as a defensive fallback for any driver/config that
38
+ * still slips a Date through, but the correct-day guarantee for pg DATE comes from this parser.
39
+ */
40
+ export declare function configurePgDeboxTypeParsers(types: PgTypesLike): void;
41
+ /**
42
+ * The `mysql2` pool options the read-path de-box (issue #59) requires: `supportBigNumbers` +
43
+ * `bigNumberStrings` so BIGINT arrives as an EXACT string (→ bigint; a plain number would already
44
+ * have rounded it), and `dateStrings` so the DATE/TIMESTAMP/DATETIME family arrives as its native
45
+ * textual string (→ the `date→string` outType, NOT a JS Date). Spread into `mysql.createPool(...)`.
46
+ */
47
+ export declare const mysqlDeboxPoolOptions: {
48
+ readonly supportBigNumbers: true;
49
+ readonly bigNumberStrings: true;
50
+ readonly dateStrings: true;
51
+ };
20
52
  /** The minimal `pg.Pool` surface we need: `query(text, values)` resolving `{ rows }`. */
21
53
  export interface PgPoolLike {
22
54
  query(text: string, values?: unknown[]): Promise<{
@@ -43,5 +75,43 @@ export declare function pgPoolExecutor(pool: PgPoolLike): SqlExecutorAsync;
43
75
  *
44
76
  * Recommend `connectionLimit` ≥ the plan's `concurrency` (default 16).
45
77
  */
78
+ /** Minimal `pg` module surface: a `Pool` ctor + the global `types.setTypeParser`. */
79
+ export interface PgModuleLike {
80
+ Pool: new (config: Record<string, unknown>) => PgPoolLike & {
81
+ end?: () => Promise<void>;
82
+ };
83
+ types: PgTypesLike;
84
+ }
85
+ /** Minimal `mysql2/promise` module surface: `createPool`. */
86
+ export interface Mysql2ModuleLike {
87
+ createPool(config: Record<string, unknown>): MysqlPoolLike & {
88
+ end?: () => Promise<void>;
89
+ };
90
+ }
91
+ /**
92
+ * Build a PG pool + executor with the read-path de-box wired IN (issue #59): registers the pg date
93
+ * type parsers (DATE/TIMESTAMP family → native textual string) globally, then builds the pool.
94
+ * int8 already arrives as a string on pg. Returns `{ pool, exec }` — pass `exec` to
95
+ * `executeBehaviorAsync`. This is the production async path's de-box-correct entry (no hand-spread
96
+ * options).
97
+ */
98
+ export declare function pgDeboxExecutor(pg: PgModuleLike, config: Record<string, unknown>): {
99
+ pool: PgPoolLike & {
100
+ end?: () => Promise<void>;
101
+ };
102
+ exec: SqlExecutorAsync;
103
+ };
104
+ /**
105
+ * Build a MySQL pool + executor with the read-path de-box wired IN (issue #59): the pool carries
106
+ * {@link mysqlDeboxPoolOptions} (`supportBigNumbers + bigNumberStrings` so BIGINT → exact string,
107
+ * `dateStrings` so the date family → string) — options that MUST be set at pool construction (a
108
+ * rounded BIGINT cannot be un-rounded post-hoc). Returns `{ pool, exec }` for `executeBehaviorAsync`.
109
+ */
110
+ export declare function mysqlDeboxExecutor(mysql2: Mysql2ModuleLike, config: Record<string, unknown>): {
111
+ pool: MysqlPoolLike & {
112
+ end?: () => Promise<void>;
113
+ };
114
+ exec: SqlExecutorAsync;
115
+ };
46
116
  export declare function mysqlPoolExecutor(pool: MysqlPoolLike): SqlExecutorAsync;
47
117
  //# sourceMappingURL=pool-executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pool-executor.d.ts","sourceRoot":"","sources":["../../../src/scp/makesql/pool-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,yFAAyF;AACzF,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,E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AAE,gBAAgB,CAAA;CAAE,CAG7K;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,gBAAgB,CAKvE"}
@@ -18,8 +18,61 @@
18
18
  * force either into a consumer that only uses the sync better-sqlite3 conformance path.
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.mysqlDeboxPoolOptions = void 0;
22
+ exports.configurePgDeboxTypeParsers = configurePgDeboxTypeParsers;
21
23
  exports.pgPoolExecutor = pgPoolExecutor;
24
+ exports.pgDeboxExecutor = pgDeboxExecutor;
25
+ exports.mysqlDeboxExecutor = mysqlDeboxExecutor;
22
26
  exports.mysqlPoolExecutor = mysqlPoolExecutor;
27
+ // ── TS read-path driver de-box config (issue #59) ─────────────────────────────
28
+ // The read-path materializer (`materializeCell`) coerces each driver cell to the JS form its SQL
29
+ // column type declares (BIGINT→bigint, DATE→string, …). For that to be LOSSLESS the driver must
30
+ // hand the value over in a coercible form:
31
+ // - PG: int8 (OID 20) already arrives as a STRING; DATE/TIMESTAMP/TIMESTAMPTZ arrive as a JS
32
+ // Date by default (TZ-shifted). `configurePgDeboxTypeParsers` registers `pg` type parsers so
33
+ // the date family arrives as its NATIVE TEXTUAL form (carrying TZ for timestamptz) — the
34
+ // value-preserving string the materializer expects. This is a GLOBAL `pg` setting (pg has no
35
+ // per-pool parser), applied once by the consumer that owns the pg import.
36
+ // - MySQL: BIGINT arrives as a rounded JS number by default (LOSSY). The pool MUST be built with
37
+ // `mysqlDeboxPoolOptions` (`supportBigNumbers + bigNumberStrings` so BIGINT→string, and
38
+ // `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
+ /**
42
+ * Register `pg` type parsers so the read-path de-box (issue #59) gets coercible values: the
43
+ * 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
+ * the consumer that owns the `pg` module (`import { types } from 'pg'; configurePgDeboxTypeParsers(types)`).
47
+ *
48
+ * WHY the GLOBAL parser (a documented, deliberate exception): `pg`'s default DATE parser builds a JS
49
+ * `Date` at LOCAL midnight, which shifts the UTC CALENDAR DAY (e.g. `2026-07-14` → a Date whose UTC
50
+ * day is `2026-07-13`). That loss happens INSIDE the driver, BEFORE the materializer sees the value —
51
+ * so materializer-side coercion CANNOT recover the correct calendar day from the already-shifted
52
+ * Date. Reading the native text (this parser) is the only lossless option, and `pg` exposes type
53
+ * parsers only at module (process-global) scope. It is set ONCE at pool creation, not per read. The
54
+ * materializer's `Date → ISO string` path remains as a defensive fallback for any driver/config that
55
+ * still slips a Date through, but the correct-day guarantee for pg DATE comes from this parser.
56
+ */
57
+ function configurePgDeboxTypeParsers(types) {
58
+ const asString = (v) => v; // identity: keep the driver's native textual form
59
+ types.setTypeParser(PG_OID.DATE, asString);
60
+ types.setTypeParser(PG_OID.TIMESTAMP, asString);
61
+ types.setTypeParser(PG_OID.TIMESTAMPTZ, asString);
62
+ types.setTypeParser(PG_OID.TIME, asString);
63
+ types.setTypeParser(PG_OID.TIMETZ, asString);
64
+ }
65
+ /**
66
+ * The `mysql2` pool options the read-path de-box (issue #59) requires: `supportBigNumbers` +
67
+ * `bigNumberStrings` so BIGINT arrives as an EXACT string (→ bigint; a plain number would already
68
+ * have rounded it), and `dateStrings` so the DATE/TIMESTAMP/DATETIME family arrives as its native
69
+ * textual string (→ the `date→string` outType, NOT a JS Date). Spread into `mysql.createPool(...)`.
70
+ */
71
+ exports.mysqlDeboxPoolOptions = {
72
+ supportBigNumbers: true,
73
+ bigNumberStrings: true,
74
+ dateStrings: true,
75
+ };
23
76
  /**
24
77
  * Adapt a `pg.Pool` to the async executor seam. Each `exec` runs `pool.query`, which acquires a
25
78
  * pooled connection, runs the query, and releases it — so N concurrent siblings run on N pooled
@@ -35,12 +88,27 @@ function pgPoolExecutor(pool) {
35
88
  };
36
89
  }
37
90
  /**
38
- * Adapt a `mysql2/promise` pool to the async executor seam. `pool.query` acquires + releases a
39
- * pooled connection per call, so concurrent siblings run in parallel. The graph renders `?`
40
- * placeholders for the `mysql` dialect — `mysql2`'s native form.
41
- *
42
- * Recommend `connectionLimit` ≥ the plan's `concurrency` (default 16).
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).
43
96
  */
97
+ function pgDeboxExecutor(pg, config) {
98
+ configurePgDeboxTypeParsers(pg.types);
99
+ const pool = new pg.Pool(config);
100
+ return { pool, exec: pgPoolExecutor(pool) };
101
+ }
102
+ /**
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`.
107
+ */
108
+ function mysqlDeboxExecutor(mysql2, config) {
109
+ const pool = mysql2.createPool({ ...config, ...exports.mysqlDeboxPoolOptions });
110
+ return { pool, exec: mysqlPoolExecutor(pool) };
111
+ }
44
112
  function mysqlPoolExecutor(pool) {
45
113
  return async (sql, params) => {
46
114
  const [rows] = await pool.query(sql, params);
@@ -1 +1 @@
1
- {"version":3,"file":"pool-executor.js","sourceRoot":"","sources":["../../../src/scp/makesql/pool-executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiB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AE,CAAC,CAAC;IACxE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;AACjD,CAAC;AAED,SAAgB,iBAAiB,CAAC,IAAmB;IACnD,OAAO,KAAK,EAAE,GAAW,EAAE,MAAiB,EAAsC,EAAE;QAClF,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
@@ -33,11 +33,11 @@
33
33
  * Expression IR, a SKIP-`cond` guard becomes the statement's `skip` expression, and the SQL
34
34
  * text is emitted once.
35
35
  */
36
- import { type Scope, type Value, type ComponentGraphIR } from 'behavior-contracts';
37
- import type { ComponentRefNode, MapNode, BehaviorModelContract } from '../authoring';
36
+ import { type Scope, type Value } from 'behavior-contracts';
37
+ import type { ComponentGraphIR, ComponentRefNode, MapNode, BehaviorModelContract } from '../authoring';
38
38
  import { type Dialect } from './handler';
39
39
  import { type FindFilterSource } from '../find-filter-guard';
40
- import type { ColumnTypeResolver } from '../coltype';
40
+ import { type ColumnTypeResolver, type MaterializeClass } from '../coltype';
41
41
  /** A closed-set bc Expression IR node used as a deferred value-spec or a skip expression. */
42
42
  export type ValueSpec = unknown;
43
43
  /**
@@ -120,51 +120,60 @@ export declare function executeStaticBundle(bundle: StaticBundle, input: Scope,
120
120
  */
121
121
  export declare function executeStaticWrite(bundle: StaticBundle, input: Scope, db: SqliteDb): Record<string, unknown>[];
122
122
  /**
123
- * The compiled, portable READ graph of a behavior method: the surrogate bc `ComponentGraphIR`
124
- * (each SQL node → a `makeSQL` node with one `__scope` port; wiring / map / Φ output preserved)
125
- * plus the per-node static statement templates and the optional heads. Pure JSON —
126
- * `JSON.stringify` round-trips, so a per-language runtime executes it with bc + a SQL driver.
123
+ * The compiled, portable READ graph of a behavior method (#12 de-surrogated): `compileBehaviors`'
124
+ * REAL `ComponentGraphIR` — the authored `Select`/`Count`/map nodes with their own ports (only
125
+ * additively annotated with read `outType`/`outputType`), NOT a hand-built `__makeSqlNode`/`__scope`
126
+ * surrogate — plus the per-node static `makeSQL` statement templates (opaque, v1-`DBConditions`-
127
+ * sourced SQL TEXT) keyed by the real body-node id, and the optional heads. Pure JSON —
128
+ * `JSON.stringify` round-trips, so every language runtime walks this real-node IR natively (topology
129
+ * from the real nodes, SQL from `statementsById`) with a SQL driver — never bc `runBehavior`.
127
130
  */
128
131
  export interface ReadGraph {
129
132
  readonly dialect: Dialect;
130
133
  readonly name: string;
131
- /** The surrogate bc IR (catalog nodes → `makeSQL` `__scope`-port nodes). */
134
+ /** `compileBehaviors`' real `ComponentGraphIR` (real `Select`/`Count`/map nodes; outType-annotated). */
132
135
  readonly ir: ComponentGraphIR;
133
- /** Per-node static `makeSQL` statement templates, keyed by body node id. */
136
+ /** Per-node static `makeSQL` statement templates (v1-sourced SQL text), keyed by real body node id. */
134
137
  readonly statementsById: Record<string, readonly StaticStatement[]>;
135
138
  /** Input heads normalized to present-as-null (absent-key SKIP; SSoT-driven). */
136
139
  readonly optionalHeads: readonly string[];
140
+ /**
141
+ * TS read-path MATERIALIZERS (issue #59), per Select node: `column → MaterializeClass`. Present
142
+ * ONLY when a column-type resolver was supplied at compile (same gate as the `outType`
143
+ * annotations) — without it the read stays un-materialized (raw driver values), identical to the
144
+ * pre-#59 behavior. When present, the read handler coerces each raw row cell to the JS form the
145
+ * SQL column type declares (BIGINT→bigint, INT→number, DATE→string, BOOLEAN→boolean), consistent
146
+ * across sqlite/pg/mysql.
147
+ */
148
+ readonly materializersByNode?: Record<string, Record<string, MaterializeClass>>;
137
149
  }
138
150
  /**
139
- * Compile a READ behavior method into a portable {@link ReadGraph}: rewrite each authored SQL
140
- * body node to a `makeSQL` node carrying a synthetic `__scope` port (bc evaluates it in-scope),
141
- * and compile each node's static statements ONCE. SYMBOLIC — no concrete input. bc will own map
142
- * iteration / wire binding / Φ output at execute time; the handler renders each node's statements.
151
+ * Compile a READ behavior method into a portable {@link ReadGraph} (#12 de-surrogated): keep
152
+ * `compileBehaviors`' REAL `Select`/`Count`/map body nodes (only additively annotate each with its
153
+ * read `outType`), and compile each node's static `makeSQL` statements ONCE into the `statementsById`
154
+ * sidecar (keyed by the real body-node id). SYMBOLIC — no concrete input. The native walker
155
+ * ({@link executeReadGraph}) owns map iteration / wire binding / Φ output at execute time, rendering
156
+ * each node's statements against the walk scope — never bc `runBehavior`, never a `__scope` surrogate.
143
157
  */
144
158
  export declare function compileReadGraph(contract: BehaviorModelContract, dialect: Dialect, entry?: string, findFilterModel?: FindFilterSource, resolveColumnType?: ColumnTypeResolver): ReadGraph;
145
159
  /**
146
- * Execute a compiled {@link ReadGraph} via bc `runBehavior` + a makeSQL handler: bc drives map
147
- * iteration / wire binding / Φ output; the handler renders each node's static statements against
148
- * the evaluated `__scope` and runs REAL SQLite. Returns the component's Φ output. This is the
149
- * design's "bc composes, makeSQL executes" — the SAME path a per-language runtime follows.
160
+ * Execute a compiled {@link ReadGraph} via the NATIVE walker (#12): walk `compileBehaviors`' REAL
161
+ * `Select`/`Count`/map node IR in `plan.groups` stage order — computing each node's rows from its
162
+ * `statementsById` fragments (rendered against the walk scope) and committing `(nodeId → value)` —
163
+ * then evaluate the component's `output` Φ expression. NO bc `runBehavior`, NO `__makeSqlNode`
164
+ * surrogate; litedbmodel owns map iteration / wire binding / Φ output. This is the SAME native
165
+ * orchestration model the rust/go/py/php runtimes follow — one shape, all 5 languages, interpreter-free.
150
166
  */
151
167
  export declare function executeReadGraph(graph: ReadGraph, input: Scope, db: SqliteDb): Value;
152
168
  /** An async driver seam: run a rendered `{ sql, params }` and resolve to result rows (#40). */
153
169
  export type SqlExecutorAsync = (sql: string, params: unknown[]) => Promise<Record<string, unknown>[]>;
154
170
  /**
155
- * Async twin of {@link executeReadGraph} — the PG / MySQL execution model (#40).
156
- *
157
- * Byte-identical composition (SAME IR, SAME per-node SQL text + params, SAME Φ output), but bc's
158
- * `runBehaviorAsync` drives it: the makeSQL handler returns a Promise, and bc dispatches the
159
- * INDEPENDENT sibling nodes of a plan stage on `runPlanAsync`'s bounded-parallel path (bc#23),
160
- * bounded by the plan's `concurrency` (default 16). Against a pooled async driver (`pg` / `mysql2`,
161
- * each `exec` call resolving on its own pooled connection), that becomes REAL parallel read-relation
162
- * DB I/O — the plan's declared concurrency finally cashes out as concurrent dispatch. The result is
163
- * deterministic (bc commits stage outcomes in declaration order), so it equals the serial
164
- * `executeReadGraph` output exactly; only the wall-clock changes.
165
- *
166
- * The conformance bar stays on the SYNC in-proc better-sqlite3 path (`executeReadGraph`); this async
167
- * path is the live PG/MySQL execution model and is proven by the latency-injecting concurrency test.
171
+ * Async twin of {@link executeReadGraph} — the live PG / MySQL execution model (#40). Byte-identical
172
+ * composition (SAME real-node IR, SAME per-node SQL text + params, SAME Φ output); within a plan stage
173
+ * the INDEPENDENT sibling nodes are dispatched concurrently against the pooled async executor (each
174
+ * `exec` resolving on its own pooled connection), and a map node's per-element queries fan out in
175
+ * bounded parallel. The result is deterministic (stage outcomes commit in declaration order), so it
176
+ * equals the serial `executeReadGraph` output exactly; only the wall-clock changes.
168
177
  */
169
178
  export declare function executeReadGraphAsync(graph: ReadGraph, input: Scope, exec: SqlExecutorAsync): Promise<Value>;
170
179
  /**