@elsikora/nestjs-crud-automator 1.6.4-dev.1 → 1.6.5-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +381 -266
- package/dist/cjs/class/metadata-storage.class.js +2 -3
- package/dist/cjs/class/metadata-storage.class.js.map +1 -1
- package/dist/cjs/decorator/api/method.decorator.js +56 -56
- package/dist/cjs/decorator/api/method.decorator.js.map +1 -1
- package/dist/cjs/decorator/api/property/date.decorator.js +2 -2
- package/dist/cjs/decorator/api/property/date.decorator.js.map +1 -1
- package/dist/cjs/decorator/api/property/string.decorator.js +2 -2
- package/dist/cjs/decorator/api/property/string.decorator.js.map +1 -1
- package/dist/cjs/factory/api/controller.factory.js +3 -0
- package/dist/cjs/factory/api/controller.factory.js.map +1 -1
- package/dist/cjs/package.json +8 -0
- package/dist/cjs/utility/api/controller/get-list/transform-filter.utility.js +3 -1
- package/dist/cjs/utility/api/controller/get-list/transform-filter.utility.js.map +1 -1
- package/dist/cjs/utility/api/controller/write-dto-swagger.utility.js +1 -1
- package/dist/cjs/utility/api/controller/write-dto-swagger.utility.js.map +1 -1
- package/dist/cjs/utility/api/controller/write-method.utility.js +6 -1
- package/dist/cjs/utility/api/controller/write-method.utility.js.map +1 -1
- package/dist/cjs/utility/camel-case-string.utility.js +1 -1
- package/dist/cjs/utility/camel-case-string.utility.js.map +1 -1
- package/dist/cjs/utility/dto/generate-exception.utility.js +5 -5
- package/dist/cjs/utility/dto/generate-exception.utility.js.map +1 -1
- package/dist/cjs/utility/dto/generate-get-list-response.utility.js +5 -0
- package/dist/cjs/utility/dto/generate-get-list-response.utility.js.map +1 -1
- package/dist/cjs/utility/dto/generate-relation-response.utility.js +1 -0
- package/dist/cjs/utility/dto/generate-relation-response.utility.js.map +1 -1
- package/dist/cjs/utility/dto/get-get-list-query-base-class.utility.js +4 -0
- package/dist/cjs/utility/dto/get-get-list-query-base-class.utility.js.map +1 -1
- package/dist/cjs/validator/has-paired-custom-suffixes-fields.validator.js.map +1 -1
- package/dist/esm/class/api/index.d.ts +1 -0
- package/dist/esm/class/api/service-base.class.d.ts +11 -0
- package/dist/esm/class/index.d.ts +3 -0
- package/dist/esm/class/metadata-storage.class.d.ts +12 -0
- package/dist/esm/class/utility/dto/index.d.ts +2 -0
- package/dist/esm/class/utility/dto/property/factory/boolean.class.d.ts +6 -0
- package/dist/esm/class/utility/dto/property/factory/date.class.d.ts +6 -0
- package/dist/esm/class/utility/dto/property/factory/enum.class.d.ts +6 -0
- package/dist/esm/class/utility/dto/property/factory/index.d.ts +6 -0
- package/dist/esm/class/utility/dto/property/factory/number.class.d.ts +7 -0
- package/dist/esm/class/utility/dto/property/factory/object.class.d.ts +6 -0
- package/dist/esm/class/utility/dto/property/factory/relation.class.d.ts +7 -0
- package/dist/esm/class/utility/dto/property/factory/string.class.d.ts +6 -0
- package/dist/esm/class/utility/dto/property/factory/uuid.class.d.ts +6 -0
- package/dist/esm/class/utility/dto/property/index.d.ts +1 -0
- package/dist/esm/class/utility/dto/strategy/body.class.d.ts +6 -0
- package/dist/esm/class/utility/dto/strategy/index.d.ts +4 -0
- package/dist/esm/class/utility/dto/strategy/query.class.d.ts +6 -0
- package/dist/esm/class/utility/dto/strategy/request.class.d.ts +6 -0
- package/dist/esm/class/utility/dto/strategy/response.class.d.ts +6 -0
- package/dist/esm/class/utility/index.d.ts +1 -0
- package/dist/esm/constant/date.constant.d.ts +4 -0
- package/dist/esm/constant/decorator/api/controller.constant.d.ts +3 -0
- package/dist/esm/constant/decorator/api/function.constant.d.ts +4 -0
- package/dist/esm/constant/decorator/api/index.d.ts +3 -0
- package/dist/esm/constant/decorator/api/property-describe.constant.d.ts +3 -0
- package/dist/esm/constant/decorator/index.d.ts +1 -0
- package/dist/esm/constant/dto/exception.constant.d.ts +6 -0
- package/dist/esm/constant/dto/index.d.ts +3 -0
- package/dist/esm/constant/dto/list.constant.d.ts +7 -0
- package/dist/esm/constant/dto/transformer-value.constant.d.ts +7 -0
- package/dist/esm/constant/factory/dto/get-list-query.constant.d.ts +6 -0
- package/dist/esm/constant/factory/dto/index.d.ts +1 -0
- package/dist/esm/constant/factory/index.d.ts +1 -0
- package/dist/esm/constant/index.d.ts +6 -0
- package/dist/esm/constant/interface/api/filter.constant.d.ts +3 -0
- package/dist/esm/constant/interface/api/index.d.ts +2 -0
- package/dist/esm/constant/interface/api/property/index.d.ts +2 -0
- package/dist/esm/constant/interface/api/property/string.constant.d.ts +6 -0
- package/dist/esm/constant/interface/api/property/wallet.constant.d.ts +5 -0
- package/dist/esm/constant/interface/index.d.ts +1 -0
- package/dist/esm/constant/number.constant.d.ts +18 -0
- package/dist/esm/constant/utility/dto/constant.d.ts +6 -0
- package/dist/esm/constant/utility/dto/generate.constant.d.ts +4 -0
- package/dist/esm/decorator/api/controller.decorator.d.ts +3 -0
- package/dist/esm/decorator/api/function/create.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/function/decorator.d.ts +3 -0
- package/dist/esm/decorator/api/function/delete.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/function/get-list.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/function/get-many.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/function/get.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/function/index.d.ts +7 -0
- package/dist/esm/decorator/api/function/update.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/index.d.ts +5 -0
- package/dist/esm/decorator/api/method.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/property/boolean.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/property/date.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/property/describe.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/property/enum.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/property/index.d.ts +7 -0
- package/dist/esm/decorator/api/property/number.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/property/object.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/property/string.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/property/uuid.decorator.d.ts +2 -0
- package/dist/esm/decorator/api/service.decorator.d.ts +3 -0
- package/dist/esm/decorator/index.d.ts +1 -0
- package/dist/esm/enum/decorator/api/action.enum.d.ts +30 -0
- package/dist/esm/enum/decorator/api/authentication-type.enum.d.ts +6 -0
- package/dist/esm/enum/decorator/api/controller/index.d.ts +2 -0
- package/dist/esm/enum/decorator/api/controller/load-relations-strategy.enum.d.ts +4 -0
- package/dist/esm/enum/decorator/api/controller/request-transformer-type.enum.d.ts +4 -0
- package/dist/esm/enum/decorator/api/dto-type.enum.d.ts +6 -0
- package/dist/esm/enum/decorator/api/function/index.d.ts +1 -0
- package/dist/esm/enum/decorator/api/function/type.enum.d.ts +8 -0
- package/dist/esm/enum/decorator/api/index.d.ts +7 -0
- package/dist/esm/enum/decorator/api/property/data-type.enum.d.ts +18 -0
- package/dist/esm/enum/decorator/api/property/date/identifier.enum.d.ts +14 -0
- package/dist/esm/enum/decorator/api/property/date/index.d.ts +2 -0
- package/dist/esm/enum/decorator/api/property/date/type.enum.d.ts +5 -0
- package/dist/esm/enum/decorator/api/property/desribe-type.enum.d.ts +10 -0
- package/dist/esm/enum/decorator/api/property/index.d.ts +5 -0
- package/dist/esm/enum/decorator/api/property/number-type.enum.d.ts +4 -0
- package/dist/esm/enum/decorator/api/property/string-type.enum.d.ts +11 -0
- package/dist/esm/enum/decorator/api/route-type.enum.d.ts +8 -0
- package/dist/esm/enum/decorator/index.d.ts +1 -0
- package/dist/esm/enum/exception.enum.d.ts +30 -0
- package/dist/esm/enum/filter-operation.enum.d.ts +110 -0
- package/dist/esm/enum/filter-order-direction.enum.d.ts +4 -0
- package/dist/esm/enum/index.d.ts +4 -0
- package/dist/esm/enum/utility/error-string-action.enum.d.ts +102 -0
- package/dist/esm/enum/utility/index.d.ts +1 -0
- package/dist/esm/external/tslib/tslib.es6.js +35 -0
- package/dist/esm/external/tslib/tslib.es6.js.map +1 -0
- package/dist/esm/factory/api/controller.factory.d.ts +18 -0
- package/dist/esm/factory/api/index.d.ts +1 -0
- package/dist/esm/factory/index.d.ts +1 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/interceptor/correlation-id-response-body.interceptor.d.ts +5 -0
- package/dist/esm/interceptor/index.d.ts +1 -0
- package/dist/esm/interface/api-authentication-request.interface.d.ts +4 -0
- package/dist/esm/interface/api-base-entity.interface.d.ts +4 -0
- package/dist/esm/interface/api-dto-validator.interface.d.ts +4 -0
- package/dist/esm/interface/api-request-validator.interface.d.ts +7 -0
- package/dist/esm/interface/class/dto/index.d.ts +1 -0
- package/dist/esm/interface/class/dto/strategy.interface.d.ts +5 -0
- package/dist/esm/interface/class/index.d.ts +2 -0
- package/dist/esm/interface/class/metadata-entry.interface.d.ts +2 -0
- package/dist/esm/interface/decorator/api/controller/base.interface.d.ts +4 -0
- package/dist/esm/interface/decorator/api/controller/index.d.ts +3 -0
- package/dist/esm/interface/decorator/api/controller/properties/index.d.ts +1 -0
- package/dist/esm/interface/decorator/api/controller/properties/route/authentication.interface.d.ts +9 -0
- package/dist/esm/interface/decorator/api/controller/properties/route/auto-dto-config.interface.d.ts +4 -0
- package/dist/esm/interface/decorator/api/controller/properties/route/base-request.interface.d.ts +8 -0
- package/dist/esm/interface/decorator/api/controller/properties/route/base-response.interface.d.ts +7 -0
- package/dist/esm/interface/decorator/api/controller/properties/route/base.interface.d.ts +11 -0
- package/dist/esm/interface/decorator/api/controller/properties/route/index.d.ts +7 -0
- package/dist/esm/interface/decorator/api/controller/properties/route/with-auto-dto.interface.d.ts +7 -0
- package/dist/esm/interface/decorator/api/controller/properties/route/with-dto.interface.d.ts +7 -0
- package/dist/esm/interface/decorator/api/controller/properties.interface.d.ts +11 -0
- package/dist/esm/interface/decorator/api/function/create-executor-properties.interface.d.ts +8 -0
- package/dist/esm/interface/decorator/api/function/delete-executor-properties.interface.d.ts +9 -0
- package/dist/esm/interface/decorator/api/function/get-executor-properties.interface.d.ts +8 -0
- package/dist/esm/interface/decorator/api/function/get-list-executor-properties.interface.d.ts +8 -0
- package/dist/esm/interface/decorator/api/function/get-many-executor-properties.interface.d.ts +8 -0
- package/dist/esm/interface/decorator/api/function/index.d.ts +7 -0
- package/dist/esm/interface/decorator/api/function/properties.interface.d.ts +4 -0
- package/dist/esm/interface/decorator/api/function/update-executor-properties.interface.d.ts +10 -0
- package/dist/esm/interface/decorator/api/get-list-response-result.interface.d.ts +7 -0
- package/dist/esm/interface/decorator/api/index.d.ts +5 -0
- package/dist/esm/interface/decorator/api/method/index.d.ts +2 -0
- package/dist/esm/interface/decorator/api/method/properties.interface.d.ts +17 -0
- package/dist/esm/interface/decorator/api/method/throttler-properties.interface.d.ts +4 -0
- package/dist/esm/interface/decorator/api/response-type.interface.d.ts +9 -0
- package/dist/esm/interface/decorator/index.d.ts +1 -0
- package/dist/esm/interface/dto-generate-factory.interface.d.ts +6 -0
- package/dist/esm/interface/entity/column.interface.d.ts +7 -0
- package/dist/esm/interface/entity/index.d.ts +2 -0
- package/dist/esm/interface/entity/interface.d.ts +7 -0
- package/dist/esm/interface/index.d.ts +8 -0
- package/dist/esm/interface/utility/api/controller/index.d.ts +1 -0
- package/dist/esm/interface/utility/api/controller/primary-column.interface.d.ts +4 -0
- package/dist/esm/interface/utility/api/index.d.ts +1 -0
- package/dist/esm/interface/utility/error-string-properties.interface.d.ts +5 -0
- package/dist/esm/interface/utility/get-entity-columns-properties.interface.d.ts +6 -0
- package/dist/esm/interface/utility/index.d.ts +2 -0
- package/dist/esm/package.json +8 -0
- package/dist/esm/src/class/api/service-base.class.js +23 -0
- package/dist/esm/src/class/api/service-base.class.js.map +1 -0
- package/dist/esm/src/class/metadata-storage.class.js +47 -0
- package/dist/esm/src/class/metadata-storage.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/property/factory/boolean.class.js +15 -0
- package/dist/esm/src/class/utility/dto/property/factory/boolean.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/property/factory/date.class.js +15 -0
- package/dist/esm/src/class/utility/dto/property/factory/date.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/property/factory/enum.class.js +15 -0
- package/dist/esm/src/class/utility/dto/property/factory/enum.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/property/factory/number.class.js +32 -0
- package/dist/esm/src/class/utility/dto/property/factory/number.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/property/factory/object.class.js +16 -0
- package/dist/esm/src/class/utility/dto/property/factory/object.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/property/factory/relation.class.js +29 -0
- package/dist/esm/src/class/utility/dto/property/factory/relation.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/property/factory/string.class.js +15 -0
- package/dist/esm/src/class/utility/dto/property/factory/string.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/property/factory/uuid.class.js +11 -0
- package/dist/esm/src/class/utility/dto/property/factory/uuid.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/strategy/body.class.js +47 -0
- package/dist/esm/src/class/utility/dto/strategy/body.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/strategy/query.class.js +44 -0
- package/dist/esm/src/class/utility/dto/strategy/query.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/strategy/request.class.js +47 -0
- package/dist/esm/src/class/utility/dto/strategy/request.class.js.map +1 -0
- package/dist/esm/src/class/utility/dto/strategy/response.class.js +47 -0
- package/dist/esm/src/class/utility/dto/strategy/response.class.js.map +1 -0
- package/dist/esm/src/constant/date.constant.js +9 -0
- package/dist/esm/src/constant/date.constant.js.map +1 -0
- package/dist/esm/src/constant/decorator/api/controller.constant.js +7 -0
- package/dist/esm/src/constant/decorator/api/controller.constant.js.map +1 -0
- package/dist/esm/src/constant/decorator/api/function.constant.js +24 -0
- package/dist/esm/src/constant/decorator/api/function.constant.js.map +1 -0
- package/dist/esm/src/constant/decorator/api/property-describe.constant.js +7 -0
- package/dist/esm/src/constant/decorator/api/property-describe.constant.js.map +1 -0
- package/dist/esm/src/constant/dto/exception.constant.js +13 -0
- package/dist/esm/src/constant/dto/exception.constant.js.map +1 -0
- package/dist/esm/src/constant/dto/list.constant.js +13 -0
- package/dist/esm/src/constant/dto/list.constant.js.map +1 -0
- package/dist/esm/src/constant/dto/transformer-value.constant.js +15 -0
- package/dist/esm/src/constant/dto/transformer-value.constant.js.map +1 -0
- package/dist/esm/src/constant/factory/dto/get-list-query.constant.js +13 -0
- package/dist/esm/src/constant/factory/dto/get-list-query.constant.js.map +1 -0
- package/dist/esm/src/constant/interface/api/filter.constant.js +7 -0
- package/dist/esm/src/constant/interface/api/filter.constant.js.map +1 -0
- package/dist/esm/src/constant/interface/api/property/string.constant.js +11 -0
- package/dist/esm/src/constant/interface/api/property/string.constant.js.map +1 -0
- package/dist/esm/src/constant/interface/api/property/wallet.constant.js +11 -0
- package/dist/esm/src/constant/interface/api/property/wallet.constant.js.map +1 -0
- package/dist/esm/src/constant/number.constant.js +37 -0
- package/dist/esm/src/constant/number.constant.js.map +1 -0
- package/dist/esm/src/constant/utility/dto/constant.js +53 -0
- package/dist/esm/src/constant/utility/dto/constant.js.map +1 -0
- package/dist/esm/src/constant/utility/dto/generate.constant.js +9 -0
- package/dist/esm/src/constant/utility/dto/generate.constant.js.map +1 -0
- package/dist/esm/src/decorator/api/controller.decorator.js +16 -0
- package/dist/esm/src/decorator/api/controller.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/function/create.decorator.js +51 -0
- package/dist/esm/src/decorator/api/function/create.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/function/decorator.js +69 -0
- package/dist/esm/src/decorator/api/function/decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/function/delete.decorator.js +69 -0
- package/dist/esm/src/decorator/api/function/delete.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/function/get-list.decorator.js +58 -0
- package/dist/esm/src/decorator/api/function/get-list.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/function/get-many.decorator.js +55 -0
- package/dist/esm/src/decorator/api/function/get-many.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/function/get.decorator.js +55 -0
- package/dist/esm/src/decorator/api/function/get.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/function/update.decorator.js +80 -0
- package/dist/esm/src/decorator/api/function/update.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/method.decorator.js +349 -0
- package/dist/esm/src/decorator/api/method.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/property/boolean.decorator.js +177 -0
- package/dist/esm/src/decorator/api/property/boolean.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/property/date.decorator.js +204 -0
- package/dist/esm/src/decorator/api/property/date.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/property/describe.decorator.js +29 -0
- package/dist/esm/src/decorator/api/property/describe.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/property/enum.decorator.js +103 -0
- package/dist/esm/src/decorator/api/property/enum.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/property/number.decorator.js +213 -0
- package/dist/esm/src/decorator/api/property/number.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/property/object.decorator.js +102 -0
- package/dist/esm/src/decorator/api/property/object.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/property/string.decorator.js +232 -0
- package/dist/esm/src/decorator/api/property/string.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/property/uuid.decorator.js +118 -0
- package/dist/esm/src/decorator/api/property/uuid.decorator.js.map +1 -0
- package/dist/esm/src/decorator/api/service.decorator.js +161 -0
- package/dist/esm/src/decorator/api/service.decorator.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/action.enum.js +34 -0
- package/dist/esm/src/enum/decorator/api/action.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/authentication-type.enum.js +10 -0
- package/dist/esm/src/enum/decorator/api/authentication-type.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/controller/load-relations-strategy.enum.js +8 -0
- package/dist/esm/src/enum/decorator/api/controller/load-relations-strategy.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/controller/request-transformer-type.enum.js +8 -0
- package/dist/esm/src/enum/decorator/api/controller/request-transformer-type.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/dto-type.enum.js +10 -0
- package/dist/esm/src/enum/decorator/api/dto-type.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/function/type.enum.js +12 -0
- package/dist/esm/src/enum/decorator/api/function/type.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/property/data-type.enum.js +22 -0
- package/dist/esm/src/enum/decorator/api/property/data-type.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/property/date/identifier.enum.js +18 -0
- package/dist/esm/src/enum/decorator/api/property/date/identifier.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/property/date/type.enum.js +11 -0
- package/dist/esm/src/enum/decorator/api/property/date/type.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/property/desribe-type.enum.js +14 -0
- package/dist/esm/src/enum/decorator/api/property/desribe-type.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/property/number-type.enum.js +10 -0
- package/dist/esm/src/enum/decorator/api/property/number-type.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/property/string-type.enum.js +17 -0
- package/dist/esm/src/enum/decorator/api/property/string-type.enum.js.map +1 -0
- package/dist/esm/src/enum/decorator/api/route-type.enum.js +12 -0
- package/dist/esm/src/enum/decorator/api/route-type.enum.js.map +1 -0
- package/dist/esm/src/enum/exception.enum.js +34 -0
- package/dist/esm/src/enum/exception.enum.js.map +1 -0
- package/dist/esm/src/enum/filter-operation.enum.js +123 -0
- package/dist/esm/src/enum/filter-operation.enum.js.map +1 -0
- package/dist/esm/src/enum/filter-order-direction.enum.js +8 -0
- package/dist/esm/src/enum/filter-order-direction.enum.js.map +1 -0
- package/dist/esm/src/enum/utility/error-string-action.enum.js +106 -0
- package/dist/esm/src/enum/utility/error-string-action.enum.js.map +1 -0
- package/dist/esm/src/factory/api/controller.factory.js +216 -0
- package/dist/esm/src/factory/api/controller.factory.js.map +1 -0
- package/dist/esm/src/index.js +82 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/interceptor/correlation-id-response-body.interceptor.js +76 -0
- package/dist/esm/src/interceptor/correlation-id-response-body.interceptor.js.map +1 -0
- package/dist/esm/src/utility/api/controller/apply-decorators.utility.js +81 -0
- package/dist/esm/src/utility/api/controller/apply-decorators.utility.js.map +1 -0
- package/dist/esm/src/utility/api/controller/apply-metadata.utility.js +76 -0
- package/dist/esm/src/utility/api/controller/apply-metadata.utility.js.map +1 -0
- package/dist/esm/src/utility/api/controller/get-list/transform-filter.utility.js +48 -0
- package/dist/esm/src/utility/api/controller/get-list/transform-filter.utility.js.map +1 -0
- package/dist/esm/src/utility/api/controller/get-list/transform-operation.utility.js +80 -0
- package/dist/esm/src/utility/api/controller/get-list/transform-operation.utility.js.map +1 -0
- package/dist/esm/src/utility/api/controller/get-method-name.utility.js +9 -0
- package/dist/esm/src/utility/api/controller/get-method-name.utility.js.map +1 -0
- package/dist/esm/src/utility/api/controller/get-primary-column.utility.js +13 -0
- package/dist/esm/src/utility/api/controller/get-primary-column.utility.js.map +1 -0
- package/dist/esm/src/utility/api/controller/handle-request-relations.utility.js +70 -0
- package/dist/esm/src/utility/api/controller/handle-request-relations.utility.js.map +1 -0
- package/dist/esm/src/utility/api/controller/transform-data.utility.js +147 -0
- package/dist/esm/src/utility/api/controller/transform-data.utility.js.map +1 -0
- package/dist/esm/src/utility/api/controller/validate-request.utility.js +16 -0
- package/dist/esm/src/utility/api/controller/validate-request.utility.js.map +1 -0
- package/dist/esm/src/utility/api/controller/write-dto-swagger.utility.js +77 -0
- package/dist/esm/src/utility/api/controller/write-dto-swagger.utility.js.map +1 -0
- package/dist/esm/src/utility/api/controller/write-method.utility.js +18 -0
- package/dist/esm/src/utility/api/controller/write-method.utility.js.map +1 -0
- package/dist/esm/src/utility/api/filter-order-by-from-entity.utility.js +46 -0
- package/dist/esm/src/utility/api/filter-order-by-from-entity.utility.js.map +1 -0
- package/dist/esm/src/utility/camel-case-string.utility.js +29 -0
- package/dist/esm/src/utility/camel-case-string.utility.js.map +1 -0
- package/dist/esm/src/utility/capitalize-string.utility.js +6 -0
- package/dist/esm/src/utility/capitalize-string.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/analize.utility.js +25 -0
- package/dist/esm/src/utility/dto/analize.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/build-decorator.utility.js +49 -0
- package/dist/esm/src/utility/dto/build-decorator.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/generate-decorator.utility.js +13 -0
- package/dist/esm/src/utility/dto/generate-decorator.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/generate-exception.utility.js +96 -0
- package/dist/esm/src/utility/dto/generate-exception.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/generate-filter-decorator.utility.js +50 -0
- package/dist/esm/src/utility/dto/generate-filter-decorator.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/generate-get-list-response.utility.js +102 -0
- package/dist/esm/src/utility/dto/generate-get-list-response.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/generate-relation-response.utility.js +19 -0
- package/dist/esm/src/utility/dto/generate-relation-response.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/generate.utility.js +131 -0
- package/dist/esm/src/utility/dto/generate.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/get-decorator-config.utility.js +18 -0
- package/dist/esm/src/utility/dto/get-decorator-config.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/get-get-list-query-base-class.utility.js +95 -0
- package/dist/esm/src/utility/dto/get-get-list-query-base-class.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/handle-date-property.utility.js +33 -0
- package/dist/esm/src/utility/dto/handle-date-property.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/is-property-exposed-for-guard.utility.js +13 -0
- package/dist/esm/src/utility/dto/is-property-exposed-for-guard.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/is-property-should-be-marked.utility.js +44 -0
- package/dist/esm/src/utility/dto/is-property-should-be-marked.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/is-should-be-generated.utility.js +39 -0
- package/dist/esm/src/utility/dto/is-should-be-generated.utility.js.map +1 -0
- package/dist/esm/src/utility/dto/validate-property-config.utility.js +4 -0
- package/dist/esm/src/utility/dto/validate-property-config.utility.js.map +1 -0
- package/dist/esm/src/utility/error-exception.utility.js +6 -0
- package/dist/esm/src/utility/error-exception.utility.js.map +1 -0
- package/dist/esm/src/utility/error-string.utility.js +6 -0
- package/dist/esm/src/utility/error-string.utility.js.map +1 -0
- package/dist/esm/src/utility/generate-entity-information.utility.js +76 -0
- package/dist/esm/src/utility/generate-entity-information.utility.js.map +1 -0
- package/dist/esm/src/utility/get-entity-columns.utility.js +20 -0
- package/dist/esm/src/utility/get-entity-columns.utility.js.map +1 -0
- package/dist/esm/src/utility/is-error-of-type.utility.js +66 -0
- package/dist/esm/src/utility/is-error-of-type.utility.js.map +1 -0
- package/dist/esm/src/validator/all-or-none-of-listed-properties.validator.js +23 -0
- package/dist/esm/src/validator/all-or-none-of-listed-properties.validator.js.map +1 -0
- package/dist/esm/src/validator/has-at-least-one-and-only-one-of-listed-properties.validator.js +33 -0
- package/dist/esm/src/validator/has-at-least-one-and-only-one-of-listed-properties.validator.js.map +1 -0
- package/dist/esm/src/validator/has-at-least-one-of-listed-properties.validator.js +29 -0
- package/dist/esm/src/validator/has-at-least-one-of-listed-properties.validator.js.map +1 -0
- package/dist/esm/src/validator/has-at-least-one-property.validator.js +17 -0
- package/dist/esm/src/validator/has-at-least-one-property.validator.js.map +1 -0
- package/dist/esm/src/validator/has-paired-custom-suffixes-fields.validator.js +214 -0
- package/dist/esm/src/validator/has-paired-custom-suffixes-fields.validator.js.map +1 -0
- package/dist/esm/src/validator/is-regular-expression.validator.js +25 -0
- package/dist/esm/src/validator/is-regular-expression.validator.js.map +1 -0
- package/dist/esm/src/validator/only-one-of-listed-properties.validator.js +28 -0
- package/dist/esm/src/validator/only-one-of-listed-properties.validator.js.map +1 -0
- package/dist/esm/type/api-request-transformer.type.d.ts +15 -0
- package/dist/esm/type/class/api-exception.type.d.ts +2 -0
- package/dist/esm/type/class/controller/index.d.ts +1 -0
- package/dist/esm/type/class/controller/method.type.d.ts +5 -0
- package/dist/esm/type/class/index.d.ts +3 -0
- package/dist/esm/type/class/metadata.type.d.ts +2 -0
- package/dist/esm/type/decorator/api/controller/constructor.type.d.ts +4 -0
- package/dist/esm/type/decorator/api/controller/get-list-query.type.d.ts +8 -0
- package/dist/esm/type/decorator/api/controller/index.d.ts +5 -0
- package/dist/esm/type/decorator/api/controller/properties/index.d.ts +1 -0
- package/dist/esm/type/decorator/api/controller/properties/route/base-request-relations.type.d.ts +18 -0
- package/dist/esm/type/decorator/api/controller/properties/route/base-request-transformers.type.d.ts +10 -0
- package/dist/esm/type/decorator/api/controller/properties/route/base-response-transformers.type.d.ts +10 -0
- package/dist/esm/type/decorator/api/controller/properties/route/index.d.ts +3 -0
- package/dist/esm/type/decorator/api/controller/properties-route.type.d.ts +3 -0
- package/dist/esm/type/decorator/api/controller/transformer-config.type.d.ts +8 -0
- package/dist/esm/type/decorator/api/filter/allowed-types.type.d.ts +1 -0
- package/dist/esm/type/decorator/api/filter/extracted-allowed-types.type.d.ts +2 -0
- package/dist/esm/type/decorator/api/filter/field-selector.type.d.ts +3 -0
- package/dist/esm/type/decorator/api/filter/index.d.ts +4 -0
- package/dist/esm/type/decorator/api/filter/order-by.type.d.ts +4 -0
- package/dist/esm/type/decorator/api/function/create-properties.type.d.ts +2 -0
- package/dist/esm/type/decorator/api/function/delete-criteria.type.d.ts +2 -0
- package/dist/esm/type/decorator/api/function/get-list-properties-where.type.d.ts +7 -0
- package/dist/esm/type/decorator/api/function/get-list-properties.type.d.ts +2 -0
- package/dist/esm/type/decorator/api/function/get-many.properties.d.ts +2 -0
- package/dist/esm/type/decorator/api/function/get-properties.type.d.ts +2 -0
- package/dist/esm/type/decorator/api/function/index.d.ts +9 -0
- package/dist/esm/type/decorator/api/function/properties.type.d.ts +7 -0
- package/dist/esm/type/decorator/api/function/update-criteria.type.d.ts +2 -0
- package/dist/esm/type/decorator/api/function/update-properties.type.d.ts +2 -0
- package/dist/esm/type/decorator/api/index.d.ts +5 -0
- package/dist/esm/type/decorator/api/property/base/array/index.d.ts +2 -0
- package/dist/esm/type/decorator/api/property/base/array/optional-properties.type.d.ts +3 -0
- package/dist/esm/type/decorator/api/property/base/array/required-properties.type.d.ts +6 -0
- package/dist/esm/type/decorator/api/property/base/index.d.ts +4 -0
- package/dist/esm/type/decorator/api/property/base/properties.type.d.ts +9 -0
- package/dist/esm/type/decorator/api/property/base/request-properties.type.d.ts +4 -0
- package/dist/esm/type/decorator/api/property/base/response-properties.type.d.ts +4 -0
- package/dist/esm/type/decorator/api/property/date-properties.type.d.ts +6 -0
- package/dist/esm/type/decorator/api/property/describe/array/index.d.ts +2 -0
- package/dist/esm/type/decorator/api/property/describe/array/optional-properties.type.d.ts +3 -0
- package/dist/esm/type/decorator/api/property/describe/array/required-properties.type.d.ts +6 -0
- package/dist/esm/type/decorator/api/property/describe/base-properties.type.d.ts +5 -0
- package/dist/esm/type/decorator/api/property/describe/boolean-properties.type.d.ts +7 -0
- package/dist/esm/type/decorator/api/property/describe/date-properties.type.d.ts +8 -0
- package/dist/esm/type/decorator/api/property/describe/dto/body-properties.type.d.ts +5 -0
- package/dist/esm/type/decorator/api/property/describe/dto/guard-properties.type.d.ts +6 -0
- package/dist/esm/type/decorator/api/property/describe/dto/index.d.ts +5 -0
- package/dist/esm/type/decorator/api/property/describe/dto/properties.type.d.ts +11 -0
- package/dist/esm/type/decorator/api/property/describe/dto/query/get-list-properties.type.d.ts +3 -0
- package/dist/esm/type/decorator/api/property/describe/dto/query/index.d.ts +2 -0
- package/dist/esm/type/decorator/api/property/describe/dto/query/properties.type.d.ts +6 -0
- package/dist/esm/type/decorator/api/property/describe/dto/request-properties.type.d.ts +5 -0
- package/dist/esm/type/decorator/api/property/describe/dto/response-properties.type.d.ts +5 -0
- package/dist/esm/type/decorator/api/property/describe/enum-properties.type.d.ts +9 -0
- package/dist/esm/type/decorator/api/property/describe/example-properties.type.d.ts +7 -0
- package/dist/esm/type/decorator/api/property/describe/index.d.ts +13 -0
- package/dist/esm/type/decorator/api/property/describe/number-properties.type.d.ts +12 -0
- package/dist/esm/type/decorator/api/property/describe/object-properties.type.d.ts +12 -0
- package/dist/esm/type/decorator/api/property/describe/properties/base-dto-properties.type.d.ts +2 -0
- package/dist/esm/type/decorator/api/property/describe/properties/base-properties.type.d.ts +10 -0
- package/dist/esm/type/decorator/api/property/describe/properties/index.d.ts +2 -0
- package/dist/esm/type/decorator/api/property/describe/properties.type.d.ts +9 -0
- package/dist/esm/type/decorator/api/property/describe/relation-properties.type.d.ts +6 -0
- package/dist/esm/type/decorator/api/property/describe/string-properties.type.d.ts +12 -0
- package/dist/esm/type/decorator/api/property/describe/uuid-properties.type.d.ts +7 -0
- package/dist/esm/type/decorator/api/property/enum-properties.type.d.ts +6 -0
- package/dist/esm/type/decorator/api/property/index.d.ts +6 -0
- package/dist/esm/type/decorator/api/property/number-properties.type.d.ts +9 -0
- package/dist/esm/type/decorator/api/property/object-properties.type.d.ts +8 -0
- package/dist/esm/type/decorator/api/property/string-properties.type.d.ts +9 -0
- package/dist/esm/type/decorator/api/property/uuid-properties.type.d.ts +2 -0
- package/dist/esm/type/decorator/api/service/index.d.ts +2 -0
- package/dist/esm/type/decorator/api/service/keys.type.d.ts +4 -0
- package/dist/esm/type/decorator/api/service/properties.type.d.ts +3 -0
- package/dist/esm/type/decorator/index.d.ts +1 -0
- package/dist/esm/type/factory/api/controller/index.d.ts +4 -0
- package/dist/esm/type/factory/api/controller/method-map.type.d.ts +12 -0
- package/dist/esm/type/factory/api/controller/method-name-map.type.d.ts +5 -0
- package/dist/esm/type/factory/api/controller/method-name.type.d.ts +4 -0
- package/dist/esm/type/factory/api/controller/target-methods.type.d.ts +9 -0
- package/dist/esm/type/factory/api/index.d.ts +1 -0
- package/dist/esm/type/factory/index.d.ts +1 -0
- package/dist/esm/type/index.d.ts +5 -0
- package/dist/esm/type/utility/api/controller/index.d.ts +1 -0
- package/dist/esm/type/utility/api/controller/transform-data/data.type.d.ts +6 -0
- package/dist/esm/type/utility/api/controller/transform-data/index.d.ts +3 -0
- package/dist/esm/type/utility/api/controller/transform-data/is-validation-properties.type.d.ts +3 -0
- package/dist/esm/type/utility/api/controller/transform-data/object-to-transform.type.d.ts +9 -0
- package/dist/esm/type/utility/api/index.d.ts +1 -0
- package/dist/esm/type/utility/capitalize-string.type.d.ts +1 -0
- package/dist/esm/type/utility/date-keys.type.d.ts +2 -0
- package/dist/esm/type/utility/date-range-keys.type.d.ts +4 -0
- package/dist/esm/type/utility/dto/generate-allowed-combination.type.d.ts +9 -0
- package/dist/esm/type/utility/dto/generate-is-allowed-combination.type.d.ts +3 -0
- package/dist/esm/type/utility/dto/index.d.ts +2 -0
- package/dist/esm/type/utility/filter-keys.type.d.ts +7 -0
- package/dist/esm/type/utility/index.d.ts +7 -0
- package/dist/esm/type/utility/non-date-keys.type.d.ts +2 -0
- package/dist/esm/utility/api/controller/apply-decorators.utility.d.ts +4 -0
- package/dist/esm/utility/api/controller/apply-metadata.utility.d.ts +4 -0
- package/dist/esm/utility/api/controller/get-list/index.d.ts +2 -0
- package/dist/esm/utility/api/controller/get-list/transform-filter.utility.d.ts +3 -0
- package/dist/esm/utility/api/controller/get-list/transform-operation.utility.d.ts +3 -0
- package/dist/esm/utility/api/controller/get-method-name.utility.d.ts +2 -0
- package/dist/esm/utility/api/controller/get-primary-column.utility.d.ts +3 -0
- package/dist/esm/utility/api/controller/handle-request-relations.utility.d.ts +4 -0
- package/dist/esm/utility/api/controller/index.d.ts +9 -0
- package/dist/esm/utility/api/controller/transform-data.utility.d.ts +4 -0
- package/dist/esm/utility/api/controller/validate-request.utility.d.ts +3 -0
- package/dist/esm/utility/api/controller/write-dto-swagger.utility.d.ts +4 -0
- package/dist/esm/utility/api/controller/write-method.utility.d.ts +3 -0
- package/dist/esm/utility/api/filter-order-by-from-entity.utility.d.ts +6 -0
- package/dist/esm/utility/api/index.d.ts +2 -0
- package/dist/esm/utility/camel-case-string.utility.d.ts +1 -0
- package/dist/esm/utility/capitalize-string.utility.d.ts +1 -0
- package/dist/esm/utility/dto/analize.utility.d.ts +2 -0
- package/dist/esm/utility/dto/build-decorator.utility.d.ts +6 -0
- package/dist/esm/utility/dto/generate-decorator.utility.d.ts +4 -0
- package/dist/esm/utility/dto/generate-exception.utility.d.ts +2 -0
- package/dist/esm/utility/dto/generate-filter-decorator.utility.d.ts +3 -0
- package/dist/esm/utility/dto/generate-get-list-response.utility.d.ts +4 -0
- package/dist/esm/utility/dto/generate-relation-response.utility.d.ts +4 -0
- package/dist/esm/utility/dto/generate.utility.d.ts +6 -0
- package/dist/esm/utility/dto/get-decorator-config.utility.d.ts +3 -0
- package/dist/esm/utility/dto/get-get-list-query-base-class.utility.d.ts +5 -0
- package/dist/esm/utility/dto/handle-date-property.utility.d.ts +5 -0
- package/dist/esm/utility/dto/index.d.ts +12 -0
- package/dist/esm/utility/dto/is-property-exposed-for-guard.utility.d.ts +5 -0
- package/dist/esm/utility/dto/is-property-should-be-marked.utility.d.ts +5 -0
- package/dist/esm/utility/dto/is-should-be-generated.utility.d.ts +2 -0
- package/dist/esm/utility/dto/validate-property-config.utility.d.ts +2 -0
- package/dist/esm/utility/error-exception.utility.d.ts +1 -0
- package/dist/esm/utility/error-string.utility.d.ts +2 -0
- package/dist/esm/utility/generate-entity-information.utility.d.ts +2 -0
- package/dist/esm/utility/get-entity-columns.utility.d.ts +2 -0
- package/dist/esm/utility/index.d.ts +9 -0
- package/dist/esm/utility/is-error-of-type.utility.d.ts +2 -0
- package/dist/esm/validator/all-or-none-of-listed-properties.validator.d.ts +5 -0
- package/dist/esm/validator/has-at-least-one-and-only-one-of-listed-properties.validator.d.ts +5 -0
- package/dist/esm/validator/has-at-least-one-of-listed-properties.validator.d.ts +5 -0
- package/dist/esm/validator/has-at-least-one-property.validator.d.ts +5 -0
- package/dist/esm/validator/has-paired-custom-suffixes-fields.validator.d.ts +7 -0
- package/dist/esm/validator/index.d.ts +6 -0
- package/dist/esm/validator/is-regular-expression.validator.d.ts +4 -0
- package/dist/esm/validator/only-one-of-listed-properties.validator.d.ts +5 -0
- package/package.json +22 -14
- package/dist/package.json +0 -97
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { applyDecorators } from '@nestjs/common';
|
|
2
|
+
import { ApiProperty, ApiResponseProperty } from '@nestjs/swagger';
|
|
3
|
+
import { Expose, Exclude, Transform } from 'class-transformer';
|
|
4
|
+
import { IsOptional, IsArray, ArrayMinSize, ArrayMaxSize, ArrayNotEmpty, IsDate } from 'class-validator';
|
|
5
|
+
import '../../../enum/decorator/api/action.enum.js';
|
|
6
|
+
import '../../../enum/decorator/api/authentication-type.enum.js';
|
|
7
|
+
import '../../../enum/decorator/api/controller/load-relations-strategy.enum.js';
|
|
8
|
+
import '../../../enum/decorator/api/controller/request-transformer-type.enum.js';
|
|
9
|
+
import '../../../enum/decorator/api/dto-type.enum.js';
|
|
10
|
+
import '../../../enum/decorator/api/function/type.enum.js';
|
|
11
|
+
import { EApiPropertyDataType } from '../../../enum/decorator/api/property/data-type.enum.js';
|
|
12
|
+
import { EApiPropertyDateIdentifier } from '../../../enum/decorator/api/property/date/identifier.enum.js';
|
|
13
|
+
import { EApiPropertyDateType } from '../../../enum/decorator/api/property/date/type.enum.js';
|
|
14
|
+
import '../../../enum/decorator/api/property/desribe-type.enum.js';
|
|
15
|
+
import '../../../enum/decorator/api/property/number-type.enum.js';
|
|
16
|
+
import '../../../enum/decorator/api/property/string-type.enum.js';
|
|
17
|
+
import '../../../enum/decorator/api/route-type.enum.js';
|
|
18
|
+
import '../../../enum/exception.enum.js';
|
|
19
|
+
import '../../../enum/filter-order-direction.enum.js';
|
|
20
|
+
import '../../../enum/utility/error-string-action.enum.js';
|
|
21
|
+
|
|
22
|
+
function ApiPropertyDate(properties) {
|
|
23
|
+
validateOptions(properties);
|
|
24
|
+
const apiPropertyOptions = buildApiPropertyOptions(properties);
|
|
25
|
+
const decorators = buildDecorators(properties, apiPropertyOptions);
|
|
26
|
+
return applyDecorators(...decorators);
|
|
27
|
+
}
|
|
28
|
+
function buildApiPropertyOptions(properties) {
|
|
29
|
+
const example = getExample(properties.format);
|
|
30
|
+
const apiPropertyOptions = {
|
|
31
|
+
description: `${String(properties.entity.name)} ${getDescription(properties.identifier)}`,
|
|
32
|
+
nullable: properties.isNullable,
|
|
33
|
+
type: EApiPropertyDataType.STRING,
|
|
34
|
+
};
|
|
35
|
+
apiPropertyOptions.required = properties.isResponse === false || properties.isResponse === undefined ? properties.isRequired : false;
|
|
36
|
+
if (properties.isArray) {
|
|
37
|
+
apiPropertyOptions.isArray = true;
|
|
38
|
+
apiPropertyOptions.minItems = properties.minItems;
|
|
39
|
+
apiPropertyOptions.maxItems = properties.maxItems;
|
|
40
|
+
apiPropertyOptions.uniqueItems = properties.isUniqueItems;
|
|
41
|
+
apiPropertyOptions.items = {
|
|
42
|
+
maxLength: example.length,
|
|
43
|
+
minLength: example.length,
|
|
44
|
+
};
|
|
45
|
+
apiPropertyOptions.example = [example];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
apiPropertyOptions.minLength = example.length;
|
|
49
|
+
apiPropertyOptions.maxLength = example.length;
|
|
50
|
+
apiPropertyOptions.example = example;
|
|
51
|
+
}
|
|
52
|
+
apiPropertyOptions.pattern = getPattern(properties.format);
|
|
53
|
+
apiPropertyOptions.format = properties.format;
|
|
54
|
+
return apiPropertyOptions;
|
|
55
|
+
}
|
|
56
|
+
function buildDecorators(properties, apiPropertyOptions) {
|
|
57
|
+
const decorators = [ApiProperty(apiPropertyOptions)];
|
|
58
|
+
decorators.push(...buildResponseDecorators(properties), ...buildRequestDecorators(properties), ...buildFormatDecorators(properties), ...buildTransformDecorators(properties));
|
|
59
|
+
return decorators;
|
|
60
|
+
}
|
|
61
|
+
function buildFormatDecorators(properties) {
|
|
62
|
+
const decorators = [];
|
|
63
|
+
const isArray = properties.isArray ?? false;
|
|
64
|
+
if (!properties.isResponse) {
|
|
65
|
+
decorators.push(IsDate({ each: isArray }));
|
|
66
|
+
}
|
|
67
|
+
return decorators;
|
|
68
|
+
}
|
|
69
|
+
function buildRequestDecorators(properties) {
|
|
70
|
+
const decorators = [];
|
|
71
|
+
if (properties.isResponse === false || properties.isResponse === undefined) {
|
|
72
|
+
if (!properties.isRequired) {
|
|
73
|
+
decorators.push(IsOptional());
|
|
74
|
+
}
|
|
75
|
+
if (properties.isArray === true) {
|
|
76
|
+
decorators.push(IsArray(), ArrayMinSize(properties.minItems), ArrayMaxSize(properties.maxItems));
|
|
77
|
+
if (properties.minItems > 0) {
|
|
78
|
+
decorators.push(ArrayNotEmpty());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return decorators;
|
|
83
|
+
}
|
|
84
|
+
function buildResponseDecorators(properties) {
|
|
85
|
+
const decorators = [];
|
|
86
|
+
if (properties.isResponse) {
|
|
87
|
+
decorators.push(ApiResponseProperty());
|
|
88
|
+
if (properties.isExpose === undefined || properties.isExpose) {
|
|
89
|
+
decorators.push(Expose());
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
decorators.push(Exclude());
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return decorators;
|
|
96
|
+
}
|
|
97
|
+
function buildTransformDecorators(properties) {
|
|
98
|
+
const decorators = [];
|
|
99
|
+
if (!properties.isResponse) {
|
|
100
|
+
if (properties.isArray) {
|
|
101
|
+
decorators.push(Transform(({ value }) => {
|
|
102
|
+
if (!Array.isArray(value)) {
|
|
103
|
+
const singleValue = value;
|
|
104
|
+
return singleValue ? [new Date(singleValue)] : [];
|
|
105
|
+
}
|
|
106
|
+
return value.map((dateString) => (dateString ? new Date(dateString) : undefined));
|
|
107
|
+
}, { toClassOnly: true }));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
decorators.push(Transform(({ value }) => (value ? new Date(value) : undefined), { toClassOnly: true }));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return decorators;
|
|
114
|
+
}
|
|
115
|
+
function getDescription(identifier) {
|
|
116
|
+
switch (identifier) {
|
|
117
|
+
case EApiPropertyDateIdentifier.CREATED_AT: {
|
|
118
|
+
return "creation date";
|
|
119
|
+
}
|
|
120
|
+
case EApiPropertyDateIdentifier.CREATED_AT_FROM: {
|
|
121
|
+
return "createdAt from";
|
|
122
|
+
}
|
|
123
|
+
case EApiPropertyDateIdentifier.CREATED_AT_TO: {
|
|
124
|
+
return "createdAt to";
|
|
125
|
+
}
|
|
126
|
+
case EApiPropertyDateIdentifier.DATE: {
|
|
127
|
+
return "date";
|
|
128
|
+
}
|
|
129
|
+
case EApiPropertyDateIdentifier.EXPIRES_IN: {
|
|
130
|
+
return "expiration date";
|
|
131
|
+
}
|
|
132
|
+
case EApiPropertyDateIdentifier.RECEIVED_AT: {
|
|
133
|
+
return "receivedAt date";
|
|
134
|
+
}
|
|
135
|
+
case EApiPropertyDateIdentifier.RECEIVED_AT_FROM: {
|
|
136
|
+
return "receivedAt from";
|
|
137
|
+
}
|
|
138
|
+
case EApiPropertyDateIdentifier.RECEIVED_AT_TO: {
|
|
139
|
+
return "receivedAt to";
|
|
140
|
+
}
|
|
141
|
+
case EApiPropertyDateIdentifier.REFRESH_IN: {
|
|
142
|
+
return "refresh date";
|
|
143
|
+
}
|
|
144
|
+
case EApiPropertyDateIdentifier.UPDATED_AT: {
|
|
145
|
+
return "last update date";
|
|
146
|
+
}
|
|
147
|
+
case EApiPropertyDateIdentifier.UPDATED_AT_FROM: {
|
|
148
|
+
return "updatedAt from";
|
|
149
|
+
}
|
|
150
|
+
case EApiPropertyDateIdentifier.UPDATED_AT_TO: {
|
|
151
|
+
return "updatedAt to";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function getExample(format) {
|
|
156
|
+
const startOfYearUTCDate = new Date(Date.UTC(new Date().getUTCFullYear(), 0, 1, 0, 0, 0, 0));
|
|
157
|
+
switch (format) {
|
|
158
|
+
case EApiPropertyDateType.DATE: {
|
|
159
|
+
return startOfYearUTCDate.toISOString().split("T")[0] ?? "2025-01-01";
|
|
160
|
+
}
|
|
161
|
+
case EApiPropertyDateType.DATE_TIME: {
|
|
162
|
+
return startOfYearUTCDate.toISOString();
|
|
163
|
+
}
|
|
164
|
+
case EApiPropertyDateType.TIME: {
|
|
165
|
+
return startOfYearUTCDate.toISOString().split("T")[1]?.split(".")[0] ?? "00:00:00";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function getPattern(format) {
|
|
170
|
+
switch (format) {
|
|
171
|
+
case EApiPropertyDateType.DATE: {
|
|
172
|
+
return "^[0-9]{4}-[0-9]{2}-[0-9]{2}$";
|
|
173
|
+
}
|
|
174
|
+
case EApiPropertyDateType.DATE_TIME: {
|
|
175
|
+
return "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z$";
|
|
176
|
+
}
|
|
177
|
+
case EApiPropertyDateType.TIME: {
|
|
178
|
+
return "^[0-9]{2}:[0-9]{2}:[0-9]{2}$";
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function validateOptions(properties) {
|
|
183
|
+
const errors = [];
|
|
184
|
+
if (properties.isArray === true) {
|
|
185
|
+
if (properties.minItems > properties.maxItems) {
|
|
186
|
+
errors.push("'minItems' is greater than 'maxItems'");
|
|
187
|
+
}
|
|
188
|
+
if (properties.minItems < 0) {
|
|
189
|
+
errors.push("'minItems' is less than 0");
|
|
190
|
+
}
|
|
191
|
+
if (properties.maxItems < 0) {
|
|
192
|
+
errors.push("'maxItems' is less than 0");
|
|
193
|
+
}
|
|
194
|
+
if (properties.isUniqueItems && properties.maxItems <= 1) {
|
|
195
|
+
errors.push("'uniqueItems' is true but 'maxItems' is less than or equal to 1");
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (errors.length > 0) {
|
|
199
|
+
throw new Error(`ApiPropertyDate error: ${errors.join("\n")}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export { ApiPropertyDate };
|
|
204
|
+
//# sourceMappingURL=date.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.decorator.js","sources":["../../../../../../../src/decorator/api/property/date.decorator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAWM,SAAU,eAAe,CAAC,UAAsC,EAAA;IACrE,eAAe,CAAC,UAAU,CAAC;AAE3B,IAAA,MAAM,kBAAkB,GAAuB,uBAAuB,CAAC,UAAU,CAAC;IAClF,MAAM,UAAU,GAA6B,eAAe,CAAC,UAAU,EAAE,kBAAkB,CAAC;AAE5F,IAAA,OAAO,eAAe,CAAC,GAAG,UAAU,CAAC;AACtC;AAEA,SAAS,uBAAuB,CAAC,UAAsC,EAAA;IACtE,MAAM,OAAO,GAAW,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC;AAErD,IAAA,MAAM,kBAAkB,GAAuB;AAC9C,QAAA,WAAW,EAAE,CAAG,EAAA,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,CAAE,CAAA;QAEzF,QAAQ,EAAE,UAAU,CAAC,UAAU;QAC/B,IAAI,EAAE,oBAAoB,CAAC,MAAM;KACjC;IAED,kBAAkB,CAAC,QAAQ,GAAG,UAAU,CAAC,UAAU,KAAK,KAAK,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS,GAAG,UAAU,CAAC,UAAU,GAAG,KAAK;AAEpI,IAAA,IAAI,UAAU,CAAC,OAAO,EAAE;AACvB,QA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BAA8B;;AAGtC,QAAA,KAAK,oBAAoB,CAAC,SAAS,EAAE;AACpC,YAAA,OAAO,mEAAmE;;AAG3E,QAAA,KAAK,oBAAoB,CAAC,IAAI,EAAE;AAC/B,YAAA,OAAO,8BAA8B;;;AAGxC;AAEA,SAAS,eAAe,CAAC,UAAsC,EAAA;IAC9D,MAAM,MAAM,GAAkB,EAAE;AAEhC,IAAA,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE;QAChC,IAAI,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE;AAC9C,YAAA,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC;;AAGrD,QAAA,IAAI,UAAU,CAAC,QAAQ,GAAG,CAAC,EAAE;AAC5B,YAAA,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC;;AAGzC,QAAA,IAAI,UAAU,CAAC,QAAQ,GAAG,CAAC,EAAE;AAC5B,YAAA,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC;;QAGzC,IAAI,UAAU,CAAC,aAAa,IAAI,UAAU,CAAC,QAAQ,IAAI,CAAC,EAAE;AACzD,YAAA,MAAM,CAAC,IAAI,CAAC,iEAAiE,CAAC;;;AAIhF,IAAA,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;AACtB,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,uBAAA,EAA0B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE,CAAA,CAAC;;AAEhE;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MetadataStorage } from '../../../class/metadata-storage.class.js';
|
|
2
|
+
import '../../../enum/decorator/api/action.enum.js';
|
|
3
|
+
import '../../../enum/decorator/api/authentication-type.enum.js';
|
|
4
|
+
import '../../../enum/decorator/api/controller/load-relations-strategy.enum.js';
|
|
5
|
+
import '../../../enum/decorator/api/controller/request-transformer-type.enum.js';
|
|
6
|
+
import '../../../enum/decorator/api/dto-type.enum.js';
|
|
7
|
+
import '../../../enum/decorator/api/function/type.enum.js';
|
|
8
|
+
import '../../../enum/decorator/api/property/data-type.enum.js';
|
|
9
|
+
import '../../../enum/decorator/api/property/date/identifier.enum.js';
|
|
10
|
+
import '../../../enum/decorator/api/property/date/type.enum.js';
|
|
11
|
+
import '../../../enum/decorator/api/property/desribe-type.enum.js';
|
|
12
|
+
import '../../../enum/decorator/api/property/number-type.enum.js';
|
|
13
|
+
import '../../../enum/decorator/api/property/string-type.enum.js';
|
|
14
|
+
import '../../../enum/decorator/api/route-type.enum.js';
|
|
15
|
+
import '../../../enum/exception.enum.js';
|
|
16
|
+
import '../../../enum/filter-order-direction.enum.js';
|
|
17
|
+
import '../../../enum/utility/error-string-action.enum.js';
|
|
18
|
+
import '../../../constant/decorator/api/function.constant.js';
|
|
19
|
+
import { PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT } from '../../../constant/decorator/api/property-describe.constant.js';
|
|
20
|
+
|
|
21
|
+
function ApiPropertyDescribe(properties) {
|
|
22
|
+
return (target, propertyKey) => {
|
|
23
|
+
const entityName = target.constructor.name;
|
|
24
|
+
MetadataStorage.getInstance().setMetadata(entityName, propertyKey, PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT.METADATA_PROPERTY_NAME, properties);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { ApiPropertyDescribe };
|
|
29
|
+
//# sourceMappingURL=describe.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.decorator.js","sources":["../../../../../../../src/decorator/api/property/describe.decorator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAKM,SAAU,mBAAmB,CAAC,UAA0C,EAAA;AAC7E,IAAA,OAAO,CAAC,MAAwB,EAAE,WAAmB,KAAU;AAC9D,QAAA,MAAM,UAAU,GAAW,MAAM,CAAC,WAAW,CAAC,IAAI;AAClD,QAAA,eAAe,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,wCAAwC,CAAC,sBAAsB,EAAE,UAAU,CAAC;AAChJ,KAAC;AACF;;;;"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { applyDecorators } from '@nestjs/common';
|
|
2
|
+
import { ApiProperty, ApiResponseProperty } from '@nestjs/swagger';
|
|
3
|
+
import { Expose, Exclude } from 'class-transformer';
|
|
4
|
+
import { IsOptional, IsArray, ArrayMinSize, ArrayMaxSize, ArrayNotEmpty, IsEnum } from 'class-validator';
|
|
5
|
+
|
|
6
|
+
function ApiPropertyEnum(properties) {
|
|
7
|
+
validateOptions(properties);
|
|
8
|
+
const apiPropertyOptions = buildApiPropertyOptions(properties);
|
|
9
|
+
const decorators = buildDecorators(properties, apiPropertyOptions);
|
|
10
|
+
return applyDecorators(...decorators);
|
|
11
|
+
}
|
|
12
|
+
function buildApiPropertyOptions(properties) {
|
|
13
|
+
const apiPropertyOptions = {
|
|
14
|
+
description: `${String(properties.entity.name)} ${properties.description ?? ""}`,
|
|
15
|
+
nullable: properties.isNullable,
|
|
16
|
+
};
|
|
17
|
+
apiPropertyOptions.required = properties.isResponse === false || properties.isResponse === undefined ? properties.isRequired : false;
|
|
18
|
+
if (properties.isArray === true) {
|
|
19
|
+
apiPropertyOptions.isArray = true;
|
|
20
|
+
apiPropertyOptions.minItems = properties.minItems;
|
|
21
|
+
apiPropertyOptions.maxItems = properties.maxItems;
|
|
22
|
+
apiPropertyOptions.uniqueItems = properties.isUniqueItems;
|
|
23
|
+
if (properties.exampleValue) {
|
|
24
|
+
apiPropertyOptions.example = Array.isArray(properties.exampleValue) ? properties.exampleValue : [properties.exampleValue];
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
apiPropertyOptions.example = [Object.values(properties.enum)[0]];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (properties.exampleValue) {
|
|
31
|
+
apiPropertyOptions.example = properties.exampleValue;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
apiPropertyOptions.example = Object.values(properties.enum)[0];
|
|
35
|
+
}
|
|
36
|
+
apiPropertyOptions.enum = properties.enum;
|
|
37
|
+
return apiPropertyOptions;
|
|
38
|
+
}
|
|
39
|
+
function buildDecorators(properties, apiPropertyOptions) {
|
|
40
|
+
const decorators = [ApiProperty(apiPropertyOptions)];
|
|
41
|
+
decorators.push(...buildResponseDecorators(properties), ...buildRequestDecorators(properties), ...buildFormatDecorators(properties));
|
|
42
|
+
return decorators;
|
|
43
|
+
}
|
|
44
|
+
function buildFormatDecorators(properties) {
|
|
45
|
+
const decorators = [];
|
|
46
|
+
const isArray = properties.isArray ?? false;
|
|
47
|
+
decorators.push(IsEnum(properties.enum, { each: isArray }));
|
|
48
|
+
return decorators;
|
|
49
|
+
}
|
|
50
|
+
function buildRequestDecorators(properties) {
|
|
51
|
+
const decorators = [];
|
|
52
|
+
if (properties.isResponse === false || properties.isResponse === undefined) {
|
|
53
|
+
if (!properties.isRequired) {
|
|
54
|
+
decorators.push(IsOptional());
|
|
55
|
+
}
|
|
56
|
+
if (properties.isArray === true) {
|
|
57
|
+
decorators.push(IsArray(), ArrayMinSize(properties.minItems), ArrayMaxSize(properties.maxItems));
|
|
58
|
+
if (properties.minItems > 0) {
|
|
59
|
+
decorators.push(ArrayNotEmpty());
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return decorators;
|
|
64
|
+
}
|
|
65
|
+
function buildResponseDecorators(properties) {
|
|
66
|
+
const decorators = [];
|
|
67
|
+
if (properties.isResponse) {
|
|
68
|
+
decorators.push(ApiResponseProperty());
|
|
69
|
+
if (properties.isExpose === undefined || properties.isExpose) {
|
|
70
|
+
decorators.push(Expose());
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
decorators.push(Exclude());
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return decorators;
|
|
77
|
+
}
|
|
78
|
+
function validateOptions(properties) {
|
|
79
|
+
const errors = [];
|
|
80
|
+
if (properties.isArray === true) {
|
|
81
|
+
if (properties.minItems > properties.maxItems) {
|
|
82
|
+
errors.push("'minItems' is greater than 'maxItems'");
|
|
83
|
+
}
|
|
84
|
+
if (properties.minItems < 0) {
|
|
85
|
+
errors.push("'minItems' is less than 0");
|
|
86
|
+
}
|
|
87
|
+
if (properties.maxItems < 0) {
|
|
88
|
+
errors.push("'maxItems' is less than 0");
|
|
89
|
+
}
|
|
90
|
+
if (properties.isUniqueItems && properties.maxItems <= 1) {
|
|
91
|
+
errors.push("'uniqueItems' is true but 'maxItems' is less than or equal to 1");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (properties.exampleValue && !Object.values(properties.enum).includes(properties.exampleValue)) {
|
|
95
|
+
errors.push("'exampleValue' is not in 'enum'");
|
|
96
|
+
}
|
|
97
|
+
if (errors.length > 0) {
|
|
98
|
+
throw new Error(`ApiPropertyEnum error: ${errors.join("\n")}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { ApiPropertyEnum };
|
|
103
|
+
//# sourceMappingURL=enum.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum.decorator.js","sources":["../../../../../../../src/decorator/api/property/enum.decorator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AASM,SAAU,eAAe,CAAC,UAAsC,EAAA;IACrE,eAAe,CAAC,UAAU,CAAC;AAE3B,IAAA,MAAM,kBAAkB,GAAuB,uBAAuB,CAAC,UAAU,CAAC;IAClF,MAAM,UAAU,GAA6B,eAAe,CAAC,UAAU,EAAE,kBAAkB,CAAC;AAE5F,IAAA,OAAO,eAAe,CAAC,GAAG,UAAU,CAAC;AACtC;AAEA,SAAS,uBAAuB,CAAC,UAAsC,EAAA;AACtE,IAAA,MAAM,kBAAkB,GAA6C;AACpE,QAAA,WAAW,EAAE,CAAG,EAAA,MAAM,CAAC,UAAU,CAAC,MAAM,CAA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
|
|
1
|
+
import { applyDecorators } from '@nestjs/common';
|
|
2
|
+
import { ApiProperty, ApiResponseProperty } from '@nestjs/swagger';
|
|
3
|
+
import { Expose, Exclude, Type, Transform } from 'class-transformer';
|
|
4
|
+
import { isInt, IsOptional, IsArray, ArrayMinSize, ArrayMaxSize, ArrayNotEmpty, IsInt, IsNumber, IsDivisibleBy, Min, Max } from 'class-validator';
|
|
5
|
+
import random from 'lodash/random';
|
|
6
|
+
import '../../../constant/decorator/api/function.constant.js';
|
|
7
|
+
import { NUMBER_CONSTANT } from '../../../constant/number.constant.js';
|
|
8
|
+
import '../../../enum/decorator/api/action.enum.js';
|
|
9
|
+
import '../../../enum/decorator/api/authentication-type.enum.js';
|
|
10
|
+
import '../../../enum/decorator/api/controller/load-relations-strategy.enum.js';
|
|
11
|
+
import '../../../enum/decorator/api/controller/request-transformer-type.enum.js';
|
|
12
|
+
import '../../../enum/decorator/api/dto-type.enum.js';
|
|
13
|
+
import '../../../enum/decorator/api/function/type.enum.js';
|
|
14
|
+
import { EApiPropertyDataType } from '../../../enum/decorator/api/property/data-type.enum.js';
|
|
15
|
+
import '../../../enum/decorator/api/property/date/identifier.enum.js';
|
|
16
|
+
import '../../../enum/decorator/api/property/date/type.enum.js';
|
|
17
|
+
import '../../../enum/decorator/api/property/desribe-type.enum.js';
|
|
18
|
+
import { EApiPropertyNumberType } from '../../../enum/decorator/api/property/number-type.enum.js';
|
|
19
|
+
import '../../../enum/decorator/api/property/string-type.enum.js';
|
|
20
|
+
import '../../../enum/decorator/api/route-type.enum.js';
|
|
21
|
+
import '../../../enum/exception.enum.js';
|
|
22
|
+
import '../../../enum/filter-order-direction.enum.js';
|
|
23
|
+
import '../../../enum/utility/error-string-action.enum.js';
|
|
24
|
+
|
|
25
|
+
function ApiPropertyNumber(properties) {
|
|
26
|
+
if (properties.exampleValue === undefined) {
|
|
27
|
+
properties.exampleValue = random(properties.minimum, properties.maximum);
|
|
28
|
+
}
|
|
29
|
+
validateOptions(properties);
|
|
30
|
+
const apiPropertyOptions = buildApiPropertyOptions(properties);
|
|
31
|
+
const decorators = buildDecorators(properties, apiPropertyOptions);
|
|
32
|
+
return applyDecorators(...decorators);
|
|
33
|
+
}
|
|
34
|
+
function buildApiPropertyOptions(properties) {
|
|
35
|
+
const apiPropertyOptions = {
|
|
36
|
+
description: `${String(properties.entity.name)} ${properties.description ?? ""}`,
|
|
37
|
+
format: getFormat(properties),
|
|
38
|
+
nullable: properties.isNullable,
|
|
39
|
+
type: getType(properties),
|
|
40
|
+
};
|
|
41
|
+
apiPropertyOptions.required = properties.isResponse === false || properties.isResponse === undefined ? properties.isRequired : false;
|
|
42
|
+
if (properties.isArray) {
|
|
43
|
+
apiPropertyOptions.isArray = true;
|
|
44
|
+
apiPropertyOptions.minItems = properties.minItems;
|
|
45
|
+
apiPropertyOptions.maxItems = properties.maxItems;
|
|
46
|
+
apiPropertyOptions.uniqueItems = properties.isUniqueItems;
|
|
47
|
+
apiPropertyOptions.example = Array.isArray(properties.exampleValue) ? properties.exampleValue : [properties.exampleValue];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
apiPropertyOptions.example = properties.exampleValue;
|
|
51
|
+
}
|
|
52
|
+
apiPropertyOptions.minimum = properties.minimum;
|
|
53
|
+
apiPropertyOptions.maximum = properties.maximum;
|
|
54
|
+
if ((properties.isResponse === false || properties.isResponse === undefined) && properties.multipleOf !== undefined) {
|
|
55
|
+
apiPropertyOptions.multipleOf = properties.multipleOf;
|
|
56
|
+
}
|
|
57
|
+
return apiPropertyOptions;
|
|
58
|
+
}
|
|
59
|
+
function buildDecorators(properties, apiPropertyOptions) {
|
|
60
|
+
const decorators = [ApiProperty(apiPropertyOptions)];
|
|
61
|
+
decorators.push(...buildResponseDecorators(properties), ...buildRequestDecorators(properties), ...buildFormatDecorators(properties), ...buildTransformDecorators(properties), ...buildNumberValidationDecorators(properties));
|
|
62
|
+
return decorators;
|
|
63
|
+
}
|
|
64
|
+
function buildFormatDecorators(properties) {
|
|
65
|
+
const decorators = [];
|
|
66
|
+
const isArray = properties.isArray ?? false;
|
|
67
|
+
if (properties.isResponse === undefined || !properties.isResponse) {
|
|
68
|
+
switch (properties.format) {
|
|
69
|
+
case EApiPropertyNumberType.DOUBLE: {
|
|
70
|
+
decorators.push(IsNumber({}, { each: isArray }));
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case EApiPropertyNumberType.INTEGER: {
|
|
74
|
+
decorators.push(IsInt({ each: isArray }));
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
default: {
|
|
78
|
+
throw new Error(`ApiPropertyNumber error: Format is not valid for number property: ${String(properties.format)}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
decorators.push(Type(() => Number));
|
|
82
|
+
}
|
|
83
|
+
return decorators;
|
|
84
|
+
}
|
|
85
|
+
function buildNumberValidationDecorators(properties) {
|
|
86
|
+
const decorators = [];
|
|
87
|
+
const isArray = properties.isArray ?? false;
|
|
88
|
+
if ((properties.isResponse === false || properties.isResponse === undefined) && properties.multipleOf !== undefined) {
|
|
89
|
+
decorators.push(IsDivisibleBy(properties.multipleOf, { each: isArray }), Min(properties.minimum, { each: isArray }), Max(properties.maximum, { each: isArray }));
|
|
90
|
+
}
|
|
91
|
+
return decorators;
|
|
92
|
+
}
|
|
93
|
+
function buildRequestDecorators(properties) {
|
|
94
|
+
const decorators = [];
|
|
95
|
+
if (properties.isResponse === false || properties.isResponse === undefined) {
|
|
96
|
+
if (!properties.isRequired) {
|
|
97
|
+
decorators.push(IsOptional());
|
|
98
|
+
}
|
|
99
|
+
if (properties.isArray === true) {
|
|
100
|
+
decorators.push(IsArray(), ArrayMinSize(properties.minItems), ArrayMaxSize(properties.maxItems));
|
|
101
|
+
if (properties.minItems > 0) {
|
|
102
|
+
decorators.push(ArrayNotEmpty());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return decorators;
|
|
107
|
+
}
|
|
108
|
+
function buildResponseDecorators(properties) {
|
|
109
|
+
const decorators = [];
|
|
110
|
+
if (properties.isResponse) {
|
|
111
|
+
decorators.push(ApiResponseProperty());
|
|
112
|
+
if (properties.isExpose === undefined || properties.isExpose) {
|
|
113
|
+
decorators.push(Expose());
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
decorators.push(Exclude());
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return decorators;
|
|
120
|
+
}
|
|
121
|
+
function buildTransformDecorators(properties) {
|
|
122
|
+
const decorators = [];
|
|
123
|
+
if (!properties.isResponse) {
|
|
124
|
+
if (properties.isArray) {
|
|
125
|
+
decorators.push(Transform(({ value }) => value.map(Number), { toClassOnly: true }));
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
decorators.push(Transform(({ value }) => Number(value), { toClassOnly: true }));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return decorators;
|
|
132
|
+
}
|
|
133
|
+
function getFormat(properties) {
|
|
134
|
+
switch (properties.format) {
|
|
135
|
+
case EApiPropertyNumberType.DOUBLE: {
|
|
136
|
+
return EApiPropertyNumberType.DOUBLE;
|
|
137
|
+
}
|
|
138
|
+
case EApiPropertyNumberType.INTEGER: {
|
|
139
|
+
return properties.maximum <= NUMBER_CONSTANT.MAX_INTEGER && properties.maximum >= NUMBER_CONSTANT.MIN_INTEGER ? "int32" : "int64";
|
|
140
|
+
}
|
|
141
|
+
default: {
|
|
142
|
+
throw new Error("ApiPropertyNumber error: Format is not defined");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function getType(properties) {
|
|
147
|
+
switch (properties.format) {
|
|
148
|
+
case EApiPropertyNumberType.DOUBLE: {
|
|
149
|
+
return EApiPropertyDataType.NUMBER;
|
|
150
|
+
}
|
|
151
|
+
case EApiPropertyNumberType.INTEGER: {
|
|
152
|
+
return EApiPropertyDataType.INTEGER;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function validateOptions(properties) {
|
|
157
|
+
const errors = [];
|
|
158
|
+
if (properties.minimum > properties.maximum) {
|
|
159
|
+
errors.push("'minimum' is greater than maximum");
|
|
160
|
+
}
|
|
161
|
+
if (properties.multipleOf !== undefined) {
|
|
162
|
+
if (Array.isArray(properties.exampleValue)) {
|
|
163
|
+
for (const example of properties.exampleValue) {
|
|
164
|
+
if (!isInt(example / properties.multipleOf)) {
|
|
165
|
+
errors.push("'exampleValue' is not a multiple of 'multipleOf' value: " + String(example));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else if (properties.exampleValue !== undefined && !isInt(properties.exampleValue / properties.multipleOf)) {
|
|
170
|
+
errors.push("'exampleValue' is not a multiple of 'multipleOf' value: " + String(properties.exampleValue));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (Array.isArray(properties.exampleValue)) {
|
|
174
|
+
for (const example of properties.exampleValue) {
|
|
175
|
+
if (example < properties.minimum) {
|
|
176
|
+
errors.push("'exampleValue' is less than 'minimum': " + String(example));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else if (properties.exampleValue !== undefined && properties.exampleValue < properties.minimum) {
|
|
181
|
+
errors.push("'exampleValue' is less than 'minimum': " + String(properties.exampleValue));
|
|
182
|
+
}
|
|
183
|
+
if (Array.isArray(properties.exampleValue)) {
|
|
184
|
+
for (const example of properties.exampleValue) {
|
|
185
|
+
if (example > properties.maximum) {
|
|
186
|
+
errors.push("'exampleValue' is greater than 'maximum': " + String(example));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else if (properties.exampleValue !== undefined && properties.exampleValue > properties.maximum) {
|
|
191
|
+
errors.push("'exampleValue' is greater than 'maximum': " + String(properties.exampleValue));
|
|
192
|
+
}
|
|
193
|
+
if (properties.isArray === true) {
|
|
194
|
+
if (properties.minItems > properties.maxItems) {
|
|
195
|
+
errors.push("'minItems' is greater than 'maxItems'");
|
|
196
|
+
}
|
|
197
|
+
if (properties.minItems < 0) {
|
|
198
|
+
errors.push("'minItems' is less than 0");
|
|
199
|
+
}
|
|
200
|
+
if (properties.maxItems < 0) {
|
|
201
|
+
errors.push("'maxItems' is less than 0");
|
|
202
|
+
}
|
|
203
|
+
if (properties.isUniqueItems && properties.maxItems <= 1) {
|
|
204
|
+
errors.push("'uniqueItems' is true but 'maxItems' is less than or equal to 1");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (errors.length > 0) {
|
|
208
|
+
throw new Error(`ApiPropertyNumber error: ${errors.join("\n")}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export { ApiPropertyNumber };
|
|
213
|
+
//# sourceMappingURL=number.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.decorator.js","sources":["../../../../../../../src/decorator/api/property/number.decorator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAaM,SAAU,iBAAiB,CAAC,UAAwC,EAAA;AACzE,IAAA,IAAI,UAAU,CAAC,YAAY,KAAK,SAAS,EAAE;AAC1C,QAAA,UAAU,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;;IAGzE,eAAe,CAAC,UAAU,CAAC;AAE3B,IAAA,MAAM,kBAAkB,GAAuB,uBAAuB,CAAC,UAAU,CAAC;IAClF,MAAM,UAAU,GAA6B,eAAe,CAAC,UAAU,EAAE,kBAAkB,CAAC;AAE5F,IAAA,OAAO,eAAe,CAAC,GAAG,UAAU,CAAC;AACtC;AAEA,SAAS,uBAAuB,CAAC,UAAwC,EAAA;AACxE,IAAA,MAAM,kBAAkB,GAAuB;AAC9C,QAAA,WAAW,EAAE,CAAG,EAAA,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,WAAW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