mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
refactor: 前端全面替换 any 为 unknown 并统一错误处理,后端用量记录补写请求头/体
- 前端 API 层、stores、conversation 解析器、组件全面替换 any 为 unknown/具体类型 - 错误处理统一使用 parseApiError/getErrorStatus 替代 err.response?.data?.detail 模式 - 后端 handler/TaskService/UsageLifecycle/StreamTracker 链路传递 request_headers/request_body - streaming/pending 状态更新时可补写客户端和提供商的请求头及请求体 - 新增 TaskService 和 UsageService 相关测试
This commit is contained in:
@@ -28,8 +28,8 @@ export interface OAuthProviderExport {
|
||||
scopes?: string[] | null
|
||||
redirect_uri: string
|
||||
frontend_callback_url: string
|
||||
attribute_mapping?: any
|
||||
extra_config?: any
|
||||
attribute_mapping?: Record<string, unknown>
|
||||
extra_config?: Record<string, unknown>
|
||||
is_enabled?: boolean
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ export interface UserExport {
|
||||
allowed_providers?: string[] | null
|
||||
allowed_api_formats?: string[] | null
|
||||
allowed_models?: string[] | null
|
||||
model_capability_settings?: any
|
||||
model_capability_settings?: Record<string, Record<string, boolean>>
|
||||
quota_usd?: number | null
|
||||
used_usd?: number
|
||||
total_usd?: number
|
||||
@@ -79,7 +79,7 @@ export interface UserApiKeyExport {
|
||||
allowed_models?: string[] | null
|
||||
rate_limit?: number | null // null = 无限制
|
||||
concurrent_limit?: number | null
|
||||
force_capabilities?: any
|
||||
force_capabilities?: Record<string, boolean>
|
||||
is_active: boolean
|
||||
expires_at?: string | null
|
||||
auto_delete_on_expiry?: boolean
|
||||
@@ -94,9 +94,9 @@ export interface GlobalModelExport {
|
||||
name: string
|
||||
display_name: string
|
||||
default_price_per_request?: number | null
|
||||
default_tiered_pricing: any
|
||||
default_tiered_pricing: Record<string, unknown>
|
||||
supported_capabilities?: string[] | null
|
||||
config?: any
|
||||
config?: Record<string, unknown>
|
||||
is_active: boolean
|
||||
}
|
||||
|
||||
@@ -112,8 +112,8 @@ export interface ProviderExport {
|
||||
is_active: boolean
|
||||
concurrent_limit?: number | null
|
||||
max_retries?: number | null
|
||||
proxy?: any
|
||||
config?: any
|
||||
proxy?: Record<string, unknown>
|
||||
config?: Record<string, unknown>
|
||||
endpoints: EndpointExport[]
|
||||
api_keys: ProviderKeyExport[]
|
||||
models: ModelExport[]
|
||||
@@ -122,12 +122,12 @@ export interface ProviderExport {
|
||||
export interface EndpointExport {
|
||||
api_format: string
|
||||
base_url: string
|
||||
headers?: any
|
||||
headers?: Record<string, unknown>
|
||||
max_retries?: number
|
||||
is_active: boolean
|
||||
custom_path?: string | null
|
||||
config?: any
|
||||
proxy?: any
|
||||
config?: Record<string, unknown>
|
||||
proxy?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface ProviderKeyExport {
|
||||
@@ -139,8 +139,8 @@ export interface ProviderKeyExport {
|
||||
internal_priority?: number
|
||||
global_priority_by_format?: Record<string, number> | null
|
||||
rpm_limit?: number | null
|
||||
allowed_models?: any
|
||||
capabilities?: any
|
||||
allowed_models?: string[] | null
|
||||
capabilities?: Record<string, boolean>
|
||||
cache_ttl_minutes?: number
|
||||
max_probe_interval_minutes?: number
|
||||
is_active: boolean
|
||||
@@ -149,16 +149,16 @@ export interface ProviderKeyExport {
|
||||
export interface ModelExport {
|
||||
global_model_name: string | null
|
||||
provider_model_name: string
|
||||
provider_model_mappings?: any
|
||||
provider_model_mappings?: Record<string, unknown>
|
||||
price_per_request?: number | null
|
||||
tiered_pricing?: any
|
||||
tiered_pricing?: Record<string, unknown>
|
||||
supports_vision?: boolean | null
|
||||
supports_function_calling?: boolean | null
|
||||
supports_streaming?: boolean | null
|
||||
supports_extended_thinking?: boolean | null
|
||||
supports_image_generation?: boolean | null
|
||||
is_active: boolean
|
||||
config?: any
|
||||
config?: Record<string, unknown>
|
||||
}
|
||||
|
||||
// 邮件模板接口
|
||||
@@ -533,14 +533,14 @@ export const adminApi = {
|
||||
|
||||
// 系统配置相关
|
||||
// 获取所有系统配置
|
||||
async getAllSystemConfigs(): Promise<any[]> {
|
||||
const response = await apiClient.get<any[]>('/api/admin/system/configs')
|
||||
async getAllSystemConfigs(): Promise<Array<{ key: string; value: unknown; description?: string }>> {
|
||||
const response = await apiClient.get<Array<{ key: string; value: unknown; description?: string }>>('/api/admin/system/configs')
|
||||
return response.data
|
||||
},
|
||||
|
||||
// 获取特定系统配置
|
||||
async getSystemConfig(key: string): Promise<{ key: string; value: any }> {
|
||||
const response = await apiClient.get<{ key: string; value: any }>(
|
||||
async getSystemConfig(key: string): Promise<{ key: string; value: unknown }> {
|
||||
const response = await apiClient.get<{ key: string; value: unknown }>(
|
||||
`/api/admin/system/configs/${key}`
|
||||
)
|
||||
return response.data
|
||||
@@ -549,10 +549,10 @@ export const adminApi = {
|
||||
// 更新系统配置
|
||||
async updateSystemConfig(
|
||||
key: string,
|
||||
value: any,
|
||||
value: unknown,
|
||||
description?: string
|
||||
): Promise<{ key: string; value: any; description?: string }> {
|
||||
const response = await apiClient.put<{ key: string; value: any; description?: string }>(
|
||||
): Promise<{ key: string; value: unknown; description?: string }> {
|
||||
const response = await apiClient.put<{ key: string; value: unknown; description?: string }>(
|
||||
`/api/admin/system/configs/${key}`,
|
||||
{ value, description }
|
||||
)
|
||||
@@ -568,8 +568,8 @@ export const adminApi = {
|
||||
},
|
||||
|
||||
// 获取系统统计
|
||||
async getSystemStats(): Promise<any> {
|
||||
const response = await apiClient.get<any>('/api/admin/system/stats')
|
||||
async getSystemStats(): Promise<Record<string, unknown>> {
|
||||
const response = await apiClient.get<Record<string, unknown>>('/api/admin/system/stats')
|
||||
return response.data
|
||||
},
|
||||
|
||||
@@ -621,7 +621,7 @@ export const adminApi = {
|
||||
},
|
||||
|
||||
// 测试 SMTP 连接,支持传入未保存的配置
|
||||
async testSmtpConnection(config: Record<string, any> = {}): Promise<{ success: boolean; message: string }> {
|
||||
async testSmtpConnection(config: Record<string, unknown> = {}): Promise<{ success: boolean; message: string }> {
|
||||
const response = await apiClient.post<{ success: boolean; message: string }>(
|
||||
'/api/admin/system/smtp/test',
|
||||
config
|
||||
@@ -860,8 +860,8 @@ export const adminApi = {
|
||||
user_id?: string
|
||||
model?: string
|
||||
provider_name?: string
|
||||
}): Promise<any[]> {
|
||||
const response = await apiClient.get<any[]>('/api/admin/stats/time-series', { params })
|
||||
}): Promise<Array<Record<string, unknown>>> {
|
||||
const response = await apiClient.get<Array<Record<string, unknown>>>('/api/admin/stats/time-series', { params })
|
||||
return response.data
|
||||
},
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ export interface AsyncTaskRequestMetadata {
|
||||
user_agent: string
|
||||
request_id: string
|
||||
request_headers?: Record<string, string>
|
||||
poll_raw_response?: any // 轮询完成时的原始响应
|
||||
billing_snapshot?: any // 计费快照
|
||||
poll_raw_response?: unknown // 轮询完成时的原始响应
|
||||
billing_snapshot?: unknown // 计费快照
|
||||
}
|
||||
|
||||
// 异步任务详情
|
||||
@@ -68,8 +68,8 @@ export interface AsyncTaskDetail extends AsyncTaskItem {
|
||||
client_api_format: string
|
||||
provider_api_format: string
|
||||
format_converted: boolean
|
||||
original_request_body: any
|
||||
converted_request_body: any
|
||||
original_request_body: unknown
|
||||
converted_request_body: unknown
|
||||
size: string | null
|
||||
video_urls: string[] | null
|
||||
thumbnail_url: string | null
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface AuditLog {
|
||||
ip_address?: string
|
||||
status_code?: number
|
||||
error_message?: string
|
||||
metadata?: any
|
||||
metadata?: Record<string, unknown>
|
||||
created_at: string
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export interface PaginationMeta {
|
||||
export interface AuditLogsResponse {
|
||||
items: AuditLog[]
|
||||
meta: PaginationMeta
|
||||
filters?: Record<string, any>
|
||||
filters?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface AuditFilters {
|
||||
@@ -33,19 +33,19 @@ export interface AuditFilters {
|
||||
offset?: number
|
||||
}
|
||||
|
||||
function normalizeAuditResponse(data: any): AuditLogsResponse {
|
||||
const items: AuditLog[] = data.items ?? data.logs ?? []
|
||||
const meta: PaginationMeta = data.meta ?? {
|
||||
total: data.total ?? items.length,
|
||||
limit: data.limit ?? items.length,
|
||||
offset: data.offset ?? 0,
|
||||
count: data.count ?? items.length
|
||||
function normalizeAuditResponse(data: Record<string, unknown>): AuditLogsResponse {
|
||||
const items: AuditLog[] = (data.items ?? data.logs ?? []) as AuditLog[]
|
||||
const meta: PaginationMeta = (data.meta as PaginationMeta) ?? {
|
||||
total: (data.total as number) ?? items.length,
|
||||
limit: (data.limit as number) ?? items.length,
|
||||
offset: (data.offset as number) ?? 0,
|
||||
count: (data.count as number) ?? items.length
|
||||
}
|
||||
|
||||
return {
|
||||
items,
|
||||
meta,
|
||||
filters: data.filters
|
||||
filters: data.filters as Record<string, unknown> | undefined
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ export const auditApi = {
|
||||
|
||||
// 分析用户行为 (管理员)
|
||||
async analyzeUserBehavior(userId: number, days: number = 7): Promise<{
|
||||
analysis: any
|
||||
analysis: Record<string, unknown>
|
||||
recommendations: string[]
|
||||
}> {
|
||||
const response = await apiClient.get(`/api/admin/monitoring/user-behavior/${userId}`, {
|
||||
|
||||
@@ -63,11 +63,13 @@ function createDemoAdapter(defaultAdapter: AxiosAdapter) {
|
||||
mockResponse.config = config
|
||||
return mockResponse
|
||||
}
|
||||
} catch (error: any) {
|
||||
} catch (error: unknown) {
|
||||
// Mock 错误需要附加 config,否则 handleResponseError 会崩溃
|
||||
if (error.response) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
error.config = config
|
||||
error.response.config = config
|
||||
if (error.response) {
|
||||
error.response.config = config
|
||||
}
|
||||
}
|
||||
throw error
|
||||
}
|
||||
@@ -130,14 +132,18 @@ class ApiClient {
|
||||
/**
|
||||
* 处理响应错误
|
||||
*/
|
||||
private async handleResponseError(error: any): Promise<any> {
|
||||
const originalRequest = error.config
|
||||
|
||||
private async handleResponseError(error: unknown): Promise<never> {
|
||||
// 请求被取消
|
||||
if (axios.isCancel(error)) {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
||||
if (!axios.isAxiosError(error)) {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
||||
const originalRequest = error.config
|
||||
|
||||
// 网络错误或服务器不可达
|
||||
if (!error.response) {
|
||||
log.warn('Network error or server unreachable', error.message)
|
||||
@@ -160,18 +166,18 @@ class ApiClient {
|
||||
/**
|
||||
* 处理401认证错误
|
||||
*/
|
||||
private async handle401Error(error: any, originalRequest: any): Promise<any> {
|
||||
private async handle401Error(error: import('axios').AxiosError, originalRequest: InternalAxiosRequestConfig & { _retry?: boolean; _retryCount?: number } | undefined): Promise<AxiosResponse> {
|
||||
// 如果不需要认证,直接返回错误
|
||||
if (isPublicEndpoint(originalRequest?.url, originalRequest?.method)) {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
||||
// 如果已经重试过,不再重试
|
||||
if (originalRequest._retry) {
|
||||
if (!originalRequest || originalRequest._retry) {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
||||
const errorDetail = error.response?.data?.detail || ''
|
||||
const errorDetail = (error.response?.data as Record<string, unknown>)?.detail as string || ''
|
||||
log.debug('Got 401 error, attempting token refresh', { errorDetail })
|
||||
|
||||
// 检查是否为业务相关的401错误(用户被禁用/删除等)
|
||||
@@ -221,9 +227,9 @@ class ApiClient {
|
||||
*/
|
||||
private async refreshTokenAndRetry(
|
||||
refreshToken: string,
|
||||
originalRequest: any,
|
||||
originalError: any
|
||||
): Promise<any> {
|
||||
originalRequest: InternalAxiosRequestConfig,
|
||||
originalError: import('axios').AxiosError
|
||||
): Promise<AxiosResponse> {
|
||||
this.isRefreshing = true
|
||||
this.refreshPromise = this.refreshToken(refreshToken)
|
||||
|
||||
@@ -237,8 +243,8 @@ class ApiClient {
|
||||
// 重试原始请求
|
||||
originalRequest.headers.Authorization = `Bearer ${response.data.access_token}`
|
||||
return this.client.request(originalRequest)
|
||||
} catch (refreshError: any) {
|
||||
log.error('Token refresh failed', refreshError)
|
||||
} catch (refreshError: unknown) {
|
||||
log.error('Token refresh failed', refreshError instanceof Error ? refreshError.message : String(refreshError))
|
||||
this.isRefreshing = false
|
||||
this.refreshPromise = null
|
||||
this.clearAuth()
|
||||
@@ -282,27 +288,27 @@ class ApiClient {
|
||||
}
|
||||
|
||||
// 以下方法直接委托给 axios client,Demo 模式由 adapter 统一处理
|
||||
async request<T = any>(config: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
async request<T = unknown>(config: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
return this.client.request<T>(config)
|
||||
}
|
||||
|
||||
async get<T = any>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
async get<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
return this.client.get<T>(url, config)
|
||||
}
|
||||
|
||||
async post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
async post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
return this.client.post<T>(url, data, config)
|
||||
}
|
||||
|
||||
async put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
async put<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
return this.client.put<T>(url, data, config)
|
||||
}
|
||||
|
||||
async patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
async patch<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
return this.client.patch<T>(url, data, config)
|
||||
}
|
||||
|
||||
async delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
async delete<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {
|
||||
return this.client.delete<T>(url, config)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,15 +165,15 @@ export interface RequestDetail {
|
||||
error_message?: string
|
||||
response_time_ms: number
|
||||
created_at: string
|
||||
request_headers?: Record<string, any>
|
||||
request_body?: Record<string, any>
|
||||
provider_request_headers?: Record<string, any>
|
||||
provider_request_body?: Record<string, any>
|
||||
response_headers?: Record<string, any>
|
||||
client_response_headers?: Record<string, any>
|
||||
response_body?: Record<string, any>
|
||||
client_response_body?: Record<string, any>
|
||||
metadata?: Record<string, any>
|
||||
request_headers?: Record<string, unknown>
|
||||
request_body?: Record<string, unknown>
|
||||
provider_request_headers?: Record<string, unknown>
|
||||
provider_request_body?: Record<string, unknown>
|
||||
response_headers?: Record<string, unknown>
|
||||
client_response_headers?: Record<string, unknown>
|
||||
response_body?: Record<string, unknown>
|
||||
client_response_body?: Record<string, unknown>
|
||||
metadata?: Record<string, unknown>
|
||||
// 阶梯计费信息
|
||||
tiered_pricing?: {
|
||||
total_input_context: number // 总输入上下文 (input + cache_read)
|
||||
@@ -211,7 +211,7 @@ export interface CurlData {
|
||||
url: string
|
||||
method: string
|
||||
headers: Record<string, string>
|
||||
body: Record<string, any>
|
||||
body: Record<string, unknown>
|
||||
curl: string
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ export interface ReplayRequest {
|
||||
provider_id?: string
|
||||
endpoint_id?: string
|
||||
api_key_id?: string
|
||||
body_override?: Record<string, any>
|
||||
body_override?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface ReplayResponse {
|
||||
@@ -227,7 +227,7 @@ export interface ReplayResponse {
|
||||
provider: string
|
||||
status_code: number
|
||||
response_headers: Record<string, string>
|
||||
response_body: Record<string, any>
|
||||
response_body: Record<string, unknown>
|
||||
response_time_ms: number
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export async function createEndpoint(
|
||||
body_rules?: BodyRule[]
|
||||
max_retries?: number
|
||||
is_active?: boolean
|
||||
config?: Record<string, any>
|
||||
config?: Record<string, unknown>
|
||||
proxy?: ProxyConfig | null
|
||||
format_acceptance_config?: FormatAcceptanceConfig | null
|
||||
}
|
||||
@@ -52,7 +52,7 @@ export async function updateEndpoint(
|
||||
body_rules: BodyRule[] | null
|
||||
max_retries: number
|
||||
is_active: boolean
|
||||
config: Record<string, any>
|
||||
config: Record<string, unknown> | null
|
||||
proxy: ProxyConfig | null
|
||||
format_acceptance_config: FormatAcceptanceConfig | null
|
||||
}>
|
||||
|
||||
@@ -59,7 +59,7 @@ export interface RevealKeyResult {
|
||||
auth_type: 'api_key' | 'vertex_ai' | 'oauth'
|
||||
api_key?: string
|
||||
refresh_token?: string
|
||||
auth_config?: string | Record<string, any>
|
||||
auth_config?: string | Record<string, unknown>
|
||||
}
|
||||
|
||||
export async function revealEndpointKey(keyId: string): Promise<RevealKeyResult> {
|
||||
@@ -70,7 +70,7 @@ export async function revealEndpointKey(keyId: string): Promise<RevealKeyResult>
|
||||
/**
|
||||
* 导出 OAuth Key 凭据(扁平 JSON,用于跨实例迁移)
|
||||
*/
|
||||
export async function exportKey(keyId: string): Promise<Record<string, any>> {
|
||||
export async function exportKey(keyId: string): Promise<Record<string, unknown>> {
|
||||
const response = await client.get(`/api/admin/endpoints/keys/${keyId}/export`)
|
||||
return response.data
|
||||
}
|
||||
@@ -104,7 +104,7 @@ export async function addProviderKey(
|
||||
api_formats: string[] // 支持的 API 格式列表(必填)
|
||||
api_key: string
|
||||
auth_type?: 'api_key' | 'vertex_ai' | 'oauth' // 认证类型
|
||||
auth_config?: Record<string, any> // 认证配置(Vertex AI Service Account JSON)
|
||||
auth_config?: Record<string, unknown> // 认证配置(Vertex AI Service Account JSON)
|
||||
name: string
|
||||
rate_multipliers?: Record<string, number> | null // 按 API 格式的成本倍率
|
||||
internal_priority?: number
|
||||
@@ -132,7 +132,7 @@ export async function updateProviderKey(
|
||||
api_formats: string[] // 支持的 API 格式列表
|
||||
api_key: string
|
||||
auth_type: 'api_key' | 'vertex_ai' | 'oauth' // 认证类型
|
||||
auth_config: Record<string, any> // 认证配置(Vertex AI Service Account JSON)
|
||||
auth_config: Record<string, unknown> // 认证配置(Vertex AI Service Account JSON)
|
||||
name: string
|
||||
rate_multipliers: Record<string, number> | null // 按 API 格式的成本倍率
|
||||
internal_priority: number
|
||||
@@ -175,7 +175,7 @@ export interface RefreshQuotaResult {
|
||||
key_name: string
|
||||
status: 'success' | 'no_metadata' | 'error'
|
||||
// Codex: 额度字段为扁平结构;Antigravity: 返回 { antigravity: { quota_by_model: ... } }
|
||||
metadata?: Record<string, any>
|
||||
metadata?: Record<string, unknown>
|
||||
message?: string
|
||||
status_code?: number
|
||||
}>
|
||||
|
||||
@@ -5,7 +5,6 @@ import type {
|
||||
ModelUpdate,
|
||||
ModelCatalogResponse,
|
||||
ProviderAvailableSourceModelsResponse,
|
||||
UpstreamModel,
|
||||
ImportFromUpstreamResponse,
|
||||
} from './types'
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ export interface Model {
|
||||
global_model_id?: string // 关联的 GlobalModel ID
|
||||
provider_model_name: string // Provider 侧的主模型名称
|
||||
provider_model_mappings?: ProviderModelMapping[] | null // 模型名称映射列表(带优先级)
|
||||
config?: Record<string, any> | null // 额外配置(如 billing/video 等)
|
||||
config?: Record<string, unknown> | null // 额外配置(如 billing/video 等)
|
||||
// 原始配置值(可能为空,为空时使用 GlobalModel 默认值)
|
||||
price_per_request?: number | null // 按次计费价格
|
||||
tiered_pricing?: TieredPricingConfig | null // 阶梯计费配置
|
||||
@@ -56,7 +56,7 @@ export interface Model {
|
||||
global_model_name?: string
|
||||
global_model_display_name?: string
|
||||
// 有效配置(合并 Model 和 GlobalModel 的 config)
|
||||
effective_config?: Record<string, any> | null
|
||||
effective_config?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface ModelCreate {
|
||||
@@ -73,7 +73,7 @@ export interface ModelCreate {
|
||||
supports_extended_thinking?: boolean
|
||||
supports_image_generation?: boolean
|
||||
is_active?: boolean
|
||||
config?: Record<string, any>
|
||||
config?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface ModelUpdate {
|
||||
@@ -89,7 +89,7 @@ export interface ModelUpdate {
|
||||
supports_image_generation?: boolean
|
||||
is_active?: boolean
|
||||
is_available?: boolean
|
||||
config?: Record<string, any> | null
|
||||
config?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface ModelCapabilities {
|
||||
@@ -183,7 +183,7 @@ export interface GlobalModelCreate {
|
||||
// Key 能力配置 - 模型支持的能力列表
|
||||
supported_capabilities?: string[]
|
||||
// 模型配置(JSON格式)- 包含能力、规格、元信息等
|
||||
config?: Record<string, any>
|
||||
config?: Record<string, unknown>
|
||||
is_active?: boolean
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ export interface GlobalModelUpdate {
|
||||
// Key 能力配置 - 模型支持的能力列表
|
||||
supported_capabilities?: string[] | null
|
||||
// 模型配置(JSON格式)- 包含能力、规格、元信息等
|
||||
config?: Record<string, any> | null
|
||||
config?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface GlobalModelResponse {
|
||||
@@ -212,7 +212,7 @@ export interface GlobalModelResponse {
|
||||
// Key 能力配置 - 模型支持的能力列表
|
||||
supported_capabilities?: string[] | null
|
||||
// 模型配置(JSON格式)
|
||||
config?: Record<string, any> | null
|
||||
config?: Record<string, unknown> | null
|
||||
// 统计数据
|
||||
provider_count?: number
|
||||
active_provider_count?: number
|
||||
|
||||
@@ -52,7 +52,7 @@ export type HeaderRule = HeaderRuleSet | HeaderRuleDrop | HeaderRuleRename
|
||||
export interface BodyRuleSet {
|
||||
action: 'set'
|
||||
path: string
|
||||
value: any
|
||||
value: unknown
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ export interface BodyRuleRename {
|
||||
export interface BodyRuleAppend {
|
||||
action: 'append'
|
||||
path: string
|
||||
value: any
|
||||
value: unknown
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ export interface BodyRuleInsert {
|
||||
action: 'insert'
|
||||
path: string
|
||||
index: number
|
||||
value: any
|
||||
value: unknown
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +132,7 @@ export type BodyRuleConditionOp =
|
||||
export interface BodyRuleCondition {
|
||||
path: string
|
||||
op: BodyRuleConditionOp
|
||||
value?: any // exists / not_exists 不需要 value
|
||||
value?: unknown // exists / not_exists 不需要 value
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ export interface ProviderEndpoint {
|
||||
body_rules?: BodyRule[] // 请求体规则列表,支持 set/drop/rename 操作
|
||||
max_retries: number
|
||||
is_active: boolean
|
||||
config?: Record<string, any>
|
||||
config?: Record<string, unknown>
|
||||
proxy?: ProxyConfig | null
|
||||
// 格式转换配置
|
||||
format_acceptance_config?: FormatAcceptanceConfig | null
|
||||
@@ -352,7 +352,7 @@ export interface EndpointAPIKeyUpdate {
|
||||
name?: string
|
||||
api_key?: string // 仅在需要更新时提供
|
||||
auth_type?: 'api_key' | 'vertex_ai' | 'oauth' // 认证类型
|
||||
auth_config?: Record<string, any> // 认证配置(Vertex AI Service Account JSON)
|
||||
auth_config?: Record<string, unknown> // 认证配置(Vertex AI Service Account JSON)
|
||||
rate_multipliers?: Record<string, number> | null // 按 API 格式的成本倍率
|
||||
internal_priority?: number
|
||||
global_priority_by_format?: Record<string, number> | null // 按 API 格式的全局优先级
|
||||
@@ -492,7 +492,7 @@ export interface HealthStatus {
|
||||
key_consecutive_failures?: number
|
||||
key_last_failure_at?: string
|
||||
key_is_active?: boolean
|
||||
key_statistics?: Record<string, any>
|
||||
key_statistics?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface HealthSummary {
|
||||
@@ -537,6 +537,6 @@ export interface AdaptiveStatsResponse {
|
||||
old_limit: number
|
||||
new_limit: number
|
||||
reason: string
|
||||
[key: string]: any
|
||||
[key: string]: unknown
|
||||
}>
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export interface UserPreferences {
|
||||
avatar_url?: string
|
||||
bio?: string
|
||||
default_provider_id?: string // UUID
|
||||
default_provider?: any
|
||||
default_provider?: Record<string, unknown>
|
||||
theme: string
|
||||
language: string
|
||||
timezone?: string
|
||||
@@ -216,7 +216,7 @@ export const meApi = {
|
||||
async getActiveRequests(ids?: string): Promise<{
|
||||
requests: Array<{
|
||||
id: string
|
||||
status: 'pending' | 'streaming' | 'completed' | 'failed'
|
||||
status: 'pending' | 'streaming' | 'completed' | 'failed' | 'cancelled'
|
||||
input_tokens: number
|
||||
output_tokens: number
|
||||
cache_creation_input_tokens?: number | null
|
||||
@@ -237,7 +237,7 @@ export const meApi = {
|
||||
},
|
||||
|
||||
// 获取可用的提供商
|
||||
async getAvailableProviders(): Promise<any[]> {
|
||||
async getAvailableProviders(): Promise<Array<Record<string, unknown>>> {
|
||||
const response = await apiClient.get('/api/users/me/providers')
|
||||
return response.data
|
||||
},
|
||||
@@ -256,7 +256,7 @@ export const meApi = {
|
||||
default_price_per_request: number | null
|
||||
default_tiered_pricing: TieredPricingConfig | null
|
||||
supported_capabilities: string[] | null
|
||||
config: Record<string, any> | null
|
||||
config: Record<string, unknown> | null
|
||||
}>
|
||||
total: number
|
||||
}> {
|
||||
@@ -265,7 +265,7 @@ export const meApi = {
|
||||
},
|
||||
|
||||
// 获取端点状态(不包含敏感信息)
|
||||
async getEndpointStatus(): Promise<any[]> {
|
||||
async getEndpointStatus(): Promise<Array<Record<string, unknown>>> {
|
||||
const response = await apiClient.get('/api/users/me/endpoint-status')
|
||||
return response.data
|
||||
},
|
||||
|
||||
@@ -44,8 +44,8 @@ export interface OAuthProviderAdminConfig {
|
||||
scopes?: string[] | null
|
||||
redirect_uri: string
|
||||
frontend_callback_url: string
|
||||
attribute_mapping?: Record<string, any> | null
|
||||
extra_config?: Record<string, any> | null
|
||||
attribute_mapping?: Record<string, unknown> | null
|
||||
extra_config?: Record<string, unknown> | null
|
||||
is_enabled: boolean
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ export interface OAuthProviderUpsertRequest {
|
||||
scopes?: string[] | null
|
||||
redirect_uri: string
|
||||
frontend_callback_url: string
|
||||
attribute_mapping?: Record<string, any> | null
|
||||
extra_config?: Record<string, any> | null
|
||||
attribute_mapping?: Record<string, unknown> | null
|
||||
extra_config?: Record<string, unknown> | null
|
||||
is_enabled: boolean
|
||||
force?: boolean
|
||||
}
|
||||
|
||||
@@ -45,17 +45,17 @@ export interface ArchitectureInfo {
|
||||
architecture_id: string
|
||||
display_name: string
|
||||
description: string
|
||||
credentials_schema: Record<string, any>
|
||||
credentials_schema: Record<string, unknown>
|
||||
supported_auth_types: Array<{
|
||||
type: string
|
||||
display_name: string
|
||||
credentials_schema?: Record<string, any>
|
||||
credentials_schema?: Record<string, unknown>
|
||||
}>
|
||||
supported_actions: Array<{
|
||||
type: string
|
||||
display_name: string
|
||||
description: string
|
||||
config_schema: Record<string, any>
|
||||
config_schema: Record<string, unknown>
|
||||
}>
|
||||
default_connector: string | null
|
||||
}
|
||||
@@ -85,7 +85,7 @@ export interface BalanceInfo {
|
||||
total_available: number | null
|
||||
expires_at: string | null
|
||||
currency: string
|
||||
extra: Record<string, any> & {
|
||||
extra: Record<string, unknown> & {
|
||||
// Anyrouter 签到信息
|
||||
checkin_success?: boolean | null // true=成功, false=失败, null=已签到/跳过
|
||||
checkin_message?: string
|
||||
@@ -98,7 +98,7 @@ export interface CheckinInfo {
|
||||
streak_days: number | null
|
||||
next_reward: number | null
|
||||
message: string | null
|
||||
extra: Record<string, any>
|
||||
extra: Record<string, unknown>
|
||||
}
|
||||
|
||||
/** 操作结果响应 */
|
||||
@@ -115,14 +115,14 @@ export interface ActionResultResponse {
|
||||
/** 连接器配置请求 */
|
||||
export interface ConnectorConfigRequest {
|
||||
auth_type: ConnectorAuthType
|
||||
config: Record<string, any>
|
||||
credentials: Record<string, any>
|
||||
config: Record<string, unknown>
|
||||
credentials: Record<string, unknown>
|
||||
}
|
||||
|
||||
/** 操作配置请求 */
|
||||
export interface ActionConfigRequest {
|
||||
enabled: boolean
|
||||
config: Record<string, any>
|
||||
config: Record<string, unknown>
|
||||
}
|
||||
|
||||
/** 保存配置请求 */
|
||||
@@ -136,12 +136,12 @@ export interface SaveConfigRequest {
|
||||
|
||||
/** 连接请求 */
|
||||
export interface ConnectRequest {
|
||||
credentials?: Record<string, any>
|
||||
credentials?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/** 执行操作请求 */
|
||||
export interface ExecuteActionRequest {
|
||||
config?: Record<string, any>
|
||||
config?: Record<string, unknown>
|
||||
}
|
||||
|
||||
// ==================== API Functions ====================
|
||||
@@ -186,8 +186,8 @@ export interface ProviderOpsConfigResponse {
|
||||
base_url?: string
|
||||
connector?: {
|
||||
auth_type: string
|
||||
config: Record<string, any>
|
||||
credentials: Record<string, any>
|
||||
config: Record<string, unknown>
|
||||
credentials: Record<string, unknown>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,9 +339,9 @@ export interface VerifyAuthResponse {
|
||||
quota?: number
|
||||
used_quota?: number
|
||||
request_count?: number
|
||||
extra?: Record<string, any>
|
||||
extra?: Record<string, unknown>
|
||||
}
|
||||
updated_credentials?: Record<string, any>
|
||||
updated_credentials?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ export interface ProxyNode {
|
||||
proxy_username?: string
|
||||
proxy_password?: string // 脱敏后的密码
|
||||
// 硬件信息(aether-proxy 节点)
|
||||
hardware_info: Record<string, any> | null
|
||||
hardware_info: Record<string, unknown> | null
|
||||
estimated_max_concurrency: number | null
|
||||
// 远程配置(aether-proxy 节点)
|
||||
remote_config: ProxyNodeRemoteConfig | null
|
||||
|
||||
@@ -16,7 +16,7 @@ export interface PublicGlobalModel {
|
||||
// Key 能力支持
|
||||
supported_capabilities: string[] | null
|
||||
// 模型配置(JSON)
|
||||
config: Record<string, any> | null
|
||||
config: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface PublicGlobalModelListResponse {
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface CandidateRecord {
|
||||
error_message?: string
|
||||
latency_ms?: number
|
||||
concurrent_requests?: number
|
||||
extra_data?: Record<string, any>
|
||||
extra_data?: Record<string, unknown>
|
||||
created_at: string
|
||||
started_at?: string
|
||||
finished_at?: string
|
||||
|
||||
@@ -182,7 +182,7 @@ export const usageApi = {
|
||||
limit?: number
|
||||
offset?: number
|
||||
}): Promise<{
|
||||
records: any[]
|
||||
records: Array<Record<string, unknown>>
|
||||
total: number
|
||||
limit: number
|
||||
offset: number
|
||||
@@ -198,7 +198,7 @@ export const usageApi = {
|
||||
async getActiveRequests(ids?: string[]): Promise<{
|
||||
requests: Array<{
|
||||
id: string
|
||||
status: 'pending' | 'streaming' | 'completed' | 'failed'
|
||||
status: 'pending' | 'streaming' | 'completed' | 'failed' | 'cancelled'
|
||||
input_tokens: number
|
||||
output_tokens: number
|
||||
cache_creation_input_tokens?: number | null
|
||||
|
||||
@@ -101,7 +101,7 @@ export const usersApi = {
|
||||
},
|
||||
|
||||
// 管理员统计
|
||||
async getUsageStats(): Promise<any> {
|
||||
async getUsageStats(): Promise<Record<string, unknown>> {
|
||||
const response = await apiClient.get('/api/admin/usage/stats')
|
||||
return response.data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user