Files
radicle-explorer/httpd-client/lib/project/comment.ts
T
2023-05-12 14:30:27 +00:00

32 lines
860 B
TypeScript

import type { ZodSchema } from "zod";
import { array, number, record, strictObject, string } from "zod";
export type ThreadUpdateAction =
| { type: "comment"; body: string; replyTo?: string }
| { type: "edit"; id: string; body: string }
| { type: "redact"; id: string }
| {
type: "react";
to: string;
reaction: { emoji: string };
active: boolean;
};
export interface Comment {
id: string;
author: { id: string; alias?: string };
body: string;
reactions: Record<string, number>[];
timestamp: number;
replyTo: string | null;
}
export const commentSchema = strictObject({
id: string(),
author: strictObject({ id: string(), alias: string().optional() }),
body: string(),
reactions: array(record(string(), number())),
timestamp: number(),
replyTo: string().nullable(),
}) satisfies ZodSchema<Comment>;