import type { ServiceState } from '../lib/3proxy'; export type ServiceProtocol = 'socks5' | 'http'; export type ServiceCommand = 'socks' | 'proxy'; export interface DailyTrafficBucket { day: string; bytes: number; share: number; } export interface ProxyServiceRecord { id: string; name: string; command: ServiceCommand; protocol: ServiceProtocol; description: string; port: number; enabled: boolean; assignable: boolean; } export interface ProxyUserRecord { id: string; username: string; password: string; serviceId: string; status: Exclude; usedBytes: number; quotaBytes: number | null; paused?: boolean; } export interface SystemSettings { publicHost: string; configMode: string; reloadMode: string; storageMode: string; services: ProxyServiceRecord[]; } export interface ControlPlaneState { service: { versionLabel: string; lastEvent: string; startedAt: string | null; }; traffic: { totalBytes: number; liveConnections: number; activeUsers: number; daily: DailyTrafficBucket[]; }; userRecords: ProxyUserRecord[]; system: SystemSettings; } export interface DashboardSnapshot { service: { status: ServiceState; pidLabel: string; versionLabel: string; uptimeLabel: string; lastEvent: string; }; traffic: ControlPlaneState['traffic']; users: { total: number; live: number; nearQuota: number; exceeded: number; }; attention: Array<{ level: Exclude; title: string; message: string; }>; userRecords: ProxyUserRecord[]; system: ControlPlaneState['system'] & { previewConfig: string; }; } export interface DashboardSnapshotPatch { service?: DashboardSnapshot['service']; traffic?: DashboardSnapshot['traffic']; users?: DashboardSnapshot['users']; attention?: DashboardSnapshot['attention']; userRecords?: DashboardSnapshot['userRecords']; system?: DashboardSnapshot['system']; } export type DashboardSyncMessage = | { type: 'snapshot.init'; snapshot: DashboardSnapshot; } | { type: 'snapshot.patch'; patch: DashboardSnapshotPatch; } | { type: 'session.expired'; error: string; }; export interface CreateUserInput { username: string; password: string; serviceId: string; quotaMb: number | null; } export type UpdateSystemInput = SystemSettings; export interface PanelLoginInput { login: string; password: string; } export interface PanelLoginResponse { token: string; expiresAt: string; ttlMs: number; }