cry-synced-db-client 0.1.107 → 0.1.108
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 +17 -7
- package/dist/src/types/I_SyncedDb.d.ts +14 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2499,14 +2499,24 @@ var _SyncEngine = class _SyncEngine {
|
|
|
2499
2499
|
const deletes = [];
|
|
2500
2500
|
const ids = dirtyChanges.map((dc) => dc._id);
|
|
2501
2501
|
const fullItems = await this.dexieDb.getByIds(collectionName, ids);
|
|
2502
|
-
for (
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2502
|
+
for (let i = 0; i < fullItems.length; i++) {
|
|
2503
|
+
const fullItem = fullItems[i];
|
|
2504
|
+
const id = ids[i];
|
|
2505
|
+
if (fullItem) {
|
|
2506
|
+
if (fullItem._deleted) {
|
|
2507
|
+
deletes.push(fullItem);
|
|
2508
|
+
} else {
|
|
2509
|
+
const delta = dirtyChangesMap.get(String(fullItem._id));
|
|
2510
|
+
if (delta) {
|
|
2511
|
+
updates.push({ _id: fullItem._id, delta });
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
} else if (id != null) {
|
|
2515
|
+
const delta = dirtyChangesMap.get(String(id));
|
|
2508
2516
|
if (delta) {
|
|
2509
|
-
|
|
2517
|
+
const reconstructed = __spreadProps(__spreadValues({}, delta), { _id: id });
|
|
2518
|
+
await this.dexieDb.save(collectionName, id, reconstructed);
|
|
2519
|
+
updates.push({ _id: id, delta });
|
|
2510
2520
|
}
|
|
2511
2521
|
}
|
|
2512
2522
|
}
|
|
@@ -475,6 +475,20 @@ export interface I_SyncedDb {
|
|
|
475
475
|
init(): Promise<void>;
|
|
476
476
|
/** Zapre bazo in počisti resurse */
|
|
477
477
|
close(): Promise<void>;
|
|
478
|
+
/**
|
|
479
|
+
* Flush all debounced pending writes to Dexie.
|
|
480
|
+
* Resolves when all data is persisted to IndexedDB.
|
|
481
|
+
* Does NOT upload to server — call sync() for that.
|
|
482
|
+
*/
|
|
483
|
+
flush(): Promise<void>;
|
|
484
|
+
/**
|
|
485
|
+
* Returns when all collections were last successfully synced
|
|
486
|
+
* from the server, or undefined if never synced.
|
|
487
|
+
* Persisted in Dexie via syncMeta key `__lastFullSync`.
|
|
488
|
+
* Only set when syncOnlyCollections is null (all collections active).
|
|
489
|
+
* Cleared on dropDatabase().
|
|
490
|
+
*/
|
|
491
|
+
lastSuccessfulServerSync(): Date | undefined;
|
|
478
492
|
/** Ali je povezan na server */
|
|
479
493
|
isOnline(): boolean;
|
|
480
494
|
/** Nastavi online/offline status. Returns a promise when going online. */
|