/** * @angular-modernizer/plugin-angular - Missing Output Transform Rule * * Thin rule wrapper. All logic in MissingOutputTransformOrchestrator. */ import type { TransformRule, TransformContext, TransformResult, } from '@angular-modernizer/plugin-system'; import type { PublicApi } from '@angular-modernizer/api'; import { MissingOutputTransformOrchestrator } from '../orchestrators/missing-output-transform.orchestrator.js'; /** * Transform rule that adds output() signals to presentational component methods * that currently call services directly, and replaces those service calls with * event emissions. * * Activated via transformationType: 'missing-output-transform' in plugin config. * * @example * // BEFORE * delete() { this.userService.deleteUser(this.user.id); } * * // AFTER * deleteClick = output(); * delete() { this.deleteClick.emit(this.user.id); } * * @see MissingOutputTransformOrchestrator */ export class MissingOutputTransformRule implements TransformRule { public readonly id = 'angular:missing-output-transform'; public readonly name = 'Missing Output Transform'; public readonly description = 'Adds output() signals for methods calling services directly in presentational components'; public readonly category = 'angular-architecture'; public readonly tags = [ 'angular', 'architecture', 'presentational', 'output', 'refactoring', ]; private readonly orchestrator = new MissingOutputTransformOrchestrator(); async transform( context: TransformContext, ): Promise { const pluginConfig = context.config[ '@angular-modernizer/plugin-angular' ] as Record | undefined; if (pluginConfig?.['transformationType'] !== 'missing-output-transform') { return { ruleId: this.id, modified: false, message: 'Transformation type not applicable', filePath: context.filePath, }; } return this.orchestrator.run(context); } }