@cyberskill/shared 2.3.0 → 2.3.1

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,44 @@
1
- import { cloneDeep as U, isObject as $ } from "lodash-es";
2
- import k from "migrate-mongo";
3
- import { Document as K } from "mongoose";
4
- import W from "mongoose-aggregate-paginate-v2";
5
- import Q from "mongoose-paginate-v2";
6
- import { v4 as F } from "uuid";
7
- import { getNestedValue as H, setNestedValue as J } from "../../util/object/object.util.js";
8
- import { regexSearchMapper as z } from "../../util/common/common.util.js";
9
- import { writeFileSync as G, pathExistsSync as X, readFileSync as Y, appendFileSync as Z } from "../fs/fs.util.js";
1
+ import { cloneDeep as B, isObject as T } from "lodash-es";
2
+ import K from "migrate-mongo";
3
+ import { Document as W } from "mongoose";
4
+ import Q from "mongoose-aggregate-paginate-v2";
5
+ import H from "mongoose-paginate-v2";
6
+ import { v4 as $ } from "uuid";
7
+ import { getNestedValue as J, setNestedValue as z } from "../../util/object/object.util.js";
8
+ import { regexSearchMapper as X } from "../../util/common/common.util.js";
9
+ import { writeFileSync as G, pathExistsSync as Y, readFileSync as Z, appendFileSync as ee } from "../fs/fs.util.js";
10
10
  import { PATH as x, MIGRATE_MONGO_CONFIG as q } from "../path/path.constant.js";
11
- import { validate as ee } from "../../util/validate/validate.util.js";
12
- import { generateShortId as te, generateSlug as j } from "../../util/string/string.util.js";
13
- import { RESPONSE_STATUS as R } from "../../constant/response-status.js";
14
- import { catchError as f } from "../log/log.util.js";
15
- var re = Object.defineProperty, se = Object.defineProperties, ne = Object.getOwnPropertyDescriptors, L = Object.getOwnPropertySymbols, ce = Object.prototype.hasOwnProperty, ue = Object.prototype.propertyIsEnumerable, T = (n, t, e) => t in n ? re(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, E = (n, t) => {
11
+ import { validate as te } from "../../util/validate/validate.util.js";
12
+ import { generateShortId as re, generateSlug as I } from "../../util/string/string.util.js";
13
+ import { RESPONSE_STATUS as v } from "../../constant/response-status.js";
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) => {
16
16
  for (var e in t || (t = {}))
17
- ce.call(t, e) && T(n, e, t[e]);
17
+ ce.call(t, e) && j(s, e, t[e]);
18
18
  if (L)
19
19
  for (var e of L(t))
20
- ue.call(t, e) && T(n, e, t[e]);
21
- return n;
22
- }, w = (n, t) => se(n, ne(t)), oe = (n, t, e) => T(n, typeof t != "symbol" ? t + "" : t, e), a = (n, t, e) => new Promise((r, s) => {
23
- var c = (i) => {
20
+ oe.call(t, e) && j(s, e, t[e]);
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) => {
24
24
  try {
25
- o(e.next(i));
26
- } catch (l) {
27
- s(l);
25
+ i(e.next(o));
26
+ } catch (a) {
27
+ n(a);
28
28
  }
29
- }, u = (i) => {
29
+ }, c = (o) => {
30
30
  try {
31
- o(e.throw(i));
32
- } catch (l) {
33
- s(l);
31
+ i(e.throw(o));
32
+ } catch (a) {
33
+ n(a);
34
34
  }
35
- }, o = (i) => i.done ? r(i.value) : Promise.resolve(i.value).then(c, u);
36
- o((e = e.apply(n, t)).next());
35
+ }, i = (o) => o.done ? r(o.value) : Promise.resolve(o.value).then(u, c);
36
+ i((e = e.apply(s, t)).next());
37
37
  });
38
- function ie(n) {
39
- return n === n.toUpperCase() ? n.charAt(0).toUpperCase() + n.slice(1).toLowerCase() : n;
38
+ function le(s) {
39
+ return s === s.toUpperCase() ? s.charAt(0).toUpperCase() + s.slice(1).toLowerCase() : s;
40
40
  }
41
- const b = {
41
+ const V = {
42
42
  /**
43
43
  * Creates generic fields that are commonly used across MongoDB documents.
44
44
  * This function generates standard fields including a UUID, deletion flag, and timestamps
@@ -48,7 +48,7 @@ const b = {
48
48
  */
49
49
  createGenericFields() {
50
50
  return {
51
- id: F(),
51
+ id: $(),
52
52
  isDel: !1,
53
53
  createdAt: /* @__PURE__ */ new Date(),
54
54
  updatedAt: /* @__PURE__ */ new Date()
@@ -62,8 +62,8 @@ const b = {
62
62
  * @param schema - The Mongoose schema to apply plugins to.
63
63
  * @param plugins - An array of plugin functions or false values to filter and apply.
64
64
  */
65
- applyPlugins(n, t) {
66
- t.filter((e) => typeof e == "function").forEach((e) => n.plugin(e));
65
+ applyPlugins(s, t) {
66
+ t.filter((e) => typeof e == "function").forEach((e) => s.plugin(e));
67
67
  },
68
68
  /**
69
69
  * Applies middleware functions to a Mongoose schema.
@@ -72,9 +72,9 @@ const b = {
72
72
  * @param schema - The Mongoose schema to apply middleware to.
73
73
  * @param middlewares - An array of middleware configurations with method, pre, and post functions.
74
74
  */
75
- applyMiddlewares(n, t) {
76
- t.forEach(({ method: e, pre: r, post: s }) => {
77
- e && r && n.pre(e, r), e && s && n.post(e, s);
75
+ applyMiddlewares(s, t) {
76
+ t.forEach(({ method: e, pre: r, post: n }) => {
77
+ e && r && s.pre(e, r), e && n && s.post(e, n);
78
78
  });
79
79
  },
80
80
  /**
@@ -85,10 +85,10 @@ const b = {
85
85
  * @param mongoose - The Mongoose instance to create the schema with.
86
86
  * @returns A Mongoose schema with generic document fields.
87
87
  */
88
- createGenericSchema(n) {
89
- return new n.Schema(
88
+ createGenericSchema(s) {
89
+ return new s.Schema(
90
90
  {
91
- id: { type: String, default: F, unique: !0 },
91
+ id: { type: String, default: $, unique: !0 },
92
92
  isDel: { type: Boolean, default: !1 }
93
93
  },
94
94
  { timestamps: !0 }
@@ -107,34 +107,34 @@ const b = {
107
107
  * @returns A configured Mongoose schema.
108
108
  */
109
109
  createSchema({
110
- mongoose: n,
110
+ mongoose: s,
111
111
  schema: t,
112
112
  virtuals: e = [],
113
113
  standalone: r = !1
114
114
  }) {
115
- const s = new n.Schema(t, {
115
+ const n = new s.Schema(t, {
116
116
  toJSON: { virtuals: !0 },
117
117
  // So `res.json()` and other `JSON.stringify()` functions include virtuals
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: 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
121
+ return e.forEach(({ name: u, options: c, get: i }) => {
122
+ if (V.isDynamicVirtual(c)) {
123
+ const o = n.statics;
124
+ o._dynamicVirtuals || (o._dynamicVirtuals = []), o._dynamicVirtuals.push({
125
+ name: u,
126
+ options: c
127
127
  });
128
- const l = s.virtual(c);
129
- o ? l.get(o) : l.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 : []);
128
+ const a = n.virtual(u);
129
+ i ? a.get(i) : a.get(function() {
130
+ var f;
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 i = s.virtual(c, u);
135
- o && i.get(o);
134
+ const o = n.virtual(u, c);
135
+ i && o.get(i);
136
136
  }
137
- }), r || s.add(b.createGenericSchema(n)), s;
137
+ }), r || n.add(V.createGenericSchema(s)), n;
138
138
  },
139
139
  /**
140
140
  * Creates a Mongoose model with plugins, middleware, and pagination support.
@@ -153,23 +153,23 @@ const b = {
153
153
  * @throws {Error} When the model name is not provided.
154
154
  */
155
155
  createModel({
156
- mongoose: n,
156
+ mongoose: s,
157
157
  name: t,
158
158
  schema: e,
159
159
  virtuals: r = [],
160
- pagination: s = !0,
161
- aggregate: c = !0,
162
- middlewares: u = []
160
+ pagination: n = !0,
161
+ aggregate: u = !0,
162
+ middlewares: c = []
163
163
  }) {
164
164
  if (!t)
165
165
  throw new Error("Model name is required.");
166
- if (n.models[t])
167
- return n.models[t];
168
- const o = b.createSchema({ mongoose: n, schema: e, virtuals: r });
169
- return (s || c) && b.applyPlugins(o, [
170
- s && Q,
171
- c && W
172
- ]), b.applyMiddlewares(o, u), n.model(t, o);
166
+ if (s.models[t])
167
+ return s.models[t];
168
+ const i = V.createSchema({ mongoose: s, schema: e, virtuals: r });
169
+ return (n || u) && V.applyPlugins(i, [
170
+ n && H,
171
+ u && Q
172
+ ]), V.applyMiddlewares(i, c), s.model(t, i);
173
173
  },
174
174
  /**
175
175
  * Validation utilities for Mongoose schemas.
@@ -184,9 +184,9 @@ const b = {
184
184
  * @returns A validation function that returns true if the field is not empty.
185
185
  */
186
186
  isRequired() {
187
- return function(n) {
188
- return a(this, null, function* () {
189
- return !ee.isEmpty(n);
187
+ return function(s) {
188
+ return l(this, null, function* () {
189
+ return !te.isEmpty(s);
190
190
  });
191
191
  };
192
192
  },
@@ -199,12 +199,12 @@ const b = {
199
199
  * @returns A validation function that returns true if the value is unique across the specified fields.
200
200
  * @throws {Error} When fields is not a non-empty array of strings.
201
201
  */
202
- isUnique(n) {
202
+ isUnique(s) {
203
203
  return function(t) {
204
- return a(this, null, function* () {
205
- if (!Array.isArray(n) || n.length === 0)
204
+ return l(this, null, function* () {
205
+ if (!Array.isArray(s) || s.length === 0)
206
206
  throw new Error("Fields must be a non-empty array of strings.");
207
- const e = { $or: n.map((s) => ({ [s]: t })) };
207
+ const e = { $or: s.map((n) => ({ [n]: t })) };
208
208
  return !(yield this.constructor.exists(e));
209
209
  });
210
210
  };
@@ -218,12 +218,12 @@ const b = {
218
218
  * @returns A validation function that returns true if the value matches all regex patterns.
219
219
  * @throws {Error} When regexArray is not an array of valid RegExp objects.
220
220
  */
221
- matchesRegex(n) {
221
+ matchesRegex(s) {
222
222
  return function(t) {
223
- return a(this, null, function* () {
224
- if (!Array.isArray(n) || n.some((e) => !(e instanceof RegExp)))
223
+ return l(this, null, function* () {
224
+ if (!Array.isArray(s) || s.some((e) => !(e instanceof RegExp)))
225
225
  throw new Error("regexArray must be an array of valid RegExp objects.");
226
- return n.every((e) => e.test(t));
226
+ return s.every((e) => e.test(t));
227
227
  });
228
228
  };
229
229
  }
@@ -232,7 +232,7 @@ const b = {
232
232
  * Migration utilities for MongoDB.
233
233
  * This object extends the migrate-mongo library with additional configuration utilities.
234
234
  */
235
- migrate: w(E({}, k), {
235
+ migrate: w(S({}, K), {
236
236
  /**
237
237
  * Sets the migration configuration and updates .gitignore.
238
238
  * This function creates a migration configuration file and ensures it's properly
@@ -240,15 +240,15 @@ const b = {
240
240
  *
241
241
  * @param options - Migration configuration options to write to the config file.
242
242
  */
243
- setConfig: (n) => {
243
+ setConfig: (s) => {
244
244
  const t = `// This file is automatically generated by the Cyberskill CLI.
245
- module.exports = ${JSON.stringify(n, null, 4)}`;
245
+ module.exports = ${JSON.stringify(s, null, 4)}`;
246
246
  G(x.MIGRATE_MONGO_CONFIG, t);
247
247
  const e = `
248
248
  ${q}
249
249
  `;
250
- X(x.GIT_IGNORE) ? Y(x.GIT_IGNORE, "utf-8").split(`
251
- `).includes(q) || Z(x.GIT_IGNORE, e) : G(x.GIT_IGNORE, e);
250
+ Y(x.GIT_IGNORE) ? Z(x.GIT_IGNORE, "utf-8").split(`
251
+ `).includes(q) || ee(x.GIT_IGNORE, e) : G(x.GIT_IGNORE, e);
252
252
  }
253
253
  }),
254
254
  /**
@@ -260,20 +260,20 @@ ${q}
260
260
  * @param fields - An array of field names to convert to regex patterns.
261
261
  * @returns A new filter object with string values converted to regex patterns.
262
262
  */
263
- regexify(n, t) {
264
- if (!n)
263
+ regexify(s, t) {
264
+ if (!s)
265
265
  return {};
266
- let e = U(n);
266
+ let e = B(s);
267
267
  if (!t || t.length === 0)
268
268
  return e;
269
269
  for (const r of t) {
270
- const s = r.toString().split("."), c = H(e, s);
271
- if (typeof c == "string" && c.length > 0) {
272
- const u = {
273
- $regex: `.*${z(c)}.*`,
270
+ const n = r.toString().split("."), u = J(e, n);
271
+ if (typeof u == "string" && u.length > 0) {
272
+ const c = {
273
+ $regex: `.*${X(u)}.*`,
274
274
  $options: "i"
275
275
  };
276
- e = J(e, s, u);
276
+ e = z(e, n, c);
277
277
  }
278
278
  }
279
279
  return e;
@@ -284,137 +284,161 @@ ${q}
284
284
  * @param options - The virtual options to check.
285
285
  * @returns True if the options contain a dynamic ref function.
286
286
  */
287
- isDynamicVirtual(n) {
288
- return !!(n && typeof n.ref == "function");
287
+ isDynamicVirtual(s) {
288
+ return !!(s && typeof s.ref == "function");
289
289
  }
290
290
  };
291
- function le(n) {
292
- return n !== null && typeof n == "object" && "toObject" in n && typeof n.toObject == "function";
291
+ function ae(s) {
292
+ return s !== null && typeof s == "object" && "toObject" in s && typeof s.toObject == "function";
293
293
  }
294
- function ae(n, t, e) {
295
- if (!n.length || !t || !(e != null && e.ref))
294
+ function F(s, t) {
295
+ if (!s || !t || t.length === 0)
296
+ return s;
297
+ const e = new Set(t.map((r) => r.name));
298
+ if (Array.isArray(s)) {
299
+ const r = s.filter((n) => {
300
+ if (typeof n == "string")
301
+ return !e.has(n);
302
+ if (typeof n == "object" && n !== null) {
303
+ const u = n;
304
+ return !e.has(u.path || u.populate || "");
305
+ }
306
+ return !0;
307
+ });
308
+ return r.length > 0 ? r : void 0;
309
+ }
310
+ if (typeof s == "string")
311
+ return e.has(s) ? void 0 : s;
312
+ if (typeof s == "object" && s !== null) {
313
+ const r = s, n = r.path || r.populate || "";
314
+ return e.has(n) ? void 0 : s;
315
+ }
316
+ return s;
317
+ }
318
+ function de(s, t, e) {
319
+ if (!s.length || !t || !(e != null && e.ref))
296
320
  return [];
297
321
  const r = /* @__PURE__ */ new Map();
298
- return n.forEach((s) => {
322
+ return s.forEach((n) => {
299
323
  try {
300
- const c = e.ref(s);
301
- if (c == null)
324
+ const u = e.ref(n);
325
+ if (u == null)
302
326
  return;
303
- const u = typeof c == "string" ? c : String(c);
304
- if (u && u.trim() !== "") {
305
- const o = ie(u);
306
- r.has(o) || r.set(o, []), r.get(o).push(s);
327
+ const c = typeof u == "string" ? u : String(u);
328
+ if (c && c.trim() !== "") {
329
+ const i = le(c);
330
+ r.has(i) || r.set(i, []), r.get(i).push(n);
307
331
  }
308
- } catch (c) {
309
- f(new Error(`Dynamic ref function failed for virtual "${t}": ${c instanceof Error ? c.message : String(c)}`));
332
+ } catch (u) {
333
+ d(new Error(`Dynamic ref function failed for virtual "${t}": ${u instanceof Error ? u.message : String(u)}`));
310
334
  }
311
- }), Array.from(r.entries()).map(([s, c]) => ({ model: s, docs: c }));
335
+ }), Array.from(r.entries()).map(([n, u]) => ({ model: n, docs: u }));
312
336
  }
313
- function P(n, t, e, r, s) {
314
- return a(this, null, function* () {
337
+ function U(s, t, e, r, n) {
338
+ return l(this, null, function* () {
315
339
  if (!t.length || !e.length || !r)
316
340
  return t;
317
- const c = e.filter((i) => {
341
+ const u = e.filter((o) => {
318
342
  if (Array.isArray(r))
319
- return r.length > 0 && r.some((l) => typeof l == "string" ? l === i.name : l.path === i.name);
343
+ return r.length > 0 && r.some((a) => typeof a == "string" ? a === o.name : a.path === o.name);
320
344
  if (typeof r == "string")
321
- return r === i.name;
345
+ return r === o.name;
322
346
  if (typeof r == "object" && r !== null) {
323
- const l = r;
324
- return l.path && l.path === i.name || l.populate && l.populate === i.name;
347
+ const a = r;
348
+ return a.path && a.path === o.name || a.populate && a.populate === o.name;
325
349
  }
326
350
  return !1;
327
351
  });
328
- if (c.length === 0)
352
+ if (u.length === 0)
329
353
  return t;
330
- const u = U(t.map(
331
- (i) => le(i) ? i.toObject() : i
354
+ const c = B(t.map(
355
+ (o) => ae(o) ? o.toObject() : o
332
356
  ));
333
- u.forEach((i) => {
334
- c.forEach(({ name: l, options: d }) => {
335
- if (!(l in i)) {
336
- const m = i;
337
- m[l] = d.count ? 0 : d.justOne ? null : [];
357
+ c.forEach((o) => {
358
+ u.forEach(({ name: a, options: f }) => {
359
+ if (!(a in o)) {
360
+ const m = o;
361
+ m[a] = f.count ? 0 : f.justOne ? null : [];
338
362
  }
339
363
  });
340
364
  });
341
- const o = /* @__PURE__ */ new Map();
342
- for (const i of c) {
343
- const { name: l, options: d } = i, m = ae(u, l, d);
365
+ const i = /* @__PURE__ */ new Map();
366
+ for (const o of u) {
367
+ const { name: a, options: f } = o, m = de(c, a, f);
344
368
  for (const p of m) {
345
- o.has(p.model) || o.set(p.model, {
369
+ i.has(p.model) || i.set(p.model, {
346
370
  virtuals: [],
347
371
  localValueSets: /* @__PURE__ */ new Map(),
348
372
  docsByLocalValue: /* @__PURE__ */ new Map()
349
373
  });
350
- const h = o.get(p.model);
351
- h.virtuals.find((N) => N.name === l) || (h.virtuals.push(i), h.localValueSets.set(l, /* @__PURE__ */ new Set()));
352
- const M = h.localValueSets.get(l);
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);
353
377
  p.docs.forEach((N) => {
354
- const C = N[d.localField];
378
+ const C = N[f.localField];
355
379
  if (C != null) {
356
- const _ = String(C);
357
- M.add(_);
358
- let v = -1;
359
- const D = N;
360
- D.id !== void 0 ? v = u.findIndex((V) => V.id === D.id) : D._id !== void 0 && (v = u.findIndex((V) => {
361
- var O, y, S, g;
362
- return ((y = (O = V._id) == null ? void 0 : O.toString) == null ? void 0 : y.call(O)) === ((g = (S = D._id) == null ? void 0 : S.toString) == null ? void 0 : g.call(S));
363
- })), v !== -1 && (h.docsByLocalValue.has(_) || h.docsByLocalValue.set(_, []), h.docsByLocalValue.get(_).push(v));
380
+ const D = String(C);
381
+ M.add(D);
382
+ let _ = -1;
383
+ const R = N;
384
+ R.id !== void 0 ? _ = c.findIndex((b) => b.id === R.id) : R._id !== void 0 && (_ = c.findIndex((b) => {
385
+ var O, y, E, g;
386
+ return ((y = (O = b._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));
387
+ })), _ !== -1 && (h.docsByLocalValue.has(D) || h.docsByLocalValue.set(D, []), h.docsByLocalValue.get(D).push(_));
364
388
  }
365
389
  });
366
390
  }
367
391
  }
368
- return yield Promise.all(Array.from(o.entries()).map((i) => a(null, [i], function* ([l, d]) {
369
- const m = n.models[l];
392
+ return yield Promise.all(Array.from(i.entries()).map((o) => l(null, [o], function* ([a, f]) {
393
+ const m = s.models[a];
370
394
  if (!m)
371
395
  return;
372
396
  const p = /* @__PURE__ */ new Set();
373
- if (d.localValueSets.forEach((_) => {
374
- _.forEach((v) => p.add(v));
397
+ if (f.localValueSets.forEach((D) => {
398
+ D.forEach((_) => p.add(_));
375
399
  }), p.size === 0)
376
400
  return;
377
- const h = [...new Set(d.virtuals.map((_) => _.options.foreignField))], M = Array.from(p);
401
+ const h = [...new Set(f.virtuals.map((D) => D.options.foreignField))], M = Array.from(p);
378
402
  let N;
379
- h.length === 1 ? N = { [String(h[0])]: { $in: M } } : N = { $or: h.map((_) => ({ [_]: { $in: M } })) };
380
- const C = yield m.find(N, s).lean();
381
- for (const _ of d.virtuals) {
382
- const { name: v, options: D } = _, V = C.filter((O) => {
383
- const y = O[D.foreignField];
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();
405
+ for (const D of f.virtuals) {
406
+ const { name: _, options: R } = D, b = C.filter((O) => {
407
+ const y = O[R.foreignField];
384
408
  return y != null && p.has(String(y));
385
409
  });
386
- if (D.count) {
410
+ if (R.count) {
387
411
  const O = /* @__PURE__ */ new Map();
388
- V.forEach((y) => {
389
- var S;
390
- const g = (S = y[D.foreignField]) == null ? void 0 : S.toString();
412
+ b.forEach((y) => {
413
+ var E;
414
+ const g = (E = y[R.foreignField]) == null ? void 0 : E.toString();
391
415
  g && O.set(g, (O.get(g) || 0) + 1);
392
- }), d.localValueSets.get(v).forEach((y) => {
393
- const S = d.docsByLocalValue.get(y) || [], g = O.get(y) || 0;
394
- S.forEach((A) => {
395
- const I = u[A];
396
- I[v] === void 0 && (I[v] = g);
416
+ }), f.localValueSets.get(_).forEach((y) => {
417
+ const E = f.docsByLocalValue.get(y) || [], g = O.get(y) || 0;
418
+ E.forEach((A) => {
419
+ const P = c[A];
420
+ P[_] === void 0 && (P[_] = g);
397
421
  });
398
422
  });
399
423
  } else {
400
424
  const O = /* @__PURE__ */ new Map();
401
- V.forEach((y) => {
402
- var S;
403
- const g = (S = y[D.foreignField]) == null ? void 0 : S.toString();
425
+ b.forEach((y) => {
426
+ var E;
427
+ const g = (E = y[R.foreignField]) == null ? void 0 : E.toString();
404
428
  g && (O.has(g) || O.set(g, []), O.get(g).push(y));
405
- }), d.localValueSets.get(v).forEach((y) => {
406
- const S = d.docsByLocalValue.get(y) || [], g = O.get(y) || [], A = D.justOne ? g[0] || null : g;
407
- S.forEach((I) => {
408
- const B = u[I];
409
- B[v] = A;
429
+ }), f.localValueSets.get(_).forEach((y) => {
430
+ const E = f.docsByLocalValue.get(y) || [], g = O.get(y) || [], A = R.justOne ? g[0] || null : g;
431
+ E.forEach((P) => {
432
+ const k = c[P];
433
+ k[_] = A;
410
434
  });
411
435
  });
412
436
  }
413
437
  }
414
- }))), u;
438
+ }))), c;
415
439
  });
416
440
  }
417
- class Ne {
441
+ class Ve {
418
442
  /**
419
443
  * Creates a new MongoDB controller instance.
420
444
  *
@@ -422,7 +446,7 @@ class Ne {
422
446
  * @param collectionName - The name of the collection to operate on.
423
447
  */
424
448
  constructor(t, e) {
425
- oe(this, "collection"), this.collection = t.collection(e);
449
+ ie(this, "collection"), this.collection = t.collection(e);
426
450
  }
427
451
  /**
428
452
  * Creates a single document in the collection.
@@ -432,9 +456,9 @@ class Ne {
432
456
  * @returns A promise that resolves to a standardized response with the created document.
433
457
  */
434
458
  createOne(t) {
435
- return a(this, null, function* () {
459
+ return l(this, null, function* () {
436
460
  try {
437
- const e = E(E({}, b.createGenericFields()), t);
461
+ const e = S(S({}, V.createGenericFields()), t);
438
462
  return (yield this.collection.insertOne(e)).acknowledged ? {
439
463
  success: !0,
440
464
  message: "Document created successfully",
@@ -442,10 +466,10 @@ class Ne {
442
466
  } : {
443
467
  success: !1,
444
468
  message: "Document creation failed",
445
- code: R.INTERNAL_SERVER_ERROR.CODE
469
+ code: v.INTERNAL_SERVER_ERROR.CODE
446
470
  };
447
471
  } catch (e) {
448
- return f(e);
472
+ return d(e);
449
473
  }
450
474
  });
451
475
  }
@@ -457,20 +481,20 @@ class Ne {
457
481
  * @returns A promise that resolves to a standardized response with the created documents.
458
482
  */
459
483
  createMany(t) {
460
- return a(this, null, function* () {
484
+ return l(this, null, function* () {
461
485
  try {
462
- const e = t.map((s) => E(E({}, b.createGenericFields()), s)), r = yield this.collection.insertMany(e);
486
+ const e = t.map((n) => S(S({}, V.createGenericFields()), n)), r = yield this.collection.insertMany(e);
463
487
  return r.insertedCount === 0 ? {
464
488
  success: !1,
465
489
  message: "No documents were inserted",
466
- code: R.INTERNAL_SERVER_ERROR.CODE
490
+ code: v.INTERNAL_SERVER_ERROR.CODE
467
491
  } : {
468
492
  success: !0,
469
493
  message: `${r.insertedCount} documents created successfully`,
470
494
  result: e
471
495
  };
472
496
  } catch (e) {
473
- return f(e);
497
+ return d(e);
474
498
  }
475
499
  });
476
500
  }
@@ -481,12 +505,12 @@ class Ne {
481
505
  * @returns A promise that resolves to a standardized response with the found document.
482
506
  */
483
507
  findOne(t) {
484
- return a(this, null, function* () {
508
+ return l(this, null, function* () {
485
509
  try {
486
510
  const e = yield this.collection.findOne(t);
487
- return e ? { success: !0, message: "Document found", result: e } : { success: !1, message: "Document not found", code: R.NOT_FOUND.CODE };
511
+ return e ? { success: !0, message: "Document found", result: e } : { success: !1, message: "Document not found", code: v.NOT_FOUND.CODE };
488
512
  } catch (e) {
489
- return f(e);
513
+ return d(e);
490
514
  }
491
515
  });
492
516
  }
@@ -497,7 +521,7 @@ class Ne {
497
521
  * @returns A promise that resolves to a standardized response with the found documents.
498
522
  */
499
523
  findAll() {
500
- return a(this, arguments, function* (t = {}) {
524
+ return l(this, arguments, function* (t = {}) {
501
525
  try {
502
526
  return {
503
527
  success: !0,
@@ -505,7 +529,7 @@ class Ne {
505
529
  result: yield this.collection.find(t).toArray()
506
530
  };
507
531
  } catch (e) {
508
- return f(e);
532
+ return d(e);
509
533
  }
510
534
  });
511
535
  }
@@ -516,7 +540,7 @@ class Ne {
516
540
  * @returns A promise that resolves to a standardized response with the document count.
517
541
  */
518
542
  count() {
519
- return a(this, arguments, function* (t = {}) {
543
+ return l(this, arguments, function* (t = {}) {
520
544
  try {
521
545
  const e = yield this.collection.countDocuments(t);
522
546
  return {
@@ -525,7 +549,7 @@ class Ne {
525
549
  result: e
526
550
  };
527
551
  } catch (e) {
528
- return f(e);
552
+ return d(e);
529
553
  }
530
554
  });
531
555
  }
@@ -537,7 +561,7 @@ class Ne {
537
561
  * @returns A promise that resolves to a standardized response with the update result.
538
562
  */
539
563
  updateOne(t, e) {
540
- return a(this, null, function* () {
564
+ return l(this, null, function* () {
541
565
  try {
542
566
  const r = yield this.collection.updateOne(t, {
543
567
  $set: e
@@ -545,14 +569,14 @@ class Ne {
545
569
  return r.matchedCount === 0 ? {
546
570
  success: !1,
547
571
  message: "No documents matched the filter",
548
- code: R.INTERNAL_SERVER_ERROR.CODE
572
+ code: v.INTERNAL_SERVER_ERROR.CODE
549
573
  } : {
550
574
  success: !0,
551
575
  message: "Document updated successfully",
552
576
  result: r
553
577
  };
554
578
  } catch (r) {
555
- return f(r);
579
+ return d(r);
556
580
  }
557
581
  });
558
582
  }
@@ -564,7 +588,7 @@ class Ne {
564
588
  * @returns A promise that resolves to a standardized response with the update result.
565
589
  */
566
590
  updateMany(t, e) {
567
- return a(this, null, function* () {
591
+ return l(this, null, function* () {
568
592
  try {
569
593
  const r = yield this.collection.updateMany(t, {
570
594
  $set: e
@@ -572,14 +596,14 @@ class Ne {
572
596
  return r.matchedCount === 0 ? {
573
597
  success: !1,
574
598
  message: "No documents matched the filter",
575
- code: R.INTERNAL_SERVER_ERROR.CODE
599
+ code: v.INTERNAL_SERVER_ERROR.CODE
576
600
  } : {
577
601
  success: !0,
578
602
  message: "Documents updated successfully",
579
603
  result: r
580
604
  };
581
605
  } catch (r) {
582
- return f(r);
606
+ return d(r);
583
607
  }
584
608
  });
585
609
  }
@@ -590,20 +614,20 @@ class Ne {
590
614
  * @returns A promise that resolves to a standardized response with the delete result.
591
615
  */
592
616
  deleteOne(t) {
593
- return a(this, null, function* () {
617
+ return l(this, null, function* () {
594
618
  try {
595
619
  const e = yield this.collection.deleteOne(t);
596
620
  return e.deletedCount === 0 ? {
597
621
  success: !1,
598
622
  message: "No documents matched the filter",
599
- code: R.INTERNAL_SERVER_ERROR.CODE
623
+ code: v.INTERNAL_SERVER_ERROR.CODE
600
624
  } : {
601
625
  success: !0,
602
626
  message: "Document deleted successfully",
603
627
  result: e
604
628
  };
605
629
  } catch (e) {
606
- return f(e);
630
+ return d(e);
607
631
  }
608
632
  });
609
633
  }
@@ -614,20 +638,20 @@ class Ne {
614
638
  * @returns A promise that resolves to a standardized response with the delete result.
615
639
  */
616
640
  deleteMany(t) {
617
- return a(this, null, function* () {
641
+ return l(this, null, function* () {
618
642
  try {
619
643
  const e = yield this.collection.deleteMany(t);
620
644
  return e.deletedCount === 0 ? {
621
645
  success: !1,
622
646
  message: "No documents matched the filter",
623
- code: R.INTERNAL_SERVER_ERROR.CODE
647
+ code: v.INTERNAL_SERVER_ERROR.CODE
624
648
  } : {
625
649
  success: !0,
626
650
  message: "Documents deleted successfully",
627
651
  result: e
628
652
  };
629
653
  } catch (e) {
630
- return f(e);
654
+ return d(e);
631
655
  }
632
656
  });
633
657
  }
@@ -649,6 +673,44 @@ class be {
649
673
  getModelName() {
650
674
  return this.model.modelName;
651
675
  }
676
+ /**
677
+ * Gets the dynamic virtuals configuration from the model schema.
678
+ *
679
+ * @returns Array of dynamic virtual configurations or undefined if none exist.
680
+ */
681
+ getDynamicVirtuals() {
682
+ return this.model.schema.statics._dynamicVirtuals;
683
+ }
684
+ /**
685
+ * Populates dynamic virtuals for a single document.
686
+ *
687
+ * @param result - The document to populate dynamic virtuals for.
688
+ * @param populate - The populate options to determine which virtuals to populate.
689
+ * @returns The document with dynamic virtuals populated.
690
+ */
691
+ populateDynamicVirtualsForDocument(t, e) {
692
+ return l(this, null, function* () {
693
+ const r = this.getDynamicVirtuals();
694
+ if (r && r.length > 0) {
695
+ const n = yield U(this.model.base, [t], r, e);
696
+ return n && n[0] ? n[0] : t;
697
+ }
698
+ return t;
699
+ });
700
+ }
701
+ /**
702
+ * Populates dynamic virtuals for an array of documents.
703
+ *
704
+ * @param results - The documents to populate dynamic virtuals for.
705
+ * @param populate - The populate options to determine which virtuals to populate.
706
+ * @returns The documents with dynamic virtuals populated.
707
+ */
708
+ populateDynamicVirtualsForDocuments(t, e) {
709
+ return l(this, null, function* () {
710
+ const r = this.getDynamicVirtuals();
711
+ return r && r.length > 0 && t.length > 0 ? yield U(this.model.base, t, r, e) : t;
712
+ });
713
+ }
652
714
  /**
653
715
  * Finds a single document with optional population and projection.
654
716
  * Automatically handles dynamic virtual population if configured.
@@ -660,25 +722,18 @@ class be {
660
722
  * @returns A promise that resolves to a standardized response with the found document.
661
723
  */
662
724
  findOne() {
663
- return a(this, arguments, function* (t = {}, e = {}, r = {}, s) {
725
+ return l(this, arguments, function* (t = {}, e = {}, r = {}, n) {
664
726
  try {
665
- const c = this.model.findOne(t, e, r), o = this.model.schema.statics._dynamicVirtuals;
666
- s && (!o || o.length === 0) && c.populate(s);
667
- const i = yield c.exec();
668
- if (!i)
669
- return {
670
- success: !1,
671
- message: `No ${this.getModelName()} found.`,
672
- code: R.NOT_FOUND.CODE
673
- };
674
- let l = i;
675
- if (o && o.length > 0) {
676
- const d = yield P(this.model.base, [i], o, s);
677
- l = d && d[0] ? d[0] : i;
678
- }
679
- return { success: !0, result: l };
680
- } catch (c) {
681
- return f(c);
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) } : {
731
+ success: !1,
732
+ message: `No ${this.getModelName()} found.`,
733
+ code: v.NOT_FOUND.CODE
734
+ };
735
+ } catch (u) {
736
+ return d(u);
682
737
  }
683
738
  });
684
739
  }
@@ -693,15 +748,14 @@ class be {
693
748
  * @returns A promise that resolves to a standardized response with the found documents.
694
749
  */
695
750
  findAll() {
696
- return a(this, arguments, function* (t = {}, e = {}, r = {}, s) {
751
+ return l(this, arguments, function* (t = {}, e = {}, r = {}, n) {
697
752
  try {
698
- const c = this.model.find(t, e, r), o = this.model.schema.statics._dynamicVirtuals;
699
- s && (!o || o.length === 0) && c.populate(s);
700
- const i = yield c.exec();
701
- let l = i;
702
- return o && o.length > 0 && i.length > 0 && (l = yield P(this.model.base, i, o, s)), { success: !0, result: l };
703
- } catch (c) {
704
- return f(c);
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) };
757
+ } catch (u) {
758
+ return d(u);
705
759
  }
706
760
  });
707
761
  }
@@ -714,15 +768,14 @@ class be {
714
768
  * @returns A promise that resolves to a standardized response with paginated results.
715
769
  */
716
770
  findPaging() {
717
- return a(this, arguments, function* (t = {}, e = {}) {
771
+ return l(this, arguments, function* (t = {}, e = {}) {
718
772
  try {
719
- const s = this.model.schema.statics._dynamicVirtuals, c = E({}, e);
720
- s && s.length > 0 && (c.populate = void 0);
721
- const u = yield this.model.paginate(t, c);
722
- let o = u.docs;
723
- return s && s.length > 0 && u.docs.length > 0 && (o = yield P(this.model.base, u.docs, s, e.populate)), { success: !0, result: w(E({}, u), { docs: o }) };
773
+ const r = this.getDynamicVirtuals(), n = S({}, e);
774
+ e.populate && (n.populate = F(e.populate, r));
775
+ const u = yield this.model.paginate(t, n), c = yield this.populateDynamicVirtualsForDocuments(u.docs, e.populate);
776
+ return { success: !0, result: w(S({}, u), { docs: c }) };
724
777
  } catch (r) {
725
- return f(r);
778
+ return d(r);
726
779
  }
727
780
  });
728
781
  }
@@ -734,18 +787,17 @@ class be {
734
787
  * @returns A promise that resolves to a standardized response with paginated aggregation results.
735
788
  */
736
789
  findPagingAggregate(t) {
737
- return a(this, arguments, function* (e, r = {}) {
790
+ return l(this, arguments, function* (e, r = {}) {
738
791
  try {
739
- const c = this.model.schema.statics._dynamicVirtuals, u = E({}, r);
740
- c && c.length > 0 && (u.populate = void 0);
741
- const o = yield this.model.aggregatePaginate(
792
+ const n = this.getDynamicVirtuals(), u = S({}, r);
793
+ r.populate && (u.populate = F(r.populate, n));
794
+ const c = yield this.model.aggregatePaginate(
742
795
  this.model.aggregate(e),
743
796
  u
744
- );
745
- let i = o.docs;
746
- return c && c.length > 0 && o.docs.length > 0 && (i = yield P(this.model.base, o.docs, c, r.populate)), { success: !0, result: w(E({}, o), { docs: i }) };
747
- } catch (s) {
748
- return f(s);
797
+ ), i = yield this.populateDynamicVirtualsForDocuments(c.docs, r.populate);
798
+ return { success: !0, result: w(S({}, c), { docs: i }) };
799
+ } catch (n) {
800
+ return d(n);
749
801
  }
750
802
  });
751
803
  }
@@ -756,11 +808,11 @@ class be {
756
808
  * @returns A promise that resolves to a standardized response with the document count.
757
809
  */
758
810
  count() {
759
- return a(this, arguments, function* (t = {}) {
811
+ return l(this, arguments, function* (t = {}) {
760
812
  try {
761
813
  return { success: !0, result: yield this.model.countDocuments(t) };
762
814
  } catch (e) {
763
- return f(e);
815
+ return d(e);
764
816
  }
765
817
  });
766
818
  }
@@ -771,11 +823,11 @@ class be {
771
823
  * @returns A promise that resolves to a standardized response with the created document.
772
824
  */
773
825
  createOne(t) {
774
- return a(this, null, function* () {
826
+ return l(this, null, function* () {
775
827
  try {
776
828
  return { success: !0, result: yield this.model.create(t) };
777
829
  } catch (e) {
778
- return f(e);
830
+ return d(e);
779
831
  }
780
832
  });
781
833
  }
@@ -787,11 +839,11 @@ class be {
787
839
  * @returns A promise that resolves to a standardized response with the created documents.
788
840
  */
789
841
  createMany(t) {
790
- return a(this, arguments, function* (e, r = {}) {
842
+ return l(this, arguments, function* (e, r = {}) {
791
843
  try {
792
- return { success: !0, result: (yield this.model.insertMany(e, r)).map((u) => u instanceof K ? u.toObject() : null).filter((u) => u !== null) };
793
- } catch (s) {
794
- return f(s);
844
+ return { success: !0, result: (yield this.model.insertMany(e, r)).map((c) => c instanceof W ? c.toObject() : null).filter((c) => c !== null) };
845
+ } catch (n) {
846
+ return d(n);
795
847
  }
796
848
  });
797
849
  }
@@ -804,18 +856,18 @@ class be {
804
856
  * @returns A promise that resolves to a standardized response with the updated document.
805
857
  */
806
858
  updateOne() {
807
- return a(this, arguments, function* (t = {}, e = {}, r = {}) {
859
+ return l(this, arguments, function* (t = {}, e = {}, r = {}) {
808
860
  try {
809
- const s = yield this.model.findOneAndUpdate(t, e, E({
861
+ const n = yield this.model.findOneAndUpdate(t, e, S({
810
862
  new: !0
811
863
  }, r)).exec();
812
- return s ? { success: !0, result: s } : {
864
+ return n ? { success: !0, result: n } : {
813
865
  success: !1,
814
866
  message: `Failed to update ${this.getModelName()}.`,
815
- code: R.NOT_FOUND.CODE
867
+ code: v.NOT_FOUND.CODE
816
868
  };
817
- } catch (s) {
818
- return f(s);
869
+ } catch (n) {
870
+ return d(n);
819
871
  }
820
872
  });
821
873
  }
@@ -828,11 +880,11 @@ class be {
828
880
  * @returns A promise that resolves to a standardized response with the update result.
829
881
  */
830
882
  updateMany() {
831
- return a(this, arguments, function* (t = {}, e = {}, r = {}) {
883
+ return l(this, arguments, function* (t = {}, e = {}, r = {}) {
832
884
  try {
833
885
  return { success: !0, result: yield this.model.updateMany(t, e, r).exec() };
834
- } catch (s) {
835
- return f(s);
886
+ } catch (n) {
887
+ return d(n);
836
888
  }
837
889
  });
838
890
  }
@@ -844,16 +896,16 @@ class be {
844
896
  * @returns A promise that resolves to a standardized response with the deleted document.
845
897
  */
846
898
  deleteOne() {
847
- return a(this, arguments, function* (t = {}, e = {}) {
899
+ return l(this, arguments, function* (t = {}, e = {}) {
848
900
  try {
849
901
  const r = yield this.model.findOneAndDelete(t, e).exec();
850
902
  return r ? { success: !0, result: r } : {
851
903
  success: !1,
852
904
  message: `No ${this.getModelName()} found to delete.`,
853
- code: R.NOT_FOUND.CODE
905
+ code: v.NOT_FOUND.CODE
854
906
  };
855
907
  } catch (r) {
856
- return f(r);
908
+ return d(r);
857
909
  }
858
910
  });
859
911
  }
@@ -865,16 +917,16 @@ class be {
865
917
  * @returns A promise that resolves to a standardized response with the delete result.
866
918
  */
867
919
  deleteMany() {
868
- return a(this, arguments, function* (t = {}, e = {}) {
920
+ return l(this, arguments, function* (t = {}, e = {}) {
869
921
  try {
870
922
  const r = yield this.model.deleteMany(t, e).exec();
871
923
  return r.deletedCount === 0 ? {
872
924
  success: !1,
873
925
  message: "No documents found to delete.",
874
- code: R.NOT_FOUND.CODE
926
+ code: v.NOT_FOUND.CODE
875
927
  } : { success: !0, result: r };
876
928
  } catch (r) {
877
- return f(r);
929
+ return d(r);
878
930
  }
879
931
  });
880
932
  }
@@ -887,23 +939,23 @@ class be {
887
939
  * @returns A promise that resolves to a standardized response with the unique short ID.
888
940
  */
889
941
  createShortId(t, e = 4) {
890
- return a(this, null, function* () {
942
+ return l(this, null, function* () {
891
943
  try {
892
- const s = Array.from({ length: 10 }, (o, i) => te(t, i + e)), u = (yield Promise.all(
893
- s.map((o) => this.model.exists({ shortId: o }))
894
- )).findIndex((o) => !o);
895
- if (u !== -1) {
896
- const o = s[u];
897
- if (o)
898
- return { success: !0, result: o };
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);
947
+ if (c !== -1) {
948
+ const i = n[c];
949
+ if (i)
950
+ return { success: !0, result: i };
899
951
  }
900
952
  return {
901
953
  success: !1,
902
954
  message: "Failed to create a unique shortId",
903
- code: R.INTERNAL_SERVER_ERROR.CODE
955
+ code: v.INTERNAL_SERVER_ERROR.CODE
904
956
  };
905
957
  } catch (r) {
906
- return f(r);
958
+ return d(r);
907
959
  }
908
960
  });
909
961
  }
@@ -918,14 +970,14 @@ class be {
918
970
  * @param options.filter - Additional filter conditions to apply to the query.
919
971
  * @returns A MongoDB query object for checking slug existence.
920
972
  */
921
- createSlugQuery({ slug: t, field: e, isObject: r, filter: s }) {
922
- const c = E({}, s != null ? s : {});
923
- return r ? w(E({}, c), {
973
+ createSlugQuery({ slug: t, field: e, isObject: r, filter: n }) {
974
+ const u = S({}, n != null ? n : {});
975
+ return r ? w(S({}, u), {
924
976
  $or: [
925
977
  { [`slug.${e}`]: t },
926
978
  { slugHistory: { $elemMatch: { [`slug.${e}`]: t } } }
927
979
  ]
928
- }) : w(E({}, c), {
980
+ }) : w(S({}, u), {
929
981
  $or: [
930
982
  { slug: t },
931
983
  { slugHistory: t }
@@ -944,18 +996,18 @@ class be {
944
996
  * @returns A promise that resolves to a unique slug string.
945
997
  */
946
998
  createUniqueSlug(t) {
947
- return a(this, arguments, function* ({ slug: e, field: r, isObject: s, filter: c }) {
948
- const u = j(e), i = Array.from({ length: 100 }, (m, p) => p === 0 ? u : `${u}-${p}`), d = (yield Promise.all(
949
- i.map(
950
- (m) => this.model.exists(this.createSlugQuery({ slug: m, field: r, isObject: s, filter: c }))
999
+ 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(
1002
+ (m) => this.model.exists(this.createSlugQuery({ slug: m, field: r, isObject: n, filter: u }))
951
1003
  )
952
1004
  )).findIndex((m) => !m);
953
- if (d !== -1) {
954
- const m = i[d];
1005
+ if (f !== -1) {
1006
+ const m = o[f];
955
1007
  if (m)
956
1008
  return m;
957
1009
  }
958
- return `${u}-${Date.now()}`;
1010
+ return `${c}-${Date.now()}`;
959
1011
  });
960
1012
  }
961
1013
  /**
@@ -969,29 +1021,29 @@ class be {
969
1021
  * @returns A promise that resolves to a standardized response with the created slug(s).
970
1022
  */
971
1023
  createSlug(t) {
972
- return a(this, arguments, function* ({ field: e, from: r, filter: s }) {
1024
+ return l(this, arguments, function* ({ field: e, from: r, filter: n }) {
973
1025
  try {
974
- const c = r[e];
975
- return $(c) ? { success: !0, result: Object.fromEntries(
1026
+ const u = r[e];
1027
+ return T(u) ? { success: !0, result: Object.fromEntries(
976
1028
  yield Promise.all(
977
- Object.entries(c).map((l) => a(this, [l], function* ([d, m]) {
1029
+ Object.entries(u).map((a) => l(this, [a], function* ([f, m]) {
978
1030
  const p = yield this.createUniqueSlug({
979
1031
  slug: m,
980
- field: d,
1032
+ field: f,
981
1033
  isObject: !0,
982
- filter: s
1034
+ filter: n
983
1035
  });
984
- return [d, p];
1036
+ return [f, p];
985
1037
  }))
986
1038
  )
987
1039
  ) } : { success: !0, result: yield this.createUniqueSlug({
988
- slug: c,
1040
+ slug: u,
989
1041
  field: e,
990
1042
  isObject: !1,
991
- filter: s
1043
+ filter: n
992
1044
  }) };
993
- } catch (c) {
994
- return f(c);
1045
+ } catch (u) {
1046
+ return d(u);
995
1047
  }
996
1048
  });
997
1049
  }
@@ -1007,31 +1059,31 @@ class be {
1007
1059
  * @returns A promise that resolves to a standardized response indicating whether the slug exists.
1008
1060
  */
1009
1061
  checkSlug(t) {
1010
- return a(this, arguments, function* ({ slug: e, field: r, from: s, filter: c }) {
1062
+ return l(this, arguments, function* ({ slug: e, field: r, from: n, filter: u }) {
1011
1063
  try {
1012
- const u = s[r];
1013
- if ($(u)) {
1014
- const m = Object.values(u).map((h) => j(h));
1064
+ const c = n[r];
1065
+ if (T(c)) {
1066
+ const m = Object.values(c).map((h) => I(h));
1015
1067
  return (yield Promise.all(
1016
1068
  m.map(
1017
1069
  (h) => this.model.exists(this.createSlugQuery({
1018
1070
  slug: h,
1019
1071
  field: r,
1020
1072
  isObject: !0,
1021
- filter: c
1073
+ filter: u
1022
1074
  }))
1023
1075
  )
1024
1076
  )).some((h) => h) ? { success: !0, result: !0 } : { success: !0, result: !1 };
1025
1077
  }
1026
- const i = j(e);
1078
+ const o = I(e);
1027
1079
  return { success: !0, result: (yield this.model.exists(this.createSlugQuery({
1028
- slug: i,
1080
+ slug: o,
1029
1081
  field: r,
1030
1082
  isObject: !1,
1031
- filter: c
1083
+ filter: u
1032
1084
  }))) !== null };
1033
- } catch (u) {
1034
- return f(u);
1085
+ } catch (c) {
1086
+ return d(c);
1035
1087
  }
1036
1088
  });
1037
1089
  }
@@ -1042,17 +1094,17 @@ class be {
1042
1094
  * @returns A promise that resolves to a standardized response with the aggregation results.
1043
1095
  */
1044
1096
  aggregate(t) {
1045
- return a(this, null, function* () {
1097
+ return l(this, null, function* () {
1046
1098
  try {
1047
1099
  return { success: !0, result: yield this.model.aggregate(t) };
1048
1100
  } catch (e) {
1049
- return f(e);
1101
+ return d(e);
1050
1102
  }
1051
1103
  });
1052
1104
  }
1053
1105
  }
1054
1106
  export {
1055
- Ne as MongoController,
1107
+ Ve as MongoController,
1056
1108
  be as MongooseController,
1057
- b as mongo
1109
+ V as mongo
1058
1110
  };