diff --git a/src/components/usage/CredentialStatsCard.tsx b/src/components/usage/CredentialStatsCard.tsx index 0579b30c..cd9b795c 100644 --- a/src/components/usage/CredentialStatsCard.tsx +++ b/src/components/usage/CredentialStatsCard.tsx @@ -11,6 +11,7 @@ import { import { authFilesApi } from '@/services/api/authFiles'; import type { GeminiKeyConfig, ProviderKeyConfig, OpenAIProviderConfig } from '@/types'; import type { AuthFileItem } from '@/types/authFile'; +import type { CredentialInfo } from '@/types/sourceInfo'; import type { UsagePayload } from './hooks/useUsageData'; import styles from '@/pages/UsagePage.module.scss'; @@ -24,11 +25,6 @@ export interface CredentialStatsCardProps { openaiProviders: OpenAIProviderConfig[]; } -interface CredentialInfo { - name: string; - type: string; -} - interface CredentialRow { key: string; displayName: string; diff --git a/src/components/usage/RequestEventsDetailsCard.tsx b/src/components/usage/RequestEventsDetailsCard.tsx index 14dd5298..511f0987 100644 --- a/src/components/usage/RequestEventsDetailsCard.tsx +++ b/src/components/usage/RequestEventsDetailsCard.tsx @@ -7,6 +7,7 @@ import { Select } from '@/components/ui/Select'; import { authFilesApi } from '@/services/api/authFiles'; import type { GeminiKeyConfig, ProviderKeyConfig, OpenAIProviderConfig } from '@/types'; import type { AuthFileItem } from '@/types/authFile'; +import type { CredentialInfo, SourceInfo } from '@/types/sourceInfo'; import { buildCandidateUsageSourceIds, collectUsageDetails, @@ -60,16 +61,6 @@ const encodeCsv = (value: string | number): string => { return `"${safeText.replace(/"/g, '""')}"`; }; -type CredentialInfo = { - name: string; - type: string; -}; - -type SourceInfo = { - displayName: string; - type: string; -}; - export function RequestEventsDetailsCard({ usage, loading, diff --git a/src/pages/LogsPage.tsx b/src/pages/LogsPage.tsx index 81ec0c32..fcabb80f 100644 --- a/src/pages/LogsPage.tsx +++ b/src/pages/LogsPage.tsx @@ -23,6 +23,7 @@ import { authFilesApi } from '@/services/api/authFiles'; import { logsApi } from '@/services/api/logs'; import { usageApi } from '@/services/api/usage'; import type { AuthFileItem } from '@/types'; +import type { CredentialInfo, SourceInfo } from '@/types/sourceInfo'; import { copyToClipboard } from '@/utils/clipboard'; import { downloadBlob } from '@/utils/download'; import { MANAGEMENT_API_PREFIX } from '@/utils/constants'; @@ -157,16 +158,6 @@ type TraceCandidate = { timeDeltaMs: number | null; }; -type TraceCredentialInfo = { - name: string; - type: string; -}; - -type TraceSourceInfo = { - displayName: string; - type: string; -}; - const TRACE_USAGE_CACHE_MS = 60 * 1000; const TRACE_MATCH_STRONG_WINDOW_MS = 3 * 1000; const TRACE_MATCH_WINDOW_MS = 10 * 1000; @@ -505,7 +496,7 @@ export function LogsPage() { const [requestLogDownloading, setRequestLogDownloading] = useState(false); const [traceLogLine, setTraceLogLine] = useState(null); const [traceUsageDetails, setTraceUsageDetails] = useState([]); - const [traceAuthFileMap, setTraceAuthFileMap] = useState>(new Map()); + const [traceAuthFileMap, setTraceAuthFileMap] = useState>(new Map()); const [traceLoading, setTraceLoading] = useState(false); const [traceError, setTraceError] = useState(''); @@ -529,7 +520,7 @@ export function LogsPage() { const disableControls = connectionStatus !== 'connected'; const traceSourceInfoMap = useMemo(() => { - const map = new Map(); + const map = new Map(); const registerSource = (sourceId: string, displayName: string, type: string) => { if (!sourceId || !displayName || map.has(sourceId)) return; @@ -786,7 +777,7 @@ export function LogsPage() { ? authFilesResponse : (authFilesResponse as { files?: AuthFileItem[] })?.files; if (Array.isArray(files)) { - const map = new Map(); + const map = new Map(); files.forEach((file) => { const key = normalizeAuthIndex(file['auth_index'] ?? file.authIndex); if (!key) return; @@ -932,7 +923,7 @@ export function LogsPage() { return scored.slice(0, 8); }, [traceLogLine, traceUsageDetails]); const resolveTraceSourceInfo = useCallback( - (sourceRaw: string, authIndex: unknown): TraceSourceInfo => { + (sourceRaw: string, authIndex: unknown): SourceInfo => { const source = sourceRaw.trim(); const matchedSource = traceSourceInfoMap.get(source); if (matchedSource) { diff --git a/src/types/index.ts b/src/types/index.ts index 1919adca..476e8911 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -13,3 +13,4 @@ export * from './oauth'; export * from './usage'; export * from './log'; export * from './quota'; +export * from './sourceInfo'; diff --git a/src/types/sourceInfo.ts b/src/types/sourceInfo.ts new file mode 100644 index 00000000..205e3180 --- /dev/null +++ b/src/types/sourceInfo.ts @@ -0,0 +1,9 @@ +export type SourceInfo = { + displayName: string; + type: string; +}; + +export type CredentialInfo = { + name: string; + type: string; +};