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