@koalarx/nest 3.1.49 → 4.0.1
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/README.md +106 -444
- package/cli/commands/add/index.js +97 -0
- package/cli/commands/help.js +44 -0
- package/cli/commands/new/configure-test-runner.js +13 -0
- package/cli/commands/new/create-ddd-structure.js +52 -0
- package/cli/commands/new/create-empty-nest-project.js +58 -0
- package/cli/commands/new/fix-lint-config.js +24 -0
- package/cli/commands/new/index.js +202 -0
- package/cli/commands/version.js +5 -0
- package/cli/constants/auth-strategy-artifacts.js +56 -0
- package/cli/constants/auth-strategy-checklist.js +314 -0
- package/cli/constants/cli-commands.js +24 -0
- package/cli/constants/cli-project-checklist.js +289 -0
- package/cli/constants/core-packages.js +34 -0
- package/cli/constants/domain.js +171 -0
- package/cli/constants/package-manager.js +5 -0
- package/cli/constants/version.js +5 -0
- package/cli/index.js +55 -0
- package/cli/types/index.js +0 -0
- package/cli/utils/add-project-features.js +170 -0
- package/cli/utils/apply-optional-features.js +48 -0
- package/cli/utils/auth-strategy-validation.js +179 -0
- package/cli/utils/cancel.js +8 -0
- package/cli/utils/cli-options.js +27 -0
- package/cli/utils/cli-project-validation.js +157 -0
- package/cli/utils/detect-project-state.js +131 -0
- package/cli/utils/format-code.js +9 -0
- package/cli/utils/get-package-manager.js +12 -0
- package/cli/utils/get-package-root.js +19 -0
- package/cli/utils/get-source-code-path.js +15 -0
- package/cli/utils/install-module.js +258 -0
- package/cli/utils/normalize-add-args.js +25 -0
- package/cli/utils/parse-new-args.js +127 -0
- package/cli/utils/patch-auth-install.js +224 -0
- package/cli/utils/patch-define-documentation.js +222 -0
- package/cli/utils/patch-env.js +106 -0
- package/cli/utils/patch-generated-project.js +21 -0
- package/cli/utils/patch-health-module.js +80 -0
- package/cli/utils/patch-infra-module.js +62 -0
- package/cli/utils/patch-jobs-module.js +103 -0
- package/cli/utils/patch-main.js +15 -0
- package/cli/utils/patch-person-features.js +127 -0
- package/cli/utils/project-files.js +11 -0
- package/cli/utils/prune-auth-strategies.js +116 -0
- package/cli/utils/prune-core-auth.js +17 -0
- package/cli/utils/remove-sample-parts.js +203 -0
- package/cli/utils/resolve-project-path.js +19 -0
- package/cli/utils/restore-person-features.js +64 -0
- package/cli/utils/run-command.js +31 -0
- package/cli/utils/sync-auth-strategy-files.js +63 -0
- package/koala-nest/.env.example +34 -0
- package/koala-nest/.prettierrc +4 -0
- package/koala-nest/README.md +51 -0
- package/koala-nest/bunfig.toml +7 -0
- package/koala-nest/eslint.config.mjs +55 -0
- package/koala-nest/nest-cli.json +9 -0
- package/koala-nest/package.json +79 -0
- package/koala-nest/src/application/auth/common/auth-token.response.ts +15 -0
- package/koala-nest/src/application/auth/common/user-claims.ts +6 -0
- package/koala-nest/src/application/auth/login/login.handler.ts +42 -0
- package/koala-nest/src/application/auth/login/login.request.ts +9 -0
- package/koala-nest/src/application/auth/login/login.response.ts +3 -0
- package/koala-nest/src/application/auth/login/login.validator.ts +12 -0
- package/koala-nest/src/application/auth/oauth2/auth-link/auth-link.handler.ts +24 -0
- package/koala-nest/src/application/auth/oauth2/auth-link/auth-link.request.ts +10 -0
- package/koala-nest/src/application/auth/oauth2/auth-link/auth-link.response.ts +6 -0
- package/koala-nest/src/application/auth/oauth2/auth-link/auth-link.validator.ts +12 -0
- package/koala-nest/src/application/auth/oauth2/callback/oauth-callback.response.ts +10 -0
- package/koala-nest/src/application/auth/oauth2/exchange-code/exchange-code.handler.ts +73 -0
- package/koala-nest/src/application/auth/oauth2/exchange-code/exchange-code.request.ts +16 -0
- package/koala-nest/src/application/auth/oauth2/exchange-code/exchange-code.validator.ts +14 -0
- package/koala-nest/src/application/auth/oauth2/scalar-token/scalar-oauth-token.handler.ts +35 -0
- package/koala-nest/src/application/auth/oauth2/scalar-token/scalar-token.types.ts +1 -0
- package/koala-nest/src/application/auth/refresh-token/refresh-token.handler.ts +26 -0
- package/koala-nest/src/application/auth/user-info/user-info.handler.ts +30 -0
- package/koala-nest/src/application/auth/user-info/user-info.response.ts +20 -0
- package/koala-nest/src/application/common/created-registre.response.ts +20 -0
- package/koala-nest/src/application/common/pagination.request.ts +41 -0
- package/koala-nest/src/application/common/request-handler.base.ts +3 -0
- package/koala-nest/src/application/common/request-validator.base.ts +33 -0
- package/koala-nest/src/application/mapping/mapping.provider.ts +9 -0
- package/koala-nest/src/application/mapping/person.mapper.ts +44 -0
- package/koala-nest/src/application/person/create/create-person.handler.ts +34 -0
- package/koala-nest/src/application/person/create/create-person.request.ts +29 -0
- package/koala-nest/src/application/person/create/create-person.response.ts +3 -0
- package/koala-nest/src/application/person/create/create-person.validator.ts +9 -0
- package/koala-nest/src/application/person/delete/delete-person.handler.ts +22 -0
- package/koala-nest/src/application/person/find-person-or-throw.ts +16 -0
- package/koala-nest/src/application/person/jobs/cron/create-person.job.ts +58 -0
- package/koala-nest/src/application/person/jobs/cron/delete-inactive.job.ts +57 -0
- package/koala-nest/src/application/person/jobs/events/person/inactive-person/inactive-person.event.ts +4 -0
- package/koala-nest/src/application/person/jobs/events/person/inactive-person/inactive-person.handler.ts +54 -0
- package/koala-nest/src/application/person/jobs/events/person/person-event.job.ts +19 -0
- package/koala-nest/src/application/person/person.schemas.ts +21 -0
- package/koala-nest/src/application/person/read/read-person.handler.ts +22 -0
- package/koala-nest/src/application/person/read/read-person.response.ts +44 -0
- package/koala-nest/src/application/person/read-many/read-many-person.handler.ts +63 -0
- package/koala-nest/src/application/person/read-many/read-many-person.request.ts +13 -0
- package/koala-nest/src/application/person/read-many/read-many-person.response.ts +30 -0
- package/koala-nest/src/application/person/read-many/read-many-person.validator.ts +15 -0
- package/koala-nest/src/application/person/update/update-person.handler.ts +51 -0
- package/koala-nest/src/application/person/update/update-person.request.ts +41 -0
- package/koala-nest/src/application/person/update/update-person.validator.ts +9 -0
- package/koala-nest/src/core/auth/assert-user-active.ts +18 -0
- package/koala-nest/src/core/auth/auth-profile.enum.ts +7 -0
- package/koala-nest/src/core/auth/auth-routes.ts +5 -0
- package/koala-nest/src/core/auth/auth.constants.ts +6 -0
- package/koala-nest/src/core/auth/jwt-claims.ts +23 -0
- package/koala-nest/src/core/auth/oauth-provider.registry.ts +94 -0
- package/koala-nest/src/core/auth/parse-jwt-expires-in.ts +30 -0
- package/koala-nest/src/core/auth/parse-oauth2-provider-env.ts +56 -0
- package/koala-nest/src/core/auth/resolve-refresh-token.ts +40 -0
- package/koala-nest/src/core/background-services/cron-service/cron-job.handler.base.ts +65 -0
- package/koala-nest/src/core/background-services/event-service/event-class.ts +5 -0
- package/koala-nest/src/core/background-services/event-service/event-handler.base.ts +17 -0
- package/koala-nest/src/core/background-services/event-service/event-job.ts +31 -0
- package/koala-nest/src/core/background-services/event-service/event-queue.ts +107 -0
- package/koala-nest/src/core/base/entity.base.ts +3 -0
- package/koala-nest/src/core/base/object-class.ts +14 -0
- package/koala-nest/src/core/constants/cache.constants.ts +16 -0
- package/koala-nest/src/core/constants/cron.constants.ts +14 -0
- package/koala-nest/src/core/constants/query-params.ts +7 -0
- package/koala-nest/src/core/env.ts +42 -0
- package/koala-nest/src/core/schemas/boolean.schema.ts +24 -0
- package/koala-nest/src/core/schemas/document-number-mask.ts +22 -0
- package/koala-nest/src/core/schemas/document-number.schema.ts +21 -0
- package/koala-nest/src/core/schemas/document-number.utils.ts +15 -0
- package/koala-nest/src/core/schemas/email.schema.ts +13 -0
- package/koala-nest/src/core/schemas/index.ts +6 -0
- package/koala-nest/src/core/schemas/list-query.schema.ts +18 -0
- package/koala-nest/src/core/schemas/native-enum.schema.ts +36 -0
- package/koala-nest/src/core/tools/mapping/auto-map.ts +14 -0
- package/koala-nest/src/core/tools/mapping/auto-mapper.ts +102 -0
- package/koala-nest/src/core/tools/mapping/create-map.ts +11 -0
- package/koala-nest/src/core/tools/mapping/for-member.ts +16 -0
- package/koala-nest/src/core/tools/mapping/index.ts +4 -0
- package/koala-nest/src/core/tools/mapping/mapping-store.ts +121 -0
- package/koala-nest/src/core/types/auth-provider-config-response.type.ts +5 -0
- package/koala-nest/src/core/types/index.ts +5 -0
- package/koala-nest/src/core/utils/build-list-cache-key.ts +19 -0
- package/koala-nest/src/core/utils/cron-expression-to-boolean.ts +65 -0
- package/koala-nest/src/core/utils/env.config.ts +17 -0
- package/koala-nest/src/core/utils/filter-request-params.ts +29 -0
- package/koala-nest/src/core/utils/format-typeorm-error.ts +173 -0
- package/koala-nest/src/core/utils/format-zod-error.ts +201 -0
- package/koala-nest/src/core/utils/hash-password.ts +5 -0
- package/koala-nest/src/core/utils/icomparable.ts +1 -0
- package/koala-nest/src/core/utils/is-provider-registered.ts +40 -0
- package/koala-nest/src/core/utils/name-to-login.ts +25 -0
- package/koala-nest/src/core/utils/person-list-cache.ts +7 -0
- package/koala-nest/src/core/utils/report-error.ts +18 -0
- package/koala-nest/src/core/utils/resolve-api-host.ts +8 -0
- package/koala-nest/src/core/utils/time.constants.ts +5 -0
- package/koala-nest/src/domain/auth/dtos/auth-provider-config.dto.ts +12 -0
- package/koala-nest/src/domain/auth/dtos/oauth-user-info.dto.ts +9 -0
- package/koala-nest/src/domain/auth/services/iauth.service.ts +37 -0
- package/koala-nest/src/domain/common/icache.service.ts +11 -0
- package/koala-nest/src/domain/common/ilogging.service.ts +9 -0
- package/koala-nest/src/domain/common/ired-lock.service.ts +4 -0
- package/koala-nest/src/domain/dtos/logged-user-info.dto.ts +30 -0
- package/koala-nest/src/domain/dtos/pagination.dto.ts +35 -0
- package/koala-nest/src/domain/dtos/person-query.dto.ts +10 -0
- package/koala-nest/src/domain/entities/person/person-address.ts +14 -0
- package/koala-nest/src/domain/entities/person/person-contact.ts +28 -0
- package/koala-nest/src/domain/entities/person/person.ts +44 -0
- package/koala-nest/src/domain/entities/user/enums/user-status.enum.ts +6 -0
- package/koala-nest/src/domain/entities/user/user.ts +49 -0
- package/koala-nest/src/domain/repositories/iperson.repository.ts +10 -0
- package/koala-nest/src/domain/repositories/iuser.repository.ts +8 -0
- package/koala-nest/src/domain/services/ilogged-user-info.service.ts +5 -0
- package/koala-nest/src/host/app.module.ts +27 -0
- package/koala-nest/src/host/controllers/auth/auth.module.ts +38 -0
- package/koala-nest/src/host/controllers/auth/login.controller.ts +41 -0
- package/koala-nest/src/host/controllers/auth/refresh-token.controller.ts +24 -0
- package/koala-nest/src/host/controllers/auth/router.config.ts +9 -0
- package/koala-nest/src/host/controllers/auth/user-info.controller.ts +19 -0
- package/koala-nest/src/host/controllers/common/controller.base.ts +9 -0
- package/koala-nest/src/host/controllers/common/controller.module.ts +10 -0
- package/koala-nest/src/host/controllers/common/router-config.base.ts +14 -0
- package/koala-nest/src/host/controllers/health-check/health-check.controller.ts +29 -0
- package/koala-nest/src/host/controllers/health-check/health-check.module.ts +22 -0
- package/koala-nest/src/host/controllers/oauth2/auth-link.controller.ts +29 -0
- package/koala-nest/src/host/controllers/oauth2/exchange-code.controller.ts +29 -0
- package/koala-nest/src/host/controllers/oauth2/oauth-callback.controller.ts +28 -0
- package/koala-nest/src/host/controllers/oauth2/router.config.ts +9 -0
- package/koala-nest/src/host/controllers/oauth2/scalar-token.controller.ts +16 -0
- package/koala-nest/src/host/controllers/person/create-person.controller.ts +23 -0
- package/koala-nest/src/host/controllers/person/delete-person.controller.ts +23 -0
- package/koala-nest/src/host/controllers/person/person.module.ts +39 -0
- package/koala-nest/src/host/controllers/person/read-many-person.controller.ts +24 -0
- package/koala-nest/src/host/controllers/person/read-person.controller.ts +21 -0
- package/koala-nest/src/host/controllers/person/router.config.ts +9 -0
- package/koala-nest/src/host/controllers/person/update-person.controller.ts +22 -0
- package/koala-nest/src/host/decorators/api-exclude-endpoint-diff-develop.decorator.ts +9 -0
- package/koala-nest/src/host/decorators/api-property-enum.decorator.ts +49 -0
- package/koala-nest/src/host/decorators/api-property-only-develop.decorator.ts +19 -0
- package/koala-nest/src/host/decorators/controller.decorator.ts +10 -0
- package/koala-nest/src/host/decorators/is-public.decorator.ts +82 -0
- package/koala-nest/src/host/decorators/restriction-by-profile.decorator.ts +13 -0
- package/koala-nest/src/host/decorators/scalar-token-endpoint.decorator.ts +14 -0
- package/koala-nest/src/host/filters/errors.filter.ts +99 -0
- package/koala-nest/src/host/jobs/jobs-bootstrap.service.ts +61 -0
- package/koala-nest/src/host/jobs/jobs.module.ts +41 -0
- package/koala-nest/src/host/jobs/jobs.tokens.ts +2 -0
- package/koala-nest/src/host/main.ts +43 -0
- package/koala-nest/src/host/open-api/define-documentation.ts +210 -0
- package/koala-nest/src/host/security/guards/auth.guard.ts +107 -0
- package/koala-nest/src/host/security/guards/profiles.guard.ts +32 -0
- package/koala-nest/src/host/security/security.module.ts +62 -0
- package/koala-nest/src/host/security/strategies/jwt.strategy.ts +61 -0
- package/koala-nest/src/infra/auth/jwt-token.service.ts +48 -0
- package/koala-nest/src/infra/auth/oauth2-auth.service.ts +208 -0
- package/koala-nest/src/infra/common/cache-service.provider.ts +47 -0
- package/koala-nest/src/infra/common/env.service.ts +12 -0
- package/koala-nest/src/infra/common/in-memory-cache.service.ts +71 -0
- package/koala-nest/src/infra/common/logging.service.ts +19 -0
- package/koala-nest/src/infra/common/red-lock.service.ts +44 -0
- package/koala-nest/src/infra/common/redis-cache.service.ts +72 -0
- package/koala-nest/src/infra/database/data-source-factory.ts +23 -0
- package/koala-nest/src/infra/database/database.module.ts +19 -0
- package/koala-nest/src/infra/database/migrations/1781281330533-Init.ts +67 -0
- package/koala-nest/src/infra/database/migrations/generate-migration.ts +26 -0
- package/koala-nest/src/infra/database/migrations/migration-datasource.ts +14 -0
- package/koala-nest/src/infra/infra.module.ts +29 -0
- package/koala-nest/src/infra/repositories/person.repository.ts +49 -0
- package/koala-nest/src/infra/repositories/repository.base.ts +20 -0
- package/koala-nest/src/infra/repositories/repository.module.ts +16 -0
- package/koala-nest/src/infra/repositories/user.repository.ts +38 -0
- package/koala-nest/src/infra/services/database.indicator.service.ts +17 -0
- package/koala-nest/src/infra/services/logged-user-info.service.ts +32 -0
- package/koala-nest/src/infra/services/redis.indicator.service.ts +66 -0
- package/koala-nest/src/test/app-auth-test.module.ts +32 -0
- package/koala-nest/src/test/app-test.module.ts +22 -0
- package/koala-nest/src/test/application/auth-link.handler.spec.ts +22 -0
- package/koala-nest/src/test/application/create-person.handler.spec.ts +39 -0
- package/koala-nest/src/test/application/create-person.job.spec.ts +55 -0
- package/koala-nest/src/test/application/delete-inactive.job.spec.ts +35 -0
- package/koala-nest/src/test/application/delete-person.handler.spec.ts +46 -0
- package/koala-nest/src/test/application/exchange-code.handler.spec.ts +67 -0
- package/koala-nest/src/test/application/inactive-person.handler.spec.ts +48 -0
- package/koala-nest/src/test/application/login.handler.spec.ts +55 -0
- package/koala-nest/src/test/application/read-many-person.handler.spec.ts +64 -0
- package/koala-nest/src/test/application/read-person.handler.spec.ts +44 -0
- package/koala-nest/src/test/application/refresh-token.handler.spec.ts +34 -0
- package/koala-nest/src/test/application/scalar-oauth-token.handler.spec.ts +63 -0
- package/koala-nest/src/test/application/update-person.handler.spec.ts +78 -0
- package/koala-nest/src/test/bun-test-globals.d.ts +1 -0
- package/koala-nest/src/test/core/auth.guard.spec.ts +77 -0
- package/koala-nest/src/test/core/build-list-cache-key.spec.ts +29 -0
- package/koala-nest/src/test/core/cron-expression-to-boolean.spec.ts +22 -0
- package/koala-nest/src/test/core/cron-job.handler.spec.ts +40 -0
- package/koala-nest/src/test/core/env.config.spec.ts +14 -0
- package/koala-nest/src/test/core/env.spec.ts +61 -0
- package/koala-nest/src/test/core/event-queue.spec.ts +53 -0
- package/koala-nest/src/test/core/format-typeorm-error.spec.ts +42 -0
- package/koala-nest/src/test/core/format-zod-error.spec.ts +38 -0
- package/koala-nest/src/test/core/is-provider-registered.spec.ts +35 -0
- package/koala-nest/src/test/core/jwt.strategy.spec.ts +38 -0
- package/koala-nest/src/test/core/mapping.spec.ts +177 -0
- package/koala-nest/src/test/core/oauth-provider.registry.spec.ts +79 -0
- package/koala-nest/src/test/core/profiles.guard.spec.ts +42 -0
- package/koala-nest/src/test/core/resolve-api-host.spec.ts +20 -0
- package/koala-nest/src/test/core/schemas.spec.ts +95 -0
- package/koala-nest/src/test/create-auth-e2e-test-app.ts +22 -0
- package/koala-nest/src/test/create-e2e-test-app.ts +14 -0
- package/koala-nest/src/test/e2e-context.ts +7 -0
- package/koala-nest/src/test/host/controllers/auth/auth.controller.e2e.spec.ts +87 -0
- package/koala-nest/src/test/host/controllers/person/lazy-loading.e2e.spec.ts +181 -0
- package/koala-nest/src/test/host/controllers/person/person.controller.e2e.spec.ts +148 -0
- package/koala-nest/src/test/host/errors.filter.spec.ts +75 -0
- package/koala-nest/src/test/host/is-public-open-api.spec.ts +60 -0
- package/koala-nest/src/test/host/oauth-callback.controller.spec.ts +18 -0
- package/koala-nest/src/test/infra/cache-service.provider.spec.ts +21 -0
- package/koala-nest/src/test/infra/in-memory-cache.service.spec.ts +49 -0
- package/koala-nest/src/test/infra/jwt-token.service.spec.ts +28 -0
- package/koala-nest/src/test/infra/logged-user-info.service.spec.ts +33 -0
- package/koala-nest/src/test/infra/oauth2-auth.service.spec.ts +112 -0
- package/koala-nest/src/test/infra/red-lock.service.spec.ts +43 -0
- package/koala-nest/src/test/infra/redis-cache.service.spec.ts +100 -0
- package/koala-nest/src/test/infra/redis-indicator.service.spec.ts +75 -0
- package/koala-nest/src/test/mockup/person/person.entities.ts +35 -0
- package/koala-nest/src/test/mockup/person/person.requests.ts +23 -0
- package/koala-nest/src/test/mockup/person/person.responses.ts +31 -0
- package/koala-nest/src/test/services/cache.stub.ts +41 -0
- package/koala-nest/src/test/services/fake-logging.service.ts +13 -0
- package/koala-nest/src/test/services/fake-red-lock.service.ts +11 -0
- package/koala-nest/src/test/services/logged-user-info.fake-service.ts +18 -0
- package/koala-nest/src/test/setup-e2e.ts +66 -0
- package/koala-nest/src/test/setup.ts +1 -0
- package/koala-nest/src/test/utils/configure-test-app.ts +24 -0
- package/koala-nest/src/test/utils/create-e2e-database.ts +50 -0
- package/koala-nest/src/test/utils/e2e-database-client.ts +9 -0
- package/koala-nest/src/test/utils/guard-test-context.ts +28 -0
- package/koala-nest/src/test/utils/jwt-test-keys.ts +27 -0
- package/koala-nest/tsconfig.build.json +8 -0
- package/koala-nest/tsconfig.json +36 -0
- package/koala-nest/tsconfig.spec.json +11 -0
- package/package.json +19 -29
- package/core/backgroud-services/cron-service/cron-job.handler.base.d.ts +0 -16
- package/core/backgroud-services/cron-service/cron-job.handler.base.js +0 -49
- package/core/backgroud-services/event-service/event-class.d.ts +0 -5
- package/core/backgroud-services/event-service/event-class.js +0 -11
- package/core/backgroud-services/event-service/event-handler.base.d.ts +0 -8
- package/core/backgroud-services/event-service/event-handler.base.js +0 -14
- package/core/backgroud-services/event-service/event-is-trigger.d.ts +0 -3
- package/core/backgroud-services/event-service/event-is-trigger.js +0 -7
- package/core/backgroud-services/event-service/event-job.d.ts +0 -13
- package/core/backgroud-services/event-service/event-job.js +0 -21
- package/core/backgroud-services/event-service/event-queue.d.ts +0 -18
- package/core/backgroud-services/event-service/event-queue.js +0 -65
- package/core/constants/query-params.d.ts +0 -6
- package/core/constants/query-params.js +0 -8
- package/core/controllers/base.controller.d.ts +0 -4
- package/core/controllers/base.controller.js +0 -6
- package/core/controllers/controller.decorator.d.ts +0 -2
- package/core/controllers/controller.decorator.js +0 -11
- package/core/controllers/created-registre-response.base.d.ts +0 -10
- package/core/controllers/created-registre-response.base.js +0 -35
- package/core/controllers/list-response.base.d.ts +0 -4
- package/core/controllers/list-response.base.js +0 -21
- package/core/controllers/pagination.request.d.ts +0 -10
- package/core/controllers/pagination.request.js +0 -56
- package/core/controllers/router-config.base.d.ts +0 -7
- package/core/controllers/router-config.base.js +0 -18
- package/core/controllers/schemas/boolean.schema.d.ts +0 -2
- package/core/controllers/schemas/boolean.schema.js +0 -12
- package/core/controllers/schemas/document-number.schema.d.ts +0 -1
- package/core/controllers/schemas/document-number.schema.js +0 -26
- package/core/controllers/schemas/email.schema.d.ts +0 -1
- package/core/controllers/schemas/email.schema.js +0 -13
- package/core/controllers/schemas/list-query.schema.d.ts +0 -17
- package/core/controllers/schemas/list-query.schema.js +0 -19
- package/core/controllers/schemas/native-enum.schema.d.ts +0 -7
- package/core/controllers/schemas/native-enum.schema.js +0 -28
- package/core/controllers/schemas/set-mask-document-number.schema.d.ts +0 -1
- package/core/controllers/schemas/set-mask-document-number.schema.js +0 -13
- package/core/database/entity.base.d.ts +0 -27
- package/core/database/entity.base.js +0 -145
- package/core/database/entity.decorator.d.ts +0 -12
- package/core/database/entity.decorator.js +0 -37
- package/core/database/prisma-client-with-custom-transaction.interface.d.ts +0 -8
- package/core/database/prisma-client-with-custom-transaction.interface.js +0 -2
- package/core/database/prisma-resolver.d.ts +0 -2
- package/core/database/prisma-resolver.js +0 -74
- package/core/database/prisma-transactional-client.d.ts +0 -11
- package/core/database/prisma-transactional-client.js +0 -25
- package/core/database/prisma.service.d.ts +0 -24
- package/core/database/prisma.service.js +0 -104
- package/core/database/repository.base.d.ts +0 -82
- package/core/database/repository.base.js +0 -668
- package/core/dtos/pagination.dto.d.ts +0 -9
- package/core/dtos/pagination.dto.js +0 -49
- package/core/errors/bad-request.error.d.ts +0 -5
- package/core/errors/bad-request.error.js +0 -10
- package/core/errors/conflict.error.d.ts +0 -4
- package/core/errors/conflict.error.js +0 -10
- package/core/errors/error.base.d.ts +0 -4
- package/core/errors/error.base.js +0 -11
- package/core/errors/no-content.error.d.ts +0 -5
- package/core/errors/no-content.error.js +0 -10
- package/core/errors/not-allowed.error.d.ts +0 -5
- package/core/errors/not-allowed.error.js +0 -10
- package/core/errors/resource-not-found.error.d.ts +0 -5
- package/core/errors/resource-not-found.error.js +0 -10
- package/core/errors/use-case-error.d.ts +0 -3
- package/core/errors/use-case-error.js +0 -2
- package/core/errors/user-already-exist.error.d.ts +0 -4
- package/core/errors/user-already-exist.error.js +0 -10
- package/core/errors/wrong-credentials.error.d.ts +0 -4
- package/core/errors/wrong-credentials.error.js +0 -10
- package/core/health-check/health-check.controller.d.ts +0 -5
- package/core/health-check/health-check.controller.js +0 -32
- package/core/health-check/health-check.module.d.ts +0 -2
- package/core/health-check/health-check.module.js +0 -19
- package/core/index.d.ts +0 -18
- package/core/index.js +0 -7
- package/core/koala-app.d.ts +0 -64
- package/core/koala-app.js +0 -258
- package/core/koala-global-vars.d.ts +0 -7
- package/core/koala-global-vars.js +0 -9
- package/core/koala-nest-database.module.d.ts +0 -16
- package/core/koala-nest-database.module.js +0 -52
- package/core/koala-nest-http.module.d.ts +0 -13
- package/core/koala-nest-http.module.js +0 -37
- package/core/koala-nest.module.d.ts +0 -17
- package/core/koala-nest.module.js +0 -66
- package/core/mapping/auto-mapping-class-context.d.ts +0 -16
- package/core/mapping/auto-mapping-class-context.js +0 -18
- package/core/mapping/auto-mapping-context.d.ts +0 -11
- package/core/mapping/auto-mapping-context.js +0 -24
- package/core/mapping/auto-mapping-list.d.ts +0 -28
- package/core/mapping/auto-mapping-list.js +0 -99
- package/core/mapping/auto-mapping-profile.d.ts +0 -3
- package/core/mapping/auto-mapping-profile.js +0 -6
- package/core/mapping/auto-mapping.decorator.d.ts +0 -9
- package/core/mapping/auto-mapping.decorator.js +0 -27
- package/core/mapping/auto-mapping.module.d.ts +0 -5
- package/core/mapping/auto-mapping.module.js +0 -29
- package/core/mapping/auto-mapping.service.d.ts +0 -20
- package/core/mapping/auto-mapping.service.js +0 -197
- package/core/mapping/create-map.d.ts +0 -3
- package/core/mapping/create-map.js +0 -7
- package/core/mapping/for-member.d.ts +0 -5
- package/core/mapping/for-member.js +0 -8
- package/core/request-overflow/request-handler.base.d.ts +0 -4
- package/core/request-overflow/request-handler.base.js +0 -6
- package/core/request-overflow/request-result.d.ts +0 -15
- package/core/request-overflow/request-result.js +0 -37
- package/core/request-overflow/request-validator.base.d.ts +0 -7
- package/core/request-overflow/request-validator.base.js +0 -26
- package/core/security/strategies/api-key.strategy.d.ts +0 -16
- package/core/security/strategies/api-key.strategy.js +0 -31
- package/core/utils/assing-object.d.ts +0 -5
- package/core/utils/assing-object.js +0 -6
- package/core/utils/automap-cycle-context.d.ts +0 -6
- package/core/utils/automap-cycle-context.js +0 -33
- package/core/utils/env.config.d.ts +0 -6
- package/core/utils/env.config.js +0 -18
- package/core/utils/filter-request-params.d.ts +0 -13
- package/core/utils/filter-request-params.js +0 -22
- package/core/utils/find-on-list.d.ts +0 -2
- package/core/utils/find-on-list.js +0 -13
- package/core/utils/generate-prisma-include-schema.d.ts +0 -9
- package/core/utils/generate-prisma-include-schema.js +0 -60
- package/core/utils/get-type-by-prop.d.ts +0 -2
- package/core/utils/get-type-by-prop.js +0 -11
- package/core/utils/hydrate-entity-from-cache.d.ts +0 -22
- package/core/utils/hydrate-entity-from-cache.js +0 -76
- package/core/utils/instanciate-class-with-dependencies-injection.d.ts +0 -2
- package/core/utils/instanciate-class-with-dependencies-injection.js +0 -10
- package/core/utils/interfaces/icomparable.d.ts +0 -5
- package/core/utils/interfaces/icomparable.js +0 -6
- package/core/utils/is-plain-object.d.ts +0 -1
- package/core/utils/is-plain-object.js +0 -8
- package/core/utils/list.d.ts +0 -39
- package/core/utils/list.js +0 -167
- package/core/utils/promise-all.d.ts +0 -7
- package/core/utils/promise-all.js +0 -19
- package/core/utils/proxy.d.ts +0 -1
- package/core/utils/proxy.js +0 -27
- package/core/utils/set-mask-document-number.d.ts +0 -1
- package/core/utils/set-mask-document-number.js +0 -13
- package/core/validators/file-validator.d.ts +0 -27
- package/core/validators/file-validator.js +0 -94
- package/decorators/api-exclude-endpoint-diff-develop.decorator.d.ts +0 -1
- package/decorators/api-exclude-endpoint-diff-develop.decorator.js +0 -9
- package/decorators/api-property-enum.decorator.d.ts +0 -8
- package/decorators/api-property-enum.decorator.js +0 -21
- package/decorators/api-property-only-develop.decorator.d.ts +0 -2
- package/decorators/api-property-only-develop.decorator.js +0 -9
- package/decorators/cookies.decorator.d.ts +0 -1
- package/decorators/cookies.decorator.js +0 -8
- package/decorators/is-public.decorator.d.ts +0 -2
- package/decorators/is-public.decorator.js +0 -7
- package/decorators/upload.decorator.d.ts +0 -1
- package/decorators/upload.decorator.js +0 -18
- package/env/env.d.ts +0 -25
- package/env/env.js +0 -14
- package/env/env.module.d.ts +0 -2
- package/env/env.module.js +0 -20
- package/env/env.service.d.ts +0 -7
- package/env/env.service.js +0 -28
- package/filters/domain-errors.filter.d.ts +0 -18
- package/filters/domain-errors.filter.js +0 -92
- package/filters/global-exception.filter.d.ts +0 -8
- package/filters/global-exception.filter.js +0 -68
- package/filters/prisma-validation-exception.filter.d.ts +0 -10
- package/filters/prisma-validation-exception.filter.js +0 -82
- package/filters/zod-errors.filter.d.ts +0 -9
- package/filters/zod-errors.filter.js +0 -60
- package/services/logging/ilogging.service.d.ts +0 -16
- package/services/logging/ilogging.service.js +0 -6
- package/services/logging/logging.service.d.ts +0 -4
- package/services/logging/logging.service.js +0 -20
- package/services/redis/iredis.service.d.ts +0 -6
- package/services/redis/iredis.service.js +0 -6
- package/services/redis/redis.service.d.ts +0 -14
- package/services/redis/redis.service.js +0 -65
- package/services/redlock/ired-lock.service.d.ts +0 -4
- package/services/redlock/ired-lock.service.js +0 -6
- package/services/redlock/red-lock.service.d.ts +0 -9
- package/services/redlock/red-lock.service.js +0 -46
- package/test/koala-app-test-dependencies.d.ts +0 -10
- package/test/koala-app-test-dependencies.js +0 -13
- package/test/koala-app-test.d.ts +0 -22
- package/test/koala-app-test.js +0 -77
- package/test/repositories/in-memory-base.repository.d.ts +0 -17
- package/test/repositories/in-memory-base.repository.js +0 -67
- package/test/services/fake-logging.service.d.ts +0 -4
- package/test/services/fake-logging.service.js +0 -9
- package/test/services/fake-red-lock.service.d.ts +0 -5
- package/test/services/fake-red-lock.service.js +0 -11
- package/test/utils/create-e2e-database.d.ts +0 -7
- package/test/utils/create-e2e-database.js +0 -38
- package/test/utils/e2e-database-client.d.ts +0 -7
- package/test/utils/e2e-database-client.js +0 -12
- package/test/utils/wait-for.d.ts +0 -1
- package/test/utils/wait-for.js +0 -21
- package/tsconfig.lib.tsbuildinfo +0 -1
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PaginationDto = void 0;
|
|
13
|
-
const query_params_1 = require("../constants/query-params");
|
|
14
|
-
const auto_mapping_decorator_1 = require("../mapping/auto-mapping.decorator");
|
|
15
|
-
class PaginationDto {
|
|
16
|
-
page = 0;
|
|
17
|
-
limit = query_params_1.QUERY_FILTER_PARAMS.limit;
|
|
18
|
-
orderBy = '';
|
|
19
|
-
direction = 'asc';
|
|
20
|
-
skip() {
|
|
21
|
-
return (this.limit ?? 0) * (this.page ?? query_params_1.QUERY_FILTER_PARAMS.page);
|
|
22
|
-
}
|
|
23
|
-
generateOrderBy() {
|
|
24
|
-
if (this.orderBy) {
|
|
25
|
-
const orderByField = this.orderBy.split('.');
|
|
26
|
-
return orderByField.reduceRight((acc, item, index) => ({
|
|
27
|
-
[item]: index === orderByField.length - 1 ? this.direction : acc,
|
|
28
|
-
}), {});
|
|
29
|
-
}
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.PaginationDto = PaginationDto;
|
|
34
|
-
__decorate([
|
|
35
|
-
(0, auto_mapping_decorator_1.AutoMap)(),
|
|
36
|
-
__metadata("design:type", Number)
|
|
37
|
-
], PaginationDto.prototype, "page", void 0);
|
|
38
|
-
__decorate([
|
|
39
|
-
(0, auto_mapping_decorator_1.AutoMap)(),
|
|
40
|
-
__metadata("design:type", Number)
|
|
41
|
-
], PaginationDto.prototype, "limit", void 0);
|
|
42
|
-
__decorate([
|
|
43
|
-
(0, auto_mapping_decorator_1.AutoMap)(),
|
|
44
|
-
__metadata("design:type", String)
|
|
45
|
-
], PaginationDto.prototype, "orderBy", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, auto_mapping_decorator_1.AutoMap)(),
|
|
48
|
-
__metadata("design:type", String)
|
|
49
|
-
], PaginationDto.prototype, "direction", void 0);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BadRequestError = void 0;
|
|
4
|
-
const error_base_1 = require("./error.base");
|
|
5
|
-
class BadRequestError extends error_base_1.ErrorBase {
|
|
6
|
-
constructor(message, data) {
|
|
7
|
-
super(message ?? 'Bad Request', data);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.BadRequestError = BadRequestError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConflictError = void 0;
|
|
4
|
-
const error_base_1 = require("./error.base");
|
|
5
|
-
class ConflictError extends error_base_1.ErrorBase {
|
|
6
|
-
constructor(identifier, data) {
|
|
7
|
-
super(`O registro ${identifier} já existe.`, data);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.ConflictError = ConflictError;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorBase = void 0;
|
|
4
|
-
class ErrorBase extends Error {
|
|
5
|
-
data;
|
|
6
|
-
constructor(message, data) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.data = data;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.ErrorBase = ErrorBase;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoContentError = void 0;
|
|
4
|
-
const error_base_1 = require("./error.base");
|
|
5
|
-
class NoContentError extends error_base_1.ErrorBase {
|
|
6
|
-
constructor(message, data) {
|
|
7
|
-
super(message ?? 'No Content', data);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.NoContentError = NoContentError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotAllowedError = void 0;
|
|
4
|
-
const error_base_1 = require("./error.base");
|
|
5
|
-
class NotAllowedError extends error_base_1.ErrorBase {
|
|
6
|
-
constructor(message, data) {
|
|
7
|
-
super(message ?? 'Você não tem permissão para utilizar esse recurso.', data);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.NotAllowedError = NotAllowedError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResourceNotFoundError = void 0;
|
|
4
|
-
const error_base_1 = require("./error.base");
|
|
5
|
-
class ResourceNotFoundError extends error_base_1.ErrorBase {
|
|
6
|
-
constructor(name = 'Recurso', data) {
|
|
7
|
-
super(`${name} não encontrado(a).`, data);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.ResourceNotFoundError = ResourceNotFoundError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserAlreadyExist = void 0;
|
|
4
|
-
const error_base_1 = require("./error.base");
|
|
5
|
-
class UserAlreadyExist extends error_base_1.ErrorBase {
|
|
6
|
-
constructor(identifier, data) {
|
|
7
|
-
super(`User ${identifier} already exists`, data);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.UserAlreadyExist = UserAlreadyExist;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WrongCredentialsError = void 0;
|
|
4
|
-
const error_base_1 = require("./error.base");
|
|
5
|
-
class WrongCredentialsError extends error_base_1.ErrorBase {
|
|
6
|
-
constructor(data) {
|
|
7
|
-
super('Credentials are not valid', data);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.WrongCredentialsError = WrongCredentialsError;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.HealthCheckController = void 0;
|
|
13
|
-
const is_public_decorator_1 = require("../../decorators/is-public.decorator");
|
|
14
|
-
const common_1 = require("@nestjs/common");
|
|
15
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
16
|
-
let HealthCheckController = class HealthCheckController {
|
|
17
|
-
healthCheck() {
|
|
18
|
-
return { status: 'ok' };
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
exports.HealthCheckController = HealthCheckController;
|
|
22
|
-
__decorate([
|
|
23
|
-
(0, common_1.Get)(),
|
|
24
|
-
(0, is_public_decorator_1.IsPublic)(),
|
|
25
|
-
(0, swagger_1.ApiExcludeEndpoint)(),
|
|
26
|
-
__metadata("design:type", Function),
|
|
27
|
-
__metadata("design:paramtypes", []),
|
|
28
|
-
__metadata("design:returntype", void 0)
|
|
29
|
-
], HealthCheckController.prototype, "healthCheck", null);
|
|
30
|
-
exports.HealthCheckController = HealthCheckController = __decorate([
|
|
31
|
-
(0, common_1.Controller)('health')
|
|
32
|
-
], HealthCheckController);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.HealthCheckModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const health_check_controller_1 = require("./health-check.controller");
|
|
12
|
-
let HealthCheckModule = class HealthCheckModule {
|
|
13
|
-
};
|
|
14
|
-
exports.HealthCheckModule = HealthCheckModule;
|
|
15
|
-
exports.HealthCheckModule = HealthCheckModule = __decorate([
|
|
16
|
-
(0, common_1.Module)({
|
|
17
|
-
controllers: [health_check_controller_1.HealthCheckController],
|
|
18
|
-
})
|
|
19
|
-
], HealthCheckModule);
|
package/core/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type FileType = Express.Multer.File;
|
|
2
|
-
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
3
|
-
export type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
4
|
-
export type CreatedRegister<TypeId = string> = {
|
|
5
|
-
id: TypeId;
|
|
6
|
-
};
|
|
7
|
-
export type ListResponse<TItem = any> = {
|
|
8
|
-
items: Array<TItem>;
|
|
9
|
-
count: number;
|
|
10
|
-
};
|
|
11
|
-
export type FileResponse = {
|
|
12
|
-
filename: string;
|
|
13
|
-
type: string;
|
|
14
|
-
base64: string;
|
|
15
|
-
};
|
|
16
|
-
export type QueryDirectionType = 'asc' | 'desc';
|
|
17
|
-
export { setPrismaClient } from './database/prisma-resolver';
|
|
18
|
-
export { setPrismaClientOptions } from './database/prisma.service';
|
package/core/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setPrismaClientOptions = exports.setPrismaClient = void 0;
|
|
4
|
-
var prisma_resolver_1 = require("./database/prisma-resolver");
|
|
5
|
-
Object.defineProperty(exports, "setPrismaClient", { enumerable: true, get: function () { return prisma_resolver_1.setPrismaClient; } });
|
|
6
|
-
var prisma_service_1 = require("./database/prisma.service");
|
|
7
|
-
Object.defineProperty(exports, "setPrismaClientOptions", { enumerable: true, get: function () { return prisma_service_1.setPrismaClientOptions; } });
|
package/core/koala-app.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { CanActivate, INestApplication, Type } from '@nestjs/common';
|
|
2
|
-
import { BaseExceptionFilter } from '@nestjs/core';
|
|
3
|
-
import { SecuritySchemeObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
|
|
4
|
-
import { CronJobHandlerBase } from './backgroud-services/cron-service/cron-job.handler.base';
|
|
5
|
-
import { EventHandlerBase } from './backgroud-services/event-service/event-handler.base';
|
|
6
|
-
import { PrismaTransactionalClient } from './database/prisma-transactional-client';
|
|
7
|
-
interface ApiDocAuthorizationConfig {
|
|
8
|
-
name: string;
|
|
9
|
-
config: SecuritySchemeObject;
|
|
10
|
-
}
|
|
11
|
-
interface ApiDocServerConfig {
|
|
12
|
-
url: string;
|
|
13
|
-
description: string;
|
|
14
|
-
}
|
|
15
|
-
type ScalarTheme = 'alternate' | 'default' | 'moon' | 'purple' | 'solarized' | 'bluePlanet' | 'saturn' | 'kepler' | 'mars' | 'deepSpace' | 'none';
|
|
16
|
-
interface ApiDocConfig {
|
|
17
|
-
endpoint: string;
|
|
18
|
-
title: string;
|
|
19
|
-
ui?: 'swagger' | 'scalar';
|
|
20
|
-
theme?: ScalarTheme;
|
|
21
|
-
description?: string;
|
|
22
|
-
externalDoc?: {
|
|
23
|
-
message: string;
|
|
24
|
-
url: string;
|
|
25
|
-
};
|
|
26
|
-
servers?: ApiDocServerConfig[];
|
|
27
|
-
version: string;
|
|
28
|
-
authorizations?: boolean | ApiDocAuthorizationConfig[];
|
|
29
|
-
}
|
|
30
|
-
type CronJobClass = string | symbol | Function | Type<CronJobHandlerBase>;
|
|
31
|
-
type EventJobClass = string | symbol | Function | Type<EventHandlerBase>;
|
|
32
|
-
export declare class KoalaApp {
|
|
33
|
-
private readonly app;
|
|
34
|
-
private _globalExceptionFilter;
|
|
35
|
-
private _prismaValidationExceptionFilter;
|
|
36
|
-
private _domainExceptionFilter;
|
|
37
|
-
private _zodExceptionFilter;
|
|
38
|
-
private _guards;
|
|
39
|
-
private _cronJobs;
|
|
40
|
-
private _eventJobs;
|
|
41
|
-
private _apiReferenceEndpoint;
|
|
42
|
-
private _ngrokKey;
|
|
43
|
-
private _ngrokUrl;
|
|
44
|
-
constructor(app: INestApplication<any>);
|
|
45
|
-
private showListeningMessage;
|
|
46
|
-
private startJobs;
|
|
47
|
-
addGlobalGuard(Guard: Type<CanActivate>): this;
|
|
48
|
-
addCronJob(job: CronJobClass): this;
|
|
49
|
-
addEventJob(eventJob: EventJobClass): this;
|
|
50
|
-
addCustomGlobalExceptionFilter(filter: BaseExceptionFilter): this;
|
|
51
|
-
addCustomPrismaValidationExceptionFilter(filter: BaseExceptionFilter): this;
|
|
52
|
-
addCustomDomainExceptionFilter(filter: BaseExceptionFilter): this;
|
|
53
|
-
addCustomZodExceptionFilter(filter: BaseExceptionFilter): this;
|
|
54
|
-
useDoc(config: ApiDocConfig): this;
|
|
55
|
-
useNgrok(key: string): this;
|
|
56
|
-
enableCors(): this;
|
|
57
|
-
setAppName(name: string): this;
|
|
58
|
-
setInternalUserName(name: string): this;
|
|
59
|
-
setDbTransactionContext(transactionContext: Type<PrismaTransactionalClient>): this;
|
|
60
|
-
build(): Promise<INestApplication<any>>;
|
|
61
|
-
serve(host?: string): Promise<void>;
|
|
62
|
-
buildAndServe(host?: string): Promise<void>;
|
|
63
|
-
}
|
|
64
|
-
export {};
|
package/core/koala-app.js
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KoalaApp = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
-
const nestjs_api_reference_1 = require("@scalar/nestjs-api-reference");
|
|
7
|
-
const consola = require("consola");
|
|
8
|
-
const expressBasicAuth = require("express-basic-auth");
|
|
9
|
-
const env_service_1 = require("../env/env.service");
|
|
10
|
-
const domain_errors_filter_1 = require("../filters/domain-errors.filter");
|
|
11
|
-
const global_exception_filter_1 = require("../filters/global-exception.filter");
|
|
12
|
-
const prisma_validation_exception_filter_1 = require("../filters/prisma-validation-exception.filter");
|
|
13
|
-
const zod_errors_filter_1 = require("../filters/zod-errors.filter");
|
|
14
|
-
const ilogging_service_1 = require("../services/logging/ilogging.service");
|
|
15
|
-
const koala_global_vars_1 = require("./koala-global-vars");
|
|
16
|
-
const env_config_1 = require("./utils/env.config");
|
|
17
|
-
const instanciate_class_with_dependencies_injection_1 = require("./utils/instanciate-class-with-dependencies-injection");
|
|
18
|
-
const utils_1 = require("@koalarx/utils");
|
|
19
|
-
class KoalaApp {
|
|
20
|
-
app;
|
|
21
|
-
_globalExceptionFilter;
|
|
22
|
-
_prismaValidationExceptionFilter;
|
|
23
|
-
_domainExceptionFilter;
|
|
24
|
-
_zodExceptionFilter;
|
|
25
|
-
_guards = [];
|
|
26
|
-
_cronJobs = [];
|
|
27
|
-
_eventJobs = [];
|
|
28
|
-
_apiReferenceEndpoint;
|
|
29
|
-
_ngrokKey;
|
|
30
|
-
_ngrokUrl;
|
|
31
|
-
constructor(app) {
|
|
32
|
-
this.app = app;
|
|
33
|
-
let loggingService = this.app.get(ilogging_service_1.ILoggingService);
|
|
34
|
-
if (!loggingService.report) {
|
|
35
|
-
loggingService = (0, instanciate_class_with_dependencies_injection_1.instanciateClassWithDependenciesInjection)(this.app, loggingService);
|
|
36
|
-
}
|
|
37
|
-
this._globalExceptionFilter = new global_exception_filter_1.GlobalExceptionsFilter(loggingService);
|
|
38
|
-
this._prismaValidationExceptionFilter = new prisma_validation_exception_filter_1.PrismaValidationExceptionFilter(loggingService);
|
|
39
|
-
this._domainExceptionFilter = new domain_errors_filter_1.DomainErrorsFilter(loggingService);
|
|
40
|
-
this._zodExceptionFilter = new zod_errors_filter_1.ZodErrorsFilter(loggingService);
|
|
41
|
-
}
|
|
42
|
-
showListeningMessage(port, host = 'localhost') {
|
|
43
|
-
const envService = this.app.get(env_service_1.EnvService);
|
|
44
|
-
console.log('------------------------------');
|
|
45
|
-
if (this._apiReferenceEndpoint) {
|
|
46
|
-
consola.info('API Reference:', `http://${host}:${port}${this._apiReferenceEndpoint}`);
|
|
47
|
-
}
|
|
48
|
-
consola.info('Health Check:', `http://${host}:${port}/health`);
|
|
49
|
-
consola.info('Internal Host:', `http://${host}:${port}`);
|
|
50
|
-
if (this._ngrokUrl) {
|
|
51
|
-
consola.info('External Host:', this._ngrokUrl);
|
|
52
|
-
consola.info('External Inspect:', `http://${host}:4040/inspect/http`);
|
|
53
|
-
}
|
|
54
|
-
consola.box('Environment:', envService.get('NODE_ENV'));
|
|
55
|
-
console.log('------------------------------');
|
|
56
|
-
}
|
|
57
|
-
async startJobs() {
|
|
58
|
-
await (0, utils_1.delay)(5000);
|
|
59
|
-
const cronJobs = await Promise.all(this._cronJobs.map((job) => this.app.resolve(job)));
|
|
60
|
-
for (const cronJob of cronJobs) {
|
|
61
|
-
cronJob.start();
|
|
62
|
-
}
|
|
63
|
-
const eventJobs = await Promise.all(this._eventJobs.map((job) => this.app.resolve(job)));
|
|
64
|
-
for (const eventJob of eventJobs) {
|
|
65
|
-
eventJob.setupSubscriptions();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
addGlobalGuard(Guard) {
|
|
69
|
-
this._guards.push((0, instanciate_class_with_dependencies_injection_1.instanciateClassWithDependenciesInjection)(this.app, Guard));
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
addCronJob(job) {
|
|
73
|
-
this._cronJobs.push(job);
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
addEventJob(eventJob) {
|
|
77
|
-
this._eventJobs.push(eventJob);
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
addCustomGlobalExceptionFilter(filter) {
|
|
81
|
-
this._globalExceptionFilter = filter;
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
addCustomPrismaValidationExceptionFilter(filter) {
|
|
85
|
-
this._prismaValidationExceptionFilter = filter;
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
addCustomDomainExceptionFilter(filter) {
|
|
89
|
-
this._domainExceptionFilter = filter;
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
addCustomZodExceptionFilter(filter) {
|
|
93
|
-
this._zodExceptionFilter = filter;
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
useDoc(config) {
|
|
97
|
-
const credentials = {
|
|
98
|
-
username: process.env.SWAGGER_USERNAME ?? '',
|
|
99
|
-
password: process.env.SWAGGER_PASSWORD ?? '',
|
|
100
|
-
};
|
|
101
|
-
if (env_config_1.EnvConfig.isEnvDevelop &&
|
|
102
|
-
credentials.username &&
|
|
103
|
-
credentials.password) {
|
|
104
|
-
this.app.use([config.endpoint], expressBasicAuth({
|
|
105
|
-
challenge: true,
|
|
106
|
-
users: {
|
|
107
|
-
[credentials.username]: credentials.password,
|
|
108
|
-
},
|
|
109
|
-
}));
|
|
110
|
-
}
|
|
111
|
-
const documentBuilder = new swagger_1.DocumentBuilder()
|
|
112
|
-
.setTitle(config.title)
|
|
113
|
-
.setVersion(config.version);
|
|
114
|
-
if (config.description) {
|
|
115
|
-
if (config.externalDoc) {
|
|
116
|
-
documentBuilder.setDescription(`${config.description}\n\n[${config.externalDoc.message}](${config.externalDoc.url})`);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
documentBuilder.setDescription(config.description);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (config.authorizations) {
|
|
123
|
-
if (Array.isArray(config.authorizations)) {
|
|
124
|
-
for (const auth of config.authorizations) {
|
|
125
|
-
documentBuilder.addBearerAuth(auth.config, auth.name);
|
|
126
|
-
documentBuilder.addSecurityRequirements(auth.name);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
documentBuilder.addBearerAuth();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (config.servers) {
|
|
134
|
-
for (const server of config.servers) {
|
|
135
|
-
documentBuilder.addServer(server.url, server.description);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const document = swagger_1.SwaggerModule.createDocument(this.app, documentBuilder.build());
|
|
139
|
-
const swaggerEndpoint = config.endpoint;
|
|
140
|
-
this._apiReferenceEndpoint = swaggerEndpoint;
|
|
141
|
-
if (config.ui === 'scalar' && swaggerEndpoint === '/') {
|
|
142
|
-
throw new common_1.InternalServerErrorException("O endpoint de documentação não pode ser '/' para UI Scalar.");
|
|
143
|
-
}
|
|
144
|
-
swagger_1.SwaggerModule.setup(swaggerEndpoint, this.app, document, {
|
|
145
|
-
swaggerUiEnabled: config.ui !== 'scalar',
|
|
146
|
-
});
|
|
147
|
-
if (config.ui === 'scalar') {
|
|
148
|
-
this.app.use(swaggerEndpoint, (0, nestjs_api_reference_1.apiReference)({
|
|
149
|
-
spec: {
|
|
150
|
-
content: document,
|
|
151
|
-
},
|
|
152
|
-
hideModels: true,
|
|
153
|
-
hideDownloadButton: true,
|
|
154
|
-
hideClientButton: true,
|
|
155
|
-
theme: config.theme ?? 'default',
|
|
156
|
-
hiddenClients: [
|
|
157
|
-
'libcurl',
|
|
158
|
-
'clj_http',
|
|
159
|
-
'restsharp',
|
|
160
|
-
'native',
|
|
161
|
-
'http1.1',
|
|
162
|
-
'asynchttp',
|
|
163
|
-
'nethttp',
|
|
164
|
-
'okhttp',
|
|
165
|
-
'unirest',
|
|
166
|
-
'xhr',
|
|
167
|
-
'okhttp',
|
|
168
|
-
'native',
|
|
169
|
-
'request',
|
|
170
|
-
'unirest',
|
|
171
|
-
'nsurlsession',
|
|
172
|
-
'cohttp',
|
|
173
|
-
'guzzle',
|
|
174
|
-
'http1',
|
|
175
|
-
'http2',
|
|
176
|
-
'webrequest',
|
|
177
|
-
'restmethod',
|
|
178
|
-
'requests',
|
|
179
|
-
'httr',
|
|
180
|
-
'native',
|
|
181
|
-
'httpie',
|
|
182
|
-
'wget',
|
|
183
|
-
'nsurlsession',
|
|
184
|
-
'undici',
|
|
185
|
-
],
|
|
186
|
-
metaData: {
|
|
187
|
-
title: config.title,
|
|
188
|
-
description: config.description,
|
|
189
|
-
},
|
|
190
|
-
}));
|
|
191
|
-
}
|
|
192
|
-
return this;
|
|
193
|
-
}
|
|
194
|
-
useNgrok(key) {
|
|
195
|
-
this._ngrokKey = key;
|
|
196
|
-
return this;
|
|
197
|
-
}
|
|
198
|
-
enableCors() {
|
|
199
|
-
this.app.enableCors({
|
|
200
|
-
credentials: true,
|
|
201
|
-
origin: true,
|
|
202
|
-
optionsSuccessStatus: 200,
|
|
203
|
-
});
|
|
204
|
-
return this;
|
|
205
|
-
}
|
|
206
|
-
setAppName(name) {
|
|
207
|
-
koala_global_vars_1.KoalaGlobalVars.appName = name;
|
|
208
|
-
return this;
|
|
209
|
-
}
|
|
210
|
-
setInternalUserName(name) {
|
|
211
|
-
koala_global_vars_1.KoalaGlobalVars.internalUserName = name;
|
|
212
|
-
return this;
|
|
213
|
-
}
|
|
214
|
-
setDbTransactionContext(transactionContext) {
|
|
215
|
-
koala_global_vars_1.KoalaGlobalVars.dbTransactionContext = transactionContext;
|
|
216
|
-
return this;
|
|
217
|
-
}
|
|
218
|
-
async build() {
|
|
219
|
-
if (koala_global_vars_1.KoalaGlobalVars.dbTransactionContext) {
|
|
220
|
-
this.app.useGlobalFilters(this._prismaValidationExceptionFilter);
|
|
221
|
-
}
|
|
222
|
-
this.app.useGlobalFilters(this._globalExceptionFilter, this._domainExceptionFilter, this._zodExceptionFilter);
|
|
223
|
-
for (const guard of this._guards) {
|
|
224
|
-
this.app.useGlobalGuards(guard);
|
|
225
|
-
}
|
|
226
|
-
if (this._ngrokKey) {
|
|
227
|
-
let ngrok;
|
|
228
|
-
try {
|
|
229
|
-
ngrok = require('ngrok');
|
|
230
|
-
}
|
|
231
|
-
catch {
|
|
232
|
-
throw new common_1.InternalServerErrorException('Para usar o suporte ao ngrok, instale a dependência opcional "ngrok" (ex: bun add ngrok ou npm install ngrok)');
|
|
233
|
-
}
|
|
234
|
-
const envService = this.app.get(env_service_1.EnvService);
|
|
235
|
-
const port = envService.get('PORT') ?? 3000;
|
|
236
|
-
await ngrok
|
|
237
|
-
.connect({
|
|
238
|
-
authtoken: this._ngrokKey,
|
|
239
|
-
addr: port,
|
|
240
|
-
})
|
|
241
|
-
.then((url) => {
|
|
242
|
-
this._ngrokUrl = url;
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
this.startJobs();
|
|
246
|
-
return this.app;
|
|
247
|
-
}
|
|
248
|
-
async serve(host) {
|
|
249
|
-
const envService = this.app.get(env_service_1.EnvService);
|
|
250
|
-
const port = envService.get('PORT') ?? 3000;
|
|
251
|
-
this.app.listen(port).then(() => this.showListeningMessage(port, host));
|
|
252
|
-
}
|
|
253
|
-
async buildAndServe(host) {
|
|
254
|
-
await this.build();
|
|
255
|
-
await this.serve(host);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
exports.KoalaApp = KoalaApp;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Type } from '@nestjs/common';
|
|
2
|
-
import { PrismaTransactionalClient } from './database/prisma-transactional-client';
|
|
3
|
-
export declare class KoalaGlobalVars {
|
|
4
|
-
static appName: string;
|
|
5
|
-
static internalUserName: string;
|
|
6
|
-
static dbTransactionContext?: Type<PrismaTransactionalClient>;
|
|
7
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KoalaGlobalVars = void 0;
|
|
4
|
-
class KoalaGlobalVars {
|
|
5
|
-
static appName = 'koala-nest';
|
|
6
|
-
static internalUserName = 'internal';
|
|
7
|
-
static dbTransactionContext;
|
|
8
|
-
}
|
|
9
|
-
exports.KoalaGlobalVars = KoalaGlobalVars;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { DynamicModule, ForwardReference, InjectionToken, Type } from '@nestjs/common';
|
|
2
|
-
import { RepositoryBase } from '../core/database/repository.base';
|
|
3
|
-
export declare const PRISMA_TOKEN = "PRISMA_SERVICE_TOKEN";
|
|
4
|
-
export interface KoalaNestDatabaseProviderConfig<T> {
|
|
5
|
-
interface: InjectionToken;
|
|
6
|
-
class: Type<T>;
|
|
7
|
-
}
|
|
8
|
-
interface KoalaNestDatabaseModuleConfig {
|
|
9
|
-
repositories: KoalaNestDatabaseProviderConfig<RepositoryBase<any>>[];
|
|
10
|
-
services: KoalaNestDatabaseProviderConfig<any>[];
|
|
11
|
-
imports?: Array<Type<any> | DynamicModule | ForwardReference<any>>;
|
|
12
|
-
}
|
|
13
|
-
export declare class KoalaNestDatabaseModule {
|
|
14
|
-
static register(config: KoalaNestDatabaseModuleConfig): DynamicModule;
|
|
15
|
-
}
|
|
16
|
-
export {};
|