#nullable enable
using Baya.Application.Models.Identity;
using Baya.Domain.Entities.User;

namespace Baya.Application.Contracts.Persistence;

public interface IUserAccountRepository
{
    /// <summary>No-tracking projection of the user's account facts + active role names (for `/me`).
    /// The phone comes back decrypted and unmasked — masking is the handler's job.</summary>
    Task<UserAccountSnapshot?> GetAccountSnapshotAsync(int userId, CancellationToken cancellationToken);

    /// <summary>Tracked user row for an in-place edit of the base identity (e.g. name).</summary>
    Task<User?> GetTrackedByIdAsync(int userId, CancellationToken cancellationToken);

    Task<Role?> GetRoleByNameAsync(string roleName, CancellationToken cancellationToken);

    /// <summary>Tracked user-role lookup that bypasses the revoked-filter, so a revoked grant can be
    /// re-activated instead of violating the composite key.</summary>
    Task<UserRole?> GetUserRoleIncludingRevokedAsync(int userId, int roleId, CancellationToken cancellationToken);

    Task AddUserRoleAsync(UserRole userRole, CancellationToken cancellationToken);
}