@novu/js 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chunk-7B52C2XE.js +70 -0
- package/dist/cjs/{chunk-HEC6BX2T.js → chunk-AALXN67T.js} +237 -304
- package/dist/cjs/index.js +15 -14
- package/dist/cjs/themes/index.d.ts +7 -0
- package/dist/cjs/themes/index.js +17 -0
- package/dist/cjs/types-yDke_w6U.d.ts +98 -0
- package/dist/cjs/ui/index.d.ts +6 -97
- package/dist/cjs/ui/index.js +162 -145
- package/dist/esm/{chunk-J3BKCO4X.mjs → chunk-QIWP6QB5.mjs} +2 -61
- package/dist/esm/chunk-STZMOEWR.mjs +61 -0
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/themes/index.d.mts +7 -0
- package/dist/esm/themes/index.mjs +15 -0
- package/dist/esm/types-xYLv4vWZ.d.mts +98 -0
- package/dist/esm/ui/index.d.mts +6 -97
- package/dist/esm/ui/index.mjs +67 -50
- package/dist/index.css +1 -1
- package/dist/novu.min.js +1 -1
- package/dist/novu.min.js.gz +0 -0
- package/package.json +13 -2
- package/themes/package.json +5 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunk7B52C2XE_js = require('./chunk-7B52C2XE.js');
|
|
3
4
|
var mitt = require('mitt');
|
|
4
5
|
var io = require('socket.io-client');
|
|
5
6
|
var client = require('@novu/client');
|
|
@@ -9,66 +10,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
9
10
|
var mitt__default = /*#__PURE__*/_interopDefault(mitt);
|
|
10
11
|
var io__default = /*#__PURE__*/_interopDefault(io);
|
|
11
12
|
|
|
12
|
-
var __defProp = Object.defineProperty;
|
|
13
|
-
var __defProps = Object.defineProperties;
|
|
14
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
15
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
16
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
18
|
-
var __typeError = (msg) => {
|
|
19
|
-
throw TypeError(msg);
|
|
20
|
-
};
|
|
21
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
22
|
-
var __spreadValues = (a, b) => {
|
|
23
|
-
for (var prop in b || (b = {}))
|
|
24
|
-
if (__hasOwnProp.call(b, prop))
|
|
25
|
-
__defNormalProp(a, prop, b[prop]);
|
|
26
|
-
if (__getOwnPropSymbols)
|
|
27
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
28
|
-
if (__propIsEnum.call(b, prop))
|
|
29
|
-
__defNormalProp(a, prop, b[prop]);
|
|
30
|
-
}
|
|
31
|
-
return a;
|
|
32
|
-
};
|
|
33
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
34
|
-
var __objRest = (source, exclude) => {
|
|
35
|
-
var target = {};
|
|
36
|
-
for (var prop in source)
|
|
37
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
38
|
-
target[prop] = source[prop];
|
|
39
|
-
if (source != null && __getOwnPropSymbols)
|
|
40
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
41
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
42
|
-
target[prop] = source[prop];
|
|
43
|
-
}
|
|
44
|
-
return target;
|
|
45
|
-
};
|
|
46
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
47
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
48
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
49
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
50
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
51
|
-
var __async = (__this, __arguments, generator) => {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
var fulfilled = (value) => {
|
|
54
|
-
try {
|
|
55
|
-
step(generator.next(value));
|
|
56
|
-
} catch (e) {
|
|
57
|
-
reject(e);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var rejected = (value) => {
|
|
61
|
-
try {
|
|
62
|
-
step(generator.throw(value));
|
|
63
|
-
} catch (e) {
|
|
64
|
-
reject(e);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
68
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
|
|
72
13
|
// src/types.ts
|
|
73
14
|
var NotificationStatus = /* @__PURE__ */ ((NotificationStatus2) => {
|
|
74
15
|
NotificationStatus2["READ"] = "read";
|
|
@@ -150,17 +91,17 @@ var isSameFilter = (filter1, filter2) => {
|
|
|
150
91
|
var _mittEmitter;
|
|
151
92
|
var NovuEventEmitter = class {
|
|
152
93
|
constructor() {
|
|
153
|
-
__privateAdd(this, _mittEmitter);
|
|
154
|
-
__privateSet(this, _mittEmitter, mitt__default.default());
|
|
94
|
+
chunk7B52C2XE_js.__privateAdd(this, _mittEmitter);
|
|
95
|
+
chunk7B52C2XE_js.__privateSet(this, _mittEmitter, mitt__default.default());
|
|
155
96
|
}
|
|
156
97
|
on(eventName, listener) {
|
|
157
|
-
__privateGet(this, _mittEmitter).on(eventName, listener);
|
|
98
|
+
chunk7B52C2XE_js.__privateGet(this, _mittEmitter).on(eventName, listener);
|
|
158
99
|
}
|
|
159
100
|
off(eventName, listener) {
|
|
160
|
-
__privateGet(this, _mittEmitter).off(eventName, listener);
|
|
101
|
+
chunk7B52C2XE_js.__privateGet(this, _mittEmitter).off(eventName, listener);
|
|
161
102
|
}
|
|
162
103
|
emit(type, event) {
|
|
163
|
-
__privateGet(this, _mittEmitter).emit(type, event);
|
|
104
|
+
chunk7B52C2XE_js.__privateGet(this, _mittEmitter).emit(type, event);
|
|
164
105
|
}
|
|
165
106
|
};
|
|
166
107
|
_mittEmitter = new WeakMap();
|
|
@@ -180,24 +121,24 @@ var BaseModule = class {
|
|
|
180
121
|
inboxServiceInstance,
|
|
181
122
|
eventEmitterInstance
|
|
182
123
|
}) {
|
|
183
|
-
__privateAdd(this, _callsQueue, []);
|
|
184
|
-
__privateAdd(this, _sessionError);
|
|
124
|
+
chunk7B52C2XE_js.__privateAdd(this, _callsQueue, []);
|
|
125
|
+
chunk7B52C2XE_js.__privateAdd(this, _sessionError);
|
|
185
126
|
this._emitter = eventEmitterInstance;
|
|
186
127
|
this._inboxService = inboxServiceInstance;
|
|
187
128
|
this._emitter.on("session.initialize.resolved", ({ error, data }) => {
|
|
188
129
|
if (data) {
|
|
189
130
|
this.onSessionSuccess(data);
|
|
190
|
-
__privateGet(this, _callsQueue).forEach((_0) => __async(this, [_0], function* ({ fn, resolve }) {
|
|
131
|
+
chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach((_0) => chunk7B52C2XE_js.__async(this, [_0], function* ({ fn, resolve }) {
|
|
191
132
|
resolve(yield fn());
|
|
192
133
|
}));
|
|
193
|
-
__privateSet(this, _callsQueue, []);
|
|
134
|
+
chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
|
|
194
135
|
} else if (error) {
|
|
195
136
|
this.onSessionError(error);
|
|
196
|
-
__privateSet(this, _sessionError, error);
|
|
197
|
-
__privateGet(this, _callsQueue).forEach(({ resolve }) => {
|
|
137
|
+
chunk7B52C2XE_js.__privateSet(this, _sessionError, error);
|
|
138
|
+
chunk7B52C2XE_js.__privateGet(this, _callsQueue).forEach(({ resolve }) => {
|
|
198
139
|
resolve({ error: new NovuError("Failed to initialize session, please contact the support", error) });
|
|
199
140
|
});
|
|
200
|
-
__privateSet(this, _callsQueue, []);
|
|
141
|
+
chunk7B52C2XE_js.__privateSet(this, _callsQueue, []);
|
|
201
142
|
}
|
|
202
143
|
});
|
|
203
144
|
}
|
|
@@ -206,17 +147,17 @@ var BaseModule = class {
|
|
|
206
147
|
onSessionError(_) {
|
|
207
148
|
}
|
|
208
149
|
callWithSession(fn) {
|
|
209
|
-
return __async(this, null, function* () {
|
|
150
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
210
151
|
if (this._inboxService.isSessionInitialized) {
|
|
211
152
|
return fn();
|
|
212
153
|
}
|
|
213
|
-
if (__privateGet(this, _sessionError)) {
|
|
154
|
+
if (chunk7B52C2XE_js.__privateGet(this, _sessionError)) {
|
|
214
155
|
return Promise.resolve({
|
|
215
|
-
error: new NovuError("Failed to initialize session, please contact the support", __privateGet(this, _sessionError))
|
|
156
|
+
error: new NovuError("Failed to initialize session, please contact the support", chunk7B52C2XE_js.__privateGet(this, _sessionError))
|
|
216
157
|
});
|
|
217
158
|
}
|
|
218
159
|
return new Promise((resolve, reject) => {
|
|
219
|
-
__privateGet(this, _callsQueue).push({ fn, resolve, reject });
|
|
160
|
+
chunk7B52C2XE_js.__privateGet(this, _callsQueue).push({ fn, resolve, reject });
|
|
220
161
|
});
|
|
221
162
|
});
|
|
222
163
|
}
|
|
@@ -228,10 +169,10 @@ _sessionError = new WeakMap();
|
|
|
228
169
|
var _emitter, _inboxService;
|
|
229
170
|
var Notification = class {
|
|
230
171
|
constructor(notification, emitter, inboxService) {
|
|
231
|
-
__privateAdd(this, _emitter);
|
|
232
|
-
__privateAdd(this, _inboxService);
|
|
233
|
-
__privateSet(this, _emitter, emitter);
|
|
234
|
-
__privateSet(this, _inboxService, inboxService);
|
|
172
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter);
|
|
173
|
+
chunk7B52C2XE_js.__privateAdd(this, _inboxService);
|
|
174
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter, emitter);
|
|
175
|
+
chunk7B52C2XE_js.__privateSet(this, _inboxService, inboxService);
|
|
235
176
|
this.id = notification.id;
|
|
236
177
|
this.subject = notification.subject;
|
|
237
178
|
this.body = notification.body;
|
|
@@ -251,8 +192,8 @@ var Notification = class {
|
|
|
251
192
|
}
|
|
252
193
|
read() {
|
|
253
194
|
return read({
|
|
254
|
-
emitter: __privateGet(this, _emitter),
|
|
255
|
-
apiService: __privateGet(this, _inboxService),
|
|
195
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
196
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
256
197
|
args: {
|
|
257
198
|
notification: this
|
|
258
199
|
}
|
|
@@ -260,8 +201,8 @@ var Notification = class {
|
|
|
260
201
|
}
|
|
261
202
|
unread() {
|
|
262
203
|
return unread({
|
|
263
|
-
emitter: __privateGet(this, _emitter),
|
|
264
|
-
apiService: __privateGet(this, _inboxService),
|
|
204
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
205
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
265
206
|
args: {
|
|
266
207
|
notification: this
|
|
267
208
|
}
|
|
@@ -269,8 +210,8 @@ var Notification = class {
|
|
|
269
210
|
}
|
|
270
211
|
archive() {
|
|
271
212
|
return archive({
|
|
272
|
-
emitter: __privateGet(this, _emitter),
|
|
273
|
-
apiService: __privateGet(this, _inboxService),
|
|
213
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
214
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
274
215
|
args: {
|
|
275
216
|
notification: this
|
|
276
217
|
}
|
|
@@ -278,8 +219,8 @@ var Notification = class {
|
|
|
278
219
|
}
|
|
279
220
|
unarchive() {
|
|
280
221
|
return unarchive({
|
|
281
|
-
emitter: __privateGet(this, _emitter),
|
|
282
|
-
apiService: __privateGet(this, _inboxService),
|
|
222
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
223
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
283
224
|
args: {
|
|
284
225
|
notification: this
|
|
285
226
|
}
|
|
@@ -290,8 +231,8 @@ var Notification = class {
|
|
|
290
231
|
throw new Error("Primary action is not available");
|
|
291
232
|
}
|
|
292
233
|
return completeAction({
|
|
293
|
-
emitter: __privateGet(this, _emitter),
|
|
294
|
-
apiService: __privateGet(this, _inboxService),
|
|
234
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
235
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
295
236
|
args: {
|
|
296
237
|
notification: this
|
|
297
238
|
},
|
|
@@ -303,8 +244,8 @@ var Notification = class {
|
|
|
303
244
|
throw new Error("Secondary action is not available");
|
|
304
245
|
}
|
|
305
246
|
return completeAction({
|
|
306
|
-
emitter: __privateGet(this, _emitter),
|
|
307
|
-
apiService: __privateGet(this, _inboxService),
|
|
247
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
248
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
308
249
|
args: {
|
|
309
250
|
notification: this
|
|
310
251
|
},
|
|
@@ -316,8 +257,8 @@ var Notification = class {
|
|
|
316
257
|
throw new Error("Primary action is not available");
|
|
317
258
|
}
|
|
318
259
|
return revertAction({
|
|
319
|
-
emitter: __privateGet(this, _emitter),
|
|
320
|
-
apiService: __privateGet(this, _inboxService),
|
|
260
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
261
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
321
262
|
args: {
|
|
322
263
|
notification: this
|
|
323
264
|
},
|
|
@@ -329,8 +270,8 @@ var Notification = class {
|
|
|
329
270
|
throw new Error("Secondary action is not available");
|
|
330
271
|
}
|
|
331
272
|
return revertAction({
|
|
332
|
-
emitter: __privateGet(this, _emitter),
|
|
333
|
-
apiService: __privateGet(this, _inboxService),
|
|
273
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
|
|
274
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
|
|
334
275
|
args: {
|
|
335
276
|
notification: this
|
|
336
277
|
},
|
|
@@ -338,17 +279,17 @@ var Notification = class {
|
|
|
338
279
|
});
|
|
339
280
|
}
|
|
340
281
|
on(eventName, listener) {
|
|
341
|
-
__privateGet(this, _emitter).on(eventName, listener);
|
|
282
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter).on(eventName, listener);
|
|
342
283
|
}
|
|
343
284
|
off(eventName, listener) {
|
|
344
|
-
__privateGet(this, _emitter).off(eventName, listener);
|
|
285
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter).off(eventName, listener);
|
|
345
286
|
}
|
|
346
287
|
};
|
|
347
288
|
_emitter = new WeakMap();
|
|
348
289
|
_inboxService = new WeakMap();
|
|
349
290
|
|
|
350
291
|
// src/notifications/helpers.ts
|
|
351
|
-
var read = (_0) => __async(void 0, [_0], function* ({
|
|
292
|
+
var read = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
352
293
|
emitter,
|
|
353
294
|
apiService,
|
|
354
295
|
args
|
|
@@ -380,7 +321,7 @@ var read = (_0) => __async(void 0, [_0], function* ({
|
|
|
380
321
|
return { error: new NovuError("Failed to read notification", error) };
|
|
381
322
|
}
|
|
382
323
|
});
|
|
383
|
-
var unread = (_0) => __async(void 0, [_0], function* ({
|
|
324
|
+
var unread = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
384
325
|
emitter,
|
|
385
326
|
apiService,
|
|
386
327
|
args
|
|
@@ -412,7 +353,7 @@ var unread = (_0) => __async(void 0, [_0], function* ({
|
|
|
412
353
|
return { error: new NovuError("Failed to unread notification", error) };
|
|
413
354
|
}
|
|
414
355
|
});
|
|
415
|
-
var archive = (_0) => __async(void 0, [_0], function* ({
|
|
356
|
+
var archive = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
416
357
|
emitter,
|
|
417
358
|
apiService,
|
|
418
359
|
args
|
|
@@ -444,7 +385,7 @@ var archive = (_0) => __async(void 0, [_0], function* ({
|
|
|
444
385
|
return { error: new NovuError("Failed to archive notification", error) };
|
|
445
386
|
}
|
|
446
387
|
});
|
|
447
|
-
var unarchive = (_0) => __async(void 0, [_0], function* ({
|
|
388
|
+
var unarchive = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
448
389
|
emitter,
|
|
449
390
|
apiService,
|
|
450
391
|
args
|
|
@@ -476,18 +417,18 @@ var unarchive = (_0) => __async(void 0, [_0], function* ({
|
|
|
476
417
|
return { error: new NovuError("Failed to unarchive notification", error) };
|
|
477
418
|
}
|
|
478
419
|
});
|
|
479
|
-
var completeAction = (_0) => __async(void 0, [_0], function* ({
|
|
420
|
+
var completeAction = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
480
421
|
emitter,
|
|
481
422
|
apiService,
|
|
482
423
|
args,
|
|
483
424
|
actionType
|
|
484
425
|
}) {
|
|
485
426
|
const optimisticUpdate = actionType === "primary" /* PRIMARY */ ? {
|
|
486
|
-
primaryAction: __spreadProps(__spreadValues({}, "notification" in args ? args.notification.primaryAction : {}), {
|
|
427
|
+
primaryAction: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, "notification" in args ? args.notification.primaryAction : {}), {
|
|
487
428
|
isCompleted: true
|
|
488
429
|
})
|
|
489
430
|
} : {
|
|
490
|
-
secondaryAction: __spreadProps(__spreadValues({}, "notification" in args ? args.notification.secondaryAction : {}), {
|
|
431
|
+
secondaryAction: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, "notification" in args ? args.notification.secondaryAction : {}), {
|
|
491
432
|
isCompleted: true
|
|
492
433
|
})
|
|
493
434
|
};
|
|
@@ -509,18 +450,18 @@ var completeAction = (_0) => __async(void 0, [_0], function* ({
|
|
|
509
450
|
return { error: new NovuError(`Failed to complete ${actionType} action on the notification`, error) };
|
|
510
451
|
}
|
|
511
452
|
});
|
|
512
|
-
var revertAction = (_0) => __async(void 0, [_0], function* ({
|
|
453
|
+
var revertAction = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
513
454
|
emitter,
|
|
514
455
|
apiService,
|
|
515
456
|
args,
|
|
516
457
|
actionType
|
|
517
458
|
}) {
|
|
518
459
|
const optimisticUpdate = actionType === "primary" /* PRIMARY */ ? {
|
|
519
|
-
primaryAction: __spreadProps(__spreadValues({}, "notification" in args ? args.notification.primaryAction : {}), {
|
|
460
|
+
primaryAction: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, "notification" in args ? args.notification.primaryAction : {}), {
|
|
520
461
|
isCompleted: false
|
|
521
462
|
})
|
|
522
463
|
} : {
|
|
523
|
-
secondaryAction: __spreadProps(__spreadValues({}, "notification" in args ? args.notification.secondaryAction : {}), {
|
|
464
|
+
secondaryAction: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, "notification" in args ? args.notification.secondaryAction : {}), {
|
|
524
465
|
isCompleted: false
|
|
525
466
|
})
|
|
526
467
|
};
|
|
@@ -547,7 +488,7 @@ var getNotificationDetails = (args, update, dependencies) => {
|
|
|
547
488
|
return {
|
|
548
489
|
notificationId: args.notification.id,
|
|
549
490
|
optimisticValue: new Notification(
|
|
550
|
-
__spreadValues(__spreadValues({}, args.notification), update),
|
|
491
|
+
chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, args.notification), update),
|
|
551
492
|
dependencies.emitter,
|
|
552
493
|
dependencies.apiService
|
|
553
494
|
)
|
|
@@ -558,7 +499,7 @@ var getNotificationDetails = (args, update, dependencies) => {
|
|
|
558
499
|
};
|
|
559
500
|
}
|
|
560
501
|
};
|
|
561
|
-
var readAll = (_0) => __async(void 0, [_0], function* ({
|
|
502
|
+
var readAll = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
562
503
|
emitter,
|
|
563
504
|
inboxService,
|
|
564
505
|
notificationsCache,
|
|
@@ -568,7 +509,7 @@ var readAll = (_0) => __async(void 0, [_0], function* ({
|
|
|
568
509
|
const notifications = notificationsCache.getUniqueNotifications({ tags });
|
|
569
510
|
const optimisticNotifications = notifications.map(
|
|
570
511
|
(notification) => new Notification(
|
|
571
|
-
__spreadProps(__spreadValues({}, notification), {
|
|
512
|
+
chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notification), {
|
|
572
513
|
isRead: true,
|
|
573
514
|
readAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
574
515
|
isArchived: false,
|
|
@@ -587,7 +528,7 @@ var readAll = (_0) => __async(void 0, [_0], function* ({
|
|
|
587
528
|
return { error: new NovuError("Failed to read all notifications", error) };
|
|
588
529
|
}
|
|
589
530
|
});
|
|
590
|
-
var archiveAll = (_0) => __async(void 0, [_0], function* ({
|
|
531
|
+
var archiveAll = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
591
532
|
emitter,
|
|
592
533
|
inboxService,
|
|
593
534
|
notificationsCache,
|
|
@@ -597,7 +538,7 @@ var archiveAll = (_0) => __async(void 0, [_0], function* ({
|
|
|
597
538
|
const notifications = notificationsCache.getUniqueNotifications({ tags });
|
|
598
539
|
const optimisticNotifications = notifications.map(
|
|
599
540
|
(notification) => new Notification(
|
|
600
|
-
__spreadProps(__spreadValues({}, notification), {
|
|
541
|
+
chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notification), {
|
|
601
542
|
isRead: true,
|
|
602
543
|
readAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
603
544
|
isArchived: true,
|
|
@@ -616,7 +557,7 @@ var archiveAll = (_0) => __async(void 0, [_0], function* ({
|
|
|
616
557
|
return { error: new NovuError("Failed to archive all notifications", error) };
|
|
617
558
|
}
|
|
618
559
|
});
|
|
619
|
-
var archiveAllRead = (_0) => __async(void 0, [_0], function* ({
|
|
560
|
+
var archiveAllRead = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
620
561
|
emitter,
|
|
621
562
|
inboxService,
|
|
622
563
|
notificationsCache,
|
|
@@ -626,7 +567,7 @@ var archiveAllRead = (_0) => __async(void 0, [_0], function* ({
|
|
|
626
567
|
const notifications = notificationsCache.getUniqueNotifications({ tags, read: true });
|
|
627
568
|
const optimisticNotifications = notifications.map(
|
|
628
569
|
(notification) => new Notification(
|
|
629
|
-
__spreadProps(__spreadValues({}, notification), { isArchived: true, archivedAt: (/* @__PURE__ */ new Date()).toISOString() }),
|
|
570
|
+
chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notification), { isArchived: true, archivedAt: (/* @__PURE__ */ new Date()).toISOString() }),
|
|
630
571
|
emitter,
|
|
631
572
|
inboxService
|
|
632
573
|
)
|
|
@@ -645,29 +586,29 @@ var archiveAllRead = (_0) => __async(void 0, [_0], function* ({
|
|
|
645
586
|
var _cache;
|
|
646
587
|
var InMemoryCache = class {
|
|
647
588
|
constructor() {
|
|
648
|
-
__privateAdd(this, _cache);
|
|
649
|
-
__privateSet(this, _cache, /* @__PURE__ */ new Map());
|
|
589
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache);
|
|
590
|
+
chunk7B52C2XE_js.__privateSet(this, _cache, /* @__PURE__ */ new Map());
|
|
650
591
|
}
|
|
651
592
|
get(key) {
|
|
652
|
-
return __privateGet(this, _cache).get(key);
|
|
593
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache).get(key);
|
|
653
594
|
}
|
|
654
595
|
getValues() {
|
|
655
|
-
return Array.from(__privateGet(this, _cache).values());
|
|
596
|
+
return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).values());
|
|
656
597
|
}
|
|
657
598
|
entries() {
|
|
658
|
-
return Array.from(__privateGet(this, _cache).entries());
|
|
599
|
+
return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).entries());
|
|
659
600
|
}
|
|
660
601
|
keys() {
|
|
661
|
-
return Array.from(__privateGet(this, _cache).keys());
|
|
602
|
+
return Array.from(chunk7B52C2XE_js.__privateGet(this, _cache).keys());
|
|
662
603
|
}
|
|
663
604
|
set(key, value) {
|
|
664
|
-
__privateGet(this, _cache).set(key, value);
|
|
605
|
+
chunk7B52C2XE_js.__privateGet(this, _cache).set(key, value);
|
|
665
606
|
}
|
|
666
607
|
remove(key) {
|
|
667
|
-
__privateGet(this, _cache).delete(key);
|
|
608
|
+
chunk7B52C2XE_js.__privateGet(this, _cache).delete(key);
|
|
668
609
|
}
|
|
669
610
|
clear() {
|
|
670
|
-
__privateGet(this, _cache).clear();
|
|
611
|
+
chunk7B52C2XE_js.__privateGet(this, _cache).clear();
|
|
671
612
|
}
|
|
672
613
|
};
|
|
673
614
|
_cache = new WeakMap();
|
|
@@ -707,13 +648,13 @@ var removeEvents = [
|
|
|
707
648
|
var _emitter2, _cache2;
|
|
708
649
|
var NotificationsCache = class {
|
|
709
650
|
constructor({ emitter }) {
|
|
710
|
-
__privateAdd(this, _emitter2);
|
|
651
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter2);
|
|
711
652
|
/**
|
|
712
653
|
* The key is the stringified notifications filter, the values are the paginated notifications.
|
|
713
654
|
*/
|
|
714
|
-
__privateAdd(this, _cache2);
|
|
655
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache2);
|
|
715
656
|
this.updateNotification = (key, data) => {
|
|
716
|
-
const notificationsResponse = __privateGet(this, _cache2).get(key);
|
|
657
|
+
const notificationsResponse = chunk7B52C2XE_js.__privateGet(this, _cache2).get(key);
|
|
717
658
|
if (!notificationsResponse) {
|
|
718
659
|
return false;
|
|
719
660
|
}
|
|
@@ -723,11 +664,11 @@ var NotificationsCache = class {
|
|
|
723
664
|
}
|
|
724
665
|
const updatedNotifications = [...notificationsResponse.notifications];
|
|
725
666
|
updatedNotifications[index] = data;
|
|
726
|
-
__privateGet(this, _cache2).set(key, __spreadProps(__spreadValues({}, notificationsResponse), { notifications: updatedNotifications }));
|
|
667
|
+
chunk7B52C2XE_js.__privateGet(this, _cache2).set(key, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notificationsResponse), { notifications: updatedNotifications }));
|
|
727
668
|
return true;
|
|
728
669
|
};
|
|
729
670
|
this.removeNotification = (key, data) => {
|
|
730
|
-
const notificationsResponse = __privateGet(this, _cache2).get(key);
|
|
671
|
+
const notificationsResponse = chunk7B52C2XE_js.__privateGet(this, _cache2).get(key);
|
|
731
672
|
if (!notificationsResponse) {
|
|
732
673
|
return false;
|
|
733
674
|
}
|
|
@@ -737,7 +678,7 @@ var NotificationsCache = class {
|
|
|
737
678
|
}
|
|
738
679
|
const newNotifications = [...notificationsResponse.notifications];
|
|
739
680
|
newNotifications.splice(index, 1);
|
|
740
|
-
__privateGet(this, _cache2).set(key, __spreadProps(__spreadValues({}, notificationsResponse), {
|
|
681
|
+
chunk7B52C2XE_js.__privateGet(this, _cache2).set(key, chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notificationsResponse), {
|
|
741
682
|
notifications: newNotifications
|
|
742
683
|
}));
|
|
743
684
|
return true;
|
|
@@ -748,7 +689,7 @@ var NotificationsCache = class {
|
|
|
748
689
|
}
|
|
749
690
|
const notifications = Array.isArray(data) ? data : [data];
|
|
750
691
|
const uniqueFilterKeys = /* @__PURE__ */ new Set();
|
|
751
|
-
__privateGet(this, _cache2).keys().forEach((key) => {
|
|
692
|
+
chunk7B52C2XE_js.__privateGet(this, _cache2).keys().forEach((key) => {
|
|
752
693
|
notifications.forEach((notification) => {
|
|
753
694
|
let isNotificationFound = false;
|
|
754
695
|
if (remove) {
|
|
@@ -763,26 +704,26 @@ var NotificationsCache = class {
|
|
|
763
704
|
});
|
|
764
705
|
uniqueFilterKeys.forEach((key) => {
|
|
765
706
|
const notificationsResponse = this.getAggregated(getFilter(key));
|
|
766
|
-
__privateGet(this, _emitter2).emit("notifications.list.updated", {
|
|
707
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter2).emit("notifications.list.updated", {
|
|
767
708
|
data: notificationsResponse
|
|
768
709
|
});
|
|
769
710
|
});
|
|
770
711
|
};
|
|
771
|
-
__privateSet(this, _emitter2, emitter);
|
|
712
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter2, emitter);
|
|
772
713
|
updateEvents.forEach((event) => {
|
|
773
|
-
__privateGet(this, _emitter2).on(event, this.handleNotificationEvent());
|
|
714
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter2).on(event, this.handleNotificationEvent());
|
|
774
715
|
});
|
|
775
716
|
removeEvents.forEach((event) => {
|
|
776
|
-
__privateGet(this, _emitter2).on(event, this.handleNotificationEvent({ remove: true }));
|
|
717
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter2).on(event, this.handleNotificationEvent({ remove: true }));
|
|
777
718
|
});
|
|
778
|
-
__privateSet(this, _cache2, new InMemoryCache());
|
|
719
|
+
chunk7B52C2XE_js.__privateSet(this, _cache2, new InMemoryCache());
|
|
779
720
|
}
|
|
780
721
|
getAggregated(filter) {
|
|
781
|
-
const cacheKeys = __privateGet(this, _cache2).keys().filter((key) => {
|
|
722
|
+
const cacheKeys = chunk7B52C2XE_js.__privateGet(this, _cache2).keys().filter((key) => {
|
|
782
723
|
const parsedFilter = getFilter(key);
|
|
783
724
|
return isSameFilter(parsedFilter, filter);
|
|
784
725
|
});
|
|
785
|
-
return cacheKeys.map((key) => __privateGet(this, _cache2).get(key)).reduce(
|
|
726
|
+
return cacheKeys.map((key) => chunk7B52C2XE_js.__privateGet(this, _cache2).get(key)).reduce(
|
|
786
727
|
(acc, el) => {
|
|
787
728
|
if (!el) {
|
|
788
729
|
return acc;
|
|
@@ -797,15 +738,15 @@ var NotificationsCache = class {
|
|
|
797
738
|
);
|
|
798
739
|
}
|
|
799
740
|
has(args) {
|
|
800
|
-
return __privateGet(this, _cache2).get(getCacheKey(args)) !== void 0;
|
|
741
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache2).get(getCacheKey(args)) !== void 0;
|
|
801
742
|
}
|
|
802
743
|
set(args, data) {
|
|
803
|
-
__privateGet(this, _cache2).set(getCacheKey(args), data);
|
|
744
|
+
chunk7B52C2XE_js.__privateGet(this, _cache2).set(getCacheKey(args), data);
|
|
804
745
|
}
|
|
805
746
|
update(args, data) {
|
|
806
747
|
this.set(args, data);
|
|
807
748
|
const notificationsResponse = this.getAggregated(getFilter(getCacheKey(args)));
|
|
808
|
-
__privateGet(this, _emitter2).emit("notifications.list.updated", {
|
|
749
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter2).emit("notifications.list.updated", {
|
|
809
750
|
data: notificationsResponse
|
|
810
751
|
});
|
|
811
752
|
}
|
|
@@ -819,12 +760,12 @@ var NotificationsCache = class {
|
|
|
819
760
|
* The same tags can be applied to multiple filters which means that the same notification can be duplicated.
|
|
820
761
|
*/
|
|
821
762
|
getUniqueNotifications({ tags, read: read2 }) {
|
|
822
|
-
const keys = __privateGet(this, _cache2).keys();
|
|
763
|
+
const keys = chunk7B52C2XE_js.__privateGet(this, _cache2).keys();
|
|
823
764
|
const uniqueNotifications = /* @__PURE__ */ new Map();
|
|
824
765
|
keys.forEach((key) => {
|
|
825
766
|
const filter = getFilter(key);
|
|
826
767
|
if (areTagsEqual(tags, filter.tags)) {
|
|
827
|
-
const value = __privateGet(this, _cache2).get(key);
|
|
768
|
+
const value = chunk7B52C2XE_js.__privateGet(this, _cache2).get(key);
|
|
828
769
|
if (!value) {
|
|
829
770
|
return;
|
|
830
771
|
}
|
|
@@ -834,15 +775,15 @@ var NotificationsCache = class {
|
|
|
834
775
|
return Array.from(uniqueNotifications.values());
|
|
835
776
|
}
|
|
836
777
|
clear(filter) {
|
|
837
|
-
const keys = __privateGet(this, _cache2).keys();
|
|
778
|
+
const keys = chunk7B52C2XE_js.__privateGet(this, _cache2).keys();
|
|
838
779
|
keys.forEach((key) => {
|
|
839
780
|
if (isSameFilter(getFilter(key), filter)) {
|
|
840
|
-
__privateGet(this, _cache2).remove(key);
|
|
781
|
+
chunk7B52C2XE_js.__privateGet(this, _cache2).remove(key);
|
|
841
782
|
}
|
|
842
783
|
});
|
|
843
784
|
}
|
|
844
785
|
clearAll() {
|
|
845
|
-
__privateGet(this, _cache2).clear();
|
|
786
|
+
chunk7B52C2XE_js.__privateGet(this, _cache2).clear();
|
|
846
787
|
}
|
|
847
788
|
};
|
|
848
789
|
_emitter2 = new WeakMap();
|
|
@@ -860,22 +801,22 @@ var Notifications = class extends BaseModule {
|
|
|
860
801
|
eventEmitterInstance,
|
|
861
802
|
inboxServiceInstance
|
|
862
803
|
});
|
|
863
|
-
__privateAdd(this, _useCache);
|
|
804
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache);
|
|
864
805
|
this.cache = new NotificationsCache({
|
|
865
806
|
emitter: eventEmitterInstance
|
|
866
807
|
});
|
|
867
|
-
__privateSet(this, _useCache, useCache);
|
|
808
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache, useCache);
|
|
868
809
|
}
|
|
869
810
|
list() {
|
|
870
|
-
return __async(this, arguments, function* (_a = {}) {
|
|
871
|
-
var _b = _a, { limit = 10 } = _b, restOptions = __objRest(_b, ["limit"]);
|
|
872
|
-
return this.callWithSession(() => __async(this, null, function* () {
|
|
873
|
-
const args = __spreadValues({ limit }, restOptions);
|
|
811
|
+
return chunk7B52C2XE_js.__async(this, arguments, function* (_a = {}) {
|
|
812
|
+
var _b = _a, { limit = 10 } = _b, restOptions = chunk7B52C2XE_js.__objRest(_b, ["limit"]);
|
|
813
|
+
return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
814
|
+
const args = chunk7B52C2XE_js.__spreadValues({ limit }, restOptions);
|
|
874
815
|
try {
|
|
875
|
-
let data = __privateGet(this, _useCache) ? this.cache.getAll(args) : void 0;
|
|
816
|
+
let data = chunk7B52C2XE_js.__privateGet(this, _useCache) ? this.cache.getAll(args) : void 0;
|
|
876
817
|
this._emitter.emit("notifications.list.pending", { args, data });
|
|
877
818
|
if (!data) {
|
|
878
|
-
const response = yield this._inboxService.fetchNotifications(__spreadValues({
|
|
819
|
+
const response = yield this._inboxService.fetchNotifications(chunk7B52C2XE_js.__spreadValues({
|
|
879
820
|
limit
|
|
880
821
|
}, restOptions));
|
|
881
822
|
data = {
|
|
@@ -883,7 +824,7 @@ var Notifications = class extends BaseModule {
|
|
|
883
824
|
filter: response.filter,
|
|
884
825
|
notifications: response.data.map((el) => new Notification(el, this._emitter, this._inboxService))
|
|
885
826
|
};
|
|
886
|
-
if (__privateGet(this, _useCache)) {
|
|
827
|
+
if (chunk7B52C2XE_js.__privateGet(this, _useCache)) {
|
|
887
828
|
this.cache.set(args, data);
|
|
888
829
|
data = this.cache.getAll(args);
|
|
889
830
|
}
|
|
@@ -898,9 +839,9 @@ var Notifications = class extends BaseModule {
|
|
|
898
839
|
});
|
|
899
840
|
}
|
|
900
841
|
count(args) {
|
|
901
|
-
return __async(this, null, function* () {
|
|
902
|
-
return this.callWithSession(() => __async(this, null, function* () {
|
|
903
|
-
const filters = args && "filters" in args ? args.filters : [__spreadValues({}, args)];
|
|
842
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
843
|
+
return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
844
|
+
const filters = args && "filters" in args ? args.filters : [chunk7B52C2XE_js.__spreadValues({}, args)];
|
|
904
845
|
try {
|
|
905
846
|
this._emitter.emit("notifications.count.pending", { args });
|
|
906
847
|
const response = yield this._inboxService.count({
|
|
@@ -920,9 +861,9 @@ var Notifications = class extends BaseModule {
|
|
|
920
861
|
});
|
|
921
862
|
}
|
|
922
863
|
read(args) {
|
|
923
|
-
return __async(this, null, function* () {
|
|
864
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
924
865
|
return this.callWithSession(
|
|
925
|
-
() => __async(this, null, function* () {
|
|
866
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
926
867
|
return read({
|
|
927
868
|
emitter: this._emitter,
|
|
928
869
|
apiService: this._inboxService,
|
|
@@ -933,9 +874,9 @@ var Notifications = class extends BaseModule {
|
|
|
933
874
|
});
|
|
934
875
|
}
|
|
935
876
|
unread(args) {
|
|
936
|
-
return __async(this, null, function* () {
|
|
877
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
937
878
|
return this.callWithSession(
|
|
938
|
-
() => __async(this, null, function* () {
|
|
879
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
939
880
|
return unread({
|
|
940
881
|
emitter: this._emitter,
|
|
941
882
|
apiService: this._inboxService,
|
|
@@ -946,9 +887,9 @@ var Notifications = class extends BaseModule {
|
|
|
946
887
|
});
|
|
947
888
|
}
|
|
948
889
|
archive(args) {
|
|
949
|
-
return __async(this, null, function* () {
|
|
890
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
950
891
|
return this.callWithSession(
|
|
951
|
-
() => __async(this, null, function* () {
|
|
892
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
952
893
|
return archive({
|
|
953
894
|
emitter: this._emitter,
|
|
954
895
|
apiService: this._inboxService,
|
|
@@ -959,9 +900,9 @@ var Notifications = class extends BaseModule {
|
|
|
959
900
|
});
|
|
960
901
|
}
|
|
961
902
|
unarchive(args) {
|
|
962
|
-
return __async(this, null, function* () {
|
|
903
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
963
904
|
return this.callWithSession(
|
|
964
|
-
() => __async(this, null, function* () {
|
|
905
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
965
906
|
return unarchive({
|
|
966
907
|
emitter: this._emitter,
|
|
967
908
|
apiService: this._inboxService,
|
|
@@ -972,9 +913,9 @@ var Notifications = class extends BaseModule {
|
|
|
972
913
|
});
|
|
973
914
|
}
|
|
974
915
|
completePrimary(args) {
|
|
975
|
-
return __async(this, null, function* () {
|
|
916
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
976
917
|
return this.callWithSession(
|
|
977
|
-
() => __async(this, null, function* () {
|
|
918
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
978
919
|
return completeAction({
|
|
979
920
|
emitter: this._emitter,
|
|
980
921
|
apiService: this._inboxService,
|
|
@@ -986,9 +927,9 @@ var Notifications = class extends BaseModule {
|
|
|
986
927
|
});
|
|
987
928
|
}
|
|
988
929
|
completeSecondary(args) {
|
|
989
|
-
return __async(this, null, function* () {
|
|
930
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
990
931
|
return this.callWithSession(
|
|
991
|
-
() => __async(this, null, function* () {
|
|
932
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
992
933
|
return completeAction({
|
|
993
934
|
emitter: this._emitter,
|
|
994
935
|
apiService: this._inboxService,
|
|
@@ -1000,9 +941,9 @@ var Notifications = class extends BaseModule {
|
|
|
1000
941
|
});
|
|
1001
942
|
}
|
|
1002
943
|
revertPrimary(args) {
|
|
1003
|
-
return __async(this, null, function* () {
|
|
944
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1004
945
|
return this.callWithSession(
|
|
1005
|
-
() => __async(this, null, function* () {
|
|
946
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1006
947
|
return revertAction({
|
|
1007
948
|
emitter: this._emitter,
|
|
1008
949
|
apiService: this._inboxService,
|
|
@@ -1014,9 +955,9 @@ var Notifications = class extends BaseModule {
|
|
|
1014
955
|
});
|
|
1015
956
|
}
|
|
1016
957
|
revertSecondary(args) {
|
|
1017
|
-
return __async(this, null, function* () {
|
|
958
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1018
959
|
return this.callWithSession(
|
|
1019
|
-
() => __async(this, null, function* () {
|
|
960
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1020
961
|
return revertAction({
|
|
1021
962
|
emitter: this._emitter,
|
|
1022
963
|
apiService: this._inboxService,
|
|
@@ -1028,9 +969,9 @@ var Notifications = class extends BaseModule {
|
|
|
1028
969
|
});
|
|
1029
970
|
}
|
|
1030
971
|
readAll() {
|
|
1031
|
-
return __async(this, arguments, function* ({ tags } = {}) {
|
|
972
|
+
return chunk7B52C2XE_js.__async(this, arguments, function* ({ tags } = {}) {
|
|
1032
973
|
return this.callWithSession(
|
|
1033
|
-
() => __async(this, null, function* () {
|
|
974
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1034
975
|
return readAll({
|
|
1035
976
|
emitter: this._emitter,
|
|
1036
977
|
inboxService: this._inboxService,
|
|
@@ -1042,9 +983,9 @@ var Notifications = class extends BaseModule {
|
|
|
1042
983
|
});
|
|
1043
984
|
}
|
|
1044
985
|
archiveAll() {
|
|
1045
|
-
return __async(this, arguments, function* ({ tags } = {}) {
|
|
986
|
+
return chunk7B52C2XE_js.__async(this, arguments, function* ({ tags } = {}) {
|
|
1046
987
|
return this.callWithSession(
|
|
1047
|
-
() => __async(this, null, function* () {
|
|
988
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1048
989
|
return archiveAll({
|
|
1049
990
|
emitter: this._emitter,
|
|
1050
991
|
inboxService: this._inboxService,
|
|
@@ -1056,9 +997,9 @@ var Notifications = class extends BaseModule {
|
|
|
1056
997
|
});
|
|
1057
998
|
}
|
|
1058
999
|
archiveAllRead() {
|
|
1059
|
-
return __async(this, arguments, function* ({ tags } = {}) {
|
|
1000
|
+
return chunk7B52C2XE_js.__async(this, arguments, function* ({ tags } = {}) {
|
|
1060
1001
|
return this.callWithSession(
|
|
1061
|
-
() => __async(this, null, function* () {
|
|
1002
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1062
1003
|
return archiveAllRead({
|
|
1063
1004
|
emitter: this._emitter,
|
|
1064
1005
|
inboxService: this._inboxService,
|
|
@@ -1082,26 +1023,26 @@ _useCache = new WeakMap();
|
|
|
1082
1023
|
var _emitter3, _inboxService2, _options;
|
|
1083
1024
|
var Session = class {
|
|
1084
1025
|
constructor(options, inboxServiceInstance, eventEmitterInstance) {
|
|
1085
|
-
__privateAdd(this, _emitter3);
|
|
1086
|
-
__privateAdd(this, _inboxService2);
|
|
1087
|
-
__privateAdd(this, _options);
|
|
1088
|
-
__privateSet(this, _emitter3, eventEmitterInstance);
|
|
1089
|
-
__privateSet(this, _inboxService2, inboxServiceInstance);
|
|
1090
|
-
__privateSet(this, _options, options);
|
|
1026
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter3);
|
|
1027
|
+
chunk7B52C2XE_js.__privateAdd(this, _inboxService2);
|
|
1028
|
+
chunk7B52C2XE_js.__privateAdd(this, _options);
|
|
1029
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter3, eventEmitterInstance);
|
|
1030
|
+
chunk7B52C2XE_js.__privateSet(this, _inboxService2, inboxServiceInstance);
|
|
1031
|
+
chunk7B52C2XE_js.__privateSet(this, _options, options);
|
|
1091
1032
|
}
|
|
1092
1033
|
initialize() {
|
|
1093
|
-
return __async(this, null, function* () {
|
|
1034
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1094
1035
|
try {
|
|
1095
|
-
const { applicationIdentifier, subscriberId, subscriberHash } = __privateGet(this, _options);
|
|
1096
|
-
__privateGet(this, _emitter3).emit("session.initialize.pending", { args: __privateGet(this, _options) });
|
|
1097
|
-
const response = yield __privateGet(this, _inboxService2).initializeSession({
|
|
1036
|
+
const { applicationIdentifier, subscriberId, subscriberHash } = chunk7B52C2XE_js.__privateGet(this, _options);
|
|
1037
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("session.initialize.pending", { args: chunk7B52C2XE_js.__privateGet(this, _options) });
|
|
1038
|
+
const response = yield chunk7B52C2XE_js.__privateGet(this, _inboxService2).initializeSession({
|
|
1098
1039
|
applicationIdentifier,
|
|
1099
1040
|
subscriberId,
|
|
1100
1041
|
subscriberHash
|
|
1101
1042
|
});
|
|
1102
|
-
__privateGet(this, _emitter3).emit("session.initialize.resolved", { args: __privateGet(this, _options), data: response });
|
|
1043
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("session.initialize.resolved", { args: chunk7B52C2XE_js.__privateGet(this, _options), data: response });
|
|
1103
1044
|
} catch (error) {
|
|
1104
|
-
__privateGet(this, _emitter3).emit("session.initialize.resolved", { args: __privateGet(this, _options), error });
|
|
1045
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter3).emit("session.initialize.resolved", { args: chunk7B52C2XE_js.__privateGet(this, _options), error });
|
|
1105
1046
|
}
|
|
1106
1047
|
});
|
|
1107
1048
|
}
|
|
@@ -1114,10 +1055,10 @@ _options = new WeakMap();
|
|
|
1114
1055
|
var _emitter4, _apiService;
|
|
1115
1056
|
var Preference = class {
|
|
1116
1057
|
constructor(preference, { emitterInstance, inboxServiceInstance }) {
|
|
1117
|
-
__privateAdd(this, _emitter4);
|
|
1118
|
-
__privateAdd(this, _apiService);
|
|
1119
|
-
__privateSet(this, _emitter4, emitterInstance);
|
|
1120
|
-
__privateSet(this, _apiService, inboxServiceInstance);
|
|
1058
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter4);
|
|
1059
|
+
chunk7B52C2XE_js.__privateAdd(this, _apiService);
|
|
1060
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter4, emitterInstance);
|
|
1061
|
+
chunk7B52C2XE_js.__privateSet(this, _apiService, inboxServiceInstance);
|
|
1121
1062
|
this.level = preference.level;
|
|
1122
1063
|
this.enabled = preference.enabled;
|
|
1123
1064
|
this.channels = preference.channels;
|
|
@@ -1126,8 +1067,8 @@ var Preference = class {
|
|
|
1126
1067
|
update({ channelPreferences }) {
|
|
1127
1068
|
var _a;
|
|
1128
1069
|
return updatePreference({
|
|
1129
|
-
emitter: __privateGet(this, _emitter4),
|
|
1130
|
-
apiService: __privateGet(this, _apiService),
|
|
1070
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1071
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _apiService),
|
|
1131
1072
|
args: {
|
|
1132
1073
|
workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
|
|
1133
1074
|
channelPreferences,
|
|
@@ -1145,7 +1086,7 @@ _emitter4 = new WeakMap();
|
|
|
1145
1086
|
_apiService = new WeakMap();
|
|
1146
1087
|
|
|
1147
1088
|
// src/preferences/helpers.ts
|
|
1148
|
-
var updatePreference = (_0) => __async(void 0, [_0], function* ({
|
|
1089
|
+
var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
1149
1090
|
emitter,
|
|
1150
1091
|
apiService,
|
|
1151
1092
|
args
|
|
@@ -1155,8 +1096,8 @@ var updatePreference = (_0) => __async(void 0, [_0], function* ({
|
|
|
1155
1096
|
emitter.emit("preference.update.pending", {
|
|
1156
1097
|
args,
|
|
1157
1098
|
data: args.preference ? new Preference(
|
|
1158
|
-
__spreadProps(__spreadValues({}, args.preference), {
|
|
1159
|
-
channels: __spreadValues(__spreadValues({}, args.preference.channels), channelPreferences)
|
|
1099
|
+
chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, args.preference), {
|
|
1100
|
+
channels: chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, args.preference.channels), channelPreferences)
|
|
1160
1101
|
}),
|
|
1161
1102
|
{
|
|
1162
1103
|
emitterInstance: emitter,
|
|
@@ -1197,10 +1138,10 @@ var getCacheKey2 = ({ tags }) => {
|
|
|
1197
1138
|
var _emitter5, _cache3;
|
|
1198
1139
|
var PreferencesCache = class {
|
|
1199
1140
|
constructor({ emitterInstance }) {
|
|
1200
|
-
__privateAdd(this, _emitter5);
|
|
1201
|
-
__privateAdd(this, _cache3);
|
|
1141
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter5);
|
|
1142
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache3);
|
|
1202
1143
|
this.updatePreference = (key, data) => {
|
|
1203
|
-
const preferences = __privateGet(this, _cache3).get(key);
|
|
1144
|
+
const preferences = chunk7B52C2XE_js.__privateGet(this, _cache3).get(key);
|
|
1204
1145
|
if (!preferences) {
|
|
1205
1146
|
return false;
|
|
1206
1147
|
}
|
|
@@ -1215,43 +1156,43 @@ var PreferencesCache = class {
|
|
|
1215
1156
|
}
|
|
1216
1157
|
const updatedPreferences = [...preferences];
|
|
1217
1158
|
updatedPreferences[index] = data;
|
|
1218
|
-
__privateGet(this, _cache3).set(key, updatedPreferences);
|
|
1159
|
+
chunk7B52C2XE_js.__privateGet(this, _cache3).set(key, updatedPreferences);
|
|
1219
1160
|
return true;
|
|
1220
1161
|
};
|
|
1221
1162
|
this.handlePreferenceEvent = ({ data }) => {
|
|
1222
1163
|
if (!data) {
|
|
1223
1164
|
return;
|
|
1224
1165
|
}
|
|
1225
|
-
__privateGet(this, _cache3).keys().forEach((key) => {
|
|
1166
|
+
chunk7B52C2XE_js.__privateGet(this, _cache3).keys().forEach((key) => {
|
|
1226
1167
|
const hasUpdatedPreference = this.updatePreference(key, data);
|
|
1227
|
-
const updatedPreference = __privateGet(this, _cache3).get(key);
|
|
1168
|
+
const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache3).get(key);
|
|
1228
1169
|
if (!hasUpdatedPreference || !updatedPreference) {
|
|
1229
1170
|
return;
|
|
1230
1171
|
}
|
|
1231
|
-
__privateGet(this, _emitter5).emit("preferences.list.updated", {
|
|
1172
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter5).emit("preferences.list.updated", {
|
|
1232
1173
|
data: updatedPreference
|
|
1233
1174
|
});
|
|
1234
1175
|
});
|
|
1235
1176
|
};
|
|
1236
|
-
__privateSet(this, _emitter5, emitterInstance);
|
|
1177
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter5, emitterInstance);
|
|
1237
1178
|
updateEvents2.forEach((event) => {
|
|
1238
|
-
__privateGet(this, _emitter5).on(event, this.handlePreferenceEvent);
|
|
1179
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter5).on(event, this.handlePreferenceEvent);
|
|
1239
1180
|
});
|
|
1240
|
-
__privateSet(this, _cache3, new InMemoryCache());
|
|
1181
|
+
chunk7B52C2XE_js.__privateSet(this, _cache3, new InMemoryCache());
|
|
1241
1182
|
}
|
|
1242
1183
|
has(args) {
|
|
1243
|
-
return __privateGet(this, _cache3).get(getCacheKey2(args)) !== void 0;
|
|
1184
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache3).get(getCacheKey2(args)) !== void 0;
|
|
1244
1185
|
}
|
|
1245
1186
|
set(args, data) {
|
|
1246
|
-
__privateGet(this, _cache3).set(getCacheKey2(args), data);
|
|
1187
|
+
chunk7B52C2XE_js.__privateGet(this, _cache3).set(getCacheKey2(args), data);
|
|
1247
1188
|
}
|
|
1248
1189
|
getAll(args) {
|
|
1249
1190
|
if (this.has(args)) {
|
|
1250
|
-
return __privateGet(this, _cache3).get(getCacheKey2(args));
|
|
1191
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache3).get(getCacheKey2(args));
|
|
1251
1192
|
}
|
|
1252
1193
|
}
|
|
1253
1194
|
clearAll() {
|
|
1254
|
-
__privateGet(this, _cache3).clear();
|
|
1195
|
+
chunk7B52C2XE_js.__privateGet(this, _cache3).clear();
|
|
1255
1196
|
}
|
|
1256
1197
|
};
|
|
1257
1198
|
_emitter5 = new WeakMap();
|
|
@@ -1269,17 +1210,17 @@ var Preferences = class extends BaseModule {
|
|
|
1269
1210
|
eventEmitterInstance,
|
|
1270
1211
|
inboxServiceInstance
|
|
1271
1212
|
});
|
|
1272
|
-
__privateAdd(this, _useCache2);
|
|
1213
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache2);
|
|
1273
1214
|
this.cache = new PreferencesCache({
|
|
1274
1215
|
emitterInstance: this._emitter
|
|
1275
1216
|
});
|
|
1276
|
-
__privateSet(this, _useCache2, useCache);
|
|
1217
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache2, useCache);
|
|
1277
1218
|
}
|
|
1278
1219
|
list() {
|
|
1279
|
-
return __async(this, arguments, function* (args = {}) {
|
|
1280
|
-
return this.callWithSession(() => __async(this, null, function* () {
|
|
1220
|
+
return chunk7B52C2XE_js.__async(this, arguments, function* (args = {}) {
|
|
1221
|
+
return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1281
1222
|
try {
|
|
1282
|
-
let data = __privateGet(this, _useCache2) ? this.cache.getAll(args) : void 0;
|
|
1223
|
+
let data = chunk7B52C2XE_js.__privateGet(this, _useCache2) ? this.cache.getAll(args) : void 0;
|
|
1283
1224
|
this._emitter.emit("preferences.list.pending", { args, data });
|
|
1284
1225
|
if (!data) {
|
|
1285
1226
|
const response = yield this._inboxService.fetchPreferences(args.tags);
|
|
@@ -1289,7 +1230,7 @@ var Preferences = class extends BaseModule {
|
|
|
1289
1230
|
inboxServiceInstance: this._inboxService
|
|
1290
1231
|
})
|
|
1291
1232
|
);
|
|
1292
|
-
if (__privateGet(this, _useCache2)) {
|
|
1233
|
+
if (chunk7B52C2XE_js.__privateGet(this, _useCache2)) {
|
|
1293
1234
|
this.cache.set(args, data);
|
|
1294
1235
|
data = this.cache.getAll(args);
|
|
1295
1236
|
}
|
|
@@ -1304,9 +1245,9 @@ var Preferences = class extends BaseModule {
|
|
|
1304
1245
|
});
|
|
1305
1246
|
}
|
|
1306
1247
|
update(args) {
|
|
1307
|
-
return __async(this, null, function* () {
|
|
1248
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1308
1249
|
return this.callWithSession(
|
|
1309
|
-
() => __async(this, null, function* () {
|
|
1250
|
+
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1310
1251
|
return updatePreference({ emitter: this._emitter, apiService: this._inboxService, args });
|
|
1311
1252
|
})
|
|
1312
1253
|
);
|
|
@@ -1393,44 +1334,44 @@ var Socket = class extends BaseModule {
|
|
|
1393
1334
|
eventEmitterInstance,
|
|
1394
1335
|
inboxServiceInstance
|
|
1395
1336
|
});
|
|
1396
|
-
__privateAdd(this, _Socket_instances);
|
|
1397
|
-
__privateAdd(this, _token);
|
|
1398
|
-
__privateAdd(this, _emitter6);
|
|
1399
|
-
__privateAdd(this, _socketIo);
|
|
1400
|
-
__privateAdd(this, _socketUrl);
|
|
1401
|
-
__privateAdd(this, _notificationReceived, ({ message }) => {
|
|
1402
|
-
__privateGet(this, _emitter6).emit(NOTIFICATION_RECEIVED, {
|
|
1403
|
-
result: new Notification(mapToNotification(message), __privateGet(this, _emitter6), this._inboxService)
|
|
1337
|
+
chunk7B52C2XE_js.__privateAdd(this, _Socket_instances);
|
|
1338
|
+
chunk7B52C2XE_js.__privateAdd(this, _token);
|
|
1339
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter6);
|
|
1340
|
+
chunk7B52C2XE_js.__privateAdd(this, _socketIo);
|
|
1341
|
+
chunk7B52C2XE_js.__privateAdd(this, _socketUrl);
|
|
1342
|
+
chunk7B52C2XE_js.__privateAdd(this, _notificationReceived, ({ message }) => {
|
|
1343
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter6).emit(NOTIFICATION_RECEIVED, {
|
|
1344
|
+
result: new Notification(mapToNotification(message), chunk7B52C2XE_js.__privateGet(this, _emitter6), this._inboxService)
|
|
1404
1345
|
});
|
|
1405
1346
|
});
|
|
1406
|
-
__privateAdd(this, _unseenCountChanged, ({ unseenCount }) => {
|
|
1407
|
-
__privateGet(this, _emitter6).emit(UNSEEN_COUNT_CHANGED, {
|
|
1347
|
+
chunk7B52C2XE_js.__privateAdd(this, _unseenCountChanged, ({ unseenCount }) => {
|
|
1348
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter6).emit(UNSEEN_COUNT_CHANGED, {
|
|
1408
1349
|
result: unseenCount
|
|
1409
1350
|
});
|
|
1410
1351
|
});
|
|
1411
|
-
__privateAdd(this, _unreadCountChanged, ({ unreadCount }) => {
|
|
1412
|
-
__privateGet(this, _emitter6).emit(UNREAD_COUNT_CHANGED, {
|
|
1352
|
+
chunk7B52C2XE_js.__privateAdd(this, _unreadCountChanged, ({ unreadCount }) => {
|
|
1353
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter6).emit(UNREAD_COUNT_CHANGED, {
|
|
1413
1354
|
result: unreadCount
|
|
1414
1355
|
});
|
|
1415
1356
|
});
|
|
1416
|
-
__privateSet(this, _emitter6, eventEmitterInstance);
|
|
1417
|
-
__privateSet(this, _socketUrl, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL);
|
|
1357
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter6, eventEmitterInstance);
|
|
1358
|
+
chunk7B52C2XE_js.__privateSet(this, _socketUrl, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL);
|
|
1418
1359
|
}
|
|
1419
1360
|
onSessionSuccess({ token }) {
|
|
1420
|
-
__privateSet(this, _token, token);
|
|
1361
|
+
chunk7B52C2XE_js.__privateSet(this, _token, token);
|
|
1421
1362
|
}
|
|
1422
1363
|
isSocketEvent(eventName) {
|
|
1423
1364
|
return eventName === NOTIFICATION_RECEIVED || eventName === UNSEEN_COUNT_CHANGED || eventName === UNREAD_COUNT_CHANGED;
|
|
1424
1365
|
}
|
|
1425
1366
|
initialize() {
|
|
1426
|
-
if (__privateGet(this, _token)) {
|
|
1427
|
-
__privateMethod(this, _Socket_instances, initializeSocket_fn).call(this).catch((error) => {
|
|
1367
|
+
if (chunk7B52C2XE_js.__privateGet(this, _token)) {
|
|
1368
|
+
chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, initializeSocket_fn).call(this).catch((error) => {
|
|
1428
1369
|
console.error(error);
|
|
1429
1370
|
});
|
|
1430
1371
|
return;
|
|
1431
1372
|
}
|
|
1432
|
-
this.callWithSession(() => __async(this, null, function* () {
|
|
1433
|
-
__privateMethod(this, _Socket_instances, initializeSocket_fn).call(this).catch((error) => {
|
|
1373
|
+
this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1374
|
+
chunk7B52C2XE_js.__privateMethod(this, _Socket_instances, initializeSocket_fn).call(this).catch((error) => {
|
|
1434
1375
|
console.error(error);
|
|
1435
1376
|
});
|
|
1436
1377
|
return {};
|
|
@@ -1446,29 +1387,29 @@ _unseenCountChanged = new WeakMap();
|
|
|
1446
1387
|
_unreadCountChanged = new WeakMap();
|
|
1447
1388
|
_Socket_instances = new WeakSet();
|
|
1448
1389
|
initializeSocket_fn = function() {
|
|
1449
|
-
return __async(this, null, function* () {
|
|
1390
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1450
1391
|
var _a, _b, _c;
|
|
1451
|
-
if (!!__privateGet(this, _socketIo)) {
|
|
1392
|
+
if (!!chunk7B52C2XE_js.__privateGet(this, _socketIo)) {
|
|
1452
1393
|
return;
|
|
1453
1394
|
}
|
|
1454
|
-
const args = { socketUrl: __privateGet(this, _socketUrl) };
|
|
1455
|
-
__privateGet(this, _emitter6).emit("socket.connect.pending", { args });
|
|
1456
|
-
__privateSet(this, _socketIo, io__default.default(__privateGet(this, _socketUrl), {
|
|
1395
|
+
const args = { socketUrl: chunk7B52C2XE_js.__privateGet(this, _socketUrl) };
|
|
1396
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter6).emit("socket.connect.pending", { args });
|
|
1397
|
+
chunk7B52C2XE_js.__privateSet(this, _socketIo, io__default.default(chunk7B52C2XE_js.__privateGet(this, _socketUrl), {
|
|
1457
1398
|
reconnectionDelayMax: 1e4,
|
|
1458
1399
|
transports: ["websocket"],
|
|
1459
1400
|
query: {
|
|
1460
|
-
token: `${__privateGet(this, _token)}`
|
|
1401
|
+
token: `${chunk7B52C2XE_js.__privateGet(this, _token)}`
|
|
1461
1402
|
}
|
|
1462
1403
|
}));
|
|
1463
|
-
__privateGet(this, _socketIo).on("connect", () => {
|
|
1464
|
-
__privateGet(this, _emitter6).emit("socket.connect.resolved", { args });
|
|
1404
|
+
chunk7B52C2XE_js.__privateGet(this, _socketIo).on("connect", () => {
|
|
1405
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter6).emit("socket.connect.resolved", { args });
|
|
1465
1406
|
});
|
|
1466
|
-
__privateGet(this, _socketIo).on("connect_error", (error) => {
|
|
1467
|
-
__privateGet(this, _emitter6).emit("socket.connect.resolved", { args, error });
|
|
1407
|
+
chunk7B52C2XE_js.__privateGet(this, _socketIo).on("connect_error", (error) => {
|
|
1408
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter6).emit("socket.connect.resolved", { args, error });
|
|
1468
1409
|
});
|
|
1469
|
-
(_a = __privateGet(this, _socketIo)) == null ? void 0 : _a.on("notification_received" /* RECEIVED */, __privateGet(this, _notificationReceived));
|
|
1470
|
-
(_b = __privateGet(this, _socketIo)) == null ? void 0 : _b.on("unseen_count_changed" /* UNSEEN */, __privateGet(this, _unseenCountChanged));
|
|
1471
|
-
(_c = __privateGet(this, _socketIo)) == null ? void 0 : _c.on("unread_count_changed" /* UNREAD */, __privateGet(this, _unreadCountChanged));
|
|
1410
|
+
(_a = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _a.on("notification_received" /* RECEIVED */, chunk7B52C2XE_js.__privateGet(this, _notificationReceived));
|
|
1411
|
+
(_b = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _b.on("unseen_count_changed" /* UNSEEN */, chunk7B52C2XE_js.__privateGet(this, _unseenCountChanged));
|
|
1412
|
+
(_c = chunk7B52C2XE_js.__privateGet(this, _socketIo)) == null ? void 0 : _c.on("unread_count_changed" /* UNREAD */, chunk7B52C2XE_js.__privateGet(this, _unreadCountChanged));
|
|
1472
1413
|
});
|
|
1473
1414
|
};
|
|
1474
1415
|
|
|
@@ -1481,24 +1422,24 @@ var _httpClient;
|
|
|
1481
1422
|
var InboxService = class {
|
|
1482
1423
|
constructor(options = {}) {
|
|
1483
1424
|
this.isSessionInitialized = false;
|
|
1484
|
-
__privateAdd(this, _httpClient);
|
|
1485
|
-
__privateSet(this, _httpClient, new client.HttpClient(options));
|
|
1486
|
-
__privateGet(this, _httpClient).updateHeaders({
|
|
1425
|
+
chunk7B52C2XE_js.__privateAdd(this, _httpClient);
|
|
1426
|
+
chunk7B52C2XE_js.__privateSet(this, _httpClient, new client.HttpClient(options));
|
|
1427
|
+
chunk7B52C2XE_js.__privateGet(this, _httpClient).updateHeaders({
|
|
1487
1428
|
"Novu-API-Version": NOVU_API_VERSION
|
|
1488
1429
|
});
|
|
1489
1430
|
}
|
|
1490
1431
|
initializeSession(_0) {
|
|
1491
|
-
return __async(this, arguments, function* ({
|
|
1432
|
+
return chunk7B52C2XE_js.__async(this, arguments, function* ({
|
|
1492
1433
|
applicationIdentifier,
|
|
1493
1434
|
subscriberId,
|
|
1494
1435
|
subscriberHash
|
|
1495
1436
|
}) {
|
|
1496
|
-
const response = yield __privateGet(this, _httpClient).post(`${INBOX_ROUTE}/session`, {
|
|
1437
|
+
const response = yield chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_ROUTE}/session`, {
|
|
1497
1438
|
applicationIdentifier,
|
|
1498
1439
|
subscriberId,
|
|
1499
1440
|
subscriberHash
|
|
1500
1441
|
});
|
|
1501
|
-
__privateGet(this, _httpClient).setAuthorizationToken(response.token);
|
|
1442
|
+
chunk7B52C2XE_js.__privateGet(this, _httpClient).setAuthorizationToken(response.token);
|
|
1502
1443
|
this.isSessionInitialized = true;
|
|
1503
1444
|
return response;
|
|
1504
1445
|
});
|
|
@@ -1527,37 +1468,37 @@ var InboxService = class {
|
|
|
1527
1468
|
if (archived !== void 0) {
|
|
1528
1469
|
queryParams.append("archived", `${archived}`);
|
|
1529
1470
|
}
|
|
1530
|
-
return __privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}?${queryParams.toString()}`);
|
|
1471
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}?${queryParams.toString()}`);
|
|
1531
1472
|
}
|
|
1532
1473
|
count({ filters }) {
|
|
1533
|
-
return __privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}/count?filters=${JSON.stringify(filters)}`);
|
|
1474
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}/count?filters=${JSON.stringify(filters)}`);
|
|
1534
1475
|
}
|
|
1535
1476
|
read(notificationId) {
|
|
1536
|
-
return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/read`);
|
|
1477
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/read`);
|
|
1537
1478
|
}
|
|
1538
1479
|
unread(notificationId) {
|
|
1539
|
-
return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unread`);
|
|
1480
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unread`);
|
|
1540
1481
|
}
|
|
1541
1482
|
archive(notificationId) {
|
|
1542
|
-
return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/archive`);
|
|
1483
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/archive`);
|
|
1543
1484
|
}
|
|
1544
1485
|
unarchive(notificationId) {
|
|
1545
|
-
return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unarchive`);
|
|
1486
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unarchive`);
|
|
1546
1487
|
}
|
|
1547
1488
|
readAll({ tags }) {
|
|
1548
|
-
return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read`, { tags });
|
|
1489
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read`, { tags });
|
|
1549
1490
|
}
|
|
1550
1491
|
archiveAll({ tags }) {
|
|
1551
|
-
return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/archive`, { tags });
|
|
1492
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/archive`, { tags });
|
|
1552
1493
|
}
|
|
1553
1494
|
archiveAllRead({ tags }) {
|
|
1554
|
-
return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read-archive`, { tags });
|
|
1495
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read-archive`, { tags });
|
|
1555
1496
|
}
|
|
1556
1497
|
completeAction({
|
|
1557
1498
|
actionType,
|
|
1558
1499
|
notificationId
|
|
1559
1500
|
}) {
|
|
1560
|
-
return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/complete`, {
|
|
1501
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/complete`, {
|
|
1561
1502
|
actionType
|
|
1562
1503
|
});
|
|
1563
1504
|
}
|
|
@@ -1565,7 +1506,7 @@ var InboxService = class {
|
|
|
1565
1506
|
actionType,
|
|
1566
1507
|
notificationId
|
|
1567
1508
|
}) {
|
|
1568
|
-
return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/revert`, {
|
|
1509
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/revert`, {
|
|
1569
1510
|
actionType
|
|
1570
1511
|
});
|
|
1571
1512
|
}
|
|
@@ -1575,16 +1516,16 @@ var InboxService = class {
|
|
|
1575
1516
|
tags.forEach((tag) => queryParams.append("tags[]", tag));
|
|
1576
1517
|
}
|
|
1577
1518
|
const query = queryParams.size ? `?${queryParams.toString()}` : "";
|
|
1578
|
-
return __privateGet(this, _httpClient).get(`${INBOX_ROUTE}/preferences${query}`);
|
|
1519
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).get(`${INBOX_ROUTE}/preferences${query}`);
|
|
1579
1520
|
}
|
|
1580
1521
|
updateGlobalPreferences(channelPreferences) {
|
|
1581
|
-
return __privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences`, channelPreferences);
|
|
1522
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences`, channelPreferences);
|
|
1582
1523
|
}
|
|
1583
1524
|
updateWorkflowPreferences({
|
|
1584
1525
|
workflowId,
|
|
1585
1526
|
channelPreferences
|
|
1586
1527
|
}) {
|
|
1587
|
-
return __privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/${workflowId}`, channelPreferences);
|
|
1528
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/${workflowId}`, channelPreferences);
|
|
1588
1529
|
}
|
|
1589
1530
|
};
|
|
1590
1531
|
_httpClient = new WeakMap();
|
|
@@ -1593,46 +1534,46 @@ _httpClient = new WeakMap();
|
|
|
1593
1534
|
var _emitter7, _session, _socket, _inboxService3;
|
|
1594
1535
|
var Novu = class {
|
|
1595
1536
|
constructor(options) {
|
|
1596
|
-
__privateAdd(this, _emitter7);
|
|
1597
|
-
__privateAdd(this, _session);
|
|
1598
|
-
__privateAdd(this, _socket);
|
|
1599
|
-
__privateAdd(this, _inboxService3);
|
|
1537
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter7);
|
|
1538
|
+
chunk7B52C2XE_js.__privateAdd(this, _session);
|
|
1539
|
+
chunk7B52C2XE_js.__privateAdd(this, _socket);
|
|
1540
|
+
chunk7B52C2XE_js.__privateAdd(this, _inboxService3);
|
|
1600
1541
|
var _a, _b, _c;
|
|
1601
|
-
__privateSet(this, _inboxService3, new InboxService({ backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL }));
|
|
1602
|
-
__privateSet(this, _emitter7, new NovuEventEmitter());
|
|
1603
|
-
__privateSet(this, _session, new Session(
|
|
1542
|
+
chunk7B52C2XE_js.__privateSet(this, _inboxService3, new InboxService({ backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL }));
|
|
1543
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter7, new NovuEventEmitter());
|
|
1544
|
+
chunk7B52C2XE_js.__privateSet(this, _session, new Session(
|
|
1604
1545
|
{
|
|
1605
1546
|
applicationIdentifier: options.applicationIdentifier,
|
|
1606
1547
|
subscriberId: options.subscriberId,
|
|
1607
1548
|
subscriberHash: options.subscriberHash
|
|
1608
1549
|
},
|
|
1609
|
-
__privateGet(this, _inboxService3),
|
|
1610
|
-
__privateGet(this, _emitter7)
|
|
1550
|
+
chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
1551
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter7)
|
|
1611
1552
|
));
|
|
1612
|
-
__privateGet(this, _session).initialize();
|
|
1553
|
+
chunk7B52C2XE_js.__privateGet(this, _session).initialize();
|
|
1613
1554
|
this.notifications = new Notifications({
|
|
1614
1555
|
useCache: (_b = options.useCache) != null ? _b : true,
|
|
1615
|
-
inboxServiceInstance: __privateGet(this, _inboxService3),
|
|
1616
|
-
eventEmitterInstance: __privateGet(this, _emitter7)
|
|
1556
|
+
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
1557
|
+
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter7)
|
|
1617
1558
|
});
|
|
1618
1559
|
this.preferences = new Preferences({
|
|
1619
1560
|
useCache: (_c = options.useCache) != null ? _c : true,
|
|
1620
|
-
inboxServiceInstance: __privateGet(this, _inboxService3),
|
|
1621
|
-
eventEmitterInstance: __privateGet(this, _emitter7)
|
|
1561
|
+
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
1562
|
+
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter7)
|
|
1622
1563
|
});
|
|
1623
|
-
__privateSet(this, _socket, new Socket({
|
|
1564
|
+
chunk7B52C2XE_js.__privateSet(this, _socket, new Socket({
|
|
1624
1565
|
socketUrl: options.socketUrl,
|
|
1625
|
-
eventEmitterInstance: __privateGet(this, _emitter7),
|
|
1626
|
-
inboxServiceInstance: __privateGet(this, _inboxService3)
|
|
1566
|
+
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter7),
|
|
1567
|
+
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3)
|
|
1627
1568
|
}));
|
|
1628
1569
|
this.on = (eventName, listener) => {
|
|
1629
|
-
if (__privateGet(this, _socket).isSocketEvent(eventName)) {
|
|
1630
|
-
__privateGet(this, _socket).initialize();
|
|
1570
|
+
if (chunk7B52C2XE_js.__privateGet(this, _socket).isSocketEvent(eventName)) {
|
|
1571
|
+
chunk7B52C2XE_js.__privateGet(this, _socket).initialize();
|
|
1631
1572
|
}
|
|
1632
|
-
__privateGet(this, _emitter7).on(eventName, listener);
|
|
1573
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter7).on(eventName, listener);
|
|
1633
1574
|
};
|
|
1634
1575
|
this.off = (eventName, listener) => {
|
|
1635
|
-
__privateGet(this, _emitter7).off(eventName, listener);
|
|
1576
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter7).off(eventName, listener);
|
|
1636
1577
|
};
|
|
1637
1578
|
}
|
|
1638
1579
|
};
|
|
@@ -1652,13 +1593,5 @@ exports.PreferenceLevel = PreferenceLevel;
|
|
|
1652
1593
|
exports.PreferenceOverrideSource = PreferenceOverrideSource;
|
|
1653
1594
|
exports.PreferenceOverrideSourceEnum = PreferenceOverrideSourceEnum;
|
|
1654
1595
|
exports.WebSocketEvent = WebSocketEvent;
|
|
1655
|
-
exports.__async = __async;
|
|
1656
|
-
exports.__objRest = __objRest;
|
|
1657
|
-
exports.__privateAdd = __privateAdd;
|
|
1658
|
-
exports.__privateGet = __privateGet;
|
|
1659
|
-
exports.__privateMethod = __privateMethod;
|
|
1660
|
-
exports.__privateSet = __privateSet;
|
|
1661
|
-
exports.__spreadProps = __spreadProps;
|
|
1662
|
-
exports.__spreadValues = __spreadValues;
|
|
1663
1596
|
exports.areTagsEqual = areTagsEqual;
|
|
1664
1597
|
exports.isSameFilter = isSameFilter;
|