-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
412 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"env", | ||
{ | ||
"targets": { | ||
"node": "4" | ||
} | ||
} | ||
] | ||
], | ||
"plugins": [ | ||
"transform-runtime" | ||
], | ||
"env": { | ||
"test": { | ||
"plugins": [ | ||
"istanbul" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"env": { | ||
"mocha": true, | ||
"node": true, | ||
"es6": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 8, | ||
"sourceType": "module" | ||
}, | ||
"extends": "loopback", | ||
"globals": { | ||
"should": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,33 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
# dotenv environment variables file | ||
.env | ||
# JetBrains IDE | ||
.idea | ||
|
||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
# JetBrains IDE | ||
.idea | ||
|
||
dist | ||
test | ||
.travis.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"require": [ | ||
"babel-register" | ||
], | ||
"sourceMap": false, | ||
"instrument": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- 4 | ||
- 6 | ||
- 8 | ||
|
||
env: | ||
- ARANGODB_VERSION=3.1 | ||
- ARANGODB_VERSION=3.2 | ||
|
||
before_install: | ||
- chmod +x ./test/travis/setup_arangodb.sh | ||
- ./test/travis/setup_arangodb.sh | ||
|
||
after_success: | ||
- npm run lint | ||
- npm run coverage | ||
- npm run nsp | ||
|
||
after_script: | ||
- ./test/travis/teardown_arangodb.sh | ||
|
||
branches: | ||
only: | ||
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"name": "loopback-graph-arangodb", | ||
"version": "0.0.0", | ||
"description": "A mixin to handle arangodb edges for loopback models", | ||
"main": "dist/index.js", | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"lint": "eslint lib/**/*.js test/**/*.js", | ||
"test": "cross-env NODE_ENV=test nyc mocha", | ||
"nsp": "nsp check", | ||
"build": "babel src -d dist", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/mrbatista/loopback-graph-arangodb.git" | ||
}, | ||
"author": "Matteo Padovano <mrba7ista@gmail.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/mrbatista/loopback-graph-arangodb/issues" | ||
}, | ||
"homepage": "https://github.com/mrbatista/loopback-graph-arangodb#readme", | ||
"dependencies": { | ||
"babel-runtime": "^6.26.0", | ||
"bluebird": "^3.5.1", | ||
"debug": "^3.1.0", | ||
"supertest": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^8.0.3", | ||
"babel-plugin-istanbul": "^4.1.5", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-env": "^1.6.0", | ||
"babel-register": "^6.26.0", | ||
"chai": "^4.1.2", | ||
"coveralls": "^3.0.0", | ||
"cross-env": "^5.1.1", | ||
"dirty-chai": "^2.0.1", | ||
"eslint": "^3.14.0", | ||
"eslint-config-loopback": "^8.0.0", | ||
"faker": "^4.1.0", | ||
"loopback": "^3.17.1", | ||
"loopback-connector-arangodb": "^2.0.2", | ||
"loopback-datasource-juggler": "^3.13.0", | ||
"loopback-edge-arangodb": "^1.3.1", | ||
"mocha": "^4.0.1", | ||
"nsp": "^2.8.0", | ||
"nyc": "^11.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import debug from 'debug'; | ||
|
||
export default debug('loopback:mixins:edge-arangodb'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import assert from 'assert'; | ||
import Promise from 'bluebird'; | ||
|
||
import debug from './debug'; | ||
|
||
export default (Model, options) => { | ||
debug('Graph mixin for Model %s with options %O', Model.modelName, options); | ||
|
||
Model.create = async function(data) { | ||
const modelName = Model.modelName; | ||
data = data || {}; | ||
data.name = modelName; | ||
const connector = this.getConnector(); | ||
const graph = connector.db.graph(modelName); | ||
return await graph.create(data); | ||
}; | ||
|
||
Model.destroy = async function(deleteCollections) { | ||
const modelName = Model.modelName; | ||
const connector = this.getConnector(); | ||
const graph = connector.db.graph(modelName); | ||
return await graph.drop(deleteCollections); | ||
}; | ||
|
||
/** | ||
* Performs a traversal starting from the given startVertex and following | ||
* edges contained in any of the edge collections of graph. | ||
* | ||
* @param graphOptions {Object} The graph options | ||
* @property {String} startVertex The start vertex | ||
* @param options {Object} The options object | ||
* @returns {Promise.<Model|Error>} | ||
*/ | ||
Model.traversal = async function(graphOptions, options) { | ||
assert(typeof graphOptions === 'object', 'graphOptions must be an object'); | ||
|
||
if (typeof graphOptions.startVertex !== 'string') { | ||
const err = new Error('startVertex is required'); | ||
err.code = 'START_VERTEX_IS_REQUIRED'; | ||
err.statusCode = 400; | ||
return Promise.reject(err); | ||
} else { | ||
const startVertex = graphOptions.startVertex; | ||
const modelName = Model.modelName; | ||
const connector = this.getConnector(); | ||
const graph = connector.db.graph(modelName); | ||
return await graph.traversal(startVertex, graphOptions); | ||
} | ||
}; | ||
|
||
if (typeof Model.remoteMethod === 'function') { | ||
Model.remoteMethod('traversal', { | ||
description: `Performs a traversal starting from the given startVertex | ||
and following edges contained in any of the edge collections of graph | ||
${Model.modelName} name.`, | ||
accepts: [ | ||
{ | ||
arg: 'graphOptions', | ||
type: 'object', | ||
http: {source: 'query'}, | ||
required: true, | ||
}, | ||
{arg: 'options', type: 'object', http: 'optionsFromRequest'}, | ||
], | ||
http: {path: '/traversal', verb: 'get'}, | ||
returns: {arg: 'result', root: true, type: 'object'}, | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {deprecate} from 'util'; | ||
import graph from './graph'; | ||
|
||
export default deprecate(app => { | ||
app.modelBuilder.mixins.define('Graph', graph); | ||
}, 'app.modelBuilder.mixins.define: Use mixinSources instead; ' + | ||
'see https://github.com/mrbatista/loopback-graph-arangodb'); | ||
|
Oops, something went wrong.