@novu/js 3.6.0 → 3.7.1-nightly.20250723
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-RN7LHLHM.js → chunk-FZQYUNQH.js} +187 -32
- package/dist/cjs/{chunk-ERC62PGI.js → chunk-QFZ5WJGI.js} +15 -0
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +9 -8
- package/dist/cjs/internal/index.d.ts +8 -1
- package/dist/cjs/internal/index.js +6 -2
- package/dist/{esm/novu-CnZkqUKP.d.mts → cjs/novu-Gnea9ink.d.ts} +38 -165
- package/dist/cjs/themes/index.d.ts +3 -2
- package/dist/{esm/types-DKUFj4Oc.d.mts → cjs/types-C4qukwbH.d.ts} +2 -1
- package/dist/cjs/types-Y8PRbRbj.d.ts +165 -0
- package/dist/cjs/ui/index.d.ts +4 -4
- package/dist/cjs/ui/index.js +386 -132
- package/dist/esm/{chunk-P4R443TU.mjs → chunk-EO566EDU.mjs} +187 -33
- package/dist/esm/{chunk-GPV65U5R.mjs → chunk-KYYDDVBR.mjs} +15 -1
- package/dist/esm/index.d.mts +3 -2
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/internal/index.d.mts +8 -1
- package/dist/esm/internal/index.mjs +1 -1
- package/dist/{cjs/novu-CnZkqUKP.d.ts → esm/novu-DiZKRUW5.d.mts} +38 -165
- package/dist/esm/themes/index.d.mts +3 -2
- package/dist/{cjs/types-BSZsDqkz.d.ts → esm/types-D_hCZpTY.d.mts} +2 -1
- package/dist/esm/types-Y8PRbRbj.d.mts +165 -0
- package/dist/esm/ui/index.d.mts +4 -4
- package/dist/esm/ui/index.mjs +380 -126
- package/dist/novu.min.js +12 -12
- package/dist/novu.min.js.gz +0 -0
- package/package.json +3 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkQFZ5WJGI_js = require('./chunk-QFZ5WJGI.js');
|
|
3
4
|
var chunk7B52C2XE_js = require('./chunk-7B52C2XE.js');
|
|
4
5
|
var mitt = require('mitt');
|
|
5
6
|
var io = require('socket.io-client');
|
|
@@ -70,12 +71,12 @@ var areDataEqual = (data1, data2) => {
|
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
73
|
var isSameFilter = (filter1, filter2) => {
|
|
73
|
-
return areDataEqual(filter1.data, filter2.data) && areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived && filter1.snoozed === filter2.snoozed;
|
|
74
|
+
return areDataEqual(filter1.data, filter2.data) && areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived && filter1.snoozed === filter2.snoozed && filter1.seen === filter2.seen;
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
// src/api/http-client.ts
|
|
77
78
|
var DEFAULT_API_VERSION = "v1";
|
|
78
|
-
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.
|
|
79
|
+
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.7.1-nightly.20250723"}`;
|
|
79
80
|
var HttpClient = class {
|
|
80
81
|
constructor(options = {}) {
|
|
81
82
|
// Environment variable for local development that overrides the default API endpoint without affecting the Inbox DX
|
|
@@ -224,6 +225,7 @@ var InboxService = class {
|
|
|
224
225
|
read: read2,
|
|
225
226
|
tags,
|
|
226
227
|
snoozed,
|
|
228
|
+
seen: seen2,
|
|
227
229
|
data
|
|
228
230
|
}) {
|
|
229
231
|
const searchParams = new URLSearchParams(`limit=${limit}`);
|
|
@@ -245,6 +247,9 @@ var InboxService = class {
|
|
|
245
247
|
if (snoozed !== void 0) {
|
|
246
248
|
searchParams.append("snoozed", `${snoozed}`);
|
|
247
249
|
}
|
|
250
|
+
if (seen2 !== void 0) {
|
|
251
|
+
searchParams.append("seen", `${seen2}`);
|
|
252
|
+
}
|
|
248
253
|
if (data !== void 0) {
|
|
249
254
|
searchParams.append("data", JSON.stringify(data));
|
|
250
255
|
}
|
|
@@ -292,11 +297,25 @@ var InboxService = class {
|
|
|
292
297
|
});
|
|
293
298
|
}
|
|
294
299
|
archiveAllRead({ tags, data }) {
|
|
295
|
-
return chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read
|
|
300
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/archive/read`, {
|
|
296
301
|
tags,
|
|
297
302
|
data: data ? JSON.stringify(data) : void 0
|
|
298
303
|
});
|
|
299
304
|
}
|
|
305
|
+
markAsSeen({
|
|
306
|
+
notificationIds,
|
|
307
|
+
tags,
|
|
308
|
+
data
|
|
309
|
+
}) {
|
|
310
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/seen`, {
|
|
311
|
+
notificationIds,
|
|
312
|
+
tags,
|
|
313
|
+
data: data ? JSON.stringify(data) : void 0
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
seen(notificationId) {
|
|
317
|
+
return this.markAsSeen({ notificationIds: [notificationId] });
|
|
318
|
+
}
|
|
300
319
|
completeAction({
|
|
301
320
|
actionType,
|
|
302
321
|
notificationId
|
|
@@ -445,12 +464,14 @@ var Notification = class {
|
|
|
445
464
|
this.body = notification.body;
|
|
446
465
|
this.to = notification.to;
|
|
447
466
|
this.isRead = notification.isRead;
|
|
467
|
+
this.isSeen = notification.isSeen;
|
|
448
468
|
this.isArchived = notification.isArchived;
|
|
449
469
|
this.isSnoozed = notification.isSnoozed;
|
|
450
470
|
this.snoozedUntil = notification.snoozedUntil;
|
|
451
471
|
this.deliveredAt = notification.deliveredAt;
|
|
452
472
|
this.createdAt = notification.createdAt;
|
|
453
473
|
this.readAt = notification.readAt;
|
|
474
|
+
this.firstSeenAt = notification.firstSeenAt;
|
|
454
475
|
this.archivedAt = notification.archivedAt;
|
|
455
476
|
this.avatar = notification.avatar;
|
|
456
477
|
this.primaryAction = notification.primaryAction;
|
|
@@ -479,6 +500,15 @@ var Notification = class {
|
|
|
479
500
|
}
|
|
480
501
|
});
|
|
481
502
|
}
|
|
503
|
+
seen() {
|
|
504
|
+
return seen({
|
|
505
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
506
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
507
|
+
args: {
|
|
508
|
+
notification: this
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}
|
|
482
512
|
archive() {
|
|
483
513
|
return archive({
|
|
484
514
|
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
@@ -648,6 +678,38 @@ var unread = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
|
648
678
|
return { error: new NovuError("Failed to unread notification", error) };
|
|
649
679
|
}
|
|
650
680
|
});
|
|
681
|
+
var seen = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
682
|
+
emitter,
|
|
683
|
+
apiService,
|
|
684
|
+
args
|
|
685
|
+
}) {
|
|
686
|
+
const { notificationId, optimisticValue } = getNotificationDetails(
|
|
687
|
+
args,
|
|
688
|
+
{
|
|
689
|
+
isSeen: true
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
emitter,
|
|
693
|
+
apiService
|
|
694
|
+
}
|
|
695
|
+
);
|
|
696
|
+
try {
|
|
697
|
+
emitter.emit("notification.seen.pending", {
|
|
698
|
+
args,
|
|
699
|
+
data: optimisticValue
|
|
700
|
+
});
|
|
701
|
+
yield apiService.seen(notificationId);
|
|
702
|
+
if (!optimisticValue) {
|
|
703
|
+
throw new Error("Failed to create optimistic value for notification");
|
|
704
|
+
}
|
|
705
|
+
const updatedNotification = new Notification(optimisticValue, emitter, apiService);
|
|
706
|
+
emitter.emit("notification.seen.resolved", { args, data: updatedNotification });
|
|
707
|
+
return { data: updatedNotification };
|
|
708
|
+
} catch (error) {
|
|
709
|
+
emitter.emit("notification.seen.resolved", { args, error });
|
|
710
|
+
return { error: new NovuError("Failed to mark notification as seen", error) };
|
|
711
|
+
}
|
|
712
|
+
});
|
|
651
713
|
var archive = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
652
714
|
emitter,
|
|
653
715
|
apiService,
|
|
@@ -884,6 +946,42 @@ var readAll = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
|
884
946
|
return { error: new NovuError("Failed to read all notifications", error) };
|
|
885
947
|
}
|
|
886
948
|
});
|
|
949
|
+
var seenAll = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
950
|
+
emitter,
|
|
951
|
+
inboxService,
|
|
952
|
+
notificationsCache,
|
|
953
|
+
notificationIds,
|
|
954
|
+
tags,
|
|
955
|
+
data
|
|
956
|
+
}) {
|
|
957
|
+
try {
|
|
958
|
+
const notifications = notificationsCache.getUniqueNotifications({ tags, data });
|
|
959
|
+
const filteredNotifications = notificationIds && notificationIds.length > 0 ? notifications.filter((notification) => notificationIds.includes(notification.id)) : notifications;
|
|
960
|
+
const optimisticNotifications = filteredNotifications.map(
|
|
961
|
+
(notification) => new Notification(
|
|
962
|
+
chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notification), {
|
|
963
|
+
isSeen: true,
|
|
964
|
+
firstSeenAt: notification.firstSeenAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
965
|
+
}),
|
|
966
|
+
emitter,
|
|
967
|
+
inboxService
|
|
968
|
+
)
|
|
969
|
+
);
|
|
970
|
+
emitter.emit("notifications.seen_all.pending", {
|
|
971
|
+
args: { notificationIds, tags, data },
|
|
972
|
+
data: optimisticNotifications
|
|
973
|
+
});
|
|
974
|
+
yield inboxService.markAsSeen({ notificationIds, tags, data });
|
|
975
|
+
emitter.emit("notifications.seen_all.resolved", {
|
|
976
|
+
args: { notificationIds, tags, data },
|
|
977
|
+
data: optimisticNotifications
|
|
978
|
+
});
|
|
979
|
+
return {};
|
|
980
|
+
} catch (error) {
|
|
981
|
+
emitter.emit("notifications.seen_all.resolved", { args: { notificationIds, tags, data }, error });
|
|
982
|
+
return { error: new NovuError("Failed to mark all notifications as seen", error) };
|
|
983
|
+
}
|
|
984
|
+
});
|
|
887
985
|
var archiveAll = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
888
986
|
emitter,
|
|
889
987
|
inboxService,
|
|
@@ -972,21 +1070,32 @@ var InMemoryCache = class {
|
|
|
972
1070
|
_cache = new WeakMap();
|
|
973
1071
|
|
|
974
1072
|
// src/cache/notifications-cache.ts
|
|
975
|
-
var excludeEmpty = ({ tags, data, read: read2, archived, snoozed, limit, offset, after }) => Object.entries({ tags, data, read: read2, archived, snoozed, limit, offset, after }).filter(([_, value]) => value !== null && value !== void 0 && !(Array.isArray(value) && value.length === 0)).reduce((acc, [key, value]) => {
|
|
1073
|
+
var excludeEmpty = ({ tags, data, read: read2, archived, snoozed, seen: seen2, limit, offset, after }) => Object.entries({ tags, data, read: read2, archived, snoozed, seen: seen2, limit, offset, after }).filter(([_, value]) => value !== null && value !== void 0 && !(Array.isArray(value) && value.length === 0)).reduce((acc, [key, value]) => {
|
|
976
1074
|
acc[key] = value;
|
|
977
1075
|
return acc;
|
|
978
1076
|
}, {});
|
|
979
|
-
var getCacheKey = ({
|
|
980
|
-
|
|
1077
|
+
var getCacheKey = ({
|
|
1078
|
+
tags,
|
|
1079
|
+
data,
|
|
1080
|
+
read: read2,
|
|
1081
|
+
archived,
|
|
1082
|
+
snoozed,
|
|
1083
|
+
seen: seen2,
|
|
1084
|
+
limit,
|
|
1085
|
+
offset,
|
|
1086
|
+
after
|
|
1087
|
+
}) => {
|
|
1088
|
+
return JSON.stringify(excludeEmpty({ tags, data, read: read2, archived, snoozed, seen: seen2, limit, offset, after }));
|
|
981
1089
|
};
|
|
982
1090
|
var getFilterKey = ({
|
|
983
1091
|
tags,
|
|
984
1092
|
data,
|
|
985
1093
|
read: read2,
|
|
986
1094
|
archived,
|
|
987
|
-
snoozed
|
|
1095
|
+
snoozed,
|
|
1096
|
+
seen: seen2
|
|
988
1097
|
}) => {
|
|
989
|
-
return JSON.stringify(excludeEmpty({ tags, data, read: read2, archived, snoozed }));
|
|
1098
|
+
return JSON.stringify(excludeEmpty({ tags, data, read: read2, archived, snoozed, seen: seen2 }));
|
|
990
1099
|
};
|
|
991
1100
|
var getFilter = (key) => {
|
|
992
1101
|
return JSON.parse(key);
|
|
@@ -1123,7 +1232,8 @@ var NotificationsCache = class {
|
|
|
1123
1232
|
data: args.data,
|
|
1124
1233
|
read: args.read,
|
|
1125
1234
|
snoozed: args.snoozed,
|
|
1126
|
-
archived: args.archived
|
|
1235
|
+
archived: args.archived,
|
|
1236
|
+
seen: args.seen
|
|
1127
1237
|
});
|
|
1128
1238
|
}
|
|
1129
1239
|
}
|
|
@@ -1183,6 +1293,9 @@ var Notifications = class extends BaseModule {
|
|
|
1183
1293
|
});
|
|
1184
1294
|
chunk7B52C2XE_js.__privateSet(this, _useCache, useCache);
|
|
1185
1295
|
}
|
|
1296
|
+
get inboxService() {
|
|
1297
|
+
return this._inboxService;
|
|
1298
|
+
}
|
|
1186
1299
|
list() {
|
|
1187
1300
|
return chunk7B52C2XE_js.__async(this, arguments, function* (_a = {}) {
|
|
1188
1301
|
var _b = _a, { limit = 10 } = _b, restOptions = chunk7B52C2XE_js.__objRest(_b, ["limit"]);
|
|
@@ -1263,6 +1376,19 @@ var Notifications = class extends BaseModule {
|
|
|
1263
1376
|
);
|
|
1264
1377
|
});
|
|
1265
1378
|
}
|
|
1379
|
+
seen(args) {
|
|
1380
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1381
|
+
return this.callWithSession(
|
|
1382
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1383
|
+
return seen({
|
|
1384
|
+
emitter: this._emitter,
|
|
1385
|
+
apiService: this._inboxService,
|
|
1386
|
+
args
|
|
1387
|
+
});
|
|
1388
|
+
})
|
|
1389
|
+
);
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1266
1392
|
archive(args) {
|
|
1267
1393
|
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1268
1394
|
return this.callWithSession(
|
|
@@ -1389,6 +1515,28 @@ var Notifications = class extends BaseModule {
|
|
|
1389
1515
|
);
|
|
1390
1516
|
});
|
|
1391
1517
|
}
|
|
1518
|
+
seenAll() {
|
|
1519
|
+
return chunk7B52C2XE_js.__async(this, arguments, function* (args = {}) {
|
|
1520
|
+
return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1521
|
+
if ("notificationIds" in args) {
|
|
1522
|
+
return seenAll({
|
|
1523
|
+
emitter: this._emitter,
|
|
1524
|
+
inboxService: this._inboxService,
|
|
1525
|
+
notificationsCache: this.cache,
|
|
1526
|
+
notificationIds: args.notificationIds
|
|
1527
|
+
});
|
|
1528
|
+
} else {
|
|
1529
|
+
return seenAll({
|
|
1530
|
+
emitter: this._emitter,
|
|
1531
|
+
inboxService: this._inboxService,
|
|
1532
|
+
notificationsCache: this.cache,
|
|
1533
|
+
tags: "tags" in args ? args.tags : void 0,
|
|
1534
|
+
data: "data" in args ? args.data : void 0
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
}));
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1392
1540
|
archiveAll() {
|
|
1393
1541
|
return chunk7B52C2XE_js.__async(this, arguments, function* ({
|
|
1394
1542
|
tags,
|
|
@@ -1784,6 +1932,11 @@ var Preferences = class extends BaseModule {
|
|
|
1784
1932
|
};
|
|
1785
1933
|
_useCache3 = new WeakMap();
|
|
1786
1934
|
|
|
1935
|
+
// src/utils/is-browser.ts
|
|
1936
|
+
function isBrowser() {
|
|
1937
|
+
return typeof window !== "undefined";
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1787
1940
|
// src/session/session.ts
|
|
1788
1941
|
var _emitter5, _inboxService2, _options;
|
|
1789
1942
|
var Session = class {
|
|
@@ -1827,12 +1980,19 @@ var Session = class {
|
|
|
1827
1980
|
}
|
|
1828
1981
|
initialize(options) {
|
|
1829
1982
|
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1830
|
-
var _a, _b;
|
|
1983
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1984
|
+
if (((_a = chunk7B52C2XE_js.__privateGet(this, _options).subscriber) == null ? void 0 : _a.subscriberId) === ((_b = options == null ? void 0 : options.subscriber) == null ? void 0 : _b.subscriberId)) {
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1831
1987
|
try {
|
|
1832
1988
|
if (options) {
|
|
1833
1989
|
chunk7B52C2XE_js.__privateSet(this, _options, options);
|
|
1834
1990
|
}
|
|
1835
1991
|
const { subscriber, subscriberHash, applicationIdentifier } = chunk7B52C2XE_js.__privateGet(this, _options);
|
|
1992
|
+
let currentTimezone;
|
|
1993
|
+
if (isBrowser()) {
|
|
1994
|
+
currentTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1995
|
+
}
|
|
1836
1996
|
let finalApplicationIdentifier = applicationIdentifier;
|
|
1837
1997
|
if (!finalApplicationIdentifier) {
|
|
1838
1998
|
const storedAppId = this.handleApplicationIdentifier("get");
|
|
@@ -1846,12 +2006,15 @@ var Session = class {
|
|
|
1846
2006
|
const response = yield chunk7B52C2XE_js.__privateGet(this, _inboxService2).initializeSession({
|
|
1847
2007
|
applicationIdentifier: finalApplicationIdentifier,
|
|
1848
2008
|
subscriberHash,
|
|
1849
|
-
subscriber
|
|
2009
|
+
subscriber: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, subscriber), {
|
|
2010
|
+
subscriberId: (_c = subscriber == null ? void 0 : subscriber.subscriberId) != null ? _c : "",
|
|
2011
|
+
timezone: (_d = subscriber == null ? void 0 : subscriber.timezone) != null ? _d : currentTimezone
|
|
2012
|
+
})
|
|
1850
2013
|
});
|
|
1851
|
-
if ((
|
|
2014
|
+
if ((_e = response == null ? void 0 : response.applicationIdentifier) == null ? void 0 : _e.startsWith("pk_keyless_")) {
|
|
1852
2015
|
this.handleApplicationIdentifier("store", response.applicationIdentifier);
|
|
1853
2016
|
}
|
|
1854
|
-
if (!((
|
|
2017
|
+
if (!((_f = response == null ? void 0 : response.applicationIdentifier) == null ? void 0 : _f.startsWith("pk_keyless_"))) {
|
|
1855
2018
|
this.handleApplicationIdentifier("delete");
|
|
1856
2019
|
}
|
|
1857
2020
|
chunk7B52C2XE_js.__privateGet(this, _emitter5).emit("session.initialize.resolved", { args: chunk7B52C2XE_js.__privateGet(this, _options), data: response });
|
|
@@ -1872,11 +2035,13 @@ var mapToNotification = ({
|
|
|
1872
2035
|
_id,
|
|
1873
2036
|
content,
|
|
1874
2037
|
read: read2,
|
|
2038
|
+
seen: seen2,
|
|
1875
2039
|
archived,
|
|
1876
2040
|
snoozedUntil,
|
|
1877
2041
|
deliveredAt,
|
|
1878
2042
|
createdAt,
|
|
1879
2043
|
lastReadDate,
|
|
2044
|
+
firstSeenDate,
|
|
1880
2045
|
archivedAt,
|
|
1881
2046
|
channel,
|
|
1882
2047
|
subscriber,
|
|
@@ -1910,6 +2075,7 @@ var mapToNotification = ({
|
|
|
1910
2075
|
body: content,
|
|
1911
2076
|
to,
|
|
1912
2077
|
isRead: read2,
|
|
2078
|
+
isSeen: seen2,
|
|
1913
2079
|
isArchived: archived,
|
|
1914
2080
|
isSnoozed: !!snoozedUntil
|
|
1915
2081
|
}, deliveredAt && {
|
|
@@ -1919,6 +2085,7 @@ var mapToNotification = ({
|
|
|
1919
2085
|
}), {
|
|
1920
2086
|
createdAt,
|
|
1921
2087
|
readAt: lastReadDate,
|
|
2088
|
+
firstSeenAt: firstSeenDate,
|
|
1922
2089
|
archivedAt,
|
|
1923
2090
|
avatar,
|
|
1924
2091
|
primaryAction: primaryCta && {
|
|
@@ -2068,11 +2235,13 @@ var mapToNotification2 = ({
|
|
|
2068
2235
|
_id,
|
|
2069
2236
|
content,
|
|
2070
2237
|
read: read2,
|
|
2238
|
+
seen: seen2,
|
|
2071
2239
|
archived,
|
|
2072
2240
|
snoozedUntil,
|
|
2073
2241
|
deliveredAt,
|
|
2074
2242
|
createdAt,
|
|
2075
2243
|
lastReadDate,
|
|
2244
|
+
firstSeenDate,
|
|
2076
2245
|
archivedAt,
|
|
2077
2246
|
channel,
|
|
2078
2247
|
subscriber,
|
|
@@ -2106,6 +2275,7 @@ var mapToNotification2 = ({
|
|
|
2106
2275
|
body: content,
|
|
2107
2276
|
to,
|
|
2108
2277
|
isRead: read2,
|
|
2278
|
+
isSeen: seen2,
|
|
2109
2279
|
isArchived: archived,
|
|
2110
2280
|
isSnoozed: !!snoozedUntil
|
|
2111
2281
|
}, deliveredAt && {
|
|
@@ -2115,6 +2285,7 @@ var mapToNotification2 = ({
|
|
|
2115
2285
|
}), {
|
|
2116
2286
|
createdAt,
|
|
2117
2287
|
readAt: lastReadDate,
|
|
2288
|
+
firstSeenAt: firstSeenDate,
|
|
2118
2289
|
archivedAt,
|
|
2119
2290
|
avatar,
|
|
2120
2291
|
primaryAction: primaryCta && {
|
|
@@ -2332,13 +2503,12 @@ function createSocket({
|
|
|
2332
2503
|
}
|
|
2333
2504
|
|
|
2334
2505
|
// src/novu.ts
|
|
2335
|
-
var _emitter8, _session, _inboxService3
|
|
2506
|
+
var _emitter8, _session, _inboxService3;
|
|
2336
2507
|
var Novu = class {
|
|
2337
2508
|
constructor(options) {
|
|
2338
2509
|
chunk7B52C2XE_js.__privateAdd(this, _emitter8);
|
|
2339
2510
|
chunk7B52C2XE_js.__privateAdd(this, _session);
|
|
2340
2511
|
chunk7B52C2XE_js.__privateAdd(this, _inboxService3);
|
|
2341
|
-
chunk7B52C2XE_js.__privateAdd(this, _currentSubscriberId);
|
|
2342
2512
|
var _a, _b;
|
|
2343
2513
|
chunk7B52C2XE_js.__privateSet(this, _inboxService3, new InboxService({
|
|
2344
2514
|
apiUrl: options.apiUrl || options.backendUrl,
|
|
@@ -2349,13 +2519,11 @@ var Novu = class {
|
|
|
2349
2519
|
{
|
|
2350
2520
|
applicationIdentifier: options.applicationIdentifier || "",
|
|
2351
2521
|
subscriberHash: options.subscriberHash,
|
|
2352
|
-
subscriber: buildSubscriber(options)
|
|
2522
|
+
subscriber: chunkQFZ5WJGI_js.buildSubscriber({ subscriberId: options.subscriberId, subscriber: options.subscriber })
|
|
2353
2523
|
},
|
|
2354
2524
|
chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
2355
2525
|
chunk7B52C2XE_js.__privateGet(this, _emitter8)
|
|
2356
2526
|
));
|
|
2357
|
-
const initialSubscriber = buildSubscriber(options);
|
|
2358
|
-
chunk7B52C2XE_js.__privateSet(this, _currentSubscriberId, initialSubscriber.subscriberId);
|
|
2359
2527
|
chunk7B52C2XE_js.__privateGet(this, _session).initialize();
|
|
2360
2528
|
this.notifications = new Notifications({
|
|
2361
2529
|
useCache: (_a = options.useCache) != null ? _a : true,
|
|
@@ -2393,31 +2561,17 @@ var Novu = class {
|
|
|
2393
2561
|
}
|
|
2394
2562
|
changeSubscriber(options) {
|
|
2395
2563
|
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
2396
|
-
if (chunk7B52C2XE_js.__privateGet(this, _currentSubscriberId) === options.subscriber.subscriberId) {
|
|
2397
|
-
return;
|
|
2398
|
-
}
|
|
2399
2564
|
yield chunk7B52C2XE_js.__privateGet(this, _session).initialize({
|
|
2400
2565
|
applicationIdentifier: chunk7B52C2XE_js.__privateGet(this, _session).applicationIdentifier || "",
|
|
2401
2566
|
subscriberHash: options.subscriberHash,
|
|
2402
2567
|
subscriber: options.subscriber
|
|
2403
2568
|
});
|
|
2404
|
-
chunk7B52C2XE_js.__privateSet(this, _currentSubscriberId, options.subscriber.subscriberId);
|
|
2405
2569
|
});
|
|
2406
2570
|
}
|
|
2407
2571
|
};
|
|
2408
2572
|
_emitter8 = new WeakMap();
|
|
2409
2573
|
_session = new WeakMap();
|
|
2410
2574
|
_inboxService3 = new WeakMap();
|
|
2411
|
-
_currentSubscriberId = new WeakMap();
|
|
2412
|
-
function buildSubscriber(options) {
|
|
2413
|
-
if (options.subscriber) {
|
|
2414
|
-
return typeof options.subscriber === "string" ? { subscriberId: options.subscriber } : options.subscriber;
|
|
2415
|
-
}
|
|
2416
|
-
if (options.subscriberId) {
|
|
2417
|
-
return { subscriberId: options.subscriberId };
|
|
2418
|
-
}
|
|
2419
|
-
return { subscriberId: "" };
|
|
2420
|
-
}
|
|
2421
2575
|
|
|
2422
2576
|
exports.ChannelType = ChannelType;
|
|
2423
2577
|
exports.DEFAULT_API_VERSION = DEFAULT_API_VERSION;
|
|
@@ -2426,4 +2580,5 @@ exports.Novu = Novu;
|
|
|
2426
2580
|
exports.PreferenceLevel = PreferenceLevel;
|
|
2427
2581
|
exports.WebSocketEvent = WebSocketEvent;
|
|
2428
2582
|
exports.areTagsEqual = areTagsEqual;
|
|
2583
|
+
exports.isBrowser = isBrowser;
|
|
2429
2584
|
exports.isSameFilter = isSameFilter;
|
|
@@ -32,4 +32,19 @@ var parseMarkdownIntoTokens = (text) => {
|
|
|
32
32
|
return tokens;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
// src/ui/internal/buildSubscriber.ts
|
|
36
|
+
function buildSubscriber({
|
|
37
|
+
subscriberId,
|
|
38
|
+
subscriber
|
|
39
|
+
}) {
|
|
40
|
+
if (subscriber) {
|
|
41
|
+
return typeof subscriber === "string" ? { subscriberId: subscriber } : subscriber;
|
|
42
|
+
}
|
|
43
|
+
if (subscriberId) {
|
|
44
|
+
return { subscriberId };
|
|
45
|
+
}
|
|
46
|
+
return { subscriberId: "" };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
exports.buildSubscriber = buildSubscriber;
|
|
35
50
|
exports.parseMarkdownIntoTokens = parseMarkdownIntoTokens;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { E as EventHandler, a as Events, F as FiltersCountResponse, L as ListNotificationsResponse, b as Notification, N as Novu, P as Preference, S as SocketEventNames } from './novu-Gnea9ink.js';
|
|
2
|
+
import { N as NotificationFilter } from './types-Y8PRbRbj.js';
|
|
3
|
+
export { C as ChannelPreference, a as ChannelType, I as InboxNotification, b as NotificationStatus, c as NovuError, d as NovuOptions, P as PreferenceLevel, e as PreferencesResponse, S as StandardNovuOptions, f as Subscriber, W as WebSocketEvent } from './types-Y8PRbRbj.js';
|
|
3
4
|
|
|
4
5
|
declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
|
|
5
6
|
declare const isSameFilter: (filter1: NotificationFilter, filter2: NotificationFilter) => boolean;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkFZQYUNQH_js = require('./chunk-FZQYUNQH.js');
|
|
4
|
+
require('./chunk-QFZ5WJGI.js');
|
|
4
5
|
require('./chunk-7B52C2XE.js');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
Object.defineProperty(exports, "ChannelType", {
|
|
9
10
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkFZQYUNQH_js.ChannelType; }
|
|
11
12
|
});
|
|
12
13
|
Object.defineProperty(exports, "NotificationStatus", {
|
|
13
14
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkFZQYUNQH_js.NotificationStatus; }
|
|
15
16
|
});
|
|
16
17
|
Object.defineProperty(exports, "Novu", {
|
|
17
18
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkFZQYUNQH_js.Novu; }
|
|
19
20
|
});
|
|
20
21
|
Object.defineProperty(exports, "PreferenceLevel", {
|
|
21
22
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkFZQYUNQH_js.PreferenceLevel; }
|
|
23
24
|
});
|
|
24
25
|
Object.defineProperty(exports, "WebSocketEvent", {
|
|
25
26
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkFZQYUNQH_js.WebSocketEvent; }
|
|
27
28
|
});
|
|
28
29
|
Object.defineProperty(exports, "areTagsEqual", {
|
|
29
30
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkFZQYUNQH_js.areTagsEqual; }
|
|
31
32
|
});
|
|
32
33
|
Object.defineProperty(exports, "isSameFilter", {
|
|
33
34
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkFZQYUNQH_js.isSameFilter; }
|
|
35
36
|
});
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { f as Subscriber } from '../types-Y8PRbRbj.js';
|
|
2
|
+
|
|
1
3
|
interface Token {
|
|
2
4
|
type: 'bold' | 'text';
|
|
3
5
|
content: string;
|
|
4
6
|
}
|
|
5
7
|
declare const parseMarkdownIntoTokens: (text: string) => Token[];
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
declare function buildSubscriber({ subscriberId, subscriber, }: {
|
|
10
|
+
subscriberId: string | undefined;
|
|
11
|
+
subscriber: Subscriber | string | undefined;
|
|
12
|
+
}): Subscriber;
|
|
13
|
+
|
|
14
|
+
export { type Token, buildSubscriber, parseMarkdownIntoTokens };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQFZ5WJGI_js = require('../chunk-QFZ5WJGI.js');
|
|
4
4
|
require('../chunk-7B52C2XE.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
Object.defineProperty(exports, "buildSubscriber", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkQFZ5WJGI_js.buildSubscriber; }
|
|
11
|
+
});
|
|
8
12
|
Object.defineProperty(exports, "parseMarkdownIntoTokens", {
|
|
9
13
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkQFZ5WJGI_js.parseMarkdownIntoTokens; }
|
|
11
15
|
});
|