@restorecommerce/chassis-srv
Version:
Restore Commerce microservice chassis
198 lines • 9.15 kB
TypeScript
import { Database } from 'arangojs';
import { Arango } from './base.js';
import { GraphDatabaseProvider } from '../../index.js';
import { Graph } from 'arangojs/graph';
import { ArangoCollection } from 'arangojs/collection';
import { Vertices, Collection, Options as TraversalOptions, Filters as GraphFilters, DeepPartial } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/graph.js';
import { TraversalResponse } from './interface.js';
import { type Logger } from '@restorecommerce/logger';
export declare class ArangoGraph extends Arango implements GraphDatabaseProvider {
readonly graph: Graph;
readonly edgeDefConfig: any;
readonly logger?: Logger;
constructor(db: Database, graph: Graph, edgeDefConfig: any, logger?: Logger);
/**
* create a Graph instance.
*
* @param {String} graphName graph name
* @param edgeDefinitions — Definitions for the relations of the graph.
* @param options — Options for creating the graph.
* @return {Object} A Graph instance
*/
createGraphDB(graphName: string, edgeDefinitions: any, options: object): Promise<Graph>;
/**
* create a new Vertex with given data.
*
* @param {string} collectionName vertex collection name
* @param {Object} data data for vertex
* @return {Object} created vertex
*/
createVertex(collectionName: string, data: any): Promise<any>;
/**
* Retreives the vertex with the given documentHandle from the collection.
*
* @param {string} collectionName vertex collection name
* @param {string} documentHandle The handle of the vertex to retrieve.
* This can be either the _id or the _key of a vertex in the collection,
* or a vertex (i.e. an object with an _id or _key property).
* @return {Object} created vertex
*/
getVertex(collectionName: string, documentHandle: string): Promise<object>;
/**
* Deletes the vertex with the given documentHandle from the collection.
*
* @param {string} collectionName vertex collection name
* @param {string[]} documentHandles An array of the documentHandles to be removed.
* This can be either the _id or the _key of a vertex in the collection,
* or a vertex (i.e. an object with an _id or _key property).
* @return {Object} removed vertex
*/
removeVertex(collectionName: string, documentHandles: string | string[]): Promise<any>;
/**
* gets a new GraphVertexCollection instance with the given name for this graph.
*
* @param {string} collectionName The handle of the vertex to retrieve.
* This can be either the _id or the _key of a vertex in the collection,
* or a vertex (i.e. an object with an _id or _key property).
* @return {Object} created vertex
*/
getVertexCollection(collectionName: string): Promise<object>;
/**
* Fetches all vertex collections from the graph and returns
* an array of collection descriptions.
*
* @return {Array<string>} vertex list
*/
listVertexCollections(): Promise<string[]>;
/**
* Fetches all vertex collections from the database and returns an array
* of GraphVertexCollection instances for the collections.
*
* @return {Array<Object>} vertex list
*/
getAllVertexCollections(): Promise<any>;
/**
* Adds the collection with the given collectionName to the graph's
* vertex collections.
*
* @param {string} collectionName Name of the vertex collection to add to the graph.
* @param {boolean} excludeOrphans Whether orphan collections should be excluded.
* @return {Array<Object>} vertex list
*/
addVertexCollection(collectionName: string): Promise<any>;
/**
* Removes the vertex collection with the given collectionName from the graph.
*
* @param {string} collectionName Name of the vertex collection to remove from the graph.
* @param {boolean} dropCollection If set to true, the collection will
* also be deleted from the database.
* @return {Object } removed vertex
*/
removeVertexCollection(collectionName: string, dropCollection?: boolean): Promise<any>;
/**
* @return {Graph} A Graph instance
*/
getGraphDB(): Graph;
/**
* Creates a new edge between the vertices fromId and toId with the given data.
*
* @param {string} collectionName name of the edge collection
* @param {Object} data The data of the new edge. If fromId and toId are not
* specified, the data needs to contain the properties _from and _to.
* @param {string} fromId The handle of the start vertex of this edge.
* This can be either the _id of a document in the database, the _key of an
* edge in the collection, or a document (i.e. an object with an _id or _key property).
* @param {string} toId The handle of the end vertex of this edge.
* This can be either the _id of a document in the database, the _key of an
* edge in the collection, or a document (i.e. an object with an _id or _key property).
* @return {Object} edge object
*/
createEdge(collectionName: string, data: object, fromId?: string, toId?: string): Promise<object>;
/**
* Retrieves the edge with the given documentHandle from the collection.
*
* @param {String} collectionName collection name
* @param {String} documentHandle edge key
* @return {Object} edge object
*/
getEdge(collectionName: string, documentHandle: string): Promise<object>;
/**
* Retrieves a list of all edges of the document with the given documentHandle.
*
* @param {String} collectionName edge collection name
* @param {String} documentHandle The handle of the document to retrieve
* the edges of. This can be either the _id of a document in the database,
* the _key of an edge in the collection, or a document
* (i.e. an object with an _id or _key property).
* @return {Object} edge object
*/
getAllEdgesForVertice(collectionName: string, documentHandle: string): Promise<any>;
/**
* get all incoming edges.
*
* @param {String} collectionName edge collection name
* @param {String} documentHandle The handle of the document
* @return {[Object]} list of edges
*/
getInEdges(collectionName: string, documentHandle: string): Promise<any>;
/**
* get all outgoing edges.
*
* @param {String} collectionName edge collection name
* @param {String} documentHandle The handle of the document
* @return {[Object]} list of edges
*/
getOutEdges(collectionName: string, documentHandle: string): Promise<any>;
/**
* collection traversal - Performs a traversal starting from the given
* startVertex and following edges contained in this edge collection.
*
* @param {String} collectionName collection name
* @param {String | String[]} startVertex Start vertex or vertices.
* This can be either the _id of a document in the database,
* the _key of an edge in the collection, or a document
* (i.e. an object with an _id or _key property).
* @param {any} opts opts.direction opts.filter, opts.visitor,
* opts.init, opts.expander, opts.sort
* @return {[Object]} edge traversal path
*/
traversal(vertices: Vertices, collection: Collection, opts: DeepPartial<TraversalOptions>, filters?: GraphFilters[]): Promise<TraversalResponse>;
getAllChildrenNodes(startVertex: string, edgeName: string): Promise<any>;
arrUnique<T>(arr: T[]): T[];
/**
* Adds the given edge definition to the graph.
*
* @param {string} edgeName edge name
* @param {Object} fromVertice from vertice
* @param {Object} toVertice from vertice
* @return {Object} The added edge definition
*/
addEdgeDefinition(edgeName: string, fromVertice: (string | ArangoCollection)[], toVertice: (string | ArangoCollection)[]): Promise<object>;
/**
* Removes the edge definition with the given definitionName form the graph.
*
* @param {string} definitionName Name of the edge definition
* to remove from the graph.
* @param {boolean} dropCollection If set to true, the edge collection
* associated with the definition will also be deleted from the database.
* @return {Object} replaced edge definition
*/
removeEdgeDefinition(definitionName: string, dropCollection?: boolean): Promise<object>;
/**
* list graphs.
*
* @return {Promise<any>} list all the graphs
*/
listGraphs(): Promise<any>;
/**
* Deletes the edge with the given documentHandle from the collection.
*
* @param {string} collectionName edge collection name
* @param {string} documentHandle The handle of the edge to retrieve.
* This can be either the _id or the _key of an edge in the collection,
* or an edge (i.e. an object with an _id or _key property).
* @return {Object} removed Edge
*/
removeEdge(collectionName: string, documentHandle: string): Promise<any>;
}
//# sourceMappingURL=graph.d.ts.map