opencode/packages/stories/mocks/app/context/server-sync.ts

25 lines
673 B
TypeScript

import type { IntegrationMethod } from "@opencode/client/promise"
type ProviderAuthMethod = Extract<IntegrationMethod, { type: "key" | "oauth" }>
const data = {
provider: {
all: new Map(),
connected: [],
default: {},
},
provider_auth: {} as Record<string, ProviderAuthMethod[]>,
config: { disabled_providers: [] as string[] },
}
export function mockProviderAuth(provider: string, methods: ProviderAuthMethod[]) {
const previous = data.provider_auth[provider]
data.provider_auth[provider] = methods
return () => {
if (previous) {
data.provider_auth[provider] = previous
return
}
delete data.provider_auth[provider]
}
}