cry-synced-db-client 0.1.168 → 0.1.170
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 +20 -5
- package/dist/src/types/I_SyncedDb.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4381,8 +4381,8 @@ var _SyncedDb = class _SyncedDb {
|
|
|
4381
4381
|
});
|
|
4382
4382
|
this.pendingChanges = new PendingChangesManager({
|
|
4383
4383
|
tenant: this.tenant,
|
|
4384
|
-
debounceDexieWritesMs: (_l = config.debounceDexieWritesMs) != null ? _l :
|
|
4385
|
-
debounceRestWritesMs: (_m = config.debounceRestWritesMs) != null ? _m :
|
|
4384
|
+
debounceDexieWritesMs: (_l = config.debounceDexieWritesMs) != null ? _l : 200,
|
|
4385
|
+
debounceRestWritesMs: (_m = config.debounceRestWritesMs) != null ? _m : 1e3,
|
|
4386
4386
|
callbacks: {
|
|
4387
4387
|
onDexieWriteRequest: config.onDexieWriteRequest,
|
|
4388
4388
|
onDexieWriteResult: config.onDexieWriteResult,
|
|
@@ -6423,6 +6423,18 @@ var SyncedDb = _SyncedDb;
|
|
|
6423
6423
|
import Dexie from "dexie";
|
|
6424
6424
|
var SYNC_META_TABLE = "_sync_meta";
|
|
6425
6425
|
var DIRTY_CHANGES_TABLE = "_dirty_changes";
|
|
6426
|
+
var META_ONLY_DIRTY_KEYS = /* @__PURE__ */ new Set([
|
|
6427
|
+
"_id",
|
|
6428
|
+
"_ts",
|
|
6429
|
+
"_rev",
|
|
6430
|
+
"_lastUpdaterId"
|
|
6431
|
+
]);
|
|
6432
|
+
function isMetaOnlyChanges(changes) {
|
|
6433
|
+
for (const k of Object.keys(changes)) {
|
|
6434
|
+
if (!META_ONLY_DIRTY_KEYS.has(k)) return false;
|
|
6435
|
+
}
|
|
6436
|
+
return true;
|
|
6437
|
+
}
|
|
6426
6438
|
var DexieDb = class extends Dexie {
|
|
6427
6439
|
constructor(tenant, collectionConfigs) {
|
|
6428
6440
|
super(`synced-db-${tenant}`);
|
|
@@ -6587,6 +6599,7 @@ var DexieDb = class extends Dexie {
|
|
|
6587
6599
|
return result;
|
|
6588
6600
|
}
|
|
6589
6601
|
async addDirtyChange(collection, id, changes, baseMeta) {
|
|
6602
|
+
if (isMetaOnlyChanges(changes)) return;
|
|
6590
6603
|
const stringId = this.idToString(id);
|
|
6591
6604
|
const existing = await this.dirtyChanges.get([collection, stringId]);
|
|
6592
6605
|
const now = Date.now();
|
|
@@ -6609,13 +6622,15 @@ var DexieDb = class extends Dexie {
|
|
|
6609
6622
|
async addDirtyChangesBatch(collection, changesList) {
|
|
6610
6623
|
var _a, _b;
|
|
6611
6624
|
if (changesList.length === 0) return;
|
|
6625
|
+
const filtered = changesList.filter((c) => !isMetaOnlyChanges(c.changes));
|
|
6626
|
+
if (filtered.length === 0) return;
|
|
6612
6627
|
const now = Date.now();
|
|
6613
6628
|
const keys = [];
|
|
6614
|
-
for (const c of
|
|
6629
|
+
for (const c of filtered) keys.push([collection, this.idToString(c.id)]);
|
|
6615
6630
|
const existingEntries = await this.dirtyChanges.bulkGet(keys);
|
|
6616
6631
|
const toWrite = [];
|
|
6617
|
-
for (let i = 0; i <
|
|
6618
|
-
const changeItem =
|
|
6632
|
+
for (let i = 0; i < filtered.length; i++) {
|
|
6633
|
+
const changeItem = filtered[i];
|
|
6619
6634
|
const stringId = this.idToString(changeItem.id);
|
|
6620
6635
|
const existing = existingEntries[i];
|
|
6621
6636
|
if (existing) {
|
|
@@ -429,9 +429,9 @@ export interface SyncedDbConfig {
|
|
|
429
429
|
restTimeoutMs?: number;
|
|
430
430
|
/** Timeout za sync REST klice v ms (default: 120000) - daljši ker sync prenaša več podatkov */
|
|
431
431
|
syncTimeoutMs?: number;
|
|
432
|
-
/** Debounce čas za zapis v Dexie v ms (default:
|
|
432
|
+
/** Debounce čas za zapis v Dexie v ms (default: 200) */
|
|
433
433
|
debounceDexieWritesMs?: number;
|
|
434
|
-
/** Debounce čas za pošiljanje na REST v ms (default:
|
|
434
|
+
/** Debounce čas za pošiljanje na REST v ms (default: 1000) - po uspešnem zapisu v Dexie */
|
|
435
435
|
debounceRestWritesMs?: number;
|
|
436
436
|
/**
|
|
437
437
|
* Callback fired on each sync failure. Unlike the removed `onForcedOffline`,
|