@koalarx/nest 3.1.50 → 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 -83
- 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
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { AuthStrategy } from "./domain.js";
|
|
2
|
+
import {
|
|
3
|
+
JWT_ONLY_REMOVE_PATHS,
|
|
4
|
+
OAUTH2_ONLY_REMOVE_PATHS
|
|
5
|
+
} from "./auth-strategy-artifacts.js";
|
|
6
|
+
export const AUTH_SHARED_REQUIRED_PATHS = [
|
|
7
|
+
"src/host/controllers/auth/auth.module.ts",
|
|
8
|
+
"src/host/security/security.module.ts",
|
|
9
|
+
"src/domain/auth/services/iauth.service.ts",
|
|
10
|
+
"src/infra/auth/jwt-token.service.ts",
|
|
11
|
+
"src/domain/dtos/logged-user-info.dto.ts",
|
|
12
|
+
"src/domain/entities/user/user.ts",
|
|
13
|
+
"src/infra/database/migrations/1781281330533-Init.ts"
|
|
14
|
+
];
|
|
15
|
+
export const JWT_REQUIRED_PATHS = [
|
|
16
|
+
"src/host/controllers/auth/login.controller.ts",
|
|
17
|
+
"src/application/auth/login/login.handler.ts",
|
|
18
|
+
"src/application/auth/refresh-token/refresh-token.handler.ts",
|
|
19
|
+
"src/test/application/login.handler.spec.ts"
|
|
20
|
+
];
|
|
21
|
+
export const OAUTH2_REQUIRED_PATHS = [
|
|
22
|
+
"src/application/auth/oauth2",
|
|
23
|
+
"src/host/controllers/oauth2/auth-link.controller.ts",
|
|
24
|
+
"src/application/auth/oauth2/auth-link/auth-link.handler.ts",
|
|
25
|
+
"src/host/decorators/scalar-token-endpoint.decorator.ts",
|
|
26
|
+
"src/domain/auth/dtos/oauth-user-info.dto.ts",
|
|
27
|
+
"src/domain/auth/dtos/auth-provider-config.dto.ts",
|
|
28
|
+
"src/infra/auth/oauth2-auth.service.ts",
|
|
29
|
+
"src/core/types/auth-provider-config-response.type.ts",
|
|
30
|
+
"src/core/auth/oauth-provider.registry.ts",
|
|
31
|
+
"src/core/auth/parse-oauth2-provider-env.ts",
|
|
32
|
+
"src/test/application/auth-link.handler.spec.ts",
|
|
33
|
+
"src/test/application/exchange-code.handler.spec.ts",
|
|
34
|
+
"src/test/application/scalar-oauth-token.handler.spec.ts",
|
|
35
|
+
"src/test/host/oauth-callback.controller.spec.ts",
|
|
36
|
+
"src/test/infra/oauth2-auth.service.spec.ts",
|
|
37
|
+
"src/test/core/oauth-provider.registry.spec.ts"
|
|
38
|
+
];
|
|
39
|
+
export const NO_AUTH_FORBIDDEN_PATHS = [
|
|
40
|
+
"src/application/auth",
|
|
41
|
+
"src/host/controllers/oauth2",
|
|
42
|
+
"src/host/security/security.module.ts",
|
|
43
|
+
"src/domain/auth",
|
|
44
|
+
"src/infra/auth",
|
|
45
|
+
"src/core/auth",
|
|
46
|
+
"src/domain/dtos/logged-user-info.dto.ts",
|
|
47
|
+
"src/domain/services/ilogged-user-info.service.ts",
|
|
48
|
+
"src/infra/services/logged-user-info.service.ts",
|
|
49
|
+
"src/host/decorators/scalar-token-endpoint.decorator.ts",
|
|
50
|
+
"src/host/decorators/restriction-by-profile.decorator.ts"
|
|
51
|
+
];
|
|
52
|
+
export const JWT_FORBIDDEN_CONTENT = [
|
|
53
|
+
"IOAuth2Service",
|
|
54
|
+
"OAuth2AuthService",
|
|
55
|
+
"OAuthProviderRegistry",
|
|
56
|
+
"OAuthUserInfoDto",
|
|
57
|
+
"AuthProviderConfigDto",
|
|
58
|
+
"parse-oauth2-provider-env",
|
|
59
|
+
"oauth-provider.registry",
|
|
60
|
+
"oauth2-auth.service",
|
|
61
|
+
"OAuthAuthLinkHandler",
|
|
62
|
+
"OAuthExchangeCodeController",
|
|
63
|
+
"ScalarOAuthTokenHandler",
|
|
64
|
+
"OAUTH2_PROVIDERS",
|
|
65
|
+
"OAUTH2_PROVIDER_ENV",
|
|
66
|
+
"parseOAuth2ProviderEnv"
|
|
67
|
+
];
|
|
68
|
+
export const OAUTH2_LOGIN_FORBIDDEN_CONTENT = [
|
|
69
|
+
"LoginController",
|
|
70
|
+
"LoginHandler"
|
|
71
|
+
];
|
|
72
|
+
export function resolveAuthProfile(selection) {
|
|
73
|
+
if (selection === false || selection.length === 0) {
|
|
74
|
+
return "none";
|
|
75
|
+
}
|
|
76
|
+
const hasJwt = selection.includes(AuthStrategy.JWT);
|
|
77
|
+
const hasOauth = selection.includes(AuthStrategy.OAUTH2);
|
|
78
|
+
if (hasJwt && hasOauth) {
|
|
79
|
+
return "jwt+oauth2";
|
|
80
|
+
}
|
|
81
|
+
if (hasJwt) {
|
|
82
|
+
return "jwt";
|
|
83
|
+
}
|
|
84
|
+
if (hasOauth) {
|
|
85
|
+
return "oauth2";
|
|
86
|
+
}
|
|
87
|
+
return "none";
|
|
88
|
+
}
|
|
89
|
+
export function requiredPathsForProfile(profile) {
|
|
90
|
+
switch (profile) {
|
|
91
|
+
case "none":
|
|
92
|
+
return [];
|
|
93
|
+
case "jwt":
|
|
94
|
+
return [...AUTH_SHARED_REQUIRED_PATHS, ...JWT_REQUIRED_PATHS];
|
|
95
|
+
case "oauth2":
|
|
96
|
+
return [...AUTH_SHARED_REQUIRED_PATHS, ...OAUTH2_REQUIRED_PATHS];
|
|
97
|
+
case "jwt+oauth2":
|
|
98
|
+
return [
|
|
99
|
+
...AUTH_SHARED_REQUIRED_PATHS,
|
|
100
|
+
...JWT_REQUIRED_PATHS,
|
|
101
|
+
...OAUTH2_REQUIRED_PATHS
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export function forbiddenPathsForProfile(profile) {
|
|
106
|
+
switch (profile) {
|
|
107
|
+
case "none":
|
|
108
|
+
return NO_AUTH_FORBIDDEN_PATHS;
|
|
109
|
+
case "jwt":
|
|
110
|
+
return JWT_ONLY_REMOVE_PATHS;
|
|
111
|
+
case "oauth2":
|
|
112
|
+
return OAUTH2_ONLY_REMOVE_PATHS;
|
|
113
|
+
case "jwt+oauth2":
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export function envExampleMustContain(profile) {
|
|
118
|
+
switch (profile) {
|
|
119
|
+
case "none":
|
|
120
|
+
return [];
|
|
121
|
+
case "jwt":
|
|
122
|
+
return ["JWT_PRIVATE_KEY"];
|
|
123
|
+
case "oauth2":
|
|
124
|
+
return ["JWT_PRIVATE_KEY", "OAUTH2_PROVIDERS"];
|
|
125
|
+
case "jwt+oauth2":
|
|
126
|
+
return ["JWT_PRIVATE_KEY", "OAUTH2_PROVIDERS"];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export function envExampleMustNotContain(profile) {
|
|
130
|
+
switch (profile) {
|
|
131
|
+
case "none":
|
|
132
|
+
return ["JWT_PRIVATE_KEY", "OAUTH2_PROVIDERS"];
|
|
133
|
+
case "jwt":
|
|
134
|
+
return ["OAUTH2_PROVIDERS"];
|
|
135
|
+
case "oauth2":
|
|
136
|
+
return [];
|
|
137
|
+
case "jwt+oauth2":
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export function envSourceMustContain(profile) {
|
|
142
|
+
switch (profile) {
|
|
143
|
+
case "none":
|
|
144
|
+
return [];
|
|
145
|
+
case "jwt":
|
|
146
|
+
return ["JWT_PRIVATE_KEY"];
|
|
147
|
+
case "oauth2":
|
|
148
|
+
return ["OAUTH2_PROVIDERS", "parse-oauth2-provider-env"];
|
|
149
|
+
case "jwt+oauth2":
|
|
150
|
+
return ["JWT_PRIVATE_KEY", "OAUTH2_PROVIDERS", "parse-oauth2-provider-env"];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export function envSourceMustNotContain(profile) {
|
|
154
|
+
switch (profile) {
|
|
155
|
+
case "none":
|
|
156
|
+
return [
|
|
157
|
+
"JWT_PRIVATE_KEY",
|
|
158
|
+
"OAUTH2_PROVIDERS",
|
|
159
|
+
"parse-oauth2-provider-env",
|
|
160
|
+
"OAUTH2_PROVIDER_ENV"
|
|
161
|
+
];
|
|
162
|
+
case "jwt":
|
|
163
|
+
return ["parse-oauth2-provider-env", "OAUTH2_PROVIDERS", "OAUTH2_PROVIDER_ENV"];
|
|
164
|
+
case "oauth2":
|
|
165
|
+
return [];
|
|
166
|
+
case "jwt+oauth2":
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export function iauthMustContain(profile) {
|
|
171
|
+
switch (profile) {
|
|
172
|
+
case "none":
|
|
173
|
+
return [];
|
|
174
|
+
case "jwt":
|
|
175
|
+
return ["IJwtTokenService"];
|
|
176
|
+
case "oauth2":
|
|
177
|
+
return ["IJwtTokenService", "IOAuth2Service"];
|
|
178
|
+
case "jwt+oauth2":
|
|
179
|
+
return ["IJwtTokenService", "IOAuth2Service"];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
export function iauthMustNotContain(profile) {
|
|
183
|
+
switch (profile) {
|
|
184
|
+
case "none":
|
|
185
|
+
return ["IJwtTokenService", "IOAuth2Service"];
|
|
186
|
+
case "jwt":
|
|
187
|
+
return ["IOAuth2Service"];
|
|
188
|
+
case "oauth2":
|
|
189
|
+
return [];
|
|
190
|
+
case "jwt+oauth2":
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
export function authModuleMustContain(profile) {
|
|
195
|
+
switch (profile) {
|
|
196
|
+
case "none":
|
|
197
|
+
return [];
|
|
198
|
+
case "jwt":
|
|
199
|
+
return ["LoginController"];
|
|
200
|
+
case "oauth2":
|
|
201
|
+
return ["OAuthAuthLinkController"];
|
|
202
|
+
case "jwt+oauth2":
|
|
203
|
+
return ["LoginController", "OAuthAuthLinkController"];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
export function authModuleMustNotContain(profile) {
|
|
207
|
+
switch (profile) {
|
|
208
|
+
case "none":
|
|
209
|
+
return ["LoginController", "OAuthAuthLinkController"];
|
|
210
|
+
case "jwt":
|
|
211
|
+
return ["OAuthAuthLinkController"];
|
|
212
|
+
case "oauth2":
|
|
213
|
+
return ["LoginController"];
|
|
214
|
+
case "jwt+oauth2":
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
export function securityModuleMustContain(profile) {
|
|
219
|
+
switch (profile) {
|
|
220
|
+
case "none":
|
|
221
|
+
return [];
|
|
222
|
+
case "jwt":
|
|
223
|
+
return ["IJwtTokenService"];
|
|
224
|
+
case "oauth2":
|
|
225
|
+
return ["IJwtTokenService", "IOAuth2Service", "OAuthProviderRegistry"];
|
|
226
|
+
case "jwt+oauth2":
|
|
227
|
+
return ["IJwtTokenService", "IOAuth2Service", "OAuthProviderRegistry"];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
export function securityModuleMustNotContain(profile) {
|
|
231
|
+
switch (profile) {
|
|
232
|
+
case "none":
|
|
233
|
+
return ["SecurityModule", "IJwtTokenService", "IOAuth2Service"];
|
|
234
|
+
case "jwt":
|
|
235
|
+
return ["IOAuth2Service", "OAuthProviderRegistry"];
|
|
236
|
+
case "oauth2":
|
|
237
|
+
return [];
|
|
238
|
+
case "jwt+oauth2":
|
|
239
|
+
return [];
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
export function cacheConstantsMustContain(profile) {
|
|
243
|
+
return profile === "oauth2" || profile === "jwt+oauth2" ? ["OAUTH2_STATE"] : [];
|
|
244
|
+
}
|
|
245
|
+
export function cacheConstantsMustNotContain(profile) {
|
|
246
|
+
return profile === "jwt" || profile === "none" ? ["OAUTH2_STATE"] : [];
|
|
247
|
+
}
|
|
248
|
+
export function defineDocumentationMustContain(profile) {
|
|
249
|
+
switch (profile) {
|
|
250
|
+
case "none":
|
|
251
|
+
return ["apiReference"];
|
|
252
|
+
case "jwt":
|
|
253
|
+
return ["JWT", "isProviderRegistered"];
|
|
254
|
+
case "oauth2":
|
|
255
|
+
return ["buildDocAuthorizations", "IOAuth2Service"];
|
|
256
|
+
case "jwt+oauth2":
|
|
257
|
+
return ["JWT", "IOAuth2Service", "buildDocAuthorizations"];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
export function defineDocumentationMustNotContain(profile) {
|
|
261
|
+
switch (profile) {
|
|
262
|
+
case "none":
|
|
263
|
+
return ["buildDocAuthorizations", "IOAuth2Service", "OAuthProviderRegistry"];
|
|
264
|
+
case "jwt":
|
|
265
|
+
return ["OAuthProviderRegistry", "IOAuth2Service"];
|
|
266
|
+
case "oauth2":
|
|
267
|
+
return [];
|
|
268
|
+
case "jwt+oauth2":
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
export function appModuleMustContain(profile) {
|
|
273
|
+
switch (profile) {
|
|
274
|
+
case "none":
|
|
275
|
+
return ["InfraModule"];
|
|
276
|
+
case "jwt":
|
|
277
|
+
case "oauth2":
|
|
278
|
+
case "jwt+oauth2":
|
|
279
|
+
return ["SecurityModule", "AuthModule"];
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
export function appModuleMustNotContain(profile) {
|
|
283
|
+
return profile === "none" ? ["SecurityModule", "AuthModule"] : [];
|
|
284
|
+
}
|
|
285
|
+
export function forbiddenContentPatterns(profile) {
|
|
286
|
+
switch (profile) {
|
|
287
|
+
case "none":
|
|
288
|
+
return [...JWT_FORBIDDEN_CONTENT, ...OAUTH2_LOGIN_FORBIDDEN_CONTENT];
|
|
289
|
+
case "jwt":
|
|
290
|
+
return JWT_FORBIDDEN_CONTENT;
|
|
291
|
+
case "oauth2":
|
|
292
|
+
return OAUTH2_LOGIN_FORBIDDEN_CONTENT;
|
|
293
|
+
case "jwt+oauth2":
|
|
294
|
+
return [];
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
export const AUTH_PROFILE_MATRIX = [
|
|
298
|
+
"none",
|
|
299
|
+
"jwt",
|
|
300
|
+
"oauth2",
|
|
301
|
+
"jwt+oauth2"
|
|
302
|
+
];
|
|
303
|
+
export function profileToAuthStrategies(profile) {
|
|
304
|
+
switch (profile) {
|
|
305
|
+
case "none":
|
|
306
|
+
return false;
|
|
307
|
+
case "jwt":
|
|
308
|
+
return [AuthStrategy.JWT];
|
|
309
|
+
case "oauth2":
|
|
310
|
+
return [AuthStrategy.OAUTH2];
|
|
311
|
+
case "jwt+oauth2":
|
|
312
|
+
return [AuthStrategy.JWT, AuthStrategy.OAUTH2];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const CliCommand = {
|
|
2
|
+
HELP: "help",
|
|
3
|
+
NEW: "new",
|
|
4
|
+
ADD: "add",
|
|
5
|
+
VERSION: "version"
|
|
6
|
+
};
|
|
7
|
+
export const CliFlag = {
|
|
8
|
+
HELP: "--help",
|
|
9
|
+
HELP_SHORT: "-h",
|
|
10
|
+
VERBOSE: "--verbose",
|
|
11
|
+
NEW: "--new",
|
|
12
|
+
NEW_SHORT: "-n",
|
|
13
|
+
ADD: "--add",
|
|
14
|
+
ADD_SHORT: "-a",
|
|
15
|
+
VERSION: "--version",
|
|
16
|
+
VERSION_SHORT: "-v",
|
|
17
|
+
TEMPLATE: "--template",
|
|
18
|
+
TEMPLATE_SHORT: "-t",
|
|
19
|
+
PACKAGE_MANAGER: "--package-manager",
|
|
20
|
+
PACKAGE_MANAGER_SHORT: "--pm",
|
|
21
|
+
AUTH: "--auth",
|
|
22
|
+
FEATURES: "--features",
|
|
23
|
+
FEATURE: "--feature"
|
|
24
|
+
};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthStrategy,
|
|
3
|
+
ExtraFeature,
|
|
4
|
+
Template,
|
|
5
|
+
resolveNewProjectOptions
|
|
6
|
+
} from "./domain.js";
|
|
7
|
+
import { resolveProjectFeatures } from "../utils/install-module.js";
|
|
8
|
+
export const CORE_REQUIRED_PATHS = [
|
|
9
|
+
"src/core/env.ts",
|
|
10
|
+
"src/host/main.ts",
|
|
11
|
+
"src/host/app.module.ts",
|
|
12
|
+
"src/host/jobs/jobs.module.ts",
|
|
13
|
+
"src/host/jobs/jobs-bootstrap.service.ts",
|
|
14
|
+
"src/infra/infra.module.ts",
|
|
15
|
+
"src/host/open-api/define-documentation.ts",
|
|
16
|
+
"src/infra/repositories/repository.module.ts",
|
|
17
|
+
"src/infra/database/data-source-factory.ts"
|
|
18
|
+
];
|
|
19
|
+
export const CORE_PACKAGE_DEPENDENCIES = [
|
|
20
|
+
"@koalarx/utils",
|
|
21
|
+
"zod",
|
|
22
|
+
"typeorm",
|
|
23
|
+
"@scalar/nestjs-api-reference"
|
|
24
|
+
];
|
|
25
|
+
export const DEFAULT_TEMPLATE_FORBIDDEN_PATHS = [
|
|
26
|
+
"src/host/controllers/person/person.module.ts",
|
|
27
|
+
"src/infra/repositories/person.repository.ts"
|
|
28
|
+
];
|
|
29
|
+
export const CRUD_TEMPLATE_REQUIRED_PATHS = [
|
|
30
|
+
"src/host/controllers/person/person.module.ts",
|
|
31
|
+
"src/host/controllers/person/delete-person.controller.ts",
|
|
32
|
+
"src/application/person/jobs/cron/create-person.job.ts",
|
|
33
|
+
"src/application/person/jobs/cron/delete-inactive.job.ts",
|
|
34
|
+
"src/application/person/jobs/events/person/person-event.job.ts",
|
|
35
|
+
"src/application/person/jobs/events/person/inactive-person/inactive-person.handler.ts",
|
|
36
|
+
"src/application/person/jobs/events/person/inactive-person/inactive-person.event.ts"
|
|
37
|
+
];
|
|
38
|
+
export const CRUD_TEMPLATE_FORBIDDEN_PATHS = [
|
|
39
|
+
"src/application/person/events"
|
|
40
|
+
];
|
|
41
|
+
export const CRUD_BUNDLED_PACKAGES = [
|
|
42
|
+
"ioredis",
|
|
43
|
+
"cron-parser"
|
|
44
|
+
];
|
|
45
|
+
export const CACHE_REDIS_REQUIRED_PATHS = [
|
|
46
|
+
"src/infra/common/redis-cache.service.ts"
|
|
47
|
+
];
|
|
48
|
+
export const CACHE_REDIS_PACKAGES = ["ioredis"];
|
|
49
|
+
export const HEALTH_REQUIRED_PATHS = [
|
|
50
|
+
"src/host/controllers/health-check/health-check.controller.ts",
|
|
51
|
+
"src/infra/services/database.indicator.service.ts"
|
|
52
|
+
];
|
|
53
|
+
export const HEALTH_REDIS_INDICATOR_PATH = "src/infra/services/redis.indicator.service.ts";
|
|
54
|
+
export const HEALTH_PACKAGES = ["@nestjs/terminus", "@nestjs/axios"];
|
|
55
|
+
export const CRON_REQUIRED_PATHS = [
|
|
56
|
+
"src/core/utils/cron-expression-to-boolean.ts",
|
|
57
|
+
"src/core/background-services/cron-service/cron-job.handler.base.ts"
|
|
58
|
+
];
|
|
59
|
+
export const CRON_PACKAGES = ["cron-parser"];
|
|
60
|
+
export const EVENTS_REQUIRED_PATHS = [
|
|
61
|
+
"src/core/background-services/event-service/event-handler.base.ts"
|
|
62
|
+
];
|
|
63
|
+
export const AUTH_JWT_PACKAGES = ["@nestjs/jwt", "passport-jwt"];
|
|
64
|
+
export const CLI_NEW_SELECTION_MATRIX = [
|
|
65
|
+
{
|
|
66
|
+
label: "default sem auth",
|
|
67
|
+
template: Template.DEFAULT,
|
|
68
|
+
auth: [],
|
|
69
|
+
features: []
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: "default sem auth + health",
|
|
73
|
+
template: Template.DEFAULT,
|
|
74
|
+
auth: [],
|
|
75
|
+
features: [ExtraFeature.HEALTH_CHECK]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
label: "default sem auth + cache",
|
|
79
|
+
template: Template.DEFAULT,
|
|
80
|
+
auth: [],
|
|
81
|
+
features: [ExtraFeature.CACHE]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
label: "default sem auth + cron",
|
|
85
|
+
template: Template.DEFAULT,
|
|
86
|
+
auth: [],
|
|
87
|
+
features: [ExtraFeature.INTERNAL_CRON_JOBS]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: "default sem auth + events",
|
|
91
|
+
template: Template.DEFAULT,
|
|
92
|
+
auth: [],
|
|
93
|
+
features: [ExtraFeature.INTERNAL_EVENT_JOBS]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: "default sem auth + cache + health + cron + events",
|
|
97
|
+
template: Template.DEFAULT,
|
|
98
|
+
auth: [],
|
|
99
|
+
features: [
|
|
100
|
+
ExtraFeature.CACHE,
|
|
101
|
+
ExtraFeature.HEALTH_CHECK,
|
|
102
|
+
ExtraFeature.INTERNAL_CRON_JOBS,
|
|
103
|
+
ExtraFeature.INTERNAL_EVENT_JOBS
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: "default jwt",
|
|
108
|
+
template: Template.DEFAULT,
|
|
109
|
+
auth: [AuthStrategy.JWT],
|
|
110
|
+
features: []
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label: "default oauth2",
|
|
114
|
+
template: Template.DEFAULT,
|
|
115
|
+
auth: [AuthStrategy.OAUTH2],
|
|
116
|
+
features: []
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: "default jwt + oauth2",
|
|
120
|
+
template: Template.DEFAULT,
|
|
121
|
+
auth: [AuthStrategy.JWT, AuthStrategy.OAUTH2],
|
|
122
|
+
features: []
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
label: "default jwt + cache + health",
|
|
126
|
+
template: Template.DEFAULT,
|
|
127
|
+
auth: [AuthStrategy.JWT],
|
|
128
|
+
features: [ExtraFeature.CACHE, ExtraFeature.HEALTH_CHECK]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: "crud jwt",
|
|
132
|
+
template: Template.CRUD_SAMPLE,
|
|
133
|
+
auth: [AuthStrategy.JWT],
|
|
134
|
+
features: []
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: "crud oauth2",
|
|
138
|
+
template: Template.CRUD_SAMPLE,
|
|
139
|
+
auth: [AuthStrategy.OAUTH2],
|
|
140
|
+
features: []
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
label: "crud jwt + oauth2",
|
|
144
|
+
template: Template.CRUD_SAMPLE,
|
|
145
|
+
auth: [AuthStrategy.JWT, AuthStrategy.OAUTH2],
|
|
146
|
+
features: []
|
|
147
|
+
}
|
|
148
|
+
];
|
|
149
|
+
export function buildProjectExpectation(template, auth, features) {
|
|
150
|
+
const resolved = resolveNewProjectOptions(template, [...auth], [...features]);
|
|
151
|
+
const projectFeatures = resolveProjectFeatures(resolved.features, resolved.auth);
|
|
152
|
+
let cache = false;
|
|
153
|
+
if (projectFeatures.cacheWithRedis) {
|
|
154
|
+
cache = "redis";
|
|
155
|
+
} else if (projectFeatures.cache) {
|
|
156
|
+
cache = "memory";
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
template,
|
|
160
|
+
auth: resolved.auth.length === 0 ? false : resolved.auth,
|
|
161
|
+
cache,
|
|
162
|
+
health: projectFeatures.health,
|
|
163
|
+
cronJobs: projectFeatures.cronJobs,
|
|
164
|
+
eventJobs: projectFeatures.eventJobs
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export function requiredPathsForExpectation(expectation) {
|
|
168
|
+
const paths = [...CORE_REQUIRED_PATHS];
|
|
169
|
+
if (expectation.template === Template.CRUD_SAMPLE) {
|
|
170
|
+
paths.push(...CRUD_TEMPLATE_REQUIRED_PATHS);
|
|
171
|
+
}
|
|
172
|
+
if (expectation.cache === "redis") {
|
|
173
|
+
paths.push(...CACHE_REDIS_REQUIRED_PATHS);
|
|
174
|
+
}
|
|
175
|
+
if (expectation.health) {
|
|
176
|
+
paths.push(...HEALTH_REQUIRED_PATHS);
|
|
177
|
+
if (expectation.cache === "redis") {
|
|
178
|
+
paths.push(HEALTH_REDIS_INDICATOR_PATH);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (expectation.cronJobs) {
|
|
182
|
+
paths.push(...CRON_REQUIRED_PATHS);
|
|
183
|
+
}
|
|
184
|
+
if (expectation.eventJobs) {
|
|
185
|
+
paths.push(...EVENTS_REQUIRED_PATHS);
|
|
186
|
+
}
|
|
187
|
+
return paths;
|
|
188
|
+
}
|
|
189
|
+
export function forbiddenPathsForExpectation(expectation) {
|
|
190
|
+
const paths = [];
|
|
191
|
+
if (expectation.template === Template.DEFAULT) {
|
|
192
|
+
paths.push(...DEFAULT_TEMPLATE_FORBIDDEN_PATHS);
|
|
193
|
+
} else {
|
|
194
|
+
paths.push(...CRUD_TEMPLATE_FORBIDDEN_PATHS);
|
|
195
|
+
}
|
|
196
|
+
if (expectation.cache !== "redis") {
|
|
197
|
+
paths.push(...CACHE_REDIS_REQUIRED_PATHS);
|
|
198
|
+
}
|
|
199
|
+
if (!expectation.health) {
|
|
200
|
+
paths.push(...HEALTH_REQUIRED_PATHS, HEALTH_REDIS_INDICATOR_PATH);
|
|
201
|
+
} else if (expectation.cache !== "redis") {
|
|
202
|
+
paths.push(HEALTH_REDIS_INDICATOR_PATH);
|
|
203
|
+
}
|
|
204
|
+
if (!expectation.cronJobs) {
|
|
205
|
+
paths.push(...CRON_REQUIRED_PATHS);
|
|
206
|
+
}
|
|
207
|
+
if (!expectation.eventJobs) {
|
|
208
|
+
paths.push(...EVENTS_REQUIRED_PATHS);
|
|
209
|
+
}
|
|
210
|
+
return paths;
|
|
211
|
+
}
|
|
212
|
+
export function requiredPackagesForExpectation(expectation) {
|
|
213
|
+
const packages = new Set(CORE_PACKAGE_DEPENDENCIES);
|
|
214
|
+
if (expectation.cache === "redis") {
|
|
215
|
+
for (const pkg of CACHE_REDIS_PACKAGES) {
|
|
216
|
+
packages.add(pkg);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (expectation.health) {
|
|
220
|
+
for (const pkg of HEALTH_PACKAGES) {
|
|
221
|
+
packages.add(pkg);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (expectation.cronJobs) {
|
|
225
|
+
for (const pkg of CRON_PACKAGES) {
|
|
226
|
+
packages.add(pkg);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (expectation.auth !== false) {
|
|
230
|
+
for (const pkg of AUTH_JWT_PACKAGES) {
|
|
231
|
+
packages.add(pkg);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return [...packages];
|
|
235
|
+
}
|
|
236
|
+
export function appModuleMustContain(expectation) {
|
|
237
|
+
const patterns = ["JobsModule.register"];
|
|
238
|
+
if (expectation.template === Template.CRUD_SAMPLE) {
|
|
239
|
+
patterns.push("PersonModule", "InactivePersonHandler", "CreatePersonJob", "DeleteInactiveJob");
|
|
240
|
+
} else if (expectation.auth === false) {
|
|
241
|
+
patterns.push("InfraModule", "eventHandlers: []", "cronJobs: []");
|
|
242
|
+
} else {
|
|
243
|
+
patterns.push("eventHandlers: []", "cronJobs: []");
|
|
244
|
+
}
|
|
245
|
+
if (expectation.health) {
|
|
246
|
+
patterns.push("HealthCheckModule");
|
|
247
|
+
}
|
|
248
|
+
if (expectation.auth !== false) {
|
|
249
|
+
patterns.push("SecurityModule", "AuthModule");
|
|
250
|
+
}
|
|
251
|
+
return patterns;
|
|
252
|
+
}
|
|
253
|
+
export function appModuleMustNotContain(expectation) {
|
|
254
|
+
const patterns = [];
|
|
255
|
+
if (expectation.template === Template.DEFAULT) {
|
|
256
|
+
patterns.push("PersonModule");
|
|
257
|
+
}
|
|
258
|
+
if (expectation.auth === false) {
|
|
259
|
+
patterns.push("SecurityModule", "AuthModule");
|
|
260
|
+
}
|
|
261
|
+
if (!expectation.health) {
|
|
262
|
+
patterns.push("HealthCheckModule");
|
|
263
|
+
}
|
|
264
|
+
return patterns;
|
|
265
|
+
}
|
|
266
|
+
export function infraModuleMustContain(expectation) {
|
|
267
|
+
if (expectation.cache === false) {
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
return ["ICacheService", "CacheServiceProvider"];
|
|
271
|
+
}
|
|
272
|
+
export function infraModuleMustNotContain(expectation) {
|
|
273
|
+
if (expectation.cache === false) {
|
|
274
|
+
return ["ICacheService", "CacheServiceProvider"];
|
|
275
|
+
}
|
|
276
|
+
return [];
|
|
277
|
+
}
|
|
278
|
+
export function healthControllerMustContain(expectation) {
|
|
279
|
+
if (!expectation.health) {
|
|
280
|
+
return [];
|
|
281
|
+
}
|
|
282
|
+
return expectation.cache === "redis" ? ["RedisIndicator"] : [];
|
|
283
|
+
}
|
|
284
|
+
export function healthControllerMustNotContain(expectation) {
|
|
285
|
+
if (!expectation.health || expectation.cache === "redis") {
|
|
286
|
+
return [];
|
|
287
|
+
}
|
|
288
|
+
return ["RedisIndicator"];
|
|
289
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const CORE_PACKAGES = [
|
|
2
|
+
"@koalarx/utils",
|
|
3
|
+
"@nestjs/config",
|
|
4
|
+
"@nestjs/swagger",
|
|
5
|
+
"typeorm",
|
|
6
|
+
"pg",
|
|
7
|
+
"zod",
|
|
8
|
+
"@scalar/nestjs-api-reference"
|
|
9
|
+
];
|
|
10
|
+
export const CACHE_PACKAGES = ["ioredis"];
|
|
11
|
+
export const AUTH_PACKAGES = [
|
|
12
|
+
"@nestjs/jwt",
|
|
13
|
+
"@nestjs/passport",
|
|
14
|
+
"passport",
|
|
15
|
+
"passport-jwt",
|
|
16
|
+
"cookie-parser",
|
|
17
|
+
"bcrypt"
|
|
18
|
+
];
|
|
19
|
+
export const AUTH_DEV_PACKAGES = [
|
|
20
|
+
"@types/cookie-parser",
|
|
21
|
+
"@types/bcrypt"
|
|
22
|
+
];
|
|
23
|
+
export const CRON_PACKAGES = ["cron-parser"];
|
|
24
|
+
export const HEALTH_PACKAGES = ["@nestjs/terminus", "@nestjs/axios"];
|
|
25
|
+
export function devAddFlag(packageManager) {
|
|
26
|
+
switch (packageManager) {
|
|
27
|
+
case "npm":
|
|
28
|
+
return "-D";
|
|
29
|
+
case "pnpm":
|
|
30
|
+
return "-D";
|
|
31
|
+
default:
|
|
32
|
+
return "-d";
|
|
33
|
+
}
|
|
34
|
+
}
|