@withpotter/communication — module reference

HTTP routes this module mounts, plus its internal use-cases, entities, and repositories. The exhaustive request/response contract is the engine’s OpenAPI document at /docs; the layered structure below follows the package internal architecture.

HTTP routes

Communications /communications

MethodPathAuthDescription
GET/communications/logsYesList notification logs
GET/communications/messaging-creditsYesGet messaging credit balance and info
GET/communications/messaging-credits/monthly-usageYesGet messaging credit usage grouped by month
GET/communications/messaging-credits/transactionsYesGet messaging credit transaction history
GET/communications/messaging-credits/usageYesGet messaging usage statistics
GET/communications/preferences/:memberIdYesGet notification preferences for a member
GET/communications/statsYesGet notification statistics
GET/communications/templatesYesList all email templates
GET/communications/templates/:idYesGet an email template by ID
POST/communications/messaging-credits/initialize-purchaseYesInitialize a Paystack payment to purchase messaging credits
POST/communications/messaging-credits/purchaseYesManually add messaging credits (admin only)
POST/communications/sendYesSend an email using a template
POST/communications/send-bulkYesSend bulk email using a template
POST/communications/send-smsYesSend an SMS message
POST/communications/send-whatsappYesSend a WhatsApp message
POST/communications/templatesYesCreate an email template
POST/communications/test-emailYesSend a test email to verify email configuration
POST/communications/test-smsYesSend a test SMS to verify SMS configuration
POST/communications/test-whatsappYesSend a test WhatsApp to verify configuration
PUT/communications/preferences/:memberIdYesUpdate notification preferences for a member
PUT/communications/templates/:idYesUpdate an email template
DELETE/communications/templates/:idYesDelete an email template

ResendWebhookController /webhooks/resend

MethodPathAuthDescription
POST/webhooks/resendHandle webhook

Internals

Use-cases

Application operations. Each is a single-purpose class with one execute() method.

Use-caseSignature
CreateEmailTemplateUseCaseexecute(tenantId: string, dto: CreateEmailTemplateDto): Promise<EmailTemplateResponseDto>
DeleteEmailTemplateUseCaseexecute(tenantId: string, templateId: string): Promise<void>
GetEmailTemplateUseCaseexecute(tenantId: string, templateId: string): Promise<EmailTemplateResponseDto>
GetNotificationStatsUseCaseexecute(tenantId: string, startDate?: Date, endDate?: Date): Promise<NotificationStatsDto>
GetPreferencesUseCaseexecute(tenantId: string, memberId: string): Promise<PreferencesResponseDto>
ListEmailTemplatesUseCaseexecute(tenantId: string, type?: EmailTemplateType): Promise<EmailTemplateResponseDto[]>
ListNotificationLogsUseCaseexecute(tenantId: string, query: NotificationLogQueryDto): Promise<NotificationLogListResponseDto>
SendBulkEmailUseCaseexecute(tenantId: string, templateType: EmailTemplateType, templateId: string | undefined, recipients: BulkRecipient[], commonVariables?: Record<string, string>): Promise<BulkEmailSendResult>
SendEmailUseCaseexecute(tenantId: string, dto: SendEmailDto): Promise<EmailSendResult>
SendSmsUseCaseexecute(tenantId: string, dto: SendSmsDto): Promise<SmsSendResult>
SendTestEmailUseCaseexecute(tenantId: string, toEmail: string): Promise<{ success: boolean; message: string }>
UpdateEmailTemplateUseCaseexecute(tenantId: string, templateId: string, dto: UpdateEmailTemplateDto): Promise<EmailTemplateResponseDto>
UpdatePreferencesUseCaseexecute(tenantId: string, memberId: string, dto: UpdatePreferencesDto): Promise<PreferencesResponseDto>

Entities

Sequelize models owned by this module.

EmailTemplate — table email_templates

FieldType
idstring
tenantIdstring
typeEmailTemplateType
namestring
subjectstring
htmlContentstring
textContentstring
variablesRecord<string, string>
isActiveboolean
isDefaultboolean
createdAtDate
updatedAtDate
idstring
tenantIdstring
channelNotificationChannel
templateTypeEmailTemplateType
templateIdstring | null
memberIdstring | null
recipientEmailstring | null
recipientPhonestring | null
subjectstring
contentstring
metadataRecord<string, unknown>
statusNotificationStatus
errorMessagestring | null
externalIdstring | null
sentAtDate | null
deliveredAtDate | null
createdAtDate
updatedAtDate
idstring
tenantIdstring
memberIdstring
orderConfirmationboolean
orderShippedboolean
orderDeliveredboolean
newsletterboolean
promotionalboolean
reviewRequestboolean
abandonedCartboolean
emailEnabledboolean
smsEnabledboolean
pushEnabledboolean
createdAtDate
updatedAtDate
idstring
messageTypeMessageType
scopePricingScope
organizationIdstring | null
tenantIdstring | null
costPerUnitnumber
currencystring
effectiveFromDate | null
effectiveUntilDate | null
isActiveboolean
notesstring | null
createdAtDate
updatedAtDate

Repositories

Data-access classes wrapping the entities.

EmailTemplateRepository

create · findById · findByTenantAndType · findAllByTenant · findByType · update · delete · setDefault · updateStatus · findWithFilters · getStats · findByMember · deleteOldLogs · getOrCreate · shouldSendNotification · getPricing · findByScope · seedPlatformDefaults

Services

  • EmailCreditsScheduler
  • EmailCreditsService
  • EmailService
  • MessagingCreditsScheduler
  • MessagingCreditsService
  • NotificationDispatcher
  • ResendWebhookService
  • SmsService
  • TemplateService
  • UsageTrackingService
  • WhatsAppService

Providers

  • MetaWhatsAppProvider
  • PlatformEmailProvider
  • PlatformSmsProvider
  • PlatformWhatsAppProvider
  • ResendProvider
  • TermiiProvider
  • TermiiWhatsAppProvider
  • TwilioSmsProvider
  • TwilioWhatsAppProvider

Generated from the module’s source. Routes are relative to the engine root (default http://localhost:3001). For full request/response schemas use the live OpenAPI document.