UNPKG

argosjs

Version:

Ethereum smart-contract events visualiser

113 lines (112 loc) 3.61 kB
import { Record, Session } from "neo4j-driver/types/v1"; import { PersistenceStrategies } from "../utils/strategy"; import { QueryData } from "../utils/types"; import { EventInfoDataStruct } from "../watcher/Watcher"; import { Database, DatabaseConstructor, DatabaseModels } from "./Database"; export interface Neo4JConstructor extends DatabaseConstructor { bolt: string; http?: string; https?: string; enterpriseMode?: boolean; driverConf: object; } export default class Neo4J extends Database { /** * Create a connection to Neo4J database * @param {string} connection neo4j bolt * @param {string} username neo4j username * @param {string} password neo4j password * @param {boolean} enterpriseMode neo4j enterprise mode * @param {object} settings neo4 driver settings */ static createInstance(connection: string, username: string, password: string, enterpriseMode?: boolean, settings?: object): Neo4J; private _dbInstance; private _dbSession; private _models; /** * Create a connection to Neo4J database * @param {string} connection neo4j bolt * @param {string} username neo4j username * @param {string} password neo4j password * @param {boolean} enterpriseMode neo4j enterprise mode * @param {object} settings neo4 driver settings */ constructor(connection: string, username: string, password: string, enterpriseMode: boolean, settings: object); /** * Connect to the database */ dbConnect(): Promise<Session[]>; /** * Reconnect to the database */ dbReconnect(): Promise<void>; /** * Close connection to the database */ dbTerminate(): Promise<void[]>; /** * Load a model * @param {DatabaseModels} model loaded model using require() */ dbCreateModel(model: DatabaseModels): void; /** * Get all nodes' type */ getNodeTypes(): string[]; /** * Get all relationships' type */ getRelTypes(): string[]; /** * Delete all entry in the database */ dbClearAll(): Promise<void>; /** * Tell the database to execute a query * @param {QueryData} queryData where parameters * @returns {Promise<any>} the result of queries */ executeQuery(queryData: QueryData): Promise<Record[]>; /** * Tell the database to execute a query * @param {QueryData[]} queries a string query * @returns {Promise<any>} the result of queries */ executeQueries(queries: QueryData[]): Promise<any>; /** * * @param fileName */ exportCSV(fileName: string): Promise<void>; /** * Import from CSV */ importCSV(fileName: string): Promise<void>; /** * Prepare queries and batch-persist them to DB * @param eidss the extracted data * @param PS the persistence strategy */ persistDataToDB(eidss: EventInfoDataStruct[], PS: PersistenceStrategies): Promise<void>; private prepareCypherParams; /** * Find the type of Node property * @param nodeStrat * @param propKey */ private findNodeAttrType; /** * Find the type of Relationship property * @param relStrat * @param propKey */ private findRelationshipAttrType; /** * find the proper neo4j sanitiser for the incoming data as string * @param type the type in question. <a src="https://github.com/adam-cowley/neode#property-types">Reference</a> */ private findSanitiser; private findRelationshipModels; private findAttributesModels; } export { Neo4J };