@36node/query-normalizr
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.4.2](https://github.com/36node/query-normalizr/compare/@36node/query-normalizr@0.4.1...@36node/query-normalizr@0.4.2) (2019-06-08) | ||
### Bug Fixes | ||
* make query-normalizr support wxapp ([#93](https://github.com/36node/query-normalizr/issues/93)) ([5c7f84d](https://github.com/36node/query-normalizr/commit/5c7f84d)) | ||
## [0.4.1](https://github.com/36node/query-normalizr/compare/@36node/query-normalizr@0.4.0...@36node/query-normalizr@0.4.1) (2019-06-06) | ||
@@ -8,0 +19,0 @@ |
@@ -1,2 +0,2 @@ | ||
var r=require("humps"),e=require("lodash");function t(r){return function(r){return!isNaN(r)}(r)?Number(r):r}function i(r){return Array.isArray(r)?r:[r]}function n(i){var n=e.pickBy(i,function(r,t){return!e.startsWith(t,"_")}),o=e.pickBy(i,function(r,t){return e.startsWith(t,"_")}),s={},a=o._limit,u=o._offset,l=o._sort,c=o._populate,f=o._select,p=o._group,_=function(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&-1===e.indexOf(i)&&(t[i]=r[i]);return t}(o,["_limit","_offset","_sort","_populate","_select","_group"]);e.isNil(a)||(s.limit=t(a)),e.isNil(u)||(s.offset=t(u)),e.isNil(l)||(s.sort=l),e.isNil(c)||(s.populate=c),e.isNil(f)||(s.select=f),e.isNil(p)||(s.group=p);var y=Object.keys(n).reduce(function(r,e){var t=n[e];if(!t)return r;var i=/(.+)_(gt|lt|gte|lte|ne)$/.exec(e);if(i){var o=i[1],s=i[2];return r[o]=r[o]||{},r[o]["$"+s]=t,r}return(i=/(.+)_like/.exec(e))?(r[i[1]]=Array.isArray(t)?{$regex:t.map(function(r){return new RegExp(r,"i")})}:{$regex:new RegExp(t,"i")},r):(r[e]="true"===t||"false"!==t&&("string"==typeof t?t.trim():t),r)},{});return e.isEmpty(y)||(s.filter=r.camelizeKeys(y,function(r,e){return"id"===r?"_id":e(r)})),Object.assign({},s,_)}function o(r){return void 0===r&&(r={}),function(r,e){return r.querystring&&(r.normalizedQuery=n(r.query)),e()}}function s(r,e){return r+"_"+e.replace("$","")}exports.queryNormalizr=o,exports.QueryNormalizr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return console.log("QueryNormalizr is deprecated, plz use queryNormalizr instead."),o.apply(void 0,r)},exports.normalize=n,exports.denormalize=function(r){void 0===r&&(r={});var i=r.limit,n=r.offset,o=r.sort,a=r.populate,u=r.select,l=r.group,c=r.filter;void 0===c&&(c={});var f=function(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&-1===e.indexOf(i)&&(t[i]=r[i]);return t}(r,["limit","offset","sort","populate","select","group","filter"]),p={};for(var _ in e.isNil(i)||(p._limit=t(i)),e.isNil(n)||(p._offset=t(n)),e.isNil(o)||(p._sort=o),e.isNil(a)||(p._populate=a),e.isNil(u)||(p._select=u),e.isNil(l)||(p._group=l),c){var y=c[_];if("object"!=typeof y||Array.isArray(y))p[_]=y;else for(var m in y)switch(m){case"$lt":case"$gt":case"$lte":case"$gte":case"$ne":p[s(_,m)]=y[m];break;case"$regex":p[s(_,"$like")]=Array.isArray(y[m])?y[m].map(function(r){return r.source}):y[m].source}}return Object.assign({},p,f)},exports.toJsonServer=function(r){var n=e.pickBy(r,function(r,t){return!e.startsWith(t,"_")}),o=e.pickBy(r,function(r,t){return e.startsWith(t,"_")}),s={},a=o._limit,u=o._offset;void 0===u&&(u=0);var l=o._sort,c=o._populate;if(e.isNil(a)||(s._limit=t(a),s._start=t(u)),!e.isNil(l)){var f=i(l),p=f.map(function(r){return e.startsWith(r,"-")?"desc":"asc"});s._sort=f.map(function(r){return e.trimStart(r,"-")}).join(","),s._order=p.join(",")}if(!e.isNil(c)){var _=i(c);s._embed=_.join(",")}return Object.assign({},s,n)}; | ||
function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}var e=r(require("lodash/isEmpty")),t=require("humps"),i=r(require("lodash/pickBy")),o=r(require("lodash/startsWith")),n=r(require("lodash/isNil")),u=r(require("lodash/trimStart"));function a(r){return function(r){return!isNaN(r)}(r)?Number(r):r}function s(r){return Array.isArray(r)?r:[r]}function c(r){var u=i(r,function(r,e){return!o(e,"_")}),s=i(r,function(r,e){return o(e,"_")}),c={},f=s._limit,l=s._offset,p=s._sort,_=s._populate,y=s._select,m=s._group,v=function(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&-1===e.indexOf(i)&&(t[i]=r[i]);return t}(s,["_limit","_offset","_sort","_populate","_select","_group"]);n(f)||(c.limit=a(f)),n(l)||(c.offset=a(l)),n(p)||(c.sort=p),n(_)||(c.populate=_),n(y)||(c.select=y),n(m)||(c.group=m);var d=Object.keys(u).reduce(function(r,e){var t=u[e];if(!t)return r;var i=/(.+)_(gt|lt|gte|lte|ne)$/.exec(e);if(i){var o=i[1],n=i[2];return r[o]=r[o]||{},r[o]["$"+n]=t,r}return(i=/(.+)_like/.exec(e))?(r[i[1]]=Array.isArray(t)?{$regex:t.map(function(r){return new RegExp(r,"i")})}:{$regex:new RegExp(t,"i")},r):(r[e]="true"===t||"false"!==t&&("string"==typeof t?t.trim():t),r)},{});return e(d)||(c.filter=t.camelizeKeys(d,function(r,e){return"id"===r?"_id":e(r)})),Object.assign({},c,v)}function f(r){return void 0===r&&(r={}),function(r,e){return r.querystring&&(r.normalizedQuery=c(r.query)),e()}}function l(r,e){return r+"_"+e.replace("$","")}exports.queryNormalizr=f,exports.QueryNormalizr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return console.log("QueryNormalizr is deprecated, plz use queryNormalizr instead."),f.apply(void 0,r)},exports.normalize=c,exports.denormalize=function(r){void 0===r&&(r={});var e=r.limit,t=r.offset,i=r.sort,o=r.populate,u=r.select,s=r.group,c=r.filter;void 0===c&&(c={});var f=function(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&-1===e.indexOf(i)&&(t[i]=r[i]);return t}(r,["limit","offset","sort","populate","select","group","filter"]),p={};for(var _ in n(e)||(p._limit=a(e)),n(t)||(p._offset=a(t)),n(i)||(p._sort=i),n(o)||(p._populate=o),n(u)||(p._select=u),n(s)||(p._group=s),c){var y=c[_];if("object"!=typeof y||Array.isArray(y))p[_]=y;else for(var m in y)switch(m){case"$lt":case"$gt":case"$lte":case"$gte":case"$ne":p[l(_,m)]=y[m];break;case"$regex":p[l(_,"$like")]=Array.isArray(y[m])?y[m].map(function(r){return r.source}):y[m].source}}return Object.assign({},p,f)},exports.toJsonServer=function(r){var e=i(r,function(r,e){return!o(e,"_")}),t=i(r,function(r,e){return o(e,"_")}),c={},f=t._limit,l=t._offset;void 0===l&&(l=0);var p=t._sort,_=t._populate;if(n(f)||(c._limit=a(f),c._start=a(l)),!n(p)){var y=s(p),m=y.map(function(r){return o(r,"-")?"desc":"asc"});c._sort=y.map(function(r){return u(r,"-")}).join(","),c._order=m.join(",")}if(!n(_)){var v=s(_);c._embed=v.join(",")}return Object.assign({},c,e)}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@36node/query-normalizr", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "A module boilerplate for nodejs and web.", | ||
@@ -34,3 +34,3 @@ "repository": { | ||
}, | ||
"gitHead": "a448654fcde3937e82936e19581b17fdaab68f46" | ||
"gitHead": "ea05e5cac29e7d2faea55e14cc655b205ed2173e" | ||
} |
Sorry, the diff of this file is not supported yet
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
36281