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

namespace ZB.MOM.WW.ScadaBridge.Commons.Types.Deployment;

/// <summary>
/// One rendered row of the Central UI deployment-status list: a
/// <c>DeploymentRecord</c> projection already joined to its <c>Instance</c>.
///
/// <para>
/// The join is what removes the page's SECOND full-table read. Rendering a row
/// needs the instance's display name and site scoping needs its site, and the page
/// used to obtain both by materializing every instance into two dictionaries. Both
/// values now come back with the page of rows that actually needs them.
/// </para>
///
/// <para>
/// Like <see cref="DeploymentRecordSummary"/>, the <c>RowVersion</c>
/// optimistic-concurrency token is deliberately absent — this is a READ projection
/// and must never be mistaken for something that can be written back. Mutating
/// paths keep loading the tracked entity.
/// </para>
///
/// <para>
/// Message-contract evolution rule: additive-only. New fields go on the end with a
/// default.
/// </para>
/// </summary>
/// <param name="Id">Deployment record row id.</param>
/// <param name="DeploymentId">The logical deployment id (GUID, "N" format).</param>
/// <param name="InstanceId">Instance the deployment targeted.</param>
/// <param name="InstanceUniqueName">The target instance's unique name, for display.</param>
/// <param name="SiteId">The target instance's site, the value site scoping is evaluated against.</param>
/// <param name="Status">Terminal or in-flight deployment status.</param>
/// <param name="RevisionHash">Revision hash of the deployed configuration.</param>
/// <param name="DeployedBy">User who initiated the deployment.</param>
/// <param name="DeployedAt">When the deployment was initiated.</param>
/// <param name="CompletedAt">When the deployment reached a terminal status, if it has.</param>
/// <param name="ErrorMessage">Failure detail when the deployment did not succeed.</param>
public sealed record DeploymentListRow(
    int Id,
    string DeploymentId,
    int InstanceId,
    string InstanceUniqueName,
    int SiteId,
    DeploymentStatus Status,
    string? RevisionHash,
    string DeployedBy,
    DateTimeOffset DeployedAt,
    DateTimeOffset? CompletedAt,
    string? ErrorMessage);
