import { api } from './api'; import { Account, QuotaData } from '../types/account'; /** * List all accounts */ export async function listAccounts(): Promise { return await api.get('/api/accounts'); } /** * Get current account */ export async function getCurrentAccount(): Promise { return await api.get('/api/accounts/current'); } /** * Add account using refresh token */ export async function addAccount(email: string, refreshToken: string): Promise { return await api.post('/api/accounts', { email, refresh_token: refreshToken }); } /** * Delete account */ export async function deleteAccount(accountId: string): Promise { return await api.delete(`/api/accounts/${accountId}`); } /** * Delete multiple accounts */ export async function deleteAccounts(accountIds: string[]): Promise { // Delete sequentially for (const id of accountIds) { await deleteAccount(id); } } /** * Set current account (cloud version - no IDE sync) */ export async function switchAccount(accountId: string): Promise { return await api.post(`/api/accounts/${accountId}/set-current`); } /** * Fetch account quota */ export async function fetchAccountQuota(accountId: string): Promise { return await api.post(`/api/accounts/${accountId}/quota`); } export interface RefreshStats { total: number; success: number; failed: number; details: string[]; } /** * Refresh all account quotas */ export async function refreshAllQuotas(): Promise { return await api.post('/api/accounts/refresh-all'); } // ======================================== // Cloud-incompatible functions (stubs) // ======================================== /** * OAuth login - Not supported in cloud version * Users should add accounts via Refresh Token */ export async function startOAuthLogin(): Promise { throw new Error('OAuth login is not supported in cloud version. Please add accounts using Refresh Token.'); } /** * Complete OAuth login - Not supported */ export async function completeOAuthLogin(): Promise { throw new Error('OAuth login is not supported in cloud version.'); } /** * Cancel OAuth login - Not supported */ export async function cancelOAuthLogin(): Promise { // No-op } /** * Import V1 accounts - Not supported in cloud version */ export async function importV1Accounts(): Promise { throw new Error('V1 import is not supported in cloud version.'); } /** * Import from DB - Not supported in cloud version */ export async function importFromDb(): Promise { throw new Error('DB import is not supported in cloud version.'); } /** * Import from custom DB - Not supported in cloud version */ export async function importFromCustomDb(_path: string): Promise { throw new Error('Custom DB import is not supported in cloud version.'); } /** * Sync account from DB - Not supported in cloud version */ export async function syncAccountFromDb(): Promise { // Return null silently (used in background tasks) return null; }