fix(provider): type auth errors (#27301)
This commit is contained in:
@@ -10,6 +10,26 @@ import { described } from "./metadata"
|
||||
|
||||
const root = "/provider"
|
||||
|
||||
const ProviderAuthErrorName = Schema.Union([
|
||||
Schema.Literal("BadRequest"),
|
||||
Schema.Literal("ProviderAuthOauthMissing"),
|
||||
Schema.Literal("ProviderAuthOauthCodeMissing"),
|
||||
Schema.Literal("ProviderAuthOauthCallbackFailed"),
|
||||
Schema.Literal("ProviderAuthValidationFailed"),
|
||||
])
|
||||
export class ProviderAuthApiError extends Schema.ErrorClass<ProviderAuthApiError>("ProviderAuthError")(
|
||||
{
|
||||
name: ProviderAuthErrorName,
|
||||
data: Schema.Struct({
|
||||
providerID: Schema.optional(ProviderID),
|
||||
field: Schema.optional(Schema.String),
|
||||
message: Schema.optional(Schema.String),
|
||||
kind: Schema.optional(Schema.String),
|
||||
}),
|
||||
},
|
||||
{ httpApiStatus: 400 },
|
||||
) {}
|
||||
|
||||
export const ProviderApi = HttpApi.make("provider")
|
||||
.add(
|
||||
HttpApiGroup.make("provider")
|
||||
@@ -39,7 +59,7 @@ export const ProviderApi = HttpApi.make("provider")
|
||||
query: WorkspaceRoutingQuery,
|
||||
payload: ProviderAuth.AuthorizeInput,
|
||||
success: described(Schema.UndefinedOr(ProviderAuth.Authorization), "Authorization URL and method"),
|
||||
error: HttpApiError.BadRequest,
|
||||
error: ProviderAuthApiError,
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "provider.oauth.authorize",
|
||||
@@ -52,7 +72,7 @@ export const ProviderApi = HttpApi.make("provider")
|
||||
query: WorkspaceRoutingQuery,
|
||||
payload: ProviderAuth.CallbackInput,
|
||||
success: described(Schema.Boolean, "OAuth callback processed successfully"),
|
||||
error: HttpApiError.BadRequest,
|
||||
error: ProviderAuthApiError,
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "provider.oauth.callback",
|
||||
|
||||
Reference in New Issue
Block a user