@qaecy/cue-sdk 0.0.32 → 0.0.33
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/browser.js +7509 -7182
- package/index.d.ts +2 -1
- package/index.js +18 -17
- package/node.js +28 -56
- package/package.json +11 -1
- package/PORTAL_MIGRATION.md +0 -346
- package/assets/wasm/dir_scanner_wasm.js +0 -461
- package/assets/wasm/dir_scanner_wasm_bg.wasm +0 -0
- package/cue-C7sbHLj4.js +0 -9249
- package/lib/api.d.ts +0 -57
- package/lib/auth.d.ts +0 -78
- package/lib/cache.d.ts +0 -26
- package/lib/contexts.d.ts +0 -17
- package/lib/cue-node.d.ts +0 -21
- package/lib/cue.d.ts +0 -135
- package/lib/documents.d.ts +0 -224
- package/lib/entities.d.ts +0 -187
- package/lib/extraction.d.ts +0 -48
- package/lib/gis.d.ts +0 -89
- package/lib/index-api.d.ts +0 -11
- package/lib/models.d.ts +0 -460
- package/lib/privileges.d.ts +0 -72
- package/lib/profile.d.ts +0 -60
- package/lib/project-view.d.ts +0 -114
- package/lib/project.d.ts +0 -45
- package/lib/schema.d.ts +0 -85
- package/lib/signal.d.ts +0 -54
- package/lib/storage.d.ts +0 -52
- package/lib/sync.d.ts +0 -125
- package/lib/tables.d.ts +0 -14
- package/variables.d.ts +0 -51
package/lib/api.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { CueAuth } from './auth';
|
|
2
|
-
import { SearchRequest, SearchResponse, ShaclValidationReport, UnitsConsumedDto } from './models';
|
|
3
|
-
import { CueProjects } from './project';
|
|
4
|
-
import { CueSyncApi } from './sync';
|
|
5
|
-
import { CueTables } from './tables';
|
|
6
|
-
import { CueExtraction } from './extraction';
|
|
7
|
-
import { CueContexts } from './contexts';
|
|
8
|
-
import { CueIndexApi } from './index-api';
|
|
9
|
-
export declare class CueApi {
|
|
10
|
-
private readonly _auth;
|
|
11
|
-
private readonly _gatewayUrl;
|
|
12
|
-
readonly projects: CueProjects;
|
|
13
|
-
readonly sync?: CueSyncApi | undefined;
|
|
14
|
-
readonly tables: CueTables;
|
|
15
|
-
/** Semantic extraction client — call document pages against a SemanticTemplate. */
|
|
16
|
-
readonly extraction: CueExtraction;
|
|
17
|
-
/** Session context file client — fetch and decompress context documents. */
|
|
18
|
-
readonly contexts: CueContexts;
|
|
19
|
-
/** Direct interface to the Cue Index accessor — search and lookup. */
|
|
20
|
-
readonly index: CueIndexApi;
|
|
21
|
-
/** Active language used for language-sensitive SPARQL queries across all project classes. */
|
|
22
|
-
language: string;
|
|
23
|
-
/** Updates the active language. All project classes (`CueProjectSchema`, `CueProjectDocuments`, `CueProjectEntities`) read this at query time. */
|
|
24
|
-
setLanguage(lang: string): void;
|
|
25
|
-
constructor(_auth: CueAuth, _gatewayUrl: string, projects: CueProjects, sync?: CueSyncApi | undefined);
|
|
26
|
-
/**
|
|
27
|
-
* Returns standard authentication headers for the current user.
|
|
28
|
-
* Useful when calling Cue-backed services directly (e.g. the GIS proxy).
|
|
29
|
-
*/
|
|
30
|
-
getAuthHeaders(): Promise<Record<string, string>>;
|
|
31
|
-
/**
|
|
32
|
-
* Search project documents using natural language.
|
|
33
|
-
* The user must be authenticated before calling this.
|
|
34
|
-
*/
|
|
35
|
-
search(request: SearchRequest): Promise<SearchResponse>;
|
|
36
|
-
/**
|
|
37
|
-
* Execute a SPARQL query against the project's triplestore.
|
|
38
|
-
* The user must be authenticated before calling this.
|
|
39
|
-
*/
|
|
40
|
-
sparql(query: string, projectId: string, graphType?: string): Promise<unknown>;
|
|
41
|
-
/**
|
|
42
|
-
* Validate a SHACL shape against the project's triplestore.
|
|
43
|
-
*
|
|
44
|
-
* @param shape - SHACL shapes graph in Turtle syntax.
|
|
45
|
-
* @param projectId - Project to validate against.
|
|
46
|
-
* @param options - `format`: `'json-ld'` (default, structured result) or `'turtle'` (raw string).
|
|
47
|
-
* `verbose`: include server-side timing logs.
|
|
48
|
-
*
|
|
49
|
-
* Returns a {@link ShaclValidationReport} for JSON-LD, or a Turtle string.
|
|
50
|
-
*/
|
|
51
|
-
shacl(shape: string, projectId: string, options?: {
|
|
52
|
-
format?: 'json-ld' | 'turtle';
|
|
53
|
-
verbose?: boolean;
|
|
54
|
-
graphType?: string;
|
|
55
|
-
}): Promise<ShaclValidationReport | string>;
|
|
56
|
-
getConsumption(projectId: string): Promise<UnitsConsumedDto>;
|
|
57
|
-
}
|
package/lib/auth.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Auth, User } from 'firebase/auth';
|
|
2
|
-
import { FirebaseApp } from 'firebase/app';
|
|
3
|
-
import { CueEndpoints, PasswordCredentials, SsoProvider } from './models';
|
|
4
|
-
import { ReadonlySignal } from './signal';
|
|
5
|
-
export type AuthStateListener = (user: User | null) => void;
|
|
6
|
-
export type Unsubscribe = () => void;
|
|
7
|
-
export declare class CueAuth {
|
|
8
|
-
private readonly _auth;
|
|
9
|
-
private readonly _endpoints;
|
|
10
|
-
private readonly _userSignal;
|
|
11
|
-
private readonly _tokenSignal;
|
|
12
|
-
private readonly _isSuperAdminSignal;
|
|
13
|
-
private readonly _userIdsSignal;
|
|
14
|
-
private readonly _stopTokenListener;
|
|
15
|
-
/** Reactive auth state — emits the signed-in `User`, or `null` when signed out. */
|
|
16
|
-
readonly user: ReadonlySignal<User | null>;
|
|
17
|
-
/** Reactive Firebase ID token — refreshes automatically; `null` when signed out. */
|
|
18
|
-
readonly token: ReadonlySignal<string | null>;
|
|
19
|
-
/** `true` when the current user has the `superadmin` custom claim. */
|
|
20
|
-
readonly isSuperAdmin: ReadonlySignal<boolean>;
|
|
21
|
-
/** All unique UIDs for the current user (Firebase UID + linked provider UIDs). */
|
|
22
|
-
readonly userIds: ReadonlySignal<string[]>;
|
|
23
|
-
constructor(app: FirebaseApp, useEmulator: boolean | undefined, endpoints: CueEndpoints);
|
|
24
|
-
/** Stop all internal Firebase listeners. Call when the `Cue` instance is no longer needed. */
|
|
25
|
-
destroy(): void;
|
|
26
|
-
/** Sign in with Google or Microsoft via browser popup */
|
|
27
|
-
signIn(provider: SsoProvider): Promise<User>;
|
|
28
|
-
/** Sign in with email and password */
|
|
29
|
-
signIn(provider: 'password', credentials: PasswordCredentials): Promise<User>;
|
|
30
|
-
/**
|
|
31
|
-
* Initiate a redirect-based sign-in (mobile / iframe contexts where popups
|
|
32
|
-
* are blocked). Call `checkRedirectResult()` on the next page load to
|
|
33
|
-
* retrieve the result.
|
|
34
|
-
*/
|
|
35
|
-
signInWithRedirect(provider: SsoProvider): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Retrieve the result of a redirect sign-in. Returns the signed-in `User`
|
|
38
|
-
* or `null` if there is no pending redirect result.
|
|
39
|
-
* Call this once on app startup before showing a sign-in UI.
|
|
40
|
-
*/
|
|
41
|
-
checkRedirectResult(): Promise<User | null>;
|
|
42
|
-
/**
|
|
43
|
-
* One-shot async check — returns `true` if the current user has the
|
|
44
|
-
* `superadmin` custom claim. For reactive use, read `cue.auth.isSuperAdmin`
|
|
45
|
-
* (the signal) instead.
|
|
46
|
-
*/
|
|
47
|
-
checkSuperAdmin(): Promise<boolean>;
|
|
48
|
-
/** Sign in with a Cue API key. `projectId` is optional — omit it when no project context is available (e.g. admin flows). */
|
|
49
|
-
signInWithApiKey(cueApiKey: string, projectId?: string): Promise<User>;
|
|
50
|
-
/** Sign in with a Firebase custom token (e.g. minted server-side for MCP/OAuth flows). */
|
|
51
|
-
signInWithCustomToken(token: string): Promise<User>;
|
|
52
|
-
/** Sign out the current user */
|
|
53
|
-
signOut(): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Register a new user by name and email.
|
|
56
|
-
* The backend validates that the email domain belongs to an existing organisation,
|
|
57
|
-
* creates the Firebase Auth account, assigns org membership, and dispatches a
|
|
58
|
-
* "set your password" email to the address provided.
|
|
59
|
-
* Returns the new user's UID and the organisation name on success.
|
|
60
|
-
*/
|
|
61
|
-
signUp(name: string, email: string): Promise<{
|
|
62
|
-
uid: string;
|
|
63
|
-
orgName: string;
|
|
64
|
-
}>;
|
|
65
|
-
/** Currently signed-in user, or null if not authenticated */
|
|
66
|
-
get currentUser(): User | null;
|
|
67
|
-
/** Subscribe to authentication state changes. Returns an unsubscribe function. */
|
|
68
|
-
onAuthStateChanged(listener: AuthStateListener): Unsubscribe;
|
|
69
|
-
/** Get the Firebase ID token for the current user, or null if not authenticated */
|
|
70
|
-
getToken(forceRefresh?: boolean): Promise<string | null>;
|
|
71
|
-
/**
|
|
72
|
-
* Executes a fetch with a Bearer token. On a 401 response the token is
|
|
73
|
-
* force-refreshed and the request is retried once before throwing.
|
|
74
|
-
*/
|
|
75
|
-
authenticatedFetch(url: string, init?: RequestInit): Promise<Response>;
|
|
76
|
-
/** Raw Firebase Auth instance, for advanced use cases */
|
|
77
|
-
get firebaseAuth(): Auth;
|
|
78
|
-
}
|
package/lib/cache.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FirebaseStorage } from 'firebase/storage';
|
|
2
|
-
/** Shape stored by the query cache. */
|
|
3
|
-
export interface QueryCacheEntry {
|
|
4
|
-
query: string;
|
|
5
|
-
results: unknown;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Gzip-compressed JSON cache backed by the `persistence` Cloud Storage bucket.
|
|
9
|
-
*
|
|
10
|
-
* Path conventions:
|
|
11
|
-
* - Query results: `portal/projects/{pid}/queries/{id}.json.gz`
|
|
12
|
-
* - Agent sessions: `portal/projects/{pid}/agent/{id}.json.gz`
|
|
13
|
-
* - User-project data: `portal/projects/{pid}/users/{uid}/{id}.json.gz`
|
|
14
|
-
*/
|
|
15
|
-
export declare class CueCache {
|
|
16
|
-
private readonly _storage;
|
|
17
|
-
constructor(_storage: FirebaseStorage);
|
|
18
|
-
getQueryCache(projectId: string, id: string): Promise<QueryCacheEntry | undefined>;
|
|
19
|
-
setQueryCache(projectId: string, id: string, payload: QueryCacheEntry): Promise<void>;
|
|
20
|
-
getAgentSessionCache(projectId: string, id: string): Promise<object | undefined>;
|
|
21
|
-
setAgentSessionCache(projectId: string, id: string, payload: object): Promise<void>;
|
|
22
|
-
getUserProjectCache(projectId: string, userId: string, id: string): Promise<object | undefined>;
|
|
23
|
-
setUserProjectCache(projectId: string, userId: string, id: string, payload: object): Promise<void>;
|
|
24
|
-
private _get;
|
|
25
|
-
private _set;
|
|
26
|
-
}
|
package/lib/contexts.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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/cue-node.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { CueApi } from './api';
|
|
2
|
-
import { Cue } from './cue';
|
|
3
|
-
import { CueProjects } from './project';
|
|
4
|
-
import { CueSyncApi } from './sync';
|
|
5
|
-
import { CueSdkConfig } from './models';
|
|
6
|
-
/**
|
|
7
|
-
* Node.js entry point for the QAECY SDK.
|
|
8
|
-
* Extends `Cue` with file-sync capabilities that require Node.js APIs.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const cue = new CueNode({ apiKey: '...', appId: '...', measurementId: '...' });
|
|
12
|
-
* await cue.auth.signInWithApiKey(key);
|
|
13
|
-
* await cue.api.sync.sync(localFiles, { spaceId, providerId, userId });
|
|
14
|
-
*/
|
|
15
|
-
export declare class CueNode extends Cue {
|
|
16
|
-
readonly api: CueApi & {
|
|
17
|
-
sync: CueSyncApi;
|
|
18
|
-
};
|
|
19
|
-
constructor(config: CueSdkConfig);
|
|
20
|
-
protected _buildApi(projects: CueProjects): CueApi;
|
|
21
|
-
}
|
package/lib/cue.d.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { FirebaseApp } from 'firebase/app';
|
|
2
|
-
import { FirebaseStorage } from 'firebase/storage';
|
|
3
|
-
import { CueAuth } from './auth';
|
|
4
|
-
import { CueStorage } from './storage';
|
|
5
|
-
import { CueApi } from './api';
|
|
6
|
-
import { CueGis } from './gis';
|
|
7
|
-
import { CueProjects } from './project';
|
|
8
|
-
import { CueProfile } from './profile';
|
|
9
|
-
import { CuePrivileges } from './privileges';
|
|
10
|
-
import { CueCache } from './cache';
|
|
11
|
-
import { CueProjectView, CueProjectViewOptions } from './project-view';
|
|
12
|
-
import { CueProjectEntities } from './entities';
|
|
13
|
-
import { CueProjectDocuments } from './documents';
|
|
14
|
-
import { CueEndpoints, CueSdkConfig, QueryCache } from './models';
|
|
15
|
-
/**
|
|
16
|
-
* Main entry point for the QAECY SDK (browser-safe).
|
|
17
|
-
* For Node.js use with file-sync capabilities, use `CueNode` from `js-cue-sdk/node`.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const cue = new Cue({ apiKey: '...', appId: '...', measurementId: '...' });
|
|
21
|
-
* await cue.auth.signIn('google');
|
|
22
|
-
* const results = await cue.api.search({ term: 'my query', projectId: 'project-id' });
|
|
23
|
-
*/
|
|
24
|
-
export declare class Cue {
|
|
25
|
-
readonly auth: CueAuth;
|
|
26
|
-
readonly api: CueApi;
|
|
27
|
-
readonly projects: CueProjects;
|
|
28
|
-
readonly profile: CueProfile;
|
|
29
|
-
readonly privileges: CuePrivileges;
|
|
30
|
-
readonly cache: CueCache;
|
|
31
|
-
readonly storage: CueStorage;
|
|
32
|
-
protected readonly _app: FirebaseApp;
|
|
33
|
-
protected readonly _endpoints: CueEndpoints;
|
|
34
|
-
protected readonly _isEmulator: boolean;
|
|
35
|
-
protected _storageRaw: FirebaseStorage;
|
|
36
|
-
protected _storageProcessed: FirebaseStorage;
|
|
37
|
-
private _gis;
|
|
38
|
-
private readonly _projectDocuments;
|
|
39
|
-
private readonly _verbose;
|
|
40
|
-
/**
|
|
41
|
-
* Reactive GIS service. Lazily constructed on first access.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```ts
|
|
45
|
-
* cue.gis.setProjectId('my-project');
|
|
46
|
-
* cue.gis.onAvailableCategories(cats => ...);
|
|
47
|
-
* cue.gis.setBbox([west, south, east, north]);
|
|
48
|
-
* cue.gis.setSelectedCategories(new Set(['cadastre', 'building']));
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
get gis(): CueGis;
|
|
52
|
-
constructor(config?: CueSdkConfig);
|
|
53
|
-
/**
|
|
54
|
-
* Create a `Cue` instance from an already-initialized Firebase app.
|
|
55
|
-
*
|
|
56
|
-
* Use this when the host application (e.g. cue-portal via `CueFirebase`) has
|
|
57
|
-
* already called `initializeApp()`. Reusing the same `FirebaseApp` means the
|
|
58
|
-
* SDK shares the same auth state and Firestore instance — no second login is
|
|
59
|
-
* needed and `getToken()` returns the portal user's token directly.
|
|
60
|
-
*
|
|
61
|
-
* Emulator connections are skipped because the host app already set them up.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* // In an Angular service after CueFirebase is ready:
|
|
65
|
-
* const cue = Cue.fromApp(CueFirebase.getInstance().app!, {
|
|
66
|
-
* environment: 'emulator',
|
|
67
|
-
* });
|
|
68
|
-
*/
|
|
69
|
-
static fromApp(app: FirebaseApp, config?: Omit<CueSdkConfig, 'apiKey' | 'appId' | 'measurementId'>): Cue;
|
|
70
|
-
/** Override in subclasses to provide a custom CueApi (e.g. with sync). */
|
|
71
|
-
protected _buildApi(projects: CueProjects): CueApi;
|
|
72
|
-
/** Convenience: get the current user's Firebase ID token */
|
|
73
|
-
getToken(forceRefresh?: boolean): Promise<string | null>;
|
|
74
|
-
/**
|
|
75
|
-
* Create a `CueProjectView` for the given project, wiring the SDK's query
|
|
76
|
-
* cache automatically.
|
|
77
|
-
*
|
|
78
|
-
* The view auto-fetches the document overview and entity graph on construction
|
|
79
|
-
* and exposes reactive signals for all project knowledge-graph state.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```ts
|
|
83
|
-
* const view = cue.createProjectView('my-project', { language: 'en' });
|
|
84
|
-
* view.requestEntityData(['uuid1']);
|
|
85
|
-
* const info = view.entityInfoMap.get()['uuid1'];
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
createProjectView(projectId: string, opts: Omit<CueProjectViewOptions, 'queryCache'> & {
|
|
89
|
-
queryCache?: QueryCache;
|
|
90
|
-
}): CueProjectView;
|
|
91
|
-
/**
|
|
92
|
-
* Creates a `CueProjectEntities` instance for the given project, with the
|
|
93
|
-
* SDK query cache wired automatically.
|
|
94
|
-
*
|
|
95
|
-
* Prefer this over `new CueProjectEntities(cue.api, projectId)` — it avoids
|
|
96
|
-
* the manual cache setup and keeps the instance bound to the correct API.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```ts
|
|
100
|
-
* const entities = cue.createProjectEntities('my-project');
|
|
101
|
-
* entities.requestEntityData(['uuid1']);
|
|
102
|
-
* const info = entities.entityInfoMap.get()['uuid1'];
|
|
103
|
-
*
|
|
104
|
-
* // Promise-based (no signal polling needed):
|
|
105
|
-
* const graph = await entities.buildSummaryGraph('graph');
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
createProjectEntities(projectId: string, opts?: {
|
|
109
|
-
rdfBase?: string;
|
|
110
|
-
graphType?: string;
|
|
111
|
-
queryCache?: QueryCache;
|
|
112
|
-
verbose?: boolean;
|
|
113
|
-
}): CueProjectEntities;
|
|
114
|
-
/**
|
|
115
|
-
* Creates a `CueProjectDocuments` instance for the given project, with the
|
|
116
|
-
* SDK query cache wired automatically.
|
|
117
|
-
*
|
|
118
|
-
* Prefer this over `new CueProjectDocuments(cue.api, projectId)` — it avoids
|
|
119
|
-
* the manual cache setup and keeps the instance bound to the correct API.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```ts
|
|
123
|
-
* const docs = cue.createProjectDocuments('my-project');
|
|
124
|
-
* await docs.fetchOverview();
|
|
125
|
-
* const data = await docs.fetchDocumentData(['uuid1', 'uuid2']);
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
createProjectDocuments(projectId: string, opts?: {
|
|
129
|
-
language?: string;
|
|
130
|
-
rdfBase?: string;
|
|
131
|
-
graphType?: string;
|
|
132
|
-
queryCache?: QueryCache;
|
|
133
|
-
verbose?: boolean;
|
|
134
|
-
}): CueProjectDocuments;
|
|
135
|
-
}
|
package/lib/documents.d.ts
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { CueApi } from './api';
|
|
2
|
-
import { ReadonlySignal } from './signal';
|
|
3
|
-
import { FileType } from 'js/models';
|
|
4
|
-
import { DocumentInfo, ProjectDocumentsData, QueryCache } from './models';
|
|
5
|
-
/**
|
|
6
|
-
* Manages document data for a single project.
|
|
7
|
-
*
|
|
8
|
-
* ### Data model
|
|
9
|
-
* - **`documentInfoMap`** — lazily populated per-document detail signal.
|
|
10
|
-
* Call `requestDocumentData(uuids)` to load entries; already-cached UUIDs
|
|
11
|
-
* are skipped. Data is merged incrementally.
|
|
12
|
-
* - **`projectDocumentsData`** — project-level overview (documents grouped by
|
|
13
|
-
* suffix and content category, plus duplicate count). Auto-fetched on
|
|
14
|
-
* construction via three parallel SPARQL queries that resolve as a single
|
|
15
|
-
* atomic update.
|
|
16
|
-
*
|
|
17
|
-
* ### Language
|
|
18
|
-
* `subject` and `summary` fields on documents are language-tagged in the
|
|
19
|
-
* triplestore. Pass the active language to `requestDocumentData()` and call
|
|
20
|
-
* `setLanguage()` when it changes (which clears and re-fetches the info map
|
|
21
|
-
* so labels re-resolve in the new language).
|
|
22
|
-
*
|
|
23
|
-
* ### Lifecycle
|
|
24
|
-
* Call `reset()` when the project changes. The Angular adapter's project-change
|
|
25
|
-
* effect should call this, followed by `fetchOverview()` once the triplestore
|
|
26
|
-
* is ready.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const docs = new CueProjectDocuments(cue.api, projectId, 'en');
|
|
31
|
-
* await docs.fetchOverview();
|
|
32
|
-
* docs.requestDocumentData(['uuid1', 'uuid2']);
|
|
33
|
-
* const info = docs.documentInfoMap.get()['uuid1'];
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare class CueProjectDocuments {
|
|
37
|
-
private readonly _api;
|
|
38
|
-
private readonly _projectId;
|
|
39
|
-
private readonly _queryCache?;
|
|
40
|
-
private readonly _graphType?;
|
|
41
|
-
private readonly _verbose;
|
|
42
|
-
/** Full RDF base URL for this project, e.g. `https://cue.qaecy.com/r/{pid}/` */
|
|
43
|
-
readonly baseURL: string;
|
|
44
|
-
/** Tracks the language for which `_documentInfoMap` is currently populated. */
|
|
45
|
-
private _currentLang;
|
|
46
|
-
private readonly _documentInfoMap;
|
|
47
|
-
/** Cumulative unique document UUIDs ever passed to request methods (survives cache hits). */
|
|
48
|
-
private readonly _seenIds;
|
|
49
|
-
private readonly _projectDocumentsData;
|
|
50
|
-
/** Lazily populated per-document detail map. */
|
|
51
|
-
readonly documentInfoMap: ReadonlySignal<Record<string, DocumentInfo>>;
|
|
52
|
-
/** Project-level document overview (grouped counts + sizes). */
|
|
53
|
-
readonly projectDocumentsData: ReadonlySignal<ProjectDocumentsData>;
|
|
54
|
-
constructor(_api: CueApi, _projectId: string, language?: string,
|
|
55
|
-
/** Override the RDF resource base URL. Defaults to `https://cue.qaecy.com/r/`. */
|
|
56
|
-
rdfBase?: string, _queryCache?: QueryCache | undefined, _graphType?: string | undefined, _verbose?: boolean);
|
|
57
|
-
/**
|
|
58
|
-
* Resets all document state. Call when the active project changes.
|
|
59
|
-
* Follow with `fetchOverview()` once the triplestore is ready.
|
|
60
|
-
*/
|
|
61
|
-
reset(): void;
|
|
62
|
-
/**
|
|
63
|
-
* Updates the active language and clears the document info map so that
|
|
64
|
-
* language-sensitive fields (subject, summary) are re-fetched on the next
|
|
65
|
-
* `requestDocumentData()` call.
|
|
66
|
-
*/
|
|
67
|
-
setLanguage(lang: string): void;
|
|
68
|
-
/**
|
|
69
|
-
* Fetches the three-part project overview (by suffix, by content category,
|
|
70
|
-
* duplicate count) in parallel and writes them as a single atomic update to
|
|
71
|
-
* `projectDocumentsData`. Safe to call again to refresh.
|
|
72
|
-
*/
|
|
73
|
-
fetchOverview(): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* Lazily batch-fetches core metadata for the given document UUIDs.
|
|
76
|
-
* Already-cached UUIDs are skipped. Data is merged into `documentInfoMap`
|
|
77
|
-
* once the SPARQL response arrives.
|
|
78
|
-
*/
|
|
79
|
-
requestDocumentData(uuids: string[]): void;
|
|
80
|
-
/**
|
|
81
|
-
* Promise-based alternative to {@link requestDocumentData} for non-reactive contexts.
|
|
82
|
-
*
|
|
83
|
-
* Resolves with the `DocumentInfo` entries for every requested UUID once the
|
|
84
|
-
* SPARQL response arrives. UUIDs already present in the cache are returned
|
|
85
|
-
* immediately without a network request. The result is also written into
|
|
86
|
-
* `documentInfoMap` so reactive consumers stay in sync.
|
|
87
|
-
*
|
|
88
|
-
* UUIDs not found in the triplestore are omitted from the returned map.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```ts
|
|
92
|
-
* const docs = await cueProjectDocs.fetchDocumentData(['uuid1', 'uuid2']);
|
|
93
|
-
* console.log(docs['uuid1'].subject);
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
fetchDocumentData(uuids: string[]): Promise<Record<string, DocumentInfo>>;
|
|
97
|
-
/**
|
|
98
|
-
* Fetches a lightweight document metadata shape (id/path/suffix/size) for
|
|
99
|
-
* the given UUIDs and merges the results into `documentInfoMap`.
|
|
100
|
-
*
|
|
101
|
-
* This is useful for list/table contexts that do not need language-tagged
|
|
102
|
-
* fields (`subject`, `summary`) or category/tag enrichment.
|
|
103
|
-
*
|
|
104
|
-
* UUIDs already present in `documentInfoMap` are skipped.
|
|
105
|
-
*/
|
|
106
|
-
fetchDocumentDataSimple(uuids: string[]): Promise<Record<string, DocumentInfo>>;
|
|
107
|
-
/**
|
|
108
|
-
* Returns the alternative representations of the given document UUID.
|
|
109
|
-
*
|
|
110
|
-
* Alternative representations are derived artefacts stored under
|
|
111
|
-
* `qcy:alternativeRepresentation` in the triplestore — for example a
|
|
112
|
-
* `.fragments` BIM tile derived from an `.ifc` source file.
|
|
113
|
-
*
|
|
114
|
-
* The returned `DocumentInfo` entries are also merged into
|
|
115
|
-
* `documentInfoMap` so reactive consumers stay in sync.
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```ts
|
|
119
|
-
* const alts = await docs.fetchAlternativeRepresentations('abc-123');
|
|
120
|
-
* // alts[0].suffix => '.fragments'
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
fetchAlternativeRepresentations(uuid: string): Promise<DocumentInfo[]>;
|
|
124
|
-
/**
|
|
125
|
-
* Returns a single arbitrary file path from the project's triplestore.
|
|
126
|
-
* Useful for pre-filling path-based query inputs with a realistic example.
|
|
127
|
-
*/
|
|
128
|
-
randomFilePath(): Promise<string | null>;
|
|
129
|
-
/**
|
|
130
|
-
* Fetches all `qcy:FileContent` documents whose file suffix matches one of
|
|
131
|
-
* the given extensions (e.g. `'.ifc'`, `'.pdf'`).
|
|
132
|
-
*
|
|
133
|
-
* By default returns only `{ iri, uuid }` — pass `includeMetadata: true` to
|
|
134
|
-
* also get `path`, `suffix`, and `size`. Use the default form when you intend
|
|
135
|
-
* to lazy-load full details via `requestDocumentData`.
|
|
136
|
-
*
|
|
137
|
-
* Suffixes are matched case-insensitively and the leading dot is optional
|
|
138
|
-
* (both `'ifc'` and `'.ifc'` are accepted).
|
|
139
|
-
*/
|
|
140
|
-
documentsBySuffix(suffixes: string[], includeMetadata?: false): Promise<Array<{
|
|
141
|
-
iri: string;
|
|
142
|
-
uuid: string;
|
|
143
|
-
}>>;
|
|
144
|
-
documentsBySuffix(suffixes: string[], includeMetadata: true): Promise<Array<{
|
|
145
|
-
iri: string;
|
|
146
|
-
uuid: string;
|
|
147
|
-
path: string;
|
|
148
|
-
suffix: string;
|
|
149
|
-
size: number;
|
|
150
|
-
}>>;
|
|
151
|
-
/**
|
|
152
|
-
* Fetches documents whose file suffix maps to one of the given `FileType`
|
|
153
|
-
* values (e.g. `FileType.BIM`, `FileType.CAD`).
|
|
154
|
-
*
|
|
155
|
-
* Resolves matching suffixes from `fileExtensionsInfo` and delegates to
|
|
156
|
-
* `documentsBySuffix`. Accepts the same `includeMetadata` flag.
|
|
157
|
-
*/
|
|
158
|
-
documentsByFileType(fileTypes: FileType[], includeMetadata?: false): Promise<Array<{
|
|
159
|
-
iri: string;
|
|
160
|
-
uuid: string;
|
|
161
|
-
}>>;
|
|
162
|
-
documentsByFileType(fileTypes: FileType[], includeMetadata: true): Promise<Array<{
|
|
163
|
-
iri: string;
|
|
164
|
-
uuid: string;
|
|
165
|
-
path: string;
|
|
166
|
-
suffix: string;
|
|
167
|
-
size: number;
|
|
168
|
-
}>>;
|
|
169
|
-
/**
|
|
170
|
-
* Fetches all `qcy:FileContent` documents that carry one of the given
|
|
171
|
-
* content-category IRIs (e.g. as returned by `projectDocumentsData.documentsByContentCategory`).
|
|
172
|
-
*
|
|
173
|
-
* By default returns only `{ iri, uuid }` — pass `includeMetadata: true` to
|
|
174
|
-
* also get `path`, `suffix`, and `size`. Use the default form when you intend
|
|
175
|
-
* to lazy-load full details via `requestDocumentData`.
|
|
176
|
-
*/
|
|
177
|
-
documentsByContentCategory(categoryIRIs: string[], includeMetadata?: false): Promise<Array<{
|
|
178
|
-
iri: string;
|
|
179
|
-
uuid: string;
|
|
180
|
-
}>>;
|
|
181
|
-
documentsByContentCategory(categoryIRIs: string[], includeMetadata: true): Promise<Array<{
|
|
182
|
-
iri: string;
|
|
183
|
-
uuid: string;
|
|
184
|
-
path: string;
|
|
185
|
-
suffix: string;
|
|
186
|
-
size: number;
|
|
187
|
-
}>>;
|
|
188
|
-
/**
|
|
189
|
-
* Fetches documents whose MIME type matches one of the given strings
|
|
190
|
-
* (e.g. `'application/x-step'`, `'application/pdf'`).
|
|
191
|
-
*
|
|
192
|
-
* Resolves matching suffixes from `fileExtensionsInfo` and delegates to
|
|
193
|
-
* `documentsBySuffix`. Accepts the same `includeMetadata` flag.
|
|
194
|
-
*/
|
|
195
|
-
documentsByMime(mimeTypes: string[], includeMetadata?: false): Promise<Array<{
|
|
196
|
-
iri: string;
|
|
197
|
-
uuid: string;
|
|
198
|
-
}>>;
|
|
199
|
-
documentsByMime(mimeTypes: string[], includeMetadata: true): Promise<Array<{
|
|
200
|
-
iri: string;
|
|
201
|
-
uuid: string;
|
|
202
|
-
path: string;
|
|
203
|
-
suffix: string;
|
|
204
|
-
size: number;
|
|
205
|
-
}>>;
|
|
206
|
-
/** Builds a full resource IRI from a UUID without a SPARQL round-trip. */
|
|
207
|
-
private _resourceIri;
|
|
208
|
-
private _log;
|
|
209
|
-
/** Executes the document-info SPARQL query for the given UUIDs, merges results
|
|
210
|
-
* into `documentInfoMap`, and returns the newly fetched entries. */
|
|
211
|
-
private _fetchDocumentInfoBatch;
|
|
212
|
-
/** Executes a reduced document-info query (id/path/suffix/size only), merges
|
|
213
|
-
* into `documentInfoMap`, and returns newly fetched entries. */
|
|
214
|
-
private _fetchSimpleDocumentInfoBatch;
|
|
215
|
-
private _fetchDocumentsBySuffix;
|
|
216
|
-
private _buildDocumentsBySuffixQuery;
|
|
217
|
-
private _runDocumentsBySuffixQuery;
|
|
218
|
-
private _fetchDocumentsByContentCategory;
|
|
219
|
-
private _buildDocumentsByContentCategoryQuery;
|
|
220
|
-
private _runDocumentsByContentCategoryQuery;
|
|
221
|
-
private _fetchDuplicateCount;
|
|
222
|
-
private _buildDuplicateCountQuery;
|
|
223
|
-
private _runDuplicateCountQuery;
|
|
224
|
-
}
|