mongoose-smart-query 0.1.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,27 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
1
25
  import { Schema } from 'mongoose';
2
26
  interface PluginOptions {
3
27
  /**
@@ -62,7 +86,7 @@ interface TObject {
62
86
  * @param $project The $project's pipeline that can contains possible $lookup.
63
87
  * @returns An array with the fields with a possible $lookup.
64
88
  */
65
- export declare function getListOfPossibleLookups($project: any): string[];
89
+ export declare const getListOfPossibleLookups: ($project: any) => string[];
66
90
  /**
67
91
  * Converts a string to object. Example:
68
92
  * 'name age friends { name }' => { name: 1, age: 1, friends: { name: 1 } }
@@ -1 +1 @@
1
- "use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,i,s,c){return new(s=s||Promise)(function(t,r){function n(e){try{a(c.next(e))}catch(e){r(e)}}function o(e){try{a(c.throw(e))}catch(e){r(e)}}function a(e){var r;e.done?t(e.value):((r=e.value)instanceof s?r:new s(function(e){e(r)})).then(n,o)}a((c=c.apply(e,i||[])).next())})},__generator=this&&this.__generator||function(n,o){var a,i,s,c={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},u={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function e(t){return function(e){var r=[t,e];if(a)throw new TypeError("Generator is already executing.");for(;c=u&&r[u=0]?0:c;)try{if(a=1,i&&(s=2&r[0]?i.return:r[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,r[1])).done)return s;switch(i=0,(r=s?[2&r[0],s.value]:r)[0]){case 0:case 1:s=r;break;case 4:return c.label++,{value:r[1],done:!1};case 5:c.label++,i=r[1],r=[0];continue;case 7:r=c.ops.pop(),c.trys.pop();continue;default:if(!(s=0<(s=c.trys).length&&s[s.length-1])&&(6===r[0]||2===r[0])){c=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]<s[3]))c.label=r[1];else if(6===r[0]&&c.label<s[1])c.label=s[1],s=r;else{if(!(s&&c.label<s[2])){s[2]&&c.ops.pop(),c.trys.pop();continue}c.label=s[2],c.ops.push(r)}}r=o.call(n,c)}catch(e){r=[6,e],i=0}finally{a=s=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}}},__spreadArray=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var n,o=0,a=r.length;o<a;o++)!n&&o in r||((n=n||Array.prototype.slice.call(r,0,o))[o]=r[o]);return e.concat(n||Array.prototype.slice.call(r))},mongoose_1=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.removeKeys=exports.stringToQuery=exports.getListOfPossibleLookups=void 0,require("mongoose"));function getListOfPossibleLookups(t){var e,n=[];for(e in t)!function(r){var e;if("object"!=typeof t[r])return r.includes(".")&&(e=r.split(/\.(.+)/),n.push(e[0]));n.push(r),e=getListOfPossibleLookups(t[r]),n=n.concat(e.map(function(e){return r+"."+e}))}(e);return n}function stringToQuery(e,a){void 0===a&&(a="1");e=(e=void 0===e?"":e).replace(/(})(?!$| *})|([\w.]+)(?= *{)|([\w.]+)(?=$| *})|([\w.]+)/g,function(e,r,t,n,o){return r?r+",":t?'"'.concat(t,'":'):n?'"'.concat(n,'": ').concat(a):o?'"'.concat(o,'": ').concat(a,","):""});return JSON.parse("{ ".concat(e," }"))}function parseValue(e,r){switch(r){case"ObjectID":case"ObjectId":return new mongoose_1.Types.ObjectId(e);case"Date":return new Date(e);case"Number":return Number(e);case"Boolean":return"boolean"==typeof e?e:"true"===e;default:return e}}function removeKeys(e,r){var t,n=__assign({},e);for(t in r)!n[t]||"object"==typeof r[t]&&(n[t]=removeKeys(n[t],r[t]),0!==Object.keys(n[t]).length)||delete n[t];return n}function default_1(b,e){var r=e.protectedFields,p=void 0===r?"":r,r=e.defaultFields,f=void 0===r?"_id":r,r=e.defaultSort,y=void 0===r?"-_id":r,r=e.defaultLimit,h=void 0===r?20:r,r=e.pageQueryName,d=void 0===r?"$page":r,r=e.limitQueryName,g=void 0===r?"$limit":r,r=e.fieldsQueryName,$=void 0===r?"$fields":r,r=e.sortQueryName,_=void 0===r?"$sort":r,r=e.queryName,m=void 0===r?"$q":r,r=e.unwindName,w=void 0===r?"$unwind":r,r=e.fieldsForDefaultQuery,A=void 0===r?"":r,r=e.allFieldsQueryName,O=void 0===r?"$getAllFields":r,r=e.getAllFieldsByDefault,x=void 0!==r&&r,j=stringToQuery(p);b.statics.smartQuery=function(e){e=this.__smartQueryGetPipeline(__assign({},e=void 0===e?{}:e));return this.aggregate(e)},b.statics.smartCount=function(t){return void 0===t&&(t={}),__awaiter(this,void 0,void 0,function(){var r;return __generator(this,function(e){switch(e.label){case 0:return r=this.__smartQueryGetPipeline(__assign({},t),!0),[4,this.aggregate(r)];case 1:return[2,0===(r=e.sent()).length?0:r[0].size]}})})},b.statics.__smartQueryGetPipeline=function(v,e){void 0===e&&(e=!1);var r=JSON.parse(JSON.stringify(v)),t=parseInt(v[d])||1,n=parseInt(v[g])||h,u=function(){var e,g={},$={},_=[];for(e in v)!function(e){var r,t=b.path(e);if(!t&&!e.includes("."))return;var n,o=t?g:$,a=/(?:\{(\$?[\w ]+)\})?([^{}\n]+)/g,i=[];if("string"==typeof v[e]){var s={},c=v[e],u=c.startsWith("{$or}");for(u&&(c=c.replace("{$or}",""));null!==(n=a.exec(c));)i.push([n[0],n[1],n[2]]);for(var l=0,p=i;l<p.length;l++){var f=p[l],y=f[1],h=f[2];switch(y){case"$exists":s[e]={$exists:"false"!==h};break;case"$includes":s[e]={$regex:RegExp(h.replace(/[^\w]/g,"."),"i")};break;case"$in":case"$nin":var d=h.split(",").map(function(e){return parseValue(e.trim(),null==t?void 0:t.instance)});s[e]=((r={})[y]=d,r);break;default:d=parseValue(h,null==t?void 0:t.instance);y?"object"==typeof s[e]?s[e][y]=d:s[e]=((r={})[y]=d,r):"string"==typeof h&&h.includes("$exists")?s[e]={$exists:!0,$ne:[]}:s[e]=d}}u?_.push(s):Object.assign(o,s)}else o[e]=parseValue(v[e],null==t?void 0:t.instance)}(e);return 0!==_.length&&(g.$or=_),{$localMatch:g,$foreignMatch:$}};function o(){return v[w]?[{$unwind:{path:"$".concat(v[w]),preserveNullAndEmptyArrays:!0}}]:[]}var a,i,s=function(){var e,r={},t={};if(v[m]&&A)for(var n=A.split(" "),o=v[m].replace(/[()[\\\]*]/g,"."),a={$regex:RegExp(o,"i")},i=0,s=n;i<s.length;i++){var c=s[i];!!b.path(c)?(t.$or||(t.$or=[]),t.$or.push(((e={})["".concat(c)]=a,e))):(t.$or||(t.$or=[]),t.$or.push(((e={})["".concat(c)]=a,e)))}o=u(),n=o.$localMatch.$or||o.$foreignMatch.$or;return n&&(delete o.$localMatch.$or,delete o.$foreignMatch.$or,Array.isArray(r.$or)?r.$or=r.$or.concat(n):Array.isArray(t.$or)?t.$or=t.$or.concat(n):r.$or=n),{$queryMatch:__assign(__assign({},r),o.$localMatch),$foreignMatch:__assign(__assign({},t),o.$foreignMatch)}}(),c=(!(c=v)[$]&&f&&(c[$]=f),removeKeys(stringToQuery(c[$]),j)),l=(a=[],getListOfPossibleLookups(c).forEach(function(e){var r=b.path(e);r&&r.options.ref&&(r=r.options.ref,a.push({$lookup:{from:r,localField:e,foreignField:"_id",as:e}},{$unwind:{path:"$".concat(e),preserveNullAndEmptyArrays:!0}}))}),a);return e?i=__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([],0!==Object.keys(s.$queryMatch).length?[{$match:s.$queryMatch}]:[],!0),l,!0),o(),!0),0!==Object.keys(s.$foreignMatch).length?[{$match:s.$foreignMatch}]:[],!0),[{$count:"size"}],!1):(e=function(){if(!v[_]){if(!y)return{};v[_]=y}for(var e=/(-)?([\w.]+)/g,r={},t={};null!==(o=e.exec(v[_]));){var n=o[1],o=o[2];!!b.path(o)?r[o]=n?-1:1:t[o]=n?-1:1}return{$localSort:0!==Object.keys(r).length?r:void 0,$foreignSort:0!==Object.keys(t).length?t:void 0}}(),i=__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([],0!==Object.keys(s.$queryMatch).length?[{$match:s.$queryMatch}]:[],!0),e.$localSort?[{$sort:e.$localSort}]:[],!0),l,!0),o(),!0),0!==Object.keys(s.$foreignMatch).length?[{$match:s.$foreignMatch}]:[],!0),[{$skip:(t-1)*n},{$limit:n}],!1),!r[$]&&!0===x||"true"===(null==(e=v[O])?void 0:e.toString())?p&&i.push({$project:stringToQuery(p,"0")}):i.push({$project:c})),i}}exports.getListOfPossibleLookups=getListOfPossibleLookups,exports.stringToQuery=stringToQuery,exports.removeKeys=removeKeys,exports.default=default_1;
1
+ "use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,s,a,c){return new(a=a||Promise)(function(r,t){function n(e){try{o(c.next(e))}catch(e){t(e)}}function i(e){try{o(c.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,i)}o((c=c.apply(e,s||[])).next())})},__generator=this&&this.__generator||function(n,i){var o,s,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},u={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function e(r){return function(e){var t=[r,e];if(o)throw new TypeError("Generator is already executing.");for(;c=u&&t[u=0]?0:c;)try{if(o=1,s&&(a=2&t[0]?s.return:t[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,t[1])).done)return a;switch(s=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,s=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))c.label=t[1];else if(6===t[0]&&c.label<a[1])c.label=a[1],a=t;else{if(!(a&&c.label<a[2])){a[2]&&c.ops.pop(),c.trys.pop();continue}c.label=a[2],c.ops.push(t)}}t=i.call(n,c)}catch(e){t=[6,e],s=0}finally{o=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}},__spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||((n=n||Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},mongoose_1=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.removeKeys=exports.stringToQuery=exports.getListOfPossibleLookups=void 0,require("mongoose")),getListOfPossibleLookups=function(r){var e,n=[];for(e in r)!function(t){var e;if("object"!=typeof r[t])return t.includes(".")&&(e=t.split(/\.(.+)/),n.push(e[0]));n.push(t),e=(0,exports.getListOfPossibleLookups)(r[t]),n=n.concat(e.map(function(e){return t+"."+e}))}(e);return n};function stringToQuery(e,o){void 0===o&&(o="1");e=(e=void 0===e?"":e).replace(/(})(?!$| *})|([\w.]+)(?= *{)|([\w.]+)(?=$| *})|([\w.]+)/g,function(e,t,r,n,i){return t?t+",":r?'"'.concat(r,'":'):n?'"'.concat(n,'": ').concat(o):i?'"'.concat(i,'": ').concat(o,","):""});return JSON.parse("{ ".concat(e," }"))}function parseValue(e,t){switch(t){case"ObjectID":case"ObjectId":return new mongoose_1.Types.ObjectId(e);case"Date":return new Date(e);case"Number":return Number(e);case"Boolean":return"boolean"==typeof e?e:"true"===e;default:return e}}function removeKeys(e,t){var r,n=__assign({},e);for(r in t)!n[r]||"object"==typeof t[r]&&(n[r]=removeKeys(n[r],t[r]),0!==Object.keys(n[r]).length)||delete n[r];return n}function default_1(j,e){var t=e.protectedFields,m=void 0===t?"":t,t=e.defaultFields,$=void 0===t?"_id":t,t=e.defaultSort,O=void 0===t?"-_id":t,t=e.defaultLimit,x=void 0===t?20:t,t=e.pageQueryName,k=void 0===t?"$page":t,t=e.limitQueryName,A=void 0===t?"$limit":t,t=e.fieldsQueryName,Q=void 0===t?"$fields":t,t=e.sortQueryName,P=void 0===t?"$sort":t,t=e.queryName,L=void 0===t?"$q":t,t=e.unwindName,N=void 0===t?"$unwind":t,t=e.fieldsForDefaultQuery,S=void 0===t?"":t,t=e.allFieldsQueryName,T=void 0===t?"$getAllFields":t,t=e.getAllFieldsByDefault,I=void 0!==t&&t,F=stringToQuery(m);j.statics.smartQuery=function(){return __awaiter(this,arguments,void 0,function(t){var r,n,o,i,s,a,c,u;return void 0===t&&(t={}),__generator(this,function(e){switch(e.label){case 0:return[4,this.__smartQueryGetPipeline(__assign({},t))];case 1:return r=e.sent(),n=r.pipeline,o=r.lookupsConfirmados,i=t.business?{business:new mongoose_1.Types.ObjectId(t.business)}:{},[4,this.aggregate(n)];case 2:return s=e.sent(),[4,Promise.all(o.map(function(t){var e=s.filter(function(e){return e[t.field]}).map(function(e){return e[t.field]});return mongoose_1.connection.collection(t.from).find(__assign({_id:{$in:e}},i)).project(t.project).toArray()}))];case 3:for(u in a=e.sent(),c=function(e){for(var r=a[e],n=o[e],t=0,i=s;t<i.length;t++)!function(t){t[n.field]=r.find(function(e){return e._id.equals(t[n.field])})}(i[t])},o)c(u);return[2,s]}})})},j.statics.smartCount=function(){return __awaiter(this,arguments,void 0,function(t){var r;return void 0===t&&(t={}),__generator(this,function(e){switch(e.label){case 0:return[4,this.__smartQueryGetPipeline(__assign({},t),!0)];case 1:return r=e.sent().pipeline,[4,this.aggregate(r)];case 2:return[2,0===(r=e.sent()).length?0:r[0].size]}})})},j.statics.__smartQueryGetPipeline=function(e){return __awaiter(this,arguments,void 0,function(w,r){var _,n,i,o,h,s,a,c,u,l,f,p,d,g,y,v,b=this;return void 0===r&&(r=!1),__generator(this,function(e){switch(e.label){case 0:return _=w.business?{business:new mongoose_1.Types.ObjectId(w.business)}:{},n=JSON.parse(JSON.stringify(w)),i=parseInt(w[k])||1,o=parseInt(w[A])||x,h=function(){return __awaiter(b,void 0,void 0,function(){var b,m,$,t,r,n=this;return __generator(this,function(e){switch(e.label){case 0:for(r in b={},m={},$=[],t=function(e){var t,r=j.path(e);if(!r&&!e.includes("."))return"continue";var n,i,o=e,s=void 0,a=w[o],e=(e.includes(".")&&(p=(e=e.split("."))[0],e=e[1],n=j.path(p))&&n.options.ref&&(o=e,m[s=p]={collection:n.options.ref,$match:{}}),s?m[s].$match:b),c=/(?:\{(\$?[\w ]+)\})?([^{}\n]+)/g,u=[];if("string"==typeof a){var l={},f=a,p=f.startsWith("{$or}");for(p&&(f=f.replace("{$or}",""));null!==(i=c.exec(f));)u.push([i[0],i[1],i[2]]);for(var d=0,_=u;d<_.length;d++){var h=_[d],g=h[1],y=h[2];switch(g){case"$exists":l[o]={$exists:"false"!==y};break;case"$includes":l[o]={$regex:RegExp(y.replace(/[^\w]/g,"."),"i")};break;case"$in":case"$nin":var v=y.split(",").map(function(e){return parseValue(e.trim(),null==r?void 0:r.instance)});l[o]=((t={})[g]=v,t);break;default:v=parseValue(y,null==r?void 0:r.instance);g?"object"==typeof l[o]?l[o][g]=v:l[o]=((t={})[g]=v,t):"string"==typeof y&&y.includes("$exists")?l[o]={$exists:!0,$ne:[]}:l[o]=v}}p?$.push(l):Object.assign(e,l)}else e[o]=parseValue(a,null==r?void 0:r.instance)},w)t(r);return 0!==$.length&&(b.$or=$),0===Object.keys(m).length?[3,2]:[4,Promise.all(Object.entries(m).map(function(e){return __awaiter(n,[e],void 0,function(e){var t,r=e[0],n=e[1];return __generator(this,function(e){switch(e.label){case 0:return[4,mongoose_1.connection.collection(n.collection).find(__assign(__assign({},n.$match),_)).project({_id:1}).toArray()];case 1:return t=e.sent(),b[r]={$in:t.map(function(e){return e._id})},[2]}})})}))];case 1:e.sent(),e.label=2;case 2:return[2,b]}})})},s=function(){return w[N]?[{$unwind:{path:"$".concat(w[N]),preserveNullAndEmptyArrays:!0}}]:[]},[4,function(){return __awaiter(b,void 0,void 0,function(){var o,t,r,n,i,s,a,c,u,l,f,p,d=this;return __generator(this,function(e){switch(e.label){case 0:if(o={},t={},!w[L]||!S)return[3,2];for(l=S.split(" "),u=w[L].replace(/[()[\\\]*]/g,"."),r={$regex:RegExp(u,"i")},n=0,i=l;n<i.length;n++)s=i[n],j.path(s)?(o.$or||(o.$or=[]),o.$or.push(((f={})[s]=r,f))):s.includes(".")&&(f=s.split("."),s=f[0],a=f[1],c=j.path(s))&&c.options.ref&&(t[s]?t[s].$match.$or.push(((p={})[a]=r,p)):t[s]={collection:c.options.ref,$match:{$or:[((p={})[a]=r,p)]}});return 0===Object.keys(t).length?[3,2]:[4,Promise.all(Object.entries(t).map(function(e){return __awaiter(d,[e],void 0,function(e){var t,r,n=e[0],i=e[1];return __generator(this,function(e){switch(e.label){case 0:return[4,mongoose_1.connection.collection(i.collection).find(__assign(__assign({},i.$match),_)).project({_id:1}).toArray()];case 1:return t=e.sent(),(t=t.map(function(e){return e._id})).length&&o.$or.push(((r={})[n]={$in:t},r)),[2]}})})}))];case 1:e.sent(),e.label=2;case 2:return[4,h()];case 3:return u=e.sent(),(l=u.$or)&&(delete u.$or,Array.isArray(o.$or)?o.$or=o.$or.concat(l):o.$or=l),[2,__assign(__assign({},o),u)]}})})}()];case 1:if(v=e.sent(),!(t=w)[Q]&&$&&(t[Q]=$),a=removeKeys(stringToQuery(t[Q]),F),c=(0,exports.getListOfPossibleLookups)(a).reduce(function(e,r){var t,n=j.path(r);return n&&n.options.ref?(t=Object.keys(a||{}).reduce(function(e,t){return t.startsWith(r+".")?(e[t.split(".")[1]]=1,e):t.startsWith(r)&&"object"==typeof a[r]?a[r]:e},{}),e.concat([{field:r,from:n.options.ref,project:t}])):e},[]),r)u=__spreadArray(__spreadArray(__spreadArray([],0!==Object.keys(v).length?[{$match:v}]:[],!0),s(),!0),[{$count:"size"}],!1);else if(l=function(){if(!w[P]){if(!O)return{};w[P]=O}for(var e=/(-)?([\w.]+)/g,t={},r={};null!==(i=e.exec(w[P]));){var n=i[1],i=i[2];!!j.path(i)?t[i]=n?-1:1:r[i]=n?-1:1}return{$localSort:0!==Object.keys(t).length?t:void 0,$foreignSort:0!==Object.keys(r).length?r:void 0}}(),u=__spreadArray(__spreadArray(__spreadArray(__spreadArray([],0!==Object.keys(v).length?[{$match:v}]:[],!0),l.$localSort?[{$sort:l.$localSort}]:[],!0),s(),!0),[{$skip:(i-1)*o},{$limit:o}],!1),!n[Q]&&!0===I||"true"===(null==(v=w[T])?void 0:v.toString()))m&&u.push({$project:stringToQuery(m,"0")});else{for(f=__assign({},a),p=0,d=c;p<d.length;p++){for(y in g=d[p],f)y.includes(g.field+".")&&delete f[y];f[g.field]=1}u.push({$project:f})}return[2,{pipeline:u,lookupsConfirmados:c}]}var t})})}}exports.getListOfPossibleLookups=getListOfPossibleLookups,exports.stringToQuery=stringToQuery,exports.removeKeys=removeKeys,exports.default=default_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongoose-smart-query",
3
- "version": "0.1.6",
3
+ "version": "1.0.0",
4
4
  "description": "Optimize rest requests",
5
5
  "main": "./dist/mongoose-smart-query.js",
6
6
  "types": "./dist/mongoose-smart-query.d.ts",
@@ -31,20 +31,22 @@
31
31
  },
32
32
  "homepage": "https://github.com/mgyugcha/mongoose-smart-query#readme",
33
33
  "devDependencies": {
34
- "@types/jest": "^29.5.6",
35
- "@typescript-eslint/eslint-plugin": "^6.8.0",
36
- "@typescript-eslint/parser": "^6.8.0",
37
- "eslint": "^8.51.0",
38
- "eslint-config-prettier": "^9.0.0",
34
+ "@types/jest": "^29.5.12",
35
+ "@typescript-eslint/eslint-plugin": "^7.5.0",
36
+ "@typescript-eslint/parser": "^7.5.0",
37
+ "eslint": "^8.57.0",
38
+ "eslint-config-prettier": "^9.1.0",
39
39
  "eslint-config-standard": "^17.1.0",
40
- "eslint-plugin-import": "^2.28.1",
41
- "eslint-plugin-jest": "^27.4.2",
40
+ "eslint-plugin-import": "^2.29.1",
41
+ "eslint-plugin-jest": "^27.9.0",
42
42
  "eslint-plugin-node": "^11.1.0",
43
43
  "eslint-plugin-promise": "^6.1.1",
44
44
  "jest": "^29.7.0",
45
- "mongoose": "^7.6.3",
46
- "ts-jest": "^29.1.1",
47
- "typescript": "^5.2.2",
45
+ "ts-jest": "^29.1.2",
46
+ "typescript": "^5.4.3",
48
47
  "uglify-js": "^3.17.4"
48
+ },
49
+ "peerDependencies": {
50
+ "mongoose": "^7"
49
51
  }
50
52
  }