import z from "zod"; // export const sendMessageSchema = z.object({ // roomId: z.string(), // message: z.string(), // }); // const messageSchema = z.object({ // id: z.string(), // message: z.string(), // roomId: z.string(), // sentAt: z.date(), // sender: z.object({ // name: z.string(), // }), // }); export const sendMessageSchema = z.object({ roomId: z.string(), content: z.string(), // changed from message }); export type PusherMessageData = { message: Message; }; const messageSchema = z.object({ message: z.object({ id: z.string(), content: z.string(), // changed from message roomId: z.string(), createdAt: z.date(), // changed from sentAt author: z.object({ // changed from sender id: z.string(), }), authorId: z.string().optional(), replies: z .array( z.object({ id: z.string(), content: z.string(), createdAt: z.date(), author: z.object({ id: z.string(), }), }) ) .optional(), replyToId: z.string().optional(), originalMessageId: z.string().optional(), originalMessage: z .object({ id: z.string(), content: z.string(), roomId: z.string(), createdAt: z.date(), authorId: z.string().optional(), replyTo: z.string().optional(), author: { id: z.string(), name: z.string(), email: z.string(), emailVerified: z.boolean().optional(), image: z.string(), }, }) .optional(), }), }); export type Message = z.TypeOf<typeof messageSchema>; export const messageSubSchema = z.object({ roomId: z.string(), });