Skip to content

@venturekit-pro/comms API

FunctionDescription
createEmailProvider(config)Create an email provider (SES or SMTP)
createPushProvider(config)Create a push notification provider (SNS)
createSmsProvider(config)Create an SMS provider (SNS)

ChannelProvider interface:

MethodDescription
send(options)Send a message via this channel
nameChannel name ('email', 'push', 'sms')
FunctionDescription
createCommsClient(config)Create a comms client with one or more providers

CommsClient interface:

MethodDescription
send(request)Send a single message across one or more channels
broadcast(request)Send to many recipients with channel fallback
FunctionDescription
renderString(template, vars)Render a single template string
renderTemplate(template, vars)Render a MessageTemplate (subject + body)
extractVariables(template)Extract {{variable}} placeholders from a template
createTemplateRegistry()Create an in-memory template store
FunctionDescription
isChannelAllowed(userId, channel, store)Check whether a channel is allowed for a user
isQuietHours(prefs, now?)Check whether the user is in quiet hours
getEffectiveChannels(requested, prefs)Filter channels through user preferences
createMemoryPreferenceStore()Create an in-memory PreferenceStore
FunctionDescription
createChatManager(store)Create a chat manager backed by a ChatStore

ChatManager interface:

MethodDescription
createDirectRoom(userA, userB)Create a 1-1 direct room
createGroupRoom(options)Create a group room
sendMessage(options)Send a chat message
getMessages(roomId, options?)Fetch messages for a room

Comms-related types are exported from ./types/index.js and the messaging/chat modules. Common shapes include Channel, DeliveryStatus, MessagePriority, Message, Attachment, Recipient, DeliveryReceipt, SendRequest, BroadcastRequest, SendResult, BroadcastResult, MessageTemplate, RenderedTemplate, NotificationPreference, PreferenceStore, ChatRoom, Participant, ChatMessage, TypingEvent, PresenceStatus, UserPresence, UnreadCount, ChatStore.

ConstantDescription
DEFAULT_PREFERENCESDefault per-user notification preferences