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
@@ -0,0 +1,50 @@
1
+ /**
2
+ * litedbmodel v2 SCP — the op-INDEPENDENT leaf transport DECLARATION (the `@leaf static` SSoT).
3
+ *
4
+ * The whole per-DSL execution surface is THREE op-agnostic leaves. This module DECLARES them on
5
+ * behavior-contracts' native TS authoring surface and NOTHING else: it imports only
6
+ * `behavior-contracts`, holds no implementation, and is READ by `bc generate --from` (the bodies are
7
+ * never executed — bc derives each leaf's catalog entry from the signature alone).
8
+ *
9
+ * Every authored / emitted litedbmodel model imports `Db` FROM HERE, so there is exactly one leaf
10
+ * catalog in the repo: change a port here and every generated module in every language follows. The
11
+ * runtime side of the same three symbols lives in `./leaves` (the handler bodies + the native
12
+ * transport symbol map); it is deliberately a DIFFERENT module so a `--from` typecheck of an authored
13
+ * model pulls in the declaration only, never the driver stack.
14
+ *
15
+ * ## The port vocabulary
16
+ *
17
+ * The ports are declared `WireValue` / `WireValue[]` — bc's OPAQUE wire type. A binding annotated
18
+ * `WireValue[]` stays opaque (wire passthrough), so an intermediate result flows leaf→leaf with no
19
+ * typed↔generic round-trip; the SINGLE de-box happens at the one binding that declares a CONCRETE row
20
+ * type. A relation op therefore runs `executeSQL → pluck → executeSQL → … → group` entirely on the
21
+ * wire plane and materializes the whole nested typed graph exactly once, at the end.
22
+ */
23
+ import { type WireValue } from 'behavior-contracts';
24
+ /**
25
+ * The three OP-AGNOSTIC leaf transports. The bodies are declaration stubs — `bc generate --from`
26
+ * reads this source and derives the catalog from the signatures; the executable side is the handler
27
+ * map in `./leaves` (TS) and the per-language runtime transports (`execute_sql` / `pluck_keys` /
28
+ * `group_children`, see {@link import('./leaves').LEAF_TRANSPORT_SYMBOLS}).
29
+ */
30
+ export declare class Db {
31
+ /**
32
+ * The SOLE SQL transport: bind `params` and run `sql` through the central execute/run seam.
33
+ * `write` selects `run` (INSERT/UPDATE/DELETE) vs `execute` (SELECT / RETURNING); `returning` keeps
34
+ * a RETURNING write on the row path; `bigint` runs the read in exact-integer mode. A non-returning
35
+ * write yields the one-row `[{changes, lastInsertRowid}]` summary so the output shape is uniform.
36
+ *
37
+ * `guard` is the RELATION runaway cap (`{limit, model, relation}` — the compiled op's own
38
+ * {@link import('./limit-config').RelationGuard}) that a guarded relation child fetch carries: the
39
+ * transport asserts the fetched row count against it and raises `LimitExceededError` when the batch
40
+ * overruns. It rides HERE because this is where the RAW child rows exist — past `group` the graph is
41
+ * already nested — and because SCP has no throw, so the enforcement must live in the transport. A
42
+ * statement with no cap omits the port entirely (every non-relation call is byte-unchanged).
43
+ */
44
+ static executeSQL(sql: string, params: WireValue[], write: boolean, returning: boolean, bigint: boolean, whereDynamic?: WireValue | null, guard?: WireValue | null): WireValue[];
45
+ /** Relation key extraction: the deduped, non-null key set over the ordered key-column tuple `col`. */
46
+ static pluck(rows: WireValue[], col: string[]): WireValue[];
47
+ /** Relation shaping: nest `children` under each parent's `into`, matching `child[fk]` to `parent[pk]`. */
48
+ static group(parents: WireValue[], children: WireValue[], pk: string[], fk: string[], into: string, single: boolean): WireValue[];
49
+ }
50
+ //# sourceMappingURL=leaf-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leaf-transport.d.ts","sourceRoot":"","sources":["../../src/scp/leaf-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAgB1D;;;;;GAKG;AACH,qBAAa,EAAE;IACb;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,SAAS,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,EAAE;IAEtL,sGAAsG;IAChG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE;IAEjE,0GAA0G;IACpG,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE;CACxI"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /**
3
+ * litedbmodel v2 SCP — the op-INDEPENDENT leaf transport DECLARATION (the `@leaf static` SSoT).
4
+ *
5
+ * The whole per-DSL execution surface is THREE op-agnostic leaves. This module DECLARES them on
6
+ * behavior-contracts' native TS authoring surface and NOTHING else: it imports only
7
+ * `behavior-contracts`, holds no implementation, and is READ by `bc generate --from` (the bodies are
8
+ * never executed — bc derives each leaf's catalog entry from the signature alone).
9
+ *
10
+ * Every authored / emitted litedbmodel model imports `Db` FROM HERE, so there is exactly one leaf
11
+ * catalog in the repo: change a port here and every generated module in every language follows. The
12
+ * runtime side of the same three symbols lives in `./leaves` (the handler bodies + the native
13
+ * transport symbol map); it is deliberately a DIFFERENT module so a `--from` typecheck of an authored
14
+ * model pulls in the declaration only, never the driver stack.
15
+ *
16
+ * ## The port vocabulary
17
+ *
18
+ * The ports are declared `WireValue` / `WireValue[]` — bc's OPAQUE wire type. A binding annotated
19
+ * `WireValue[]` stays opaque (wire passthrough), so an intermediate result flows leaf→leaf with no
20
+ * typed↔generic round-trip; the SINGLE de-box happens at the one binding that declares a CONCRETE row
21
+ * type. A relation op therefore runs `executeSQL → pluck → executeSQL → … → group` entirely on the
22
+ * wire plane and materializes the whole nested typed graph exactly once, at the end.
23
+ */
24
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
25
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
26
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
27
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
28
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
29
+ };
30
+ var __metadata = (this && this.__metadata) || function (k, v) {
31
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.Db = void 0;
35
+ const behavior_contracts_1 = require("behavior-contracts");
36
+ /**
37
+ * The body of every declaration below. A `@leaf` body is never lowered and never executed — bc derives
38
+ * the catalog entry from the SIGNATURE alone — so calling a leaf on the TS plane is a wiring bug, and
39
+ * this throws rather than returning a plausible empty result. Taking `args` keeps every declared
40
+ * parameter genuinely referenced (they are the PORT NAMES; they may not be renamed or dropped).
41
+ */
42
+ function declarationStub(leafName, args) {
43
+ void args;
44
+ throw new Error(`litedbmodel Db.${leafName} is a leaf DECLARATION read by \`bc generate\` — it has no TS body. ` +
45
+ `The executable transport is the handler map \`leafHandlers\` / \`leafHandlersAsync\` in ./leaves.`);
46
+ }
47
+ /**
48
+ * The three OP-AGNOSTIC leaf transports. The bodies are declaration stubs — `bc generate --from`
49
+ * reads this source and derives the catalog from the signatures; the executable side is the handler
50
+ * map in `./leaves` (TS) and the per-language runtime transports (`execute_sql` / `pluck_keys` /
51
+ * `group_children`, see {@link import('./leaves').LEAF_TRANSPORT_SYMBOLS}).
52
+ */
53
+ class Db {
54
+ /**
55
+ * The SOLE SQL transport: bind `params` and run `sql` through the central execute/run seam.
56
+ * `write` selects `run` (INSERT/UPDATE/DELETE) vs `execute` (SELECT / RETURNING); `returning` keeps
57
+ * a RETURNING write on the row path; `bigint` runs the read in exact-integer mode. A non-returning
58
+ * write yields the one-row `[{changes, lastInsertRowid}]` summary so the output shape is uniform.
59
+ *
60
+ * `guard` is the RELATION runaway cap (`{limit, model, relation}` — the compiled op's own
61
+ * {@link import('./limit-config').RelationGuard}) that a guarded relation child fetch carries: the
62
+ * transport asserts the fetched row count against it and raises `LimitExceededError` when the batch
63
+ * overruns. It rides HERE because this is where the RAW child rows exist — past `group` the graph is
64
+ * already nested — and because SCP has no throw, so the enforcement must live in the transport. A
65
+ * statement with no cap omits the port entirely (every non-relation call is byte-unchanged).
66
+ */
67
+ static executeSQL(sql, params, write, returning, bigint, whereDynamic, guard) { return declarationStub('executeSQL', [sql, params, write, returning, bigint, whereDynamic, guard]); }
68
+ /** Relation key extraction: the deduped, non-null key set over the ordered key-column tuple `col`. */
69
+ static pluck(rows, col) { return declarationStub('pluck', [rows, col]); }
70
+ /** Relation shaping: nest `children` under each parent's `into`, matching `child[fk]` to `parent[pk]`. */
71
+ static group(parents, children, pk, fk, into, single) { return declarationStub('group', [parents, children, pk, fk, into, single]); }
72
+ }
73
+ exports.Db = Db;
74
+ __decorate([
75
+ behavior_contracts_1.leaf,
76
+ __metadata("design:type", Function),
77
+ __metadata("design:paramtypes", [String, Array, Boolean, Boolean, Boolean, Object, Object]),
78
+ __metadata("design:returntype", Array)
79
+ ], Db, "executeSQL", null);
80
+ __decorate([
81
+ behavior_contracts_1.leaf,
82
+ __metadata("design:type", Function),
83
+ __metadata("design:paramtypes", [Array, Array]),
84
+ __metadata("design:returntype", Array)
85
+ ], Db, "pluck", null);
86
+ __decorate([
87
+ behavior_contracts_1.leaf,
88
+ __metadata("design:type", Function),
89
+ __metadata("design:paramtypes", [Array, Array, Array, Array, String, Boolean]),
90
+ __metadata("design:returntype", Array)
91
+ ], Db, "group", null);
92
+ //# sourceMappingURL=leaf-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leaf-transport.js","sourceRoot":"","sources":["../../src/scp/leaf-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;;;;;;;;;;AAEH,2DAA0D;AAE1D;;;;;GAKG;AACH,SAAS,eAAe,CAAC,QAAgB,EAAE,IAAwB;IACjE,KAAK,IAAI,CAAC;IACV,MAAM,IAAI,KAAK,CACb,kBAAkB,QAAQ,sEAAsE;QAC9F,mGAAmG,CACtG,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAa,EAAE;IACb;;;;;;;;;;;;OAYG;IACU,AAAP,MAAM,CAAC,UAAU,CAAC,GAAW,EAAE,MAAmB,EAAE,KAAc,EAAE,SAAkB,EAAE,MAAe,EAAE,YAA+B,EAAE,KAAwB,IAAiB,OAAO,eAAe,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9R,sGAAsG;IACzF,AAAP,MAAM,CAAC,KAAK,CAAC,IAAiB,EAAE,GAAa,IAAiB,OAAO,eAAe,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnH,0GAA0G;IAC7F,AAAP,MAAM,CAAC,KAAK,CAAC,OAAoB,EAAE,QAAqB,EAAE,EAAY,EAAE,EAAY,EAAE,IAAY,EAAE,MAAe,IAAiB,OAAO,eAAe,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CACxN;AArBD,gBAqBC;AAPc;IAAZ,yBAAI;;;;0BAAyR;AAGjR;IAAZ,yBAAI;;;;qBAA8G;AAGtG;IAAZ,yBAAI;;;;qBAAkN"}
@@ -0,0 +1,174 @@
1
+ /**
2
+ * litedbmodel v2 SCP — the op-INDEPENDENT leaf transport IMPLEMENTATION (the TS runtime side).
3
+ *
4
+ * The three leaves are DECLARED once in {@link import('./leaf-transport').Db} (`@leaf static`, read by
5
+ * `bc generate --from`). THIS module carries their executable bodies and hands them to a generated
6
+ * module as a behavior-contracts handler map — the boundary injection a `bind(handlers)` /
7
+ * `bindAsync(handlers)` facade expects. Declaration and implementation are separate modules on
8
+ * purpose: a `--from` typecheck of an authored model must pull in the signature only, never the
9
+ * driver stack.
10
+ *
11
+ * - {@link executeSQL} — the SOLE SQL transport. Binds params and runs one statement through the
12
+ * central {@link import('./exec-context') execute/run seam} (the ONLY driver contact). Read
13
+ * (`write:false`) → rows; write (`write:true`) → a one-row `[{changes,lastInsertRowid}]` summary
14
+ * (RETURNING writes return their rows via `execute`). It owns the transport-level param shaping a
15
+ * relation key-set needs — the dialect array encoding + deferred PG cast resolution + `?`→`$N`
16
+ * render — and, when the statement is a GUARDED relation child fetch, the runaway check on its raw
17
+ * rows ({@link import('./limit-config').assertRelationHardLimit}): the RAW child rows exist only
18
+ * here, since `group` already sees a nested graph and SCP itself has no throw.
19
+ * - {@link pluck} — rows + the ordered key-column tuple → the deduped, non-null key array (the
20
+ * `= ANY($1)` / `json_each(?)` batch key set).
21
+ * - {@link group} — parents + a flat child list + `pk`/`fk`/`into` → each parent with its matching
22
+ * children nested under `into` (`hasMany` → list, single → the one child or null). This is the
23
+ * in-memory grouping that makes the child fetch ONE query (N+1-free).
24
+ *
25
+ * The environment (connection seam + dialect) is captured by the handler FACTORY, never carried on
26
+ * the IR (C4): {@link leafHandlers} closes over a sync {@link LeafContext} and {@link
27
+ * leafHandlersAsync} over an {@link AsyncLeafContext}. The same three symbols are what the native
28
+ * codegen calls directly ({@link LEAF_TRANSPORT_SYMBOLS}).
29
+ */
30
+ import type { Handlers, AsyncHandlers } from 'behavior-contracts/runtime';
31
+ import { type ExecutionContext, type AsyncExecutionContext, type StatementIntent } from './exec-context';
32
+ import { type RelationGuard } from './limit-config';
33
+ import { type Dialect } from './makesql/handler';
34
+ /**
35
+ * The environment boundary the handler factory captures (C4 — never on the IR). `exec` is the SYNC
36
+ * connection/middleware/tx seam (better-sqlite3, run via a generated module's `bind`); `dialect`
37
+ * selects the transport-level param encoding + placeholder render. The native ports carry the SAME facts.
38
+ */
39
+ export interface LeafContext {
40
+ /** The central sync execute/run seam (connection provider + middleware + tx pin). */
41
+ readonly exec: ExecutionContext;
42
+ /** The target SQL dialect (drives array-param encoding + `?`→`$N` render). */
43
+ readonly dialect: Dialect;
44
+ }
45
+ /**
46
+ * The ASYNC environment boundary (live PG / MySQL, run via a generated module's `bindAsync`). Carries
47
+ * the async execute/run seam ({@link AsyncExecutionContext}) instead of the sync one.
48
+ */
49
+ export interface AsyncLeafContext {
50
+ /** The central async execute/run seam (pooled per-execution connection ownership). */
51
+ readonly execAsync: AsyncExecutionContext;
52
+ /** The target SQL dialect. */
53
+ readonly dialect: Dialect;
54
+ }
55
+ /** The evaluated `executeSQL` ports a generated module hands the transport. */
56
+ interface ExecuteSqlPorts {
57
+ readonly sql: string;
58
+ readonly params: unknown[];
59
+ readonly write: boolean;
60
+ readonly returning: boolean;
61
+ readonly bigint: boolean;
62
+ /** The DYNAMIC WHERE plan (absent on a fully-bounded statement). See {@link assembleDynamicWhere}. */
63
+ readonly whereDynamic?: DynamicWherePlan | null;
64
+ /**
65
+ * The RELATION runaway cap this statement's rows are asserted against (absent ⇒ uncapped). Carried
66
+ * verbatim from the compiled relation op — see {@link assertRelationHardLimit}.
67
+ */
68
+ readonly guard?: RelationGuard | null;
69
+ }
70
+ /** Splice a ` WHERE …` clause (leading space included, or `''`) into `baseSql` before its first tail keyword. */
71
+ export declare function spliceWhere(baseSql: string, whereSql: string): string;
72
+ /**
73
+ * ONE evaluated WHERE fragment of a dynamic plan. bc has ALREADY evaluated the fragment's params and
74
+ * its SKIP guard against the input: a fragment whose guard was false evaluated LAZILY to `null` (bc's
75
+ * `cond` only evaluates the taken branch, so a dropped fragment's params are never evaluated).
76
+ */
77
+ export interface DynamicWhereFrag {
78
+ readonly sql: string;
79
+ readonly params: readonly unknown[];
80
+ }
81
+ /** The evaluated dynamic-WHERE plan: the fragment list, holes (skipped fragments) included. */
82
+ export interface DynamicWherePlan {
83
+ readonly frags?: readonly (DynamicWhereFrag | null)[];
84
+ }
85
+ /**
86
+ * Assemble the effective statement from a DYNAMIC WHERE plan: drop the absent (`null`) fragments,
87
+ * join the survivors with ` WHERE ` / ` AND `, splice the clause into the base `sql` before its first
88
+ * tail keyword ({@link spliceWhere}) — the exact position a bounded WHERE occupies — and bind the
89
+ * surviving fragments' params BEFORE the base params (the WHERE `?`s precede the tail's).
90
+ *
91
+ * A SKIP predicate's presence is per-CALL, so the FINAL statement can only be determined here, at
92
+ * execution time — which is also why `?`→`$N` is rendered after this ({@link prepareSql}), never at
93
+ * emit time. A statement with NO optional predicate carries no plan at all: its WHERE is spliced into
94
+ * the static `sql` at emit time and it never reaches this function.
95
+ */
96
+ export declare function assembleDynamicWhere(p: {
97
+ sql: string;
98
+ params: unknown[];
99
+ whereDynamic: DynamicWherePlan;
100
+ }): {
101
+ sql: string;
102
+ params: unknown[];
103
+ };
104
+ /** Prepare a statement for the seam: resolve deferred PG cast(s), render `?`→`$N`, encode params. */
105
+ export declare function prepareSql(p: {
106
+ sql: string;
107
+ params: unknown[];
108
+ write: boolean;
109
+ }, dialect: Dialect): {
110
+ sql: string;
111
+ bound: unknown[];
112
+ intent: StatementIntent;
113
+ };
114
+ /**
115
+ * The SYNC `executeSQL` body. `write` selects `run` (INSERT/UPDATE/DELETE) vs `execute` (SELECT /
116
+ * RETURNING); a non-returning write returns the one-row `[{changes,lastInsertRowid}]` summary so the
117
+ * leaf output shape is uniform.
118
+ *
119
+ * A read ALWAYS runs in exact-integer mode (better-sqlite3 `safeIntegers`), so an INTEGER column
120
+ * arrives as a `BigInt` — the value bc's `int` scalar declares. It is not conditional: the wire carries
121
+ * int and float as DISTINCT kinds, so a column declared `Int` cannot be satisfied by a JS number on any
122
+ * dialect, and gating exactness per endpoint made SQLite disagree with PostgreSQL and MySQL (whose
123
+ * integer type parsers are unconditional — `configurePgDeboxTypeParsers`, `mysqlDeboxPoolOptions`),
124
+ * which the conformance corpus rejects as dialect-variant. `bigint` is retained as a port because the
125
+ * generated modules declare it, but it no longer selects the seam.
126
+ */
127
+ export declare function executeSQL(p: ExecuteSqlPorts, ctx: LeafContext): Array<Record<string, unknown>>;
128
+ /** The ASYNC (live PG / MySQL) `executeSQL` body — the twin of {@link executeSQL} over the async seam. */
129
+ export declare function executeSQLAsync(p: ExecuteSqlPorts, ctx: AsyncLeafContext): Promise<Array<Record<string, unknown>>>;
130
+ /**
131
+ * Extract the deduped, non-null key set from `rows` over the ordered key-column tuple `col` — the
132
+ * batch key set a relation child fetch binds. Insertion order preserved; a row missing any key column
133
+ * is dropped (no partial keys). A single-key tuple yields a flat scalar array (`json_each` scalar
134
+ * `value`); a composite tuple yields an array-of-tuples (`json_each` per-ordinal `$[i]`). Dedupe is
135
+ * the shared grouping core ({@link dedupeKeyTuples}) — the SAME SSoT the lazy-relation path uses.
136
+ */
137
+ export declare function pluck(p: {
138
+ rows: Array<Record<string, unknown>>;
139
+ col: string[];
140
+ }): unknown[];
141
+ /**
142
+ * Distribute a flat `children` list onto `parents` by matching `child[fk]` to `parent[pk]`, nesting
143
+ * the result under `into`. `single:true` (belongsTo/hasOne) nests the one matching child (or `null`);
144
+ * otherwise (hasMany) nests the child list (`[]` when none). `pk`/`fk` are the ordered key-column
145
+ * tuples, so a composite relation nests by the WHOLE key (no `''`-collapse cartesian). Grouping is the
146
+ * shared core ({@link groupByKey}/{@link attachToParent}) — the SAME SSoT the lazy-relation path uses.
147
+ */
148
+ export declare function group(p: {
149
+ parents: Array<Record<string, unknown>>;
150
+ children: Array<Record<string, unknown>>;
151
+ pk: string[];
152
+ fk: string[];
153
+ into: string;
154
+ single: boolean;
155
+ }): Array<Record<string, unknown>>;
156
+ /**
157
+ * The SYNC handler map for a generated module's `bind(handlers)` — catalog name → the transport body,
158
+ * closed over the sync environment. This is the ONLY place the three leaves are wired to the TS
159
+ * runtime; a generated module never carries an implementation.
160
+ */
161
+ export declare function leafHandlers(ctx: LeafContext): Handlers;
162
+ /**
163
+ * The ASYNC handler map for a generated module's `bindAsync(handlers)` (live PG / MySQL). Only the SQL
164
+ * transport differs — the shaping leaves are the SAME implementations.
165
+ */
166
+ export declare function leafHandlersAsync(ctx: AsyncLeafContext): AsyncHandlers;
167
+ /**
168
+ * The native-codegen transport symbol table (`bc generate --leaf-transport`): each op-independent leaf
169
+ * → the runtime symbol the covered native module calls directly. The consumer supplies these
170
+ * (litedbmodel = a fixed set of ops, not one method per node).
171
+ */
172
+ export declare const LEAF_TRANSPORT_SYMBOLS: Readonly<Record<string, string>>;
173
+ export {};
174
+ //# sourceMappingURL=leaves.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leaves.d.ts","sourceRoot":"","sources":["../../src/scp/leaves.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAsB,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAK1B,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAsB,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAKrE;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sFAAsF;IACtF,QAAQ,CAAC,SAAS,EAAE,qBAAqB,CAAC;IAC1C,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,+EAA+E;AAC/E,UAAU,eAAe;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,sGAAsG;IACtG,QAAQ,CAAC,Y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C1G,wBAAsB,eAAe,CAAC,CAAC,EAAE,eAAe,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAMxH;AAID;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,OAAO,EAAE,CAG3F;AAID;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAAC,EAAE,EAAE,MAAM,EAAE,CAAC;IAAC,EAAE,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAGzM;AAwDD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,QAAQ,CAKvD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,aAAa,CAKtE;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAInE,CAAC"}
@@ -0,0 +1,287 @@
1
+ "use strict";
2
+ /**
3
+ * litedbmodel v2 SCP — the op-INDEPENDENT leaf transport IMPLEMENTATION (the TS runtime side).
4
+ *
5
+ * The three leaves are DECLARED once in {@link import('./leaf-transport').Db} (`@leaf static`, read by
6
+ * `bc generate --from`). THIS module carries their executable bodies and hands them to a generated
7
+ * module as a behavior-contracts handler map — the boundary injection a `bind(handlers)` /
8
+ * `bindAsync(handlers)` facade expects. Declaration and implementation are separate modules on
9
+ * purpose: a `--from` typecheck of an authored model must pull in the signature only, never the
10
+ * driver stack.
11
+ *
12
+ * - {@link executeSQL} — the SOLE SQL transport. Binds params and runs one statement through the
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
18
+ * rows ({@link import('./limit-config').assertRelationHardLimit}): the RAW child rows exist only
19
+ * here, since `group` already sees a nested graph and SCP itself has no throw.
20
+ * - {@link pluck} — rows + the ordered key-column tuple → the deduped, non-null key array (the
21
+ * `= ANY($1)` / `json_each(?)` batch key set).
22
+ * - {@link group} — parents + a flat child list + `pk`/`fk`/`into` → each parent with its matching
23
+ * children nested under `into` (`hasMany` → list, single → the one child or null). This is the
24
+ * in-memory grouping that makes the child fetch ONE query (N+1-free).
25
+ *
26
+ * The environment (connection seam + dialect) is captured by the handler FACTORY, never carried on
27
+ * the IR (C4): {@link leafHandlers} closes over a sync {@link LeafContext} and {@link
28
+ * leafHandlersAsync} over an {@link AsyncLeafContext}. The same three symbols are what the native
29
+ * codegen calls directly ({@link LEAF_TRANSPORT_SYMBOLS}).
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.LEAF_TRANSPORT_SYMBOLS = void 0;
33
+ exports.spliceWhere = spliceWhere;
34
+ exports.assembleDynamicWhere = assembleDynamicWhere;
35
+ exports.prepareSql = prepareSql;
36
+ exports.executeSQL = executeSQL;
37
+ exports.executeSQLAsync = executeSQLAsync;
38
+ exports.pluck = pluck;
39
+ exports.group = group;
40
+ exports.leafHandlers = leafHandlers;
41
+ exports.leafHandlersAsync = leafHandlersAsync;
42
+ const exec_context_1 = require("./exec-context");
43
+ const limit_config_1 = require("./limit-config");
44
+ const handler_1 = require("./makesql/handler");
45
+ const json_array_1 = require("./makesql/json-array");
46
+ const compile_relation_1 = require("./makesql/compile-relation");
47
+ const grouping_1 = require("./grouping");
48
+ // ── 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
+ /**
62
+ * Assemble the effective statement from a DYNAMIC WHERE plan: drop the absent (`null`) fragments,
63
+ * join the survivors with ` WHERE ` / ` AND `, splice the clause into the base `sql` before its first
64
+ * tail keyword ({@link spliceWhere}) — the exact position a bounded WHERE occupies — and bind the
65
+ * surviving fragments' params BEFORE the base params (the WHERE `?`s precede the tail's).
66
+ *
67
+ * A SKIP predicate's presence is per-CALL, so the FINAL statement can only be determined here, at
68
+ * execution time — which is also why `?`→`$N` is rendered after this ({@link prepareSql}), never at
69
+ * emit time. A statement with NO optional predicate carries no plan at all: its WHERE is spliced into
70
+ * the static `sql` at emit time and it never reaches this function.
71
+ */
72
+ function assembleDynamicWhere(p) {
73
+ const frags = (p.whereDynamic.frags ?? []).filter((f) => f != null);
74
+ let whereSql = '';
75
+ const whereParams = [];
76
+ frags.forEach((f, i) => {
77
+ whereSql += (i === 0 ? ' WHERE ' : ' AND ') + f.sql;
78
+ whereParams.push(...f.params);
79
+ });
80
+ return { sql: spliceWhere(p.sql, whereSql), params: [...whereParams, ...p.params] };
81
+ }
82
+ /**
83
+ * The effective `{sql, params}` a statement executes: the dynamic plan assembled when one is present,
84
+ * the ports verbatim otherwise. The ONE place the two shapes converge — both transports consume it.
85
+ */
86
+ function effectiveStatement(p) {
87
+ if (p.whereDynamic == null)
88
+ return p;
89
+ return { ...assembleDynamicWhere({ sql: p.sql, params: p.params, whereDynamic: p.whereDynamic }), write: p.write };
90
+ }
91
+ /** Normalize a driver integer (number|bigint) to bc's `int` value model (BigInt). */
92
+ function toBcInt(v) {
93
+ return typeof v === 'bigint' ? v : BigInt(v);
94
+ }
95
+ // ── executeSQL — the sole op-independent SQL transport ─────────────────────────
96
+ /**
97
+ * Encode a value list for the driver: a bound scalar passes through; an ARRAY element (a key set or a
98
+ * batch record list bound as ONE param — `= ANY(?)` / `json_each(?)` / `JSON_TABLE(?)`) binds as the
99
+ * raw array on PostgreSQL and as a single JSON string on MySQL/SQLite (the `makesql` locked model).
100
+ *
101
+ * A TUPLE SET (an array whose elements are themselves arrays — the composite relation key set the
102
+ * `pluck` leaf yields) binds as the single JSON array-of-tuples string on EVERY dialect, PostgreSQL
103
+ * included: each dialect's composite batch expands that ONE param server-side
104
+ * (`json_array_elements` / `JSON_TABLE` / `json_each`), which is what lets a composite relation ride
105
+ * the same three-leaf transport as everything else instead of needing a per-column transpose (#159).
106
+ *
107
+ * The JSON encoding is the SHARED one ({@link encodeJsonArrayParam}) — the same encoder the imperative
108
+ * `inListJson` path uses, so the generated and imperative paths cannot drift on bigint / boolean
109
+ * element handling.
110
+ */
111
+ function encodeParams(params, dialect) {
112
+ return params.map((p) => {
113
+ if (!Array.isArray(p))
114
+ return p;
115
+ if (dialect === 'postgres' && !isTupleSet(p))
116
+ return p;
117
+ return (0, json_array_1.encodeJsonArrayParam)(dialect, p);
118
+ });
119
+ }
120
+ /**
121
+ * A composite key set: a bound array whose elements are the key TUPLES (arrays). Total under the
122
+ * library's type system — every OTHER array param is a list of SCALAR cells (a single-key set, an
123
+ * IN-list, a batch write's per-column array), because every non-scalar column class (json / uuid /
124
+ * decimal) de-boxes to a bc STRING ({@link import('./coltype').keyArrayElemScalar}), never a JS array.
125
+ */
126
+ function isTupleSet(param) {
127
+ return param.length > 0 && Array.isArray(param[0]);
128
+ }
129
+ /** Prepare a statement for the seam: resolve deferred PG cast(s), render `?`→`$N`, encode params. */
130
+ function prepareSql(p, dialect) {
131
+ let sql = p.sql;
132
+ if (dialect === 'postgres') {
133
+ for (const param of p.params)
134
+ if (Array.isArray(param))
135
+ sql = (0, compile_relation_1.resolvePgArrayCast)(sql, param);
136
+ }
137
+ sql = (0, handler_1.renderPlaceholders)(sql, dialect);
138
+ const bound = encodeParams(p.params, dialect);
139
+ const intent = { write: p.write === true };
140
+ return { sql, bound, intent };
141
+ }
142
+ /**
143
+ * The affected-write summary row a non-returning write yields (uniform `items` output shape).
144
+ *
145
+ * BOTH fields are integers, so both are normalized to bc's `int` value model (BigInt) — the shape a
146
+ * declared `{changes: Int, lastInsertRowid: Int}` contract conforms against, and the shape the rust /
147
+ * go / python / php transports return. Leaving `changes` a JS number made the SAME generated IR
148
+ * conform in one language and fail `expected int, got float` in another.
149
+ */
150
+ function writeSummary(info) {
151
+ return [{ changes: toBcInt(info.changes), lastInsertRowid: toBcInt(info.lastInsertRowid) }];
152
+ }
153
+ /**
154
+ * The SYNC `executeSQL` body. `write` selects `run` (INSERT/UPDATE/DELETE) vs `execute` (SELECT /
155
+ * RETURNING); a non-returning write returns the one-row `[{changes,lastInsertRowid}]` summary so the
156
+ * leaf output shape is uniform.
157
+ *
158
+ * A read ALWAYS runs in exact-integer mode (better-sqlite3 `safeIntegers`), so an INTEGER column
159
+ * arrives as a `BigInt` — the value bc's `int` scalar declares. It is not conditional: the wire carries
160
+ * int and float as DISTINCT kinds, so a column declared `Int` cannot be satisfied by a JS number on any
161
+ * dialect, and gating exactness per endpoint made SQLite disagree with PostgreSQL and MySQL (whose
162
+ * integer type parsers are unconditional — `configurePgDeboxTypeParsers`, `mysqlDeboxPoolOptions`),
163
+ * which the conformance corpus rejects as dialect-variant. `bigint` is retained as a port because the
164
+ * generated modules declare it, but it no longer selects the seam.
165
+ */
166
+ function executeSQL(p, ctx) {
167
+ const prepared = prepareSql(effectiveStatement(p), ctx.dialect);
168
+ if (p.write === true && p.returning !== true)
169
+ return writeSummary((0, exec_context_1.run)(ctx.exec, prepared.sql, prepared.bound, prepared.intent));
170
+ const rows = (0, exec_context_1.executeSafe)(ctx.exec, prepared.sql, prepared.bound, prepared.intent);
171
+ (0, limit_config_1.assertRelationHardLimit)(rows, p.guard);
172
+ return rows;
173
+ }
174
+ /** The ASYNC (live PG / MySQL) `executeSQL` body — the twin of {@link executeSQL} over the async seam. */
175
+ async function executeSQLAsync(p, ctx) {
176
+ const prepared = prepareSql(effectiveStatement(p), ctx.dialect);
177
+ if (p.write === true && p.returning !== true)
178
+ return writeSummary(await (0, exec_context_1.runAsync)(ctx.execAsync, prepared.sql, prepared.bound, prepared.intent));
179
+ const rows = (await (0, exec_context_1.executeAsync)(ctx.execAsync, prepared.sql, prepared.bound, prepared.intent));
180
+ (0, limit_config_1.assertRelationHardLimit)(rows, p.guard);
181
+ return rows;
182
+ }
183
+ // ── pluck — rows + key columns → the deduped key array (the `= ANY($1)` batch key set) ──
184
+ /**
185
+ * Extract the deduped, non-null key set from `rows` over the ordered key-column tuple `col` — the
186
+ * batch key set a relation child fetch binds. Insertion order preserved; a row missing any key column
187
+ * is dropped (no partial keys). A single-key tuple yields a flat scalar array (`json_each` scalar
188
+ * `value`); a composite tuple yields an array-of-tuples (`json_each` per-ordinal `$[i]`). Dedupe is
189
+ * the shared grouping core ({@link dedupeKeyTuples}) — the SAME SSoT the lazy-relation path uses.
190
+ */
191
+ function pluck(p) {
192
+ const tuples = (0, grouping_1.dedupeKeyTuples)(p.rows, p.col);
193
+ return p.col.length === 1 ? tuples.map((t) => t[0]) : tuples.map((t) => [...t]);
194
+ }
195
+ // ── group — parents + flat children → each parent with its children nested ─────
196
+ /**
197
+ * Distribute a flat `children` list onto `parents` by matching `child[fk]` to `parent[pk]`, nesting
198
+ * the result under `into`. `single:true` (belongsTo/hasOne) nests the one matching child (or `null`);
199
+ * otherwise (hasMany) nests the child list (`[]` when none). `pk`/`fk` are the ordered key-column
200
+ * tuples, so a composite relation nests by the WHOLE key (no `''`-collapse cartesian). Grouping is the
201
+ * shared core ({@link groupByKey}/{@link attachToParent}) — the SAME SSoT the lazy-relation path uses.
202
+ */
203
+ function group(p) {
204
+ const byKey = (0, grouping_1.groupByKey)(p.children, p.fk);
205
+ return p.parents.map((par) => ({ ...par, [p.into]: (0, grouping_1.attachToParent)(par, p.pk, byKey, p.single === true) }));
206
+ }
207
+ // ── handler maps: the boundary injection a generated module's bind()/bindAsync() consumes ──
208
+ /**
209
+ * Read the OPTIONAL relation `guard` port. Absent (or null) ⇒ the statement is uncapped. The cap
210
+ * arrives in bc's `int` value model, which on the TS plane is a BigInt, so it is normalized to the
211
+ * `number` {@link RelationGuard} (and {@link import('./errors').LimitExceededError}) declare — the
212
+ * SAME numeric type the rust/go/python/php transports hand their own check. A guard that is present
213
+ * but not a `{limit, relation}` record is a LOUD port failure, never a silently dropped cap: a guard
214
+ * that fails to unbox is a runaway that would otherwise sail through.
215
+ */
216
+ function relationGuardPort(port) {
217
+ if (port === undefined || port === null)
218
+ return null;
219
+ const g = port;
220
+ const limit = typeof g.limit === 'bigint' ? Number(g.limit) : g.limit;
221
+ if (typeof limit !== 'number' || !Number.isInteger(limit) || typeof g.relation !== 'string') {
222
+ throw new Error(`scp leaf executeSQL: the 'guard' port must be a {limit:int, model?:string, relation:string} ` +
223
+ `relation cap, got ${JSON.stringify(port)}`);
224
+ }
225
+ return { limit, ...(typeof g.model === 'string' ? { model: g.model } : {}), relation: g.relation };
226
+ }
227
+ /** Read the declared `executeSQL` ports off the evaluated port record (the generated module's Values). */
228
+ function executeSqlPorts(ports) {
229
+ return {
230
+ sql: ports.sql,
231
+ params: ports.params,
232
+ write: ports.write === true,
233
+ returning: ports.returning === true,
234
+ bigint: ports.bigint === true,
235
+ whereDynamic: (ports.whereDynamic ?? null),
236
+ guard: relationGuardPort(ports.guard),
237
+ };
238
+ }
239
+ /**
240
+ * The two ENVIRONMENT-FREE relation handlers. `pluck`/`group` are pure in-memory shaping, so the sync
241
+ * and async maps share this ONE definition (never a second copy per environment).
242
+ */
243
+ const shapingHandlers = {
244
+ pluck: (ports) => ({ ok: pluck({ rows: ports.rows, col: ports.col }) }),
245
+ group: (ports) => ({
246
+ ok: group({
247
+ parents: ports.parents,
248
+ children: ports.children,
249
+ pk: ports.pk,
250
+ fk: ports.fk,
251
+ into: ports.into,
252
+ single: ports.single === true,
253
+ }),
254
+ }),
255
+ };
256
+ /**
257
+ * The SYNC handler map for a generated module's `bind(handlers)` — catalog name → the transport body,
258
+ * closed over the sync environment. This is the ONLY place the three leaves are wired to the TS
259
+ * runtime; a generated module never carries an implementation.
260
+ */
261
+ function leafHandlers(ctx) {
262
+ return {
263
+ ...shapingHandlers,
264
+ executeSQL: (ports) => ({ ok: executeSQL(executeSqlPorts(ports), ctx) }),
265
+ };
266
+ }
267
+ /**
268
+ * The ASYNC handler map for a generated module's `bindAsync(handlers)` (live PG / MySQL). Only the SQL
269
+ * transport differs — the shaping leaves are the SAME implementations.
270
+ */
271
+ function leafHandlersAsync(ctx) {
272
+ return {
273
+ ...shapingHandlers,
274
+ executeSQL: async (ports) => ({ ok: (await executeSQLAsync(executeSqlPorts(ports), ctx)) }),
275
+ };
276
+ }
277
+ /**
278
+ * The native-codegen transport symbol table (`bc generate --leaf-transport`): each op-independent leaf
279
+ * → the runtime symbol the covered native module calls directly. The consumer supplies these
280
+ * (litedbmodel = a fixed set of ops, not one method per node).
281
+ */
282
+ exports.LEAF_TRANSPORT_SYMBOLS = {
283
+ executeSQL: 'execute_sql',
284
+ pluck: 'pluck_keys',
285
+ group: 'group_children',
286
+ };
287
+ //# sourceMappingURL=leaves.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leaves.js","sourceRoot":"","sources":["../../src/scp/leaves.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAmEH,kCAIC;AA4BD,oDASC;AAoDD,gCASC;AA2BD,gCAMC;AAGD,0CAMC;AAWD,sBAGC;AAWD,sBAGC;AA6DD,oCAKC;AAMD,8CAKC;AAzTD,iDASwB;AACxB,iDAA6E;AAC7E,+CAAqE;AACrE,qDAA4D;AAC5D,iEAAgE;AAChE,yCAAyE;AAyCzE,kGAAkG;AAElG;;;GAGG;AACH,MAAM,aAAa,GAAG,6DAA6D,CAAC;AAEpF,iHAAiH;AACjH,SAAgB,WAAW,CAAC,OAAe,EAAE,QAAgB;IAC3D,IAAI,QAAQ,KAAK,EAAE;QAAE,OAAO,OAAO,CAAC;IACpC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClH,CAAC;AAiBD;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAAC,CAAqE;IACxG,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAyB,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;IAC3F,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,MAAM,WAAW,GAAc,EAAE,CAAC;IAClC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EA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