@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
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ import { Novu } from '@novu/js';
|
|
|
20
20
|
|
|
21
21
|
const novu = new Novu({
|
|
22
22
|
applicationIdentifier: 'YOUR_NOVU_APPLICATION_IDENTIFIER',
|
|
23
|
-
|
|
23
|
+
subscriber: 'YOUR_INTERNAL_SUBSCRIBER_ID',
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
const { data: notifications, error } = await novu.notifications.list();
|
|
@@ -13,8 +13,10 @@ var io__default = /*#__PURE__*/_interopDefault(io);
|
|
|
13
13
|
var NotificationStatus = /* @__PURE__ */ ((NotificationStatus2) => {
|
|
14
14
|
NotificationStatus2["READ"] = "read";
|
|
15
15
|
NotificationStatus2["SEEN"] = "seen";
|
|
16
|
+
NotificationStatus2["SNOOZED"] = "snoozed";
|
|
16
17
|
NotificationStatus2["UNREAD"] = "unread";
|
|
17
18
|
NotificationStatus2["UNSEEN"] = "unseen";
|
|
19
|
+
NotificationStatus2["UNSNOOZED"] = "unsnoozed";
|
|
18
20
|
return NotificationStatus2;
|
|
19
21
|
})(NotificationStatus || {});
|
|
20
22
|
var PreferenceLevel = /* @__PURE__ */ ((PreferenceLevel2) => {
|
|
@@ -54,13 +56,13 @@ var areTagsEqual = (tags1, tags2) => {
|
|
|
54
56
|
return arrayValuesEqual(tags1, tags2) || !tags1 && (tags2 == null ? void 0 : tags2.length) === 0 || (tags1 == null ? void 0 : tags1.length) === 0 && !tags2;
|
|
55
57
|
};
|
|
56
58
|
var isSameFilter = (filter1, filter2) => {
|
|
57
|
-
return areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived;
|
|
59
|
+
return areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived && filter1.snoozed === filter2.snoozed;
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
// src/api/http-client.ts
|
|
61
63
|
var DEFAULT_API_VERSION = "v1";
|
|
62
64
|
var DEFAULT_BACKEND_URL = "https://api.novu.co";
|
|
63
|
-
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.
|
|
65
|
+
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.3.0"}`;
|
|
64
66
|
var HttpClient = class {
|
|
65
67
|
constructor(options = {}) {
|
|
66
68
|
const {
|
|
@@ -175,13 +177,13 @@ var InboxService = class {
|
|
|
175
177
|
initializeSession(_0) {
|
|
176
178
|
return chunk7B52C2XE_js.__async(this, arguments, function* ({
|
|
177
179
|
applicationIdentifier,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
subscriberHash,
|
|
181
|
+
subscriber
|
|
180
182
|
}) {
|
|
181
183
|
const response = yield chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_ROUTE}/session`, {
|
|
182
184
|
applicationIdentifier,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
subscriberHash,
|
|
186
|
+
subscriber
|
|
185
187
|
});
|
|
186
188
|
chunk7B52C2XE_js.__privateGet(this, _httpClient).setAuthorizationToken(response.token);
|
|
187
189
|
this.isSessionInitialized = true;
|
|
@@ -194,7 +196,8 @@ var InboxService = class {
|
|
|
194
196
|
limit = 10,
|
|
195
197
|
offset,
|
|
196
198
|
read: read2,
|
|
197
|
-
tags
|
|
199
|
+
tags,
|
|
200
|
+
snoozed
|
|
198
201
|
}) {
|
|
199
202
|
const searchParams = new URLSearchParams(`limit=${limit}`);
|
|
200
203
|
if (after) {
|
|
@@ -212,6 +215,9 @@ var InboxService = class {
|
|
|
212
215
|
if (archived !== void 0) {
|
|
213
216
|
searchParams.append("archived", `${archived}`);
|
|
214
217
|
}
|
|
218
|
+
if (snoozed !== void 0) {
|
|
219
|
+
searchParams.append("snoozed", `${snoozed}`);
|
|
220
|
+
}
|
|
215
221
|
return chunk7B52C2XE_js.__privateGet(this, _httpClient).get(INBOX_NOTIFICATIONS_ROUTE, searchParams, false);
|
|
216
222
|
}
|
|
217
223
|
count({ filters }) {
|
|
@@ -235,6 +241,12 @@ var InboxService = class {
|
|
|
235
241
|
unarchive(notificationId) {
|
|
236
242
|
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unarchive`);
|
|
237
243
|
}
|
|
244
|
+
snooze(notificationId, snoozeUntil) {
|
|
245
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/snooze`, { snoozeUntil });
|
|
246
|
+
}
|
|
247
|
+
unsnooze(notificationId) {
|
|
248
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unsnooze`);
|
|
249
|
+
}
|
|
238
250
|
readAll({ tags }) {
|
|
239
251
|
return chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read`, { tags });
|
|
240
252
|
}
|
|
@@ -373,6 +385,9 @@ var Notification = class {
|
|
|
373
385
|
this.to = notification.to;
|
|
374
386
|
this.isRead = notification.isRead;
|
|
375
387
|
this.isArchived = notification.isArchived;
|
|
388
|
+
this.isSnoozed = notification.isSnoozed;
|
|
389
|
+
this.snoozedUntil = notification.snoozedUntil;
|
|
390
|
+
this.deliveredAt = notification.deliveredAt;
|
|
376
391
|
this.createdAt = notification.createdAt;
|
|
377
392
|
this.readAt = notification.readAt;
|
|
378
393
|
this.archivedAt = notification.archivedAt;
|
|
@@ -421,6 +436,23 @@ var Notification = class {
|
|
|
421
436
|
}
|
|
422
437
|
});
|
|
423
438
|
}
|
|
439
|
+
snooze(snoozeUntil) {
|
|
440
|
+
return snooze({
|
|
441
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
442
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
443
|
+
args: {
|
|
444
|
+
notification: this,
|
|
445
|
+
snoozeUntil
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
unsnooze() {
|
|
450
|
+
return unsnooze({
|
|
451
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
452
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
453
|
+
args: { notification: this }
|
|
454
|
+
});
|
|
455
|
+
}
|
|
424
456
|
completePrimary() {
|
|
425
457
|
if (!this.primaryAction) {
|
|
426
458
|
throw new Error("Primary action is not available");
|
|
@@ -619,6 +651,66 @@ var unarchive = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
|
619
651
|
return { error: new NovuError("Failed to unarchive notification", error) };
|
|
620
652
|
}
|
|
621
653
|
});
|
|
654
|
+
var snooze = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
655
|
+
emitter,
|
|
656
|
+
apiService,
|
|
657
|
+
args
|
|
658
|
+
}) {
|
|
659
|
+
const { notificationId, optimisticValue } = getNotificationDetails(
|
|
660
|
+
args,
|
|
661
|
+
{
|
|
662
|
+
isSnoozed: true,
|
|
663
|
+
snoozedUntil: args.snoozeUntil
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
emitter,
|
|
667
|
+
apiService
|
|
668
|
+
}
|
|
669
|
+
);
|
|
670
|
+
try {
|
|
671
|
+
emitter.emit("notification.snooze.pending", {
|
|
672
|
+
args,
|
|
673
|
+
data: optimisticValue
|
|
674
|
+
});
|
|
675
|
+
const response = yield apiService.snooze(notificationId, args.snoozeUntil);
|
|
676
|
+
const updatedNotification = new Notification(response, emitter, apiService);
|
|
677
|
+
emitter.emit("notification.snooze.resolved", { args, data: updatedNotification });
|
|
678
|
+
return { data: updatedNotification };
|
|
679
|
+
} catch (error) {
|
|
680
|
+
emitter.emit("notification.snooze.resolved", { args, error });
|
|
681
|
+
return { error: new NovuError("Failed to snooze notification", error) };
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
var unsnooze = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
685
|
+
emitter,
|
|
686
|
+
apiService,
|
|
687
|
+
args
|
|
688
|
+
}) {
|
|
689
|
+
const { notificationId, optimisticValue } = getNotificationDetails(
|
|
690
|
+
args,
|
|
691
|
+
{
|
|
692
|
+
isSnoozed: false,
|
|
693
|
+
snoozedUntil: null
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
emitter,
|
|
697
|
+
apiService
|
|
698
|
+
}
|
|
699
|
+
);
|
|
700
|
+
try {
|
|
701
|
+
emitter.emit("notification.unsnooze.pending", {
|
|
702
|
+
args,
|
|
703
|
+
data: optimisticValue
|
|
704
|
+
});
|
|
705
|
+
const response = yield apiService.unsnooze(notificationId);
|
|
706
|
+
const updatedNotification = new Notification(response, emitter, apiService);
|
|
707
|
+
emitter.emit("notification.unsnooze.resolved", { args, data: updatedNotification });
|
|
708
|
+
return { data: updatedNotification };
|
|
709
|
+
} catch (error) {
|
|
710
|
+
emitter.emit("notification.unsnooze.resolved", { args, error });
|
|
711
|
+
return { error: new NovuError("Failed to unsnooze notification", error) };
|
|
712
|
+
}
|
|
713
|
+
});
|
|
622
714
|
var completeAction = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
623
715
|
emitter,
|
|
624
716
|
apiService,
|
|
@@ -816,15 +908,20 @@ var InMemoryCache = class {
|
|
|
816
908
|
_cache = new WeakMap();
|
|
817
909
|
|
|
818
910
|
// src/cache/notifications-cache.ts
|
|
819
|
-
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]) => {
|
|
911
|
+
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]) => {
|
|
820
912
|
acc[key] = value;
|
|
821
913
|
return acc;
|
|
822
914
|
}, {});
|
|
823
|
-
var getCacheKey = ({ tags, read: read2, archived, limit, offset, after }) => {
|
|
824
|
-
return JSON.stringify(excludeEmpty({ tags, read: read2, archived, limit, offset, after }));
|
|
915
|
+
var getCacheKey = ({ tags, read: read2, archived, snoozed, limit, offset, after }) => {
|
|
916
|
+
return JSON.stringify(excludeEmpty({ tags, read: read2, archived, snoozed, limit, offset, after }));
|
|
825
917
|
};
|
|
826
|
-
var getFilterKey = ({
|
|
827
|
-
|
|
918
|
+
var getFilterKey = ({
|
|
919
|
+
tags,
|
|
920
|
+
read: read2,
|
|
921
|
+
archived,
|
|
922
|
+
snoozed
|
|
923
|
+
}) => {
|
|
924
|
+
return JSON.stringify(excludeEmpty({ tags, read: read2, archived, snoozed }));
|
|
828
925
|
};
|
|
829
926
|
var getFilter = (key) => {
|
|
830
927
|
return JSON.parse(key);
|
|
@@ -844,6 +941,8 @@ var updateEvents = [
|
|
|
844
941
|
var removeEvents = [
|
|
845
942
|
"notification.archive.pending",
|
|
846
943
|
"notification.unarchive.pending",
|
|
944
|
+
"notification.snooze.pending",
|
|
945
|
+
"notification.unsnooze.pending",
|
|
847
946
|
"notifications.archive_all.pending",
|
|
848
947
|
"notifications.archive_all_read.pending"
|
|
849
948
|
];
|
|
@@ -954,7 +1053,7 @@ var NotificationsCache = class {
|
|
|
954
1053
|
}
|
|
955
1054
|
getAll(args) {
|
|
956
1055
|
if (this.has(args)) {
|
|
957
|
-
return this.getAggregated({ tags: args.tags, read: args.read, archived: args.archived });
|
|
1056
|
+
return this.getAggregated({ tags: args.tags, read: args.read, snoozed: args.snoozed, archived: args.archived });
|
|
958
1057
|
}
|
|
959
1058
|
}
|
|
960
1059
|
/**
|
|
@@ -1115,6 +1214,32 @@ var Notifications = class extends BaseModule {
|
|
|
1115
1214
|
);
|
|
1116
1215
|
});
|
|
1117
1216
|
}
|
|
1217
|
+
snooze(args) {
|
|
1218
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1219
|
+
return this.callWithSession(
|
|
1220
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1221
|
+
return snooze({
|
|
1222
|
+
emitter: this._emitter,
|
|
1223
|
+
apiService: this._inboxService,
|
|
1224
|
+
args
|
|
1225
|
+
});
|
|
1226
|
+
})
|
|
1227
|
+
);
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
unsnooze(args) {
|
|
1231
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1232
|
+
return this.callWithSession(
|
|
1233
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1234
|
+
return unsnooze({
|
|
1235
|
+
emitter: this._emitter,
|
|
1236
|
+
apiService: this._inboxService,
|
|
1237
|
+
args
|
|
1238
|
+
});
|
|
1239
|
+
})
|
|
1240
|
+
);
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1118
1243
|
completePrimary(args) {
|
|
1119
1244
|
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1120
1245
|
return this.callWithSession(
|
|
@@ -1496,17 +1621,17 @@ var Session = class {
|
|
|
1496
1621
|
return chunk7B52C2XE_js.__privateGet(this, _options).applicationIdentifier;
|
|
1497
1622
|
}
|
|
1498
1623
|
get subscriberId() {
|
|
1499
|
-
return chunk7B52C2XE_js.__privateGet(this, _options).subscriberId;
|
|
1624
|
+
return chunk7B52C2XE_js.__privateGet(this, _options).subscriber.subscriberId;
|
|
1500
1625
|
}
|
|
1501
1626
|
initialize() {
|
|
1502
1627
|
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1503
1628
|
try {
|
|
1504
|
-
const { applicationIdentifier,
|
|
1629
|
+
const { applicationIdentifier, subscriberHash, subscriber } = chunk7B52C2XE_js.__privateGet(this, _options);
|
|
1505
1630
|
chunk7B52C2XE_js.__privateGet(this, _emitter5).emit("session.initialize.pending", { args: chunk7B52C2XE_js.__privateGet(this, _options) });
|
|
1506
1631
|
const response = yield chunk7B52C2XE_js.__privateGet(this, _inboxService2).initializeSession({
|
|
1507
1632
|
applicationIdentifier,
|
|
1508
|
-
|
|
1509
|
-
|
|
1633
|
+
subscriberHash,
|
|
1634
|
+
subscriber
|
|
1510
1635
|
});
|
|
1511
1636
|
chunk7B52C2XE_js.__privateGet(this, _emitter5).emit("session.initialize.resolved", { args: chunk7B52C2XE_js.__privateGet(this, _options), data: response });
|
|
1512
1637
|
} catch (error) {
|
|
@@ -1527,6 +1652,8 @@ var mapToNotification = ({
|
|
|
1527
1652
|
content,
|
|
1528
1653
|
read: read2,
|
|
1529
1654
|
archived,
|
|
1655
|
+
snoozedUntil,
|
|
1656
|
+
deliveredAt,
|
|
1530
1657
|
createdAt,
|
|
1531
1658
|
lastReadDate,
|
|
1532
1659
|
archivedAt,
|
|
@@ -1539,25 +1666,36 @@ var mapToNotification = ({
|
|
|
1539
1666
|
data,
|
|
1540
1667
|
workflow
|
|
1541
1668
|
}) => {
|
|
1542
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
1669
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1543
1670
|
const to = {
|
|
1544
|
-
id:
|
|
1671
|
+
id: subscriber == null ? void 0 : subscriber._id,
|
|
1672
|
+
subscriberId: subscriber == null ? void 0 : subscriber.subscriberId,
|
|
1545
1673
|
firstName: subscriber == null ? void 0 : subscriber.firstName,
|
|
1546
1674
|
lastName: subscriber == null ? void 0 : subscriber.lastName,
|
|
1547
1675
|
avatar: subscriber == null ? void 0 : subscriber.avatar,
|
|
1548
|
-
|
|
1676
|
+
locale: subscriber == null ? void 0 : subscriber.locale,
|
|
1677
|
+
data: subscriber == null ? void 0 : subscriber.data,
|
|
1678
|
+
timezone: subscriber == null ? void 0 : subscriber.timezone,
|
|
1679
|
+
email: subscriber == null ? void 0 : subscriber.email,
|
|
1680
|
+
phone: subscriber == null ? void 0 : subscriber.phone
|
|
1549
1681
|
};
|
|
1550
|
-
const primaryCta = (
|
|
1551
|
-
const secondaryCta = (
|
|
1552
|
-
const actionType = (
|
|
1553
|
-
const actionStatus = (
|
|
1554
|
-
return {
|
|
1682
|
+
const primaryCta = (_b = (_a = cta.action) == null ? void 0 : _a.buttons) == null ? void 0 : _b.find((button) => button.type === "primary" /* PRIMARY */);
|
|
1683
|
+
const secondaryCta = (_d = (_c = cta.action) == null ? void 0 : _c.buttons) == null ? void 0 : _d.find((button) => button.type === "secondary" /* SECONDARY */);
|
|
1684
|
+
const actionType = (_f = (_e = cta.action) == null ? void 0 : _e.result) == null ? void 0 : _f.type;
|
|
1685
|
+
const actionStatus = (_g = cta.action) == null ? void 0 : _g.status;
|
|
1686
|
+
return chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({
|
|
1555
1687
|
id: _id,
|
|
1556
1688
|
subject,
|
|
1557
1689
|
body: content,
|
|
1558
1690
|
to,
|
|
1559
1691
|
isRead: read2,
|
|
1560
1692
|
isArchived: archived,
|
|
1693
|
+
isSnoozed: !!snoozedUntil
|
|
1694
|
+
}, deliveredAt && {
|
|
1695
|
+
deliveredAt
|
|
1696
|
+
}), snoozedUntil && {
|
|
1697
|
+
snoozedUntil
|
|
1698
|
+
}), {
|
|
1561
1699
|
createdAt,
|
|
1562
1700
|
readAt: lastReadDate,
|
|
1563
1701
|
archivedAt,
|
|
@@ -1580,13 +1718,13 @@ var mapToNotification = ({
|
|
|
1580
1718
|
},
|
|
1581
1719
|
channelType: channel,
|
|
1582
1720
|
tags,
|
|
1583
|
-
redirect: ((
|
|
1721
|
+
redirect: ((_h = cta.data) == null ? void 0 : _h.url) ? {
|
|
1584
1722
|
url: cta.data.url,
|
|
1585
1723
|
target: cta.data.target
|
|
1586
1724
|
} : void 0,
|
|
1587
1725
|
data,
|
|
1588
1726
|
workflow
|
|
1589
|
-
};
|
|
1727
|
+
});
|
|
1590
1728
|
};
|
|
1591
1729
|
var _token, _emitter6, _socketIo, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _Socket_instances, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
|
|
1592
1730
|
var Socket = class extends BaseModule {
|
|
@@ -1718,8 +1856,8 @@ var Novu = class {
|
|
|
1718
1856
|
chunk7B52C2XE_js.__privateSet(this, _session, new Session(
|
|
1719
1857
|
{
|
|
1720
1858
|
applicationIdentifier: options.applicationIdentifier,
|
|
1721
|
-
|
|
1722
|
-
|
|
1859
|
+
subscriberHash: options.subscriberHash,
|
|
1860
|
+
subscriber: buildSubscriber(options)
|
|
1723
1861
|
},
|
|
1724
1862
|
chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
1725
1863
|
chunk7B52C2XE_js.__privateGet(this, _emitter7)
|
|
@@ -1763,6 +1901,15 @@ var Novu = class {
|
|
|
1763
1901
|
_emitter7 = new WeakMap();
|
|
1764
1902
|
_session = new WeakMap();
|
|
1765
1903
|
_inboxService3 = new WeakMap();
|
|
1904
|
+
function buildSubscriber(options) {
|
|
1905
|
+
let subscriberObj;
|
|
1906
|
+
if (options.subscriber) {
|
|
1907
|
+
subscriberObj = typeof options.subscriber === "string" ? { subscriberId: options.subscriber } : options.subscriber;
|
|
1908
|
+
} else {
|
|
1909
|
+
subscriberObj = { subscriberId: options.subscriberId };
|
|
1910
|
+
}
|
|
1911
|
+
return subscriberObj;
|
|
1912
|
+
}
|
|
1766
1913
|
|
|
1767
1914
|
exports.ChannelType = ChannelType;
|
|
1768
1915
|
exports.NotificationStatus = NotificationStatus;
|
package/dist/cjs/index.d.ts
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.js';
|
|
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.js';
|
|
3
3
|
|
|
4
4
|
declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
|
|
5
5
|
declare const isSameFilter: (filter1: NotificationFilter, filter2: NotificationFilter) => boolean;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkKIOGWIKT_js = require('./chunk-KIOGWIKT.js');
|
|
4
4
|
require('./chunk-7B52C2XE.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "ChannelType", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkKIOGWIKT_js.ChannelType; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "NotificationStatus", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkKIOGWIKT_js.NotificationStatus; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "Novu", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkKIOGWIKT_js.Novu; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "PreferenceLevel", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkKIOGWIKT_js.PreferenceLevel; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "WebSocketEvent", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkKIOGWIKT_js.WebSocketEvent; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "areTagsEqual", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkKIOGWIKT_js.areTagsEqual; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "isSameFilter", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkKIOGWIKT_js.isSameFilter; }
|
|
35
35
|
});
|
|
@@ -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 };
|