@geolonia/geonicdb-sdk 0.27.1 → 0.29.0

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/README.md CHANGED
@@ -183,9 +183,21 @@ Notes:
183
183
  same origin keep separate sessions.
184
184
  - Persistence is best-effort: a failed IDB write (or no Web Crypto, so the
185
185
  session stays Bearer) does not break login — it just means no rehydrate.
186
+ - If IndexedDB hangs (no completion events), each persistence operation is
187
+ bounded per stage: up to **3 seconds for open + 3 seconds for transaction**
188
+ (about 6 seconds max per operation). In `login({ rememberSession: true })`,
189
+ DPoP save and cache initialization are sequential, so the path can take up to
190
+ about 18 seconds before fail-open. Login still succeeds; only persistence is
191
+ skipped, so reloading may require signing in again.
192
+ - On persistence failure the SDK also tries to clear older persisted entries,
193
+ but if the browser's IndexedDB is permanently broken this cleanup is still
194
+ best-effort (not guaranteed). On shared devices, prefer
195
+ `rememberSession: false` and clear site data when needed.
186
196
  - Opt-in by design: shared-device flows should leave `rememberSession` off.
187
197
  - iOS Safari may evict IndexedDB under ITP after 7 days of no user
188
198
  interaction with the origin.
199
+ - Concurrent session updates across multiple tabs may cause revision counter
200
+ collisions, potentially clearing the session from another tab (known limitation).
189
201
 
190
202
  ### External Token
191
203
 
@@ -494,6 +506,11 @@ if (await db.restoreSession()) {
494
506
  They are dropped on every credential change (`login()`, `setCredentials()`,
495
507
  `logout()`) and only read back by the same principal that wrote them, via
496
508
  `restoreSession()`.
509
+ - IndexedDB persistence is bounded per stage (**open up to 3 seconds + operation
510
+ up to 3 seconds**). On timeout, the SDK keeps request/session flows alive
511
+ (fail-open), leaves persistent cache disabled for the lifetime of that SDK
512
+ instance (until reload), and opens a fail-fast circuit so queued persistence
513
+ ops do not consume timeout windows.
497
514
  - Capacity / LRU follow `cacheMaxEntries`, the same as the in-memory cache.
498
515
  - In non-browser runtimes (Node, CLI) without IndexedDB the cache stays
499
516
  in-memory only — fully backward compatible.
@@ -617,7 +634,7 @@ handle.stop();
617
634
  | `getTemporalEntities(params?)` | `GetTemporalEntitiesParams` | `Promise<Record<string, unknown>[]>` | Query temporal entities |
618
635
  | `getTemporalEntity(entityId)` | `string` | `Promise<Record<string, unknown>>` | Get temporal representation of a single entity |
619
636
 
620
- > Temporal reads answer with **`206 Partial Content`** and a `Content-Range` header when `lastN` is present or the default instance cap actually truncated the history (#2343, ETSI GS CIM 009 clause 6.3.10). Untruncated reads are `200`. Empty results and aggregated representations (`aggrMethods`) remain `200` even when `lastN` is specified, because `Content-Range` cannot be derived. Both methods are unaffected — the SDK checks `res.ok`, which accepts any 2xx. Use `requestRaw()` when you need to read the `Content-Range` value itself.
637
+ > Temporal reads return `200 OK`. Use `requestRaw()` to read `intervalafter` and `intervalbefore` from the `Link` header. Pass `lastN` to start from the most recent instances.
621
638
 
622
639
  #### `GetTemporalEntitiesParams`
623
640
 
@@ -921,3 +938,33 @@ const inArea = await client.getEntities({
921
938
  ## License
922
939
 
923
940
  MIT
941
+
942
+ ### Asynchronous query snapshots
943
+
944
+ Use `requestRaw` to obtain the creation Location (201; processing is asynchronous), then poll
945
+ it using `request` while `snapshotStatus` is `preparing`. Stop with an error on
946
+ `failure`; proceed to reads on `success`, `partial` or `empty`.
947
+ The SDK exports `CreateQuerySnapshot`, `SnapshotQuery` and `QuerySnapshot` types.
948
+
949
+ ```ts
950
+ const created = await db.requestRaw('POST', '/ngsi-ld/v1/snapshots', {
951
+ type: 'Snapshot', snapshotQueries: [{ type: 'Query', entities: [{ type: 'Room' }] }]
952
+ });
953
+ if (!created.ok) throw new Error(`Snapshot creation failed: ${created.status}`);
954
+ const location = created.headers.get('Location');
955
+ if (!location) throw new Error('Snapshot Location is missing');
956
+ let snapshot: import('@geolonia/geonicdb-sdk').QuerySnapshot;
957
+ for (;;) {
958
+ snapshot = await db.request('GET', location) as typeof snapshot;
959
+ if (snapshot.snapshotStatus === 'failure') throw new Error('Snapshot capture failed');
960
+ if (snapshot.snapshotStatus !== 'preparing') break;
961
+ await new Promise((resolve) => setTimeout(resolve, 1000));
962
+ }
963
+ const snapshotId = snapshot.id;
964
+ const frozen = await db.request('GET', '/ngsi-ld/v1/entities?type=Room', undefined, {
965
+ headers: { 'NGSILD-Snapshot': snapshotId }
966
+ });
967
+ ```
968
+
969
+ Header-bearing reads skip the SDK cache. Only local current entities and GET entities/by-id
970
+ are supported; limits and unsupported operations are described in the broker API documentation.