UNPKG

@elsikora/nestjs-crud-automator

Version:

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

34 lines (30 loc) 1.34 kB
'use strict'; var classTransformer = require('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) { classTransformer.Exclude()(target, propertyKey); } else { classTransformer.Expose()(target, propertyKey); } Reflect.defineMetadata?.(AUTO_DTO_RESPONSE_EXPOSURE_METADATA_KEY, true, target, propertyKey); } exports.ApplyAutoDtoResponseExposure = ApplyAutoDtoResponseExposure; //# sourceMappingURL=apply-auto-dto-response-exposure.utility.js.map