@elsikora/nestjs-crud-automator 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/class/api/base-service.class.d.ts +5 -5
- package/dist/class/api/base-service.class.js +19 -10
- package/dist/class/api/base-service.class.js.map +1 -1
- package/dist/class/api/index.d.ts +0 -1
- package/dist/class/api/index.js +0 -1
- package/dist/class/api/index.js.map +1 -1
- package/dist/class/index.d.ts +1 -0
- package/dist/class/index.js +1 -0
- package/dist/class/index.js.map +1 -1
- package/dist/class/utility/dto/index.d.ts +2 -0
- package/dist/{decorator/api/route → class/utility/dto}/index.js +2 -2
- package/dist/class/utility/dto/index.js.map +1 -0
- package/dist/class/utility/dto/property/factory/boolean.class.d.ts +5 -0
- package/dist/class/utility/dto/property/factory/boolean.class.js +15 -0
- package/dist/class/utility/dto/property/factory/boolean.class.js.map +1 -0
- package/dist/class/utility/dto/property/factory/date.class.d.ts +5 -0
- package/dist/class/utility/dto/property/factory/date.class.js +15 -0
- package/dist/class/utility/dto/property/factory/date.class.js.map +1 -0
- package/dist/class/utility/dto/property/factory/index.d.ts +6 -0
- package/dist/{dto/exception → class/utility/dto/property/factory}/index.js +6 -7
- package/dist/class/utility/dto/property/factory/index.js.map +1 -0
- package/dist/class/utility/dto/property/factory/number.class.d.ts +5 -0
- package/dist/class/utility/dto/property/factory/number.class.js +19 -0
- package/dist/class/utility/dto/property/factory/number.class.js.map +1 -0
- package/dist/class/utility/dto/property/factory/object.class.d.ts +5 -0
- package/dist/class/utility/dto/property/factory/object.class.js +17 -0
- package/dist/class/utility/dto/property/factory/object.class.js.map +1 -0
- package/dist/class/utility/dto/property/factory/relation.class.d.ts +5 -0
- package/dist/class/utility/dto/property/factory/relation.class.js +11 -0
- package/dist/class/utility/dto/property/factory/relation.class.js.map +1 -0
- package/dist/class/utility/dto/property/factory/string.class.d.ts +5 -0
- package/dist/class/utility/dto/property/factory/string.class.js +15 -0
- package/dist/class/utility/dto/property/factory/string.class.js.map +1 -0
- package/dist/class/utility/dto/property/factory/uuid.class.d.ts +5 -0
- package/dist/class/utility/dto/property/factory/uuid.class.js +11 -0
- package/dist/class/utility/dto/property/factory/uuid.class.js.map +1 -0
- package/dist/class/utility/dto/property/index.d.ts +1 -0
- package/dist/{dto → class/utility/dto/property}/index.js +1 -1
- package/dist/class/utility/dto/property/index.js.map +1 -0
- package/dist/class/utility/dto/strategy/body.class.d.ts +6 -0
- package/dist/class/utility/dto/strategy/body.class.js +21 -0
- package/dist/class/utility/dto/strategy/body.class.js.map +1 -0
- package/dist/class/utility/dto/strategy/index.d.ts +4 -0
- package/dist/class/utility/dto/strategy/index.js +21 -0
- package/dist/class/utility/dto/strategy/index.js.map +1 -0
- package/dist/class/utility/dto/strategy/query.class.d.ts +6 -0
- package/dist/class/utility/dto/strategy/query.class.js +18 -0
- package/dist/class/utility/dto/strategy/query.class.js.map +1 -0
- package/dist/class/utility/dto/strategy/request.class.d.ts +6 -0
- package/dist/class/utility/dto/strategy/request.class.js +26 -0
- package/dist/class/utility/dto/strategy/request.class.js.map +1 -0
- package/dist/class/utility/dto/strategy/response.class.d.ts +6 -0
- package/dist/class/utility/dto/strategy/response.class.js +18 -0
- package/dist/class/utility/dto/strategy/response.class.js.map +1 -0
- package/dist/class/utility/index.d.ts +1 -0
- package/dist/class/utility/index.js +18 -0
- package/dist/class/utility/index.js.map +1 -0
- package/dist/constant/decorator/api/controller.constant.d.ts +1 -1
- package/dist/constant/decorator/api/controller.constant.js +2 -2
- package/dist/constant/decorator/api/controller.constant.js.map +1 -1
- package/dist/constant/decorator/api/function.constant.d.ts +1 -1
- package/dist/constant/decorator/api/function.constant.js +2 -2
- package/dist/constant/decorator/api/function.constant.js.map +1 -1
- package/dist/constant/decorator/api/property-describe.constant.d.ts +1 -1
- package/dist/constant/decorator/api/property-describe.constant.js +2 -2
- package/dist/constant/decorator/api/property-describe.constant.js.map +1 -1
- package/dist/constant/factory/dto/get-list-query.constant.d.ts +1 -2
- package/dist/constant/factory/dto/get-list-query.constant.js +2 -2
- package/dist/constant/factory/dto/get-list-query.constant.js.map +1 -1
- package/dist/constant/interface/api/filter.constant.d.ts +1 -1
- package/dist/constant/interface/api/filter.constant.js +2 -2
- package/dist/constant/interface/api/filter.constant.js.map +1 -1
- package/dist/constant/interface/api/index.d.ts +1 -0
- package/dist/constant/interface/api/index.js +1 -0
- package/dist/constant/interface/api/index.js.map +1 -1
- package/dist/constant/interface/api/property/string.constant.d.ts +1 -1
- package/dist/constant/interface/api/property/string.constant.js +2 -2
- package/dist/constant/interface/api/property/string.constant.js.map +1 -1
- package/dist/constant/interface/api/property/wallet.constant.d.ts +1 -1
- package/dist/constant/interface/api/property/wallet.constant.js +2 -2
- package/dist/constant/interface/api/property/wallet.constant.js.map +1 -1
- package/dist/constant/utility/dto/constant.d.ts +6 -0
- package/dist/constant/utility/dto/constant.js +27 -0
- package/dist/constant/utility/dto/constant.js.map +1 -0
- package/dist/decorator/api/controller.decorator.d.ts +3 -7
- package/dist/decorator/api/controller.decorator.js +2 -2
- package/dist/decorator/api/controller.decorator.js.map +1 -1
- package/dist/decorator/api/function/create.decorator.d.ts +2 -4
- package/dist/decorator/api/function/create.decorator.js +25 -17
- package/dist/decorator/api/function/create.decorator.js.map +1 -1
- package/dist/decorator/api/function/decorator.d.ts +3 -7
- package/dist/decorator/api/function/decorator.js +20 -16
- package/dist/decorator/api/function/decorator.js.map +1 -1
- package/dist/decorator/api/function/delete.decorator.d.ts +3 -3
- package/dist/decorator/api/function/delete.decorator.js +6 -6
- package/dist/decorator/api/function/delete.decorator.js.map +1 -1
- package/dist/decorator/api/function/get-list.decorator.d.ts +3 -3
- package/dist/decorator/api/function/get-list.decorator.js +9 -8
- package/dist/decorator/api/function/get-list.decorator.js.map +1 -1
- package/dist/decorator/api/function/get.decorator.d.ts +3 -3
- package/dist/decorator/api/function/get.decorator.js +8 -9
- package/dist/decorator/api/function/get.decorator.js.map +1 -1
- package/dist/decorator/api/function/update.decorator.d.ts +3 -3
- package/dist/decorator/api/function/update.decorator.js +10 -14
- package/dist/decorator/api/function/update.decorator.js.map +1 -1
- package/dist/decorator/api/index.d.ts +0 -1
- package/dist/decorator/api/index.js +0 -1
- package/dist/decorator/api/index.js.map +1 -1
- package/dist/decorator/api/method.decorator.js +58 -0
- package/dist/decorator/api/method.decorator.js.map +1 -1
- package/dist/decorator/api/property/date.decorator.js.map +1 -1
- package/dist/decorator/api/property/describe.decorator.js +1 -1
- package/dist/decorator/api/property/describe.decorator.js.map +1 -1
- package/dist/decorator/api/property/string.decorator.js +13 -6
- package/dist/decorator/api/property/string.decorator.js.map +1 -1
- package/dist/decorator/api/property/wallet.decorator.js +3 -3
- package/dist/decorator/api/property/wallet.decorator.js.map +1 -1
- package/dist/decorator/api/service.decorator.d.ts +3 -6
- package/dist/decorator/api/service.decorator.js +23 -49
- package/dist/decorator/api/service.decorator.js.map +1 -1
- package/dist/enum/decorator/api/authentication-type.enum.d.ts +1 -0
- package/dist/enum/decorator/api/authentication-type.enum.js +1 -0
- package/dist/enum/decorator/api/authentication-type.enum.js.map +1 -1
- package/dist/enum/decorator/api/dto-type.enum.d.ts +3 -3
- package/dist/enum/decorator/api/dto-type.enum.js +2 -2
- package/dist/enum/decorator/api/dto-type.enum.js.map +1 -1
- package/dist/enum/decorator/api/property/desribe-type.enum.d.ts +2 -1
- package/dist/enum/decorator/api/property/desribe-type.enum.js +1 -0
- package/dist/enum/decorator/api/property/desribe-type.enum.js.map +1 -1
- package/dist/factory/api/controller.factory.d.ts +8 -8
- package/dist/factory/api/controller.factory.js +89 -55
- package/dist/factory/api/controller.factory.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/interceptor/correlation-id-response-body.interceptor.js +0 -8
- package/dist/interceptor/correlation-id-response-body.interceptor.js.map +1 -1
- package/dist/interface/class/dto/index.d.ts +1 -0
- package/dist/interface/class/dto/index.js +18 -0
- package/dist/interface/class/dto/index.js.map +1 -0
- package/dist/interface/class/dto/strategy.interface.d.ts +5 -0
- package/dist/{type/decorator/api/function/get-properties.type.js → interface/class/dto/strategy.interface.js} +1 -1
- package/dist/interface/class/dto/strategy.interface.js.map +1 -0
- package/dist/interface/class/index.d.ts +1 -0
- package/dist/interface/class/index.js +18 -0
- package/dist/interface/class/index.js.map +1 -0
- package/dist/interface/decorator/api/controller-properties.interface.d.ts +12 -7
- package/dist/interface/decorator/api/controller-properties.interface.js.map +1 -1
- package/dist/interface/decorator/api/function/create-properties.interface.d.ts +4 -0
- package/dist/interface/decorator/api/function/create-properties.interface.js +3 -0
- package/dist/interface/decorator/api/function/create-properties.interface.js.map +1 -0
- package/dist/interface/decorator/api/index.d.ts +1 -0
- package/dist/interface/decorator/api/index.js +1 -0
- package/dist/interface/decorator/api/index.js.map +1 -1
- package/dist/interface/decorator/api/method/properties.interface.d.ts +3 -2
- package/dist/interface/decorator/api/method/properties.interface.js.map +1 -1
- package/dist/interface/decorator/api/property/base-properties.interface.d.ts +1 -1
- package/dist/interface/decorator/api/property/base-properties.interface.js.map +1 -1
- package/dist/interface/dto-generate-factory.interface.d.ts +5 -0
- package/dist/interface/dto-generate-factory.interface.js +3 -0
- package/dist/interface/dto-generate-factory.interface.js.map +1 -0
- package/dist/interface/index.d.ts +2 -0
- package/dist/interface/index.js +2 -0
- package/dist/interface/index.js.map +1 -1
- package/dist/interface/utility/get-entity-columns-properties.interface.d.ts +5 -0
- package/dist/interface/utility/get-entity-columns-properties.interface.js +3 -0
- package/dist/interface/utility/get-entity-columns-properties.interface.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/type/decorator/api/controller/constructor.type.d.ts +4 -0
- package/dist/type/decorator/api/{function/create-properties.type.js → controller/constructor.type.js} +1 -1
- package/dist/type/decorator/api/controller/constructor.type.js.map +1 -0
- package/dist/type/decorator/api/controller/index.d.ts +1 -0
- package/dist/type/decorator/api/controller/index.js +18 -0
- package/dist/type/decorator/api/controller/index.js.map +1 -0
- package/dist/type/decorator/api/function/create/executor-properties.type.d.ts +8 -0
- package/dist/type/decorator/api/function/create/executor-properties.type.js +3 -0
- package/dist/type/decorator/api/function/create/executor-properties.type.js.map +1 -0
- package/dist/type/decorator/api/function/create/index.d.ts +2 -0
- package/dist/type/decorator/api/function/create/index.js +19 -0
- package/dist/type/decorator/api/function/create/index.js.map +1 -0
- package/dist/type/decorator/api/function/{update-properties.type.js → create/properties.type.js} +1 -1
- package/dist/type/decorator/api/function/create/properties.type.js.map +1 -0
- package/dist/type/decorator/api/function/delete/executor-properties.type.d.ts +9 -0
- package/dist/type/decorator/api/function/delete/executor-properties.type.js +3 -0
- package/dist/type/decorator/api/function/delete/executor-properties.type.js.map +1 -0
- package/dist/type/decorator/api/function/delete/index.d.ts +1 -0
- package/dist/type/decorator/api/function/delete/index.js +18 -0
- package/dist/type/decorator/api/function/delete/index.js.map +1 -0
- package/dist/type/decorator/api/function/get/executor-properties.type.d.ts +7 -0
- package/dist/type/decorator/api/function/get/executor-properties.type.js +3 -0
- package/dist/type/decorator/api/function/get/executor-properties.type.js.map +1 -0
- package/dist/type/decorator/api/function/get/index.d.ts +2 -0
- package/dist/type/decorator/api/function/get/index.js +19 -0
- package/dist/type/decorator/api/function/get/index.js.map +1 -0
- package/dist/type/decorator/api/function/get/properties.type.js +3 -0
- package/dist/type/decorator/api/function/get/properties.type.js.map +1 -0
- package/dist/type/decorator/api/function/get-list/base-properties.type.d.ts +16 -0
- package/dist/type/decorator/api/function/get-list/base-properties.type.js +3 -0
- package/dist/type/decorator/api/function/get-list/base-properties.type.js.map +1 -0
- package/dist/type/decorator/api/function/get-list/executor-properties.type.d.ts +9 -0
- package/dist/type/decorator/api/function/get-list/executor-properties.type.js +3 -0
- package/dist/type/decorator/api/function/get-list/executor-properties.type.js.map +1 -0
- package/dist/type/decorator/api/function/get-list/index.d.ts +3 -0
- package/dist/type/decorator/api/function/get-list/index.js +20 -0
- package/dist/type/decorator/api/function/get-list/index.js.map +1 -0
- package/dist/type/decorator/api/function/get-list/properties.type.d.ts +9 -0
- package/dist/type/decorator/api/function/get-list/properties.type.js +3 -0
- package/dist/type/decorator/api/function/get-list/properties.type.js.map +1 -0
- package/dist/type/decorator/api/function/index.d.ts +5 -4
- package/dist/type/decorator/api/function/index.js +5 -4
- package/dist/type/decorator/api/function/index.js.map +1 -1
- package/dist/type/decorator/api/function/properties.type.d.ts +7 -0
- package/dist/type/decorator/api/function/properties.type.js +3 -0
- package/dist/type/decorator/api/function/properties.type.js.map +1 -0
- package/dist/type/decorator/api/function/update/executor-properties.type.d.ts +11 -0
- package/dist/type/decorator/api/function/update/executor-properties.type.js +3 -0
- package/dist/type/decorator/api/function/update/executor-properties.type.js.map +1 -0
- package/dist/type/decorator/api/function/update/index.d.ts +2 -0
- package/dist/type/decorator/api/function/update/index.js +19 -0
- package/dist/type/decorator/api/function/update/index.js.map +1 -0
- package/dist/type/decorator/api/function/update/properties.type.js +3 -0
- package/dist/type/decorator/api/function/update/properties.type.js.map +1 -0
- package/dist/type/decorator/api/index.d.ts +1 -0
- package/dist/type/decorator/api/index.js +1 -0
- package/dist/type/decorator/api/index.js.map +1 -1
- package/dist/type/decorator/api/property/describe/array/index.d.ts +2 -0
- package/dist/type/decorator/api/property/describe/array/index.js +19 -0
- package/dist/type/decorator/api/property/describe/array/index.js.map +1 -0
- package/dist/type/decorator/api/property/describe/array/optional-properties.type.d.ts +3 -0
- package/dist/type/decorator/api/property/describe/array/optional-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/array/optional-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/array/required-properties.type.d.ts +6 -0
- package/dist/type/decorator/api/property/describe/array/required-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/array/required-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/base-properties.type.d.ts +7 -0
- package/dist/type/decorator/api/property/describe/base-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/base-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/boolean-properties.type.d.ts +7 -0
- package/dist/type/decorator/api/property/describe/boolean-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/boolean-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/date-properties.type.d.ts +7 -0
- package/dist/type/decorator/api/property/describe/date-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/date-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/dto/body-properties.type.d.ts +5 -0
- package/dist/type/decorator/api/property/describe/dto/body-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/dto/body-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/dto/index.d.ts +5 -0
- package/dist/type/decorator/api/property/describe/dto/index.js +22 -0
- package/dist/type/decorator/api/property/describe/dto/index.js.map +1 -0
- package/dist/type/decorator/api/property/describe/dto/properties.type.d.ts +6 -0
- package/dist/type/decorator/api/property/describe/dto/properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/dto/properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/dto/query/get-list-properties.type.d.ts +3 -0
- package/dist/type/decorator/api/property/describe/dto/query/get-list-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/dto/query/index.d.ts +2 -0
- package/dist/type/decorator/api/property/describe/dto/query/index.js +19 -0
- package/dist/type/decorator/api/property/describe/dto/query/index.js.map +1 -0
- package/dist/type/decorator/api/property/describe/dto/query/properties.type.d.ts +6 -0
- package/dist/type/decorator/api/property/describe/dto/query/properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/dto/query/properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/dto/request-properties.type.d.ts +5 -0
- package/dist/type/decorator/api/property/describe/dto/request-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/dto/request-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/dto/response-properties.type.d.ts +5 -0
- package/dist/type/decorator/api/property/describe/dto/response-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/dto/response-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/example-properties.type.d.ts +7 -0
- package/dist/type/decorator/api/property/describe/example-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/example-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/index.d.ts +12 -0
- package/dist/type/decorator/api/property/describe/index.js +29 -0
- package/dist/type/decorator/api/property/describe/index.js.map +1 -0
- package/dist/type/decorator/api/property/describe/number-properties.type.d.ts +13 -0
- package/dist/type/decorator/api/property/describe/number-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/number-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/object-properties.type.d.ts +10 -0
- package/dist/type/decorator/api/property/describe/object-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/object-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/properties/base-dto-properties.type.d.ts +2 -0
- package/dist/type/decorator/api/property/describe/properties/base-dto-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/properties/base-dto-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/properties/base-properties.type.d.ts +10 -0
- package/dist/type/decorator/api/property/describe/properties/base-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/properties/base-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/properties/index.d.ts +2 -0
- package/dist/type/decorator/api/property/describe/properties/index.js +19 -0
- package/dist/type/decorator/api/property/describe/properties/index.js.map +1 -0
- package/dist/type/decorator/api/property/describe/properties.type.d.ts +8 -0
- package/dist/type/decorator/api/property/describe/properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/relation-properties.type.d.ts +6 -0
- package/dist/type/decorator/api/property/describe/relation-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/relation-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/string-properties.type.d.ts +13 -0
- package/dist/type/decorator/api/property/describe/string-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/string-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/describe/uuid-properties.type.d.ts +7 -0
- package/dist/type/decorator/api/property/describe/uuid-properties.type.js +3 -0
- package/dist/type/decorator/api/property/describe/uuid-properties.type.js.map +1 -0
- package/dist/type/decorator/api/property/index.d.ts +1 -1
- package/dist/type/decorator/api/property/index.js +1 -1
- package/dist/type/decorator/api/property/index.js.map +1 -1
- package/dist/type/decorator/api/service-properties.type.d.ts +3 -0
- package/dist/type/decorator/api/service-properties.type.js +3 -0
- package/dist/type/decorator/api/service-properties.type.js.map +1 -0
- package/dist/type/index.d.ts +1 -0
- package/dist/type/index.js +1 -0
- package/dist/type/index.js.map +1 -1
- package/dist/type/utility/dto/generate-allowed-combination.type.d.ts +9 -0
- package/dist/type/utility/dto/generate-allowed-combination.type.js +3 -0
- package/dist/type/utility/dto/generate-allowed-combination.type.js.map +1 -0
- package/dist/type/utility/dto/generate-is-allowed-combination.type.d.ts +3 -0
- package/dist/type/utility/dto/generate-is-allowed-combination.type.js +3 -0
- package/dist/type/utility/dto/generate-is-allowed-combination.type.js.map +1 -0
- package/dist/type/utility/dto/index.d.ts +2 -0
- package/dist/type/utility/dto/index.js +19 -0
- package/dist/type/utility/dto/index.js.map +1 -0
- package/dist/type/utility/index.d.ts +1 -0
- package/dist/type/utility/index.js +18 -0
- package/dist/type/utility/index.js.map +1 -0
- package/dist/utility/api/controller/get-method-name.utility.d.ts +1 -1
- package/dist/utility/api/controller/get-method-name.utility.js +1 -1
- package/dist/utility/api/controller/get-method-name.utility.js.map +1 -1
- package/dist/utility/api/controller/write-method.utility.d.ts +3 -3
- package/dist/utility/api/controller/write-method.utility.js +2 -2
- package/dist/utility/api/controller/write-method.utility.js.map +1 -1
- package/dist/utility/api/filter-order-by-from-entity.utility.d.ts +4 -2
- package/dist/utility/api/filter-order-by-from-entity.utility.js +17 -14
- package/dist/utility/api/filter-order-by-from-entity.utility.js.map +1 -1
- package/dist/utility/dto/analize.utility.js.map +1 -1
- package/dist/utility/dto/build-decorator.utility.d.ts +4 -0
- package/dist/utility/dto/build-decorator.utility.js +31 -0
- package/dist/utility/dto/build-decorator.utility.js.map +1 -0
- package/dist/utility/dto/generate-decorator.utility.d.ts +3 -0
- package/dist/utility/dto/generate-decorator.utility.js +15 -0
- package/dist/utility/dto/generate-decorator.utility.js.map +1 -0
- package/dist/utility/dto/generate-exception.utility.d.ts +2 -0
- package/dist/utility/dto/generate-exception.utility.js +88 -0
- package/dist/utility/dto/generate-exception.utility.js.map +1 -0
- package/dist/utility/dto/generate.utility.d.ts +2 -2
- package/dist/utility/dto/generate.utility.js +51 -308
- package/dist/utility/dto/generate.utility.js.map +1 -1
- package/dist/utility/dto/get-base-class.utility.d.ts +3 -0
- package/dist/utility/dto/get-base-class.utility.js +65 -0
- package/dist/utility/dto/get-base-class.utility.js.map +1 -0
- package/dist/utility/dto/get-decorator-config.utility.d.ts +3 -0
- package/dist/utility/dto/get-decorator-config.utility.js +21 -0
- package/dist/utility/dto/get-decorator-config.utility.js.map +1 -0
- package/dist/utility/dto/handle-date-property.utility.d.ts +5 -0
- package/dist/utility/dto/handle-date-property.utility.js +18 -0
- package/dist/utility/dto/handle-date-property.utility.js.map +1 -0
- package/dist/utility/dto/index.d.ts +8 -0
- package/dist/utility/dto/index.js +8 -0
- package/dist/utility/dto/index.js.map +1 -1
- package/dist/utility/dto/is-property-should-be-enabled.utility.d.ts +3 -0
- package/dist/utility/dto/is-property-should-be-enabled.utility.js +26 -0
- package/dist/utility/dto/is-property-should-be-enabled.utility.js.map +1 -0
- package/dist/utility/dto/is-should-be-generated.utility.d.ts +2 -0
- package/dist/utility/dto/is-should-be-generated.utility.js +25 -0
- package/dist/utility/dto/is-should-be-generated.utility.js.map +1 -0
- package/dist/utility/dto/validate-property-config.utility.d.ts +2 -0
- package/dist/utility/dto/validate-property-config.utility.js +14 -0
- package/dist/utility/dto/validate-property-config.utility.js.map +1 -0
- package/dist/utility/generate-entity-information.utility.js +15 -6
- package/dist/utility/generate-entity-information.utility.js.map +1 -1
- package/dist/utility/get-entity-columns.utility.d.ts +3 -2
- package/dist/utility/get-entity-columns.utility.js +4 -3
- package/dist/utility/get-entity-columns.utility.js.map +1 -1
- package/package.json +4 -1
- package/dist/class/api/base-controller.class.d.ts +0 -4
- package/dist/class/api/base-controller.class.js +0 -10
- package/dist/class/api/base-controller.class.js.map +0 -1
- package/dist/decorator/api/route/decorator.d.ts +0 -18
- package/dist/decorator/api/route/decorator.js +0 -43
- package/dist/decorator/api/route/decorator.js.map +0 -1
- package/dist/decorator/api/route/get.decorator.d.ts +0 -9
- package/dist/decorator/api/route/get.decorator.js +0 -53
- package/dist/decorator/api/route/get.decorator.js.map +0 -1
- package/dist/decorator/api/route/index.d.ts +0 -2
- package/dist/decorator/api/route/index.js.map +0 -1
- package/dist/dto/exception/bad-request.dto.d.ts +0 -8
- package/dist/dto/exception/bad-request.dto.js +0 -84
- package/dist/dto/exception/bad-request.dto.js.map +0 -1
- package/dist/dto/exception/conflict.dto.d.ts +0 -8
- package/dist/dto/exception/conflict.dto.js +0 -84
- package/dist/dto/exception/conflict.dto.js.map +0 -1
- package/dist/dto/exception/forbidden.dto.d.ts +0 -8
- package/dist/dto/exception/forbidden.dto.js +0 -84
- package/dist/dto/exception/forbidden.dto.js.map +0 -1
- package/dist/dto/exception/index.d.ts +0 -7
- package/dist/dto/exception/index.js.map +0 -1
- package/dist/dto/exception/internal-server-error.dto.d.ts +0 -8
- package/dist/dto/exception/internal-server-error.dto.js +0 -84
- package/dist/dto/exception/internal-server-error.dto.js.map +0 -1
- package/dist/dto/exception/not-found.dto.d.ts +0 -8
- package/dist/dto/exception/not-found.dto.js +0 -84
- package/dist/dto/exception/not-found.dto.js.map +0 -1
- package/dist/dto/exception/too-many-requests.dto.d.ts +0 -8
- package/dist/dto/exception/too-many-requests.dto.js +0 -84
- package/dist/dto/exception/too-many-requests.dto.js.map +0 -1
- package/dist/dto/exception/unauthorized.dto.d.ts +0 -8
- package/dist/dto/exception/unauthorized.dto.js +0 -84
- package/dist/dto/exception/unauthorized.dto.js.map +0 -1
- package/dist/dto/index.d.ts +0 -1
- package/dist/dto/index.js.map +0 -1
- package/dist/type/decorator/api/function/create-properties.type.js.map +0 -1
- package/dist/type/decorator/api/function/get-list-properties.type.d.ts +0 -23
- package/dist/type/decorator/api/function/get-list-properties.type.js.map +0 -1
- package/dist/type/decorator/api/function/get-properties.type.js.map +0 -1
- package/dist/type/decorator/api/function/update-properties.type.js.map +0 -1
- package/dist/type/decorator/api/property/describe-properties.type.d.ts +0 -64
- package/dist/type/decorator/api/property/describe-properties.type.js +0 -3
- package/dist/type/decorator/api/property/describe-properties.type.js.map +0 -1
- /package/dist/type/decorator/api/function/{create-properties.type.d.ts → create/properties.type.d.ts} +0 -0
- /package/dist/type/decorator/api/function/{get-properties.type.d.ts → get/properties.type.d.ts} +0 -0
- /package/dist/type/decorator/api/function/{update-properties.type.d.ts → update/properties.type.d.ts} +0 -0
- /package/dist/type/decorator/api/{function → property/describe/dto/query}/get-list-properties.type.js +0 -0
|
@@ -6,12 +6,13 @@ const typeorm_1 = require("typeorm");
|
|
|
6
6
|
const constant_1 = require("../../../constant");
|
|
7
7
|
const enum_1 = require("../../../enum");
|
|
8
8
|
const utility_1 = require("../../../utility");
|
|
9
|
-
async function executor(
|
|
9
|
+
async function executor(options) {
|
|
10
|
+
const { entity, filter, properties, repository } = options;
|
|
10
11
|
try {
|
|
11
12
|
const [items, totalCount] = await repository.findAndCount(filter);
|
|
12
13
|
if (items.length === 0) {
|
|
13
14
|
throw new common_1.NotFoundException((0, utility_1.ErrorString)({
|
|
14
|
-
entity:
|
|
15
|
+
entity: entity,
|
|
15
16
|
type: enum_1.EErrorStringAction.LIST_PAGE_NOT_FOUND,
|
|
16
17
|
}));
|
|
17
18
|
}
|
|
@@ -28,7 +29,7 @@ async function executor(repository, entityType, properties, filter) {
|
|
|
28
29
|
throw error;
|
|
29
30
|
}
|
|
30
31
|
throw new common_1.InternalServerErrorException((0, utility_1.ErrorString)({
|
|
31
|
-
entity:
|
|
32
|
+
entity: entity,
|
|
32
33
|
type: enum_1.EErrorStringAction.FETCHING_LIST_ERROR,
|
|
33
34
|
}));
|
|
34
35
|
}
|
|
@@ -44,17 +45,17 @@ function ApiFunctionGetList(options) {
|
|
|
44
45
|
where: {},
|
|
45
46
|
};
|
|
46
47
|
const typedEntityProperties = entityProperties;
|
|
47
|
-
Object.keys(typedEntityProperties)
|
|
48
|
+
for (const key of Object.keys(typedEntityProperties)) {
|
|
48
49
|
if (typeof typedEntityProperties[key] === "string") {
|
|
49
50
|
filter.where = {
|
|
50
51
|
...filter.where,
|
|
51
52
|
[key]: (0, typeorm_1.Like)(`%${typedEntityProperties[key]}%`),
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
|
-
}
|
|
55
|
+
}
|
|
55
56
|
if (orderBy) {
|
|
56
57
|
filter.order = {
|
|
57
|
-
[orderBy]: orderDirection || constant_1.
|
|
58
|
+
[orderBy]: orderDirection || constant_1.FUNCTION_API_DECORATOR_CONSTANT.DEFAULT_FILTER_ORDER_BY_DIRECTION,
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
if ("createdAt" in options.model.prototype) {
|
|
@@ -119,9 +120,9 @@ function ApiFunctionGetList(options) {
|
|
|
119
120
|
}
|
|
120
121
|
const repository = this.repository;
|
|
121
122
|
if (!repository) {
|
|
122
|
-
throw
|
|
123
|
+
throw (0, utility_1.ErrorException)("Repository is not available in this context");
|
|
123
124
|
}
|
|
124
|
-
return executor(
|
|
125
|
+
return executor({ entity: options.model, filter, properties, repository });
|
|
125
126
|
};
|
|
126
127
|
return descriptor;
|
|
127
128
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-list.decorator.js","sourceRoot":"/","sources":["decorator/api/function/get-list.decorator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":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BAAe,EAAC,cAAc,CAAC;qBAC3C,CAAC;gBACH,CAAC;qBAAM,IAAI,YAAY,EAAE,CAAC;oBACzB,MAAM,CAAC,KAAK,GAAG;wBACd,GAAG,MAAM,CAAC,KAAK;wBACf,UAAU,EAAE,IAAA,yBAAe,EAAC,YAAY,CAAC;qBACzC,CAAC;gBACH,CAAC;YACF,CAAC;YAED,MAAM,UAAU,GAAkB,IAAI,CAAC,UAAU,CAAC;YAElD,IAAI,CAAC,UAAU,EAAE,CAAC;gBACjB,MAAM,IAAA,wBAAc,EAAC,6CAA6C,CAAC,CAAC;YACrE,CAAC;YAED,OAAO,QAAQ,CAAI,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;QAC/E,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { HttpException, InternalServerErrorException, NotFoundException } from \"@nestjs/common\";\nimport { Between, LessThanOrEqual, Like, MoreThanOrEqual } from \"typeorm\";\n\nimport { FUNCTION_API_DECORATOR_CONSTANT } from \"../../../constant\";\nimport { EErrorStringAction } from \"../../../enum\";\n\nimport { ErrorException, ErrorString } from \"../../../utility\";\n\nimport type { IApiBaseEntity, IApiGetListResponseResult } from \"../../../interface\";\n\nimport type { TApiFunctionGetListProperties } from \"../../../type\";\nimport type { IApiFunctionGetListExecutorProperties } from \"../../../type/decorator/api/function/get-list/executor-properties.type\";\nimport type { FindManyOptions, FindOptionsRelations, Repository } from \"typeorm\";\n\nasync function executor<E extends IApiBaseEntity>(options: IApiFunctionGetListExecutorProperties<E>): Promise<IApiGetListResponseResult<E>> {\n\tconst { entity, filter, properties, repository }: IApiFunctionGetListExecutorProperties<E> = options;\n\n\ttry {\n\t\tconst [items, totalCount]: [Array<E>, number] = await repository.findAndCount(filter);\n\n\t\tif (items.length === 0) {\n\t\t\tthrow new NotFoundException(\n\t\t\t\tErrorString({\n\t\t\t\t\tentity: entity,\n\t\t\t\t\ttype: EErrorStringAction.LIST_PAGE_NOT_FOUND,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tcount: items.length,\n\t\t\tcurrentPage: properties.page,\n\t\t\titems,\n\t\t\ttotalCount,\n\t\t\ttotalPages: Math.ceil(totalCount / properties.limit),\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof HttpException) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new InternalServerErrorException(\n\t\t\tErrorString({\n\t\t\t\tentity: entity,\n\t\t\t\ttype: EErrorStringAction.FETCHING_LIST_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionGetList<E extends IApiBaseEntity>(options: { model: new () => E }) {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\treturn function (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n\t\tdescriptor.value = async function (\n\t\t\tthis: {\n\t\t\t\trepository: Repository<E>;\n\t\t\t},\n\t\t\tproperties: TApiFunctionGetListProperties<InstanceType<typeof options.model>>,\n\t\t\trelations: FindOptionsRelations<E>,\n\t\t): Promise<IApiGetListResponseResult<E>> {\n\t\t\tconst { createdAtFrom, createdAtTo, limit, orderBy, orderDirection, page, receivedAtFrom, receivedAtTo, updatedAtFrom, updatedAtTo, ...entityProperties }: TApiFunctionGetListProperties<InstanceType<typeof options.model>> = properties;\n\n\t\t\tconst filter: FindManyOptions<typeof options.model> = {\n\t\t\t\trelations,\n\t\t\t\tskip: limit * (page - 1),\n\t\t\t\ttake: limit,\n\t\t\t\twhere: {},\n\t\t\t};\n\n\t\t\tconst typedEntityProperties: keyof typeof options.model = entityProperties as Exclude<keyof Omit<E, \"createdAt\" | \"receivedAt\" | \"updatedAt\">, keyof E>;\n\n\t\t\tfor (const key of Object.keys(typedEntityProperties)) {\n\t\t\t\tif (typeof typedEntityProperties[key] === \"string\") {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\t[key]: Like(`%${typedEntityProperties[key] as string}%`),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (orderBy) {\n\t\t\t\tfilter.order = {\n\t\t\t\t\t[orderBy as never as string]: orderDirection || FUNCTION_API_DECORATOR_CONSTANT.DEFAULT_FILTER_ORDER_BY_DIRECTION,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (\"createdAt\" in options.model.prototype) {\n\t\t\t\tif (createdAtFrom && createdAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tcreatedAt: Between(createdAtFrom, createdAtTo),\n\t\t\t\t\t};\n\t\t\t\t} else if (createdAtFrom) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tcreatedAt: MoreThanOrEqual(createdAtFrom),\n\t\t\t\t\t};\n\t\t\t\t} else if (createdAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tcreatedAt: LessThanOrEqual(createdAtTo),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"updatedAt\" in options.model.prototype) {\n\t\t\t\tif (updatedAtFrom && updatedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tupdatedAt: Between(updatedAtFrom, updatedAtTo),\n\t\t\t\t\t};\n\t\t\t\t} else if (updatedAtFrom) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tupdatedAt: MoreThanOrEqual(updatedAtFrom),\n\t\t\t\t\t};\n\t\t\t\t} else if (updatedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\tupdatedAt: LessThanOrEqual(updatedAtTo),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (\"receivedAt\" in options.model.prototype) {\n\t\t\t\tif (receivedAtFrom && receivedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\treceivedAt: Between(receivedAtFrom, receivedAtTo),\n\t\t\t\t\t};\n\t\t\t\t} else if (receivedAtFrom) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\treceivedAt: MoreThanOrEqual(receivedAtFrom),\n\t\t\t\t\t};\n\t\t\t\t} else if (receivedAtTo) {\n\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\treceivedAt: LessThanOrEqual(receivedAtTo),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst repository: Repository<E> = this.repository;\n\n\t\t\tif (!repository) {\n\t\t\t\tthrow ErrorException(\"Repository is not available in this context\");\n\t\t\t}\n\n\t\t\treturn executor<E>({ entity: options.model, filter, properties, repository });\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function ApiFunctionGet<E extends
|
|
1
|
+
import type { IApiBaseEntity } from "../../../interface";
|
|
2
|
+
export declare function ApiFunctionGet<E extends IApiBaseEntity>(options: {
|
|
3
3
|
model: new () => E;
|
|
4
|
-
}): (_target:
|
|
4
|
+
}): (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
@@ -5,22 +5,21 @@ const common_1 = require("@nestjs/common");
|
|
|
5
5
|
const typeorm_1 = require("typeorm");
|
|
6
6
|
const enum_1 = require("../../../enum");
|
|
7
7
|
const utility_1 = require("../../../utility");
|
|
8
|
-
async function executor(
|
|
9
|
-
|
|
8
|
+
async function executor(options) {
|
|
9
|
+
const { entity, filter, repository } = options;
|
|
10
10
|
try {
|
|
11
11
|
const item = await repository.findOne(filter);
|
|
12
12
|
if (!item) {
|
|
13
|
-
throw new common_1.NotFoundException((0, utility_1.ErrorString)({ entity:
|
|
13
|
+
throw new common_1.NotFoundException((0, utility_1.ErrorString)({ entity: entity, type: enum_1.EErrorStringAction.NOT_FOUND }));
|
|
14
14
|
}
|
|
15
15
|
return item;
|
|
16
16
|
}
|
|
17
17
|
catch (error) {
|
|
18
|
-
console.log("FUCKIGH", error);
|
|
19
18
|
if (error instanceof common_1.HttpException) {
|
|
20
19
|
throw error;
|
|
21
20
|
}
|
|
22
21
|
throw new common_1.InternalServerErrorException((0, utility_1.ErrorString)({
|
|
23
|
-
entity:
|
|
22
|
+
entity: entity,
|
|
24
23
|
type: enum_1.EErrorStringAction.FETCHING_ERROR,
|
|
25
24
|
}));
|
|
26
25
|
}
|
|
@@ -35,20 +34,20 @@ function ApiFunctionGet(options) {
|
|
|
35
34
|
if (properties) {
|
|
36
35
|
const { ...entityProperties } = properties;
|
|
37
36
|
const typedEntityProperties = entityProperties;
|
|
38
|
-
Object.keys(typedEntityProperties)
|
|
37
|
+
for (const key of Object.keys(typedEntityProperties)) {
|
|
39
38
|
if (typeof typedEntityProperties[key] === "string") {
|
|
40
39
|
filter.where = {
|
|
41
40
|
...filter.where,
|
|
42
41
|
[key]: (0, typeorm_1.Like)(`%${typedEntityProperties[key]}%`),
|
|
43
42
|
};
|
|
44
43
|
}
|
|
45
|
-
}
|
|
44
|
+
}
|
|
46
45
|
}
|
|
47
46
|
const repository = this.repository;
|
|
48
47
|
if (!repository) {
|
|
49
|
-
throw
|
|
48
|
+
throw (0, utility_1.ErrorException)("Repository is not available in this context");
|
|
50
49
|
}
|
|
51
|
-
return executor(
|
|
50
|
+
return executor({ entity: options.model, filter, repository });
|
|
52
51
|
};
|
|
53
52
|
return descriptor;
|
|
54
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.decorator.js","sourceRoot":"/","sources":["decorator/api/function/get.decorator.ts"],"names":[],"mappings":";;AAqCA,
|
|
1
|
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AAC;gBAExJ,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,EAAE,CAAC;oBACtD,IAAI,OAAO,qBAAqB,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;wBACpD,MAAM,CAAC,KAAK,GAAG;4BACd,GAAG,MAAM,CAAC,KAAK;4BACf,CAAC,GAAG,CAAC,EAAE,IAAA,cAAI,EAAC,IAAI,qBAAqB,CAAC,GAAG,CAAW,GAAG,CAAC;yBACxD,CAAC;oBACH,CAAC;gBACF,CAAC;YACF,CAAC;YAED,MAAM,UAAU,GAAkB,IAAI,CAAC,UAAU,CAAC;YAElD,IAAI,CAAC,UAAU,EAAE,CAAC;gBACjB,MAAM,IAAA,wBAAc,EAAC,6CAA6C,CAAC,CAAC;YACrE,CAAC;YAED,OAAO,QAAQ,CAAI,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QACnE,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { HttpException, InternalServerErrorException, NotFoundException } from \"@nestjs/common\";\nimport { Like } from \"typeorm\";\n\nimport { EErrorStringAction } from \"../../../enum\";\n\nimport { ErrorException, ErrorString } from \"../../../utility\";\n\nimport type { IApiBaseEntity } from \"../../../interface\";\nimport type { IApiFunctionGetExecutorProperties, TApiFunctionGetProperties } from \"../../../type\";\n\nimport type { FindManyOptions, FindOptionsRelations, Repository } from \"typeorm\";\n\nasync function executor<E extends IApiBaseEntity>(options: IApiFunctionGetExecutorProperties<E>): Promise<E> {\n\tconst { entity, filter, repository }: IApiFunctionGetExecutorProperties<E> = options;\n\n\ttry {\n\t\tconst item: E | null = await repository.findOne(filter);\n\n\t\tif (!item) {\n\t\t\tthrow new NotFoundException(ErrorString({ entity: entity, type: EErrorStringAction.NOT_FOUND }));\n\t\t}\n\n\t\treturn item;\n\t} catch (error) {\n\t\tif (error instanceof HttpException) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new InternalServerErrorException(\n\t\t\tErrorString({\n\t\t\t\tentity: entity,\n\t\t\t\ttype: EErrorStringAction.FETCHING_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionGet<E extends IApiBaseEntity>(options: { model: new () => E }) {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\treturn function (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n\t\tdescriptor.value = async function (\n\t\t\tthis: {\n\t\t\t\trepository: Repository<E>;\n\t\t\t},\n\t\t\tid: string,\n\t\t\tproperties?: TApiFunctionGetProperties<InstanceType<typeof options.model>>,\n\t\t\trelations?: FindOptionsRelations<E>,\n\t\t): Promise<E> {\n\t\t\tconst filter: FindManyOptions<typeof options.model> = {\n\t\t\t\trelations: relations,\n\t\t\t\twhere: { id },\n\t\t\t};\n\n\t\t\tif (properties) {\n\t\t\t\tconst { ...entityProperties }: TApiFunctionGetProperties<InstanceType<typeof options.model>> = properties;\n\n\t\t\t\tconst typedEntityProperties: keyof typeof options.model = entityProperties as Exclude<keyof Omit<E, \"createdAt\" | \"receivedAt\" | \"updatedAt\">, keyof E>;\n\n\t\t\t\tfor (const key of Object.keys(typedEntityProperties)) {\n\t\t\t\t\tif (typeof typedEntityProperties[key] === \"string\") {\n\t\t\t\t\t\tfilter.where = {\n\t\t\t\t\t\t\t...filter.where,\n\t\t\t\t\t\t\t[key]: Like(`%${typedEntityProperties[key] as string}%`),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst repository: Repository<E> = this.repository;\n\n\t\t\tif (!repository) {\n\t\t\t\tthrow ErrorException(\"Repository is not available in this context\");\n\t\t\t}\n\n\t\t\treturn executor<E>({ entity: options.model, filter, repository });\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function ApiFunctionUpdate<E extends
|
|
1
|
+
import type { IApiBaseEntity } from "../../../interface";
|
|
2
|
+
export declare function ApiFunctionUpdate<E extends IApiBaseEntity>(options: {
|
|
3
3
|
model: new () => E;
|
|
4
|
-
}): (_target:
|
|
4
|
+
}): (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
@@ -5,17 +5,13 @@ const common_1 = require("@nestjs/common");
|
|
|
5
5
|
const enum_1 = require("../../../enum");
|
|
6
6
|
const utility_1 = require("../../../utility");
|
|
7
7
|
const get_decorator_1 = require("./get.decorator");
|
|
8
|
-
async function executor(
|
|
8
|
+
async function executor(options) {
|
|
9
|
+
const { entity, getFunction, id, properties, repository } = options;
|
|
9
10
|
try {
|
|
10
11
|
const entity = await getFunction(id.toString());
|
|
11
|
-
const allColumns = (0, utility_1.GetEntityColumns)(
|
|
12
|
-
const autoGeneratedColumns = (0, utility_1.GetEntityColumns)(
|
|
13
|
-
const filteredProperties = Object.
|
|
14
|
-
if (allColumns.includes(key) && !autoGeneratedColumns.includes(key)) {
|
|
15
|
-
accumulator[key] = properties[key];
|
|
16
|
-
}
|
|
17
|
-
return accumulator;
|
|
18
|
-
}, {});
|
|
12
|
+
const allColumns = (0, utility_1.GetEntityColumns)({ entity: entity, shouldTakeGeneratedOnly: false });
|
|
13
|
+
const autoGeneratedColumns = (0, utility_1.GetEntityColumns)({ entity: entity, shouldTakeGeneratedOnly: true });
|
|
14
|
+
const filteredProperties = Object.fromEntries(Object.entries(properties).filter(([key]) => allColumns.includes(key) && !autoGeneratedColumns.includes(key)));
|
|
19
15
|
const updatedEntity = repository.merge(entity, filteredProperties);
|
|
20
16
|
return await repository.save(updatedEntity);
|
|
21
17
|
}
|
|
@@ -25,7 +21,7 @@ async function executor(repository, entityType, id, properties, getFunction) {
|
|
|
25
21
|
throw error;
|
|
26
22
|
}
|
|
27
23
|
throw new common_1.InternalServerErrorException((0, utility_1.ErrorString)({
|
|
28
|
-
entity:
|
|
24
|
+
entity: entity,
|
|
29
25
|
type: enum_1.EErrorStringAction.UPDATING_ERROR,
|
|
30
26
|
}));
|
|
31
27
|
}
|
|
@@ -37,12 +33,12 @@ function ApiFunctionUpdate(options) {
|
|
|
37
33
|
descriptor.value = async function (id, properties) {
|
|
38
34
|
const repository = this.repository;
|
|
39
35
|
if (!repository) {
|
|
40
|
-
throw
|
|
36
|
+
throw (0, utility_1.ErrorException)("Repository is not available in this context");
|
|
41
37
|
}
|
|
42
38
|
if (!getFunction) {
|
|
43
39
|
const getDescriptor = {
|
|
44
40
|
value: function () {
|
|
45
|
-
return Promise.reject(
|
|
41
|
+
return Promise.reject((0, utility_1.ErrorException)("Not implemented"));
|
|
46
42
|
},
|
|
47
43
|
};
|
|
48
44
|
getDecorator(this, "get", getDescriptor);
|
|
@@ -50,10 +46,10 @@ function ApiFunctionUpdate(options) {
|
|
|
50
46
|
getFunction = getDescriptor.value.bind(this);
|
|
51
47
|
}
|
|
52
48
|
else {
|
|
53
|
-
throw
|
|
49
|
+
throw (0, utility_1.ErrorException)("Get function is not properly decorated");
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
|
-
return executor(
|
|
52
|
+
return executor({ entity: new options.model(), getFunction, id, properties, repository });
|
|
57
53
|
};
|
|
58
54
|
return descriptor;
|
|
59
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.decorator.js","sourceRoot":"/","sources":["decorator/api/function/update.decorator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"update.decorator.js","sourceRoot":"/","sources":["decorator/api/function/update.decorator.ts"],"names":[],"mappings":";;AA2CA,8CAuCC;AAlFD,2CAA6E;AAE7E,wCAAmD;AAEnD,8CAAiF;AAEjF,mDAAiD;AAOjD,KAAK,UAAU,QAAQ,CAA2B,OAAgD;IACjG,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE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AO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC1J,IAAI,WAAkF,CAAC;QAEvF,UAAU,CAAC,KAAK,GAAG,KAAK,WAIvB,EAAmB,EACnB,UAA4E;YAE5E,MAAM,UAAU,GAAkB,IAAI,CAAC,UAAU,CAAC;YAElD,IAAI,CAAC,UAAU,EAAE,CAAC;gBACjB,MAAM,IAAA,wBAAc,EAAC,6CAA6C,CAAC,CAAC;YACrE,CAAC;YAED,IAAI,CAAC,WAAW,EAAE,CAAC;gBAClB,MAAM,aAAa,GAAmG;oBACrH,KAAK,EAAE;wBACN,OAAO,OAAO,CAAC,MAAM,CAAC,IAAA,wBAAc,EAAC,iBAAiB,CAAC,CAAC,CAAC;oBAC1D,CAAC;iBACD,CAAC;gBACF,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;gBAEzC,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;oBACzB,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC9C,CAAC;qBAAM,CAAC;oBACP,MAAM,IAAA,wBAAc,EAAC,wCAAwC,CAAC,CAAC;gBAChE,CAAC;YACF,CAAC;YAED,OAAO,QAAQ,CAAI,EAAE,MAAM,EAAE,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;QAC9F,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { HttpException, InternalServerErrorException } from \"@nestjs/common\";\n\nimport { EErrorStringAction } from \"../../../enum\";\n\nimport { ErrorException, ErrorString, GetEntityColumns } from \"../../../utility\";\n\nimport { ApiFunctionGet } from \"./get.decorator\";\n\nimport type { IApiBaseEntity } from \"../../../interface\";\nimport type { IApiFunctionUpdateExecutorProperties, TApiFunctionGetProperties, TApiFunctionUpdateProperties } from \"../../../type\";\n\nimport type { DeepPartial, Repository } from \"typeorm\";\n\nasync function executor<E extends IApiBaseEntity>(options: IApiFunctionUpdateExecutorProperties<E>): Promise<E> {\n\tconst { entity, getFunction, id, properties, repository }: IApiFunctionUpdateExecutorProperties<E> = options;\n\n\ttry {\n\t\tconst entity: E = await getFunction(id.toString());\n\n\t\tconst allColumns: Array<keyof E> = GetEntityColumns<E>({ entity: entity, shouldTakeGeneratedOnly: false });\n\t\tconst autoGeneratedColumns: Array<keyof E> = GetEntityColumns<E>({ entity: entity, shouldTakeGeneratedOnly: true });\n\n\t\tconst filteredProperties: DeepPartial<E> = Object.fromEntries(Object.entries(properties).filter(([key]: [string, unknown]) => allColumns.includes(key as keyof E) && !autoGeneratedColumns.includes(key as keyof E))) as DeepPartial<E>;\n\n\t\tconst updatedEntity: E = repository.merge(entity, filteredProperties);\n\n\t\treturn await repository.save(updatedEntity);\n\t} catch (error) {\n\t\tconsole.log(error);\n\n\t\tif (error instanceof HttpException) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tthrow new InternalServerErrorException(\n\t\t\tErrorString({\n\t\t\t\tentity: entity,\n\t\t\t\ttype: EErrorStringAction.UPDATING_ERROR,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nexport function ApiFunctionUpdate<E extends IApiBaseEntity>(options: { model: new () => E }) {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\treturn function (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n\t\tconst getDecorator: (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor = ApiFunctionGet({ model: options.model });\n\t\tlet getFunction: (id: string, properties?: TApiFunctionGetProperties<E>) => Promise<E>;\n\n\t\tdescriptor.value = async function (\n\t\t\tthis: {\n\t\t\t\trepository: Repository<E>;\n\t\t\t},\n\t\t\tid: number | string,\n\t\t\tproperties: TApiFunctionUpdateProperties<InstanceType<typeof options.model>>,\n\t\t): Promise<E> {\n\t\t\tconst repository: Repository<E> = this.repository;\n\n\t\t\tif (!repository) {\n\t\t\t\tthrow ErrorException(\"Repository is not available in this context\");\n\t\t\t}\n\n\t\t\tif (!getFunction) {\n\t\t\t\tconst getDescriptor: TypedPropertyDescriptor<(id: string, properties?: TApiFunctionGetProperties<E>) => Promise<E>> = {\n\t\t\t\t\tvalue: function () {\n\t\t\t\t\t\treturn Promise.reject(ErrorException(\"Not implemented\"));\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tgetDecorator(this, \"get\", getDescriptor);\n\n\t\t\t\tif (getDescriptor.value) {\n\t\t\t\t\tgetFunction = getDescriptor.value.bind(this);\n\t\t\t\t} else {\n\t\t\t\t\tthrow ErrorException(\"Get function is not properly decorated\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn executor<E>({ entity: new options.model(), getFunction, id, properties, repository });\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n"]}
|
|
@@ -18,5 +18,4 @@ __exportStar(require("./function"), exports);
|
|
|
18
18
|
__exportStar(require("./property"), exports);
|
|
19
19
|
__exportStar(require("./service.decorator"), exports);
|
|
20
20
|
__exportStar(require("./controller.decorator"), exports);
|
|
21
|
-
__exportStar(require("./route"), exports);
|
|
22
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["decorator/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,6CAA2B;AAC3B,sDAAoC;AACpC,yDAAuC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["decorator/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,6CAA2B;AAC3B,sDAAoC;AACpC,yDAAuC","sourcesContent":["export * from \"./function\";\nexport * from \"./property\";\nexport * from \"./service.decorator\";\nexport * from \"./controller.decorator\";\n"]}
|
|
@@ -5,6 +5,7 @@ const common_1 = require("@nestjs/common");
|
|
|
5
5
|
const swagger_1 = require("@nestjs/swagger");
|
|
6
6
|
const throttler_1 = require("@nestjs/throttler");
|
|
7
7
|
const enum_1 = require("../../enum");
|
|
8
|
+
const utility_1 = require("../../utility");
|
|
8
9
|
function ApiMethod(options) {
|
|
9
10
|
let summary = "";
|
|
10
11
|
if (options.action) {
|
|
@@ -123,6 +124,50 @@ function ApiMethod(options) {
|
|
|
123
124
|
if (options.throttler) {
|
|
124
125
|
decorators.push((0, throttler_1.Throttle)({ default: options.throttler }));
|
|
125
126
|
}
|
|
127
|
+
if (options.responses) {
|
|
128
|
+
if (options.responses.unauthorized) {
|
|
129
|
+
decorators.push((0, swagger_1.ApiUnauthorizedResponse)({
|
|
130
|
+
description: "Unauthorized",
|
|
131
|
+
status: common_1.HttpStatus.UNAUTHORIZED,
|
|
132
|
+
type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.UNAUTHORIZED),
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
if (options.responses.forbidden) {
|
|
136
|
+
decorators.push((0, swagger_1.ApiForbiddenResponse)({
|
|
137
|
+
description: "Forbiddeb",
|
|
138
|
+
status: common_1.HttpStatus.FORBIDDEN,
|
|
139
|
+
type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.FORBIDDEN),
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
if (options.responses.internalServerError) {
|
|
143
|
+
decorators.push((0, swagger_1.ApiInternalServerErrorResponse)({
|
|
144
|
+
description: "Internal Server Error",
|
|
145
|
+
status: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
146
|
+
type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.INTERNAL_SERVER_ERROR),
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
if (options.responses.notFound) {
|
|
150
|
+
decorators.push((0, swagger_1.ApiNotFoundResponse)({
|
|
151
|
+
description: "Not Found",
|
|
152
|
+
status: common_1.HttpStatus.NOT_FOUND,
|
|
153
|
+
type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.NOT_FOUND),
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
if (options.responses.badRequest) {
|
|
157
|
+
decorators.push((0, swagger_1.ApiBadRequestResponse)({
|
|
158
|
+
description: "Bad Request",
|
|
159
|
+
status: common_1.HttpStatus.BAD_REQUEST,
|
|
160
|
+
type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.BAD_REQUEST),
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
if (options.responses.tooManyRequests) {
|
|
164
|
+
decorators.push((0, swagger_1.ApiTooManyRequestsResponse)({
|
|
165
|
+
description: "Too Many Requests",
|
|
166
|
+
status: common_1.HttpStatus.TOO_MANY_REQUESTS,
|
|
167
|
+
type: (0, utility_1.DtoGenerateException)(common_1.HttpStatus.TOO_MANY_REQUESTS),
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
126
171
|
switch (options.method) {
|
|
127
172
|
case common_1.RequestMethod.GET: {
|
|
128
173
|
decorators.push((0, common_1.Get)(options.path));
|
|
@@ -148,6 +193,19 @@ function ApiMethod(options) {
|
|
|
148
193
|
throw new Error(`ApiMethod error: Method ${options.method} is not supported`);
|
|
149
194
|
}
|
|
150
195
|
}
|
|
196
|
+
if (options.authentication) {
|
|
197
|
+
decorators.push((0, common_1.UseGuards)(options.authentication.guard));
|
|
198
|
+
if (options.authentication?.bearerStrategies?.length) {
|
|
199
|
+
for (const strategy of options.authentication?.bearerStrategies) {
|
|
200
|
+
decorators.push((0, swagger_1.ApiBearerAuth)(strategy));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (options.authentication?.securityStrategies?.length) {
|
|
204
|
+
for (const strategy of options.authentication.securityStrategies) {
|
|
205
|
+
decorators.push((0, swagger_1.ApiSecurity)(strategy));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
151
209
|
return (0, common_1.applyDecorators)(...decorators);
|
|
152
210
|
}
|
|
153
211
|
//# sourceMappingURL=method.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.decorator.js","sourceRoot":"/","sources":["decorator/api/method.decorator.ts"],"names":[],"mappings":";;AAeA,8BAkSC;AAjTD,2CAAyG;AACzG,6CAA4D;AAC5D,iDAA6C;AAE7C,qCAAwC;AAWxC,SAAgB,SAAS,CAA2B,OAAgC;IACnF,IAAI,OAAO,GAAW,EAAE,CAAC;IAEzB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;YACxB,KAAK,iBAAU,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACxB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACxB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACxB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,cAAc,CAAC,CAAC,CAAC;gBAChC,OAAO,GAAG,sBAAsB,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAExD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,UAAU,CAAC,CAAC,CAAC;gBAC5B,OAAO,GAAG,sBAAsB,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC;gBAEzD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAA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P,CAAC;QAED,KAAK,sBAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1B,UAAU,CAAC,IAAI,CAAC,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAErC,MAAM;QACP,CAAC;QAED,KAAK,sBAAa,CAAC,GAAG,CAAC,CAAC,CAAC;YACxB,UAAU,CAAC,IAAI,CAAC,IAAA,YAAG,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAEnC,MAAM;QACP,CAAC;QAED,KAAK,sBAAa,CAAC,MAAM,CAAC,CAAC,CAAC;YAC3B,UAAU,CAAC,IAAI,CAAC,IAAA,eAAM,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAEtC,MAAM;QACP,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,CAAC,MAAM,mBAAmB,CAAC,CAAC;QAC/E,CAAC;IACF,CAAC;IAwBD,OAAO,IAAA,wBAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { applyDecorators, Delete, Get, HttpCode, Patch, Post, Put, RequestMethod } from \"@nestjs/common\";\nimport { ApiOperation, ApiResponse } from \"@nestjs/swagger\";\nimport { Throttle } from \"@nestjs/throttler\";\n\nimport { EApiAction } from \"../../enum\";\n\nimport type { IApiBaseEntity, IApiMethodProperties } from \"../../interface\";\n// import { ExceptionBadRequestDTO } from \"../../dto/exception/bad-request.dto\";\n\n/* import { ExceptionForbiddenDTO } from \"../../dto/exception/forbidden.dto\";\nimport { ExceptionInternalServerErrorDTO } from \"../../dto/exception/internal-server-error.dto\";\nimport { ExceptionNotFoundDTO } from \"../../dto/exception/not-found.dto\";\nimport { ExceptionTooManyRequestsDTO } from \"../../dto/exception/too-many-requests.dto\";\nimport { ExceptionUnauthorizedDTO } from \"../../dto/exception/unauthorized.dto\";*/\n\nexport function ApiMethod<T extends IApiBaseEntity>(options: IApiMethodProperties<T>): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void {\n\tlet summary: string = \"\";\n\n\tif (options.action) {\n\t\tswitch (options.action) {\n\t\t\tcase EApiAction.FETCH: {\n\t\t\t\tsummary = `Fetching \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CREATE: {\n\t\t\t\tsummary = `Creating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.UPDATE: {\n\t\t\t\tsummary = `Updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.DELETE: {\n\t\t\t\tsummary = `Deleting \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.PARTIAL_UPDATE: {\n\t\t\t\tsummary = `Partial updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_LIST: {\n\t\t\t\tsummary = `Fetching list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SPECIFIED: {\n\t\t\t\tsummary = `Fetching \\`${options.entity.name}\\` of specified item`;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REGISTRATION: {\n\t\t\t\tsummary = `Registration of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.AUTHENTICATION: {\n\t\t\t\tsummary = `Authentication of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CONFIRMATION: {\n\t\t\t\tsummary = `Confirmation of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REFRESH: {\n\t\t\t\tsummary = `Refresh of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SIMPLE_LIST: {\n\t\t\t\tsummary = `Fetching simple list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!options.description && options.action) {\n\t\tswitch (options.action) {\n\t\t\tcase EApiAction.FETCH: {\n\t\t\t\toptions.description = `This method is used for fetching \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CREATE: {\n\t\t\t\toptions.description = `This method is used for creating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.UPDATE: {\n\t\t\t\toptions.description = `This method is used for updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.DELETE: {\n\t\t\t\toptions.description = `This method is used for deleting \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.PARTIAL_UPDATE: {\n\t\t\t\toptions.description = `This method is used for partial updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_LIST: {\n\t\t\t\toptions.description = `This method is used for fetching list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SPECIFIED: {\n\t\t\t\toptions.description = `This method is used for fetching \\`${options.entity.name}\\` of specified item`;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REGISTRATION: {\n\t\t\t\toptions.description = `This method is used for registration of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.AUTHENTICATION: {\n\t\t\t\toptions.description = `This method is used for authentication of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CONFIRMATION: {\n\t\t\t\toptions.description = `This method is used for confirmation of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REFRESH: {\n\t\t\t\toptions.description = `This method is used for refresh of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SIMPLE_LIST: {\n\t\t\t\toptions.description = `This method is used for fetching simple list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst decorators: Array<MethodDecorator> = [\n\t\tApiOperation({ description: options.description, summary }),\n\t\tApiResponse({\n\t\t\tdescription: \"Success\",\n\t\t\tstatus: options.httpCode,\n\t\t\ttype: options.responseType,\n\t\t}),\n\t\tHttpCode(options.httpCode),\n\t];\n\n\tif (options.throttler) {\n\t\tdecorators.push(Throttle({ default: options.throttler }));\n\t}\n\n\t/* if (options.responses) {\n\t\tif (options.responses.unauthorized) {\n\t\t\tdecorators.push(\n\t\t\t\tApiUnauthorizedResponse({\n\t\t\t\t\tdescription: \"Unauthorized\",\n\t\t\t\t\tstatus: HttpStatus.UNAUTHORIZED,\n\t\t\t\t\ttype: ExceptionUnauthorizedDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.forbidden) {\n\t\t\tdecorators.push(\n\t\t\t\tApiForbiddenResponse({\n\t\t\t\t\tdescription: \"Forbidden\",\n\t\t\t\t\tstatus: HttpStatus.FORBIDDEN,\n\t\t\t\t\ttype: ExceptionForbiddenDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.internalServerError) {\n\t\t\tdecorators.push(\n\t\t\t\tApiInternalServerErrorResponse({\n\t\t\t\t\tdescription: \"Internal Server Error\",\n\t\t\t\t\tstatus: HttpStatus.INTERNAL_SERVER_ERROR,\n\t\t\t\t\ttype: ExceptionInternalServerErrorDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.notFound) {\n\t\t\tdecorators.push(\n\t\t\t\tApiNotFoundResponse({\n\t\t\t\t\tdescription: \"Not Found\",\n\t\t\t\t\tstatus: HttpStatus.NOT_FOUND,\n\t\t\t\t\ttype: ExceptionNotFoundDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.badRequest) {\n\t\t\tdecorators.push(\n\t\t\t\tApiBadRequestResponse({\n\t\t\t\t\tdescription: \"Bad Request\",\n\t\t\t\t\tstatus: HttpStatus.BAD_REQUEST,\n\t\t\t\t\ttype: ExceptionBadRequestDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.tooManyRequests) {\n\t\t\tdecorators.push(\n\t\t\t\tApiBadRequestResponse({\n\t\t\t\t\tdescription: \"Too Many Requests\",\n\t\t\t\t\tstatus: HttpStatus.TOO_MANY_REQUESTS,\n\t\t\t\t\ttype: ExceptionTooManyRequestsDTO,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}*/\n\n\tswitch (options.method) {\n\t\tcase RequestMethod.GET: {\n\t\t\tdecorators.push(Get(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.POST: {\n\t\t\tdecorators.push(Post(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.PATCH: {\n\t\t\tdecorators.push(Patch(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.PUT: {\n\t\t\tdecorators.push(Put(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.DELETE: {\n\t\t\tdecorators.push(Delete(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tthrow new Error(`ApiMethod error: Method ${options.method} is not supported`);\n\t\t}\n\t}\n\n\t/* if (options.authentication) {\n switch (options.authentication) {\n case EApiAuthenticationType.USER: {\n decorators.push(ApiBearerAuth(\"userAuthorization\"), isUser());\n\n break;\n }\n\n case EApiAuthenticationType.ADMIN: {\n decorators.push(ApiBearerAuth(\"adminAuthorization\"), isAdminUser());\n\n break;\n }\n\n case EApiAuthenticationType.ACCOUNT: {\n decorators.push(ApiBearerAuth(\"accountAuthorization\"), ApiSecurity(\"accountRequestSignature\"), ApiSecurity(\"accountRequestTimestamp\"), isAccount());\n\n break;\n }\n }\n }*/\n\n\treturn applyDecorators(...decorators);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"method.decorator.js","sourceRoot":"/","sources":["decorator/api/method.decorator.ts"],"names":[],"mappings":";;AAUA,8BA4RC;AAtSD,2CAAgI;AAChI,6CAA+O;AAC/O,iDAA6C;AAE7C,qCAAwC;AAExC,2CAAqD;AAIrD,SAAgB,SAAS,CAA2B,OAAgC;IACnF,IAAI,OAAO,GAAW,EAAE,CAAC;IAEzB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;YACxB,KAAK,iBAAU,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACxB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACxB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBACxB,OAAO,GAAG,cAAc,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;gBAEhD,MAAM;YACP,CAAC;YAED,KAAK,iBAAU,CAAC,cAAc,CAAC,CAAC,CAAC;gB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2BAA2B,OAAO,CAAC,MAAM,mBAAmB,CAAC,CAAC;QAC/E,CAAC;IACF,CAAC;IAED,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC5B,UAAU,CAAC,IAAI,CAAC,IAAA,kBAAS,EAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAEzD,IAAI,OAAO,CAAC,cAAc,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;YACtD,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,cAAc,EAAE,gBAAgB,EAAE,CAAC;gBACjE,UAAU,CAAC,IAAI,CAAC,IAAA,uBAAa,EAAC,QAAQ,CAAC,CAAC,CAAC;YAC1C,CAAC;QACF,CAAC;QAED,IAAI,OAAO,CAAC,cAAc,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC;YACxD,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC;gBAClE,UAAU,CAAC,IAAI,CAAC,IAAA,qBAAW,EAAC,QAAQ,CAAC,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,IAAA,wBAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { applyDecorators, Delete, Get, HttpCode, HttpStatus, Patch, Post, Put, RequestMethod, UseGuards } from \"@nestjs/common\";\nimport { ApiBadRequestResponse, ApiBearerAuth, ApiForbiddenResponse, ApiInternalServerErrorResponse, ApiNotFoundResponse, ApiOperation, ApiResponse, ApiSecurity, ApiTooManyRequestsResponse, ApiUnauthorizedResponse } from \"@nestjs/swagger\";\nimport { Throttle } from \"@nestjs/throttler\";\n\nimport { EApiAction } from \"../../enum\";\n\nimport { DtoGenerateException } from \"../../utility\";\n\nimport type { IApiBaseEntity, IApiMethodProperties } from \"../../interface\";\n\nexport function ApiMethod<T extends IApiBaseEntity>(options: IApiMethodProperties<T>): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void {\n\tlet summary: string = \"\";\n\n\tif (options.action) {\n\t\tswitch (options.action) {\n\t\t\tcase EApiAction.FETCH: {\n\t\t\t\tsummary = `Fetching \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CREATE: {\n\t\t\t\tsummary = `Creating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.UPDATE: {\n\t\t\t\tsummary = `Updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.DELETE: {\n\t\t\t\tsummary = `Deleting \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.PARTIAL_UPDATE: {\n\t\t\t\tsummary = `Partial updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_LIST: {\n\t\t\t\tsummary = `Fetching list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SPECIFIED: {\n\t\t\t\tsummary = `Fetching \\`${options.entity.name}\\` of specified item`;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REGISTRATION: {\n\t\t\t\tsummary = `Registration of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.AUTHENTICATION: {\n\t\t\t\tsummary = `Authentication of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CONFIRMATION: {\n\t\t\t\tsummary = `Confirmation of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REFRESH: {\n\t\t\t\tsummary = `Refresh of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SIMPLE_LIST: {\n\t\t\t\tsummary = `Fetching simple list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!options.description && options.action) {\n\t\tswitch (options.action) {\n\t\t\tcase EApiAction.FETCH: {\n\t\t\t\toptions.description = `This method is used for fetching \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CREATE: {\n\t\t\t\toptions.description = `This method is used for creating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.UPDATE: {\n\t\t\t\toptions.description = `This method is used for updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.DELETE: {\n\t\t\t\toptions.description = `This method is used for deleting \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.PARTIAL_UPDATE: {\n\t\t\t\toptions.description = `This method is used for partial updating \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_LIST: {\n\t\t\t\toptions.description = `This method is used for fetching list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SPECIFIED: {\n\t\t\t\toptions.description = `This method is used for fetching \\`${options.entity.name}\\` of specified item`;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REGISTRATION: {\n\t\t\t\toptions.description = `This method is used for registration of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.AUTHENTICATION: {\n\t\t\t\toptions.description = `This method is used for authentication of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.CONFIRMATION: {\n\t\t\t\toptions.description = `This method is used for confirmation of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.REFRESH: {\n\t\t\t\toptions.description = `This method is used for refresh of \\`${options.entity.name}\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase EApiAction.FETCH_SIMPLE_LIST: {\n\t\t\t\toptions.description = `This method is used for fetching simple list of \\`${options.entity.name}s\\``;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst decorators: Array<MethodDecorator> = [\n\t\tApiOperation({ description: options.description, summary }),\n\t\tApiResponse({\n\t\t\tdescription: \"Success\",\n\t\t\tstatus: options.httpCode,\n\t\t\ttype: options.responseType,\n\t\t}),\n\t\tHttpCode(options.httpCode),\n\t];\n\n\tif (options.throttler) {\n\t\tdecorators.push(Throttle({ default: options.throttler }));\n\t}\n\n\tif (options.responses) {\n\t\tif (options.responses.unauthorized) {\n\t\t\tdecorators.push(\n\t\t\t\tApiUnauthorizedResponse({\n\t\t\t\t\tdescription: \"Unauthorized\",\n\t\t\t\t\tstatus: HttpStatus.UNAUTHORIZED,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.UNAUTHORIZED),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.forbidden) {\n\t\t\tdecorators.push(\n\t\t\t\tApiForbiddenResponse({\n\t\t\t\t\tdescription: \"Forbiddeb\",\n\t\t\t\t\tstatus: HttpStatus.FORBIDDEN,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.FORBIDDEN),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.internalServerError) {\n\t\t\tdecorators.push(\n\t\t\t\tApiInternalServerErrorResponse({\n\t\t\t\t\tdescription: \"Internal Server Error\",\n\t\t\t\t\tstatus: HttpStatus.INTERNAL_SERVER_ERROR,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.INTERNAL_SERVER_ERROR),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.notFound) {\n\t\t\tdecorators.push(\n\t\t\t\tApiNotFoundResponse({\n\t\t\t\t\tdescription: \"Not Found\",\n\t\t\t\t\tstatus: HttpStatus.NOT_FOUND,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.NOT_FOUND),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.badRequest) {\n\t\t\tdecorators.push(\n\t\t\t\tApiBadRequestResponse({\n\t\t\t\t\tdescription: \"Bad Request\",\n\t\t\t\t\tstatus: HttpStatus.BAD_REQUEST,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.BAD_REQUEST),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (options.responses.tooManyRequests) {\n\t\t\tdecorators.push(\n\t\t\t\tApiTooManyRequestsResponse({\n\t\t\t\t\tdescription: \"Too Many Requests\",\n\t\t\t\t\tstatus: HttpStatus.TOO_MANY_REQUESTS,\n\t\t\t\t\ttype: DtoGenerateException(HttpStatus.TOO_MANY_REQUESTS),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tswitch (options.method) {\n\t\tcase RequestMethod.GET: {\n\t\t\tdecorators.push(Get(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.POST: {\n\t\t\tdecorators.push(Post(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.PATCH: {\n\t\t\tdecorators.push(Patch(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.PUT: {\n\t\t\tdecorators.push(Put(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tcase RequestMethod.DELETE: {\n\t\t\tdecorators.push(Delete(options.path));\n\n\t\t\tbreak;\n\t\t}\n\n\t\tdefault: {\n\t\t\tthrow new Error(`ApiMethod error: Method ${options.method} is not supported`);\n\t\t}\n\t}\n\n\tif (options.authentication) {\n\t\tdecorators.push(UseGuards(options.authentication.guard));\n\n\t\tif (options.authentication?.bearerStrategies?.length) {\n\t\t\tfor (const strategy of options.authentication?.bearerStrategies) {\n\t\t\t\tdecorators.push(ApiBearerAuth(strategy));\n\t\t\t}\n\t\t}\n\n\t\tif (options.authentication?.securityStrategies?.length) {\n\t\t\tfor (const strategy of options.authentication.securityStrategies) {\n\t\t\t\tdecorators.push(ApiSecurity(strategy));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn applyDecorators(...decorators);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.decorator.js","sourceRoot":"/","sources":["decorator/api/property/date.decorator.ts"],"names":[],"mappings":";;AAmEA,
|
|
1
|
+
{"version":3,"file":"date.decorator.js","sourceRoot":"/","sources":["decorator/api/property/date.decorator.ts"],"names":[],"mappings":";;AAmEA,0CA0BC;AA7FD,2CAAiD;AAEjD,yDAAyC;AAEzC,gDAAoD;AACpD,wCAA2E;AAE3E,yDAAuD;AAIvD,SAAS,cAAc,CAAC,IAA0B;IACjD,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,2BAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;YACnC,OAAO,eAAe,CAAC;QACxB,CAAC;QAED,KAAK,2BAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;YACnC,OAAO,kBAAkB,CAAC;QAC3B,CAAC;QAED,KAAK,2BAAoB,CAAC,eAAe,CAAC,CAAC,CAAC;YAC3C,OAAO,gBAAgB,CAAC;QACzB,CAAC;QAED,KAAK,2BAAoB,CAAC,aAAa,CAAC,CAAC,CAAC;YACzC,OAAO,cAAc,CAAC;QACvB,CAAC;QAED,KAAK,2BAAoB,CAAC,aAAa,CAAC,CAAC,CAAC;YACzC,OAAO,cAAc,CAAC;QACvB,CAAC;QAED,KAAK,2BAAoB,CAAC,eAAe,CAAC,CAAC,CAAC;YAC3C,OAAO,gBAAgB,CAAC;QACzB,CAAC;QAED,KAAK,2BAAoB,CAAC,UAAU,CAAC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AAQ,EAAE,CAAC,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,QAAQ;QACrD,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,IAAI,EAAE,2BAAoB,CAAC,SAAS;KACpC,CAAC;IACF,MAAM,UAAU,GAA6B,CAAC,IAAA,oCAAiB,EAAC,EAAE,GAAG,wBAAwB,EAAE,CAAC,CAAC,CAAC;IAElG,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;QAC1B,UAAU,CAAC,IAAI,CAAC,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,IAAA,wBAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,eAAe,CAA2B,UAAyC;IAC3F,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,OAAO,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACtE,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAChD,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,0BAAe,CAAC,gBAAgB,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;AACF,CAAC","sourcesContent":["import { applyDecorators } from \"@nestjs/common\";\n\nimport { Type } from \"class-transformer\";\n\nimport { NUMBER_CONSTANT } from \"../../../constant\";\nimport { EApiPropertyDataType, EApiPropertyDateType } from \"../../../enum\";\n\nimport { ApiPropertyString } from \"./string.decorator\";\n\nimport type { IApiBaseEntity, IApiPropertyDateProperties, IApiPropertyStringProperties } from \"../../../interface\";\n\nfunction getDescription(type: EApiPropertyDateType): string {\n\tswitch (type) {\n\t\tcase EApiPropertyDateType.CREATED: {\n\t\t\treturn \"creation date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.UPDATED: {\n\t\t\treturn \"last update date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.CREATED_AT_FROM: {\n\t\t\treturn \"createdAt from\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.CREATED_AT_TO: {\n\t\t\treturn \"createdAt to\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.UPDATED_AT_TO: {\n\t\t\treturn \"updatedAt to\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.UPDATED_AT_FROM: {\n\t\t\treturn \"updatedAt from\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.EXPIRES_IN: {\n\t\t\treturn \"expiration date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.REFRESH_IN: {\n\t\t\treturn \"refresh date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.DATE: {\n\t\t\treturn \"date\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.RECEIVED_AT_FROM: {\n\t\t\treturn \"receivedAt from\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.RECEIVED_AT_TO: {\n\t\t\treturn \"receivedAt to\";\n\t\t}\n\n\t\tcase EApiPropertyDateType.RECEIVED_AT: {\n\t\t\treturn \"receivedAt date\";\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn \"\";\n\t\t}\n\t}\n}\n\nexport function ApiPropertyDate<T extends IApiBaseEntity>(properties: IApiPropertyDateProperties<T>): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void {\n\tvalidateOptions<T>(properties);\n\n\tconst startOfYearUTCDate: string = new Date(Date.UTC(new Date().getUTCFullYear(), 0, 1, 0, 0, 0, 0)).toISOString();\n\n\tconst apiPropertyStringOptions: IApiPropertyStringProperties<T> = {\n\t\tdescription: getDescription(properties.type),\n\t\tentity: properties.entity,\n\t\texample: startOfYearUTCDate,\n\t\texpose: properties.expose,\n\t\tformat: EApiPropertyDataType.DATE_TIME,\n\t\tmaxLength: startOfYearUTCDate.length,\n\t\tminLength: startOfYearUTCDate.length,\n\t\tnullable: properties.nullable,\n\t\tpattern: \"/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z$/\",\n\t\trequired: !properties.response && properties.required,\n\t\tresponse: properties.response,\n\t\ttype: EApiPropertyDataType.DATE_TIME,\n\t};\n\tconst decorators: Array<PropertyDecorator> = [ApiPropertyString({ ...apiPropertyStringOptions })];\n\n\tif (!properties.response) {\n\t\tdecorators.push(Type(() => Date));\n\t}\n\n\treturn applyDecorators(...decorators);\n}\n\nfunction validateOptions<T extends IApiBaseEntity>(properties: IApiPropertyDateProperties<T>): void {\n\tconst errors: Array<string> = [];\n\n\tif (!properties.response && typeof properties.required !== \"boolean\") {\n\t\terrors.push(\"Required is not defined\");\n\t}\n\n\tif (properties.response && properties.required) {\n\t\terrors.push(\"Required is defined for response\");\n\t}\n\n\tif (errors.length > NUMBER_CONSTANT.ZERO_LIST_LENGTH) {\n\t\tthrow new Error(`ApiPropertyDate error: ${errors.join(\"\\n\")}`);\n\t}\n}\n"]}
|
|
@@ -6,7 +6,7 @@ const constant_1 = require("../../../constant");
|
|
|
6
6
|
function ApiPropertyDescribe(properties) {
|
|
7
7
|
return (target, propertyKey) => {
|
|
8
8
|
const entityName = target.constructor.name;
|
|
9
|
-
class_1.MetadataStorage.getInstance().setMetadata(entityName, propertyKey, constant_1.
|
|
9
|
+
class_1.MetadataStorage.getInstance().setMetadata(entityName, propertyKey, constant_1.PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT.METADATA_PROPERTY_NAME, properties);
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=describe.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.decorator.js","sourceRoot":"/","sources":["decorator/api/property/describe.decorator.ts"],"names":[],"mappings":";;AAKA,kDAKC;AAVD,0CAAiD;AACjD,gDAA6E;AAI7E,SAAgB,mBAAmB,CAAC,UAA0C;IAC7E,OAAO,CAAC,MAAwB,EAAE,WAAmB,EAAQ,EAAE;QAC9D,MAAM,UAAU,GAAW,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QACnD,uBAAe,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,mDAAwC,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;IACjJ,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { MetadataStorage } from \"../../../class\";\nimport {
|
|
1
|
+
{"version":3,"file":"describe.decorator.js","sourceRoot":"/","sources":["decorator/api/property/describe.decorator.ts"],"names":[],"mappings":";;AAKA,kDAKC;AAVD,0CAAiD;AACjD,gDAA6E;AAI7E,SAAgB,mBAAmB,CAAC,UAA0C;IAC7E,OAAO,CAAC,MAAwB,EAAE,WAAmB,EAAQ,EAAE;QAC9D,MAAM,UAAU,GAAW,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QACnD,uBAAe,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,mDAAwC,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;IACjJ,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { MetadataStorage } from \"../../../class\";\nimport { PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT } from \"../../../constant\";\n\nimport type { TApiPropertyDescribeProperties } from \"../../../type\";\n\nexport function ApiPropertyDescribe(properties: TApiPropertyDescribeProperties) {\n\treturn (target: Record<any, any>, propertyKey: string): void => {\n\t\tconst entityName: string = target.constructor.name;\n\t\tMetadataStorage.getInstance().setMetadata(entityName, propertyKey, PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT.METADATA_PROPERTY_NAME, properties);\n\t};\n}\n"]}
|
|
@@ -15,6 +15,9 @@ function ApiPropertyString(properties) {
|
|
|
15
15
|
validateOptions(properties);
|
|
16
16
|
const apiPropertyOptions = buildApiPropertyOptions(properties);
|
|
17
17
|
const decorators = buildDecorators(properties, apiPropertyOptions);
|
|
18
|
+
if (properties.description === "message amount pattern") {
|
|
19
|
+
console.log("PODSOS", apiPropertyOptions);
|
|
20
|
+
}
|
|
18
21
|
return (0, common_1.applyDecorators)(...decorators);
|
|
19
22
|
}
|
|
20
23
|
function buildOptionsFromEnum(properties) {
|
|
@@ -44,8 +47,8 @@ function validateOptions(properties) {
|
|
|
44
47
|
if ((!properties.response && (!properties.example || !properties.pattern)) || (properties.example && properties.pattern)) {
|
|
45
48
|
const matches = properties.pattern.match(/^\/(.*?)\/([gimuy]*)$/);
|
|
46
49
|
if (matches) {
|
|
47
|
-
const pattern = matches[constant_1.
|
|
48
|
-
const flags = matches[constant_1.
|
|
50
|
+
const pattern = matches[constant_1.STRING_PROPERTY_API_INTERFACE_CONSTANT.REGEX_PATTERN_INDEX];
|
|
51
|
+
const flags = matches[constant_1.STRING_PROPERTY_API_INTERFACE_CONSTANT.REGEX_FLAGS_INDEX];
|
|
49
52
|
const regex = new RegExp(pattern, flags);
|
|
50
53
|
if (Array.isArray(properties.example)) {
|
|
51
54
|
for (const example of properties.example) {
|
|
@@ -119,6 +122,7 @@ function buildApiPropertyOptions(properties) {
|
|
|
119
122
|
const apiPropertyOptions = {
|
|
120
123
|
description: `${properties.entity.name} ${properties.description || ""}`,
|
|
121
124
|
example: properties.example,
|
|
125
|
+
expose: properties.expose,
|
|
122
126
|
format: properties.format,
|
|
123
127
|
maxLength: properties.maxLength,
|
|
124
128
|
minLength: properties.minLength,
|
|
@@ -147,10 +151,13 @@ function buildApiPropertyOptions(properties) {
|
|
|
147
151
|
function buildDecorators(properties, apiPropertyOptions) {
|
|
148
152
|
const decorators = [(0, swagger_1.ApiProperty)(apiPropertyOptions)];
|
|
149
153
|
if (properties.response) {
|
|
150
|
-
decorators.push(swagger_1.ApiResponseProperty);
|
|
151
|
-
if (properties.expose) {
|
|
154
|
+
decorators.push((0, swagger_1.ApiResponseProperty)());
|
|
155
|
+
if (properties.expose === undefined || properties.expose) {
|
|
152
156
|
decorators.push((0, class_transformer_1.Expose)());
|
|
153
157
|
}
|
|
158
|
+
else {
|
|
159
|
+
decorators.push((0, class_transformer_1.Exclude)());
|
|
160
|
+
}
|
|
154
161
|
}
|
|
155
162
|
else if (properties.isArray) {
|
|
156
163
|
if (!properties.required) {
|
|
@@ -204,7 +211,7 @@ function buildDecorators(properties, apiPropertyOptions) {
|
|
|
204
211
|
break;
|
|
205
212
|
}
|
|
206
213
|
case enum_1.EApiPropertyDataType.IP: {
|
|
207
|
-
decorators.push((0, class_validator_1.IsIP)(constant_1.
|
|
214
|
+
decorators.push((0, class_validator_1.IsIP)(constant_1.STRING_PROPERTY_API_INTERFACE_CONSTANT.IP_VERSION, { each: true }));
|
|
208
215
|
break;
|
|
209
216
|
}
|
|
210
217
|
default: {
|
|
@@ -257,7 +264,7 @@ function buildDecorators(properties, apiPropertyOptions) {
|
|
|
257
264
|
break;
|
|
258
265
|
}
|
|
259
266
|
case enum_1.EApiPropertyDataType.IP: {
|
|
260
|
-
decorators.push((0, class_validator_1.IsIP)(constant_1.
|
|
267
|
+
decorators.push((0, class_validator_1.IsIP)(constant_1.STRING_PROPERTY_API_INTERFACE_CONSTANT.IP_VERSION));
|
|
261
268
|
break;
|
|
262
269
|
}
|
|
263
270
|
case enum_1.EApiPropertyDataType.DATE_TIME:
|