@crvouga/mockingbird-service-sqlite 0.2.0 → 1.0.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/CHANGELOG.md +13 -1
- package/README.md +5 -2
- package/dist/api/database.d.ts +10 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +2 -2
- package/package.json +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-sqlite
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 1.0.0 (2026-09-24)
|
|
4
|
+
|
|
5
|
+
### ⚠️ Breaking changes
|
|
6
|
+
|
|
7
|
+
- vendor branding for every service; purge internal mocks and consumer names ([f689534](https://github.com/crvouga/mockingbird/commit/f6895343543550dafcb7d76b426cae7635e03226))
|
|
8
|
+
|
|
9
|
+
## 0.3.0 (2026-09-22)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
- add deterministic time travel and branching ([a6c341f](https://github.com/crvouga/mockingbird/commit/a6c341f9476f09227a1be4fe830942e4f60c17d9))
|
|
14
|
+
|
|
15
|
+
## 0.2.0 (2026-09-21)
|
|
4
16
|
|
|
5
17
|
### Features
|
|
6
18
|
|
package/README.md
CHANGED
|
@@ -148,10 +148,11 @@ wrapped `bun:sqlite`) also satisfies the port.
|
|
|
148
148
|
| Method | Behaviour |
|
|
149
149
|
| --- | --- |
|
|
150
150
|
| `exec(sql)` | Runs all semicolon-separated statements; **discards** row results (`void`). Does **not** accept bind parameters. Read `db.changes` / `db.lastInsertRowid` afterwards if needed (counters reflect the **most recent** completed statement, matching SQLite). |
|
|
151
|
-
| `query(sql, params?)` | **Single statement only** (trailing `;` is fine). Returns all rows. Multi-statement scripts throw `misuse`. |
|
|
151
|
+
| `query(sql, params?, { at? }?)` | **Single statement only** (trailing `;` is fine). Returns all rows. `at` queries an immutable checkpoint without changing live state. Multi-statement scripts throw `misuse`. |
|
|
152
152
|
| `prepare(sql)` | **Single statement only**. Parses immediately; the AST is reused. Pass binds as rest args to `run` / `all` / `get` / `result` on each call. |
|
|
153
153
|
| `transaction(fn)` | If idle: `BEGIN`, `fn()`, `COMMIT`, or `ROLLBACK` + rethrow. If already in a transaction: nested savepoint. A nested SQL `BEGIN` still errors. `close()` inside `fn` throws `misuse`. |
|
|
154
154
|
| `snapshot()` | Freeze a reusable `Snapshot` template (no encode). Illegal inside a transaction. |
|
|
155
|
+
| `checkpoint()` / `branch(at?)` | Name a COW snapshot as a checkpoint; open an isolated branch from it (or current state). |
|
|
155
156
|
| `Snapshot.open()` | Copy-on-write fork from a template. The parent stays open. |
|
|
156
157
|
| `Snapshot.encode()` | Lazy SQLM blob for persistence / worker boot (computed once, cached). |
|
|
157
158
|
| `Snapshot.decode(bytes)` | Decode a blob once per `Uint8Array` (WeakMap); later `open()` calls are copy-on-write. |
|
|
@@ -305,10 +306,12 @@ interface DatabaseOptions {
|
|
|
305
306
|
class Database {
|
|
306
307
|
constructor(options?: DatabaseOptions)
|
|
307
308
|
exec(sql: string): void
|
|
308
|
-
query<T = QueryRow>(sql: string, params?: readonly BindValue[]): T[]
|
|
309
|
+
query<T = QueryRow>(sql: string, params?: readonly BindValue[], options?: { at?: Snapshot }): T[]
|
|
309
310
|
prepare(sql: string): Statement
|
|
310
311
|
transaction<T>(fn: () => T): T
|
|
311
312
|
snapshot(): Snapshot
|
|
313
|
+
checkpoint(): Snapshot
|
|
314
|
+
branch(at?: Snapshot): Database
|
|
312
315
|
close(): void // also [Symbol.dispose] when available
|
|
313
316
|
readonly changes: number
|
|
314
317
|
readonly lastInsertRowid: number | bigint
|
package/dist/api/database.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { type DatabaseOptions, type RandomMode } from "../runtime/index.js";
|
|
|
2
2
|
import type { BindValue, QueryRow } from "../types/value.js";
|
|
3
3
|
import { type Snapshot } from "./snapshot.js";
|
|
4
4
|
import { Statement } from "./statement.js";
|
|
5
|
+
/** Additive time-travel controls for read APIs. */
|
|
6
|
+
export interface QueryOptions {
|
|
7
|
+
/** Execute against this immutable checkpoint instead of the live database. */
|
|
8
|
+
at?: Snapshot;
|
|
9
|
+
}
|
|
5
10
|
/**
|
|
6
11
|
* Pure TypeScript in-memory SQLite database.
|
|
7
12
|
*
|
|
@@ -53,7 +58,7 @@ export declare class Database {
|
|
|
53
58
|
* @returns All result rows.
|
|
54
59
|
* @throws {SqliteError} If the database is closed, `sql` is not a single statement, or execution fails.
|
|
55
60
|
*/
|
|
56
|
-
query<T = QueryRow>(sql: string, params?: readonly BindValue[]): T[];
|
|
61
|
+
query<T = QueryRow>(sql: string, params?: readonly BindValue[], options?: QueryOptions): T[];
|
|
57
62
|
/**
|
|
58
63
|
* Compile a single SQL statement into a reusable {@link Statement}.
|
|
59
64
|
*
|
|
@@ -81,6 +86,10 @@ export declare class Database {
|
|
|
81
86
|
* @throws {SqliteError} If the database is closed or a transaction is open.
|
|
82
87
|
*/
|
|
83
88
|
snapshot(): Snapshot;
|
|
89
|
+
/** Alias for {@link snapshot}, naming the value as a timeline checkpoint. */
|
|
90
|
+
checkpoint(): Snapshot;
|
|
91
|
+
/** Open a copy-on-write branch from `at`, or from the current state when omitted. */
|
|
92
|
+
branch(at?: Snapshot): Database;
|
|
84
93
|
/**
|
|
85
94
|
* Close the database. Further SQL throws {@link SqliteError}. Idempotent.
|
|
86
95
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* @module
|
|
23
23
|
*/
|
|
24
|
-
export { Database, type DatabaseOptions, Snapshot } from "./api/database.js";
|
|
24
|
+
export { Database, type DatabaseOptions, type QueryOptions, Snapshot } from "./api/database.js";
|
|
25
25
|
export { type RunResult, Statement } from "./api/statement.js";
|
|
26
26
|
export { type ErrorCategory, SqliteError } from "./errors/index.js";
|
|
27
27
|
export type { ResultSet } from "./executor/result.js";
|
package/dist/index.js
CHANGED
|
@@ -15848,8 +15848,9 @@ var Database = class {
|
|
|
15848
15848
|
* @returns All result rows.
|
|
15849
15849
|
* @throws {SqliteError} If the database is closed, `sql` is not a single statement, or execution fails.
|
|
15850
15850
|
*/
|
|
15851
|
-
query(sql, params = []) {
|
|
15851
|
+
query(sql, params = [], options = {}) {
|
|
15852
15852
|
this.assertOpen();
|
|
15853
|
+
if (options.at) return options.at.open().query(sql, params);
|
|
15853
15854
|
return this.prepareSingle(sql).all(...params);
|
|
15854
15855
|
}
|
|
15855
15856
|
/**
|
|
@@ -15917,6 +15918,15 @@ var Database = class {
|
|
|
15917
15918
|
}
|
|
15918
15919
|
return captureSnapshot(this.state, this.prng, this.now, this.seed, this.randomMode, this.systemClock);
|
|
15919
15920
|
}
|
|
15921
|
+
/** Alias for {@link snapshot}, naming the value as a timeline checkpoint. */
|
|
15922
|
+
checkpoint() {
|
|
15923
|
+
return this.snapshot();
|
|
15924
|
+
}
|
|
15925
|
+
/** Open a copy-on-write branch from `at`, or from the current state when omitted. */
|
|
15926
|
+
branch(at = this.snapshot()) {
|
|
15927
|
+
this.assertOpen();
|
|
15928
|
+
return at.open();
|
|
15929
|
+
}
|
|
15920
15930
|
/**
|
|
15921
15931
|
* Close the database. Further SQL throws {@link SqliteError}. Idempotent.
|
|
15922
15932
|
*
|