@novu/js 3.11.0-rc.1 → 3.12.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{chunk-VWSQDNZX.js → chunk-OZV3TKWX.js} +6 -0
- package/dist/cjs/{chunk-TROJWAJA.js → chunk-SZEUW4CB.js} +1070 -309
- package/dist/cjs/index.d.ts +5 -4
- package/dist/cjs/index.js +26 -14
- package/dist/cjs/internal/index.d.ts +8 -2
- package/dist/cjs/internal/index.js +8 -4
- package/dist/{esm/novu-DY-mm8Og.d.mts → cjs/novu-BVtCFUxa.d.ts} +398 -203
- package/dist/cjs/themes/index.d.ts +11 -5
- package/dist/cjs/themes/index.js +17 -1
- package/dist/{esm/types-BM_9Xx5Z.d.mts → cjs/types-D-9ozWeQ.d.ts} +20 -1
- package/dist/cjs/types-Rjzg7eo3.d.ts +836 -0
- package/dist/cjs/ui/index.d.ts +74 -7
- package/dist/cjs/ui/index.js +1786 -261
- package/dist/esm/{chunk-D4W52D4A.mjs → chunk-IA6ISHOP.mjs} +1068 -310
- package/dist/esm/{chunk-RZWQYM3H.mjs → chunk-RO3GDYAG.mjs} +6 -1
- package/dist/esm/index.d.mts +5 -4
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/internal/index.d.mts +8 -2
- package/dist/esm/internal/index.mjs +1 -1
- package/dist/{cjs/novu-ThMWeiRt.d.ts → esm/novu-YP3PwsQR.d.mts} +398 -203
- package/dist/esm/themes/index.d.mts +11 -5
- package/dist/esm/themes/index.mjs +16 -2
- package/dist/{cjs/types-BM_9Xx5Z.d.ts → esm/types-D-9ozWeQ.d.mts} +20 -1
- package/dist/esm/types-DmMJ1GiR.d.mts +836 -0
- package/dist/esm/ui/index.d.mts +74 -7
- package/dist/esm/ui/index.mjs +1783 -257
- package/dist/index.css +1 -1
- package/dist/novu.min.js +12 -12
- package/dist/novu.min.js.gz +0 -0
- package/package.json +18 -17
- package/dist/cjs/types-BjANCN3c.d.ts +0 -537
- package/dist/esm/types-C5eX1GmB.d.mts +0 -537
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOZV3TKWX_js = require('./chunk-OZV3TKWX.js');
|
|
4
4
|
var chunk7B52C2XE_js = require('./chunk-7B52C2XE.js');
|
|
5
5
|
var mitt = require('mitt');
|
|
6
6
|
require('event-target-polyfill');
|
|
@@ -55,6 +55,14 @@ var WorkflowCriticalityEnum = /* @__PURE__ */ ((WorkflowCriticalityEnum2) => {
|
|
|
55
55
|
return WorkflowCriticalityEnum2;
|
|
56
56
|
})(WorkflowCriticalityEnum || {});
|
|
57
57
|
|
|
58
|
+
// src/utils/errors.ts
|
|
59
|
+
var NovuError = class extends Error {
|
|
60
|
+
constructor(message, originalError) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.originalError = originalError;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
58
66
|
// src/utils/arrays.ts
|
|
59
67
|
var arrayValuesEqual = (arr1, arr2) => {
|
|
60
68
|
if (arr1 === arr2) {
|
|
@@ -131,24 +139,788 @@ function checkBasicFilters(notification, filter) {
|
|
|
131
139
|
if (filter.read !== void 0 && notification.isRead !== filter.read) {
|
|
132
140
|
return false;
|
|
133
141
|
}
|
|
134
|
-
if (filter.seen !== void 0 && notification.isSeen !== filter.seen) {
|
|
135
|
-
return false;
|
|
142
|
+
if (filter.seen !== void 0 && notification.isSeen !== filter.seen) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
if (filter.archived !== void 0 && notification.isArchived !== filter.archived) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if (filter.snoozed !== void 0 && notification.isSnoozed !== filter.snoozed) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
function checkNotificationMatchesFilter(notification, filter) {
|
|
154
|
+
return checkBasicFilters(notification, filter) && checkNotificationTagFilter(notification.tags, filter.tags) && checkNotificationDataFilter(notification.data, filter.data);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/subscriptions/subscription.ts
|
|
158
|
+
var _emitter, _inboxService, _cache, _useCache, _isStale;
|
|
159
|
+
var TopicSubscription = class {
|
|
160
|
+
constructor(subscription, emitter, inboxService, cache, useCache) {
|
|
161
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter);
|
|
162
|
+
chunk7B52C2XE_js.__privateAdd(this, _inboxService);
|
|
163
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache);
|
|
164
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache);
|
|
165
|
+
chunk7B52C2XE_js.__privateAdd(this, _isStale, false);
|
|
166
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter, emitter);
|
|
167
|
+
chunk7B52C2XE_js.__privateSet(this, _inboxService, inboxService);
|
|
168
|
+
chunk7B52C2XE_js.__privateSet(this, _cache, cache);
|
|
169
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache, useCache);
|
|
170
|
+
this.id = subscription.id;
|
|
171
|
+
this.identifier = subscription.identifier;
|
|
172
|
+
this.topicKey = subscription.topicKey;
|
|
173
|
+
this.preferences = subscription.preferences.map(
|
|
174
|
+
(pref) => new SubscriptionPreference(chunk7B52C2XE_js.__spreadValues({}, pref), chunk7B52C2XE_js.__privateGet(this, _emitter), chunk7B52C2XE_js.__privateGet(this, _inboxService), chunk7B52C2XE_js.__privateGet(this, _cache), chunk7B52C2XE_js.__privateGet(this, _useCache))
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
update(args) {
|
|
178
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
179
|
+
return updateSubscription({
|
|
180
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
181
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
182
|
+
cache: chunk7B52C2XE_js.__privateGet(this, _cache),
|
|
183
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache),
|
|
184
|
+
args: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, args), { subscription: this })
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
updatePreference(args) {
|
|
189
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
190
|
+
if (chunk7B52C2XE_js.__privateGet(this, _isStale)) {
|
|
191
|
+
return {
|
|
192
|
+
error: new NovuError("Cannot update a deleted subscription", new Error("Subscription is stale"))
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return updateSubscriptionPreference({
|
|
196
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
197
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
198
|
+
cache: chunk7B52C2XE_js.__privateGet(this, _cache),
|
|
199
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache),
|
|
200
|
+
args: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, args), { subscriptionId: this.id })
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
bulkUpdatePreferences(args) {
|
|
205
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
206
|
+
if (chunk7B52C2XE_js.__privateGet(this, _isStale)) {
|
|
207
|
+
return {
|
|
208
|
+
error: new NovuError("Cannot bulk update a deleted subscription", new Error("Subscription is stale"))
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return bulkUpdateSubscriptionPreference({
|
|
212
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
213
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
214
|
+
cache: chunk7B52C2XE_js.__privateGet(this, _cache),
|
|
215
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache),
|
|
216
|
+
args: args.map((arg) => chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, arg), { subscriptionId: this.id }))
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
delete() {
|
|
221
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
222
|
+
if (chunk7B52C2XE_js.__privateGet(this, _isStale)) {
|
|
223
|
+
return {
|
|
224
|
+
error: new NovuError("Cannot delete an already deleted subscription", new Error("Subscription is stale"))
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
return deleteSubscription({
|
|
228
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
229
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
230
|
+
args: { subscription: this }
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
_emitter = new WeakMap();
|
|
236
|
+
_inboxService = new WeakMap();
|
|
237
|
+
_cache = new WeakMap();
|
|
238
|
+
_useCache = new WeakMap();
|
|
239
|
+
_isStale = new WeakMap();
|
|
240
|
+
|
|
241
|
+
// src/subscriptions/helpers.ts
|
|
242
|
+
var listSubscriptions = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
243
|
+
emitter,
|
|
244
|
+
apiService,
|
|
245
|
+
cache,
|
|
246
|
+
options,
|
|
247
|
+
args
|
|
248
|
+
}) {
|
|
249
|
+
try {
|
|
250
|
+
const { useCache, refetch } = options;
|
|
251
|
+
let data = useCache && !refetch ? cache.getAll(args) : void 0;
|
|
252
|
+
emitter.emit("subscriptions.list.pending", { args, data });
|
|
253
|
+
if (!data || refetch) {
|
|
254
|
+
const response = yield apiService.fetchSubscriptions(args.topicKey);
|
|
255
|
+
data = response.map((el) => {
|
|
256
|
+
return new TopicSubscription(chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, el), { topicKey: args.topicKey }), emitter, apiService, cache, useCache);
|
|
257
|
+
});
|
|
258
|
+
if (useCache) {
|
|
259
|
+
cache.set(args, data);
|
|
260
|
+
data = cache.getAll(args);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
emitter.emit("subscriptions.list.resolved", { args, data });
|
|
264
|
+
return { data };
|
|
265
|
+
} catch (error) {
|
|
266
|
+
emitter.emit("subscriptions.list.resolved", { args, error });
|
|
267
|
+
return { error: new NovuError("Failed to fetch subscriptions", error) };
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
var getSubscription = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
271
|
+
emitter,
|
|
272
|
+
apiService,
|
|
273
|
+
cache,
|
|
274
|
+
options,
|
|
275
|
+
args
|
|
276
|
+
}) {
|
|
277
|
+
try {
|
|
278
|
+
const { useCache, refetch } = options;
|
|
279
|
+
let data = useCache && !refetch ? cache.get(args) : void 0;
|
|
280
|
+
emitter.emit("subscription.get.pending", { args, data });
|
|
281
|
+
if (!data || refetch) {
|
|
282
|
+
const response = yield apiService.getSubscription({
|
|
283
|
+
topicKey: args.topicKey,
|
|
284
|
+
identifier: args.identifier
|
|
285
|
+
});
|
|
286
|
+
if (!response) {
|
|
287
|
+
emitter.emit("subscription.get.resolved", { args, data: null });
|
|
288
|
+
return { data: null };
|
|
289
|
+
}
|
|
290
|
+
data = new TopicSubscription(chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, response), { topicKey: args.topicKey }), emitter, apiService, cache, useCache);
|
|
291
|
+
if (useCache) {
|
|
292
|
+
cache.setOne(args, data);
|
|
293
|
+
data = cache.get(args);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
emitter.emit("subscription.get.resolved", { args, data });
|
|
297
|
+
return { data };
|
|
298
|
+
} catch (error) {
|
|
299
|
+
emitter.emit("subscription.get.resolved", { args, error });
|
|
300
|
+
return { error: new NovuError("Failed to fetch subscription", error) };
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
var createSubscription = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
304
|
+
emitter,
|
|
305
|
+
apiService,
|
|
306
|
+
cache,
|
|
307
|
+
useCache,
|
|
308
|
+
args
|
|
309
|
+
}) {
|
|
310
|
+
var _a;
|
|
311
|
+
try {
|
|
312
|
+
emitter.emit("subscription.create.pending", { args });
|
|
313
|
+
const response = yield apiService.createSubscription({
|
|
314
|
+
identifier: (_a = args.identifier) != null ? _a : "",
|
|
315
|
+
name: args.name,
|
|
316
|
+
topicKey: args.topicKey,
|
|
317
|
+
topicName: args.topicName,
|
|
318
|
+
preferences: args.preferences
|
|
319
|
+
});
|
|
320
|
+
const subscription = new TopicSubscription(
|
|
321
|
+
chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, response), { topicKey: args.topicKey }),
|
|
322
|
+
emitter,
|
|
323
|
+
apiService,
|
|
324
|
+
cache,
|
|
325
|
+
useCache
|
|
326
|
+
);
|
|
327
|
+
emitter.emit("subscription.create.resolved", { args, data: subscription });
|
|
328
|
+
return { data: subscription };
|
|
329
|
+
} catch (error) {
|
|
330
|
+
emitter.emit("subscription.create.resolved", { args, error });
|
|
331
|
+
return { error: new NovuError("Failed to create subscription", error) };
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
var updateSubscription = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
335
|
+
emitter,
|
|
336
|
+
apiService,
|
|
337
|
+
cache,
|
|
338
|
+
useCache,
|
|
339
|
+
args
|
|
340
|
+
}) {
|
|
341
|
+
const subscriptionId = "subscriptionId" in args ? args.subscriptionId : args.subscription.id;
|
|
342
|
+
const topicKey = "topicKey" in args ? args.topicKey : args.subscription.topicKey;
|
|
343
|
+
try {
|
|
344
|
+
emitter.emit("subscription.update.pending", {
|
|
345
|
+
args
|
|
346
|
+
});
|
|
347
|
+
const response = yield apiService.updateSubscription({
|
|
348
|
+
topicKey,
|
|
349
|
+
subscriptionId,
|
|
350
|
+
name: args.name,
|
|
351
|
+
preferences: args.preferences
|
|
352
|
+
});
|
|
353
|
+
const updatedSubscription = new TopicSubscription(chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, response), { topicKey }), emitter, apiService, cache, useCache);
|
|
354
|
+
emitter.emit("subscription.update.resolved", { args, data: updatedSubscription });
|
|
355
|
+
return { data: updatedSubscription };
|
|
356
|
+
} catch (error) {
|
|
357
|
+
emitter.emit("subscription.update.resolved", { args, error });
|
|
358
|
+
return { error: new NovuError("Failed to update subscription", error) };
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
var updateSubscriptionPreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
362
|
+
emitter,
|
|
363
|
+
apiService,
|
|
364
|
+
cache,
|
|
365
|
+
useCache,
|
|
366
|
+
args
|
|
367
|
+
}) {
|
|
368
|
+
var _a, _b;
|
|
369
|
+
const workflowId = "workflowId" in args ? args.workflowId : (_b = (_a = args.preference) == null ? void 0 : _a.workflow) == null ? void 0 : _b.id;
|
|
370
|
+
try {
|
|
371
|
+
emitter.emit("subscription.preference.update.pending", {
|
|
372
|
+
args,
|
|
373
|
+
data: "preference" in args ? new SubscriptionPreference(
|
|
374
|
+
chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, args.preference), typeof args.value === "boolean" ? { enabled: args.value } : { condition: args.value }),
|
|
375
|
+
emitter,
|
|
376
|
+
apiService,
|
|
377
|
+
cache,
|
|
378
|
+
useCache
|
|
379
|
+
) : void 0
|
|
380
|
+
});
|
|
381
|
+
const response = yield apiService.updateSubscriptionPreference(chunk7B52C2XE_js.__spreadValues({
|
|
382
|
+
subscriptionId: args.subscriptionId,
|
|
383
|
+
workflowId
|
|
384
|
+
}, typeof args.value === "boolean" ? { enabled: args.value } : { condition: args.value }));
|
|
385
|
+
const updatedSubscription = new SubscriptionPreference(chunk7B52C2XE_js.__spreadValues({}, response), emitter, apiService, cache, useCache);
|
|
386
|
+
emitter.emit("subscription.preference.update.resolved", { args, data: updatedSubscription });
|
|
387
|
+
return { data: updatedSubscription };
|
|
388
|
+
} catch (error) {
|
|
389
|
+
emitter.emit("subscription.preference.update.resolved", { args, error });
|
|
390
|
+
return { error: new NovuError("Failed to update subscription", error) };
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
var bulkUpdateSubscriptionPreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
394
|
+
emitter,
|
|
395
|
+
apiService,
|
|
396
|
+
cache,
|
|
397
|
+
useCache,
|
|
398
|
+
args
|
|
399
|
+
}) {
|
|
400
|
+
try {
|
|
401
|
+
const optimisticallyUpdatedPreferences = args.map(
|
|
402
|
+
(arg) => "preference" in arg ? new SubscriptionPreference(
|
|
403
|
+
chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, arg.preference), typeof arg.value === "boolean" ? { enabled: arg.value } : { condition: arg.value }),
|
|
404
|
+
emitter,
|
|
405
|
+
apiService,
|
|
406
|
+
cache,
|
|
407
|
+
useCache
|
|
408
|
+
) : void 0
|
|
409
|
+
).filter((el) => el !== void 0);
|
|
410
|
+
emitter.emit("subscription.preferences.bulk_update.pending", {
|
|
411
|
+
args,
|
|
412
|
+
data: optimisticallyUpdatedPreferences
|
|
413
|
+
});
|
|
414
|
+
const preferencesToUpdate = args.map((arg) => {
|
|
415
|
+
var _a, _b, _c, _d, _e, _f;
|
|
416
|
+
return chunk7B52C2XE_js.__spreadValues({
|
|
417
|
+
subscriptionIdOrIdentifier: arg.subscriptionId,
|
|
418
|
+
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 : ""
|
|
419
|
+
}, typeof arg.value === "boolean" ? { enabled: arg.value } : { condition: arg.value });
|
|
420
|
+
});
|
|
421
|
+
const response = yield apiService.bulkUpdateSubscriptionPreferences(preferencesToUpdate);
|
|
422
|
+
const preferences = response.map((el) => new SubscriptionPreference(el, emitter, apiService, cache, useCache));
|
|
423
|
+
emitter.emit("subscription.preferences.bulk_update.resolved", { args, data: preferences });
|
|
424
|
+
return { data: preferences };
|
|
425
|
+
} catch (error) {
|
|
426
|
+
emitter.emit("subscription.preferences.bulk_update.resolved", { args, error });
|
|
427
|
+
return { error: new NovuError("Failed to bulk update subscription preferences", error) };
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
var deleteSubscription = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
431
|
+
emitter,
|
|
432
|
+
apiService,
|
|
433
|
+
args
|
|
434
|
+
}) {
|
|
435
|
+
const subscriptionId = "subscriptionId" in args ? args.subscriptionId : args.subscription.id;
|
|
436
|
+
const topicKey = "topicKey" in args ? args.topicKey : args.subscription.topicKey;
|
|
437
|
+
try {
|
|
438
|
+
emitter.emit("subscription.delete.pending", { args });
|
|
439
|
+
yield apiService.deleteSubscription({ topicKey, subscriptionId });
|
|
440
|
+
emitter.emit("subscription.delete.resolved", { args });
|
|
441
|
+
return { data: void 0 };
|
|
442
|
+
} catch (error) {
|
|
443
|
+
emitter.emit("subscription.delete.resolved", { args, error });
|
|
444
|
+
return { error: new NovuError("Failed to delete subscription", error) };
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
// src/subscriptions/subscription-preference.ts
|
|
449
|
+
var _emitter2, _inboxService2, _cache2, _useCache2;
|
|
450
|
+
var SubscriptionPreference = class {
|
|
451
|
+
constructor(preference, emitter, inboxService, cache, useCache) {
|
|
452
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter2);
|
|
453
|
+
chunk7B52C2XE_js.__privateAdd(this, _inboxService2);
|
|
454
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache2);
|
|
455
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache2);
|
|
456
|
+
var _a;
|
|
457
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter2, emitter);
|
|
458
|
+
chunk7B52C2XE_js.__privateSet(this, _inboxService2, inboxService);
|
|
459
|
+
chunk7B52C2XE_js.__privateSet(this, _cache2, cache);
|
|
460
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache2, useCache);
|
|
461
|
+
this.enabled = preference.enabled;
|
|
462
|
+
this.condition = (_a = preference.condition) != null ? _a : void 0;
|
|
463
|
+
this.workflow = preference.workflow;
|
|
464
|
+
this.subscriptionId = preference.subscriptionId;
|
|
465
|
+
}
|
|
466
|
+
update(args) {
|
|
467
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
468
|
+
var _a;
|
|
469
|
+
return updateSubscriptionPreference({
|
|
470
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter2),
|
|
471
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService2),
|
|
472
|
+
cache: chunk7B52C2XE_js.__privateGet(this, _cache2),
|
|
473
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache2),
|
|
474
|
+
args: {
|
|
475
|
+
subscriptionId: this.subscriptionId,
|
|
476
|
+
workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
|
|
477
|
+
value: args.value,
|
|
478
|
+
preference: this
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
_emitter2 = new WeakMap();
|
|
485
|
+
_inboxService2 = new WeakMap();
|
|
486
|
+
_cache2 = new WeakMap();
|
|
487
|
+
_useCache2 = new WeakMap();
|
|
488
|
+
|
|
489
|
+
// src/base-module.ts
|
|
490
|
+
var _callsQueue, _sessionError;
|
|
491
|
+
var BaseModule = class {
|
|
492
|
+
constructor({
|
|
493
|
+
inboxServiceInstance,
|
|
494
|
+
eventEmitterInstance
|
|
495
|
+
}) {
|
|
496
|
+
chunk7B52C2XE_js.__privateAdd(this, _callsQueue, []);
|
|
497
|
+
chunk7B52C2XE_js.__privateAdd(this, _sessionError);
|
|
498
|
+
this._emitter = eventEmitterInstance;
|
|
499
|
+
this._inboxService = inboxServiceInstance;
|
|
500
|
+
this._emitter.on("session.initialize.resolved", ({ error, data }) => {
|
|
501
|
+
if (data) {
|
|
502
|
+
this.onSessionSuccess(data);
|
|
503
|
+
chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach((_0) => chunk7B52C2XE_js.__async(this, [_0], function* ({ fn, resolve }) {
|
|
504
|
+
resolve(yield fn());
|
|
505
|
+
}));
|
|
506
|
+
chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
|
|
507
|
+
} else if (error) {
|
|
508
|
+
this.onSessionError(error);
|
|
509
|
+
chunk7B52C2XE_js.__privateSet(this, _sessionError, error);
|
|
510
|
+
chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach(({ resolve }) => {
|
|
511
|
+
resolve({ error: new NovuError("Failed to initialize session, please contact the support", error) });
|
|
512
|
+
});
|
|
513
|
+
chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
onSessionSuccess(_) {
|
|
518
|
+
}
|
|
519
|
+
onSessionError(_) {
|
|
520
|
+
}
|
|
521
|
+
callWithSession(fn) {
|
|
522
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
523
|
+
if (this._inboxService.isSessionInitialized) {
|
|
524
|
+
return fn();
|
|
525
|
+
}
|
|
526
|
+
if (chunk7B52C2XE_js.__privateGet(this, _sessionError)) {
|
|
527
|
+
return Promise.resolve({
|
|
528
|
+
error: new NovuError("Failed to initialize session, please contact the support", chunk7B52C2XE_js.__privateGet(this, _sessionError))
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
return new Promise((resolve, reject) => {
|
|
532
|
+
chunk7B52C2XE_js.__privateGet(this, _callsQueue).push({ fn, resolve, reject });
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
_callsQueue = new WeakMap();
|
|
538
|
+
_sessionError = new WeakMap();
|
|
539
|
+
|
|
540
|
+
// src/cache/in-memory-cache.ts
|
|
541
|
+
var _cache3;
|
|
542
|
+
var InMemoryCache = class {
|
|
543
|
+
constructor() {
|
|
544
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache3);
|
|
545
|
+
chunk7B52C2XE_js.__privateSet(this, _cache3, /* @__PURE__ */ new Map());
|
|
546
|
+
}
|
|
547
|
+
get(key) {
|
|
548
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache3).get(key);
|
|
549
|
+
}
|
|
550
|
+
getValues() {
|
|
551
|
+
return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache3).values());
|
|
552
|
+
}
|
|
553
|
+
entries() {
|
|
554
|
+
return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache3).entries());
|
|
555
|
+
}
|
|
556
|
+
keys() {
|
|
557
|
+
return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache3).keys());
|
|
558
|
+
}
|
|
559
|
+
set(key, value) {
|
|
560
|
+
chunk7B52C2XE_js.__privateGet(this, _cache3).set(key, value);
|
|
561
|
+
}
|
|
562
|
+
remove(key) {
|
|
563
|
+
chunk7B52C2XE_js.__privateGet(this, _cache3).delete(key);
|
|
564
|
+
}
|
|
565
|
+
clear() {
|
|
566
|
+
chunk7B52C2XE_js.__privateGet(this, _cache3).clear();
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
_cache3 = new WeakMap();
|
|
570
|
+
|
|
571
|
+
// src/cache/subscriptions-cache.ts
|
|
572
|
+
var getListCacheKey = (args) => {
|
|
573
|
+
return `list:${args.topicKey}`;
|
|
574
|
+
};
|
|
575
|
+
var getTopicKeyFromListCacheKey = (key) => {
|
|
576
|
+
return key.split(":")[1];
|
|
577
|
+
};
|
|
578
|
+
var getItemCacheKey = (args) => {
|
|
579
|
+
return `item:${args.topicKey}:${args.identifier}`;
|
|
580
|
+
};
|
|
581
|
+
var _emitter3, _cache4, _useCache3, _itemCache, _inboxService3;
|
|
582
|
+
var SubscriptionsCache = class {
|
|
583
|
+
constructor({
|
|
584
|
+
emitterInstance,
|
|
585
|
+
inboxServiceInstance,
|
|
586
|
+
useCache
|
|
587
|
+
}) {
|
|
588
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter3);
|
|
589
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache4);
|
|
590
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache3);
|
|
591
|
+
chunk7B52C2XE_js.__privateAdd(this, _itemCache);
|
|
592
|
+
chunk7B52C2XE_js.__privateAdd(this, _inboxService3);
|
|
593
|
+
this.handleCreate = (subscription) => {
|
|
594
|
+
const listKey = getListCacheKey({ topicKey: subscription.topicKey });
|
|
595
|
+
const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
|
|
596
|
+
if (subscriptions) {
|
|
597
|
+
const updatedSubscriptions = [...subscriptions, subscription];
|
|
598
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
|
|
599
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
|
|
600
|
+
data: { topicKey: subscription.topicKey, subscriptions: updatedSubscriptions }
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).set(
|
|
604
|
+
getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier }),
|
|
605
|
+
subscription
|
|
606
|
+
);
|
|
607
|
+
};
|
|
608
|
+
this.handleUpdate = (subscription) => {
|
|
609
|
+
const listKey = getListCacheKey({ topicKey: subscription.topicKey });
|
|
610
|
+
const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
|
|
611
|
+
if (subscriptions) {
|
|
612
|
+
const updatedSubscriptions = subscriptions.map((el) => el.id === subscription.id ? subscription : el);
|
|
613
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
|
|
614
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
|
|
615
|
+
data: { topicKey: subscription.topicKey, subscriptions: updatedSubscriptions }
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).set(
|
|
619
|
+
getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier }),
|
|
620
|
+
subscription
|
|
621
|
+
);
|
|
622
|
+
};
|
|
623
|
+
this.handlePreferenceUpdate = (preference) => {
|
|
624
|
+
this.updateSubscriptionPreferences([preference]);
|
|
625
|
+
};
|
|
626
|
+
this.handleBulkPreferenceUpdate = (preferences) => {
|
|
627
|
+
this.updateSubscriptionPreferences(preferences);
|
|
628
|
+
};
|
|
629
|
+
this.updateSubscriptionPreferences = (updatedPreferences) => {
|
|
630
|
+
var _a;
|
|
631
|
+
const preferencesBySubscription = /* @__PURE__ */ new Map();
|
|
632
|
+
for (const pref of updatedPreferences) {
|
|
633
|
+
const existing = (_a = preferencesBySubscription.get(pref.subscriptionId)) != null ? _a : [];
|
|
634
|
+
existing.push(pref);
|
|
635
|
+
preferencesBySubscription.set(pref.subscriptionId, existing);
|
|
636
|
+
}
|
|
637
|
+
const allListKeys = chunk7B52C2XE_js.__privateGet(this, _cache4).keys();
|
|
638
|
+
for (const listKey of allListKeys) {
|
|
639
|
+
const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
|
|
640
|
+
if (!subscriptions) continue;
|
|
641
|
+
let hasUpdates = false;
|
|
642
|
+
const updatedSubscriptions = subscriptions.map((subscription) => {
|
|
643
|
+
const subscriptionPreferences = preferencesBySubscription.get(subscription.id);
|
|
644
|
+
if (subscriptionPreferences) {
|
|
645
|
+
hasUpdates = true;
|
|
646
|
+
return this.createUpdatedSubscription(subscription, subscriptionPreferences);
|
|
647
|
+
}
|
|
648
|
+
return subscription;
|
|
649
|
+
});
|
|
650
|
+
if (hasUpdates) {
|
|
651
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
|
|
652
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
|
|
653
|
+
data: { topicKey: getTopicKeyFromListCacheKey(listKey), subscriptions: updatedSubscriptions }
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const allItemKeys = chunk7B52C2XE_js.__privateGet(this, _itemCache).keys();
|
|
658
|
+
for (const key of allItemKeys) {
|
|
659
|
+
const subscription = chunk7B52C2XE_js.__privateGet(this, _itemCache).get(key);
|
|
660
|
+
if (!subscription) continue;
|
|
661
|
+
const subscriptionPreferences = preferencesBySubscription.get(subscription.id);
|
|
662
|
+
if (subscriptionPreferences) {
|
|
663
|
+
const updatedSubscription = this.createUpdatedSubscription(subscription, subscriptionPreferences);
|
|
664
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).set(key, updatedSubscription);
|
|
665
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscription.update.resolved", {
|
|
666
|
+
args: { subscription },
|
|
667
|
+
data: updatedSubscription
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
this.createUpdatedSubscription = (subscription, subscriptionPreferences) => {
|
|
673
|
+
const updatedPreferences = subscription.preferences.map((pref) => {
|
|
674
|
+
const newPreference = subscriptionPreferences.find((el) => el.workflow.id === pref.workflow.id);
|
|
675
|
+
if (newPreference) {
|
|
676
|
+
return newPreference;
|
|
677
|
+
}
|
|
678
|
+
return pref;
|
|
679
|
+
});
|
|
680
|
+
return new TopicSubscription(
|
|
681
|
+
{
|
|
682
|
+
id: subscription.id,
|
|
683
|
+
identifier: subscription.identifier,
|
|
684
|
+
topicKey: subscription.topicKey,
|
|
685
|
+
preferences: updatedPreferences
|
|
686
|
+
},
|
|
687
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3),
|
|
688
|
+
chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
689
|
+
this,
|
|
690
|
+
chunk7B52C2XE_js.__privateGet(this, _useCache3)
|
|
691
|
+
);
|
|
692
|
+
};
|
|
693
|
+
this.handleDelete = (subscription) => {
|
|
694
|
+
const listKey = getListCacheKey({ topicKey: subscription.topicKey });
|
|
695
|
+
const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
|
|
696
|
+
if (subscriptions) {
|
|
697
|
+
const updatedSubscriptions = subscriptions.filter((el) => el.id !== subscription.id);
|
|
698
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
|
|
699
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
|
|
700
|
+
data: { topicKey: subscription.topicKey, subscriptions: updatedSubscriptions }
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).remove(getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier }));
|
|
704
|
+
};
|
|
705
|
+
this.handleDeleteById = (subscriptionId) => {
|
|
706
|
+
const allListKeys = chunk7B52C2XE_js.__privateGet(this, _cache4).keys();
|
|
707
|
+
for (const listKey of allListKeys) {
|
|
708
|
+
const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
|
|
709
|
+
if (subscriptions) {
|
|
710
|
+
const subscription = subscriptions.find((el) => el.id === subscriptionId || el.identifier === subscriptionId);
|
|
711
|
+
if (subscription) {
|
|
712
|
+
const updatedSubscriptions = subscriptions.filter((el) => el.id !== subscription.id);
|
|
713
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).set(listKey, updatedSubscriptions);
|
|
714
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("subscriptions.list.updated", {
|
|
715
|
+
data: { topicKey: getTopicKeyFromListCacheKey(listKey), subscriptions: updatedSubscriptions }
|
|
716
|
+
});
|
|
717
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).remove(
|
|
718
|
+
getItemCacheKey({ topicKey: subscription.topicKey, identifier: subscription.identifier })
|
|
719
|
+
);
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
const allItemKeys = chunk7B52C2XE_js.__privateGet(this, _itemCache).keys();
|
|
725
|
+
for (const key of allItemKeys) {
|
|
726
|
+
const subscription = chunk7B52C2XE_js.__privateGet(this, _itemCache).get(key);
|
|
727
|
+
if (subscription && (subscription.id === subscriptionId || subscription.identifier === subscriptionId)) {
|
|
728
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).remove(key);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter3, emitterInstance);
|
|
734
|
+
chunk7B52C2XE_js.__privateSet(this, _cache4, new InMemoryCache());
|
|
735
|
+
chunk7B52C2XE_js.__privateSet(this, _itemCache, new InMemoryCache());
|
|
736
|
+
chunk7B52C2XE_js.__privateSet(this, _inboxService3, inboxServiceInstance);
|
|
737
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache3, useCache);
|
|
738
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.create.resolved", ({ data }) => {
|
|
739
|
+
if (data) {
|
|
740
|
+
this.handleCreate(data);
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.update.resolved", ({ data }) => {
|
|
744
|
+
if (data) {
|
|
745
|
+
this.handleUpdate(data);
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.delete.resolved", ({ args }) => {
|
|
749
|
+
if ("subscription" in args) {
|
|
750
|
+
this.handleDelete(args.subscription);
|
|
751
|
+
} else if ("subscriptionId" in args) {
|
|
752
|
+
this.handleDeleteById(args.subscriptionId);
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.preference.update.pending", ({ data }) => {
|
|
756
|
+
if (data) {
|
|
757
|
+
this.handlePreferenceUpdate(data);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.preference.update.resolved", ({ data }) => {
|
|
761
|
+
if (data) {
|
|
762
|
+
this.handlePreferenceUpdate(data);
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).on("subscription.preferences.bulk_update.resolved", ({ data }) => {
|
|
766
|
+
if (data && data.length > 0) {
|
|
767
|
+
this.handleBulkPreferenceUpdate(data);
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
has(args) {
|
|
772
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache4).get(getListCacheKey(args)) !== void 0;
|
|
773
|
+
}
|
|
774
|
+
set(args, data) {
|
|
775
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).set(getListCacheKey(args), data);
|
|
776
|
+
for (const subscription of data) {
|
|
777
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).set(
|
|
778
|
+
getItemCacheKey({ topicKey: args.topicKey, identifier: subscription.identifier }),
|
|
779
|
+
subscription
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
setOne(args, data) {
|
|
784
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).set(getItemCacheKey(args), data);
|
|
785
|
+
}
|
|
786
|
+
getAll(args) {
|
|
787
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache4).get(getListCacheKey(args));
|
|
788
|
+
}
|
|
789
|
+
get(args) {
|
|
790
|
+
return chunk7B52C2XE_js.__privateGet(this, _itemCache).get(getItemCacheKey(args));
|
|
791
|
+
}
|
|
792
|
+
invalidate(args) {
|
|
793
|
+
const listKey = getListCacheKey({ topicKey: args.topicKey });
|
|
794
|
+
const subscriptions = chunk7B52C2XE_js.__privateGet(this, _cache4).get(listKey);
|
|
795
|
+
if (subscriptions) {
|
|
796
|
+
for (const subscription of subscriptions) {
|
|
797
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).remove(getItemCacheKey({ topicKey: args.topicKey, identifier: subscription.identifier }));
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).remove(listKey);
|
|
801
|
+
const allItemKeys = chunk7B52C2XE_js.__privateGet(this, _itemCache).keys();
|
|
802
|
+
for (const key of allItemKeys) {
|
|
803
|
+
if (key.startsWith(`item:${args.topicKey}:`)) {
|
|
804
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).remove(key);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
clearAll() {
|
|
809
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).clear();
|
|
810
|
+
chunk7B52C2XE_js.__privateGet(this, _itemCache).clear();
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
_emitter3 = new WeakMap();
|
|
814
|
+
_cache4 = new WeakMap();
|
|
815
|
+
_useCache3 = new WeakMap();
|
|
816
|
+
_itemCache = new WeakMap();
|
|
817
|
+
_inboxService3 = new WeakMap();
|
|
818
|
+
|
|
819
|
+
// src/subscriptions/subscriptions.ts
|
|
820
|
+
var _useCache4, _subscriber;
|
|
821
|
+
var Subscriptions = class extends BaseModule {
|
|
822
|
+
constructor({
|
|
823
|
+
useCache,
|
|
824
|
+
inboxServiceInstance,
|
|
825
|
+
eventEmitterInstance,
|
|
826
|
+
subscriber
|
|
827
|
+
}) {
|
|
828
|
+
super({
|
|
829
|
+
eventEmitterInstance,
|
|
830
|
+
inboxServiceInstance
|
|
831
|
+
});
|
|
832
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache4);
|
|
833
|
+
chunk7B52C2XE_js.__privateAdd(this, _subscriber);
|
|
834
|
+
this.cache = new SubscriptionsCache({
|
|
835
|
+
emitterInstance: this._emitter,
|
|
836
|
+
inboxServiceInstance: this._inboxService,
|
|
837
|
+
useCache
|
|
838
|
+
});
|
|
839
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache4, useCache);
|
|
840
|
+
chunk7B52C2XE_js.__privateSet(this, _subscriber, subscriber);
|
|
841
|
+
}
|
|
842
|
+
list(args, options) {
|
|
843
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
844
|
+
return this.callWithSession(
|
|
845
|
+
() => {
|
|
846
|
+
var _a;
|
|
847
|
+
return listSubscriptions({
|
|
848
|
+
emitter: this._emitter,
|
|
849
|
+
apiService: this._inboxService,
|
|
850
|
+
cache: this.cache,
|
|
851
|
+
options: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, options), {
|
|
852
|
+
useCache: (_a = options == null ? void 0 : options.useCache) != null ? _a : chunk7B52C2XE_js.__privateGet(this, _useCache4)
|
|
853
|
+
}),
|
|
854
|
+
args
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
get(args, options) {
|
|
861
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
862
|
+
return this.callWithSession(
|
|
863
|
+
() => {
|
|
864
|
+
var _a, _b;
|
|
865
|
+
return getSubscription({
|
|
866
|
+
emitter: this._emitter,
|
|
867
|
+
apiService: this._inboxService,
|
|
868
|
+
cache: this.cache,
|
|
869
|
+
options: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, options), {
|
|
870
|
+
useCache: (_a = options == null ? void 0 : options.useCache) != null ? _a : chunk7B52C2XE_js.__privateGet(this, _useCache4)
|
|
871
|
+
}),
|
|
872
|
+
args: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, args), {
|
|
873
|
+
identifier: (_b = args.identifier) != null ? _b : chunkOZV3TKWX_js.buildSubscriptionIdentifier({ topicKey: args.topicKey, subscriberId: chunk7B52C2XE_js.__privateGet(this, _subscriber).subscriberId })
|
|
874
|
+
})
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
);
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
create(args) {
|
|
881
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
882
|
+
return this.callWithSession(
|
|
883
|
+
() => createSubscription({
|
|
884
|
+
emitter: this._emitter,
|
|
885
|
+
apiService: this._inboxService,
|
|
886
|
+
cache: this.cache,
|
|
887
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache4),
|
|
888
|
+
args
|
|
889
|
+
})
|
|
890
|
+
);
|
|
891
|
+
});
|
|
136
892
|
}
|
|
137
|
-
|
|
138
|
-
return
|
|
893
|
+
update(args) {
|
|
894
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
895
|
+
return this.callWithSession(
|
|
896
|
+
() => updateSubscription({
|
|
897
|
+
emitter: this._emitter,
|
|
898
|
+
apiService: this._inboxService,
|
|
899
|
+
cache: this.cache,
|
|
900
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache4),
|
|
901
|
+
args
|
|
902
|
+
})
|
|
903
|
+
);
|
|
904
|
+
});
|
|
139
905
|
}
|
|
140
|
-
|
|
141
|
-
return
|
|
906
|
+
delete(args) {
|
|
907
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
908
|
+
return this.callWithSession(
|
|
909
|
+
() => deleteSubscription({
|
|
910
|
+
emitter: this._emitter,
|
|
911
|
+
apiService: this._inboxService,
|
|
912
|
+
args
|
|
913
|
+
})
|
|
914
|
+
);
|
|
915
|
+
});
|
|
142
916
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return checkBasicFilters(notification, filter) && checkNotificationTagFilter(notification.tags, filter.tags) && checkNotificationDataFilter(notification.data, filter.data);
|
|
147
|
-
}
|
|
917
|
+
};
|
|
918
|
+
_useCache4 = new WeakMap();
|
|
919
|
+
_subscriber = new WeakMap();
|
|
148
920
|
|
|
149
921
|
// src/api/http-client.ts
|
|
150
922
|
var DEFAULT_API_VERSION = "v1";
|
|
151
|
-
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.
|
|
923
|
+
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.12.0-rc.1"}`;
|
|
152
924
|
var HttpClient = class {
|
|
153
925
|
constructor(options = {}) {
|
|
154
926
|
// Environment variable for local development that overrides the default API endpoint without affecting the Inbox DX
|
|
@@ -485,6 +1257,57 @@ var InboxService = class {
|
|
|
485
1257
|
};
|
|
486
1258
|
return chunk7B52C2XE_js.__privateGet(this, _httpClient).post("/inbox/events", payload);
|
|
487
1259
|
}
|
|
1260
|
+
fetchSubscriptions(topicKey) {
|
|
1261
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).get(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions`);
|
|
1262
|
+
}
|
|
1263
|
+
getSubscription({
|
|
1264
|
+
topicKey,
|
|
1265
|
+
identifier
|
|
1266
|
+
}) {
|
|
1267
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).get(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${identifier}`);
|
|
1268
|
+
}
|
|
1269
|
+
createSubscription({
|
|
1270
|
+
identifier,
|
|
1271
|
+
name,
|
|
1272
|
+
topicKey,
|
|
1273
|
+
topicName,
|
|
1274
|
+
preferences
|
|
1275
|
+
}) {
|
|
1276
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions`, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({
|
|
1277
|
+
identifier,
|
|
1278
|
+
name
|
|
1279
|
+
}, topicName && { topic: { name: topicName } }), {
|
|
1280
|
+
preferences
|
|
1281
|
+
}));
|
|
1282
|
+
}
|
|
1283
|
+
updateSubscription({
|
|
1284
|
+
topicKey,
|
|
1285
|
+
subscriptionId,
|
|
1286
|
+
name,
|
|
1287
|
+
preferences
|
|
1288
|
+
}) {
|
|
1289
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${subscriptionId}`, {
|
|
1290
|
+
name,
|
|
1291
|
+
preferences
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
updateSubscriptionPreference({
|
|
1295
|
+
subscriptionId,
|
|
1296
|
+
workflowId,
|
|
1297
|
+
enabled,
|
|
1298
|
+
condition
|
|
1299
|
+
}) {
|
|
1300
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/subscriptions/${subscriptionId}/preferences/${workflowId}`, {
|
|
1301
|
+
enabled,
|
|
1302
|
+
condition
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
bulkUpdateSubscriptionPreferences(preferences) {
|
|
1306
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/bulk`, { preferences });
|
|
1307
|
+
}
|
|
1308
|
+
deleteSubscription({ topicKey, subscriptionId }) {
|
|
1309
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).delete(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${subscriptionId}`);
|
|
1310
|
+
}
|
|
488
1311
|
};
|
|
489
1312
|
_httpClient = new WeakMap();
|
|
490
1313
|
var _mittEmitter;
|
|
@@ -508,14 +1331,6 @@ var NovuEventEmitter = class {
|
|
|
508
1331
|
};
|
|
509
1332
|
_mittEmitter = new WeakMap();
|
|
510
1333
|
|
|
511
|
-
// src/utils/errors.ts
|
|
512
|
-
var NovuError = class extends Error {
|
|
513
|
-
constructor(message, originalError) {
|
|
514
|
-
super(message);
|
|
515
|
-
this.originalError = originalError;
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
|
|
519
1334
|
// src/notifications/helpers.ts
|
|
520
1335
|
var read = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
521
1336
|
emitter,
|
|
@@ -985,13 +1800,13 @@ var deleteAll = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
|
985
1800
|
});
|
|
986
1801
|
|
|
987
1802
|
// src/notifications/notification.ts
|
|
988
|
-
var
|
|
1803
|
+
var _emitter4, _inboxService4;
|
|
989
1804
|
var Notification = class {
|
|
990
1805
|
constructor(notification, emitter, inboxService) {
|
|
991
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
992
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
993
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
994
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
1806
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter4);
|
|
1807
|
+
chunk7B52C2XE_js.__privateAdd(this, _inboxService4);
|
|
1808
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter4, emitter);
|
|
1809
|
+
chunk7B52C2XE_js.__privateSet(this, _inboxService4, inboxService);
|
|
995
1810
|
this.id = notification.id;
|
|
996
1811
|
this.transactionId = notification.transactionId;
|
|
997
1812
|
this.subject = notification.subject;
|
|
@@ -1019,8 +1834,8 @@ var Notification = class {
|
|
|
1019
1834
|
}
|
|
1020
1835
|
read() {
|
|
1021
1836
|
return read({
|
|
1022
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1023
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1837
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1838
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1024
1839
|
args: {
|
|
1025
1840
|
notification: this
|
|
1026
1841
|
}
|
|
@@ -1028,8 +1843,8 @@ var Notification = class {
|
|
|
1028
1843
|
}
|
|
1029
1844
|
unread() {
|
|
1030
1845
|
return unread({
|
|
1031
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1032
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1846
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1847
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1033
1848
|
args: {
|
|
1034
1849
|
notification: this
|
|
1035
1850
|
}
|
|
@@ -1037,8 +1852,8 @@ var Notification = class {
|
|
|
1037
1852
|
}
|
|
1038
1853
|
seen() {
|
|
1039
1854
|
return seen({
|
|
1040
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1041
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1855
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1856
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1042
1857
|
args: {
|
|
1043
1858
|
notification: this
|
|
1044
1859
|
}
|
|
@@ -1046,8 +1861,8 @@ var Notification = class {
|
|
|
1046
1861
|
}
|
|
1047
1862
|
archive() {
|
|
1048
1863
|
return archive({
|
|
1049
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1050
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1864
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1865
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1051
1866
|
args: {
|
|
1052
1867
|
notification: this
|
|
1053
1868
|
}
|
|
@@ -1055,8 +1870,8 @@ var Notification = class {
|
|
|
1055
1870
|
}
|
|
1056
1871
|
unarchive() {
|
|
1057
1872
|
return unarchive({
|
|
1058
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1059
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1873
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1874
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1060
1875
|
args: {
|
|
1061
1876
|
notification: this
|
|
1062
1877
|
}
|
|
@@ -1064,8 +1879,8 @@ var Notification = class {
|
|
|
1064
1879
|
}
|
|
1065
1880
|
delete() {
|
|
1066
1881
|
return deleteNotification({
|
|
1067
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1068
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1882
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1883
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1069
1884
|
args: {
|
|
1070
1885
|
notification: this
|
|
1071
1886
|
}
|
|
@@ -1073,8 +1888,8 @@ var Notification = class {
|
|
|
1073
1888
|
}
|
|
1074
1889
|
snooze(snoozeUntil) {
|
|
1075
1890
|
return snooze({
|
|
1076
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1077
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1891
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1892
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1078
1893
|
args: {
|
|
1079
1894
|
notification: this,
|
|
1080
1895
|
snoozeUntil
|
|
@@ -1083,8 +1898,8 @@ var Notification = class {
|
|
|
1083
1898
|
}
|
|
1084
1899
|
unsnooze() {
|
|
1085
1900
|
return unsnooze({
|
|
1086
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1087
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1901
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1902
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1088
1903
|
args: { notification: this }
|
|
1089
1904
|
});
|
|
1090
1905
|
}
|
|
@@ -1093,8 +1908,8 @@ var Notification = class {
|
|
|
1093
1908
|
throw new Error("Primary action is not available");
|
|
1094
1909
|
}
|
|
1095
1910
|
return completeAction({
|
|
1096
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1097
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1911
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1912
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1098
1913
|
args: {
|
|
1099
1914
|
notification: this
|
|
1100
1915
|
},
|
|
@@ -1106,8 +1921,8 @@ var Notification = class {
|
|
|
1106
1921
|
throw new Error("Secondary action is not available");
|
|
1107
1922
|
}
|
|
1108
1923
|
return completeAction({
|
|
1109
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1110
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1924
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1925
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1111
1926
|
args: {
|
|
1112
1927
|
notification: this
|
|
1113
1928
|
},
|
|
@@ -1119,8 +1934,8 @@ var Notification = class {
|
|
|
1119
1934
|
throw new Error("Primary action is not available");
|
|
1120
1935
|
}
|
|
1121
1936
|
return revertAction({
|
|
1122
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1123
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1937
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1938
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1124
1939
|
args: {
|
|
1125
1940
|
notification: this
|
|
1126
1941
|
},
|
|
@@ -1132,8 +1947,8 @@ var Notification = class {
|
|
|
1132
1947
|
throw new Error("Secondary action is not available");
|
|
1133
1948
|
}
|
|
1134
1949
|
return revertAction({
|
|
1135
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
1136
|
-
apiService: chunk7B52C2XE_js.__privateGet(this,
|
|
1950
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1951
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService4),
|
|
1137
1952
|
args: {
|
|
1138
1953
|
notification: this
|
|
1139
1954
|
},
|
|
@@ -1141,7 +1956,7 @@ var Notification = class {
|
|
|
1141
1956
|
});
|
|
1142
1957
|
}
|
|
1143
1958
|
on(eventName, listener) {
|
|
1144
|
-
const cleanup = chunk7B52C2XE_js.__privateGet(this,
|
|
1959
|
+
const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter4).on(eventName, listener);
|
|
1145
1960
|
return () => {
|
|
1146
1961
|
cleanup();
|
|
1147
1962
|
};
|
|
@@ -1151,93 +1966,11 @@ var Notification = class {
|
|
|
1151
1966
|
* Use the cleanup function returned by the "on" method instead.
|
|
1152
1967
|
*/
|
|
1153
1968
|
off(eventName, listener) {
|
|
1154
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
1155
|
-
}
|
|
1156
|
-
};
|
|
1157
|
-
_emitter = new WeakMap();
|
|
1158
|
-
_inboxService = new WeakMap();
|
|
1159
|
-
|
|
1160
|
-
// src/base-module.ts
|
|
1161
|
-
var _callsQueue, _sessionError;
|
|
1162
|
-
var BaseModule = class {
|
|
1163
|
-
constructor({
|
|
1164
|
-
inboxServiceInstance,
|
|
1165
|
-
eventEmitterInstance
|
|
1166
|
-
}) {
|
|
1167
|
-
chunk7B52C2XE_js.__privateAdd(this, _callsQueue, []);
|
|
1168
|
-
chunk7B52C2XE_js.__privateAdd(this, _sessionError);
|
|
1169
|
-
this._emitter = eventEmitterInstance;
|
|
1170
|
-
this._inboxService = inboxServiceInstance;
|
|
1171
|
-
this._emitter.on("session.initialize.resolved", ({ error, data }) => {
|
|
1172
|
-
if (data) {
|
|
1173
|
-
this.onSessionSuccess(data);
|
|
1174
|
-
chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach((_0) => chunk7B52C2XE_js.__async(this, [_0], function* ({ fn, resolve }) {
|
|
1175
|
-
resolve(yield fn());
|
|
1176
|
-
}));
|
|
1177
|
-
chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
|
|
1178
|
-
} else if (error) {
|
|
1179
|
-
this.onSessionError(error);
|
|
1180
|
-
chunk7B52C2XE_js.__privateSet(this, _sessionError, error);
|
|
1181
|
-
chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach(({ resolve }) => {
|
|
1182
|
-
resolve({ error: new NovuError("Failed to initialize session, please contact the support", error) });
|
|
1183
|
-
});
|
|
1184
|
-
chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
|
|
1185
|
-
}
|
|
1186
|
-
});
|
|
1187
|
-
}
|
|
1188
|
-
onSessionSuccess(_) {
|
|
1189
|
-
}
|
|
1190
|
-
onSessionError(_) {
|
|
1191
|
-
}
|
|
1192
|
-
callWithSession(fn) {
|
|
1193
|
-
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1194
|
-
if (this._inboxService.isSessionInitialized) {
|
|
1195
|
-
return fn();
|
|
1196
|
-
}
|
|
1197
|
-
if (chunk7B52C2XE_js.__privateGet(this, _sessionError)) {
|
|
1198
|
-
return Promise.resolve({
|
|
1199
|
-
error: new NovuError("Failed to initialize session, please contact the support", chunk7B52C2XE_js.__privateGet(this, _sessionError))
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1202
|
-
return new Promise((resolve, reject) => {
|
|
1203
|
-
chunk7B52C2XE_js.__privateGet(this, _callsQueue).push({ fn, resolve, reject });
|
|
1204
|
-
});
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
};
|
|
1208
|
-
_callsQueue = new WeakMap();
|
|
1209
|
-
_sessionError = new WeakMap();
|
|
1210
|
-
|
|
1211
|
-
// src/cache/in-memory-cache.ts
|
|
1212
|
-
var _cache;
|
|
1213
|
-
var InMemoryCache = class {
|
|
1214
|
-
constructor() {
|
|
1215
|
-
chunk7B52C2XE_js.__privateAdd(this, _cache);
|
|
1216
|
-
chunk7B52C2XE_js.__privateSet(this, _cache, /* @__PURE__ */ new Map());
|
|
1217
|
-
}
|
|
1218
|
-
get(key) {
|
|
1219
|
-
return chunk7B52C2XE_js.__privateGet(this, _cache).get(key);
|
|
1220
|
-
}
|
|
1221
|
-
getValues() {
|
|
1222
|
-
return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).values());
|
|
1223
|
-
}
|
|
1224
|
-
entries() {
|
|
1225
|
-
return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).entries());
|
|
1226
|
-
}
|
|
1227
|
-
keys() {
|
|
1228
|
-
return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).keys());
|
|
1229
|
-
}
|
|
1230
|
-
set(key, value) {
|
|
1231
|
-
chunk7B52C2XE_js.__privateGet(this, _cache).set(key, value);
|
|
1232
|
-
}
|
|
1233
|
-
remove(key) {
|
|
1234
|
-
chunk7B52C2XE_js.__privateGet(this, _cache).delete(key);
|
|
1235
|
-
}
|
|
1236
|
-
clear() {
|
|
1237
|
-
chunk7B52C2XE_js.__privateGet(this, _cache).clear();
|
|
1969
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter4).off(eventName, listener);
|
|
1238
1970
|
}
|
|
1239
1971
|
};
|
|
1240
|
-
|
|
1972
|
+
_emitter4 = new WeakMap();
|
|
1973
|
+
_inboxService4 = new WeakMap();
|
|
1241
1974
|
|
|
1242
1975
|
// src/cache/notifications-cache.ts
|
|
1243
1976
|
var excludeEmpty = ({
|
|
@@ -1305,16 +2038,16 @@ var removeEvents = [
|
|
|
1305
2038
|
"notifications.archive_all_read.pending",
|
|
1306
2039
|
"notifications.delete_all.pending"
|
|
1307
2040
|
];
|
|
1308
|
-
var
|
|
2041
|
+
var _emitter5, _cache5;
|
|
1309
2042
|
var NotificationsCache = class {
|
|
1310
2043
|
constructor({ emitter }) {
|
|
1311
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2044
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter5);
|
|
1312
2045
|
/**
|
|
1313
2046
|
* The key is the stringified notifications filter, the values are the paginated notifications.
|
|
1314
2047
|
*/
|
|
1315
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2048
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache5);
|
|
1316
2049
|
this.updateNotification = (key, data) => {
|
|
1317
|
-
const notificationsResponse = chunk7B52C2XE_js.__privateGet(this,
|
|
2050
|
+
const notificationsResponse = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
|
|
1318
2051
|
if (!notificationsResponse) {
|
|
1319
2052
|
return false;
|
|
1320
2053
|
}
|
|
@@ -1324,11 +2057,11 @@ var NotificationsCache = class {
|
|
|
1324
2057
|
}
|
|
1325
2058
|
const updatedNotifications = [...notificationsResponse.notifications];
|
|
1326
2059
|
updatedNotifications[index] = data;
|
|
1327
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2060
|
+
chunk7B52C2XE_js.__privateGet(this, _cache5).set(key, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notificationsResponse), { notifications: updatedNotifications }));
|
|
1328
2061
|
return true;
|
|
1329
2062
|
};
|
|
1330
2063
|
this.removeNotification = (key, data) => {
|
|
1331
|
-
const notificationsResponse = chunk7B52C2XE_js.__privateGet(this,
|
|
2064
|
+
const notificationsResponse = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
|
|
1332
2065
|
if (!notificationsResponse) {
|
|
1333
2066
|
return false;
|
|
1334
2067
|
}
|
|
@@ -1338,7 +2071,7 @@ var NotificationsCache = class {
|
|
|
1338
2071
|
}
|
|
1339
2072
|
const newNotifications = [...notificationsResponse.notifications];
|
|
1340
2073
|
newNotifications.splice(index, 1);
|
|
1341
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2074
|
+
chunk7B52C2XE_js.__privateGet(this, _cache5).set(key, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notificationsResponse), {
|
|
1342
2075
|
notifications: newNotifications
|
|
1343
2076
|
}));
|
|
1344
2077
|
return true;
|
|
@@ -1357,8 +2090,8 @@ var NotificationsCache = class {
|
|
|
1357
2090
|
notifications = [args.notification];
|
|
1358
2091
|
} else if ("notificationId" in args && args.notificationId) {
|
|
1359
2092
|
const foundNotifications = [];
|
|
1360
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
1361
|
-
const cachedResponse = chunk7B52C2XE_js.__privateGet(this,
|
|
2093
|
+
chunk7B52C2XE_js.__privateGet(this, _cache5).keys().forEach((key) => {
|
|
2094
|
+
const cachedResponse = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
|
|
1362
2095
|
if (cachedResponse) {
|
|
1363
2096
|
const found = cachedResponse.notifications.find((n) => n.id === args.notificationId);
|
|
1364
2097
|
if (found) {
|
|
@@ -1373,7 +2106,7 @@ var NotificationsCache = class {
|
|
|
1373
2106
|
return;
|
|
1374
2107
|
}
|
|
1375
2108
|
const uniqueFilterKeys = /* @__PURE__ */ new Set();
|
|
1376
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2109
|
+
chunk7B52C2XE_js.__privateGet(this, _cache5).keys().forEach((key) => {
|
|
1377
2110
|
notifications.forEach((notification) => {
|
|
1378
2111
|
let isNotificationFound = false;
|
|
1379
2112
|
if (remove) {
|
|
@@ -1388,26 +2121,26 @@ var NotificationsCache = class {
|
|
|
1388
2121
|
});
|
|
1389
2122
|
uniqueFilterKeys.forEach((key) => {
|
|
1390
2123
|
const notificationsResponse = this.getAggregated(getFilter(key));
|
|
1391
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2124
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter5).emit("notifications.list.updated", {
|
|
1392
2125
|
data: notificationsResponse
|
|
1393
2126
|
});
|
|
1394
2127
|
});
|
|
1395
2128
|
};
|
|
1396
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2129
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter5, emitter);
|
|
1397
2130
|
updateEvents.forEach((event) => {
|
|
1398
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2131
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter5).on(event, this.handleNotificationEvent());
|
|
1399
2132
|
});
|
|
1400
2133
|
removeEvents.forEach((event) => {
|
|
1401
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2134
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter5).on(event, this.handleNotificationEvent({ remove: true }));
|
|
1402
2135
|
});
|
|
1403
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2136
|
+
chunk7B52C2XE_js.__privateSet(this, _cache5, new InMemoryCache());
|
|
1404
2137
|
}
|
|
1405
2138
|
getAggregated(filter) {
|
|
1406
|
-
const cacheKeys = chunk7B52C2XE_js.__privateGet(this,
|
|
2139
|
+
const cacheKeys = chunk7B52C2XE_js.__privateGet(this, _cache5).keys().filter((key) => {
|
|
1407
2140
|
const parsedFilter = getFilter(key);
|
|
1408
2141
|
return isSameFilter(parsedFilter, filter);
|
|
1409
2142
|
});
|
|
1410
|
-
return cacheKeys.map((key) => chunk7B52C2XE_js.__privateGet(this,
|
|
2143
|
+
return cacheKeys.map((key) => chunk7B52C2XE_js.__privateGet(this, _cache5).get(key)).reduce(
|
|
1411
2144
|
(acc, el) => {
|
|
1412
2145
|
if (!el) {
|
|
1413
2146
|
return acc;
|
|
@@ -1422,15 +2155,15 @@ var NotificationsCache = class {
|
|
|
1422
2155
|
);
|
|
1423
2156
|
}
|
|
1424
2157
|
has(args) {
|
|
1425
|
-
return chunk7B52C2XE_js.__privateGet(this,
|
|
2158
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache5).get(getCacheKey(args)) !== void 0;
|
|
1426
2159
|
}
|
|
1427
2160
|
set(args, data) {
|
|
1428
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2161
|
+
chunk7B52C2XE_js.__privateGet(this, _cache5).set(getCacheKey(args), data);
|
|
1429
2162
|
}
|
|
1430
2163
|
update(args, data) {
|
|
1431
2164
|
this.set(args, data);
|
|
1432
2165
|
const notificationsResponse = this.getAggregated(getFilter(getCacheKey(args)));
|
|
1433
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2166
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter5).emit("notifications.list.updated", {
|
|
1434
2167
|
data: notificationsResponse
|
|
1435
2168
|
});
|
|
1436
2169
|
}
|
|
@@ -1456,12 +2189,12 @@ var NotificationsCache = class {
|
|
|
1456
2189
|
read: read2,
|
|
1457
2190
|
data
|
|
1458
2191
|
}) {
|
|
1459
|
-
const keys = chunk7B52C2XE_js.__privateGet(this,
|
|
2192
|
+
const keys = chunk7B52C2XE_js.__privateGet(this, _cache5).keys();
|
|
1460
2193
|
const uniqueNotifications = /* @__PURE__ */ new Map();
|
|
1461
2194
|
keys.forEach((key) => {
|
|
1462
2195
|
const filter = getFilter(key);
|
|
1463
2196
|
if (areTagsEqual(tags, filter.tags) && areDataEqual(data, filter.data)) {
|
|
1464
|
-
const value = chunk7B52C2XE_js.__privateGet(this,
|
|
2197
|
+
const value = chunk7B52C2XE_js.__privateGet(this, _cache5).get(key);
|
|
1465
2198
|
if (!value) {
|
|
1466
2199
|
return;
|
|
1467
2200
|
}
|
|
@@ -1473,22 +2206,22 @@ var NotificationsCache = class {
|
|
|
1473
2206
|
return Array.from(uniqueNotifications.values());
|
|
1474
2207
|
}
|
|
1475
2208
|
clear(filter) {
|
|
1476
|
-
const keys = chunk7B52C2XE_js.__privateGet(this,
|
|
2209
|
+
const keys = chunk7B52C2XE_js.__privateGet(this, _cache5).keys();
|
|
1477
2210
|
keys.forEach((key) => {
|
|
1478
2211
|
if (isSameFilter(getFilter(key), filter)) {
|
|
1479
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2212
|
+
chunk7B52C2XE_js.__privateGet(this, _cache5).remove(key);
|
|
1480
2213
|
}
|
|
1481
2214
|
});
|
|
1482
2215
|
}
|
|
1483
2216
|
clearAll() {
|
|
1484
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2217
|
+
chunk7B52C2XE_js.__privateGet(this, _cache5).clear();
|
|
1485
2218
|
}
|
|
1486
2219
|
};
|
|
1487
|
-
|
|
1488
|
-
|
|
2220
|
+
_emitter5 = new WeakMap();
|
|
2221
|
+
_cache5 = new WeakMap();
|
|
1489
2222
|
|
|
1490
2223
|
// src/notifications/notifications.ts
|
|
1491
|
-
var
|
|
2224
|
+
var _useCache5;
|
|
1492
2225
|
var Notifications = class extends BaseModule {
|
|
1493
2226
|
constructor({
|
|
1494
2227
|
useCache,
|
|
@@ -1499,11 +2232,11 @@ var Notifications = class extends BaseModule {
|
|
|
1499
2232
|
eventEmitterInstance,
|
|
1500
2233
|
inboxServiceInstance
|
|
1501
2234
|
});
|
|
1502
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2235
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache5);
|
|
1503
2236
|
this.cache = new NotificationsCache({
|
|
1504
2237
|
emitter: eventEmitterInstance
|
|
1505
2238
|
});
|
|
1506
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2239
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache5, useCache);
|
|
1507
2240
|
}
|
|
1508
2241
|
get inboxService() {
|
|
1509
2242
|
return this._inboxService;
|
|
@@ -1514,7 +2247,7 @@ var Notifications = class extends BaseModule {
|
|
|
1514
2247
|
return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1515
2248
|
const args = chunk7B52C2XE_js.__spreadValues({ limit }, restOptions);
|
|
1516
2249
|
try {
|
|
1517
|
-
const shouldUseCache = "useCache" in args ? args.useCache : chunk7B52C2XE_js.__privateGet(this,
|
|
2250
|
+
const shouldUseCache = "useCache" in args ? args.useCache : chunk7B52C2XE_js.__privateGet(this, _useCache5);
|
|
1518
2251
|
let data = shouldUseCache ? this.cache.getAll(args) : void 0;
|
|
1519
2252
|
this._emitter.emit("notifications.list.pending", { args, data });
|
|
1520
2253
|
if (!data) {
|
|
@@ -1826,10 +2559,10 @@ var Notifications = class extends BaseModule {
|
|
|
1826
2559
|
});
|
|
1827
2560
|
}
|
|
1828
2561
|
};
|
|
1829
|
-
|
|
2562
|
+
_useCache5 = new WeakMap();
|
|
1830
2563
|
|
|
1831
2564
|
// src/preferences/schedule.ts
|
|
1832
|
-
var
|
|
2565
|
+
var _emitter6, _apiService, _cache6, _useCache6;
|
|
1833
2566
|
var Schedule = class {
|
|
1834
2567
|
constructor(schedule, {
|
|
1835
2568
|
emitterInstance,
|
|
@@ -1837,14 +2570,14 @@ var Schedule = class {
|
|
|
1837
2570
|
cache,
|
|
1838
2571
|
useCache
|
|
1839
2572
|
}) {
|
|
1840
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2573
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter6);
|
|
1841
2574
|
chunk7B52C2XE_js.__privateAdd(this, _apiService);
|
|
1842
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
1843
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
1844
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2575
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache6);
|
|
2576
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache6);
|
|
2577
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter6, emitterInstance);
|
|
1845
2578
|
chunk7B52C2XE_js.__privateSet(this, _apiService, inboxServiceInstance);
|
|
1846
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
1847
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2579
|
+
chunk7B52C2XE_js.__privateSet(this, _cache6, cache);
|
|
2580
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache6, useCache);
|
|
1848
2581
|
this.isEnabled = schedule.isEnabled;
|
|
1849
2582
|
this.weeklySchedule = schedule.weeklySchedule;
|
|
1850
2583
|
}
|
|
@@ -1853,10 +2586,10 @@ var Schedule = class {
|
|
|
1853
2586
|
var _a;
|
|
1854
2587
|
const hasWeeklySchedule = !!args.weeklySchedule || !!this.weeklySchedule;
|
|
1855
2588
|
return updateSchedule({
|
|
1856
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
2589
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter6),
|
|
1857
2590
|
apiService: chunk7B52C2XE_js.__privateGet(this, _apiService),
|
|
1858
|
-
cache: chunk7B52C2XE_js.__privateGet(this,
|
|
1859
|
-
useCache: chunk7B52C2XE_js.__privateGet(this,
|
|
2591
|
+
cache: chunk7B52C2XE_js.__privateGet(this, _cache6),
|
|
2592
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache6),
|
|
1860
2593
|
args: chunk7B52C2XE_js.__spreadValues({
|
|
1861
2594
|
isEnabled: (_a = args.isEnabled) != null ? _a : this.isEnabled
|
|
1862
2595
|
}, hasWeeklySchedule && {
|
|
@@ -1866,13 +2599,13 @@ var Schedule = class {
|
|
|
1866
2599
|
});
|
|
1867
2600
|
}
|
|
1868
2601
|
};
|
|
1869
|
-
|
|
2602
|
+
_emitter6 = new WeakMap();
|
|
1870
2603
|
_apiService = new WeakMap();
|
|
1871
|
-
|
|
1872
|
-
|
|
2604
|
+
_cache6 = new WeakMap();
|
|
2605
|
+
_useCache6 = new WeakMap();
|
|
1873
2606
|
|
|
1874
2607
|
// src/preferences/preference.ts
|
|
1875
|
-
var
|
|
2608
|
+
var _emitter7, _apiService2, _cache7, _scheduleCache, _useCache7;
|
|
1876
2609
|
var Preference = class {
|
|
1877
2610
|
constructor(preference, {
|
|
1878
2611
|
emitterInstance,
|
|
@@ -1881,16 +2614,16 @@ var Preference = class {
|
|
|
1881
2614
|
scheduleCache,
|
|
1882
2615
|
useCache
|
|
1883
2616
|
}) {
|
|
1884
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2617
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter7);
|
|
1885
2618
|
chunk7B52C2XE_js.__privateAdd(this, _apiService2);
|
|
1886
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2619
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache7);
|
|
1887
2620
|
chunk7B52C2XE_js.__privateAdd(this, _scheduleCache);
|
|
1888
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
1889
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2621
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache7);
|
|
2622
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter7, emitterInstance);
|
|
1890
2623
|
chunk7B52C2XE_js.__privateSet(this, _apiService2, inboxServiceInstance);
|
|
1891
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2624
|
+
chunk7B52C2XE_js.__privateSet(this, _cache7, cache);
|
|
1892
2625
|
chunk7B52C2XE_js.__privateSet(this, _scheduleCache, scheduleCache);
|
|
1893
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2626
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache7, useCache);
|
|
1894
2627
|
this.level = preference.level;
|
|
1895
2628
|
this.enabled = preference.enabled;
|
|
1896
2629
|
this.channels = preference.channels;
|
|
@@ -1906,11 +2639,11 @@ var Preference = class {
|
|
|
1906
2639
|
}) {
|
|
1907
2640
|
var _a;
|
|
1908
2641
|
return updatePreference({
|
|
1909
|
-
emitter: chunk7B52C2XE_js.__privateGet(this,
|
|
2642
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter7),
|
|
1910
2643
|
apiService: chunk7B52C2XE_js.__privateGet(this, _apiService2),
|
|
1911
|
-
cache: chunk7B52C2XE_js.__privateGet(this,
|
|
2644
|
+
cache: chunk7B52C2XE_js.__privateGet(this, _cache7),
|
|
1912
2645
|
scheduleCache: chunk7B52C2XE_js.__privateGet(this, _scheduleCache),
|
|
1913
|
-
useCache: chunk7B52C2XE_js.__privateGet(this,
|
|
2646
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache7),
|
|
1914
2647
|
args: {
|
|
1915
2648
|
workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
|
|
1916
2649
|
channels: channels || channelPreferences,
|
|
@@ -1919,11 +2652,11 @@ var Preference = class {
|
|
|
1919
2652
|
});
|
|
1920
2653
|
}
|
|
1921
2654
|
};
|
|
1922
|
-
|
|
2655
|
+
_emitter7 = new WeakMap();
|
|
1923
2656
|
_apiService2 = new WeakMap();
|
|
1924
|
-
|
|
2657
|
+
_cache7 = new WeakMap();
|
|
1925
2658
|
_scheduleCache = new WeakMap();
|
|
1926
|
-
|
|
2659
|
+
_useCache7 = new WeakMap();
|
|
1927
2660
|
|
|
1928
2661
|
// src/preferences/helpers.ts
|
|
1929
2662
|
var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
@@ -2120,7 +2853,7 @@ var updateSchedule = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
|
2120
2853
|
});
|
|
2121
2854
|
|
|
2122
2855
|
// src/preferences/preference-schedule.ts
|
|
2123
|
-
var
|
|
2856
|
+
var _useCache8;
|
|
2124
2857
|
var PreferenceSchedule = class extends BaseModule {
|
|
2125
2858
|
constructor({
|
|
2126
2859
|
cache,
|
|
@@ -2132,16 +2865,16 @@ var PreferenceSchedule = class extends BaseModule {
|
|
|
2132
2865
|
eventEmitterInstance,
|
|
2133
2866
|
inboxServiceInstance
|
|
2134
2867
|
});
|
|
2135
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2868
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache8);
|
|
2136
2869
|
this.cache = cache;
|
|
2137
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2870
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache8, useCache);
|
|
2138
2871
|
}
|
|
2139
2872
|
get() {
|
|
2140
2873
|
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
2141
2874
|
return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
2142
2875
|
var _a, _b;
|
|
2143
2876
|
try {
|
|
2144
|
-
let data = chunk7B52C2XE_js.__privateGet(this,
|
|
2877
|
+
let data = chunk7B52C2XE_js.__privateGet(this, _useCache8) ? this.cache.getAll() : void 0;
|
|
2145
2878
|
this._emitter.emit("preference.schedule.get.pending", { args: void 0, data });
|
|
2146
2879
|
if (!data) {
|
|
2147
2880
|
const globalPreference = yield this._inboxService.fetchGlobalPreferences();
|
|
@@ -2154,10 +2887,10 @@ var PreferenceSchedule = class extends BaseModule {
|
|
|
2154
2887
|
emitterInstance: this._emitter,
|
|
2155
2888
|
inboxServiceInstance: this._inboxService,
|
|
2156
2889
|
cache: this.cache,
|
|
2157
|
-
useCache: chunk7B52C2XE_js.__privateGet(this,
|
|
2890
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache8)
|
|
2158
2891
|
}
|
|
2159
2892
|
);
|
|
2160
|
-
if (chunk7B52C2XE_js.__privateGet(this,
|
|
2893
|
+
if (chunk7B52C2XE_js.__privateGet(this, _useCache8)) {
|
|
2161
2894
|
this.cache.set(data);
|
|
2162
2895
|
data = this.cache.getAll();
|
|
2163
2896
|
}
|
|
@@ -2181,14 +2914,14 @@ var PreferenceSchedule = class extends BaseModule {
|
|
|
2181
2914
|
emitter: this._emitter,
|
|
2182
2915
|
apiService: this._inboxService,
|
|
2183
2916
|
cache: this.cache,
|
|
2184
|
-
useCache: chunk7B52C2XE_js.__privateGet(this,
|
|
2917
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache8),
|
|
2185
2918
|
args
|
|
2186
2919
|
})
|
|
2187
2920
|
);
|
|
2188
2921
|
});
|
|
2189
2922
|
}
|
|
2190
2923
|
};
|
|
2191
|
-
|
|
2924
|
+
_useCache8 = new WeakMap();
|
|
2192
2925
|
|
|
2193
2926
|
// src/cache/preferences-cache.ts
|
|
2194
2927
|
var updateEvents2 = [
|
|
@@ -2211,13 +2944,13 @@ var excludeEmpty2 = ({ tags, severity }) => Object.entries({ tags, severity }).r
|
|
|
2211
2944
|
var getCacheKey2 = ({ tags, severity }) => {
|
|
2212
2945
|
return JSON.stringify(excludeEmpty2({ tags, severity }));
|
|
2213
2946
|
};
|
|
2214
|
-
var
|
|
2947
|
+
var _emitter8, _cache8;
|
|
2215
2948
|
var PreferencesCache = class {
|
|
2216
2949
|
constructor({ emitterInstance }) {
|
|
2217
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2218
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2950
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter8);
|
|
2951
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache8);
|
|
2219
2952
|
this.updatePreference = (key, data) => {
|
|
2220
|
-
const preferences = chunk7B52C2XE_js.__privateGet(this,
|
|
2953
|
+
const preferences = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key);
|
|
2221
2954
|
if (!preferences) {
|
|
2222
2955
|
return false;
|
|
2223
2956
|
}
|
|
@@ -2232,11 +2965,11 @@ var PreferencesCache = class {
|
|
|
2232
2965
|
}
|
|
2233
2966
|
const updatedPreferences = [...preferences];
|
|
2234
2967
|
updatedPreferences[index] = data;
|
|
2235
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2968
|
+
chunk7B52C2XE_js.__privateGet(this, _cache8).set(key, updatedPreferences);
|
|
2236
2969
|
return true;
|
|
2237
2970
|
};
|
|
2238
2971
|
this.updatePreferenceSchedule = (key, data) => {
|
|
2239
|
-
const preferences = chunk7B52C2XE_js.__privateGet(this,
|
|
2972
|
+
const preferences = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key);
|
|
2240
2973
|
if (!preferences) {
|
|
2241
2974
|
return false;
|
|
2242
2975
|
}
|
|
@@ -2246,7 +2979,7 @@ var PreferencesCache = class {
|
|
|
2246
2979
|
}
|
|
2247
2980
|
const updatedPreferences = [...preferences];
|
|
2248
2981
|
updatedPreferences[index].schedule = data;
|
|
2249
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2982
|
+
chunk7B52C2XE_js.__privateGet(this, _cache8).set(key, updatedPreferences);
|
|
2250
2983
|
return true;
|
|
2251
2984
|
};
|
|
2252
2985
|
this.handleScheduleEvent = ({ data }) => {
|
|
@@ -2254,19 +2987,19 @@ var PreferencesCache = class {
|
|
|
2254
2987
|
if (!data) {
|
|
2255
2988
|
return;
|
|
2256
2989
|
}
|
|
2257
|
-
const cacheKeys = chunk7B52C2XE_js.__privateGet(this,
|
|
2990
|
+
const cacheKeys = chunk7B52C2XE_js.__privateGet(this, _cache8).keys();
|
|
2258
2991
|
const uniqueFilterKeys = /* @__PURE__ */ new Set();
|
|
2259
2992
|
for (const key of cacheKeys) {
|
|
2260
2993
|
const hasUpdatedPreference = this.updatePreferenceSchedule(key, data);
|
|
2261
|
-
const updatedPreference = chunk7B52C2XE_js.__privateGet(this,
|
|
2994
|
+
const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key);
|
|
2262
2995
|
if (!hasUpdatedPreference || !updatedPreference) {
|
|
2263
2996
|
continue;
|
|
2264
2997
|
}
|
|
2265
2998
|
uniqueFilterKeys.add(key);
|
|
2266
2999
|
}
|
|
2267
3000
|
for (const key of uniqueFilterKeys) {
|
|
2268
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2269
|
-
data: (_a = chunk7B52C2XE_js.__privateGet(this,
|
|
3001
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter8).emit("preferences.list.updated", {
|
|
3002
|
+
data: (_a = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key)) != null ? _a : []
|
|
2270
3003
|
});
|
|
2271
3004
|
}
|
|
2272
3005
|
};
|
|
@@ -2276,10 +3009,10 @@ var PreferencesCache = class {
|
|
|
2276
3009
|
}
|
|
2277
3010
|
const preferences = Array.isArray(data) ? data : [data];
|
|
2278
3011
|
const uniqueFilterKeys = /* @__PURE__ */ new Set();
|
|
2279
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3012
|
+
chunk7B52C2XE_js.__privateGet(this, _cache8).keys().forEach((key) => {
|
|
2280
3013
|
preferences.forEach((preference) => {
|
|
2281
3014
|
const hasUpdatedPreference = this.updatePreference(key, preference);
|
|
2282
|
-
const updatedPreference = chunk7B52C2XE_js.__privateGet(this,
|
|
3015
|
+
const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key);
|
|
2283
3016
|
if (!hasUpdatedPreference || !updatedPreference) {
|
|
2284
3017
|
return;
|
|
2285
3018
|
}
|
|
@@ -2288,37 +3021,37 @@ var PreferencesCache = class {
|
|
|
2288
3021
|
});
|
|
2289
3022
|
uniqueFilterKeys.forEach((key) => {
|
|
2290
3023
|
var _a;
|
|
2291
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2292
|
-
data: (_a = chunk7B52C2XE_js.__privateGet(this,
|
|
3024
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter8).emit("preferences.list.updated", {
|
|
3025
|
+
data: (_a = chunk7B52C2XE_js.__privateGet(this, _cache8).get(key)) != null ? _a : []
|
|
2293
3026
|
});
|
|
2294
3027
|
});
|
|
2295
3028
|
};
|
|
2296
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
3029
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter8, emitterInstance);
|
|
2297
3030
|
for (const event of updateEvents2) {
|
|
2298
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3031
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter8).on(event, this.handlePreferenceEvent);
|
|
2299
3032
|
}
|
|
2300
3033
|
for (const event of scheduleUpdateEvents) {
|
|
2301
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3034
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter8).on(event, this.handleScheduleEvent);
|
|
2302
3035
|
}
|
|
2303
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
3036
|
+
chunk7B52C2XE_js.__privateSet(this, _cache8, new InMemoryCache());
|
|
2304
3037
|
}
|
|
2305
3038
|
has(args) {
|
|
2306
|
-
return chunk7B52C2XE_js.__privateGet(this,
|
|
3039
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache8).get(getCacheKey2(args)) !== void 0;
|
|
2307
3040
|
}
|
|
2308
3041
|
set(args, data) {
|
|
2309
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3042
|
+
chunk7B52C2XE_js.__privateGet(this, _cache8).set(getCacheKey2(args), data);
|
|
2310
3043
|
}
|
|
2311
3044
|
getAll(args) {
|
|
2312
3045
|
if (this.has(args)) {
|
|
2313
|
-
return chunk7B52C2XE_js.__privateGet(this,
|
|
3046
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache8).get(getCacheKey2(args));
|
|
2314
3047
|
}
|
|
2315
3048
|
}
|
|
2316
3049
|
clearAll() {
|
|
2317
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3050
|
+
chunk7B52C2XE_js.__privateGet(this, _cache8).clear();
|
|
2318
3051
|
}
|
|
2319
3052
|
};
|
|
2320
|
-
|
|
2321
|
-
|
|
3053
|
+
_emitter8 = new WeakMap();
|
|
3054
|
+
_cache8 = new WeakMap();
|
|
2322
3055
|
|
|
2323
3056
|
// src/cache/schedule-cache.ts
|
|
2324
3057
|
var updateEvents3 = [
|
|
@@ -2328,17 +3061,17 @@ var updateEvents3 = [
|
|
|
2328
3061
|
var getCacheKey3 = () => {
|
|
2329
3062
|
return "schedule";
|
|
2330
3063
|
};
|
|
2331
|
-
var
|
|
3064
|
+
var _emitter9, _cache9;
|
|
2332
3065
|
var ScheduleCache = class {
|
|
2333
3066
|
constructor({ emitterInstance }) {
|
|
2334
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2335
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
3067
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter9);
|
|
3068
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache9);
|
|
2336
3069
|
this.updateScheduleInCache = (key, data) => {
|
|
2337
|
-
const schedule = chunk7B52C2XE_js.__privateGet(this,
|
|
3070
|
+
const schedule = chunk7B52C2XE_js.__privateGet(this, _cache9).get(key);
|
|
2338
3071
|
if (!schedule) {
|
|
2339
3072
|
return false;
|
|
2340
3073
|
}
|
|
2341
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3074
|
+
chunk7B52C2XE_js.__privateGet(this, _cache9).set(key, data);
|
|
2342
3075
|
return true;
|
|
2343
3076
|
};
|
|
2344
3077
|
this.handleScheduleEvent = ({ data }) => {
|
|
@@ -2346,47 +3079,47 @@ var ScheduleCache = class {
|
|
|
2346
3079
|
return;
|
|
2347
3080
|
}
|
|
2348
3081
|
const uniqueFilterKeys = /* @__PURE__ */ new Set();
|
|
2349
|
-
const keys = chunk7B52C2XE_js.__privateGet(this,
|
|
3082
|
+
const keys = chunk7B52C2XE_js.__privateGet(this, _cache9).keys();
|
|
2350
3083
|
for (const key of keys) {
|
|
2351
3084
|
const hasUpdatedSchedule = this.updateScheduleInCache(key, data);
|
|
2352
|
-
const updatedSchedule = chunk7B52C2XE_js.__privateGet(this,
|
|
3085
|
+
const updatedSchedule = chunk7B52C2XE_js.__privateGet(this, _cache9).get(key);
|
|
2353
3086
|
if (!hasUpdatedSchedule || !updatedSchedule) {
|
|
2354
3087
|
continue;
|
|
2355
3088
|
}
|
|
2356
3089
|
uniqueFilterKeys.add(key);
|
|
2357
3090
|
}
|
|
2358
3091
|
for (const key of uniqueFilterKeys) {
|
|
2359
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2360
|
-
data: chunk7B52C2XE_js.__privateGet(this,
|
|
3092
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter9).emit("preference.schedule.get.updated", {
|
|
3093
|
+
data: chunk7B52C2XE_js.__privateGet(this, _cache9).get(key)
|
|
2361
3094
|
});
|
|
2362
3095
|
}
|
|
2363
3096
|
};
|
|
2364
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
3097
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter9, emitterInstance);
|
|
2365
3098
|
for (const event of updateEvents3) {
|
|
2366
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3099
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter9).on(event, this.handleScheduleEvent);
|
|
2367
3100
|
}
|
|
2368
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
3101
|
+
chunk7B52C2XE_js.__privateSet(this, _cache9, new InMemoryCache());
|
|
2369
3102
|
}
|
|
2370
3103
|
has() {
|
|
2371
|
-
return chunk7B52C2XE_js.__privateGet(this,
|
|
3104
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache9).get(getCacheKey3()) !== void 0;
|
|
2372
3105
|
}
|
|
2373
3106
|
set(data) {
|
|
2374
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3107
|
+
chunk7B52C2XE_js.__privateGet(this, _cache9).set(getCacheKey3(), data);
|
|
2375
3108
|
}
|
|
2376
3109
|
getAll() {
|
|
2377
3110
|
if (this.has()) {
|
|
2378
|
-
return chunk7B52C2XE_js.__privateGet(this,
|
|
3111
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache9).get(getCacheKey3());
|
|
2379
3112
|
}
|
|
2380
3113
|
}
|
|
2381
3114
|
clearAll() {
|
|
2382
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3115
|
+
chunk7B52C2XE_js.__privateGet(this, _cache9).clear();
|
|
2383
3116
|
}
|
|
2384
3117
|
};
|
|
2385
|
-
|
|
2386
|
-
|
|
3118
|
+
_emitter9 = new WeakMap();
|
|
3119
|
+
_cache9 = new WeakMap();
|
|
2387
3120
|
|
|
2388
3121
|
// src/preferences/preferences.ts
|
|
2389
|
-
var
|
|
3122
|
+
var _useCache9;
|
|
2390
3123
|
var Preferences = class extends BaseModule {
|
|
2391
3124
|
constructor({
|
|
2392
3125
|
useCache,
|
|
@@ -2397,14 +3130,14 @@ var Preferences = class extends BaseModule {
|
|
|
2397
3130
|
eventEmitterInstance,
|
|
2398
3131
|
inboxServiceInstance
|
|
2399
3132
|
});
|
|
2400
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
3133
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache9);
|
|
2401
3134
|
this.cache = new PreferencesCache({
|
|
2402
3135
|
emitterInstance: this._emitter
|
|
2403
3136
|
});
|
|
2404
3137
|
this.scheduleCache = new ScheduleCache({
|
|
2405
3138
|
emitterInstance: this._emitter
|
|
2406
3139
|
});
|
|
2407
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
3140
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache9, useCache);
|
|
2408
3141
|
this.schedule = new PreferenceSchedule({
|
|
2409
3142
|
cache: this.scheduleCache,
|
|
2410
3143
|
useCache,
|
|
@@ -2417,7 +3150,7 @@ var Preferences = class extends BaseModule {
|
|
|
2417
3150
|
return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
2418
3151
|
var _a;
|
|
2419
3152
|
try {
|
|
2420
|
-
let data = chunk7B52C2XE_js.__privateGet(this,
|
|
3153
|
+
let data = chunk7B52C2XE_js.__privateGet(this, _useCache9) ? this.cache.getAll(args) : void 0;
|
|
2421
3154
|
this._emitter.emit("preferences.list.pending", { args, data });
|
|
2422
3155
|
if (!data) {
|
|
2423
3156
|
const response = yield this._inboxService.fetchPreferences({
|
|
@@ -2431,10 +3164,10 @@ var Preferences = class extends BaseModule {
|
|
|
2431
3164
|
inboxServiceInstance: this._inboxService,
|
|
2432
3165
|
cache: this.cache,
|
|
2433
3166
|
scheduleCache: this.scheduleCache,
|
|
2434
|
-
useCache: chunk7B52C2XE_js.__privateGet(this,
|
|
3167
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache9)
|
|
2435
3168
|
})
|
|
2436
3169
|
);
|
|
2437
|
-
if (chunk7B52C2XE_js.__privateGet(this,
|
|
3170
|
+
if (chunk7B52C2XE_js.__privateGet(this, _useCache9)) {
|
|
2438
3171
|
this.cache.set(args, data);
|
|
2439
3172
|
data = this.cache.getAll(args);
|
|
2440
3173
|
}
|
|
@@ -2456,7 +3189,7 @@ var Preferences = class extends BaseModule {
|
|
|
2456
3189
|
apiService: this._inboxService,
|
|
2457
3190
|
cache: this.cache,
|
|
2458
3191
|
scheduleCache: this.scheduleCache,
|
|
2459
|
-
useCache: chunk7B52C2XE_js.__privateGet(this,
|
|
3192
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache9),
|
|
2460
3193
|
args
|
|
2461
3194
|
})
|
|
2462
3195
|
);
|
|
@@ -2470,14 +3203,14 @@ var Preferences = class extends BaseModule {
|
|
|
2470
3203
|
apiService: this._inboxService,
|
|
2471
3204
|
cache: this.cache,
|
|
2472
3205
|
scheduleCache: this.scheduleCache,
|
|
2473
|
-
useCache: chunk7B52C2XE_js.__privateGet(this,
|
|
3206
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache9),
|
|
2474
3207
|
args
|
|
2475
3208
|
})
|
|
2476
3209
|
);
|
|
2477
3210
|
});
|
|
2478
3211
|
}
|
|
2479
3212
|
};
|
|
2480
|
-
|
|
3213
|
+
_useCache9 = new WeakMap();
|
|
2481
3214
|
|
|
2482
3215
|
// src/utils/is-browser.ts
|
|
2483
3216
|
function isBrowser() {
|
|
@@ -2485,14 +3218,14 @@ function isBrowser() {
|
|
|
2485
3218
|
}
|
|
2486
3219
|
|
|
2487
3220
|
// src/session/session.ts
|
|
2488
|
-
var
|
|
3221
|
+
var _emitter10, _inboxService5, _options;
|
|
2489
3222
|
var Session = class {
|
|
2490
3223
|
constructor(options, inboxServiceInstance, eventEmitterInstance) {
|
|
2491
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2492
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
3224
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter10);
|
|
3225
|
+
chunk7B52C2XE_js.__privateAdd(this, _inboxService5);
|
|
2493
3226
|
chunk7B52C2XE_js.__privateAdd(this, _options);
|
|
2494
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2495
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
3227
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter10, eventEmitterInstance);
|
|
3228
|
+
chunk7B52C2XE_js.__privateSet(this, _inboxService5, inboxServiceInstance);
|
|
2496
3229
|
chunk7B52C2XE_js.__privateSet(this, _options, options);
|
|
2497
3230
|
}
|
|
2498
3231
|
get applicationIdentifier() {
|
|
@@ -2563,8 +3296,8 @@ var Session = class {
|
|
|
2563
3296
|
} else {
|
|
2564
3297
|
this.handleApplicationIdentifier("delete");
|
|
2565
3298
|
}
|
|
2566
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2567
|
-
const response = yield chunk7B52C2XE_js.__privateGet(this,
|
|
3299
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter10).emit("session.initialize.pending", { args: chunk7B52C2XE_js.__privateGet(this, _options) });
|
|
3300
|
+
const response = yield chunk7B52C2XE_js.__privateGet(this, _inboxService5).initializeSession({
|
|
2568
3301
|
applicationIdentifier: finalApplicationIdentifier,
|
|
2569
3302
|
subscriberHash,
|
|
2570
3303
|
contextHash,
|
|
@@ -2581,15 +3314,15 @@ var Session = class {
|
|
|
2581
3314
|
if (!((_f = response == null ? void 0 : response.applicationIdentifier) == null ? void 0 : _f.startsWith("pk_keyless_"))) {
|
|
2582
3315
|
this.handleApplicationIdentifier("delete");
|
|
2583
3316
|
}
|
|
2584
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3317
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter10).emit("session.initialize.resolved", { args: chunk7B52C2XE_js.__privateGet(this, _options), data: response });
|
|
2585
3318
|
} catch (error) {
|
|
2586
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3319
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter10).emit("session.initialize.resolved", { args: chunk7B52C2XE_js.__privateGet(this, _options), error });
|
|
2587
3320
|
}
|
|
2588
3321
|
});
|
|
2589
3322
|
}
|
|
2590
3323
|
};
|
|
2591
|
-
|
|
2592
|
-
|
|
3324
|
+
_emitter10 = new WeakMap();
|
|
3325
|
+
_inboxService5 = new WeakMap();
|
|
2593
3326
|
_options = new WeakMap();
|
|
2594
3327
|
var PRODUCTION_SOCKET_URL = "wss://socket.novu.co";
|
|
2595
3328
|
var NOTIFICATION_RECEIVED = "notifications.notification_received";
|
|
@@ -2682,7 +3415,7 @@ var mapToNotification = ({
|
|
|
2682
3415
|
severity
|
|
2683
3416
|
});
|
|
2684
3417
|
};
|
|
2685
|
-
var _token,
|
|
3418
|
+
var _token, _emitter11, _partySocket, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _handleMessage, _PartySocketClient_instances, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
|
|
2686
3419
|
var PartySocketClient = class extends BaseModule {
|
|
2687
3420
|
constructor({
|
|
2688
3421
|
socketUrl,
|
|
@@ -2695,15 +3428,15 @@ var PartySocketClient = class extends BaseModule {
|
|
|
2695
3428
|
});
|
|
2696
3429
|
chunk7B52C2XE_js.__privateAdd(this, _PartySocketClient_instances);
|
|
2697
3430
|
chunk7B52C2XE_js.__privateAdd(this, _token);
|
|
2698
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
3431
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter11);
|
|
2699
3432
|
chunk7B52C2XE_js.__privateAdd(this, _partySocket);
|
|
2700
3433
|
chunk7B52C2XE_js.__privateAdd(this, _socketUrl);
|
|
2701
3434
|
chunk7B52C2XE_js.__privateAdd(this, _notificationReceived, (event) => {
|
|
2702
3435
|
try {
|
|
2703
3436
|
const data = JSON.parse(event.data);
|
|
2704
3437
|
if (data.event === "notification_received" /* RECEIVED */) {
|
|
2705
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2706
|
-
result: new Notification(mapToNotification(data.data.message), chunk7B52C2XE_js.__privateGet(this,
|
|
3438
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter11).emit(NOTIFICATION_RECEIVED, {
|
|
3439
|
+
result: new Notification(mapToNotification(data.data.message), chunk7B52C2XE_js.__privateGet(this, _emitter11), this._inboxService)
|
|
2707
3440
|
});
|
|
2708
3441
|
}
|
|
2709
3442
|
} catch (error) {
|
|
@@ -2714,7 +3447,7 @@ var PartySocketClient = class extends BaseModule {
|
|
|
2714
3447
|
try {
|
|
2715
3448
|
const data = JSON.parse(event.data);
|
|
2716
3449
|
if (data.event === "unseen_count_changed" /* UNSEEN */) {
|
|
2717
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3450
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter11).emit(UNSEEN_COUNT_CHANGED, {
|
|
2718
3451
|
result: data.data.unseenCount
|
|
2719
3452
|
});
|
|
2720
3453
|
}
|
|
@@ -2725,7 +3458,7 @@ var PartySocketClient = class extends BaseModule {
|
|
|
2725
3458
|
try {
|
|
2726
3459
|
const data = JSON.parse(event.data);
|
|
2727
3460
|
if (data.event === "unread_count_changed" /* UNREAD */) {
|
|
2728
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3461
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter11).emit(UNREAD_COUNT_CHANGED, {
|
|
2729
3462
|
result: data.data.counts
|
|
2730
3463
|
});
|
|
2731
3464
|
}
|
|
@@ -2750,7 +3483,7 @@ var PartySocketClient = class extends BaseModule {
|
|
|
2750
3483
|
} catch (error) {
|
|
2751
3484
|
}
|
|
2752
3485
|
});
|
|
2753
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
3486
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter11, eventEmitterInstance);
|
|
2754
3487
|
chunk7B52C2XE_js.__privateSet(this, _socketUrl, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL);
|
|
2755
3488
|
}
|
|
2756
3489
|
onSessionSuccess({ token }) {
|
|
@@ -2777,7 +3510,7 @@ var PartySocketClient = class extends BaseModule {
|
|
|
2777
3510
|
}
|
|
2778
3511
|
};
|
|
2779
3512
|
_token = new WeakMap();
|
|
2780
|
-
|
|
3513
|
+
_emitter11 = new WeakMap();
|
|
2781
3514
|
_partySocket = new WeakMap();
|
|
2782
3515
|
_socketUrl = new WeakMap();
|
|
2783
3516
|
_notificationReceived = new WeakMap();
|
|
@@ -2791,15 +3524,15 @@ initializeSocket_fn = function() {
|
|
|
2791
3524
|
return;
|
|
2792
3525
|
}
|
|
2793
3526
|
const args = { socketUrl: chunk7B52C2XE_js.__privateGet(this, _socketUrl) };
|
|
2794
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3527
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter11).emit("socket.connect.pending", { args });
|
|
2795
3528
|
const url = new URL(chunk7B52C2XE_js.__privateGet(this, _socketUrl));
|
|
2796
3529
|
url.searchParams.set("token", chunk7B52C2XE_js.__privateGet(this, _token));
|
|
2797
3530
|
chunk7B52C2XE_js.__privateSet(this, _partySocket, new partysocket.WebSocket(url.toString()));
|
|
2798
3531
|
chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("open", () => {
|
|
2799
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3532
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter11).emit("socket.connect.resolved", { args });
|
|
2800
3533
|
});
|
|
2801
3534
|
chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("error", (error) => {
|
|
2802
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3535
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter11).emit("socket.connect.resolved", { args, error });
|
|
2803
3536
|
});
|
|
2804
3537
|
chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("message", chunk7B52C2XE_js.__privateGet(this, _handleMessage));
|
|
2805
3538
|
});
|
|
@@ -2917,7 +3650,7 @@ var mapToNotification2 = ({
|
|
|
2917
3650
|
severity
|
|
2918
3651
|
});
|
|
2919
3652
|
};
|
|
2920
|
-
var _token2,
|
|
3653
|
+
var _token2, _emitter12, _socketIo, _socketUrl2, _notificationReceived2, _unseenCountChanged2, _unreadCountChanged2, _Socket_instances, initializeSocket_fn2, handleConnectSocket_fn2, handleDisconnectSocket_fn2;
|
|
2921
3654
|
var Socket = class extends BaseModule {
|
|
2922
3655
|
constructor({
|
|
2923
3656
|
socketUrl,
|
|
@@ -2930,25 +3663,25 @@ var Socket = class extends BaseModule {
|
|
|
2930
3663
|
});
|
|
2931
3664
|
chunk7B52C2XE_js.__privateAdd(this, _Socket_instances);
|
|
2932
3665
|
chunk7B52C2XE_js.__privateAdd(this, _token2);
|
|
2933
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
3666
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter12);
|
|
2934
3667
|
chunk7B52C2XE_js.__privateAdd(this, _socketIo);
|
|
2935
3668
|
chunk7B52C2XE_js.__privateAdd(this, _socketUrl2);
|
|
2936
3669
|
chunk7B52C2XE_js.__privateAdd(this, _notificationReceived2, ({ message }) => {
|
|
2937
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2938
|
-
result: new Notification(mapToNotification2(message), chunk7B52C2XE_js.__privateGet(this,
|
|
3670
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter12).emit(NOTIFICATION_RECEIVED2, {
|
|
3671
|
+
result: new Notification(mapToNotification2(message), chunk7B52C2XE_js.__privateGet(this, _emitter12), this._inboxService)
|
|
2939
3672
|
});
|
|
2940
3673
|
});
|
|
2941
3674
|
chunk7B52C2XE_js.__privateAdd(this, _unseenCountChanged2, ({ unseenCount }) => {
|
|
2942
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3675
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter12).emit(UNSEEN_COUNT_CHANGED2, {
|
|
2943
3676
|
result: unseenCount
|
|
2944
3677
|
});
|
|
2945
3678
|
});
|
|
2946
3679
|
chunk7B52C2XE_js.__privateAdd(this, _unreadCountChanged2, ({ counts }) => {
|
|
2947
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3680
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter12).emit(UNREAD_COUNT_CHANGED2, {
|
|
2948
3681
|
result: counts
|
|
2949
3682
|
});
|
|
2950
3683
|
});
|
|
2951
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
3684
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter12, eventEmitterInstance);
|
|
2952
3685
|
chunk7B52C2XE_js.__privateSet(this, _socketUrl2, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL2);
|
|
2953
3686
|
}
|
|
2954
3687
|
onSessionSuccess({ token }) {
|
|
@@ -2975,7 +3708,7 @@ var Socket = class extends BaseModule {
|
|
|
2975
3708
|
}
|
|
2976
3709
|
};
|
|
2977
3710
|
_token2 = new WeakMap();
|
|
2978
|
-
|
|
3711
|
+
_emitter12 = new WeakMap();
|
|
2979
3712
|
_socketIo = new WeakMap();
|
|
2980
3713
|
_socketUrl2 = new WeakMap();
|
|
2981
3714
|
_notificationReceived2 = new WeakMap();
|
|
@@ -2989,7 +3722,7 @@ initializeSocket_fn2 = function() {
|
|
|
2989
3722
|
return;
|
|
2990
3723
|
}
|
|
2991
3724
|
const args = { socketUrl: chunk7B52C2XE_js.__privateGet(this, _socketUrl2) };
|
|
2992
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3725
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter12).emit("socket.connect.pending", { args });
|
|
2993
3726
|
chunk7B52C2XE_js.__privateSet(this, _socketIo, io__default.default(chunk7B52C2XE_js.__privateGet(this, _socketUrl2), {
|
|
2994
3727
|
reconnectionDelayMax: 1e4,
|
|
2995
3728
|
transports: ["websocket"],
|
|
@@ -2998,10 +3731,10 @@ initializeSocket_fn2 = function() {
|
|
|
2998
3731
|
}
|
|
2999
3732
|
}));
|
|
3000
3733
|
chunk7B52C2XE_js.__privateGet(this, _socketIo).on("connect", () => {
|
|
3001
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3734
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter12).emit("socket.connect.resolved", { args });
|
|
3002
3735
|
});
|
|
3003
3736
|
chunk7B52C2XE_js.__privateGet(this, _socketIo).on("connect_error", (error) => {
|
|
3004
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3737
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter12).emit("socket.connect.resolved", { args, error });
|
|
3005
3738
|
});
|
|
3006
3739
|
(_a = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _a.on("notification_received" /* RECEIVED */, chunk7B52C2XE_js.__privateGet(this, _notificationReceived2));
|
|
3007
3740
|
(_b = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _b.on("unseen_count_changed" /* UNSEEN */, chunk7B52C2XE_js.__privateGet(this, _unseenCountChanged2));
|
|
@@ -3075,57 +3808,66 @@ function createSocket({
|
|
|
3075
3808
|
}
|
|
3076
3809
|
|
|
3077
3810
|
// src/novu.ts
|
|
3078
|
-
var
|
|
3811
|
+
var _emitter13, _session, _inboxService6, _options2;
|
|
3079
3812
|
var Novu = class {
|
|
3080
3813
|
constructor(options) {
|
|
3081
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
3814
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter13);
|
|
3082
3815
|
chunk7B52C2XE_js.__privateAdd(this, _session);
|
|
3083
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
3084
|
-
|
|
3085
|
-
|
|
3816
|
+
chunk7B52C2XE_js.__privateAdd(this, _inboxService6);
|
|
3817
|
+
chunk7B52C2XE_js.__privateAdd(this, _options2);
|
|
3818
|
+
var _a, _b, _c;
|
|
3819
|
+
chunk7B52C2XE_js.__privateSet(this, _options2, options);
|
|
3820
|
+
chunk7B52C2XE_js.__privateSet(this, _inboxService6, new InboxService({
|
|
3086
3821
|
apiUrl: options.apiUrl || options.backendUrl,
|
|
3087
3822
|
userAgent: options.__userAgent
|
|
3088
3823
|
}));
|
|
3089
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
3824
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter13, new NovuEventEmitter());
|
|
3825
|
+
const subscriber = chunkOZV3TKWX_js.buildSubscriber({ subscriberId: options.subscriberId, subscriber: options.subscriber });
|
|
3090
3826
|
chunk7B52C2XE_js.__privateSet(this, _session, new Session(
|
|
3091
3827
|
{
|
|
3092
3828
|
applicationIdentifier: options.applicationIdentifier || "",
|
|
3093
3829
|
subscriberHash: options.subscriberHash,
|
|
3094
|
-
subscriber
|
|
3830
|
+
subscriber,
|
|
3095
3831
|
defaultSchedule: options.defaultSchedule,
|
|
3096
3832
|
context: options.context,
|
|
3097
3833
|
contextHash: options.contextHash
|
|
3098
3834
|
},
|
|
3099
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3100
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3835
|
+
chunk7B52C2XE_js.__privateGet(this, _inboxService6),
|
|
3836
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter13)
|
|
3101
3837
|
));
|
|
3102
3838
|
chunk7B52C2XE_js.__privateGet(this, _session).initialize();
|
|
3103
3839
|
this.notifications = new Notifications({
|
|
3104
3840
|
useCache: (_a = options.useCache) != null ? _a : true,
|
|
3105
|
-
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this,
|
|
3106
|
-
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this,
|
|
3841
|
+
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService6),
|
|
3842
|
+
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter13)
|
|
3107
3843
|
});
|
|
3108
3844
|
this.preferences = new Preferences({
|
|
3109
3845
|
useCache: (_b = options.useCache) != null ? _b : true,
|
|
3110
|
-
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this,
|
|
3111
|
-
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this,
|
|
3846
|
+
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService6),
|
|
3847
|
+
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter13)
|
|
3848
|
+
});
|
|
3849
|
+
this.subscriptions = new Subscriptions({
|
|
3850
|
+
subscriber,
|
|
3851
|
+
useCache: (_c = options.useCache) != null ? _c : true,
|
|
3852
|
+
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService6),
|
|
3853
|
+
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter13)
|
|
3112
3854
|
});
|
|
3113
3855
|
this.socket = createSocket({
|
|
3114
3856
|
socketUrl: options.socketUrl,
|
|
3115
|
-
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this,
|
|
3116
|
-
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this,
|
|
3857
|
+
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter13),
|
|
3858
|
+
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService6)
|
|
3117
3859
|
});
|
|
3118
3860
|
this.on = (eventName, listener) => {
|
|
3119
3861
|
if (this.socket.isSocketEvent(eventName)) {
|
|
3120
3862
|
this.socket.connect();
|
|
3121
3863
|
}
|
|
3122
|
-
const cleanup = chunk7B52C2XE_js.__privateGet(this,
|
|
3864
|
+
const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter13).on(eventName, listener);
|
|
3123
3865
|
return () => {
|
|
3124
3866
|
cleanup();
|
|
3125
3867
|
};
|
|
3126
3868
|
};
|
|
3127
3869
|
this.off = (eventName, listener) => {
|
|
3128
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
3870
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter13).off(eventName, listener);
|
|
3129
3871
|
};
|
|
3130
3872
|
}
|
|
3131
3873
|
get applicationIdentifier() {
|
|
@@ -3137,9 +3879,21 @@ var Novu = class {
|
|
|
3137
3879
|
get context() {
|
|
3138
3880
|
return chunk7B52C2XE_js.__privateGet(this, _session).context;
|
|
3139
3881
|
}
|
|
3882
|
+
get options() {
|
|
3883
|
+
return chunk7B52C2XE_js.__privateGet(this, _options2);
|
|
3884
|
+
}
|
|
3140
3885
|
get contextKey() {
|
|
3141
|
-
return
|
|
3886
|
+
return chunkOZV3TKWX_js.buildContextKey(chunk7B52C2XE_js.__privateGet(this, _session).context);
|
|
3887
|
+
}
|
|
3888
|
+
clearCache() {
|
|
3889
|
+
this.notifications.cache.clearAll();
|
|
3890
|
+
this.preferences.cache.clearAll();
|
|
3891
|
+
this.preferences.scheduleCache.clearAll();
|
|
3892
|
+
this.subscriptions.cache.clearAll();
|
|
3142
3893
|
}
|
|
3894
|
+
/**
|
|
3895
|
+
* @deprecated
|
|
3896
|
+
*/
|
|
3143
3897
|
changeSubscriber(options) {
|
|
3144
3898
|
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
3145
3899
|
yield chunk7B52C2XE_js.__privateGet(this, _session).initialize({
|
|
@@ -3150,13 +3904,16 @@ var Novu = class {
|
|
|
3150
3904
|
context: chunk7B52C2XE_js.__privateGet(this, _session).context,
|
|
3151
3905
|
contextHash: chunk7B52C2XE_js.__privateGet(this, _session).contextHash
|
|
3152
3906
|
});
|
|
3153
|
-
this.
|
|
3907
|
+
this.clearCache();
|
|
3154
3908
|
const disconnectResult = yield this.socket.disconnect();
|
|
3155
3909
|
if (!disconnectResult.error) {
|
|
3156
3910
|
yield this.socket.connect();
|
|
3157
3911
|
}
|
|
3158
3912
|
});
|
|
3159
3913
|
}
|
|
3914
|
+
/**
|
|
3915
|
+
* @deprecated
|
|
3916
|
+
*/
|
|
3160
3917
|
changeContext(options) {
|
|
3161
3918
|
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
3162
3919
|
const currentSubscriber = chunk7B52C2XE_js.__privateGet(this, _session).subscriber;
|
|
@@ -3171,7 +3928,7 @@ var Novu = class {
|
|
|
3171
3928
|
context: options.context,
|
|
3172
3929
|
contextHash: options.contextHash
|
|
3173
3930
|
});
|
|
3174
|
-
this.
|
|
3931
|
+
this.clearCache();
|
|
3175
3932
|
const disconnectResult = yield this.socket.disconnect();
|
|
3176
3933
|
if (!disconnectResult.error) {
|
|
3177
3934
|
yield this.socket.connect();
|
|
@@ -3179,16 +3936,20 @@ var Novu = class {
|
|
|
3179
3936
|
});
|
|
3180
3937
|
}
|
|
3181
3938
|
};
|
|
3182
|
-
|
|
3939
|
+
_emitter13 = new WeakMap();
|
|
3183
3940
|
_session = new WeakMap();
|
|
3184
|
-
|
|
3941
|
+
_inboxService6 = new WeakMap();
|
|
3942
|
+
_options2 = new WeakMap();
|
|
3185
3943
|
|
|
3186
3944
|
exports.ChannelType = ChannelType;
|
|
3187
3945
|
exports.DEFAULT_API_VERSION = DEFAULT_API_VERSION;
|
|
3188
3946
|
exports.NotificationStatus = NotificationStatus;
|
|
3189
3947
|
exports.Novu = Novu;
|
|
3948
|
+
exports.NovuError = NovuError;
|
|
3190
3949
|
exports.PreferenceLevel = PreferenceLevel;
|
|
3191
3950
|
exports.SeverityLevelEnum = SeverityLevelEnum;
|
|
3951
|
+
exports.SubscriptionPreference = SubscriptionPreference;
|
|
3952
|
+
exports.TopicSubscription = TopicSubscription;
|
|
3192
3953
|
exports.WebSocketEvent = WebSocketEvent;
|
|
3193
3954
|
exports.WorkflowCriticalityEnum = WorkflowCriticalityEnum;
|
|
3194
3955
|
exports.areSeveritiesEqual = areSeveritiesEqual;
|