@knora/api
Version:
JavaScript library that handles API requests to Knora
55 lines (54 loc) • 2.13 kB
TypeScript
import { Observable } from "rxjs";
import { V2Endpoint } from "../api/v2/v2-endpoint";
import { KnoraApiConfig } from "../knora-api-config";
import { ClassDefinition } from "../models/v2/ontologies/class-definition";
import { PropertyDefinition } from "../models/v2/ontologies/property-definition";
import { ReadOntology } from "../models/v2/ontologies/read-ontology";
import { GenericCache } from "./GenericCache";
/**
* Represents resource class definitions
* and property definitions the resource classes have cardinalities for.
*/
export interface IResourceClassAndPropertyDefinitions {
/**
* Resource class definitions and their cardinalities.
*/
classes: {
[index: string]: ClassDefinition;
};
/**
* Property definitions referred to in cardinalities.
*/
properties: {
[index: string]: PropertyDefinition;
};
}
/**
* Caches ontologies obtained from Knora and handles direct dependencies between ontologies.
*/
export declare class OntologyCache extends GenericCache<ReadOntology> {
private knoraApiConfig;
private v2Endpoint;
constructor(knoraApiConfig: KnoraApiConfig, v2Endpoint: V2Endpoint);
/**
* Gets an ontology from the cache including its direct dependencies.
*
* The ontology Iris are the keys of the resulting Map.
*
* @param ontologyIri the Iri of the ontology.
* @returns the requested ontology and its direct dependencies.
*/
getOntology(ontologyIri: string): Observable<Map<string, ReadOntology>>;
/**
* Gets a resource class definition including the property definitions
* the resource class has cardinalities for.
*
* This method does not return third party ontology entities, e.g., rdfs.
*
* @param resourceClassIri
*/
getResourceClassDefinition(resourceClassIri: string): Observable<IResourceClassAndPropertyDefinitions>;
protected requestItemFromKnora(key: string, isDependency: boolean): Observable<ReadOntology[]>;
protected getKeyOfItem(item: ReadOntology): string;
protected getDependenciesOfItem(item: ReadOntology): string[];
}