@geolonia/geonicdb-sdk 0.28.0 → 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 +31 -1
- package/geonicdb.cjs.map +2 -2
- package/geonicdb.d.ts +45 -0
- package/geonicdb.iife.js.map +2 -2
- package/geonicdb.mjs.map +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -634,7 +634,7 @@ handle.stop();
|
|
|
634
634
|
| `getTemporalEntities(params?)` | `GetTemporalEntitiesParams` | `Promise<Record<string, unknown>[]>` | Query temporal entities |
|
|
635
635
|
| `getTemporalEntity(entityId)` | `string` | `Promise<Record<string, unknown>>` | Get temporal representation of a single entity |
|
|
636
636
|
|
|
637
|
-
> Temporal reads
|
|
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.
|
|
638
638
|
|
|
639
639
|
#### `GetTemporalEntitiesParams`
|
|
640
640
|
|
|
@@ -938,3 +938,33 @@ const inArea = await client.getEntities({
|
|
|
938
938
|
## License
|
|
939
939
|
|
|
940
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.
|