@cyberskill/shared 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("lodash-es"),k=require("migrate-mongo"),H=require("mongoose"),K=require("mongoose-aggregate-paginate-v2"),W=require("mongoose-paginate-v2"),U=require("uuid"),$=require("../../util/object/object.util.cjs"),Q=require("../../util/common/common.util.cjs"),P=require("../fs/fs.util.cjs"),T=require("../path/path.constant.cjs"),J=require("../../util/validate/validate.util.cjs"),j=require("../../util/string/string.util.cjs"),v=require("../../constant/response-status.cjs"),d=require("../log/log.util.cjs");var z=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable,q=(s,t,e)=>t in s?z(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,O=(s,t)=>{for(var e in t||(t={}))Z.call(t,e)&&q(s,e,t[e]);if(G)for(var e of G(t))ee.call(t,e)&&q(s,e,t[e]);return s},b=(s,t)=>X(s,Y(t)),te=(s,t,e)=>q(s,typeof t!="symbol"?t+"":t,e),l=(s,t,e)=>new Promise((r,n)=>{var c=o=>{try{i(e.next(o))}catch(a){n(a)}},u=o=>{try{i(e.throw(o))}catch(a){n(a)}},i=o=>o.done?r(o.value):Promise.resolve(o.value).then(c,u);i((e=e.apply(s,t)).next())});function re(s){return s===s.toUpperCase()?s.charAt(0).toUpperCase()+s.slice(1).toLowerCase():s}const V={createGenericFields(){return{id:U.v4(),isDel:!1,createdAt:new Date,updatedAt:new Date}},applyPlugins(s,t){t.filter(e=>typeof e=="function").forEach(e=>s.plugin(e))},applyMiddlewares(s,t){t.forEach(({method:e,pre:r,post:n})=>{e&&r&&s.pre(e,r),e&&n&&s.post(e,n)})},createGenericSchema(s){return new s.Schema({id:{type:String,default:U.v4,unique:!0},isDel:{type:Boolean,default:!1}},{timestamps:!0})},createSchema({mongoose:s,schema:t,virtuals:e=[],standalone:r=!1}){const n=new s.Schema(t,{toJSON:{virtuals:!0},toObject:{virtuals:!0}});return e.forEach(({name:c,options:u,get:i})=>{if(V.isDynamicVirtual(u)){const o=n.statics;o._dynamicVirtuals||(o._dynamicVirtuals=[]),o._dynamicVirtuals.push({name:c,options:u});const a=n.virtual(c);i?a.get(i):a.get(function(){var f;return((f=this._populated)==null?void 0:f[c])||(u!=null&&u.count?0:u!=null&&u.justOne?null:[])})}else{const o=n.virtual(c,u);i&&o.get(i)}}),r||n.add(V.createGenericSchema(s)),n},createModel({mongoose:s,name:t,schema:e,virtuals:r=[],pagination:n=!0,aggregate:c=!0,middlewares:u=[]}){if(!t)throw new Error("Model name is required.");if(s.models[t])return s.models[t];const i=V.createSchema({mongoose:s,schema:e,virtuals:r});return(n||c)&&V.applyPlugins(i,[n&&W,c&&K]),V.applyMiddlewares(i,u),s.model(t,i)},validator:{isRequired(){return function(s){return l(this,null,function*(){return!J.validate.isEmpty(s)})}},isUnique(s){return function(t){return l(this,null,function*(){if(!Array.isArray(s)||s.length===0)throw new Error("Fields must be a non-empty array of strings.");const e={$or:s.map(n=>({[n]:t}))};return!(yield this.constructor.exists(e))})}},matchesRegex(s){return function(t){return l(this,null,function*(){if(!Array.isArray(s)||s.some(e=>!(e instanceof RegExp)))throw new Error("regexArray must be an array of valid RegExp objects.");return s.every(e=>e.test(t))})}}},migrate:b(O({},k),{setConfig:s=>{const t=`// This file is automatically generated by the Cyberskill CLI.
2
- module.exports = ${JSON.stringify(s,null,4)}`;P.writeFileSync(T.PATH.MIGRATE_MONGO_CONFIG,t);const e=`
3
- ${T.MIGRATE_MONGO_CONFIG}
4
- `;P.pathExistsSync(T.PATH.GIT_IGNORE)?P.readFileSync(T.PATH.GIT_IGNORE,"utf-8").split(`
5
- `).includes(T.MIGRATE_MONGO_CONFIG)||P.appendFileSync(T.PATH.GIT_IGNORE,e):P.writeFileSync(T.PATH.GIT_IGNORE,e)}}),regexify(s,t){if(!s)return{};let e=I.cloneDeep(s);if(!t||t.length===0)return e;for(const r of t){const n=r.toString().split("."),c=$.getNestedValue(e,n);if(typeof c=="string"&&c.length>0){const u={$regex:`.*${Q.regexSearchMapper(c)}.*`,$options:"i"};e=$.setNestedValue(e,n,u)}}return e},isDynamicVirtual(s){return!!(s&&typeof s.ref=="function")}};function se(s){return s!==null&&typeof s=="object"&&"toObject"in s&&typeof s.toObject=="function"}function F(s,t){if(!s||!t||t.length===0)return s;const e=new Set(t.map(r=>r.name));if(Array.isArray(s)){const r=s.filter(n=>{if(typeof n=="string")return!e.has(n);if(typeof n=="object"&&n!==null){const c=n;return!e.has(c.path||c.populate||"")}return!0});return r.length>0?r:void 0}if(typeof s=="string")return e.has(s)?void 0:s;if(typeof s=="object"&&s!==null){const r=s,n=r.path||r.populate||"";return e.has(n)?void 0:s}return s}function ne(s,t,e){if(!s.length||!t||!(e!=null&&e.ref))return[];const r=new Map;return s.forEach(n=>{try{const c=e.ref(n);if(c==null)return;const u=typeof c=="string"?c:String(c);if(u&&u.trim()!==""){const i=re(u);r.has(i)||r.set(i,[]),r.get(i).push(n)}}catch(c){d.catchError(new Error(`Dynamic ref function failed for virtual "${t}": ${c instanceof Error?c.message:String(c)}`))}}),Array.from(r.entries()).map(([n,c])=>({model:n,docs:c}))}function L(s,t,e,r,n){return l(this,null,function*(){if(!t.length||!e.length||!r)return t;const c=e.filter(o=>{if(Array.isArray(r))return r.length>0&&r.some(a=>typeof a=="string"?a===o.name:a.path===o.name);if(typeof r=="string")return r===o.name;if(typeof r=="object"&&r!==null){const a=r;return a.path&&a.path===o.name||a.populate&&a.populate===o.name}return!1});if(c.length===0)return t;const u=I.cloneDeep(t.map(o=>se(o)?o.toObject():o));u.forEach(o=>{c.forEach(({name:a,options:f})=>{if(!(a in o)){const h=o;h[a]=f.count?0:f.justOne?null:[]}})});const i=new Map;for(const o of c){const{name:a,options:f}=o,h=ne(u,a,f);for(const S of h){i.has(S.model)||i.set(S.model,{virtuals:[],localValueSets:new Map,docsByLocalValue:new Map});const m=i.get(S.model);m.virtuals.find(N=>N.name===a)||(m.virtuals.push(o),m.localValueSets.set(a,new Set));const M=m.localValueSets.get(a);S.docs.forEach(N=>{const w=N[f.localField];if(w!=null){const _=String(w);M.add(_);let D=-1;const R=N;R.id!==void 0?D=u.findIndex(A=>A.id===R.id):R._id!==void 0&&(D=u.findIndex(A=>{var E,y,p,g;return((y=(E=A._id)==null?void 0:E.toString)==null?void 0:y.call(E))===((g=(p=R._id)==null?void 0:p.toString)==null?void 0:g.call(p))})),D!==-1&&(m.docsByLocalValue.has(_)||m.docsByLocalValue.set(_,[]),m.docsByLocalValue.get(_).push(D))}})}}return yield Promise.all(Array.from(i.entries()).map(o=>l(null,[o],function*([a,f]){const h=s.models[a];if(!h)return;const S=new Set;if(f.localValueSets.forEach(_=>{_.forEach(D=>S.add(D))}),S.size===0)return;const m=[...new Set(f.virtuals.map(_=>_.options.foreignField))],M=Array.from(S);let N;m.length===1?N={[String(m[0])]:{$in:M}}:N={$or:m.map(_=>({[_]:{$in:M}}))};const w=yield h.find(N,n).lean();for(const _ of f.virtuals){const{name:D,options:R}=_,A=w.filter(E=>{const y=E[R.foreignField];return y!=null&&S.has(String(y))});if(R.count){const E=new Map;A.forEach(y=>{var p;const g=(p=y[R.foreignField])==null?void 0:p.toString();g&&E.set(g,(E.get(g)||0)+1)}),f.localValueSets.get(D).forEach(y=>{const p=f.docsByLocalValue.get(y)||[],g=E.get(y)||0;p.forEach(C=>{const x=u[C];x[D]===void 0&&(x[D]=g)})})}else{const E=new Map;A.forEach(y=>{var p;const g=(p=y[R.foreignField])==null?void 0:p.toString();g&&(E.has(g)||E.set(g,[]),E.get(g).push(y))}),f.localValueSets.get(D).forEach(y=>{const p=f.docsByLocalValue.get(y)||[],g=E.get(y)||[],C=R.justOne?g[0]||null:g;p.forEach(x=>{const B=u[x];B[D]=C})})}}}))),u})}class ce{constructor(t,e){te(this,"collection"),this.collection=t.collection(e)}createOne(t){return l(this,null,function*(){try{const e=O(O({},V.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 d.catchError(e)}})}createMany(t){return l(this,null,function*(){try{const e=t.map(n=>O(O({},V.createGenericFields()),n)),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 d.catchError(e)}})}findOne(t){return l(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 d.catchError(e)}})}findAll(){return l(this,arguments,function*(t={}){try{return{success:!0,message:"Documents retrieved successfully",result:yield this.collection.find(t).toArray()}}catch(e){return d.catchError(e)}})}count(){return l(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 d.catchError(e)}})}updateOne(t,e){return l(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 d.catchError(r)}})}updateMany(t,e){return l(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 d.catchError(r)}})}deleteOne(t){return l(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 d.catchError(e)}})}deleteMany(t){return l(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 d.catchError(e)}})}}class ue{constructor(t){this.model=t}getModelName(){return this.model.modelName}getDynamicVirtuals(){return this.model.schema.statics._dynamicVirtuals}populateDynamicVirtualsForDocument(t,e){return l(this,null,function*(){const r=this.getDynamicVirtuals();if(r&&r.length>0){const n=yield L(this.model.base,[t],r,e);return n&&n[0]?n[0]:t}return t})}populateDynamicVirtualsForDocuments(t,e){return l(this,null,function*(){const r=this.getDynamicVirtuals();return r&&r.length>0&&t.length>0?yield L(this.model.base,t,r,e):t})}findOne(){return l(this,arguments,function*(t={},e={},r={},n){try{const c=this.model.findOne(t,e,r),u=this.getDynamicVirtuals(),i=F(n,u);i&&c.populate(i);const o=yield c.exec();return o?{success:!0,result:yield this.populateDynamicVirtualsForDocument(o,n)}:{success:!1,message:`No ${this.getModelName()} found.`,code:v.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(c){return d.catchError(c)}})}findAll(){return l(this,arguments,function*(t={},e={},r={},n){try{const c=this.model.find(t,e,r),u=this.getDynamicVirtuals(),i=F(n,u);i&&c.populate(i);const o=yield c.exec();return{success:!0,result:yield this.populateDynamicVirtualsForDocuments(o,n)}}catch(c){return d.catchError(c)}})}findPaging(){return l(this,arguments,function*(t={},e={}){try{const r=this.getDynamicVirtuals(),n=O({},e);e.populate&&(n.populate=F(e.populate,r));const c=yield this.model.paginate(t,n),u=yield this.populateDynamicVirtualsForDocuments(c.docs,e.populate);return{success:!0,result:b(O({},c),{docs:u})}}catch(r){return d.catchError(r)}})}findPagingAggregate(t){return l(this,arguments,function*(e,r={}){try{const n=this.getDynamicVirtuals(),c=O({},r);r.populate&&(c.populate=F(r.populate,n));const u=yield this.model.aggregatePaginate(this.model.aggregate(e),c),i=yield this.populateDynamicVirtualsForDocuments(u.docs,r.populate);return{success:!0,result:b(O({},u),{docs:i})}}catch(n){return d.catchError(n)}})}count(){return l(this,arguments,function*(t={}){try{return{success:!0,result:yield this.model.countDocuments(t)}}catch(e){return d.catchError(e)}})}createOne(t){return l(this,null,function*(){try{return{success:!0,result:yield this.model.create(t)}}catch(e){return d.catchError(e)}})}createMany(t){return l(this,arguments,function*(e,r={}){try{return{success:!0,result:(yield this.model.insertMany(e,r)).map(u=>u instanceof H.Document?u.toObject():null).filter(u=>u!==null)}}catch(n){return d.catchError(n)}})}updateOne(){return l(this,arguments,function*(t={},e={},r={}){try{const n=yield this.model.findOneAndUpdate(t,e,O({new:!0},r)).exec();return n?{success:!0,result:n}:{success:!1,message:`Failed to update ${this.getModelName()}.`,code:v.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(n){return d.catchError(n)}})}updateMany(){return l(this,arguments,function*(t={},e={},r={}){try{return{success:!0,result:yield this.model.updateMany(t,e,r).exec()}}catch(n){return d.catchError(n)}})}deleteOne(){return l(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 d.catchError(r)}})}deleteMany(){return l(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 d.catchError(r)}})}createShortId(t,e=4){return l(this,null,function*(){try{const n=Array.from({length:10},(i,o)=>j.generateShortId(t,o+e)),u=(yield Promise.all(n.map(i=>this.model.exists({shortId:i})))).findIndex(i=>!i);if(u!==-1){const i=n[u];if(i)return{success:!0,result:i}}return{success:!1,message:"Failed to create a unique shortId",code:v.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}catch(r){return d.catchError(r)}})}createSlugQuery({slug:t,field:e,isObject:r,filter:n}){const c=O({},n!=null?n:{});return r?b(O({},c),{$or:[{[`slug.${e}`]:t},{slugHistory:{$elemMatch:{[`slug.${e}`]:t}}}]}):b(O({},c),{$or:[{slug:t},{slugHistory:t}]})}createUniqueSlug(t){return l(this,arguments,function*({slug:e,field:r,isObject:n,filter:c}){const u=j.generateSlug(e),o=Array.from({length:100},(h,S)=>S===0?u:`${u}-${S}`),f=(yield Promise.all(o.map(h=>this.model.exists(this.createSlugQuery({slug:h,field:r,isObject:n,filter:c}))))).findIndex(h=>!h);if(f!==-1){const h=o[f];if(h)return h}return`${u}-${Date.now()}`})}createSlug(t){return l(this,arguments,function*({field:e,from:r,filter:n}){try{const c=r[e];return I.isObject(c)?{success:!0,result:Object.fromEntries(yield Promise.all(Object.entries(c).map(a=>l(this,[a],function*([f,h]){const S=yield this.createUniqueSlug({slug:h,field:f,isObject:!0,filter:n});return[f,S]}))))}:{success:!0,result:yield this.createUniqueSlug({slug:c,field:e,isObject:!1,filter:n})}}catch(c){return d.catchError(c)}})}checkSlug(t){return l(this,arguments,function*({slug:e,field:r,from:n,filter:c}){try{const u=n[r];if(I.isObject(u)){const h=Object.values(u).map(m=>j.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 o=j.generateSlug(e);return{success:!0,result:(yield this.model.exists(this.createSlugQuery({slug:o,field:r,isObject:!1,filter:c})))!==null}}catch(u){return d.catchError(u)}})}aggregate(t){return l(this,null,function*(){try{return{success:!0,result:yield this.model.aggregate(t)}}catch(e){return d.catchError(e)}})}}exports.MongoController=ce;exports.MongooseController=ue;exports.mongo=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("lodash-es"),H=require("migrate-mongo"),k=require("mongoose"),K=require("mongoose-aggregate-paginate-v2"),W=require("mongoose-paginate-v2"),U=require("uuid"),$=require("../../util/object/object.util.cjs"),Q=require("../../util/common/common.util.cjs"),P=require("../fs/fs.util.cjs"),A=require("../path/path.constant.cjs"),J=require("../../util/validate/validate.util.cjs"),j=require("../../util/string/string.util.cjs"),D=require("../../constant/response-status.cjs"),d=require("../log/log.util.cjs");var z=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable,q=(s,t,e)=>t in s?z(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,O=(s,t)=>{for(var e in t||(t={}))Z.call(t,e)&&q(s,e,t[e]);if(G)for(var e of G(t))ee.call(t,e)&&q(s,e,t[e]);return s},b=(s,t)=>X(s,Y(t)),te=(s,t,e)=>q(s,typeof t!="symbol"?t+"":t,e),l=(s,t,e)=>new Promise((r,n)=>{var c=o=>{try{i(e.next(o))}catch(a){n(a)}},u=o=>{try{i(e.throw(o))}catch(a){n(a)}},i=o=>o.done?r(o.value):Promise.resolve(o.value).then(c,u);i((e=e.apply(s,t)).next())});function re(s){return s===s.toUpperCase()?s.charAt(0).toUpperCase()+s.slice(1).toLowerCase():s}const V={createGenericFields(){return{id:U.v4(),isDel:!1,createdAt:new Date,updatedAt:new Date}},applyPlugins(s,t){t.filter(e=>typeof e=="function").forEach(e=>s.plugin(e))},applyMiddlewares(s,t){t.forEach(({method:e,pre:r,post:n})=>{e&&r&&s.pre(e,r),e&&n&&s.post(e,n)})},createGenericSchema(s){return new s.Schema({id:{type:String,default:U.v4,unique:!0},isDel:{type:Boolean,default:!1}},{timestamps:!0})},createSchema({mongoose:s,schema:t,virtuals:e=[],standalone:r=!1}){const n=new s.Schema(t,{toJSON:{virtuals:!0},toObject:{virtuals:!0}});return e.forEach(({name:c,options:u,get:i})=>{if(V.isDynamicVirtual(u)){const o=n.statics;o._dynamicVirtuals||(o._dynamicVirtuals=[]),o._dynamicVirtuals.push({name:c,options:u});const a=n.virtual(c);i?a.get(i):a.get(function(){var f;return((f=this._populated)==null?void 0:f[c])||(u!=null&&u.count?0:u!=null&&u.justOne?null:[])})}else{const o=n.virtual(c,u);i&&o.get(i)}}),r||n.add(V.createGenericSchema(s)),n},createModel({mongoose:s,name:t,schema:e,virtuals:r=[],pagination:n=!0,aggregate:c=!0,middlewares:u=[]}){if(!t)throw new Error("Model name is required.");if(s.models[t])return s.models[t];const i=V.createSchema({mongoose:s,schema:e,virtuals:r});return(n||c)&&V.applyPlugins(i,[n&&W,c&&K]),V.applyMiddlewares(i,u),s.model(t,i)},validator:{isRequired(){return function(s){return l(this,null,function*(){return!J.validate.isEmpty(s)})}},isUnique(s){return function(t){return l(this,null,function*(){if(!Array.isArray(s)||s.length===0)throw new Error("Fields must be a non-empty array of strings.");const e={$or:s.map(n=>({[n]:t}))};return!(yield this.constructor.exists(e))})}},matchesRegex(s){return function(t){return l(this,null,function*(){if(!Array.isArray(s)||s.some(e=>!(e instanceof RegExp)))throw new Error("regexArray must be an array of valid RegExp objects.");return s.every(e=>e.test(t))})}}},migrate:b(O({},H),{setConfig:s=>{const t=`// This file is automatically generated by the Cyberskill CLI.
2
+ module.exports = ${JSON.stringify(s,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(s,t){if(!s)return{};let e=I.cloneDeep(s);if(!t||t.length===0)return e;for(const r of t){const n=r.toString().split("."),c=$.getNestedValue(e,n);if(typeof c=="string"&&c.length>0){const u={$regex:`.*${Q.regexSearchMapper(c)}.*`,$options:"i"};e=$.setNestedValue(e,n,u)}}return e},isDynamicVirtual(s){return!!(s&&typeof s.ref=="function")},getNewRecords(s,t,e){return l(this,null,function*(){const r=yield s.findAll({});return r.success?t.filter(c=>!r.result.some(u=>e(u,c))):t})},getExistingRecords(s,t,e){return l(this,null,function*(){const r=yield s.findAll({});return r.success?r.result.filter(c=>t.some(u=>e(c,u))):[]})}};function se(s){return s!==null&&typeof s=="object"&&"toObject"in s&&typeof s.toObject=="function"}function F(s,t){if(!s||!t||t.length===0)return s;const e=new Set(t.map(r=>r.name));if(Array.isArray(s)){const r=s.filter(n=>{if(typeof n=="string")return!e.has(n);if(typeof n=="object"&&n!==null){const c=n;return!e.has(c.path||c.populate||"")}return!0});return r.length>0?r:void 0}if(typeof s=="string")return e.has(s)?void 0:s;if(typeof s=="object"&&s!==null){const r=s,n=r.path||r.populate||"";return e.has(n)?void 0:s}return s}function ne(s,t,e){if(!s.length||!t||!(e!=null&&e.ref))return[];const r=new Map;return s.forEach(n=>{try{const c=e.ref(n);if(c==null)return;const u=typeof c=="string"?c:String(c);if(u&&u.trim()!==""){const i=re(u);r.has(i)||r.set(i,[]),r.get(i).push(n)}}catch(c){d.catchError(new Error(`Dynamic ref function failed for virtual "${t}": ${c instanceof Error?c.message:String(c)}`))}}),Array.from(r.entries()).map(([n,c])=>({model:n,docs:c}))}function L(s,t,e,r,n){return l(this,null,function*(){if(!t.length||!e.length||!r)return t;const c=e.filter(o=>{if(Array.isArray(r))return r.length>0&&r.some(a=>typeof a=="string"?a===o.name:a.path===o.name);if(typeof r=="string")return r===o.name;if(typeof r=="object"&&r!==null){const a=r;return a.path&&a.path===o.name||a.populate&&a.populate===o.name}return!1});if(c.length===0)return t;const u=I.cloneDeep(t.map(o=>se(o)?o.toObject():o));u.forEach(o=>{c.forEach(({name:a,options:f})=>{if(!(a in o)){const h=o;h[a]=f.count?0:f.justOne?null:[]}})});const i=new Map;for(const o of c){const{name:a,options:f}=o,h=ne(u,a,f);for(const E of h){i.has(E.model)||i.set(E.model,{virtuals:[],localValueSets:new Map,docsByLocalValue:new Map});const m=i.get(E.model);m.virtuals.find(N=>N.name===a)||(m.virtuals.push(o),m.localValueSets.set(a,new Set));const M=m.localValueSets.get(a);E.docs.forEach(N=>{const x=N[f.localField];if(x!=null){const _=String(x);M.add(_);let R=-1;const v=N;v.id!==void 0?R=u.findIndex(T=>T.id===v.id):v._id!==void 0&&(R=u.findIndex(T=>{var S,y,p,g;return((y=(S=T._id)==null?void 0:S.toString)==null?void 0:y.call(S))===((g=(p=v._id)==null?void 0:p.toString)==null?void 0:g.call(p))})),R!==-1&&(m.docsByLocalValue.has(_)||m.docsByLocalValue.set(_,[]),m.docsByLocalValue.get(_).push(R))}})}}return yield Promise.all(Array.from(i.entries()).map(o=>l(null,[o],function*([a,f]){const h=s.models[a];if(!h)return;const E=new Set;if(f.localValueSets.forEach(_=>{_.forEach(R=>E.add(R))}),E.size===0)return;const m=[...new Set(f.virtuals.map(_=>_.options.foreignField))],M=Array.from(E);let N;m.length===1?N={[String(m[0])]:{$in:M}}:N={$or:m.map(_=>({[_]:{$in:M}}))};const x=yield h.find(N,n).lean();for(const _ of f.virtuals){const{name:R,options:v}=_,T=x.filter(S=>{const y=S[v.foreignField];return y!=null&&E.has(String(y))});if(v.count){const S=new Map;T.forEach(y=>{var p;const g=(p=y[v.foreignField])==null?void 0:p.toString();g&&S.set(g,(S.get(g)||0)+1)}),f.localValueSets.get(R).forEach(y=>{const p=f.docsByLocalValue.get(y)||[],g=S.get(y)||0;p.forEach(w=>{const C=u[w];C[R]===void 0&&(C[R]=g)})})}else{const S=new Map;T.forEach(y=>{var p;const g=(p=y[v.foreignField])==null?void 0:p.toString();g&&(S.has(g)||S.set(g,[]),S.get(g).push(y))}),f.localValueSets.get(R).forEach(y=>{const p=f.docsByLocalValue.get(y)||[],g=S.get(y)||[],w=v.justOne?g[0]||null:g;p.forEach(C=>{const B=u[C];B[R]=w})})}}}))),u})}class ce{constructor(t,e){te(this,"collection"),this.collection=t.collection(e)}createOne(t){return l(this,null,function*(){try{const e=O(O({},V.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 d.catchError(e)}})}createMany(t){return l(this,null,function*(){try{const e=t.map(n=>O(O({},V.createGenericFields()),n)),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 d.catchError(e)}})}findOne(t){return l(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 d.catchError(e)}})}findAll(){return l(this,arguments,function*(t={}){try{return{success:!0,message:"Documents retrieved successfully",result:yield this.collection.find(t).toArray()}}catch(e){return d.catchError(e)}})}count(){return l(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 d.catchError(e)}})}updateOne(t,e){return l(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 d.catchError(r)}})}updateMany(t,e){return l(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 d.catchError(r)}})}deleteOne(t){return l(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 d.catchError(e)}})}deleteMany(t){return l(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 d.catchError(e)}})}}class ue{constructor(t){this.model=t}getModelName(){return this.model.modelName}getDynamicVirtuals(){return this.model.schema.statics._dynamicVirtuals}populateDynamicVirtualsForDocument(t,e){return l(this,null,function*(){const r=this.getDynamicVirtuals();if(r&&r.length>0){const n=yield L(this.model.base,[t],r,e);return n&&n[0]?n[0]:t}return t})}populateDynamicVirtualsForDocuments(t,e){return l(this,null,function*(){const r=this.getDynamicVirtuals();return r&&r.length>0&&t.length>0?yield L(this.model.base,t,r,e):t})}findOne(){return l(this,arguments,function*(t={},e={},r={},n){try{const c=this.model.findOne(t,e,r),u=this.getDynamicVirtuals(),i=F(n,u);i&&c.populate(i);const o=yield c.exec();return o?{success:!0,result:yield this.populateDynamicVirtualsForDocument(o,n)}:{success:!1,message:`No ${this.getModelName()} found.`,code:D.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(c){return d.catchError(c)}})}findAll(){return l(this,arguments,function*(t={},e={},r={},n){try{const c=this.model.find(t,e,r),u=this.getDynamicVirtuals(),i=F(n,u);i&&c.populate(i);const o=yield c.exec();return{success:!0,result:yield this.populateDynamicVirtualsForDocuments(o,n)}}catch(c){return d.catchError(c)}})}findPaging(){return l(this,arguments,function*(t={},e={}){try{const r=this.getDynamicVirtuals(),n=O({},e);e.populate&&(n.populate=F(e.populate,r));const c=yield this.model.paginate(t,n),u=yield this.populateDynamicVirtualsForDocuments(c.docs,e.populate);return{success:!0,result:b(O({},c),{docs:u})}}catch(r){return d.catchError(r)}})}findPagingAggregate(t){return l(this,arguments,function*(e,r={}){try{const n=this.getDynamicVirtuals(),c=O({},r);r.populate&&(c.populate=F(r.populate,n));const u=yield this.model.aggregatePaginate(this.model.aggregate(e),c),i=yield this.populateDynamicVirtualsForDocuments(u.docs,r.populate);return{success:!0,result:b(O({},u),{docs:i})}}catch(n){return d.catchError(n)}})}count(){return l(this,arguments,function*(t={}){try{return{success:!0,result:yield this.model.countDocuments(t)}}catch(e){return d.catchError(e)}})}createOne(t){return l(this,null,function*(){try{return{success:!0,result:yield this.model.create(t)}}catch(e){return d.catchError(e)}})}createMany(t){return l(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(n){return d.catchError(n)}})}updateOne(){return l(this,arguments,function*(t={},e={},r={}){try{const n=yield this.model.findOneAndUpdate(t,e,O({new:!0},r)).exec();return n?{success:!0,result:n}:{success:!1,message:`Failed to update ${this.getModelName()}.`,code:D.RESPONSE_STATUS.NOT_FOUND.CODE}}catch(n){return d.catchError(n)}})}updateMany(){return l(this,arguments,function*(t={},e={},r={}){try{return{success:!0,result:yield this.model.updateMany(t,e,r).exec()}}catch(n){return d.catchError(n)}})}deleteOne(){return l(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 d.catchError(r)}})}deleteMany(){return l(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 d.catchError(r)}})}createShortId(t,e=4){return l(this,null,function*(){try{const n=Array.from({length:10},(i,o)=>j.generateShortId(t,o+e)),u=(yield Promise.all(n.map(i=>this.model.exists({shortId:i})))).findIndex(i=>!i);if(u!==-1){const i=n[u];if(i)return{success:!0,result:i}}return{success:!1,message:"Failed to create a unique shortId",code:D.RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE}}catch(r){return d.catchError(r)}})}createSlugQuery({slug:t,field:e,isObject:r,filter:n}){const c=O({},n!=null?n:{});return r?b(O({},c),{$or:[{[`slug.${e}`]:t},{slugHistory:{$elemMatch:{[`slug.${e}`]:t}}}]}):b(O({},c),{$or:[{slug:t},{slugHistory:t}]})}createUniqueSlug(t){return l(this,arguments,function*({slug:e,field:r,isObject:n,filter:c}){const u=j.generateSlug(e),o=Array.from({length:100},(h,E)=>E===0?u:`${u}-${E}`),f=(yield Promise.all(o.map(h=>this.model.exists(this.createSlugQuery({slug:h,field:r,isObject:n,filter:c}))))).findIndex(h=>!h);if(f!==-1){const h=o[f];if(h)return h}return`${u}-${Date.now()}`})}createSlug(t){return l(this,arguments,function*({field:e,from:r,filter:n}){try{const c=r[e];return I.isObject(c)?{success:!0,result:Object.fromEntries(yield Promise.all(Object.entries(c).map(a=>l(this,[a],function*([f,h]){const E=yield this.createUniqueSlug({slug:h,field:f,isObject:!0,filter:n});return[f,E]}))))}:{success:!0,result:yield this.createUniqueSlug({slug:c,field:e,isObject:!1,filter:n})}}catch(c){return d.catchError(c)}})}checkSlug(t){return l(this,arguments,function*({slug:e,field:r,from:n,filter:c}){try{const u=n[r];if(I.isObject(u)){const h=Object.values(u).map(m=>j.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 o=j.generateSlug(e);return{success:!0,result:(yield this.model.exists(this.createSlugQuery({slug:o,field:r,isObject:!1,filter:c})))!==null}}catch(u){return d.catchError(u)}})}aggregate(t){return l(this,null,function*(){try{return{success:!0,result:yield this.model.aggregate(t)}}catch(e){return d.catchError(e)}})}}exports.MongoController=ce;exports.MongooseController=ue;exports.mongo=V;
@@ -160,6 +160,22 @@ export declare const mongo: {
160
160
  * @returns True if the options contain a dynamic ref function.
161
161
  */
162
162
  isDynamicVirtual<T, R extends string = string>(options?: T_VirtualOptions<T, R>): options is I_DynamicVirtualOptions<T, R>;
163
+ /**
164
+ * Generic utility function to get new records from the database
165
+ * @param controller - MongoController instance
166
+ * @param recordsToCheck - Array of records to check
167
+ * @param filterFn - Function to determine if a record already exists
168
+ * @returns Array of records that don't exist in the database
169
+ */
170
+ getNewRecords<T extends I_GenericDocument>(controller: MongoController<T>, recordsToCheck: T[], filterFn: (existingRecord: T_WithId<T>, newRecord: T) => boolean): Promise<T[]>;
171
+ /**
172
+ * Generic utility function to get existing records that match the filter criteria
173
+ * @param controller - MongoController instance
174
+ * @param recordsToCheck - Array of records to check
175
+ * @param filterFn - Function to determine if a record exists
176
+ * @returns Array of existing records that match the filter criteria
177
+ */
178
+ getExistingRecords<T extends I_GenericDocument>(controller: MongoController<T>, recordsToCheck: T[], filterFn: (existingRecord: T_WithId<T>, newRecord: T) => boolean): Promise<T_WithId<T>[]>;
163
179
  };
164
180
  /**
165
181
  * MongoDB native driver controller for direct database operations.
@@ -1,9 +1,9 @@
1
- import { cloneDeep as B, isObject as T } from "lodash-es";
1
+ import { cloneDeep as B, isObject as $ } from "lodash-es";
2
2
  import K from "migrate-mongo";
3
3
  import { Document as W } from "mongoose";
4
4
  import Q from "mongoose-aggregate-paginate-v2";
5
5
  import H from "mongoose-paginate-v2";
6
- import { v4 as $ } from "uuid";
6
+ import { v4 as T } from "uuid";
7
7
  import { getNestedValue as J, setNestedValue as z } from "../../util/object/object.util.js";
8
8
  import { regexSearchMapper as X } from "../../util/common/common.util.js";
9
9
  import { writeFileSync as G, pathExistsSync as Y, readFileSync as Z, appendFileSync as ee } from "../fs/fs.util.js";
@@ -12,28 +12,28 @@ import { validate as te } from "../../util/validate/validate.util.js";
12
12
  import { generateShortId as re, generateSlug as I } from "../../util/string/string.util.js";
13
13
  import { RESPONSE_STATUS as v } from "../../constant/response-status.js";
14
14
  import { catchError as d } from "../log/log.util.js";
15
- var se = Object.defineProperty, ne = Object.defineProperties, ue = Object.getOwnPropertyDescriptors, L = Object.getOwnPropertySymbols, ce = Object.prototype.hasOwnProperty, oe = Object.prototype.propertyIsEnumerable, j = (s, t, e) => t in s ? se(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, S = (s, t) => {
15
+ var se = Object.defineProperty, ne = Object.defineProperties, ue = Object.getOwnPropertyDescriptors, L = Object.getOwnPropertySymbols, ce = Object.prototype.hasOwnProperty, ie = Object.prototype.propertyIsEnumerable, j = (s, t, e) => t in s ? se(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, S = (s, t) => {
16
16
  for (var e in t || (t = {}))
17
17
  ce.call(t, e) && j(s, e, t[e]);
18
18
  if (L)
19
19
  for (var e of L(t))
20
- oe.call(t, e) && j(s, e, t[e]);
20
+ ie.call(t, e) && j(s, e, t[e]);
21
21
  return s;
22
- }, w = (s, t) => ne(s, ue(t)), ie = (s, t, e) => j(s, typeof t != "symbol" ? t + "" : t, e), l = (s, t, e) => new Promise((r, n) => {
23
- var u = (o) => {
22
+ }, w = (s, t) => ne(s, ue(t)), oe = (s, t, e) => j(s, typeof t != "symbol" ? t + "" : t, e), l = (s, t, e) => new Promise((r, n) => {
23
+ var u = (i) => {
24
24
  try {
25
- i(e.next(o));
25
+ o(e.next(i));
26
26
  } catch (a) {
27
27
  n(a);
28
28
  }
29
- }, c = (o) => {
29
+ }, c = (i) => {
30
30
  try {
31
- i(e.throw(o));
31
+ o(e.throw(i));
32
32
  } catch (a) {
33
33
  n(a);
34
34
  }
35
- }, i = (o) => o.done ? r(o.value) : Promise.resolve(o.value).then(u, c);
36
- i((e = e.apply(s, t)).next());
35
+ }, o = (i) => i.done ? r(i.value) : Promise.resolve(i.value).then(u, c);
36
+ o((e = e.apply(s, t)).next());
37
37
  });
38
38
  function le(s) {
39
39
  return s === s.toUpperCase() ? s.charAt(0).toUpperCase() + s.slice(1).toLowerCase() : s;
@@ -48,7 +48,7 @@ const V = {
48
48
  */
49
49
  createGenericFields() {
50
50
  return {
51
- id: $(),
51
+ id: T(),
52
52
  isDel: !1,
53
53
  createdAt: /* @__PURE__ */ new Date(),
54
54
  updatedAt: /* @__PURE__ */ new Date()
@@ -88,7 +88,7 @@ const V = {
88
88
  createGenericSchema(s) {
89
89
  return new s.Schema(
90
90
  {
91
- id: { type: String, default: $, unique: !0 },
91
+ id: { type: String, default: T, unique: !0 },
92
92
  isDel: { type: Boolean, default: !1 }
93
93
  },
94
94
  { timestamps: !0 }
@@ -118,21 +118,21 @@ const V = {
118
118
  toObject: { virtuals: !0 }
119
119
  // So `console.log()` and other functions that use `toObject()` include virtuals
120
120
  });
121
- return e.forEach(({ name: u, options: c, get: i }) => {
121
+ return e.forEach(({ name: u, options: c, get: o }) => {
122
122
  if (V.isDynamicVirtual(c)) {
123
- const o = n.statics;
124
- o._dynamicVirtuals || (o._dynamicVirtuals = []), o._dynamicVirtuals.push({
123
+ const i = n.statics;
124
+ i._dynamicVirtuals || (i._dynamicVirtuals = []), i._dynamicVirtuals.push({
125
125
  name: u,
126
126
  options: c
127
127
  });
128
128
  const a = n.virtual(u);
129
- i ? a.get(i) : a.get(function() {
129
+ o ? a.get(o) : a.get(function() {
130
130
  var f;
131
131
  return ((f = this._populated) == null ? void 0 : f[u]) || (c != null && c.count ? 0 : c != null && c.justOne ? null : []);
132
132
  });
133
133
  } else {
134
- const o = n.virtual(u, c);
135
- i && o.get(i);
134
+ const i = n.virtual(u, c);
135
+ o && i.get(o);
136
136
  }
137
137
  }), r || n.add(V.createGenericSchema(s)), n;
138
138
  },
@@ -165,11 +165,11 @@ const V = {
165
165
  throw new Error("Model name is required.");
166
166
  if (s.models[t])
167
167
  return s.models[t];
168
- const i = V.createSchema({ mongoose: s, schema: e, virtuals: r });
169
- return (n || u) && V.applyPlugins(i, [
168
+ const o = V.createSchema({ mongoose: s, schema: e, virtuals: r });
169
+ return (n || u) && V.applyPlugins(o, [
170
170
  n && H,
171
171
  u && Q
172
- ]), V.applyMiddlewares(i, c), s.model(t, i);
172
+ ]), V.applyMiddlewares(o, c), s.model(t, o);
173
173
  },
174
174
  /**
175
175
  * Validation utilities for Mongoose schemas.
@@ -286,6 +286,40 @@ ${q}
286
286
  */
287
287
  isDynamicVirtual(s) {
288
288
  return !!(s && typeof s.ref == "function");
289
+ },
290
+ /**
291
+ * Generic utility function to get new records from the database
292
+ * @param controller - MongoController instance
293
+ * @param recordsToCheck - Array of records to check
294
+ * @param filterFn - Function to determine if a record already exists
295
+ * @returns Array of records that don't exist in the database
296
+ */
297
+ getNewRecords(s, t, e) {
298
+ return l(this, null, function* () {
299
+ const r = yield s.findAll({});
300
+ return r.success ? t.filter(
301
+ (u) => !r.result.some(
302
+ (c) => e(c, u)
303
+ )
304
+ ) : t;
305
+ });
306
+ },
307
+ /**
308
+ * Generic utility function to get existing records that match the filter criteria
309
+ * @param controller - MongoController instance
310
+ * @param recordsToCheck - Array of records to check
311
+ * @param filterFn - Function to determine if a record exists
312
+ * @returns Array of existing records that match the filter criteria
313
+ */
314
+ getExistingRecords(s, t, e) {
315
+ return l(this, null, function* () {
316
+ const r = yield s.findAll({});
317
+ return r.success ? r.result.filter(
318
+ (u) => t.some(
319
+ (c) => e(u, c)
320
+ )
321
+ ) : [];
322
+ });
289
323
  }
290
324
  };
291
325
  function ae(s) {
@@ -326,8 +360,8 @@ function de(s, t, e) {
326
360
  return;
327
361
  const c = typeof u == "string" ? u : String(u);
328
362
  if (c && c.trim() !== "") {
329
- const i = le(c);
330
- r.has(i) || r.set(i, []), r.get(i).push(n);
363
+ const o = le(c);
364
+ r.has(o) || r.set(o, []), r.get(o).push(n);
331
365
  }
332
366
  } catch (u) {
333
367
  d(new Error(`Dynamic ref function failed for virtual "${t}": ${u instanceof Error ? u.message : String(u)}`));
@@ -338,47 +372,47 @@ function U(s, t, e, r, n) {
338
372
  return l(this, null, function* () {
339
373
  if (!t.length || !e.length || !r)
340
374
  return t;
341
- const u = e.filter((o) => {
375
+ const u = e.filter((i) => {
342
376
  if (Array.isArray(r))
343
- return r.length > 0 && r.some((a) => typeof a == "string" ? a === o.name : a.path === o.name);
377
+ return r.length > 0 && r.some((a) => typeof a == "string" ? a === i.name : a.path === i.name);
344
378
  if (typeof r == "string")
345
- return r === o.name;
379
+ return r === i.name;
346
380
  if (typeof r == "object" && r !== null) {
347
381
  const a = r;
348
- return a.path && a.path === o.name || a.populate && a.populate === o.name;
382
+ return a.path && a.path === i.name || a.populate && a.populate === i.name;
349
383
  }
350
384
  return !1;
351
385
  });
352
386
  if (u.length === 0)
353
387
  return t;
354
388
  const c = B(t.map(
355
- (o) => ae(o) ? o.toObject() : o
389
+ (i) => ae(i) ? i.toObject() : i
356
390
  ));
357
- c.forEach((o) => {
391
+ c.forEach((i) => {
358
392
  u.forEach(({ name: a, options: f }) => {
359
- if (!(a in o)) {
360
- const m = o;
393
+ if (!(a in i)) {
394
+ const m = i;
361
395
  m[a] = f.count ? 0 : f.justOne ? null : [];
362
396
  }
363
397
  });
364
398
  });
365
- const i = /* @__PURE__ */ new Map();
366
- for (const o of u) {
367
- const { name: a, options: f } = o, m = de(c, a, f);
399
+ const o = /* @__PURE__ */ new Map();
400
+ for (const i of u) {
401
+ const { name: a, options: f } = i, m = de(c, a, f);
368
402
  for (const p of m) {
369
- i.has(p.model) || i.set(p.model, {
403
+ o.has(p.model) || o.set(p.model, {
370
404
  virtuals: [],
371
405
  localValueSets: /* @__PURE__ */ new Map(),
372
406
  docsByLocalValue: /* @__PURE__ */ new Map()
373
407
  });
374
- const h = i.get(p.model);
375
- h.virtuals.find((N) => N.name === a) || (h.virtuals.push(o), h.localValueSets.set(a, /* @__PURE__ */ new Set()));
376
- const M = h.localValueSets.get(a);
408
+ const h = o.get(p.model);
409
+ h.virtuals.find((N) => N.name === a) || (h.virtuals.push(i), h.localValueSets.set(a, /* @__PURE__ */ new Set()));
410
+ const A = h.localValueSets.get(a);
377
411
  p.docs.forEach((N) => {
378
- const C = N[f.localField];
379
- if (C != null) {
380
- const D = String(C);
381
- M.add(D);
412
+ const M = N[f.localField];
413
+ if (M != null) {
414
+ const D = String(M);
415
+ A.add(D);
382
416
  let _ = -1;
383
417
  const R = N;
384
418
  R.id !== void 0 ? _ = c.findIndex((b) => b.id === R.id) : R._id !== void 0 && (_ = c.findIndex((b) => {
@@ -389,7 +423,7 @@ function U(s, t, e, r, n) {
389
423
  });
390
424
  }
391
425
  }
392
- return yield Promise.all(Array.from(i.entries()).map((o) => l(null, [o], function* ([a, f]) {
426
+ return yield Promise.all(Array.from(o.entries()).map((i) => l(null, [i], function* ([a, f]) {
393
427
  const m = s.models[a];
394
428
  if (!m)
395
429
  return;
@@ -398,12 +432,12 @@ function U(s, t, e, r, n) {
398
432
  D.forEach((_) => p.add(_));
399
433
  }), p.size === 0)
400
434
  return;
401
- const h = [...new Set(f.virtuals.map((D) => D.options.foreignField))], M = Array.from(p);
435
+ const h = [...new Set(f.virtuals.map((D) => D.options.foreignField))], A = Array.from(p);
402
436
  let N;
403
- h.length === 1 ? N = { [String(h[0])]: { $in: M } } : N = { $or: h.map((D) => ({ [D]: { $in: M } })) };
404
- const C = yield m.find(N, n).lean();
437
+ h.length === 1 ? N = { [String(h[0])]: { $in: A } } : N = { $or: h.map((D) => ({ [D]: { $in: A } })) };
438
+ const M = yield m.find(N, n).lean();
405
439
  for (const D of f.virtuals) {
406
- const { name: _, options: R } = D, b = C.filter((O) => {
440
+ const { name: _, options: R } = D, b = M.filter((O) => {
407
441
  const y = O[R.foreignField];
408
442
  return y != null && p.has(String(y));
409
443
  });
@@ -415,8 +449,8 @@ function U(s, t, e, r, n) {
415
449
  g && O.set(g, (O.get(g) || 0) + 1);
416
450
  }), f.localValueSets.get(_).forEach((y) => {
417
451
  const E = f.docsByLocalValue.get(y) || [], g = O.get(y) || 0;
418
- E.forEach((A) => {
419
- const P = c[A];
452
+ E.forEach((C) => {
453
+ const P = c[C];
420
454
  P[_] === void 0 && (P[_] = g);
421
455
  });
422
456
  });
@@ -427,10 +461,10 @@ function U(s, t, e, r, n) {
427
461
  const g = (E = y[R.foreignField]) == null ? void 0 : E.toString();
428
462
  g && (O.has(g) || O.set(g, []), O.get(g).push(y));
429
463
  }), f.localValueSets.get(_).forEach((y) => {
430
- const E = f.docsByLocalValue.get(y) || [], g = O.get(y) || [], A = R.justOne ? g[0] || null : g;
464
+ const E = f.docsByLocalValue.get(y) || [], g = O.get(y) || [], C = R.justOne ? g[0] || null : g;
431
465
  E.forEach((P) => {
432
466
  const k = c[P];
433
- k[_] = A;
467
+ k[_] = C;
434
468
  });
435
469
  });
436
470
  }
@@ -446,7 +480,7 @@ class Ve {
446
480
  * @param collectionName - The name of the collection to operate on.
447
481
  */
448
482
  constructor(t, e) {
449
- ie(this, "collection"), this.collection = t.collection(e);
483
+ oe(this, "collection"), this.collection = t.collection(e);
450
484
  }
451
485
  /**
452
486
  * Creates a single document in the collection.
@@ -724,10 +758,10 @@ class be {
724
758
  findOne() {
725
759
  return l(this, arguments, function* (t = {}, e = {}, r = {}, n) {
726
760
  try {
727
- const u = this.model.findOne(t, e, r), c = this.getDynamicVirtuals(), i = F(n, c);
728
- i && u.populate(i);
729
- const o = yield u.exec();
730
- return o ? { success: !0, result: yield this.populateDynamicVirtualsForDocument(o, n) } : {
761
+ const u = this.model.findOne(t, e, r), c = this.getDynamicVirtuals(), o = F(n, c);
762
+ o && u.populate(o);
763
+ const i = yield u.exec();
764
+ return i ? { success: !0, result: yield this.populateDynamicVirtualsForDocument(i, n) } : {
731
765
  success: !1,
732
766
  message: `No ${this.getModelName()} found.`,
733
767
  code: v.NOT_FOUND.CODE
@@ -750,10 +784,10 @@ class be {
750
784
  findAll() {
751
785
  return l(this, arguments, function* (t = {}, e = {}, r = {}, n) {
752
786
  try {
753
- const u = this.model.find(t, e, r), c = this.getDynamicVirtuals(), i = F(n, c);
754
- i && u.populate(i);
755
- const o = yield u.exec();
756
- return { success: !0, result: yield this.populateDynamicVirtualsForDocuments(o, n) };
787
+ const u = this.model.find(t, e, r), c = this.getDynamicVirtuals(), o = F(n, c);
788
+ o && u.populate(o);
789
+ const i = yield u.exec();
790
+ return { success: !0, result: yield this.populateDynamicVirtualsForDocuments(i, n) };
757
791
  } catch (u) {
758
792
  return d(u);
759
793
  }
@@ -794,8 +828,8 @@ class be {
794
828
  const c = yield this.model.aggregatePaginate(
795
829
  this.model.aggregate(e),
796
830
  u
797
- ), i = yield this.populateDynamicVirtualsForDocuments(c.docs, r.populate);
798
- return { success: !0, result: w(S({}, c), { docs: i }) };
831
+ ), o = yield this.populateDynamicVirtualsForDocuments(c.docs, r.populate);
832
+ return { success: !0, result: w(S({}, c), { docs: o }) };
799
833
  } catch (n) {
800
834
  return d(n);
801
835
  }
@@ -941,13 +975,13 @@ class be {
941
975
  createShortId(t, e = 4) {
942
976
  return l(this, null, function* () {
943
977
  try {
944
- const n = Array.from({ length: 10 }, (i, o) => re(t, o + e)), c = (yield Promise.all(
945
- n.map((i) => this.model.exists({ shortId: i }))
946
- )).findIndex((i) => !i);
978
+ const n = Array.from({ length: 10 }, (o, i) => re(t, i + e)), c = (yield Promise.all(
979
+ n.map((o) => this.model.exists({ shortId: o }))
980
+ )).findIndex((o) => !o);
947
981
  if (c !== -1) {
948
- const i = n[c];
949
- if (i)
950
- return { success: !0, result: i };
982
+ const o = n[c];
983
+ if (o)
984
+ return { success: !0, result: o };
951
985
  }
952
986
  return {
953
987
  success: !1,
@@ -997,13 +1031,13 @@ class be {
997
1031
  */
998
1032
  createUniqueSlug(t) {
999
1033
  return l(this, arguments, function* ({ slug: e, field: r, isObject: n, filter: u }) {
1000
- const c = I(e), o = Array.from({ length: 100 }, (m, p) => p === 0 ? c : `${c}-${p}`), f = (yield Promise.all(
1001
- o.map(
1034
+ const c = I(e), i = Array.from({ length: 100 }, (m, p) => p === 0 ? c : `${c}-${p}`), f = (yield Promise.all(
1035
+ i.map(
1002
1036
  (m) => this.model.exists(this.createSlugQuery({ slug: m, field: r, isObject: n, filter: u }))
1003
1037
  )
1004
1038
  )).findIndex((m) => !m);
1005
1039
  if (f !== -1) {
1006
- const m = o[f];
1040
+ const m = i[f];
1007
1041
  if (m)
1008
1042
  return m;
1009
1043
  }
@@ -1024,7 +1058,7 @@ class be {
1024
1058
  return l(this, arguments, function* ({ field: e, from: r, filter: n }) {
1025
1059
  try {
1026
1060
  const u = r[e];
1027
- return T(u) ? { success: !0, result: Object.fromEntries(
1061
+ return $(u) ? { success: !0, result: Object.fromEntries(
1028
1062
  yield Promise.all(
1029
1063
  Object.entries(u).map((a) => l(this, [a], function* ([f, m]) {
1030
1064
  const p = yield this.createUniqueSlug({
@@ -1062,7 +1096,7 @@ class be {
1062
1096
  return l(this, arguments, function* ({ slug: e, field: r, from: n, filter: u }) {
1063
1097
  try {
1064
1098
  const c = n[r];
1065
- if (T(c)) {
1099
+ if ($(c)) {
1066
1100
  const m = Object.values(c).map((h) => I(h));
1067
1101
  return (yield Promise.all(
1068
1102
  m.map(
@@ -1075,9 +1109,9 @@ class be {
1075
1109
  )
1076
1110
  )).some((h) => h) ? { success: !0, result: !0 } : { success: !0, result: !1 };
1077
1111
  }
1078
- const o = I(e);
1112
+ const i = I(e);
1079
1113
  return { success: !0, result: (yield this.model.exists(this.createSlugQuery({
1080
- slug: o,
1114
+ slug: i,
1081
1115
  field: r,
1082
1116
  isObject: !1,
1083
1117
  filter: u
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("lodash-es");var l=Object.defineProperty,d=Object.defineProperties,y=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,a=(e,r,t)=>r in e?l(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,p=(e,r)=>{for(var t in r||(r={}))_.call(r,t)&&a(e,t,r[t]);if(u)for(var t of u(r))O.call(r,t)&&a(e,t,r[t]);return e},f=(e,r)=>d(e,y(r));function P(e){try{return JSON.parse(e),!0}catch(r){return!1}}function g(e,r){return r.reduce((t,n)=>{if(t&&typeof t=="object"&&n in t)return t[n]},e)}function c(e,r,t){if(r.length===0)return e;const[n,...i]=r;if(i.length===0)return f(p({},e),{[n]:t});const s=e[n];return f(p({},e),{[n]:c(typeof s=="object"&&s!==null?s:{},i,t)})}function v(...e){if(e.every(o.isArray))return[].concat(...e);if(e.every(o.isPlainObject))return o.mergeWith({},...e,(r,t)=>{if(o.isArray(r)&&o.isArray(t))return r.concat(t)});throw new Error("deepMerge: All arguments must be either arrays or objects of the same type.")}exports.deepMerge=v;exports.getNestedValue=g;exports.isJSON=P;exports.setNestedValue=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("lodash-es");var c=Object.defineProperty,y=Object.defineProperties,d=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,a=(t,e,n)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,l=(t,e)=>{for(var n in e||(e={}))m.call(e,n)&&a(t,n,e[n]);if(u)for(var n of u(e))v.call(e,n)&&a(t,n,e[n]);return t},f=(t,e)=>y(t,d(e));function g(t){try{return JSON.parse(t),!0}catch(e){return!1}}function _(t,e){return e.reduce((n,o)=>{if(n&&typeof n=="object"&&o in n)return n[o]},t)}function p(t,e,n){if(e.length===0)return t;const[o,...r]=e;if(r.length===0)return f(l({},t),{[o]:n});const i=t[o];return f(l({},t),{[o]:p(typeof i=="object"&&i!==null?i:{},r,n)})}function h(...t){if(t.length===0)return{};const e=t.filter(r=>r!=null).map(r=>typeof r!="object"?{}:r);if(e.length===0)return{};if(e.length===1)return e[0];if(e.every(s.isArray))return[].concat(...e);if(e.every(r=>typeof r=="object"&&r!==null&&!s.isArray(r)))return s.mergeWith({},...e,(r,i)=>{if(s.isArray(r)&&s.isArray(i))return r.concat(i)});if(e.every(r=>typeof r!="object"||r===null))throw new Error("deepMerge: Cannot merge primitive values. All arguments must be objects or arrays.");const n=e.some(s.isArray),o=e.some(r=>typeof r=="object"&&r!==null&&!s.isArray(r));throw n&&o?new Error("deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects."):new Error("deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type.")}exports.deepMerge=h;exports.getNestedValue=_;exports.isJSON=g;exports.setNestedValue=p;
@@ -30,13 +30,44 @@ export declare function getNestedValue<T>(obj: T, path: (string | number)[]): un
30
30
  export declare function setNestedValue<T>(obj: T, path: (string | number)[], value: unknown): T;
31
31
  /**
32
32
  * Deep merges multiple objects or arrays into a single object or array.
33
- * This function handles different types of merging:
33
+ * This function handles different types of merging with improved type safety and error handling:
34
34
  * - If all arguments are arrays, it concatenates them
35
35
  * - If all arguments are objects, it deeply merges them (concatenating arrays within objects)
36
- * - Throws an error if mixed types are provided
36
+ * - Handles null/undefined values gracefully by treating them as empty objects
37
+ * - Provides better type inference and safety
38
+ * - Throws descriptive errors for invalid input
37
39
  *
38
- * @param args - The objects or arrays to merge.
40
+ * @param args - The objects or arrays to merge. Can be empty, in which case returns an empty object.
39
41
  * @returns The merged result - either a concatenated array or a deeply merged object.
40
- * @throws {Error} When arguments are mixed types (some arrays, some objects).
42
+ * @throws {Error} When arguments are mixed types (some arrays, some objects) or when all arguments are primitive values.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * // Merge objects
47
+ * deepMerge({ a: 1 }, { b: 2 }, { a: 3 }) // { a: 3, b: 2 }
48
+ *
49
+ * // Merge arrays
50
+ * deepMerge([1, 2], [3, 4]) // [1, 2, 3, 4]
51
+ *
52
+ * // Handle null/undefined
53
+ * deepMerge({ a: 1 }, null, undefined, { b: 2 }) // { a: 1, b: 2 }
54
+ *
55
+ * // Nested objects with arrays
56
+ * deepMerge(
57
+ * { items: [1, 2], config: { theme: 'dark' } },
58
+ * { items: [3, 4], config: { size: 'large' } }
59
+ * ) // { items: [1, 2, 3, 4], config: { theme: 'dark', size: 'large' } }
60
+ * ```
61
+ */
62
+ /**
63
+ * Deep merges multiple objects into a single object.
64
+ * @param args - The objects to merge. Can be empty, in which case returns an empty object.
65
+ * @returns The merged object.
66
+ */
67
+ export declare function deepMerge<T extends Record<string, unknown>>(...args: (T | null | undefined)[]): T;
68
+ /**
69
+ * Deep merges multiple arrays into a single array.
70
+ * @param args - The arrays to merge. Can be empty, in which case returns an empty array.
71
+ * @returns The merged array.
41
72
  */
42
- export declare function deepMerge<T = unknown>(...args: T[]): T;
73
+ export declare function deepMerge<T extends unknown[]>(...args: (T | null | undefined)[]): T;
@@ -1,55 +1,75 @@
1
- import { isArray as i, isPlainObject as c, mergeWith as l } from "lodash-es";
2
- var _ = Object.defineProperty, O = Object.defineProperties, d = Object.getOwnPropertyDescriptors, s = Object.getOwnPropertySymbols, y = Object.prototype.hasOwnProperty, P = Object.prototype.propertyIsEnumerable, u = (e, r, t) => r in e ? _(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, f = (e, r) => {
3
- for (var t in r || (r = {}))
4
- y.call(r, t) && u(e, t, r[t]);
5
- if (s)
6
- for (var t of s(r))
7
- P.call(r, t) && u(e, t, r[t]);
8
- return e;
9
- }, a = (e, r) => O(e, d(r));
10
- function g(e) {
1
+ import { isArray as i, mergeWith as l } from "lodash-es";
2
+ var c = Object.defineProperty, d = Object.defineProperties, m = Object.getOwnPropertyDescriptors, u = Object.getOwnPropertySymbols, y = Object.prototype.hasOwnProperty, v = Object.prototype.propertyIsEnumerable, f = (t, e, n) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, a = (t, e) => {
3
+ for (var n in e || (e = {}))
4
+ y.call(e, n) && f(t, n, e[n]);
5
+ if (u)
6
+ for (var n of u(e))
7
+ v.call(e, n) && f(t, n, e[n]);
8
+ return t;
9
+ }, p = (t, e) => d(t, m(e));
10
+ function O(t) {
11
11
  try {
12
- return JSON.parse(e), !0;
13
- } catch (r) {
12
+ return JSON.parse(t), !0;
13
+ } catch (e) {
14
14
  return !1;
15
15
  }
16
16
  }
17
- function h(e, r) {
18
- return r.reduce((t, n) => {
19
- if (t && typeof t == "object" && n in t)
20
- return t[n];
21
- }, e);
17
+ function b(t, e) {
18
+ return e.reduce((n, o) => {
19
+ if (n && typeof n == "object" && o in n)
20
+ return n[o];
21
+ }, t);
22
22
  }
23
- function m(e, r, t) {
23
+ function _(t, e, n) {
24
+ if (e.length === 0)
25
+ return t;
26
+ const [o, ...r] = e;
24
27
  if (r.length === 0)
25
- return e;
26
- const [n, ...p] = r;
27
- if (p.length === 0)
28
- return a(f({}, e), {
29
- [n]: t
28
+ return p(a({}, t), {
29
+ [o]: n
30
30
  });
31
- const o = e[n];
32
- return a(f({}, e), {
33
- [n]: m(
34
- typeof o == "object" && o !== null ? o : {},
35
- p,
36
- t
31
+ const s = t[o];
32
+ return p(a({}, t), {
33
+ [o]: _(
34
+ typeof s == "object" && s !== null ? s : {},
35
+ r,
36
+ n
37
37
  )
38
38
  });
39
39
  }
40
- function w(...e) {
40
+ function g(...t) {
41
+ if (t.length === 0)
42
+ return {};
43
+ const e = t.filter((r) => r != null).map((r) => typeof r != "object" ? {} : r);
44
+ if (e.length === 0)
45
+ return {};
46
+ if (e.length === 1)
47
+ return e[0];
41
48
  if (e.every(i))
42
49
  return [].concat(...e);
43
- if (e.every(c))
44
- return l({}, ...e, (r, t) => {
45
- if (i(r) && i(t))
46
- return r.concat(t);
50
+ if (e.every(
51
+ (r) => typeof r == "object" && r !== null && !i(r)
52
+ ))
53
+ return l({}, ...e, (r, s) => {
54
+ if (i(r) && i(s))
55
+ return r.concat(s);
47
56
  });
48
- throw new Error("deepMerge: All arguments must be either arrays or objects of the same type.");
57
+ if (e.every((r) => typeof r != "object" || r === null))
58
+ throw new Error(
59
+ "deepMerge: Cannot merge primitive values. All arguments must be objects or arrays."
60
+ );
61
+ const n = e.some(i), o = e.some(
62
+ (r) => typeof r == "object" && r !== null && !i(r)
63
+ );
64
+ throw n && o ? new Error(
65
+ "deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects."
66
+ ) : new Error(
67
+ "deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type."
68
+ );
49
69
  }
50
70
  export {
51
- w as deepMerge,
52
- h as getNestedValue,
53
- g as isJSON,
54
- m as setNestedValue
71
+ g as deepMerge,
72
+ b as getNestedValue,
73
+ O as isJSON,
74
+ _ as setNestedValue
55
75
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cyberskill/shared",
3
3
  "type": "module",
4
- "version": "2.4.0",
4
+ "version": "2.5.0",
5
5
  "description": "CyberSkill Shared",
6
6
  "author": "Stephen Cheng",
7
7
  "license": "MIT",
@@ -208,11 +208,11 @@
208
208
  },
209
209
  "dependencies": {
210
210
  "@antfu/eslint-config": "5.0.0",
211
- "@apollo/client": "3.13.8",
212
- "@apollo/client-integration-nextjs": "0.12.2",
211
+ "@apollo/client": "3.13.9",
212
+ "@apollo/client-integration-nextjs": "0.12.3",
213
213
  "@apollo/server": "5.0.0",
214
214
  "@as-integrations/express5": "1.1.2",
215
- "@dotenvx/dotenvx": "1.48.3",
215
+ "@dotenvx/dotenvx": "1.48.4",
216
216
  "@eddeee888/gcg-typescript-resolver-files": "0.12.1",
217
217
  "@eslint-react/eslint-plugin": "1.52.3",
218
218
  "@graphql-codegen/cli": "5.0.7",
@@ -256,8 +256,8 @@
256
256
  "node-fetch": "3.3.2",
257
257
  "node-persist": "4.0.4",
258
258
  "qs": "6.14.0",
259
- "react": "19.1.0",
260
- "react-dom": "19.1.0",
259
+ "react": "19.1.1",
260
+ "react-dom": "19.1.1",
261
261
  "react-hot-toast": "2.5.2",
262
262
  "react-i18next": "15.6.1",
263
263
  "slugify": "1.6.6",
@@ -271,7 +271,7 @@
271
271
  "@commitlint/cli": "19.8.1",
272
272
  "@commitlint/config-conventional": "19.8.1",
273
273
  "@eslint/config-inspector": "1.1.0",
274
- "@next/eslint-plugin-next": "15.4.4",
274
+ "@next/eslint-plugin-next": "15.4.5",
275
275
  "@testing-library/jest-dom": "6.6.4",
276
276
  "@testing-library/react": "16.3.0",
277
277
  "@types/apollo-upload-client": "18.0.0",
@@ -289,15 +289,15 @@
289
289
  "@types/migrate-mongo": "10.0.5",
290
290
  "@types/node": "24.1.0",
291
291
  "@types/node-persist": "3.1.8",
292
- "@types/react": "19.1.8",
293
- "@types/react-dom": "19.1.6",
292
+ "@types/react": "19.1.9",
293
+ "@types/react-dom": "19.1.7",
294
294
  "@types/unorm": "1.3.31",
295
295
  "@types/uuid": "10.0.0",
296
296
  "@types/ws": "8.18.1",
297
297
  "@types/yargs": "17.0.33",
298
298
  "@vitest/browser": "3.2.4",
299
299
  "eslint": "9.32.0",
300
- "eslint-config-next": "15.4.4",
300
+ "eslint-config-next": "15.4.5",
301
301
  "glob": "11.0.3",
302
302
  "lint-staged": "16.1.2",
303
303
  "node-modules-inspector": "1.0.0",