UNPKG

@elsikora/nestjs-crud-automator

Version:

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

32 lines (29 loc) 1.26 kB
import { Exclude, Expose } from 'class-transformer'; const AUTO_DTO_RESPONSE_EXPOSURE_METADATA_KEY = "crud-automator:auto-dto-response-exposure"; /** * Applies class-transformer exposure to neutral manual DTO properties without marking them * as Swagger response-only fields. * * Explicit response-only properties (`isResponse: true`) still rely on the decorator-specific * response branch that uses `ApiResponseProperty()`. * @param {object} target - Decorated DTO prototype. * @param {string | symbol} propertyKey - Decorated property key. * @param {TApiPropertyBaseProperties} properties - Crud-automator property options. */ function ApplyAutoDtoResponseExposure(target, propertyKey, properties) { if (!target || properties.isResponse !== undefined) { return; } if (Reflect.getMetadata?.(AUTO_DTO_RESPONSE_EXPOSURE_METADATA_KEY, target, propertyKey)) { return; } if (properties.isExpose === false) { Exclude()(target, propertyKey); } else { Expose()(target, propertyKey); } Reflect.defineMetadata?.(AUTO_DTO_RESPONSE_EXPOSURE_METADATA_KEY, true, target, propertyKey); } export { ApplyAutoDtoResponseExposure }; //# sourceMappingURL=apply-auto-dto-response-exposure.utility.js.map