UNPKG

@elsikora/nestjs-crud-automator

Version:

A library for automating the creation of CRUD operations in NestJS.

30 lines (26 loc) 1.6 kB
'use strict'; var constant = require('../../constant/utility/dto/constant.js'); var errorException_utility = require('../error-exception.utility.js'); /** * Factory function that generates appropriate property decorators based on property type. * Uses factories defined in DTO_UTILITY_CONSTANT to create the correct decorator for each property type. * @param {TApiPropertyDescribeProperties} metadata - Metadata describing the property * @param {IApiEntity<E>} entity - The entity metadata * @param {TApiPropertyDescribeDtoProperties} config - Configuration for the decorator * @param {EApiRouteType} method - The API route type (CREATE, DELETE, GET, etc.) * @param {EApiDtoType} dtoType - The type of DTO (REQUEST, RESPONSE, etc.) * @param {string} propertyName - The name of the property * @param {Record<string, Type<unknown>>} [generatedDTOs] - Optional record of dynamically generated DTOs * @returns {PropertyDecorator} The generated property decorator * @throws {Error} When property type has no registered factory * @template E - The entity type */ function DtoGenerateDecorator(metadata, entity, config, method, dtoType, propertyName, generatedDTOs) { const factory = constant.DTO_UTILITY_CONSTANT.PROPERTY_DECORATOR_FACTORIES[metadata.type]; if (!factory) { throw errorException_utility.ErrorException(`Unknown property type ${metadata.type}`); } return factory.create(metadata, entity, config, method, dtoType, propertyName, generatedDTOs); } exports.DtoGenerateDecorator = DtoGenerateDecorator; //# sourceMappingURL=generate-decorator.utility.js.map