@cyberskill/shared 2.0.0 → 2.1.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/README.md CHANGED
@@ -459,8 +459,8 @@ To provide developers with the tools and utilities they need to build secure, sc
459
459
  <p>Made with ❤️ by the <a href="https://github.com/cyberskill-world">CyberSkill Team</a></p>
460
460
 
461
461
  <p>
462
- <a href="https://cyberskill.world">Website</a>
463
- <a href="https://github.com/cyberskill-world/shared/issues">Issues</a>
462
+ <a href="https://cyberskill.world">Website</a>
463
+ <a href="https://github.com/cyberskill-world/shared/issues">Issues</a>
464
464
  <a href="https://github.com/cyberskill-world/shared/discussions">Discussions</a>
465
465
  </p>
466
466
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("lodash-es"),o=require("../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.15_@vitest_browser@3.2.4_jiti@2.4.2_j_e4a333d8aa4b05d17db10875e249d94f/node_modules/vitest/dist/config.cjs");function s(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 o.defineConfig(i.merge(r,e))}exports.vitestE2E=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("lodash-es"),o=require("../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.1.0_@vitest_browser@3.2.4_jiti@2.5.0_js_54cc41e7146dfcdf3e05180c4f422c31/node_modules/vitest/dist/config.cjs");function s(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 o.defineConfig(i.merge(r,e))}exports.vitestE2E=s;
@@ -1,6 +1,6 @@
1
1
  import t from "@vitejs/plugin-react-swc";
2
2
  import { merge as o } from "lodash-es";
3
- import { defineConfig as i } from "../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.15_@vitest_browser@3.2.4_jiti@2.4.2_j_e4a333d8aa4b05d17db10875e249d94f/node_modules/vitest/dist/config.js";
3
+ import { defineConfig as i } from "../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.1.0_@vitest_browser@3.2.4_jiti@2.5.0_js_54cc41e7146dfcdf3e05180c4f422c31/node_modules/vitest/dist/config.js";
4
4
  function f(r) {
5
5
  const e = {
6
6
  plugins: [t()],
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vitejs/plugin-react-swc"),n=require("lodash-es"),s=require("../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.15_@vitest_browser@3.2.4_jiti@2.4.2_j_e4a333d8aa4b05d17db10875e249d94f/node_modules/vitest/dist/config.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 s.defineConfig(n.merge(t,e))}exports.vitestUnit=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vitejs/plugin-react-swc"),n=require("lodash-es"),s=require("../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.1.0_@vitest_browser@3.2.4_jiti@2.5.0_js_54cc41e7146dfcdf3e05180c4f422c31/node_modules/vitest/dist/config.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 s.defineConfig(n.merge(t,e))}exports.vitestUnit=r;
@@ -1,6 +1,6 @@
1
1
  import i from "@vitejs/plugin-react-swc";
2
2
  import { merge as o } from "lodash-es";
3
- import { defineConfig as n } from "../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.15_@vitest_browser@3.2.4_jiti@2.4.2_j_e4a333d8aa4b05d17db10875e249d94f/node_modules/vitest/dist/config.js";
3
+ import { defineConfig as n } from "../../node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.1.0_@vitest_browser@3.2.4_jiti@2.5.0_js_54cc41e7146dfcdf3e05180c4f422c31/node_modules/vitest/dist/config.js";
4
4
  function u(t) {
5
5
  const e = {
6
6
  plugins: [i()],
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./mongo.constant.cjs"),o=require("./mongo.type.cjs"),e=require("./mongo.util.cjs"),t=require("mongoose-aggregate-paginate-v2"),r=require("mongoose-paginate-v2");exports.MONGO_MIGRATE_OPTIONS=n.MONGO_MIGRATE_OPTIONS;exports.C_Collection=o.C_Collection;exports.C_Db=o.C_Db;exports.C_Document=o.C_Document;exports.C_Model=o.C_Model;exports.MongoController=e.MongoController;exports.MongooseController=e.MongooseController;exports.mongo=e.mongo;exports.aggregatePaginate=t;exports.mongoosePaginate=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./mongo.constant.cjs"),o=require("./mongo.type.cjs"),e=require("./mongo.util.cjs");exports.MONGO_MIGRATE_OPTIONS=n.MONGO_MIGRATE_OPTIONS;exports.C_Collection=o.C_Collection;exports.C_Db=o.C_Db;exports.C_Document=o.C_Document;exports.C_Model=o.C_Model;exports.MongoController=e.MongoController;exports.MongooseController=e.MongooseController;exports.mongo=e.mongo;
@@ -1,17 +1,13 @@
1
- import { MONGO_MIGRATE_OPTIONS as r } from "./mongo.constant.js";
2
- import { C_Collection as a, C_Db as n, C_Document as g, C_Model as l } from "./mongo.type.js";
3
- import { MongoController as f, MongooseController as C, mongo as _ } from "./mongo.util.js";
4
- import { default as x } from "mongoose-aggregate-paginate-v2";
5
- import { default as s } from "mongoose-paginate-v2";
1
+ import { MONGO_MIGRATE_OPTIONS as e } from "./mongo.constant.js";
2
+ import { C_Collection as n, C_Db as t, C_Document as C, C_Model as _ } from "./mongo.type.js";
3
+ import { MongoController as M, MongooseController as O, mongo as f } from "./mongo.util.js";
6
4
  export {
7
- a as C_Collection,
8
- n as C_Db,
9
- g as C_Document,
10
- l as C_Model,
11
- r as MONGO_MIGRATE_OPTIONS,
12
- f as MongoController,
13
- C as MongooseController,
14
- x as aggregatePaginate,
15
- _ as mongo,
16
- s as mongoosePaginate
5
+ n as C_Collection,
6
+ t as C_Db,
7
+ C as C_Document,
8
+ _ as C_Model,
9
+ e as MONGO_MIGRATE_OPTIONS,
10
+ M as MongoController,
11
+ O as MongooseController,
12
+ f as mongo
17
13
  };
@@ -48,23 +48,43 @@ export type T_Omit_Update = 'id' | 'createdAt' | 'updatedAt';
48
48
  interface I_VirtualNestedOptions {
49
49
  [key: string]: I_VirtualNestedOptions | number | string | boolean;
50
50
  }
51
- interface I_VirtualOptions {
52
- ref: string;
51
+ /**
52
+ * Function type for dynamically determining the reference model name.
53
+ * Can return either a string (model name) or an enum value that represents the model.
54
+ * The function can also return undefined, which will be handled gracefully.
55
+ * This allows for optional properties in documents without requiring non-null assertions.
56
+ *
57
+ * @template T - The document type
58
+ * @template R - The return type (string or enum)
59
+ */
60
+ type T_DynamicRefFunction<T = unknown, R extends string = string> = (doc: T) => R | undefined;
61
+ interface I_VirtualBaseOptions {
53
62
  localField: string;
54
63
  foreignField: string;
55
64
  count?: boolean;
56
65
  justOne?: boolean;
57
66
  options?: I_VirtualNestedOptions;
58
67
  }
59
- interface I_MongooseOptions<T> {
68
+ interface I_VirtualOptions extends I_VirtualBaseOptions {
69
+ ref: string;
70
+ }
71
+ export interface I_DynamicVirtualOptions<T, R extends string = string> extends I_VirtualBaseOptions {
72
+ ref: T_DynamicRefFunction<T, R>;
73
+ }
74
+ export type T_VirtualOptions<T, R extends string = string> = I_VirtualOptions | I_DynamicVirtualOptions<T, R>;
75
+ export interface I_DynamicVirtualConfig<T, R extends string = string> {
76
+ name: string;
77
+ options: I_DynamicVirtualOptions<T, R>;
78
+ }
79
+ interface I_MongooseOptions<T, R extends string = string> {
60
80
  mongoose: typeof mongoose;
61
81
  virtuals?: {
62
82
  name: keyof T | string;
63
- options?: I_VirtualOptions;
83
+ options?: T_VirtualOptions<T, R>;
64
84
  get?: (this: T) => void;
65
85
  }[];
66
86
  }
67
- export interface I_CreateSchemaOptions<T> extends I_MongooseOptions<T> {
87
+ export interface I_CreateSchemaOptions<T, R extends string = string> extends I_MongooseOptions<T, R> {
68
88
  schema: T_Input_MongooseSchema<T>;
69
89
  standalone?: boolean;
70
90
  }
@@ -77,7 +97,7 @@ export interface I_MongooseModelMiddleware<T extends Partial<C_Document>> {
77
97
  pre?: T_MongooseMiddlewarePreFunction<T & T_QueryWithHelpers<T>>;
78
98
  post?: T_MongooseMiddlewarePostFunction<T>;
79
99
  }
80
- export interface I_CreateModelOptions<T extends Partial<C_Document>> extends I_MongooseOptions<T> {
100
+ export interface I_CreateModelOptions<T extends Partial<C_Document>, R extends string = string> extends I_MongooseOptions<T, R> {
81
101
  schema: T_Input_MongooseSchema<T>;
82
102
  name: string;
83
103
  aggregate?: boolean;
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("lodash-es"),C=require("migrate-mongo"),x=require("mongoose"),b=require("mongoose-aggregate-paginate-v2"),v=require("mongoose-paginate-v2"),P=require("uuid"),D=require("../../util/object/object.util.cjs"),I=require("../../util/common/common.util.cjs"),p=require("../fs/fs.util.cjs"),g=require("../path/path.constant.cjs"),q=require("../../util/validate/validate.util.cjs"),_=require("../../util/string/string.util.cjs"),d=require("../../constant/response-status.cjs"),i=require("../log/log.util.cjs");var M=Object.defineProperty,w=Object.defineProperties,j=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,N=(n,t,e)=>t in n?M(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,f=(n,t)=>{for(var e in t||(t={}))F.call(t,e)&&N(n,e,t[e]);if(A)for(var e of A(t))G.call(t,e)&&N(n,e,t[e]);return n},T=(n,t)=>w(n,j(t)),U=(n,t,e)=>N(n,typeof t!="symbol"?t+"":t,e),o=(n,t,e)=>new Promise((r,s)=>{var c=a=>{try{l(e.next(a))}catch(m){s(m)}},u=a=>{try{l(e.throw(a))}catch(m){s(m)}},l=a=>a.done?r(a.value):Promise.resolve(a.value).then(c,u);l((e=e.apply(n,t)).next())});const y={createGenericFields(){return{id:P.v4(),isDel:!1,createdAt:new Date,updatedAt:new Date}},applyPlugins(n,t){t.filter(e=>typeof e=="function").forEach(e=>n.plugin(e))},applyMiddlewares(n,t){t.forEach(({method:e,pre:r,post:s})=>{e&&r&&n.pre(e,r),e&&s&&n.post(e,s)})},createGenericSchema(n){return new n.Schema({id:{type:String,default:P.v4,unique:!0},isDel:{type:Boolean,default:!1}},{timestamps:!0})},createSchema({mongoose:n,schema:t,virtuals:e=[],standalone:r=!1}){const s=new n.Schema(t);return e.forEach(({name:c,options:u,get:l})=>{const a=s.virtual(c,u);l&&a.get(l)}),r||s.add(y.createGenericSchema(n)),s},createModel({mongoose:n,name:t,schema:e,pagination:r=!1,aggregate:s=!1,virtuals:c=[],middlewares:u=[]}){if(!t)throw new Error("Model name is required.");if(n.models[t])return n.models[t];const l=y.createSchema({mongoose:n,schema:e,virtuals:c});return y.applyPlugins(l,[r&&v,s&&b]),y.applyMiddlewares(l,u),n.model(t,l)},validator:{isRequired(){return function(n){return o(this,null,function*(){return!q.validate.isEmpty(n)})}},isUnique(n){return function(t){return o(this,null,function*(){if(!Array.isArray(n)||n.length===0)throw new Error("Fields must be a non-empty array of strings.");const e={$or:n.map(s=>({[s]:t}))};return!(yield this.constructor.exists(e))})}},matchesRegex(n){return function(t){return o(this,null,function*(){if(!Array.isArray(n)||n.some(e=>!(e instanceof RegExp)))throw new Error("regexArray must be an array of valid RegExp objects.");return n.every(e=>e.test(t))})}}},migrate:T(f({},C),{setConfig:n=>{const t=`// This file is automatically generated by the Cyberskill CLI.
2
- module.exports = ${JSON.stringify(n,null,4)}`;p.writeFileSync(g.PATH.MIGRATE_MONGO_CONFIG,t);const e=`
3
- ${g.MIGRATE_MONGO_CONFIG}
4
- `;p.pathExistsSync(g.PATH.GIT_IGNORE)?p.readFileSync(g.PATH.GIT_IGNORE,"utf-8").split(`
5
- `).includes(g.MIGRATE_MONGO_CONFIG)||p.appendFileSync(g.PATH.GIT_IGNORE,e):p.writeFileSync(g.PATH.GIT_IGNORE,e)}}),regexify(n,t){if(!n)return{};let e=R.cloneDeep(n);if(!t||t.length===0)return e;for(const r of t){const s=r.toString().split("."),c=D.getNestedValue(e,s);if(typeof c=="string"&&c.length>0){const u={$regex:`.*${I.regexSearchMapper(c)}.*`,$options:"i"};e=D.setNestedValue(e,s,u)}}return e}};class ${constructor(t,e){U(this,"collection"),this.collection=t.collection(e)}createOne(t){return o(this,null,function*(){try{const e=f(f({},y.createGenericFields()),t);return(yield this.collection.insertOne(e)).acknowledged?{success:!0,message:"Document created successfully",result:e}:{success:!1,message:"Document creation failed",code:d.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}catch(e){return i.catchError(e)}})}createMany(t){return o(this,null,function*(){try{const e=t.map(s=>f(f({},y.createGenericFields()),s)),r=yield this.collection.insertMany(e);return r.insertedCount===0?{success:!1,message:"No documents were inserted",code:d.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:`${r.insertedCount} documents created successfully`,result:e}}catch(e){return i.catchError(e)}})}findOne(t){return o(this,null,function*(){try{const e=yield this.collection.findOne(t);return e?{success:!0,message:"Document found",result:e}:{success:!1,message:"Document not found",code:d.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(e){return i.catchError(e)}})}findAll(){return o(this,arguments,function*(t={}){try{return{success:!0,message:"Documents retrieved successfully",result:yield this.collection.find(t).toArray()}}catch(e){return i.catchError(e)}})}count(){return o(this,arguments,function*(t={}){try{return{success:!0,message:"Count retrieved successfully",result:yield this.collection.countDocuments(t)}}catch(e){return i.catchError(e)}})}updateOne(t,e){return o(this,null,function*(){try{const r=yield this.collection.updateOne(t,{$set:e});return r.matchedCount===0?{success:!1,message:"No documents matched the filter",code:d.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Document updated successfully",result:r}}catch(r){return i.catchError(r)}})}updateMany(t,e){return o(this,null,function*(){try{const r=yield this.collection.updateMany(t,{$set:e});return r.matchedCount===0?{success:!1,message:"No documents matched the filter",code:d.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Documents updated successfully",result:r}}catch(r){return i.catchError(r)}})}deleteOne(t){return o(this,null,function*(){try{const e=yield this.collection.deleteOne(t);return e.deletedCount===0?{success:!1,message:"No documents matched the filter",code:d.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Document deleted successfully",result:e}}catch(e){return i.catchError(e)}})}deleteMany(t){return o(this,null,function*(){try{const e=yield this.collection.deleteMany(t);return e.deletedCount===0?{success:!1,message:"No documents matched the filter",code:d.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}:{success:!0,message:"Documents deleted successfully",result:e}}catch(e){return i.catchError(e)}})}}class V{constructor(t){this.model=t}getModelName(){return this.model.modelName}findOne(){return o(this,arguments,function*(t={},e={},r={},s){try{const c=this.model.findOne(t,e,r);s&&c.populate(s);const u=yield c.exec();return u?{success:!0,result:u}:{success:!1,message:`No ${this.getModelName()} found.`,code:d.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(c){return i.catchError(c)}})}findAll(){return o(this,arguments,function*(t={},e={},r={},s){try{const c=this.model.find(t,e,r);return s&&c.populate(s),{success:!0,result:yield c.exec()}}catch(c){return i.catchError(c)}})}findPaging(){return o(this,arguments,function*(t={},e={}){try{return{success:!0,result:yield this.model.paginate(t,e)}}catch(r){return i.catchError(r)}})}findPagingAggregate(t){return o(this,arguments,function*(e,r={}){try{return{success:!0,result:yield this.model.aggregatePaginate(this.model.aggregate(e),r)}}catch(s){return i.catchError(s)}})}count(){return o(this,arguments,function*(t={}){try{return{success:!0,result:yield this.model.countDocuments(t)}}catch(e){return i.catchError(e)}})}createOne(t){return o(this,null,function*(){try{return{success:!0,result:yield this.model.create(t)}}catch(e){return i.catchError(e)}})}createMany(t){return o(this,arguments,function*(e,r={}){try{return{success:!0,result:(yield this.model.insertMany(e,r)).map(u=>u instanceof x.Document?u.toObject():null).filter(u=>u!==null)}}catch(s){return i.catchError(s)}})}updateOne(){return o(this,arguments,function*(t={},e={},r={}){try{const s=yield this.model.findOneAndUpdate(t,e,f({new:!0},r)).exec();return s?{success:!0,result:s}:{success:!1,message:`Failed to update ${this.getModelName()}.`,code:d.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(s){return i.catchError(s)}})}updateMany(){return o(this,arguments,function*(t={},e={},r={}){try{return{success:!0,result:yield this.model.updateMany(t,e,r).exec()}}catch(s){return i.catchError(s)}})}deleteOne(){return o(this,arguments,function*(t={},e={}){try{const r=yield this.model.findOneAndDelete(t,e).exec();return r?{success:!0,result:r}:{success:!1,message:`No ${this.getModelName()} found to delete.`,code:d.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(r){return i.catchError(r)}})}deleteMany(){return o(this,arguments,function*(t={},e={}){try{const r=yield this.model.deleteMany(t,e).exec();return r.deletedCount===0?{success:!1,message:"No documents found to delete.",code:d.RESPONSE_STATUS.NOT_FOUND.CODE}:{success:!0,result:r}}catch(r){return i.catchError(r)}})}createShortId(t,e=4){return o(this,null,function*(){try{const s=Array.from({length:10},(l,a)=>_.generateShortId(t,a+e)),u=(yield Promise.all(s.map(l=>this.model.exists({shortId:l})))).findIndex(l=>!l);if(u!==-1){const l=s[u];if(l)return{success:!0,result:l}}return{success:!1,message:"Failed to create a unique shortId",code:d.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}catch(r){return i.catchError(r)}})}createSlugQuery({slug:t,field:e,isObject:r,filter:s}){const c=f({},s!=null?s:{});return r?T(f({},c),{$or:[{[`slug.${e}`]:t},{slugHistory:{$elemMatch:{[`slug.${e}`]:t}}}]}):T(f({},c),{$or:[{slug:t},{slugHistory:t}]})}createUniqueSlug(t){return o(this,arguments,function*({slug:e,field:r,isObject:s,filter:c}){const u=_.generateSlug(e),a=Array.from({length:100},(h,S)=>S===0?u:`${u}-${S}`),E=(yield Promise.all(a.map(h=>this.model.exists(this.createSlugQuery({slug:h,field:r,isObject:s,filter:c}))))).findIndex(h=>!h);if(E!==-1){const h=a[E];if(h)return h}return`${u}-${Date.now()}`})}createSlug(t){return o(this,arguments,function*({field:e,from:r,filter:s}){try{const c=r[e];return R.isObject(c)?{success:!0,result:Object.fromEntries(yield Promise.all(Object.entries(c).map(m=>o(this,[m],function*([E,h]){const S=yield this.createUniqueSlug({slug:h,field:E,isObject:!0,filter:s});return[E,S]}))))}:{success:!0,result:yield this.createUniqueSlug({slug:c,field:e,isObject:!1,filter:s})}}catch(c){return i.catchError(c)}})}checkSlug(t){return o(this,arguments,function*({slug:e,field:r,from:s,filter:c}){try{const u=s[r];if(R.isObject(u)){const h=Object.values(u).map(O=>_.generateSlug(O));return(yield Promise.all(h.map(O=>this.model.exists(this.createSlugQuery({slug:O,field:r,isObject:!0,filter:c}))))).some(O=>O)?{success:!0,result:!0}:{success:!0,result:!1}}const a=_.generateSlug(e);return{success:!0,result:(yield this.model.exists(this.createSlugQuery({slug:a,field:r,isObject:!1,filter:c})))!==null}}catch(u){return i.catchError(u)}})}aggregate(t){return o(this,null,function*(){try{return{success:!0,result:yield this.model.aggregate(t)}}catch(e){return i.catchError(e)}})}}exports.aggregatePaginate=b;exports.mongoosePaginate=v;exports.MongoController=$;exports.MongooseController=V;exports.mongo=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("lodash-es"),B=require("migrate-mongo"),k=require("mongoose"),H=require("mongoose-aggregate-paginate-v2"),K=require("mongoose-paginate-v2"),U=require("uuid"),$=require("../../util/object/object.util.cjs"),W=require("../../util/common/common.util.cjs"),P=require("../fs/fs.util.cjs"),A=require("../path/path.constant.cjs"),Q=require("../../util/validate/validate.util.cjs"),I=require("../../util/string/string.util.cjs"),v=require("../../constant/response-status.cjs"),f=require("../log/log.util.cjs");var z=Object.defineProperty,J=Object.defineProperties,X=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,F=(n,t,e)=>t in n?z(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,O=(n,t)=>{for(var e in t||(t={}))Y.call(t,e)&&F(n,e,t[e]);if(G)for(var e of G(t))Z.call(t,e)&&F(n,e,t[e]);return n},V=(n,t)=>J(n,X(t)),ee=(n,t,e)=>F(n,typeof t!="symbol"?t+"":t,e),a=(n,t,e)=>new Promise((r,s)=>{var c=i=>{try{o(e.next(i))}catch(l){s(l)}},u=i=>{try{o(e.throw(i))}catch(l){s(l)}},o=i=>i.done?r(i.value):Promise.resolve(i.value).then(c,u);o((e=e.apply(n,t)).next())});function te(n){return n===n.toUpperCase()?n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():n}const T={createGenericFields(){return{id:U.v4(),isDel:!1,createdAt:new Date,updatedAt:new Date}},applyPlugins(n,t){t.filter(e=>typeof e=="function").forEach(e=>n.plugin(e))},applyMiddlewares(n,t){t.forEach(({method:e,pre:r,post:s})=>{e&&r&&n.pre(e,r),e&&s&&n.post(e,s)})},createGenericSchema(n){return new n.Schema({id:{type:String,default:U.v4,unique:!0},isDel:{type:Boolean,default:!1}},{timestamps:!0})},createSchema({mongoose:n,schema:t,virtuals:e=[],standalone:r=!1}){const s=new n.Schema(t);return e.forEach(({name:c,options:u,get:o})=>{if(T.isDynamicVirtual(u)){const i=s.statics;i._dynamicVirtuals||(i._dynamicVirtuals=[]),i._dynamicVirtuals.push({name:c,options:u});const l=s.virtual(c);o?l.get(o):l.get(function(){var d;return((d=this._populated)==null?void 0:d[c])||(u!=null&&u.count?0:u!=null&&u.justOne?null:[])})}else{const i=s.virtual(c,u);o&&i.get(o)}}),r||s.add(T.createGenericSchema(n)),s},createModel({mongoose:n,name:t,schema:e,pagination:r=!1,aggregate:s=!1,virtuals:c=[],middlewares:u=[]}){if(!t)throw new Error("Model name is required.");if(n.models[t])return n.models[t];const o=T.createSchema({mongoose:n,schema:e,virtuals:c});return T.applyPlugins(o,[r&&K,s&&H]),T.applyMiddlewares(o,u),n.model(t,o)},validator:{isRequired(){return function(n){return a(this,null,function*(){return!Q.validate.isEmpty(n)})}},isUnique(n){return function(t){return a(this,null,function*(){if(!Array.isArray(n)||n.length===0)throw new Error("Fields must be a non-empty array of strings.");const e={$or:n.map(s=>({[s]:t}))};return!(yield this.constructor.exists(e))})}},matchesRegex(n){return function(t){return a(this,null,function*(){if(!Array.isArray(n)||n.some(e=>!(e instanceof RegExp)))throw new Error("regexArray must be an array of valid RegExp objects.");return n.every(e=>e.test(t))})}}},migrate:V(O({},B),{setConfig:n=>{const t=`// This file is automatically generated by the Cyberskill CLI.
2
+ module.exports = ${JSON.stringify(n,null,4)}`;P.writeFileSync(A.PATH.MIGRATE_MONGO_CONFIG,t);const e=`
3
+ ${A.MIGRATE_MONGO_CONFIG}
4
+ `;P.pathExistsSync(A.PATH.GIT_IGNORE)?P.readFileSync(A.PATH.GIT_IGNORE,"utf-8").split(`
5
+ `).includes(A.MIGRATE_MONGO_CONFIG)||P.appendFileSync(A.PATH.GIT_IGNORE,e):P.writeFileSync(A.PATH.GIT_IGNORE,e)}}),regexify(n,t){if(!n)return{};let e=j.cloneDeep(n);if(!t||t.length===0)return e;for(const r of t){const s=r.toString().split("."),c=$.getNestedValue(e,s);if(typeof c=="string"&&c.length>0){const u={$regex:`.*${W.regexSearchMapper(c)}.*`,$options:"i"};e=$.setNestedValue(e,s,u)}}return e},isDynamicVirtual(n){return!!(n&&typeof n.ref=="function")}};function re(n){return n!==null&&typeof n=="object"&&"toObject"in n&&typeof n.toObject=="function"}function se(n,t,e){if(!n.length||!t||!(e!=null&&e.ref))return[];const r=new Map;return n.forEach(s=>{try{const c=e.ref(s);if(c==null)return;const u=typeof c=="string"?c:String(c);if(u&&u.trim()!==""){const o=te(u);r.has(o)||r.set(o,[]),r.get(o).push(s)}}catch(c){f.catchError(new Error(`Dynamic ref function failed for virtual "${t}": ${c instanceof Error?c.message:String(c)}`))}}),Array.from(r.entries()).map(([s,c])=>({model:s,docs:c}))}function q(n,t,e,r,s){return a(this,null,function*(){if(!t.length||!e.length||!r)return t;const c=e.filter(i=>{if(Array.isArray(r))return r.length>0&&r.some(l=>typeof l=="string"?l===i.name:l.path===i.name);if(typeof r=="string")return r===i.name;if(typeof r=="object"&&r!==null){const l=r;return l.path&&l.path===i.name||l.populate&&l.populate===i.name}return!1});if(c.length===0)return t;const u=j.cloneDeep(t.map(i=>re(i)?i.toObject():i));u.forEach(i=>{c.forEach(({name:l,options:d})=>{if(!(l in i)){const h=i;h[l]=d.count?0:d.justOne?null:[]}})});const o=new Map;for(const i of c){const{name:l,options:d}=i,h=se(u,l,d);for(const S of h){o.has(S.model)||o.set(S.model,{virtuals:[],localValueSets:new Map,docsByLocalValue:new Map});const m=o.get(S.model);m.virtuals.find(D=>D.name===l)||(m.virtuals.push(i),m.localValueSets.set(l,new Set));const M=m.localValueSets.get(l);S.docs.forEach(D=>{const C=D[d.localField];if(C!=null){const _=String(C);M.add(_);let R=-1;const N=D;N.id!==void 0?R=u.findIndex(b=>b.id===N.id):N._id!==void 0&&(R=u.findIndex(b=>{var E,g,p,y;return((g=(E=b._id)==null?void 0:E.toString)==null?void 0:g.call(E))===((y=(p=N._id)==null?void 0:p.toString)==null?void 0:y.call(p))})),R!==-1&&(m.docsByLocalValue.has(_)||m.docsByLocalValue.set(_,[]),m.docsByLocalValue.get(_).push(R))}})}}return yield Promise.all(Array.from(o.entries()).map(i=>a(null,[i],function*([l,d]){const h=n.models[l];if(!h)return;const S=new Set;if(d.localValueSets.forEach(_=>{_.forEach(R=>S.add(R))}),S.size===0)return;const m=[...new Set(d.virtuals.map(_=>_.options.foreignField))],M=Array.from(S);let D;m.length===1?D={[String(m[0])]:{$in:M}}:D={$or:m.map(_=>({[_]:{$in:M}}))};const C=yield h.find(D,s).lean();for(const _ of d.virtuals){const{name:R,options:N}=_,b=C.filter(E=>{const g=E[N.foreignField];return g!=null&&S.has(String(g))});if(N.count){const E=new Map;b.forEach(g=>{var p;const y=(p=g[N.foreignField])==null?void 0:p.toString();y&&E.set(y,(E.get(y)||0)+1)}),d.localValueSets.get(R).forEach(g=>{const p=d.docsByLocalValue.get(g)||[],y=E.get(g)||0;p.forEach(w=>{const x=u[w];x[R]===void 0&&(x[R]=y)})})}else{const E=new Map;b.forEach(g=>{var p;const y=(p=g[N.foreignField])==null?void 0:p.toString();y&&(E.has(y)||E.set(y,[]),E.get(y).push(g))}),d.localValueSets.get(R).forEach(g=>{const p=d.docsByLocalValue.get(g)||[],y=E.get(g)||[],w=N.justOne?y[0]||null:y;p.forEach(x=>{const L=u[x];L[R]=w})})}}}))),u})}class ne{constructor(t,e){ee(this,"collection"),this.collection=t.collection(e)}createOne(t){return a(this,null,function*(){try{const e=O(O({},T.createGenericFields()),t);return(yield this.collection.insertOne(e)).acknowledged?{success:!0,message:"Document created successfully",result:e}:{success:!1,message:"Document creation failed",code:v.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}catch(e){return f.catchError(e)}})}createMany(t){return a(this,null,function*(){try{const e=t.map(s=>O(O({},T.createGenericFields()),s)),r=yield this.collection.insertMany(e);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:e}}catch(e){return f.catchError(e)}})}findOne(t){return a(this,null,function*(){try{const e=yield this.collection.findOne(t);return e?{success:!0,message:"Document found",result:e}:{success:!1,message:"Document not found",code:v.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(e){return f.catchError(e)}})}findAll(){return a(this,arguments,function*(t={}){try{return{success:!0,message:"Documents retrieved successfully",result:yield this.collection.find(t).toArray()}}catch(e){return f.catchError(e)}})}count(){return a(this,arguments,function*(t={}){try{const e=yield this.collection.countDocuments(t);return{success:!0,message:`${e} documents counted successfully`,result:e}}catch(e){return f.catchError(e)}})}updateOne(t,e){return a(this,null,function*(){try{const r=yield this.collection.updateOne(t,{$set:e});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 f.catchError(r)}})}updateMany(t,e){return a(this,null,function*(){try{const r=yield this.collection.updateMany(t,{$set:e});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 f.catchError(r)}})}deleteOne(t){return a(this,null,function*(){try{const e=yield this.collection.deleteOne(t);return e.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:e}}catch(e){return f.catchError(e)}})}deleteMany(t){return a(this,null,function*(){try{const e=yield this.collection.deleteMany(t);return e.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:e}}catch(e){return f.catchError(e)}})}}class ce{constructor(t){this.model=t}getModelName(){return this.model.modelName}findOne(){return a(this,arguments,function*(t={},e={},r={},s){try{const c=this.model.findOne(t,e,r),o=this.model.schema.statics._dynamicVirtuals;s&&(!o||o.length===0)&&c.populate(s);const i=yield c.exec();if(!i)return{success:!1,message:`No ${this.getModelName()} found.`,code:v.RESPONSE_STATUS.NOT_FOUND.CODE};let l=i;if(o&&o.length>0){const d=yield q(this.model.base,[i],o,s);l=d&&d[0]?d[0]:i}return{success:!0,result:l}}catch(c){return f.catchError(c)}})}findAll(){return a(this,arguments,function*(t={},e={},r={},s){try{const c=this.model.find(t,e,r),o=this.model.schema.statics._dynamicVirtuals;s&&(!o||o.length===0)&&c.populate(s);const i=yield c.exec();let l=i;return o&&o.length>0&&i.length>0&&(l=yield q(this.model.base,i,o,s)),{success:!0,result:l}}catch(c){return f.catchError(c)}})}findPaging(){return a(this,arguments,function*(t={},e={}){try{const s=this.model.schema.statics._dynamicVirtuals,c=O({},e);s&&s.length>0&&(c.populate=void 0);const u=yield this.model.paginate(t,c);let o=u.docs;return s&&s.length>0&&u.docs.length>0&&(o=yield q(this.model.base,u.docs,s,e.populate)),{success:!0,result:V(O({},u),{docs:o})}}catch(r){return f.catchError(r)}})}findPagingAggregate(t){return a(this,arguments,function*(e,r={}){try{const c=this.model.schema.statics._dynamicVirtuals,u=O({},r);c&&c.length>0&&(u.populate=void 0);const o=yield this.model.aggregatePaginate(this.model.aggregate(e),u);let i=o.docs;return c&&c.length>0&&o.docs.length>0&&(i=yield q(this.model.base,o.docs,c,r.populate)),{success:!0,result:V(O({},o),{docs:i})}}catch(s){return f.catchError(s)}})}count(){return a(this,arguments,function*(t={}){try{return{success:!0,result:yield this.model.countDocuments(t)}}catch(e){return f.catchError(e)}})}createOne(t){return a(this,null,function*(){try{return{success:!0,result:yield this.model.create(t)}}catch(e){return f.catchError(e)}})}createMany(t){return a(this,arguments,function*(e,r={}){try{return{success:!0,result:(yield this.model.insertMany(e,r)).map(u=>u instanceof k.Document?u.toObject():null).filter(u=>u!==null)}}catch(s){return f.catchError(s)}})}updateOne(){return a(this,arguments,function*(t={},e={},r={}){try{const s=yield this.model.findOneAndUpdate(t,e,O({new:!0},r)).exec();return s?{success:!0,result:s}:{success:!1,message:`Failed to update ${this.getModelName()}.`,code:v.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(s){return f.catchError(s)}})}updateMany(){return a(this,arguments,function*(t={},e={},r={}){try{return{success:!0,result:yield this.model.updateMany(t,e,r).exec()}}catch(s){return f.catchError(s)}})}deleteOne(){return a(this,arguments,function*(t={},e={}){try{const r=yield this.model.findOneAndDelete(t,e).exec();return r?{success:!0,result:r}:{success:!1,message:`No ${this.getModelName()} found to delete.`,code:v.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(r){return f.catchError(r)}})}deleteMany(){return a(this,arguments,function*(t={},e={}){try{const r=yield this.model.deleteMany(t,e).exec();return r.deletedCount===0?{success:!1,message:"No documents found to delete.",code:v.RESPONSE_STATUS.NOT_FOUND.CODE}:{success:!0,result:r}}catch(r){return f.catchError(r)}})}createShortId(t,e=4){return a(this,null,function*(){try{const s=Array.from({length:10},(o,i)=>I.generateShortId(t,i+e)),u=(yield Promise.all(s.map(o=>this.model.exists({shortId:o})))).findIndex(o=>!o);if(u!==-1){const o=s[u];if(o)return{success:!0,result:o}}return{success:!1,message:"Failed to create a unique shortId",code:v.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}catch(r){return f.catchError(r)}})}createSlugQuery({slug:t,field:e,isObject:r,filter:s}){const c=O({},s!=null?s:{});return r?V(O({},c),{$or:[{[`slug.${e}`]:t},{slugHistory:{$elemMatch:{[`slug.${e}`]:t}}}]}):V(O({},c),{$or:[{slug:t},{slugHistory:t}]})}createUniqueSlug(t){return a(this,arguments,function*({slug:e,field:r,isObject:s,filter:c}){const u=I.generateSlug(e),i=Array.from({length:100},(h,S)=>S===0?u:`${u}-${S}`),d=(yield Promise.all(i.map(h=>this.model.exists(this.createSlugQuery({slug:h,field:r,isObject:s,filter:c}))))).findIndex(h=>!h);if(d!==-1){const h=i[d];if(h)return h}return`${u}-${Date.now()}`})}createSlug(t){return a(this,arguments,function*({field:e,from:r,filter:s}){try{const c=r[e];return j.isObject(c)?{success:!0,result:Object.fromEntries(yield Promise.all(Object.entries(c).map(l=>a(this,[l],function*([d,h]){const S=yield this.createUniqueSlug({slug:h,field:d,isObject:!0,filter:s});return[d,S]}))))}:{success:!0,result:yield this.createUniqueSlug({slug:c,field:e,isObject:!1,filter:s})}}catch(c){return f.catchError(c)}})}checkSlug(t){return a(this,arguments,function*({slug:e,field:r,from:s,filter:c}){try{const u=s[r];if(j.isObject(u)){const h=Object.values(u).map(m=>I.generateSlug(m));return(yield Promise.all(h.map(m=>this.model.exists(this.createSlugQuery({slug:m,field:r,isObject:!0,filter:c}))))).some(m=>m)?{success:!0,result:!0}:{success:!0,result:!1}}const i=I.generateSlug(e);return{success:!0,result:(yield this.model.exists(this.createSlugQuery({slug:i,field:r,isObject:!1,filter:c})))!==null}}catch(u){return f.catchError(u)}})}aggregate(t){return a(this,null,function*(){try{return{success:!0,result:yield this.model.aggregate(t)}}catch(e){return f.catchError(e)}})}}exports.MongoController=ne;exports.MongooseController=ce;exports.mongo=T;
@@ -1,10 +1,7 @@
1
1
  import { default as mongooseRaw } from 'mongoose';
2
2
  import { default as migrate } from 'migrate-mongo';
3
- import { default as aggregatePaginate } from 'mongoose-aggregate-paginate-v2';
4
- import { default as mongoosePaginate } from 'mongoose-paginate-v2';
5
3
  import { I_Return } from '../../typescript/index.js';
6
- import { C_Db, C_Document, I_CreateModelOptions, I_CreateSchemaOptions, I_DeleteOptionsExtended, I_ExtendedModel, I_GenericDocument, I_Input_CheckSlug, I_Input_CreateSlug, I_Input_GenerateSlug, I_MongooseModelMiddleware, I_PaginateOptionsWithPopulate, I_UpdateOptionsExtended, T_AggregatePaginateResult, T_DeleteResult, T_Filter, T_FilterQuery, T_Input_Populate, T_InsertManyOptions, T_MongoosePlugin, T_MongooseShema, T_PaginateResult, T_PipelineStage, T_ProjectionType, T_QueryOptions, T_UpdateQuery, T_UpdateResult, T_WithId } from './mongo.type.js';
7
- export { aggregatePaginate, mongoosePaginate };
4
+ import { C_Db, C_Document, I_CreateModelOptions, I_CreateSchemaOptions, I_DeleteOptionsExtended, I_DynamicVirtualOptions, I_ExtendedModel, I_GenericDocument, I_Input_CheckSlug, I_Input_CreateSlug, I_Input_GenerateSlug, I_MongooseModelMiddleware, I_PaginateOptionsWithPopulate, I_UpdateOptionsExtended, T_AggregatePaginateResult, T_DeleteResult, T_Filter, T_FilterQuery, T_Input_Populate, T_InsertManyOptions, T_MongoosePlugin, T_MongooseShema, T_PaginateResult, T_PipelineStage, T_ProjectionType, T_QueryOptions, T_UpdateQuery, T_UpdateResult, T_VirtualOptions, T_WithId } from './mongo.type.js';
8
5
  /**
9
6
  * MongoDB utility object providing comprehensive database operations and utilities.
10
7
  * This object contains methods for creating generic fields, applying plugins and middlewares,
@@ -65,7 +62,7 @@ export declare const mongo: {
65
62
  * @param options.standalone - Whether to exclude generic fields (default: false).
66
63
  * @returns A configured Mongoose schema.
67
64
  */
68
- createSchema<T>({ mongoose, schema, virtuals, standalone, }: I_CreateSchemaOptions<T>): T_MongooseShema<T>;
65
+ createSchema<T, R extends string = string>({ mongoose, schema, virtuals, standalone, }: I_CreateSchemaOptions<T, R>): T_MongooseShema<T>;
69
66
  /**
70
67
  * Creates a Mongoose model with plugins, middleware, and pagination support.
71
68
  * This function creates a model from a schema with optional pagination and aggregation plugins,
@@ -82,7 +79,7 @@ export declare const mongo: {
82
79
  * @returns A configured Mongoose model with extended functionality.
83
80
  * @throws {Error} When the model name is not provided.
84
81
  */
85
- createModel<T extends Partial<C_Document>>({ mongoose: currentMongooseInstance, name, schema, pagination, aggregate, virtuals, middlewares, }: I_CreateModelOptions<T>): I_ExtendedModel<T>;
82
+ createModel<T extends Partial<C_Document>, R extends string = string>({ mongoose: currentMongooseInstance, name, schema, pagination, aggregate, virtuals, middlewares, }: I_CreateModelOptions<T, R>): I_ExtendedModel<T>;
86
83
  /**
87
84
  * Validation utilities for Mongoose schemas.
88
85
  * This object provides common validation functions that can be used in Mongoose schema definitions.
@@ -107,7 +104,9 @@ export declare const mongo: {
107
104
  */
108
105
  isUnique<T extends {
109
106
  constructor: {
110
- exists: (query: Record<string, unknown>) => Promise<unknown>;
107
+ exists: (query: {
108
+ [key: string]: unknown;
109
+ }) => Promise<unknown>;
111
110
  };
112
111
  }>(fields: string[]): (this: T, value: unknown) => Promise<boolean>;
113
112
  /**
@@ -136,9 +135,9 @@ export declare const mongo: {
136
135
  setConfig: (options: Partial<migrate.config.Config>) => void;
137
136
  init(): Promise<void>;
138
137
  create(description: string): Promise<string>;
139
- up(db: mongooseRaw.mongo.Db, client: mongooseRaw.mongo.MongoClient): Promise<string[]>;
140
- down(db: mongooseRaw.mongo.Db, client: mongooseRaw.mongo.MongoClient): Promise<string[]>;
141
- status(db: mongooseRaw.mongo.Db): Promise<migrate.MigrationStatus[]>;
138
+ up(db: import('mongodb').Db, client: import('mongodb').MongoClient): Promise<string[]>;
139
+ down(db: import('mongodb').Db, client: import('mongodb').MongoClient): Promise<string[]>;
140
+ status(db: import('mongodb').Db): Promise<migrate.MigrationStatus[]>;
142
141
  database: typeof migrate.database;
143
142
  config: typeof migrate.config;
144
143
  };
@@ -152,6 +151,13 @@ export declare const mongo: {
152
151
  * @returns A new filter object with string values converted to regex patterns.
153
152
  */
154
153
  regexify<T>(filter?: T_FilterQuery<T>, fields?: (keyof T | string)[]): T_FilterQuery<T>;
154
+ /**
155
+ * Checks if a virtual options object has a dynamic ref function.
156
+ *
157
+ * @param options - The virtual options to check.
158
+ * @returns True if the options contain a dynamic ref function.
159
+ */
160
+ isDynamicVirtual<T, R extends string = string>(options?: T_VirtualOptions<T, R>): options is I_DynamicVirtualOptions<T, R>;
155
161
  };
156
162
  /**
157
163
  * MongoDB native driver controller for direct database operations.
@@ -256,6 +262,7 @@ export declare class MongooseController<T extends Partial<C_Document>> {
256
262
  private getModelName;
257
263
  /**
258
264
  * Finds a single document with optional population and projection.
265
+ * Automatically handles dynamic virtual population if configured.
259
266
  *
260
267
  * @param filter - The filter criteria to find the document.
261
268
  * @param projection - The fields to include/exclude in the result.
@@ -266,6 +273,7 @@ export declare class MongooseController<T extends Partial<C_Document>> {
266
273
  findOne(filter?: T_FilterQuery<T>, projection?: T_ProjectionType<T>, options?: T_QueryOptions<T>, populate?: T_Input_Populate): Promise<I_Return<T>>;
267
274
  /**
268
275
  * Finds all documents with optional population and projection.
276
+ * Automatically handles dynamic virtual population if configured.
269
277
  *
270
278
  * @param filter - The filter criteria to find documents.
271
279
  * @param projection - The fields to include/exclude in the result.
@@ -276,6 +284,7 @@ export declare class MongooseController<T extends Partial<C_Document>> {
276
284
  findAll(filter?: T_FilterQuery<T>, projection?: T_ProjectionType<T>, options?: T_QueryOptions<T>, populate?: T_Input_Populate): Promise<I_Return<T[]>>;
277
285
  /**
278
286
  * Finds documents with pagination support.
287
+ * Automatically handles dynamic virtual population if configured.
279
288
  *
280
289
  * @param filter - The filter criteria to find documents.
281
290
  * @param options - Pagination options including page, limit, and population.