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.
- package/README.md +7 -0
- package/dist/DBConditions.d.ts.map +1 -1
- package/dist/DBConditions.js +16 -1
- package/dist/DBConditions.js.map +1 -1
- package/dist/DBHandler.d.ts.map +1 -1
- package/dist/DBHandler.js +6 -0
- package/dist/DBHandler.js.map +1 -1
- package/dist/DBModel.d.ts +84 -2
- package/dist/DBModel.d.ts.map +1 -1
- package/dist/DBModel.js +312 -29
- package/dist/DBModel.js.map +1 -1
- package/dist/decorators.d.ts +52 -0
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +127 -24
- package/dist/decorators.js.map +1 -1
- package/dist/drivers/mysql.d.ts.map +1 -1
- package/dist/drivers/mysql.js +12 -2
- package/dist/drivers/mysql.js.map +1 -1
- package/dist/drivers/postgres.d.ts.map +1 -1
- package/dist/drivers/postgres.js +13 -2
- package/dist/drivers/postgres.js.map +1 -1
- package/dist/drivers/sqlite.d.ts +2 -0
- package/dist/drivers/sqlite.d.ts.map +1 -1
- package/dist/drivers/sqlite.js +49 -4
- package/dist/drivers/sqlite.js.map +1 -1
- package/dist/index.cjs +10741 -0
- package/dist/index.d.cts +1 -0
- package/dist/scp/coltype.d.ts +108 -0
- package/dist/scp/coltype.d.ts.map +1 -1
- package/dist/scp/coltype.js +293 -6
- package/dist/scp/coltype.js.map +1 -1
- package/dist/scp/connection-routing.d.ts +312 -0
- package/dist/scp/connection-routing.d.ts.map +1 -0
- package/dist/scp/connection-routing.js +394 -0
- package/dist/scp/connection-routing.js.map +1 -0
- package/dist/scp/dbmodel-runtime.d.ts +101 -0
- package/dist/scp/dbmodel-runtime.d.ts.map +1 -0
- package/dist/scp/dbmodel-runtime.js +174 -0
- package/dist/scp/dbmodel-runtime.js.map +1 -0
- package/dist/scp/decorator-adapter.d.ts +196 -0
- package/dist/scp/decorator-adapter.d.ts.map +1 -0
- package/dist/scp/decorator-adapter.js +286 -0
- package/dist/scp/decorator-adapter.js.map +1 -0
- package/dist/scp/emit/emitter.d.ts +108 -0
- package/dist/scp/emit/emitter.d.ts.map +1 -0
- package/dist/scp/emit/emitter.js +782 -0
- package/dist/scp/emit/emitter.js.map +1 -0
- package/dist/scp/emit/endpoint.d.ts +248 -0
- package/dist/scp/emit/endpoint.d.ts.map +1 -0
- package/dist/scp/emit/endpoint.js +20 -0
- package/dist/scp/emit/endpoint.js.map +1 -0
- package/dist/scp/emit/index.d.ts +11 -0
- package/dist/scp/emit/index.d.ts.map +1 -0
- package/dist/scp/emit/index.js +13 -0
- package/dist/scp/emit/index.js.map +1 -0
- package/dist/scp/errors.d.ts +45 -1
- package/dist/scp/errors.d.ts.map +1 -1
- package/dist/scp/errors.js +47 -1
- package/dist/scp/errors.js.map +1 -1
- package/dist/scp/exec-context.d.ts +390 -0
- package/dist/scp/exec-context.d.ts.map +1 -0
- package/dist/scp/exec-context.js +540 -0
- package/dist/scp/exec-context.js.map +1 -0
- package/dist/scp/grouping.d.ts +32 -0
- package/dist/scp/grouping.d.ts.map +1 -0
- package/dist/scp/grouping.js +0 -0
- package/dist/scp/grouping.js.map +1 -0
- package/dist/scp/index.cjs +6432 -17579
- package/dist/scp/index.d.cts +1 -0
- package/dist/scp/index.d.mts +1 -0
- package/dist/scp/index.d.ts +51 -52
- package/dist/scp/index.d.ts.map +1 -1
- package/dist/scp/index.js +189 -152
- package/dist/scp/index.js.map +1 -1
- package/dist/scp/index.mjs +6067 -3659
- package/dist/scp/leaf-transport.d.ts +50 -0
- package/dist/scp/leaf-transport.d.ts.map +1 -0
- package/dist/scp/leaf-transport.js +92 -0
- package/dist/scp/leaf-transport.js.map +1 -0
- package/dist/scp/leaves.d.ts +174 -0
- package/dist/scp/leaves.d.ts.map +1 -0
- package/dist/scp/leaves.js +287 -0
- package/dist/scp/leaves.js.map +1 -0
- package/dist/scp/limit-config.d.ts +118 -0
- package/dist/scp/limit-config.d.ts.map +1 -0
- package/dist/scp/limit-config.js +126 -0
- package/dist/scp/limit-config.js.map +1 -0
- package/dist/scp/makesql/compile-relation.d.ts +49 -23
- package/dist/scp/makesql/compile-relation.d.ts.map +1 -1
- package/dist/scp/makesql/compile-relation.js +101 -76
- package/dist/scp/makesql/compile-relation.js.map +1 -1
- package/dist/scp/makesql/compile-select.d.ts +45 -10
- package/dist/scp/makesql/compile-select.d.ts.map +1 -1
- package/dist/scp/makesql/compile-select.js +50 -10
- package/dist/scp/makesql/compile-select.js.map +1 -1
- package/dist/scp/makesql/handler.d.ts +1 -1
- package/dist/scp/makesql/handler.d.ts.map +1 -1
- package/dist/scp/makesql/index.d.ts +7 -10
- package/dist/scp/makesql/index.d.ts.map +1 -1
- package/dist/scp/makesql/index.js +19 -30
- package/dist/scp/makesql/index.js.map +1 -1
- package/dist/scp/makesql/json-array.d.ts +65 -0
- package/dist/scp/makesql/json-array.d.ts.map +1 -1
- package/dist/scp/makesql/json-array.js +99 -10
- package/dist/scp/makesql/json-array.js.map +1 -1
- package/dist/scp/makesql/json-batch.d.ts.map +1 -1
- package/dist/scp/makesql/json-batch.js +21 -19
- package/dist/scp/makesql/json-batch.js.map +1 -1
- package/dist/scp/makesql/makesql.d.ts +1 -1
- package/dist/scp/makesql/makesql.d.ts.map +1 -1
- package/dist/scp/makesql/mysql-returning.d.ts +93 -0
- package/dist/scp/makesql/mysql-returning.d.ts.map +1 -0
- package/dist/scp/makesql/mysql-returning.js +215 -0
- package/dist/scp/makesql/mysql-returning.js.map +1 -0
- package/dist/scp/makesql/outtype.d.ts +75 -34
- package/dist/scp/makesql/outtype.d.ts.map +1 -1
- package/dist/scp/makesql/outtype.js +91 -118
- package/dist/scp/makesql/outtype.js.map +1 -1
- package/dist/scp/makesql/pool-executor.d.ts +135 -13
- package/dist/scp/makesql/pool-executor.d.ts.map +1 -1
- package/dist/scp/makesql/pool-executor.js +229 -21
- package/dist/scp/makesql/pool-executor.js.map +1 -1
- package/dist/scp/makesql/tx.d.ts +107 -22
- package/dist/scp/makesql/tx.d.ts.map +1 -1
- package/dist/scp/makesql/tx.js +451 -97
- package/dist/scp/makesql/tx.js.map +1 -1
- package/dist/scp/makesql/writeouttype.d.ts +7 -8
- package/dist/scp/makesql/writeouttype.d.ts.map +1 -1
- package/dist/scp/makesql/writeouttype.js +8 -7
- package/dist/scp/makesql/writeouttype.js.map +1 -1
- package/dist/scp/middleware.d.ts +287 -0
- package/dist/scp/middleware.d.ts.map +1 -0
- package/dist/scp/middleware.js +358 -0
- package/dist/scp/middleware.js.map +1 -0
- package/dist/scp/relation.d.ts +80 -9
- package/dist/scp/relation.d.ts.map +1 -1
- package/dist/scp/relation.js +198 -78
- package/dist/scp/relation.js.map +1 -1
- package/dist/scp/tx-options.d.ts +136 -0
- package/dist/scp/tx-options.d.ts.map +1 -0
- package/dist/scp/tx-options.js +184 -0
- package/dist/scp/tx-options.js.map +1 -0
- package/dist/scp/write-bundle.d.ts +131 -0
- package/dist/scp/write-bundle.d.ts.map +1 -0
- package/dist/scp/write-bundle.js +160 -0
- package/dist/scp/write-bundle.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/docs/BENCHMARK.md +58 -56
- package/docs/benchmark-chart.svg +166 -166
- package/docs/design/phase-a-execution-context.md +139 -0
- package/package.json +16 -9
- package/dist/scp/authoring-sql.d.ts +0 -134
- package/dist/scp/authoring-sql.d.ts.map +0 -1
- package/dist/scp/authoring-sql.js +0 -191
- package/dist/scp/authoring-sql.js.map +0 -1
- package/dist/scp/authoring.d.ts +0 -155
- package/dist/scp/authoring.d.ts.map +0 -1
- package/dist/scp/authoring.js +0 -162
- package/dist/scp/authoring.js.map +0 -1
- package/dist/scp/catalog.d.ts +0 -94
- package/dist/scp/catalog.d.ts.map +0 -1
- package/dist/scp/catalog.js +0 -234
- package/dist/scp/catalog.js.map +0 -1
- package/dist/scp/codegen.d.ts +0 -189
- package/dist/scp/codegen.d.ts.map +0 -1
- package/dist/scp/codegen.js +0 -421
- package/dist/scp/codegen.js.map +0 -1
- package/dist/scp/find-filter-guard.d.ts +0 -68
- package/dist/scp/find-filter-guard.d.ts.map +0 -1
- package/dist/scp/find-filter-guard.js +0 -88
- package/dist/scp/find-filter-guard.js.map +0 -1
- package/dist/scp/guard.d.ts +0 -43
- package/dist/scp/guard.d.ts.map +0 -1
- package/dist/scp/guard.js +0 -134
- package/dist/scp/guard.js.map +0 -1
- package/dist/scp/makesql/authoring-compile.d.ts +0 -90
- package/dist/scp/makesql/authoring-compile.d.ts.map +0 -1
- package/dist/scp/makesql/authoring-compile.js +0 -494
- package/dist/scp/makesql/authoring-compile.js.map +0 -1
- package/dist/scp/makesql/ir.d.ts +0 -42
- package/dist/scp/makesql/ir.d.ts.map +0 -1
- package/dist/scp/makesql/ir.js +0 -66
- package/dist/scp/makesql/ir.js.map +0 -1
- package/dist/scp/makesql/static-bundle.d.ts +0 -187
- package/dist/scp/makesql/static-bundle.d.ts.map +0 -1
- package/dist/scp/makesql/static-bundle.js +0 -1113
- package/dist/scp/makesql/static-bundle.js.map +0 -1
- package/dist/scp/runtime.d.ts +0 -242
- package/dist/scp/runtime.d.ts.map +0 -1
- package/dist/scp/runtime.js +0 -400
- package/dist/scp/runtime.js.map +0 -1
|
@@ -1,494 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* litedbmodel v2 SCP — the AUTHORING → `makeSQL` bundle path (Phase A of epic #43/#45).
|
|
4
|
-
*
|
|
5
|
-
* WS2 (`../authoring.ts`) lowers BOTH the SCP declaration blocks and the eager public
|
|
6
|
-
* API through ONE bc compile path (`publishBehaviors` / `compileEager`) into ONE
|
|
7
|
-
* portable `ComponentGraphIR` — a Component's body carries `componentRef` / `map` nodes
|
|
8
|
-
* whose SQL-structural ports (`table`, `select`, `where`, `values.<field>`, `set.<field>`,
|
|
9
|
-
* `order`, `limit`, …) are closed-set bc Expression IR (spec §7). Until now the ONLY
|
|
10
|
-
* consumer of that authored IR was the REDUCED spine (`../bridge.ts` → `../compile-sqlite.ts`
|
|
11
|
-
* → `CompiledOperation`).
|
|
12
|
-
*
|
|
13
|
-
* This module is the ADDITIVE makeSQL producer for the SAME authored IR: it reads a
|
|
14
|
-
* node's ports STRUCTURALLY (exactly the closed-set decoding `../bridge.ts` performs —
|
|
15
|
-
* same operators, same IN-sentinel, same SKIP-`cond` collapse, no invented opcode) and,
|
|
16
|
-
* given the concrete Input Port values, routes WHERE / CRUD / relation through
|
|
17
|
-
* `./compile*` + `./json-array` / `./json-batch` to emit a **`makeSQL` bundle** (composed
|
|
18
|
-
* `makeSQL` components). The value slots are resolved HANDLER-SIDE (spec §11 item 4): a bc
|
|
19
|
-
* `makeSQL` catalog leaf whose handler holds the concrete port values from bc's
|
|
20
|
-
* `runBehavior` and calls `./compile*` to build the byte-tuned SQL — so the emitted SQL is
|
|
21
|
-
* v1-tuned by construction (PG byte-match; MySQL/SQLite single-JSON-param parity).
|
|
22
|
-
*
|
|
23
|
-
* ## Single compile path (spec §9 — preserved)
|
|
24
|
-
*
|
|
25
|
-
* Both the eager public-API path (`compileEager`) and the declaration path
|
|
26
|
-
* (`publishBehaviors`) produce byte-identical authored component IR (pinned by
|
|
27
|
-
* `test/scp/authoring.test.ts`). Because {@link compileAuthoredBehavior} is a pure function
|
|
28
|
-
* of that IR + the concrete input, feeding EITHER path's contract through it yields a
|
|
29
|
-
* byte-identical `makeSQL` bundle — the single-compile-path invariant carries over to the
|
|
30
|
-
* makeSQL target with no second interpreter.
|
|
31
|
-
*
|
|
32
|
-
* Coverage (Phase A): a read behavior (Select + belongsTo `.map` + hasMany-limit `.map`),
|
|
33
|
-
* a write behavior (Insert), and a SKIP-optional condition. The three dialects share this
|
|
34
|
-
* routing; PG stays byte-identical to v1, MySQL/SQLite use the single-JSON-param forms.
|
|
35
|
-
*/
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.assembleMakeSQL = void 0;
|
|
38
|
-
exports.compileAuthoredNode = compileAuthoredNode;
|
|
39
|
-
exports.compileRelationMap = compileRelationMap;
|
|
40
|
-
exports.compileAuthoredBehavior = compileAuthoredBehavior;
|
|
41
|
-
const behavior_contracts_1 = require("behavior-contracts");
|
|
42
|
-
const tx_1 = require("./tx");
|
|
43
|
-
const makesql_1 = require("./makesql");
|
|
44
|
-
Object.defineProperty(exports, "assembleMakeSQL", { enumerable: true, get: function () { return makesql_1.assembleMakeSQL; } });
|
|
45
|
-
const compile_select_1 = require("./compile-select");
|
|
46
|
-
const compile_crud_1 = require("./compile-crud");
|
|
47
|
-
const compile_relation_1 = require("./compile-relation");
|
|
48
|
-
function isMap(n) {
|
|
49
|
-
return 'map' in n;
|
|
50
|
-
}
|
|
51
|
-
/** The catalog-name + ports of a `componentRef`/`map` body node (uniform view). */
|
|
52
|
-
function nodeRef(n) {
|
|
53
|
-
return isMap(n) ? { component: n.map.component, ports: n.map.ports } : { component: n.component, ports: n.ports };
|
|
54
|
-
}
|
|
55
|
-
/** A port that must be a literal string (`table`, `order`, `group`, `returning`). */
|
|
56
|
-
function stringPort(ports, name) {
|
|
57
|
-
const v = ports[name];
|
|
58
|
-
if (v === undefined)
|
|
59
|
-
return undefined;
|
|
60
|
-
if (typeof v !== 'string') {
|
|
61
|
-
throw new Error(`authoring-compile: port '${name}' must be a literal string in the IR (got ${JSON.stringify(v)})`);
|
|
62
|
-
}
|
|
63
|
-
return v;
|
|
64
|
-
}
|
|
65
|
-
/** A `{arr:[...]}` port → its element array (a bc-lowered literal array). */
|
|
66
|
-
function arrPort(ports, name) {
|
|
67
|
-
const v = ports[name];
|
|
68
|
-
if (v === undefined)
|
|
69
|
-
return undefined;
|
|
70
|
-
if (typeof v === 'object' && v !== null && 'arr' in v && Array.isArray(v.arr)) {
|
|
71
|
-
return v.arr;
|
|
72
|
-
}
|
|
73
|
-
throw new Error(`authoring-compile: port '${name}' must be an {arr:[...]} literal in the IR (got ${JSON.stringify(v)})`);
|
|
74
|
-
}
|
|
75
|
-
/** `select` string-array port → `string[]` (elements must be literals). */
|
|
76
|
-
function stringArrayPort(ports, name) {
|
|
77
|
-
const arr = arrPort(ports, name);
|
|
78
|
-
if (arr === undefined)
|
|
79
|
-
return undefined;
|
|
80
|
-
return arr.map((e) => {
|
|
81
|
-
if (typeof e !== 'string')
|
|
82
|
-
throw new Error(`authoring-compile: '${name}' entries must be literal strings (got ${JSON.stringify(e)})`);
|
|
83
|
-
return e;
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
/** The single-key operator name of an Expression node, or undefined if not a 1-key object. */
|
|
87
|
-
function opKey(node) {
|
|
88
|
-
if (node === null || typeof node !== 'object' || Array.isArray(node))
|
|
89
|
-
return undefined;
|
|
90
|
-
const keys = Object.keys(node);
|
|
91
|
-
return keys.length === 1 ? keys[0] : undefined;
|
|
92
|
-
}
|
|
93
|
-
/** The column name carried by a `ref`/`refOpt` path (its LAST segment — spec §7). */
|
|
94
|
-
function columnOf(node, ctx) {
|
|
95
|
-
const op = opKey(node);
|
|
96
|
-
if (op !== 'ref' && op !== 'refOpt') {
|
|
97
|
-
throw new Error(`authoring-compile: ${ctx}: the column operand must be a {ref:[...]} / {refOpt:[...]} path, got ${JSON.stringify(node)}`);
|
|
98
|
-
}
|
|
99
|
-
const path = node[op];
|
|
100
|
-
if (!Array.isArray(path) || path.length === 0 || typeof path[path.length - 1] !== 'string') {
|
|
101
|
-
throw new Error(`authoring-compile: ${ctx}: column ref path must be a non-empty string path`);
|
|
102
|
-
}
|
|
103
|
-
return path[path.length - 1];
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* If a column operand is an IN-list membership marker (its `ref`/`refOpt` path head is
|
|
107
|
-
* {@link IN_SENTINEL}), return the real column name; otherwise undefined. Same rule as
|
|
108
|
-
* `../bridge.ts` — the sentinel keeps IN expressible with only `eq` + `ref`.
|
|
109
|
-
*/
|
|
110
|
-
function inSentinelColumn(node) {
|
|
111
|
-
const op = opKey(node);
|
|
112
|
-
if (op !== 'ref' && op !== 'refOpt')
|
|
113
|
-
return undefined;
|
|
114
|
-
const path = node[op];
|
|
115
|
-
if (Array.isArray(path) && path.length >= 2 && path[0] === tx_1.IN_SENTINEL && typeof path[path.length - 1] === 'string') {
|
|
116
|
-
return path[path.length - 1];
|
|
117
|
-
}
|
|
118
|
-
return undefined;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Coerce a bc-evaluated integer Value to a JS `number` for INLINE numeric SQL text
|
|
122
|
-
* (`LIMIT n` / `OFFSET n`, which the original `_buildSelectSQL` inlines, not binds). bc's
|
|
123
|
-
* value model encodes an integer LITERAL as `bigint`; a `{ref}` reading a JS number stays
|
|
124
|
-
* a number. Both normalize to a JS number for the inline text.
|
|
125
|
-
*/
|
|
126
|
-
function asInt(v) {
|
|
127
|
-
if (typeof v === 'bigint')
|
|
128
|
-
return Number(v);
|
|
129
|
-
if (typeof v === 'number')
|
|
130
|
-
return v;
|
|
131
|
-
throw new Error(`authoring-compile: limit/offset must evaluate to an integer, got ${JSON.stringify(v)}`);
|
|
132
|
-
}
|
|
133
|
-
/** Read the two operands of a binary comparison node, fail-closed on arity. */
|
|
134
|
-
function binOperands(node, op, at) {
|
|
135
|
-
const args = node[op];
|
|
136
|
-
if (!Array.isArray(args) || args.length !== 2) {
|
|
137
|
-
throw new Error(`authoring-compile: ${at}: '${op}' expects exactly 2 operands`);
|
|
138
|
-
}
|
|
139
|
-
return [args[0], args[1]];
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* bc comparison operator → the SQL operator text. v1 `DBConditions` expresses a
|
|
143
|
-
* non-equality comparison as a CUSTOM-OP KEY carrying its own `?` placeholder
|
|
144
|
-
* (`{ '<col> <op> ?': value }` → emits `<col> <op> ?` with the value pushed) — there is
|
|
145
|
-
* NO `{ col: { '<op>': v } }` object form. `ne` against a non-null value maps to `<>`.
|
|
146
|
-
*/
|
|
147
|
-
const CMP_OPS = { lt: '<', le: '<=', gt: '>', ge: '>=', ne: '<>' };
|
|
148
|
-
// ============================================================================
|
|
149
|
-
// WHERE member → v1 ConditionObject entry (value resolved against the concrete scope).
|
|
150
|
-
//
|
|
151
|
-
// A `{cond:[c, member, null]}` node is the SKIP-optional collapse: the inner `member`
|
|
152
|
-
// contributes to the ConditionObject ONLY when `c` evaluates to a present binding
|
|
153
|
-
// (non-null / true), byte-identical to the render.ts existence rule (dynamic-expansion
|
|
154
|
-
// spec §2). This is where the makeSQL path realizes SKIP: an absent optional member adds
|
|
155
|
-
// no column key at all (so v1 `DBConditions` emits neither its text nor its param).
|
|
156
|
-
// ============================================================================
|
|
157
|
-
/**
|
|
158
|
-
* Fold ONE authored where-member Expression node into a v1 {@link ConditionObject},
|
|
159
|
-
* evaluating its value operand against `scope`. Mutates `into` (the accumulator) so
|
|
160
|
-
* declaration order (= SQL AND order) is preserved.
|
|
161
|
-
*/
|
|
162
|
-
function foldWhereMember(node, scope, into, at) {
|
|
163
|
-
const op = opKey(node);
|
|
164
|
-
if (op === undefined) {
|
|
165
|
-
throw new Error(`authoring-compile: ${at}: a where member must be a single-operator Expression node, got ${JSON.stringify(node)}`);
|
|
166
|
-
}
|
|
167
|
-
if (op === 'cond') {
|
|
168
|
-
// SKIP-optional: {cond:[c, <member>, null]}. Present iff `c` is a present binding.
|
|
169
|
-
const args = node.cond;
|
|
170
|
-
if (!Array.isArray(args) || args.length !== 3 || args[2] !== null) {
|
|
171
|
-
throw new Error(`authoring-compile: ${at}: a SKIP-optional condition must be {cond:[c, <member>, null]} (else = null)`);
|
|
172
|
-
}
|
|
173
|
-
const present = (0, behavior_contracts_1.evaluateExpression)(args[0], scope);
|
|
174
|
-
if (present !== null && present !== false)
|
|
175
|
-
foldWhereMember(args[1], scope, into, `${at}.cond.then`);
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (op === 'and') {
|
|
179
|
-
// A flat AND group folds its members into the same ConditionObject (v1 default AND).
|
|
180
|
-
const args = node.and;
|
|
181
|
-
if (!Array.isArray(args) || args.length < 2)
|
|
182
|
-
throw new Error(`authoring-compile: ${at}: 'and' group expects >= 2 members`);
|
|
183
|
-
args.forEach((m, i) => foldWhereMember(m, scope, into, `${at}.and[${i}]`));
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (op === 'or') {
|
|
187
|
-
// An OR group is v1's `__or__` list of sub-condition objects.
|
|
188
|
-
const args = node.or;
|
|
189
|
-
if (!Array.isArray(args) || args.length < 2)
|
|
190
|
-
throw new Error(`authoring-compile: ${at}: 'or' group expects >= 2 members`);
|
|
191
|
-
const branches = args.map((m, i) => {
|
|
192
|
-
const sub = {};
|
|
193
|
-
foldWhereMember(m, scope, sub, `${at}.or[${i}]`);
|
|
194
|
-
return sub;
|
|
195
|
-
});
|
|
196
|
-
const existing = into.__or__ ?? [];
|
|
197
|
-
into.__or__ = [...existing, ...branches];
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
if (op === 'eq') {
|
|
201
|
-
const [col, val] = binOperands(node, op, at);
|
|
202
|
-
const inCol = inSentinelColumn(col);
|
|
203
|
-
if (inCol !== undefined) {
|
|
204
|
-
// IN-list membership: v1 reads an array value as `IN (?, …)` (or the JSON single-param
|
|
205
|
-
// form on MySQL/SQLite via `conditionsFor`); empty array degenerates to `1 = 0`.
|
|
206
|
-
into[inCol] = (0, behavior_contracts_1.evaluateExpression)(val, scope);
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const value = (0, behavior_contracts_1.evaluateExpression)(val, scope);
|
|
210
|
-
// IS NULL: `eq(col, null)` → v1 emits `col IS NULL` for a null value.
|
|
211
|
-
into[columnOf(col, at)] = value;
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
if (op in CMP_OPS) {
|
|
215
|
-
const [col, val] = binOperands(node, op, at);
|
|
216
|
-
const column = columnOf(col, at);
|
|
217
|
-
const value = (0, behavior_contracts_1.evaluateExpression)(val, scope);
|
|
218
|
-
// `ne(col, null)` ⇒ v1 `col IS NOT NULL` (custom-op key with no placeholder).
|
|
219
|
-
if (op === 'ne' && value === null) {
|
|
220
|
-
into[`${column} IS NOT NULL`] = true;
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
// v1 custom-op form: the KEY carries its own `?` (`{ '<col> <op> ?': value }`).
|
|
224
|
-
into[`${column} ${CMP_OPS[op]} ?`] = value;
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
throw new Error(`authoring-compile: ${at}: unsupported where operator '${op}' (supported: eq/ne/lt/le/gt/ge/and/or/cond; IN via ${tx_1.IN_SENTINEL} column head; IS NULL via eq(col,null))`);
|
|
228
|
-
}
|
|
229
|
-
/** Fold the `where` port (`{arr:[...]}` of member nodes) into a v1 `ConditionObject`. */
|
|
230
|
-
function foldWherePort(ports, scope, at) {
|
|
231
|
-
const arr = arrPort(ports, 'where');
|
|
232
|
-
const conditions = {};
|
|
233
|
-
if (arr === undefined)
|
|
234
|
-
return conditions;
|
|
235
|
-
arr.forEach((m, i) => foldWhereMember(m, scope, conditions, `${at}.where[${i}]`));
|
|
236
|
-
return conditions;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Collect a flattened write record family (`<prefix>.<field>` ports) → an ordered
|
|
240
|
-
* `Record<field, Value>` with each value slot evaluated against `scope`. Field order =
|
|
241
|
-
* declaration (insertion) order of the ports — the SQL column order.
|
|
242
|
-
*/
|
|
243
|
-
function collectFamily(ports, prefix, scope) {
|
|
244
|
-
const out = {};
|
|
245
|
-
for (const k of Object.keys(ports)) {
|
|
246
|
-
if (k.startsWith(`${prefix}.`))
|
|
247
|
-
out[k.slice(prefix.length + 1)] = (0, behavior_contracts_1.evaluateExpression)(ports[k], scope);
|
|
248
|
-
}
|
|
249
|
-
return out;
|
|
250
|
-
}
|
|
251
|
-
// ============================================================================
|
|
252
|
-
// Node → makeSQL bundle (handler-side compile: concrete port values → ./compile*).
|
|
253
|
-
// ============================================================================
|
|
254
|
-
/**
|
|
255
|
-
* Compile ONE authored catalog `componentRef`/`map` node into a `makeSQL` bundle, given
|
|
256
|
-
* the concrete input `scope`. Routes WHERE / CRUD through `./compile*`. The value slots
|
|
257
|
-
* are the bc-evaluated concrete values (handler-side), so the emitted SQL text/params
|
|
258
|
-
* come STRAIGHT from the v1 builders (`compileSelect` / `compileInsert` / …) —
|
|
259
|
-
* byte-parity by construction.
|
|
260
|
-
*/
|
|
261
|
-
function compileAuthoredNode(node, scope, dialect) {
|
|
262
|
-
const { component, ports } = nodeRef(node);
|
|
263
|
-
const table = stringPort(ports, 'table');
|
|
264
|
-
if (table === undefined)
|
|
265
|
-
throw new Error(`authoring-compile: ${component} node requires a literal 'table' port`);
|
|
266
|
-
const at = `${component}`;
|
|
267
|
-
switch (component) {
|
|
268
|
-
case 'Select': {
|
|
269
|
-
const select = stringArrayPort(ports, 'select');
|
|
270
|
-
const conditions = foldWherePort(ports, scope, at);
|
|
271
|
-
return (0, compile_select_1.compileSelect)({
|
|
272
|
-
dialect,
|
|
273
|
-
tableName: table,
|
|
274
|
-
select: select ? select.join(', ') : undefined,
|
|
275
|
-
conditions,
|
|
276
|
-
order: stringPort(ports, 'order'),
|
|
277
|
-
group: stringPort(ports, 'group'),
|
|
278
|
-
limit: ports.limit !== undefined ? asInt((0, behavior_contracts_1.evaluateExpression)(ports.limit, scope)) : undefined,
|
|
279
|
-
offset: ports.offset !== undefined ? asInt((0, behavior_contracts_1.evaluateExpression)(ports.offset, scope)) : undefined,
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
case 'Insert': {
|
|
283
|
-
const values = collectFamily(ports, 'values', scope);
|
|
284
|
-
if (Object.keys(values).length === 0)
|
|
285
|
-
throw new Error(`authoring-compile: Insert requires at least one 'values.<field>' port`);
|
|
286
|
-
const returning = stringPort(ports, 'returning');
|
|
287
|
-
// A single authored Insert is ONE row → the ORIGINAL single-row `buildInsert`
|
|
288
|
-
// (`VALUES (?, …)`, byte-identical to v1). The JSON single-param batch form is
|
|
289
|
-
// reserved for multi-row `createMany` (spec §43/§45), not the authoring single
|
|
290
|
-
// Insert. Columns are CANONICAL (alphabetical) sorted — the v2 write-path SSoT
|
|
291
|
-
// (`DBModel._insert` single-record fast path aligns to the same order).
|
|
292
|
-
const columns = Object.keys(values).sort();
|
|
293
|
-
return (0, compile_crud_1.compileInsert)(dialect, { tableName: table, columns, records: [values], returning });
|
|
294
|
-
}
|
|
295
|
-
case 'Update': {
|
|
296
|
-
const set = collectFamily(ports, 'set', scope);
|
|
297
|
-
if (Object.keys(set).length === 0)
|
|
298
|
-
throw new Error(`authoring-compile: Update requires at least one 'set.<field>' port`);
|
|
299
|
-
const conditions = foldWherePort(ports, scope, at);
|
|
300
|
-
return (0, compile_crud_1.compileUpdateSingle)({
|
|
301
|
-
dialect,
|
|
302
|
-
tableName: table,
|
|
303
|
-
serializedValues: set,
|
|
304
|
-
conditions,
|
|
305
|
-
returning: stringPort(ports, 'returning'),
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
case 'Delete': {
|
|
309
|
-
const conditions = foldWherePort(ports, scope, at);
|
|
310
|
-
return (0, compile_crud_1.compileDelete)({ dialect, tableName: table, conditions, returning: stringPort(ports, 'returning') });
|
|
311
|
-
}
|
|
312
|
-
default:
|
|
313
|
-
throw new Error(`authoring-compile: catalog component '${component}' has no makeSQL compile (SQL CRUD only: Select/Insert/Update/Delete)`);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Compile a relation `.map` node into a batch-load `makeSQL` bundle. The map's inner
|
|
318
|
-
* `where` names the target key column (`eq($p.<k>, …)`); the batch key VALUES are the
|
|
319
|
-
* distinct `parentKey` values across `parentRows`. Extra (non-key) where members become
|
|
320
|
-
* the relation's merged `conditions` filter.
|
|
321
|
-
*
|
|
322
|
-
* @param parentKey the parent-row field whose values key the batch (e.g. `author_id`).
|
|
323
|
-
*/
|
|
324
|
-
function compileRelationMap(node, input, dialect, parentKey) {
|
|
325
|
-
const ports = node.map.ports;
|
|
326
|
-
const table = stringPort(ports, 'table');
|
|
327
|
-
if (table === undefined)
|
|
328
|
-
throw new Error(`authoring-compile: relation map requires a literal 'table' port`);
|
|
329
|
-
const select = stringArrayPort(ports, 'select');
|
|
330
|
-
const order = stringPort(ports, 'order');
|
|
331
|
-
// The target key column = the single eq-member column of the relation `where`.
|
|
332
|
-
const whereArr = arrPort(ports, 'where') ?? [];
|
|
333
|
-
let targetKey;
|
|
334
|
-
const filters = {};
|
|
335
|
-
whereArr.forEach((m, i) => {
|
|
336
|
-
const op = opKey(m);
|
|
337
|
-
if (op === 'eq') {
|
|
338
|
-
const [col] = binOperands(m, 'eq', `relationMap.where[${i}]`);
|
|
339
|
-
const inCol = inSentinelColumn(col);
|
|
340
|
-
const name = inCol ?? columnOf(col, `relationMap.where[${i}]`);
|
|
341
|
-
if (targetKey === undefined) {
|
|
342
|
-
targetKey = name; // first eq is the join key
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
// Any further member is a relation filter (folded against an empty scope — filters
|
|
347
|
-
// here are static; dynamic relation filters are out of Phase A scope).
|
|
348
|
-
foldWhereMember(m, {}, filters, `relationMap.where[${i}]`);
|
|
349
|
-
});
|
|
350
|
-
if (targetKey === undefined)
|
|
351
|
-
throw new Error(`authoring-compile: relation map 'where' must carry a key eq(...) member`);
|
|
352
|
-
const values = distinctKeys(input.parentRows, parentKey);
|
|
353
|
-
const base = {
|
|
354
|
-
dialect,
|
|
355
|
-
tableName: table,
|
|
356
|
-
conditions: Object.keys(filters).length > 0 ? filters : undefined,
|
|
357
|
-
order,
|
|
358
|
-
targetKey,
|
|
359
|
-
values,
|
|
360
|
-
};
|
|
361
|
-
// Unlimited honors the per-column projection (v1 `WHERE key IN … [ORDER BY]`); the
|
|
362
|
-
// per-parent-limit ROW_NUMBER/LATERAL shape projects the outer `*` (the compile-relation
|
|
363
|
-
// anchor — v1 `SELECT * FROM ranked`), so `select` is not forwarded to the limited path.
|
|
364
|
-
return input.limit !== undefined
|
|
365
|
-
? (0, compile_relation_1.compileSingleKeyLimited)({ ...base, limit: input.limit })
|
|
366
|
-
: (0, compile_relation_1.compileSingleKeyUnlimited)({ ...base, select: select ? select.join(', ') : undefined });
|
|
367
|
-
}
|
|
368
|
-
/** Distinct, non-null parent-key values in first-seen order (the batch IN-list source). */
|
|
369
|
-
function distinctKeys(rows, key) {
|
|
370
|
-
const seen = new Set();
|
|
371
|
-
const out = [];
|
|
372
|
-
for (const r of rows) {
|
|
373
|
-
const v = r[key];
|
|
374
|
-
if (v === null || v === undefined)
|
|
375
|
-
continue;
|
|
376
|
-
if (!seen.has(v)) {
|
|
377
|
-
seen.add(v);
|
|
378
|
-
out.push(v);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
return out;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Compile the PRIMARY read/write query of an authored behavior method into a `makeSQL`
|
|
385
|
-
* bundle, given the concrete Input Port `scope`. The "primary" node is the method's root
|
|
386
|
-
* catalog `componentRef` (the Select the relations map over, or the write). Relation
|
|
387
|
-
* `.map` nodes are returned unresolved (their batch keys come from executing `primary`
|
|
388
|
-
* first — {@link compileRelationMap}).
|
|
389
|
-
*
|
|
390
|
-
* This is a PURE function of the authored component IR + the input, so `publishBehaviors`
|
|
391
|
-
* (declaration) and `compileEager` (eager) — which produce byte-identical component IR —
|
|
392
|
-
* yield a byte-identical `primary` bundle (single-compile-path invariant, spec §9).
|
|
393
|
-
*/
|
|
394
|
-
function compileAuthoredBehavior(contract, scope, dialect, entry) {
|
|
395
|
-
const component = entry
|
|
396
|
-
? contract.components.find((c) => c.name === entry)
|
|
397
|
-
: contract.components[0];
|
|
398
|
-
if (component === undefined) {
|
|
399
|
-
throw new Error(`authoring-compile: entry component '${entry ?? '<first>'}' not found in contract`);
|
|
400
|
-
}
|
|
401
|
-
// The primary node is the first catalog `componentRef` (root); `map` nodes are relations.
|
|
402
|
-
const relations = [];
|
|
403
|
-
let primaryNode;
|
|
404
|
-
for (const n of component.body) {
|
|
405
|
-
if ('cond' in n)
|
|
406
|
-
continue; // pure Expression node (a shared SKIP guard), no SQL.
|
|
407
|
-
if (isMap(n)) {
|
|
408
|
-
relations.push(n);
|
|
409
|
-
continue;
|
|
410
|
-
}
|
|
411
|
-
if (primaryNode === undefined)
|
|
412
|
-
primaryNode = n;
|
|
413
|
-
}
|
|
414
|
-
if (primaryNode === undefined) {
|
|
415
|
-
throw new Error(`authoring-compile: behavior '${component.name}' has no primary catalog node`);
|
|
416
|
-
}
|
|
417
|
-
const normalized = normalizeInput(component, scope);
|
|
418
|
-
return {
|
|
419
|
-
name: component.name,
|
|
420
|
-
primary: compileAuthoredNode(primaryNode, normalized, dialect),
|
|
421
|
-
relations,
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Normalize the caller input to present-as-null for every OPTIONAL Input Port the caller
|
|
426
|
-
* omitted, so a SKIP-optional guard reading that port (`ne($.status, null)`) evaluates
|
|
427
|
-
* against a present `null` (→ the guard is false → the member drops) rather than throwing
|
|
428
|
-
* `UNKNOWN_BINDING`. This is the SAME absent-key SKIP rule the reduced runtime applies
|
|
429
|
-
* (`../runtime.ts` `normalizeInput`), driven by the SSoT — never an ad-hoc code default. A
|
|
430
|
-
* head is OPTIONAL iff EITHER (a) the component's Input Port schema marks it `required !==
|
|
431
|
-
* true`, OR (b) it drives a SKIP `cond` guard (bc infers erased-type ports as `required`,
|
|
432
|
-
* so a SKIP-guarded head declares its driving input optional — spec §7). A REQUIRED,
|
|
433
|
-
* non-SKIP head that is missing is left ABSENT so a real wiring bug surfaces loudly as
|
|
434
|
-
* bc's `UNKNOWN_BINDING`, not a silent default.
|
|
435
|
-
*/
|
|
436
|
-
function normalizeInput(component, input) {
|
|
437
|
-
const optional = new Set();
|
|
438
|
-
for (const [port, schema] of Object.entries(component.inputPorts)) {
|
|
439
|
-
if (schema.required !== true)
|
|
440
|
-
optional.add(port);
|
|
441
|
-
}
|
|
442
|
-
for (const n of component.body)
|
|
443
|
-
skipGuardHeads(n, optional);
|
|
444
|
-
const out = { ...input };
|
|
445
|
-
for (const head of optional) {
|
|
446
|
-
if (!(head in out))
|
|
447
|
-
out[head] = null;
|
|
448
|
-
}
|
|
449
|
-
return out;
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Collect the input heads that DRIVE a SKIP `cond` guard anywhere in a body node's ports
|
|
453
|
-
* (the `c` of a `{cond:[c, member, null]}` where-member). Those heads are optional (their
|
|
454
|
-
* absence must present as `null` so the guard drops the member). Reads the guard condition
|
|
455
|
-
* expression's `ref`/`refOpt` PATH HEADS structurally — no evaluation.
|
|
456
|
-
*/
|
|
457
|
-
function skipGuardHeads(n, into) {
|
|
458
|
-
if ('cond' in n)
|
|
459
|
-
return; // a shared pure Expression node, not a catalog SQL node
|
|
460
|
-
const ports = isMap(n) ? n.map.ports : n.ports;
|
|
461
|
-
const where = ports.where;
|
|
462
|
-
if (typeof where !== 'object' || where === null || !('arr' in where))
|
|
463
|
-
return;
|
|
464
|
-
const arr = where.arr;
|
|
465
|
-
if (!Array.isArray(arr))
|
|
466
|
-
return;
|
|
467
|
-
for (const m of arr) {
|
|
468
|
-
if (opKey(m) === 'cond') {
|
|
469
|
-
const cond = m.cond;
|
|
470
|
-
if (Array.isArray(cond) && cond.length === 3)
|
|
471
|
-
collectRefHeads(cond[0], into);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
/** Collect every `ref`/`refOpt` path HEAD reachable in an Expression IR node. */
|
|
476
|
-
function collectRefHeads(node, into) {
|
|
477
|
-
if (node === null || typeof node !== 'object')
|
|
478
|
-
return;
|
|
479
|
-
if (Array.isArray(node)) {
|
|
480
|
-
for (const e of node)
|
|
481
|
-
collectRefHeads(e, into);
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
const op = opKey(node);
|
|
485
|
-
if (op === 'ref' || op === 'refOpt') {
|
|
486
|
-
const path = node[op];
|
|
487
|
-
if (Array.isArray(path) && path.length > 0 && typeof path[0] === 'string')
|
|
488
|
-
into.add(path[0]);
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
for (const v of Object.values(node))
|
|
492
|
-
collectRefHeads(v, into);
|
|
493
|
-
}
|
|
494
|
-
//# sourceMappingURL=authoring-compile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-compile.js","sourceRoot":"","sources":["../../../src/scp/makesql/authoring-compile.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;AAwPH,kDAoDC;AA6BD,gDAgDC;AA0CD,0DAkCC;AAncD,2DAAgF;AAGhF,6BAAmC;AAGnC,uCAA4C;AA+fnC,gGA/fA,yBAAe,OA+fA;AA9fxB,qDAAiD;AACjD,iDAAmF;AACnF,yDAG4B;AAY5B,SAAS,KAAK,CAAC,CAA4B;IACzC,OAAO,KAAK,IAAI,CAAC,CAAC;AACpB,CAAC;AAED,mFAAmF;AACnF,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,qFAAqF;AACrF,SAAS,UAAU,CAAC,KAA8B,EAAE,IAAY;IAC9D,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACtB,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACtC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,6C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,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO;IACtD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,KAAK,MAAM,CAAC,IAAI,IAAI;YAAE,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC/C,OAAO;IACT,CAAC;IACD,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,EAAE,KAAK,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,GAAI,IAAkC,CAAC,EAAE,CAAC,CAAC;QACrD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ;YAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC,CAAC;QACvG,OAAO;IACT,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAA+B,CAAC;QAAE,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAC3F,CAAC"}
|
package/dist/scp/makesql/ir.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* litedbmodel v2 SCP — build a bc `ComponentGraphIR` whose single body node is a
|
|
3
|
-
* `makeSQL` componentRef, so a query rides bc's `runBehavior` (composition / value-eval
|
|
4
|
-
* / plan / envelope come free). The `makeSQL` ports are bc Expression IR: `sql` and
|
|
5
|
-
* `skip` are simple literals/refs; `params` is an `{ arr: [...] }` of Expression IR
|
|
6
|
-
* nodes (each a bound-value literal, an input ref, or a nested-`makeSQL` `{ obj: … }`).
|
|
7
|
-
*
|
|
8
|
-
* The bundle is pure JSON (multi-language ready). The handler (see `handler.ts`)
|
|
9
|
-
* assembles + binds + executes. bc validates the envelope and evaluates the ports.
|
|
10
|
-
*/
|
|
11
|
-
import type { ComponentGraphIR } from 'behavior-contracts';
|
|
12
|
-
import { type MakeSQL, type SqlParam, isMakeSQL } from './makesql';
|
|
13
|
-
/** Wrap a bound SQL value as a bc Expression IR literal node.
|
|
14
|
-
*
|
|
15
|
-
* bc's Expression IR represents ints as `{int:"…"}` and rejects bare `Date`/arrays.
|
|
16
|
-
* SQL bound values are opaque to bc, so we pass them as an inert `{lit}` marker that
|
|
17
|
-
* the handler unwraps — but since bc has no `lit` op, we instead carry the raw params
|
|
18
|
-
* OUT-OF-BAND: the IR references `input.params` by ref and the caller supplies the
|
|
19
|
-
* assembled params in the input scope. This keeps values byte-exact (no bc coercion).
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Build the single-`makeSQL` component IR + the input scope for a pre-assembled query.
|
|
23
|
-
*
|
|
24
|
-
* We keep SQL bound values OUT of bc's numeric/format coercion by binding them through
|
|
25
|
-
* the input scope: the `params` port is `{ ref: ["__sqlParams"] }` and the caller
|
|
26
|
-
* passes `{ __sqlParams: <the params array>, __sql: <text>, __skip: <bool> }` as input.
|
|
27
|
-
* bc evaluates the refs (returning the values verbatim), then hands them to the
|
|
28
|
-
* `makeSQL` handler, which assembles + binds + executes.
|
|
29
|
-
*/
|
|
30
|
-
export declare function makeSqlComponentIR(entry?: string): ComponentGraphIR;
|
|
31
|
-
/** The input scope for {@link makeSqlComponentIR}, from a compiled `makeSQL` bundle. */
|
|
32
|
-
export declare function makeSqlInput(node: MakeSQL): Record<string, unknown>;
|
|
33
|
-
/**
|
|
34
|
-
* bc's `evaluateExpression` rejects bare arrays / non-plain values as expressions, and
|
|
35
|
-
* the input scope is validated loosely (refs just read it). Because our params ride the
|
|
36
|
-
* scope as a plain `ref`, bc returns them verbatim (arrays, Dates, nested makeSQL
|
|
37
|
-
* objects) with NO coercion — exactly what the handler needs. `isMakeSQL` /
|
|
38
|
-
* `SqlParam` re-exported for callers building nested params.
|
|
39
|
-
*/
|
|
40
|
-
export { isMakeSQL };
|
|
41
|
-
export type { SqlParam };
|
|
42
|
-
//# sourceMappingURL=ir.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../../../src/scp/makesql/ir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAW,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE5E;;;;;;;GAOG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,SAAU,GAAG,gBAAgB,CAsBpE;AAED,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMnE;AAED;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,YAAY,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/scp/makesql/ir.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* litedbmodel v2 SCP — build a bc `ComponentGraphIR` whose single body node is a
|
|
4
|
-
* `makeSQL` componentRef, so a query rides bc's `runBehavior` (composition / value-eval
|
|
5
|
-
* / plan / envelope come free). The `makeSQL` ports are bc Expression IR: `sql` and
|
|
6
|
-
* `skip` are simple literals/refs; `params` is an `{ arr: [...] }` of Expression IR
|
|
7
|
-
* nodes (each a bound-value literal, an input ref, or a nested-`makeSQL` `{ obj: … }`).
|
|
8
|
-
*
|
|
9
|
-
* The bundle is pure JSON (multi-language ready). The handler (see `handler.ts`)
|
|
10
|
-
* assembles + binds + executes. bc validates the envelope and evaluates the ports.
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.isMakeSQL = void 0;
|
|
14
|
-
exports.makeSqlComponentIR = makeSqlComponentIR;
|
|
15
|
-
exports.makeSqlInput = makeSqlInput;
|
|
16
|
-
const makesql_1 = require("./makesql");
|
|
17
|
-
Object.defineProperty(exports, "isMakeSQL", { enumerable: true, get: function () { return makesql_1.isMakeSQL; } });
|
|
18
|
-
/** Wrap a bound SQL value as a bc Expression IR literal node.
|
|
19
|
-
*
|
|
20
|
-
* bc's Expression IR represents ints as `{int:"…"}` and rejects bare `Date`/arrays.
|
|
21
|
-
* SQL bound values are opaque to bc, so we pass them as an inert `{lit}` marker that
|
|
22
|
-
* the handler unwraps — but since bc has no `lit` op, we instead carry the raw params
|
|
23
|
-
* OUT-OF-BAND: the IR references `input.params` by ref and the caller supplies the
|
|
24
|
-
* assembled params in the input scope. This keeps values byte-exact (no bc coercion).
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Build the single-`makeSQL` component IR + the input scope for a pre-assembled query.
|
|
28
|
-
*
|
|
29
|
-
* We keep SQL bound values OUT of bc's numeric/format coercion by binding them through
|
|
30
|
-
* the input scope: the `params` port is `{ ref: ["__sqlParams"] }` and the caller
|
|
31
|
-
* passes `{ __sqlParams: <the params array>, __sql: <text>, __skip: <bool> }` as input.
|
|
32
|
-
* bc evaluates the refs (returning the values verbatim), then hands them to the
|
|
33
|
-
* `makeSQL` handler, which assembles + binds + executes.
|
|
34
|
-
*/
|
|
35
|
-
function makeSqlComponentIR(entry = 'Query') {
|
|
36
|
-
const component = {
|
|
37
|
-
name: entry,
|
|
38
|
-
inputPorts: {
|
|
39
|
-
__sql: { type: 'string', required: true },
|
|
40
|
-
__sqlParams: { type: 'arr' },
|
|
41
|
-
__skip: { type: 'bool' },
|
|
42
|
-
},
|
|
43
|
-
body: [
|
|
44
|
-
{
|
|
45
|
-
id: 'q',
|
|
46
|
-
component: makesql_1.MAKESQL,
|
|
47
|
-
ports: {
|
|
48
|
-
sql: { ref: ['__sql'] },
|
|
49
|
-
params: { ref: ['__sqlParams'] },
|
|
50
|
-
skip: { ref: ['__skip'] },
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
output: { ref: ['q'] },
|
|
55
|
-
};
|
|
56
|
-
return { irVersion: 1, exprVersion: 2, components: [component] };
|
|
57
|
-
}
|
|
58
|
-
/** The input scope for {@link makeSqlComponentIR}, from a compiled `makeSQL` bundle. */
|
|
59
|
-
function makeSqlInput(node) {
|
|
60
|
-
return {
|
|
61
|
-
__sql: node.sql,
|
|
62
|
-
__sqlParams: node.params,
|
|
63
|
-
__skip: node.skip === true,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=ir.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ir.js","sourceRoot":"","sources":["../../../src/scp/makesql/ir.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAuBH,gDAsBC;AAGD,oCAMC;AAnDD,uCAA4E;AA4DnE,0FA5DsC,mBAAS,OA4DtC;AA1DlB;;;;;;;GAOG;AAEH;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAAC,KAAK,GAAG,OAAO;IAChD,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,KAAK;QACX,UAAU,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;YACzC,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;YAC5B,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SACzB;QACD,IAAI,EAAE;YACJ;gBACE,EAAE,EAAE,GAAG;gBACP,SAAS,EAAE,iBAAO;gBAClB,KAAK,EAAE;oBACL,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE;oBACvB,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE;oBAChC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE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