Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const neo4j = require('neo4j-driver').v1;
const request = require('request');
// SET YOUR VALUE FOR THE PASSWORD AND THE IP ADDRESS WHERE THE NEO4J SERVER CAN BE ACCESSED!!
var user = "neo4j", password = "neo4j1", uri = "bolt://192.168.188.142:7687"
const driver = neo4j.driver(uri, neo4j.auth.basic(user, password));
const session = driver.session(neo4j.WRITE);
var countriesDocumentURL = "https://raw.githubusercontent.com/mledoze/countries/master/countries.json"
async function addConstraints(tx) {
console.log(`Adding Constraints`)
return tx.run('CREATE CONSTRAINT ON (l:Language) ASSERT l.name IS UNIQUE').then(tx.run('CREATE CONSTRAINT ON (c:Country) ASSERT c.name IS UNIQUE').then(tx.run('CREATE CONSTRAINT ON (r:Region) ASSERT r.name IS UNIQUE').then(tx.run('CREATE CONSTRAINT ON (c:Country) ASSERT c.code IS UNIQUE'))));
}
async function addLanguages(tx, languages) {
var neo4j = require('neo4j-driver').v1;
var graphviz = require('graphviz');
// colors from: http://flatuicolors.com/
var colors = {all:["#2ecc71","#1abc9c","#3498db","#9b59b6","#34495e","#16a085","#f1c40f","#e67e22",
"#e74c3c","#95a5a6","#f39c12","#2980b9","#8e44ad","#27ae60","#2c3e50","#bdc3c7",
"#c0392b","#d35400"],
used:{}};
function merge(o1,o2) {
for(var k in o2) {
if (o2.hasOwnProperty(k)) {
o1[k]=o2[k];
}
}
return o1;
}
let captionKey = this._config && this._config.labels && this._config.labels[label] && this._config.labels[label]['caption'],
sizeKey = this._config && this._config.labels && this._config.labels[label] && this._config.labels[label]['size'],
sizeCypher = this._config && this._config.labels && this._config.labels[label] && this._config.labels[label]['sizeCypher'],
communityKey = this._config && this._config.labels && this._config.labels[label] && this._config.labels[label]['community'];
node['id'] = n.identity.toInt();
// node size
if (sizeCypher) {
// use a cypher statement to determine the size of the node
// the cypher statement will be passed a parameter {id} with the value
// of the internal node id
let session = this._driver.session();
session.run(sizeCypher, {id: neo4j.v1.int(node['id'])})
.then(function(result) {
result.records.forEach(function(record) {
record.forEach(function(v,k,r) {
if (typeof v === "number") {
self._addNode({id: node['id'], value: v});
} else if (neo4j.v1.isInt(v)) {
self._addNode({id: node['id'], value: v.toNumber()})
}
})
})
})
} else if (typeof sizeKey === "number") {
node['value'] = sizeKey;
} else {
record.forEach(function(v, k, r) {
if (v instanceof neo4j.v1.types.Node) {
let node = self.buildNodeVisObject(v);
try {
self._addNode(node);
} catch(e) {
console.log(e);
}
}
else if (v instanceof neo4j.v1.types.Relationship) {
let edge = self.buildEdgeVisObject(v);
try {
self._addEdge(edge);
} catch(e) {
console.log(e);
}
}
else if (v instanceof neo4j.v1.types.Path) {
let n1 = self.buildNodeVisObject(v.start);
let n2 = self.buildNodeVisObject(v.end);
self._addNode(n1);
self._addNode(n2);
constructor(config, driver) {
console.log(config);
console.log(defaults);
this._config = config;
this._encrypted = config.encrypted || defaults['neo4j']['encrypted'];
this._trust = config.trust || defaults.neo4j.trust;
this._driver = driver || neo4j.v1.driver(config.server_url || defaults.neo4j.neo4jUri, neo4j.v1.auth.basic(config.server_user || defaults.neo4j.neo4jUser, config.server_password || defaults.neo4j.neo4jPassword), {encrypted: this._encrypted, trust: this._trust});
this._query = config.initial_cypher || defaults.neo4j.initialQuery;
this._nodes = {};
this._edges = {};
this._data = {};
this._network = null;
this._container = document.getElementById(config.container_id);
}
/**
* @license MIT, imicros.de (c) 2018 Andreas Leinen
*/
"use strict";
const neo4j = require("neo4j-driver").v1;
module.exports = {
name: "db.ne4j",
/**
* Service settings
*/
settings: {},
/**
* Service metadata
*/
metadata: {},
/**
* Service dependencies
require('dotenv').config();
const soliditySha3 = require('solidity-sha3').default;
const pem = require('pem');
const fs = require('fs');
const ipaddr = require('ipaddr.js');
const _ = require('lodash');
const _u = require('underscore');
const randomString = require('randomstring');
const Web3 = require('web3');
const request = require('superagent');
const { Database } = require('arangojs');
const neo4j = require('neo4j-driver').v1;
const levenshtein = require('js-levenshtein');
const BN = require('bn.js');
const numberToBN = require('number-to-bn');
const sortedStringify = require('sorted-json-stringify');
const mkdirp = require('mkdirp');
const path = require('path');
const rimraf = require('rimraf');
const logger = require('./logger');
const { sha3_256 } = require('js-sha3');
class Utilities {
/**
* Creates new hash import ID.
* @returns {*}
*/
'use strict';
const url = require('url');
const neo4j = require('neo4j-driver').v1;
const _ = require('underscore');
const asCallback = require('ascallback');
const proxyFilter = function(db) {
if (db.options.nodeify) {
db = new Proxy(db, {
get: function(target, name) {
if (name in target && typeof target[name] == 'function') {
return function() {
if (typeof arguments[arguments.length - 1] != 'function') {
return target[name].apply(target, arguments);
}
const args = [].slice.call(arguments, 0, arguments.length - 1);
const cb = arguments[arguments.length - 1];
return asCallback(target[name].apply(target, args), cb);
'use strict';
var R = require('ramda');
var neo4j = require('neo4j-driver').v1;
var both = R.both;
var compose = R.compose;
var cond = R.cond;
var converge = R.converge;
var has = R.has;
var identity = R.identity;
var invoker = R.invoker;
var is = R.is;
var isArrayLike = R.isArrayLike;
var isNil = R.isNil;
var map = R.map;
var mapObjIndexed = R.mapObjIndexed;
var prop = R.prop;
var zipObj = R.zipObj;
'use strict';
let neo4j = require('neo4j-driver').v1;
const _ = require('lodash');
var driver;
var logCypher = false;
/**
* @class OGMNeo
*/
class OGMNeo {
/**
* Creates a neo4j connection using bolt protocol. A successful connection will create a driver object that can be accessed for OGMNeo.driver
*
* @static
* @param {string} [user=neo4j] - Neo4j user.
* @param {string} [password=neo4j] - Neo4j password.
* @param {string} [host=localhost] - Neo4j host.