namespace ZB.MOM.WW.OtOpcUa.Configuration.Entities;

/// <summary>
///     Append-only audit row written by AdminOperationsActor on every mutating live-edit
///     operation. The ExecutionId optionally correlates a sequence of edits that ran inside one
///     admin transaction (e.g. an import batch that updates many Equipment rows).
/// </summary>
public sealed class ConfigEdit
{
    /// <summary>Gets the unique identifier for this edit.</summary>
    public Guid EditId { get; init; } = Guid.NewGuid();

    /// <summary>Gets the type of entity that was edited.</summary>
    public required string EntityType { get; init; }

    /// <summary>Gets the identifier of the entity that was edited.</summary>
    public Guid EntityId { get; init; }

    /// <summary>Gets the JSON payload of the column-name → new-value pairs touched by this edit.</summary>
    public required string FieldsJson { get; init; }

    /// <summary>Gets the optional correlation identifier across edits inside a single admin operation.</summary>
    public Guid? ExecutionId { get; init; }

    /// <summary>Gets the username of the user who performed the edit.</summary>
    public required string EditedBy { get; init; }

    /// <summary>Gets the UTC timestamp when the edit was performed.</summary>
    public DateTime EditedAtUtc { get; init; } = DateTime.UtcNow;

    /// <summary>Gets the node identifier of the admin instance that performed the edit.</summary>
    public required string SourceNode { get; init; }
}
