feat(lib): add AI event Zod schemas for request validation and response parsing

This commit is contained in:
2026-04-07 11:57:11 -04:00
parent 6944215578
commit 3d6999312c

View File

@@ -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<typeof AiEventRequestSchema>;
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 = { export type CalendarEvent = {
id: string; id: string;
title: string; title: string;