@nest-omni/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boilerplate.polyfill.d.ts +39 -0
- package/dist/boilerplate.polyfill.js +66 -0
- package/dist/boilerplate.polyfill.js.map +1 -0
- package/dist/common/abstract-client.service.d.ts +16 -0
- package/dist/common/abstract-client.service.js +26 -0
- package/dist/common/abstract-client.service.js.map +1 -0
- package/dist/common/abstract.entity.d.ts +17 -0
- package/dist/common/abstract.entity.js +71 -0
- package/dist/common/abstract.entity.js.map +1 -0
- package/dist/common/dto/abstract.dto.d.ts +13 -0
- package/dist/common/dto/abstract.dto.js +63 -0
- package/dist/common/dto/abstract.dto.js.map +1 -0
- package/dist/common/dto/bulk-id.dto.d.ts +3 -0
- package/dist/common/dto/bulk-id.dto.js +29 -0
- package/dist/common/dto/bulk-id.dto.js.map +1 -0
- package/dist/common/dto/create-translation.dto.d.ts +5 -0
- package/dist/common/dto/create-translation.dto.js +28 -0
- package/dist/common/dto/create-translation.dto.js.map +1 -0
- package/dist/common/dto/page-meta.dto.d.ts +15 -0
- package/dist/common/dto/page-meta.dto.js +55 -0
- package/dist/common/dto/page-meta.dto.js.map +1 -0
- package/dist/common/dto/page-options.dto.d.ts +8 -0
- package/dist/common/dto/page-options.dto.js +52 -0
- package/dist/common/dto/page-options.dto.js.map +1 -0
- package/dist/common/dto/page.dto.d.ts +11 -0
- package/dist/common/dto/page.dto.js +61 -0
- package/dist/common/dto/page.dto.js.map +1 -0
- package/dist/common/utils.d.ts +3 -0
- package/dist/common/utils.js +26 -0
- package/dist/common/utils.js.map +1 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.js +21 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/language-code.d.ts +5 -0
- package/dist/constants/language-code.js +10 -0
- package/dist/constants/language-code.js.map +1 -0
- package/dist/constants/order.d.ts +4 -0
- package/dist/constants/order.js +9 -0
- package/dist/constants/order.js.map +1 -0
- package/dist/constants/role-type.d.ts +4 -0
- package/dist/constants/role-type.js +9 -0
- package/dist/constants/role-type.js.map +1 -0
- package/dist/constants/token-type.d.ts +4 -0
- package/dist/constants/token-type.js +9 -0
- package/dist/constants/token-type.js.map +1 -0
- package/dist/decorators/api-page-ok-response.decorator.d.ts +5 -0
- package/dist/decorators/api-page-ok-response.decorator.js +26 -0
- package/dist/decorators/api-page-ok-response.decorator.js.map +1 -0
- package/dist/decorators/auth-user.decorator.d.ts +1 -0
- package/dist/decorators/auth-user.decorator.js +16 -0
- package/dist/decorators/auth-user.decorator.js.map +1 -0
- package/dist/decorators/controller.decorator.d.ts +1 -0
- package/dist/decorators/controller.decorator.js +12 -0
- package/dist/decorators/controller.decorator.js.map +1 -0
- package/dist/decorators/field.decorators.d.ts +71 -0
- package/dist/decorators/field.decorators.js +457 -0
- package/dist/decorators/field.decorators.js.map +1 -0
- package/dist/decorators/http.decorators.d.ts +3 -0
- package/dist/decorators/http.decorators.js +9 -0
- package/dist/decorators/http.decorators.js.map +1 -0
- package/dist/decorators/index.d.ts +12 -0
- package/dist/decorators/index.js +29 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/omni-auth.decorator.d.ts +8 -0
- package/dist/decorators/omni-auth.decorator.js +36 -0
- package/dist/decorators/omni-auth.decorator.js.map +1 -0
- package/dist/decorators/operation.decorator.d.ts +1 -0
- package/dist/decorators/operation.decorator.js +7 -0
- package/dist/decorators/operation.decorator.js.map +1 -0
- package/dist/decorators/property.decorators.d.ts +15 -0
- package/dist/decorators/property.decorators.js +43 -0
- package/dist/decorators/property.decorators.js.map +1 -0
- package/dist/decorators/public-route.decorator.d.ts +3 -0
- package/dist/decorators/public-route.decorator.js +8 -0
- package/dist/decorators/public-route.decorator.js.map +1 -0
- package/dist/decorators/swagger.schema.d.ts +5 -0
- package/dist/decorators/swagger.schema.js +80 -0
- package/dist/decorators/swagger.schema.js.map +1 -0
- package/dist/decorators/timestamp-column.decorator.d.ts +1 -0
- package/dist/decorators/timestamp-column.decorator.js +29 -0
- package/dist/decorators/timestamp-column.decorator.js.map +1 -0
- package/dist/decorators/transform.decorators.d.ts +8 -0
- package/dist/decorators/transform.decorators.js +96 -0
- package/dist/decorators/transform.decorators.js.map +1 -0
- package/dist/decorators/translate.decorator.d.ts +5 -0
- package/dist/decorators/translate.decorator.js +18 -0
- package/dist/decorators/translate.decorator.js.map +1 -0
- package/dist/decorators/use-dto.decorator.d.ts +4 -0
- package/dist/decorators/use-dto.decorator.js +10 -0
- package/dist/decorators/use-dto.decorator.js.map +1 -0
- package/dist/decorators/user-check.decorator.d.ts +6 -0
- package/dist/decorators/user-check.decorator.js +22 -0
- package/dist/decorators/user-check.decorator.js.map +1 -0
- package/dist/decorators/user.decorator.d.ts +8 -0
- package/dist/decorators/user.decorator.js +39 -0
- package/dist/decorators/user.decorator.js.map +1 -0
- package/dist/decorators/user_auth.decorator.d.ts +1 -0
- package/dist/decorators/user_auth.decorator.js +17 -0
- package/dist/decorators/user_auth.decorator.js.map +1 -0
- package/dist/decorators/validator.decorators.d.ts +10 -0
- package/dist/decorators/validator.decorators.js +63 -0
- package/dist/decorators/validator.decorators.js.map +1 -0
- package/dist/exceptions/file-not-image.exception.d.ts +4 -0
- package/dist/exceptions/file-not-image.exception.js +11 -0
- package/dist/exceptions/file-not-image.exception.js.map +1 -0
- package/dist/exceptions/index.d.ts +2 -0
- package/dist/exceptions/index.js +19 -0
- package/dist/exceptions/index.js.map +1 -0
- package/dist/exceptions/page-type.exception.d.ts +4 -0
- package/dist/exceptions/page-type.exception.js +11 -0
- package/dist/exceptions/page-type.exception.js.map +1 -0
- package/dist/exceptions/user-not-found.exception.d.ts +4 -0
- package/dist/exceptions/user-not-found.exception.js +11 -0
- package/dist/exceptions/user-not-found.exception.js.map +1 -0
- package/dist/filters/bad-request.filter.d.ts +5 -0
- package/dist/filters/bad-request.filter.js +65 -0
- package/dist/filters/bad-request.filter.js.map +1 -0
- package/dist/filters/constraint-errors.d.ts +1 -0
- package/dist/filters/constraint-errors.js +7 -0
- package/dist/filters/constraint-errors.js.map +1 -0
- package/dist/filters/index.d.ts +3 -0
- package/dist/filters/index.js +20 -0
- package/dist/filters/index.js.map +1 -0
- package/dist/filters/query-failed.filter.d.ts +10 -0
- package/dist/filters/query-failed.filter.js +43 -0
- package/dist/filters/query-failed.filter.js.map +1 -0
- package/dist/guards/auth.guard.d.ts +4 -0
- package/dist/guards/auth.guard.js +13 -0
- package/dist/guards/auth.guard.js.map +1 -0
- package/dist/guards/roles.guard.d.ts +7 -0
- package/dist/guards/roles.guard.js +36 -0
- package/dist/guards/roles.guard.js.map +1 -0
- package/dist/health-checker/health-checker.controller.d.ts +15 -0
- package/dist/health-checker/health-checker.controller.js +68 -0
- package/dist/health-checker/health-checker.controller.js.map +1 -0
- package/dist/health-checker/health-checker.module.d.ts +2 -0
- package/dist/health-checker/health-checker.module.js +26 -0
- package/dist/health-checker/health-checker.module.js.map +1 -0
- package/dist/health-checker/health-indicators/service.indicator.d.ts +8 -0
- package/dist/health-checker/health-indicators/service.indicator.js +57 -0
- package/dist/health-checker/health-indicators/service.indicator.js.map +1 -0
- package/dist/helpers/common.helper.d.ts +3 -0
- package/dist/helpers/common.helper.js +37 -0
- package/dist/helpers/common.helper.js.map +1 -0
- package/dist/helpers/date.helper.d.ts +10 -0
- package/dist/helpers/date.helper.js +59 -0
- package/dist/helpers/date.helper.js.map +1 -0
- package/dist/helpers/excel.helper.d.ts +12 -0
- package/dist/helpers/excel.helper.js +250 -0
- package/dist/helpers/excel.helper.js.map +1 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.js +20 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors/auth-user.interceptor.d.ts +4 -0
- package/dist/interceptors/auth-user.interceptor.js +25 -0
- package/dist/interceptors/auth-user.interceptor.js.map +1 -0
- package/dist/interceptors/index.d.ts +2 -0
- package/dist/interceptors/index.js +19 -0
- package/dist/interceptors/index.js.map +1 -0
- package/dist/interceptors/language-interceptor.service.d.ts +6 -0
- package/dist/interceptors/language-interceptor.service.js +31 -0
- package/dist/interceptors/language-interceptor.service.js.map +1 -0
- package/dist/interceptors/translation-interceptor.service.d.ts +5 -0
- package/dist/interceptors/translation-interceptor.service.js +35 -0
- package/dist/interceptors/translation-interceptor.service.js.map +1 -0
- package/dist/interfaces/IApiFile.d.ts +4 -0
- package/dist/interfaces/IApiFile.js +3 -0
- package/dist/interfaces/IApiFile.js.map +1 -0
- package/dist/interfaces/IFile.d.ts +9 -0
- package/dist/interfaces/IFile.js +3 -0
- package/dist/interfaces/IFile.js.map +1 -0
- package/dist/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
- package/dist/interfaces/ITranslationDecoratorInterface.js +3 -0
- package/dist/interfaces/ITranslationDecoratorInterface.js.map +1 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.js +20 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/response.d.ts +25 -0
- package/dist/interfaces/response.js +3 -0
- package/dist/interfaces/response.js.map +1 -0
- package/dist/middlewares/index.d.ts +3 -0
- package/dist/middlewares/index.js +20 -0
- package/dist/middlewares/index.js.map +1 -0
- package/dist/middlewares/omni-auth.middleware.d.ts +1 -0
- package/dist/middlewares/omni-auth.middleware.js +14 -0
- package/dist/middlewares/omni-auth.middleware.js.map +1 -0
- package/dist/middlewares/powerby.middleware.d.ts +1 -0
- package/dist/middlewares/powerby.middleware.js +11 -0
- package/dist/middlewares/powerby.middleware.js.map +1 -0
- package/dist/middlewares/request-id.middleware.d.ts +7 -0
- package/dist/middlewares/request-id.middleware.js +23 -0
- package/dist/middlewares/request-id.middleware.js.map +1 -0
- package/dist/providers/context.provider.d.ts +32 -0
- package/dist/providers/context.provider.js +71 -0
- package/dist/providers/context.provider.js.map +1 -0
- package/dist/providers/generator.provider.d.ts +9 -0
- package/dist/providers/generator.provider.js +51 -0
- package/dist/providers/generator.provider.js.map +1 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +19 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/setup/bootstrap.setup.d.ts +5 -0
- package/dist/setup/bootstrap.setup.js +102 -0
- package/dist/setup/bootstrap.setup.js.map +1 -0
- package/dist/setup/index.d.ts +1 -0
- package/dist/setup/index.js +18 -0
- package/dist/setup/index.js.map +1 -0
- package/dist/setup-swagger.d.ts +2 -0
- package/dist/setup-swagger.js +63 -0
- package/dist/setup-swagger.js.map +1 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +19 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/serviceRegistryModule.d.ts +2 -0
- package/dist/shared/serviceRegistryModule.js +102 -0
- package/dist/shared/serviceRegistryModule.js.map +1 -0
- package/dist/shared/services/api-config.service.d.ts +70 -0
- package/dist/shared/services/api-config.service.js +286 -0
- package/dist/shared/services/api-config.service.js.map +1 -0
- package/dist/shared/services/aws-s3.service.d.ts +10 -0
- package/dist/shared/services/aws-s3.service.js +49 -0
- package/dist/shared/services/aws-s3.service.js.map +1 -0
- package/dist/shared/services/generator.service.d.ts +4 -0
- package/dist/shared/services/generator.service.js +24 -0
- package/dist/shared/services/generator.service.js.map +1 -0
- package/dist/shared/services/index.d.ts +5 -0
- package/dist/shared/services/index.js +22 -0
- package/dist/shared/services/index.js.map +1 -0
- package/dist/shared/services/translation.service.d.ts +9 -0
- package/dist/shared/services/translation.service.js +61 -0
- package/dist/shared/services/translation.service.js.map +1 -0
- package/dist/shared/services/validator.service.d.ts +3 -0
- package/dist/shared/services/validator.service.js +21 -0
- package/dist/shared/services/validator.service.js.map +1 -0
- package/dist/snake-naming.strategy.d.ts +11 -0
- package/dist/snake-naming.strategy.js +38 -0
- package/dist/snake-naming.strategy.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validators/file-mimetype.validator.d.ts +13 -0
- package/dist/validators/file-mimetype.validator.js +24 -0
- package/dist/validators/file-mimetype.validator.js.map +1 -0
- package/dist/validators/index.d.ts +3 -0
- package/dist/validators/index.js +20 -0
- package/dist/validators/index.js.map +1 -0
- package/dist/validators/is-exists.validator.d.ts +18 -0
- package/dist/validators/is-exists.validator.js +52 -0
- package/dist/validators/is-exists.validator.js.map +1 -0
- package/dist/validators/is-unique.validator.d.ts +17 -0
- package/dist/validators/is-unique.validator.js +83 -0
- package/dist/validators/is-unique.validator.js.map +1 -0
- package/dist/validators/phone-country-code.validator.d.ts +2 -0
- package/dist/validators/phone-country-code.validator.js +31 -0
- package/dist/validators/phone-country-code.validator.js.map +1 -0
- package/dist/validators/same-as.validator.d.ts +2 -0
- package/dist/validators/same-as.validator.js +26 -0
- package/dist/validators/same-as.validator.js.map +1 -0
- package/dist/validators/skip-empty.validator.d.ts +1 -0
- package/dist/validators/skip-empty.validator.js +19 -0
- package/dist/validators/skip-empty.validator.js.map +1 -0
- package/package.json +66 -0
- package/src/boilerplate.polyfill.d.ts +39 -0
- package/src/boilerplate.polyfill.js +78 -0
- package/src/boilerplate.polyfill.ts +202 -0
- package/src/common/abstract-client.service.d.ts +20 -0
- package/src/common/abstract-client.service.js +39 -0
- package/src/common/abstract-client.service.ts +56 -0
- package/src/common/abstract.entity.d.ts +24 -0
- package/src/common/abstract.entity.js +152 -0
- package/src/common/abstract.entity.ts +73 -0
- package/src/common/dto/abstract.dto.d.ts +13 -0
- package/src/common/dto/abstract.dto.js +96 -0
- package/src/common/dto/abstract.dto.ts +64 -0
- package/src/common/dto/bulk-id.dto.d.ts +3 -0
- package/src/common/dto/bulk-id.dto.js +63 -0
- package/src/common/dto/bulk-id.dto.ts +13 -0
- package/src/common/dto/create-translation.dto.d.ts +5 -0
- package/src/common/dto/create-translation.dto.js +63 -0
- package/src/common/dto/create-translation.dto.ts +10 -0
- package/src/common/dto/page-meta.dto.d.ts +15 -0
- package/src/common/dto/page-meta.dto.js +88 -0
- package/src/common/dto/page-meta.dto.ts +37 -0
- package/src/common/dto/page-options.dto.d.ts +8 -0
- package/src/common/dto/page-options.dto.js +87 -0
- package/src/common/dto/page-options.dto.ts +35 -0
- package/src/common/dto/page.dto.d.ts +11 -0
- package/src/common/dto/page.dto.js +94 -0
- package/src/common/dto/page.dto.ts +36 -0
- package/src/common/utils.d.ts +14 -0
- package/src/common/utils.js +39 -0
- package/src/common/utils.ts +45 -0
- package/src/constants/index.d.ts +4 -0
- package/src/constants/index.js +20 -0
- package/src/constants/index.ts +4 -0
- package/src/constants/language-code.d.ts +5 -0
- package/src/constants/language-code.js +10 -0
- package/src/constants/language-code.ts +7 -0
- package/src/constants/order.d.ts +4 -0
- package/src/constants/order.js +8 -0
- package/src/constants/order.ts +4 -0
- package/src/constants/role-type.d.ts +4 -0
- package/src/constants/role-type.js +8 -0
- package/src/constants/role-type.ts +4 -0
- package/src/constants/token-type.d.ts +4 -0
- package/src/constants/token-type.js +8 -0
- package/src/constants/token-type.ts +4 -0
- package/src/decorators/api-page-ok-response.decorator.d.ts +5 -0
- package/src/decorators/api-page-ok-response.decorator.js +25 -0
- package/src/decorators/api-page-ok-response.decorator.ts +31 -0
- package/src/decorators/auth-user.decorator.d.ts +1 -0
- package/src/decorators/auth-user.decorator.js +15 -0
- package/src/decorators/auth-user.decorator.ts +16 -0
- package/src/decorators/controller.decorator.d.ts +1 -0
- package/src/decorators/controller.decorator.js +34 -0
- package/src/decorators/controller.decorator.ts +8 -0
- package/src/decorators/field.decorators.d.ts +71 -0
- package/src/decorators/field.decorators.js +455 -0
- package/src/decorators/field.decorators.ts +773 -0
- package/src/decorators/http.decorators.d.ts +3 -0
- package/src/decorators/http.decorators.js +8 -0
- package/src/decorators/http.decorators.ts +10 -0
- package/src/decorators/index.d.ts +12 -0
- package/src/decorators/index.js +28 -0
- package/src/decorators/index.ts +12 -0
- package/src/decorators/omni-auth.decorator.d.ts +8 -0
- package/src/decorators/omni-auth.decorator.js +60 -0
- package/src/decorators/omni-auth.decorator.ts +46 -0
- package/src/decorators/operation.decorator.d.ts +1 -0
- package/src/decorators/operation.decorator.js +6 -0
- package/src/decorators/operation.decorator.ts +4 -0
- package/src/decorators/property.decorators.d.ts +15 -0
- package/src/decorators/property.decorators.js +36 -0
- package/src/decorators/property.decorators.ts +62 -0
- package/src/decorators/public-route.decorator.d.ts +3 -0
- package/src/decorators/public-route.decorator.js +8 -0
- package/src/decorators/public-route.decorator.ts +8 -0
- package/src/decorators/swagger.schema.d.ts +5 -0
- package/src/decorators/swagger.schema.js +82 -0
- package/src/decorators/swagger.schema.ts +117 -0
- package/src/decorators/timestamp-column.decorator.d.ts +1 -0
- package/src/decorators/timestamp-column.decorator.js +28 -0
- package/src/decorators/timestamp-column.decorator.ts +29 -0
- package/src/decorators/transform.decorators.d.ts +35 -0
- package/src/decorators/transform.decorators.js +122 -0
- package/src/decorators/transform.decorators.ts +147 -0
- package/src/decorators/translate.decorator.d.ts +5 -0
- package/src/decorators/translate.decorator.js +18 -0
- package/src/decorators/translate.decorator.ts +19 -0
- package/src/decorators/use-dto.decorator.d.ts +4 -0
- package/src/decorators/use-dto.decorator.js +9 -0
- package/src/decorators/use-dto.decorator.ts +11 -0
- package/src/decorators/user-check.decorator.d.ts +6 -0
- package/src/decorators/user-check.decorator.js +44 -0
- package/src/decorators/user-check.decorator.ts +30 -0
- package/src/decorators/user.decorator.d.ts +8 -0
- package/src/decorators/user.decorator.js +62 -0
- package/src/decorators/user.decorator.ts +48 -0
- package/src/decorators/user_auth.decorator.d.ts +1 -0
- package/src/decorators/user_auth.decorator.js +16 -0
- package/src/decorators/user_auth.decorator.ts +15 -0
- package/src/decorators/validator.decorators.d.ts +10 -0
- package/src/decorators/validator.decorators.js +59 -0
- package/src/decorators/validator.decorators.ts +78 -0
- package/src/exceptions/file-not-image.exception.d.ts +4 -0
- package/src/exceptions/file-not-image.exception.js +10 -0
- package/src/exceptions/file-not-image.exception.ts +7 -0
- package/src/exceptions/index.d.ts +2 -0
- package/src/exceptions/index.js +18 -0
- package/src/exceptions/index.ts +2 -0
- package/src/exceptions/page-type.exception.d.ts +4 -0
- package/src/exceptions/page-type.exception.js +10 -0
- package/src/exceptions/page-type.exception.ts +7 -0
- package/src/exceptions/user-not-found.exception.d.ts +4 -0
- package/src/exceptions/user-not-found.exception.js +10 -0
- package/src/exceptions/user-not-found.exception.ts +7 -0
- package/src/filters/bad-request.filter.d.ts +5 -0
- package/src/filters/bad-request.filter.js +104 -0
- package/src/filters/bad-request.filter.ts +67 -0
- package/src/filters/constraint-errors.d.ts +1 -0
- package/src/filters/constraint-errors.js +7 -0
- package/src/filters/constraint-errors.ts +5 -0
- package/src/filters/index.d.ts +3 -0
- package/src/filters/index.js +19 -0
- package/src/filters/index.ts +3 -0
- package/src/filters/query-failed.filter.d.ts +10 -0
- package/src/filters/query-failed.filter.js +81 -0
- package/src/filters/query-failed.filter.ts +32 -0
- package/src/health-checker/health-checker.controller.d.ts +15 -0
- package/src/health-checker/health-checker.controller.js +104 -0
- package/src/health-checker/health-checker.controller.ts +51 -0
- package/src/health-checker/health-checker.module.d.ts +2 -0
- package/src/health-checker/health-checker.module.js +69 -0
- package/src/health-checker/health-checker.module.ts +13 -0
- package/src/health-checker/health-indicators/service.indicator.d.ts +8 -0
- package/src/health-checker/health-indicators/service.indicator.js +102 -0
- package/src/health-checker/health-indicators/service.indicator.ts +44 -0
- package/src/helpers/common.helper.d.ts +16 -0
- package/src/helpers/common.helper.js +49 -0
- package/src/helpers/common.helper.ts +49 -0
- package/src/helpers/date.helper.d.ts +10 -0
- package/src/helpers/date.helper.js +81 -0
- package/src/helpers/date.helper.ts +64 -0
- package/src/helpers/excel.helper.d.ts +27 -0
- package/src/helpers/excel.helper.js +338 -0
- package/src/helpers/index.d.ts +3 -0
- package/src/helpers/index.js +19 -0
- package/src/helpers/index.ts +3 -0
- package/src/i18n/en_US/validation.json +38 -0
- package/src/i18n/zh_CN/validation.json +38 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +28 -0
- package/src/index.ts +12 -0
- package/src/interceptors/auth-user.interceptor.d.ts +4 -0
- package/src/interceptors/auth-user.interceptor.js +68 -0
- package/src/interceptors/auth-user.interceptor.ts +20 -0
- package/src/interceptors/index.d.ts +2 -0
- package/src/interceptors/index.js +18 -0
- package/src/interceptors/index.ts +2 -0
- package/src/interceptors/language-interceptor.service.d.ts +6 -0
- package/src/interceptors/language-interceptor.service.js +74 -0
- package/src/interceptors/language-interceptor.service.ts +31 -0
- package/src/interceptors/translation-interceptor.service.d.ts +5 -0
- package/src/interceptors/translation-interceptor.service.js +83 -0
- package/src/interceptors/translation-interceptor.service.ts +43 -0
- package/src/interfaces/IApiFile.d.ts +4 -0
- package/src/interfaces/IApiFile.js +2 -0
- package/src/interfaces/IApiFile.ts +4 -0
- package/src/interfaces/IFile.d.ts +9 -0
- package/src/interfaces/IFile.js +2 -0
- package/src/interfaces/IFile.ts +8 -0
- package/src/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
- package/src/interfaces/ITranslationDecoratorInterface.js +2 -0
- package/src/interfaces/ITranslationDecoratorInterface.ts +3 -0
- package/src/interfaces/index.d.ts +3 -0
- package/src/interfaces/index.js +19 -0
- package/src/interfaces/index.ts +3 -0
- package/src/interfaces/response.d.ts +25 -0
- package/src/interfaces/response.js +2 -0
- package/src/interfaces/response.ts +37 -0
- package/src/middlewares/index.d.ts +3 -0
- package/src/middlewares/index.js +19 -0
- package/src/middlewares/index.ts +3 -0
- package/src/middlewares/omni-auth.middleware.d.ts +1 -0
- package/src/middlewares/omni-auth.middleware.js +13 -0
- package/src/middlewares/omni-auth.middleware.ts +10 -0
- package/src/middlewares/powerby.middleware.d.ts +1 -0
- package/src/middlewares/powerby.middleware.js +10 -0
- package/src/middlewares/powerby.middleware.ts +6 -0
- package/src/middlewares/request-id.middleware.d.ts +7 -0
- package/src/middlewares/request-id.middleware.js +22 -0
- package/src/middlewares/request-id.middleware.ts +28 -0
- package/src/providers/context.provider.d.ts +32 -0
- package/src/providers/context.provider.js +73 -0
- package/src/providers/context.provider.ts +98 -0
- package/src/providers/generator.provider.d.ts +13 -0
- package/src/providers/generator.provider.js +54 -0
- package/src/providers/generator.provider.ts +66 -0
- package/src/providers/index.d.ts +2 -0
- package/src/providers/index.js +18 -0
- package/src/providers/index.ts +2 -0
- package/src/setup/bootstrap.setup.d.ts +5 -0
- package/src/setup/bootstrap.setup.js +138 -0
- package/src/setup/bootstrap.setup.ts +139 -0
- package/src/setup/index.d.ts +1 -0
- package/src/setup/index.js +17 -0
- package/src/setup/index.ts +1 -0
- package/src/setup/microservices.setup.js +55 -0
- package/src/setup-swagger.d.ts +2 -0
- package/src/setup-swagger.js +62 -0
- package/src/setup-swagger.ts +67 -0
- package/src/shared/index.d.ts +2 -0
- package/src/shared/index.js +18 -0
- package/src/shared/index.ts +2 -0
- package/src/shared/serviceRegistryModule.d.ts +2 -0
- package/src/shared/serviceRegistryModule.js +176 -0
- package/src/shared/serviceRegistryModule.ts +110 -0
- package/src/shared/services/api-config.service.d.ts +73 -0
- package/src/shared/services/api-config.service.js +335 -0
- package/src/shared/services/api-config.service.ts +319 -0
- package/src/shared/services/aws-s3.service.d.ts +10 -0
- package/src/shared/services/aws-s3.service.js +96 -0
- package/src/shared/services/aws-s3.service.ts +39 -0
- package/src/shared/services/generator.service.d.ts +4 -0
- package/src/shared/services/generator.service.js +67 -0
- package/src/shared/services/generator.service.ts +13 -0
- package/src/shared/services/index.d.ts +5 -0
- package/src/shared/services/index.js +21 -0
- package/src/shared/services/index.ts +5 -0
- package/src/shared/services/translation.service.d.ts +9 -0
- package/src/shared/services/translation.service.js +109 -0
- package/src/shared/services/translation.service.ts +59 -0
- package/src/shared/services/validator.service.d.ts +3 -0
- package/src/shared/services/validator.service.js +64 -0
- package/src/shared/services/validator.service.ts +10 -0
- package/src/snake-naming.strategy.d.ts +11 -0
- package/src/snake-naming.strategy.js +37 -0
- package/src/snake-naming.strategy.ts +64 -0
- package/src/types.d.ts +9 -0
- package/src/types.js +2 -0
- package/src/types.ts +44 -0
- package/src/validators/file-mimetype.validator.d.ts +13 -0
- package/src/validators/file-mimetype.validator.js +21 -0
- package/src/validators/file-mimetype.validator.ts +34 -0
- package/src/validators/index.d.ts +3 -0
- package/src/validators/index.js +19 -0
- package/src/validators/index.ts +3 -0
- package/src/validators/is-exists.validator.d.ts +18 -0
- package/src/validators/is-exists.validator.js +99 -0
- package/src/validators/is-exists.validator.ts +60 -0
- package/src/validators/is-unique.validator.d.ts +17 -0
- package/src/validators/is-unique.validator.js +131 -0
- package/src/validators/is-unique.validator.ts +93 -0
- package/src/validators/phone-country-code.validator.d.ts +2 -0
- package/src/validators/phone-country-code.validator.js +30 -0
- package/src/validators/phone-country-code.validator.ts +36 -0
- package/src/validators/same-as.validator.d.ts +2 -0
- package/src/validators/same-as.validator.js +25 -0
- package/src/validators/same-as.validator.ts +27 -0
- package/src/validators/skip-empty.validator.d.ts +6 -0
- package/src/validators/skip-empty.validator.js +23 -0
- package/src/validators/skip-empty.validator.ts +25 -0
- package/tsconfig.json +21 -0
- package/tsconfig.lib.json +16 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
export type Constructor<T, Arguments extends unknown[] = undefined[]> = new (
|
|
3
|
+
...arguments_: Arguments
|
|
4
|
+
) => T;
|
|
5
|
+
|
|
6
|
+
export type Plain<T> = T;
|
|
7
|
+
|
|
8
|
+
export type PathImpl<T, Key extends keyof T> = Key extends string
|
|
9
|
+
? T[Key] extends Record<string, any>
|
|
10
|
+
?
|
|
11
|
+
| `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> &
|
|
12
|
+
string}`
|
|
13
|
+
| `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}`
|
|
14
|
+
: never
|
|
15
|
+
: never;
|
|
16
|
+
|
|
17
|
+
export type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
|
|
18
|
+
|
|
19
|
+
export type Path<T> = keyof T extends string
|
|
20
|
+
? PathImpl2<T> extends string | keyof T
|
|
21
|
+
? PathImpl2<T>
|
|
22
|
+
: keyof T
|
|
23
|
+
: never;
|
|
24
|
+
|
|
25
|
+
export type PathValue<
|
|
26
|
+
T,
|
|
27
|
+
P extends Path<T>,
|
|
28
|
+
> = P extends `${infer Key}.${infer Rest}`
|
|
29
|
+
? Key extends keyof T
|
|
30
|
+
? Rest extends Path<T[Key]>
|
|
31
|
+
? PathValue<T[Key], Rest>
|
|
32
|
+
: never
|
|
33
|
+
: never
|
|
34
|
+
: P extends keyof T
|
|
35
|
+
? T[P]
|
|
36
|
+
: never;
|
|
37
|
+
|
|
38
|
+
export type KeyOfType<Entity, U> = {
|
|
39
|
+
[P in keyof Required<Entity>]: Required<Entity>[P] extends U
|
|
40
|
+
? P
|
|
41
|
+
: Required<Entity>[P] extends U[]
|
|
42
|
+
? P
|
|
43
|
+
: never;
|
|
44
|
+
}[keyof Entity];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FileValidator } from '@nestjs/common/pipes/file/file-validator.interface';
|
|
2
|
+
import { IFile } from '@nestjs/common/pipes/file/interfaces';
|
|
3
|
+
export type FileMimetypeValidatorOptions = {
|
|
4
|
+
allowedMimetypes: string[];
|
|
5
|
+
message?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class FileMimetypeValidator extends FileValidator<FileMimetypeValidatorOptions, IFile> {
|
|
8
|
+
private allowedMimetypes;
|
|
9
|
+
private message;
|
|
10
|
+
constructor(options: FileMimetypeValidatorOptions);
|
|
11
|
+
buildErrorMessage(): string;
|
|
12
|
+
isValid(file?: IFile): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileMimetypeValidator = void 0;
|
|
4
|
+
const file_validator_interface_1 = require("@nestjs/common/pipes/file/file-validator.interface");
|
|
5
|
+
class FileMimetypeValidator extends file_validator_interface_1.FileValidator {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(options);
|
|
8
|
+
this.allowedMimetypes = options.allowedMimetypes;
|
|
9
|
+
this.message = options.message;
|
|
10
|
+
}
|
|
11
|
+
buildErrorMessage() {
|
|
12
|
+
if (this.message) {
|
|
13
|
+
return this.message;
|
|
14
|
+
}
|
|
15
|
+
return `Invalid file type. Only ${this.allowedMimetypes.join(', ')} are allowed.`;
|
|
16
|
+
}
|
|
17
|
+
isValid(file) {
|
|
18
|
+
return this.allowedMimetypes.includes(file.mimetype);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.FileMimetypeValidator = FileMimetypeValidator;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FileValidator } from '@nestjs/common/pipes/file/file-validator.interface';
|
|
2
|
+
import { IFile } from '@nestjs/common/pipes/file/interfaces';
|
|
3
|
+
|
|
4
|
+
export type FileMimetypeValidatorOptions = {
|
|
5
|
+
allowedMimetypes: string[];
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export class FileMimetypeValidator extends FileValidator<
|
|
10
|
+
FileMimetypeValidatorOptions,
|
|
11
|
+
IFile
|
|
12
|
+
> {
|
|
13
|
+
private allowedMimetypes: string[];
|
|
14
|
+
private message: string;
|
|
15
|
+
|
|
16
|
+
constructor(options: FileMimetypeValidatorOptions) {
|
|
17
|
+
super(options);
|
|
18
|
+
this.allowedMimetypes = options.allowedMimetypes;
|
|
19
|
+
this.message = options.message;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
buildErrorMessage(): string {
|
|
23
|
+
if (this.message) {
|
|
24
|
+
return this.message;
|
|
25
|
+
}
|
|
26
|
+
return `Invalid file type. Only ${this.allowedMimetypes.join(
|
|
27
|
+
', ',
|
|
28
|
+
)} are allowed.`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
isValid(file?: IFile): boolean {
|
|
32
|
+
return this.allowedMimetypes.includes(file.mimetype);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./phone-country-code.validator"), exports);
|
|
18
|
+
__exportStar(require("./skip-empty.validator"), exports);
|
|
19
|
+
__exportStar(require("./file-mimetype.validator"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
+
import type { EntitySchema, FindOptionsWhere, ObjectType } from 'typeorm';
|
|
3
|
+
import { DataSource } from 'typeorm';
|
|
4
|
+
export declare class IsExistsValidator implements ValidatorConstraintInterface {
|
|
5
|
+
private readonly dataSource;
|
|
6
|
+
constructor(dataSource: DataSource);
|
|
7
|
+
validate<E>(value: string, args: IExistsValidationArguments<E>): Promise<boolean>;
|
|
8
|
+
defaultMessage(args: ValidationArguments): string;
|
|
9
|
+
}
|
|
10
|
+
type ExistsValidationConstraints<E> = [
|
|
11
|
+
ObjectType<E> | EntitySchema<E> | string,
|
|
12
|
+
(validationArguments: ValidationArguments) => FindOptionsWhere<E>
|
|
13
|
+
];
|
|
14
|
+
interface IExistsValidationArguments<E> extends ValidationArguments {
|
|
15
|
+
constraints: ExistsValidationConstraints<E>;
|
|
16
|
+
}
|
|
17
|
+
export declare function IsExists<E>(constraints: Partial<ExistsValidationConstraints<E>>, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
46
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
47
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.IsExists = exports.IsExistsValidator = void 0;
|
|
51
|
+
const class_validator_1 = require("class-validator");
|
|
52
|
+
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
53
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
54
|
+
const common_1 = require("@nestjs/common");
|
|
55
|
+
let IsExistsValidator = (() => {
|
|
56
|
+
let _classDecorators = [(0, common_1.Injectable)(), (0, class_validator_1.ValidatorConstraint)({ name: 'isExists', async: true })];
|
|
57
|
+
let _classDescriptor;
|
|
58
|
+
let _classExtraInitializers = [];
|
|
59
|
+
let _classThis;
|
|
60
|
+
var IsExistsValidator = _classThis = class {
|
|
61
|
+
constructor(dataSource) {
|
|
62
|
+
this.dataSource = dataSource;
|
|
63
|
+
this.dataSource = (0, typeorm_transactional_1.getDataSourceByName)('default');
|
|
64
|
+
}
|
|
65
|
+
validate(value, args) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const [entityClass, findCondition] = args.constraints;
|
|
68
|
+
return ((yield this.dataSource.getRepository(entityClass).count({
|
|
69
|
+
where: findCondition(args),
|
|
70
|
+
})) > 0);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
defaultMessage(args) {
|
|
74
|
+
return (0, nestjs_i18n_1.i18nValidationMessage)('validation.IS_EXISTS')(args);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
__setFunctionName(_classThis, "IsExistsValidator");
|
|
78
|
+
(() => {
|
|
79
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
80
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
81
|
+
IsExistsValidator = _classThis = _classDescriptor.value;
|
|
82
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
83
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
84
|
+
})();
|
|
85
|
+
return IsExistsValidator = _classThis;
|
|
86
|
+
})();
|
|
87
|
+
exports.IsExistsValidator = IsExistsValidator;
|
|
88
|
+
function IsExists(constraints, validationOptions) {
|
|
89
|
+
return (object, propertyName) => {
|
|
90
|
+
(0, class_validator_1.registerDecorator)({
|
|
91
|
+
target: object.constructor,
|
|
92
|
+
propertyName,
|
|
93
|
+
options: validationOptions,
|
|
94
|
+
constraints,
|
|
95
|
+
validator: IsExistsValidator,
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
exports.IsExists = IsExists;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ValidationArguments,
|
|
3
|
+
ValidationOptions,
|
|
4
|
+
ValidatorConstraintInterface,
|
|
5
|
+
} from 'class-validator';
|
|
6
|
+
import { registerDecorator, ValidatorConstraint } from 'class-validator';
|
|
7
|
+
import type { EntitySchema, FindOptionsWhere, ObjectType } from 'typeorm';
|
|
8
|
+
import { DataSource } from 'typeorm';
|
|
9
|
+
import { getDataSourceByName } from 'typeorm-transactional';
|
|
10
|
+
import { i18nValidationMessage } from 'nestjs-i18n';
|
|
11
|
+
import { Injectable } from '@nestjs/common';
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
@ValidatorConstraint({ name: 'isExists', async: true })
|
|
15
|
+
export class IsExistsValidator implements ValidatorConstraintInterface {
|
|
16
|
+
constructor(private readonly dataSource: DataSource) {
|
|
17
|
+
this.dataSource = getDataSourceByName('default');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async validate<E>(
|
|
21
|
+
value: string,
|
|
22
|
+
args: IExistsValidationArguments<E>,
|
|
23
|
+
): Promise<boolean> {
|
|
24
|
+
const [entityClass, findCondition] = args.constraints;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
(await this.dataSource.getRepository(entityClass).count({
|
|
28
|
+
where: findCondition(args),
|
|
29
|
+
})) > 0
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
defaultMessage(args: ValidationArguments): string {
|
|
34
|
+
return i18nValidationMessage('validation.IS_EXISTS')(args);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type ExistsValidationConstraints<E> = [
|
|
39
|
+
ObjectType<E> | EntitySchema<E> | string,
|
|
40
|
+
(validationArguments: ValidationArguments) => FindOptionsWhere<E>,
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
interface IExistsValidationArguments<E> extends ValidationArguments {
|
|
44
|
+
constraints: ExistsValidationConstraints<E>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function IsExists<E>(
|
|
48
|
+
constraints: Partial<ExistsValidationConstraints<E>>,
|
|
49
|
+
validationOptions?: ValidationOptions,
|
|
50
|
+
): PropertyDecorator {
|
|
51
|
+
return (object, propertyName: string) => {
|
|
52
|
+
registerDecorator({
|
|
53
|
+
target: object.constructor,
|
|
54
|
+
propertyName,
|
|
55
|
+
options: validationOptions,
|
|
56
|
+
constraints,
|
|
57
|
+
validator: IsExistsValidator,
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
+
import { DataSource, EntitySchema, FindOptionsWhere, ObjectType } from 'typeorm';
|
|
3
|
+
export declare class IsUniqueValidator implements ValidatorConstraintInterface {
|
|
4
|
+
private readonly dataSource;
|
|
5
|
+
constructor(dataSource: DataSource);
|
|
6
|
+
validate<E>(value: string, args: IUniqueValidationArguments<E>): Promise<boolean>;
|
|
7
|
+
defaultMessage(args: ValidationArguments): string;
|
|
8
|
+
}
|
|
9
|
+
type UniqueValidationConstraints<E> = [
|
|
10
|
+
ObjectType<E> | EntitySchema<E> | string,
|
|
11
|
+
(validationArguments: ValidationArguments) => FindOptionsWhere<E>
|
|
12
|
+
];
|
|
13
|
+
interface IUniqueValidationArguments<E> extends ValidationArguments {
|
|
14
|
+
constraints: UniqueValidationConstraints<E>;
|
|
15
|
+
}
|
|
16
|
+
export declare function IsUnique<E>(constraints: Partial<UniqueValidationConstraints<E>>, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
46
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
47
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.IsUnique = exports.IsUniqueValidator = void 0;
|
|
51
|
+
const class_validator_1 = require("class-validator");
|
|
52
|
+
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
53
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
54
|
+
let IsUniqueValidator = (() => {
|
|
55
|
+
let _classDecorators = [(0, class_validator_1.ValidatorConstraint)({ name: 'isUnique', async: true })];
|
|
56
|
+
let _classDescriptor;
|
|
57
|
+
let _classExtraInitializers = [];
|
|
58
|
+
let _classThis;
|
|
59
|
+
var IsUniqueValidator = _classThis = class {
|
|
60
|
+
constructor(dataSource) {
|
|
61
|
+
this.dataSource = dataSource;
|
|
62
|
+
this.dataSource = (0, typeorm_transactional_1.getDataSourceByName)('default');
|
|
63
|
+
}
|
|
64
|
+
validate(value, args) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const [entityClass, findCondition] = args.constraints;
|
|
67
|
+
let exists;
|
|
68
|
+
const defCon = findCondition(args);
|
|
69
|
+
const pkCols = this.dataSource
|
|
70
|
+
.getMetadata(entityClass)
|
|
71
|
+
.primaryColumns.map((column) => column.propertyName);
|
|
72
|
+
const isNew = pkCols.some((pk) => args.object[pk]);
|
|
73
|
+
if (!isNew) {
|
|
74
|
+
exists =
|
|
75
|
+
(yield this.dataSource
|
|
76
|
+
.getRepository(entityClass)
|
|
77
|
+
.count({ where: defCon })) < 1;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const entities = yield this.dataSource
|
|
81
|
+
.getRepository(entityClass)
|
|
82
|
+
.createQueryBuilder()
|
|
83
|
+
.where(defCon)
|
|
84
|
+
.select(pkCols)
|
|
85
|
+
.limit(2)
|
|
86
|
+
.execute();
|
|
87
|
+
const entityCount = entities.length;
|
|
88
|
+
if (entityCount === 1) {
|
|
89
|
+
const entity = entities[0];
|
|
90
|
+
const oldPk = {};
|
|
91
|
+
const newPk = {};
|
|
92
|
+
pkCols.map((pk) => {
|
|
93
|
+
oldPk[pk] = entity[pk];
|
|
94
|
+
newPk[pk] = args.object[pk];
|
|
95
|
+
});
|
|
96
|
+
exists = JSON.stringify(oldPk) === JSON.stringify(newPk);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
exists = entityCount < 1;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return exists;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
defaultMessage(args) {
|
|
106
|
+
return (0, nestjs_i18n_1.i18nValidationMessage)('validation.IS_UNIQUE')(args);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
__setFunctionName(_classThis, "IsUniqueValidator");
|
|
110
|
+
(() => {
|
|
111
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
112
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
113
|
+
IsUniqueValidator = _classThis = _classDescriptor.value;
|
|
114
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
115
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
116
|
+
})();
|
|
117
|
+
return IsUniqueValidator = _classThis;
|
|
118
|
+
})();
|
|
119
|
+
exports.IsUniqueValidator = IsUniqueValidator;
|
|
120
|
+
function IsUnique(constraints, validationOptions) {
|
|
121
|
+
return function (object, propertyName) {
|
|
122
|
+
(0, class_validator_1.registerDecorator)({
|
|
123
|
+
target: object.constructor,
|
|
124
|
+
propertyName,
|
|
125
|
+
options: validationOptions,
|
|
126
|
+
constraints,
|
|
127
|
+
validator: IsUniqueValidator,
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
exports.IsUnique = IsUnique;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ValidationArguments,
|
|
3
|
+
ValidationOptions,
|
|
4
|
+
ValidatorConstraintInterface,
|
|
5
|
+
} from 'class-validator';
|
|
6
|
+
import { registerDecorator, ValidatorConstraint } from 'class-validator';
|
|
7
|
+
import {
|
|
8
|
+
DataSource,
|
|
9
|
+
EntitySchema,
|
|
10
|
+
FindOptionsWhere,
|
|
11
|
+
ObjectType,
|
|
12
|
+
} from 'typeorm';
|
|
13
|
+
import { getDataSourceByName } from 'typeorm-transactional';
|
|
14
|
+
import { i18nValidationMessage } from 'nestjs-i18n';
|
|
15
|
+
|
|
16
|
+
@ValidatorConstraint({ name: 'isUnique', async: true })
|
|
17
|
+
export class IsUniqueValidator implements ValidatorConstraintInterface {
|
|
18
|
+
constructor(private readonly dataSource: DataSource) {
|
|
19
|
+
this.dataSource = getDataSourceByName('default');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public async validate<E>(
|
|
23
|
+
value: string,
|
|
24
|
+
args: IUniqueValidationArguments<E>,
|
|
25
|
+
): Promise<boolean> {
|
|
26
|
+
const [entityClass, findCondition] = args.constraints;
|
|
27
|
+
|
|
28
|
+
let exists: boolean;
|
|
29
|
+
const defCon = findCondition(args);
|
|
30
|
+
const pkCols = this.dataSource
|
|
31
|
+
.getMetadata(entityClass)
|
|
32
|
+
.primaryColumns.map((column) => column.propertyName);
|
|
33
|
+
|
|
34
|
+
const isNew = pkCols.some((pk) => args.object[pk]);
|
|
35
|
+
if (!isNew) {
|
|
36
|
+
exists =
|
|
37
|
+
(await this.dataSource
|
|
38
|
+
.getRepository(entityClass)
|
|
39
|
+
.count({ where: defCon })) < 1;
|
|
40
|
+
} else {
|
|
41
|
+
const entities = await this.dataSource
|
|
42
|
+
.getRepository(entityClass)
|
|
43
|
+
.createQueryBuilder()
|
|
44
|
+
.where(defCon)
|
|
45
|
+
.select(pkCols)
|
|
46
|
+
.limit(2)
|
|
47
|
+
.execute();
|
|
48
|
+
|
|
49
|
+
const entityCount = entities.length;
|
|
50
|
+
if (entityCount === 1) {
|
|
51
|
+
const entity = entities[0];
|
|
52
|
+
const oldPk = {};
|
|
53
|
+
const newPk = {};
|
|
54
|
+
pkCols.map((pk) => {
|
|
55
|
+
oldPk[pk] = entity[pk];
|
|
56
|
+
newPk[pk] = args.object[pk];
|
|
57
|
+
});
|
|
58
|
+
exists = JSON.stringify(oldPk) === JSON.stringify(newPk);
|
|
59
|
+
} else {
|
|
60
|
+
exists = entityCount < 1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return exists;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
defaultMessage(args: ValidationArguments): string {
|
|
67
|
+
return i18nValidationMessage('validation.IS_UNIQUE')(args);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type UniqueValidationConstraints<E> = [
|
|
72
|
+
ObjectType<E> | EntitySchema<E> | string,
|
|
73
|
+
(validationArguments: ValidationArguments) => FindOptionsWhere<E>,
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
interface IUniqueValidationArguments<E> extends ValidationArguments {
|
|
77
|
+
constraints: UniqueValidationConstraints<E>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function IsUnique<E>(
|
|
81
|
+
constraints: Partial<UniqueValidationConstraints<E>>,
|
|
82
|
+
validationOptions?: ValidationOptions,
|
|
83
|
+
): PropertyDecorator {
|
|
84
|
+
return function (object, propertyName: string) {
|
|
85
|
+
registerDecorator({
|
|
86
|
+
target: object.constructor,
|
|
87
|
+
propertyName,
|
|
88
|
+
options: validationOptions,
|
|
89
|
+
constraints,
|
|
90
|
+
validator: IsUniqueValidator,
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsPhoneNumberWithCountryCode = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
function IsPhoneNumberWithCountryCode(validationOptions) {
|
|
6
|
+
return function (object, propertyName) {
|
|
7
|
+
(0, class_validator_1.ValidateIf)((_, value) => !!value)(object, propertyName);
|
|
8
|
+
const countryCodePropertyName = 'countryCode';
|
|
9
|
+
(0, class_validator_1.registerDecorator)({
|
|
10
|
+
name: 'isPhoneNumberWithCountryCode',
|
|
11
|
+
target: object.constructor,
|
|
12
|
+
propertyName: propertyName,
|
|
13
|
+
constraints: [countryCodePropertyName],
|
|
14
|
+
options: validationOptions,
|
|
15
|
+
validator: {
|
|
16
|
+
validate(value, args) {
|
|
17
|
+
const [countryCodePropertyName] = args.constraints;
|
|
18
|
+
const countryCode = args.object[countryCodePropertyName];
|
|
19
|
+
return (0, class_validator_1.isPhoneNumber)(value, countryCode);
|
|
20
|
+
},
|
|
21
|
+
defaultMessage(args) {
|
|
22
|
+
const [countryCodePropertyName] = args.constraints;
|
|
23
|
+
const countryCode = args.object[countryCodePropertyName];
|
|
24
|
+
return `$property must be a valid phone number in the country code ${countryCode}`;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.IsPhoneNumberWithCountryCode = IsPhoneNumberWithCountryCode;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isPhoneNumber,
|
|
3
|
+
registerDecorator,
|
|
4
|
+
ValidateIf,
|
|
5
|
+
ValidationArguments,
|
|
6
|
+
ValidationOptions,
|
|
7
|
+
} from 'class-validator';
|
|
8
|
+
|
|
9
|
+
export function IsPhoneNumberWithCountryCode(
|
|
10
|
+
validationOptions?: ValidationOptions,
|
|
11
|
+
) {
|
|
12
|
+
return function (object: NonNullable<unknown>, propertyName: string) {
|
|
13
|
+
ValidateIf((_, value) => !!value)(object, propertyName);
|
|
14
|
+
const countryCodePropertyName = 'countryCode';
|
|
15
|
+
|
|
16
|
+
registerDecorator({
|
|
17
|
+
name: 'isPhoneNumberWithCountryCode',
|
|
18
|
+
target: object.constructor,
|
|
19
|
+
propertyName: propertyName,
|
|
20
|
+
constraints: [countryCodePropertyName],
|
|
21
|
+
options: validationOptions,
|
|
22
|
+
validator: {
|
|
23
|
+
validate(value: any, args: ValidationArguments) {
|
|
24
|
+
const [countryCodePropertyName] = args.constraints;
|
|
25
|
+
const countryCode = args.object[countryCodePropertyName];
|
|
26
|
+
return isPhoneNumber(value, countryCode);
|
|
27
|
+
},
|
|
28
|
+
defaultMessage(args: ValidationArguments) {
|
|
29
|
+
const [countryCodePropertyName] = args.constraints;
|
|
30
|
+
const countryCode = args.object[countryCodePropertyName];
|
|
31
|
+
return `$property must be a valid phone number in the country code ${countryCode}`;
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SameAs = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
function SameAs(property, validationOptions) {
|
|
6
|
+
return function (object, propertyName) {
|
|
7
|
+
(0, class_validator_1.registerDecorator)({
|
|
8
|
+
name: 'sameAs',
|
|
9
|
+
target: object.constructor,
|
|
10
|
+
propertyName,
|
|
11
|
+
options: validationOptions,
|
|
12
|
+
constraints: [property],
|
|
13
|
+
validator: {
|
|
14
|
+
validate(value, args) {
|
|
15
|
+
const [relatedPropertyName] = args.constraints;
|
|
16
|
+
return (args === null || args === void 0 ? void 0 : args.object[relatedPropertyName]) === value;
|
|
17
|
+
},
|
|
18
|
+
defaultMessage() {
|
|
19
|
+
return '$property must match $constraint1';
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.SameAs = SameAs;
|