UNPKG

@elsikora/nestjs-crud-automator

Version:

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

32 lines (28 loc) 1.61 kB
'use strict'; var tslib_es6 = require('../../external/tslib/tslib.es6.js'); var uuid_decorator = require('../../decorator/api/property/uuid.decorator.js'); var camelCaseString_utility = require('../camel-case-string.utility.js'); var capitalizeString_utility = require('../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; } tslib_es6.__decorate([ uuid_decorator.ApiPropertyUUID({ entity, isResponse: true }), tslib_es6.__metadata("design:type", String) ], GeneratedRelationDTO.prototype, "id", void 0); Object.defineProperty(GeneratedRelationDTO, "name", { value: `${String(entity.name)}${camelCaseString_utility.CamelCaseString(method)}${camelCaseString_utility.CamelCaseString(dtoType)}${capitalizeString_utility.CapitalizeString(propertyName)}DTO` }); return GeneratedRelationDTO; } exports.DtoGenerateRelationResponse = DtoGenerateRelationResponse; //# sourceMappingURL=generate-relation-response.utility.js.map