@novu/js 3.7.1-nightly.20250723 → 3.8.1-nightly.20250813.014483f9e1

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.1-nightly.20250813.014483f9e1"}`;
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,236 @@ 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.transactionId = notification.transactionId;
891
+ this.subject = notification.subject;
892
+ this.body = notification.body;
893
+ this.to = notification.to;
894
+ this.isRead = notification.isRead;
895
+ this.isSeen = notification.isSeen;
896
+ this.isArchived = notification.isArchived;
897
+ this.isSnoozed = notification.isSnoozed;
898
+ this.snoozedUntil = notification.snoozedUntil;
899
+ this.deliveredAt = notification.deliveredAt;
900
+ this.createdAt = notification.createdAt;
901
+ this.readAt = notification.readAt;
902
+ this.firstSeenAt = notification.firstSeenAt;
903
+ this.archivedAt = notification.archivedAt;
904
+ this.avatar = notification.avatar;
905
+ this.primaryAction = notification.primaryAction;
906
+ this.secondaryAction = notification.secondaryAction;
907
+ this.channelType = notification.channelType;
908
+ this.tags = notification.tags;
909
+ this.redirect = notification.redirect;
910
+ this.data = notification.data;
911
+ this.workflow = notification.workflow;
912
+ }
913
+ read() {
914
+ return read({
915
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
916
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
917
+ args: {
918
+ notification: this
919
+ }
920
+ });
921
+ }
922
+ unread() {
923
+ return unread({
924
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
925
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
926
+ args: {
927
+ notification: this
928
+ }
929
+ });
930
+ }
931
+ seen() {
932
+ return seen({
933
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
934
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
935
+ args: {
936
+ notification: this
937
+ }
938
+ });
939
+ }
940
+ archive() {
941
+ return archive({
942
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
943
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
944
+ args: {
945
+ notification: this
946
+ }
947
+ });
948
+ }
949
+ unarchive() {
950
+ return unarchive({
951
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
952
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
953
+ args: {
954
+ notification: this
955
+ }
956
+ });
957
+ }
958
+ snooze(snoozeUntil) {
959
+ return snooze({
960
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
961
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
962
+ args: {
963
+ notification: this,
964
+ snoozeUntil
965
+ }
966
+ });
967
+ }
968
+ unsnooze() {
969
+ return unsnooze({
970
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
971
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
972
+ args: { notification: this }
973
+ });
974
+ }
975
+ completePrimary() {
976
+ if (!this.primaryAction) {
977
+ throw new Error("Primary action is not available");
978
+ }
979
+ return completeAction({
980
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
981
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
982
+ args: {
983
+ notification: this
984
+ },
985
+ actionType: "primary" /* PRIMARY */
986
+ });
987
+ }
988
+ completeSecondary() {
989
+ if (!this.primaryAction) {
990
+ throw new Error("Secondary action is not available");
991
+ }
992
+ return completeAction({
993
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
994
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
995
+ args: {
996
+ notification: this
997
+ },
998
+ actionType: "secondary" /* SECONDARY */
999
+ });
1000
+ }
1001
+ revertPrimary() {
1002
+ if (!this.primaryAction) {
1003
+ throw new Error("Primary action is not available");
1004
+ }
1005
+ return revertAction({
1006
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
1007
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
1008
+ args: {
1009
+ notification: this
1010
+ },
1011
+ actionType: "primary" /* PRIMARY */
1012
+ });
1013
+ }
1014
+ revertSecondary() {
1015
+ if (!this.primaryAction) {
1016
+ throw new Error("Secondary action is not available");
1017
+ }
1018
+ return revertAction({
1019
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
1020
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
1021
+ args: {
1022
+ notification: this
1023
+ },
1024
+ actionType: "secondary" /* SECONDARY */
1025
+ });
1026
+ }
1027
+ on(eventName, listener) {
1028
+ const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter).on(eventName, listener);
1029
+ return () => {
1030
+ cleanup();
1031
+ };
1032
+ }
1033
+ /**
1034
+ * @deprecated
1035
+ * Use the cleanup function returned by the "on" method instead.
1036
+ */
1037
+ off(eventName, listener) {
1038
+ chunk7B52C2XE_js.__privateGet(this, _emitter).off(eventName, listener);
1039
+ }
1040
+ };
1041
+ _emitter = new WeakMap();
1042
+ _inboxService = new WeakMap();
1043
+
1044
+ // src/base-module.ts
1045
+ var _callsQueue, _sessionError;
1046
+ var BaseModule = class {
1047
+ constructor({
1048
+ inboxServiceInstance,
1049
+ eventEmitterInstance
1050
+ }) {
1051
+ chunk7B52C2XE_js.__privateAdd(this, _callsQueue, []);
1052
+ chunk7B52C2XE_js.__privateAdd(this, _sessionError);
1053
+ this._emitter = eventEmitterInstance;
1054
+ this._inboxService = inboxServiceInstance;
1055
+ this._emitter.on("session.initialize.resolved", ({ error, data }) => {
1056
+ if (data) {
1057
+ this.onSessionSuccess(data);
1058
+ chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach((_0) => chunk7B52C2XE_js.__async(this, [_0], function* ({ fn, resolve }) {
1059
+ resolve(yield fn());
1060
+ }));
1061
+ chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
1062
+ } else if (error) {
1063
+ this.onSessionError(error);
1064
+ chunk7B52C2XE_js.__privateSet(this, _sessionError, error);
1065
+ chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach(({ resolve }) => {
1066
+ resolve({ error: new NovuError("Failed to initialize session, please contact the support", error) });
1067
+ });
1068
+ chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
1069
+ }
1070
+ });
1071
+ }
1072
+ onSessionSuccess(_) {
1073
+ }
1074
+ onSessionError(_) {
1075
+ }
1076
+ callWithSession(fn) {
1077
+ return chunk7B52C2XE_js.__async(this, null, function* () {
1078
+ if (this._inboxService.isSessionInitialized) {
1079
+ return fn();
1080
+ }
1081
+ if (chunk7B52C2XE_js.__privateGet(this, _sessionError)) {
1082
+ return Promise.resolve({
1083
+ error: new NovuError("Failed to initialize session, please contact the support", chunk7B52C2XE_js.__privateGet(this, _sessionError))
1084
+ });
1085
+ }
1086
+ return new Promise((resolve, reject) => {
1087
+ chunk7B52C2XE_js.__privateGet(this, _callsQueue).push({ fn, resolve, reject });
1088
+ });
1089
+ });
1090
+ }
1091
+ };
1092
+ _callsQueue = new WeakMap();
1093
+ _sessionError = new WeakMap();
1094
+
1095
+ // src/cache/in-memory-cache.ts
1096
+ var _cache;
1097
+ var InMemoryCache = class {
1098
+ constructor() {
1099
+ chunk7B52C2XE_js.__privateAdd(this, _cache);
1100
+ chunk7B52C2XE_js.__privateSet(this, _cache, /* @__PURE__ */ new Map());
1101
+ }
1102
+ get(key) {
1103
+ return chunk7B52C2XE_js.__privateGet(this, _cache).get(key);
1104
+ }
1105
+ getValues() {
1106
+ return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).values());
1107
+ }
1108
+ entries() {
1109
+ return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).entries());
1110
+ }
1057
1111
  keys() {
1058
1112
  return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).keys());
1059
1113
  }
@@ -1556,10 +1610,7 @@ var Notifications = class extends BaseModule {
1556
1610
  });
1557
1611
  }
1558
1612
  archiveAllRead() {
1559
- return chunk7B52C2XE_js.__async(this, arguments, function* ({
1560
- tags,
1561
- data
1562
- } = {}) {
1613
+ return chunk7B52C2XE_js.__async(this, arguments, function* ({ tags, data } = {}) {
1563
1614
  return this.callWithSession(
1564
1615
  () => chunk7B52C2XE_js.__async(this, null, function* () {
1565
1616
  return archiveAllRead({
@@ -1587,29 +1638,162 @@ var Notifications = class extends BaseModule {
1587
1638
  };
1588
1639
  _useCache = new WeakMap();
1589
1640
 
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
1641
+ // src/cache/preferences-cache.ts
1642
+ var updateEvents2 = [
1643
+ "preference.update.pending",
1644
+ "preference.update.resolved",
1645
+ "preferences.bulk_update.pending",
1646
+ "preferences.bulk_update.resolved"
1647
+ ];
1648
+ var excludeEmpty2 = ({ tags }) => Object.entries({ tags }).reduce((acc, [key, value]) => {
1649
+ if (value === null || value === void 0 || Array.isArray(value) && value.length === 0) {
1650
+ return acc;
1651
+ }
1652
+ acc[key] = value;
1653
+ return acc;
1654
+ }, {});
1655
+ var getCacheKey2 = ({ tags }) => {
1656
+ return JSON.stringify(excludeEmpty2({ tags }));
1657
+ };
1658
+ var _emitter3, _cache3;
1659
+ var PreferencesCache = class {
1660
+ constructor({ emitterInstance }) {
1661
+ chunk7B52C2XE_js.__privateAdd(this, _emitter3);
1662
+ chunk7B52C2XE_js.__privateAdd(this, _cache3);
1663
+ this.updatePreference = (key, data) => {
1664
+ const preferences = chunk7B52C2XE_js.__privateGet(this, _cache3).get(key);
1665
+ if (!preferences) {
1666
+ return false;
1667
+ }
1668
+ const index = preferences.findIndex(
1669
+ (el) => {
1670
+ var _a, _b;
1671
+ 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 */;
1672
+ }
1673
+ );
1674
+ if (index === -1) {
1675
+ return false;
1676
+ }
1677
+ const updatedPreferences = [...preferences];
1678
+ updatedPreferences[index] = data;
1679
+ chunk7B52C2XE_js.__privateGet(this, _cache3).set(key, updatedPreferences);
1680
+ return true;
1681
+ };
1682
+ this.handlePreferenceEvent = ({ data }) => {
1683
+ if (!data) {
1684
+ return;
1685
+ }
1686
+ const preferences = Array.isArray(data) ? data : [data];
1687
+ const uniqueFilterKeys = /* @__PURE__ */ new Set();
1688
+ chunk7B52C2XE_js.__privateGet(this, _cache3).keys().forEach((key) => {
1689
+ preferences.forEach((preference) => {
1690
+ const hasUpdatedPreference = this.updatePreference(key, preference);
1691
+ const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache3).get(key);
1692
+ if (!hasUpdatedPreference || !updatedPreference) {
1693
+ return;
1694
+ }
1695
+ uniqueFilterKeys.add(key);
1696
+ });
1697
+ });
1698
+ uniqueFilterKeys.forEach((key) => {
1699
+ var _a;
1700
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("preferences.list.updated", {
1701
+ data: (_a = chunk7B52C2XE_js.__privateGet(this, _cache3).get(key)) != null ? _a : []
1702
+ });
1703
+ });
1704
+ };
1705
+ chunk7B52C2XE_js.__privateSet(this, _emitter3, emitterInstance);
1706
+ updateEvents2.forEach((event) => {
1707
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).on(event, this.handlePreferenceEvent);
1708
+ });
1709
+ chunk7B52C2XE_js.__privateSet(this, _cache3, new InMemoryCache());
1710
+ }
1711
+ has(args) {
1712
+ return chunk7B52C2XE_js.__privateGet(this, _cache3).get(getCacheKey2(args)) !== void 0;
1713
+ }
1714
+ set(args, data) {
1715
+ chunk7B52C2XE_js.__privateGet(this, _cache3).set(getCacheKey2(args), data);
1716
+ }
1717
+ getAll(args) {
1718
+ if (this.has(args)) {
1719
+ return chunk7B52C2XE_js.__privateGet(this, _cache3).get(getCacheKey2(args));
1720
+ }
1721
+ }
1722
+ clearAll() {
1723
+ chunk7B52C2XE_js.__privateGet(this, _cache3).clear();
1724
+ }
1725
+ };
1726
+ _emitter3 = new WeakMap();
1727
+ _cache3 = new WeakMap();
1728
+
1729
+ // src/preferences/preference.ts
1730
+ var _emitter4, _apiService, _cache4, _useCache2;
1731
+ var Preference = class {
1732
+ constructor(preference, {
1733
+ emitterInstance,
1734
+ inboxServiceInstance,
1735
+ cache,
1736
+ useCache
1737
+ }) {
1738
+ chunk7B52C2XE_js.__privateAdd(this, _emitter4);
1739
+ chunk7B52C2XE_js.__privateAdd(this, _apiService);
1740
+ chunk7B52C2XE_js.__privateAdd(this, _cache4);
1741
+ chunk7B52C2XE_js.__privateAdd(this, _useCache2);
1742
+ chunk7B52C2XE_js.__privateSet(this, _emitter4, emitterInstance);
1743
+ chunk7B52C2XE_js.__privateSet(this, _apiService, inboxServiceInstance);
1744
+ chunk7B52C2XE_js.__privateSet(this, _cache4, cache);
1745
+ chunk7B52C2XE_js.__privateSet(this, _useCache2, useCache);
1746
+ this.level = preference.level;
1747
+ this.enabled = preference.enabled;
1748
+ this.channels = preference.channels;
1749
+ this.workflow = preference.workflow;
1750
+ }
1751
+ update({
1752
+ channels,
1753
+ channelPreferences
1754
+ }) {
1755
+ var _a;
1756
+ return updatePreference({
1757
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
1758
+ apiService: chunk7B52C2XE_js.__privateGet(this, _apiService),
1759
+ cache: chunk7B52C2XE_js.__privateGet(this, _cache4),
1760
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache2),
1761
+ args: {
1762
+ workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
1763
+ channels: channels || channelPreferences,
1764
+ preference: this
1765
+ }
1766
+ });
1767
+ }
1768
+ };
1769
+ _emitter4 = new WeakMap();
1770
+ _apiService = new WeakMap();
1771
+ _cache4 = new WeakMap();
1772
+ _useCache2 = new WeakMap();
1773
+
1774
+ // src/preferences/helpers.ts
1775
+ var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
1776
+ emitter,
1777
+ apiService,
1778
+ cache,
1779
+ useCache,
1780
+ args
1781
+ }) {
1782
+ var _a;
1783
+ const { channels } = args;
1784
+ const workflowId = "workflowId" in args ? args.workflowId : (_a = args.preference.workflow) == null ? void 0 : _a.id;
1785
+ try {
1786
+ emitter.emit("preference.update.pending", {
1787
+ args,
1788
+ data: "preference" in args ? new Preference(
1789
+ chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, args.preference), {
1790
+ channels: chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, args.preference.channels), channels)
1791
+ }),
1792
+ {
1793
+ emitterInstance: emitter,
1794
+ inboxServiceInstance: apiService,
1795
+ cache,
1796
+ useCache
1613
1797
  }
1614
1798
  ) : void 0
1615
1799
  });
@@ -1722,139 +1906,6 @@ var optimisticUpdateWorkflowPreferences = ({
1722
1906
  });
1723
1907
  };
1724
1908
 
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
1909
  // src/preferences/preferences.ts
1859
1910
  var _useCache3;
1860
1911
  var Preferences = class extends BaseModule {
@@ -2027,12 +2078,13 @@ var Session = class {
2027
2078
  _emitter5 = new WeakMap();
2028
2079
  _inboxService2 = new WeakMap();
2029
2080
  _options = new WeakMap();
2030
- var PRODUCTION_SOCKET_URL = "https://ws.novu.co";
2081
+ var PRODUCTION_SOCKET_URL = "wss://socket.novu.co";
2031
2082
  var NOTIFICATION_RECEIVED = "notifications.notification_received";
2032
2083
  var UNSEEN_COUNT_CHANGED = "notifications.unseen_count_changed";
2033
2084
  var UNREAD_COUNT_CHANGED = "notifications.unread_count_changed";
2034
2085
  var mapToNotification = ({
2035
2086
  _id,
2087
+ transactionId,
2036
2088
  content,
2037
2089
  read: read2,
2038
2090
  seen: seen2,
@@ -2071,6 +2123,7 @@ var mapToNotification = ({
2071
2123
  const actionStatus = (_g = cta.action) == null ? void 0 : _g.status;
2072
2124
  return chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({
2073
2125
  id: _id,
2126
+ transactionId,
2074
2127
  subject,
2075
2128
  body: content,
2076
2129
  to,
@@ -2114,8 +2167,8 @@ var mapToNotification = ({
2114
2167
  workflow
2115
2168
  });
2116
2169
  };
2117
- var _token, _emitter6, _socketIo, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _Socket_instances, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
2118
- var Socket = class extends BaseModule {
2170
+ var _token, _emitter6, _partySocket, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _handleMessage, _PartySocketClient_instances, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
2171
+ var PartySocketClient = class extends BaseModule {
2119
2172
  constructor({
2120
2173
  socketUrl,
2121
2174
  inboxServiceInstance,
@@ -2125,25 +2178,62 @@ var Socket = class extends BaseModule {
2125
2178
  eventEmitterInstance,
2126
2179
  inboxServiceInstance
2127
2180
  });
2128
- chunk7B52C2XE_js.__privateAdd(this, _Socket_instances);
2181
+ chunk7B52C2XE_js.__privateAdd(this, _PartySocketClient_instances);
2129
2182
  chunk7B52C2XE_js.__privateAdd(this, _token);
2130
2183
  chunk7B52C2XE_js.__privateAdd(this, _emitter6);
2131
- chunk7B52C2XE_js.__privateAdd(this, _socketIo);
2184
+ chunk7B52C2XE_js.__privateAdd(this, _partySocket);
2132
2185
  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
- });
2186
+ chunk7B52C2XE_js.__privateAdd(this, _notificationReceived, (event) => {
2187
+ try {
2188
+ const data = JSON.parse(event.data);
2189
+ if (data.event === "notification_received" /* RECEIVED */) {
2190
+ chunk7B52C2XE_js.__privateGet(this, _emitter6).emit(NOTIFICATION_RECEIVED, {
2191
+ result: new Notification(mapToNotification(data.data.message), chunk7B52C2XE_js.__privateGet(this, _emitter6), this._inboxService)
2192
+ });
2193
+ }
2194
+ } catch (error) {
2195
+ console.log("error", error);
2196
+ }
2137
2197
  });
2138
- chunk7B52C2XE_js.__privateAdd(this, _unseenCountChanged, ({ unseenCount }) => {
2139
- chunk7B52C2XE_js.__privateGet(this, _emitter6).emit(UNSEEN_COUNT_CHANGED, {
2140
- result: unseenCount
2141
- });
2198
+ chunk7B52C2XE_js.__privateAdd(this, _unseenCountChanged, (event) => {
2199
+ try {
2200
+ const data = JSON.parse(event.data);
2201
+ if (data.event === "unseen_count_changed" /* UNSEEN */) {
2202
+ chunk7B52C2XE_js.__privateGet(this, _emitter6).emit(UNSEEN_COUNT_CHANGED, {
2203
+ result: data.data.unseenCount
2204
+ });
2205
+ }
2206
+ } catch (error) {
2207
+ }
2142
2208
  });
2143
- chunk7B52C2XE_js.__privateAdd(this, _unreadCountChanged, ({ unreadCount }) => {
2144
- chunk7B52C2XE_js.__privateGet(this, _emitter6).emit(UNREAD_COUNT_CHANGED, {
2145
- result: unreadCount
2146
- });
2209
+ chunk7B52C2XE_js.__privateAdd(this, _unreadCountChanged, (event) => {
2210
+ try {
2211
+ const data = JSON.parse(event.data);
2212
+ if (data.event === "unread_count_changed" /* UNREAD */) {
2213
+ chunk7B52C2XE_js.__privateGet(this, _emitter6).emit(UNREAD_COUNT_CHANGED, {
2214
+ result: data.data.unreadCount
2215
+ });
2216
+ }
2217
+ } catch (error) {
2218
+ }
2219
+ });
2220
+ chunk7B52C2XE_js.__privateAdd(this, _handleMessage, (event) => {
2221
+ try {
2222
+ const data = JSON.parse(event.data);
2223
+ switch (data.event) {
2224
+ case "notification_received" /* RECEIVED */:
2225
+ chunk7B52C2XE_js.__privateGet(this, _notificationReceived).call(this, event);
2226
+ break;
2227
+ case "unseen_count_changed" /* UNSEEN */:
2228
+ chunk7B52C2XE_js.__privateGet(this, _unseenCountChanged).call(this, event);
2229
+ break;
2230
+ case "unread_count_changed" /* UNREAD */:
2231
+ chunk7B52C2XE_js.__privateGet(this, _unreadCountChanged).call(this, event);
2232
+ break;
2233
+ default:
2234
+ }
2235
+ } catch (error) {
2236
+ }
2147
2237
  });
2148
2238
  chunk7B52C2XE_js.__privateSet(this, _emitter6, eventEmitterInstance);
2149
2239
  chunk7B52C2XE_js.__privateSet(this, _socketUrl, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL);
@@ -2157,61 +2247,55 @@ var Socket = class extends BaseModule {
2157
2247
  connect() {
2158
2248
  return chunk7B52C2XE_js.__async(this, null, function* () {
2159
2249
  if (chunk7B52C2XE_js.__privateGet(this, _token)) {
2160
- return chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, handleConnectSocket_fn).call(this);
2250
+ return chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn).call(this);
2161
2251
  }
2162
- return this.callWithSession(chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, handleConnectSocket_fn).bind(this));
2252
+ return this.callWithSession(chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn).bind(this));
2163
2253
  });
2164
2254
  }
2165
2255
  disconnect() {
2166
2256
  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);
2257
+ if (chunk7B52C2XE_js.__privateGet(this, _partySocket)) {
2258
+ return chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn).call(this);
2169
2259
  }
2170
- return this.callWithSession(chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, handleDisconnectSocket_fn).bind(this));
2260
+ return this.callWithSession(chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn).bind(this));
2171
2261
  });
2172
2262
  }
2173
2263
  };
2174
2264
  _token = new WeakMap();
2175
2265
  _emitter6 = new WeakMap();
2176
- _socketIo = new WeakMap();
2266
+ _partySocket = new WeakMap();
2177
2267
  _socketUrl = new WeakMap();
2178
2268
  _notificationReceived = new WeakMap();
2179
2269
  _unseenCountChanged = new WeakMap();
2180
2270
  _unreadCountChanged = new WeakMap();
2181
- _Socket_instances = new WeakSet();
2271
+ _handleMessage = new WeakMap();
2272
+ _PartySocketClient_instances = new WeakSet();
2182
2273
  initializeSocket_fn = function() {
2183
2274
  return chunk7B52C2XE_js.__async(this, null, function* () {
2184
- var _a, _b, _c;
2185
- if (!!chunk7B52C2XE_js.__privateGet(this, _socketIo)) {
2275
+ if (chunk7B52C2XE_js.__privateGet(this, _partySocket)) {
2186
2276
  return;
2187
2277
  }
2188
2278
  const args = { socketUrl: chunk7B52C2XE_js.__privateGet(this, _socketUrl) };
2189
2279
  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", () => {
2280
+ const url = new URL(chunk7B52C2XE_js.__privateGet(this, _socketUrl));
2281
+ url.searchParams.set("token", chunk7B52C2XE_js.__privateGet(this, _token));
2282
+ chunk7B52C2XE_js.__privateSet(this, _partySocket, new partysocket.WebSocket(url.toString()));
2283
+ chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("open", () => {
2198
2284
  chunk7B52C2XE_js.__privateGet(this, _emitter6).emit("socket.connect.resolved", { args });
2199
2285
  });
2200
- chunk7B52C2XE_js.__privateGet(this, _socketIo).on("connect_error", (error) => {
2286
+ chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("error", (error) => {
2201
2287
  chunk7B52C2XE_js.__privateGet(this, _emitter6).emit("socket.connect.resolved", { args, error });
2202
2288
  });
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));
2289
+ chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("message", chunk7B52C2XE_js.__privateGet(this, _handleMessage));
2206
2290
  });
2207
2291
  };
2208
2292
  handleConnectSocket_fn = function() {
2209
2293
  return chunk7B52C2XE_js.__async(this, null, function* () {
2210
2294
  try {
2211
- yield chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, initializeSocket_fn).call(this);
2295
+ yield chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, initializeSocket_fn).call(this);
2212
2296
  return {};
2213
2297
  } catch (error) {
2214
- return { error: new NovuError("Failed to initialize the socket", error) };
2298
+ return { error: new NovuError("Failed to initialize the PartySocket", error) };
2215
2299
  }
2216
2300
  });
2217
2301
  };
@@ -2219,20 +2303,21 @@ handleDisconnectSocket_fn = function() {
2219
2303
  return chunk7B52C2XE_js.__async(this, null, function* () {
2220
2304
  var _a;
2221
2305
  try {
2222
- (_a = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _a.disconnect();
2223
- chunk7B52C2XE_js.__privateSet(this, _socketIo, void 0);
2306
+ (_a = chunk7B52C2XE_js.__privateGet(this, _partySocket)) == null ? void 0 : _a.close();
2307
+ chunk7B52C2XE_js.__privateSet(this, _partySocket, void 0);
2224
2308
  return {};
2225
2309
  } catch (error) {
2226
- return { error: new NovuError("Failed to disconnect from the socket", error) };
2310
+ return { error: new NovuError("Failed to disconnect from the PartySocket", error) };
2227
2311
  }
2228
2312
  });
2229
2313
  };
2230
- var PRODUCTION_SOCKET_URL2 = "wss://socket.novu.co";
2314
+ var PRODUCTION_SOCKET_URL2 = "https://ws.novu.co";
2231
2315
  var NOTIFICATION_RECEIVED2 = "notifications.notification_received";
2232
2316
  var UNSEEN_COUNT_CHANGED2 = "notifications.unseen_count_changed";
2233
2317
  var UNREAD_COUNT_CHANGED2 = "notifications.unread_count_changed";
2234
2318
  var mapToNotification2 = ({
2235
2319
  _id,
2320
+ transactionId,
2236
2321
  content,
2237
2322
  read: read2,
2238
2323
  seen: seen2,
@@ -2271,6 +2356,7 @@ var mapToNotification2 = ({
2271
2356
  const actionStatus = (_g = cta.action) == null ? void 0 : _g.status;
2272
2357
  return chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({
2273
2358
  id: _id,
2359
+ transactionId,
2274
2360
  subject,
2275
2361
  body: content,
2276
2362
  to,
@@ -2314,8 +2400,8 @@ var mapToNotification2 = ({
2314
2400
  workflow
2315
2401
  });
2316
2402
  };
2317
- var _token2, _emitter7, _partySocket, _socketUrl2, _notificationReceived2, _unseenCountChanged2, _unreadCountChanged2, _handleMessage, _PartySocketClient_instances, initializeSocket_fn2, handleConnectSocket_fn2, handleDisconnectSocket_fn2;
2318
- var PartySocketClient = class extends BaseModule {
2403
+ var _token2, _emitter7, _socketIo, _socketUrl2, _notificationReceived2, _unseenCountChanged2, _unreadCountChanged2, _Socket_instances, initializeSocket_fn2, handleConnectSocket_fn2, handleDisconnectSocket_fn2;
2404
+ var Socket = class extends BaseModule {
2319
2405
  constructor({
2320
2406
  socketUrl,
2321
2407
  inboxServiceInstance,
@@ -2325,62 +2411,25 @@ var PartySocketClient = class extends BaseModule {
2325
2411
  eventEmitterInstance,
2326
2412
  inboxServiceInstance
2327
2413
  });
2328
- chunk7B52C2XE_js.__privateAdd(this, _PartySocketClient_instances);
2414
+ chunk7B52C2XE_js.__privateAdd(this, _Socket_instances);
2329
2415
  chunk7B52C2XE_js.__privateAdd(this, _token2);
2330
2416
  chunk7B52C2XE_js.__privateAdd(this, _emitter7);
2331
- chunk7B52C2XE_js.__privateAdd(this, _partySocket);
2417
+ chunk7B52C2XE_js.__privateAdd(this, _socketIo);
2332
2418
  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
- }
2419
+ chunk7B52C2XE_js.__privateAdd(this, _notificationReceived2, ({ message }) => {
2420
+ chunk7B52C2XE_js.__privateGet(this, _emitter7).emit(NOTIFICATION_RECEIVED2, {
2421
+ result: new Notification(mapToNotification2(message), chunk7B52C2XE_js.__privateGet(this, _emitter7), this._inboxService)
2422
+ });
2355
2423
  });
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
- }
2424
+ chunk7B52C2XE_js.__privateAdd(this, _unseenCountChanged2, ({ unseenCount }) => {
2425
+ chunk7B52C2XE_js.__privateGet(this, _emitter7).emit(UNSEEN_COUNT_CHANGED2, {
2426
+ result: unseenCount
2427
+ });
2366
2428
  });
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
- }
2429
+ chunk7B52C2XE_js.__privateAdd(this, _unreadCountChanged2, ({ unreadCount }) => {
2430
+ chunk7B52C2XE_js.__privateGet(this, _emitter7).emit(UNREAD_COUNT_CHANGED2, {
2431
+ result: unreadCount
2432
+ });
2384
2433
  });
2385
2434
  chunk7B52C2XE_js.__privateSet(this, _emitter7, eventEmitterInstance);
2386
2435
  chunk7B52C2XE_js.__privateSet(this, _socketUrl2, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL2);
@@ -2394,55 +2443,61 @@ var PartySocketClient = class extends BaseModule {
2394
2443
  connect() {
2395
2444
  return chunk7B52C2XE_js.__async(this, null, function* () {
2396
2445
  if (chunk7B52C2XE_js.__privateGet(this, _token2)) {
2397
- return chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn2).call(this);
2446
+ return chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, handleConnectSocket_fn2).call(this);
2398
2447
  }
2399
- return this.callWithSession(chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn2).bind(this));
2448
+ return this.callWithSession(chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, handleConnectSocket_fn2).bind(this));
2400
2449
  });
2401
2450
  }
2402
2451
  disconnect() {
2403
2452
  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);
2453
+ if (chunk7B52C2XE_js.__privateGet(this, _socketIo)) {
2454
+ return chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, handleDisconnectSocket_fn2).call(this);
2406
2455
  }
2407
- return this.callWithSession(chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn2).bind(this));
2456
+ return this.callWithSession(chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, handleDisconnectSocket_fn2).bind(this));
2408
2457
  });
2409
2458
  }
2410
2459
  };
2411
2460
  _token2 = new WeakMap();
2412
2461
  _emitter7 = new WeakMap();
2413
- _partySocket = new WeakMap();
2462
+ _socketIo = new WeakMap();
2414
2463
  _socketUrl2 = new WeakMap();
2415
2464
  _notificationReceived2 = new WeakMap();
2416
2465
  _unseenCountChanged2 = new WeakMap();
2417
2466
  _unreadCountChanged2 = new WeakMap();
2418
- _handleMessage = new WeakMap();
2419
- _PartySocketClient_instances = new WeakSet();
2467
+ _Socket_instances = new WeakSet();
2420
2468
  initializeSocket_fn2 = function() {
2421
2469
  return chunk7B52C2XE_js.__async(this, null, function* () {
2422
- if (chunk7B52C2XE_js.__privateGet(this, _partySocket)) {
2470
+ var _a, _b, _c;
2471
+ if (chunk7B52C2XE_js.__privateGet(this, _socketIo)) {
2423
2472
  return;
2424
2473
  }
2425
2474
  const args = { socketUrl: chunk7B52C2XE_js.__privateGet(this, _socketUrl2) };
2426
2475
  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", () => {
2476
+ chunk7B52C2XE_js.__privateSet(this, _socketIo, io__default.default(chunk7B52C2XE_js.__privateGet(this, _socketUrl2), {
2477
+ reconnectionDelayMax: 1e4,
2478
+ transports: ["websocket"],
2479
+ query: {
2480
+ token: `${chunk7B52C2XE_js.__privateGet(this, _token2)}`
2481
+ }
2482
+ }));
2483
+ chunk7B52C2XE_js.__privateGet(this, _socketIo).on("connect", () => {
2431
2484
  chunk7B52C2XE_js.__privateGet(this, _emitter7).emit("socket.connect.resolved", { args });
2432
2485
  });
2433
- chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("error", (error) => {
2486
+ chunk7B52C2XE_js.__privateGet(this, _socketIo).on("connect_error", (error) => {
2434
2487
  chunk7B52C2XE_js.__privateGet(this, _emitter7).emit("socket.connect.resolved", { args, error });
2435
2488
  });
2436
- chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("message", chunk7B52C2XE_js.__privateGet(this, _handleMessage));
2489
+ (_a = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _a.on("notification_received" /* RECEIVED */, chunk7B52C2XE_js.__privateGet(this, _notificationReceived2));
2490
+ (_b = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _b.on("unseen_count_changed" /* UNSEEN */, chunk7B52C2XE_js.__privateGet(this, _unseenCountChanged2));
2491
+ (_c = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _c.on("unread_count_changed" /* UNREAD */, chunk7B52C2XE_js.__privateGet(this, _unreadCountChanged2));
2437
2492
  });
2438
2493
  };
2439
2494
  handleConnectSocket_fn2 = function() {
2440
2495
  return chunk7B52C2XE_js.__async(this, null, function* () {
2441
2496
  try {
2442
- yield chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, initializeSocket_fn2).call(this);
2497
+ yield chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, initializeSocket_fn2).call(this);
2443
2498
  return {};
2444
2499
  } catch (error) {
2445
- return { error: new NovuError("Failed to initialize the PartySocket", error) };
2500
+ return { error: new NovuError("Failed to initialize the socket", error) };
2446
2501
  }
2447
2502
  });
2448
2503
  };
@@ -2450,11 +2505,11 @@ handleDisconnectSocket_fn2 = function() {
2450
2505
  return chunk7B52C2XE_js.__async(this, null, function* () {
2451
2506
  var _a;
2452
2507
  try {
2453
- (_a = chunk7B52C2XE_js.__privateGet(this, _partySocket)) == null ? void 0 : _a.close();
2454
- chunk7B52C2XE_js.__privateSet(this, _partySocket, void 0);
2508
+ (_a = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _a.disconnect();
2509
+ chunk7B52C2XE_js.__privateSet(this, _socketIo, void 0);
2455
2510
  return {};
2456
2511
  } catch (error) {
2457
- return { error: new NovuError("Failed to disconnect from the PartySocket", error) };
2512
+ return { error: new NovuError("Failed to disconnect from the socket", error) };
2458
2513
  }
2459
2514
  });
2460
2515
  };
@@ -2462,17 +2517,17 @@ handleDisconnectSocket_fn2 = function() {
2462
2517
  // src/ws/socket-factory.ts
2463
2518
  var PARTY_SOCKET_URLS = [
2464
2519
  "wss://eu.socket.novu.co",
2465
- PRODUCTION_SOCKET_URL2,
2520
+ PRODUCTION_SOCKET_URL,
2466
2521
  "wss://socket.novu-staging.co",
2467
2522
  "wss://socket-worker-local.cli-shortener.workers.dev"
2468
2523
  ];
2469
2524
  var URL_TRANSFORMATIONS = {
2470
2525
  "https://eu.ws.novu.co": "wss://eu.socket.novu.co",
2471
- "https://ws.novu.co": PRODUCTION_SOCKET_URL2,
2526
+ "https://ws.novu.co": PRODUCTION_SOCKET_URL,
2472
2527
  "https://dev.ws.novu.co": "wss://socket.novu-staging.co"
2473
2528
  };
2474
2529
  function transformSocketUrl(socketUrl) {
2475
- if (!socketUrl) return PRODUCTION_SOCKET_URL2;
2530
+ if (!socketUrl) return PRODUCTION_SOCKET_URL;
2476
2531
  return URL_TRANSFORMATIONS[socketUrl] || socketUrl;
2477
2532
  }
2478
2533
  function shouldUsePartySocket(socketUrl) {
@@ -2519,7 +2574,7 @@ var Novu = class {
2519
2574
  {
2520
2575
  applicationIdentifier: options.applicationIdentifier || "",
2521
2576
  subscriberHash: options.subscriberHash,
2522
- subscriber: chunkQFZ5WJGI_js.buildSubscriber({ subscriberId: options.subscriberId, subscriber: options.subscriber })
2577
+ subscriber: chunkZB7IPCHY_js.buildSubscriber({ subscriberId: options.subscriberId, subscriber: options.subscriber })
2523
2578
  },
2524
2579
  chunk7B52C2XE_js.__privateGet(this, _inboxService3),
2525
2580
  chunk7B52C2XE_js.__privateGet(this, _emitter8)
@@ -2580,5 +2635,8 @@ exports.Novu = Novu;
2580
2635
  exports.PreferenceLevel = PreferenceLevel;
2581
2636
  exports.WebSocketEvent = WebSocketEvent;
2582
2637
  exports.areTagsEqual = areTagsEqual;
2638
+ exports.checkNotificationDataFilter = checkNotificationDataFilter;
2639
+ exports.checkNotificationMatchesFilter = checkNotificationMatchesFilter;
2640
+ exports.checkNotificationTagFilter = checkNotificationTagFilter;
2583
2641
  exports.isBrowser = isBrowser;
2584
2642
  exports.isSameFilter = isSameFilter;