@burdenoff/be-sdk 2026.510.79

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.
Files changed (220) hide show
  1. package/README.md +173 -0
  2. package/configs/eslint/index.js +492 -0
  3. package/configs/tsconfig/tsconfig.json +53 -0
  4. package/dist/EventQueueFactory-6NMSGECR.js +8 -0
  5. package/dist/EventQueueFactory-6NMSGECR.js.map +1 -0
  6. package/dist/auth/index.d.ts +66 -0
  7. package/dist/auth/index.js +8 -0
  8. package/dist/auth/index.js.map +1 -0
  9. package/dist/cache/index.d.ts +2 -0
  10. package/dist/cache/index.js +6 -0
  11. package/dist/cache/index.js.map +1 -0
  12. package/dist/captcha/index.d.ts +1 -0
  13. package/dist/captcha/index.js +4 -0
  14. package/dist/captcha/index.js.map +1 -0
  15. package/dist/chunk-2HANKZZM.js +245 -0
  16. package/dist/chunk-2HANKZZM.js.map +1 -0
  17. package/dist/chunk-2SD5L2F2.js +816 -0
  18. package/dist/chunk-2SD5L2F2.js.map +1 -0
  19. package/dist/chunk-3O2RQOPV.js +1068 -0
  20. package/dist/chunk-3O2RQOPV.js.map +1 -0
  21. package/dist/chunk-4B43DZIS.js +560 -0
  22. package/dist/chunk-4B43DZIS.js.map +1 -0
  23. package/dist/chunk-4XAEES25.js +2444 -0
  24. package/dist/chunk-4XAEES25.js.map +1 -0
  25. package/dist/chunk-4XGGWW36.js +1405 -0
  26. package/dist/chunk-4XGGWW36.js.map +1 -0
  27. package/dist/chunk-5LXDPGDH.js +245 -0
  28. package/dist/chunk-5LXDPGDH.js.map +1 -0
  29. package/dist/chunk-AI7L22ZJ.js +472 -0
  30. package/dist/chunk-AI7L22ZJ.js.map +1 -0
  31. package/dist/chunk-CBZNP6RF.js +286 -0
  32. package/dist/chunk-CBZNP6RF.js.map +1 -0
  33. package/dist/chunk-ELLX3K54.js +613 -0
  34. package/dist/chunk-ELLX3K54.js.map +1 -0
  35. package/dist/chunk-F5XEAGHQ.js +1875 -0
  36. package/dist/chunk-F5XEAGHQ.js.map +1 -0
  37. package/dist/chunk-FNZEQOJY.js +628 -0
  38. package/dist/chunk-FNZEQOJY.js.map +1 -0
  39. package/dist/chunk-GTEMQXCA.js +516 -0
  40. package/dist/chunk-GTEMQXCA.js.map +1 -0
  41. package/dist/chunk-HIWTWIGQ.js +226 -0
  42. package/dist/chunk-HIWTWIGQ.js.map +1 -0
  43. package/dist/chunk-IYE2NTRX.js +764 -0
  44. package/dist/chunk-IYE2NTRX.js.map +1 -0
  45. package/dist/chunk-J26YGR2U.js +1484 -0
  46. package/dist/chunk-J26YGR2U.js.map +1 -0
  47. package/dist/chunk-JG2FTZPI.js +509 -0
  48. package/dist/chunk-JG2FTZPI.js.map +1 -0
  49. package/dist/chunk-JVBTNSPG.js +1551 -0
  50. package/dist/chunk-JVBTNSPG.js.map +1 -0
  51. package/dist/chunk-L7ZMN2FJ.js +12 -0
  52. package/dist/chunk-L7ZMN2FJ.js.map +1 -0
  53. package/dist/chunk-M5IMU3US.js +473 -0
  54. package/dist/chunk-M5IMU3US.js.map +1 -0
  55. package/dist/chunk-MLW2HPS5.js +1267 -0
  56. package/dist/chunk-MLW2HPS5.js.map +1 -0
  57. package/dist/chunk-MNCGUYLJ.js +269 -0
  58. package/dist/chunk-MNCGUYLJ.js.map +1 -0
  59. package/dist/chunk-MOCUBSTW.js +373 -0
  60. package/dist/chunk-MOCUBSTW.js.map +1 -0
  61. package/dist/chunk-NGMEI42S.js +103 -0
  62. package/dist/chunk-NGMEI42S.js.map +1 -0
  63. package/dist/chunk-NUB5GQTU.js +270 -0
  64. package/dist/chunk-NUB5GQTU.js.map +1 -0
  65. package/dist/chunk-OVSYMNCI.js +145 -0
  66. package/dist/chunk-OVSYMNCI.js.map +1 -0
  67. package/dist/chunk-QLVKMWFA.js +94 -0
  68. package/dist/chunk-QLVKMWFA.js.map +1 -0
  69. package/dist/chunk-SAG6ZYWQ.js +89 -0
  70. package/dist/chunk-SAG6ZYWQ.js.map +1 -0
  71. package/dist/chunk-SAK2JCA7.js +198 -0
  72. package/dist/chunk-SAK2JCA7.js.map +1 -0
  73. package/dist/chunk-SBS4S2PJ.js +100 -0
  74. package/dist/chunk-SBS4S2PJ.js.map +1 -0
  75. package/dist/chunk-SNEOLWXT.js +148 -0
  76. package/dist/chunk-SNEOLWXT.js.map +1 -0
  77. package/dist/chunk-TKBD2ONF.js +564 -0
  78. package/dist/chunk-TKBD2ONF.js.map +1 -0
  79. package/dist/chunk-UBXFIIAW.js +127 -0
  80. package/dist/chunk-UBXFIIAW.js.map +1 -0
  81. package/dist/chunk-VI4VSNTI.js +57 -0
  82. package/dist/chunk-VI4VSNTI.js.map +1 -0
  83. package/dist/chunk-VWCN5PMD.js +268 -0
  84. package/dist/chunk-VWCN5PMD.js.map +1 -0
  85. package/dist/chunk-XC2YD6CF.js +913 -0
  86. package/dist/chunk-XC2YD6CF.js.map +1 -0
  87. package/dist/chunk-XE4OXN2W.js +10 -0
  88. package/dist/chunk-XE4OXN2W.js.map +1 -0
  89. package/dist/chunk-YMZEUTD2.js +110 -0
  90. package/dist/chunk-YMZEUTD2.js.map +1 -0
  91. package/dist/chunk-Z4IRLBWO.js +758 -0
  92. package/dist/chunk-Z4IRLBWO.js.map +1 -0
  93. package/dist/client/internal-client.d.ts +7 -0
  94. package/dist/client/internal-client.js +5 -0
  95. package/dist/client/internal-client.js.map +1 -0
  96. package/dist/client-CSjIrYKS.d.ts +77 -0
  97. package/dist/config-UKE2E3BW.js +4 -0
  98. package/dist/config-UKE2E3BW.js.map +1 -0
  99. package/dist/crypto/index.d.ts +1 -0
  100. package/dist/crypto/index.js +4 -0
  101. package/dist/crypto/index.js.map +1 -0
  102. package/dist/database/index.d.ts +117 -0
  103. package/dist/database/index.js +7 -0
  104. package/dist/database/index.js.map +1 -0
  105. package/dist/dataloader/index.d.ts +1 -0
  106. package/dist/dataloader/index.js +4 -0
  107. package/dist/dataloader/index.js.map +1 -0
  108. package/dist/esm-K6H7EIWK.js +1450 -0
  109. package/dist/esm-K6H7EIWK.js.map +1 -0
  110. package/dist/event-queue/index.d.ts +6 -0
  111. package/dist/event-queue/index.js +10 -0
  112. package/dist/event-queue/index.js.map +1 -0
  113. package/dist/export/index.d.ts +2 -0
  114. package/dist/export/index.js +9 -0
  115. package/dist/export/index.js.map +1 -0
  116. package/dist/feature-flags/index.d.ts +1 -0
  117. package/dist/feature-flags/index.js +4 -0
  118. package/dist/feature-flags/index.js.map +1 -0
  119. package/dist/gateway/index.d.ts +4 -0
  120. package/dist/gateway/index.js +8 -0
  121. package/dist/gateway/index.js.map +1 -0
  122. package/dist/gateway/security/index.d.ts +2 -0
  123. package/dist/gateway/security/index.js +5 -0
  124. package/dist/gateway/security/index.js.map +1 -0
  125. package/dist/graph/index.d.ts +9 -0
  126. package/dist/graph/index.js +13 -0
  127. package/dist/graph/index.js.map +1 -0
  128. package/dist/graph-emitter-Bk0FqD53.d.ts +47 -0
  129. package/dist/graphql/index.d.ts +2 -0
  130. package/dist/graphql/index.js +7 -0
  131. package/dist/graphql/index.js.map +1 -0
  132. package/dist/graphql/services/index.d.ts +24 -0
  133. package/dist/graphql/services/index.js +5 -0
  134. package/dist/graphql/services/index.js.map +1 -0
  135. package/dist/graphql-BAVrUgBF.d.ts +22 -0
  136. package/dist/i18n/index.d.ts +2 -0
  137. package/dist/i18n/index.js +5 -0
  138. package/dist/i18n/index.js.map +1 -0
  139. package/dist/i18n-DA6IPnYy.d.ts +101 -0
  140. package/dist/index-4gKQKZ2B.d.ts +71 -0
  141. package/dist/index-B18rrFru.d.ts +42 -0
  142. package/dist/index-B70b5mYS.d.ts +33 -0
  143. package/dist/index-BMq3lFjj.d.ts +247 -0
  144. package/dist/index-BODgvRtL.d.ts +316 -0
  145. package/dist/index-BS2idbnr.d.ts +874 -0
  146. package/dist/index-BV3G48cH.d.ts +124 -0
  147. package/dist/index-CHbVw5M7.d.ts +73 -0
  148. package/dist/index-Cq_xNjcv.d.ts +602 -0
  149. package/dist/index-CrQgidpx.d.ts +77 -0
  150. package/dist/index-CyVEg86m.d.ts +309 -0
  151. package/dist/index-DOcBnmMe.d.ts +166 -0
  152. package/dist/index-DSOpj8DI.d.ts +17 -0
  153. package/dist/index-DW9q22GH.d.ts +75 -0
  154. package/dist/index-DlFDFyWD.d.ts +55 -0
  155. package/dist/index-DoK0bjhH.d.ts +607 -0
  156. package/dist/index-Dtf6FBaD.d.ts +199 -0
  157. package/dist/index-KVWGHMbS.d.ts +415 -0
  158. package/dist/index-PaojfSdd.d.ts +71 -0
  159. package/dist/index-RU_M5c74.d.ts +163 -0
  160. package/dist/index-UhkH2eaB.d.ts +192 -0
  161. package/dist/index-e_18DzAg.d.ts +18 -0
  162. package/dist/index-jOuh_TKn.d.ts +59 -0
  163. package/dist/index.d.ts +584 -0
  164. package/dist/index.js +2626 -0
  165. package/dist/index.js.map +1 -0
  166. package/dist/init/index.d.ts +2 -0
  167. package/dist/init/index.js +12 -0
  168. package/dist/init/index.js.map +1 -0
  169. package/dist/instrumentation/index.d.ts +3 -0
  170. package/dist/instrumentation/index.js +5 -0
  171. package/dist/instrumentation/index.js.map +1 -0
  172. package/dist/layer/index.d.ts +2 -0
  173. package/dist/layer/index.js +6 -0
  174. package/dist/layer/index.js.map +1 -0
  175. package/dist/layer-DDip18KY.d.ts +67 -0
  176. package/dist/logger/index.d.ts +2 -0
  177. package/dist/logger/index.js +4 -0
  178. package/dist/logger/index.js.map +1 -0
  179. package/dist/middleware/index.d.ts +3 -0
  180. package/dist/middleware/index.js +5 -0
  181. package/dist/middleware/index.js.map +1 -0
  182. package/dist/notifications/index.d.ts +4 -0
  183. package/dist/notifications/index.js +7 -0
  184. package/dist/notifications/index.js.map +1 -0
  185. package/dist/observability/index.d.ts +3 -0
  186. package/dist/observability/index.js +5 -0
  187. package/dist/observability/index.js.map +1 -0
  188. package/dist/pino-logger-RYLGXPHZ.js +5 -0
  189. package/dist/pino-logger-RYLGXPHZ.js.map +1 -0
  190. package/dist/prisma/generator/index.d.ts +1 -0
  191. package/dist/prisma/generator/index.js +228 -0
  192. package/dist/prisma/generator/index.js.map +1 -0
  193. package/dist/prisma/index.d.ts +5 -0
  194. package/dist/prisma/index.js +12 -0
  195. package/dist/prisma/index.js.map +1 -0
  196. package/dist/prisma-extension-krXnYnrN.d.ts +30 -0
  197. package/dist/rbac/index.d.ts +116 -0
  198. package/dist/rbac/index.js +7 -0
  199. package/dist/rbac/index.js.map +1 -0
  200. package/dist/sdk-THO3IWEE.js +136 -0
  201. package/dist/sdk-THO3IWEE.js.map +1 -0
  202. package/dist/server/index.d.ts +359 -0
  203. package/dist/server/index.js +884 -0
  204. package/dist/server/index.js.map +1 -0
  205. package/dist/telemetry/index.d.ts +83 -0
  206. package/dist/telemetry/index.js +209 -0
  207. package/dist/telemetry/index.js.map +1 -0
  208. package/dist/temporal/index.d.ts +148 -0
  209. package/dist/temporal/index.js +6 -0
  210. package/dist/temporal/index.js.map +1 -0
  211. package/dist/tracker/index.d.ts +5 -0
  212. package/dist/tracker/index.js +9 -0
  213. package/dist/tracker/index.js.map +1 -0
  214. package/dist/types-Bo2wkjSP.d.ts +35 -0
  215. package/dist/utils/index.d.ts +1 -0
  216. package/dist/utils/index.js +4 -0
  217. package/dist/utils/index.js.map +1 -0
  218. package/dist/workspace-guard-LHBNK4TG.js +5 -0
  219. package/dist/workspace-guard-LHBNK4TG.js.map +1 -0
  220. package/package.json +241 -0
@@ -0,0 +1,913 @@
1
+ import { ValidationError } from './chunk-SAG6ZYWQ.js';
2
+ import { logger } from './chunk-CBZNP6RF.js';
3
+ import { __export, __name } from './chunk-XE4OXN2W.js';
4
+
5
+ // src/notifications/tenant-notifications.ts
6
+ var tenant_notifications_exports = {};
7
+ __export(tenant_notifications_exports, {
8
+ NotificationChannel: () => NotificationChannel,
9
+ NotificationPriority: () => NotificationPriority,
10
+ NotificationType: () => NotificationType,
11
+ TenantNotificationsModule: () => TenantNotificationsModule
12
+ });
13
+ var NotificationChannel = /* @__PURE__ */ (function(NotificationChannel3) {
14
+ NotificationChannel3["EMAIL"] = "EMAIL";
15
+ NotificationChannel3["SMS"] = "SMS";
16
+ NotificationChannel3["PUSH"] = "PUSH";
17
+ NotificationChannel3["IN_APP"] = "IN_APP";
18
+ NotificationChannel3["WEBHOOK"] = "WEBHOOK";
19
+ NotificationChannel3["WHATSAPP"] = "WHATSAPP";
20
+ NotificationChannel3["TEAMS"] = "TEAMS";
21
+ NotificationChannel3["SLACK"] = "SLACK";
22
+ NotificationChannel3["TELEGRAM"] = "TELEGRAM";
23
+ NotificationChannel3["DISCORD"] = "DISCORD";
24
+ return NotificationChannel3;
25
+ })({});
26
+ var NotificationPriority = /* @__PURE__ */ (function(NotificationPriority2) {
27
+ NotificationPriority2["LOW"] = "LOW";
28
+ NotificationPriority2["MEDIUM"] = "MEDIUM";
29
+ NotificationPriority2["HIGH"] = "HIGH";
30
+ NotificationPriority2["URGENT"] = "URGENT";
31
+ return NotificationPriority2;
32
+ })({});
33
+ var NotificationType = /* @__PURE__ */ (function(NotificationType3) {
34
+ NotificationType3["TRANSACTIONAL"] = "TRANSACTIONAL";
35
+ NotificationType3["MARKETING"] = "MARKETING";
36
+ NotificationType3["SYSTEM"] = "SYSTEM";
37
+ NotificationType3["ALERT"] = "ALERT";
38
+ return NotificationType3;
39
+ })({});
40
+ var TenantNotificationsModule = class {
41
+ static {
42
+ __name(this, "TenantNotificationsModule");
43
+ }
44
+ client;
45
+ context;
46
+ constructor(client, context) {
47
+ this.client = client;
48
+ this.context = context;
49
+ }
50
+ /**
51
+ * Send a single notification
52
+ */
53
+ async send(input) {
54
+ this.validateSendInput(input);
55
+ logger.info("[TenantNotifications] Sending notification", {
56
+ channel: input.channel,
57
+ type: input.type || "TRANSACTIONAL",
58
+ priority: input.priority || "MEDIUM"
59
+ });
60
+ const mutation = `
61
+ mutation SendNotification($input: SendNotificationInput!) {
62
+ sendNotification(input: $input)
63
+ }
64
+ `;
65
+ const variables = {
66
+ input: {
67
+ recipient: input.recipient,
68
+ channel: input.channel,
69
+ type: input.type || "TRANSACTIONAL",
70
+ priority: input.priority || "MEDIUM",
71
+ subject: input.subject,
72
+ body: input.body,
73
+ htmlBody: input.htmlBody,
74
+ data: input.data,
75
+ metadata: input.metadata,
76
+ scheduledFor: input.scheduledFor?.toISOString(),
77
+ expiresAt: input.expiresAt?.toISOString(),
78
+ trackOpens: input.trackOpens,
79
+ trackClicks: input.trackClicks
80
+ }
81
+ };
82
+ const response = await this.client.tenantQuery(mutation, variables, this.context);
83
+ logger.info("[TenantNotifications] Notification sent", {
84
+ notificationId: response.sendNotification
85
+ });
86
+ return response.sendNotification;
87
+ }
88
+ /**
89
+ * Send notification using a template
90
+ */
91
+ async sendWithTemplate(input) {
92
+ if (!input.templateSlug || input.templateSlug.trim().length === 0) {
93
+ throw new ValidationError("Template slug is required");
94
+ }
95
+ if (!input.variables || Object.keys(input.variables).length === 0) {
96
+ throw new ValidationError("Template variables are required");
97
+ }
98
+ if (!input.recipient || !input.recipient.email && !input.recipient.userId) {
99
+ throw new ValidationError("Recipient email or userId is required");
100
+ }
101
+ logger.info("[TenantNotifications] Sending notification with template", {
102
+ templateSlug: input.templateSlug,
103
+ priority: input.priority || "MEDIUM"
104
+ });
105
+ const mutation = `
106
+ mutation TriggerNotificationWithTemplate($input: TriggerNotificationWithTemplateInput!) {
107
+ triggerNotificationWithTemplate(input: $input) {
108
+ id
109
+ status
110
+ deliveryStatus
111
+ }
112
+ }
113
+ `;
114
+ const variables = {
115
+ input: {
116
+ templateSlug: input.templateSlug,
117
+ variables: input.variables,
118
+ recipient: input.recipient,
119
+ priority: input.priority || "MEDIUM",
120
+ scheduledFor: input.scheduledFor?.toISOString(),
121
+ expiresAt: input.expiresAt?.toISOString(),
122
+ trackOpens: input.trackOpens,
123
+ trackClicks: input.trackClicks,
124
+ // Platform is required for notification delivery routing
125
+ // If channelId is specified, it takes precedence; otherwise platform determines delivery
126
+ channelId: input.channelId,
127
+ platform: input.platform || "EMAIL",
128
+ timezone: input.timezone
129
+ }
130
+ };
131
+ const response = await this.client.tenantQuery(mutation, variables, this.context);
132
+ logger.info("[TenantNotifications] Notification sent with template", {
133
+ notificationId: response.triggerNotificationWithTemplate.id,
134
+ status: response.triggerNotificationWithTemplate.status
135
+ });
136
+ return response.triggerNotificationWithTemplate.id;
137
+ }
138
+ /**
139
+ * Send batch notifications
140
+ */
141
+ async sendBatch(input) {
142
+ if (!input.notifications || input.notifications.length === 0) {
143
+ throw new ValidationError("At least one notification is required");
144
+ }
145
+ logger.info("[TenantNotifications] Sending batch notifications", {
146
+ count: input.notifications.length,
147
+ batchSize: input.batchSize
148
+ });
149
+ const mutation = `
150
+ mutation SendBatchNotifications($input: BatchNotificationInput!) {
151
+ sendBatchNotifications(input: $input) {
152
+ totalRequested
153
+ totalQueued
154
+ totalFailed
155
+ batchId
156
+ }
157
+ }
158
+ `;
159
+ const variables = {
160
+ input: {
161
+ notifications: input.notifications.map((n) => ({
162
+ recipient: n.recipient,
163
+ channel: n.channel,
164
+ type: n.type || "TRANSACTIONAL",
165
+ priority: n.priority || "MEDIUM",
166
+ subject: n.subject,
167
+ body: n.body,
168
+ htmlBody: n.htmlBody,
169
+ data: n.data,
170
+ metadata: n.metadata,
171
+ scheduledFor: n.scheduledFor?.toISOString(),
172
+ expiresAt: n.expiresAt?.toISOString(),
173
+ trackOpens: n.trackOpens,
174
+ trackClicks: n.trackClicks
175
+ })),
176
+ batchSize: input.batchSize,
177
+ delayBetweenBatches: input.delayBetweenBatches,
178
+ priority: input.priority
179
+ }
180
+ };
181
+ const response = await this.client.tenantQuery(mutation, variables, this.context);
182
+ logger.info("[TenantNotifications] Batch notifications sent", {
183
+ batchId: response.sendBatchNotifications.batchId,
184
+ queued: response.sendBatchNotifications.totalQueued,
185
+ failed: response.sendBatchNotifications.totalFailed
186
+ });
187
+ return response.sendBatchNotifications;
188
+ }
189
+ /**
190
+ * Get a notification by ID
191
+ */
192
+ async getNotification(id) {
193
+ const query = `
194
+ query GetNotification($id: ID!) {
195
+ notification(id: $id) {
196
+ id
197
+ userId
198
+ channel
199
+ type
200
+ priority
201
+ status
202
+ deliveryStatus
203
+ title
204
+ message
205
+ htmlMessage
206
+ subject
207
+ recipientEmail
208
+ recipientPhone
209
+ trackOpens
210
+ trackClicks
211
+ openedAt
212
+ clickedAt
213
+ sentAt
214
+ deliveredAt
215
+ createdAt
216
+ updatedAt
217
+ }
218
+ }
219
+ `;
220
+ const response = await this.client.tenantQuery(query, {
221
+ id
222
+ }, this.context);
223
+ return response.notification;
224
+ }
225
+ /**
226
+ * Get notifications with filters
227
+ */
228
+ async getNotifications(filter) {
229
+ const query = `
230
+ query GetNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {
231
+ notifications(filter: $filter, limit: $limit, offset: $offset) {
232
+ id
233
+ userId
234
+ channel
235
+ type
236
+ priority
237
+ status
238
+ deliveryStatus
239
+ title
240
+ message
241
+ subject
242
+ recipientEmail
243
+ trackOpens
244
+ trackClicks
245
+ openedAt
246
+ clickedAt
247
+ sentAt
248
+ deliveredAt
249
+ createdAt
250
+ updatedAt
251
+ }
252
+ }
253
+ `;
254
+ const variables = {
255
+ filter: filter ? {
256
+ userId: filter.userId,
257
+ channel: filter.channel,
258
+ type: filter.type,
259
+ status: filter.status,
260
+ priority: filter.priority,
261
+ startDate: filter.startDate?.toISOString(),
262
+ endDate: filter.endDate?.toISOString()
263
+ } : void 0,
264
+ limit: filter?.limit || 50,
265
+ offset: filter?.offset || 0
266
+ };
267
+ const response = await this.client.tenantQuery(query, variables, this.context);
268
+ return response.notifications;
269
+ }
270
+ /**
271
+ * Get notification template
272
+ */
273
+ async getTemplate(slug, locale) {
274
+ const query = `
275
+ query GetNotificationTemplate($slug: String!, $locale: String) {
276
+ notificationTemplate(slug: $slug, locale: $locale) {
277
+ id
278
+ name
279
+ slug
280
+ description
281
+ channel
282
+ type
283
+ locale
284
+ subject
285
+ bodyTemplate
286
+ htmlTemplate
287
+ variables
288
+ enabled
289
+ version
290
+ createdAt
291
+ updatedAt
292
+ }
293
+ }
294
+ `;
295
+ const response = await this.client.tenantQuery(query, {
296
+ slug,
297
+ locale
298
+ }, this.context);
299
+ return response.notificationTemplate;
300
+ }
301
+ /**
302
+ * Get all notification templates
303
+ */
304
+ async getTemplates(filter) {
305
+ const query = `
306
+ query GetNotificationTemplates($filter: TemplateFilterInput) {
307
+ notificationTemplates(filter: $filter) {
308
+ id
309
+ name
310
+ slug
311
+ description
312
+ channel
313
+ type
314
+ locale
315
+ subject
316
+ bodyTemplate
317
+ htmlTemplate
318
+ variables
319
+ enabled
320
+ version
321
+ createdAt
322
+ updatedAt
323
+ }
324
+ }
325
+ `;
326
+ const response = await this.client.tenantQuery(query, {
327
+ filter
328
+ }, this.context);
329
+ return response.notificationTemplates;
330
+ }
331
+ /**
332
+ * Get notification statistics
333
+ */
334
+ async getStats(filter) {
335
+ const query = `
336
+ query GetNotificationStats($filter: NotificationFilterInput) {
337
+ notificationStats(filter: $filter) {
338
+ total
339
+ pending
340
+ queued
341
+ processing
342
+ sent
343
+ delivered
344
+ failed
345
+ byChannel
346
+ byType
347
+ }
348
+ }
349
+ `;
350
+ const variables = {
351
+ filter: filter ? {
352
+ userId: filter.userId,
353
+ startDate: filter.startDate?.toISOString(),
354
+ endDate: filter.endDate?.toISOString()
355
+ } : void 0
356
+ };
357
+ const response = await this.client.tenantQuery(query, variables, this.context);
358
+ return response.notificationStats;
359
+ }
360
+ /**
361
+ * Mark notifications as read
362
+ */
363
+ async markAsRead(notificationIds) {
364
+ const mutation = `
365
+ mutation MarkNotificationsAsRead($notificationIds: [ID!]!) {
366
+ markNotificationsAsRead(notificationIds: $notificationIds)
367
+ }
368
+ `;
369
+ await this.client.tenantQuery(mutation, {
370
+ notificationIds
371
+ }, this.context);
372
+ logger.info("[TenantNotifications] Notifications marked as read", {
373
+ count: notificationIds.length
374
+ });
375
+ return true;
376
+ }
377
+ /**
378
+ * Mark all notifications as read for the current user
379
+ */
380
+ async markAllAsRead() {
381
+ const mutation = `
382
+ mutation MarkAllMyNotificationsAsRead {
383
+ markAllMyNotificationsAsRead
384
+ }
385
+ `;
386
+ await this.client.tenantQuery(mutation, {}, this.context);
387
+ logger.info("[TenantNotifications] All notifications marked as read");
388
+ return true;
389
+ }
390
+ /**
391
+ * Delete notifications
392
+ */
393
+ async deleteNotifications(notificationIds) {
394
+ const mutation = `
395
+ mutation DeleteNotifications($notificationIds: [ID!]!) {
396
+ deleteNotifications(notificationIds: $notificationIds)
397
+ }
398
+ `;
399
+ await this.client.tenantQuery(mutation, {
400
+ notificationIds
401
+ }, this.context);
402
+ logger.info("[TenantNotifications] Notifications deleted", {
403
+ count: notificationIds.length
404
+ });
405
+ return true;
406
+ }
407
+ /**
408
+ * Delete all read notifications for the current user
409
+ */
410
+ async deleteAllReadNotifications() {
411
+ const mutation = `
412
+ mutation DeleteMyReadNotifications {
413
+ deleteMyReadNotifications
414
+ }
415
+ `;
416
+ await this.client.tenantQuery(mutation, {}, this.context);
417
+ logger.info("[TenantNotifications] All read notifications deleted");
418
+ return true;
419
+ }
420
+ /**
421
+ * Validate send notification input
422
+ */
423
+ validateSendInput(input) {
424
+ if (!input.recipient || !input.recipient.email && !input.recipient.userId && !input.recipient.phoneNumber) {
425
+ throw new ValidationError("Recipient email, userId, or phoneNumber is required");
426
+ }
427
+ if (!input.channel) {
428
+ throw new ValidationError("Notification channel is required");
429
+ }
430
+ if (!input.body || input.body.trim().length === 0) {
431
+ throw new ValidationError("Notification body is required");
432
+ }
433
+ if (input.channel === "EMAIL" && !input.recipient.email) {
434
+ throw new ValidationError("Recipient email is required for EMAIL channel");
435
+ }
436
+ if (input.channel === "SMS" && !input.recipient.phoneNumber) {
437
+ throw new ValidationError("Recipient phone number is required for SMS channel");
438
+ }
439
+ if (input.channel === "PUSH" && !input.recipient.pushToken && !input.recipient.userId) {
440
+ throw new ValidationError("Recipient push token or userId is required for PUSH channel");
441
+ }
442
+ }
443
+ };
444
+
445
+ // src/notifications/index.ts
446
+ var NotificationType2 = /* @__PURE__ */ (function(NotificationType3) {
447
+ NotificationType3["INFO"] = "info";
448
+ NotificationType3["SUCCESS"] = "success";
449
+ NotificationType3["WARNING"] = "warning";
450
+ NotificationType3["ERROR"] = "error";
451
+ return NotificationType3;
452
+ })({});
453
+ var NotificationChannel2 = /* @__PURE__ */ (function(NotificationChannel3) {
454
+ NotificationChannel3["EMAIL"] = "EMAIL";
455
+ NotificationChannel3["SMS"] = "SMS";
456
+ NotificationChannel3["WHATSAPP"] = "WHATSAPP";
457
+ NotificationChannel3["PUSH"] = "PUSH";
458
+ NotificationChannel3["SLACK"] = "SLACK";
459
+ NotificationChannel3["TEAMS"] = "TEAMS";
460
+ NotificationChannel3["WEBHOOK"] = "WEBHOOK";
461
+ return NotificationChannel3;
462
+ })({});
463
+ var NotificationsModule = class {
464
+ static {
465
+ __name(this, "NotificationsModule");
466
+ }
467
+ client;
468
+ context;
469
+ constructor(client, context) {
470
+ this.client = client;
471
+ this.context = context;
472
+ }
473
+ /**
474
+ * Send notification to users
475
+ */
476
+ async send(options) {
477
+ if (!options.title || options.title.trim().length === 0) {
478
+ throw new ValidationError("Notification title is required");
479
+ }
480
+ if (!options.message || options.message.trim().length === 0) {
481
+ throw new ValidationError("Notification message is required");
482
+ }
483
+ if (!options.userIds || options.userIds.length === 0) {
484
+ throw new ValidationError("At least one user ID is required");
485
+ }
486
+ logger.info("[Notifications] Sending notification", {
487
+ title: options.title,
488
+ userCount: options.userIds.length,
489
+ type: options.type || "info"
490
+ });
491
+ const mutation = `
492
+ mutation CreateNotification($input: CreateNotificationInput!) {
493
+ createNotification(input: $input) {
494
+ successCount
495
+ failureCount
496
+ errors
497
+ notifications {
498
+ id
499
+ }
500
+ }
501
+ }
502
+ `;
503
+ const variables = {
504
+ input: {
505
+ title: options.title,
506
+ message: options.message,
507
+ type: options.type || "info",
508
+ userIds: options.userIds,
509
+ redirectUrl: options.redirectUrl || "",
510
+ appName: options.appName,
511
+ email: options.email || false,
512
+ sms: options.sms || false
513
+ }
514
+ };
515
+ const response = await this.client.query(mutation, variables, this.context);
516
+ const result = {
517
+ successCount: response.createNotification.successCount,
518
+ failureCount: response.createNotification.failureCount,
519
+ errors: response.createNotification.errors,
520
+ notificationIds: response.createNotification.notifications.map((n) => n.id)
521
+ };
522
+ logger.info("[Notifications] Notification sent", {
523
+ successCount: result.successCount,
524
+ failureCount: result.failureCount
525
+ });
526
+ return result;
527
+ }
528
+ /**
529
+ * Send notification to a single user (convenience method)
530
+ */
531
+ async sendToUser(userId, title, message, options) {
532
+ return this.send({
533
+ title,
534
+ message,
535
+ userIds: [
536
+ userId
537
+ ],
538
+ ...options
539
+ });
540
+ }
541
+ /**
542
+ * Get notifications for a user
543
+ */
544
+ async getNotifications(options) {
545
+ logger.debug("[Notifications] Getting notifications", {
546
+ userId: options.userId
547
+ });
548
+ const query = `
549
+ query GetNotifications(
550
+ $userId: ID!
551
+ $status: NotificationStatus
552
+ $type: NotificationType
553
+ $appName: String
554
+ $search: String
555
+ $limit: Int
556
+ $offset: Int
557
+ ) {
558
+ getNotifications(
559
+ userId: $userId
560
+ status: $status
561
+ type: $type
562
+ appName: $appName
563
+ search: $search
564
+ limit: $limit
565
+ offset: $offset
566
+ ) {
567
+ notifications {
568
+ id
569
+ userId
570
+ title
571
+ message
572
+ type
573
+ status
574
+ redirectUrl
575
+ appName
576
+ createdAt
577
+ updatedAt
578
+ }
579
+ total
580
+ unreadCount
581
+ }
582
+ }
583
+ `;
584
+ const variables = {
585
+ userId: options.userId,
586
+ status: options.status,
587
+ type: options.type,
588
+ appName: options.appName,
589
+ search: options.search,
590
+ limit: options.limit || 20,
591
+ offset: options.offset || 0
592
+ };
593
+ const response = await this.client.query(query, variables, this.context);
594
+ return response.getNotifications;
595
+ }
596
+ /**
597
+ * Mark notification as read
598
+ */
599
+ async markAsRead(notificationId) {
600
+ logger.debug("[Notifications] Marking notification as read", {
601
+ notificationId
602
+ });
603
+ const mutation = `
604
+ mutation MarkNotificationAsRead($notificationId: ID!) {
605
+ markNotificationAsRead(notificationId: $notificationId) {
606
+ id
607
+ status
608
+ }
609
+ }
610
+ `;
611
+ await this.client.query(mutation, {
612
+ notificationId
613
+ }, this.context);
614
+ logger.info("[Notifications] Notification marked as read", {
615
+ notificationId
616
+ });
617
+ return true;
618
+ }
619
+ /**
620
+ * Mark multiple notifications as read
621
+ */
622
+ async markMultipleAsRead(notificationIds) {
623
+ logger.debug("[Notifications] Marking multiple notifications as read", {
624
+ count: notificationIds.length
625
+ });
626
+ const mutation = `
627
+ mutation MarkNotificationsAsRead($notificationIds: [ID!]!) {
628
+ markNotificationsAsRead(notificationIds: $notificationIds) {
629
+ count
630
+ }
631
+ }
632
+ `;
633
+ const response = await this.client.query(mutation, {
634
+ notificationIds
635
+ }, this.context);
636
+ logger.info("[Notifications] Notifications marked as read", {
637
+ count: response.markNotificationsAsRead.count
638
+ });
639
+ return response.markNotificationsAsRead.count;
640
+ }
641
+ /**
642
+ * Mark all notifications as read for the current user
643
+ */
644
+ async markAllAsRead() {
645
+ logger.debug("[Notifications] Marking all notifications as read");
646
+ const mutation = `
647
+ mutation MarkAllMyNotificationsAsRead {
648
+ markAllMyNotificationsAsRead {
649
+ count
650
+ }
651
+ }
652
+ `;
653
+ const response = await this.client.query(mutation, {}, this.context);
654
+ logger.info("[Notifications] All notifications marked as read", {
655
+ count: response.markAllMyNotificationsAsRead.count
656
+ });
657
+ return response.markAllMyNotificationsAsRead.count;
658
+ }
659
+ /**
660
+ * Delete notification
661
+ */
662
+ async deleteNotification(notificationId) {
663
+ logger.debug("[Notifications] Deleting notification", {
664
+ notificationId
665
+ });
666
+ const mutation = `
667
+ mutation DeleteNotification($notificationId: ID!) {
668
+ deleteNotification(notificationId: $notificationId) {
669
+ success
670
+ }
671
+ }
672
+ `;
673
+ await this.client.query(mutation, {
674
+ notificationId
675
+ }, this.context);
676
+ logger.info("[Notifications] Notification deleted", {
677
+ notificationId
678
+ });
679
+ return true;
680
+ }
681
+ /**
682
+ * Delete multiple notifications
683
+ */
684
+ async deleteMultiple(notificationIds) {
685
+ logger.debug("[Notifications] Deleting multiple notifications", {
686
+ count: notificationIds.length
687
+ });
688
+ const mutation = `
689
+ mutation DeleteNotifications($notificationIds: [ID!]!) {
690
+ deleteNotifications(notificationIds: $notificationIds) {
691
+ count
692
+ }
693
+ }
694
+ `;
695
+ const response = await this.client.query(mutation, {
696
+ notificationIds
697
+ }, this.context);
698
+ logger.info("[Notifications] Notifications deleted", {
699
+ count: response.deleteNotifications.count
700
+ });
701
+ return response.deleteNotifications.count;
702
+ }
703
+ /**
704
+ * Get unread notification count for a user
705
+ */
706
+ async getUnreadCount(userId) {
707
+ const result = await this.getNotifications({
708
+ userId,
709
+ status: "unread",
710
+ limit: 0
711
+ });
712
+ return result.unreadCount;
713
+ }
714
+ /**
715
+ * Send notification via specific channel (EMAIL, SMS, WHATSAPP, etc.)
716
+ * with optional in-app notification
717
+ */
718
+ async sendChannelNotification(options) {
719
+ if (!options.body || options.body.trim().length === 0) {
720
+ throw new ValidationError("Notification body is required");
721
+ }
722
+ if (!options.recipient && !options.recipients) {
723
+ throw new ValidationError("At least one recipient is required");
724
+ }
725
+ if (options.includeInApp && (!options.userIds || options.userIds.length === 0)) {
726
+ throw new ValidationError("User IDs are required when includeInApp is true");
727
+ }
728
+ logger.info("[Notifications] Sending channel notification", {
729
+ platform: options.platform,
730
+ recipientCount: options.recipients ? options.recipients.length : 1,
731
+ includeInApp: options.includeInApp,
732
+ inAppUserCount: options.userIds ? options.userIds.length : 0
733
+ });
734
+ const mutation = `
735
+ mutation TriggerNotification($input: TriggerNotificationInput!) {
736
+ triggerNotification(input: $input) {
737
+ id
738
+ status
739
+ deliveryStatus
740
+ }
741
+ }
742
+ `;
743
+ const variables = {
744
+ input: {
745
+ platform: options.platform,
746
+ channelId: options.channelId,
747
+ includeInApp: options.includeInApp || false,
748
+ userIds: options.userIds || [],
749
+ notification: {
750
+ subject: options.subject || "",
751
+ body: options.body,
752
+ htmlBody: options.htmlBody || "",
753
+ channel: options.platform,
754
+ type: options.type || "info",
755
+ recipient: options.recipient,
756
+ appName: options.appName,
757
+ redirectUrl: options.redirectUrl || "",
758
+ metadata: options.metadata || {},
759
+ trackOpens: options.trackOpens || false,
760
+ trackClicks: options.trackClicks || false,
761
+ expiresAt: options.expiresAt?.toISOString()
762
+ }
763
+ }
764
+ };
765
+ if (options.recipients && options.recipients.length > 1) {
766
+ const results = await Promise.allSettled(options.recipients.map((recipient) => this.client.query(mutation, {
767
+ input: {
768
+ ...variables.input,
769
+ notification: {
770
+ ...variables.input.notification,
771
+ recipient
772
+ }
773
+ }
774
+ }, this.context)));
775
+ let successCount = 0;
776
+ let failureCount = 0;
777
+ const errors = [];
778
+ const notificationIds = [];
779
+ results.forEach((result, index) => {
780
+ if (result.status === "fulfilled") {
781
+ successCount++;
782
+ const response2 = result.value;
783
+ notificationIds.push(response2.triggerNotification.id);
784
+ } else {
785
+ failureCount++;
786
+ errors.push(`Recipient ${index + 1}: ${result.reason instanceof Error ? result.reason.message : "Unknown error"}`);
787
+ }
788
+ });
789
+ const response = {
790
+ successCount,
791
+ failureCount,
792
+ errors,
793
+ notificationIds
794
+ };
795
+ logger.info("[Notifications] Channel notification sent (bulk)", {
796
+ successCount,
797
+ failureCount
798
+ });
799
+ return response;
800
+ } else {
801
+ try {
802
+ const response = await this.client.query(mutation, variables, this.context);
803
+ const result = {
804
+ successCount: 1,
805
+ failureCount: 0,
806
+ errors: [],
807
+ notificationIds: [
808
+ response.triggerNotification.id
809
+ ]
810
+ };
811
+ logger.info("[Notifications] Channel notification sent", {
812
+ notificationId: response.triggerNotification.id,
813
+ status: response.triggerNotification.status
814
+ });
815
+ return result;
816
+ } catch (error) {
817
+ logger.error("[Notifications] Failed to send channel notification", {
818
+ error
819
+ });
820
+ return {
821
+ successCount: 0,
822
+ failureCount: 1,
823
+ errors: [
824
+ error instanceof Error ? error.message : "Unknown error"
825
+ ],
826
+ notificationIds: []
827
+ };
828
+ }
829
+ }
830
+ }
831
+ /**
832
+ * Send notification using a template with optional in-app notification
833
+ */
834
+ async sendTemplateNotification(options) {
835
+ if (!options.templateSlug || options.templateSlug.trim().length === 0) {
836
+ throw new ValidationError("Template slug is required");
837
+ }
838
+ if (!options.variables || typeof options.variables !== "object") {
839
+ throw new ValidationError("Template variables are required");
840
+ }
841
+ if (!options.recipient && !options.recipients) {
842
+ throw new ValidationError("At least one recipient is required");
843
+ }
844
+ if (options.includeInApp && (!options.userIds || options.userIds.length === 0)) {
845
+ throw new ValidationError("User IDs are required when includeInApp is true");
846
+ }
847
+ logger.info("[Notifications] Sending template notification", {
848
+ templateSlug: options.templateSlug,
849
+ platform: options.platform,
850
+ recipientCount: options.recipients ? options.recipients.length : 1,
851
+ includeInApp: options.includeInApp,
852
+ inAppUserCount: options.userIds ? options.userIds.length : 0
853
+ });
854
+ const mutation = `
855
+ mutation TriggerNotificationWithTemplate($input: TriggerNotificationWithTemplateInput!) {
856
+ triggerNotificationWithTemplate(input: $input) {
857
+ id
858
+ status
859
+ deliveryStatus
860
+ }
861
+ }
862
+ `;
863
+ const variables = {
864
+ input: {
865
+ platform: options.platform,
866
+ channelId: options.channelId,
867
+ includeInApp: options.includeInApp || false,
868
+ userIds: options.userIds || [],
869
+ templateSlug: options.templateSlug,
870
+ variables: options.variables,
871
+ recipient: options.recipient,
872
+ recipients: options.recipients,
873
+ trackOpens: options.trackOpens || false,
874
+ trackClicks: options.trackClicks || false,
875
+ expiresAt: options.expiresAt?.toISOString(),
876
+ scheduledFor: options.scheduledFor?.toISOString(),
877
+ timezone: options.timezone
878
+ }
879
+ };
880
+ try {
881
+ const response = await this.client.query(mutation, variables, this.context);
882
+ const result = {
883
+ successCount: 1,
884
+ failureCount: 0,
885
+ errors: [],
886
+ notificationIds: [
887
+ response.triggerNotificationWithTemplate.id
888
+ ]
889
+ };
890
+ logger.info("[Notifications] Template notification sent", {
891
+ notificationId: response.triggerNotificationWithTemplate.id,
892
+ status: response.triggerNotificationWithTemplate.status
893
+ });
894
+ return result;
895
+ } catch (error) {
896
+ logger.error("[Notifications] Failed to send template notification", {
897
+ error
898
+ });
899
+ return {
900
+ successCount: 0,
901
+ failureCount: 1,
902
+ errors: [
903
+ error instanceof Error ? error.message : "Unknown error"
904
+ ],
905
+ notificationIds: []
906
+ };
907
+ }
908
+ }
909
+ };
910
+
911
+ export { NotificationChannel2 as NotificationChannel, NotificationPriority, NotificationType2 as NotificationType, NotificationsModule, TenantNotificationsModule, tenant_notifications_exports };
912
+ //# sourceMappingURL=chunk-XC2YD6CF.js.map
913
+ //# sourceMappingURL=chunk-XC2YD6CF.js.map