/** * @angular-modernizer/plugin-angular - Architecture Types * * Type definitions for architectural analysis and dependency management. */ export interface DependencyNode { /** Module/file path */ path: string; /** Layer this module belongs to */ layer: ArchitectureLayer; /** Dependencies this module imports */ dependencies: DependencyEdge[]; /** Modules that import this module */ dependents: string[]; /** Type of module */ type: ModuleType; } export interface DependencyEdge { /** Target module path */ target: string; /** Type of import */ importType: ImportType; /** Import statement location */ location: { file: string; line: number; column: number; }; /** Imported symbols */ symbols: string[]; } export enum ArchitectureLayer { // Generic architectural layers (framework-agnostic) FOUNDATION = 'foundation', // Core utilities, singletons, base infrastructure DOMAIN = 'domain', // Business logic, domain models, business rules APPLICATION = 'application', // Application services, use cases, orchestrators INFRASTRUCTURE = 'infrastructure', // External dependencies, data access, frameworks PRESENTATION = 'presentation', // UI components, controllers, views SHARED = 'shared', // Cross-cutting concerns, common utilities // Framework-specific layers (can be mapped to generic ones) CORE = 'core', // Alias for FOUNDATION (Angular-specific) FEATURES = 'features', // Feature modules (Angular-specific) MAIN = 'main', // Main app infrastructure (Angular-specific) OFFLINE = 'offline', // Offline/PWA functionality (Angular-specific) // Additional generic layers CONFIGURATION = 'configuration', // Configuration, environment settings TESTING = 'testing', // Test utilities, mocks, test infrastructure } export enum ModuleType { COMPONENT = 'component', SERVICE = 'service', DIRECTIVE = 'directive', PIPE = 'pipe', MODULE = 'module', MODEL = 'model', UTILITY = 'utility', CONFIG = 'config', } export enum ImportType { RELATIVE = 'relative', // ./ or ../ imports ABSOLUTE = 'absolute', // @core/, @shared/, etc. BARREL = 'barrel', // index.ts exports DYNAMIC = 'dynamic', // import() statements TYPE_ONLY = 'type-only', // import type statements } export interface ArchitectureViolation { /** Violation type */ type: ViolationType; /** Source module */ source: string; /** Target module */ target: string; /** Severity level */ severity: 'error' | 'warning' | 'info'; /** Description of the violation */ description: string; /** Suggested fix */ suggestedFix: string; /** Location of the violation */ location: { file: string; line: number; column: number; }; /** Additional metadata */ metadata?: Record; } export enum ViolationType { // Layer boundary violations LAYER_VIOLATION = 'layer-violation', CIRCULAR_DEPENDENCY = 'circular-dependency', // SOLID principle violations GOD_OBJECT = 'god-object', SINGLE_RESPONSIBILITY = 'single-responsibility', OPEN_CLOSED = 'open-closed', // Service pattern violations DIRECT_INSTANTIATION = 'direct-instantiation', MISSING_INTERFACE = 'missing-interface', SERVICE_LOCATOR = 'service-locator', // Component pattern violations DUMB_SMART_VIOLATION = 'dumb-smart-violation', SMART_DUMB_VIOLATION = 'smart-dumb-violation', // Other architectural issues TIGHT_COUPLING = 'tight-coupling', MISSING_ABSTRACTION = 'missing-abstraction', } export interface MigrationPlan { /** Plan identifier */ id: string; /** Description of the migration */ description: string; /** Violations this plan addresses */ violations: ArchitectureViolation[]; /** Steps to execute the migration */ steps: MigrationStep[]; /** Estimated effort */ effort: 'low' | 'medium' | 'high' | 'critical'; /** Risk level */ risk: 'low' | 'medium' | 'high'; /** Prerequisites for this migration */ prerequisites: string[]; } export interface MigrationStep { /** Step description */ description: string; /** Type of operation */ type: | 'create-interface' | 'move-file' | 'update-imports' | 'create-service' | 'refactor-class'; /** Files affected */ affectedFiles: string[]; /** Code changes required */ changes: CodeChange[]; } export interface CodeChange { /** File to modify */ file: string; /** Type of change */ type: 'add' | 'remove' | 'replace'; /** Location in file */ location: { startLine: number; startColumn: number; endLine?: number; endColumn?: number; }; /** New content */ content: string; /** Old content (for replace operations) */ oldContent?: string; } export interface ArchitectureConfig { /** Layer definitions */ // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style layers: Partial<{ [key in ArchitectureLayer]: { /** Allowed to import from these layers */ canImportFrom: ArchitectureLayer[]; /** Path patterns for this layer */ pathPatterns: string[]; /** Module types allowed in this layer */ allowedTypes: ModuleType[]; }; }>; /** Boundary rules */ boundaries: { /** Maximum circular dependency depth allowed */ maxCircularDepth: number; /** Maximum class size (methods) */ maxClassSize: number; /** Maximum service dependencies */ maxServiceDependencies: number; }; }