Skip to content

@venturekit-pro/chat API

FunctionDescription
createChatManager(store: ChatStore)Create a chat manager backed by a ChatStore

Chat manager methods:

MethodDescription
createRoom(options: CreateRoomOptions)Create a room (direct rooms require exactly 2 participants)
createDirectRoom(userA, userB)Create a 1-1 direct room
getRoom(roomId)Fetch a single room
listRooms(userId)List the rooms a user belongs to
addParticipant(roomId, userId, role?)Add a participant (not allowed on direct rooms)
removeParticipant(roomId, userId)Remove a participant (not allowed on direct rooms)
sendMessage(options: SendMessageOptions)Send a chat message (type defaults to 'text')
getMessages(roomId, { limit?, before? })Fetch paginated messages
editMessage(messageId, senderId, content)Edit a message (sender only)
deleteMessage(messageId, userId)Soft-delete a message (sender or room admin/owner)
markRead(roomId, userId, messageId)Mark messages read up to a message
getUnreadCounts(userId)Per-room unread counts
deleteRoom(roomId)Delete a room

Implement to plug in any backend (DynamoDB, Postgres, Redis, in-memory). Declares: createRoom, getRoom, updateRoom, deleteRoom, listRoomsForUser, sendMessage, getMessage, listMessages, updateMessage, deleteMessage, markRead, getUnreadCounts.

TypeDescription
RoomType'direct' | 'group' | 'channel'
ParticipantRole'owner' | 'admin' | 'member' | 'guest'
ChatMessageType'text' | 'image' | 'file' | 'system'
PresenceStatus'online' | 'away' | 'offline'
ChatRoom, Participant, ChatMessagePublic read shapes
TypingEvent, UserPresence, UnreadCountLive-state primitives
CreateRoomOptions, SendMessageOptionsManager input shapes