refactor(core): harden API parsing and improve type safety

This commit is contained in:
LTbinglingfeng
2026-02-08 09:42:00 +08:00
parent 3783bec983
commit 6c2cd761ba
39 changed files with 689 additions and 404 deletions

View File

@@ -17,8 +17,8 @@ export interface ApiClientConfig {
export interface RequestOptions {
method?: HttpMethod;
headers?: Record<string, string>;
params?: Record<string, any>;
data?: any;
params?: Record<string, unknown>;
data?: unknown;
}
// 服务器版本信息
@@ -31,6 +31,6 @@ export interface ServerVersion {
export type ApiError = Error & {
status?: number;
code?: string;
details?: any;
data?: any;
details?: unknown;
data?: unknown;
};

View File

@@ -26,7 +26,7 @@ export interface AuthFileItem {
runtimeOnly?: boolean | string;
disabled?: boolean;
modified?: number;
[key: string]: any;
[key: string]: unknown;
}
export interface AuthFilesResponse {

View File

@@ -15,7 +15,7 @@ export interface Notification {
duration?: number;
}
export interface ApiResponse<T = any> {
export interface ApiResponse<T = unknown> {
data?: T;
error?: string;
message?: string;

View File

@@ -31,7 +31,7 @@ export interface Config {
vertexApiKeys?: ProviderKeyConfig[];
openaiCompatibility?: OpenAIProviderConfig[];
oauthExcludedModels?: Record<string, string[]>;
raw?: Record<string, any>;
raw?: Record<string, unknown>;
}
export type RawConfigSection =

View File

@@ -11,7 +11,7 @@ export interface LogEntry {
timestamp: string;
level: LogLevel;
message: string;
details?: any;
details?: unknown;
}
// 日志筛选

View File

@@ -43,5 +43,5 @@ export interface OpenAIProviderConfig {
models?: ModelAlias[];
priority?: number;
testModel?: string;
[key: string]: any;
[key: string]: unknown;
}

View File

@@ -10,7 +10,7 @@ export type PayloadParamEntry = {
export type PayloadModelEntry = {
id: string;
name: string;
protocol?: 'openai' | 'gemini' | 'claude' | 'codex' | 'antigravity';
protocol?: 'openai' | 'openai-response' | 'gemini' | 'claude' | 'codex' | 'antigravity';
};
export type PayloadRule = {