Files
chad/server/plugins/schemas/chat.ts
2026-05-22 05:08:02 +06:00

27 lines
878 B
TypeScript

import { Type } from 'typebox'
import { AttachmentSchema } from './attachment.ts'
export const ReplySchema = Type.Object({
messageId: Type.String({ format: 'uuid' }),
senderUsername: Type.String(),
text: Type.String(),
}, { $id: 'Reply' })
export const ChatMessageSchema = Type.Object({
id: Type.String({ format: 'uuid' }),
senderUsername: Type.String(),
text: Type.String({ minLength: 1 }),
createdAt: Type.String({ format: 'date-time' }),
updatedAt: Type.String({ format: 'date-time' }),
attachments: Type.Array(AttachmentSchema),
}, { $id: 'ChatMessage' })
export const NewChatMessagePayloadSchema = Type.Object({
text: Type.String({ minLength: 1 }),
attachments: Type.Optional(Type.Array(Type.String({ format: 'uuid' }))),
// replyTo: Type.Object({
// messageId: Type.String({ format: 'uuid' }),
// }),
}, { $id: 'NewChatMessagePayload' })