@elsikora/nestjs-crud-automator
Version:
A library for automating the creation of CRUD operations in NestJS.
32 lines (28 loc) • 1.29 kB
JavaScript
;
var autoDtoContext_utility = require('../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 = autoDtoContext_utility.GetAutoDtoContext(target);
if (!context) {
return undefined;
}
resolvedMethod ??= context.method;
resolvedDtoType ??= context.dtoType;
}
if (!resolvedMethod || !resolvedDtoType) {
return undefined;
}
return { dtoType: resolvedDtoType, method: resolvedMethod };
}
exports.ResolveDecoratorContext = ResolveDecoratorContext;
//# sourceMappingURL=decorator-context.utility.js.map