@baukit/data-contracts-expo-sqlite 0.4.0 → 0.5.1

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 CHANGED
@@ -33,20 +33,202 @@ await storage.withTransaction((transaction) =>
33
33
  ```
34
34
 
35
35
  Nested calls made on the transaction-scoped context join the ambient exclusive
36
- transaction. Independent root calls are serialized. `close()` closes the
37
- logical adapter; pass `{ closeDatabase: true }` when it should also own the
38
- supplied database handle.
36
+ transaction. `close()` closes the logical adapter; pass
37
+ `{ closeDatabase: true }` when it should also own the supplied database handle.
39
38
 
40
39
  Namespaces share one fixed `baukit_records` table without colliding. Call `initialize()` before using a store. Records are serialized as JSON, pagination is bounded and keyset-based, and malformed persisted payloads produce a content-free error.
41
40
 
42
- The package's fast Vitest suite uses a deterministic database fake. The
41
+ ## Operation ordering
42
+
43
+ Expo SQLite runs `withExclusiveTransactionAsync` on a second connection to the
44
+ same file. A statement on the base handle that runs while that transaction is
45
+ open fails with `database is locked`. The adapter therefore runs root reads,
46
+ root writes, `initialize()`, `withTransaction()`, and `close()` one at a time,
47
+ in call order, on one queue per database file (`SQLiteDatabase.databasePath`).
48
+ Every `ExpoSqliteStore`, `SqliteRecordStore`, `SqliteKeyValueStore`, and
49
+ `SqliteSchemaMetadataStore` on that file shares the queue, whichever handle and
50
+ namespace it uses. Stores on different files do not wait for each other.
51
+
52
+ - Work on the transaction context runs on the transaction connection and never
53
+ enters the queue.
54
+ - A rejected operation releases the queue for the next caller.
55
+ - `close()` rejects new calls with `storage_closed`, waits for work it already
56
+ accepted, closes an owned handle once, and returns the same promise to every
57
+ caller, including a rejected one.
58
+ - Lock errors from SQLite reach the caller unchanged. The adapter never retries.
59
+
60
+ Inside a `withTransaction` callback, use the context it passes in. A root call
61
+ on any store for the same file queues behind the transaction, the transaction
62
+ waits for that call, and neither finishes. Keep network and file work outside the
63
+ callback, because it holds the queue for every store on that file. Raw
64
+ statements a product runs on the handle itself bypass the queue. Run them
65
+ through `ExpoSqliteConnection` instead.
66
+
67
+ The package's fast Vitest suite runs the shared contracts against a deterministic
68
+ database fake and against `NodeSqliteDatabase` (see below). The
43
69
  [Expo SQLite device-conformance app](../../../examples/expo-sqlite-conformance/README.md)
44
70
  mirrors the shared contract cases against real `expo-sqlite` on Android,
45
71
  including creation/reopening, namespace isolation, malformed data, rollback,
46
- schema-metadata upgrades, and authenticated E→F→E database isolation. Products
72
+ schema-metadata upgrades, root-versus-transaction overlap in both arrival
73
+ orders, `ExpoSqliteConnection` ordering, foreign keys, and rollback next to
74
+ `ExpoSqliteStore`, and authenticated E→F→E database isolation. Products
47
75
  derive the database name and resolve its registry with `@baukit/data-contracts`
48
76
  before opening the Expo database. iOS is a scheduled/manual macOS gate.
49
77
 
78
+ ## Raw SQL connection
79
+
80
+ `ExpoSqliteConnection` runs a product's own SQL, such as a relational schema
81
+ and its migration runner, on the same per-file queue as the stores above.
82
+
83
+ ```ts
84
+ import { ExpoSqliteConnection } from '@baukit/data-contracts-expo-sqlite';
85
+
86
+ const connection = new ExpoSqliteConnection(database);
87
+ await connection.exec('CREATE TABLE IF NOT EXISTS notes (id TEXT PRIMARY KEY, body TEXT)');
88
+ await connection.transaction(async (transaction) => {
89
+ await transaction.run('INSERT INTO notes (id, body) VALUES (?, ?)', 'one', 'first');
90
+ return transaction.get<{ readonly body: string }>('SELECT body FROM notes WHERE id = ?', 'one');
91
+ });
92
+ ```
93
+
94
+ - `exec(source)` runs a script without parameters. `run`, `get`, and `all`
95
+ bind parameters as `expo-sqlite` does: variadic values, one array, or one
96
+ object whose keys keep their `$`, `:`, or `@` prefix. `run` resolves to
97
+ `{ changes, lastInsertRowId }`, `get` to the first row or `undefined`, and
98
+ `all` to every row.
99
+ - Every root statement, `transaction()`, and `close()` waits its turn on the
100
+ queue that every store on the same database file shares. A root statement
101
+ that another caller issues while a transaction is open runs after that
102
+ transaction commits or rolls back, never inside it.
103
+ - `transaction(work)` runs `BEGIN IMMEDIATE` on the supplied handle, commits
104
+ when `work` resolves, and rolls back when `work` or the commit rejects. The
105
+ original error reaches the caller unchanged, and the result of `work` is
106
+ returned.
107
+ - The transaction context has the same statement methods. After the
108
+ transaction settles, its statements reject with `storage_closed`.
109
+ - The context's `transaction(work)` nests: it runs `SAVEPOINT` on the same
110
+ handle without waiting on the queue, so it never deadlocks behind the
111
+ transaction that holds the queue. It releases the savepoint when `work`
112
+ resolves and returns the result. When `work` rejects, it rolls back to the
113
+ savepoint, undoing only the nested statements and schema changes, and
114
+ rejects with the same error. The enclosing transaction rolls back too unless
115
+ the caller catches that error. Released nested work still rolls back when an
116
+ enclosing level fails. Nesting has no depth limit.
117
+ - Only the innermost open level accepts work. While a nested transaction is
118
+ open, statements and `transaction()` on any enclosing context reject with a
119
+ `TypeError`, so run sibling nested transactions one after another, not with
120
+ `Promise.all`.
121
+ - The connection runs `PRAGMA foreign_keys = ON` on the handle before its
122
+ first statement. Because transactions run on that handle, foreign keys and
123
+ `ON DELETE` actions stay enforced inside them. A step that must rebuild a
124
+ table can still run `PRAGMA foreign_keys = OFF` as a root statement before
125
+ its transaction and turn it back on afterwards.
126
+ - `close()` rejects new calls with `storage_closed`, waits for accepted work,
127
+ and closes the handle only with `{ closeDatabase: true }`.
128
+ - SQLite errors, including `database is locked`, pass through unchanged, and
129
+ nothing retries.
130
+
131
+ The connection does not use `withExclusiveTransactionAsync`. Expo runs `BEGIN`
132
+ on the new connection before calling the task, and SQLite ignores
133
+ `PRAGMA foreign_keys` inside a transaction, so a second connection would leave
134
+ foreign keys off with no way to turn them on.
135
+
136
+ The same deadlock rule as `withTransaction` applies: inside `work`, use the
137
+ transaction context, and nest through its `transaction()`. A root call on the
138
+ connection or on any store for the same file queues behind the transaction and
139
+ never finishes.
140
+
141
+ A helper typed against `Pick<SqliteTransaction, 'transaction'>` accepts both
142
+ the connection and a transaction context, so a repository method that opens
143
+ its own transaction runs alone at the root or as a savepoint inside a caller's
144
+ transaction.
145
+
146
+ This differs from `ExpoSqliteStore.withTransaction`, whose nested calls join
147
+ the ambient transaction as the shared storage contract requires.
148
+
149
+ ## Node tests
150
+
151
+ `@baukit/data-contracts-expo-sqlite/testing` runs Expo SQLite code in Node unit
152
+ tests (Vitest or Jest) on Node's built-in `node:sqlite`. It needs Node 24 or
153
+ later and adds no dependency.
154
+
155
+ ```ts
156
+ import { ExpoSqliteStore } from '@baukit/data-contracts-expo-sqlite';
157
+ import { NodeSqliteDatabase } from '@baukit/data-contracts-expo-sqlite/testing';
158
+
159
+ const database = new NodeSqliteDatabase();
160
+ const storage = new ExpoSqliteStore<CachedRecord>(database, 'product', { closeDatabase: true });
161
+ await storage.initialize();
162
+ ```
163
+
164
+ `NodeSqliteDatabase` implements `ExpoSqliteDatabase`, the part of an Expo
165
+ `SQLiteDatabase` that this adapter calls: `databasePath`, `execAsync`,
166
+ `runAsync`, `getFirstAsync`, `getAllAsync`, `withExclusiveTransactionAsync`, and
167
+ `closeAsync`. A product driver typed against those methods accepts it without a
168
+ cast. With no argument it opens a new temporary file and deletes it on
169
+ `closeAsync()`. With a path it opens that file and leaves it in place, so a test
170
+ can close and reopen the same database. `:memory:` throws a `TypeError`, because
171
+ an exclusive transaction must open a second connection to the same database.
172
+
173
+ It copies the device behavior that product tests tend to hide:
174
+
175
+ - `withExclusiveTransactionAsync` runs `BEGIN`, the task, and `COMMIT` on a new
176
+ connection to the same file, and rolls back when the task throws. A write on
177
+ the root handle while that transaction is open fails with `database is locked`.
178
+ - Every connection opens with foreign keys off. `PRAGMA foreign_keys = ON` on
179
+ the root handle does not reach transaction connections.
180
+ - Booleans and integral numbers bind as integers, `undefined` binds as NULL, and
181
+ named parameters need their `$`, `:`, or `@` prefix.
182
+ - Rows are plain objects, and `getFirstAsync` returns `null` for no row.
183
+
184
+ It differs from the device in three places. An unknown named parameter or an
185
+ extra positional value throws instead of being ignored. A root read during an
186
+ open transaction succeeds and sees the committed state. An integer outside the
187
+ safe range throws. It has no `withTransactionAsync`, `prepareAsync`, or
188
+ synchronous methods.
189
+
190
+ Jest projects that transform `@baukit/*` through Babel resolve the entry through
191
+ its `default` condition.
192
+
193
+ ## Migration runner conformance
194
+
195
+ `createSqliteMigrationConformanceTests(adapter)` returns framework-neutral cases
196
+ for a product's own SQLite migration runner. Register each with your test
197
+ runner:
198
+
199
+ ```ts
200
+ import {
201
+ createSqliteMigrationConformanceTests,
202
+ type SqliteMigrationConformanceAdapter,
203
+ } from '@baukit/data-contracts-expo-sqlite/testing';
204
+
205
+ const adapter: SqliteMigrationConformanceAdapter = {
206
+ migrate: (database, steps) => runMigrations(new ProductSqliteDriver(database), steps),
207
+ };
208
+
209
+ for (const testCase of createSqliteMigrationConformanceTests(adapter)) {
210
+ it(testCase.name, testCase.run);
211
+ }
212
+ ```
213
+
214
+ `migrate` receives a `NodeSqliteDatabase` and a list of
215
+ `{ version, name, sql }` steps, the complete list that one app build ships. It
216
+ must reject when the runner fails or refuses the database. The cases check that
217
+ the runner:
218
+
219
+ - applies every step to a fresh database;
220
+ - upgrades an older database and keeps its rows;
221
+ - applies nothing again after a restart;
222
+ - rolls back a failed step completely, with no table or column from its earlier
223
+ statements left behind, and applies the fixed step after a restart;
224
+ - refuses a database that a newer build migrated, and leaves it unchanged.
225
+
226
+ The suite does not read the runner's history table or `user_version`, so any
227
+ runner that records versions somewhere passes. A step's `sql` holds several
228
+ statements, so the runner must execute it as a script (`execAsync`). Each case
229
+ uses its own temporary file. A failed case throws an error that starts with
230
+ `SQLite migration conformance failed:` and names the broken expectation.
231
+
50
232
  ## Boundaries
51
233
 
52
234
  The package implements `@baukit/data-contracts` on Expo SQLite and nothing else. It does not choose a
@@ -0,0 +1,68 @@
1
+ import type { SQLiteBindParams, SQLiteRunResult, SQLiteVariadicBindParams } from 'expo-sqlite';
2
+ import { type ExpoSqliteDatabase } from './queued-database.js';
3
+ import type { StatementScope } from './statements.js';
4
+ type TransactionWork<TResult> = (transaction: SqliteTransaction) => Promise<TResult> | TResult;
5
+ /**
6
+ * Raw SQL statements. Parameters bind as `expo-sqlite` binds them: variadic values, one array, or
7
+ * one object whose keys keep their `$`, `:`, or `@` prefix.
8
+ */
9
+ export interface SqliteStatements {
10
+ /** Runs a script of one or more statements without parameters. */
11
+ exec(source: string): Promise<void>;
12
+ run(source: string, params: SQLiteBindParams): Promise<SQLiteRunResult>;
13
+ run(source: string, ...params: SQLiteVariadicBindParams): Promise<SQLiteRunResult>;
14
+ /** Resolves to the first row, or `undefined` when there is none. */
15
+ get<TRow>(source: string, params: SQLiteBindParams): Promise<TRow | undefined>;
16
+ get<TRow>(source: string, ...params: SQLiteVariadicBindParams): Promise<TRow | undefined>;
17
+ all<TRow>(source: string, params: SQLiteBindParams): Promise<TRow[]>;
18
+ all<TRow>(source: string, ...params: SQLiteVariadicBindParams): Promise<TRow[]>;
19
+ }
20
+ /**
21
+ * Statements inside one open transaction. They reject with `storage_closed` once the transaction
22
+ * has settled, and with a `TypeError` while a nested transaction started from it is open.
23
+ */
24
+ export interface SqliteTransaction extends SqliteStatements {
25
+ /**
26
+ * Runs `work` in a savepoint inside this transaction, without waiting on the file queue. The
27
+ * savepoint is released when `work` resolves and rolled back when it rejects; the rejection
28
+ * then reaches the caller, and the enclosing transaction commits only if the caller catches it.
29
+ */
30
+ transaction<TResult>(work: TransactionWork<TResult>): Promise<TResult>;
31
+ }
32
+ export interface ExpoSqliteConnectionOptions {
33
+ /** Close the supplied database when this connection closes. Defaults to false. */
34
+ readonly closeDatabase?: boolean;
35
+ }
36
+ declare class ScopedStatements implements SqliteStatements {
37
+ protected readonly scope: StatementScope;
38
+ constructor(scope: StatementScope);
39
+ exec(source: string): Promise<void>;
40
+ run(source: string, params: SQLiteBindParams): Promise<SQLiteRunResult>;
41
+ run(source: string, ...params: SQLiteVariadicBindParams): Promise<SQLiteRunResult>;
42
+ get<TRow>(source: string, params: SQLiteBindParams): Promise<TRow | undefined>;
43
+ get<TRow>(source: string, ...params: SQLiteVariadicBindParams): Promise<TRow | undefined>;
44
+ all<TRow>(source: string, params: SQLiteBindParams): Promise<TRow[]>;
45
+ all<TRow>(source: string, ...params: SQLiteVariadicBindParams): Promise<TRow[]>;
46
+ }
47
+ /**
48
+ * A raw SQL connection over an Expo SQLite database. Statements, transactions, and `close()` run
49
+ * one at a time in call order on the queue that every adapter store on the same database file
50
+ * shares, so a root statement never runs inside another caller's transaction. Transactions run
51
+ * `BEGIN IMMEDIATE` on the supplied handle, and the connection enables foreign keys before its
52
+ * first statement, so they stay enforced inside transactions.
53
+ */
54
+ export declare class ExpoSqliteConnection extends ScopedStatements {
55
+ private readonly root;
56
+ constructor(database: ExpoSqliteDatabase, options?: ExpoSqliteConnectionOptions);
57
+ /**
58
+ * Runs `work` in one transaction that commits when it resolves and rolls back when it rejects.
59
+ * Use only the transaction it receives, and nest through its `transaction()`: a root call on
60
+ * this file from inside `work` waits for the transaction, which waits for `work`, and neither
61
+ * finishes.
62
+ */
63
+ transaction<TResult>(work: TransactionWork<TResult>): Promise<TResult>;
64
+ /** Rejects new work, waits for accepted work, and settles every caller with one result. */
65
+ close(): Promise<void>;
66
+ }
67
+ export {};
68
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,EAAE,KAAK,kBAAkB,EAAkB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAqBxE,KAAK,eAAe,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,iBAAiB,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAE/F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAA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,GAAG,OAAO,CAAC,eAAe,CAAC;IACvE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;IAMlF,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;IAC9E,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;IASzF,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACpE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAOvF;AAkFD;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;IACxD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;gBAEpB,QAAQ,EAAE,kBAAkB,EAAE,OAAO,GAAE,2BAAgC;IAM1F;;;;;OAKG;IACU,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAKnF,2FAA2F;IACpF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
@@ -0,0 +1,172 @@
1
+ import { StorageError } from '@baukit/data-contracts';
2
+ import { QueuedDatabase } from './queued-database.js';
3
+ const ENFORCE_FOREIGN_KEYS = 'PRAGMA foreign_keys = ON';
4
+ const ROOT_DEPTH = 0;
5
+ const SAVEPOINT_PREFIX = 'baukit_nested_';
6
+ const ROOT_BOUNDARY = {
7
+ begin: 'BEGIN IMMEDIATE',
8
+ commit: 'COMMIT',
9
+ rollback: 'ROLLBACK',
10
+ };
11
+ class ScopedStatements {
12
+ scope;
13
+ constructor(scope) {
14
+ this.scope = scope;
15
+ }
16
+ async exec(source) {
17
+ this.scope.assertAvailable();
18
+ await this.scope.run((connection) => connection.execAsync(source));
19
+ }
20
+ async run(source, ...params) {
21
+ this.scope.assertAvailable();
22
+ return this.scope.run((connection) => connection.runAsync(source, ...variadic(params)));
23
+ }
24
+ async get(source, ...params) {
25
+ this.scope.assertAvailable();
26
+ const row = await this.scope.run((connection) => connection.getFirstAsync(source, ...variadic(params)));
27
+ return row ?? undefined;
28
+ }
29
+ async all(source, ...params) {
30
+ this.scope.assertAvailable();
31
+ return this.scope.run((connection) => connection.getAllAsync(source, ...variadic(params)));
32
+ }
33
+ }
34
+ /** One open transaction or savepoint. Only the innermost open level accepts work. */
35
+ class TransactionLevel {
36
+ connection;
37
+ depth;
38
+ active = true;
39
+ nestedOpen = false;
40
+ constructor(connection, depth) {
41
+ this.connection = connection;
42
+ this.depth = depth;
43
+ }
44
+ assertAvailable() {
45
+ if (!this.active) {
46
+ throw new StorageError('storage_closed', 'The transaction context is no longer active.');
47
+ }
48
+ if (this.nestedOpen) {
49
+ throw new TypeError('A nested SQLite transaction is open. Use the nested transaction until it settles.');
50
+ }
51
+ }
52
+ run(statement) {
53
+ return statement(this.connection);
54
+ }
55
+ async nest(work) {
56
+ this.assertAvailable();
57
+ this.nestedOpen = true;
58
+ try {
59
+ return await runLevel(this.connection, this.depth + 1, work);
60
+ }
61
+ finally {
62
+ this.nestedOpen = false;
63
+ }
64
+ }
65
+ finish() {
66
+ this.active = false;
67
+ }
68
+ }
69
+ class ConnectionTransaction extends ScopedStatements {
70
+ level;
71
+ constructor(level) {
72
+ super(level);
73
+ this.level = level;
74
+ }
75
+ transaction(work) {
76
+ return this.level.nest(work);
77
+ }
78
+ }
79
+ /** The root scope: queued on the database file, with foreign keys enabled before any work. */
80
+ class ConnectionScope {
81
+ queued;
82
+ foreignKeysEnforced = false;
83
+ constructor(queued) {
84
+ this.queued = queued;
85
+ }
86
+ assertAvailable() {
87
+ this.queued.assertOpen();
88
+ }
89
+ run(statement) {
90
+ return this.queued.enqueue(async () => {
91
+ await this.enforceForeignKeys();
92
+ return statement(this.queued.database);
93
+ });
94
+ }
95
+ async enforceForeignKeys() {
96
+ if (this.foreignKeysEnforced) {
97
+ return;
98
+ }
99
+ await this.queued.database.execAsync(ENFORCE_FOREIGN_KEYS);
100
+ this.foreignKeysEnforced = true;
101
+ }
102
+ }
103
+ /**
104
+ * A raw SQL connection over an Expo SQLite database. Statements, transactions, and `close()` run
105
+ * one at a time in call order on the queue that every adapter store on the same database file
106
+ * shares, so a root statement never runs inside another caller's transaction. Transactions run
107
+ * `BEGIN IMMEDIATE` on the supplied handle, and the connection enables foreign keys before its
108
+ * first statement, so they stay enforced inside transactions.
109
+ */
110
+ export class ExpoSqliteConnection extends ScopedStatements {
111
+ root;
112
+ constructor(database, options = {}) {
113
+ const root = new ConnectionScope(new QueuedDatabase(database, options.closeDatabase === true));
114
+ super(root);
115
+ this.root = root;
116
+ }
117
+ /**
118
+ * Runs `work` in one transaction that commits when it resolves and rolls back when it rejects.
119
+ * Use only the transaction it receives, and nest through its `transaction()`: a root call on
120
+ * this file from inside `work` waits for the transaction, which waits for `work`, and neither
121
+ * finishes.
122
+ */
123
+ async transaction(work) {
124
+ this.root.assertAvailable();
125
+ return this.root.run((connection) => runLevel(connection, ROOT_DEPTH, work));
126
+ }
127
+ /** Rejects new work, waits for accepted work, and settles every caller with one result. */
128
+ close() {
129
+ return this.root.queued.close();
130
+ }
131
+ }
132
+ function boundaryAt(depth) {
133
+ if (depth === ROOT_DEPTH) {
134
+ return ROOT_BOUNDARY;
135
+ }
136
+ const name = `${SAVEPOINT_PREFIX}${String(depth)}`;
137
+ return {
138
+ begin: `SAVEPOINT ${name}`,
139
+ commit: `RELEASE ${name}`,
140
+ rollback: `ROLLBACK TO ${name}; RELEASE ${name}`,
141
+ };
142
+ }
143
+ async function runLevel(connection, depth, work) {
144
+ const boundary = boundaryAt(depth);
145
+ await connection.execAsync(boundary.begin);
146
+ const level = new TransactionLevel(connection, depth);
147
+ try {
148
+ const result = await work(new ConnectionTransaction(level));
149
+ await connection.execAsync(boundary.commit);
150
+ return result;
151
+ }
152
+ catch (cause) {
153
+ await rollback(connection, boundary);
154
+ throw cause;
155
+ }
156
+ finally {
157
+ level.finish();
158
+ }
159
+ }
160
+ /** Keeps the original failure when SQLite has already rolled the transaction back. */
161
+ async function rollback(connection, boundary) {
162
+ try {
163
+ await connection.execAsync(boundary.rollback);
164
+ }
165
+ catch {
166
+ return;
167
+ }
168
+ }
169
+ function variadic(params) {
170
+ return params;
171
+ }
172
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,EAA2B,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAK/E,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AACxD,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAS1C,MAAM,aAAa,GAAa;IAC9B,KAAK,EAAE,iBAAiB;IACxB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACrB,CAAC;AAsCF,MAAM,gBAAgB;IACkB;IAAtC,YAAsC,KAAqB;QAArB,UAAK,GAAL,KAAK,CAAgB;IAAG,CAAC;IAExD,KAAK,CAAC,IAAI,CAAC,MAAc;QAC9B,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC7B,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;IAIM,KAAK,CAAC,GAAG,CAAC,MAAc,EAAE,GAAG,MAAqB;QACvD,I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AW,IAAI,EAAE;QACzB,QAAQ,EAAE,eAAe,IAAI,aAAa,IAAI,EAAE;KACjD,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,QAAQ,CACrB,UAA4B,EAC5B,KAAa,EACb,IAA8B;IAE9B,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACtD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5D,MAAM,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACrC,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC;AACH,CAAC;AAED,sFAAsF;AACtF,KAAK,UAAU,QAAQ,CAAC,UAA4B,EAAE,QAAkB;IACtE,IAAI,CAAC;QACH,MAAM,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;IACT,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,MAAqB;IACrC,OAAO,MAAkC,CAAC;AAC5C,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,59 +1,44 @@
1
- import { type JsonValue, type KeyValueStore, type Page, type PageOptions, type RecordStore, type ReentrantStorageTransaction, type SchemaMeta, type SchemaMetadataStore, type StoredRecord, type TransactionalStorageStore } from '@baukit/data-contracts';
2
- import type { SQLiteDatabase } from 'expo-sqlite';
3
- type SQLiteConnection = Pick<SQLiteDatabase, 'execAsync' | 'getAllAsync' | 'getFirstAsync' | 'runAsync'>;
4
- /** A namespaced Expo SQLite implementation of Baukit's provider-neutral RecordStore. */
5
- export declare class SqliteRecordStore<T extends StoredRecord> implements RecordStore<T> {
6
- private readonly database;
7
- private readonly namespace;
8
- private readonly assertAvailable;
9
- constructor(database: SQLiteConnection, namespace: string, assertAvailable?: () => void);
10
- /** Creates the shared adapter table if needed. Safe to call repeatedly. */
11
- initialize(): Promise<void>;
12
- put(record: T): Promise<void>;
13
- get(id: string): Promise<T | undefined>;
14
- delete(id: string): Promise<void>;
15
- list(options?: PageOptions): Promise<Page<T>>;
1
+ import { type KeyValueStore, type RecordStore, type ReentrantStorageTransaction, type SchemaMetadataStore, type StoredRecord, type TransactionalStorageStore } from '@baukit/data-contracts';
2
+ import { type ExpoSqliteDatabase, type SQLiteFileConnection } from './queued-database.js';
3
+ import { KeyValueStatements, RecordStatements, SchemaMetadataStatements } from './statements.js';
4
+ export type { ExpoSqliteDatabase } from './queued-database.js';
5
+ export { ExpoSqliteConnection, type ExpoSqliteConnectionOptions, type SqliteStatements, type SqliteTransaction, } from './connection.js';
6
+ /**
7
+ * A namespaced Expo SQLite implementation of Baukit's provider-neutral RecordStore.
8
+ * Statements share one queue with every adapter store that uses the same database file.
9
+ */
10
+ export declare class SqliteRecordStore<T extends StoredRecord> extends RecordStatements<T> {
11
+ constructor(database: SQLiteFileConnection, namespace: string);
16
12
  }
17
- /** Namespaced key/value storage used by the composite SQLite adapter. */
18
- export declare class SqliteKeyValueStore implements KeyValueStore {
19
- private readonly database;
20
- private readonly namespace;
21
- private readonly assertAvailable;
22
- constructor(database: SQLiteConnection, namespace: string, assertAvailable?: () => void);
23
- initialize(): Promise<void>;
24
- get(key: string): Promise<JsonValue | undefined>;
25
- set(key: string, value: JsonValue): Promise<void>;
26
- delete(key: string): Promise<void>;
27
- clear(): Promise<void>;
13
+ /** Namespaced key/value storage ordered with every adapter store on the same database file. */
14
+ export declare class SqliteKeyValueStore extends KeyValueStatements {
15
+ constructor(database: SQLiteFileConnection, namespace: string);
28
16
  }
29
- /** Namespaced portable schema metadata used by the composite SQLite adapter. */
30
- export declare class SqliteSchemaMetadataStore implements SchemaMetadataStore {
31
- private readonly database;
32
- private readonly namespace;
33
- private readonly assertAvailable;
34
- constructor(database: SQLiteConnection, namespace: string, assertAvailable?: () => void);
35
- initialize(): Promise<void>;
36
- getSchemaMeta(): Promise<SchemaMeta | undefined>;
37
- setSchemaMeta(metadata: SchemaMeta): Promise<void>;
17
+ /** Namespaced schema metadata ordered with every adapter store on the same database file. */
18
+ export declare class SqliteSchemaMetadataStore extends SchemaMetadataStatements {
19
+ constructor(database: SQLiteFileConnection, namespace: string);
38
20
  }
39
21
  export interface ExpoSqliteStoreOptions {
40
22
  /** Close the supplied database when this adapter closes. Defaults to false. */
41
23
  readonly closeDatabase?: boolean;
42
24
  }
43
- /** Complete namespaced adapter using Expo SQLite exclusive write transactions. */
25
+ /**
26
+ * Complete namespaced adapter using Expo SQLite exclusive write transactions.
27
+ * Root statements, transactions, and close run one at a time in call order, shared with every
28
+ * adapter store on the same database file.
29
+ */
44
30
  export declare class ExpoSqliteStore<T extends StoredRecord> implements TransactionalStorageStore<T> {
45
- private readonly database;
46
- private readonly options;
47
- readonly keyValues: SqliteKeyValueStore;
48
- readonly records: SqliteRecordStore<T>;
49
- readonly schemaMetadata: SqliteSchemaMetadataStore;
50
- private readonly lifecycle;
51
- private transactionTail;
52
- constructor(database: SQLiteDatabase, namespace: string, options?: ExpoSqliteStoreOptions);
53
31
  private readonly namespace;
32
+ readonly keyValues: KeyValueStore;
33
+ readonly records: RecordStore<T>;
34
+ readonly schemaMetadata: SchemaMetadataStore;
35
+ private readonly root;
36
+ private readonly queued;
37
+ constructor(database: ExpoSqliteDatabase, namespace: string, options?: ExpoSqliteStoreOptions);
54
38
  initialize(): Promise<void>;
55
39
  withTransaction<TResult>(operation: (context: ReentrantStorageTransaction<T>) => Promise<TResult> | TResult): Promise<TResult>;
40
+ /** Rejects new work, waits for accepted work, and settles every caller with one result. */
56
41
  close(): Promise<void>;
42
+ private runExclusive;
57
43
  }
58
- export {};
59
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,2BAA2B,EAChC,KAAK,UAAU,EACf,KAAK,mBAAmB,EAExB,KAAK,YAAY,EACjB,KAAK,yBAAyB,EAE/B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAgBlD,KAAK,gBAAgB,GAAG,IAAI,CAC1B,cAAc,EACd,WAAW,GAAG,aAAa,GAAG,eAAe,GAAG,UAAU,CAC3D,CAAC;AAsBF,wFAAwF;AACxF,qBAAa,iBAAiB,CAAC,CAAC,SAAS,YAAY,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IAE5E,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,MAAM,EACjB,eAAe,GAAE,MAAM,IAAsB;IAOhE,2EAA2E;IAC9D,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAe7B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAUvC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWjC,IAAI,CAAC,OAAO,GAAE,WAAgB,G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