@suprsend/web-sdk 4.1.1 → 4.1.2
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/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.js +137 -134
- package/dist/es/index.js.map +1 -1
- package/dist/types/preferences.d.ts +6 -2
- package/package.json +1 -1
package/dist/es/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import K from "mitt";
|
|
|
5
5
|
import x from "jwt-decode";
|
|
6
6
|
import { createStore as B } from "zustand/vanilla";
|
|
7
7
|
import { io as Q } from "socket.io-client";
|
|
8
|
-
var p = /* @__PURE__ */ ((a) => (a.OPT_IN = "opt_in", a.OPT_OUT = "opt_out", a))(p || {}), C = /* @__PURE__ */ ((a) => (a.ALL = "all", a.REQUIRED = "required", a))(C || {}),
|
|
8
|
+
var p = /* @__PURE__ */ ((a) => (a.OPT_IN = "opt_in", a.OPT_OUT = "opt_out", a))(p || {}), C = /* @__PURE__ */ ((a) => (a.ALL = "all", a.REQUIRED = "required", a))(C || {}), c = /* @__PURE__ */ ((a) => (a.VALIDATION_ERROR = "VALIDATION_ERROR", a.NETWORK_ERROR = "NETWORK_ERROR", a.UNKNOWN_ERROR = "UNKNOWN_ERROR", a.PERMISSION_DENIED = "PERMISSION_DENIED", a.UNSUPPORTED_ACTION = "UNSUPPORTED_ACTION", a.NOT_FOUND = "NOT_FOUND", a))(c || {}), n = /* @__PURE__ */ ((a) => (a.SUCCESS = "success", a.ERROR = "error", a))(n || {}), _ = /* @__PURE__ */ ((a) => (a.INITIAL = "INITIAL", a.LOADING = "LOADING", a.SUCCESS = "SUCCESS", a.ERROR = "ERROR", a.FETCHING_MORE = "FETCHING_MORE", a))(_ || {});
|
|
9
9
|
function N() {
|
|
10
10
|
let a = (/* @__PURE__ */ new Date()).getTime();
|
|
11
11
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
|
|
@@ -72,7 +72,7 @@ function X(a) {
|
|
|
72
72
|
}
|
|
73
73
|
async function Y(a) {
|
|
74
74
|
const t = new TextEncoder().encode(a), s = await crypto.subtle.digest("SHA-256", t);
|
|
75
|
-
return Array.from(new Uint8Array(s)).map((
|
|
75
|
+
return Array.from(new Uint8Array(s)).map((d) => d.toString(16).padStart(2, "0")).join("");
|
|
76
76
|
}
|
|
77
77
|
class U {
|
|
78
78
|
constructor(e) {
|
|
@@ -126,12 +126,12 @@ class U {
|
|
|
126
126
|
if (!this.config.distinctId)
|
|
127
127
|
return o({
|
|
128
128
|
status: n.ERROR,
|
|
129
|
-
errorType:
|
|
129
|
+
errorType: c.VALIDATION_ERROR,
|
|
130
130
|
errorMessage: "User isn't authenticated. Call identify method before performing any action"
|
|
131
131
|
});
|
|
132
132
|
if ((t = this.config.authenticateOptions) != null && t.refreshUserToken && this.config.userToken) {
|
|
133
|
-
const i = x(this.config.userToken),
|
|
134
|
-
if (
|
|
133
|
+
const i = x(this.config.userToken), d = (i.exp || 0) * 1e3, u = Date.now();
|
|
134
|
+
if (d <= u)
|
|
135
135
|
try {
|
|
136
136
|
const h = await this.config.authenticateOptions.refreshUserToken(
|
|
137
137
|
this.config.userToken,
|
|
@@ -146,20 +146,20 @@ class U {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
try {
|
|
149
|
-
const i = await this.requestApiInstance(e),
|
|
149
|
+
const i = await this.requestApiInstance(e), d = await i.json(), u = (d == null ? void 0 : d.status) || (i.ok ? n.SUCCESS : n.ERROR);
|
|
150
150
|
return o({
|
|
151
151
|
status: u,
|
|
152
|
-
body:
|
|
152
|
+
body: d,
|
|
153
153
|
statusCode: i.status,
|
|
154
|
-
errorMessage: (s =
|
|
155
|
-
errorType: (r =
|
|
154
|
+
errorMessage: (s = d == null ? void 0 : d.error) == null ? void 0 : s.message,
|
|
155
|
+
errorType: (r = d == null ? void 0 : d.error) == null ? void 0 : r.type
|
|
156
156
|
});
|
|
157
157
|
} catch (i) {
|
|
158
158
|
return console.error(i), o({
|
|
159
159
|
status: n.ERROR,
|
|
160
160
|
statusCode: 500,
|
|
161
161
|
errorMessage: (i == null ? void 0 : i.message) || "network error",
|
|
162
|
-
errorType:
|
|
162
|
+
errorType: c.NETWORK_ERROR
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
}
|
|
@@ -238,7 +238,7 @@ class q {
|
|
|
238
238
|
if (!e)
|
|
239
239
|
return o({
|
|
240
240
|
status: n.ERROR,
|
|
241
|
-
errorType:
|
|
241
|
+
errorType: c.VALIDATION_ERROR,
|
|
242
242
|
errorMessage: "Category parameter is missing"
|
|
243
243
|
});
|
|
244
244
|
const s = {
|
|
@@ -251,83 +251,83 @@ class q {
|
|
|
251
251
|
/**
|
|
252
252
|
* Used to get user's all channel level preference.
|
|
253
253
|
*/
|
|
254
|
-
async getOverallChannelPreferences() {
|
|
255
|
-
const e = this.getUrl("channel_preference");
|
|
256
|
-
return await this.config.client().request({ type: "get", url:
|
|
254
|
+
async getOverallChannelPreferences(e) {
|
|
255
|
+
const t = { tenant_id: e == null ? void 0 : e.tenantId }, s = this.getUrl("channel_preference", t);
|
|
256
|
+
return await this.config.client().request({ type: "get", url: s });
|
|
257
257
|
}
|
|
258
258
|
async _updateCategoryPreferences(e, t, s, r) {
|
|
259
|
-
const i = this.getUrl(`category/${e}`, r),
|
|
259
|
+
const i = this.getUrl(`category/${e}`, r), d = await this.config.client().request({
|
|
260
260
|
type: "patch",
|
|
261
261
|
url: i,
|
|
262
262
|
payload: t
|
|
263
263
|
});
|
|
264
|
-
return
|
|
264
|
+
return d != null && d.error ? this.config.emitter.emit("preferences_error", d) : (Object.assign(s, d.body), this.config.emitter.emit("preferences_updated", {
|
|
265
265
|
status: n.SUCCESS,
|
|
266
266
|
statusCode: 200,
|
|
267
267
|
body: this.data
|
|
268
|
-
})),
|
|
268
|
+
})), d;
|
|
269
269
|
}
|
|
270
|
-
async _updateChannelPreferences(e) {
|
|
271
|
-
const
|
|
270
|
+
async _updateChannelPreferences(e, t) {
|
|
271
|
+
const s = this.getUrl("channel_preference", t), r = await this.config.client().request({
|
|
272
272
|
type: "patch",
|
|
273
|
-
url:
|
|
273
|
+
url: s,
|
|
274
274
|
payload: e
|
|
275
275
|
});
|
|
276
|
-
return
|
|
276
|
+
return r != null && r.error ? this.config.emitter.emit("preferences_error", r) : (await this.getPreferences(this.preferenceArgs), this.config.emitter.emit("preferences_updated", {
|
|
277
277
|
status: n.SUCCESS,
|
|
278
278
|
statusCode: 200,
|
|
279
279
|
body: this.data
|
|
280
|
-
})),
|
|
280
|
+
})), r;
|
|
281
281
|
}
|
|
282
282
|
/**
|
|
283
283
|
* Used to update user's category level preference.
|
|
284
284
|
*/
|
|
285
285
|
async updateCategoryPreference(e, t, s) {
|
|
286
|
-
var h, S, b, T,
|
|
286
|
+
var h, S, b, T, y;
|
|
287
287
|
if (!e || ![p.OPT_IN, p.OPT_OUT].includes(
|
|
288
288
|
t
|
|
289
289
|
))
|
|
290
290
|
return o({
|
|
291
291
|
status: n.ERROR,
|
|
292
|
-
errorType:
|
|
292
|
+
errorType: c.VALIDATION_ERROR,
|
|
293
293
|
errorMessage: e ? "Preference parameter is invalid" : "Category parameter is missing"
|
|
294
294
|
});
|
|
295
295
|
if (!this.data)
|
|
296
296
|
return o({
|
|
297
297
|
status: n.ERROR,
|
|
298
|
-
errorType:
|
|
298
|
+
errorType: c.VALIDATION_ERROR,
|
|
299
299
|
errorMessage: "Call getPreferences method before performing action"
|
|
300
300
|
});
|
|
301
301
|
if (!this.data.sections)
|
|
302
302
|
return o({
|
|
303
303
|
status: n.ERROR,
|
|
304
|
-
errorType:
|
|
304
|
+
errorType: c.VALIDATION_ERROR,
|
|
305
305
|
errorMessage: "Sections doesn't exist"
|
|
306
306
|
});
|
|
307
307
|
let r = null, i = !1;
|
|
308
308
|
for (const R of this.data.sections) {
|
|
309
|
-
let
|
|
309
|
+
let g = !1;
|
|
310
310
|
if (R.subcategories) {
|
|
311
311
|
for (const O of R.subcategories)
|
|
312
312
|
if (O.category === e)
|
|
313
313
|
if (r = O, O.is_editable) {
|
|
314
314
|
if (O.preference !== t) {
|
|
315
|
-
O.preference = t, i = !0,
|
|
315
|
+
O.preference = t, i = !0, g = !0;
|
|
316
316
|
break;
|
|
317
317
|
}
|
|
318
318
|
} else
|
|
319
319
|
return o({
|
|
320
320
|
status: n.ERROR,
|
|
321
|
-
errorType:
|
|
321
|
+
errorType: c.VALIDATION_ERROR,
|
|
322
322
|
errorMessage: "Category preference is not editable"
|
|
323
323
|
});
|
|
324
|
-
if (
|
|
324
|
+
if (g) break;
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
if (!r)
|
|
328
328
|
return o({
|
|
329
329
|
status: n.ERROR,
|
|
330
|
-
errorType:
|
|
330
|
+
errorType: c.VALIDATION_ERROR,
|
|
331
331
|
errorMessage: "Category not found"
|
|
332
332
|
});
|
|
333
333
|
if (!i)
|
|
@@ -335,15 +335,15 @@ class q {
|
|
|
335
335
|
status: n.SUCCESS,
|
|
336
336
|
body: this.data
|
|
337
337
|
});
|
|
338
|
-
const
|
|
338
|
+
const d = [];
|
|
339
339
|
(h = r == null ? void 0 : r.channels) == null || h.forEach((R) => {
|
|
340
|
-
R.preference === p.OPT_OUT &&
|
|
340
|
+
R.preference === p.OPT_OUT && d.push(R.channel);
|
|
341
341
|
});
|
|
342
342
|
let u = !0;
|
|
343
343
|
typeof (s == null ? void 0 : s.showOptOutChannels) == "boolean" ? u = s == null ? void 0 : s.showOptOutChannels : typeof ((S = this.preferenceArgs) == null ? void 0 : S.showOptOutChannels) == "boolean" && (u = this.preferenceArgs.showOptOutChannels);
|
|
344
344
|
const l = {
|
|
345
345
|
preference: r.preference,
|
|
346
|
-
opt_out_channels: u && t === p.OPT_IN ? null :
|
|
346
|
+
opt_out_channels: u && t === p.OPT_IN ? null : d
|
|
347
347
|
};
|
|
348
348
|
return this.debouncedUpdateCategoryPreferences(
|
|
349
349
|
e,
|
|
@@ -354,7 +354,7 @@ class q {
|
|
|
354
354
|
tenant_id: (s == null ? void 0 : s.tenantId) || ((b = this.preferenceArgs) == null ? void 0 : b.tenantId),
|
|
355
355
|
show_opt_out_channels: u,
|
|
356
356
|
tags: (s == null ? void 0 : s.tags) || ((T = this.preferenceArgs) == null ? void 0 : T.tags),
|
|
357
|
-
locale: (s == null ? void 0 : s.locale) || ((
|
|
357
|
+
locale: (s == null ? void 0 : s.locale) || ((y = this.preferenceArgs) == null ? void 0 : y.locale)
|
|
358
358
|
}
|
|
359
359
|
), o({
|
|
360
360
|
status: n.SUCCESS,
|
|
@@ -365,11 +365,11 @@ class q {
|
|
|
365
365
|
* Used to update user's category level channel preference.
|
|
366
366
|
*/
|
|
367
367
|
async updateChannelPreferenceInCategory(e, t, s, r) {
|
|
368
|
-
var T,
|
|
368
|
+
var T, y, R, g, O;
|
|
369
369
|
if (!e || !s)
|
|
370
370
|
return o({
|
|
371
371
|
status: n.ERROR,
|
|
372
|
-
errorType:
|
|
372
|
+
errorType: c.VALIDATION_ERROR,
|
|
373
373
|
errorMessage: e ? "Category parameter is missing" : "Channel parameter is missing"
|
|
374
374
|
});
|
|
375
375
|
if (![p.OPT_IN, p.OPT_OUT].includes(
|
|
@@ -377,22 +377,22 @@ class q {
|
|
|
377
377
|
))
|
|
378
378
|
return o({
|
|
379
379
|
status: n.ERROR,
|
|
380
|
-
errorType:
|
|
380
|
+
errorType: c.VALIDATION_ERROR,
|
|
381
381
|
errorMessage: "Preference parameter is invalid"
|
|
382
382
|
});
|
|
383
383
|
if (!this.data)
|
|
384
384
|
return o({
|
|
385
385
|
status: n.ERROR,
|
|
386
|
-
errorType:
|
|
386
|
+
errorType: c.VALIDATION_ERROR,
|
|
387
387
|
errorMessage: "Call getPreferences method before performing action"
|
|
388
388
|
});
|
|
389
389
|
if (!this.data.sections)
|
|
390
390
|
return o({
|
|
391
391
|
status: n.ERROR,
|
|
392
|
-
errorType:
|
|
392
|
+
errorType: c.VALIDATION_ERROR,
|
|
393
393
|
errorMessage: "Sections doesn't exist"
|
|
394
394
|
});
|
|
395
|
-
let i = null,
|
|
395
|
+
let i = null, d = null, u = !1;
|
|
396
396
|
for (const m of this.data.sections) {
|
|
397
397
|
let v = !1;
|
|
398
398
|
if (m.subcategories) {
|
|
@@ -401,7 +401,7 @@ class q {
|
|
|
401
401
|
if (i = E, !E.channels) continue;
|
|
402
402
|
for (const w of E.channels)
|
|
403
403
|
if (w.channel === e)
|
|
404
|
-
if (
|
|
404
|
+
if (d = w, w.is_editable) {
|
|
405
405
|
if (w.preference !== t) {
|
|
406
406
|
w.preference = t, t === p.OPT_IN && (E.preference = p.OPT_IN), u = !0, v = !0;
|
|
407
407
|
break;
|
|
@@ -409,7 +409,7 @@ class q {
|
|
|
409
409
|
} else
|
|
410
410
|
return o({
|
|
411
411
|
status: n.ERROR,
|
|
412
|
-
errorType:
|
|
412
|
+
errorType: c.VALIDATION_ERROR,
|
|
413
413
|
errorMessage: "Channel preference is not editable"
|
|
414
414
|
});
|
|
415
415
|
}
|
|
@@ -421,13 +421,13 @@ class q {
|
|
|
421
421
|
if (!i)
|
|
422
422
|
return o({
|
|
423
423
|
status: n.ERROR,
|
|
424
|
-
errorType:
|
|
424
|
+
errorType: c.VALIDATION_ERROR,
|
|
425
425
|
errorMessage: "Category not found"
|
|
426
426
|
});
|
|
427
|
-
if (!
|
|
427
|
+
if (!d)
|
|
428
428
|
return o({
|
|
429
429
|
status: n.ERROR,
|
|
430
|
-
errorType:
|
|
430
|
+
errorType: c.VALIDATION_ERROR,
|
|
431
431
|
errorMessage: "Category's channel not found"
|
|
432
432
|
});
|
|
433
433
|
if (!u)
|
|
@@ -440,7 +440,7 @@ class q {
|
|
|
440
440
|
m.preference === p.OPT_OUT && l.push(m.channel);
|
|
441
441
|
});
|
|
442
442
|
let h = !0;
|
|
443
|
-
typeof (r == null ? void 0 : r.showOptOutChannels) == "boolean" ? h = r == null ? void 0 : r.showOptOutChannels : typeof ((
|
|
443
|
+
typeof (r == null ? void 0 : r.showOptOutChannels) == "boolean" ? h = r == null ? void 0 : r.showOptOutChannels : typeof ((y = this.preferenceArgs) == null ? void 0 : y.showOptOutChannels) == "boolean" && (h = this.preferenceArgs.showOptOutChannels);
|
|
444
444
|
const b = {
|
|
445
445
|
preference: h && i.preference === p.OPT_OUT && t === p.OPT_IN ? p.OPT_IN : i.preference,
|
|
446
446
|
opt_out_channels: l
|
|
@@ -453,7 +453,7 @@ class q {
|
|
|
453
453
|
{
|
|
454
454
|
tenant_id: (r == null ? void 0 : r.tenantId) || ((R = this.preferenceArgs) == null ? void 0 : R.tenantId),
|
|
455
455
|
show_opt_out_channels: h,
|
|
456
|
-
tags: (r == null ? void 0 : r.tags) || ((
|
|
456
|
+
tags: (r == null ? void 0 : r.tags) || ((g = this.preferenceArgs) == null ? void 0 : g.tags),
|
|
457
457
|
locale: (r == null ? void 0 : r.locale) || ((O = this.preferenceArgs) == null ? void 0 : O.locale)
|
|
458
458
|
}
|
|
459
459
|
), o({
|
|
@@ -464,38 +464,41 @@ class q {
|
|
|
464
464
|
/**
|
|
465
465
|
* Used to update user's channel level preference.
|
|
466
466
|
*/
|
|
467
|
-
async updateOverallChannelPreference(e, t) {
|
|
467
|
+
async updateOverallChannelPreference(e, t, s) {
|
|
468
|
+
var u;
|
|
468
469
|
if (!e || ![
|
|
469
470
|
C.ALL,
|
|
470
471
|
C.REQUIRED
|
|
471
472
|
].includes(t))
|
|
472
473
|
return o({
|
|
473
474
|
status: n.ERROR,
|
|
474
|
-
errorType:
|
|
475
|
+
errorType: c.VALIDATION_ERROR,
|
|
475
476
|
errorMessage: e ? "Preference parameter is invalid" : "Channel parameter is missing"
|
|
476
477
|
});
|
|
477
478
|
if (!this.data)
|
|
478
479
|
return o({
|
|
479
480
|
status: n.ERROR,
|
|
480
|
-
errorType:
|
|
481
|
+
errorType: c.VALIDATION_ERROR,
|
|
481
482
|
errorMessage: "Call getPreferences method before performing action"
|
|
482
483
|
});
|
|
483
484
|
if (!this.data.channel_preferences)
|
|
484
485
|
return o({
|
|
485
486
|
status: n.ERROR,
|
|
486
|
-
errorType:
|
|
487
|
+
errorType: c.VALIDATION_ERROR,
|
|
487
488
|
errorMessage: "Channel preferences doesn't exist"
|
|
488
489
|
});
|
|
489
|
-
let
|
|
490
|
-
const
|
|
491
|
-
for (const
|
|
492
|
-
if (
|
|
493
|
-
|
|
490
|
+
let r = null, i = !1;
|
|
491
|
+
const d = t === C.REQUIRED;
|
|
492
|
+
for (const l of this.data.channel_preferences)
|
|
493
|
+
if (l.channel === e && (r = l, l.is_restricted !== d)) {
|
|
494
|
+
l.is_restricted = d, i = !0;
|
|
494
495
|
break;
|
|
495
496
|
}
|
|
496
|
-
return
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
return r ? i ? (this.debouncedUpdateChannelPreferences(
|
|
498
|
+
r.channel,
|
|
499
|
+
{ channel_preferences: [r] },
|
|
500
|
+
{ tenant_id: (s == null ? void 0 : s.tenantId) || ((u = this.preferenceArgs) == null ? void 0 : u.tenantId) }
|
|
501
|
+
), o({
|
|
499
502
|
status: n.SUCCESS,
|
|
500
503
|
body: this.data
|
|
501
504
|
})) : o({
|
|
@@ -503,7 +506,7 @@ class q {
|
|
|
503
506
|
body: this.data
|
|
504
507
|
}) : o({
|
|
505
508
|
status: n.ERROR,
|
|
506
|
-
errorType:
|
|
509
|
+
errorType: c.VALIDATION_ERROR,
|
|
507
510
|
errorMessage: "Channel data not found"
|
|
508
511
|
});
|
|
509
512
|
}
|
|
@@ -529,14 +532,14 @@ class ee {
|
|
|
529
532
|
}
|
|
530
533
|
validateObjData(e, t) {
|
|
531
534
|
const s = {}, r = (t == null ? void 0 : t.allowReservedKeys) || !1, i = (t == null ? void 0 : t.valueType) || "";
|
|
532
|
-
for (const
|
|
533
|
-
let u = e[
|
|
534
|
-
if (!(
|
|
535
|
-
if (!r && this.isReservedKey(
|
|
535
|
+
for (const d in e) {
|
|
536
|
+
let u = e[d];
|
|
537
|
+
if (!(d && u === void 0)) {
|
|
538
|
+
if (!r && this.isReservedKey(d)) {
|
|
536
539
|
console.warn("[SuprSend]: key cannot start with $ or ss_");
|
|
537
540
|
continue;
|
|
538
541
|
}
|
|
539
|
-
i === "number" ? u = Number(u) : i === "boolean" && (u = !!u), s[
|
|
542
|
+
i === "number" ? u = Number(u) : i === "boolean" && (u = !!u), s[d] = u;
|
|
540
543
|
}
|
|
541
544
|
}
|
|
542
545
|
return s;
|
|
@@ -569,13 +572,13 @@ class ee {
|
|
|
569
572
|
if (!s)
|
|
570
573
|
return o({
|
|
571
574
|
status: n.ERROR,
|
|
572
|
-
errorType:
|
|
575
|
+
errorType: c.VALIDATION_ERROR,
|
|
573
576
|
errorMessage: "data provided is empty"
|
|
574
577
|
});
|
|
575
578
|
const r = this.validateObjData(s);
|
|
576
579
|
return I(r) ? o({
|
|
577
580
|
status: n.ERROR,
|
|
578
|
-
errorType:
|
|
581
|
+
errorType: c.VALIDATION_ERROR,
|
|
579
582
|
errorMessage: "data provided is empty"
|
|
580
583
|
}) : this.triggerUserEvent({ $set: r });
|
|
581
584
|
}
|
|
@@ -588,13 +591,13 @@ class ee {
|
|
|
588
591
|
if (!s)
|
|
589
592
|
return o({
|
|
590
593
|
status: n.ERROR,
|
|
591
|
-
errorType:
|
|
594
|
+
errorType: c.VALIDATION_ERROR,
|
|
592
595
|
errorMessage: "data provided is empty"
|
|
593
596
|
});
|
|
594
597
|
const r = this.validateObjData(s);
|
|
595
598
|
return I(r) ? o({
|
|
596
599
|
status: n.ERROR,
|
|
597
|
-
errorType:
|
|
600
|
+
errorType: c.VALIDATION_ERROR,
|
|
598
601
|
errorMessage: "data provided is empty"
|
|
599
602
|
}) : this.triggerUserEvent({ $set_once: r });
|
|
600
603
|
}
|
|
@@ -607,13 +610,13 @@ class ee {
|
|
|
607
610
|
if (!s)
|
|
608
611
|
return o({
|
|
609
612
|
status: n.ERROR,
|
|
610
|
-
errorType:
|
|
613
|
+
errorType: c.VALIDATION_ERROR,
|
|
611
614
|
errorMessage: "data provided is empty"
|
|
612
615
|
});
|
|
613
616
|
const r = this.validateObjData(s, { valueType: "number" });
|
|
614
617
|
return I(r) ? o({
|
|
615
618
|
status: n.ERROR,
|
|
616
|
-
errorType:
|
|
619
|
+
errorType: c.VALIDATION_ERROR,
|
|
617
620
|
errorMessage: "data provided is empty"
|
|
618
621
|
}) : this.triggerUserEvent({ $add: r });
|
|
619
622
|
}
|
|
@@ -626,13 +629,13 @@ class ee {
|
|
|
626
629
|
if (!s)
|
|
627
630
|
return o({
|
|
628
631
|
status: n.ERROR,
|
|
629
|
-
errorType:
|
|
632
|
+
errorType: c.VALIDATION_ERROR,
|
|
630
633
|
errorMessage: "data provided is empty"
|
|
631
634
|
});
|
|
632
635
|
const r = this.validateObjData(s);
|
|
633
636
|
return I(r) ? o({
|
|
634
637
|
status: n.ERROR,
|
|
635
|
-
errorType:
|
|
638
|
+
errorType: c.VALIDATION_ERROR,
|
|
636
639
|
errorMessage: "data provided is empty"
|
|
637
640
|
}) : this.triggerUserEvent({ $append: r });
|
|
638
641
|
}
|
|
@@ -645,13 +648,13 @@ class ee {
|
|
|
645
648
|
if (!s)
|
|
646
649
|
return o({
|
|
647
650
|
status: n.ERROR,
|
|
648
|
-
errorType:
|
|
651
|
+
errorType: c.VALIDATION_ERROR,
|
|
649
652
|
errorMessage: "data provided is empty"
|
|
650
653
|
});
|
|
651
654
|
const r = this.validateObjData(s);
|
|
652
655
|
return I(r) ? o({
|
|
653
656
|
status: n.ERROR,
|
|
654
|
-
errorType:
|
|
657
|
+
errorType: c.VALIDATION_ERROR,
|
|
655
658
|
errorMessage: "data provided is empty"
|
|
656
659
|
}) : this.triggerUserEvent({ $remove: r });
|
|
657
660
|
}
|
|
@@ -663,13 +666,13 @@ class ee {
|
|
|
663
666
|
if (!t)
|
|
664
667
|
return o({
|
|
665
668
|
status: n.ERROR,
|
|
666
|
-
errorType:
|
|
669
|
+
errorType: c.VALIDATION_ERROR,
|
|
667
670
|
errorMessage: "data provided is empty"
|
|
668
671
|
});
|
|
669
672
|
const s = this.validateArrayData(t);
|
|
670
673
|
return G(s) ? o({
|
|
671
674
|
status: n.ERROR,
|
|
672
|
-
errorType:
|
|
675
|
+
errorType: c.VALIDATION_ERROR,
|
|
673
676
|
errorMessage: "data provided is empty"
|
|
674
677
|
}) : this.triggerUserEvent({ $unset: s });
|
|
675
678
|
}
|
|
@@ -679,7 +682,7 @@ class ee {
|
|
|
679
682
|
if (!s)
|
|
680
683
|
return o({
|
|
681
684
|
status: n.ERROR,
|
|
682
|
-
errorType:
|
|
685
|
+
errorType: c.VALIDATION_ERROR,
|
|
683
686
|
errorMessage: "data provided is empty"
|
|
684
687
|
});
|
|
685
688
|
const r = this.validateObjData(s, {
|
|
@@ -687,7 +690,7 @@ class ee {
|
|
|
687
690
|
});
|
|
688
691
|
return I(r) ? o({
|
|
689
692
|
status: n.ERROR,
|
|
690
|
-
errorType:
|
|
693
|
+
errorType: c.VALIDATION_ERROR,
|
|
691
694
|
errorMessage: "data provided is empty"
|
|
692
695
|
}) : this.triggerUserEvent({ $append: r });
|
|
693
696
|
}
|
|
@@ -697,7 +700,7 @@ class ee {
|
|
|
697
700
|
if (!s)
|
|
698
701
|
return o({
|
|
699
702
|
status: n.ERROR,
|
|
700
|
-
errorType:
|
|
703
|
+
errorType: c.VALIDATION_ERROR,
|
|
701
704
|
errorMessage: "data provided is empty"
|
|
702
705
|
});
|
|
703
706
|
const r = this.validateObjData(s, {
|
|
@@ -705,7 +708,7 @@ class ee {
|
|
|
705
708
|
});
|
|
706
709
|
return I(r) ? o({
|
|
707
710
|
status: n.ERROR,
|
|
708
|
-
errorType:
|
|
711
|
+
errorType: c.VALIDATION_ERROR,
|
|
709
712
|
errorMessage: "data provided is empty"
|
|
710
713
|
}) : this.triggerUserEvent({ $remove: r });
|
|
711
714
|
}
|
|
@@ -714,7 +717,7 @@ class ee {
|
|
|
714
717
|
if (!s)
|
|
715
718
|
return o({
|
|
716
719
|
status: n.ERROR,
|
|
717
|
-
errorType:
|
|
720
|
+
errorType: c.VALIDATION_ERROR,
|
|
718
721
|
errorMessage: "data provided is empty"
|
|
719
722
|
});
|
|
720
723
|
const r = this.validateObjData(s, {
|
|
@@ -722,7 +725,7 @@ class ee {
|
|
|
722
725
|
});
|
|
723
726
|
return I(r) ? o({
|
|
724
727
|
status: n.ERROR,
|
|
725
|
-
errorType:
|
|
728
|
+
errorType: c.VALIDATION_ERROR,
|
|
726
729
|
errorMessage: "data provided is empty"
|
|
727
730
|
}) : this.triggerUserEvent({ $set: r });
|
|
728
731
|
}
|
|
@@ -735,14 +738,14 @@ class ee {
|
|
|
735
738
|
async addEmail(e) {
|
|
736
739
|
return this.validateEmail(e) ? this.appendInternal({ $email: e }) : o({
|
|
737
740
|
status: n.ERROR,
|
|
738
|
-
errorType:
|
|
741
|
+
errorType: c.VALIDATION_ERROR,
|
|
739
742
|
errorMessage: "provided email is invalid"
|
|
740
743
|
});
|
|
741
744
|
}
|
|
742
745
|
async removeEmail(e) {
|
|
743
746
|
return this.validateEmail(e) ? this.removeInternal({ $email: e }) : o({
|
|
744
747
|
status: n.ERROR,
|
|
745
|
-
errorType:
|
|
748
|
+
errorType: c.VALIDATION_ERROR,
|
|
746
749
|
errorMessage: "provided email is invalid"
|
|
747
750
|
});
|
|
748
751
|
}
|
|
@@ -752,7 +755,7 @@ class ee {
|
|
|
752
755
|
async addSms(e) {
|
|
753
756
|
return this.validateMobile(e) ? this.appendInternal({ $sms: e }) : o({
|
|
754
757
|
status: n.ERROR,
|
|
755
|
-
errorType:
|
|
758
|
+
errorType: c.VALIDATION_ERROR,
|
|
756
759
|
errorMessage: "provided mobile number is invalid, must be as per E.164 standard"
|
|
757
760
|
});
|
|
758
761
|
}
|
|
@@ -762,7 +765,7 @@ class ee {
|
|
|
762
765
|
async removeSms(e) {
|
|
763
766
|
return this.validateMobile(e) ? this.removeInternal({ $sms: e }) : o({
|
|
764
767
|
status: n.ERROR,
|
|
765
|
-
errorType:
|
|
768
|
+
errorType: c.VALIDATION_ERROR,
|
|
766
769
|
errorMessage: "provided mobile number is invalid, must be as per E.164 standard"
|
|
767
770
|
});
|
|
768
771
|
}
|
|
@@ -772,7 +775,7 @@ class ee {
|
|
|
772
775
|
async addWhatsapp(e) {
|
|
773
776
|
return this.validateMobile(e) ? this.appendInternal({ $whatsapp: e }) : o({
|
|
774
777
|
status: n.ERROR,
|
|
775
|
-
errorType:
|
|
778
|
+
errorType: c.VALIDATION_ERROR,
|
|
776
779
|
errorMessage: "provided mobile number is invalid, must be as per E.164 standard"
|
|
777
780
|
});
|
|
778
781
|
}
|
|
@@ -782,7 +785,7 @@ class ee {
|
|
|
782
785
|
async removeWhatsapp(e) {
|
|
783
786
|
return this.validateMobile(e) ? this.removeInternal({ $whatsapp: e }) : o({
|
|
784
787
|
status: n.ERROR,
|
|
785
|
-
errorType:
|
|
788
|
+
errorType: c.VALIDATION_ERROR,
|
|
786
789
|
errorMessage: "provided mobile number is invalid, must be as per E.164 standard"
|
|
787
790
|
});
|
|
788
791
|
}
|
|
@@ -794,7 +797,7 @@ class ee {
|
|
|
794
797
|
if (typeof e != "object")
|
|
795
798
|
return o({
|
|
796
799
|
status: n.ERROR,
|
|
797
|
-
errorType:
|
|
800
|
+
errorType: c.VALIDATION_ERROR,
|
|
798
801
|
errorMessage: "provided push subscription is invalid, must be an object"
|
|
799
802
|
});
|
|
800
803
|
const t = this.getDeviceId();
|
|
@@ -808,7 +811,7 @@ class ee {
|
|
|
808
811
|
if (typeof e != "object")
|
|
809
812
|
return o({
|
|
810
813
|
status: n.ERROR,
|
|
811
|
-
errorType:
|
|
814
|
+
errorType: c.VALIDATION_ERROR,
|
|
812
815
|
errorMessage: "provided push subscription is invalid, must be an object"
|
|
813
816
|
});
|
|
814
817
|
const t = this.getDeviceId();
|
|
@@ -821,28 +824,28 @@ class ee {
|
|
|
821
824
|
async addSlack(e) {
|
|
822
825
|
return typeof e != "object" ? o({
|
|
823
826
|
status: n.ERROR,
|
|
824
|
-
errorType:
|
|
827
|
+
errorType: c.VALIDATION_ERROR,
|
|
825
828
|
errorMessage: "provided slack data is invalid, must be an object"
|
|
826
829
|
}) : this.appendInternal({ $slack: e });
|
|
827
830
|
}
|
|
828
831
|
async removeSlack(e) {
|
|
829
832
|
return typeof e != "object" ? o({
|
|
830
833
|
status: n.ERROR,
|
|
831
|
-
errorType:
|
|
834
|
+
errorType: c.VALIDATION_ERROR,
|
|
832
835
|
errorMessage: "provided slack data is invalid, must be an object"
|
|
833
836
|
}) : this.removeInternal({ $slack: e });
|
|
834
837
|
}
|
|
835
838
|
async addMSTeams(e) {
|
|
836
839
|
return typeof e != "object" ? o({
|
|
837
840
|
status: n.ERROR,
|
|
838
|
-
errorType:
|
|
841
|
+
errorType: c.VALIDATION_ERROR,
|
|
839
842
|
errorMessage: "provided ms_teams data is invalid, must be object"
|
|
840
843
|
}) : this.appendInternal({ $ms_teams: e });
|
|
841
844
|
}
|
|
842
845
|
async removeMSTeams(e) {
|
|
843
846
|
return typeof e != "object" ? o({
|
|
844
847
|
status: n.ERROR,
|
|
845
|
-
errorType:
|
|
848
|
+
errorType: c.VALIDATION_ERROR,
|
|
846
849
|
errorMessage: "provided ms_teams data is invalid, must be object"
|
|
847
850
|
}) : this.removeInternal({ $ms_teams: e });
|
|
848
851
|
}
|
|
@@ -853,7 +856,7 @@ class ee {
|
|
|
853
856
|
async setPreferredLanguage(e) {
|
|
854
857
|
return typeof e != "string" ? o({
|
|
855
858
|
status: n.ERROR,
|
|
856
|
-
errorType:
|
|
859
|
+
errorType: c.VALIDATION_ERROR,
|
|
857
860
|
errorMessage: "provided language is invalid, must be string"
|
|
858
861
|
}) : this.setInternal({ $preferred_language: e });
|
|
859
862
|
}
|
|
@@ -863,7 +866,7 @@ class ee {
|
|
|
863
866
|
async setTimezone(e) {
|
|
864
867
|
return typeof e != "string" ? o({
|
|
865
868
|
status: n.ERROR,
|
|
866
|
-
errorType:
|
|
869
|
+
errorType: c.VALIDATION_ERROR,
|
|
867
870
|
errorMessage: "provided timezone is invalid, must be string"
|
|
868
871
|
}) : this.setInternal({ $timezone: e });
|
|
869
872
|
}
|
|
@@ -901,7 +904,7 @@ class te {
|
|
|
901
904
|
if (await navigator.serviceWorker.register(`/${this.config.swFileName}`), await Notification.requestPermission() !== "granted")
|
|
902
905
|
return console.warn("[SuprSend]: Notification permission isnt granted"), o({
|
|
903
906
|
status: n.ERROR,
|
|
904
|
-
errorType:
|
|
907
|
+
errorType: c.PERMISSION_DENIED,
|
|
905
908
|
errorMessage: "Notification permission isn't granted"
|
|
906
909
|
});
|
|
907
910
|
const t = await navigator.serviceWorker.ready, s = await t.pushManager.getSubscription();
|
|
@@ -912,7 +915,7 @@ class te {
|
|
|
912
915
|
"[SuprSend]: Vapid key is missing. Add it while creating SuprSend instance"
|
|
913
916
|
), o({
|
|
914
917
|
status: n.ERROR,
|
|
915
|
-
errorType:
|
|
918
|
+
errorType: c.VALIDATION_ERROR,
|
|
916
919
|
errorMessage: "Vapid key is missing. Add it while creating SuprSend instance"
|
|
917
920
|
});
|
|
918
921
|
const r = await t.pushManager.subscribe({
|
|
@@ -923,7 +926,7 @@ class te {
|
|
|
923
926
|
} catch (e) {
|
|
924
927
|
return console.warn("SuprSend: Error getting push subscription", e), o({
|
|
925
928
|
status: n.ERROR,
|
|
926
|
-
errorType:
|
|
929
|
+
errorType: c.UNKNOWN_ERROR,
|
|
927
930
|
errorMessage: (e == null ? void 0 : e.message) || "Unknown error occured while registering for push"
|
|
928
931
|
});
|
|
929
932
|
}
|
|
@@ -937,7 +940,7 @@ class te {
|
|
|
937
940
|
async registerPush() {
|
|
938
941
|
return A() && "serviceWorker" in navigator && "PushManager" in window ? this.handleRegisterPush() : (console.warn("[SuprSend]: Webpush isn't supported"), o({
|
|
939
942
|
status: n.ERROR,
|
|
940
|
-
errorType:
|
|
943
|
+
errorType: c.UNSUPPORTED_ACTION,
|
|
941
944
|
errorMessage: "Webpush isn't supported"
|
|
942
945
|
}));
|
|
943
946
|
}
|
|
@@ -1038,12 +1041,12 @@ class ae {
|
|
|
1038
1041
|
return;
|
|
1039
1042
|
}
|
|
1040
1043
|
const r = s == null ? void 0 : s.query;
|
|
1041
|
-
let i,
|
|
1042
|
-
typeof (r == null ? void 0 : r.read) == "boolean" && (i = r.read), typeof (r == null ? void 0 : r.archived) == "boolean" && (
|
|
1044
|
+
let i, d, u = [], l = [];
|
|
1045
|
+
typeof (r == null ? void 0 : r.read) == "boolean" && (i = r.read), typeof (r == null ? void 0 : r.archived) == "boolean" && (d = r.archived), typeof (r == null ? void 0 : r.tags) == "string" ? u = [r.tags] : Array.isArray(r == null ? void 0 : r.tags) && (u = r == null ? void 0 : r.tags.filter((h) => typeof h == "string")), typeof (r == null ? void 0 : r.categories) == "string" ? l = [r.categories] : Array.isArray(r == null ? void 0 : r.categories) && (l = r == null ? void 0 : r.categories.filter((h) => typeof h == "string")), t.push({
|
|
1043
1046
|
storeId: s.storeId,
|
|
1044
1047
|
label: s.label || s.storeId,
|
|
1045
1048
|
query: {
|
|
1046
|
-
archived:
|
|
1049
|
+
archived: d,
|
|
1047
1050
|
read: i,
|
|
1048
1051
|
tags: u,
|
|
1049
1052
|
categories: l
|
|
@@ -1064,8 +1067,8 @@ class ae {
|
|
|
1064
1067
|
this.socket.on("connect_error", async (e) => {
|
|
1065
1068
|
var t;
|
|
1066
1069
|
if (e.message === "Authentication Error: wrong auth token" && ((t = this.config.authenticateOptions) != null && t.refreshUserToken) && this.config.userToken) {
|
|
1067
|
-
const s = this.socket.auth["x-ss-signature"], r = x(s), i = (r.exp || 0) * 1e3,
|
|
1068
|
-
if (i <=
|
|
1070
|
+
const s = this.socket.auth["x-ss-signature"], r = x(s), i = (r.exp || 0) * 1e3, d = Date.now();
|
|
1071
|
+
if (i <= d)
|
|
1069
1072
|
try {
|
|
1070
1073
|
const l = await this.config.authenticateOptions.refreshUserToken(
|
|
1071
1074
|
this.config.userToken,
|
|
@@ -1105,18 +1108,18 @@ class ae {
|
|
|
1105
1108
|
return;
|
|
1106
1109
|
const s = t.body, r = this.store.getState();
|
|
1107
1110
|
let i = !1;
|
|
1108
|
-
const
|
|
1111
|
+
const d = { ...r.meta };
|
|
1109
1112
|
this.notificationBelongToStore(s, r.store) && (i = !0, this.store.setState({
|
|
1110
1113
|
notifications: this.orderNotificationsBasedOnPinFlag(
|
|
1111
1114
|
s,
|
|
1112
1115
|
r.notifications
|
|
1113
1116
|
)
|
|
1114
1117
|
})), (l = (u = this.feedOptions.stores) == null ? void 0 : u.map) == null || l.call(u, (h) => {
|
|
1115
|
-
this.notificationBelongToStore(s, h) && (i = !0,
|
|
1118
|
+
this.notificationBelongToStore(s, h) && (i = !0, d[h.storeId] = (r.meta[h.storeId] || 0) + 1);
|
|
1116
1119
|
}), this.store.setState({
|
|
1117
1120
|
meta: {
|
|
1118
|
-
...
|
|
1119
|
-
badge: i ?
|
|
1121
|
+
...d,
|
|
1122
|
+
badge: i ? d.badge + 1 : d.badge
|
|
1120
1123
|
}
|
|
1121
1124
|
}), i && this.emitter.emit("feed.new_notification", s), this.emitter.emit("feed.store_update", this.data);
|
|
1122
1125
|
}
|
|
@@ -1130,13 +1133,13 @@ class ae {
|
|
|
1130
1133
|
if (t[0].status !== "fulfilled") return;
|
|
1131
1134
|
const r = t[0].value;
|
|
1132
1135
|
if (r.status === n.ERROR) return;
|
|
1133
|
-
const i = r.body,
|
|
1136
|
+
const i = r.body, d = (l = s.notifications) == null ? void 0 : l.some(
|
|
1134
1137
|
(h) => h.n_id === i.n_id
|
|
1135
1138
|
);
|
|
1136
1139
|
this.notificationBelongToStore(
|
|
1137
1140
|
i,
|
|
1138
1141
|
s.store
|
|
1139
|
-
) ?
|
|
1142
|
+
) ? d ? this.store.setState({
|
|
1140
1143
|
notifications: s.notifications.map((h) => h.n_id === i.n_id ? i : h)
|
|
1141
1144
|
}) : this.store.setState({
|
|
1142
1145
|
notifications: this.orderNotificationsBasedOnPinFlag(
|
|
@@ -1164,12 +1167,12 @@ class ae {
|
|
|
1164
1167
|
}), this.emitter.emit("feed.store_update", this.data);
|
|
1165
1168
|
}
|
|
1166
1169
|
notificationBelongToStore(e, t) {
|
|
1167
|
-
var
|
|
1168
|
-
const s = !!e.read_on, r = e.archived, i = e.tags,
|
|
1169
|
-
let
|
|
1170
|
+
var g, O, m, v;
|
|
1171
|
+
const s = !!e.read_on, r = e.archived, i = e.tags, d = e.n_category, u = (g = t == null ? void 0 : t.query) == null ? void 0 : g.read, l = (O = t == null ? void 0 : t.query) == null ? void 0 : O.archived, h = (m = t == null ? void 0 : t.query) == null ? void 0 : m.tags, S = (v = t == null ? void 0 : t.query) == null ? void 0 : v.categories, b = u == null || s === u, T = !!r == !!l;
|
|
1172
|
+
let y = !1, R = !1;
|
|
1170
1173
|
return Array.isArray(h) && h.length > 0 ? h.forEach((E) => {
|
|
1171
|
-
i != null && i.includes(E) && (
|
|
1172
|
-
}) :
|
|
1174
|
+
i != null && i.includes(E) && (y = !0);
|
|
1175
|
+
}) : y = !0, Array.isArray(S) && S.length > 0 ? S.includes(d) && (R = !0) : R = !0, b && y && R && T;
|
|
1173
1176
|
}
|
|
1174
1177
|
orderNotificationsBasedOnPinFlag(e, t) {
|
|
1175
1178
|
if (e.is_pinned)
|
|
@@ -1194,8 +1197,8 @@ class ae {
|
|
|
1194
1197
|
t && (this.store.setState({ notifications: s }), await this.fetchCount(), this.emitter.emit("feed.store_update", this.data));
|
|
1195
1198
|
}
|
|
1196
1199
|
getUrl(e, t) {
|
|
1197
|
-
var
|
|
1198
|
-
const s = `${(
|
|
1200
|
+
var d;
|
|
1201
|
+
const s = `${(d = this.feedOptions.host) == null ? void 0 : d.apiHost}/v1/feed/${e}`, r = this.validateQueryParams(t), i = new URLSearchParams(
|
|
1199
1202
|
r
|
|
1200
1203
|
).toString();
|
|
1201
1204
|
return i ? `${s}?${i}` : s;
|
|
@@ -1219,12 +1222,12 @@ class ae {
|
|
|
1219
1222
|
return e == null ? void 0 : e.map((s) => this.storeQueryParamObj(s));
|
|
1220
1223
|
}
|
|
1221
1224
|
storeQueryParamObj(e) {
|
|
1222
|
-
const t = e == null ? void 0 : e.query, s = (t == null ? void 0 : t.tags) || [], r = (t == null ? void 0 : t.categories) || [], i = t == null ? void 0 : t.read,
|
|
1225
|
+
const t = e == null ? void 0 : e.query, s = (t == null ? void 0 : t.tags) || [], r = (t == null ? void 0 : t.categories) || [], i = t == null ? void 0 : t.read, d = t == null ? void 0 : t.archived;
|
|
1223
1226
|
return {
|
|
1224
1227
|
store_id: e.storeId,
|
|
1225
1228
|
query: {
|
|
1226
1229
|
read: i,
|
|
1227
|
-
archived:
|
|
1230
|
+
archived: d,
|
|
1228
1231
|
tags: { or: s },
|
|
1229
1232
|
categories: { or: r }
|
|
1230
1233
|
}
|
|
@@ -1244,7 +1247,7 @@ class ae {
|
|
|
1244
1247
|
}), await this.fetch()) : {
|
|
1245
1248
|
status: n.ERROR,
|
|
1246
1249
|
error: {
|
|
1247
|
-
type:
|
|
1250
|
+
type: c.NOT_FOUND,
|
|
1248
1251
|
message: `store with storeId ${e} doesnt exist`
|
|
1249
1252
|
}
|
|
1250
1253
|
};
|
|
@@ -1298,10 +1301,10 @@ class ae {
|
|
|
1298
1301
|
];
|
|
1299
1302
|
} else
|
|
1300
1303
|
r.search_after = [];
|
|
1301
|
-
const i = this.getUrl("notifications", r),
|
|
1302
|
-
this.fetchAbortController =
|
|
1303
|
-
const u = await this.config.client().request({ type: "get", url: i, signal:
|
|
1304
|
-
if (!
|
|
1304
|
+
const i = this.getUrl("notifications", r), d = new AbortController();
|
|
1305
|
+
this.fetchAbortController = d;
|
|
1306
|
+
const u = await this.config.client().request({ type: "get", url: i, signal: d.signal });
|
|
1307
|
+
if (!d.signal.aborted)
|
|
1305
1308
|
return u.status === n.ERROR ? (this.store.setState({ apiStatus: _.ERROR }), this.emitter.emit("feed.store_update", this.data), u) : (this.store.setState({
|
|
1306
1309
|
apiStatus: _.SUCCESS,
|
|
1307
1310
|
notifications: t.isFirstFetch ? u.body.results : [...t.notifications, ...u.body.results],
|
|
@@ -1318,7 +1321,7 @@ class ae {
|
|
|
1318
1321
|
return this.store.getState().pageInfo.hasMore === !1 ? {
|
|
1319
1322
|
status: n.ERROR,
|
|
1320
1323
|
error: {
|
|
1321
|
-
type:
|
|
1324
|
+
type: c.VALIDATION_ERROR,
|
|
1322
1325
|
message: "No more pages to fetch"
|
|
1323
1326
|
}
|
|
1324
1327
|
} : this.fetch();
|
|
@@ -1470,7 +1473,7 @@ class pe {
|
|
|
1470
1473
|
if (!this.userToken || !A()) return;
|
|
1471
1474
|
const t = x(this.userToken), s = (t.exp || 0) * 1e3, r = Date.now(), i = 1e3 * 30;
|
|
1472
1475
|
if (s && s > r) {
|
|
1473
|
-
const
|
|
1476
|
+
const d = s - r - i;
|
|
1474
1477
|
this.userTokenExpirationTimer && clearTimeout(this.userTokenExpirationTimer), this.userTokenExpirationTimer = setTimeout(async () => {
|
|
1475
1478
|
let u = "";
|
|
1476
1479
|
try {
|
|
@@ -1489,7 +1492,7 @@ class pe {
|
|
|
1489
1492
|
}
|
|
1490
1493
|
}
|
|
1491
1494
|
u && typeof u == "string" && this.identify(this.distinctId, u, this.authenticateOptions);
|
|
1492
|
-
},
|
|
1495
|
+
}, d);
|
|
1493
1496
|
}
|
|
1494
1497
|
}
|
|
1495
1498
|
client() {
|
|
@@ -1512,13 +1515,13 @@ class pe {
|
|
|
1512
1515
|
if (!e)
|
|
1513
1516
|
return o({
|
|
1514
1517
|
status: n.ERROR,
|
|
1515
|
-
errorType:
|
|
1518
|
+
errorType: c.VALIDATION_ERROR,
|
|
1516
1519
|
errorMessage: "distinctId is missing"
|
|
1517
1520
|
});
|
|
1518
1521
|
if (this.apiClient && this.distinctId && this.distinctId !== e)
|
|
1519
1522
|
return o({
|
|
1520
1523
|
status: n.ERROR,
|
|
1521
|
-
errorType:
|
|
1524
|
+
errorType: c.VALIDATION_ERROR,
|
|
1522
1525
|
errorMessage: "User already loggedin, reset current user to login new user"
|
|
1523
1526
|
});
|
|
1524
1527
|
if (this.apiClient && this.distinctId === e && this.userToken !== t)
|
|
@@ -1560,7 +1563,7 @@ class pe {
|
|
|
1560
1563
|
properties: s
|
|
1561
1564
|
})) : o({
|
|
1562
1565
|
status: n.ERROR,
|
|
1563
|
-
errorType:
|
|
1566
|
+
errorType: c.VALIDATION_ERROR,
|
|
1564
1567
|
errorMessage: "event name is missing"
|
|
1565
1568
|
});
|
|
1566
1569
|
}
|
|
@@ -1575,7 +1578,7 @@ class pe {
|
|
|
1575
1578
|
export {
|
|
1576
1579
|
_ as ApiResponseStatus,
|
|
1577
1580
|
C as ChannelLevelPreferenceOptions,
|
|
1578
|
-
|
|
1581
|
+
c as ERROR_TYPE,
|
|
1579
1582
|
ae as Feed,
|
|
1580
1583
|
p as PreferenceOptions,
|
|
1581
1584
|
n as RESPONSE_STATUS,
|