litedbmodel 2.0.2 → 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 (193) 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 +127 -24
  15. package/dist/decorators.js.map +1 -1
  16. package/dist/drivers/mysql.d.ts.map +1 -1
  17. package/dist/drivers/mysql.js +12 -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 +13 -2
  21. package/dist/drivers/postgres.js.map +1 -1
  22. package/dist/drivers/sqlite.d.ts +2 -0
  23. package/dist/drivers/sqlite.d.ts.map +1 -1
  24. package/dist/drivers/sqlite.js +49 -4
  25. package/dist/drivers/sqlite.js.map +1 -1
  26. package/dist/index.cjs +10741 -0
  27. package/dist/index.d.cts +1 -0
  28. package/dist/scp/coltype.d.ts +108 -0
  29. package/dist/scp/coltype.d.ts.map +1 -1
  30. package/dist/scp/coltype.js +293 -6
  31. package/dist/scp/coltype.js.map +1 -1
  32. package/dist/scp/connection-routing.d.ts +312 -0
  33. package/dist/scp/connection-routing.d.ts.map +1 -0
  34. package/dist/scp/connection-routing.js +394 -0
  35. package/dist/scp/connection-routing.js.map +1 -0
  36. package/dist/scp/dbmodel-runtime.d.ts +101 -0
  37. package/dist/scp/dbmodel-runtime.d.ts.map +1 -0
  38. package/dist/scp/dbmodel-runtime.js +174 -0
  39. package/dist/scp/dbmodel-runtime.js.map +1 -0
  40. package/dist/scp/decorator-adapter.d.ts +196 -0
  41. package/dist/scp/decorator-adapter.d.ts.map +1 -0
  42. package/dist/scp/decorator-adapter.js +286 -0
  43. package/dist/scp/decorator-adapter.js.map +1 -0
  44. package/dist/scp/emit/emitter.d.ts +108 -0
  45. package/dist/scp/emit/emitter.d.ts.map +1 -0
  46. package/dist/scp/emit/emitter.js +782 -0
  47. package/dist/scp/emit/emitter.js.map +1 -0
  48. package/dist/scp/emit/endpoint.d.ts +248 -0
  49. package/dist/scp/emit/endpoint.d.ts.map +1 -0
  50. package/dist/scp/emit/endpoint.js +20 -0
  51. package/dist/scp/emit/endpoint.js.map +1 -0
  52. package/dist/scp/emit/index.d.ts +11 -0
  53. package/dist/scp/emit/index.d.ts.map +1 -0
  54. package/dist/scp/emit/index.js +13 -0
  55. package/dist/scp/emit/index.js.map +1 -0
  56. package/dist/scp/errors.d.ts +45 -1
  57. package/dist/scp/errors.d.ts.map +1 -1
  58. package/dist/scp/errors.js +47 -1
  59. package/dist/scp/errors.js.map +1 -1
  60. package/dist/scp/exec-context.d.ts +390 -0
  61. package/dist/scp/exec-context.d.ts.map +1 -0
  62. package/dist/scp/exec-context.js +540 -0
  63. package/dist/scp/exec-context.js.map +1 -0
  64. package/dist/scp/grouping.d.ts +32 -0
  65. package/dist/scp/grouping.d.ts.map +1 -0
  66. package/dist/scp/grouping.js +0 -0
  67. package/dist/scp/grouping.js.map +1 -0
  68. package/dist/scp/index.cjs +6432 -17579
  69. package/dist/scp/index.d.cts +1 -0
  70. package/dist/scp/index.d.mts +1 -0
  71. package/dist/scp/index.d.ts +51 -52
  72. package/dist/scp/index.d.ts.map +1 -1
  73. package/dist/scp/index.js +189 -152
  74. package/dist/scp/index.js.map +1 -1
  75. package/dist/scp/index.mjs +6067 -3659
  76. package/dist/scp/leaf-transport.d.ts +50 -0
  77. package/dist/scp/leaf-transport.d.ts.map +1 -0
  78. package/dist/scp/leaf-transport.js +92 -0
  79. package/dist/scp/leaf-transport.js.map +1 -0
  80. package/dist/scp/leaves.d.ts +174 -0
  81. package/dist/scp/leaves.d.ts.map +1 -0
  82. package/dist/scp/leaves.js +287 -0
  83. package/dist/scp/leaves.js.map +1 -0
  84. package/dist/scp/limit-config.d.ts +118 -0
  85. package/dist/scp/limit-config.d.ts.map +1 -0
  86. package/dist/scp/limit-config.js +126 -0
  87. package/dist/scp/limit-config.js.map +1 -0
  88. package/dist/scp/makesql/compile-relation.d.ts +49 -23
  89. package/dist/scp/makesql/compile-relation.d.ts.map +1 -1
  90. package/dist/scp/makesql/compile-relation.js +101 -76
  91. package/dist/scp/makesql/compile-relation.js.map +1 -1
  92. package/dist/scp/makesql/compile-select.d.ts +45 -10
  93. package/dist/scp/makesql/compile-select.d.ts.map +1 -1
  94. package/dist/scp/makesql/compile-select.js +50 -10
  95. package/dist/scp/makesql/compile-select.js.map +1 -1
  96. package/dist/scp/makesql/handler.d.ts +1 -1
  97. package/dist/scp/makesql/handler.d.ts.map +1 -1
  98. package/dist/scp/makesql/index.d.ts +7 -10
  99. package/dist/scp/makesql/index.d.ts.map +1 -1
  100. package/dist/scp/makesql/index.js +19 -30
  101. package/dist/scp/makesql/index.js.map +1 -1
  102. package/dist/scp/makesql/json-array.d.ts +65 -0
  103. package/dist/scp/makesql/json-array.d.ts.map +1 -1
  104. package/dist/scp/makesql/json-array.js +99 -10
  105. package/dist/scp/makesql/json-array.js.map +1 -1
  106. package/dist/scp/makesql/json-batch.d.ts.map +1 -1
  107. package/dist/scp/makesql/json-batch.js +21 -19
  108. package/dist/scp/makesql/json-batch.js.map +1 -1
  109. package/dist/scp/makesql/makesql.d.ts +1 -1
  110. package/dist/scp/makesql/makesql.d.ts.map +1 -1
  111. package/dist/scp/makesql/mysql-returning.d.ts +93 -0
  112. package/dist/scp/makesql/mysql-returning.d.ts.map +1 -0
  113. package/dist/scp/makesql/mysql-returning.js +215 -0
  114. package/dist/scp/makesql/mysql-returning.js.map +1 -0
  115. package/dist/scp/makesql/outtype.d.ts +75 -34
  116. package/dist/scp/makesql/outtype.d.ts.map +1 -1
  117. package/dist/scp/makesql/outtype.js +91 -118
  118. package/dist/scp/makesql/outtype.js.map +1 -1
  119. package/dist/scp/makesql/pool-executor.d.ts +135 -13
  120. package/dist/scp/makesql/pool-executor.d.ts.map +1 -1
  121. package/dist/scp/makesql/pool-executor.js +229 -21
  122. package/dist/scp/makesql/pool-executor.js.map +1 -1
  123. package/dist/scp/makesql/tx.d.ts +107 -22
  124. package/dist/scp/makesql/tx.d.ts.map +1 -1
  125. package/dist/scp/makesql/tx.js +451 -97
  126. package/dist/scp/makesql/tx.js.map +1 -1
  127. package/dist/scp/makesql/writeouttype.d.ts +7 -8
  128. package/dist/scp/makesql/writeouttype.d.ts.map +1 -1
  129. package/dist/scp/makesql/writeouttype.js +8 -7
  130. package/dist/scp/makesql/writeouttype.js.map +1 -1
  131. package/dist/scp/middleware.d.ts +287 -0
  132. package/dist/scp/middleware.d.ts.map +1 -0
  133. package/dist/scp/middleware.js +358 -0
  134. package/dist/scp/middleware.js.map +1 -0
  135. package/dist/scp/relation.d.ts +80 -9
  136. package/dist/scp/relation.d.ts.map +1 -1
  137. package/dist/scp/relation.js +198 -78
  138. package/dist/scp/relation.js.map +1 -1
  139. package/dist/scp/tx-options.d.ts +136 -0
  140. package/dist/scp/tx-options.d.ts.map +1 -0
  141. package/dist/scp/tx-options.js +184 -0
  142. package/dist/scp/tx-options.js.map +1 -0
  143. package/dist/scp/write-bundle.d.ts +131 -0
  144. package/dist/scp/write-bundle.d.ts.map +1 -0
  145. package/dist/scp/write-bundle.js +160 -0
  146. package/dist/scp/write-bundle.js.map +1 -0
  147. package/dist/types.d.ts +7 -0
  148. package/dist/types.d.ts.map +1 -1
  149. package/dist/types.js.map +1 -1
  150. package/docs/BENCHMARK.md +58 -56
  151. package/docs/benchmark-chart.svg +166 -166
  152. package/docs/design/phase-a-execution-context.md +139 -0
  153. package/package.json +16 -9
  154. package/dist/scp/authoring-sql.d.ts +0 -134
  155. package/dist/scp/authoring-sql.d.ts.map +0 -1
  156. package/dist/scp/authoring-sql.js +0 -191
  157. package/dist/scp/authoring-sql.js.map +0 -1
  158. package/dist/scp/authoring.d.ts +0 -155
  159. package/dist/scp/authoring.d.ts.map +0 -1
  160. package/dist/scp/authoring.js +0 -162
  161. package/dist/scp/authoring.js.map +0 -1
  162. package/dist/scp/catalog.d.ts +0 -94
  163. package/dist/scp/catalog.d.ts.map +0 -1
  164. package/dist/scp/catalog.js +0 -234
  165. package/dist/scp/catalog.js.map +0 -1
  166. package/dist/scp/codegen.d.ts +0 -189
  167. package/dist/scp/codegen.d.ts.map +0 -1
  168. package/dist/scp/codegen.js +0 -421
  169. package/dist/scp/codegen.js.map +0 -1
  170. package/dist/scp/find-filter-guard.d.ts +0 -68
  171. package/dist/scp/find-filter-guard.d.ts.map +0 -1
  172. package/dist/scp/find-filter-guard.js +0 -88
  173. package/dist/scp/find-filter-guard.js.map +0 -1
  174. package/dist/scp/guard.d.ts +0 -43
  175. package/dist/scp/guard.d.ts.map +0 -1
  176. package/dist/scp/guard.js +0 -134
  177. package/dist/scp/guard.js.map +0 -1
  178. package/dist/scp/makesql/authoring-compile.d.ts +0 -90
  179. package/dist/scp/makesql/authoring-compile.d.ts.map +0 -1
  180. package/dist/scp/makesql/authoring-compile.js +0 -494
  181. package/dist/scp/makesql/authoring-compile.js.map +0 -1
  182. package/dist/scp/makesql/ir.d.ts +0 -42
  183. package/dist/scp/makesql/ir.d.ts.map +0 -1
  184. package/dist/scp/makesql/ir.js +0 -66
  185. package/dist/scp/makesql/ir.js.map +0 -1
  186. package/dist/scp/makesql/static-bundle.d.ts +0 -187
  187. package/dist/scp/makesql/static-bundle.d.ts.map +0 -1
  188. package/dist/scp/makesql/static-bundle.js +0 -1113
  189. package/dist/scp/makesql/static-bundle.js.map +0 -1
  190. package/dist/scp/runtime.d.ts +0 -242
  191. package/dist/scp/runtime.d.ts.map +0 -1
  192. package/dist/scp/runtime.js +0 -400
  193. package/dist/scp/runtime.js.map +0 -1
@@ -1,43 +0,0 @@
1
- /**
2
- * litedbmodel v2 SCP — param/fragment portability guard (WS1, #21).
3
- *
4
- * Fail-closed enforcement of the hard rule: every Expression IR node this backend emits
5
- * (param slots, fragment `when` guards) uses ONLY bc's closed operator set
6
- * (`PORTABLE_EXPR_OPERATORS`). A single-key object whose key is not a known operator is
7
- * an un-lowerable construct — it must go through the Raw SQL escape hatch (spec §13), NOT
8
- * a fake opcode. This wraps bc's `assertPortable` (no functions/Date/Promise residue)
9
- * plus the operator-set check.
10
- */
11
- import { type Component, type ComponentGraphIR } from 'behavior-contracts';
12
- /** A bc Expression IR node (closed operator set). Structural alias — a JSON expression tree. */
13
- export type ExprNode = unknown;
14
- /**
15
- * Assert one Expression IR node is portable: no residue (functions/Date/…) and every
16
- * operator-node key is in bc's closed set. Literals (number/string/bool/null) and arrays
17
- * pass structurally.
18
- *
19
- * A single-key object is an OPERATOR node only when its key is a known operator
20
- * (∈ {@link PORTABLE_EXPR_OPERATORS}); its value is then recursed as operator args. A
21
- * single-key object whose key is NOT a known operator is a real portability violation and
22
- * is rejected fail-closed (an un-lowerable pseudo-opcode → must use the Raw SQL escape
23
- * hatch, spec §13). This mirrors bc's `assertPortableComponentGraph` operator-position
24
- * semantics exactly — see {@link walkExpr} for the `obj` field-map special case.
25
- */
26
- export declare function assertExprPortable(node: ExprNode, path?: string): void;
27
- /**
28
- * Assert every Expression IR node in ONE lowered component's port wiring is portable
29
- * (WS2 AC). Walks every `componentRef`/`map` node's `ports` (and `map.over` / `map.when`)
30
- * and every `cond` node's `if`/`then`/`else`, applying {@link assertExprPortable} — so any
31
- * operator outside bc's closed set is rejected fail-closed at compile time. This is the
32
- * litedbmodel-owned portability layer the authoring lower path auto-applies, over and
33
- * above bc's own `assertPortableComponentGraph` self-check.
34
- */
35
- export declare function assertComponentPortable(component: Component): void;
36
- /**
37
- * Assert every component of a lowered Component-graph IR is portable (WS2 AC). The
38
- * authoring lower path ({@link publishBehaviors} / {@link compileEager}) invokes this
39
- * automatically so a non-portable opcode anywhere in the emitted IR is a fail-closed
40
- * compile error. Throws {@link PortabilityError} on the first violation.
41
- */
42
- export declare function assertComponentGraphPortable(ir: ComponentGraphIR): void;
43
- //# sourceMappingURL=guard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/scp/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAmF,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE5J,gGAAgG;AAChG,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC;AAE/B;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,SAAM,GAAG,IAAI,CAGnE;AAgDD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAgBlE;AAoBD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,gBAAgB,GAAG,IAAI,CAEvE"}
package/dist/scp/guard.js DELETED
@@ -1,134 +0,0 @@
1
- "use strict";
2
- /**
3
- * litedbmodel v2 SCP — param/fragment portability guard (WS1, #21).
4
- *
5
- * Fail-closed enforcement of the hard rule: every Expression IR node this backend emits
6
- * (param slots, fragment `when` guards) uses ONLY bc's closed operator set
7
- * (`PORTABLE_EXPR_OPERATORS`). A single-key object whose key is not a known operator is
8
- * an un-lowerable construct — it must go through the Raw SQL escape hatch (spec §13), NOT
9
- * a fake opcode. This wraps bc's `assertPortable` (no functions/Date/Promise residue)
10
- * plus the operator-set check.
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.assertExprPortable = assertExprPortable;
14
- exports.assertComponentPortable = assertComponentPortable;
15
- exports.assertComponentGraphPortable = assertComponentGraphPortable;
16
- const behavior_contracts_1 = require("behavior-contracts");
17
- /**
18
- * Assert one Expression IR node is portable: no residue (functions/Date/…) and every
19
- * operator-node key is in bc's closed set. Literals (number/string/bool/null) and arrays
20
- * pass structurally.
21
- *
22
- * A single-key object is an OPERATOR node only when its key is a known operator
23
- * (∈ {@link PORTABLE_EXPR_OPERATORS}); its value is then recursed as operator args. A
24
- * single-key object whose key is NOT a known operator is a real portability violation and
25
- * is rejected fail-closed (an un-lowerable pseudo-opcode → must use the Raw SQL escape
26
- * hatch, spec §13). This mirrors bc's `assertPortableComponentGraph` operator-position
27
- * semantics exactly — see {@link walkExpr} for the `obj` field-map special case.
28
- */
29
- function assertExprPortable(node, path = '$') {
30
- (0, behavior_contracts_1.assertPortable)(node, path);
31
- walkExpr(node, path);
32
- }
33
- function walkExpr(node, path) {
34
- if (node === null || typeof node !== 'object')
35
- return;
36
- if (Array.isArray(node)) {
37
- node.forEach((el, i) => walkExpr(el, `${path}[${i}]`));
38
- return;
39
- }
40
- const keys = Object.keys(node);
41
- if (keys.length === 1) {
42
- // Single-key object = OPERATOR-position node. The key must be a known opcode
43
- // (fail-closed on unknown opcodes — a real portability violation).
44
- const op = keys[0];
45
- if (!behavior_contracts_1.PORTABLE_EXPR_OPERATORS.has(op)) {
46
- throw new behavior_contracts_1.PortabilityError(path, `Portability Guard: '${op}' is not a portable Expression IR operator (closed set: ${[...behavior_contracts_1.PORTABLE_EXPR_OPERATORS].join(', ')})`);
47
- }
48
- const arg = node[op];
49
- // `obj` is the construction node: its arg is a FIELD MAP whose KEYS are data field
50
- // names (NOT opcodes) and whose VALUES are ExprNodes. Recurse into the values ONLY —
51
- // never apply the operator heuristic to the field map itself (aligns with bc's
52
- // assertPortableExpr / evaluate() so a single-field {obj:{one:…}} is not misread as an
53
- // unknown opcode). See behavior-contracts guard.ts `op === "obj"` branch.
54
- if (op === 'obj') {
55
- if (arg === null || typeof arg !== 'object' || Array.isArray(arg)) {
56
- throw new behavior_contracts_1.PortabilityError(`${path}.obj`, `Portability Guard: {obj: ...} expects an object (at ${path}.obj)`);
57
- }
58
- for (const [k, v] of Object.entries(arg)) {
59
- // Static fail-closed (defense-in-depth): own key "__proto__" is rejected here as it
60
- // is by bc's guard/evaluator (prototype pollution / cross-language divergence).
61
- if (k === behavior_contracts_1.FORBIDDEN_OBJECT_KEY) {
62
- throw new behavior_contracts_1.PortabilityError(`${path}.obj`, `Portability Guard: object key "${behavior_contracts_1.FORBIDDEN_OBJECT_KEY}" is forbidden (fail-closed) at ${path}.obj`);
63
- }
64
- walkExpr(v, `${path}.obj.${k}`);
65
- }
66
- return;
67
- }
68
- // Any other operator: recurse its arg (array of args or a nested expr node).
69
- walkExpr(arg, `${path}.${op}`);
70
- return;
71
- }
72
- // Multi-key objects are not operator nodes (operator nodes are single-key). Recurse each
73
- // value structurally so nested operator nodes are still checked (assertPortable above has
74
- // already rejected any function/Date/Promise residue across the whole subtree).
75
- for (const k of keys)
76
- walkExpr(node[k], `${path}.${k}`);
77
- }
78
- // ── Authoring→IR lower guard (WS2, #22 — auto-applied on the single compile path) ─────
79
- /**
80
- * Assert every Expression IR node in ONE lowered component's port wiring is portable
81
- * (WS2 AC). Walks every `componentRef`/`map` node's `ports` (and `map.over` / `map.when`)
82
- * and every `cond` node's `if`/`then`/`else`, applying {@link assertExprPortable} — so any
83
- * operator outside bc's closed set is rejected fail-closed at compile time. This is the
84
- * litedbmodel-owned portability layer the authoring lower path auto-applies, over and
85
- * above bc's own `assertPortableComponentGraph` self-check.
86
- */
87
- function assertComponentPortable(component) {
88
- const at = `component '${component.name}'`;
89
- for (const n of component.body) {
90
- if ('map' in n) {
91
- assertExprPortable(n.map.over, `${at}/${n.id}.map.over`);
92
- assertPortsPortable(n.map.ports, `${at}/${n.id}.map.ports`);
93
- if (n.map.when !== undefined)
94
- assertExprPortable(n.map.when, `${at}/${n.id}.map.when`);
95
- }
96
- else if ('cond' in n) {
97
- assertExprPortable(n.cond.if, `${at}/${n.id}.cond.if`);
98
- assertExprPortable(n.cond.then, `${at}/${n.id}.cond.then`);
99
- assertExprPortable(n.cond.else, `${at}/${n.id}.cond.else`);
100
- }
101
- else {
102
- assertPortsPortable(n.ports, `${at}/${n.id}.ports`);
103
- }
104
- }
105
- assertExprPortable(component.output, `${at}.output`);
106
- }
107
- /**
108
- * A component node's `ports` (and a `map.ports`) is a FIELD MAP — port NAME → ExprNode — not an
109
- * Expression node itself. Walk each port VALUE as an expression, never the ports object as a whole:
110
- * a SINGLE-port node (`{ table: 'posts' }`, e.g. a `Count` with only `table`) would otherwise be
111
- * misread by {@link walkExpr}'s single-key = OPERATOR heuristic as an unknown-opcode `{table:…}`
112
- * node. Recursing the values sidesteps that (same rationale bc's guard applies to `{obj:{…}}`).
113
- */
114
- function assertPortsPortable(ports, path) {
115
- if (ports === null || typeof ports !== 'object' || Array.isArray(ports)) {
116
- // Not a ports map (shouldn't happen for a well-formed node) — defer to the expr walker.
117
- assertExprPortable(ports, path);
118
- return;
119
- }
120
- for (const [name, value] of Object.entries(ports)) {
121
- assertExprPortable(value, `${path}.${name}`);
122
- }
123
- }
124
- /**
125
- * Assert every component of a lowered Component-graph IR is portable (WS2 AC). The
126
- * authoring lower path ({@link publishBehaviors} / {@link compileEager}) invokes this
127
- * automatically so a non-portable opcode anywhere in the emitted IR is a fail-closed
128
- * compile error. Throws {@link PortabilityError} on the first violation.
129
- */
130
- function assertComponentGraphPortable(ir) {
131
- for (const c of ir.components)
132
- assertComponentPortable(c);
133
- }
134
- //# sourceMappingURL=guard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/scp/guard.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAmBH,gDAGC;AAwDD,0DAgBC;AA0BD,oEAEC;AAxHD,2DAA4J;AAK5J;;;;;;;;;;;GAWG;AACH,SAAgB,kBAAkB,CAAC,IAAc,EAAE,IAAI,GAAG,GAAG;IAC3D,IAAA,mCAAc,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3B,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AAM,CAAC,IAAI,EAAE,CAAC,UAAU;QAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC"}
@@ -1,90 +0,0 @@
1
- /**
2
- * litedbmodel v2 SCP — the AUTHORING → `makeSQL` bundle path (Phase A of epic #43/#45).
3
- *
4
- * WS2 (`../authoring.ts`) lowers BOTH the SCP declaration blocks and the eager public
5
- * API through ONE bc compile path (`publishBehaviors` / `compileEager`) into ONE
6
- * portable `ComponentGraphIR` — a Component's body carries `componentRef` / `map` nodes
7
- * whose SQL-structural ports (`table`, `select`, `where`, `values.<field>`, `set.<field>`,
8
- * `order`, `limit`, …) are closed-set bc Expression IR (spec §7). Until now the ONLY
9
- * consumer of that authored IR was the REDUCED spine (`../bridge.ts` → `../compile-sqlite.ts`
10
- * → `CompiledOperation`).
11
- *
12
- * This module is the ADDITIVE makeSQL producer for the SAME authored IR: it reads a
13
- * node's ports STRUCTURALLY (exactly the closed-set decoding `../bridge.ts` performs —
14
- * same operators, same IN-sentinel, same SKIP-`cond` collapse, no invented opcode) and,
15
- * given the concrete Input Port values, routes WHERE / CRUD / relation through
16
- * `./compile*` + `./json-array` / `./json-batch` to emit a **`makeSQL` bundle** (composed
17
- * `makeSQL` components). The value slots are resolved HANDLER-SIDE (spec §11 item 4): a bc
18
- * `makeSQL` catalog leaf whose handler holds the concrete port values from bc's
19
- * `runBehavior` and calls `./compile*` to build the byte-tuned SQL — so the emitted SQL is
20
- * v1-tuned by construction (PG byte-match; MySQL/SQLite single-JSON-param parity).
21
- *
22
- * ## Single compile path (spec §9 — preserved)
23
- *
24
- * Both the eager public-API path (`compileEager`) and the declaration path
25
- * (`publishBehaviors`) produce byte-identical authored component IR (pinned by
26
- * `test/scp/authoring.test.ts`). Because {@link compileAuthoredBehavior} is a pure function
27
- * of that IR + the concrete input, feeding EITHER path's contract through it yields a
28
- * byte-identical `makeSQL` bundle — the single-compile-path invariant carries over to the
29
- * makeSQL target with no second interpreter.
30
- *
31
- * Coverage (Phase A): a read behavior (Select + belongsTo `.map` + hasMany-limit `.map`),
32
- * a write behavior (Insert), and a SKIP-optional condition. The three dialects share this
33
- * routing; PG stays byte-identical to v1, MySQL/SQLite use the single-JSON-param forms.
34
- */
35
- import { type Scope } from 'behavior-contracts';
36
- import type { ComponentRefNode, MapNode } from '../authoring';
37
- import type { BehaviorModelContract } from '../authoring';
38
- import type { MakeSQL } from './makesql';
39
- import { assembleMakeSQL } from './makesql';
40
- import type { Dialect } from './handler';
41
- /** A bc body node that references a catalog component (`componentRef` or `map`). */
42
- type RefLike = ComponentRefNode | MapNode;
43
- /**
44
- * Compile ONE authored catalog `componentRef`/`map` node into a `makeSQL` bundle, given
45
- * the concrete input `scope`. Routes WHERE / CRUD through `./compile*`. The value slots
46
- * are the bc-evaluated concrete values (handler-side), so the emitted SQL text/params
47
- * come STRAIGHT from the v1 builders (`compileSelect` / `compileInsert` / …) —
48
- * byte-parity by construction.
49
- */
50
- export declare function compileAuthoredNode(node: RefLike, scope: Scope, dialect: Dialect): MakeSQL;
51
- /** A relation `.map` compiled against the resolved PARENT rows (the batch key source). */
52
- export interface RelationMapInput {
53
- /** The parent result rows (from executing the parent Select node). */
54
- parentRows: Record<string, unknown>[];
55
- /** Per-parent limit (undefined ⇒ unlimited batch load). */
56
- limit?: number;
57
- }
58
- /**
59
- * Compile a relation `.map` node into a batch-load `makeSQL` bundle. The map's inner
60
- * `where` names the target key column (`eq($p.<k>, …)`); the batch key VALUES are the
61
- * distinct `parentKey` values across `parentRows`. Extra (non-key) where members become
62
- * the relation's merged `conditions` filter.
63
- *
64
- * @param parentKey the parent-row field whose values key the batch (e.g. `author_id`).
65
- */
66
- export declare function compileRelationMap(node: MapNode, input: RelationMapInput, dialect: Dialect, parentKey: string): MakeSQL;
67
- /** The compiled makeSQL artifact of one authored behavior method. */
68
- export interface AuthoredMakeSQL {
69
- /** The behavior (component) name. */
70
- readonly name: string;
71
- /** The PRIMARY read/write query bundle (the root catalog node of the method). */
72
- readonly primary: MakeSQL;
73
- /** The relation `.map` nodes of the method (batch loads), in body order (unresolved). */
74
- readonly relations: MapNode[];
75
- }
76
- /**
77
- * Compile the PRIMARY read/write query of an authored behavior method into a `makeSQL`
78
- * bundle, given the concrete Input Port `scope`. The "primary" node is the method's root
79
- * catalog `componentRef` (the Select the relations map over, or the write). Relation
80
- * `.map` nodes are returned unresolved (their batch keys come from executing `primary`
81
- * first — {@link compileRelationMap}).
82
- *
83
- * This is a PURE function of the authored component IR + the input, so `publishBehaviors`
84
- * (declaration) and `compileEager` (eager) — which produce byte-identical component IR —
85
- * yield a byte-identical `primary` bundle (single-compile-path invariant, spec §9).
86
- */
87
- export declare function compileAuthoredBehavior(contract: BehaviorModelContract, scope: Scope, dialect: Dialect, entry?: string): AuthoredMakeSQL;
88
- /** Assemble + dialect-render a compiled `makeSQL` bundle (thin convenience for callers). */
89
- export { assembleMakeSQL };
90
- //# sourceMappingURL=authoring-compile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authoring-compile.d.ts","sourceRoot":"","sources":["../../../src/scp/makesql/authoring-compile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAsB,KAAK,KAAK,EAAc,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,EAAa,gBAAgB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAO5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzC,oFAAoF;AACpF,KAAK,OAAO,GAAG,gBAAgB,GAAG,OAAO,CAAC;AAyN1C;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,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