@cyberskill/shared 2.20.0 → 2.21.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/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/node/mongo/mongo-controller.test.unit.d.ts +1 -0
- package/dist/node/mongo/mongo.test.unit.d.ts +1 -0
- package/dist/node/mongo/mongo.util.cjs +2 -2
- package/dist/node/mongo/mongo.util.d.ts +9 -203
- package/dist/node/mongo/mongo.util.js +70 -68
- package/dist/node/path/path.constant.cjs +1 -1
- package/dist/node/path/path.constant.js +113 -109
- 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.js +14 -15
- 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 +102 -69
- 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 +37 -45
- /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.3.0_sass@1.97.0_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.3.0_sass@1.97.0_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../util/object/object.util.cjs");function e(o){const t={stories:["../src/**/*.stories.@(js|jsx|mjs|ts|tsx|mdx)"],addons:["@storybook/addon-essentials","@storybook/addon-interactions","@storybook/addon-links"],framework:{name:"@storybook/react-vite",options:{}}};return s.deepMerge(t,o)}exports.storybookMain=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("../../node_modules/.pnpm/vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.3.0_sass@1.97.0_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.cjs"),o=require("../../util/object/object.util.cjs");function n(e){const r={plugins:[t()],test:{include:["**/*.test.e2e.?(c|m)[jt]s?(x)"],browser:{enabled:!0,provider:"playwright",instances:[{browser:"chromium"},{browser:"firefox"},{browser:"webkit"}]}}};return i.defineConfig(o.deepMerge(r,e))}exports.vitestE2E=n;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import t from "@vitejs/plugin-react-swc";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
function
|
|
5
|
-
const
|
|
2
|
+
import { defineConfig as o } from "../../node_modules/.pnpm/vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.3.0_sass@1.97.0_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js";
|
|
3
|
+
import { deepMerge as i } from "../../util/object/object.util.js";
|
|
4
|
+
function m(e) {
|
|
5
|
+
const r = {
|
|
6
6
|
plugins: [t()],
|
|
7
7
|
test: {
|
|
8
8
|
include: ["**/*.test.e2e.?(c|m)[jt]s?(x)"],
|
|
@@ -17,8 +17,8 @@ function f(r) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
return i(
|
|
20
|
+
return o(i(r, e));
|
|
21
21
|
}
|
|
22
22
|
export {
|
|
23
|
-
|
|
23
|
+
m as vitestE2E
|
|
24
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vitejs/plugin-react-swc"),n=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vitejs/plugin-react-swc"),n=require("../../node_modules/.pnpm/vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.3.0_sass@1.97.0_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.cjs"),s=require("../../util/object/object.util.cjs");function r(e){const t={plugins:[i()],test:{globals:!0,environment:"jsdom",pool:"vmThreads",include:["**/*.test.unit.?(c|m)[jt]s?(x)"],setupFiles:["./vitest.unit.setup.ts"]}};return n.defineConfig(s.deepMerge(t,e))}exports.vitestUnit=r;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import i from "@vitejs/plugin-react-swc";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
function
|
|
2
|
+
import { defineConfig as o } from "../../node_modules/.pnpm/vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.3.0_sass@1.97.0_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js";
|
|
3
|
+
import { deepMerge as n } from "../../util/object/object.util.js";
|
|
4
|
+
function p(t) {
|
|
5
5
|
const e = {
|
|
6
6
|
plugins: [i()],
|
|
7
7
|
test: {
|
|
@@ -12,8 +12,8 @@ function u(t) {
|
|
|
12
12
|
setupFiles: ["./vitest.unit.setup.ts"]
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
return n(
|
|
15
|
+
return o(n(e, t));
|
|
16
16
|
}
|
|
17
17
|
export {
|
|
18
|
-
|
|
18
|
+
p as vitestUnit
|
|
19
19
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("node:crypto"),J=require("migrate-mongo"),X=require("mongoose-aggregate-paginate-v2"),Y=require("mongoose-paginate-v2"),Z=require("./mongo.constant.cjs"),V=require("../../util/object/object.util.cjs"),tt=require("../../util/common/common.util.cjs"),$=require("../fs/fs.util.cjs"),T=require("../path/path.constant.cjs"),et=require("../../util/validate/validate.util.cjs"),C=require("../../util/string/string.util.cjs"),F=require("../../constant/response-status.cjs"),N=require("../log/log.util.cjs");var rt=Object.defineProperty,st=Object.defineProperties,nt=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,z=(n,e,t)=>e in n?rt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,A=(n,e)=>{for(var t in e||(e={}))it.call(e,t)&&z(n,t,e[t]);if(k)for(var t of k(e))ot.call(e,t)&&z(n,t,e[t]);return n},x=(n,e)=>st(n,nt(e)),lt=(n,e,t)=>z(n,typeof e!="symbol"?e+"":e,t),v=(n,e,t)=>new Promise((r,s)=>{var i=c=>{try{l(t.next(c))}catch(a){s(a)}},o=c=>{try{l(t.throw(c))}catch(a){s(a)}},l=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,o);l((t=t.apply(n,e)).next())});function B(n){return n!=null&&typeof n=="object"}function M(n){return n===n.toUpperCase()?n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():n}const P={createGenericFields(){return{id:W.randomUUID(),isDel:!1,createdAt:new Date,updatedAt:new Date}},applyPlugins(n,e){e.filter(t=>typeof t=="function").forEach(t=>n.plugin(t))},applyMiddlewares(n,e){e.forEach(({method:t,pre:r,post:s})=>{t&&r&&n.pre(t,r),t&&s&&n.post(t,s)})},createGenericSchema(n){return new n.Schema({id:{type:String,default:()=>W.randomUUID(),unique:!0},isDel:{type:Boolean,default:!1}},{timestamps:!0})},createSchema({mongoose:n,schema:e,virtuals:t=[],standalone:r=!1}){const s=new n.Schema(e,{toJSON:{virtuals:!0},toObject:{virtuals:!0}});return t.forEach(({name:i,options:o,get:l})=>{if(P.isDynamicVirtual(o)){const c=s.statics;c._dynamicVirtuals||(c._dynamicVirtuals=[]),c._dynamicVirtuals.push({name:i,options:o});const a=s.virtual(i);l?a.get(l):a.get(function(){var u;return((u=this._populated)==null?void 0:u[i])||(o!=null&&o.count?0:o!=null&&o.justOne?null:[])})}else{const c=s.virtual(i,o);l&&c.get(l)}}),r||s.add(P.createGenericSchema(n)),s},createModel({mongoose:n,name:e,schema:t,virtuals:r=[],pagination:s=!0,aggregate:i=!0,middlewares:o=[]}){if(!e)throw new Error("Model name is required.");if(n.models[e])return n.models[e];const l=P.createSchema({mongoose:n,schema:t,virtuals:r});(s||i)&&P.applyPlugins(l,[s&&Y,i&&X]),P.applyMiddlewares(l,o);const c=n.model(e,l);return r.length>0&&(c._virtualConfigs=r),c},validator:{isRequired(){return function(n){return v(this,null,function*(){return!et.validate.isEmpty(n)})}},isUnique(n){return function(e){return v(this,null,function*(){if(!Array.isArray(n)||n.length===0)throw new Error("Fields must be a non-empty array of strings.");const t={$or:n.map(s=>({[s]:e}))};return!(yield this.constructor.exists(t))})}},matchesRegex(n){return e=>v(null,null,function*(){if(!Array.isArray(n)||n.some(t=>!(t instanceof RegExp)))throw new Error("regexArray must be an array of valid RegExp objects.");return n.every(t=>t.test(e))})}},migrate:x(A({},J),{setConfig:n=>{const e=`// This file is automatically generated by the Cyberskill CLI.
|
|
2
2
|
module.exports = ${JSON.stringify(n,null,4)}`;$.writeFileSync(T.PATH.MIGRATE_MONGO_CONFIG,e);const t=`
|
|
3
3
|
${T.MIGRATE_MONGO_CONFIG}
|
|
4
4
|
`;$.pathExistsSync(T.PATH.GIT_IGNORE)?$.readFileSync(T.PATH.GIT_IGNORE,"utf-8").split(`
|
|
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;
|
|
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=V.deepClone(n);if(!e||e.length===0)return t;for(const r of e){const s=r.toString().split("."),i=V.getNestedValue(t,s);if(typeof i=="string"&&i.length>0){const o={$regex:`.*${tt.regexSearchMapper(i)}.*`,$options:"i"};t=V.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 U(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 L(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 G(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 O=y,E=O[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 S;if(typeof f.options.ref=="function"?S=f.options.ref(O):typeof f.options.ref=="string"&&(S=f.options.ref),S){const d=M(S);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(O):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(O):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 G(n,f,p,r,u,g));else E&&typeof E=="object"&&(yield G(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 O;if(typeof y.options.ref=="function"?O=y.options.ref(a):typeof y.options.ref=="string"&&(O=y.options.ref),O){const E=M(O);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 L(n,[y],o,r,p));else u&&typeof u=="object"&&(yield L(n,[u],o,r,p))}})}function q(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 G(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=q(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=q(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()||"",S=(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=S(b.schema,`${j}.${_}`);if(D)return D}}},d=S(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}}},S=f(h);S&&(c=S)}if(!c&&i){const h=q(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 O=Array.isArray(y)?y:[y],E=yield a.find({id:{$in:O}}).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=V.deepClone(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 O of y){c.has(O.model)||c.set(O.model,{virtuals:[],localValueSets:new Map,docsByLocalValue:new Map});const E=c.get(O.model);E.virtuals.find(h=>h.name===u)||(E.virtuals.push(a),E.localValueSets.set(u,new Set));const g=E.localValueSets.get(u);O.docs.forEach(h=>{const f=h[p.localField];if(f!=null){const S=String(f);g.add(S);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(S)||E.docsByLocalValue.set(S,[]),E.docsByLocalValue.get(S).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 O=new Set;if(p.localValueSets.forEach(S=>{S.forEach(d=>O.add(d))}),O.size===0)return;const E=[...new Set(p.virtuals.map(S=>S.options.foreignField))],g=Array.from(O);let h;E.length===1?h={[String(E[0])]:{$in:g}}:h={$or:E.map(S=>({[S]:{$in:g}}))};const f=yield y.find(h,s).lean();for(const S of p.virtuals){const{name:d,options:m}=S,j=f.filter(R=>{const _=R[m.foreignField];return _!=null&&O.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],O=new Map,E=[];for(const h of y)if(typeof h=="string")if(h.includes(".")){const f=h.split("."),S=f[0]||"",d=f.slice(1).join(".");S&&(O.has(S)||O.set(S,[]),d&&O.get(S).push(d))}else E.push(h);else if(h&&typeof h=="object"){const f=h;if(f.path&&f.path.includes(".")){const S=f.path.split("."),d=S[0]||"",m=S.slice(1).join(".");d&&(O.has(d)||O.set(d,[]),m&&O.get(d).push(m),f.populate&&O.get(d).push(f.populate))}else E.push(h)}const g=[...E];return O.forEach((h,f)=>{const S=[];for(const d of h)(typeof d=="string"||d&&typeof d=="object")&&S.push(d);S.length>0?g.push({path:f,populate:S}):g.push(f)}),g})(r);yield L(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:F.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:F.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:F.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:F.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:F.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:F.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:F.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=V.normalizeMongoFilter(e),c=this.model.findOne(l,t,r),a=this.getDynamicVirtuals(),u=U(s,a);u&&c.populate(u);const p=yield c.exec();if(!p)return{success:!1,message:`No ${this.getModelName()} found.`,code:F.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=V.normalizeMongoFilter(e),o=this.model.find(i,t,r),l=this.getDynamicVirtuals(),c=U(s,l);c&&o.populate(c);const a=yield o.exec();return{success:!0,result:(yield this.populateDynamicVirtualsForDocuments(a,s)).map(p=>{var y,O;return(O=(y=p==null?void 0:p.toObject)==null?void 0:y.call(p))!=null?O:p})}}catch(i){return N.catchError(i)}})}findPaging(){return v(this,arguments,function*(e={},t={}){try{const r=V.normalizeMongoFilter(e),s=this.getDynamicVirtuals(),i=A({},t);t.populate&&(i.populate=U(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=U(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=V.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=V.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:F.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(o){return N.catchError(o)}})}updateMany(){return v(this,arguments,function*(e={},t={},r={}){try{const s=V.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=V.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:F.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(i){return N.catchError(i)}})}deleteMany(){return v(this,arguments,function*(e={},t={}){try{const r=V.normalizeMongoFilter(e),s=yield this.model.deleteMany(r,t).exec();return s.deletedCount===0?{success:!1,message:"No documents found to delete.",code:F.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:F.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 B(o)?{success:!0,result:Object.fromEntries(yield Promise.all(Object.entries(o).map(u=>v(this,[u],function*([p,y]){const O=yield this.createUniqueSlug({slug:y,field:p,isObject:!0,haveHistory:i,filter:s});return[p,O]}))))}:{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(B(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;
|
|
@@ -157,7 +157,7 @@ export declare const mongo: {
|
|
|
157
157
|
}> & {
|
|
158
158
|
__v: number;
|
|
159
159
|
}> | undefined;
|
|
160
|
-
$op?: mongooseRaw.SchemaDefinitionProperty<"
|
|
160
|
+
$op?: mongooseRaw.SchemaDefinitionProperty<"save" | "validate" | "remove" | null | undefined, I_GenericDocument, mongooseRaw.Document<unknown, {}, I_GenericDocument, {}, mongooseRaw.ResolveSchemaOptions<mongooseRaw.DefaultSchemaOptions>> & I_GenericDocument & Required<{
|
|
161
161
|
_id: mongooseRaw.Types.ObjectId;
|
|
162
162
|
}> & {
|
|
163
163
|
__v: number;
|
|
@@ -406,7 +406,11 @@ export declare const mongo: {
|
|
|
406
406
|
}, "id"> & {
|
|
407
407
|
id: string;
|
|
408
408
|
}> | undefined;
|
|
409
|
-
}, {
|
|
409
|
+
}, {
|
|
410
|
+
[x: number]: {};
|
|
411
|
+
[x: symbol]: {};
|
|
412
|
+
[x: string]: {};
|
|
413
|
+
} & Required<{
|
|
410
414
|
_id: unknown;
|
|
411
415
|
}> & {
|
|
412
416
|
__v: number;
|
|
@@ -1248,7 +1252,7 @@ export declare class MongooseController<T extends Partial<C_Document>> {
|
|
|
1248
1252
|
* @param options.filter - Additional filter conditions to apply to the query.
|
|
1249
1253
|
* @returns A MongoDB query object for checking slug existence.
|
|
1250
1254
|
*/
|
|
1251
|
-
createSlugQuery({ slug, field, isObject, haveHistory, filter }: I_Input_GenerateSlug<T>): {
|
|
1255
|
+
createSlugQuery({ slug, field, isObject, haveHistory, filter }: I_Input_GenerateSlug<T>): (mongooseRaw.QueryFilter<T> & {
|
|
1252
1256
|
$or: ({
|
|
1253
1257
|
[x: string]: string;
|
|
1254
1258
|
slugHistory?: undefined;
|
|
@@ -1259,106 +1263,7 @@ export declare class MongooseController<T extends Partial<C_Document>> {
|
|
|
1259
1263
|
};
|
|
1260
1264
|
};
|
|
1261
1265
|
})[];
|
|
1262
|
-
|
|
1263
|
-
exec?: any;
|
|
1264
|
-
$where?: string | (mongooseRaw.mongo.Condition<mongooseRaw.ApplyBasicQueryCasting<mongooseRaw.WithLevel1NestedPaths<T, keyof T>["$where"]>> & (string | ((this: mongooseRaw.WithLevel1NestedPaths<T, keyof T> extends infer T_1 ? { [P in keyof T_1]?: mongooseRaw.ApplyBasicQueryCasting<T_1[P]> | undefined; } : never) => boolean))) | ((argument: string | Function) => mongooseRaw.Query<any[], any, {}, unknown, "find", Record<string, never>>) | ((this: {
|
|
1265
|
-
[x: string]: any;
|
|
1266
|
-
}) => boolean) | undefined;
|
|
1267
|
-
all?: any;
|
|
1268
|
-
allowDiskUse?: any;
|
|
1269
|
-
and?: any;
|
|
1270
|
-
batchSize?: any;
|
|
1271
|
-
box?: any;
|
|
1272
|
-
cast?: any;
|
|
1273
|
-
catch?: any;
|
|
1274
|
-
finally?: any;
|
|
1275
|
-
circle?: any;
|
|
1276
|
-
clone?: any;
|
|
1277
|
-
collation?: any;
|
|
1278
|
-
comment?: any;
|
|
1279
|
-
countDocuments?: any;
|
|
1280
|
-
cursor?: any;
|
|
1281
|
-
deleteMany?: any;
|
|
1282
|
-
deleteOne?: any;
|
|
1283
|
-
distinct?: any;
|
|
1284
|
-
elemMatch?: any;
|
|
1285
|
-
error?: any;
|
|
1286
|
-
equals?: any;
|
|
1287
|
-
estimatedDocumentCount?: any;
|
|
1288
|
-
exists?: any;
|
|
1289
|
-
explain?: any;
|
|
1290
|
-
find?: any;
|
|
1291
|
-
findOne?: any;
|
|
1292
|
-
findOneAndDelete?: any;
|
|
1293
|
-
findOneAndUpdate?: any;
|
|
1294
|
-
findById?: any;
|
|
1295
|
-
findByIdAndDelete?: any;
|
|
1296
|
-
findByIdAndUpdate?: any;
|
|
1297
|
-
geometry?: any;
|
|
1298
|
-
get?: any;
|
|
1299
|
-
getFilter?: any;
|
|
1300
|
-
getOptions?: any;
|
|
1301
|
-
getPopulatedPaths?: any;
|
|
1302
|
-
getQuery?: any;
|
|
1303
|
-
getUpdate?: any;
|
|
1304
|
-
gt?: any;
|
|
1305
|
-
gte?: any;
|
|
1306
|
-
hint?: any;
|
|
1307
|
-
in?: any;
|
|
1308
|
-
intersects?: any;
|
|
1309
|
-
j?: any;
|
|
1310
|
-
lean?: any;
|
|
1311
|
-
limit?: any;
|
|
1312
|
-
lt?: any;
|
|
1313
|
-
lte?: any;
|
|
1314
|
-
transform?: any;
|
|
1315
|
-
maxDistance?: any;
|
|
1316
|
-
maxTimeMS?: any;
|
|
1317
|
-
merge?: any;
|
|
1318
|
-
mod?: any;
|
|
1319
|
-
model?: any;
|
|
1320
|
-
mongooseOptions?: any;
|
|
1321
|
-
ne?: any;
|
|
1322
|
-
near?: any;
|
|
1323
|
-
nin?: any;
|
|
1324
|
-
nor?: any;
|
|
1325
|
-
or?: any;
|
|
1326
|
-
orFail?: any;
|
|
1327
|
-
polygon?: any;
|
|
1328
|
-
populate?: any;
|
|
1329
|
-
pre?: any;
|
|
1330
|
-
post?: any;
|
|
1331
|
-
projection?: any;
|
|
1332
|
-
read?: any;
|
|
1333
|
-
readConcern?: any;
|
|
1334
|
-
regex?: any;
|
|
1335
|
-
replaceOne?: any;
|
|
1336
|
-
sanitizeProjection?: any;
|
|
1337
|
-
schemaLevelProjections?: any;
|
|
1338
|
-
select?: any;
|
|
1339
|
-
selected?: any;
|
|
1340
|
-
selectedExclusively?: any;
|
|
1341
|
-
selectedInclusively?: any;
|
|
1342
|
-
session?: any;
|
|
1343
|
-
set?: any;
|
|
1344
|
-
setOptions?: any;
|
|
1345
|
-
setQuery?: any;
|
|
1346
|
-
setUpdate?: any;
|
|
1347
|
-
size?: any;
|
|
1348
|
-
skip?: any;
|
|
1349
|
-
slice?: any;
|
|
1350
|
-
sort?: any;
|
|
1351
|
-
tailable?: any;
|
|
1352
|
-
then?: any;
|
|
1353
|
-
toConstructor?: any;
|
|
1354
|
-
updateMany?: any;
|
|
1355
|
-
updateOne?: any;
|
|
1356
|
-
w?: any;
|
|
1357
|
-
where?: any;
|
|
1358
|
-
within?: any;
|
|
1359
|
-
wtimeout?: any;
|
|
1360
|
-
paginate?: any;
|
|
1361
|
-
} | {
|
|
1266
|
+
}) | (mongooseRaw.QueryFilter<T> & {
|
|
1362
1267
|
$or: ({
|
|
1363
1268
|
slug: string;
|
|
1364
1269
|
slugHistory?: undefined;
|
|
@@ -1366,106 +1271,7 @@ export declare class MongooseController<T extends Partial<C_Document>> {
|
|
|
1366
1271
|
slugHistory: string;
|
|
1367
1272
|
slug?: undefined;
|
|
1368
1273
|
})[];
|
|
1369
|
-
|
|
1370
|
-
exec?: any;
|
|
1371
|
-
$where?: string | (mongooseRaw.mongo.Condition<mongooseRaw.ApplyBasicQueryCasting<mongooseRaw.WithLevel1NestedPaths<T, keyof T>["$where"]>> & (string | ((this: mongooseRaw.WithLevel1NestedPaths<T, keyof T> extends infer T_1 ? { [P in keyof T_1]?: mongooseRaw.ApplyBasicQueryCasting<T_1[P]> | undefined; } : never) => boolean))) | ((argument: string | Function) => mongooseRaw.Query<any[], any, {}, unknown, "find", Record<string, never>>) | ((this: {
|
|
1372
|
-
[x: string]: any;
|
|
1373
|
-
}) => boolean) | undefined;
|
|
1374
|
-
all?: any;
|
|
1375
|
-
allowDiskUse?: any;
|
|
1376
|
-
and?: any;
|
|
1377
|
-
batchSize?: any;
|
|
1378
|
-
box?: any;
|
|
1379
|
-
cast?: any;
|
|
1380
|
-
catch?: any;
|
|
1381
|
-
finally?: any;
|
|
1382
|
-
circle?: any;
|
|
1383
|
-
clone?: any;
|
|
1384
|
-
collation?: any;
|
|
1385
|
-
comment?: any;
|
|
1386
|
-
countDocuments?: any;
|
|
1387
|
-
cursor?: any;
|
|
1388
|
-
deleteMany?: any;
|
|
1389
|
-
deleteOne?: any;
|
|
1390
|
-
distinct?: any;
|
|
1391
|
-
elemMatch?: any;
|
|
1392
|
-
error?: any;
|
|
1393
|
-
equals?: any;
|
|
1394
|
-
estimatedDocumentCount?: any;
|
|
1395
|
-
exists?: any;
|
|
1396
|
-
explain?: any;
|
|
1397
|
-
find?: any;
|
|
1398
|
-
findOne?: any;
|
|
1399
|
-
findOneAndDelete?: any;
|
|
1400
|
-
findOneAndUpdate?: any;
|
|
1401
|
-
findById?: any;
|
|
1402
|
-
findByIdAndDelete?: any;
|
|
1403
|
-
findByIdAndUpdate?: any;
|
|
1404
|
-
geometry?: any;
|
|
1405
|
-
get?: any;
|
|
1406
|
-
getFilter?: any;
|
|
1407
|
-
getOptions?: any;
|
|
1408
|
-
getPopulatedPaths?: any;
|
|
1409
|
-
getQuery?: any;
|
|
1410
|
-
getUpdate?: any;
|
|
1411
|
-
gt?: any;
|
|
1412
|
-
gte?: any;
|
|
1413
|
-
hint?: any;
|
|
1414
|
-
in?: any;
|
|
1415
|
-
intersects?: any;
|
|
1416
|
-
j?: any;
|
|
1417
|
-
lean?: any;
|
|
1418
|
-
limit?: any;
|
|
1419
|
-
lt?: any;
|
|
1420
|
-
lte?: any;
|
|
1421
|
-
transform?: any;
|
|
1422
|
-
maxDistance?: any;
|
|
1423
|
-
maxTimeMS?: any;
|
|
1424
|
-
merge?: any;
|
|
1425
|
-
mod?: any;
|
|
1426
|
-
model?: any;
|
|
1427
|
-
mongooseOptions?: any;
|
|
1428
|
-
ne?: any;
|
|
1429
|
-
near?: any;
|
|
1430
|
-
nin?: any;
|
|
1431
|
-
nor?: any;
|
|
1432
|
-
or?: any;
|
|
1433
|
-
orFail?: any;
|
|
1434
|
-
polygon?: any;
|
|
1435
|
-
populate?: any;
|
|
1436
|
-
pre?: any;
|
|
1437
|
-
post?: any;
|
|
1438
|
-
projection?: any;
|
|
1439
|
-
read?: any;
|
|
1440
|
-
readConcern?: any;
|
|
1441
|
-
regex?: any;
|
|
1442
|
-
replaceOne?: any;
|
|
1443
|
-
sanitizeProjection?: any;
|
|
1444
|
-
schemaLevelProjections?: any;
|
|
1445
|
-
select?: any;
|
|
1446
|
-
selected?: any;
|
|
1447
|
-
selectedExclusively?: any;
|
|
1448
|
-
selectedInclusively?: any;
|
|
1449
|
-
session?: any;
|
|
1450
|
-
set?: any;
|
|
1451
|
-
setOptions?: any;
|
|
1452
|
-
setQuery?: any;
|
|
1453
|
-
setUpdate?: any;
|
|
1454
|
-
size?: any;
|
|
1455
|
-
skip?: any;
|
|
1456
|
-
slice?: any;
|
|
1457
|
-
sort?: any;
|
|
1458
|
-
tailable?: any;
|
|
1459
|
-
then?: any;
|
|
1460
|
-
toConstructor?: any;
|
|
1461
|
-
updateMany?: any;
|
|
1462
|
-
updateOne?: any;
|
|
1463
|
-
w?: any;
|
|
1464
|
-
where?: any;
|
|
1465
|
-
within?: any;
|
|
1466
|
-
wtimeout?: any;
|
|
1467
|
-
paginate?: any;
|
|
1468
|
-
};
|
|
1274
|
+
});
|
|
1469
1275
|
/**
|
|
1470
1276
|
* Creates a unique slug based on a given string.
|
|
1471
1277
|
* This method generates multiple slug variations and finds the first available one.
|