refactor: refactor data schemas

This commit is contained in:
johannes-hernehult 2026-06-10 19:37:22 +02:00
parent efa9789a2a
commit 0176a59865

View file

@ -1,21 +1,16 @@
import { z } from "zod"; import { z } from "zod";
export const ImageSchema = z.object({ export const StepsSchema = z.object({
id: z.uuid().default(() => crypto.randomUUID()), id: z.uuid().default(() => crypto.randomUUID()),
file: z.instanceof(File), text: z.string().min(1, "Text is required"),
alt: z.string().default(""), order: z.number(),
width: z.number(), frameId: z.uuid(),
height: z.number(),
size: z.number(),
mimeType: z.string(),
createdAt: z.date(),
updatedAt: z.date(),
}); });
export const FrameSchema = z.object({ export const FrameSchema = z.object({
id: z.uuid().default(() => crypto.randomUUID()), id: z.uuid().default(() => crypto.randomUUID()),
imageId: z.uuid(), file: z.instanceof(File),
steps: z.array(z.string()).min(1, "Steps are required"), steps: z.array(StepsSchema).min(1, "Steps are required"),
order: z.number(), order: z.number(),
}); });
@ -27,9 +22,9 @@ export const GuideSchema = z.object({
createdAt: z.date(), createdAt: z.date(),
updatedAt: z.date(), updatedAt: z.date(),
deletedAt: z.date().optional(), deletedAt: z.date().optional(),
frames: z.array(FrameSchema), frames: z.array(FrameSchema).min(1, "Frames are required"),
}); });
export type Guide = z.infer<typeof GuideSchema>; export type Steps = z.infer<typeof StepsSchema>;
export type Image = z.infer<typeof ImageSchema>;
export type Frame = z.infer<typeof FrameSchema>; export type Frame = z.infer<typeof FrameSchema>;
export type Guide = z.infer<typeof GuideSchema>;