@cyberskill/shared 3.0.0 → 3.2.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.type.js +1 -0
- package/dist/config/config.type.js.map +1 -0
- package/dist/config/config.util.js +4 -2
- 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.js +1 -0
- package/dist/config/eslint/index.js.map +1 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.js +1 -0
- 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.d.ts +1 -1
- package/dist/config/storybook/storybook.preview.js +6 -4
- 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.d.ts +2 -0
- package/dist/config/vitest/vitest.e2e.js +12 -18
- package/dist/config/vitest/vitest.e2e.js.map +1 -0
- package/dist/config/vitest/vitest.unit.d.ts +2 -0
- package/dist/config/vitest/vitest.unit.js +8 -5
- package/dist/config/vitest/vitest.unit.js.map +1 -0
- package/dist/constant/common.js +1 -0
- package/dist/constant/common.js.map +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 +1 -0
- 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 +56 -45
- package/dist/node/cli/index.js.map +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 +107 -99
- 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 +49 -31
- 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.util.js +1 -0
- 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.type.js +1 -0
- package/dist/node/log/log.type.js.map +1 -0
- package/dist/node/log/log.util.js +1 -0
- 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 +106 -363
- 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.type.js +1 -0
- package/dist/node/package/package.type.js.map +1 -0
- package/dist/node/package/package.util.js +20 -20
- package/dist/node/package/package.util.js.map +1 -0
- package/dist/node/path/index.js +1 -0
- package/dist/node/path/index.js.map +1 -0
- package/dist/node/path/path.constant.js +10 -9
- 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 +1 -0
- 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 +1 -0
- 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/{ts.util.js → ws.util.js} +1 -0
- package/dist/node/ws/ws.util.js.map +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 → 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 +1 -0
- 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 +1 -0
- package/dist/react/apollo-client/apollo-client.component.js +1 -0
- 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 +14 -13
- 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 +1 -0
- 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 +1 -0
- 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 +23 -21
- 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 +1 -0
- 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.util.js +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- package/dist/react/storage/storage.hook.js.map +1 -0
- package/dist/react/storage/storage.util.js +1 -0
- 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 +1 -0
- package/dist/react/userback/userback.component.js.map +1 -0
- 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/util/common/common.util.js +27 -25
- 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 +1 -0
- 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 +50 -49
- 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 +13 -12
- package/dist/util/serializer/serializer.util.js.map +1 -0
- package/dist/util/string/index.js +1 -0
- package/dist/util/string/index.js.map +1 -0
- package/dist/util/string/string.util.js +30 -28
- 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.d.ts +0 -4
- package/dist/util/validate/validate.util.js +4 -3
- package/dist/util/validate/validate.util.js.map +1 -0
- package/package.json +68 -95
- package/public/tsconfig.base.json +1 -1
- 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 -858
- package/dist/node/mongo/mongo.controller.test.unit.d.ts +0 -1
- package/dist/node/mongo/mongo.type.cjs +0 -1
- package/dist/node/mongo/mongo.util.cjs +0 -2
- package/dist/node/mongo/mongo.util.test.unit.d.ts +0 -1
- 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.test.unit.d.ts +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_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.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.test.unit.d.ts +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/loading/loading.test.unit.d.ts +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.test.unit.d.ts +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.test.unit.d.ts +0 -1
- package/dist/util/object/object.util.cjs +0 -1
- package/dist/util/serializer/index.cjs +0 -1
- package/dist/util/serializer/serializer.test.unit.d.ts +0 -1
- package/dist/util/serializer/serializer.util.cjs +0 -1
- package/dist/util/string/index.cjs +0 -1
- package/dist/util/string/string.test.unit.d.ts +0 -1
- package/dist/util/string/string.util.cjs +0 -1
- package/dist/util/validate/index.cjs +0 -1
- package/dist/util/validate/validate.test.unit.d.ts +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
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { mongo as n } from "./mongo.util.js";
|
|
2
|
+
import { RESPONSE_STATUS as r } from "../../constant/response-status.js";
|
|
3
|
+
import { catchError as c } from "../log/log.util.js";
|
|
4
|
+
class d {
|
|
5
|
+
collection;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new MongoDB controller instance.
|
|
8
|
+
*
|
|
9
|
+
* @param db - The MongoDB database instance.
|
|
10
|
+
* @param collectionName - The name of the collection to operate on.
|
|
11
|
+
*/
|
|
12
|
+
constructor(t, e) {
|
|
13
|
+
this.collection = t.collection(e);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a single document in the collection.
|
|
17
|
+
* This method adds generic fields (id, isDel, timestamps) to the document before insertion.
|
|
18
|
+
*
|
|
19
|
+
* @param document - The document to create, with or without generic fields.
|
|
20
|
+
* @returns A promise that resolves to a standardized response with the created document.
|
|
21
|
+
*/
|
|
22
|
+
async createOne(t) {
|
|
23
|
+
try {
|
|
24
|
+
const e = {
|
|
25
|
+
...n.createGenericFields(),
|
|
26
|
+
...t
|
|
27
|
+
};
|
|
28
|
+
return (await this.collection.insertOne(e)).acknowledged ? {
|
|
29
|
+
success: !0,
|
|
30
|
+
message: "Document created successfully",
|
|
31
|
+
result: e
|
|
32
|
+
} : {
|
|
33
|
+
success: !1,
|
|
34
|
+
message: "Document creation failed",
|
|
35
|
+
code: r.INTERNAL_SERVER_ERROR.CODE
|
|
36
|
+
};
|
|
37
|
+
} catch (e) {
|
|
38
|
+
return c(e);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates multiple documents in the collection.
|
|
43
|
+
* This method adds generic fields to each document before bulk insertion.
|
|
44
|
+
*
|
|
45
|
+
* @param documents - An array of documents to create.
|
|
46
|
+
* @returns A promise that resolves to a standardized response with the created documents.
|
|
47
|
+
*/
|
|
48
|
+
async createMany(t) {
|
|
49
|
+
try {
|
|
50
|
+
const e = t.map((u) => ({
|
|
51
|
+
...n.createGenericFields(),
|
|
52
|
+
...u
|
|
53
|
+
})), s = await this.collection.insertMany(e);
|
|
54
|
+
return s.insertedCount === 0 ? {
|
|
55
|
+
success: !1,
|
|
56
|
+
message: "No documents were inserted",
|
|
57
|
+
code: r.INTERNAL_SERVER_ERROR.CODE
|
|
58
|
+
} : {
|
|
59
|
+
success: !0,
|
|
60
|
+
message: `${s.insertedCount} documents created successfully`,
|
|
61
|
+
result: e
|
|
62
|
+
};
|
|
63
|
+
} catch (e) {
|
|
64
|
+
return c(e);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Finds a single document by filter criteria.
|
|
69
|
+
*
|
|
70
|
+
* @param filter - The filter criteria to find the document.
|
|
71
|
+
* @returns A promise that resolves to a standardized response with the found document.
|
|
72
|
+
*/
|
|
73
|
+
async findOne(t) {
|
|
74
|
+
try {
|
|
75
|
+
const e = await this.collection.findOne(t, { maxTimeMS: 3e4 });
|
|
76
|
+
return e ? { success: !0, message: "Document found", result: e } : { success: !1, message: "Document not found", code: r.NOT_FOUND.CODE };
|
|
77
|
+
} catch (e) {
|
|
78
|
+
return c(e);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Finds all documents matching the filter criteria.
|
|
83
|
+
*
|
|
84
|
+
* @param filter - The filter criteria to find documents (defaults to empty object for all documents).
|
|
85
|
+
* @returns A promise that resolves to a standardized response with the found documents.
|
|
86
|
+
*/
|
|
87
|
+
async findAll(t = {}) {
|
|
88
|
+
try {
|
|
89
|
+
return {
|
|
90
|
+
success: !0,
|
|
91
|
+
message: "Documents retrieved successfully",
|
|
92
|
+
result: await this.collection.find(t).limit(1e4).maxTimeMS(3e4).toArray()
|
|
93
|
+
};
|
|
94
|
+
} catch (e) {
|
|
95
|
+
return c(e);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Counts documents matching the filter criteria.
|
|
100
|
+
*
|
|
101
|
+
* @param filter - The filter criteria to count documents (defaults to empty object for all documents).
|
|
102
|
+
* @returns A promise that resolves to a standardized response with the document count.
|
|
103
|
+
*/
|
|
104
|
+
async count(t = {}) {
|
|
105
|
+
try {
|
|
106
|
+
const e = await this.collection.countDocuments(t);
|
|
107
|
+
return {
|
|
108
|
+
success: !0,
|
|
109
|
+
message: `${e} documents counted successfully`,
|
|
110
|
+
result: e
|
|
111
|
+
};
|
|
112
|
+
} catch (e) {
|
|
113
|
+
return c(e);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Updates a single document matching the filter criteria.
|
|
118
|
+
*
|
|
119
|
+
* @param filter - The filter criteria to find the document to update.
|
|
120
|
+
* @param update - The update data to apply to the document.
|
|
121
|
+
* @returns A promise that resolves to a standardized response with the update result.
|
|
122
|
+
*/
|
|
123
|
+
async updateOne(t, e) {
|
|
124
|
+
try {
|
|
125
|
+
const s = await this.collection.updateOne(t, {
|
|
126
|
+
$set: e
|
|
127
|
+
});
|
|
128
|
+
return s.matchedCount === 0 ? {
|
|
129
|
+
success: !1,
|
|
130
|
+
message: "No documents matched the filter",
|
|
131
|
+
code: r.INTERNAL_SERVER_ERROR.CODE
|
|
132
|
+
} : {
|
|
133
|
+
success: !0,
|
|
134
|
+
message: "Document updated successfully",
|
|
135
|
+
result: s
|
|
136
|
+
};
|
|
137
|
+
} catch (s) {
|
|
138
|
+
return c(s);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Updates multiple documents matching the filter criteria.
|
|
143
|
+
*
|
|
144
|
+
* @param filter - The filter criteria to find documents to update.
|
|
145
|
+
* @param update - The update data to apply to the documents.
|
|
146
|
+
* @returns A promise that resolves to a standardized response with the update result.
|
|
147
|
+
*/
|
|
148
|
+
async updateMany(t, e) {
|
|
149
|
+
try {
|
|
150
|
+
const s = await this.collection.updateMany(t, {
|
|
151
|
+
$set: e
|
|
152
|
+
});
|
|
153
|
+
return s.matchedCount === 0 ? {
|
|
154
|
+
success: !1,
|
|
155
|
+
message: "No documents matched the filter",
|
|
156
|
+
code: r.INTERNAL_SERVER_ERROR.CODE
|
|
157
|
+
} : {
|
|
158
|
+
success: !0,
|
|
159
|
+
message: "Documents updated successfully",
|
|
160
|
+
result: s
|
|
161
|
+
};
|
|
162
|
+
} catch (s) {
|
|
163
|
+
return c(s);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Deletes a single document matching the filter criteria.
|
|
168
|
+
*
|
|
169
|
+
* @param filter - The filter criteria to find the document to delete.
|
|
170
|
+
* @returns A promise that resolves to a standardized response with the delete result.
|
|
171
|
+
*/
|
|
172
|
+
async deleteOne(t) {
|
|
173
|
+
try {
|
|
174
|
+
const e = await this.collection.deleteOne(t);
|
|
175
|
+
return e.deletedCount === 0 ? {
|
|
176
|
+
success: !1,
|
|
177
|
+
message: "No documents matched the filter",
|
|
178
|
+
code: r.INTERNAL_SERVER_ERROR.CODE
|
|
179
|
+
} : {
|
|
180
|
+
success: !0,
|
|
181
|
+
message: "Document deleted successfully",
|
|
182
|
+
result: e
|
|
183
|
+
};
|
|
184
|
+
} catch (e) {
|
|
185
|
+
return c(e);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Deletes multiple documents matching the filter criteria.
|
|
190
|
+
*
|
|
191
|
+
* @param filter - The filter criteria to find documents to delete.
|
|
192
|
+
* @returns A promise that resolves to a standardized response with the delete result.
|
|
193
|
+
*/
|
|
194
|
+
async deleteMany(t) {
|
|
195
|
+
try {
|
|
196
|
+
const e = await this.collection.deleteMany(t);
|
|
197
|
+
return e.deletedCount === 0 ? {
|
|
198
|
+
success: !1,
|
|
199
|
+
message: "No documents matched the filter",
|
|
200
|
+
code: r.INTERNAL_SERVER_ERROR.CODE
|
|
201
|
+
} : {
|
|
202
|
+
success: !0,
|
|
203
|
+
message: "Documents deleted successfully",
|
|
204
|
+
result: e
|
|
205
|
+
};
|
|
206
|
+
} catch (e) {
|
|
207
|
+
return c(e);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
export {
|
|
212
|
+
d as MongoController
|
|
213
|
+
};
|
|
214
|
+
//# sourceMappingURL=mongo.controller.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo.controller.native.js","sources":["../../../src/node/mongo/mongo.controller.native.ts"],"sourcesContent":["import type { I_Return } from '#typescript/index.js';\n\nimport { RESPONSE_STATUS } from '#constant/index.js';\n\nimport type { C_Collection, C_Db, C_Document, T_DeleteResult, T_Filter, T_OptionalUnlessRequiredId, T_UpdateResult, T_WithId } from './mongo.type.js';\n\nimport { catchError } from '../log/index.js';\nimport { mongo } from './mongo.util.js';\n\n/**\n * MongoDB native driver controller for direct database operations.\n * This class provides a simplified interface for MongoDB operations using the native driver,\n * with automatic generic field generation and standardized response formatting.\n */\nexport class MongoController<D extends Partial<C_Document>> {\n private collection: C_Collection<D>;\n\n /**\n * Creates a new MongoDB controller instance.\n *\n * @param db - The MongoDB database instance.\n * @param collectionName - The name of the collection to operate on.\n */\n constructor(db: C_Db, collectionName: string) {\n this.collection = db.collection<D>(collectionName);\n }\n\n /**\n * Creates a single document in the collection.\n * This method adds generic fields (id, isDel, timestamps) to the document before insertion.\n *\n * @param document - The document to create, with or without generic fields.\n * @returns A promise that resolves to a standardized response with the created document.\n */\n async createOne(document: D | Partial<D>): Promise<I_Return<D | Partial<D>>> {\n try {\n const finalDocument = {\n ...mongo.createGenericFields(),\n ...document,\n };\n\n const result = await this.collection.insertOne(finalDocument as unknown as T_OptionalUnlessRequiredId<D>);\n\n if (!result.acknowledged) {\n return {\n success: false,\n message: 'Document creation failed',\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n }\n\n return {\n success: true,\n message: 'Document created successfully',\n result: finalDocument,\n };\n }\n catch (error) {\n return catchError<(D | Partial<D>)>(error);\n }\n }\n\n /**\n * Creates multiple documents in the collection.\n * This method adds generic fields to each document before bulk insertion.\n *\n * @param documents - An array of documents to create.\n * @returns A promise that resolves to a standardized response with the created documents.\n */\n async createMany(documents: (D | Partial<D>)[]): Promise<I_Return<(D | Partial<D>)[]>> {\n try {\n const finalDocuments = documents.map(document => ({\n ...mongo.createGenericFields(),\n ...document,\n }));\n\n const result = await this.collection.insertMany(finalDocuments as unknown as T_OptionalUnlessRequiredId<D>[]);\n\n if (result.insertedCount === 0) {\n return {\n success: false,\n message: 'No documents were inserted',\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n }\n\n return {\n success: true,\n message: `${result.insertedCount} documents created successfully`,\n result: finalDocuments,\n };\n }\n catch (error) {\n return catchError<(D | Partial<D>)[]>(error);\n }\n }\n\n /**\n * Finds a single document by filter criteria.\n *\n * @param filter - The filter criteria to find the document.\n * @returns A promise that resolves to a standardized response with the found document.\n */\n async findOne(filter: T_Filter<D>): Promise<I_Return<T_WithId<D>>> {\n try {\n const result = await this.collection.findOne(filter, { maxTimeMS: 30_000 });\n\n if (!result) {\n return { success: false, message: 'Document not found', code: RESPONSE_STATUS.NOT_FOUND.CODE };\n }\n\n return { success: true, message: 'Document found', result };\n }\n catch (error) {\n return catchError<T_WithId<D>>(error);\n }\n }\n\n /**\n * Finds all documents matching the filter criteria.\n *\n * @param filter - The filter criteria to find documents (defaults to empty object for all documents).\n * @returns A promise that resolves to a standardized response with the found documents.\n */\n async findAll(\n filter: T_Filter<D> = {},\n ): Promise<I_Return<T_WithId<D>[]>> {\n try {\n const result = await this.collection.find(filter).limit(10_000).maxTimeMS(30_000).toArray();\n\n return {\n success: true,\n message: 'Documents retrieved successfully',\n result,\n };\n }\n catch (error) {\n return catchError<T_WithId<D>[]>(error);\n }\n }\n\n /**\n * Counts documents matching the filter criteria.\n *\n * @param filter - The filter criteria to count documents (defaults to empty object for all documents).\n * @returns A promise that resolves to a standardized response with the document count.\n */\n async count(\n filter: T_Filter<D> = {},\n ): Promise<I_Return<number>> {\n try {\n const result = await this.collection.countDocuments(filter);\n\n return {\n success: true,\n message: `${result} documents counted successfully`,\n result,\n };\n }\n catch (error) {\n return catchError<number>(error);\n }\n }\n\n /**\n * Updates a single document matching the filter criteria.\n *\n * @param filter - The filter criteria to find the document to update.\n * @param update - The update data to apply to the document.\n * @returns A promise that resolves to a standardized response with the update result.\n */\n async updateOne(\n filter: T_Filter<D>,\n update: Partial<D>,\n ): Promise<I_Return<T_UpdateResult>> {\n try {\n const result = await this.collection.updateOne(filter, {\n $set: update,\n });\n\n if (result.matchedCount === 0) {\n return {\n success: false,\n message: 'No documents matched the filter',\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n }\n return {\n success: true,\n message: 'Document updated successfully',\n result,\n };\n }\n catch (error) {\n return catchError<T_UpdateResult>(error);\n }\n }\n\n /**\n * Updates multiple documents matching the filter criteria.\n *\n * @param filter - The filter criteria to find documents to update.\n * @param update - The update data to apply to the documents.\n * @returns A promise that resolves to a standardized response with the update result.\n */\n async updateMany(\n filter: T_Filter<D>,\n update: Partial<D>,\n ): Promise<I_Return<T_UpdateResult>> {\n try {\n const result = await this.collection.updateMany(filter, {\n $set: update,\n });\n\n if (result.matchedCount === 0) {\n return {\n success: false,\n message: 'No documents matched the filter',\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n }\n\n return {\n success: true,\n message: 'Documents updated successfully',\n result,\n };\n }\n catch (error) {\n return catchError<T_UpdateResult>(error);\n }\n }\n\n /**\n * Deletes a single document matching the filter criteria.\n *\n * @param filter - The filter criteria to find the document to delete.\n * @returns A promise that resolves to a standardized response with the delete result.\n */\n async deleteOne(\n filter: T_Filter<D>,\n ): Promise<I_Return<T_DeleteResult>> {\n try {\n const result = await this.collection.deleteOne(filter);\n\n if (result.deletedCount === 0) {\n return {\n success: false,\n message: 'No documents matched the filter',\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n }\n return {\n success: true,\n message: 'Document deleted successfully',\n result,\n };\n }\n catch (error) {\n return catchError<T_DeleteResult>(error);\n }\n }\n\n /**\n * Deletes multiple documents matching the filter criteria.\n *\n * @param filter - The filter criteria to find documents to delete.\n * @returns A promise that resolves to a standardized response with the delete result.\n */\n async deleteMany(\n filter: T_Filter<D>,\n ): Promise<I_Return<T_DeleteResult>> {\n try {\n const result = await this.collection.deleteMany(filter);\n\n if (result.deletedCount === 0) {\n return {\n success: false,\n message: 'No documents matched the filter',\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n }\n\n return {\n success: true,\n message: 'Documents deleted successfully',\n result,\n };\n }\n catch (error) {\n return catchError<T_DeleteResult>(error);\n }\n }\n}\n"],"names":["mongo","RESPONSE_STATUS","catchError","MongoController","db","collectionName","document","finalDocument","error","documents","finalDocuments","result","filter","update"],"mappings":"AAcO,SAAA,SAAAA,SAAA;AAAA,SAAA,mBAAAC,SAAA;AAAA,SAAA,cAAAC,SAAA;AAAA,MAAMC,EAA+C;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQR,YAAYC,GAAUC,GAAwB;AAC1C,SAAK,aAAaD,EAAG,WAAcC,CAAc;AAAA,EACrD;AAAA;AA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AMF,IAAS,MAAM,KAAK,WAAW,WAAWC,GAAQ;AAAA,QACpD,MAAMC;AAAA,MAAA,CACT;AAED,aAAIF,EAAO,iBAAiB,IACjB;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,QACT,MAAMV,EAAgB,sBAAsB;AAAA,MAAA,IAI7C;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,QACT,QAAAU;AAAA,MAAA;AAAA,IAER,SACOH,GAAO;AACV,aAAON,EAA2BM,CAAK;AAAA,IAC3C;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UACFI,GACiC;AACjC,QAAI;AACA,YAAMD,IAAS,MAAM,KAAK,WAAW,UAAUC,CAAM;AAErD,aAAID,EAAO,iBAAiB,IACjB;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,QACT,MAAMV,EAAgB,sBAAsB;AAAA,MAAA,IAG7C;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,QACT,QAAAU;AAAA,MAAA;AAAA,IAER,SACOH,GAAO;AACV,aAAON,EAA2BM,CAAK;AAAA,IAC3C;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,WACFI,GACiC;AACjC,QAAI;AACA,YAAMD,IAAS,MAAM,KAAK,WAAW,WAAWC,CAAM;AAEtD,aAAID,EAAO,iBAAiB,IACjB;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,QACT,MAAMV,EAAgB,sBAAsB;AAAA,MAAA,IAI7C;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,QACT,QAAAU;AAAA,MAAA;AAAA,IAER,SACOH,GAAO;AACV,aAAON,EAA2BM,CAAK;AAAA,IAC3C;AAAA,EACJ;AACJ;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { default as mongooseRaw } from 'mongoose';
|
|
2
|
+
import { I_DynamicVirtualConfig, I_DynamicVirtualOptions, T_Input_Populate } from './mongo.type.js';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if value is object-like (e.g., objects, arrays, etc.), not null.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isObject(value: unknown): value is object;
|
|
7
|
+
/**
|
|
8
|
+
* Filters out dynamic virtuals from populate options to prevent Mongoose from trying to populate them.
|
|
9
|
+
* This function creates a new populate configuration that only includes regular virtuals.
|
|
10
|
+
*
|
|
11
|
+
* @template T - The document type
|
|
12
|
+
* @param populate - The original populate options
|
|
13
|
+
* @param dynamicVirtuals - Array of dynamic virtual configurations
|
|
14
|
+
* @returns Filtered populate options excluding dynamic virtuals
|
|
15
|
+
*/
|
|
16
|
+
export declare function filterDynamicVirtualsFromPopulate<T>(populate: T_Input_Populate | undefined, dynamicVirtuals: I_DynamicVirtualConfig<T>[] | undefined): T_Input_Populate | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Groups documents by the resolved model name for a dynamic virtual field.
|
|
19
|
+
* Used to batch population queries for dynamic virtuals.
|
|
20
|
+
*
|
|
21
|
+
* @template T - The document type
|
|
22
|
+
* @template R - The model name type (usually string or enum)
|
|
23
|
+
* @param {T[]} documents - The array of documents to process
|
|
24
|
+
* @param {string} virtualName - The name of the dynamic virtual field
|
|
25
|
+
* @param {I_DynamicVirtualOptions<T, R>} virtualOptions - The dynamic virtual options (must include a ref function)
|
|
26
|
+
* @returns {Array<{ model: string; docs: T[] }>} An array of groups, each with a model name and the docs for that model
|
|
27
|
+
*/
|
|
28
|
+
export declare function remapDynamicPopulate<T, R extends string = string>(documents: T[], virtualName: string, virtualOptions: I_DynamicVirtualOptions<T, R>): Array<{
|
|
29
|
+
model: string;
|
|
30
|
+
docs: T[];
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Type guard to check if an object is a Mongoose Document (has toObject method).
|
|
34
|
+
* @param obj - The object to check
|
|
35
|
+
* @returns True if obj has a toObject function
|
|
36
|
+
*/
|
|
37
|
+
export declare function isMongooseDoc(obj: unknown): obj is {
|
|
38
|
+
toObject: () => {
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Optimized batch population for dynamic virtuals.
|
|
44
|
+
*
|
|
45
|
+
* - Groups documents by model and batches queries for each model.
|
|
46
|
+
* - Populates all dynamic virtuals in parallel for maximum performance.
|
|
47
|
+
* - Uses direct assignment for plain objects and skips already populated fields.
|
|
48
|
+
* - Supports optional projection for population queries.
|
|
49
|
+
* - Only populates virtuals that are explicitly requested in populate options.
|
|
50
|
+
* - Reminder: Ensure indexes exist on foreignField in referenced collections for best performance.
|
|
51
|
+
*
|
|
52
|
+
* @template T - The document type (must be an object)
|
|
53
|
+
* @template R - The model name type (usually string or enum)
|
|
54
|
+
* @param {typeof mongooseRaw} mongoose - The Mongoose instance
|
|
55
|
+
* @param {T[]} documents - The array of documents to populate
|
|
56
|
+
* @param {I_DynamicVirtualConfig<T, R>[]} virtualConfigs - The dynamic virtual configurations to process
|
|
57
|
+
* @param {T_Input_Populate} [populate] - Population options to determine which virtuals to populate
|
|
58
|
+
* @param {Record<string, 0 | 1>} [projection] - Optional projection for population queries
|
|
59
|
+
* @returns {Promise<object[]>} The array of documents with dynamic virtuals populated
|
|
60
|
+
*/
|
|
61
|
+
export declare function populateDynamicVirtuals<T extends object, R extends string = string>(mongoose: typeof mongooseRaw, documents: T[], virtualConfigs: I_DynamicVirtualConfig<T, R>[], populate?: T_Input_Populate, projection?: Record<string, 0 | 1>, startModel?: any): Promise<T[]>;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { applyNestedPopulate as A } from "./mongo.populate.js";
|
|
2
|
+
import { convertEnumToModelName as O } from "./mongo.util.js";
|
|
3
|
+
import { deepClone as P } from "../../util/object/object.util.js";
|
|
4
|
+
import { catchError as D } from "../log/log.util.js";
|
|
5
|
+
function T(e) {
|
|
6
|
+
return e != null && typeof e == "object";
|
|
7
|
+
}
|
|
8
|
+
function _(e, p) {
|
|
9
|
+
if (!e || !p || p.length === 0)
|
|
10
|
+
return e;
|
|
11
|
+
const S = new Set(p.map((t) => t.name));
|
|
12
|
+
if (Array.isArray(e)) {
|
|
13
|
+
const t = e.filter((u) => {
|
|
14
|
+
if (typeof u == "string")
|
|
15
|
+
return ![...S].some(
|
|
16
|
+
(s) => u === s || u.startsWith(`${s}.`)
|
|
17
|
+
);
|
|
18
|
+
if (typeof u == "object" && u !== null) {
|
|
19
|
+
const s = u, V = s.path || s.populate || "";
|
|
20
|
+
return ![...S].some(
|
|
21
|
+
(h) => V === h || V.startsWith(`${h}.`)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return !0;
|
|
25
|
+
});
|
|
26
|
+
return t.length > 0 ? t : void 0;
|
|
27
|
+
}
|
|
28
|
+
if (typeof e == "string")
|
|
29
|
+
return [...S].some(
|
|
30
|
+
(t) => e === t || e.startsWith(`${t}.`)
|
|
31
|
+
) ? void 0 : e;
|
|
32
|
+
if (typeof e == "object" && e !== null) {
|
|
33
|
+
const t = e, u = t.path || t.populate || "";
|
|
34
|
+
return [...S].some(
|
|
35
|
+
(s) => u === s || u.startsWith(`${s}.`)
|
|
36
|
+
) ? void 0 : e;
|
|
37
|
+
}
|
|
38
|
+
return e;
|
|
39
|
+
}
|
|
40
|
+
function F(e, p, S) {
|
|
41
|
+
if (!e.length || !p || !S?.ref)
|
|
42
|
+
return [];
|
|
43
|
+
const t = /* @__PURE__ */ new Map();
|
|
44
|
+
return e.forEach((u) => {
|
|
45
|
+
try {
|
|
46
|
+
const s = S.ref(u);
|
|
47
|
+
if (s == null)
|
|
48
|
+
return;
|
|
49
|
+
const V = typeof s == "string" ? s : String(s);
|
|
50
|
+
if (V && V.trim() !== "") {
|
|
51
|
+
const h = O(V);
|
|
52
|
+
t.has(h) || t.set(h, []), t.get(h).push(u);
|
|
53
|
+
}
|
|
54
|
+
} catch (s) {
|
|
55
|
+
D(new Error(`Dynamic ref function failed for virtual "${p}": ${s instanceof Error ? s.message : String(s)}`));
|
|
56
|
+
}
|
|
57
|
+
}), Array.from(t.entries(), ([u, s]) => ({ model: u, docs: s }));
|
|
58
|
+
}
|
|
59
|
+
function L(e) {
|
|
60
|
+
return e !== null && typeof e == "object" && "toObject" in e && typeof e.toObject == "function";
|
|
61
|
+
}
|
|
62
|
+
async function k(e, p, S, t, u, s) {
|
|
63
|
+
if (!p.length || !S.length || !t)
|
|
64
|
+
return p;
|
|
65
|
+
const V = S.filter((a) => {
|
|
66
|
+
if (Array.isArray(t))
|
|
67
|
+
return t.length > 0 && t.some((n) => {
|
|
68
|
+
if (typeof n == "string")
|
|
69
|
+
return n === a.name || n.startsWith(`${a.name}.`);
|
|
70
|
+
if (n && typeof n == "object") {
|
|
71
|
+
const c = n, j = c.path || c.populate || "";
|
|
72
|
+
return j === a.name || j.startsWith(`${a.name}.`);
|
|
73
|
+
}
|
|
74
|
+
return !1;
|
|
75
|
+
});
|
|
76
|
+
if (typeof t == "string")
|
|
77
|
+
return t === a.name || t.startsWith(`${a.name}.`);
|
|
78
|
+
if (typeof t == "object" && t !== null) {
|
|
79
|
+
const n = t, c = n.path || n.populate || "";
|
|
80
|
+
return c === a.name || c.startsWith(`${a.name}.`);
|
|
81
|
+
}
|
|
82
|
+
return !1;
|
|
83
|
+
});
|
|
84
|
+
if (V.length === 0)
|
|
85
|
+
return p;
|
|
86
|
+
const h = P(p.map((a) => L(a) ? a.toObject() : a));
|
|
87
|
+
h.forEach((a) => {
|
|
88
|
+
V.forEach(({ name: n, options: c }) => {
|
|
89
|
+
n in a || (a[n] = c.count ? 0 : c.justOne ? null : []);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
const b = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const a of V) {
|
|
94
|
+
const { name: n, options: c } = a, j = F(h, n, c);
|
|
95
|
+
for (const l of j) {
|
|
96
|
+
b.has(l.model) || b.set(l.model, {
|
|
97
|
+
virtuals: [],
|
|
98
|
+
localValueSets: /* @__PURE__ */ new Map(),
|
|
99
|
+
docsByLocalValue: /* @__PURE__ */ new Map()
|
|
100
|
+
});
|
|
101
|
+
const y = b.get(l.model);
|
|
102
|
+
y.virtuals.some((f) => f.name === n) || (y.virtuals.push(a), y.localValueSets.set(n, /* @__PURE__ */ new Set()));
|
|
103
|
+
const w = y.localValueSets.get(n);
|
|
104
|
+
l.docs.forEach((f) => {
|
|
105
|
+
const i = f[c.localField];
|
|
106
|
+
if (i != null) {
|
|
107
|
+
const o = String(i);
|
|
108
|
+
w.add(o);
|
|
109
|
+
let r = -1;
|
|
110
|
+
const E = f;
|
|
111
|
+
E.id !== void 0 ? r = h.findIndex((m) => m.id === E.id) : E._id !== void 0 && (r = h.findIndex((m) => m._id?.toString?.() === E._id?.toString?.())), r !== -1 && (y.docsByLocalValue.has(o) || y.docsByLocalValue.set(o, []), y.docsByLocalValue.get(o).push(r));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (await Promise.all(Array.from(b.entries(), async ([a, n]) => {
|
|
117
|
+
const c = e.models[a];
|
|
118
|
+
if (!c)
|
|
119
|
+
return;
|
|
120
|
+
const j = /* @__PURE__ */ new Set();
|
|
121
|
+
if (n.localValueSets.forEach((i) => {
|
|
122
|
+
i.forEach((o) => j.add(o));
|
|
123
|
+
}), j.size === 0)
|
|
124
|
+
return;
|
|
125
|
+
const l = [...new Set(n.virtuals.map((i) => i.options.foreignField))], y = [...j];
|
|
126
|
+
let w;
|
|
127
|
+
l.length === 1 ? w = { [String(l[0])]: { $in: y } } : w = { $or: l.map((i) => ({ [i]: { $in: y } })) };
|
|
128
|
+
const f = await c.find(w, u).lean();
|
|
129
|
+
for (const i of n.virtuals) {
|
|
130
|
+
const { name: o, options: r } = i, E = f.filter((m) => {
|
|
131
|
+
const d = m[r.foreignField];
|
|
132
|
+
return d != null && j.has(String(d));
|
|
133
|
+
});
|
|
134
|
+
if (r.count) {
|
|
135
|
+
const m = /* @__PURE__ */ new Map();
|
|
136
|
+
E.forEach((d) => {
|
|
137
|
+
const g = d[r.foreignField]?.toString();
|
|
138
|
+
g && m.set(g, (m.get(g) || 0) + 1);
|
|
139
|
+
}), n.localValueSets.get(o).forEach((d) => {
|
|
140
|
+
const g = n.docsByLocalValue.get(d) || [], M = m.get(d) || 0;
|
|
141
|
+
g.forEach(($) => {
|
|
142
|
+
const W = h[$];
|
|
143
|
+
W[o] === void 0 && (W[o] = M);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
} else {
|
|
147
|
+
const m = /* @__PURE__ */ new Map();
|
|
148
|
+
E.forEach((d) => {
|
|
149
|
+
const g = d[r.foreignField]?.toString();
|
|
150
|
+
g && (m.has(g) || m.set(g, []), m.get(g).push(d));
|
|
151
|
+
}), n.localValueSets.get(o).forEach((d) => {
|
|
152
|
+
const g = n.docsByLocalValue.get(d) || [], M = m.get(d) || [], $ = r.justOne ? M[0] || null : M;
|
|
153
|
+
g.forEach((W) => {
|
|
154
|
+
const v = h[W];
|
|
155
|
+
v[o] = $;
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
})), t) {
|
|
161
|
+
const n = ((c) => {
|
|
162
|
+
const j = Array.isArray(c) ? c : [c], l = /* @__PURE__ */ new Map(), y = [];
|
|
163
|
+
for (const f of j)
|
|
164
|
+
if (typeof f == "string")
|
|
165
|
+
if (f.includes(".")) {
|
|
166
|
+
const i = f.split("."), o = i[0] || "", r = i.slice(1).join(".");
|
|
167
|
+
o && (l.has(o) || l.set(o, []), r && l.get(o).push(r));
|
|
168
|
+
} else
|
|
169
|
+
y.push(f);
|
|
170
|
+
else if (f && typeof f == "object") {
|
|
171
|
+
const i = f;
|
|
172
|
+
if (i.path && i.path.includes(".")) {
|
|
173
|
+
const o = i.path.split("."), r = o[0] || "", E = o.slice(1).join(".");
|
|
174
|
+
r && (l.has(r) || l.set(r, []), E && l.get(r).push(E), i.populate && l.get(r).push(i.populate));
|
|
175
|
+
} else
|
|
176
|
+
y.push(f);
|
|
177
|
+
}
|
|
178
|
+
const w = [...y];
|
|
179
|
+
return l.forEach((f, i) => {
|
|
180
|
+
const o = [];
|
|
181
|
+
for (const r of f)
|
|
182
|
+
(typeof r == "string" || r && typeof r == "object") && o.push(r);
|
|
183
|
+
o.length > 0 ? w.push({ path: i, populate: o }) : w.push(i);
|
|
184
|
+
}), w;
|
|
185
|
+
})(t);
|
|
186
|
+
await A(e, h, n, S, s);
|
|
187
|
+
}
|
|
188
|
+
return h;
|
|
189
|
+
}
|
|
190
|
+
export {
|
|
191
|
+
_ as filterDynamicVirtualsFromPopulate,
|
|
192
|
+
L as isMongooseDoc,
|
|
193
|
+
T as isObject,
|
|
194
|
+
k as populateDynamicVirtuals,
|
|
195
|
+
F as remapDynamicPopulate
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=mongo.dynamic-populate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo.dynamic-populate.js","sources":["../../../src/node/mongo/mongo.dynamic-populate.ts"],"sourcesContent":["import type mongooseRaw from 'mongoose';\n\nimport { deepClone } from '#util/index.js';\n\nimport type { I_DynamicVirtualConfig, I_DynamicVirtualOptions, T_Input_Populate } from './mongo.type.js';\n\nimport { catchError } from '../log/index.js';\nimport { applyNestedPopulate } from './mongo.populate.js';\nimport { convertEnumToModelName } from './mongo.util.js';\n\n/**\n * Checks if value is object-like (e.g., objects, arrays, etc.), not null.\n */\nexport function isObject(value: unknown): value is object {\n return value != null && typeof value === 'object';\n}\n\n/**\n * Filters out dynamic virtuals from populate options to prevent Mongoose from trying to populate them.\n * This function creates a new populate configuration that only includes regular virtuals.\n *\n * @template T - The document type\n * @param populate - The original populate options\n * @param dynamicVirtuals - Array of dynamic virtual configurations\n * @returns Filtered populate options excluding dynamic virtuals\n */\nexport function filterDynamicVirtualsFromPopulate<T>(\n populate: T_Input_Populate | undefined,\n dynamicVirtuals: I_DynamicVirtualConfig<T>[] | undefined,\n): T_Input_Populate | undefined {\n if (!populate || !dynamicVirtuals || dynamicVirtuals.length === 0) {\n return populate;\n }\n\n const dynamicVirtualNames = new Set(dynamicVirtuals.map(v => v.name));\n\n if (Array.isArray(populate)) {\n const filtered = populate.filter((p) => {\n if (typeof p === 'string') {\n return ![...dynamicVirtualNames].some(virtualName =>\n p === virtualName || p.startsWith(`${virtualName}.`),\n );\n }\n\n if (typeof p === 'object' && p !== null) {\n const popObj = p as { path?: string; populate?: string };\n const path = popObj.path || popObj.populate || '';\n\n return ![...dynamicVirtualNames].some(virtualName =>\n path === virtualName || path.startsWith(`${virtualName}.`),\n );\n }\n\n return true;\n });\n\n return filtered.length > 0 ? (filtered as T_Input_Populate) : undefined;\n }\n\n if (typeof populate === 'string') {\n return [...dynamicVirtualNames].some(virtualName =>\n populate === virtualName || populate.startsWith(`${virtualName}.`),\n )\n ? undefined\n : populate;\n }\n\n if (typeof populate === 'object' && populate !== null) {\n const popObj = populate as { path?: string; populate?: string };\n const path = popObj.path || popObj.populate || '';\n\n return [...dynamicVirtualNames].some(virtualName =>\n path === virtualName || path.startsWith(`${virtualName}.`),\n )\n ? undefined\n : populate;\n }\n\n return populate;\n}\n\n/**\n * Groups documents by the resolved model name for a dynamic virtual field.\n * Used to batch population queries for dynamic virtuals.\n *\n * @template T - The document type\n * @template R - The model name type (usually string or enum)\n * @param {T[]} documents - The array of documents to process\n * @param {string} virtualName - The name of the dynamic virtual field\n * @param {I_DynamicVirtualOptions<T, R>} virtualOptions - The dynamic virtual options (must include a ref function)\n * @returns {Array<{ model: string; docs: T[] }>} An array of groups, each with a model name and the docs for that model\n */\nexport function remapDynamicPopulate<T, R extends string = string>(\n documents: T[],\n virtualName: string,\n virtualOptions: I_DynamicVirtualOptions<T, R>,\n): Array<{ model: string; docs: T[] }> {\n if (!documents.length || !virtualName || !virtualOptions?.ref) {\n return [];\n }\n\n const modelGroups = new Map<string, T[]>();\n documents.forEach((doc) => {\n try {\n const modelName = virtualOptions.ref(doc);\n\n if (modelName === undefined || modelName === null) {\n return;\n }\n\n const modelNameString = typeof modelName === 'string' ? modelName : String(modelName);\n\n if (modelNameString && modelNameString.trim() !== '') {\n const convertedModelName = convertEnumToModelName(modelNameString);\n\n if (!modelGroups.has(convertedModelName)) {\n modelGroups.set(convertedModelName, []);\n }\n\n modelGroups.get(convertedModelName)!.push(doc);\n }\n }\n catch (error) {\n catchError(new Error(`Dynamic ref function failed for virtual \"${virtualName}\": ${error instanceof Error ? error.message : String(error)}`));\n }\n });\n\n return Array.from(modelGroups.entries(), ([model, docs]) => ({ model, docs }));\n}\n\n/**\n * Type guard to check if an object is a Mongoose Document (has toObject method).\n * @param obj - The object to check\n * @returns True if obj has a toObject function\n */\nexport function isMongooseDoc(obj: unknown): obj is { toObject: () => { [key: string]: unknown } } {\n return obj !== null && typeof obj === 'object' && 'toObject' in obj && typeof (obj as { toObject: unknown }).toObject === 'function';\n}\n\n/**\n * Optimized batch population for dynamic virtuals.\n *\n * - Groups documents by model and batches queries for each model.\n * - Populates all dynamic virtuals in parallel for maximum performance.\n * - Uses direct assignment for plain objects and skips already populated fields.\n * - Supports optional projection for population queries.\n * - Only populates virtuals that are explicitly requested in populate options.\n * - Reminder: Ensure indexes exist on foreignField in referenced collections for best performance.\n *\n * @template T - The document type (must be an object)\n * @template R - The model name type (usually string or enum)\n * @param {typeof mongooseRaw} mongoose - The Mongoose instance\n * @param {T[]} documents - The array of documents to populate\n * @param {I_DynamicVirtualConfig<T, R>[]} virtualConfigs - The dynamic virtual configurations to process\n * @param {T_Input_Populate} [populate] - Population options to determine which virtuals to populate\n * @param {Record<string, 0 | 1>} [projection] - Optional projection for population queries\n * @returns {Promise<object[]>} The array of documents with dynamic virtuals populated\n */\nexport async function populateDynamicVirtuals<T extends object, R extends string = string>(\n mongoose: typeof mongooseRaw,\n documents: T[],\n virtualConfigs: I_DynamicVirtualConfig<T, R>[],\n populate?: T_Input_Populate,\n projection?: Record<string, 0 | 1>,\n startModel?: any,\n): Promise<T[]> {\n if (!documents.length || !virtualConfigs.length) {\n return documents;\n }\n\n if (!populate) {\n return documents;\n }\n\n const requestedVirtuals = virtualConfigs.filter((config) => {\n if (Array.isArray(populate)) {\n return populate.length > 0 && populate.some((p) => {\n if (typeof p === 'string') {\n return p === config.name || p.startsWith(`${config.name}.`);\n }\n if (p && typeof p === 'object') {\n const popObj = p as { path?: string; populate?: string };\n const path = popObj.path || popObj.populate || '';\n\n return path === config.name || path.startsWith(`${config.name}.`);\n }\n\n return false;\n });\n }\n\n if (typeof populate === 'string') {\n return populate === config.name || populate.startsWith(`${config.name}.`);\n }\n\n if (typeof populate === 'object' && populate !== null) {\n const popObj = populate as { path?: string; populate?: string };\n const path = popObj.path || popObj.populate || '';\n\n return (path === config.name) || path.startsWith(`${config.name}.`);\n }\n\n return false;\n });\n\n if (requestedVirtuals.length === 0) {\n return documents;\n }\n\n const clonedDocuments = deepClone(documents.map(doc => isMongooseDoc(doc) ? doc.toObject() : doc)) as T[];\n\n clonedDocuments.forEach((doc) => {\n requestedVirtuals.forEach(({ name, options }) => {\n if (!(name in doc)) {\n (doc as { [key: string]: unknown })[name as string] = options.count ? 0 : (options.justOne ? null : []);\n }\n });\n });\n\n const modelProcessingMap = new Map<string, {\n virtuals: I_DynamicVirtualConfig<T, R>[];\n localValueSets: Map<string, Set<string>>;\n docsByLocalValue: Map<string, number[]>;\n }>();\n\n for (const virtualConfig of requestedVirtuals) {\n const { name, options } = virtualConfig;\n const populateGroups = remapDynamicPopulate(clonedDocuments, name, options);\n\n for (const group of populateGroups) {\n if (!modelProcessingMap.has(group.model)) {\n modelProcessingMap.set(group.model, {\n virtuals: [],\n localValueSets: new Map(),\n docsByLocalValue: new Map(),\n });\n }\n\n const processing = modelProcessingMap.get(group.model)!;\n\n if (!processing.virtuals.some(v => v.name === name)) {\n processing.virtuals.push(virtualConfig);\n processing.localValueSets.set(name as string, new Set());\n }\n\n const localValueSet = processing.localValueSets.get(name as string)!;\n group.docs.forEach((doc) => {\n const localVal = (doc as { [key: string]: unknown })[options.localField];\n\n if (localVal != null) {\n const strVal = String(localVal);\n localValueSet.add(strVal);\n\n let idx = -1;\n\n const docWithKeys = doc as { [key: string]: unknown };\n\n if (docWithKeys['id'] !== undefined) {\n idx = clonedDocuments.findIndex((d) => {\n const dWithKeys = d as { [key: string]: unknown };\n\n return dWithKeys['id'] === docWithKeys['id'];\n });\n }\n else if (docWithKeys['_id'] !== undefined) {\n idx = clonedDocuments.findIndex((d) => {\n const dWithKeys = d as { [key: string]: unknown };\n\n return dWithKeys['_id']?.toString?.() === docWithKeys['_id']?.toString?.();\n });\n }\n\n if (idx !== -1) {\n if (!processing.docsByLocalValue.has(strVal)) {\n processing.docsByLocalValue.set(strVal, []);\n }\n processing.docsByLocalValue.get(strVal)!.push(idx);\n }\n }\n });\n }\n }\n\n await Promise.all(Array.from(modelProcessingMap.entries(), async ([modelName, processing]) => {\n const Model = mongoose.models[modelName];\n\n if (!Model) {\n return;\n }\n\n const allLocalValues = new Set<string>();\n processing.localValueSets.forEach((localValueSet) => {\n localValueSet.forEach(val => allLocalValues.add(val));\n });\n\n if (allLocalValues.size === 0) {\n return;\n }\n\n const foreignFields = [...new Set(processing.virtuals.map(v => v.options.foreignField))];\n const localValuesArray = [...allLocalValues];\n let query;\n\n if (foreignFields.length === 1) {\n query = { [String(foreignFields[0])]: { $in: localValuesArray } };\n }\n else {\n query = { $or: foreignFields.map(field => ({ [field]: { $in: localValuesArray } })) };\n }\n\n const allPopulatedData = await Model.find(query, projection).lean();\n\n for (const virtualConfig of processing.virtuals) {\n const { name, options } = virtualConfig;\n const relevantData = allPopulatedData.filter((item) => {\n const foreignVal = (item)[options.foreignField];\n\n return foreignVal != null && allLocalValues.has(String(foreignVal));\n });\n\n if (options.count) {\n const countMap = new Map<string, number>();\n\n relevantData.forEach((item) => {\n const key = (item)[options.foreignField]?.toString();\n\n if (key) {\n countMap.set(key, (countMap.get(key) || 0) + 1);\n }\n });\n\n processing.localValueSets.get(name as string)!.forEach((localValue) => {\n const docs = processing.docsByLocalValue.get(localValue) || [];\n const count = countMap.get(localValue) || 0;\n\n docs.forEach((idx) => {\n const docToUpdate = clonedDocuments[idx] as { [key: string]: unknown };\n\n if (docToUpdate[name] === undefined) {\n docToUpdate[name] = count;\n }\n });\n });\n }\n else {\n const resultMap = new Map<string, T[]>();\n\n relevantData.forEach((item) => {\n const key = (item)[options.foreignField]?.toString();\n\n if (key) {\n if (!resultMap.has(key)) {\n resultMap.set(key, []);\n }\n resultMap.get(key)!.push(item);\n }\n });\n\n processing.localValueSets.get(name as string)!.forEach((localVal) => {\n const docs = processing.docsByLocalValue.get(localVal) || [];\n const results = resultMap.get(localVal) || [];\n const value = options.justOne ? (results[0] || null) : results;\n\n docs.forEach((idx) => {\n const docToUpdate = clonedDocuments[idx] as { [key: string]: unknown };\n docToUpdate[name] = value;\n });\n });\n }\n }\n }));\n\n if (populate) {\n const normalizePopulate = (pop: T_Input_Populate): T_Input_Populate => {\n const asArray = Array.isArray(pop) ? pop : [pop];\n const grouped = new Map<string, any[]>();\n const passthrough: any[] = [];\n\n for (const entry of asArray) {\n if (typeof entry === 'string') {\n if (entry.includes('.')) {\n const parts = entry.split('.');\n const first = parts[0] || '';\n const rest = parts.slice(1).join('.');\n\n if (first) {\n if (!grouped.has(first)) {\n grouped.set(first, []);\n }\n if (rest) {\n grouped.get(first)!.push(rest);\n }\n }\n }\n else {\n passthrough.push(entry);\n }\n }\n else if (entry && typeof entry === 'object') {\n const obj = entry as { path?: string; populate?: T_Input_Populate };\n\n if (obj.path && obj.path.includes('.')) {\n const parts = obj.path.split('.');\n const first = parts[0] || '';\n const rest = parts.slice(1).join('.');\n\n if (first) {\n if (!grouped.has(first)) {\n grouped.set(first, []);\n }\n if (rest) {\n grouped.get(first)!.push(rest);\n }\n if (obj.populate) {\n grouped.get(first)!.push(obj.populate as unknown as any);\n }\n }\n }\n else {\n passthrough.push(entry as any);\n }\n }\n }\n\n const normalized: any[] = [...passthrough];\n grouped.forEach((nested, root) => {\n const flat: any[] = [];\n\n for (const n of nested) {\n if (typeof n === 'string') {\n flat.push(n);\n }\n else if (n && typeof n === 'object') {\n flat.push(n);\n }\n }\n if (flat.length > 0) {\n normalized.push({ path: root as string, populate: flat as unknown as T_Input_Populate });\n }\n else {\n normalized.push(root);\n }\n });\n\n return normalized as unknown as T_Input_Populate;\n };\n\n const normalizedPopulate = normalizePopulate(populate);\n\n await applyNestedPopulate(mongoose, clonedDocuments, normalizedPopulate, virtualConfigs as I_DynamicVirtualConfig<unknown, string>[], startModel);\n }\n\n return clonedDocuments;\n}\n"],"names":["isObject","value","filterDynamicVirtualsFromPopulate","populate","dynamicVirtuals","dynamicVirtualNames","v","filtered","p","virtualName","popObj","path","remapDynamicPopulate","documents","virtualOptions","modelGroups","doc","modelName","modelNameString","convertedModelName","convertEnumToModelName","error","catchError","model","docs","isMongooseDoc","obj","populateDynamicVirtuals","mongoose","virtualConfigs","projection","startModel","requestedVirtuals","config","clonedDocuments","deepClone","name","options","modelProcessingMap","virtualConfig","populateGroups","group","processing","localValueSet","localVal","strVal","idx","docWithKeys","d","Model","allLocalValues","val","foreignFields","localValuesArray","query","field","allPopulatedData","relevantData","item","foreignVal","countMap","key","localValue","count","docToUpdate","resultMap","results","normalizedPopulate","pop","asArray","grouped","passthrough","entry","parts","first","rest","normalized","nested","root","flat","n","applyNestedPopulate"],"mappings":";;;;AAaO,SAASA,EAASC,GAAiC;AACtD,SAAOA,KAAS,QAAQ,OAAOA,KAAU;AAC7C;AAWO,SAASC,EACZC,GACAC,GAC4B;AAC5B,MAAI,CAACD,KAAY,CAACC,KAAmBA,EAAgB,WAAW;AAC5D,WAAOD;AAGX,QAAME,IAAsB,IAAI,IAAID,EAAgB,IAAI,CAAAE,MAAKA,EAAE,IAAI,CAAC;AAEpE,MAAI,MAAM,QAAQH,CAAQ,GAAG;AACzB,UAAMI,IAAWJ,EAAS,OAAO,CAACK,MAAM;AACpC,UAAI,OAAOA,KAAM;AACb,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AQD,EAAM,CAAC,KAAK,IACpBE,IAAOF,EAAM,MAAM,CAAC,EAAE,KAAK,GAAG;AAEpC,YAAIC,MACKJ,EAAQ,IAAII,CAAK,KAClBJ,EAAQ,IAAII,GAAO,EAAE,GAErBC,KACAL,EAAQ,IAAII,CAAK,EAAG,KAAKC,CAAI,GAE7BjD,EAAI,YACJ4C,EAAQ,IAAII,CAAK,EAAG,KAAKhD,EAAI,QAA0B;AAAA,UAGnE;AAEI,YAAA6C,EAAY,KAAKC,CAAY;AAAA,QAErC;AAGJ,YAAMI,IAAoB,CAAC,GAAGL,CAAW;AACzC,aAAAD,EAAQ,QAAQ,CAACO,GAAQC,MAAS;AAC9B,cAAMC,IAAc,CAAA;AAEpB,mBAAWC,KAAKH;AACZ,WAAI,OAAOG,KAAM,YAGRA,KAAK,OAAOA,KAAM,aACvBD,EAAK,KAAKC,CAAC;AAGnB,QAAID,EAAK,SAAS,IACdH,EAAW,KAAK,EAAE,MAAME,GAAgB,UAAUC,GAAqC,IAGvFH,EAAW,KAAKE,CAAI;AAAA,MAE5B,CAAC,GAEMF;AAAA,IACX,GAE6CzE,CAAQ;AAErD,UAAM8E,EAAoBrD,GAAUM,GAAiBiC,GAAoBtC,GAA6DE,CAAU;AAAA,EACpJ;AAEA,SAAOG;AACX;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as mongooseRaw } from 'mongoose';
|
|
2
|
+
import { I_DynamicVirtualConfig, T_Input_Populate } from './mongo.type.js';
|
|
3
|
+
/**
|
|
4
|
+
* Recursively applies nested populate options to populated documents.
|
|
5
|
+
* This function handles cases where a populated field needs further population.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The document type
|
|
8
|
+
* @param mongoose - The Mongoose instance
|
|
9
|
+
* @param documents - The documents to apply nested populations to
|
|
10
|
+
* @param populateOptions - The populate options to apply
|
|
11
|
+
* @param virtualConfigs - Optional virtual configurations for model inference
|
|
12
|
+
* @param currentModel - The current model context (which model's schema to search for virtuals)
|
|
13
|
+
* @returns Promise with documents that have nested populations applied
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyNestedPopulate<T extends object>(mongoose: typeof mongooseRaw, documents: T[], populateOptions: T_Input_Populate, virtualConfigs?: I_DynamicVirtualConfig<unknown, string>[], currentModel?: any): Promise<T[]>;
|