@novu/js 2.5.0 → 2.6.1

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.
@@ -823,7 +823,8 @@ var Notifications = class extends BaseModule {
823
823
  return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
824
824
  const args = chunk7B52C2XE_js.__spreadValues({ limit }, restOptions);
825
825
  try {
826
- let data = chunk7B52C2XE_js.__privateGet(this, _useCache) ? this.cache.getAll(args) : void 0;
826
+ const shouldUseCache = "useCache" in args ? args.useCache : chunk7B52C2XE_js.__privateGet(this, _useCache);
827
+ let data = shouldUseCache ? this.cache.getAll(args) : void 0;
827
828
  this._emitter.emit("notifications.list.pending", { args, data });
828
829
  if (!data) {
829
830
  const response = yield this._inboxService.fetchNotifications(chunk7B52C2XE_js.__spreadValues({
@@ -834,7 +835,7 @@ var Notifications = class extends BaseModule {
834
835
  filter: response.filter,
835
836
  notifications: response.data.map((el) => new Notification(el, this._emitter, this._inboxService))
836
837
  };
837
- if (chunk7B52C2XE_js.__privateGet(this, _useCache)) {
838
+ if (shouldUseCache) {
838
839
  this.cache.set(args, data);
839
840
  data = this.cache.getAll(args);
840
841
  }
@@ -1061,44 +1062,12 @@ _emitter3 = new WeakMap();
1061
1062
  _inboxService2 = new WeakMap();
1062
1063
  _options = new WeakMap();
1063
1064
 
1064
- // src/preferences/preference.ts
1065
- var _emitter4, _apiService;
1066
- var Preference = class {
1067
- constructor(preference, { emitterInstance, inboxServiceInstance }) {
1068
- chunk7B52C2XE_js.__privateAdd(this, _emitter4);
1069
- chunk7B52C2XE_js.__privateAdd(this, _apiService);
1070
- chunk7B52C2XE_js.__privateSet(this, _emitter4, emitterInstance);
1071
- chunk7B52C2XE_js.__privateSet(this, _apiService, inboxServiceInstance);
1072
- this.level = preference.level;
1073
- this.enabled = preference.enabled;
1074
- this.channels = preference.channels;
1075
- this.workflow = preference.workflow;
1076
- }
1077
- update({ channelPreferences }) {
1078
- var _a;
1079
- return updatePreference({
1080
- emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
1081
- apiService: chunk7B52C2XE_js.__privateGet(this, _apiService),
1082
- args: {
1083
- workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
1084
- channelPreferences,
1085
- preference: {
1086
- level: this.level,
1087
- enabled: this.enabled,
1088
- channels: this.channels,
1089
- workflow: this.workflow
1090
- }
1091
- }
1092
- });
1093
- }
1094
- };
1095
- _emitter4 = new WeakMap();
1096
- _apiService = new WeakMap();
1097
-
1098
1065
  // src/preferences/helpers.ts
1099
1066
  var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
1100
1067
  emitter,
1101
1068
  apiService,
1069
+ cache,
1070
+ useCache,
1102
1071
  args
1103
1072
  }) {
1104
1073
  const { workflowId, channelPreferences } = args;
@@ -1111,7 +1080,9 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function*
1111
1080
  }),
1112
1081
  {
1113
1082
  emitterInstance: emitter,
1114
- inboxServiceInstance: apiService
1083
+ inboxServiceInstance: apiService,
1084
+ cache,
1085
+ useCache
1115
1086
  }
1116
1087
  ) : void 0
1117
1088
  });
@@ -1119,11 +1090,14 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function*
1119
1090
  if (workflowId) {
1120
1091
  response = yield apiService.updateWorkflowPreferences({ workflowId, channelPreferences });
1121
1092
  } else {
1093
+ optimisticUpdateWorkflowPreferences({ emitter, apiService, cache, useCache, args });
1122
1094
  response = yield apiService.updateGlobalPreferences(channelPreferences);
1123
1095
  }
1124
1096
  const preference = new Preference(response, {
1125
1097
  emitterInstance: emitter,
1126
- inboxServiceInstance: apiService
1098
+ inboxServiceInstance: apiService,
1099
+ cache,
1100
+ useCache
1127
1101
  });
1128
1102
  emitter.emit("preference.update.resolved", { args, data: preference });
1129
1103
  return { data: preference };
@@ -1132,6 +1106,90 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function*
1132
1106
  return { error: new NovuError("Failed to fetch notifications", error) };
1133
1107
  }
1134
1108
  });
1109
+ var optimisticUpdateWorkflowPreferences = ({
1110
+ emitter,
1111
+ apiService,
1112
+ cache,
1113
+ useCache,
1114
+ args
1115
+ }) => {
1116
+ const allPreferences = useCache ? cache == null ? void 0 : cache.getAll({}) : void 0;
1117
+ allPreferences == null ? void 0 : allPreferences.forEach((el) => {
1118
+ var _a;
1119
+ if (el.level === "template" /* TEMPLATE */) {
1120
+ const mergedPreference = chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, el), {
1121
+ channels: Object.entries(el.channels).reduce((acc, [key, value]) => {
1122
+ var _a2;
1123
+ const channelType = key;
1124
+ acc[channelType] = (_a2 = args.channelPreferences[channelType]) != null ? _a2 : value;
1125
+ return acc;
1126
+ }, {})
1127
+ });
1128
+ const updatedPreference = args.preference ? new Preference(mergedPreference, {
1129
+ emitterInstance: emitter,
1130
+ inboxServiceInstance: apiService,
1131
+ cache,
1132
+ useCache
1133
+ }) : void 0;
1134
+ if (updatedPreference) {
1135
+ emitter.emit("preference.update.pending", {
1136
+ args: {
1137
+ workflowId: (_a = el.workflow) == null ? void 0 : _a.id,
1138
+ channelPreferences: updatedPreference.channels
1139
+ },
1140
+ data: updatedPreference
1141
+ });
1142
+ }
1143
+ }
1144
+ });
1145
+ };
1146
+
1147
+ // src/preferences/preference.ts
1148
+ var _emitter4, _apiService, _cache3, _useCache2;
1149
+ var Preference = class {
1150
+ constructor(preference, {
1151
+ emitterInstance,
1152
+ inboxServiceInstance,
1153
+ cache,
1154
+ useCache
1155
+ }) {
1156
+ chunk7B52C2XE_js.__privateAdd(this, _emitter4);
1157
+ chunk7B52C2XE_js.__privateAdd(this, _apiService);
1158
+ chunk7B52C2XE_js.__privateAdd(this, _cache3);
1159
+ chunk7B52C2XE_js.__privateAdd(this, _useCache2);
1160
+ chunk7B52C2XE_js.__privateSet(this, _emitter4, emitterInstance);
1161
+ chunk7B52C2XE_js.__privateSet(this, _apiService, inboxServiceInstance);
1162
+ chunk7B52C2XE_js.__privateSet(this, _cache3, cache);
1163
+ chunk7B52C2XE_js.__privateSet(this, _useCache2, useCache);
1164
+ this.level = preference.level;
1165
+ this.enabled = preference.enabled;
1166
+ this.channels = preference.channels;
1167
+ this.workflow = preference.workflow;
1168
+ }
1169
+ update({ channelPreferences }) {
1170
+ var _a;
1171
+ return updatePreference({
1172
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
1173
+ apiService: chunk7B52C2XE_js.__privateGet(this, _apiService),
1174
+ cache: chunk7B52C2XE_js.__privateGet(this, _cache3),
1175
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache2),
1176
+ args: {
1177
+ workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
1178
+ channelPreferences,
1179
+ preference: {
1180
+ level: this.level,
1181
+ enabled: this.enabled,
1182
+ channels: this.channels,
1183
+ workflow: this.workflow
1184
+ }
1185
+ }
1186
+ });
1187
+ }
1188
+ };
1189
+ _emitter4 = new WeakMap();
1190
+ _apiService = new WeakMap();
1191
+ _cache3 = new WeakMap();
1192
+ _useCache2 = new WeakMap();
1135
1193
 
1136
1194
  // src/cache/preferences-cache.ts
1137
1195
  var updateEvents2 = ["preference.update.pending", "preference.update.resolved"];
@@ -1145,13 +1203,13 @@ var excludeEmpty2 = ({ tags }) => Object.entries({ tags }).reduce((acc, [key, va
1145
1203
  var getCacheKey2 = ({ tags }) => {
1146
1204
  return JSON.stringify(excludeEmpty2({ tags }));
1147
1205
  };
1148
- var _emitter5, _cache3;
1206
+ var _emitter5, _cache4;
1149
1207
  var PreferencesCache = class {
1150
1208
  constructor({ emitterInstance }) {
1151
1209
  chunk7B52C2XE_js.__privateAdd(this, _emitter5);
1152
- chunk7B52C2XE_js.__privateAdd(this, _cache3);
1210
+ chunk7B52C2XE_js.__privateAdd(this, _cache4);
1153
1211
  this.updatePreference = (key, data) => {
1154
- const preferences = chunk7B52C2XE_js.__privateGet(this, _cache3).get(key);
1212
+ const preferences = chunk7B52C2XE_js.__privateGet(this, _cache4).get(key);
1155
1213
  if (!preferences) {
1156
1214
  return false;
1157
1215
  }
@@ -1166,16 +1224,16 @@ var PreferencesCache = class {
1166
1224
  }
1167
1225
  const updatedPreferences = [...preferences];
1168
1226
  updatedPreferences[index] = data;
1169
- chunk7B52C2XE_js.__privateGet(this, _cache3).set(key, updatedPreferences);
1227
+ chunk7B52C2XE_js.__privateGet(this, _cache4).set(key, updatedPreferences);
1170
1228
  return true;
1171
1229
  };
1172
1230
  this.handlePreferenceEvent = ({ data }) => {
1173
1231
  if (!data) {
1174
1232
  return;
1175
1233
  }
1176
- chunk7B52C2XE_js.__privateGet(this, _cache3).keys().forEach((key) => {
1234
+ chunk7B52C2XE_js.__privateGet(this, _cache4).keys().forEach((key) => {
1177
1235
  const hasUpdatedPreference = this.updatePreference(key, data);
1178
- const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache3).get(key);
1236
+ const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache4).get(key);
1179
1237
  if (!hasUpdatedPreference || !updatedPreference) {
1180
1238
  return;
1181
1239
  }
@@ -1188,28 +1246,28 @@ var PreferencesCache = class {
1188
1246
  updateEvents2.forEach((event) => {
1189
1247
  chunk7B52C2XE_js.__privateGet(this, _emitter5).on(event, this.handlePreferenceEvent);
1190
1248
  });
1191
- chunk7B52C2XE_js.__privateSet(this, _cache3, new InMemoryCache());
1249
+ chunk7B52C2XE_js.__privateSet(this, _cache4, new InMemoryCache());
1192
1250
  }
1193
1251
  has(args) {
1194
- return chunk7B52C2XE_js.__privateGet(this, _cache3).get(getCacheKey2(args)) !== void 0;
1252
+ return chunk7B52C2XE_js.__privateGet(this, _cache4).get(getCacheKey2(args)) !== void 0;
1195
1253
  }
1196
1254
  set(args, data) {
1197
- chunk7B52C2XE_js.__privateGet(this, _cache3).set(getCacheKey2(args), data);
1255
+ chunk7B52C2XE_js.__privateGet(this, _cache4).set(getCacheKey2(args), data);
1198
1256
  }
1199
1257
  getAll(args) {
1200
1258
  if (this.has(args)) {
1201
- return chunk7B52C2XE_js.__privateGet(this, _cache3).get(getCacheKey2(args));
1259
+ return chunk7B52C2XE_js.__privateGet(this, _cache4).get(getCacheKey2(args));
1202
1260
  }
1203
1261
  }
1204
1262
  clearAll() {
1205
- chunk7B52C2XE_js.__privateGet(this, _cache3).clear();
1263
+ chunk7B52C2XE_js.__privateGet(this, _cache4).clear();
1206
1264
  }
1207
1265
  };
1208
1266
  _emitter5 = new WeakMap();
1209
- _cache3 = new WeakMap();
1267
+ _cache4 = new WeakMap();
1210
1268
 
1211
1269
  // src/preferences/preferences.ts
1212
- var _useCache2;
1270
+ var _useCache3;
1213
1271
  var Preferences = class extends BaseModule {
1214
1272
  constructor({
1215
1273
  useCache,
@@ -1220,27 +1278,29 @@ var Preferences = class extends BaseModule {
1220
1278
  eventEmitterInstance,
1221
1279
  inboxServiceInstance
1222
1280
  });
1223
- chunk7B52C2XE_js.__privateAdd(this, _useCache2);
1281
+ chunk7B52C2XE_js.__privateAdd(this, _useCache3);
1224
1282
  this.cache = new PreferencesCache({
1225
1283
  emitterInstance: this._emitter
1226
1284
  });
1227
- chunk7B52C2XE_js.__privateSet(this, _useCache2, useCache);
1285
+ chunk7B52C2XE_js.__privateSet(this, _useCache3, useCache);
1228
1286
  }
1229
1287
  list() {
1230
1288
  return chunk7B52C2XE_js.__async(this, arguments, function* (args = {}) {
1231
1289
  return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
1232
1290
  try {
1233
- let data = chunk7B52C2XE_js.__privateGet(this, _useCache2) ? this.cache.getAll(args) : void 0;
1291
+ let data = chunk7B52C2XE_js.__privateGet(this, _useCache3) ? this.cache.getAll(args) : void 0;
1234
1292
  this._emitter.emit("preferences.list.pending", { args, data });
1235
1293
  if (!data) {
1236
1294
  const response = yield this._inboxService.fetchPreferences(args.tags);
1237
1295
  data = response.map(
1238
1296
  (el) => new Preference(el, {
1239
1297
  emitterInstance: this._emitter,
1240
- inboxServiceInstance: this._inboxService
1298
+ inboxServiceInstance: this._inboxService,
1299
+ cache: this.cache,
1300
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache3)
1241
1301
  })
1242
1302
  );
1243
- if (chunk7B52C2XE_js.__privateGet(this, _useCache2)) {
1303
+ if (chunk7B52C2XE_js.__privateGet(this, _useCache3)) {
1244
1304
  this.cache.set(args, data);
1245
1305
  data = this.cache.getAll(args);
1246
1306
  }
@@ -1254,17 +1314,8 @@ var Preferences = class extends BaseModule {
1254
1314
  }));
1255
1315
  });
1256
1316
  }
1257
- update(args) {
1258
- return chunk7B52C2XE_js.__async(this, null, function* () {
1259
- return this.callWithSession(
1260
- () => chunk7B52C2XE_js.__async(this, null, function* () {
1261
- return updatePreference({ emitter: this._emitter, apiService: this._inboxService, args });
1262
- })
1263
- );
1264
- });
1265
- }
1266
1317
  };
1267
- _useCache2 = new WeakMap();
1318
+ _useCache3 = new WeakMap();
1268
1319
  var PRODUCTION_SOCKET_URL = "https://ws.novu.co";
1269
1320
  var NOTIFICATION_RECEIVED = "notifications.notification_received";
1270
1321
  var UNSEEN_COUNT_CHANGED = "notifications.unseen_count_changed";
@@ -1542,7 +1593,7 @@ var InboxService = class {
1542
1593
  _httpClient = new WeakMap();
1543
1594
 
1544
1595
  // src/novu.ts
1545
- var version = "2.5.0";
1596
+ var version = "2.6.0";
1546
1597
  var name = "@novu/js";
1547
1598
  var userAgent = `${name}@${version}`;
1548
1599
  var _emitter7, _session, _socket, _inboxService3;
@@ -1,5 +1,5 @@
1
- import { N as NotificationFilter } from './novu-iUKr-1Nj.js';
2
- export { k as Action, A as ActionTypeEnum, m as ChannelPreference, f as ChannelType, C as CtaType, E as EventHandler, a as Events, F as FiltersCountResponse, q as IPreferenceOverride, I as InboxNotification, L as ListNotificationsResponse, i as MessageAction, M as MessageButton, t as Notification, e as NotificationActionStatus, d as NotificationButton, c as NotificationStatus, b as Novu, v as NovuError, s as NovuOptions, n as PaginatedResponse, u as Preference, P as PreferenceLevel, g as PreferenceOverrideSource, p as PreferenceOverrideSourceEnum, o as PreferencesResponse, R as Redirect, r as Result, h as Session, S as SocketEventNames, j as Subscriber, T as TODO, W as WebSocketEvent, l as Workflow } from './novu-iUKr-1Nj.js';
1
+ import { N as NotificationFilter } from './novu-C3OVXS9Q.js';
2
+ export { k as Action, A as ActionTypeEnum, m as ChannelPreference, f as ChannelType, C as CtaType, E as EventHandler, a as Events, F as FiltersCountResponse, q as IPreferenceOverride, I as InboxNotification, L as ListNotificationsResponse, i as MessageAction, M as MessageButton, t as Notification, e as NotificationActionStatus, d as NotificationButton, c as NotificationStatus, b as Novu, v as NovuError, s as NovuOptions, n as PaginatedResponse, u as Preference, P as PreferenceLevel, g as PreferenceOverrideSource, p as PreferenceOverrideSourceEnum, o as PreferencesResponse, R as Redirect, r as Result, h as Session, S as SocketEventNames, j as Subscriber, T as TODO, W as WebSocketEvent, l as Workflow } from './novu-C3OVXS9Q.js';
3
3
  import '@novu/client';
4
4
 
5
5
  declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
package/dist/cjs/index.js CHANGED
@@ -1,59 +1,59 @@
1
1
  'use strict';
2
2
 
3
- var chunkRK2WRT5F_js = require('./chunk-RK2WRT5F.js');
3
+ var chunkR7DABK4G_js = require('./chunk-R7DABK4G.js');
4
4
  require('./chunk-7B52C2XE.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "ActionTypeEnum", {
9
9
  enumerable: true,
10
- get: function () { return chunkRK2WRT5F_js.ActionTypeEnum; }
10
+ get: function () { return chunkR7DABK4G_js.ActionTypeEnum; }
11
11
  });
12
12
  Object.defineProperty(exports, "ChannelType", {
13
13
  enumerable: true,
14
- get: function () { return chunkRK2WRT5F_js.ChannelType; }
14
+ get: function () { return chunkR7DABK4G_js.ChannelType; }
15
15
  });
16
16
  Object.defineProperty(exports, "CtaType", {
17
17
  enumerable: true,
18
- get: function () { return chunkRK2WRT5F_js.CtaType; }
18
+ get: function () { return chunkR7DABK4G_js.CtaType; }
19
19
  });
20
20
  Object.defineProperty(exports, "NotificationActionStatus", {
21
21
  enumerable: true,
22
- get: function () { return chunkRK2WRT5F_js.NotificationActionStatus; }
22
+ get: function () { return chunkR7DABK4G_js.NotificationActionStatus; }
23
23
  });
24
24
  Object.defineProperty(exports, "NotificationButton", {
25
25
  enumerable: true,
26
- get: function () { return chunkRK2WRT5F_js.NotificationButton; }
26
+ get: function () { return chunkR7DABK4G_js.NotificationButton; }
27
27
  });
28
28
  Object.defineProperty(exports, "NotificationStatus", {
29
29
  enumerable: true,
30
- get: function () { return chunkRK2WRT5F_js.NotificationStatus; }
30
+ get: function () { return chunkR7DABK4G_js.NotificationStatus; }
31
31
  });
32
32
  Object.defineProperty(exports, "Novu", {
33
33
  enumerable: true,
34
- get: function () { return chunkRK2WRT5F_js.Novu; }
34
+ get: function () { return chunkR7DABK4G_js.Novu; }
35
35
  });
36
36
  Object.defineProperty(exports, "PreferenceLevel", {
37
37
  enumerable: true,
38
- get: function () { return chunkRK2WRT5F_js.PreferenceLevel; }
38
+ get: function () { return chunkR7DABK4G_js.PreferenceLevel; }
39
39
  });
40
40
  Object.defineProperty(exports, "PreferenceOverrideSource", {
41
41
  enumerable: true,
42
- get: function () { return chunkRK2WRT5F_js.PreferenceOverrideSource; }
42
+ get: function () { return chunkR7DABK4G_js.PreferenceOverrideSource; }
43
43
  });
44
44
  Object.defineProperty(exports, "PreferenceOverrideSourceEnum", {
45
45
  enumerable: true,
46
- get: function () { return chunkRK2WRT5F_js.PreferenceOverrideSourceEnum; }
46
+ get: function () { return chunkR7DABK4G_js.PreferenceOverrideSourceEnum; }
47
47
  });
48
48
  Object.defineProperty(exports, "WebSocketEvent", {
49
49
  enumerable: true,
50
- get: function () { return chunkRK2WRT5F_js.WebSocketEvent; }
50
+ get: function () { return chunkR7DABK4G_js.WebSocketEvent; }
51
51
  });
52
52
  Object.defineProperty(exports, "areTagsEqual", {
53
53
  enumerable: true,
54
- get: function () { return chunkRK2WRT5F_js.areTagsEqual; }
54
+ get: function () { return chunkR7DABK4G_js.areTagsEqual; }
55
55
  });
56
56
  Object.defineProperty(exports, "isSameFilter", {
57
57
  enumerable: true,
58
- get: function () { return chunkRK2WRT5F_js.isSameFilter; }
58
+ get: function () { return chunkR7DABK4G_js.isSameFilter; }
59
59
  });
@@ -5,6 +5,33 @@ declare class NovuError extends Error {
5
5
  constructor(message: string, originalError: unknown);
6
6
  }
7
7
 
8
+ type ListPreferencesArgs = {
9
+ tags?: string[];
10
+ };
11
+ type UpdatePreferencesArgs = {
12
+ workflowId?: string;
13
+ channelPreferences: ChannelPreference;
14
+ preference?: {
15
+ level: PreferenceLevel;
16
+ enabled: boolean;
17
+ channels: ChannelPreference;
18
+ workflow?: Workflow;
19
+ };
20
+ };
21
+
22
+ declare class PreferencesCache {
23
+ #private;
24
+ constructor({ emitterInstance }: {
25
+ emitterInstance: NovuEventEmitter;
26
+ });
27
+ private updatePreference;
28
+ private handlePreferenceEvent;
29
+ has(args: ListPreferencesArgs): boolean;
30
+ set(args: ListPreferencesArgs, data: Preference[]): void;
31
+ getAll(args: ListPreferencesArgs): Preference[] | undefined;
32
+ clearAll(): void;
33
+ }
34
+
8
35
  type PreferenceLike = Pick<Preference, 'level' | 'enabled' | 'channels' | 'workflow'>;
9
36
  declare class Preference {
10
37
  #private;
@@ -12,9 +39,11 @@ declare class Preference {
12
39
  readonly enabled: boolean;
13
40
  readonly channels: ChannelPreference;
14
41
  readonly workflow?: Workflow;
15
- constructor(preference: PreferenceLike, { emitterInstance, inboxServiceInstance }: {
42
+ constructor(preference: PreferenceLike, { emitterInstance, inboxServiceInstance, cache, useCache, }: {
16
43
  emitterInstance: NovuEventEmitter;
17
44
  inboxServiceInstance: InboxService;
45
+ cache: PreferencesCache;
46
+ useCache: boolean;
18
47
  });
19
48
  update({ channelPreferences }: {
20
49
  channelPreferences: ChannelPreference;
@@ -293,6 +322,7 @@ type ListNotificationsArgs = {
293
322
  limit?: number;
294
323
  after?: string;
295
324
  offset?: number;
325
+ useCache?: boolean;
296
326
  };
297
327
  type ListNotificationsResponse = {
298
328
  notifications: Notification[];
@@ -399,20 +429,6 @@ declare class Notifications extends BaseModule {
399
429
  }): void;
400
430
  }
401
431
 
402
- type ListPreferencesArgs = {
403
- tags?: string[];
404
- };
405
- type UpdatePreferencesArgs = {
406
- workflowId?: string;
407
- channelPreferences: ChannelPreference;
408
- preference?: {
409
- level: PreferenceLevel;
410
- enabled: boolean;
411
- channels: ChannelPreference;
412
- workflow?: Workflow;
413
- };
414
- };
415
-
416
432
  type InitializeSessionArgs = {
417
433
  applicationIdentifier: string;
418
434
  subscriberId: string;
@@ -504,19 +520,6 @@ declare class NovuEventEmitter {
504
520
  emit<Key extends EventNames>(type: Key, event?: Events[Key]): void;
505
521
  }
506
522
 
507
- declare class PreferencesCache {
508
- #private;
509
- constructor({ emitterInstance }: {
510
- emitterInstance: NovuEventEmitter;
511
- });
512
- private updatePreference;
513
- private handlePreferenceEvent;
514
- has(args: ListPreferencesArgs): boolean;
515
- set(args: ListPreferencesArgs, data: Preference[]): void;
516
- getAll(args: ListPreferencesArgs): Preference[] | undefined;
517
- clearAll(): void;
518
- }
519
-
520
523
  declare class Preferences extends BaseModule {
521
524
  #private;
522
525
  readonly cache: PreferencesCache;
@@ -526,7 +529,6 @@ declare class Preferences extends BaseModule {
526
529
  eventEmitterInstance: NovuEventEmitter;
527
530
  });
528
531
  list(args?: ListPreferencesArgs): Result<Preference[]>;
529
- update(args: UpdatePreferencesArgs): Result<Preference>;
530
532
  }
531
533
 
532
534
  declare class Novu implements Pick<NovuEventEmitter, 'on'> {
@@ -1,5 +1,5 @@
1
- import { g as Theme } from '../types-G05b9m65.js';
2
- import '../novu-iUKr-1Nj.js';
1
+ import { g as Theme } from '../types-Bg3djGZK.js';
2
+ import '../novu-C3OVXS9Q.js';
3
3
  import '@novu/client';
4
4
 
5
5
  declare const dark: Theme;
@@ -1,4 +1,4 @@
1
- import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-iUKr-1Nj.js';
1
+ import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-C3OVXS9Q.js';
2
2
 
3
3
  declare const defaultLocalization: {
4
4
  readonly locale: "en-US";
@@ -1,7 +1,7 @@
1
- import { s as NovuOptions } from '../novu-iUKr-1Nj.js';
2
- export { t as Notification } from '../novu-iUKr-1Nj.js';
3
- import { N as NotificationRenderer, B as BellRenderer, a as NotificationClickHandler, b as NotificationActionClickHandler, c as NovuProviderProps, d as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, R as RouterPush } from '../types-G05b9m65.js';
4
- export { e as AppearanceKey, C as CSSProperties, E as ElementStyles, f as Elements, i as LocalizationKey, h as NotificationStatus, g as Theme, V as Variables } from '../types-G05b9m65.js';
1
+ import { s as NovuOptions } from '../novu-C3OVXS9Q.js';
2
+ export { t as Notification } from '../novu-C3OVXS9Q.js';
3
+ import { N as NotificationRenderer, B as BellRenderer, a as NotificationClickHandler, b as NotificationActionClickHandler, c as NovuProviderProps, d as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, R as RouterPush } from '../types-Bg3djGZK.js';
4
+ export { e as AppearanceKey, C as CSSProperties, E as ElementStyles, f as Elements, i as LocalizationKey, h as NotificationStatus, g as Theme, V as Variables } from '../types-Bg3djGZK.js';
5
5
  import * as solid_js from 'solid-js';
6
6
  import { ComponentProps } from 'solid-js';
7
7
  import { MountableElement } from 'solid-js/web';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkRK2WRT5F_js = require('../chunk-RK2WRT5F.js');
3
+ var chunkR7DABK4G_js = require('../chunk-R7DABK4G.js');
4
4
  var chunkERC62PGI_js = require('../chunk-ERC62PGI.js');
5
5
  var chunk7B52C2XE_js = require('../chunk-7B52C2XE.js');
6
6
  var web = require('solid-js/web');
@@ -753,7 +753,7 @@ var useInboxContext = () => {
753
753
  };
754
754
  var NovuContext = solidJs.createContext(void 0);
755
755
  function NovuProvider(props) {
756
- const novu = solidJs.createMemo(() => props.novu || new chunkRK2WRT5F_js.Novu(props.options));
756
+ const novu = solidJs.createMemo(() => props.novu || new chunkR7DABK4G_js.Novu(props.options));
757
757
  return web.createComponent(NovuContext.Provider, {
758
758
  get value() {
759
759
  return novu();
@@ -2012,7 +2012,7 @@ var useNotificationsInfiniteScroll = (props) => {
2012
2012
  }));
2013
2013
  solidJs.onMount(() => {
2014
2014
  const listener = ({ data: data2 }) => {
2015
- if (!data2 || !chunkRK2WRT5F_js.isSameFilter(filter, data2.filter)) {
2015
+ if (!data2 || !chunkR7DABK4G_js.isSameFilter(filter, data2.filter)) {
2016
2016
  return;
2017
2017
  }
2018
2018
  mutate({ data: data2.notifications, hasMore: data2.hasMore });
@@ -2022,7 +2022,7 @@ var useNotificationsInfiniteScroll = (props) => {
2022
2022
  });
2023
2023
  solidJs.createEffect(() => {
2024
2024
  const newFilter = chunk7B52C2XE_js.__spreadValues({}, props.options());
2025
- if (chunkRK2WRT5F_js.isSameFilter(filter, newFilter)) {
2025
+ if (chunkR7DABK4G_js.isSameFilter(filter, newFilter)) {
2026
2026
  return;
2027
2027
  }
2028
2028
  novu.notifications.clearCache();
@@ -2072,7 +2072,7 @@ var useReadAll = (props) => {
2072
2072
  yield novu.notifications.readAll({ tags });
2073
2073
  (_a = props == null ? void 0 : props.onSuccess) == null ? void 0 : _a.call(props);
2074
2074
  } catch (error) {
2075
- (_b = props == null ? void 0 : props.onError) == null ? void 0 : _b.call(props, error);
2075
+ (_b = void 0 ) == null ? void 0 : _b.call(props, error);
2076
2076
  }
2077
2077
  });
2078
2078
  return { readAll };
@@ -2087,7 +2087,7 @@ var useArchiveAll = (props) => {
2087
2087
  yield novu.notifications.archiveAll({ tags });
2088
2088
  (_a = props == null ? void 0 : props.onSuccess) == null ? void 0 : _a.call(props);
2089
2089
  } catch (error) {
2090
- (_b = props == null ? void 0 : props.onError) == null ? void 0 : _b.call(props, error);
2090
+ (_b = void 0 ) == null ? void 0 : _b.call(props, error);
2091
2091
  }
2092
2092
  });
2093
2093
  return { archiveAll };
@@ -2102,7 +2102,7 @@ var useArchiveAllRead = (props) => {
2102
2102
  yield novu.notifications.archiveAllRead({ tags });
2103
2103
  (_a = props == null ? void 0 : props.onSuccess) == null ? void 0 : _a.call(props);
2104
2104
  } catch (error) {
2105
- (_b = props == null ? void 0 : props.onError) == null ? void 0 : _b.call(props, error);
2105
+ (_b = void 0 ) == null ? void 0 : _b.call(props, error);
2106
2106
  }
2107
2107
  });
2108
2108
  return { archiveAllRead };
@@ -3998,7 +3998,7 @@ var Renderer = (props) => {
3998
3998
  }
3999
3999
  });
4000
4000
  };
4001
- var version = "2.5.0";
4001
+ var version = "2.6.0";
4002
4002
  var cssHref = `https://cdn.jsdelivr.net/npm/@novu/js@${version}/dist/index.css`;
4003
4003
  var _dispose, _rootElement, _mountedElements, _setMountedElements, _appearance, _setAppearance, _localization, _setLocalization, _options, _setOptions, _tabs, _setTabs, _routerPush, _setRouterPush, _preferencesFilter, _setPreferencesFilter, _predefinedNovu, _NovuUI_instances, mountComponentRenderer_fn, updateComponentProps_fn;
4004
4004
  var NovuUI = class {