graphdb
Version:
Javascript client library supporting GraphDB and RDF4J REST API.
139 lines (138 loc) • 6.13 kB
TypeScript
export = StatementsService;
/**
* Service for reading, inserting or deleting repository statements.
*
* @author Mihail Radkov
* @author Svilen Velikov
*/
declare class StatementsService extends Service {
/**
* Instantiates the service with the supplied executor and parser utils.
*
* @param {Function} httpRequestExecutor executor for HTTP requests
* @param {ParserRegistry} parserRegistry registry of available parsers
* @param {Function} parseExecutor function that will parse provided data
*/
constructor(httpRequestExecutor: Function, parserRegistry: ParserRegistry, parseExecutor: Function);
parserRegistry: ParserRegistry;
parseExecutor: Function;
/**
* Fetch rdf data from statements endpoint using provided parameters.
*
* Provided values will be automatically converted to N-Triples if they are
* not already encoded as such.
*
* @param {GetStatementsPayload} payload is an object holding the request
* parameters.
*
* @return {ServiceRequest} service request that resolves to plain string or
* Quad according to provided response type.
*/
get(payload: GetStatementsPayload): ServiceRequest;
/**
* Saves the provided statement payload in the repository.
*
* The payload will be converted to a quad or a collection of quads in case
* there are multiple contexts.
*
* After the conversion, the produced quad(s) will be serialized to Turtle or
* Trig format and send to the repository as payload.
*
* See {@link #addQuads()}.
*
* @param {AddStatementPayload} payload holding request parameters
*
* @return {ServiceRequest} service request that will resolve if the addition
* is successful or reject in case of failure
*
* @throws {Error} if the payload is not provided or the payload has null
* subject, predicate and/or object
*/
add(payload: AddStatementPayload): ServiceRequest;
/**
* Serializes the provided quads to Turtle format and sends them to the
* repository as payload.
*
* If any of the quads have a graph, then the text will be serialized to the
* Trig format which is an extended version of Turtle supporting contexts.
*
* @param {Quad[]} quads collection of quads to be sent as Turtle/Trig text
* @param {string|string[]} [context] restricts the insertion to the given
* context. Will be encoded as N-Triple if it is not already one
* @param {string} [baseURI] used to resolve relative URIs in the data
*
* @return {ServiceRequest} service request that will be resolved if the
* addition is successful or rejected in case of failure
*
* @throws {Error} if no quads are provided or if they cannot be converted
*/
addQuads(quads: Quad[], context?: string | string[], baseURI?: string): ServiceRequest;
/**
* Overwrites the repository's data by serializing the provided quads to
* Turtle format and sending them to the repository as payload.
*
* If any of the quads have a graph, then the text will be serialized to the
* Trig format which is an extended version of Turtle supporting contexts.
*
* The overwrite will be restricted if the context parameter is specified.
*
* @param {Quad[]} quads collection of quads to be sent as Turtle/Trig text
* @param {string|string[]} [context] restricts the insertion to the given
* context. Will be encoded as N-Triple if it is not already one
* @param {string} [baseURI] used to resolve relative URIs in the data
*
* @return {ServiceRequest} service request that will be resolved if the
* overwrite is successful or rejected in case of failure
*
* @throws {Error} if no quads are provided or if they cannot be converted
*/
putQuads(quads: Quad[], context?: string | string[], baseURI?: string): ServiceRequest;
/**
* Constructs HttpRequestBuilder from the provided parameters for saving or
* overwriting statements.
*
* @private
*
* @param {Quad[]} quads collection of quads to be sent as Turtle/Trig text
* @param {string|string[]} [context] restricts the insertion to the given
* context. Will be encoded as N-Triple if it is not already one
* @param {string} [baseURI] used to resolve relative URIs in the data
* @param {boolean} overwrite defines if the data should overwrite the repo
* data or not
*
* @return {HttpRequestBuilder} promise resolving after the data has
* been inserted successfully or an error if not
*
* @throws {Error} if no quads are provided or if they cannot be converted
*/
private getInsertRequest;
/**
* Deletes statements in the repository based on the provided subject,
* predicate, object and or contexts. Each of them is optional and acts as
* statements filter which effectively narrows the scope of the deletion.
*
* Providing context or contexts will restricts the operation to one or more
* specific contexts in the repository.
*
* Provided values will be automatically converted to N-Triples if they are
* not already encoded as such.
*
* @param {String} [subject] resource subject
* @param {String} [predicate] resource predicate
* @param {String} [object] resource object
* @param {String[]|String} [contexts] resource or resources context
*
* @return {ServiceRequest} service request that will be resolved if the
* deletion is successful or rejected in case of failure
*/
deleteStatements(subject?: string, predicate?: string, object?: string, contexts?: string[] | string): ServiceRequest;
/**
* Deletes all statements in the repository.
*
* @return {ServiceRequest} service request that will be resolved if the
* deletion is successful or rejected in case of failure
*/
deleteAllStatements(): ServiceRequest;
}
import Service = require("./service");
import ServiceRequest = require("./service-request");