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;