cry-synced-db-client 0.1.4 → 0.1.6
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/db/RestProxy.d.ts +3 -3
- package/dist/db/SyncedDb.d.ts +9 -0
- package/dist/index.js +2304 -20
- package/dist/types/I_SyncedDb.d.ts +54 -1
- package/package.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AggregateOptions, Timestamp } from "mongodb";
|
|
2
|
-
import type { Id, DbEntity } from "./DbEntity";
|
|
2
|
+
import type { Id, DbEntity, LocalDbEntity } from "./DbEntity";
|
|
3
3
|
import type { QuerySpec, UpdateSpec, InsertSpec, BatchSpec, I_RestInterface, CollectionUpdateRequest, CollectionUpdateResult, GetNewerSpec } from "./I_RestInterface";
|
|
4
4
|
import type { I_DexieDb } from "./I_DexieDb";
|
|
5
5
|
import type { I_InMemDb } from "./I_InMemDb";
|
|
@@ -54,6 +54,40 @@ export interface FindNewerCallInfo {
|
|
|
54
54
|
/** Timestamp when request started */
|
|
55
55
|
timestamp: Date;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Callback payload for Dexie write requests (before writing)
|
|
59
|
+
*/
|
|
60
|
+
export interface DexieWriteRequestInfo {
|
|
61
|
+
/** Collection being written to */
|
|
62
|
+
collection: string;
|
|
63
|
+
/** ID of the item being written */
|
|
64
|
+
id: Id;
|
|
65
|
+
/** Data being written */
|
|
66
|
+
data: Partial<LocalDbEntity>;
|
|
67
|
+
/** Whether this is an insert (true) or update (false) */
|
|
68
|
+
isInsert: boolean;
|
|
69
|
+
/** Timestamp when write started */
|
|
70
|
+
timestamp: Date;
|
|
71
|
+
/** Where the write was called from (for debugging) */
|
|
72
|
+
calledFrom?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Callback payload for Dexie write results (after writing)
|
|
76
|
+
*/
|
|
77
|
+
export interface DexieWriteResultInfo {
|
|
78
|
+
/** Collection that was written to */
|
|
79
|
+
collection: string;
|
|
80
|
+
/** ID of the item that was written */
|
|
81
|
+
id: Id;
|
|
82
|
+
/** Duration in ms */
|
|
83
|
+
durationMs: number;
|
|
84
|
+
/** Whether the write succeeded */
|
|
85
|
+
success: boolean;
|
|
86
|
+
/** Error if failed */
|
|
87
|
+
error?: Error;
|
|
88
|
+
/** Where the write was called from (for debugging) */
|
|
89
|
+
calledFrom?: string;
|
|
90
|
+
}
|
|
57
91
|
/**
|
|
58
92
|
* Informacije o sinhronizaciji za debugging/logging
|
|
59
93
|
*/
|
|
@@ -122,6 +156,10 @@ export interface SyncedDbConfig {
|
|
|
122
156
|
onFindNewerManyCall?: (info: FindNewerManyCallInfo) => void;
|
|
123
157
|
/** Callback when findNewer is called */
|
|
124
158
|
onFindNewerCall?: (info: FindNewerCallInfo) => void;
|
|
159
|
+
/** Callback before writing to Dexie */
|
|
160
|
+
onDexieWriteRequest?: (info: DexieWriteRequestInfo) => void;
|
|
161
|
+
/** Callback after writing to Dexie */
|
|
162
|
+
onDexieWriteResult?: (info: DexieWriteResultInfo) => void;
|
|
125
163
|
/**
|
|
126
164
|
* Interval za avtomatsko sinhronizacijo v ms (opcijsko).
|
|
127
165
|
* Če je podano, se sync() kliče avtomatsko na ta interval, ko je online.
|
|
@@ -239,4 +277,19 @@ export interface I_SyncedDb {
|
|
|
239
277
|
getDebounceRestWritesMs(): number;
|
|
240
278
|
/** Vrne vse dirty objekte iz vseh kolekcij */
|
|
241
279
|
getDirty<T extends DbEntity>(): Promise<Readonly<Record<string, readonly T[]>>>;
|
|
280
|
+
/**
|
|
281
|
+
* Deletes all data for a single collection from Dexie and in-memory.
|
|
282
|
+
* First sends all dirty data to the server.
|
|
283
|
+
* @param collection Name of the collection to delete
|
|
284
|
+
* @param force If true, deletes data even if sending dirty data fails
|
|
285
|
+
* @returns true if successful, false if sending failed and force was false
|
|
286
|
+
*/
|
|
287
|
+
deleteCollectionData(collection: string, force?: boolean): Promise<boolean>;
|
|
288
|
+
/**
|
|
289
|
+
* Deletes all data for all collections from Dexie and in-memory.
|
|
290
|
+
* First sends all dirty data to the server.
|
|
291
|
+
* @param force If true, deletes data even if sending dirty data fails
|
|
292
|
+
* @returns true if successful, false if sending failed and force was false
|
|
293
|
+
*/
|
|
294
|
+
deleteAllCollectionsData(force?: boolean): Promise<boolean>;
|
|
242
295
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cry-synced-db-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"cry-helpers": "^2.1.180",
|
|
35
|
+
"msgpackr": "^1.11.8",
|
|
35
36
|
"notepack": "^0.0.2",
|
|
36
37
|
"notepack.io": "^3.0.1",
|
|
37
38
|
"undici": "^7.18.2"
|