UNPKG

@elsikora/nestjs-crud-automator

Version:

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

30 lines (27 loc) 1.22 kB
import { GetAutoDtoContext } from '../get/auto-dto-context.utility.js'; /** * Resolves decorator context using explicit config or auto-propagated DTO metadata. * @param {object} target - Decorated DTO prototype. * @param {EApiRouteType | undefined} method - Explicit method override. * @param {EApiDtoType | undefined} dtoType - Explicit DTO type override. * @param {boolean} shouldAutoResolve - Whether to pull context from auto DTO pipeline. * @returns {{ dtoType: EApiDtoType; method: EApiRouteType } | undefined} Resolved context if available. */ function ResolveDecoratorContext(target, method, dtoType, shouldAutoResolve) { let resolvedMethod = method; let resolvedDtoType = dtoType; if (shouldAutoResolve && (!resolvedMethod || !resolvedDtoType)) { const context = GetAutoDtoContext(target); if (!context) { return undefined; } resolvedMethod ??= context.method; resolvedDtoType ??= context.dtoType; } if (!resolvedMethod || !resolvedDtoType) { return undefined; } return { dtoType: resolvedDtoType, method: resolvedMethod }; } export { ResolveDecoratorContext }; //# sourceMappingURL=decorator-context.utility.js.map