From 37612f588a0c9d6cd5f6217c683293be2b96791e Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Thu, 15 Jan 2026 19:44:28 +0200 Subject: [PATCH] feat(web): add chat comments types --- .../contracts/types/chat-comments.types.ts | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 surfsense_web/contracts/types/chat-comments.types.ts diff --git a/surfsense_web/contracts/types/chat-comments.types.ts b/surfsense_web/contracts/types/chat-comments.types.ts new file mode 100644 index 000000000..2e10cdc9d --- /dev/null +++ b/surfsense_web/contracts/types/chat-comments.types.ts @@ -0,0 +1,167 @@ +import { z } from "zod"; + +export const author = z.object({ + id: z.string().uuid(), + display_name: z.string().nullable(), + avatar_url: z.string().nullable(), + email: z.string(), +}); + +export const commentReply = z.object({ + id: z.number(), + content: z.string(), + content_rendered: z.string(), + author: author.nullable(), + created_at: z.string(), + updated_at: z.string(), + is_edited: z.boolean(), + can_edit: z.boolean(), + can_delete: z.boolean(), +}); + +export const comment = z.object({ + id: z.number(), + message_id: z.number(), + content: z.string(), + content_rendered: z.string(), + author: author.nullable(), + created_at: z.string(), + updated_at: z.string(), + is_edited: z.boolean(), + can_edit: z.boolean(), + can_delete: z.boolean(), + reply_count: z.number(), + replies: z.array(commentReply), +}); + +export const mentionContext = z.object({ + thread_id: z.number(), + thread_title: z.string(), + message_id: z.number(), + search_space_id: z.number(), + search_space_name: z.string(), +}); + +export const mentionComment = z.object({ + id: z.number(), + content_preview: z.string(), + author: author.nullable(), + created_at: z.string(), +}); + +export const mention = z.object({ + id: z.number(), + read: z.boolean(), + created_at: z.string(), + comment: mentionComment, + context: mentionContext, +}); + +/** + * Get comments for a message + */ +export const getCommentsRequest = z.object({ + message_id: z.number(), +}); + +export const getCommentsResponse = z.object({ + comments: z.array(comment), + total_count: z.number(), +}); + +/** + * Create comment + */ +export const createCommentRequest = z.object({ + message_id: z.number(), + content: z.string().min(1).max(5000), +}); + +export const createCommentResponse = comment; + +/** + * Create reply + */ +export const createReplyRequest = z.object({ + comment_id: z.number(), + content: z.string().min(1).max(5000), +}); + +export const createReplyResponse = commentReply; + +/** + * Update comment + */ +export const updateCommentRequest = z.object({ + comment_id: z.number(), + content: z.string().min(1).max(5000), +}); + +export const updateCommentResponse = commentReply; + +/** + * Delete comment + */ +export const deleteCommentRequest = z.object({ + comment_id: z.number(), +}); + +export const deleteCommentResponse = z.object({ + message: z.string(), + comment_id: z.number(), +}); + +/** + * Get mentions + */ +export const getMentionsRequest = z.object({ + search_space_id: z.number().optional(), + unread_only: z.boolean().optional(), +}); + +export const getMentionsResponse = z.object({ + mentions: z.array(mention), + unread_count: z.number(), +}); + +/** + * Mark mention as read + */ +export const markMentionReadRequest = z.object({ + mention_id: z.number(), +}); + +export const markMentionReadResponse = z.object({ + mention_id: z.number(), + read: z.boolean(), +}); + +/** + * Mark all mentions as read + */ +export const markAllMentionsReadResponse = z.object({ + message: z.string(), + count: z.number(), +}); + +export type Author = z.infer; +export type CommentReply = z.infer; +export type Comment = z.infer; +export type MentionContext = z.infer; +export type MentionComment = z.infer; +export type Mention = z.infer; +export type GetCommentsRequest = z.infer; +export type GetCommentsResponse = z.infer; +export type CreateCommentRequest = z.infer; +export type CreateCommentResponse = z.infer; +export type CreateReplyRequest = z.infer; +export type CreateReplyResponse = z.infer; +export type UpdateCommentRequest = z.infer; +export type UpdateCommentResponse = z.infer; +export type DeleteCommentRequest = z.infer; +export type DeleteCommentResponse = z.infer; +export type GetMentionsRequest = z.infer; +export type GetMentionsResponse = z.infer; +export type MarkMentionReadRequest = z.infer; +export type MarkMentionReadResponse = z.infer; +export type MarkAllMentionsReadResponse = z.infer;