UNPKG

@elsikora/nestjs-crud-automator

Version:

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

30 lines (27 loc) 1.46 kB
import { __decorate, __metadata } from '../../external/tslib/tslib.es6.js'; import { ApiPropertyUUID } from '../../decorator/api/property/uuid.decorator.js'; import { CamelCaseString } from '../camel-case-string.utility.js'; import { CapitalizeString } from '../capitalize-string.utility.js'; /** * Creates a simple relationship DTO containing only an ID field. * Used for representing related entities in API responses with minimal information. * @param {IApiEntity<E>} entity - The entity metadata * @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 relation property * @returns {Type<unknown>} A generated DTO class for relation representation * @template E - The entity type */ function DtoGenerateRelationResponse(entity, method, dtoType, propertyName) { class GeneratedRelationDTO { id; } __decorate([ ApiPropertyUUID({ entity, isResponse: true }), __metadata("design:type", String) ], GeneratedRelationDTO.prototype, "id", void 0); Object.defineProperty(GeneratedRelationDTO, "name", { value: `${String(entity.name)}${CamelCaseString(method)}${CamelCaseString(dtoType)}${CapitalizeString(propertyName)}DTO` }); return GeneratedRelationDTO; } export { DtoGenerateRelationResponse }; //# sourceMappingURL=generate-relation-response.utility.js.map