@novu/js 3.6.0 → 3.7.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-RN7LHLHM.js → chunk-FDWMGQIF.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-AIY4HF7H.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,3 +1,4 @@
|
|
|
1
|
+
import { buildSubscriber } from './chunk-KYYDDVBR.mjs';
|
|
1
2
|
import { __privateAdd, __privateSet, __privateGet, __async, __objRest, __spreadValues, __spreadProps, __privateMethod } from './chunk-STZMOEWR.mjs';
|
|
2
3
|
import mitt from 'mitt';
|
|
3
4
|
import io from 'socket.io-client';
|
|
@@ -63,12 +64,12 @@ var areDataEqual = (data1, data2) => {
|
|
|
63
64
|
}
|
|
64
65
|
};
|
|
65
66
|
var isSameFilter = (filter1, filter2) => {
|
|
66
|
-
return areDataEqual(filter1.data, filter2.data) && areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived && filter1.snoozed === filter2.snoozed;
|
|
67
|
+
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;
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
// src/api/http-client.ts
|
|
70
71
|
var DEFAULT_API_VERSION = "v1";
|
|
71
|
-
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.
|
|
72
|
+
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.7.0"}`;
|
|
72
73
|
var HttpClient = class {
|
|
73
74
|
constructor(options = {}) {
|
|
74
75
|
// Environment variable for local development that overrides the default API endpoint without affecting the Inbox DX
|
|
@@ -217,6 +218,7 @@ var InboxService = class {
|
|
|
217
218
|
read: read2,
|
|
218
219
|
tags,
|
|
219
220
|
snoozed,
|
|
221
|
+
seen: seen2,
|
|
220
222
|
data
|
|
221
223
|
}) {
|
|
222
224
|
const searchParams = new URLSearchParams(`limit=${limit}`);
|
|
@@ -238,6 +240,9 @@ var InboxService = class {
|
|
|
238
240
|
if (snoozed !== void 0) {
|
|
239
241
|
searchParams.append("snoozed", `${snoozed}`);
|
|
240
242
|
}
|
|
243
|
+
if (seen2 !== void 0) {
|
|
244
|
+
searchParams.append("seen", `${seen2}`);
|
|
245
|
+
}
|
|
241
246
|
if (data !== void 0) {
|
|
242
247
|
searchParams.append("data", JSON.stringify(data));
|
|
243
248
|
}
|
|
@@ -285,11 +290,25 @@ var InboxService = class {
|
|
|
285
290
|
});
|
|
286
291
|
}
|
|
287
292
|
archiveAllRead({ tags, data }) {
|
|
288
|
-
return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read
|
|
293
|
+
return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/archive/read`, {
|
|
289
294
|
tags,
|
|
290
295
|
data: data ? JSON.stringify(data) : void 0
|
|
291
296
|
});
|
|
292
297
|
}
|
|
298
|
+
markAsSeen({
|
|
299
|
+
notificationIds,
|
|
300
|
+
tags,
|
|
301
|
+
data
|
|
302
|
+
}) {
|
|
303
|
+
return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/seen`, {
|
|
304
|
+
notificationIds,
|
|
305
|
+
tags,
|
|
306
|
+
data: data ? JSON.stringify(data) : void 0
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
seen(notificationId) {
|
|
310
|
+
return this.markAsSeen({ notificationIds: [notificationId] });
|
|
311
|
+
}
|
|
293
312
|
completeAction({
|
|
294
313
|
actionType,
|
|
295
314
|
notificationId
|
|
@@ -438,12 +457,14 @@ var Notification = class {
|
|
|
438
457
|
this.body = notification.body;
|
|
439
458
|
this.to = notification.to;
|
|
440
459
|
this.isRead = notification.isRead;
|
|
460
|
+
this.isSeen = notification.isSeen;
|
|
441
461
|
this.isArchived = notification.isArchived;
|
|
442
462
|
this.isSnoozed = notification.isSnoozed;
|
|
443
463
|
this.snoozedUntil = notification.snoozedUntil;
|
|
444
464
|
this.deliveredAt = notification.deliveredAt;
|
|
445
465
|
this.createdAt = notification.createdAt;
|
|
446
466
|
this.readAt = notification.readAt;
|
|
467
|
+
this.firstSeenAt = notification.firstSeenAt;
|
|
447
468
|
this.archivedAt = notification.archivedAt;
|
|
448
469
|
this.avatar = notification.avatar;
|
|
449
470
|
this.primaryAction = notification.primaryAction;
|
|
@@ -472,6 +493,15 @@ var Notification = class {
|
|
|
472
493
|
}
|
|
473
494
|
});
|
|
474
495
|
}
|
|
496
|
+
seen() {
|
|
497
|
+
return seen({
|
|
498
|
+
emitter: __privateGet(this, _emitter),
|
|
499
|
+
apiService: __privateGet(this, _inboxService),
|
|
500
|
+
args: {
|
|
501
|
+
notification: this
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
}
|
|
475
505
|
archive() {
|
|
476
506
|
return archive({
|
|
477
507
|
emitter: __privateGet(this, _emitter),
|
|
@@ -641,6 +671,38 @@ var unread = (_0) => __async(void 0, [_0], function* ({
|
|
|
641
671
|
return { error: new NovuError("Failed to unread notification", error) };
|
|
642
672
|
}
|
|
643
673
|
});
|
|
674
|
+
var seen = (_0) => __async(void 0, [_0], function* ({
|
|
675
|
+
emitter,
|
|
676
|
+
apiService,
|
|
677
|
+
args
|
|
678
|
+
}) {
|
|
679
|
+
const { notificationId, optimisticValue } = getNotificationDetails(
|
|
680
|
+
args,
|
|
681
|
+
{
|
|
682
|
+
isSeen: true
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
emitter,
|
|
686
|
+
apiService
|
|
687
|
+
}
|
|
688
|
+
);
|
|
689
|
+
try {
|
|
690
|
+
emitter.emit("notification.seen.pending", {
|
|
691
|
+
args,
|
|
692
|
+
data: optimisticValue
|
|
693
|
+
});
|
|
694
|
+
yield apiService.seen(notificationId);
|
|
695
|
+
if (!optimisticValue) {
|
|
696
|
+
throw new Error("Failed to create optimistic value for notification");
|
|
697
|
+
}
|
|
698
|
+
const updatedNotification = new Notification(optimisticValue, emitter, apiService);
|
|
699
|
+
emitter.emit("notification.seen.resolved", { args, data: updatedNotification });
|
|
700
|
+
return { data: updatedNotification };
|
|
701
|
+
} catch (error) {
|
|
702
|
+
emitter.emit("notification.seen.resolved", { args, error });
|
|
703
|
+
return { error: new NovuError("Failed to mark notification as seen", error) };
|
|
704
|
+
}
|
|
705
|
+
});
|
|
644
706
|
var archive = (_0) => __async(void 0, [_0], function* ({
|
|
645
707
|
emitter,
|
|
646
708
|
apiService,
|
|
@@ -877,6 +939,42 @@ var readAll = (_0) => __async(void 0, [_0], function* ({
|
|
|
877
939
|
return { error: new NovuError("Failed to read all notifications", error) };
|
|
878
940
|
}
|
|
879
941
|
});
|
|
942
|
+
var seenAll = (_0) => __async(void 0, [_0], function* ({
|
|
943
|
+
emitter,
|
|
944
|
+
inboxService,
|
|
945
|
+
notificationsCache,
|
|
946
|
+
notificationIds,
|
|
947
|
+
tags,
|
|
948
|
+
data
|
|
949
|
+
}) {
|
|
950
|
+
try {
|
|
951
|
+
const notifications = notificationsCache.getUniqueNotifications({ tags, data });
|
|
952
|
+
const filteredNotifications = notificationIds && notificationIds.length > 0 ? notifications.filter((notification) => notificationIds.includes(notification.id)) : notifications;
|
|
953
|
+
const optimisticNotifications = filteredNotifications.map(
|
|
954
|
+
(notification) => new Notification(
|
|
955
|
+
__spreadProps(__spreadValues({}, notification), {
|
|
956
|
+
isSeen: true,
|
|
957
|
+
firstSeenAt: notification.firstSeenAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
958
|
+
}),
|
|
959
|
+
emitter,
|
|
960
|
+
inboxService
|
|
961
|
+
)
|
|
962
|
+
);
|
|
963
|
+
emitter.emit("notifications.seen_all.pending", {
|
|
964
|
+
args: { notificationIds, tags, data },
|
|
965
|
+
data: optimisticNotifications
|
|
966
|
+
});
|
|
967
|
+
yield inboxService.markAsSeen({ notificationIds, tags, data });
|
|
968
|
+
emitter.emit("notifications.seen_all.resolved", {
|
|
969
|
+
args: { notificationIds, tags, data },
|
|
970
|
+
data: optimisticNotifications
|
|
971
|
+
});
|
|
972
|
+
return {};
|
|
973
|
+
} catch (error) {
|
|
974
|
+
emitter.emit("notifications.seen_all.resolved", { args: { notificationIds, tags, data }, error });
|
|
975
|
+
return { error: new NovuError("Failed to mark all notifications as seen", error) };
|
|
976
|
+
}
|
|
977
|
+
});
|
|
880
978
|
var archiveAll = (_0) => __async(void 0, [_0], function* ({
|
|
881
979
|
emitter,
|
|
882
980
|
inboxService,
|
|
@@ -965,21 +1063,32 @@ var InMemoryCache = class {
|
|
|
965
1063
|
_cache = new WeakMap();
|
|
966
1064
|
|
|
967
1065
|
// src/cache/notifications-cache.ts
|
|
968
|
-
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]) => {
|
|
1066
|
+
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]) => {
|
|
969
1067
|
acc[key] = value;
|
|
970
1068
|
return acc;
|
|
971
1069
|
}, {});
|
|
972
|
-
var getCacheKey = ({
|
|
973
|
-
|
|
1070
|
+
var getCacheKey = ({
|
|
1071
|
+
tags,
|
|
1072
|
+
data,
|
|
1073
|
+
read: read2,
|
|
1074
|
+
archived,
|
|
1075
|
+
snoozed,
|
|
1076
|
+
seen: seen2,
|
|
1077
|
+
limit,
|
|
1078
|
+
offset,
|
|
1079
|
+
after
|
|
1080
|
+
}) => {
|
|
1081
|
+
return JSON.stringify(excludeEmpty({ tags, data, read: read2, archived, snoozed, seen: seen2, limit, offset, after }));
|
|
974
1082
|
};
|
|
975
1083
|
var getFilterKey = ({
|
|
976
1084
|
tags,
|
|
977
1085
|
data,
|
|
978
1086
|
read: read2,
|
|
979
1087
|
archived,
|
|
980
|
-
snoozed
|
|
1088
|
+
snoozed,
|
|
1089
|
+
seen: seen2
|
|
981
1090
|
}) => {
|
|
982
|
-
return JSON.stringify(excludeEmpty({ tags, data, read: read2, archived, snoozed }));
|
|
1091
|
+
return JSON.stringify(excludeEmpty({ tags, data, read: read2, archived, snoozed, seen: seen2 }));
|
|
983
1092
|
};
|
|
984
1093
|
var getFilter = (key) => {
|
|
985
1094
|
return JSON.parse(key);
|
|
@@ -1116,7 +1225,8 @@ var NotificationsCache = class {
|
|
|
1116
1225
|
data: args.data,
|
|
1117
1226
|
read: args.read,
|
|
1118
1227
|
snoozed: args.snoozed,
|
|
1119
|
-
archived: args.archived
|
|
1228
|
+
archived: args.archived,
|
|
1229
|
+
seen: args.seen
|
|
1120
1230
|
});
|
|
1121
1231
|
}
|
|
1122
1232
|
}
|
|
@@ -1176,6 +1286,9 @@ var Notifications = class extends BaseModule {
|
|
|
1176
1286
|
});
|
|
1177
1287
|
__privateSet(this, _useCache, useCache);
|
|
1178
1288
|
}
|
|
1289
|
+
get inboxService() {
|
|
1290
|
+
return this._inboxService;
|
|
1291
|
+
}
|
|
1179
1292
|
list() {
|
|
1180
1293
|
return __async(this, arguments, function* (_a = {}) {
|
|
1181
1294
|
var _b = _a, { limit = 10 } = _b, restOptions = __objRest(_b, ["limit"]);
|
|
@@ -1256,6 +1369,19 @@ var Notifications = class extends BaseModule {
|
|
|
1256
1369
|
);
|
|
1257
1370
|
});
|
|
1258
1371
|
}
|
|
1372
|
+
seen(args) {
|
|
1373
|
+
return __async(this, null, function* () {
|
|
1374
|
+
return this.callWithSession(
|
|
1375
|
+
() => __async(this, null, function* () {
|
|
1376
|
+
return seen({
|
|
1377
|
+
emitter: this._emitter,
|
|
1378
|
+
apiService: this._inboxService,
|
|
1379
|
+
args
|
|
1380
|
+
});
|
|
1381
|
+
})
|
|
1382
|
+
);
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1259
1385
|
archive(args) {
|
|
1260
1386
|
return __async(this, null, function* () {
|
|
1261
1387
|
return this.callWithSession(
|
|
@@ -1382,6 +1508,28 @@ var Notifications = class extends BaseModule {
|
|
|
1382
1508
|
);
|
|
1383
1509
|
});
|
|
1384
1510
|
}
|
|
1511
|
+
seenAll() {
|
|
1512
|
+
return __async(this, arguments, function* (args = {}) {
|
|
1513
|
+
return this.callWithSession(() => __async(this, null, function* () {
|
|
1514
|
+
if ("notificationIds" in args) {
|
|
1515
|
+
return seenAll({
|
|
1516
|
+
emitter: this._emitter,
|
|
1517
|
+
inboxService: this._inboxService,
|
|
1518
|
+
notificationsCache: this.cache,
|
|
1519
|
+
notificationIds: args.notificationIds
|
|
1520
|
+
});
|
|
1521
|
+
} else {
|
|
1522
|
+
return seenAll({
|
|
1523
|
+
emitter: this._emitter,
|
|
1524
|
+
inboxService: this._inboxService,
|
|
1525
|
+
notificationsCache: this.cache,
|
|
1526
|
+
tags: "tags" in args ? args.tags : void 0,
|
|
1527
|
+
data: "data" in args ? args.data : void 0
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
}));
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1385
1533
|
archiveAll() {
|
|
1386
1534
|
return __async(this, arguments, function* ({
|
|
1387
1535
|
tags,
|
|
@@ -1777,6 +1925,11 @@ var Preferences = class extends BaseModule {
|
|
|
1777
1925
|
};
|
|
1778
1926
|
_useCache3 = new WeakMap();
|
|
1779
1927
|
|
|
1928
|
+
// src/utils/is-browser.ts
|
|
1929
|
+
function isBrowser() {
|
|
1930
|
+
return typeof window !== "undefined";
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1780
1933
|
// src/session/session.ts
|
|
1781
1934
|
var _emitter5, _inboxService2, _options;
|
|
1782
1935
|
var Session = class {
|
|
@@ -1820,12 +1973,19 @@ var Session = class {
|
|
|
1820
1973
|
}
|
|
1821
1974
|
initialize(options) {
|
|
1822
1975
|
return __async(this, null, function* () {
|
|
1823
|
-
var _a, _b;
|
|
1976
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1977
|
+
if (((_a = __privateGet(this, _options).subscriber) == null ? void 0 : _a.subscriberId) === ((_b = options == null ? void 0 : options.subscriber) == null ? void 0 : _b.subscriberId)) {
|
|
1978
|
+
return;
|
|
1979
|
+
}
|
|
1824
1980
|
try {
|
|
1825
1981
|
if (options) {
|
|
1826
1982
|
__privateSet(this, _options, options);
|
|
1827
1983
|
}
|
|
1828
1984
|
const { subscriber, subscriberHash, applicationIdentifier } = __privateGet(this, _options);
|
|
1985
|
+
let currentTimezone;
|
|
1986
|
+
if (isBrowser()) {
|
|
1987
|
+
currentTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1988
|
+
}
|
|
1829
1989
|
let finalApplicationIdentifier = applicationIdentifier;
|
|
1830
1990
|
if (!finalApplicationIdentifier) {
|
|
1831
1991
|
const storedAppId = this.handleApplicationIdentifier("get");
|
|
@@ -1839,12 +1999,15 @@ var Session = class {
|
|
|
1839
1999
|
const response = yield __privateGet(this, _inboxService2).initializeSession({
|
|
1840
2000
|
applicationIdentifier: finalApplicationIdentifier,
|
|
1841
2001
|
subscriberHash,
|
|
1842
|
-
subscriber
|
|
2002
|
+
subscriber: __spreadProps(__spreadValues({}, subscriber), {
|
|
2003
|
+
subscriberId: (_c = subscriber == null ? void 0 : subscriber.subscriberId) != null ? _c : "",
|
|
2004
|
+
timezone: (_d = subscriber == null ? void 0 : subscriber.timezone) != null ? _d : currentTimezone
|
|
2005
|
+
})
|
|
1843
2006
|
});
|
|
1844
|
-
if ((
|
|
2007
|
+
if ((_e = response == null ? void 0 : response.applicationIdentifier) == null ? void 0 : _e.startsWith("pk_keyless_")) {
|
|
1845
2008
|
this.handleApplicationIdentifier("store", response.applicationIdentifier);
|
|
1846
2009
|
}
|
|
1847
|
-
if (!((
|
|
2010
|
+
if (!((_f = response == null ? void 0 : response.applicationIdentifier) == null ? void 0 : _f.startsWith("pk_keyless_"))) {
|
|
1848
2011
|
this.handleApplicationIdentifier("delete");
|
|
1849
2012
|
}
|
|
1850
2013
|
__privateGet(this, _emitter5).emit("session.initialize.resolved", { args: __privateGet(this, _options), data: response });
|
|
@@ -1865,11 +2028,13 @@ var mapToNotification = ({
|
|
|
1865
2028
|
_id,
|
|
1866
2029
|
content,
|
|
1867
2030
|
read: read2,
|
|
2031
|
+
seen: seen2,
|
|
1868
2032
|
archived,
|
|
1869
2033
|
snoozedUntil,
|
|
1870
2034
|
deliveredAt,
|
|
1871
2035
|
createdAt,
|
|
1872
2036
|
lastReadDate,
|
|
2037
|
+
firstSeenDate,
|
|
1873
2038
|
archivedAt,
|
|
1874
2039
|
channel,
|
|
1875
2040
|
subscriber,
|
|
@@ -1903,6 +2068,7 @@ var mapToNotification = ({
|
|
|
1903
2068
|
body: content,
|
|
1904
2069
|
to,
|
|
1905
2070
|
isRead: read2,
|
|
2071
|
+
isSeen: seen2,
|
|
1906
2072
|
isArchived: archived,
|
|
1907
2073
|
isSnoozed: !!snoozedUntil
|
|
1908
2074
|
}, deliveredAt && {
|
|
@@ -1912,6 +2078,7 @@ var mapToNotification = ({
|
|
|
1912
2078
|
}), {
|
|
1913
2079
|
createdAt,
|
|
1914
2080
|
readAt: lastReadDate,
|
|
2081
|
+
firstSeenAt: firstSeenDate,
|
|
1915
2082
|
archivedAt,
|
|
1916
2083
|
avatar,
|
|
1917
2084
|
primaryAction: primaryCta && {
|
|
@@ -2061,11 +2228,13 @@ var mapToNotification2 = ({
|
|
|
2061
2228
|
_id,
|
|
2062
2229
|
content,
|
|
2063
2230
|
read: read2,
|
|
2231
|
+
seen: seen2,
|
|
2064
2232
|
archived,
|
|
2065
2233
|
snoozedUntil,
|
|
2066
2234
|
deliveredAt,
|
|
2067
2235
|
createdAt,
|
|
2068
2236
|
lastReadDate,
|
|
2237
|
+
firstSeenDate,
|
|
2069
2238
|
archivedAt,
|
|
2070
2239
|
channel,
|
|
2071
2240
|
subscriber,
|
|
@@ -2099,6 +2268,7 @@ var mapToNotification2 = ({
|
|
|
2099
2268
|
body: content,
|
|
2100
2269
|
to,
|
|
2101
2270
|
isRead: read2,
|
|
2271
|
+
isSeen: seen2,
|
|
2102
2272
|
isArchived: archived,
|
|
2103
2273
|
isSnoozed: !!snoozedUntil
|
|
2104
2274
|
}, deliveredAt && {
|
|
@@ -2108,6 +2278,7 @@ var mapToNotification2 = ({
|
|
|
2108
2278
|
}), {
|
|
2109
2279
|
createdAt,
|
|
2110
2280
|
readAt: lastReadDate,
|
|
2281
|
+
firstSeenAt: firstSeenDate,
|
|
2111
2282
|
archivedAt,
|
|
2112
2283
|
avatar,
|
|
2113
2284
|
primaryAction: primaryCta && {
|
|
@@ -2325,13 +2496,12 @@ function createSocket({
|
|
|
2325
2496
|
}
|
|
2326
2497
|
|
|
2327
2498
|
// src/novu.ts
|
|
2328
|
-
var _emitter8, _session, _inboxService3
|
|
2499
|
+
var _emitter8, _session, _inboxService3;
|
|
2329
2500
|
var Novu = class {
|
|
2330
2501
|
constructor(options) {
|
|
2331
2502
|
__privateAdd(this, _emitter8);
|
|
2332
2503
|
__privateAdd(this, _session);
|
|
2333
2504
|
__privateAdd(this, _inboxService3);
|
|
2334
|
-
__privateAdd(this, _currentSubscriberId);
|
|
2335
2505
|
var _a, _b;
|
|
2336
2506
|
__privateSet(this, _inboxService3, new InboxService({
|
|
2337
2507
|
apiUrl: options.apiUrl || options.backendUrl,
|
|
@@ -2342,13 +2512,11 @@ var Novu = class {
|
|
|
2342
2512
|
{
|
|
2343
2513
|
applicationIdentifier: options.applicationIdentifier || "",
|
|
2344
2514
|
subscriberHash: options.subscriberHash,
|
|
2345
|
-
subscriber: buildSubscriber(options)
|
|
2515
|
+
subscriber: buildSubscriber({ subscriberId: options.subscriberId, subscriber: options.subscriber })
|
|
2346
2516
|
},
|
|
2347
2517
|
__privateGet(this, _inboxService3),
|
|
2348
2518
|
__privateGet(this, _emitter8)
|
|
2349
2519
|
));
|
|
2350
|
-
const initialSubscriber = buildSubscriber(options);
|
|
2351
|
-
__privateSet(this, _currentSubscriberId, initialSubscriber.subscriberId);
|
|
2352
2520
|
__privateGet(this, _session).initialize();
|
|
2353
2521
|
this.notifications = new Notifications({
|
|
2354
2522
|
useCache: (_a = options.useCache) != null ? _a : true,
|
|
@@ -2386,30 +2554,16 @@ var Novu = class {
|
|
|
2386
2554
|
}
|
|
2387
2555
|
changeSubscriber(options) {
|
|
2388
2556
|
return __async(this, null, function* () {
|
|
2389
|
-
if (__privateGet(this, _currentSubscriberId) === options.subscriber.subscriberId) {
|
|
2390
|
-
return;
|
|
2391
|
-
}
|
|
2392
2557
|
yield __privateGet(this, _session).initialize({
|
|
2393
2558
|
applicationIdentifier: __privateGet(this, _session).applicationIdentifier || "",
|
|
2394
2559
|
subscriberHash: options.subscriberHash,
|
|
2395
2560
|
subscriber: options.subscriber
|
|
2396
2561
|
});
|
|
2397
|
-
__privateSet(this, _currentSubscriberId, options.subscriber.subscriberId);
|
|
2398
2562
|
});
|
|
2399
2563
|
}
|
|
2400
2564
|
};
|
|
2401
2565
|
_emitter8 = new WeakMap();
|
|
2402
2566
|
_session = new WeakMap();
|
|
2403
2567
|
_inboxService3 = new WeakMap();
|
|
2404
|
-
_currentSubscriberId = new WeakMap();
|
|
2405
|
-
function buildSubscriber(options) {
|
|
2406
|
-
if (options.subscriber) {
|
|
2407
|
-
return typeof options.subscriber === "string" ? { subscriberId: options.subscriber } : options.subscriber;
|
|
2408
|
-
}
|
|
2409
|
-
if (options.subscriberId) {
|
|
2410
|
-
return { subscriberId: options.subscriberId };
|
|
2411
|
-
}
|
|
2412
|
-
return { subscriberId: "" };
|
|
2413
|
-
}
|
|
2414
2568
|
|
|
2415
|
-
export { ChannelType, DEFAULT_API_VERSION, NotificationStatus, Novu, PreferenceLevel, WebSocketEvent, areTagsEqual, isSameFilter };
|
|
2569
|
+
export { ChannelType, DEFAULT_API_VERSION, NotificationStatus, Novu, PreferenceLevel, WebSocketEvent, areTagsEqual, isBrowser, isSameFilter };
|
|
@@ -30,4 +30,18 @@ var parseMarkdownIntoTokens = (text) => {
|
|
|
30
30
|
return tokens;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
// src/ui/internal/buildSubscriber.ts
|
|
34
|
+
function buildSubscriber({
|
|
35
|
+
subscriberId,
|
|
36
|
+
subscriber
|
|
37
|
+
}) {
|
|
38
|
+
if (subscriber) {
|
|
39
|
+
return typeof subscriber === "string" ? { subscriberId: subscriber } : subscriber;
|
|
40
|
+
}
|
|
41
|
+
if (subscriberId) {
|
|
42
|
+
return { subscriberId };
|
|
43
|
+
}
|
|
44
|
+
return { subscriberId: "" };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { buildSubscriber, parseMarkdownIntoTokens };
|
package/dist/esm/index.d.mts
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-DiZKRUW5.mjs';
|
|
2
|
+
import { N as NotificationFilter } from './types-Y8PRbRbj.mjs';
|
|
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.mjs';
|
|
3
4
|
|
|
4
5
|
declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
|
|
5
6
|
declare const isSameFilter: (filter1: NotificationFilter, filter2: NotificationFilter) => boolean;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { ChannelType, NotificationStatus, Novu, PreferenceLevel, WebSocketEvent, areTagsEqual, isSameFilter } from './chunk-
|
|
1
|
+
export { ChannelType, NotificationStatus, Novu, PreferenceLevel, WebSocketEvent, areTagsEqual, isSameFilter } from './chunk-AIY4HF7H.mjs';
|
|
2
|
+
import './chunk-KYYDDVBR.mjs';
|
|
2
3
|
import './chunk-STZMOEWR.mjs';
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { f as Subscriber } from '../types-Y8PRbRbj.mjs';
|
|
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,2 +1,2 @@
|
|
|
1
|
-
export { parseMarkdownIntoTokens } from '../chunk-
|
|
1
|
+
export { buildSubscriber, parseMarkdownIntoTokens } from '../chunk-KYYDDVBR.mjs';
|
|
2
2
|
import '../chunk-STZMOEWR.mjs';
|