@burdenoff/be-sdk 2026.511.2 → 2026.512.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EventQueueFactory-YGCOETTR.js +8 -0
- package/dist/{EventQueueFactory-6NMSGECR.js.map → EventQueueFactory-YGCOETTR.js.map} +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +2 -2
- package/dist/{chunk-2SD5L2F2.js → chunk-342WTZ4B.js} +3 -3
- package/dist/{chunk-2SD5L2F2.js.map → chunk-342WTZ4B.js.map} +1 -1
- package/dist/{chunk-JG2FTZPI.js → chunk-5CAA3JST.js} +3 -3
- package/dist/{chunk-JG2FTZPI.js.map → chunk-5CAA3JST.js.map} +1 -1
- package/dist/{chunk-J26YGR2U.js → chunk-ER77ZA7C.js} +3 -3
- package/dist/{chunk-J26YGR2U.js.map → chunk-ER77ZA7C.js.map} +1 -1
- package/dist/{chunk-XC2YD6CF.js → chunk-I43B35CP.js} +3 -3
- package/dist/{chunk-XC2YD6CF.js.map → chunk-I43B35CP.js.map} +1 -1
- package/dist/{chunk-MNCGUYLJ.js → chunk-KFPP47FP.js} +6 -3
- package/dist/chunk-KFPP47FP.js.map +1 -0
- package/dist/{chunk-M5IMU3US.js → chunk-QTSPQQWA.js} +5 -5
- package/dist/{chunk-M5IMU3US.js.map → chunk-QTSPQQWA.js.map} +1 -1
- package/dist/{chunk-SAG6ZYWQ.js → chunk-RTQIRGVB.js} +2 -2
- package/dist/{chunk-SAG6ZYWQ.js.map → chunk-RTQIRGVB.js.map} +1 -1
- package/dist/{chunk-ELLX3K54.js → chunk-RUGNI7CR.js} +3 -3
- package/dist/{chunk-ELLX3K54.js.map → chunk-RUGNI7CR.js.map} +1 -1
- package/dist/{chunk-F5XEAGHQ.js → chunk-THTLTTA6.js} +4 -4
- package/dist/{chunk-F5XEAGHQ.js.map → chunk-THTLTTA6.js.map} +1 -1
- package/dist/{chunk-YN6NTFJK.js → chunk-VGMFFO6N.js} +5 -5
- package/dist/{chunk-YN6NTFJK.js.map → chunk-VGMFFO6N.js.map} +1 -1
- package/dist/{chunk-L7ZMN2FJ.js → chunk-VOFKF27Q.js} +2 -2
- package/dist/chunk-VOFKF27Q.js.map +1 -0
- package/dist/{chunk-OVSYMNCI.js → chunk-VX35BOJP.js} +35 -12
- package/dist/chunk-VX35BOJP.js.map +1 -0
- package/dist/{chunk-SAK2JCA7.js → chunk-WBWM7UY7.js} +3 -3
- package/dist/{chunk-SAK2JCA7.js.map → chunk-WBWM7UY7.js.map} +1 -1
- package/dist/{chunk-3O2RQOPV.js → chunk-YOLJ6ONY.js} +12 -4
- package/dist/chunk-YOLJ6ONY.js.map +1 -0
- package/dist/{chunk-AI7L22ZJ.js → chunk-ZTSNNKI3.js} +11 -5
- package/dist/chunk-ZTSNNKI3.js.map +1 -0
- package/dist/config-7U7J3QXQ.js +4 -0
- package/dist/{config-UKE2E3BW.js.map → config-7U7J3QXQ.js.map} +1 -1
- package/dist/database/index.js +2 -2
- package/dist/event-queue/index.d.ts +3 -3
- package/dist/event-queue/index.js +5 -5
- package/dist/graph/index.d.ts +3 -3
- package/dist/graph/index.js +7 -7
- package/dist/graphql/index.d.ts +1 -1
- package/dist/graphql/index.js +2 -2
- package/dist/{graphql-BAVrUgBF.d.ts → graphql-0_hoaeUf.d.ts} +1 -1
- package/dist/{index-Cq_xNjcv.d.ts → index-BF2uh_h9.d.ts} +4 -2
- package/dist/{index-CHbVw5M7.d.ts → index-CSPbpywb.d.ts} +2 -0
- package/dist/{index-KVWGHMbS.d.ts → index-DJq060D-.d.ts} +3 -3
- package/dist/{index-CrQgidpx.d.ts → index-DYEts1R8.d.ts} +1 -1
- package/dist/{index-BS2idbnr.d.ts → index-DZO2nvC9.d.ts} +2 -2
- package/dist/{index-B18rrFru.d.ts → index-HkD7NBED.d.ts} +2 -0
- package/dist/{index-DoK0bjhH.d.ts → index-TKcu5LDR.d.ts} +1 -1
- package/dist/{index-DOcBnmMe.d.ts → index-XY9x2I6b.d.ts} +2 -0
- package/dist/{index-CyVEg86m.d.ts → index-zzKCairW.d.ts} +2 -2
- package/dist/index.d.ts +15 -15
- package/dist/index.js +24 -22
- package/dist/index.js.map +1 -1
- package/dist/init/index.d.ts +1 -1
- package/dist/init/index.js +4 -4
- package/dist/instrumentation/index.d.ts +3 -3
- package/dist/logger/index.d.ts +2 -2
- package/dist/notifications/index.d.ts +3 -3
- package/dist/notifications/index.js +2 -2
- package/dist/prisma/index.js +5 -5
- package/dist/rbac/index.d.ts +2 -2
- package/dist/rbac/index.js +2 -2
- package/dist/telemetry/index.d.ts +4 -4
- package/dist/tracker/index.d.ts +4 -4
- package/dist/tracker/index.js +4 -4
- package/package.json +1 -1
- package/dist/EventQueueFactory-6NMSGECR.js +0 -8
- package/dist/chunk-3O2RQOPV.js.map +0 -1
- package/dist/chunk-AI7L22ZJ.js.map +0 -1
- package/dist/chunk-L7ZMN2FJ.js.map +0 -1
- package/dist/chunk-MNCGUYLJ.js.map +0 -1
- package/dist/chunk-OVSYMNCI.js.map +0 -1
- package/dist/config-UKE2E3BW.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/notifications/tenant-notifications.ts","../src/notifications/index.ts"],"names":["NotificationChannel","NotificationPriority","NotificationType","TenantNotificationsModule","client","context","send","input","validateSendInput","logger","info","channel","type","priority","mutation","variables","recipient","subject","body","htmlBody","data","metadata","scheduledFor","toISOString","expiresAt","trackOpens","trackClicks","response","tenantQuery","notificationId","sendNotification","sendWithTemplate","templateSlug","trim","length","ValidationError","Object","keys","email","userId","channelId","platform","timezone","triggerNotificationWithTemplate","id","status","sendBatch","notifications","count","batchSize","map","n","delayBetweenBatches","batchId","sendBatchNotifications","queued","totalQueued","failed","totalFailed","getNotification","query","notification","getNotifications","filter","startDate","endDate","undefined","limit","offset","getTemplate","slug","locale","notificationTemplate","getTemplates","notificationTemplates","getStats","notificationStats","markAsRead","notificationIds","markAllAsRead","deleteNotifications","deleteAllReadNotifications","phoneNumber","pushToken","NotificationsModule","options","title","message","userIds","userCount","redirectUrl","appName","sms","result","successCount","createNotification","failureCount","errors","sendToUser","debug","search","markMultipleAsRead","markNotificationsAsRead","markAllMyNotificationsAsRead","deleteNotification","deleteMultiple","getUnreadCount","unreadCount","sendChannelNotification","recipients","includeInApp","recipientCount","inAppUserCount","results","Promise","allSettled","forEach","index","value","push","triggerNotification","reason","Error","error","sendTemplateNotification"],"mappings":";;;;;AAAA,IAAA,4BAAA,GAAA;;;;;;;AAcO,IAAKA,mBAAAA,6BAAAA,oBAAAA,EAAAA;;;;;;;;;;;AAAAA,EAAAA,OAAAA,oBAAAA;;AAaL,IAAKC,oBAAAA,6BAAAA,qBAAAA,EAAAA;;;;;AAAAA,EAAAA,OAAAA,qBAAAA;;AAOL,IAAKC,gBAAAA,6BAAAA,iBAAAA,EAAAA;;;;;AAAAA,EAAAA,OAAAA,iBAAAA;;AAsIL,IAAMC,4BAAN,MAAMA;EAxKb;;;;;AAyKE,EAAA,WAAA,CACUC,QACAC,OAAAA,EACR;SAFQD,MAAAA,GAAAA,MAAAA;SACAC,OAAAA,GAAAA,OAAAA;AACP,EAAA;;;;AAKH,EAAA,MAAaC,KAAKC,KAAAA,EAA+C;AAE/D,IAAA,IAAA,CAAKC,kBAAkBD,KAAAA,CAAAA;AAEvBE,IAAAA,MAAAA,CAAOC,KAAK,4CAAA,EAA8C;AACxDC,MAAAA,OAAAA,EAASJ,KAAAA,CAAMI,OAAAA;AACfC,MAAAA,IAAAA,EAAML,MAAMK,IAAAA,IAAI,eAAA;AAChBC,MAAAA,QAAAA,EAAUN,MAAMM,QAAAA,IAAQ;KAC1B,CAAA;AAEA,IAAA,MAAMC,QAAAA,GAAW;;;;;AAMjB,IAAA,MAAMC,SAAAA,GAAY;MAChBR,KAAAA,EAAO;AACLS,QAAAA,SAAAA,EAAWT,KAAAA,CAAMS,SAAAA;AACjBL,QAAAA,OAAAA,EAASJ,KAAAA,CAA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AACxDmB,QAAAA,cAAAA,EAAgBF,SAASgB,+BAAAA,CAAgCC,EAAAA;AACzDC,QAAAA,MAAAA,EAAQlB,SAASgB,+BAAAA,CAAgCE;OACnD,CAAA;AAEA,MAAA,OAAOgD,MAAAA;AACT,IAAA,CAAA,CAAA,OAAS8B,KAAAA,EAAO;AACdlH,MAAAA,MAAAA,CAAOkH,MAAM,sDAAA,EAAwD;AAAEA,QAAAA;OAAM,CAAA;AAE7E,MAAA,OAAO;QACL7B,YAAAA,EAAc,CAAA;QACdE,YAAAA,EAAc,CAAA;QACdC,MAAAA,EAAQ;UAAC0B,KAAAA,YAAiBD,KAAAA,GAAQC,MAAMpC,OAAAA,GAAU;;AAClDT,QAAAA,eAAAA,EAAiB;AACnB,OAAA;AACF,IAAA;AACF,EAAA;AACF","file":"chunk-XC2YD6CF.js","sourcesContent":["/**\n * Tenant-Backend Notifications Module\n * Comprehensive notification system supporting 10+ channels via tenant-backend\n */\n\nimport type { BurdenoffGraphQLClient } from '../client/graphql.js';\nimport type { SDKContext } from '../types/index.js';\nimport { ValidationError } from '../types/index.js';\nimport { logger } from '../logger/index.js';\n\n// ========================================\n// Enums\n// ========================================\n\nexport enum NotificationChannel {\n EMAIL = 'EMAIL',\n SMS = 'SMS',\n PUSH = 'PUSH',\n IN_APP = 'IN_APP',\n WEBHOOK = 'WEBHOOK',\n WHATSAPP = 'WHATSAPP',\n TEAMS = 'TEAMS',\n SLACK = 'SLACK',\n TELEGRAM = 'TELEGRAM',\n DISCORD = 'DISCORD',\n}\n\nexport enum NotificationPriority {\n LOW = 'LOW',\n MEDIUM = 'MEDIUM',\n HIGH = 'HIGH',\n URGENT = 'URGENT',\n}\n\nexport enum NotificationType {\n TRANSACTIONAL = 'TRANSACTIONAL',\n MARKETING = 'MARKETING',\n SYSTEM = 'SYSTEM',\n ALERT = 'ALERT',\n}\n\n// ========================================\n// Types & Interfaces\n// ========================================\n\nexport interface RecipientInput {\n userId?: string;\n email?: string;\n phoneNumber?: string;\n pushToken?: string;\n whatsappNumber?: string;\n teamsUserId?: string;\n slackUserId?: string;\n webhookUrl?: string;\n name?: string;\n locale?: string;\n timezone?: string;\n}\n\nexport interface SendNotificationInput {\n recipient: RecipientInput;\n channel: NotificationChannel;\n type?: NotificationType;\n priority?: NotificationPriority;\n subject?: string;\n body: string;\n htmlBody?: string;\n data?: Record<string, unknown>;\n metadata?: Record<string, unknown>;\n scheduledFor?: Date;\n expiresAt?: Date;\n trackOpens?: boolean;\n trackClicks?: boolean;\n}\n\nexport interface SendWithTemplateInput {\n templateSlug: string;\n variables: Record<string, unknown>;\n recipient: RecipientInput;\n priority?: NotificationPriority;\n scheduledFor?: Date;\n expiresAt?: Date;\n trackOpens?: boolean;\n trackClicks?: boolean;\n /** Specific channel instance ID from channel service (takes precedence) */\n channelId?: string;\n /** Platform type for auto-failover (EMAIL, SMS, etc.) - used if channelId not provided */\n platform?: NotificationChannel;\n /** Timezone for scheduling */\n timezone?: string;\n}\n\nexport interface BatchNotificationInput {\n notifications: SendNotificationInput[];\n batchSize?: number;\n delayBetweenBatches?: number;\n priority?: NotificationPriority;\n}\n\nexport interface Notification {\n id: string;\n userId: string;\n channel: NotificationChannel;\n type: NotificationType;\n priority: NotificationPriority;\n status: string;\n deliveryStatus?: string;\n title: string;\n message: string;\n htmlMessage?: string;\n subject?: string;\n recipientEmail?: string;\n recipientPhone?: string;\n trackOpens: boolean;\n trackClicks: boolean;\n openedAt?: string;\n clickedAt?: string;\n sentAt?: string;\n deliveredAt?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface NotificationTemplate {\n id: string;\n name: string;\n slug: string;\n description?: string;\n channel: NotificationChannel;\n type: NotificationType;\n locale: string;\n subject?: string;\n bodyTemplate: string;\n htmlTemplate?: string;\n variables: Array<{\n name: string;\n type: string;\n required: boolean;\n defaultValue?: unknown;\n description?: string;\n example?: unknown;\n }>;\n enabled: boolean;\n version: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface NotificationStats {\n total: number;\n pending: number;\n queued: number;\n processing: number;\n sent: number;\n delivered: number;\n failed: number;\n byChannel: Record<string, number>;\n byType: Record<string, number>;\n}\n\n// ========================================\n// Tenant Notifications Module\n// ========================================\n\n/**\n * Tenant-Backend Notifications Module\n * Provides access to the centralized notification system\n */\nexport class TenantNotificationsModule {\n constructor(\n private client: BurdenoffGraphQLClient,\n private context: SDKContext\n ) {}\n\n /**\n * Send a single notification\n */\n public async send(input: SendNotificationInput): Promise<string> {\n // Validate inputs\n this.validateSendInput(input);\n\n logger.info('[TenantNotifications] Sending notification', {\n channel: input.channel,\n type: input.type || NotificationType.TRANSACTIONAL,\n priority: input.priority || NotificationPriority.MEDIUM,\n });\n\n const mutation = `\n mutation SendNotification($input: SendNotificationInput!) {\n sendNotification(input: $input)\n }\n `;\n\n const variables = {\n input: {\n recipient: input.recipient,\n channel: input.channel,\n type: input.type || NotificationType.TRANSACTIONAL,\n priority: input.priority || NotificationPriority.MEDIUM,\n subject: input.subject,\n body: input.body,\n htmlBody: input.htmlBody,\n data: input.data,\n metadata: input.metadata,\n scheduledFor: input.scheduledFor?.toISOString(),\n expiresAt: input.expiresAt?.toISOString(),\n trackOpens: input.trackOpens,\n trackClicks: input.trackClicks,\n },\n };\n\n const response = await this.client.tenantQuery<{\n sendNotification: string;\n }>(mutation, variables, this.context);\n\n logger.info('[TenantNotifications] Notification sent', {\n notificationId: response.sendNotification,\n });\n\n return response.sendNotification;\n }\n\n /**\n * Send notification using a template\n */\n public async sendWithTemplate(input: SendWithTemplateInput): Promise<string> {\n // Validate inputs\n if (!input.templateSlug || input.templateSlug.trim().length === 0) {\n throw new ValidationError('Template slug is required');\n }\n\n if (!input.variables || Object.keys(input.variables).length === 0) {\n throw new ValidationError('Template variables are required');\n }\n\n if (!input.recipient || (!input.recipient.email && !input.recipient.userId)) {\n throw new ValidationError('Recipient email or userId is required');\n }\n\n logger.info('[TenantNotifications] Sending notification with template', {\n templateSlug: input.templateSlug,\n priority: input.priority || NotificationPriority.MEDIUM,\n });\n\n const mutation = `\n mutation TriggerNotificationWithTemplate($input: TriggerNotificationWithTemplateInput!) {\n triggerNotificationWithTemplate(input: $input) {\n id\n status\n deliveryStatus\n }\n }\n `;\n\n const variables = {\n input: {\n templateSlug: input.templateSlug,\n variables: input.variables,\n recipient: input.recipient,\n priority: input.priority || NotificationPriority.MEDIUM,\n scheduledFor: input.scheduledFor?.toISOString(),\n expiresAt: input.expiresAt?.toISOString(),\n trackOpens: input.trackOpens,\n trackClicks: input.trackClicks,\n // Platform is required for notification delivery routing\n // If channelId is specified, it takes precedence; otherwise platform determines delivery\n channelId: input.channelId,\n platform: input.platform || NotificationChannel.EMAIL,\n timezone: input.timezone,\n },\n };\n\n const response = await this.client.tenantQuery<{\n triggerNotificationWithTemplate: { id: string; status: string; deliveryStatus?: string };\n }>(mutation, variables, this.context);\n\n logger.info('[TenantNotifications] Notification sent with template', {\n notificationId: response.triggerNotificationWithTemplate.id,\n status: response.triggerNotificationWithTemplate.status,\n });\n\n return response.triggerNotificationWithTemplate.id;\n }\n\n /**\n * Send batch notifications\n */\n public async sendBatch(input: BatchNotificationInput): Promise<{\n totalRequested: number;\n totalQueued: number;\n totalFailed: number;\n batchId: string;\n }> {\n if (!input.notifications || input.notifications.length === 0) {\n throw new ValidationError('At least one notification is required');\n }\n\n logger.info('[TenantNotifications] Sending batch notifications', {\n count: input.notifications.length,\n batchSize: input.batchSize,\n });\n\n const mutation = `\n mutation SendBatchNotifications($input: BatchNotificationInput!) {\n sendBatchNotifications(input: $input) {\n totalRequested\n totalQueued\n totalFailed\n batchId\n }\n }\n `;\n\n const variables = {\n input: {\n notifications: input.notifications.map((n) => ({\n recipient: n.recipient,\n channel: n.channel,\n type: n.type || NotificationType.TRANSACTIONAL,\n priority: n.priority || NotificationPriority.MEDIUM,\n subject: n.subject,\n body: n.body,\n htmlBody: n.htmlBody,\n data: n.data,\n metadata: n.metadata,\n scheduledFor: n.scheduledFor?.toISOString(),\n expiresAt: n.expiresAt?.toISOString(),\n trackOpens: n.trackOpens,\n trackClicks: n.trackClicks,\n })),\n batchSize: input.batchSize,\n delayBetweenBatches: input.delayBetweenBatches,\n priority: input.priority,\n },\n };\n\n const response = await this.client.tenantQuery<{\n sendBatchNotifications: {\n totalRequested: number;\n totalQueued: number;\n totalFailed: number;\n batchId: string;\n };\n }>(mutation, variables, this.context);\n\n logger.info('[TenantNotifications] Batch notifications sent', {\n batchId: response.sendBatchNotifications.batchId,\n queued: response.sendBatchNotifications.totalQueued,\n failed: response.sendBatchNotifications.totalFailed,\n });\n\n return response.sendBatchNotifications;\n }\n\n /**\n * Get a notification by ID\n */\n public async getNotification(id: string): Promise<Notification | null> {\n const query = `\n query GetNotification($id: ID!) {\n notification(id: $id) {\n id\n userId\n channel\n type\n priority\n status\n deliveryStatus\n title\n message\n htmlMessage\n subject\n recipientEmail\n recipientPhone\n trackOpens\n trackClicks\n openedAt\n clickedAt\n sentAt\n deliveredAt\n createdAt\n updatedAt\n }\n }\n `;\n\n const response = await this.client.tenantQuery<{\n notification: Notification | null;\n }>(query, { id }, this.context);\n\n return response.notification;\n }\n\n /**\n * Get notifications with filters\n */\n public async getNotifications(filter?: {\n userId?: string;\n channel?: NotificationChannel;\n type?: NotificationType;\n status?: string;\n priority?: NotificationPriority;\n startDate?: Date;\n endDate?: Date;\n limit?: number;\n offset?: number;\n }): Promise<Notification[]> {\n const query = `\n query GetNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {\n notifications(filter: $filter, limit: $limit, offset: $offset) {\n id\n userId\n channel\n type\n priority\n status\n deliveryStatus\n title\n message\n subject\n recipientEmail\n trackOpens\n trackClicks\n openedAt\n clickedAt\n sentAt\n deliveredAt\n createdAt\n updatedAt\n }\n }\n `;\n\n const variables = {\n filter: filter\n ? {\n userId: filter.userId,\n channel: filter.channel,\n type: filter.type,\n status: filter.status,\n priority: filter.priority,\n startDate: filter.startDate?.toISOString(),\n endDate: filter.endDate?.toISOString(),\n }\n : undefined,\n limit: filter?.limit || 50,\n offset: filter?.offset || 0,\n };\n\n const response = await this.client.tenantQuery<{\n notifications: Notification[];\n }>(query, variables, this.context);\n\n return response.notifications;\n }\n\n /**\n * Get notification template\n */\n public async getTemplate(slug: string, locale?: string): Promise<NotificationTemplate | null> {\n const query = `\n query GetNotificationTemplate($slug: String!, $locale: String) {\n notificationTemplate(slug: $slug, locale: $locale) {\n id\n name\n slug\n description\n channel\n type\n locale\n subject\n bodyTemplate\n htmlTemplate\n variables\n enabled\n version\n createdAt\n updatedAt\n }\n }\n `;\n\n const response = await this.client.tenantQuery<{\n notificationTemplate: NotificationTemplate | null;\n }>(query, { slug, locale }, this.context);\n\n return response.notificationTemplate;\n }\n\n /**\n * Get all notification templates\n */\n public async getTemplates(filter?: {\n channel?: NotificationChannel;\n type?: NotificationType;\n enabled?: boolean;\n }): Promise<NotificationTemplate[]> {\n const query = `\n query GetNotificationTemplates($filter: TemplateFilterInput) {\n notificationTemplates(filter: $filter) {\n id\n name\n slug\n description\n channel\n type\n locale\n subject\n bodyTemplate\n htmlTemplate\n variables\n enabled\n version\n createdAt\n updatedAt\n }\n }\n `;\n\n const response = await this.client.tenantQuery<{\n notificationTemplates: NotificationTemplate[];\n }>(query, { filter }, this.context);\n\n return response.notificationTemplates;\n }\n\n /**\n * Get notification statistics\n */\n public async getStats(filter?: { userId?: string; startDate?: Date; endDate?: Date }): Promise<NotificationStats> {\n const query = `\n query GetNotificationStats($filter: NotificationFilterInput) {\n notificationStats(filter: $filter) {\n total\n pending\n queued\n processing\n sent\n delivered\n failed\n byChannel\n byType\n }\n }\n `;\n\n const variables = {\n filter: filter\n ? {\n userId: filter.userId,\n startDate: filter.startDate?.toISOString(),\n endDate: filter.endDate?.toISOString(),\n }\n : undefined,\n };\n\n const response = await this.client.tenantQuery<{\n notificationStats: NotificationStats;\n }>(query, variables, this.context);\n\n return response.notificationStats;\n }\n\n /**\n * Mark notifications as read\n */\n public async markAsRead(notificationIds: string[]): Promise<boolean> {\n const mutation = `\n mutation MarkNotificationsAsRead($notificationIds: [ID!]!) {\n markNotificationsAsRead(notificationIds: $notificationIds)\n }\n `;\n\n await this.client.tenantQuery(mutation, { notificationIds }, this.context);\n\n logger.info('[TenantNotifications] Notifications marked as read', {\n count: notificationIds.length,\n });\n\n return true;\n }\n\n /**\n * Mark all notifications as read for the current user\n */\n public async markAllAsRead(): Promise<boolean> {\n const mutation = `\n mutation MarkAllMyNotificationsAsRead {\n markAllMyNotificationsAsRead\n }\n `;\n\n await this.client.tenantQuery(mutation, {}, this.context);\n\n logger.info('[TenantNotifications] All notifications marked as read');\n\n return true;\n }\n\n /**\n * Delete notifications\n */\n public async deleteNotifications(notificationIds: string[]): Promise<boolean> {\n const mutation = `\n mutation DeleteNotifications($notificationIds: [ID!]!) {\n deleteNotifications(notificationIds: $notificationIds)\n }\n `;\n\n await this.client.tenantQuery(mutation, { notificationIds }, this.context);\n\n logger.info('[TenantNotifications] Notifications deleted', {\n count: notificationIds.length,\n });\n\n return true;\n }\n\n /**\n * Delete all read notifications for the current user\n */\n public async deleteAllReadNotifications(): Promise<boolean> {\n const mutation = `\n mutation DeleteMyReadNotifications {\n deleteMyReadNotifications\n }\n `;\n\n await this.client.tenantQuery(mutation, {}, this.context);\n\n logger.info('[TenantNotifications] All read notifications deleted');\n\n return true;\n }\n\n /**\n * Validate send notification input\n */\n private validateSendInput(input: SendNotificationInput): void {\n if (!input.recipient || (!input.recipient.email && !input.recipient.userId && !input.recipient.phoneNumber)) {\n throw new ValidationError('Recipient email, userId, or phoneNumber is required');\n }\n\n if (!input.channel) {\n throw new ValidationError('Notification channel is required');\n }\n\n if (!input.body || input.body.trim().length === 0) {\n throw new ValidationError('Notification body is required');\n }\n\n // Channel-specific validation\n if (input.channel === NotificationChannel.EMAIL && !input.recipient.email) {\n throw new ValidationError('Recipient email is required for EMAIL channel');\n }\n\n if (input.channel === NotificationChannel.SMS && !input.recipient.phoneNumber) {\n throw new ValidationError('Recipient phone number is required for SMS channel');\n }\n\n if (input.channel === NotificationChannel.PUSH && !input.recipient.pushToken && !input.recipient.userId) {\n throw new ValidationError('Recipient push token or userId is required for PUSH channel');\n }\n }\n}\n","/**\n * Notifications Module\n * Send in-app, email, SMS, and push notifications via workspaces-backend\n */\n\nimport type { BurdenoffGraphQLClient } from '../client/graphql.js';\nimport type { SDKContext } from '../types/index.js';\nimport { ValidationError } from '../types/index.js';\nimport { logger } from '../logger/index.js';\n\nexport enum NotificationType {\n INFO = 'info',\n SUCCESS = 'success',\n WARNING = 'warning',\n ERROR = 'error',\n}\n\nexport enum NotificationChannel {\n EMAIL = 'EMAIL',\n SMS = 'SMS',\n WHATSAPP = 'WHATSAPP',\n PUSH = 'PUSH',\n SLACK = 'SLACK',\n TEAMS = 'TEAMS',\n WEBHOOK = 'WEBHOOK',\n}\n\n// Re-export from tenant-notifications\nexport { NotificationPriority, TenantNotificationsModule } from './tenant-notifications.js';\n\nexport interface SendNotificationOptions {\n /** Notification title */\n title: string;\n /** Notification message */\n message: string;\n /** Notification type */\n type?: NotificationType;\n /** Target user IDs */\n userIds: string[];\n /** Optional redirect URL */\n redirectUrl?: string;\n /** Application name */\n appName?: string;\n /** Send email notification */\n email?: boolean;\n /** Send SMS notification */\n sms?: boolean;\n}\n\nexport interface NotificationResponse {\n /** Number of successful notifications */\n successCount: number;\n /** Number of failed notifications */\n failureCount: number;\n /** Error messages if any */\n errors: string[];\n /** Created notification IDs */\n notificationIds?: string[];\n}\n\nexport interface GetNotificationsOptions {\n /** User ID to get notifications for */\n userId: string;\n /** Filter by status */\n status?: 'unread' | 'read' | 'all';\n /** Filter by type */\n type?: NotificationType;\n /** Filter by app name */\n appName?: string;\n /** Search term */\n search?: string;\n /** Limit number of results */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n}\n\nexport interface Notification {\n id: string;\n userId: string;\n title: string;\n message: string;\n type: NotificationType;\n status: 'unread' | 'read';\n redirectUrl?: string;\n appName?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface RecipientInput {\n email?: string;\n locale?: string;\n name?: string;\n phoneNumber?: string;\n pushToken?: string;\n slackUserId?: string;\n teamsUserId?: string;\n timezone?: string;\n userId?: string;\n webhookUrl?: string;\n whatsappNumber?: string;\n}\n\nexport interface SendChannelNotificationOptions {\n /** Primary delivery channel (EMAIL, SMS, WHATSAPP, etc.) */\n platform: NotificationChannel;\n /** Recipient information for primary channel */\n recipient: RecipientInput;\n /** Multiple recipients for bulk delivery */\n recipients?: RecipientInput[];\n /** Notification subject (for EMAIL) */\n subject?: string;\n /** Notification body/message */\n body: string;\n /** HTML body (for EMAIL) */\n htmlBody?: string;\n /** Notification type */\n type?: NotificationType;\n /** Application name */\n appName?: string;\n /** Redirect URL */\n redirectUrl?: string;\n /** Also send as in-app notification */\n includeInApp?: boolean;\n /** User IDs for in-app notifications (required when includeInApp is true) */\n userIds?: string[];\n /** Additional metadata */\n metadata?: Record<string, unknown>;\n /** Track email opens */\n trackOpens?: boolean;\n /** Track link clicks */\n trackClicks?: boolean;\n /** Expiration time */\n expiresAt?: Date;\n /** Specific channel instance ID (overrides platform) */\n channelId?: string;\n}\n\nexport interface SendTemplateNotificationOptions {\n /** Primary delivery channel (EMAIL, SMS, WHATSAPP, etc.) */\n platform: NotificationChannel;\n /** Template slug to use */\n templateSlug: string;\n /** Template variables */\n variables: Record<string, unknown>;\n /** Recipient information for primary channel */\n recipient?: RecipientInput;\n /** Multiple recipients for bulk delivery */\n recipients?: RecipientInput[];\n /** Also send as in-app notification */\n includeInApp?: boolean;\n /** User IDs for in-app notifications (required when includeInApp is true) */\n userIds?: string[];\n /** Application name */\n appName?: string;\n /** Track email opens */\n trackOpens?: boolean;\n /** Track link clicks */\n trackClicks?: boolean;\n /** Expiration time */\n expiresAt?: Date;\n /** Scheduled delivery time */\n scheduledFor?: Date;\n /** Timezone for scheduling */\n timezone?: string;\n /** Specific channel instance ID (overrides platform) */\n channelId?: string;\n}\n\n/**\n * Notifications Module\n */\nexport class NotificationsModule {\n constructor(\n private client: BurdenoffGraphQLClient,\n private context: SDKContext\n ) {}\n\n /**\n * Send notification to users\n */\n public async send(options: SendNotificationOptions): Promise<NotificationResponse> {\n // Validate inputs\n if (!options.title || options.title.trim().length === 0) {\n throw new ValidationError('Notification title is required');\n }\n\n if (!options.message || options.message.trim().length === 0) {\n throw new ValidationError('Notification message is required');\n }\n\n if (!options.userIds || options.userIds.length === 0) {\n throw new ValidationError('At least one user ID is required');\n }\n\n logger.info('[Notifications] Sending notification', {\n title: options.title,\n userCount: options.userIds.length,\n type: options.type || NotificationType.INFO,\n });\n\n const mutation = `\n mutation CreateNotification($input: CreateNotificationInput!) {\n createNotification(input: $input) {\n successCount\n failureCount\n errors\n notifications {\n id\n }\n }\n }\n `;\n\n const variables = {\n input: {\n title: options.title,\n message: options.message,\n type: options.type || NotificationType.INFO,\n userIds: options.userIds,\n redirectUrl: options.redirectUrl || '',\n appName: options.appName,\n email: options.email || false,\n sms: options.sms || false,\n },\n };\n\n const response = await this.client.query<{\n createNotification: NotificationResponse & { notifications: Array<{ id: string }> };\n }>(mutation, variables, this.context);\n\n const result = {\n successCount: response.createNotification.successCount,\n failureCount: response.createNotification.failureCount,\n errors: response.createNotification.errors,\n notificationIds: response.createNotification.notifications.map((n) => n.id),\n };\n\n logger.info('[Notifications] Notification sent', {\n successCount: result.successCount,\n failureCount: result.failureCount,\n });\n\n return result;\n }\n\n /**\n * Send notification to a single user (convenience method)\n */\n public async sendToUser(\n userId: string,\n title: string,\n message: string,\n options?: Omit<SendNotificationOptions, 'userIds' | 'title' | 'message'>\n ): Promise<NotificationResponse> {\n return this.send({\n title,\n message,\n userIds: [userId],\n ...options,\n });\n }\n\n /**\n * Get notifications for a user\n */\n public async getNotifications(options: GetNotificationsOptions): Promise<{\n notifications: Notification[];\n total: number;\n unreadCount: number;\n }> {\n logger.debug('[Notifications] Getting notifications', { userId: options.userId });\n\n const query = `\n query GetNotifications(\n $userId: ID!\n $status: NotificationStatus\n $type: NotificationType\n $appName: String\n $search: String\n $limit: Int\n $offset: Int\n ) {\n getNotifications(\n userId: $userId\n status: $status\n type: $type\n appName: $appName\n search: $search\n limit: $limit\n offset: $offset\n ) {\n notifications {\n id\n userId\n title\n message\n type\n status\n redirectUrl\n appName\n createdAt\n updatedAt\n }\n total\n unreadCount\n }\n }\n `;\n\n const variables = {\n userId: options.userId,\n status: options.status,\n type: options.type,\n appName: options.appName,\n search: options.search,\n limit: options.limit || 20,\n offset: options.offset || 0,\n };\n\n const response = await this.client.query<{\n getNotifications: {\n notifications: Notification[];\n total: number;\n unreadCount: number;\n };\n }>(query, variables, this.context);\n\n return response.getNotifications;\n }\n\n /**\n * Mark notification as read\n */\n public async markAsRead(notificationId: string): Promise<boolean> {\n logger.debug('[Notifications] Marking notification as read', { notificationId });\n\n const mutation = `\n mutation MarkNotificationAsRead($notificationId: ID!) {\n markNotificationAsRead(notificationId: $notificationId) {\n id\n status\n }\n }\n `;\n\n await this.client.query(mutation, { notificationId }, this.context);\n\n logger.info('[Notifications] Notification marked as read', { notificationId });\n\n return true;\n }\n\n /**\n * Mark multiple notifications as read\n */\n public async markMultipleAsRead(notificationIds: string[]): Promise<number> {\n logger.debug('[Notifications] Marking multiple notifications as read', {\n count: notificationIds.length,\n });\n\n const mutation = `\n mutation MarkNotificationsAsRead($notificationIds: [ID!]!) {\n markNotificationsAsRead(notificationIds: $notificationIds) {\n count\n }\n }\n `;\n\n const response = await this.client.query<{\n markNotificationsAsRead: { count: number };\n }>(mutation, { notificationIds }, this.context);\n\n logger.info('[Notifications] Notifications marked as read', {\n count: response.markNotificationsAsRead.count,\n });\n\n return response.markNotificationsAsRead.count;\n }\n\n /**\n * Mark all notifications as read for the current user\n */\n public async markAllAsRead(): Promise<number> {\n logger.debug('[Notifications] Marking all notifications as read');\n\n const mutation = `\n mutation MarkAllMyNotificationsAsRead {\n markAllMyNotificationsAsRead {\n count\n }\n }\n `;\n\n const response = await this.client.query<{\n markAllMyNotificationsAsRead: { count: number };\n }>(mutation, {}, this.context);\n\n logger.info('[Notifications] All notifications marked as read', {\n count: response.markAllMyNotificationsAsRead.count,\n });\n\n return response.markAllMyNotificationsAsRead.count;\n }\n\n /**\n * Delete notification\n */\n public async deleteNotification(notificationId: string): Promise<boolean> {\n logger.debug('[Notifications] Deleting notification', { notificationId });\n\n const mutation = `\n mutation DeleteNotification($notificationId: ID!) {\n deleteNotification(notificationId: $notificationId) {\n success\n }\n }\n `;\n\n await this.client.query(mutation, { notificationId }, this.context);\n\n logger.info('[Notifications] Notification deleted', { notificationId });\n\n return true;\n }\n\n /**\n * Delete multiple notifications\n */\n public async deleteMultiple(notificationIds: string[]): Promise<number> {\n logger.debug('[Notifications] Deleting multiple notifications', {\n count: notificationIds.length,\n });\n\n const mutation = `\n mutation DeleteNotifications($notificationIds: [ID!]!) {\n deleteNotifications(notificationIds: $notificationIds) {\n count\n }\n }\n `;\n\n const response = await this.client.query<{\n deleteNotifications: { count: number };\n }>(mutation, { notificationIds }, this.context);\n\n logger.info('[Notifications] Notifications deleted', {\n count: response.deleteNotifications.count,\n });\n\n return response.deleteNotifications.count;\n }\n\n /**\n * Get unread notification count for a user\n */\n public async getUnreadCount(userId: string): Promise<number> {\n const result = await this.getNotifications({\n userId,\n status: 'unread',\n limit: 0,\n });\n\n return result.unreadCount;\n }\n\n /**\n * Send notification via specific channel (EMAIL, SMS, WHATSAPP, etc.)\n * with optional in-app notification\n */\n public async sendChannelNotification(options: SendChannelNotificationOptions): Promise<NotificationResponse> {\n // Validate inputs\n if (!options.body || options.body.trim().length === 0) {\n throw new ValidationError('Notification body is required');\n }\n\n if (!options.recipient && !options.recipients) {\n throw new ValidationError('At least one recipient is required');\n }\n\n if (options.includeInApp && (!options.userIds || options.userIds.length === 0)) {\n throw new ValidationError('User IDs are required when includeInApp is true');\n }\n\n logger.info('[Notifications] Sending channel notification', {\n platform: options.platform,\n recipientCount: options.recipients ? options.recipients.length : 1,\n includeInApp: options.includeInApp,\n inAppUserCount: options.userIds ? options.userIds.length : 0,\n });\n\n const mutation = `\n mutation TriggerNotification($input: TriggerNotificationInput!) {\n triggerNotification(input: $input) {\n id\n status\n deliveryStatus\n }\n }\n `;\n\n const variables = {\n input: {\n platform: options.platform,\n channelId: options.channelId,\n includeInApp: options.includeInApp || false,\n userIds: options.userIds || [],\n notification: {\n subject: options.subject || '',\n body: options.body,\n htmlBody: options.htmlBody || '',\n channel: options.platform,\n type: options.type || NotificationType.INFO,\n recipient: options.recipient,\n appName: options.appName,\n redirectUrl: options.redirectUrl || '',\n metadata: options.metadata || {},\n trackOpens: options.trackOpens || false,\n trackClicks: options.trackClicks || false,\n expiresAt: options.expiresAt?.toISOString(),\n },\n },\n };\n\n // Handle bulk recipients\n if (options.recipients && options.recipients.length > 1) {\n const results = await Promise.allSettled(\n options.recipients.map((recipient) =>\n this.client.query(\n mutation,\n {\n input: {\n ...variables.input,\n notification: {\n ...variables.input.notification,\n recipient,\n },\n },\n },\n this.context\n )\n )\n );\n\n let successCount = 0;\n let failureCount = 0;\n const errors: string[] = [];\n const notificationIds: string[] = [];\n\n results.forEach((result, index) => {\n if (result.status === 'fulfilled') {\n successCount++;\n const response = result.value as { triggerNotification: { id: string } };\n notificationIds.push(response.triggerNotification.id);\n } else {\n failureCount++;\n errors.push(\n `Recipient ${index + 1}: ${result.reason instanceof Error ? result.reason.message : 'Unknown error'}`\n );\n }\n });\n\n const response: NotificationResponse = {\n successCount,\n failureCount,\n errors,\n notificationIds,\n };\n\n logger.info('[Notifications] Channel notification sent (bulk)', {\n successCount,\n failureCount,\n });\n\n return response;\n } else {\n // Single recipient\n try {\n const response = await this.client.query<{\n triggerNotification: { id: string; status: string; deliveryStatus: string };\n }>(mutation, variables, this.context);\n\n const result: NotificationResponse = {\n successCount: 1,\n failureCount: 0,\n errors: [],\n notificationIds: [response.triggerNotification.id],\n };\n\n logger.info('[Notifications] Channel notification sent', {\n notificationId: response.triggerNotification.id,\n status: response.triggerNotification.status,\n });\n\n return result;\n } catch (error) {\n logger.error('[Notifications] Failed to send channel notification', { error });\n\n return {\n successCount: 0,\n failureCount: 1,\n errors: [error instanceof Error ? error.message : 'Unknown error'],\n notificationIds: [],\n };\n }\n }\n }\n\n /**\n * Send notification using a template with optional in-app notification\n */\n public async sendTemplateNotification(options: SendTemplateNotificationOptions): Promise<NotificationResponse> {\n // Validate inputs\n if (!options.templateSlug || options.templateSlug.trim().length === 0) {\n throw new ValidationError('Template slug is required');\n }\n\n if (!options.variables || typeof options.variables !== 'object') {\n throw new ValidationError('Template variables are required');\n }\n\n if (!options.recipient && !options.recipients) {\n throw new ValidationError('At least one recipient is required');\n }\n\n if (options.includeInApp && (!options.userIds || options.userIds.length === 0)) {\n throw new ValidationError('User IDs are required when includeInApp is true');\n }\n\n logger.info('[Notifications] Sending template notification', {\n templateSlug: options.templateSlug,\n platform: options.platform,\n recipientCount: options.recipients ? options.recipients.length : 1,\n includeInApp: options.includeInApp,\n inAppUserCount: options.userIds ? options.userIds.length : 0,\n });\n\n const mutation = `\n mutation TriggerNotificationWithTemplate($input: TriggerNotificationWithTemplateInput!) {\n triggerNotificationWithTemplate(input: $input) {\n id\n status\n deliveryStatus\n }\n }\n `;\n\n const variables = {\n input: {\n platform: options.platform,\n channelId: options.channelId,\n includeInApp: options.includeInApp || false,\n userIds: options.userIds || [],\n templateSlug: options.templateSlug,\n variables: options.variables,\n recipient: options.recipient,\n recipients: options.recipients,\n trackOpens: options.trackOpens || false,\n trackClicks: options.trackClicks || false,\n expiresAt: options.expiresAt?.toISOString(),\n scheduledFor: options.scheduledFor?.toISOString(),\n timezone: options.timezone,\n },\n };\n\n try {\n const response = await this.client.query<{\n triggerNotificationWithTemplate: { id: string; status: string; deliveryStatus: string };\n }>(mutation, variables, this.context);\n\n const result: NotificationResponse = {\n successCount: 1,\n failureCount: 0,\n errors: [],\n notificationIds: [response.triggerNotificationWithTemplate.id],\n };\n\n logger.info('[Notifications] Template notification sent', {\n notificationId: response.triggerNotificationWithTemplate.id,\n status: response.triggerNotificationWithTemplate.status,\n });\n\n return result;\n } catch (error) {\n logger.error('[Notifications] Failed to send template notification', { error });\n\n return {\n successCount: 0,\n failureCount: 1,\n errors: [error instanceof Error ? error.message : 'Unknown error'],\n notificationIds: [],\n };\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/notifications/tenant-notifications.ts","../src/notifications/index.ts"],"names":["NotificationChannel","NotificationPriority","NotificationType","TenantNotificationsModule","client","context","send","input","validateSendInput","logger","info","channel","type","priority","mutation","variables","recipient","subject","body","htmlBody","data","metadata","scheduledFor","toISOString","expiresAt","trackOpens","trackClicks","response","tenantQuery","notificationId","sendNotification","sendWithTemplate","templateSlug","trim","length","ValidationError","Object","keys","email","userId","channelId","platform","timezone","triggerNotificationWithTemplate","id","status","sendBatch","notifications","count","batchSize","map","n","delayBetweenBatches","batchId","sendBatchNotifications","queued","totalQueued","failed","totalFailed","getNotification","query","notification","getNotifications","filter","startDate","endDate","undefined","limit","offset","getTemplate","slug","locale","notificationTemplate","getTemplates","notificationTemplates","getStats","notificationStats","markAsRead","notificationIds","markAllAsRead","deleteNotifications","deleteAllReadNotifications","phoneNumber","pushToken","NotificationsModule","options","title","message","userIds","userCount","redirectUrl","appName","sms","result","successCount","createNotification","failureCount","errors","sendToUser","debug","search","markMultipleAsRead","markNotificationsAsRead","markAllMyNotificationsAsRead","deleteNotification","deleteMultiple","getUnreadCount","unreadCount","sendChannelNotification","recipients","includeInApp","recipientCount","inAppUserCount","results","Promise","allSettled","forEach","index","value","push","triggerNotification","reason","Error","error","sendTemplateNotification"],"mappings":";;;;;AAAA,IAAA,4BAAA,GAAA;;;;;;;AAcO,IAAKA,mBAAAA,6BAAAA,oBAAAA,EAAAA;;;;;;;;;;;AAAAA,EAAAA,OAAAA,oBAAAA;;AAaL,IAAKC,oBAAAA,6BAAAA,qBAAAA,EAAAA;;;;;AAAAA,EAAAA,OAAAA,qBAAAA;;AAOL,IAAKC,gBAAAA,6BAAAA,iBAAAA,EAAAA;;;;;AAAAA,EAAAA,OAA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A,IAAc,KAAA;AAClCC,QAAAA,WAAAA,EAAa2D,QAAQ3D,WAAAA,IAAe,KAAA;QACpCF,SAAAA,EAAW6D,OAAAA,CAAQ7D,WAAWD,WAAAA,EAAAA;QAC9BD,YAAAA,EAAc+D,OAAAA,CAAQ/D,cAAcC,WAAAA,EAAAA;AACpCmB,QAAAA,QAAAA,EAAU2C,OAAAA,CAAQ3C;AACpB;AACF,KAAA;AAEA,IAAA,IAAI;AACF,MAAA,MAAMf,QAAAA,GAAW,MAAM,IAAA,CAAKvB,MAAAA,CAAOwD,MAEhC9C,QAAAA,EAAUC,SAAAA,EAAW,KAAKV,OAAO,CAAA;AAEpC,MAAA,MAAMwF,MAAAA,GAA+B;QACnCC,YAAAA,EAAc,CAAA;QACdE,YAAAA,EAAc,CAAA;AACdC,QAAAA,MAAAA,EAAQ,EAAA;QACRnB,eAAAA,EAAiB;AAACnD,UAAAA,QAAAA,CAASgB,+BAAAA,CAAgCC;;AAC7D,OAAA;AAEAnC,MAAAA,MAAAA,CAAOC,KAAK,4CAAA,EAA8C;AACxDmB,QAAAA,cAAAA,EAAgBF,SAASgB,+BAAAA,CAAgCC,EAAAA;AACzDC,QAAAA,MAAAA,EAAQlB,SAASgB,+BAAAA,CAAgCE;OACnD,CAAA;AAEA,MAAA,OAAOgD,MAAAA;AACT,IAAA,CAAA,CAAA,OAAS8B,KAAAA,EAAO;AACdlH,MAAAA,MAAAA,CAAOkH,MAAM,sDAAA,EAAwD;AAAEA,QAAAA;OAAM,CAAA;AAE7E,MAAA,OAAO;QACL7B,YAAAA,EAAc,CAAA;QACdE,YAAAA,EAAc,CAAA;QACdC,MAAAA,EAAQ;UAAC0B,KAAAA,YAAiBD,KAAAA,GAAQC,MAAMpC,OAAAA,GAAU;;AAClDT,QAAAA,eAAAA,EAAiB;AACnB,OAAA;AACF,IAAA;AACF,EAAA;AACF","file":"chunk-I43B35CP.js","sourcesContent":["/**\n * Tenant-Backend Notifications Module\n * Comprehensive notification system supporting 10+ channels via tenant-backend\n */\n\nimport type { BurdenoffGraphQLClient } from '../client/graphql.js';\nimport type { SDKContext } from '../types/index.js';\nimport { ValidationError } from '../types/index.js';\nimport { logger } from '../logger/index.js';\n\n// ========================================\n// Enums\n// ========================================\n\nexport enum NotificationChannel {\n EMAIL = 'EMAIL',\n SMS = 'SMS',\n PUSH = 'PUSH',\n IN_APP = 'IN_APP',\n WEBHOOK = 'WEBHOOK',\n WHATSAPP = 'WHATSAPP',\n TEAMS = 'TEAMS',\n SLACK = 'SLACK',\n TELEGRAM = 'TELEGRAM',\n DISCORD = 'DISCORD',\n}\n\nexport enum NotificationPriority {\n LOW = 'LOW',\n MEDIUM = 'MEDIUM',\n HIGH = 'HIGH',\n URGENT = 'URGENT',\n}\n\nexport enum NotificationType {\n TRANSACTIONAL = 'TRANSACTIONAL',\n MARKETING = 'MARKETING',\n SYSTEM = 'SYSTEM',\n ALERT = 'ALERT',\n}\n\n// ========================================\n// Types & Interfaces\n// ========================================\n\nexport interface RecipientInput {\n userId?: string;\n email?: string;\n phoneNumber?: string;\n pushToken?: string;\n whatsappNumber?: string;\n teamsUserId?: string;\n slackUserId?: string;\n webhookUrl?: string;\n name?: string;\n locale?: string;\n timezone?: string;\n}\n\nexport interface SendNotificationInput {\n recipient: RecipientInput;\n channel: NotificationChannel;\n type?: NotificationType;\n priority?: NotificationPriority;\n subject?: string;\n body: string;\n htmlBody?: string;\n data?: Record<string, unknown>;\n metadata?: Record<string, unknown>;\n scheduledFor?: Date;\n expiresAt?: Date;\n trackOpens?: boolean;\n trackClicks?: boolean;\n}\n\nexport interface SendWithTemplateInput {\n templateSlug: string;\n variables: Record<string, unknown>;\n recipient: RecipientInput;\n priority?: NotificationPriority;\n scheduledFor?: Date;\n expiresAt?: Date;\n trackOpens?: boolean;\n trackClicks?: boolean;\n /** Specific channel instance ID from channel service (takes precedence) */\n channelId?: string;\n /** Platform type for auto-failover (EMAIL, SMS, etc.) - used if channelId not provided */\n platform?: NotificationChannel;\n /** Timezone for scheduling */\n timezone?: string;\n}\n\nexport interface BatchNotificationInput {\n notifications: SendNotificationInput[];\n batchSize?: number;\n delayBetweenBatches?: number;\n priority?: NotificationPriority;\n}\n\nexport interface Notification {\n id: string;\n userId: string;\n channel: NotificationChannel;\n type: NotificationType;\n priority: NotificationPriority;\n status: string;\n deliveryStatus?: string;\n title: string;\n message: string;\n htmlMessage?: string;\n subject?: string;\n recipientEmail?: string;\n recipientPhone?: string;\n trackOpens: boolean;\n trackClicks: boolean;\n openedAt?: string;\n clickedAt?: string;\n sentAt?: string;\n deliveredAt?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface NotificationTemplate {\n id: string;\n name: string;\n slug: string;\n description?: string;\n channel: NotificationChannel;\n type: NotificationType;\n locale: string;\n subject?: string;\n bodyTemplate: string;\n htmlTemplate?: string;\n variables: Array<{\n name: string;\n type: string;\n required: boolean;\n defaultValue?: unknown;\n description?: string;\n example?: unknown;\n }>;\n enabled: boolean;\n version: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface NotificationStats {\n total: number;\n pending: number;\n queued: number;\n processing: number;\n sent: number;\n delivered: number;\n failed: number;\n byChannel: Record<string, number>;\n byType: Record<string, number>;\n}\n\n// ========================================\n// Tenant Notifications Module\n// ========================================\n\n/**\n * Tenant-Backend Notifications Module\n * Provides access to the centralized notification system\n */\nexport class TenantNotificationsModule {\n constructor(\n private client: BurdenoffGraphQLClient,\n private context: SDKContext\n ) {}\n\n /**\n * Send a single notification\n */\n public async send(input: SendNotificationInput): Promise<string> {\n // Validate inputs\n this.validateSendInput(input);\n\n logger.info('[TenantNotifications] Sending notification', {\n channel: input.channel,\n type: input.type || NotificationType.TRANSACTIONAL,\n priority: input.priority || NotificationPriority.MEDIUM,\n });\n\n const mutation = `\n mutation SendNotification($input: SendNotificationInput!) {\n sendNotification(input: $input)\n }\n `;\n\n const variables = {\n input: {\n recipient: input.recipient,\n channel: input.channel,\n type: input.type || NotificationType.TRANSACTIONAL,\n priority: input.priority || NotificationPriority.MEDIUM,\n subject: input.subject,\n body: input.body,\n htmlBody: input.htmlBody,\n data: input.data,\n metadata: input.metadata,\n scheduledFor: input.scheduledFor?.toISOString(),\n expiresAt: input.expiresAt?.toISOString(),\n trackOpens: input.trackOpens,\n trackClicks: input.trackClicks,\n },\n };\n\n const response = await this.client.tenantQuery<{\n sendNotification: string;\n }>(mutation, variables, this.context);\n\n logger.info('[TenantNotifications] Notification sent', {\n notificationId: response.sendNotification,\n });\n\n return response.sendNotification;\n }\n\n /**\n * Send notification using a template\n */\n public async sendWithTemplate(input: SendWithTemplateInput): Promise<string> {\n // Validate inputs\n if (!input.templateSlug || input.templateSlug.trim().length === 0) {\n throw new ValidationError('Template slug is required');\n }\n\n if (!input.variables || Object.keys(input.variables).length === 0) {\n throw new ValidationError('Template variables are required');\n }\n\n if (!input.recipient || (!input.recipient.email && !input.recipient.userId)) {\n throw new ValidationError('Recipient email or userId is required');\n }\n\n logger.info('[TenantNotifications] Sending notification with template', {\n templateSlug: input.templateSlug,\n priority: input.priority || NotificationPriority.MEDIUM,\n });\n\n const mutation = `\n mutation TriggerNotificationWithTemplate($input: TriggerNotificationWithTemplateInput!) {\n triggerNotificationWithTemplate(input: $input) {\n id\n status\n deliveryStatus\n }\n }\n `;\n\n const variables = {\n input: {\n templateSlug: input.templateSlug,\n variables: input.variables,\n recipient: input.recipient,\n priority: input.priority || NotificationPriority.MEDIUM,\n scheduledFor: input.scheduledFor?.toISOString(),\n expiresAt: input.expiresAt?.toISOString(),\n trackOpens: input.trackOpens,\n trackClicks: input.trackClicks,\n // Platform is required for notification delivery routing\n // If channelId is specified, it takes precedence; otherwise platform determines delivery\n channelId: input.channelId,\n platform: input.platform || NotificationChannel.EMAIL,\n timezone: input.timezone,\n },\n };\n\n const response = await this.client.tenantQuery<{\n triggerNotificationWithTemplate: { id: string; status: string; deliveryStatus?: string };\n }>(mutation, variables, this.context);\n\n logger.info('[TenantNotifications] Notification sent with template', {\n notificationId: response.triggerNotificationWithTemplate.id,\n status: response.triggerNotificationWithTemplate.status,\n });\n\n return response.triggerNotificationWithTemplate.id;\n }\n\n /**\n * Send batch notifications\n */\n public async sendBatch(input: BatchNotificationInput): Promise<{\n totalRequested: number;\n totalQueued: number;\n totalFailed: number;\n batchId: string;\n }> {\n if (!input.notifications || input.notifications.length === 0) {\n throw new ValidationError('At least one notification is required');\n }\n\n logger.info('[TenantNotifications] Sending batch notifications', {\n count: input.notifications.length,\n batchSize: input.batchSize,\n });\n\n const mutation = `\n mutation SendBatchNotifications($input: BatchNotificationInput!) {\n sendBatchNotifications(input: $input) {\n totalRequested\n totalQueued\n totalFailed\n batchId\n }\n }\n `;\n\n const variables = {\n input: {\n notifications: input.notifications.map((n) => ({\n recipient: n.recipient,\n channel: n.channel,\n type: n.type || NotificationType.TRANSACTIONAL,\n priority: n.priority || NotificationPriority.MEDIUM,\n subject: n.subject,\n body: n.body,\n htmlBody: n.htmlBody,\n data: n.data,\n metadata: n.metadata,\n scheduledFor: n.scheduledFor?.toISOString(),\n expiresAt: n.expiresAt?.toISOString(),\n trackOpens: n.trackOpens,\n trackClicks: n.trackClicks,\n })),\n batchSize: input.batchSize,\n delayBetweenBatches: input.delayBetweenBatches,\n priority: input.priority,\n },\n };\n\n const response = await this.client.tenantQuery<{\n sendBatchNotifications: {\n totalRequested: number;\n totalQueued: number;\n totalFailed: number;\n batchId: string;\n };\n }>(mutation, variables, this.context);\n\n logger.info('[TenantNotifications] Batch notifications sent', {\n batchId: response.sendBatchNotifications.batchId,\n queued: response.sendBatchNotifications.totalQueued,\n failed: response.sendBatchNotifications.totalFailed,\n });\n\n return response.sendBatchNotifications;\n }\n\n /**\n * Get a notification by ID\n */\n public async getNotification(id: string): Promise<Notification | null> {\n const query = `\n query GetNotification($id: ID!) {\n notification(id: $id) {\n id\n userId\n channel\n type\n priority\n status\n deliveryStatus\n title\n message\n htmlMessage\n subject\n recipientEmail\n recipientPhone\n trackOpens\n trackClicks\n openedAt\n clickedAt\n sentAt\n deliveredAt\n createdAt\n updatedAt\n }\n }\n `;\n\n const response = await this.client.tenantQuery<{\n notification: Notification | null;\n }>(query, { id }, this.context);\n\n return response.notification;\n }\n\n /**\n * Get notifications with filters\n */\n public async getNotifications(filter?: {\n userId?: string;\n channel?: NotificationChannel;\n type?: NotificationType;\n status?: string;\n priority?: NotificationPriority;\n startDate?: Date;\n endDate?: Date;\n limit?: number;\n offset?: number;\n }): Promise<Notification[]> {\n const query = `\n query GetNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {\n notifications(filter: $filter, limit: $limit, offset: $offset) {\n id\n userId\n channel\n type\n priority\n status\n deliveryStatus\n title\n message\n subject\n recipientEmail\n trackOpens\n trackClicks\n openedAt\n clickedAt\n sentAt\n deliveredAt\n createdAt\n updatedAt\n }\n }\n `;\n\n const variables = {\n filter: filter\n ? {\n userId: filter.userId,\n channel: filter.channel,\n type: filter.type,\n status: filter.status,\n priority: filter.priority,\n startDate: filter.startDate?.toISOString(),\n endDate: filter.endDate?.toISOString(),\n }\n : undefined,\n limit: filter?.limit || 50,\n offset: filter?.offset || 0,\n };\n\n const response = await this.client.tenantQuery<{\n notifications: Notification[];\n }>(query, variables, this.context);\n\n return response.notifications;\n }\n\n /**\n * Get notification template\n */\n public async getTemplate(slug: string, locale?: string): Promise<NotificationTemplate | null> {\n const query = `\n query GetNotificationTemplate($slug: String!, $locale: String) {\n notificationTemplate(slug: $slug, locale: $locale) {\n id\n name\n slug\n description\n channel\n type\n locale\n subject\n bodyTemplate\n htmlTemplate\n variables\n enabled\n version\n createdAt\n updatedAt\n }\n }\n `;\n\n const response = await this.client.tenantQuery<{\n notificationTemplate: NotificationTemplate | null;\n }>(query, { slug, locale }, this.context);\n\n return response.notificationTemplate;\n }\n\n /**\n * Get all notification templates\n */\n public async getTemplates(filter?: {\n channel?: NotificationChannel;\n type?: NotificationType;\n enabled?: boolean;\n }): Promise<NotificationTemplate[]> {\n const query = `\n query GetNotificationTemplates($filter: TemplateFilterInput) {\n notificationTemplates(filter: $filter) {\n id\n name\n slug\n description\n channel\n type\n locale\n subject\n bodyTemplate\n htmlTemplate\n variables\n enabled\n version\n createdAt\n updatedAt\n }\n }\n `;\n\n const response = await this.client.tenantQuery<{\n notificationTemplates: NotificationTemplate[];\n }>(query, { filter }, this.context);\n\n return response.notificationTemplates;\n }\n\n /**\n * Get notification statistics\n */\n public async getStats(filter?: { userId?: string; startDate?: Date; endDate?: Date }): Promise<NotificationStats> {\n const query = `\n query GetNotificationStats($filter: NotificationFilterInput) {\n notificationStats(filter: $filter) {\n total\n pending\n queued\n processing\n sent\n delivered\n failed\n byChannel\n byType\n }\n }\n `;\n\n const variables = {\n filter: filter\n ? {\n userId: filter.userId,\n startDate: filter.startDate?.toISOString(),\n endDate: filter.endDate?.toISOString(),\n }\n : undefined,\n };\n\n const response = await this.client.tenantQuery<{\n notificationStats: NotificationStats;\n }>(query, variables, this.context);\n\n return response.notificationStats;\n }\n\n /**\n * Mark notifications as read\n */\n public async markAsRead(notificationIds: string[]): Promise<boolean> {\n const mutation = `\n mutation MarkNotificationsAsRead($notificationIds: [ID!]!) {\n markNotificationsAsRead(notificationIds: $notificationIds)\n }\n `;\n\n await this.client.tenantQuery(mutation, { notificationIds }, this.context);\n\n logger.info('[TenantNotifications] Notifications marked as read', {\n count: notificationIds.length,\n });\n\n return true;\n }\n\n /**\n * Mark all notifications as read for the current user\n */\n public async markAllAsRead(): Promise<boolean> {\n const mutation = `\n mutation MarkAllMyNotificationsAsRead {\n markAllMyNotificationsAsRead\n }\n `;\n\n await this.client.tenantQuery(mutation, {}, this.context);\n\n logger.info('[TenantNotifications] All notifications marked as read');\n\n return true;\n }\n\n /**\n * Delete notifications\n */\n public async deleteNotifications(notificationIds: string[]): Promise<boolean> {\n const mutation = `\n mutation DeleteNotifications($notificationIds: [ID!]!) {\n deleteNotifications(notificationIds: $notificationIds)\n }\n `;\n\n await this.client.tenantQuery(mutation, { notificationIds }, this.context);\n\n logger.info('[TenantNotifications] Notifications deleted', {\n count: notificationIds.length,\n });\n\n return true;\n }\n\n /**\n * Delete all read notifications for the current user\n */\n public async deleteAllReadNotifications(): Promise<boolean> {\n const mutation = `\n mutation DeleteMyReadNotifications {\n deleteMyReadNotifications\n }\n `;\n\n await this.client.tenantQuery(mutation, {}, this.context);\n\n logger.info('[TenantNotifications] All read notifications deleted');\n\n return true;\n }\n\n /**\n * Validate send notification input\n */\n private validateSendInput(input: SendNotificationInput): void {\n if (!input.recipient || (!input.recipient.email && !input.recipient.userId && !input.recipient.phoneNumber)) {\n throw new ValidationError('Recipient email, userId, or phoneNumber is required');\n }\n\n if (!input.channel) {\n throw new ValidationError('Notification channel is required');\n }\n\n if (!input.body || input.body.trim().length === 0) {\n throw new ValidationError('Notification body is required');\n }\n\n // Channel-specific validation\n if (input.channel === NotificationChannel.EMAIL && !input.recipient.email) {\n throw new ValidationError('Recipient email is required for EMAIL channel');\n }\n\n if (input.channel === NotificationChannel.SMS && !input.recipient.phoneNumber) {\n throw new ValidationError('Recipient phone number is required for SMS channel');\n }\n\n if (input.channel === NotificationChannel.PUSH && !input.recipient.pushToken && !input.recipient.userId) {\n throw new ValidationError('Recipient push token or userId is required for PUSH channel');\n }\n }\n}\n","/**\n * Notifications Module\n * Send in-app, email, SMS, and push notifications via workspaces-backend\n */\n\nimport type { BurdenoffGraphQLClient } from '../client/graphql.js';\nimport type { SDKContext } from '../types/index.js';\nimport { ValidationError } from '../types/index.js';\nimport { logger } from '../logger/index.js';\n\nexport enum NotificationType {\n INFO = 'info',\n SUCCESS = 'success',\n WARNING = 'warning',\n ERROR = 'error',\n}\n\nexport enum NotificationChannel {\n EMAIL = 'EMAIL',\n SMS = 'SMS',\n WHATSAPP = 'WHATSAPP',\n PUSH = 'PUSH',\n SLACK = 'SLACK',\n TEAMS = 'TEAMS',\n WEBHOOK = 'WEBHOOK',\n}\n\n// Re-export from tenant-notifications\nexport { NotificationPriority, TenantNotificationsModule } from './tenant-notifications.js';\n\nexport interface SendNotificationOptions {\n /** Notification title */\n title: string;\n /** Notification message */\n message: string;\n /** Notification type */\n type?: NotificationType;\n /** Target user IDs */\n userIds: string[];\n /** Optional redirect URL */\n redirectUrl?: string;\n /** Application name */\n appName?: string;\n /** Send email notification */\n email?: boolean;\n /** Send SMS notification */\n sms?: boolean;\n}\n\nexport interface NotificationResponse {\n /** Number of successful notifications */\n successCount: number;\n /** Number of failed notifications */\n failureCount: number;\n /** Error messages if any */\n errors: string[];\n /** Created notification IDs */\n notificationIds?: string[];\n}\n\nexport interface GetNotificationsOptions {\n /** User ID to get notifications for */\n userId: string;\n /** Filter by status */\n status?: 'unread' | 'read' | 'all';\n /** Filter by type */\n type?: NotificationType;\n /** Filter by app name */\n appName?: string;\n /** Search term */\n search?: string;\n /** Limit number of results */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n}\n\nexport interface Notification {\n id: string;\n userId: string;\n title: string;\n message: string;\n type: NotificationType;\n status: 'unread' | 'read';\n redirectUrl?: string;\n appName?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface RecipientInput {\n email?: string;\n locale?: string;\n name?: string;\n phoneNumber?: string;\n pushToken?: string;\n slackUserId?: string;\n teamsUserId?: string;\n timezone?: string;\n userId?: string;\n webhookUrl?: string;\n whatsappNumber?: string;\n}\n\nexport interface SendChannelNotificationOptions {\n /** Primary delivery channel (EMAIL, SMS, WHATSAPP, etc.) */\n platform: NotificationChannel;\n /** Recipient information for primary channel */\n recipient: RecipientInput;\n /** Multiple recipients for bulk delivery */\n recipients?: RecipientInput[];\n /** Notification subject (for EMAIL) */\n subject?: string;\n /** Notification body/message */\n body: string;\n /** HTML body (for EMAIL) */\n htmlBody?: string;\n /** Notification type */\n type?: NotificationType;\n /** Application name */\n appName?: string;\n /** Redirect URL */\n redirectUrl?: string;\n /** Also send as in-app notification */\n includeInApp?: boolean;\n /** User IDs for in-app notifications (required when includeInApp is true) */\n userIds?: string[];\n /** Additional metadata */\n metadata?: Record<string, unknown>;\n /** Track email opens */\n trackOpens?: boolean;\n /** Track link clicks */\n trackClicks?: boolean;\n /** Expiration time */\n expiresAt?: Date;\n /** Specific channel instance ID (overrides platform) */\n channelId?: string;\n}\n\nexport interface SendTemplateNotificationOptions {\n /** Primary delivery channel (EMAIL, SMS, WHATSAPP, etc.) */\n platform: NotificationChannel;\n /** Template slug to use */\n templateSlug: string;\n /** Template variables */\n variables: Record<string, unknown>;\n /** Recipient information for primary channel */\n recipient?: RecipientInput;\n /** Multiple recipients for bulk delivery */\n recipients?: RecipientInput[];\n /** Also send as in-app notification */\n includeInApp?: boolean;\n /** User IDs for in-app notifications (required when includeInApp is true) */\n userIds?: string[];\n /** Application name */\n appName?: string;\n /** Track email opens */\n trackOpens?: boolean;\n /** Track link clicks */\n trackClicks?: boolean;\n /** Expiration time */\n expiresAt?: Date;\n /** Scheduled delivery time */\n scheduledFor?: Date;\n /** Timezone for scheduling */\n timezone?: string;\n /** Specific channel instance ID (overrides platform) */\n channelId?: string;\n}\n\n/**\n * Notifications Module\n */\nexport class NotificationsModule {\n constructor(\n private client: BurdenoffGraphQLClient,\n private context: SDKContext\n ) {}\n\n /**\n * Send notification to users\n */\n public async send(options: SendNotificationOptions): Promise<NotificationResponse> {\n // Validate inputs\n if (!options.title || options.title.trim().length === 0) {\n throw new ValidationError('Notification title is required');\n }\n\n if (!options.message || options.message.trim().length === 0) {\n throw new ValidationError('Notification message is required');\n }\n\n if (!options.userIds || options.userIds.length === 0) {\n throw new ValidationError('At least one user ID is required');\n }\n\n logger.info('[Notifications] Sending notification', {\n title: options.title,\n userCount: options.userIds.length,\n type: options.type || NotificationType.INFO,\n });\n\n const mutation = `\n mutation CreateNotification($input: CreateNotificationInput!) {\n createNotification(input: $input) {\n successCount\n failureCount\n errors\n notifications {\n id\n }\n }\n }\n `;\n\n const variables = {\n input: {\n title: options.title,\n message: options.message,\n type: options.type || NotificationType.INFO,\n userIds: options.userIds,\n redirectUrl: options.redirectUrl || '',\n appName: options.appName,\n email: options.email || false,\n sms: options.sms || false,\n },\n };\n\n const response = await this.client.query<{\n createNotification: NotificationResponse & { notifications: Array<{ id: string }> };\n }>(mutation, variables, this.context);\n\n const result = {\n successCount: response.createNotification.successCount,\n failureCount: response.createNotification.failureCount,\n errors: response.createNotification.errors,\n notificationIds: response.createNotification.notifications.map((n) => n.id),\n };\n\n logger.info('[Notifications] Notification sent', {\n successCount: result.successCount,\n failureCount: result.failureCount,\n });\n\n return result;\n }\n\n /**\n * Send notification to a single user (convenience method)\n */\n public async sendToUser(\n userId: string,\n title: string,\n message: string,\n options?: Omit<SendNotificationOptions, 'userIds' | 'title' | 'message'>\n ): Promise<NotificationResponse> {\n return this.send({\n title,\n message,\n userIds: [userId],\n ...options,\n });\n }\n\n /**\n * Get notifications for a user\n */\n public async getNotifications(options: GetNotificationsOptions): Promise<{\n notifications: Notification[];\n total: number;\n unreadCount: number;\n }> {\n logger.debug('[Notifications] Getting notifications', { userId: options.userId });\n\n const query = `\n query GetNotifications(\n $userId: ID!\n $status: NotificationStatus\n $type: NotificationType\n $appName: String\n $search: String\n $limit: Int\n $offset: Int\n ) {\n getNotifications(\n userId: $userId\n status: $status\n type: $type\n appName: $appName\n search: $search\n limit: $limit\n offset: $offset\n ) {\n notifications {\n id\n userId\n title\n message\n type\n status\n redirectUrl\n appName\n createdAt\n updatedAt\n }\n total\n unreadCount\n }\n }\n `;\n\n const variables = {\n userId: options.userId,\n status: options.status,\n type: options.type,\n appName: options.appName,\n search: options.search,\n limit: options.limit || 20,\n offset: options.offset || 0,\n };\n\n const response = await this.client.query<{\n getNotifications: {\n notifications: Notification[];\n total: number;\n unreadCount: number;\n };\n }>(query, variables, this.context);\n\n return response.getNotifications;\n }\n\n /**\n * Mark notification as read\n */\n public async markAsRead(notificationId: string): Promise<boolean> {\n logger.debug('[Notifications] Marking notification as read', { notificationId });\n\n const mutation = `\n mutation MarkNotificationAsRead($notificationId: ID!) {\n markNotificationAsRead(notificationId: $notificationId) {\n id\n status\n }\n }\n `;\n\n await this.client.query(mutation, { notificationId }, this.context);\n\n logger.info('[Notifications] Notification marked as read', { notificationId });\n\n return true;\n }\n\n /**\n * Mark multiple notifications as read\n */\n public async markMultipleAsRead(notificationIds: string[]): Promise<number> {\n logger.debug('[Notifications] Marking multiple notifications as read', {\n count: notificationIds.length,\n });\n\n const mutation = `\n mutation MarkNotificationsAsRead($notificationIds: [ID!]!) {\n markNotificationsAsRead(notificationIds: $notificationIds) {\n count\n }\n }\n `;\n\n const response = await this.client.query<{\n markNotificationsAsRead: { count: number };\n }>(mutation, { notificationIds }, this.context);\n\n logger.info('[Notifications] Notifications marked as read', {\n count: response.markNotificationsAsRead.count,\n });\n\n return response.markNotificationsAsRead.count;\n }\n\n /**\n * Mark all notifications as read for the current user\n */\n public async markAllAsRead(): Promise<number> {\n logger.debug('[Notifications] Marking all notifications as read');\n\n const mutation = `\n mutation MarkAllMyNotificationsAsRead {\n markAllMyNotificationsAsRead {\n count\n }\n }\n `;\n\n const response = await this.client.query<{\n markAllMyNotificationsAsRead: { count: number };\n }>(mutation, {}, this.context);\n\n logger.info('[Notifications] All notifications marked as read', {\n count: response.markAllMyNotificationsAsRead.count,\n });\n\n return response.markAllMyNotificationsAsRead.count;\n }\n\n /**\n * Delete notification\n */\n public async deleteNotification(notificationId: string): Promise<boolean> {\n logger.debug('[Notifications] Deleting notification', { notificationId });\n\n const mutation = `\n mutation DeleteNotification($notificationId: ID!) {\n deleteNotification(notificationId: $notificationId) {\n success\n }\n }\n `;\n\n await this.client.query(mutation, { notificationId }, this.context);\n\n logger.info('[Notifications] Notification deleted', { notificationId });\n\n return true;\n }\n\n /**\n * Delete multiple notifications\n */\n public async deleteMultiple(notificationIds: string[]): Promise<number> {\n logger.debug('[Notifications] Deleting multiple notifications', {\n count: notificationIds.length,\n });\n\n const mutation = `\n mutation DeleteNotifications($notificationIds: [ID!]!) {\n deleteNotifications(notificationIds: $notificationIds) {\n count\n }\n }\n `;\n\n const response = await this.client.query<{\n deleteNotifications: { count: number };\n }>(mutation, { notificationIds }, this.context);\n\n logger.info('[Notifications] Notifications deleted', {\n count: response.deleteNotifications.count,\n });\n\n return response.deleteNotifications.count;\n }\n\n /**\n * Get unread notification count for a user\n */\n public async getUnreadCount(userId: string): Promise<number> {\n const result = await this.getNotifications({\n userId,\n status: 'unread',\n limit: 0,\n });\n\n return result.unreadCount;\n }\n\n /**\n * Send notification via specific channel (EMAIL, SMS, WHATSAPP, etc.)\n * with optional in-app notification\n */\n public async sendChannelNotification(options: SendChannelNotificationOptions): Promise<NotificationResponse> {\n // Validate inputs\n if (!options.body || options.body.trim().length === 0) {\n throw new ValidationError('Notification body is required');\n }\n\n if (!options.recipient && !options.recipients) {\n throw new ValidationError('At least one recipient is required');\n }\n\n if (options.includeInApp && (!options.userIds || options.userIds.length === 0)) {\n throw new ValidationError('User IDs are required when includeInApp is true');\n }\n\n logger.info('[Notifications] Sending channel notification', {\n platform: options.platform,\n recipientCount: options.recipients ? options.recipients.length : 1,\n includeInApp: options.includeInApp,\n inAppUserCount: options.userIds ? options.userIds.length : 0,\n });\n\n const mutation = `\n mutation TriggerNotification($input: TriggerNotificationInput!) {\n triggerNotification(input: $input) {\n id\n status\n deliveryStatus\n }\n }\n `;\n\n const variables = {\n input: {\n platform: options.platform,\n channelId: options.channelId,\n includeInApp: options.includeInApp || false,\n userIds: options.userIds || [],\n notification: {\n subject: options.subject || '',\n body: options.body,\n htmlBody: options.htmlBody || '',\n channel: options.platform,\n type: options.type || NotificationType.INFO,\n recipient: options.recipient,\n appName: options.appName,\n redirectUrl: options.redirectUrl || '',\n metadata: options.metadata || {},\n trackOpens: options.trackOpens || false,\n trackClicks: options.trackClicks || false,\n expiresAt: options.expiresAt?.toISOString(),\n },\n },\n };\n\n // Handle bulk recipients\n if (options.recipients && options.recipients.length > 1) {\n const results = await Promise.allSettled(\n options.recipients.map((recipient) =>\n this.client.query(\n mutation,\n {\n input: {\n ...variables.input,\n notification: {\n ...variables.input.notification,\n recipient,\n },\n },\n },\n this.context\n )\n )\n );\n\n let successCount = 0;\n let failureCount = 0;\n const errors: string[] = [];\n const notificationIds: string[] = [];\n\n results.forEach((result, index) => {\n if (result.status === 'fulfilled') {\n successCount++;\n const response = result.value as { triggerNotification: { id: string } };\n notificationIds.push(response.triggerNotification.id);\n } else {\n failureCount++;\n errors.push(\n `Recipient ${index + 1}: ${result.reason instanceof Error ? result.reason.message : 'Unknown error'}`\n );\n }\n });\n\n const response: NotificationResponse = {\n successCount,\n failureCount,\n errors,\n notificationIds,\n };\n\n logger.info('[Notifications] Channel notification sent (bulk)', {\n successCount,\n failureCount,\n });\n\n return response;\n } else {\n // Single recipient\n try {\n const response = await this.client.query<{\n triggerNotification: { id: string; status: string; deliveryStatus: string };\n }>(mutation, variables, this.context);\n\n const result: NotificationResponse = {\n successCount: 1,\n failureCount: 0,\n errors: [],\n notificationIds: [response.triggerNotification.id],\n };\n\n logger.info('[Notifications] Channel notification sent', {\n notificationId: response.triggerNotification.id,\n status: response.triggerNotification.status,\n });\n\n return result;\n } catch (error) {\n logger.error('[Notifications] Failed to send channel notification', { error });\n\n return {\n successCount: 0,\n failureCount: 1,\n errors: [error instanceof Error ? error.message : 'Unknown error'],\n notificationIds: [],\n };\n }\n }\n }\n\n /**\n * Send notification using a template with optional in-app notification\n */\n public async sendTemplateNotification(options: SendTemplateNotificationOptions): Promise<NotificationResponse> {\n // Validate inputs\n if (!options.templateSlug || options.templateSlug.trim().length === 0) {\n throw new ValidationError('Template slug is required');\n }\n\n if (!options.variables || typeof options.variables !== 'object') {\n throw new ValidationError('Template variables are required');\n }\n\n if (!options.recipient && !options.recipients) {\n throw new ValidationError('At least one recipient is required');\n }\n\n if (options.includeInApp && (!options.userIds || options.userIds.length === 0)) {\n throw new ValidationError('User IDs are required when includeInApp is true');\n }\n\n logger.info('[Notifications] Sending template notification', {\n templateSlug: options.templateSlug,\n platform: options.platform,\n recipientCount: options.recipients ? options.recipients.length : 1,\n includeInApp: options.includeInApp,\n inAppUserCount: options.userIds ? options.userIds.length : 0,\n });\n\n const mutation = `\n mutation TriggerNotificationWithTemplate($input: TriggerNotificationWithTemplateInput!) {\n triggerNotificationWithTemplate(input: $input) {\n id\n status\n deliveryStatus\n }\n }\n `;\n\n const variables = {\n input: {\n platform: options.platform,\n channelId: options.channelId,\n includeInApp: options.includeInApp || false,\n userIds: options.userIds || [],\n templateSlug: options.templateSlug,\n variables: options.variables,\n recipient: options.recipient,\n recipients: options.recipients,\n trackOpens: options.trackOpens || false,\n trackClicks: options.trackClicks || false,\n expiresAt: options.expiresAt?.toISOString(),\n scheduledFor: options.scheduledFor?.toISOString(),\n timezone: options.timezone,\n },\n };\n\n try {\n const response = await this.client.query<{\n triggerNotificationWithTemplate: { id: string; status: string; deliveryStatus: string };\n }>(mutation, variables, this.context);\n\n const result: NotificationResponse = {\n successCount: 1,\n failureCount: 0,\n errors: [],\n notificationIds: [response.triggerNotificationWithTemplate.id],\n };\n\n logger.info('[Notifications] Template notification sent', {\n notificationId: response.triggerNotificationWithTemplate.id,\n status: response.triggerNotificationWithTemplate.status,\n });\n\n return result;\n } catch (error) {\n logger.error('[Notifications] Failed to send template notification', { error });\n\n return {\n successCount: 0,\n failureCount: 1,\n errors: [error instanceof Error ? error.message : 'Unknown error'],\n notificationIds: [],\n };\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDatabaseService, Logger } from './chunk-QLVKMWFA.js';
|
|
2
|
-
import { NatsConnectionManager } from './chunk-
|
|
2
|
+
import { NatsConnectionManager } from './chunk-VX35BOJP.js';
|
|
3
3
|
import { logger } from './chunk-CBZNP6RF.js';
|
|
4
4
|
import { __export, __name } from './chunk-XE4OXN2W.js';
|
|
5
5
|
import { StringCodec } from 'nats';
|
|
@@ -37,6 +37,9 @@ async function createNatsEventTarget(options) {
|
|
|
37
37
|
name: mergedConnectionOptions.name,
|
|
38
38
|
user: effectiveUser,
|
|
39
39
|
password: effectivePass,
|
|
40
|
+
token: mergedConnectionOptions.token ?? process.env["NATS_TOKEN"],
|
|
41
|
+
creds: mergedConnectionOptions.creds ?? process.env["NATS_CREDS"],
|
|
42
|
+
credsFile: mergedConnectionOptions.credsFile ?? process.env["NATS_CREDS_FILE"],
|
|
40
43
|
maxReconnectAttempts: mergedConnectionOptions.maxReconnectAttempts,
|
|
41
44
|
reconnectTimeWait: mergedConnectionOptions.reconnectTimeWait
|
|
42
45
|
};
|
|
@@ -265,5 +268,5 @@ async function createNatsEventTarget(options) {
|
|
|
265
268
|
__name(createNatsEventTarget, "createNatsEventTarget");
|
|
266
269
|
|
|
267
270
|
export { createNatsEventTarget, graphql_exports };
|
|
268
|
-
//# sourceMappingURL=chunk-
|
|
269
|
-
//# sourceMappingURL=chunk-
|
|
271
|
+
//# sourceMappingURL=chunk-KFPP47FP.js.map
|
|
272
|
+
//# sourceMappingURL=chunk-KFPP47FP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graphql/index.ts","../src/graphql/nats-event-target.ts"],"names":["createNatsEventTarget","options","natsUrl","connectionOptions","serializer","stringify","data","JSON","parse","message","subjectPrefix","sc","StringCodec","defaultConnectionOptions","name","maxReconnectAttempts","reconnectTimeWait","pingInterval","maxPingOut","timeout","mergedConnectionOptions","effectiveUser","user","process","env","effectivePass","pass","password","connectionConfig","type","url","Array","isArray","token","creds","credsFile","connectionManager","connection","NatsConnectionManager","connect","getNatsConnection","logger","info","error","Error","callbacks","Map","subscriptions","getSubject","eventType","subscribeToNats","has","subject","subscription","subscribe","set","debug","msg","messageData","decode","payload","eventCallbacks","get","size","event","CustomEvent","detail","callback","from","callbackError","messageError","subscriptionError","unsubscribeFromNats","unsubscribe","delete","eventTarget","addEventListener","listener","Set","add","listenerCount","removeEventListener","remainingListeners","dispatchEvent","encode","publish","serializeError","close","entries","clear","disconnect","isHealthy","isClosed"],"mappings":";;;;;;;AAAA,IAAA,eAAA,GAAA;;;;;;ACwPA,eAAsBA,sBAAsBC,OAAAA,EAA+B;AACzE,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IAAI;AACFnC,YAAAA,YAAAA,CAAaoB,WAAAA,EAAW;AACxBhC,YAAAA,MAAAA,CAAOe,MAAM,6CAAA,EAA+C;AAC1DP,cAAAA;aACF,CAAA;AACF,UAAA,CAAA,CAAA,OAASN,KAAAA,EAAO;AACdF,YAAAA,MAAAA,CAAOE,MAAM,oDAAA,EAAsD;AACjEM,cAAAA,SAAAA;cACAN,KAAAA,EAAOA,KAAAA,YAAiBC,KAAAA,GAAQD,KAAAA,CAAMlC,OAAAA,GAAU;aAClD,CAAA;AACF,UAAA;AACF,QAAA;AAGAsC,QAAAA,aAAAA,CAAc0C,KAAAA,EAAK;AACnB5C,QAAAA,SAAAA,CAAU4C,KAAAA,EAAK;AAGf,QAAA,MAAMrD,kBAAkBsD,UAAAA,EAAU;AAElCjD,QAAAA,MAAAA,CAAOC,KAAK,uDAAA,CAAA;AACd,MAAA,CAAA,CAAA,OAASC,KAAAA,EAAO;AACdF,QAAAA,MAAAA,CAAOE,MAAM,mDAAA,EAAqD;UAChEA,KAAAA,EAAOA,KAAAA,YAAiBC,KAAAA,GAAQD,KAAAA,CAAMlC,OAAAA,GAAU;SAClD,CAAA;AACA,QAAA,MAAMkC,KAAAA;AACR,MAAA;AACF,IAAA,CAAA;;;;IAKAgD,SAAAA,GAAAA;AACE,MAAA,OAAO,CAACtD,WAAWuD,QAAAA,EAAQ;AAC7B,IAAA;AACF,GAAA;AAEA,EAAA,OAAOjB,WAAAA;AACT;AA/VsB3E,MAAAA,CAAAA,qBAAAA,EAAAA,uBAAAA,CAAAA","file":"chunk-KFPP47FP.js","sourcesContent":["/**\n * GraphQL Utilities Module\n *\n * Provides GraphQL-related utilities for Burdenoff products.\n *\n * @module graphql\n */\n\nexport { createNatsEventTarget } from './nats-event-target.js';\nexport type { NatsEventTarget, NatsEventTargetOptions, MessageSerializer } from './nats-event-target.js';\n\n// Injectable services for GraphQL Modules\nexport { Logger, createDatabaseService } from './services/index.js';\nexport type { DatabaseService, PrismaTransactionClient } from './services/index.js';\n","/**\n * NATS-based EventTarget Implementation for GraphQL Yoga Distributed PubSub\n *\n * Provides NATS pub/sub infrastructure for GraphQL subscriptions across multiple server instances.\n * This enables horizontal scaling of GraphQL servers while maintaining real-time subscription functionality.\n *\n * Uses event queue abstraction's NatsConnectionManager for connection management\n * while maintaining Core NATS pub/sub for low-latency GraphQL subscriptions\n *\n * Architecture:\n * - Uses NATS Core NATS (not JetStream) for low-latency pub/sub\n * - Implements DOM EventTarget interface required by graphql-yoga's createPubSub\n * - Handles message serialization/deserialization with JSON (customizable)\n * - Manages NATS subscriptions and publishing lifecycle\n * - Includes error handling and reconnection logic\n *\n * Features:\n * - Automatic subscription management per event type\n * - Multiple listener support per event type\n * - Custom serialization support (e.g., SuperJSON for complex types)\n * - Graceful connection handling and cleanup\n * - TypeScript type safety\n *\n * @example\n * ```typescript\n * import { createNatsEventTarget } from '@burdenoff/be-sdk';\n * import { createPubSub } from 'graphql-yoga';\n *\n * const eventTarget = await createNatsEventTarget({\n * natsUrl: 'nats://localhost:4222',\n * });\n *\n * const pubsub = createPubSub({ eventTarget });\n * ```\n *\n * Reference Implementation:\n * Based on @graphql-yoga/redis-event-target pattern\n * https://github.com/graphql-hive/graphql-yoga/tree/main/packages/event-target/redis-event-target\n */\n\nimport type { NatsConnection, Subscription } from 'nats';\nimport { StringCodec } from 'nats';\nimport { logger } from '../logger/index.js';\nimport { NatsConnectionManager } from '../event-queue/implementations/nats/NatsConnection.js';\nimport type { BaseQueueConfig } from '../event-queue/types/config.js';\n\n/**\n * Message Serializer Interface\n *\n * Allows custom serialization for event payloads.\n * Useful for handling non-JSON-serializable data (Dates, BigInts, etc.)\n *\n * @example\n * ```typescript\n * import superjson from 'superjson';\n *\n * const eventTarget = await createNatsEventTarget({\n * natsUrl: 'nats://localhost:4222',\n * serializer: {\n * stringify: (data) => superjson.stringify(data),\n * parse: (message) => superjson.parse(message),\n * }\n * });\n * ```\n */\nexport interface MessageSerializer {\n /**\n * Serialize data to string for transmission over NATS\n */\n stringify: (data: unknown) => string | Promise<string>;\n\n /**\n * Deserialize string message from NATS back to original type\n */\n parse: (message: string) => unknown | Promise<unknown>;\n}\n\n/**\n * NATS EventTarget Options\n */\nexport interface NatsEventTargetOptions {\n /**\n * NATS server URL(s)\n * Examples:\n * - Single server: 'nats://localhost:4222'\n * - Multiple servers: ['nats://server1:4222', 'nats://server2:4222']\n * - With credentials: 'nats://user:password@localhost:4222'\n */\n natsUrl: string | string[];\n\n /**\n * Optional NATS connection options\n * See: https://github.com/nats-io/nats.js#connection-options\n */\n connectionOptions?: {\n /**\n * Connection name for debugging\n * @default 'graphql-pubsub'\n */\n name?: string;\n\n /**\n * Maximum reconnection attempts (-1 for infinite)\n * @default -1\n */\n maxReconnectAttempts?: number;\n\n /**\n * Time to wait between reconnection attempts (ms)\n * @default 2000\n */\n reconnectTimeWait?: number;\n\n /**\n * Ping interval (ms)\n * @default 20000\n */\n pingInterval?: number;\n\n /**\n * Maximum outstanding pings\n * @default 2\n */\n maxPingOut?: number;\n\n /**\n * Connection timeout (ms)\n * @default 20000\n */\n timeout?: number;\n\n /**\n * NATS credentials file contents (JWT + NKEY seed)\n */\n creds?: string;\n\n /**\n * Path to a NATS credentials file\n */\n credsFile?: string;\n };\n\n /**\n * Custom message serializer\n * Defaults to JSON.stringify/parse\n */\n serializer?: MessageSerializer;\n\n /**\n * Subject prefix for all GraphQL subscription topics\n * Useful for namespacing in multi-tenant or multi-app environments\n *\n * @default 'graphql.pubsub'\n *\n * Example: With prefix 'myapp.gql', a subscription to 'MESSAGE_ADDED'\n * will use NATS subject 'myapp.gql.MESSAGE_ADDED'\n */\n subjectPrefix?: string;\n}\n\n/**\n * Event Listener Type\n * Compatible with DOM EventListener interface\n */\ntype EventListener = (event: Event) => void;\n\n/**\n * NATS EventTarget Implementation\n *\n * Implements the EventTarget interface required by graphql-yoga's createPubSub.\n * Uses NATS Core NATS for pub/sub messaging across distributed GraphQL servers.\n */\nexport interface NatsEventTarget {\n /**\n * Subscribe to events of a specific type\n *\n * @param type - Event type (GraphQL subscription trigger)\n * @param listener - Callback function to invoke when event is received\n */\n addEventListener(type: string, listener: EventListener): void;\n\n /**\n * Unsubscribe from events of a specific type\n *\n * @param type - Event type (GraphQL subscription trigger)\n * @param listener - Callback function to remove\n */\n removeEventListener(type: string, listener: EventListener): void;\n\n /**\n * Publish an event to all subscribers\n *\n * @param event - Event to dispatch (must have 'type' and 'detail' properties)\n * @returns Always returns true (EventTarget interface requirement)\n */\n dispatchEvent(event: Event): boolean;\n\n /**\n * Close the NATS connection and cleanup resources\n * Should be called on application shutdown\n */\n close(): Promise<void>;\n\n /**\n * Check if the NATS connection is healthy\n */\n isHealthy(): boolean;\n}\n\n/**\n * Create NATS-based EventTarget for GraphQL Yoga Distributed PubSub\n *\n * This function creates an EventTarget implementation that uses NATS for\n * distributed publish-subscribe across multiple GraphQL server instances.\n *\n * @param options - NATS connection and configuration options\n * @returns Promise resolving to NatsEventTarget instance\n *\n * @example\n * ```typescript\n * // Basic usage\n * const eventTarget = await createNatsEventTarget({\n * natsUrl: 'nats://localhost:4222',\n * });\n *\n * const pubsub = createPubSub({ eventTarget });\n * ```\n *\n * @example\n * ```typescript\n * // With custom configuration\n * const eventTarget = await createNatsEventTarget({\n * natsUrl: ['nats://server1:4222', 'nats://server2:4222'],\n * connectionOptions: {\n * name: 'my-graphql-server',\n * maxReconnectAttempts: 10,\n * reconnectTimeWait: 1000,\n * },\n * subjectPrefix: 'myapp.graphql',\n * serializer: {\n * stringify: (data) => JSON.stringify(data),\n * parse: (msg) => JSON.parse(msg),\n * },\n * });\n * ```\n *\n * @throws {Error} If connection to NATS server fails\n */\nexport async function createNatsEventTarget(options: NatsEventTargetOptions): Promise<NatsEventTarget> {\n const {\n natsUrl,\n connectionOptions = {},\n serializer = {\n stringify: async (data: unknown): Promise<string> => JSON.stringify(data),\n parse: async (message: string): Promise<unknown> => JSON.parse(message),\n },\n subjectPrefix = 'graphql.pubsub',\n } = options;\n\n // NATS StringCodec for encoding/decoding messages\n const sc = StringCodec();\n\n // Default connection options\n const defaultConnectionOptions = {\n name: 'graphql-pubsub',\n maxReconnectAttempts: -1, // Infinite reconnects\n reconnectTimeWait: 2000, // 2 seconds\n pingInterval: 20000, // 20 seconds\n maxPingOut: 2,\n timeout: 20000, // 20 seconds\n };\n\n const mergedConnectionOptions = {\n ...defaultConnectionOptions,\n ...connectionOptions,\n };\n\n // Create connection manager config. Auth is sourced from\n // connectionOptions.user/pass first, then falls back to NATS_USER /\n // NATS_PASSWORD env vars. Required because the bun-bundled `nats`\n // 2.29.x client mis-parses URL-embedded credentials, so the URL must\n // be credential-free and auth must arrive as separate ConnectionOptions.\n const effectiveUser = (mergedConnectionOptions as { user?: string }).user ?? process.env['NATS_USER'];\n const effectivePass =\n (mergedConnectionOptions as { pass?: string; password?: string }).pass ??\n (mergedConnectionOptions as { pass?: string; password?: string }).password ??\n process.env['NATS_PASSWORD'];\n const connectionConfig: BaseQueueConfig = {\n type: 'nats',\n url: Array.isArray(natsUrl) ? (natsUrl[0] ?? 'nats://localhost:4222') : natsUrl,\n name: mergedConnectionOptions.name,\n user: effectiveUser,\n password: effectivePass,\n token: (mergedConnectionOptions as { token?: string }).token ?? process.env['NATS_TOKEN'],\n creds: (mergedConnectionOptions as { creds?: string }).creds ?? process.env['NATS_CREDS'],\n credsFile: (mergedConnectionOptions as { credsFile?: string }).credsFile ?? process.env['NATS_CREDS_FILE'],\n maxReconnectAttempts: mergedConnectionOptions.maxReconnectAttempts,\n reconnectTimeWait: mergedConnectionOptions.reconnectTimeWait,\n };\n\n // Connect to NATS using connection manager\n let connectionManager: NatsConnectionManager;\n let connection: NatsConnection;\n try {\n connectionManager = new NatsConnectionManager(connectionConfig);\n await connectionManager.connect();\n connection = connectionManager.getNatsConnection();\n\n logger.info('[NatsEventTarget] Connected to NATS', {\n url: connectionConfig.url,\n name: connectionConfig.name,\n });\n } catch (error) {\n logger.error('[NatsEventTarget] Failed to connect to NATS', {\n error: error instanceof Error ? error.message : 'Unknown error',\n url: connectionConfig.url,\n });\n throw error;\n }\n\n // Track callbacks per event type\n // Map<eventType, Set<listener>>\n const callbacks = new Map<string, Set<EventListener>>();\n\n // Track NATS subscriptions per event type\n // Map<eventType, Subscription>\n const subscriptions = new Map<string, Subscription>();\n\n /**\n * Get NATS subject for an event type\n * Prefixes the event type with the configured subject prefix\n */\n const getSubject = (eventType: string): string => {\n return `${subjectPrefix}.${eventType}`;\n };\n\n /**\n * Subscribe to NATS subject for an event type\n * Creates a new NATS subscription if one doesn't exist\n */\n const subscribeToNats = (eventType: string): void => {\n // Check if already subscribed\n if (subscriptions.has(eventType)) {\n return;\n }\n\n const subject = getSubject(eventType);\n\n try {\n // Create NATS subscription\n const subscription = connection.subscribe(subject);\n\n // Store subscription\n subscriptions.set(eventType, subscription);\n\n logger.debug('[NatsEventTarget] Subscribed to NATS subject', {\n eventType,\n subject,\n });\n\n // Process messages asynchronously\n void (async (): Promise<void> => {\n try {\n for await (const msg of subscription) {\n try {\n // Decode and deserialize message\n const messageData = sc.decode(msg.data);\n const payload = await serializer.parse(messageData);\n\n // Get callbacks for this event type\n const eventCallbacks = callbacks.get(eventType);\n\n if (eventCallbacks && eventCallbacks.size > 0) {\n // Create CustomEvent with payload\n const event = new CustomEvent(eventType, {\n detail: payload,\n });\n\n // Dispatch to all registered callbacks\n for (const callback of Array.from(eventCallbacks)) {\n try {\n callback(event);\n } catch (callbackError) {\n logger.error('[NatsEventTarget] Error in event callback', {\n eventType,\n error: callbackError instanceof Error ? callbackError.message : 'Unknown error',\n });\n }\n }\n }\n } catch (messageError) {\n logger.error('[NatsEventTarget] Error processing NATS message', {\n eventType,\n subject,\n error: messageError instanceof Error ? messageError.message : 'Unknown error',\n });\n }\n }\n } catch (subscriptionError) {\n logger.error('[NatsEventTarget] Error in NATS subscription loop', {\n eventType,\n subject,\n error: subscriptionError instanceof Error ? subscriptionError.message : 'Unknown error',\n });\n }\n })();\n } catch (error) {\n logger.error('[NatsEventTarget] Failed to subscribe to NATS subject', {\n eventType,\n subject,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n throw error;\n }\n };\n\n /**\n * Unsubscribe from NATS subject for an event type\n * Only unsubscribes if no more callbacks are registered\n */\n const unsubscribeFromNats = (eventType: string): void => {\n const subscription = subscriptions.get(eventType);\n\n if (subscription) {\n try {\n subscription.unsubscribe();\n subscriptions.delete(eventType);\n\n logger.debug('[NatsEventTarget] Unsubscribed from NATS subject', {\n eventType,\n subject: getSubject(eventType),\n });\n } catch (error) {\n logger.error('[NatsEventTarget] Failed to unsubscribe from NATS subject', {\n eventType,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n }\n }\n };\n\n /**\n * EventTarget Implementation\n */\n const eventTarget: NatsEventTarget = {\n /**\n * Add event listener (subscribe)\n */\n addEventListener(type: string, listener: EventListener): void {\n try {\n // Get or create callback set for this event type\n let eventCallbacks = callbacks.get(type);\n\n if (!eventCallbacks) {\n eventCallbacks = new Set();\n callbacks.set(type, eventCallbacks);\n\n // First listener for this event type - subscribe to NATS\n subscribeToNats(type);\n }\n\n // Add listener to set\n eventCallbacks.add(listener);\n\n logger.debug('[NatsEventTarget] Event listener added', {\n eventType: type,\n listenerCount: eventCallbacks.size,\n });\n } catch (error) {\n logger.error('[NatsEventTarget] Failed to add event listener', {\n eventType: type,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n throw error;\n }\n },\n\n /**\n * Remove event listener (unsubscribe)\n */\n removeEventListener(type: string, listener: EventListener): void {\n try {\n const eventCallbacks = callbacks.get(type);\n\n if (eventCallbacks) {\n // Remove listener from set\n eventCallbacks.delete(listener);\n\n const remainingListeners = eventCallbacks.size;\n\n logger.debug('[NatsEventTarget] Event listener removed', {\n eventType: type,\n remainingListeners,\n });\n\n // If no more listeners, unsubscribe from NATS and cleanup\n if (remainingListeners === 0) {\n callbacks.delete(type);\n unsubscribeFromNats(type);\n }\n }\n } catch (error) {\n logger.error('[NatsEventTarget] Failed to remove event listener', {\n eventType: type,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n throw error;\n }\n },\n\n /**\n * Dispatch event (publish)\n */\n dispatchEvent(event: Event): boolean {\n try {\n const eventType = event.type;\n const subject = getSubject(eventType);\n\n // Extract payload from CustomEvent detail or use event itself\n const payload = 'detail' in event ? (event as CustomEvent).detail : event;\n\n // Serialize payload (fire and forget for async serializers)\n void (async (): Promise<void> => {\n try {\n const message = await serializer.stringify(payload);\n\n // Encode and publish to NATS\n const data = sc.encode(message);\n connection.publish(subject, data);\n\n logger.debug('[NatsEventTarget] Event dispatched to NATS', {\n eventType,\n subject,\n });\n } catch (serializeError) {\n logger.error('[NatsEventTarget] Failed to serialize event for dispatch', {\n eventType,\n error: serializeError instanceof Error ? serializeError.message : 'Unknown error',\n });\n }\n })();\n\n return true;\n } catch (error) {\n logger.error('[NatsEventTarget] Failed to dispatch event', {\n eventType: event.type,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n throw error;\n }\n },\n\n /**\n * Close NATS connection and cleanup\n */\n async close(): Promise<void> {\n try {\n logger.info('[NatsEventTarget] Closing NATS connection...');\n\n // Unsubscribe from all subjects\n for (const [eventType, subscription] of Array.from(subscriptions.entries())) {\n try {\n subscription.unsubscribe();\n logger.debug('[NatsEventTarget] Unsubscribed from subject', {\n eventType,\n });\n } catch (error) {\n logger.error('[NatsEventTarget] Error unsubscribing from subject', {\n eventType,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n }\n }\n\n // Clear all subscriptions and callbacks\n subscriptions.clear();\n callbacks.clear();\n\n // Disconnect using connection manager\n await connectionManager.disconnect();\n\n logger.info('[NatsEventTarget] NATS connection closed successfully');\n } catch (error) {\n logger.error('[NatsEventTarget] Failed to close NATS connection', {\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n throw error;\n }\n },\n\n /**\n * Check if connection is healthy\n */\n isHealthy(): boolean {\n return !connection.isClosed();\n },\n };\n\n return eventTarget;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { resetGraphEventEmitter, getGraphEventEmitter, createMemoryPublisher, createGraphEventEmitter, createMemoryConsumer, createGraphEventEmitter2, NatsGraphEventEmitter, MemoryEventQueue, MemoryEventPublisher, MemoryEventConsumer, MemoryEventBus } from './chunk-
|
|
2
|
-
import { NatsEventPublisher, NatsEventConsumer, EventQueueFactory } from './chunk-
|
|
3
|
-
import { QueueType } from './chunk-
|
|
1
|
+
import { resetGraphEventEmitter, getGraphEventEmitter, createMemoryPublisher, createGraphEventEmitter, createMemoryConsumer, createGraphEventEmitter2, NatsGraphEventEmitter, MemoryEventQueue, MemoryEventPublisher, MemoryEventConsumer, MemoryEventBus } from './chunk-RUGNI7CR.js';
|
|
2
|
+
import { NatsEventPublisher, NatsEventConsumer, EventQueueFactory } from './chunk-YOLJ6ONY.js';
|
|
3
|
+
import { QueueType } from './chunk-VOFKF27Q.js';
|
|
4
4
|
import { logger } from './chunk-CBZNP6RF.js';
|
|
5
5
|
import { __export, __name } from './chunk-XE4OXN2W.js';
|
|
6
6
|
|
|
@@ -469,5 +469,5 @@ function createConsumer(stream, consumer) {
|
|
|
469
469
|
__name(createConsumer, "createConsumer");
|
|
470
470
|
|
|
471
471
|
export { EventPriority, EventsModule, ModuleEventsService, createConsumer, createModuleEventsService, createPublisher, event_queue_exports };
|
|
472
|
-
//# sourceMappingURL=chunk-
|
|
473
|
-
//# sourceMappingURL=chunk-
|
|
472
|
+
//# sourceMappingURL=chunk-QTSPQQWA.js.map
|
|
473
|
+
//# sourceMappingURL=chunk-QTSPQQWA.js.map
|