Comparing version 2.0.0-alpha.13 to 2.0.0-alpha.14
@@ -164,3 +164,3 @@ 'use strict'; | ||
/** | ||
* Parses "true", "like,equal,notEqual,greater,greaterOrEqual,less,lessOrEqual". | ||
* Parses "true", "equal,notEqual,greater,greaterOrEqual,less,lessOrEqual,like,between,notBetween". | ||
* | ||
@@ -175,3 +175,3 @@ * "true" defaults to "equal". | ||
filter, | ||
['like', 'equal', 'notEqual', 'greater', 'greaterOrEqual', 'less', 'lessOrEqual'], | ||
['equal', 'notEqual', 'greater', 'greaterOrEqual', 'less', 'lessOrEqual', 'like', 'between', 'notBetween'], | ||
context | ||
@@ -178,0 +178,0 @@ ); |
@@ -28,38 +28,39 @@ 'use strict'; | ||
explain.attributes = dst.request.attributes ? dst.request.attributes.join(',') : undefined; | ||
explain.filter = dst.request.filter | ||
? dst.request.filter | ||
.map(orFilter => | ||
orFilter | ||
.map(andFilter => { | ||
const operators = { | ||
like: '~', | ||
equal: '=', | ||
notEqual: '!=', | ||
less: '<', | ||
lessOrEqual: '<=', | ||
greater: '>', | ||
greaterOrEqual: '>=' | ||
}; | ||
explain.filter = | ||
dst.request.filter && | ||
dst.request.filter | ||
.map(orFilter => | ||
orFilter | ||
.map(andFilter => { | ||
function renderRecursiveArray(array) { | ||
if (!Array.isArray(array)) return array; | ||
return '[' + array.map(renderRecursiveArray).join(',') + ']'; | ||
} | ||
function renderRecursiveArray(array) { | ||
if (!Array.isArray(array)) return array; | ||
return '[' + array.map(renderRecursiveArray).join(',') + ']'; | ||
} | ||
const operators = { | ||
equal: value => '=' + renderRecursiveArray(value), | ||
notEqual: value => '!=' + renderRecursiveArray(value), | ||
less: value => '<' + value, | ||
lessOrEqual: value => '<=' + value, | ||
greater: value => '>' + value, | ||
greaterOrEqual: value => '>=' + value, | ||
like: value => '~' + value, | ||
between: value => '=' + value[0] + '..' + value[1], | ||
notBetween: value => '!=' + value[0] + '..' + value[1] | ||
}; | ||
return ( | ||
renderRecursiveArray(andFilter.attribute) + | ||
(operators[andFilter.operator] | ||
? operators[andFilter.operator] | ||
: ' ' + andFilter.operator + ' ') + | ||
renderRecursiveArray(andFilter.value) + | ||
(andFilter.valueFromParentKey ? '{from-parent-key}' : '') + | ||
(has(andFilter, 'valueFromSubFilter') | ||
? `{from-sub-filter: ${andFilter.valueFromSubFilter}}` | ||
: '') | ||
); | ||
}) | ||
.join(' AND ') | ||
) | ||
.join(' OR ') | ||
: undefined; | ||
return ( | ||
renderRecursiveArray(andFilter.attribute) + | ||
(operators[andFilter.operator] | ||
? operators[andFilter.operator](andFilter.value) | ||
: ' ' + andFilter.operator + ' ' + andFilter.value) + | ||
(andFilter.valueFromParentKey ? '{from-parent-key}' : '') + | ||
(has(andFilter, 'valueFromSubFilter') | ||
? `{from-sub-filter: ${andFilter.valueFromSubFilter}}` | ||
: '') | ||
); | ||
}) | ||
.join(' AND ') | ||
) | ||
.join(' OR '); | ||
explain.search = dst.request.search; | ||
@@ -66,0 +67,0 @@ explain.order = dst.request.order |
{ | ||
"name": "flora", | ||
"version": "2.0.0-alpha.13", | ||
"version": "2.0.0-alpha.14", | ||
"description": "FLexible Open Rest API", | ||
@@ -44,30 +44,30 @@ "main": "index.js", | ||
"@godmodelabs/busboy": "^0.3.1", | ||
"bunyan": "^1.5.1", | ||
"chokidar": "^2.1.0", | ||
"content-type": "^1.0.2", | ||
"bunyan": "^1.8.12", | ||
"chokidar": "^2.1.5", | ||
"content-type": "^1.0.4", | ||
"flora-cluster": "^2.0.0-alpha.2", | ||
"flora-errors": "^2.0.0-alpha.1", | ||
"flora-request-parser": "^2.1.0", | ||
"flora-request-parser": "^2.2.0", | ||
"has": "^1.0.3", | ||
"lodash": "^4.17.11", | ||
"moment-timezone": "^0.5.23", | ||
"moment-timezone": "^0.5.25", | ||
"promise-events": "^0.1.4", | ||
"serve-static": "^1.10.0", | ||
"xmldom": "^0.1.19" | ||
"serve-static": "^1.13.2", | ||
"xmldom": "^0.1.27" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.1.6", | ||
"@types/chai": "^4.1.7", | ||
"chai": "^4.2.0", | ||
"chai-as-promised": "^7.1.1", | ||
"eslint": "^5.13.0", | ||
"eslint-config-prettier": "^4.0.0", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"jsdoc": "^3.5.3", | ||
"mocha": "^5.2.0", | ||
"mock-fs": "^4.8.0", | ||
"eslint": "^5.16.0", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"jsdoc": "^3.5.5", | ||
"mocha": "^6.1.4", | ||
"mock-fs": "^4.9.0", | ||
"pre-commit": "^1.2.2", | ||
"prettier": "^1.15.2", | ||
"sinon": "^7.2.3", | ||
"prettier": "^1.17.0", | ||
"sinon": "^7.3.2", | ||
"sinon-chai": "^3.3.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
188931
4098
Updatedbunyan@^1.8.12
Updatedchokidar@^2.1.5
Updatedcontent-type@^1.0.4
Updatedflora-request-parser@^2.2.0
Updatedmoment-timezone@^0.5.25
Updatedserve-static@^1.13.2
Updatedxmldom@^0.1.27