@cyberskill/shared 2.6.0 → 2.7.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,44 +1,45 @@
1
- import { cloneDeep as B, isObject as T } from "lodash-es";
2
- import K from "migrate-mongo";
1
+ import { cloneDeep as B, isObject as $ } from "lodash-es";
2
+ import Q from "migrate-mongo";
3
3
  import { Document as W } from "mongoose";
4
- import Q from "mongoose-aggregate-paginate-v2";
5
- import H from "mongoose-paginate-v2";
4
+ import k from "mongoose-aggregate-paginate-v2";
5
+ import J from "mongoose-paginate-v2";
6
6
  import { v4 as G } from "uuid";
7
- import { getNestedValue as J, setNestedValue as X, normalizeMongoFilter as V } from "../../util/object/object.util.js";
8
- import { regexSearchMapper as Y } from "../../util/common/common.util.js";
9
- import { writeFileSync as q, pathExistsSync as Z, readFileSync as ee, appendFileSync as te } from "../fs/fs.util.js";
10
- import { PATH as F, MIGRATE_MONGO_CONFIG as L } from "../path/path.constant.js";
11
- import { validate as re } from "../../util/validate/validate.util.js";
12
- import { generateShortId as se, generateSlug as j } from "../../util/string/string.util.js";
13
- import { RESPONSE_STATUS as v } from "../../constant/response-status.js";
14
- import { catchError as f } from "../log/log.util.js";
15
- var ne = Object.defineProperty, ce = Object.defineProperties, ue = Object.getOwnPropertyDescriptors, U = Object.getOwnPropertySymbols, ie = Object.prototype.hasOwnProperty, oe = Object.prototype.propertyIsEnumerable, $ = (n, t, e) => t in n ? ne(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, S = (n, t) => {
7
+ import { MONGO_SLUG_MAX_ATTEMPTS as X } from "./mongo.constant.js";
8
+ import { getNestedValue as H, setNestedValue as Y, normalizeMongoFilter as b } from "../../util/object/object.util.js";
9
+ import { regexSearchMapper as Z } from "../../util/common/common.util.js";
10
+ import { writeFileSync as q, pathExistsSync as ee, readFileSync as te, appendFileSync as re } from "../fs/fs.util.js";
11
+ import { PATH as w, MIGRATE_MONGO_CONFIG as L } from "../path/path.constant.js";
12
+ import { validate as se } from "../../util/validate/validate.util.js";
13
+ import { generateShortId as ne, generateSlug as I } from "../../util/string/string.util.js";
14
+ import { RESPONSE_STATUS as R } from "../../constant/response-status.js";
15
+ import { catchError as d } from "../log/log.util.js";
16
+ var ue = Object.defineProperty, ce = Object.defineProperties, ie = Object.getOwnPropertyDescriptors, U = Object.getOwnPropertySymbols, oe = Object.prototype.hasOwnProperty, le = Object.prototype.propertyIsEnumerable, T = (n, t, e) => t in n ? ue(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, S = (n, t) => {
16
17
  for (var e in t || (t = {}))
17
- ie.call(t, e) && $(n, e, t[e]);
18
+ oe.call(t, e) && T(n, e, t[e]);
18
19
  if (U)
19
20
  for (var e of U(t))
20
- oe.call(t, e) && $(n, e, t[e]);
21
+ le.call(t, e) && T(n, e, t[e]);
21
22
  return n;
22
- }, w = (n, t) => ce(n, ue(t)), le = (n, t, e) => $(n, typeof t != "symbol" ? t + "" : t, e), l = (n, t, e) => new Promise((r, s) => {
23
- var c = (i) => {
23
+ }, F = (n, t) => ce(n, ie(t)), ae = (n, t, e) => T(n, typeof t != "symbol" ? t + "" : t, e), a = (n, t, e) => new Promise((r, s) => {
24
+ var u = (o) => {
24
25
  try {
25
- o(e.next(i));
26
- } catch (a) {
27
- s(a);
26
+ i(e.next(o));
27
+ } catch (l) {
28
+ s(l);
28
29
  }
29
- }, u = (i) => {
30
+ }, c = (o) => {
30
31
  try {
31
- o(e.throw(i));
32
- } catch (a) {
33
- s(a);
32
+ i(e.throw(o));
33
+ } catch (l) {
34
+ s(l);
34
35
  }
35
- }, o = (i) => i.done ? r(i.value) : Promise.resolve(i.value).then(c, u);
36
- o((e = e.apply(n, t)).next());
36
+ }, i = (o) => o.done ? r(o.value) : Promise.resolve(o.value).then(u, c);
37
+ i((e = e.apply(n, t)).next());
37
38
  });
38
- function ae(n) {
39
+ function de(n) {
39
40
  return n === n.toUpperCase() ? n.charAt(0).toUpperCase() + n.slice(1).toLowerCase() : n;
40
41
  }
41
- const b = {
42
+ const x = {
42
43
  /**
43
44
  * Creates generic fields that are commonly used across MongoDB documents.
44
45
  * This function generates standard fields including a UUID, deletion flag, and timestamps
@@ -118,23 +119,23 @@ const b = {
118
119
  toObject: { virtuals: !0 }
119
120
  // So `console.log()` and other functions that use `toObject()` include virtuals
120
121
  });
121
- return e.forEach(({ name: c, options: u, get: o }) => {
122
- if (b.isDynamicVirtual(u)) {
123
- const i = s.statics;
124
- i._dynamicVirtuals || (i._dynamicVirtuals = []), i._dynamicVirtuals.push({
125
- name: c,
126
- options: u
122
+ return e.forEach(({ name: u, options: c, get: i }) => {
123
+ if (x.isDynamicVirtual(c)) {
124
+ const o = s.statics;
125
+ o._dynamicVirtuals || (o._dynamicVirtuals = []), o._dynamicVirtuals.push({
126
+ name: u,
127
+ options: c
127
128
  });
128
- const a = s.virtual(c);
129
- o ? a.get(o) : a.get(function() {
130
- var d;
131
- return ((d = this._populated) == null ? void 0 : d[c]) || (u != null && u.count ? 0 : u != null && u.justOne ? null : []);
129
+ const l = s.virtual(u);
130
+ i ? l.get(i) : l.get(function() {
131
+ var f;
132
+ return ((f = this._populated) == null ? void 0 : f[u]) || (c != null && c.count ? 0 : c != null && c.justOne ? null : []);
132
133
  });
133
134
  } else {
134
- const i = s.virtual(c, u);
135
- o && i.get(o);
135
+ const o = s.virtual(u, c);
136
+ i && o.get(i);
136
137
  }
137
- }), r || s.add(b.createGenericSchema(n)), s;
138
+ }), r || s.add(x.createGenericSchema(n)), s;
138
139
  },
139
140
  /**
140
141
  * Creates a Mongoose model with plugins, middleware, and pagination support.
@@ -158,18 +159,18 @@ const b = {
158
159
  schema: e,
159
160
  virtuals: r = [],
160
161
  pagination: s = !0,
161
- aggregate: c = !0,
162
- middlewares: u = []
162
+ aggregate: u = !0,
163
+ middlewares: c = []
163
164
  }) {
164
165
  if (!t)
165
166
  throw new Error("Model name is required.");
166
167
  if (n.models[t])
167
168
  return n.models[t];
168
- const o = b.createSchema({ mongoose: n, schema: e, virtuals: r });
169
- return (s || c) && b.applyPlugins(o, [
170
- s && H,
171
- c && Q
172
- ]), b.applyMiddlewares(o, u), n.model(t, o);
169
+ const i = x.createSchema({ mongoose: n, schema: e, virtuals: r });
170
+ return (s || u) && x.applyPlugins(i, [
171
+ s && J,
172
+ u && k
173
+ ]), x.applyMiddlewares(i, c), n.model(t, i);
173
174
  },
174
175
  /**
175
176
  * Validation utilities for Mongoose schemas.
@@ -185,8 +186,8 @@ const b = {
185
186
  */
186
187
  isRequired() {
187
188
  return function(n) {
188
- return l(this, null, function* () {
189
- return !re.isEmpty(n);
189
+ return a(this, null, function* () {
190
+ return !se.isEmpty(n);
190
191
  });
191
192
  };
192
193
  },
@@ -201,7 +202,7 @@ const b = {
201
202
  */
202
203
  isUnique(n) {
203
204
  return function(t) {
204
- return l(this, null, function* () {
205
+ return a(this, null, function* () {
205
206
  if (!Array.isArray(n) || n.length === 0)
206
207
  throw new Error("Fields must be a non-empty array of strings.");
207
208
  const e = { $or: n.map((s) => ({ [s]: t })) };
@@ -220,7 +221,7 @@ const b = {
220
221
  */
221
222
  matchesRegex(n) {
222
223
  return function(t) {
223
- return l(this, null, function* () {
224
+ return a(this, null, function* () {
224
225
  if (!Array.isArray(n) || n.some((e) => !(e instanceof RegExp)))
225
226
  throw new Error("regexArray must be an array of valid RegExp objects.");
226
227
  return n.every((e) => e.test(t));
@@ -232,7 +233,7 @@ const b = {
232
233
  * Migration utilities for MongoDB.
233
234
  * This object extends the migrate-mongo library with additional configuration utilities.
234
235
  */
235
- migrate: w(S({}, K), {
236
+ migrate: F(S({}, Q), {
236
237
  /**
237
238
  * Sets the migration configuration and updates .gitignore.
238
239
  * This function creates a migration configuration file and ensures it's properly
@@ -243,12 +244,12 @@ const b = {
243
244
  setConfig: (n) => {
244
245
  const t = `// This file is automatically generated by the Cyberskill CLI.
245
246
  module.exports = ${JSON.stringify(n, null, 4)}`;
246
- q(F.MIGRATE_MONGO_CONFIG, t);
247
+ q(w.MIGRATE_MONGO_CONFIG, t);
247
248
  const e = `
248
249
  ${L}
249
250
  `;
250
- Z(F.GIT_IGNORE) ? ee(F.GIT_IGNORE, "utf-8").split(`
251
- `).includes(L) || te(F.GIT_IGNORE, e) : q(F.GIT_IGNORE, e);
251
+ ee(w.GIT_IGNORE) ? te(w.GIT_IGNORE, "utf-8").split(`
252
+ `).includes(L) || re(w.GIT_IGNORE, e) : q(w.GIT_IGNORE, e);
252
253
  }
253
254
  }),
254
255
  /**
@@ -267,13 +268,13 @@ ${L}
267
268
  if (!t || t.length === 0)
268
269
  return e;
269
270
  for (const r of t) {
270
- const s = r.toString().split("."), c = J(e, s);
271
- if (typeof c == "string" && c.length > 0) {
272
- const u = {
273
- $regex: `.*${Y(c)}.*`,
271
+ const s = r.toString().split("."), u = H(e, s);
272
+ if (typeof u == "string" && u.length > 0) {
273
+ const c = {
274
+ $regex: `.*${Z(u)}.*`,
274
275
  $options: "i"
275
276
  };
276
- e = X(e, s, u);
277
+ e = Y(e, s, c);
277
278
  }
278
279
  }
279
280
  return e;
@@ -295,11 +296,11 @@ ${L}
295
296
  * @returns Array of records that don't exist in the database
296
297
  */
297
298
  getNewRecords(n, t, e) {
298
- return l(this, null, function* () {
299
+ return a(this, null, function* () {
299
300
  const r = yield n.findAll({});
300
301
  return r.success ? t.filter(
301
- (c) => !r.result.some(
302
- (u) => e(u, c)
302
+ (u) => !r.result.some(
303
+ (c) => e(c, u)
303
304
  )
304
305
  ) : t;
305
306
  });
@@ -312,20 +313,20 @@ ${L}
312
313
  * @returns Array of existing records that match the filter criteria
313
314
  */
314
315
  getExistingRecords(n, t, e) {
315
- return l(this, null, function* () {
316
+ return a(this, null, function* () {
316
317
  const r = yield n.findAll({});
317
318
  return r.success ? r.result.filter(
318
- (c) => t.some(
319
- (u) => e(c, u)
319
+ (u) => t.some(
320
+ (c) => e(u, c)
320
321
  )
321
322
  ) : [];
322
323
  });
323
324
  }
324
325
  };
325
- function de(n) {
326
+ function fe(n) {
326
327
  return n !== null && typeof n == "object" && "toObject" in n && typeof n.toObject == "function";
327
328
  }
328
- function I(n, t) {
329
+ function j(n, t) {
329
330
  if (!n || !t || t.length === 0)
330
331
  return n;
331
332
  const e = new Set(t.map((r) => r.name));
@@ -334,8 +335,8 @@ function I(n, t) {
334
335
  if (typeof s == "string")
335
336
  return !e.has(s);
336
337
  if (typeof s == "object" && s !== null) {
337
- const c = s;
338
- return !e.has(c.path || c.populate || "");
338
+ const u = s;
339
+ return !e.has(u.path || u.populate || "");
339
340
  }
340
341
  return !0;
341
342
  });
@@ -349,130 +350,130 @@ function I(n, t) {
349
350
  }
350
351
  return n;
351
352
  }
352
- function fe(n, t, e) {
353
+ function me(n, t, e) {
353
354
  if (!n.length || !t || !(e != null && e.ref))
354
355
  return [];
355
356
  const r = /* @__PURE__ */ new Map();
356
357
  return n.forEach((s) => {
357
358
  try {
358
- const c = e.ref(s);
359
- if (c == null)
359
+ const u = e.ref(s);
360
+ if (u == null)
360
361
  return;
361
- const u = typeof c == "string" ? c : String(c);
362
- if (u && u.trim() !== "") {
363
- const o = ae(u);
364
- r.has(o) || r.set(o, []), r.get(o).push(s);
362
+ const c = typeof u == "string" ? u : String(u);
363
+ if (c && c.trim() !== "") {
364
+ const i = de(c);
365
+ r.has(i) || r.set(i, []), r.get(i).push(s);
365
366
  }
366
- } catch (c) {
367
- f(new Error(`Dynamic ref function failed for virtual "${t}": ${c instanceof Error ? c.message : String(c)}`));
367
+ } catch (u) {
368
+ d(new Error(`Dynamic ref function failed for virtual "${t}": ${u instanceof Error ? u.message : String(u)}`));
368
369
  }
369
- }), Array.from(r.entries()).map(([s, c]) => ({ model: s, docs: c }));
370
+ }), Array.from(r.entries()).map(([s, u]) => ({ model: s, docs: u }));
370
371
  }
371
372
  function z(n, t, e, r, s) {
372
- return l(this, null, function* () {
373
+ return a(this, null, function* () {
373
374
  if (!t.length || !e.length || !r)
374
375
  return t;
375
- const c = e.filter((i) => {
376
+ const u = e.filter((o) => {
376
377
  if (Array.isArray(r))
377
- return r.length > 0 && r.some((a) => typeof a == "string" ? a === i.name : a.path === i.name);
378
+ return r.length > 0 && r.some((l) => typeof l == "string" ? l === o.name : l.path === o.name);
378
379
  if (typeof r == "string")
379
- return r === i.name;
380
+ return r === o.name;
380
381
  if (typeof r == "object" && r !== null) {
381
- const a = r;
382
- return a.path && a.path === i.name || a.populate && a.populate === i.name;
382
+ const l = r;
383
+ return l.path && l.path === o.name || l.populate && l.populate === o.name;
383
384
  }
384
385
  return !1;
385
386
  });
386
- if (c.length === 0)
387
+ if (u.length === 0)
387
388
  return t;
388
- const u = B(t.map(
389
- (i) => de(i) ? i.toObject() : i
389
+ const c = B(t.map(
390
+ (o) => fe(o) ? o.toObject() : o
390
391
  ));
391
- u.forEach((i) => {
392
- c.forEach(({ name: a, options: d }) => {
393
- if (!(a in i)) {
394
- const m = i;
395
- m[a] = d.count ? 0 : d.justOne ? null : [];
392
+ c.forEach((o) => {
393
+ u.forEach(({ name: l, options: f }) => {
394
+ if (!(l in o)) {
395
+ const O = o;
396
+ O[l] = f.count ? 0 : f.justOne ? null : [];
396
397
  }
397
398
  });
398
399
  });
399
- const o = /* @__PURE__ */ new Map();
400
- for (const i of c) {
401
- const { name: a, options: d } = i, m = fe(u, a, d);
402
- for (const p of m) {
403
- o.has(p.model) || o.set(p.model, {
400
+ const i = /* @__PURE__ */ new Map();
401
+ for (const o of u) {
402
+ const { name: l, options: f } = o, O = me(c, l, f);
403
+ for (const m of O) {
404
+ i.has(m.model) || i.set(m.model, {
404
405
  virtuals: [],
405
406
  localValueSets: /* @__PURE__ */ new Map(),
406
407
  docsByLocalValue: /* @__PURE__ */ new Map()
407
408
  });
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 M = h.localValueSets.get(a);
411
- p.docs.forEach((N) => {
412
- const A = N[d.localField];
409
+ const g = i.get(m.model);
410
+ g.virtuals.find((V) => V.name === l) || (g.virtuals.push(o), g.localValueSets.set(l, /* @__PURE__ */ new Set()));
411
+ const v = g.localValueSets.get(l);
412
+ m.docs.forEach((V) => {
413
+ const A = V[f.localField];
413
414
  if (A != null) {
414
415
  const D = String(A);
415
- M.add(D);
416
+ v.add(D);
416
417
  let _ = -1;
417
- const R = N;
418
- R.id !== void 0 ? _ = u.findIndex((x) => x.id === R.id) : R._id !== void 0 && (_ = u.findIndex((x) => {
419
- var O, y, E, g;
420
- return ((y = (O = x._id) == null ? void 0 : O.toString) == null ? void 0 : y.call(O)) === ((g = (E = R._id) == null ? void 0 : E.toString) == null ? void 0 : g.call(E));
421
- })), _ !== -1 && (h.docsByLocalValue.has(D) || h.docsByLocalValue.set(D, []), h.docsByLocalValue.get(D).push(_));
418
+ const N = V;
419
+ N.id !== void 0 ? _ = c.findIndex((M) => M.id === N.id) : N._id !== void 0 && (_ = c.findIndex((M) => {
420
+ var p, h, E, y;
421
+ return ((h = (p = M._id) == null ? void 0 : p.toString) == null ? void 0 : h.call(p)) === ((y = (E = N._id) == null ? void 0 : E.toString) == null ? void 0 : y.call(E));
422
+ })), _ !== -1 && (g.docsByLocalValue.has(D) || g.docsByLocalValue.set(D, []), g.docsByLocalValue.get(D).push(_));
422
423
  }
423
424
  });
424
425
  }
425
426
  }
426
- return yield Promise.all(Array.from(o.entries()).map((i) => l(null, [i], function* ([a, d]) {
427
- const m = n.models[a];
428
- if (!m)
427
+ return yield Promise.all(Array.from(i.entries()).map((o) => a(null, [o], function* ([l, f]) {
428
+ const O = n.models[l];
429
+ if (!O)
429
430
  return;
430
- const p = /* @__PURE__ */ new Set();
431
- if (d.localValueSets.forEach((D) => {
432
- D.forEach((_) => p.add(_));
433
- }), p.size === 0)
431
+ const m = /* @__PURE__ */ new Set();
432
+ if (f.localValueSets.forEach((D) => {
433
+ D.forEach((_) => m.add(_));
434
+ }), m.size === 0)
434
435
  return;
435
- const h = [...new Set(d.virtuals.map((D) => D.options.foreignField))], M = Array.from(p);
436
- let N;
437
- h.length === 1 ? N = { [String(h[0])]: { $in: M } } : N = { $or: h.map((D) => ({ [D]: { $in: M } })) };
438
- const A = yield m.find(N, s).lean();
439
- for (const D of d.virtuals) {
440
- const { name: _, options: R } = D, x = A.filter((O) => {
441
- const y = O[R.foreignField];
442
- return y != null && p.has(String(y));
436
+ const g = [...new Set(f.virtuals.map((D) => D.options.foreignField))], v = Array.from(m);
437
+ let V;
438
+ g.length === 1 ? V = { [String(g[0])]: { $in: v } } : V = { $or: g.map((D) => ({ [D]: { $in: v } })) };
439
+ const A = yield O.find(V, s).lean();
440
+ for (const D of f.virtuals) {
441
+ const { name: _, options: N } = D, M = A.filter((p) => {
442
+ const h = p[N.foreignField];
443
+ return h != null && m.has(String(h));
443
444
  });
444
- if (R.count) {
445
- const O = /* @__PURE__ */ new Map();
446
- x.forEach((y) => {
445
+ if (N.count) {
446
+ const p = /* @__PURE__ */ new Map();
447
+ M.forEach((h) => {
447
448
  var E;
448
- const g = (E = y[R.foreignField]) == null ? void 0 : E.toString();
449
- g && O.set(g, (O.get(g) || 0) + 1);
450
- }), d.localValueSets.get(_).forEach((y) => {
451
- const E = d.docsByLocalValue.get(y) || [], g = O.get(y) || 0;
452
- E.forEach((C) => {
453
- const P = u[C];
454
- P[_] === void 0 && (P[_] = g);
449
+ const y = (E = h[N.foreignField]) == null ? void 0 : E.toString();
450
+ y && p.set(y, (p.get(y) || 0) + 1);
451
+ }), f.localValueSets.get(_).forEach((h) => {
452
+ const E = f.docsByLocalValue.get(h) || [], y = p.get(h) || 0;
453
+ E.forEach((P) => {
454
+ const C = c[P];
455
+ C[_] === void 0 && (C[_] = y);
455
456
  });
456
457
  });
457
458
  } else {
458
- const O = /* @__PURE__ */ new Map();
459
- x.forEach((y) => {
459
+ const p = /* @__PURE__ */ new Map();
460
+ M.forEach((h) => {
460
461
  var E;
461
- const g = (E = y[R.foreignField]) == null ? void 0 : E.toString();
462
- g && (O.has(g) || O.set(g, []), O.get(g).push(y));
463
- }), d.localValueSets.get(_).forEach((y) => {
464
- const E = d.docsByLocalValue.get(y) || [], g = O.get(y) || [], C = R.justOne ? g[0] || null : g;
465
- E.forEach((P) => {
466
- const k = u[P];
467
- k[_] = C;
462
+ const y = (E = h[N.foreignField]) == null ? void 0 : E.toString();
463
+ y && (p.has(y) || p.set(y, []), p.get(y).push(h));
464
+ }), f.localValueSets.get(_).forEach((h) => {
465
+ const E = f.docsByLocalValue.get(h) || [], y = p.get(h) || [], P = N.justOne ? y[0] || null : y;
466
+ E.forEach((C) => {
467
+ const K = c[C];
468
+ K[_] = P;
468
469
  });
469
470
  });
470
471
  }
471
472
  }
472
- }))), u;
473
+ }))), c;
473
474
  });
474
475
  }
475
- class be {
476
+ class Me {
476
477
  /**
477
478
  * Creates a new MongoDB controller instance.
478
479
  *
@@ -480,7 +481,7 @@ class be {
480
481
  * @param collectionName - The name of the collection to operate on.
481
482
  */
482
483
  constructor(t, e) {
483
- le(this, "collection"), this.collection = t.collection(e);
484
+ ae(this, "collection"), this.collection = t.collection(e);
484
485
  }
485
486
  /**
486
487
  * Creates a single document in the collection.
@@ -490,9 +491,9 @@ class be {
490
491
  * @returns A promise that resolves to a standardized response with the created document.
491
492
  */
492
493
  createOne(t) {
493
- return l(this, null, function* () {
494
+ return a(this, null, function* () {
494
495
  try {
495
- const e = S(S({}, b.createGenericFields()), t);
496
+ const e = S(S({}, x.createGenericFields()), t);
496
497
  return (yield this.collection.insertOne(e)).acknowledged ? {
497
498
  success: !0,
498
499
  message: "Document created successfully",
@@ -500,10 +501,10 @@ class be {
500
501
  } : {
501
502
  success: !1,
502
503
  message: "Document creation failed",
503
- code: v.INTERNAL_SERVER_ERROR.CODE
504
+ code: R.INTERNAL_SERVER_ERROR.CODE
504
505
  };
505
506
  } catch (e) {
506
- return f(e);
507
+ return d(e);
507
508
  }
508
509
  });
509
510
  }
@@ -515,20 +516,20 @@ class be {
515
516
  * @returns A promise that resolves to a standardized response with the created documents.
516
517
  */
517
518
  createMany(t) {
518
- return l(this, null, function* () {
519
+ return a(this, null, function* () {
519
520
  try {
520
- const e = t.map((s) => S(S({}, b.createGenericFields()), s)), r = yield this.collection.insertMany(e);
521
+ const e = t.map((s) => S(S({}, x.createGenericFields()), s)), r = yield this.collection.insertMany(e);
521
522
  return r.insertedCount === 0 ? {
522
523
  success: !1,
523
524
  message: "No documents were inserted",
524
- code: v.INTERNAL_SERVER_ERROR.CODE
525
+ code: R.INTERNAL_SERVER_ERROR.CODE
525
526
  } : {
526
527
  success: !0,
527
528
  message: `${r.insertedCount} documents created successfully`,
528
529
  result: e
529
530
  };
530
531
  } catch (e) {
531
- return f(e);
532
+ return d(e);
532
533
  }
533
534
  });
534
535
  }
@@ -539,12 +540,12 @@ class be {
539
540
  * @returns A promise that resolves to a standardized response with the found document.
540
541
  */
541
542
  findOne(t) {
542
- return l(this, null, function* () {
543
+ return a(this, null, function* () {
543
544
  try {
544
545
  const e = yield this.collection.findOne(t);
545
- return e ? { success: !0, message: "Document found", result: e } : { success: !1, message: "Document not found", code: v.NOT_FOUND.CODE };
546
+ return e ? { success: !0, message: "Document found", result: e } : { success: !1, message: "Document not found", code: R.NOT_FOUND.CODE };
546
547
  } catch (e) {
547
- return f(e);
548
+ return d(e);
548
549
  }
549
550
  });
550
551
  }
@@ -555,7 +556,7 @@ class be {
555
556
  * @returns A promise that resolves to a standardized response with the found documents.
556
557
  */
557
558
  findAll() {
558
- return l(this, arguments, function* (t = {}) {
559
+ return a(this, arguments, function* (t = {}) {
559
560
  try {
560
561
  return {
561
562
  success: !0,
@@ -563,7 +564,7 @@ class be {
563
564
  result: yield this.collection.find(t).toArray()
564
565
  };
565
566
  } catch (e) {
566
- return f(e);
567
+ return d(e);
567
568
  }
568
569
  });
569
570
  }
@@ -574,7 +575,7 @@ class be {
574
575
  * @returns A promise that resolves to a standardized response with the document count.
575
576
  */
576
577
  count() {
577
- return l(this, arguments, function* (t = {}) {
578
+ return a(this, arguments, function* (t = {}) {
578
579
  try {
579
580
  const e = yield this.collection.countDocuments(t);
580
581
  return {
@@ -583,7 +584,7 @@ class be {
583
584
  result: e
584
585
  };
585
586
  } catch (e) {
586
- return f(e);
587
+ return d(e);
587
588
  }
588
589
  });
589
590
  }
@@ -595,7 +596,7 @@ class be {
595
596
  * @returns A promise that resolves to a standardized response with the update result.
596
597
  */
597
598
  updateOne(t, e) {
598
- return l(this, null, function* () {
599
+ return a(this, null, function* () {
599
600
  try {
600
601
  const r = yield this.collection.updateOne(t, {
601
602
  $set: e
@@ -603,14 +604,14 @@ class be {
603
604
  return r.matchedCount === 0 ? {
604
605
  success: !1,
605
606
  message: "No documents matched the filter",
606
- code: v.INTERNAL_SERVER_ERROR.CODE
607
+ code: R.INTERNAL_SERVER_ERROR.CODE
607
608
  } : {
608
609
  success: !0,
609
610
  message: "Document updated successfully",
610
611
  result: r
611
612
  };
612
613
  } catch (r) {
613
- return f(r);
614
+ return d(r);
614
615
  }
615
616
  });
616
617
  }
@@ -622,7 +623,7 @@ class be {
622
623
  * @returns A promise that resolves to a standardized response with the update result.
623
624
  */
624
625
  updateMany(t, e) {
625
- return l(this, null, function* () {
626
+ return a(this, null, function* () {
626
627
  try {
627
628
  const r = yield this.collection.updateMany(t, {
628
629
  $set: e
@@ -630,14 +631,14 @@ class be {
630
631
  return r.matchedCount === 0 ? {
631
632
  success: !1,
632
633
  message: "No documents matched the filter",
633
- code: v.INTERNAL_SERVER_ERROR.CODE
634
+ code: R.INTERNAL_SERVER_ERROR.CODE
634
635
  } : {
635
636
  success: !0,
636
637
  message: "Documents updated successfully",
637
638
  result: r
638
639
  };
639
640
  } catch (r) {
640
- return f(r);
641
+ return d(r);
641
642
  }
642
643
  });
643
644
  }
@@ -648,20 +649,20 @@ class be {
648
649
  * @returns A promise that resolves to a standardized response with the delete result.
649
650
  */
650
651
  deleteOne(t) {
651
- return l(this, null, function* () {
652
+ return a(this, null, function* () {
652
653
  try {
653
654
  const e = yield this.collection.deleteOne(t);
654
655
  return e.deletedCount === 0 ? {
655
656
  success: !1,
656
657
  message: "No documents matched the filter",
657
- code: v.INTERNAL_SERVER_ERROR.CODE
658
+ code: R.INTERNAL_SERVER_ERROR.CODE
658
659
  } : {
659
660
  success: !0,
660
661
  message: "Document deleted successfully",
661
662
  result: e
662
663
  };
663
664
  } catch (e) {
664
- return f(e);
665
+ return d(e);
665
666
  }
666
667
  });
667
668
  }
@@ -672,25 +673,25 @@ class be {
672
673
  * @returns A promise that resolves to a standardized response with the delete result.
673
674
  */
674
675
  deleteMany(t) {
675
- return l(this, null, function* () {
676
+ return a(this, null, function* () {
676
677
  try {
677
678
  const e = yield this.collection.deleteMany(t);
678
679
  return e.deletedCount === 0 ? {
679
680
  success: !1,
680
681
  message: "No documents matched the filter",
681
- code: v.INTERNAL_SERVER_ERROR.CODE
682
+ code: R.INTERNAL_SERVER_ERROR.CODE
682
683
  } : {
683
684
  success: !0,
684
685
  message: "Documents deleted successfully",
685
686
  result: e
686
687
  };
687
688
  } catch (e) {
688
- return f(e);
689
+ return d(e);
689
690
  }
690
691
  });
691
692
  }
692
693
  }
693
- class xe {
694
+ class we {
694
695
  /**
695
696
  * Creates a new Mongoose controller instance.
696
697
  *
@@ -723,7 +724,7 @@ class xe {
723
724
  * @returns The document with dynamic virtuals populated.
724
725
  */
725
726
  populateDynamicVirtualsForDocument(t, e) {
726
- return l(this, null, function* () {
727
+ return a(this, null, function* () {
727
728
  const r = this.getDynamicVirtuals();
728
729
  if (r && r.length > 0) {
729
730
  const s = yield z(this.model.base, [t], r, e);
@@ -740,7 +741,7 @@ class xe {
740
741
  * @returns The documents with dynamic virtuals populated.
741
742
  */
742
743
  populateDynamicVirtualsForDocuments(t, e) {
743
- return l(this, null, function* () {
744
+ return a(this, null, function* () {
744
745
  const r = this.getDynamicVirtuals();
745
746
  return r && r.length > 0 && t.length > 0 ? yield z(this.model.base, t, r, e) : t;
746
747
  });
@@ -756,18 +757,18 @@ class xe {
756
757
  * @returns A promise that resolves to a standardized response with the found document.
757
758
  */
758
759
  findOne() {
759
- return l(this, arguments, function* (t = {}, e = {}, r = {}, s) {
760
+ return a(this, arguments, function* (t = {}, e = {}, r = {}, s) {
760
761
  try {
761
- const c = V(t), u = this.model.findOne(c, e, r), o = this.getDynamicVirtuals(), i = I(s, o);
762
- i && u.populate(i);
763
- const a = yield u.exec();
764
- return a ? { success: !0, result: yield this.populateDynamicVirtualsForDocument(a, s) } : {
762
+ const u = b(t), c = this.model.findOne(u, e, r), i = this.getDynamicVirtuals(), o = j(s, i);
763
+ o && c.populate(o);
764
+ const l = yield c.exec();
765
+ return l ? { success: !0, result: yield this.populateDynamicVirtualsForDocument(l, s) } : {
765
766
  success: !1,
766
767
  message: `No ${this.getModelName()} found.`,
767
- code: v.NOT_FOUND.CODE
768
+ code: R.NOT_FOUND.CODE
768
769
  };
769
- } catch (c) {
770
- return f(c);
770
+ } catch (u) {
771
+ return d(u);
771
772
  }
772
773
  });
773
774
  }
@@ -782,14 +783,14 @@ class xe {
782
783
  * @returns A promise that resolves to a standardized response with the found documents.
783
784
  */
784
785
  findAll() {
785
- return l(this, arguments, function* (t = {}, e = {}, r = {}, s) {
786
+ return a(this, arguments, function* (t = {}, e = {}, r = {}, s) {
786
787
  try {
787
- const c = V(t), u = this.model.find(c, e, r), o = this.getDynamicVirtuals(), i = I(s, o);
788
- i && u.populate(i);
789
- const a = yield u.exec();
790
- return { success: !0, result: yield this.populateDynamicVirtualsForDocuments(a, s) };
791
- } catch (c) {
792
- return f(c);
788
+ const u = b(t), c = this.model.find(u, e, r), i = this.getDynamicVirtuals(), o = j(s, i);
789
+ o && c.populate(o);
790
+ const l = yield c.exec();
791
+ return { success: !0, result: yield this.populateDynamicVirtualsForDocuments(l, s) };
792
+ } catch (u) {
793
+ return d(u);
793
794
  }
794
795
  });
795
796
  }
@@ -802,14 +803,14 @@ class xe {
802
803
  * @returns A promise that resolves to a standardized response with paginated results.
803
804
  */
804
805
  findPaging() {
805
- return l(this, arguments, function* (t = {}, e = {}) {
806
+ return a(this, arguments, function* (t = {}, e = {}) {
806
807
  try {
807
- const r = V(t), s = this.getDynamicVirtuals(), c = S({}, e);
808
- e.populate && (c.populate = I(e.populate, s));
809
- const u = yield this.model.paginate(r, c), o = yield this.populateDynamicVirtualsForDocuments(u.docs, e.populate);
810
- return { success: !0, result: w(S({}, u), { docs: o }) };
808
+ const r = b(t), s = this.getDynamicVirtuals(), u = S({}, e);
809
+ e.populate && (u.populate = j(e.populate, s));
810
+ const c = yield this.model.paginate(r, u), i = yield this.populateDynamicVirtualsForDocuments(c.docs, e.populate);
811
+ return { success: !0, result: F(S({}, c), { docs: i }) };
811
812
  } catch (r) {
812
- return f(r);
813
+ return d(r);
813
814
  }
814
815
  });
815
816
  }
@@ -821,17 +822,17 @@ class xe {
821
822
  * @returns A promise that resolves to a standardized response with paginated aggregation results.
822
823
  */
823
824
  findPagingAggregate(t) {
824
- return l(this, arguments, function* (e, r = {}) {
825
+ return a(this, arguments, function* (e, r = {}) {
825
826
  try {
826
- const s = this.getDynamicVirtuals(), c = S({}, r);
827
- r.populate && (c.populate = I(r.populate, s));
828
- const u = yield this.model.aggregatePaginate(
827
+ const s = this.getDynamicVirtuals(), u = S({}, r);
828
+ r.populate && (u.populate = j(r.populate, s));
829
+ const c = yield this.model.aggregatePaginate(
829
830
  this.model.aggregate(e),
830
- c
831
- ), o = yield this.populateDynamicVirtualsForDocuments(u.docs, r.populate);
832
- return { success: !0, result: w(S({}, u), { docs: o }) };
831
+ u
832
+ ), i = yield this.populateDynamicVirtualsForDocuments(c.docs, r.populate);
833
+ return { success: !0, result: F(S({}, c), { docs: i }) };
833
834
  } catch (s) {
834
- return f(s);
835
+ return d(s);
835
836
  }
836
837
  });
837
838
  }
@@ -842,12 +843,12 @@ class xe {
842
843
  * @returns A promise that resolves to a standardized response with the document count.
843
844
  */
844
845
  count() {
845
- return l(this, arguments, function* (t = {}) {
846
+ return a(this, arguments, function* (t = {}) {
846
847
  try {
847
- const e = V(t);
848
+ const e = b(t);
848
849
  return { success: !0, result: yield this.model.countDocuments(e) };
849
850
  } catch (e) {
850
- return f(e);
851
+ return d(e);
851
852
  }
852
853
  });
853
854
  }
@@ -858,11 +859,11 @@ class xe {
858
859
  * @returns A promise that resolves to a standardized response with the created document.
859
860
  */
860
861
  createOne(t) {
861
- return l(this, null, function* () {
862
+ return a(this, null, function* () {
862
863
  try {
863
864
  return { success: !0, result: yield this.model.create(t) };
864
865
  } catch (e) {
865
- return f(e);
866
+ return d(e);
866
867
  }
867
868
  });
868
869
  }
@@ -874,11 +875,11 @@ class xe {
874
875
  * @returns A promise that resolves to a standardized response with the created documents.
875
876
  */
876
877
  createMany(t) {
877
- return l(this, arguments, function* (e, r = {}) {
878
+ return a(this, arguments, function* (e, r = {}) {
878
879
  try {
879
- return { success: !0, result: (yield this.model.insertMany(e, r)).map((u) => u instanceof W ? u.toObject() : null).filter((u) => u !== null) };
880
+ return { success: !0, result: (yield this.model.insertMany(e, r)).map((c) => c instanceof W ? c.toObject() : null).filter((c) => c !== null) };
880
881
  } catch (s) {
881
- return f(s);
882
+ return d(s);
882
883
  }
883
884
  });
884
885
  }
@@ -891,18 +892,18 @@ class xe {
891
892
  * @returns A promise that resolves to a standardized response with the updated document.
892
893
  */
893
894
  updateOne() {
894
- return l(this, arguments, function* (t = {}, e = {}, r = {}) {
895
+ return a(this, arguments, function* (t = {}, e = {}, r = {}) {
895
896
  try {
896
- const s = V(t), c = yield this.model.findOneAndUpdate(s, e, S({
897
+ const s = b(t), u = yield this.model.findOneAndUpdate(s, e, S({
897
898
  new: !0
898
899
  }, r)).exec();
899
- return c ? { success: !0, result: c } : {
900
+ return u ? { success: !0, result: u } : {
900
901
  success: !1,
901
902
  message: `Failed to update ${this.getModelName()}.`,
902
- code: v.NOT_FOUND.CODE
903
+ code: R.NOT_FOUND.CODE
903
904
  };
904
905
  } catch (s) {
905
- return f(s);
906
+ return d(s);
906
907
  }
907
908
  });
908
909
  }
@@ -915,12 +916,12 @@ class xe {
915
916
  * @returns A promise that resolves to a standardized response with the update result.
916
917
  */
917
918
  updateMany() {
918
- return l(this, arguments, function* (t = {}, e = {}, r = {}) {
919
+ return a(this, arguments, function* (t = {}, e = {}, r = {}) {
919
920
  try {
920
- const s = V(t);
921
+ const s = b(t);
921
922
  return { success: !0, result: yield this.model.updateMany(s, e, r).exec() };
922
923
  } catch (s) {
923
- return f(s);
924
+ return d(s);
924
925
  }
925
926
  });
926
927
  }
@@ -932,16 +933,16 @@ class xe {
932
933
  * @returns A promise that resolves to a standardized response with the deleted document.
933
934
  */
934
935
  deleteOne() {
935
- return l(this, arguments, function* (t = {}, e = {}) {
936
+ return a(this, arguments, function* (t = {}, e = {}) {
936
937
  try {
937
- const r = V(t), s = yield this.model.findOneAndDelete(r, e).exec();
938
+ const r = b(t), s = yield this.model.findOneAndDelete(r, e).exec();
938
939
  return s ? { success: !0, result: s } : {
939
940
  success: !1,
940
941
  message: `No ${this.getModelName()} found to delete.`,
941
- code: v.NOT_FOUND.CODE
942
+ code: R.NOT_FOUND.CODE
942
943
  };
943
944
  } catch (r) {
944
- return f(r);
945
+ return d(r);
945
946
  }
946
947
  });
947
948
  }
@@ -953,16 +954,16 @@ class xe {
953
954
  * @returns A promise that resolves to a standardized response with the delete result.
954
955
  */
955
956
  deleteMany() {
956
- return l(this, arguments, function* (t = {}, e = {}) {
957
+ return a(this, arguments, function* (t = {}, e = {}) {
957
958
  try {
958
- const r = V(t), s = yield this.model.deleteMany(r, e).exec();
959
+ const r = b(t), s = yield this.model.deleteMany(r, e).exec();
959
960
  return s.deletedCount === 0 ? {
960
961
  success: !1,
961
962
  message: "No documents found to delete.",
962
- code: v.NOT_FOUND.CODE
963
+ code: R.NOT_FOUND.CODE
963
964
  } : { success: !0, result: s };
964
965
  } catch (r) {
965
- return f(r);
966
+ return d(r);
966
967
  }
967
968
  });
968
969
  }
@@ -975,23 +976,23 @@ class xe {
975
976
  * @returns A promise that resolves to a standardized response with the unique short ID.
976
977
  */
977
978
  createShortId(t, e = 4) {
978
- return l(this, null, function* () {
979
+ return a(this, null, function* () {
979
980
  try {
980
- const s = Array.from({ length: 10 }, (o, i) => se(t, i + e)), u = (yield Promise.all(
981
- s.map((o) => this.model.exists({ shortId: o }))
982
- )).findIndex((o) => !o);
983
- if (u !== -1) {
984
- const o = s[u];
985
- if (o)
986
- return { success: !0, result: o };
981
+ const s = Array.from({ length: 10 }, (i, o) => ne(t, o + e)), c = (yield Promise.all(
982
+ s.map((i) => this.model.exists({ shortId: i }))
983
+ )).findIndex((i) => !i);
984
+ if (c !== -1) {
985
+ const i = s[c];
986
+ if (i)
987
+ return { success: !0, result: i };
987
988
  }
988
989
  return {
989
990
  success: !1,
990
991
  message: "Failed to create a unique shortId",
991
- code: v.INTERNAL_SERVER_ERROR.CODE
992
+ code: R.INTERNAL_SERVER_ERROR.CODE
992
993
  };
993
994
  } catch (r) {
994
- return f(r);
995
+ return d(r);
995
996
  }
996
997
  });
997
998
  }
@@ -1006,17 +1007,17 @@ class xe {
1006
1007
  * @param options.filter - Additional filter conditions to apply to the query.
1007
1008
  * @returns A MongoDB query object for checking slug existence.
1008
1009
  */
1009
- createSlugQuery({ slug: t, field: e, isObject: r, filter: s }) {
1010
- const c = S({}, s != null ? s : {});
1011
- return r ? w(S({}, c), {
1010
+ createSlugQuery({ slug: t, field: e, isObject: r, haveHistory: s = !1, filter: u }) {
1011
+ const c = S({}, u != null ? u : {});
1012
+ return r ? F(S({}, c), {
1012
1013
  $or: [
1013
1014
  { [`slug.${e}`]: t },
1014
- { slugHistory: { $elemMatch: { [`slug.${e}`]: t } } }
1015
+ ...s ? [{ slugHistory: { $elemMatch: { [`slug.${e}`]: t } } }] : []
1015
1016
  ]
1016
- }) : w(S({}, c), {
1017
+ }) : F(S({}, c), {
1017
1018
  $or: [
1018
1019
  { slug: t },
1019
- { slugHistory: t }
1020
+ ...s ? [{ slugHistory: t }] : []
1020
1021
  ]
1021
1022
  });
1022
1023
  }
@@ -1032,18 +1033,23 @@ class xe {
1032
1033
  * @returns A promise that resolves to a unique slug string.
1033
1034
  */
1034
1035
  createUniqueSlug(t) {
1035
- return l(this, arguments, function* ({ slug: e, field: r, isObject: s, filter: c }) {
1036
- const u = j(e), i = Array.from({ length: 100 }, (m, p) => p === 0 ? u : `${u}-${p}`), d = (yield Promise.all(
1037
- i.map(
1038
- (m) => this.model.exists(this.createSlugQuery({ slug: m, field: r, isObject: s, filter: c }))
1039
- )
1040
- )).findIndex((m) => !m);
1041
- if (d !== -1) {
1042
- const m = i[d];
1043
- if (m)
1036
+ return a(this, arguments, function* ({ slug: e, field: r, isObject: s, haveHistory: u, filter: c }) {
1037
+ if (!e || typeof e != "string")
1038
+ throw new Error("Invalid slug provided: must be a non-empty string");
1039
+ const i = I(e);
1040
+ if (!(yield this.model.exists(
1041
+ this.createSlugQuery({ slug: i, field: r, isObject: s, haveHistory: u, filter: c })
1042
+ )))
1043
+ return i;
1044
+ for (let O = 1; O <= X; O++) {
1045
+ const m = `${i}-${O}`;
1046
+ if (!(yield this.model.exists(
1047
+ this.createSlugQuery({ slug: m, field: r, isObject: s, haveHistory: u, filter: c })
1048
+ )))
1044
1049
  return m;
1045
1050
  }
1046
- return `${u}-${Date.now()}`;
1051
+ const l = Date.now(), f = Math.random().toString(36).substring(2, 8);
1052
+ return `${i}-${l}-${f}`;
1047
1053
  });
1048
1054
  }
1049
1055
  /**
@@ -1057,29 +1063,31 @@ class xe {
1057
1063
  * @returns A promise that resolves to a standardized response with the created slug(s).
1058
1064
  */
1059
1065
  createSlug(t) {
1060
- return l(this, arguments, function* ({ field: e, from: r, filter: s }) {
1066
+ return a(this, arguments, function* ({ field: e, from: r, filter: s, haveHistory: u }) {
1061
1067
  try {
1062
1068
  const c = r[e];
1063
- return T(c) ? { success: !0, result: Object.fromEntries(
1069
+ return $(c) ? { success: !0, result: Object.fromEntries(
1064
1070
  yield Promise.all(
1065
- Object.entries(c).map((a) => l(this, [a], function* ([d, m]) {
1066
- const p = yield this.createUniqueSlug({
1071
+ Object.entries(c).map((f) => a(this, [f], function* ([O, m]) {
1072
+ const g = yield this.createUniqueSlug({
1067
1073
  slug: m,
1068
- field: d,
1074
+ field: O,
1069
1075
  isObject: !0,
1076
+ haveHistory: u,
1070
1077
  filter: s
1071
1078
  });
1072
- return [d, p];
1079
+ return [O, g];
1073
1080
  }))
1074
1081
  )
1075
1082
  ) } : { success: !0, result: yield this.createUniqueSlug({
1076
1083
  slug: c,
1077
1084
  field: e,
1078
1085
  isObject: !1,
1086
+ haveHistory: u,
1079
1087
  filter: s
1080
1088
  }) };
1081
1089
  } catch (c) {
1082
- return f(c);
1090
+ return d(c);
1083
1091
  }
1084
1092
  });
1085
1093
  }
@@ -1095,31 +1103,32 @@ class xe {
1095
1103
  * @returns A promise that resolves to a standardized response indicating whether the slug exists.
1096
1104
  */
1097
1105
  checkSlug(t) {
1098
- return l(this, arguments, function* ({ slug: e, field: r, from: s, filter: c }) {
1106
+ return a(this, arguments, function* ({ slug: e, field: r, from: s, filter: u, haveHistory: c }) {
1099
1107
  try {
1100
- const u = s[r];
1101
- if (T(u)) {
1102
- const m = Object.values(u).map((h) => j(h));
1108
+ const i = s[r];
1109
+ if ($(i)) {
1110
+ const m = Object.values(i).map((v) => I(v));
1103
1111
  return (yield Promise.all(
1104
1112
  m.map(
1105
- (h) => this.model.exists(this.createSlugQuery({
1106
- slug: h,
1113
+ (v) => this.model.exists(this.createSlugQuery({
1114
+ slug: v,
1107
1115
  field: r,
1108
1116
  isObject: !0,
1109
- filter: c
1117
+ haveHistory: c,
1118
+ filter: u
1110
1119
  }))
1111
1120
  )
1112
- )).some((h) => h) ? { success: !0, result: !0 } : { success: !0, result: !1 };
1121
+ )).some((v) => v) ? { success: !0, result: !0 } : { success: !0, result: !1 };
1113
1122
  }
1114
- const i = j(e);
1123
+ const l = I(e);
1115
1124
  return { success: !0, result: (yield this.model.exists(this.createSlugQuery({
1116
- slug: i,
1125
+ slug: l,
1117
1126
  field: r,
1118
1127
  isObject: !1,
1119
- filter: c
1128
+ filter: u
1120
1129
  }))) !== null };
1121
- } catch (u) {
1122
- return f(u);
1130
+ } catch (i) {
1131
+ return d(i);
1123
1132
  }
1124
1133
  });
1125
1134
  }
@@ -1130,17 +1139,17 @@ class xe {
1130
1139
  * @returns A promise that resolves to a standardized response with the aggregation results.
1131
1140
  */
1132
1141
  aggregate(t) {
1133
- return l(this, null, function* () {
1142
+ return a(this, null, function* () {
1134
1143
  try {
1135
1144
  return { success: !0, result: yield this.model.aggregate(t) };
1136
1145
  } catch (e) {
1137
- return f(e);
1146
+ return d(e);
1138
1147
  }
1139
1148
  });
1140
1149
  }
1141
1150
  }
1142
1151
  export {
1143
- be as MongoController,
1144
- xe as MongooseController,
1145
- b as mongo
1152
+ Me as MongoController,
1153
+ we as MongooseController,
1154
+ x as mongo
1146
1155
  };