diff --git a/src/services/api/providers.ts b/src/services/api/providers.ts index 3d9ee43..1f953ea 100644 --- a/src/services/api/providers.ts +++ b/src/services/api/providers.ts @@ -22,25 +22,18 @@ const serializeHeaders = (headers?: Record) => const isRecord = (value: unknown): value is Record => value !== null && typeof value === 'object' && !Array.isArray(value); -const RESPONSE_ONLY_FIELDS = ['auth-index', 'authIndex', 'auth_index'] as const; +const RESPONSE_ONLY_FIELDS = ['auth-index'] as const; const PROVIDER_KEY_FIELDS = [ 'api-key', - 'apiKey', 'priority', 'prefix', 'base-url', - 'baseUrl', - 'base_url', 'websockets', 'proxy-url', - 'proxyUrl', - 'proxy_url', 'headers', 'models', 'excluded-models', - 'excludedModels', - 'excluded_models', 'cloak', ] as const; @@ -55,52 +48,17 @@ const OPENAI_PROVIDER_FIELDS = [ 'disabled', 'prefix', 'base-url', - 'baseUrl', - 'base_url', 'api-key-entries', - 'apiKeyEntries', - 'api_key_entries', - 'api-keys', - 'apiKeys', - 'api_keys', 'headers', 'models', 'test-model', - 'testModel', - 'test_model', ] as const; -const MODEL_ALIAS_FIELDS = [ - 'name', - 'id', - 'model', - 'alias', - 'display_name', - 'displayName', - 'priority', - 'test-model', - 'testModel', - 'test_model', -] as const; +const MODEL_ALIAS_FIELDS = ['name', 'alias', 'priority', 'test-model'] as const; -const API_KEY_ENTRY_FIELDS = [ - 'api-key', - 'apiKey', - 'key', - 'proxy-url', - 'proxyUrl', - 'proxy_url', -] as const; +const API_KEY_ENTRY_FIELDS = ['api-key', 'proxy-url'] as const; -const CLOAK_FIELDS = [ - 'mode', - 'strict-mode', - 'strictMode', - 'strict_mode', - 'sensitive-words', - 'sensitiveWords', - 'sensitive_words', -] as const; +const CLOAK_FIELDS = ['mode', 'strict-mode', 'sensitive-words'] as const; const RAW_SECTION_ALIASES: Record = { 'gemini-api-key': ['gemini-api-key', 'geminiApiKey', 'geminiApiKeys'], @@ -121,20 +79,19 @@ const getStringField = (record: Record, keys: readonly string[] }; const providerKeyIdentity = (record: Record) => { - const apiKey = getStringField(record, ['api-key', 'apiKey']); + const apiKey = getStringField(record, ['api-key']); if (!apiKey) return ''; - const baseUrl = getStringField(record, ['base-url', 'baseUrl', 'base_url']); + const baseUrl = getStringField(record, ['base-url']); return `${apiKey}\u0000${baseUrl}`; }; const openAIProviderIdentity = (record: Record) => - getStringField(record, ['name', 'id']); + getStringField(record, ['name']); -const modelIdentity = (record: Record) => - getStringField(record, ['name', 'id', 'model']); +const modelIdentity = (record: Record) => getStringField(record, ['name']); const apiKeyEntryIdentity = (record: Record) => - getStringField(record, ['api-key', 'apiKey', 'key']); + getStringField(record, ['api-key']); const cloneWithoutKnownFields = ( raw: unknown, @@ -246,9 +203,7 @@ const mergeProviderKeyPayload = ( const mergeOpenAIProviderPayload = (raw: unknown, payload: Record) => { const next = mergeKnownFields(raw, payload, OPENAI_PROVIDER_FIELDS); - const rawApiKeyEntries = isRecord(raw) - ? (raw['api-key-entries'] ?? raw.apiKeyEntries) - : undefined; + const rawApiKeyEntries = isRecord(raw) ? raw['api-key-entries'] : undefined; const apiKeyEntries = payload['api-key-entries']; if (Array.isArray(apiKeyEntries)) { next['api-key-entries'] = mergeKnownRecordList(