@forklaunch/core 0.2.3 → 0.2.6
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/LICENSE +21 -0
- package/lib/dist/cache/index.d.ts +4 -0
- package/lib/dist/cache/index.d.ts.map +1 -0
- package/lib/dist/cache/interfaces/ttlCache.interface.d.ts +2 -0
- package/lib/dist/cache/interfaces/ttlCache.interface.d.ts.map +1 -0
- package/lib/dist/cache/redisTtlCache.d.ts +353 -0
- package/lib/dist/cache/redisTtlCache.d.ts.map +1 -0
- package/{dist → lib/dist}/cache/redisTtlCache.js +1 -4
- package/lib/dist/cache/types/ttlCacheRecord.types.d.ts +2 -0
- package/lib/dist/cache/types/ttlCacheRecord.types.d.ts.map +1 -0
- package/lib/dist/controllers/index.d.ts +2 -0
- package/lib/dist/controllers/index.d.ts.map +1 -0
- package/lib/dist/controllers/interfaces/controller.interface.d.ts +2 -0
- package/lib/dist/controllers/interfaces/controller.interface.d.ts.map +1 -0
- package/lib/dist/database/index.d.ts +2 -0
- package/lib/dist/database/index.d.ts.map +1 -0
- package/lib/dist/database/mikro/models/entities/base.entity.d.ts +26 -0
- package/lib/dist/database/mikro/models/entities/base.entity.d.ts.map +1 -0
- package/lib/dist/database/mikro/models/entities/base.entity.js +46 -0
- package/lib/dist/entityMapper/index.d.ts +3 -0
- package/lib/dist/entityMapper/index.d.ts.map +1 -0
- package/lib/dist/entityMapper/interfaces/entityMapper.interface.d.ts +2 -0
- package/lib/dist/entityMapper/interfaces/entityMapper.interface.d.ts.map +1 -0
- package/lib/dist/entityMapper/models/baseEntityMapper.model.d.ts +63 -0
- package/lib/dist/entityMapper/models/baseEntityMapper.model.d.ts.map +1 -0
- package/lib/dist/entityMapper/models/requestEntityMapper.model.d.ts +58 -0
- package/lib/dist/entityMapper/models/requestEntityMapper.model.d.ts.map +1 -0
- package/lib/dist/entityMapper/models/responseEntityMapper.model.d.ts +56 -0
- package/lib/dist/entityMapper/models/responseEntityMapper.model.d.ts.map +1 -0
- package/lib/dist/entityMapper/types/entityMapper.types.d.ts +2 -0
- package/lib/dist/entityMapper/types/entityMapper.types.d.ts.map +1 -0
- package/lib/dist/http/guards/isHttpContractDetails.d.ts +5 -0
- package/lib/dist/http/guards/isHttpContractDetails.d.ts.map +1 -0
- package/lib/dist/http/guards/isHttpContractDetails.js +6 -0
- package/lib/dist/http/guards/isResponseShape.d.ts +2 -0
- package/lib/dist/http/guards/isResponseShape.d.ts.map +1 -0
- package/lib/dist/http/guards/isResponseShape.js +7 -0
- package/lib/dist/http/index.d.ts +6 -0
- package/lib/dist/http/index.d.ts.map +1 -0
- package/{dist → lib/dist}/http/index.js +1 -2
- package/lib/dist/http/interfaces/expressLikeApplication.interface.d.ts +12 -0
- package/lib/dist/http/interfaces/expressLikeApplication.interface.d.ts.map +1 -0
- package/lib/dist/http/interfaces/expressLikeRouter.interface.d.ts +103 -0
- package/lib/dist/http/interfaces/expressLikeRouter.interface.d.ts.map +1 -0
- package/lib/dist/http/interfaces/expressLikeRouter.interface.js +336 -0
- package/lib/dist/http/interfaces/index.d.ts +3 -0
- package/lib/dist/http/interfaces/index.d.ts.map +1 -0
- package/lib/dist/http/interfaces/index.js +2 -0
- package/lib/dist/http/middleware/index.d.ts +3 -0
- package/lib/dist/http/middleware/index.d.ts.map +1 -0
- package/lib/dist/http/middleware/request.middleware.d.ts +69 -0
- package/lib/dist/http/middleware/request.middleware.d.ts.map +1 -0
- package/{dist → lib/dist}/http/middleware/request.middleware.js +55 -117
- package/lib/dist/http/middleware/response.middleware.d.ts +27 -0
- package/lib/dist/http/middleware/response.middleware.d.ts.map +1 -0
- package/lib/dist/http/middleware/response.middleware.js +52 -0
- package/lib/dist/http/openApiV3Generator/index.d.ts +2 -0
- package/lib/dist/http/openApiV3Generator/index.d.ts.map +1 -0
- package/lib/dist/http/openApiV3Generator/index.js +1 -0
- package/lib/dist/http/openApiV3Generator/openApiV3Generator.d.ts +11 -0
- package/lib/dist/http/openApiV3Generator/openApiV3Generator.d.ts.map +1 -0
- package/{dist/http → lib/dist/http/openApiV3Generator}/openApiV3Generator.js +2 -24
- package/lib/dist/http/types/apiDefinition.types.d.ts +2 -0
- package/lib/dist/http/types/apiDefinition.types.d.ts.map +1 -0
- package/lib/dist/http/types/contractDetails.types.d.ts +2 -0
- package/lib/dist/http/types/contractDetails.types.d.ts.map +1 -0
- package/lib/dist/http/types/index.d.ts +4 -0
- package/lib/dist/http/types/index.d.ts.map +1 -0
- package/lib/dist/http/types/index.js +3 -0
- package/lib/dist/http/types/router.types.d.ts +2 -0
- package/lib/dist/http/types/router.types.d.ts.map +1 -0
- package/lib/dist/http/utils/enrichExpressLikeSend.d.ts +28 -0
- package/lib/dist/http/utils/enrichExpressLikeSend.d.ts.map +1 -0
- package/lib/dist/http/utils/enrichExpressLikeSend.js +50 -0
- package/lib/dist/http/utils/httpStatusCodes.d.ts +986 -0
- package/lib/dist/http/utils/httpStatusCodes.d.ts.map +1 -0
- package/lib/dist/http/utils/index.d.ts +3 -0
- package/lib/dist/http/utils/index.d.ts.map +1 -0
- package/lib/dist/http/utils/index.js +2 -0
- package/lib/dist/index.d.ts +7 -0
- package/lib/dist/index.d.ts.map +1 -0
- package/lib/dist/jest.config.d.ts +15 -0
- package/lib/dist/jest.config.d.ts.map +1 -0
- package/lib/dist/jest.config.js +21 -0
- package/lib/dist/lib/index.d.ts +7 -0
- package/lib/dist/lib/index.d.ts.map +1 -0
- package/lib/dist/lib/index.js +6 -0
- package/lib/dist/lib/jest.config.d.ts +15 -0
- package/lib/dist/lib/jest.config.d.ts.map +1 -0
- package/lib/dist/lib/jest.config.js +21 -0
- package/lib/dist/lib/src/cache/index.d.ts +4 -0
- package/lib/dist/lib/src/cache/index.d.ts.map +1 -0
- package/lib/dist/lib/src/cache/index.js +3 -0
- package/lib/dist/lib/src/cache/interfaces/ttlCache.interface.d.ts +2 -0
- package/lib/dist/lib/src/cache/interfaces/ttlCache.interface.d.ts.map +1 -0
- package/lib/dist/lib/src/cache/redisTtlCache.d.ts +353 -0
- package/lib/dist/lib/src/cache/redisTtlCache.d.ts.map +1 -0
- package/lib/dist/lib/src/cache/redisTtlCache.js +98 -0
- package/lib/dist/lib/src/cache/types/ttlCacheRecord.types.d.ts +2 -0
- package/lib/dist/lib/src/cache/types/ttlCacheRecord.types.d.ts.map +1 -0
- package/lib/dist/lib/src/cache/types/ttlCacheRecord.types.js +1 -0
- package/lib/dist/lib/src/controllers/index.d.ts +2 -0
- package/lib/dist/lib/src/controllers/index.d.ts.map +1 -0
- package/lib/dist/lib/src/controllers/index.js +1 -0
- package/lib/dist/lib/src/controllers/interfaces/controller.interface.d.ts +2 -0
- package/lib/dist/lib/src/controllers/interfaces/controller.interface.d.ts.map +1 -0
- package/lib/dist/lib/src/controllers/interfaces/controller.interface.js +1 -0
- package/lib/dist/lib/src/database/index.d.ts +2 -0
- package/lib/dist/lib/src/database/index.d.ts.map +1 -0
- package/lib/dist/lib/src/database/index.js +1 -0
- package/lib/dist/lib/src/database/mikro/models/entities/base.entity.d.ts +26 -0
- package/lib/dist/lib/src/database/mikro/models/entities/base.entity.d.ts.map +1 -0
- package/lib/dist/lib/src/database/mikro/models/entities/base.entity.js +46 -0
- package/lib/dist/lib/src/domainMapper/index.d.ts +3 -0
- package/lib/dist/lib/src/domainMapper/index.d.ts.map +1 -0
- package/lib/dist/lib/src/domainMapper/index.js +2 -0
- package/lib/dist/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts +2 -0
- package/lib/dist/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts.map +1 -0
- package/lib/dist/lib/src/domainMapper/interfaces/dtoMapper.interface.js +1 -0
- package/lib/dist/lib/src/domainMapper/models/baseDtoMapper.model.d.ts +63 -0
- package/lib/dist/lib/src/domainMapper/models/baseDtoMapper.model.d.ts.map +1 -0
- package/lib/dist/lib/src/domainMapper/models/baseDtoMapper.model.js +75 -0
- package/lib/dist/lib/src/domainMapper/models/requestDtoMapper.model.d.ts +58 -0
- package/lib/dist/lib/src/domainMapper/models/requestDtoMapper.model.d.ts.map +1 -0
- package/lib/dist/lib/src/domainMapper/models/requestDtoMapper.model.js +70 -0
- package/lib/dist/lib/src/domainMapper/models/responseDtoMapper.model.d.ts +56 -0
- package/lib/dist/lib/src/domainMapper/models/responseDtoMapper.model.d.ts.map +1 -0
- package/lib/dist/lib/src/domainMapper/models/responseDtoMapper.model.js +65 -0
- package/lib/dist/lib/src/domainMapper/types/dtoMapper.types.d.ts +2 -0
- package/lib/dist/lib/src/domainMapper/types/dtoMapper.types.d.ts.map +1 -0
- package/lib/dist/lib/src/domainMapper/types/dtoMapper.types.js +1 -0
- package/lib/dist/lib/src/dtoMapper/index.d.ts +3 -0
- package/lib/dist/lib/src/dtoMapper/index.d.ts.map +1 -0
- package/lib/dist/lib/src/dtoMapper/index.js +2 -0
- package/lib/dist/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts +2 -0
- package/lib/dist/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts.map +1 -0
- package/lib/dist/lib/src/dtoMapper/interfaces/dtoMapper.interface.js +1 -0
- package/lib/dist/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts +63 -0
- package/lib/dist/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts.map +1 -0
- package/lib/dist/lib/src/dtoMapper/models/baseDtoMapper.model.js +75 -0
- package/lib/dist/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts +58 -0
- package/lib/dist/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts.map +1 -0
- package/lib/dist/lib/src/dtoMapper/models/requestDtoMapper.model.js +70 -0
- package/lib/dist/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts +56 -0
- package/lib/dist/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts.map +1 -0
- package/lib/dist/lib/src/dtoMapper/models/responseDtoMapper.model.js +65 -0
- package/lib/dist/lib/src/dtoMapper/types/dtoMapper.types.d.ts +2 -0
- package/lib/dist/lib/src/dtoMapper/types/dtoMapper.types.d.ts.map +1 -0
- package/lib/dist/lib/src/dtoMapper/types/dtoMapper.types.js +1 -0
- package/lib/dist/lib/src/http/application/expressLikeApplication.d.ts +18 -0
- package/lib/dist/lib/src/http/application/expressLikeApplication.d.ts.map +1 -0
- package/lib/dist/lib/src/http/application/expressLikeApplication.js +20 -0
- package/lib/dist/lib/src/http/guards/isHttpContractDetails.d.ts +5 -0
- package/lib/dist/lib/src/http/guards/isHttpContractDetails.d.ts.map +1 -0
- package/lib/dist/lib/src/http/guards/isHttpContractDetails.js +6 -0
- package/lib/dist/lib/src/http/guards/isResponseShape.d.ts +2 -0
- package/lib/dist/lib/src/http/guards/isResponseShape.d.ts.map +1 -0
- package/lib/dist/lib/src/http/guards/isResponseShape.js +7 -0
- package/lib/dist/lib/src/http/handler/typedHandler.d.ts +21 -0
- package/lib/dist/lib/src/http/handler/typedHandler.d.ts.map +1 -0
- package/lib/dist/lib/src/http/handler/typedHandler.js +25 -0
- package/lib/dist/lib/src/http/index.d.ts +11 -0
- package/lib/dist/lib/src/http/index.d.ts.map +1 -0
- package/lib/dist/lib/src/http/index.js +10 -0
- package/lib/dist/lib/src/http/interfaces/expressLikeApplication.interface.d.ts +12 -0
- package/lib/dist/lib/src/http/interfaces/expressLikeApplication.interface.d.ts.map +1 -0
- package/lib/dist/lib/src/http/interfaces/expressLikeApplication.interface.js +14 -0
- package/lib/dist/lib/src/http/interfaces/expressLikeRouter.interface.d.ts +2 -0
- package/lib/dist/lib/src/http/interfaces/expressLikeRouter.interface.d.ts.map +1 -0
- package/lib/dist/lib/src/http/interfaces/expressLikeRouter.interface.js +1 -0
- package/lib/dist/lib/src/http/interfaces/index.d.ts +3 -0
- package/lib/dist/lib/src/http/interfaces/index.d.ts.map +1 -0
- package/lib/dist/lib/src/http/interfaces/index.js +2 -0
- package/lib/dist/lib/src/http/middleware/index.d.ts +3 -0
- package/lib/dist/lib/src/http/middleware/index.d.ts.map +1 -0
- package/lib/dist/lib/src/http/middleware/index.js +2 -0
- package/lib/dist/lib/src/http/middleware/request/auth.middleware.d.ts +27 -0
- package/lib/dist/lib/src/http/middleware/request/auth.middleware.d.ts.map +1 -0
- package/lib/dist/lib/src/http/middleware/request/auth.middleware.js +107 -0
- package/lib/dist/lib/src/http/middleware/request/cors.middleware.d.ts +9 -0
- package/lib/dist/lib/src/http/middleware/request/cors.middleware.d.ts.map +1 -0
- package/lib/dist/lib/src/http/middleware/request/cors.middleware.js +15 -0
- package/lib/dist/lib/src/http/middleware/request/createContext.middleware.d.ts +12 -0
- package/lib/dist/lib/src/http/middleware/request/createContext.middleware.d.ts.map +1 -0
- package/lib/dist/lib/src/http/middleware/request/createContext.middleware.js +26 -0
- package/lib/dist/lib/src/http/middleware/request/enrichDetails.middleware.d.ts +12 -0
- package/lib/dist/lib/src/http/middleware/request/enrichDetails.middleware.d.ts.map +1 -0
- package/lib/dist/lib/src/http/middleware/request/enrichDetails.middleware.js +19 -0
- package/lib/dist/lib/src/http/middleware/request/parse.middleware.d.ts +13 -0
- package/lib/dist/lib/src/http/middleware/request/parse.middleware.d.ts.map +1 -0
- package/lib/dist/lib/src/http/middleware/request/parse.middleware.js +43 -0
- package/lib/dist/lib/src/http/middleware/request.middleware.d.ts +69 -0
- package/lib/dist/lib/src/http/middleware/request.middleware.d.ts.map +1 -0
- package/lib/dist/lib/src/http/middleware/request.middleware.js +210 -0
- package/lib/dist/lib/src/http/middleware/response/parse.middleware.d.ts +27 -0
- package/lib/dist/lib/src/http/middleware/response/parse.middleware.d.ts.map +1 -0
- package/lib/dist/lib/src/http/middleware/response/parse.middleware.js +52 -0
- package/lib/dist/lib/src/http/middleware/response.middleware.d.ts +27 -0
- package/lib/dist/lib/src/http/middleware/response.middleware.d.ts.map +1 -0
- package/lib/dist/lib/src/http/middleware/response.middleware.js +52 -0
- package/lib/dist/lib/src/http/openApiV3Generator/index.d.ts +2 -0
- package/lib/dist/lib/src/http/openApiV3Generator/index.d.ts.map +1 -0
- package/lib/dist/lib/src/http/openApiV3Generator/index.js +1 -0
- package/lib/dist/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts +11 -0
- package/lib/dist/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts.map +1 -0
- package/lib/dist/lib/src/http/openApiV3Generator/openApiV3Generator.js +167 -0
- package/lib/dist/lib/src/http/router/expressLikeRouter.d.ts +89 -0
- package/lib/dist/lib/src/http/router/expressLikeRouter.d.ts.map +1 -0
- package/{dist/http/interfaces/forklaunchExpress.router.interface.js → lib/dist/lib/src/http/router/expressLikeRouter.js} +85 -91
- package/lib/dist/lib/src/http/types/apiDefinition.types.d.ts +2 -0
- package/lib/dist/lib/src/http/types/apiDefinition.types.d.ts.map +1 -0
- package/lib/dist/lib/src/http/types/apiDefinition.types.js +1 -0
- package/lib/dist/lib/src/http/types/contractDetails.types.d.ts +2 -0
- package/lib/dist/lib/src/http/types/contractDetails.types.d.ts.map +1 -0
- package/lib/dist/lib/src/http/types/contractDetails.types.js +1 -0
- package/lib/dist/lib/src/http/types/index.d.ts +4 -0
- package/lib/dist/lib/src/http/types/index.d.ts.map +1 -0
- package/lib/dist/lib/src/http/types/index.js +3 -0
- package/lib/dist/lib/src/http/types/router.types.d.ts +2 -0
- package/lib/dist/lib/src/http/types/router.types.d.ts.map +1 -0
- package/lib/dist/lib/src/http/types/router.types.js +1 -0
- package/lib/dist/lib/src/http/utils/enrichExpressLikeSend.d.ts +28 -0
- package/lib/dist/lib/src/http/utils/enrichExpressLikeSend.d.ts.map +1 -0
- package/lib/dist/lib/src/http/utils/enrichExpressLikeSend.js +50 -0
- package/lib/dist/lib/src/http/utils/httpStatusCodes.d.ts +986 -0
- package/lib/dist/lib/src/http/utils/httpStatusCodes.d.ts.map +1 -0
- package/lib/dist/lib/src/http/utils/httpStatusCodes.js +1039 -0
- package/lib/dist/lib/src/http/utils/index.d.ts +3 -0
- package/lib/dist/lib/src/http/utils/index.d.ts.map +1 -0
- package/lib/dist/lib/src/http/utils/index.js +2 -0
- package/lib/dist/lib/src/services/index.d.ts +2 -0
- package/lib/dist/lib/src/services/index.d.ts.map +1 -0
- package/lib/dist/lib/src/services/interfaces/baseService.d.ts +2 -0
- package/lib/dist/lib/src/services/interfaces/baseService.d.ts.map +1 -0
- package/lib/dist/lib/src/services/interfaces/baseService.js +1 -0
- package/lib/dist/lib/tests/dtoMapper.test.d.ts +2 -0
- package/lib/dist/lib/tests/dtoMapper.test.d.ts.map +1 -0
- package/lib/dist/lib/tests/dtoMapper.test.js +172 -0
- package/lib/dist/lib/tests/entityMapper.test.d.ts.map +1 -0
- package/lib/dist/lib/tests/entityMapper.test.js +172 -0
- package/lib/dist/lib/tests/expressLikeRouter.test.d.ts +2 -0
- package/lib/dist/lib/tests/expressLikeRouter.test.d.ts.map +1 -0
- package/lib/dist/lib/tests/expressLikeRouter.test.js +3 -0
- package/lib/dist/lib/tests/http.middleware.test.d.ts.map +1 -0
- package/lib/dist/lib/tests/http.middleware.test.js +95 -0
- package/lib/dist/lib/tests/openApiV3Generator.test.d.ts.map +1 -0
- package/lib/dist/lib/tests/openApiV3Generator.test.js +66 -0
- package/lib/dist/lib/tests/redisTtlCache.test.d.ts.map +1 -0
- package/lib/dist/lib/tests/redisTtlCache.test.js +49 -0
- package/lib/dist/lib/tests/typedHandler.test.d.ts +2 -0
- package/lib/dist/lib/tests/typedHandler.test.d.ts.map +1 -0
- package/lib/dist/lib/tests/typedHandler.test.js +3 -0
- package/lib/dist/lib/vitest.config.d.ts +3 -0
- package/lib/dist/lib/vitest.config.d.ts.map +1 -0
- package/lib/dist/lib/vitest.config.js +7 -0
- package/lib/dist/services/index.d.ts +2 -0
- package/lib/dist/services/index.d.ts.map +1 -0
- package/lib/dist/services/index.js +1 -0
- package/lib/dist/services/interfaces/baseService.d.ts +2 -0
- package/lib/dist/services/interfaces/baseService.d.ts.map +1 -0
- package/lib/dist/services/interfaces/baseService.js +1 -0
- package/lib/dist/tests/entityMapper.test.d.ts +2 -0
- package/lib/dist/tests/entityMapper.test.d.ts.map +1 -0
- package/{dist → lib/dist}/tests/entityMapper.test.js +6 -2
- package/lib/dist/tests/http.middleware.test.d.ts +2 -0
- package/lib/dist/tests/http.middleware.test.d.ts.map +1 -0
- package/{dist → lib/dist}/tests/http.middleware.test.js +39 -21
- package/lib/dist/tests/openApiV3Generator.test.d.ts +2 -0
- package/lib/dist/tests/openApiV3Generator.test.d.ts.map +1 -0
- package/{dist → lib/dist}/tests/openApiV3Generator.test.js +1 -1
- package/lib/dist/tests/redisTtlCache.test.d.ts +2 -0
- package/lib/dist/tests/redisTtlCache.test.d.ts.map +1 -0
- package/lib/eslint.config.mjs +10 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -0
- package/lib/jest.config.d.ts +4 -0
- package/lib/jest.config.d.ts.map +1 -0
- package/lib/jest.config.js +21 -0
- package/lib/src/cache/index.d.ts.map +1 -0
- package/lib/src/cache/index.js +3 -0
- package/lib/src/cache/interfaces/ttlCache.interface.d.ts.map +1 -0
- package/lib/src/cache/interfaces/ttlCache.interface.js +1 -0
- package/lib/src/cache/redisTtlCache.d.ts.map +1 -0
- package/lib/src/cache/redisTtlCache.js +98 -0
- package/lib/src/cache/types/ttlCacheRecord.types.d.ts.map +1 -0
- package/lib/src/cache/types/ttlCacheRecord.types.js +1 -0
- package/lib/src/controllers/index.d.ts.map +1 -0
- package/lib/src/controllers/index.js +1 -0
- package/lib/src/controllers/interfaces/controller.interface.d.ts.map +1 -0
- package/lib/src/controllers/interfaces/controller.interface.js +1 -0
- package/lib/src/database/index.d.ts.map +1 -0
- package/lib/src/database/index.js +1 -0
- package/lib/src/database/mikro/models/entities/base.entity.d.ts.map +1 -0
- package/lib/src/domainMapper/index.d.ts +3 -0
- package/lib/src/domainMapper/index.d.ts.map +1 -0
- package/lib/src/domainMapper/index.js +2 -0
- package/{dist/entityMapper/interfaces/entityMapper.interface.d.ts → lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts} +3 -3
- package/lib/src/domainMapper/interfaces/dtoMapper.interface.d.ts.map +1 -0
- package/lib/src/domainMapper/interfaces/dtoMapper.interface.js +1 -0
- package/{dist/entityMapper/models/baseEntityMapper.model.d.ts → lib/src/domainMapper/models/baseDtoMapper.model.d.ts} +13 -13
- package/lib/src/domainMapper/models/baseDtoMapper.model.d.ts.map +1 -0
- package/lib/src/domainMapper/models/baseDtoMapper.model.js +75 -0
- package/{dist/entityMapper/models/requestEntityMapper.model.d.ts → lib/src/domainMapper/models/requestDtoMapper.model.d.ts} +13 -13
- package/lib/src/domainMapper/models/requestDtoMapper.model.d.ts.map +1 -0
- package/lib/src/domainMapper/models/requestDtoMapper.model.js +70 -0
- package/{dist/entityMapper/models/responseEntityMapper.model.d.ts → lib/src/domainMapper/models/responseDtoMapper.model.d.ts} +12 -12
- package/lib/src/domainMapper/models/responseDtoMapper.model.d.ts.map +1 -0
- package/lib/src/domainMapper/models/responseDtoMapper.model.js +65 -0
- package/lib/src/domainMapper/types/dtoMapper.types.d.ts +9 -0
- package/lib/src/domainMapper/types/dtoMapper.types.d.ts.map +1 -0
- package/lib/src/domainMapper/types/dtoMapper.types.js +1 -0
- package/lib/src/dtoMapper/index.d.ts +3 -0
- package/lib/src/dtoMapper/index.d.ts.map +1 -0
- package/lib/src/dtoMapper/index.js +2 -0
- package/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts +18 -0
- package/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts.map +1 -0
- package/lib/src/dtoMapper/interfaces/dtoMapper.interface.js +1 -0
- package/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts +72 -0
- package/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts.map +1 -0
- package/lib/src/dtoMapper/models/baseDtoMapper.model.js +75 -0
- package/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts +68 -0
- package/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts.map +1 -0
- package/lib/src/dtoMapper/models/requestDtoMapper.model.js +70 -0
- package/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts +67 -0
- package/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts.map +1 -0
- package/lib/src/dtoMapper/models/responseDtoMapper.model.js +65 -0
- package/lib/src/dtoMapper/types/dtoMapper.types.d.ts +9 -0
- package/lib/src/dtoMapper/types/dtoMapper.types.d.ts.map +1 -0
- package/lib/src/dtoMapper/types/dtoMapper.types.js +1 -0
- package/lib/src/http/application/expressLikeApplication.d.ts +22 -0
- package/lib/src/http/application/expressLikeApplication.d.ts.map +1 -0
- package/lib/src/http/application/expressLikeApplication.js +20 -0
- package/lib/src/http/guards/isExpressLikeSchemaHandler.d.ts +5 -0
- package/lib/src/http/guards/isExpressLikeSchemaHandler.d.ts.map +1 -0
- package/lib/src/http/guards/isExpressLikeSchemaHandler.js +9 -0
- package/lib/src/http/guards/isHttpContractDetails.d.ts +7 -0
- package/lib/src/http/guards/isHttpContractDetails.d.ts.map +1 -0
- package/lib/src/http/guards/isHttpContractDetails.js +9 -0
- package/lib/src/http/guards/isPathParamContractDetails.d.ts +4 -0
- package/lib/src/http/guards/isPathParamContractDetails.d.ts.map +1 -0
- package/lib/src/http/guards/isPathParamContractDetails.js +10 -0
- package/lib/src/http/guards/isResponseShape.d.ts +3 -0
- package/lib/src/http/guards/isResponseShape.d.ts.map +1 -0
- package/lib/src/http/guards/isResponseShape.js +7 -0
- package/lib/src/http/guards/isTypedHandler.d.ts +5 -0
- package/lib/src/http/guards/isTypedHandler.d.ts.map +1 -0
- package/lib/src/http/guards/isTypedHandler.js +6 -0
- package/lib/src/http/handler/typedHandler.d.ts +24 -0
- package/lib/src/http/handler/typedHandler.d.ts.map +1 -0
- package/lib/src/http/handler/typedHandler.js +25 -0
- package/lib/src/http/handlers/typedHandler.d.ts +27 -0
- package/lib/src/http/handlers/typedHandler.d.ts.map +1 -0
- package/lib/src/http/handlers/typedHandler.js +30 -0
- package/lib/src/http/index.d.ts +12 -0
- package/lib/src/http/index.d.ts.map +1 -0
- package/lib/src/http/index.js +11 -0
- package/{dist/http/interfaces/forklaunchExpress.application.interface.d.ts → lib/src/http/interfaces/expressLikeApplication.interface.d.ts} +1 -1
- package/lib/src/http/interfaces/expressLikeApplication.interface.d.ts.map +1 -0
- package/lib/src/http/interfaces/expressLikeApplication.interface.js +14 -0
- package/lib/src/http/interfaces/expressLikeRouter.interface.d.ts +24 -0
- package/lib/src/http/interfaces/expressLikeRouter.interface.d.ts.map +1 -0
- package/lib/src/http/interfaces/expressLikeRouter.interface.js +1 -0
- package/lib/src/http/interfaces/index.d.ts +3 -0
- package/lib/src/http/interfaces/index.d.ts.map +1 -0
- package/lib/src/http/interfaces/index.js +2 -0
- package/lib/src/http/middleware/index.d.ts.map +1 -0
- package/lib/src/http/middleware/index.js +2 -0
- package/lib/src/http/middleware/request/auth.middleware.d.ts +31 -0
- package/lib/src/http/middleware/request/auth.middleware.d.ts.map +1 -0
- package/lib/src/http/middleware/request/auth.middleware.js +107 -0
- package/lib/src/http/middleware/request/cors.middleware.d.ts +13 -0
- package/lib/src/http/middleware/request/cors.middleware.d.ts.map +1 -0
- package/lib/src/http/middleware/request/cors.middleware.js +15 -0
- package/lib/src/http/middleware/request/createContext.middleware.d.ts +15 -0
- package/lib/src/http/middleware/request/createContext.middleware.d.ts.map +1 -0
- package/lib/src/http/middleware/request/createContext.middleware.js +26 -0
- package/lib/src/http/middleware/request/enrichDetails.middleware.d.ts +15 -0
- package/lib/src/http/middleware/request/enrichDetails.middleware.d.ts.map +1 -0
- package/lib/src/http/middleware/request/enrichDetails.middleware.js +19 -0
- package/lib/src/http/middleware/request/parse.middleware.d.ts +17 -0
- package/lib/src/http/middleware/request/parse.middleware.d.ts.map +1 -0
- package/lib/src/http/middleware/request/parse.middleware.js +43 -0
- package/lib/src/http/middleware/request.middleware.d.ts +73 -0
- package/lib/src/http/middleware/request.middleware.d.ts.map +1 -0
- package/lib/src/http/middleware/request.middleware.js +210 -0
- package/lib/src/http/middleware/response/parse.middleware.d.ts +31 -0
- package/lib/src/http/middleware/response/parse.middleware.d.ts.map +1 -0
- package/lib/src/http/middleware/response/parse.middleware.js +52 -0
- package/lib/src/http/middleware/response.middleware.d.ts +31 -0
- package/lib/src/http/middleware/response.middleware.d.ts.map +1 -0
- package/lib/src/http/middleware/response.middleware.js +52 -0
- package/lib/src/http/openApiV3Generator/index.d.ts +2 -0
- package/lib/src/http/openApiV3Generator/index.d.ts.map +1 -0
- package/lib/src/http/openApiV3Generator/index.js +1 -0
- package/{dist/http → lib/src/http/openApiV3Generator}/openApiV3Generator.d.ts +1 -1
- package/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts.map +1 -0
- package/lib/src/http/openApiV3Generator/openApiV3Generator.js +169 -0
- package/lib/src/http/router/expressLikeRouter.d.ts +135 -0
- package/lib/src/http/router/expressLikeRouter.d.ts.map +1 -0
- package/lib/src/http/router/expressLikeRouter.js +438 -0
- package/{dist/http/types/api.types.d.ts → lib/src/http/types/apiDefinition.types.d.ts} +49 -24
- package/lib/src/http/types/apiDefinition.types.d.ts.map +1 -0
- package/lib/src/http/types/apiDefinition.types.js +1 -0
- package/lib/src/http/types/contractDetails.types.d.ts +169 -0
- package/lib/src/http/types/contractDetails.types.d.ts.map +1 -0
- package/lib/src/http/types/contractDetails.types.js +1 -0
- package/lib/src/http/types/expressLikeRouter.types.d.ts +35 -0
- package/lib/src/http/types/expressLikeRouter.types.d.ts.map +1 -0
- package/lib/src/http/types/expressLikeRouter.types.js +1 -0
- package/lib/src/http/types/index.d.ts +4 -0
- package/lib/src/http/types/index.d.ts.map +1 -0
- package/lib/src/http/types/index.js +3 -0
- package/{dist/http/types/forklaunch.types.d.ts → lib/src/http/types/router.types.d.ts} +3 -3
- package/lib/src/http/types/router.types.d.ts.map +1 -0
- package/lib/src/http/types/router.types.js +1 -0
- package/lib/src/http/utils/enrichExpressLikeSend.d.ts +32 -0
- package/lib/src/http/utils/enrichExpressLikeSend.d.ts.map +1 -0
- package/lib/src/http/utils/enrichExpressLikeSend.js +50 -0
- package/lib/src/http/utils/httpStatusCodes.d.ts.map +1 -0
- package/lib/src/http/utils/httpStatusCodes.js +1039 -0
- package/lib/src/http/utils/index.d.ts +3 -0
- package/lib/src/http/utils/index.d.ts.map +1 -0
- package/lib/src/http/utils/index.js +2 -0
- package/lib/src/services/index.d.ts.map +1 -0
- package/lib/src/services/index.js +1 -0
- package/lib/src/services/interfaces/baseService.d.ts.map +1 -0
- package/lib/src/services/interfaces/baseService.js +1 -0
- package/lib/tests/dtoMapper.test.d.ts +2 -0
- package/lib/tests/dtoMapper.test.d.ts.map +1 -0
- package/lib/tests/dtoMapper.test.js +168 -0
- package/lib/tests/entityMapper.test.d.ts +2 -0
- package/lib/tests/entityMapper.test.js +168 -0
- package/lib/tests/expressLikeRouter.test.d.ts +2 -0
- package/lib/tests/expressLikeRouter.test.d.ts.map +1 -0
- package/lib/tests/expressLikeRouter.test.js +3 -0
- package/lib/tests/expressLikeRouterInstantiation.test.d.ts +2 -0
- package/lib/tests/expressLikeRouterInstantiation.test.d.ts.map +1 -0
- package/lib/tests/expressLikeRouterInstantiation.test.js +60 -0
- package/lib/tests/http.middleware.test.d.ts +2 -0
- package/lib/tests/http.middleware.test.js +102 -0
- package/lib/tests/openApiV3Generator.test.d.ts +2 -0
- package/lib/tests/openApiV3Generator.test.js +66 -0
- package/lib/tests/redisTtlCache.test.d.ts +2 -0
- package/lib/tests/redisTtlCache.test.js +49 -0
- package/lib/tests/typedHandler.test.d.ts +2 -0
- package/lib/tests/typedHandler.test.d.ts.map +1 -0
- package/lib/tests/typedHandler.test.js +3 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/vitest.config.d.ts +3 -0
- package/lib/vitest.config.d.ts.map +1 -0
- package/lib/vitest.config.js +7 -0
- package/package.json +52 -30
- package/dist/cache/index.d.ts.map +0 -1
- package/dist/cache/interfaces/ttlCache.interface.d.ts.map +0 -1
- package/dist/cache/redisTtlCache.d.ts.map +0 -1
- package/dist/cache/types/ttlCacheRecord.types.d.ts.map +0 -1
- package/dist/controllers/index.d.ts.map +0 -1
- package/dist/controllers/interfaces/controller.interface.d.ts.map +0 -1
- package/dist/database/index.d.ts.map +0 -1
- package/dist/database/mikro/models/entities/base.entity.d.ts.map +0 -1
- package/dist/entityMapper/index.d.ts +0 -3
- package/dist/entityMapper/index.d.ts.map +0 -1
- package/dist/entityMapper/interfaces/entityMapper.interface.d.ts.map +0 -1
- package/dist/entityMapper/models/baseEntityMapper.model.d.ts.map +0 -1
- package/dist/entityMapper/models/requestEntityMapper.model.d.ts.map +0 -1
- package/dist/entityMapper/models/responseEntityMapper.model.d.ts.map +0 -1
- package/dist/entityMapper/types/entityMapper.types.d.ts +0 -10
- package/dist/entityMapper/types/entityMapper.types.d.ts.map +0 -1
- package/dist/eslint.config.mjs +0 -10
- package/dist/http/httpStatusCodes.d.ts.map +0 -1
- package/dist/http/index.d.ts +0 -7
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/interfaces/forklaunchExpress.application.interface.d.ts.map +0 -1
- package/dist/http/interfaces/forklaunchExpress.router.interface.d.ts +0 -118
- package/dist/http/interfaces/forklaunchExpress.router.interface.d.ts.map +0 -1
- package/dist/http/interfaces/index.d.ts +0 -3
- package/dist/http/interfaces/index.d.ts.map +0 -1
- package/dist/http/interfaces/index.js +0 -2
- package/dist/http/middleware/index.d.ts.map +0 -1
- package/dist/http/middleware/request.middleware.d.ts +0 -111
- package/dist/http/middleware/request.middleware.d.ts.map +0 -1
- package/dist/http/middleware/response.middleware.d.ts +0 -17
- package/dist/http/middleware/response.middleware.d.ts.map +0 -1
- package/dist/http/middleware/response.middleware.js +0 -49
- package/dist/http/openApiV3Generator.d.ts.map +0 -1
- package/dist/http/regex.d.ts +0 -9
- package/dist/http/regex.d.ts.map +0 -1
- package/dist/http/regex.js +0 -111
- package/dist/http/types/api.types.d.ts.map +0 -1
- package/dist/http/types/forklaunch.types.d.ts.map +0 -1
- package/dist/http/types/index.d.ts +0 -4
- package/dist/http/types/index.d.ts.map +0 -1
- package/dist/http/types/index.js +0 -3
- package/dist/http/types/primitive.types.d.ts +0 -110
- package/dist/http/types/primitive.types.d.ts.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/jest.config.d.ts +0 -4
- package/dist/jest.config.d.ts.map +0 -1
- package/dist/jest.config.js +0 -7
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/interfaces/baseService.d.ts.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/{dist → lib/dist}/cache/index.js +0 -0
- /package/{dist → lib/dist}/cache/interfaces/ttlCache.interface.js +0 -0
- /package/{dist → lib/dist}/cache/types/ttlCacheRecord.types.js +0 -0
- /package/{dist → lib/dist}/controllers/index.js +0 -0
- /package/{dist → lib/dist}/controllers/interfaces/controller.interface.js +0 -0
- /package/{dist → lib/dist}/database/index.js +0 -0
- /package/{dist → lib/dist}/entityMapper/index.js +0 -0
- /package/{dist → lib/dist}/entityMapper/interfaces/entityMapper.interface.js +0 -0
- /package/{dist → lib/dist}/entityMapper/models/baseEntityMapper.model.js +0 -0
- /package/{dist → lib/dist}/entityMapper/models/requestEntityMapper.model.js +0 -0
- /package/{dist → lib/dist}/entityMapper/models/responseEntityMapper.model.js +0 -0
- /package/{dist → lib/dist}/entityMapper/types/entityMapper.types.js +0 -0
- /package/{dist/http/interfaces/forklaunchExpress.application.interface.js → lib/dist/http/interfaces/expressLikeApplication.interface.js} +0 -0
- /package/{dist → lib/dist}/http/middleware/index.js +0 -0
- /package/{dist/http/types/api.types.js → lib/dist/http/types/apiDefinition.types.js} +0 -0
- /package/{dist/http/types/forklaunch.types.js → lib/dist/http/types/contractDetails.types.js} +0 -0
- /package/{dist/http/types/primitive.types.js → lib/dist/http/types/router.types.js} +0 -0
- /package/{dist/http → lib/dist/http/utils}/httpStatusCodes.js +0 -0
- /package/{dist → lib/dist}/index.js +0 -0
- /package/{dist/services/interfaces/baseService.js → lib/dist/lib/src/cache/interfaces/ttlCache.interface.js} +0 -0
- /package/{dist → lib/dist/lib/src}/services/index.js +0 -0
- /package/{dist → lib/dist/lib}/tests/entityMapper.test.d.ts +0 -0
- /package/{dist → lib/dist/lib}/tests/http.middleware.test.d.ts +0 -0
- /package/{dist → lib/dist/lib}/tests/openApiV3Generator.test.d.ts +0 -0
- /package/{dist → lib/dist/lib}/tests/redisTtlCache.test.d.ts +0 -0
- /package/{dist → lib/dist}/tests/redisTtlCache.test.js +0 -0
- /package/{dist → lib}/eslint.config.d.mts +0 -0
- /package/{dist → lib}/eslint.config.d.mts.map +0 -0
- /package/{dist → lib/src}/cache/index.d.ts +0 -0
- /package/{dist → lib/src}/cache/interfaces/ttlCache.interface.d.ts +0 -0
- /package/{dist → lib/src}/cache/redisTtlCache.d.ts +0 -0
- /package/{dist → lib/src}/cache/types/ttlCacheRecord.types.d.ts +0 -0
- /package/{dist → lib/src}/controllers/index.d.ts +0 -0
- /package/{dist → lib/src}/controllers/interfaces/controller.interface.d.ts +0 -0
- /package/{dist → lib/src}/database/index.d.ts +0 -0
- /package/{dist → lib/src}/database/mikro/models/entities/base.entity.d.ts +0 -0
- /package/{dist → lib/src}/database/mikro/models/entities/base.entity.js +0 -0
- /package/{dist → lib/src}/http/middleware/index.d.ts +0 -0
- /package/{dist/http → lib/src/http/utils}/httpStatusCodes.d.ts +0 -0
- /package/{dist → lib/src}/services/index.d.ts +0 -0
- /package/{dist → lib/src}/services/interfaces/baseService.d.ts +0 -0
- /package/{dist → lib}/tests/entityMapper.test.d.ts.map +0 -0
- /package/{dist → lib}/tests/http.middleware.test.d.ts.map +0 -0
- /package/{dist → lib}/tests/openApiV3Generator.test.d.ts.map +0 -0
- /package/{dist → lib}/tests/redisTtlCache.test.d.ts.map +0 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
import { BaseDtoMapper, construct } from './baseDtoMapper.model';
|
2
|
+
/**
|
3
|
+
* Abstract class representing a request entity mapper.
|
4
|
+
*
|
5
|
+
* @template Entity - A type that extends BaseEntity.
|
6
|
+
* @template SV - A type that extends AnySchemaValidator.
|
7
|
+
* @extends {BaseDtoMapper<SV>}
|
8
|
+
*/
|
9
|
+
export class RequestDtoMapper extends BaseDtoMapper {
|
10
|
+
/**
|
11
|
+
* The entity type.
|
12
|
+
* @type {Entity}
|
13
|
+
* @protected
|
14
|
+
*/
|
15
|
+
_Entity;
|
16
|
+
/**
|
17
|
+
* Populates the DTO with data from a JSON object.
|
18
|
+
*
|
19
|
+
* @param {this['_dto']} json - The JSON object.
|
20
|
+
* @returns {this} - The instance of the RequestDtoMapper.
|
21
|
+
*/
|
22
|
+
fromJson(json) {
|
23
|
+
if (!this.schemaValidator.validate(this.schemaValidator.schemify(this.schema), json)) {
|
24
|
+
throw new Error('Invalid DTO');
|
25
|
+
}
|
26
|
+
this.dto = json;
|
27
|
+
return this;
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Deserializes a JSON object to an entity.
|
31
|
+
*
|
32
|
+
* @param {this['_dto']} json - The JSON object.
|
33
|
+
* @param {...unknown[]} additionalArgs - Additional arguments.
|
34
|
+
* @returns {Entity} - The entity.
|
35
|
+
*/
|
36
|
+
deserializeJsonToEntity(json, ...additionalArgs) {
|
37
|
+
return this.fromJson(json).toEntity(...additionalArgs);
|
38
|
+
}
|
39
|
+
/**
|
40
|
+
* Creates an instance of a RequestDtoMapper from a JSON object.
|
41
|
+
*
|
42
|
+
* @template T - A type that extends RequestDtoMapper.
|
43
|
+
* @template SV - A type that extends AnySchemaValidator.
|
44
|
+
* @template JsonType - The type of the JSON object.
|
45
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
46
|
+
* @param {SV} schemaValidator - The schema provider.
|
47
|
+
* @param {JsonType} json - The JSON object.
|
48
|
+
* @returns {T} - An instance of the T.
|
49
|
+
*/
|
50
|
+
static fromJson(schemaValidator, json) {
|
51
|
+
return construct(this, schemaValidator).fromJson(json);
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* Deserializes a JSON object to an entity.
|
55
|
+
*
|
56
|
+
* @template T - A type that extends RequestDtoMapper.
|
57
|
+
* @template SV - A type that extends AnySchemaValidator.
|
58
|
+
* @template JsonType - The type of the JSON object.
|
59
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
60
|
+
* @param {SV} schemaValidator - The schema provider.
|
61
|
+
* @param {JsonType} json - The JSON object.
|
62
|
+
* @param {...unknown[]} additionalArgs - Additional arguments.
|
63
|
+
* @returns {T['_Entity']} - The entity.
|
64
|
+
*/
|
65
|
+
static deserializeJsonToEntity(schemaValidator, json, ...additionalArgs) {
|
66
|
+
return construct(this, schemaValidator)
|
67
|
+
.fromJson(json)
|
68
|
+
.toEntity(...additionalArgs);
|
69
|
+
}
|
70
|
+
}
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
2
|
import { BaseEntity } from '../../database/mikro/models/entities/base.entity';
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { DtoMapperConstructor } from '../interfaces/dtoMapper.interface';
|
4
|
+
import { BaseDtoMapper } from './baseDtoMapper.model';
|
5
5
|
/**
|
6
6
|
* Abstract class representing a response entity mapper.
|
7
7
|
*
|
8
8
|
* @template Entity - A type that extends BaseEntity.
|
9
9
|
* @template SV - A type that extends AnySchemaValidator.
|
10
|
-
* @extends {
|
10
|
+
* @extends {BaseDtoMapper<SV>}
|
11
11
|
*/
|
12
|
-
export declare abstract class
|
12
|
+
export declare abstract class ResponseDtoMapper<Entity extends BaseEntity, SV extends AnySchemaValidator> extends BaseDtoMapper<SV> {
|
13
13
|
/**
|
14
14
|
* The entity type.
|
15
15
|
* @type {Entity}
|
@@ -22,7 +22,7 @@ export declare abstract class ResponseEntityMapper<Entity extends BaseEntity, SV
|
|
22
22
|
* @abstract
|
23
23
|
* @param {Entity} entity - The entity to convert.
|
24
24
|
* @param {...unknown[]} additionalArgs - Additional arguments.
|
25
|
-
* @returns {this} - The instance of the
|
25
|
+
* @returns {this} - The instance of the ResponseDtoMapper.
|
26
26
|
*/
|
27
27
|
abstract fromEntity(entity: Entity, ...additionalArgs: unknown[]): this;
|
28
28
|
/**
|
@@ -43,25 +43,25 @@ export declare abstract class ResponseEntityMapper<Entity extends BaseEntity, SV
|
|
43
43
|
/**
|
44
44
|
* Populates entity mapper with DTO from an entity.
|
45
45
|
*
|
46
|
-
* @template T - A type that extends
|
46
|
+
* @template T - A type that extends ResponseDtoMapper.
|
47
47
|
* @template SV - A type that extends AnySchemaValidator.
|
48
|
-
* @param {
|
48
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
49
49
|
* @param {SV} schemaValidator - The schema provider.
|
50
50
|
* @param {T['_Entity']} entity - The entity to convert.
|
51
51
|
* @returns {T} - An instance of the T.
|
52
52
|
*/
|
53
|
-
static fromEntity<T extends
|
53
|
+
static fromEntity<T extends ResponseDtoMapper<BaseEntity, SV>, SV extends AnySchemaValidator>(this: DtoMapperConstructor<T, SV>, schemaValidator: SV, entity: T['_Entity']): T;
|
54
54
|
/**
|
55
55
|
* Serializes an entity to a JSON object.
|
56
56
|
*
|
57
|
-
* @template T - A type that extends
|
57
|
+
* @template T - A type that extends ResponseDtoMapper.
|
58
58
|
* @template SV - A type that extends AnySchemaValidator.
|
59
|
-
* @param {
|
59
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
60
60
|
* @param {SV} schemaValidator - The schema provider.
|
61
61
|
* @param {T['_Entity']} entity - The entity to serialize.
|
62
62
|
* @returns {T['_dto']} - The JSON object.
|
63
63
|
* @throws {Error} - Throws an error if the DTO is invalid.
|
64
64
|
*/
|
65
|
-
static serializeEntityToJson<T extends
|
65
|
+
static serializeEntityToJson<T extends ResponseDtoMapper<BaseEntity, SV>, SV extends AnySchemaValidator>(this: DtoMapperConstructor<T, SV>, schemaValidator: SV, entity: T['_Entity']): T['_dto'];
|
66
66
|
}
|
67
|
-
//# sourceMappingURL=
|
67
|
+
//# sourceMappingURL=responseDtoMapper.model.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"responseDtoMapper.model.d.ts","sourceRoot":"","sources":["../../../../src/domainMapper/models/responseDtoMapper.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,kDAAkD,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAa,MAAM,uBAAuB,CAAC;AAEjE;;;;;;GAMG;AACH,8BAAsB,iBAAiB,CACrC,MAAM,SAAS,UAAU,EACzB,EAAE,SAAS,kBAAkB,CAC7B,SAAQ,aAAa,CAAC,EAAE,CAAC;IACzB;;;;OAIG;IACH,OAAO,EAAG,MAAM,CAAC;IAEjB;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAEvE;;;;;OAKG;IACH,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;IAYtB;;;;;;OAMG;IACH,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAInD;;;;;;;;;OASG;IACH,MAAM,CAAC,UAAU,CACf,CAAC,SAAS,iBAAiB,CAAC,UAAU,EAAE,EAAE,CAAC,EAC3C,EAAE,SAAS,kBAAkB,EAE7B,IAAI,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,EACjC,eAAe,EAAE,EAAE,EACnB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,GACnB,CAAC;IAIJ;;;;;;;;;;OAUG;IACH,MAAM,CAAC,qBAAqB,CAC1B,CAAC,SAAS,iBAAiB,CAAC,UAAU,EAAE,EAAE,CAAC,EAC3C,EAAE,SAAS,kBAAkB,EAE7B,IAAI,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,EACjC,eAAe,EAAE,EAAE,EACnB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,GACnB,CAAC,CAAC,MAAM,CAAC;CAGb"}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { BaseDtoMapper, construct } from './baseDtoMapper.model';
|
2
|
+
/**
|
3
|
+
* Abstract class representing a response entity mapper.
|
4
|
+
*
|
5
|
+
* @template Entity - A type that extends BaseEntity.
|
6
|
+
* @template SV - A type that extends AnySchemaValidator.
|
7
|
+
* @extends {BaseDtoMapper<SV>}
|
8
|
+
*/
|
9
|
+
export class ResponseDtoMapper extends BaseDtoMapper {
|
10
|
+
/**
|
11
|
+
* The entity type.
|
12
|
+
* @type {Entity}
|
13
|
+
* @protected
|
14
|
+
*/
|
15
|
+
_Entity;
|
16
|
+
/**
|
17
|
+
* Converts the underlying DTO to a JSON object.
|
18
|
+
*
|
19
|
+
* @returns {this['_dto']} - The JSON object.
|
20
|
+
* @throws {Error} - Throws an error if the DTO is invalid.
|
21
|
+
*/
|
22
|
+
toJson() {
|
23
|
+
if (!this.schemaValidator.validate(this.schemaValidator.schemify(this.schema), this.dto)) {
|
24
|
+
throw new Error('Invalid DTO');
|
25
|
+
}
|
26
|
+
return this.dto;
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* Serializes an entity to a JSON object.
|
30
|
+
*
|
31
|
+
* @param {Entity} entity - The entity to serialize.
|
32
|
+
* @returns {this['_dto']} - The JSON object.
|
33
|
+
* @throws {Error} - Throws an error if the DTO is invalid.
|
34
|
+
*/
|
35
|
+
serializeEntityToJson(entity) {
|
36
|
+
return this.fromEntity(entity).toJson();
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* Populates entity mapper with DTO from an entity.
|
40
|
+
*
|
41
|
+
* @template T - A type that extends ResponseDtoMapper.
|
42
|
+
* @template SV - A type that extends AnySchemaValidator.
|
43
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
44
|
+
* @param {SV} schemaValidator - The schema provider.
|
45
|
+
* @param {T['_Entity']} entity - The entity to convert.
|
46
|
+
* @returns {T} - An instance of the T.
|
47
|
+
*/
|
48
|
+
static fromEntity(schemaValidator, entity) {
|
49
|
+
return construct(this, schemaValidator).fromEntity(entity);
|
50
|
+
}
|
51
|
+
/**
|
52
|
+
* Serializes an entity to a JSON object.
|
53
|
+
*
|
54
|
+
* @template T - A type that extends ResponseDtoMapper.
|
55
|
+
* @template SV - A type that extends AnySchemaValidator.
|
56
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
57
|
+
* @param {SV} schemaValidator - The schema provider.
|
58
|
+
* @param {T['_Entity']} entity - The entity to serialize.
|
59
|
+
* @returns {T['_dto']} - The JSON object.
|
60
|
+
* @throws {Error} - Throws an error if the DTO is invalid.
|
61
|
+
*/
|
62
|
+
static serializeEntityToJson(schemaValidator, entity) {
|
63
|
+
return construct(this, schemaValidator).serializeEntityToJson(entity);
|
64
|
+
}
|
65
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { AnySchemaValidator, UnboxedObjectSchema } from '@forklaunch/validator';
|
2
|
+
/**
|
3
|
+
* Type representing a schema validator object for an entity mapper.
|
4
|
+
*
|
5
|
+
* @template SV - A type that extends AnySchemaValidator.
|
6
|
+
* @typedef {SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>} DtoMapperSchemaValidatorObject
|
7
|
+
*/
|
8
|
+
export type DtoMapperSchemaValidatorObject<SV extends AnySchemaValidator> = SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>;
|
9
|
+
//# sourceMappingURL=dtoMapper.types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"dtoMapper.types.d.ts","sourceRoot":"","sources":["../../../../src/domainMapper/types/dtoMapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,MAAM,8BAA8B,CAAC,EAAE,SAAS,kBAAkB,IACpE,EAAE,CAAC,oBAAoB,CAAC,GACxB,mBAAmB,CAAC,EAAE,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dtoMapper/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
+
/**
|
3
|
+
* Interface representing a constructor for an entity mapper.
|
4
|
+
*
|
5
|
+
* @template T - The type of the entity mapper.
|
6
|
+
* @template SV - The type of the schema validator.
|
7
|
+
* @interface DtoMapperConstructor
|
8
|
+
*/
|
9
|
+
export interface DtoMapperConstructor<T, SV extends AnySchemaValidator> {
|
10
|
+
/**
|
11
|
+
* Creates a new instance of the entity mapper.
|
12
|
+
*
|
13
|
+
* @param {AnySchemaValidator} schemaValidator - The arguments to pass to the constructor.
|
14
|
+
* @returns {T} - A new instance of the entity mapper.
|
15
|
+
*/
|
16
|
+
new (schemaValidator: SV): T;
|
17
|
+
}
|
18
|
+
//# sourceMappingURL=dtoMapper.interface.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"dtoMapper.interface.d.ts","sourceRoot":"","sources":["../../../../src/dtoMapper/interfaces/dtoMapper.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,EAAE,EAAE,SAAS,kBAAkB;IACpE;;;;;OAKG;IACH,KAAK,eAAe,EAAE,EAAE,GAAG,CAAC,CAAC;CAC9B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { AnySchemaValidator, Schema, SchemaValidator } from '@forklaunch/validator';
|
2
|
+
import { DtoMapperConstructor } from '../interfaces/dtoMapper.interface';
|
3
|
+
import { DtoMapperSchemaValidatorObject } from '../types/dtoMapper.types';
|
4
|
+
/**
|
5
|
+
* Constructs an instance of a T.
|
6
|
+
*
|
7
|
+
* @template T - A type that extends BaseDtoMapper.
|
8
|
+
* @template SV - A type that extends AnySchemaValidator.
|
9
|
+
* @param {DtoMapperConstructor<T, SV>} self - The constructor of the T.
|
10
|
+
* @param {SV} [schemaValidator] - The optional schema validator.
|
11
|
+
* @returns {T} - An instance of the T.
|
12
|
+
*/
|
13
|
+
export declare function construct<T, SV extends AnySchemaValidator>(self: DtoMapperConstructor<T, SV>, schemaValidator?: SV): T;
|
14
|
+
/**
|
15
|
+
* Abstract class representing a base entity mapper.
|
16
|
+
*
|
17
|
+
* @template SV - A type that extends AnySchemaValidator.
|
18
|
+
*/
|
19
|
+
export declare abstract class BaseDtoMapper<SV extends AnySchemaValidator> {
|
20
|
+
/**
|
21
|
+
* The schema validator exact type.
|
22
|
+
* @type {SV}
|
23
|
+
* @protected
|
24
|
+
*/
|
25
|
+
_SV: SV;
|
26
|
+
/**
|
27
|
+
* The schema validator as a general type.
|
28
|
+
* @type {SchemaValidator}
|
29
|
+
* @protected
|
30
|
+
*/
|
31
|
+
protected schemaValidator: SchemaValidator;
|
32
|
+
/**
|
33
|
+
* The schema definition.
|
34
|
+
* @type {DtoMapperSchemaValidatorObject<SV>}
|
35
|
+
* @abstract
|
36
|
+
*/
|
37
|
+
abstract schema: DtoMapperSchemaValidatorObject<SV>;
|
38
|
+
/**
|
39
|
+
* The Data Transfer Object (DTO).
|
40
|
+
* @type {Schema<this['schema'], SV>}
|
41
|
+
*/
|
42
|
+
_dto: Schema<this['schema'], SV>;
|
43
|
+
/**
|
44
|
+
* Creates an instance of BaseDtoMapper.
|
45
|
+
*
|
46
|
+
* @param {SV} schemaValidator - The schema provider.
|
47
|
+
*/
|
48
|
+
constructor(schemaValidator: SV);
|
49
|
+
/**
|
50
|
+
* Validates and sets the Data Transfer Object (DTO).
|
51
|
+
*
|
52
|
+
* @param {this['_dto']} dto - The Data Transfer Object (DTO).
|
53
|
+
* @throws {Error} - Throws an error if the DTO is invalid.
|
54
|
+
*/
|
55
|
+
set dto(_dto: this['_dto']);
|
56
|
+
/**
|
57
|
+
* Validates and gets the Data Transfer Object (DTO).
|
58
|
+
*
|
59
|
+
* @returns {this['_dto']} - The Data Transfer Object (DTO).
|
60
|
+
*/
|
61
|
+
get dto(): this['_dto'];
|
62
|
+
/**
|
63
|
+
* Gets the schema of a T.
|
64
|
+
*
|
65
|
+
* @template T - A type that extends BaseDtoMapper.
|
66
|
+
* @template SV - A type that extends AnySchemaValidator.
|
67
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
68
|
+
* @returns {T['schema']} - The schema of the T.
|
69
|
+
*/
|
70
|
+
static schema<T extends BaseDtoMapper<SV>, SV extends AnySchemaValidator>(this: DtoMapperConstructor<T, SV>): T['schema'];
|
71
|
+
}
|
72
|
+
//# sourceMappingURL=baseDtoMapper.model.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"baseDtoMapper.model.d.ts","sourceRoot":"","sources":["../../../../src/dtoMapper/models/baseDtoMapper.model.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAE1E;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,SAAS,kBAAkB,EACxD,IAAI,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,EACjC,eAAe,CAAC,EAAE,EAAE,GACnB,CAAC,CAEH;AAED;;;;GAIG;AACH,8BAAsB,aAAa,CAAC,EAAE,SAAS,kBAAkB;IAC/D;;;;OAIG;IACH,GAAG,EAAG,EAAE,CAAC;IAET;;;;OAIG;IACH,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAE3C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,8BAA8B,CAAC,EAAE,CAAC,CAAC;IAEpD;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAG9B;IAEF;;;;OAIG;gBACS,eAAe,EAAE,EAAE;IAI/B;;;;;OAKG;IACH,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAUzB;IAED;;;;OAIG;IACH,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAEtB;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,kBAAkB,EACtE,IAAI,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,GAChC,CAAC,CAAC,QAAQ,CAAC;CAGf"}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/**
|
2
|
+
* Constructs an instance of a T.
|
3
|
+
*
|
4
|
+
* @template T - A type that extends BaseDtoMapper.
|
5
|
+
* @template SV - A type that extends AnySchemaValidator.
|
6
|
+
* @param {DtoMapperConstructor<T, SV>} self - The constructor of the T.
|
7
|
+
* @param {SV} [schemaValidator] - The optional schema validator.
|
8
|
+
* @returns {T} - An instance of the T.
|
9
|
+
*/
|
10
|
+
export function construct(self, schemaValidator) {
|
11
|
+
return new self(schemaValidator || {});
|
12
|
+
}
|
13
|
+
/**
|
14
|
+
* Abstract class representing a base entity mapper.
|
15
|
+
*
|
16
|
+
* @template SV - A type that extends AnySchemaValidator.
|
17
|
+
*/
|
18
|
+
export class BaseDtoMapper {
|
19
|
+
/**
|
20
|
+
* The schema validator exact type.
|
21
|
+
* @type {SV}
|
22
|
+
* @protected
|
23
|
+
*/
|
24
|
+
_SV;
|
25
|
+
/**
|
26
|
+
* The schema validator as a general type.
|
27
|
+
* @type {SchemaValidator}
|
28
|
+
* @protected
|
29
|
+
*/
|
30
|
+
schemaValidator;
|
31
|
+
/**
|
32
|
+
* The Data Transfer Object (DTO).
|
33
|
+
* @type {Schema<this['schema'], SV>}
|
34
|
+
*/
|
35
|
+
_dto = {};
|
36
|
+
/**
|
37
|
+
* Creates an instance of BaseDtoMapper.
|
38
|
+
*
|
39
|
+
* @param {SV} schemaValidator - The schema provider.
|
40
|
+
*/
|
41
|
+
constructor(schemaValidator) {
|
42
|
+
this.schemaValidator = schemaValidator;
|
43
|
+
}
|
44
|
+
/**
|
45
|
+
* Validates and sets the Data Transfer Object (DTO).
|
46
|
+
*
|
47
|
+
* @param {this['_dto']} dto - The Data Transfer Object (DTO).
|
48
|
+
* @throws {Error} - Throws an error if the DTO is invalid.
|
49
|
+
*/
|
50
|
+
set dto(_dto) {
|
51
|
+
if (!this.schemaValidator.validate(this.schemaValidator.schemify(this.schema), _dto)) {
|
52
|
+
throw new Error('Invalid DTO');
|
53
|
+
}
|
54
|
+
this._dto = _dto;
|
55
|
+
}
|
56
|
+
/**
|
57
|
+
* Validates and gets the Data Transfer Object (DTO).
|
58
|
+
*
|
59
|
+
* @returns {this['_dto']} - The Data Transfer Object (DTO).
|
60
|
+
*/
|
61
|
+
get dto() {
|
62
|
+
return this._dto;
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* Gets the schema of a T.
|
66
|
+
*
|
67
|
+
* @template T - A type that extends BaseDtoMapper.
|
68
|
+
* @template SV - A type that extends AnySchemaValidator.
|
69
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
70
|
+
* @returns {T['schema']} - The schema of the T.
|
71
|
+
*/
|
72
|
+
static schema() {
|
73
|
+
return construct(this).schema;
|
74
|
+
}
|
75
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
+
import { BaseEntity } from '../../database/mikro/models/entities/base.entity';
|
3
|
+
import { DtoMapperConstructor } from '../interfaces/dtoMapper.interface';
|
4
|
+
import { BaseDtoMapper } from './baseDtoMapper.model';
|
5
|
+
/**
|
6
|
+
* Abstract class representing a request entity mapper.
|
7
|
+
*
|
8
|
+
* @template Entity - A type that extends BaseEntity.
|
9
|
+
* @template SV - A type that extends AnySchemaValidator.
|
10
|
+
* @extends {BaseDtoMapper<SV>}
|
11
|
+
*/
|
12
|
+
export declare abstract class RequestDtoMapper<Entity extends BaseEntity, SV extends AnySchemaValidator> extends BaseDtoMapper<SV> {
|
13
|
+
/**
|
14
|
+
* The entity type.
|
15
|
+
* @type {Entity}
|
16
|
+
* @protected
|
17
|
+
*/
|
18
|
+
_Entity: Entity;
|
19
|
+
/**
|
20
|
+
* Converts the underlying DTO to an entity.
|
21
|
+
*
|
22
|
+
* @abstract
|
23
|
+
* @param {...unknown[]} additionalArgs - Additional arguments.
|
24
|
+
* @returns {Entity} - The entity.
|
25
|
+
*/
|
26
|
+
abstract toEntity(...additionalArgs: unknown[]): Entity;
|
27
|
+
/**
|
28
|
+
* Populates the DTO with data from a JSON object.
|
29
|
+
*
|
30
|
+
* @param {this['_dto']} json - The JSON object.
|
31
|
+
* @returns {this} - The instance of the RequestDtoMapper.
|
32
|
+
*/
|
33
|
+
fromJson(json: this['_dto']): this;
|
34
|
+
/**
|
35
|
+
* Deserializes a JSON object to an entity.
|
36
|
+
*
|
37
|
+
* @param {this['_dto']} json - The JSON object.
|
38
|
+
* @param {...unknown[]} additionalArgs - Additional arguments.
|
39
|
+
* @returns {Entity} - The entity.
|
40
|
+
*/
|
41
|
+
deserializeJsonToEntity(json: this['_dto'], ...additionalArgs: unknown[]): Entity;
|
42
|
+
/**
|
43
|
+
* Creates an instance of a RequestDtoMapper from a JSON object.
|
44
|
+
*
|
45
|
+
* @template T - A type that extends RequestDtoMapper.
|
46
|
+
* @template SV - A type that extends AnySchemaValidator.
|
47
|
+
* @template JsonType - The type of the JSON object.
|
48
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
49
|
+
* @param {SV} schemaValidator - The schema provider.
|
50
|
+
* @param {JsonType} json - The JSON object.
|
51
|
+
* @returns {T} - An instance of the T.
|
52
|
+
*/
|
53
|
+
static fromJson<T extends RequestDtoMapper<BaseEntity, SV>, SV extends AnySchemaValidator, JsonType extends T['_dto']>(this: DtoMapperConstructor<T, SV>, schemaValidator: SV, json: JsonType): T;
|
54
|
+
/**
|
55
|
+
* Deserializes a JSON object to an entity.
|
56
|
+
*
|
57
|
+
* @template T - A type that extends RequestDtoMapper.
|
58
|
+
* @template SV - A type that extends AnySchemaValidator.
|
59
|
+
* @template JsonType - The type of the JSON object.
|
60
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
61
|
+
* @param {SV} schemaValidator - The schema provider.
|
62
|
+
* @param {JsonType} json - The JSON object.
|
63
|
+
* @param {...unknown[]} additionalArgs - Additional arguments.
|
64
|
+
* @returns {T['_Entity']} - The entity.
|
65
|
+
*/
|
66
|
+
static deserializeJsonToEntity<T extends RequestDtoMapper<BaseEntity, SV>, SV extends AnySchemaValidator, JsonType extends T['_dto']>(this: DtoMapperConstructor<T, SV>, schemaValidator: SV, json: JsonType, ...additionalArgs: unknown[]): T['_Entity'];
|
67
|
+
}
|
68
|
+
//# sourceMappingURL=requestDtoMapper.model.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"requestDtoMapper.model.d.ts","sourceRoot":"","sources":["../../../../src/dtoMapper/models/requestDtoMapper.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,kDAAkD,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAa,MAAM,uBAAuB,CAAC;AAEjE;;;;;;GAMG;AACH,8BAAsB,gBAAgB,CACpC,MAAM,SAAS,UAAU,EACzB,EAAE,SAAS,kBAAkB,CAC7B,SAAQ,aAAa,CAAC,EAAE,CAAC;IACzB;;;;OAIG;IACH,OAAO,EAAG,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,MAAM;IAEvD;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI;IAalC;;;;;;OAMG;IACH,uBAAuB,CACrB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAClB,GAAG,cAAc,EAAE,OAAO,EAAE,GAC3B,MAAM;IAIT;;;;;;;;;;OAUG;IACH,MAAM,CAAC,QAAQ,CACb,CAAC,SAAS,gBAAgB,CAAC,UAAU,EAAE,EAAE,CAAC,EAC1C,EAAE,SAAS,kBAAkB,EAC7B,QAAQ,SAAS,CAAC,CAAC,MAAM,CAAC,EAE1B,IAAI,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,EACjC,eAAe,EAAE,EAAE,EACnB,IAAI,EAAE,QAAQ,GACb,CAAC;IAIJ;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,uBAAuB,CAC5B,CAAC,SAAS,gBAAgB,CAAC,UAAU,EAAE,EAAE,CAAC,EAC1C,EAAE,SAAS,kBAAkB,EAC7B,QAAQ,SAAS,CAAC,CAAC,MAAM,CAAC,EAE1B,IAAI,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,EACjC,eAAe,EAAE,EAAE,EACnB,IAAI,EAAE,QAAQ,EACd,GAAG,cAAc,EAAE,OAAO,EAAE,GAC3B,CAAC,CAAC,SAAS,CAAC;CAKhB"}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import { BaseDtoMapper, construct } from './baseDtoMapper.model';
|
2
|
+
/**
|
3
|
+
* Abstract class representing a request entity mapper.
|
4
|
+
*
|
5
|
+
* @template Entity - A type that extends BaseEntity.
|
6
|
+
* @template SV - A type that extends AnySchemaValidator.
|
7
|
+
* @extends {BaseDtoMapper<SV>}
|
8
|
+
*/
|
9
|
+
export class RequestDtoMapper extends BaseDtoMapper {
|
10
|
+
/**
|
11
|
+
* The entity type.
|
12
|
+
* @type {Entity}
|
13
|
+
* @protected
|
14
|
+
*/
|
15
|
+
_Entity;
|
16
|
+
/**
|
17
|
+
* Populates the DTO with data from a JSON object.
|
18
|
+
*
|
19
|
+
* @param {this['_dto']} json - The JSON object.
|
20
|
+
* @returns {this} - The instance of the RequestDtoMapper.
|
21
|
+
*/
|
22
|
+
fromJson(json) {
|
23
|
+
if (!this.schemaValidator.validate(this.schemaValidator.schemify(this.schema), json)) {
|
24
|
+
throw new Error('Invalid DTO');
|
25
|
+
}
|
26
|
+
this.dto = json;
|
27
|
+
return this;
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Deserializes a JSON object to an entity.
|
31
|
+
*
|
32
|
+
* @param {this['_dto']} json - The JSON object.
|
33
|
+
* @param {...unknown[]} additionalArgs - Additional arguments.
|
34
|
+
* @returns {Entity} - The entity.
|
35
|
+
*/
|
36
|
+
deserializeJsonToEntity(json, ...additionalArgs) {
|
37
|
+
return this.fromJson(json).toEntity(...additionalArgs);
|
38
|
+
}
|
39
|
+
/**
|
40
|
+
* Creates an instance of a RequestDtoMapper from a JSON object.
|
41
|
+
*
|
42
|
+
* @template T - A type that extends RequestDtoMapper.
|
43
|
+
* @template SV - A type that extends AnySchemaValidator.
|
44
|
+
* @template JsonType - The type of the JSON object.
|
45
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
46
|
+
* @param {SV} schemaValidator - The schema provider.
|
47
|
+
* @param {JsonType} json - The JSON object.
|
48
|
+
* @returns {T} - An instance of the T.
|
49
|
+
*/
|
50
|
+
static fromJson(schemaValidator, json) {
|
51
|
+
return construct(this, schemaValidator).fromJson(json);
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* Deserializes a JSON object to an entity.
|
55
|
+
*
|
56
|
+
* @template T - A type that extends RequestDtoMapper.
|
57
|
+
* @template SV - A type that extends AnySchemaValidator.
|
58
|
+
* @template JsonType - The type of the JSON object.
|
59
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
60
|
+
* @param {SV} schemaValidator - The schema provider.
|
61
|
+
* @param {JsonType} json - The JSON object.
|
62
|
+
* @param {...unknown[]} additionalArgs - Additional arguments.
|
63
|
+
* @returns {T['_Entity']} - The entity.
|
64
|
+
*/
|
65
|
+
static deserializeJsonToEntity(schemaValidator, json, ...additionalArgs) {
|
66
|
+
return construct(this, schemaValidator)
|
67
|
+
.fromJson(json)
|
68
|
+
.toEntity(...additionalArgs);
|
69
|
+
}
|
70
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
|
+
import { BaseEntity } from '../../database/mikro/models/entities/base.entity';
|
3
|
+
import { DtoMapperConstructor } from '../interfaces/dtoMapper.interface';
|
4
|
+
import { BaseDtoMapper } from './baseDtoMapper.model';
|
5
|
+
/**
|
6
|
+
* Abstract class representing a response entity mapper.
|
7
|
+
*
|
8
|
+
* @template Entity - A type that extends BaseEntity.
|
9
|
+
* @template SV - A type that extends AnySchemaValidator.
|
10
|
+
* @extends {BaseDtoMapper<SV>}
|
11
|
+
*/
|
12
|
+
export declare abstract class ResponseDtoMapper<Entity extends BaseEntity, SV extends AnySchemaValidator> extends BaseDtoMapper<SV> {
|
13
|
+
/**
|
14
|
+
* The entity type.
|
15
|
+
* @type {Entity}
|
16
|
+
* @protected
|
17
|
+
*/
|
18
|
+
_Entity: Entity;
|
19
|
+
/**
|
20
|
+
* Populates entity mapper with DTO from an entity.
|
21
|
+
*
|
22
|
+
* @abstract
|
23
|
+
* @param {Entity} entity - The entity to convert.
|
24
|
+
* @param {...unknown[]} additionalArgs - Additional arguments.
|
25
|
+
* @returns {this} - The instance of the ResponseDtoMapper.
|
26
|
+
*/
|
27
|
+
abstract fromEntity(entity: Entity, ...additionalArgs: unknown[]): this;
|
28
|
+
/**
|
29
|
+
* Converts the underlying DTO to a JSON object.
|
30
|
+
*
|
31
|
+
* @returns {this['_dto']} - The JSON object.
|
32
|
+
* @throws {Error} - Throws an error if the DTO is invalid.
|
33
|
+
*/
|
34
|
+
toJson(): this['_dto'];
|
35
|
+
/**
|
36
|
+
* Serializes an entity to a JSON object.
|
37
|
+
*
|
38
|
+
* @param {Entity} entity - The entity to serialize.
|
39
|
+
* @returns {this['_dto']} - The JSON object.
|
40
|
+
* @throws {Error} - Throws an error if the DTO is invalid.
|
41
|
+
*/
|
42
|
+
serializeEntityToJson(entity: Entity): this['_dto'];
|
43
|
+
/**
|
44
|
+
* Populates entity mapper with DTO from an entity.
|
45
|
+
*
|
46
|
+
* @template T - A type that extends ResponseDtoMapper.
|
47
|
+
* @template SV - A type that extends AnySchemaValidator.
|
48
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
49
|
+
* @param {SV} schemaValidator - The schema provider.
|
50
|
+
* @param {T['_Entity']} entity - The entity to convert.
|
51
|
+
* @returns {T} - An instance of the T.
|
52
|
+
*/
|
53
|
+
static fromEntity<T extends ResponseDtoMapper<BaseEntity, SV>, SV extends AnySchemaValidator>(this: DtoMapperConstructor<T, SV>, schemaValidator: SV, entity: T['_Entity']): T;
|
54
|
+
/**
|
55
|
+
* Serializes an entity to a JSON object.
|
56
|
+
*
|
57
|
+
* @template T - A type that extends ResponseDtoMapper.
|
58
|
+
* @template SV - A type that extends AnySchemaValidator.
|
59
|
+
* @param {DtoMapperConstructor<T, SV>} this - The constructor of the T.
|
60
|
+
* @param {SV} schemaValidator - The schema provider.
|
61
|
+
* @param {T['_Entity']} entity - The entity to serialize.
|
62
|
+
* @returns {T['_dto']} - The JSON object.
|
63
|
+
* @throws {Error} - Throws an error if the DTO is invalid.
|
64
|
+
*/
|
65
|
+
static serializeEntityToJson<T extends ResponseDtoMapper<BaseEntity, SV>, SV extends AnySchemaValidator>(this: DtoMapperConstructor<T, SV>, schemaValidator: SV, entity: T['_Entity']): T['_dto'];
|
66
|
+
}
|
67
|
+
//# sourceMappingURL=responseDtoMapper.model.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"responseDtoMapper.model.d.ts","sourceRoot":"","sources":["../../../../src/dtoMapper/models/responseDtoMapper.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,kDAAkD,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAa,MAAM,uBAAuB,CAAC;AAEjE;;;;;;GAMG;AACH,8BAAsB,iBAAiB,CACrC,MAAM,SAAS,UAAU,EACzB,EAAE,SAAS,kBAAkB,CAC7B,SAAQ,aAAa,CAAC,EAAE,CAAC;IACzB;;;;OAIG;IACH,OAAO,EAAG,MAAM,CAAC;IAEjB;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAEvE;;;;;OAKG;IACH,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;IAYtB;;;;;;OAMG;IACH,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAInD;;;;;;;;;OASG;IACH,MAAM,CAAC,UAAU,CACf,CAAC,SAAS,iBAAiB,CAAC,UAAU,EAAE,EAAE,CAAC,EAC3C,EAAE,SAAS,kBAAkB,EAE7B,IAAI,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,EACjC,eAAe,EAAE,EAAE,EACnB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,GACnB,CAAC;IAIJ;;;;;;;;;;OAUG;IACH,MAAM,CAAC,qBAAqB,CAC1B,CAAC,SAAS,iBAAiB,CAAC,UAAU,EAAE,EAAE,CAAC,EAC3C,EAAE,SAAS,kBAAkB,EAE7B,IAAI,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,EACjC,eAAe,EAAE,EAAE,EACnB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,GACnB,CAAC,CAAC,MAAM,CAAC;CAGb"}
|