/**
 * Configuration File Updater System
 * Phase 4, Checkpoint D2 - Safe configuration file modification with rollback support
 */
import { UserChoice, ConfigurationPrompt } from './interactive-configuration';
import { SchemaChange } from './schema-evolution';
export interface ConfigurationUpdate {
    id: string;
    filePath: string;
    updateType: 'add' | 'modify' | 'remove' | 'replace' | 'create';
    targetSection: string;
    changes: ConfigurationChange[];
    metadata: {
        triggeredBy: string;
        timestamp: Date;
        backupPath?: string;
        checksum: string;
        estimatedRisk: 'LOW' | 'MEDIUM' | 'HIGH';
    };
}
export interface ConfigurationChange {
    path: string;
    operation: 'set' | 'push' | 'splice' | 'delete' | 'merge';
    oldValue?: any;
    newValue?: any;
    context?: {
        before?: string;
        after?: string;
        indentation?: string;
    };
}
export interface UpdateResult {
    success: boolean;
    updatedFiles: string[];
    errors: UpdateError[];
    warnings: UpdateWarning[];
    rollbackPlan: RollbackAction[];
    metadata: {
        totalChanges: number;
        executionTime: number;
        filesModified: number;
        backupsCreated: number;
    };
}
export interface UpdateError {
    code: string;
    message: string;
    filePath: string;
    severity: 'error' | 'critical';
    context?: any;
}
export interface UpdateWarning {
    code: string;
    message: string;
    filePath: string;
    impact: 'low' | 'medium' | 'high';
    recommendation?: string;
}
export interface RollbackAction {
    type: 'restore_file' | 'undo_changes' | 'delete_file' | 'recreate_backup';
    filePath: string;
    backupPath?: string;
    changes?: ConfigurationChange[];
    order: number;
}
export interface FileProcessor {
    name: string;
    supportedExtensions: string[];
    canProcess: (filePath: string) => boolean;
    parse: (content: string) => any;
    stringify: (data: any, options?: any) => string;
    applyChanges: (data: any, changes: ConfigurationChange[]) => any;
    validate: (data: any) => {
        isValid: boolean;
        errors: string[];
    };
}
export interface ConfigurationTemplate {
    id: string;
    name: string;
    description: string;
    targetFiles: string[];
    variables: TemplateVariable[];
    generate: (variables: Record<string, any>) => Record<string, any>;
}
export interface TemplateVariable {
    name: string;
    type: 'string' | 'number' | 'boolean' | 'array' | 'object';
    description: string;
    defaultValue?: any;
    required: boolean;
    validation?: {
        pattern?: string;
        min?: number;
        max?: number;
        options?: any[];
    };
}
export declare class ConfigurationFileUpdater {
    private fileProcessors;
    private templates;
    private updateHistory;
    private backupDirectory;
    constructor(backupDirectory?: string);
    /**
     * Apply a batch of configuration updates based on user choices
     */
    applyUpdates(choices: UserChoice[], prompts: ConfigurationPrompt[], schemaChanges: SchemaChange[]): Promise<UpdateResult>;
    /**
     * Apply a single configuration update
     */
    applyUpdate(update: ConfigurationUpdate): Promise<{
        success: boolean;
        errors: UpdateError[];
        warnings: UpdateWarning[];
        rollbackActions: RollbackAction[];
    }>;
    /**
     * Rollback configuration changes
     */
    rollbackUpdates(rollbackPlan: RollbackAction[]): Promise<{
        success: boolean;
        errors: string[];
        restoredFiles: string[];
    }>;
    /**
     * Create configuration from template
     */
    createFromTemplate(templateId: string, variables: Record<string, any>, targetDirectory?: string): Promise<{
        success: boolean;
        createdFiles: string[];
        errors: string[];
    }>;
    /**
     * Get update history
     */
    getUpdateHistory(): ConfigurationUpdate[];
    /**
     * Clear update history
     */
    clearUpdateHistory(): void;
    /**
     * Add custom file processor
     */
    addFileProcessor(processor: FileProcessor): void;
    /**
     * Add configuration template
     */
    addTemplate(template: ConfigurationTemplate): void;
    /**
     * Private: Initialize built-in file processors
     */
    private initializeFileProcessors;
    /**
     * Private: Initialize configuration templates
     */
    private initializeTemplates;
    /**
     * Private: Generate update from configuration action
     */
    private generateUpdate;
    /**
     * Private: Get appropriate file processor
     */
    private getFileProcessor;
    /**
     * Private: Create backup of file
     */
    private createBackup;
    /**
     * Private: Calculate file checksum
     */
    private calculateChecksum;
    /**
     * Private: Ensure backup directory exists
     */
    private ensureBackupDirectory;
    /**
     * Private: Validate template variables
     */
    private validateTemplateVariables;
}
//# sourceMappingURL=config-file-updater.d.ts.map