/** * Content Change Tracker - Persistent tracking of website content changes * * Provides: * - Persistent fingerprint storage using PersistentStore * - URL tracking with change history * - Change detection with detailed reports * - Alert support for content changes * * Part of F-003: Content Change Detection Alerts */ import { type ContentFingerprint, type ChangeReport } from './change-detector.js'; import { type DiffResult, type DiffOptions, type DiffStats } from './diff-generator.js'; /** * A tracked URL with its fingerprint and metadata */ export interface TrackedUrl { /** The URL being tracked */ url: string; /** Domain extracted from URL */ domain: string; /** Current content fingerprint */ fingerprint: ContentFingerprint; /** When tracking started */ trackedSince: number; /** Last check timestamp */ lastChecked: number; /** Number of times checked */ checkCount: number; /** Number of times content changed */ changeCount: number; /** Optional label for this tracked URL */ label?: string; /** Optional tags for categorization */ tags?: string[]; } /** * A record of a content change */ export interface ChangeRecord { /** The URL that changed */ url: string; /** When the change was detected */ timestamp: number; /** Previous fingerprint */ previousFingerprint: ContentFingerprint; /** New fingerprint */ newFingerprint: ContentFingerprint; /** Significance of the change */ significance: 'low' | 'medium' | 'high'; /** Summary of the change */ summary: string; /** Number of sections added */ sectionsAdded: number; /** Number of sections removed */ sectionsRemoved: number; /** Number of sections modified */ sectionsModified: number; /** Diff statistics (added in F-010) */ diffStats?: DiffStats; } /** * Result of generating a diff between content versions */ export interface ContentDiffResult { /** The URL being compared */ url: string; /** Whether there are any changes */ hasChanges: boolean; /** Unified diff format string (like git diff) */ unifiedDiff: string; /** Summary of changes */ summary: string; /** Detailed statistics */ stats: DiffStats; /** Full diff result for advanced usage */ fullDiff: DiffResult; } /** * Options for tracking a URL */ export interface TrackUrlOptions { /** Optional label for the tracked URL */ label?: string; /** Optional tags for categorization */ tags?: string[]; } /** * Result of checking for content changes */ export interface CheckResult { /** Whether the URL is being tracked */ isTracked: boolean; /** Whether content has changed since last check */ hasChanged: boolean; /** Full change report if content changed */ changeReport?: ChangeReport; /** The tracked URL info */ trackedUrl?: TrackedUrl; /** Whether this is the first check (no previous fingerprint) */ isFirstCheck: boolean; } /** * Statistics about tracked URLs */ export interface TrackerStats { /** Total number of tracked URLs */ totalTracked: number; /** Number of URLs with at least one change */ urlsWithChanges: number; /** Total changes detected */ totalChanges: number; /** Changes by significance */ changesBySignificance: { low: number; medium: number; high: number; }; /** Most recently changed URLs */ recentChanges: Array<{ url: string; timestamp: number; significance: 'low' | 'medium' | 'high'; }>; } /** * Configuration for ContentChangeTracker */ export interface ContentChangeTrackerConfig { /** Maximum history entries to keep (default: 1000) */ maxHistoryEntries: number; /** Storage file path */ storagePath: string; } /** * ContentChangeTracker - Tracks content changes across URLs persistently */ export declare class ContentChangeTracker { private store; private data; private config; private initialized; constructor(config?: Partial); /** * Initialize the tracker by loading stored data */ initialize(): Promise; /** * Extract domain from URL */ private extractDomain; /** * Track a URL for content changes * * @param url - The URL to track * @param content - Current content of the page * @param options - Optional tracking options * @returns The tracked URL info */ trackUrl(url: string, content: string, options?: TrackUrlOptions): Promise; /** * Check if tracked content has changed * * @param url - The URL to check * @param currentContent - Current content of the page * @returns Check result with change details */ checkForChanges(url: string, currentContent: string): Promise; /** * Check for changes with full content comparison * * @param url - The URL to check * @param previousContent - Previous content for detailed comparison * @param currentContent - Current content * @returns Check result with detailed change report */ checkWithDetailedComparison(url: string, previousContent: string, currentContent: string): Promise; /** * Generate a change summary based on fingerprints */ private generateChangeSummary; /** * Stop tracking a URL * * @param url - The URL to stop tracking * @returns Whether the URL was being tracked */ untrackUrl(url: string): Promise; /** * Get a tracked URL's info * * @param url - The URL to get info for * @returns The tracked URL info or undefined */ getTrackedUrl(url: string): Promise; /** * List all tracked URLs * * @param options - Filter options * @returns Array of tracked URLs */ listTrackedUrls(options?: { domain?: string; tags?: string[]; hasChanges?: boolean; limit?: number; offset?: number; }): Promise; /** * Get change history for a URL or all URLs * * @param url - Optional URL to filter by * @param limit - Maximum entries to return * @returns Array of change records */ getChangeHistory(url?: string, limit?: number): Promise; /** * Get tracker statistics */ getStats(): Promise; /** * Clear all tracking data */ clear(): Promise; /** * Check if a URL is being tracked */ isTracking(url: string): Promise; /** * Get URLs by domain */ getUrlsByDomain(domain: string): Promise; /** * Flush pending writes */ flush(): Promise; /** * Generate a line-by-line diff between two content versions * * This is the main method for F-010: Diff Generation. * It provides a unified diff format (like git diff) showing exactly what changed. * * @param oldContent - Previous content * @param newContent - Current content * @param url - URL for labeling (optional) * @param options - Diff generation options * @returns ContentDiffResult with unified diff and statistics */ generateDiff(oldContent: string, newContent: string, url?: string, options?: DiffOptions): ContentDiffResult; /** * Check for changes and generate a diff if content has changed * * Combines change detection with diff generation for a complete * before/after comparison. * * @param url - The URL to check * @param previousContent - Previous content for comparison * @param currentContent - Current content * @param diffOptions - Options for diff generation * @returns Check result with optional diff */ checkAndDiff(url: string, previousContent: string, currentContent: string, diffOptions?: DiffOptions): Promise; /** * Save data to persistent storage */ private save; } /** * Get the global ContentChangeTracker instance */ export declare function getContentChangeTracker(config?: Partial): ContentChangeTracker; /** * Create a new ContentChangeTracker instance (for testing) */ export declare function createContentChangeTracker(config?: Partial): ContentChangeTracker; //# sourceMappingURL=content-change-tracker.d.ts.map