namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.RemoteQuery;

/// <summary>
/// A single event log entry returned from a site query.
/// </summary>
/// <param name="Id">
/// The event's primary key: a GUID string minted by the recording site node.
/// <para>
/// This was a <c>long</c> autoincrement id until LocalDb Phase 1. Site pairs now
/// replicate <c>site_events</c> with last-writer-wins on this key, so a
/// server-minted integer would have both nodes issuing the same ids for unrelated
/// events and silently overwriting each other on sync. Consumers must treat it as
/// an opaque identifier — it carries no ordering.
/// </para>
/// </param>
public record EventLogEntry(
    string Id,
    DateTimeOffset Timestamp,
    string EventType,
    string Severity,
    string? InstanceId,
    string Source,
    string Message,
    string? Details);

/// <summary>
/// Response containing paginated event log entries from a site.
/// </summary>
/// <param name="ContinuationToken">
/// Opaque keyset-pagination cursor: pass it back verbatim on the next request to
/// continue after the last returned row, or <see langword="null"/> to start from the
/// beginning. Encodes <c>timestamp</c> and <c>id</c> together, because GUID ids do not
/// sort chronologically and timestamps alone are not unique. Do not parse it.
/// </param>
public record EventLogQueryResponse(
    string CorrelationId,
    string SiteId,
    IReadOnlyList<EventLogEntry> Entries,
    string? ContinuationToken,
    bool HasMore,
    bool Success,
    string? ErrorMessage,
    DateTimeOffset Timestamp);
