using ColaFlow.Modules.Mcp.Domain.Entities;

namespace ColaFlow.Modules.Mcp.Domain.Repositories;

/// <summary>
/// Repository interface for MCP API Keys
/// </summary>
public interface IMcpApiKeyRepository
{
    /// <summary>
    /// Get API Key by ID
    /// </summary>
    Task<McpApiKey?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default);

    /// <summary>
    /// Get API Key by key prefix (for fast lookup)
    /// </summary>
    Task<McpApiKey?> GetByPrefixAsync(string keyPrefix, CancellationToken cancellationToken = default);

    /// <summary>
    /// Get all API Keys for a tenant
    /// </summary>
    Task<List<McpApiKey>> GetByTenantIdAsync(Guid tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// Get all API Keys for a user
    /// </summary>
    Task<List<McpApiKey>> GetByUserIdAsync(Guid userId, Guid tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// Add a new API Key
    /// </summary>
    Task AddAsync(McpApiKey apiKey, CancellationToken cancellationToken = default);

    /// <summary>
    /// Update an existing API Key
    /// </summary>
    Task UpdateAsync(McpApiKey apiKey, CancellationToken cancellationToken = default);

    /// <summary>
    /// Delete an API Key (physical delete - use Revoke for soft delete)
    /// </summary>
    Task DeleteAsync(McpApiKey apiKey, CancellationToken cancellationToken = default);

    /// <summary>
    /// Check if an API Key prefix already exists
    /// </summary>
    Task<bool> ExistsByPrefixAsync(string keyPrefix, CancellationToken cancellationToken = default);
}
