/** * @angular-modernizer/plugin-angular - Interface Extraction Transformation Rule * * Transform rule that extracts inline interface types to named interfaces. * This is part of the modernization to improve code maintainability and reusability. * * Philosophy: "Thin Rule, Thick Orchestrator" * - The rule is a minimal wrapper * - All business logic lives in the orchestrator * - The rule handles the plugin protocol (TransformRule interface) */ import type { TransformRule, TransformContext, TransformResult } from '@angular-modernizer/plugin-system'; import type { PublicApi } from '@angular-modernizer/api'; /** * Transform rule for extracting inline interface types to named interfaces. * * @remarks * This rule implements the {@link TransformRule} interface and serves as the * bridge between the Angular Modernizer's plugin system and the interface * extraction orchestrator. It follows the "Thin Rule, Thick Orchestrator" pattern * where the rule handles protocol compliance while delegating all business logic * to the {@link InterfaceExtractionOrchestrator}. * * ## What It Does * * The rule orchestrates the conversion of: * - **Constructor parameters**: Extract inline types to named interfaces * - **Method parameters**: Extract complex inline types to interfaces * - **Method return types**: Extract inline return types to interfaces * - **Property types**: Extract inline property types to interfaces * * ## Example Usage * * This rule is typically not used directly, but rather accessed through the * {@link AngularPlugin}: * * ```typescript * const plugin = new AngularPlugin(); * const rules = plugin.getTransformRules(); * const rule = rules.find(r => r.id === 'angular:interface-extraction'); * const result = await rule.transform(context); * ``` * * ## Transformation Behavior * * **Constructor Parameters**: * ```typescript * // Before * constructor(private config: { apiUrl: string; timeout: number }) {} * * // After * interface Config { apiUrl: string; timeout: number; } * constructor(private config: Config) {} * ``` * * **Method Returns**: * ```typescript * // Before * getUser(): { name: string; email: string } { ... } * * // After * interface User { name: string; email: string; } * getUser(): User { ... } * ``` * * @see {@link InterfaceExtractionOrchestrator} for transformation logic * @see {@link TransformRule} for the interface contract * @see {@link AngularPlugin} for plugin integration * * @public */ export declare class InterfaceExtractionRule implements TransformRule { /** * Unique rule identifier. * Format: "plugin-name:rule-name" */ readonly id = "angular:interface-extraction"; /** * Human-readable rule name. */ readonly name = "Interface Extraction"; /** * Rule description. */ readonly description = "Extracts inline interface types to named interfaces for better code maintainability"; /** * Rule category for grouping. */ readonly category = "modernization"; /** * Tags for filtering and search. */ readonly tags: string[]; /** * The orchestrator that performs the actual transformation. */ private readonly orchestrator; /** * Transform a source file by extracting inline interface types to named interfaces. * * @remarks * This method implements the {@link TransformRule.transform} contract. * It delegates to the {@link InterfaceExtractionOrchestrator} for the actual * transformation work, then packages the result into a {@link TransformResult}. * * The method: * 1. Captures the file's initial state * 2. Invokes the orchestrator to perform the extraction * 3. Detects whether the file was modified * 4. Returns a standardized {@link TransformResult} * * ## Return Value * * The transform result includes: * - `modified`: Whether the file was changed * - `message`: A human-readable summary * - `filePath`: The path to the transformed file * - `ruleId`: This rule's identifier * * @param context - Transform context with file, project, and API access * * @returns Promise resolving to the transformation result * * @example * ```typescript * const rule = new InterfaceExtractionRule(); * const result = await rule.transform(context); * * if (result.modified) { * console.info(`Extracted interfaces: ${result.filePath}`); * } * ``` * * @public */ transform(context: TransformContext): Promise; } //# sourceMappingURL=interface-extraction.rule.d.ts.map