@mondart/nestjs-common-module 1.0.3
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/.eslintrc.js +25 -0
- package/.github/workflows/npm-publish.yml +34 -0
- package/.prettierrc +4 -0
- package/common/caching/caching.module.ts +28 -0
- package/common/caching/caching.service.ts +34 -0
- package/common/caching/index.ts +2 -0
- package/common/constants/index.ts +1 -0
- package/common/constants/validation-constraints.const.ts +14 -0
- package/common/controllers/core-crud.controller.ts +106 -0
- package/common/controllers/index.ts +1 -0
- package/common/decorators/entity-order.decorator.ts +19 -0
- package/common/decorators/index.ts +2 -0
- package/common/decorators/swagger-api-response.decorator.ts +30 -0
- package/common/decorators/validations/default/array-max-size.decorator.ts +9 -0
- package/common/decorators/validations/default/array-min-size.decorator.ts +9 -0
- package/common/decorators/validations/default/array-not-empty.decorator.ts +7 -0
- package/common/decorators/validations/default/index.ts +20 -0
- package/common/decorators/validations/default/is-array.decorator.ts +7 -0
- package/common/decorators/validations/default/is-boolean.decorator.ts +10 -0
- package/common/decorators/validations/default/is-date.decorator.ts +10 -0
- package/common/decorators/validations/default/is-enum.decorator.ts +9 -0
- package/common/decorators/validations/default/is-int.decorator.ts +10 -0
- package/common/decorators/validations/default/is-not-empty-object.decorator.ts +15 -0
- package/common/decorators/validations/default/is-not-empty.decorator.ts +7 -0
- package/common/decorators/validations/default/is-number-string.decorator.ts +12 -0
- package/common/decorators/validations/default/is-object.decorator.ts +7 -0
- package/common/decorators/validations/default/is-positive.decorator.ts +10 -0
- package/common/decorators/validations/default/is-string.decorator.ts +8 -0
- package/common/decorators/validations/default/is-uuid.decorator.ts +7 -0
- package/common/decorators/validations/default/matches.decorator.ts +13 -0
- package/common/decorators/validations/default/max-length.decorator.ts +9 -0
- package/common/decorators/validations/default/max.decorator.ts +13 -0
- package/common/decorators/validations/default/min-length.decorator.ts +9 -0
- package/common/decorators/validations/default/min.decorator.ts +13 -0
- package/common/decorators/validations/index.ts +3 -0
- package/common/decorators/validations/is-id.decorator.ts +20 -0
- package/common/decorators/validations/is-not-empty-string.decorator.ts +14 -0
- package/common/dto/index.ts +2 -0
- package/common/dto/request/base-request.dto.ts +11 -0
- package/common/dto/request/event.dto.ts +25 -0
- package/common/dto/request/id.dto.ts +10 -0
- package/common/dto/request/ids.dto.ts +13 -0
- package/common/dto/request/index.ts +4 -0
- package/common/dto/response/base-response-with-action-dates.dto.ts +19 -0
- package/common/dto/response/base-response.dto.ts +10 -0
- package/common/dto/response/error-response.dto.ts +22 -0
- package/common/dto/response/index.ts +5 -0
- package/common/dto/response/kafka-success-response.dto.ts +56 -0
- package/common/dto/response/success-response.dto.ts +32 -0
- package/common/dto/response/validation.dto.ts +80 -0
- package/common/entities/action-dates.entity.ts +30 -0
- package/common/entities/base.entity.ts +7 -0
- package/common/entities/index.ts +2 -0
- package/common/entities/parent.entity.ts +35 -0
- package/common/enums/environments.enum.ts +6 -0
- package/common/enums/index.ts +2 -0
- package/common/enums/shared-messages.enum.ts +40 -0
- package/common/filters/http-exception.filter.ts +74 -0
- package/common/filters/index.ts +1 -0
- package/common/filters/rpc-exception.filter.ts +40 -0
- package/common/helper/get-env.helper.ts +3 -0
- package/common/helper/get-env.ts +3 -0
- package/common/helper/index.ts +2 -0
- package/common/helper/message-formatter.helper.ts +30 -0
- package/common/helper/multi-inheritance.helper.ts +12 -0
- package/common/helper/multi-inheritance.util.ts +12 -0
- package/common/index.ts +14 -0
- package/common/interface/core-crud-service.option.ts +8 -0
- package/common/interface/custom-validation-arguments.interface.ts +20 -0
- package/common/interface/index.ts +2 -0
- package/common/interface/kafka-success-response.interfase.ts +9 -0
- package/common/interface/pagination-query.ts +39 -0
- package/common/lib/index.ts +1 -0
- package/common/lib/kafka/constant/consumer.const.ts +13 -0
- package/common/lib/kafka/constant/kafka.const.ts +9 -0
- package/common/lib/kafka/index.ts +5 -0
- package/common/lib/kafka/kafka-admin.service.ts +51 -0
- package/common/lib/kafka/kafka-consumer.service.ts +59 -0
- package/common/lib/kafka/kafka-instance.const.ts +9 -0
- package/common/lib/kafka/kafka-logger.ts +25 -0
- package/common/lib/kafka/kafka-producer.service.ts +97 -0
- package/common/lib/kafka/kafka.interface.ts +22 -0
- package/common/lib/kafka/kafka.module.ts +80 -0
- package/common/lib/kafka/kafka.provider.ts +10 -0
- package/common/lib/kafka/kafka.service.ts +224 -0
- package/common/services/core-crud.service.ts +457 -0
- package/common/services/index.ts +1 -0
- package/common/strategy/index.ts +1 -0
- package/common/strategy/type-orm-naming.strategy.ts +17 -0
- package/common/validators/does-exist.validator.ts +42 -0
- package/common/validators/env.validator.ts +28 -0
- package/common/validators/index.ts +4 -0
- package/common/validators/is-unique.validator.ts +70 -0
- package/common/validators/validation-options.ts +38 -0
- package/dist/caching/caching.module.d.ts +2 -0
- package/dist/caching/caching.module.js +41 -0
- package/dist/caching/caching.module.js.map +1 -0
- package/dist/caching/caching.service.d.ts +9 -0
- package/dist/caching/caching.service.js +45 -0
- package/dist/caching/caching.service.js.map +1 -0
- package/dist/caching/index.d.ts +2 -0
- package/dist/caching/index.js +19 -0
- package/dist/caching/index.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +18 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/validation-constraints.const.d.ts +14 -0
- package/dist/constants/validation-constraints.const.js +19 -0
- package/dist/constants/validation-constraints.const.js.map +1 -0
- package/dist/controllers/core-crud.controller.d.ts +19 -0
- package/dist/controllers/core-crud.controller.js +72 -0
- package/dist/controllers/core-crud.controller.js.map +1 -0
- package/dist/controllers/index.d.ts +1 -0
- package/dist/controllers/index.js +18 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/decorators/entity-order.decorator.d.ts +2 -0
- package/dist/decorators/entity-order.decorator.js +18 -0
- package/dist/decorators/entity-order.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.js +19 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/swagger-api-response.decorator.d.ts +5 -0
- package/dist/decorators/swagger-api-response.decorator.js +25 -0
- package/dist/decorators/swagger-api-response.decorator.js.map +1 -0
- package/dist/decorators/validations/default/array-max-size.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/array-max-size.decorator.js +12 -0
- package/dist/decorators/validations/default/array-max-size.decorator.js.map +1 -0
- package/dist/decorators/validations/default/array-min-size.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/array-min-size.decorator.js +12 -0
- package/dist/decorators/validations/default/array-min-size.decorator.js.map +1 -0
- package/dist/decorators/validations/default/array-not-empty.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/array-not-empty.decorator.js +10 -0
- package/dist/decorators/validations/default/array-not-empty.decorator.js.map +1 -0
- package/dist/decorators/validations/default/index.d.ts +20 -0
- package/dist/decorators/validations/default/index.js +37 -0
- package/dist/decorators/validations/default/index.js.map +1 -0
- package/dist/decorators/validations/default/is-array.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/is-array.decorator.js +10 -0
- package/dist/decorators/validations/default/is-array.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-boolean.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-boolean.decorator.js +10 -0
- package/dist/decorators/validations/default/is-boolean.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-date.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-date.decorator.js +10 -0
- package/dist/decorators/validations/default/is-date.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-enum.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/is-enum.decorator.js +12 -0
- package/dist/decorators/validations/default/is-enum.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-int.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-int.decorator.js +10 -0
- package/dist/decorators/validations/default/is-int.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-not-empty-object.decorator.d.ts +5 -0
- package/dist/decorators/validations/default/is-not-empty-object.decorator.js +13 -0
- package/dist/decorators/validations/default/is-not-empty-object.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-not-empty.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/is-not-empty.decorator.js +10 -0
- package/dist/decorators/validations/default/is-not-empty.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-number-string.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-number-string.decorator.js +10 -0
- package/dist/decorators/validations/default/is-number-string.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-object.decorator.d.ts +2 -0
- package/dist/decorators/validations/default/is-object.decorator.js +10 -0
- package/dist/decorators/validations/default/is-object.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-positive.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-positive.decorator.js +10 -0
- package/dist/decorators/validations/default/is-positive.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-string.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-string.decorator.js +11 -0
- package/dist/decorators/validations/default/is-string.decorator.js.map +1 -0
- package/dist/decorators/validations/default/is-uuid.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/is-uuid.decorator.js +10 -0
- package/dist/decorators/validations/default/is-uuid.decorator.js.map +1 -0
- package/dist/decorators/validations/default/matches.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/matches.decorator.js +10 -0
- package/dist/decorators/validations/default/matches.decorator.js.map +1 -0
- package/dist/decorators/validations/default/max-length.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/max-length.decorator.js +12 -0
- package/dist/decorators/validations/default/max-length.decorator.js.map +1 -0
- package/dist/decorators/validations/default/max.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/max.decorator.js +10 -0
- package/dist/decorators/validations/default/max.decorator.js.map +1 -0
- package/dist/decorators/validations/default/min-length.decorator.d.ts +1 -0
- package/dist/decorators/validations/default/min-length.decorator.js +12 -0
- package/dist/decorators/validations/default/min-length.decorator.js.map +1 -0
- package/dist/decorators/validations/default/min.decorator.d.ts +3 -0
- package/dist/decorators/validations/default/min.decorator.js +10 -0
- package/dist/decorators/validations/default/min.decorator.js.map +1 -0
- package/dist/decorators/validations/index.d.ts +3 -0
- package/dist/decorators/validations/index.js +20 -0
- package/dist/decorators/validations/index.js.map +1 -0
- package/dist/decorators/validations/is-id.decorator.d.ts +4 -0
- package/dist/decorators/validations/is-id.decorator.js +21 -0
- package/dist/decorators/validations/is-id.decorator.js.map +1 -0
- package/dist/decorators/validations/is-not-empty-string.decorator.d.ts +4 -0
- package/dist/decorators/validations/is-not-empty-string.decorator.js +15 -0
- package/dist/decorators/validations/is-not-empty-string.decorator.js.map +1 -0
- package/dist/dto/index.d.ts +2 -0
- package/dist/dto/index.js +19 -0
- package/dist/dto/index.js.map +1 -0
- package/dist/dto/request/base-request.dto.d.ts +4 -0
- package/dist/dto/request/base-request.dto.js +24 -0
- package/dist/dto/request/base-request.dto.js.map +1 -0
- package/dist/dto/request/event.dto.d.ts +8 -0
- package/dist/dto/request/event.dto.js +45 -0
- package/dist/dto/request/event.dto.js.map +1 -0
- package/dist/dto/request/id.dto.d.ts +3 -0
- package/dist/dto/request/id.dto.js +25 -0
- package/dist/dto/request/id.dto.js.map +1 -0
- package/dist/dto/request/ids.dto.d.ts +3 -0
- package/dist/dto/request/ids.dto.js +28 -0
- package/dist/dto/request/ids.dto.js.map +1 -0
- package/dist/dto/request/index.d.ts +4 -0
- package/dist/dto/request/index.js +21 -0
- package/dist/dto/request/index.js.map +1 -0
- package/dist/dto/response/base-response-with-action-dates.dto.d.ts +7 -0
- package/dist/dto/response/base-response-with-action-dates.dto.js +36 -0
- package/dist/dto/response/base-response-with-action-dates.dto.js.map +1 -0
- package/dist/dto/response/base-response.dto.d.ts +4 -0
- package/dist/dto/response/base-response.dto.js +24 -0
- package/dist/dto/response/base-response.dto.js.map +1 -0
- package/dist/dto/response/error-response.dto.d.ts +8 -0
- package/dist/dto/response/error-response.dto.js +38 -0
- package/dist/dto/response/error-response.dto.js.map +1 -0
- package/dist/dto/response/index.d.ts +5 -0
- package/dist/dto/response/index.js +22 -0
- package/dist/dto/response/index.js.map +1 -0
- package/dist/dto/response/kafka-success-response.dto.d.ts +14 -0
- package/dist/dto/response/kafka-success-response.dto.js +66 -0
- package/dist/dto/response/kafka-success-response.dto.js.map +1 -0
- package/dist/dto/response/success-response.dto.d.ts +9 -0
- package/dist/dto/response/success-response.dto.js +44 -0
- package/dist/dto/response/success-response.dto.js.map +1 -0
- package/dist/dto/response/validation.dto.d.ts +25 -0
- package/dist/dto/response/validation.dto.js +84 -0
- package/dist/dto/response/validation.dto.js.map +1 -0
- package/dist/entities/action-dates.entity.d.ts +8 -0
- package/dist/entities/action-dates.entity.js +43 -0
- package/dist/entities/action-dates.entity.js.map +1 -0
- package/dist/entities/base.entity.d.ts +4 -0
- package/dist/entities/base.entity.js +22 -0
- package/dist/entities/base.entity.js.map +1 -0
- package/dist/entities/index.d.ts +2 -0
- package/dist/entities/index.js +19 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/parent.entity.d.ts +8 -0
- package/dist/entities/parent.entity.js +45 -0
- package/dist/entities/parent.entity.js.map +1 -0
- package/dist/enums/environments.enum.d.ts +6 -0
- package/dist/enums/environments.enum.js +11 -0
- package/dist/enums/environments.enum.js.map +1 -0
- package/dist/enums/index.d.ts +2 -0
- package/dist/enums/index.js +19 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/enums/shared-messages.enum.d.ts +25 -0
- package/dist/enums/shared-messages.enum.js +30 -0
- package/dist/enums/shared-messages.enum.js.map +1 -0
- package/dist/filters/http-exception.filter.d.ts +8 -0
- package/dist/filters/http-exception.filter.js +65 -0
- package/dist/filters/http-exception.filter.js.map +1 -0
- package/dist/filters/index.d.ts +1 -0
- package/dist/filters/index.js +18 -0
- package/dist/filters/index.js.map +1 -0
- package/dist/filters/rpc-exception.filter.d.ts +5 -0
- package/dist/filters/rpc-exception.filter.js +21 -0
- package/dist/filters/rpc-exception.filter.js.map +1 -0
- package/dist/helper/get-env.d.ts +1 -0
- package/dist/helper/get-env.helper.d.ts +1 -0
- package/dist/helper/get-env.helper.js +7 -0
- package/dist/helper/get-env.helper.js.map +1 -0
- package/dist/helper/get-env.js +7 -0
- package/dist/helper/get-env.js.map +1 -0
- package/dist/helper/index.d.ts +2 -0
- package/dist/helper/index.js +19 -0
- package/dist/helper/index.js.map +1 -0
- package/dist/helper/message-formatter.helper.d.ts +3 -0
- package/dist/helper/message-formatter.helper.js +27 -0
- package/dist/helper/message-formatter.helper.js.map +1 -0
- package/dist/helper/multi-inheritance.helper.d.ts +1 -0
- package/dist/helper/multi-inheritance.helper.js +13 -0
- package/dist/helper/multi-inheritance.helper.js.map +1 -0
- package/dist/helper/multi-inheritance.util.d.ts +1 -0
- package/dist/helper/multi-inheritance.util.js +13 -0
- package/dist/helper/multi-inheritance.util.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/interface/core-crud-service.option.d.ts +7 -0
- package/dist/interface/core-crud-service.option.js +10 -0
- package/dist/interface/core-crud-service.option.js.map +1 -0
- package/dist/interface/custom-validation-arguments.interface.d.ts +14 -0
- package/dist/interface/custom-validation-arguments.interface.js +3 -0
- package/dist/interface/custom-validation-arguments.interface.js.map +1 -0
- package/dist/interface/index.d.ts +2 -0
- package/dist/interface/index.js +19 -0
- package/dist/interface/index.js.map +1 -0
- package/dist/interface/kafka-success-response.interfase.d.ts +9 -0
- package/dist/interface/kafka-success-response.interfase.js +3 -0
- package/dist/interface/kafka-success-response.interfase.js.map +1 -0
- package/dist/interface/pagination-query.d.ts +13 -0
- package/dist/interface/pagination-query.js +55 -0
- package/dist/interface/pagination-query.js.map +1 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +18 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/kafka/constant/consumer.const.d.ts +12 -0
- package/dist/lib/kafka/constant/consumer.const.js +18 -0
- package/dist/lib/kafka/constant/consumer.const.js.map +1 -0
- package/dist/lib/kafka/constant/kafka.const.d.ts +9 -0
- package/dist/lib/kafka/constant/kafka.const.js +14 -0
- package/dist/lib/kafka/constant/kafka.const.js.map +1 -0
- package/dist/lib/kafka/index.d.ts +4 -0
- package/dist/lib/kafka/index.js +8 -0
- package/dist/lib/kafka/index.js.map +1 -0
- package/dist/lib/kafka/kafka-admin.service.d.ts +7 -0
- package/dist/lib/kafka/kafka-admin.service.js +47 -0
- package/dist/lib/kafka/kafka-admin.service.js.map +1 -0
- package/dist/lib/kafka/kafka-consumer.service.d.ts +9 -0
- package/dist/lib/kafka/kafka-consumer.service.js +50 -0
- package/dist/lib/kafka/kafka-consumer.service.js.map +1 -0
- package/dist/lib/kafka/kafka-instance.const.d.ts +2 -0
- package/dist/lib/kafka/kafka-instance.const.js +12 -0
- package/dist/lib/kafka/kafka-instance.const.js.map +1 -0
- package/dist/lib/kafka/kafka-logger.d.ts +2 -0
- package/dist/lib/kafka/kafka-logger.js +22 -0
- package/dist/lib/kafka/kafka-logger.js.map +1 -0
- package/dist/lib/kafka/kafka-producer.service.d.ts +10 -0
- package/dist/lib/kafka/kafka-producer.service.js +76 -0
- package/dist/lib/kafka/kafka-producer.service.js.map +1 -0
- package/dist/lib/kafka/kafka.interface.d.ts +15 -0
- package/dist/lib/kafka/kafka.interface.js +5 -0
- package/dist/lib/kafka/kafka.interface.js.map +1 -0
- package/dist/lib/kafka/kafka.module.d.ts +10 -0
- package/dist/lib/kafka/kafka.module.js +77 -0
- package/dist/lib/kafka/kafka.module.js.map +1 -0
- package/dist/lib/kafka/kafka.provider.d.ts +7 -0
- package/dist/lib/kafka/kafka.provider.js +12 -0
- package/dist/lib/kafka/kafka.provider.js.map +1 -0
- package/dist/lib/kafka/kafka.service.d.ts +38 -0
- package/dist/lib/kafka/kafka.service.js +124 -0
- package/dist/lib/kafka/kafka.service.js.map +1 -0
- package/dist/services/core-crud.service.d.ts +31 -0
- package/dist/services/core-crud.service.js +318 -0
- package/dist/services/core-crud.service.js.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +18 -0
- package/dist/services/index.js.map +1 -0
- package/dist/strategy/index.d.ts +1 -0
- package/dist/strategy/index.js +18 -0
- package/dist/strategy/index.js.map +1 -0
- package/dist/strategy/type-orm-naming.strategy.d.ts +4 -0
- package/dist/strategy/type-orm-naming.strategy.js +12 -0
- package/dist/strategy/type-orm-naming.strategy.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/validators/does-exist.validator.d.ts +8 -0
- package/dist/validators/does-exist.validator.js +48 -0
- package/dist/validators/does-exist.validator.js.map +1 -0
- package/dist/validators/env.validator.d.ts +2 -0
- package/dist/validators/env.validator.js +27 -0
- package/dist/validators/env.validator.js.map +1 -0
- package/dist/validators/index.d.ts +4 -0
- package/dist/validators/index.js +21 -0
- package/dist/validators/index.js.map +1 -0
- package/dist/validators/is-unique.validator.d.ts +7 -0
- package/dist/validators/is-unique.validator.js +58 -0
- package/dist/validators/is-unique.validator.js.map +1 -0
- package/dist/validators/validation-options.d.ts +3 -0
- package/dist/validators/validation-options.js +28 -0
- package/dist/validators/validation-options.js.map +1 -0
- package/nest-cli.json +8 -0
- package/package.json +81 -0
- package/tsconfig.build.json +4 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { Type } from 'class-transformer';
|
|
3
|
+
import { IsId } from '../../decorators/validations/is-id.decorator';
|
|
4
|
+
|
|
5
|
+
export class IdDto {
|
|
6
|
+
@ApiProperty({ default: 1 })
|
|
7
|
+
@Type(() => Number)
|
|
8
|
+
@IsId({ optional: false })
|
|
9
|
+
id: number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { Transform } from 'class-transformer';
|
|
3
|
+
import { IsId } from '../../decorators/validations/is-id.decorator';
|
|
4
|
+
|
|
5
|
+
export class IdsDto {
|
|
6
|
+
@ApiProperty({ default: [1], isArray: true })
|
|
7
|
+
@Transform((o) => {
|
|
8
|
+
const ids = o.value.split(',');
|
|
9
|
+
return ids.map((value: string) => Number(value));
|
|
10
|
+
})
|
|
11
|
+
@IsId({ optional: false, each: true })
|
|
12
|
+
ids: number[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { BaseResponse } from './base-response.dto';
|
|
3
|
+
|
|
4
|
+
export class BaseResponseWithActionDates extends BaseResponse {
|
|
5
|
+
@ApiProperty({ type: Date })
|
|
6
|
+
public createdAt: Date;
|
|
7
|
+
@ApiProperty({ type: Date })
|
|
8
|
+
public updatedAt: Date;
|
|
9
|
+
@ApiPropertyOptional({ type: Date, default: null })
|
|
10
|
+
public deletedAt?: Date;
|
|
11
|
+
|
|
12
|
+
constructor(init: Partial<BaseResponseWithActionDates>) {
|
|
13
|
+
super(init);
|
|
14
|
+
|
|
15
|
+
this.createdAt = init?.createdAt;
|
|
16
|
+
this.updatedAt = init?.updatedAt;
|
|
17
|
+
this.deletedAt = init?.deletedAt;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
|
|
3
|
+
export class BaseErrorResponse {
|
|
4
|
+
@ApiProperty({ type: String })
|
|
5
|
+
message: string;
|
|
6
|
+
|
|
7
|
+
@ApiProperty({ type: Number })
|
|
8
|
+
statusCode: number;
|
|
9
|
+
|
|
10
|
+
@ApiProperty()
|
|
11
|
+
details: Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ErrorResponse extends BaseErrorResponse {
|
|
15
|
+
constructor(message: string, statusCode: number, details: any = {}) {
|
|
16
|
+
super();
|
|
17
|
+
|
|
18
|
+
this.message = message;
|
|
19
|
+
this.statusCode = statusCode;
|
|
20
|
+
this.details = details;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { IsNumber, IsOptional, IsString } from 'class-validator';
|
|
2
|
+
import { KafkaSuccessResponseInterface } from '../../interface/kafka-success-response.interfase';
|
|
3
|
+
|
|
4
|
+
export class BaseEventDto<type> {
|
|
5
|
+
@IsString()
|
|
6
|
+
@IsOptional()
|
|
7
|
+
topic?: string;
|
|
8
|
+
|
|
9
|
+
@IsString()
|
|
10
|
+
event_source: string;
|
|
11
|
+
|
|
12
|
+
@IsString()
|
|
13
|
+
@IsOptional()
|
|
14
|
+
model?: string;
|
|
15
|
+
|
|
16
|
+
@IsString()
|
|
17
|
+
@IsOptional()
|
|
18
|
+
event_key?: string;
|
|
19
|
+
|
|
20
|
+
@IsOptional()
|
|
21
|
+
data?: type;
|
|
22
|
+
|
|
23
|
+
@IsNumber()
|
|
24
|
+
@IsOptional()
|
|
25
|
+
partition?: number;
|
|
26
|
+
|
|
27
|
+
@IsNumber()
|
|
28
|
+
@IsOptional()
|
|
29
|
+
status?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class KafkaSuccessResponse<type> extends BaseEventDto<type> {
|
|
33
|
+
constructor({
|
|
34
|
+
data,
|
|
35
|
+
event_source,
|
|
36
|
+
topic,
|
|
37
|
+
model,
|
|
38
|
+
event_key,
|
|
39
|
+
partition,
|
|
40
|
+
status,
|
|
41
|
+
}: KafkaSuccessResponseInterface<type>) {
|
|
42
|
+
super();
|
|
43
|
+
|
|
44
|
+
this.data = data;
|
|
45
|
+
this.topic = topic;
|
|
46
|
+
this.event_source = event_source;
|
|
47
|
+
this.model = model;
|
|
48
|
+
this.event_key = event_key;
|
|
49
|
+
this.partition = partition;
|
|
50
|
+
this.status = status;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public stringify() {
|
|
54
|
+
return JSON.stringify(this);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { SharedMessages } from '../../enums/shared-messages.enum';
|
|
3
|
+
|
|
4
|
+
export class BaseSuccessResponse<type> {
|
|
5
|
+
@ApiProperty({ type: Object })
|
|
6
|
+
data: type;
|
|
7
|
+
|
|
8
|
+
@ApiProperty({ type: Object })
|
|
9
|
+
metadata: object;
|
|
10
|
+
|
|
11
|
+
@ApiProperty({ type: String, default: SharedMessages.SUCCESSFUL })
|
|
12
|
+
message: string;
|
|
13
|
+
|
|
14
|
+
@ApiProperty({ type: Number, default: 200 })
|
|
15
|
+
statusCode: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class SuccessResponse<type> extends BaseSuccessResponse<type> {
|
|
19
|
+
constructor(
|
|
20
|
+
data: type,
|
|
21
|
+
message: string = null,
|
|
22
|
+
statusCode = 200,
|
|
23
|
+
metadata = null,
|
|
24
|
+
) {
|
|
25
|
+
super();
|
|
26
|
+
|
|
27
|
+
this.data = data;
|
|
28
|
+
this.message = message;
|
|
29
|
+
this.statusCode = statusCode;
|
|
30
|
+
this.metadata = metadata;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { HttpStatus, ValidationError } from '@nestjs/common';
|
|
2
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
+
|
|
4
|
+
export class validationErrorMsg {
|
|
5
|
+
@ApiProperty({ type: String })
|
|
6
|
+
field: string;
|
|
7
|
+
|
|
8
|
+
@ApiProperty({ type: String })
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class ValidationMsg {
|
|
13
|
+
@ApiProperty({ type: String })
|
|
14
|
+
entity: string;
|
|
15
|
+
|
|
16
|
+
@ApiProperty({
|
|
17
|
+
type: validationErrorMsg,
|
|
18
|
+
isArray: true,
|
|
19
|
+
})
|
|
20
|
+
errors: Array<validationErrorMsg>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class ValidationErrorResponseType {
|
|
24
|
+
@ApiProperty({ type: String })
|
|
25
|
+
message: string;
|
|
26
|
+
|
|
27
|
+
@ApiProperty({ type: String })
|
|
28
|
+
statusCode: string;
|
|
29
|
+
|
|
30
|
+
@ApiProperty({ type: ValidationMsg })
|
|
31
|
+
validationMsg: ValidationMsg;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class ValidationErrorResponseDto {
|
|
35
|
+
public message: string;
|
|
36
|
+
public statusCode: string;
|
|
37
|
+
public validationMsg: object;
|
|
38
|
+
|
|
39
|
+
constructor(
|
|
40
|
+
message: string,
|
|
41
|
+
error: {
|
|
42
|
+
validationErrors?: Array<ValidationError>;
|
|
43
|
+
errors?: validationErrorMsg[];
|
|
44
|
+
},
|
|
45
|
+
) {
|
|
46
|
+
let validation =
|
|
47
|
+
error.validationErrors &&
|
|
48
|
+
error.validationErrors.map((error) => {
|
|
49
|
+
error = { ...error, ...this.formatValidationError(error) };
|
|
50
|
+
|
|
51
|
+
const field = error.property;
|
|
52
|
+
|
|
53
|
+
const message = Object.values(error.constraints)[0];
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
field,
|
|
57
|
+
message,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
validation = validation || error.errors;
|
|
62
|
+
|
|
63
|
+
this.message = message;
|
|
64
|
+
this.statusCode = String(HttpStatus.BAD_REQUEST);
|
|
65
|
+
this.validationMsg = {
|
|
66
|
+
errors: validation,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private formatValidationError(err: ValidationError) {
|
|
71
|
+
if (err.children.length === 0)
|
|
72
|
+
return {
|
|
73
|
+
property: err.property,
|
|
74
|
+
constraints: err.constraints,
|
|
75
|
+
children: err.children,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return this.formatValidationError(err.children[0]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CreateDateColumn,
|
|
3
|
+
UpdateDateColumn,
|
|
4
|
+
DeleteDateColumn,
|
|
5
|
+
Column,
|
|
6
|
+
BaseEntity,
|
|
7
|
+
} from 'typeorm';
|
|
8
|
+
import { Order } from '../decorators/entity-order.decorator';
|
|
9
|
+
|
|
10
|
+
export class ActionDatesEntity extends BaseEntity {
|
|
11
|
+
@Order(9999)
|
|
12
|
+
@CreateDateColumn()
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
|
|
15
|
+
@Order(9999)
|
|
16
|
+
@UpdateDateColumn()
|
|
17
|
+
updatedAt: Date;
|
|
18
|
+
|
|
19
|
+
@Order(9999)
|
|
20
|
+
@DeleteDateColumn()
|
|
21
|
+
deletedAt: Date;
|
|
22
|
+
|
|
23
|
+
@Order(9999)
|
|
24
|
+
@Column({ nullable: true })
|
|
25
|
+
createdBy?: string;
|
|
26
|
+
|
|
27
|
+
@Order(9999)
|
|
28
|
+
@Column({ nullable: true })
|
|
29
|
+
updatedBy?: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseEntity,
|
|
3
|
+
Column,
|
|
4
|
+
DataSource,
|
|
5
|
+
PrimaryGeneratedColumn,
|
|
6
|
+
} from 'typeorm';
|
|
7
|
+
import { ActionDatesEntity } from './action-dates.entity';
|
|
8
|
+
import { getOrder, Order } from '../decorators/entity-order.decorator';
|
|
9
|
+
|
|
10
|
+
export class ParentEntity extends ActionDatesEntity {
|
|
11
|
+
@Order(-1)
|
|
12
|
+
@PrimaryGeneratedColumn()
|
|
13
|
+
id: number;
|
|
14
|
+
|
|
15
|
+
@Order(9998)
|
|
16
|
+
@Column({ default: true })
|
|
17
|
+
isActive: boolean;
|
|
18
|
+
|
|
19
|
+
@Order(9999)
|
|
20
|
+
@Column({ type: 'json', nullable: true })
|
|
21
|
+
metadata?: any;
|
|
22
|
+
|
|
23
|
+
static useDataSource(dataSource: DataSource) {
|
|
24
|
+
BaseEntity.useDataSource.call(this, dataSource);
|
|
25
|
+
const meta = dataSource.entityMetadatasMap.get(this);
|
|
26
|
+
if (meta != null) {
|
|
27
|
+
// reorder columns here
|
|
28
|
+
meta.columns = [...meta.columns].sort((x, y) => {
|
|
29
|
+
const orderX = getOrder((x.target as any).prototype, x.propertyName);
|
|
30
|
+
const orderY = getOrder((y.target as any).prototype, y.propertyName);
|
|
31
|
+
return orderX - orderY;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export enum SharedMessages {
|
|
2
|
+
// Generic errors
|
|
3
|
+
INTERNAL_SERVER_ERROR = 'Internal Server Error.',
|
|
4
|
+
NOT_IMPLEMENTED = 'This feature has not been implemented yet.',
|
|
5
|
+
RECURSIVE_CHILD = 'Some children IDs are invalid, the parent product can not be used in children, it is recursive.',
|
|
6
|
+
SUCCESSFUL = 'Operation completed successfully.',
|
|
7
|
+
IS_UNiQUE = 'Field must be unique.',
|
|
8
|
+
|
|
9
|
+
// Create (POST) specific errors
|
|
10
|
+
CREATE_FAILED = 'Failed to create: {0}.',
|
|
11
|
+
CREATE_DENIED = 'Permission denied to create: {0}.',
|
|
12
|
+
|
|
13
|
+
// Read (GET) specific errors
|
|
14
|
+
FETCH_FAILED = 'Failed to fetch: {0}.',
|
|
15
|
+
RESOURCE_NOT_FOUND = 'The requested {0} was not found.',
|
|
16
|
+
DUPLICATED_SKU = 'The SKU is reserved.',
|
|
17
|
+
DUPLICATED_CODE = 'The Code is reserved.',
|
|
18
|
+
INVALID_COMPOSITE_SUB_ITEMS = 'Composite sub items are invalid.',
|
|
19
|
+
INVALID_GROUPED_SUB_ITEMS = 'Sub items are invalid.',
|
|
20
|
+
|
|
21
|
+
// Update (PUT/PATCH) specific errors
|
|
22
|
+
UPDATE_FAILED = 'Failed to update: {0}.',
|
|
23
|
+
UPDATE_DENIED = 'Permission denied to update: {0}.',
|
|
24
|
+
|
|
25
|
+
// Upsert (PUT/PATCH) specific errors
|
|
26
|
+
UPSERT_FAILED = 'Failed to upsert: {0}.',
|
|
27
|
+
UPSERT_DENIED = 'Permission denied to upsert: {0}.',
|
|
28
|
+
|
|
29
|
+
// Delete (DELETE) specific errors
|
|
30
|
+
DELETE_FAILED = 'Failed to delete: {0}.',
|
|
31
|
+
DELETE_DENIED = 'Permission denied to delete: {0}.',
|
|
32
|
+
|
|
33
|
+
// Validation errors
|
|
34
|
+
SORT_VALIDATION_FAILED = 'Sort parameter validation failed {0}.',
|
|
35
|
+
PARAMETER_VALIDATION_FAILED = 'Parameter validation failed {0}.',
|
|
36
|
+
|
|
37
|
+
// Authentication and Authorization errors
|
|
38
|
+
UNAUTHORIZED = 'Authorization is required to access this {0}.',
|
|
39
|
+
FORBIDDEN = 'Access to this {0} is forbidden.',
|
|
40
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArgumentsHost,
|
|
3
|
+
Catch,
|
|
4
|
+
ExceptionFilter,
|
|
5
|
+
HttpException,
|
|
6
|
+
HttpStatus,
|
|
7
|
+
Logger,
|
|
8
|
+
} from '@nestjs/common';
|
|
9
|
+
import { Response } from 'express';
|
|
10
|
+
import { ErrorResponse } from '../dto';
|
|
11
|
+
import { ConfigService } from '@nestjs/config';
|
|
12
|
+
import { SharedMessages } from '../enums/shared-messages.enum';
|
|
13
|
+
import { KafkaContext } from '@nestjs/microservices';
|
|
14
|
+
|
|
15
|
+
@Catch(HttpException)
|
|
16
|
+
export class HttpExceptionFilter implements ExceptionFilter {
|
|
17
|
+
constructor(private readonly configService: ConfigService) {}
|
|
18
|
+
catch(exception: HttpException, host: ArgumentsHost) {
|
|
19
|
+
const context = host.switchToHttp();
|
|
20
|
+
const response = context.getResponse<Response>();
|
|
21
|
+
const status = exception.getStatus();
|
|
22
|
+
const result = exception.getResponse() as {
|
|
23
|
+
message: string | string[];
|
|
24
|
+
error: string | string[];
|
|
25
|
+
details: any;
|
|
26
|
+
};
|
|
27
|
+
const logger = new Logger('OrderKafkaController', { timestamp: true });
|
|
28
|
+
|
|
29
|
+
if (response instanceof KafkaContext) {
|
|
30
|
+
logger.error(result);
|
|
31
|
+
|
|
32
|
+
// TODO: add sentry for manage kafka exceptions
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
if (status === HttpStatus.UNPROCESSABLE_ENTITY) {
|
|
36
|
+
return response.status(status).json(result);
|
|
37
|
+
} else if (status === HttpStatus.BAD_REQUEST) {
|
|
38
|
+
// if (result instanceof SharedMessages) {
|
|
39
|
+
//
|
|
40
|
+
// }
|
|
41
|
+
return response
|
|
42
|
+
.status(status)
|
|
43
|
+
.json(
|
|
44
|
+
new ErrorResponse(
|
|
45
|
+
String(result?.error),
|
|
46
|
+
status,
|
|
47
|
+
typeof result?.message === 'string'
|
|
48
|
+
? result?.message
|
|
49
|
+
: result?.message[0],
|
|
50
|
+
),
|
|
51
|
+
);
|
|
52
|
+
} else {
|
|
53
|
+
let message: string;
|
|
54
|
+
|
|
55
|
+
if (typeof result.message === 'string') {
|
|
56
|
+
message = result?.message;
|
|
57
|
+
} else {
|
|
58
|
+
message = result?.message[0];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return response.status(status).json(new ErrorResponse(message, status));
|
|
62
|
+
}
|
|
63
|
+
} catch (err) {
|
|
64
|
+
response
|
|
65
|
+
.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
66
|
+
.json(
|
|
67
|
+
new ErrorResponse(
|
|
68
|
+
SharedMessages.INTERNAL_SERVER_ERROR,
|
|
69
|
+
HttpStatus.INTERNAL_SERVER_ERROR,
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './http-exception.filter';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Catch, ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import { BaseRpcExceptionFilter, RpcException } from '@nestjs/microservices';
|
|
3
|
+
|
|
4
|
+
@Catch(RpcException)
|
|
5
|
+
export class KafkaExceptionFilter extends BaseRpcExceptionFilter {
|
|
6
|
+
catch(exception: any, host: ArgumentsHost) {
|
|
7
|
+
return super.catch(exception, host);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// @Catch(RpcException)
|
|
12
|
+
// export class CustomRpcExceptionFilter
|
|
13
|
+
// implements RpcExceptionFilter<RpcException>
|
|
14
|
+
// {
|
|
15
|
+
// catch(exception: RpcException, host: ArgumentsHost) {
|
|
16
|
+
// const ctx = host.switchToRpc();
|
|
17
|
+
// const response = ctx.getContext();
|
|
18
|
+
//
|
|
19
|
+
// const status =
|
|
20
|
+
// exception instanceof HttpException
|
|
21
|
+
// ? exception.getStatus()
|
|
22
|
+
// : HttpStatus.INTERNAL_SERVER_ERROR;
|
|
23
|
+
//
|
|
24
|
+
// const message = exception.message || 'Internal server error';
|
|
25
|
+
//
|
|
26
|
+
// return response.send({
|
|
27
|
+
// statusCode: status,
|
|
28
|
+
// message: message,
|
|
29
|
+
// });
|
|
30
|
+
// }
|
|
31
|
+
// // catch(exception: RpcException, host: ArgumentsHost): Observable<any> {
|
|
32
|
+
// // return throwError(() =>
|
|
33
|
+
// // new KafkaSuccessResponse<any>({
|
|
34
|
+
// // data: exception.getError(),
|
|
35
|
+
// // event_source: 'product',
|
|
36
|
+
// // status: 400,
|
|
37
|
+
// // }).stringify(),
|
|
38
|
+
// // );
|
|
39
|
+
// // }
|
|
40
|
+
// }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class MessageFormatter {
|
|
2
|
+
/**
|
|
3
|
+
* Function to replace a message from the SharedMessages enum with custom arguments.
|
|
4
|
+
* @param message The message of the SharedMessages enum.
|
|
5
|
+
* @param args Custom arguments to replace placeholders in the message.
|
|
6
|
+
* @returns The formatted message.
|
|
7
|
+
*/
|
|
8
|
+
static replace(message: string, ...args: any[]): string {
|
|
9
|
+
// Check if the message exists in the enum
|
|
10
|
+
if (!message) {
|
|
11
|
+
throw new Error(`Message with key ${message} does not exist.`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Replace placeholders in the message with provided arguments
|
|
15
|
+
if (args.length !== 0) {
|
|
16
|
+
args.forEach((arg, index) => {
|
|
17
|
+
const placeholder = `{${index}}`;
|
|
18
|
+
if (arg !== undefined && arg !== null) {
|
|
19
|
+
message = message.replace(placeholder, String(arg));
|
|
20
|
+
} else {
|
|
21
|
+
message = message.replace(placeholder, '');
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
message = message.replace(' {0} ', ' ');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return message;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const multiInheritance = (baseClass: any, extendedClasses: any[]) => {
|
|
2
|
+
extendedClasses.forEach((extendedClass) => {
|
|
3
|
+
Object.getOwnPropertyNames(extendedClass.prototype).forEach((name) => {
|
|
4
|
+
Object.defineProperty(
|
|
5
|
+
baseClass.prototype,
|
|
6
|
+
name,
|
|
7
|
+
Object.getOwnPropertyDescriptor(extendedClass.prototype, name) ||
|
|
8
|
+
Object.create(null),
|
|
9
|
+
);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const multiInheritance = (baseClass: any, extendedClasses: any[]) => {
|
|
2
|
+
extendedClasses.forEach((extendedClass) => {
|
|
3
|
+
Object.getOwnPropertyNames(extendedClass.prototype).forEach((name) => {
|
|
4
|
+
Object.defineProperty(
|
|
5
|
+
baseClass.prototype,
|
|
6
|
+
name,
|
|
7
|
+
Object.getOwnPropertyDescriptor(extendedClass.prototype, name) ||
|
|
8
|
+
Object.create(null),
|
|
9
|
+
);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
};
|
package/common/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * as caching from './caching';
|
|
2
|
+
export * as constants from './constants';
|
|
3
|
+
export * as controllers from './controllers';
|
|
4
|
+
export * as decorators from './decorators';
|
|
5
|
+
export * as dto from './dto';
|
|
6
|
+
export * as entities from './entities';
|
|
7
|
+
export * as enums from './enums';
|
|
8
|
+
export * as filters from './filters';
|
|
9
|
+
export * as helper from './helper';
|
|
10
|
+
export * as interfaces from './interface';
|
|
11
|
+
export * as lib from './lib';
|
|
12
|
+
export * as services from './services';
|
|
13
|
+
export * as strategy from './strategy';
|
|
14
|
+
export * as validators from './validators';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm';
|
|
2
|
+
import { FindOptionsRelations } from 'typeorm/find-options/FindOptionsRelations';
|
|
3
|
+
|
|
4
|
+
export class CoreCrudServiceOption<T> {
|
|
5
|
+
entityManager?: EntityManager;
|
|
6
|
+
relations?: FindOptionsRelations<T>;
|
|
7
|
+
existsCheck?: boolean = true;
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ValidationArguments } from 'class-validator/types/validation/ValidationArguments';
|
|
2
|
+
import { ValidatorConstraintInterface } from 'class-validator/types/validation/ValidatorConstraintInterface';
|
|
3
|
+
|
|
4
|
+
export interface CustomValidationArguments extends ValidationArguments {
|
|
5
|
+
constraints: CustomConstraintsInterface[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface CustomConstraintsInterface {
|
|
9
|
+
repository: string;
|
|
10
|
+
pathToProperty?: string;
|
|
11
|
+
whereQuery?: object;
|
|
12
|
+
stringPropertyQuery?: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface CustomValidatorConstraintInterface
|
|
15
|
+
extends ValidatorConstraintInterface {
|
|
16
|
+
validate(
|
|
17
|
+
value: any,
|
|
18
|
+
validationArguments?: CustomValidationArguments,
|
|
19
|
+
): Promise<boolean> | boolean;
|
|
20
|
+
}
|