import { CueApi } from './api'; import { ReadonlySignal } from './signal'; import { CategoryDef, RelationshipDef } from './models'; /** * Holds the schema for a single project: available content categories, * entity categories, and entity relationship types. * * The full schema is fetched **once** (a single SPARQL query covering all three * collections) and cached. Labels and definitions are retained for every * available language as {@link LangMap}s; switching language is therefore a * cheap, client-side re-projection with no extra network round-trip. * * ### Reactive paradigm * All three collections are exposed as `ReadonlySignal`. Framework adapters * (e.g. Angular) should bridge these to their own reactive primitives using * `subscribe()`. * * ### Lifecycle * One `CueProjectSchema` instance should be created per project. It is owned * by the higher-level `CueProjectView` and shares the same `CueApi` instance. * * @example * ```ts * const schema = new CueProjectSchema(cue.api, projectId, 'en'); * schema.availableContentCategories.get(); // CategoryDef[] * schema.setLanguage('da'); // re-projects cached data instantly * await schema.refresh(); // force re-fetch * ``` */ export declare class CueProjectSchema { private readonly _api; private readonly _projectId; private readonly _graphType?; private _snapshot?; private _inflight?; private _currentLang; private readonly _verbose; private readonly _contentCategories; private readonly _entityCategories; private readonly _relationships; /** Currently active content categories for the selected language. */ readonly availableContentCategories: ReadonlySignal; /** Currently active entity categories for the selected language. */ readonly availableEntityCategories: ReadonlySignal; /** Currently active entity relationship types for the selected language. */ readonly availableEntityRelationships: ReadonlySignal; /** * Resolves when the initial schema load for the constructor language has * completed (or failed). Await this before reading signal values imperatively. */ readonly ready: Promise; constructor(_api: CueApi, _projectId: string, language: string, _graphType?: string | undefined, verbose?: boolean); /** Returns the currently active language. */ get language(): string; /** * Switch the active language. Re-projects the already-fetched schema for the * new language without re-querying; only triggers a fetch if nothing has been * loaded yet. */ setLanguage(lang: string): void; /** * Force a re-fetch of the schema, bypassing the cache. * Useful when the triplestore data has changed. */ refresh(): Promise; private _load; /** * Fetches the schema once. On QLever the pre-computed `schemas` materialized * view is tried first; if it yields no rows we warn and fall back to the live * schema query. */ private _fetchSnapshot; private _apply; /** Projects a language-independent {@link SchemaNode} into a {@link CategoryDef}. */ private _toDef; /** * Single query covering content categories, entity categories and entity * relationship types. Labels/definitions are returned untouched (with their * language tags) so they can be grouped into {@link LangMap}s client-side. */ private _buildSchemaQuery; /** Runs a schema query and groups the flat rows into a {@link SchemaSnapshot}. */ private _runSchemaQuery; }