import type { PipelineStateValueV1, StatisticsResponse } from '../../../sdk'; import type { SourceHealthState } from '../../../hooks/usePipelineStatus.types'; export interface MapPipelineHealthInput { stats: StatisticsResponse | undefined; sourceConnectionKeys: string[]; /** Collector state from the pipeline status endpoint. */ state?: PipelineStateValueV1; } export interface PipelineHealthResult { /** Pass-through of the collector state from the status endpoint. */ state?: PipelineStateValueV1; /** Undefined when the pipeline isn't running or no connections are reported. */ sourceHealth?: SourceHealthState; } /** * Derives `sourceHealth` from the collector run state and the per-connection * statuses reported by the monitoring statistics endpoint. * * Decision table: * * | state | declared sources | every status `'connected'` | sourceHealth | * | -------------------------- | ---------------- | -------------------------- | ------------ | * | `cdc` / `initial-sync` | ≥1 | yes | `'healthy'` | * | `cdc` / `initial-sync` | ≥1 | no / missing / undefined | `'unhealthy'`| * | `cdc` / `initial-sync` | 0 | n/a | `undefined` | * | `not-running` / undefined | any | any | `undefined` | * * Notes: * - Status comparison is case-insensitive (`'Connected'` counts as healthy). * - A declared source with no entry in `stats.connections` is treated as * unhealthy — its status resolves to `undefined` and fails the check. * - When the pipeline isn't running we deliberately return `undefined` so the * UI can hide the health pill instead of showing a misleading verdict. * * IDEA: this derivation is UI-side today because the SDK only exposes raw * connection statuses. If/when the RDI server exposes an aggregated * `sourceHealth` field on the status endpoint, drop this util and read it * straight from the SDK response. */ export declare const mapPipelineHealth: ({ stats, sourceConnectionKeys, state }: MapPipelineHealthInput) => PipelineHealthResult;