@novu/js 3.1.0 → 3.3.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/README.md +1 -1
- package/dist/cjs/{chunk-WONVNOTK.js → chunk-KIOGWIKT.js} +176 -29
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +8 -8
- package/dist/{esm/novu-DDPQzl99.d.mts → cjs/novu-DJTVB7VN.d.ts} +53 -15
- package/dist/cjs/themes/index.d.ts +2 -2
- package/dist/cjs/types-BPv1rvbm.d.ts +121 -0
- package/dist/cjs/ui/index.d.ts +4 -4
- package/dist/cjs/ui/index.js +1529 -343
- package/dist/esm/{chunk-WQDFFXIB.mjs → chunk-GTZM2EDR.mjs} +176 -29
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/{cjs/novu-DDPQzl99.d.ts → esm/novu-DJTVB7VN.d.mts} +53 -15
- package/dist/esm/themes/index.d.mts +2 -2
- package/dist/esm/types-CYgpCW2I.d.mts +121 -0
- package/dist/esm/ui/index.d.mts +4 -4
- package/dist/esm/ui/index.mjs +1527 -341
- package/dist/index.css +1 -1
- package/dist/novu.min.js +10 -10
- package/dist/novu.min.js.gz +0 -0
- package/package.json +3 -3
- package/dist/cjs/types-CVvP6EyP.d.ts +0 -103
- package/dist/esm/types-DFXwHejb.d.mts +0 -103
|
@@ -6,8 +6,10 @@ import io from 'socket.io-client';
|
|
|
6
6
|
var NotificationStatus = /* @__PURE__ */ ((NotificationStatus2) => {
|
|
7
7
|
NotificationStatus2["READ"] = "read";
|
|
8
8
|
NotificationStatus2["SEEN"] = "seen";
|
|
9
|
+
NotificationStatus2["SNOOZED"] = "snoozed";
|
|
9
10
|
NotificationStatus2["UNREAD"] = "unread";
|
|
10
11
|
NotificationStatus2["UNSEEN"] = "unseen";
|
|
12
|
+
NotificationStatus2["UNSNOOZED"] = "unsnoozed";
|
|
11
13
|
return NotificationStatus2;
|
|
12
14
|
})(NotificationStatus || {});
|
|
13
15
|
var PreferenceLevel = /* @__PURE__ */ ((PreferenceLevel2) => {
|
|
@@ -47,13 +49,13 @@ var areTagsEqual = (tags1, tags2) => {
|
|
|
47
49
|
return arrayValuesEqual(tags1, tags2) || !tags1 && (tags2 == null ? void 0 : tags2.length) === 0 || (tags1 == null ? void 0 : tags1.length) === 0 && !tags2;
|
|
48
50
|
};
|
|
49
51
|
var isSameFilter = (filter1, filter2) => {
|
|
50
|
-
return areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived;
|
|
52
|
+
return areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived && filter1.snoozed === filter2.snoozed;
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
// src/api/http-client.ts
|
|
54
56
|
var DEFAULT_API_VERSION = "v1";
|
|
55
57
|
var DEFAULT_BACKEND_URL = "https://api.novu.co";
|
|
56
|
-
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.
|
|
58
|
+
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.3.0"}`;
|
|
57
59
|
var HttpClient = class {
|
|
58
60
|
constructor(options = {}) {
|
|
59
61
|
const {
|
|
@@ -168,13 +170,13 @@ var InboxService = class {
|
|
|
168
170
|
initializeSession(_0) {
|
|
169
171
|
return __async(this, arguments, function* ({
|
|
170
172
|
applicationIdentifier,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
subscriberHash,
|
|
174
|
+
subscriber
|
|
173
175
|
}) {
|
|
174
176
|
const response = yield __privateGet(this, _httpClient).post(`${INBOX_ROUTE}/session`, {
|
|
175
177
|
applicationIdentifier,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
subscriberHash,
|
|
179
|
+
subscriber
|
|
178
180
|
});
|
|
179
181
|
__privateGet(this, _httpClient).setAuthorizationToken(response.token);
|
|
180
182
|
this.isSessionInitialized = true;
|
|
@@ -187,7 +189,8 @@ var InboxService = class {
|
|
|
187
189
|
limit = 10,
|
|
188
190
|
offset,
|
|
189
191
|
read: read2,
|
|
190
|
-
tags
|
|
192
|
+
tags,
|
|
193
|
+
snoozed
|
|
191
194
|
}) {
|
|
192
195
|
const searchParams = new URLSearchParams(`limit=${limit}`);
|
|
193
196
|
if (after) {
|
|
@@ -205,6 +208,9 @@ var InboxService = class {
|
|
|
205
208
|
if (archived !== void 0) {
|
|
206
209
|
searchParams.append("archived", `${archived}`);
|
|
207
210
|
}
|
|
211
|
+
if (snoozed !== void 0) {
|
|
212
|
+
searchParams.append("snoozed", `${snoozed}`);
|
|
213
|
+
}
|
|
208
214
|
return __privateGet(this, _httpClient).get(INBOX_NOTIFICATIONS_ROUTE, searchParams, false);
|
|
209
215
|
}
|
|
210
216
|
count({ filters }) {
|
|
@@ -228,6 +234,12 @@ var InboxService = class {
|
|
|
228
234
|
unarchive(notificationId) {
|
|
229
235
|
return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unarchive`);
|
|
230
236
|
}
|
|
237
|
+
snooze(notificationId, snoozeUntil) {
|
|
238
|
+
return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/snooze`, { snoozeUntil });
|
|
239
|
+
}
|
|
240
|
+
unsnooze(notificationId) {
|
|
241
|
+
return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unsnooze`);
|
|
242
|
+
}
|
|
231
243
|
readAll({ tags }) {
|
|
232
244
|
return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read`, { tags });
|
|
233
245
|
}
|
|
@@ -366,6 +378,9 @@ var Notification = class {
|
|
|
366
378
|
this.to = notification.to;
|
|
367
379
|
this.isRead = notification.isRead;
|
|
368
380
|
this.isArchived = notification.isArchived;
|
|
381
|
+
this.isSnoozed = notification.isSnoozed;
|
|
382
|
+
this.snoozedUntil = notification.snoozedUntil;
|
|
383
|
+
this.deliveredAt = notification.deliveredAt;
|
|
369
384
|
this.createdAt = notification.createdAt;
|
|
370
385
|
this.readAt = notification.readAt;
|
|
371
386
|
this.archivedAt = notification.archivedAt;
|
|
@@ -414,6 +429,23 @@ var Notification = class {
|
|
|
414
429
|
}
|
|
415
430
|
});
|
|
416
431
|
}
|
|
432
|
+
snooze(snoozeUntil) {
|
|
433
|
+
return snooze({
|
|
434
|
+
emitter: __privateGet(this, _emitter),
|
|
435
|
+
apiService: __privateGet(this, _inboxService),
|
|
436
|
+
args: {
|
|
437
|
+
notification: this,
|
|
438
|
+
snoozeUntil
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
unsnooze() {
|
|
443
|
+
return unsnooze({
|
|
444
|
+
emitter: __privateGet(this, _emitter),
|
|
445
|
+
apiService: __privateGet(this, _inboxService),
|
|
446
|
+
args: { notification: this }
|
|
447
|
+
});
|
|
448
|
+
}
|
|
417
449
|
completePrimary() {
|
|
418
450
|
if (!this.primaryAction) {
|
|
419
451
|
throw new Error("Primary action is not available");
|
|
@@ -612,6 +644,66 @@ var unarchive = (_0) => __async(void 0, [_0], function* ({
|
|
|
612
644
|
return { error: new NovuError("Failed to unarchive notification", error) };
|
|
613
645
|
}
|
|
614
646
|
});
|
|
647
|
+
var snooze = (_0) => __async(void 0, [_0], function* ({
|
|
648
|
+
emitter,
|
|
649
|
+
apiService,
|
|
650
|
+
args
|
|
651
|
+
}) {
|
|
652
|
+
const { notificationId, optimisticValue } = getNotificationDetails(
|
|
653
|
+
args,
|
|
654
|
+
{
|
|
655
|
+
isSnoozed: true,
|
|
656
|
+
snoozedUntil: args.snoozeUntil
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
emitter,
|
|
660
|
+
apiService
|
|
661
|
+
}
|
|
662
|
+
);
|
|
663
|
+
try {
|
|
664
|
+
emitter.emit("notification.snooze.pending", {
|
|
665
|
+
args,
|
|
666
|
+
data: optimisticValue
|
|
667
|
+
});
|
|
668
|
+
const response = yield apiService.snooze(notificationId, args.snoozeUntil);
|
|
669
|
+
const updatedNotification = new Notification(response, emitter, apiService);
|
|
670
|
+
emitter.emit("notification.snooze.resolved", { args, data: updatedNotification });
|
|
671
|
+
return { data: updatedNotification };
|
|
672
|
+
} catch (error) {
|
|
673
|
+
emitter.emit("notification.snooze.resolved", { args, error });
|
|
674
|
+
return { error: new NovuError("Failed to snooze notification", error) };
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
var unsnooze = (_0) => __async(void 0, [_0], function* ({
|
|
678
|
+
emitter,
|
|
679
|
+
apiService,
|
|
680
|
+
args
|
|
681
|
+
}) {
|
|
682
|
+
const { notificationId, optimisticValue } = getNotificationDetails(
|
|
683
|
+
args,
|
|
684
|
+
{
|
|
685
|
+
isSnoozed: false,
|
|
686
|
+
snoozedUntil: null
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
emitter,
|
|
690
|
+
apiService
|
|
691
|
+
}
|
|
692
|
+
);
|
|
693
|
+
try {
|
|
694
|
+
emitter.emit("notification.unsnooze.pending", {
|
|
695
|
+
args,
|
|
696
|
+
data: optimisticValue
|
|
697
|
+
});
|
|
698
|
+
const response = yield apiService.unsnooze(notificationId);
|
|
699
|
+
const updatedNotification = new Notification(response, emitter, apiService);
|
|
700
|
+
emitter.emit("notification.unsnooze.resolved", { args, data: updatedNotification });
|
|
701
|
+
return { data: updatedNotification };
|
|
702
|
+
} catch (error) {
|
|
703
|
+
emitter.emit("notification.unsnooze.resolved", { args, error });
|
|
704
|
+
return { error: new NovuError("Failed to unsnooze notification", error) };
|
|
705
|
+
}
|
|
706
|
+
});
|
|
615
707
|
var completeAction = (_0) => __async(void 0, [_0], function* ({
|
|
616
708
|
emitter,
|
|
617
709
|
apiService,
|
|
@@ -809,15 +901,20 @@ var InMemoryCache = class {
|
|
|
809
901
|
_cache = new WeakMap();
|
|
810
902
|
|
|
811
903
|
// src/cache/notifications-cache.ts
|
|
812
|
-
var excludeEmpty = ({ tags, read: read2, archived, limit, offset, after }) => Object.entries({ tags, read: read2, archived, limit, offset, after }).filter(([_, value]) => value !== null && value !== void 0 && !(Array.isArray(value) && value.length === 0)).reduce((acc, [key, value]) => {
|
|
904
|
+
var excludeEmpty = ({ tags, read: read2, archived, snoozed, limit, offset, after }) => Object.entries({ tags, read: read2, archived, snoozed, limit, offset, after }).filter(([_, value]) => value !== null && value !== void 0 && !(Array.isArray(value) && value.length === 0)).reduce((acc, [key, value]) => {
|
|
813
905
|
acc[key] = value;
|
|
814
906
|
return acc;
|
|
815
907
|
}, {});
|
|
816
|
-
var getCacheKey = ({ tags, read: read2, archived, limit, offset, after }) => {
|
|
817
|
-
return JSON.stringify(excludeEmpty({ tags, read: read2, archived, limit, offset, after }));
|
|
908
|
+
var getCacheKey = ({ tags, read: read2, archived, snoozed, limit, offset, after }) => {
|
|
909
|
+
return JSON.stringify(excludeEmpty({ tags, read: read2, archived, snoozed, limit, offset, after }));
|
|
818
910
|
};
|
|
819
|
-
var getFilterKey = ({
|
|
820
|
-
|
|
911
|
+
var getFilterKey = ({
|
|
912
|
+
tags,
|
|
913
|
+
read: read2,
|
|
914
|
+
archived,
|
|
915
|
+
snoozed
|
|
916
|
+
}) => {
|
|
917
|
+
return JSON.stringify(excludeEmpty({ tags, read: read2, archived, snoozed }));
|
|
821
918
|
};
|
|
822
919
|
var getFilter = (key) => {
|
|
823
920
|
return JSON.parse(key);
|
|
@@ -837,6 +934,8 @@ var updateEvents = [
|
|
|
837
934
|
var removeEvents = [
|
|
838
935
|
"notification.archive.pending",
|
|
839
936
|
"notification.unarchive.pending",
|
|
937
|
+
"notification.snooze.pending",
|
|
938
|
+
"notification.unsnooze.pending",
|
|
840
939
|
"notifications.archive_all.pending",
|
|
841
940
|
"notifications.archive_all_read.pending"
|
|
842
941
|
];
|
|
@@ -947,7 +1046,7 @@ var NotificationsCache = class {
|
|
|
947
1046
|
}
|
|
948
1047
|
getAll(args) {
|
|
949
1048
|
if (this.has(args)) {
|
|
950
|
-
return this.getAggregated({ tags: args.tags, read: args.read, archived: args.archived });
|
|
1049
|
+
return this.getAggregated({ tags: args.tags, read: args.read, snoozed: args.snoozed, archived: args.archived });
|
|
951
1050
|
}
|
|
952
1051
|
}
|
|
953
1052
|
/**
|
|
@@ -1108,6 +1207,32 @@ var Notifications = class extends BaseModule {
|
|
|
1108
1207
|
);
|
|
1109
1208
|
});
|
|
1110
1209
|
}
|
|
1210
|
+
snooze(args) {
|
|
1211
|
+
return __async(this, null, function* () {
|
|
1212
|
+
return this.callWithSession(
|
|
1213
|
+
() => __async(this, null, function* () {
|
|
1214
|
+
return snooze({
|
|
1215
|
+
emitter: this._emitter,
|
|
1216
|
+
apiService: this._inboxService,
|
|
1217
|
+
args
|
|
1218
|
+
});
|
|
1219
|
+
})
|
|
1220
|
+
);
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
unsnooze(args) {
|
|
1224
|
+
return __async(this, null, function* () {
|
|
1225
|
+
return this.callWithSession(
|
|
1226
|
+
() => __async(this, null, function* () {
|
|
1227
|
+
return unsnooze({
|
|
1228
|
+
emitter: this._emitter,
|
|
1229
|
+
apiService: this._inboxService,
|
|
1230
|
+
args
|
|
1231
|
+
});
|
|
1232
|
+
})
|
|
1233
|
+
);
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1111
1236
|
completePrimary(args) {
|
|
1112
1237
|
return __async(this, null, function* () {
|
|
1113
1238
|
return this.callWithSession(
|
|
@@ -1489,17 +1614,17 @@ var Session = class {
|
|
|
1489
1614
|
return __privateGet(this, _options).applicationIdentifier;
|
|
1490
1615
|
}
|
|
1491
1616
|
get subscriberId() {
|
|
1492
|
-
return __privateGet(this, _options).subscriberId;
|
|
1617
|
+
return __privateGet(this, _options).subscriber.subscriberId;
|
|
1493
1618
|
}
|
|
1494
1619
|
initialize() {
|
|
1495
1620
|
return __async(this, null, function* () {
|
|
1496
1621
|
try {
|
|
1497
|
-
const { applicationIdentifier,
|
|
1622
|
+
const { applicationIdentifier, subscriberHash, subscriber } = __privateGet(this, _options);
|
|
1498
1623
|
__privateGet(this, _emitter5).emit("session.initialize.pending", { args: __privateGet(this, _options) });
|
|
1499
1624
|
const response = yield __privateGet(this, _inboxService2).initializeSession({
|
|
1500
1625
|
applicationIdentifier,
|
|
1501
|
-
|
|
1502
|
-
|
|
1626
|
+
subscriberHash,
|
|
1627
|
+
subscriber
|
|
1503
1628
|
});
|
|
1504
1629
|
__privateGet(this, _emitter5).emit("session.initialize.resolved", { args: __privateGet(this, _options), data: response });
|
|
1505
1630
|
} catch (error) {
|
|
@@ -1520,6 +1645,8 @@ var mapToNotification = ({
|
|
|
1520
1645
|
content,
|
|
1521
1646
|
read: read2,
|
|
1522
1647
|
archived,
|
|
1648
|
+
snoozedUntil,
|
|
1649
|
+
deliveredAt,
|
|
1523
1650
|
createdAt,
|
|
1524
1651
|
lastReadDate,
|
|
1525
1652
|
archivedAt,
|
|
@@ -1532,25 +1659,36 @@ var mapToNotification = ({
|
|
|
1532
1659
|
data,
|
|
1533
1660
|
workflow
|
|
1534
1661
|
}) => {
|
|
1535
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
1662
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1536
1663
|
const to = {
|
|
1537
|
-
id:
|
|
1664
|
+
id: subscriber == null ? void 0 : subscriber._id,
|
|
1665
|
+
subscriberId: subscriber == null ? void 0 : subscriber.subscriberId,
|
|
1538
1666
|
firstName: subscriber == null ? void 0 : subscriber.firstName,
|
|
1539
1667
|
lastName: subscriber == null ? void 0 : subscriber.lastName,
|
|
1540
1668
|
avatar: subscriber == null ? void 0 : subscriber.avatar,
|
|
1541
|
-
|
|
1669
|
+
locale: subscriber == null ? void 0 : subscriber.locale,
|
|
1670
|
+
data: subscriber == null ? void 0 : subscriber.data,
|
|
1671
|
+
timezone: subscriber == null ? void 0 : subscriber.timezone,
|
|
1672
|
+
email: subscriber == null ? void 0 : subscriber.email,
|
|
1673
|
+
phone: subscriber == null ? void 0 : subscriber.phone
|
|
1542
1674
|
};
|
|
1543
|
-
const primaryCta = (
|
|
1544
|
-
const secondaryCta = (
|
|
1545
|
-
const actionType = (
|
|
1546
|
-
const actionStatus = (
|
|
1547
|
-
return {
|
|
1675
|
+
const primaryCta = (_b = (_a = cta.action) == null ? void 0 : _a.buttons) == null ? void 0 : _b.find((button) => button.type === "primary" /* PRIMARY */);
|
|
1676
|
+
const secondaryCta = (_d = (_c = cta.action) == null ? void 0 : _c.buttons) == null ? void 0 : _d.find((button) => button.type === "secondary" /* SECONDARY */);
|
|
1677
|
+
const actionType = (_f = (_e = cta.action) == null ? void 0 : _e.result) == null ? void 0 : _f.type;
|
|
1678
|
+
const actionStatus = (_g = cta.action) == null ? void 0 : _g.status;
|
|
1679
|
+
return __spreadProps(__spreadValues(__spreadValues({
|
|
1548
1680
|
id: _id,
|
|
1549
1681
|
subject,
|
|
1550
1682
|
body: content,
|
|
1551
1683
|
to,
|
|
1552
1684
|
isRead: read2,
|
|
1553
1685
|
isArchived: archived,
|
|
1686
|
+
isSnoozed: !!snoozedUntil
|
|
1687
|
+
}, deliveredAt && {
|
|
1688
|
+
deliveredAt
|
|
1689
|
+
}), snoozedUntil && {
|
|
1690
|
+
snoozedUntil
|
|
1691
|
+
}), {
|
|
1554
1692
|
createdAt,
|
|
1555
1693
|
readAt: lastReadDate,
|
|
1556
1694
|
archivedAt,
|
|
@@ -1573,13 +1711,13 @@ var mapToNotification = ({
|
|
|
1573
1711
|
},
|
|
1574
1712
|
channelType: channel,
|
|
1575
1713
|
tags,
|
|
1576
|
-
redirect: ((
|
|
1714
|
+
redirect: ((_h = cta.data) == null ? void 0 : _h.url) ? {
|
|
1577
1715
|
url: cta.data.url,
|
|
1578
1716
|
target: cta.data.target
|
|
1579
1717
|
} : void 0,
|
|
1580
1718
|
data,
|
|
1581
1719
|
workflow
|
|
1582
|
-
};
|
|
1720
|
+
});
|
|
1583
1721
|
};
|
|
1584
1722
|
var _token, _emitter6, _socketIo, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _Socket_instances, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
|
|
1585
1723
|
var Socket = class extends BaseModule {
|
|
@@ -1711,8 +1849,8 @@ var Novu = class {
|
|
|
1711
1849
|
__privateSet(this, _session, new Session(
|
|
1712
1850
|
{
|
|
1713
1851
|
applicationIdentifier: options.applicationIdentifier,
|
|
1714
|
-
|
|
1715
|
-
|
|
1852
|
+
subscriberHash: options.subscriberHash,
|
|
1853
|
+
subscriber: buildSubscriber(options)
|
|
1716
1854
|
},
|
|
1717
1855
|
__privateGet(this, _inboxService3),
|
|
1718
1856
|
__privateGet(this, _emitter7)
|
|
@@ -1756,5 +1894,14 @@ var Novu = class {
|
|
|
1756
1894
|
_emitter7 = new WeakMap();
|
|
1757
1895
|
_session = new WeakMap();
|
|
1758
1896
|
_inboxService3 = new WeakMap();
|
|
1897
|
+
function buildSubscriber(options) {
|
|
1898
|
+
let subscriberObj;
|
|
1899
|
+
if (options.subscriber) {
|
|
1900
|
+
subscriberObj = typeof options.subscriber === "string" ? { subscriberId: options.subscriber } : options.subscriber;
|
|
1901
|
+
} else {
|
|
1902
|
+
subscriberObj = { subscriberId: options.subscriberId };
|
|
1903
|
+
}
|
|
1904
|
+
return subscriberObj;
|
|
1905
|
+
}
|
|
1759
1906
|
|
|
1760
1907
|
export { ChannelType, NotificationStatus, Novu, PreferenceLevel, WebSocketEvent, areTagsEqual, isSameFilter };
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NotificationFilter } from './novu-
|
|
2
|
-
export { C as ChannelPreference, c as ChannelType, E as EventHandler, a as Events, F as FiltersCountResponse, I as InboxNotification, L as ListNotificationsResponse, d as Notification, e as NotificationStatus, b as Novu, f as NovuError, g as NovuOptions, P as Preference, h as PreferenceLevel, i as PreferencesResponse, S as SocketEventNames, W as WebSocketEvent } from './novu-
|
|
1
|
+
import { N as NotificationFilter } from './novu-DJTVB7VN.mjs';
|
|
2
|
+
export { C as ChannelPreference, c as ChannelType, E as EventHandler, a as Events, F as FiltersCountResponse, I as InboxNotification, L as ListNotificationsResponse, d as Notification, e as NotificationStatus, b as Novu, f as NovuError, g as NovuOptions, P as Preference, h as PreferenceLevel, i as PreferencesResponse, S as SocketEventNames, j as Subscriber, W as WebSocketEvent } from './novu-DJTVB7VN.mjs';
|
|
3
3
|
|
|
4
4
|
declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
|
|
5
5
|
declare const isSameFilter: (filter1: NotificationFilter, filter2: NotificationFilter) => boolean;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ChannelType, NotificationStatus, Novu, PreferenceLevel, WebSocketEvent, areTagsEqual, isSameFilter } from './chunk-
|
|
1
|
+
export { ChannelType, NotificationStatus, Novu, PreferenceLevel, WebSocketEvent, areTagsEqual, isSameFilter } from './chunk-GTZM2EDR.mjs';
|
|
2
2
|
import './chunk-STZMOEWR.mjs';
|
|
@@ -63,8 +63,10 @@ declare global {
|
|
|
63
63
|
declare enum NotificationStatus {
|
|
64
64
|
READ = "read",
|
|
65
65
|
SEEN = "seen",
|
|
66
|
+
SNOOZED = "snoozed",
|
|
66
67
|
UNREAD = "unread",
|
|
67
|
-
UNSEEN = "unseen"
|
|
68
|
+
UNSEEN = "unseen",
|
|
69
|
+
UNSNOOZED = "unsnoozed"
|
|
68
70
|
}
|
|
69
71
|
declare enum PreferenceLevel {
|
|
70
72
|
GLOBAL = "global",
|
|
@@ -87,13 +89,19 @@ type Session = {
|
|
|
87
89
|
totalUnreadCount: number;
|
|
88
90
|
removeNovuBranding: boolean;
|
|
89
91
|
isDevelopmentMode: boolean;
|
|
92
|
+
maxSnoozeDurationHours: number;
|
|
90
93
|
};
|
|
91
94
|
type Subscriber = {
|
|
92
|
-
id
|
|
95
|
+
id?: string;
|
|
96
|
+
subscriberId: string;
|
|
93
97
|
firstName?: string;
|
|
94
98
|
lastName?: string;
|
|
99
|
+
email?: string;
|
|
100
|
+
phone?: string;
|
|
95
101
|
avatar?: string;
|
|
96
|
-
|
|
102
|
+
locale?: string;
|
|
103
|
+
data?: Record<string, unknown>;
|
|
104
|
+
timezone?: string;
|
|
97
105
|
};
|
|
98
106
|
type Redirect = {
|
|
99
107
|
url: string;
|
|
@@ -122,6 +130,9 @@ type InboxNotification = {
|
|
|
122
130
|
to: Subscriber;
|
|
123
131
|
isRead: boolean;
|
|
124
132
|
isArchived: boolean;
|
|
133
|
+
isSnoozed: boolean;
|
|
134
|
+
snoozedUntil?: string | null;
|
|
135
|
+
deliveredAt?: string[];
|
|
125
136
|
createdAt: string;
|
|
126
137
|
readAt?: string | null;
|
|
127
138
|
archivedAt?: string | null;
|
|
@@ -138,6 +149,7 @@ type NotificationFilter = {
|
|
|
138
149
|
tags?: string[];
|
|
139
150
|
read?: boolean;
|
|
140
151
|
archived?: boolean;
|
|
152
|
+
snoozed?: boolean;
|
|
141
153
|
};
|
|
142
154
|
type ChannelPreference = {
|
|
143
155
|
email?: boolean;
|
|
@@ -167,17 +179,23 @@ type Result<D = undefined, E = NovuError> = Promise<{
|
|
|
167
179
|
error?: E;
|
|
168
180
|
}>;
|
|
169
181
|
type NovuOptions = {
|
|
170
|
-
applicationIdentifier: string;
|
|
171
|
-
subscriberId: string;
|
|
172
|
-
subscriberHash?: string;
|
|
173
182
|
/** @deprecated Use apiUrl instead */
|
|
174
183
|
backendUrl?: string;
|
|
184
|
+
/** @internal Should be used internally for testing purposes */
|
|
185
|
+
__userAgent?: string;
|
|
186
|
+
applicationIdentifier: string;
|
|
187
|
+
subscriberHash?: string;
|
|
175
188
|
apiUrl?: string;
|
|
176
189
|
socketUrl?: string;
|
|
177
190
|
useCache?: boolean;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
191
|
+
} & ({
|
|
192
|
+
/** @deprecated Use subscriber prop instead */
|
|
193
|
+
subscriberId: string;
|
|
194
|
+
subscriber?: never;
|
|
195
|
+
} | {
|
|
196
|
+
subscriber: Subscriber | string;
|
|
197
|
+
subscriberId?: never;
|
|
198
|
+
});
|
|
181
199
|
type Prettify<T> = {
|
|
182
200
|
[K in keyof T]: T[K];
|
|
183
201
|
} & {};
|
|
@@ -193,15 +211,16 @@ declare class InboxService {
|
|
|
193
211
|
#private;
|
|
194
212
|
isSessionInitialized: boolean;
|
|
195
213
|
constructor(options?: InboxServiceOptions);
|
|
196
|
-
initializeSession({ applicationIdentifier,
|
|
214
|
+
initializeSession({ applicationIdentifier, subscriberHash, subscriber, }: {
|
|
197
215
|
applicationIdentifier: string;
|
|
198
|
-
subscriberId: string;
|
|
199
216
|
subscriberHash?: string;
|
|
217
|
+
subscriber: Subscriber;
|
|
200
218
|
}): Promise<Session>;
|
|
201
|
-
fetchNotifications({ after, archived, limit, offset, read, tags, }: {
|
|
219
|
+
fetchNotifications({ after, archived, limit, offset, read, tags, snoozed, }: {
|
|
202
220
|
tags?: string[];
|
|
203
221
|
read?: boolean;
|
|
204
222
|
archived?: boolean;
|
|
223
|
+
snoozed?: boolean;
|
|
205
224
|
limit?: number;
|
|
206
225
|
after?: string;
|
|
207
226
|
offset?: number;
|
|
@@ -226,6 +245,8 @@ declare class InboxService {
|
|
|
226
245
|
unread(notificationId: string): Promise<InboxNotification>;
|
|
227
246
|
archive(notificationId: string): Promise<InboxNotification>;
|
|
228
247
|
unarchive(notificationId: string): Promise<InboxNotification>;
|
|
248
|
+
snooze(notificationId: string, snoozeUntil: string): Promise<InboxNotification>;
|
|
249
|
+
unsnooze(notificationId: string): Promise<InboxNotification>;
|
|
229
250
|
readAll({ tags }: {
|
|
230
251
|
tags?: string[];
|
|
231
252
|
}): Promise<void>;
|
|
@@ -272,6 +293,9 @@ declare class Notification implements Pick<NovuEventEmitter, 'on'>, InboxNotific
|
|
|
272
293
|
readonly to: InboxNotification['to'];
|
|
273
294
|
readonly isRead: InboxNotification['isRead'];
|
|
274
295
|
readonly isArchived: InboxNotification['isArchived'];
|
|
296
|
+
readonly isSnoozed: InboxNotification['isSnoozed'];
|
|
297
|
+
readonly snoozedUntil?: InboxNotification['snoozedUntil'];
|
|
298
|
+
readonly deliveredAt?: InboxNotification['deliveredAt'];
|
|
275
299
|
readonly createdAt: InboxNotification['createdAt'];
|
|
276
300
|
readonly readAt?: InboxNotification['readAt'];
|
|
277
301
|
readonly archivedAt?: InboxNotification['archivedAt'];
|
|
@@ -288,6 +312,8 @@ declare class Notification implements Pick<NovuEventEmitter, 'on'>, InboxNotific
|
|
|
288
312
|
unread(): Result<Notification>;
|
|
289
313
|
archive(): Result<Notification>;
|
|
290
314
|
unarchive(): Result<Notification>;
|
|
315
|
+
snooze(snoozeUntil: string): Result<Notification>;
|
|
316
|
+
unsnooze(): Result<Notification>;
|
|
291
317
|
completePrimary(): Result<Notification>;
|
|
292
318
|
completeSecondary(): Result<Notification>;
|
|
293
319
|
revertPrimary(): Result<Notification>;
|
|
@@ -304,6 +330,7 @@ type ListNotificationsArgs = {
|
|
|
304
330
|
tags?: string[];
|
|
305
331
|
read?: boolean;
|
|
306
332
|
archived?: boolean;
|
|
333
|
+
snoozed?: boolean;
|
|
307
334
|
limit?: number;
|
|
308
335
|
after?: string;
|
|
309
336
|
offset?: number;
|
|
@@ -318,12 +345,14 @@ type FilterCountArgs = {
|
|
|
318
345
|
tags?: string[];
|
|
319
346
|
read?: boolean;
|
|
320
347
|
archived?: boolean;
|
|
348
|
+
snoozed?: boolean;
|
|
321
349
|
};
|
|
322
350
|
type FiltersCountArgs = {
|
|
323
351
|
filters: Array<{
|
|
324
352
|
tags?: string[];
|
|
325
353
|
read?: boolean;
|
|
326
354
|
archived?: boolean;
|
|
355
|
+
snoozed?: boolean;
|
|
327
356
|
}>;
|
|
328
357
|
};
|
|
329
358
|
type CountArgs = undefined | FilterCountArgs | FiltersCountArgs;
|
|
@@ -348,6 +377,10 @@ type ReadArgs = BaseArgs | InstanceArgs;
|
|
|
348
377
|
type UnreadArgs = BaseArgs | InstanceArgs;
|
|
349
378
|
type ArchivedArgs = BaseArgs | InstanceArgs;
|
|
350
379
|
type UnarchivedArgs = BaseArgs | InstanceArgs;
|
|
380
|
+
type SnoozeArgs = (BaseArgs | InstanceArgs) & {
|
|
381
|
+
snoozeUntil: string;
|
|
382
|
+
};
|
|
383
|
+
type UnsnoozeArgs = BaseArgs | InstanceArgs;
|
|
351
384
|
type CompleteArgs = BaseArgs | InstanceArgs;
|
|
352
385
|
type RevertArgs = BaseArgs | InstanceArgs;
|
|
353
386
|
|
|
@@ -392,6 +425,9 @@ declare class Notifications extends BaseModule {
|
|
|
392
425
|
archive(args: InstanceArgs): Result<Notification>;
|
|
393
426
|
unarchive(args: BaseArgs): Result<Notification>;
|
|
394
427
|
unarchive(args: InstanceArgs): Result<Notification>;
|
|
428
|
+
snooze(args: SnoozeArgs): Result<Notification>;
|
|
429
|
+
unsnooze(args: BaseArgs): Result<Notification>;
|
|
430
|
+
unsnooze(args: InstanceArgs): Result<Notification>;
|
|
395
431
|
completePrimary(args: BaseArgs): Result<Notification>;
|
|
396
432
|
completePrimary(args: InstanceArgs): Result<Notification>;
|
|
397
433
|
completeSecondary(args: BaseArgs): Result<Notification>;
|
|
@@ -416,7 +452,7 @@ declare class Notifications extends BaseModule {
|
|
|
416
452
|
|
|
417
453
|
type InitializeSessionArgs = {
|
|
418
454
|
applicationIdentifier: string;
|
|
419
|
-
|
|
455
|
+
subscriber: Subscriber;
|
|
420
456
|
subscriberHash?: string;
|
|
421
457
|
};
|
|
422
458
|
|
|
@@ -440,6 +476,8 @@ type NotificationReadEvents = BaseEvents<'notification.read', ReadArgs, Notifica
|
|
|
440
476
|
type NotificationUnreadEvents = BaseEvents<'notification.unread', UnreadArgs, Notification>;
|
|
441
477
|
type NotificationArchiveEvents = BaseEvents<'notification.archive', ArchivedArgs, Notification>;
|
|
442
478
|
type NotificationUnarchiveEvents = BaseEvents<'notification.unarchive', UnarchivedArgs, Notification>;
|
|
479
|
+
type NotificationSnoozeEvents = BaseEvents<'notification.snooze', SnoozeArgs, Notification>;
|
|
480
|
+
type NotificationUnsnoozeEvents = BaseEvents<'notification.unsnooze', UnsnoozeArgs, Notification>;
|
|
443
481
|
type NotificationCompleteActionEvents = BaseEvents<'notification.complete_action', CompleteArgs, Notification>;
|
|
444
482
|
type NotificationRevertActionEvents = BaseEvents<'notification.revert_action', RevertArgs, Notification>;
|
|
445
483
|
type NotificationsReadAllEvents = BaseEvents<'notifications.read_all', {
|
|
@@ -492,7 +530,7 @@ type Events = SessionInitializeEvents & NotificationsFetchEvents & {
|
|
|
492
530
|
'preferences.list.updated': {
|
|
493
531
|
data: Preference[];
|
|
494
532
|
};
|
|
495
|
-
} & PreferenceUpdateEvents & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents;
|
|
533
|
+
} & PreferenceUpdateEvents & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationSnoozeEvents & NotificationUnsnoozeEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents;
|
|
496
534
|
type EventNames = keyof Events;
|
|
497
535
|
type SocketEventNames = keyof SocketEvents;
|
|
498
536
|
type EventHandler<T = unknown> = (event: T) => void;
|
|
@@ -545,4 +583,4 @@ declare class Novu implements Pick<NovuEventEmitter, 'on'> {
|
|
|
545
583
|
constructor(options: NovuOptions);
|
|
546
584
|
}
|
|
547
585
|
|
|
548
|
-
export { type ChannelPreference as C, type EventHandler as E, type FiltersCountResponse as F, type InboxNotification as I, type ListNotificationsResponse as L, type NotificationFilter as N, Preference as P, type SocketEventNames as S, WebSocketEvent as W, type Events as a, Novu as b, ChannelType as c, Notification as d, NotificationStatus as e, NovuError as f, type NovuOptions as g, PreferenceLevel as h, type PreferencesResponse as i };
|
|
586
|
+
export { type ChannelPreference as C, type EventHandler as E, type FiltersCountResponse as F, type InboxNotification as I, type ListNotificationsResponse as L, type NotificationFilter as N, Preference as P, type SocketEventNames as S, WebSocketEvent as W, type Events as a, Novu as b, ChannelType as c, Notification as d, NotificationStatus as e, NovuError as f, type NovuOptions as g, PreferenceLevel as h, type PreferencesResponse as i, type Subscriber as j };
|