syncano-server
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -9,2 +9,6 @@ "use strict"; | ||
/** | ||
* @todo Extend with methods like delete, first, take, shuffle, etc. | ||
* @link https://laravel.com/docs/5.3/collections | ||
*/ | ||
var Collection = function Collection(data) { | ||
@@ -11,0 +15,0 @@ _classCallCheck(this, Collection); |
@@ -13,3 +13,3 @@ 'use strict'; | ||
var _queryBuilder = require('./queryBuilder'); | ||
var _queryBuilder = require('./query-builder'); | ||
@@ -211,3 +211,3 @@ var _queryBuilder2 = _interopRequireDefault(_queryBuilder); | ||
value: function take(count) { | ||
return this.withQuery({ page_size: count }); | ||
return this.withQuery({ page_size: count }); // eslint-disable-line camelcase | ||
} | ||
@@ -233,3 +233,3 @@ | ||
return this.withQuery({ | ||
order_by: '' + direction + column | ||
order_by: '' + direction + column // eslint-disable-line camelcase | ||
}); | ||
@@ -236,0 +236,0 @@ } |
@@ -6,31 +6,4 @@ 'use strict'; | ||
}); | ||
var _isEmpty2 = require('lodash/isEmpty'); | ||
var _isEmpty3 = _interopRequireDefault(_isEmpty2); | ||
var _isArray2 = require('lodash/isArray'); | ||
var _isArray3 = _interopRequireDefault(_isArray2); | ||
var _reduce2 = require('lodash/reduce'); | ||
var _reduce3 = _interopRequireDefault(_reduce2); | ||
var _isObject2 = require('lodash/isObject'); | ||
var _isObject3 = _interopRequireDefault(_isObject2); | ||
var _map2 = require('lodash/map'); | ||
var _map3 = _interopRequireDefault(_map2); | ||
exports.SyncanoError = SyncanoError; | ||
exports.NotFoundError = NotFoundError; | ||
exports.PaginationError = PaginationError; | ||
exports.ValidationError = ValidationError; | ||
exports.RequestError = RequestError; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function SyncanoError(message) { | ||
@@ -54,66 +27,2 @@ this.name = 'SyncanoError'; | ||
NotFoundError.prototype = Object.create(SyncanoError.prototype); | ||
NotFoundError.prototype.constructor = SyncanoError; | ||
function PaginationError(message) { | ||
this.name = 'PaginationError'; | ||
this.message = message || ''; | ||
this.stack = new Error().stack; | ||
} | ||
PaginationError.prototype = Object.create(SyncanoError.prototype); | ||
PaginationError.prototype.constructor = SyncanoError; | ||
function ValidationError() { | ||
var errors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
this.name = 'ValidationError'; | ||
this.stack = new Error().stack; | ||
this.errors = errors; | ||
this.message = (0, _map3.default)(errors, function (value, key) { | ||
return '"' + key + '" ' + value.join(', '); | ||
}).join('\n'); | ||
} | ||
ValidationError.prototype = Object.create(SyncanoError.prototype); | ||
ValidationError.prototype.constructor = ValidationError; | ||
function RequestError(error) { | ||
var _this = this; | ||
this.name = 'RequestError'; | ||
this.status = error.status; | ||
this.errors = error.response.body; | ||
this.originalError = error; | ||
this.response = error.response; | ||
this.message = ''; | ||
this.stack = new Error().stack; | ||
if ((0, _isObject3.default)(this.errors)) { | ||
this.message = (0, _reduce3.default)(['detail', 'error', '__all__', 'non_field_errors'], function (result, value) { | ||
var error = _this.errors[value]; | ||
if ((0, _isArray3.default)(error)) { | ||
error = error.join(', '); | ||
} | ||
result += error || ''; | ||
return result; | ||
}, this.message); | ||
if ((0, _isEmpty3.default)(this.message)) { | ||
this.message = (0, _map3.default)(this.errors, function (value, key) { | ||
if ((0, _isArray3.default)(value)) { | ||
value = value.join(', '); | ||
} | ||
return '"' + key + '" ' + value; | ||
}).join('\n'); | ||
} | ||
} | ||
if ((0, _isEmpty3.default)(this.message)) { | ||
this.message = error.message; | ||
} | ||
} | ||
RequestError.prototype = Object.create(SyncanoError.prototype); | ||
RequestError.prototype.constructor = RequestError; | ||
NotFoundError.prototype.constructor = SyncanoError; |
@@ -7,6 +7,2 @@ 'use strict'; | ||
var _syncano = require('./syncano'); | ||
var _syncano2 = _interopRequireDefault(_syncano); | ||
var _server = require('./server'); | ||
@@ -18,5 +14,2 @@ | ||
exports.default = { | ||
server: _server2.default, | ||
syncano: _syncano2.default | ||
}; | ||
exports.default = _server2.default; |
{ | ||
"name": "syncano-server", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "A library to intereact with the Syncano API on a server side", | ||
@@ -25,9 +25,4 @@ "main": "lib/index.js", | ||
"release": "npm-run-all release:*", | ||
"release:git-config": "git config --global user.email $GITHUB_EMAIL && git config --global user.name $GITHUB_NAME", | ||
"release:npm-token": "echo \"//registry.npmjs.org/:_authToken=${NPM_TOKEN}\nprogress=false\" > ~/.npmrc", | ||
"release:npm": "npm publish", | ||
"release:docs": "gh-pages -d docs -m \"Docs v${npm_package_version} [ci skip]\"", | ||
"release:reset": "git reset --hard $CIRCLE_SHA1", | ||
"release:version": "mversion patch", | ||
"release:commit": "git commit -am \"Bump to v${npm_package_version} [ci skip]\" && git push origin master && git push origin master:devel" | ||
"release:reset": "git reset --hard $CIRCLE_SHA1" | ||
}, | ||
@@ -39,3 +34,2 @@ "repository": { | ||
"dependencies": { | ||
"lodash": "^4.6.1", | ||
"node-fetch": "^1.6.3" | ||
@@ -45,5 +39,2 @@ }, | ||
"babel-cli": "^6.5.1", | ||
"babel-core": "^6.5.1", | ||
"babel-loader": "^6.2.2", | ||
"babel-plugin-lodash": "^3.1.3", | ||
"babel-plugin-transform-class-properties": "^6.22.0", | ||
@@ -55,3 +46,2 @@ "babel-plugin-transform-export-extensions": "^6.22.0", | ||
"babel-preset-env": "^1.1.4", | ||
"babel-preset-es2015": "^6.5.0", | ||
"babel-register": "^6.5.1", | ||
@@ -64,6 +54,3 @@ "codecov": "^1.0.1", | ||
"jsdoc": "^3.4.0", | ||
"json-loader": "^0.5.4", | ||
"mocha": "^2.4.5", | ||
"mocha-logger": "^1.0.2", | ||
"mversion": "^1.10.1", | ||
"nock": "^8.0.0", | ||
@@ -80,35 +67,10 @@ "npm-run-all": "^2.0.0", | ||
"esnext": true, | ||
"envs": [ | ||
"node", | ||
"mocha" | ||
], | ||
"globals": [ | ||
"CONFIG", | ||
"META", | ||
"__webpack_require__", | ||
"_", | ||
"it", | ||
"describe", | ||
"beforeEach", | ||
"afterEach", | ||
"before", | ||
"after" | ||
], | ||
"ignore": [], | ||
"rules": { | ||
"no-use-extend-native/no-use-extend-native": 0, | ||
"max-nested-callbacks": [ | ||
"error", | ||
5 | ||
], | ||
"camelcase": 0, | ||
"unicorn/filename-case": 0, | ||
"new-cap": 0, | ||
"object-curly-spacing": 0, | ||
"no-warning-comments": [ | ||
0, | ||
{ | ||
"terms": [ | ||
"todo" | ||
] | ||
} | ||
] | ||
} | ||
"CONFIG" | ||
] | ||
} | ||
} |
@@ -0,1 +1,5 @@ | ||
/** | ||
* @todo Extend with methods like delete, first, take, shuffle, etc. | ||
* @link https://laravel.com/docs/5.3/collections | ||
*/ | ||
export default class Collection { | ||
@@ -2,0 +6,0 @@ constructor(data) { |
import querystring from 'querystring' | ||
import QueryBuilder from './queryBuilder' | ||
import QueryBuilder from './query-builder' | ||
import Collection from './collection' | ||
import { NotFoundError } from './errors' | ||
import {NotFoundError} from './errors' | ||
@@ -12,4 +12,4 @@ /** | ||
url(id) { | ||
const { instanceName, className } = this.instance | ||
const url = `https://api.syncano.rocks/v2/instances/${instanceName}/classes/${className}/objects/${id ? id+'/' : ''}` | ||
const {instanceName, className} = this.instance | ||
const url = `https://api.syncano.rocks/v2/instances/${instanceName}/classes/${className}/objects/${id ? id + '/' : ''}` | ||
const query = querystring.stringify(this.query) | ||
@@ -34,3 +34,3 @@ | ||
let result = [] | ||
const { baseUrl } = this | ||
const {baseUrl} = this | ||
const fetch = this.fetch.bind(this) | ||
@@ -80,3 +80,3 @@ const pageSize = this.query.page_size || 0 | ||
.list() | ||
.then(({ objects }) => objects[0] || null) | ||
.then(({objects}) => objects[0] || null) | ||
} | ||
@@ -154,3 +154,3 @@ | ||
take(count) { | ||
return this.withQuery({ page_size: count }) | ||
return this.withQuery({page_size: count}) // eslint-disable-line camelcase | ||
} | ||
@@ -171,3 +171,3 @@ | ||
return this.withQuery({ | ||
order_by: `${direction}${column}` | ||
order_by: `${direction}${column}` // eslint-disable-line camelcase | ||
}) | ||
@@ -193,6 +193,6 @@ } | ||
const currentQuery = JSON.parse(this.query.query || '{}') | ||
const nextQuery = { [column]: { [whereOperator]: whereValue } } | ||
const nextQuery = {[column]: {[whereOperator]: whereValue}} | ||
const query = Object.assign(currentQuery, nextQuery) | ||
return this.withQuery({ query: JSON.stringify(query) }) | ||
return this.withQuery({query: JSON.stringify(query)}) | ||
} | ||
@@ -199,0 +199,0 @@ |
@@ -1,3 +0,1 @@ | ||
import _ from 'lodash' | ||
export function SyncanoError(message) { | ||
@@ -20,61 +18,1 @@ this.name = 'SyncanoError' | ||
NotFoundError.prototype.constructor = SyncanoError | ||
export function PaginationError(message) { | ||
this.name = 'PaginationError' | ||
this.message = message || '' | ||
this.stack = (new Error()).stack | ||
} | ||
PaginationError.prototype = Object.create(SyncanoError.prototype) | ||
PaginationError.prototype.constructor = SyncanoError | ||
export function ValidationError(errors = {}) { | ||
this.name = 'ValidationError' | ||
this.stack = (new Error()).stack | ||
this.errors = errors | ||
this.message = _.map(errors, (value, key) => { | ||
return `"${key}" ${value.join(', ')}` | ||
}).join('\n') | ||
} | ||
ValidationError.prototype = Object.create(SyncanoError.prototype) | ||
ValidationError.prototype.constructor = ValidationError | ||
export function RequestError(error) { | ||
this.name = 'RequestError' | ||
this.status = error.status | ||
this.errors = error.response.body | ||
this.originalError = error | ||
this.response = error.response | ||
this.message = '' | ||
this.stack = (new Error()).stack | ||
if (_.isObject(this.errors)) { | ||
this.message = _.reduce(['detail', 'error', '__all__', 'non_field_errors'], (result, value) => { | ||
let error = this.errors[value] | ||
if (_.isArray(error)) { | ||
error = error.join(', ') | ||
} | ||
result += error || '' | ||
return result | ||
}, this.message) | ||
if (_.isEmpty(this.message)) { | ||
this.message = _.map(this.errors, (value, key) => { | ||
if (_.isArray(value)) { | ||
value = value.join(', ') | ||
} | ||
return `"${key}" ${value}` | ||
}).join('\n') | ||
} | ||
} | ||
if (_.isEmpty(this.message)) { | ||
this.message = error.message | ||
} | ||
} | ||
RequestError.prototype = Object.create(SyncanoError.prototype) | ||
RequestError.prototype.constructor = RequestError |
@@ -1,7 +0,3 @@ | ||
import syncano from './syncano' | ||
import server from './server' | ||
export default { | ||
server, | ||
syncano | ||
} | ||
export default server |
@@ -5,3 +5,3 @@ import Data from './data' | ||
const instance = className => { | ||
let config = { ...options, className } | ||
let config = {...options, className} | ||
@@ -11,3 +11,3 @@ if (global.CONFIG) { | ||
token: CONFIG.SYNCANO_API_KEY, | ||
instanceName: CONFIG.SYNCANO_INSTANCE_NAME, | ||
instanceName: CONFIG.SYNCANO_INSTANCE_NAME | ||
}, options) | ||
@@ -14,0 +14,0 @@ } |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1
21
4
246934
23
756
- Removedlodash@^4.6.1
- Removedlodash@4.17.21(transitive)