export type TodoID = string; export interface Todo { id: TodoID; completed: boolean; title: string; } interface Error { error: string; errorDetails?: { message: string; path: Array; type: string; }[]; } interface Success { data: T; } export type Response = Error | Success; export interface ServerEvents { "todo:created": (todo: Todo) => void; "todo:updated": (todo: Todo) => void; "todo:deleted": (id: TodoID) => void; } export interface ClientEvents { "todo:list": (callback: (res: Response) => void) => void; "todo:create": ( payload: Omit, callback: (res: Response) => void ) => void; "todo:read": (id: TodoID, callback: (res: Response) => void) => void; "todo:update": ( payload: Todo, callback: (res?: Response) => void ) => void; "todo:delete": (id: TodoID, callback: (res?: Response) => void) => void; }