mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-30 16:50:47 +08:00
32 lines
860 B
TypeScript
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>;
|