using ZB.MOM.WW.ScadaBridge.Commons.Types.Audit;
namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Audit;
///
/// Site Calls UI -> Central: paginated, filtered query over the central
/// SiteCalls table (Site Call Audit #22). All filter fields are optional;
/// restricts results to stuck cached calls. Mirrors
///
/// but uses keyset paging ( + )
/// to match the repository's (CreatedAtUtc DESC, TrackedOperationId DESC)
/// cursor, rather than page numbers.
///
///
/// matches the SiteCall.Channel column —
/// "ApiOutbound" or "DbOutbound" (the spec's Kind notion;
/// the entity exposes it as Channel). is an
/// exact-match target filter, consistent with the repository's
/// predicate.
///
///
/// Requested page size. The actor clamps this to the [1, 200] range, so
/// the effective ceiling is 200 rows per page regardless of the value sent.
///
public sealed record SiteCallQueryRequest(
string CorrelationId,
string? StatusFilter,
string? SourceSiteFilter,
string? ChannelFilter,
string? TargetKeyword,
bool StuckOnly,
DateTime? FromUtc,
DateTime? ToUtc,
DateTime? AfterCreatedAtUtc,
Guid? AfterId,
int PageSize,
string? SourceNodeFilter = null);
///
/// A single SiteCalls row summarised for the Site Calls UI grid. Carries
/// only the columns the
/// entity genuinely exposes — there are no source-instance/script provenance
/// columns on that entity, so unlike
///
/// none are surfaced here.
///
///
/// is not called out in the Site Call Audit plan, but
/// it is a real (nullable)
/// column — the last HTTP status code observed for the call — so it is surfaced
/// here for the grid; null for non-HTTP channels or before a first attempt.
///
public sealed record SiteCallSummary(
Guid TrackedOperationId,
string SourceSite,
string Channel,
string Target,
string Status,
int RetryCount,
string? LastError,
int? HttpStatus,
DateTime CreatedAtUtc,
DateTime UpdatedAtUtc,
DateTime? TerminalAtUtc,
bool IsStuck,
string? SourceNode = null);
///
/// Central -> Site Calls UI: paginated response for a .
/// The keyset cursor of the last row is echoed back as
/// + for the caller
/// to request the following page; both are null when the page was empty.
/// On a repository fault is false,
/// carries the cause and is empty.
///
public sealed record SiteCallQueryResponse(
string CorrelationId,
bool Success,
string? ErrorMessage,
IReadOnlyList SiteCalls,
DateTime? NextAfterCreatedAtUtc,
Guid? NextAfterId);
///
/// Site Calls UI -> Central: request for the full detail of a single cached call,
/// for the report detail modal.
///
public sealed record SiteCallDetailRequest(
string CorrelationId,
Guid TrackedOperationId);
///
/// Central -> Site Calls UI: full detail for one cached call. On a repository
/// fault or missing row, is false /
/// is null and carries
/// the cause.
///
public sealed record SiteCallDetailResponse(
string CorrelationId,
bool Success,
string? ErrorMessage,
SiteCallDetail? Detail);
///
/// Full SiteCalls row detail for the report detail modal — every field
/// on the entity,
/// including and the
/// timestamp the grid summary omits.
///
public sealed record SiteCallDetail(
Guid TrackedOperationId,
string SourceSite,
string Channel,
string Target,
string Status,
int RetryCount,
string? LastError,
int? HttpStatus,
DateTime CreatedAtUtc,
DateTime UpdatedAtUtc,
DateTime? TerminalAtUtc,
DateTime IngestedAtUtc,
string? SourceNode = null);
///
/// Site Calls UI -> Central: request for the global SiteCalls KPI summary.
/// Mirrors .
///
public sealed record SiteCallKpiRequest(
string CorrelationId);
///
/// Central -> Site Calls UI: KPI summary for the Site Calls dashboard. On a
/// repository fault is false,
/// carries the cause, and the KPI fields are
/// zeroed/null.
///
public sealed record SiteCallKpiResponse(
string CorrelationId,
bool Success,
string? ErrorMessage,
int BufferedCount,
int ParkedCount,
int FailedLastInterval,
int DeliveredLastInterval,
TimeSpan? OldestPendingAge,
int StuckCount);
///
/// Site Calls UI -> Central: request for the per-source-site SiteCalls
/// KPI breakdown. Mirrors
/// .
///
public sealed record PerSiteSiteCallKpiRequest(
string CorrelationId);
///
/// Central -> Site Calls UI: per-site KPI breakdown for the Site Calls KPIs
/// page. On a repository fault is false,
/// carries the cause, and is empty.
///
public sealed record PerSiteSiteCallKpiResponse(
string CorrelationId,
bool Success,
string? ErrorMessage,
IReadOnlyList Sites);
///
/// Site Calls UI -> Central: request for the per-node SiteCalls
/// KPI breakdown. Mirrors but groups
/// by SourceNode instead of SourceSite. Additive — does not
/// change per-site behaviour.
///
public sealed record PerNodeSiteCallKpiRequest(
string CorrelationId);
///
/// Central -> Site Calls UI: per-node KPI breakdown for the Site Calls KPIs
/// page. On a repository fault is false,
/// carries the cause, and is empty.
/// Nodes with a NULL SourceNode are omitted.
///
public sealed record PerNodeSiteCallKpiResponse(
string CorrelationId,
bool Success,
string? ErrorMessage,
IReadOnlyList Nodes);