@novu/js 3.17.0 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{chunk-7B52C2XE.js → chunk-A6CBLMST.js} +9 -0
- package/dist/cjs/{chunk-SP44ETLM.js → chunk-NR4RSYUE.js} +772 -694
- package/dist/cjs/{chunk-WDGG3OER.js → chunk-TLQQB5Y7.js} +217 -199
- package/dist/{esm/inbox-service-CGCuuYnv.d.mts → cjs/inbox-service-DSSwFYNG.d.ts} +18 -2
- package/dist/cjs/index.d.ts +93 -4
- package/dist/cjs/index.js +246 -20
- package/dist/cjs/internal/index.d.ts +1 -1
- package/dist/cjs/internal/index.js +7 -7
- package/dist/cjs/{novu-CmNBco-0.d.ts → novu-BQCC3vQS.d.ts} +3 -2
- package/dist/cjs/themes/index.d.ts +3 -3
- package/dist/cjs/themes/index.js +1 -1
- package/dist/cjs/{types-BF6zvyj6.d.ts → types-Djf8MaW9.d.ts} +2 -2
- package/dist/cjs/ui/index.d.ts +18 -6
- package/dist/cjs/ui/index.js +609 -243
- package/dist/esm/{chunk-BKA3HRZM.mjs → chunk-33B2GJE2.mjs} +140 -64
- package/dist/esm/{chunk-STZMOEWR.mjs → chunk-3LR3AF54.mjs} +9 -1
- package/dist/esm/{chunk-4S22IB5W.mjs → chunk-T3NTOGY3.mjs} +193 -176
- package/dist/{cjs/inbox-service-CGCuuYnv.d.ts → esm/inbox-service-DSSwFYNG.d.mts} +18 -2
- package/dist/esm/index.d.mts +93 -4
- package/dist/esm/index.mjs +228 -3
- package/dist/esm/internal/index.d.mts +1 -1
- package/dist/esm/internal/index.mjs +2 -2
- package/dist/esm/{novu-CFYEiYN8.d.mts → novu-Z0z0-IxO.d.mts} +3 -2
- package/dist/esm/themes/index.d.mts +3 -3
- package/dist/esm/themes/index.mjs +1 -1
- package/dist/esm/{types-CJKmgwu6.d.mts → types-BJ345m1Q.d.mts} +2 -2
- package/dist/esm/ui/index.d.mts +18 -6
- package/dist/esm/ui/index.mjs +424 -58
- package/dist/novu.min.js +15 -15
- package/dist/novu.min.js.gz +0 -0
- package/package.json +7 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkTLQQB5Y7_js = require('./chunk-TLQQB5Y7.js');
|
|
4
|
+
var chunkA6CBLMST_js = require('./chunk-A6CBLMST.js');
|
|
5
5
|
var mitt = require('mitt');
|
|
6
6
|
require('event-target-polyfill');
|
|
7
7
|
var partysocket = require('partysocket');
|
|
@@ -341,76 +341,76 @@ function checkNotificationMatchesFilter(notification, filter) {
|
|
|
341
341
|
var _emitter, _inboxService, _cache, _useCache, _isStale;
|
|
342
342
|
var TopicSubscription = class {
|
|
343
343
|
constructor(subscription, emitter, inboxService, cache, useCache) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
344
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter);
|
|
345
|
+
chunkA6CBLMST_js.__privateAdd(this, _inboxService);
|
|
346
|
+
chunkA6CBLMST_js.__privateAdd(this, _cache);
|
|
347
|
+
chunkA6CBLMST_js.__privateAdd(this, _useCache);
|
|
348
|
+
chunkA6CBLMST_js.__privateAdd(this, _isStale, false);
|
|
349
349
|
var _a;
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
350
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter, emitter);
|
|
351
|
+
chunkA6CBLMST_js.__privateSet(this, _inboxService, inboxService);
|
|
352
|
+
chunkA6CBLMST_js.__privateSet(this, _cache, cache);
|
|
353
|
+
chunkA6CBLMST_js.__privateSet(this, _useCache, useCache);
|
|
354
354
|
this.id = subscription.id;
|
|
355
355
|
this.identifier = subscription.identifier;
|
|
356
356
|
this.topicKey = subscription.topicKey;
|
|
357
357
|
this.preferences = (_a = subscription.preferences) == null ? void 0 : _a.map(
|
|
358
|
-
(pref) => new SubscriptionPreference(
|
|
358
|
+
(pref) => new SubscriptionPreference(chunkA6CBLMST_js.__spreadValues({}, pref), chunkA6CBLMST_js.__privateGet(this, _emitter), chunkA6CBLMST_js.__privateGet(this, _inboxService), chunkA6CBLMST_js.__privateGet(this, _cache), chunkA6CBLMST_js.__privateGet(this, _useCache))
|
|
359
359
|
);
|
|
360
360
|
}
|
|
361
361
|
update(args) {
|
|
362
|
-
return
|
|
362
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
363
363
|
return updateSubscription({
|
|
364
|
-
emitter:
|
|
365
|
-
apiService:
|
|
366
|
-
cache:
|
|
367
|
-
useCache:
|
|
368
|
-
args:
|
|
364
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
365
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
366
|
+
cache: chunkA6CBLMST_js.__privateGet(this, _cache),
|
|
367
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache),
|
|
368
|
+
args: chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, args), { subscription: this })
|
|
369
369
|
});
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
372
|
updatePreference(args) {
|
|
373
|
-
return
|
|
374
|
-
if (
|
|
373
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
374
|
+
if (chunkA6CBLMST_js.__privateGet(this, _isStale)) {
|
|
375
375
|
return {
|
|
376
|
-
error: new
|
|
376
|
+
error: new chunkTLQQB5Y7_js.NovuError("Cannot update a deleted subscription", new Error("Subscription is stale"))
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
379
|
return updateSubscriptionPreference({
|
|
380
|
-
emitter:
|
|
381
|
-
apiService:
|
|
382
|
-
cache:
|
|
383
|
-
useCache:
|
|
384
|
-
args:
|
|
380
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
381
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
382
|
+
cache: chunkA6CBLMST_js.__privateGet(this, _cache),
|
|
383
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache),
|
|
384
|
+
args: chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, args), { subscriptionId: this.identifier })
|
|
385
385
|
});
|
|
386
386
|
});
|
|
387
387
|
}
|
|
388
388
|
bulkUpdatePreferences(args) {
|
|
389
|
-
return
|
|
390
|
-
if (
|
|
389
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
390
|
+
if (chunkA6CBLMST_js.__privateGet(this, _isStale)) {
|
|
391
391
|
return {
|
|
392
|
-
error: new
|
|
392
|
+
error: new chunkTLQQB5Y7_js.NovuError("Cannot bulk update a deleted subscription", new Error("Subscription is stale"))
|
|
393
393
|
};
|
|
394
394
|
}
|
|
395
395
|
return bulkUpdateSubscriptionPreference({
|
|
396
|
-
emitter:
|
|
397
|
-
apiService:
|
|
398
|
-
cache:
|
|
399
|
-
useCache:
|
|
400
|
-
args: args.map((arg) =>
|
|
396
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
397
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
398
|
+
cache: chunkA6CBLMST_js.__privateGet(this, _cache),
|
|
399
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache),
|
|
400
|
+
args: args.map((arg) => chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, arg), { subscriptionId: this.identifier }))
|
|
401
401
|
});
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
delete() {
|
|
405
|
-
return
|
|
406
|
-
if (
|
|
405
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
406
|
+
if (chunkA6CBLMST_js.__privateGet(this, _isStale)) {
|
|
407
407
|
return {
|
|
408
|
-
error: new
|
|
408
|
+
error: new chunkTLQQB5Y7_js.NovuError("Cannot delete an already deleted subscription", new Error("Subscription is stale"))
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
411
|
return deleteSubscription({
|
|
412
|
-
emitter:
|
|
413
|
-
apiService:
|
|
412
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter),
|
|
413
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService),
|
|
414
414
|
args: { subscription: this }
|
|
415
415
|
});
|
|
416
416
|
});
|
|
@@ -423,7 +423,7 @@ _useCache = new WeakMap();
|
|
|
423
423
|
_isStale = new WeakMap();
|
|
424
424
|
|
|
425
425
|
// src/subscriptions/helpers.ts
|
|
426
|
-
var listSubscriptions = (_0) =>
|
|
426
|
+
var listSubscriptions = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
427
427
|
emitter,
|
|
428
428
|
apiService,
|
|
429
429
|
cache,
|
|
@@ -437,7 +437,7 @@ var listSubscriptions = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* (
|
|
|
437
437
|
if (!data || refetch) {
|
|
438
438
|
const response = yield apiService.fetchSubscriptions(args.topicKey);
|
|
439
439
|
data = response.map((el) => {
|
|
440
|
-
return new TopicSubscription(
|
|
440
|
+
return new TopicSubscription(chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, el), { topicKey: args.topicKey }), emitter, apiService, cache, useCache);
|
|
441
441
|
});
|
|
442
442
|
if (useCache) {
|
|
443
443
|
cache.set(args, data);
|
|
@@ -448,10 +448,10 @@ var listSubscriptions = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* (
|
|
|
448
448
|
return { data };
|
|
449
449
|
} catch (error) {
|
|
450
450
|
emitter.emit("subscriptions.list.resolved", { args, error });
|
|
451
|
-
return { error: new
|
|
451
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to fetch subscriptions", error) };
|
|
452
452
|
}
|
|
453
453
|
});
|
|
454
|
-
var getSubscription = (_0) =>
|
|
454
|
+
var getSubscription = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
455
455
|
emitter,
|
|
456
456
|
apiService,
|
|
457
457
|
cache,
|
|
@@ -468,7 +468,7 @@ var getSubscription = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
468
468
|
emitter.emit("subscription.get.resolved", { args, data: null });
|
|
469
469
|
return { data: null };
|
|
470
470
|
}
|
|
471
|
-
data = new TopicSubscription(
|
|
471
|
+
data = new TopicSubscription(chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, response), { topicKey: args.topicKey }), emitter, apiService, cache, useCache);
|
|
472
472
|
if (useCache) {
|
|
473
473
|
cache.setOne(args, data);
|
|
474
474
|
data = cache.get(args);
|
|
@@ -478,10 +478,10 @@ var getSubscription = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
478
478
|
return { data };
|
|
479
479
|
} catch (error) {
|
|
480
480
|
emitter.emit("subscription.get.resolved", { args, error });
|
|
481
|
-
return { error: new
|
|
481
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to fetch subscription", error) };
|
|
482
482
|
}
|
|
483
483
|
});
|
|
484
|
-
var createSubscription = (_0) =>
|
|
484
|
+
var createSubscription = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
485
485
|
emitter,
|
|
486
486
|
apiService,
|
|
487
487
|
cache,
|
|
@@ -499,7 +499,7 @@ var createSubscription = (_0) => chunk7B52C2XE_js.__async(null, [_0], function*
|
|
|
499
499
|
preferences: args.preferences
|
|
500
500
|
});
|
|
501
501
|
const subscription = new TopicSubscription(
|
|
502
|
-
|
|
502
|
+
chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, response), { topicKey: args.topicKey }),
|
|
503
503
|
emitter,
|
|
504
504
|
apiService,
|
|
505
505
|
cache,
|
|
@@ -509,10 +509,10 @@ var createSubscription = (_0) => chunk7B52C2XE_js.__async(null, [_0], function*
|
|
|
509
509
|
return { data: subscription };
|
|
510
510
|
} catch (error) {
|
|
511
511
|
emitter.emit("subscription.create.resolved", { args, error });
|
|
512
|
-
return { error: new
|
|
512
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to create subscription", error) };
|
|
513
513
|
}
|
|
514
514
|
});
|
|
515
|
-
var updateSubscription = (_0) =>
|
|
515
|
+
var updateSubscription = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
516
516
|
emitter,
|
|
517
517
|
apiService,
|
|
518
518
|
cache,
|
|
@@ -531,15 +531,15 @@ var updateSubscription = (_0) => chunk7B52C2XE_js.__async(null, [_0], function*
|
|
|
531
531
|
name: args.name,
|
|
532
532
|
preferences: args.preferences
|
|
533
533
|
});
|
|
534
|
-
const updatedSubscription = new TopicSubscription(
|
|
534
|
+
const updatedSubscription = new TopicSubscription(chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, response), { topicKey }), emitter, apiService, cache, useCache);
|
|
535
535
|
emitter.emit("subscription.update.resolved", { args, data: updatedSubscription });
|
|
536
536
|
return { data: updatedSubscription };
|
|
537
537
|
} catch (error) {
|
|
538
538
|
emitter.emit("subscription.update.resolved", { args, error });
|
|
539
|
-
return { error: new
|
|
539
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to update subscription", error) };
|
|
540
540
|
}
|
|
541
541
|
});
|
|
542
|
-
var updateSubscriptionPreference = (_0) =>
|
|
542
|
+
var updateSubscriptionPreference = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
543
543
|
emitter,
|
|
544
544
|
apiService,
|
|
545
545
|
cache,
|
|
@@ -552,14 +552,14 @@ var updateSubscriptionPreference = (_0) => chunk7B52C2XE_js.__async(null, [_0],
|
|
|
552
552
|
emitter.emit("subscription.preference.update.pending", {
|
|
553
553
|
args,
|
|
554
554
|
data: "preference" in args ? new SubscriptionPreference(
|
|
555
|
-
|
|
555
|
+
chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({}, args.preference), typeof args.value === "boolean" ? { enabled: args.value } : { condition: args.value }),
|
|
556
556
|
emitter,
|
|
557
557
|
apiService,
|
|
558
558
|
cache,
|
|
559
559
|
useCache
|
|
560
560
|
) : void 0
|
|
561
561
|
});
|
|
562
|
-
const response = yield apiService.updateSubscriptionPreference(
|
|
562
|
+
const response = yield apiService.updateSubscriptionPreference(chunkA6CBLMST_js.__spreadValues({
|
|
563
563
|
subscriptionIdentifier: args.subscriptionId,
|
|
564
564
|
workflowId
|
|
565
565
|
}, typeof args.value === "boolean" ? {
|
|
@@ -570,15 +570,15 @@ var updateSubscriptionPreference = (_0) => chunk7B52C2XE_js.__async(null, [_0],
|
|
|
570
570
|
chat: args.value,
|
|
571
571
|
push: args.value
|
|
572
572
|
} : { condition: args.value }));
|
|
573
|
-
const updatedSubscription = new SubscriptionPreference(
|
|
573
|
+
const updatedSubscription = new SubscriptionPreference(chunkA6CBLMST_js.__spreadValues({}, response), emitter, apiService, cache, useCache);
|
|
574
574
|
emitter.emit("subscription.preference.update.resolved", { args, data: updatedSubscription });
|
|
575
575
|
return { data: updatedSubscription };
|
|
576
576
|
} catch (error) {
|
|
577
577
|
emitter.emit("subscription.preference.update.resolved", { args, error });
|
|
578
|
-
return { error: new
|
|
578
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to update subscription", error) };
|
|
579
579
|
}
|
|
580
580
|
});
|
|
581
|
-
var bulkUpdateSubscriptionPreference = (_0) =>
|
|
581
|
+
var bulkUpdateSubscriptionPreference = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
582
582
|
emitter,
|
|
583
583
|
apiService,
|
|
584
584
|
cache,
|
|
@@ -588,7 +588,7 @@ var bulkUpdateSubscriptionPreference = (_0) => chunk7B52C2XE_js.__async(null, [_
|
|
|
588
588
|
try {
|
|
589
589
|
const optimisticallyUpdatedPreferences = args.map(
|
|
590
590
|
(arg) => "preference" in arg ? new SubscriptionPreference(
|
|
591
|
-
|
|
591
|
+
chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({}, arg.preference), typeof arg.value === "boolean" ? { enabled: arg.value } : { condition: arg.value }),
|
|
592
592
|
emitter,
|
|
593
593
|
apiService,
|
|
594
594
|
cache,
|
|
@@ -601,7 +601,7 @@ var bulkUpdateSubscriptionPreference = (_0) => chunk7B52C2XE_js.__async(null, [_
|
|
|
601
601
|
});
|
|
602
602
|
const preferencesToUpdate = args.map((arg) => {
|
|
603
603
|
var _a, _b, _c, _d, _e, _f;
|
|
604
|
-
return
|
|
604
|
+
return chunkA6CBLMST_js.__spreadValues({
|
|
605
605
|
subscriptionIdentifier: arg.subscriptionId,
|
|
606
606
|
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 : ""
|
|
607
607
|
}, 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 });
|
|
@@ -612,10 +612,10 @@ var bulkUpdateSubscriptionPreference = (_0) => chunk7B52C2XE_js.__async(null, [_
|
|
|
612
612
|
return { data: preferences };
|
|
613
613
|
} catch (error) {
|
|
614
614
|
emitter.emit("subscription.preferences.bulk_update.resolved", { args, error });
|
|
615
|
-
return { error: new
|
|
615
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to bulk update subscription preferences", error) };
|
|
616
616
|
}
|
|
617
617
|
});
|
|
618
|
-
var deleteSubscription = (_0) =>
|
|
618
|
+
var deleteSubscription = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
619
619
|
emitter,
|
|
620
620
|
apiService,
|
|
621
621
|
args
|
|
@@ -629,7 +629,7 @@ var deleteSubscription = (_0) => chunk7B52C2XE_js.__async(null, [_0], function*
|
|
|
629
629
|
return { data: void 0 };
|
|
630
630
|
} catch (error) {
|
|
631
631
|
emitter.emit("subscription.delete.resolved", { args, error });
|
|
632
|
-
return { error: new
|
|
632
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to delete subscription", error) };
|
|
633
633
|
}
|
|
634
634
|
});
|
|
635
635
|
|
|
@@ -637,28 +637,28 @@ var deleteSubscription = (_0) => chunk7B52C2XE_js.__async(null, [_0], function*
|
|
|
637
637
|
var _emitter2, _inboxService2, _cache2, _useCache2;
|
|
638
638
|
var SubscriptionPreference = class {
|
|
639
639
|
constructor(preference, emitter, inboxService, cache, useCache) {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
640
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter2);
|
|
641
|
+
chunkA6CBLMST_js.__privateAdd(this, _inboxService2);
|
|
642
|
+
chunkA6CBLMST_js.__privateAdd(this, _cache2);
|
|
643
|
+
chunkA6CBLMST_js.__privateAdd(this, _useCache2);
|
|
644
644
|
var _a;
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
645
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter2, emitter);
|
|
646
|
+
chunkA6CBLMST_js.__privateSet(this, _inboxService2, inboxService);
|
|
647
|
+
chunkA6CBLMST_js.__privateSet(this, _cache2, cache);
|
|
648
|
+
chunkA6CBLMST_js.__privateSet(this, _useCache2, useCache);
|
|
649
649
|
this.enabled = preference.enabled;
|
|
650
650
|
this.condition = (_a = preference.condition) != null ? _a : void 0;
|
|
651
651
|
this.workflow = preference.workflow;
|
|
652
652
|
this.subscriptionId = preference.subscriptionId;
|
|
653
653
|
}
|
|
654
654
|
update(args) {
|
|
655
|
-
return
|
|
655
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
656
656
|
var _a;
|
|
657
657
|
return updateSubscriptionPreference({
|
|
658
|
-
emitter:
|
|
659
|
-
apiService:
|
|
660
|
-
cache:
|
|
661
|
-
useCache:
|
|
658
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter2),
|
|
659
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _inboxService2),
|
|
660
|
+
cache: chunkA6CBLMST_js.__privateGet(this, _cache2),
|
|
661
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache2),
|
|
662
662
|
args: {
|
|
663
663
|
subscriptionId: this.subscriptionId,
|
|
664
664
|
workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
|
|
@@ -681,24 +681,24 @@ var BaseModule = class {
|
|
|
681
681
|
inboxServiceInstance,
|
|
682
682
|
eventEmitterInstance
|
|
683
683
|
}) {
|
|
684
|
-
|
|
685
|
-
|
|
684
|
+
chunkA6CBLMST_js.__privateAdd(this, _callsQueue, []);
|
|
685
|
+
chunkA6CBLMST_js.__privateAdd(this, _sessionError);
|
|
686
686
|
this._emitter = eventEmitterInstance;
|
|
687
687
|
this._inboxService = inboxServiceInstance;
|
|
688
688
|
this._emitter.on("session.initialize.resolved", ({ error, data }) => {
|
|
689
689
|
if (data) {
|
|
690
690
|
this.onSessionSuccess(data);
|
|
691
|
-
|
|
691
|
+
chunkA6CBLMST_js.__privateGet(this, _callsQueue).forEach((_0) => chunkA6CBLMST_js.__async(this, [_0], function* ({ fn, resolve }) {
|
|
692
692
|
resolve(yield fn());
|
|
693
693
|
}));
|
|
694
|
-
|
|
694
|
+
chunkA6CBLMST_js.__privateSet(this, _callsQueue, []);
|
|
695
695
|
} else if (error) {
|
|
696
696
|
this.onSessionError(error);
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
resolve({ error: new
|
|
697
|
+
chunkA6CBLMST_js.__privateSet(this, _sessionError, error);
|
|
698
|
+
chunkA6CBLMST_js.__privateGet(this, _callsQueue).forEach(({ resolve }) => {
|
|
699
|
+
resolve({ error: new chunkTLQQB5Y7_js.NovuError("Failed to initialize session, please contact the support", error) });
|
|
700
700
|
});
|
|
701
|
-
|
|
701
|
+
chunkA6CBLMST_js.__privateSet(this, _callsQueue, []);
|
|
702
702
|
}
|
|
703
703
|
});
|
|
704
704
|
}
|
|
@@ -707,17 +707,17 @@ var BaseModule = class {
|
|
|
707
707
|
onSessionError(_) {
|
|
708
708
|
}
|
|
709
709
|
callWithSession(fn) {
|
|
710
|
-
return
|
|
710
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
711
711
|
if (this._inboxService.isSessionInitialized) {
|
|
712
712
|
return fn();
|
|
713
713
|
}
|
|
714
|
-
if (
|
|
714
|
+
if (chunkA6CBLMST_js.__privateGet(this, _sessionError)) {
|
|
715
715
|
return Promise.resolve({
|
|
716
|
-
error: new
|
|
716
|
+
error: new chunkTLQQB5Y7_js.NovuError("Failed to initialize session, please contact the support", chunkA6CBLMST_js.__privateGet(this, _sessionError))
|
|
717
717
|
});
|
|
718
718
|
}
|
|
719
719
|
return new Promise((resolve, reject) => {
|
|
720
|
-
|
|
720
|
+
chunkA6CBLMST_js.__privateGet(this, _callsQueue).push({ fn, resolve, reject });
|
|
721
721
|
});
|
|
722
722
|
});
|
|
723
723
|
}
|
|
@@ -729,29 +729,29 @@ _sessionError = new WeakMap();
|
|
|
729
729
|
var _cache3;
|
|
730
730
|
var InMemoryCache = class {
|
|
731
731
|
constructor() {
|
|
732
|
-
|
|
733
|
-
|
|
732
|
+
chunkA6CBLMST_js.__privateAdd(this, _cache3);
|
|
733
|
+
chunkA6CBLMST_js.__privateSet(this, _cache3, /* @__PURE__ */ new Map());
|
|
734
734
|
}
|
|
735
735
|
get(key) {
|
|
736
|
-
return
|
|
736
|
+
return chunkA6CBLMST_js.__privateGet(this, _cache3).get(key);
|
|
737
737
|
}
|
|
738
738
|
getValues() {
|
|
739
|
-
return Array.from(
|
|
739
|
+
return Array.from(chunkA6CBLMST_js.__privateGet(this, _cache3).values());
|
|
740
740
|
}
|
|
741
741
|
entries() {
|
|
742
|
-
return Array.from(
|
|
742
|
+
return Array.from(chunkA6CBLMST_js.__privateGet(this, _cache3).entries());
|
|
743
743
|
}
|
|
744
744
|
keys() {
|
|
745
|
-
return Array.from(
|
|
745
|
+
return Array.from(chunkA6CBLMST_js.__privateGet(this, _cache3).keys());
|
|
746
746
|
}
|
|
747
747
|
set(key, value) {
|
|
748
|
-
|
|
748
|
+
chunkA6CBLMST_js.__privateGet(this, _cache3).set(key, value);
|
|
749
749
|
}
|
|
750
750
|
remove(key) {
|
|
751
|
-
|
|
751
|
+
chunkA6CBLMST_js.__privateGet(this, _cache3).delete(key);
|
|
752
752
|
}
|
|
753
753
|
clear() {
|
|
754
|
-
|
|
754
|
+
chunkA6CBLMST_js.__privateGet(this, _cache3).clear();
|
|
755
755
|
}
|
|
756
756
|
};
|
|
757
757
|
_cache3 = new WeakMap();
|
|
@@ -773,37 +773,37 @@ var SubscriptionsCache = class {
|
|
|
773
773
|
inboxServiceInstance,
|
|
774
774
|
useCache
|
|
775
775
|
}) {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
776
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter3);
|
|
777
|
+
chunkA6CBLMST_js.__privateAdd(this, _cache4);
|
|
778
|
+
chunkA6CBLMST_js.__privateAdd(this, _useCache3);
|
|
779
|
+
chunkA6CBLMST_js.__privateAdd(this, _itemCache);
|
|
780
|
+
chunkA6CBLMST_js.__privateAdd(this, _inboxService3);
|
|
781
781
|
this.handleCreate = (subscription) => {
|
|
782
782
|
const listKey = getListCacheKey({ topicKey: subscription.topicKey });
|
|
783
|
-
const subscriptions =
|
|
783
|
+
const subscriptions = chunkA6CBLMST_js.__privateGet(this, _cache4).get(listKey);
|
|
784
784
|
if (subscriptions) {
|
|
785
785
|
const updatedSubscriptions = [...subscriptions, subscription];
|
|
786
|
-
|
|
787
|
-
|
|
786
|
+
chunkA6CBLMST_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
|
|
787
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
|
|
788
788
|
data: { topicKey: subscription.topicKey, subscriptions: updatedSubscriptions }
|
|
789
789
|
});
|
|
790
790
|
}
|
|
791
|
-
|
|
791
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).set(
|
|
792
792
|
getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier }),
|
|
793
793
|
subscription
|
|
794
794
|
);
|
|
795
795
|
};
|
|
796
796
|
this.handleUpdate = (subscription) => {
|
|
797
797
|
const listKey = getListCacheKey({ topicKey: subscription.topicKey });
|
|
798
|
-
const subscriptions =
|
|
798
|
+
const subscriptions = chunkA6CBLMST_js.__privateGet(this, _cache4).get(listKey);
|
|
799
799
|
if (subscriptions) {
|
|
800
800
|
const updatedSubscriptions = subscriptions.map((el) => el.id === subscription.id ? subscription : el);
|
|
801
|
-
|
|
802
|
-
|
|
801
|
+
chunkA6CBLMST_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
|
|
802
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
|
|
803
803
|
data: { topicKey: subscription.topicKey, subscriptions: updatedSubscriptions }
|
|
804
804
|
});
|
|
805
805
|
}
|
|
806
|
-
|
|
806
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).set(
|
|
807
807
|
getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier }),
|
|
808
808
|
subscription
|
|
809
809
|
);
|
|
@@ -822,9 +822,9 @@ var SubscriptionsCache = class {
|
|
|
822
822
|
existing.push(pref);
|
|
823
823
|
preferencesBySubscription.set(pref.subscriptionId, existing);
|
|
824
824
|
}
|
|
825
|
-
const allListKeys =
|
|
825
|
+
const allListKeys = chunkA6CBLMST_js.__privateGet(this, _cache4).keys();
|
|
826
826
|
for (const listKey of allListKeys) {
|
|
827
|
-
const subscriptions =
|
|
827
|
+
const subscriptions = chunkA6CBLMST_js.__privateGet(this, _cache4).get(listKey);
|
|
828
828
|
if (!subscriptions) continue;
|
|
829
829
|
let hasUpdates = false;
|
|
830
830
|
const updatedSubscriptions = subscriptions.map((subscription) => {
|
|
@@ -836,21 +836,21 @@ var SubscriptionsCache = class {
|
|
|
836
836
|
return subscription;
|
|
837
837
|
});
|
|
838
838
|
if (hasUpdates) {
|
|
839
|
-
|
|
840
|
-
|
|
839
|
+
chunkA6CBLMST_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
|
|
840
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
|
|
841
841
|
data: { topicKey: getTopicKeyFromListCacheKey(listKey), subscriptions: updatedSubscriptions }
|
|
842
842
|
});
|
|
843
843
|
}
|
|
844
844
|
}
|
|
845
|
-
const allItemKeys =
|
|
845
|
+
const allItemKeys = chunkA6CBLMST_js.__privateGet(this, _itemCache).keys();
|
|
846
846
|
for (const key of allItemKeys) {
|
|
847
|
-
const subscription =
|
|
847
|
+
const subscription = chunkA6CBLMST_js.__privateGet(this, _itemCache).get(key);
|
|
848
848
|
if (!subscription) continue;
|
|
849
849
|
const subscriptionPreferences = preferencesBySubscription.get(subscription.identifier);
|
|
850
850
|
if (subscriptionPreferences) {
|
|
851
851
|
const updatedSubscription = this.createUpdatedSubscription(subscription, subscriptionPreferences);
|
|
852
|
-
|
|
853
|
-
|
|
852
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).set(key, updatedSubscription);
|
|
853
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).emit("subscription.update.resolved", {
|
|
854
854
|
args: { subscription },
|
|
855
855
|
data: updatedSubscription
|
|
856
856
|
});
|
|
@@ -873,130 +873,130 @@ var SubscriptionsCache = class {
|
|
|
873
873
|
topicKey: subscription.topicKey,
|
|
874
874
|
preferences: updatedPreferences
|
|
875
875
|
},
|
|
876
|
-
|
|
877
|
-
|
|
876
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3),
|
|
877
|
+
chunkA6CBLMST_js.__privateGet(this, _inboxService3),
|
|
878
878
|
this,
|
|
879
|
-
|
|
879
|
+
chunkA6CBLMST_js.__privateGet(this, _useCache3)
|
|
880
880
|
);
|
|
881
881
|
};
|
|
882
882
|
this.handleDelete = (subscription) => {
|
|
883
883
|
const listKey = getListCacheKey({ topicKey: subscription.topicKey });
|
|
884
|
-
const subscriptions =
|
|
884
|
+
const subscriptions = chunkA6CBLMST_js.__privateGet(this, _cache4).get(listKey);
|
|
885
885
|
if (subscriptions) {
|
|
886
886
|
const updatedSubscriptions = subscriptions.filter((el) => el.id !== subscription.id);
|
|
887
|
-
|
|
888
|
-
|
|
887
|
+
chunkA6CBLMST_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
|
|
888
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
|
|
889
889
|
data: { topicKey: subscription.topicKey, subscriptions: updatedSubscriptions }
|
|
890
890
|
});
|
|
891
891
|
}
|
|
892
|
-
|
|
892
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).remove(getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier }));
|
|
893
893
|
};
|
|
894
894
|
this.handleDeleteByIdentifier = (identifier) => {
|
|
895
|
-
const allListKeys =
|
|
895
|
+
const allListKeys = chunkA6CBLMST_js.__privateGet(this, _cache4).keys();
|
|
896
896
|
for (const listKey of allListKeys) {
|
|
897
|
-
const subscriptions =
|
|
897
|
+
const subscriptions = chunkA6CBLMST_js.__privateGet(this, _cache4).get(listKey);
|
|
898
898
|
if (subscriptions) {
|
|
899
899
|
const subscription = subscriptions.find((el) => el.identifier === identifier);
|
|
900
900
|
if (subscription) {
|
|
901
901
|
const updatedSubscriptions = subscriptions.filter((el) => el.identifier !== identifier);
|
|
902
|
-
|
|
903
|
-
|
|
902
|
+
chunkA6CBLMST_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
|
|
903
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
|
|
904
904
|
data: { topicKey: getTopicKeyFromListCacheKey(listKey), subscriptions: updatedSubscriptions }
|
|
905
905
|
});
|
|
906
|
-
|
|
906
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).remove(
|
|
907
907
|
getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier })
|
|
908
908
|
);
|
|
909
909
|
return;
|
|
910
910
|
}
|
|
911
911
|
}
|
|
912
912
|
}
|
|
913
|
-
const allItemKeys =
|
|
913
|
+
const allItemKeys = chunkA6CBLMST_js.__privateGet(this, _itemCache).keys();
|
|
914
914
|
for (const key of allItemKeys) {
|
|
915
|
-
const subscription =
|
|
915
|
+
const subscription = chunkA6CBLMST_js.__privateGet(this, _itemCache).get(key);
|
|
916
916
|
if (subscription && subscription.identifier === identifier) {
|
|
917
|
-
|
|
917
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).remove(key);
|
|
918
918
|
return;
|
|
919
919
|
}
|
|
920
920
|
}
|
|
921
921
|
};
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
922
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter3, emitterInstance);
|
|
923
|
+
chunkA6CBLMST_js.__privateSet(this, _cache4, new InMemoryCache());
|
|
924
|
+
chunkA6CBLMST_js.__privateSet(this, _itemCache, new InMemoryCache());
|
|
925
|
+
chunkA6CBLMST_js.__privateSet(this, _inboxService3, inboxServiceInstance);
|
|
926
|
+
chunkA6CBLMST_js.__privateSet(this, _useCache3, useCache);
|
|
927
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).on("subscription.create.resolved", ({ data }) => {
|
|
928
928
|
if (data) {
|
|
929
929
|
this.handleCreate(data);
|
|
930
930
|
}
|
|
931
931
|
});
|
|
932
|
-
|
|
932
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).on("subscription.update.resolved", ({ data }) => {
|
|
933
933
|
if (data) {
|
|
934
934
|
this.handleUpdate(data);
|
|
935
935
|
}
|
|
936
936
|
});
|
|
937
|
-
|
|
937
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).on("subscription.delete.resolved", ({ args }) => {
|
|
938
938
|
if ("subscription" in args) {
|
|
939
939
|
this.handleDelete(args.subscription);
|
|
940
940
|
} else if ("identifier" in args) {
|
|
941
941
|
this.handleDeleteByIdentifier(args.identifier);
|
|
942
942
|
}
|
|
943
943
|
});
|
|
944
|
-
|
|
944
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).on("subscription.preference.update.pending", ({ data }) => {
|
|
945
945
|
if (data) {
|
|
946
946
|
this.handlePreferenceUpdate(data);
|
|
947
947
|
}
|
|
948
948
|
});
|
|
949
|
-
|
|
949
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).on("subscription.preference.update.resolved", ({ data }) => {
|
|
950
950
|
if (data) {
|
|
951
951
|
this.handlePreferenceUpdate(data);
|
|
952
952
|
}
|
|
953
953
|
});
|
|
954
|
-
|
|
954
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter3).on("subscription.preferences.bulk_update.resolved", ({ data }) => {
|
|
955
955
|
if (data && data.length > 0) {
|
|
956
956
|
this.handleBulkPreferenceUpdate(data);
|
|
957
957
|
}
|
|
958
958
|
});
|
|
959
959
|
}
|
|
960
960
|
has(args) {
|
|
961
|
-
return
|
|
961
|
+
return chunkA6CBLMST_js.__privateGet(this, _cache4).get(getListCacheKey(args)) !== void 0;
|
|
962
962
|
}
|
|
963
963
|
set(args, data) {
|
|
964
|
-
|
|
964
|
+
chunkA6CBLMST_js.__privateGet(this, _cache4).set(getListCacheKey(args), data);
|
|
965
965
|
for (const subscription of data) {
|
|
966
|
-
|
|
966
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).set(
|
|
967
967
|
getItemCacheKey({ topicKey: args.topicKey, identifier: subscription.identifier }),
|
|
968
968
|
subscription
|
|
969
969
|
);
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
972
|
setOne(args, data) {
|
|
973
|
-
|
|
973
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).set(getItemCacheKey(args), data);
|
|
974
974
|
}
|
|
975
975
|
getAll(args) {
|
|
976
|
-
return
|
|
976
|
+
return chunkA6CBLMST_js.__privateGet(this, _cache4).get(getListCacheKey(args));
|
|
977
977
|
}
|
|
978
978
|
get(args) {
|
|
979
|
-
return
|
|
979
|
+
return chunkA6CBLMST_js.__privateGet(this, _itemCache).get(getItemCacheKey(args));
|
|
980
980
|
}
|
|
981
981
|
invalidate(args) {
|
|
982
982
|
const listKey = getListCacheKey({ topicKey: args.topicKey });
|
|
983
|
-
const subscriptions =
|
|
983
|
+
const subscriptions = chunkA6CBLMST_js.__privateGet(this, _cache4).get(listKey);
|
|
984
984
|
if (subscriptions) {
|
|
985
985
|
for (const subscription of subscriptions) {
|
|
986
|
-
|
|
986
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).remove(getItemCacheKey({ topicKey: args.topicKey, identifier: subscription.identifier }));
|
|
987
987
|
}
|
|
988
988
|
}
|
|
989
|
-
|
|
990
|
-
const allItemKeys =
|
|
989
|
+
chunkA6CBLMST_js.__privateGet(this, _cache4).remove(listKey);
|
|
990
|
+
const allItemKeys = chunkA6CBLMST_js.__privateGet(this, _itemCache).keys();
|
|
991
991
|
for (const key of allItemKeys) {
|
|
992
992
|
if (key.startsWith(`item:${args.topicKey}:`)) {
|
|
993
|
-
|
|
993
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).remove(key);
|
|
994
994
|
}
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
997
|
clearAll() {
|
|
998
|
-
|
|
999
|
-
|
|
998
|
+
chunkA6CBLMST_js.__privateGet(this, _cache4).clear();
|
|
999
|
+
chunkA6CBLMST_js.__privateGet(this, _itemCache).clear();
|
|
1000
1000
|
}
|
|
1001
1001
|
};
|
|
1002
1002
|
_emitter3 = new WeakMap();
|
|
@@ -1019,20 +1019,20 @@ var Subscriptions = class extends BaseModule {
|
|
|
1019
1019
|
eventEmitterInstance,
|
|
1020
1020
|
inboxServiceInstance
|
|
1021
1021
|
});
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1022
|
+
chunkA6CBLMST_js.__privateAdd(this, _useCache4);
|
|
1023
|
+
chunkA6CBLMST_js.__privateAdd(this, _subscriber);
|
|
1024
|
+
chunkA6CBLMST_js.__privateAdd(this, _contextKey);
|
|
1025
1025
|
this.cache = new SubscriptionsCache({
|
|
1026
1026
|
emitterInstance: this._emitter,
|
|
1027
1027
|
inboxServiceInstance: this._inboxService,
|
|
1028
1028
|
useCache
|
|
1029
1029
|
});
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1030
|
+
chunkA6CBLMST_js.__privateSet(this, _useCache4, useCache);
|
|
1031
|
+
chunkA6CBLMST_js.__privateSet(this, _subscriber, subscriber);
|
|
1032
|
+
chunkA6CBLMST_js.__privateSet(this, _contextKey, contextKey);
|
|
1033
1033
|
}
|
|
1034
1034
|
list(args, options) {
|
|
1035
|
-
return
|
|
1035
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1036
1036
|
return this.callWithSession(
|
|
1037
1037
|
() => {
|
|
1038
1038
|
var _a;
|
|
@@ -1040,8 +1040,8 @@ var Subscriptions = class extends BaseModule {
|
|
|
1040
1040
|
emitter: this._emitter,
|
|
1041
1041
|
apiService: this._inboxService,
|
|
1042
1042
|
cache: this.cache,
|
|
1043
|
-
options:
|
|
1044
|
-
useCache: (_a = options == null ? void 0 : options.useCache) != null ? _a :
|
|
1043
|
+
options: chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, options), {
|
|
1044
|
+
useCache: (_a = options == null ? void 0 : options.useCache) != null ? _a : chunkA6CBLMST_js.__privateGet(this, _useCache4)
|
|
1045
1045
|
}),
|
|
1046
1046
|
args
|
|
1047
1047
|
});
|
|
@@ -1050,7 +1050,7 @@ var Subscriptions = class extends BaseModule {
|
|
|
1050
1050
|
});
|
|
1051
1051
|
}
|
|
1052
1052
|
get(args, options) {
|
|
1053
|
-
return
|
|
1053
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1054
1054
|
return this.callWithSession(
|
|
1055
1055
|
() => {
|
|
1056
1056
|
var _a, _b;
|
|
@@ -1058,14 +1058,14 @@ var Subscriptions = class extends BaseModule {
|
|
|
1058
1058
|
emitter: this._emitter,
|
|
1059
1059
|
apiService: this._inboxService,
|
|
1060
1060
|
cache: this.cache,
|
|
1061
|
-
options:
|
|
1062
|
-
useCache: (_a = options == null ? void 0 : options.useCache) != null ? _a :
|
|
1061
|
+
options: chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, options), {
|
|
1062
|
+
useCache: (_a = options == null ? void 0 : options.useCache) != null ? _a : chunkA6CBLMST_js.__privateGet(this, _useCache4)
|
|
1063
1063
|
}),
|
|
1064
|
-
args:
|
|
1065
|
-
identifier: (_b = args.identifier) != null ? _b :
|
|
1064
|
+
args: chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, args), {
|
|
1065
|
+
identifier: (_b = args.identifier) != null ? _b : chunkTLQQB5Y7_js.buildSubscriptionIdentifier({
|
|
1066
1066
|
topicKey: args.topicKey,
|
|
1067
|
-
subscriberId:
|
|
1068
|
-
contextKey:
|
|
1067
|
+
subscriberId: chunkA6CBLMST_js.__privateGet(this, _subscriber).subscriberId,
|
|
1068
|
+
contextKey: chunkA6CBLMST_js.__privateGet(this, _contextKey)
|
|
1069
1069
|
})
|
|
1070
1070
|
})
|
|
1071
1071
|
});
|
|
@@ -1074,33 +1074,33 @@ var Subscriptions = class extends BaseModule {
|
|
|
1074
1074
|
});
|
|
1075
1075
|
}
|
|
1076
1076
|
create(args) {
|
|
1077
|
-
return
|
|
1077
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1078
1078
|
return this.callWithSession(
|
|
1079
1079
|
() => createSubscription({
|
|
1080
1080
|
emitter: this._emitter,
|
|
1081
1081
|
apiService: this._inboxService,
|
|
1082
1082
|
cache: this.cache,
|
|
1083
|
-
useCache:
|
|
1083
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache4),
|
|
1084
1084
|
args
|
|
1085
1085
|
})
|
|
1086
1086
|
);
|
|
1087
1087
|
});
|
|
1088
1088
|
}
|
|
1089
1089
|
update(args) {
|
|
1090
|
-
return
|
|
1090
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1091
1091
|
return this.callWithSession(
|
|
1092
1092
|
() => updateSubscription({
|
|
1093
1093
|
emitter: this._emitter,
|
|
1094
1094
|
apiService: this._inboxService,
|
|
1095
1095
|
cache: this.cache,
|
|
1096
|
-
useCache:
|
|
1096
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache4),
|
|
1097
1097
|
args
|
|
1098
1098
|
})
|
|
1099
1099
|
);
|
|
1100
1100
|
});
|
|
1101
1101
|
}
|
|
1102
1102
|
delete(args) {
|
|
1103
|
-
return
|
|
1103
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1104
1104
|
return this.callWithSession(
|
|
1105
1105
|
() => deleteSubscription({
|
|
1106
1106
|
emitter: this._emitter,
|
|
@@ -1117,7 +1117,7 @@ _contextKey = new WeakMap();
|
|
|
1117
1117
|
|
|
1118
1118
|
// src/api/http-client.ts
|
|
1119
1119
|
var DEFAULT_API_VERSION = "v1";
|
|
1120
|
-
var DEFAULT_CLIENT_VERSION = `${"@novu/js"}@${"3.
|
|
1120
|
+
var DEFAULT_CLIENT_VERSION = `${"@novu/js"}@${"3.18.0"}`;
|
|
1121
1121
|
var HttpClient = class {
|
|
1122
1122
|
constructor(options = {}) {
|
|
1123
1123
|
// Environment variable for local development that overrides the default API endpoint without affecting the Inbox DX
|
|
@@ -1125,7 +1125,7 @@ var HttpClient = class {
|
|
|
1125
1125
|
const { apiVersion = DEFAULT_API_VERSION, apiUrl = this.DEFAULT_BACKEND_URL, headers = {} } = options || {};
|
|
1126
1126
|
this.apiVersion = apiVersion;
|
|
1127
1127
|
this.apiUrl = `${apiUrl}/${apiVersion}`;
|
|
1128
|
-
this.headers =
|
|
1128
|
+
this.headers = chunkA6CBLMST_js.__spreadValues({
|
|
1129
1129
|
"Novu-API-Version": "2024-06-26",
|
|
1130
1130
|
"Novu-Client-Version": DEFAULT_CLIENT_VERSION,
|
|
1131
1131
|
"Content-Type": "application/json"
|
|
@@ -1143,10 +1143,10 @@ var HttpClient = class {
|
|
|
1143
1143
|
this.headers["Novu-Application-Identifier"] = keylessAppIdentifier;
|
|
1144
1144
|
}
|
|
1145
1145
|
setHeaders(headers) {
|
|
1146
|
-
this.headers =
|
|
1146
|
+
this.headers = chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({}, this.headers), headers);
|
|
1147
1147
|
}
|
|
1148
1148
|
get(path, searchParams, unwrapEnvelope = true) {
|
|
1149
|
-
return
|
|
1149
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1150
1150
|
return this.doFetch({
|
|
1151
1151
|
path,
|
|
1152
1152
|
searchParams,
|
|
@@ -1158,7 +1158,7 @@ var HttpClient = class {
|
|
|
1158
1158
|
});
|
|
1159
1159
|
}
|
|
1160
1160
|
post(path, body, options) {
|
|
1161
|
-
return
|
|
1161
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1162
1162
|
return this.doFetch({
|
|
1163
1163
|
path,
|
|
1164
1164
|
options: {
|
|
@@ -1170,7 +1170,7 @@ var HttpClient = class {
|
|
|
1170
1170
|
});
|
|
1171
1171
|
}
|
|
1172
1172
|
patch(path, body) {
|
|
1173
|
-
return
|
|
1173
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1174
1174
|
return this.doFetch({
|
|
1175
1175
|
path,
|
|
1176
1176
|
options: {
|
|
@@ -1181,7 +1181,7 @@ var HttpClient = class {
|
|
|
1181
1181
|
});
|
|
1182
1182
|
}
|
|
1183
1183
|
delete(path, body) {
|
|
1184
|
-
return
|
|
1184
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1185
1185
|
return this.doFetch({
|
|
1186
1186
|
path,
|
|
1187
1187
|
options: {
|
|
@@ -1192,7 +1192,7 @@ var HttpClient = class {
|
|
|
1192
1192
|
});
|
|
1193
1193
|
}
|
|
1194
1194
|
doFetch(_0) {
|
|
1195
|
-
return
|
|
1195
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* ({
|
|
1196
1196
|
path,
|
|
1197
1197
|
searchParams,
|
|
1198
1198
|
options,
|
|
@@ -1201,7 +1201,7 @@ var HttpClient = class {
|
|
|
1201
1201
|
const fullUrl = combineUrl(this.apiUrl, path, searchParams ? `?${searchParams.toString()}` : "");
|
|
1202
1202
|
const reqInit = {
|
|
1203
1203
|
method: (options == null ? void 0 : options.method) || "GET",
|
|
1204
|
-
headers:
|
|
1204
|
+
headers: chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({}, this.headers), (options == null ? void 0 : options.headers) || {}),
|
|
1205
1205
|
body: (options == null ? void 0 : options.body) ? JSON.stringify(options.body) : void 0
|
|
1206
1206
|
};
|
|
1207
1207
|
const response = yield fetch(fullUrl, reqInit);
|
|
@@ -1294,11 +1294,11 @@ var _httpClient;
|
|
|
1294
1294
|
var InboxService = class {
|
|
1295
1295
|
constructor(options = {}) {
|
|
1296
1296
|
this.isSessionInitialized = false;
|
|
1297
|
-
|
|
1298
|
-
|
|
1297
|
+
chunkA6CBLMST_js.__privateAdd(this, _httpClient);
|
|
1298
|
+
chunkA6CBLMST_js.__privateSet(this, _httpClient, new HttpClient(options));
|
|
1299
1299
|
}
|
|
1300
1300
|
initializeSession(_0) {
|
|
1301
|
-
return
|
|
1301
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* ({
|
|
1302
1302
|
applicationIdentifier,
|
|
1303
1303
|
subscriberHash,
|
|
1304
1304
|
contextHash,
|
|
@@ -1306,7 +1306,7 @@ var InboxService = class {
|
|
|
1306
1306
|
defaultSchedule,
|
|
1307
1307
|
context
|
|
1308
1308
|
}) {
|
|
1309
|
-
const response = yield
|
|
1309
|
+
const response = yield chunkA6CBLMST_js.__privateGet(this, _httpClient).post(`${INBOX_ROUTE}/session`, {
|
|
1310
1310
|
applicationIdentifier,
|
|
1311
1311
|
subscriberHash,
|
|
1312
1312
|
contextHash,
|
|
@@ -1314,8 +1314,8 @@ var InboxService = class {
|
|
|
1314
1314
|
defaultSchedule,
|
|
1315
1315
|
context
|
|
1316
1316
|
});
|
|
1317
|
-
|
|
1318
|
-
|
|
1317
|
+
chunkA6CBLMST_js.__privateGet(this, _httpClient).setAuthorizationToken(response.token);
|
|
1318
|
+
chunkA6CBLMST_js.__privateGet(this, _httpClient).setKeylessHeader(response.applicationIdentifier);
|
|
1319
1319
|
this.isSessionInitialized = true;
|
|
1320
1320
|
return response;
|
|
1321
1321
|
});
|
|
@@ -1370,12 +1370,12 @@ var InboxService = class {
|
|
|
1370
1370
|
if (createdLte) {
|
|
1371
1371
|
searchParams.append("createdLte", `${createdLte}`);
|
|
1372
1372
|
}
|
|
1373
|
-
return
|
|
1373
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).get(INBOX_NOTIFICATIONS_ROUTE, searchParams, false);
|
|
1374
1374
|
}
|
|
1375
1375
|
count({
|
|
1376
1376
|
filters
|
|
1377
1377
|
}) {
|
|
1378
|
-
return
|
|
1378
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).get(
|
|
1379
1379
|
`${INBOX_NOTIFICATIONS_ROUTE}/count`,
|
|
1380
1380
|
new URLSearchParams({
|
|
1381
1381
|
filters: JSON.stringify(filters)
|
|
@@ -1384,46 +1384,46 @@ var InboxService = class {
|
|
|
1384
1384
|
);
|
|
1385
1385
|
}
|
|
1386
1386
|
read(notificationId) {
|
|
1387
|
-
return
|
|
1387
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/read`);
|
|
1388
1388
|
}
|
|
1389
1389
|
unread(notificationId) {
|
|
1390
|
-
return
|
|
1390
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unread`);
|
|
1391
1391
|
}
|
|
1392
1392
|
archive(notificationId) {
|
|
1393
|
-
return
|
|
1393
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/archive`);
|
|
1394
1394
|
}
|
|
1395
1395
|
unarchive(notificationId) {
|
|
1396
|
-
return
|
|
1396
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unarchive`);
|
|
1397
1397
|
}
|
|
1398
1398
|
snooze(notificationId, snoozeUntil) {
|
|
1399
|
-
return
|
|
1399
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/snooze`, { snoozeUntil });
|
|
1400
1400
|
}
|
|
1401
1401
|
unsnooze(notificationId) {
|
|
1402
|
-
return
|
|
1402
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unsnooze`);
|
|
1403
1403
|
}
|
|
1404
1404
|
readAll({ tags, data }) {
|
|
1405
|
-
return
|
|
1405
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read`, {
|
|
1406
1406
|
tags,
|
|
1407
1407
|
data: data ? JSON.stringify(data) : void 0
|
|
1408
1408
|
});
|
|
1409
1409
|
}
|
|
1410
1410
|
archiveAll({ tags, data }) {
|
|
1411
|
-
return
|
|
1411
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/archive`, {
|
|
1412
1412
|
tags,
|
|
1413
1413
|
data: data ? JSON.stringify(data) : void 0
|
|
1414
1414
|
});
|
|
1415
1415
|
}
|
|
1416
1416
|
archiveAllRead({ tags, data }) {
|
|
1417
|
-
return
|
|
1417
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read-archive`, {
|
|
1418
1418
|
tags,
|
|
1419
1419
|
data: data ? JSON.stringify(data) : void 0
|
|
1420
1420
|
});
|
|
1421
1421
|
}
|
|
1422
1422
|
delete(notificationId) {
|
|
1423
|
-
return
|
|
1423
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).delete(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/delete`);
|
|
1424
1424
|
}
|
|
1425
1425
|
deleteAll({ tags, data }) {
|
|
1426
|
-
return
|
|
1426
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/delete`, {
|
|
1427
1427
|
tags,
|
|
1428
1428
|
data: data ? JSON.stringify(data) : void 0
|
|
1429
1429
|
});
|
|
@@ -1433,7 +1433,7 @@ var InboxService = class {
|
|
|
1433
1433
|
tags,
|
|
1434
1434
|
data
|
|
1435
1435
|
}) {
|
|
1436
|
-
return
|
|
1436
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/seen`, {
|
|
1437
1437
|
notificationIds,
|
|
1438
1438
|
tags,
|
|
1439
1439
|
data: data ? JSON.stringify(data) : void 0
|
|
@@ -1446,7 +1446,7 @@ var InboxService = class {
|
|
|
1446
1446
|
actionType,
|
|
1447
1447
|
notificationId
|
|
1448
1448
|
}) {
|
|
1449
|
-
return
|
|
1449
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/complete`, {
|
|
1450
1450
|
actionType
|
|
1451
1451
|
});
|
|
1452
1452
|
}
|
|
@@ -1454,7 +1454,7 @@ var InboxService = class {
|
|
|
1454
1454
|
actionType,
|
|
1455
1455
|
notificationId
|
|
1456
1456
|
}) {
|
|
1457
|
-
return
|
|
1457
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/revert`, {
|
|
1458
1458
|
actionType
|
|
1459
1459
|
});
|
|
1460
1460
|
}
|
|
@@ -1480,22 +1480,22 @@ var InboxService = class {
|
|
|
1480
1480
|
queryParams.append("criticality", criticality);
|
|
1481
1481
|
}
|
|
1482
1482
|
const query = queryParams.size ? `?${queryParams.toString()}` : "";
|
|
1483
|
-
return
|
|
1483
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).get(`${INBOX_ROUTE}/preferences${query}`);
|
|
1484
1484
|
}
|
|
1485
1485
|
bulkUpdatePreferences(preferences) {
|
|
1486
|
-
return
|
|
1486
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/bulk`, { preferences });
|
|
1487
1487
|
}
|
|
1488
1488
|
updateGlobalPreferences(preferences) {
|
|
1489
|
-
return
|
|
1489
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences`, preferences);
|
|
1490
1490
|
}
|
|
1491
1491
|
updateWorkflowPreferences({
|
|
1492
1492
|
workflowId,
|
|
1493
1493
|
channels
|
|
1494
1494
|
}) {
|
|
1495
|
-
return
|
|
1495
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/${workflowId}`, channels);
|
|
1496
1496
|
}
|
|
1497
1497
|
fetchGlobalPreferences() {
|
|
1498
|
-
return
|
|
1498
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).get(`${INBOX_ROUTE}/preferences/global`);
|
|
1499
1499
|
}
|
|
1500
1500
|
triggerHelloWorldEvent() {
|
|
1501
1501
|
const payload = {
|
|
@@ -1512,10 +1512,10 @@ var InboxService = class {
|
|
|
1512
1512
|
secondaryActionUrl: "https://go.novu.co/keyless-docs"
|
|
1513
1513
|
}
|
|
1514
1514
|
};
|
|
1515
|
-
return
|
|
1515
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post("/inbox/events", payload);
|
|
1516
1516
|
}
|
|
1517
1517
|
fetchSubscriptions(topicKey) {
|
|
1518
|
-
return
|
|
1518
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).get(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions`);
|
|
1519
1519
|
}
|
|
1520
1520
|
getSubscription(topicKey, identifier, workflowIds, tags) {
|
|
1521
1521
|
const searchParams = new URLSearchParams();
|
|
@@ -1523,7 +1523,7 @@ var InboxService = class {
|
|
|
1523
1523
|
for (const workflowIdentifier of workflowIds) searchParams.append("workflowIds", workflowIdentifier);
|
|
1524
1524
|
if (tags == null ? void 0 : tags.length) for (const tag of tags) searchParams.append("tags", tag);
|
|
1525
1525
|
const query = searchParams.size ? `?${searchParams.toString()}` : "";
|
|
1526
|
-
return
|
|
1526
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).get(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${identifier}${query}`);
|
|
1527
1527
|
}
|
|
1528
1528
|
createSubscription({
|
|
1529
1529
|
identifier,
|
|
@@ -1532,7 +1532,7 @@ var InboxService = class {
|
|
|
1532
1532
|
topicName,
|
|
1533
1533
|
preferences
|
|
1534
1534
|
}) {
|
|
1535
|
-
return
|
|
1535
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions`, chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({
|
|
1536
1536
|
identifier,
|
|
1537
1537
|
name
|
|
1538
1538
|
}, topicName && { topic: { name: topicName } }), preferences !== void 0 && { preferences }));
|
|
@@ -1543,7 +1543,7 @@ var InboxService = class {
|
|
|
1543
1543
|
name,
|
|
1544
1544
|
preferences
|
|
1545
1545
|
}) {
|
|
1546
|
-
return
|
|
1546
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${identifier}`, chunkA6CBLMST_js.__spreadValues({
|
|
1547
1547
|
name
|
|
1548
1548
|
}, preferences !== void 0 && { preferences }));
|
|
1549
1549
|
}
|
|
@@ -1558,7 +1558,7 @@ var InboxService = class {
|
|
|
1558
1558
|
chat,
|
|
1559
1559
|
push
|
|
1560
1560
|
}) {
|
|
1561
|
-
return
|
|
1561
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/subscriptions/${subscriptionIdentifier}/preferences/${workflowId}`, {
|
|
1562
1562
|
enabled,
|
|
1563
1563
|
condition,
|
|
1564
1564
|
email,
|
|
@@ -1569,10 +1569,10 @@ var InboxService = class {
|
|
|
1569
1569
|
});
|
|
1570
1570
|
}
|
|
1571
1571
|
bulkUpdateSubscriptionPreferences(preferences) {
|
|
1572
|
-
return
|
|
1572
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/bulk`, { preferences });
|
|
1573
1573
|
}
|
|
1574
1574
|
deleteSubscription({ topicKey, identifier }) {
|
|
1575
|
-
return
|
|
1575
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).delete(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${identifier}`);
|
|
1576
1576
|
}
|
|
1577
1577
|
/**
|
|
1578
1578
|
* @deprecated Use generateConnectOAuthUrl() or generateLinkUserOAuthUrl() instead.
|
|
@@ -1588,7 +1588,7 @@ var InboxService = class {
|
|
|
1588
1588
|
connectionMode,
|
|
1589
1589
|
autoLinkUser
|
|
1590
1590
|
}) {
|
|
1591
|
-
return
|
|
1591
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(CHAT_OAUTH_ROUTE, {
|
|
1592
1592
|
integrationIdentifier,
|
|
1593
1593
|
connectionIdentifier,
|
|
1594
1594
|
subscriberId,
|
|
@@ -1609,7 +1609,7 @@ var InboxService = class {
|
|
|
1609
1609
|
connectionMode,
|
|
1610
1610
|
autoLinkUser
|
|
1611
1611
|
}) {
|
|
1612
|
-
return
|
|
1612
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(CHANNEL_CONNECTIONS_OAUTH_ROUTE, {
|
|
1613
1613
|
integrationIdentifier,
|
|
1614
1614
|
connectionIdentifier,
|
|
1615
1615
|
subscriberId,
|
|
@@ -1626,7 +1626,7 @@ var InboxService = class {
|
|
|
1626
1626
|
context,
|
|
1627
1627
|
userScope
|
|
1628
1628
|
}) {
|
|
1629
|
-
return
|
|
1629
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(CHANNEL_ENDPOINTS_OAUTH_ROUTE, {
|
|
1630
1630
|
integrationIdentifier,
|
|
1631
1631
|
connectionIdentifier,
|
|
1632
1632
|
subscriberId,
|
|
@@ -1636,10 +1636,10 @@ var InboxService = class {
|
|
|
1636
1636
|
}
|
|
1637
1637
|
listChannelConnections(args = {}) {
|
|
1638
1638
|
const query = buildChannelListSearchParams(args);
|
|
1639
|
-
return
|
|
1639
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).get(`${CHANNEL_CONNECTIONS_ROUTE}${query}`, void 0, false);
|
|
1640
1640
|
}
|
|
1641
1641
|
getChannelConnection(identifier) {
|
|
1642
|
-
return
|
|
1642
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).get(`${CHANNEL_CONNECTIONS_ROUTE}/${identifier}`);
|
|
1643
1643
|
}
|
|
1644
1644
|
createChannelConnection({
|
|
1645
1645
|
identifier,
|
|
@@ -1649,7 +1649,7 @@ var InboxService = class {
|
|
|
1649
1649
|
workspace,
|
|
1650
1650
|
auth
|
|
1651
1651
|
}) {
|
|
1652
|
-
return
|
|
1652
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(CHANNEL_CONNECTIONS_ROUTE, {
|
|
1653
1653
|
identifier,
|
|
1654
1654
|
integrationIdentifier,
|
|
1655
1655
|
subscriberId,
|
|
@@ -1659,14 +1659,14 @@ var InboxService = class {
|
|
|
1659
1659
|
});
|
|
1660
1660
|
}
|
|
1661
1661
|
deleteChannelConnection(identifier) {
|
|
1662
|
-
return
|
|
1662
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).delete(`${CHANNEL_CONNECTIONS_ROUTE}/${identifier}`);
|
|
1663
1663
|
}
|
|
1664
1664
|
listChannelEndpoints(args = {}) {
|
|
1665
1665
|
const query = buildChannelListSearchParams(args);
|
|
1666
|
-
return
|
|
1666
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).get(`${CHANNEL_ENDPOINTS_ROUTE}${query}`, void 0, false);
|
|
1667
1667
|
}
|
|
1668
1668
|
getChannelEndpoint(identifier) {
|
|
1669
|
-
return
|
|
1669
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).get(`${CHANNEL_ENDPOINTS_ROUTE}/${identifier}`);
|
|
1670
1670
|
}
|
|
1671
1671
|
createChannelEndpoint({
|
|
1672
1672
|
identifier,
|
|
@@ -1677,7 +1677,7 @@ var InboxService = class {
|
|
|
1677
1677
|
type,
|
|
1678
1678
|
endpoint
|
|
1679
1679
|
}) {
|
|
1680
|
-
return
|
|
1680
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(CHANNEL_ENDPOINTS_ROUTE, {
|
|
1681
1681
|
identifier,
|
|
1682
1682
|
integrationIdentifier,
|
|
1683
1683
|
connectionIdentifier,
|
|
@@ -1688,13 +1688,18 @@ var InboxService = class {
|
|
|
1688
1688
|
});
|
|
1689
1689
|
}
|
|
1690
1690
|
deleteChannelEndpoint(identifier) {
|
|
1691
|
-
return
|
|
1691
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).delete(`${CHANNEL_ENDPOINTS_ROUTE}/${identifier}`);
|
|
1692
|
+
}
|
|
1693
|
+
linkChannelEndpoint({ integrationIdentifier }) {
|
|
1694
|
+
return chunkA6CBLMST_js.__privateGet(this, _httpClient).post(`${CHANNEL_ENDPOINTS_ROUTE}/link`, {
|
|
1695
|
+
integrationIdentifier
|
|
1696
|
+
});
|
|
1692
1697
|
}
|
|
1693
1698
|
};
|
|
1694
1699
|
_httpClient = new WeakMap();
|
|
1695
1700
|
|
|
1696
1701
|
// src/channel-connections/helpers.ts
|
|
1697
|
-
var generateChatOAuthUrl = (_0) =>
|
|
1702
|
+
var generateChatOAuthUrl = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1698
1703
|
emitter,
|
|
1699
1704
|
apiService,
|
|
1700
1705
|
args
|
|
@@ -1706,10 +1711,10 @@ var generateChatOAuthUrl = (_0) => chunk7B52C2XE_js.__async(null, [_0], function
|
|
|
1706
1711
|
return { data };
|
|
1707
1712
|
} catch (error) {
|
|
1708
1713
|
emitter.emit("channel-connection.oauth-url.resolved", { args, error });
|
|
1709
|
-
return { error: new
|
|
1714
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to generate chat OAuth URL", error) };
|
|
1710
1715
|
}
|
|
1711
1716
|
});
|
|
1712
|
-
var generateConnectOAuthUrl = (_0) =>
|
|
1717
|
+
var generateConnectOAuthUrl = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1713
1718
|
emitter,
|
|
1714
1719
|
apiService,
|
|
1715
1720
|
args
|
|
@@ -1721,10 +1726,10 @@ var generateConnectOAuthUrl = (_0) => chunk7B52C2XE_js.__async(null, [_0], funct
|
|
|
1721
1726
|
return { data };
|
|
1722
1727
|
} catch (error) {
|
|
1723
1728
|
emitter.emit("channel-connection.oauth-url.resolved", { args, error });
|
|
1724
|
-
return { error: new
|
|
1729
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to generate connect OAuth URL", error) };
|
|
1725
1730
|
}
|
|
1726
1731
|
});
|
|
1727
|
-
var listChannelConnections = (_0) =>
|
|
1732
|
+
var listChannelConnections = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1728
1733
|
emitter,
|
|
1729
1734
|
apiService,
|
|
1730
1735
|
args
|
|
@@ -1737,10 +1742,10 @@ var listChannelConnections = (_0) => chunk7B52C2XE_js.__async(null, [_0], functi
|
|
|
1737
1742
|
return { data };
|
|
1738
1743
|
} catch (error) {
|
|
1739
1744
|
emitter.emit("channel-connections.list.resolved", { args, error });
|
|
1740
|
-
return { error: new
|
|
1745
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to list channel connections", error) };
|
|
1741
1746
|
}
|
|
1742
1747
|
});
|
|
1743
|
-
var getChannelConnection = (_0) =>
|
|
1748
|
+
var getChannelConnection = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1744
1749
|
emitter,
|
|
1745
1750
|
apiService,
|
|
1746
1751
|
args
|
|
@@ -1752,10 +1757,10 @@ var getChannelConnection = (_0) => chunk7B52C2XE_js.__async(null, [_0], function
|
|
|
1752
1757
|
return { data };
|
|
1753
1758
|
} catch (error) {
|
|
1754
1759
|
emitter.emit("channel-connection.get.resolved", { args, error });
|
|
1755
|
-
return { error: new
|
|
1760
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to get channel connection", error) };
|
|
1756
1761
|
}
|
|
1757
1762
|
});
|
|
1758
|
-
var deleteChannelConnection = (_0) =>
|
|
1763
|
+
var deleteChannelConnection = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1759
1764
|
emitter,
|
|
1760
1765
|
apiService,
|
|
1761
1766
|
args
|
|
@@ -1767,7 +1772,7 @@ var deleteChannelConnection = (_0) => chunk7B52C2XE_js.__async(null, [_0], funct
|
|
|
1767
1772
|
return { data: void 0 };
|
|
1768
1773
|
} catch (error) {
|
|
1769
1774
|
emitter.emit("channel-connection.delete.resolved", { args, error });
|
|
1770
|
-
return { error: new
|
|
1775
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to delete channel connection", error) };
|
|
1771
1776
|
}
|
|
1772
1777
|
});
|
|
1773
1778
|
|
|
@@ -1783,7 +1788,7 @@ var ChannelConnections = class extends BaseModule {
|
|
|
1783
1788
|
* @deprecated Use generateConnectOAuthUrl() instead. For user-level linking use channelEndpoints.generateLinkUserOAuthUrl().
|
|
1784
1789
|
*/
|
|
1785
1790
|
generateOAuthUrl(args) {
|
|
1786
|
-
return
|
|
1791
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1787
1792
|
return this.callWithSession(
|
|
1788
1793
|
() => generateChatOAuthUrl({
|
|
1789
1794
|
emitter: this._emitter,
|
|
@@ -1794,7 +1799,7 @@ var ChannelConnections = class extends BaseModule {
|
|
|
1794
1799
|
});
|
|
1795
1800
|
}
|
|
1796
1801
|
generateConnectOAuthUrl(args) {
|
|
1797
|
-
return
|
|
1802
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1798
1803
|
return this.callWithSession(
|
|
1799
1804
|
() => generateConnectOAuthUrl({
|
|
1800
1805
|
emitter: this._emitter,
|
|
@@ -1805,7 +1810,7 @@ var ChannelConnections = class extends BaseModule {
|
|
|
1805
1810
|
});
|
|
1806
1811
|
}
|
|
1807
1812
|
list() {
|
|
1808
|
-
return
|
|
1813
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* (args = {}) {
|
|
1809
1814
|
return this.callWithSession(
|
|
1810
1815
|
() => listChannelConnections({
|
|
1811
1816
|
emitter: this._emitter,
|
|
@@ -1816,7 +1821,7 @@ var ChannelConnections = class extends BaseModule {
|
|
|
1816
1821
|
});
|
|
1817
1822
|
}
|
|
1818
1823
|
get(args) {
|
|
1819
|
-
return
|
|
1824
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1820
1825
|
return this.callWithSession(
|
|
1821
1826
|
() => getChannelConnection({
|
|
1822
1827
|
emitter: this._emitter,
|
|
@@ -1827,7 +1832,7 @@ var ChannelConnections = class extends BaseModule {
|
|
|
1827
1832
|
});
|
|
1828
1833
|
}
|
|
1829
1834
|
delete(args) {
|
|
1830
|
-
return
|
|
1835
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1831
1836
|
return this.callWithSession(
|
|
1832
1837
|
() => deleteChannelConnection({
|
|
1833
1838
|
emitter: this._emitter,
|
|
@@ -1840,7 +1845,7 @@ var ChannelConnections = class extends BaseModule {
|
|
|
1840
1845
|
};
|
|
1841
1846
|
|
|
1842
1847
|
// src/channel-endpoints/helpers.ts
|
|
1843
|
-
var generateLinkUserOAuthUrl = (_0) =>
|
|
1848
|
+
var generateLinkUserOAuthUrl = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1844
1849
|
emitter,
|
|
1845
1850
|
apiService,
|
|
1846
1851
|
args
|
|
@@ -1852,10 +1857,10 @@ var generateLinkUserOAuthUrl = (_0) => chunk7B52C2XE_js.__async(null, [_0], func
|
|
|
1852
1857
|
return { data };
|
|
1853
1858
|
} catch (error) {
|
|
1854
1859
|
emitter.emit("channel-endpoint.oauth-url.resolved", { args, error });
|
|
1855
|
-
return { error: new
|
|
1860
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to generate link user OAuth URL", error) };
|
|
1856
1861
|
}
|
|
1857
1862
|
});
|
|
1858
|
-
var listChannelEndpoints = (_0) =>
|
|
1863
|
+
var listChannelEndpoints = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1859
1864
|
emitter,
|
|
1860
1865
|
apiService,
|
|
1861
1866
|
args
|
|
@@ -1868,10 +1873,10 @@ var listChannelEndpoints = (_0) => chunk7B52C2XE_js.__async(null, [_0], function
|
|
|
1868
1873
|
return { data };
|
|
1869
1874
|
} catch (error) {
|
|
1870
1875
|
emitter.emit("channel-endpoints.list.resolved", { args, error });
|
|
1871
|
-
return { error: new
|
|
1876
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to list channel endpoints", error) };
|
|
1872
1877
|
}
|
|
1873
1878
|
});
|
|
1874
|
-
var getChannelEndpoint = (_0) =>
|
|
1879
|
+
var getChannelEndpoint = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1875
1880
|
emitter,
|
|
1876
1881
|
apiService,
|
|
1877
1882
|
args
|
|
@@ -1883,10 +1888,10 @@ var getChannelEndpoint = (_0) => chunk7B52C2XE_js.__async(null, [_0], function*
|
|
|
1883
1888
|
return { data };
|
|
1884
1889
|
} catch (error) {
|
|
1885
1890
|
emitter.emit("channel-endpoint.get.resolved", { args, error });
|
|
1886
|
-
return { error: new
|
|
1891
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to get channel endpoint", error) };
|
|
1887
1892
|
}
|
|
1888
1893
|
});
|
|
1889
|
-
var createChannelEndpoint = (_0) =>
|
|
1894
|
+
var createChannelEndpoint = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1890
1895
|
emitter,
|
|
1891
1896
|
apiService,
|
|
1892
1897
|
args
|
|
@@ -1898,10 +1903,10 @@ var createChannelEndpoint = (_0) => chunk7B52C2XE_js.__async(null, [_0], functio
|
|
|
1898
1903
|
return { data };
|
|
1899
1904
|
} catch (error) {
|
|
1900
1905
|
emitter.emit("channel-endpoint.create.resolved", { args, error });
|
|
1901
|
-
return { error: new
|
|
1906
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to create channel endpoint", error) };
|
|
1902
1907
|
}
|
|
1903
1908
|
});
|
|
1904
|
-
var deleteChannelEndpoint = (_0) =>
|
|
1909
|
+
var deleteChannelEndpoint = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1905
1910
|
emitter,
|
|
1906
1911
|
apiService,
|
|
1907
1912
|
args
|
|
@@ -1913,7 +1918,22 @@ var deleteChannelEndpoint = (_0) => chunk7B52C2XE_js.__async(null, [_0], functio
|
|
|
1913
1918
|
return { data: void 0 };
|
|
1914
1919
|
} catch (error) {
|
|
1915
1920
|
emitter.emit("channel-endpoint.delete.resolved", { args, error });
|
|
1916
|
-
return { error: new
|
|
1921
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to delete channel endpoint", error) };
|
|
1922
|
+
}
|
|
1923
|
+
});
|
|
1924
|
+
var linkChannelEndpoint = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
1925
|
+
emitter,
|
|
1926
|
+
apiService,
|
|
1927
|
+
args
|
|
1928
|
+
}) {
|
|
1929
|
+
try {
|
|
1930
|
+
emitter.emit("channel-endpoint.link.pending", { args });
|
|
1931
|
+
const data = yield apiService.linkChannelEndpoint(args);
|
|
1932
|
+
emitter.emit("channel-endpoint.link.resolved", { args, data });
|
|
1933
|
+
return { data };
|
|
1934
|
+
} catch (error) {
|
|
1935
|
+
emitter.emit("channel-endpoint.link.resolved", { args, error });
|
|
1936
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to link channel endpoint", error) };
|
|
1917
1937
|
}
|
|
1918
1938
|
});
|
|
1919
1939
|
|
|
@@ -1926,7 +1946,7 @@ var ChannelEndpoints = class extends BaseModule {
|
|
|
1926
1946
|
super({ inboxServiceInstance, eventEmitterInstance });
|
|
1927
1947
|
}
|
|
1928
1948
|
generateLinkUserOAuthUrl(args) {
|
|
1929
|
-
return
|
|
1949
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1930
1950
|
return this.callWithSession(
|
|
1931
1951
|
() => generateLinkUserOAuthUrl({
|
|
1932
1952
|
emitter: this._emitter,
|
|
@@ -1937,7 +1957,7 @@ var ChannelEndpoints = class extends BaseModule {
|
|
|
1937
1957
|
});
|
|
1938
1958
|
}
|
|
1939
1959
|
list() {
|
|
1940
|
-
return
|
|
1960
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* (args = {}) {
|
|
1941
1961
|
return this.callWithSession(
|
|
1942
1962
|
() => listChannelEndpoints({
|
|
1943
1963
|
emitter: this._emitter,
|
|
@@ -1948,7 +1968,7 @@ var ChannelEndpoints = class extends BaseModule {
|
|
|
1948
1968
|
});
|
|
1949
1969
|
}
|
|
1950
1970
|
get(args) {
|
|
1951
|
-
return
|
|
1971
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1952
1972
|
return this.callWithSession(
|
|
1953
1973
|
() => getChannelEndpoint({
|
|
1954
1974
|
emitter: this._emitter,
|
|
@@ -1959,7 +1979,7 @@ var ChannelEndpoints = class extends BaseModule {
|
|
|
1959
1979
|
});
|
|
1960
1980
|
}
|
|
1961
1981
|
create(args) {
|
|
1962
|
-
return
|
|
1982
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1963
1983
|
return this.callWithSession(
|
|
1964
1984
|
() => createChannelEndpoint({
|
|
1965
1985
|
emitter: this._emitter,
|
|
@@ -1970,7 +1990,7 @@ var ChannelEndpoints = class extends BaseModule {
|
|
|
1970
1990
|
});
|
|
1971
1991
|
}
|
|
1972
1992
|
delete(args) {
|
|
1973
|
-
return
|
|
1993
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
1974
1994
|
return this.callWithSession(
|
|
1975
1995
|
() => deleteChannelEndpoint({
|
|
1976
1996
|
emitter: this._emitter,
|
|
@@ -1980,24 +2000,35 @@ var ChannelEndpoints = class extends BaseModule {
|
|
|
1980
2000
|
);
|
|
1981
2001
|
});
|
|
1982
2002
|
}
|
|
2003
|
+
link(args) {
|
|
2004
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2005
|
+
return this.callWithSession(
|
|
2006
|
+
() => linkChannelEndpoint({
|
|
2007
|
+
emitter: this._emitter,
|
|
2008
|
+
apiService: this._inboxService,
|
|
2009
|
+
args
|
|
2010
|
+
})
|
|
2011
|
+
);
|
|
2012
|
+
});
|
|
2013
|
+
}
|
|
1983
2014
|
};
|
|
1984
2015
|
var _mittEmitter;
|
|
1985
2016
|
var NovuEventEmitter = class {
|
|
1986
2017
|
constructor() {
|
|
1987
|
-
|
|
1988
|
-
|
|
2018
|
+
chunkA6CBLMST_js.__privateAdd(this, _mittEmitter);
|
|
2019
|
+
chunkA6CBLMST_js.__privateSet(this, _mittEmitter, mitt__default.default());
|
|
1989
2020
|
}
|
|
1990
2021
|
on(eventName, listener) {
|
|
1991
|
-
|
|
2022
|
+
chunkA6CBLMST_js.__privateGet(this, _mittEmitter).on(eventName, listener);
|
|
1992
2023
|
return () => {
|
|
1993
2024
|
this.off(eventName, listener);
|
|
1994
2025
|
};
|
|
1995
2026
|
}
|
|
1996
2027
|
off(eventName, listener) {
|
|
1997
|
-
|
|
2028
|
+
chunkA6CBLMST_js.__privateGet(this, _mittEmitter).off(eventName, listener);
|
|
1998
2029
|
}
|
|
1999
2030
|
emit(type, event) {
|
|
2000
|
-
|
|
2031
|
+
chunkA6CBLMST_js.__privateGet(this, _mittEmitter).emit(type, event);
|
|
2001
2032
|
}
|
|
2002
2033
|
};
|
|
2003
2034
|
_mittEmitter = new WeakMap();
|
|
@@ -2059,12 +2090,16 @@ var updateEvents = [
|
|
|
2059
2090
|
"notification.read.resolved",
|
|
2060
2091
|
"notification.unread.pending",
|
|
2061
2092
|
"notification.unread.resolved",
|
|
2093
|
+
"notification.seen.pending",
|
|
2094
|
+
"notification.seen.resolved",
|
|
2062
2095
|
"notification.complete_action.pending",
|
|
2063
2096
|
"notification.complete_action.resolved",
|
|
2064
2097
|
"notification.revert_action.pending",
|
|
2065
2098
|
"notification.revert_action.resolved",
|
|
2066
2099
|
"notifications.read_all.pending",
|
|
2067
|
-
"notifications.read_all.resolved"
|
|
2100
|
+
"notifications.read_all.resolved",
|
|
2101
|
+
"notifications.seen_all.pending",
|
|
2102
|
+
"notifications.seen_all.resolved"
|
|
2068
2103
|
];
|
|
2069
2104
|
var removeEvents = [
|
|
2070
2105
|
"notification.archive.pending",
|
|
@@ -2076,31 +2111,48 @@ var removeEvents = [
|
|
|
2076
2111
|
"notifications.archive_all_read.pending",
|
|
2077
2112
|
"notifications.delete_all.pending"
|
|
2078
2113
|
];
|
|
2079
|
-
var _emitter4, _inboxService4, _cache5;
|
|
2114
|
+
var _emitter4, _inboxService4, _cache5, _toNotificationInstance, _normalizeNotifications;
|
|
2080
2115
|
var NotificationsCache = class {
|
|
2081
2116
|
constructor({ emitter, inboxService }) {
|
|
2082
|
-
|
|
2083
|
-
|
|
2117
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter4);
|
|
2118
|
+
chunkA6CBLMST_js.__privateAdd(this, _inboxService4);
|
|
2084
2119
|
/**
|
|
2085
2120
|
* The key is the stringified notifications filter, the values are the paginated notifications.
|
|
2086
2121
|
*/
|
|
2087
|
-
|
|
2088
|
-
this
|
|
2089
|
-
|
|
2122
|
+
chunkA6CBLMST_js.__privateAdd(this, _cache5);
|
|
2123
|
+
chunkA6CBLMST_js.__privateAdd(this, _toNotificationInstance, (notification) => {
|
|
2124
|
+
return chunkTLQQB5Y7_js.ensureNotificationInstance({
|
|
2125
|
+
notification,
|
|
2126
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter4),
|
|
2127
|
+
inboxService: chunkA6CBLMST_js.__privateGet(this, _inboxService4)
|
|
2128
|
+
});
|
|
2129
|
+
});
|
|
2130
|
+
chunkA6CBLMST_js.__privateAdd(this, _normalizeNotifications, (notifications) => {
|
|
2131
|
+
return notifications.map((notification) => chunkA6CBLMST_js.__privateGet(this, _toNotificationInstance).call(this, notification));
|
|
2132
|
+
});
|
|
2133
|
+
this.syncNotificationInBucket = (key, data) => {
|
|
2134
|
+
const notification = chunkA6CBLMST_js.__privateGet(this, _toNotificationInstance).call(this, data);
|
|
2135
|
+
const notificationsResponse = chunkA6CBLMST_js.__privateGet(this, _cache5).get(key);
|
|
2090
2136
|
if (!notificationsResponse) {
|
|
2091
2137
|
return false;
|
|
2092
2138
|
}
|
|
2093
|
-
const
|
|
2094
|
-
|
|
2095
|
-
|
|
2139
|
+
const bucketFilter = getFilter(key);
|
|
2140
|
+
const matchesFilter = checkBasicFilters(notification, bucketFilter) && checkNotificationTagFilter(notification.tags, bucketFilter.tags);
|
|
2141
|
+
const index = notificationsResponse.notifications.findIndex((el) => el.id === notification.id);
|
|
2142
|
+
const existsInBucket = index !== -1;
|
|
2143
|
+
if (matchesFilter && existsInBucket) {
|
|
2144
|
+
const updatedNotifications = [...notificationsResponse.notifications];
|
|
2145
|
+
updatedNotifications[index] = notification;
|
|
2146
|
+
chunkA6CBLMST_js.__privateGet(this, _cache5).set(key, chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, notificationsResponse), { notifications: updatedNotifications }));
|
|
2147
|
+
return true;
|
|
2096
2148
|
}
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
return
|
|
2149
|
+
if (!matchesFilter && existsInBucket) {
|
|
2150
|
+
return this.removeNotification(key, notification);
|
|
2151
|
+
}
|
|
2152
|
+
return false;
|
|
2101
2153
|
};
|
|
2102
2154
|
this.removeNotification = (key, data) => {
|
|
2103
|
-
const notificationsResponse =
|
|
2155
|
+
const notificationsResponse = chunkA6CBLMST_js.__privateGet(this, _cache5).get(key);
|
|
2104
2156
|
if (!notificationsResponse) {
|
|
2105
2157
|
return false;
|
|
2106
2158
|
}
|
|
@@ -2110,7 +2162,7 @@ var NotificationsCache = class {
|
|
|
2110
2162
|
}
|
|
2111
2163
|
const newNotifications = [...notificationsResponse.notifications];
|
|
2112
2164
|
newNotifications.splice(index, 1);
|
|
2113
|
-
|
|
2165
|
+
chunkA6CBLMST_js.__privateGet(this, _cache5).set(key, chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, notificationsResponse), {
|
|
2114
2166
|
notifications: newNotifications
|
|
2115
2167
|
}));
|
|
2116
2168
|
return true;
|
|
@@ -2120,17 +2172,17 @@ var NotificationsCache = class {
|
|
|
2120
2172
|
let notifications = [];
|
|
2121
2173
|
if (data !== void 0 && data !== null) {
|
|
2122
2174
|
if (Array.isArray(data) && data.every((item) => typeof item === "object" && "id" in item)) {
|
|
2123
|
-
notifications = data;
|
|
2175
|
+
notifications = chunkA6CBLMST_js.__privateGet(this, _normalizeNotifications).call(this, data);
|
|
2124
2176
|
} else if (typeof data === "object" && "id" in data) {
|
|
2125
|
-
notifications = [data];
|
|
2177
|
+
notifications = [chunkA6CBLMST_js.__privateGet(this, _toNotificationInstance).call(this, data)];
|
|
2126
2178
|
}
|
|
2127
2179
|
} else if (remove && args) {
|
|
2128
2180
|
if ("notification" in args && args.notification) {
|
|
2129
|
-
notifications = [args.notification];
|
|
2181
|
+
notifications = [chunkA6CBLMST_js.__privateGet(this, _toNotificationInstance).call(this, args.notification)];
|
|
2130
2182
|
} else if ("notificationId" in args && args.notificationId) {
|
|
2131
2183
|
const foundNotifications = [];
|
|
2132
|
-
|
|
2133
|
-
const cachedResponse =
|
|
2184
|
+
chunkA6CBLMST_js.__privateGet(this, _cache5).keys().forEach((key) => {
|
|
2185
|
+
const cachedResponse = chunkA6CBLMST_js.__privateGet(this, _cache5).get(key);
|
|
2134
2186
|
if (cachedResponse) {
|
|
2135
2187
|
const found = cachedResponse.notifications.find((n) => n.id === args.notificationId);
|
|
2136
2188
|
if (found) {
|
|
@@ -2145,13 +2197,13 @@ var NotificationsCache = class {
|
|
|
2145
2197
|
return;
|
|
2146
2198
|
}
|
|
2147
2199
|
const uniqueFilterKeys = /* @__PURE__ */ new Set();
|
|
2148
|
-
|
|
2200
|
+
chunkA6CBLMST_js.__privateGet(this, _cache5).keys().forEach((key) => {
|
|
2149
2201
|
notifications.forEach((notification) => {
|
|
2150
2202
|
let isNotificationFound = false;
|
|
2151
2203
|
if (remove) {
|
|
2152
2204
|
isNotificationFound = this.removeNotification(key, notification);
|
|
2153
2205
|
} else {
|
|
2154
|
-
isNotificationFound = this.
|
|
2206
|
+
isNotificationFound = this.syncNotificationInBucket(key, notification);
|
|
2155
2207
|
}
|
|
2156
2208
|
if (isNotificationFound) {
|
|
2157
2209
|
uniqueFilterKeys.add(getFilterKey(getFilter(key)));
|
|
@@ -2160,69 +2212,72 @@ var NotificationsCache = class {
|
|
|
2160
2212
|
});
|
|
2161
2213
|
uniqueFilterKeys.forEach((key) => {
|
|
2162
2214
|
const notificationsResponse = this.getAggregated(getFilter(key));
|
|
2163
|
-
|
|
2215
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter4).emit("notifications.list.updated", {
|
|
2164
2216
|
data: notificationsResponse
|
|
2165
2217
|
});
|
|
2166
2218
|
});
|
|
2167
2219
|
};
|
|
2168
|
-
|
|
2169
|
-
|
|
2220
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter4, emitter);
|
|
2221
|
+
chunkA6CBLMST_js.__privateSet(this, _inboxService4, inboxService);
|
|
2170
2222
|
updateEvents.forEach((event) => {
|
|
2171
|
-
|
|
2223
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter4).on(event, this.handleNotificationEvent());
|
|
2172
2224
|
});
|
|
2173
2225
|
removeEvents.forEach((event) => {
|
|
2174
|
-
|
|
2226
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter4).on(event, this.handleNotificationEvent({ remove: true }));
|
|
2175
2227
|
});
|
|
2176
|
-
|
|
2228
|
+
chunkA6CBLMST_js.__privateSet(this, _cache5, new InMemoryCache());
|
|
2177
2229
|
}
|
|
2178
2230
|
getAggregated(filter) {
|
|
2179
|
-
const cacheKeys =
|
|
2231
|
+
const cacheKeys = chunkA6CBLMST_js.__privateGet(this, _cache5).keys().filter((key) => {
|
|
2180
2232
|
const parsedFilter = getFilter(key);
|
|
2181
2233
|
return isSameFilter(parsedFilter, filter);
|
|
2182
2234
|
});
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
}
|
|
2194
|
-
|
|
2195
|
-
|
|
2235
|
+
const uniqueNotifications = /* @__PURE__ */ new Map();
|
|
2236
|
+
let hasMore = false;
|
|
2237
|
+
for (const key of cacheKeys) {
|
|
2238
|
+
const cachedResponse = chunkA6CBLMST_js.__privateGet(this, _cache5).get(key);
|
|
2239
|
+
if (!cachedResponse) {
|
|
2240
|
+
continue;
|
|
2241
|
+
}
|
|
2242
|
+
hasMore = cachedResponse.hasMore;
|
|
2243
|
+
for (const notification of cachedResponse.notifications) {
|
|
2244
|
+
uniqueNotifications.set(notification.id, notification);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
return {
|
|
2248
|
+
hasMore,
|
|
2249
|
+
filter,
|
|
2250
|
+
notifications: Array.from(uniqueNotifications.values())
|
|
2251
|
+
};
|
|
2196
2252
|
}
|
|
2197
2253
|
get(args) {
|
|
2198
|
-
return
|
|
2254
|
+
return chunkA6CBLMST_js.__privateGet(this, _cache5).get(getCacheKey(args));
|
|
2199
2255
|
}
|
|
2200
2256
|
has(args) {
|
|
2201
|
-
return
|
|
2257
|
+
return chunkA6CBLMST_js.__privateGet(this, _cache5).get(getCacheKey(args)) !== void 0;
|
|
2202
2258
|
}
|
|
2203
2259
|
set(args, data) {
|
|
2204
|
-
|
|
2260
|
+
chunkA6CBLMST_js.__privateGet(this, _cache5).set(getCacheKey(args), chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, data), {
|
|
2261
|
+
notifications: chunkA6CBLMST_js.__privateGet(this, _normalizeNotifications).call(this, data.notifications)
|
|
2262
|
+
}));
|
|
2205
2263
|
}
|
|
2206
2264
|
unshift(args, notification) {
|
|
2207
2265
|
const cacheKey = getCacheKey(args);
|
|
2208
|
-
const cachedData =
|
|
2266
|
+
const cachedData = chunkA6CBLMST_js.__privateGet(this, _cache5).get(cacheKey) || {
|
|
2209
2267
|
hasMore: false,
|
|
2210
2268
|
filter: getFilter(cacheKey),
|
|
2211
2269
|
notifications: []
|
|
2212
2270
|
};
|
|
2213
|
-
const notificationInstance =
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
});
|
|
2218
|
-
this.update(args, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, cachedData), {
|
|
2219
|
-
notifications: [notificationInstance, ...cachedData.notifications]
|
|
2271
|
+
const notificationInstance = chunkA6CBLMST_js.__privateGet(this, _toNotificationInstance).call(this, chunkA6CBLMST_js.__spreadValues({}, notification));
|
|
2272
|
+
const dedupedNotifications = cachedData.notifications.filter((n) => n.id !== notification.id);
|
|
2273
|
+
this.update(args, chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, cachedData), {
|
|
2274
|
+
notifications: [notificationInstance, ...dedupedNotifications]
|
|
2220
2275
|
}));
|
|
2221
2276
|
}
|
|
2222
2277
|
update(args, data) {
|
|
2223
2278
|
this.set(args, data);
|
|
2224
2279
|
const notificationsResponse = this.getAggregated(getFilter(getCacheKey(args)));
|
|
2225
|
-
|
|
2280
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter4).emit("notifications.list.updated", {
|
|
2226
2281
|
data: notificationsResponse
|
|
2227
2282
|
});
|
|
2228
2283
|
}
|
|
@@ -2250,12 +2305,12 @@ var NotificationsCache = class {
|
|
|
2250
2305
|
read: read2,
|
|
2251
2306
|
data
|
|
2252
2307
|
}) {
|
|
2253
|
-
const keys =
|
|
2308
|
+
const keys = chunkA6CBLMST_js.__privateGet(this, _cache5).keys();
|
|
2254
2309
|
const uniqueNotifications = /* @__PURE__ */ new Map();
|
|
2255
2310
|
keys.forEach((key) => {
|
|
2256
2311
|
const filter = getFilter(key);
|
|
2257
2312
|
if (areTagsEqual(tags, filter.tags) && areDataEqual(data, filter.data)) {
|
|
2258
|
-
const value =
|
|
2313
|
+
const value = chunkA6CBLMST_js.__privateGet(this, _cache5).get(key);
|
|
2259
2314
|
if (!value) {
|
|
2260
2315
|
return;
|
|
2261
2316
|
}
|
|
@@ -2267,20 +2322,22 @@ var NotificationsCache = class {
|
|
|
2267
2322
|
return Array.from(uniqueNotifications.values());
|
|
2268
2323
|
}
|
|
2269
2324
|
clear(filter) {
|
|
2270
|
-
const keys =
|
|
2325
|
+
const keys = chunkA6CBLMST_js.__privateGet(this, _cache5).keys();
|
|
2271
2326
|
keys.forEach((key) => {
|
|
2272
2327
|
if (isSameFilter(getFilter(key), filter)) {
|
|
2273
|
-
|
|
2328
|
+
chunkA6CBLMST_js.__privateGet(this, _cache5).remove(key);
|
|
2274
2329
|
}
|
|
2275
2330
|
});
|
|
2276
2331
|
}
|
|
2277
2332
|
clearAll() {
|
|
2278
|
-
|
|
2333
|
+
chunkA6CBLMST_js.__privateGet(this, _cache5).clear();
|
|
2279
2334
|
}
|
|
2280
2335
|
};
|
|
2281
2336
|
_emitter4 = new WeakMap();
|
|
2282
2337
|
_inboxService4 = new WeakMap();
|
|
2283
2338
|
_cache5 = new WeakMap();
|
|
2339
|
+
_toNotificationInstance = new WeakMap();
|
|
2340
|
+
_normalizeNotifications = new WeakMap();
|
|
2284
2341
|
|
|
2285
2342
|
// src/notifications/notifications.ts
|
|
2286
2343
|
var _useCache5;
|
|
@@ -2294,30 +2351,30 @@ var Notifications = class extends BaseModule {
|
|
|
2294
2351
|
eventEmitterInstance,
|
|
2295
2352
|
inboxServiceInstance
|
|
2296
2353
|
});
|
|
2297
|
-
|
|
2354
|
+
chunkA6CBLMST_js.__privateAdd(this, _useCache5);
|
|
2298
2355
|
this.cache = new NotificationsCache({
|
|
2299
2356
|
emitter: eventEmitterInstance,
|
|
2300
2357
|
inboxService: inboxServiceInstance
|
|
2301
2358
|
});
|
|
2302
|
-
|
|
2359
|
+
chunkA6CBLMST_js.__privateSet(this, _useCache5, useCache);
|
|
2303
2360
|
}
|
|
2304
2361
|
list() {
|
|
2305
|
-
return
|
|
2306
|
-
var _b = _a, { limit = 10 } = _b, restOptions =
|
|
2307
|
-
return this.callWithSession(() =>
|
|
2308
|
-
const args =
|
|
2362
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* (_a = {}) {
|
|
2363
|
+
var _b = _a, { limit = 10 } = _b, restOptions = chunkA6CBLMST_js.__objRest(_b, ["limit"]);
|
|
2364
|
+
return this.callWithSession(() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2365
|
+
const args = chunkA6CBLMST_js.__spreadValues({ limit }, restOptions);
|
|
2309
2366
|
try {
|
|
2310
|
-
const shouldUseCache = "useCache" in args ? args.useCache :
|
|
2367
|
+
const shouldUseCache = "useCache" in args ? args.useCache : chunkA6CBLMST_js.__privateGet(this, _useCache5);
|
|
2311
2368
|
let data = shouldUseCache ? this.cache.getAll(args) : void 0;
|
|
2312
2369
|
this._emitter.emit("notifications.list.pending", { args, data });
|
|
2313
2370
|
if (!data) {
|
|
2314
|
-
const response = yield this._inboxService.fetchNotifications(
|
|
2371
|
+
const response = yield this._inboxService.fetchNotifications(chunkA6CBLMST_js.__spreadValues({
|
|
2315
2372
|
limit
|
|
2316
2373
|
}, restOptions));
|
|
2317
2374
|
data = {
|
|
2318
2375
|
hasMore: response.hasMore,
|
|
2319
2376
|
filter: response.filter,
|
|
2320
|
-
notifications: response.data.map((el) => new
|
|
2377
|
+
notifications: response.data.map((el) => new chunkTLQQB5Y7_js.Notification(el, this._emitter, this._inboxService))
|
|
2321
2378
|
};
|
|
2322
2379
|
if (shouldUseCache) {
|
|
2323
2380
|
this.cache.set(args, data);
|
|
@@ -2328,15 +2385,15 @@ var Notifications = class extends BaseModule {
|
|
|
2328
2385
|
return { data };
|
|
2329
2386
|
} catch (error) {
|
|
2330
2387
|
this._emitter.emit("notifications.list.resolved", { args, error });
|
|
2331
|
-
return { error: new
|
|
2388
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to fetch notifications", error) };
|
|
2332
2389
|
}
|
|
2333
2390
|
}));
|
|
2334
2391
|
});
|
|
2335
2392
|
}
|
|
2336
2393
|
count(args) {
|
|
2337
|
-
return
|
|
2338
|
-
return this.callWithSession(() =>
|
|
2339
|
-
const filters = args && "filters" in args ? args.filters : [
|
|
2394
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2395
|
+
return this.callWithSession(() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2396
|
+
const filters = args && "filters" in args ? args.filters : [chunkA6CBLMST_js.__spreadValues({}, args)];
|
|
2340
2397
|
try {
|
|
2341
2398
|
this._emitter.emit("notifications.count.pending", { args });
|
|
2342
2399
|
const response = yield this._inboxService.count({
|
|
@@ -2350,16 +2407,16 @@ var Notifications = class extends BaseModule {
|
|
|
2350
2407
|
return { data };
|
|
2351
2408
|
} catch (error) {
|
|
2352
2409
|
this._emitter.emit("notifications.count.resolved", { args, error });
|
|
2353
|
-
return { error: new
|
|
2410
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to count notifications", error) };
|
|
2354
2411
|
}
|
|
2355
2412
|
}));
|
|
2356
2413
|
});
|
|
2357
2414
|
}
|
|
2358
2415
|
read(args) {
|
|
2359
|
-
return
|
|
2416
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2360
2417
|
return this.callWithSession(
|
|
2361
|
-
() =>
|
|
2362
|
-
return
|
|
2418
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2419
|
+
return chunkTLQQB5Y7_js.read({
|
|
2363
2420
|
emitter: this._emitter,
|
|
2364
2421
|
apiService: this._inboxService,
|
|
2365
2422
|
args
|
|
@@ -2369,10 +2426,10 @@ var Notifications = class extends BaseModule {
|
|
|
2369
2426
|
});
|
|
2370
2427
|
}
|
|
2371
2428
|
unread(args) {
|
|
2372
|
-
return
|
|
2429
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2373
2430
|
return this.callWithSession(
|
|
2374
|
-
() =>
|
|
2375
|
-
return
|
|
2431
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2432
|
+
return chunkTLQQB5Y7_js.unread({
|
|
2376
2433
|
emitter: this._emitter,
|
|
2377
2434
|
apiService: this._inboxService,
|
|
2378
2435
|
args
|
|
@@ -2382,10 +2439,10 @@ var Notifications = class extends BaseModule {
|
|
|
2382
2439
|
});
|
|
2383
2440
|
}
|
|
2384
2441
|
seen(args) {
|
|
2385
|
-
return
|
|
2442
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2386
2443
|
return this.callWithSession(
|
|
2387
|
-
() =>
|
|
2388
|
-
return
|
|
2444
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2445
|
+
return chunkTLQQB5Y7_js.seen({
|
|
2389
2446
|
emitter: this._emitter,
|
|
2390
2447
|
apiService: this._inboxService,
|
|
2391
2448
|
args
|
|
@@ -2395,10 +2452,10 @@ var Notifications = class extends BaseModule {
|
|
|
2395
2452
|
});
|
|
2396
2453
|
}
|
|
2397
2454
|
archive(args) {
|
|
2398
|
-
return
|
|
2455
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2399
2456
|
return this.callWithSession(
|
|
2400
|
-
() =>
|
|
2401
|
-
return
|
|
2457
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2458
|
+
return chunkTLQQB5Y7_js.archive({
|
|
2402
2459
|
emitter: this._emitter,
|
|
2403
2460
|
apiService: this._inboxService,
|
|
2404
2461
|
args
|
|
@@ -2408,10 +2465,10 @@ var Notifications = class extends BaseModule {
|
|
|
2408
2465
|
});
|
|
2409
2466
|
}
|
|
2410
2467
|
unarchive(args) {
|
|
2411
|
-
return
|
|
2468
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2412
2469
|
return this.callWithSession(
|
|
2413
|
-
() =>
|
|
2414
|
-
return
|
|
2470
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2471
|
+
return chunkTLQQB5Y7_js.unarchive({
|
|
2415
2472
|
emitter: this._emitter,
|
|
2416
2473
|
apiService: this._inboxService,
|
|
2417
2474
|
args
|
|
@@ -2421,10 +2478,10 @@ var Notifications = class extends BaseModule {
|
|
|
2421
2478
|
});
|
|
2422
2479
|
}
|
|
2423
2480
|
delete(args) {
|
|
2424
|
-
return
|
|
2481
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2425
2482
|
return this.callWithSession(
|
|
2426
|
-
() =>
|
|
2427
|
-
return
|
|
2483
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2484
|
+
return chunkTLQQB5Y7_js.deleteNotification({
|
|
2428
2485
|
emitter: this._emitter,
|
|
2429
2486
|
apiService: this._inboxService,
|
|
2430
2487
|
args
|
|
@@ -2434,10 +2491,10 @@ var Notifications = class extends BaseModule {
|
|
|
2434
2491
|
});
|
|
2435
2492
|
}
|
|
2436
2493
|
snooze(args) {
|
|
2437
|
-
return
|
|
2494
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2438
2495
|
return this.callWithSession(
|
|
2439
|
-
() =>
|
|
2440
|
-
return
|
|
2496
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2497
|
+
return chunkTLQQB5Y7_js.snooze({
|
|
2441
2498
|
emitter: this._emitter,
|
|
2442
2499
|
apiService: this._inboxService,
|
|
2443
2500
|
args
|
|
@@ -2447,10 +2504,10 @@ var Notifications = class extends BaseModule {
|
|
|
2447
2504
|
});
|
|
2448
2505
|
}
|
|
2449
2506
|
unsnooze(args) {
|
|
2450
|
-
return
|
|
2507
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2451
2508
|
return this.callWithSession(
|
|
2452
|
-
() =>
|
|
2453
|
-
return
|
|
2509
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2510
|
+
return chunkTLQQB5Y7_js.unsnooze({
|
|
2454
2511
|
emitter: this._emitter,
|
|
2455
2512
|
apiService: this._inboxService,
|
|
2456
2513
|
args
|
|
@@ -2460,10 +2517,10 @@ var Notifications = class extends BaseModule {
|
|
|
2460
2517
|
});
|
|
2461
2518
|
}
|
|
2462
2519
|
completePrimary(args) {
|
|
2463
|
-
return
|
|
2520
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2464
2521
|
return this.callWithSession(
|
|
2465
|
-
() =>
|
|
2466
|
-
return
|
|
2522
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2523
|
+
return chunkTLQQB5Y7_js.completeAction({
|
|
2467
2524
|
emitter: this._emitter,
|
|
2468
2525
|
apiService: this._inboxService,
|
|
2469
2526
|
args,
|
|
@@ -2474,10 +2531,10 @@ var Notifications = class extends BaseModule {
|
|
|
2474
2531
|
});
|
|
2475
2532
|
}
|
|
2476
2533
|
completeSecondary(args) {
|
|
2477
|
-
return
|
|
2534
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2478
2535
|
return this.callWithSession(
|
|
2479
|
-
() =>
|
|
2480
|
-
return
|
|
2536
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2537
|
+
return chunkTLQQB5Y7_js.completeAction({
|
|
2481
2538
|
emitter: this._emitter,
|
|
2482
2539
|
apiService: this._inboxService,
|
|
2483
2540
|
args,
|
|
@@ -2488,10 +2545,10 @@ var Notifications = class extends BaseModule {
|
|
|
2488
2545
|
});
|
|
2489
2546
|
}
|
|
2490
2547
|
revertPrimary(args) {
|
|
2491
|
-
return
|
|
2548
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2492
2549
|
return this.callWithSession(
|
|
2493
|
-
() =>
|
|
2494
|
-
return
|
|
2550
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2551
|
+
return chunkTLQQB5Y7_js.revertAction({
|
|
2495
2552
|
emitter: this._emitter,
|
|
2496
2553
|
apiService: this._inboxService,
|
|
2497
2554
|
args,
|
|
@@ -2502,10 +2559,10 @@ var Notifications = class extends BaseModule {
|
|
|
2502
2559
|
});
|
|
2503
2560
|
}
|
|
2504
2561
|
revertSecondary(args) {
|
|
2505
|
-
return
|
|
2562
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2506
2563
|
return this.callWithSession(
|
|
2507
|
-
() =>
|
|
2508
|
-
return
|
|
2564
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2565
|
+
return chunkTLQQB5Y7_js.revertAction({
|
|
2509
2566
|
emitter: this._emitter,
|
|
2510
2567
|
apiService: this._inboxService,
|
|
2511
2568
|
args,
|
|
@@ -2516,13 +2573,13 @@ var Notifications = class extends BaseModule {
|
|
|
2516
2573
|
});
|
|
2517
2574
|
}
|
|
2518
2575
|
readAll() {
|
|
2519
|
-
return
|
|
2576
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* ({
|
|
2520
2577
|
tags,
|
|
2521
2578
|
data
|
|
2522
2579
|
} = {}) {
|
|
2523
2580
|
return this.callWithSession(
|
|
2524
|
-
() =>
|
|
2525
|
-
return
|
|
2581
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2582
|
+
return chunkTLQQB5Y7_js.readAll({
|
|
2526
2583
|
emitter: this._emitter,
|
|
2527
2584
|
inboxService: this._inboxService,
|
|
2528
2585
|
notificationsCache: this.cache,
|
|
@@ -2534,17 +2591,17 @@ var Notifications = class extends BaseModule {
|
|
|
2534
2591
|
});
|
|
2535
2592
|
}
|
|
2536
2593
|
seenAll() {
|
|
2537
|
-
return
|
|
2538
|
-
return this.callWithSession(() =>
|
|
2594
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* (args = {}) {
|
|
2595
|
+
return this.callWithSession(() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2539
2596
|
if ("notificationIds" in args) {
|
|
2540
|
-
return
|
|
2597
|
+
return chunkTLQQB5Y7_js.seenAll({
|
|
2541
2598
|
emitter: this._emitter,
|
|
2542
2599
|
inboxService: this._inboxService,
|
|
2543
2600
|
notificationsCache: this.cache,
|
|
2544
2601
|
notificationIds: args.notificationIds
|
|
2545
2602
|
});
|
|
2546
2603
|
} else {
|
|
2547
|
-
return
|
|
2604
|
+
return chunkTLQQB5Y7_js.seenAll({
|
|
2548
2605
|
emitter: this._emitter,
|
|
2549
2606
|
inboxService: this._inboxService,
|
|
2550
2607
|
notificationsCache: this.cache,
|
|
@@ -2556,13 +2613,13 @@ var Notifications = class extends BaseModule {
|
|
|
2556
2613
|
});
|
|
2557
2614
|
}
|
|
2558
2615
|
archiveAll() {
|
|
2559
|
-
return
|
|
2616
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* ({
|
|
2560
2617
|
tags,
|
|
2561
2618
|
data
|
|
2562
2619
|
} = {}) {
|
|
2563
2620
|
return this.callWithSession(
|
|
2564
|
-
() =>
|
|
2565
|
-
return
|
|
2621
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2622
|
+
return chunkTLQQB5Y7_js.archiveAll({
|
|
2566
2623
|
emitter: this._emitter,
|
|
2567
2624
|
inboxService: this._inboxService,
|
|
2568
2625
|
notificationsCache: this.cache,
|
|
@@ -2574,13 +2631,13 @@ var Notifications = class extends BaseModule {
|
|
|
2574
2631
|
});
|
|
2575
2632
|
}
|
|
2576
2633
|
archiveAllRead() {
|
|
2577
|
-
return
|
|
2634
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* ({
|
|
2578
2635
|
tags,
|
|
2579
2636
|
data
|
|
2580
2637
|
} = {}) {
|
|
2581
2638
|
return this.callWithSession(
|
|
2582
|
-
() =>
|
|
2583
|
-
return
|
|
2639
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2640
|
+
return chunkTLQQB5Y7_js.archiveAllRead({
|
|
2584
2641
|
emitter: this._emitter,
|
|
2585
2642
|
inboxService: this._inboxService,
|
|
2586
2643
|
notificationsCache: this.cache,
|
|
@@ -2592,13 +2649,13 @@ var Notifications = class extends BaseModule {
|
|
|
2592
2649
|
});
|
|
2593
2650
|
}
|
|
2594
2651
|
deleteAll() {
|
|
2595
|
-
return
|
|
2652
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* ({
|
|
2596
2653
|
tags,
|
|
2597
2654
|
data
|
|
2598
2655
|
} = {}) {
|
|
2599
2656
|
return this.callWithSession(
|
|
2600
|
-
() =>
|
|
2601
|
-
return
|
|
2657
|
+
() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2658
|
+
return chunkTLQQB5Y7_js.deleteAll({
|
|
2602
2659
|
emitter: this._emitter,
|
|
2603
2660
|
inboxService: this._inboxService,
|
|
2604
2661
|
notificationsCache: this.cache,
|
|
@@ -2617,7 +2674,7 @@ var Notifications = class extends BaseModule {
|
|
|
2617
2674
|
this.cache.clearAll();
|
|
2618
2675
|
}
|
|
2619
2676
|
triggerHelloWorldEvent() {
|
|
2620
|
-
return
|
|
2677
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2621
2678
|
return this._inboxService.triggerHelloWorldEvent();
|
|
2622
2679
|
});
|
|
2623
2680
|
}
|
|
@@ -2633,30 +2690,30 @@ var Schedule = class {
|
|
|
2633
2690
|
cache,
|
|
2634
2691
|
useCache
|
|
2635
2692
|
}) {
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2693
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter5);
|
|
2694
|
+
chunkA6CBLMST_js.__privateAdd(this, _apiService);
|
|
2695
|
+
chunkA6CBLMST_js.__privateAdd(this, _cache6);
|
|
2696
|
+
chunkA6CBLMST_js.__privateAdd(this, _useCache6);
|
|
2697
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter5, emitterInstance);
|
|
2698
|
+
chunkA6CBLMST_js.__privateSet(this, _apiService, inboxServiceInstance);
|
|
2699
|
+
chunkA6CBLMST_js.__privateSet(this, _cache6, cache);
|
|
2700
|
+
chunkA6CBLMST_js.__privateSet(this, _useCache6, useCache);
|
|
2644
2701
|
this.isEnabled = schedule.isEnabled;
|
|
2645
2702
|
this.weeklySchedule = schedule.weeklySchedule;
|
|
2646
2703
|
}
|
|
2647
2704
|
update(args) {
|
|
2648
|
-
return
|
|
2705
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2649
2706
|
var _a;
|
|
2650
2707
|
const hasWeeklySchedule = !!args.weeklySchedule || !!this.weeklySchedule;
|
|
2651
2708
|
return updateSchedule({
|
|
2652
|
-
emitter:
|
|
2653
|
-
apiService:
|
|
2654
|
-
cache:
|
|
2655
|
-
useCache:
|
|
2656
|
-
args:
|
|
2709
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter5),
|
|
2710
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _apiService),
|
|
2711
|
+
cache: chunkA6CBLMST_js.__privateGet(this, _cache6),
|
|
2712
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache6),
|
|
2713
|
+
args: chunkA6CBLMST_js.__spreadValues({
|
|
2657
2714
|
isEnabled: (_a = args.isEnabled) != null ? _a : this.isEnabled
|
|
2658
2715
|
}, hasWeeklySchedule && {
|
|
2659
|
-
weeklySchedule:
|
|
2716
|
+
weeklySchedule: chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({}, this.weeklySchedule), args.weeklySchedule)
|
|
2660
2717
|
})
|
|
2661
2718
|
});
|
|
2662
2719
|
});
|
|
@@ -2677,22 +2734,22 @@ var Preference = class {
|
|
|
2677
2734
|
scheduleCache,
|
|
2678
2735
|
useCache
|
|
2679
2736
|
}) {
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2737
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter6);
|
|
2738
|
+
chunkA6CBLMST_js.__privateAdd(this, _apiService2);
|
|
2739
|
+
chunkA6CBLMST_js.__privateAdd(this, _cache7);
|
|
2740
|
+
chunkA6CBLMST_js.__privateAdd(this, _scheduleCache);
|
|
2741
|
+
chunkA6CBLMST_js.__privateAdd(this, _useCache7);
|
|
2742
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter6, emitterInstance);
|
|
2743
|
+
chunkA6CBLMST_js.__privateSet(this, _apiService2, inboxServiceInstance);
|
|
2744
|
+
chunkA6CBLMST_js.__privateSet(this, _cache7, cache);
|
|
2745
|
+
chunkA6CBLMST_js.__privateSet(this, _scheduleCache, scheduleCache);
|
|
2746
|
+
chunkA6CBLMST_js.__privateSet(this, _useCache7, useCache);
|
|
2690
2747
|
this.level = preference.level;
|
|
2691
2748
|
this.enabled = preference.enabled;
|
|
2692
2749
|
this.channels = preference.channels;
|
|
2693
2750
|
this.workflow = preference.workflow;
|
|
2694
2751
|
this.schedule = new Schedule(
|
|
2695
|
-
|
|
2752
|
+
chunkA6CBLMST_js.__spreadValues({}, preference.schedule),
|
|
2696
2753
|
{ emitterInstance, inboxServiceInstance, cache: scheduleCache, useCache }
|
|
2697
2754
|
);
|
|
2698
2755
|
}
|
|
@@ -2702,11 +2759,11 @@ var Preference = class {
|
|
|
2702
2759
|
}) {
|
|
2703
2760
|
var _a;
|
|
2704
2761
|
return updatePreference({
|
|
2705
|
-
emitter:
|
|
2706
|
-
apiService:
|
|
2707
|
-
cache:
|
|
2708
|
-
scheduleCache:
|
|
2709
|
-
useCache:
|
|
2762
|
+
emitter: chunkA6CBLMST_js.__privateGet(this, _emitter6),
|
|
2763
|
+
apiService: chunkA6CBLMST_js.__privateGet(this, _apiService2),
|
|
2764
|
+
cache: chunkA6CBLMST_js.__privateGet(this, _cache7),
|
|
2765
|
+
scheduleCache: chunkA6CBLMST_js.__privateGet(this, _scheduleCache),
|
|
2766
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache7),
|
|
2710
2767
|
args: {
|
|
2711
2768
|
workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
|
|
2712
2769
|
channels: channels || channelPreferences,
|
|
@@ -2722,7 +2779,7 @@ _scheduleCache = new WeakMap();
|
|
|
2722
2779
|
_useCache7 = new WeakMap();
|
|
2723
2780
|
|
|
2724
2781
|
// src/preferences/helpers.ts
|
|
2725
|
-
var updatePreference = (_0) =>
|
|
2782
|
+
var updatePreference = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
2726
2783
|
emitter,
|
|
2727
2784
|
apiService,
|
|
2728
2785
|
cache,
|
|
@@ -2737,8 +2794,8 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
2737
2794
|
emitter.emit("preference.update.pending", {
|
|
2738
2795
|
args,
|
|
2739
2796
|
data: "preference" in args ? new Preference(
|
|
2740
|
-
|
|
2741
|
-
channels:
|
|
2797
|
+
chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, args.preference), {
|
|
2798
|
+
channels: chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({}, args.preference.channels), channels)
|
|
2742
2799
|
}),
|
|
2743
2800
|
{
|
|
2744
2801
|
emitterInstance: emitter,
|
|
@@ -2767,10 +2824,10 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
2767
2824
|
return { data: preference };
|
|
2768
2825
|
} catch (error) {
|
|
2769
2826
|
emitter.emit("preference.update.resolved", { args, error });
|
|
2770
|
-
return { error: new
|
|
2827
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to update preference", error) };
|
|
2771
2828
|
}
|
|
2772
2829
|
});
|
|
2773
|
-
var bulkUpdatePreference = (_0) =>
|
|
2830
|
+
var bulkUpdatePreference = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
2774
2831
|
emitter,
|
|
2775
2832
|
apiService,
|
|
2776
2833
|
cache,
|
|
@@ -2780,13 +2837,13 @@ var bulkUpdatePreference = (_0) => chunk7B52C2XE_js.__async(null, [_0], function
|
|
|
2780
2837
|
}) {
|
|
2781
2838
|
const globalPreference = args.find((arg) => "preference" in arg && arg.preference.level === "global" /* GLOBAL */);
|
|
2782
2839
|
if (globalPreference) {
|
|
2783
|
-
return { error: new
|
|
2840
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Global preference is not supported in bulk update", "") };
|
|
2784
2841
|
}
|
|
2785
2842
|
try {
|
|
2786
2843
|
const optimisticallyUpdatedPreferences = args.map(
|
|
2787
2844
|
(arg) => "preference" in arg ? new Preference(
|
|
2788
|
-
|
|
2789
|
-
channels:
|
|
2845
|
+
chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, arg.preference), {
|
|
2846
|
+
channels: chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({}, arg.preference.channels), arg.channels)
|
|
2790
2847
|
}),
|
|
2791
2848
|
{
|
|
2792
2849
|
emitterInstance: emitter,
|
|
@@ -2803,7 +2860,7 @@ var bulkUpdatePreference = (_0) => chunk7B52C2XE_js.__async(null, [_0], function
|
|
|
2803
2860
|
});
|
|
2804
2861
|
const preferencesToUpdate = args.map((arg) => {
|
|
2805
2862
|
var _a, _b, _c, _d;
|
|
2806
|
-
return
|
|
2863
|
+
return chunkA6CBLMST_js.__spreadValues({
|
|
2807
2864
|
workflowId: "workflowId" in arg ? arg.workflowId : (_d = (_c = (_a = arg.preference.workflow) == null ? void 0 : _a.id) != null ? _c : (_b = arg.preference.workflow) == null ? void 0 : _b.identifier) != null ? _d : ""
|
|
2808
2865
|
}, arg.channels);
|
|
2809
2866
|
});
|
|
@@ -2821,7 +2878,7 @@ var bulkUpdatePreference = (_0) => chunk7B52C2XE_js.__async(null, [_0], function
|
|
|
2821
2878
|
return { data: preferences };
|
|
2822
2879
|
} catch (error) {
|
|
2823
2880
|
emitter.emit("preferences.bulk_update.resolved", { args, error });
|
|
2824
|
-
return { error: new
|
|
2881
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to bulk update preferences", error) };
|
|
2825
2882
|
}
|
|
2826
2883
|
});
|
|
2827
2884
|
var optimisticUpdateWorkflowPreferences = ({
|
|
@@ -2836,7 +2893,7 @@ var optimisticUpdateWorkflowPreferences = ({
|
|
|
2836
2893
|
allPreferences == null ? void 0 : allPreferences.forEach((el) => {
|
|
2837
2894
|
var _a, _b;
|
|
2838
2895
|
if (el.level === "template" /* TEMPLATE */) {
|
|
2839
|
-
const mergedPreference =
|
|
2896
|
+
const mergedPreference = chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, el), {
|
|
2840
2897
|
channels: Object.entries(el.channels).reduce((acc, [key, value]) => {
|
|
2841
2898
|
var _a2;
|
|
2842
2899
|
const channelType = key;
|
|
@@ -2863,7 +2920,7 @@ var optimisticUpdateWorkflowPreferences = ({
|
|
|
2863
2920
|
}
|
|
2864
2921
|
});
|
|
2865
2922
|
};
|
|
2866
|
-
var updateSchedule = (_0) =>
|
|
2923
|
+
var updateSchedule = (_0) => chunkA6CBLMST_js.__async(null, [_0], function* ({
|
|
2867
2924
|
emitter,
|
|
2868
2925
|
apiService,
|
|
2869
2926
|
cache,
|
|
@@ -2911,7 +2968,7 @@ var updateSchedule = (_0) => chunk7B52C2XE_js.__async(null, [_0], function* ({
|
|
|
2911
2968
|
return { data: updatedSchedule };
|
|
2912
2969
|
} catch (error) {
|
|
2913
2970
|
emitter.emit("preference.schedule.update.resolved", { args, error });
|
|
2914
|
-
return { error: new
|
|
2971
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to update preference", error) };
|
|
2915
2972
|
}
|
|
2916
2973
|
});
|
|
2917
2974
|
|
|
@@ -2928,16 +2985,16 @@ var PreferenceSchedule = class extends BaseModule {
|
|
|
2928
2985
|
eventEmitterInstance,
|
|
2929
2986
|
inboxServiceInstance
|
|
2930
2987
|
});
|
|
2931
|
-
|
|
2988
|
+
chunkA6CBLMST_js.__privateAdd(this, _useCache8);
|
|
2932
2989
|
this.cache = cache;
|
|
2933
|
-
|
|
2990
|
+
chunkA6CBLMST_js.__privateSet(this, _useCache8, useCache);
|
|
2934
2991
|
}
|
|
2935
2992
|
get() {
|
|
2936
|
-
return
|
|
2937
|
-
return this.callWithSession(() =>
|
|
2993
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2994
|
+
return this.callWithSession(() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2938
2995
|
var _a, _b;
|
|
2939
2996
|
try {
|
|
2940
|
-
let data =
|
|
2997
|
+
let data = chunkA6CBLMST_js.__privateGet(this, _useCache8) ? this.cache.getAll() : void 0;
|
|
2941
2998
|
this._emitter.emit("preference.schedule.get.pending", { args: void 0, data });
|
|
2942
2999
|
if (!data) {
|
|
2943
3000
|
const globalPreference = yield this._inboxService.fetchGlobalPreferences();
|
|
@@ -2950,10 +3007,10 @@ var PreferenceSchedule = class extends BaseModule {
|
|
|
2950
3007
|
emitterInstance: this._emitter,
|
|
2951
3008
|
inboxServiceInstance: this._inboxService,
|
|
2952
3009
|
cache: this.cache,
|
|
2953
|
-
useCache:
|
|
3010
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache8)
|
|
2954
3011
|
}
|
|
2955
3012
|
);
|
|
2956
|
-
if (
|
|
3013
|
+
if (chunkA6CBLMST_js.__privateGet(this, _useCache8)) {
|
|
2957
3014
|
this.cache.set(data);
|
|
2958
3015
|
data = this.cache.getAll();
|
|
2959
3016
|
}
|
|
@@ -2971,13 +3028,13 @@ var PreferenceSchedule = class extends BaseModule {
|
|
|
2971
3028
|
});
|
|
2972
3029
|
}
|
|
2973
3030
|
update(args) {
|
|
2974
|
-
return
|
|
3031
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
2975
3032
|
return this.callWithSession(
|
|
2976
3033
|
() => updateSchedule({
|
|
2977
3034
|
emitter: this._emitter,
|
|
2978
3035
|
apiService: this._inboxService,
|
|
2979
3036
|
cache: this.cache,
|
|
2980
|
-
useCache:
|
|
3037
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache8),
|
|
2981
3038
|
args
|
|
2982
3039
|
})
|
|
2983
3040
|
);
|
|
@@ -3010,10 +3067,10 @@ var getCacheKey2 = ({ tags, severity }) => {
|
|
|
3010
3067
|
var _emitter7, _cache8;
|
|
3011
3068
|
var PreferencesCache = class {
|
|
3012
3069
|
constructor({ emitterInstance }) {
|
|
3013
|
-
|
|
3014
|
-
|
|
3070
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter7);
|
|
3071
|
+
chunkA6CBLMST_js.__privateAdd(this, _cache8);
|
|
3015
3072
|
this.updatePreference = (key, data) => {
|
|
3016
|
-
const preferences =
|
|
3073
|
+
const preferences = chunkA6CBLMST_js.__privateGet(this, _cache8).get(key);
|
|
3017
3074
|
if (!preferences) {
|
|
3018
3075
|
return false;
|
|
3019
3076
|
}
|
|
@@ -3028,11 +3085,11 @@ var PreferencesCache = class {
|
|
|
3028
3085
|
}
|
|
3029
3086
|
const updatedPreferences = [...preferences];
|
|
3030
3087
|
updatedPreferences[index] = data;
|
|
3031
|
-
|
|
3088
|
+
chunkA6CBLMST_js.__privateGet(this, _cache8).set(key, updatedPreferences);
|
|
3032
3089
|
return true;
|
|
3033
3090
|
};
|
|
3034
3091
|
this.updatePreferenceSchedule = (key, data) => {
|
|
3035
|
-
const preferences =
|
|
3092
|
+
const preferences = chunkA6CBLMST_js.__privateGet(this, _cache8).get(key);
|
|
3036
3093
|
if (!preferences) {
|
|
3037
3094
|
return false;
|
|
3038
3095
|
}
|
|
@@ -3042,7 +3099,7 @@ var PreferencesCache = class {
|
|
|
3042
3099
|
}
|
|
3043
3100
|
const updatedPreferences = [...preferences];
|
|
3044
3101
|
updatedPreferences[index].schedule = data;
|
|
3045
|
-
|
|
3102
|
+
chunkA6CBLMST_js.__privateGet(this, _cache8).set(key, updatedPreferences);
|
|
3046
3103
|
return true;
|
|
3047
3104
|
};
|
|
3048
3105
|
this.handleScheduleEvent = ({ data }) => {
|
|
@@ -3050,19 +3107,19 @@ var PreferencesCache = class {
|
|
|
3050
3107
|
if (!data) {
|
|
3051
3108
|
return;
|
|
3052
3109
|
}
|
|
3053
|
-
const cacheKeys =
|
|
3110
|
+
const cacheKeys = chunkA6CBLMST_js.__privateGet(this, _cache8).keys();
|
|
3054
3111
|
const uniqueFilterKeys = /* @__PURE__ */ new Set();
|
|
3055
3112
|
for (const key of cacheKeys) {
|
|
3056
3113
|
const hasUpdatedPreference = this.updatePreferenceSchedule(key, data);
|
|
3057
|
-
const updatedPreference =
|
|
3114
|
+
const updatedPreference = chunkA6CBLMST_js.__privateGet(this, _cache8).get(key);
|
|
3058
3115
|
if (!hasUpdatedPreference || !updatedPreference) {
|
|
3059
3116
|
continue;
|
|
3060
3117
|
}
|
|
3061
3118
|
uniqueFilterKeys.add(key);
|
|
3062
3119
|
}
|
|
3063
3120
|
for (const key of uniqueFilterKeys) {
|
|
3064
|
-
|
|
3065
|
-
data: (_a =
|
|
3121
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter7).emit("preferences.list.updated", {
|
|
3122
|
+
data: (_a = chunkA6CBLMST_js.__privateGet(this, _cache8).get(key)) != null ? _a : []
|
|
3066
3123
|
});
|
|
3067
3124
|
}
|
|
3068
3125
|
};
|
|
@@ -3072,10 +3129,10 @@ var PreferencesCache = class {
|
|
|
3072
3129
|
}
|
|
3073
3130
|
const preferences = Array.isArray(data) ? data : [data];
|
|
3074
3131
|
const uniqueFilterKeys = /* @__PURE__ */ new Set();
|
|
3075
|
-
|
|
3132
|
+
chunkA6CBLMST_js.__privateGet(this, _cache8).keys().forEach((key) => {
|
|
3076
3133
|
preferences.forEach((preference) => {
|
|
3077
3134
|
const hasUpdatedPreference = this.updatePreference(key, preference);
|
|
3078
|
-
const updatedPreference =
|
|
3135
|
+
const updatedPreference = chunkA6CBLMST_js.__privateGet(this, _cache8).get(key);
|
|
3079
3136
|
if (!hasUpdatedPreference || !updatedPreference) {
|
|
3080
3137
|
return;
|
|
3081
3138
|
}
|
|
@@ -3084,33 +3141,33 @@ var PreferencesCache = class {
|
|
|
3084
3141
|
});
|
|
3085
3142
|
uniqueFilterKeys.forEach((key) => {
|
|
3086
3143
|
var _a;
|
|
3087
|
-
|
|
3088
|
-
data: (_a =
|
|
3144
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter7).emit("preferences.list.updated", {
|
|
3145
|
+
data: (_a = chunkA6CBLMST_js.__privateGet(this, _cache8).get(key)) != null ? _a : []
|
|
3089
3146
|
});
|
|
3090
3147
|
});
|
|
3091
3148
|
};
|
|
3092
|
-
|
|
3149
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter7, emitterInstance);
|
|
3093
3150
|
for (const event of updateEvents2) {
|
|
3094
|
-
|
|
3151
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter7).on(event, this.handlePreferenceEvent);
|
|
3095
3152
|
}
|
|
3096
3153
|
for (const event of scheduleUpdateEvents) {
|
|
3097
|
-
|
|
3154
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter7).on(event, this.handleScheduleEvent);
|
|
3098
3155
|
}
|
|
3099
|
-
|
|
3156
|
+
chunkA6CBLMST_js.__privateSet(this, _cache8, new InMemoryCache());
|
|
3100
3157
|
}
|
|
3101
3158
|
has(args) {
|
|
3102
|
-
return
|
|
3159
|
+
return chunkA6CBLMST_js.__privateGet(this, _cache8).get(getCacheKey2(args)) !== void 0;
|
|
3103
3160
|
}
|
|
3104
3161
|
set(args, data) {
|
|
3105
|
-
|
|
3162
|
+
chunkA6CBLMST_js.__privateGet(this, _cache8).set(getCacheKey2(args), data);
|
|
3106
3163
|
}
|
|
3107
3164
|
getAll(args) {
|
|
3108
3165
|
if (this.has(args)) {
|
|
3109
|
-
return
|
|
3166
|
+
return chunkA6CBLMST_js.__privateGet(this, _cache8).get(getCacheKey2(args));
|
|
3110
3167
|
}
|
|
3111
3168
|
}
|
|
3112
3169
|
clearAll() {
|
|
3113
|
-
|
|
3170
|
+
chunkA6CBLMST_js.__privateGet(this, _cache8).clear();
|
|
3114
3171
|
}
|
|
3115
3172
|
};
|
|
3116
3173
|
_emitter7 = new WeakMap();
|
|
@@ -3127,14 +3184,14 @@ var getCacheKey3 = () => {
|
|
|
3127
3184
|
var _emitter8, _cache9;
|
|
3128
3185
|
var ScheduleCache = class {
|
|
3129
3186
|
constructor({ emitterInstance }) {
|
|
3130
|
-
|
|
3131
|
-
|
|
3187
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter8);
|
|
3188
|
+
chunkA6CBLMST_js.__privateAdd(this, _cache9);
|
|
3132
3189
|
this.updateScheduleInCache = (key, data) => {
|
|
3133
|
-
const schedule =
|
|
3190
|
+
const schedule = chunkA6CBLMST_js.__privateGet(this, _cache9).get(key);
|
|
3134
3191
|
if (!schedule) {
|
|
3135
3192
|
return false;
|
|
3136
3193
|
}
|
|
3137
|
-
|
|
3194
|
+
chunkA6CBLMST_js.__privateGet(this, _cache9).set(key, data);
|
|
3138
3195
|
return true;
|
|
3139
3196
|
};
|
|
3140
3197
|
this.handleScheduleEvent = ({ data }) => {
|
|
@@ -3142,40 +3199,40 @@ var ScheduleCache = class {
|
|
|
3142
3199
|
return;
|
|
3143
3200
|
}
|
|
3144
3201
|
const uniqueFilterKeys = /* @__PURE__ */ new Set();
|
|
3145
|
-
const keys =
|
|
3202
|
+
const keys = chunkA6CBLMST_js.__privateGet(this, _cache9).keys();
|
|
3146
3203
|
for (const key of keys) {
|
|
3147
3204
|
const hasUpdatedSchedule = this.updateScheduleInCache(key, data);
|
|
3148
|
-
const updatedSchedule =
|
|
3205
|
+
const updatedSchedule = chunkA6CBLMST_js.__privateGet(this, _cache9).get(key);
|
|
3149
3206
|
if (!hasUpdatedSchedule || !updatedSchedule) {
|
|
3150
3207
|
continue;
|
|
3151
3208
|
}
|
|
3152
3209
|
uniqueFilterKeys.add(key);
|
|
3153
3210
|
}
|
|
3154
3211
|
for (const key of uniqueFilterKeys) {
|
|
3155
|
-
|
|
3156
|
-
data:
|
|
3212
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter8).emit("preference.schedule.get.updated", {
|
|
3213
|
+
data: chunkA6CBLMST_js.__privateGet(this, _cache9).get(key)
|
|
3157
3214
|
});
|
|
3158
3215
|
}
|
|
3159
3216
|
};
|
|
3160
|
-
|
|
3217
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter8, emitterInstance);
|
|
3161
3218
|
for (const event of updateEvents3) {
|
|
3162
|
-
|
|
3219
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter8).on(event, this.handleScheduleEvent);
|
|
3163
3220
|
}
|
|
3164
|
-
|
|
3221
|
+
chunkA6CBLMST_js.__privateSet(this, _cache9, new InMemoryCache());
|
|
3165
3222
|
}
|
|
3166
3223
|
has() {
|
|
3167
|
-
return
|
|
3224
|
+
return chunkA6CBLMST_js.__privateGet(this, _cache9).get(getCacheKey3()) !== void 0;
|
|
3168
3225
|
}
|
|
3169
3226
|
set(data) {
|
|
3170
|
-
|
|
3227
|
+
chunkA6CBLMST_js.__privateGet(this, _cache9).set(getCacheKey3(), data);
|
|
3171
3228
|
}
|
|
3172
3229
|
getAll() {
|
|
3173
3230
|
if (this.has()) {
|
|
3174
|
-
return
|
|
3231
|
+
return chunkA6CBLMST_js.__privateGet(this, _cache9).get(getCacheKey3());
|
|
3175
3232
|
}
|
|
3176
3233
|
}
|
|
3177
3234
|
clearAll() {
|
|
3178
|
-
|
|
3235
|
+
chunkA6CBLMST_js.__privateGet(this, _cache9).clear();
|
|
3179
3236
|
}
|
|
3180
3237
|
};
|
|
3181
3238
|
_emitter8 = new WeakMap();
|
|
@@ -3193,14 +3250,14 @@ var Preferences = class extends BaseModule {
|
|
|
3193
3250
|
eventEmitterInstance,
|
|
3194
3251
|
inboxServiceInstance
|
|
3195
3252
|
});
|
|
3196
|
-
|
|
3253
|
+
chunkA6CBLMST_js.__privateAdd(this, _useCache9);
|
|
3197
3254
|
this.cache = new PreferencesCache({
|
|
3198
3255
|
emitterInstance: this._emitter
|
|
3199
3256
|
});
|
|
3200
3257
|
this.scheduleCache = new ScheduleCache({
|
|
3201
3258
|
emitterInstance: this._emitter
|
|
3202
3259
|
});
|
|
3203
|
-
|
|
3260
|
+
chunkA6CBLMST_js.__privateSet(this, _useCache9, useCache);
|
|
3204
3261
|
this.schedule = new PreferenceSchedule({
|
|
3205
3262
|
cache: this.scheduleCache,
|
|
3206
3263
|
useCache,
|
|
@@ -3209,11 +3266,11 @@ var Preferences = class extends BaseModule {
|
|
|
3209
3266
|
});
|
|
3210
3267
|
}
|
|
3211
3268
|
list() {
|
|
3212
|
-
return
|
|
3213
|
-
return this.callWithSession(() =>
|
|
3269
|
+
return chunkA6CBLMST_js.__async(this, arguments, function* (args = {}) {
|
|
3270
|
+
return this.callWithSession(() => chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3214
3271
|
var _a;
|
|
3215
3272
|
try {
|
|
3216
|
-
let data =
|
|
3273
|
+
let data = chunkA6CBLMST_js.__privateGet(this, _useCache9) ? this.cache.getAll(args) : void 0;
|
|
3217
3274
|
this._emitter.emit("preferences.list.pending", { args, data });
|
|
3218
3275
|
if (!data) {
|
|
3219
3276
|
const response = yield this._inboxService.fetchPreferences({
|
|
@@ -3227,10 +3284,10 @@ var Preferences = class extends BaseModule {
|
|
|
3227
3284
|
inboxServiceInstance: this._inboxService,
|
|
3228
3285
|
cache: this.cache,
|
|
3229
3286
|
scheduleCache: this.scheduleCache,
|
|
3230
|
-
useCache:
|
|
3287
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache9)
|
|
3231
3288
|
})
|
|
3232
3289
|
);
|
|
3233
|
-
if (
|
|
3290
|
+
if (chunkA6CBLMST_js.__privateGet(this, _useCache9)) {
|
|
3234
3291
|
this.cache.set(args, data);
|
|
3235
3292
|
data = this.cache.getAll(args);
|
|
3236
3293
|
}
|
|
@@ -3245,28 +3302,28 @@ var Preferences = class extends BaseModule {
|
|
|
3245
3302
|
});
|
|
3246
3303
|
}
|
|
3247
3304
|
update(args) {
|
|
3248
|
-
return
|
|
3305
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3249
3306
|
return this.callWithSession(
|
|
3250
3307
|
() => updatePreference({
|
|
3251
3308
|
emitter: this._emitter,
|
|
3252
3309
|
apiService: this._inboxService,
|
|
3253
3310
|
cache: this.cache,
|
|
3254
3311
|
scheduleCache: this.scheduleCache,
|
|
3255
|
-
useCache:
|
|
3312
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache9),
|
|
3256
3313
|
args
|
|
3257
3314
|
})
|
|
3258
3315
|
);
|
|
3259
3316
|
});
|
|
3260
3317
|
}
|
|
3261
3318
|
bulkUpdate(args) {
|
|
3262
|
-
return
|
|
3319
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3263
3320
|
return this.callWithSession(
|
|
3264
3321
|
() => bulkUpdatePreference({
|
|
3265
3322
|
emitter: this._emitter,
|
|
3266
3323
|
apiService: this._inboxService,
|
|
3267
3324
|
cache: this.cache,
|
|
3268
3325
|
scheduleCache: this.scheduleCache,
|
|
3269
|
-
useCache:
|
|
3326
|
+
useCache: chunkA6CBLMST_js.__privateGet(this, _useCache9),
|
|
3270
3327
|
args
|
|
3271
3328
|
})
|
|
3272
3329
|
);
|
|
@@ -3284,31 +3341,31 @@ function isBrowser() {
|
|
|
3284
3341
|
var _emitter9, _inboxService5, _options;
|
|
3285
3342
|
var Session = class {
|
|
3286
3343
|
constructor(options, inboxServiceInstance, eventEmitterInstance) {
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3344
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter9);
|
|
3345
|
+
chunkA6CBLMST_js.__privateAdd(this, _inboxService5);
|
|
3346
|
+
chunkA6CBLMST_js.__privateAdd(this, _options);
|
|
3347
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter9, eventEmitterInstance);
|
|
3348
|
+
chunkA6CBLMST_js.__privateSet(this, _inboxService5, inboxServiceInstance);
|
|
3349
|
+
chunkA6CBLMST_js.__privateSet(this, _options, options);
|
|
3293
3350
|
}
|
|
3294
3351
|
get applicationIdentifier() {
|
|
3295
|
-
return
|
|
3352
|
+
return chunkA6CBLMST_js.__privateGet(this, _options).applicationIdentifier;
|
|
3296
3353
|
}
|
|
3297
3354
|
get subscriberId() {
|
|
3298
3355
|
var _a;
|
|
3299
|
-
return (_a =
|
|
3356
|
+
return (_a = chunkA6CBLMST_js.__privateGet(this, _options).subscriber) == null ? void 0 : _a.subscriberId;
|
|
3300
3357
|
}
|
|
3301
3358
|
get context() {
|
|
3302
|
-
return
|
|
3359
|
+
return chunkA6CBLMST_js.__privateGet(this, _options).context;
|
|
3303
3360
|
}
|
|
3304
3361
|
get subscriberHash() {
|
|
3305
|
-
return
|
|
3362
|
+
return chunkA6CBLMST_js.__privateGet(this, _options).subscriberHash;
|
|
3306
3363
|
}
|
|
3307
3364
|
get contextHash() {
|
|
3308
|
-
return
|
|
3365
|
+
return chunkA6CBLMST_js.__privateGet(this, _options).contextHash;
|
|
3309
3366
|
}
|
|
3310
3367
|
get subscriber() {
|
|
3311
|
-
return
|
|
3368
|
+
return chunkA6CBLMST_js.__privateGet(this, _options).subscriber;
|
|
3312
3369
|
}
|
|
3313
3370
|
handleApplicationIdentifier(method, identifier) {
|
|
3314
3371
|
if (typeof window === "undefined" || !window.localStorage) {
|
|
@@ -3334,18 +3391,18 @@ var Session = class {
|
|
|
3334
3391
|
}
|
|
3335
3392
|
}
|
|
3336
3393
|
initialize(options) {
|
|
3337
|
-
return
|
|
3394
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3338
3395
|
var _a, _b, _c, _d, _e, _f;
|
|
3339
|
-
const subscriberUnchanged = ((_a =
|
|
3340
|
-
const contextUnchanged = JSON.stringify(
|
|
3396
|
+
const subscriberUnchanged = ((_a = chunkA6CBLMST_js.__privateGet(this, _options).subscriber) == null ? void 0 : _a.subscriberId) === ((_b = options == null ? void 0 : options.subscriber) == null ? void 0 : _b.subscriberId);
|
|
3397
|
+
const contextUnchanged = JSON.stringify(chunkA6CBLMST_js.__privateGet(this, _options).context) === JSON.stringify(options == null ? void 0 : options.context);
|
|
3341
3398
|
if (subscriberUnchanged && contextUnchanged) {
|
|
3342
3399
|
return;
|
|
3343
3400
|
}
|
|
3344
3401
|
try {
|
|
3345
3402
|
if (options) {
|
|
3346
|
-
|
|
3403
|
+
chunkA6CBLMST_js.__privateSet(this, _options, options);
|
|
3347
3404
|
}
|
|
3348
|
-
const { subscriber, subscriberHash, contextHash, applicationIdentifier, defaultSchedule, context } =
|
|
3405
|
+
const { subscriber, subscriberHash, contextHash, applicationIdentifier, defaultSchedule, context } = chunkA6CBLMST_js.__privateGet(this, _options);
|
|
3349
3406
|
let currentTimezone;
|
|
3350
3407
|
if (isBrowser()) {
|
|
3351
3408
|
currentTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
@@ -3359,12 +3416,12 @@ var Session = class {
|
|
|
3359
3416
|
} else {
|
|
3360
3417
|
this.handleApplicationIdentifier("delete");
|
|
3361
3418
|
}
|
|
3362
|
-
|
|
3363
|
-
const response = yield
|
|
3419
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter9).emit("session.initialize.pending", { args: chunkA6CBLMST_js.__privateGet(this, _options) });
|
|
3420
|
+
const response = yield chunkA6CBLMST_js.__privateGet(this, _inboxService5).initializeSession({
|
|
3364
3421
|
applicationIdentifier: finalApplicationIdentifier,
|
|
3365
3422
|
subscriberHash,
|
|
3366
3423
|
contextHash,
|
|
3367
|
-
subscriber:
|
|
3424
|
+
subscriber: chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues({}, subscriber), {
|
|
3368
3425
|
subscriberId: (_c = subscriber == null ? void 0 : subscriber.subscriberId) != null ? _c : "",
|
|
3369
3426
|
timezone: (_d = subscriber == null ? void 0 : subscriber.timezone) != null ? _d : currentTimezone
|
|
3370
3427
|
}),
|
|
@@ -3377,9 +3434,9 @@ var Session = class {
|
|
|
3377
3434
|
if (!((_f = response == null ? void 0 : response.applicationIdentifier) == null ? void 0 : _f.startsWith("pk_keyless_"))) {
|
|
3378
3435
|
this.handleApplicationIdentifier("delete");
|
|
3379
3436
|
}
|
|
3380
|
-
|
|
3437
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter9).emit("session.initialize.resolved", { args: chunkA6CBLMST_js.__privateGet(this, _options), data: response });
|
|
3381
3438
|
} catch (error) {
|
|
3382
|
-
|
|
3439
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter9).emit("session.initialize.resolved", { args: chunkA6CBLMST_js.__privateGet(this, _options), error });
|
|
3383
3440
|
}
|
|
3384
3441
|
});
|
|
3385
3442
|
}
|
|
@@ -3387,6 +3444,26 @@ var Session = class {
|
|
|
3387
3444
|
_emitter9 = new WeakMap();
|
|
3388
3445
|
_inboxService5 = new WeakMap();
|
|
3389
3446
|
_options = new WeakMap();
|
|
3447
|
+
|
|
3448
|
+
// src/utils/in-app-redirect-url.ts
|
|
3449
|
+
var IN_APP_REDIRECT_URL_REGEX = /^(?:\{\{[^}]*\}\}.*|(?!mailto:)(?:https?:\/\/[^\s/$.?#][^\s{}]*(?:\{\{[^}]*\}\}[^\s{}]*)*)|\/(?!\/)[^\s{}]*(?:\{\{[^}]*\}\}[^\s{}]*)*)$/;
|
|
3450
|
+
var IN_APP_REDIRECT_TARGETS = ["_self", "_blank", "_parent", "_top", "_unfencedTop"];
|
|
3451
|
+
function isValidInAppRedirectUrl(url) {
|
|
3452
|
+
return IN_APP_REDIRECT_URL_REGEX.test(url);
|
|
3453
|
+
}
|
|
3454
|
+
function isValidInAppRedirectTarget(target) {
|
|
3455
|
+
return typeof target === "string" && IN_APP_REDIRECT_TARGETS.includes(target);
|
|
3456
|
+
}
|
|
3457
|
+
function sanitizeInAppRedirect(url, target) {
|
|
3458
|
+
if (!url || !isValidInAppRedirectUrl(url)) {
|
|
3459
|
+
return void 0;
|
|
3460
|
+
}
|
|
3461
|
+
return chunkA6CBLMST_js.__spreadValues({
|
|
3462
|
+
url
|
|
3463
|
+
}, isValidInAppRedirectTarget(target) ? { target } : {});
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3466
|
+
// src/ws/party-socket.ts
|
|
3390
3467
|
var PRODUCTION_SOCKET_URL = "wss://socket.novu.co";
|
|
3391
3468
|
var HIBERNATION_HEARTBEAT_MS = 25e3;
|
|
3392
3469
|
var HIBERNATION_PING_PAYLOAD = "ping";
|
|
@@ -3416,7 +3493,7 @@ var mapToNotification = ({
|
|
|
3416
3493
|
workflow,
|
|
3417
3494
|
severity
|
|
3418
3495
|
}) => {
|
|
3419
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3496
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3420
3497
|
const to = {
|
|
3421
3498
|
id: subscriber == null ? void 0 : subscriber._id,
|
|
3422
3499
|
subscriberId: subscriber == null ? void 0 : subscriber.subscriberId,
|
|
@@ -3433,7 +3510,7 @@ var mapToNotification = ({
|
|
|
3433
3510
|
const secondaryCta = (_d = (_c = cta.action) == null ? void 0 : _c.buttons) == null ? void 0 : _d.find((button) => button.type === "secondary" /* SECONDARY */);
|
|
3434
3511
|
const actionType = (_f = (_e = cta.action) == null ? void 0 : _e.result) == null ? void 0 : _f.type;
|
|
3435
3512
|
const actionStatus = (_g = cta.action) == null ? void 0 : _g.status;
|
|
3436
|
-
return
|
|
3513
|
+
return chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({
|
|
3437
3514
|
id: _id,
|
|
3438
3515
|
transactionId,
|
|
3439
3516
|
subject,
|
|
@@ -3456,25 +3533,16 @@ var mapToNotification = ({
|
|
|
3456
3533
|
primaryAction: primaryCta && {
|
|
3457
3534
|
label: primaryCta.content,
|
|
3458
3535
|
isCompleted: actionType === "primary" /* PRIMARY */ && actionStatus === "done" /* DONE */,
|
|
3459
|
-
redirect: primaryCta.url
|
|
3460
|
-
target: primaryCta.target,
|
|
3461
|
-
url: primaryCta.url
|
|
3462
|
-
} : void 0
|
|
3536
|
+
redirect: sanitizeInAppRedirect(primaryCta.url, primaryCta.target)
|
|
3463
3537
|
},
|
|
3464
3538
|
secondaryAction: secondaryCta && {
|
|
3465
3539
|
label: secondaryCta.content,
|
|
3466
3540
|
isCompleted: actionType === "secondary" /* SECONDARY */ && actionStatus === "done" /* DONE */,
|
|
3467
|
-
redirect: secondaryCta.url
|
|
3468
|
-
target: secondaryCta.target,
|
|
3469
|
-
url: secondaryCta.url
|
|
3470
|
-
} : void 0
|
|
3541
|
+
redirect: sanitizeInAppRedirect(secondaryCta.url, secondaryCta.target)
|
|
3471
3542
|
},
|
|
3472
3543
|
channelType: channel,
|
|
3473
3544
|
tags,
|
|
3474
|
-
redirect: ((_h = cta.data) == null ? void 0 : _h.url) ?
|
|
3475
|
-
url: cta.data.url,
|
|
3476
|
-
target: cta.data.target
|
|
3477
|
-
} : void 0,
|
|
3545
|
+
redirect: sanitizeInAppRedirect((_h = cta.data) == null ? void 0 : _h.url, (_i = cta.data) == null ? void 0 : _i.target),
|
|
3478
3546
|
data,
|
|
3479
3547
|
workflow,
|
|
3480
3548
|
severity
|
|
@@ -3492,48 +3560,48 @@ var PartySocketClient = class extends BaseModule {
|
|
|
3492
3560
|
eventEmitterInstance,
|
|
3493
3561
|
inboxServiceInstance
|
|
3494
3562
|
});
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3563
|
+
chunkA6CBLMST_js.__privateAdd(this, _PartySocketClient_instances);
|
|
3564
|
+
chunkA6CBLMST_js.__privateAdd(this, _token);
|
|
3565
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter10);
|
|
3566
|
+
chunkA6CBLMST_js.__privateAdd(this, _partySocket);
|
|
3567
|
+
chunkA6CBLMST_js.__privateAdd(this, _socketUrl);
|
|
3568
|
+
chunkA6CBLMST_js.__privateAdd(this, _socketOptions);
|
|
3569
|
+
chunkA6CBLMST_js.__privateAdd(this, _hibernationHeartbeatIntervalId);
|
|
3570
|
+
chunkA6CBLMST_js.__privateAdd(this, _notificationReceived, (event) => {
|
|
3503
3571
|
try {
|
|
3504
3572
|
const data = JSON.parse(event.data);
|
|
3505
3573
|
if (data.event === "notification_received" /* RECEIVED */) {
|
|
3506
|
-
|
|
3507
|
-
result: new
|
|
3574
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter10).emit(NOTIFICATION_RECEIVED, {
|
|
3575
|
+
result: new chunkTLQQB5Y7_js.Notification(mapToNotification(data.data.message), chunkA6CBLMST_js.__privateGet(this, _emitter10), this._inboxService)
|
|
3508
3576
|
});
|
|
3509
3577
|
}
|
|
3510
3578
|
} catch (error) {
|
|
3511
3579
|
console.log("error", error);
|
|
3512
3580
|
}
|
|
3513
3581
|
});
|
|
3514
|
-
|
|
3582
|
+
chunkA6CBLMST_js.__privateAdd(this, _unseenCountChanged, (event) => {
|
|
3515
3583
|
try {
|
|
3516
3584
|
const data = JSON.parse(event.data);
|
|
3517
3585
|
if (data.event === "unseen_count_changed" /* UNSEEN */) {
|
|
3518
|
-
|
|
3586
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter10).emit(UNSEEN_COUNT_CHANGED, {
|
|
3519
3587
|
result: data.data.unseenCount
|
|
3520
3588
|
});
|
|
3521
3589
|
}
|
|
3522
3590
|
} catch (error) {
|
|
3523
3591
|
}
|
|
3524
3592
|
});
|
|
3525
|
-
|
|
3593
|
+
chunkA6CBLMST_js.__privateAdd(this, _unreadCountChanged, (event) => {
|
|
3526
3594
|
try {
|
|
3527
3595
|
const data = JSON.parse(event.data);
|
|
3528
3596
|
if (data.event === "unread_count_changed" /* UNREAD */) {
|
|
3529
|
-
|
|
3597
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter10).emit(UNREAD_COUNT_CHANGED, {
|
|
3530
3598
|
result: data.data.counts
|
|
3531
3599
|
});
|
|
3532
3600
|
}
|
|
3533
3601
|
} catch (error) {
|
|
3534
3602
|
}
|
|
3535
3603
|
});
|
|
3536
|
-
|
|
3604
|
+
chunkA6CBLMST_js.__privateAdd(this, _handleMessage, (event) => {
|
|
3537
3605
|
if (event.data === HIBERNATION_PING_PAYLOAD || event.data === "pong") {
|
|
3538
3606
|
return;
|
|
3539
3607
|
}
|
|
@@ -3541,43 +3609,43 @@ var PartySocketClient = class extends BaseModule {
|
|
|
3541
3609
|
const data = JSON.parse(event.data);
|
|
3542
3610
|
switch (data.event) {
|
|
3543
3611
|
case "notification_received" /* RECEIVED */:
|
|
3544
|
-
|
|
3612
|
+
chunkA6CBLMST_js.__privateGet(this, _notificationReceived).call(this, event);
|
|
3545
3613
|
break;
|
|
3546
3614
|
case "unseen_count_changed" /* UNSEEN */:
|
|
3547
|
-
|
|
3615
|
+
chunkA6CBLMST_js.__privateGet(this, _unseenCountChanged).call(this, event);
|
|
3548
3616
|
break;
|
|
3549
3617
|
case "unread_count_changed" /* UNREAD */:
|
|
3550
|
-
|
|
3618
|
+
chunkA6CBLMST_js.__privateGet(this, _unreadCountChanged).call(this, event);
|
|
3551
3619
|
break;
|
|
3552
3620
|
default:
|
|
3553
3621
|
}
|
|
3554
3622
|
} catch (error) {
|
|
3555
3623
|
}
|
|
3556
3624
|
});
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3625
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter10, eventEmitterInstance);
|
|
3626
|
+
chunkA6CBLMST_js.__privateSet(this, _socketUrl, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL);
|
|
3627
|
+
chunkA6CBLMST_js.__privateSet(this, _socketOptions, socketOptions);
|
|
3560
3628
|
}
|
|
3561
3629
|
onSessionSuccess({ token }) {
|
|
3562
|
-
|
|
3630
|
+
chunkA6CBLMST_js.__privateSet(this, _token, token);
|
|
3563
3631
|
}
|
|
3564
3632
|
isSocketEvent(eventName) {
|
|
3565
3633
|
return eventName === NOTIFICATION_RECEIVED || eventName === UNSEEN_COUNT_CHANGED || eventName === UNREAD_COUNT_CHANGED;
|
|
3566
3634
|
}
|
|
3567
3635
|
connect() {
|
|
3568
|
-
return
|
|
3569
|
-
if (
|
|
3570
|
-
return
|
|
3636
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3637
|
+
if (chunkA6CBLMST_js.__privateGet(this, _token)) {
|
|
3638
|
+
return chunkA6CBLMST_js.__privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn).call(this);
|
|
3571
3639
|
}
|
|
3572
|
-
return this.callWithSession(
|
|
3640
|
+
return this.callWithSession(chunkA6CBLMST_js.__privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn).bind(this));
|
|
3573
3641
|
});
|
|
3574
3642
|
}
|
|
3575
3643
|
disconnect() {
|
|
3576
|
-
return
|
|
3577
|
-
if (
|
|
3578
|
-
return
|
|
3644
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3645
|
+
if (chunkA6CBLMST_js.__privateGet(this, _partySocket)) {
|
|
3646
|
+
return chunkA6CBLMST_js.__privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn).call(this);
|
|
3579
3647
|
}
|
|
3580
|
-
return this.callWithSession(
|
|
3648
|
+
return this.callWithSession(chunkA6CBLMST_js.__privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn).bind(this));
|
|
3581
3649
|
});
|
|
3582
3650
|
}
|
|
3583
3651
|
};
|
|
@@ -3593,15 +3661,15 @@ _unreadCountChanged = new WeakMap();
|
|
|
3593
3661
|
_handleMessage = new WeakMap();
|
|
3594
3662
|
_PartySocketClient_instances = new WeakSet();
|
|
3595
3663
|
clearHibernationHeartbeat_fn = function() {
|
|
3596
|
-
if (
|
|
3597
|
-
clearInterval(
|
|
3598
|
-
|
|
3664
|
+
if (chunkA6CBLMST_js.__privateGet(this, _hibernationHeartbeatIntervalId) !== void 0) {
|
|
3665
|
+
clearInterval(chunkA6CBLMST_js.__privateGet(this, _hibernationHeartbeatIntervalId));
|
|
3666
|
+
chunkA6CBLMST_js.__privateSet(this, _hibernationHeartbeatIntervalId, void 0);
|
|
3599
3667
|
}
|
|
3600
3668
|
};
|
|
3601
3669
|
startHibernationHeartbeat_fn = function() {
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
const socket =
|
|
3670
|
+
chunkA6CBLMST_js.__privateMethod(this, _PartySocketClient_instances, clearHibernationHeartbeat_fn).call(this);
|
|
3671
|
+
chunkA6CBLMST_js.__privateSet(this, _hibernationHeartbeatIntervalId, setInterval(() => {
|
|
3672
|
+
const socket = chunkA6CBLMST_js.__privateGet(this, _partySocket);
|
|
3605
3673
|
if (!socket || socket.readyState !== partysocket.WebSocket.OPEN) {
|
|
3606
3674
|
return;
|
|
3607
3675
|
}
|
|
@@ -3612,53 +3680,53 @@ startHibernationHeartbeat_fn = function() {
|
|
|
3612
3680
|
}, HIBERNATION_HEARTBEAT_MS));
|
|
3613
3681
|
};
|
|
3614
3682
|
initializeSocket_fn = function() {
|
|
3615
|
-
return
|
|
3616
|
-
if (
|
|
3683
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3684
|
+
if (chunkA6CBLMST_js.__privateGet(this, _partySocket)) {
|
|
3617
3685
|
return;
|
|
3618
3686
|
}
|
|
3619
|
-
const args = { socketUrl:
|
|
3620
|
-
|
|
3621
|
-
const url = new URL(
|
|
3622
|
-
url.searchParams.set("token",
|
|
3623
|
-
|
|
3624
|
-
const socket =
|
|
3687
|
+
const args = { socketUrl: chunkA6CBLMST_js.__privateGet(this, _socketUrl) };
|
|
3688
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter10).emit("socket.connect.pending", { args });
|
|
3689
|
+
const url = new URL(chunkA6CBLMST_js.__privateGet(this, _socketUrl));
|
|
3690
|
+
url.searchParams.set("token", chunkA6CBLMST_js.__privateGet(this, _token));
|
|
3691
|
+
chunkA6CBLMST_js.__privateSet(this, _partySocket, new partysocket.WebSocket(url.toString(), void 0, chunkA6CBLMST_js.__privateGet(this, _socketOptions)));
|
|
3692
|
+
const socket = chunkA6CBLMST_js.__privateGet(this, _partySocket);
|
|
3625
3693
|
socket.addEventListener("open", () => {
|
|
3626
|
-
|
|
3627
|
-
|
|
3694
|
+
chunkA6CBLMST_js.__privateMethod(this, _PartySocketClient_instances, startHibernationHeartbeat_fn).call(this);
|
|
3695
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter10).emit("socket.connect.resolved", { args });
|
|
3628
3696
|
});
|
|
3629
3697
|
socket.addEventListener("error", (error) => {
|
|
3630
|
-
|
|
3698
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter10).emit("socket.connect.resolved", { args, error });
|
|
3631
3699
|
});
|
|
3632
3700
|
socket.addEventListener("close", () => {
|
|
3633
|
-
if (socket !==
|
|
3701
|
+
if (socket !== chunkA6CBLMST_js.__privateGet(this, _partySocket)) {
|
|
3634
3702
|
return;
|
|
3635
3703
|
}
|
|
3636
|
-
|
|
3637
|
-
|
|
3704
|
+
chunkA6CBLMST_js.__privateMethod(this, _PartySocketClient_instances, clearHibernationHeartbeat_fn).call(this);
|
|
3705
|
+
chunkA6CBLMST_js.__privateSet(this, _partySocket, void 0);
|
|
3638
3706
|
});
|
|
3639
|
-
socket.addEventListener("message",
|
|
3707
|
+
socket.addEventListener("message", chunkA6CBLMST_js.__privateGet(this, _handleMessage));
|
|
3640
3708
|
});
|
|
3641
3709
|
};
|
|
3642
3710
|
handleConnectSocket_fn = function() {
|
|
3643
|
-
return
|
|
3711
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3644
3712
|
try {
|
|
3645
|
-
yield
|
|
3713
|
+
yield chunkA6CBLMST_js.__privateMethod(this, _PartySocketClient_instances, initializeSocket_fn).call(this);
|
|
3646
3714
|
return {};
|
|
3647
3715
|
} catch (error) {
|
|
3648
|
-
return { error: new
|
|
3716
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to initialize the PartySocket", error) };
|
|
3649
3717
|
}
|
|
3650
3718
|
});
|
|
3651
3719
|
};
|
|
3652
3720
|
handleDisconnectSocket_fn = function() {
|
|
3653
|
-
return
|
|
3721
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3654
3722
|
var _a;
|
|
3655
3723
|
try {
|
|
3656
|
-
|
|
3657
|
-
(_a =
|
|
3658
|
-
|
|
3724
|
+
chunkA6CBLMST_js.__privateMethod(this, _PartySocketClient_instances, clearHibernationHeartbeat_fn).call(this);
|
|
3725
|
+
(_a = chunkA6CBLMST_js.__privateGet(this, _partySocket)) == null ? void 0 : _a.close();
|
|
3726
|
+
chunkA6CBLMST_js.__privateSet(this, _partySocket, void 0);
|
|
3659
3727
|
return {};
|
|
3660
3728
|
} catch (error) {
|
|
3661
|
-
return { error: new
|
|
3729
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to disconnect from the PartySocket", error) };
|
|
3662
3730
|
}
|
|
3663
3731
|
});
|
|
3664
3732
|
};
|
|
@@ -3689,7 +3757,7 @@ var mapToNotification2 = ({
|
|
|
3689
3757
|
workflow,
|
|
3690
3758
|
severity
|
|
3691
3759
|
}) => {
|
|
3692
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3760
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3693
3761
|
const to = {
|
|
3694
3762
|
id: subscriber == null ? void 0 : subscriber._id,
|
|
3695
3763
|
subscriberId: subscriber == null ? void 0 : subscriber.subscriberId,
|
|
@@ -3706,7 +3774,7 @@ var mapToNotification2 = ({
|
|
|
3706
3774
|
const secondaryCta = (_d = (_c = cta.action) == null ? void 0 : _c.buttons) == null ? void 0 : _d.find((button) => button.type === "secondary" /* SECONDARY */);
|
|
3707
3775
|
const actionType = (_f = (_e = cta.action) == null ? void 0 : _e.result) == null ? void 0 : _f.type;
|
|
3708
3776
|
const actionStatus = (_g = cta.action) == null ? void 0 : _g.status;
|
|
3709
|
-
return
|
|
3777
|
+
return chunkA6CBLMST_js.__spreadProps(chunkA6CBLMST_js.__spreadValues(chunkA6CBLMST_js.__spreadValues({
|
|
3710
3778
|
id: _id,
|
|
3711
3779
|
transactionId,
|
|
3712
3780
|
subject,
|
|
@@ -3729,25 +3797,16 @@ var mapToNotification2 = ({
|
|
|
3729
3797
|
primaryAction: primaryCta && {
|
|
3730
3798
|
label: primaryCta.content,
|
|
3731
3799
|
isCompleted: actionType === "primary" /* PRIMARY */ && actionStatus === "done" /* DONE */,
|
|
3732
|
-
redirect: primaryCta.url
|
|
3733
|
-
target: primaryCta.target,
|
|
3734
|
-
url: primaryCta.url
|
|
3735
|
-
} : void 0
|
|
3800
|
+
redirect: sanitizeInAppRedirect(primaryCta.url, primaryCta.target)
|
|
3736
3801
|
},
|
|
3737
3802
|
secondaryAction: secondaryCta && {
|
|
3738
3803
|
label: secondaryCta.content,
|
|
3739
3804
|
isCompleted: actionType === "secondary" /* SECONDARY */ && actionStatus === "done" /* DONE */,
|
|
3740
|
-
redirect: secondaryCta.url
|
|
3741
|
-
target: secondaryCta.target,
|
|
3742
|
-
url: secondaryCta.url
|
|
3743
|
-
} : void 0
|
|
3805
|
+
redirect: sanitizeInAppRedirect(secondaryCta.url, secondaryCta.target)
|
|
3744
3806
|
},
|
|
3745
3807
|
channelType: channel,
|
|
3746
3808
|
tags,
|
|
3747
|
-
redirect: ((_h = cta.data) == null ? void 0 : _h.url) ?
|
|
3748
|
-
url: cta.data.url,
|
|
3749
|
-
target: cta.data.target
|
|
3750
|
-
} : void 0,
|
|
3809
|
+
redirect: sanitizeInAppRedirect((_h = cta.data) == null ? void 0 : _h.url, (_i = cta.data) == null ? void 0 : _i.target),
|
|
3751
3810
|
data,
|
|
3752
3811
|
workflow,
|
|
3753
3812
|
severity
|
|
@@ -3765,51 +3824,51 @@ var Socket = class extends BaseModule {
|
|
|
3765
3824
|
eventEmitterInstance,
|
|
3766
3825
|
inboxServiceInstance
|
|
3767
3826
|
});
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
result: new
|
|
3827
|
+
chunkA6CBLMST_js.__privateAdd(this, _Socket_instances);
|
|
3828
|
+
chunkA6CBLMST_js.__privateAdd(this, _token2);
|
|
3829
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter11);
|
|
3830
|
+
chunkA6CBLMST_js.__privateAdd(this, _socketIo);
|
|
3831
|
+
chunkA6CBLMST_js.__privateAdd(this, _socketUrl2);
|
|
3832
|
+
chunkA6CBLMST_js.__privateAdd(this, _socketOptions2);
|
|
3833
|
+
chunkA6CBLMST_js.__privateAdd(this, _notificationReceived2, ({ message }) => {
|
|
3834
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter11).emit(NOTIFICATION_RECEIVED2, {
|
|
3835
|
+
result: new chunkTLQQB5Y7_js.Notification(mapToNotification2(message), chunkA6CBLMST_js.__privateGet(this, _emitter11), this._inboxService)
|
|
3777
3836
|
});
|
|
3778
3837
|
});
|
|
3779
|
-
|
|
3780
|
-
|
|
3838
|
+
chunkA6CBLMST_js.__privateAdd(this, _unseenCountChanged2, ({ unseenCount }) => {
|
|
3839
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter11).emit(UNSEEN_COUNT_CHANGED2, {
|
|
3781
3840
|
result: unseenCount
|
|
3782
3841
|
});
|
|
3783
3842
|
});
|
|
3784
|
-
|
|
3785
|
-
|
|
3843
|
+
chunkA6CBLMST_js.__privateAdd(this, _unreadCountChanged2, ({ counts }) => {
|
|
3844
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter11).emit(UNREAD_COUNT_CHANGED2, {
|
|
3786
3845
|
result: counts
|
|
3787
3846
|
});
|
|
3788
3847
|
});
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3848
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter11, eventEmitterInstance);
|
|
3849
|
+
chunkA6CBLMST_js.__privateSet(this, _socketUrl2, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL2);
|
|
3850
|
+
chunkA6CBLMST_js.__privateSet(this, _socketOptions2, socketOptions);
|
|
3792
3851
|
}
|
|
3793
3852
|
onSessionSuccess({ token }) {
|
|
3794
|
-
|
|
3853
|
+
chunkA6CBLMST_js.__privateSet(this, _token2, token);
|
|
3795
3854
|
}
|
|
3796
3855
|
isSocketEvent(eventName) {
|
|
3797
3856
|
return eventName === NOTIFICATION_RECEIVED2 || eventName === UNSEEN_COUNT_CHANGED2 || eventName === UNREAD_COUNT_CHANGED2;
|
|
3798
3857
|
}
|
|
3799
3858
|
connect() {
|
|
3800
|
-
return
|
|
3801
|
-
if (
|
|
3802
|
-
return
|
|
3859
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3860
|
+
if (chunkA6CBLMST_js.__privateGet(this, _token2)) {
|
|
3861
|
+
return chunkA6CBLMST_js.__privateMethod(this, _Socket_instances, handleConnectSocket_fn2).call(this);
|
|
3803
3862
|
}
|
|
3804
|
-
return this.callWithSession(
|
|
3863
|
+
return this.callWithSession(chunkA6CBLMST_js.__privateMethod(this, _Socket_instances, handleConnectSocket_fn2).bind(this));
|
|
3805
3864
|
});
|
|
3806
3865
|
}
|
|
3807
3866
|
disconnect() {
|
|
3808
|
-
return
|
|
3809
|
-
if (
|
|
3810
|
-
return
|
|
3867
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3868
|
+
if (chunkA6CBLMST_js.__privateGet(this, _socketIo)) {
|
|
3869
|
+
return chunkA6CBLMST_js.__privateMethod(this, _Socket_instances, handleDisconnectSocket_fn2).call(this);
|
|
3811
3870
|
}
|
|
3812
|
-
return this.callWithSession(
|
|
3871
|
+
return this.callWithSession(chunkA6CBLMST_js.__privateMethod(this, _Socket_instances, handleDisconnectSocket_fn2).bind(this));
|
|
3813
3872
|
});
|
|
3814
3873
|
}
|
|
3815
3874
|
};
|
|
@@ -3823,50 +3882,50 @@ _unseenCountChanged2 = new WeakMap();
|
|
|
3823
3882
|
_unreadCountChanged2 = new WeakMap();
|
|
3824
3883
|
_Socket_instances = new WeakSet();
|
|
3825
3884
|
initializeSocket_fn2 = function() {
|
|
3826
|
-
return
|
|
3885
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3827
3886
|
var _a, _b, _c, _d;
|
|
3828
|
-
if (
|
|
3887
|
+
if (chunkA6CBLMST_js.__privateGet(this, _socketIo)) {
|
|
3829
3888
|
return;
|
|
3830
3889
|
}
|
|
3831
|
-
const args = { socketUrl:
|
|
3832
|
-
|
|
3833
|
-
|
|
3890
|
+
const args = { socketUrl: chunkA6CBLMST_js.__privateGet(this, _socketUrl2) };
|
|
3891
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter11).emit("socket.connect.pending", { args });
|
|
3892
|
+
chunkA6CBLMST_js.__privateSet(this, _socketIo, io__default.default(chunkA6CBLMST_js.__privateGet(this, _socketUrl2), chunkA6CBLMST_js.__spreadValues({
|
|
3834
3893
|
reconnectionDelayMax: 1e4,
|
|
3835
3894
|
transports: ["websocket"],
|
|
3836
3895
|
query: {
|
|
3837
|
-
token: `${
|
|
3896
|
+
token: `${chunkA6CBLMST_js.__privateGet(this, _token2)}`
|
|
3838
3897
|
}
|
|
3839
|
-
}, (_a =
|
|
3840
|
-
|
|
3841
|
-
|
|
3898
|
+
}, (_a = chunkA6CBLMST_js.__privateGet(this, _socketOptions2)) != null ? _a : {})));
|
|
3899
|
+
chunkA6CBLMST_js.__privateGet(this, _socketIo).on("connect", () => {
|
|
3900
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter11).emit("socket.connect.resolved", { args });
|
|
3842
3901
|
});
|
|
3843
|
-
|
|
3844
|
-
|
|
3902
|
+
chunkA6CBLMST_js.__privateGet(this, _socketIo).on("connect_error", (error) => {
|
|
3903
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter11).emit("socket.connect.resolved", { args, error });
|
|
3845
3904
|
});
|
|
3846
|
-
(_b =
|
|
3847
|
-
(_c =
|
|
3848
|
-
(_d =
|
|
3905
|
+
(_b = chunkA6CBLMST_js.__privateGet(this, _socketIo)) == null ? void 0 : _b.on("notification_received" /* RECEIVED */, chunkA6CBLMST_js.__privateGet(this, _notificationReceived2));
|
|
3906
|
+
(_c = chunkA6CBLMST_js.__privateGet(this, _socketIo)) == null ? void 0 : _c.on("unseen_count_changed" /* UNSEEN */, chunkA6CBLMST_js.__privateGet(this, _unseenCountChanged2));
|
|
3907
|
+
(_d = chunkA6CBLMST_js.__privateGet(this, _socketIo)) == null ? void 0 : _d.on("unread_count_changed" /* UNREAD */, chunkA6CBLMST_js.__privateGet(this, _unreadCountChanged2));
|
|
3849
3908
|
});
|
|
3850
3909
|
};
|
|
3851
3910
|
handleConnectSocket_fn2 = function() {
|
|
3852
|
-
return
|
|
3911
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3853
3912
|
try {
|
|
3854
|
-
yield
|
|
3913
|
+
yield chunkA6CBLMST_js.__privateMethod(this, _Socket_instances, initializeSocket_fn2).call(this);
|
|
3855
3914
|
return {};
|
|
3856
3915
|
} catch (error) {
|
|
3857
|
-
return { error: new
|
|
3916
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to initialize the socket", error) };
|
|
3858
3917
|
}
|
|
3859
3918
|
});
|
|
3860
3919
|
};
|
|
3861
3920
|
handleDisconnectSocket_fn2 = function() {
|
|
3862
|
-
return
|
|
3921
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
3863
3922
|
var _a;
|
|
3864
3923
|
try {
|
|
3865
|
-
(_a =
|
|
3866
|
-
|
|
3924
|
+
(_a = chunkA6CBLMST_js.__privateGet(this, _socketIo)) == null ? void 0 : _a.disconnect();
|
|
3925
|
+
chunkA6CBLMST_js.__privateSet(this, _socketIo, void 0);
|
|
3867
3926
|
return {};
|
|
3868
3927
|
} catch (error) {
|
|
3869
|
-
return { error: new
|
|
3928
|
+
return { error: new chunkTLQQB5Y7_js.NovuError("Failed to disconnect from the socket", error) };
|
|
3870
3929
|
}
|
|
3871
3930
|
});
|
|
3872
3931
|
};
|
|
@@ -3907,7 +3966,7 @@ function createSocket({
|
|
|
3907
3966
|
eventEmitterInstance
|
|
3908
3967
|
}) {
|
|
3909
3968
|
const transformedSocketUrl = transformSocketUrl(socketUrl);
|
|
3910
|
-
const _a = socketOptions || {}, { socketType: explicitSocketType } = _a, restSocketOptions =
|
|
3969
|
+
const _a = socketOptions || {}, { socketType: explicitSocketType } = _a, restSocketOptions = chunkA6CBLMST_js.__objRest(_a, ["socketType"]);
|
|
3911
3970
|
const socketType = resolveSocketType(transformedSocketUrl, explicitSocketType);
|
|
3912
3971
|
switch (socketType) {
|
|
3913
3972
|
case "partysocket" /* PARTY_SOCKET */:
|
|
@@ -3932,19 +3991,19 @@ function createSocket({
|
|
|
3932
3991
|
var _emitter12, _session, _inboxService6, _options2;
|
|
3933
3992
|
var Novu = class {
|
|
3934
3993
|
constructor(options) {
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3994
|
+
chunkA6CBLMST_js.__privateAdd(this, _emitter12);
|
|
3995
|
+
chunkA6CBLMST_js.__privateAdd(this, _session);
|
|
3996
|
+
chunkA6CBLMST_js.__privateAdd(this, _inboxService6);
|
|
3997
|
+
chunkA6CBLMST_js.__privateAdd(this, _options2);
|
|
3939
3998
|
var _a, _b, _c;
|
|
3940
|
-
|
|
3941
|
-
|
|
3999
|
+
chunkA6CBLMST_js.__privateSet(this, _options2, options);
|
|
4000
|
+
chunkA6CBLMST_js.__privateSet(this, _inboxService6, new InboxService({
|
|
3942
4001
|
apiUrl: options.apiUrl || options.backendUrl
|
|
3943
4002
|
}));
|
|
3944
|
-
|
|
3945
|
-
const subscriber =
|
|
3946
|
-
const contextKey =
|
|
3947
|
-
|
|
4003
|
+
chunkA6CBLMST_js.__privateSet(this, _emitter12, new NovuEventEmitter());
|
|
4004
|
+
const subscriber = chunkTLQQB5Y7_js.buildSubscriber({ subscriberId: options.subscriberId, subscriber: options.subscriber });
|
|
4005
|
+
const contextKey = chunkTLQQB5Y7_js.buildContextKey(options.context);
|
|
4006
|
+
chunkA6CBLMST_js.__privateSet(this, _session, new Session(
|
|
3948
4007
|
{
|
|
3949
4008
|
applicationIdentifier: options.applicationIdentifier || "",
|
|
3950
4009
|
subscriberHash: options.subscriberHash,
|
|
@@ -3953,68 +4012,68 @@ var Novu = class {
|
|
|
3953
4012
|
context: options.context,
|
|
3954
4013
|
contextHash: options.contextHash
|
|
3955
4014
|
},
|
|
3956
|
-
|
|
3957
|
-
|
|
4015
|
+
chunkA6CBLMST_js.__privateGet(this, _inboxService6),
|
|
4016
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter12)
|
|
3958
4017
|
));
|
|
3959
|
-
|
|
4018
|
+
chunkA6CBLMST_js.__privateGet(this, _session).initialize();
|
|
3960
4019
|
this.notifications = new Notifications({
|
|
3961
4020
|
useCache: (_a = options.useCache) != null ? _a : true,
|
|
3962
|
-
inboxServiceInstance:
|
|
3963
|
-
eventEmitterInstance:
|
|
4021
|
+
inboxServiceInstance: chunkA6CBLMST_js.__privateGet(this, _inboxService6),
|
|
4022
|
+
eventEmitterInstance: chunkA6CBLMST_js.__privateGet(this, _emitter12)
|
|
3964
4023
|
});
|
|
3965
4024
|
this.preferences = new Preferences({
|
|
3966
4025
|
useCache: (_b = options.useCache) != null ? _b : true,
|
|
3967
|
-
inboxServiceInstance:
|
|
3968
|
-
eventEmitterInstance:
|
|
4026
|
+
inboxServiceInstance: chunkA6CBLMST_js.__privateGet(this, _inboxService6),
|
|
4027
|
+
eventEmitterInstance: chunkA6CBLMST_js.__privateGet(this, _emitter12)
|
|
3969
4028
|
});
|
|
3970
4029
|
this.subscriptions = new Subscriptions({
|
|
3971
4030
|
subscriber,
|
|
3972
4031
|
contextKey,
|
|
3973
4032
|
useCache: (_c = options.useCache) != null ? _c : true,
|
|
3974
|
-
inboxServiceInstance:
|
|
3975
|
-
eventEmitterInstance:
|
|
4033
|
+
inboxServiceInstance: chunkA6CBLMST_js.__privateGet(this, _inboxService6),
|
|
4034
|
+
eventEmitterInstance: chunkA6CBLMST_js.__privateGet(this, _emitter12)
|
|
3976
4035
|
});
|
|
3977
4036
|
this.channelConnections = new ChannelConnections({
|
|
3978
|
-
inboxServiceInstance:
|
|
3979
|
-
eventEmitterInstance:
|
|
4037
|
+
inboxServiceInstance: chunkA6CBLMST_js.__privateGet(this, _inboxService6),
|
|
4038
|
+
eventEmitterInstance: chunkA6CBLMST_js.__privateGet(this, _emitter12)
|
|
3980
4039
|
});
|
|
3981
4040
|
this.channelEndpoints = new ChannelEndpoints({
|
|
3982
|
-
inboxServiceInstance:
|
|
3983
|
-
eventEmitterInstance:
|
|
4041
|
+
inboxServiceInstance: chunkA6CBLMST_js.__privateGet(this, _inboxService6),
|
|
4042
|
+
eventEmitterInstance: chunkA6CBLMST_js.__privateGet(this, _emitter12)
|
|
3984
4043
|
});
|
|
3985
4044
|
this.socket = createSocket({
|
|
3986
4045
|
socketUrl: options.socketUrl,
|
|
3987
4046
|
socketOptions: options.socketOptions,
|
|
3988
|
-
eventEmitterInstance:
|
|
3989
|
-
inboxServiceInstance:
|
|
4047
|
+
eventEmitterInstance: chunkA6CBLMST_js.__privateGet(this, _emitter12),
|
|
4048
|
+
inboxServiceInstance: chunkA6CBLMST_js.__privateGet(this, _inboxService6)
|
|
3990
4049
|
});
|
|
3991
4050
|
this.on = (eventName, listener) => {
|
|
3992
4051
|
if (this.socket.isSocketEvent(eventName)) {
|
|
3993
4052
|
this.socket.connect();
|
|
3994
4053
|
}
|
|
3995
|
-
const cleanup =
|
|
4054
|
+
const cleanup = chunkA6CBLMST_js.__privateGet(this, _emitter12).on(eventName, listener);
|
|
3996
4055
|
return () => {
|
|
3997
4056
|
cleanup();
|
|
3998
4057
|
};
|
|
3999
4058
|
};
|
|
4000
4059
|
this.off = (eventName, listener) => {
|
|
4001
|
-
|
|
4060
|
+
chunkA6CBLMST_js.__privateGet(this, _emitter12).off(eventName, listener);
|
|
4002
4061
|
};
|
|
4003
4062
|
}
|
|
4004
4063
|
get applicationIdentifier() {
|
|
4005
|
-
return
|
|
4064
|
+
return chunkA6CBLMST_js.__privateGet(this, _session).applicationIdentifier;
|
|
4006
4065
|
}
|
|
4007
4066
|
get subscriberId() {
|
|
4008
|
-
return
|
|
4067
|
+
return chunkA6CBLMST_js.__privateGet(this, _session).subscriberId;
|
|
4009
4068
|
}
|
|
4010
4069
|
get context() {
|
|
4011
|
-
return
|
|
4070
|
+
return chunkA6CBLMST_js.__privateGet(this, _session).context;
|
|
4012
4071
|
}
|
|
4013
4072
|
get options() {
|
|
4014
|
-
return
|
|
4073
|
+
return chunkA6CBLMST_js.__privateGet(this, _options2);
|
|
4015
4074
|
}
|
|
4016
4075
|
get contextKey() {
|
|
4017
|
-
return
|
|
4076
|
+
return chunkTLQQB5Y7_js.buildContextKey(chunkA6CBLMST_js.__privateGet(this, _session).context);
|
|
4018
4077
|
}
|
|
4019
4078
|
clearCache() {
|
|
4020
4079
|
this.notifications.cache.clearAll();
|
|
@@ -4026,14 +4085,14 @@ var Novu = class {
|
|
|
4026
4085
|
* @deprecated
|
|
4027
4086
|
*/
|
|
4028
4087
|
changeSubscriber(options) {
|
|
4029
|
-
return
|
|
4030
|
-
yield
|
|
4031
|
-
applicationIdentifier:
|
|
4088
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
4089
|
+
yield chunkA6CBLMST_js.__privateGet(this, _session).initialize({
|
|
4090
|
+
applicationIdentifier: chunkA6CBLMST_js.__privateGet(this, _session).applicationIdentifier || "",
|
|
4032
4091
|
subscriberHash: options.subscriberHash,
|
|
4033
4092
|
subscriber: options.subscriber,
|
|
4034
4093
|
// Preserve existing context and contextHash
|
|
4035
|
-
context:
|
|
4036
|
-
contextHash:
|
|
4094
|
+
context: chunkA6CBLMST_js.__privateGet(this, _session).context,
|
|
4095
|
+
contextHash: chunkA6CBLMST_js.__privateGet(this, _session).contextHash
|
|
4037
4096
|
});
|
|
4038
4097
|
this.clearCache();
|
|
4039
4098
|
const disconnectResult = yield this.socket.disconnect();
|
|
@@ -4046,15 +4105,15 @@ var Novu = class {
|
|
|
4046
4105
|
* @deprecated
|
|
4047
4106
|
*/
|
|
4048
4107
|
changeContext(options) {
|
|
4049
|
-
return
|
|
4050
|
-
const currentSubscriber =
|
|
4108
|
+
return chunkA6CBLMST_js.__async(this, null, function* () {
|
|
4109
|
+
const currentSubscriber = chunkA6CBLMST_js.__privateGet(this, _session).subscriber;
|
|
4051
4110
|
if (!currentSubscriber) {
|
|
4052
4111
|
throw new Error("Cannot change context without an active subscriber");
|
|
4053
4112
|
}
|
|
4054
|
-
yield
|
|
4055
|
-
applicationIdentifier:
|
|
4113
|
+
yield chunkA6CBLMST_js.__privateGet(this, _session).initialize({
|
|
4114
|
+
applicationIdentifier: chunkA6CBLMST_js.__privateGet(this, _session).applicationIdentifier || "",
|
|
4056
4115
|
// Preserve existing subscriber and subscriberHash
|
|
4057
|
-
subscriberHash:
|
|
4116
|
+
subscriberHash: chunkA6CBLMST_js.__privateGet(this, _session).subscriberHash,
|
|
4058
4117
|
subscriber: currentSubscriber,
|
|
4059
4118
|
context: options.context,
|
|
4060
4119
|
contextHash: options.contextHash
|
|
@@ -4072,7 +4131,25 @@ _session = new WeakMap();
|
|
|
4072
4131
|
_inboxService6 = new WeakMap();
|
|
4073
4132
|
_options2 = new WeakMap();
|
|
4074
4133
|
|
|
4134
|
+
// src/notifications/count-sync-events.ts
|
|
4135
|
+
var NOTIFICATION_COUNT_SYNC_EVENTS = [
|
|
4136
|
+
"notification.read.resolved",
|
|
4137
|
+
"notification.unread.resolved",
|
|
4138
|
+
"notification.seen.resolved",
|
|
4139
|
+
"notification.archive.resolved",
|
|
4140
|
+
"notification.unarchive.resolved",
|
|
4141
|
+
"notification.snooze.resolved",
|
|
4142
|
+
"notification.unsnooze.resolved",
|
|
4143
|
+
"notification.delete.resolved",
|
|
4144
|
+
"notifications.read_all.resolved",
|
|
4145
|
+
"notifications.seen_all.resolved",
|
|
4146
|
+
"notifications.archive_all.resolved",
|
|
4147
|
+
"notifications.archive_all_read.resolved",
|
|
4148
|
+
"notifications.delete_all.resolved"
|
|
4149
|
+
];
|
|
4150
|
+
|
|
4075
4151
|
exports.DEFAULT_API_VERSION = DEFAULT_API_VERSION;
|
|
4152
|
+
exports.NOTIFICATION_COUNT_SYNC_EVENTS = NOTIFICATION_COUNT_SYNC_EVENTS;
|
|
4076
4153
|
exports.Novu = Novu;
|
|
4077
4154
|
exports.SubscriptionPreference = SubscriptionPreference;
|
|
4078
4155
|
exports.TopicSubscription = TopicSubscription;
|
|
@@ -4080,7 +4157,8 @@ exports.areSeveritiesEqual = areSeveritiesEqual;
|
|
|
4080
4157
|
exports.areTagsEqual = areTagsEqual;
|
|
4081
4158
|
exports.checkNotificationDataFilter = checkNotificationDataFilter;
|
|
4082
4159
|
exports.checkNotificationMatchesFilter = checkNotificationMatchesFilter;
|
|
4083
|
-
exports.checkNotificationTagFilter = checkNotificationTagFilter;
|
|
4084
4160
|
exports.isBrowser = isBrowser;
|
|
4085
4161
|
exports.isSameFilter = isSameFilter;
|
|
4162
|
+
exports.isValidInAppRedirectTarget = isValidInAppRedirectTarget;
|
|
4163
|
+
exports.isValidInAppRedirectUrl = isValidInAppRedirectUrl;
|
|
4086
4164
|
exports.normalizeTagGroups = normalizeTagGroups;
|