using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;

namespace ZB.MOM.WW.ScadaBridge.CentralUI.Services;

/// <summary>
/// CentralUI facade that projects the per-site health reports' name-keyed
/// connection statuses onto a connection-id → <see cref="ConnectionHealth"/> map for
/// the design DataConnections page. Reuses the existing health transport — the
/// <see cref="ZB.MOM.WW.ScadaBridge.HealthMonitoring.ICentralHealthAggregator"/>'s
/// already-aggregated <c>SiteHealthReport.DataConnectionStatuses</c> — and resolves
/// each report's connection NAME key back to a <c>DataConnection.Id</c> within the
/// report's own site, so the page can render a live badge per connection node.
/// </summary>
public interface IConnectionHealthQueryService
{
    /// <summary>
    /// Returns a snapshot of connection-id → latest known <see cref="ConnectionHealth"/>
    /// across every configured site. A site with no health report yet (or a
    /// heartbeat-only state) contributes no entries; a report referencing a
    /// connection name that does not match any configured connection is skipped.
    /// Callers treat a missing key as "unknown" rather than a failure.
    /// </summary>
    /// <param name="ct">Cancellation token.</param>
    /// <returns>A task resolving to the connection-id → health map.</returns>
    Task<IReadOnlyDictionary<int, ConnectionHealth>> GetConnectionHealthAsync(
        CancellationToken ct = default);
}
