@qaecy/cue-sdk 0.0.33 → 0.0.35
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/assets/wasm/dir_scanner_wasm.mjs +461 -0
- package/assets/wasm/dir_scanner_wasm_bg.wasm +0 -0
- package/document-filter-Dr_-QbaZ.js +10187 -0
- package/index.d.ts +14 -3
- package/index.js +33 -24
- package/lib/api.d.ts +79 -0
- package/lib/app-data.d.ts +21 -0
- package/lib/apps.d.ts +24 -0
- package/lib/auth.d.ts +77 -0
- package/lib/cache.d.ts +26 -0
- package/lib/contexts.d.ts +17 -0
- package/lib/cue-node.d.ts +19 -0
- package/lib/cue.d.ts +129 -0
- package/lib/currency.d.ts +34 -0
- package/lib/document-filter.d.ts +76 -0
- package/lib/documents.d.ts +223 -0
- package/lib/entities.d.ts +211 -0
- package/lib/extraction.d.ts +48 -0
- package/lib/gis.d.ts +89 -0
- package/lib/index-api.d.ts +39 -0
- package/lib/mcp.d.ts +61 -0
- package/lib/models.d.ts +662 -0
- package/lib/privileges.d.ts +76 -0
- package/lib/processing.d.ts +25 -0
- package/lib/profile.d.ts +128 -0
- package/lib/project-view.d.ts +112 -0
- package/lib/project.d.ts +56 -0
- package/lib/schema.d.ts +84 -0
- package/lib/signal.d.ts +38 -0
- package/lib/signup.d.ts +73 -0
- package/lib/storage.d.ts +52 -0
- package/lib/sync.d.ts +153 -0
- package/lib/tables.d.ts +14 -0
- package/lib/user-settings.d.ts +22 -0
- package/node.js +33 -24
- package/package.json +5 -6
- package/variables.d.ts +71 -0
- package/browser.js +0 -37970
package/index.d.ts
CHANGED
|
@@ -4,10 +4,16 @@ export { CueStorage } from './lib/storage';
|
|
|
4
4
|
export type { StorageBucket } from './lib/storage';
|
|
5
5
|
export type { GisBBox, GisCategoryDescriptor, GisFeature, GisFeaturesMap, FeatureCategory } from './lib/gis';
|
|
6
6
|
export { CueAuth } from './lib/auth';
|
|
7
|
+
export { CueSignUp, CueRequestError } from './lib/signup';
|
|
8
|
+
export type { OrgSignUpPayload, OrgSignUpPlan } from './lib/signup';
|
|
7
9
|
export { CueApi } from './lib/api';
|
|
8
10
|
export { CueIndexApi } from './lib/index-api';
|
|
11
|
+
export { CueMcp } from './lib/mcp';
|
|
12
|
+
export type { McpCallOptions } from './lib/mcp';
|
|
9
13
|
export type { IndexSearchRequest, IndexItem, IndexSearchResponse, IndexFilterOption, IndexAppliedFilters, AvailableFiltersResponse, SearchFilter, DocumentFilterOption, AvailableDocumentFilters, } from './lib/models';
|
|
10
14
|
export { CueSyncApi, configureScanWasm } from './lib/sync';
|
|
15
|
+
export { CueProcessingApi } from './lib/processing';
|
|
16
|
+
export type { ProcessingStatusWatcher } from './lib/processing';
|
|
11
17
|
export { CueProjectSchema } from './lib/schema';
|
|
12
18
|
export { CueDocumentFilter } from './lib/document-filter';
|
|
13
19
|
export { CueProjectEntities } from './lib/entities';
|
|
@@ -18,15 +24,20 @@ export { CueProjects } from './lib/project';
|
|
|
18
24
|
export { CueProfile } from './lib/profile';
|
|
19
25
|
export { CuePrivileges, REQUIRED_ROLES } from './lib/privileges';
|
|
20
26
|
export type { UserProjectRole, Privileges } from './lib/privileges';
|
|
21
|
-
export { CueSignal, cueComputed
|
|
27
|
+
export { CueSignal, cueComputed } from './lib/signal';
|
|
22
28
|
export type { ReadonlySignal } from './lib/signal';
|
|
23
29
|
export { CueCache } from './lib/cache';
|
|
24
30
|
export type { QueryCacheEntry } from './lib/cache';
|
|
25
|
-
export
|
|
31
|
+
export { CueCurrency, SUPPORTED_CURRENCIES, BASE_CURRENCY } from './lib/currency';
|
|
32
|
+
export type { SupportedCurrency, CurrencyRates } from './lib/currency';
|
|
33
|
+
export type { CueSdkConfig, SsoProvider, PasswordCredentials, SearchRequest, SearchResponse, SearchSource, SearchOptions, ProjectData, ProjectSettings, QleverStats, CreateProjectOptions, SyncOptions, SyncResult, SyncPreview, ScanOutputRecord, UnitCreditMap, UnitsConsumedDto, OrgCreditsDto, OrgPlanSummary, MonthlyConsumptionDto, ProjectConsumptionReportDto, OrgConsumptionReportDto, OrganizationData, OrgMember, ProfileSSOAccount, APIKeyInfo, APIKeyDoc, ProjectDoc, OrganizationDoc, UserDoc, UserSettings, CustomAppRecord, CustomAppWithHtml, CreateCustomAppOptions, UpdateCustomAppOptions, RDFWritingDoc, ProcessingStatus, ProcessingStage, ViewDefinition, QueryCache, LangMap, CategoryDef, RelationshipDef, EntityCoreData, EntityRelationship, EntityRelationships, MapGeometry, EntityDetailedData, ProjectEntitiesData, SummaryGraphData, DocumentInfo, DocumentSummary, ProjectDocumentsData, } from './lib/models';
|
|
26
34
|
export type { AuthStateListener, Unsubscribe } from './lib/auth';
|
|
27
35
|
export { CueTables } from './lib/tables';
|
|
28
36
|
export type { ProjectTable } from './lib/tables';
|
|
29
37
|
export { CueExtraction } from './lib/extraction';
|
|
30
38
|
export type { ExtractionRequest, ExtractionResponse } from './lib/extraction';
|
|
31
39
|
export { CueContexts } from './lib/contexts';
|
|
32
|
-
export type { ContextDoc, ContextItem } from './lib/models';
|
|
40
|
+
export type { ContextDoc, ContextItem, McpContext } from './lib/models';
|
|
41
|
+
export { CueAppData } from './lib/app-data';
|
|
42
|
+
export { CueApps } from './lib/apps';
|
|
43
|
+
export { CueUserSettings } from './lib/user-settings';
|
package/index.js
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as a, C as u, f as C, A as t, D as r, c as i, v as c, z as o, w as n, m as p, y as E, a as S, g as P, h as R, s as A, k as g, r as m, o as j, n as l, l as D, p as U, q as x, e as f, d as h, t as d, b as y, i as I, x as _, E as b, R as q, S as v, j as w, u as B } from "./document-filter-Dr_-QbaZ.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
u as
|
|
5
|
-
C as
|
|
6
|
-
t as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
c as
|
|
10
|
-
|
|
11
|
-
n as
|
|
12
|
-
|
|
3
|
+
a as BASE_CURRENCY,
|
|
4
|
+
u as Cue,
|
|
5
|
+
C as CueApi,
|
|
6
|
+
t as CueAppData,
|
|
7
|
+
r as CueApps,
|
|
8
|
+
i as CueAuth,
|
|
9
|
+
c as CueCache,
|
|
10
|
+
o as CueContexts,
|
|
11
|
+
n as CueCurrency,
|
|
12
|
+
p as CueDocumentFilter,
|
|
13
|
+
E as CueExtraction,
|
|
14
|
+
S as CueGis,
|
|
15
|
+
P as CueIndexApi,
|
|
16
|
+
R as CueMcp,
|
|
17
|
+
A as CuePrivileges,
|
|
18
|
+
g as CueProcessingApi,
|
|
13
19
|
m as CueProfile,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
j as CueProjectDocuments,
|
|
21
|
+
l as CueProjectEntities,
|
|
22
|
+
D as CueProjectSchema,
|
|
23
|
+
U as CueProjectView,
|
|
24
|
+
x as CueProjects,
|
|
25
|
+
f as CueRequestError,
|
|
26
|
+
h as CueSignUp,
|
|
27
|
+
d as CueSignal,
|
|
28
|
+
y as CueStorage,
|
|
29
|
+
I as CueSyncApi,
|
|
30
|
+
_ as CueTables,
|
|
31
|
+
b as CueUserSettings,
|
|
32
|
+
q as REQUIRED_ROLES,
|
|
33
|
+
v as SUPPORTED_CURRENCIES,
|
|
34
|
+
w as configureScanWasm,
|
|
35
|
+
B as cueComputed
|
|
27
36
|
};
|
package/lib/api.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
import { CueMcp } from './mcp';
|
|
10
|
+
import { CueAppData } from './app-data';
|
|
11
|
+
import { CueApps } from './apps';
|
|
12
|
+
import { CueUserSettings } from './user-settings';
|
|
13
|
+
import { CueProcessingApi } from './processing';
|
|
14
|
+
export declare class CueApi {
|
|
15
|
+
private readonly _auth;
|
|
16
|
+
private readonly _gatewayUrl;
|
|
17
|
+
readonly projects: CueProjects;
|
|
18
|
+
readonly sync?: CueSyncApi | undefined;
|
|
19
|
+
readonly tables: CueTables;
|
|
20
|
+
/** Semantic extraction client — call document pages against a SemanticTemplate. */
|
|
21
|
+
readonly extraction: CueExtraction;
|
|
22
|
+
/** Session context file client — fetch and decompress context documents. */
|
|
23
|
+
readonly contexts: CueContexts;
|
|
24
|
+
/** Direct interface to the Cue Index accessor — search and lookup. */
|
|
25
|
+
readonly index: CueIndexApi;
|
|
26
|
+
/** Generic caller for Cue Index MCP data-tool endpoints — returns each tool's Context result (`{ id, text }`) proxied as-is. */
|
|
27
|
+
readonly mcp: CueMcp;
|
|
28
|
+
/** Per-app, per-user data storage — small JSON blobs namespaced by app UUID. */
|
|
29
|
+
readonly appData: CueAppData;
|
|
30
|
+
/** Studio apps saved and shared within an organization (e.g. built with the AI App Builder). */
|
|
31
|
+
readonly apps: CueApps;
|
|
32
|
+
/** Global, per-user app settings — one small JSON blob shared across the whole portal (e.g. language). */
|
|
33
|
+
readonly userSettings: CueUserSettings;
|
|
34
|
+
/** Live pipeline-progress status for a project (upload → processing → loading → enrichment). */
|
|
35
|
+
readonly processing: CueProcessingApi;
|
|
36
|
+
/** Active language used for language-sensitive SPARQL queries across all project classes. */
|
|
37
|
+
language: string;
|
|
38
|
+
/** Updates the active language. All project classes (`CueProjectSchema`, `CueProjectDocuments`, `CueProjectEntities`) read this at query time. */
|
|
39
|
+
setLanguage(lang: string): void;
|
|
40
|
+
constructor(_auth: CueAuth, _gatewayUrl: string, projects: CueProjects, sync?: CueSyncApi | undefined);
|
|
41
|
+
/**
|
|
42
|
+
* Returns standard authentication headers for the current user.
|
|
43
|
+
* Useful when calling Cue-backed services directly (e.g. the GIS proxy).
|
|
44
|
+
*/
|
|
45
|
+
getAuthHeaders(): Promise<Record<string, string>>;
|
|
46
|
+
/**
|
|
47
|
+
* Search project documents using natural language.
|
|
48
|
+
* The user must be authenticated before calling this.
|
|
49
|
+
*/
|
|
50
|
+
search(request: SearchRequest): Promise<SearchResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Execute a SPARQL query against the project's triplestore.
|
|
53
|
+
* The user must be authenticated before calling this.
|
|
54
|
+
*/
|
|
55
|
+
sparql(query: string, projectId: string, graphType?: string): Promise<unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* Validate a SHACL shape against the project's triplestore.
|
|
58
|
+
*
|
|
59
|
+
* @param shape - SHACL shapes graph in Turtle syntax.
|
|
60
|
+
* @param projectId - Project to validate against.
|
|
61
|
+
* @param options - `format`: `'json-ld'` (default, structured result) or `'turtle'` (raw string).
|
|
62
|
+
* `verbose`: include server-side timing logs.
|
|
63
|
+
*
|
|
64
|
+
* Returns a {@link ShaclValidationReport} for JSON-LD, or a Turtle string.
|
|
65
|
+
*/
|
|
66
|
+
shacl(shape: string, projectId: string, options?: {
|
|
67
|
+
format?: 'json-ld' | 'turtle';
|
|
68
|
+
verbose?: boolean;
|
|
69
|
+
graphType?: string;
|
|
70
|
+
}): Promise<ShaclValidationReport | string>;
|
|
71
|
+
/**
|
|
72
|
+
* Per-extension credit rates for `tier` (e.g. `{ pdf: 4, ifc: 2, dwg: 2 }`),
|
|
73
|
+
* read from the public `unit-credit.json` rate table. Used to show usage
|
|
74
|
+
* estimates (e.g. the sign-up plan-selection step) without an authenticated
|
|
75
|
+
* project context.
|
|
76
|
+
*/
|
|
77
|
+
getUnitCredits(tier: 's' | 'm' | 'l'): Promise<Record<string, number>>;
|
|
78
|
+
getConsumption(projectId: string): Promise<UnitsConsumedDto>;
|
|
79
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CueAuth } from './auth';
|
|
2
|
+
/**
|
|
3
|
+
* Per-app, per-user data storage. Each app persists its own small JSON blob
|
|
4
|
+
* (capped at 100KB server-side), keyed by a UUID4 the app hardcodes for
|
|
5
|
+
* itself — this namespaces the data so no two apps can collide.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CueAppData {
|
|
8
|
+
private readonly _auth;
|
|
9
|
+
private readonly _gatewayUrl;
|
|
10
|
+
constructor(_auth: CueAuth, _gatewayUrl: string);
|
|
11
|
+
/**
|
|
12
|
+
* Fetch this app's persisted data for the current user.
|
|
13
|
+
* Returns `null` if nothing has been saved yet.
|
|
14
|
+
*/
|
|
15
|
+
get<T = unknown>(appId: string): Promise<T | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Save this app's data for the current user. Overwrites any previous value.
|
|
18
|
+
* The server rejects payloads larger than 100KB.
|
|
19
|
+
*/
|
|
20
|
+
set(appId: string, data: unknown): Promise<void>;
|
|
21
|
+
}
|
package/lib/apps.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CueAuth } from './auth';
|
|
2
|
+
import { CreateCustomAppOptions, CustomAppRecord, CustomAppWithHtml, UpdateCustomAppOptions } from './models';
|
|
3
|
+
/**
|
|
4
|
+
* Studio apps saved and shared within an organization — e.g. apps built with
|
|
5
|
+
* the AI App Builder. Distinct from `cue.api.appData`: that's a private,
|
|
6
|
+
* per-user settings blob namespaced by an app's own id; this is the shared
|
|
7
|
+
* app record itself (name, HTML, author) visible to every member of the app's
|
|
8
|
+
* organization.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CueApps {
|
|
11
|
+
private readonly _auth;
|
|
12
|
+
private readonly _gatewayUrl;
|
|
13
|
+
constructor(_auth: CueAuth, _gatewayUrl: string);
|
|
14
|
+
/** List every custom app shared within the given organization (metadata only, no HTML). */
|
|
15
|
+
list(organizationId: string): Promise<CustomAppRecord[]>;
|
|
16
|
+
/** Fetch a single custom app's full record, including its HTML body. */
|
|
17
|
+
get(id: string): Promise<CustomAppWithHtml>;
|
|
18
|
+
/** Save a new custom app, shared with every member of `organizationID`. Any org member may create one. */
|
|
19
|
+
create(options: CreateCustomAppOptions): Promise<CustomAppRecord>;
|
|
20
|
+
/** Update an existing custom app. Only the original author or an organization admin may do this. */
|
|
21
|
+
update(id: string, options: UpdateCustomAppOptions): Promise<CustomAppRecord>;
|
|
22
|
+
/** Delete a custom app. Only the original author or an organization admin may do this. */
|
|
23
|
+
remove(id: string): Promise<void>;
|
|
24
|
+
}
|
package/lib/auth.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
/**
|
|
53
|
+
* Mint a short-lived Firebase custom token for the current user, scoped to
|
|
54
|
+
* the same identity as their existing session. Used to bootstrap a second
|
|
55
|
+
* `Cue` instance inside a sandboxed, cross-origin context (e.g. an
|
|
56
|
+
* `srcdoc` iframe hosting AI-generated app HTML) that has no access to the
|
|
57
|
+
* portal's IndexedDB-persisted session — the sandboxed instance calls
|
|
58
|
+
* `signInWithCustomToken` with the returned token instead of relying on
|
|
59
|
+
* restored auth state.
|
|
60
|
+
*/
|
|
61
|
+
mintAppSessionToken(): Promise<string>;
|
|
62
|
+
/** Sign out the current user */
|
|
63
|
+
signOut(): Promise<void>;
|
|
64
|
+
/** Currently signed-in user, or null if not authenticated */
|
|
65
|
+
get currentUser(): User | null;
|
|
66
|
+
/** Subscribe to authentication state changes. Returns an unsubscribe function. */
|
|
67
|
+
onAuthStateChanged(listener: AuthStateListener): Unsubscribe;
|
|
68
|
+
/** Get the Firebase ID token for the current user, or null if not authenticated */
|
|
69
|
+
getToken(forceRefresh?: boolean): Promise<string | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Executes a fetch with a Bearer token. On a 401 response the token is
|
|
72
|
+
* force-refreshed and the request is retried once before throwing.
|
|
73
|
+
*/
|
|
74
|
+
authenticatedFetch(url: string, init?: RequestInit): Promise<Response>;
|
|
75
|
+
/** Raw Firebase Auth instance, for advanced use cases */
|
|
76
|
+
get firebaseAuth(): Auth;
|
|
77
|
+
}
|
package/lib/cache.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CueApi } from './api';
|
|
2
|
+
import { Cue } from './cue';
|
|
3
|
+
import { CueSyncApi } from './sync';
|
|
4
|
+
import { CueSdkConfig } from './models';
|
|
5
|
+
/**
|
|
6
|
+
* Node.js entry point for the QAECY SDK.
|
|
7
|
+
* Extends `Cue` with file-sync capabilities that require Node.js APIs.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const cue = new CueNode({ apiKey: '...', appId: '...', measurementId: '...' });
|
|
11
|
+
* await cue.auth.signInWithApiKey(key);
|
|
12
|
+
* await cue.api.sync.sync(localFiles, { spaceId, providerId, userId });
|
|
13
|
+
*/
|
|
14
|
+
export declare class CueNode extends Cue {
|
|
15
|
+
readonly api: CueApi & {
|
|
16
|
+
sync: CueSyncApi;
|
|
17
|
+
};
|
|
18
|
+
constructor(config: CueSdkConfig);
|
|
19
|
+
}
|
package/lib/cue.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { FirebaseApp } from 'firebase/app';
|
|
2
|
+
import { FirebaseStorage } from 'firebase/storage';
|
|
3
|
+
import { CueBlobStorage } from 'js-databases';
|
|
4
|
+
import { CueAuth } from './auth';
|
|
5
|
+
import { CueSignUp } from './signup';
|
|
6
|
+
import { CueStorage } from './storage';
|
|
7
|
+
import { CueApi } from './api';
|
|
8
|
+
import { CueGis } from './gis';
|
|
9
|
+
import { CueProjects } from './project';
|
|
10
|
+
import { CueProfile } from './profile';
|
|
11
|
+
import { CuePrivileges } from './privileges';
|
|
12
|
+
import { CueCache } from './cache';
|
|
13
|
+
import { CueCurrency } from './currency';
|
|
14
|
+
import { CueProjectView, CueProjectViewOptions } from './project-view';
|
|
15
|
+
import { CueProjectEntities } from './entities';
|
|
16
|
+
import { CueProjectDocuments } from './documents';
|
|
17
|
+
import { CueEndpoints, CueSdkConfig } from './models';
|
|
18
|
+
/**
|
|
19
|
+
* Main entry point for the QAECY SDK (browser-safe).
|
|
20
|
+
* For Node.js use with file-sync capabilities, use `CueNode` from `js-cue-sdk/node`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const cue = new Cue({ apiKey: '...', appId: '...', measurementId: '...' });
|
|
24
|
+
* await cue.auth.signIn('google');
|
|
25
|
+
* const results = await cue.api.search({ term: 'my query', projectId: 'project-id' });
|
|
26
|
+
*/
|
|
27
|
+
export declare class Cue {
|
|
28
|
+
readonly auth: CueAuth;
|
|
29
|
+
readonly signup: CueSignUp;
|
|
30
|
+
readonly api: CueApi;
|
|
31
|
+
readonly projects: CueProjects;
|
|
32
|
+
readonly profile: CueProfile;
|
|
33
|
+
readonly privileges: CuePrivileges;
|
|
34
|
+
readonly cache: CueCache;
|
|
35
|
+
readonly storage: CueStorage;
|
|
36
|
+
readonly currency: CueCurrency;
|
|
37
|
+
protected readonly _app: FirebaseApp;
|
|
38
|
+
protected readonly _endpoints: CueEndpoints;
|
|
39
|
+
protected readonly _isEmulator: boolean;
|
|
40
|
+
protected _storageRaw: FirebaseStorage;
|
|
41
|
+
protected _storageProcessed: FirebaseStorage;
|
|
42
|
+
private _gis;
|
|
43
|
+
private readonly _projectDocuments;
|
|
44
|
+
private readonly _verbose;
|
|
45
|
+
/**
|
|
46
|
+
* Reactive GIS service. Lazily constructed on first access.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* cue.gis.setProjectId('my-project');
|
|
51
|
+
* cue.gis.onAvailableCategories(cats => ...);
|
|
52
|
+
* cue.gis.setBbox([west, south, east, north]);
|
|
53
|
+
* cue.gis.setSelectedCategories(new Set(['cadastre', 'building']));
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
get gis(): CueGis;
|
|
57
|
+
constructor(config?: CueSdkConfig);
|
|
58
|
+
/**
|
|
59
|
+
* Create a `Cue` instance from an already-initialized Firebase app.
|
|
60
|
+
*
|
|
61
|
+
* Use this when the host application (e.g. cue-portal via `CueFirebase`) has
|
|
62
|
+
* already called `initializeApp()`. Reusing the same `FirebaseApp` means the
|
|
63
|
+
* SDK shares the same auth state and Firestore instance — no second login is
|
|
64
|
+
* needed and `getToken()` returns the portal user's token directly.
|
|
65
|
+
*
|
|
66
|
+
* Emulator connections are skipped because the host app already set them up.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // In an Angular service after CueFirebase is ready:
|
|
70
|
+
* const cue = Cue.fromApp(CueFirebase.getInstance().app!, {
|
|
71
|
+
* environment: 'emulator',
|
|
72
|
+
* });
|
|
73
|
+
*/
|
|
74
|
+
static fromApp(app: FirebaseApp, config?: Omit<CueSdkConfig, 'apiKey' | 'appId' | 'measurementId'>): Cue;
|
|
75
|
+
protected _buildApi(projects: CueProjects, blob: CueBlobStorage): CueApi;
|
|
76
|
+
/** Convenience: get the current user's Firebase ID token */
|
|
77
|
+
getToken(forceRefresh?: boolean): Promise<string | null>;
|
|
78
|
+
/**
|
|
79
|
+
* Create a `CueProjectView` for the given project, wiring the SDK's query
|
|
80
|
+
* cache automatically.
|
|
81
|
+
*
|
|
82
|
+
* The view auto-fetches the document overview and entity graph on construction
|
|
83
|
+
* and exposes reactive signals for all project knowledge-graph state.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const view = cue.createProjectView('my-project', { language: 'en' });
|
|
88
|
+
* view.requestEntityData(['uuid1']);
|
|
89
|
+
* const info = view.entityInfoMap.get()['uuid1'];
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
createProjectView(projectId: string, opts: CueProjectViewOptions): CueProjectView;
|
|
93
|
+
/**
|
|
94
|
+
* Creates a `CueProjectEntities` instance for the given project, bound to the
|
|
95
|
+
* correct API.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const entities = cue.createProjectEntities('my-project');
|
|
100
|
+
* entities.requestEntityData(['uuid1']);
|
|
101
|
+
* const info = entities.entityInfoMap.get()['uuid1'];
|
|
102
|
+
*
|
|
103
|
+
* // Promise-based (no signal polling needed):
|
|
104
|
+
* const graph = await entities.buildSummaryGraph('graph');
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
createProjectEntities(projectId: string, opts?: {
|
|
108
|
+
rdfBase?: string;
|
|
109
|
+
graphType?: string;
|
|
110
|
+
verbose?: boolean;
|
|
111
|
+
}): CueProjectEntities;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a `CueProjectDocuments` instance for the given project, bound to the
|
|
114
|
+
* correct API.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const docs = cue.createProjectDocuments('my-project');
|
|
119
|
+
* await docs.fetchOverview();
|
|
120
|
+
* const data = await docs.fetchDocumentData(['uuid1', 'uuid2']);
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
createProjectDocuments(projectId: string, opts?: {
|
|
124
|
+
language?: string;
|
|
125
|
+
rdfBase?: string;
|
|
126
|
+
graphType?: string;
|
|
127
|
+
verbose?: boolean;
|
|
128
|
+
}): CueProjectDocuments;
|
|
129
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type SupportedCurrency = 'CHF' | 'DKK' | 'EUR';
|
|
2
|
+
export declare const SUPPORTED_CURRENCIES: SupportedCurrency[];
|
|
3
|
+
export declare const BASE_CURRENCY: SupportedCurrency;
|
|
4
|
+
/**
|
|
5
|
+
* CHF-based exchange rates. `rates[currency]` is "how many units of
|
|
6
|
+
* `currency` equal 1 CHF" — so `rates.CHF` is always `1`.
|
|
7
|
+
*/
|
|
8
|
+
export interface CurrencyRates {
|
|
9
|
+
base: 'CHF';
|
|
10
|
+
rates: Record<SupportedCurrency, number>;
|
|
11
|
+
fetchedAt: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Live CHF-based exchange rates for DKK/EUR, sourced from the Frankfurter API
|
|
15
|
+
* (ECB reference rates — the same market rates Google Finance quotes). Used
|
|
16
|
+
* to convert the CHF-denominated pricing model into a user's preferred
|
|
17
|
+
* display currency; billing itself always stays in CHF.
|
|
18
|
+
*/
|
|
19
|
+
export declare class CueCurrency {
|
|
20
|
+
private _cached;
|
|
21
|
+
private _pending;
|
|
22
|
+
/**
|
|
23
|
+
* Fetches the current rates, cached in-memory for one hour. Concurrent
|
|
24
|
+
* calls share a single in-flight request. If a refetch fails and a
|
|
25
|
+
* previous rate set is cached, the stale rates are served instead of
|
|
26
|
+
* throwing — a transient network blip shouldn't break the pricing UI.
|
|
27
|
+
*/
|
|
28
|
+
getRates(forceRefresh?: boolean): Promise<CurrencyRates>;
|
|
29
|
+
private _fetchRates;
|
|
30
|
+
/** Converts an amount in CHF into `currency` using `rates`. */
|
|
31
|
+
fromBase(amountChf: number, currency: SupportedCurrency, rates: CurrencyRates): number;
|
|
32
|
+
/** Converts an amount in `currency` back into CHF using `rates`. */
|
|
33
|
+
toBase(amount: number, currency: SupportedCurrency, rates: CurrencyRates): number;
|
|
34
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { CueApi } from './api';
|
|
2
|
+
import { AvailableDocumentFilters, DocumentFilterOption, SearchFilter } from './models';
|
|
3
|
+
/**
|
|
4
|
+
* Provides document-filter queries for a single project.
|
|
5
|
+
*
|
|
6
|
+
* - **{@link availableFilters}** — discovers which mime / content / entity-category
|
|
7
|
+
* options exist within the document set that satisfies the currently applied
|
|
8
|
+
* filters. Uses a 2-tier strategy to avoid cross-product result blowup:
|
|
9
|
+
* 1. QLever: 3 parallel single-dimension queries via `document-categories` view
|
|
10
|
+
* 2. Fallback: 3 parallel live triple-pattern queries
|
|
11
|
+
* - **{@link doLookup}** — returns UUIDs of documents that satisfy a
|
|
12
|
+
* `SearchFilter[]` expression.
|
|
13
|
+
*
|
|
14
|
+
* ### Usage
|
|
15
|
+
* ```ts
|
|
16
|
+
* const filter = new CueDocumentFilter(cue.api, projectId);
|
|
17
|
+
* const opts = await filter.availableFilters(); // full option set
|
|
18
|
+
* const narrowed = await filter.availableFilters({ // adaptive narrowing
|
|
19
|
+
* entityCategories: ['https://…/Person'],
|
|
20
|
+
* });
|
|
21
|
+
* const ids = await filter.doLookup([
|
|
22
|
+
* { type: 'entity', included: ['https://…/Person'], excluded: [] },
|
|
23
|
+
* ]);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class CueDocumentFilter {
|
|
27
|
+
private readonly _api;
|
|
28
|
+
private readonly _projectId;
|
|
29
|
+
private readonly _graphType?;
|
|
30
|
+
constructor(_api: CueApi, _projectId: string, _graphType?: string | undefined);
|
|
31
|
+
/**
|
|
32
|
+
* Returns which mime, content and entity-category options are available among
|
|
33
|
+
* documents that satisfy `applied`. Pass an empty object (or omit) to get
|
|
34
|
+
* options across the full project.
|
|
35
|
+
*
|
|
36
|
+
* Uses a 2-tier strategy — each tier falls through on error or empty result:
|
|
37
|
+
* 1. QLever: 3 parallel single-dimension queries via `document-categories` view
|
|
38
|
+
* 2. Fallback: 3 parallel live triple-pattern queries
|
|
39
|
+
*/
|
|
40
|
+
availableFilters(applied?: {
|
|
41
|
+
mimes?: string[];
|
|
42
|
+
contents?: string[];
|
|
43
|
+
entityCategories?: string[];
|
|
44
|
+
entities?: string[];
|
|
45
|
+
}): Promise<AvailableDocumentFilters>;
|
|
46
|
+
/**
|
|
47
|
+
* Lists the *specific* entities (e.g. "John Doe") of a given entity category
|
|
48
|
+
* (e.g. "Person") that are mentioned by documents satisfying `applied`.
|
|
49
|
+
*
|
|
50
|
+
* Each returned option's `iri` is the canonical-entity IRI (suitable for an
|
|
51
|
+
* `entityInstance` {@link SearchFilter}), and `label` is the entity's
|
|
52
|
+
* `qcy:value`. Results are narrowed by the currently applied filters so the
|
|
53
|
+
* list shrinks as other filters are added.
|
|
54
|
+
*/
|
|
55
|
+
availableEntities(categoryIri: string, applied?: {
|
|
56
|
+
mimes?: string[];
|
|
57
|
+
contents?: string[];
|
|
58
|
+
entityCategories?: string[];
|
|
59
|
+
entities?: string[];
|
|
60
|
+
}): Promise<DocumentFilterOption[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Returns UUIDs of documents that satisfy all provided filters.
|
|
63
|
+
*
|
|
64
|
+
* Filter semantics:
|
|
65
|
+
* - Multiple filter objects (different types) → AND between types
|
|
66
|
+
* - Multiple IRIs in `included` for the same type → OR
|
|
67
|
+
* - `excluded` IRIs → AND NOT
|
|
68
|
+
*/
|
|
69
|
+
doLookup(filters: SearchFilter[]): Promise<string[]>;
|
|
70
|
+
/** Single-dimension available-filters query using the dimension-specific views. */
|
|
71
|
+
private _buildViewDimQuery;
|
|
72
|
+
/** Single-dimension available-filters query using live triple patterns. */
|
|
73
|
+
private _buildLiveDimQuery;
|
|
74
|
+
private _buildViewFilterQuery;
|
|
75
|
+
private _buildFilterQuery;
|
|
76
|
+
}
|