import { z } from "zod/v4"; const annotationTypeEnum = z.enum([ "RECTANGLE", "ELLIPSE", "ARROW", "FREEHAND", "TEXT", "PIN", "SCREENSHOT", ]); export type AnnotationTypeValue = z.infer; /** * Shape data varies by annotation type. We use a loose Json schema * here and validate more specifically in the service layer if needed. */ const annotationDataSchema = z.object({ x: z.number().optional(), y: z.number().optional(), width: z.number().optional(), height: z.number().optional(), endX: z.number().optional(), endY: z.number().optional(), points: z.array(z.object({ x: z.number(), y: z.number() })).optional(), text: z.string().optional(), color: z.string().optional(), strokeWidth: z.number().optional(), imageUrl: z.string().optional(), }); export const createAnnotationSchema = z.object({ type: annotationTypeEnum, data: annotationDataSchema, imageX: z.number(), imageY: z.number(), timestampSeconds: z.number().nullable().optional(), // null/undefined for image, number for video commentContent: z.string().min(1, "Comment text is required"), stageId: z.string().min(1, "Stage ID is required"), }); export type CreateAnnotationInput = z.infer; export const updateAnnotationSchema = z.object({ data: annotationDataSchema.optional(), imageX: z.number().optional(), imageY: z.number().optional(), timestampSeconds: z.number().nullable().optional(), }); export type UpdateAnnotationInput = z.infer;