/** * Dynamic Refresh Scheduler (INT-008) * * Provides intelligent refresh scheduling for government content based on observed * update patterns. Replaces fixed staleness thresholds (e.g., 90 days) with dynamic * schedules learned from actual content changes. * * Features: * - Content type presets (regulations, fees, forms, etc.) * - Domain-specific pattern learning * - Optimal refresh interval recommendations * - Government-specific update patterns (fiscal years, legislative sessions) * * @example * ```typescript * const scheduler = new DynamicRefreshScheduler(); * * // Record content observation * scheduler.recordContentCheck( * 'https://exteriores.gob.es/es/ServiciosAlCiudadano/Paginas/NIE.aspx', * 'abc123hash', * true, // content changed * 'government_forms' * ); * * // Get refresh recommendation * const schedule = scheduler.getRefreshSchedule( * 'https://exteriores.gob.es/es/ServiciosAlCiudadano/Paginas/NIE.aspx' * ); * console.log(schedule.recommendedRefreshHours); // e.g., 168 (weekly) * console.log(schedule.nextCheckAt); // timestamp * ``` */ import { ContentChangePredictor } from './content-change-predictor.js'; import type { ContentChangePattern, ContentChangeAnalysis, PollRecommendation, ContentChangePredictionConfig } from '../types/content-change.js'; /** * Content type presets for government content */ export type GovernmentContentType = 'regulations' | 'fees' | 'forms' | 'requirements' | 'procedures' | 'contact_info' | 'news' | 'deadlines' | 'portal_status'; /** * Preset configuration for a content type */ export interface ContentTypePreset { /** Content type identifier */ type: GovernmentContentType; /** Default refresh interval in hours if no pattern detected */ defaultRefreshHours: number; /** Minimum refresh interval in hours */ minRefreshHours: number; /** Maximum refresh interval in hours */ maxRefreshHours: number; /** Expected update pattern description */ expectedPattern: string; /** Typical update triggers */ updateTriggers: string[]; } /** * Presets for different government content types */ export declare const CONTENT_TYPE_PRESETS: Record; /** * Domain-specific update patterns for known government portals */ export interface DomainPattern { /** Domain name pattern (regex) */ domainPattern: string; /** Country code */ country: string; /** Default content type for this domain */ defaultContentType: GovernmentContentType; /** Known update schedule */ knownSchedule?: string; /** Fiscal year start month (1-12) */ fiscalYearStartMonth?: number; } /** * Known domain patterns for government portals */ export declare const KNOWN_DOMAIN_PATTERNS: DomainPattern[]; /** * Refresh schedule result */ export interface RefreshSchedule { /** URL being scheduled */ url: string; /** Domain extracted from URL */ domain: string; /** Detected or inferred content type */ contentType: GovernmentContentType; /** Recommended refresh interval in hours */ recommendedRefreshHours: number; /** Recommended refresh interval in milliseconds */ recommendedRefreshMs: number; /** Next recommended check timestamp */ nextCheckAt: number; /** Confidence in the schedule (0-1) */ confidence: number; /** Whether this is based on learned patterns */ isLearned: boolean; /** Reason for this schedule */ reason: string; /** Underlying pattern analysis (if available) */ pattern?: ContentChangePattern; /** Preset used (if applicable) */ preset?: ContentTypePreset; /** Domain pattern match (if applicable) */ domainMatch?: DomainPattern; } /** * Configuration for DynamicRefreshScheduler */ export interface DynamicRefreshSchedulerConfig { /** ContentChangePredictor configuration */ predictorConfig?: Partial; /** Whether to use domain pattern hints */ useDomainPatterns: boolean; /** Whether to apply content type presets */ useContentTypePresets: boolean; /** Default content type if not detected */ defaultContentType: GovernmentContentType; } /** * URL content tracking entry */ interface UrlTracking { url: string; domain: string; urlPattern: string; contentType: GovernmentContentType; lastContentHash?: string; lastCheckAt: number; checkCount: number; changeCount: number; } /** * Dynamic Refresh Scheduler * * Provides intelligent refresh scheduling for government content. */ export declare class DynamicRefreshScheduler { private predictor; private config; private urlTracking; constructor(config?: Partial); /** * Record a content check observation */ recordContentCheck(url: string, contentHash: string, changed: boolean, contentType?: GovernmentContentType): RefreshSchedule; /** * Get refresh schedule for a URL */ getRefreshSchedule(url: string, contentType?: GovernmentContentType): RefreshSchedule; /** * Check if a URL should be refreshed now */ shouldRefreshNow(url: string, contentType?: GovernmentContentType): PollRecommendation; /** * Get all tracked URLs with their schedules */ getAllSchedules(): RefreshSchedule[]; /** * Get URLs that need refresh now */ getUrlsNeedingRefresh(): Array<{ url: string; schedule: RefreshSchedule; recommendation: PollRecommendation; }>; /** * Export patterns for persistence */ exportPatterns(): { patterns: Record; tracking: Array; }; /** * Import patterns from persistence */ importPatterns(data: { patterns: Record; tracking?: Array; }): void; /** * Get content type preset */ getPreset(contentType: GovernmentContentType): ContentTypePreset; /** * Get all presets */ getAllPresets(): ContentTypePreset[]; /** * Get pattern analysis for a URL */ analyzeUrl(url: string): ContentChangeAnalysis; /** * Parse URL into domain and pattern */ private parseUrl; /** * Detect content type from URL and domain */ private detectContentType; /** * Match domain against known patterns */ private matchDomain; private matchesNewsPattern; private matchesFeePattern; private matchesFormPattern; private matchesRegulationPattern; private matchesProcedurePattern; private matchesContactPattern; private matchesDeadlinePattern; private matchesStatusPattern; } /** * Create a DynamicRefreshScheduler instance */ export declare function createDynamicRefreshScheduler(config?: Partial): DynamicRefreshScheduler; export { ContentChangePredictor }; export type { ContentChangePattern, ContentChangeAnalysis, PollRecommendation, ContentChangePredictionConfig, }; //# sourceMappingURL=dynamic-refresh-scheduler.d.ts.map