import { CueApi } from './api'; import { ReadonlySignal } from './signal'; import { FileType } from 'js/models'; import { DocumentInfo, ProjectDocumentsData } from './models'; /** * Manages document data for a single project. * * ### Data model * - **`documentInfoMap`** — lazily populated per-document detail signal. * Call `requestDocumentData(uuids)` to load entries; already-cached UUIDs * are skipped. Data is merged incrementally. * - **`projectDocumentsData`** — project-level overview (documents grouped by * suffix and content category, plus duplicate count). Auto-fetched on * construction via three parallel SPARQL queries that resolve as a single * atomic update. * * ### Language * `subject` and `summary` fields on documents are language-tagged in the * triplestore. Pass the active language to `requestDocumentData()` and call * `setLanguage()` when it changes (which clears and re-fetches the info map * so labels re-resolve in the new language). * * ### Lifecycle * Call `reset()` when the project changes. The Angular adapter's project-change * effect should call this, followed by `fetchOverview()` once the triplestore * is ready. * * @example * ```ts * const docs = new CueProjectDocuments(cue.api, projectId, 'en'); * await docs.fetchOverview(); * docs.requestDocumentData(['uuid1', 'uuid2']); * const info = docs.documentInfoMap.get()['uuid1']; * ``` */ export declare class CueProjectDocuments { private readonly _api; private readonly _projectId; private readonly _graphType?; private readonly _verbose; /** Full RDF base URL for this project, e.g. `https://cue.qaecy.com/r/{pid}/` */ readonly baseURL: string; /** Tracks the language for which `_documentInfoMap` is currently populated. */ private _currentLang; private readonly _documentInfoMap; /** Cumulative unique document UUIDs ever passed to request methods (survives cache hits). */ private readonly _seenIds; private readonly _projectDocumentsData; /** Lazily populated per-document detail map. */ readonly documentInfoMap: ReadonlySignal>; /** Project-level document overview (grouped counts + sizes). */ readonly projectDocumentsData: ReadonlySignal; constructor(_api: CueApi, _projectId: string, language?: string, /** Override the RDF resource base URL. Defaults to `https://cue.qaecy.com/r/`. */ rdfBase?: string, _graphType?: string | undefined, _verbose?: boolean); /** * Resets all document state. Call when the active project changes. * Follow with `fetchOverview()` once the triplestore is ready. */ reset(): void; /** * Updates the active language and clears the document info map so that * language-sensitive fields (subject, summary) are re-fetched on the next * `requestDocumentData()` call. */ setLanguage(lang: string): void; /** * Fetches the three-part project overview (by suffix, by content category, * duplicate count) in parallel and writes them as a single atomic update to * `projectDocumentsData`. Safe to call again to refresh. */ fetchOverview(): Promise; /** * Lazily batch-fetches core metadata for the given document UUIDs. * Already-cached UUIDs are skipped. Data is merged into `documentInfoMap` * once the SPARQL response arrives. */ requestDocumentData(uuids: string[]): void; /** * Promise-based alternative to {@link requestDocumentData} for non-reactive contexts. * * Resolves with the `DocumentInfo` entries for every requested UUID once the * SPARQL response arrives. UUIDs already present in the cache are returned * immediately without a network request. The result is also written into * `documentInfoMap` so reactive consumers stay in sync. * * UUIDs not found in the triplestore are omitted from the returned map. * * @example * ```ts * const docs = await cueProjectDocs.fetchDocumentData(['uuid1', 'uuid2']); * console.log(docs['uuid1'].subject); * ``` */ fetchDocumentData(uuids: string[]): Promise>; /** * Fetches a lightweight document metadata shape (id/path/suffix/size) for * the given UUIDs and merges the results into `documentInfoMap`. * * This is useful for list/table contexts that do not need language-tagged * fields (`subject`, `summary`) or category/tag enrichment. * * UUIDs already present in `documentInfoMap` are skipped. */ fetchDocumentDataSimple(uuids: string[]): Promise>; /** * Returns the alternative representations of the given document UUID. * * Alternative representations are derived artefacts stored under * `qcy:alternativeRepresentation` in the triplestore — for example a * `.fragments` BIM tile derived from an `.ifc` source file. * * The returned `DocumentInfo` entries are also merged into * `documentInfoMap` so reactive consumers stay in sync. * * @example * ```ts * const alts = await docs.fetchAlternativeRepresentations('abc-123'); * // alts[0].suffix => '.fragments' * ``` */ fetchAlternativeRepresentations(uuid: string): Promise; /** * Returns a single arbitrary file path from the project's triplestore. * Useful for pre-filling path-based query inputs with a realistic example. */ randomFilePath(): Promise; /** * Fetches all `qcy:FileContent` documents whose file suffix matches one of * the given extensions (e.g. `'.ifc'`, `'.pdf'`). * * By default returns only `{ iri, uuid }` — pass `includeMetadata: true` to * also get `path`, `suffix`, and `size`. Use the default form when you intend * to lazy-load full details via `requestDocumentData`. * * Suffixes are matched case-insensitively and the leading dot is optional * (both `'ifc'` and `'.ifc'` are accepted). */ documentsBySuffix(suffixes: string[], includeMetadata?: false): Promise>; documentsBySuffix(suffixes: string[], includeMetadata: true): Promise>; /** * Fetches documents whose file suffix maps to one of the given `FileType` * values (e.g. `FileType.BIM`, `FileType.CAD`). * * Resolves matching suffixes from `fileExtensionsInfo` and delegates to * `documentsBySuffix`. Accepts the same `includeMetadata` flag. */ documentsByFileType(fileTypes: FileType[], includeMetadata?: false): Promise>; documentsByFileType(fileTypes: FileType[], includeMetadata: true): Promise>; /** * Fetches all `qcy:FileContent` documents that carry one of the given * content-category IRIs (e.g. as returned by `projectDocumentsData.documentsByContentCategory`). * * By default returns only `{ iri, uuid }` — pass `includeMetadata: true` to * also get `path`, `suffix`, and `size`. Use the default form when you intend * to lazy-load full details via `requestDocumentData`. */ documentsByContentCategory(categoryIRIs: string[], includeMetadata?: false): Promise>; documentsByContentCategory(categoryIRIs: string[], includeMetadata: true): Promise>; /** * Fetches documents whose MIME type matches one of the given strings * (e.g. `'application/x-step'`, `'application/pdf'`). * * Resolves matching suffixes from `fileExtensionsInfo` and delegates to * `documentsBySuffix`. Accepts the same `includeMetadata` flag. */ documentsByMime(mimeTypes: string[], includeMetadata?: false): Promise>; documentsByMime(mimeTypes: string[], includeMetadata: true): Promise>; /** Builds a full resource IRI from a UUID without a SPARQL round-trip. */ private _resourceIri; private _log; /** Executes the document-info SPARQL query for the given UUIDs, merges results * into `documentInfoMap`, and returns the newly fetched entries. */ private _fetchDocumentInfoBatch; /** Executes a reduced document-info query (id/path/suffix/size only), merges * into `documentInfoMap`, and returns newly fetched entries. */ private _fetchSimpleDocumentInfoBatch; private _fetchDocumentsBySuffix; private _buildDocumentsBySuffixQuery; private _runDocumentsBySuffixQuery; private _fetchDocumentsByContentCategory; private _buildDocumentsByContentCategoryQuery; private _runDocumentsByContentCategoryQuery; private _fetchDuplicateCount; private _buildDuplicateCountQuery; private _runDuplicateCountQuery; }