@baukit/data-contracts-dexie 0.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/LICENSE +21 -0
- package/README.md +85 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +286 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Patrick Koss
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# `@baukit/data-contracts-dexie`
|
|
2
|
+
|
|
3
|
+
A product-neutral Dexie 4.x implementation of `@baukit/data-contracts` for web
|
|
4
|
+
applications that need key/value data, ID-ordered records, portable schema
|
|
5
|
+
metadata, and compound write transactions.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { openDexieStore } from '@baukit/data-contracts-dexie';
|
|
9
|
+
|
|
10
|
+
interface CachedRecord {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly value: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const storage = await openDexieStore<CachedRecord>('product-cache');
|
|
16
|
+
await storage.withTransaction(async (transaction) => {
|
|
17
|
+
await transaction.records.put({ id: 'record-1', value: 'local' });
|
|
18
|
+
await transaction.keyValues.set('outbox:mutation-1', {
|
|
19
|
+
entityId: 'record-1',
|
|
20
|
+
operation: 'put',
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
await storage.close();
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The package owns three generic IndexedDB object stores. It does not define
|
|
27
|
+
product tables, entity relationships, soft-delete behavior, revisions, sync
|
|
28
|
+
protocols, or database naming policy.
|
|
29
|
+
|
|
30
|
+
Authenticated products should resolve an opaque name with
|
|
31
|
+
`@baukit/data-contracts` before calling `openDexieStore`. The fake-IndexedDB and
|
|
32
|
+
Chromium/WebKit suites run the shared offline E→F→E identity-transition cases
|
|
33
|
+
in addition to the transaction contract.
|
|
34
|
+
|
|
35
|
+
## Transaction model
|
|
36
|
+
|
|
37
|
+
Nested transactions explicitly join the ambient transaction when they are
|
|
38
|
+
started through the callback's transaction-scoped context:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
await storage.withTransaction((transaction) =>
|
|
42
|
+
transaction.withTransaction((sameTransaction) => sameTransaction.records.put(record)),
|
|
43
|
+
);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Compose transactional repositories from that scoped context. A call on the
|
|
47
|
+
root `storage` object is an independent transaction and is serialized behind
|
|
48
|
+
transactions that already started. Transaction contexts must not be retained
|
|
49
|
+
after their callback ends.
|
|
50
|
+
|
|
51
|
+
Prepare network, native, crypto, filesystem, or other external promise results
|
|
52
|
+
before opening a write transaction. Dexie tracks its own promise zone, but an
|
|
53
|
+
unrelated promise layer can let the browser's IndexedDB request queue drain and
|
|
54
|
+
auto-commit early. Keep the callback limited to the complete local write set.
|
|
55
|
+
|
|
56
|
+
Do not blanket-ignore Dexie's `PrematureCommitError`. That error can mean the
|
|
57
|
+
browser committed only an early subset of the intended writes. Treating it as
|
|
58
|
+
success without proof can silently split a compound operation. Acceptance
|
|
59
|
+
tests must observe every intended write, the matching outbox entry, and full
|
|
60
|
+
rollback when any step fails.
|
|
61
|
+
|
|
62
|
+
Quota failures surface as `StorageError` with code
|
|
63
|
+
`storage_quota_exceeded`. After `close()` resolves, operations fail with code
|
|
64
|
+
`storage_closed`.
|
|
65
|
+
|
|
66
|
+
## Verification
|
|
67
|
+
|
|
68
|
+
`pnpm test` uses `fake-indexeddb` and stays fast. The browser suite is a
|
|
69
|
+
separate Chromium and WebKit gate. Install browsers into a repository-local
|
|
70
|
+
cache and run it from the repository root:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
PLAYWRIGHT_BROWSERS_PATH="$PWD/typescript/.playwright-browsers" \
|
|
74
|
+
corepack pnpm --dir typescript --filter @baukit/data-contracts-dexie \
|
|
75
|
+
exec playwright install --with-deps chromium webkit
|
|
76
|
+
PLAYWRIGHT_BROWSERS_PATH="$PWD/typescript/.playwright-browsers" \
|
|
77
|
+
corepack pnpm --dir typescript --filter @baukit/data-contracts-dexie \
|
|
78
|
+
run test:browser
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Run `corepack pnpm --dir typescript run check` for the normal workspace gate.
|
|
82
|
+
The package-local `check` script also includes the browser suite and therefore
|
|
83
|
+
expects the two browser binaries to be installed. CI should add the same
|
|
84
|
+
repository-local browser install and `test:browser` commands as a distinct
|
|
85
|
+
step; the workspace's ordinary `test` task intentionally remains fast.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
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 DexieOptions, type Table } from 'dexie';
|
|
3
|
+
interface KeyValueRow {
|
|
4
|
+
readonly key: string;
|
|
5
|
+
readonly payload: string;
|
|
6
|
+
}
|
|
7
|
+
interface RecordRow {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly payload: string;
|
|
10
|
+
}
|
|
11
|
+
interface SchemaRow extends SchemaMeta {
|
|
12
|
+
readonly key: 'schema';
|
|
13
|
+
}
|
|
14
|
+
/** Dexie implementation of the provider-neutral key/value contract. */
|
|
15
|
+
export declare class DexieKeyValueStore implements KeyValueStore {
|
|
16
|
+
private readonly table;
|
|
17
|
+
private readonly assertAvailable;
|
|
18
|
+
constructor(table: Table<KeyValueRow, string>, assertAvailable: () => void);
|
|
19
|
+
get(key: string): Promise<JsonValue | undefined>;
|
|
20
|
+
set(key: string, value: JsonValue): Promise<void>;
|
|
21
|
+
delete(key: string): Promise<void>;
|
|
22
|
+
clear(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/** Dexie implementation of ID-ordered record storage. */
|
|
25
|
+
export declare class DexieRecordStore<T extends StoredRecord> implements RecordStore<T> {
|
|
26
|
+
private readonly table;
|
|
27
|
+
private readonly assertAvailable;
|
|
28
|
+
constructor(table: Table<RecordRow, string>, assertAvailable: () => void);
|
|
29
|
+
put(record: T): Promise<void>;
|
|
30
|
+
get(id: string): Promise<T | undefined>;
|
|
31
|
+
delete(id: string): Promise<void>;
|
|
32
|
+
list(options?: PageOptions): Promise<Page<T>>;
|
|
33
|
+
}
|
|
34
|
+
/** Dexie implementation of portable schema metadata. */
|
|
35
|
+
export declare class DexieSchemaMetadataStore implements SchemaMetadataStore {
|
|
36
|
+
private readonly table;
|
|
37
|
+
private readonly assertAvailable;
|
|
38
|
+
constructor(table: Table<SchemaRow, string>, assertAvailable: () => void);
|
|
39
|
+
getSchemaMeta(): Promise<SchemaMeta | undefined>;
|
|
40
|
+
setSchemaMeta(metadata: SchemaMeta): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export interface OpenDexieStoreOptions {
|
|
43
|
+
readonly indexedDB?: DexieOptions['indexedDB'];
|
|
44
|
+
readonly IDBKeyRange?: DexieOptions['IDBKeyRange'];
|
|
45
|
+
}
|
|
46
|
+
/** Complete Dexie 4.x adapter for Baukit's base storage contracts. */
|
|
47
|
+
export declare class DexieStore<T extends StoredRecord> implements TransactionalStorageStore<T> {
|
|
48
|
+
private readonly database;
|
|
49
|
+
readonly keyValues: DexieKeyValueStore;
|
|
50
|
+
readonly records: DexieRecordStore<T>;
|
|
51
|
+
readonly schemaMetadata: DexieSchemaMetadataStore;
|
|
52
|
+
private readonly lifecycle;
|
|
53
|
+
private transactionTail;
|
|
54
|
+
private constructor();
|
|
55
|
+
static open<TRecord extends StoredRecord>(databaseName: string, options?: OpenDexieStoreOptions): Promise<DexieStore<TRecord>>;
|
|
56
|
+
withTransaction<TResult>(operation: (context: ReentrantStorageTransaction<T>) => Promise<TResult> | TResult): Promise<TResult>;
|
|
57
|
+
close(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
/** Opens a Dexie-backed store and closes it if initialization fails. */
|
|
60
|
+
export declare function openDexieStore<T extends StoredRecord>(databaseName: string, options?: OpenDexieStoreOptions): Promise<DexieStore<T>>;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,K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MAAM,EACpB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAkBlB,eAAe,CAAC,OAAO,EAClC,SAAS,EAAE,CAAC,OAAO,EAAE,2BAA2B,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,GACjF,OAAO,CAAC,OAAO,CAAC;IA4BN,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CASpC;AAED,wEAAwE;AACxE,wBAAsB,cAAc,CAAC,CAAC,SAAS,YAAY,EACzD,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAExB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE, StorageError, normalizeStorageError, } from '@baukit/data-contracts';
|
|
2
|
+
import { Dexie } from 'dexie';
|
|
3
|
+
const CURSOR_PREFIX = 'dexie1:';
|
|
4
|
+
class BaukitDexieDatabase extends Dexie {
|
|
5
|
+
keyValues;
|
|
6
|
+
records;
|
|
7
|
+
schemaMetadata;
|
|
8
|
+
constructor(name, options) {
|
|
9
|
+
super(name, options);
|
|
10
|
+
this.version(1).stores({
|
|
11
|
+
keyValues: 'key',
|
|
12
|
+
records: 'id',
|
|
13
|
+
schemaMetadata: 'key',
|
|
14
|
+
});
|
|
15
|
+
this.keyValues = this.table('keyValues');
|
|
16
|
+
this.records = this.table('records');
|
|
17
|
+
this.schemaMetadata = this.table('schemaMetadata');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function assertOpen(lifecycle) {
|
|
21
|
+
if (lifecycle.status !== 'open') {
|
|
22
|
+
throw new StorageError('storage_closed', 'The storage adapter is closed.');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function write(operation) {
|
|
26
|
+
try {
|
|
27
|
+
return await operation();
|
|
28
|
+
}
|
|
29
|
+
catch (cause) {
|
|
30
|
+
throw normalizeStorageError(cause);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Dexie implementation of the provider-neutral key/value contract. */
|
|
34
|
+
export class DexieKeyValueStore {
|
|
35
|
+
table;
|
|
36
|
+
assertAvailable;
|
|
37
|
+
constructor(table, assertAvailable) {
|
|
38
|
+
this.table = table;
|
|
39
|
+
this.assertAvailable = assertAvailable;
|
|
40
|
+
}
|
|
41
|
+
async get(key) {
|
|
42
|
+
this.assertAvailable();
|
|
43
|
+
const row = await this.table.get(key);
|
|
44
|
+
return row === undefined ? undefined : parseJson(row.payload, 'key/value');
|
|
45
|
+
}
|
|
46
|
+
async set(key, value) {
|
|
47
|
+
this.assertAvailable();
|
|
48
|
+
await write(() => this.table.put({ key, payload: serialize(value, 'Value') }).then(() => undefined));
|
|
49
|
+
}
|
|
50
|
+
async delete(key) {
|
|
51
|
+
this.assertAvailable();
|
|
52
|
+
await write(() => this.table.delete(key));
|
|
53
|
+
}
|
|
54
|
+
async clear() {
|
|
55
|
+
this.assertAvailable();
|
|
56
|
+
await write(() => this.table.clear());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Dexie implementation of ID-ordered record storage. */
|
|
60
|
+
export class DexieRecordStore {
|
|
61
|
+
table;
|
|
62
|
+
assertAvailable;
|
|
63
|
+
constructor(table, assertAvailable) {
|
|
64
|
+
this.table = table;
|
|
65
|
+
this.assertAvailable = assertAvailable;
|
|
66
|
+
}
|
|
67
|
+
async put(record) {
|
|
68
|
+
this.assertAvailable();
|
|
69
|
+
if (record.id.length === 0) {
|
|
70
|
+
throw new TypeError('Record id must not be empty.');
|
|
71
|
+
}
|
|
72
|
+
await write(() => this.table.put({ id: record.id, payload: serialize(record, 'Record') }).then(() => undefined));
|
|
73
|
+
}
|
|
74
|
+
async get(id) {
|
|
75
|
+
this.assertAvailable();
|
|
76
|
+
const row = await this.table.get(id);
|
|
77
|
+
return row === undefined ? undefined : parseRecord(row.payload);
|
|
78
|
+
}
|
|
79
|
+
async delete(id) {
|
|
80
|
+
this.assertAvailable();
|
|
81
|
+
await write(() => this.table.delete(id));
|
|
82
|
+
}
|
|
83
|
+
async list(options = {}) {
|
|
84
|
+
this.assertAvailable();
|
|
85
|
+
const limit = pageLimit(options.limit);
|
|
86
|
+
const afterId = decodeCursor(options.cursor);
|
|
87
|
+
const collection = afterId === undefined ? this.table.orderBy('id') : this.table.where('id').above(afterId);
|
|
88
|
+
const rows = await collection.limit(limit + 1).toArray();
|
|
89
|
+
const hasNext = rows.length > limit;
|
|
90
|
+
const pageRows = rows.slice(0, limit);
|
|
91
|
+
const last = pageRows.at(-1);
|
|
92
|
+
return {
|
|
93
|
+
items: pageRows.map((row) => parseRecord(row.payload)),
|
|
94
|
+
nextCursor: hasNext && last !== undefined ? encodeCursor(last.id) : null,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Dexie implementation of portable schema metadata. */
|
|
99
|
+
export class DexieSchemaMetadataStore {
|
|
100
|
+
table;
|
|
101
|
+
assertAvailable;
|
|
102
|
+
constructor(table, assertAvailable) {
|
|
103
|
+
this.table = table;
|
|
104
|
+
this.assertAvailable = assertAvailable;
|
|
105
|
+
}
|
|
106
|
+
async getSchemaMeta() {
|
|
107
|
+
this.assertAvailable();
|
|
108
|
+
const row = await this.table.get('schema');
|
|
109
|
+
return row === undefined ? undefined : { name: row.name, version: row.version };
|
|
110
|
+
}
|
|
111
|
+
async setSchemaMeta(metadata) {
|
|
112
|
+
this.assertAvailable();
|
|
113
|
+
validateSchemaMeta(metadata);
|
|
114
|
+
await write(() => this.table
|
|
115
|
+
.put({ key: 'schema', name: metadata.name, version: metadata.version })
|
|
116
|
+
.then(() => undefined));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
class DexieTransaction {
|
|
120
|
+
keyValues;
|
|
121
|
+
records;
|
|
122
|
+
schemaMetadata;
|
|
123
|
+
active = true;
|
|
124
|
+
constructor(database) {
|
|
125
|
+
const assertActive = () => {
|
|
126
|
+
if (!this.active) {
|
|
127
|
+
throw new StorageError('storage_closed', 'The transaction context is no longer active.');
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
this.keyValues = new DexieKeyValueStore(database.keyValues, assertActive);
|
|
131
|
+
this.records = new DexieRecordStore(database.records, assertActive);
|
|
132
|
+
this.schemaMetadata = new DexieSchemaMetadataStore(database.schemaMetadata, assertActive);
|
|
133
|
+
}
|
|
134
|
+
async withTransaction(operation) {
|
|
135
|
+
if (!this.active) {
|
|
136
|
+
throw new StorageError('storage_closed', 'The transaction context is no longer active.');
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
return await operation(this);
|
|
140
|
+
}
|
|
141
|
+
catch (cause) {
|
|
142
|
+
throw normalizeStorageError(cause);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
finish() {
|
|
146
|
+
this.active = false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/** Complete Dexie 4.x adapter for Baukit's base storage contracts. */
|
|
150
|
+
export class DexieStore {
|
|
151
|
+
database;
|
|
152
|
+
keyValues;
|
|
153
|
+
records;
|
|
154
|
+
schemaMetadata;
|
|
155
|
+
lifecycle = { status: 'open' };
|
|
156
|
+
transactionTail = Promise.resolve();
|
|
157
|
+
constructor(database) {
|
|
158
|
+
this.database = database;
|
|
159
|
+
const assertAvailable = () => {
|
|
160
|
+
assertOpen(this.lifecycle);
|
|
161
|
+
};
|
|
162
|
+
this.keyValues = new DexieKeyValueStore(database.keyValues, assertAvailable);
|
|
163
|
+
this.records = new DexieRecordStore(database.records, assertAvailable);
|
|
164
|
+
this.schemaMetadata = new DexieSchemaMetadataStore(database.schemaMetadata, assertAvailable);
|
|
165
|
+
}
|
|
166
|
+
static async open(databaseName, options = {}) {
|
|
167
|
+
if (databaseName.length === 0) {
|
|
168
|
+
throw new TypeError('Database name must not be empty.');
|
|
169
|
+
}
|
|
170
|
+
const dexieOptions = {
|
|
171
|
+
...(options.indexedDB === undefined ? {} : { indexedDB: options.indexedDB }),
|
|
172
|
+
...(options.IDBKeyRange === undefined ? {} : { IDBKeyRange: options.IDBKeyRange }),
|
|
173
|
+
};
|
|
174
|
+
const database = new BaukitDexieDatabase(databaseName, dexieOptions);
|
|
175
|
+
try {
|
|
176
|
+
await database.open();
|
|
177
|
+
return new DexieStore(database);
|
|
178
|
+
}
|
|
179
|
+
catch (cause) {
|
|
180
|
+
database.close();
|
|
181
|
+
throw normalizeStorageError(cause);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async withTransaction(operation) {
|
|
185
|
+
assertOpen(this.lifecycle);
|
|
186
|
+
const previous = this.transactionTail;
|
|
187
|
+
let release = () => undefined;
|
|
188
|
+
this.transactionTail = new Promise((resolve) => {
|
|
189
|
+
release = resolve;
|
|
190
|
+
});
|
|
191
|
+
await previous;
|
|
192
|
+
let transaction;
|
|
193
|
+
try {
|
|
194
|
+
assertOpen(this.lifecycle);
|
|
195
|
+
return await this.database.transaction('rw!', [this.database.keyValues, this.database.records, this.database.schemaMetadata], async () => {
|
|
196
|
+
transaction = new DexieTransaction(this.database);
|
|
197
|
+
return operation(transaction);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
catch (cause) {
|
|
201
|
+
throw normalizeStorageError(cause);
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
transaction?.finish();
|
|
205
|
+
release();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async close() {
|
|
209
|
+
if (this.lifecycle.status === 'closed') {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.lifecycle.status = 'closing';
|
|
213
|
+
await this.transactionTail;
|
|
214
|
+
this.database.close();
|
|
215
|
+
this.lifecycle.status = 'closed';
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** Opens a Dexie-backed store and closes it if initialization fails. */
|
|
219
|
+
export async function openDexieStore(databaseName, options = {}) {
|
|
220
|
+
return DexieStore.open(databaseName, options);
|
|
221
|
+
}
|
|
222
|
+
function pageLimit(requested) {
|
|
223
|
+
const limit = requested ?? DEFAULT_PAGE_SIZE;
|
|
224
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > MAX_PAGE_SIZE) {
|
|
225
|
+
throw new RangeError(`Page limit must be an integer from 1 to ${String(MAX_PAGE_SIZE)}.`);
|
|
226
|
+
}
|
|
227
|
+
return limit;
|
|
228
|
+
}
|
|
229
|
+
function encodeCursor(id) {
|
|
230
|
+
return `${CURSOR_PREFIX}${encodeURIComponent(id)}`;
|
|
231
|
+
}
|
|
232
|
+
function decodeCursor(cursor) {
|
|
233
|
+
if (cursor === undefined || cursor === null) {
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
if (!cursor.startsWith(CURSOR_PREFIX)) {
|
|
237
|
+
throw new TypeError('Invalid record cursor.');
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
return decodeURIComponent(cursor.slice(CURSOR_PREFIX.length));
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
throw new TypeError('Invalid record cursor.');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function serialize(value, kind) {
|
|
247
|
+
try {
|
|
248
|
+
const payload = JSON.stringify(value);
|
|
249
|
+
return payload;
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
throw new TypeError(`${kind} must be JSON serializable.`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function parseJson(payload, kind) {
|
|
256
|
+
try {
|
|
257
|
+
return JSON.parse(payload);
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
throw new TypeError(`The local database contains an invalid ${kind} value.`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function parseRecord(payload) {
|
|
264
|
+
try {
|
|
265
|
+
const value = JSON.parse(payload);
|
|
266
|
+
if (typeof value !== 'object' ||
|
|
267
|
+
value === null ||
|
|
268
|
+
Array.isArray(value) ||
|
|
269
|
+
typeof Reflect.get(value, 'id') !== 'string') {
|
|
270
|
+
throw new TypeError('invalid record');
|
|
271
|
+
}
|
|
272
|
+
return value;
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
throw new TypeError('The local database contains an invalid record.');
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function validateSchemaMeta(metadata) {
|
|
279
|
+
if (metadata.name.length === 0) {
|
|
280
|
+
throw new TypeError('Schema name must not be empty.');
|
|
281
|
+
}
|
|
282
|
+
if (!Number.isInteger(metadata.version) || metadata.version < 0) {
|
|
283
|
+
throw new TypeError('Schema version must be a non-negative integer.');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EASb,YAAY,EAGZ,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,EAAiC,MAAM,OAAO,CAAC;AAoB7D,MAAM,aAAa,GAAG,SAAS,CAAC;AAEhC,MAAM,mBAAoB,SAAQ,KAAK;IACrB,SAAS,CAA6B;IACtC,OAAO,CAA2B;IAClC,cAAc,CAA2B;IAEzD,YAAmB,IAAY,EAAE,OAAsB;QACrD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACrB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,IAAI;YACb,cAAc,EAAE,KAAK;SACtB,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACrC,IAA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SAAS,CAAC,0CAA0C,IAAI,SAAS,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,OAAe;IAClC,IAAI,CAAC;QACH,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3C,IACE,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACpB,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,QAAQ,EAC5C,CAAC;YACD,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,KAAqB,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;IACxE,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAoB;IAC9C,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,SAAS,CAAC,gCAAgC,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@baukit/data-contracts-dexie",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Dexie 4.x implementation of @baukit/data-contracts for web applications.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Patrick Koss",
|
|
7
|
+
"homepage": "https://github.com/PatrickKoss/baukit#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/PatrickKoss/baukit.git",
|
|
11
|
+
"directory": "typescript/packages/data-contracts-dexie"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/PatrickKoss/baukit/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=24.0.0"
|
|
22
|
+
},
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@vitest/browser-playwright": "4.1.10",
|
|
37
|
+
"dexie": "4.4.5",
|
|
38
|
+
"fake-indexeddb": "6.2.5",
|
|
39
|
+
"playwright": "1.62.1",
|
|
40
|
+
"typescript": "6.0.3",
|
|
41
|
+
"vitest": "4.1.10",
|
|
42
|
+
"@baukit/data-contracts": "0.1.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@baukit/data-contracts": "^0.1.0",
|
|
46
|
+
"dexie": "^4.4.5"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -p tsconfig.json",
|
|
50
|
+
"test": "vitest run --config ../../vitest.config.ts --exclude 'src/**/*.browser.test.ts'",
|
|
51
|
+
"test:browser": "tsc -p tsconfig.browser.json && vitest run --config vitest.browser.config.ts",
|
|
52
|
+
"check": "pnpm run build && pnpm run lint && pnpm run test && pnpm run format:check && pnpm run test:browser",
|
|
53
|
+
"lint": "eslint src --max-warnings=0",
|
|
54
|
+
"format:check": "prettier --check src package.json tsconfig.json tsconfig.browser.json vitest.browser.config.ts"
|
|
55
|
+
}
|
|
56
|
+
}
|