namespace Books.Api.EventFlow.Repositories;

/// <summary>
/// Repository for document content hashes to prevent duplicate processing.
/// </summary>
public interface IDocumentHashRepository
{
    /// <summary>
    /// Check if a document with this hash has already been processed for a company.
    /// </summary>
    Task<DocumentHashRecord?> GetByHashAsync(
        string companyId,
        string contentHash,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Record a processed document hash.
    /// </summary>
    Task InsertAsync(
        string companyId,
        string contentHash,
        string originalFilename,
        string? attachmentId,
        string? draftId,
        CancellationToken cancellationToken = default);
}

/// <summary>
/// Record of a processed document.
/// </summary>
public class DocumentHashRecord
{
    public string Id { get; set; } = string.Empty;
    public string CompanyId { get; set; } = string.Empty;
    public string ContentHash { get; set; } = string.Empty;
    public string OriginalFilename { get; set; } = string.Empty;
    public string? AttachmentId { get; set; }
    public string? DraftId { get; set; }
    public DateTime CreatedAt { get; set; }
}
