@qaecy/cue-sdk 0.0.30 → 0.0.31

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
@@ -19,9 +19,11 @@ export { CueSignal, cueComputed, staleWhileRevalidate } from './lib/signal';
19
19
  export type { ReadonlySignal } from './lib/signal';
20
20
  export { CueCache } from './lib/cache';
21
21
  export type { QueryCacheEntry } from './lib/cache';
22
- 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';
22
+ 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, LangMap, CategoryDef, RelationshipDef, EntityCoreData, EntityRelationship, EntityRelationships, MapGeometry, EntityDetailedData, ProjectEntitiesData, DocumentInfo, DocumentSummary, ProjectDocumentsData, } from './lib/models';
23
23
  export type { AuthStateListener, Unsubscribe } from './lib/auth';
24
24
  export { CueTables } from './lib/tables';
25
25
  export type { ProjectTable } from './lib/tables';
26
26
  export { CueExtraction } from './lib/extraction';
27
27
  export type { ExtractionRequest, ExtractionResponse } from './lib/extraction';
28
+ export { CueContexts } from './lib/contexts';
29
+ export type { ContextDoc, ContextItem } from './lib/models';
package/index.js CHANGED
@@ -1,24 +1,25 @@
1
- import { C as s, a as u, b as C, c as t, d as i, e as c, f as o, g as r, h as l, i as n, j as P, k as j, l as m, m as S, n as g, o as h, p, R as E, q as R, r as f, s as d } from "./cue-DWCLcFvj.js";
1
+ import { C as s, a as u, b as C, c as t, d as i, e as o, f as c, g as r, h as n, i as l, j as P, k as j, l as m, m as S, n as g, o as h, p, q as E, R, r as f, s as d, t as x } from "./cue-VOCN5IEZ.js";
2
2
  export {
3
3
  s as Cue,
4
4
  u as CueApi,
5
5
  C as CueAuth,
6
6
  t as CueCache,
7
- i as CueExtraction,
7
+ i as CueContexts,
8
+ o as CueExtraction,
8
9
  c as CueGis,
9
- o as CuePrivileges,
10
- r as CueProfile,
10
+ r as CuePrivileges,
11
+ n as CueProfile,
11
12
  l as CueProjectDocuments,
12
- n as CueProjectEntities,
13
- P as CueProjectSchema,
14
- j as CueProjectView,
15
- m as CueProjects,
16
- S as CueSignal,
17
- g as CueStorage,
18
- h as CueSyncApi,
19
- p as CueTables,
20
- E as REQUIRED_ROLES,
21
- R as configureScanWasm,
22
- f as cueComputed,
23
- d as staleWhileRevalidate
13
+ P as CueProjectEntities,
14
+ j as CueProjectSchema,
15
+ m as CueProjectView,
16
+ S as CueProjects,
17
+ g as CueSignal,
18
+ h as CueStorage,
19
+ p as CueSyncApi,
20
+ E as CueTables,
21
+ R as REQUIRED_ROLES,
22
+ f as configureScanWasm,
23
+ d as cueComputed,
24
+ x as staleWhileRevalidate
24
25
  };
package/lib/api.d.ts CHANGED
@@ -4,6 +4,7 @@ import { CueProjects } from './project';
4
4
  import { CueSyncApi } from './sync';
5
5
  import { CueTables } from './tables';
6
6
  import { CueExtraction } from './extraction';
7
+ import { CueContexts } from './contexts';
7
8
  export declare class CueApi {
8
9
  private readonly _auth;
9
10
  private readonly _gatewayUrl;
@@ -12,6 +13,8 @@ export declare class CueApi {
12
13
  readonly tables: CueTables;
13
14
  /** Semantic extraction client — call document pages against a SemanticTemplate. */
14
15
  readonly extraction: CueExtraction;
16
+ /** Session context file client — fetch and decompress context documents. */
17
+ readonly contexts: CueContexts;
15
18
  /** Active language used for language-sensitive SPARQL queries across all project classes. */
16
19
  language: string;
17
20
  /** Updates the active language. All project classes (`CueProjectSchema`, `CueProjectDocuments`, `CueProjectEntities`) read this at query time. */
@@ -0,0 +1,17 @@
1
+ import { CueAuth } from './auth';
2
+ import { ContextDoc } from './models';
3
+ export declare class CueContexts {
4
+ private readonly _auth;
5
+ private readonly _gatewayUrl;
6
+ constructor(_auth: CueAuth, _gatewayUrl: string);
7
+ /**
8
+ * Fetch and decompress a session context document.
9
+ *
10
+ * Context files are stored as `sessions_eu_west6/{projectId}/contexts/{contextId}.json.gz`
11
+ * and served via the gateway at `GET /storage/sessions/{projectId}/contexts/{contextId}.json.gz`.
12
+ *
13
+ * @param projectId - The project the context belongs to.
14
+ * @param contextId - The context document ID (without the `.json.gz` suffix).
15
+ */
16
+ getContext(projectId: string, contextId: string): Promise<ContextDoc>;
17
+ }
package/lib/entities.d.ts CHANGED
@@ -170,6 +170,13 @@ export declare class CueProjectEntities {
170
170
  buildSummaryGraph(format: 'graph', entityIRI?: string): Promise<SummaryGraphData>;
171
171
  buildSummaryGraph(format: 'md', entityIRI?: string): Promise<string>;
172
172
  buildSummaryGraph(format?: undefined, entityIRI?: string): Promise<unknown>;
173
+ /**
174
+ * Fetches the category-summary rows. On QLever the pre-computed
175
+ * `entity-summary` materialized view is tried first; if it yields no rows we
176
+ * warn and fall back to the live aggregation query. Fuseki always uses the
177
+ * live query.
178
+ */
179
+ private _fetchSummaryData;
173
180
  private _computeEntityInfoMap;
174
181
  private _fetchOutgoingRelationships;
175
182
  private _fetchIncomingRelationships;
package/lib/models.d.ts CHANGED
@@ -60,6 +60,26 @@ export interface SearchResponse {
60
60
  sources: SearchSource[];
61
61
  rankedSources: SearchSource[];
62
62
  }
63
+ export interface ContextItem {
64
+ id: string;
65
+ type: string;
66
+ relevance: number;
67
+ info: Record<string, unknown>;
68
+ sub_items: ContextItem[];
69
+ }
70
+ export interface ContextDoc {
71
+ id: string;
72
+ total: number;
73
+ operation: {
74
+ type: string;
75
+ };
76
+ input: string;
77
+ items: ContextItem[];
78
+ within: string[];
79
+ meta: {
80
+ time_created: string;
81
+ };
82
+ }
63
83
  export interface ProjectSettings {
64
84
  views?: Array<{
65
85
  id: string;
@@ -285,12 +305,35 @@ export interface QueryCache {
285
305
  get(key: string): Promise<unknown | undefined>;
286
306
  set(key: string, data: unknown): Promise<void>;
287
307
  }
308
+ /**
309
+ * A multilingual string keyed by BCP-47 language tag. The special `default`
310
+ * key always resolves to the English value (or, when no English value exists,
311
+ * to the untagged/first available value).
312
+ */
313
+ export type LangMap = {
314
+ [lang: string]: string;
315
+ };
288
316
  /** A taxonomy node (content category or entity category) from the triplestore. */
289
317
  export interface CategoryDef {
290
318
  iri: string;
319
+ /**
320
+ * Label resolved for the currently active language (falls back to `default`
321
+ * / English). This is a computed convenience view of {@link CategoryDef.labels}.
322
+ */
291
323
  label: string;
324
+ /**
325
+ * Definition resolved for the currently active language (falls back to
326
+ * `default` / English). Computed view of {@link CategoryDef.definitions}.
327
+ */
328
+ definition?: string;
329
+ /** Full set of labels keyed by language tag (plus a `default` key). */
330
+ labels: LangMap;
331
+ /** Full set of definitions keyed by language tag (plus a `default` key). */
332
+ definitions?: LangMap;
292
333
  /** IRI of the parent category (skos:broader), if any. */
293
334
  parent?: string;
335
+ /** Whether this category is marked as deprecated in the triplestore. */
336
+ deprecated?: boolean;
294
337
  }
295
338
  /**
296
339
  * A relationship type discovered in the triplestore via `qcy:relatedEntity` property scan.
package/lib/schema.d.ts CHANGED
@@ -5,8 +5,10 @@ import { CategoryDef, QueryCache, RelationshipDef } from './models';
5
5
  * Holds the schema for a single project: available content categories,
6
6
  * entity categories, and entity relationship types.
7
7
  *
8
- * Data is fetched lazily on construction and cached per language so that
9
- * switching back to a previously loaded language is instant.
8
+ * The full schema is fetched **once** (a single SPARQL query covering all three
9
+ * collections) and cached. Labels and definitions are retained for every
10
+ * available language as {@link LangMap}s; switching language is therefore a
11
+ * cheap, client-side re-projection with no extra network round-trip.
10
12
  *
11
13
  * ### Reactive paradigm
12
14
  * All three collections are exposed as `ReadonlySignal<T>`. Framework adapters
@@ -21,8 +23,8 @@ import { CategoryDef, QueryCache, RelationshipDef } from './models';
21
23
  * ```ts
22
24
  * const schema = new CueProjectSchema(cue.api, projectId, 'en');
23
25
  * schema.availableContentCategories.get(); // CategoryDef[]
24
- * schema.setLanguage('da'); // loads from cache or re-fetches
25
- * await schema.refresh(); // force re-fetch current language
26
+ * schema.setLanguage('da'); // re-projects cached data instantly
27
+ * await schema.refresh(); // force re-fetch
26
28
  * ```
27
29
  */
28
30
  export declare class CueProjectSchema {
@@ -30,8 +32,10 @@ export declare class CueProjectSchema {
30
32
  private readonly _projectId;
31
33
  private readonly _queryCache?;
32
34
  private readonly _graphType?;
33
- private readonly _cache;
35
+ private _snapshot?;
36
+ private _inflight?;
34
37
  private _currentLang;
38
+ private readonly _verbose;
35
39
  private readonly _contentCategories;
36
40
  private readonly _entityCategories;
37
41
  private readonly _relationships;
@@ -46,26 +50,36 @@ export declare class CueProjectSchema {
46
50
  * completed (or failed). Await this before reading signal values imperatively.
47
51
  */
48
52
  readonly ready: Promise<void>;
49
- constructor(_api: CueApi, _projectId: string, language: string, _queryCache?: QueryCache | undefined, _graphType?: string | undefined);
53
+ constructor(_api: CueApi, _projectId: string, language: string, _queryCache?: QueryCache | undefined, _graphType?: string | undefined, verbose?: boolean);
50
54
  /** Returns the currently active language. */
51
55
  get language(): string;
52
56
  /**
53
- * Switch the active language. If the data for this language has already been
54
- * fetched it is applied immediately from cache; otherwise a new SPARQL fetch
55
- * is triggered.
57
+ * Switch the active language. Re-projects the already-fetched schema for the
58
+ * new language without re-querying; only triggers a fetch if nothing has been
59
+ * loaded yet.
56
60
  */
57
61
  setLanguage(lang: string): void;
58
62
  /**
59
- * Force a re-fetch for the current language, bypassing the cache.
63
+ * Force a re-fetch of the schema, bypassing the cache.
60
64
  * Useful when the triplestore data has changed.
61
65
  */
62
66
  refresh(): Promise<void>;
63
67
  private _load;
68
+ /**
69
+ * Fetches the schema once. On QLever the pre-computed `schemas` materialized
70
+ * view is tried first; if it yields no rows we warn and fall back to the live
71
+ * schema query.
72
+ */
73
+ private _fetchSnapshot;
64
74
  private _apply;
65
- private _fetchCategories;
66
- private _buildCategoriesQuery;
67
- private _runCategoriesQuery;
68
- private _fetchRelationships;
69
- private _buildRelationshipsQuery;
70
- private _runRelationshipsQuery;
75
+ /** Projects a language-independent {@link SchemaNode} into a {@link CategoryDef}. */
76
+ private _toDef;
77
+ /**
78
+ * Single query covering content categories, entity categories and entity
79
+ * relationship types. Labels/definitions are returned untouched (with their
80
+ * language tags) so they can be grouped into {@link LangMap}s client-side.
81
+ */
82
+ private _buildSchemaQuery;
83
+ /** Runs a schema query and groups the flat rows into a {@link SchemaSnapshot}. */
84
+ private _runSchemaQuery;
71
85
  }
package/lib/storage.d.ts CHANGED
@@ -1,30 +1,41 @@
1
- import { CueBlobStorage } from 'js-databases';
1
+ import { CueAuth } from './auth';
2
2
  export type StorageBucket = 'raw' | 'processed';
3
3
  /**
4
- * Provides document download URL resolution against the Cue Firebase Storage buckets.
4
+ * Provides document download URL resolution proxied through the Cue gateway.
5
+ *
6
+ * The returned URLs require an `Authorization: Bearer {token}` header — use
7
+ * `cue.api.getAuthHeaders()` or `cue.auth.authenticatedFetch()` to fetch them.
8
+ * For use in `<img src>` / `<video src>`, convert to a blob URL first:
9
+ * ```ts
10
+ * const response = await cue.auth.authenticatedFetch(url);
11
+ * const objectUrl = URL.createObjectURL(await response.blob());
12
+ * ```
5
13
  *
6
14
  * @example
7
15
  * ```ts
8
- * const url = await cue.storage.getDownloadUrl('my-project', 'abc123', '.pdf');
16
+ * const url = cue.storage.getDownloadUrl('my-project', 'abc123', '.pdf');
17
+ * const res = await cue.auth.authenticatedFetch(url);
9
18
  * ```
10
19
  */
11
20
  export declare class CueStorage {
12
- private readonly _blob;
13
- constructor(_blob: CueBlobStorage);
21
+ private readonly _auth;
22
+ private readonly _gatewayUrl;
23
+ constructor(_auth: CueAuth, _gatewayUrl: string);
14
24
  /**
15
- * Returns a Firebase authenticated download URL for a document stored in Cue.
25
+ * Returns a gateway download URL for a document stored in Cue.
16
26
  *
17
27
  * The storage path is `{projectId}/{uuid}{suffix}`, e.g. `my-project/abc-123.pdf`.
28
+ * The returned URL must be fetched with an Authorization header.
18
29
  *
19
30
  * @param projectId - The Cue project (space) ID.
20
31
  * @param uuid - The document UUID.
21
32
  * @param suffix - File suffix including the leading dot, e.g. `'.pdf'`, `'.ifc'`.
22
33
  * @param bucket - `'raw'` (default, original uploads) or `'processed'` (derived artefacts).
23
34
  */
24
- getDownloadUrl(projectId: string, uuid: string, suffix: string, bucket?: StorageBucket): Promise<string>;
35
+ getDownloadUrl(projectId: string, uuid: string, suffix: string, bucket?: StorageBucket): string;
25
36
  /**
26
- * Returns a Firebase authenticated download URL for an alternative representation
27
- * using its full `qcy:remoteRelativePath` stored in the processed bucket.
37
+ * Returns a gateway download URL for an alternative representation using its
38
+ * full `qcy:remoteRelativePath` stored in the processed bucket.
28
39
  *
29
40
  * Use this instead of `getDownloadUrl` when the document info was obtained via
30
41
  * `fetchAlternativeRepresentations` and carries a `remoteRelativePath`.
@@ -32,5 +43,10 @@ export declare class CueStorage {
32
43
  * @param remoteRelativePath - The full path in the processed bucket,
33
44
  * e.g. `{projectId}/fragments/{uuid}.fragments`.
34
45
  */
35
- getAltRepDownloadUrl(remoteRelativePath: string): Promise<string>;
46
+ getAltRepDownloadUrl(remoteRelativePath: string): string;
47
+ /**
48
+ * Fetch a file through the gateway and return it as a Blob.
49
+ * Convenience wrapper around `getDownloadUrl` + `authenticatedFetch`.
50
+ */
51
+ downloadBlob(projectId: string, uuid: string, suffix: string, bucket?: StorageBucket): Promise<Blob>;
36
52
  }
package/node.js CHANGED
@@ -1,59 +1,61 @@
1
- import { C as h, B as l, t as _, u as E, v as S, o as m, w as P, a as d } from "./cue-DWCLcFvj.js";
2
- import { b as j, c as x, d as y, e as I, f as K, g as L, h as v, i as H, j as N, k as O, l as D, m as G, n as W, p as k, R as q, q as Q, r as V, s as z } from "./cue-DWCLcFvj.js";
3
- import { getStorage as t, connectStorageEmulator as w } from "firebase/storage";
1
+ import { C as S, B as _, u as l, v as E, w as m, x as P, p as d, y as w, a as U } from "./cue-VOCN5IEZ.js";
2
+ import { b as y, c as I, d as K, e as L, f as N, g as O, h as v, i as H, j as D, k as G, l as W, m as k, n as q, o as Q, q as V, R as z, r as F, s as J, t as M } from "./cue-VOCN5IEZ.js";
3
+ import { getStorage as s, connectStorageEmulator as b } from "firebase/storage";
4
4
  import "firebase/firestore";
5
- class A extends h {
6
- constructor(s) {
7
- super(s);
5
+ class A extends S {
6
+ constructor(t) {
7
+ super(t);
8
8
  }
9
- _buildApi(s) {
10
- const r = t(this._app, l), i = t(this._app, _), n = this._storageRaw, u = t(this._app, E), c = this._storageProcessed, e = t(this._app, S);
9
+ _buildApi(t) {
10
+ const r = s(this._app, _), i = s(this._app, l), n = this._storageRaw, u = s(this._app, E), c = this._storageProcessed, e = s(this._app, m);
11
11
  if (this._isEmulator) {
12
- const p = this._endpoints.storageEmulatorHost, g = this._endpoints.storageEmulatorPort;
13
- w(e, p, g);
12
+ const g = this._endpoints.storageEmulatorHost, h = this._endpoints.storageEmulatorPort;
13
+ b(e, g, h);
14
14
  }
15
- const C = new P({
15
+ const C = s(this._app, P), p = new w({
16
16
  storageChatSessions: r,
17
17
  storageLogs: i,
18
18
  storageRaw: n,
19
19
  storagePersistence: u,
20
20
  storageProcessed: c,
21
- storagePublic: e
22
- }), a = new m(
21
+ storagePublic: e,
22
+ storageSessions: C
23
+ }), a = new d(
23
24
  this.auth,
24
- s,
25
- C,
25
+ t,
26
+ p,
26
27
  this._endpoints.gatewayUrl
27
- ), o = new d(
28
+ ), o = new U(
28
29
  this.auth,
29
30
  this._endpoints.gatewayUrl,
30
- s,
31
+ t,
31
32
  a
32
33
  );
33
34
  return a._bindApi(o), o;
34
35
  }
35
36
  }
36
37
  export {
37
- h as Cue,
38
- d as CueApi,
39
- j as CueAuth,
40
- x as CueCache,
41
- y as CueExtraction,
42
- I as CueGis,
38
+ S as Cue,
39
+ U as CueApi,
40
+ y as CueAuth,
41
+ I as CueCache,
42
+ K as CueContexts,
43
+ L as CueExtraction,
44
+ N as CueGis,
43
45
  A as CueNode,
44
- K as CuePrivileges,
45
- L as CueProfile,
46
- v as CueProjectDocuments,
47
- H as CueProjectEntities,
48
- N as CueProjectSchema,
49
- O as CueProjectView,
50
- D as CueProjects,
51
- G as CueSignal,
52
- W as CueStorage,
53
- m as CueSyncApi,
54
- k as CueTables,
55
- q as REQUIRED_ROLES,
56
- Q as configureScanWasm,
57
- V as cueComputed,
58
- z as staleWhileRevalidate
46
+ O as CuePrivileges,
47
+ v as CueProfile,
48
+ H as CueProjectDocuments,
49
+ D as CueProjectEntities,
50
+ G as CueProjectSchema,
51
+ W as CueProjectView,
52
+ k as CueProjects,
53
+ q as CueSignal,
54
+ Q as CueStorage,
55
+ d as CueSyncApi,
56
+ V as CueTables,
57
+ z as REQUIRED_ROLES,
58
+ F as configureScanWasm,
59
+ J as cueComputed,
60
+ M as staleWhileRevalidate
59
61
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qaecy/cue-sdk",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
package/variables.d.ts CHANGED
@@ -14,6 +14,7 @@ export declare const GCP_REGION = "europe-west6";
14
14
  export declare const COLLECTION_API_KEYS = "apiKeys";
15
15
  export declare const COLLECTION_ORGANIZATIONS = "organizations";
16
16
  export declare const COLLECTION_PROJECTS = "projects";
17
+ export declare const BUCKET_SESSIONS = "sessions_eu_west6";
17
18
  export declare const BUCKET_CHAT_SESSIONS = "spaces_chats_eu_west6";
18
19
  export declare const BUCKET_RAW = "spaces_raw_eu_west6";
19
20
  export declare const BUCKET_PROCESSED = "spaces_processed_eu_west6";
@@ -36,6 +37,9 @@ export declare const ENDPOINT_QLEVER_QUERY = "/qlever-server/qlever/query";
36
37
  export declare const ENDPOINT_QLEVER_UPDATE = "/qlever-server/qlever/update";
37
38
  export declare const ENDPOINT_QLEVER_SHACL = "/qlever-server/qlever/shacl";
38
39
  export declare const ENDPOINT_FSS_BATCH = "/commands/file-system-structure/batch";
40
+ export declare const ENDPOINT_STORAGE_SESSIONS = "/storage/sessions";
41
+ export declare const ENDPOINT_STORAGE_RAW = "/storage/raw";
42
+ export declare const ENDPOINT_STORAGE_PROCESSED = "/storage/processed";
39
43
  export declare const MICROSOFT_PROVIDER_ID = "microsoft.com";
40
44
  export declare const SUPERADMIN_ROLE = "superadmin";
41
45
  /**