cry-synced-db-client 0.1.193 → 0.1.195

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 CHANGED
@@ -1,6 +1,34 @@
1
1
  # Versions
2
2
 
3
- ## 0.1.192 (2026-05-25)
3
+ ## 0.1.195 (2026-06-09)
4
+
5
+ ### `ensureItemsAreLoaded` always fetches all IDs from server
6
+
7
+ `findById` / `findByIds` z `referToServer: true` (privzeto) sedaj **vedno
8
+ awaitata** server klic za vse zahtevane ID-je. Prej je `ensureItemsAreLoaded`
9
+ preverila Dexie in klicala server samo za ID-je, ki v Dexie niso obstajali.
10
+ To je pomenilo, da je ob in-mem cache missu (item ni v in-mem, ampak je v
11
+ Dexie) `referToServer` vrnil stale podatke brez server klica.
12
+
13
+ Popravek: `ensureItemsAreLoaded` ne preverja več Dexie pred server klicem
14
+ — vedno fetča vse ID-je iz `restInterface.findByIds`, jih shrani v Dexie +
15
+ in-mem. `referToServer` zdaj resnično awaita sveže podatke s serverja.
16
+
17
+ Internal: `ensureItemsAreLoaded` — odstranjena Dexie pre-check (`getByIds`
18
+ → `missingIds`).
19
+
20
+
21
+ ## 0.1.194 (2026-06-09)
22
+
23
+ ### Preload status `ready` fix
24
+
25
+ `ready` flag na `CollectionPreloadStatus` se sedaj nastavi na `true` že ko
26
+ je `state === "hydrated"`, ne glede na `itemCount` ali `everDownloaded`.
27
+ Prazen (še nikoli sinhroniziran) direktorij je še vedno ready — svežina
28
+ podatkov je globalni koncept (`lastSuccessfulServerSync`).
29
+
30
+
31
+ ## 0.1.193 (2026-05-25)
4
32
 
5
33
  Adds per-collection preload status reporting (non-breaking, additive).
6
34
 
@@ -11,10 +39,12 @@ New synchronous getter `getPreloadStatus(): PreloadStatus` and config callback
11
39
  (non-`writeOnly`), in-scope collection:
12
40
 
13
41
  - Per-collection `state` (`pending` / `hydrated` / `failed`), `itemCount`,
14
- `lastError`, `everDownloaded`, and a derived `ready` flag
15
- (`ready = hydrated && (itemCount > 0 || everDownloaded)` a hydrated-but-empty
16
- collection that was never downloaded is **not** ready, so a fresh device
17
- doesn't report "full" before its first server sync).
42
+ `lastError`, `everDownloaded` (informational), and a derived `ready` flag
43
+ (`ready = (state === "hydrated")` the local cache is loaded into in-mem;
44
+ empty is valid). Data *freshness* is a separate, global concern
45
+ (`lastSuccessfulServerSync`), deliberately **not** folded into `ready`:
46
+ gating on a per-collection cursor wedged the aggregate at `partial` for
47
+ genuinely-empty, never-synced collections (every tenant has several).
18
48
  - Rolled-up `aggregate`: `idle` / `full` / `partial` / `failed`.
19
49
 
20
50
  The callback fires on each hydration transition (success/failure), on scope
package/dist/index.js CHANGED
@@ -5745,17 +5745,9 @@ var _SyncedDb = class _SyncedDb {
5745
5745
  this.assertCollection(collection);
5746
5746
  if ((_a = this.collections.get(collection)) == null ? void 0 : _a.writeOnly) return;
5747
5747
  if (ids.length === 0) return;
5748
- const localItems = await this.dexieDb.getByIds(collection, ids);
5749
- const missingIds = [];
5750
- for (let i = 0; i < ids.length; i++) {
5751
- if (!localItems[i]) {
5752
- missingIds.push(ids[i]);
5753
- }
5754
- }
5755
- if (missingIds.length === 0) return;
5756
5748
  if (!this.isOnline()) return;
5757
5749
  const serverItems = await this.connectionManager.withRestTimeout(
5758
- this.restInterface.findByIds(collection, missingIds),
5750
+ this.restInterface.findByIds(collection, ids),
5759
5751
  "ensureItemsAreLoaded"
5760
5752
  );
5761
5753
  if (!serverItems || serverItems.length === 0) return;
@@ -6971,7 +6963,7 @@ var _SyncedDb = class _SyncedDb {
6971
6963
  if (!this.isSyncAllowed(name)) continue;
6972
6964
  const rec = (_a = this.preloadStatusMap.get(name)) != null ? _a : { state: "pending", itemCount: 0 };
6973
6965
  const everDownloaded = !!((_b = this.syncMetaCache.get(name)) == null ? void 0 : _b.lastSyncTs);
6974
- const ready = rec.state === "hydrated" && (rec.itemCount > 0 || everDownloaded);
6966
+ const ready = rec.state === "hydrated";
6975
6967
  if (rec.state === "failed") failedCount++;
6976
6968
  else if (ready) readyCount++;
6977
6969
  else pendingCount++;
@@ -411,18 +411,21 @@ export interface CollectionPreloadStatus {
411
411
  /** In-mem item count after the last successful hydration (0 is valid). */
412
412
  itemCount: number;
413
413
  /**
414
- * Whether the collection is considered ready: hydrated AND either has data
415
- * (`itemCount > 0`) or its cursor has advanced via a server download
416
- * (`everDownloaded`). A hydrated-but-empty collection that was never
417
- * downloaded is NOT ready — we can't tell "genuinely empty" from
418
- * "not fetched yet".
414
+ * Whether the local cache is loaded into in-mem (`state === "hydrated"`).
415
+ * Empty is valid a genuinely empty, never-synced collection is still ready.
416
+ * Data *freshness* is a separate, global concern (`lastSuccessfulServerSync`),
417
+ * not tracked per-collection.
419
418
  */
420
419
  ready: boolean;
421
420
  /** Timestamp of the last successful Dexie→in-mem hydration. */
422
421
  hydratedAt?: Date;
423
422
  /** Error message from the last failed hydration (set when `state === "failed"`). */
424
423
  lastError?: string;
425
- /** True once a server download has advanced this collection's cursor (`lastSyncTs` set). */
424
+ /**
425
+ * Informational: true once a server download has advanced this collection's
426
+ * cursor (`lastSyncTs` set). NOT part of `ready` — an unused collection may
427
+ * never get a cursor yet is perfectly loadable.
428
+ */
426
429
  everDownloaded: boolean;
427
430
  }
428
431
  /** Rolled-up preload status across all readable, in-scope collections. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.193",
3
+ "version": "0.1.195",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",