/**
 * Health History & Trends Service
 *
 * Tracks health scores over time and calculates trends.
 *
 * @since v1.66.0
 */
import type { HealthGrade, PluginHealthScore, ServerHealthSummary } from './health-types.js';
/**
 * Time periods for trend calculation
 */
export type TrendPeriod = '24h' | '7d' | '30d' | '90d';
/**
 * Health history entry for a single plugin
 */
export interface PluginHealthHistoryEntry {
    /** Plugin ID */
    pluginId: string;
    /** Overall score at this point */
    score: number;
    /** Grade at this point */
    grade: HealthGrade;
    /** Component scores */
    components: {
        version: number;
        compatibility: number;
        maintenance: number;
        dependencies: number;
        security: number;
    };
    /** Number of issues */
    issueCount: number;
    /** Timestamp */
    timestamp: number;
}
/**
 * Server-wide health history entry
 */
export interface ServerHealthHistoryEntry {
    /** Overall server score */
    score: number;
    /** Server grade */
    grade: HealthGrade;
    /** Total plugins */
    totalPlugins: number;
    /** Count by status */
    byStatus: {
        healthy: number;
        warning: number;
        outdated: number;
        critical: number;
    };
    /** Total critical issues */
    criticalIssueCount: number;
    /** Timestamp */
    timestamp: number;
}
/**
 * Health trend information
 */
export interface HealthTrend {
    /** Current score */
    currentScore: number;
    /** Score at start of period */
    startScore: number;
    /** Score change */
    change: number;
    /** Percentage change */
    changePercent: number;
    /** Trend direction */
    direction: 'improving' | 'declining' | 'stable';
    /** Period analyzed */
    period: TrendPeriod;
    /** Sparkline data (normalized 0-1) */
    sparkline: number[];
    /** Number of data points */
    dataPoints: number;
}
/**
 * Health event (significant change)
 */
export interface HealthEvent {
    /** Event ID */
    id: string;
    /** Event type */
    type: 'score_change' | 'issue_detected' | 'issue_resolved' | 'plugin_added' | 'plugin_removed' | 'update_applied';
    /** Plugin ID (if applicable) */
    pluginId?: string;
    /** Plugin name */
    pluginName?: string;
    /** Description */
    description: string;
    /** Score impact */
    scoreImpact?: number;
    /** Timestamp */
    timestamp: number;
}
/**
 * Complete health history
 */
export interface HealthHistory {
    /** Plugin histories */
    plugins: Map<string, PluginHealthHistoryEntry[]>;
    /** Server history */
    server: ServerHealthHistoryEntry[];
    /** Events */
    events: HealthEvent[];
    /** When history was last updated */
    lastUpdated: number;
}
/**
 * Health history configuration
 */
export interface HealthHistoryConfig {
    /** Maximum history duration in days */
    maxHistoryDays: number;
    /** Sample interval in hours */
    sampleIntervalHours: number;
    /** Maximum samples to keep */
    maxSamples: number;
    /** Significant change threshold (for events) */
    significantChangeThreshold: number;
}
/**
 * Default history configuration
 */
export declare const DEFAULT_HISTORY_CONFIG: HealthHistoryConfig;
/**
 * Get milliseconds for a period
 */
export declare function getPeriodMs(period: TrendPeriod): number;
/**
 * Calculate trend from history entries
 */
export declare function calculateTrend(entries: Array<{
    score: number;
    timestamp: number;
}>, period: TrendPeriod): HealthTrend;
/**
 * Health History Service
 */
export declare class HealthHistoryService {
    private history;
    private config;
    constructor(config?: HealthHistoryConfig);
    /**
     * Get current configuration
     */
    getConfig(): HealthHistoryConfig;
    /**
     * Record plugin health scores
     */
    recordPluginScores(scores: PluginHealthScore[]): void;
    /**
     * Record server health summary
     */
    recordServerSummary(summary: ServerHealthSummary): void;
    /**
     * Add a health event
     */
    addEvent(event: HealthEvent): void;
    /**
     * Get plugin health trend
     */
    getPluginTrend(pluginId: string, period?: TrendPeriod): HealthTrend | null;
    /**
     * Get server health trend
     */
    getServerTrend(period?: TrendPeriod): HealthTrend;
    /**
     * Get plugin history
     */
    getPluginHistory(pluginId: string, period?: TrendPeriod): PluginHealthHistoryEntry[];
    /**
     * Get server history
     */
    getServerHistory(period?: TrendPeriod): ServerHealthHistoryEntry[];
    /**
     * Get recent events
     */
    getEvents(limit?: number, period?: TrendPeriod): HealthEvent[];
    /**
     * Get plugin events
     */
    getPluginEvents(pluginId: string, limit?: number): HealthEvent[];
    /**
     * Get all plugins with trends
     */
    getAllPluginTrends(period?: TrendPeriod): Map<string, HealthTrend>;
    /**
     * Get plugins with declining health
     */
    getDecliningPlugins(period?: TrendPeriod, threshold?: number): string[];
    /**
     * Get plugins with improving health
     */
    getImprovingPlugins(period?: TrendPeriod, threshold?: number): string[];
    /**
     * Prune old history entries
     */
    private pruneHistory;
    /**
     * Export history for persistence
     */
    exportHistory(): {
        plugins: Array<[string, PluginHealthHistoryEntry[]]>;
        server: ServerHealthHistoryEntry[];
        events: HealthEvent[];
        lastUpdated: number;
    };
    /**
     * Import history from persistence
     */
    importHistory(data: ReturnType<HealthHistoryService['exportHistory']>): void;
    /**
     * Clear all history
     */
    clearHistory(): void;
}
/**
 * Create a health history service instance
 */
export declare function createHealthHistoryService(config?: HealthHistoryConfig): HealthHistoryService;
/**
 * Generate ASCII sparkline from data
 */
export declare function generateSparkline(data: number[], width?: number): string;
//# sourceMappingURL=health-history.d.ts.map