#nullable enable
using Baya.Domain.Common;

namespace Baya.Domain.Entities.Audit;

/// <summary>
/// Immutable, append-only record of a state change on a compliance-sensitive entity. Never updated or
/// deleted in app code — it is the system of record for disputes/finance. <see cref="EntityId"/> is a
/// string so the trail is polymorphic across differently-typed primary keys.
/// </summary>
public class AuditLog : IEntity
{
    public long Id { get; set; }

    public string EntityType { get; set; } = string.Empty;

    public string EntityId { get; set; } = string.Empty;

    public string Action { get; set; } = AuditAction.Updated;

    public string? ChangedFieldsJson { get; set; }

    public int? ActorUserId { get; set; }

    public DateTimeOffset OccurredAt { get; set; }
}

/// <summary>Stable codes for <see cref="AuditLog.Action"/>.</summary>
public static class AuditAction
{
    public const string Created = "created";
    public const string Updated = "updated";
    public const string Deleted = "deleted";
}
