mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
fix(frontend): load provider integrations through the typed OpenCode client
Fetch integrations with callOpenCode instead of a dedicated backend route, drop the unused provider credentials list query, label an existing key as "Edit API key", and keep the loaded provider list when a background refetch fails.
This commit is contained in:
1 parent
b179267376
commit
99713e15b4
13 files changed
+44
-84
No files matched your search
@@ -2,6 +2,7 @@ import { API_BASE_URL } from "@/config"
|
||||
import type { FormAnswer, IntegrationInfo, IntegrationMethod } from "@opencode-manager/shared/opencode"
|
||||
import type { OAuthAttemptStatus, OAuthAuthorizeResponse } from "@opencode-manager/shared/schemas"
|
||||
import { fetchWrapper, fetchWrapperVoid } from "./fetchWrapper"
|
||||
import { callOpenCode } from "./opencodeApi"
|
||||
|
||||
export type {
|
||||
FormAnswer,
|
||||
@@ -48,9 +49,7 @@ export const oauthApi = {
|
||||
},
|
||||
|
||||
getIntegrations: async (): Promise<IntegrationInfo[]> => {
|
||||
const { integrations } = await fetchWrapper<{ integrations: IntegrationInfo[] }>(
|
||||
`${API_BASE_URL}/api/oauth/integrations`
|
||||
)
|
||||
return integrations
|
||||
const { data } = await callOpenCode((api) => api.integration.list())
|
||||
return data
|
||||
},
|
||||
}
|
||||
@@ -304,13 +304,6 @@ describe('providerCredentialsApi', () => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('lists provider ids with credentials from the Manager response', async () => {
|
||||
mockFetchWrapper.mockResolvedValue({ providers: ['anthropic', 'openai'] })
|
||||
|
||||
await expect(providerCredentialsApi.list()).resolves.toEqual(['anthropic', 'openai'])
|
||||
expect(mockFetchWrapper).toHaveBeenCalledWith(`${API_BASE_URL}/api/providers/credentials`)
|
||||
})
|
||||
|
||||
it('reports credential status from the Manager response', async () => {
|
||||
mockFetchWrapper.mockResolvedValue({ hasCredentials: true })
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
type ModelPreferenceModel,
|
||||
type ModelRef,
|
||||
} from "@opencode-manager/shared/opencode";
|
||||
import type { CredentialListResponse, CredentialStatusResponse } from "@opencode-manager/shared/schemas";
|
||||
import type { CredentialStatusResponse } from "@opencode-manager/shared/schemas";
|
||||
|
||||
export type Model = Pick<ModelInfo, 'id' | 'modelID' | 'name'> & {
|
||||
limit?: {
|
||||
@@ -186,11 +186,6 @@ export function formatProviderName(provider: Provider): string {
|
||||
}
|
||||
|
||||
export const providerCredentialsApi = {
|
||||
list: async (): Promise<string[]> => {
|
||||
const { providers } = await fetchWrapper<CredentialListResponse>(`${API_BASE_URL}/api/providers/credentials`);
|
||||
return providers;
|
||||
},
|
||||
|
||||
getStatus: async (providerId: string): Promise<boolean> => {
|
||||
const { hasCredentials } = await fetchWrapper<CredentialStatusResponse>(
|
||||
`${API_BASE_URL}/api/providers/${providerId}/credentials/status`
|
||||
|
||||
Reference in new issue
Block a user