import type { Nullable } from "../types/index.js"; type HealthStatus = "failed" | "success"; /** * Event payload emitted when channel health or provider auth state changes. */ export interface HealthEvent { channelKey: string; providerTag: string; status: HealthStatus; timestamp: number; } /** * Snapshot of current health state for SSE initial payload. */ export interface HealthSnapshot { channels: Record; providers: Record; } /** * Loads the health state from health.json into memory. Entries older than HEALTH_TTL are pruned during loading. Called once at startup from app.ts. */ export declare function loadHealthState(): Promise; /** * Records a successful tune for a channel. Sets the channel's health to "success" and optionally marks the provider as verified (authenticated). Triggers a * debounced flush. The markAuth parameter allows callers to skip provider auth marking when a successful tune does not prove paid access (e.g., Sling Freestream * channels succeed without a subscription). * @param channelKey - The channel key (canonical key, e.g., "nbc"). * @param providerTag - The provider tag for the currently selected provider variant. * @param markAuth - Whether to also mark the provider as authenticated (default: true). */ export declare function markChannelSuccess(channelKey: string, providerTag: string, markAuth?: boolean): void; /** * Records a provider as authenticated without a specific channel context. Used when a provider action (e.g., precaching) proves the provider is accessible and logged * in, even though no channel was tuned. Triggers a debounced flush and emits a health event with an empty channelKey. * @param providerTag - The provider tag to mark as authenticated. */ export declare function markProviderAuth(providerTag: string): void; /** * Records a failed tune for a channel. Sets the channel's health to "failed". Does not affect provider auth — a single channel failure doesn't prove the provider * is unauthenticated. Triggers a debounced flush. * @param channelKey - The channel key (canonical key, e.g., "nbc"). * @param providerTag - The provider tag for the currently selected provider variant. */ export declare function markChannelFailure(channelKey: string, providerTag: string): void; /** * Returns the health status and timestamp for a channel. Returns null if no entry exists, the entry is stale (older than 7 days), or the stored providerTag doesn't * match the current one (provider was switched). * @param channelKey - The channel key (canonical key, e.g., "nbc"). * @param providerTag - The provider tag for the currently selected provider variant. * @returns Object with status and timestamp, or null if unknown. */ export declare function getChannelHealth(channelKey: string, providerTag: string): Nullable<{ status: HealthStatus; timestamp: number; }>; /** * Returns the timestamp when a provider was last verified as authenticated, or null if unknown. Verification is proven by at least one successful tune within the * TTL window. A non-null return means the provider is verified; the value is the Unix millisecond timestamp of the most recent successful tune. * @param providerTag - The provider tag to check. * @returns Timestamp of last verification, or null if unknown (no entry or stale). */ export declare function getProviderAuth(providerTag: string): Nullable; /** * Returns a snapshot of current health state for SSE initial payloads. Stale entries (older than HEALTH_TTL) are excluded. * @returns Snapshot with channel health and provider auth maps. */ export declare function getHealthSnapshot(): HealthSnapshot; /** * Subscribes a callback to receive health change events. Returns an unsubscribe function. Follows the same pattern as subscribeToStatus in statusEmitter.ts. * @param callback - Function to call when channel health or provider auth changes. * @returns A function to unsubscribe the callback. */ export declare function subscribeToHealth(callback: (event: HealthEvent) => void): () => void; export {};