@novu/js 3.17.0 → 3.18.0
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/cjs/{chunk-7B52C2XE.js → chunk-A6CBLMST.js} +9 -0
- package/dist/cjs/{chunk-SP44ETLM.js → chunk-NR4RSYUE.js} +772 -694
- package/dist/cjs/{chunk-WDGG3OER.js → chunk-TLQQB5Y7.js} +217 -199
- package/dist/{esm/inbox-service-CGCuuYnv.d.mts → cjs/inbox-service-DSSwFYNG.d.ts} +18 -2
- package/dist/cjs/index.d.ts +93 -4
- package/dist/cjs/index.js +246 -20
- package/dist/cjs/internal/index.d.ts +1 -1
- package/dist/cjs/internal/index.js +7 -7
- package/dist/cjs/{novu-CmNBco-0.d.ts → novu-BQCC3vQS.d.ts} +3 -2
- package/dist/cjs/themes/index.d.ts +3 -3
- package/dist/cjs/themes/index.js +1 -1
- package/dist/cjs/{types-BF6zvyj6.d.ts → types-Djf8MaW9.d.ts} +2 -2
- package/dist/cjs/ui/index.d.ts +18 -6
- package/dist/cjs/ui/index.js +609 -243
- package/dist/esm/{chunk-BKA3HRZM.mjs → chunk-33B2GJE2.mjs} +140 -64
- package/dist/esm/{chunk-STZMOEWR.mjs → chunk-3LR3AF54.mjs} +9 -1
- package/dist/esm/{chunk-4S22IB5W.mjs → chunk-T3NTOGY3.mjs} +193 -176
- package/dist/{cjs/inbox-service-CGCuuYnv.d.ts → esm/inbox-service-DSSwFYNG.d.mts} +18 -2
- package/dist/esm/index.d.mts +93 -4
- package/dist/esm/index.mjs +228 -3
- package/dist/esm/internal/index.d.mts +1 -1
- package/dist/esm/internal/index.mjs +2 -2
- package/dist/esm/{novu-CFYEiYN8.d.mts → novu-Z0z0-IxO.d.mts} +3 -2
- package/dist/esm/themes/index.d.mts +3 -3
- package/dist/esm/themes/index.mjs +1 -1
- package/dist/esm/{types-CJKmgwu6.d.mts → types-BJ345m1Q.d.mts} +2 -2
- package/dist/esm/ui/index.d.mts +18 -6
- package/dist/esm/ui/index.mjs +424 -58
- package/dist/novu.min.js +15 -15
- package/dist/novu.min.js.gz +0 -0
- package/package.json +7 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkA6CBLMST_js = require('./chunk-A6CBLMST.js');
|
|
4
4
|
|
|
5
5
|
// src/ui/internal/buildContextKey.ts
|
|
6
6
|
function buildContextKey(context) {
|
|
@@ -95,8 +95,194 @@ var NovuError = class extends Error {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
+
// src/notifications/notification.ts
|
|
99
|
+
var _emitter, _inboxService;
|
|
100
|
+
var Notification = class {
|
|
101
|
+
constructor(notification, emitter, inboxService) {
|
|
102
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter);
|
|
103
|
+
chunkA6CBLMST_js.__privateAdd(this, _inboxService);
|
|
104
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter, emitter);
|
|
105
|
+
chunkA6CBLMST_js.__privateSet(this, _inboxService, inboxService);
|
|
106
|
+
this.id = notification.id;
|
|
107
|
+
this.transactionId = notification.transactionId;
|
|
108
|
+
this.subject = notification.subject;
|
|
109
|
+
this.body = notification.body;
|
|
110
|
+
this.to = notification.to;
|
|
111
|
+
this.isRead = notification.isRead;
|
|
112
|
+
this.isSeen = notification.isSeen;
|
|
113
|
+
this.isArchived = notification.isArchived;
|
|
114
|
+
this.isSnoozed = notification.isSnoozed;
|
|
115
|
+
this.snoozedUntil = notification.snoozedUntil;
|
|
116
|
+
this.deliveredAt = notification.deliveredAt;
|
|
117
|
+
this.createdAt = notification.createdAt;
|
|
118
|
+
this.readAt = notification.readAt;
|
|
119
|
+
this.firstSeenAt = notification.firstSeenAt;
|
|
120
|
+
this.archivedAt = notification.archivedAt;
|
|
121
|
+
this.avatar = notification.avatar;
|
|
122
|
+
this.primaryAction = notification.primaryAction;
|
|
123
|
+
this.secondaryAction = notification.secondaryAction;
|
|
124
|
+
this.channelType = notification.channelType;
|
|
125
|
+
this.tags = notification.tags;
|
|
126
|
+
this.redirect = notification.redirect;
|
|
127
|
+
this.data = notification.data;
|
|
128
|
+
this.workflow = notification.workflow;
|
|
129
|
+
this.severity = notification.severity;
|
|
130
|
+
}
|
|
131
|
+
read() {
|
|
132
|
+
return read({
|
|
133
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
134
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
135
|
+
args: {
|
|
136
|
+
notification: this
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
unread() {
|
|
141
|
+
return unread({
|
|
142
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
143
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
144
|
+
args: {
|
|
145
|
+
notification: this
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
seen() {
|
|
150
|
+
return seen({
|
|
151
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
152
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
153
|
+
args: {
|
|
154
|
+
notification: this
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
archive() {
|
|
159
|
+
return archive({
|
|
160
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
161
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
162
|
+
args: {
|
|
163
|
+
notification: this
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
unarchive() {
|
|
168
|
+
return unarchive({
|
|
169
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
170
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
171
|
+
args: {
|
|
172
|
+
notification: this
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
delete() {
|
|
177
|
+
return deleteNotification({
|
|
178
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
179
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
180
|
+
args: {
|
|
181
|
+
notification: this
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
snooze(snoozeUntil) {
|
|
186
|
+
return snooze({
|
|
187
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
188
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
189
|
+
args: {
|
|
190
|
+
notification: this,
|
|
191
|
+
snoozeUntil
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
unsnooze() {
|
|
196
|
+
return unsnooze({
|
|
197
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
198
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
199
|
+
args: { notification: this }
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
completePrimary() {
|
|
203
|
+
if (!this.primaryAction) {
|
|
204
|
+
throw new Error("Primary action is not available");
|
|
205
|
+
}
|
|
206
|
+
return completeAction({
|
|
207
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
208
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
209
|
+
args: {
|
|
210
|
+
notification: this
|
|
211
|
+
},
|
|
212
|
+
actionType: "primary" /* PRIMARY */
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
completeSecondary() {
|
|
216
|
+
if (!this.primaryAction) {
|
|
217
|
+
throw new Error("Secondary action is not available");
|
|
218
|
+
}
|
|
219
|
+
return completeAction({
|
|
220
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
221
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
222
|
+
args: {
|
|
223
|
+
notification: this
|
|
224
|
+
},
|
|
225
|
+
actionType: "secondary" /* SECONDARY */
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
revertPrimary() {
|
|
229
|
+
if (!this.primaryAction) {
|
|
230
|
+
throw new Error("Primary action is not available");
|
|
231
|
+
}
|
|
232
|
+
return revertAction({
|
|
233
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
234
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
235
|
+
args: {
|
|
236
|
+
notification: this
|
|
237
|
+
},
|
|
238
|
+
actionType: "primary" /* PRIMARY */
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
revertSecondary() {
|
|
242
|
+
if (!this.primaryAction) {
|
|
243
|
+
throw new Error("Secondary action is not available");
|
|
244
|
+
}
|
|
245
|
+
return revertAction({
|
|
246
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
247
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
248
|
+
args: {
|
|
249
|
+
notification: this
|
|
250
|
+
},
|
|
251
|
+
actionType: "secondary" /* SECONDARY */
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
on(eventName, listener) {
|
|
255
|
+
const cleanup = chunkA6CBLMST_js.__privateGet(this, _emitter).on(eventName, listener);
|
|
256
|
+
return () => {
|
|
257
|
+
cleanup();
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* @deprecated
|
|
262
|
+
* Use the cleanup function returned by the "on" method instead.
|
|
263
|
+
*/
|
|
264
|
+
off(eventName, listener) {
|
|
265
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter).off(eventName, listener);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
_emitter = new WeakMap();
|
|
269
|
+
_inboxService = new WeakMap();
|
|
270
|
+
|
|
98
271
|
// src/notifications/helpers.ts
|
|
99
|
-
|
|
272
|
+
function ensureNotificationInstance({
|
|
273
|
+
notification,
|
|
274
|
+
emitter,
|
|
275
|
+
inboxService
|
|
276
|
+
}) {
|
|
277
|
+
if (notification instanceof Notification) {
|
|
278
|
+
return notification;
|
|
279
|
+
}
|
|
280
|
+
if (typeof notification.read === "function") {
|
|
281
|
+
return notification;
|
|
282
|
+
}
|
|
283
|
+
return new Notification(notification, emitter, inboxService);
|
|
284
|
+
}
|
|
285
|
+
var read = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
100
286
|
emitter,
|
|
101
287
|
apiService,
|
|
102
288
|
args
|
|
@@ -128,7 +314,7 @@ var read = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
128
314
|
return { error: new NovuError("Failed to read notification", error) };
|
|
129
315
|
}
|
|
130
316
|
});
|
|
131
|
-
var unread = (_0) =>
|
|
317
|
+
var unread = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
132
318
|
emitter,
|
|
133
319
|
apiService,
|
|
134
320
|
args
|
|
@@ -160,7 +346,7 @@ var unread = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
160
346
|
return { error: new NovuError("Failed to unread notification", error) };
|
|
161
347
|
}
|
|
162
348
|
});
|
|
163
|
-
var seen = (_0) =>
|
|
349
|
+
var seen = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
164
350
|
emitter,
|
|
165
351
|
apiService,
|
|
166
352
|
args
|
|
@@ -192,7 +378,7 @@ var seen = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
192
378
|
return { error: new NovuError("Failed to mark notification as seen", error) };
|
|
193
379
|
}
|
|
194
380
|
});
|
|
195
|
-
var archive = (_0) =>
|
|
381
|
+
var archive = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
196
382
|
emitter,
|
|
197
383
|
apiService,
|
|
198
384
|
args
|
|
@@ -224,7 +410,7 @@ var archive = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
224
410
|
return { error: new NovuError("Failed to archive notification", error) };
|
|
225
411
|
}
|
|
226
412
|
});
|
|
227
|
-
var unarchive = (_0) =>
|
|
413
|
+
var unarchive = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
228
414
|
emitter,
|
|
229
415
|
apiService,
|
|
230
416
|
args
|
|
@@ -256,7 +442,7 @@ var unarchive = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
256
442
|
return { error: new NovuError("Failed to unarchive notification", error) };
|
|
257
443
|
}
|
|
258
444
|
});
|
|
259
|
-
var snooze = (_0) =>
|
|
445
|
+
var snooze = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
260
446
|
emitter,
|
|
261
447
|
apiService,
|
|
262
448
|
args
|
|
@@ -286,7 +472,7 @@ var snooze = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
286
472
|
return { error: new NovuError("Failed to snooze notification", error) };
|
|
287
473
|
}
|
|
288
474
|
});
|
|
289
|
-
var unsnooze = (_0) =>
|
|
475
|
+
var unsnooze = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
290
476
|
emitter,
|
|
291
477
|
apiService,
|
|
292
478
|
args
|
|
@@ -316,18 +502,18 @@ var unsnooze = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
316
502
|
return { error: new NovuError("Failed to unsnooze notification", error) };
|
|
317
503
|
}
|
|
318
504
|
});
|
|
319
|
-
var completeAction = (_0) =>
|
|
505
|
+
var completeAction = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
320
506
|
emitter,
|
|
321
507
|
apiService,
|
|
322
508
|
args,
|
|
323
509
|
actionType
|
|
324
510
|
}) {
|
|
325
511
|
const optimisticUpdate = actionType === "primary" /* PRIMARY */ ? {
|
|
326
|
-
primaryAction:
|
|
512
|
+
primaryAction: chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, "notification" in args ? args.notification.primaryAction : {}), {
|
|
327
513
|
isCompleted: true
|
|
328
514
|
})
|
|
329
515
|
} : {
|
|
330
|
-
secondaryAction:
|
|
516
|
+
secondaryAction: chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, "notification" in args ? args.notification.secondaryAction : {}), {
|
|
331
517
|
isCompleted: true
|
|
332
518
|
})
|
|
333
519
|
};
|
|
@@ -349,18 +535,18 @@ var completeAction = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
349
535
|
return { error: new NovuError(`Failed to complete ${actionType} action on the notification`, error) };
|
|
350
536
|
}
|
|
351
537
|
});
|
|
352
|
-
var revertAction = (_0) =>
|
|
538
|
+
var revertAction = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
353
539
|
emitter,
|
|
354
540
|
apiService,
|
|
355
541
|
args,
|
|
356
542
|
actionType
|
|
357
543
|
}) {
|
|
358
544
|
const optimisticUpdate = actionType === "primary" /* PRIMARY */ ? {
|
|
359
|
-
primaryAction:
|
|
545
|
+
primaryAction: chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, "notification" in args ? args.notification.primaryAction : {}), {
|
|
360
546
|
isCompleted: false
|
|
361
547
|
})
|
|
362
548
|
} : {
|
|
363
|
-
secondaryAction:
|
|
549
|
+
secondaryAction: chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, "notification" in args ? args.notification.secondaryAction : {}), {
|
|
364
550
|
isCompleted: false
|
|
365
551
|
})
|
|
366
552
|
};
|
|
@@ -387,7 +573,7 @@ var getNotificationDetails = (args, update, dependencies) => {
|
|
|
387
573
|
return {
|
|
388
574
|
notificationId: args.notification.id,
|
|
389
575
|
optimisticValue: new Notification(
|
|
390
|
-
|
|
576
|
+
chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({}, args.notification), update),
|
|
391
577
|
dependencies.emitter,
|
|
392
578
|
dependencies.apiService
|
|
393
579
|
)
|
|
@@ -398,7 +584,7 @@ var getNotificationDetails = (args, update, dependencies) => {
|
|
|
398
584
|
};
|
|
399
585
|
}
|
|
400
586
|
};
|
|
401
|
-
var readAll = (_0) =>
|
|
587
|
+
var readAll = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
402
588
|
emitter,
|
|
403
589
|
inboxService,
|
|
404
590
|
notificationsCache,
|
|
@@ -409,7 +595,7 @@ var readAll = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
409
595
|
const notifications = notificationsCache.getUniqueNotifications({ tags, data });
|
|
410
596
|
const optimisticNotifications = notifications.map(
|
|
411
597
|
(notification) => new Notification(
|
|
412
|
-
|
|
598
|
+
chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, notification), {
|
|
413
599
|
isRead: true,
|
|
414
600
|
readAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
415
601
|
isArchived: false,
|
|
@@ -428,7 +614,7 @@ var readAll = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
428
614
|
return { error: new NovuError("Failed to read all notifications", error) };
|
|
429
615
|
}
|
|
430
616
|
});
|
|
431
|
-
var seenAll = (_0) =>
|
|
617
|
+
var seenAll = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
432
618
|
emitter,
|
|
433
619
|
inboxService,
|
|
434
620
|
notificationsCache,
|
|
@@ -441,7 +627,7 @@ var seenAll = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
441
627
|
const filteredNotifications = notificationIds && notificationIds.length > 0 ? notifications.filter((notification) => notificationIds.includes(notification.id)) : notifications;
|
|
442
628
|
const optimisticNotifications = filteredNotifications.map(
|
|
443
629
|
(notification) => new Notification(
|
|
444
|
-
|
|
630
|
+
chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, notification), {
|
|
445
631
|
isSeen: true,
|
|
446
632
|
firstSeenAt: notification.firstSeenAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
447
633
|
}),
|
|
@@ -464,7 +650,7 @@ var seenAll = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
464
650
|
return { error: new NovuError("Failed to mark all notifications as seen", error) };
|
|
465
651
|
}
|
|
466
652
|
});
|
|
467
|
-
var archiveAll = (_0) =>
|
|
653
|
+
var archiveAll = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
468
654
|
emitter,
|
|
469
655
|
inboxService,
|
|
470
656
|
notificationsCache,
|
|
@@ -475,7 +661,7 @@ var archiveAll = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
475
661
|
const notifications = notificationsCache.getUniqueNotifications({ tags, data });
|
|
476
662
|
const optimisticNotifications = notifications.map(
|
|
477
663
|
(notification) => new Notification(
|
|
478
|
-
|
|
664
|
+
chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, notification), {
|
|
479
665
|
isRead: true,
|
|
480
666
|
readAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
481
667
|
isArchived: true,
|
|
@@ -494,7 +680,7 @@ var archiveAll = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
494
680
|
return { error: new NovuError("Failed to archive all notifications", error) };
|
|
495
681
|
}
|
|
496
682
|
});
|
|
497
|
-
var archiveAllRead = (_0) =>
|
|
683
|
+
var archiveAllRead = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
498
684
|
emitter,
|
|
499
685
|
inboxService,
|
|
500
686
|
notificationsCache,
|
|
@@ -505,7 +691,7 @@ var archiveAllRead = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
505
691
|
const notifications = notificationsCache.getUniqueNotifications({ tags, data, read: true });
|
|
506
692
|
const optimisticNotifications = notifications.map(
|
|
507
693
|
(notification) => new Notification(
|
|
508
|
-
|
|
694
|
+
chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, notification), { isArchived: true, archivedAt: (/* @__PURE__ */ new Date()).toISOString() }),
|
|
509
695
|
emitter,
|
|
510
696
|
inboxService
|
|
511
697
|
)
|
|
@@ -519,7 +705,7 @@ var archiveAllRead = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
519
705
|
return { error: new NovuError("Failed to archive all read notifications", error) };
|
|
520
706
|
}
|
|
521
707
|
});
|
|
522
|
-
var deleteNotification = (_0) =>
|
|
708
|
+
var deleteNotification = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
523
709
|
emitter,
|
|
524
710
|
apiService,
|
|
525
711
|
args
|
|
@@ -544,7 +730,7 @@ var deleteNotification = (_0) => chunk7B52C2XE_js.__async(null, [_0], function*
|
|
|
544
730
|
return { error: new NovuError("Failed to delete notification", error) };
|
|
545
731
|
}
|
|
546
732
|
});
|
|
547
|
-
var deleteAll = (_0) =>
|
|
733
|
+
var deleteAll = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
548
734
|
emitter,
|
|
549
735
|
inboxService,
|
|
550
736
|
notificationsCache,
|
|
@@ -563,186 +749,17 @@ var deleteAll = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
563
749
|
}
|
|
564
750
|
});
|
|
565
751
|
|
|
566
|
-
// src/notifications/notification.ts
|
|
567
|
-
var _emitter, _inboxService;
|
|
568
|
-
var Notification = class {
|
|
569
|
-
constructor(notification, emitter, inboxService) {
|
|
570
|
-
chunk7B52C2XE_js.__privateAdd(this, _emitter);
|
|
571
|
-
chunk7B52C2XE_js.__privateAdd(this, _inboxService);
|
|
572
|
-
chunk7B52C2XE_js.__privateSet(this, _emitter, emitter);
|
|
573
|
-
chunk7B52C2XE_js.__privateSet(this, _inboxService, inboxService);
|
|
574
|
-
this.id = notification.id;
|
|
575
|
-
this.transactionId = notification.transactionId;
|
|
576
|
-
this.subject = notification.subject;
|
|
577
|
-
this.body = notification.body;
|
|
578
|
-
this.to = notification.to;
|
|
579
|
-
this.isRead = notification.isRead;
|
|
580
|
-
this.isSeen = notification.isSeen;
|
|
581
|
-
this.isArchived = notification.isArchived;
|
|
582
|
-
this.isSnoozed = notification.isSnoozed;
|
|
583
|
-
this.snoozedUntil = notification.snoozedUntil;
|
|
584
|
-
this.deliveredAt = notification.deliveredAt;
|
|
585
|
-
this.createdAt = notification.createdAt;
|
|
586
|
-
this.readAt = notification.readAt;
|
|
587
|
-
this.firstSeenAt = notification.firstSeenAt;
|
|
588
|
-
this.archivedAt = notification.archivedAt;
|
|
589
|
-
this.avatar = notification.avatar;
|
|
590
|
-
this.primaryAction = notification.primaryAction;
|
|
591
|
-
this.secondaryAction = notification.secondaryAction;
|
|
592
|
-
this.channelType = notification.channelType;
|
|
593
|
-
this.tags = notification.tags;
|
|
594
|
-
this.redirect = notification.redirect;
|
|
595
|
-
this.data = notification.data;
|
|
596
|
-
this.workflow = notification.workflow;
|
|
597
|
-
this.severity = notification.severity;
|
|
598
|
-
}
|
|
599
|
-
read() {
|
|
600
|
-
return read({
|
|
601
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
602
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
603
|
-
args: {
|
|
604
|
-
notification: this
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
unread() {
|
|
609
|
-
return unread({
|
|
610
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
611
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
612
|
-
args: {
|
|
613
|
-
notification: this
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
seen() {
|
|
618
|
-
return seen({
|
|
619
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
620
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
621
|
-
args: {
|
|
622
|
-
notification: this
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
archive() {
|
|
627
|
-
return archive({
|
|
628
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
629
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
630
|
-
args: {
|
|
631
|
-
notification: this
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
unarchive() {
|
|
636
|
-
return unarchive({
|
|
637
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
638
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
639
|
-
args: {
|
|
640
|
-
notification: this
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
delete() {
|
|
645
|
-
return deleteNotification({
|
|
646
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
647
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
648
|
-
args: {
|
|
649
|
-
notification: this
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
snooze(snoozeUntil) {
|
|
654
|
-
return snooze({
|
|
655
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
656
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
657
|
-
args: {
|
|
658
|
-
notification: this,
|
|
659
|
-
snoozeUntil
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
unsnooze() {
|
|
664
|
-
return unsnooze({
|
|
665
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
666
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
667
|
-
args: { notification: this }
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
completePrimary() {
|
|
671
|
-
if (!this.primaryAction) {
|
|
672
|
-
throw new Error("Primary action is not available");
|
|
673
|
-
}
|
|
674
|
-
return completeAction({
|
|
675
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
676
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
677
|
-
args: {
|
|
678
|
-
notification: this
|
|
679
|
-
},
|
|
680
|
-
actionType: "primary" /* PRIMARY */
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
completeSecondary() {
|
|
684
|
-
if (!this.primaryAction) {
|
|
685
|
-
throw new Error("Secondary action is not available");
|
|
686
|
-
}
|
|
687
|
-
return completeAction({
|
|
688
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
689
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
690
|
-
args: {
|
|
691
|
-
notification: this
|
|
692
|
-
},
|
|
693
|
-
actionType: "secondary" /* SECONDARY */
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
revertPrimary() {
|
|
697
|
-
if (!this.primaryAction) {
|
|
698
|
-
throw new Error("Primary action is not available");
|
|
699
|
-
}
|
|
700
|
-
return revertAction({
|
|
701
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
702
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
703
|
-
args: {
|
|
704
|
-
notification: this
|
|
705
|
-
},
|
|
706
|
-
actionType: "primary" /* PRIMARY */
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
revertSecondary() {
|
|
710
|
-
if (!this.primaryAction) {
|
|
711
|
-
throw new Error("Secondary action is not available");
|
|
712
|
-
}
|
|
713
|
-
return revertAction({
|
|
714
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
715
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
716
|
-
args: {
|
|
717
|
-
notification: this
|
|
718
|
-
},
|
|
719
|
-
actionType: "secondary" /* SECONDARY */
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
on(eventName, listener) {
|
|
723
|
-
const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter).on(eventName, listener);
|
|
724
|
-
return () => {
|
|
725
|
-
cleanup();
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* @deprecated
|
|
730
|
-
* Use the cleanup function returned by the "on" method instead.
|
|
731
|
-
*/
|
|
732
|
-
off(eventName, listener) {
|
|
733
|
-
chunk7B52C2XE_js.__privateGet(this, _emitter).off(eventName, listener);
|
|
734
|
-
}
|
|
735
|
-
};
|
|
736
|
-
_emitter = new WeakMap();
|
|
737
|
-
_inboxService = new WeakMap();
|
|
738
|
-
|
|
739
752
|
// src/ui/internal/createNotification.ts
|
|
740
753
|
function createNotification({
|
|
741
754
|
emitter,
|
|
742
755
|
inboxService,
|
|
743
756
|
notification
|
|
744
757
|
}) {
|
|
745
|
-
return
|
|
758
|
+
return ensureNotificationInstance({
|
|
759
|
+
notification,
|
|
760
|
+
emitter,
|
|
761
|
+
inboxService
|
|
762
|
+
});
|
|
746
763
|
}
|
|
747
764
|
|
|
748
765
|
// src/ui/internal/parseMarkdown.tsx
|
|
@@ -819,6 +836,7 @@ exports.completeAction = completeAction;
|
|
|
819
836
|
exports.createNotification = createNotification;
|
|
820
837
|
exports.deleteAll = deleteAll;
|
|
821
838
|
exports.deleteNotification = deleteNotification;
|
|
839
|
+
exports.ensureNotificationInstance = ensureNotificationInstance;
|
|
822
840
|
exports.parseMarkdownIntoTokens = parseMarkdownIntoTokens;
|
|
823
841
|
exports.read = read;
|
|
824
842
|
exports.readAll = readAll;
|
|
@@ -301,6 +301,7 @@ type ChannelEndpointsFetchEvents = BaseEvents<'channel-endpoints.list', ListChan
|
|
|
301
301
|
type ChannelEndpointGetEvents = BaseEvents<'channel-endpoint.get', GetChannelEndpointArgs, ChannelEndpointResponse | null>;
|
|
302
302
|
type ChannelEndpointCreateEvents = BaseEvents<'channel-endpoint.create', CreateChannelEndpointArgs, ChannelEndpointResponse>;
|
|
303
303
|
type ChannelEndpointDeleteEvents = BaseEvents<'channel-endpoint.delete', DeleteChannelEndpointArgs, void>;
|
|
304
|
+
type ChannelEndpointLinkEvents = BaseEvents<'channel-endpoint.link', LinkChannelEndpointArgs, LinkChannelEndpointResponse>;
|
|
304
305
|
type SocketConnectEvents = BaseEvents<'socket.connect', {
|
|
305
306
|
socketUrl: string;
|
|
306
307
|
}, undefined>;
|
|
@@ -354,7 +355,7 @@ type Events = SessionInitializeEvents & NotificationsFetchEvents & {
|
|
|
354
355
|
subscriptions: TopicSubscription[];
|
|
355
356
|
};
|
|
356
357
|
};
|
|
357
|
-
} & ChannelConnectionOAuthUrlEvents & ChannelConnectionsFetchEvents & ChannelConnectionGetEvents & ChannelConnectionDeleteEvents & ChannelEndpointOAuthUrlEvents & ChannelEndpointsFetchEvents & ChannelEndpointGetEvents & ChannelEndpointCreateEvents & ChannelEndpointDeleteEvents & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationSeenEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationDeleteEvents & NotificationSnoozeEvents & NotificationUnsnoozeEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsSeenAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents & NotificationsDeletedAllEvents;
|
|
358
|
+
} & ChannelConnectionOAuthUrlEvents & ChannelConnectionsFetchEvents & ChannelConnectionGetEvents & ChannelConnectionDeleteEvents & ChannelEndpointOAuthUrlEvents & ChannelEndpointsFetchEvents & ChannelEndpointGetEvents & ChannelEndpointCreateEvents & ChannelEndpointDeleteEvents & ChannelEndpointLinkEvents & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationSeenEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationDeleteEvents & NotificationSnoozeEvents & NotificationUnsnoozeEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsSeenAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents & NotificationsDeletedAllEvents;
|
|
358
359
|
type EventNames = keyof Events;
|
|
359
360
|
type SocketEventNames = keyof SocketEvents;
|
|
360
361
|
type EventHandler<T = unknown> = (event: T) => void;
|
|
@@ -864,6 +865,20 @@ type CreateChannelEndpointArgs = {
|
|
|
864
865
|
type DeleteChannelEndpointArgs = {
|
|
865
866
|
identifier: string;
|
|
866
867
|
};
|
|
868
|
+
/**
|
|
869
|
+
* Args for issuing a provider-specific URL the subscriber opens to link their
|
|
870
|
+
* chat identity (e.g. a Telegram `t.me` deep link). The subscriber is derived
|
|
871
|
+
* from the session token, so only the integration identifier is required.
|
|
872
|
+
*/
|
|
873
|
+
type LinkChannelEndpointArgs = {
|
|
874
|
+
integrationIdentifier: string;
|
|
875
|
+
};
|
|
876
|
+
type LinkChannelEndpointResponse = {
|
|
877
|
+
/** URL the subscriber opens to link their chat identity (deep link or OAuth URL). */
|
|
878
|
+
url: string;
|
|
879
|
+
/** Provider-specific metadata returned alongside the link URL (e.g. Telegram `botUsername`, `expiresAt`). */
|
|
880
|
+
providerMetadata?: Record<string, unknown>;
|
|
881
|
+
};
|
|
867
882
|
|
|
868
883
|
type InboxServiceOptions = HttpClientOptions;
|
|
869
884
|
declare class InboxService {
|
|
@@ -1038,6 +1053,7 @@ declare class InboxService {
|
|
|
1038
1053
|
getChannelEndpoint(identifier: string): Promise<ChannelEndpointResponse>;
|
|
1039
1054
|
createChannelEndpoint({ identifier, integrationIdentifier, connectionIdentifier, subscriberId, context, type, endpoint, }: CreateChannelEndpointArgs): Promise<ChannelEndpointResponse>;
|
|
1040
1055
|
deleteChannelEndpoint(identifier: string): Promise<void>;
|
|
1056
|
+
linkChannelEndpoint({ integrationIdentifier }: LinkChannelEndpointArgs): Promise<LinkChannelEndpointResponse>;
|
|
1041
1057
|
}
|
|
1042
1058
|
|
|
1043
|
-
export { type
|
|
1059
|
+
export { type UnreadCount as $, type NovuOptions as A, type BaseDeleteSubscriptionArgs as B, type ChannelConnectionResponse as C, type DaySchedule as D, type EventHandler as E, type FiltersCountResponse as F, type GenerateChatOAuthUrlArgs as G, type NovuSocketOptions as H, type InboxNotification as I, type PreferenceFilter as J, PreferenceLevel as K, type LinkChannelEndpointArgs as L, type PreferencesResponse as M, Notification as N, Schedule as O, Preference as P, type SocketEventNames as Q, type SocketTypeOption as R, SeverityLevelEnum as S, type TagsFilter as T, type StandardNovuOptions as U, type Subscriber as V, SubscriptionPreference as W, type TagsFilterAndForm as X, type TagsFilterOrGroup as Y, type TimeRange as Z, TopicSubscription as _, type NotificationFilter as a, type UpdateSubscriptionArgs as a0, type UpdateSubscriptionPreferenceArgs as a1, WebSocketEvent as a2, type WeeklySchedule as a3, WorkflowCriticalityEnum as a4, type WorkflowFilter as a5, type WorkflowGroupFilter as a6, type WorkflowIdentifierOrId as a7, type ConnectionMode as a8, InboxService as a9, NovuEventEmitter as aa, type Session as ab, type Result as ac, ScheduleCache as ad, type UpdateScheduleArgs as ae, PreferencesCache as af, type ListPreferencesArgs as ag, type BasePreferenceArgs as ah, type InstancePreferenceArgs as ai, type ListNotificationsArgs as aj, type FilterCountArgs as ak, type FilterCountResponse as al, type FiltersCountArgs as am, type BaseArgs as an, type InstanceArgs as ao, type SnoozeArgs as ap, type GenerateConnectOAuthUrlArgs as aq, type GenerateLinkUserOAuthUrlArgs as ar, SubscriptionsCache as as, type Options as at, type EventNames as au, type ContextValue as av, type BaseUpdateSubscriptionArgs as b, type ChannelEndpointResponse as c, type ChannelPreference as d, ChannelType as e, type Context as f, type CreateChannelConnectionArgs as g, type CreateChannelEndpointArgs as h, type CreateSubscriptionArgs as i, type DefaultSchedule as j, type DeleteChannelConnectionArgs as k, type DeleteChannelEndpointArgs as l, type DeleteSubscriptionArgs as m, type Events as n, type GetChannelConnectionArgs as o, type GetChannelEndpointArgs as p, type GetSubscriptionArgs as q, type InstanceDeleteSubscriptionArgs as r, type InstanceUpdateSubscriptionArgs as s, type LinkChannelEndpointResponse as t, type ListChannelConnectionsArgs as u, type ListChannelEndpointsArgs as v, type ListNotificationsResponse as w, type ListSubscriptionsArgs as x, NotificationStatus as y, NovuError as z };
|