import { u as CwvSummary } from "./index-X8c3MrjB.js"; import { a as IndexingFinding, c as RedirectFinding, i as DuplicateTitleFinding, t as BrokenLink } from "./link-check-CVOhtrRy.js"; //#region src/core/health/index.d.ts /** The KV surface the health store needs—structural so the real `KVNamespace` * fits without importing Workers types (mirrors `DraftBufferKV`). */ interface HealthKV { get(key: string): Promise; put(key: string, value: string, options?: { expirationTtl?: number; }): Promise; } /** Default KV key the summary is stored under. */ declare const HEALTH_KV_KEY = "louise:health:summary"; /** Cap on each list of stored details (broken links, redirects, indexing, shared * titles), so the persisted blob stays small even if a crawl finds many (the * counts are exact; the details are a sample for a list). */ declare const MAX_BROKEN_LINK_DETAILS = 50; /** * The persisted owner-facing health snapshot. The counts drive the dashboard * card's traffic light; `brokenLinkDetails` backs a fuller "what's broken" list. * Shape-compatible with `overview.health` (the extra detail field is ignored * there), so the overview route can return a stored summary directly. */ interface HealthSummary { brokenLinks: number; missingAlt: number; seoGaps: number; /** ISO timestamp of the scan. */ checkedAt: string; /** A capped sample of the broken links found, for a detail view. */ brokenLinkDetails?: BrokenLink[]; /** Internal links that redirect (from `crawlSite`). Absent when the scan didn't crawl. */ redirects?: number; /** A capped sample, each against the page that holds the link. */ redirectDetails?: RedirectFinding[]; /** Crawled pages whose robots directive or canonical keeps them out of search. */ indexing?: number; /** A capped sample of the indexing findings. */ indexingDetails?: IndexingFinding[]; /** Titles more than one crawled page shares. */ duplicateTitles?: number; /** A capped sample of the shared titles and their pages. */ duplicateTitleDetails?: DuplicateTitleFinding[]; /** Real-visitor Core Web Vitals (#106 CWV)—present once the scan folds in a * p75 snapshot from Analytics Engine; absent → the panel shows "not measured yet". */ cwv?: CwvSummary; /** Schema migrations the running code needs that the database hasn't applied * (`migrationStatus(…).pending` from `louise-toolkit/db`). Absent or empty * when the database is up to date. Worth checking live when the summary is * read, since a deploy can land between scans. */ pendingMigrations?: string[]; } /** The raw parts of a scan, assembled by {@link summarizeHealth}. */ interface HealthInput { /** Broken links from `checkLinks`—the length is the count, a capped slice the detail. */ brokenLinks: BrokenLink[]; /** Count of media assets / images with no alt text. */ missingAlt: number; /** Count of published, indexable pages missing an SEO title or description. * Leave `noindex` pages out: they don't need either for search. */ seoGaps: number; /** From `crawlSite`: internal links that redirect. Omit when the scan didn't crawl. */ redirects?: readonly RedirectFinding[]; /** From `crawlSite`: pages whose robots directive or canonical keeps them out of search. */ indexing?: readonly IndexingFinding[]; /** From `crawlSite`: titles more than one page shares. */ duplicateTitles?: readonly DuplicateTitleFinding[]; /** Pending schema migrations, from `migrationStatus`. Omit if the site doesn't check. */ pendingMigrations?: readonly string[]; /** Scan time (defaults to now)—injectable so tests are deterministic. */ now?: Date; } /** Assemble a {@link HealthSummary} from a scan's parts: exact counts, a capped * sample of broken-link details, and the scan timestamp. */ declare function summarizeHealth(input: HealthInput): HealthSummary; /** Total number of issues in a summary—the dashboard's "N things need attention". */ declare function healthIssueCount(summary: HealthSummary): number; /** * How old a scheduled job's last success can get before {@link isStale} flags it: * 36 hours. A daily job can run late or miss one run and still read as fresh, * but two missed runs in a row read as stale. Override it per site when the job * runs on a different schedule. */ declare const HEALTH_STALE_AFTER_MS: number; /** * Whether a scheduled job's last success is older than `maxAgeMs`, so a job that * quietly stopped running shows up instead of looking like one that ran an hour * ago. Pure: pass `now` for a deterministic result. * * - A missing or unparseable `timestamp` counts as stale, and so does a number * outside the `Date` range. A job with no readable record of success hasn't * shown that it ran, and a monitor that stays quiet about that is the failure * this check exists to catch. * - A timestamp in the future (clock skew between the job and the reader) is * age 0, so it counts as fresh. * - The age has to exceed `maxAgeMs`, so an age of exactly `maxAgeMs` is fresh. * Pass `Infinity` to turn the check off. A `NaN` or negative threshold flags * everything, so a misconfigured threshold shows up as out of date instead of * hiding a job that stopped. * * `ageCheck` (the status route's check) applies this same rule. * * @param timestamp An ISO 8601 string (like `HealthSummary.checkedAt`), epoch * milliseconds, or a `Date`. * @param maxAgeMs The largest age that still counts as fresh, in milliseconds. * {@link HEALTH_STALE_AFTER_MS} suits a daily job. * @param now The current time. Defaults to the moment of the call. */ declare function isStale(timestamp: string | number | Date | null | undefined, maxAgeMs: number, now?: Date | number): boolean; /** Persist the summary. Omit `ttlSeconds` to keep it until the next scan overwrites. */ declare function writeHealthSummary(kv: HealthKV, summary: HealthSummary, opts?: { key?: string; ttlSeconds?: number; }): Promise; /** Read the persisted summary, or `null` when none is stored (or it's unparseable; * a corrupt blob degrades to "no data" rather than throwing). */ declare function readHealthSummary(kv: HealthKV, key?: string): Promise; //#endregion export { HealthSummary as a, isStale as c, writeHealthSummary as d, HealthKV as i, readHealthSummary as l, HEALTH_STALE_AFTER_MS as n, MAX_BROKEN_LINK_DETAILS as o, HealthInput as r, healthIssueCount as s, HEALTH_KV_KEY as t, summarizeHealth as u };