Files
family_wishlist/packages/shared/src/folder.schema.ts
T

34 lines
1.0 KiB
TypeScript

import { z } from 'zod';
import type { Wish } from './wish.schema.js';
export const createFolderSchema = z.object({
name: z.string().trim().min(1).max(80),
description: z.string().trim().max(500).optional(),
emoji: z
.string()
.trim()
.max(32)
.regex(/^(?:(?:\p{Extended_Pictographic}|\p{Regional_Indicator})[\p{Extended_Pictographic}\p{Regional_Indicator}\p{Emoji_Modifier}\uFE0F\u200D]*|[#*0-9]\uFE0F?\u20E3)$/u)
.optional(),
});
export const updateFolderSchema = createFolderSchema.pick({ name: true, description: true }).partial().strict();
export type UpdateFolderInput = z.infer<typeof updateFolderSchema>;
export type CreateFolderInput = z.infer<typeof createFolderSchema>;
export interface WishFolder {
id: string;
name: string;
description: string | null;
emoji: string | null;
imageUrl: string | null;
}
export interface WishDashboard {
authors: { id: string; displayName: string; avatarUrl: string | null }[];
folders: WishFolder[];
wishes: (Wish & { userId: string; isNewForOwner: boolean })[];
}