@novu/js 3.11.0 → 3.11.2-nightly.20251224.eb609546a3

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 (36) hide show
  1. package/dist/cjs/{chunk-QQNKEWGC.js → chunk-C6V4UPCA.js} +1338 -1241
  2. package/dist/cjs/chunk-CDGREQFE.js +799 -0
  3. package/dist/cjs/index.d.ts +4 -4
  4. package/dist/cjs/index.js +38 -26
  5. package/dist/cjs/internal/index.d.ts +14 -2
  6. package/dist/cjs/internal/index.js +12 -4
  7. package/dist/cjs/novu-DxuaDf-Z.d.ts +192 -0
  8. package/dist/{esm/novu-DY-mm8Og.d.mts → cjs/novu-event-emitter-BOA_6GfJ.d.ts} +413 -162
  9. package/dist/cjs/themes/index.d.ts +11 -5
  10. package/dist/cjs/themes/index.js +17 -1
  11. package/dist/cjs/types-Buzm23uF.d.ts +836 -0
  12. package/dist/cjs/ui/index.d.ts +74 -7
  13. package/dist/cjs/ui/index.js +1836 -261
  14. package/dist/esm/{chunk-UM35OVAD.mjs → chunk-NF4ANB6D.mjs} +1308 -1207
  15. package/dist/esm/chunk-SWKDFXVR.mjs +770 -0
  16. package/dist/esm/index.d.mts +4 -4
  17. package/dist/esm/index.mjs +2 -2
  18. package/dist/esm/internal/index.d.mts +14 -2
  19. package/dist/esm/internal/index.mjs +1 -1
  20. package/dist/esm/novu-DY8vwRGE.d.mts +192 -0
  21. package/dist/{cjs/novu-ThMWeiRt.d.ts → esm/novu-event-emitter-BOA_6GfJ.d.mts} +413 -162
  22. package/dist/esm/themes/index.d.mts +11 -5
  23. package/dist/esm/themes/index.mjs +16 -2
  24. package/dist/esm/types-xBjzv9ok.d.mts +836 -0
  25. package/dist/esm/ui/index.d.mts +74 -7
  26. package/dist/esm/ui/index.mjs +1833 -257
  27. package/dist/index.css +1 -1
  28. package/dist/novu.min.js +12 -12
  29. package/dist/novu.min.js.gz +0 -0
  30. package/package.json +18 -17
  31. package/dist/cjs/chunk-VWSQDNZX.js +0 -66
  32. package/dist/cjs/types-BM_9Xx5Z.d.ts +0 -220
  33. package/dist/cjs/types-BjANCN3c.d.ts +0 -537
  34. package/dist/esm/chunk-RZWQYM3H.mjs +0 -62
  35. package/dist/esm/types-BM_9Xx5Z.d.mts +0 -220
  36. package/dist/esm/types-C5eX1GmB.d.mts +0 -537
@@ -0,0 +1,770 @@
1
+ import { __async, __spreadProps, __spreadValues, __privateAdd, __privateSet, __privateGet } from './chunk-STZMOEWR.mjs';
2
+
3
+ // src/ui/internal/buildContextKey.ts
4
+ function buildContextKey(context) {
5
+ if (!context) {
6
+ return "";
7
+ }
8
+ const keys = [];
9
+ for (const [type, value] of Object.entries(context)) {
10
+ if (value) {
11
+ const id = typeof value === "string" ? value : value.id;
12
+ keys.push(`${type}:${id}`);
13
+ }
14
+ }
15
+ return keys.sort().join(",");
16
+ }
17
+
18
+ // src/ui/internal/buildSubscriber.ts
19
+ function buildSubscriber({
20
+ subscriberId,
21
+ subscriber
22
+ }) {
23
+ if (subscriber) {
24
+ return typeof subscriber === "string" ? { subscriberId: subscriber } : subscriber;
25
+ }
26
+ if (subscriberId) {
27
+ return { subscriberId };
28
+ }
29
+ return { subscriberId: "" };
30
+ }
31
+
32
+ // src/ui/internal/buildSubscriptionIdentifier.ts
33
+ function buildSubscriptionIdentifier({ topicKey, subscriberId }) {
34
+ return `tk_${topicKey}:si_${subscriberId}`;
35
+ }
36
+
37
+ // src/types.ts
38
+ var NotificationStatus = /* @__PURE__ */ ((NotificationStatus2) => {
39
+ NotificationStatus2["READ"] = "read";
40
+ NotificationStatus2["SEEN"] = "seen";
41
+ NotificationStatus2["SNOOZED"] = "snoozed";
42
+ NotificationStatus2["UNREAD"] = "unread";
43
+ NotificationStatus2["UNSEEN"] = "unseen";
44
+ NotificationStatus2["UNSNOOZED"] = "unsnoozed";
45
+ return NotificationStatus2;
46
+ })(NotificationStatus || {});
47
+ var PreferenceLevel = /* @__PURE__ */ ((PreferenceLevel2) => {
48
+ PreferenceLevel2["GLOBAL"] = "global";
49
+ PreferenceLevel2["TEMPLATE"] = "template";
50
+ return PreferenceLevel2;
51
+ })(PreferenceLevel || {});
52
+ var ChannelType = /* @__PURE__ */ ((ChannelType2) => {
53
+ ChannelType2["IN_APP"] = "in_app";
54
+ ChannelType2["EMAIL"] = "email";
55
+ ChannelType2["SMS"] = "sms";
56
+ ChannelType2["CHAT"] = "chat";
57
+ ChannelType2["PUSH"] = "push";
58
+ return ChannelType2;
59
+ })(ChannelType || {});
60
+ var WebSocketEvent = /* @__PURE__ */ ((WebSocketEvent2) => {
61
+ WebSocketEvent2["RECEIVED"] = "notification_received";
62
+ WebSocketEvent2["UNREAD"] = "unread_count_changed";
63
+ WebSocketEvent2["UNSEEN"] = "unseen_count_changed";
64
+ return WebSocketEvent2;
65
+ })(WebSocketEvent || {});
66
+ var SeverityLevelEnum = /* @__PURE__ */ ((SeverityLevelEnum2) => {
67
+ SeverityLevelEnum2["HIGH"] = "high";
68
+ SeverityLevelEnum2["MEDIUM"] = "medium";
69
+ SeverityLevelEnum2["LOW"] = "low";
70
+ SeverityLevelEnum2["NONE"] = "none";
71
+ return SeverityLevelEnum2;
72
+ })(SeverityLevelEnum || {});
73
+ var WorkflowCriticalityEnum = /* @__PURE__ */ ((WorkflowCriticalityEnum2) => {
74
+ WorkflowCriticalityEnum2["CRITICAL"] = "critical";
75
+ WorkflowCriticalityEnum2["NON_CRITICAL"] = "nonCritical";
76
+ WorkflowCriticalityEnum2["ALL"] = "all";
77
+ return WorkflowCriticalityEnum2;
78
+ })(WorkflowCriticalityEnum || {});
79
+
80
+ // src/utils/errors.ts
81
+ var NovuError = class extends Error {
82
+ constructor(message, originalError) {
83
+ super(message);
84
+ this.originalError = originalError;
85
+ }
86
+ };
87
+
88
+ // src/notifications/helpers.ts
89
+ var read = (_0) => __async(void 0, [_0], function* ({
90
+ emitter,
91
+ apiService,
92
+ args
93
+ }) {
94
+ const { notificationId, optimisticValue } = getNotificationDetails(
95
+ args,
96
+ {
97
+ isRead: true,
98
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
99
+ isArchived: false,
100
+ archivedAt: void 0
101
+ },
102
+ {
103
+ emitter,
104
+ apiService
105
+ }
106
+ );
107
+ try {
108
+ emitter.emit("notification.read.pending", {
109
+ args,
110
+ data: optimisticValue
111
+ });
112
+ const response = yield apiService.read(notificationId);
113
+ const updatedNotification = new Notification(response, emitter, apiService);
114
+ emitter.emit("notification.read.resolved", { args, data: updatedNotification });
115
+ return { data: updatedNotification };
116
+ } catch (error) {
117
+ emitter.emit("notification.read.resolved", { args, error });
118
+ return { error: new NovuError("Failed to read notification", error) };
119
+ }
120
+ });
121
+ var unread = (_0) => __async(void 0, [_0], function* ({
122
+ emitter,
123
+ apiService,
124
+ args
125
+ }) {
126
+ const { notificationId, optimisticValue } = getNotificationDetails(
127
+ args,
128
+ {
129
+ isRead: false,
130
+ readAt: null,
131
+ isArchived: false,
132
+ archivedAt: void 0
133
+ },
134
+ {
135
+ emitter,
136
+ apiService
137
+ }
138
+ );
139
+ try {
140
+ emitter.emit("notification.unread.pending", {
141
+ args,
142
+ data: optimisticValue
143
+ });
144
+ const response = yield apiService.unread(notificationId);
145
+ const updatedNotification = new Notification(response, emitter, apiService);
146
+ emitter.emit("notification.unread.resolved", { args, data: updatedNotification });
147
+ return { data: updatedNotification };
148
+ } catch (error) {
149
+ emitter.emit("notification.unread.resolved", { args, error });
150
+ return { error: new NovuError("Failed to unread notification", error) };
151
+ }
152
+ });
153
+ var seen = (_0) => __async(void 0, [_0], function* ({
154
+ emitter,
155
+ apiService,
156
+ args
157
+ }) {
158
+ const { notificationId, optimisticValue } = getNotificationDetails(
159
+ args,
160
+ {
161
+ isSeen: true
162
+ },
163
+ {
164
+ emitter,
165
+ apiService
166
+ }
167
+ );
168
+ try {
169
+ emitter.emit("notification.seen.pending", {
170
+ args,
171
+ data: optimisticValue
172
+ });
173
+ yield apiService.seen(notificationId);
174
+ if (!optimisticValue) {
175
+ throw new Error("Failed to create optimistic value for notification");
176
+ }
177
+ const updatedNotification = new Notification(optimisticValue, emitter, apiService);
178
+ emitter.emit("notification.seen.resolved", { args, data: updatedNotification });
179
+ return { data: updatedNotification };
180
+ } catch (error) {
181
+ emitter.emit("notification.seen.resolved", { args, error });
182
+ return { error: new NovuError("Failed to mark notification as seen", error) };
183
+ }
184
+ });
185
+ var archive = (_0) => __async(void 0, [_0], function* ({
186
+ emitter,
187
+ apiService,
188
+ args
189
+ }) {
190
+ const { notificationId, optimisticValue } = getNotificationDetails(
191
+ args,
192
+ {
193
+ isArchived: true,
194
+ archivedAt: (/* @__PURE__ */ new Date()).toISOString(),
195
+ isRead: true,
196
+ readAt: (/* @__PURE__ */ new Date()).toISOString()
197
+ },
198
+ {
199
+ emitter,
200
+ apiService
201
+ }
202
+ );
203
+ try {
204
+ emitter.emit("notification.archive.pending", {
205
+ args,
206
+ data: optimisticValue
207
+ });
208
+ const response = yield apiService.archive(notificationId);
209
+ const updatedNotification = new Notification(response, emitter, apiService);
210
+ emitter.emit("notification.archive.resolved", { args, data: updatedNotification });
211
+ return { data: updatedNotification };
212
+ } catch (error) {
213
+ emitter.emit("notification.archive.resolved", { args, error });
214
+ return { error: new NovuError("Failed to archive notification", error) };
215
+ }
216
+ });
217
+ var unarchive = (_0) => __async(void 0, [_0], function* ({
218
+ emitter,
219
+ apiService,
220
+ args
221
+ }) {
222
+ const { notificationId, optimisticValue } = getNotificationDetails(
223
+ args,
224
+ {
225
+ isArchived: false,
226
+ archivedAt: null,
227
+ isRead: true,
228
+ readAt: (/* @__PURE__ */ new Date()).toISOString()
229
+ },
230
+ {
231
+ emitter,
232
+ apiService
233
+ }
234
+ );
235
+ try {
236
+ emitter.emit("notification.unarchive.pending", {
237
+ args,
238
+ data: optimisticValue
239
+ });
240
+ const response = yield apiService.unarchive(notificationId);
241
+ const updatedNotification = new Notification(response, emitter, apiService);
242
+ emitter.emit("notification.unarchive.resolved", { args, data: updatedNotification });
243
+ return { data: updatedNotification };
244
+ } catch (error) {
245
+ emitter.emit("notification.unarchive.resolved", { args, error });
246
+ return { error: new NovuError("Failed to unarchive notification", error) };
247
+ }
248
+ });
249
+ var snooze = (_0) => __async(void 0, [_0], function* ({
250
+ emitter,
251
+ apiService,
252
+ args
253
+ }) {
254
+ const { notificationId, optimisticValue } = getNotificationDetails(
255
+ args,
256
+ {
257
+ isSnoozed: true,
258
+ snoozedUntil: args.snoozeUntil
259
+ },
260
+ {
261
+ emitter,
262
+ apiService
263
+ }
264
+ );
265
+ try {
266
+ emitter.emit("notification.snooze.pending", {
267
+ args,
268
+ data: optimisticValue
269
+ });
270
+ const response = yield apiService.snooze(notificationId, args.snoozeUntil);
271
+ const updatedNotification = new Notification(response, emitter, apiService);
272
+ emitter.emit("notification.snooze.resolved", { args, data: updatedNotification });
273
+ return { data: updatedNotification };
274
+ } catch (error) {
275
+ emitter.emit("notification.snooze.resolved", { args, error });
276
+ return { error: new NovuError("Failed to snooze notification", error) };
277
+ }
278
+ });
279
+ var unsnooze = (_0) => __async(void 0, [_0], function* ({
280
+ emitter,
281
+ apiService,
282
+ args
283
+ }) {
284
+ const { notificationId, optimisticValue } = getNotificationDetails(
285
+ args,
286
+ {
287
+ isSnoozed: false,
288
+ snoozedUntil: null
289
+ },
290
+ {
291
+ emitter,
292
+ apiService
293
+ }
294
+ );
295
+ try {
296
+ emitter.emit("notification.unsnooze.pending", {
297
+ args,
298
+ data: optimisticValue
299
+ });
300
+ const response = yield apiService.unsnooze(notificationId);
301
+ const updatedNotification = new Notification(response, emitter, apiService);
302
+ emitter.emit("notification.unsnooze.resolved", { args, data: updatedNotification });
303
+ return { data: updatedNotification };
304
+ } catch (error) {
305
+ emitter.emit("notification.unsnooze.resolved", { args, error });
306
+ return { error: new NovuError("Failed to unsnooze notification", error) };
307
+ }
308
+ });
309
+ var completeAction = (_0) => __async(void 0, [_0], function* ({
310
+ emitter,
311
+ apiService,
312
+ args,
313
+ actionType
314
+ }) {
315
+ const optimisticUpdate = actionType === "primary" /* PRIMARY */ ? {
316
+ primaryAction: __spreadProps(__spreadValues({}, "notification" in args ? args.notification.primaryAction : {}), {
317
+ isCompleted: true
318
+ })
319
+ } : {
320
+ secondaryAction: __spreadProps(__spreadValues({}, "notification" in args ? args.notification.secondaryAction : {}), {
321
+ isCompleted: true
322
+ })
323
+ };
324
+ const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate, {
325
+ emitter,
326
+ apiService
327
+ });
328
+ try {
329
+ emitter.emit("notification.complete_action.pending", {
330
+ args,
331
+ data: optimisticValue
332
+ });
333
+ const response = yield apiService.completeAction({ actionType, notificationId });
334
+ const updatedNotification = new Notification(response, emitter, apiService);
335
+ emitter.emit("notification.complete_action.resolved", { args, data: updatedNotification });
336
+ return { data: updatedNotification };
337
+ } catch (error) {
338
+ emitter.emit("notification.complete_action.resolved", { args, error });
339
+ return { error: new NovuError(`Failed to complete ${actionType} action on the notification`, error) };
340
+ }
341
+ });
342
+ var revertAction = (_0) => __async(void 0, [_0], function* ({
343
+ emitter,
344
+ apiService,
345
+ args,
346
+ actionType
347
+ }) {
348
+ const optimisticUpdate = actionType === "primary" /* PRIMARY */ ? {
349
+ primaryAction: __spreadProps(__spreadValues({}, "notification" in args ? args.notification.primaryAction : {}), {
350
+ isCompleted: false
351
+ })
352
+ } : {
353
+ secondaryAction: __spreadProps(__spreadValues({}, "notification" in args ? args.notification.secondaryAction : {}), {
354
+ isCompleted: false
355
+ })
356
+ };
357
+ const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate, {
358
+ emitter,
359
+ apiService
360
+ });
361
+ try {
362
+ emitter.emit("notification.revert_action.pending", {
363
+ args,
364
+ data: optimisticValue
365
+ });
366
+ const response = yield apiService.revertAction({ actionType, notificationId });
367
+ const updatedNotification = new Notification(response, emitter, apiService);
368
+ emitter.emit("notification.revert_action.resolved", { args, data: updatedNotification });
369
+ return { data: updatedNotification };
370
+ } catch (error) {
371
+ emitter.emit("notification.revert_action.resolved", { args, error });
372
+ return { error: new NovuError("Failed to fetch notifications", error) };
373
+ }
374
+ });
375
+ var getNotificationDetails = (args, update, dependencies) => {
376
+ if ("notification" in args) {
377
+ return {
378
+ notificationId: args.notification.id,
379
+ optimisticValue: new Notification(
380
+ __spreadValues(__spreadValues({}, args.notification), update),
381
+ dependencies.emitter,
382
+ dependencies.apiService
383
+ )
384
+ };
385
+ } else {
386
+ return {
387
+ notificationId: args.notificationId
388
+ };
389
+ }
390
+ };
391
+ var readAll = (_0) => __async(void 0, [_0], function* ({
392
+ emitter,
393
+ inboxService,
394
+ notificationsCache,
395
+ tags,
396
+ data
397
+ }) {
398
+ try {
399
+ const notifications = notificationsCache.getUniqueNotifications({ tags, data });
400
+ const optimisticNotifications = notifications.map(
401
+ (notification) => new Notification(
402
+ __spreadProps(__spreadValues({}, notification), {
403
+ isRead: true,
404
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
405
+ isArchived: false,
406
+ archivedAt: void 0
407
+ }),
408
+ emitter,
409
+ inboxService
410
+ )
411
+ );
412
+ emitter.emit("notifications.read_all.pending", { args: { tags, data }, data: optimisticNotifications });
413
+ yield inboxService.readAll({ tags, data });
414
+ emitter.emit("notifications.read_all.resolved", { args: { tags, data }, data: optimisticNotifications });
415
+ return {};
416
+ } catch (error) {
417
+ emitter.emit("notifications.read_all.resolved", { args: { tags, data }, error });
418
+ return { error: new NovuError("Failed to read all notifications", error) };
419
+ }
420
+ });
421
+ var seenAll = (_0) => __async(void 0, [_0], function* ({
422
+ emitter,
423
+ inboxService,
424
+ notificationsCache,
425
+ notificationIds,
426
+ tags,
427
+ data
428
+ }) {
429
+ try {
430
+ const notifications = notificationsCache.getUniqueNotifications({ tags, data });
431
+ const filteredNotifications = notificationIds && notificationIds.length > 0 ? notifications.filter((notification) => notificationIds.includes(notification.id)) : notifications;
432
+ const optimisticNotifications = filteredNotifications.map(
433
+ (notification) => new Notification(
434
+ __spreadProps(__spreadValues({}, notification), {
435
+ isSeen: true,
436
+ firstSeenAt: notification.firstSeenAt || (/* @__PURE__ */ new Date()).toISOString()
437
+ }),
438
+ emitter,
439
+ inboxService
440
+ )
441
+ );
442
+ emitter.emit("notifications.seen_all.pending", {
443
+ args: { notificationIds, tags, data },
444
+ data: optimisticNotifications
445
+ });
446
+ yield inboxService.markAsSeen({ notificationIds, tags, data });
447
+ emitter.emit("notifications.seen_all.resolved", {
448
+ args: { notificationIds, tags, data },
449
+ data: optimisticNotifications
450
+ });
451
+ return {};
452
+ } catch (error) {
453
+ emitter.emit("notifications.seen_all.resolved", { args: { notificationIds, tags, data }, error });
454
+ return { error: new NovuError("Failed to mark all notifications as seen", error) };
455
+ }
456
+ });
457
+ var archiveAll = (_0) => __async(void 0, [_0], function* ({
458
+ emitter,
459
+ inboxService,
460
+ notificationsCache,
461
+ tags,
462
+ data
463
+ }) {
464
+ try {
465
+ const notifications = notificationsCache.getUniqueNotifications({ tags, data });
466
+ const optimisticNotifications = notifications.map(
467
+ (notification) => new Notification(
468
+ __spreadProps(__spreadValues({}, notification), {
469
+ isRead: true,
470
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
471
+ isArchived: true,
472
+ archivedAt: (/* @__PURE__ */ new Date()).toISOString()
473
+ }),
474
+ emitter,
475
+ inboxService
476
+ )
477
+ );
478
+ emitter.emit("notifications.archive_all.pending", { args: { tags, data }, data: optimisticNotifications });
479
+ yield inboxService.archiveAll({ tags, data });
480
+ emitter.emit("notifications.archive_all.resolved", { args: { tags, data }, data: optimisticNotifications });
481
+ return {};
482
+ } catch (error) {
483
+ emitter.emit("notifications.archive_all.resolved", { args: { tags, data }, error });
484
+ return { error: new NovuError("Failed to archive all notifications", error) };
485
+ }
486
+ });
487
+ var archiveAllRead = (_0) => __async(void 0, [_0], function* ({
488
+ emitter,
489
+ inboxService,
490
+ notificationsCache,
491
+ tags,
492
+ data
493
+ }) {
494
+ try {
495
+ const notifications = notificationsCache.getUniqueNotifications({ tags, data, read: true });
496
+ const optimisticNotifications = notifications.map(
497
+ (notification) => new Notification(
498
+ __spreadProps(__spreadValues({}, notification), { isArchived: true, archivedAt: (/* @__PURE__ */ new Date()).toISOString() }),
499
+ emitter,
500
+ inboxService
501
+ )
502
+ );
503
+ emitter.emit("notifications.archive_all_read.pending", { args: { tags, data }, data: optimisticNotifications });
504
+ yield inboxService.archiveAllRead({ tags, data });
505
+ emitter.emit("notifications.archive_all_read.resolved", { args: { tags, data }, data: optimisticNotifications });
506
+ return {};
507
+ } catch (error) {
508
+ emitter.emit("notifications.archive_all_read.resolved", { args: { tags, data }, error });
509
+ return { error: new NovuError("Failed to archive all read notifications", error) };
510
+ }
511
+ });
512
+ var deleteNotification = (_0) => __async(void 0, [_0], function* ({
513
+ emitter,
514
+ apiService,
515
+ args
516
+ }) {
517
+ const { notificationId } = getNotificationDetails(
518
+ args,
519
+ {},
520
+ {
521
+ emitter,
522
+ apiService
523
+ }
524
+ );
525
+ try {
526
+ emitter.emit("notification.delete.pending", {
527
+ args
528
+ });
529
+ yield apiService.delete(notificationId);
530
+ emitter.emit("notification.delete.resolved", { args });
531
+ return {};
532
+ } catch (error) {
533
+ emitter.emit("notification.delete.resolved", { args, error });
534
+ return { error: new NovuError("Failed to delete notification", error) };
535
+ }
536
+ });
537
+ var deleteAll = (_0) => __async(void 0, [_0], function* ({
538
+ emitter,
539
+ inboxService,
540
+ notificationsCache,
541
+ tags,
542
+ data
543
+ }) {
544
+ try {
545
+ const notifications = notificationsCache.getUniqueNotifications({ tags, data });
546
+ emitter.emit("notifications.delete_all.pending", { args: { tags, data }, data: notifications });
547
+ yield inboxService.deleteAll({ tags, data });
548
+ emitter.emit("notifications.delete_all.resolved", { args: { tags, data } });
549
+ return {};
550
+ } catch (error) {
551
+ emitter.emit("notifications.delete_all.resolved", { args: { tags, data }, error });
552
+ return { error: new NovuError("Failed to delete all notifications", error) };
553
+ }
554
+ });
555
+
556
+ // src/notifications/notification.ts
557
+ var _emitter, _inboxService;
558
+ var Notification = class {
559
+ constructor(notification, emitter, inboxService) {
560
+ __privateAdd(this, _emitter);
561
+ __privateAdd(this, _inboxService);
562
+ __privateSet(this, _emitter, emitter);
563
+ __privateSet(this, _inboxService, inboxService);
564
+ this.id = notification.id;
565
+ this.transactionId = notification.transactionId;
566
+ this.subject = notification.subject;
567
+ this.body = notification.body;
568
+ this.to = notification.to;
569
+ this.isRead = notification.isRead;
570
+ this.isSeen = notification.isSeen;
571
+ this.isArchived = notification.isArchived;
572
+ this.isSnoozed = notification.isSnoozed;
573
+ this.snoozedUntil = notification.snoozedUntil;
574
+ this.deliveredAt = notification.deliveredAt;
575
+ this.createdAt = notification.createdAt;
576
+ this.readAt = notification.readAt;
577
+ this.firstSeenAt = notification.firstSeenAt;
578
+ this.archivedAt = notification.archivedAt;
579
+ this.avatar = notification.avatar;
580
+ this.primaryAction = notification.primaryAction;
581
+ this.secondaryAction = notification.secondaryAction;
582
+ this.channelType = notification.channelType;
583
+ this.tags = notification.tags;
584
+ this.redirect = notification.redirect;
585
+ this.data = notification.data;
586
+ this.workflow = notification.workflow;
587
+ this.severity = notification.severity;
588
+ }
589
+ read() {
590
+ return read({
591
+ emitter: __privateGet(this, _emitter),
592
+ apiService: __privateGet(this, _inboxService),
593
+ args: {
594
+ notification: this
595
+ }
596
+ });
597
+ }
598
+ unread() {
599
+ return unread({
600
+ emitter: __privateGet(this, _emitter),
601
+ apiService: __privateGet(this, _inboxService),
602
+ args: {
603
+ notification: this
604
+ }
605
+ });
606
+ }
607
+ seen() {
608
+ return seen({
609
+ emitter: __privateGet(this, _emitter),
610
+ apiService: __privateGet(this, _inboxService),
611
+ args: {
612
+ notification: this
613
+ }
614
+ });
615
+ }
616
+ archive() {
617
+ return archive({
618
+ emitter: __privateGet(this, _emitter),
619
+ apiService: __privateGet(this, _inboxService),
620
+ args: {
621
+ notification: this
622
+ }
623
+ });
624
+ }
625
+ unarchive() {
626
+ return unarchive({
627
+ emitter: __privateGet(this, _emitter),
628
+ apiService: __privateGet(this, _inboxService),
629
+ args: {
630
+ notification: this
631
+ }
632
+ });
633
+ }
634
+ delete() {
635
+ return deleteNotification({
636
+ emitter: __privateGet(this, _emitter),
637
+ apiService: __privateGet(this, _inboxService),
638
+ args: {
639
+ notification: this
640
+ }
641
+ });
642
+ }
643
+ snooze(snoozeUntil) {
644
+ return snooze({
645
+ emitter: __privateGet(this, _emitter),
646
+ apiService: __privateGet(this, _inboxService),
647
+ args: {
648
+ notification: this,
649
+ snoozeUntil
650
+ }
651
+ });
652
+ }
653
+ unsnooze() {
654
+ return unsnooze({
655
+ emitter: __privateGet(this, _emitter),
656
+ apiService: __privateGet(this, _inboxService),
657
+ args: { notification: this }
658
+ });
659
+ }
660
+ completePrimary() {
661
+ if (!this.primaryAction) {
662
+ throw new Error("Primary action is not available");
663
+ }
664
+ return completeAction({
665
+ emitter: __privateGet(this, _emitter),
666
+ apiService: __privateGet(this, _inboxService),
667
+ args: {
668
+ notification: this
669
+ },
670
+ actionType: "primary" /* PRIMARY */
671
+ });
672
+ }
673
+ completeSecondary() {
674
+ if (!this.primaryAction) {
675
+ throw new Error("Secondary action is not available");
676
+ }
677
+ return completeAction({
678
+ emitter: __privateGet(this, _emitter),
679
+ apiService: __privateGet(this, _inboxService),
680
+ args: {
681
+ notification: this
682
+ },
683
+ actionType: "secondary" /* SECONDARY */
684
+ });
685
+ }
686
+ revertPrimary() {
687
+ if (!this.primaryAction) {
688
+ throw new Error("Primary action is not available");
689
+ }
690
+ return revertAction({
691
+ emitter: __privateGet(this, _emitter),
692
+ apiService: __privateGet(this, _inboxService),
693
+ args: {
694
+ notification: this
695
+ },
696
+ actionType: "primary" /* PRIMARY */
697
+ });
698
+ }
699
+ revertSecondary() {
700
+ if (!this.primaryAction) {
701
+ throw new Error("Secondary action is not available");
702
+ }
703
+ return revertAction({
704
+ emitter: __privateGet(this, _emitter),
705
+ apiService: __privateGet(this, _inboxService),
706
+ args: {
707
+ notification: this
708
+ },
709
+ actionType: "secondary" /* SECONDARY */
710
+ });
711
+ }
712
+ on(eventName, listener) {
713
+ const cleanup = __privateGet(this, _emitter).on(eventName, listener);
714
+ return () => {
715
+ cleanup();
716
+ };
717
+ }
718
+ /**
719
+ * @deprecated
720
+ * Use the cleanup function returned by the "on" method instead.
721
+ */
722
+ off(eventName, listener) {
723
+ __privateGet(this, _emitter).off(eventName, listener);
724
+ }
725
+ };
726
+ _emitter = new WeakMap();
727
+ _inboxService = new WeakMap();
728
+
729
+ // src/ui/internal/createNotification.ts
730
+ function createNotification({
731
+ emitter,
732
+ inboxService,
733
+ notification
734
+ }) {
735
+ return new Notification(notification, emitter, inboxService);
736
+ }
737
+
738
+ // src/ui/internal/parseMarkdown.tsx
739
+ var parseMarkdownIntoTokens = (text) => {
740
+ const tokens = [];
741
+ let buffer = "";
742
+ let inBold = false;
743
+ for (let i = 0; i < text.length; i += 1) {
744
+ if (text[i] === "\\" && text[i + 1] === "*") {
745
+ buffer += "*";
746
+ i += 1;
747
+ } else if (text[i] === "*" && text[i + 1] === "*") {
748
+ if (buffer) {
749
+ tokens.push({
750
+ type: inBold ? "bold" : "text",
751
+ content: buffer
752
+ });
753
+ buffer = "";
754
+ }
755
+ inBold = !inBold;
756
+ i += 1;
757
+ } else {
758
+ buffer += text[i];
759
+ }
760
+ }
761
+ if (buffer) {
762
+ tokens.push({
763
+ type: inBold ? "bold" : "text",
764
+ content: buffer
765
+ });
766
+ }
767
+ return tokens;
768
+ };
769
+
770
+ export { ChannelType, Notification, NotificationStatus, NovuError, PreferenceLevel, SeverityLevelEnum, WebSocketEvent, WorkflowCriticalityEnum, archive, archiveAll, archiveAllRead, buildContextKey, buildSubscriber, buildSubscriptionIdentifier, completeAction, createNotification, deleteAll, deleteNotification, parseMarkdownIntoTokens, read, readAll, revertAction, seen, seenAll, snooze, unarchive, unread, unsnooze };