import { BlankNode, Dataset, Literal, NamedNode, Quad, Variable } from "@rdfjs/types"; import { PropertyChange } from "./changemgmt.js"; import { LiteralValue } from "./fdr.js"; import { Graph, LocalGraph } from "./graph.js"; import { DatasetIngester } from "./triplestore-client.js"; import { Subject, RemoteDataSpec, DataSpec, SubjectChangeSynchronization, SubjectId } from "./dataspecAPI.js"; import { Subscription } from "subscription"; declare type _InternalPropertyValue = Literal | Subject; /** * Base class for the concrete Subject implementation. * Encalpusaltes the basic logic for * 1. read, edit, delete operations, * 2. change tracking * 3. working copy creation and management */ declare abstract class SubjectBase implements Subject, SubjectChangeSynchronization { readonly id: SubjectId; protected properties: object | null; readonly changes: Array; protected workingCopies: SubjectLightCopy[]; constructor(id: SubjectId); abstract getGraph(): Graph; protected abstract notifyGraphAboutPropertyChange(prop: string[]): void; protected abstract resolveName(name: string): string; abstract commit(): Promise; abstract syncFromUpstream(changes: PropertyChange[]): any; abstract syncFromDownstream(changes: PropertyChange[]): any; abstract workingCopy(reactivityDecorator?: (original: Subject) => Subject): Subject; abstract get ready(): boolean; onReferentsChanged: Subscription; protected onPropertyChanged: Subscription; propertyAsSubject(propertyName: string, value: LiteralValue | Subject, lang?: string): Subject; /** * Enqueue a change to the buffer which will be sent to upstream sources * of truth for synchronization * @param change the change to enqueue */ protected enqueueToChangeBuffer(...change: PropertyChange[]): void; protected onlyWithLanguage(values: Array, lang: string): Literal[]; /** * Parse the language string or if not set, parse the environment's default language setting * @param lang * @returns */ protected parseLangString(lang?: string): { language?: string; languageIsOptional: boolean; }; /** * parse a literal into a js value accordig to the datatype property * @param literal * @returns */ private makeValueFromLiteral; /** * * @param prop * @param lang the language of the requested values. If set, only values with the given * language will be returned. If no values of the given language are present and the * language is optional (lang ends with '?'), all the values will be returned. If not set, * all the values will be returned * @returns an array consisting of all the values of the given property. If the values * are string literals only values with the specified language are returned. Non * string literals are transformed into js objects according to their set datatype. * If threre are no values with the given language and teh */ getAll(prop: string, lang?: string): Subject[] | LiteralValue[]; /** * * @param prop * @param lang the language of the requested values. If set, only values with the given * language will be returned. If no values of the given language are present and the * language is optional (lang ends with '?'), all the values will be returned. If not set, * all the values will be returned * @returns the (first) value of the given property with the given language (if set) or if * no language is set or the language is optional and no values with the given language are present, * the first value present */ get(prop: string, lang?: string): Subject | LiteralValue | null; set(prop: string, lang?: string, ...object: Subject[] | LiteralValue[]): Subject; setMore(prop: string, lang?: any, ...object: Subject[] | LiteralValue[]): Subject; delete(prop: string, lang?: any, ...val: Subject[] | LiteralValue[]): Subject; propertyNames(): string[]; private obj; private setObj; private setMoreObjects; private deleteObject; /** * Return the set of values of a data property. Throw an exception if * the values are not RDF literals. * @param prop The name of the property. */ private val; /** * Set some specific literal values for a key on the object. * If there are already some values, replace them * * @param prop * @param val * @returns */ private setVal; /** * Add some literal values for a key on the object. * * @param prop * @param lang * @param val * @returns */ private setMoreValues; private deleteValue; /** * Apply a change to the subject * * @param changes */ apply(changes: PropertyChange[]): void; notifyReferentsChanged(referent: any, key: any): void; addReferentsChangedCallback(callback: (referent: Subject, key: string) => void): void; removeReferentsChangedCallback(callback: (referent: Subject, key: string) => void): void; addPropertyChangedCallback(callback: (key: string) => void): void; removePropertyChangedCallback(callback: (key: string) => void): void; } /** * The main subject implementation of the Subject interface which works with the LocalGraph * * This class is only exported so that it's accessible to the `graph.ts` module. */ export declare class SubjectImpl extends SubjectBase implements RemoteDataSpec { readonly id: SubjectId; getGraph(): Graph; protected resolveName(name: string): string; /** * Notify the graph that some properties have changed * @param changedProperties the changed properties */ protected notifyGraphAboutPropertyChange(changedProperties: string[]): void; graph: LocalGraph; constructor(id: SubjectId, graph: LocalGraph); get query(): { type: string; propertyValueIdentifier: { ontologyId: string; subject: { id: SubjectId; }; predicate: string; object: Literal | Subject | { id: SubjectId; }; }; id?: undefined; } | { type: string; id: string; propertyValueIdentifier?: undefined; }; get ready(): boolean; use(): Promise; apply(changes: PropertyChange[]): void; /** * Ingest the quads from a dataset which are relevant to this Subject into * this Subject's properties * * @param dataset */ ingest(dataset: Dataset): void; workingCopy(reactivityDecorator?: (original: T) => T): Subject; commit(): Promise; syncFromUpstream(changes: PropertyChange[]): Promise; syncFromDownstream(changes: PropertyChange[]): void; } /** * A buffer for changes to another subject */ declare class SubjectLightCopy extends SubjectBase { getGraph: () => Graph; private resolver; get ready(): boolean; /** * * @param original * @param getGraph * @param resolver */ constructor(original: Subject, getGraph: () => Graph, resolver: (string: any) => string); hydrate(properties: object): void; protected notifyGraphAboutPropertyChange(prop: string[]): void; protected resolveName(name: string): string; workingCopy(reactivityDecorator?: ((original: Subject) => Subject)): Subject; private originial; commit(): Promise; syncFromDownstream(changes: PropertyChange[]): void; syncFromUpstream(changes: PropertyChange[]): void; apply(changes: PropertyChange[]): void; } export declare const type_guards: { /** * Type quard for the DatasetIngeste type * @param dataSpec * @returns */ isIngester(dataSpec: any): dataSpec is DatasetIngester; /** * * @param subject * @returns */ isSubjectValue(subject: any): subject is Subject | Subject[]; isLiteralValue(literal: any): literal is LiteralValue | LiteralValue[]; isRemoteDataSpec(dataSpec: DataSpec): dataSpec is RemoteDataSpec; isSubjectChangeSynchronization(subject: any): subject is SubjectChangeSynchronization; isNamedNode(entity: NamedNode | BlankNode | Quad | Variable | Literal): entity is NamedNode; isQuad(entity: NamedNode | BlankNode | Quad | Variable | Literal): entity is Quad; isLiteral(entity: any): entity is Literal; }; /** * A Property value identifier is an identifier of a specific value of a * specific property on a subject. * This is the Object based equivalent of an RDF triple */ export declare class PropertyValueIdentifier implements SubjectId { readonly subject: SubjectId; readonly property: string; readonly value: _InternalPropertyValue; constructor(subject: SubjectId, property: string, value: _InternalPropertyValue); equals(other: SubjectId): boolean; /** * Transform the property * @returns */ toQuad(): Quad; toString(): string; } export {};