using System.Collections.Generic;
using System.Threading.Tasks;
using QuantEngine.Core.Models;

namespace QuantEngine.Core.Interfaces
{
    public interface IWorkspaceRepository
    {
        // Accounts
        Task<IEnumerable<WorkspaceAccount>> GetAccountsAsync();
        Task<WorkspaceAccount?> GetAccountByUsernameAsync(string username);
        Task<bool> UpsertAccountAsync(WorkspaceAccount account);
        Task<WorkspaceSession?> GetSessionByTokenHashAsync(string tokenHash);
        Task<bool> UpsertSessionAsync(WorkspaceSession session);
        Task<bool> RevokeSessionAsync(string tokenHash, string revokedAt);

        // Settings
        Task<IEnumerable<Setting>> GetSettingsAsync();
        Task<Setting?> GetSettingByKeyAsync(string key);
        Task<bool> UpsertSettingAsync(Setting setting);
        Task<bool> DeleteSettingAsync(string key);

        // AccountSnapshot
        Task<IEnumerable<AccountSnapshot>> GetAccountSnapshotsAsync();
        Task<bool> InsertAccountSnapshotsAsync(IEnumerable<AccountSnapshot> snapshots);
        Task<bool> ClearAccountSnapshotsAsync();

        // WorkspaceApproval
        Task<IEnumerable<WorkspaceApproval>> GetApprovalsAsync();
        Task<WorkspaceApproval?> GetApprovalAsync(string domain, string targetRef);
        Task<bool> UpsertApprovalAsync(WorkspaceApproval approval);

        // WorkspaceLock
        Task<IEnumerable<WorkspaceLock>> GetLocksAsync();
        Task<WorkspaceLock?> GetLockAsync(string domain, string targetRef);
        Task<bool> AcquireLockAsync(WorkspaceLock @lock);
        Task<bool> ReleaseLockAsync(string domain, string targetRef);
    }
}
