cry-synced-db-client 0.1.127 → 0.1.132

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.
Files changed (2) hide show
  1. package/dist/index.js +41 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2507,7 +2507,15 @@ var _SyncEngine = class _SyncEngine {
2507
2507
  });
2508
2508
  throw err;
2509
2509
  }
2510
- const uploadStats = await this.uploadDirtyItems(calledFrom);
2510
+ let uploadStats = { sentCount: 0 };
2511
+ try {
2512
+ uploadStats = await this.uploadDirtyItems(calledFrom);
2513
+ } catch (err) {
2514
+ console.error(
2515
+ "uploadDirtyItems failed (download succeeded, staying online):",
2516
+ err
2517
+ );
2518
+ }
2511
2519
  sentCount = uploadStats.sentCount;
2512
2520
  for (const [collectionName, stats] of Object.entries(uploadStats.collectionSentCounts || {})) {
2513
2521
  if (collectionStats[collectionName]) {
@@ -2583,6 +2591,12 @@ var _SyncEngine = class _SyncEngine {
2583
2591
  }
2584
2592
  }
2585
2593
  }
2594
+ if (updates.length === 0 && deletes.length === 0) {
2595
+ console.warn(
2596
+ `uploadDirtyItems: ${collectionName} has ${dirtyChanges.length} dirty entries but 0 updates/deletes`
2597
+ );
2598
+ continue;
2599
+ }
2586
2600
  collectionBatches.push([{
2587
2601
  collection: collectionName,
2588
2602
  batch: {
@@ -2704,7 +2718,25 @@ var _SyncEngine = class _SyncEngine {
2704
2718
  }
2705
2719
  }
2706
2720
  if (errors2) {
2707
- console.error(`Sync errors for ${collection}:`, errors2);
2721
+ console.error(
2722
+ `Sync upload errors for ${collection}:`,
2723
+ errors2,
2724
+ "\u2014 dirty entries for failed items will persist until retry"
2725
+ );
2726
+ }
2727
+ const sentIds = /* @__PURE__ */ new Set([
2728
+ ...collectionBatches.flat().filter((b) => b.collection === collection).flatMap((b) => [
2729
+ ...b.batch.updates.map((u) => String(u._id)),
2730
+ ...b.batch.deletes.map((d) => String(d._id))
2731
+ ])
2732
+ ]);
2733
+ const ackIds = new Set(allSuccessIds.map(String));
2734
+ const unacked = [...sentIds].filter((id) => !ackIds.has(id));
2735
+ if (unacked.length > 0) {
2736
+ console.warn(
2737
+ `uploadDirtyItems: ${collection}: ${unacked.length} items sent but not acknowledged:`,
2738
+ unacked
2739
+ );
2708
2740
  }
2709
2741
  }
2710
2742
  return { sentCount, collectionSentCounts };
@@ -5105,9 +5137,13 @@ var DexieDb = class extends Dexie {
5105
5137
  }
5106
5138
  async clearDirtyChangesBatch(collection, ids) {
5107
5139
  if (ids.length === 0) return;
5108
- const keys = [];
5109
- for (const id of ids) keys.push([collection, this.idToString(id)]);
5110
- await this.dirtyChanges.bulkDelete(keys);
5140
+ const promises = [];
5141
+ for (const id of ids) {
5142
+ promises.push(
5143
+ this.dirtyChanges.delete([collection, this.idToString(id)])
5144
+ );
5145
+ }
5146
+ await Promise.all(promises);
5111
5147
  }
5112
5148
  async clearDirtyChanges(collection) {
5113
5149
  await this.dirtyChanges.where("[collection+id]").between([collection, Dexie.minKey], [collection, Dexie.maxKey]).delete();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.127",
3
+ "version": "0.1.132",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",