From 3d6999312cd963d0887d59107767f7687206d2a2 Mon Sep 17 00:00:00 2001 From: Dmytro Stanchiev Date: Tue, 7 Apr 2026 11:57:11 -0400 Subject: [PATCH] feat(lib): add AI event Zod schemas for request validation and response parsing --- src/lib/types.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/lib/types.ts b/src/lib/types.ts index 1d8293c..4f63518 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -1,3 +1,34 @@ +import { z } from "zod"; + +export const AiEventRequestSchema = z + .object({ + prompt: z.string().trim().max(2000).optional(), + imageBase64: z + .string() + .startsWith("data:", "Must be a valid data URL") + .max(10 * 1024 * 1024 * 1.37, "Image must be less than 10MB") + .optional(), + }) + .refine((data) => data.prompt || data.imageBase64, { + message: "Either a prompt or an image is required", + }); + +export type AiEventRequest = z.infer; + +export const AiEventResponseItemSchema = z.object({ + id: z.string().optional(), + title: z.string().min(1), + description: z.string().optional(), + location: z.string().optional(), + url: z.string().optional(), + start: z.string(), + end: z.string().optional(), + allDay: z.boolean().optional(), + recurrenceRule: z.string().optional(), +}); + +export const AiEventResponseSchema = z.array(AiEventResponseItemSchema); + export type CalendarEvent = { id: string; title: string;