| import { api } from './api'; |
| import { Account, QuotaData } from '../types/account'; |
|
|
| |
| |
| |
| export async function listAccounts(): Promise<Account[]> { |
| return await api.get<Account[]>('/api/accounts'); |
| } |
|
|
| |
| |
| |
| export async function getCurrentAccount(): Promise<Account | null> { |
| return await api.get<Account | null>('/api/accounts/current'); |
| } |
|
|
| |
| |
| |
| export async function addAccount(email: string, refreshToken: string): Promise<Account> { |
| return await api.post<Account>('/api/accounts', { email, refresh_token: refreshToken }); |
| } |
|
|
| |
| |
| |
| export async function deleteAccount(accountId: string): Promise<void> { |
| return await api.delete<void>(`/api/accounts/${accountId}`); |
| } |
|
|
| |
| |
| |
| export async function deleteAccounts(accountIds: string[]): Promise<void> { |
| |
| for (const id of accountIds) { |
| await deleteAccount(id); |
| } |
| } |
|
|
| |
| |
| |
| export async function switchAccount(accountId: string): Promise<void> { |
| return await api.post<void>(`/api/accounts/${accountId}/set-current`); |
| } |
|
|
| |
| |
| |
| export async function fetchAccountQuota(accountId: string): Promise<QuotaData> { |
| return await api.post<QuotaData>(`/api/accounts/${accountId}/quota`); |
| } |
|
|
| export interface RefreshStats { |
| total: number; |
| success: number; |
| failed: number; |
| details: string[]; |
| } |
|
|
| |
| |
| |
| export async function refreshAllQuotas(): Promise<RefreshStats> { |
| return await api.post<RefreshStats>('/api/accounts/refresh-all'); |
| } |
|
|
| |
| |
| |
|
|
| |
| |
| |
| |
| export async function startOAuthLogin(): Promise<Account> { |
| throw new Error('OAuth login is not supported in cloud version. Please add accounts using Refresh Token.'); |
| } |
|
|
| |
| |
| |
| export async function completeOAuthLogin(): Promise<Account> { |
| throw new Error('OAuth login is not supported in cloud version.'); |
| } |
|
|
| |
| |
| |
| export async function cancelOAuthLogin(): Promise<void> { |
| |
| } |
|
|
| |
| |
| |
| export async function importV1Accounts(): Promise<Account[]> { |
| throw new Error('V1 import is not supported in cloud version.'); |
| } |
|
|
| |
| |
| |
| export async function importFromDb(): Promise<Account> { |
| throw new Error('DB import is not supported in cloud version.'); |
| } |
|
|
| |
| |
| |
| export async function importFromCustomDb(_path: string): Promise<Account> { |
| throw new Error('Custom DB import is not supported in cloud version.'); |
| } |
|
|
| |
| |
| |
| export async function syncAccountFromDb(): Promise<Account | null> { |
| |
| return null; |
| } |
|
|