add board/settings type definitions and Zod validation schemas
This commit is contained in:
61
src/lib/schemas.ts
Normal file
61
src/lib/schemas.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const checklistItemSchema = z.object({
|
||||
id: z.string(),
|
||||
text: z.string(),
|
||||
checked: z.boolean(),
|
||||
});
|
||||
|
||||
export const attachmentSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
path: z.string(),
|
||||
mode: z.enum(["link", "copy"]).default("link"),
|
||||
});
|
||||
|
||||
export const labelSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
color: z.string(),
|
||||
});
|
||||
|
||||
export const cardSchema = z.object({
|
||||
id: z.string(),
|
||||
title: z.string(),
|
||||
description: z.string().default(""),
|
||||
labels: z.array(z.string()).default([]),
|
||||
checklist: z.array(checklistItemSchema).default([]),
|
||||
dueDate: z.string().nullable().default(null),
|
||||
attachments: z.array(attachmentSchema).default([]),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
});
|
||||
|
||||
export const columnSchema = z.object({
|
||||
id: z.string(),
|
||||
title: z.string(),
|
||||
cardIds: z.array(z.string()).default([]),
|
||||
width: z.enum(["narrow", "standard", "wide"]).default("standard"),
|
||||
});
|
||||
|
||||
export const boardSettingsSchema = z.object({
|
||||
attachmentMode: z.enum(["link", "copy"]).default("link"),
|
||||
});
|
||||
|
||||
export const boardSchema = z.object({
|
||||
id: z.string(),
|
||||
title: z.string(),
|
||||
color: z.string().default("#6366f1"),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
columns: z.array(columnSchema).default([]),
|
||||
cards: z.record(z.string(), cardSchema).default({}),
|
||||
labels: z.array(labelSchema).default([]),
|
||||
settings: boardSettingsSchema.default({ attachmentMode: "link" }),
|
||||
});
|
||||
|
||||
export const appSettingsSchema = z.object({
|
||||
theme: z.enum(["light", "dark", "system"]).default("system"),
|
||||
dataDirectory: z.string().nullable().default(null),
|
||||
recentBoardIds: z.array(z.string()).default([]),
|
||||
});
|
||||
Reference in New Issue
Block a user