@novu/js 3.7.0 → 3.8.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.
@@ -1,8 +1,8 @@
1
- import { buildSubscriber } from './chunk-KYYDDVBR.mjs';
1
+ import { buildSubscriber } from './chunk-QOD7NZ77.mjs';
2
2
  import { __privateAdd, __privateSet, __privateGet, __async, __objRest, __spreadValues, __spreadProps, __privateMethod } from './chunk-STZMOEWR.mjs';
3
3
  import mitt from 'mitt';
4
- import io from 'socket.io-client';
5
4
  import { WebSocket } from 'partysocket';
5
+ import io from 'socket.io-client';
6
6
 
7
7
  // src/types.ts
8
8
  var NotificationStatus = /* @__PURE__ */ ((NotificationStatus2) => {
@@ -66,10 +66,63 @@ var areDataEqual = (data1, data2) => {
66
66
  var isSameFilter = (filter1, filter2) => {
67
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;
68
68
  };
69
+ function checkNotificationDataFilter(notificationData, filterData) {
70
+ if (!filterData || Object.keys(filterData).length === 0) {
71
+ return true;
72
+ }
73
+ if (!notificationData) {
74
+ return false;
75
+ }
76
+ return Object.entries(filterData).every(([key, filterValue]) => {
77
+ const notifValue = notificationData[key];
78
+ if (notifValue === void 0 && filterValue !== void 0) {
79
+ return false;
80
+ }
81
+ if (Array.isArray(filterValue)) {
82
+ if (Array.isArray(notifValue)) {
83
+ if (filterValue.length !== notifValue.length) return false;
84
+ const sortedFilterValue = [...filterValue].sort();
85
+ const sortedNotifValue = [...notifValue].sort();
86
+ return sortedFilterValue.every((val, index) => val === sortedNotifValue[index]);
87
+ } else {
88
+ return filterValue.includes(notifValue);
89
+ }
90
+ } else {
91
+ return notifValue === filterValue;
92
+ }
93
+ });
94
+ }
95
+ function checkNotificationTagFilter(notificationTags, filterTags) {
96
+ if (!filterTags || filterTags.length === 0) {
97
+ return true;
98
+ }
99
+ if (!notificationTags || notificationTags.length === 0) {
100
+ return false;
101
+ }
102
+ return filterTags.some((tag) => notificationTags.includes(tag));
103
+ }
104
+ function checkBasicFilters(notification, filter) {
105
+ if (filter.read !== void 0 && notification.isRead !== filter.read) {
106
+ return false;
107
+ }
108
+ if (filter.seen !== void 0 && notification.isSeen !== filter.seen) {
109
+ return false;
110
+ }
111
+ if (filter.archived !== void 0 && notification.isArchived !== filter.archived) {
112
+ return false;
113
+ }
114
+ if (filter.snoozed !== void 0 && notification.isSnoozed !== filter.snoozed) {
115
+ return false;
116
+ }
117
+ return true;
118
+ }
119
+ function checkNotificationMatchesFilter(notification, filter) {
120
+ return checkBasicFilters(notification, filter) && checkNotificationTagFilter(notification.tags, filter.tags) && checkNotificationDataFilter(notification.data, filter.data);
121
+ }
69
122
 
70
123
  // src/api/http-client.ts
71
124
  var DEFAULT_API_VERSION = "v1";
72
- var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.7.0"}`;
125
+ var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.8.0"}`;
73
126
  var HttpClient = class {
74
127
  constructor(options = {}) {
75
128
  // Environment variable for local development that overrides the default API endpoint without affecting the Inbox DX
@@ -393,219 +446,6 @@ var NovuError = class extends Error {
393
446
  }
394
447
  };
395
448
 
396
- // src/base-module.ts
397
- var _callsQueue, _sessionError;
398
- var BaseModule = class {
399
- constructor({
400
- inboxServiceInstance,
401
- eventEmitterInstance
402
- }) {
403
- __privateAdd(this, _callsQueue, []);
404
- __privateAdd(this, _sessionError);
405
- this._emitter = eventEmitterInstance;
406
- this._inboxService = inboxServiceInstance;
407
- this._emitter.on("session.initialize.resolved", ({ error, data }) => {
408
- if (data) {
409
- this.onSessionSuccess(data);
410
- __privateGet(this, _callsQueue).forEach((_0) => __async(this, [_0], function* ({ fn, resolve }) {
411
- resolve(yield fn());
412
- }));
413
- __privateSet(this, _callsQueue, []);
414
- } else if (error) {
415
- this.onSessionError(error);
416
- __privateSet(this, _sessionError, error);
417
- __privateGet(this, _callsQueue).forEach(({ resolve }) => {
418
- resolve({ error: new NovuError("Failed to initialize session, please contact the support", error) });
419
- });
420
- __privateSet(this, _callsQueue, []);
421
- }
422
- });
423
- }
424
- onSessionSuccess(_) {
425
- }
426
- onSessionError(_) {
427
- }
428
- callWithSession(fn) {
429
- return __async(this, null, function* () {
430
- if (this._inboxService.isSessionInitialized) {
431
- return fn();
432
- }
433
- if (__privateGet(this, _sessionError)) {
434
- return Promise.resolve({
435
- error: new NovuError("Failed to initialize session, please contact the support", __privateGet(this, _sessionError))
436
- });
437
- }
438
- return new Promise((resolve, reject) => {
439
- __privateGet(this, _callsQueue).push({ fn, resolve, reject });
440
- });
441
- });
442
- }
443
- };
444
- _callsQueue = new WeakMap();
445
- _sessionError = new WeakMap();
446
-
447
- // src/notifications/notification.ts
448
- var _emitter, _inboxService;
449
- var Notification = class {
450
- constructor(notification, emitter, inboxService) {
451
- __privateAdd(this, _emitter);
452
- __privateAdd(this, _inboxService);
453
- __privateSet(this, _emitter, emitter);
454
- __privateSet(this, _inboxService, inboxService);
455
- this.id = notification.id;
456
- this.subject = notification.subject;
457
- this.body = notification.body;
458
- this.to = notification.to;
459
- this.isRead = notification.isRead;
460
- this.isSeen = notification.isSeen;
461
- this.isArchived = notification.isArchived;
462
- this.isSnoozed = notification.isSnoozed;
463
- this.snoozedUntil = notification.snoozedUntil;
464
- this.deliveredAt = notification.deliveredAt;
465
- this.createdAt = notification.createdAt;
466
- this.readAt = notification.readAt;
467
- this.firstSeenAt = notification.firstSeenAt;
468
- this.archivedAt = notification.archivedAt;
469
- this.avatar = notification.avatar;
470
- this.primaryAction = notification.primaryAction;
471
- this.secondaryAction = notification.secondaryAction;
472
- this.channelType = notification.channelType;
473
- this.tags = notification.tags;
474
- this.redirect = notification.redirect;
475
- this.data = notification.data;
476
- this.workflow = notification.workflow;
477
- }
478
- read() {
479
- return read({
480
- emitter: __privateGet(this, _emitter),
481
- apiService: __privateGet(this, _inboxService),
482
- args: {
483
- notification: this
484
- }
485
- });
486
- }
487
- unread() {
488
- return unread({
489
- emitter: __privateGet(this, _emitter),
490
- apiService: __privateGet(this, _inboxService),
491
- args: {
492
- notification: this
493
- }
494
- });
495
- }
496
- seen() {
497
- return seen({
498
- emitter: __privateGet(this, _emitter),
499
- apiService: __privateGet(this, _inboxService),
500
- args: {
501
- notification: this
502
- }
503
- });
504
- }
505
- archive() {
506
- return archive({
507
- emitter: __privateGet(this, _emitter),
508
- apiService: __privateGet(this, _inboxService),
509
- args: {
510
- notification: this
511
- }
512
- });
513
- }
514
- unarchive() {
515
- return unarchive({
516
- emitter: __privateGet(this, _emitter),
517
- apiService: __privateGet(this, _inboxService),
518
- args: {
519
- notification: this
520
- }
521
- });
522
- }
523
- snooze(snoozeUntil) {
524
- return snooze({
525
- emitter: __privateGet(this, _emitter),
526
- apiService: __privateGet(this, _inboxService),
527
- args: {
528
- notification: this,
529
- snoozeUntil
530
- }
531
- });
532
- }
533
- unsnooze() {
534
- return unsnooze({
535
- emitter: __privateGet(this, _emitter),
536
- apiService: __privateGet(this, _inboxService),
537
- args: { notification: this }
538
- });
539
- }
540
- completePrimary() {
541
- if (!this.primaryAction) {
542
- throw new Error("Primary action is not available");
543
- }
544
- return completeAction({
545
- emitter: __privateGet(this, _emitter),
546
- apiService: __privateGet(this, _inboxService),
547
- args: {
548
- notification: this
549
- },
550
- actionType: "primary" /* PRIMARY */
551
- });
552
- }
553
- completeSecondary() {
554
- if (!this.primaryAction) {
555
- throw new Error("Secondary action is not available");
556
- }
557
- return completeAction({
558
- emitter: __privateGet(this, _emitter),
559
- apiService: __privateGet(this, _inboxService),
560
- args: {
561
- notification: this
562
- },
563
- actionType: "secondary" /* SECONDARY */
564
- });
565
- }
566
- revertPrimary() {
567
- if (!this.primaryAction) {
568
- throw new Error("Primary action is not available");
569
- }
570
- return revertAction({
571
- emitter: __privateGet(this, _emitter),
572
- apiService: __privateGet(this, _inboxService),
573
- args: {
574
- notification: this
575
- },
576
- actionType: "primary" /* PRIMARY */
577
- });
578
- }
579
- revertSecondary() {
580
- if (!this.primaryAction) {
581
- throw new Error("Secondary action is not available");
582
- }
583
- return revertAction({
584
- emitter: __privateGet(this, _emitter),
585
- apiService: __privateGet(this, _inboxService),
586
- args: {
587
- notification: this
588
- },
589
- actionType: "secondary" /* SECONDARY */
590
- });
591
- }
592
- on(eventName, listener) {
593
- const cleanup = __privateGet(this, _emitter).on(eventName, listener);
594
- return () => {
595
- cleanup();
596
- };
597
- }
598
- /**
599
- * @deprecated
600
- * Use the cleanup function returned by the "on" method instead.
601
- */
602
- off(eventName, listener) {
603
- __privateGet(this, _emitter).off(eventName, listener);
604
- }
605
- };
606
- _emitter = new WeakMap();
607
- _inboxService = new WeakMap();
608
-
609
449
  // src/notifications/helpers.ts
610
450
  var read = (_0) => __async(void 0, [_0], function* ({
611
451
  emitter,
@@ -1031,22 +871,235 @@ var archiveAllRead = (_0) => __async(void 0, [_0], function* ({
1031
871
  }
1032
872
  });
1033
873
 
1034
- // src/cache/in-memory-cache.ts
1035
- var _cache;
1036
- var InMemoryCache = class {
1037
- constructor() {
1038
- __privateAdd(this, _cache);
1039
- __privateSet(this, _cache, /* @__PURE__ */ new Map());
1040
- }
1041
- get(key) {
1042
- return __privateGet(this, _cache).get(key);
1043
- }
1044
- getValues() {
1045
- return Array.from(__privateGet(this, _cache).values());
1046
- }
1047
- entries() {
1048
- return Array.from(__privateGet(this, _cache).entries());
1049
- }
874
+ // src/notifications/notification.ts
875
+ var _emitter, _inboxService;
876
+ var Notification = class {
877
+ constructor(notification, emitter, inboxService) {
878
+ __privateAdd(this, _emitter);
879
+ __privateAdd(this, _inboxService);
880
+ __privateSet(this, _emitter, emitter);
881
+ __privateSet(this, _inboxService, inboxService);
882
+ this.id = notification.id;
883
+ this.subject = notification.subject;
884
+ this.body = notification.body;
885
+ this.to = notification.to;
886
+ this.isRead = notification.isRead;
887
+ this.isSeen = notification.isSeen;
888
+ this.isArchived = notification.isArchived;
889
+ this.isSnoozed = notification.isSnoozed;
890
+ this.snoozedUntil = notification.snoozedUntil;
891
+ this.deliveredAt = notification.deliveredAt;
892
+ this.createdAt = notification.createdAt;
893
+ this.readAt = notification.readAt;
894
+ this.firstSeenAt = notification.firstSeenAt;
895
+ this.archivedAt = notification.archivedAt;
896
+ this.avatar = notification.avatar;
897
+ this.primaryAction = notification.primaryAction;
898
+ this.secondaryAction = notification.secondaryAction;
899
+ this.channelType = notification.channelType;
900
+ this.tags = notification.tags;
901
+ this.redirect = notification.redirect;
902
+ this.data = notification.data;
903
+ this.workflow = notification.workflow;
904
+ }
905
+ read() {
906
+ return read({
907
+ emitter: __privateGet(this, _emitter),
908
+ apiService: __privateGet(this, _inboxService),
909
+ args: {
910
+ notification: this
911
+ }
912
+ });
913
+ }
914
+ unread() {
915
+ return unread({
916
+ emitter: __privateGet(this, _emitter),
917
+ apiService: __privateGet(this, _inboxService),
918
+ args: {
919
+ notification: this
920
+ }
921
+ });
922
+ }
923
+ seen() {
924
+ return seen({
925
+ emitter: __privateGet(this, _emitter),
926
+ apiService: __privateGet(this, _inboxService),
927
+ args: {
928
+ notification: this
929
+ }
930
+ });
931
+ }
932
+ archive() {
933
+ return archive({
934
+ emitter: __privateGet(this, _emitter),
935
+ apiService: __privateGet(this, _inboxService),
936
+ args: {
937
+ notification: this
938
+ }
939
+ });
940
+ }
941
+ unarchive() {
942
+ return unarchive({
943
+ emitter: __privateGet(this, _emitter),
944
+ apiService: __privateGet(this, _inboxService),
945
+ args: {
946
+ notification: this
947
+ }
948
+ });
949
+ }
950
+ snooze(snoozeUntil) {
951
+ return snooze({
952
+ emitter: __privateGet(this, _emitter),
953
+ apiService: __privateGet(this, _inboxService),
954
+ args: {
955
+ notification: this,
956
+ snoozeUntil
957
+ }
958
+ });
959
+ }
960
+ unsnooze() {
961
+ return unsnooze({
962
+ emitter: __privateGet(this, _emitter),
963
+ apiService: __privateGet(this, _inboxService),
964
+ args: { notification: this }
965
+ });
966
+ }
967
+ completePrimary() {
968
+ if (!this.primaryAction) {
969
+ throw new Error("Primary action is not available");
970
+ }
971
+ return completeAction({
972
+ emitter: __privateGet(this, _emitter),
973
+ apiService: __privateGet(this, _inboxService),
974
+ args: {
975
+ notification: this
976
+ },
977
+ actionType: "primary" /* PRIMARY */
978
+ });
979
+ }
980
+ completeSecondary() {
981
+ if (!this.primaryAction) {
982
+ throw new Error("Secondary action is not available");
983
+ }
984
+ return completeAction({
985
+ emitter: __privateGet(this, _emitter),
986
+ apiService: __privateGet(this, _inboxService),
987
+ args: {
988
+ notification: this
989
+ },
990
+ actionType: "secondary" /* SECONDARY */
991
+ });
992
+ }
993
+ revertPrimary() {
994
+ if (!this.primaryAction) {
995
+ throw new Error("Primary action is not available");
996
+ }
997
+ return revertAction({
998
+ emitter: __privateGet(this, _emitter),
999
+ apiService: __privateGet(this, _inboxService),
1000
+ args: {
1001
+ notification: this
1002
+ },
1003
+ actionType: "primary" /* PRIMARY */
1004
+ });
1005
+ }
1006
+ revertSecondary() {
1007
+ if (!this.primaryAction) {
1008
+ throw new Error("Secondary action is not available");
1009
+ }
1010
+ return revertAction({
1011
+ emitter: __privateGet(this, _emitter),
1012
+ apiService: __privateGet(this, _inboxService),
1013
+ args: {
1014
+ notification: this
1015
+ },
1016
+ actionType: "secondary" /* SECONDARY */
1017
+ });
1018
+ }
1019
+ on(eventName, listener) {
1020
+ const cleanup = __privateGet(this, _emitter).on(eventName, listener);
1021
+ return () => {
1022
+ cleanup();
1023
+ };
1024
+ }
1025
+ /**
1026
+ * @deprecated
1027
+ * Use the cleanup function returned by the "on" method instead.
1028
+ */
1029
+ off(eventName, listener) {
1030
+ __privateGet(this, _emitter).off(eventName, listener);
1031
+ }
1032
+ };
1033
+ _emitter = new WeakMap();
1034
+ _inboxService = new WeakMap();
1035
+
1036
+ // src/base-module.ts
1037
+ var _callsQueue, _sessionError;
1038
+ var BaseModule = class {
1039
+ constructor({
1040
+ inboxServiceInstance,
1041
+ eventEmitterInstance
1042
+ }) {
1043
+ __privateAdd(this, _callsQueue, []);
1044
+ __privateAdd(this, _sessionError);
1045
+ this._emitter = eventEmitterInstance;
1046
+ this._inboxService = inboxServiceInstance;
1047
+ this._emitter.on("session.initialize.resolved", ({ error, data }) => {
1048
+ if (data) {
1049
+ this.onSessionSuccess(data);
1050
+ __privateGet(this, _callsQueue).forEach((_0) => __async(this, [_0], function* ({ fn, resolve }) {
1051
+ resolve(yield fn());
1052
+ }));
1053
+ __privateSet(this, _callsQueue, []);
1054
+ } else if (error) {
1055
+ this.onSessionError(error);
1056
+ __privateSet(this, _sessionError, error);
1057
+ __privateGet(this, _callsQueue).forEach(({ resolve }) => {
1058
+ resolve({ error: new NovuError("Failed to initialize session, please contact the support", error) });
1059
+ });
1060
+ __privateSet(this, _callsQueue, []);
1061
+ }
1062
+ });
1063
+ }
1064
+ onSessionSuccess(_) {
1065
+ }
1066
+ onSessionError(_) {
1067
+ }
1068
+ callWithSession(fn) {
1069
+ return __async(this, null, function* () {
1070
+ if (this._inboxService.isSessionInitialized) {
1071
+ return fn();
1072
+ }
1073
+ if (__privateGet(this, _sessionError)) {
1074
+ return Promise.resolve({
1075
+ error: new NovuError("Failed to initialize session, please contact the support", __privateGet(this, _sessionError))
1076
+ });
1077
+ }
1078
+ return new Promise((resolve, reject) => {
1079
+ __privateGet(this, _callsQueue).push({ fn, resolve, reject });
1080
+ });
1081
+ });
1082
+ }
1083
+ };
1084
+ _callsQueue = new WeakMap();
1085
+ _sessionError = new WeakMap();
1086
+
1087
+ // src/cache/in-memory-cache.ts
1088
+ var _cache;
1089
+ var InMemoryCache = class {
1090
+ constructor() {
1091
+ __privateAdd(this, _cache);
1092
+ __privateSet(this, _cache, /* @__PURE__ */ new Map());
1093
+ }
1094
+ get(key) {
1095
+ return __privateGet(this, _cache).get(key);
1096
+ }
1097
+ getValues() {
1098
+ return Array.from(__privateGet(this, _cache).values());
1099
+ }
1100
+ entries() {
1101
+ return Array.from(__privateGet(this, _cache).entries());
1102
+ }
1050
1103
  keys() {
1051
1104
  return Array.from(__privateGet(this, _cache).keys());
1052
1105
  }
@@ -1549,10 +1602,7 @@ var Notifications = class extends BaseModule {
1549
1602
  });
1550
1603
  }
1551
1604
  archiveAllRead() {
1552
- return __async(this, arguments, function* ({
1553
- tags,
1554
- data
1555
- } = {}) {
1605
+ return __async(this, arguments, function* ({ tags, data } = {}) {
1556
1606
  return this.callWithSession(
1557
1607
  () => __async(this, null, function* () {
1558
1608
  return archiveAllRead({
@@ -1580,29 +1630,162 @@ var Notifications = class extends BaseModule {
1580
1630
  };
1581
1631
  _useCache = new WeakMap();
1582
1632
 
1583
- // src/preferences/helpers.ts
1584
- var updatePreference = (_0) => __async(void 0, [_0], function* ({
1585
- emitter,
1586
- apiService,
1587
- cache,
1588
- useCache,
1589
- args
1590
- }) {
1591
- var _a;
1592
- const { channels } = args;
1593
- const workflowId = "workflowId" in args ? args.workflowId : (_a = args.preference.workflow) == null ? void 0 : _a.id;
1594
- try {
1595
- emitter.emit("preference.update.pending", {
1596
- args,
1597
- data: "preference" in args ? new Preference(
1598
- __spreadProps(__spreadValues({}, args.preference), {
1599
- channels: __spreadValues(__spreadValues({}, args.preference.channels), channels)
1600
- }),
1601
- {
1602
- emitterInstance: emitter,
1603
- inboxServiceInstance: apiService,
1604
- cache,
1605
- useCache
1633
+ // src/cache/preferences-cache.ts
1634
+ var updateEvents2 = [
1635
+ "preference.update.pending",
1636
+ "preference.update.resolved",
1637
+ "preferences.bulk_update.pending",
1638
+ "preferences.bulk_update.resolved"
1639
+ ];
1640
+ var excludeEmpty2 = ({ tags }) => Object.entries({ tags }).reduce((acc, [key, value]) => {
1641
+ if (value === null || value === void 0 || Array.isArray(value) && value.length === 0) {
1642
+ return acc;
1643
+ }
1644
+ acc[key] = value;
1645
+ return acc;
1646
+ }, {});
1647
+ var getCacheKey2 = ({ tags }) => {
1648
+ return JSON.stringify(excludeEmpty2({ tags }));
1649
+ };
1650
+ var _emitter3, _cache3;
1651
+ var PreferencesCache = class {
1652
+ constructor({ emitterInstance }) {
1653
+ __privateAdd(this, _emitter3);
1654
+ __privateAdd(this, _cache3);
1655
+ this.updatePreference = (key, data) => {
1656
+ const preferences = __privateGet(this, _cache3).get(key);
1657
+ if (!preferences) {
1658
+ return false;
1659
+ }
1660
+ const index = preferences.findIndex(
1661
+ (el) => {
1662
+ var _a, _b;
1663
+ return ((_a = el.workflow) == null ? void 0 : _a.id) === ((_b = data.workflow) == null ? void 0 : _b.id) || el.level === data.level && data.level === "global" /* GLOBAL */;
1664
+ }
1665
+ );
1666
+ if (index === -1) {
1667
+ return false;
1668
+ }
1669
+ const updatedPreferences = [...preferences];
1670
+ updatedPreferences[index] = data;
1671
+ __privateGet(this, _cache3).set(key, updatedPreferences);
1672
+ return true;
1673
+ };
1674
+ this.handlePreferenceEvent = ({ data }) => {
1675
+ if (!data) {
1676
+ return;
1677
+ }
1678
+ const preferences = Array.isArray(data) ? data : [data];
1679
+ const uniqueFilterKeys = /* @__PURE__ */ new Set();
1680
+ __privateGet(this, _cache3).keys().forEach((key) => {
1681
+ preferences.forEach((preference) => {
1682
+ const hasUpdatedPreference = this.updatePreference(key, preference);
1683
+ const updatedPreference = __privateGet(this, _cache3).get(key);
1684
+ if (!hasUpdatedPreference || !updatedPreference) {
1685
+ return;
1686
+ }
1687
+ uniqueFilterKeys.add(key);
1688
+ });
1689
+ });
1690
+ uniqueFilterKeys.forEach((key) => {
1691
+ var _a;
1692
+ __privateGet(this, _emitter3).emit("preferences.list.updated", {
1693
+ data: (_a = __privateGet(this, _cache3).get(key)) != null ? _a : []
1694
+ });
1695
+ });
1696
+ };
1697
+ __privateSet(this, _emitter3, emitterInstance);
1698
+ updateEvents2.forEach((event) => {
1699
+ __privateGet(this, _emitter3).on(event, this.handlePreferenceEvent);
1700
+ });
1701
+ __privateSet(this, _cache3, new InMemoryCache());
1702
+ }
1703
+ has(args) {
1704
+ return __privateGet(this, _cache3).get(getCacheKey2(args)) !== void 0;
1705
+ }
1706
+ set(args, data) {
1707
+ __privateGet(this, _cache3).set(getCacheKey2(args), data);
1708
+ }
1709
+ getAll(args) {
1710
+ if (this.has(args)) {
1711
+ return __privateGet(this, _cache3).get(getCacheKey2(args));
1712
+ }
1713
+ }
1714
+ clearAll() {
1715
+ __privateGet(this, _cache3).clear();
1716
+ }
1717
+ };
1718
+ _emitter3 = new WeakMap();
1719
+ _cache3 = new WeakMap();
1720
+
1721
+ // src/preferences/preference.ts
1722
+ var _emitter4, _apiService, _cache4, _useCache2;
1723
+ var Preference = class {
1724
+ constructor(preference, {
1725
+ emitterInstance,
1726
+ inboxServiceInstance,
1727
+ cache,
1728
+ useCache
1729
+ }) {
1730
+ __privateAdd(this, _emitter4);
1731
+ __privateAdd(this, _apiService);
1732
+ __privateAdd(this, _cache4);
1733
+ __privateAdd(this, _useCache2);
1734
+ __privateSet(this, _emitter4, emitterInstance);
1735
+ __privateSet(this, _apiService, inboxServiceInstance);
1736
+ __privateSet(this, _cache4, cache);
1737
+ __privateSet(this, _useCache2, useCache);
1738
+ this.level = preference.level;
1739
+ this.enabled = preference.enabled;
1740
+ this.channels = preference.channels;
1741
+ this.workflow = preference.workflow;
1742
+ }
1743
+ update({
1744
+ channels,
1745
+ channelPreferences
1746
+ }) {
1747
+ var _a;
1748
+ return updatePreference({
1749
+ emitter: __privateGet(this, _emitter4),
1750
+ apiService: __privateGet(this, _apiService),
1751
+ cache: __privateGet(this, _cache4),
1752
+ useCache: __privateGet(this, _useCache2),
1753
+ args: {
1754
+ workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
1755
+ channels: channels || channelPreferences,
1756
+ preference: this
1757
+ }
1758
+ });
1759
+ }
1760
+ };
1761
+ _emitter4 = new WeakMap();
1762
+ _apiService = new WeakMap();
1763
+ _cache4 = new WeakMap();
1764
+ _useCache2 = new WeakMap();
1765
+
1766
+ // src/preferences/helpers.ts
1767
+ var updatePreference = (_0) => __async(void 0, [_0], function* ({
1768
+ emitter,
1769
+ apiService,
1770
+ cache,
1771
+ useCache,
1772
+ args
1773
+ }) {
1774
+ var _a;
1775
+ const { channels } = args;
1776
+ const workflowId = "workflowId" in args ? args.workflowId : (_a = args.preference.workflow) == null ? void 0 : _a.id;
1777
+ try {
1778
+ emitter.emit("preference.update.pending", {
1779
+ args,
1780
+ data: "preference" in args ? new Preference(
1781
+ __spreadProps(__spreadValues({}, args.preference), {
1782
+ channels: __spreadValues(__spreadValues({}, args.preference.channels), channels)
1783
+ }),
1784
+ {
1785
+ emitterInstance: emitter,
1786
+ inboxServiceInstance: apiService,
1787
+ cache,
1788
+ useCache
1606
1789
  }
1607
1790
  ) : void 0
1608
1791
  });
@@ -1715,139 +1898,6 @@ var optimisticUpdateWorkflowPreferences = ({
1715
1898
  });
1716
1899
  };
1717
1900
 
1718
- // src/preferences/preference.ts
1719
- var _emitter3, _apiService, _cache3, _useCache2;
1720
- var Preference = class {
1721
- constructor(preference, {
1722
- emitterInstance,
1723
- inboxServiceInstance,
1724
- cache,
1725
- useCache
1726
- }) {
1727
- __privateAdd(this, _emitter3);
1728
- __privateAdd(this, _apiService);
1729
- __privateAdd(this, _cache3);
1730
- __privateAdd(this, _useCache2);
1731
- __privateSet(this, _emitter3, emitterInstance);
1732
- __privateSet(this, _apiService, inboxServiceInstance);
1733
- __privateSet(this, _cache3, cache);
1734
- __privateSet(this, _useCache2, useCache);
1735
- this.level = preference.level;
1736
- this.enabled = preference.enabled;
1737
- this.channels = preference.channels;
1738
- this.workflow = preference.workflow;
1739
- }
1740
- update({
1741
- channels,
1742
- channelPreferences
1743
- }) {
1744
- var _a;
1745
- return updatePreference({
1746
- emitter: __privateGet(this, _emitter3),
1747
- apiService: __privateGet(this, _apiService),
1748
- cache: __privateGet(this, _cache3),
1749
- useCache: __privateGet(this, _useCache2),
1750
- args: {
1751
- workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
1752
- channels: channels || channelPreferences,
1753
- preference: this
1754
- }
1755
- });
1756
- }
1757
- };
1758
- _emitter3 = new WeakMap();
1759
- _apiService = new WeakMap();
1760
- _cache3 = new WeakMap();
1761
- _useCache2 = new WeakMap();
1762
-
1763
- // src/cache/preferences-cache.ts
1764
- var updateEvents2 = [
1765
- "preference.update.pending",
1766
- "preference.update.resolved",
1767
- "preferences.bulk_update.pending",
1768
- "preferences.bulk_update.resolved"
1769
- ];
1770
- var excludeEmpty2 = ({ tags }) => Object.entries({ tags }).reduce((acc, [key, value]) => {
1771
- if (value === null || value === void 0 || Array.isArray(value) && value.length === 0) {
1772
- return acc;
1773
- }
1774
- acc[key] = value;
1775
- return acc;
1776
- }, {});
1777
- var getCacheKey2 = ({ tags }) => {
1778
- return JSON.stringify(excludeEmpty2({ tags }));
1779
- };
1780
- var _emitter4, _cache4;
1781
- var PreferencesCache = class {
1782
- constructor({ emitterInstance }) {
1783
- __privateAdd(this, _emitter4);
1784
- __privateAdd(this, _cache4);
1785
- this.updatePreference = (key, data) => {
1786
- const preferences = __privateGet(this, _cache4).get(key);
1787
- if (!preferences) {
1788
- return false;
1789
- }
1790
- const index = preferences.findIndex(
1791
- (el) => {
1792
- var _a, _b;
1793
- return ((_a = el.workflow) == null ? void 0 : _a.id) === ((_b = data.workflow) == null ? void 0 : _b.id) || el.level === data.level && data.level === "global" /* GLOBAL */;
1794
- }
1795
- );
1796
- if (index === -1) {
1797
- return false;
1798
- }
1799
- const updatedPreferences = [...preferences];
1800
- updatedPreferences[index] = data;
1801
- __privateGet(this, _cache4).set(key, updatedPreferences);
1802
- return true;
1803
- };
1804
- this.handlePreferenceEvent = ({ data }) => {
1805
- if (!data) {
1806
- return;
1807
- }
1808
- const preferences = Array.isArray(data) ? data : [data];
1809
- const uniqueFilterKeys = /* @__PURE__ */ new Set();
1810
- __privateGet(this, _cache4).keys().forEach((key) => {
1811
- preferences.forEach((preference) => {
1812
- const hasUpdatedPreference = this.updatePreference(key, preference);
1813
- const updatedPreference = __privateGet(this, _cache4).get(key);
1814
- if (!hasUpdatedPreference || !updatedPreference) {
1815
- return;
1816
- }
1817
- uniqueFilterKeys.add(key);
1818
- });
1819
- });
1820
- uniqueFilterKeys.forEach((key) => {
1821
- var _a;
1822
- __privateGet(this, _emitter4).emit("preferences.list.updated", {
1823
- data: (_a = __privateGet(this, _cache4).get(key)) != null ? _a : []
1824
- });
1825
- });
1826
- };
1827
- __privateSet(this, _emitter4, emitterInstance);
1828
- updateEvents2.forEach((event) => {
1829
- __privateGet(this, _emitter4).on(event, this.handlePreferenceEvent);
1830
- });
1831
- __privateSet(this, _cache4, new InMemoryCache());
1832
- }
1833
- has(args) {
1834
- return __privateGet(this, _cache4).get(getCacheKey2(args)) !== void 0;
1835
- }
1836
- set(args, data) {
1837
- __privateGet(this, _cache4).set(getCacheKey2(args), data);
1838
- }
1839
- getAll(args) {
1840
- if (this.has(args)) {
1841
- return __privateGet(this, _cache4).get(getCacheKey2(args));
1842
- }
1843
- }
1844
- clearAll() {
1845
- __privateGet(this, _cache4).clear();
1846
- }
1847
- };
1848
- _emitter4 = new WeakMap();
1849
- _cache4 = new WeakMap();
1850
-
1851
1901
  // src/preferences/preferences.ts
1852
1902
  var _useCache3;
1853
1903
  var Preferences = class extends BaseModule {
@@ -2020,7 +2070,7 @@ var Session = class {
2020
2070
  _emitter5 = new WeakMap();
2021
2071
  _inboxService2 = new WeakMap();
2022
2072
  _options = new WeakMap();
2023
- var PRODUCTION_SOCKET_URL = "https://ws.novu.co";
2073
+ var PRODUCTION_SOCKET_URL = "wss://socket.novu.co";
2024
2074
  var NOTIFICATION_RECEIVED = "notifications.notification_received";
2025
2075
  var UNSEEN_COUNT_CHANGED = "notifications.unseen_count_changed";
2026
2076
  var UNREAD_COUNT_CHANGED = "notifications.unread_count_changed";
@@ -2107,8 +2157,8 @@ var mapToNotification = ({
2107
2157
  workflow
2108
2158
  });
2109
2159
  };
2110
- var _token, _emitter6, _socketIo, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _Socket_instances, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
2111
- var Socket = class extends BaseModule {
2160
+ var _token, _emitter6, _partySocket, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _handleMessage, _PartySocketClient_instances, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
2161
+ var PartySocketClient = class extends BaseModule {
2112
2162
  constructor({
2113
2163
  socketUrl,
2114
2164
  inboxServiceInstance,
@@ -2118,25 +2168,62 @@ var Socket = class extends BaseModule {
2118
2168
  eventEmitterInstance,
2119
2169
  inboxServiceInstance
2120
2170
  });
2121
- __privateAdd(this, _Socket_instances);
2171
+ __privateAdd(this, _PartySocketClient_instances);
2122
2172
  __privateAdd(this, _token);
2123
2173
  __privateAdd(this, _emitter6);
2124
- __privateAdd(this, _socketIo);
2174
+ __privateAdd(this, _partySocket);
2125
2175
  __privateAdd(this, _socketUrl);
2126
- __privateAdd(this, _notificationReceived, ({ message }) => {
2127
- __privateGet(this, _emitter6).emit(NOTIFICATION_RECEIVED, {
2128
- result: new Notification(mapToNotification(message), __privateGet(this, _emitter6), this._inboxService)
2129
- });
2176
+ __privateAdd(this, _notificationReceived, (event) => {
2177
+ try {
2178
+ const data = JSON.parse(event.data);
2179
+ if (data.event === "notification_received" /* RECEIVED */) {
2180
+ __privateGet(this, _emitter6).emit(NOTIFICATION_RECEIVED, {
2181
+ result: new Notification(mapToNotification(data.data.message), __privateGet(this, _emitter6), this._inboxService)
2182
+ });
2183
+ }
2184
+ } catch (error) {
2185
+ console.log("error", error);
2186
+ }
2130
2187
  });
2131
- __privateAdd(this, _unseenCountChanged, ({ unseenCount }) => {
2132
- __privateGet(this, _emitter6).emit(UNSEEN_COUNT_CHANGED, {
2133
- result: unseenCount
2134
- });
2188
+ __privateAdd(this, _unseenCountChanged, (event) => {
2189
+ try {
2190
+ const data = JSON.parse(event.data);
2191
+ if (data.event === "unseen_count_changed" /* UNSEEN */) {
2192
+ __privateGet(this, _emitter6).emit(UNSEEN_COUNT_CHANGED, {
2193
+ result: data.data.unseenCount
2194
+ });
2195
+ }
2196
+ } catch (error) {
2197
+ }
2135
2198
  });
2136
- __privateAdd(this, _unreadCountChanged, ({ unreadCount }) => {
2137
- __privateGet(this, _emitter6).emit(UNREAD_COUNT_CHANGED, {
2138
- result: unreadCount
2139
- });
2199
+ __privateAdd(this, _unreadCountChanged, (event) => {
2200
+ try {
2201
+ const data = JSON.parse(event.data);
2202
+ if (data.event === "unread_count_changed" /* UNREAD */) {
2203
+ __privateGet(this, _emitter6).emit(UNREAD_COUNT_CHANGED, {
2204
+ result: data.data.unreadCount
2205
+ });
2206
+ }
2207
+ } catch (error) {
2208
+ }
2209
+ });
2210
+ __privateAdd(this, _handleMessage, (event) => {
2211
+ try {
2212
+ const data = JSON.parse(event.data);
2213
+ switch (data.event) {
2214
+ case "notification_received" /* RECEIVED */:
2215
+ __privateGet(this, _notificationReceived).call(this, event);
2216
+ break;
2217
+ case "unseen_count_changed" /* UNSEEN */:
2218
+ __privateGet(this, _unseenCountChanged).call(this, event);
2219
+ break;
2220
+ case "unread_count_changed" /* UNREAD */:
2221
+ __privateGet(this, _unreadCountChanged).call(this, event);
2222
+ break;
2223
+ default:
2224
+ }
2225
+ } catch (error) {
2226
+ }
2140
2227
  });
2141
2228
  __privateSet(this, _emitter6, eventEmitterInstance);
2142
2229
  __privateSet(this, _socketUrl, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL);
@@ -2150,61 +2237,55 @@ var Socket = class extends BaseModule {
2150
2237
  connect() {
2151
2238
  return __async(this, null, function* () {
2152
2239
  if (__privateGet(this, _token)) {
2153
- return __privateMethod(this, _Socket_instances, handleConnectSocket_fn).call(this);
2240
+ return __privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn).call(this);
2154
2241
  }
2155
- return this.callWithSession(__privateMethod(this, _Socket_instances, handleConnectSocket_fn).bind(this));
2242
+ return this.callWithSession(__privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn).bind(this));
2156
2243
  });
2157
2244
  }
2158
2245
  disconnect() {
2159
2246
  return __async(this, null, function* () {
2160
- if (__privateGet(this, _socketIo)) {
2161
- return __privateMethod(this, _Socket_instances, handleDisconnectSocket_fn).call(this);
2247
+ if (__privateGet(this, _partySocket)) {
2248
+ return __privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn).call(this);
2162
2249
  }
2163
- return this.callWithSession(__privateMethod(this, _Socket_instances, handleDisconnectSocket_fn).bind(this));
2250
+ return this.callWithSession(__privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn).bind(this));
2164
2251
  });
2165
2252
  }
2166
2253
  };
2167
2254
  _token = new WeakMap();
2168
2255
  _emitter6 = new WeakMap();
2169
- _socketIo = new WeakMap();
2256
+ _partySocket = new WeakMap();
2170
2257
  _socketUrl = new WeakMap();
2171
2258
  _notificationReceived = new WeakMap();
2172
2259
  _unseenCountChanged = new WeakMap();
2173
2260
  _unreadCountChanged = new WeakMap();
2174
- _Socket_instances = new WeakSet();
2261
+ _handleMessage = new WeakMap();
2262
+ _PartySocketClient_instances = new WeakSet();
2175
2263
  initializeSocket_fn = function() {
2176
2264
  return __async(this, null, function* () {
2177
- var _a, _b, _c;
2178
- if (!!__privateGet(this, _socketIo)) {
2265
+ if (__privateGet(this, _partySocket)) {
2179
2266
  return;
2180
2267
  }
2181
2268
  const args = { socketUrl: __privateGet(this, _socketUrl) };
2182
2269
  __privateGet(this, _emitter6).emit("socket.connect.pending", { args });
2183
- __privateSet(this, _socketIo, io(__privateGet(this, _socketUrl), {
2184
- reconnectionDelayMax: 1e4,
2185
- transports: ["websocket"],
2186
- query: {
2187
- token: `${__privateGet(this, _token)}`
2188
- }
2189
- }));
2190
- __privateGet(this, _socketIo).on("connect", () => {
2270
+ const url = new URL(__privateGet(this, _socketUrl));
2271
+ url.searchParams.set("token", __privateGet(this, _token));
2272
+ __privateSet(this, _partySocket, new WebSocket(url.toString()));
2273
+ __privateGet(this, _partySocket).addEventListener("open", () => {
2191
2274
  __privateGet(this, _emitter6).emit("socket.connect.resolved", { args });
2192
2275
  });
2193
- __privateGet(this, _socketIo).on("connect_error", (error) => {
2276
+ __privateGet(this, _partySocket).addEventListener("error", (error) => {
2194
2277
  __privateGet(this, _emitter6).emit("socket.connect.resolved", { args, error });
2195
2278
  });
2196
- (_a = __privateGet(this, _socketIo)) == null ? void 0 : _a.on("notification_received" /* RECEIVED */, __privateGet(this, _notificationReceived));
2197
- (_b = __privateGet(this, _socketIo)) == null ? void 0 : _b.on("unseen_count_changed" /* UNSEEN */, __privateGet(this, _unseenCountChanged));
2198
- (_c = __privateGet(this, _socketIo)) == null ? void 0 : _c.on("unread_count_changed" /* UNREAD */, __privateGet(this, _unreadCountChanged));
2279
+ __privateGet(this, _partySocket).addEventListener("message", __privateGet(this, _handleMessage));
2199
2280
  });
2200
2281
  };
2201
2282
  handleConnectSocket_fn = function() {
2202
2283
  return __async(this, null, function* () {
2203
2284
  try {
2204
- yield __privateMethod(this, _Socket_instances, initializeSocket_fn).call(this);
2285
+ yield __privateMethod(this, _PartySocketClient_instances, initializeSocket_fn).call(this);
2205
2286
  return {};
2206
2287
  } catch (error) {
2207
- return { error: new NovuError("Failed to initialize the socket", error) };
2288
+ return { error: new NovuError("Failed to initialize the PartySocket", error) };
2208
2289
  }
2209
2290
  });
2210
2291
  };
@@ -2212,15 +2293,15 @@ handleDisconnectSocket_fn = function() {
2212
2293
  return __async(this, null, function* () {
2213
2294
  var _a;
2214
2295
  try {
2215
- (_a = __privateGet(this, _socketIo)) == null ? void 0 : _a.disconnect();
2216
- __privateSet(this, _socketIo, void 0);
2296
+ (_a = __privateGet(this, _partySocket)) == null ? void 0 : _a.close();
2297
+ __privateSet(this, _partySocket, void 0);
2217
2298
  return {};
2218
2299
  } catch (error) {
2219
- return { error: new NovuError("Failed to disconnect from the socket", error) };
2300
+ return { error: new NovuError("Failed to disconnect from the PartySocket", error) };
2220
2301
  }
2221
2302
  });
2222
2303
  };
2223
- var PRODUCTION_SOCKET_URL2 = "wss://socket.novu.co";
2304
+ var PRODUCTION_SOCKET_URL2 = "https://ws.novu.co";
2224
2305
  var NOTIFICATION_RECEIVED2 = "notifications.notification_received";
2225
2306
  var UNSEEN_COUNT_CHANGED2 = "notifications.unseen_count_changed";
2226
2307
  var UNREAD_COUNT_CHANGED2 = "notifications.unread_count_changed";
@@ -2307,8 +2388,8 @@ var mapToNotification2 = ({
2307
2388
  workflow
2308
2389
  });
2309
2390
  };
2310
- var _token2, _emitter7, _partySocket, _socketUrl2, _notificationReceived2, _unseenCountChanged2, _unreadCountChanged2, _handleMessage, _PartySocketClient_instances, initializeSocket_fn2, handleConnectSocket_fn2, handleDisconnectSocket_fn2;
2311
- var PartySocketClient = class extends BaseModule {
2391
+ var _token2, _emitter7, _socketIo, _socketUrl2, _notificationReceived2, _unseenCountChanged2, _unreadCountChanged2, _Socket_instances, initializeSocket_fn2, handleConnectSocket_fn2, handleDisconnectSocket_fn2;
2392
+ var Socket = class extends BaseModule {
2312
2393
  constructor({
2313
2394
  socketUrl,
2314
2395
  inboxServiceInstance,
@@ -2318,62 +2399,25 @@ var PartySocketClient = class extends BaseModule {
2318
2399
  eventEmitterInstance,
2319
2400
  inboxServiceInstance
2320
2401
  });
2321
- __privateAdd(this, _PartySocketClient_instances);
2402
+ __privateAdd(this, _Socket_instances);
2322
2403
  __privateAdd(this, _token2);
2323
2404
  __privateAdd(this, _emitter7);
2324
- __privateAdd(this, _partySocket);
2405
+ __privateAdd(this, _socketIo);
2325
2406
  __privateAdd(this, _socketUrl2);
2326
- __privateAdd(this, _notificationReceived2, (event) => {
2327
- try {
2328
- const data = JSON.parse(event.data);
2329
- if (data.event === "notification_received" /* RECEIVED */) {
2330
- __privateGet(this, _emitter7).emit(NOTIFICATION_RECEIVED2, {
2331
- result: new Notification(mapToNotification2(data.data.message), __privateGet(this, _emitter7), this._inboxService)
2332
- });
2333
- }
2334
- } catch (error) {
2335
- console.log("error", error);
2336
- }
2337
- });
2338
- __privateAdd(this, _unseenCountChanged2, (event) => {
2339
- try {
2340
- const data = JSON.parse(event.data);
2341
- if (data.event === "unseen_count_changed" /* UNSEEN */) {
2342
- __privateGet(this, _emitter7).emit(UNSEEN_COUNT_CHANGED2, {
2343
- result: data.data.unseenCount
2344
- });
2345
- }
2346
- } catch (error) {
2347
- }
2407
+ __privateAdd(this, _notificationReceived2, ({ message }) => {
2408
+ __privateGet(this, _emitter7).emit(NOTIFICATION_RECEIVED2, {
2409
+ result: new Notification(mapToNotification2(message), __privateGet(this, _emitter7), this._inboxService)
2410
+ });
2348
2411
  });
2349
- __privateAdd(this, _unreadCountChanged2, (event) => {
2350
- try {
2351
- const data = JSON.parse(event.data);
2352
- if (data.event === "unread_count_changed" /* UNREAD */) {
2353
- __privateGet(this, _emitter7).emit(UNREAD_COUNT_CHANGED2, {
2354
- result: data.data.unreadCount
2355
- });
2356
- }
2357
- } catch (error) {
2358
- }
2412
+ __privateAdd(this, _unseenCountChanged2, ({ unseenCount }) => {
2413
+ __privateGet(this, _emitter7).emit(UNSEEN_COUNT_CHANGED2, {
2414
+ result: unseenCount
2415
+ });
2359
2416
  });
2360
- __privateAdd(this, _handleMessage, (event) => {
2361
- try {
2362
- const data = JSON.parse(event.data);
2363
- switch (data.event) {
2364
- case "notification_received" /* RECEIVED */:
2365
- __privateGet(this, _notificationReceived2).call(this, event);
2366
- break;
2367
- case "unseen_count_changed" /* UNSEEN */:
2368
- __privateGet(this, _unseenCountChanged2).call(this, event);
2369
- break;
2370
- case "unread_count_changed" /* UNREAD */:
2371
- __privateGet(this, _unreadCountChanged2).call(this, event);
2372
- break;
2373
- default:
2374
- }
2375
- } catch (error) {
2376
- }
2417
+ __privateAdd(this, _unreadCountChanged2, ({ unreadCount }) => {
2418
+ __privateGet(this, _emitter7).emit(UNREAD_COUNT_CHANGED2, {
2419
+ result: unreadCount
2420
+ });
2377
2421
  });
2378
2422
  __privateSet(this, _emitter7, eventEmitterInstance);
2379
2423
  __privateSet(this, _socketUrl2, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL2);
@@ -2387,55 +2431,61 @@ var PartySocketClient = class extends BaseModule {
2387
2431
  connect() {
2388
2432
  return __async(this, null, function* () {
2389
2433
  if (__privateGet(this, _token2)) {
2390
- return __privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn2).call(this);
2434
+ return __privateMethod(this, _Socket_instances, handleConnectSocket_fn2).call(this);
2391
2435
  }
2392
- return this.callWithSession(__privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn2).bind(this));
2436
+ return this.callWithSession(__privateMethod(this, _Socket_instances, handleConnectSocket_fn2).bind(this));
2393
2437
  });
2394
2438
  }
2395
2439
  disconnect() {
2396
2440
  return __async(this, null, function* () {
2397
- if (__privateGet(this, _partySocket)) {
2398
- return __privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn2).call(this);
2441
+ if (__privateGet(this, _socketIo)) {
2442
+ return __privateMethod(this, _Socket_instances, handleDisconnectSocket_fn2).call(this);
2399
2443
  }
2400
- return this.callWithSession(__privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn2).bind(this));
2444
+ return this.callWithSession(__privateMethod(this, _Socket_instances, handleDisconnectSocket_fn2).bind(this));
2401
2445
  });
2402
2446
  }
2403
2447
  };
2404
2448
  _token2 = new WeakMap();
2405
2449
  _emitter7 = new WeakMap();
2406
- _partySocket = new WeakMap();
2450
+ _socketIo = new WeakMap();
2407
2451
  _socketUrl2 = new WeakMap();
2408
2452
  _notificationReceived2 = new WeakMap();
2409
2453
  _unseenCountChanged2 = new WeakMap();
2410
2454
  _unreadCountChanged2 = new WeakMap();
2411
- _handleMessage = new WeakMap();
2412
- _PartySocketClient_instances = new WeakSet();
2455
+ _Socket_instances = new WeakSet();
2413
2456
  initializeSocket_fn2 = function() {
2414
2457
  return __async(this, null, function* () {
2415
- if (__privateGet(this, _partySocket)) {
2458
+ var _a, _b, _c;
2459
+ if (__privateGet(this, _socketIo)) {
2416
2460
  return;
2417
2461
  }
2418
2462
  const args = { socketUrl: __privateGet(this, _socketUrl2) };
2419
2463
  __privateGet(this, _emitter7).emit("socket.connect.pending", { args });
2420
- const url = new URL(__privateGet(this, _socketUrl2));
2421
- url.searchParams.set("token", __privateGet(this, _token2));
2422
- __privateSet(this, _partySocket, new WebSocket(url.toString()));
2423
- __privateGet(this, _partySocket).addEventListener("open", () => {
2464
+ __privateSet(this, _socketIo, io(__privateGet(this, _socketUrl2), {
2465
+ reconnectionDelayMax: 1e4,
2466
+ transports: ["websocket"],
2467
+ query: {
2468
+ token: `${__privateGet(this, _token2)}`
2469
+ }
2470
+ }));
2471
+ __privateGet(this, _socketIo).on("connect", () => {
2424
2472
  __privateGet(this, _emitter7).emit("socket.connect.resolved", { args });
2425
2473
  });
2426
- __privateGet(this, _partySocket).addEventListener("error", (error) => {
2474
+ __privateGet(this, _socketIo).on("connect_error", (error) => {
2427
2475
  __privateGet(this, _emitter7).emit("socket.connect.resolved", { args, error });
2428
2476
  });
2429
- __privateGet(this, _partySocket).addEventListener("message", __privateGet(this, _handleMessage));
2477
+ (_a = __privateGet(this, _socketIo)) == null ? void 0 : _a.on("notification_received" /* RECEIVED */, __privateGet(this, _notificationReceived2));
2478
+ (_b = __privateGet(this, _socketIo)) == null ? void 0 : _b.on("unseen_count_changed" /* UNSEEN */, __privateGet(this, _unseenCountChanged2));
2479
+ (_c = __privateGet(this, _socketIo)) == null ? void 0 : _c.on("unread_count_changed" /* UNREAD */, __privateGet(this, _unreadCountChanged2));
2430
2480
  });
2431
2481
  };
2432
2482
  handleConnectSocket_fn2 = function() {
2433
2483
  return __async(this, null, function* () {
2434
2484
  try {
2435
- yield __privateMethod(this, _PartySocketClient_instances, initializeSocket_fn2).call(this);
2485
+ yield __privateMethod(this, _Socket_instances, initializeSocket_fn2).call(this);
2436
2486
  return {};
2437
2487
  } catch (error) {
2438
- return { error: new NovuError("Failed to initialize the PartySocket", error) };
2488
+ return { error: new NovuError("Failed to initialize the socket", error) };
2439
2489
  }
2440
2490
  });
2441
2491
  };
@@ -2443,11 +2493,11 @@ handleDisconnectSocket_fn2 = function() {
2443
2493
  return __async(this, null, function* () {
2444
2494
  var _a;
2445
2495
  try {
2446
- (_a = __privateGet(this, _partySocket)) == null ? void 0 : _a.close();
2447
- __privateSet(this, _partySocket, void 0);
2496
+ (_a = __privateGet(this, _socketIo)) == null ? void 0 : _a.disconnect();
2497
+ __privateSet(this, _socketIo, void 0);
2448
2498
  return {};
2449
2499
  } catch (error) {
2450
- return { error: new NovuError("Failed to disconnect from the PartySocket", error) };
2500
+ return { error: new NovuError("Failed to disconnect from the socket", error) };
2451
2501
  }
2452
2502
  });
2453
2503
  };
@@ -2455,17 +2505,17 @@ handleDisconnectSocket_fn2 = function() {
2455
2505
  // src/ws/socket-factory.ts
2456
2506
  var PARTY_SOCKET_URLS = [
2457
2507
  "wss://eu.socket.novu.co",
2458
- PRODUCTION_SOCKET_URL2,
2508
+ PRODUCTION_SOCKET_URL,
2459
2509
  "wss://socket.novu-staging.co",
2460
2510
  "wss://socket-worker-local.cli-shortener.workers.dev"
2461
2511
  ];
2462
2512
  var URL_TRANSFORMATIONS = {
2463
2513
  "https://eu.ws.novu.co": "wss://eu.socket.novu.co",
2464
- "https://ws.novu.co": PRODUCTION_SOCKET_URL2,
2514
+ "https://ws.novu.co": PRODUCTION_SOCKET_URL,
2465
2515
  "https://dev.ws.novu.co": "wss://socket.novu-staging.co"
2466
2516
  };
2467
2517
  function transformSocketUrl(socketUrl) {
2468
- if (!socketUrl) return PRODUCTION_SOCKET_URL2;
2518
+ if (!socketUrl) return PRODUCTION_SOCKET_URL;
2469
2519
  return URL_TRANSFORMATIONS[socketUrl] || socketUrl;
2470
2520
  }
2471
2521
  function shouldUsePartySocket(socketUrl) {
@@ -2566,4 +2616,4 @@ _emitter8 = new WeakMap();
2566
2616
  _session = new WeakMap();
2567
2617
  _inboxService3 = new WeakMap();
2568
2618
 
2569
- export { ChannelType, DEFAULT_API_VERSION, NotificationStatus, Novu, PreferenceLevel, WebSocketEvent, areTagsEqual, isBrowser, isSameFilter };
2619
+ export { ChannelType, DEFAULT_API_VERSION, NotificationStatus, Novu, PreferenceLevel, WebSocketEvent, areTagsEqual, checkNotificationDataFilter, checkNotificationMatchesFilter, checkNotificationTagFilter, isBrowser, isSameFilter };