litedbmodel 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +44 -24
- package/dist/decorators.js.map +1 -1
- package/dist/drivers/mysql.d.ts.map +1 -1
- package/dist/drivers/mysql.js +6 -0
- package/dist/drivers/mysql.js.map +1 -1
- package/dist/drivers/postgres.d.ts.map +1 -1
- package/dist/drivers/postgres.js +7 -0
- 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 +37 -2
- package/dist/drivers/sqlite.js.map +1 -1
- package/dist/scp/authoring.d.ts +66 -3
- package/dist/scp/authoring.d.ts.map +1 -1
- package/dist/scp/authoring.js +194 -5
- package/dist/scp/authoring.js.map +1 -1
- package/dist/scp/catalog.d.ts +6 -2
- package/dist/scp/catalog.d.ts.map +1 -1
- package/dist/scp/catalog.js +17 -2
- package/dist/scp/catalog.js.map +1 -1
- package/dist/scp/codegen.d.ts +132 -26
- package/dist/scp/codegen.d.ts.map +1 -1
- package/dist/scp/codegen.js +546 -35
- package/dist/scp/codegen.js.map +1 -1
- package/dist/scp/coltype.d.ts +124 -0
- package/dist/scp/coltype.d.ts.map +1 -0
- package/dist/scp/coltype.js +408 -0
- package/dist/scp/coltype.js.map +1 -0
- package/dist/scp/dialect.d.ts +12 -3
- package/dist/scp/dialect.d.ts.map +1 -1
- package/dist/scp/dialect.js +12 -3
- package/dist/scp/dialect.js.map +1 -1
- package/dist/scp/fragment/assemble.d.ts.map +1 -1
- package/dist/scp/fragment/assemble.js +10 -2
- package/dist/scp/fragment/assemble.js.map +1 -1
- package/dist/scp/fragment/compile-pg.js +4 -4
- package/dist/scp/guard.d.ts +1 -1
- package/dist/scp/guard.d.ts.map +1 -1
- package/dist/scp/guard.js +6 -0
- package/dist/scp/guard.js.map +1 -1
- package/dist/scp/index.cjs +10003 -4917
- package/dist/scp/index.d.ts +8 -5
- package/dist/scp/index.d.ts.map +1 -1
- package/dist/scp/index.js +35 -9
- package/dist/scp/index.js.map +1 -1
- package/dist/scp/index.mjs +1343 -213
- package/dist/scp/makesql/authoring-compile.d.ts.map +1 -1
- package/dist/scp/makesql/authoring-compile.js +11 -0
- package/dist/scp/makesql/authoring-compile.js.map +1 -1
- package/dist/scp/makesql/compile-select.d.ts +8 -1
- package/dist/scp/makesql/compile-select.d.ts.map +1 -1
- package/dist/scp/makesql/compile-select.js +1 -1
- package/dist/scp/makesql/compile-select.js.map +1 -1
- package/dist/scp/makesql/index.d.ts +2 -3
- package/dist/scp/makesql/index.d.ts.map +1 -1
- package/dist/scp/makesql/index.js +6 -6
- package/dist/scp/makesql/index.js.map +1 -1
- package/dist/scp/makesql/json-batch.d.ts.map +1 -1
- package/dist/scp/makesql/json-batch.js +6 -1
- package/dist/scp/makesql/json-batch.js.map +1 -1
- package/dist/scp/makesql/outtype.d.ts +99 -0
- package/dist/scp/makesql/outtype.d.ts.map +1 -0
- package/dist/scp/makesql/outtype.js +328 -0
- package/dist/scp/makesql/outtype.js.map +1 -0
- package/dist/scp/makesql/pool-executor.d.ts +70 -0
- package/dist/scp/makesql/pool-executor.d.ts.map +1 -1
- package/dist/scp/makesql/pool-executor.js +73 -5
- package/dist/scp/makesql/pool-executor.js.map +1 -1
- package/dist/scp/makesql/static-bundle.d.ts +41 -30
- package/dist/scp/makesql/static-bundle.d.ts.map +1 -1
- package/dist/scp/makesql/static-bundle.js +351 -131
- package/dist/scp/makesql/static-bundle.js.map +1 -1
- package/dist/scp/makesql/tx.d.ts +1 -1
- package/dist/scp/makesql/tx.d.ts.map +1 -1
- package/dist/scp/makesql/tx.js +48 -3
- package/dist/scp/makesql/tx.js.map +1 -1
- package/dist/scp/makesql/writeouttype.d.ts +65 -0
- package/dist/scp/makesql/writeouttype.d.ts.map +1 -0
- package/dist/scp/makesql/writeouttype.js +194 -0
- package/dist/scp/makesql/writeouttype.js.map +1 -0
- package/dist/scp/relation.d.ts +15 -1
- package/dist/scp/relation.d.ts.map +1 -1
- package/dist/scp/relation.js +61 -2
- package/dist/scp/relation.js.map +1 -1
- package/dist/scp/runtime.d.ts +17 -5
- package/dist/scp/runtime.d.ts.map +1 -1
- package/dist/scp/runtime.js +55 -14
- package/dist/scp/runtime.js.map +1 -1
- package/docs/BENCHMARK.md +58 -56
- package/docs/benchmark-chart.svg +166 -166
- package/docs/proposal/litedbmodel-v2-scp-architecture.md +51 -0
- package/package.json +8 -2
- 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
|
@@ -33,9 +33,11 @@
|
|
|
33
33
|
* Expression IR, a SKIP-`cond` guard becomes the statement's `skip` expression, and the SQL
|
|
34
34
|
* text is emitted once.
|
|
35
35
|
*/
|
|
36
|
-
import { type Scope, type Value
|
|
37
|
-
import type { ComponentRefNode, MapNode, BehaviorModelContract } from '../authoring';
|
|
36
|
+
import { type Scope, type Value } from 'behavior-contracts';
|
|
37
|
+
import type { ComponentGraphIR, ComponentRefNode, MapNode, BehaviorModelContract } from '../authoring';
|
|
38
38
|
import { type Dialect } from './handler';
|
|
39
|
+
import { type FindFilterSource } from '../find-filter-guard';
|
|
40
|
+
import { type ColumnTypeResolver, type MaterializeClass } from '../coltype';
|
|
39
41
|
/** A closed-set bc Expression IR node used as a deferred value-spec or a skip expression. */
|
|
40
42
|
export type ValueSpec = unknown;
|
|
41
43
|
/**
|
|
@@ -118,51 +120,60 @@ export declare function executeStaticBundle(bundle: StaticBundle, input: Scope,
|
|
|
118
120
|
*/
|
|
119
121
|
export declare function executeStaticWrite(bundle: StaticBundle, input: Scope, db: SqliteDb): Record<string, unknown>[];
|
|
120
122
|
/**
|
|
121
|
-
* The compiled, portable READ graph of a behavior method
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
123
|
+
* The compiled, portable READ graph of a behavior method (#12 de-surrogated): `compileBehaviors`'
|
|
124
|
+
* REAL `ComponentGraphIR` — the authored `Select`/`Count`/map nodes with their own ports (only
|
|
125
|
+
* additively annotated with read `outType`/`outputType`), NOT a hand-built `__makeSqlNode`/`__scope`
|
|
126
|
+
* surrogate — plus the per-node static `makeSQL` statement templates (opaque, v1-`DBConditions`-
|
|
127
|
+
* sourced SQL TEXT) keyed by the real body-node id, and the optional heads. Pure JSON —
|
|
128
|
+
* `JSON.stringify` round-trips, so every language runtime walks this real-node IR natively (topology
|
|
129
|
+
* from the real nodes, SQL from `statementsById`) with a SQL driver — never bc `runBehavior`.
|
|
125
130
|
*/
|
|
126
131
|
export interface ReadGraph {
|
|
127
132
|
readonly dialect: Dialect;
|
|
128
133
|
readonly name: string;
|
|
129
|
-
/**
|
|
134
|
+
/** `compileBehaviors`' real `ComponentGraphIR` (real `Select`/`Count`/map nodes; outType-annotated). */
|
|
130
135
|
readonly ir: ComponentGraphIR;
|
|
131
|
-
/** Per-node static `makeSQL` statement templates, keyed by body node id. */
|
|
136
|
+
/** Per-node static `makeSQL` statement templates (v1-sourced SQL text), keyed by real body node id. */
|
|
132
137
|
readonly statementsById: Record<string, readonly StaticStatement[]>;
|
|
133
138
|
/** Input heads normalized to present-as-null (absent-key SKIP; SSoT-driven). */
|
|
134
139
|
readonly optionalHeads: readonly string[];
|
|
140
|
+
/**
|
|
141
|
+
* TS read-path MATERIALIZERS (issue #59), per Select node: `column → MaterializeClass`. Present
|
|
142
|
+
* ONLY when a column-type resolver was supplied at compile (same gate as the `outType`
|
|
143
|
+
* annotations) — without it the read stays un-materialized (raw driver values), identical to the
|
|
144
|
+
* pre-#59 behavior. When present, the read handler coerces each raw row cell to the JS form the
|
|
145
|
+
* SQL column type declares (BIGINT→bigint, INT→number, DATE→string, BOOLEAN→boolean), consistent
|
|
146
|
+
* across sqlite/pg/mysql.
|
|
147
|
+
*/
|
|
148
|
+
readonly materializersByNode?: Record<string, Record<string, MaterializeClass>>;
|
|
135
149
|
}
|
|
136
150
|
/**
|
|
137
|
-
* Compile a READ behavior method into a portable {@link ReadGraph}
|
|
138
|
-
*
|
|
139
|
-
* and compile each node's static statements ONCE
|
|
140
|
-
*
|
|
151
|
+
* Compile a READ behavior method into a portable {@link ReadGraph} (#12 de-surrogated): keep
|
|
152
|
+
* `compileBehaviors`' REAL `Select`/`Count`/map body nodes (only additively annotate each with its
|
|
153
|
+
* read `outType`), and compile each node's static `makeSQL` statements ONCE into the `statementsById`
|
|
154
|
+
* sidecar (keyed by the real body-node id). SYMBOLIC — no concrete input. The native walker
|
|
155
|
+
* ({@link executeReadGraph}) owns map iteration / wire binding / Φ output at execute time, rendering
|
|
156
|
+
* each node's statements against the walk scope — never bc `runBehavior`, never a `__scope` surrogate.
|
|
141
157
|
*/
|
|
142
|
-
export declare function compileReadGraph(contract: BehaviorModelContract, dialect: Dialect, entry?: string): ReadGraph;
|
|
158
|
+
export declare function compileReadGraph(contract: BehaviorModelContract, dialect: Dialect, entry?: string, findFilterModel?: FindFilterSource, resolveColumnType?: ColumnTypeResolver): ReadGraph;
|
|
143
159
|
/**
|
|
144
|
-
* Execute a compiled {@link ReadGraph} via
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
160
|
+
* Execute a compiled {@link ReadGraph} via the NATIVE walker (#12): walk `compileBehaviors`' REAL
|
|
161
|
+
* `Select`/`Count`/map node IR in `plan.groups` stage order — computing each node's rows from its
|
|
162
|
+
* `statementsById` fragments (rendered against the walk scope) and committing `(nodeId → value)` —
|
|
163
|
+
* then evaluate the component's `output` Φ expression. NO bc `runBehavior`, NO `__makeSqlNode`
|
|
164
|
+
* surrogate; litedbmodel owns map iteration / wire binding / Φ output. This is the SAME native
|
|
165
|
+
* orchestration model the rust/go/py/php runtimes follow — one shape, all 5 languages, interpreter-free.
|
|
148
166
|
*/
|
|
149
167
|
export declare function executeReadGraph(graph: ReadGraph, input: Scope, db: SqliteDb): Value;
|
|
150
168
|
/** An async driver seam: run a rendered `{ sql, params }` and resolve to result rows (#40). */
|
|
151
169
|
export type SqlExecutorAsync = (sql: string, params: unknown[]) => Promise<Record<string, unknown>[]>;
|
|
152
170
|
/**
|
|
153
|
-
* Async twin of {@link executeReadGraph} — the PG / MySQL execution model (#40).
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* `
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* each `exec` call resolving on its own pooled connection), that becomes REAL parallel read-relation
|
|
160
|
-
* DB I/O — the plan's declared concurrency finally cashes out as concurrent dispatch. The result is
|
|
161
|
-
* deterministic (bc commits stage outcomes in declaration order), so it equals the serial
|
|
162
|
-
* `executeReadGraph` output exactly; only the wall-clock changes.
|
|
163
|
-
*
|
|
164
|
-
* The conformance bar stays on the SYNC in-proc better-sqlite3 path (`executeReadGraph`); this async
|
|
165
|
-
* path is the live PG/MySQL execution model and is proven by the latency-injecting concurrency test.
|
|
171
|
+
* Async twin of {@link executeReadGraph} — the live PG / MySQL execution model (#40). Byte-identical
|
|
172
|
+
* composition (SAME real-node IR, SAME per-node SQL text + params, SAME Φ output); within a plan stage
|
|
173
|
+
* the INDEPENDENT sibling nodes are dispatched concurrently against the pooled async executor (each
|
|
174
|
+
* `exec` resolving on its own pooled connection), and a map node's per-element queries fan out in
|
|
175
|
+
* bounded parallel. The result is deterministic (stage outcomes commit in declaration order), so it
|
|
176
|
+
* equals the serial `executeReadGraph` output exactly; only the wall-clock changes.
|
|
166
177
|
*/
|
|
167
178
|
export declare function executeReadGraphAsync(graph: ReadGraph, input: Scope, exec: SqlExecutorAsync): Promise<Value>;
|
|
168
179
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-bundle.d.ts","sourceRoot":"","sources":["../../../src/scp/makesql/static-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,O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