@roc-db/indexed-db 0.2.0-pre.6 → 0.2.0-pre.7
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/index.js +26 -3
- package/dist/types/createIndexedDBAdapter.d.ts +19 -0
- package/dist/types/functions/begin.d.ts +1 -0
- package/dist/types/functions/createEntity.d.ts +3 -0
- package/dist/types/functions/deleteEntity.d.ts +1 -0
- package/dist/types/functions/end.d.ts +4 -0
- package/dist/types/functions/findDebounceMutation.d.ts +3 -0
- package/dist/types/functions/getChangeSetMutations.d.ts +3 -0
- package/dist/types/functions/index.d.ts +12 -0
- package/dist/types/functions/pageMutations.d.ts +2 -0
- package/dist/types/functions/patchEntity.d.ts +7 -0
- package/dist/types/functions/readEntity.d.ts +1 -0
- package/dist/types/functions/readMutation.d.ts +1 -0
- package/dist/types/functions/saveMutation.d.ts +1 -0
- package/dist/types/functions/updateEntity.d.ts +6 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types/IndexedDBEngine.d.ts +5 -0
- package/dist/types/types/IndexedDBReadTransaction.d.ts +4 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __export(exports_functions, {
|
|
|
20
20
|
readMutation: () => readMutation,
|
|
21
21
|
readEntity: () => readEntity,
|
|
22
22
|
patchEntity: () => patchEntity,
|
|
23
|
+
pageMutations: () => pageMutations,
|
|
23
24
|
getChangeSetMutations: () => getChangeSetMutations,
|
|
24
25
|
findDebounceMutation: () => findDebounceMutation,
|
|
25
26
|
end: () => end,
|
|
@@ -29,7 +30,7 @@ __export(exports_functions, {
|
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
// src/functions/begin.ts
|
|
32
|
-
var begin = async (request, engineOpts) => {
|
|
33
|
+
var begin = async (request, engineOpts, callback) => {
|
|
33
34
|
return new Promise((resolve, reject) => {
|
|
34
35
|
let db;
|
|
35
36
|
const idbRequest = indexedDB.open(engineOpts.dbName, 1);
|
|
@@ -45,7 +46,7 @@ var begin = async (request, engineOpts) => {
|
|
|
45
46
|
};
|
|
46
47
|
idbRequest.onsuccess = (event) => {
|
|
47
48
|
db = idbRequest.result;
|
|
48
|
-
resolve({
|
|
49
|
+
resolve(callback({
|
|
49
50
|
...engineOpts,
|
|
50
51
|
db,
|
|
51
52
|
txn: db.transaction(["entities", "mutations"], request.type === "write" ? "readwrite" : "readonly"),
|
|
@@ -53,7 +54,7 @@ var begin = async (request, engineOpts) => {
|
|
|
53
54
|
entities: new Map([]),
|
|
54
55
|
mutations: new Map([])
|
|
55
56
|
} : null
|
|
56
|
-
});
|
|
57
|
+
}));
|
|
57
58
|
};
|
|
58
59
|
});
|
|
59
60
|
};
|
|
@@ -189,6 +190,28 @@ var findDebounceMutation = async (request, engine, now) => {
|
|
|
189
190
|
};
|
|
190
191
|
});
|
|
191
192
|
};
|
|
193
|
+
// src/functions/pageMutations.ts
|
|
194
|
+
var pageMutations = async (txn, args) => {
|
|
195
|
+
const { size, changeSetRef, skip } = args;
|
|
196
|
+
if (!changeSetRef)
|
|
197
|
+
throw new Error("changeSetRef is required");
|
|
198
|
+
const objectStore = txn.engineOpts.txn.objectStore("mutations");
|
|
199
|
+
const index = objectStore.index("byChangeSetRef");
|
|
200
|
+
const range = IDBKeyRange.only(changeSetRef);
|
|
201
|
+
const idbRequest = index.openCursor(range);
|
|
202
|
+
return new Promise((resolve, reject) => {
|
|
203
|
+
const results = [];
|
|
204
|
+
idbRequest.onsuccess = () => {
|
|
205
|
+
const cursor = idbRequest.result;
|
|
206
|
+
if (cursor) {
|
|
207
|
+
results.push(cursor.value);
|
|
208
|
+
cursor.continue();
|
|
209
|
+
} else {
|
|
210
|
+
resolve(results);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
};
|
|
192
215
|
// src/functions/patchEntity.ts
|
|
193
216
|
import { deepPatch, NotFoundError } from "roc-db";
|
|
194
217
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const createIndexedDBAdapter: ({ operations, entities, dbName, }: {
|
|
2
|
+
operations: any;
|
|
3
|
+
entities: any;
|
|
4
|
+
dbName?: string | undefined;
|
|
5
|
+
}) => {
|
|
6
|
+
_name: string;
|
|
7
|
+
_engineOpts: EngineOptions;
|
|
8
|
+
_entityKinds: Entities[number]["shape"]["entity"]["value"];
|
|
9
|
+
_operationNames: Operations[number]["operationName"];
|
|
10
|
+
_operations: Operations;
|
|
11
|
+
_entites: Entities;
|
|
12
|
+
createRef: (entity: any) => string;
|
|
13
|
+
changeSet: (changeSetRef: any) => /*elided*/ any & {
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
};
|
|
16
|
+
syncOptimisticMutation: (mutation: any) => any;
|
|
17
|
+
} & {
|
|
18
|
+
[x: string]: any;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const begin: (request: any, engineOpts: any, callback: any) => Promise<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const deleteEntity: (txn: any, ref: any, cascade?: boolean) => Promise<boolean>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { begin } from "./begin";
|
|
2
|
+
export { createEntity } from "./createEntity";
|
|
3
|
+
export { deleteEntity } from "./deleteEntity";
|
|
4
|
+
export { end } from "./end";
|
|
5
|
+
export { getChangeSetMutations } from "./getChangeSetMutations";
|
|
6
|
+
export { findDebounceMutation } from "./findDebounceMutation";
|
|
7
|
+
export { pageMutations } from "./pageMutations";
|
|
8
|
+
export { patchEntity } from "./patchEntity";
|
|
9
|
+
export { readEntity } from "./readEntity";
|
|
10
|
+
export { readMutation } from "./readMutation";
|
|
11
|
+
export { saveMutation } from "./saveMutation";
|
|
12
|
+
export { updateEntity } from "./updateEntity";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IndexedDBReadTransaction } from "../types/IndexedDBReadTransaction";
|
|
2
|
+
export declare const patchEntity: (txn: IndexedDBReadTransaction, ref: any, { data, children, parents, ancestors }: {
|
|
3
|
+
data?: {} | undefined;
|
|
4
|
+
children?: {} | undefined;
|
|
5
|
+
parents?: {} | undefined;
|
|
6
|
+
ancestors?: {} | undefined;
|
|
7
|
+
}) => Promise<any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const readEntity: (txn: any, ref: any) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const readMutation: (engineOpts: any, ref: any) => Promise<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const saveMutation: (txn: any, finalizedMutation: any) => Promise<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createIndexedDBAdapter } from "./createIndexedDBAdapter";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roc-db/indexed-db",
|
|
3
|
-
"version": "0.2.0-pre.
|
|
3
|
+
"version": "0.2.0-pre.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"dependencies": {},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"roc-db": "0.2.0-pre.
|
|
17
|
+
"roc-db": "0.2.0-pre.7",
|
|
18
18
|
"zod": "3.24.2"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [],
|