@novu/js 3.11.1 → 3.11.2-nightly.20251224.97b30e30dd

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.
Files changed (32) hide show
  1. package/dist/cjs/{chunk-MKYWGA37.js → chunk-AFLPFCXM.js} +1069 -294
  2. package/dist/cjs/{chunk-WFVHYVDM.js → chunk-CDGREQFE.js} +6 -0
  3. package/dist/cjs/index.d.ts +4 -3
  4. package/dist/cjs/index.js +26 -14
  5. package/dist/cjs/internal/index.d.ts +8 -2
  6. package/dist/cjs/internal/index.js +9 -5
  7. package/dist/{esm/novu-3CfttQ8e.d.mts → cjs/novu-DxuaDf-Z.d.ts} +28 -1
  8. package/dist/{esm/novu-event-emitter-C7GZ7-r1.d.mts → cjs/novu-event-emitter-BOA_6GfJ.d.ts} +195 -1
  9. package/dist/cjs/themes/index.d.ts +11 -5
  10. package/dist/cjs/themes/index.js +17 -1
  11. package/dist/cjs/types-Buzm23uF.d.ts +836 -0
  12. package/dist/cjs/ui/index.d.ts +74 -8
  13. package/dist/cjs/ui/index.js +1836 -261
  14. package/dist/esm/{chunk-76A4RQYD.mjs → chunk-GDLXUD4E.mjs} +1038 -265
  15. package/dist/esm/{chunk-GY4JXBST.mjs → chunk-SWKDFXVR.mjs} +6 -1
  16. package/dist/esm/index.d.mts +4 -3
  17. package/dist/esm/index.mjs +2 -2
  18. package/dist/esm/internal/index.d.mts +8 -2
  19. package/dist/esm/internal/index.mjs +1 -1
  20. package/dist/{cjs/novu-CKWESYFZ.d.ts → esm/novu-DY8vwRGE.d.mts} +28 -1
  21. package/dist/{cjs/novu-event-emitter-C7GZ7-r1.d.ts → esm/novu-event-emitter-BOA_6GfJ.d.mts} +195 -1
  22. package/dist/esm/themes/index.d.mts +11 -5
  23. package/dist/esm/themes/index.mjs +16 -2
  24. package/dist/esm/types-xBjzv9ok.d.mts +836 -0
  25. package/dist/esm/ui/index.d.mts +74 -8
  26. package/dist/esm/ui/index.mjs +1833 -257
  27. package/dist/index.css +1 -1
  28. package/dist/novu.min.js +12 -12
  29. package/dist/novu.min.js.gz +0 -0
  30. package/package.json +2 -1
  31. package/dist/cjs/types-CeLsxWJg.d.ts +0 -537
  32. package/dist/esm/types-4YuozpWu.d.mts +0 -537
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkWFVHYVDM_js = require('./chunk-WFVHYVDM.js');
3
+ var chunkCDGREQFE_js = require('./chunk-CDGREQFE.js');
4
4
  var chunk7B52C2XE_js = require('./chunk-7B52C2XE.js');
5
5
  var mitt = require('mitt');
6
6
  require('event-target-polyfill');
@@ -103,9 +103,779 @@ function checkNotificationMatchesFilter(notification, filter) {
103
103
  return checkBasicFilters(notification, filter) && checkNotificationTagFilter(notification.tags, filter.tags) && checkNotificationDataFilter(notification.data, filter.data);
104
104
  }
105
105
 
106
+ // src/subscriptions/subscription.ts
107
+ var _emitter, _inboxService, _cache, _useCache, _isStale;
108
+ var TopicSubscription = class {
109
+ constructor(subscription, emitter, inboxService, cache, useCache) {
110
+ chunk7B52C2XE_js.__privateAdd(this, _emitter);
111
+ chunk7B52C2XE_js.__privateAdd(this, _inboxService);
112
+ chunk7B52C2XE_js.__privateAdd(this, _cache);
113
+ chunk7B52C2XE_js.__privateAdd(this, _useCache);
114
+ chunk7B52C2XE_js.__privateAdd(this, _isStale, false);
115
+ var _a;
116
+ chunk7B52C2XE_js.__privateSet(this, _emitter, emitter);
117
+ chunk7B52C2XE_js.__privateSet(this, _inboxService, inboxService);
118
+ chunk7B52C2XE_js.__privateSet(this, _cache, cache);
119
+ chunk7B52C2XE_js.__privateSet(this, _useCache, useCache);
120
+ this.id = subscription.id;
121
+ this.identifier = subscription.identifier;
122
+ this.topicKey = subscription.topicKey;
123
+ this.preferences = (_a = subscription.preferences) == null ? void 0 : _a.map(
124
+ (pref) => new SubscriptionPreference(chunk7B52C2XE_js.__spreadValues({}, pref), chunk7B52C2XE_js.__privateGet(this, _emitter), chunk7B52C2XE_js.__privateGet(this, _inboxService), chunk7B52C2XE_js.__privateGet(this, _cache), chunk7B52C2XE_js.__privateGet(this, _useCache))
125
+ );
126
+ }
127
+ update(args) {
128
+ return chunk7B52C2XE_js.__async(this, null, function* () {
129
+ return updateSubscription({
130
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
131
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
132
+ cache: chunk7B52C2XE_js.__privateGet(this, _cache),
133
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache),
134
+ args: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, args), { subscription: this })
135
+ });
136
+ });
137
+ }
138
+ updatePreference(args) {
139
+ return chunk7B52C2XE_js.__async(this, null, function* () {
140
+ if (chunk7B52C2XE_js.__privateGet(this, _isStale)) {
141
+ return {
142
+ error: new chunkCDGREQFE_js.NovuError("Cannot update a deleted subscription", new Error("Subscription is stale"))
143
+ };
144
+ }
145
+ return updateSubscriptionPreference({
146
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
147
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
148
+ cache: chunk7B52C2XE_js.__privateGet(this, _cache),
149
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache),
150
+ args: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, args), { subscriptionId: this.id })
151
+ });
152
+ });
153
+ }
154
+ bulkUpdatePreferences(args) {
155
+ return chunk7B52C2XE_js.__async(this, null, function* () {
156
+ if (chunk7B52C2XE_js.__privateGet(this, _isStale)) {
157
+ return {
158
+ error: new chunkCDGREQFE_js.NovuError("Cannot bulk update a deleted subscription", new Error("Subscription is stale"))
159
+ };
160
+ }
161
+ return bulkUpdateSubscriptionPreference({
162
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
163
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
164
+ cache: chunk7B52C2XE_js.__privateGet(this, _cache),
165
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache),
166
+ args: args.map((arg) => chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, arg), { subscriptionId: this.id }))
167
+ });
168
+ });
169
+ }
170
+ delete() {
171
+ return chunk7B52C2XE_js.__async(this, null, function* () {
172
+ if (chunk7B52C2XE_js.__privateGet(this, _isStale)) {
173
+ return {
174
+ error: new chunkCDGREQFE_js.NovuError("Cannot delete an already deleted subscription", new Error("Subscription is stale"))
175
+ };
176
+ }
177
+ return deleteSubscription({
178
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
179
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
180
+ args: { subscription: this }
181
+ });
182
+ });
183
+ }
184
+ };
185
+ _emitter = new WeakMap();
186
+ _inboxService = new WeakMap();
187
+ _cache = new WeakMap();
188
+ _useCache = new WeakMap();
189
+ _isStale = new WeakMap();
190
+
191
+ // src/subscriptions/helpers.ts
192
+ var listSubscriptions = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
193
+ emitter,
194
+ apiService,
195
+ cache,
196
+ options,
197
+ args
198
+ }) {
199
+ try {
200
+ const { useCache, refetch } = options;
201
+ let data = useCache && !refetch ? cache.getAll(args) : void 0;
202
+ emitter.emit("subscriptions.list.pending", { args, data });
203
+ if (!data || refetch) {
204
+ const response = yield apiService.fetchSubscriptions(args.topicKey);
205
+ data = response.map((el) => {
206
+ return new TopicSubscription(chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, el), { topicKey: args.topicKey }), emitter, apiService, cache, useCache);
207
+ });
208
+ if (useCache) {
209
+ cache.set(args, data);
210
+ data = cache.getAll(args);
211
+ }
212
+ }
213
+ emitter.emit("subscriptions.list.resolved", { args, data });
214
+ return { data };
215
+ } catch (error) {
216
+ emitter.emit("subscriptions.list.resolved", { args, error });
217
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to fetch subscriptions", error) };
218
+ }
219
+ });
220
+ var getSubscription = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
221
+ emitter,
222
+ apiService,
223
+ cache,
224
+ options,
225
+ args
226
+ }) {
227
+ try {
228
+ const { useCache, refetch } = options;
229
+ let data = useCache && !refetch ? cache.get(args) : void 0;
230
+ emitter.emit("subscription.get.pending", { args, data });
231
+ if (!data || refetch) {
232
+ const response = yield apiService.getSubscription(args.topicKey, args.identifier, args.workflowIds, args.tags);
233
+ if (!response) {
234
+ emitter.emit("subscription.get.resolved", { args, data: null });
235
+ return { data: null };
236
+ }
237
+ data = new TopicSubscription(chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, response), { topicKey: args.topicKey }), emitter, apiService, cache, useCache);
238
+ if (useCache) {
239
+ cache.setOne(args, data);
240
+ data = cache.get(args);
241
+ }
242
+ }
243
+ emitter.emit("subscription.get.resolved", { args, data });
244
+ return { data };
245
+ } catch (error) {
246
+ emitter.emit("subscription.get.resolved", { args, error });
247
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to fetch subscription", error) };
248
+ }
249
+ });
250
+ var createSubscription = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
251
+ emitter,
252
+ apiService,
253
+ cache,
254
+ useCache,
255
+ args
256
+ }) {
257
+ var _a;
258
+ try {
259
+ emitter.emit("subscription.create.pending", { args });
260
+ const response = yield apiService.createSubscription({
261
+ identifier: (_a = args.identifier) != null ? _a : "",
262
+ name: args.name,
263
+ topicKey: args.topicKey,
264
+ topicName: args.topicName,
265
+ preferences: args.preferences
266
+ });
267
+ const subscription = new TopicSubscription(
268
+ chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, response), { topicKey: args.topicKey }),
269
+ emitter,
270
+ apiService,
271
+ cache,
272
+ useCache
273
+ );
274
+ emitter.emit("subscription.create.resolved", { args, data: subscription });
275
+ return { data: subscription };
276
+ } catch (error) {
277
+ emitter.emit("subscription.create.resolved", { args, error });
278
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to create subscription", error) };
279
+ }
280
+ });
281
+ var updateSubscription = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
282
+ emitter,
283
+ apiService,
284
+ cache,
285
+ useCache,
286
+ args
287
+ }) {
288
+ const subscriptionId = "subscriptionId" in args ? args.subscriptionId : args.subscription.id;
289
+ const topicKey = "topicKey" in args ? args.topicKey : args.subscription.topicKey;
290
+ try {
291
+ emitter.emit("subscription.update.pending", {
292
+ args
293
+ });
294
+ const response = yield apiService.updateSubscription({
295
+ topicKey,
296
+ subscriptionId,
297
+ name: args.name,
298
+ preferences: args.preferences
299
+ });
300
+ const updatedSubscription = new TopicSubscription(chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, response), { topicKey }), emitter, apiService, cache, useCache);
301
+ emitter.emit("subscription.update.resolved", { args, data: updatedSubscription });
302
+ return { data: updatedSubscription };
303
+ } catch (error) {
304
+ emitter.emit("subscription.update.resolved", { args, error });
305
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to update subscription", error) };
306
+ }
307
+ });
308
+ var updateSubscriptionPreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
309
+ emitter,
310
+ apiService,
311
+ cache,
312
+ useCache,
313
+ args
314
+ }) {
315
+ var _a, _b;
316
+ const workflowId = "workflowId" in args ? args.workflowId : (_b = (_a = args.preference) == null ? void 0 : _a.workflow) == null ? void 0 : _b.id;
317
+ try {
318
+ emitter.emit("subscription.preference.update.pending", {
319
+ args,
320
+ data: "preference" in args ? new SubscriptionPreference(
321
+ chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, args.preference), typeof args.value === "boolean" ? { enabled: args.value } : { condition: args.value }),
322
+ emitter,
323
+ apiService,
324
+ cache,
325
+ useCache
326
+ ) : void 0
327
+ });
328
+ const response = yield apiService.updateSubscriptionPreference(chunk7B52C2XE_js.__spreadValues({
329
+ subscriptionId: args.subscriptionId,
330
+ workflowId
331
+ }, typeof args.value === "boolean" ? {
332
+ enabled: args.value,
333
+ email: args.value,
334
+ sms: args.value,
335
+ in_app: args.value,
336
+ chat: args.value,
337
+ push: args.value
338
+ } : { condition: args.value }));
339
+ const updatedSubscription = new SubscriptionPreference(chunk7B52C2XE_js.__spreadValues({}, response), emitter, apiService, cache, useCache);
340
+ emitter.emit("subscription.preference.update.resolved", { args, data: updatedSubscription });
341
+ return { data: updatedSubscription };
342
+ } catch (error) {
343
+ emitter.emit("subscription.preference.update.resolved", { args, error });
344
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to update subscription", error) };
345
+ }
346
+ });
347
+ var bulkUpdateSubscriptionPreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
348
+ emitter,
349
+ apiService,
350
+ cache,
351
+ useCache,
352
+ args
353
+ }) {
354
+ try {
355
+ const optimisticallyUpdatedPreferences = args.map(
356
+ (arg) => "preference" in arg ? new SubscriptionPreference(
357
+ chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, arg.preference), typeof arg.value === "boolean" ? { enabled: arg.value } : { condition: arg.value }),
358
+ emitter,
359
+ apiService,
360
+ cache,
361
+ useCache
362
+ ) : void 0
363
+ ).filter((el) => el !== void 0);
364
+ emitter.emit("subscription.preferences.bulk_update.pending", {
365
+ args,
366
+ data: optimisticallyUpdatedPreferences
367
+ });
368
+ const preferencesToUpdate = args.map((arg) => {
369
+ var _a, _b, _c, _d, _e, _f;
370
+ return chunk7B52C2XE_js.__spreadValues({
371
+ subscriptionIdOrIdentifier: arg.subscriptionId,
372
+ workflowId: "workflowId" in arg ? arg.workflowId : (_f = (_e = (_b = (_a = arg.preference) == null ? void 0 : _a.workflow) == null ? void 0 : _b.id) != null ? _e : (_d = (_c = arg.preference) == null ? void 0 : _c.workflow) == null ? void 0 : _d.identifier) != null ? _f : ""
373
+ }, typeof arg.value === "boolean" ? { enabled: arg.value, email: arg.value, sms: arg.value, in_app: arg.value, chat: arg.value, push: arg.value } : { condition: arg.value });
374
+ });
375
+ const response = yield apiService.bulkUpdateSubscriptionPreferences(preferencesToUpdate);
376
+ const preferences = response.map((el) => new SubscriptionPreference(el, emitter, apiService, cache, useCache));
377
+ emitter.emit("subscription.preferences.bulk_update.resolved", { args, data: preferences });
378
+ return { data: preferences };
379
+ } catch (error) {
380
+ emitter.emit("subscription.preferences.bulk_update.resolved", { args, error });
381
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to bulk update subscription preferences", error) };
382
+ }
383
+ });
384
+ var deleteSubscription = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
385
+ emitter,
386
+ apiService,
387
+ args
388
+ }) {
389
+ const subscriptionId = "subscriptionId" in args ? args.subscriptionId : args.subscription.id;
390
+ const topicKey = "topicKey" in args ? args.topicKey : args.subscription.topicKey;
391
+ try {
392
+ emitter.emit("subscription.delete.pending", { args });
393
+ yield apiService.deleteSubscription({ topicKey, subscriptionId });
394
+ emitter.emit("subscription.delete.resolved", { args });
395
+ return { data: void 0 };
396
+ } catch (error) {
397
+ emitter.emit("subscription.delete.resolved", { args, error });
398
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to delete subscription", error) };
399
+ }
400
+ });
401
+
402
+ // src/subscriptions/subscription-preference.ts
403
+ var _emitter2, _inboxService2, _cache2, _useCache2;
404
+ var SubscriptionPreference = class {
405
+ constructor(preference, emitter, inboxService, cache, useCache) {
406
+ chunk7B52C2XE_js.__privateAdd(this, _emitter2);
407
+ chunk7B52C2XE_js.__privateAdd(this, _inboxService2);
408
+ chunk7B52C2XE_js.__privateAdd(this, _cache2);
409
+ chunk7B52C2XE_js.__privateAdd(this, _useCache2);
410
+ var _a;
411
+ chunk7B52C2XE_js.__privateSet(this, _emitter2, emitter);
412
+ chunk7B52C2XE_js.__privateSet(this, _inboxService2, inboxService);
413
+ chunk7B52C2XE_js.__privateSet(this, _cache2, cache);
414
+ chunk7B52C2XE_js.__privateSet(this, _useCache2, useCache);
415
+ this.enabled = preference.enabled;
416
+ this.condition = (_a = preference.condition) != null ? _a : void 0;
417
+ this.workflow = preference.workflow;
418
+ this.subscriptionId = preference.subscriptionId;
419
+ }
420
+ update(args) {
421
+ return chunk7B52C2XE_js.__async(this, null, function* () {
422
+ var _a;
423
+ return updateSubscriptionPreference({
424
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter2),
425
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService2),
426
+ cache: chunk7B52C2XE_js.__privateGet(this, _cache2),
427
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache2),
428
+ args: {
429
+ subscriptionId: this.subscriptionId,
430
+ workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
431
+ value: args.value,
432
+ preference: this
433
+ }
434
+ });
435
+ });
436
+ }
437
+ };
438
+ _emitter2 = new WeakMap();
439
+ _inboxService2 = new WeakMap();
440
+ _cache2 = new WeakMap();
441
+ _useCache2 = new WeakMap();
442
+
443
+ // src/base-module.ts
444
+ var _callsQueue, _sessionError;
445
+ var BaseModule = class {
446
+ constructor({
447
+ inboxServiceInstance,
448
+ eventEmitterInstance
449
+ }) {
450
+ chunk7B52C2XE_js.__privateAdd(this, _callsQueue, []);
451
+ chunk7B52C2XE_js.__privateAdd(this, _sessionError);
452
+ this._emitter = eventEmitterInstance;
453
+ this._inboxService = inboxServiceInstance;
454
+ this._emitter.on("session.initialize.resolved", ({ error, data }) => {
455
+ if (data) {
456
+ this.onSessionSuccess(data);
457
+ chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach((_0) => chunk7B52C2XE_js.__async(this, [_0], function* ({ fn, resolve }) {
458
+ resolve(yield fn());
459
+ }));
460
+ chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
461
+ } else if (error) {
462
+ this.onSessionError(error);
463
+ chunk7B52C2XE_js.__privateSet(this, _sessionError, error);
464
+ chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach(({ resolve }) => {
465
+ resolve({ error: new chunkCDGREQFE_js.NovuError("Failed to initialize session, please contact the support", error) });
466
+ });
467
+ chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
468
+ }
469
+ });
470
+ }
471
+ onSessionSuccess(_) {
472
+ }
473
+ onSessionError(_) {
474
+ }
475
+ callWithSession(fn) {
476
+ return chunk7B52C2XE_js.__async(this, null, function* () {
477
+ if (this._inboxService.isSessionInitialized) {
478
+ return fn();
479
+ }
480
+ if (chunk7B52C2XE_js.__privateGet(this, _sessionError)) {
481
+ return Promise.resolve({
482
+ error: new chunkCDGREQFE_js.NovuError("Failed to initialize session, please contact the support", chunk7B52C2XE_js.__privateGet(this, _sessionError))
483
+ });
484
+ }
485
+ return new Promise((resolve, reject) => {
486
+ chunk7B52C2XE_js.__privateGet(this, _callsQueue).push({ fn, resolve, reject });
487
+ });
488
+ });
489
+ }
490
+ };
491
+ _callsQueue = new WeakMap();
492
+ _sessionError = new WeakMap();
493
+
494
+ // src/cache/in-memory-cache.ts
495
+ var _cache3;
496
+ var InMemoryCache = class {
497
+ constructor() {
498
+ chunk7B52C2XE_js.__privateAdd(this, _cache3);
499
+ chunk7B52C2XE_js.__privateSet(this, _cache3, /* @__PURE__ */ new Map());
500
+ }
501
+ get(key) {
502
+ return chunk7B52C2XE_js.__privateGet(this, _cache3).get(key);
503
+ }
504
+ getValues() {
505
+ return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache3).values());
506
+ }
507
+ entries() {
508
+ return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache3).entries());
509
+ }
510
+ keys() {
511
+ return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache3).keys());
512
+ }
513
+ set(key, value) {
514
+ chunk7B52C2XE_js.__privateGet(this, _cache3).set(key, value);
515
+ }
516
+ remove(key) {
517
+ chunk7B52C2XE_js.__privateGet(this, _cache3).delete(key);
518
+ }
519
+ clear() {
520
+ chunk7B52C2XE_js.__privateGet(this, _cache3).clear();
521
+ }
522
+ };
523
+ _cache3 = new WeakMap();
524
+
525
+ // src/cache/subscriptions-cache.ts
526
+ var getListCacheKey = (args) => {
527
+ return `list:${args.topicKey}`;
528
+ };
529
+ var getTopicKeyFromListCacheKey = (key) => {
530
+ return key.split(":")[1];
531
+ };
532
+ var getItemCacheKey = (args) => {
533
+ return `item:${args.topicKey}:${args.identifier}`;
534
+ };
535
+ var _emitter3, _cache4, _useCache3, _itemCache, _inboxService3;
536
+ var SubscriptionsCache = class {
537
+ constructor({
538
+ emitterInstance,
539
+ inboxServiceInstance,
540
+ useCache
541
+ }) {
542
+ chunk7B52C2XE_js.__privateAdd(this, _emitter3);
543
+ chunk7B52C2XE_js.__privateAdd(this, _cache4);
544
+ chunk7B52C2XE_js.__privateAdd(this, _useCache3);
545
+ chunk7B52C2XE_js.__privateAdd(this, _itemCache);
546
+ chunk7B52C2XE_js.__privateAdd(this, _inboxService3);
547
+ this.handleCreate = (subscription) => {
548
+ const listKey = getListCacheKey({ topicKey: subscription.topicKey });
549
+ const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
550
+ if (subscriptions) {
551
+ const updatedSubscriptions = [...subscriptions, subscription];
552
+ chunk7B52C2XE_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
553
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
554
+ data: { topicKey: subscription.topicKey, subscriptions: updatedSubscriptions }
555
+ });
556
+ }
557
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).set(
558
+ getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier }),
559
+ subscription
560
+ );
561
+ };
562
+ this.handleUpdate = (subscription) => {
563
+ const listKey = getListCacheKey({ topicKey: subscription.topicKey });
564
+ const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
565
+ if (subscriptions) {
566
+ const updatedSubscriptions = subscriptions.map((el) => el.id === subscription.id ? subscription : el);
567
+ chunk7B52C2XE_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
568
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
569
+ data: { topicKey: subscription.topicKey, subscriptions: updatedSubscriptions }
570
+ });
571
+ }
572
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).set(
573
+ getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier }),
574
+ subscription
575
+ );
576
+ };
577
+ this.handlePreferenceUpdate = (preference) => {
578
+ this.updateSubscriptionPreferences([preference]);
579
+ };
580
+ this.handleBulkPreferenceUpdate = (preferences) => {
581
+ this.updateSubscriptionPreferences(preferences);
582
+ };
583
+ this.updateSubscriptionPreferences = (updatedPreferences) => {
584
+ var _a;
585
+ const preferencesBySubscription = /* @__PURE__ */ new Map();
586
+ for (const pref of updatedPreferences) {
587
+ const existing = (_a = preferencesBySubscription.get(pref.subscriptionId)) != null ? _a : [];
588
+ existing.push(pref);
589
+ preferencesBySubscription.set(pref.subscriptionId, existing);
590
+ }
591
+ const allListKeys = chunk7B52C2XE_js.__privateGet(this, _cache4).keys();
592
+ for (const listKey of allListKeys) {
593
+ const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
594
+ if (!subscriptions) continue;
595
+ let hasUpdates = false;
596
+ const updatedSubscriptions = subscriptions.map((subscription) => {
597
+ const subscriptionPreferences = preferencesBySubscription.get(subscription.id);
598
+ if (subscriptionPreferences) {
599
+ hasUpdates = true;
600
+ return this.createUpdatedSubscription(subscription, subscriptionPreferences);
601
+ }
602
+ return subscription;
603
+ });
604
+ if (hasUpdates) {
605
+ chunk7B52C2XE_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
606
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
607
+ data: { topicKey: getTopicKeyFromListCacheKey(listKey), subscriptions: updatedSubscriptions }
608
+ });
609
+ }
610
+ }
611
+ const allItemKeys = chunk7B52C2XE_js.__privateGet(this, _itemCache).keys();
612
+ for (const key of allItemKeys) {
613
+ const subscription = chunk7B52C2XE_js.__privateGet(this, _itemCache).get(key);
614
+ if (!subscription) continue;
615
+ const subscriptionPreferences = preferencesBySubscription.get(subscription.id);
616
+ if (subscriptionPreferences) {
617
+ const updatedSubscription = this.createUpdatedSubscription(subscription, subscriptionPreferences);
618
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).set(key, updatedSubscription);
619
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscription.update.resolved", {
620
+ args: { subscription },
621
+ data: updatedSubscription
622
+ });
623
+ }
624
+ }
625
+ };
626
+ this.createUpdatedSubscription = (subscription, subscriptionPreferences) => {
627
+ var _a;
628
+ const updatedPreferences = (_a = subscription.preferences) == null ? void 0 : _a.map((pref) => {
629
+ const newPreference = subscriptionPreferences.find((el) => el.workflow.id === pref.workflow.id);
630
+ if (newPreference) {
631
+ return newPreference;
632
+ }
633
+ return pref;
634
+ });
635
+ return new TopicSubscription(
636
+ {
637
+ id: subscription.id,
638
+ identifier: subscription.identifier,
639
+ topicKey: subscription.topicKey,
640
+ preferences: updatedPreferences
641
+ },
642
+ chunk7B52C2XE_js.__privateGet(this, _emitter3),
643
+ chunk7B52C2XE_js.__privateGet(this, _inboxService3),
644
+ this,
645
+ chunk7B52C2XE_js.__privateGet(this, _useCache3)
646
+ );
647
+ };
648
+ this.handleDelete = (subscription) => {
649
+ const listKey = getListCacheKey({ topicKey: subscription.topicKey });
650
+ const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
651
+ if (subscriptions) {
652
+ const updatedSubscriptions = subscriptions.filter((el) => el.id !== subscription.id);
653
+ chunk7B52C2XE_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
654
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
655
+ data: { topicKey: subscription.topicKey, subscriptions: updatedSubscriptions }
656
+ });
657
+ }
658
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).remove(getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier }));
659
+ };
660
+ this.handleDeleteById = (subscriptionId) => {
661
+ const allListKeys = chunk7B52C2XE_js.__privateGet(this, _cache4).keys();
662
+ for (const listKey of allListKeys) {
663
+ const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
664
+ if (subscriptions) {
665
+ const subscription = subscriptions.find((el) => el.id === subscriptionId || el.identifier === subscriptionId);
666
+ if (subscription) {
667
+ const updatedSubscriptions = subscriptions.filter((el) => el.id !== subscription.id);
668
+ chunk7B52C2XE_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
669
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
670
+ data: { topicKey: getTopicKeyFromListCacheKey(listKey), subscriptions: updatedSubscriptions }
671
+ });
672
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).remove(
673
+ getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier })
674
+ );
675
+ return;
676
+ }
677
+ }
678
+ }
679
+ const allItemKeys = chunk7B52C2XE_js.__privateGet(this, _itemCache).keys();
680
+ for (const key of allItemKeys) {
681
+ const subscription = chunk7B52C2XE_js.__privateGet(this, _itemCache).get(key);
682
+ if (subscription && (subscription.id === subscriptionId || subscription.identifier === subscriptionId)) {
683
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).remove(key);
684
+ return;
685
+ }
686
+ }
687
+ };
688
+ chunk7B52C2XE_js.__privateSet(this, _emitter3, emitterInstance);
689
+ chunk7B52C2XE_js.__privateSet(this, _cache4, new InMemoryCache());
690
+ chunk7B52C2XE_js.__privateSet(this, _itemCache, new InMemoryCache());
691
+ chunk7B52C2XE_js.__privateSet(this, _inboxService3, inboxServiceInstance);
692
+ chunk7B52C2XE_js.__privateSet(this, _useCache3, useCache);
693
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.create.resolved", ({ data }) => {
694
+ if (data) {
695
+ this.handleCreate(data);
696
+ }
697
+ });
698
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.update.resolved", ({ data }) => {
699
+ if (data) {
700
+ this.handleUpdate(data);
701
+ }
702
+ });
703
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.delete.resolved", ({ args }) => {
704
+ if ("subscription" in args) {
705
+ this.handleDelete(args.subscription);
706
+ } else if ("subscriptionId" in args) {
707
+ this.handleDeleteById(args.subscriptionId);
708
+ }
709
+ });
710
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.preference.update.pending", ({ data }) => {
711
+ if (data) {
712
+ this.handlePreferenceUpdate(data);
713
+ }
714
+ });
715
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.preference.update.resolved", ({ data }) => {
716
+ if (data) {
717
+ this.handlePreferenceUpdate(data);
718
+ }
719
+ });
720
+ chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.preferences.bulk_update.resolved", ({ data }) => {
721
+ if (data && data.length > 0) {
722
+ this.handleBulkPreferenceUpdate(data);
723
+ }
724
+ });
725
+ }
726
+ has(args) {
727
+ return chunk7B52C2XE_js.__privateGet(this, _cache4).get(getListCacheKey(args)) !== void 0;
728
+ }
729
+ set(args, data) {
730
+ chunk7B52C2XE_js.__privateGet(this, _cache4).set(getListCacheKey(args), data);
731
+ for (const subscription of data) {
732
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).set(
733
+ getItemCacheKey({ topicKey: args.topicKey, identifier: subscription.identifier }),
734
+ subscription
735
+ );
736
+ }
737
+ }
738
+ setOne(args, data) {
739
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).set(getItemCacheKey(args), data);
740
+ }
741
+ getAll(args) {
742
+ return chunk7B52C2XE_js.__privateGet(this, _cache4).get(getListCacheKey(args));
743
+ }
744
+ get(args) {
745
+ return chunk7B52C2XE_js.__privateGet(this, _itemCache).get(getItemCacheKey(args));
746
+ }
747
+ invalidate(args) {
748
+ const listKey = getListCacheKey({ topicKey: args.topicKey });
749
+ const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
750
+ if (subscriptions) {
751
+ for (const subscription of subscriptions) {
752
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).remove(getItemCacheKey({ topicKey: args.topicKey, identifier: subscription.identifier }));
753
+ }
754
+ }
755
+ chunk7B52C2XE_js.__privateGet(this, _cache4).remove(listKey);
756
+ const allItemKeys = chunk7B52C2XE_js.__privateGet(this, _itemCache).keys();
757
+ for (const key of allItemKeys) {
758
+ if (key.startsWith(`item:${args.topicKey}:`)) {
759
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).remove(key);
760
+ }
761
+ }
762
+ }
763
+ clearAll() {
764
+ chunk7B52C2XE_js.__privateGet(this, _cache4).clear();
765
+ chunk7B52C2XE_js.__privateGet(this, _itemCache).clear();
766
+ }
767
+ };
768
+ _emitter3 = new WeakMap();
769
+ _cache4 = new WeakMap();
770
+ _useCache3 = new WeakMap();
771
+ _itemCache = new WeakMap();
772
+ _inboxService3 = new WeakMap();
773
+
774
+ // src/subscriptions/subscriptions.ts
775
+ var _useCache4, _subscriber;
776
+ var Subscriptions = class extends BaseModule {
777
+ constructor({
778
+ useCache,
779
+ inboxServiceInstance,
780
+ eventEmitterInstance,
781
+ subscriber
782
+ }) {
783
+ super({
784
+ eventEmitterInstance,
785
+ inboxServiceInstance
786
+ });
787
+ chunk7B52C2XE_js.__privateAdd(this, _useCache4);
788
+ chunk7B52C2XE_js.__privateAdd(this, _subscriber);
789
+ this.cache = new SubscriptionsCache({
790
+ emitterInstance: this._emitter,
791
+ inboxServiceInstance: this._inboxService,
792
+ useCache
793
+ });
794
+ chunk7B52C2XE_js.__privateSet(this, _useCache4, useCache);
795
+ chunk7B52C2XE_js.__privateSet(this, _subscriber, subscriber);
796
+ }
797
+ list(args, options) {
798
+ return chunk7B52C2XE_js.__async(this, null, function* () {
799
+ return this.callWithSession(
800
+ () => {
801
+ var _a;
802
+ return listSubscriptions({
803
+ emitter: this._emitter,
804
+ apiService: this._inboxService,
805
+ cache: this.cache,
806
+ options: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, options), {
807
+ useCache: (_a = options == null ? void 0 : options.useCache) != null ? _a : chunk7B52C2XE_js.__privateGet(this, _useCache4)
808
+ }),
809
+ args
810
+ });
811
+ }
812
+ );
813
+ });
814
+ }
815
+ get(args, options) {
816
+ return chunk7B52C2XE_js.__async(this, null, function* () {
817
+ return this.callWithSession(
818
+ () => {
819
+ var _a, _b;
820
+ return getSubscription({
821
+ emitter: this._emitter,
822
+ apiService: this._inboxService,
823
+ cache: this.cache,
824
+ options: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, options), {
825
+ useCache: (_a = options == null ? void 0 : options.useCache) != null ? _a : chunk7B52C2XE_js.__privateGet(this, _useCache4)
826
+ }),
827
+ args: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, args), {
828
+ identifier: (_b = args.identifier) != null ? _b : chunkCDGREQFE_js.buildSubscriptionIdentifier({ topicKey: args.topicKey, subscriberId: chunk7B52C2XE_js.__privateGet(this, _subscriber).subscriberId })
829
+ })
830
+ });
831
+ }
832
+ );
833
+ });
834
+ }
835
+ create(args) {
836
+ return chunk7B52C2XE_js.__async(this, null, function* () {
837
+ return this.callWithSession(
838
+ () => createSubscription({
839
+ emitter: this._emitter,
840
+ apiService: this._inboxService,
841
+ cache: this.cache,
842
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache4),
843
+ args
844
+ })
845
+ );
846
+ });
847
+ }
848
+ update(args) {
849
+ return chunk7B52C2XE_js.__async(this, null, function* () {
850
+ return this.callWithSession(
851
+ () => updateSubscription({
852
+ emitter: this._emitter,
853
+ apiService: this._inboxService,
854
+ cache: this.cache,
855
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache4),
856
+ args
857
+ })
858
+ );
859
+ });
860
+ }
861
+ delete(args) {
862
+ return chunk7B52C2XE_js.__async(this, null, function* () {
863
+ return this.callWithSession(
864
+ () => deleteSubscription({
865
+ emitter: this._emitter,
866
+ apiService: this._inboxService,
867
+ args
868
+ })
869
+ );
870
+ });
871
+ }
872
+ };
873
+ _useCache4 = new WeakMap();
874
+ _subscriber = new WeakMap();
875
+
106
876
  // src/api/http-client.ts
107
877
  var DEFAULT_API_VERSION = "v1";
108
- var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.11.1"}`;
878
+ var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.11.2-nightly.20251224.97b30e30dd"}`;
109
879
  var HttpClient = class {
110
880
  constructor(options = {}) {
111
881
  // Environment variable for local development that overrides the default API endpoint without affecting the Inbox DX
@@ -442,6 +1212,66 @@ var InboxService = class {
442
1212
  };
443
1213
  return chunk7B52C2XE_js.__privateGet(this, _httpClient).post("/inbox/events", payload);
444
1214
  }
1215
+ fetchSubscriptions(topicKey) {
1216
+ return chunk7B52C2XE_js.__privateGet(this, _httpClient).get(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions`);
1217
+ }
1218
+ getSubscription(topicKey, identifier, workflowIds, tags) {
1219
+ const searchParams = new URLSearchParams();
1220
+ if (workflowIds == null ? void 0 : workflowIds.length)
1221
+ for (const workflowIdentifier of workflowIds) searchParams.append("workflowIds", workflowIdentifier);
1222
+ if (tags == null ? void 0 : tags.length) for (const tag of tags) searchParams.append("tags", tag);
1223
+ const query = searchParams.size ? `?${searchParams.toString()}` : "";
1224
+ return chunk7B52C2XE_js.__privateGet(this, _httpClient).get(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${identifier}${query}`);
1225
+ }
1226
+ createSubscription({
1227
+ identifier,
1228
+ name,
1229
+ topicKey,
1230
+ topicName,
1231
+ preferences
1232
+ }) {
1233
+ return chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions`, chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({
1234
+ identifier,
1235
+ name
1236
+ }, topicName && { topic: { name: topicName } }), preferences !== void 0 && { preferences }));
1237
+ }
1238
+ updateSubscription({
1239
+ topicKey,
1240
+ subscriptionId,
1241
+ name,
1242
+ preferences
1243
+ }) {
1244
+ return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${subscriptionId}`, chunk7B52C2XE_js.__spreadValues({
1245
+ name
1246
+ }, preferences !== void 0 && { preferences }));
1247
+ }
1248
+ updateSubscriptionPreference({
1249
+ subscriptionId,
1250
+ workflowId,
1251
+ enabled,
1252
+ condition,
1253
+ email,
1254
+ sms,
1255
+ in_app,
1256
+ chat,
1257
+ push
1258
+ }) {
1259
+ return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/subscriptions/${subscriptionId}/preferences/${workflowId}`, {
1260
+ enabled,
1261
+ condition,
1262
+ email,
1263
+ sms,
1264
+ in_app,
1265
+ chat,
1266
+ push
1267
+ });
1268
+ }
1269
+ bulkUpdateSubscriptionPreferences(preferences) {
1270
+ return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/bulk`, { preferences });
1271
+ }
1272
+ deleteSubscription({ topicKey, subscriptionId }) {
1273
+ return chunk7B52C2XE_js.__privateGet(this, _httpClient).delete(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${subscriptionId}`);
1274
+ }
445
1275
  };
446
1276
  _httpClient = new WeakMap();
447
1277
  var _mittEmitter;
@@ -465,88 +1295,6 @@ var NovuEventEmitter = class {
465
1295
  };
466
1296
  _mittEmitter = new WeakMap();
467
1297
 
468
- // src/base-module.ts
469
- var _callsQueue, _sessionError;
470
- var BaseModule = class {
471
- constructor({
472
- inboxServiceInstance,
473
- eventEmitterInstance
474
- }) {
475
- chunk7B52C2XE_js.__privateAdd(this, _callsQueue, []);
476
- chunk7B52C2XE_js.__privateAdd(this, _sessionError);
477
- this._emitter = eventEmitterInstance;
478
- this._inboxService = inboxServiceInstance;
479
- this._emitter.on("session.initialize.resolved", ({ error, data }) => {
480
- if (data) {
481
- this.onSessionSuccess(data);
482
- chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach((_0) => chunk7B52C2XE_js.__async(this, [_0], function* ({ fn, resolve }) {
483
- resolve(yield fn());
484
- }));
485
- chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
486
- } else if (error) {
487
- this.onSessionError(error);
488
- chunk7B52C2XE_js.__privateSet(this, _sessionError, error);
489
- chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach(({ resolve }) => {
490
- resolve({ error: new chunkWFVHYVDM_js.NovuError("Failed to initialize session, please contact the support", error) });
491
- });
492
- chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
493
- }
494
- });
495
- }
496
- onSessionSuccess(_) {
497
- }
498
- onSessionError(_) {
499
- }
500
- callWithSession(fn) {
501
- return chunk7B52C2XE_js.__async(this, null, function* () {
502
- if (this._inboxService.isSessionInitialized) {
503
- return fn();
504
- }
505
- if (chunk7B52C2XE_js.__privateGet(this, _sessionError)) {
506
- return Promise.resolve({
507
- error: new chunkWFVHYVDM_js.NovuError("Failed to initialize session, please contact the support", chunk7B52C2XE_js.__privateGet(this, _sessionError))
508
- });
509
- }
510
- return new Promise((resolve, reject) => {
511
- chunk7B52C2XE_js.__privateGet(this, _callsQueue).push({ fn, resolve, reject });
512
- });
513
- });
514
- }
515
- };
516
- _callsQueue = new WeakMap();
517
- _sessionError = new WeakMap();
518
-
519
- // src/cache/in-memory-cache.ts
520
- var _cache;
521
- var InMemoryCache = class {
522
- constructor() {
523
- chunk7B52C2XE_js.__privateAdd(this, _cache);
524
- chunk7B52C2XE_js.__privateSet(this, _cache, /* @__PURE__ */ new Map());
525
- }
526
- get(key) {
527
- return chunk7B52C2XE_js.__privateGet(this, _cache).get(key);
528
- }
529
- getValues() {
530
- return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).values());
531
- }
532
- entries() {
533
- return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).entries());
534
- }
535
- keys() {
536
- return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).keys());
537
- }
538
- set(key, value) {
539
- chunk7B52C2XE_js.__privateGet(this, _cache).set(key, value);
540
- }
541
- remove(key) {
542
- chunk7B52C2XE_js.__privateGet(this, _cache).delete(key);
543
- }
544
- clear() {
545
- chunk7B52C2XE_js.__privateGet(this, _cache).clear();
546
- }
547
- };
548
- _cache = new WeakMap();
549
-
550
1298
  // src/cache/notifications-cache.ts
551
1299
  var excludeEmpty = ({
552
1300
  tags,
@@ -613,17 +1361,17 @@ var removeEvents = [
613
1361
  "notifications.archive_all_read.pending",
614
1362
  "notifications.delete_all.pending"
615
1363
  ];
616
- var _emitter, _inboxService, _cache2;
1364
+ var _emitter4, _inboxService4, _cache5;
617
1365
  var NotificationsCache = class {
618
1366
  constructor({ emitter, inboxService }) {
619
- chunk7B52C2XE_js.__privateAdd(this, _emitter);
620
- chunk7B52C2XE_js.__privateAdd(this, _inboxService);
1367
+ chunk7B52C2XE_js.__privateAdd(this, _emitter4);
1368
+ chunk7B52C2XE_js.__privateAdd(this, _inboxService4);
621
1369
  /**
622
1370
  * The key is the stringified notifications filter, the values are the paginated notifications.
623
1371
  */
624
- chunk7B52C2XE_js.__privateAdd(this, _cache2);
1372
+ chunk7B52C2XE_js.__privateAdd(this, _cache5);
625
1373
  this.updateNotification = (key, data) => {
626
- const notificationsResponse = chunk7B52C2XE_js.__privateGet(this, _cache2).get(key);
1374
+ const notificationsResponse = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
627
1375
  if (!notificationsResponse) {
628
1376
  return false;
629
1377
  }
@@ -633,11 +1381,11 @@ var NotificationsCache = class {
633
1381
  }
634
1382
  const updatedNotifications = [...notificationsResponse.notifications];
635
1383
  updatedNotifications[index] = data;
636
- chunk7B52C2XE_js.__privateGet(this, _cache2).set(key, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notificationsResponse), { notifications: updatedNotifications }));
1384
+ chunk7B52C2XE_js.__privateGet(this, _cache5).set(key, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notificationsResponse), { notifications: updatedNotifications }));
637
1385
  return true;
638
1386
  };
639
1387
  this.removeNotification = (key, data) => {
640
- const notificationsResponse = chunk7B52C2XE_js.__privateGet(this, _cache2).get(key);
1388
+ const notificationsResponse = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
641
1389
  if (!notificationsResponse) {
642
1390
  return false;
643
1391
  }
@@ -647,7 +1395,7 @@ var NotificationsCache = class {
647
1395
  }
648
1396
  const newNotifications = [...notificationsResponse.notifications];
649
1397
  newNotifications.splice(index, 1);
650
- chunk7B52C2XE_js.__privateGet(this, _cache2).set(key, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notificationsResponse), {
1398
+ chunk7B52C2XE_js.__privateGet(this, _cache5).set(key, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notificationsResponse), {
651
1399
  notifications: newNotifications
652
1400
  }));
653
1401
  return true;
@@ -666,8 +1414,8 @@ var NotificationsCache = class {
666
1414
  notifications = [args.notification];
667
1415
  } else if ("notificationId" in args && args.notificationId) {
668
1416
  const foundNotifications = [];
669
- chunk7B52C2XE_js.__privateGet(this, _cache2).keys().forEach((key) => {
670
- const cachedResponse = chunk7B52C2XE_js.__privateGet(this, _cache2).get(key);
1417
+ chunk7B52C2XE_js.__privateGet(this, _cache5).keys().forEach((key) => {
1418
+ const cachedResponse = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
671
1419
  if (cachedResponse) {
672
1420
  const found = cachedResponse.notifications.find((n) => n.id === args.notificationId);
673
1421
  if (found) {
@@ -682,7 +1430,7 @@ var NotificationsCache = class {
682
1430
  return;
683
1431
  }
684
1432
  const uniqueFilterKeys = /* @__PURE__ */ new Set();
685
- chunk7B52C2XE_js.__privateGet(this, _cache2).keys().forEach((key) => {
1433
+ chunk7B52C2XE_js.__privateGet(this, _cache5).keys().forEach((key) => {
686
1434
  notifications.forEach((notification) => {
687
1435
  let isNotificationFound = false;
688
1436
  if (remove) {
@@ -697,27 +1445,27 @@ var NotificationsCache = class {
697
1445
  });
698
1446
  uniqueFilterKeys.forEach((key) => {
699
1447
  const notificationsResponse = this.getAggregated(getFilter(key));
700
- chunk7B52C2XE_js.__privateGet(this, _emitter).emit("notifications.list.updated", {
1448
+ chunk7B52C2XE_js.__privateGet(this, _emitter4).emit("notifications.list.updated", {
701
1449
  data: notificationsResponse
702
1450
  });
703
1451
  });
704
1452
  };
705
- chunk7B52C2XE_js.__privateSet(this, _emitter, emitter);
706
- chunk7B52C2XE_js.__privateSet(this, _inboxService, inboxService);
1453
+ chunk7B52C2XE_js.__privateSet(this, _emitter4, emitter);
1454
+ chunk7B52C2XE_js.__privateSet(this, _inboxService4, inboxService);
707
1455
  updateEvents.forEach((event) => {
708
- chunk7B52C2XE_js.__privateGet(this, _emitter).on(event, this.handleNotificationEvent());
1456
+ chunk7B52C2XE_js.__privateGet(this, _emitter4).on(event, this.handleNotificationEvent());
709
1457
  });
710
1458
  removeEvents.forEach((event) => {
711
- chunk7B52C2XE_js.__privateGet(this, _emitter).on(event, this.handleNotificationEvent({ remove: true }));
1459
+ chunk7B52C2XE_js.__privateGet(this, _emitter4).on(event, this.handleNotificationEvent({ remove: true }));
712
1460
  });
713
- chunk7B52C2XE_js.__privateSet(this, _cache2, new InMemoryCache());
1461
+ chunk7B52C2XE_js.__privateSet(this, _cache5, new InMemoryCache());
714
1462
  }
715
1463
  getAggregated(filter) {
716
- const cacheKeys = chunk7B52C2XE_js.__privateGet(this, _cache2).keys().filter((key) => {
1464
+ const cacheKeys = chunk7B52C2XE_js.__privateGet(this, _cache5).keys().filter((key) => {
717
1465
  const parsedFilter = getFilter(key);
718
1466
  return isSameFilter(parsedFilter, filter);
719
1467
  });
720
- return cacheKeys.map((key) => chunk7B52C2XE_js.__privateGet(this, _cache2).get(key)).reduce(
1468
+ return cacheKeys.map((key) => chunk7B52C2XE_js.__privateGet(this, _cache5).get(key)).reduce(
721
1469
  (acc, el) => {
722
1470
  if (!el) {
723
1471
  return acc;
@@ -732,25 +1480,25 @@ var NotificationsCache = class {
732
1480
  );
733
1481
  }
734
1482
  get(args) {
735
- return chunk7B52C2XE_js.__privateGet(this, _cache2).get(getCacheKey(args));
1483
+ return chunk7B52C2XE_js.__privateGet(this, _cache5).get(getCacheKey(args));
736
1484
  }
737
1485
  has(args) {
738
- return chunk7B52C2XE_js.__privateGet(this, _cache2).get(getCacheKey(args)) !== void 0;
1486
+ return chunk7B52C2XE_js.__privateGet(this, _cache5).get(getCacheKey(args)) !== void 0;
739
1487
  }
740
1488
  set(args, data) {
741
- chunk7B52C2XE_js.__privateGet(this, _cache2).set(getCacheKey(args), data);
1489
+ chunk7B52C2XE_js.__privateGet(this, _cache5).set(getCacheKey(args), data);
742
1490
  }
743
1491
  unshift(args, notification) {
744
1492
  const cacheKey = getCacheKey(args);
745
- const cachedData = chunk7B52C2XE_js.__privateGet(this, _cache2).get(cacheKey) || {
1493
+ const cachedData = chunk7B52C2XE_js.__privateGet(this, _cache5).get(cacheKey) || {
746
1494
  hasMore: false,
747
1495
  filter: getFilter(cacheKey),
748
1496
  notifications: []
749
1497
  };
750
- const notificationInstance = chunkWFVHYVDM_js.createNotification({
1498
+ const notificationInstance = chunkCDGREQFE_js.createNotification({
751
1499
  notification: chunk7B52C2XE_js.__spreadValues({}, notification),
752
- emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
753
- inboxService: chunk7B52C2XE_js.__privateGet(this, _inboxService)
1500
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
1501
+ inboxService: chunk7B52C2XE_js.__privateGet(this, _inboxService4)
754
1502
  });
755
1503
  this.update(args, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, cachedData), {
756
1504
  notifications: [notificationInstance, ...cachedData.notifications]
@@ -759,7 +1507,7 @@ var NotificationsCache = class {
759
1507
  update(args, data) {
760
1508
  this.set(args, data);
761
1509
  const notificationsResponse = this.getAggregated(getFilter(getCacheKey(args)));
762
- chunk7B52C2XE_js.__privateGet(this, _emitter).emit("notifications.list.updated", {
1510
+ chunk7B52C2XE_js.__privateGet(this, _emitter4).emit("notifications.list.updated", {
763
1511
  data: notificationsResponse
764
1512
  });
765
1513
  }
@@ -785,12 +1533,12 @@ var NotificationsCache = class {
785
1533
  read: read2,
786
1534
  data
787
1535
  }) {
788
- const keys = chunk7B52C2XE_js.__privateGet(this, _cache2).keys();
1536
+ const keys = chunk7B52C2XE_js.__privateGet(this, _cache5).keys();
789
1537
  const uniqueNotifications = /* @__PURE__ */ new Map();
790
1538
  keys.forEach((key) => {
791
1539
  const filter = getFilter(key);
792
1540
  if (areTagsEqual(tags, filter.tags) && areDataEqual(data, filter.data)) {
793
- const value = chunk7B52C2XE_js.__privateGet(this, _cache2).get(key);
1541
+ const value = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
794
1542
  if (!value) {
795
1543
  return;
796
1544
  }
@@ -802,23 +1550,23 @@ var NotificationsCache = class {
802
1550
  return Array.from(uniqueNotifications.values());
803
1551
  }
804
1552
  clear(filter) {
805
- const keys = chunk7B52C2XE_js.__privateGet(this, _cache2).keys();
1553
+ const keys = chunk7B52C2XE_js.__privateGet(this, _cache5).keys();
806
1554
  keys.forEach((key) => {
807
1555
  if (isSameFilter(getFilter(key), filter)) {
808
- chunk7B52C2XE_js.__privateGet(this, _cache2).remove(key);
1556
+ chunk7B52C2XE_js.__privateGet(this, _cache5).remove(key);
809
1557
  }
810
1558
  });
811
1559
  }
812
1560
  clearAll() {
813
- chunk7B52C2XE_js.__privateGet(this, _cache2).clear();
1561
+ chunk7B52C2XE_js.__privateGet(this, _cache5).clear();
814
1562
  }
815
1563
  };
816
- _emitter = new WeakMap();
817
- _inboxService = new WeakMap();
818
- _cache2 = new WeakMap();
1564
+ _emitter4 = new WeakMap();
1565
+ _inboxService4 = new WeakMap();
1566
+ _cache5 = new WeakMap();
819
1567
 
820
1568
  // src/notifications/notifications.ts
821
- var _useCache;
1569
+ var _useCache5;
822
1570
  var Notifications = class extends BaseModule {
823
1571
  constructor({
824
1572
  useCache,
@@ -829,12 +1577,12 @@ var Notifications = class extends BaseModule {
829
1577
  eventEmitterInstance,
830
1578
  inboxServiceInstance
831
1579
  });
832
- chunk7B52C2XE_js.__privateAdd(this, _useCache);
1580
+ chunk7B52C2XE_js.__privateAdd(this, _useCache5);
833
1581
  this.cache = new NotificationsCache({
834
1582
  emitter: eventEmitterInstance,
835
1583
  inboxService: inboxServiceInstance
836
1584
  });
837
- chunk7B52C2XE_js.__privateSet(this, _useCache, useCache);
1585
+ chunk7B52C2XE_js.__privateSet(this, _useCache5, useCache);
838
1586
  }
839
1587
  list() {
840
1588
  return chunk7B52C2XE_js.__async(this, arguments, function* (_a = {}) {
@@ -842,7 +1590,7 @@ var Notifications = class extends BaseModule {
842
1590
  return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
843
1591
  const args = chunk7B52C2XE_js.__spreadValues({ limit }, restOptions);
844
1592
  try {
845
- const shouldUseCache = "useCache" in args ? args.useCache : chunk7B52C2XE_js.__privateGet(this, _useCache);
1593
+ const shouldUseCache = "useCache" in args ? args.useCache : chunk7B52C2XE_js.__privateGet(this, _useCache5);
846
1594
  let data = shouldUseCache ? this.cache.getAll(args) : void 0;
847
1595
  this._emitter.emit("notifications.list.pending", { args, data });
848
1596
  if (!data) {
@@ -852,7 +1600,7 @@ var Notifications = class extends BaseModule {
852
1600
  data = {
853
1601
  hasMore: response.hasMore,
854
1602
  filter: response.filter,
855
- notifications: response.data.map((el) => new chunkWFVHYVDM_js.Notification(el, this._emitter, this._inboxService))
1603
+ notifications: response.data.map((el) => new chunkCDGREQFE_js.Notification(el, this._emitter, this._inboxService))
856
1604
  };
857
1605
  if (shouldUseCache) {
858
1606
  this.cache.set(args, data);
@@ -863,7 +1611,7 @@ var Notifications = class extends BaseModule {
863
1611
  return { data };
864
1612
  } catch (error) {
865
1613
  this._emitter.emit("notifications.list.resolved", { args, error });
866
- return { error: new chunkWFVHYVDM_js.NovuError("Failed to fetch notifications", error) };
1614
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to fetch notifications", error) };
867
1615
  }
868
1616
  }));
869
1617
  });
@@ -885,7 +1633,7 @@ var Notifications = class extends BaseModule {
885
1633
  return { data };
886
1634
  } catch (error) {
887
1635
  this._emitter.emit("notifications.count.resolved", { args, error });
888
- return { error: new chunkWFVHYVDM_js.NovuError("Failed to count notifications", error) };
1636
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to count notifications", error) };
889
1637
  }
890
1638
  }));
891
1639
  });
@@ -894,7 +1642,7 @@ var Notifications = class extends BaseModule {
894
1642
  return chunk7B52C2XE_js.__async(this, null, function* () {
895
1643
  return this.callWithSession(
896
1644
  () => chunk7B52C2XE_js.__async(this, null, function* () {
897
- return chunkWFVHYVDM_js.read({
1645
+ return chunkCDGREQFE_js.read({
898
1646
  emitter: this._emitter,
899
1647
  apiService: this._inboxService,
900
1648
  args
@@ -907,7 +1655,7 @@ var Notifications = class extends BaseModule {
907
1655
  return chunk7B52C2XE_js.__async(this, null, function* () {
908
1656
  return this.callWithSession(
909
1657
  () => chunk7B52C2XE_js.__async(this, null, function* () {
910
- return chunkWFVHYVDM_js.unread({
1658
+ return chunkCDGREQFE_js.unread({
911
1659
  emitter: this._emitter,
912
1660
  apiService: this._inboxService,
913
1661
  args
@@ -920,7 +1668,7 @@ var Notifications = class extends BaseModule {
920
1668
  return chunk7B52C2XE_js.__async(this, null, function* () {
921
1669
  return this.callWithSession(
922
1670
  () => chunk7B52C2XE_js.__async(this, null, function* () {
923
- return chunkWFVHYVDM_js.seen({
1671
+ return chunkCDGREQFE_js.seen({
924
1672
  emitter: this._emitter,
925
1673
  apiService: this._inboxService,
926
1674
  args
@@ -933,7 +1681,7 @@ var Notifications = class extends BaseModule {
933
1681
  return chunk7B52C2XE_js.__async(this, null, function* () {
934
1682
  return this.callWithSession(
935
1683
  () => chunk7B52C2XE_js.__async(this, null, function* () {
936
- return chunkWFVHYVDM_js.archive({
1684
+ return chunkCDGREQFE_js.archive({
937
1685
  emitter: this._emitter,
938
1686
  apiService: this._inboxService,
939
1687
  args
@@ -946,7 +1694,7 @@ var Notifications = class extends BaseModule {
946
1694
  return chunk7B52C2XE_js.__async(this, null, function* () {
947
1695
  return this.callWithSession(
948
1696
  () => chunk7B52C2XE_js.__async(this, null, function* () {
949
- return chunkWFVHYVDM_js.unarchive({
1697
+ return chunkCDGREQFE_js.unarchive({
950
1698
  emitter: this._emitter,
951
1699
  apiService: this._inboxService,
952
1700
  args
@@ -959,7 +1707,7 @@ var Notifications = class extends BaseModule {
959
1707
  return chunk7B52C2XE_js.__async(this, null, function* () {
960
1708
  return this.callWithSession(
961
1709
  () => chunk7B52C2XE_js.__async(this, null, function* () {
962
- return chunkWFVHYVDM_js.deleteNotification({
1710
+ return chunkCDGREQFE_js.deleteNotification({
963
1711
  emitter: this._emitter,
964
1712
  apiService: this._inboxService,
965
1713
  args
@@ -972,7 +1720,7 @@ var Notifications = class extends BaseModule {
972
1720
  return chunk7B52C2XE_js.__async(this, null, function* () {
973
1721
  return this.callWithSession(
974
1722
  () => chunk7B52C2XE_js.__async(this, null, function* () {
975
- return chunkWFVHYVDM_js.snooze({
1723
+ return chunkCDGREQFE_js.snooze({
976
1724
  emitter: this._emitter,
977
1725
  apiService: this._inboxService,
978
1726
  args
@@ -985,7 +1733,7 @@ var Notifications = class extends BaseModule {
985
1733
  return chunk7B52C2XE_js.__async(this, null, function* () {
986
1734
  return this.callWithSession(
987
1735
  () => chunk7B52C2XE_js.__async(this, null, function* () {
988
- return chunkWFVHYVDM_js.unsnooze({
1736
+ return chunkCDGREQFE_js.unsnooze({
989
1737
  emitter: this._emitter,
990
1738
  apiService: this._inboxService,
991
1739
  args
@@ -998,7 +1746,7 @@ var Notifications = class extends BaseModule {
998
1746
  return chunk7B52C2XE_js.__async(this, null, function* () {
999
1747
  return this.callWithSession(
1000
1748
  () => chunk7B52C2XE_js.__async(this, null, function* () {
1001
- return chunkWFVHYVDM_js.completeAction({
1749
+ return chunkCDGREQFE_js.completeAction({
1002
1750
  emitter: this._emitter,
1003
1751
  apiService: this._inboxService,
1004
1752
  args,
@@ -1012,7 +1760,7 @@ var Notifications = class extends BaseModule {
1012
1760
  return chunk7B52C2XE_js.__async(this, null, function* () {
1013
1761
  return this.callWithSession(
1014
1762
  () => chunk7B52C2XE_js.__async(this, null, function* () {
1015
- return chunkWFVHYVDM_js.completeAction({
1763
+ return chunkCDGREQFE_js.completeAction({
1016
1764
  emitter: this._emitter,
1017
1765
  apiService: this._inboxService,
1018
1766
  args,
@@ -1026,7 +1774,7 @@ var Notifications = class extends BaseModule {
1026
1774
  return chunk7B52C2XE_js.__async(this, null, function* () {
1027
1775
  return this.callWithSession(
1028
1776
  () => chunk7B52C2XE_js.__async(this, null, function* () {
1029
- return chunkWFVHYVDM_js.revertAction({
1777
+ return chunkCDGREQFE_js.revertAction({
1030
1778
  emitter: this._emitter,
1031
1779
  apiService: this._inboxService,
1032
1780
  args,
@@ -1040,7 +1788,7 @@ var Notifications = class extends BaseModule {
1040
1788
  return chunk7B52C2XE_js.__async(this, null, function* () {
1041
1789
  return this.callWithSession(
1042
1790
  () => chunk7B52C2XE_js.__async(this, null, function* () {
1043
- return chunkWFVHYVDM_js.revertAction({
1791
+ return chunkCDGREQFE_js.revertAction({
1044
1792
  emitter: this._emitter,
1045
1793
  apiService: this._inboxService,
1046
1794
  args,
@@ -1057,7 +1805,7 @@ var Notifications = class extends BaseModule {
1057
1805
  } = {}) {
1058
1806
  return this.callWithSession(
1059
1807
  () => chunk7B52C2XE_js.__async(this, null, function* () {
1060
- return chunkWFVHYVDM_js.readAll({
1808
+ return chunkCDGREQFE_js.readAll({
1061
1809
  emitter: this._emitter,
1062
1810
  inboxService: this._inboxService,
1063
1811
  notificationsCache: this.cache,
@@ -1072,14 +1820,14 @@ var Notifications = class extends BaseModule {
1072
1820
  return chunk7B52C2XE_js.__async(this, arguments, function* (args = {}) {
1073
1821
  return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
1074
1822
  if ("notificationIds" in args) {
1075
- return chunkWFVHYVDM_js.seenAll({
1823
+ return chunkCDGREQFE_js.seenAll({
1076
1824
  emitter: this._emitter,
1077
1825
  inboxService: this._inboxService,
1078
1826
  notificationsCache: this.cache,
1079
1827
  notificationIds: args.notificationIds
1080
1828
  });
1081
1829
  } else {
1082
- return chunkWFVHYVDM_js.seenAll({
1830
+ return chunkCDGREQFE_js.seenAll({
1083
1831
  emitter: this._emitter,
1084
1832
  inboxService: this._inboxService,
1085
1833
  notificationsCache: this.cache,
@@ -1097,7 +1845,7 @@ var Notifications = class extends BaseModule {
1097
1845
  } = {}) {
1098
1846
  return this.callWithSession(
1099
1847
  () => chunk7B52C2XE_js.__async(this, null, function* () {
1100
- return chunkWFVHYVDM_js.archiveAll({
1848
+ return chunkCDGREQFE_js.archiveAll({
1101
1849
  emitter: this._emitter,
1102
1850
  inboxService: this._inboxService,
1103
1851
  notificationsCache: this.cache,
@@ -1112,7 +1860,7 @@ var Notifications = class extends BaseModule {
1112
1860
  return chunk7B52C2XE_js.__async(this, arguments, function* ({ tags, data } = {}) {
1113
1861
  return this.callWithSession(
1114
1862
  () => chunk7B52C2XE_js.__async(this, null, function* () {
1115
- return chunkWFVHYVDM_js.archiveAllRead({
1863
+ return chunkCDGREQFE_js.archiveAllRead({
1116
1864
  emitter: this._emitter,
1117
1865
  inboxService: this._inboxService,
1118
1866
  notificationsCache: this.cache,
@@ -1130,7 +1878,7 @@ var Notifications = class extends BaseModule {
1130
1878
  } = {}) {
1131
1879
  return this.callWithSession(
1132
1880
  () => chunk7B52C2XE_js.__async(this, null, function* () {
1133
- return chunkWFVHYVDM_js.deleteAll({
1881
+ return chunkCDGREQFE_js.deleteAll({
1134
1882
  emitter: this._emitter,
1135
1883
  inboxService: this._inboxService,
1136
1884
  notificationsCache: this.cache,
@@ -1154,10 +1902,10 @@ var Notifications = class extends BaseModule {
1154
1902
  });
1155
1903
  }
1156
1904
  };
1157
- _useCache = new WeakMap();
1905
+ _useCache5 = new WeakMap();
1158
1906
 
1159
1907
  // src/preferences/schedule.ts
1160
- var _emitter2, _apiService, _cache3, _useCache2;
1908
+ var _emitter5, _apiService, _cache6, _useCache6;
1161
1909
  var Schedule = class {
1162
1910
  constructor(schedule, {
1163
1911
  emitterInstance,
@@ -1165,14 +1913,14 @@ var Schedule = class {
1165
1913
  cache,
1166
1914
  useCache
1167
1915
  }) {
1168
- chunk7B52C2XE_js.__privateAdd(this, _emitter2);
1916
+ chunk7B52C2XE_js.__privateAdd(this, _emitter5);
1169
1917
  chunk7B52C2XE_js.__privateAdd(this, _apiService);
1170
- chunk7B52C2XE_js.__privateAdd(this, _cache3);
1171
- chunk7B52C2XE_js.__privateAdd(this, _useCache2);
1172
- chunk7B52C2XE_js.__privateSet(this, _emitter2, emitterInstance);
1918
+ chunk7B52C2XE_js.__privateAdd(this, _cache6);
1919
+ chunk7B52C2XE_js.__privateAdd(this, _useCache6);
1920
+ chunk7B52C2XE_js.__privateSet(this, _emitter5, emitterInstance);
1173
1921
  chunk7B52C2XE_js.__privateSet(this, _apiService, inboxServiceInstance);
1174
- chunk7B52C2XE_js.__privateSet(this, _cache3, cache);
1175
- chunk7B52C2XE_js.__privateSet(this, _useCache2, useCache);
1922
+ chunk7B52C2XE_js.__privateSet(this, _cache6, cache);
1923
+ chunk7B52C2XE_js.__privateSet(this, _useCache6, useCache);
1176
1924
  this.isEnabled = schedule.isEnabled;
1177
1925
  this.weeklySchedule = schedule.weeklySchedule;
1178
1926
  }
@@ -1181,10 +1929,10 @@ var Schedule = class {
1181
1929
  var _a;
1182
1930
  const hasWeeklySchedule = !!args.weeklySchedule || !!this.weeklySchedule;
1183
1931
  return updateSchedule({
1184
- emitter: chunk7B52C2XE_js.__privateGet(this, _emitter2),
1932
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter5),
1185
1933
  apiService: chunk7B52C2XE_js.__privateGet(this, _apiService),
1186
- cache: chunk7B52C2XE_js.__privateGet(this, _cache3),
1187
- useCache: chunk7B52C2XE_js.__privateGet(this, _useCache2),
1934
+ cache: chunk7B52C2XE_js.__privateGet(this, _cache6),
1935
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache6),
1188
1936
  args: chunk7B52C2XE_js.__spreadValues({
1189
1937
  isEnabled: (_a = args.isEnabled) != null ? _a : this.isEnabled
1190
1938
  }, hasWeeklySchedule && {
@@ -1194,13 +1942,13 @@ var Schedule = class {
1194
1942
  });
1195
1943
  }
1196
1944
  };
1197
- _emitter2 = new WeakMap();
1945
+ _emitter5 = new WeakMap();
1198
1946
  _apiService = new WeakMap();
1199
- _cache3 = new WeakMap();
1200
- _useCache2 = new WeakMap();
1947
+ _cache6 = new WeakMap();
1948
+ _useCache6 = new WeakMap();
1201
1949
 
1202
1950
  // src/preferences/preference.ts
1203
- var _emitter3, _apiService2, _cache4, _scheduleCache, _useCache3;
1951
+ var _emitter6, _apiService2, _cache7, _scheduleCache, _useCache7;
1204
1952
  var Preference = class {
1205
1953
  constructor(preference, {
1206
1954
  emitterInstance,
@@ -1209,16 +1957,16 @@ var Preference = class {
1209
1957
  scheduleCache,
1210
1958
  useCache
1211
1959
  }) {
1212
- chunk7B52C2XE_js.__privateAdd(this, _emitter3);
1960
+ chunk7B52C2XE_js.__privateAdd(this, _emitter6);
1213
1961
  chunk7B52C2XE_js.__privateAdd(this, _apiService2);
1214
- chunk7B52C2XE_js.__privateAdd(this, _cache4);
1962
+ chunk7B52C2XE_js.__privateAdd(this, _cache7);
1215
1963
  chunk7B52C2XE_js.__privateAdd(this, _scheduleCache);
1216
- chunk7B52C2XE_js.__privateAdd(this, _useCache3);
1217
- chunk7B52C2XE_js.__privateSet(this, _emitter3, emitterInstance);
1964
+ chunk7B52C2XE_js.__privateAdd(this, _useCache7);
1965
+ chunk7B52C2XE_js.__privateSet(this, _emitter6, emitterInstance);
1218
1966
  chunk7B52C2XE_js.__privateSet(this, _apiService2, inboxServiceInstance);
1219
- chunk7B52C2XE_js.__privateSet(this, _cache4, cache);
1967
+ chunk7B52C2XE_js.__privateSet(this, _cache7, cache);
1220
1968
  chunk7B52C2XE_js.__privateSet(this, _scheduleCache, scheduleCache);
1221
- chunk7B52C2XE_js.__privateSet(this, _useCache3, useCache);
1969
+ chunk7B52C2XE_js.__privateSet(this, _useCache7, useCache);
1222
1970
  this.level = preference.level;
1223
1971
  this.enabled = preference.enabled;
1224
1972
  this.channels = preference.channels;
@@ -1234,11 +1982,11 @@ var Preference = class {
1234
1982
  }) {
1235
1983
  var _a;
1236
1984
  return updatePreference({
1237
- emitter: chunk7B52C2XE_js.__privateGet(this, _emitter3),
1985
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter6),
1238
1986
  apiService: chunk7B52C2XE_js.__privateGet(this, _apiService2),
1239
- cache: chunk7B52C2XE_js.__privateGet(this, _cache4),
1987
+ cache: chunk7B52C2XE_js.__privateGet(this, _cache7),
1240
1988
  scheduleCache: chunk7B52C2XE_js.__privateGet(this, _scheduleCache),
1241
- useCache: chunk7B52C2XE_js.__privateGet(this, _useCache3),
1989
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache7),
1242
1990
  args: {
1243
1991
  workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
1244
1992
  channels: channels || channelPreferences,
@@ -1247,11 +1995,11 @@ var Preference = class {
1247
1995
  });
1248
1996
  }
1249
1997
  };
1250
- _emitter3 = new WeakMap();
1998
+ _emitter6 = new WeakMap();
1251
1999
  _apiService2 = new WeakMap();
1252
- _cache4 = new WeakMap();
2000
+ _cache7 = new WeakMap();
1253
2001
  _scheduleCache = new WeakMap();
1254
- _useCache3 = new WeakMap();
2002
+ _useCache7 = new WeakMap();
1255
2003
 
1256
2004
  // src/preferences/helpers.ts
1257
2005
  var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
@@ -1299,7 +2047,7 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function*
1299
2047
  return { data: preference };
1300
2048
  } catch (error) {
1301
2049
  emitter.emit("preference.update.resolved", { args, error });
1302
- return { error: new chunkWFVHYVDM_js.NovuError("Failed to update preference", error) };
2050
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to update preference", error) };
1303
2051
  }
1304
2052
  });
1305
2053
  var bulkUpdatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
@@ -1312,7 +2060,7 @@ var bulkUpdatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], functi
1312
2060
  }) {
1313
2061
  const globalPreference = args.find((arg) => "preference" in arg && arg.preference.level === "global" /* GLOBAL */);
1314
2062
  if (globalPreference) {
1315
- return { error: new chunkWFVHYVDM_js.NovuError("Global preference is not supported in bulk update", "") };
2063
+ return { error: new chunkCDGREQFE_js.NovuError("Global preference is not supported in bulk update", "") };
1316
2064
  }
1317
2065
  try {
1318
2066
  const optimisticallyUpdatedPreferences = args.map(
@@ -1353,7 +2101,7 @@ var bulkUpdatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], functi
1353
2101
  return { data: preferences };
1354
2102
  } catch (error) {
1355
2103
  emitter.emit("preferences.bulk_update.resolved", { args, error });
1356
- return { error: new chunkWFVHYVDM_js.NovuError("Failed to bulk update preferences", error) };
2104
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to bulk update preferences", error) };
1357
2105
  }
1358
2106
  });
1359
2107
  var optimisticUpdateWorkflowPreferences = ({
@@ -1443,12 +2191,12 @@ var updateSchedule = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
1443
2191
  return { data: updatedSchedule };
1444
2192
  } catch (error) {
1445
2193
  emitter.emit("preference.schedule.update.resolved", { args, error });
1446
- return { error: new chunkWFVHYVDM_js.NovuError("Failed to update preference", error) };
2194
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to update preference", error) };
1447
2195
  }
1448
2196
  });
1449
2197
 
1450
2198
  // src/preferences/preference-schedule.ts
1451
- var _useCache4;
2199
+ var _useCache8;
1452
2200
  var PreferenceSchedule = class extends BaseModule {
1453
2201
  constructor({
1454
2202
  cache,
@@ -1460,16 +2208,16 @@ var PreferenceSchedule = class extends BaseModule {
1460
2208
  eventEmitterInstance,
1461
2209
  inboxServiceInstance
1462
2210
  });
1463
- chunk7B52C2XE_js.__privateAdd(this, _useCache4);
2211
+ chunk7B52C2XE_js.__privateAdd(this, _useCache8);
1464
2212
  this.cache = cache;
1465
- chunk7B52C2XE_js.__privateSet(this, _useCache4, useCache);
2213
+ chunk7B52C2XE_js.__privateSet(this, _useCache8, useCache);
1466
2214
  }
1467
2215
  get() {
1468
2216
  return chunk7B52C2XE_js.__async(this, null, function* () {
1469
2217
  return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
1470
2218
  var _a, _b;
1471
2219
  try {
1472
- let data = chunk7B52C2XE_js.__privateGet(this, _useCache4) ? this.cache.getAll() : void 0;
2220
+ let data = chunk7B52C2XE_js.__privateGet(this, _useCache8) ? this.cache.getAll() : void 0;
1473
2221
  this._emitter.emit("preference.schedule.get.pending", { args: void 0, data });
1474
2222
  if (!data) {
1475
2223
  const globalPreference = yield this._inboxService.fetchGlobalPreferences();
@@ -1482,10 +2230,10 @@ var PreferenceSchedule = class extends BaseModule {
1482
2230
  emitterInstance: this._emitter,
1483
2231
  inboxServiceInstance: this._inboxService,
1484
2232
  cache: this.cache,
1485
- useCache: chunk7B52C2XE_js.__privateGet(this, _useCache4)
2233
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache8)
1486
2234
  }
1487
2235
  );
1488
- if (chunk7B52C2XE_js.__privateGet(this, _useCache4)) {
2236
+ if (chunk7B52C2XE_js.__privateGet(this, _useCache8)) {
1489
2237
  this.cache.set(data);
1490
2238
  data = this.cache.getAll();
1491
2239
  }
@@ -1509,14 +2257,14 @@ var PreferenceSchedule = class extends BaseModule {
1509
2257
  emitter: this._emitter,
1510
2258
  apiService: this._inboxService,
1511
2259
  cache: this.cache,
1512
- useCache: chunk7B52C2XE_js.__privateGet(this, _useCache4),
2260
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache8),
1513
2261
  args
1514
2262
  })
1515
2263
  );
1516
2264
  });
1517
2265
  }
1518
2266
  };
1519
- _useCache4 = new WeakMap();
2267
+ _useCache8 = new WeakMap();
1520
2268
 
1521
2269
  // src/cache/preferences-cache.ts
1522
2270
  var updateEvents2 = [
@@ -1539,13 +2287,13 @@ var excludeEmpty2 = ({ tags, severity }) => Object.entries({ tags, severity }).r
1539
2287
  var getCacheKey2 = ({ tags, severity }) => {
1540
2288
  return JSON.stringify(excludeEmpty2({ tags, severity }));
1541
2289
  };
1542
- var _emitter4, _cache5;
2290
+ var _emitter7, _cache8;
1543
2291
  var PreferencesCache = class {
1544
2292
  constructor({ emitterInstance }) {
1545
- chunk7B52C2XE_js.__privateAdd(this, _emitter4);
1546
- chunk7B52C2XE_js.__privateAdd(this, _cache5);
2293
+ chunk7B52C2XE_js.__privateAdd(this, _emitter7);
2294
+ chunk7B52C2XE_js.__privateAdd(this, _cache8);
1547
2295
  this.updatePreference = (key, data) => {
1548
- const preferences = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
2296
+ const preferences = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key);
1549
2297
  if (!preferences) {
1550
2298
  return false;
1551
2299
  }
@@ -1560,11 +2308,11 @@ var PreferencesCache = class {
1560
2308
  }
1561
2309
  const updatedPreferences = [...preferences];
1562
2310
  updatedPreferences[index] = data;
1563
- chunk7B52C2XE_js.__privateGet(this, _cache5).set(key, updatedPreferences);
2311
+ chunk7B52C2XE_js.__privateGet(this, _cache8).set(key, updatedPreferences);
1564
2312
  return true;
1565
2313
  };
1566
2314
  this.updatePreferenceSchedule = (key, data) => {
1567
- const preferences = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
2315
+ const preferences = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key);
1568
2316
  if (!preferences) {
1569
2317
  return false;
1570
2318
  }
@@ -1574,7 +2322,7 @@ var PreferencesCache = class {
1574
2322
  }
1575
2323
  const updatedPreferences = [...preferences];
1576
2324
  updatedPreferences[index].schedule = data;
1577
- chunk7B52C2XE_js.__privateGet(this, _cache5).set(key, updatedPreferences);
2325
+ chunk7B52C2XE_js.__privateGet(this, _cache8).set(key, updatedPreferences);
1578
2326
  return true;
1579
2327
  };
1580
2328
  this.handleScheduleEvent = ({ data }) => {
@@ -1582,19 +2330,19 @@ var PreferencesCache = class {
1582
2330
  if (!data) {
1583
2331
  return;
1584
2332
  }
1585
- const cacheKeys = chunk7B52C2XE_js.__privateGet(this, _cache5).keys();
2333
+ const cacheKeys = chunk7B52C2XE_js.__privateGet(this, _cache8).keys();
1586
2334
  const uniqueFilterKeys = /* @__PURE__ */ new Set();
1587
2335
  for (const key of cacheKeys) {
1588
2336
  const hasUpdatedPreference = this.updatePreferenceSchedule(key, data);
1589
- const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
2337
+ const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key);
1590
2338
  if (!hasUpdatedPreference || !updatedPreference) {
1591
2339
  continue;
1592
2340
  }
1593
2341
  uniqueFilterKeys.add(key);
1594
2342
  }
1595
2343
  for (const key of uniqueFilterKeys) {
1596
- chunk7B52C2XE_js.__privateGet(this, _emitter4).emit("preferences.list.updated", {
1597
- data: (_a = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key)) != null ? _a : []
2344
+ chunk7B52C2XE_js.__privateGet(this, _emitter7).emit("preferences.list.updated", {
2345
+ data: (_a = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key)) != null ? _a : []
1598
2346
  });
1599
2347
  }
1600
2348
  };
@@ -1604,10 +2352,10 @@ var PreferencesCache = class {
1604
2352
  }
1605
2353
  const preferences = Array.isArray(data) ? data : [data];
1606
2354
  const uniqueFilterKeys = /* @__PURE__ */ new Set();
1607
- chunk7B52C2XE_js.__privateGet(this, _cache5).keys().forEach((key) => {
2355
+ chunk7B52C2XE_js.__privateGet(this, _cache8).keys().forEach((key) => {
1608
2356
  preferences.forEach((preference) => {
1609
2357
  const hasUpdatedPreference = this.updatePreference(key, preference);
1610
- const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
2358
+ const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key);
1611
2359
  if (!hasUpdatedPreference || !updatedPreference) {
1612
2360
  return;
1613
2361
  }
@@ -1616,37 +2364,37 @@ var PreferencesCache = class {
1616
2364
  });
1617
2365
  uniqueFilterKeys.forEach((key) => {
1618
2366
  var _a;
1619
- chunk7B52C2XE_js.__privateGet(this, _emitter4).emit("preferences.list.updated", {
1620
- data: (_a = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key)) != null ? _a : []
2367
+ chunk7B52C2XE_js.__privateGet(this, _emitter7).emit("preferences.list.updated", {
2368
+ data: (_a = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key)) != null ? _a : []
1621
2369
  });
1622
2370
  });
1623
2371
  };
1624
- chunk7B52C2XE_js.__privateSet(this, _emitter4, emitterInstance);
2372
+ chunk7B52C2XE_js.__privateSet(this, _emitter7, emitterInstance);
1625
2373
  for (const event of updateEvents2) {
1626
- chunk7B52C2XE_js.__privateGet(this, _emitter4).on(event, this.handlePreferenceEvent);
2374
+ chunk7B52C2XE_js.__privateGet(this, _emitter7).on(event, this.handlePreferenceEvent);
1627
2375
  }
1628
2376
  for (const event of scheduleUpdateEvents) {
1629
- chunk7B52C2XE_js.__privateGet(this, _emitter4).on(event, this.handleScheduleEvent);
2377
+ chunk7B52C2XE_js.__privateGet(this, _emitter7).on(event, this.handleScheduleEvent);
1630
2378
  }
1631
- chunk7B52C2XE_js.__privateSet(this, _cache5, new InMemoryCache());
2379
+ chunk7B52C2XE_js.__privateSet(this, _cache8, new InMemoryCache());
1632
2380
  }
1633
2381
  has(args) {
1634
- return chunk7B52C2XE_js.__privateGet(this, _cache5).get(getCacheKey2(args)) !== void 0;
2382
+ return chunk7B52C2XE_js.__privateGet(this, _cache8).get(getCacheKey2(args)) !== void 0;
1635
2383
  }
1636
2384
  set(args, data) {
1637
- chunk7B52C2XE_js.__privateGet(this, _cache5).set(getCacheKey2(args), data);
2385
+ chunk7B52C2XE_js.__privateGet(this, _cache8).set(getCacheKey2(args), data);
1638
2386
  }
1639
2387
  getAll(args) {
1640
2388
  if (this.has(args)) {
1641
- return chunk7B52C2XE_js.__privateGet(this, _cache5).get(getCacheKey2(args));
2389
+ return chunk7B52C2XE_js.__privateGet(this, _cache8).get(getCacheKey2(args));
1642
2390
  }
1643
2391
  }
1644
2392
  clearAll() {
1645
- chunk7B52C2XE_js.__privateGet(this, _cache5).clear();
2393
+ chunk7B52C2XE_js.__privateGet(this, _cache8).clear();
1646
2394
  }
1647
2395
  };
1648
- _emitter4 = new WeakMap();
1649
- _cache5 = new WeakMap();
2396
+ _emitter7 = new WeakMap();
2397
+ _cache8 = new WeakMap();
1650
2398
 
1651
2399
  // src/cache/schedule-cache.ts
1652
2400
  var updateEvents3 = [
@@ -1656,17 +2404,17 @@ var updateEvents3 = [
1656
2404
  var getCacheKey3 = () => {
1657
2405
  return "schedule";
1658
2406
  };
1659
- var _emitter5, _cache6;
2407
+ var _emitter8, _cache9;
1660
2408
  var ScheduleCache = class {
1661
2409
  constructor({ emitterInstance }) {
1662
- chunk7B52C2XE_js.__privateAdd(this, _emitter5);
1663
- chunk7B52C2XE_js.__privateAdd(this, _cache6);
2410
+ chunk7B52C2XE_js.__privateAdd(this, _emitter8);
2411
+ chunk7B52C2XE_js.__privateAdd(this, _cache9);
1664
2412
  this.updateScheduleInCache = (key, data) => {
1665
- const schedule = chunk7B52C2XE_js.__privateGet(this, _cache6).get(key);
2413
+ const schedule = chunk7B52C2XE_js.__privateGet(this, _cache9).get(key);
1666
2414
  if (!schedule) {
1667
2415
  return false;
1668
2416
  }
1669
- chunk7B52C2XE_js.__privateGet(this, _cache6).set(key, data);
2417
+ chunk7B52C2XE_js.__privateGet(this, _cache9).set(key, data);
1670
2418
  return true;
1671
2419
  };
1672
2420
  this.handleScheduleEvent = ({ data }) => {
@@ -1674,47 +2422,47 @@ var ScheduleCache = class {
1674
2422
  return;
1675
2423
  }
1676
2424
  const uniqueFilterKeys = /* @__PURE__ */ new Set();
1677
- const keys = chunk7B52C2XE_js.__privateGet(this, _cache6).keys();
2425
+ const keys = chunk7B52C2XE_js.__privateGet(this, _cache9).keys();
1678
2426
  for (const key of keys) {
1679
2427
  const hasUpdatedSchedule = this.updateScheduleInCache(key, data);
1680
- const updatedSchedule = chunk7B52C2XE_js.__privateGet(this, _cache6).get(key);
2428
+ const updatedSchedule = chunk7B52C2XE_js.__privateGet(this, _cache9).get(key);
1681
2429
  if (!hasUpdatedSchedule || !updatedSchedule) {
1682
2430
  continue;
1683
2431
  }
1684
2432
  uniqueFilterKeys.add(key);
1685
2433
  }
1686
2434
  for (const key of uniqueFilterKeys) {
1687
- chunk7B52C2XE_js.__privateGet(this, _emitter5).emit("preference.schedule.get.updated", {
1688
- data: chunk7B52C2XE_js.__privateGet(this, _cache6).get(key)
2435
+ chunk7B52C2XE_js.__privateGet(this, _emitter8).emit("preference.schedule.get.updated", {
2436
+ data: chunk7B52C2XE_js.__privateGet(this, _cache9).get(key)
1689
2437
  });
1690
2438
  }
1691
2439
  };
1692
- chunk7B52C2XE_js.__privateSet(this, _emitter5, emitterInstance);
2440
+ chunk7B52C2XE_js.__privateSet(this, _emitter8, emitterInstance);
1693
2441
  for (const event of updateEvents3) {
1694
- chunk7B52C2XE_js.__privateGet(this, _emitter5).on(event, this.handleScheduleEvent);
2442
+ chunk7B52C2XE_js.__privateGet(this, _emitter8).on(event, this.handleScheduleEvent);
1695
2443
  }
1696
- chunk7B52C2XE_js.__privateSet(this, _cache6, new InMemoryCache());
2444
+ chunk7B52C2XE_js.__privateSet(this, _cache9, new InMemoryCache());
1697
2445
  }
1698
2446
  has() {
1699
- return chunk7B52C2XE_js.__privateGet(this, _cache6).get(getCacheKey3()) !== void 0;
2447
+ return chunk7B52C2XE_js.__privateGet(this, _cache9).get(getCacheKey3()) !== void 0;
1700
2448
  }
1701
2449
  set(data) {
1702
- chunk7B52C2XE_js.__privateGet(this, _cache6).set(getCacheKey3(), data);
2450
+ chunk7B52C2XE_js.__privateGet(this, _cache9).set(getCacheKey3(), data);
1703
2451
  }
1704
2452
  getAll() {
1705
2453
  if (this.has()) {
1706
- return chunk7B52C2XE_js.__privateGet(this, _cache6).get(getCacheKey3());
2454
+ return chunk7B52C2XE_js.__privateGet(this, _cache9).get(getCacheKey3());
1707
2455
  }
1708
2456
  }
1709
2457
  clearAll() {
1710
- chunk7B52C2XE_js.__privateGet(this, _cache6).clear();
2458
+ chunk7B52C2XE_js.__privateGet(this, _cache9).clear();
1711
2459
  }
1712
2460
  };
1713
- _emitter5 = new WeakMap();
1714
- _cache6 = new WeakMap();
2461
+ _emitter8 = new WeakMap();
2462
+ _cache9 = new WeakMap();
1715
2463
 
1716
2464
  // src/preferences/preferences.ts
1717
- var _useCache5;
2465
+ var _useCache9;
1718
2466
  var Preferences = class extends BaseModule {
1719
2467
  constructor({
1720
2468
  useCache,
@@ -1725,14 +2473,14 @@ var Preferences = class extends BaseModule {
1725
2473
  eventEmitterInstance,
1726
2474
  inboxServiceInstance
1727
2475
  });
1728
- chunk7B52C2XE_js.__privateAdd(this, _useCache5);
2476
+ chunk7B52C2XE_js.__privateAdd(this, _useCache9);
1729
2477
  this.cache = new PreferencesCache({
1730
2478
  emitterInstance: this._emitter
1731
2479
  });
1732
2480
  this.scheduleCache = new ScheduleCache({
1733
2481
  emitterInstance: this._emitter
1734
2482
  });
1735
- chunk7B52C2XE_js.__privateSet(this, _useCache5, useCache);
2483
+ chunk7B52C2XE_js.__privateSet(this, _useCache9, useCache);
1736
2484
  this.schedule = new PreferenceSchedule({
1737
2485
  cache: this.scheduleCache,
1738
2486
  useCache,
@@ -1745,7 +2493,7 @@ var Preferences = class extends BaseModule {
1745
2493
  return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
1746
2494
  var _a;
1747
2495
  try {
1748
- let data = chunk7B52C2XE_js.__privateGet(this, _useCache5) ? this.cache.getAll(args) : void 0;
2496
+ let data = chunk7B52C2XE_js.__privateGet(this, _useCache9) ? this.cache.getAll(args) : void 0;
1749
2497
  this._emitter.emit("preferences.list.pending", { args, data });
1750
2498
  if (!data) {
1751
2499
  const response = yield this._inboxService.fetchPreferences({
@@ -1759,10 +2507,10 @@ var Preferences = class extends BaseModule {
1759
2507
  inboxServiceInstance: this._inboxService,
1760
2508
  cache: this.cache,
1761
2509
  scheduleCache: this.scheduleCache,
1762
- useCache: chunk7B52C2XE_js.__privateGet(this, _useCache5)
2510
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache9)
1763
2511
  })
1764
2512
  );
1765
- if (chunk7B52C2XE_js.__privateGet(this, _useCache5)) {
2513
+ if (chunk7B52C2XE_js.__privateGet(this, _useCache9)) {
1766
2514
  this.cache.set(args, data);
1767
2515
  data = this.cache.getAll(args);
1768
2516
  }
@@ -1784,7 +2532,7 @@ var Preferences = class extends BaseModule {
1784
2532
  apiService: this._inboxService,
1785
2533
  cache: this.cache,
1786
2534
  scheduleCache: this.scheduleCache,
1787
- useCache: chunk7B52C2XE_js.__privateGet(this, _useCache5),
2535
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache9),
1788
2536
  args
1789
2537
  })
1790
2538
  );
@@ -1798,14 +2546,14 @@ var Preferences = class extends BaseModule {
1798
2546
  apiService: this._inboxService,
1799
2547
  cache: this.cache,
1800
2548
  scheduleCache: this.scheduleCache,
1801
- useCache: chunk7B52C2XE_js.__privateGet(this, _useCache5),
2549
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache9),
1802
2550
  args
1803
2551
  })
1804
2552
  );
1805
2553
  });
1806
2554
  }
1807
2555
  };
1808
- _useCache5 = new WeakMap();
2556
+ _useCache9 = new WeakMap();
1809
2557
 
1810
2558
  // src/utils/is-browser.ts
1811
2559
  function isBrowser() {
@@ -1813,14 +2561,14 @@ function isBrowser() {
1813
2561
  }
1814
2562
 
1815
2563
  // src/session/session.ts
1816
- var _emitter6, _inboxService2, _options;
2564
+ var _emitter9, _inboxService5, _options;
1817
2565
  var Session = class {
1818
2566
  constructor(options, inboxServiceInstance, eventEmitterInstance) {
1819
- chunk7B52C2XE_js.__privateAdd(this, _emitter6);
1820
- chunk7B52C2XE_js.__privateAdd(this, _inboxService2);
2567
+ chunk7B52C2XE_js.__privateAdd(this, _emitter9);
2568
+ chunk7B52C2XE_js.__privateAdd(this, _inboxService5);
1821
2569
  chunk7B52C2XE_js.__privateAdd(this, _options);
1822
- chunk7B52C2XE_js.__privateSet(this, _emitter6, eventEmitterInstance);
1823
- chunk7B52C2XE_js.__privateSet(this, _inboxService2, inboxServiceInstance);
2570
+ chunk7B52C2XE_js.__privateSet(this, _emitter9, eventEmitterInstance);
2571
+ chunk7B52C2XE_js.__privateSet(this, _inboxService5, inboxServiceInstance);
1824
2572
  chunk7B52C2XE_js.__privateSet(this, _options, options);
1825
2573
  }
1826
2574
  get applicationIdentifier() {
@@ -1891,8 +2639,8 @@ var Session = class {
1891
2639
  } else {
1892
2640
  this.handleApplicationIdentifier("delete");
1893
2641
  }
1894
- chunk7B52C2XE_js.__privateGet(this, _emitter6).emit("session.initialize.pending", { args: chunk7B52C2XE_js.__privateGet(this, _options) });
1895
- const response = yield chunk7B52C2XE_js.__privateGet(this, _inboxService2).initializeSession({
2642
+ chunk7B52C2XE_js.__privateGet(this, _emitter9).emit("session.initialize.pending", { args: chunk7B52C2XE_js.__privateGet(this, _options) });
2643
+ const response = yield chunk7B52C2XE_js.__privateGet(this, _inboxService5).initializeSession({
1896
2644
  applicationIdentifier: finalApplicationIdentifier,
1897
2645
  subscriberHash,
1898
2646
  contextHash,
@@ -1909,15 +2657,15 @@ var Session = class {
1909
2657
  if (!((_f = response == null ? void 0 : response.applicationIdentifier) == null ? void 0 : _f.startsWith("pk_keyless_"))) {
1910
2658
  this.handleApplicationIdentifier("delete");
1911
2659
  }
1912
- chunk7B52C2XE_js.__privateGet(this, _emitter6).emit("session.initialize.resolved", { args: chunk7B52C2XE_js.__privateGet(this, _options), data: response });
2660
+ chunk7B52C2XE_js.__privateGet(this, _emitter9).emit("session.initialize.resolved", { args: chunk7B52C2XE_js.__privateGet(this, _options), data: response });
1913
2661
  } catch (error) {
1914
- chunk7B52C2XE_js.__privateGet(this, _emitter6).emit("session.initialize.resolved", { args: chunk7B52C2XE_js.__privateGet(this, _options), error });
2662
+ chunk7B52C2XE_js.__privateGet(this, _emitter9).emit("session.initialize.resolved", { args: chunk7B52C2XE_js.__privateGet(this, _options), error });
1915
2663
  }
1916
2664
  });
1917
2665
  }
1918
2666
  };
1919
- _emitter6 = new WeakMap();
1920
- _inboxService2 = new WeakMap();
2667
+ _emitter9 = new WeakMap();
2668
+ _inboxService5 = new WeakMap();
1921
2669
  _options = new WeakMap();
1922
2670
  var PRODUCTION_SOCKET_URL = "wss://socket.novu.co";
1923
2671
  var NOTIFICATION_RECEIVED = "notifications.notification_received";
@@ -2010,7 +2758,7 @@ var mapToNotification = ({
2010
2758
  severity
2011
2759
  });
2012
2760
  };
2013
- var _token, _emitter7, _partySocket, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _handleMessage, _PartySocketClient_instances, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
2761
+ var _token, _emitter10, _partySocket, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _handleMessage, _PartySocketClient_instances, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
2014
2762
  var PartySocketClient = class extends BaseModule {
2015
2763
  constructor({
2016
2764
  socketUrl,
@@ -2023,15 +2771,15 @@ var PartySocketClient = class extends BaseModule {
2023
2771
  });
2024
2772
  chunk7B52C2XE_js.__privateAdd(this, _PartySocketClient_instances);
2025
2773
  chunk7B52C2XE_js.__privateAdd(this, _token);
2026
- chunk7B52C2XE_js.__privateAdd(this, _emitter7);
2774
+ chunk7B52C2XE_js.__privateAdd(this, _emitter10);
2027
2775
  chunk7B52C2XE_js.__privateAdd(this, _partySocket);
2028
2776
  chunk7B52C2XE_js.__privateAdd(this, _socketUrl);
2029
2777
  chunk7B52C2XE_js.__privateAdd(this, _notificationReceived, (event) => {
2030
2778
  try {
2031
2779
  const data = JSON.parse(event.data);
2032
2780
  if (data.event === "notification_received" /* RECEIVED */) {
2033
- chunk7B52C2XE_js.__privateGet(this, _emitter7).emit(NOTIFICATION_RECEIVED, {
2034
- result: new chunkWFVHYVDM_js.Notification(mapToNotification(data.data.message), chunk7B52C2XE_js.__privateGet(this, _emitter7), this._inboxService)
2781
+ chunk7B52C2XE_js.__privateGet(this, _emitter10).emit(NOTIFICATION_RECEIVED, {
2782
+ result: new chunkCDGREQFE_js.Notification(mapToNotification(data.data.message), chunk7B52C2XE_js.__privateGet(this, _emitter10), this._inboxService)
2035
2783
  });
2036
2784
  }
2037
2785
  } catch (error) {
@@ -2042,7 +2790,7 @@ var PartySocketClient = class extends BaseModule {
2042
2790
  try {
2043
2791
  const data = JSON.parse(event.data);
2044
2792
  if (data.event === "unseen_count_changed" /* UNSEEN */) {
2045
- chunk7B52C2XE_js.__privateGet(this, _emitter7).emit(UNSEEN_COUNT_CHANGED, {
2793
+ chunk7B52C2XE_js.__privateGet(this, _emitter10).emit(UNSEEN_COUNT_CHANGED, {
2046
2794
  result: data.data.unseenCount
2047
2795
  });
2048
2796
  }
@@ -2053,7 +2801,7 @@ var PartySocketClient = class extends BaseModule {
2053
2801
  try {
2054
2802
  const data = JSON.parse(event.data);
2055
2803
  if (data.event === "unread_count_changed" /* UNREAD */) {
2056
- chunk7B52C2XE_js.__privateGet(this, _emitter7).emit(UNREAD_COUNT_CHANGED, {
2804
+ chunk7B52C2XE_js.__privateGet(this, _emitter10).emit(UNREAD_COUNT_CHANGED, {
2057
2805
  result: data.data.counts
2058
2806
  });
2059
2807
  }
@@ -2078,7 +2826,7 @@ var PartySocketClient = class extends BaseModule {
2078
2826
  } catch (error) {
2079
2827
  }
2080
2828
  });
2081
- chunk7B52C2XE_js.__privateSet(this, _emitter7, eventEmitterInstance);
2829
+ chunk7B52C2XE_js.__privateSet(this, _emitter10, eventEmitterInstance);
2082
2830
  chunk7B52C2XE_js.__privateSet(this, _socketUrl, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL);
2083
2831
  }
2084
2832
  onSessionSuccess({ token }) {
@@ -2105,7 +2853,7 @@ var PartySocketClient = class extends BaseModule {
2105
2853
  }
2106
2854
  };
2107
2855
  _token = new WeakMap();
2108
- _emitter7 = new WeakMap();
2856
+ _emitter10 = new WeakMap();
2109
2857
  _partySocket = new WeakMap();
2110
2858
  _socketUrl = new WeakMap();
2111
2859
  _notificationReceived = new WeakMap();
@@ -2119,15 +2867,15 @@ initializeSocket_fn = function() {
2119
2867
  return;
2120
2868
  }
2121
2869
  const args = { socketUrl: chunk7B52C2XE_js.__privateGet(this, _socketUrl) };
2122
- chunk7B52C2XE_js.__privateGet(this, _emitter7).emit("socket.connect.pending", { args });
2870
+ chunk7B52C2XE_js.__privateGet(this, _emitter10).emit("socket.connect.pending", { args });
2123
2871
  const url = new URL(chunk7B52C2XE_js.__privateGet(this, _socketUrl));
2124
2872
  url.searchParams.set("token", chunk7B52C2XE_js.__privateGet(this, _token));
2125
2873
  chunk7B52C2XE_js.__privateSet(this, _partySocket, new partysocket.WebSocket(url.toString()));
2126
2874
  chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("open", () => {
2127
- chunk7B52C2XE_js.__privateGet(this, _emitter7).emit("socket.connect.resolved", { args });
2875
+ chunk7B52C2XE_js.__privateGet(this, _emitter10).emit("socket.connect.resolved", { args });
2128
2876
  });
2129
2877
  chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("error", (error) => {
2130
- chunk7B52C2XE_js.__privateGet(this, _emitter7).emit("socket.connect.resolved", { args, error });
2878
+ chunk7B52C2XE_js.__privateGet(this, _emitter10).emit("socket.connect.resolved", { args, error });
2131
2879
  });
2132
2880
  chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("message", chunk7B52C2XE_js.__privateGet(this, _handleMessage));
2133
2881
  });
@@ -2138,7 +2886,7 @@ handleConnectSocket_fn = function() {
2138
2886
  yield chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, initializeSocket_fn).call(this);
2139
2887
  return {};
2140
2888
  } catch (error) {
2141
- return { error: new chunkWFVHYVDM_js.NovuError("Failed to initialize the PartySocket", error) };
2889
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to initialize the PartySocket", error) };
2142
2890
  }
2143
2891
  });
2144
2892
  };
@@ -2150,7 +2898,7 @@ handleDisconnectSocket_fn = function() {
2150
2898
  chunk7B52C2XE_js.__privateSet(this, _partySocket, void 0);
2151
2899
  return {};
2152
2900
  } catch (error) {
2153
- return { error: new chunkWFVHYVDM_js.NovuError("Failed to disconnect from the PartySocket", error) };
2901
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to disconnect from the PartySocket", error) };
2154
2902
  }
2155
2903
  });
2156
2904
  };
@@ -2245,7 +2993,7 @@ var mapToNotification2 = ({
2245
2993
  severity
2246
2994
  });
2247
2995
  };
2248
- var _token2, _emitter8, _socketIo, _socketUrl2, _notificationReceived2, _unseenCountChanged2, _unreadCountChanged2, _Socket_instances, initializeSocket_fn2, handleConnectSocket_fn2, handleDisconnectSocket_fn2;
2996
+ var _token2, _emitter11, _socketIo, _socketUrl2, _notificationReceived2, _unseenCountChanged2, _unreadCountChanged2, _Socket_instances, initializeSocket_fn2, handleConnectSocket_fn2, handleDisconnectSocket_fn2;
2249
2997
  var Socket = class extends BaseModule {
2250
2998
  constructor({
2251
2999
  socketUrl,
@@ -2258,25 +3006,25 @@ var Socket = class extends BaseModule {
2258
3006
  });
2259
3007
  chunk7B52C2XE_js.__privateAdd(this, _Socket_instances);
2260
3008
  chunk7B52C2XE_js.__privateAdd(this, _token2);
2261
- chunk7B52C2XE_js.__privateAdd(this, _emitter8);
3009
+ chunk7B52C2XE_js.__privateAdd(this, _emitter11);
2262
3010
  chunk7B52C2XE_js.__privateAdd(this, _socketIo);
2263
3011
  chunk7B52C2XE_js.__privateAdd(this, _socketUrl2);
2264
3012
  chunk7B52C2XE_js.__privateAdd(this, _notificationReceived2, ({ message }) => {
2265
- chunk7B52C2XE_js.__privateGet(this, _emitter8).emit(NOTIFICATION_RECEIVED2, {
2266
- result: new chunkWFVHYVDM_js.Notification(mapToNotification2(message), chunk7B52C2XE_js.__privateGet(this, _emitter8), this._inboxService)
3013
+ chunk7B52C2XE_js.__privateGet(this, _emitter11).emit(NOTIFICATION_RECEIVED2, {
3014
+ result: new chunkCDGREQFE_js.Notification(mapToNotification2(message), chunk7B52C2XE_js.__privateGet(this, _emitter11), this._inboxService)
2267
3015
  });
2268
3016
  });
2269
3017
  chunk7B52C2XE_js.__privateAdd(this, _unseenCountChanged2, ({ unseenCount }) => {
2270
- chunk7B52C2XE_js.__privateGet(this, _emitter8).emit(UNSEEN_COUNT_CHANGED2, {
3018
+ chunk7B52C2XE_js.__privateGet(this, _emitter11).emit(UNSEEN_COUNT_CHANGED2, {
2271
3019
  result: unseenCount
2272
3020
  });
2273
3021
  });
2274
3022
  chunk7B52C2XE_js.__privateAdd(this, _unreadCountChanged2, ({ counts }) => {
2275
- chunk7B52C2XE_js.__privateGet(this, _emitter8).emit(UNREAD_COUNT_CHANGED2, {
3023
+ chunk7B52C2XE_js.__privateGet(this, _emitter11).emit(UNREAD_COUNT_CHANGED2, {
2276
3024
  result: counts
2277
3025
  });
2278
3026
  });
2279
- chunk7B52C2XE_js.__privateSet(this, _emitter8, eventEmitterInstance);
3027
+ chunk7B52C2XE_js.__privateSet(this, _emitter11, eventEmitterInstance);
2280
3028
  chunk7B52C2XE_js.__privateSet(this, _socketUrl2, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL2);
2281
3029
  }
2282
3030
  onSessionSuccess({ token }) {
@@ -2303,7 +3051,7 @@ var Socket = class extends BaseModule {
2303
3051
  }
2304
3052
  };
2305
3053
  _token2 = new WeakMap();
2306
- _emitter8 = new WeakMap();
3054
+ _emitter11 = new WeakMap();
2307
3055
  _socketIo = new WeakMap();
2308
3056
  _socketUrl2 = new WeakMap();
2309
3057
  _notificationReceived2 = new WeakMap();
@@ -2317,7 +3065,7 @@ initializeSocket_fn2 = function() {
2317
3065
  return;
2318
3066
  }
2319
3067
  const args = { socketUrl: chunk7B52C2XE_js.__privateGet(this, _socketUrl2) };
2320
- chunk7B52C2XE_js.__privateGet(this, _emitter8).emit("socket.connect.pending", { args });
3068
+ chunk7B52C2XE_js.__privateGet(this, _emitter11).emit("socket.connect.pending", { args });
2321
3069
  chunk7B52C2XE_js.__privateSet(this, _socketIo, io__default.default(chunk7B52C2XE_js.__privateGet(this, _socketUrl2), {
2322
3070
  reconnectionDelayMax: 1e4,
2323
3071
  transports: ["websocket"],
@@ -2326,10 +3074,10 @@ initializeSocket_fn2 = function() {
2326
3074
  }
2327
3075
  }));
2328
3076
  chunk7B52C2XE_js.__privateGet(this, _socketIo).on("connect", () => {
2329
- chunk7B52C2XE_js.__privateGet(this, _emitter8).emit("socket.connect.resolved", { args });
3077
+ chunk7B52C2XE_js.__privateGet(this, _emitter11).emit("socket.connect.resolved", { args });
2330
3078
  });
2331
3079
  chunk7B52C2XE_js.__privateGet(this, _socketIo).on("connect_error", (error) => {
2332
- chunk7B52C2XE_js.__privateGet(this, _emitter8).emit("socket.connect.resolved", { args, error });
3080
+ chunk7B52C2XE_js.__privateGet(this, _emitter11).emit("socket.connect.resolved", { args, error });
2333
3081
  });
2334
3082
  (_a = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _a.on("notification_received" /* RECEIVED */, chunk7B52C2XE_js.__privateGet(this, _notificationReceived2));
2335
3083
  (_b = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _b.on("unseen_count_changed" /* UNSEEN */, chunk7B52C2XE_js.__privateGet(this, _unseenCountChanged2));
@@ -2342,7 +3090,7 @@ handleConnectSocket_fn2 = function() {
2342
3090
  yield chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, initializeSocket_fn2).call(this);
2343
3091
  return {};
2344
3092
  } catch (error) {
2345
- return { error: new chunkWFVHYVDM_js.NovuError("Failed to initialize the socket", error) };
3093
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to initialize the socket", error) };
2346
3094
  }
2347
3095
  });
2348
3096
  };
@@ -2354,7 +3102,7 @@ handleDisconnectSocket_fn2 = function() {
2354
3102
  chunk7B52C2XE_js.__privateSet(this, _socketIo, void 0);
2355
3103
  return {};
2356
3104
  } catch (error) {
2357
- return { error: new chunkWFVHYVDM_js.NovuError("Failed to disconnect from the socket", error) };
3105
+ return { error: new chunkCDGREQFE_js.NovuError("Failed to disconnect from the socket", error) };
2358
3106
  }
2359
3107
  });
2360
3108
  };
@@ -2403,57 +3151,66 @@ function createSocket({
2403
3151
  }
2404
3152
 
2405
3153
  // src/novu.ts
2406
- var _emitter9, _session, _inboxService3;
3154
+ var _emitter12, _session, _inboxService6, _options2;
2407
3155
  var Novu = class {
2408
3156
  constructor(options) {
2409
- chunk7B52C2XE_js.__privateAdd(this, _emitter9);
3157
+ chunk7B52C2XE_js.__privateAdd(this, _emitter12);
2410
3158
  chunk7B52C2XE_js.__privateAdd(this, _session);
2411
- chunk7B52C2XE_js.__privateAdd(this, _inboxService3);
2412
- var _a, _b;
2413
- chunk7B52C2XE_js.__privateSet(this, _inboxService3, new InboxService({
3159
+ chunk7B52C2XE_js.__privateAdd(this, _inboxService6);
3160
+ chunk7B52C2XE_js.__privateAdd(this, _options2);
3161
+ var _a, _b, _c;
3162
+ chunk7B52C2XE_js.__privateSet(this, _options2, options);
3163
+ chunk7B52C2XE_js.__privateSet(this, _inboxService6, new InboxService({
2414
3164
  apiUrl: options.apiUrl || options.backendUrl,
2415
3165
  userAgent: options.__userAgent
2416
3166
  }));
2417
- chunk7B52C2XE_js.__privateSet(this, _emitter9, new NovuEventEmitter());
3167
+ chunk7B52C2XE_js.__privateSet(this, _emitter12, new NovuEventEmitter());
3168
+ const subscriber = chunkCDGREQFE_js.buildSubscriber({ subscriberId: options.subscriberId, subscriber: options.subscriber });
2418
3169
  chunk7B52C2XE_js.__privateSet(this, _session, new Session(
2419
3170
  {
2420
3171
  applicationIdentifier: options.applicationIdentifier || "",
2421
3172
  subscriberHash: options.subscriberHash,
2422
- subscriber: chunkWFVHYVDM_js.buildSubscriber({ subscriberId: options.subscriberId, subscriber: options.subscriber }),
3173
+ subscriber,
2423
3174
  defaultSchedule: options.defaultSchedule,
2424
3175
  context: options.context,
2425
3176
  contextHash: options.contextHash
2426
3177
  },
2427
- chunk7B52C2XE_js.__privateGet(this, _inboxService3),
2428
- chunk7B52C2XE_js.__privateGet(this, _emitter9)
3178
+ chunk7B52C2XE_js.__privateGet(this, _inboxService6),
3179
+ chunk7B52C2XE_js.__privateGet(this, _emitter12)
2429
3180
  ));
2430
3181
  chunk7B52C2XE_js.__privateGet(this, _session).initialize();
2431
3182
  this.notifications = new Notifications({
2432
3183
  useCache: (_a = options.useCache) != null ? _a : true,
2433
- inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3),
2434
- eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter9)
3184
+ inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService6),
3185
+ eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter12)
2435
3186
  });
2436
3187
  this.preferences = new Preferences({
2437
3188
  useCache: (_b = options.useCache) != null ? _b : true,
2438
- inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3),
2439
- eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter9)
3189
+ inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService6),
3190
+ eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter12)
3191
+ });
3192
+ this.subscriptions = new Subscriptions({
3193
+ subscriber,
3194
+ useCache: (_c = options.useCache) != null ? _c : true,
3195
+ inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService6),
3196
+ eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter12)
2440
3197
  });
2441
3198
  this.socket = createSocket({
2442
3199
  socketUrl: options.socketUrl,
2443
- eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter9),
2444
- inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3)
3200
+ eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter12),
3201
+ inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService6)
2445
3202
  });
2446
3203
  this.on = (eventName, listener) => {
2447
3204
  if (this.socket.isSocketEvent(eventName)) {
2448
3205
  this.socket.connect();
2449
3206
  }
2450
- const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter9).on(eventName, listener);
3207
+ const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter12).on(eventName, listener);
2451
3208
  return () => {
2452
3209
  cleanup();
2453
3210
  };
2454
3211
  };
2455
3212
  this.off = (eventName, listener) => {
2456
- chunk7B52C2XE_js.__privateGet(this, _emitter9).off(eventName, listener);
3213
+ chunk7B52C2XE_js.__privateGet(this, _emitter12).off(eventName, listener);
2457
3214
  };
2458
3215
  }
2459
3216
  get applicationIdentifier() {
@@ -2465,9 +3222,21 @@ var Novu = class {
2465
3222
  get context() {
2466
3223
  return chunk7B52C2XE_js.__privateGet(this, _session).context;
2467
3224
  }
3225
+ get options() {
3226
+ return chunk7B52C2XE_js.__privateGet(this, _options2);
3227
+ }
2468
3228
  get contextKey() {
2469
- return chunkWFVHYVDM_js.buildContextKey(chunk7B52C2XE_js.__privateGet(this, _session).context);
3229
+ return chunkCDGREQFE_js.buildContextKey(chunk7B52C2XE_js.__privateGet(this, _session).context);
3230
+ }
3231
+ clearCache() {
3232
+ this.notifications.cache.clearAll();
3233
+ this.preferences.cache.clearAll();
3234
+ this.preferences.scheduleCache.clearAll();
3235
+ this.subscriptions.cache.clearAll();
2470
3236
  }
3237
+ /**
3238
+ * @deprecated
3239
+ */
2471
3240
  changeSubscriber(options) {
2472
3241
  return chunk7B52C2XE_js.__async(this, null, function* () {
2473
3242
  yield chunk7B52C2XE_js.__privateGet(this, _session).initialize({
@@ -2478,13 +3247,16 @@ var Novu = class {
2478
3247
  context: chunk7B52C2XE_js.__privateGet(this, _session).context,
2479
3248
  contextHash: chunk7B52C2XE_js.__privateGet(this, _session).contextHash
2480
3249
  });
2481
- this.notifications.cache.clearAll();
3250
+ this.clearCache();
2482
3251
  const disconnectResult = yield this.socket.disconnect();
2483
3252
  if (!disconnectResult.error) {
2484
3253
  yield this.socket.connect();
2485
3254
  }
2486
3255
  });
2487
3256
  }
3257
+ /**
3258
+ * @deprecated
3259
+ */
2488
3260
  changeContext(options) {
2489
3261
  return chunk7B52C2XE_js.__async(this, null, function* () {
2490
3262
  const currentSubscriber = chunk7B52C2XE_js.__privateGet(this, _session).subscriber;
@@ -2499,7 +3271,7 @@ var Novu = class {
2499
3271
  context: options.context,
2500
3272
  contextHash: options.contextHash
2501
3273
  });
2502
- this.notifications.cache.clearAll();
3274
+ this.clearCache();
2503
3275
  const disconnectResult = yield this.socket.disconnect();
2504
3276
  if (!disconnectResult.error) {
2505
3277
  yield this.socket.connect();
@@ -2507,12 +3279,15 @@ var Novu = class {
2507
3279
  });
2508
3280
  }
2509
3281
  };
2510
- _emitter9 = new WeakMap();
3282
+ _emitter12 = new WeakMap();
2511
3283
  _session = new WeakMap();
2512
- _inboxService3 = new WeakMap();
3284
+ _inboxService6 = new WeakMap();
3285
+ _options2 = new WeakMap();
2513
3286
 
2514
3287
  exports.DEFAULT_API_VERSION = DEFAULT_API_VERSION;
2515
3288
  exports.Novu = Novu;
3289
+ exports.SubscriptionPreference = SubscriptionPreference;
3290
+ exports.TopicSubscription = TopicSubscription;
2516
3291
  exports.areSeveritiesEqual = areSeveritiesEqual;
2517
3292
  exports.areTagsEqual = areTagsEqual;
2518
3293
  exports.checkNotificationDataFilter = checkNotificationDataFilter;