@cyberskill/shared 2.20.0 → 2.25.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.
- package/dist/config/eslint/index.cjs +1 -1
- package/dist/config/eslint/index.d.ts +2 -7
- package/dist/config/eslint/index.js +1 -1
- package/dist/config/storybook/storybook.main.cjs +1 -1
- package/dist/config/storybook/storybook.main.js +1 -1
- package/dist/config/vitest/vitest.e2e.cjs +1 -1
- package/dist/config/vitest/vitest.e2e.js +6 -6
- package/dist/config/vitest/vitest.unit.cjs +1 -1
- package/dist/config/vitest/vitest.unit.js +5 -5
- package/dist/config/vitest/vitest.unit.setup.d.ts +0 -1
- package/dist/node/cli/index.cjs +4 -4
- package/dist/node/cli/index.js +56 -51
- package/dist/node/command/command.util.cjs +2 -2
- package/dist/node/command/command.util.d.ts +4 -1
- package/dist/node/command/command.util.js +125 -112
- package/dist/node/express/express.util.cjs +1 -1
- package/dist/node/express/express.util.js +24 -23
- package/dist/node/mongo/index.cjs +1 -1
- package/dist/node/mongo/index.d.ts +1 -0
- package/dist/node/mongo/index.js +15 -12
- package/dist/node/mongo/mongo.controller.cjs +1 -0
- package/dist/node/mongo/mongo.controller.d.ts +317 -0
- package/dist/node/mongo/mongo.controller.js +956 -0
- package/dist/node/mongo/mongo.controller.test.unit.d.ts +1 -0
- package/dist/node/mongo/mongo.type.d.ts +9 -10
- package/dist/node/mongo/mongo.util.cjs +5 -5
- package/dist/node/mongo/mongo.util.d.ts +32 -515
- package/dist/node/mongo/mongo.util.js +314 -1239
- package/dist/node/mongo/mongo.util.test.unit.d.ts +1 -0
- package/dist/node/path/path.constant.cjs +1 -1
- package/dist/node/path/path.constant.d.ts +2 -2
- package/dist/node/path/path.constant.js +120 -116
- package/dist/node/path/path.test.unit.d.ts +1 -0
- package/dist/node/path/path.util.d.ts +2 -2
- package/dist/react/loading/loading.component.cjs +2 -2
- package/dist/react/loading/loading.component.js +32 -19
- package/dist/react/loading/loading.test.unit.d.ts +1 -0
- package/dist/react/loading/loading.type.d.ts +2 -1
- package/dist/util/common/common.test.unit.d.ts +1 -0
- package/dist/util/common/common.util.cjs +1 -1
- package/dist/util/common/common.util.d.ts +3 -0
- package/dist/util/common/common.util.js +35 -35
- package/dist/util/index.cjs +1 -1
- package/dist/util/index.js +16 -15
- package/dist/util/object/index.cjs +1 -1
- package/dist/util/object/index.js +4 -3
- package/dist/util/object/object.test.unit.d.ts +1 -0
- package/dist/util/object/object.util.cjs +1 -1
- package/dist/util/object/object.util.d.ts +10 -30
- package/dist/util/object/object.util.js +110 -73
- package/dist/util/serializer/serializer.test.unit.d.ts +1 -0
- package/dist/util/serializer/serializer.util.cjs +1 -1
- package/dist/util/serializer/serializer.util.js +19 -16
- package/dist/util/string/string.test.unit.d.ts +1 -0
- package/dist/util/string/string.util.cjs +1 -1
- package/dist/util/string/string.util.d.ts +4 -3
- package/dist/util/string/string.util.js +32 -41
- package/dist/util/validate/validate.test.unit.d.ts +1 -0
- package/dist/util/validate/validate.util.cjs +1 -1
- package/dist/util/validate/validate.util.js +9 -9
- package/package.json +44 -51
- /package/dist/node_modules/.pnpm/{vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_tsx@4.20.6_yaml@2.8.1 → vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.cjs +0 -0
- /package/dist/node_modules/.pnpm/{vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_tsx@4.20.6_yaml@2.8.1 → vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -17,7 +17,7 @@ export declare class C_Collection<T extends Partial<C_Document>> extends Collect
|
|
|
17
17
|
}
|
|
18
18
|
export interface I_ExtendedModel<T extends Partial<C_Document>> extends Model<T>, PaginateModel<T>, AggregatePaginateModel<T> {
|
|
19
19
|
}
|
|
20
|
-
export type
|
|
20
|
+
export type T_QueryFilter<T> = QueryFilter<T>;
|
|
21
21
|
export type T_ProjectionType<T> = ProjectionType<T>;
|
|
22
22
|
export type T_QueryOptions<T> = QueryOptions<T>;
|
|
23
23
|
export type T_PaginateOptions = PaginateOptions;
|
|
@@ -91,7 +91,6 @@ export interface I_CreateSchemaOptions<T, R extends string = string> extends I_M
|
|
|
91
91
|
export type T_MongooseMiddlewareMethod = string | RegExp;
|
|
92
92
|
export type T_MongooseMiddlewarePreFunction<T> = T_PreMiddlewareFunction<T> & T_PreSaveMiddlewareFunction<T>;
|
|
93
93
|
export type T_MongooseMiddlewarePostFunction<T> = T_PostMiddlewareFunction<T> & T_ErrorHandlingMiddlewareFunction<T> & T_ErrorHandlingMiddlewareWithOption<T>;
|
|
94
|
-
export type T_MongooseHookNextFunction = (error?: Error) => void;
|
|
95
94
|
export interface I_MongooseModelMiddleware<T extends Partial<C_Document>> {
|
|
96
95
|
method: T_MongooseMiddlewareMethod;
|
|
97
96
|
pre?: T_MongooseMiddlewarePreFunction<T & T_QueryWithHelpers<T>>;
|
|
@@ -109,17 +108,17 @@ export interface I_PaginateOptionsWithPopulate extends T_PaginateOptions, Omit<T
|
|
|
109
108
|
populate?: T_Input_Populate;
|
|
110
109
|
}
|
|
111
110
|
export interface I_Input_FindOne<T> extends T_PopulateOption {
|
|
112
|
-
filter:
|
|
111
|
+
filter: T_QueryFilter<T>;
|
|
113
112
|
projection?: T_ProjectionType<T>;
|
|
114
113
|
options?: T_QueryOptions<T>;
|
|
115
114
|
}
|
|
116
115
|
export interface I_Input_FindAll<T> extends T_PopulateOption {
|
|
117
|
-
filter:
|
|
116
|
+
filter: T_QueryFilter<T>;
|
|
118
117
|
projection?: T_ProjectionType<T>;
|
|
119
118
|
options?: T_QueryOptions<T>;
|
|
120
119
|
}
|
|
121
120
|
export interface I_Input_FindPaging<T = undefined> {
|
|
122
|
-
filter?:
|
|
121
|
+
filter?: T_QueryFilter<T>;
|
|
123
122
|
options?: I_PaginateOptionsWithPopulate;
|
|
124
123
|
}
|
|
125
124
|
export interface I_Input_FindPagingAggregate {
|
|
@@ -136,12 +135,12 @@ export interface I_UpdateOptionsExtended extends Omit<QueryOptions, 'session'> {
|
|
|
136
135
|
session?: ClientSession;
|
|
137
136
|
}
|
|
138
137
|
export interface I_Input_UpdateOne<T> extends T_PopulateOption {
|
|
139
|
-
filter:
|
|
138
|
+
filter: T_QueryFilter<T>;
|
|
140
139
|
update: T_UpdateQuery<T>;
|
|
141
140
|
options?: I_UpdateOptionsExtended;
|
|
142
141
|
}
|
|
143
142
|
export interface I_Input_UpdateMany<T> extends T_PopulateOption {
|
|
144
|
-
filter:
|
|
143
|
+
filter: T_QueryFilter<T>;
|
|
145
144
|
update: T_UpdateQuery<T>;
|
|
146
145
|
options?: I_UpdateOptionsExtended;
|
|
147
146
|
}
|
|
@@ -149,16 +148,16 @@ export interface I_DeleteOptionsExtended extends Omit<QueryOptions, 'session'> {
|
|
|
149
148
|
session?: ClientSession;
|
|
150
149
|
}
|
|
151
150
|
export interface I_Input_DeleteOne<T> {
|
|
152
|
-
filter:
|
|
151
|
+
filter: T_QueryFilter<T>;
|
|
153
152
|
options?: I_DeleteOptionsExtended;
|
|
154
153
|
}
|
|
155
154
|
export interface I_Input_DeleteMany<T> {
|
|
156
|
-
filter:
|
|
155
|
+
filter: T_QueryFilter<T>;
|
|
157
156
|
options?: I_DeleteOptionsExtended;
|
|
158
157
|
}
|
|
159
158
|
export interface I_InputSlug<T> {
|
|
160
159
|
field: string;
|
|
161
|
-
filter?:
|
|
160
|
+
filter?: T_QueryFilter<T>;
|
|
162
161
|
haveHistory?: boolean;
|
|
163
162
|
}
|
|
164
163
|
export interface I_Input_CreateSlug<T> extends I_InputSlug<T> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
module.exports = ${JSON.stringify(
|
|
3
|
-
${
|
|
4
|
-
|
|
5
|
-
`).includes(T.MIGRATE_MONGO_CONFIG)||$.appendFileSync(T.PATH.GIT_IGNORE,t):$.writeFileSync(T.PATH.GIT_IGNORE,t)}}),regexify(n,e){if(!n)return{};let t=U.cloneDeep(n);if(!e||e.length===0)return t;for(const r of e){const s=r.toString().split("."),i=F.getNestedValue(t,s);if(typeof i=="string"&&i.length>0){const o={$regex:`.*${tt.regexSearchMapper(i)}.*`,$options:"i"};t=F.setNestedValue(t,s,o)}}return t},isDynamicVirtual(n){return!!(n&&typeof n.ref=="function")},getNewRecords(n,e,t){return v(this,null,function*(){const r=yield n.findAll({});return r.success?e.filter(i=>!r.result.some(o=>t(o,i))):e})},getExistingRecords(n,e,t){return v(this,null,function*(){const r=yield n.findAll({});return r.success?r.result.filter(i=>e.some(o=>t(i,o))):[]})}};function q(n,e){if(!n||!e||e.length===0)return n;const t=new Set(e.map(r=>r.name));if(Array.isArray(n)){const r=n.filter(s=>{if(typeof s=="string")return!Array.from(t).some(i=>s===i||s.startsWith(`${i}.`));if(typeof s=="object"&&s!==null){const i=s,o=i.path||i.populate||"";return!Array.from(t).some(l=>o===l||o.startsWith(`${l}.`))}return!0});return r.length>0?r:void 0}if(typeof n=="string")return Array.from(t).some(r=>n===r||n.startsWith(`${r}.`))?void 0:n;if(typeof n=="object"&&n!==null){const r=n,s=r.path||r.populate||"";return Array.from(t).some(i=>s===i||s.startsWith(`${i}.`))?void 0:n}return n}function ct(n,e,t){if(!n.length||!e||!(t!=null&&t.ref))return[];const r=new Map;return n.forEach(s=>{try{const i=t.ref(s);if(i==null)return;const o=typeof i=="string"?i:String(i);if(o&&o.trim()!==""){const l=M(o);r.has(l)||r.set(l,[]),r.get(l).push(s)}}catch(i){N.catchError(new Error(`Dynamic ref function failed for virtual "${e}": ${i instanceof Error?i.message:String(i)}`))}}),Array.from(r.entries()).map(([s,i])=>({model:s,docs:i}))}function ut(n){return n!==null&&typeof n=="object"&&"toObject"in n&&typeof n.toObject=="function"}function W(n,e,t,r,s){return v(this,null,function*(){if(!e.length||!t)return e;const i=Array.isArray(t)?t:[t];for(const o of i)typeof o=="string"?yield Q(n,e,o,r,s):o&&typeof o=="object"&&(yield at(n,e,o,r,s));return e})}function Q(n,e,t,r,s){return v(this,null,function*(){var i,o,l,c;const a=t.split(".");if(a.length<2){for(const y of e)yield z(n,y,t,r,void 0,s);return}const u=a[0];if(!u||u.trim()==="")return;const p=a.slice(1).join(".");for(const y of e){const S=y,E=S[u];if(E&&typeof E=="object"){let g=s;const h=g;if(s&&s.schema&&s.schema.virtuals){const f=s.schema.virtuals[u];if(f&&f.options&&f.options.ref){let O;if(typeof f.options.ref=="function"?O=f.options.ref(S):typeof f.options.ref=="string"&&(O=f.options.ref),O){const d=M(O);n.models[d]&&(g=n.models[d])}}}if(!g){const f=(o=(i=s==null?void 0:s.schema)==null?void 0:i.statics)!=null?o:{},d=((s==null?void 0:s._virtualConfigs)||f._dynamicVirtuals||[]).find(m=>m.name===u);if(d&&d.options&&d.options.ref){let m;if(typeof d.options.ref=="function"?m=d.options.ref(S):typeof d.options.ref=="string"&&(m=d.options.ref),m){const j=M(m);n.models[j]&&(g=n.models[j])}}}if(g===h){const f=(c=(l=s==null?void 0:s.schema)==null?void 0:l.statics)!=null?c:{},d=((s==null?void 0:s._virtualConfigs)||f._dynamicVirtuals||[]).find(m=>m.name===u);if(d&&d.options&&d.options.ref){let m;if(typeof d.options.ref=="function"?m=d.options.ref(S):typeof d.options.ref=="string"&&(m=d.options.ref),m){const j=M(m);n.models[j]&&(g=n.models[j])}}}if(Array.isArray(E))for(const f of E)f&&typeof f=="object"&&(yield z(n,f,p,r,u,g));else E&&typeof E=="object"&&(yield z(n,E,p,r,u,g))}}})}function at(n,e,t,r,s){return v(this,null,function*(){const{path:i,populate:o}=t;if(!i)return;if(!o){yield Q(n,e,i,r,s);return}const l=i;for(const c of e){const a=c,u=a[l];let p=s;if(s&&s.schema&&s.schema.virtuals){const y=s.schema.virtuals[l];if(y&&y.options&&y.options.ref){let S;if(typeof y.options.ref=="function"?S=y.options.ref(a):typeof y.options.ref=="string"&&(S=y.options.ref),S){const E=M(S);n.models[E]&&(p=n.models[E])}}}if(!p&&typeof u=="object"&&u&&"entityType"in u){const y=M(String(u.entityType));n.models[y]&&(p=n.models[y])}if(u&&typeof u=="object")if(Array.isArray(u))for(const y of u)y&&typeof y=="object"&&(yield W(n,[y],o,r,p));else u&&typeof u=="object"&&(yield W(n,[u],o,r,p))}})}function G(n,e,t,r){if(!t||!e||!e.schema)return;const s=t.split(".");let i=e.schema;for(let o=0;o<s.length;o++){const l=s[o];if(i&&i.virtuals&&l){const c=i.virtuals[l];if(c&&c.options&&c.options.ref){let a;if(typeof c.options.ref=="function"?a=c.options.ref(r):typeof c.options.ref=="string"&&(a=c.options.ref),a&&typeof a=="string"){if(o===s.length-1)return a;const u=n.models[a];if(u&&u.schema){i=u.schema;continue}}}}if(i&&i.paths&&l){const c=i.paths[l];if(c&&c.schema){i=c.schema;continue}}return}}function ft(n,e){if(e)for(const t of Object.keys(n.models)){const r=n.models[t],s=r==null?void 0:r.schema;if(s&&(s.paths&&s.paths[e]||s.virtuals&&s.virtuals[e]))return r}}function dt(n,e){const t=(e||"").split(".")[0]||"";if(t)for(const r of Object.keys(n.models)){const s=n.models[r],i=s==null?void 0:s.schema;if(i&&(i.paths&&i.paths[t]||i.virtuals&&i.virtuals[t]))return s}}function z(n,e,t,r,s,i){return v(this,null,function*(){var o,l;let c=e.__t;if(!c){if(i){const g=s?`${s}.${t}`:t,h=(g||"").split(".")[0]||"";let f=i;if(!!!((o=f==null?void 0:f.schema)!=null&&o.paths&&f.schema.paths[h]||(l=f==null?void 0:f.schema)!=null&&l.virtuals&&f.schema.virtuals[h])){const m=dt(n,g);m&&(f=m)}const d=G(n,f,g,e);if(d)c=d;else{const m=(g.includes(".")?g.split(".").pop():g)||"";if(m){const j=ft(n,m);if(j){const R=G(n,j,g,e);R&&(c=R)}}}}if(r&&r.length>0){const g=t.split(".").pop()||"",h=r.find(f=>f.name===g);if(h&&h.options.ref){let f;typeof h.options.ref=="function"?f=h.options.ref(e):typeof h.options.ref=="string"&&(f=h.options.ref),f&&typeof f=="string"&&(c=f)}}if(!c){for(const[g,h]of Object.entries(e))if(g==="entityType"&&typeof h=="string"){c=h;break}if(c&&n.models[c]){const g=n.models[c];if(g&&g.schema){const h=g.schema,f=t.split(".").pop()||"",O=(m,j="root")=>{if(!m||!m.virtuals)return;const R=m.virtuals;for(const _ of Object.keys(R))if(_===f){const b=R[_];if(b&&b.options&&b.options.ref){let D;if(typeof b.options.ref=="function"?D=b.options.ref(e):typeof b.options.ref=="string"&&(D=b.options.ref),D&&typeof D=="string")return D}}if(m.paths)for(const _ of Object.keys(m.paths)){const b=m.paths[_];if(b&&b.schema){const D=O(b.schema,`${j}.${_}`);if(D)return D}}},d=O(h);d&&(c=d)}}}if(!c){const g=t.split(".").pop()||"";if(i&&i.schema){const h=i.schema,f=(d,m="root")=>{if(!d||!d.virtuals)return;const j=d.virtuals;for(const R of Object.keys(j))if(R===g){const _=j[R];if(_&&_.options&&_.options.ref){let b;if(typeof _.options.ref=="function"?b=_.options.ref(e):typeof _.options.ref=="string"&&(b=_.options.ref),b&&typeof b=="string")return b}}if(d.paths)for(const R of Object.keys(d.paths)){const _=d.paths[R];if(_&&_.schema){const b=f(_.schema,`${m}.${R}`);if(b)return b}}},O=f(h);O&&(c=O)}if(!c&&i){const h=G(n,i,t,e);h&&(c=h)}if(!c&&r&&r.length>0){const h=r.find(f=>f.name===g);if(h&&h.options.ref){let f;typeof h.options.ref=="function"?f=h.options.ref(e):typeof h.options.ref=="string"&&(f=h.options.ref),f&&typeof f=="string"&&(c=f)}}}if(!c){const g=t.split(".").pop()||"",h=g?g.charAt(0).toUpperCase()+g.slice(1):"";h&&n.models[h]&&(c=h)}}const a=n.models[c];if(!a)return;const u=`${t}Id`,p=`${t}Ids`,y=e[u]||e[p]||e[t];if(!y)return;const S=Array.isArray(y)?y:[y],E=yield a.find({id:{$in:S}}).lean();E.length>0&&(Array.isArray(y)?e[t]=E:e[t]=E[0])})}function K(n,e,t,r,s,i){return v(this,null,function*(){if(!e.length||!t.length||!r)return e;const o=t.filter(a=>{if(Array.isArray(r))return r.length>0&&r.some(u=>{if(typeof u=="string")return u===a.name||u.startsWith(`${a.name}.`);if(u&&typeof u=="object"){const p=u,y=p.path||p.populate||"";return y===a.name||y.startsWith(`${a.name}.`)}return!1});if(typeof r=="string")return r===a.name||r.startsWith(`${a.name}.`);if(typeof r=="object"&&r!==null){const u=r,p=u.path||u.populate||"";return p===a.name||p.startsWith(`${a.name}.`)}return!1});if(o.length===0)return e;const l=U.cloneDeep(e.map(a=>ut(a)?a.toObject():a));l.forEach(a=>{o.forEach(({name:u,options:p})=>{u in a||(a[u]=p.count?0:p.justOne?null:[])})});const c=new Map;for(const a of o){const{name:u,options:p}=a,y=ct(l,u,p);for(const S of y){c.has(S.model)||c.set(S.model,{virtuals:[],localValueSets:new Map,docsByLocalValue:new Map});const E=c.get(S.model);E.virtuals.find(h=>h.name===u)||(E.virtuals.push(a),E.localValueSets.set(u,new Set));const g=E.localValueSets.get(u);S.docs.forEach(h=>{const f=h[p.localField];if(f!=null){const O=String(f);g.add(O);let d=-1;const m=h;m.id!==void 0?d=l.findIndex(j=>j.id===m.id):m._id!==void 0&&(d=l.findIndex(j=>{var R,_,b,D;return((_=(R=j._id)==null?void 0:R.toString)==null?void 0:_.call(R))===((D=(b=m._id)==null?void 0:b.toString)==null?void 0:D.call(b))})),d!==-1&&(E.docsByLocalValue.has(O)||E.docsByLocalValue.set(O,[]),E.docsByLocalValue.get(O).push(d))}})}}if(yield Promise.all(Array.from(c.entries()).map(a=>v(null,[a],function*([u,p]){const y=n.models[u];if(!y)return;const S=new Set;if(p.localValueSets.forEach(O=>{O.forEach(d=>S.add(d))}),S.size===0)return;const E=[...new Set(p.virtuals.map(O=>O.options.foreignField))],g=Array.from(S);let h;E.length===1?h={[String(E[0])]:{$in:g}}:h={$or:E.map(O=>({[O]:{$in:g}}))};const f=yield y.find(h,s).lean();for(const O of p.virtuals){const{name:d,options:m}=O,j=f.filter(R=>{const _=R[m.foreignField];return _!=null&&S.has(String(_))});if(m.count){const R=new Map;j.forEach(_=>{var b;const D=(b=_[m.foreignField])==null?void 0:b.toString();D&&R.set(D,(R.get(D)||0)+1)}),p.localValueSets.get(d).forEach(_=>{const b=p.docsByLocalValue.get(_)||[],D=R.get(_)||0;b.forEach(w=>{const I=l[w];I[d]===void 0&&(I[d]=D)})})}else{const R=new Map;j.forEach(_=>{var b;const D=(b=_[m.foreignField])==null?void 0:b.toString();D&&(R.has(D)||R.set(D,[]),R.get(D).push(_))}),p.localValueSets.get(d).forEach(_=>{const b=p.docsByLocalValue.get(_)||[],D=R.get(_)||[],w=m.justOne?D[0]||null:D;b.forEach(I=>{const H=l[I];H[d]=w})})}}}))),r){const u=(p=>{const y=Array.isArray(p)?p:[p],S=new Map,E=[];for(const h of y)if(typeof h=="string")if(h.includes(".")){const f=h.split("."),O=f[0]||"",d=f.slice(1).join(".");O&&(S.has(O)||S.set(O,[]),d&&S.get(O).push(d))}else E.push(h);else if(h&&typeof h=="object"){const f=h;if(f.path&&f.path.includes(".")){const O=f.path.split("."),d=O[0]||"",m=O.slice(1).join(".");d&&(S.has(d)||S.set(d,[]),m&&S.get(d).push(m),f.populate&&S.get(d).push(f.populate))}else E.push(h)}const g=[...E];return S.forEach((h,f)=>{const O=[];for(const d of h)(typeof d=="string"||d&&typeof d=="object")&&O.push(d);O.length>0?g.push({path:f,populate:O}):g.push(f)}),g})(r);yield W(n,l,u,t,i)}return l})}class ht{constructor(e,t){lt(this,"collection"),this.collection=e.collection(t)}createOne(e){return v(this,null,function*(){try{const t=A(A({},P.createGenericFields()),e);return(yield this.collection.insertOne(t)).acknowledged?{success:!0,message:"Document created successfully",result:t}:{success:!1,message:"Document creation failed",code:V.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}catch(t){return N.catchError(t)}})}createMany(e){return v(this,null,function*(){try{const t=e.map(s=>A(A({},P.createGenericFields()),s)),r=yield this.collection.insertMany(t);return r.insertedCount===0?{success:!1,message:"No documents were inserted",code:V.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:`${r.insertedCount} documents created successfully`,result:t}}catch(t){return N.catchError(t)}})}findOne(e){return v(this,null,function*(){try{const t=yield this.collection.findOne(e);return t?{success:!0,message:"Document found",result:t}:{success:!1,message:"Document not found",code:V.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(t){return N.catchError(t)}})}findAll(){return v(this,arguments,function*(e={}){try{return{success:!0,message:"Documents retrieved successfully",result:yield this.collection.find(e).toArray()}}catch(t){return N.catchError(t)}})}count(){return v(this,arguments,function*(e={}){try{const t=yield this.collection.countDocuments(e);return{success:!0,message:`${t} documents counted successfully`,result:t}}catch(t){return N.catchError(t)}})}updateOne(e,t){return v(this,null,function*(){try{const r=yield this.collection.updateOne(e,{$set:t});return r.matchedCount===0?{success:!1,message:"No documents matched the filter",code:V.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Document updated successfully",result:r}}catch(r){return N.catchError(r)}})}updateMany(e,t){return v(this,null,function*(){try{const r=yield this.collection.updateMany(e,{$set:t});return r.matchedCount===0?{success:!1,message:"No documents matched the filter",code:V.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Documents updated successfully",result:r}}catch(r){return N.catchError(r)}})}deleteOne(e){return v(this,null,function*(){try{const t=yield this.collection.deleteOne(e);return t.deletedCount===0?{success:!1,message:"No documents matched the filter",code:V.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Document deleted successfully",result:t}}catch(t){return N.catchError(t)}})}deleteMany(e){return v(this,null,function*(){try{const t=yield this.collection.deleteMany(e);return t.deletedCount===0?{success:!1,message:"No documents matched the filter",code:V.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Documents deleted successfully",result:t}}catch(t){return N.catchError(t)}})}}class pt{constructor(e){this.model=e}getModelName(){return this.model.modelName}getDynamicVirtuals(){if(this.model._virtualConfigs){const r=this.model._virtualConfigs.filter(s=>{var i;return typeof((i=s.options)==null?void 0:i.ref)=="function"});if(r.length>0)return r}return this.model.schema.statics._dynamicVirtuals}populateDynamicVirtualsForDocument(e,t){return v(this,null,function*(){const r=this.getDynamicVirtuals();if(r&&r.length>0){const s=yield K(this.model.base,[e],r,t,void 0,this.model);return s&&s[0]?s[0]:e}return e})}populateDynamicVirtualsForDocuments(e,t){return v(this,null,function*(){const r=this.getDynamicVirtuals();return r&&r.length>0&&e.length>0?yield K(this.model.base,e,r,t,void 0,this.model):e})}findOne(){return v(this,arguments,function*(e={},t={},r={},s){var i,o;try{const l=F.normalizeMongoFilter(e),c=this.model.findOne(l,t,r),a=this.getDynamicVirtuals(),u=q(s,a);u&&c.populate(u);const p=yield c.exec();if(!p)return{success:!1,message:`No ${this.getModelName()} found.`,code:V.RESPONSE_STATUS.NOT_FOUND.CODE};const y=yield this.populateDynamicVirtualsForDocument(p,s);return{success:!0,result:(o=(i=y==null?void 0:y.toObject)==null?void 0:i.call(y))!=null?o:y}}catch(l){return N.catchError(l)}})}findAll(){return v(this,arguments,function*(e={},t={},r={},s){try{const i=F.normalizeMongoFilter(e),o=this.model.find(i,t,r),l=this.getDynamicVirtuals(),c=q(s,l);c&&o.populate(c);const a=yield o.exec();return{success:!0,result:(yield this.populateDynamicVirtualsForDocuments(a,s)).map(p=>{var y,S;return(S=(y=p==null?void 0:p.toObject)==null?void 0:y.call(p))!=null?S:p})}}catch(i){return N.catchError(i)}})}findPaging(){return v(this,arguments,function*(e={},t={}){try{const r=F.normalizeMongoFilter(e),s=this.getDynamicVirtuals(),i=A({},t);t.populate&&(i.populate=q(t.populate,s));const o=yield this.model.paginate(r,i);if(s&&s.length>0){const l=yield this.populateDynamicVirtualsForDocuments(o.docs,t.populate);return{success:!0,result:x(A({},o),{docs:l.map(c=>{var a,u;return(u=(a=c==null?void 0:c.toObject)==null?void 0:a.call(c))!=null?u:c})})}}return{success:!0,result:x(A({},o),{docs:o.docs.map(l=>{var c,a;return(a=(c=l==null?void 0:l.toObject)==null?void 0:c.call(l))!=null?a:l})})}}catch(r){return N.catchError(r)}})}findPagingAggregate(e){return v(this,arguments,function*(t,r={}){try{const s=this.getDynamicVirtuals(),i=A({},r);r.populate&&(i.populate=q(r.populate,s));const o=yield this.model.aggregatePaginate(this.model.aggregate(t),i),l=yield this.populateDynamicVirtualsForDocuments(o.docs,r.populate);return{success:!0,result:x(A({},o),{docs:l.map(c=>{var a,u;return(u=(a=c==null?void 0:c.toObject)==null?void 0:a.call(c))!=null?u:c})})}}catch(s){return N.catchError(s)}})}count(){return v(this,arguments,function*(e={}){try{const t=F.normalizeMongoFilter(e);return{success:!0,result:yield this.model.countDocuments(t)}}catch(t){return N.catchError(t)}})}createOne(e){return v(this,null,function*(){var t,r;try{const s=yield this.model.create(e);return{success:!0,result:(r=(t=s==null?void 0:s.toObject)==null?void 0:t.call(s))!=null?r:s}}catch(s){return N.catchError(s)}})}createMany(e){return v(this,arguments,function*(t,r={}){try{return{success:!0,result:(yield this.model.insertMany(t,r)).map(i=>{var o,l;return(l=(o=i==null?void 0:i.toObject)==null?void 0:o.call(i))!=null?l:i})}}catch(s){return N.catchError(s)}})}updateOne(){return v(this,arguments,function*(e={},t={},r={}){var s,i;try{const o=F.normalizeMongoFilter(e),l=yield this.model.findOneAndUpdate(o,t,A({new:!0},r)).exec();return l?{success:!0,result:(i=(s=l==null?void 0:l.toObject)==null?void 0:s.call(l))!=null?i:l}:{success:!1,message:`Failed to update ${this.getModelName()}.`,code:V.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(o){return N.catchError(o)}})}updateMany(){return v(this,arguments,function*(e={},t={},r={}){try{const s=F.normalizeMongoFilter(e);return{success:!0,result:yield this.model.updateMany(s,t,r).exec()}}catch(s){return N.catchError(s)}})}deleteOne(){return v(this,arguments,function*(e={},t={}){var r,s;try{const i=F.normalizeMongoFilter(e),o=yield this.model.findOneAndDelete(i,t).exec();return o?{success:!0,result:(s=(r=o==null?void 0:o.toObject)==null?void 0:r.call(o))!=null?s:o}:{success:!1,message:`No ${this.getModelName()} found to delete.`,code:V.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(i){return N.catchError(i)}})}deleteMany(){return v(this,arguments,function*(e={},t={}){try{const r=F.normalizeMongoFilter(e),s=yield this.model.deleteMany(r,t).exec();return s.deletedCount===0?{success:!1,message:"No documents found to delete.",code:V.RESPONSE_STATUS.NOT_FOUND.CODE}:{success:!0,result:s}}catch(r){return N.catchError(r)}})}createShortId(e,t=4){return v(this,null,function*(){try{const s=Array.from({length:10},(l,c)=>C.generateShortId(e,c+t)),o=(yield Promise.all(s.map(l=>this.model.exists({shortId:l})))).findIndex(l=>!l);if(o!==-1){const l=s[o];if(l)return{success:!0,result:l}}return{success:!1,message:"Failed to create a unique shortId",code:V.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}catch(r){return N.catchError(r)}})}createSlugQuery({slug:e,field:t,isObject:r,haveHistory:s=!1,filter:i}){const o=A({},i!=null?i:{});return r?x(A({},o),{$or:[{[`slug.${t}`]:e},...s?[{slugHistory:{$elemMatch:{[`slug.${t}`]:e}}}]:[]]}):x(A({},o),{$or:[{slug:e},...s?[{slugHistory:e}]:[]]})}createUniqueSlug(e){return v(this,arguments,function*({slug:t,field:r,isObject:s,haveHistory:i,filter:o}){if(!t||typeof t!="string")throw new Error("Invalid slug provided: must be a non-empty string");const l=C.generateSlug(t);if(!(yield this.model.exists(this.createSlugQuery({slug:l,field:r,isObject:s,haveHistory:i,filter:o}))))return l;for(let p=1;p<=Z.MONGO_SLUG_MAX_ATTEMPTS;p++){const y=`${l}-${p}`;if(!(yield this.model.exists(this.createSlugQuery({slug:y,field:r,isObject:s,haveHistory:i,filter:o}))))return y}const a=Date.now(),u=Math.random().toString(36).substring(2,8);return`${l}-${a}-${u}`})}createSlug(e){return v(this,arguments,function*({field:t,from:r,filter:s,haveHistory:i}){try{const o=r[t];return U.isObject(o)?{success:!0,result:Object.fromEntries(yield Promise.all(Object.entries(o).map(u=>v(this,[u],function*([p,y]){const S=yield this.createUniqueSlug({slug:y,field:p,isObject:!0,haveHistory:i,filter:s});return[p,S]}))))}:{success:!0,result:yield this.createUniqueSlug({slug:o,field:t,isObject:!1,haveHistory:i,filter:s})}}catch(o){return N.catchError(o)}})}checkSlug(e){return v(this,arguments,function*({slug:t,field:r,from:s,filter:i,haveHistory:o}){try{const l=s[r];if(U.isObject(l)){const y=Object.values(l).map(E=>C.generateSlug(E));return(yield Promise.all(y.map(E=>this.model.exists(this.createSlugQuery({slug:E,field:r,isObject:!0,haveHistory:o,filter:i}))))).some(E=>E)?{success:!0,result:!0}:{success:!0,result:!1}}const a=C.generateSlug(t);return{success:!0,result:(yield this.model.exists(this.createSlugQuery({slug:a,field:r,isObject:!1,filter:i})))!==null}}catch(l){return N.catchError(l)}})}aggregate(e){return v(this,null,function*(){try{return{success:!0,result:yield this.model.aggregate(e)}}catch(t){return N.catchError(t)}})}distinct(e){return v(this,arguments,function*(t,r={},s={}){try{return{success:!0,result:yield this.model.distinct(t,r,s)}}catch(i){return N.catchError(i)}})}}exports.MongoController=ht;exports.MongooseController=pt;exports.mongo=P;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("migrate-mongo"),U=require("mongoose-aggregate-paginate-v2"),k=require("mongoose-paginate-v2"),$=require("node:crypto"),F=require("../../util/object/object.util.cjs"),B=require("../../util/common/common.util.cjs"),E=require("../fs/fs.util.cjs"),w=require("../path/path.constant.cjs"),H=require("../../util/validate/validate.util.cjs");var J=Object.defineProperty,K=Object.defineProperties,L=Object.getOwnPropertyDescriptors,q=Object.getOwnPropertySymbols,M=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,D=(t,i,e)=>i in t?J(t,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[i]=e,Q=(t,i)=>{for(var e in i||(i={}))M.call(i,e)&&D(t,e,i[e]);if(q)for(var e of q(i))z.call(i,e)&&D(t,e,i[e]);return t},W=(t,i)=>K(t,L(i)),R=(t,i,e)=>new Promise((o,r)=>{var n=s=>{try{y(e.next(s))}catch(h){r(h)}},l=s=>{try{y(e.throw(s))}catch(h){r(h)}},y=s=>s.done?o(s.value):Promise.resolve(s.value).then(n,l);y((e=e.apply(t,i)).next())});function P(t){return t===t.toUpperCase()?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():t}const I={createGenericFields(){return{id:$.randomUUID(),isDel:!1,createdAt:new Date,updatedAt:new Date}},applyPlugins(t,i){i.filter(e=>typeof e=="function").forEach(e=>t.plugin(e))},applyMiddlewares(t,i){i.forEach(({method:e,pre:o,post:r})=>{e&&o&&t.pre(e,o),e&&r&&t.post(e,r)})},createGenericSchema(t){return new t.Schema({id:{type:String,default:()=>$.randomUUID(),unique:!0},isDel:{type:Boolean,default:!1}},{timestamps:!0})},createSchema({mongoose:t,schema:i,virtuals:e=[],standalone:o=!1}){const r=new t.Schema(i,{toJSON:{virtuals:!0},toObject:{virtuals:!0}});return e.forEach(({name:n,options:l,get:y})=>{if(I.isDynamicVirtual(l)){const s=r.statics;s._dynamicVirtuals||(s._dynamicVirtuals=[]),s._dynamicVirtuals.push({name:n,options:l});const h=r.virtual(n);y?h.get(y):h.get(function(){var u;return((u=this._populated)==null?void 0:u[n])||(l!=null&&l.count?0:l!=null&&l.justOne?null:[])})}else{const s=r.virtual(n,l);y&&s.get(y)}}),o||r.add(I.createGenericSchema(t)),r},createModel({mongoose:t,name:i,schema:e,virtuals:o=[],pagination:r=!0,aggregate:n=!0,middlewares:l=[]}){if(!i)throw new Error("Model name is required.");if(t.models[i])return t.models[i];const y=I.createSchema({mongoose:t,schema:e,virtuals:o});(r||n)&&I.applyPlugins(y,[r&&k,n&&U]),I.applyMiddlewares(y,l);const s=t.model(i,y);return o.length>0&&(s._virtualConfigs=o),s},validator:{isRequired(){return function(t){return R(this,null,function*(){return!H.validate.isEmpty(t)})}},isUnique(t){return function(i){return R(this,null,function*(){if(!Array.isArray(t)||t.length===0)throw new Error("Fields must be a non-empty array of strings.");const e={$or:t.map(r=>({[r]:i}))};return!(yield this.constructor.exists(e))})}},matchesRegex(t){return i=>R(null,null,function*(){if(!Array.isArray(t)||t.some(e=>!(e instanceof RegExp)))throw new Error("regexArray must be an array of valid RegExp objects.");return t.every(e=>e.test(i))})}},migrate:W(Q({},T),{setConfig:t=>{const i=`// This file is automatically generated by the Cyberskill CLI.
|
|
2
|
+
module.exports = ${JSON.stringify(t,null,4)}`;E.writeFileSync(w.PATH.MIGRATE_MONGO_CONFIG,i);const e=`
|
|
3
|
+
${w.MIGRATE_MONGO_CONFIG}
|
|
4
|
+
`;E.pathExistsSync(w.PATH.GIT_IGNORE)?E.readFileSync(w.PATH.GIT_IGNORE,"utf-8").split(`
|
|
5
|
+
`).includes(w.MIGRATE_MONGO_CONFIG)||E.appendFileSync(w.PATH.GIT_IGNORE,e):E.writeFileSync(w.PATH.GIT_IGNORE,e)}}),regexify(t,i){if(!t)return{};let e=F.deepClone(t);if(!i||i.length===0)return e;for(const o of i){const r=o.toString().split("."),n=F.getNestedValue(e,r);if(typeof n=="string"&&n.length>0){const l={$regex:`.*${B.regexSearchMapper(n)}.*`,$options:"i"};e=F.setNestedValue(e,r,l)}}return e},isDynamicVirtual(t){return!!(t&&typeof t.ref=="function")},getNewRecords(t,i,e){return R(this,null,function*(){const o=yield t.findAll({});return o.success?i.filter(n=>!o.result.some(l=>e(l,n))):i})},getExistingRecords(t,i,e){return R(this,null,function*(){const o=yield t.findAll({});return o.success?o.result.filter(n=>i.some(l=>e(n,l))):[]})}};function x(t,i,e,o,r){return R(this,null,function*(){if(!i.length||!e)return i;const n=Array.isArray(e)?e:[e];for(const l of n)typeof l=="string"?yield C(t,i,l,o,r):l&&typeof l=="object"&&(yield X(t,i,l,o,r));return i})}function C(t,i,e,o,r){return R(this,null,function*(){var n,l,y,s;const h=e.split(".");if(h.length<2){for(const m of i)yield V(t,m,e,o,void 0,r);return}const u=h[0];if(!u||u.trim()==="")return;const S=h.slice(1).join(".");for(const m of i){const N=m,O=N[u];if(O&&typeof O=="object"){let c=r;const a=c;if(r&&r.schema&&r.schema.virtuals){const f=r.schema.virtuals[u];if(f&&f.options&&f.options.ref){let g;if(typeof f.options.ref=="function"?g=f.options.ref(N):typeof f.options.ref=="string"&&(g=f.options.ref),g){const p=P(g);t.models[p]&&(c=t.models[p])}}}if(!c){const f=(l=(n=r==null?void 0:r.schema)==null?void 0:n.statics)!=null?l:{},p=((r==null?void 0:r._virtualConfigs)||f._dynamicVirtuals||[]).find(d=>d.name===u);if(p&&p.options&&p.options.ref){let d;if(typeof p.options.ref=="function"?d=p.options.ref(N):typeof p.options.ref=="string"&&(d=p.options.ref),d){const b=P(d);t.models[b]&&(c=t.models[b])}}}if(c===a){const f=(s=(y=r==null?void 0:r.schema)==null?void 0:y.statics)!=null?s:{},p=((r==null?void 0:r._virtualConfigs)||f._dynamicVirtuals||[]).find(d=>d.name===u);if(p&&p.options&&p.options.ref){let d;if(typeof p.options.ref=="function"?d=p.options.ref(N):typeof p.options.ref=="string"&&(d=p.options.ref),d){const b=P(d);t.models[b]&&(c=t.models[b])}}}if(Array.isArray(O))for(const f of O)f&&typeof f=="object"&&(yield V(t,f,S,o,u,c));else O&&typeof O=="object"&&(yield V(t,O,S,o,u,c))}}})}function X(t,i,e,o,r){return R(this,null,function*(){const{path:n,populate:l}=e;if(!n)return;if(!l){yield C(t,i,n,o,r);return}const y=n;for(const s of i){const h=s,u=h[y];let S=r;if(r&&r.schema&&r.schema.virtuals){const m=r.schema.virtuals[y];if(m&&m.options&&m.options.ref){let N;if(typeof m.options.ref=="function"?N=m.options.ref(h):typeof m.options.ref=="string"&&(N=m.options.ref),N){const O=P(N);t.models[O]&&(S=t.models[O])}}}if(!S&&typeof u=="object"&&u&&"entityType"in u){const m=P(String(u.entityType));t.models[m]&&(S=t.models[m])}if(u&&typeof u=="object")if(Array.isArray(u))for(const m of u)m&&typeof m=="object"&&(yield x(t,[m],l,o,S));else u&&typeof u=="object"&&(yield x(t,[u],l,o,S))}})}function G(t,i,e,o){if(!e||!i||!i.schema)return;const r=e.split(".");let n=i.schema;for(let l=0;l<r.length;l++){const y=r[l];if(n&&n.virtuals&&y){const s=n.virtuals[y];if(s&&s.options&&s.options.ref){let h;if(typeof s.options.ref=="function"?h=s.options.ref(o):typeof s.options.ref=="string"&&(h=s.options.ref),h&&typeof h=="string"){if(l===r.length-1)return h;const u=t.models[h];if(u&&u.schema){n=u.schema;continue}}}}if(n&&n.paths&&y){const s=n.paths[y];if(s&&s.schema){n=s.schema;continue}}return}}function Y(t,i){if(i)for(const e of Object.keys(t.models)){const o=t.models[e],r=o==null?void 0:o.schema;if(r&&(r.paths&&r.paths[i]||r.virtuals&&r.virtuals[i]))return o}}function Z(t,i){const e=(i||"").split(".")[0]||"";if(e)for(const o of Object.keys(t.models)){const r=t.models[o],n=r==null?void 0:r.schema;if(n&&(n.paths&&n.paths[e]||n.virtuals&&n.virtuals[e]))return r}}function V(t,i,e,o,r,n){return R(this,null,function*(){var l,y;let s=i.__t;if(!s){if(n){const c=r?`${r}.${e}`:e,a=(c||"").split(".")[0]||"";let f=n;if(!!!((l=f==null?void 0:f.schema)!=null&&l.paths&&f.schema.paths[a]||(y=f==null?void 0:f.schema)!=null&&y.virtuals&&f.schema.virtuals[a])){const d=Z(t,c);d&&(f=d)}const p=G(t,f,c,i);if(p)s=p;else{const d=(c.includes(".")?c.split(".").pop():c)||"";if(d){const b=Y(t,d);if(b){const j=G(t,b,c,i);j&&(s=j)}}}}if(o&&o.length>0){const c=e.split(".").pop()||"",a=o.find(f=>f.name===c);if(a&&a.options.ref){let f;typeof a.options.ref=="function"?f=a.options.ref(i):typeof a.options.ref=="string"&&(f=a.options.ref),f&&typeof f=="string"&&(s=f)}}if(!s){for(const[c,a]of Object.entries(i))if(c==="entityType"&&typeof a=="string"){s=a;break}if(s&&t.models[s]){const c=t.models[s];if(c&&c.schema){const a=c.schema,f=e.split(".").pop()||"",g=(d,b="root")=>{if(!d||!d.virtuals)return;const j=d.virtuals;for(const _ of Object.keys(j))if(_===f){const v=j[_];if(v&&v.options&&v.options.ref){let A;if(typeof v.options.ref=="function"?A=v.options.ref(i):typeof v.options.ref=="string"&&(A=v.options.ref),A&&typeof A=="string")return A}}if(d.paths)for(const _ of Object.keys(d.paths)){const v=d.paths[_];if(v&&v.schema){const A=g(v.schema,`${b}.${_}`);if(A)return A}}},p=g(a);p&&(s=p)}}}if(!s){const c=e.split(".").pop()||"";if(n&&n.schema){const a=n.schema,f=(p,d="root")=>{if(!p||!p.virtuals)return;const b=p.virtuals;for(const j of Object.keys(b))if(j===c){const _=b[j];if(_&&_.options&&_.options.ref){let v;if(typeof _.options.ref=="function"?v=_.options.ref(i):typeof _.options.ref=="string"&&(v=_.options.ref),v&&typeof v=="string")return v}}if(p.paths)for(const j of Object.keys(p.paths)){const _=p.paths[j];if(_&&_.schema){const v=f(_.schema,`${d}.${j}`);if(v)return v}}},g=f(a);g&&(s=g)}if(!s&&n){const a=G(t,n,e,i);a&&(s=a)}if(!s&&o&&o.length>0){const a=o.find(f=>f.name===c);if(a&&a.options.ref){let f;typeof a.options.ref=="function"?f=a.options.ref(i):typeof a.options.ref=="string"&&(f=a.options.ref),f&&typeof f=="string"&&(s=f)}}}if(!s){const c=e.split(".").pop()||"",a=c?c.charAt(0).toUpperCase()+c.slice(1):"";a&&t.models[a]&&(s=a)}}const h=t.models[s];if(!h)return;const u=`${e}Id`,S=`${e}Ids`,m=i[u]||i[S]||i[e];if(!m)return;const N=Array.isArray(m)?m:[m],O=yield h.find({id:{$in:N}}).lean();O.length>0&&(Array.isArray(m)?i[e]=O:i[e]=O[0])})}exports.applyNestedPopulate=x;exports.convertEnumToModelName=P;exports.mongo=I;
|