@formant/data-sdk 1.17.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-sdk.cjs.js +2 -2
- package/dist/data-sdk.cjs.js.map +1 -1
- package/dist/data-sdk.es.js +396 -387
- package/dist/data-sdk.es.js.map +1 -1
- package/dist/data-sdk.es6.js +1791 -1783
- package/dist/data-sdk.umd.js +27 -27
- package/dist/types/data-sdk/src/cache/StoreCache.d.ts +4 -2
- package/package.json +1 -1
package/dist/data-sdk.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var ce = Object.defineProperty;
|
|
2
2
|
var de = (a, e, t) => e in a ? ce(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
3
|
var s = (a, e, t) => (de(a, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { decode as
|
|
4
|
+
import { decode as V } from "base-64";
|
|
5
5
|
import * as u from "date-fns";
|
|
6
6
|
import { startOfMinute as he, addMinutes as le, roundToNearestMinutes as ue, addSeconds as me } from "date-fns";
|
|
7
|
-
import { RtcClient as
|
|
7
|
+
import { RtcClient as A, SignalingPromiseClient as N } from "@formant/realtime-sdk";
|
|
8
8
|
import { EventEmitter as fe } from "eventemitter3";
|
|
9
9
|
import { deflate as we } from "pako";
|
|
10
10
|
import { fromByteArray as pe } from "base64-js";
|
|
@@ -38,14 +38,14 @@ const h = ge(
|
|
|
38
38
|
typeof window < "u" && window.location ? window.location.search : void 0
|
|
39
39
|
)
|
|
40
40
|
);
|
|
41
|
-
class
|
|
41
|
+
class x extends Error {
|
|
42
42
|
constructor(t) {
|
|
43
43
|
super("login failed");
|
|
44
44
|
s(this, "reason");
|
|
45
45
|
this.reason = t, this.name = "LoginFailureError", Object.setPrototypeOf(this, new.target.prototype);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
class
|
|
48
|
+
class U extends Error {
|
|
49
49
|
constructor(t) {
|
|
50
50
|
super("login challenged");
|
|
51
51
|
s(this, "challenge");
|
|
@@ -98,17 +98,17 @@ class ve {
|
|
|
98
98
|
async login(e, t, n = {}) {
|
|
99
99
|
const { advanced: i = !1 } = n;
|
|
100
100
|
try {
|
|
101
|
-
const
|
|
101
|
+
const o = await fetch(`${this._apiUrl}/v1/admin/auth/login`, {
|
|
102
102
|
method: "POST",
|
|
103
103
|
body: JSON.stringify({ email: e, password: t }),
|
|
104
104
|
headers: {
|
|
105
105
|
"Content-Type": "application/json"
|
|
106
106
|
}
|
|
107
|
-
}), c = await
|
|
108
|
-
if (
|
|
109
|
-
throw new
|
|
107
|
+
}), c = await o.json();
|
|
108
|
+
if (o.status !== 200)
|
|
109
|
+
throw new x(c.message);
|
|
110
110
|
if ("challenge" in c)
|
|
111
|
-
throw new
|
|
111
|
+
throw new U(c.challenge);
|
|
112
112
|
const { authentication: d } = c;
|
|
113
113
|
return await this.loginWithToken(
|
|
114
114
|
d.accessToken,
|
|
@@ -117,25 +117,25 @@ class ve {
|
|
|
117
117
|
result: "success",
|
|
118
118
|
authentication: d
|
|
119
119
|
} : d;
|
|
120
|
-
} catch (
|
|
121
|
-
if (i || console.error("login() failed", { err:
|
|
122
|
-
throw
|
|
123
|
-
return
|
|
120
|
+
} catch (o) {
|
|
121
|
+
if (i || console.error("login() failed", { err: o }), this._waitingForAuth.forEach((c) => c(!1)), this._waitingForAuth.clear(), !i)
|
|
122
|
+
throw o;
|
|
123
|
+
return o instanceof U ? {
|
|
124
124
|
result: "challenged",
|
|
125
|
-
challenge:
|
|
125
|
+
challenge: o.challenge
|
|
126
126
|
} : {
|
|
127
127
|
result: "failure",
|
|
128
|
-
reason:
|
|
128
|
+
reason: o instanceof x ? o.reason : o instanceof Error ? o.message : String(o)
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
async loginWithToken(e, t) {
|
|
133
133
|
var i;
|
|
134
|
-
const n = JSON.parse(
|
|
134
|
+
const n = JSON.parse(V(e.split(".")[1]));
|
|
135
135
|
try {
|
|
136
|
-
let
|
|
137
|
-
if (this._isShareToken = n["formant:claims"] && n["formant:claims"].type == "share", n["formant:claims"] && (this._currentOrganization = n["formant:claims"].organizationId), n["custom:organization_id"] && (this._currentOrganization = n["custom:organization_id"]), this._isShareToken || (
|
|
138
|
-
const c = await fetch(`${this._apiUrl}/v1/admin/users/${
|
|
136
|
+
let o;
|
|
137
|
+
if (this._isShareToken = n["formant:claims"] && n["formant:claims"].type == "share", n["formant:claims"] && (this._currentOrganization = n["formant:claims"].organizationId), n["custom:organization_id"] && (this._currentOrganization = n["custom:organization_id"]), this._isShareToken || (o = n.sub), n["formant:claims"] && n["formant:claims"].userId && (o = n["formant:claims"].userId), o && ((i = this._currentUser) == null ? void 0 : i.id) !== o) {
|
|
138
|
+
const c = await fetch(`${this._apiUrl}/v1/admin/users/${o}`, {
|
|
139
139
|
method: "GET",
|
|
140
140
|
headers: {
|
|
141
141
|
"Content-Type": "application/json",
|
|
@@ -147,8 +147,8 @@ class ve {
|
|
|
147
147
|
this._currentUser = d;
|
|
148
148
|
}
|
|
149
149
|
this._token = e, this._waitingForAuth.forEach((c) => c(!0));
|
|
150
|
-
} catch (
|
|
151
|
-
console.error("loginWithToken() failed", { err:
|
|
150
|
+
} catch (o) {
|
|
151
|
+
console.error("loginWithToken() failed", { err: o }), this._waitingForAuth.forEach((c) => c(!1));
|
|
152
152
|
} finally {
|
|
153
153
|
this._waitingForAuth.clear();
|
|
154
154
|
}
|
|
@@ -280,7 +280,7 @@ class ve {
|
|
|
280
280
|
);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function k() {
|
|
284
284
|
return typeof window < "u" && window.location ? new URLSearchParams(window.location.search).get("module") : null;
|
|
285
285
|
}
|
|
286
286
|
function T(a) {
|
|
@@ -289,7 +289,7 @@ function T(a) {
|
|
|
289
289
|
window.parent.postMessage(a, "*");
|
|
290
290
|
}
|
|
291
291
|
function F() {
|
|
292
|
-
const a =
|
|
292
|
+
const a = k();
|
|
293
293
|
if (!a)
|
|
294
294
|
throw new Error("No module context");
|
|
295
295
|
T({
|
|
@@ -306,7 +306,7 @@ function H(a) {
|
|
|
306
306
|
window.removeEventListener("message", e);
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
|
-
const
|
|
309
|
+
const r = new ve({
|
|
310
310
|
apiUrl: h,
|
|
311
311
|
refreshAuthToken: F,
|
|
312
312
|
addAccessTokenRefreshListener: H
|
|
@@ -317,7 +317,7 @@ async function Te(a) {
|
|
|
317
317
|
{
|
|
318
318
|
headers: {
|
|
319
319
|
"Content-Type": "application/json",
|
|
320
|
-
Authorization: "Bearer " +
|
|
320
|
+
Authorization: "Bearer " + r.token
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
)).json()).configuration;
|
|
@@ -340,7 +340,7 @@ function Ee(a) {
|
|
|
340
340
|
});
|
|
341
341
|
}
|
|
342
342
|
function ke() {
|
|
343
|
-
const a =
|
|
343
|
+
const a = k();
|
|
344
344
|
if (!a)
|
|
345
345
|
throw new Error("No module context");
|
|
346
346
|
T({
|
|
@@ -349,7 +349,7 @@ function ke() {
|
|
|
349
349
|
});
|
|
350
350
|
}
|
|
351
351
|
function Oe(a, e) {
|
|
352
|
-
const t =
|
|
352
|
+
const t = k();
|
|
353
353
|
if (!t)
|
|
354
354
|
throw new Error("No module context");
|
|
355
355
|
T({
|
|
@@ -360,7 +360,7 @@ function Oe(a, e) {
|
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
362
|
function Re(a, e) {
|
|
363
|
-
const t =
|
|
363
|
+
const t = k();
|
|
364
364
|
if (!t)
|
|
365
365
|
throw new Error("No module context");
|
|
366
366
|
T({
|
|
@@ -370,8 +370,8 @@ function Re(a, e) {
|
|
|
370
370
|
after: e || 0
|
|
371
371
|
});
|
|
372
372
|
}
|
|
373
|
-
function
|
|
374
|
-
const e =
|
|
373
|
+
function Ae(a) {
|
|
374
|
+
const e = k();
|
|
375
375
|
if (!e)
|
|
376
376
|
throw new Error("No module context");
|
|
377
377
|
T({
|
|
@@ -380,7 +380,7 @@ function be(a) {
|
|
|
380
380
|
menus: a
|
|
381
381
|
});
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function be(a) {
|
|
384
384
|
T({ type: "show_message", message: a });
|
|
385
385
|
}
|
|
386
386
|
function je(a, e) {
|
|
@@ -393,14 +393,14 @@ function je(a, e) {
|
|
|
393
393
|
};
|
|
394
394
|
return window.addEventListener("message", t), () => window.removeEventListener("message", t);
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function Ne(a) {
|
|
397
397
|
const e = (t) => {
|
|
398
398
|
const n = t.data;
|
|
399
399
|
n.type === "module_menu_item_clicked" && a(n.menu);
|
|
400
400
|
};
|
|
401
401
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function De(a) {
|
|
404
404
|
const e = (t) => {
|
|
405
405
|
const n = t.data;
|
|
406
406
|
n.type === "module_configuration" && a(n);
|
|
@@ -408,7 +408,7 @@ function Ne(a) {
|
|
|
408
408
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
409
409
|
}
|
|
410
410
|
function Pe(a) {
|
|
411
|
-
const e =
|
|
411
|
+
const e = k();
|
|
412
412
|
e && T({ type: "request_module_data", module: e });
|
|
413
413
|
const t = (n) => {
|
|
414
414
|
const i = n.data;
|
|
@@ -428,27 +428,27 @@ function Le(a) {
|
|
|
428
428
|
};
|
|
429
429
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
430
430
|
}
|
|
431
|
-
const Ie = 1, W = 1e3, K = 60 * W, Q = 60 * K,
|
|
431
|
+
const Ie = 1, W = 1e3, K = 60 * W, Q = 60 * K, L = 24 * Q, _e = 7 * L, $e = 30 * L, ze = 365 * L, I = {
|
|
432
432
|
millisecond: Ie,
|
|
433
433
|
second: W,
|
|
434
434
|
minute: K,
|
|
435
435
|
hour: Q,
|
|
436
|
-
day:
|
|
437
|
-
week:
|
|
438
|
-
month:
|
|
439
|
-
year:
|
|
436
|
+
day: L,
|
|
437
|
+
week: _e,
|
|
438
|
+
month: $e,
|
|
439
|
+
year: ze
|
|
440
440
|
};
|
|
441
441
|
function Me(a, e) {
|
|
442
442
|
return a.filter((t) => e.includes(t.type));
|
|
443
443
|
}
|
|
444
|
-
function
|
|
444
|
+
function Be(a, e, t) {
|
|
445
445
|
const n = e.getTime(), i = t.getTime();
|
|
446
|
-
return a.map((
|
|
447
|
-
...
|
|
448
|
-
points:
|
|
446
|
+
return a.map((o) => ({
|
|
447
|
+
...o,
|
|
448
|
+
points: o.points.filter(
|
|
449
449
|
([c]) => c >= n && c < i
|
|
450
450
|
)
|
|
451
|
-
})).filter(({ points:
|
|
451
|
+
})).filter(({ points: o }) => o.length > 0);
|
|
452
452
|
}
|
|
453
453
|
class J {
|
|
454
454
|
constructor({
|
|
@@ -458,20 +458,21 @@ class J {
|
|
|
458
458
|
s(this, "entries", /* @__PURE__ */ new Map());
|
|
459
459
|
s(this, "metadata", /* @__PURE__ */ new Map());
|
|
460
460
|
s(this, "capacity");
|
|
461
|
-
s(this, "
|
|
462
|
-
this.capacity = e || 1e4, this.
|
|
461
|
+
s(this, "staleIntervalMs");
|
|
462
|
+
this.capacity = e || 1e4, this.staleIntervalMs = t || I.minute;
|
|
463
463
|
}
|
|
464
464
|
get(e, t) {
|
|
465
|
-
const n = this.keyToCacheKey(e)
|
|
466
|
-
return
|
|
465
|
+
const n = this.keyToCacheKey(e);
|
|
466
|
+
return this.isStale(n) && !this.isGenerating(n) && t && this.generate(e, t), this.entries.get(n);
|
|
467
467
|
}
|
|
468
468
|
set(e, t) {
|
|
469
469
|
const n = this.keyToCacheKey(e);
|
|
470
470
|
this.metadata.set(n, {
|
|
471
471
|
generating: !1,
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
472
|
+
staleAt: performance.now() + this.staleIntervalMs
|
|
473
|
+
});
|
|
474
|
+
const i = this.entries.get(n);
|
|
475
|
+
JSON.stringify(i) === JSON.stringify(t) || (this.entries.set(n, t), this.enforceMaxSize());
|
|
475
476
|
}
|
|
476
477
|
clear() {
|
|
477
478
|
this.entries.clear(), [...this.metadata.values()].forEach((e) => e.generating = !1);
|
|
@@ -482,73 +483,81 @@ class J {
|
|
|
482
483
|
keyToCacheKey(e) {
|
|
483
484
|
return JSON.stringify(e);
|
|
484
485
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
486
|
+
enforceMaxSize() {
|
|
487
|
+
for (; this.metadata.size > this.capacity && this.metadata.size > 0; ) {
|
|
488
|
+
const [e] = [...this.metadata.entries()].reduce(
|
|
489
|
+
([t, n], [i, o]) => o.staleAt < n.staleAt ? [i, o] : [t, n]
|
|
490
|
+
);
|
|
491
|
+
this.clearKey(e);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
isStale(e) {
|
|
495
|
+
const t = this.metadata.get(e);
|
|
496
|
+
return t ? (t == null ? void 0 : t.staleAt) < performance.now() : !0;
|
|
497
|
+
}
|
|
498
|
+
isGenerating(e) {
|
|
499
|
+
const t = this.metadata.get(e);
|
|
500
|
+
return t ? t.generating : !1;
|
|
492
501
|
}
|
|
493
502
|
generate(e, t) {
|
|
494
|
-
const n = this.keyToCacheKey(e), i = this.metadata.get(n) || {}
|
|
503
|
+
const n = this.keyToCacheKey(e), i = this.metadata.get(n) || {}, o = t().then((c) => {
|
|
504
|
+
const d = this.metadata.get(n);
|
|
505
|
+
return (d == null ? void 0 : d.generating) !== o || this.set(e, c), c;
|
|
506
|
+
}).catch((c) => {
|
|
507
|
+
throw this.metadata.delete(n), c;
|
|
508
|
+
});
|
|
495
509
|
this.metadata.set(n, {
|
|
496
510
|
...i,
|
|
497
|
-
generating:
|
|
498
|
-
|
|
499
|
-
})
|
|
500
|
-
t.then((r) => {
|
|
501
|
-
const c = this.metadata.get(n);
|
|
502
|
-
!(c != null && c.generating) || this.set(e, r);
|
|
503
|
-
});
|
|
504
|
-
}, 0);
|
|
511
|
+
generating: o,
|
|
512
|
+
staleAt: performance.now() + this.staleIntervalMs
|
|
513
|
+
});
|
|
505
514
|
}
|
|
506
515
|
}
|
|
507
|
-
async function
|
|
508
|
-
if (!
|
|
516
|
+
async function _(a) {
|
|
517
|
+
if (!r.token)
|
|
509
518
|
throw new Error("Not authenticated");
|
|
510
519
|
return (await (await fetch(`${h}/v1/queries/queries`, {
|
|
511
520
|
method: "POST",
|
|
512
521
|
body: JSON.stringify(a),
|
|
513
522
|
headers: {
|
|
514
523
|
"Content-Type": "application/json",
|
|
515
|
-
Authorization: "Bearer " +
|
|
524
|
+
Authorization: "Bearer " + r.token
|
|
516
525
|
}
|
|
517
526
|
})).json()).items;
|
|
518
527
|
}
|
|
519
|
-
class
|
|
528
|
+
class qe {
|
|
520
529
|
constructor() {
|
|
521
530
|
s(this, "queryStoreCache", new J({
|
|
522
531
|
capacity: 1e4,
|
|
523
|
-
timeout: 20 *
|
|
532
|
+
timeout: 20 * I.second
|
|
524
533
|
}));
|
|
525
534
|
s(this, "liveQueryStoreCache", new J({
|
|
526
535
|
capacity: 1e4,
|
|
527
|
-
timeout: 200 *
|
|
536
|
+
timeout: 200 * I.millisecond
|
|
528
537
|
}));
|
|
529
538
|
}
|
|
530
|
-
moduleQuery(e, t, n, i,
|
|
539
|
+
moduleQuery(e, t, n, i, o, c = !1) {
|
|
531
540
|
const d = {
|
|
532
541
|
...e,
|
|
533
542
|
names: [...t],
|
|
534
543
|
types: [...n]
|
|
535
|
-
}, y = this.query(d, i,
|
|
544
|
+
}, y = this.query(d, i, o, c);
|
|
536
545
|
return y === void 0 || y === "too much data" ? y : Me(y, n);
|
|
537
546
|
}
|
|
538
547
|
query(e, t, n, i = !1) {
|
|
539
|
-
const
|
|
548
|
+
const o = {
|
|
540
549
|
...e,
|
|
541
550
|
start: he(t).toISOString(),
|
|
542
551
|
end: i ? n.toISOString() : le(ue(n), 1).toISOString(),
|
|
543
552
|
latestOnly: i
|
|
544
553
|
}, c = n > me(/* @__PURE__ */ new Date(), -20);
|
|
545
554
|
let d;
|
|
546
|
-
return c ? d = this.liveQueryCache(
|
|
555
|
+
return c ? d = this.liveQueryCache(o) : d = this.queryCache(o), !d || d === "too much data" || i ? d : Be(d, t, n);
|
|
547
556
|
}
|
|
548
557
|
queryCache(e) {
|
|
549
558
|
return this.queryStoreCache.get(e, async () => {
|
|
550
559
|
try {
|
|
551
|
-
return await
|
|
560
|
+
return await _(e);
|
|
552
561
|
} catch (t) {
|
|
553
562
|
throw t;
|
|
554
563
|
}
|
|
@@ -557,21 +566,21 @@ class xe {
|
|
|
557
566
|
liveQueryCache(e) {
|
|
558
567
|
return this.liveQueryStoreCache.get(e, async () => {
|
|
559
568
|
try {
|
|
560
|
-
return await
|
|
569
|
+
return await _(e);
|
|
561
570
|
} catch (t) {
|
|
562
571
|
throw t;
|
|
563
572
|
}
|
|
564
573
|
});
|
|
565
574
|
}
|
|
566
575
|
}
|
|
567
|
-
const
|
|
568
|
-
function
|
|
576
|
+
const xe = new qe();
|
|
577
|
+
function Ue(a, e, t) {
|
|
569
578
|
const n = (i) => {
|
|
570
|
-
const
|
|
571
|
-
if (
|
|
572
|
-
const { start: c, end: d } =
|
|
579
|
+
const o = i.data;
|
|
580
|
+
if (o.type === "module_data") {
|
|
581
|
+
const { start: c, end: d } = o.queryRange;
|
|
573
582
|
t(
|
|
574
|
-
|
|
583
|
+
xe.moduleQuery(
|
|
575
584
|
{},
|
|
576
585
|
a,
|
|
577
586
|
e,
|
|
@@ -592,14 +601,14 @@ async function Je(a, e, t) {
|
|
|
592
601
|
maxTime: t,
|
|
593
602
|
time: a
|
|
594
603
|
});
|
|
595
|
-
const i = (
|
|
596
|
-
const c =
|
|
604
|
+
const i = (o) => {
|
|
605
|
+
const c = o.data;
|
|
597
606
|
c.type === "date_response" && (window.removeEventListener("message", i), n(c.data));
|
|
598
607
|
};
|
|
599
608
|
window.addEventListener("message", i);
|
|
600
609
|
});
|
|
601
610
|
}
|
|
602
|
-
async function
|
|
611
|
+
async function Ge(a, e) {
|
|
603
612
|
return new Promise((t) => {
|
|
604
613
|
const n = Math.random().toString();
|
|
605
614
|
T({
|
|
@@ -609,16 +618,16 @@ async function Ve(a, e) {
|
|
|
609
618
|
okText: e == null ? void 0 : e.okText,
|
|
610
619
|
cancelText: e == null ? void 0 : e.cancelText
|
|
611
620
|
});
|
|
612
|
-
const i = (
|
|
613
|
-
const c =
|
|
621
|
+
const i = (o) => {
|
|
622
|
+
const c = o.data;
|
|
614
623
|
c.type === "prompt_response" && c.promptId === n && t(c.data), window.removeEventListener("message", i);
|
|
615
624
|
};
|
|
616
625
|
window.addEventListener("message", i);
|
|
617
626
|
});
|
|
618
627
|
}
|
|
619
|
-
const
|
|
628
|
+
const q = class {
|
|
620
629
|
static isModule() {
|
|
621
|
-
return
|
|
630
|
+
return k() !== null;
|
|
622
631
|
}
|
|
623
632
|
static async getCurrentModuleConfiguration() {
|
|
624
633
|
let e = new URLSearchParams("");
|
|
@@ -628,7 +637,7 @@ const g = class g {
|
|
|
628
637
|
return Te(t.trim());
|
|
629
638
|
}
|
|
630
639
|
static get isOnline() {
|
|
631
|
-
return
|
|
640
|
+
return q._isOnline;
|
|
632
641
|
}
|
|
633
642
|
static listenForConnectionEvents() {
|
|
634
643
|
const e = (t) => {
|
|
@@ -642,12 +651,12 @@ const g = class g {
|
|
|
642
651
|
const i = setTimeout(
|
|
643
652
|
() => n(new Error("deadline expired: took too long")),
|
|
644
653
|
e
|
|
645
|
-
),
|
|
646
|
-
window.removeEventListener("message",
|
|
654
|
+
), o = (c) => {
|
|
655
|
+
window.removeEventListener("message", o), clearTimeout(i);
|
|
647
656
|
const { data: d } = c;
|
|
648
657
|
d.type === "formant_online" && (this._isOnline = d.online, t(d.online));
|
|
649
658
|
};
|
|
650
|
-
window.addEventListener("message",
|
|
659
|
+
window.addEventListener("message", o), T({ type: "formant_online" });
|
|
651
660
|
});
|
|
652
661
|
}
|
|
653
662
|
static waitForConnection(e = 5e3) {
|
|
@@ -656,18 +665,18 @@ const g = class g {
|
|
|
656
665
|
setTimeout(() => {
|
|
657
666
|
t = !0, d(new Error("deadline expired: took too long"));
|
|
658
667
|
}, e);
|
|
659
|
-
}), i = (c) => new Promise((d) => setTimeout(d, c)),
|
|
668
|
+
}), i = (c) => new Promise((d) => setTimeout(d, c)), o = async () => {
|
|
660
669
|
for (await i(50); !t && !(this.isOnline || await this.checkConnection); )
|
|
661
670
|
await i(500);
|
|
662
671
|
};
|
|
663
|
-
return Promise.race([n,
|
|
672
|
+
return Promise.race([n, o()]);
|
|
664
673
|
}
|
|
665
674
|
};
|
|
666
|
-
|
|
667
|
-
s(g, "
|
|
668
|
-
s(g, "
|
|
669
|
-
s(g, "
|
|
670
|
-
|
|
675
|
+
let g = q;
|
|
676
|
+
s(g, "getCurrentModuleContext", k), // senders
|
|
677
|
+
s(g, "disableAnalyticsBottomBar", Ce), s(g, "goToDevice", Se), s(g, "goToTime", Ee), s(g, "refreshAuthToken", F), s(g, "requestModuleData", ke), s(g, "sendChannelData", Oe), s(g, "setModuleDateTimeRange", Re), s(g, "setupModuleMenus", Ae), s(g, "showMessage", be), // listeners
|
|
678
|
+
s(g, "addAccessTokenRefreshListener", H), s(g, "addChannelDataListener", je), s(g, "addMenuListener", Ne), s(g, "addModuleConfigurationListener", De), s(g, "addModuleDataListener", Pe), s(g, "addOverviewDeviceListener", Le), s(g, "addStreamListener", Ue), // bidirectional
|
|
679
|
+
s(g, "getDate", Je), s(g, "prompt", Ge), s(g, "_isOnline", null);
|
|
671
680
|
function f(a, e) {
|
|
672
681
|
if (a !== void 0)
|
|
673
682
|
return a;
|
|
@@ -691,11 +700,11 @@ const p = {
|
|
|
691
700
|
portForward: p.PORT_FORWARD,
|
|
692
701
|
observe: p.OBSERVE,
|
|
693
702
|
headless: p.HEADLESS
|
|
694
|
-
},
|
|
695
|
-
var
|
|
703
|
+
}, O = Symbol("RtcClientPool.instance");
|
|
704
|
+
var Vt;
|
|
696
705
|
class D {
|
|
697
706
|
constructor(e) {
|
|
698
|
-
s(this,
|
|
707
|
+
s(this, Vt, null);
|
|
699
708
|
s(this, "createClient");
|
|
700
709
|
s(this, "ttlMs");
|
|
701
710
|
s(this, "proxyHandler");
|
|
@@ -706,18 +715,18 @@ class D {
|
|
|
706
715
|
});
|
|
707
716
|
const { createClient: t, ttlMs: n = 0 } = e;
|
|
708
717
|
this.createClient = t, this.ttlMs = Math.max(n, 0), this.proxyHandler = {
|
|
709
|
-
get: (i,
|
|
710
|
-
switch (
|
|
718
|
+
get: (i, o, c) => {
|
|
719
|
+
switch (o) {
|
|
711
720
|
case "shutdown":
|
|
712
721
|
return () => this.releaseInstance(c);
|
|
713
722
|
default:
|
|
714
|
-
return Reflect.get(i,
|
|
723
|
+
return Reflect.get(i, o, c);
|
|
715
724
|
}
|
|
716
725
|
}
|
|
717
726
|
};
|
|
718
727
|
}
|
|
719
728
|
get isActive() {
|
|
720
|
-
return this[
|
|
729
|
+
return this[O] !== null;
|
|
721
730
|
}
|
|
722
731
|
get size() {
|
|
723
732
|
return this.proxyReceivers.size;
|
|
@@ -727,13 +736,13 @@ class D {
|
|
|
727
736
|
return this.proxyReceivers.set(t, e ?? null), t;
|
|
728
737
|
}
|
|
729
738
|
allocate() {
|
|
730
|
-
if (this[
|
|
731
|
-
return this.teardownTimeout && (clearTimeout(this.teardownTimeout), this.teardownTimeout = null), this[
|
|
739
|
+
if (this[O])
|
|
740
|
+
return this.teardownTimeout && (clearTimeout(this.teardownTimeout), this.teardownTimeout = null), this[O];
|
|
732
741
|
const e = this.createClient(this.dispatch);
|
|
733
|
-
return this[
|
|
742
|
+
return this[O] = e, e;
|
|
734
743
|
}
|
|
735
744
|
async teardown() {
|
|
736
|
-
const e = this[
|
|
745
|
+
const e = this[O];
|
|
737
746
|
if (!e) {
|
|
738
747
|
console.warn("singleton has already been shutdown!");
|
|
739
748
|
return;
|
|
@@ -741,7 +750,7 @@ class D {
|
|
|
741
750
|
try {
|
|
742
751
|
await e.shutdown();
|
|
743
752
|
} finally {
|
|
744
|
-
this[
|
|
753
|
+
this[O] = null;
|
|
745
754
|
}
|
|
746
755
|
}
|
|
747
756
|
async releaseInstance(e) {
|
|
@@ -750,63 +759,63 @@ class D {
|
|
|
750
759
|
}, this.ttlMs)), !0) : (console.warn("this instance has already been released!"), !1);
|
|
751
760
|
}
|
|
752
761
|
}
|
|
753
|
-
|
|
754
|
-
const
|
|
762
|
+
Vt = O;
|
|
763
|
+
const P = async () => f(r.token, "Realtime when user isn't authorized"), R = {
|
|
755
764
|
[p.UNKNOWN]: new D({
|
|
756
765
|
ttlMs: 2500,
|
|
757
|
-
createClient: (a) => new
|
|
758
|
-
signalingClient: new
|
|
759
|
-
getToken:
|
|
766
|
+
createClient: (a) => new A({
|
|
767
|
+
signalingClient: new N(h),
|
|
768
|
+
getToken: P,
|
|
760
769
|
sessionType: p.UNKNOWN,
|
|
761
770
|
receive: a
|
|
762
771
|
})
|
|
763
772
|
}),
|
|
764
773
|
[p.TELEOP]: new D({
|
|
765
774
|
ttlMs: 2500,
|
|
766
|
-
createClient: (a) => new
|
|
767
|
-
signalingClient: new
|
|
768
|
-
getToken:
|
|
775
|
+
createClient: (a) => new A({
|
|
776
|
+
signalingClient: new N(h),
|
|
777
|
+
getToken: P,
|
|
769
778
|
sessionType: p.TELEOP,
|
|
770
779
|
receive: a
|
|
771
780
|
})
|
|
772
781
|
}),
|
|
773
782
|
[p.PORT_FORWARD]: new D({
|
|
774
783
|
ttlMs: 2500,
|
|
775
|
-
createClient: (a) => new
|
|
776
|
-
signalingClient: new
|
|
777
|
-
getToken:
|
|
784
|
+
createClient: (a) => new A({
|
|
785
|
+
signalingClient: new N(h),
|
|
786
|
+
getToken: P,
|
|
778
787
|
sessionType: p.PORT_FORWARD,
|
|
779
788
|
receive: a
|
|
780
789
|
})
|
|
781
790
|
}),
|
|
782
791
|
[p.OBSERVE]: new D({
|
|
783
792
|
ttlMs: 2500,
|
|
784
|
-
createClient: (a) => new
|
|
785
|
-
signalingClient: new
|
|
786
|
-
getToken:
|
|
793
|
+
createClient: (a) => new A({
|
|
794
|
+
signalingClient: new N(h),
|
|
795
|
+
getToken: P,
|
|
787
796
|
sessionType: p.OBSERVE,
|
|
788
797
|
receive: a
|
|
789
798
|
})
|
|
790
799
|
}),
|
|
791
800
|
[p.HEADLESS]: new D({
|
|
792
801
|
ttlMs: 2500,
|
|
793
|
-
createClient: (a) => new
|
|
794
|
-
signalingClient: new
|
|
795
|
-
getToken:
|
|
802
|
+
createClient: (a) => new A({
|
|
803
|
+
signalingClient: new N(h),
|
|
804
|
+
getToken: P,
|
|
796
805
|
sessionType: p.HEADLESS,
|
|
797
806
|
receive: a
|
|
798
807
|
})
|
|
799
808
|
})
|
|
800
|
-
},
|
|
801
|
-
...
|
|
802
|
-
unknown:
|
|
803
|
-
teleop:
|
|
804
|
-
portForward:
|
|
805
|
-
observe:
|
|
806
|
-
headless:
|
|
807
|
-
},
|
|
809
|
+
}, Ve = {
|
|
810
|
+
...R,
|
|
811
|
+
unknown: R[p.UNKNOWN],
|
|
812
|
+
teleop: R[p.TELEOP],
|
|
813
|
+
portForward: R[p.PORT_FORWARD],
|
|
814
|
+
observe: R[p.OBSERVE],
|
|
815
|
+
headless: R[p.HEADLESS]
|
|
816
|
+
}, $ = R[p.TELEOP], Fe = (a) => {
|
|
808
817
|
const { sessionType: e } = a;
|
|
809
|
-
return e ?
|
|
818
|
+
return e ? Ve[e] : $;
|
|
810
819
|
};
|
|
811
820
|
class He {
|
|
812
821
|
constructor(e) {
|
|
@@ -860,8 +869,8 @@ class Ke {
|
|
|
860
869
|
console.error(t), this.error = "An error occurred in DataChannel", this.errorListeners.forEach((n) => n(t));
|
|
861
870
|
}, this.dataChannel.onmessage = (t) => {
|
|
862
871
|
this.listeners.forEach((n) => {
|
|
863
|
-
const i = new Uint8Array(t.data),
|
|
864
|
-
n(
|
|
872
|
+
const i = new Uint8Array(t.data), o = this.decoder.decode(i);
|
|
873
|
+
n(o);
|
|
865
874
|
}), this.binaryListeners.forEach((n) => {
|
|
866
875
|
n(new Uint8Array(t.data));
|
|
867
876
|
});
|
|
@@ -1009,21 +1018,21 @@ class Xe extends X {
|
|
|
1009
1018
|
const i = t.slice(0, 16).toString();
|
|
1010
1019
|
if (i.length === 0)
|
|
1011
1020
|
throw new Error("Invalid response");
|
|
1012
|
-
const
|
|
1013
|
-
if (
|
|
1021
|
+
const o = t.slice(16);
|
|
1022
|
+
if (o.length === 0)
|
|
1014
1023
|
throw new Error("Invalid response");
|
|
1015
|
-
this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i,
|
|
1024
|
+
this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, o);
|
|
1016
1025
|
});
|
|
1017
1026
|
}
|
|
1018
1027
|
async request(t) {
|
|
1019
1028
|
if (this.channel || await this.initialize(), !this.channel)
|
|
1020
1029
|
throw new Error("Failed to create channel");
|
|
1021
|
-
const { channel: n, requestIdToResponseMap: i, timeout:
|
|
1030
|
+
const { channel: n, requestIdToResponseMap: i, timeout: o } = this;
|
|
1022
1031
|
await n.waitTilReady();
|
|
1023
1032
|
const c = this.generateBinaryId(), d = c.toString();
|
|
1024
1033
|
i.set(d, !0), n.sendBinary(new Uint8Array([...c, ...t]));
|
|
1025
1034
|
const y = (/* @__PURE__ */ new Date()).getTime();
|
|
1026
|
-
for (; (/* @__PURE__ */ new Date()).getTime() < y +
|
|
1035
|
+
for (; (/* @__PURE__ */ new Date()).getTime() < y + o; )
|
|
1027
1036
|
if (await b(50), i.has(d)) {
|
|
1028
1037
|
const m = i.get(d);
|
|
1029
1038
|
if (m !== !0) {
|
|
@@ -1039,7 +1048,7 @@ class Xe extends X {
|
|
|
1039
1048
|
}
|
|
1040
1049
|
throw i.delete(d), console.error({
|
|
1041
1050
|
name: "TimeoutError",
|
|
1042
|
-
message: `Request timed out after ${
|
|
1051
|
+
message: `Request timed out after ${o / 1e3} seconds`
|
|
1043
1052
|
}), new Error("Binary request data channel request timed out");
|
|
1044
1053
|
}
|
|
1045
1054
|
}
|
|
@@ -1049,10 +1058,10 @@ class Ye extends X {
|
|
|
1049
1058
|
}
|
|
1050
1059
|
async initialize() {
|
|
1051
1060
|
this.channel = await this.device.createCustomDataChannel(this.channel_name), this.channel.addListener((e) => {
|
|
1052
|
-
const t = JSON.parse(e), { id: n, data: i, error:
|
|
1061
|
+
const t = JSON.parse(e), { id: n, data: i, error: o } = t;
|
|
1053
1062
|
if (!n)
|
|
1054
1063
|
throw new Error("Invalid response");
|
|
1055
|
-
if (!i && !
|
|
1064
|
+
if (!i && !o)
|
|
1056
1065
|
throw new Error("Invalid response");
|
|
1057
1066
|
this.requestIdToResponseMap.has(n) && this.requestIdToResponseMap.set(n, t);
|
|
1058
1067
|
});
|
|
@@ -1062,19 +1071,19 @@ class Ye extends X {
|
|
|
1062
1071
|
throw new Error("Failed to create channel");
|
|
1063
1072
|
const { channel: t, requestIdToResponseMap: n, timeout: i } = this;
|
|
1064
1073
|
await t.waitTilReady();
|
|
1065
|
-
const
|
|
1066
|
-
n.set(
|
|
1074
|
+
const o = this.generateTextId();
|
|
1075
|
+
n.set(o, !0), t.send(
|
|
1067
1076
|
JSON.stringify({
|
|
1068
|
-
id:
|
|
1077
|
+
id: o,
|
|
1069
1078
|
data: e
|
|
1070
1079
|
})
|
|
1071
1080
|
);
|
|
1072
1081
|
const c = (/* @__PURE__ */ new Date()).getTime();
|
|
1073
1082
|
for (; (/* @__PURE__ */ new Date()).getTime() < c + i; )
|
|
1074
|
-
if (await b(50), n.has(
|
|
1075
|
-
const d = n.get(
|
|
1083
|
+
if (await b(50), n.has(o)) {
|
|
1084
|
+
const d = n.get(o);
|
|
1076
1085
|
if (d !== !0) {
|
|
1077
|
-
n.delete(
|
|
1086
|
+
n.delete(o);
|
|
1078
1087
|
const { data: y, error: m } = d;
|
|
1079
1088
|
if (y)
|
|
1080
1089
|
return y;
|
|
@@ -1085,7 +1094,7 @@ class Ye extends X {
|
|
|
1085
1094
|
}), new Error("Text request datachannel adapter error");
|
|
1086
1095
|
}
|
|
1087
1096
|
}
|
|
1088
|
-
throw n.delete(
|
|
1097
|
+
throw n.delete(o), console.error({
|
|
1089
1098
|
name: "TimeoutError",
|
|
1090
1099
|
message: `Request timed out after ${i / 1e3} seconds`
|
|
1091
1100
|
}), new Error("Text request datachannel request timed out");
|
|
@@ -1145,13 +1154,13 @@ class Y extends fe {
|
|
|
1145
1154
|
return n;
|
|
1146
1155
|
}
|
|
1147
1156
|
async getRealtimeVideoStreams() {
|
|
1148
|
-
var i,
|
|
1157
|
+
var i, o, c;
|
|
1149
1158
|
const t = await this.getConfiguration(), n = [];
|
|
1150
1159
|
for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
|
|
1151
1160
|
d.rtcStreamType === "h264-video-frame" && n.push({
|
|
1152
1161
|
name: d.name
|
|
1153
1162
|
});
|
|
1154
|
-
for (const d of ((
|
|
1163
|
+
for (const d of ((o = t.teleop) == null ? void 0 : o.rosStreams) ?? [])
|
|
1155
1164
|
d.topicType == "formant/H264VideoFrame" && n.push({
|
|
1156
1165
|
name: d.topicName
|
|
1157
1166
|
}), (d.topicType === "sensor_msgs/Image" || d.topicType === "sensor_msgs/CompressedImage") && d.encodeVideo && n.push({
|
|
@@ -1239,8 +1248,8 @@ class Y extends fe {
|
|
|
1239
1248
|
const i = f(
|
|
1240
1249
|
this.rtcClient,
|
|
1241
1250
|
"Realtime connection has not been started"
|
|
1242
|
-
),
|
|
1243
|
-
i.controlRemoteStream(f(
|
|
1251
|
+
), o = await this.getRemotePeer();
|
|
1252
|
+
i.controlRemoteStream(f(o).id, {
|
|
1244
1253
|
streamName: t,
|
|
1245
1254
|
setAudioFormat: n
|
|
1246
1255
|
});
|
|
@@ -1249,9 +1258,9 @@ class Y extends fe {
|
|
|
1249
1258
|
const i = f(
|
|
1250
1259
|
this.rtcClient,
|
|
1251
1260
|
"Realtime connection has not been started"
|
|
1252
|
-
),
|
|
1261
|
+
), o = await this.getRemotePeer(), c = await new Promise((d) => {
|
|
1253
1262
|
i.createCustomDataChannel(
|
|
1254
|
-
f(
|
|
1263
|
+
f(o).id,
|
|
1255
1264
|
t,
|
|
1256
1265
|
{
|
|
1257
1266
|
ordered: !0,
|
|
@@ -1272,17 +1281,17 @@ class Y extends fe {
|
|
|
1272
1281
|
const i = f(
|
|
1273
1282
|
this.rtcClient,
|
|
1274
1283
|
"Realtime connection has not been started"
|
|
1275
|
-
),
|
|
1276
|
-
i.send(f(
|
|
1284
|
+
), o = await this.getRemotePeer();
|
|
1285
|
+
i.send(f(o).id, t, n);
|
|
1277
1286
|
}
|
|
1278
1287
|
async getRealtimeAudioStreams() {
|
|
1279
|
-
var i,
|
|
1288
|
+
var i, o, c;
|
|
1280
1289
|
const t = await this.getConfiguration(), n = [];
|
|
1281
1290
|
for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
|
|
1282
1291
|
d.rtcStreamType === "audio-chunk" && n.push({
|
|
1283
1292
|
name: d.name
|
|
1284
1293
|
});
|
|
1285
|
-
for (const d of ((
|
|
1294
|
+
for (const d of ((o = t.teleop) == null ? void 0 : o.rosStreams) ?? [])
|
|
1286
1295
|
d.topicType == "audio_common_msgs/AudioData" && n.push({
|
|
1287
1296
|
name: d.topicName
|
|
1288
1297
|
});
|
|
@@ -1300,18 +1309,18 @@ function et(a) {
|
|
|
1300
1309
|
return pe(n);
|
|
1301
1310
|
}
|
|
1302
1311
|
async function Z() {
|
|
1303
|
-
if (!
|
|
1312
|
+
if (!r.token)
|
|
1304
1313
|
throw new Error("Not authenticated");
|
|
1305
1314
|
return (await (await fetch(`${h}/v1/admin/views`, {
|
|
1306
1315
|
method: "GET",
|
|
1307
1316
|
headers: {
|
|
1308
1317
|
"Content-Type": "application/json",
|
|
1309
|
-
Authorization: "Bearer " +
|
|
1318
|
+
Authorization: "Bearer " + r.token
|
|
1310
1319
|
}
|
|
1311
1320
|
})).json()).items;
|
|
1312
1321
|
}
|
|
1313
1322
|
async function ee(a, e) {
|
|
1314
|
-
if (!
|
|
1323
|
+
if (!r.token)
|
|
1315
1324
|
throw new Error("Not authenticated");
|
|
1316
1325
|
const n = (await Z()).filter((d) => d.name === e);
|
|
1317
1326
|
if (n.length === 0)
|
|
@@ -1321,10 +1330,10 @@ async function ee(a, e) {
|
|
|
1321
1330
|
body: JSON.stringify(a),
|
|
1322
1331
|
headers: {
|
|
1323
1332
|
"Content-Type": "application/json",
|
|
1324
|
-
Authorization: "Bearer " +
|
|
1333
|
+
Authorization: "Bearer " + r.token
|
|
1325
1334
|
}
|
|
1326
|
-
}),
|
|
1327
|
-
return `${
|
|
1335
|
+
}), o = h.replace("api", "app"), { code: c } = await i.json();
|
|
1336
|
+
return `${o}/shares/${c}#${et({
|
|
1328
1337
|
viewId: n[0].id
|
|
1329
1338
|
})}`;
|
|
1330
1339
|
}
|
|
@@ -1355,10 +1364,10 @@ function at(a) {
|
|
|
1355
1364
|
function it(a) {
|
|
1356
1365
|
return a.min;
|
|
1357
1366
|
}
|
|
1358
|
-
function
|
|
1367
|
+
function rt(a) {
|
|
1359
1368
|
return a.count === 0 ? -1 : a.sum / a.count;
|
|
1360
1369
|
}
|
|
1361
|
-
function
|
|
1370
|
+
function ot(a) {
|
|
1362
1371
|
return a.sum;
|
|
1363
1372
|
}
|
|
1364
1373
|
function st(a) {
|
|
@@ -1368,8 +1377,8 @@ const nn = {
|
|
|
1368
1377
|
min: it,
|
|
1369
1378
|
max: at,
|
|
1370
1379
|
"standard deviation": nt,
|
|
1371
|
-
average:
|
|
1372
|
-
sum:
|
|
1380
|
+
average: rt,
|
|
1381
|
+
sum: ot,
|
|
1373
1382
|
count: st
|
|
1374
1383
|
}, te = {
|
|
1375
1384
|
day: {
|
|
@@ -1428,32 +1437,32 @@ const nn = {
|
|
|
1428
1437
|
// bg-BG: 'dd.mm.YYYY'
|
|
1429
1438
|
a.split("/")[0] + "/" + a.split("/")[1] + "–" + e.split("/")[0] + "/" + e.split("/")[1]
|
|
1430
1439
|
);
|
|
1431
|
-
async function
|
|
1432
|
-
if (!
|
|
1440
|
+
async function z(a) {
|
|
1441
|
+
if (!r.token)
|
|
1433
1442
|
throw new Error("Not authenticated");
|
|
1434
1443
|
return (await (await fetch(`${h}/v1/admin/events/query`, {
|
|
1435
1444
|
method: "POST",
|
|
1436
1445
|
body: JSON.stringify(a),
|
|
1437
1446
|
headers: {
|
|
1438
1447
|
"Content-Type": "application/json",
|
|
1439
|
-
Authorization: "Bearer " +
|
|
1448
|
+
Authorization: "Bearer " + r.token
|
|
1440
1449
|
}
|
|
1441
1450
|
})).json()).items;
|
|
1442
1451
|
}
|
|
1443
1452
|
async function ne(a, e, t, n, i) {
|
|
1444
|
-
const
|
|
1453
|
+
const o = te[e];
|
|
1445
1454
|
return await Promise.all(
|
|
1446
1455
|
Array(t).fill(0).map(async (c, d) => {
|
|
1447
|
-
const y = new Date(n), m =
|
|
1448
|
-
|
|
1456
|
+
const y = new Date(n), m = o.sub(
|
|
1457
|
+
o.start(y),
|
|
1449
1458
|
t - d - 1
|
|
1450
|
-
), w =
|
|
1451
|
-
|
|
1459
|
+
), w = o.sub(
|
|
1460
|
+
o.end(y),
|
|
1452
1461
|
t - d - 1
|
|
1453
1462
|
), v = ct(
|
|
1454
1463
|
m.toLocaleDateString(),
|
|
1455
1464
|
w.toLocaleDateString()
|
|
1456
|
-
), C = await
|
|
1465
|
+
), C = await z({
|
|
1457
1466
|
...i,
|
|
1458
1467
|
eventTypes: a,
|
|
1459
1468
|
start: new Date(m).toISOString(),
|
|
@@ -1463,15 +1472,15 @@ async function ne(a, e, t, n, i) {
|
|
|
1463
1472
|
})
|
|
1464
1473
|
);
|
|
1465
1474
|
}
|
|
1466
|
-
async function
|
|
1467
|
-
return (await
|
|
1475
|
+
async function M(a, e) {
|
|
1476
|
+
return (await z({
|
|
1468
1477
|
...a,
|
|
1469
1478
|
eventTypes: ["annotation"]
|
|
1470
1479
|
})).filter(
|
|
1471
|
-
(
|
|
1472
|
-
).reduce((
|
|
1480
|
+
(o) => !!o.tags && Object.keys(o.tags).includes(e)
|
|
1481
|
+
).reduce((o, c) => {
|
|
1473
1482
|
const d = c.tags[e];
|
|
1474
|
-
return d in
|
|
1483
|
+
return d in o ? (o[d] += 1, o) : (o[d] = 1, o);
|
|
1475
1484
|
}, {});
|
|
1476
1485
|
}
|
|
1477
1486
|
async function ae(a, e, t) {
|
|
@@ -1480,7 +1489,7 @@ async function ae(a, e, t) {
|
|
|
1480
1489
|
end: new Date(n)
|
|
1481
1490
|
}), d = c.map((m, w) => {
|
|
1482
1491
|
const v = new Date(m).toISOString(), C = w === c.length - 1 ? new Date(Date.now()).toISOString() : new Date(c[w + 1]);
|
|
1483
|
-
return
|
|
1492
|
+
return M(
|
|
1484
1493
|
{
|
|
1485
1494
|
...a,
|
|
1486
1495
|
start: v,
|
|
@@ -1495,13 +1504,13 @@ async function ae(a, e, t) {
|
|
|
1495
1504
|
}));
|
|
1496
1505
|
}
|
|
1497
1506
|
async function ie(a, e, t, n, i) {
|
|
1498
|
-
let
|
|
1499
|
-
Array.isArray(a) || (
|
|
1507
|
+
let o = a;
|
|
1508
|
+
Array.isArray(a) || (o = [a]);
|
|
1500
1509
|
let c = e;
|
|
1501
1510
|
return Array.isArray(e) || (c = [e]), (await (await fetch(`${h}/v1/queries/queries`, {
|
|
1502
1511
|
method: "POST",
|
|
1503
1512
|
body: JSON.stringify({
|
|
1504
|
-
deviceIds:
|
|
1513
|
+
deviceIds: o,
|
|
1505
1514
|
end: n.toISOString(),
|
|
1506
1515
|
names: c,
|
|
1507
1516
|
start: t.toISOString(),
|
|
@@ -1509,24 +1518,24 @@ async function ie(a, e, t, n, i) {
|
|
|
1509
1518
|
}),
|
|
1510
1519
|
headers: {
|
|
1511
1520
|
"Content-Type": "application/json",
|
|
1512
|
-
Authorization: "Bearer " +
|
|
1521
|
+
Authorization: "Bearer " + r.token
|
|
1513
1522
|
}
|
|
1514
1523
|
})).json()).items;
|
|
1515
1524
|
}
|
|
1516
|
-
async function
|
|
1517
|
-
if (!
|
|
1525
|
+
async function re() {
|
|
1526
|
+
if (!r.token)
|
|
1518
1527
|
throw new Error("Not authenticated");
|
|
1519
|
-
const a =
|
|
1528
|
+
const a = $.get();
|
|
1520
1529
|
try {
|
|
1521
1530
|
return await a.getSessions();
|
|
1522
1531
|
} finally {
|
|
1523
1532
|
await a.shutdown();
|
|
1524
1533
|
}
|
|
1525
1534
|
}
|
|
1526
|
-
async function
|
|
1527
|
-
if (!
|
|
1535
|
+
async function oe() {
|
|
1536
|
+
if (!r.token)
|
|
1528
1537
|
throw new Error("Not authenticated");
|
|
1529
|
-
const a =
|
|
1538
|
+
const a = $.get();
|
|
1530
1539
|
try {
|
|
1531
1540
|
return await a.getPeers();
|
|
1532
1541
|
} finally {
|
|
@@ -1534,55 +1543,55 @@ async function re() {
|
|
|
1534
1543
|
}
|
|
1535
1544
|
}
|
|
1536
1545
|
async function dt(a) {
|
|
1537
|
-
if (!
|
|
1546
|
+
if (!r.token)
|
|
1538
1547
|
throw new Error("Not authenticated");
|
|
1539
1548
|
return await (await fetch(`${h}/v1/admin/devices`, {
|
|
1540
1549
|
method: "POST",
|
|
1541
1550
|
body: JSON.stringify(a),
|
|
1542
1551
|
headers: {
|
|
1543
1552
|
"Content-Type": "application/json",
|
|
1544
|
-
Authorization: "Bearer " +
|
|
1553
|
+
Authorization: "Bearer " + r.token
|
|
1545
1554
|
}
|
|
1546
1555
|
})).json();
|
|
1547
1556
|
}
|
|
1548
1557
|
async function ht(a, e) {
|
|
1549
|
-
if (!
|
|
1558
|
+
if (!r.token)
|
|
1550
1559
|
throw new Error("Not authenticated");
|
|
1551
1560
|
return await (await fetch(`${h}/v1/admin/devices/${a}`, {
|
|
1552
1561
|
method: "PATCH",
|
|
1553
1562
|
body: JSON.stringify(e),
|
|
1554
1563
|
headers: {
|
|
1555
1564
|
"Content-Type": "application/json",
|
|
1556
|
-
Authorization: "Bearer " +
|
|
1565
|
+
Authorization: "Bearer " + r.token
|
|
1557
1566
|
}
|
|
1558
1567
|
})).json();
|
|
1559
1568
|
}
|
|
1560
1569
|
async function lt() {
|
|
1561
|
-
if (!
|
|
1570
|
+
if (!r.token)
|
|
1562
1571
|
throw new Error("Not authenticated");
|
|
1563
1572
|
return (await (await fetch(`${h}/v1/admin/device-details/query`, {
|
|
1564
1573
|
method: "POST",
|
|
1565
1574
|
body: JSON.stringify({ enabled: !0, type: "default" }),
|
|
1566
1575
|
headers: {
|
|
1567
1576
|
"Content-Type": "application/json",
|
|
1568
|
-
Authorization: "Bearer " +
|
|
1577
|
+
Authorization: "Bearer " + r.token
|
|
1569
1578
|
}
|
|
1570
1579
|
})).json()).items;
|
|
1571
1580
|
}
|
|
1572
1581
|
async function ut(a) {
|
|
1573
|
-
if (!
|
|
1582
|
+
if (!r.token)
|
|
1574
1583
|
throw new Error("Not authenticated");
|
|
1575
1584
|
return (await (await fetch(`${h}/v1/admin/devices/query`, {
|
|
1576
1585
|
method: "POST",
|
|
1577
1586
|
body: JSON.stringify(a),
|
|
1578
1587
|
headers: {
|
|
1579
1588
|
"Content-Type": "application/json",
|
|
1580
|
-
Authorization: "Bearer " +
|
|
1589
|
+
Authorization: "Bearer " + r.token
|
|
1581
1590
|
}
|
|
1582
1591
|
})).json()).items;
|
|
1583
1592
|
}
|
|
1584
1593
|
async function mt(a) {
|
|
1585
|
-
if (!
|
|
1594
|
+
if (!r.token)
|
|
1586
1595
|
throw new Error("Not authenticated");
|
|
1587
1596
|
return await (await fetch(
|
|
1588
1597
|
`${h}/v1/admin/devices/${a}/disable`,
|
|
@@ -1590,7 +1599,7 @@ async function mt(a) {
|
|
|
1590
1599
|
method: "POST",
|
|
1591
1600
|
headers: {
|
|
1592
1601
|
"Content-Type": "application/json",
|
|
1593
|
-
Authorization: "Bearer " +
|
|
1602
|
+
Authorization: "Bearer " + r.token
|
|
1594
1603
|
}
|
|
1595
1604
|
}
|
|
1596
1605
|
)).json();
|
|
@@ -1609,7 +1618,7 @@ class S extends Y {
|
|
|
1609
1618
|
}),
|
|
1610
1619
|
headers: {
|
|
1611
1620
|
"Content-Type": "application/json",
|
|
1612
|
-
Authorization: "Bearer " +
|
|
1621
|
+
Authorization: "Bearer " + r.token
|
|
1613
1622
|
}
|
|
1614
1623
|
}
|
|
1615
1624
|
)).json()).items;
|
|
@@ -1626,7 +1635,7 @@ class S extends Y {
|
|
|
1626
1635
|
method: "GET",
|
|
1627
1636
|
headers: {
|
|
1628
1637
|
"Content-Type": "application/json",
|
|
1629
|
-
Authorization: "Bearer " +
|
|
1638
|
+
Authorization: "Bearer " + r.token
|
|
1630
1639
|
}
|
|
1631
1640
|
});
|
|
1632
1641
|
const n = await t.json();
|
|
@@ -1641,7 +1650,7 @@ class S extends Y {
|
|
|
1641
1650
|
method: "GET",
|
|
1642
1651
|
headers: {
|
|
1643
1652
|
"Content-Type": "application/json",
|
|
1644
|
-
Authorization: "Bearer " +
|
|
1653
|
+
Authorization: "Bearer " + r.token
|
|
1645
1654
|
}
|
|
1646
1655
|
}
|
|
1647
1656
|
), (await t.json()).document;
|
|
@@ -1658,7 +1667,7 @@ class S extends Y {
|
|
|
1658
1667
|
method: "GET",
|
|
1659
1668
|
headers: {
|
|
1660
1669
|
"Content-Type": "application/json",
|
|
1661
|
-
Authorization: "Bearer " +
|
|
1670
|
+
Authorization: "Bearer " + r.token
|
|
1662
1671
|
}
|
|
1663
1672
|
})).json();
|
|
1664
1673
|
return (n = t == null ? void 0 : t.state) == null ? void 0 : n.agentVersion;
|
|
@@ -1671,7 +1680,7 @@ class S extends Y {
|
|
|
1671
1680
|
}),
|
|
1672
1681
|
headers: {
|
|
1673
1682
|
"Content-Type": "application/json",
|
|
1674
|
-
Authorization: "Bearer " +
|
|
1683
|
+
Authorization: "Bearer " + r.token
|
|
1675
1684
|
}
|
|
1676
1685
|
})).json()).fileUrls;
|
|
1677
1686
|
}
|
|
@@ -1712,7 +1721,7 @@ class S extends Y {
|
|
|
1712
1721
|
const w = await this.getRemoteDevicePeerId(c);
|
|
1713
1722
|
this.assertNotCancelled(d);
|
|
1714
1723
|
let v;
|
|
1715
|
-
for (let
|
|
1724
|
+
for (let j = 0; j < i && (v = await c.connect(w), !v); j++)
|
|
1716
1725
|
b(100), this.assertNotCancelled(d);
|
|
1717
1726
|
if (!v)
|
|
1718
1727
|
throw new Error(
|
|
@@ -1782,7 +1791,7 @@ class S extends Y {
|
|
|
1782
1791
|
throw new Error(`Realtime connection hasn't been started for ${this.id}`);
|
|
1783
1792
|
}
|
|
1784
1793
|
async isInRealtimeSession() {
|
|
1785
|
-
const e = await
|
|
1794
|
+
const e = await oe(), t = await re(), n = e.find((i) => i.deviceId === this.id);
|
|
1786
1795
|
return n ? t[n.id].length > 0 : !1;
|
|
1787
1796
|
}
|
|
1788
1797
|
async getAvailableCommands() {
|
|
@@ -1792,7 +1801,7 @@ class S extends Y {
|
|
|
1792
1801
|
method: "GET",
|
|
1793
1802
|
headers: {
|
|
1794
1803
|
"Content-Type": "application/json",
|
|
1795
|
-
Authorization: "Bearer " +
|
|
1804
|
+
Authorization: "Bearer " + r.token
|
|
1796
1805
|
}
|
|
1797
1806
|
}
|
|
1798
1807
|
)).json()).items.map((n) => ({
|
|
@@ -1830,11 +1839,11 @@ class S extends Y {
|
|
|
1830
1839
|
deviceId: this.id,
|
|
1831
1840
|
command: c.command,
|
|
1832
1841
|
parameter: y,
|
|
1833
|
-
userId: (w =
|
|
1842
|
+
userId: (w = r.currentUser) == null ? void 0 : w.id
|
|
1834
1843
|
}),
|
|
1835
1844
|
headers: {
|
|
1836
1845
|
"Content-Type": "application/json",
|
|
1837
|
-
Authorization: "Bearer " +
|
|
1846
|
+
Authorization: "Bearer " + r.token
|
|
1838
1847
|
}
|
|
1839
1848
|
});
|
|
1840
1849
|
}
|
|
@@ -1843,7 +1852,7 @@ class S extends Y {
|
|
|
1843
1852
|
method: "GET",
|
|
1844
1853
|
headers: {
|
|
1845
1854
|
"Content-Type": "application/json",
|
|
1846
|
-
Authorization: "Bearer " +
|
|
1855
|
+
Authorization: "Bearer " + r.token
|
|
1847
1856
|
}
|
|
1848
1857
|
});
|
|
1849
1858
|
}
|
|
@@ -1857,7 +1866,7 @@ class S extends Y {
|
|
|
1857
1866
|
}),
|
|
1858
1867
|
headers: {
|
|
1859
1868
|
"Content-Type": "application/json",
|
|
1860
|
-
Authorization: "Bearer " +
|
|
1869
|
+
Authorization: "Bearer " + r.token
|
|
1861
1870
|
}
|
|
1862
1871
|
})).json();
|
|
1863
1872
|
return new He(n);
|
|
@@ -1882,7 +1891,7 @@ class S extends Y {
|
|
|
1882
1891
|
}),
|
|
1883
1892
|
headers: {
|
|
1884
1893
|
"Content-Type": "application/json",
|
|
1885
|
-
Authorization: "Bearer " +
|
|
1894
|
+
Authorization: "Bearer " + r.token
|
|
1886
1895
|
}
|
|
1887
1896
|
}
|
|
1888
1897
|
), n = [], i = [];
|
|
@@ -1905,7 +1914,7 @@ class S extends Y {
|
|
|
1905
1914
|
}),
|
|
1906
1915
|
headers: {
|
|
1907
1916
|
"Content-Type": "application/json",
|
|
1908
|
-
Authorization: "Bearer " +
|
|
1917
|
+
Authorization: "Bearer " + r.token
|
|
1909
1918
|
}
|
|
1910
1919
|
}
|
|
1911
1920
|
)).json();
|
|
@@ -1922,13 +1931,13 @@ class S extends Y {
|
|
|
1922
1931
|
}),
|
|
1923
1932
|
headers: {
|
|
1924
1933
|
"Content-Type": "application/json",
|
|
1925
|
-
Authorization: "Bearer " +
|
|
1934
|
+
Authorization: "Bearer " + r.token
|
|
1926
1935
|
}
|
|
1927
1936
|
}
|
|
1928
1937
|
)).json();
|
|
1929
1938
|
}
|
|
1930
1939
|
async getAnnotationCount(e, t) {
|
|
1931
|
-
return await
|
|
1940
|
+
return await M({ ...e, deviceIds: [this.id] }, t);
|
|
1932
1941
|
}
|
|
1933
1942
|
async getAnnotationCountByIntervals(e, t, n) {
|
|
1934
1943
|
return await ae(
|
|
@@ -1937,9 +1946,9 @@ class S extends Y {
|
|
|
1937
1946
|
n
|
|
1938
1947
|
);
|
|
1939
1948
|
}
|
|
1940
|
-
async eventsCounter(e, t, n, i,
|
|
1949
|
+
async eventsCounter(e, t, n, i, o) {
|
|
1941
1950
|
return await ne(e, t, n, i, {
|
|
1942
|
-
...
|
|
1951
|
+
...o,
|
|
1943
1952
|
deviceIds: [this.id]
|
|
1944
1953
|
});
|
|
1945
1954
|
}
|
|
@@ -1959,12 +1968,12 @@ class ft extends Y {
|
|
|
1959
1968
|
async getLatestTelemetry() {
|
|
1960
1969
|
this.telemetryStreamActive || this.subscribeToTelemetry();
|
|
1961
1970
|
const t = this.streamTelemetry;
|
|
1962
|
-
return Object.entries(t).map(([i,
|
|
1971
|
+
return Object.entries(t).map(([i, o]) => ({
|
|
1963
1972
|
deviceId: this.id,
|
|
1964
1973
|
streamName: i,
|
|
1965
1974
|
streamType: "json",
|
|
1966
|
-
currentValue:
|
|
1967
|
-
currentValueTime:
|
|
1975
|
+
currentValue: o,
|
|
1976
|
+
currentValueTime: o.timestamp,
|
|
1968
1977
|
tags: {}
|
|
1969
1978
|
}));
|
|
1970
1979
|
}
|
|
@@ -1981,15 +1990,15 @@ class ft extends Y {
|
|
|
1981
1990
|
}), n.addEventListener("readystatechange", (i) => {
|
|
1982
1991
|
n.readyState === XMLHttpRequest.DONE && this.handleXHRError("closed");
|
|
1983
1992
|
}), n.addEventListener("progress", (i) => {
|
|
1984
|
-
const
|
|
1985
|
-
t =
|
|
1993
|
+
const o = i.loaded, c = o - t;
|
|
1994
|
+
t = o, n.responseText.substr(-c).split(`
|
|
1986
1995
|
`).forEach((m) => {
|
|
1987
1996
|
var w;
|
|
1988
1997
|
if (m.length > 0) {
|
|
1989
1998
|
const v = JSON.parse(m);
|
|
1990
1999
|
if ((w = v.result) != null && w.datapoint) {
|
|
1991
|
-
const C = v.result.datapoint,
|
|
1992
|
-
delete C.stream, this.streamTelemetry[
|
|
2000
|
+
const C = v.result.datapoint, j = C.stream;
|
|
2001
|
+
delete C.stream, this.streamTelemetry[j] = C;
|
|
1993
2002
|
}
|
|
1994
2003
|
}
|
|
1995
2004
|
});
|
|
@@ -2012,7 +2021,7 @@ class ft extends Y {
|
|
|
2012
2021
|
this.rtcClient && console.warn(
|
|
2013
2022
|
"overwriting existing rtcClient due to missing connectionMonitorInterval"
|
|
2014
2023
|
);
|
|
2015
|
-
const n = new
|
|
2024
|
+
const n = new A({
|
|
2016
2025
|
lanOnlyMode: !0,
|
|
2017
2026
|
receive: this.handleMessage,
|
|
2018
2027
|
sessionType: t
|
|
@@ -2051,11 +2060,11 @@ class ft extends Y {
|
|
|
2051
2060
|
if (t)
|
|
2052
2061
|
throw new Error(`Realtime connection hasn't been started for ${this.id}`);
|
|
2053
2062
|
}
|
|
2054
|
-
async sendCommand(t, n, i,
|
|
2063
|
+
async sendCommand(t, n, i, o) {
|
|
2055
2064
|
const c = {
|
|
2056
2065
|
value: n,
|
|
2057
2066
|
scrubberTime: (i || /* @__PURE__ */ new Date()).toISOString(),
|
|
2058
|
-
meta:
|
|
2067
|
+
meta: o
|
|
2059
2068
|
};
|
|
2060
2069
|
return await fetch(`${this.peerUrl}/v1/enqueue-command`, {
|
|
2061
2070
|
method: "POST",
|
|
@@ -2070,42 +2079,42 @@ class ft extends Y {
|
|
|
2070
2079
|
}
|
|
2071
2080
|
}
|
|
2072
2081
|
async function wt(a, e) {
|
|
2073
|
-
if (!
|
|
2082
|
+
if (!r.token)
|
|
2074
2083
|
throw new Error("Not authenticated");
|
|
2075
2084
|
return await (await fetch(`${h}/v1/admin/devices/${a}`, {
|
|
2076
2085
|
method: "PATCH",
|
|
2077
2086
|
body: JSON.stringify({ fleetId: e }),
|
|
2078
2087
|
headers: {
|
|
2079
2088
|
"Content-Type": "application/json",
|
|
2080
|
-
Authorization: "Bearer " +
|
|
2089
|
+
Authorization: "Bearer " + r.token
|
|
2081
2090
|
}
|
|
2082
2091
|
})).json();
|
|
2083
2092
|
}
|
|
2084
2093
|
async function pt(a) {
|
|
2085
|
-
if (!
|
|
2094
|
+
if (!r.token)
|
|
2086
2095
|
throw new Error("Not authenticated");
|
|
2087
2096
|
return (await (await fetch(`${h}/v1/queries/queries`, {
|
|
2088
2097
|
method: "POST",
|
|
2089
2098
|
body: JSON.stringify(a),
|
|
2090
2099
|
headers: {
|
|
2091
2100
|
"Content-Type": "application/json",
|
|
2092
|
-
Authorization: "Bearer " +
|
|
2101
|
+
Authorization: "Bearer " + r.token
|
|
2093
2102
|
}
|
|
2094
2103
|
})).json()).aggregates;
|
|
2095
2104
|
}
|
|
2096
2105
|
async function yt(a) {
|
|
2097
|
-
if (!
|
|
2106
|
+
if (!r.token)
|
|
2098
2107
|
throw new Error("Not authenticated");
|
|
2099
2108
|
await fetch(`${h}/v1/admin/fleets/${a}`, {
|
|
2100
2109
|
method: "DELETE",
|
|
2101
2110
|
headers: {
|
|
2102
2111
|
"Content-Type": "application/json",
|
|
2103
|
-
Authorization: "Bearer " +
|
|
2112
|
+
Authorization: "Bearer " + r.token
|
|
2104
2113
|
}
|
|
2105
2114
|
});
|
|
2106
2115
|
}
|
|
2107
2116
|
async function gt() {
|
|
2108
|
-
if (!
|
|
2117
|
+
if (!r.token)
|
|
2109
2118
|
throw new Error("Not authenticated");
|
|
2110
2119
|
return (await (await fetch(
|
|
2111
2120
|
`${h}/v1/queries/analytics/streams`,
|
|
@@ -2113,13 +2122,13 @@ async function gt() {
|
|
|
2113
2122
|
method: "GET",
|
|
2114
2123
|
headers: {
|
|
2115
2124
|
"Content-Type": "application/json",
|
|
2116
|
-
Authorization: "Bearer " +
|
|
2125
|
+
Authorization: "Bearer " + r.token
|
|
2117
2126
|
}
|
|
2118
2127
|
}
|
|
2119
2128
|
)).json()).items;
|
|
2120
2129
|
}
|
|
2121
2130
|
async function vt() {
|
|
2122
|
-
if (!
|
|
2131
|
+
if (!r.token)
|
|
2123
2132
|
throw new Error("Not authenticated");
|
|
2124
2133
|
return (await (await fetch(
|
|
2125
2134
|
`${h}/v1/admin/analytics-modules`,
|
|
@@ -2127,39 +2136,39 @@ async function vt() {
|
|
|
2127
2136
|
method: "GET",
|
|
2128
2137
|
headers: {
|
|
2129
2138
|
"Content-Type": "application/json",
|
|
2130
|
-
Authorization: "Bearer " +
|
|
2139
|
+
Authorization: "Bearer " + r.token
|
|
2131
2140
|
}
|
|
2132
2141
|
}
|
|
2133
2142
|
)).json()).items;
|
|
2134
2143
|
}
|
|
2135
2144
|
async function Tt(a) {
|
|
2136
|
-
if (!
|
|
2145
|
+
if (!r.token)
|
|
2137
2146
|
throw new Error("Not authenticated");
|
|
2138
2147
|
return await (await fetch(`${h}/v1/queries/analytics/rows`, {
|
|
2139
2148
|
method: "POST",
|
|
2140
2149
|
body: JSON.stringify(a),
|
|
2141
2150
|
headers: {
|
|
2142
2151
|
"Content-Type": "application/json",
|
|
2143
|
-
Authorization: "Bearer " +
|
|
2152
|
+
Authorization: "Bearer " + r.token
|
|
2144
2153
|
}
|
|
2145
2154
|
})).json();
|
|
2146
2155
|
}
|
|
2147
2156
|
async function se(a) {
|
|
2148
|
-
if (!
|
|
2157
|
+
if (!r.token)
|
|
2149
2158
|
throw new Error("Not authenticated");
|
|
2150
2159
|
return (await (await fetch(`${h}/v1/admin/devices/query`, {
|
|
2151
2160
|
method: "POST",
|
|
2152
2161
|
body: JSON.stringify(a),
|
|
2153
2162
|
headers: {
|
|
2154
2163
|
"Content-Type": "application/json",
|
|
2155
|
-
Authorization: "Bearer " +
|
|
2164
|
+
Authorization: "Bearer " + r.token
|
|
2156
2165
|
}
|
|
2157
2166
|
})).json()).items.map(
|
|
2158
2167
|
(n) => new S(n.id, n.name, n.organizationId, n.tags)
|
|
2159
2168
|
);
|
|
2160
2169
|
}
|
|
2161
2170
|
async function Ct() {
|
|
2162
|
-
if (!
|
|
2171
|
+
if (!r.token)
|
|
2163
2172
|
throw new Error("Not authenticated");
|
|
2164
2173
|
let a = new URLSearchParams("");
|
|
2165
2174
|
typeof window < "u" && window.location && (a = new URLSearchParams(window.location.search));
|
|
@@ -2171,7 +2180,7 @@ async function Ct() {
|
|
|
2171
2180
|
{
|
|
2172
2181
|
headers: {
|
|
2173
2182
|
"Content-Type": "application/json",
|
|
2174
|
-
Authorization: "Bearer " +
|
|
2183
|
+
Authorization: "Bearer " + r.token
|
|
2175
2184
|
}
|
|
2176
2185
|
}
|
|
2177
2186
|
), { tagKey: n, tagValue: i } = await t.json();
|
|
@@ -2182,39 +2191,39 @@ async function Ct() {
|
|
|
2182
2191
|
});
|
|
2183
2192
|
}
|
|
2184
2193
|
async function St(a) {
|
|
2185
|
-
if (!
|
|
2194
|
+
if (!r.token)
|
|
2186
2195
|
throw new Error("Not authenticated");
|
|
2187
2196
|
const t = await (await fetch(`${h}/v1/admin/devices/${a}`, {
|
|
2188
2197
|
method: "GET",
|
|
2189
2198
|
headers: {
|
|
2190
2199
|
"Content-Type": "application/json",
|
|
2191
|
-
Authorization: "Bearer " +
|
|
2200
|
+
Authorization: "Bearer " + r.token
|
|
2192
2201
|
}
|
|
2193
2202
|
})).json(), n = t.name;
|
|
2194
2203
|
return new S(a, n, t.organizationId, t.tags);
|
|
2195
2204
|
}
|
|
2196
|
-
async function
|
|
2197
|
-
if (!
|
|
2205
|
+
async function B() {
|
|
2206
|
+
if (!r.token)
|
|
2198
2207
|
throw new Error("Not authenticated");
|
|
2199
2208
|
const e = await (await fetch(`${h}/v1/admin/device-details/query`, {
|
|
2200
2209
|
method: "POST",
|
|
2201
2210
|
body: JSON.stringify({ enabled: !0, type: "default" }),
|
|
2202
2211
|
headers: {
|
|
2203
2212
|
"Content-Type": "application/json",
|
|
2204
|
-
Authorization: "Bearer " +
|
|
2213
|
+
Authorization: "Bearer " + r.token
|
|
2205
2214
|
}
|
|
2206
2215
|
})).json();
|
|
2207
2216
|
return e.items, e.items.map(
|
|
2208
2217
|
(t) => new S(
|
|
2209
2218
|
t.id,
|
|
2210
2219
|
t.name,
|
|
2211
|
-
f(
|
|
2220
|
+
f(r.currentOrganization),
|
|
2212
2221
|
t.tags
|
|
2213
2222
|
)
|
|
2214
2223
|
);
|
|
2215
2224
|
}
|
|
2216
2225
|
async function Et(a) {
|
|
2217
|
-
if (!
|
|
2226
|
+
if (!r.token)
|
|
2218
2227
|
throw new Error("Not authenticated");
|
|
2219
2228
|
return (await (await fetch(
|
|
2220
2229
|
`${h}/v1/admin/events/query/id=${a}`,
|
|
@@ -2222,7 +2231,7 @@ async function Et(a) {
|
|
|
2222
2231
|
method: "GET",
|
|
2223
2232
|
headers: {
|
|
2224
2233
|
"Content-Type": "application/json",
|
|
2225
|
-
Authorization: "Bearer " +
|
|
2234
|
+
Authorization: "Bearer " + r.token
|
|
2226
2235
|
}
|
|
2227
2236
|
}
|
|
2228
2237
|
)).json()).items;
|
|
@@ -2235,7 +2244,7 @@ async function kt(a) {
|
|
|
2235
2244
|
}),
|
|
2236
2245
|
headers: {
|
|
2237
2246
|
"Content-Type": "application/json",
|
|
2238
|
-
Authorization: "Bearer " +
|
|
2247
|
+
Authorization: "Bearer " + r.token
|
|
2239
2248
|
}
|
|
2240
2249
|
})).json();
|
|
2241
2250
|
if (t.fileUrls.length === 0)
|
|
@@ -2243,29 +2252,29 @@ async function kt(a) {
|
|
|
2243
2252
|
return t.fileUrls[0];
|
|
2244
2253
|
}
|
|
2245
2254
|
async function Ot(a) {
|
|
2246
|
-
if (!
|
|
2255
|
+
if (!r.token)
|
|
2247
2256
|
throw new Error("Not authenticated");
|
|
2248
2257
|
return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
|
|
2249
2258
|
method: "GET",
|
|
2250
2259
|
headers: {
|
|
2251
2260
|
"Content-Type": "application/json",
|
|
2252
|
-
Authorization: "Bearer " +
|
|
2261
|
+
Authorization: "Bearer " + r.token
|
|
2253
2262
|
}
|
|
2254
2263
|
})).json();
|
|
2255
2264
|
}
|
|
2256
2265
|
async function Rt(a) {
|
|
2257
|
-
if (!
|
|
2266
|
+
if (!r.token)
|
|
2258
2267
|
throw new Error("Not authenticated");
|
|
2259
2268
|
return (await (await fetch(`${h}/v1/admin/fleets/${a}/devices`, {
|
|
2260
2269
|
method: "GET",
|
|
2261
2270
|
headers: {
|
|
2262
2271
|
"Content-Type": "application/json",
|
|
2263
|
-
Authorization: "Bearer " +
|
|
2272
|
+
Authorization: "Bearer " + r.token
|
|
2264
2273
|
}
|
|
2265
2274
|
})).json()).items;
|
|
2266
2275
|
}
|
|
2267
|
-
async function
|
|
2268
|
-
if (!
|
|
2276
|
+
async function At() {
|
|
2277
|
+
if (!r.token)
|
|
2269
2278
|
throw new Error("Not authenticated");
|
|
2270
2279
|
return (await (await fetch(
|
|
2271
2280
|
`${h}/v1/admin/intervention-requests`,
|
|
@@ -2273,12 +2282,12 @@ async function bt() {
|
|
|
2273
2282
|
method: "GET",
|
|
2274
2283
|
headers: {
|
|
2275
2284
|
"Content-Type": "application/json",
|
|
2276
|
-
Authorization: "Bearer " +
|
|
2285
|
+
Authorization: "Bearer " + r.token
|
|
2277
2286
|
}
|
|
2278
2287
|
}
|
|
2279
2288
|
)).json()).items;
|
|
2280
2289
|
}
|
|
2281
|
-
async function
|
|
2290
|
+
async function bt(...a) {
|
|
2282
2291
|
const e = a.flat().filter((i) => !!i);
|
|
2283
2292
|
return e.length === 0 ? [] : (await (await fetch(
|
|
2284
2293
|
`${h}/v1/queries/stream-current-value`,
|
|
@@ -2289,52 +2298,52 @@ async function At(...a) {
|
|
|
2289
2298
|
}),
|
|
2290
2299
|
headers: {
|
|
2291
2300
|
"Content-Type": "application/json",
|
|
2292
|
-
Authorization: "Bearer " +
|
|
2301
|
+
Authorization: "Bearer " + r.token
|
|
2293
2302
|
}
|
|
2294
2303
|
}
|
|
2295
2304
|
)).json()).items;
|
|
2296
2305
|
}
|
|
2297
2306
|
async function jt() {
|
|
2298
|
-
if (!
|
|
2307
|
+
if (!r.token)
|
|
2299
2308
|
throw new Error("Not authenticated");
|
|
2300
2309
|
const t = (await (await fetch(`${h}/v1/queries/online-devices`, {
|
|
2301
2310
|
method: "GET",
|
|
2302
2311
|
headers: {
|
|
2303
2312
|
"Content-Type": "application/json",
|
|
2304
|
-
Authorization: "Bearer " +
|
|
2313
|
+
Authorization: "Bearer " + r.token
|
|
2305
2314
|
}
|
|
2306
2315
|
})).json()).items;
|
|
2307
|
-
return (await
|
|
2316
|
+
return (await B()).filter((i) => t.includes(i.id));
|
|
2308
2317
|
}
|
|
2309
|
-
async function
|
|
2310
|
-
if (!
|
|
2318
|
+
async function Nt() {
|
|
2319
|
+
if (!r.token)
|
|
2311
2320
|
throw new Error("Not authenticated");
|
|
2312
2321
|
const t = (await (await fetch(`${h}/v1/signaling/peers`, {
|
|
2313
2322
|
method: "GET",
|
|
2314
2323
|
headers: {
|
|
2315
2324
|
"Content-Type": "application/json",
|
|
2316
|
-
Authorization: "Bearer " +
|
|
2325
|
+
Authorization: "Bearer " + r.token
|
|
2317
2326
|
}
|
|
2318
2327
|
})).json()).items.map(
|
|
2319
2328
|
(i) => i.deviceId
|
|
2320
2329
|
);
|
|
2321
|
-
return (await
|
|
2330
|
+
return (await B()).filter((i) => t.includes(i.id));
|
|
2322
2331
|
}
|
|
2323
|
-
async function
|
|
2324
|
-
if (!
|
|
2332
|
+
async function Dt() {
|
|
2333
|
+
if (!r.token)
|
|
2325
2334
|
throw new Error("Not authenticated");
|
|
2326
2335
|
return (await (await fetch(`${h}/v1/admin/streams`, {
|
|
2327
2336
|
method: "GET",
|
|
2328
2337
|
headers: {
|
|
2329
2338
|
"Content-Type": "application/json",
|
|
2330
|
-
Authorization: "Bearer " +
|
|
2339
|
+
Authorization: "Bearer " + r.token
|
|
2331
2340
|
}
|
|
2332
2341
|
})).json()).items.filter(
|
|
2333
2342
|
(t) => t.enabled
|
|
2334
2343
|
);
|
|
2335
2344
|
}
|
|
2336
2345
|
async function Pt(a) {
|
|
2337
|
-
if (!
|
|
2346
|
+
if (!r.token)
|
|
2338
2347
|
throw new Error("Not authenticated");
|
|
2339
2348
|
return await (await fetch(
|
|
2340
2349
|
`${h}/v1/queries/analytics/task-report-rows`,
|
|
@@ -2343,13 +2352,13 @@ async function Pt(a) {
|
|
|
2343
2352
|
body: JSON.stringify(a),
|
|
2344
2353
|
headers: {
|
|
2345
2354
|
"Content-Type": "application/json",
|
|
2346
|
-
Authorization: "Bearer " +
|
|
2355
|
+
Authorization: "Bearer " + r.token
|
|
2347
2356
|
}
|
|
2348
2357
|
}
|
|
2349
2358
|
)).json();
|
|
2350
2359
|
}
|
|
2351
2360
|
async function Lt() {
|
|
2352
|
-
if (!
|
|
2361
|
+
if (!r.token)
|
|
2353
2362
|
throw new Error("Not authenticated");
|
|
2354
2363
|
return (await (await fetch(
|
|
2355
2364
|
`${h}/v1/queries/analytics/task-reports`,
|
|
@@ -2357,36 +2366,36 @@ async function Lt() {
|
|
|
2357
2366
|
method: "GET",
|
|
2358
2367
|
headers: {
|
|
2359
2368
|
"Content-Type": "application/json",
|
|
2360
|
-
Authorization: "Bearer " +
|
|
2369
|
+
Authorization: "Bearer " + r.token
|
|
2361
2370
|
}
|
|
2362
2371
|
}
|
|
2363
2372
|
)).json()).items;
|
|
2364
2373
|
}
|
|
2365
2374
|
async function It() {
|
|
2366
|
-
if (!
|
|
2375
|
+
if (!r.token)
|
|
2367
2376
|
throw new Error("Not authenticated");
|
|
2368
2377
|
return (await (await fetch(`${h}/v1/admin/fleets`, {
|
|
2369
2378
|
method: "GET",
|
|
2370
2379
|
headers: {
|
|
2371
2380
|
"Content-Type": "application/json",
|
|
2372
|
-
Authorization: "Bearer " +
|
|
2381
|
+
Authorization: "Bearer " + r.token
|
|
2373
2382
|
}
|
|
2374
2383
|
})).json()).items;
|
|
2375
2384
|
}
|
|
2376
|
-
async function
|
|
2377
|
-
if (!
|
|
2385
|
+
async function _t(a, e) {
|
|
2386
|
+
if (!r.token)
|
|
2378
2387
|
throw new Error("Not authenticated");
|
|
2379
2388
|
return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
|
|
2380
2389
|
method: "PATCH",
|
|
2381
2390
|
body: JSON.stringify(e),
|
|
2382
2391
|
headers: {
|
|
2383
2392
|
"Content-Type": "application/json",
|
|
2384
|
-
Authorization: "Bearer " +
|
|
2393
|
+
Authorization: "Bearer " + r.token
|
|
2385
2394
|
}
|
|
2386
2395
|
})).json();
|
|
2387
2396
|
}
|
|
2388
|
-
async function
|
|
2389
|
-
if (!
|
|
2397
|
+
async function $t(a) {
|
|
2398
|
+
if (!r.token)
|
|
2390
2399
|
throw new Error("Not authenticated");
|
|
2391
2400
|
return await (await fetch(
|
|
2392
2401
|
`${h}/v1/admin/streams/${a.id}`,
|
|
@@ -2395,60 +2404,60 @@ async function zt(a) {
|
|
|
2395
2404
|
body: JSON.stringify(a),
|
|
2396
2405
|
headers: {
|
|
2397
2406
|
"Content-Type": "application/json",
|
|
2398
|
-
Authorization: "Bearer " +
|
|
2407
|
+
Authorization: "Bearer " + r.token
|
|
2399
2408
|
}
|
|
2400
2409
|
}
|
|
2401
2410
|
)).json();
|
|
2402
2411
|
}
|
|
2403
|
-
async function
|
|
2404
|
-
if (!
|
|
2412
|
+
async function zt(a) {
|
|
2413
|
+
if (!r.token)
|
|
2405
2414
|
throw new Error("Not authenticated");
|
|
2406
2415
|
return await (await fetch(`${h}/v1/admin/views/${a.id}`, {
|
|
2407
2416
|
method: "PATCH",
|
|
2408
2417
|
body: JSON.stringify(a),
|
|
2409
2418
|
headers: {
|
|
2410
2419
|
"Content-Type": "application/json",
|
|
2411
|
-
Authorization: "Bearer " +
|
|
2420
|
+
Authorization: "Bearer " + r.token
|
|
2412
2421
|
}
|
|
2413
2422
|
})).json();
|
|
2414
2423
|
}
|
|
2415
2424
|
async function Mt(a) {
|
|
2416
|
-
if (!
|
|
2425
|
+
if (!r.token)
|
|
2417
2426
|
throw new Error("Not authenticated");
|
|
2418
2427
|
return await (await fetch(`${h}/v1/queries/analytics`, {
|
|
2419
2428
|
method: "POST",
|
|
2420
2429
|
body: JSON.stringify(a),
|
|
2421
2430
|
headers: {
|
|
2422
2431
|
"Content-Type": "application/json",
|
|
2423
|
-
Authorization: "Bearer " +
|
|
2432
|
+
Authorization: "Bearer " + r.token
|
|
2424
2433
|
}
|
|
2425
2434
|
})).json();
|
|
2426
2435
|
}
|
|
2427
|
-
async function
|
|
2428
|
-
if (!
|
|
2436
|
+
async function Bt(a) {
|
|
2437
|
+
if (!r.token)
|
|
2429
2438
|
throw new Error("Not authenticated");
|
|
2430
2439
|
return await (await fetch(`${h}/v1/admin/fleets`, {
|
|
2431
2440
|
method: "POST",
|
|
2432
2441
|
body: JSON.stringify(a),
|
|
2433
2442
|
headers: {
|
|
2434
2443
|
"Content-Type": "application/json",
|
|
2435
|
-
Authorization: "Bearer " +
|
|
2444
|
+
Authorization: "Bearer " + r.token
|
|
2436
2445
|
}
|
|
2437
2446
|
})).json();
|
|
2438
2447
|
}
|
|
2439
|
-
async function
|
|
2440
|
-
if (!
|
|
2448
|
+
async function qt() {
|
|
2449
|
+
if (!r.token)
|
|
2441
2450
|
throw new Error("Not authenticated");
|
|
2442
2451
|
return (await (await fetch(`${h}/v1/admin/event-trigger-groups`, {
|
|
2443
2452
|
method: "GET",
|
|
2444
2453
|
headers: {
|
|
2445
2454
|
"Content-Type": "application/json",
|
|
2446
|
-
Authorization: "Bearer " +
|
|
2455
|
+
Authorization: "Bearer " + r.token
|
|
2447
2456
|
}
|
|
2448
2457
|
})).json()).items;
|
|
2449
2458
|
}
|
|
2450
|
-
async function
|
|
2451
|
-
if (!
|
|
2459
|
+
async function xt(a) {
|
|
2460
|
+
if (!r.token)
|
|
2452
2461
|
throw new Error("Not authenticated");
|
|
2453
2462
|
return await (await fetch(
|
|
2454
2463
|
`${h}/v1/admin/event-trigger-groups/${a}`,
|
|
@@ -2456,13 +2465,13 @@ async function Ut(a) {
|
|
|
2456
2465
|
method: "GET",
|
|
2457
2466
|
headers: {
|
|
2458
2467
|
"Content-Type": "application/json",
|
|
2459
|
-
Authorization: "Bearer " +
|
|
2468
|
+
Authorization: "Bearer " + r.token
|
|
2460
2469
|
}
|
|
2461
2470
|
}
|
|
2462
2471
|
)).json();
|
|
2463
2472
|
}
|
|
2464
|
-
async function
|
|
2465
|
-
if (!
|
|
2473
|
+
async function Ut(a, e) {
|
|
2474
|
+
if (!r.token)
|
|
2466
2475
|
throw new Error("Not authenticated");
|
|
2467
2476
|
return await (await fetch(
|
|
2468
2477
|
`${h}/v1/admin/event-trigger-groups/${a}`,
|
|
@@ -2471,19 +2480,19 @@ async function _t(a, e) {
|
|
|
2471
2480
|
body: JSON.stringify(e),
|
|
2472
2481
|
headers: {
|
|
2473
2482
|
"Content-Type": "application/json",
|
|
2474
|
-
Authorization: "Bearer " +
|
|
2483
|
+
Authorization: "Bearer " + r.token
|
|
2475
2484
|
}
|
|
2476
2485
|
}
|
|
2477
2486
|
)).json();
|
|
2478
2487
|
}
|
|
2479
|
-
const
|
|
2488
|
+
const E = class {
|
|
2480
2489
|
static async setDefaultDevice(e) {
|
|
2481
|
-
|
|
2490
|
+
E.defaultDeviceId = e;
|
|
2482
2491
|
}
|
|
2483
2492
|
static async getCurrentDevice() {
|
|
2484
|
-
if (!
|
|
2493
|
+
if (!r.token)
|
|
2485
2494
|
throw new Error("Not authenticated");
|
|
2486
|
-
if (!
|
|
2495
|
+
if (!E.defaultDeviceId)
|
|
2487
2496
|
throw new Error("No known default device");
|
|
2488
2497
|
const n = (await (await fetch(
|
|
2489
2498
|
`${h}/v1/admin/device-details/query`,
|
|
@@ -2491,18 +2500,18 @@ const l = class l {
|
|
|
2491
2500
|
method: "POST",
|
|
2492
2501
|
headers: {
|
|
2493
2502
|
"Content-Type": "application/json",
|
|
2494
|
-
Authorization: "Bearer " +
|
|
2503
|
+
Authorization: "Bearer " + r.token
|
|
2495
2504
|
}
|
|
2496
2505
|
}
|
|
2497
2506
|
)).json()).items.find(
|
|
2498
|
-
(c) => c.id ===
|
|
2499
|
-
), i = n.name,
|
|
2500
|
-
|
|
2507
|
+
(c) => c.id === E.defaultDeviceId
|
|
2508
|
+
), i = n.name, o = new S(
|
|
2509
|
+
E.defaultDeviceId,
|
|
2501
2510
|
i,
|
|
2502
|
-
f(
|
|
2511
|
+
f(r.currentOrganization),
|
|
2503
2512
|
n.tags
|
|
2504
2513
|
);
|
|
2505
|
-
return
|
|
2514
|
+
return E.knownContext.push(new WeakRef(o)), o;
|
|
2506
2515
|
}
|
|
2507
2516
|
static async getPeerDevice(e) {
|
|
2508
2517
|
const t = new ft(e);
|
|
@@ -2510,29 +2519,29 @@ const l = class l {
|
|
|
2510
2519
|
}
|
|
2511
2520
|
static async getDevice(e) {
|
|
2512
2521
|
const t = await St(e);
|
|
2513
|
-
return
|
|
2522
|
+
return E.knownContext.push(new WeakRef(t)), t;
|
|
2514
2523
|
}
|
|
2515
2524
|
};
|
|
2516
|
-
|
|
2517
|
-
|
|
2525
|
+
let l = E;
|
|
2526
|
+
s(l, "defaultDeviceId"), s(l, "knownContext", []), s(l, "createFleet", Bt), s(l, "listFleets", It), s(l, "getFleet", Ot), s(l, "patchFleet", _t), s(l, "deleteFleet", yt), s(l, "addDeviceToFleet", wt), s(l, "getFleetDevices", Rt), s(l, "aggregateTelemetry", pt), s(l, "createShareLink", ee), s(l, "eventsCounter", ne), s(l, "getAnalyticStreams", gt), s(l, "getAnalyticsModules", vt), s(l, "getAnalyticsRows", Tt), s(l, "getAnnotationCount", M), s(l, "getAnnotationCountByIntervals", ae), s(l, "getCurrentGroup", Ct), s(l, "getDevices", B), s(l, "getEvent", Et), s(l, "getFileUrl", kt), s(l, "getInterventions", At), s(l, "getLatestTelemetry", bt), s(l, "getOnlineDevices", jt), s(l, "getPeers", oe), s(l, "getRealtimeDevices", Nt), s(l, "getRealtimeSessions", re), s(l, "getStreams", Dt), s(l, "getTaskReportRows", Pt), s(l, "getTaskReportTables", Lt), s(l, "getTelemetry", ie), s(l, "getViews", Z), s(l, "patchStream", $t), s(l, "patchView", zt), s(l, "queryAnalytics", Mt), s(l, "queryDevices", se), s(l, "queryEvents", z), s(l, "queryTelemetry", _), s(l, "getAllEventTriggerGroup", qt), s(l, "getEventTriggerGroup", xt), s(l, "patchEventTriggergroup", Ut);
|
|
2518
2527
|
class an {
|
|
2519
2528
|
static async set(e, t, n) {
|
|
2520
2529
|
try {
|
|
2521
2530
|
const i = await fetch(h + "/v1/admin/key-value", {
|
|
2522
2531
|
method: "POST",
|
|
2523
2532
|
body: JSON.stringify({
|
|
2524
|
-
organizationId: f(
|
|
2533
|
+
organizationId: f(r.currentUser).organizationId,
|
|
2525
2534
|
key: e,
|
|
2526
2535
|
value: t,
|
|
2527
2536
|
tags: n
|
|
2528
2537
|
}),
|
|
2529
2538
|
headers: {
|
|
2530
2539
|
"Content-Type": "application/json",
|
|
2531
|
-
Authorization: "Bearer " +
|
|
2540
|
+
Authorization: "Bearer " + r.token
|
|
2532
2541
|
}
|
|
2533
|
-
}),
|
|
2542
|
+
}), o = await i.json();
|
|
2534
2543
|
if (i.status !== 200)
|
|
2535
|
-
throw new Error(
|
|
2544
|
+
throw new Error(o.message);
|
|
2536
2545
|
} catch (i) {
|
|
2537
2546
|
throw i;
|
|
2538
2547
|
}
|
|
@@ -2545,7 +2554,7 @@ class an {
|
|
|
2545
2554
|
method: "GET",
|
|
2546
2555
|
headers: {
|
|
2547
2556
|
"Content-Type": "application/json",
|
|
2548
|
-
Authorization: "Bearer " +
|
|
2557
|
+
Authorization: "Bearer " + r.token
|
|
2549
2558
|
}
|
|
2550
2559
|
}
|
|
2551
2560
|
), n = await t.json();
|
|
@@ -2562,7 +2571,7 @@ class an {
|
|
|
2562
2571
|
method: "GET",
|
|
2563
2572
|
headers: {
|
|
2564
2573
|
"Content-Type": "application/json",
|
|
2565
|
-
Authorization: "Bearer " +
|
|
2574
|
+
Authorization: "Bearer " + r.token
|
|
2566
2575
|
}
|
|
2567
2576
|
}), t = await e.json();
|
|
2568
2577
|
if (e.status !== 200)
|
|
@@ -2580,7 +2589,7 @@ class an {
|
|
|
2580
2589
|
method: "DELETE",
|
|
2581
2590
|
headers: {
|
|
2582
2591
|
"Content-Type": "application/json",
|
|
2583
|
-
Authorization: "Bearer " +
|
|
2592
|
+
Authorization: "Bearer " + r.token
|
|
2584
2593
|
}
|
|
2585
2594
|
}
|
|
2586
2595
|
)).ok)
|
|
@@ -2599,7 +2608,7 @@ class an {
|
|
|
2599
2608
|
body: JSON.stringify({ keys: e }),
|
|
2600
2609
|
headers: {
|
|
2601
2610
|
"Content-Type": "application/json",
|
|
2602
|
-
Authorization: "Bearer " +
|
|
2611
|
+
Authorization: "Bearer " + r.token
|
|
2603
2612
|
}
|
|
2604
2613
|
}
|
|
2605
2614
|
);
|
|
@@ -2612,14 +2621,14 @@ class an {
|
|
|
2612
2621
|
}
|
|
2613
2622
|
}
|
|
2614
2623
|
function Jt(a) {
|
|
2615
|
-
return Uint8Array.from(
|
|
2624
|
+
return Uint8Array.from(V(a), (e) => e.charCodeAt(0));
|
|
2616
2625
|
}
|
|
2617
|
-
function
|
|
2626
|
+
function G() {
|
|
2618
2627
|
const { userAgent: a } = navigator;
|
|
2619
2628
|
return a ? a.includes("Firefox/") ? "Firefox" : a.includes("Edg/") ? "Edge" : a.includes("Chrome/") ? "Chrome" : a.includes("Safari/") ? "Safari" : a.includes("MSIE/") || a.includes("Trident/") ? "IE" : "Other" : "Other";
|
|
2620
2629
|
}
|
|
2621
|
-
const
|
|
2622
|
-
class
|
|
2630
|
+
const Gt = "audio-chunk";
|
|
2631
|
+
class rn {
|
|
2623
2632
|
constructor(e, t) {
|
|
2624
2633
|
s(this, "muted", !1);
|
|
2625
2634
|
s(this, "hasReceivedData", !1);
|
|
@@ -2636,12 +2645,12 @@ class on {
|
|
|
2636
2645
|
return;
|
|
2637
2646
|
this.hasReceivedData || (this.hasReceivedData = !0);
|
|
2638
2647
|
const { audioContext: n, muted: i } = this;
|
|
2639
|
-
if (!n || e.header.stream.streamType !==
|
|
2648
|
+
if (!n || e.header.stream.streamType !== Gt || i !== !1)
|
|
2640
2649
|
return;
|
|
2641
|
-
const
|
|
2650
|
+
const o = Jt(t);
|
|
2642
2651
|
try {
|
|
2643
2652
|
await n.decodeAudioData(
|
|
2644
|
-
|
|
2653
|
+
o.buffer,
|
|
2645
2654
|
this.scheduleChunk
|
|
2646
2655
|
);
|
|
2647
2656
|
} catch (d) {
|
|
@@ -2661,9 +2670,9 @@ class on {
|
|
|
2661
2670
|
const n = this.createChunk(e);
|
|
2662
2671
|
n && n.buffer && (this.isPlaying === !1 && (this.startTime = t.currentTime, this.lastChunkOffset = 0, this.isPlaying = !0), n.start(this.startTime + this.lastChunkOffset, 0, e.duration), this.lastChunkOffset += n.buffer.duration, this.chunks.push(n));
|
|
2663
2672
|
});
|
|
2664
|
-
this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i,
|
|
2665
|
-
this.receive(
|
|
2666
|
-
}),
|
|
2673
|
+
this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, o) => {
|
|
2674
|
+
this.receive(o);
|
|
2675
|
+
}), G() === "Safari" || G() === "IE" ? this.changeAudioWireFormat("wav") : this.changeAudioWireFormat("opus");
|
|
2667
2676
|
const n = window.AudioContext || window.webkitAudioContext;
|
|
2668
2677
|
this.audioContext = new n();
|
|
2669
2678
|
}
|
|
@@ -2691,67 +2700,67 @@ class on {
|
|
|
2691
2700
|
(async () => await this.device.changeStreamAudioType(t.name, e))();
|
|
2692
2701
|
}
|
|
2693
2702
|
}
|
|
2694
|
-
class
|
|
2703
|
+
class on {
|
|
2695
2704
|
static async listAccounts() {
|
|
2696
|
-
if (!
|
|
2705
|
+
if (!r.token)
|
|
2697
2706
|
throw new Error("Not authenticated");
|
|
2698
2707
|
return (await (await fetch(`${h}/v1/admin/accounts`, {
|
|
2699
2708
|
method: "GET",
|
|
2700
2709
|
headers: {
|
|
2701
2710
|
"Content-Type": "application/json",
|
|
2702
|
-
Authorization: "Bearer " +
|
|
2711
|
+
Authorization: "Bearer " + r.token
|
|
2703
2712
|
}
|
|
2704
2713
|
})).json()).items;
|
|
2705
2714
|
}
|
|
2706
2715
|
static async createAccounts(e) {
|
|
2707
|
-
if (!
|
|
2716
|
+
if (!r.token)
|
|
2708
2717
|
throw new Error("Not authenticated");
|
|
2709
2718
|
return await (await fetch(`${h}/v1/admin/accounts`, {
|
|
2710
2719
|
method: "POST",
|
|
2711
2720
|
body: JSON.stringify(e),
|
|
2712
2721
|
headers: {
|
|
2713
2722
|
"Content-Type": "application/json",
|
|
2714
|
-
Authorization: "Bearer " +
|
|
2723
|
+
Authorization: "Bearer " + r.token
|
|
2715
2724
|
}
|
|
2716
2725
|
})).json();
|
|
2717
2726
|
}
|
|
2718
2727
|
static async getAccount(e) {
|
|
2719
|
-
if (!
|
|
2728
|
+
if (!r.token)
|
|
2720
2729
|
throw new Error("Not authenticated");
|
|
2721
2730
|
return await (await fetch(`${h}/v1/admin/accounts/${e}`, {
|
|
2722
2731
|
method: "GET",
|
|
2723
2732
|
headers: {
|
|
2724
2733
|
"Content-Type": "application/json",
|
|
2725
|
-
Authorization: "Bearer " +
|
|
2734
|
+
Authorization: "Bearer " + r.token
|
|
2726
2735
|
}
|
|
2727
2736
|
})).json();
|
|
2728
2737
|
}
|
|
2729
2738
|
static async patchAccount(e, t) {
|
|
2730
|
-
if (!
|
|
2739
|
+
if (!r.token)
|
|
2731
2740
|
throw new Error("Not authenticated");
|
|
2732
2741
|
return await (await fetch(`${h}/v1/admin/accounts/${e}`, {
|
|
2733
2742
|
method: "PATCH",
|
|
2734
2743
|
body: JSON.stringify(t),
|
|
2735
2744
|
headers: {
|
|
2736
2745
|
"Content-Type": "application/json",
|
|
2737
|
-
Authorization: "Bearer " +
|
|
2746
|
+
Authorization: "Bearer " + r.token
|
|
2738
2747
|
}
|
|
2739
2748
|
})).json();
|
|
2740
2749
|
}
|
|
2741
2750
|
static async deleteAccount(e) {
|
|
2742
|
-
if (!
|
|
2751
|
+
if (!r.token)
|
|
2743
2752
|
throw new Error("Not authenticated");
|
|
2744
2753
|
if (!(await fetch(`${h}/v1/admin/accounts/${e}`, {
|
|
2745
2754
|
method: "DELETE",
|
|
2746
2755
|
headers: {
|
|
2747
2756
|
"Content-Type": "application/json",
|
|
2748
|
-
Authorization: "Bearer " +
|
|
2757
|
+
Authorization: "Bearer " + r.token
|
|
2749
2758
|
}
|
|
2750
2759
|
})).ok)
|
|
2751
2760
|
throw new Error("Unable to delete account");
|
|
2752
2761
|
}
|
|
2753
2762
|
static async getAccountTree(e) {
|
|
2754
|
-
if (!
|
|
2763
|
+
if (!r.token)
|
|
2755
2764
|
throw new Error("Not authenticated");
|
|
2756
2765
|
return await (await fetch(
|
|
2757
2766
|
`${h}/v1/admin/accounts/${e}/tree`,
|
|
@@ -2759,7 +2768,7 @@ class rn {
|
|
|
2759
2768
|
method: "GET",
|
|
2760
2769
|
headers: {
|
|
2761
2770
|
"Content-Type": "application/json",
|
|
2762
|
-
Authorization: "Bearer " +
|
|
2771
|
+
Authorization: "Bearer " + r.token
|
|
2763
2772
|
}
|
|
2764
2773
|
}
|
|
2765
2774
|
)).json();
|
|
@@ -2767,119 +2776,119 @@ class rn {
|
|
|
2767
2776
|
}
|
|
2768
2777
|
class sn {
|
|
2769
2778
|
static async listRoles() {
|
|
2770
|
-
if (!
|
|
2779
|
+
if (!r.token)
|
|
2771
2780
|
throw new Error("Not authenticated");
|
|
2772
2781
|
return (await (await fetch(`${h}/v1/admin/roles`, {
|
|
2773
2782
|
method: "GET",
|
|
2774
2783
|
headers: {
|
|
2775
2784
|
"Content-Type": "application/json",
|
|
2776
|
-
Authorization: "Bearer " +
|
|
2785
|
+
Authorization: "Bearer " + r.token
|
|
2777
2786
|
}
|
|
2778
2787
|
})).json()).items;
|
|
2779
2788
|
}
|
|
2780
2789
|
static async createRole(e) {
|
|
2781
|
-
if (!
|
|
2790
|
+
if (!r.token)
|
|
2782
2791
|
throw new Error("Not authenticated");
|
|
2783
2792
|
return await (await fetch(`${h}/v1/admin/roles`, {
|
|
2784
2793
|
method: "POST",
|
|
2785
2794
|
body: JSON.stringify(e),
|
|
2786
2795
|
headers: {
|
|
2787
2796
|
"Content-Type": "application/json",
|
|
2788
|
-
Authorization: "Bearer " +
|
|
2797
|
+
Authorization: "Bearer " + r.token
|
|
2789
2798
|
}
|
|
2790
2799
|
})).json();
|
|
2791
2800
|
}
|
|
2792
2801
|
static async getRole(e) {
|
|
2793
|
-
if (!
|
|
2802
|
+
if (!r.token)
|
|
2794
2803
|
throw new Error("Not authenticated");
|
|
2795
2804
|
return await (await fetch(`${h}/v1/admin/roles/${e}`, {
|
|
2796
2805
|
method: "GET",
|
|
2797
2806
|
headers: {
|
|
2798
2807
|
"Content-Type": "application/json",
|
|
2799
|
-
Authorization: "Bearer " +
|
|
2808
|
+
Authorization: "Bearer " + r.token
|
|
2800
2809
|
}
|
|
2801
2810
|
})).json();
|
|
2802
2811
|
}
|
|
2803
2812
|
static async patchRole(e, t) {
|
|
2804
|
-
if (!
|
|
2813
|
+
if (!r.token)
|
|
2805
2814
|
throw new Error("Not authenticated");
|
|
2806
2815
|
return await (await fetch(`${h}/v1/admin/roles/${e}`, {
|
|
2807
2816
|
method: "PATCH",
|
|
2808
2817
|
body: JSON.stringify(t),
|
|
2809
2818
|
headers: {
|
|
2810
2819
|
"Content-Type": "application/json",
|
|
2811
|
-
Authorization: "Bearer " +
|
|
2820
|
+
Authorization: "Bearer " + r.token
|
|
2812
2821
|
}
|
|
2813
2822
|
})).json();
|
|
2814
2823
|
}
|
|
2815
2824
|
static async deleteRole(e) {
|
|
2816
|
-
if (!
|
|
2825
|
+
if (!r.token)
|
|
2817
2826
|
throw new Error("Not authenticated");
|
|
2818
2827
|
await fetch(`${h}/v1/admin/roles/${e}`, {
|
|
2819
2828
|
method: "DELETE",
|
|
2820
2829
|
headers: {
|
|
2821
2830
|
"Content-Type": "application/json",
|
|
2822
|
-
Authorization: "Bearer " +
|
|
2831
|
+
Authorization: "Bearer " + r.token
|
|
2823
2832
|
}
|
|
2824
2833
|
});
|
|
2825
2834
|
}
|
|
2826
2835
|
}
|
|
2827
2836
|
class cn {
|
|
2828
2837
|
static async listUsers() {
|
|
2829
|
-
if (!
|
|
2838
|
+
if (!r.token)
|
|
2830
2839
|
throw new Error("Not authenticated");
|
|
2831
2840
|
return (await (await fetch(`${h}/v1/admin/users`, {
|
|
2832
2841
|
method: "GET",
|
|
2833
2842
|
headers: {
|
|
2834
2843
|
"Content-Type": "application/json",
|
|
2835
|
-
Authorization: "Bearer " +
|
|
2844
|
+
Authorization: "Bearer " + r.token
|
|
2836
2845
|
}
|
|
2837
2846
|
})).json()).items;
|
|
2838
2847
|
}
|
|
2839
2848
|
static async createUser(e) {
|
|
2840
|
-
if (!
|
|
2849
|
+
if (!r.token)
|
|
2841
2850
|
throw new Error("Not authenticated");
|
|
2842
2851
|
return await (await fetch(`${h}/v1/admin/users`, {
|
|
2843
2852
|
method: "POST",
|
|
2844
2853
|
body: JSON.stringify(e),
|
|
2845
2854
|
headers: {
|
|
2846
2855
|
"Content-Type": "application/json",
|
|
2847
|
-
Authorization: "Bearer " +
|
|
2856
|
+
Authorization: "Bearer " + r.token
|
|
2848
2857
|
}
|
|
2849
2858
|
})).json();
|
|
2850
2859
|
}
|
|
2851
2860
|
static async getUser(e) {
|
|
2852
|
-
if (!
|
|
2861
|
+
if (!r.token)
|
|
2853
2862
|
throw new Error("Not authenticated");
|
|
2854
2863
|
return await (await fetch(`${h}/v1/admin/users/${e}`, {
|
|
2855
2864
|
method: "GET",
|
|
2856
2865
|
headers: {
|
|
2857
2866
|
"Content-Type": "application/json",
|
|
2858
|
-
Authorization: "Bearer " +
|
|
2867
|
+
Authorization: "Bearer " + r.token
|
|
2859
2868
|
}
|
|
2860
2869
|
})).json();
|
|
2861
2870
|
}
|
|
2862
2871
|
static async patchUser(e, t) {
|
|
2863
|
-
if (!
|
|
2872
|
+
if (!r.token)
|
|
2864
2873
|
throw new Error("Not authenticated");
|
|
2865
2874
|
return await (await fetch(`${h}/v1/admin/users/${e}`, {
|
|
2866
2875
|
method: "PATCH",
|
|
2867
2876
|
body: JSON.stringify(t),
|
|
2868
2877
|
headers: {
|
|
2869
2878
|
"Content-Type": "application/json",
|
|
2870
|
-
Authorization: "Bearer " +
|
|
2879
|
+
Authorization: "Bearer " + r.token
|
|
2871
2880
|
}
|
|
2872
2881
|
})).json();
|
|
2873
2882
|
}
|
|
2874
2883
|
static async deleteUser(e) {
|
|
2875
|
-
if (!
|
|
2884
|
+
if (!r.token)
|
|
2876
2885
|
throw new Error("Not authenticated");
|
|
2877
2886
|
await fetch(`${h}/v1/admin/users/${e}`, {
|
|
2878
2887
|
method: "PATCH",
|
|
2879
2888
|
body: JSON.stringify({ enabled: !1, roleId: null, teamId: null }),
|
|
2880
2889
|
headers: {
|
|
2881
2890
|
"Content-Type": "application/json",
|
|
2882
|
-
Authorization: "Bearer " +
|
|
2891
|
+
Authorization: "Bearer " + r.token
|
|
2883
2892
|
}
|
|
2884
2893
|
});
|
|
2885
2894
|
}
|
|
@@ -2911,21 +2920,21 @@ const dn = ["viewer", "operator", "administrator"], hn = "viewer", ln = "operato
|
|
|
2911
2920
|
], yn = ["selection", "labeling", "teleop"], gn = ["info", "warning", "error", "critical"], vn = ["video/mp4"], Tn = (a) => new Promise((e) => setTimeout(e, a * 1e3));
|
|
2912
2921
|
try {
|
|
2913
2922
|
const a = typeof window < "u" && window.location ? new URLSearchParams(window.location.search) : new URLSearchParams(""), e = a.get("device");
|
|
2914
|
-
e &&
|
|
2923
|
+
e && l.setDefaultDevice(e);
|
|
2915
2924
|
const t = a.get("auth");
|
|
2916
|
-
t &&
|
|
2925
|
+
t && r.loginWithToken(t), a.get("module") && r.listenForRefresh(), typeof window < "u" && g.listenForConnectionEvents();
|
|
2917
2926
|
} catch {
|
|
2918
2927
|
}
|
|
2919
2928
|
export {
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2929
|
+
on as Account,
|
|
2930
|
+
g as App,
|
|
2931
|
+
rn as AudioPlayer,
|
|
2932
|
+
r as Authentication,
|
|
2924
2933
|
Xe as BinaryRequestDataChannel,
|
|
2925
2934
|
He as CaptureStream,
|
|
2926
2935
|
Ke as DataChannel,
|
|
2927
2936
|
S as Device,
|
|
2928
|
-
|
|
2937
|
+
l as Fleet,
|
|
2929
2938
|
an as KeyValue,
|
|
2930
2939
|
Qe as Manipulator,
|
|
2931
2940
|
ft as PeerDevice,
|
|
@@ -2942,12 +2951,12 @@ export {
|
|
|
2942
2951
|
fn as annotationTypes,
|
|
2943
2952
|
wn as eventTypes,
|
|
2944
2953
|
ct as formatTimeFrameText,
|
|
2945
|
-
|
|
2954
|
+
rt as getAverage,
|
|
2946
2955
|
st as getCount,
|
|
2947
2956
|
at as getMax,
|
|
2948
2957
|
it as getMin,
|
|
2949
2958
|
nt as getStandardDeviation,
|
|
2950
|
-
|
|
2959
|
+
ot as getSum,
|
|
2951
2960
|
tt as getVariance,
|
|
2952
2961
|
pn as healthStatuses,
|
|
2953
2962
|
yn as interventionTypes,
|