UNPKG

@asymmetrik/janusgraph-manager

Version:

Janusgraph management tooling in NodeJS/Typescript

189 lines (179 loc) 7.92 kB
// Generated by dts-bundle v0.7.3 // Dependencies for this module: // ../gremlin import { driver } from 'gremlin'; export type JanusGraphMangerOptions = { /** * Name of the graph to traverse. */ graphName?: string; /** * Whether or not to use the ConfiguredGraphFactory for dynamic graphs. */ useConfiguredGraphFactory?: boolean; /** * Path to a JanusGraphFactory configuration on the remote, for use with JanusGraphFactory. */ configPath?: string; }; export class JanusGraphManager { /** * Default constructor. * @param client A preconfigured gremlin client for accessing gremlin-server. * @param options JanusGraphOptions for accessing the graph: * - graphName will have a default of `'graph'`. * - useConfiguredGraphFactory will have a default of `false` * - configPath has no default. */ constructor(client: driver.Client, options: JanusGraphMangerOptions); /** * Builds and persists a single graph index. * Currently, if an index with the same name is already created, this will *not* recreate the index. * @param index GraphIndex to create. * @param commit Whether or not to commit the changes. * @returns */ createGraphIndex(index: GraphIndex, commit?: boolean): Promise<number>; /** * Builds and persists a single VertexCentric index. * Currently, if an index with the same name is already created, this will *not* recreate the index. * @param index VertexCentricIndex to create. * @param commit Whether or not to commit the changes. * @returns */ createVertexCentricIndex(index: VertexCentricIndex, commit?: boolean): Promise<number>; /** * Will pause execution until the management system reports that all indices on a graph have reached the REGISTERED or ENABLED state. * @param schema GraphSchema to process. * @param graph Name of the traversal alias to analyze. Default: `graph` * @returns A promise with the number of indices that reached REGISTERED or ENABLED state. */ waitForIndices(schema: GraphSchema, graph?: string): Promise<number>; /** * Will pause execution until the management system reports that a single index on a graph has reached the REGISTERED or ENABLED state. * @param index Index to process. * @param graph Name of the traversal alias to analyze. Default: `graph` * @returns A promise of 1, indicating that 1 index has reached REGISTERED or ENABLED state. */ waitForIndex(index: GraphIndex | VertexCentricIndex, graph?: string): Promise<number>; /** * Will build only the indices from a graph schema. * @param schema - GraphSchema to get index definitions from. * @param commit - Whether or not to commit and close the traversal. Default: `false` * @returns A promise containing the number of successful traversals made. */ createIndices(schema: GraphSchema, commit?: boolean): Promise<number>; /** * Attempts to enable indices. * @param schema - GraphSchema to enable indicies for. * @param commit - Whether or not to commit and close the traversal. Default: `false` * @returns A promise containing the number of successful traversals made. */ enableIndices(schema: GraphSchema, commit?: boolean): Promise<number>; /** * Attempts to reindex all indices. * @param schema - GraphSchema to reindex indicies for. * @param commit - Whether or not to commit and close the traversal. Default: `false` * @returns A promise containing the number of successful traversals made. */ reindexIndices(schema: GraphSchema, commit?: boolean): Promise<number>; /** * Reindex an arbitrary index for an arbitrary graph. * @param graphname The graph the index is located on. * @param index The index to reindex. * @param commit Whether or not to commit (default: `false`) * @returns A promise containing the output of the reindex command. */ reindex(graphname: string, index: GraphIndex | VertexCentricIndex, commit?: boolean): Promise<unknown>; /** * Creates all the schema definitions. * @param schema - GraphSchema to get schema definitions from. * @param indices - If set `true`, will build indices as well. Default `false`. * @returns A promise containing the number of successful traversals made. */ createSchema(schema: GraphSchema, indices?: boolean): Promise<number>; /** * Retrieves all of the graph indices for the current graph. * @returns A promise containing a list of all the indices. */ getIndices(): Promise<unknown[]>; /** * Retrieves a console-friendly representation of the current graph schema * @returns A promise containing a console-friendly string of the schema and state of indices */ printSchema(): Promise<string>; /** * Leverages the gremlin client to commit a management message. * @param message Message to send prior to the commit. Not required. * @returns A promise from client commit submission. */ commit(message?: string): Promise<unknown>; /** * Attempts to close the gremlin client. * @returns A promise with close status-- defers to {@see driver.Client.prototype.close()} */ close(): Promise<void>; } export type GraphSchema = { name: string; vertices: Vertex[]; edges: Edge[]; graphIndices: GraphIndex[]; vcIndices: VertexCentricIndex[]; }; /** * JanusGraph Edge. * @property label - Edge label * @property multiplicity - default: `MULTI` * @property properties */ export type Edge = { label: string; multiplicity?: EdgeMultiplicity; properties: Property[]; }; export type EdgeMultiplicity = 'MULTI' | 'SIMPLE' | 'MANY2ONE' | 'ONE2MANY' | 'ONE2ONE'; export type Vertex = { label: string; properties: Property[]; }; export type GraphIndex = { name: string; element: ElementClass; keys: IndexKey[]; type: CompositeOrMixedIndexType; unique?: boolean; label?: string; backend?: string; }; export type IndexKey = { field: string; mapping?: IndexKeyMapping; }; export type IndexKeyMapping = 'STRING' | 'TEXT' | 'TEXTSTRING' | 'PREFIX_TREE'; export type CompositeOrMixedIndexType = 'Composite' | 'Mixed'; export type VertexCentricIndexType = 'VertexCentric'; export type IndexType = CompositeOrMixedIndexType | VertexCentricIndexType; export type ElementClass = 'Vertex' | 'Edge'; export type VertexCentricIndex = { name: string; keys: Set<string>; direction: Direction; order: Order; edgelabel: string; }; export type Direction = 'IN' | 'OUT' | 'BOTH'; export type Order = 'desc' | 'asc'; /** * JanusGraph Property. * @property key - name of the property. * @property datatype - default: `Object.class` * @property cardinality - default: `SINGLE` */ export type Property = { key: string; datatype?: PropertyType; cardinality?: PropertyCardinality; }; export type PropertyType = 'String' | 'Character' | 'Boolean' | 'Byte' | 'Short' | 'Integer' | 'Long' | 'Float' | 'Double' | 'Date' | 'Geoshape' | 'UUID'; export type PropertyCardinality = 'SINGLE' | 'SET' | 'LIST';