@xylabs/indexed-db 4.13.3 → 4.13.5
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/browser/index.d.ts +74 -81
- package/dist/neutral/index.d.ts +74 -81
- package/dist/node/index.d.ts +74 -81
- package/package.json +7 -7
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,81 +1,74 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export
|
|
74
|
-
|
|
75
|
-
export declare function withReadWriteStore<T extends EmptyObject = EmptyObject, R = T>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [StoreNames<ObjectStore<T>>], StoreNames<ObjectStore<T>>, 'readwrite'> | null) => Promise<R> | R, logger?: Logger): Promise<R>;
|
|
76
|
-
|
|
77
|
-
export declare function withStore<T extends EmptyObject = EmptyObject, R = T, M extends 'readonly' | 'readwrite' = 'readonly'>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [
|
|
78
|
-
StoreNames<ObjectStore<T>>
|
|
79
|
-
], StoreNames<ObjectStore<T>>, M> | null) => Promise<R> | R, mode: M, logger?: Logger): Promise<R>;
|
|
80
|
-
|
|
81
|
-
export { }
|
|
1
|
+
import { Logger } from '@xylabs/logger';
|
|
2
|
+
import { DBSchema, IDBPDatabase, StoreNames, StoreValue, StoreKey, IDBPObjectStore } from 'idb';
|
|
3
|
+
import { EmptyObject } from '@xylabs/object';
|
|
4
|
+
import { KeyValueStore } from '@xylabs/storage';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The index direction (1 for ascending, -1 for descending)
|
|
8
|
+
*/
|
|
9
|
+
type IndexDirection = -1 | 1;
|
|
10
|
+
/**
|
|
11
|
+
* Description of index(es) to be created on a store
|
|
12
|
+
*/
|
|
13
|
+
type IndexDescription = {
|
|
14
|
+
/**
|
|
15
|
+
* The key(s) to index
|
|
16
|
+
*/
|
|
17
|
+
key: Record<string, IndexDirection>;
|
|
18
|
+
/**
|
|
19
|
+
* Is the indexed value an array
|
|
20
|
+
*/
|
|
21
|
+
multiEntry?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* If true, the index must enforce uniqueness on the key
|
|
24
|
+
*/
|
|
25
|
+
unique?: boolean;
|
|
26
|
+
};
|
|
27
|
+
declare const IndexSeparator = "-";
|
|
28
|
+
/**
|
|
29
|
+
* Given an index description, this will build the index
|
|
30
|
+
* name in standard form
|
|
31
|
+
* @param index The index description
|
|
32
|
+
* @returns The index name in standard form
|
|
33
|
+
*/
|
|
34
|
+
declare const buildStandardIndexName: (index: IndexDescription) => string;
|
|
35
|
+
|
|
36
|
+
declare function checkDbNeedsUpgrade(dbName: string, stores: Record<string, IndexDescription[]>, logger?: Logger): Promise<number>;
|
|
37
|
+
|
|
38
|
+
declare function createStoreDuringUpgrade<DBTypes extends DBSchema | unknown = unknown>(db: IDBPDatabase<DBTypes>, storeName: StoreNames<DBTypes>, indexes: IndexDescription[], logger?: Logger): void;
|
|
39
|
+
|
|
40
|
+
interface ObjectStore<T extends EmptyObject = EmptyObject> {
|
|
41
|
+
[s: string]: T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare function getExistingIndexes<T extends EmptyObject = EmptyObject>(db: IDBPDatabase<ObjectStore<T>> | string, storeName: StoreNames<ObjectStore<T>>, logger?: Logger): Promise<IndexDescription[] | null>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* An IndexedDB key/value store.
|
|
48
|
+
*/
|
|
49
|
+
declare class IndexedDbKeyValueStore<T extends DBSchema, S extends StoreNames<T>> implements KeyValueStore<StoreValue<T, S>, StoreKey<T, S>> {
|
|
50
|
+
readonly dbName: string;
|
|
51
|
+
readonly storeName: S;
|
|
52
|
+
constructor(dbName: string, storeName: S);
|
|
53
|
+
clear?(): Promise<void>;
|
|
54
|
+
delete(key: StoreKey<T, S>): Promise<void>;
|
|
55
|
+
get(key: StoreKey<T, S>): Promise<StoreValue<T, S> | undefined>;
|
|
56
|
+
keys?(): Promise<StoreKey<T, S>[]>;
|
|
57
|
+
set(key: StoreKey<T, S>, value: StoreValue<T, S>): Promise<void>;
|
|
58
|
+
withDb<R = StoreValue<T, S>>(callback: (db: IDBPDatabase<T>) => Promise<R> | R): Promise<R>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
declare function withDb<DBTypes extends DBSchema | unknown = unknown, R = EmptyObject>(dbName: string, callback: (db: IDBPDatabase<DBTypes>) => Promise<R> | R, expectedIndexes?: Record<string, IndexDescription[]>, logger?: Logger, lock?: boolean): Promise<R>;
|
|
62
|
+
|
|
63
|
+
declare function withDbByVersion<DBTypes extends DBSchema | unknown = unknown, R = EmptyObject>(dbName: string, callback: (db: IDBPDatabase<DBTypes>) => Promise<R> | R, version?: number, expectedIndexes?: Record<string, IndexDescription[]>, logger?: Logger, lock?: boolean): Promise<R>;
|
|
64
|
+
|
|
65
|
+
declare function withReadOnlyStore<T extends EmptyObject = EmptyObject, R = T>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [StoreNames<ObjectStore<T>>], StoreNames<ObjectStore<T>>, 'readonly'> | null) => Promise<R> | R, logger?: Logger): Promise<R>;
|
|
66
|
+
|
|
67
|
+
declare function withReadWriteStore<T extends EmptyObject = EmptyObject, R = T>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [StoreNames<ObjectStore<T>>], StoreNames<ObjectStore<T>>, 'readwrite'> | null) => Promise<R> | R, logger?: Logger): Promise<R>;
|
|
68
|
+
|
|
69
|
+
declare function withStore<T extends EmptyObject = EmptyObject, R = T, M extends 'readonly' | 'readwrite' = 'readonly'>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [
|
|
70
|
+
StoreNames<ObjectStore<T>>
|
|
71
|
+
], StoreNames<ObjectStore<T>>, M> | null) => Promise<R> | R, mode: M, logger?: Logger): Promise<R>;
|
|
72
|
+
|
|
73
|
+
export { IndexSeparator, IndexedDbKeyValueStore, buildStandardIndexName, checkDbNeedsUpgrade, createStoreDuringUpgrade, getExistingIndexes, withDb, withDbByVersion, withReadOnlyStore, withReadWriteStore, withStore };
|
|
74
|
+
export type { IndexDescription, IndexDirection, ObjectStore };
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,81 +1,74 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export
|
|
74
|
-
|
|
75
|
-
export declare function withReadWriteStore<T extends EmptyObject = EmptyObject, R = T>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [StoreNames<ObjectStore<T>>], StoreNames<ObjectStore<T>>, 'readwrite'> | null) => Promise<R> | R, logger?: Logger): Promise<R>;
|
|
76
|
-
|
|
77
|
-
export declare function withStore<T extends EmptyObject = EmptyObject, R = T, M extends 'readonly' | 'readwrite' = 'readonly'>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [
|
|
78
|
-
StoreNames<ObjectStore<T>>
|
|
79
|
-
], StoreNames<ObjectStore<T>>, M> | null) => Promise<R> | R, mode: M, logger?: Logger): Promise<R>;
|
|
80
|
-
|
|
81
|
-
export { }
|
|
1
|
+
import { Logger } from '@xylabs/logger';
|
|
2
|
+
import { DBSchema, IDBPDatabase, StoreNames, StoreValue, StoreKey, IDBPObjectStore } from 'idb';
|
|
3
|
+
import { EmptyObject } from '@xylabs/object';
|
|
4
|
+
import { KeyValueStore } from '@xylabs/storage';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The index direction (1 for ascending, -1 for descending)
|
|
8
|
+
*/
|
|
9
|
+
type IndexDirection = -1 | 1;
|
|
10
|
+
/**
|
|
11
|
+
* Description of index(es) to be created on a store
|
|
12
|
+
*/
|
|
13
|
+
type IndexDescription = {
|
|
14
|
+
/**
|
|
15
|
+
* The key(s) to index
|
|
16
|
+
*/
|
|
17
|
+
key: Record<string, IndexDirection>;
|
|
18
|
+
/**
|
|
19
|
+
* Is the indexed value an array
|
|
20
|
+
*/
|
|
21
|
+
multiEntry?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* If true, the index must enforce uniqueness on the key
|
|
24
|
+
*/
|
|
25
|
+
unique?: boolean;
|
|
26
|
+
};
|
|
27
|
+
declare const IndexSeparator = "-";
|
|
28
|
+
/**
|
|
29
|
+
* Given an index description, this will build the index
|
|
30
|
+
* name in standard form
|
|
31
|
+
* @param index The index description
|
|
32
|
+
* @returns The index name in standard form
|
|
33
|
+
*/
|
|
34
|
+
declare const buildStandardIndexName: (index: IndexDescription) => string;
|
|
35
|
+
|
|
36
|
+
declare function checkDbNeedsUpgrade(dbName: string, stores: Record<string, IndexDescription[]>, logger?: Logger): Promise<number>;
|
|
37
|
+
|
|
38
|
+
declare function createStoreDuringUpgrade<DBTypes extends DBSchema | unknown = unknown>(db: IDBPDatabase<DBTypes>, storeName: StoreNames<DBTypes>, indexes: IndexDescription[], logger?: Logger): void;
|
|
39
|
+
|
|
40
|
+
interface ObjectStore<T extends EmptyObject = EmptyObject> {
|
|
41
|
+
[s: string]: T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare function getExistingIndexes<T extends EmptyObject = EmptyObject>(db: IDBPDatabase<ObjectStore<T>> | string, storeName: StoreNames<ObjectStore<T>>, logger?: Logger): Promise<IndexDescription[] | null>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* An IndexedDB key/value store.
|
|
48
|
+
*/
|
|
49
|
+
declare class IndexedDbKeyValueStore<T extends DBSchema, S extends StoreNames<T>> implements KeyValueStore<StoreValue<T, S>, StoreKey<T, S>> {
|
|
50
|
+
readonly dbName: string;
|
|
51
|
+
readonly storeName: S;
|
|
52
|
+
constructor(dbName: string, storeName: S);
|
|
53
|
+
clear?(): Promise<void>;
|
|
54
|
+
delete(key: StoreKey<T, S>): Promise<void>;
|
|
55
|
+
get(key: StoreKey<T, S>): Promise<StoreValue<T, S> | undefined>;
|
|
56
|
+
keys?(): Promise<StoreKey<T, S>[]>;
|
|
57
|
+
set(key: StoreKey<T, S>, value: StoreValue<T, S>): Promise<void>;
|
|
58
|
+
withDb<R = StoreValue<T, S>>(callback: (db: IDBPDatabase<T>) => Promise<R> | R): Promise<R>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
declare function withDb<DBTypes extends DBSchema | unknown = unknown, R = EmptyObject>(dbName: string, callback: (db: IDBPDatabase<DBTypes>) => Promise<R> | R, expectedIndexes?: Record<string, IndexDescription[]>, logger?: Logger, lock?: boolean): Promise<R>;
|
|
62
|
+
|
|
63
|
+
declare function withDbByVersion<DBTypes extends DBSchema | unknown = unknown, R = EmptyObject>(dbName: string, callback: (db: IDBPDatabase<DBTypes>) => Promise<R> | R, version?: number, expectedIndexes?: Record<string, IndexDescription[]>, logger?: Logger, lock?: boolean): Promise<R>;
|
|
64
|
+
|
|
65
|
+
declare function withReadOnlyStore<T extends EmptyObject = EmptyObject, R = T>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [StoreNames<ObjectStore<T>>], StoreNames<ObjectStore<T>>, 'readonly'> | null) => Promise<R> | R, logger?: Logger): Promise<R>;
|
|
66
|
+
|
|
67
|
+
declare function withReadWriteStore<T extends EmptyObject = EmptyObject, R = T>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [StoreNames<ObjectStore<T>>], StoreNames<ObjectStore<T>>, 'readwrite'> | null) => Promise<R> | R, logger?: Logger): Promise<R>;
|
|
68
|
+
|
|
69
|
+
declare function withStore<T extends EmptyObject = EmptyObject, R = T, M extends 'readonly' | 'readwrite' = 'readonly'>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [
|
|
70
|
+
StoreNames<ObjectStore<T>>
|
|
71
|
+
], StoreNames<ObjectStore<T>>, M> | null) => Promise<R> | R, mode: M, logger?: Logger): Promise<R>;
|
|
72
|
+
|
|
73
|
+
export { IndexSeparator, IndexedDbKeyValueStore, buildStandardIndexName, checkDbNeedsUpgrade, createStoreDuringUpgrade, getExistingIndexes, withDb, withDbByVersion, withReadOnlyStore, withReadWriteStore, withStore };
|
|
74
|
+
export type { IndexDescription, IndexDirection, ObjectStore };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,81 +1,74 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export
|
|
74
|
-
|
|
75
|
-
export declare function withReadWriteStore<T extends EmptyObject = EmptyObject, R = T>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [StoreNames<ObjectStore<T>>], StoreNames<ObjectStore<T>>, 'readwrite'> | null) => Promise<R> | R, logger?: Logger): Promise<R>;
|
|
76
|
-
|
|
77
|
-
export declare function withStore<T extends EmptyObject = EmptyObject, R = T, M extends 'readonly' | 'readwrite' = 'readonly'>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [
|
|
78
|
-
StoreNames<ObjectStore<T>>
|
|
79
|
-
], StoreNames<ObjectStore<T>>, M> | null) => Promise<R> | R, mode: M, logger?: Logger): Promise<R>;
|
|
80
|
-
|
|
81
|
-
export { }
|
|
1
|
+
import { Logger } from '@xylabs/logger';
|
|
2
|
+
import { DBSchema, IDBPDatabase, StoreNames, StoreValue, StoreKey, IDBPObjectStore } from 'idb';
|
|
3
|
+
import { EmptyObject } from '@xylabs/object';
|
|
4
|
+
import { KeyValueStore } from '@xylabs/storage';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The index direction (1 for ascending, -1 for descending)
|
|
8
|
+
*/
|
|
9
|
+
type IndexDirection = -1 | 1;
|
|
10
|
+
/**
|
|
11
|
+
* Description of index(es) to be created on a store
|
|
12
|
+
*/
|
|
13
|
+
type IndexDescription = {
|
|
14
|
+
/**
|
|
15
|
+
* The key(s) to index
|
|
16
|
+
*/
|
|
17
|
+
key: Record<string, IndexDirection>;
|
|
18
|
+
/**
|
|
19
|
+
* Is the indexed value an array
|
|
20
|
+
*/
|
|
21
|
+
multiEntry?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* If true, the index must enforce uniqueness on the key
|
|
24
|
+
*/
|
|
25
|
+
unique?: boolean;
|
|
26
|
+
};
|
|
27
|
+
declare const IndexSeparator = "-";
|
|
28
|
+
/**
|
|
29
|
+
* Given an index description, this will build the index
|
|
30
|
+
* name in standard form
|
|
31
|
+
* @param index The index description
|
|
32
|
+
* @returns The index name in standard form
|
|
33
|
+
*/
|
|
34
|
+
declare const buildStandardIndexName: (index: IndexDescription) => string;
|
|
35
|
+
|
|
36
|
+
declare function checkDbNeedsUpgrade(dbName: string, stores: Record<string, IndexDescription[]>, logger?: Logger): Promise<number>;
|
|
37
|
+
|
|
38
|
+
declare function createStoreDuringUpgrade<DBTypes extends DBSchema | unknown = unknown>(db: IDBPDatabase<DBTypes>, storeName: StoreNames<DBTypes>, indexes: IndexDescription[], logger?: Logger): void;
|
|
39
|
+
|
|
40
|
+
interface ObjectStore<T extends EmptyObject = EmptyObject> {
|
|
41
|
+
[s: string]: T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare function getExistingIndexes<T extends EmptyObject = EmptyObject>(db: IDBPDatabase<ObjectStore<T>> | string, storeName: StoreNames<ObjectStore<T>>, logger?: Logger): Promise<IndexDescription[] | null>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* An IndexedDB key/value store.
|
|
48
|
+
*/
|
|
49
|
+
declare class IndexedDbKeyValueStore<T extends DBSchema, S extends StoreNames<T>> implements KeyValueStore<StoreValue<T, S>, StoreKey<T, S>> {
|
|
50
|
+
readonly dbName: string;
|
|
51
|
+
readonly storeName: S;
|
|
52
|
+
constructor(dbName: string, storeName: S);
|
|
53
|
+
clear?(): Promise<void>;
|
|
54
|
+
delete(key: StoreKey<T, S>): Promise<void>;
|
|
55
|
+
get(key: StoreKey<T, S>): Promise<StoreValue<T, S> | undefined>;
|
|
56
|
+
keys?(): Promise<StoreKey<T, S>[]>;
|
|
57
|
+
set(key: StoreKey<T, S>, value: StoreValue<T, S>): Promise<void>;
|
|
58
|
+
withDb<R = StoreValue<T, S>>(callback: (db: IDBPDatabase<T>) => Promise<R> | R): Promise<R>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
declare function withDb<DBTypes extends DBSchema | unknown = unknown, R = EmptyObject>(dbName: string, callback: (db: IDBPDatabase<DBTypes>) => Promise<R> | R, expectedIndexes?: Record<string, IndexDescription[]>, logger?: Logger, lock?: boolean): Promise<R>;
|
|
62
|
+
|
|
63
|
+
declare function withDbByVersion<DBTypes extends DBSchema | unknown = unknown, R = EmptyObject>(dbName: string, callback: (db: IDBPDatabase<DBTypes>) => Promise<R> | R, version?: number, expectedIndexes?: Record<string, IndexDescription[]>, logger?: Logger, lock?: boolean): Promise<R>;
|
|
64
|
+
|
|
65
|
+
declare function withReadOnlyStore<T extends EmptyObject = EmptyObject, R = T>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [StoreNames<ObjectStore<T>>], StoreNames<ObjectStore<T>>, 'readonly'> | null) => Promise<R> | R, logger?: Logger): Promise<R>;
|
|
66
|
+
|
|
67
|
+
declare function withReadWriteStore<T extends EmptyObject = EmptyObject, R = T>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [StoreNames<ObjectStore<T>>], StoreNames<ObjectStore<T>>, 'readwrite'> | null) => Promise<R> | R, logger?: Logger): Promise<R>;
|
|
68
|
+
|
|
69
|
+
declare function withStore<T extends EmptyObject = EmptyObject, R = T, M extends 'readonly' | 'readwrite' = 'readonly'>(db: IDBPDatabase<ObjectStore<T>>, storeName: StoreNames<ObjectStore<T>>, callback: (store: IDBPObjectStore<ObjectStore<T>, [
|
|
70
|
+
StoreNames<ObjectStore<T>>
|
|
71
|
+
], StoreNames<ObjectStore<T>>, M> | null) => Promise<R> | R, mode: M, logger?: Logger): Promise<R>;
|
|
72
|
+
|
|
73
|
+
export { IndexSeparator, IndexedDbKeyValueStore, buildStandardIndexName, checkDbNeedsUpgrade, createStoreDuringUpgrade, getExistingIndexes, withDb, withDbByVersion, withReadOnlyStore, withReadWriteStore, withStore };
|
|
74
|
+
export type { IndexDescription, IndexDirection, ObjectStore };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/indexed-db",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.5",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hex",
|
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
"packages/**/*"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@xylabs/exists": "^4.13.
|
|
53
|
-
"@xylabs/logger": "^4.13.
|
|
54
|
-
"@xylabs/object": "^4.13.
|
|
55
|
-
"@xylabs/storage": "^4.13.
|
|
52
|
+
"@xylabs/exists": "^4.13.5",
|
|
53
|
+
"@xylabs/logger": "^4.13.5",
|
|
54
|
+
"@xylabs/object": "^4.13.5",
|
|
55
|
+
"@xylabs/storage": "^4.13.5",
|
|
56
56
|
"async-mutex": "^0.5.0",
|
|
57
57
|
"idb": "^8.0.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.0-rc.
|
|
61
|
-
"@xylabs/tsconfig-dom": "^7.0.0-rc.
|
|
60
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.0-rc.8",
|
|
61
|
+
"@xylabs/tsconfig-dom": "^7.0.0-rc.8",
|
|
62
62
|
"fake-indexeddb": "^6.0.1",
|
|
63
63
|
"jsdom": "^26.1.0",
|
|
64
64
|
"typescript": "^5.8.3",
|