litedbmodel 2.2.2 → 2.2.3
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 +2 -1
- package/dist/DBModel.d.ts.map +1 -1
- package/dist/DBModel.js +3 -0
- package/dist/DBModel.js.map +1 -1
- package/dist/Middleware.d.ts +19 -2
- package/dist/Middleware.d.ts.map +1 -1
- package/dist/Middleware.js +1 -0
- package/dist/Middleware.js.map +1 -1
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +8 -0
- package/dist/decorators.js.map +1 -1
- package/dist/drivers/MysqlHelper.d.ts +1 -1
- package/dist/drivers/MysqlHelper.d.ts.map +1 -1
- package/dist/drivers/MysqlHelper.js.map +1 -1
- package/dist/drivers/PostgresHelper.d.ts +1 -1
- package/dist/drivers/PostgresHelper.d.ts.map +1 -1
- package/dist/drivers/PostgresHelper.js.map +1 -1
- package/dist/drivers/SqliteHelper.d.ts +1 -1
- package/dist/drivers/SqliteHelper.d.ts.map +1 -1
- package/dist/drivers/SqliteHelper.js.map +1 -1
- package/dist/index.cjs +99 -33
- package/dist/scp/connection-routing.d.ts +38 -1
- package/dist/scp/connection-routing.d.ts.map +1 -1
- package/dist/scp/connection-routing.js +64 -5
- package/dist/scp/connection-routing.js.map +1 -1
- package/dist/scp/dbmodel-runtime.d.ts +2 -1
- package/dist/scp/dbmodel-runtime.d.ts.map +1 -1
- package/dist/scp/dbmodel-runtime.js +2 -1
- package/dist/scp/dbmodel-runtime.js.map +1 -1
- package/dist/scp/decorator-adapter.d.ts +22 -0
- package/dist/scp/decorator-adapter.d.ts.map +1 -1
- package/dist/scp/decorator-adapter.js +26 -0
- package/dist/scp/decorator-adapter.js.map +1 -1
- package/dist/scp/emit/emitter.d.ts +21 -10
- package/dist/scp/emit/emitter.d.ts.map +1 -1
- package/dist/scp/emit/emitter.js +119 -51
- package/dist/scp/emit/emitter.js.map +1 -1
- package/dist/scp/emit/endpoint.d.ts +3 -8
- package/dist/scp/emit/endpoint.d.ts.map +1 -1
- package/dist/scp/exec-context.d.ts +39 -17
- package/dist/scp/exec-context.d.ts.map +1 -1
- package/dist/scp/exec-context.js +69 -35
- package/dist/scp/exec-context.js.map +1 -1
- package/dist/scp/grouping.d.ts.map +1 -1
- package/dist/scp/grouping.js +0 -0
- package/dist/scp/grouping.js.map +1 -1
- package/dist/scp/index.cjs +251 -629
- package/dist/scp/index.d.ts +6 -11
- package/dist/scp/index.d.ts.map +1 -1
- package/dist/scp/index.js +10 -28
- package/dist/scp/index.js.map +1 -1
- package/dist/scp/index.mjs +251 -617
- package/dist/scp/leaf-transport.d.ts +127 -39
- package/dist/scp/leaf-transport.d.ts.map +1 -1
- package/dist/scp/leaf-transport.js +30 -24
- package/dist/scp/leaf-transport.js.map +1 -1
- package/dist/scp/leaves.d.ts +57 -20
- package/dist/scp/leaves.d.ts.map +1 -1
- package/dist/scp/leaves.js +224 -65
- package/dist/scp/leaves.js.map +1 -1
- package/dist/scp/makesql/compile-select.d.ts +28 -1
- package/dist/scp/makesql/compile-select.d.ts.map +1 -1
- package/dist/scp/makesql/compile-select.js +19 -17
- package/dist/scp/makesql/compile-select.js.map +1 -1
- package/dist/scp/makesql/index.d.ts +2 -2
- package/dist/scp/makesql/index.d.ts.map +1 -1
- package/dist/scp/makesql/index.js +4 -6
- package/dist/scp/makesql/index.js.map +1 -1
- package/dist/scp/makesql/tx.d.ts +27 -69
- package/dist/scp/makesql/tx.d.ts.map +1 -1
- package/dist/scp/makesql/tx.js +26 -448
- package/dist/scp/makesql/tx.js.map +1 -1
- package/dist/scp/middleware.d.ts +4 -4
- package/dist/scp/middleware.d.ts.map +1 -1
- package/dist/scp/middleware.js +2 -2
- package/dist/scp/middleware.js.map +1 -1
- package/dist/scp/relation.d.ts +31 -12
- package/dist/scp/relation.d.ts.map +1 -1
- package/dist/scp/relation.js +16 -6
- package/dist/scp/relation.js.map +1 -1
- package/dist/scp/typed-object.d.ts +23 -19
- package/dist/scp/typed-object.d.ts.map +1 -1
- package/dist/scp/typed-object.js +24 -30
- package/dist/scp/typed-object.js.map +1 -1
- package/dist/scp/write-bundle.d.ts +21 -70
- package/dist/scp/write-bundle.d.ts.map +1 -1
- package/dist/scp/write-bundle.js +15 -79
- package/dist/scp/write-bundle.js.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/docs/architecture.md +452 -0
- package/docs/design/phase-a-execution-context.md +2 -0
- package/package.json +14 -3
- package/dist/scp/writes.d.ts +0 -251
- package/dist/scp/writes.d.ts.map +0 -1
- package/dist/scp/writes.js +0 -176
- package/dist/scp/writes.js.map +0 -1
- package/docs/proposal/contracts-architecture-feasibility.md +0 -328
- package/docs/proposal/contracts-architecture.md +0 -579
- package/docs/proposal/litedbmodel-v2-scp-architecture.md +0 -433
- package/docs/proposal/sql-dynamic-expansion-spec.md +0 -175
- package/docs/proposal/v0-coverage-matrix.md +0 -157
- package/docs/proposal/v2-completeness-plan.md +0 -90
- package/docs/proposal/v2-sql-parity-checklist.md +0 -162
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* catalog leaf + handler + compile. Pure-JSON bundle, multi-language ready.
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
14
|
-
exports.mysqlPoolFactory = exports.pgPoolFactory = exports.mysqlConnectionPool = exports.pgConnectionPool = exports.mysqlDeboxPoolOptions = exports.configurePgDeboxTypeParsers = exports.bindReselect = exports.buildMysqlReselect = exports.stripMysqlPkHint = exports.mysqlPkHint = exports.IN_SENTINEL = exports.
|
|
13
|
+
exports.pgTypeSpecimen = exports.compileWriteNode = exports.renderTxStatement = exports.executeTransactionAsync = exports.literalize = exports.deriveBatchPlan = exports.rowsHaveDbToken = exports.mysqlJsonTableColumn = exports.sqliteUpdateManyJson = exports.mysqlUpdateManyJson = exports.sqliteInsertJson = exports.mysqlInsertJson = exports.conditionsFor = exports.JsonArrayConditions = exports.encodeJsonArrayParam = exports.inListPredicate = exports.inListJson = exports.compileCompositeKeyStaticLimited = exports.compileCompositeKeyLimited = exports.compileCompositeKeyStaticUnlimited = exports.compileCompositeKeyUnlimited = exports.compileSingleKeyLimited = exports.compileSingleKeyUnlimited = exports.PG_ARRAY_CAST_TOKEN = exports.resolvePgArrayCast = exports.inferPgArrayType = exports.compileDeleteMany = exports.compileDelete = exports.compileUpdateSingle = exports.compileUpdateMany = exports.compileInsertMany = exports.compileInsert = exports.builderFor = exports.compileSelect = exports.noCastFormatter = exports.pgCastFormatter = exports.formatterFor = exports.andTrailing = exports.whereClause = exports.compileWhere = exports.makeSqlHandlerSync = exports.makeSqlHandler = exports.renderPorts = exports.renderPlaceholders = exports.composeMakeSQL = exports.assembleMakeSQL = exports.isMakeSQL = exports.LITEDBMODEL_MAKESQL_CATALOG = exports.makeSqlCatalogEntry = exports.MAKESQL = void 0;
|
|
14
|
+
exports.mysqlPoolFactory = exports.pgPoolFactory = exports.mysqlConnectionPool = exports.pgConnectionPool = exports.mysqlDeboxPoolOptions = exports.configurePgDeboxTypeParsers = exports.bindReselect = exports.buildMysqlReselect = exports.stripMysqlPkHint = exports.mysqlPkHint = exports.IN_SENTINEL = exports.ENTITY_ROOT = void 0;
|
|
15
15
|
// Catalog leaf + assembly core.
|
|
16
16
|
var makesql_1 = require("./makesql");
|
|
17
17
|
Object.defineProperty(exports, "MAKESQL", { enumerable: true, get: function () { return makesql_1.MAKESQL; } });
|
|
@@ -72,17 +72,15 @@ Object.defineProperty(exports, "mysqlUpdateManyJson", { enumerable: true, get: f
|
|
|
72
72
|
Object.defineProperty(exports, "sqliteUpdateManyJson", { enumerable: true, get: function () { return json_batch_1.sqliteUpdateManyJson; } });
|
|
73
73
|
Object.defineProperty(exports, "mysqlJsonTableColumn", { enumerable: true, get: function () { return json_batch_1.mysqlJsonTableColumn; } });
|
|
74
74
|
Object.defineProperty(exports, "rowsHaveDbToken", { enumerable: true, get: function () { return json_batch_1.rowsHaveDbToken; } });
|
|
75
|
-
// Write
|
|
75
|
+
// Write descriptor → makeSQL statement, batch plan derivation, and the live async 1-tx runtime.
|
|
76
76
|
var tx_1 = require("./tx");
|
|
77
|
-
Object.defineProperty(exports, "deriveTransactionPlan", { enumerable: true, get: function () { return tx_1.deriveTransactionPlan; } });
|
|
78
77
|
Object.defineProperty(exports, "deriveBatchPlan", { enumerable: true, get: function () { return tx_1.deriveBatchPlan; } });
|
|
79
78
|
Object.defineProperty(exports, "literalize", { enumerable: true, get: function () { return tx_1.literalize; } });
|
|
80
|
-
Object.defineProperty(exports, "executeTransaction", { enumerable: true, get: function () { return tx_1.executeTransaction; } });
|
|
81
79
|
Object.defineProperty(exports, "executeTransactionAsync", { enumerable: true, get: function () { return tx_1.executeTransactionAsync; } });
|
|
82
|
-
Object.defineProperty(exports, "countingDriver", { enumerable: true, get: function () { return tx_1.countingDriver; } });
|
|
83
80
|
Object.defineProperty(exports, "renderTxStatement", { enumerable: true, get: function () { return tx_1.renderTxStatement; } });
|
|
84
81
|
Object.defineProperty(exports, "compileWriteNode", { enumerable: true, get: function () { return tx_1.compileWriteNode; } });
|
|
85
82
|
Object.defineProperty(exports, "pgTypeSpecimen", { enumerable: true, get: function () { return tx_1.pgTypeSpecimen; } });
|
|
83
|
+
Object.defineProperty(exports, "ENTITY_ROOT", { enumerable: true, get: function () { return tx_1.ENTITY_ROOT; } });
|
|
86
84
|
Object.defineProperty(exports, "IN_SENTINEL", { enumerable: true, get: function () { return tx_1.IN_SENTINEL; } });
|
|
87
85
|
// MySQL has no RETURNING: the pk-hint format + the write→re-select derivation the mysql connection
|
|
88
86
|
// adapter (and the 4 native driver ports) share. ONE home for "MySQL cannot RETURN rows".
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scp/makesql/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;AAEH,gCAAgC;AAChC,qCAOmB;AANjB,kGA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;AAClC,8HAAA,0BAA0B,OAAA;AAC1B,oIAAA,gCAAgC,OAAA;AAIlC,gFAAgF;AAChF,wFAAwF;AACxF,2CAAqH;AAA5G,wGAAA,UAAU,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,kHAAA,oBAAoB,OAAA;AAAE,iHAAA,mBAAmB,OAAA;AAAE,2GAAA,aAAa,OAAA;AAC9F,2CAOsB;AANpB,6GAAA,eAAe,OAAA;AACf,8GAAA,gBAAgB,OAAA;AAChB,iHAAA,mBAAmB,OAAA;AACnB,kHAAA,oBAAoB,OAAA;AACpB,kHAAA,oBAAoB,OAAA;AACpB,6GAAA,eAAe,OAAA;AAGjB,gGAAgG;AAChG,2BASc;AARZ,qGAAA,eAAe,OAAA;AACf,gGAAA,UAAU,OAAA;AACV,6GAAA,uBAAuB,OAAA;AACvB,uGAAA,iBAAiB,OAAA;AACjB,sGAAA,gBAAgB,OAAA;AAChB,oGAAA,cAAc,OAAA;AACd,iGAAA,WAAW,OAAA;AACX,iGAAA,WAAW,OAAA;AAGb,mGAAmG;AACnG,0FAA0F;AAC1F,qDAAoG;AAA3F,8GAAA,WAAW,OAAA;AAAE,mHAAA,gBAAgB,OAAA;AAAE,qHAAA,kBAAkB,OAAA;AAAE,+GAAA,YAAY,OAAA;AAgBxE,mGAAmG;AACnG,oDAAoD;AACpD,iDAA6J;AAApJ,4HAAA,2BAA2B,OAAA;AAAE,sHAAA,qBAAqB,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AAAE,oHAAA,mBAAmB,OAAA;AAAE,8GAAA,aAAa,OAAA;AAAE,iHAAA,gBAAgB,OAAA"}
|
package/dist/scp/makesql/tx.d.ts
CHANGED
|
@@ -1,42 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* litedbmodel v2 SCP — write
|
|
3
|
-
* the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* bc Expression IR refs resolved at execute time against the accumulated transaction scope.
|
|
2
|
+
* litedbmodel v2 SCP — the write descriptor → makeSQL statement compiler ({@link compileWriteNode}),
|
|
3
|
+
* the BATCH transaction-plan derivation ({@link deriveBatchPlan}), and the live async 1-tx runtime
|
|
4
|
+
* ({@link executeTransactionAsync}). No reduced IR is emitted anywhere: every statement's SQL is
|
|
5
|
+
* COMPLETE tuned text (byte-identical to what the v1 write path sends — `INSERT … ON CONFLICT DO
|
|
6
|
+
* NOTHING`, `UPDATE … SET c = ?`, `DELETE FROM … WHERE …`), and its `params` are closed-set bc
|
|
7
|
+
* Expression IR refs resolved at execute time against the transaction scope.
|
|
9
8
|
*
|
|
10
9
|
* A statement op is exactly a `makeSQL` template: `{ sql, params }` where `sql` carries `?`
|
|
11
10
|
* placeholders and `params` are Expression IR (`{ref:[…]}` / a literal / a `{obj:{…}}` payload)
|
|
12
11
|
* that bc evaluates per statement — then the concrete values assemble + render + bind through
|
|
13
12
|
* the SAME `assembleMakeSQL` / `renderPlaceholders` the read path uses.
|
|
14
13
|
*
|
|
15
|
-
*
|
|
14
|
+
* A BATCH write (createMany / updateMany / deleteMany) is ONE logical op that produces N grouped
|
|
15
|
+
* statements; {@link deriveBatchPlan} lowers those into a gate-free {@link TransactionPlan}
|
|
16
|
+
* (`entityFrom` null, every statement `role:'body'`), run in the declared order as ONE transaction.
|
|
17
|
+
* The single-row and read paths are lowered by `bc generate` into a native module per language and
|
|
18
|
+
* never reach this runtime; there is no runtime read-compile and no runtime single-write compile.
|
|
16
19
|
*
|
|
17
|
-
*
|
|
18
|
-
* failing gate short-circuits — the remaining statements never execute and the tx ROLLBACKs.
|
|
20
|
+
* ## Gate short-circuit (still supported by the runtime)
|
|
19
21
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* `$.entity.<f>` → `{ref:['__entity','<f>']}` (the sole body write's RETURNING row)
|
|
24
|
-
* `$.ref.<w>.<f>` → `{ref:['<w>','<f>']}` (a named upstream write's RETURNING row)
|
|
25
|
-
*
|
|
26
|
-
* ## tx-DAG derivation (spec §6 / §14) — gate-first + data-dependency topo order
|
|
27
|
-
*
|
|
28
|
-
* Statements form a data-dependency DAG (`$.ref.<w>.*` consumes an earlier write's RETURNING
|
|
29
|
-
* row via `TxStatement.binds`) with a gate-first constraint. A deterministic Kahn topo sort
|
|
30
|
-
* (stable ascending declaration `seq` tie-break) orders them into a single-transaction plan.
|
|
31
|
-
* Underivable shapes (cycle, dangling `$.ref`, referenced write without RETURNING, duplicate
|
|
32
|
-
* bind, composite `$.entity`) are LOUD rejects — never a silently mis-ordered plan.
|
|
22
|
+
* A statement MAY carry a {@link GateRule} the runtime evaluates AFTER executing it: a failing gate
|
|
23
|
+
* short-circuits — the remaining statements never execute and the tx ROLLBACKs. The batch plans
|
|
24
|
+
* derived here carry no gates; the rule survives for a caller that hands the runtime a gated plan.
|
|
33
25
|
*/
|
|
34
26
|
import { type Scope } from 'behavior-contracts/runtime';
|
|
35
27
|
import { type ColumnTypeResolver } from '../coltype';
|
|
36
28
|
import { type Dialect as MakeSQLDialect } from './handler';
|
|
37
|
-
import { type
|
|
29
|
+
import { type PooledAsyncContext } from '../exec-context';
|
|
38
30
|
import { type TransactionOptions } from '../tx-options';
|
|
39
|
-
import { type LifecycleContract, type LifecycleEffects, type WriteLifecyclePhase } from '../writes';
|
|
40
31
|
/** A closed-set bc Expression IR node used as a `makeSQL` deferred param (ref / literal / obj). */
|
|
41
32
|
export type TxExpr = unknown;
|
|
42
33
|
/**
|
|
@@ -108,6 +99,17 @@ export interface TxOp {
|
|
|
108
99
|
}
|
|
109
100
|
/** The role a transaction statement plays (drives the runtime's gate-first interpretation). */
|
|
110
101
|
export type StatementRole = 'gate:requires' | 'gate:idempotency' | 'gate:unique' | 'body' | 'derive' | 'edge' | 'emit';
|
|
102
|
+
/**
|
|
103
|
+
* The write intent a {@link TransactionPlan} carries. It labels the plan the BATCH compilers derive
|
|
104
|
+
* (`createMany` ⇒ `create`, `updateMany` ⇒ `update`, `deleteMany` ⇒ `remove`) so a consumer can tell
|
|
105
|
+
* the three apart without re-reading the SQL.
|
|
106
|
+
*/
|
|
107
|
+
export type WriteLifecyclePhase = 'create' | 'update' | 'remove';
|
|
108
|
+
/**
|
|
109
|
+
* The reserved scope key the tx runtime binds the plan's `entityFrom` row under, so a later statement
|
|
110
|
+
* that references the written row resolves against it. Reserved: no input field may use this name.
|
|
111
|
+
*/
|
|
112
|
+
export declare const ENTITY_ROOT = "__entity";
|
|
111
113
|
/** The gate rule the runtime evaluates on a gate statement's result to decide short-circuit. */
|
|
112
114
|
export type GateRule = 'existsElseRollback' | 'insertedElseRollback' | 'insertedElseNoop';
|
|
113
115
|
/** One ordered statement of a transaction plan (pure JSON — a makeSQL template + its role). */
|
|
@@ -134,7 +136,6 @@ export interface TransactionPlan {
|
|
|
134
136
|
readonly statements: readonly TxStatement[];
|
|
135
137
|
readonly onIdempotentHit: IdempotentHitPolicy;
|
|
136
138
|
}
|
|
137
|
-
/** The reserved column-ref path head that marks an IN-list membership (mirrors the bridge). */
|
|
138
139
|
export declare const IN_SENTINEL = "@in";
|
|
139
140
|
type WriteComponent = 'Insert' | 'Update' | 'Delete' | 'Select';
|
|
140
141
|
interface WriteNodeLike {
|
|
@@ -171,22 +172,6 @@ export declare function pkPort(ports: Record<string, unknown>): {
|
|
|
171
172
|
* are CANONICAL (alphabetical) sorted — the v2 write-path SSoT (matches `DBModel._insert`).
|
|
172
173
|
*/
|
|
173
174
|
export declare function compileWriteNode(node: WriteNodeLike, dialect?: MakeSQLDialect, resolveColumnType?: ColumnTypeResolver): TxOp;
|
|
174
|
-
/** The base write op the Command declares (`Insert`/`Update`/`Delete` with `onWrite`). */
|
|
175
|
-
export interface BaseWrite {
|
|
176
|
-
/** The compiled base write makeSQL op (complete `sql` + deferred Expression-IR `params`). */
|
|
177
|
-
readonly op: TxOp;
|
|
178
|
-
readonly label: string;
|
|
179
|
-
/** The write's stable NAME (composite scope) — referenced downstream as `$.ref.<name>.*`. */
|
|
180
|
-
readonly name?: string;
|
|
181
|
-
/** The write's OWN save-contract effects (composite scope). */
|
|
182
|
-
readonly effects?: LifecycleEffects;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Derive the ORDERED, gate-first {@link TransactionPlan} from a Command's base write(s) + its
|
|
186
|
-
* lifecycle save contract (spec §6 / §14). Single base write = fixed §6 group; multiple named
|
|
187
|
-
* base writes = a topologically-ordered gate-first tx DAG (`$.ref.<name>.*` data dependencies).
|
|
188
|
-
*/
|
|
189
|
-
export declare function deriveTransactionPlan(phase: WriteLifecyclePhase, bases: readonly BaseWrite[], lifecycle: LifecycleContract, dialect?: MakeSQLDialect): TransactionPlan;
|
|
190
175
|
/**
|
|
191
176
|
* Lower a list of CONCRETE batch-write ops (createMany / updateMany / deleteMany — each already
|
|
192
177
|
* compiled by driving the v1 builders in `compile-crud`, so its `sql` is byte-identical to v1 and
|
|
@@ -205,15 +190,6 @@ export declare function deriveBatchPlan(phase: WriteLifecyclePhase, ops: readonl
|
|
|
205
190
|
params: readonly unknown[];
|
|
206
191
|
label?: string;
|
|
207
192
|
}[]): TransactionPlan;
|
|
208
|
-
/**
|
|
209
|
-
* The minimal synchronous SQLite driver surface the tx runtime needs (better-sqlite3) — the
|
|
210
|
-
* backward-compat public seam. Internally the tx runs through the {@link ExecutionContext} seam
|
|
211
|
-
* (`../exec-context`); a raw driver passed here is wrapped via {@link contextForDriver}. Aliased to
|
|
212
|
-
* {@link SqliteDriver}.
|
|
213
|
-
*/
|
|
214
|
-
export type SqliteDb = SqliteDriver;
|
|
215
|
-
/** A tx entry accepts either a raw {@link SqliteDb} or a full {@link ExecutionContext}. */
|
|
216
|
-
export type DbOrContext = SqliteDb | ExecutionContext;
|
|
217
193
|
/** Why a transaction did not commit (a gate short-circuit outcome; not a driver error). */
|
|
218
194
|
export type ShortCircuitReason = 'requires_absent' | 'unique_collision' | 'idempotent_duplicate';
|
|
219
195
|
/** The structured outcome of executing a {@link TransactionPlan}. */
|
|
@@ -234,24 +210,6 @@ export interface TransactionResult {
|
|
|
234
210
|
*/
|
|
235
211
|
readonly returnedRows?: readonly (readonly Record<string, unknown>[])[];
|
|
236
212
|
}
|
|
237
|
-
/**
|
|
238
|
-
* Execute a derived {@link TransactionPlan} as ONE real SQLite transaction with gate-first
|
|
239
|
-
* short-circuit. Accepts a raw {@link SqliteDb} (wrapped via {@link contextForDriver}) or a full
|
|
240
|
-
* {@link ExecutionContext}. The transaction derives a tx-scoped ctx (`withConnection(conn, true)`)
|
|
241
|
-
* that PINS one connection so BEGIN, every body statement, and COMMIT/ROLLBACK all run on the SAME
|
|
242
|
-
* connection (§3, per-execution ownership). For the single-DB SQLite driver the pinned connection
|
|
243
|
-
* is the sole connection; the ownership shows its teeth on the pooled async path
|
|
244
|
-
* ({@link import('../exec-context').withTransactionAsync}), which this mirrors.
|
|
245
|
-
*/
|
|
246
|
-
export declare function executeTransaction(db: DbOrContext, plan: TransactionPlan, input: Scope, dialect?: MakeSQLDialect): TransactionResult;
|
|
247
|
-
/**
|
|
248
|
-
* A counting {@link SqliteDb} wrapper: forwards every call to the wrapped driver but records
|
|
249
|
-
* each PREPARED SQL string. Tests use it to PROVE gate-first short-circuit.
|
|
250
|
-
*/
|
|
251
|
-
export declare function countingDriver(db: SqliteDb): {
|
|
252
|
-
db: SqliteDb;
|
|
253
|
-
prepared: string[];
|
|
254
|
-
};
|
|
255
213
|
/** Render one statement op to its dialect SQL text + params (exposed for golden tests). */
|
|
256
214
|
export declare function renderTxStatement(op: TxOp, scope: Scope, dialect?: MakeSQLDialect): {
|
|
257
215
|
sql: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../src/scp/makesql/tx.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../../src/scp/makesql/tx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH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