cry-synced-db-client 0.1.201 → 0.1.203
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/CHANGELOG.md +21 -0
- package/dist/index.js +32 -12
- package/dist/src/db/sync/SyncEngine.d.ts +0 -1
- package/dist/src/types/I_SyncedDb.d.ts +6 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 0.1.203 (2026-06-15)
|
|
4
|
+
|
|
5
|
+
### `onDirtyItemStuck` callback zdaj prejme tudi `itemsContent: DirtyChange[]`
|
|
6
|
+
|
|
7
|
+
`DirtyItemStuckInfo` je dobil novo polje `itemsContent` — polni `DirtyChange[]`
|
|
8
|
+
entry-ji (vključno s `changes` payload-om), ne samo `DirtyMeta[]` z metapodatki.
|
|
9
|
+
|
|
10
|
+
**Affected paths:**
|
|
11
|
+
- `callOnDirtyItemStuck` v `SyncEngine.ts`: async, fetcha polne entry-je prek
|
|
12
|
+
`dexieDb.getDirtyChangesBatch()` in jih posreduje kot `itemsContent`
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
onDirtyItemStuck: (info) => {
|
|
16
|
+
// info.items — DirtyMeta[] (isto kot prej)
|
|
17
|
+
// info.itemsContent — DirtyChange[] (polni entry-ji s `changes` payload-om)
|
|
18
|
+
console.log('Stuck changes:', info.itemsContent[0]!.changes);
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
899 pass, 0 fail.
|
|
23
|
+
|
|
3
24
|
## 0.1.201 (2026-06-14)
|
|
4
25
|
|
|
5
26
|
### `onBeforeDirtyClearAll` callback zdaj prejme `DirtyChange[]` (ne samo `DirtyMeta[]`)
|
package/dist/index.js
CHANGED
|
@@ -3195,7 +3195,6 @@ var SUPRESS_DB_WARNINGS = true;
|
|
|
3195
3195
|
var _SyncEngine = class _SyncEngine {
|
|
3196
3196
|
constructor(config) {
|
|
3197
3197
|
this.tenant = config.tenant;
|
|
3198
|
-
this.updaterId = config.updaterId;
|
|
3199
3198
|
this.collections = config.collections;
|
|
3200
3199
|
this.dexieDb = config.dexieDb;
|
|
3201
3200
|
this.restInterface = config.restInterface;
|
|
@@ -3666,7 +3665,7 @@ var _SyncEngine = class _SyncEngine {
|
|
|
3666
3665
|
collectionName,
|
|
3667
3666
|
preprocessSkippedIds
|
|
3668
3667
|
);
|
|
3669
|
-
this.callOnDirtyItemStuck(collectionName, newlyStuck, calledFrom);
|
|
3668
|
+
await this.callOnDirtyItemStuck(collectionName, newlyStuck, calledFrom);
|
|
3670
3669
|
}
|
|
3671
3670
|
if (mappedUpdates.length === 0) continue;
|
|
3672
3671
|
collectionBatches.push([
|
|
@@ -3719,7 +3718,7 @@ var _SyncEngine = class _SyncEngine {
|
|
|
3719
3718
|
b.collection,
|
|
3720
3719
|
allIds
|
|
3721
3720
|
);
|
|
3722
|
-
this.callOnDirtyItemStuck(b.collection, newlyStuck, calledFrom);
|
|
3721
|
+
await this.callOnDirtyItemStuck(b.collection, newlyStuck, calledFrom);
|
|
3723
3722
|
}
|
|
3724
3723
|
}
|
|
3725
3724
|
throw err;
|
|
@@ -3798,7 +3797,7 @@ var _SyncEngine = class _SyncEngine {
|
|
|
3798
3797
|
collection,
|
|
3799
3798
|
retainedIds
|
|
3800
3799
|
);
|
|
3801
|
-
this.callOnDirtyItemStuck(collection, newlyStuck, calledFrom);
|
|
3800
|
+
await this.callOnDirtyItemStuck(collection, newlyStuck, calledFrom);
|
|
3802
3801
|
}
|
|
3803
3802
|
let collectionSentCount = 0;
|
|
3804
3803
|
const isWriteOnly = (_b = this.collections.get(collection)) == null ? void 0 : _b.writeOnly;
|
|
@@ -4343,12 +4342,18 @@ var _SyncEngine = class _SyncEngine {
|
|
|
4343
4342
|
}
|
|
4344
4343
|
}
|
|
4345
4344
|
}
|
|
4346
|
-
callOnDirtyItemStuck(collection, stuckMetas, calledFrom) {
|
|
4345
|
+
async callOnDirtyItemStuck(collection, stuckMetas, calledFrom) {
|
|
4347
4346
|
if (!this.callbacks.onDirtyItemStuck || stuckMetas.length === 0) return;
|
|
4348
4347
|
try {
|
|
4348
|
+
const ids = stuckMetas.map(
|
|
4349
|
+
(m) => m.id
|
|
4350
|
+
);
|
|
4351
|
+
const fullMap = await this.dexieDb.getDirtyChangesBatch(collection, ids);
|
|
4352
|
+
const itemsContent = stuckMetas.map((m) => fullMap.get(String(m.id))).filter(Boolean);
|
|
4349
4353
|
this.callbacks.onDirtyItemStuck({
|
|
4350
4354
|
collection,
|
|
4351
4355
|
items: stuckMetas,
|
|
4356
|
+
itemsContent,
|
|
4352
4357
|
calledFrom,
|
|
4353
4358
|
timestamp: /* @__PURE__ */ new Date()
|
|
4354
4359
|
});
|
|
@@ -6700,14 +6705,29 @@ var _SyncedDb = class _SyncedDb {
|
|
|
6700
6705
|
const metas = await this.dexieDb.getDirtyMeta(collectionName);
|
|
6701
6706
|
const stuck = metas.filter((m) => m.stuckSince !== void 0);
|
|
6702
6707
|
if (stuck.length === 0) continue;
|
|
6703
|
-
const
|
|
6704
|
-
const changesMap = await this.dexieDb.getDirtyChangesBatch(
|
|
6705
|
-
collectionName,
|
|
6706
|
-
stuckIds
|
|
6707
|
-
);
|
|
6708
|
+
const allDirty = await this.dexieDb.getDirty(collectionName);
|
|
6708
6709
|
const content = stuck.map((m) => {
|
|
6709
|
-
const
|
|
6710
|
-
|
|
6710
|
+
const dirtyId = String(m.id);
|
|
6711
|
+
const found = allDirty.find(
|
|
6712
|
+
(d) => String(d._id) === dirtyId
|
|
6713
|
+
);
|
|
6714
|
+
if (found) {
|
|
6715
|
+
const _a = found, { _id, _ts, _rev } = _a, changedFields = __objRest(_a, ["_id", "_ts", "_rev"]);
|
|
6716
|
+
return {
|
|
6717
|
+
collection: collectionName,
|
|
6718
|
+
id: dirtyId,
|
|
6719
|
+
changes: changedFields,
|
|
6720
|
+
baseTs: _ts,
|
|
6721
|
+
baseRev: _rev,
|
|
6722
|
+
createdAt: m.createdAt,
|
|
6723
|
+
updatedAt: m.updatedAt,
|
|
6724
|
+
firstUploadAttempt: m.firstUploadAttempt,
|
|
6725
|
+
lastUploadAttempt: m.lastUploadAttempt,
|
|
6726
|
+
numUploadAttempts: m.numUploadAttempts,
|
|
6727
|
+
stuckSince: m.stuckSince
|
|
6728
|
+
};
|
|
6729
|
+
}
|
|
6730
|
+
return __spreadProps(__spreadValues({}, m), { changes: {} });
|
|
6711
6731
|
});
|
|
6712
6732
|
this.safeCallback(this.onBeforeDirtyClearAll, {
|
|
6713
6733
|
reason: "discard-stuck",
|
|
@@ -12,7 +12,6 @@ import type { I_SyncEngine, SyncEngineConfig, SyncExtras } from "../types/manage
|
|
|
12
12
|
import type { UploadResult } from "../types/internal";
|
|
13
13
|
export declare class SyncEngine implements I_SyncEngine {
|
|
14
14
|
private readonly tenant;
|
|
15
|
-
private readonly updaterId;
|
|
16
15
|
private readonly collections;
|
|
17
16
|
private readonly dexieDb;
|
|
18
17
|
private readonly restInterface;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AggregateOptions } from "mongodb";
|
|
2
2
|
import type { Id, DbEntity, LocalDbEntity } from "./DbEntity";
|
|
3
3
|
import type { QuerySpec, QueryOpts, UpdateSpec, InsertSpec, BatchSpec, I_RestInterface, CollectionUpdateRequest, CollectionUpdateResult, GetNewerSpec } from "./I_RestInterface";
|
|
4
|
-
import type { DirtyMeta, I_DexieDb } from "./I_DexieDb";
|
|
4
|
+
import type { DirtyMeta, DirtyChange, I_DexieDb } from "./I_DexieDb";
|
|
5
5
|
import type { I_InMemDb } from "./I_InMemDb";
|
|
6
6
|
import type { I_ServerUpdateNotifier } from "./I_ServerUpdateNotifier";
|
|
7
7
|
import type { WakeSyncInfo, NetworkStatusChangeInfo } from "../db/types/managers";
|
|
@@ -101,6 +101,11 @@ export interface DirtyItemStuckInfo {
|
|
|
101
101
|
collection: string;
|
|
102
102
|
/** Meta podatki stuck itemov (vsebujejo `stuckSince`, `numUploadAttempts`, itd.) */
|
|
103
103
|
items: import("./I_DexieDb").DirtyMeta[];
|
|
104
|
+
/**
|
|
105
|
+
* Polni DirtyChange entry-ji (vključno s `changes` payload-om) za stuck iteme.
|
|
106
|
+
* Vsebuje dejanske spremenjene field-e, ne samo metapodatke.
|
|
107
|
+
*/
|
|
108
|
+
itemsContent: DirtyChange[];
|
|
104
109
|
/** Optional caller tag */
|
|
105
110
|
calledFrom?: string;
|
|
106
111
|
/** Timestamp when stuck was detected */
|