@36node/query-normalizr
Advanced tools
Comparing version 0.4.4 to 0.4.5
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.4.5](https://github.com/36node/sketch/compare/@36node/query-normalizr@0.4.4...@36node/query-normalizr@0.4.5) (2019-07-06) | ||
**Note:** Version bump only for package @36node/query-normalizr | ||
## [0.4.4](https://github.com/36node/sketch/compare/@36node/query-normalizr@0.4.3...@36node/query-normalizr@0.4.4) (2019-06-20) | ||
@@ -8,0 +16,0 @@ |
@@ -1,2 +0,2 @@ | ||
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)}; | ||
function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}var e=r(require("lodash/isEmpty")),t=require("humps"),o=r(require("lodash/pickBy")),i=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=o(r,function(r,e){return!i(e,"_")}),s=o(r,function(r,e){return i(e,"_")}),c={},l=s._limit,f=s._offset,p=s._sort,_=s._populate,d=s._select,m=s._group,v=function(r,e){var t={};for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&-1===e.indexOf(o)&&(t[o]=r[o]);return t}(s,["_limit","_offset","_sort","_populate","_select","_group"]);n(l)||(c.limit=a(l)),n(f)||(c.offset=a(f)),n(p)||(c.sort=p),n(_)||(c.populate=_),n(d)||(c.select=d),n(m)||(c.group=m);var y=Object.keys(u).reduce(function(r,e){var t=u[e];if(!t)return r;var o=/(.+)_(gt|lt|gte|lte|ne)$/.exec(e);if(o){var i=o[1],n=o[2];return r[i]=r[i]||{},r[i]["$"+n]=t,r}return(o=/(.+)_like/.exec(e))?(r[o[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(y)||(c.filter=t.camelizeKeys(y,function(r,e){return"id"===r?"_id":e(r)})),Object.assign({},c,v)}function l(r){return void 0===r&&(r={}),function(r,e){return r.querystring&&(r.normalizedQuery=c(r.query)),e()}}function f(r,e){return r+"_"+e.replace("$","")}exports.queryNormalizr=l,exports.QueryNormalizr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return console.log("QueryNormalizr is deprecated, plz use queryNormalizr instead."),l.apply(void 0,r)},exports.normalize=c,exports.denormalize=function(r){void 0===r&&(r={});var e=r.limit,t=r.offset,o=r.sort,i=r.populate,u=r.select,s=r.group,c=r.filter;void 0===c&&(c={});var l=function(r,e){var t={};for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&-1===e.indexOf(o)&&(t[o]=r[o]);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(o)||(p._sort=o),n(i)||(p._populate=i),n(u)||(p._select=u),n(s)||(p._group=s),c){var d=c[_];if("object"!=typeof d||Array.isArray(d))p[_]=d;else for(var m in d)switch(m){case"$lt":case"$gt":case"$lte":case"$gte":case"$ne":p[f(_,m)]=d[m];break;case"$regex":p[f(_,"$like")]=Array.isArray(d[m])?d[m].map(function(r){return r.source}):d[m].source}}return Object.assign({},p,l)},exports.toJsonServer=function(r){console.warn("toJsonServer in query-normalizr is deprecated! Please use @36node/mock-server");var e=o(r,function(r,e){return!i(e,"_")}),t=o(r,function(r,e){return i(e,"_")}),c={},l=t._limit,f=t._offset;void 0===f&&(f=0);var p=t._sort,_=t._populate;if(n(l)||(c._limit=a(l),c._start=a(f)),!n(p)){var d=s(p),m=d.map(function(r){return i(r,"-")?"desc":"asc"});c._sort=d.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.4", | ||
"version": "0.4.5", | ||
"description": "A module boilerplate for nodejs and web.", | ||
@@ -34,3 +34,3 @@ "repository": { | ||
}, | ||
"gitHead": "df2d2ca01e1d424b51c1ce2ab0620e7b3cb224c7" | ||
"gitHead": "acb5867476817235703191651f0e3a7e3d5c0c19" | ||
} |
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
35397
56