@cyberskill/shared 2.26.0 → 2.28.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.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/dist/config/config.util.cjs +1 -1
  3. package/dist/config/config.util.js +14 -19
  4. package/dist/config/eslint/index.cjs +1 -1
  5. package/dist/config/eslint/index.d.ts +2 -0
  6. package/dist/config/eslint/index.js +1 -1
  7. package/dist/config/vitest/vitest.e2e.cjs +1 -1
  8. package/dist/config/vitest/vitest.e2e.js +1 -1
  9. package/dist/config/vitest/vitest.unit.cjs +1 -1
  10. package/dist/config/vitest/vitest.unit.js +1 -1
  11. package/dist/node/cli/index.cjs +2 -5
  12. package/dist/node/cli/index.js +108 -103
  13. package/dist/node/command/command.util.js +1 -1
  14. package/dist/node/fs/fs.util.cjs +4 -1
  15. package/dist/node/fs/fs.util.d.ts +8 -0
  16. package/dist/node/fs/fs.util.js +58 -50
  17. package/dist/node/fs/index.cjs +1 -1
  18. package/dist/node/fs/index.js +13 -12
  19. package/dist/node/mongo/mongo.type.js +3 -3
  20. package/dist/node/mongo/mongo.util.cjs +2 -5
  21. package/dist/node/mongo/mongo.util.js +206 -211
  22. package/dist/node/path/index.cjs +1 -1
  23. package/dist/node/path/index.js +53 -51
  24. package/dist/node/path/path.constant.cjs +1 -1
  25. package/dist/node/path/path.constant.d.ts +3 -0
  26. package/dist/node/path/path.constant.js +63 -60
  27. package/dist/node/storage/storage.util.cjs +1 -1
  28. package/dist/node/storage/storage.util.js +1 -1
  29. package/dist/node/upload/upload.util.js +3 -3
  30. package/dist/react/apollo-client/apollo-client.component.cjs +1 -1
  31. package/dist/react/apollo-client/apollo-client.component.d.ts +1 -1
  32. package/dist/react/apollo-client/apollo-client.component.js +4 -3
  33. package/dist/react/apollo-client/apollo-client.context.cjs +1 -1
  34. package/dist/react/apollo-client/apollo-client.context.d.ts +1 -1
  35. package/dist/react/apollo-client/apollo-client.context.js +9 -8
  36. package/dist/react/apollo-client/apollo-client.util.cjs +1 -1
  37. package/dist/react/apollo-client/apollo-client.util.js +3 -3
  38. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +1 -1
  39. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.d.ts +1 -1
  40. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +9 -8
  41. package/dist/react/apollo-error/apollo-error.component.cjs +1 -1
  42. package/dist/react/apollo-error/apollo-error.component.d.ts +1 -1
  43. package/dist/react/apollo-error/apollo-error.component.js +2 -1
  44. package/dist/react/apollo-error/apollo-error.provider.cjs +1 -1
  45. package/dist/react/apollo-error/apollo-error.provider.d.ts +1 -1
  46. package/dist/react/apollo-error/apollo-error.provider.js +4 -3
  47. package/dist/react/loading/loading.component.cjs +2 -2
  48. package/dist/react/loading/loading.component.d.ts +1 -1
  49. package/dist/react/loading/loading.component.js +7 -6
  50. package/dist/react/loading/loading.provider.cjs +1 -1
  51. package/dist/react/loading/loading.provider.d.ts +1 -1
  52. package/dist/react/loading/loading.provider.js +8 -7
  53. package/dist/react/next-intl/next-intl.hoc.cjs +1 -1
  54. package/dist/react/next-intl/next-intl.hoc.d.ts +2 -1
  55. package/dist/react/next-intl/next-intl.hoc.js +12 -12
  56. package/dist/react/next-intl/next-intl.provider.cjs +1 -1
  57. package/dist/react/next-intl/next-intl.provider.d.ts +1 -1
  58. package/dist/react/next-intl/next-intl.provider.js +5 -4
  59. package/dist/util/common/common.util.cjs +1 -1
  60. package/dist/util/common/common.util.d.ts +9 -0
  61. package/dist/util/common/common.util.js +33 -29
  62. package/dist/util/common/index.cjs +1 -1
  63. package/dist/util/common/index.js +6 -5
  64. package/dist/util/index.cjs +1 -1
  65. package/dist/util/index.js +23 -22
  66. package/dist/util/object/object.util.cjs +1 -1
  67. package/dist/util/object/object.util.js +40 -36
  68. package/package.json +45 -44
  69. package/dist/node/mongo/mongo.util.d.ts +0 -1040
  70. /package/dist/node_modules/.pnpm/{vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.0_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.cjs +0 -0
  71. /package/dist/node_modules/.pnpm/{vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.0_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +0 -0
@@ -1,39 +1,39 @@
1
- import U from "migrate-mongo";
2
- import q from "mongoose-aggregate-paginate-v2";
3
- import B from "mongoose-paginate-v2";
4
- import { randomUUID as x } from "node:crypto";
5
- import { deepClone as J, getNestedValue as K, setNestedValue as L } from "../../util/object/object.util.js";
6
- import { regexSearchMapper as H } from "../../util/common/common.util.js";
7
- import { writeFileSync as G, pathExistsSync as T, readFileSync as z, appendFileSync as Q } from "../fs/fs.util.js";
8
- import { PATH as A, MIGRATE_MONGO_CONFIG as V } from "../path/path.constant.js";
9
- import { validate as W } from "../../util/validate/validate.util.js";
10
- var X = Object.defineProperty, Y = Object.defineProperties, Z = Object.getOwnPropertyDescriptors, $ = Object.getOwnPropertySymbols, M = Object.prototype.hasOwnProperty, tt = Object.prototype.propertyIsEnumerable, D = (t, i, e) => i in t ? X(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e, et = (t, i) => {
11
- for (var e in i || (i = {}))
12
- M.call(i, e) && D(t, e, i[e]);
13
- if ($)
14
- for (var e of $(i))
15
- tt.call(i, e) && D(t, e, i[e]);
1
+ import C from "migrate-mongo";
2
+ import k from "mongoose-aggregate-paginate-v2";
3
+ import U from "mongoose-paginate-v2";
4
+ import { randomUUID as I } from "node:crypto";
5
+ import { deepClone as q, getNestedValue as B, setNestedValue as J } from "../../util/object/object.util.js";
6
+ import { regexSearchMapper as K } from "../../util/common/common.util.js";
7
+ import { writeFileSync as L, addGitIgnoreEntry as H } from "../fs/fs.util.js";
8
+ import { PATH as V, MIGRATE_MONGO_CONFIG as z } from "../path/path.constant.js";
9
+ import { validate as Q } from "../../util/validate/validate.util.js";
10
+ var W = Object.defineProperty, X = Object.defineProperties, Y = Object.getOwnPropertyDescriptors, x = Object.getOwnPropertySymbols, Z = Object.prototype.hasOwnProperty, T = Object.prototype.propertyIsEnumerable, $ = (t, e, i) => e in t ? W(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, M = (t, e) => {
11
+ for (var i in e || (e = {}))
12
+ Z.call(e, i) && $(t, i, e[i]);
13
+ if (x)
14
+ for (var i of x(e))
15
+ T.call(e, i) && $(t, i, e[i]);
16
16
  return t;
17
- }, it = (t, i) => Y(t, Z(i)), S = (t, i, e) => new Promise((o, r) => {
18
- var n = (s) => {
17
+ }, tt = (t, e) => X(t, Y(e)), w = (t, e, i) => new Promise((n, r) => {
18
+ var o = (s) => {
19
19
  try {
20
- y(e.next(s));
20
+ y(i.next(s));
21
21
  } catch (h) {
22
22
  r(h);
23
23
  }
24
24
  }, l = (s) => {
25
25
  try {
26
- y(e.throw(s));
26
+ y(i.throw(s));
27
27
  } catch (h) {
28
28
  r(h);
29
29
  }
30
- }, y = (s) => s.done ? o(s.value) : Promise.resolve(s.value).then(n, l);
31
- y((e = e.apply(t, i)).next());
30
+ }, y = (s) => s.done ? n(s.value) : Promise.resolve(s.value).then(o, l);
31
+ y((i = i.apply(t, e)).next());
32
32
  });
33
- function E(t) {
33
+ function P(t) {
34
34
  return t === t.toUpperCase() ? t.charAt(0).toUpperCase() + t.slice(1).toLowerCase() : t;
35
35
  }
36
- const I = {
36
+ const A = {
37
37
  /**
38
38
  * Creates generic fields that are commonly used across MongoDB documents.
39
39
  * This function generates standard fields including a UUID, deletion flag, and timestamps
@@ -43,7 +43,7 @@ const I = {
43
43
  */
44
44
  createGenericFields() {
45
45
  return {
46
- id: x(),
46
+ id: I(),
47
47
  isDel: !1,
48
48
  createdAt: /* @__PURE__ */ new Date(),
49
49
  updatedAt: /* @__PURE__ */ new Date()
@@ -57,8 +57,8 @@ const I = {
57
57
  * @param schema - The Mongoose schema to apply plugins to.
58
58
  * @param plugins - An array of plugin functions or false values to filter and apply.
59
59
  */
60
- applyPlugins(t, i) {
61
- i.filter((e) => typeof e == "function").forEach((e) => t.plugin(e));
60
+ applyPlugins(t, e) {
61
+ e.filter((i) => typeof i == "function").forEach((i) => t.plugin(i));
62
62
  },
63
63
  /**
64
64
  * Applies middleware functions to a Mongoose schema.
@@ -67,9 +67,9 @@ const I = {
67
67
  * @param schema - The Mongoose schema to apply middleware to.
68
68
  * @param middlewares - An array of middleware configurations with method, pre, and post functions.
69
69
  */
70
- applyMiddlewares(t, i) {
71
- i.forEach(({ method: e, pre: o, post: r }) => {
72
- e && o && t.pre(e, o), e && r && t.post(e, r);
70
+ applyMiddlewares(t, e) {
71
+ e.forEach(({ method: i, pre: n, post: r }) => {
72
+ i && n && t.pre(i, n), i && r && t.post(i, r);
73
73
  });
74
74
  },
75
75
  /**
@@ -83,7 +83,7 @@ const I = {
83
83
  createGenericSchema(t) {
84
84
  return new t.Schema(
85
85
  {
86
- id: { type: String, default: () => x(), unique: !0 },
86
+ id: { type: String, default: () => I(), unique: !0 },
87
87
  isDel: { type: Boolean, default: !1 }
88
88
  },
89
89
  { timestamps: !0 }
@@ -103,33 +103,33 @@ const I = {
103
103
  */
104
104
  createSchema({
105
105
  mongoose: t,
106
- schema: i,
107
- virtuals: e = [],
108
- standalone: o = !1
106
+ schema: e,
107
+ virtuals: i = [],
108
+ standalone: n = !1
109
109
  }) {
110
- const r = new t.Schema(i, {
110
+ const r = new t.Schema(e, {
111
111
  toJSON: { virtuals: !0 },
112
112
  // So `res.json()` and other `JSON.stringify()` functions include virtuals
113
113
  toObject: { virtuals: !0 }
114
114
  // So `console.log()` and other functions that use `toObject()` include virtuals
115
115
  });
116
- return e.forEach(({ name: n, options: l, get: y }) => {
117
- if (I.isDynamicVirtual(l)) {
116
+ return i.forEach(({ name: o, options: l, get: y }) => {
117
+ if (A.isDynamicVirtual(l)) {
118
118
  const s = r.statics;
119
119
  s._dynamicVirtuals || (s._dynamicVirtuals = []), s._dynamicVirtuals.push({
120
- name: n,
120
+ name: o,
121
121
  options: l
122
122
  });
123
- const h = r.virtual(n);
123
+ const h = r.virtual(o);
124
124
  y ? h.get(y) : h.get(function() {
125
125
  var u;
126
- return ((u = this._populated) == null ? void 0 : u[n]) || (l != null && l.count ? 0 : l != null && l.justOne ? null : []);
126
+ return ((u = this._populated) == null ? void 0 : u[o]) || (l != null && l.count ? 0 : l != null && l.justOne ? null : []);
127
127
  });
128
128
  } else {
129
- const s = r.virtual(n, l);
129
+ const s = r.virtual(o, l);
130
130
  y && s.get(y);
131
131
  }
132
- }), o || r.add(I.createGenericSchema(t)), r;
132
+ }), n || r.add(A.createGenericSchema(t)), r;
133
133
  },
134
134
  /**
135
135
  * Creates a Mongoose model with plugins, middleware, and pagination support.
@@ -149,24 +149,24 @@ const I = {
149
149
  */
150
150
  createModel({
151
151
  mongoose: t,
152
- name: i,
153
- schema: e,
154
- virtuals: o = [],
152
+ name: e,
153
+ schema: i,
154
+ virtuals: n = [],
155
155
  pagination: r = !0,
156
- aggregate: n = !0,
156
+ aggregate: o = !0,
157
157
  middlewares: l = []
158
158
  }) {
159
- if (!i)
159
+ if (!e)
160
160
  throw new Error("Model name is required.");
161
- if (t.models[i])
162
- return t.models[i];
163
- const y = I.createSchema({ mongoose: t, schema: e, virtuals: o });
164
- (r || n) && I.applyPlugins(y, [
165
- r && B,
166
- n && q
167
- ]), I.applyMiddlewares(y, l);
168
- const s = t.model(i, y);
169
- return o.length > 0 && (s._virtualConfigs = o), s;
161
+ if (t.models[e])
162
+ return t.models[e];
163
+ const y = A.createSchema({ mongoose: t, schema: i, virtuals: n });
164
+ (r || o) && A.applyPlugins(y, [
165
+ r && U,
166
+ o && k
167
+ ]), A.applyMiddlewares(y, l);
168
+ const s = t.model(e, y);
169
+ return n.length > 0 && (s._virtualConfigs = n), s;
170
170
  },
171
171
  /**
172
172
  * Validation utilities for Mongoose schemas.
@@ -182,8 +182,8 @@ const I = {
182
182
  */
183
183
  isRequired() {
184
184
  return function(t) {
185
- return S(this, null, function* () {
186
- return !W.isEmpty(t);
185
+ return w(this, null, function* () {
186
+ return !Q.isEmpty(t);
187
187
  });
188
188
  };
189
189
  },
@@ -197,12 +197,12 @@ const I = {
197
197
  * @throws {Error} When fields is not a non-empty array of strings.
198
198
  */
199
199
  isUnique(t) {
200
- return function(i) {
201
- return S(this, null, function* () {
200
+ return function(e) {
201
+ return w(this, null, function* () {
202
202
  if (!Array.isArray(t) || t.length === 0)
203
203
  throw new Error("Fields must be a non-empty array of strings.");
204
- const e = { $or: t.map((r) => ({ [r]: i })) };
205
- return !(yield this.constructor.exists(e));
204
+ const i = { $or: t.map((r) => ({ [r]: e })) };
205
+ return !(yield this.constructor.exists(i));
206
206
  });
207
207
  };
208
208
  },
@@ -216,10 +216,10 @@ const I = {
216
216
  * @throws {Error} When regexArray is not an array of valid RegExp objects.
217
217
  */
218
218
  matchesRegex(t) {
219
- return (i) => S(null, null, function* () {
220
- if (!Array.isArray(t) || t.some((e) => !(e instanceof RegExp)))
219
+ return (e) => w(null, null, function* () {
220
+ if (!Array.isArray(t) || t.some((i) => !(i instanceof RegExp)))
221
221
  throw new Error("regexArray must be an array of valid RegExp objects.");
222
- return t.every((e) => e.test(i));
222
+ return t.every((i) => i.test(e));
223
223
  });
224
224
  }
225
225
  },
@@ -227,7 +227,7 @@ const I = {
227
227
  * Migration utilities for MongoDB.
228
228
  * This object extends the migrate-mongo library with additional configuration utilities.
229
229
  */
230
- migrate: it(et({}, U), {
230
+ migrate: tt(M({}, C), {
231
231
  /**
232
232
  * Sets the migration configuration and updates .gitignore.
233
233
  * This function creates a migration configuration file and ensures it's properly
@@ -236,14 +236,9 @@ const I = {
236
236
  * @param options - Migration configuration options to write to the config file.
237
237
  */
238
238
  setConfig: (t) => {
239
- const i = `// This file is automatically generated by the Cyberskill CLI.
239
+ const e = `// This file is automatically generated by the Cyberskill CLI.
240
240
  module.exports = ${JSON.stringify(t, null, 4)}`;
241
- G(A.MIGRATE_MONGO_CONFIG, i);
242
- const e = `
243
- ${V}
244
- `;
245
- T(A.GIT_IGNORE) ? z(A.GIT_IGNORE, "utf-8").split(`
246
- `).includes(V) || Q(A.GIT_IGNORE, e) : G(A.GIT_IGNORE, e);
241
+ L(V.MIGRATE_MONGO_CONFIG, e), H(V.GIT_IGNORE, z);
247
242
  }
248
243
  }),
249
244
  /**
@@ -255,23 +250,23 @@ ${V}
255
250
  * @param fields - An array of field names to convert to regex patterns.
256
251
  * @returns A new filter object with string values converted to regex patterns.
257
252
  */
258
- regexify(t, i) {
253
+ regexify(t, e) {
259
254
  if (!t)
260
255
  return {};
261
- let e = J(t);
262
- if (!i || i.length === 0)
263
- return e;
264
- for (const o of i) {
265
- const r = o.toString().split("."), n = K(e, r);
266
- if (typeof n == "string" && n.length > 0) {
256
+ let i = q(t);
257
+ if (!e || e.length === 0)
258
+ return i;
259
+ for (const n of e) {
260
+ const r = n.toString().split("."), o = B(i, r);
261
+ if (typeof o == "string" && o.length > 0) {
267
262
  const l = {
268
- $regex: `.*${H(n)}.*`,
263
+ $regex: `.*${K(o)}.*`,
269
264
  $options: "i"
270
265
  };
271
- e = L(e, r, l);
266
+ i = J(i, r, l);
272
267
  }
273
268
  }
274
- return e;
269
+ return i;
275
270
  },
276
271
  /**
277
272
  * Checks if a virtual options object has a dynamic ref function.
@@ -289,14 +284,14 @@ ${V}
289
284
  * @param filterFn - Function to determine if a record already exists
290
285
  * @returns Array of records that don't exist in the database
291
286
  */
292
- getNewRecords(t, i, e) {
293
- return S(this, null, function* () {
294
- const o = yield t.findAll({});
295
- return o.success ? i.filter(
296
- (n) => !o.result.some(
297
- (l) => e(l, n)
287
+ getNewRecords(t, e, i) {
288
+ return w(this, null, function* () {
289
+ const n = yield t.findAll({});
290
+ return n.success ? e.filter(
291
+ (o) => !n.result.some(
292
+ (l) => i(l, o)
298
293
  )
299
- ) : i;
294
+ ) : e;
300
295
  });
301
296
  },
302
297
  /**
@@ -306,62 +301,62 @@ ${V}
306
301
  * @param filterFn - Function to determine if a record exists
307
302
  * @returns Array of existing records that match the filter criteria
308
303
  */
309
- getExistingRecords(t, i, e) {
310
- return S(this, null, function* () {
311
- const o = yield t.findAll({});
312
- return o.success ? o.result.filter(
313
- (n) => i.some(
314
- (l) => e(n, l)
304
+ getExistingRecords(t, e, i) {
305
+ return w(this, null, function* () {
306
+ const n = yield t.findAll({});
307
+ return n.success ? n.result.filter(
308
+ (o) => e.some(
309
+ (l) => i(o, l)
315
310
  )
316
311
  ) : [];
317
312
  });
318
313
  }
319
314
  };
320
- function C(t, i, e, o, r) {
321
- return S(this, null, function* () {
322
- if (!i.length || !e)
323
- return i;
324
- const n = Array.isArray(e) ? e : [e];
325
- for (const l of n)
326
- typeof l == "string" ? yield k(t, i, l, o, r) : l && typeof l == "object" && (yield rt(t, i, l, o, r));
327
- return i;
315
+ function D(t, e, i, n, r) {
316
+ return w(this, null, function* () {
317
+ if (!e.length || !i)
318
+ return e;
319
+ const o = Array.isArray(i) ? i : [i];
320
+ for (const l of o)
321
+ typeof l == "string" ? yield G(t, e, l, n, r) : l && typeof l == "object" && (yield et(t, e, l, n, r));
322
+ return e;
328
323
  });
329
324
  }
330
- function k(t, i, e, o, r) {
331
- return S(this, null, function* () {
332
- var n, l, y, s;
333
- const h = e.split(".");
325
+ function G(t, e, i, n, r) {
326
+ return w(this, null, function* () {
327
+ var o, l, y, s;
328
+ const h = i.split(".");
334
329
  if (h.length < 2) {
335
- for (const m of i)
336
- yield P(t, m, e, o, void 0, r);
330
+ for (const m of e)
331
+ yield F(t, m, i, n, void 0, r);
337
332
  return;
338
333
  }
339
334
  const u = h[0];
340
335
  if (!u || u.trim() === "")
341
336
  return;
342
337
  const R = h.slice(1).join(".");
343
- for (const m of i) {
344
- const N = m, O = N[u];
338
+ for (const m of e) {
339
+ const j = m, O = j[u];
345
340
  if (O && typeof O == "object") {
346
341
  let c = r;
347
342
  const a = c;
348
343
  if (r && r.schema && r.schema.virtuals) {
349
344
  const f = r.schema.virtuals[u];
350
345
  if (f && f.options && f.options.ref) {
351
- let g;
352
- if (typeof f.options.ref == "function" ? g = f.options.ref(N) : typeof f.options.ref == "string" && (g = f.options.ref), g) {
353
- const p = E(g);
346
+ let b;
347
+ if (typeof f.options.ref == "function" ? b = f.options.ref(j) : typeof f.options.ref == "string" && (b = f.options.ref), b) {
348
+ const p = P(b);
354
349
  t.models[p] && (c = t.models[p]);
355
350
  }
356
351
  }
357
352
  }
358
353
  if (!c) {
359
- const f = (l = (n = r == null ? void 0 : r.schema) == null ? void 0 : n.statics) != null ? l : {}, p = ((r == null ? void 0 : r._virtualConfigs) || f._dynamicVirtuals || []).find((d) => d.name === u);
354
+ const f = (l = (o = r == null ? void 0 : r.schema) == null ? void 0 : o.statics) != null ? l : {}, p = ((r == null ? void 0 : r._virtualConfigs) || f._dynamicVirtuals || []).find((d) => d.name === u);
360
355
  if (p && p.options && p.options.ref) {
361
356
  let d;
362
- if (typeof p.options.ref == "function" ? d = p.options.ref(N) : typeof p.options.ref == "string" && (d = p.options.ref), d) {
363
- const b = E(d);
364
- t.models[b] && (c = t.models[b]);
357
+ if (typeof p.options.ref == "function" ? d = p.options.ref(j) : typeof p.options.ref == "string" && (d = p.options.ref), d) {
358
+ const g = P(d);
359
+ t.models[g] && (c = t.models[g]);
365
360
  }
366
361
  }
367
362
  }
@@ -369,139 +364,139 @@ function k(t, i, e, o, r) {
369
364
  const f = (s = (y = r == null ? void 0 : r.schema) == null ? void 0 : y.statics) != null ? s : {}, p = ((r == null ? void 0 : r._virtualConfigs) || f._dynamicVirtuals || []).find((d) => d.name === u);
370
365
  if (p && p.options && p.options.ref) {
371
366
  let d;
372
- if (typeof p.options.ref == "function" ? d = p.options.ref(N) : typeof p.options.ref == "string" && (d = p.options.ref), d) {
373
- const b = E(d);
374
- t.models[b] && (c = t.models[b]);
367
+ if (typeof p.options.ref == "function" ? d = p.options.ref(j) : typeof p.options.ref == "string" && (d = p.options.ref), d) {
368
+ const g = P(d);
369
+ t.models[g] && (c = t.models[g]);
375
370
  }
376
371
  }
377
372
  }
378
373
  if (Array.isArray(O))
379
374
  for (const f of O)
380
- f && typeof f == "object" && (yield P(t, f, R, o, u, c));
381
- else O && typeof O == "object" && (yield P(t, O, R, o, u, c));
375
+ f && typeof f == "object" && (yield F(t, f, R, n, u, c));
376
+ else O && typeof O == "object" && (yield F(t, O, R, n, u, c));
382
377
  }
383
378
  }
384
379
  });
385
380
  }
386
- function rt(t, i, e, o, r) {
387
- return S(this, null, function* () {
388
- const { path: n, populate: l } = e;
389
- if (!n)
381
+ function et(t, e, i, n, r) {
382
+ return w(this, null, function* () {
383
+ const { path: o, populate: l } = i;
384
+ if (!o)
390
385
  return;
391
386
  if (!l) {
392
- yield k(t, i, n, o, r);
387
+ yield G(t, e, o, n, r);
393
388
  return;
394
389
  }
395
- const y = n;
396
- for (const s of i) {
390
+ const y = o;
391
+ for (const s of e) {
397
392
  const h = s, u = h[y];
398
393
  let R = r;
399
394
  if (r && r.schema && r.schema.virtuals) {
400
395
  const m = r.schema.virtuals[y];
401
396
  if (m && m.options && m.options.ref) {
402
- let N;
403
- if (typeof m.options.ref == "function" ? N = m.options.ref(h) : typeof m.options.ref == "string" && (N = m.options.ref), N) {
404
- const O = E(N);
397
+ let j;
398
+ if (typeof m.options.ref == "function" ? j = m.options.ref(h) : typeof m.options.ref == "string" && (j = m.options.ref), j) {
399
+ const O = P(j);
405
400
  t.models[O] && (R = t.models[O]);
406
401
  }
407
402
  }
408
403
  }
409
404
  if (!R && typeof u == "object" && u && "entityType" in u) {
410
- const m = E(String(u.entityType));
405
+ const m = P(String(u.entityType));
411
406
  t.models[m] && (R = t.models[m]);
412
407
  }
413
408
  if (u && typeof u == "object")
414
409
  if (Array.isArray(u))
415
410
  for (const m of u)
416
- m && typeof m == "object" && (yield C(t, [m], l, o, R));
417
- else u && typeof u == "object" && (yield C(t, [u], l, o, R));
411
+ m && typeof m == "object" && (yield D(t, [m], l, n, R));
412
+ else u && typeof u == "object" && (yield D(t, [u], l, n, R));
418
413
  }
419
414
  });
420
415
  }
421
- function F(t, i, e, o) {
422
- if (!e || !i || !i.schema)
416
+ function E(t, e, i, n) {
417
+ if (!i || !e || !e.schema)
423
418
  return;
424
- const r = e.split(".");
425
- let n = i.schema;
419
+ const r = i.split(".");
420
+ let o = e.schema;
426
421
  for (let l = 0; l < r.length; l++) {
427
422
  const y = r[l];
428
- if (n && n.virtuals && y) {
429
- const s = n.virtuals[y];
423
+ if (o && o.virtuals && y) {
424
+ const s = o.virtuals[y];
430
425
  if (s && s.options && s.options.ref) {
431
426
  let h;
432
- if (typeof s.options.ref == "function" ? h = s.options.ref(o) : typeof s.options.ref == "string" && (h = s.options.ref), h && typeof h == "string") {
427
+ if (typeof s.options.ref == "function" ? h = s.options.ref(n) : typeof s.options.ref == "string" && (h = s.options.ref), h && typeof h == "string") {
433
428
  if (l === r.length - 1)
434
429
  return h;
435
430
  const u = t.models[h];
436
431
  if (u && u.schema) {
437
- n = u.schema;
432
+ o = u.schema;
438
433
  continue;
439
434
  }
440
435
  }
441
436
  }
442
437
  }
443
- if (n && n.paths && y) {
444
- const s = n.paths[y];
438
+ if (o && o.paths && y) {
439
+ const s = o.paths[y];
445
440
  if (s && s.schema) {
446
- n = s.schema;
441
+ o = s.schema;
447
442
  continue;
448
443
  }
449
444
  }
450
445
  return;
451
446
  }
452
447
  }
453
- function st(t, i) {
454
- if (i)
455
- for (const e of Object.keys(t.models)) {
456
- const o = t.models[e], r = o == null ? void 0 : o.schema;
457
- if (r && (r.paths && r.paths[i] || r.virtuals && r.virtuals[i]))
458
- return o;
448
+ function it(t, e) {
449
+ if (e)
450
+ for (const i of Object.keys(t.models)) {
451
+ const n = t.models[i], r = n == null ? void 0 : n.schema;
452
+ if (r && (r.paths && r.paths[e] || r.virtuals && r.virtuals[e]))
453
+ return n;
459
454
  }
460
455
  }
461
- function nt(t, i) {
462
- const e = (i || "").split(".")[0] || "";
463
- if (e)
464
- for (const o of Object.keys(t.models)) {
465
- const r = t.models[o], n = r == null ? void 0 : r.schema;
466
- if (n && (n.paths && n.paths[e] || n.virtuals && n.virtuals[e]))
456
+ function rt(t, e) {
457
+ const i = (e || "").split(".")[0] || "";
458
+ if (i)
459
+ for (const n of Object.keys(t.models)) {
460
+ const r = t.models[n], o = r == null ? void 0 : r.schema;
461
+ if (o && (o.paths && o.paths[i] || o.virtuals && o.virtuals[i]))
467
462
  return r;
468
463
  }
469
464
  }
470
- function P(t, i, e, o, r, n) {
471
- return S(this, null, function* () {
465
+ function F(t, e, i, n, r, o) {
466
+ return w(this, null, function* () {
472
467
  var l, y;
473
- let s = i.__t;
468
+ let s = e.__t;
474
469
  if (!s) {
475
- if (n) {
476
- const c = r ? `${r}.${e}` : e, a = (c || "").split(".")[0] || "";
477
- let f = n;
470
+ if (o) {
471
+ const c = r ? `${r}.${i}` : i, a = (c || "").split(".")[0] || "";
472
+ let f = o;
478
473
  if (!!!((l = f == null ? void 0 : f.schema) != null && l.paths && f.schema.paths[a] || (y = f == null ? void 0 : f.schema) != null && y.virtuals && f.schema.virtuals[a])) {
479
- const d = nt(t, c);
474
+ const d = rt(t, c);
480
475
  d && (f = d);
481
476
  }
482
- const p = F(t, f, c, i);
477
+ const p = E(t, f, c, e);
483
478
  if (p)
484
479
  s = p;
485
480
  else {
486
481
  const d = (c.includes(".") ? c.split(".").pop() : c) || "";
487
482
  if (d) {
488
- const b = st(t, d);
489
- if (b) {
490
- const j = F(t, b, c, i);
491
- j && (s = j);
483
+ const g = it(t, d);
484
+ if (g) {
485
+ const N = E(t, g, c, e);
486
+ N && (s = N);
492
487
  }
493
488
  }
494
489
  }
495
490
  }
496
- if (o && o.length > 0) {
497
- const c = e.split(".").pop() || "", a = o.find((f) => f.name === c);
491
+ if (n && n.length > 0) {
492
+ const c = i.split(".").pop() || "", a = n.find((f) => f.name === c);
498
493
  if (a && a.options.ref) {
499
494
  let f;
500
- typeof a.options.ref == "function" ? f = a.options.ref(i) : typeof a.options.ref == "string" && (f = a.options.ref), f && typeof f == "string" && (s = f);
495
+ typeof a.options.ref == "function" ? f = a.options.ref(e) : typeof a.options.ref == "string" && (f = a.options.ref), f && typeof f == "string" && (s = f);
501
496
  }
502
497
  }
503
498
  if (!s) {
504
- for (const [c, a] of Object.entries(i))
499
+ for (const [c, a] of Object.entries(e))
505
500
  if (c === "entityType" && typeof a == "string") {
506
501
  s = a;
507
502
  break;
@@ -509,90 +504,90 @@ function P(t, i, e, o, r, n) {
509
504
  if (s && t.models[s]) {
510
505
  const c = t.models[s];
511
506
  if (c && c.schema) {
512
- const a = c.schema, f = e.split(".").pop() || "", g = (d, b = "root") => {
507
+ const a = c.schema, f = i.split(".").pop() || "", b = (d, g = "root") => {
513
508
  if (!d || !d.virtuals)
514
509
  return;
515
- const j = d.virtuals;
516
- for (const _ of Object.keys(j))
510
+ const N = d.virtuals;
511
+ for (const _ of Object.keys(N))
517
512
  if (_ === f) {
518
- const v = j[_];
513
+ const v = N[_];
519
514
  if (v && v.options && v.options.ref) {
520
- let w;
521
- if (typeof v.options.ref == "function" ? w = v.options.ref(i) : typeof v.options.ref == "string" && (w = v.options.ref), w && typeof w == "string")
522
- return w;
515
+ let S;
516
+ if (typeof v.options.ref == "function" ? S = v.options.ref(e) : typeof v.options.ref == "string" && (S = v.options.ref), S && typeof S == "string")
517
+ return S;
523
518
  }
524
519
  }
525
520
  if (d.paths)
526
521
  for (const _ of Object.keys(d.paths)) {
527
522
  const v = d.paths[_];
528
523
  if (v && v.schema) {
529
- const w = g(v.schema, `${b}.${_}`);
530
- if (w)
531
- return w;
524
+ const S = b(v.schema, `${g}.${_}`);
525
+ if (S)
526
+ return S;
532
527
  }
533
528
  }
534
- }, p = g(a);
529
+ }, p = b(a);
535
530
  p && (s = p);
536
531
  }
537
532
  }
538
533
  }
539
534
  if (!s) {
540
- const c = e.split(".").pop() || "";
541
- if (n && n.schema) {
542
- const a = n.schema, f = (p, d = "root") => {
535
+ const c = i.split(".").pop() || "";
536
+ if (o && o.schema) {
537
+ const a = o.schema, f = (p, d = "root") => {
543
538
  if (!p || !p.virtuals)
544
539
  return;
545
- const b = p.virtuals;
546
- for (const j of Object.keys(b))
547
- if (j === c) {
548
- const _ = b[j];
540
+ const g = p.virtuals;
541
+ for (const N of Object.keys(g))
542
+ if (N === c) {
543
+ const _ = g[N];
549
544
  if (_ && _.options && _.options.ref) {
550
545
  let v;
551
- if (typeof _.options.ref == "function" ? v = _.options.ref(i) : typeof _.options.ref == "string" && (v = _.options.ref), v && typeof v == "string")
546
+ if (typeof _.options.ref == "function" ? v = _.options.ref(e) : typeof _.options.ref == "string" && (v = _.options.ref), v && typeof v == "string")
552
547
  return v;
553
548
  }
554
549
  }
555
550
  if (p.paths)
556
- for (const j of Object.keys(p.paths)) {
557
- const _ = p.paths[j];
551
+ for (const N of Object.keys(p.paths)) {
552
+ const _ = p.paths[N];
558
553
  if (_ && _.schema) {
559
- const v = f(_.schema, `${d}.${j}`);
554
+ const v = f(_.schema, `${d}.${N}`);
560
555
  if (v)
561
556
  return v;
562
557
  }
563
558
  }
564
- }, g = f(a);
565
- g && (s = g);
559
+ }, b = f(a);
560
+ b && (s = b);
566
561
  }
567
- if (!s && n) {
568
- const a = F(t, n, e, i);
562
+ if (!s && o) {
563
+ const a = E(t, o, i, e);
569
564
  a && (s = a);
570
565
  }
571
- if (!s && o && o.length > 0) {
572
- const a = o.find((f) => f.name === c);
566
+ if (!s && n && n.length > 0) {
567
+ const a = n.find((f) => f.name === c);
573
568
  if (a && a.options.ref) {
574
569
  let f;
575
- typeof a.options.ref == "function" ? f = a.options.ref(i) : typeof a.options.ref == "string" && (f = a.options.ref), f && typeof f == "string" && (s = f);
570
+ typeof a.options.ref == "function" ? f = a.options.ref(e) : typeof a.options.ref == "string" && (f = a.options.ref), f && typeof f == "string" && (s = f);
576
571
  }
577
572
  }
578
573
  }
579
574
  if (!s) {
580
- const c = e.split(".").pop() || "", a = c ? c.charAt(0).toUpperCase() + c.slice(1) : "";
575
+ const c = i.split(".").pop() || "", a = c ? c.charAt(0).toUpperCase() + c.slice(1) : "";
581
576
  a && t.models[a] && (s = a);
582
577
  }
583
578
  }
584
579
  const h = t.models[s];
585
580
  if (!h)
586
581
  return;
587
- const u = `${e}Id`, R = `${e}Ids`, m = i[u] || i[R] || i[e];
582
+ const u = `${i}Id`, R = `${i}Ids`, m = e[u] || e[R] || e[i];
588
583
  if (!m)
589
584
  return;
590
- const N = Array.isArray(m) ? m : [m], O = yield h.find({ id: { $in: N } }).lean();
591
- O.length > 0 && (Array.isArray(m) ? i[e] = O : i[e] = O[0]);
585
+ const j = Array.isArray(m) ? m : [m], O = yield h.find({ id: { $in: j } }).lean();
586
+ O.length > 0 && (Array.isArray(m) ? e[i] = O : e[i] = O[0]);
592
587
  });
593
588
  }
594
589
  export {
595
- C as applyNestedPopulate,
596
- E as convertEnumToModelName,
597
- I as mongo
590
+ D as applyNestedPopulate,
591
+ P as convertEnumToModelName,
592
+ A as mongo
598
593
  };