@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.
- package/dist/config/commitlint/index.js +8 -9
- package/dist/config/commitlint/index.js.map +1 -1
- package/dist/config/config.type.js +8 -5
- package/dist/config/config.type.js.map +1 -1
- package/dist/config/config.util.js +33 -42
- package/dist/config/config.util.js.map +1 -1
- package/dist/config/env/env.constant.js +6 -5
- package/dist/config/env/env.constant.js.map +1 -1
- package/dist/config/env/env.util.js +26 -27
- package/dist/config/env/env.util.js.map +1 -1
- package/dist/config/env/index.js +2 -7
- package/dist/config/eslint/index.js +23 -19
- package/dist/config/eslint/index.js.map +1 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.js +30 -38
- package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -1
- package/dist/config/graphql-codegen/index.js +2 -5
- package/dist/config/index.js +3 -7
- package/dist/config/lint-staged/index.js +8 -7
- package/dist/config/lint-staged/index.js.map +1 -1
- package/dist/config/storybook/index.js +2 -6
- package/dist/config/storybook/storybook.main.js +19 -18
- package/dist/config/storybook/storybook.main.js.map +1 -1
- package/dist/config/storybook/storybook.preview.js +31 -37
- package/dist/config/storybook/storybook.preview.js.map +1 -1
- package/dist/config/vitest/index.js +3 -7
- package/dist/config/vitest/vitest.e2e.js +14 -17
- package/dist/config/vitest/vitest.e2e.js.map +1 -1
- package/dist/config/vitest/vitest.unit.js +31 -32
- package/dist/config/vitest/vitest.unit.js.map +1 -1
- package/dist/constant/common.js +6 -5
- package/dist/constant/common.js.map +1 -1
- package/dist/constant/index.js +3 -7
- package/dist/constant/response-status.d.ts +186 -186
- package/dist/constant/response-status.js +254 -253
- package/dist/constant/response-status.js.map +1 -1
- package/dist/node/apollo-server/apollo-server.util.js +27 -29
- package/dist/node/apollo-server/apollo-server.util.js.map +1 -1
- package/dist/node/apollo-server/index.js +2 -7
- package/dist/node/cli/index.js +112 -113
- package/dist/node/cli/index.js.map +1 -1
- package/dist/node/command/command.type.js +8 -5
- package/dist/node/command/command.type.js.map +1 -1
- package/dist/node/command/command.util.js +136 -149
- package/dist/node/command/command.util.js.map +1 -1
- package/dist/node/command/index.js +3 -12
- package/dist/node/express/express.type.d.ts +11 -0
- package/dist/node/express/express.type.js +2 -0
- package/dist/node/express/express.util.js +74 -65
- package/dist/node/express/express.util.js.map +1 -1
- package/dist/node/express/index.js +3 -14
- package/dist/node/fs/fs.util.js +27 -51
- package/dist/node/fs/fs.util.js.map +1 -1
- package/dist/node/fs/index.js +2 -19
- package/dist/node/log/index.js +2 -8
- package/dist/node/log/log.type.js +8 -5
- package/dist/node/log/log.type.js.map +1 -1
- package/dist/node/log/log.util.js +51 -68
- package/dist/node/log/log.util.js.map +1 -1
- package/dist/node/mongo/index.js +8 -26
- package/dist/node/mongo/mongo.constant.js +6 -6
- package/dist/node/mongo/mongo.constant.js.map +1 -1
- package/dist/node/mongo/mongo.controller.mongoose.d.ts +6 -1
- package/dist/node/mongo/mongo.controller.mongoose.js +333 -467
- package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -1
- package/dist/node/mongo/mongo.controller.native.js +153 -212
- package/dist/node/mongo/mongo.controller.native.js.map +1 -1
- package/dist/node/mongo/mongo.dynamic-populate.js +164 -192
- package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -1
- package/dist/node/mongo/mongo.populate.js +229 -262
- package/dist/node/mongo/mongo.populate.js.map +1 -1
- package/dist/node/mongo/mongo.type.js +8 -17
- package/dist/node/mongo/mongo.type.js.map +1 -1
- package/dist/node/mongo/mongo.util.js +134 -293
- package/dist/node/mongo/mongo.util.js.map +1 -1
- package/dist/node/package/index.js +3 -11
- package/dist/node/package/package.type.js +8 -5
- package/dist/node/package/package.type.js.map +1 -1
- package/dist/node/package/package.util.js +216 -225
- package/dist/node/package/package.util.js.map +1 -1
- package/dist/node/path/index.js +3 -58
- package/dist/node/path/path.constant.js +211 -298
- package/dist/node/path/path.constant.js.map +1 -1
- package/dist/node/path/path.util.js +13 -16
- package/dist/node/path/path.util.js.map +1 -1
- package/dist/node/storage/index.js +3 -10
- package/dist/node/storage/storage.constant.js +6 -8
- package/dist/node/storage/storage.constant.js.map +1 -1
- package/dist/node/storage/storage.util.js +127 -178
- package/dist/node/storage/storage.util.js.map +1 -1
- package/dist/node/upload/index.js +4 -16
- package/dist/node/upload/upload.constant.js +58 -32
- package/dist/node/upload/upload.constant.js.map +1 -1
- package/dist/node/upload/upload.type.js +8 -5
- package/dist/node/upload/upload.type.js.map +1 -1
- package/dist/node/upload/upload.util.js +125 -137
- package/dist/node/upload/upload.util.js.map +1 -1
- package/dist/node/ws/index.js +2 -6
- package/dist/node/ws/ws.type.d.ts +7 -8
- package/dist/node/ws/ws.util.js +46 -44
- package/dist/node/ws/ws.util.js.map +1 -1
- 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
- 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
- package/dist/react/apollo-client/apollo-client.component.js +16 -18
- package/dist/react/apollo-client/apollo-client.component.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.constant.js +6 -5
- package/dist/react/apollo-client/apollo-client.constant.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.context.js +10 -13
- package/dist/react/apollo-client/apollo-client.context.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.module.scss.js +8 -7
- package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.util.js +57 -75
- package/dist/react/apollo-client/apollo-client.util.js.map +1 -1
- package/dist/react/apollo-client/index.js +7 -30
- package/dist/react/apollo-client/links/index.js +2 -5
- package/dist/react/apollo-client/links/upload.js +63 -107
- package/dist/react/apollo-client/links/upload.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +14 -16
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +8 -7
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +14 -14
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -1
- package/dist/react/apollo-client-nextjs/index.js +3 -7
- package/dist/react/apollo-error/apollo-error.component.js +57 -69
- package/dist/react/apollo-error/apollo-error.component.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.context.js +7 -6
- package/dist/react/apollo-error/apollo-error.context.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.hook.js +10 -10
- package/dist/react/apollo-error/apollo-error.hook.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.module.scss.js +15 -11
- package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.provider.js +31 -25
- package/dist/react/apollo-error/apollo-error.provider.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.util.js +14 -16
- package/dist/react/apollo-error/apollo-error.util.js.map +1 -1
- package/dist/react/apollo-error/index.js +5 -15
- package/dist/react/i18next/i18next.hook.js +7 -6
- package/dist/react/i18next/i18next.hook.js.map +1 -1
- package/dist/react/i18next/i18next.util.js +9 -8
- package/dist/react/i18next/i18next.util.js.map +1 -1
- package/dist/react/i18next/index.js +3 -7
- package/dist/react/loading/index.js +3 -9
- package/dist/react/loading/loading.component.js +47 -48
- package/dist/react/loading/loading.component.js.map +1 -1
- package/dist/react/loading/loading.context.js +7 -6
- package/dist/react/loading/loading.context.js.map +1 -1
- package/dist/react/loading/loading.hook.js +11 -11
- package/dist/react/loading/loading.hook.js.map +1 -1
- package/dist/react/loading/loading.module.scss.js +18 -15
- package/dist/react/loading/loading.module.scss.js.map +1 -1
- package/dist/react/loading/loading.provider.js +26 -18
- package/dist/react/loading/loading.provider.js.map +1 -1
- package/dist/react/log/index.js +2 -6
- package/dist/react/log/log.util.d.ts +8 -0
- package/dist/react/log/log.util.js +33 -29
- package/dist/react/log/log.util.js.map +1 -1
- package/dist/react/next-intl/index.js +6 -14
- package/dist/react/next-intl/next-intl.constant.js +16 -15
- package/dist/react/next-intl/next-intl.constant.js.map +1 -1
- package/dist/react/next-intl/next-intl.context.js +7 -6
- package/dist/react/next-intl/next-intl.context.js.map +1 -1
- package/dist/react/next-intl/next-intl.hoc.js +20 -23
- package/dist/react/next-intl/next-intl.hoc.js.map +1 -1
- package/dist/react/next-intl/next-intl.hook.js +13 -14
- package/dist/react/next-intl/next-intl.hook.js.map +1 -1
- package/dist/react/next-intl/next-intl.provider.js +28 -23
- package/dist/react/next-intl/next-intl.provider.js.map +1 -1
- package/dist/react/storage/index.js +3 -7
- package/dist/react/storage/storage.hook.js +61 -58
- package/dist/react/storage/storage.hook.js.map +1 -1
- package/dist/react/storage/storage.util.js +36 -68
- package/dist/react/storage/storage.util.js.map +1 -1
- package/dist/react/toast/index.js +2 -6
- package/dist/react/userback/index.js +2 -5
- package/dist/react/userback/userback.component.js +27 -27
- package/dist/react/userback/userback.component.js.map +1 -1
- package/dist/style.css +2 -1
- package/dist/typescript/common.type.js +8 -5
- package/dist/typescript/common.type.js.map +1 -1
- package/dist/typescript/index.js +2 -5
- package/dist/util/common/common.util.js +119 -48
- package/dist/util/common/common.util.js.map +1 -1
- package/dist/util/common/index.js +2 -9
- package/dist/util/index.js +6 -27
- package/dist/util/object/index.d.ts +3 -0
- package/dist/util/object/index.js +2 -10
- package/dist/util/object/object.util.js +94 -128
- package/dist/util/object/object.util.js.map +1 -1
- package/dist/util/serializer/index.js +2 -5
- package/dist/util/serializer/serializer.util.js +73 -78
- package/dist/util/serializer/serializer.util.js.map +1 -1
- package/dist/util/string/index.d.ts +3 -0
- package/dist/util/string/index.js +2 -10
- package/dist/util/string/string.util.js +59 -71
- package/dist/util/string/string.util.js.map +1 -1
- package/dist/util/validate/index.d.ts +3 -0
- package/dist/util/validate/index.js +2 -5
- package/dist/util/validate/validate.util.js +13 -39
- package/dist/util/validate/validate.util.js.map +1 -1
- package/package.json +29 -27
- package/dist/config/env/index.js.map +0 -1
- package/dist/config/graphql-codegen/index.js.map +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/config/storybook/index.js.map +0 -1
- package/dist/config/vitest/index.js.map +0 -1
- package/dist/constant/index.js.map +0 -1
- package/dist/node/apollo-server/index.js.map +0 -1
- package/dist/node/command/index.js.map +0 -1
- package/dist/node/express/index.js.map +0 -1
- package/dist/node/fs/index.js.map +0 -1
- package/dist/node/log/index.js.map +0 -1
- package/dist/node/mongo/index.js.map +0 -1
- package/dist/node/package/index.js.map +0 -1
- package/dist/node/path/index.js.map +0 -1
- package/dist/node/storage/index.js.map +0 -1
- package/dist/node/upload/index.js.map +0 -1
- package/dist/node/ws/index.js.map +0 -1
- 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
- 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
- package/dist/react/apollo-client/index.js.map +0 -1
- package/dist/react/apollo-client/links/index.js.map +0 -1
- package/dist/react/apollo-client-nextjs/index.js.map +0 -1
- package/dist/react/apollo-error/index.js.map +0 -1
- package/dist/react/i18next/index.js.map +0 -1
- package/dist/react/loading/index.js.map +0 -1
- package/dist/react/log/index.js.map +0 -1
- package/dist/react/next-intl/index.js.map +0 -1
- package/dist/react/storage/index.js.map +0 -1
- package/dist/react/toast/index.js.map +0 -1
- package/dist/react/userback/index.js.map +0 -1
- package/dist/typescript/index.js.map +0 -1
- package/dist/util/common/index.js.map +0 -1
- package/dist/util/index.js.map +0 -1
- package/dist/util/object/index.js.map +0 -1
- package/dist/util/serializer/index.js.map +0 -1
- package/dist/util/string/index.js.map +0 -1
- package/dist/util/validate/index.js.map +0 -1
|
@@ -1,269 +1,236 @@
|
|
|
1
|
-
import { convertEnumToModelName as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
//# sourceMappingURL=mongo.populate.js.map
|
|
233
|
+
//#endregion
|
|
234
|
+
export { t as applyNestedPopulate };
|
|
235
|
+
|
|
236
|
+
//# sourceMappingURL=mongo.populate.js.map
|