Skip to content

Commit 167229f

Browse files
committed
Refactor checkExistKey to use centralized SECRET_KEYS array
1 parent 381b078 commit 167229f

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/shared/checkExistApiConfig.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
import { ApiConfiguration } from "../shared/api"
2+
import { SECRET_KEYS } from "./globalState"
23

34
export function checkExistKey(config: ApiConfiguration | undefined) {
4-
return config
5-
? [
6-
config.apiKey,
7-
config.glamaApiKey,
8-
config.openRouterApiKey,
9-
config.awsRegion,
10-
config.vertexProjectId,
11-
config.openAiApiKey,
12-
config.ollamaModelId,
13-
config.lmStudioModelId,
14-
config.geminiApiKey,
15-
config.openAiNativeApiKey,
16-
config.deepSeekApiKey,
17-
config.mistralApiKey,
18-
config.vsCodeLmModelSelector,
19-
config.requestyApiKey,
20-
config.unboundApiKey,
21-
].some((key) => key !== undefined)
22-
: false
5+
if (!config) return false
6+
7+
// Check all secret keys from the centralized SECRET_KEYS array
8+
const hasSecretKey = SECRET_KEYS.some((key) => config[key as keyof ApiConfiguration] !== undefined)
9+
10+
// Check additional non-secret configuration properties
11+
const hasOtherConfig = [
12+
config.awsRegion,
13+
config.vertexProjectId,
14+
config.ollamaModelId,
15+
config.lmStudioModelId,
16+
config.vsCodeLmModelSelector,
17+
].some((value) => value !== undefined)
18+
19+
return hasSecretKey || hasOtherConfig
2320
}

0 commit comments

Comments
 (0)