@dofe/infra-common 0.1.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/dist/adapters/base.adapter.d.ts +84 -0
- package/dist/adapters/base.adapter.d.ts.map +1 -0
- package/dist/adapters/base.adapter.js +19 -0
- package/dist/adapters/base.adapter.js.map +1 -0
- package/dist/adapters/index.d.ts +35 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +53 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/common.module.d.ts +7 -0
- package/dist/common.module.d.ts.map +1 -0
- package/dist/common.module.js +26 -0
- package/dist/common.module.js.map +1 -0
- package/dist/config/agentx.config.d.ts +37 -0
- package/dist/config/agentx.config.d.ts.map +1 -0
- package/dist/config/agentx.config.js +81 -0
- package/dist/config/agentx.config.js.map +1 -0
- package/dist/config/configuration.d.ts +55 -0
- package/dist/config/configuration.d.ts.map +1 -0
- package/dist/config/configuration.js +336 -0
- package/dist/config/configuration.js.map +1 -0
- package/dist/config/constant/config.constants.d.ts +48 -0
- package/dist/config/constant/config.constants.d.ts.map +1 -0
- package/dist/config/constant/config.constants.js +86 -0
- package/dist/config/constant/config.constants.js.map +1 -0
- package/dist/config/dto/config.dto.d.ts +222 -0
- package/dist/config/dto/config.dto.d.ts.map +1 -0
- package/dist/config/dto/config.dto.js +42 -0
- package/dist/config/dto/config.dto.js.map +1 -0
- package/dist/config/env-config.service.d.ts +147 -0
- package/dist/config/env-config.service.d.ts.map +1 -0
- package/dist/config/env-config.service.js +296 -0
- package/dist/config/env-config.service.js.map +1 -0
- package/dist/config/features/feature-errors.d.ts +13 -0
- package/dist/config/features/feature-errors.d.ts.map +1 -0
- package/dist/config/features/feature-errors.js +25 -0
- package/dist/config/features/feature-errors.js.map +1 -0
- package/dist/config/features/feature-registry.d.ts +26 -0
- package/dist/config/features/feature-registry.d.ts.map +1 -0
- package/dist/config/features/feature-registry.js +172 -0
- package/dist/config/features/feature-registry.js.map +1 -0
- package/dist/config/features/index.d.ts +4 -0
- package/dist/config/features/index.d.ts.map +1 -0
- package/dist/config/features/index.js +9 -0
- package/dist/config/features/index.js.map +1 -0
- package/dist/config/validation/env.validation.d.ts +132 -0
- package/dist/config/validation/env.validation.d.ts.map +1 -0
- package/dist/config/validation/env.validation.js +304 -0
- package/dist/config/validation/env.validation.js.map +1 -0
- package/dist/config/validation/index.d.ts +21 -0
- package/dist/config/validation/index.d.ts.map +1 -0
- package/dist/config/validation/index.js +119 -0
- package/dist/config/validation/index.js.map +1 -0
- package/dist/config/validation/keys.validation.d.ts +884 -0
- package/dist/config/validation/keys.validation.d.ts.map +1 -0
- package/dist/config/validation/keys.validation.js +506 -0
- package/dist/config/validation/keys.validation.js.map +1 -0
- package/dist/config/validation/yaml.validation.d.ts +765 -0
- package/dist/config/validation/yaml.validation.d.ts.map +1 -0
- package/dist/config/validation/yaml.validation.js +488 -0
- package/dist/config/validation/yaml.validation.js.map +1 -0
- package/dist/config/vendor.config.d.ts +48 -0
- package/dist/config/vendor.config.d.ts.map +1 -0
- package/dist/config/vendor.config.js +136 -0
- package/dist/config/vendor.config.js.map +1 -0
- package/dist/decorators/api-key/api-key.decorator.d.ts +25 -0
- package/dist/decorators/api-key/api-key.decorator.d.ts.map +1 -0
- package/dist/decorators/api-key/api-key.decorator.js +30 -0
- package/dist/decorators/api-key/api-key.decorator.js.map +1 -0
- package/dist/decorators/api-key/index.d.ts +2 -0
- package/dist/decorators/api-key/index.d.ts.map +1 -0
- package/dist/decorators/api-key/index.js +18 -0
- package/dist/decorators/api-key/index.js.map +1 -0
- package/dist/decorators/app-version/app-version.controller.d.ts +30 -0
- package/dist/decorators/app-version/app-version.controller.d.ts.map +1 -0
- package/dist/decorators/app-version/app-version.controller.js +159 -0
- package/dist/decorators/app-version/app-version.controller.js.map +1 -0
- package/dist/decorators/app-version/app-version.interceptor.d.ts +15 -0
- package/dist/decorators/app-version/app-version.interceptor.d.ts.map +1 -0
- package/dist/decorators/app-version/app-version.interceptor.js +42 -0
- package/dist/decorators/app-version/app-version.interceptor.js.map +1 -0
- package/dist/decorators/app-version/app-version.module.d.ts +8 -0
- package/dist/decorators/app-version/app-version.module.d.ts.map +1 -0
- package/dist/decorators/app-version/app-version.module.js +39 -0
- package/dist/decorators/app-version/app-version.module.js.map +1 -0
- package/dist/decorators/app-version/app-version.service.d.ts +88 -0
- package/dist/decorators/app-version/app-version.service.d.ts.map +1 -0
- package/dist/decorators/app-version/app-version.service.js +251 -0
- package/dist/decorators/app-version/app-version.service.js.map +1 -0
- package/dist/decorators/app-version/index.d.ts +8 -0
- package/dist/decorators/app-version/index.d.ts.map +1 -0
- package/dist/decorators/app-version/index.js +15 -0
- package/dist/decorators/app-version/index.js.map +1 -0
- package/dist/decorators/audit-log.decorator.d.ts +41 -0
- package/dist/decorators/audit-log.decorator.d.ts.map +1 -0
- package/dist/decorators/audit-log.decorator.js +19 -0
- package/dist/decorators/audit-log.decorator.js.map +1 -0
- package/dist/decorators/cache/cache.decorator.d.ts +256 -0
- package/dist/decorators/cache/cache.decorator.d.ts.map +1 -0
- package/dist/decorators/cache/cache.decorator.js +339 -0
- package/dist/decorators/cache/cache.decorator.js.map +1 -0
- package/dist/decorators/cache/cache.interceptor.d.ts +43 -0
- package/dist/decorators/cache/cache.interceptor.d.ts.map +1 -0
- package/dist/decorators/cache/cache.interceptor.js +219 -0
- package/dist/decorators/cache/cache.interceptor.js.map +1 -0
- package/dist/decorators/cache/cache.module.d.ts +9 -0
- package/dist/decorators/cache/cache.module.d.ts.map +1 -0
- package/dist/decorators/cache/cache.module.js +36 -0
- package/dist/decorators/cache/cache.module.js.map +1 -0
- package/dist/decorators/cache/index.d.ts +7 -0
- package/dist/decorators/cache/index.d.ts.map +1 -0
- package/dist/decorators/cache/index.js +32 -0
- package/dist/decorators/cache/index.js.map +1 -0
- package/dist/decorators/data-visibility/data-visibility.decorator.d.ts +74 -0
- package/dist/decorators/data-visibility/data-visibility.decorator.d.ts.map +1 -0
- package/dist/decorators/data-visibility/data-visibility.decorator.js +87 -0
- package/dist/decorators/data-visibility/data-visibility.decorator.js.map +1 -0
- package/dist/decorators/data-visibility/index.d.ts +2 -0
- package/dist/decorators/data-visibility/index.d.ts.map +1 -0
- package/dist/decorators/data-visibility/index.js +18 -0
- package/dist/decorators/data-visibility/index.js.map +1 -0
- package/dist/decorators/event/event.decorator.d.ts +152 -0
- package/dist/decorators/event/event.decorator.d.ts.map +1 -0
- package/dist/decorators/event/event.decorator.js +158 -0
- package/dist/decorators/event/event.decorator.js.map +1 -0
- package/dist/decorators/event/event.interceptor.d.ts +23 -0
- package/dist/decorators/event/event.interceptor.d.ts.map +1 -0
- package/dist/decorators/event/event.interceptor.js +140 -0
- package/dist/decorators/event/event.interceptor.js.map +1 -0
- package/dist/decorators/event/event.module.d.ts +9 -0
- package/dist/decorators/event/event.module.d.ts.map +1 -0
- package/dist/decorators/event/event.module.js +59 -0
- package/dist/decorators/event/event.module.js.map +1 -0
- package/dist/decorators/event/handlers/cache-event.handler.d.ts +55 -0
- package/dist/decorators/event/handlers/cache-event.handler.d.ts.map +1 -0
- package/dist/decorators/event/handlers/cache-event.handler.js +159 -0
- package/dist/decorators/event/handlers/cache-event.handler.js.map +1 -0
- package/dist/decorators/event/index.d.ts +8 -0
- package/dist/decorators/event/index.d.ts.map +1 -0
- package/dist/decorators/event/index.js +26 -0
- package/dist/decorators/event/index.js.map +1 -0
- package/dist/decorators/feature-flag/feature-flag.decorator.d.ts +144 -0
- package/dist/decorators/feature-flag/feature-flag.decorator.d.ts.map +1 -0
- package/dist/decorators/feature-flag/feature-flag.decorator.js +135 -0
- package/dist/decorators/feature-flag/feature-flag.decorator.js.map +1 -0
- package/dist/decorators/feature-flag/feature-flag.interceptor.d.ts +30 -0
- package/dist/decorators/feature-flag/feature-flag.interceptor.d.ts.map +1 -0
- package/dist/decorators/feature-flag/feature-flag.interceptor.js +127 -0
- package/dist/decorators/feature-flag/feature-flag.interceptor.js.map +1 -0
- package/dist/decorators/feature-flag/feature-flag.module.d.ts +9 -0
- package/dist/decorators/feature-flag/feature-flag.module.d.ts.map +1 -0
- package/dist/decorators/feature-flag/feature-flag.module.js +39 -0
- package/dist/decorators/feature-flag/feature-flag.module.js.map +1 -0
- package/dist/decorators/feature-flag/feature-flag.service.d.ts +102 -0
- package/dist/decorators/feature-flag/feature-flag.service.d.ts.map +1 -0
- package/dist/decorators/feature-flag/feature-flag.service.js +373 -0
- package/dist/decorators/feature-flag/feature-flag.service.js.map +1 -0
- package/dist/decorators/feature-flag/feature-flag.service.spec.d.ts +2 -0
- package/dist/decorators/feature-flag/feature-flag.service.spec.d.ts.map +1 -0
- package/dist/decorators/feature-flag/feature-flag.service.spec.js +264 -0
- package/dist/decorators/feature-flag/feature-flag.service.spec.js.map +1 -0
- package/dist/decorators/feature-flag/index.d.ts +8 -0
- package/dist/decorators/feature-flag/index.d.ts.map +1 -0
- package/dist/decorators/feature-flag/index.js +23 -0
- package/dist/decorators/feature-flag/index.js.map +1 -0
- package/dist/decorators/rate-limit/dto/rate-limit.dto.d.ts +174 -0
- package/dist/decorators/rate-limit/dto/rate-limit.dto.d.ts.map +1 -0
- package/dist/decorators/rate-limit/dto/rate-limit.dto.js +8 -0
- package/dist/decorators/rate-limit/dto/rate-limit.dto.js.map +1 -0
- package/dist/decorators/rate-limit/index.d.ts +24 -0
- package/dist/decorators/rate-limit/index.d.ts.map +1 -0
- package/dist/decorators/rate-limit/index.js +44 -0
- package/dist/decorators/rate-limit/index.js.map +1 -0
- package/dist/decorators/rate-limit/rate-limit.constants.d.ts +16 -0
- package/dist/decorators/rate-limit/rate-limit.constants.d.ts.map +1 -0
- package/dist/decorators/rate-limit/rate-limit.constants.js +22 -0
- package/dist/decorators/rate-limit/rate-limit.constants.js.map +1 -0
- package/dist/decorators/rate-limit/rate-limit.decorator.d.ts +132 -0
- package/dist/decorators/rate-limit/rate-limit.decorator.d.ts.map +1 -0
- package/dist/decorators/rate-limit/rate-limit.decorator.js +185 -0
- package/dist/decorators/rate-limit/rate-limit.decorator.js.map +1 -0
- package/dist/decorators/rate-limit/rate-limit.exception.d.ts +39 -0
- package/dist/decorators/rate-limit/rate-limit.exception.d.ts.map +1 -0
- package/dist/decorators/rate-limit/rate-limit.exception.js +67 -0
- package/dist/decorators/rate-limit/rate-limit.exception.js.map +1 -0
- package/dist/decorators/rate-limit/rate-limit.module.d.ts +25 -0
- package/dist/decorators/rate-limit/rate-limit.module.d.ts.map +1 -0
- package/dist/decorators/rate-limit/rate-limit.module.js +48 -0
- package/dist/decorators/rate-limit/rate-limit.module.js.map +1 -0
- package/dist/decorators/rate-limit/rate-limit.service.d.ts +102 -0
- package/dist/decorators/rate-limit/rate-limit.service.d.ts.map +1 -0
- package/dist/decorators/rate-limit/rate-limit.service.js +390 -0
- package/dist/decorators/rate-limit/rate-limit.service.js.map +1 -0
- package/dist/decorators/response.decorator.d.ts +10 -0
- package/dist/decorators/response.decorator.d.ts.map +1 -0
- package/dist/decorators/response.decorator.js +58 -0
- package/dist/decorators/response.decorator.js.map +1 -0
- package/dist/decorators/skip-version-check.decorator.d.ts +25 -0
- package/dist/decorators/skip-version-check.decorator.d.ts.map +1 -0
- package/dist/decorators/skip-version-check.decorator.js +31 -0
- package/dist/decorators/skip-version-check.decorator.js.map +1 -0
- package/dist/decorators/tenant/index.d.ts +2 -0
- package/dist/decorators/tenant/index.d.ts.map +1 -0
- package/dist/decorators/tenant/index.js +18 -0
- package/dist/decorators/tenant/index.js.map +1 -0
- package/dist/decorators/tenant/tenant.decorator.d.ts +82 -0
- package/dist/decorators/tenant/tenant.decorator.d.ts.map +1 -0
- package/dist/decorators/tenant/tenant.decorator.js +98 -0
- package/dist/decorators/tenant/tenant.decorator.js.map +1 -0
- package/dist/decorators/transaction/index.d.ts +6 -0
- package/dist/decorators/transaction/index.d.ts.map +1 -0
- package/dist/decorators/transaction/index.js +12 -0
- package/dist/decorators/transaction/index.js.map +1 -0
- package/dist/decorators/transaction/transactional.decorator.d.ts +234 -0
- package/dist/decorators/transaction/transactional.decorator.d.ts.map +1 -0
- package/dist/decorators/transaction/transactional.decorator.js +433 -0
- package/dist/decorators/transaction/transactional.decorator.js.map +1 -0
- package/dist/decorators/ts-rest-controller.decorator.d.ts +38 -0
- package/dist/decorators/ts-rest-controller.decorator.d.ts.map +1 -0
- package/dist/decorators/ts-rest-controller.decorator.js +25 -0
- package/dist/decorators/ts-rest-controller.decorator.js.map +1 -0
- package/dist/decorators/validation.decorator.d.ts +4 -0
- package/dist/decorators/validation.decorator.d.ts.map +1 -0
- package/dist/decorators/validation.decorator.js +121 -0
- package/dist/decorators/validation.decorator.js.map +1 -0
- package/dist/decorators/version/index.d.ts +7 -0
- package/dist/decorators/version/index.d.ts.map +1 -0
- package/dist/decorators/version/index.js +25 -0
- package/dist/decorators/version/index.js.map +1 -0
- package/dist/decorators/version/version.decorator.d.ts +96 -0
- package/dist/decorators/version/version.decorator.d.ts.map +1 -0
- package/dist/decorators/version/version.decorator.js +146 -0
- package/dist/decorators/version/version.decorator.js.map +1 -0
- package/dist/decorators/version/version.interceptor.d.ts +19 -0
- package/dist/decorators/version/version.interceptor.d.ts.map +1 -0
- package/dist/decorators/version/version.interceptor.js +86 -0
- package/dist/decorators/version/version.interceptor.js.map +1 -0
- package/dist/decorators/version/version.module.d.ts +8 -0
- package/dist/decorators/version/version.module.d.ts.map +1 -0
- package/dist/decorators/version/version.module.js +33 -0
- package/dist/decorators/version/version.module.js.map +1 -0
- package/dist/encryption.service.d.ts +15 -0
- package/dist/encryption.service.d.ts.map +1 -0
- package/dist/encryption.service.js +35 -0
- package/dist/encryption.service.js.map +1 -0
- package/dist/enums/action.enum.d.ts +8 -0
- package/dist/enums/action.enum.d.ts.map +1 -0
- package/dist/enums/action.enum.js +12 -0
- package/dist/enums/action.enum.js.map +1 -0
- package/dist/enums/error-codes.d.ts +33 -0
- package/dist/enums/error-codes.d.ts.map +1 -0
- package/dist/enums/error-codes.js +52 -0
- package/dist/enums/error-codes.js.map +1 -0
- package/dist/enums/role.enum.d.ts +5 -0
- package/dist/enums/role.enum.d.ts.map +1 -0
- package/dist/enums/role.enum.js +9 -0
- package/dist/enums/role.enum.js.map +1 -0
- package/dist/filter/exception/api.exception.d.ts +77 -0
- package/dist/filter/exception/api.exception.d.ts.map +1 -0
- package/dist/filter/exception/api.exception.js +151 -0
- package/dist/filter/exception/api.exception.js.map +1 -0
- package/dist/filter/exception/exception.d.ts +8 -0
- package/dist/filter/exception/exception.d.ts.map +1 -0
- package/dist/filter/exception/exception.js +50 -0
- package/dist/filter/exception/exception.js.map +1 -0
- package/dist/filter/exception/http.exception.d.ts +11 -0
- package/dist/filter/exception/http.exception.d.ts.map +1 -0
- package/dist/filter/exception/http.exception.js +152 -0
- package/dist/filter/exception/http.exception.js.map +1 -0
- package/dist/guards/api-key.guard.d.ts +42 -0
- package/dist/guards/api-key.guard.d.ts.map +1 -0
- package/dist/guards/api-key.guard.js +159 -0
- package/dist/guards/api-key.guard.js.map +1 -0
- package/dist/guards/auth.guard.d.ts +39 -0
- package/dist/guards/auth.guard.d.ts.map +1 -0
- package/dist/guards/auth.guard.js +178 -0
- package/dist/guards/auth.guard.js.map +1 -0
- package/dist/guards/data-visibility.guard.d.ts +18 -0
- package/dist/guards/data-visibility.guard.d.ts.map +1 -0
- package/dist/guards/data-visibility.guard.js +84 -0
- package/dist/guards/data-visibility.guard.js.map +1 -0
- package/dist/guards/index.d.ts +7 -0
- package/dist/guards/index.d.ts.map +1 -0
- package/dist/guards/index.js +23 -0
- package/dist/guards/index.js.map +1 -0
- package/dist/guards/permission.guard.d.ts +20 -0
- package/dist/guards/permission.guard.d.ts.map +1 -0
- package/dist/guards/permission.guard.js +141 -0
- package/dist/guards/permission.guard.js.map +1 -0
- package/dist/guards/tenant-context.guard.d.ts +12 -0
- package/dist/guards/tenant-context.guard.d.ts.map +1 -0
- package/dist/guards/tenant-context.guard.js +94 -0
- package/dist/guards/tenant-context.guard.js.map +1 -0
- package/dist/guards/version.guard.d.ts +100 -0
- package/dist/guards/version.guard.d.ts.map +1 -0
- package/dist/guards/version.guard.js +233 -0
- package/dist/guards/version.guard.js.map +1 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptor/audit/audit-log.interceptor.d.ts +16 -0
- package/dist/interceptor/audit/audit-log.interceptor.d.ts.map +1 -0
- package/dist/interceptor/audit/audit-log.interceptor.js +156 -0
- package/dist/interceptor/audit/audit-log.interceptor.js.map +1 -0
- package/dist/interceptor/audit/index.d.ts +2 -0
- package/dist/interceptor/audit/index.d.ts.map +1 -0
- package/dist/interceptor/audit/index.js +18 -0
- package/dist/interceptor/audit/index.js.map +1 -0
- package/dist/interceptor/mask/index.d.ts +2 -0
- package/dist/interceptor/mask/index.d.ts.map +1 -0
- package/dist/interceptor/mask/index.js +18 -0
- package/dist/interceptor/mask/index.js.map +1 -0
- package/dist/interceptor/mask/mask.interceptor.d.ts +79 -0
- package/dist/interceptor/mask/mask.interceptor.d.ts.map +1 -0
- package/dist/interceptor/mask/mask.interceptor.js +197 -0
- package/dist/interceptor/mask/mask.interceptor.js.map +1 -0
- package/dist/interceptor/rate-limit/no-rate-limit.interceptor.d.ts +6 -0
- package/dist/interceptor/rate-limit/no-rate-limit.interceptor.d.ts.map +1 -0
- package/dist/interceptor/rate-limit/no-rate-limit.interceptor.js +20 -0
- package/dist/interceptor/rate-limit/no-rate-limit.interceptor.js.map +1 -0
- package/dist/interceptor/rate-limit/rate-limit.interceptor.d.ts +45 -0
- package/dist/interceptor/rate-limit/rate-limit.interceptor.d.ts.map +1 -0
- package/dist/interceptor/rate-limit/rate-limit.interceptor.js +193 -0
- package/dist/interceptor/rate-limit/rate-limit.interceptor.js.map +1 -0
- package/dist/interceptor/transform/transform.interceptor.d.ts +37 -0
- package/dist/interceptor/transform/transform.interceptor.d.ts.map +1 -0
- package/dist/interceptor/transform/transform.interceptor.js +72 -0
- package/dist/interceptor/transform/transform.interceptor.js.map +1 -0
- package/dist/interceptor/transform/transform.interceptor.spec.d.ts +2 -0
- package/dist/interceptor/transform/transform.interceptor.spec.d.ts.map +1 -0
- package/dist/interceptor/transform/transform.interceptor.spec.js +9 -0
- package/dist/interceptor/transform/transform.interceptor.spec.js.map +1 -0
- package/dist/interceptor/version/index.d.ts +2 -0
- package/dist/interceptor/version/index.d.ts.map +1 -0
- package/dist/interceptor/version/index.js +18 -0
- package/dist/interceptor/version/index.js.map +1 -0
- package/dist/interceptor/version/version-header.interceptor.d.ts +31 -0
- package/dist/interceptor/version/version-header.interceptor.d.ts.map +1 -0
- package/dist/interceptor/version/version-header.interceptor.js +62 -0
- package/dist/interceptor/version/version-header.interceptor.js.map +1 -0
- package/dist/middleware/request.middleware.d.ts +27 -0
- package/dist/middleware/request.middleware.d.ts.map +1 -0
- package/dist/middleware/request.middleware.js +141 -0
- package/dist/middleware/request.middleware.js.map +1 -0
- package/dist/middleware/tenant-isolation.middleware.d.ts +12 -0
- package/dist/middleware/tenant-isolation.middleware.d.ts.map +1 -0
- package/dist/middleware/tenant-isolation.middleware.js +51 -0
- package/dist/middleware/tenant-isolation.middleware.js.map +1 -0
- package/dist/pipes/transform-root.pipe.d.ts +5 -0
- package/dist/pipes/transform-root.pipe.d.ts.map +1 -0
- package/dist/pipes/transform-root.pipe.js +24 -0
- package/dist/pipes/transform-root.pipe.js.map +1 -0
- package/dist/ts-rest/index.d.ts +36 -0
- package/dist/ts-rest/index.d.ts.map +1 -0
- package/dist/ts-rest/index.js +65 -0
- package/dist/ts-rest/index.js.map +1 -0
- package/dist/ts-rest/response.helper.d.ts +261 -0
- package/dist/ts-rest/response.helper.d.ts.map +1 -0
- package/dist/ts-rest/response.helper.js +372 -0
- package/dist/ts-rest/response.helper.js.map +1 -0
- package/dist/utils/audit-log-helper.util.d.ts +41 -0
- package/dist/utils/audit-log-helper.util.d.ts.map +1 -0
- package/dist/utils/audit-log-helper.util.js +115 -0
- package/dist/utils/audit-log-helper.util.js.map +1 -0
- package/dist/utils/audit-signature.util.d.ts +64 -0
- package/dist/utils/audit-signature.util.d.ts.map +1 -0
- package/dist/utils/audit-signature.util.js +155 -0
- package/dist/utils/audit-signature.util.js.map +1 -0
- package/dist/utils/prisma-error.util.d.ts +160 -0
- package/dist/utils/prisma-error.util.d.ts.map +1 -0
- package/dist/utils/prisma-error.util.js +342 -0
- package/dist/utils/prisma-error.util.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rate Limit Service
|
|
4
|
+
*
|
|
5
|
+
* 限流服务,使用 Redis Sorted Set 实现滑动窗口算法
|
|
6
|
+
*
|
|
7
|
+
* 特性:
|
|
8
|
+
* - 多维度限流 (IP, userId, tenantId, apiKey)
|
|
9
|
+
* - Redis 分布式存储
|
|
10
|
+
* - Feature Flag 动态开关
|
|
11
|
+
* - 白名单支持
|
|
12
|
+
* - 结构化日志和监控
|
|
13
|
+
*
|
|
14
|
+
* 配置项 (config.local.yaml):
|
|
15
|
+
* ```yaml
|
|
16
|
+
* rateLimit:
|
|
17
|
+
* enabled: true
|
|
18
|
+
* featureFlag: 'rate-limit-enabled'
|
|
19
|
+
* default:
|
|
20
|
+
* limit: 100
|
|
21
|
+
* window: 60
|
|
22
|
+
* dimensions:
|
|
23
|
+
* ip: { limit: 200, window: 60 }
|
|
24
|
+
* userId: { limit: 500, window: 60 }
|
|
25
|
+
* tenantId: { limit: 2000, window: 60 }
|
|
26
|
+
* apiKey: { limit: 1000, window: 60 }
|
|
27
|
+
* redis:
|
|
28
|
+
* keyPrefix: 'pardx:ratelimit:'
|
|
29
|
+
* whitelist:
|
|
30
|
+
* ips: ['127.0.0.1', '::1']
|
|
31
|
+
* userIds: []
|
|
32
|
+
* apiKeys: []
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
36
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
37
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
38
|
+
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;
|
|
39
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
|
+
};
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.RateLimitService = void 0;
|
|
52
|
+
const common_1 = require("@nestjs/common");
|
|
53
|
+
const config_1 = require("@nestjs/config");
|
|
54
|
+
const nest_winston_1 = require("nest-winston");
|
|
55
|
+
const winston_1 = require("winston");
|
|
56
|
+
const infra_redis_1 = require("@dofe/infra-redis");
|
|
57
|
+
const feature_flag_service_1 = require("../feature-flag/feature-flag.service");
|
|
58
|
+
const environment_util_1 = __importDefault(require("@dofe/infra-utils/environment.util"));
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// Constants
|
|
61
|
+
// ============================================================================
|
|
62
|
+
const DEFAULT_CONFIG = {
|
|
63
|
+
enabled: true,
|
|
64
|
+
featureFlag: 'rate-limit-enabled',
|
|
65
|
+
default: { limit: 100, window: 60 },
|
|
66
|
+
dimensions: {
|
|
67
|
+
ip: { limit: 200, window: 60 },
|
|
68
|
+
userId: { limit: 500, window: 60 },
|
|
69
|
+
tenantId: { limit: 2000, window: 60 },
|
|
70
|
+
apiKey: { limit: 1000, window: 60 },
|
|
71
|
+
},
|
|
72
|
+
redis: { keyPrefix: 'pardx:ratelimit:' },
|
|
73
|
+
whitelist: { ips: ['127.0.0.1', '::1'], userIds: [], apiKeys: [] },
|
|
74
|
+
};
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// Service
|
|
77
|
+
// ============================================================================
|
|
78
|
+
let RateLimitService = class RateLimitService {
|
|
79
|
+
configService;
|
|
80
|
+
redis;
|
|
81
|
+
featureFlagService;
|
|
82
|
+
logger;
|
|
83
|
+
config = DEFAULT_CONFIG;
|
|
84
|
+
keyPrefix = 'pardx:ratelimit:';
|
|
85
|
+
constructor(configService, redis, featureFlagService, logger) {
|
|
86
|
+
this.configService = configService;
|
|
87
|
+
this.redis = redis;
|
|
88
|
+
this.featureFlagService = featureFlagService;
|
|
89
|
+
this.logger = logger;
|
|
90
|
+
}
|
|
91
|
+
async onModuleInit() {
|
|
92
|
+
const config = this.configService.get('rateLimit');
|
|
93
|
+
if (config) {
|
|
94
|
+
this.config = {
|
|
95
|
+
...DEFAULT_CONFIG,
|
|
96
|
+
...config,
|
|
97
|
+
dimensions: {
|
|
98
|
+
...DEFAULT_CONFIG.dimensions,
|
|
99
|
+
...config.dimensions,
|
|
100
|
+
},
|
|
101
|
+
whitelist: {
|
|
102
|
+
...DEFAULT_CONFIG.whitelist,
|
|
103
|
+
...config.whitelist,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
this.keyPrefix = config.redis?.keyPrefix || 'pardx:ratelimit:';
|
|
107
|
+
}
|
|
108
|
+
if (environment_util_1.default.isProduction()) {
|
|
109
|
+
this.logger.info('RateLimitService module initialized', {
|
|
110
|
+
enabled: this.config.enabled,
|
|
111
|
+
keyPrefix: this.keyPrefix,
|
|
112
|
+
dimensions: Object.keys(this.config.dimensions),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// =========================================================================
|
|
117
|
+
// Public Methods
|
|
118
|
+
// =========================================================================
|
|
119
|
+
/**
|
|
120
|
+
* 检查限流是否启用
|
|
121
|
+
*/
|
|
122
|
+
async isEnabled() {
|
|
123
|
+
if (!this.config.enabled) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
// 通过 Feature Flag 动态控制
|
|
127
|
+
if (this.featureFlagService && this.config.featureFlag) {
|
|
128
|
+
return await this.featureFlagService.isEnabled(this.config.featureFlag);
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 检查特定 Feature Flag 是否启用
|
|
134
|
+
*/
|
|
135
|
+
async isFeatureEnabled(flagName) {
|
|
136
|
+
if (!this.featureFlagService) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
return await this.featureFlagService.isEnabled(flagName);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 检查是否在白名单中
|
|
143
|
+
*/
|
|
144
|
+
isWhitelisted(context) {
|
|
145
|
+
const { whitelist } = this.config;
|
|
146
|
+
if (whitelist.ips.includes(context.ip)) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
if (context.userId && whitelist.userIds.includes(context.userId)) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (context.apiKey && whitelist.apiKeys.includes(context.apiKey)) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* 执行限流检查
|
|
159
|
+
*
|
|
160
|
+
* @param context 限流上下文
|
|
161
|
+
* @param options 限流选项
|
|
162
|
+
* @returns 限流检查结果
|
|
163
|
+
*/
|
|
164
|
+
async checkRateLimit(context, options) {
|
|
165
|
+
const dimension = options.dimension || this.selectBestDimension(context);
|
|
166
|
+
const identifier = this.getIdentifier(context, dimension);
|
|
167
|
+
const key = this.generateKey(context, options, dimension, identifier);
|
|
168
|
+
// 获取限流配置
|
|
169
|
+
const limit = options.limit || this.getDimensionConfig(dimension).limit;
|
|
170
|
+
const window = options.window || this.getDimensionConfig(dimension).window;
|
|
171
|
+
const now = Math.floor(Date.now() / 1000);
|
|
172
|
+
const windowStart = now - window;
|
|
173
|
+
try {
|
|
174
|
+
// 使用 Redis Sorted Set 实现滑动窗口
|
|
175
|
+
const multi = this.redis.redis.multi();
|
|
176
|
+
// 1. 移除过期的记录
|
|
177
|
+
multi.zremrangebyscore(key, 0, windowStart);
|
|
178
|
+
// 2. 获取当前窗口内的请求数
|
|
179
|
+
multi.zcard(key);
|
|
180
|
+
// 3. 添加当前请求 (使用 traceId 确保唯一性)
|
|
181
|
+
multi.zadd(key, now.toString(), `${now}:${context.traceId}`);
|
|
182
|
+
// 4. 设置过期时间
|
|
183
|
+
multi.expire(key, window + 1);
|
|
184
|
+
const results = await multi.exec();
|
|
185
|
+
// zcard 的结果在 results[1][1]
|
|
186
|
+
const currentCount = results?.[1]?.[1] || 0;
|
|
187
|
+
const allowed = currentCount < limit;
|
|
188
|
+
const result = {
|
|
189
|
+
allowed,
|
|
190
|
+
limit,
|
|
191
|
+
remaining: Math.max(0, limit - currentCount - 1),
|
|
192
|
+
resetTime: now + window,
|
|
193
|
+
retryAfter: window,
|
|
194
|
+
dimension,
|
|
195
|
+
identifier,
|
|
196
|
+
};
|
|
197
|
+
// 记录事件
|
|
198
|
+
this.logEvent({
|
|
199
|
+
type: allowed ? 'allowed' : 'blocked',
|
|
200
|
+
traceId: context.traceId,
|
|
201
|
+
dimension,
|
|
202
|
+
identifier,
|
|
203
|
+
path: context.path,
|
|
204
|
+
method: context.method,
|
|
205
|
+
currentCount: currentCount + 1,
|
|
206
|
+
limit,
|
|
207
|
+
userId: context.userId,
|
|
208
|
+
ip: context.ip,
|
|
209
|
+
timestamp: new Date(),
|
|
210
|
+
});
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
this.logger.error('Rate limit check failed', {
|
|
215
|
+
error: error.message,
|
|
216
|
+
key,
|
|
217
|
+
traceId: context.traceId,
|
|
218
|
+
});
|
|
219
|
+
// 降级: Redis 出错时放行请求
|
|
220
|
+
return {
|
|
221
|
+
allowed: true,
|
|
222
|
+
limit,
|
|
223
|
+
remaining: limit - 1,
|
|
224
|
+
resetTime: now + window,
|
|
225
|
+
retryAfter: window,
|
|
226
|
+
dimension,
|
|
227
|
+
identifier,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* 获取当前的限流状态 (不增加计数)
|
|
233
|
+
*/
|
|
234
|
+
async getRateLimitStatus(context, options) {
|
|
235
|
+
const dimension = options.dimension || this.selectBestDimension(context);
|
|
236
|
+
const identifier = this.getIdentifier(context, dimension);
|
|
237
|
+
const key = this.generateKey(context, options, dimension, identifier);
|
|
238
|
+
const limit = options.limit || this.getDimensionConfig(dimension).limit;
|
|
239
|
+
const window = options.window || this.getDimensionConfig(dimension).window;
|
|
240
|
+
const now = Math.floor(Date.now() / 1000);
|
|
241
|
+
const windowStart = now - window;
|
|
242
|
+
try {
|
|
243
|
+
// 只读取当前计数
|
|
244
|
+
await this.redis.redis.zremrangebyscore(key, 0, windowStart);
|
|
245
|
+
const currentCount = await this.redis.redis.zcard(key);
|
|
246
|
+
return {
|
|
247
|
+
allowed: currentCount < limit,
|
|
248
|
+
limit,
|
|
249
|
+
remaining: Math.max(0, limit - currentCount),
|
|
250
|
+
resetTime: now + window,
|
|
251
|
+
retryAfter: window,
|
|
252
|
+
dimension,
|
|
253
|
+
identifier,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
this.logger.error('Rate limit status check failed', {
|
|
258
|
+
error: error.message,
|
|
259
|
+
key,
|
|
260
|
+
});
|
|
261
|
+
return {
|
|
262
|
+
allowed: true,
|
|
263
|
+
limit,
|
|
264
|
+
remaining: limit,
|
|
265
|
+
resetTime: now + window,
|
|
266
|
+
retryAfter: window,
|
|
267
|
+
dimension,
|
|
268
|
+
identifier,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* 重置限流计数
|
|
274
|
+
*/
|
|
275
|
+
async resetRateLimit(context, options) {
|
|
276
|
+
const dimension = options.dimension || this.selectBestDimension(context);
|
|
277
|
+
const identifier = this.getIdentifier(context, dimension);
|
|
278
|
+
const key = this.generateKey(context, options, dimension, identifier);
|
|
279
|
+
try {
|
|
280
|
+
await this.redis.redis.del(key);
|
|
281
|
+
this.logger.info('Rate limit reset', {
|
|
282
|
+
key,
|
|
283
|
+
dimension,
|
|
284
|
+
identifier,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
this.logger.error('Rate limit reset failed', {
|
|
289
|
+
error: error.message,
|
|
290
|
+
key,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// =========================================================================
|
|
295
|
+
// Private Methods
|
|
296
|
+
// =========================================================================
|
|
297
|
+
/**
|
|
298
|
+
* 自动选择最佳限流维度
|
|
299
|
+
* 优先级: apiKey > userId > tenantId > ip
|
|
300
|
+
*/
|
|
301
|
+
selectBestDimension(context) {
|
|
302
|
+
if (context.apiKey)
|
|
303
|
+
return 'apiKey';
|
|
304
|
+
if (context.userId)
|
|
305
|
+
return 'userId';
|
|
306
|
+
if (context.tenantId)
|
|
307
|
+
return 'tenantId';
|
|
308
|
+
return 'ip';
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* 获取维度的标识符值
|
|
312
|
+
*/
|
|
313
|
+
getIdentifier(context, dimension) {
|
|
314
|
+
switch (dimension) {
|
|
315
|
+
case 'apiKey':
|
|
316
|
+
return context.apiKey || 'unknown';
|
|
317
|
+
case 'userId':
|
|
318
|
+
return context.userId || 'anonymous';
|
|
319
|
+
case 'tenantId':
|
|
320
|
+
return context.tenantId || 'default';
|
|
321
|
+
case 'ip':
|
|
322
|
+
default:
|
|
323
|
+
return context.ip;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* 生成 Redis key
|
|
328
|
+
*
|
|
329
|
+
* 格式: {prefix}{dimension}:{identifier}:{normalizedPath}
|
|
330
|
+
* 例如: pardx:ratelimit:userId:user-123:/api/export
|
|
331
|
+
*/
|
|
332
|
+
generateKey(context, options, dimension, identifier) {
|
|
333
|
+
// 如果有自定义 keyGenerator,使用它
|
|
334
|
+
if (options.keyGenerator) {
|
|
335
|
+
return `${this.keyPrefix}${options.keyGenerator(context)}`;
|
|
336
|
+
}
|
|
337
|
+
// 规范化路径: 移除 query string,替换 UUID/数字 ID
|
|
338
|
+
const normalizedPath = context.path
|
|
339
|
+
.split('?')[0]
|
|
340
|
+
.replace(/\/[0-9a-f-]{36}/gi, '/:id') // UUID
|
|
341
|
+
.replace(/\/\d+/g, '/:id'); // 数字 ID
|
|
342
|
+
return `${this.keyPrefix}${dimension}:${identifier}:${normalizedPath}`;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* 获取维度配置
|
|
346
|
+
*/
|
|
347
|
+
getDimensionConfig(dimension) {
|
|
348
|
+
if (dimension === 'composite') {
|
|
349
|
+
return this.config.default;
|
|
350
|
+
}
|
|
351
|
+
return this.config.dimensions[dimension] || this.config.default;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* 记录限流事件
|
|
355
|
+
*/
|
|
356
|
+
logEvent(event) {
|
|
357
|
+
const logData = {
|
|
358
|
+
type: event.type,
|
|
359
|
+
traceId: event.traceId,
|
|
360
|
+
dimension: event.dimension,
|
|
361
|
+
identifier: event.identifier,
|
|
362
|
+
path: event.path,
|
|
363
|
+
method: event.method,
|
|
364
|
+
count: event.currentCount,
|
|
365
|
+
limit: event.limit,
|
|
366
|
+
userId: event.userId,
|
|
367
|
+
ip: event.ip,
|
|
368
|
+
};
|
|
369
|
+
if (event.type === 'blocked') {
|
|
370
|
+
this.logger.warn('Rate limit exceeded', logData);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
// 只在高负载时记录 allowed 事件
|
|
374
|
+
if (event.currentCount >= event.limit * 0.8) {
|
|
375
|
+
this.logger.info('Rate limit approaching', logData);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
exports.RateLimitService = RateLimitService;
|
|
381
|
+
exports.RateLimitService = RateLimitService = __decorate([
|
|
382
|
+
(0, common_1.Injectable)(),
|
|
383
|
+
__param(2, (0, common_1.Optional)()),
|
|
384
|
+
__param(3, (0, common_1.Inject)(nest_winston_1.WINSTON_MODULE_PROVIDER)),
|
|
385
|
+
__metadata("design:paramtypes", [config_1.ConfigService,
|
|
386
|
+
infra_redis_1.RedisService,
|
|
387
|
+
feature_flag_service_1.FeatureFlagService,
|
|
388
|
+
winston_1.Logger])
|
|
389
|
+
], RateLimitService);
|
|
390
|
+
//# sourceMappingURL=rate-limit.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limit.service.js","sourceRoot":"","sources":["../../../src/decorators/rate-limit/rate-limit.service.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;;;;;;;;;;;;;;;;;AAEH,2CAA4E;AAC5E,2CAA+C;AAC/C,+CAAuD;AACvD,qCAAiC;AACjC,mDAAiD;AACjD,+EAA0E;AAW1E,0FAA4D;AAE5D,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,cAAc,GAAoB;IACtC,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,oBAAoB;IACjC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE;IACnC,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE;QAC9B,MAAM,EAAE,EAAE,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BAAU,GAAE;IAQR,WAAA,IAAA,iBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,eAAM,EAAC,sCAAuB,CAAC,CAAA;qCAHA,sBAAa;QACrB,0BAAY;QACa,yCAAkB;QACT,gBAAM;GARvD,gBAAgB,CAkW5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* 封装 swagger 返回统一结构
|
|
4
|
+
* 支持复杂类型 { code, msg, data }
|
|
5
|
+
* @param model 返回的 data 的数据类型
|
|
6
|
+
* @param isArray data 是否是数组
|
|
7
|
+
* @param isPager 设置为 true, 则 data 类型为 { list, total } , false data 类型是纯数组
|
|
8
|
+
*/
|
|
9
|
+
export declare const ApiResponse: <TModel extends Type<any>>(model?: TModel, isArray?: boolean, isPager?: boolean) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
10
|
+
//# sourceMappingURL=response.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/response.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,gBAAgB,CAAC;AAMvD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,SAAS,IAAI,CAAC,GAAG,CAAC,EAClD,QAAQ,MAAM,EACd,UAAU,OAAO,EACjB,UAAU,OAAO,gJAkDlB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiResponse = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
const infra_utils_1 = require("@dofe/infra-utils");
|
|
7
|
+
const baseTypeNames = ['String', 'Number', 'Boolean'];
|
|
8
|
+
/**
|
|
9
|
+
* 封装 swagger 返回统一结构
|
|
10
|
+
* 支持复杂类型 { code, msg, data }
|
|
11
|
+
* @param model 返回的 data 的数据类型
|
|
12
|
+
* @param isArray data 是否是数组
|
|
13
|
+
* @param isPager 设置为 true, 则 data 类型为 { list, total } , false data 类型是纯数组
|
|
14
|
+
*/
|
|
15
|
+
const ApiResponse = (model, isArray, isPager) => {
|
|
16
|
+
const modelIsBaseType = model && baseTypeNames.includes(model.name);
|
|
17
|
+
const items = modelIsBaseType
|
|
18
|
+
? { type: model.name.toLocaleLowerCase() }
|
|
19
|
+
: model
|
|
20
|
+
? { $ref: (0, swagger_1.getSchemaPath)(model) }
|
|
21
|
+
: null;
|
|
22
|
+
const prop = isArray && isPager
|
|
23
|
+
? {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
list: {
|
|
27
|
+
type: 'array',
|
|
28
|
+
items,
|
|
29
|
+
},
|
|
30
|
+
total: {
|
|
31
|
+
type: 'number',
|
|
32
|
+
default: 0,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
: isArray
|
|
37
|
+
? {
|
|
38
|
+
type: 'array',
|
|
39
|
+
items,
|
|
40
|
+
}
|
|
41
|
+
: items
|
|
42
|
+
? items
|
|
43
|
+
: { type: 'null', default: null };
|
|
44
|
+
return (0, common_1.applyDecorators)((0, swagger_1.ApiExtraModels)(...(model && !modelIsBaseType ? [infra_utils_1.Response, model] : [infra_utils_1.Response])), (0, swagger_1.ApiOkResponse)({
|
|
45
|
+
schema: {
|
|
46
|
+
allOf: [
|
|
47
|
+
{ $ref: (0, swagger_1.getSchemaPath)(infra_utils_1.Response) },
|
|
48
|
+
{
|
|
49
|
+
properties: {
|
|
50
|
+
data: prop,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
exports.ApiResponse = ApiResponse;
|
|
58
|
+
//# sourceMappingURL=response.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.decorator.js","sourceRoot":"","sources":["../../src/decorators/response.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AACvD,6CAA+E;AAC/E,mDAA6C;AAE7C,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAEtD;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,CACzB,KAAc,EACd,OAAiB,EACjB,OAAiB,EACjB,EAAE;IACF,MAAM,eAAe,GAAG,KAAK,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpE,MAAM,KAAK,GAAG,eAAe;QAC3B,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE;QAC1C,CAAC,CAAC,KAAK;YACL,CAAC,CAAC,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,KAAK,CAAC,EAAE;YAChC,CAAC,CAAC,IAAI,CAAC;IAEX,MAAM,IAAI,GACR,OAAO,IAAI,OAAO;QAChB,CAAC,CAAC;YACE,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,KAAK;iBACN;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,CAAC;iBACX;aACF;SACF;QACH,CAAC,CAAC,OAAO;YACP,CAAC,CAAC;gBACE,IAAI,EAAE,OAAO;gBACb,KAAK;aACN;YACH,CAAC,CAAC,KAAK;gBACL,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAE1C,OAAO,IAAA,wBAAe,EACpB,IAAA,wBAAc,EACZ,GAAG,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,sBAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAQ,CAAC,CAAC,CAChE,EACD,IAAA,uBAAa,EAAC;QACZ,MAAM,EAAE;YACN,KAAK,EAAE;gBACL,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,sBAAQ,CAAC,EAAE;gBACjC;oBACE,UAAU,EAAE;wBACV,IAAI,EAAE,IAAI;qBACX;iBACF;aACF;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AArDW,QAAA,WAAW,eAqDtB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skip Version Check Decorator
|
|
3
|
+
* 跳过版本检查装饰器
|
|
4
|
+
*
|
|
5
|
+
* 标记的控制器或方法将跳过 VersionGuard 的版本检查。
|
|
6
|
+
* 适用于健康检查、版本信息等不需要版本控制的端点。
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // 跳过整个控制器
|
|
11
|
+
* @SkipVersionCheck()
|
|
12
|
+
* @Controller('health')
|
|
13
|
+
* export class HealthController { ... }
|
|
14
|
+
*
|
|
15
|
+
* // 跳过单个方法
|
|
16
|
+
* @Controller('api')
|
|
17
|
+
* export class ApiController {
|
|
18
|
+
* @SkipVersionCheck()
|
|
19
|
+
* @Get('version')
|
|
20
|
+
* getVersion() { ... }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const SkipVersionCheck: () => import("@nestjs/common").CustomDecorator<string>;
|
|
25
|
+
//# sourceMappingURL=skip-version-check.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skip-version-check.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/skip-version-check.decorator.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,gBAAgB,wDAA8C,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SkipVersionCheck = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const version_guard_1 = require("../guards/version.guard");
|
|
6
|
+
/**
|
|
7
|
+
* Skip Version Check Decorator
|
|
8
|
+
* 跳过版本检查装饰器
|
|
9
|
+
*
|
|
10
|
+
* 标记的控制器或方法将跳过 VersionGuard 的版本检查。
|
|
11
|
+
* 适用于健康检查、版本信息等不需要版本控制的端点。
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // 跳过整个控制器
|
|
16
|
+
* @SkipVersionCheck()
|
|
17
|
+
* @Controller('health')
|
|
18
|
+
* export class HealthController { ... }
|
|
19
|
+
*
|
|
20
|
+
* // 跳过单个方法
|
|
21
|
+
* @Controller('api')
|
|
22
|
+
* export class ApiController {
|
|
23
|
+
* @SkipVersionCheck()
|
|
24
|
+
* @Get('version')
|
|
25
|
+
* getVersion() { ... }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const SkipVersionCheck = () => (0, common_1.SetMetadata)(version_guard_1.SKIP_VERSION_CHECK, true);
|
|
30
|
+
exports.SkipVersionCheck = SkipVersionCheck;
|
|
31
|
+
//# sourceMappingURL=skip-version-check.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skip-version-check.decorator.js","sourceRoot":"","sources":["../../src/decorators/skip-version-check.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAC7C,2DAA6D;AAE7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACI,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,kCAAkB,EAAE,IAAI,CAAC,CAAC;AAA/D,QAAA,gBAAgB,oBAA+C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/decorators/tenant/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./tenant.decorator"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/tenant/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Permission } from '@dofe/infra-contracts';
|
|
2
|
+
/**
|
|
3
|
+
* 公共端点装饰器 - 标记不需要认证的端点
|
|
4
|
+
*/
|
|
5
|
+
export declare const Public: () => import("@nestjs/common").CustomDecorator<"isPublicEndpoint">;
|
|
6
|
+
/**
|
|
7
|
+
* 租户范围装饰器 - 标记需要租户上下文的端点
|
|
8
|
+
*/
|
|
9
|
+
export declare const TenantScope: () => import("@nestjs/common").CustomDecorator<"requiresTenantScope">;
|
|
10
|
+
/**
|
|
11
|
+
* 要求权限装饰器 - 标记需要特定权限的端点
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* @RequirePermissions(PERMISSION.GATEWAY_READ)
|
|
16
|
+
* async listGateways() { ... }
|
|
17
|
+
*
|
|
18
|
+
* @RequirePermissions([PERMISSION.BOT_CREATE, PERMISSION.BOT_UPDATE])
|
|
19
|
+
* async createOrUpdateBot() { ... }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const RequirePermissions: (permissions: Permission | Permission[]) => import("@nestjs/common").CustomDecorator<"requirePermissions">;
|
|
23
|
+
/**
|
|
24
|
+
* 租户 API 装饰器 - 组合认证、租户上下文和权限检查
|
|
25
|
+
* 应用于需要租户上下文和权限检查的 API 端点
|
|
26
|
+
*
|
|
27
|
+
* @param permissions 需要的权限
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* @TenantApi(PERMISSION.GATEWAY_READ)
|
|
32
|
+
* async listGateways() { ... }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const TenantApi: (permissions: Permission | Permission[]) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
36
|
+
/**
|
|
37
|
+
* 当前租户参数装饰器 - 从请求中提取当前租户 ID
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* async list(@CurrentTenant() tenantId: string) { ... }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const CurrentTenant: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
45
|
+
/**
|
|
46
|
+
* 当前租户成员参数装饰器 - 从请求中提取当前租户成员信息
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* async getInfo(@CurrentTenantMember() member: TenantMember) { ... }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const CurrentTenantMember: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
54
|
+
/**
|
|
55
|
+
* 团队上下文信息
|
|
56
|
+
*/
|
|
57
|
+
export interface TeamContext {
|
|
58
|
+
/** 当前租户/团队 ID */
|
|
59
|
+
tenantId: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 当前团队参数装饰器 - 从请求中提取团队上下文
|
|
63
|
+
* 别名装饰器,与 @CurrentTenant() 提供相同的租户上下文,但语义更偏向"团队"
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* async list(@TeamInfo() teamInfo: TeamContext) { ... }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare const TeamInfo: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
71
|
+
/**
|
|
72
|
+
* 从请求中提取团队 ID
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const teamId = getTeamId(req);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function getTeamId(request: {
|
|
80
|
+
tenantId?: string;
|
|
81
|
+
}): string;
|
|
82
|
+
//# sourceMappingURL=tenant.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant.decorator.d.ts","sourceRoot":"","sources":["../../../src/decorators/tenant/tenant.decorator.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,UAAU,EACX,MAAM,uBAAuB,CAAC;AAK/B;;GAEG;AACH,eAAO,MAAM,MAAM,oEAA+C,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,WAAW,uEAA4C,CAAC;AAErE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,GAAI,aAAa,UAAU,GAAG,UAAU,EAAE,mEAItE,CAAC;AAEJ;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GAAI,aAAa,UAAU,GAAG,UAAU,EAAE,gJAK7D,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,mDAKzB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,mDAK/B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iBAAiB;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,mDAOpB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEhE"}
|