fix: update InitiateOAuthSchema to be non-optional for proper zValidator typing

Co-Authored-By: Dallin Bentley <dallinbentley98@gmail.com>
This commit is contained in:
Devin AI 2025-07-18 04:44:25 +00:00
parent e45c253344
commit eeb2959920
4 changed files with 12 additions and 14 deletions

View File

@ -19,7 +19,7 @@ import { updateIntegrationHandler } from './update-integration';
const app = new Hono() const app = new Hono()
// Public endpoints (no auth required for OAuth flow) // Public endpoints (no auth required for OAuth flow)
.post('/auth/init', requireAuth, zValidator('json', z.object({}).merge(InitiateOAuthSchema.unwrap())), initiateOAuthHandler) .post('/auth/init', requireAuth, zValidator('json', InitiateOAuthSchema), initiateOAuthHandler)
.get('/auth/callback', handleOAuthCallbackHandler) .get('/auth/callback', handleOAuthCallbackHandler)
// Protected endpoints // Protected endpoints
.get('/integration', requireAuth, getIntegrationHandler) .get('/integration', requireAuth, getIntegrationHandler)

View File

@ -46,7 +46,7 @@ export async function initiateOAuthHandler(c: Context): Promise<Response> {
throw new HTTPException(400, { message: 'Organization not found' }); throw new HTTPException(400, { message: 'Organization not found' });
} }
const request = c.req.valid('json') as InitiateOAuthRequest; const request = c.req.valid('json');
const metadata = request?.metadata; const metadata = request?.metadata;
const enrichedMetadata = { const enrichedMetadata = {

View File

@ -23,7 +23,7 @@ export async function updateIntegrationHandler(c: Context): Promise<Response> {
} }
try { try {
const request = c.req.valid('json') as UpdateIntegrationRequest; const request = c.req.valid('json');
const updateData: { const updateData: {
defaultChannel?: { id: string; name: string }; defaultChannel?: { id: string; name: string };

View File

@ -11,17 +11,15 @@ const SlackSharingPermissionEnum: Record<SlackSharingPermissionBase, SlackSharin
}); });
// POST /api/v2/slack/auth/init // POST /api/v2/slack/auth/init
export const InitiateOAuthSchema = z export const InitiateOAuthSchema = z.object({
.object({ metadata: z
metadata: z .object({
.object({ return_url: z.string().optional(),
return_url: z.string().optional(), source: z.string().optional(),
source: z.string().optional(), project_id: z.string().uuid().optional(),
project_id: z.string().uuid().optional(), })
}) .optional(),
.optional(), });
})
.optional();
export type InitiateOAuthRequest = z.infer<typeof InitiateOAuthSchema>; export type InitiateOAuthRequest = z.infer<typeof InitiateOAuthSchema>;