Isolate providers per client: add provider targets and a Codex-side form
This commit is contained in:
1 parent
adc8234cc9
commit
d759fe5e5d
13 files changed
+595
-309
No files matched your search
+3
-1
@@ -50,11 +50,13 @@ export interface ProviderInput {
|
||||
base_url: string;
|
||||
api_key: string;
|
||||
models: Models;
|
||||
target: ApplyTarget;
|
||||
}
|
||||
|
||||
export const api = {
|
||||
getStatus: () => request<Status>("/api/status"),
|
||||
listProviders: () => request<{ items: Provider[] }>("/api/providers"),
|
||||
listProviders: (target?: ApplyTarget) =>
|
||||
request<{ items: Provider[] }>(target ? `/api/providers?target=${target}` : "/api/providers"),
|
||||
createProvider: (input: ProviderInput) =>
|
||||
request<Provider>("/api/providers", { method: "POST", body: JSON.stringify(input) }),
|
||||
updateProvider: (id: string, input: ProviderInput) =>
|
||||
|
||||
+7
-4
@@ -3,7 +3,7 @@ import { api, type ProviderInput } from "./api";
|
||||
|
||||
export const queryKeys = {
|
||||
status: ["status"] as const,
|
||||
providers: ["providers"] as const,
|
||||
providers: (target: string) => ["providers", target] as const,
|
||||
logs: ["logs"] as const,
|
||||
backups: (target: string) => ["backups", target] as const,
|
||||
settings: ["settings"] as const,
|
||||
@@ -13,8 +13,11 @@ export function useStatus() {
|
||||
return useQuery({ queryKey: queryKeys.status, queryFn: api.getStatus, refetchInterval: 5000 });
|
||||
}
|
||||
|
||||
export function useProviders() {
|
||||
return useQuery({ queryKey: queryKeys.providers, queryFn: api.listProviders });
|
||||
export function useProviders(target: "claude" | "codex") {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.providers(target),
|
||||
queryFn: () => api.listProviders(target),
|
||||
});
|
||||
}
|
||||
|
||||
export function useLogs() {
|
||||
@@ -31,7 +34,7 @@ export function useSettings() {
|
||||
|
||||
function invalidateAll(queryClient: ReturnType<typeof useQueryClient>) {
|
||||
return Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.providers }),
|
||||
queryClient.invalidateQueries({ queryKey: ["providers"] }),
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.status }),
|
||||
queryClient.invalidateQueries({ queryKey: ["backups"] }),
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.settings }),
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface Provider {
|
||||
models: Models;
|
||||
enabled_for_claude: boolean;
|
||||
enabled_for_codex: boolean;
|
||||
target: "claude" | "codex";
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user