@venturekit-pro/chat
@venturekit-pro/chat provides chat primitives — 1-1, group, and channel rooms with participant roles, message history, edit/soft-delete, read receipts, typing indicators, and presence. Storage is pluggable via the ChatStore interface, and there is no baked-in transport — pair it with WebSockets, SSE, or any pub/sub you already run.
Installation
Section titled “Installation”npm install @venturekit-pro/chat@devWhat It Provides
Section titled “What It Provides”Chat Manager
Section titled “Chat Manager”import { createChatManager, type ChatStore } from '@venturekit-pro/chat';
const store: ChatStore = /* your storage adapter */;const chat = createChatManager(store);
// Direct (1-1) roomconst room = await chat.createDirectRoom('user-1', 'user-2');
// Send + readawait chat.sendMessage({ roomId: room.id, senderId: 'user-1', content: 'Hello!' });const messages = await chat.getMessages(room.id, { limit: 50 });await chat.markRead(room.id, 'user-2', messages[0].id);Group & Channel Rooms
Section titled “Group & Channel Rooms”const group = await chat.createRoom({ type: 'group', // 'direct' | 'group' | 'channel' name: 'Project Alpha', participants: [ { userId: 'user-1', role: 'owner' }, // 'owner' | 'admin' | 'member' | 'guest' { userId: 'user-2', role: 'member' }, ],});
await chat.addParticipant(group.id, 'user-3', 'member');await chat.removeParticipant(group.id, 'user-2');Manager Methods
Section titled “Manager Methods”| Method | Description |
|---|---|
createRoom(options) | Create a room (direct rooms require exactly 2 participants) |
createDirectRoom(userA, userB) | Shortcut for a 1-1 room |
getRoom(roomId) / listRooms(userId) | Read rooms |
addParticipant(roomId, userId, role?) / removeParticipant(roomId, userId) | Manage membership (not allowed on direct rooms) |
sendMessage(options) | Send a message (type defaults to 'text') |
getMessages(roomId, { limit?, before? }) | Paginated message history |
editMessage(messageId, senderId, content) | Edit (sender only) |
deleteMessage(messageId, userId) | Soft-delete (sender or room admin/owner) |
markRead(roomId, userId, messageId) | Mark read up to a message |
getUnreadCounts(userId) | Per-room unread counts |
deleteRoom(roomId) | Delete a room |
Storage (ChatStore)
Section titled “Storage (ChatStore)”The package is transport- and storage-agnostic. Implement the ChatStore interface (12 methods covering rooms, messages, and read receipts) against DynamoDB, Postgres, Redis, or an in-memory adapter for tests.
import type { ChatStore } from '@venturekit-pro/chat';RoomType, ParticipantRole, ChatMessageType, ChatRoom, Participant, ChatMessage, TypingEvent, PresenceStatus, UserPresence, UnreadCount, ChatStore, CreateRoomOptions, SendMessageOptions.
Dependencies
Section titled “Dependencies”@venturekit/core— required
Related
Section titled “Related”- WebSockets — a real-time transport to pair with chat
@venturekit/notify— transactional email/WhatsApp/SMS/push (the other half of the oldcommspackage)- API Reference — full type documentation