UNPKG

graphdb

Version:

Javascript client library supporting GraphDB and RDF4J REST API.

85 lines (84 loc) 3.08 kB
export = NamespaceService; /** * Service for namespace management. * * @author Mihail Radkov * @author Svilen Velikov */ declare class NamespaceService extends Service { /** * Retrieves all present namespaces as a collection of {@link Namespace}. * * @return {ServiceRequest} a service request resolving to a collection of * {@link Namespace} */ getNamespaces(): ServiceRequest; /** * Maps the response data from the namespaces request into {@link Namespace}. * * @private * * @param {object} responseData the data to map * * @return {Namespace[]} the mapped namespaces */ private mapNamespaceResponse; /** * Retrieves the namespace for the given prefix as {@link NamedNode}. * * For example if <code>rdfs</code> is provided as prefix that would result in * a {@link NamedNode} corresponding to following namespace: * <code>http://www.w3.org/2000/01/rdf-schema#</code> * * Note: This method should be invoked only with prefixes. Anything else would * result in an error from the server. * * @param {string} prefix prefix of the namespace to be retrieved * * @return {ServiceRequest} service request resolving to {@link NamedNode} * * @throws {Error} if the prefix parameter is not supplied */ getNamespace(prefix: string): ServiceRequest; /** * Creates or updates the namespace for the given prefix. * * If the provided prefix or namespace parameter is not a string or * {@link NamedNode} then the method will throw an error. * * @param {string} prefix prefix of the namespace to be created/updated * @param {string|NamedNode} namespace the namespace to be created/updated * * @return {ServiceRequest} service request that will be resolved if the * create/update request is successful * * @throws {Error} if the prefix or namespace parameter are not provided */ saveNamespace(prefix: string, namespace: string | NamedNode): ServiceRequest; /** * Deletes a namespace that corresponds to the given prefix. * * For example if <code>rdfs</code> is provided as prefix that would delete * the following namespace: <code>http://www.w3.org/2000/01/rdf-schema#</code> * * Note: This method should be invoked only with prefixes. Anything else would * result in an error from the server. * * @param {string} prefix prefix of the namespace to be deleted * * @return {Promise<void>} promise that will be resolved if the deletion is * successful * * @throws {Error} if the prefix parameter is not provided */ deleteNamespace(prefix: string): Promise<void>; /** * Deletes all namespace declarations in the repository. * * @return {Promise<void>} promise that will be resolved after * successful deletion */ deleteNamespaces(): Promise<void>; } import Service = require("./service"); import ServiceRequest = require("./service-request");