@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 @@
|
|
|
1
|
+
{"version":3,"file":"log.util.js","sources":["../../../src/node/log/log.util.ts"],"sourcesContent":["import type { ChalkInstance } from 'chalk';\n\nimport chalk from 'chalk';\nimport consola from 'consola';\nimport { GraphQLError } from 'graphql';\n\nimport type { I_Return } from '#typescript/index.js';\n\nimport { getEnv } from '#config/env/index.js';\nimport { RESPONSE_STATUS } from '#constant/index.js';\n\nimport type { I_CatchErrorOptions, I_IssueEntry, I_Log, I_ThrowError } from './log.type.js';\n\nconst env = getEnv();\n\n/**\n * Throws a standardized error with optional status information and type specification.\n * This function creates and throws errors that can be either GraphQL errors (with extensions)\n * or standard JavaScript errors, depending on the specified type.\n *\n * @param options - Error configuration including message, status information, and error type.\n * @param options.message - The error message to display.\n * @param options.status - The response status information (defaults to INTERNAL_SERVER_ERROR).\n * @param options.type - The type of error to throw ('graphql' or 'rest', defaults to 'graphql').\n * @throws {GraphQLError} When type is 'graphql', throws a GraphQL error with extensions.\n * @throws {Error} When type is 'rest' or unspecified, throws a standard JavaScript error.\n */\nexport function throwError({\n message,\n status = RESPONSE_STATUS.INTERNAL_SERVER_ERROR,\n type = 'graphql',\n}: I_ThrowError): never {\n const responseMessage\n = message ?? status.MESSAGE ?? 'Internal server error';\n\n if (type === 'graphql') {\n throw new GraphQLError(responseMessage, {\n extensions: { code: status.CODE },\n });\n }\n\n else {\n throw new Error(responseMessage);\n }\n}\n\nif (!env.DEBUG) {\n consola.level = 4;\n}\n\n/**\n * Gets a chalk color instance by keyword name.\n * This function safely retrieves a chalk color function by name, falling back to green\n * if the specified color is not available or invalid.\n *\n * @param color - The color keyword to get the chalk instance for.\n * @returns A chalk instance for the specified color, or green as fallback.\n */\nfunction chalkKeyword(color: string): ChalkInstance {\n const chalkColor = chalk[color as keyof typeof chalk];\n\n return typeof chalkColor === 'function' ? (chalkColor as ChalkInstance) : chalk.green;\n}\n\n/**\n * Enhanced logging interface that extends consola with custom functionality.\n * This object provides all standard consola logging methods plus additional features\n * like boxed log printing for structured error/warning display.\n */\nexport const log: I_Log = {\n silent: consola.silent,\n level: consola.level,\n fatal: consola.fatal,\n error: consola.error,\n warn: consola.warn,\n log: consola.log,\n info: consola.info,\n success: consola.success,\n ready: consola.ready,\n start: consola.start,\n box: consola.box,\n debug: consola.debug,\n trace: consola.trace,\n verbose: consola.verbose,\n /**\n * Prints a boxed log with structured issue information.\n * This method displays issues (errors or warnings) in a formatted box with:\n * - File paths and line/column positions\n * - Rule violations (if applicable)\n * - Error/warning messages\n * - Color-coded output based on issue type\n *\n * @param title - The title to display in the box header.\n * @param issues - An array of issue entries to display.\n * @param color - The color to use for highlighting (defaults to 'red').\n */\n printBoxedLog(title: string, issues: I_IssueEntry[], color = 'red') {\n if (!issues?.length) {\n consola.box(chalk.green(title));\n return;\n }\n\n issues.forEach(({ file, position, rule, message }) => {\n const positionSuffix = position ? `:${position}` : '';\n const filePath = `${file}${positionSuffix}`;\n consola.log(`${chalk.gray('File:')} ${chalk.blue(filePath)}`);\n\n if (rule) {\n consola.log(` ${chalkKeyword(color)('Rule:')} ${rule}`);\n }\n\n consola.log(` ${chalkKeyword(color)('Message:')} ${message}`);\n });\n\n consola.box(chalkKeyword(color)(`${title} : ${issues.length}`));\n\n consola.log(chalk.gray('─'.repeat(40)));\n },\n};\n\n/**\n * Catches and handles errors with configurable behavior.\n * This function provides a standardized way to handle errors with options for:\n * - Logging control (whether to log the error)\n * - Return value specification (what to return on error)\n * - Custom callback execution (additional error handling)\n *\n * @param errorInput - The error to catch and handle.\n * @param options - Configuration options for error handling behavior.\n * @returns Either the specified return value or a standardized error response object.\n */\nexport function catchError<T = unknown>(errorInput: unknown, options: I_CatchErrorOptions & { returnValue: T }): T;\nexport function catchError<T = unknown>(errorInput: unknown, options?: I_CatchErrorOptions): I_Return<T>;\nexport function catchError<T = unknown>(errorInput: unknown, options?: I_CatchErrorOptions): I_Return<T> | T {\n const { shouldLog = true, returnValue, callback } = options ?? {};\n\n const error = errorInput instanceof Error\n ? errorInput\n : new Error(typeof errorInput === 'string' ? errorInput : 'Unknown error');\n\n if (shouldLog) {\n log.error(error.message);\n }\n\n if (callback && typeof callback === 'function') {\n callback(error);\n }\n\n if (returnValue) {\n return returnValue as T;\n }\n\n return {\n success: false,\n message: error.message,\n code: RESPONSE_STATUS.INTERNAL_SERVER_ERROR.CODE,\n };\n}\n"],"names":["env","getEnv","throwError","message","status","RESPONSE_STATUS","type","responseMessage","GraphQLError","consola","chalkKeyword","color","chalkColor","chalk","log","title","issues","file","position","rule","positionSuffix","filePath","catchError","errorInput","options","shouldLog","returnValue","callback","error"],"mappings":";;;;;AAaA,MAAMA,IAAMC,EAAA;AAcL,SAASC,EAAW;AAAA,EACvB,SAAAC;AAAA,EACA,QAAAC,IAASC,EAAgB;AAAA,EACzB,MAAAC,IAAO;AACX,GAAwB;AACpB,QAAMC,IACAJ,KAAWC,EAAO,WAAW;AAEnC,QAAIE,MAAS,YACH,IAAIE,EAAaD,GAAiB;AAAA,IACpC,YAAY,EAAE,MAAMH,EAAO,KAAA;AAAA,EAAK,CACnC,IAIK,IAAI,MAAMG,CAAe;AAEvC;AAEKP,EAAI,UACLS,EAAQ,QAAQ;AAWpB,SAASC,EAAaC,GAA8B;AAChD,QAAMC,IAAaC,EAAMF,CAA2B;AAEpD,SAAO,OAAOC,KAAe,aAAcA,IAA+BC,EAAM;AACpF;AAOO,MAAMC,IAAa;AAAA,EACtB,QAAQL,EAAQ;AAAA,EAChB,OAAOA,EAAQ;AAAA,EACf,OAAOA,EAAQ;AAAA,EACf,OAAOA,EAAQ;AAAA,EACf,MAAMA,EAAQ;AAAA,EACd,KAAKA,EAAQ;AAAA,EACb,MAAMA,EAAQ;AAAA,EACd,SAASA,EAAQ;AAAA,EACjB,OAAOA,EAAQ;AAAA,EACf,OAAOA,EAAQ;AAAA,EACf,KAAKA,EAAQ;AAAA,EACb,OAAOA,EAAQ;AAAA,EACf,OAAOA,EAAQ;AAAA,EACf,SAASA,EAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAajB,cAAcM,GAAeC,GAAwBL,IAAQ,OAAO;AAChE,QAAI,CAACK,GAAQ,QAAQ;AACjB,MAAAP,EAAQ,IAAII,EAAM,MAAME,CAAK,CAAC;AAC9B;AAAA,IACJ;AAEA,IAAAC,EAAO,QAAQ,CAAC,EAAE,MAAAC,GAAM,UAAAC,GAAU,MAAAC,GAAM,SAAAhB,QAAc;AAClD,YAAMiB,IAAiBF,IAAW,IAAIA,CAAQ,KAAK,IAC7CG,IAAW,GAAGJ,CAAI,GAAGG,CAAc;AACzC,MAAAX,EAAQ,IAAI,GAAGI,EAAM,KAAK,OAAO,CAAC,IAAIA,EAAM,KAAKQ,CAAQ,CAAC,EAAE,GAExDF,KACAV,EAAQ,IAAI,MAAMC,EAAaC,CAAK,EAAE,OAAO,CAAC,IAAIQ,CAAI,EAAE,GAG5DV,EAAQ,IAAI,MAAMC,EAAaC,CAAK,EAAE,UAAU,CAAC,IAAIR,CAAO,EAAE;AAAA,IAClE,CAAC,GAEDM,EAAQ,IAAIC,EAAaC,CAAK,EAAE,GAAGI,CAAK,MAAMC,EAAO,MAAM,EAAE,CAAC,GAE9DP,EAAQ,IAAII,EAAM,KAAK,IAAI,OAAO,EAAE,CAAC,CAAC;AAAA,EAC1C;AACJ;AAeO,SAASS,EAAwBC,GAAqBC,GAAgD;AACzG,QAAM,EAAE,WAAAC,IAAY,IAAM,aAAAC,GAAa,UAAAC,EAAA,IAAaH,KAAW,CAAA,GAEzDI,IAAQL,aAAsB,QAC9BA,IACA,IAAI,MAAM,OAAOA,KAAe,WAAWA,IAAa,eAAe;AAU7E,SARIE,KACAX,EAAI,MAAMc,EAAM,OAAO,GAGvBD,KAAY,OAAOA,KAAa,cAChCA,EAASC,CAAK,GAGdF,KAIG;AAAA,IACH,SAAS;AAAA,IACT,SAASE,EAAM;AAAA,IACf,MAAMvB,EAAgB,sBAAsB;AAAA,EAAA;AAEpD;"}
|
package/dist/node/mongo/index.js
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import { MONGO_MIGRATE_OPTIONS as r, MONGO_SLUG_MAX_ATTEMPTS as t } from "./mongo.constant.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { filterDynamicVirtualsFromPopulate as m, isMongooseDoc as p, isObject as n, populateDynamicVirtuals as a, remapDynamicPopulate as M } from "./mongo.dynamic-populate.js";
|
|
3
|
+
import { applyNestedPopulate as _ } from "./mongo.populate.js";
|
|
4
|
+
import { C_Collection as f, C_Db as u, C_Document as s, C_Model as x } from "./mongo.type.js";
|
|
5
|
+
import { convertEnumToModelName as O, mongo as D } from "./mongo.util.js";
|
|
6
|
+
import { MongoController as N } from "./mongo.controller.native.js";
|
|
7
|
+
import { MongooseController as g } from "./mongo.controller.mongoose.js";
|
|
5
8
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
f as C_Collection,
|
|
10
|
+
u as C_Db,
|
|
11
|
+
s as C_Document,
|
|
12
|
+
x as C_Model,
|
|
10
13
|
r as MONGO_MIGRATE_OPTIONS,
|
|
11
14
|
t as MONGO_SLUG_MAX_ATTEMPTS,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
N as MongoController,
|
|
16
|
+
g as MongooseController,
|
|
17
|
+
_ as applyNestedPopulate,
|
|
18
|
+
O as convertEnumToModelName,
|
|
19
|
+
m as filterDynamicVirtualsFromPopulate,
|
|
20
|
+
p as isMongooseDoc,
|
|
21
|
+
n as isObject,
|
|
22
|
+
D as mongo,
|
|
23
|
+
a as populateDynamicVirtuals,
|
|
24
|
+
M as remapDynamicPopulate
|
|
17
25
|
};
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongo.constant.js","sources":["../../../src/node/mongo/mongo.constant.ts"],"sourcesContent":["/**\n * Environment variable key for MongoDB migration options.\n * This constant defines the environment variable name that can be used to configure\n * MongoDB migration settings and options for database schema management.\n */\nexport const MONGO_MIGRATE_OPTIONS = 'MONGO_MIGRATE_OPTIONS';\n\n/**\n * Maximum number of attempts to generate a unique slug.\n * This constant defines the maximum number of attempts to generate a unique slug\n * before giving up and returning a fallback slug.\n */\nexport const MONGO_SLUG_MAX_ATTEMPTS = 100;\n"],"names":["MONGO_MIGRATE_OPTIONS","MONGO_SLUG_MAX_ATTEMPTS"],"mappings":"AAKO,MAAMA,IAAwB,yBAOxBC,IAA0B;"}
|
|
@@ -1,317 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { I_Return } from '../../typescript/index.js';
|
|
3
|
-
import { C_Db, C_Document, I_DeleteOptionsExtended, I_ExtendedModel, I_Input_CheckSlug, I_Input_CreateSlug, I_Input_GenerateSlug, I_PaginateOptionsWithPopulate, I_UpdateOptionsExtended, T_AggregatePaginateResult, T_DeleteResult, T_Filter, T_Input_Populate, T_InsertManyOptions, T_PaginateResult, T_PipelineStage, T_ProjectionType, T_QueryFilter, T_QueryOptions, T_UpdateQuery, T_UpdateResult, T_WithId } from './mongo.type.js';
|
|
1
|
+
export * from './mongo.controller.mongoose.js';
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* Re-exports both MongoDB controller implementations.
|
|
4
|
+
* - MongoController: Native MongoDB driver operations
|
|
5
|
+
* - MongooseController: Mongoose ORM with pagination, aggregation, and slug generation
|
|
8
6
|
*/
|
|
9
|
-
export
|
|
10
|
-
private collection;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new MongoDB controller instance.
|
|
13
|
-
*
|
|
14
|
-
* @param db - The MongoDB database instance.
|
|
15
|
-
* @param collectionName - The name of the collection to operate on.
|
|
16
|
-
*/
|
|
17
|
-
constructor(db: C_Db, collectionName: string);
|
|
18
|
-
/**
|
|
19
|
-
* Creates a single document in the collection.
|
|
20
|
-
* This method adds generic fields (id, isDel, timestamps) to the document before insertion.
|
|
21
|
-
*
|
|
22
|
-
* @param document - The document to create, with or without generic fields.
|
|
23
|
-
* @returns A promise that resolves to a standardized response with the created document.
|
|
24
|
-
*/
|
|
25
|
-
createOne(document: D | Partial<D>): Promise<I_Return<D | Partial<D>>>;
|
|
26
|
-
/**
|
|
27
|
-
* Creates multiple documents in the collection.
|
|
28
|
-
* This method adds generic fields to each document before bulk insertion.
|
|
29
|
-
*
|
|
30
|
-
* @param documents - An array of documents to create.
|
|
31
|
-
* @returns A promise that resolves to a standardized response with the created documents.
|
|
32
|
-
*/
|
|
33
|
-
createMany(documents: (D | Partial<D>)[]): Promise<I_Return<(D | Partial<D>)[]>>;
|
|
34
|
-
/**
|
|
35
|
-
* Finds a single document by filter criteria.
|
|
36
|
-
*
|
|
37
|
-
* @param filter - The filter criteria to find the document.
|
|
38
|
-
* @returns A promise that resolves to a standardized response with the found document.
|
|
39
|
-
*/
|
|
40
|
-
findOne(filter: T_Filter<D>): Promise<I_Return<T_WithId<D>>>;
|
|
41
|
-
/**
|
|
42
|
-
* Finds all documents matching the filter criteria.
|
|
43
|
-
*
|
|
44
|
-
* @param filter - The filter criteria to find documents (defaults to empty object for all documents).
|
|
45
|
-
* @returns A promise that resolves to a standardized response with the found documents.
|
|
46
|
-
*/
|
|
47
|
-
findAll(filter?: T_Filter<D>): Promise<I_Return<T_WithId<D>[]>>;
|
|
48
|
-
/**
|
|
49
|
-
* Counts documents matching the filter criteria.
|
|
50
|
-
*
|
|
51
|
-
* @param filter - The filter criteria to count documents (defaults to empty object for all documents).
|
|
52
|
-
* @returns A promise that resolves to a standardized response with the document count.
|
|
53
|
-
*/
|
|
54
|
-
count(filter?: T_Filter<D>): Promise<I_Return<number>>;
|
|
55
|
-
/**
|
|
56
|
-
* Updates a single document matching the filter criteria.
|
|
57
|
-
*
|
|
58
|
-
* @param filter - The filter criteria to find the document to update.
|
|
59
|
-
* @param update - The update data to apply to the document.
|
|
60
|
-
* @returns A promise that resolves to a standardized response with the update result.
|
|
61
|
-
*/
|
|
62
|
-
updateOne(filter: T_Filter<D>, update: Partial<D>): Promise<I_Return<T_UpdateResult>>;
|
|
63
|
-
/**
|
|
64
|
-
* Updates multiple documents matching the filter criteria.
|
|
65
|
-
*
|
|
66
|
-
* @param filter - The filter criteria to find documents to update.
|
|
67
|
-
* @param update - The update data to apply to the documents.
|
|
68
|
-
* @returns A promise that resolves to a standardized response with the update result.
|
|
69
|
-
*/
|
|
70
|
-
updateMany(filter: T_Filter<D>, update: Partial<D>): Promise<I_Return<T_UpdateResult>>;
|
|
71
|
-
/**
|
|
72
|
-
* Deletes a single document matching the filter criteria.
|
|
73
|
-
*
|
|
74
|
-
* @param filter - The filter criteria to find the document to delete.
|
|
75
|
-
* @returns A promise that resolves to a standardized response with the delete result.
|
|
76
|
-
*/
|
|
77
|
-
deleteOne(filter: T_Filter<D>): Promise<I_Return<T_DeleteResult>>;
|
|
78
|
-
/**
|
|
79
|
-
* Deletes multiple documents matching the filter criteria.
|
|
80
|
-
*
|
|
81
|
-
* @param filter - The filter criteria to find documents to delete.
|
|
82
|
-
* @returns A promise that resolves to a standardized response with the delete result.
|
|
83
|
-
*/
|
|
84
|
-
deleteMany(filter: T_Filter<D>): Promise<I_Return<T_DeleteResult>>;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Mongoose controller for database operations with advanced features.
|
|
88
|
-
* This class provides a comprehensive interface for Mongoose operations including
|
|
89
|
-
* pagination, aggregation, slug generation, and short ID creation.
|
|
90
|
-
*/
|
|
91
|
-
export declare class MongooseController<T extends Partial<C_Document>> {
|
|
92
|
-
private model;
|
|
93
|
-
/**
|
|
94
|
-
* Creates a new Mongoose controller instance.
|
|
95
|
-
*
|
|
96
|
-
* @param model - The Mongoose model to operate on.
|
|
97
|
-
*/
|
|
98
|
-
constructor(model: I_ExtendedModel<T>);
|
|
99
|
-
/**
|
|
100
|
-
* Gets the model name for logging and error messages.
|
|
101
|
-
*
|
|
102
|
-
* @returns The name of the model.
|
|
103
|
-
*/
|
|
104
|
-
private getModelName;
|
|
105
|
-
/**
|
|
106
|
-
* Gets the dynamic virtuals configuration from the model instance.
|
|
107
|
-
*
|
|
108
|
-
* @returns Array of dynamic virtual configurations or undefined if none exist.
|
|
109
|
-
*/
|
|
110
|
-
private getDynamicVirtuals;
|
|
111
|
-
/**
|
|
112
|
-
* Populates dynamic virtuals for a single document.
|
|
113
|
-
*
|
|
114
|
-
* @param result - The document to populate dynamic virtuals for.
|
|
115
|
-
* @param populate - The populate options to determine which virtuals to populate.
|
|
116
|
-
* @returns The document with dynamic virtuals populated.
|
|
117
|
-
*/
|
|
118
|
-
private populateDynamicVirtualsForDocument;
|
|
119
|
-
/**
|
|
120
|
-
* Populates dynamic virtuals for an array of documents.
|
|
121
|
-
*
|
|
122
|
-
* @param results - The documents to populate dynamic virtuals for.
|
|
123
|
-
* @param populate - The populate options to determine which virtuals to populate.
|
|
124
|
-
* @returns The documents with dynamic virtuals populated.
|
|
125
|
-
*/
|
|
126
|
-
private populateDynamicVirtualsForDocuments;
|
|
127
|
-
/**
|
|
128
|
-
* Finds a single document with optional population and projection.
|
|
129
|
-
* Automatically handles dynamic virtual population if configured.
|
|
130
|
-
*
|
|
131
|
-
* @param filter - The filter criteria to find the document.
|
|
132
|
-
* @param projection - The fields to include/exclude in the result.
|
|
133
|
-
* @param options - Query options for the operation.
|
|
134
|
-
* @param populate - Population configuration for related documents.
|
|
135
|
-
* @returns A promise that resolves to a standardized response with the found document.
|
|
136
|
-
*/
|
|
137
|
-
findOne(filter?: T_QueryFilter<T>, projection?: T_ProjectionType<T>, options?: T_QueryOptions<T>, populate?: T_Input_Populate): Promise<I_Return<T>>;
|
|
138
|
-
/**
|
|
139
|
-
* Finds all documents with optional population and projection.
|
|
140
|
-
* Automatically handles dynamic virtual population if configured.
|
|
141
|
-
*
|
|
142
|
-
* @param filter - The filter criteria to find documents.
|
|
143
|
-
* @param projection - The fields to include/exclude in the result.
|
|
144
|
-
* @param options - Query options for the operation.
|
|
145
|
-
* @param populate - Population configuration for related documents.
|
|
146
|
-
* @returns A promise that resolves to a standardized response with the found documents.
|
|
147
|
-
*/
|
|
148
|
-
findAll(filter?: T_QueryFilter<T>, projection?: T_ProjectionType<T>, options?: T_QueryOptions<T>, populate?: T_Input_Populate): Promise<I_Return<T[]>>;
|
|
149
|
-
/**
|
|
150
|
-
* Finds documents with pagination support.
|
|
151
|
-
* Automatically handles dynamic virtual population if configured.
|
|
152
|
-
*
|
|
153
|
-
* @param filter - The filter criteria to find documents.
|
|
154
|
-
* @param options - Pagination options including page, limit, and population.
|
|
155
|
-
* @returns A promise that resolves to a standardized response with paginated results.
|
|
156
|
-
*/
|
|
157
|
-
findPaging(filter?: T_QueryFilter<T>, options?: I_PaginateOptionsWithPopulate): Promise<I_Return<T_PaginateResult<T>>>;
|
|
158
|
-
/**
|
|
159
|
-
* Performs aggregation with pagination support.
|
|
160
|
-
*
|
|
161
|
-
* @param pipeline - The aggregation pipeline stages.
|
|
162
|
-
* @param options - Pagination options for the aggregation result.
|
|
163
|
-
* @returns A promise that resolves to a standardized response with paginated aggregation results.
|
|
164
|
-
*/
|
|
165
|
-
findPagingAggregate(pipeline: T_PipelineStage[], options?: I_PaginateOptionsWithPopulate): Promise<I_Return<T_AggregatePaginateResult<T>>>;
|
|
166
|
-
/**
|
|
167
|
-
* Counts documents matching the filter criteria.
|
|
168
|
-
*
|
|
169
|
-
* @param filter - The filter criteria to count documents.
|
|
170
|
-
* @returns A promise that resolves to a standardized response with the document count.
|
|
171
|
-
*/
|
|
172
|
-
count(filter?: T_QueryFilter<T>): Promise<I_Return<number>>;
|
|
173
|
-
/**
|
|
174
|
-
* Creates a single document.
|
|
175
|
-
*
|
|
176
|
-
* @param doc - The document to create.
|
|
177
|
-
* @returns A promise that resolves to a standardized response with the created document.
|
|
178
|
-
*/
|
|
179
|
-
createOne(doc: T | Partial<T>): Promise<I_Return<T>>;
|
|
180
|
-
/**
|
|
181
|
-
* Creates multiple documents with bulk insertion.
|
|
182
|
-
*
|
|
183
|
-
* @param docs - An array of documents to create.
|
|
184
|
-
* @param options - Options for the bulk insertion operation.
|
|
185
|
-
* @returns A promise that resolves to a standardized response with the created documents.
|
|
186
|
-
*/
|
|
187
|
-
createMany(docs: (T | Partial<T>)[], options?: T_InsertManyOptions): Promise<I_Return<T[]>>;
|
|
188
|
-
/**
|
|
189
|
-
* Updates a single document and returns the updated version.
|
|
190
|
-
*
|
|
191
|
-
* @param filter - The filter criteria to find the document to update.
|
|
192
|
-
* @param update - The update data to apply.
|
|
193
|
-
* @param options - Options for the update operation.
|
|
194
|
-
* @returns A promise that resolves to a standardized response with the updated document.
|
|
195
|
-
*/
|
|
196
|
-
updateOne(filter?: T_QueryFilter<T>, update?: T_UpdateQuery<T>, options?: I_UpdateOptionsExtended): Promise<I_Return<T>>;
|
|
197
|
-
/**
|
|
198
|
-
* Updates multiple documents matching the filter criteria.
|
|
199
|
-
*
|
|
200
|
-
* @param filter - The filter criteria to find documents to update.
|
|
201
|
-
* @param update - The update data to apply.
|
|
202
|
-
* @param options - Options for the update operation.
|
|
203
|
-
* @returns A promise that resolves to a standardized response with the update result.
|
|
204
|
-
*/
|
|
205
|
-
updateMany(filter?: T_QueryFilter<T>, update?: T_UpdateQuery<T>, options?: I_UpdateOptionsExtended): Promise<I_Return<T_UpdateResult>>;
|
|
206
|
-
/**
|
|
207
|
-
* Deletes a single document and returns the deleted version.
|
|
208
|
-
*
|
|
209
|
-
* @param filter - The filter criteria to find the document to delete.
|
|
210
|
-
* @param options - Options for the delete operation.
|
|
211
|
-
* @returns A promise that resolves to a standardized response with the deleted document.
|
|
212
|
-
*/
|
|
213
|
-
deleteOne(filter?: T_QueryFilter<T>, options?: I_DeleteOptionsExtended): Promise<I_Return<T>>;
|
|
214
|
-
/**
|
|
215
|
-
* Deletes multiple documents matching the filter criteria.
|
|
216
|
-
*
|
|
217
|
-
* @param filter - The filter criteria to find documents to delete.
|
|
218
|
-
* @param options - Options for the delete operation.
|
|
219
|
-
* @returns A promise that resolves to a standardized response with the delete result.
|
|
220
|
-
*/
|
|
221
|
-
deleteMany(filter?: T_QueryFilter<T>, options?: I_DeleteOptionsExtended): Promise<I_Return<T_DeleteResult>>;
|
|
222
|
-
/**
|
|
223
|
-
* Creates a unique short ID based on a given ID.
|
|
224
|
-
* This method generates multiple short IDs with increasing lengths and finds the first available one.
|
|
225
|
-
*
|
|
226
|
-
* @param id - The base ID to generate short IDs from.
|
|
227
|
-
* @param length - The initial length for short ID generation (default: 4).
|
|
228
|
-
* @returns A promise that resolves to a standardized response with the unique short ID.
|
|
229
|
-
*/
|
|
230
|
-
createShortId(id: string, length?: number): Promise<I_Return<string>>;
|
|
231
|
-
/**
|
|
232
|
-
* Creates a query for slug existence checking.
|
|
233
|
-
* This method generates a query that checks for slug existence in both current and historical slug fields.
|
|
234
|
-
*
|
|
235
|
-
* @param options - Configuration for slug query generation including slug, field, and filter.
|
|
236
|
-
* @param options.slug - The slug string to check for existence.
|
|
237
|
-
* @param options.field - The field name for object-based slug checking.
|
|
238
|
-
* @param options.isObject - Whether the slug is stored as an object with nested fields.
|
|
239
|
-
* @param options.haveHistory - Whether to check historical slug fields for existence.
|
|
240
|
-
* @param options.filter - Additional filter conditions to apply to the query.
|
|
241
|
-
* @returns A MongoDB query object for checking slug existence.
|
|
242
|
-
*/
|
|
243
|
-
createSlugQuery({ slug, field, isObject, haveHistory, filter }: I_Input_GenerateSlug<T>): (mongooseRaw.QueryFilter<T> & {
|
|
244
|
-
$or: ({
|
|
245
|
-
[x: string]: string;
|
|
246
|
-
slugHistory?: undefined;
|
|
247
|
-
} | {
|
|
248
|
-
slugHistory: {
|
|
249
|
-
$elemMatch: {
|
|
250
|
-
[x: string]: string;
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
})[];
|
|
254
|
-
}) | (mongooseRaw.QueryFilter<T> & {
|
|
255
|
-
$or: ({
|
|
256
|
-
slug: string;
|
|
257
|
-
slugHistory?: undefined;
|
|
258
|
-
} | {
|
|
259
|
-
slugHistory: string;
|
|
260
|
-
slug?: undefined;
|
|
261
|
-
})[];
|
|
262
|
-
});
|
|
263
|
-
/**
|
|
264
|
-
* Creates a unique slug based on a given string.
|
|
265
|
-
* This method generates multiple slug variations and finds the first available one.
|
|
266
|
-
*
|
|
267
|
-
* @param options - Configuration for slug generation including slug, field, and filter.
|
|
268
|
-
* @param options.slug - The base slug string to make unique.
|
|
269
|
-
* @param options.field - The field name for object-based slug checking.
|
|
270
|
-
* @param options.isObject - Whether the slug is stored as an object with nested fields.
|
|
271
|
-
* @param options.haveHistory - Whether to check historical slug fields for uniqueness.
|
|
272
|
-
* @param options.filter - Additional filter conditions to apply when checking slug existence.
|
|
273
|
-
* @returns A promise that resolves to a unique slug string.
|
|
274
|
-
*/
|
|
275
|
-
createUniqueSlug({ slug, field, isObject, haveHistory, filter }: I_Input_GenerateSlug<T>): Promise<string>;
|
|
276
|
-
/**
|
|
277
|
-
* Creates a slug for a document field.
|
|
278
|
-
* This method handles both simple string fields and object fields with nested slug generation.
|
|
279
|
-
*
|
|
280
|
-
* @param options - Configuration for slug creation including field, source document, and filter.
|
|
281
|
-
* @param options.field - The field name to create a slug for.
|
|
282
|
-
* @param options.from - The source document containing the field value.
|
|
283
|
-
* @param options.haveHistory - Whether to check historical slug fields for uniqueness.
|
|
284
|
-
* @param options.filter - Additional filter conditions to apply when checking slug existence.
|
|
285
|
-
* @returns A promise that resolves to a standardized response with the created slug(s).
|
|
286
|
-
*/
|
|
287
|
-
createSlug<R = string>({ field, from, filter, haveHistory }: I_Input_CreateSlug<T>): Promise<I_Return<R>>;
|
|
288
|
-
/**
|
|
289
|
-
* Checks if a slug already exists in the collection.
|
|
290
|
-
* This method verifies slug existence in both current and historical slug fields.
|
|
291
|
-
*
|
|
292
|
-
* @param options - Configuration for slug checking including slug, field, source document, and filter.
|
|
293
|
-
* @param options.slug - The slug string to check for existence.
|
|
294
|
-
* @param options.field - The field name for object-based slug checking.
|
|
295
|
-
* @param options.from - The source document containing the field value.
|
|
296
|
-
* @param options.haveHistory - Whether to check historical slug fields for existence.
|
|
297
|
-
* @param options.filter - Additional filter conditions to apply to the query.
|
|
298
|
-
* @returns A promise that resolves to a standardized response indicating whether the slug exists.
|
|
299
|
-
*/
|
|
300
|
-
checkSlug({ slug, field, from, filter, haveHistory }: I_Input_CheckSlug<T>): Promise<I_Return<boolean>>;
|
|
301
|
-
/**
|
|
302
|
-
* Performs aggregation operations on the collection.
|
|
303
|
-
*
|
|
304
|
-
* @param pipeline - The aggregation pipeline stages to execute.
|
|
305
|
-
* @returns A promise that resolves to a standardized response with the aggregation results.
|
|
306
|
-
*/
|
|
307
|
-
aggregate(pipeline: T_PipelineStage[]): Promise<I_Return<T[]>>;
|
|
308
|
-
/**
|
|
309
|
-
* Retrieves distinct values for the specified key from the collection.
|
|
310
|
-
*
|
|
311
|
-
* @param key - The field for which to return distinct values.
|
|
312
|
-
* @param filter - The filter query to apply (optional).
|
|
313
|
-
* @param options - Additional options for the distinct operation (optional).
|
|
314
|
-
* @returns A promise that resolves to a standardized response with the array of distinct values.
|
|
315
|
-
*/
|
|
316
|
-
distinct(key: string, filter?: T_QueryFilter<T>, options?: T_QueryOptions<T>): Promise<I_Return<unknown[]>>;
|
|
317
|
-
}
|
|
7
|
+
export * from './mongo.controller.native.js';
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { I_Return } from '../../typescript/index.js';
|
|
2
|
+
import { C_Document, I_DeleteOptionsExtended, I_ExtendedModel, I_Input_CheckSlug, I_Input_CreateSlug, I_Input_GenerateSlug, I_PaginateOptionsWithPopulate, I_UpdateOptionsExtended, T_AggregatePaginateResult, T_DeleteResult, T_Input_Populate, T_InsertManyOptions, T_PaginateResult, T_PipelineStage, T_ProjectionType, T_QueryFilter, T_QueryOptions, T_UpdateQuery, T_UpdateResult } from './mongo.type.js';
|
|
3
|
+
/**
|
|
4
|
+
* Mongoose controller for database operations with advanced features.
|
|
5
|
+
* This class provides a comprehensive interface for Mongoose operations including
|
|
6
|
+
* pagination, aggregation, slug generation, and short ID creation.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MongooseController<T extends Partial<C_Document>> {
|
|
9
|
+
private model;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new Mongoose controller instance.
|
|
12
|
+
*
|
|
13
|
+
* @param model - The Mongoose model to operate on.
|
|
14
|
+
*/
|
|
15
|
+
constructor(model: I_ExtendedModel<T>);
|
|
16
|
+
/**
|
|
17
|
+
* Gets the model name for logging and error messages.
|
|
18
|
+
*
|
|
19
|
+
* @returns The name of the model.
|
|
20
|
+
*/
|
|
21
|
+
private getModelName;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the dynamic virtuals configuration from the model instance.
|
|
24
|
+
*
|
|
25
|
+
* @returns Array of dynamic virtual configurations or undefined if none exist.
|
|
26
|
+
*/
|
|
27
|
+
private getDynamicVirtuals;
|
|
28
|
+
/**
|
|
29
|
+
* Populates dynamic virtuals for a single document.
|
|
30
|
+
*
|
|
31
|
+
* @param result - The document to populate dynamic virtuals for.
|
|
32
|
+
* @param populate - The populate options to determine which virtuals to populate.
|
|
33
|
+
* @returns The document with dynamic virtuals populated.
|
|
34
|
+
*/
|
|
35
|
+
private populateDynamicVirtualsForDocument;
|
|
36
|
+
/**
|
|
37
|
+
* Populates dynamic virtuals for an array of documents.
|
|
38
|
+
*
|
|
39
|
+
* @param results - The documents to populate dynamic virtuals for.
|
|
40
|
+
* @param populate - The populate options to determine which virtuals to populate.
|
|
41
|
+
* @returns The documents with dynamic virtuals populated.
|
|
42
|
+
*/
|
|
43
|
+
private populateDynamicVirtualsForDocuments;
|
|
44
|
+
/**
|
|
45
|
+
* Finds a single document with optional population and projection.
|
|
46
|
+
* Automatically handles dynamic virtual population if configured.
|
|
47
|
+
*
|
|
48
|
+
* @param filter - The filter criteria to find the document.
|
|
49
|
+
* @param projection - The fields to include/exclude in the result.
|
|
50
|
+
* @param options - Query options for the operation.
|
|
51
|
+
* @param populate - Population configuration for related documents.
|
|
52
|
+
* @returns A promise that resolves to a standardized response with the found document.
|
|
53
|
+
*/
|
|
54
|
+
findOne(filter?: T_QueryFilter<T>, projection?: T_ProjectionType<T>, options?: T_QueryOptions<T>, populate?: T_Input_Populate): Promise<I_Return<T>>;
|
|
55
|
+
/**
|
|
56
|
+
* Finds all documents with optional population and projection.
|
|
57
|
+
* Automatically handles dynamic virtual population if configured.
|
|
58
|
+
*
|
|
59
|
+
* @param filter - The filter criteria to find documents.
|
|
60
|
+
* @param projection - The fields to include/exclude in the result.
|
|
61
|
+
* @param options - Query options for the operation.
|
|
62
|
+
* @param populate - Population configuration for related documents.
|
|
63
|
+
* @returns A promise that resolves to a standardized response with the found documents.
|
|
64
|
+
*/
|
|
65
|
+
findAll(filter?: T_QueryFilter<T>, projection?: T_ProjectionType<T>, options?: T_QueryOptions<T>, populate?: T_Input_Populate): Promise<I_Return<T[]>>;
|
|
66
|
+
/**
|
|
67
|
+
* Finds documents with pagination support.
|
|
68
|
+
* Automatically handles dynamic virtual population if configured.
|
|
69
|
+
*
|
|
70
|
+
* @param filter - The filter criteria to find documents.
|
|
71
|
+
* @param options - Pagination options including page, limit, and population.
|
|
72
|
+
* @returns A promise that resolves to a standardized response with paginated results.
|
|
73
|
+
*/
|
|
74
|
+
findPaging(filter?: T_QueryFilter<T>, options?: I_PaginateOptionsWithPopulate): Promise<I_Return<T_PaginateResult<T>>>;
|
|
75
|
+
/**
|
|
76
|
+
* Performs aggregation with pagination support.
|
|
77
|
+
*
|
|
78
|
+
* @param pipeline - The aggregation pipeline stages.
|
|
79
|
+
* @param options - Pagination options for the aggregation result.
|
|
80
|
+
* @returns A promise that resolves to a standardized response with paginated aggregation results.
|
|
81
|
+
*/
|
|
82
|
+
findPagingAggregate(pipeline: T_PipelineStage[], options?: I_PaginateOptionsWithPopulate): Promise<I_Return<T_AggregatePaginateResult<T>>>;
|
|
83
|
+
/**
|
|
84
|
+
* Counts documents matching the filter criteria.
|
|
85
|
+
*
|
|
86
|
+
* @param filter - The filter criteria to count documents.
|
|
87
|
+
* @returns A promise that resolves to a standardized response with the document count.
|
|
88
|
+
*/
|
|
89
|
+
count(filter?: T_QueryFilter<T>): Promise<I_Return<number>>;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a single document.
|
|
92
|
+
*
|
|
93
|
+
* @param doc - The document to create.
|
|
94
|
+
* @returns A promise that resolves to a standardized response with the created document.
|
|
95
|
+
*/
|
|
96
|
+
createOne(doc: T | Partial<T>): Promise<I_Return<T>>;
|
|
97
|
+
/**
|
|
98
|
+
* Creates multiple documents with bulk insertion.
|
|
99
|
+
*
|
|
100
|
+
* @param docs - An array of documents to create.
|
|
101
|
+
* @param options - Options for the bulk insertion operation.
|
|
102
|
+
* @returns A promise that resolves to a standardized response with the created documents.
|
|
103
|
+
*/
|
|
104
|
+
createMany(docs: (T | Partial<T>)[], options?: T_InsertManyOptions): Promise<I_Return<T[]>>;
|
|
105
|
+
/**
|
|
106
|
+
* Updates a single document and returns the updated version.
|
|
107
|
+
*
|
|
108
|
+
* @param filter - The filter criteria to find the document to update.
|
|
109
|
+
* @param update - The update data to apply.
|
|
110
|
+
* @param options - Options for the update operation.
|
|
111
|
+
* @returns A promise that resolves to a standardized response with the updated document.
|
|
112
|
+
*/
|
|
113
|
+
updateOne(filter?: T_QueryFilter<T>, update?: T_UpdateQuery<T>, options?: I_UpdateOptionsExtended): Promise<I_Return<T>>;
|
|
114
|
+
/**
|
|
115
|
+
* Updates multiple documents matching the filter criteria.
|
|
116
|
+
*
|
|
117
|
+
* @param filter - The filter criteria to find documents to update.
|
|
118
|
+
* @param update - The update data to apply.
|
|
119
|
+
* @param options - Options for the update operation.
|
|
120
|
+
* @returns A promise that resolves to a standardized response with the update result.
|
|
121
|
+
*/
|
|
122
|
+
updateMany(filter?: T_QueryFilter<T>, update?: T_UpdateQuery<T>, options?: I_UpdateOptionsExtended): Promise<I_Return<T_UpdateResult>>;
|
|
123
|
+
/**
|
|
124
|
+
* Deletes a single document and returns the deleted version.
|
|
125
|
+
*
|
|
126
|
+
* @param filter - The filter criteria to find the document to delete.
|
|
127
|
+
* @param options - Options for the delete operation.
|
|
128
|
+
* @returns A promise that resolves to a standardized response with the deleted document.
|
|
129
|
+
*/
|
|
130
|
+
deleteOne(filter?: T_QueryFilter<T>, options?: I_DeleteOptionsExtended): Promise<I_Return<T>>;
|
|
131
|
+
/**
|
|
132
|
+
* Deletes multiple documents matching the filter criteria.
|
|
133
|
+
*
|
|
134
|
+
* @param filter - The filter criteria to find documents to delete.
|
|
135
|
+
* @param options - Options for the delete operation.
|
|
136
|
+
* @returns A promise that resolves to a standardized response with the delete result.
|
|
137
|
+
*/
|
|
138
|
+
deleteMany(filter?: T_QueryFilter<T>, options?: I_DeleteOptionsExtended): Promise<I_Return<T_DeleteResult>>;
|
|
139
|
+
/**
|
|
140
|
+
* Creates a unique short ID based on a given ID.
|
|
141
|
+
* This method generates multiple short IDs with increasing lengths and finds the first available one.
|
|
142
|
+
*
|
|
143
|
+
* @param id - The base ID to generate short IDs from.
|
|
144
|
+
* @param length - The initial length for short ID generation (default: 4).
|
|
145
|
+
* @returns A promise that resolves to a standardized response with the unique short ID.
|
|
146
|
+
*/
|
|
147
|
+
createShortId(id: string, length?: number): Promise<I_Return<string>>;
|
|
148
|
+
/**
|
|
149
|
+
* Creates a query for slug existence checking.
|
|
150
|
+
* This method generates a query that checks for slug existence in both current and historical slug fields.
|
|
151
|
+
*
|
|
152
|
+
* @param options - Configuration for slug query generation including slug, field, and filter.
|
|
153
|
+
* @param options.slug - The slug string to check for existence.
|
|
154
|
+
* @param options.field - The field name for object-based slug checking.
|
|
155
|
+
* @param options.isObject - Whether the slug is stored as an object with nested fields.
|
|
156
|
+
* @param options.haveHistory - Whether to check historical slug fields for existence.
|
|
157
|
+
* @param options.filter - Additional filter conditions to apply to the query.
|
|
158
|
+
* @returns A MongoDB query object for checking slug existence.
|
|
159
|
+
*/
|
|
160
|
+
createSlugQuery({ slug, field, isObject, haveHistory, filter }: I_Input_GenerateSlug<T>): (import('mongoose').QueryFilter<T> & {
|
|
161
|
+
$or: ({
|
|
162
|
+
[x: string]: string;
|
|
163
|
+
slugHistory?: undefined;
|
|
164
|
+
} | {
|
|
165
|
+
slugHistory: {
|
|
166
|
+
$elemMatch: {
|
|
167
|
+
[x: string]: string;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
})[];
|
|
171
|
+
}) | (import('mongoose').QueryFilter<T> & {
|
|
172
|
+
$or: ({
|
|
173
|
+
slug: string;
|
|
174
|
+
slugHistory?: undefined;
|
|
175
|
+
} | {
|
|
176
|
+
slugHistory: string;
|
|
177
|
+
slug?: undefined;
|
|
178
|
+
})[];
|
|
179
|
+
});
|
|
180
|
+
/**
|
|
181
|
+
* Creates a unique slug based on a given string.
|
|
182
|
+
* This method generates multiple slug variations and finds the first available one.
|
|
183
|
+
*
|
|
184
|
+
* @param options - Configuration for slug generation including slug, field, and filter.
|
|
185
|
+
* @param options.slug - The base slug string to make unique.
|
|
186
|
+
* @param options.field - The field name for object-based slug checking.
|
|
187
|
+
* @param options.isObject - Whether the slug is stored as an object with nested fields.
|
|
188
|
+
* @param options.haveHistory - Whether to check historical slug fields for uniqueness.
|
|
189
|
+
* @param options.filter - Additional filter conditions to apply when checking slug existence.
|
|
190
|
+
* @returns A promise that resolves to a unique slug string.
|
|
191
|
+
*/
|
|
192
|
+
createUniqueSlug({ slug, field, isObject, haveHistory, filter }: I_Input_GenerateSlug<T>): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* Creates a slug for a document field.
|
|
195
|
+
* This method handles both simple string fields and object fields with nested slug generation.
|
|
196
|
+
*
|
|
197
|
+
* @param options - Configuration for slug creation including field, source document, and filter.
|
|
198
|
+
* @param options.field - The field name to create a slug for.
|
|
199
|
+
* @param options.from - The source document containing the field value.
|
|
200
|
+
* @param options.haveHistory - Whether to check historical slug fields for uniqueness.
|
|
201
|
+
* @param options.filter - Additional filter conditions to apply when checking slug existence.
|
|
202
|
+
* @returns A promise that resolves to a standardized response with the created slug(s).
|
|
203
|
+
*/
|
|
204
|
+
createSlug<R = string>({ field, from, filter, haveHistory }: I_Input_CreateSlug<T>): Promise<I_Return<R>>;
|
|
205
|
+
/**
|
|
206
|
+
* Checks if a slug already exists in the collection.
|
|
207
|
+
* This method verifies slug existence in both current and historical slug fields.
|
|
208
|
+
*
|
|
209
|
+
* @param options - Configuration for slug checking including slug, field, source document, and filter.
|
|
210
|
+
* @param options.slug - The slug string to check for existence.
|
|
211
|
+
* @param options.field - The field name for object-based slug checking.
|
|
212
|
+
* @param options.from - The source document containing the field value.
|
|
213
|
+
* @param options.haveHistory - Whether to check historical slug fields for existence.
|
|
214
|
+
* @param options.filter - Additional filter conditions to apply to the query.
|
|
215
|
+
* @returns A promise that resolves to a standardized response indicating whether the slug exists.
|
|
216
|
+
*/
|
|
217
|
+
checkSlug({ slug, field, from, filter, haveHistory }: I_Input_CheckSlug<T>): Promise<I_Return<boolean>>;
|
|
218
|
+
/**
|
|
219
|
+
* Performs aggregation operations on the collection.
|
|
220
|
+
*
|
|
221
|
+
* @param pipeline - The aggregation pipeline stages to execute.
|
|
222
|
+
* @returns A promise that resolves to a standardized response with the aggregation results.
|
|
223
|
+
*/
|
|
224
|
+
aggregate(pipeline: T_PipelineStage[]): Promise<I_Return<T[]>>;
|
|
225
|
+
/**
|
|
226
|
+
* Retrieves distinct values for the specified key from the collection.
|
|
227
|
+
*
|
|
228
|
+
* @param key - The field for which to return distinct values.
|
|
229
|
+
* @param filter - The filter query to apply (optional).
|
|
230
|
+
* @param options - Additional options for the distinct operation (optional).
|
|
231
|
+
* @returns A promise that resolves to a standardized response with the array of distinct values.
|
|
232
|
+
*/
|
|
233
|
+
distinct(key: string, filter?: T_QueryFilter<T>, options?: T_QueryOptions<T>): Promise<I_Return<unknown[]>>;
|
|
234
|
+
}
|