feat: 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([]),
|
||||
});
|
||||
64
src/types/board.ts
Normal file
64
src/types/board.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
export interface Board {
|
||||
id: string;
|
||||
title: string;
|
||||
color: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
columns: Column[];
|
||||
cards: Record<string, Card>;
|
||||
labels: Label[];
|
||||
settings: BoardSettings;
|
||||
}
|
||||
|
||||
export interface Column {
|
||||
id: string;
|
||||
title: string;
|
||||
cardIds: string[];
|
||||
width: ColumnWidth;
|
||||
}
|
||||
|
||||
export type ColumnWidth = "narrow" | "standard" | "wide";
|
||||
|
||||
export interface Card {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
labels: string[];
|
||||
checklist: ChecklistItem[];
|
||||
dueDate: string | null;
|
||||
attachments: Attachment[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface Label {
|
||||
id: string;
|
||||
name: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
export interface ChecklistItem {
|
||||
id: string;
|
||||
text: string;
|
||||
checked: boolean;
|
||||
}
|
||||
|
||||
export interface Attachment {
|
||||
id: string;
|
||||
name: string;
|
||||
path: string;
|
||||
mode: "link" | "copy";
|
||||
}
|
||||
|
||||
export interface BoardSettings {
|
||||
attachmentMode: "link" | "copy";
|
||||
}
|
||||
|
||||
export interface BoardMeta {
|
||||
id: string;
|
||||
title: string;
|
||||
color: string;
|
||||
cardCount: number;
|
||||
columnCount: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
5
src/types/settings.ts
Normal file
5
src/types/settings.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface AppSettings {
|
||||
theme: "light" | "dark" | "system";
|
||||
dataDirectory: string | null;
|
||||
recentBoardIds: string[];
|
||||
}
|
||||
Reference in New Issue
Block a user