@qaecy/cue-sdk 0.0.14 → 0.0.16

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
@@ -155,6 +155,17 @@ const data = await cue.api.sparql(
155
155
  );
156
156
  ```
157
157
 
158
+ ### `cue.api.language` / `cue.api.setLanguage(lang)`
159
+
160
+ Active language used for language-sensitive SPARQL label queries (e.g. schema category labels and document text fields). Defaults to `'en'`. All project classes (`CueProjectSchema`, `CueProjectDocuments`, `CueProjectEntities`) read this shared value at query time.
161
+
162
+ ```typescript
163
+ cue.api.setLanguage('da');
164
+ console.log(cue.api.language); // 'da'
165
+ ```
166
+
167
+ When using `CueProjectView`, prefer calling `view.setLanguage(lang)` — it updates `api.language` **and** reloads language-sensitive cached data (schema labels, document subjects/summaries) for the new language.
168
+
158
169
  ## Projects
159
170
 
160
171
  Manage Cue projects via `cue.api.projects` (`CueProjects`).
@@ -188,6 +199,34 @@ const project = await cue.api.projects.createProject({
188
199
  });
189
200
  ```
190
201
 
202
+ ## Entities
203
+
204
+ Entity data for a project is accessed via a `CueProjectView`. Create a view with `cue.createProjectView(projectId)` and use `view.entities` (`CueProjectEntities`) for all entity-level operations.
205
+
206
+ ### `view.entities.buildSummaryGraph(format?)`
207
+
208
+ Fetches a project-level summary of entity category relationships: how many times entities of one category point to entities of another via each predicate, ordered by descending occurrence count.
209
+
210
+ | Parameter | Type | Description |
211
+ |---|---|---|
212
+ | `format` | `'graph'` \| `'md'` \| `undefined` | `'graph'` returns structured nodes + edges (`SummaryGraphData`); `'md'` returns a compact aligned text table; omit for the raw SPARQL JSON result |
213
+
214
+ ```typescript
215
+ // Structured graph — nodes and edges separated
216
+ const g = await view.entities.buildSummaryGraph('graph');
217
+ // g.entities → [{ iri: 'https://…FloorPlanDrawing' }, …]
218
+ // g.relations → [{ sourceID, predicate, targetID, weight }, …]
219
+
220
+ // Compact markdown table
221
+ const md = await view.entities.buildSummaryGraph('md');
222
+ // qcy:FloorPlanDrawing -> qcy:includesBuildingEntity -> qcy:BuildingZone (5652)
223
+ // qcy:Activity -> qcy:involvesBuildingEntity -> qcy:BuildingElement (4003)
224
+ // qcy:BuildingElement -> qcy:elementHasMaterial -> qcy:Material (3551)
225
+
226
+ // Raw SPARQL JSON result
227
+ const raw = await view.entities.buildSummaryGraph();
228
+ ```
229
+
191
230
  ## Node.js — file sync
192
231
 
193
232
  For server-side or CLI use with file-sync capabilities, import from `@qaecy/cue-sdk/node`:
@@ -237,6 +276,118 @@ Returns a `SyncResult`:
237
276
  | `totalSize` | `number` | Total size across all files |
238
277
  | `rdfWritten` | `boolean` | Whether any RDF metadata was written |
239
278
 
279
+ ## GIS
280
+
281
+ Reactive GIS service for querying spatial features within a map viewport. Accessed via the lazy getter `cue.gis` — the `CueGis` instance is created on first access and reused for the lifetime of the `Cue` object.
282
+
283
+ The `js/cue-gis` library (gateway routing, adapters, OpenStreetMap, Matrikel, etc.) is **bundled inside the SDK** — no extra install needed.
284
+
285
+ ### Quick example
286
+
287
+ ```typescript
288
+ const gis = cue.gis;
289
+
290
+ // Set the active project (drives the Cue-authenticated data source)
291
+ gis.setProjectId('my-project-id');
292
+
293
+ // Subscribe to results
294
+ const unsubCats = gis.onAvailableCategories((cats) => {
295
+ console.log('Available categories:', cats.map(c => c.label));
296
+ });
297
+
298
+ const unsubFeatures = gis.onFeaturesChange((featuresMap) => {
299
+ for (const [category, features] of featuresMap) {
300
+ console.log(`${category}: ${features.length} features`);
301
+ }
302
+ });
303
+
304
+ gis.onLoadingChange((loading) => console.log('Loading:', loading));
305
+
306
+ // On every map pan/zoom (e.g. from a Mapbox moveend event):
307
+ map.on('moveend', () => {
308
+ const b = map.getBounds();
309
+ gis.setBbox([b.getWest(), b.getSouth(), b.getEast(), b.getNorth()]);
310
+ });
311
+
312
+ // When the user toggles a category:
313
+ gis.setSelectedCategories(new Set(['cadastre', 'building']));
314
+
315
+ // Cleanup (e.g. on sign-out or component destroy):
316
+ unsubCats();
317
+ unsubFeatures();
318
+ gis.destroy();
319
+ ```
320
+
321
+ ### `cue.gis.setProjectId(projectId)`
322
+
323
+ Set the active project. Triggers a new query when a bbox is set. Pass `null` to clear.
324
+
325
+ ```typescript
326
+ cue.gis.setProjectId('my-project-id');
327
+ cue.gis.setProjectId(null); // clear
328
+ ```
329
+
330
+ ### `cue.gis.setBbox(bbox)`
331
+
332
+ Set the current map viewport as `[west, south, east, north]` (WGS-84). Triggers a debounced query (1.5 s) to list available categories and reload selected features.
333
+
334
+ ```typescript
335
+ cue.gis.setBbox([8.5, 47.3, 8.6, 47.4]);
336
+ ```
337
+
338
+ ### `cue.gis.setSelectedCategories(categories)`
339
+
340
+ Replace the full set of selected categories. Features for newly selected categories are fetched immediately; deselected ones are dropped from the results.
341
+
342
+ ```typescript
343
+ cue.gis.setSelectedCategories(new Set(['cadastre', 'building', 'greenspace']));
344
+ ```
345
+
346
+ ### `cue.gis.onAvailableCategories(callback)` → unsubscribe
347
+
348
+ Subscribe to the list of feature-category descriptors available in the current viewport. Replays the current value immediately.
349
+
350
+ ```typescript
351
+ const unsub = cue.gis.onAvailableCategories((cats) => {
352
+ // cats: GisCategoryDescriptor[]
353
+ renderCategoryPanel(cats);
354
+ });
355
+ ```
356
+
357
+ ### `cue.gis.onFeaturesChange(callback)` → unsubscribe
358
+
359
+ Subscribe to the live feature map (category → features). Replays the current value immediately.
360
+
361
+ ```typescript
362
+ const unsub = cue.gis.onFeaturesChange((map) => {
363
+ // map: Map<FeatureCategory, GisFeature[]>
364
+ for (const [cat, features] of map) renderLayer(cat, features);
365
+ });
366
+ ```
367
+
368
+ ### `cue.gis.onLoadingChange(callback)` → unsubscribe
369
+
370
+ Subscribe to the global loading state. `true` while any query is in flight.
371
+
372
+ ```typescript
373
+ const unsub = cue.gis.onLoadingChange((loading) => showSpinner(loading));
374
+ ```
375
+
376
+ ### `cue.gis.destroy()`
377
+
378
+ Cancel all in-flight requests, clear all listeners, and reset internal state. Call on sign-out or component teardown.
379
+
380
+ ### Types
381
+
382
+ | Type | Description |
383
+ |---|---|
384
+ | `GisBBox` | `[west, south, east, north]` — WGS-84 decimal degrees |
385
+ | `FeatureCategory` | `'address' \| 'poi' \| 'railway' \| 'natural' \| 'manmade' \| 'cadastre' \| 'building' \| 'greenspace' \| 'paved' \| 'zone'` |
386
+ | `GisCategoryDescriptor` | `{ category, label, description, preferredColor }` |
387
+ | `GisFeature` | Full feature record with geometry, properties, tier, source info |
388
+ | `GisFeaturesMap` | `Map<FeatureCategory, GisFeature[]>` |
389
+ | `CueGis` | The class exposed via `cue.gis` |
390
+
240
391
  ## Advanced
241
392
 
242
393
  Access the raw Firebase `Auth` instance for advanced use cases: