UNPKG

@faubulous/mentor-rdf

Version:

A library for working with RDF vocabularies with support for basic RDFS and OWL inference.

150 lines (149 loc) 8.32 kB
import { Store } from "./store"; import { QueryOptions, DefinitionQueryOptions, TypedInstanceQueryOptions } from "./resource-repository"; import { ConceptRepository } from "./concept-repository"; /** * A repository for retrieving classes from graphs. */ export declare class ClassRepository extends ConceptRepository { constructor(store: Store); /** * Get all classes in the repository. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param options Optional query parameters. * @returns An iterator of all classes in the repository. */ getClasses(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>; /** * Get the super classes of a given class. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param subjectUri URI of a class. * @param options Optional query parameters. * @returns An iterator of super classes of the given class. */ getSuperClasses(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): IterableIterator<string>; /** * Get the first discovered path from a given class to a root class. * @param subjectUri URI of a class. * @returns An iterator containing the first path that is found from the given class to a root class. */ getRootClassPath(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): IterableIterator<string>; /** * Recursively find the first path from a given class to a root class. * @param subjectUri URI of a class. * @param path The current class path. * @param backtrack Set of URIs that have already been visited. * @returns The first path that is found from the given class to a root class. */ private _getRootClassPath; /** * Indicate if there are sub classes of a given class. * @param subjectUri URI of a class. * @returns true if the class has sub classes, false otherwise. */ hasSubClasses(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): boolean; /** * Get the sub classes of a given class or all root classes. * @param subjectUri URI of a class or undefined to get all root classes. * @returns An iterator of sub classes of the given class, or root classes if no subject is provided. */ getSubClasses(graphUris: string | string[] | undefined, subjectUri?: string, options?: DefinitionQueryOptions): IterableIterator<string>; /** * Recursively traverse all sub classes of a given class and invoke a callback. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param superClass The super class to start the traversal from. * @param callback A function to call for each sub class. If the function returns `false`, the traversal stops. * @param options Optional query parameters. * @param visited A set of visited URIs. * @returns `true` if the traversal was completed, `false` if it was stopped by the callback. */ private _traverseSubClasses; /** * Get all sub classes of a given class, including indirect sub classes. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param subjectUri URI of a class. * @param options Optional query parameters. * @returns An iterator of all sub classes of the given class. */ getAllSubClasses(graphUris: string | string[] | undefined, subjectUri: string, options?: DefinitionQueryOptions): IterableIterator<string>; /** * Recursively traverse all sub classes of a given class and yield them. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param superClass The super class to start the traversal from. * @param options Optional query parameters. * @param visited A set of visited URIs. */ private _traverseSubClassesGenerator; /** * Indicate if there are instances of a given class or any of its sub classes. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param typeUri URI of the class. * @param options Optional query parameters. * @returns `true` if the class has instances, `false` otherwise. */ hasSubjectsOfType(graphUris: string | string[] | undefined, typeUri: string, options?: DefinitionQueryOptions & TypedInstanceQueryOptions): boolean; /** * Get all subjects of a given class in the repository. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param typeUri URI of the class. * @param options Optional query parameters. * @returns An iterator of all subjects of the given class. */ getSubjectsOfType(graphUris: string | string[] | undefined, typeUri: string, options?: DefinitionQueryOptions & TypedInstanceQueryOptions): IterableIterator<string>; /** * Indicate if a given class is direct or indirect (inferred) sub class of another class. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param subjectUri URI of the sub class. * @param classUri URI of the super class. * @param options Optional query parameters. * @returns `true` if the class is a sub class of the other class, false otherwise. */ isSubClassOf(graphUris: string | string[] | undefined, subjectUri: string, classUri: string, options?: DefinitionQueryOptions): boolean; /** * Indicate if a given class is the intersection of classes. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param subjectUri URI of a class. * @returns `true` if the class is the intersection of classes, `false` otherwise. */ isIntersectionOfClasses(graphUris: string | string[] | undefined, subjectUri: string): boolean; private _isIntersectionOfClasses; /** * Indicate if a given class is a (disjoint) union of classes. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param subjectUri URI of a class. * @returns `true` if the class is a (disjoint) union of classes, `false` otherwise. */ isUnionOfClasses(graphUris: string | string[] | undefined, subjectUri: string): boolean; private _isUnionOfClasses; /** * Get all classes from the repository that have no super classes. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param options Optional query parameters. * @returns An iterator of root classes in the repository. */ getRootClasses(graphUris: string | string[] | undefined, options?: DefinitionQueryOptions): IterableIterator<string>; /** * Indicate if there is an equivalent class of a given class. * @param graphUris URIs of the graphs to search, `undefined` for the default graph. * @param subjectUri URI of a class. * @param options Optional query parameters. * @returns `true` if the class has an equivalent class, `false` otherwise. */ hasEquivalentClass(graphUris: string | string[] | undefined, subjectUri: string, options?: QueryOptions): boolean; /** * Indicate if a given class has at least one individual defined for it or for one of its sub classes. * @param graphUris Graph URIs to search in, undefined for the default graph. * @param classUri URI of a class. * @param options Optional query parameters. * @returns `true` if the class has individuals, `false` otherwise. */ hasIndividuals(graphUris: string | string[] | undefined, classUri: string, options?: DefinitionQueryOptions): boolean; /** * Internal method to check for individuals with cycle detection. * @param graphUris Graph URIs to search in, undefined for the default graph. * @param classUri URI of a class. * @param options Optional query parameters. * @param backtrack Set of already visited class URIs to prevent cycles. * @returns `true` if the class has individuals, `false` otherwise. */ private _hasIndividuals; }