mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 21:04:23 +01:00
feat: add dynamic OAuth prompt system with conditional fields
- Add PromptFieldSchema supporting text and select input types - Support conditional prompt visibility based on previous inputs - Add inputs parameter to OAuth authorize request - Update OAuth dialogs to render dynamic prompts - Add OPENCODE_PUBLIC_URL config for OAuth callback URLs - Remove redundant OAuthMethod enum in favor of backend schema
This commit is contained in:
1 parent
9d94c333b4
commit
2b5e130916
12 files changed
+371
-78
No files matched your search
@@ -1,21 +1,14 @@
|
||||
import { API_BASE_URL } from "@/config"
|
||||
import type { components, operations } from "./opencode-types"
|
||||
import { fetchWrapper, FetchError } from "./fetchWrapper"
|
||||
|
||||
export interface OAuthAuthorizeResponse {
|
||||
url: string
|
||||
method: "code"
|
||||
instructions: string
|
||||
}
|
||||
type OpenCodeAuthorizeRequest = NonNullable<operations["provider.oauth.authorize"]["requestBody"]>["content"]["application/json"]
|
||||
|
||||
export interface OAuthCallbackRequest {
|
||||
method: number
|
||||
code?: string
|
||||
}
|
||||
export type OAuthAuthorizeResponse = components["schemas"]["ProviderAuthAuthorization"]
|
||||
|
||||
export interface ProviderAuthMethod {
|
||||
type: "oauth" | "api"
|
||||
label: string
|
||||
}
|
||||
export type OAuthCallbackRequest = NonNullable<operations["provider.oauth.callback"]["requestBody"]>["content"]["application/json"]
|
||||
|
||||
export type ProviderAuthMethod = components["schemas"]["ProviderAuthMethod"]
|
||||
|
||||
export interface ProviderAuthMethods {
|
||||
[providerId: string]: ProviderAuthMethod[]
|
||||
@@ -29,12 +22,12 @@ function handleApiError(error: unknown, context: string): never {
|
||||
}
|
||||
|
||||
export const oauthApi = {
|
||||
authorize: async (providerId: string, method: number): Promise<OAuthAuthorizeResponse> => {
|
||||
authorize: async (providerId: string, method: number, inputs?: OpenCodeAuthorizeRequest["inputs"]): Promise<OAuthAuthorizeResponse> => {
|
||||
try {
|
||||
return await fetchWrapper(`${API_BASE_URL}/api/oauth/${providerId}/oauth/authorize`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ method }),
|
||||
body: JSON.stringify({ method, inputs }),
|
||||
})
|
||||
} catch (error) {
|
||||
handleApiError(error, "OAuth authorization failed")
|
||||
|
||||
Reference in new issue
Block a user