@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/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { Cue } from './lib/cue';
2
+ export { CueGis } from './lib/gis';
3
+ export type { GisBBox, GisCategoryDescriptor, GisFeature, GisFeaturesMap, FeatureCategory } from './lib/gis';
2
4
  export { CueAuth } from './lib/auth';
3
5
  export { CueApi } from './lib/api';
4
6
  export { CueSyncApi, configureScanWasm } from './lib/sync';
@@ -17,3 +19,5 @@ export { CueCache } from './lib/cache';
17
19
  export type { QueryCacheEntry } from './lib/cache';
18
20
  export type { CueSdkConfig, SsoProvider, PasswordCredentials, SearchRequest, SearchResponse, SearchSource, SearchOptions, ProjectData, ProjectSettings, CreateProjectOptions, SyncOptions, SyncResult, SyncPreview, ScanOutputRecord, UnitsConsumedDto, OrganizationData, OrgMember, ProfileSSOAccount, APIKeyInfo, APIKeyDoc, ProjectDoc, OrganizationDoc, UserDoc, RDFWritingDoc, ViewDefinition, QueryCache, CategoryDef, RelationshipDef, EntityCoreData, EntityRelationship, EntityRelationships, MapGeometry, EntityDetailedData, ProjectEntitiesData, DocumentInfo, DocumentSummary, ProjectDocumentsData, } from './lib/models';
19
21
  export type { AuthStateListener, Unsubscribe } from './lib/auth';
22
+ export { CueTables } from './lib/tables';
23
+ export type { ProjectTable } from './lib/tables';
package/index.js CHANGED
@@ -1,20 +1,22 @@
1
- import { C as s, a as u, b as C, c, d as i, e as t, f as o, g as r, h as l, i as n, j as P, k as j, l as m, R as h, m as R, n as S, s as f } from "./cue-DjbCgB69.js";
1
+ import { C as s, a as u, b as C, c as i, d as c, e as t, f as o, g as r, h as l, i as n, j as P, k as j, l as m, m as h, n as p, R, o as S, p as f, s as g } from "./cue-DiFnK22Q.js";
2
2
  export {
3
3
  s as Cue,
4
4
  u as CueApi,
5
5
  C as CueAuth,
6
- c as CueCache,
7
- i as CuePrivileges,
8
- t as CueProfile,
9
- o as CueProjectDocuments,
10
- r as CueProjectEntities,
11
- l as CueProjectSchema,
12
- n as CueProjectView,
13
- P as CueProjects,
14
- j as CueSignal,
15
- m as CueSyncApi,
16
- h as REQUIRED_ROLES,
17
- R as configureScanWasm,
18
- S as cueComputed,
19
- f as staleWhileRevalidate
6
+ i as CueCache,
7
+ c as CueGis,
8
+ t as CuePrivileges,
9
+ o as CueProfile,
10
+ r as CueProjectDocuments,
11
+ l as CueProjectEntities,
12
+ n as CueProjectSchema,
13
+ P as CueProjectView,
14
+ j as CueProjects,
15
+ m as CueSignal,
16
+ h as CueSyncApi,
17
+ p as CueTables,
18
+ R as REQUIRED_ROLES,
19
+ S as configureScanWasm,
20
+ f as cueComputed,
21
+ g as staleWhileRevalidate
20
22
  };
package/lib/api.d.ts CHANGED
@@ -1,12 +1,18 @@
1
1
  import { CueAuth } from './auth';
2
- import { SearchRequest, SearchResponse, UnitsConsumedDto } from './models';
2
+ import { SearchRequest, SearchResponse, ShaclValidationReport, UnitsConsumedDto } from './models';
3
3
  import { CueProjects } from './project';
4
4
  import { CueSyncApi } from './sync';
5
+ import { CueTables } from './tables';
5
6
  export declare class CueApi {
6
7
  private readonly _auth;
7
8
  private readonly _gatewayUrl;
8
9
  readonly projects: CueProjects;
9
10
  readonly sync?: CueSyncApi | undefined;
11
+ readonly tables: CueTables;
12
+ /** Active language used for language-sensitive SPARQL queries across all project classes. */
13
+ language: string;
14
+ /** Updates the active language. All project classes (`CueProjectSchema`, `CueProjectDocuments`, `CueProjectEntities`) read this at query time. */
15
+ setLanguage(lang: string): void;
10
16
  constructor(_auth: CueAuth, _gatewayUrl: string, projects: CueProjects, sync?: CueSyncApi | undefined);
11
17
  /**
12
18
  * Returns standard authentication headers for the current user.
@@ -23,5 +29,20 @@ export declare class CueApi {
23
29
  * The user must be authenticated before calling this.
24
30
  */
25
31
  sparql(query: string, projectId: string, graphType?: string): Promise<unknown>;
32
+ /**
33
+ * Validate a SHACL shape against the project's triplestore.
34
+ *
35
+ * @param shape - SHACL shapes graph in Turtle syntax.
36
+ * @param projectId - Project to validate against.
37
+ * @param options - `format`: `'json-ld'` (default, structured result) or `'turtle'` (raw string).
38
+ * `verbose`: include server-side timing logs.
39
+ *
40
+ * Returns a {@link ShaclValidationReport} for JSON-LD, or a Turtle string.
41
+ */
42
+ shacl(shape: string, projectId: string, options?: {
43
+ format?: 'json-ld' | 'turtle';
44
+ verbose?: boolean;
45
+ graphType?: string;
46
+ }): Promise<ShaclValidationReport | string>;
26
47
  getConsumption(projectId: string): Promise<UnitsConsumedDto>;
27
48
  }
package/lib/cue.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { FirebaseApp } from 'firebase/app';
2
2
  import { CueAuth } from './auth';
3
3
  import { CueApi } from './api';
4
+ import { CueGis } from './gis';
4
5
  import { CueProjects } from './project';
5
6
  import { CueProfile } from './profile';
6
7
  import { CuePrivileges } from './privileges';
@@ -26,6 +27,19 @@ export declare class Cue {
26
27
  protected readonly _app: FirebaseApp;
27
28
  protected readonly _endpoints: CueEndpoints;
28
29
  protected readonly _isEmulator: boolean;
30
+ private _gis;
31
+ /**
32
+ * Reactive GIS service. Lazily constructed on first access.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * cue.gis.setProjectId('my-project');
37
+ * cue.gis.onAvailableCategories(cats => ...);
38
+ * cue.gis.setBbox([west, south, east, north]);
39
+ * cue.gis.setSelectedCategories(new Set(['cadastre', 'building']));
40
+ * ```
41
+ */
42
+ get gis(): CueGis;
29
43
  constructor(config?: CueSdkConfig);
30
44
  /**
31
45
  * Create a `Cue` instance from an already-initialized Firebase app.
@@ -39,14 +39,15 @@ export declare class CueProjectDocuments {
39
39
  private readonly _graphType?;
40
40
  /** Full RDF base URL for this project, e.g. `https://cue.qaecy.com/r/{pid}/` */
41
41
  readonly baseURL: string;
42
- private _language;
42
+ /** Tracks the language for which `_documentInfoMap` is currently populated. */
43
+ private _currentLang;
43
44
  private readonly _documentInfoMap;
44
45
  private readonly _projectDocumentsData;
45
46
  /** Lazily populated per-document detail map. */
46
47
  readonly documentInfoMap: ReadonlySignal<Record<string, DocumentInfo>>;
47
48
  /** Project-level document overview (grouped counts + sizes). */
48
49
  readonly projectDocumentsData: ReadonlySignal<ProjectDocumentsData>;
49
- constructor(_api: CueApi, _projectId: string, language: string,
50
+ constructor(_api: CueApi, _projectId: string, language?: string,
50
51
  /** Override the RDF resource base URL. Defaults to `https://cue.qaecy.com/r/`. */
51
52
  rdfBase?: string, _queryCache?: QueryCache | undefined, _graphType?: string | undefined);
52
53
  /**
@@ -72,6 +73,11 @@ export declare class CueProjectDocuments {
72
73
  * once the SPARQL response arrives.
73
74
  */
74
75
  requestDocumentData(uuids: string[]): void;
76
+ /**
77
+ * Returns a single arbitrary file path from the project's triplestore.
78
+ * Useful for pre-filling path-based query inputs with a realistic example.
79
+ */
80
+ randomFilePath(): Promise<string | null>;
75
81
  private _fetchDocumentsBySuffix;
76
82
  private _buildDocumentsBySuffixQuery;
77
83
  private _runDocumentsBySuffixQuery;
package/lib/entities.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CueApi } from './api';
2
2
  import { ReadonlySignal } from './signal';
3
- import { EntityDetailedData, EntityRelationships, ProjectEntitiesData, QueryCache } from './models';
3
+ import { EntityDetailedData, EntityRelationships, ProjectEntitiesData, SummaryGraphData, QueryCache } from './models';
4
4
  /**
5
5
  * Manages entity data for a single project.
6
6
  *
@@ -97,6 +97,42 @@ export declare class CueProjectEntities {
97
97
  * document service (future `CueProjectDocuments`).
98
98
  */
99
99
  fetchEntityDocuments(iri: string): Promise<string[]>;
100
+ /**
101
+ * Fetches all `qcy:EntityCategory` IRIs and their preferred labels for this
102
+ * project. Uses `api.language` (default `'en'`);
103
+ * falls back to an untagged label when no match is found.
104
+ */
105
+ contentCategoriesInProject(orderByOccurences?: boolean): Promise<{
106
+ iri: string;
107
+ label: string;
108
+ }[]>;
109
+ /**
110
+ * Fetches a summary graph of entity category relationships for the project.
111
+ *
112
+ * Each row describes how many times entities of `sourceCat` point to
113
+ * entities of `targetCat` via a given `predicate`, ordered by descending
114
+ * occurrence count.
115
+ *
116
+ * @param format
117
+ * - `undefined` — raw SPARQL JSON result
118
+ * - `'graph'` — structured `{ entities, relations }` with predicates and weights
119
+ * - `'md'` — compact aligned text table
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * // Structured graph (nodes + edges)
124
+ * const g = await entities.buildSummaryGraph('graph');
125
+ * // g.entities → [{ iri: 'https://…FloorPlanDrawing' }, …]
126
+ * // g.relations → [{ sourceID, predicate, targetID, weight }, …]
127
+ *
128
+ * // Markdown table
129
+ * const md = await entities.buildSummaryGraph('md');
130
+ * // qcy:FloorPlanDrawing -> qcy:includesBuildingEntity -> qcy:BuildingZone (5652)
131
+ * ```
132
+ */
133
+ buildSummaryGraph(format: 'graph'): Promise<SummaryGraphData>;
134
+ buildSummaryGraph(format: 'md'): Promise<string>;
135
+ buildSummaryGraph(format?: undefined): Promise<unknown>;
100
136
  private _computeEntityInfoMap;
101
137
  private _fetchOutgoingRelationships;
102
138
  private _fetchIncomingRelationships;
package/lib/gis.d.ts ADDED
@@ -0,0 +1,89 @@
1
+ import { BBox, FeatureCategory, FeatureCategoryDescriptor, GisFeature } from 'js/cue-gis';
2
+ export type GisBBox = BBox;
3
+ export type { FeatureCategory };
4
+ export type GisCategoryDescriptor = FeatureCategoryDescriptor;
5
+ export type { GisFeature };
6
+ export type GisFeaturesMap = Map<FeatureCategory, GisFeature[]>;
7
+ type Listener<T> = (value: T) => void;
8
+ /**
9
+ * Reactive GIS service, exposed lazily as `cue.gis`.
10
+ *
11
+ * Push-based: consumers set the active bbox and selected categories; results are
12
+ * delivered via subscription callbacks. All debouncing and request cancellation
13
+ * are handled internally.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * cue.gis.setProjectId('my-project-id');
18
+ * cue.gis.onAvailableCategories(cats => console.log(cats));
19
+ *
20
+ * // On every map pan/zoom:
21
+ * cue.gis.setBbox([west, south, east, north]);
22
+ *
23
+ * // When the user toggles a category:
24
+ * cue.gis.setSelectedCategories(new Set(['cadastre', 'building']));
25
+ *
26
+ * // Cleanup:
27
+ * cue.gis.destroy();
28
+ * ```
29
+ */
30
+ export declare class CueGis {
31
+ private readonly _getAuthHeaders;
32
+ private readonly _gatewayUrl;
33
+ private _bbox;
34
+ private _projectId;
35
+ private _selectedCategories;
36
+ private _queryToken;
37
+ private _categoryTokens;
38
+ private _debounceTimer;
39
+ private _availableCategories;
40
+ private _features;
41
+ private readonly _catListeners;
42
+ private readonly _featListeners;
43
+ private readonly _loadListeners;
44
+ private _gatewayCache;
45
+ private _gatewayProjectId;
46
+ /** @internal — construct via `cue.gis`, not directly. */
47
+ constructor(_getAuthHeaders: () => Promise<Record<string, string>>, _gatewayUrl: string);
48
+ /**
49
+ * Update the current map viewport.
50
+ * Triggers a debounced query for available categories and reloads selected ones.
51
+ */
52
+ setBbox(bbox: BBox): void;
53
+ /**
54
+ * Set or clear the active project.
55
+ * Rebuilds the authenticated adapter so subsequent requests carry the new project header.
56
+ */
57
+ setProjectId(projectId: string | null): void;
58
+ /**
59
+ * Replace the full set of selected categories.
60
+ * Newly added categories begin loading immediately; removed categories are cleared.
61
+ */
62
+ setSelectedCategories(categories: Set<FeatureCategory>): void;
63
+ /**
64
+ * Subscribe to available-category updates.
65
+ * Replays the current value immediately, then fires on every bbox change.
66
+ * @returns An unsubscribe function.
67
+ */
68
+ onAvailableCategories(cb: Listener<GisCategoryDescriptor[]>): () => void;
69
+ /**
70
+ * Subscribe to the feature map (category → GisFeature[]).
71
+ * Replays the current value immediately, then fires whenever features change.
72
+ * @returns An unsubscribe function.
73
+ */
74
+ onFeaturesChange(cb: Listener<GisFeaturesMap>): () => void;
75
+ /**
76
+ * Subscribe to the global loading state.
77
+ * Fires `true` while the category list is being queried, `false` when done.
78
+ * @returns An unsubscribe function.
79
+ */
80
+ onLoadingChange(cb: Listener<boolean>): () => void;
81
+ /** Cancel all pending requests and clear all listeners. */
82
+ destroy(): void;
83
+ private _scheduleDebouncedQuery;
84
+ private _getGateway;
85
+ private _queryLayers;
86
+ private _loadCategory;
87
+ private _emitFeatures;
88
+ private _emitLoading;
89
+ }
package/lib/models.d.ts CHANGED
@@ -152,6 +152,34 @@ export interface UnitsConsumedDto {
152
152
  unitsAvailable: number;
153
153
  unitsConsumed: number;
154
154
  }
155
+ export interface ShaclViolation {
156
+ '@type': string;
157
+ 'sh:focusNode': {
158
+ '@id': string;
159
+ } | {
160
+ '@value': string;
161
+ };
162
+ 'sh:resultPath'?: {
163
+ '@id': string;
164
+ };
165
+ 'sh:resultSeverity': {
166
+ '@id': string;
167
+ };
168
+ 'sh:sourceConstraintComponent': {
169
+ '@id': string;
170
+ };
171
+ 'sh:sourceShape'?: {
172
+ '@id': string;
173
+ };
174
+ 'sh:resultMessage': string;
175
+ 'sh:value'?: string;
176
+ }
177
+ export interface ShaclValidationReport {
178
+ '@context': Record<string, string>;
179
+ '@type': string;
180
+ 'sh:conforms': boolean;
181
+ 'sh:result'?: ShaclViolation[];
182
+ }
155
183
  export interface SyncPreview {
156
184
  /** Per-extension cost breakdown for files not yet synced */
157
185
  costRecords: ScanOutputRecord[];
@@ -320,6 +348,22 @@ export interface ProjectEntitiesData {
320
348
  targetID: string;
321
349
  }>;
322
350
  }
351
+ /**
352
+ * Structured summary graph returned by `buildSummaryGraph('graph')`.
353
+ * Nodes are deduplicated category IRIs; edges carry the predicate and
354
+ * occurrence count from the summary query.
355
+ */
356
+ export interface SummaryGraphData {
357
+ entities: Array<{
358
+ iri: string;
359
+ }>;
360
+ relations: Array<{
361
+ sourceID: string;
362
+ predicate: string;
363
+ targetID: string;
364
+ weight: number;
365
+ }>;
366
+ }
323
367
  /** Core metadata for a single document (FileContent node). */
324
368
  export interface DocumentInfo {
325
369
  id: string;
@@ -42,6 +42,11 @@ export declare class CueProjectView {
42
42
  readonly availableEntityCategories: ReadonlySignal<CategoryDef[]>;
43
43
  /** Available entity relationship types. Auto-fetched on init. */
44
44
  readonly availableEntityRelationships: ReadonlySignal<RelationshipDef[]>;
45
+ /**
46
+ * Resolves when the initial schema load has completed. Await before reading
47
+ * schema signal values imperatively.
48
+ */
49
+ readonly schemaReady: Promise<void>;
45
50
  /** Merged per-entity detail map. Populated lazily via `requestEntityData()` etc. */
46
51
  readonly entityInfoMap: ReadonlySignal<Record<string, EntityDetailedData>>;
47
52
  /** Project-level entity co-occurrence graph. Fetched once on init. */
package/lib/schema.d.ts CHANGED
@@ -31,7 +31,7 @@ export declare class CueProjectSchema {
31
31
  private readonly _queryCache?;
32
32
  private readonly _graphType?;
33
33
  private readonly _cache;
34
- private readonly _language;
34
+ private _currentLang;
35
35
  private readonly _contentCategories;
36
36
  private readonly _entityCategories;
37
37
  private readonly _relationships;
@@ -41,6 +41,11 @@ export declare class CueProjectSchema {
41
41
  readonly availableEntityCategories: ReadonlySignal<CategoryDef[]>;
42
42
  /** Currently active entity relationship types for the selected language. */
43
43
  readonly availableEntityRelationships: ReadonlySignal<RelationshipDef[]>;
44
+ /**
45
+ * Resolves when the initial schema load for the constructor language has
46
+ * completed (or failed). Await this before reading signal values imperatively.
47
+ */
48
+ readonly ready: Promise<void>;
44
49
  constructor(_api: CueApi, _projectId: string, language: string, _queryCache?: QueryCache | undefined, _graphType?: string | undefined);
45
50
  /** Returns the currently active language. */
46
51
  get language(): string;
@@ -0,0 +1,14 @@
1
+ import { CueAuth } from './auth';
2
+ export interface ProjectTable {
3
+ id: string;
4
+ title: string;
5
+ columnDefs: Record<string, unknown>[];
6
+ rowDef: string;
7
+ }
8
+ export declare class CueTables {
9
+ private readonly _auth;
10
+ private readonly _gatewayUrl;
11
+ constructor(_auth: CueAuth, _gatewayUrl: string);
12
+ listTables(projectId: string): Promise<ProjectTable[]>;
13
+ saveTables(tables: ProjectTable[] | unknown[], projectId: string): Promise<void>;
14
+ }
package/node.js CHANGED
@@ -1,36 +1,36 @@
1
- import { C as _, B as E, o as l, p as S, q as m, r as P, t as d, l as U, u as B, a as R } from "./cue-DjbCgB69.js";
2
- import { b as y, c as I, d as L, e as O, f as x, g as D, h as H, i as N, j as W, k as v, R as k, m as q, n as G, s as Q } from "./cue-DjbCgB69.js";
1
+ import { C as _, B as E, q as l, r as S, t as m, u as P, v as d, m as U, w as B, a as R } from "./cue-DiFnK22Q.js";
2
+ import { b as y, c as I, d as L, e as O, f as v, g as x, h as D, i as H, j as N, k as W, l as G, n as k, R as q, o as Q, p as V, s as z } from "./cue-DiFnK22Q.js";
3
3
  import { getStorage as s, connectStorageEmulator as o } from "firebase/storage";
4
4
  import "firebase/firestore";
5
- class w extends _ {
5
+ class f extends _ {
6
6
  constructor(t) {
7
7
  super(t);
8
8
  }
9
9
  _buildApi(t) {
10
- const p = s(this._app, E), C = s(this._app, l), i = s(this._app, S), g = s(this._app, m), r = s(this._app, P), n = s(this._app, d);
10
+ const C = s(this._app, E), p = s(this._app, l), i = s(this._app, S), g = s(this._app, m), r = s(this._app, P), n = s(this._app, d);
11
11
  if (this._isEmulator) {
12
12
  const e = this._endpoints.storageEmulatorHost, a = this._endpoints.storageEmulatorPort;
13
13
  o(i, e, a), o(r, e, a), o(n, e, a);
14
14
  }
15
15
  const h = new B({
16
- storageChatSessions: p,
17
- storageLogs: C,
16
+ storageChatSessions: C,
17
+ storageLogs: p,
18
18
  storageRaw: i,
19
19
  storagePersistence: g,
20
20
  storageProcessed: r,
21
21
  storagePublic: n
22
- }), c = new U(
22
+ }), u = new U(
23
23
  this.auth,
24
24
  t,
25
25
  h,
26
26
  this._endpoints.gatewayUrl
27
- ), u = new R(
27
+ ), c = new R(
28
28
  this.auth,
29
29
  this._endpoints.gatewayUrl,
30
30
  t,
31
- c
31
+ u
32
32
  );
33
- return c._bindApi(u), u;
33
+ return u._bindApi(c), c;
34
34
  }
35
35
  }
36
36
  export {
@@ -38,18 +38,20 @@ export {
38
38
  R as CueApi,
39
39
  y as CueAuth,
40
40
  I as CueCache,
41
- w as CueNode,
42
- L as CuePrivileges,
43
- O as CueProfile,
41
+ L as CueGis,
42
+ f as CueNode,
43
+ O as CuePrivileges,
44
+ v as CueProfile,
44
45
  x as CueProjectDocuments,
45
46
  D as CueProjectEntities,
46
47
  H as CueProjectSchema,
47
48
  N as CueProjectView,
48
49
  W as CueProjects,
49
- v as CueSignal,
50
+ G as CueSignal,
50
51
  U as CueSyncApi,
51
- k as REQUIRED_ROLES,
52
- q as configureScanWasm,
53
- G as cueComputed,
54
- Q as staleWhileRevalidate
52
+ k as CueTables,
53
+ q as REQUIRED_ROLES,
54
+ Q as configureScanWasm,
55
+ V as cueComputed,
56
+ z as staleWhileRevalidate
55
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qaecy/cue-sdk",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
package/variables.d.ts CHANGED
@@ -30,8 +30,10 @@ export declare const ENDPOINT_CREATE_PROJECT = "/commands/admin/project";
30
30
  export declare const ENDPOINT_SEARCH = "/assistant/search";
31
31
  export declare const ENDPOINT_FUSEKI_QUERY = "/triplestore/query";
32
32
  export declare const ENDPOINT_FUSEKI_UPDATE = "/triplestore/update";
33
+ export declare const ENDPOINT_FUSEKI_SHACL = "/triplestore/shacl";
33
34
  export declare const ENDPOINT_QLEVER_QUERY = "/qlever-server/qlever/query";
34
35
  export declare const ENDPOINT_QLEVER_UPDATE = "/qlever-server/qlever/update";
36
+ export declare const ENDPOINT_QLEVER_SHACL = "/qlever-server/qlever/shacl";
35
37
  export declare const ENDPOINT_FSS_BATCH = "/commands/file-system-structure/batch";
36
38
  export declare const MICROSOFT_PROVIDER_ID = "microsoft.com";
37
39
  export declare const SUPERADMIN_ROLE = "superadmin";