Files
hive-manage-v3/frontend/src/api/keys.ts
T
enzo 3d905b606a feat: Key batch management (Key Manager service, API, frontend) (Phase 6)
Backend service for reading/writing profile .env files with masking,
auto-backup, batch overwrite, batch scan, diff view, and CSV export.
Owner/operator-only API endpoints. Frontend KeysPage with batch-overwrite
modal, batch-scan results, diff view with highlight, and CSV download.
Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-22 17:24:53 +08:00

73 lines
1.5 KiB
TypeScript

import client from './client'
export interface KeyFieldEntry {
profile: string
fields: Record<string, string>
missing: number
}
export interface KeyListResponse {
data: KeyFieldEntry[]
}
export interface OverwriteResult {
profile: string
success: boolean
}
export interface OverwriteResponse {
results: OverwriteResult[]
}
export interface ScanResult {
profile: string
missing: string[]
missing_count: number
total: number
}
export interface ScanResponse {
results: ScanResult[]
}
export interface DiffRow {
field: string
[profile: string]: string | number
}
export interface DiffResponse {
profiles: string[]
rows: DiffRow[]
}
export const getKeys = (profiles?: string) =>
client.get<KeyListResponse>('/keys', { params: profiles ? { profiles } : {} })
export const batchOverwrite = (body: {
profile_names: string[]
key_name: string
new_value: string
confirmation: string
}) => client.post<OverwriteResponse>('/keys/batch-overwrite', body)
export const batchScan = (profile_names?: string[]) =>
client.post<ScanResponse>('/keys/batch-scan', { profile_names })
export const getDiff = (profiles: string) =>
client.get<DiffResponse>('/keys/diff', { params: { profiles } })
export const exportCsv = (profiles?: string) =>
client.get<string>('/keys/export', {
params: profiles ? { profiles } : {},
responseType: 'text',
})
export const WHITELIST_FIELDS = [
'DEEPSEEK_API_KEY',
'OPENAI_API_KEY',
'ANTHROPIC_API_KEY',
'GOOGLE_API_KEY',
'FEISHU_APP_ID',
'FEISHU_APP_SECRET',
]