@cyberskill/shared 2.28.0 → 3.1.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 +1 -0
- package/dist/config/commitlint/index.js.map +1 -0
- package/dist/config/config.test.unit.d.ts +1 -0
- package/dist/config/config.type.js +1 -0
- package/dist/config/config.type.js.map +1 -0
- package/dist/config/config.type.test.unit.d.ts +1 -0
- package/dist/config/config.util.js +25 -33
- package/dist/config/config.util.js.map +1 -0
- package/dist/config/env/env.constant.js +1 -0
- package/dist/config/env/env.constant.js.map +1 -0
- package/dist/config/env/env.util.js +1 -0
- package/dist/config/env/env.util.js.map +1 -0
- package/dist/config/env/index.js +1 -0
- package/dist/config/env/index.js.map +1 -0
- package/dist/config/eslint/index.d.ts +4 -0
- package/dist/config/eslint/index.js +5 -12
- package/dist/config/eslint/index.js.map +1 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.js +29 -33
- package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -0
- package/dist/config/graphql-codegen/index.js +1 -0
- package/dist/config/graphql-codegen/index.js.map +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/lint-staged/index.js +1 -0
- package/dist/config/lint-staged/index.js.map +1 -0
- package/dist/config/storybook/index.js +1 -0
- package/dist/config/storybook/index.js.map +1 -0
- package/dist/config/storybook/storybook.main.js +1 -0
- package/dist/config/storybook/storybook.main.js.map +1 -0
- package/dist/config/storybook/storybook.preview.js +11 -13
- package/dist/config/storybook/storybook.preview.js.map +1 -0
- package/dist/config/vitest/index.js +1 -0
- package/dist/config/vitest/index.js.map +1 -0
- package/dist/config/vitest/vitest.e2e.js +2 -1
- package/dist/config/vitest/vitest.e2e.js.map +1 -0
- package/dist/config/vitest/vitest.unit.js +20 -8
- package/dist/config/vitest/vitest.unit.js.map +1 -0
- package/dist/constant/common.js +2 -1
- package/dist/constant/common.js.map +1 -0
- package/dist/constant/constant.test.unit.d.ts +1 -0
- package/dist/constant/index.js +1 -0
- package/dist/constant/index.js.map +1 -0
- package/dist/constant/response-status.js +1 -0
- package/dist/constant/response-status.js.map +1 -0
- package/dist/node/apollo-server/apollo-server.util.js +22 -48
- package/dist/node/apollo-server/apollo-server.util.js.map +1 -0
- package/dist/node/apollo-server/index.js +1 -0
- package/dist/node/apollo-server/index.js.map +1 -0
- package/dist/node/cli/index.js +110 -165
- package/dist/node/cli/index.js.map +1 -0
- package/dist/node/command/command.test.unit.d.ts +1 -0
- package/dist/node/command/command.type.js +1 -0
- package/dist/node/command/command.type.js.map +1 -0
- package/dist/node/command/command.util.js +142 -169
- package/dist/node/command/command.util.js.map +1 -0
- package/dist/node/command/index.js +1 -0
- package/dist/node/command/index.js.map +1 -0
- package/dist/node/express/express.type.d.ts +4 -0
- package/dist/node/express/express.util.js +56 -71
- package/dist/node/express/express.util.js.map +1 -0
- package/dist/node/express/index.js +1 -0
- package/dist/node/express/index.js.map +1 -0
- package/dist/node/fs/fs.test.unit.d.ts +1 -0
- package/dist/node/fs/fs.util.js +46 -60
- package/dist/node/fs/fs.util.js.map +1 -0
- package/dist/node/fs/index.js +1 -0
- package/dist/node/fs/index.js.map +1 -0
- package/dist/node/log/index.js +1 -0
- package/dist/node/log/index.js.map +1 -0
- package/dist/node/log/log.test.unit.d.ts +1 -0
- package/dist/node/log/log.type.js +1 -0
- package/dist/node/log/log.type.js.map +1 -0
- package/dist/node/log/log.util.js +30 -30
- package/dist/node/log/log.util.js.map +1 -0
- package/dist/node/mongo/index.d.ts +2 -0
- package/dist/node/mongo/index.js +21 -12
- package/dist/node/mongo/index.js.map +1 -0
- package/dist/node/mongo/mongo.constant.js +1 -0
- package/dist/node/mongo/mongo.constant.js.map +1 -0
- package/dist/node/mongo/mongo.controller.d.ts +5 -315
- package/dist/node/mongo/mongo.controller.mongoose.d.ts +234 -0
- package/dist/node/mongo/mongo.controller.mongoose.js +468 -0
- package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -0
- package/dist/node/mongo/mongo.controller.native.d.ts +84 -0
- package/dist/node/mongo/mongo.controller.native.js +214 -0
- package/dist/node/mongo/mongo.controller.native.js.map +1 -0
- package/dist/node/mongo/mongo.dynamic-populate.d.ts +61 -0
- package/dist/node/mongo/mongo.dynamic-populate.js +197 -0
- package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -0
- package/dist/node/mongo/mongo.populate.d.ts +15 -0
- package/dist/node/mongo/mongo.populate.js +269 -0
- package/dist/node/mongo/mongo.populate.js.map +1 -0
- package/dist/node/mongo/mongo.type.js +1 -0
- package/dist/node/mongo/mongo.type.js.map +1 -0
- package/dist/node/mongo/mongo.util.d.ts +52 -0
- package/dist/node/mongo/mongo.util.js +111 -409
- package/dist/node/mongo/mongo.util.js.map +1 -0
- package/dist/node/package/index.js +1 -0
- package/dist/node/package/index.js.map +1 -0
- package/dist/node/package/package.test.unit.d.ts +1 -0
- package/dist/node/package/package.type.js +1 -0
- package/dist/node/package/package.type.js.map +1 -0
- package/dist/node/package/package.util.js +197 -226
- package/dist/node/package/package.util.js.map +1 -0
- package/dist/node/path/index.js +27 -25
- package/dist/node/path/index.js.map +1 -0
- package/dist/node/path/path.constant.d.ts +2 -0
- package/dist/node/path/path.constant.js +131 -150
- package/dist/node/path/path.constant.js.map +1 -0
- package/dist/node/path/path.util.js +1 -0
- package/dist/node/path/path.util.js.map +1 -0
- package/dist/node/storage/index.js +1 -0
- package/dist/node/storage/index.js.map +1 -0
- package/dist/node/storage/storage.constant.js +1 -0
- package/dist/node/storage/storage.constant.js.map +1 -0
- package/dist/node/storage/storage.util.js +111 -158
- package/dist/node/storage/storage.util.js.map +1 -0
- package/dist/node/upload/index.js +1 -0
- package/dist/node/upload/index.js.map +1 -0
- package/dist/node/upload/upload.constant.js +1 -0
- package/dist/node/upload/upload.constant.js.map +1 -0
- package/dist/node/upload/upload.type.js +1 -0
- package/dist/node/upload/upload.type.js.map +1 -0
- package/dist/node/upload/upload.util.js +120 -150
- package/dist/node/upload/upload.util.js.map +1 -0
- package/dist/node/ws/index.d.ts +1 -1
- package/dist/node/ws/index.js +2 -1
- package/dist/node/ws/index.js.map +1 -0
- package/dist/node/ws/ws.util.js +46 -0
- package/dist/node/ws/ws.util.js.map +1 -0
- package/dist/node_modules/.pnpm/{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 → vitest@4.0.18_@types_node@25.3.3_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 +1 -0
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.3_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 +1 -0
- package/dist/react/apollo-client/apollo-client.component.js +5 -4
- package/dist/react/apollo-client/apollo-client.component.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.constant.js +1 -0
- package/dist/react/apollo-client/apollo-client.constant.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.context.js +1 -0
- package/dist/react/apollo-client/apollo-client.context.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.module.scss.js +1 -0
- package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.util.js +52 -58
- package/dist/react/apollo-client/apollo-client.util.js.map +1 -0
- package/dist/react/apollo-client/index.js +1 -0
- package/dist/react/apollo-client/index.js.map +1 -0
- package/dist/react/apollo-client/links/index.js +1 -0
- package/dist/react/apollo-client/links/index.js.map +1 -0
- package/dist/react/apollo-client/links/upload.js +72 -74
- package/dist/react/apollo-client/links/upload.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +12 -18
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -0
- package/dist/react/apollo-client-nextjs/index.js +1 -0
- package/dist/react/apollo-client-nextjs/index.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.component.js +62 -23
- package/dist/react/apollo-error/apollo-error.component.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.context.js +1 -0
- package/dist/react/apollo-error/apollo-error.context.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.hook.js +1 -0
- package/dist/react/apollo-error/apollo-error.hook.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.module.scss.js +7 -6
- package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.provider.js +1 -0
- package/dist/react/apollo-error/apollo-error.provider.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.test.unit.d.ts +1 -0
- package/dist/react/apollo-error/apollo-error.util.js +7 -6
- package/dist/react/apollo-error/apollo-error.util.js.map +1 -0
- package/dist/react/apollo-error/index.js +1 -0
- package/dist/react/apollo-error/index.js.map +1 -0
- package/dist/react/i18next/i18next.hook.js +1 -0
- package/dist/react/i18next/i18next.hook.js.map +1 -0
- package/dist/react/i18next/i18next.util.js +1 -0
- package/dist/react/i18next/i18next.util.js.map +1 -0
- package/dist/react/i18next/index.js +1 -0
- package/dist/react/i18next/index.js.map +1 -0
- package/dist/react/loading/index.js +1 -0
- package/dist/react/loading/index.js.map +1 -0
- package/dist/react/loading/loading.component.js +31 -46
- package/dist/react/loading/loading.component.js.map +1 -0
- package/dist/react/loading/loading.context.js +1 -0
- package/dist/react/loading/loading.context.js.map +1 -0
- package/dist/react/loading/loading.hook.js +1 -0
- package/dist/react/loading/loading.hook.js.map +1 -0
- package/dist/react/loading/loading.module.scss.js +1 -0
- package/dist/react/loading/loading.module.scss.js.map +1 -0
- package/dist/react/loading/loading.provider.js +1 -0
- package/dist/react/loading/loading.provider.js.map +1 -0
- package/dist/react/log/index.js +1 -0
- package/dist/react/log/index.js.map +1 -0
- package/dist/react/log/log.util.js +5 -4
- package/dist/react/log/log.util.js.map +1 -0
- package/dist/react/next-intl/index.js +1 -0
- package/dist/react/next-intl/index.js.map +1 -0
- package/dist/react/next-intl/next-intl.constant.js +1 -0
- package/dist/react/next-intl/next-intl.constant.js.map +1 -0
- package/dist/react/next-intl/next-intl.context.js +1 -0
- package/dist/react/next-intl/next-intl.context.js.map +1 -0
- package/dist/react/next-intl/next-intl.hoc.js +14 -22
- package/dist/react/next-intl/next-intl.hoc.js.map +1 -0
- package/dist/react/next-intl/next-intl.hook.js +1 -0
- package/dist/react/next-intl/next-intl.hook.js.map +1 -0
- package/dist/react/next-intl/next-intl.provider.js +8 -7
- package/dist/react/next-intl/next-intl.provider.js.map +1 -0
- package/dist/react/storage/index.js +1 -0
- package/dist/react/storage/index.js.map +1 -0
- package/dist/react/storage/storage.hook.js +44 -59
- package/dist/react/storage/storage.hook.js.map +1 -0
- package/dist/react/storage/storage.test.unit.d.ts +1 -0
- package/dist/react/storage/storage.util.js +29 -53
- package/dist/react/storage/storage.util.js.map +1 -0
- package/dist/react/toast/index.js +1 -0
- package/dist/react/toast/index.js.map +1 -0
- package/dist/react/userback/index.js +1 -0
- package/dist/react/userback/index.js.map +1 -0
- package/dist/react/userback/userback.component.js +19 -42
- package/dist/react/userback/userback.component.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/typescript/common.type.js +1 -0
- package/dist/typescript/common.type.js.map +1 -0
- package/dist/typescript/index.js +1 -0
- package/dist/typescript/index.js.map +1 -0
- package/dist/typescript/typescript.test.unit.d.ts +1 -0
- package/dist/util/common/common.util.d.ts +2 -0
- package/dist/util/common/common.util.js +30 -37
- package/dist/util/common/common.util.js.map +1 -0
- package/dist/util/common/index.js +1 -0
- package/dist/util/common/index.js.map +1 -0
- package/dist/util/index.js +11 -9
- package/dist/util/index.js.map +1 -0
- package/dist/util/object/index.js +1 -0
- package/dist/util/object/index.js.map +1 -0
- package/dist/util/object/object.util.js +73 -76
- package/dist/util/object/object.util.js.map +1 -0
- package/dist/util/serializer/index.js +1 -0
- package/dist/util/serializer/index.js.map +1 -0
- package/dist/util/serializer/serializer.util.js +1 -0
- package/dist/util/serializer/serializer.util.js.map +1 -0
- package/dist/util/string/index.js +5 -3
- package/dist/util/string/index.js.map +1 -0
- package/dist/util/string/string.util.d.ts +12 -0
- package/dist/util/string/string.util.js +64 -44
- package/dist/util/string/string.util.js.map +1 -0
- package/dist/util/validate/index.js +1 -0
- package/dist/util/validate/index.js.map +1 -0
- package/dist/util/validate/validate.util.js +1 -0
- package/dist/util/validate/validate.util.js.map +1 -0
- package/package.json +76 -96
- package/public/tsconfig.base.json +7 -3
- package/README.md +0 -470
- package/dist/config/commitlint/index.cjs +0 -1
- package/dist/config/config.type.cjs +0 -1
- package/dist/config/config.util.cjs +0 -1
- package/dist/config/env/env.constant.cjs +0 -1
- package/dist/config/env/env.util.cjs +0 -1
- package/dist/config/env/index.cjs +0 -1
- package/dist/config/eslint/index.cjs +0 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.cjs +0 -1
- package/dist/config/graphql-codegen/index.cjs +0 -1
- package/dist/config/index.cjs +0 -1
- package/dist/config/lint-staged/index.cjs +0 -1
- package/dist/config/storybook/index.cjs +0 -1
- package/dist/config/storybook/storybook.main.cjs +0 -1
- package/dist/config/storybook/storybook.preview.cjs +0 -1
- package/dist/config/vitest/index.cjs +0 -1
- package/dist/config/vitest/vitest.e2e.cjs +0 -1
- package/dist/config/vitest/vitest.unit.cjs +0 -1
- package/dist/constant/common.cjs +0 -1
- package/dist/constant/index.cjs +0 -1
- package/dist/constant/response-status.cjs +0 -1
- package/dist/node/apollo-server/apollo-server.util.cjs +0 -1
- package/dist/node/apollo-server/index.cjs +0 -1
- package/dist/node/cli/index.cjs +0 -3
- package/dist/node/command/command.type.cjs +0 -1
- package/dist/node/command/command.util.cjs +0 -2
- package/dist/node/command/index.cjs +0 -1
- package/dist/node/express/express.util.cjs +0 -1
- package/dist/node/express/index.cjs +0 -1
- package/dist/node/fs/fs.util.cjs +0 -4
- package/dist/node/fs/index.cjs +0 -1
- package/dist/node/log/index.cjs +0 -1
- package/dist/node/log/log.type.cjs +0 -1
- package/dist/node/log/log.util.cjs +0 -1
- package/dist/node/mongo/index.cjs +0 -1
- package/dist/node/mongo/mongo.constant.cjs +0 -1
- package/dist/node/mongo/mongo.controller.cjs +0 -1
- package/dist/node/mongo/mongo.controller.js +0 -956
- package/dist/node/mongo/mongo.type.cjs +0 -1
- package/dist/node/mongo/mongo.util.cjs +0 -2
- package/dist/node/package/index.cjs +0 -1
- package/dist/node/package/package.type.cjs +0 -1
- package/dist/node/package/package.util.cjs +0 -1
- package/dist/node/path/index.cjs +0 -1
- package/dist/node/path/path.constant.cjs +0 -1
- package/dist/node/path/path.util.cjs +0 -1
- package/dist/node/storage/index.cjs +0 -1
- package/dist/node/storage/storage.constant.cjs +0 -1
- package/dist/node/storage/storage.util.cjs +0 -1
- package/dist/node/upload/index.cjs +0 -1
- package/dist/node/upload/upload.constant.cjs +0 -1
- package/dist/node/upload/upload.type.cjs +0 -1
- package/dist/node/upload/upload.util.cjs +0 -1
- package/dist/node/ws/index.cjs +0 -1
- package/dist/node/ws/ts.util.cjs +0 -1
- package/dist/node/ws/ts.util.js +0 -68
- package/dist/node_modules/.pnpm/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 -1
- package/dist/react/apollo-client/apollo-client.component.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.constant.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.context.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.module.scss.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.util.cjs +0 -1
- package/dist/react/apollo-client/index.cjs +0 -1
- package/dist/react/apollo-client/links/index.cjs +0 -1
- package/dist/react/apollo-client/links/upload.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +0 -1
- package/dist/react/apollo-client-nextjs/index.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.component.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.context.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.hook.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.module.scss.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.provider.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.util.cjs +0 -1
- package/dist/react/apollo-error/index.cjs +0 -1
- package/dist/react/i18next/i18next.hook.cjs +0 -1
- package/dist/react/i18next/i18next.util.cjs +0 -1
- package/dist/react/i18next/index.cjs +0 -1
- package/dist/react/loading/index.cjs +0 -1
- package/dist/react/loading/loading.component.cjs +0 -6
- package/dist/react/loading/loading.context.cjs +0 -1
- package/dist/react/loading/loading.hook.cjs +0 -1
- package/dist/react/loading/loading.module.scss.cjs +0 -1
- package/dist/react/loading/loading.provider.cjs +0 -1
- package/dist/react/log/index.cjs +0 -1
- package/dist/react/log/log.util.cjs +0 -1
- package/dist/react/next-intl/index.cjs +0 -1
- package/dist/react/next-intl/next-intl.constant.cjs +0 -1
- package/dist/react/next-intl/next-intl.context.cjs +0 -1
- package/dist/react/next-intl/next-intl.hoc.cjs +0 -1
- package/dist/react/next-intl/next-intl.hook.cjs +0 -1
- package/dist/react/next-intl/next-intl.provider.cjs +0 -1
- package/dist/react/storage/index.cjs +0 -1
- package/dist/react/storage/storage.hook.cjs +0 -1
- package/dist/react/storage/storage.util.cjs +0 -1
- package/dist/react/toast/index.cjs +0 -1
- package/dist/react/userback/index.cjs +0 -1
- package/dist/react/userback/userback.component.cjs +0 -1
- package/dist/typescript/common.type.cjs +0 -1
- package/dist/typescript/index.cjs +0 -1
- package/dist/util/common/common.util.cjs +0 -1
- package/dist/util/common/index.cjs +0 -1
- package/dist/util/index.cjs +0 -1
- package/dist/util/object/index.cjs +0 -1
- package/dist/util/object/object.util.cjs +0 -1
- package/dist/util/serializer/index.cjs +0 -1
- package/dist/util/serializer/serializer.util.cjs +0 -1
- package/dist/util/string/index.cjs +0 -1
- package/dist/util/string/string.util.cjs +0 -1
- package/dist/util/validate/index.cjs +0 -1
- package/dist/util/validate/validate.util.cjs +0 -1
- /package/dist/node/ws/{ts.util.d.ts → ws.util.d.ts} +0 -0
|
@@ -1,39 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
return t;
|
|
17
|
-
}, tt = (t, e) => X(t, Y(e)), w = (t, e, i) => new Promise((n, r) => {
|
|
18
|
-
var o = (s) => {
|
|
19
|
-
try {
|
|
20
|
-
y(i.next(s));
|
|
21
|
-
} catch (h) {
|
|
22
|
-
r(h);
|
|
23
|
-
}
|
|
24
|
-
}, l = (s) => {
|
|
25
|
-
try {
|
|
26
|
-
y(i.throw(s));
|
|
27
|
-
} catch (h) {
|
|
28
|
-
r(h);
|
|
29
|
-
}
|
|
30
|
-
}, y = (s) => s.done ? n(s.value) : Promise.resolve(s.value).then(o, l);
|
|
31
|
-
y((i = i.apply(t, e)).next());
|
|
32
|
-
});
|
|
33
|
-
function P(t) {
|
|
34
|
-
return t === t.toUpperCase() ? t.charAt(0).toUpperCase() + t.slice(1).toLowerCase() : t;
|
|
1
|
+
import m from "mongoose-aggregate-paginate-v2";
|
|
2
|
+
import p from "mongoose-paginate-v2";
|
|
3
|
+
import { randomUUID as f } from "node:crypto";
|
|
4
|
+
import { deepClone as y, getNestedValue as g, setNestedValue as h } from "../../util/object/object.util.js";
|
|
5
|
+
import { regexSearchMapper as w } from "../../util/common/common.util.js";
|
|
6
|
+
import { writeFileSync as S, addGitIgnoreEntry as E } from "../fs/fs.util.js";
|
|
7
|
+
import { PATH as d, MIGRATE_MONGO_CONFIG as R } from "../path/path.constant.js";
|
|
8
|
+
import { validate as x } from "../../util/validate/validate.util.js";
|
|
9
|
+
function I(e) {
|
|
10
|
+
return e === e.toUpperCase() ? e.charAt(0).toUpperCase() + e.slice(1).toLowerCase() : e;
|
|
35
11
|
}
|
|
36
|
-
const
|
|
12
|
+
const l = {
|
|
37
13
|
/**
|
|
38
14
|
* Creates generic fields that are commonly used across MongoDB documents.
|
|
39
15
|
* This function generates standard fields including a UUID, deletion flag, and timestamps
|
|
@@ -43,7 +19,7 @@ const A = {
|
|
|
43
19
|
*/
|
|
44
20
|
createGenericFields() {
|
|
45
21
|
return {
|
|
46
|
-
id:
|
|
22
|
+
id: f(),
|
|
47
23
|
isDel: !1,
|
|
48
24
|
createdAt: /* @__PURE__ */ new Date(),
|
|
49
25
|
updatedAt: /* @__PURE__ */ new Date()
|
|
@@ -57,8 +33,8 @@ const A = {
|
|
|
57
33
|
* @param schema - The Mongoose schema to apply plugins to.
|
|
58
34
|
* @param plugins - An array of plugin functions or false values to filter and apply.
|
|
59
35
|
*/
|
|
60
|
-
applyPlugins(
|
|
61
|
-
|
|
36
|
+
applyPlugins(e, r) {
|
|
37
|
+
r.filter((t) => typeof t == "function").forEach((t) => e.plugin(t));
|
|
62
38
|
},
|
|
63
39
|
/**
|
|
64
40
|
* Applies middleware functions to a Mongoose schema.
|
|
@@ -67,9 +43,9 @@ const A = {
|
|
|
67
43
|
* @param schema - The Mongoose schema to apply middleware to.
|
|
68
44
|
* @param middlewares - An array of middleware configurations with method, pre, and post functions.
|
|
69
45
|
*/
|
|
70
|
-
applyMiddlewares(
|
|
71
|
-
|
|
72
|
-
|
|
46
|
+
applyMiddlewares(e, r) {
|
|
47
|
+
r.forEach(({ method: t, pre: n, post: i }) => {
|
|
48
|
+
t && n && e.pre(t, n), t && i && e.post(t, i);
|
|
73
49
|
});
|
|
74
50
|
},
|
|
75
51
|
/**
|
|
@@ -80,10 +56,10 @@ const A = {
|
|
|
80
56
|
* @param mongoose - The Mongoose instance to create the schema with.
|
|
81
57
|
* @returns A Mongoose schema with generic document fields.
|
|
82
58
|
*/
|
|
83
|
-
createGenericSchema(
|
|
84
|
-
return new
|
|
59
|
+
createGenericSchema(e) {
|
|
60
|
+
return new e.Schema(
|
|
85
61
|
{
|
|
86
|
-
id: { type: String, default: () =>
|
|
62
|
+
id: { type: String, default: () => f(), unique: !0 },
|
|
87
63
|
isDel: { type: Boolean, default: !1 }
|
|
88
64
|
},
|
|
89
65
|
{ timestamps: !0 }
|
|
@@ -102,34 +78,33 @@ const A = {
|
|
|
102
78
|
* @returns A configured Mongoose schema.
|
|
103
79
|
*/
|
|
104
80
|
createSchema({
|
|
105
|
-
mongoose:
|
|
106
|
-
schema:
|
|
107
|
-
virtuals:
|
|
81
|
+
mongoose: e,
|
|
82
|
+
schema: r,
|
|
83
|
+
virtuals: t = [],
|
|
108
84
|
standalone: n = !1
|
|
109
85
|
}) {
|
|
110
|
-
const
|
|
86
|
+
const i = new e.Schema(r, {
|
|
111
87
|
toJSON: { virtuals: !0 },
|
|
112
88
|
// So `res.json()` and other `JSON.stringify()` functions include virtuals
|
|
113
89
|
toObject: { virtuals: !0 }
|
|
114
90
|
// So `console.log()` and other functions that use `toObject()` include virtuals
|
|
115
91
|
});
|
|
116
|
-
return
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
name:
|
|
121
|
-
options:
|
|
92
|
+
return t.forEach(({ name: s, options: a, get: o }) => {
|
|
93
|
+
if (l.isDynamicVirtual(a)) {
|
|
94
|
+
const c = i.statics;
|
|
95
|
+
c._dynamicVirtuals || (c._dynamicVirtuals = []), c._dynamicVirtuals.push({
|
|
96
|
+
name: s,
|
|
97
|
+
options: a
|
|
122
98
|
});
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return ((u = this._populated) == null ? void 0 : u[o]) || (l != null && l.count ? 0 : l != null && l.justOne ? null : []);
|
|
99
|
+
const u = i.virtual(s);
|
|
100
|
+
o ? u.get(o) : u.get(function() {
|
|
101
|
+
return this._populated?.[s] || (a?.count ? 0 : a?.justOne ? null : []);
|
|
127
102
|
});
|
|
128
103
|
} else {
|
|
129
|
-
const
|
|
130
|
-
|
|
104
|
+
const c = i.virtual(s, a);
|
|
105
|
+
o && c.get(o);
|
|
131
106
|
}
|
|
132
|
-
}), n ||
|
|
107
|
+
}), n || i.add(l.createGenericSchema(e)), i;
|
|
133
108
|
},
|
|
134
109
|
/**
|
|
135
110
|
* Creates a Mongoose model with plugins, middleware, and pagination support.
|
|
@@ -148,25 +123,25 @@ const A = {
|
|
|
148
123
|
* @throws {Error} When the model name is not provided.
|
|
149
124
|
*/
|
|
150
125
|
createModel({
|
|
151
|
-
mongoose:
|
|
152
|
-
name:
|
|
153
|
-
schema:
|
|
126
|
+
mongoose: e,
|
|
127
|
+
name: r,
|
|
128
|
+
schema: t,
|
|
154
129
|
virtuals: n = [],
|
|
155
|
-
pagination:
|
|
156
|
-
aggregate:
|
|
157
|
-
middlewares:
|
|
130
|
+
pagination: i = !0,
|
|
131
|
+
aggregate: s = !0,
|
|
132
|
+
middlewares: a = []
|
|
158
133
|
}) {
|
|
159
|
-
if (!
|
|
134
|
+
if (!r)
|
|
160
135
|
throw new Error("Model name is required.");
|
|
161
|
-
if (
|
|
162
|
-
return
|
|
163
|
-
const
|
|
164
|
-
(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
]),
|
|
168
|
-
const
|
|
169
|
-
return n.length > 0 && (
|
|
136
|
+
if (e.models[r])
|
|
137
|
+
return e.models[r];
|
|
138
|
+
const o = l.createSchema({ mongoose: e, schema: t, virtuals: n });
|
|
139
|
+
(i || s) && l.applyPlugins(o, [
|
|
140
|
+
i && p,
|
|
141
|
+
s && m
|
|
142
|
+
]), l.applyMiddlewares(o, a);
|
|
143
|
+
const c = e.model(r, o);
|
|
144
|
+
return n.length > 0 && (c._virtualConfigs = n), c;
|
|
170
145
|
},
|
|
171
146
|
/**
|
|
172
147
|
* Validation utilities for Mongoose schemas.
|
|
@@ -181,10 +156,8 @@ const A = {
|
|
|
181
156
|
* @returns A validation function that returns true if the field is not empty.
|
|
182
157
|
*/
|
|
183
158
|
isRequired() {
|
|
184
|
-
return function(
|
|
185
|
-
return
|
|
186
|
-
return !Q.isEmpty(t);
|
|
187
|
-
});
|
|
159
|
+
return async function(e) {
|
|
160
|
+
return !x.isEmpty(e);
|
|
188
161
|
};
|
|
189
162
|
},
|
|
190
163
|
/**
|
|
@@ -196,14 +169,12 @@ const A = {
|
|
|
196
169
|
* @returns A validation function that returns true if the value is unique across the specified fields.
|
|
197
170
|
* @throws {Error} When fields is not a non-empty array of strings.
|
|
198
171
|
*/
|
|
199
|
-
isUnique(
|
|
200
|
-
return function(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return !(yield this.constructor.exists(i));
|
|
206
|
-
});
|
|
172
|
+
isUnique(e) {
|
|
173
|
+
return async function(r) {
|
|
174
|
+
if (!Array.isArray(e) || e.length === 0)
|
|
175
|
+
throw new Error("Fields must be a non-empty array of strings.");
|
|
176
|
+
const t = { $or: e.map((i) => ({ [i]: r })) };
|
|
177
|
+
return !await this.constructor.exists(t);
|
|
207
178
|
};
|
|
208
179
|
},
|
|
209
180
|
/**
|
|
@@ -215,19 +186,28 @@ const A = {
|
|
|
215
186
|
* @returns A validation function that returns true if the value matches all regex patterns.
|
|
216
187
|
* @throws {Error} When regexArray is not an array of valid RegExp objects.
|
|
217
188
|
*/
|
|
218
|
-
matchesRegex(
|
|
219
|
-
return (
|
|
220
|
-
if (!Array.isArray(
|
|
189
|
+
matchesRegex(e) {
|
|
190
|
+
return async (r) => {
|
|
191
|
+
if (!Array.isArray(e) || e.some((t) => !(t instanceof RegExp)))
|
|
221
192
|
throw new Error("regexArray must be an array of valid RegExp objects.");
|
|
222
|
-
return
|
|
223
|
-
}
|
|
193
|
+
return e.every((t) => t.test(r));
|
|
194
|
+
};
|
|
224
195
|
}
|
|
225
196
|
},
|
|
226
197
|
/**
|
|
227
198
|
* Migration utilities for MongoDB.
|
|
228
199
|
* This object extends the migrate-mongo library with additional configuration utilities.
|
|
229
200
|
*/
|
|
230
|
-
migrate:
|
|
201
|
+
migrate: {
|
|
202
|
+
/**
|
|
203
|
+
* Lazily loads the migrate-mongo module to avoid eager import overhead.
|
|
204
|
+
* Use this to access migrate-mongo methods (up, down, status, create) programmatically.
|
|
205
|
+
*
|
|
206
|
+
* @returns A promise resolving to the migrate-mongo module.
|
|
207
|
+
*/
|
|
208
|
+
async getModule() {
|
|
209
|
+
return (await import("migrate-mongo")).default;
|
|
210
|
+
},
|
|
231
211
|
/**
|
|
232
212
|
* Sets the migration configuration and updates .gitignore.
|
|
233
213
|
* This function creates a migration configuration file and ensures it's properly
|
|
@@ -235,12 +215,12 @@ const A = {
|
|
|
235
215
|
*
|
|
236
216
|
* @param options - Migration configuration options to write to the config file.
|
|
237
217
|
*/
|
|
238
|
-
setConfig: (
|
|
239
|
-
const
|
|
240
|
-
module.exports = ${JSON.stringify(
|
|
241
|
-
|
|
218
|
+
setConfig: (e) => {
|
|
219
|
+
const r = `// This file is automatically generated by the Cyberskill CLI.
|
|
220
|
+
module.exports = ${JSON.stringify(e, null, 4)}`;
|
|
221
|
+
S(d.MIGRATE_MONGO_CONFIG, r), E(d.GIT_IGNORE, R);
|
|
242
222
|
}
|
|
243
|
-
}
|
|
223
|
+
},
|
|
244
224
|
/**
|
|
245
225
|
* Converts string values in a filter to regex patterns for case-insensitive search.
|
|
246
226
|
* This function recursively processes a filter object and converts string values in specified fields
|
|
@@ -250,23 +230,23 @@ module.exports = ${JSON.stringify(t, null, 4)}`;
|
|
|
250
230
|
* @param fields - An array of field names to convert to regex patterns.
|
|
251
231
|
* @returns A new filter object with string values converted to regex patterns.
|
|
252
232
|
*/
|
|
253
|
-
regexify(
|
|
254
|
-
if (!
|
|
233
|
+
regexify(e, r) {
|
|
234
|
+
if (!e)
|
|
255
235
|
return {};
|
|
256
|
-
let
|
|
257
|
-
if (!
|
|
258
|
-
return
|
|
259
|
-
for (const n of
|
|
260
|
-
const
|
|
261
|
-
if (typeof
|
|
262
|
-
const
|
|
263
|
-
$regex: `.*${
|
|
236
|
+
let t = y(e);
|
|
237
|
+
if (!r || r.length === 0)
|
|
238
|
+
return t;
|
|
239
|
+
for (const n of r) {
|
|
240
|
+
const i = n.toString().split("."), s = g(t, i);
|
|
241
|
+
if (typeof s == "string" && s.length > 0) {
|
|
242
|
+
const a = {
|
|
243
|
+
$regex: `.*${w(s)}.*`,
|
|
264
244
|
$options: "i"
|
|
265
245
|
};
|
|
266
|
-
|
|
246
|
+
t = h(t, i, a);
|
|
267
247
|
}
|
|
268
248
|
}
|
|
269
|
-
return
|
|
249
|
+
return t;
|
|
270
250
|
},
|
|
271
251
|
/**
|
|
272
252
|
* Checks if a virtual options object has a dynamic ref function.
|
|
@@ -274,8 +254,8 @@ module.exports = ${JSON.stringify(t, null, 4)}`;
|
|
|
274
254
|
* @param options - The virtual options to check.
|
|
275
255
|
* @returns True if the options contain a dynamic ref function.
|
|
276
256
|
*/
|
|
277
|
-
isDynamicVirtual(
|
|
278
|
-
return !!(
|
|
257
|
+
isDynamicVirtual(e) {
|
|
258
|
+
return !!(e && typeof e.ref == "function");
|
|
279
259
|
},
|
|
280
260
|
/**
|
|
281
261
|
* Generic utility function to get new records from the database
|
|
@@ -284,15 +264,13 @@ module.exports = ${JSON.stringify(t, null, 4)}`;
|
|
|
284
264
|
* @param filterFn - Function to determine if a record already exists
|
|
285
265
|
* @returns Array of records that don't exist in the database
|
|
286
266
|
*/
|
|
287
|
-
getNewRecords(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
(
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
) : e;
|
|
295
|
-
});
|
|
267
|
+
async getNewRecords(e, r, t) {
|
|
268
|
+
const n = await e.findAll({});
|
|
269
|
+
return n.success ? r.filter(
|
|
270
|
+
(s) => !n.result.some(
|
|
271
|
+
(a) => t(a, s)
|
|
272
|
+
)
|
|
273
|
+
) : r;
|
|
296
274
|
},
|
|
297
275
|
/**
|
|
298
276
|
* Generic utility function to get existing records that match the filter criteria
|
|
@@ -301,293 +279,17 @@ module.exports = ${JSON.stringify(t, null, 4)}`;
|
|
|
301
279
|
* @param filterFn - Function to determine if a record exists
|
|
302
280
|
* @returns Array of existing records that match the filter criteria
|
|
303
281
|
*/
|
|
304
|
-
getExistingRecords(
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
(
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
) : [];
|
|
312
|
-
});
|
|
282
|
+
async getExistingRecords(e, r, t) {
|
|
283
|
+
const n = await e.findAll({});
|
|
284
|
+
return n.success ? n.result.filter(
|
|
285
|
+
(s) => r.some(
|
|
286
|
+
(a) => t(s, a)
|
|
287
|
+
)
|
|
288
|
+
) : [];
|
|
313
289
|
}
|
|
314
290
|
};
|
|
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;
|
|
323
|
-
});
|
|
324
|
-
}
|
|
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(".");
|
|
329
|
-
if (h.length < 2) {
|
|
330
|
-
for (const m of e)
|
|
331
|
-
yield F(t, m, i, n, void 0, r);
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
const u = h[0];
|
|
335
|
-
if (!u || u.trim() === "")
|
|
336
|
-
return;
|
|
337
|
-
const R = h.slice(1).join(".");
|
|
338
|
-
for (const m of e) {
|
|
339
|
-
const j = m, O = j[u];
|
|
340
|
-
if (O && typeof O == "object") {
|
|
341
|
-
let c = r;
|
|
342
|
-
const a = c;
|
|
343
|
-
if (r && r.schema && r.schema.virtuals) {
|
|
344
|
-
const f = r.schema.virtuals[u];
|
|
345
|
-
if (f && f.options && f.options.ref) {
|
|
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);
|
|
349
|
-
t.models[p] && (c = t.models[p]);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
if (!c) {
|
|
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);
|
|
355
|
-
if (p && p.options && p.options.ref) {
|
|
356
|
-
let d;
|
|
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]);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
if (c === a) {
|
|
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);
|
|
365
|
-
if (p && p.options && p.options.ref) {
|
|
366
|
-
let d;
|
|
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]);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
if (Array.isArray(O))
|
|
374
|
-
for (const f of O)
|
|
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));
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
function et(t, e, i, n, r) {
|
|
382
|
-
return w(this, null, function* () {
|
|
383
|
-
const { path: o, populate: l } = i;
|
|
384
|
-
if (!o)
|
|
385
|
-
return;
|
|
386
|
-
if (!l) {
|
|
387
|
-
yield G(t, e, o, n, r);
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
const y = o;
|
|
391
|
-
for (const s of e) {
|
|
392
|
-
const h = s, u = h[y];
|
|
393
|
-
let R = r;
|
|
394
|
-
if (r && r.schema && r.schema.virtuals) {
|
|
395
|
-
const m = r.schema.virtuals[y];
|
|
396
|
-
if (m && m.options && m.options.ref) {
|
|
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);
|
|
400
|
-
t.models[O] && (R = t.models[O]);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
if (!R && typeof u == "object" && u && "entityType" in u) {
|
|
405
|
-
const m = P(String(u.entityType));
|
|
406
|
-
t.models[m] && (R = t.models[m]);
|
|
407
|
-
}
|
|
408
|
-
if (u && typeof u == "object")
|
|
409
|
-
if (Array.isArray(u))
|
|
410
|
-
for (const m of u)
|
|
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));
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
function E(t, e, i, n) {
|
|
417
|
-
if (!i || !e || !e.schema)
|
|
418
|
-
return;
|
|
419
|
-
const r = i.split(".");
|
|
420
|
-
let o = e.schema;
|
|
421
|
-
for (let l = 0; l < r.length; l++) {
|
|
422
|
-
const y = r[l];
|
|
423
|
-
if (o && o.virtuals && y) {
|
|
424
|
-
const s = o.virtuals[y];
|
|
425
|
-
if (s && s.options && s.options.ref) {
|
|
426
|
-
let h;
|
|
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") {
|
|
428
|
-
if (l === r.length - 1)
|
|
429
|
-
return h;
|
|
430
|
-
const u = t.models[h];
|
|
431
|
-
if (u && u.schema) {
|
|
432
|
-
o = u.schema;
|
|
433
|
-
continue;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
if (o && o.paths && y) {
|
|
439
|
-
const s = o.paths[y];
|
|
440
|
-
if (s && s.schema) {
|
|
441
|
-
o = s.schema;
|
|
442
|
-
continue;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
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;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
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]))
|
|
462
|
-
return r;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
function F(t, e, i, n, r, o) {
|
|
466
|
-
return w(this, null, function* () {
|
|
467
|
-
var l, y;
|
|
468
|
-
let s = e.__t;
|
|
469
|
-
if (!s) {
|
|
470
|
-
if (o) {
|
|
471
|
-
const c = r ? `${r}.${i}` : i, a = (c || "").split(".")[0] || "";
|
|
472
|
-
let f = o;
|
|
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])) {
|
|
474
|
-
const d = rt(t, c);
|
|
475
|
-
d && (f = d);
|
|
476
|
-
}
|
|
477
|
-
const p = E(t, f, c, e);
|
|
478
|
-
if (p)
|
|
479
|
-
s = p;
|
|
480
|
-
else {
|
|
481
|
-
const d = (c.includes(".") ? c.split(".").pop() : c) || "";
|
|
482
|
-
if (d) {
|
|
483
|
-
const g = it(t, d);
|
|
484
|
-
if (g) {
|
|
485
|
-
const N = E(t, g, c, e);
|
|
486
|
-
N && (s = N);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
if (n && n.length > 0) {
|
|
492
|
-
const c = i.split(".").pop() || "", a = n.find((f) => f.name === c);
|
|
493
|
-
if (a && a.options.ref) {
|
|
494
|
-
let 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);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
if (!s) {
|
|
499
|
-
for (const [c, a] of Object.entries(e))
|
|
500
|
-
if (c === "entityType" && typeof a == "string") {
|
|
501
|
-
s = a;
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
if (s && t.models[s]) {
|
|
505
|
-
const c = t.models[s];
|
|
506
|
-
if (c && c.schema) {
|
|
507
|
-
const a = c.schema, f = i.split(".").pop() || "", b = (d, g = "root") => {
|
|
508
|
-
if (!d || !d.virtuals)
|
|
509
|
-
return;
|
|
510
|
-
const N = d.virtuals;
|
|
511
|
-
for (const _ of Object.keys(N))
|
|
512
|
-
if (_ === f) {
|
|
513
|
-
const v = N[_];
|
|
514
|
-
if (v && v.options && v.options.ref) {
|
|
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;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
if (d.paths)
|
|
521
|
-
for (const _ of Object.keys(d.paths)) {
|
|
522
|
-
const v = d.paths[_];
|
|
523
|
-
if (v && v.schema) {
|
|
524
|
-
const S = b(v.schema, `${g}.${_}`);
|
|
525
|
-
if (S)
|
|
526
|
-
return S;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
}, p = b(a);
|
|
530
|
-
p && (s = p);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
if (!s) {
|
|
535
|
-
const c = i.split(".").pop() || "";
|
|
536
|
-
if (o && o.schema) {
|
|
537
|
-
const a = o.schema, f = (p, d = "root") => {
|
|
538
|
-
if (!p || !p.virtuals)
|
|
539
|
-
return;
|
|
540
|
-
const g = p.virtuals;
|
|
541
|
-
for (const N of Object.keys(g))
|
|
542
|
-
if (N === c) {
|
|
543
|
-
const _ = g[N];
|
|
544
|
-
if (_ && _.options && _.options.ref) {
|
|
545
|
-
let v;
|
|
546
|
-
if (typeof _.options.ref == "function" ? v = _.options.ref(e) : typeof _.options.ref == "string" && (v = _.options.ref), v && typeof v == "string")
|
|
547
|
-
return v;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
if (p.paths)
|
|
551
|
-
for (const N of Object.keys(p.paths)) {
|
|
552
|
-
const _ = p.paths[N];
|
|
553
|
-
if (_ && _.schema) {
|
|
554
|
-
const v = f(_.schema, `${d}.${N}`);
|
|
555
|
-
if (v)
|
|
556
|
-
return v;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}, b = f(a);
|
|
560
|
-
b && (s = b);
|
|
561
|
-
}
|
|
562
|
-
if (!s && o) {
|
|
563
|
-
const a = E(t, o, i, e);
|
|
564
|
-
a && (s = a);
|
|
565
|
-
}
|
|
566
|
-
if (!s && n && n.length > 0) {
|
|
567
|
-
const a = n.find((f) => f.name === c);
|
|
568
|
-
if (a && a.options.ref) {
|
|
569
|
-
let 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);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
if (!s) {
|
|
575
|
-
const c = i.split(".").pop() || "", a = c ? c.charAt(0).toUpperCase() + c.slice(1) : "";
|
|
576
|
-
a && t.models[a] && (s = a);
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
const h = t.models[s];
|
|
580
|
-
if (!h)
|
|
581
|
-
return;
|
|
582
|
-
const u = `${i}Id`, R = `${i}Ids`, m = e[u] || e[R] || e[i];
|
|
583
|
-
if (!m)
|
|
584
|
-
return;
|
|
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]);
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
291
|
export {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
A as mongo
|
|
292
|
+
I as convertEnumToModelName,
|
|
293
|
+
l as mongo
|
|
593
294
|
};
|
|
295
|
+
//# sourceMappingURL=mongo.util.js.map
|