/** * @angular-modernizer/plugin-angular - Dependency Injection Migration Orchestrator * * The central "brain" of the dependency injection migration transformation plugin. * Orchestrates the modernization of Angular dependency injection patterns. * * Philosophy: "API-Driven Orchestration" * - Receives all capabilities via TransformContext * - Uses PublicApi for all AST operations * - Stateless - no constructor dependencies * - Pure business logic, no low-level manipulation */ import type { TransformContext } from '@angular-modernizer/plugin-system'; import type { PublicApi } from '@angular-modernizer/api'; /** * Dependency Injection Migration Orchestrator * * @remarks * The central orchestrator for modernizing Angular dependency injection patterns. * This class demonstrates the "API-Driven Plugin" pattern where all capabilities * are received via context objects rather than constructor injection. * * ## Architecture Pattern * * This orchestrator follows three core principles: * 1. **Stateless Design** - No constructor dependencies * 2. **Context-Driven** - All capabilities injected via {@link TransformContext} * 3. **API-First** - Uses {@link PublicApi} for all AST operations * * ## Transformation Workflow * * The orchestrator performs the following steps: * 1. Detect deprecated DI patterns in the source file * 2. Transform string-based injection tokens to proper InjectionToken usage * 3. Update deprecated injector creation patterns * 4. Modernize provider configurations where applicable * 5. Ensure proper imports are in place * * ## Example Usage * * ```typescript * const orchestrator = new DependencyInjectionMigrationOrchestrator(); * const context = ContextFactory.createTransformContext({ * sourceFile, * project, * api, * config: {} * }); * orchestrator.run(context); * ``` * * @see {@link TransformContext} for context structure * @see {@link PublicApi} for available API tools * * @public */ export declare class DependencyInjectionMigrationOrchestrator { /** * Creates a new DependencyInjectionMigrationOrchestrator instance. * * @remarks * The constructor is intentionally stateless. All dependencies are provided * through the {@link TransformContext} passed to the {@link run} method. * This enables testing, composition, and prevents tight coupling. * * @public */ constructor(); /** * Executes the dependency injection migration transformation on a single source file. * * @remarks * This method is the main entry point for the orchestrator. It receives all * necessary dependencies (project, API, config) through the context parameter, * scans the file for deprecated DI patterns, and modernizes them. * * The method operates on one source file at a time and is safe to call * multiple times. It will: * - Find string-based @Inject() decorators and convert them to inject() calls * - Update deprecated ReflectiveInjector usage * - Modernize provider configurations * - Ensure proper imports are in place * * ## Transformation Behavior * * **String-based @Inject() Decorators**: * ```typescript * // Before * @Inject('API_URL') private apiUrl: string; * * // After * private apiUrl = inject(API_URL_TOKEN); * ``` * * **ReflectiveInjector Usage**: * ```typescript * // Before * const injector = ReflectiveInjector.resolveAndCreate([SomeService]); * * // After * const injector = Injector.create({ providers: [SomeService] }); * ``` * * @param context - The transformation context containing: * - `sourceFile`: The TypeScript source file to transform * - `project`: The ts-morph Project for cross-file analysis * - `api`: The PublicApi with analysis and transformation tools * - `config`: User-provided configuration options * * @example * ```typescript * // Basic usage * orchestrator.run(context); * * // With custom configuration * const context = ContextFactory.createTransformContext({ * sourceFile, * project, * api, * config: {} * }); * orchestrator.run(context); * ``` * * @see {@link TransformContext} for context structure * * @public */ run(context: TransformContext): void; /** * Transform @Inject() decorators with string tokens to inject() calls. * * @param sourceFile - The source file to transform * @param api - The PublicApi with transformation tools */ private transformInjectDecorators; /** * Convert an @Inject() decorator to an inject() call. * * @param property - The property declaration to transform * @param tokenValue - The string token value * @param api - The PublicApi with transformation tools */ private convertInjectDecoratorToInjectCall; /** * Get the token name for a string token value. * * @param tokenValue - The string token value * @returns The token variable name */ private getTokenName; /** * Transform ReflectiveInjector usage to modern Injector.create(). * * @param sourceFile - The source file to transform * @param api - The PublicApi with transformation tools */ private transformReflectiveInjectorUsage; /** * Convert ReflectiveInjector.resolveAndCreate() to Injector.create(). * * @param call - The call expression to transform * @param api - The PublicApi with transformation tools */ private convertReflectiveInjectorCall; /** * Transform provider configurations to modern syntax. * * @param sourceFile - The source file to transform * @param api - The PublicApi with transformation tools */ private transformProviderConfigurations; /** * Check if an array literal looks like a providers array. * * @param arrayLiteral - The array literal to check * @returns True if it looks like a providers array */ private isProvidersArray; /** * Modernize a providers array to use modern syntax. * * @param arrayLiteral - The providers array to modernize * @param api - The PublicApi with transformation tools */ private modernizeProvidersArray; /** * Ensure the inject function is imported from @angular/core. * * @param sourceFile - The source file to add the import to * @param api - The PublicApi with import management tools */ private ensureInjectImport; /** * Ensure the Injector is imported from @angular/core. * * @param sourceFile - The source file to add the import to * @param api - The PublicApi with import management tools */ private ensureInjectorImport; /** * Ensure modern provider-related imports are available. * * @param sourceFile - The source file to add imports to * @param api - The PublicApi with import management tools */ private ensureModernProviderImports; } //# sourceMappingURL=dependency-injection-migration-orchestrator.d.ts.map