@cyberskill/shared 3.2.0 → 3.3.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 (237) hide show
  1. package/dist/config/commitlint/index.js +8 -9
  2. package/dist/config/commitlint/index.js.map +1 -1
  3. package/dist/config/config.type.js +8 -5
  4. package/dist/config/config.type.js.map +1 -1
  5. package/dist/config/config.util.js +33 -42
  6. package/dist/config/config.util.js.map +1 -1
  7. package/dist/config/env/env.constant.js +6 -5
  8. package/dist/config/env/env.constant.js.map +1 -1
  9. package/dist/config/env/env.util.js +26 -27
  10. package/dist/config/env/env.util.js.map +1 -1
  11. package/dist/config/env/index.js +2 -7
  12. package/dist/config/eslint/index.js +23 -19
  13. package/dist/config/eslint/index.js.map +1 -1
  14. package/dist/config/graphql-codegen/graphql-codegen.util.js +30 -38
  15. package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -1
  16. package/dist/config/graphql-codegen/index.js +2 -5
  17. package/dist/config/index.js +3 -7
  18. package/dist/config/lint-staged/index.js +8 -7
  19. package/dist/config/lint-staged/index.js.map +1 -1
  20. package/dist/config/storybook/index.js +2 -6
  21. package/dist/config/storybook/storybook.main.js +19 -18
  22. package/dist/config/storybook/storybook.main.js.map +1 -1
  23. package/dist/config/storybook/storybook.preview.js +31 -37
  24. package/dist/config/storybook/storybook.preview.js.map +1 -1
  25. package/dist/config/vitest/index.js +3 -7
  26. package/dist/config/vitest/vitest.e2e.js +14 -17
  27. package/dist/config/vitest/vitest.e2e.js.map +1 -1
  28. package/dist/config/vitest/vitest.unit.js +31 -32
  29. package/dist/config/vitest/vitest.unit.js.map +1 -1
  30. package/dist/constant/common.js +6 -5
  31. package/dist/constant/common.js.map +1 -1
  32. package/dist/constant/index.js +3 -7
  33. package/dist/constant/response-status.d.ts +186 -186
  34. package/dist/constant/response-status.js +254 -253
  35. package/dist/constant/response-status.js.map +1 -1
  36. package/dist/node/apollo-server/apollo-server.util.js +27 -29
  37. package/dist/node/apollo-server/apollo-server.util.js.map +1 -1
  38. package/dist/node/apollo-server/index.js +2 -7
  39. package/dist/node/cli/index.js +112 -113
  40. package/dist/node/cli/index.js.map +1 -1
  41. package/dist/node/command/command.type.js +8 -5
  42. package/dist/node/command/command.type.js.map +1 -1
  43. package/dist/node/command/command.util.js +136 -149
  44. package/dist/node/command/command.util.js.map +1 -1
  45. package/dist/node/command/index.js +3 -12
  46. package/dist/node/express/express.type.d.ts +11 -0
  47. package/dist/node/express/express.type.js +2 -0
  48. package/dist/node/express/express.util.js +74 -65
  49. package/dist/node/express/express.util.js.map +1 -1
  50. package/dist/node/express/index.js +3 -14
  51. package/dist/node/fs/fs.util.js +27 -51
  52. package/dist/node/fs/fs.util.js.map +1 -1
  53. package/dist/node/fs/index.js +2 -19
  54. package/dist/node/log/index.js +2 -8
  55. package/dist/node/log/log.type.js +8 -5
  56. package/dist/node/log/log.type.js.map +1 -1
  57. package/dist/node/log/log.util.js +51 -68
  58. package/dist/node/log/log.util.js.map +1 -1
  59. package/dist/node/mongo/index.js +8 -26
  60. package/dist/node/mongo/mongo.constant.js +6 -6
  61. package/dist/node/mongo/mongo.constant.js.map +1 -1
  62. package/dist/node/mongo/mongo.controller.mongoose.d.ts +6 -1
  63. package/dist/node/mongo/mongo.controller.mongoose.js +333 -467
  64. package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -1
  65. package/dist/node/mongo/mongo.controller.native.js +153 -212
  66. package/dist/node/mongo/mongo.controller.native.js.map +1 -1
  67. package/dist/node/mongo/mongo.dynamic-populate.js +164 -192
  68. package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -1
  69. package/dist/node/mongo/mongo.populate.js +229 -262
  70. package/dist/node/mongo/mongo.populate.js.map +1 -1
  71. package/dist/node/mongo/mongo.type.js +8 -17
  72. package/dist/node/mongo/mongo.type.js.map +1 -1
  73. package/dist/node/mongo/mongo.util.js +134 -293
  74. package/dist/node/mongo/mongo.util.js.map +1 -1
  75. package/dist/node/package/index.js +3 -11
  76. package/dist/node/package/package.type.js +8 -5
  77. package/dist/node/package/package.type.js.map +1 -1
  78. package/dist/node/package/package.util.js +216 -225
  79. package/dist/node/package/package.util.js.map +1 -1
  80. package/dist/node/path/index.js +3 -58
  81. package/dist/node/path/path.constant.js +211 -298
  82. package/dist/node/path/path.constant.js.map +1 -1
  83. package/dist/node/path/path.util.js +13 -16
  84. package/dist/node/path/path.util.js.map +1 -1
  85. package/dist/node/storage/index.js +3 -10
  86. package/dist/node/storage/storage.constant.js +6 -8
  87. package/dist/node/storage/storage.constant.js.map +1 -1
  88. package/dist/node/storage/storage.util.js +127 -178
  89. package/dist/node/storage/storage.util.js.map +1 -1
  90. package/dist/node/upload/index.js +4 -16
  91. package/dist/node/upload/upload.constant.js +58 -32
  92. package/dist/node/upload/upload.constant.js.map +1 -1
  93. package/dist/node/upload/upload.type.js +8 -5
  94. package/dist/node/upload/upload.type.js.map +1 -1
  95. package/dist/node/upload/upload.util.js +125 -137
  96. package/dist/node/upload/upload.util.js.map +1 -1
  97. package/dist/node/ws/index.js +2 -6
  98. package/dist/node/ws/ws.type.d.ts +7 -8
  99. package/dist/node/ws/ws.util.js +46 -44
  100. package/dist/node/ws/ws.util.js.map +1 -1
  101. package/dist/node_modules/.pnpm/vitest@4.1.0_@types_node@25.5.0_jsdom@29.0.0_@noble_hashes@1.8.0__vite@8.0.0_@types_nod_53aa4254f295b3c40bb8f17b6ab226b5/node_modules/vitest/dist/config.js +8 -0
  102. package/dist/node_modules/.pnpm/vitest@4.1.0_@types_node@25.5.0_jsdom@29.0.0_@noble_hashes@1.8.0__vite@8.0.0_@types_nod_53aa4254f295b3c40bb8f17b6ab226b5/node_modules/vitest/dist/config.js.map +1 -0
  103. package/dist/react/apollo-client/apollo-client.component.js +16 -18
  104. package/dist/react/apollo-client/apollo-client.component.js.map +1 -1
  105. package/dist/react/apollo-client/apollo-client.constant.js +6 -5
  106. package/dist/react/apollo-client/apollo-client.constant.js.map +1 -1
  107. package/dist/react/apollo-client/apollo-client.context.js +10 -13
  108. package/dist/react/apollo-client/apollo-client.context.js.map +1 -1
  109. package/dist/react/apollo-client/apollo-client.module.scss.js +8 -7
  110. package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -1
  111. package/dist/react/apollo-client/apollo-client.util.js +57 -75
  112. package/dist/react/apollo-client/apollo-client.util.js.map +1 -1
  113. package/dist/react/apollo-client/index.js +7 -30
  114. package/dist/react/apollo-client/links/index.js +2 -5
  115. package/dist/react/apollo-client/links/upload.js +63 -107
  116. package/dist/react/apollo-client/links/upload.js.map +1 -1
  117. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +14 -16
  118. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -1
  119. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +8 -7
  120. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -1
  121. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +14 -14
  122. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -1
  123. package/dist/react/apollo-client-nextjs/index.js +3 -7
  124. package/dist/react/apollo-error/apollo-error.component.js +57 -69
  125. package/dist/react/apollo-error/apollo-error.component.js.map +1 -1
  126. package/dist/react/apollo-error/apollo-error.context.js +7 -6
  127. package/dist/react/apollo-error/apollo-error.context.js.map +1 -1
  128. package/dist/react/apollo-error/apollo-error.hook.js +10 -10
  129. package/dist/react/apollo-error/apollo-error.hook.js.map +1 -1
  130. package/dist/react/apollo-error/apollo-error.module.scss.js +15 -11
  131. package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -1
  132. package/dist/react/apollo-error/apollo-error.provider.js +31 -25
  133. package/dist/react/apollo-error/apollo-error.provider.js.map +1 -1
  134. package/dist/react/apollo-error/apollo-error.util.js +14 -16
  135. package/dist/react/apollo-error/apollo-error.util.js.map +1 -1
  136. package/dist/react/apollo-error/index.js +5 -15
  137. package/dist/react/i18next/i18next.hook.js +7 -6
  138. package/dist/react/i18next/i18next.hook.js.map +1 -1
  139. package/dist/react/i18next/i18next.util.js +9 -8
  140. package/dist/react/i18next/i18next.util.js.map +1 -1
  141. package/dist/react/i18next/index.js +3 -7
  142. package/dist/react/loading/index.js +3 -9
  143. package/dist/react/loading/loading.component.js +47 -48
  144. package/dist/react/loading/loading.component.js.map +1 -1
  145. package/dist/react/loading/loading.context.js +7 -6
  146. package/dist/react/loading/loading.context.js.map +1 -1
  147. package/dist/react/loading/loading.hook.js +11 -11
  148. package/dist/react/loading/loading.hook.js.map +1 -1
  149. package/dist/react/loading/loading.module.scss.js +18 -15
  150. package/dist/react/loading/loading.module.scss.js.map +1 -1
  151. package/dist/react/loading/loading.provider.js +26 -18
  152. package/dist/react/loading/loading.provider.js.map +1 -1
  153. package/dist/react/log/index.js +2 -6
  154. package/dist/react/log/log.util.d.ts +8 -0
  155. package/dist/react/log/log.util.js +33 -29
  156. package/dist/react/log/log.util.js.map +1 -1
  157. package/dist/react/next-intl/index.js +6 -14
  158. package/dist/react/next-intl/next-intl.constant.js +16 -15
  159. package/dist/react/next-intl/next-intl.constant.js.map +1 -1
  160. package/dist/react/next-intl/next-intl.context.js +7 -6
  161. package/dist/react/next-intl/next-intl.context.js.map +1 -1
  162. package/dist/react/next-intl/next-intl.hoc.js +20 -23
  163. package/dist/react/next-intl/next-intl.hoc.js.map +1 -1
  164. package/dist/react/next-intl/next-intl.hook.js +13 -14
  165. package/dist/react/next-intl/next-intl.hook.js.map +1 -1
  166. package/dist/react/next-intl/next-intl.provider.js +28 -23
  167. package/dist/react/next-intl/next-intl.provider.js.map +1 -1
  168. package/dist/react/storage/index.js +3 -7
  169. package/dist/react/storage/storage.hook.js +61 -58
  170. package/dist/react/storage/storage.hook.js.map +1 -1
  171. package/dist/react/storage/storage.util.js +36 -68
  172. package/dist/react/storage/storage.util.js.map +1 -1
  173. package/dist/react/toast/index.js +2 -6
  174. package/dist/react/userback/index.js +2 -5
  175. package/dist/react/userback/userback.component.js +27 -27
  176. package/dist/react/userback/userback.component.js.map +1 -1
  177. package/dist/style.css +2 -1
  178. package/dist/typescript/common.type.js +8 -5
  179. package/dist/typescript/common.type.js.map +1 -1
  180. package/dist/typescript/index.js +2 -5
  181. package/dist/util/common/common.util.js +119 -48
  182. package/dist/util/common/common.util.js.map +1 -1
  183. package/dist/util/common/index.js +2 -9
  184. package/dist/util/index.js +6 -27
  185. package/dist/util/object/index.d.ts +3 -0
  186. package/dist/util/object/index.js +2 -10
  187. package/dist/util/object/object.util.js +94 -128
  188. package/dist/util/object/object.util.js.map +1 -1
  189. package/dist/util/serializer/index.js +2 -5
  190. package/dist/util/serializer/serializer.util.js +73 -78
  191. package/dist/util/serializer/serializer.util.js.map +1 -1
  192. package/dist/util/string/index.d.ts +3 -0
  193. package/dist/util/string/index.js +2 -10
  194. package/dist/util/string/string.util.js +59 -71
  195. package/dist/util/string/string.util.js.map +1 -1
  196. package/dist/util/validate/index.d.ts +3 -0
  197. package/dist/util/validate/index.js +2 -5
  198. package/dist/util/validate/validate.util.js +13 -39
  199. package/dist/util/validate/validate.util.js.map +1 -1
  200. package/package.json +29 -27
  201. package/dist/config/env/index.js.map +0 -1
  202. package/dist/config/graphql-codegen/index.js.map +0 -1
  203. package/dist/config/index.js.map +0 -1
  204. package/dist/config/storybook/index.js.map +0 -1
  205. package/dist/config/vitest/index.js.map +0 -1
  206. package/dist/constant/index.js.map +0 -1
  207. package/dist/node/apollo-server/index.js.map +0 -1
  208. package/dist/node/command/index.js.map +0 -1
  209. package/dist/node/express/index.js.map +0 -1
  210. package/dist/node/fs/index.js.map +0 -1
  211. package/dist/node/log/index.js.map +0 -1
  212. package/dist/node/mongo/index.js.map +0 -1
  213. package/dist/node/package/index.js.map +0 -1
  214. package/dist/node/path/index.js.map +0 -1
  215. package/dist/node/storage/index.js.map +0 -1
  216. package/dist/node/upload/index.js.map +0 -1
  217. package/dist/node/ws/index.js.map +0 -1
  218. package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.5_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 -7
  219. package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.5_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.map +0 -1
  220. package/dist/react/apollo-client/index.js.map +0 -1
  221. package/dist/react/apollo-client/links/index.js.map +0 -1
  222. package/dist/react/apollo-client-nextjs/index.js.map +0 -1
  223. package/dist/react/apollo-error/index.js.map +0 -1
  224. package/dist/react/i18next/index.js.map +0 -1
  225. package/dist/react/loading/index.js.map +0 -1
  226. package/dist/react/log/index.js.map +0 -1
  227. package/dist/react/next-intl/index.js.map +0 -1
  228. package/dist/react/storage/index.js.map +0 -1
  229. package/dist/react/toast/index.js.map +0 -1
  230. package/dist/react/userback/index.js.map +0 -1
  231. package/dist/typescript/index.js.map +0 -1
  232. package/dist/util/common/index.js.map +0 -1
  233. package/dist/util/index.js.map +0 -1
  234. package/dist/util/object/index.js.map +0 -1
  235. package/dist/util/serializer/index.js.map +0 -1
  236. package/dist/util/string/index.js.map +0 -1
  237. package/dist/util/validate/index.js.map +0 -1
@@ -1,269 +1,236 @@
1
- import { convertEnumToModelName as F } from "./mongo.util.js";
2
- async function $(f, o, a, c, n) {
3
- if (!o.length || !a)
4
- return o;
5
- const r = Array.isArray(a) ? a : [a];
6
- for (const i of r)
7
- typeof i == "string" ? await k(f, o, i, c, n) : i && typeof i == "object" && await I(f, o, i, c, n);
8
- return o;
1
+ import { convertEnumToModelName as e } from "./mongo.util.js";
2
+ //#region src/node/mongo/mongo.populate.ts
3
+ async function t(e, t, i, a, o) {
4
+ if (!t.length || !i) return t;
5
+ let s = Array.isArray(i) ? i : [i];
6
+ for (let i of s) typeof i == "string" ? await n(e, t, i, a, o) : i && typeof i == "object" && await r(e, t, i, a, o);
7
+ return t;
9
8
  }
10
- async function k(f, o, a, c, n) {
11
- const r = a.split(".");
12
- if (r.length < 2) {
13
- for (const d of o)
14
- await w(f, d, a, c, void 0, n);
15
- return;
16
- }
17
- const i = r[0];
18
- if (!i || i.trim() === "")
19
- return;
20
- const j = r.slice(1).join(".");
21
- for (const d of o) {
22
- const h = d, p = h[i];
23
- if (p && typeof p == "object") {
24
- let b = n;
25
- const l = b;
26
- if (n && n.schema && n.schema.virtuals) {
27
- const s = n.schema.virtuals[i];
28
- if (s && s.options && s.options.ref) {
29
- let e;
30
- if (typeof s.options.ref == "function" ? e = s.options.ref(h) : typeof s.options.ref == "string" && (e = s.options.ref), e) {
31
- const t = F(e);
32
- f.models[t] && (b = f.models[t]);
33
- }
34
- }
35
- }
36
- if (!b) {
37
- const s = n?.schema?.statics ?? {}, t = (n?._virtualConfigs || s._dynamicVirtuals || []).find((y) => y.name === i);
38
- if (t && t.options && t.options.ref) {
39
- let y;
40
- if (typeof t.options.ref == "function" ? y = t.options.ref(h) : typeof t.options.ref == "string" && (y = t.options.ref), y) {
41
- const m = F(y);
42
- f.models[m] && (b = f.models[m]);
43
- }
44
- }
45
- }
46
- if (b === l) {
47
- const s = n?.schema?.statics ?? {}, t = (n?._virtualConfigs || s._dynamicVirtuals || []).find((y) => y.name === i);
48
- if (t && t.options && t.options.ref) {
49
- let y;
50
- if (typeof t.options.ref == "function" ? y = t.options.ref(h) : typeof t.options.ref == "string" && (y = t.options.ref), y) {
51
- const m = F(y);
52
- f.models[m] && (b = f.models[m]);
53
- }
54
- }
55
- }
56
- if (Array.isArray(p))
57
- for (const s of p)
58
- s && typeof s == "object" && await w(f, s, j, c, i, b);
59
- else p && typeof p == "object" && await w(f, p, j, c, i, b);
60
- }
61
- }
9
+ async function n(t, n, r, i, a) {
10
+ let o = r.split(".");
11
+ if (o.length < 2) {
12
+ for (let e of n) await s(t, e, r, i, void 0, a);
13
+ return;
14
+ }
15
+ let c = o[0];
16
+ if (!c || c.trim() === "") return;
17
+ let l = o.slice(1).join(".");
18
+ for (let r of n) {
19
+ let n = r, o = n[c];
20
+ if (o && typeof o == "object") {
21
+ let r = a, u = r;
22
+ if (a && a.schema && a.schema.virtuals) {
23
+ let i = a.schema.virtuals[c];
24
+ if (i && i.options && i.options.ref) {
25
+ let a;
26
+ if (typeof i.options.ref == "function" ? a = i.options.ref(n) : typeof i.options.ref == "string" && (a = i.options.ref), a) {
27
+ let n = e(a);
28
+ t.models[n] && (r = t.models[n]);
29
+ }
30
+ }
31
+ }
32
+ if (!r) {
33
+ let i = (a?._virtualConfigs || (a?.schema?.statics ?? {})._dynamicVirtuals || []).find((e) => e.name === c);
34
+ if (i && i.options && i.options.ref) {
35
+ let a;
36
+ if (typeof i.options.ref == "function" ? a = i.options.ref(n) : typeof i.options.ref == "string" && (a = i.options.ref), a) {
37
+ let n = e(a);
38
+ t.models[n] && (r = t.models[n]);
39
+ }
40
+ }
41
+ }
42
+ if (r === u) {
43
+ let i = (a?._virtualConfigs || (a?.schema?.statics ?? {})._dynamicVirtuals || []).find((e) => e.name === c);
44
+ if (i && i.options && i.options.ref) {
45
+ let a;
46
+ if (typeof i.options.ref == "function" ? a = i.options.ref(n) : typeof i.options.ref == "string" && (a = i.options.ref), a) {
47
+ let n = e(a);
48
+ t.models[n] && (r = t.models[n]);
49
+ }
50
+ }
51
+ }
52
+ if (Array.isArray(o)) for (let e of o) e && typeof e == "object" && await s(t, e, l, i, c, r);
53
+ else o && typeof o == "object" && await s(t, o, l, i, c, r);
54
+ }
55
+ }
62
56
  }
63
- async function I(f, o, a, c, n) {
64
- const { path: r, populate: i } = a;
65
- if (!r)
66
- return;
67
- if (!i) {
68
- await k(f, o, r, c, n);
69
- return;
70
- }
71
- const j = r;
72
- for (const d of o) {
73
- const h = d, p = h[j];
74
- let b = n;
75
- if (n && n.schema && n.schema.virtuals) {
76
- const l = n.schema.virtuals[j];
77
- if (l && l.options && l.options.ref) {
78
- let s;
79
- if (typeof l.options.ref == "function" ? s = l.options.ref(h) : typeof l.options.ref == "string" && (s = l.options.ref), s) {
80
- const e = F(s);
81
- f.models[e] && (b = f.models[e]);
82
- }
83
- }
84
- }
85
- if (!b && typeof p == "object" && p && "entityType" in p) {
86
- const l = F(String(p.entityType));
87
- f.models[l] && (b = f.models[l]);
88
- }
89
- if (p && typeof p == "object")
90
- if (Array.isArray(p))
91
- for (const l of p)
92
- l && typeof l == "object" && await $(f, [l], i, c, b);
93
- else p && typeof p == "object" && await $(f, [p], i, c, b);
94
- }
57
+ async function r(r, i, a, o, s) {
58
+ let { path: c, populate: l } = a;
59
+ if (!c) return;
60
+ if (!l) {
61
+ await n(r, i, c, o, s);
62
+ return;
63
+ }
64
+ let u = c;
65
+ for (let n of i) {
66
+ let i = n, a = i[u], c = s;
67
+ if (s && s.schema && s.schema.virtuals) {
68
+ let t = s.schema.virtuals[u];
69
+ if (t && t.options && t.options.ref) {
70
+ let n;
71
+ if (typeof t.options.ref == "function" ? n = t.options.ref(i) : typeof t.options.ref == "string" && (n = t.options.ref), n) {
72
+ let t = e(n);
73
+ r.models[t] && (c = r.models[t]);
74
+ }
75
+ }
76
+ }
77
+ if (!c && typeof a == "object" && a && "entityType" in a) {
78
+ let t = e(String(a.entityType));
79
+ r.models[t] && (c = r.models[t]);
80
+ }
81
+ if (a && typeof a == "object") if (Array.isArray(a)) for (let e of a) e && typeof e == "object" && await t(r, [e], l, o, c);
82
+ else a && typeof a == "object" && await t(r, [a], l, o, c);
83
+ }
95
84
  }
96
- function R(f, o, a, c) {
97
- if (!a || !o || !o.schema)
98
- return;
99
- const n = a.split(".");
100
- let r = o.schema;
101
- for (let i = 0; i < n.length; i++) {
102
- const j = n[i];
103
- if (r && r.virtuals && j) {
104
- const d = r.virtuals[j];
105
- if (d && d.options && d.options.ref) {
106
- let h;
107
- if (typeof d.options.ref == "function" ? h = d.options.ref(c) : typeof d.options.ref == "string" && (h = d.options.ref), h && typeof h == "string") {
108
- if (i === n.length - 1)
109
- return h;
110
- const p = f.models[h];
111
- if (p && p.schema) {
112
- r = p.schema;
113
- continue;
114
- }
115
- }
116
- }
117
- }
118
- if (r && r.paths && j) {
119
- const d = r.paths[j];
120
- if (d && d.schema) {
121
- r = d.schema;
122
- continue;
123
- }
124
- }
125
- return;
126
- }
85
+ function i(e, t, n, r) {
86
+ if (!n || !t || !t.schema) return;
87
+ let i = n.split("."), a = t.schema;
88
+ for (let t = 0; t < i.length; t++) {
89
+ let n = i[t];
90
+ if (a && a.virtuals && n) {
91
+ let o = a.virtuals[n];
92
+ if (o && o.options && o.options.ref) {
93
+ let n;
94
+ if (typeof o.options.ref == "function" ? n = o.options.ref(r) : typeof o.options.ref == "string" && (n = o.options.ref), n && typeof n == "string") {
95
+ if (t === i.length - 1) return n;
96
+ let r = e.models[n];
97
+ if (r && r.schema) {
98
+ a = r.schema;
99
+ continue;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ if (a && a.paths && n) {
105
+ let e = a.paths[n];
106
+ if (e && e.schema) {
107
+ a = e.schema;
108
+ continue;
109
+ }
110
+ }
111
+ return;
112
+ }
127
113
  }
128
- function S(f, o) {
129
- if (o)
130
- for (const a of Object.keys(f.models)) {
131
- const c = f.models[a], n = c?.schema;
132
- if (n && (n.paths && n.paths[o] || n.virtuals && n.virtuals[o]))
133
- return c;
134
- }
114
+ function a(e, t) {
115
+ if (t) for (let n of Object.keys(e.models)) {
116
+ let r = e.models[n], i = r?.schema;
117
+ if (i && (i.paths && i.paths[t] || i.virtuals && i.virtuals[t])) return r;
118
+ }
135
119
  }
136
- function _(f, o) {
137
- const a = (o || "").split(".")[0] || "";
138
- if (a)
139
- for (const c of Object.keys(f.models)) {
140
- const n = f.models[c], r = n?.schema;
141
- if (r && (r.paths && r.paths[a] || r.virtuals && r.virtuals[a]))
142
- return n;
143
- }
120
+ function o(e, t) {
121
+ let n = (t || "").split(".")[0] || "";
122
+ if (n) for (let t of Object.keys(e.models)) {
123
+ let r = e.models[t], i = r?.schema;
124
+ if (i && (i.paths && i.paths[n] || i.virtuals && i.virtuals[n])) return r;
125
+ }
144
126
  }
145
- async function w(f, o, a, c, n, r) {
146
- let i = o.__t;
147
- if (!i) {
148
- if (r) {
149
- const s = n ? `${n}.${a}` : a, e = (s || "").split(".")[0] || "";
150
- let t = r;
151
- if (!!!(t?.schema?.paths && t.schema.paths[e] || t?.schema?.virtuals && t.schema.virtuals[e])) {
152
- const N = _(f, s);
153
- N && (t = N);
154
- }
155
- const m = R(f, t, s, o);
156
- if (m)
157
- i = m;
158
- else {
159
- const N = (s.includes(".") ? s.split(".").pop() : s) || "";
160
- if (N) {
161
- const V = S(f, N);
162
- if (V) {
163
- const O = R(f, V, s, o);
164
- O && (i = O);
165
- }
166
- }
167
- }
168
- }
169
- if (c && c.length > 0) {
170
- const s = a.split(".").pop() || "", e = c.find((t) => t.name === s);
171
- if (e && e.options.ref) {
172
- let t;
173
- typeof e.options.ref == "function" ? t = e.options.ref(o) : typeof e.options.ref == "string" && (t = e.options.ref), t && typeof t == "string" && (i = t);
174
- }
175
- }
176
- if (!i) {
177
- for (const [s, e] of Object.entries(o))
178
- if (s === "entityType" && typeof e == "string") {
179
- i = e;
180
- break;
181
- }
182
- if (i && f.models[i]) {
183
- const s = f.models[i];
184
- if (s && s.schema) {
185
- const e = s.schema, t = a.split(".").pop() || "", y = (N, V = "root") => {
186
- if (!N || !N.virtuals)
187
- return;
188
- const O = N.virtuals;
189
- for (const v of Object.keys(O))
190
- if (v === t) {
191
- const u = O[v];
192
- if (u && u.options && u.options.ref) {
193
- let A;
194
- if (typeof u.options.ref == "function" ? A = u.options.ref(o) : typeof u.options.ref == "string" && (A = u.options.ref), A && typeof A == "string")
195
- return A;
196
- }
197
- }
198
- if (N.paths)
199
- for (const v of Object.keys(N.paths)) {
200
- const u = N.paths[v];
201
- if (u && u.schema) {
202
- const A = y(u.schema, `${V}.${v}`);
203
- if (A)
204
- return A;
205
- }
206
- }
207
- }, m = y(e);
208
- m && (i = m);
209
- }
210
- }
211
- }
212
- if (!i) {
213
- const s = a.split(".").pop() || "";
214
- if (r && r.schema) {
215
- const e = r.schema, t = (m, N = "root") => {
216
- if (!m || !m.virtuals)
217
- return;
218
- const V = m.virtuals;
219
- for (const O of Object.keys(V))
220
- if (O === s) {
221
- const v = V[O];
222
- if (v && v.options && v.options.ref) {
223
- let u;
224
- if (typeof v.options.ref == "function" ? u = v.options.ref(o) : typeof v.options.ref == "string" && (u = v.options.ref), u && typeof u == "string")
225
- return u;
226
- }
227
- }
228
- if (m.paths)
229
- for (const O of Object.keys(m.paths)) {
230
- const v = m.paths[O];
231
- if (v && v.schema) {
232
- const u = t(v.schema, `${N}.${O}`);
233
- if (u)
234
- return u;
235
- }
236
- }
237
- }, y = t(e);
238
- y && (i = y);
239
- }
240
- if (!i && r) {
241
- const e = R(f, r, a, o);
242
- e && (i = e);
243
- }
244
- if (!i && c && c.length > 0) {
245
- const e = c.find((t) => t.name === s);
246
- if (e && e.options.ref) {
247
- let t;
248
- typeof e.options.ref == "function" ? t = e.options.ref(o) : typeof e.options.ref == "string" && (t = e.options.ref), t && typeof t == "string" && (i = t);
249
- }
250
- }
251
- }
252
- if (!i) {
253
- const s = a.split(".").pop() || "", e = s ? s.charAt(0).toUpperCase() + s.slice(1) : "";
254
- e && f.models[e] && (i = e);
255
- }
256
- }
257
- const j = f.models[i];
258
- if (!j)
259
- return;
260
- const d = `${a}Id`, h = `${a}Ids`, p = o[d] || o[h] || o[a];
261
- if (!p)
262
- return;
263
- const b = Array.isArray(p) ? p : [p], l = await j.find({ id: { $in: b } }).lean();
264
- l.length > 0 && (Array.isArray(p) ? o[a] = l : o[a] = l[0]);
127
+ async function s(e, t, n, r, s, c) {
128
+ let l = t.__t;
129
+ if (!l) {
130
+ if (c) {
131
+ let r = s ? `${s}.${n}` : n, u = (r || "").split(".")[0] || "", d = c;
132
+ if (!(d?.schema?.paths && d.schema.paths[u] || d?.schema?.virtuals && d.schema.virtuals[u])) {
133
+ let t = o(e, r);
134
+ t && (d = t);
135
+ }
136
+ let f = i(e, d, r, t);
137
+ if (f) l = f;
138
+ else {
139
+ let n = (r.includes(".") ? r.split(".").pop() : r) || "";
140
+ if (n) {
141
+ let o = a(e, n);
142
+ if (o) {
143
+ let n = i(e, o, r, t);
144
+ n && (l = n);
145
+ }
146
+ }
147
+ }
148
+ }
149
+ if (r && r.length > 0) {
150
+ let e = n.split(".").pop() || "", i = r.find((t) => t.name === e);
151
+ if (i && i.options.ref) {
152
+ let e;
153
+ typeof i.options.ref == "function" ? e = i.options.ref(t) : typeof i.options.ref == "string" && (e = i.options.ref), e && typeof e == "string" && (l = e);
154
+ }
155
+ }
156
+ if (!l) {
157
+ for (let [e, n] of Object.entries(t)) if (e === "entityType" && typeof n == "string") {
158
+ l = n;
159
+ break;
160
+ }
161
+ if (l && e.models[l]) {
162
+ let r = e.models[l];
163
+ if (r && r.schema) {
164
+ let e = r.schema, i = n.split(".").pop() || "", a = (e, n = "root") => {
165
+ if (!e || !e.virtuals) return;
166
+ let r = e.virtuals;
167
+ for (let e of Object.keys(r)) if (e === i) {
168
+ let n = r[e];
169
+ if (n && n.options && n.options.ref) {
170
+ let e;
171
+ if (typeof n.options.ref == "function" ? e = n.options.ref(t) : typeof n.options.ref == "string" && (e = n.options.ref), e && typeof e == "string") return e;
172
+ }
173
+ }
174
+ if (e.paths) for (let t of Object.keys(e.paths)) {
175
+ let r = e.paths[t];
176
+ if (r && r.schema) {
177
+ let e = a(r.schema, `${n}.${t}`);
178
+ if (e) return e;
179
+ }
180
+ }
181
+ }, o = a(e);
182
+ o && (l = o);
183
+ }
184
+ }
185
+ }
186
+ if (!l) {
187
+ let a = n.split(".").pop() || "";
188
+ if (c && c.schema) {
189
+ let e = c.schema, n = (e, r = "root") => {
190
+ if (!e || !e.virtuals) return;
191
+ let i = e.virtuals;
192
+ for (let e of Object.keys(i)) if (e === a) {
193
+ let n = i[e];
194
+ if (n && n.options && n.options.ref) {
195
+ let e;
196
+ if (typeof n.options.ref == "function" ? e = n.options.ref(t) : typeof n.options.ref == "string" && (e = n.options.ref), e && typeof e == "string") return e;
197
+ }
198
+ }
199
+ if (e.paths) for (let t of Object.keys(e.paths)) {
200
+ let i = e.paths[t];
201
+ if (i && i.schema) {
202
+ let e = n(i.schema, `${r}.${t}`);
203
+ if (e) return e;
204
+ }
205
+ }
206
+ }, r = n(e);
207
+ r && (l = r);
208
+ }
209
+ if (!l && c) {
210
+ let r = i(e, c, n, t);
211
+ r && (l = r);
212
+ }
213
+ if (!l && r && r.length > 0) {
214
+ let e = r.find((e) => e.name === a);
215
+ if (e && e.options.ref) {
216
+ let n;
217
+ typeof e.options.ref == "function" ? n = e.options.ref(t) : typeof e.options.ref == "string" && (n = e.options.ref), n && typeof n == "string" && (l = n);
218
+ }
219
+ }
220
+ }
221
+ if (!l) {
222
+ let t = n.split(".").pop() || "", r = t ? t.charAt(0).toUpperCase() + t.slice(1) : "";
223
+ r && e.models[r] && (l = r);
224
+ }
225
+ }
226
+ let u = e.models[l];
227
+ if (!u) return;
228
+ let d = `${n}Id`, f = `${n}Ids`, p = t[d] || t[f] || t[n];
229
+ if (!p) return;
230
+ let m = await u.find({ id: { $in: Array.isArray(p) ? p : [p] } }).lean();
231
+ m.length > 0 && (Array.isArray(p) ? t[n] = m : t[n] = m[0]);
265
232
  }
266
- export {
267
- $ as applyNestedPopulate
268
- };
269
- //# sourceMappingURL=mongo.populate.js.map
233
+ //#endregion
234
+ export { t as applyNestedPopulate };
235
+
236
+ //# sourceMappingURL=mongo.populate.js.map