/** * Base Retention Manager * * Abstract base class for retention managers that provides shared logic for: * - Age-based cleanup * - Size-based cleanup * - Count-based cleanup * - File compression * - Policy management * * Concrete implementations extend this for specific file types (logs, sessions, etc.) */ /** * Base interface for retention policies */ export interface BaseRetentionPolicy { compressAfterDays?: number; maxAgeDays?: number; maxCount?: number; maxSizeMB?: number; } /** * Base interface for cleanup results */ export interface BaseCleanupResult { compressedItems: string[]; deletedItems: string[]; errors: string[]; totalSizeAfter: number; totalSizeBefore: number; } /** * Base interface for file info */ export interface BaseFileInfo { filePath: string; isCompressed: boolean; modifiedTime: Date; size: number; } /** * Logger interface for retention operations */ export interface RetentionLogger { debug(message: string, context?: Record): void; error(message: string, error?: Error, context?: Record): void; info(message: string, context?: Record): void; warn(message: string, context?: Record): void; } /** * Abstract base class for retention managers */ export declare abstract class BaseRetentionManager { protected dryRun: boolean; protected abstract readonly logger: RetentionLogger; protected policy: TPolicy; constructor(policy: TPolicy, dryRun?: boolean); /** * Get the age of a file item in days. * Subclasses can override this to use custom date fields (e.g., session.updated_at). */ protected abstract getItemAgeDays(item: TFileInfo): number; /** * Get a display identifier for the file item (for logging). */ protected abstract getItemDisplayId(item: TFileInfo): string; /** * Delete a file item and any associated files (e.g., snapshots). */ protected abstract deleteItem(item: TFileInfo): Promise; /** * Record a deletion in the result. */ protected abstract recordDeletion(item: TFileInfo, result: TResult): void; /** * Record a compression in the result. */ protected abstract recordCompression(item: TFileInfo, result: TResult): void; /** * Compress a file using gzip * Shared implementation for both log and session files */ protected compressFile(filePath: string): Promise; /** * Compress a file with optional size logging */ protected compressFileWithStats(filePath: string): Promise<{ compressionRatio: number; savedBytes: number; }>; /** * Apply age-based cleanup: delete items older than maxAgeDays */ protected applyAgePolicy(items: TFileInfo[], result: TResult, getCutoffDate: () => Date): Promise; /** * Apply size-based cleanup: keep total size under maxSizeMB */ protected applySizePolicy(items: TFileInfo[], result: TResult): Promise; /** * Apply count-based cleanup: keep maximum maxCount items */ protected applyCountPolicy(items: TFileInfo[], result: TResult): Promise; /** * Apply compression policy: compress items older than compressAfterDays */ protected applyCompressionPolicy(items: TFileInfo[], result: TResult, getCutoffDate: () => Date): Promise; /** * Delete items with error handling */ protected deleteItemsWithErrorHandling(items: TFileInfo[], result: TResult, reason: string): Promise; /** * Update retention policy */ updatePolicy(policy: Partial): void; /** * Get current retention policy */ getPolicy(): TPolicy; /** * Set dry run mode */ setDryRun(dryRun: boolean): void; /** * Check if running in dry run mode */ isDryRun(): boolean; /** * Calculate cutoff date from days offset */ protected calculateCutoffDate(days: number): Date; /** * Calculate total size of items */ protected calculateTotalSize(items: TFileInfo[]): number; } //# sourceMappingURL=base-retention-manager.d.ts.map