mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
- 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
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const AuthEntrySchema = z.object({
|
|
type: z.enum(["api", "oauth"]),
|
|
key: z.string().optional(),
|
|
refresh: z.string().optional(),
|
|
access: z.string().optional(),
|
|
expires: z.number().optional(),
|
|
});
|
|
|
|
export const AuthCredentialsSchema = z.record(z.string(), AuthEntrySchema);
|
|
|
|
export const SetCredentialRequestSchema = z.object({
|
|
apiKey: z.string().min(1),
|
|
});
|
|
|
|
export const CredentialStatusResponseSchema = z.object({
|
|
hasCredentials: z.boolean(),
|
|
});
|
|
|
|
export const CredentialListResponseSchema = z.object({
|
|
providers: z.array(z.string()),
|
|
});
|
|
|
|
export const PromptFieldSchema = z.discriminatedUnion("type", [
|
|
z.object({
|
|
type: z.literal("text"),
|
|
key: z.string(),
|
|
message: z.string(),
|
|
placeholder: z.string().optional(),
|
|
}),
|
|
z.object({
|
|
type: z.literal("select"),
|
|
key: z.string(),
|
|
message: z.string(),
|
|
options: z.array(z.object({
|
|
label: z.string(),
|
|
value: z.string(),
|
|
})),
|
|
when: z.object({
|
|
key: z.string(),
|
|
value: z.string(),
|
|
}).optional(),
|
|
}),
|
|
]);
|
|
|
|
export const ProviderAuthMethodSchema = z.object({
|
|
type: z.enum(["oauth", "api"]),
|
|
label: z.string(),
|
|
prompts: z.array(PromptFieldSchema).optional(),
|
|
});
|
|
|
|
export const ProviderAuthMethodsSchema = z.record(z.string(), z.array(ProviderAuthMethodSchema));
|
|
|
|
export const OAuthAuthorizeRequestSchema = z.object({
|
|
method: z.number(),
|
|
inputs: z.record(z.string(), z.string()).optional(),
|
|
});
|
|
|
|
export const OAuthAuthorizeResponseSchema = z.object({
|
|
url: z.string(),
|
|
method: z.enum(["auto", "code"]),
|
|
instructions: z.string(),
|
|
});
|
|
|
|
export const OAuthCallbackRequestSchema = z.object({
|
|
method: z.number(),
|
|
code: z.string().optional(),
|
|
});
|
|
|
|
export const ProviderAuthMethodsResponseSchema = z.object({
|
|
providers: z.record(z.string(), z.array(ProviderAuthMethodSchema)),
|
|
}).or(ProviderAuthMethodsSchema);
|