@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,102 @@
|
|
|
1
|
+
import { applyDecorators } from '@nestjs/common';
|
|
2
|
+
import { ApiProperty, ApiResponseProperty } from '@nestjs/swagger';
|
|
3
|
+
import { Expose, Exclude, Type } from 'class-transformer';
|
|
4
|
+
import { IsOptional, IsArray, ArrayMinSize, ArrayMaxSize, ArrayNotEmpty, ValidateNested } from 'class-validator';
|
|
5
|
+
|
|
6
|
+
function ApiPropertyObject(options) {
|
|
7
|
+
validateOptions(options);
|
|
8
|
+
const apiPropertyOptions = buildApiPropertyOptions(options);
|
|
9
|
+
const decorators = buildDecorators(options, 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
|
+
type: properties.type,
|
|
17
|
+
};
|
|
18
|
+
apiPropertyOptions.required = properties.isResponse === false || properties.isResponse === undefined ? properties.isRequired : false;
|
|
19
|
+
if (properties.additionalProperties) {
|
|
20
|
+
apiPropertyOptions.additionalProperties = properties.additionalProperties;
|
|
21
|
+
}
|
|
22
|
+
if (properties.isArray) {
|
|
23
|
+
apiPropertyOptions.isArray = true;
|
|
24
|
+
apiPropertyOptions.minItems = properties.minItems;
|
|
25
|
+
apiPropertyOptions.maxItems = properties.maxItems;
|
|
26
|
+
apiPropertyOptions.uniqueItems = properties.isUniqueItems;
|
|
27
|
+
apiPropertyOptions.description = `Array of ${String(properties.entity.name)} ${properties.description ?? ""}`;
|
|
28
|
+
}
|
|
29
|
+
return apiPropertyOptions;
|
|
30
|
+
}
|
|
31
|
+
function buildDecorators(properties, apiPropertyOptions) {
|
|
32
|
+
const decorators = [ApiProperty(apiPropertyOptions)];
|
|
33
|
+
decorators.push(...buildResponseDecorators(properties), ...buildRequestDecorators(properties), ...buildTransformDecorators(properties), ...buildObjectValidationDecorators(properties));
|
|
34
|
+
return decorators;
|
|
35
|
+
}
|
|
36
|
+
function buildObjectValidationDecorators(properties) {
|
|
37
|
+
const decorators = [];
|
|
38
|
+
const isArray = properties.isArray ?? false;
|
|
39
|
+
if (!properties.isResponse && properties.shouldValidateNested) {
|
|
40
|
+
decorators.push(ValidateNested({ each: isArray }));
|
|
41
|
+
}
|
|
42
|
+
return decorators;
|
|
43
|
+
}
|
|
44
|
+
function buildRequestDecorators(properties) {
|
|
45
|
+
const decorators = [];
|
|
46
|
+
if (properties.isResponse === false || properties.isResponse === undefined) {
|
|
47
|
+
if (!properties.isRequired) {
|
|
48
|
+
decorators.push(IsOptional());
|
|
49
|
+
}
|
|
50
|
+
if (properties.isArray === true) {
|
|
51
|
+
decorators.push(IsArray(), ArrayMinSize(properties.minItems), ArrayMaxSize(properties.maxItems));
|
|
52
|
+
if (properties.minItems > 0) {
|
|
53
|
+
decorators.push(ArrayNotEmpty());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return decorators;
|
|
58
|
+
}
|
|
59
|
+
function buildResponseDecorators(properties) {
|
|
60
|
+
const decorators = [];
|
|
61
|
+
if (properties.isResponse) {
|
|
62
|
+
decorators.push(ApiResponseProperty());
|
|
63
|
+
if (properties.isExpose === undefined || properties.isExpose) {
|
|
64
|
+
decorators.push(Expose());
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
decorators.push(Exclude());
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return decorators;
|
|
71
|
+
}
|
|
72
|
+
function buildTransformDecorators(properties) {
|
|
73
|
+
const decorators = [];
|
|
74
|
+
decorators.push(Type(() => properties.type));
|
|
75
|
+
return decorators;
|
|
76
|
+
}
|
|
77
|
+
function validateOptions(properties) {
|
|
78
|
+
const errors = [];
|
|
79
|
+
if (properties.isArray && !properties.shouldValidateNested && !properties.isResponse) {
|
|
80
|
+
errors.push("Array property must be 'shouldValidateNested'");
|
|
81
|
+
}
|
|
82
|
+
if (properties.isArray === true) {
|
|
83
|
+
if (properties.minItems > properties.maxItems) {
|
|
84
|
+
errors.push("'minItems' is greater than 'maxItems'");
|
|
85
|
+
}
|
|
86
|
+
if (properties.minItems < 0) {
|
|
87
|
+
errors.push("'minItems' is less than 0");
|
|
88
|
+
}
|
|
89
|
+
if (properties.maxItems < 0) {
|
|
90
|
+
errors.push("'maxItems' is less than 0");
|
|
91
|
+
}
|
|
92
|
+
if (properties.isUniqueItems && properties.maxItems <= 1) {
|
|
93
|
+
errors.push("'uniqueItems' is true but 'maxItems' is less than or equal to 1");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (errors.length > 0) {
|
|
97
|
+
throw new Error(`ApiPropertyString error: ${errors.join("\n")}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { ApiPropertyObject };
|
|
102
|
+
//# sourceMappingURL=object.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.decorator.js","sources":["../../../../../../../src/decorator/api/property/object.decorator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AASM,SAAU,iBAAiB,CAAC,OAAqC,EAAA;IACtE,eAAe,CAAC,OAAO,CAAC;AAExB,IAAA,MAAM,kBAAkB,GAAuB,uBAAuB,CAAC,OAAO,CAAC;IAC/E,MAAM,UAAU,GAA6B,eAAe,CAAC,OAAO,EAAE,kBAAkB,CAAC;AAEzF,IAAA,OAAO,eAAe,CAAC,GAAG,UAAU,CAAC;AACtC;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AAI,CAAC,CAAE,CAAA,CAAC;;AAElE;;;;"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { applyDecorators } from '@nestjs/common';
|
|
2
|
+
import { ApiProperty, ApiResponseProperty } from '@nestjs/swagger';
|
|
3
|
+
import { Expose, Exclude, Type } from 'class-transformer';
|
|
4
|
+
import { IsOptional, IsArray, ArrayMinSize, ArrayMaxSize, ArrayNotEmpty, IsUUID, IsUrl, IsString, IsUppercase, Validate, Matches, IsLowercase, IsIP, IsEmail, IsDate, Length } from 'class-validator';
|
|
5
|
+
import '../../../constant/decorator/api/function.constant.js';
|
|
6
|
+
import { STRING_PROPERTY_API_INTERFACE_CONSTANT } from '../../../constant/interface/api/property/string.constant.js';
|
|
7
|
+
import '../../../enum/decorator/api/action.enum.js';
|
|
8
|
+
import '../../../enum/decorator/api/authentication-type.enum.js';
|
|
9
|
+
import '../../../enum/decorator/api/controller/load-relations-strategy.enum.js';
|
|
10
|
+
import '../../../enum/decorator/api/controller/request-transformer-type.enum.js';
|
|
11
|
+
import '../../../enum/decorator/api/dto-type.enum.js';
|
|
12
|
+
import '../../../enum/decorator/api/function/type.enum.js';
|
|
13
|
+
import { EApiPropertyDataType } from '../../../enum/decorator/api/property/data-type.enum.js';
|
|
14
|
+
import '../../../enum/decorator/api/property/date/identifier.enum.js';
|
|
15
|
+
import '../../../enum/decorator/api/property/date/type.enum.js';
|
|
16
|
+
import '../../../enum/decorator/api/property/desribe-type.enum.js';
|
|
17
|
+
import '../../../enum/decorator/api/property/number-type.enum.js';
|
|
18
|
+
import { EApiPropertyStringType } from '../../../enum/decorator/api/property/string-type.enum.js';
|
|
19
|
+
import '../../../enum/decorator/api/route-type.enum.js';
|
|
20
|
+
import '../../../enum/exception.enum.js';
|
|
21
|
+
import '../../../enum/filter-order-direction.enum.js';
|
|
22
|
+
import '../../../enum/utility/error-string-action.enum.js';
|
|
23
|
+
import '../../../validator/all-or-none-of-listed-properties.validator.js';
|
|
24
|
+
import '../../../validator/has-at-least-one-and-only-one-of-listed-properties.validator.js';
|
|
25
|
+
import '../../../validator/has-at-least-one-of-listed-properties.validator.js';
|
|
26
|
+
import '../../../validator/has-at-least-one-property.validator.js';
|
|
27
|
+
import { IsRegularExpression } from '../../../validator/is-regular-expression.validator.js';
|
|
28
|
+
import '../../../validator/only-one-of-listed-properties.validator.js';
|
|
29
|
+
|
|
30
|
+
function ApiPropertyString(properties) {
|
|
31
|
+
validateOptions(properties);
|
|
32
|
+
const apiPropertyOptions = buildApiPropertyOptions(properties);
|
|
33
|
+
const decorators = buildDecorators(properties, apiPropertyOptions);
|
|
34
|
+
return applyDecorators(...decorators);
|
|
35
|
+
}
|
|
36
|
+
function buildApiPropertyOptions(properties) {
|
|
37
|
+
const apiPropertyOptions = {
|
|
38
|
+
description: `${String(properties.entity.name)} ${properties.description ?? ""}`,
|
|
39
|
+
nullable: properties.isNullable,
|
|
40
|
+
type: EApiPropertyDataType.STRING,
|
|
41
|
+
};
|
|
42
|
+
apiPropertyOptions.required = properties.isResponse === false || properties.isResponse === undefined ? properties.isRequired : false;
|
|
43
|
+
if (properties.isArray === true) {
|
|
44
|
+
apiPropertyOptions.isArray = true;
|
|
45
|
+
apiPropertyOptions.minItems = properties.minItems;
|
|
46
|
+
apiPropertyOptions.maxItems = properties.maxItems;
|
|
47
|
+
apiPropertyOptions.uniqueItems = properties.isUniqueItems;
|
|
48
|
+
apiPropertyOptions.items = {
|
|
49
|
+
maxLength: properties.maxLength,
|
|
50
|
+
minLength: properties.minLength,
|
|
51
|
+
};
|
|
52
|
+
apiPropertyOptions.example = Array.isArray(properties.exampleValue) ? properties.exampleValue : [properties.exampleValue];
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
apiPropertyOptions.maxLength = properties.maxLength;
|
|
56
|
+
apiPropertyOptions.minLength = properties.minLength;
|
|
57
|
+
apiPropertyOptions.example = properties.exampleValue;
|
|
58
|
+
}
|
|
59
|
+
apiPropertyOptions.format = properties.format;
|
|
60
|
+
apiPropertyOptions.pattern = properties.pattern.slice(1, -1);
|
|
61
|
+
return apiPropertyOptions;
|
|
62
|
+
}
|
|
63
|
+
function buildDecorators(properties, apiPropertyOptions) {
|
|
64
|
+
const decorators = [ApiProperty(apiPropertyOptions)];
|
|
65
|
+
decorators.push(...buildResponseDecorators(properties), ...buildRequestDecorators(properties), ...buildFormatDecorators(properties), ...buildStringValidationDecorators(properties));
|
|
66
|
+
return decorators;
|
|
67
|
+
}
|
|
68
|
+
function buildFormatDecorators(properties) {
|
|
69
|
+
const decorators = [];
|
|
70
|
+
const isArray = properties.isArray ?? false;
|
|
71
|
+
if (properties.isResponse === undefined || !properties.isResponse) {
|
|
72
|
+
switch (properties.format) {
|
|
73
|
+
case EApiPropertyStringType.DATE: {
|
|
74
|
+
decorators.push(IsDate({ each: isArray }), Type(() => Date));
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case EApiPropertyStringType.EMAIL: {
|
|
78
|
+
decorators.push(IsEmail({}, { each: isArray }));
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case EApiPropertyStringType.IP: {
|
|
82
|
+
decorators.push(IsIP(STRING_PROPERTY_API_INTERFACE_CONSTANT.IP_VERSION, { each: isArray }));
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case EApiPropertyStringType.LOWERCASE_STRING: {
|
|
86
|
+
decorators.push(IsString({ each: isArray }), IsLowercase({ each: isArray }));
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case EApiPropertyStringType.REGEXP: {
|
|
90
|
+
decorators.push(Validate(IsRegularExpression, {
|
|
91
|
+
each: isArray,
|
|
92
|
+
message: `${String(properties.description)} must be valid regular expression string`,
|
|
93
|
+
}), Matches(new RegExp(properties.pattern.slice(1, -1)), { each: isArray }), Type(() => RegExp));
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case EApiPropertyStringType.STRING: {
|
|
97
|
+
decorators.push(IsString({ each: isArray }));
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case EApiPropertyStringType.UPPERCASE_STRING: {
|
|
101
|
+
decorators.push(IsString({ each: isArray }), IsUppercase({ each: isArray }));
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case EApiPropertyStringType.URL: {
|
|
105
|
+
decorators.push(IsUrl({
|
|
106
|
+
protocols: ["https", "http"],
|
|
107
|
+
require_host: true,
|
|
108
|
+
require_protocol: true,
|
|
109
|
+
}, { each: isArray }));
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case EApiPropertyStringType.UUID: {
|
|
113
|
+
decorators.push(IsUUID("all", { each: isArray }));
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
default: {
|
|
117
|
+
throw new Error(`ApiPropertyString error: Format is not valid for string property: ${String(properties.format)}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return decorators;
|
|
122
|
+
}
|
|
123
|
+
function buildRequestDecorators(properties) {
|
|
124
|
+
const decorators = [];
|
|
125
|
+
if (properties.isResponse === false || properties.isResponse === undefined) {
|
|
126
|
+
if (!properties.isRequired) {
|
|
127
|
+
decorators.push(IsOptional());
|
|
128
|
+
}
|
|
129
|
+
if (properties.isArray === true) {
|
|
130
|
+
decorators.push(IsArray(), ArrayMinSize(properties.minItems), ArrayMaxSize(properties.maxItems));
|
|
131
|
+
if (properties.minItems > 0) {
|
|
132
|
+
decorators.push(ArrayNotEmpty());
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return decorators;
|
|
137
|
+
}
|
|
138
|
+
function buildResponseDecorators(properties) {
|
|
139
|
+
const decorators = [];
|
|
140
|
+
if (properties.isResponse) {
|
|
141
|
+
decorators.push(ApiResponseProperty());
|
|
142
|
+
if (properties.isExpose === undefined || properties.isExpose) {
|
|
143
|
+
decorators.push(Expose());
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
decorators.push(Exclude());
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return decorators;
|
|
150
|
+
}
|
|
151
|
+
function buildStringValidationDecorators(properties) {
|
|
152
|
+
const decorators = [];
|
|
153
|
+
const isArray = properties.isArray ?? false;
|
|
154
|
+
if (properties.isResponse === false || properties.isResponse === undefined) {
|
|
155
|
+
Matches(new RegExp(properties.pattern.slice(1, -1)), { each: isArray });
|
|
156
|
+
Length(properties.minLength, properties.maxLength, { each: isArray });
|
|
157
|
+
}
|
|
158
|
+
return decorators;
|
|
159
|
+
}
|
|
160
|
+
function validateOptions(properties) {
|
|
161
|
+
const errors = [];
|
|
162
|
+
if ((!properties.isResponse && (!properties.exampleValue || !properties.pattern)) || (properties.exampleValue && properties.pattern)) {
|
|
163
|
+
const matches = /^\/(.*?)\/([gimuy]*)$/.exec(properties.pattern);
|
|
164
|
+
if (matches) {
|
|
165
|
+
const pattern = matches[STRING_PROPERTY_API_INTERFACE_CONSTANT.REGEX_PATTERN_INDEX] ?? "";
|
|
166
|
+
const flags = matches[STRING_PROPERTY_API_INTERFACE_CONSTANT.REGEX_FLAGS_INDEX] ?? "";
|
|
167
|
+
const regex = new RegExp(pattern, flags);
|
|
168
|
+
if (Array.isArray(properties.exampleValue)) {
|
|
169
|
+
for (const example of properties.exampleValue) {
|
|
170
|
+
if (!regex.test(example)) {
|
|
171
|
+
errors.push("RegExp 'pattern' does not match example string: " + example);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else if (!regex.test(properties.exampleValue)) {
|
|
176
|
+
errors.push("RegExp 'pattern' does not match 'example' string: " + properties.exampleValue);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
errors.push("Invalid RegExp 'pattern' format: " + properties.pattern);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (properties.minLength > properties.maxLength) {
|
|
184
|
+
errors.push("'minLength' is greater than 'maxLength'");
|
|
185
|
+
}
|
|
186
|
+
if (properties.minLength < 0) {
|
|
187
|
+
errors.push("'minLength' is less than 0");
|
|
188
|
+
}
|
|
189
|
+
if (properties.maxLength < 0) {
|
|
190
|
+
errors.push("'maxLength' is less than 0");
|
|
191
|
+
}
|
|
192
|
+
if (Array.isArray(properties.exampleValue)) {
|
|
193
|
+
for (const example of properties.exampleValue) {
|
|
194
|
+
if (example.length < properties.minLength) {
|
|
195
|
+
errors.push("Example length is less than 'minLength': " + example);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else if (properties.exampleValue.length < properties.minLength) {
|
|
200
|
+
errors.push("Example length is less than 'minLength': " + properties.exampleValue);
|
|
201
|
+
}
|
|
202
|
+
if (Array.isArray(properties.exampleValue)) {
|
|
203
|
+
for (const example of properties.exampleValue) {
|
|
204
|
+
if (example.length > properties.maxLength) {
|
|
205
|
+
errors.push("Example length is greater than 'maxLength': " + example);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else if (properties.exampleValue.length > properties.maxLength) {
|
|
210
|
+
errors.push("Example length is greater than 'maxLength': " + properties.exampleValue);
|
|
211
|
+
}
|
|
212
|
+
if (properties.isArray === true) {
|
|
213
|
+
if (properties.minItems > properties.maxItems) {
|
|
214
|
+
errors.push("'minItems' is greater than 'maxItems'");
|
|
215
|
+
}
|
|
216
|
+
if (properties.minItems < 0) {
|
|
217
|
+
errors.push("'minItems' is less than 0");
|
|
218
|
+
}
|
|
219
|
+
if (properties.maxItems < 0) {
|
|
220
|
+
errors.push("'maxItems' is less than 0");
|
|
221
|
+
}
|
|
222
|
+
if (properties.isUniqueItems && properties.maxItems <= 1) {
|
|
223
|
+
errors.push("'uniqueItems' is true but 'maxItems' is less than or equal to 1");
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (errors.length > 0) {
|
|
227
|
+
throw new Error(`ApiPropertyString error: ${errors.join("\n")}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export { ApiPropertyString };
|
|
232
|
+
//# sourceMappingURL=string.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.decorator.js","sources":["../../../../../../../src/decorator/api/property/string.decorator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaM,SAAU,iBAAiB,CAAC,UAAwC,EAAA;IACzE,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,GAA6C;AACpE,QAAA,WAAW,EAAE,CAAG,EAAA,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,WAAW,IAAI,EAAE,CAAE,CAAA;QAEhF,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,KAAK,IAAI,EAAE;AAChC,QAAA,kBAAkB,CAAC,OAAO,GAAG,IAAI;AACjC,QAAA,kBAAkB,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ;AACjD,QAAA,kBAAkB,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ;AACjD,QAAA,kBAAkB,CAAC,WAAW,GAAG,UAAU,CAAC,aAAa;QACzD,kBAAkB,CAAC,KAAK,GAAG;YAC1B,SAAS,EAAE,UAAU,CAAC,SAAS;YAC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AAC,IAAI,CAAC,iEAAiE,CAAC;;;AAIhF,IAAA,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;AACtB,QAAA,MAAM,IAAI,KAAK,CAAC,CAAA,yBAAA,EAA4B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE,CAAA,CAAC;;AAElE;;;;"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { applyDecorators } from '@nestjs/common';
|
|
3
|
+
import { ApiProperty, ApiResponseProperty } from '@nestjs/swagger';
|
|
4
|
+
import { Expose, Exclude } from 'class-transformer';
|
|
5
|
+
import { IsOptional, IsArray, ArrayMinSize, ArrayMaxSize, ArrayNotEmpty, IsUUID } from 'class-validator';
|
|
6
|
+
import '../../../enum/decorator/api/action.enum.js';
|
|
7
|
+
import '../../../enum/decorator/api/authentication-type.enum.js';
|
|
8
|
+
import '../../../enum/decorator/api/controller/load-relations-strategy.enum.js';
|
|
9
|
+
import '../../../enum/decorator/api/controller/request-transformer-type.enum.js';
|
|
10
|
+
import '../../../enum/decorator/api/dto-type.enum.js';
|
|
11
|
+
import '../../../enum/decorator/api/function/type.enum.js';
|
|
12
|
+
import { EApiPropertyDataType } from '../../../enum/decorator/api/property/data-type.enum.js';
|
|
13
|
+
import '../../../enum/decorator/api/property/date/identifier.enum.js';
|
|
14
|
+
import '../../../enum/decorator/api/property/date/type.enum.js';
|
|
15
|
+
import '../../../enum/decorator/api/property/desribe-type.enum.js';
|
|
16
|
+
import '../../../enum/decorator/api/property/number-type.enum.js';
|
|
17
|
+
import { EApiPropertyStringType } from '../../../enum/decorator/api/property/string-type.enum.js';
|
|
18
|
+
import '../../../enum/decorator/api/route-type.enum.js';
|
|
19
|
+
import '../../../enum/exception.enum.js';
|
|
20
|
+
import '../../../enum/filter-order-direction.enum.js';
|
|
21
|
+
import '../../../enum/utility/error-string-action.enum.js';
|
|
22
|
+
|
|
23
|
+
function ApiPropertyUUID(properties) {
|
|
24
|
+
const uuidExample = randomUUID();
|
|
25
|
+
validateOptions(properties);
|
|
26
|
+
const apiPropertyOptions = buildApiPropertyOptions(uuidExample, properties);
|
|
27
|
+
const decorators = buildDecorators(properties, apiPropertyOptions);
|
|
28
|
+
return applyDecorators(...decorators);
|
|
29
|
+
}
|
|
30
|
+
function buildApiPropertyOptions(uuidExample, properties) {
|
|
31
|
+
const apiPropertyOptions = {
|
|
32
|
+
description: `${String(properties.entity.name)} ${properties.description ?? "identifier"}`,
|
|
33
|
+
nullable: properties.isNullable,
|
|
34
|
+
type: EApiPropertyDataType.STRING,
|
|
35
|
+
};
|
|
36
|
+
apiPropertyOptions.required = properties.isResponse === false || properties.isResponse === undefined ? properties.isRequired : false;
|
|
37
|
+
if (properties.isArray) {
|
|
38
|
+
apiPropertyOptions.isArray = true;
|
|
39
|
+
apiPropertyOptions.minItems = properties.minItems;
|
|
40
|
+
apiPropertyOptions.maxItems = properties.maxItems;
|
|
41
|
+
apiPropertyOptions.uniqueItems = properties.isUniqueItems;
|
|
42
|
+
apiPropertyOptions.items = {
|
|
43
|
+
maxLength: uuidExample.length,
|
|
44
|
+
minLength: uuidExample.length,
|
|
45
|
+
};
|
|
46
|
+
apiPropertyOptions.example = [uuidExample];
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
apiPropertyOptions.minLength = uuidExample.length;
|
|
50
|
+
apiPropertyOptions.maxLength = uuidExample.length;
|
|
51
|
+
apiPropertyOptions.example = uuidExample;
|
|
52
|
+
}
|
|
53
|
+
apiPropertyOptions.format = EApiPropertyStringType.UUID;
|
|
54
|
+
apiPropertyOptions.pattern = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$";
|
|
55
|
+
return apiPropertyOptions;
|
|
56
|
+
}
|
|
57
|
+
function buildDecorators(properties, apiPropertyOptions) {
|
|
58
|
+
const decorators = [ApiProperty(apiPropertyOptions)];
|
|
59
|
+
decorators.push(...buildResponseDecorators(properties), ...buildRequestDecorators(properties), ...buildFormatDecorators(properties));
|
|
60
|
+
return decorators;
|
|
61
|
+
}
|
|
62
|
+
function buildFormatDecorators(properties) {
|
|
63
|
+
const decorators = [];
|
|
64
|
+
const isArray = properties.isArray ?? false;
|
|
65
|
+
decorators.push(IsUUID(undefined, { each: isArray }));
|
|
66
|
+
return decorators;
|
|
67
|
+
}
|
|
68
|
+
function buildRequestDecorators(properties) {
|
|
69
|
+
const decorators = [];
|
|
70
|
+
if (properties.isResponse === false || properties.isResponse === undefined) {
|
|
71
|
+
if (!properties.isRequired) {
|
|
72
|
+
decorators.push(IsOptional());
|
|
73
|
+
}
|
|
74
|
+
if (properties.isArray === true) {
|
|
75
|
+
decorators.push(IsArray(), ArrayMinSize(properties.minItems), ArrayMaxSize(properties.maxItems));
|
|
76
|
+
if (properties.minItems > 0) {
|
|
77
|
+
decorators.push(ArrayNotEmpty());
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return decorators;
|
|
82
|
+
}
|
|
83
|
+
function buildResponseDecorators(properties) {
|
|
84
|
+
const decorators = [];
|
|
85
|
+
if (properties.isResponse) {
|
|
86
|
+
decorators.push(ApiResponseProperty());
|
|
87
|
+
if (properties.isExpose === undefined || properties.isExpose) {
|
|
88
|
+
decorators.push(Expose());
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
decorators.push(Exclude());
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return decorators;
|
|
95
|
+
}
|
|
96
|
+
function validateOptions(properties) {
|
|
97
|
+
const errors = [];
|
|
98
|
+
if (properties.isArray === true) {
|
|
99
|
+
if (properties.minItems > properties.maxItems) {
|
|
100
|
+
errors.push("'minItems' is greater than 'maxItems'");
|
|
101
|
+
}
|
|
102
|
+
if (properties.minItems < 0) {
|
|
103
|
+
errors.push("'minItems' is less than 0");
|
|
104
|
+
}
|
|
105
|
+
if (properties.maxItems < 0) {
|
|
106
|
+
errors.push("'maxItems' is less than 0");
|
|
107
|
+
}
|
|
108
|
+
if (properties.isUniqueItems && properties.maxItems <= 1) {
|
|
109
|
+
errors.push("'uniqueItems' is true but 'maxItems' is less than or equal to 1");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (errors.length > 0) {
|
|
113
|
+
throw new Error(`ApiPropertyUUID error: ${errors.join("\n")}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { ApiPropertyUUID };
|
|
118
|
+
//# sourceMappingURL=uuid.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.decorator.js","sources":["../../../../../../../src/decorator/api/property/uuid.decorator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAaM,SAAU,eAAe,CAAC,UAAsC,EAAA;AACrE,IAAA,MAAM,WAAW,GAAW,UAAU,EAAE;IAExC,eAAe,CAAC,UAAU,CAAC;IAE3B,MAAM,kBAAkB,GAAuB,uBAAuB,CAAC,WAAW,EAAE,UAAU,CAAC;IAC/F,MAAM,UAAU,GAA6B,eAAe,CAAC,UAAU,EAAE,kBAAkB,CAAC;AAE5F,IAAA,OAAO,eAAe,CAAC,GAAG,UAAU,CAAC;AACtC;AAEA,SAAS,uBAAuB,CAAC,WAAmB,EAAE,UAAsC,EAAA;AAC3F,IAAA,MAAM,kBAAkB,GAAuB;AAC9C,QAAA,WAAW,EAAE,CAAG,EAAA,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,WAAW,IAAI,YAAY,CAAE,CAAA;QAE1F,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,G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AChC,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,161 @@
|
|
|
1
|
+
import '../../enum/decorator/api/action.enum.js';
|
|
2
|
+
import '../../enum/decorator/api/authentication-type.enum.js';
|
|
3
|
+
import '../../enum/decorator/api/controller/load-relations-strategy.enum.js';
|
|
4
|
+
import '../../enum/decorator/api/controller/request-transformer-type.enum.js';
|
|
5
|
+
import '../../enum/decorator/api/dto-type.enum.js';
|
|
6
|
+
import { EApiFunctionType } from '../../enum/decorator/api/function/type.enum.js';
|
|
7
|
+
import '../../enum/decorator/api/property/data-type.enum.js';
|
|
8
|
+
import '../../enum/decorator/api/property/date/identifier.enum.js';
|
|
9
|
+
import '../../enum/decorator/api/property/date/type.enum.js';
|
|
10
|
+
import '../../enum/decorator/api/property/desribe-type.enum.js';
|
|
11
|
+
import '../../enum/decorator/api/property/number-type.enum.js';
|
|
12
|
+
import '../../enum/decorator/api/property/string-type.enum.js';
|
|
13
|
+
import '../../enum/decorator/api/route-type.enum.js';
|
|
14
|
+
import '../../enum/exception.enum.js';
|
|
15
|
+
import '../../enum/filter-order-direction.enum.js';
|
|
16
|
+
import '../../enum/utility/error-string-action.enum.js';
|
|
17
|
+
import '@nestjs/common';
|
|
18
|
+
import { ApiFunction } from './function/decorator.js';
|
|
19
|
+
|
|
20
|
+
function ApiService(properties) {
|
|
21
|
+
const { entity } = properties;
|
|
22
|
+
return function (target) {
|
|
23
|
+
const originalConstructor = target;
|
|
24
|
+
const ExtendedClass = class extends originalConstructor {
|
|
25
|
+
constructor(..._arguments) {
|
|
26
|
+
super(..._arguments);
|
|
27
|
+
if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.GET_LIST)) {
|
|
28
|
+
Object.defineProperty(this, EApiFunctionType.GET_LIST, {
|
|
29
|
+
configurable: true,
|
|
30
|
+
enumerable: true,
|
|
31
|
+
value: async function (properties, relations) {
|
|
32
|
+
const apiFunctionDecorator = ApiFunction({
|
|
33
|
+
entity,
|
|
34
|
+
type: EApiFunctionType.GET_LIST,
|
|
35
|
+
});
|
|
36
|
+
const descriptor = {
|
|
37
|
+
configurable: true,
|
|
38
|
+
enumerable: true,
|
|
39
|
+
value: () => void 0,
|
|
40
|
+
writable: true,
|
|
41
|
+
};
|
|
42
|
+
const decoratedDescriptor = apiFunctionDecorator(this, EApiFunctionType.GET_LIST, descriptor);
|
|
43
|
+
return decoratedDescriptor.value.call(this, properties);
|
|
44
|
+
},
|
|
45
|
+
writable: true,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.GET)) {
|
|
49
|
+
Object.defineProperty(this, EApiFunctionType.GET, {
|
|
50
|
+
configurable: true,
|
|
51
|
+
enumerable: true,
|
|
52
|
+
value: async function (properties) {
|
|
53
|
+
const apiFunctionDecorator = ApiFunction({
|
|
54
|
+
entity,
|
|
55
|
+
type: EApiFunctionType.GET,
|
|
56
|
+
});
|
|
57
|
+
const descriptor = {
|
|
58
|
+
configurable: true,
|
|
59
|
+
enumerable: true,
|
|
60
|
+
value: () => void 0,
|
|
61
|
+
writable: true,
|
|
62
|
+
};
|
|
63
|
+
const decoratedDescriptor = apiFunctionDecorator(this, EApiFunctionType.GET, descriptor);
|
|
64
|
+
return decoratedDescriptor.value.call(this, properties);
|
|
65
|
+
},
|
|
66
|
+
writable: true,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.GET_MANY)) {
|
|
70
|
+
Object.defineProperty(this, EApiFunctionType.GET_MANY, {
|
|
71
|
+
configurable: true,
|
|
72
|
+
enumerable: true,
|
|
73
|
+
value: async function (properties) {
|
|
74
|
+
const apiFunctionDecorator = ApiFunction({
|
|
75
|
+
entity,
|
|
76
|
+
type: EApiFunctionType.GET_MANY,
|
|
77
|
+
});
|
|
78
|
+
const descriptor = {
|
|
79
|
+
configurable: true,
|
|
80
|
+
enumerable: true,
|
|
81
|
+
value: () => void 0,
|
|
82
|
+
writable: true,
|
|
83
|
+
};
|
|
84
|
+
const decoratedDescriptor = apiFunctionDecorator(this, EApiFunctionType.GET_MANY, descriptor);
|
|
85
|
+
return decoratedDescriptor.value.call(this, properties);
|
|
86
|
+
},
|
|
87
|
+
writable: true,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.CREATE)) {
|
|
91
|
+
Object.defineProperty(this, EApiFunctionType.CREATE, {
|
|
92
|
+
configurable: true,
|
|
93
|
+
enumerable: true,
|
|
94
|
+
value: async function (properties) {
|
|
95
|
+
const apiFunctionDecorator = ApiFunction({
|
|
96
|
+
entity,
|
|
97
|
+
type: EApiFunctionType.CREATE,
|
|
98
|
+
});
|
|
99
|
+
const descriptor = {
|
|
100
|
+
configurable: true,
|
|
101
|
+
enumerable: true,
|
|
102
|
+
value: () => void 0,
|
|
103
|
+
writable: true,
|
|
104
|
+
};
|
|
105
|
+
const decoratedDescriptor = apiFunctionDecorator(this, EApiFunctionType.CREATE, descriptor);
|
|
106
|
+
return decoratedDescriptor.value.call(this, properties);
|
|
107
|
+
},
|
|
108
|
+
writable: true,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.UPDATE)) {
|
|
112
|
+
Object.defineProperty(this, EApiFunctionType.UPDATE, {
|
|
113
|
+
configurable: true,
|
|
114
|
+
enumerable: true,
|
|
115
|
+
value: async function (criteria, properties) {
|
|
116
|
+
const apiFunctionDecorator = ApiFunction({
|
|
117
|
+
entity,
|
|
118
|
+
type: EApiFunctionType.UPDATE,
|
|
119
|
+
});
|
|
120
|
+
const descriptor = {
|
|
121
|
+
configurable: true,
|
|
122
|
+
enumerable: true,
|
|
123
|
+
value: () => void 0,
|
|
124
|
+
writable: true,
|
|
125
|
+
};
|
|
126
|
+
const decoratedDescriptor = apiFunctionDecorator(this, EApiFunctionType.UPDATE, descriptor);
|
|
127
|
+
return decoratedDescriptor.value.call(this, criteria, properties);
|
|
128
|
+
},
|
|
129
|
+
writable: true,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.DELETE)) {
|
|
133
|
+
Object.defineProperty(this, EApiFunctionType.DELETE, {
|
|
134
|
+
configurable: true,
|
|
135
|
+
enumerable: true,
|
|
136
|
+
value: async function (criteria) {
|
|
137
|
+
const apiFunctionDecorator = ApiFunction({
|
|
138
|
+
entity,
|
|
139
|
+
type: EApiFunctionType.DELETE,
|
|
140
|
+
});
|
|
141
|
+
const descriptor = {
|
|
142
|
+
configurable: true,
|
|
143
|
+
enumerable: true,
|
|
144
|
+
value: () => void 0,
|
|
145
|
+
writable: true,
|
|
146
|
+
};
|
|
147
|
+
const decoratedDescriptor = apiFunctionDecorator(this, EApiFunctionType.DELETE, descriptor);
|
|
148
|
+
return decoratedDescriptor.value.call(this, criteria);
|
|
149
|
+
},
|
|
150
|
+
writable: true,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
Object.setPrototypeOf(ExtendedClass, originalConstructor);
|
|
156
|
+
return ExtendedClass;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export { ApiService };
|
|
161
|
+
//# sourceMappingURL=service.decorator.js.map
|