/** * @angular-modernizer/plugin-angular - Promise Service to Observable Transform Rule * * Thin rule wrapper. All logic in PromiseServiceTransformOrchestrator. */ import type { TransformRule, TransformContext, TransformResult, } from '@angular-modernizer/plugin-system'; import type { PublicApi } from '@angular-modernizer/api'; import { PromiseServiceTransformOrchestrator } from '../orchestrators/promise-service-transform.orchestrator.js'; export class PromiseServiceTransformRule implements TransformRule { public readonly id = 'angular:promise-service-to-observable'; public readonly name = 'Promise Service to Observable Transform'; public readonly description = 'Transforms @Injectable service methods from Promise to Observable, adding retry and error handling'; public readonly category = 'refactoring'; public readonly tags = [ 'angular', 'rxjs', 'observable', 'promise', 'services', 'http', ]; private readonly orchestrator = new PromiseServiceTransformOrchestrator(); async transform( context: TransformContext, ): Promise { const pluginConfig = context.config[ '@angular-modernizer/plugin-angular' ] as Record | undefined; if ( pluginConfig?.['transformationType'] !== 'promise-service-to-observable' ) { return { ruleId: this.id, modified: false, message: 'Transformation type not applicable', filePath: context.filePath, }; } const options = (pluginConfig?.['options'] as Record) ?? {}; return this.orchestrator.run(context, { methodName: options['methodName'] as string | undefined, transformAll: (options['transformAll'] as boolean | undefined) ?? false, }); } }