@formant/data-sdk 1.15.0 → 1.17.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 +393 -369
- package/dist/data-sdk.es.js.map +1 -1
- package/dist/data-sdk.es6.js +1784 -1759
- package/dist/data-sdk.umd.js +27 -27
- package/dist/types/data-sdk/src/stores/AuthenticationStore.d.ts +3 -0
- package/dist/types/data-sdk/src/stores/ICheckSsoResult.d.ts +5 -0
- package/package.json +2 -2
package/dist/data-sdk.es.js
CHANGED
|
@@ -4,7 +4,7 @@ var s = (a, e, t) => (de(a, typeof e != "symbol" ? e + "" : e, t), t);
|
|
|
4
4
|
import { decode as G } 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 R, SignalingPromiseClient as j } 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 U 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 _ 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 r = 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 r.json();
|
|
108
|
+
if (r.status !== 200)
|
|
109
|
+
throw new U(c.message);
|
|
110
110
|
if ("challenge" in c)
|
|
111
|
-
throw new
|
|
111
|
+
throw new _(c.challenge);
|
|
112
112
|
const { authentication: d } = c;
|
|
113
113
|
return await this.loginWithToken(
|
|
114
114
|
d.accessToken,
|
|
@@ -117,15 +117,15 @@ 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 (r) {
|
|
121
|
+
if (i || console.error("login() failed", { err: r }), this._waitingForAuth.forEach((c) => c(!1)), this._waitingForAuth.clear(), !i)
|
|
122
|
+
throw r;
|
|
123
|
+
return r instanceof _ ? {
|
|
124
124
|
result: "challenged",
|
|
125
|
-
challenge:
|
|
125
|
+
challenge: r.challenge
|
|
126
126
|
} : {
|
|
127
127
|
result: "failure",
|
|
128
|
-
reason:
|
|
128
|
+
reason: r instanceof U ? r.reason : r instanceof Error ? r.message : String(r)
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -133,9 +133,9 @@ class ve {
|
|
|
133
133
|
var i;
|
|
134
134
|
const n = JSON.parse(G(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 r;
|
|
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 || (r = n.sub), n["formant:claims"] && n["formant:claims"].userId && (r = n["formant:claims"].userId), r && ((i = this._currentUser) == null ? void 0 : i.id) !== r) {
|
|
138
|
+
const c = await fetch(`${this._apiUrl}/v1/admin/users/${r}`, {
|
|
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 (r) {
|
|
151
|
+
console.error("loginWithToken() failed", { err: r }), this._waitingForAuth.forEach((c) => c(!1));
|
|
152
152
|
} finally {
|
|
153
153
|
this._waitingForAuth.clear();
|
|
154
154
|
}
|
|
@@ -255,8 +255,32 @@ class ve {
|
|
|
255
255
|
})).json();
|
|
256
256
|
await this.loginWithToken(n.authentication.accessToken, e);
|
|
257
257
|
}
|
|
258
|
+
async checkSso(e, t) {
|
|
259
|
+
return await (await fetch(`${this._apiUrl}/v1/admin/auth/check-sso`, {
|
|
260
|
+
method: "POST",
|
|
261
|
+
body: JSON.stringify({ email: e, allowUserAutoCreation: t }),
|
|
262
|
+
headers: {
|
|
263
|
+
"Content-Type": "application/json"
|
|
264
|
+
}
|
|
265
|
+
})).json();
|
|
266
|
+
}
|
|
267
|
+
async loginWithSso(e, t) {
|
|
268
|
+
const i = await (await fetch(`${this._apiUrl}/v1/admin/auth/login-sso`, {
|
|
269
|
+
method: "POST",
|
|
270
|
+
body: JSON.stringify({ token: e, refreshToken: t }),
|
|
271
|
+
headers: {
|
|
272
|
+
"Content-Type": "application/json"
|
|
273
|
+
}
|
|
274
|
+
})).json();
|
|
275
|
+
if (!i.authentication)
|
|
276
|
+
throw new Error("Failed to login with SSO");
|
|
277
|
+
return await this.loginWithToken(
|
|
278
|
+
i.authentication.accessToken,
|
|
279
|
+
i.authentication.refreshToken
|
|
280
|
+
);
|
|
281
|
+
}
|
|
258
282
|
}
|
|
259
|
-
function
|
|
283
|
+
function E() {
|
|
260
284
|
return typeof window < "u" && window.location ? new URLSearchParams(window.location.search).get("module") : null;
|
|
261
285
|
}
|
|
262
286
|
function T(a) {
|
|
@@ -264,8 +288,8 @@ function T(a) {
|
|
|
264
288
|
throw new Error("cannot send message to non-existent parent");
|
|
265
289
|
window.parent.postMessage(a, "*");
|
|
266
290
|
}
|
|
267
|
-
function
|
|
268
|
-
const a =
|
|
291
|
+
function F() {
|
|
292
|
+
const a = E();
|
|
269
293
|
if (!a)
|
|
270
294
|
throw new Error("No module context");
|
|
271
295
|
T({
|
|
@@ -273,7 +297,7 @@ function H() {
|
|
|
273
297
|
module: a
|
|
274
298
|
});
|
|
275
299
|
}
|
|
276
|
-
function
|
|
300
|
+
function H(a) {
|
|
277
301
|
function e(t) {
|
|
278
302
|
const n = t.data;
|
|
279
303
|
n.type === "auth_token" && a(n.token);
|
|
@@ -282,10 +306,10 @@ function F(a) {
|
|
|
282
306
|
window.removeEventListener("message", e);
|
|
283
307
|
};
|
|
284
308
|
}
|
|
285
|
-
const
|
|
309
|
+
const o = new ve({
|
|
286
310
|
apiUrl: h,
|
|
287
|
-
refreshAuthToken:
|
|
288
|
-
addAccessTokenRefreshListener:
|
|
311
|
+
refreshAuthToken: F,
|
|
312
|
+
addAccessTokenRefreshListener: H
|
|
289
313
|
});
|
|
290
314
|
async function Te(a) {
|
|
291
315
|
return (await (await fetch(
|
|
@@ -293,7 +317,7 @@ async function Te(a) {
|
|
|
293
317
|
{
|
|
294
318
|
headers: {
|
|
295
319
|
"Content-Type": "application/json",
|
|
296
|
-
Authorization: "Bearer " +
|
|
320
|
+
Authorization: "Bearer " + o.token
|
|
297
321
|
}
|
|
298
322
|
}
|
|
299
323
|
)).json()).configuration;
|
|
@@ -303,20 +327,20 @@ function Ce() {
|
|
|
303
327
|
type: "hide_analytics_date_picker"
|
|
304
328
|
});
|
|
305
329
|
}
|
|
306
|
-
function
|
|
330
|
+
function Se(a) {
|
|
307
331
|
T({
|
|
308
332
|
type: "go_to_device",
|
|
309
333
|
deviceId: a
|
|
310
334
|
});
|
|
311
335
|
}
|
|
312
|
-
function
|
|
336
|
+
function Ee(a) {
|
|
313
337
|
T({
|
|
314
338
|
type: "go_to_time",
|
|
315
339
|
time: a.getTime()
|
|
316
340
|
});
|
|
317
341
|
}
|
|
318
342
|
function ke() {
|
|
319
|
-
const a =
|
|
343
|
+
const a = E();
|
|
320
344
|
if (!a)
|
|
321
345
|
throw new Error("No module context");
|
|
322
346
|
T({
|
|
@@ -325,7 +349,7 @@ function ke() {
|
|
|
325
349
|
});
|
|
326
350
|
}
|
|
327
351
|
function Oe(a, e) {
|
|
328
|
-
const t =
|
|
352
|
+
const t = E();
|
|
329
353
|
if (!t)
|
|
330
354
|
throw new Error("No module context");
|
|
331
355
|
T({
|
|
@@ -336,7 +360,7 @@ function Oe(a, e) {
|
|
|
336
360
|
});
|
|
337
361
|
}
|
|
338
362
|
function Re(a, e) {
|
|
339
|
-
const t =
|
|
363
|
+
const t = E();
|
|
340
364
|
if (!t)
|
|
341
365
|
throw new Error("No module context");
|
|
342
366
|
T({
|
|
@@ -346,8 +370,8 @@ function Re(a, e) {
|
|
|
346
370
|
after: e || 0
|
|
347
371
|
});
|
|
348
372
|
}
|
|
349
|
-
function
|
|
350
|
-
const e =
|
|
373
|
+
function be(a) {
|
|
374
|
+
const e = E();
|
|
351
375
|
if (!e)
|
|
352
376
|
throw new Error("No module context");
|
|
353
377
|
T({
|
|
@@ -356,7 +380,7 @@ function Ae(a) {
|
|
|
356
380
|
menus: a
|
|
357
381
|
});
|
|
358
382
|
}
|
|
359
|
-
function
|
|
383
|
+
function Ae(a) {
|
|
360
384
|
T({ type: "show_message", message: a });
|
|
361
385
|
}
|
|
362
386
|
function je(a, e) {
|
|
@@ -384,7 +408,7 @@ function Ne(a) {
|
|
|
384
408
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
385
409
|
}
|
|
386
410
|
function Pe(a) {
|
|
387
|
-
const e =
|
|
411
|
+
const e = E();
|
|
388
412
|
e && T({ type: "request_module_data", module: e });
|
|
389
413
|
const t = (n) => {
|
|
390
414
|
const i = n.data;
|
|
@@ -404,27 +428,27 @@ function Le(a) {
|
|
|
404
428
|
};
|
|
405
429
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
406
430
|
}
|
|
407
|
-
const Ie = 1, W = 1e3, K = 60 * W, Q = 60 * K,
|
|
431
|
+
const Ie = 1, W = 1e3, K = 60 * W, Q = 60 * K, P = 24 * Q, $e = 7 * P, ze = 30 * P, Be = 365 * P, L = {
|
|
408
432
|
millisecond: Ie,
|
|
409
433
|
second: W,
|
|
410
434
|
minute: K,
|
|
411
435
|
hour: Q,
|
|
412
|
-
day:
|
|
413
|
-
week:
|
|
414
|
-
month:
|
|
415
|
-
year:
|
|
436
|
+
day: P,
|
|
437
|
+
week: $e,
|
|
438
|
+
month: ze,
|
|
439
|
+
year: Be
|
|
416
440
|
};
|
|
417
|
-
function
|
|
441
|
+
function Me(a, e) {
|
|
418
442
|
return a.filter((t) => e.includes(t.type));
|
|
419
443
|
}
|
|
420
|
-
function
|
|
444
|
+
function qe(a, e, t) {
|
|
421
445
|
const n = e.getTime(), i = t.getTime();
|
|
422
|
-
return a.map((
|
|
423
|
-
...
|
|
424
|
-
points:
|
|
446
|
+
return a.map((r) => ({
|
|
447
|
+
...r,
|
|
448
|
+
points: r.points.filter(
|
|
425
449
|
([c]) => c >= n && c < i
|
|
426
450
|
)
|
|
427
|
-
})).filter(({ points:
|
|
451
|
+
})).filter(({ points: r }) => r.length > 0);
|
|
428
452
|
}
|
|
429
453
|
class J {
|
|
430
454
|
constructor({
|
|
@@ -435,11 +459,11 @@ class J {
|
|
|
435
459
|
s(this, "metadata", /* @__PURE__ */ new Map());
|
|
436
460
|
s(this, "capacity");
|
|
437
461
|
s(this, "timeout");
|
|
438
|
-
this.capacity = e || 1e4, this.timeout = t ||
|
|
462
|
+
this.capacity = e || 1e4, this.timeout = t || L.minute;
|
|
439
463
|
}
|
|
440
464
|
get(e, t) {
|
|
441
|
-
const n = this.keyToCacheKey(e), i = this.entries.get(n),
|
|
442
|
-
return (i === void 0 ||
|
|
465
|
+
const n = this.keyToCacheKey(e), i = this.entries.get(n), r = this.metadata.get(n);
|
|
466
|
+
return (i === void 0 || r && (r == null ? void 0 : r.expiration.getTime()) < Date.now()) && !(r != null && r.generating) && t && this.generate(e, t()), i === void 0 && r && r.lastValue !== void 0 ? r.lastValue : i;
|
|
443
467
|
}
|
|
444
468
|
set(e, t) {
|
|
445
469
|
const n = this.keyToCacheKey(e);
|
|
@@ -462,7 +486,7 @@ class J {
|
|
|
462
486
|
if (this.metadata.size < 1)
|
|
463
487
|
return;
|
|
464
488
|
const [e] = [...this.metadata.entries()].reduce(
|
|
465
|
-
([t, n], [i,
|
|
489
|
+
([t, n], [i, r]) => r.expiration.getTime() < n.expiration.getTime() ? [i, r] : [t, n]
|
|
466
490
|
);
|
|
467
491
|
this.clearKey(e);
|
|
468
492
|
}
|
|
@@ -473,58 +497,58 @@ class J {
|
|
|
473
497
|
generating: !0,
|
|
474
498
|
expiration: new Date(Date.now() + this.timeout)
|
|
475
499
|
}), setTimeout(() => {
|
|
476
|
-
t.then((
|
|
500
|
+
t.then((r) => {
|
|
477
501
|
const c = this.metadata.get(n);
|
|
478
|
-
!(c != null && c.generating) || this.set(e,
|
|
502
|
+
!(c != null && c.generating) || this.set(e, r);
|
|
479
503
|
});
|
|
480
504
|
}, 0);
|
|
481
505
|
}
|
|
482
506
|
}
|
|
483
|
-
async function
|
|
484
|
-
if (!
|
|
507
|
+
async function I(a) {
|
|
508
|
+
if (!o.token)
|
|
485
509
|
throw new Error("Not authenticated");
|
|
486
510
|
return (await (await fetch(`${h}/v1/queries/queries`, {
|
|
487
511
|
method: "POST",
|
|
488
512
|
body: JSON.stringify(a),
|
|
489
513
|
headers: {
|
|
490
514
|
"Content-Type": "application/json",
|
|
491
|
-
Authorization: "Bearer " +
|
|
515
|
+
Authorization: "Bearer " + o.token
|
|
492
516
|
}
|
|
493
517
|
})).json()).items;
|
|
494
518
|
}
|
|
495
|
-
class
|
|
519
|
+
class xe {
|
|
496
520
|
constructor() {
|
|
497
521
|
s(this, "queryStoreCache", new J({
|
|
498
522
|
capacity: 1e4,
|
|
499
|
-
timeout: 20 *
|
|
523
|
+
timeout: 20 * L.second
|
|
500
524
|
}));
|
|
501
525
|
s(this, "liveQueryStoreCache", new J({
|
|
502
526
|
capacity: 1e4,
|
|
503
|
-
timeout: 200 *
|
|
527
|
+
timeout: 200 * L.millisecond
|
|
504
528
|
}));
|
|
505
529
|
}
|
|
506
|
-
moduleQuery(e, t, n, i,
|
|
530
|
+
moduleQuery(e, t, n, i, r, c = !1) {
|
|
507
531
|
const d = {
|
|
508
532
|
...e,
|
|
509
533
|
names: [...t],
|
|
510
534
|
types: [...n]
|
|
511
|
-
}, y = this.query(d, i,
|
|
512
|
-
return y === void 0 || y === "too much data" ? y :
|
|
535
|
+
}, y = this.query(d, i, r, c);
|
|
536
|
+
return y === void 0 || y === "too much data" ? y : Me(y, n);
|
|
513
537
|
}
|
|
514
538
|
query(e, t, n, i = !1) {
|
|
515
|
-
const
|
|
539
|
+
const r = {
|
|
516
540
|
...e,
|
|
517
541
|
start: he(t).toISOString(),
|
|
518
542
|
end: i ? n.toISOString() : le(ue(n), 1).toISOString(),
|
|
519
543
|
latestOnly: i
|
|
520
544
|
}, c = n > me(/* @__PURE__ */ new Date(), -20);
|
|
521
545
|
let d;
|
|
522
|
-
return c ? d = this.liveQueryCache(
|
|
546
|
+
return c ? d = this.liveQueryCache(r) : d = this.queryCache(r), !d || d === "too much data" || i ? d : qe(d, t, n);
|
|
523
547
|
}
|
|
524
548
|
queryCache(e) {
|
|
525
549
|
return this.queryStoreCache.get(e, async () => {
|
|
526
550
|
try {
|
|
527
|
-
return await
|
|
551
|
+
return await I(e);
|
|
528
552
|
} catch (t) {
|
|
529
553
|
throw t;
|
|
530
554
|
}
|
|
@@ -533,21 +557,21 @@ class qe {
|
|
|
533
557
|
liveQueryCache(e) {
|
|
534
558
|
return this.liveQueryStoreCache.get(e, async () => {
|
|
535
559
|
try {
|
|
536
|
-
return await
|
|
560
|
+
return await I(e);
|
|
537
561
|
} catch (t) {
|
|
538
562
|
throw t;
|
|
539
563
|
}
|
|
540
564
|
});
|
|
541
565
|
}
|
|
542
566
|
}
|
|
543
|
-
const
|
|
544
|
-
function
|
|
567
|
+
const Ue = new xe();
|
|
568
|
+
function _e(a, e, t) {
|
|
545
569
|
const n = (i) => {
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
548
|
-
const { start: c, end: d } =
|
|
570
|
+
const r = i.data;
|
|
571
|
+
if (r.type === "module_data") {
|
|
572
|
+
const { start: c, end: d } = r.queryRange;
|
|
549
573
|
t(
|
|
550
|
-
|
|
574
|
+
Ue.moduleQuery(
|
|
551
575
|
{},
|
|
552
576
|
a,
|
|
553
577
|
e,
|
|
@@ -568,8 +592,8 @@ async function Je(a, e, t) {
|
|
|
568
592
|
maxTime: t,
|
|
569
593
|
time: a
|
|
570
594
|
});
|
|
571
|
-
const i = (
|
|
572
|
-
const c =
|
|
595
|
+
const i = (r) => {
|
|
596
|
+
const c = r.data;
|
|
573
597
|
c.type === "date_response" && (window.removeEventListener("message", i), n(c.data));
|
|
574
598
|
};
|
|
575
599
|
window.addEventListener("message", i);
|
|
@@ -585,16 +609,16 @@ async function Ve(a, e) {
|
|
|
585
609
|
okText: e == null ? void 0 : e.okText,
|
|
586
610
|
cancelText: e == null ? void 0 : e.cancelText
|
|
587
611
|
});
|
|
588
|
-
const i = (
|
|
589
|
-
const c =
|
|
612
|
+
const i = (r) => {
|
|
613
|
+
const c = r.data;
|
|
590
614
|
c.type === "prompt_response" && c.promptId === n && t(c.data), window.removeEventListener("message", i);
|
|
591
615
|
};
|
|
592
616
|
window.addEventListener("message", i);
|
|
593
617
|
});
|
|
594
618
|
}
|
|
595
|
-
const
|
|
619
|
+
const g = class g {
|
|
596
620
|
static isModule() {
|
|
597
|
-
return
|
|
621
|
+
return E() !== null;
|
|
598
622
|
}
|
|
599
623
|
static async getCurrentModuleConfiguration() {
|
|
600
624
|
let e = new URLSearchParams("");
|
|
@@ -604,7 +628,7 @@ const q = class {
|
|
|
604
628
|
return Te(t.trim());
|
|
605
629
|
}
|
|
606
630
|
static get isOnline() {
|
|
607
|
-
return
|
|
631
|
+
return g._isOnline;
|
|
608
632
|
}
|
|
609
633
|
static listenForConnectionEvents() {
|
|
610
634
|
const e = (t) => {
|
|
@@ -618,12 +642,12 @@ const q = class {
|
|
|
618
642
|
const i = setTimeout(
|
|
619
643
|
() => n(new Error("deadline expired: took too long")),
|
|
620
644
|
e
|
|
621
|
-
),
|
|
622
|
-
window.removeEventListener("message",
|
|
645
|
+
), r = (c) => {
|
|
646
|
+
window.removeEventListener("message", r), clearTimeout(i);
|
|
623
647
|
const { data: d } = c;
|
|
624
648
|
d.type === "formant_online" && (this._isOnline = d.online, t(d.online));
|
|
625
649
|
};
|
|
626
|
-
window.addEventListener("message",
|
|
650
|
+
window.addEventListener("message", r), T({ type: "formant_online" });
|
|
627
651
|
});
|
|
628
652
|
}
|
|
629
653
|
static waitForConnection(e = 5e3) {
|
|
@@ -632,18 +656,18 @@ const q = class {
|
|
|
632
656
|
setTimeout(() => {
|
|
633
657
|
t = !0, d(new Error("deadline expired: took too long"));
|
|
634
658
|
}, e);
|
|
635
|
-
}), i = (c) => new Promise((d) => setTimeout(d, c)),
|
|
659
|
+
}), i = (c) => new Promise((d) => setTimeout(d, c)), r = async () => {
|
|
636
660
|
for (await i(50); !t && !(this.isOnline || await this.checkConnection); )
|
|
637
661
|
await i(500);
|
|
638
662
|
};
|
|
639
|
-
return Promise.race([n,
|
|
663
|
+
return Promise.race([n, r()]);
|
|
640
664
|
}
|
|
641
665
|
};
|
|
642
|
-
|
|
643
|
-
s(g, "
|
|
644
|
-
s(g, "
|
|
645
|
-
s(g, "addAccessTokenRefreshListener", F), s(g, "addChannelDataListener", je), s(g, "addMenuListener", De), s(g, "addModuleConfigurationListener", Ne), s(g, "addModuleDataListener", Pe), s(g, "addOverviewDeviceListener", Le), s(g, "addStreamListener", Ue), // bidirectional
|
|
666
|
+
s(g, "getCurrentModuleContext", E), // senders
|
|
667
|
+
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", be), s(g, "showMessage", Ae), // listeners
|
|
668
|
+
s(g, "addAccessTokenRefreshListener", H), s(g, "addChannelDataListener", je), s(g, "addMenuListener", De), s(g, "addModuleConfigurationListener", Ne), s(g, "addModuleDataListener", Pe), s(g, "addOverviewDeviceListener", Le), s(g, "addStreamListener", _e), // bidirectional
|
|
646
669
|
s(g, "getDate", Je), s(g, "prompt", Ve), s(g, "_isOnline", null);
|
|
670
|
+
let $ = g;
|
|
647
671
|
function f(a, e) {
|
|
648
672
|
if (a !== void 0)
|
|
649
673
|
return a;
|
|
@@ -667,9 +691,9 @@ const p = {
|
|
|
667
691
|
portForward: p.PORT_FORWARD,
|
|
668
692
|
observe: p.OBSERVE,
|
|
669
693
|
headless: p.HEADLESS
|
|
670
|
-
},
|
|
694
|
+
}, k = Symbol("RtcClientPool.instance");
|
|
671
695
|
var Gt;
|
|
672
|
-
class
|
|
696
|
+
class D {
|
|
673
697
|
constructor(e) {
|
|
674
698
|
s(this, Gt, null);
|
|
675
699
|
s(this, "createClient");
|
|
@@ -682,18 +706,18 @@ class N {
|
|
|
682
706
|
});
|
|
683
707
|
const { createClient: t, ttlMs: n = 0 } = e;
|
|
684
708
|
this.createClient = t, this.ttlMs = Math.max(n, 0), this.proxyHandler = {
|
|
685
|
-
get: (i,
|
|
686
|
-
switch (
|
|
709
|
+
get: (i, r, c) => {
|
|
710
|
+
switch (r) {
|
|
687
711
|
case "shutdown":
|
|
688
712
|
return () => this.releaseInstance(c);
|
|
689
713
|
default:
|
|
690
|
-
return Reflect.get(i,
|
|
714
|
+
return Reflect.get(i, r, c);
|
|
691
715
|
}
|
|
692
716
|
}
|
|
693
717
|
};
|
|
694
718
|
}
|
|
695
719
|
get isActive() {
|
|
696
|
-
return this[
|
|
720
|
+
return this[k] !== null;
|
|
697
721
|
}
|
|
698
722
|
get size() {
|
|
699
723
|
return this.proxyReceivers.size;
|
|
@@ -703,13 +727,13 @@ class N {
|
|
|
703
727
|
return this.proxyReceivers.set(t, e ?? null), t;
|
|
704
728
|
}
|
|
705
729
|
allocate() {
|
|
706
|
-
if (this[
|
|
707
|
-
return this.teardownTimeout && (clearTimeout(this.teardownTimeout), this.teardownTimeout = null), this[
|
|
730
|
+
if (this[k])
|
|
731
|
+
return this.teardownTimeout && (clearTimeout(this.teardownTimeout), this.teardownTimeout = null), this[k];
|
|
708
732
|
const e = this.createClient(this.dispatch);
|
|
709
|
-
return this[
|
|
733
|
+
return this[k] = e, e;
|
|
710
734
|
}
|
|
711
735
|
async teardown() {
|
|
712
|
-
const e = this[
|
|
736
|
+
const e = this[k];
|
|
713
737
|
if (!e) {
|
|
714
738
|
console.warn("singleton has already been shutdown!");
|
|
715
739
|
return;
|
|
@@ -717,7 +741,7 @@ class N {
|
|
|
717
741
|
try {
|
|
718
742
|
await e.shutdown();
|
|
719
743
|
} finally {
|
|
720
|
-
this[
|
|
744
|
+
this[k] = null;
|
|
721
745
|
}
|
|
722
746
|
}
|
|
723
747
|
async releaseInstance(e) {
|
|
@@ -726,65 +750,65 @@ class N {
|
|
|
726
750
|
}, this.ttlMs)), !0) : (console.warn("this instance has already been released!"), !1);
|
|
727
751
|
}
|
|
728
752
|
}
|
|
729
|
-
Gt =
|
|
730
|
-
const
|
|
731
|
-
[p.UNKNOWN]: new
|
|
753
|
+
Gt = k;
|
|
754
|
+
const N = async () => f(o.token, "Realtime when user isn't authorized"), O = {
|
|
755
|
+
[p.UNKNOWN]: new D({
|
|
732
756
|
ttlMs: 2500,
|
|
733
|
-
createClient: (a) => new
|
|
734
|
-
signalingClient: new
|
|
735
|
-
getToken:
|
|
757
|
+
createClient: (a) => new R({
|
|
758
|
+
signalingClient: new j(h),
|
|
759
|
+
getToken: N,
|
|
736
760
|
sessionType: p.UNKNOWN,
|
|
737
761
|
receive: a
|
|
738
762
|
})
|
|
739
763
|
}),
|
|
740
|
-
[p.TELEOP]: new
|
|
764
|
+
[p.TELEOP]: new D({
|
|
741
765
|
ttlMs: 2500,
|
|
742
|
-
createClient: (a) => new
|
|
743
|
-
signalingClient: new
|
|
744
|
-
getToken:
|
|
766
|
+
createClient: (a) => new R({
|
|
767
|
+
signalingClient: new j(h),
|
|
768
|
+
getToken: N,
|
|
745
769
|
sessionType: p.TELEOP,
|
|
746
770
|
receive: a
|
|
747
771
|
})
|
|
748
772
|
}),
|
|
749
|
-
[p.PORT_FORWARD]: new
|
|
773
|
+
[p.PORT_FORWARD]: new D({
|
|
750
774
|
ttlMs: 2500,
|
|
751
|
-
createClient: (a) => new
|
|
752
|
-
signalingClient: new
|
|
753
|
-
getToken:
|
|
775
|
+
createClient: (a) => new R({
|
|
776
|
+
signalingClient: new j(h),
|
|
777
|
+
getToken: N,
|
|
754
778
|
sessionType: p.PORT_FORWARD,
|
|
755
779
|
receive: a
|
|
756
780
|
})
|
|
757
781
|
}),
|
|
758
|
-
[p.OBSERVE]: new
|
|
782
|
+
[p.OBSERVE]: new D({
|
|
759
783
|
ttlMs: 2500,
|
|
760
|
-
createClient: (a) => new
|
|
761
|
-
signalingClient: new
|
|
762
|
-
getToken:
|
|
784
|
+
createClient: (a) => new R({
|
|
785
|
+
signalingClient: new j(h),
|
|
786
|
+
getToken: N,
|
|
763
787
|
sessionType: p.OBSERVE,
|
|
764
788
|
receive: a
|
|
765
789
|
})
|
|
766
790
|
}),
|
|
767
|
-
[p.HEADLESS]: new
|
|
791
|
+
[p.HEADLESS]: new D({
|
|
768
792
|
ttlMs: 2500,
|
|
769
|
-
createClient: (a) => new
|
|
770
|
-
signalingClient: new
|
|
771
|
-
getToken:
|
|
793
|
+
createClient: (a) => new R({
|
|
794
|
+
signalingClient: new j(h),
|
|
795
|
+
getToken: N,
|
|
772
796
|
sessionType: p.HEADLESS,
|
|
773
797
|
receive: a
|
|
774
798
|
})
|
|
775
799
|
})
|
|
776
800
|
}, Ge = {
|
|
777
|
-
...
|
|
778
|
-
unknown:
|
|
779
|
-
teleop:
|
|
780
|
-
portForward:
|
|
781
|
-
observe:
|
|
782
|
-
headless:
|
|
783
|
-
},
|
|
801
|
+
...O,
|
|
802
|
+
unknown: O[p.UNKNOWN],
|
|
803
|
+
teleop: O[p.TELEOP],
|
|
804
|
+
portForward: O[p.PORT_FORWARD],
|
|
805
|
+
observe: O[p.OBSERVE],
|
|
806
|
+
headless: O[p.HEADLESS]
|
|
807
|
+
}, B = O[p.TELEOP], Fe = (a) => {
|
|
784
808
|
const { sessionType: e } = a;
|
|
785
|
-
return e ? Ge[e] :
|
|
809
|
+
return e ? Ge[e] : B;
|
|
786
810
|
};
|
|
787
|
-
class
|
|
811
|
+
class He {
|
|
788
812
|
constructor(e) {
|
|
789
813
|
s(this, "token");
|
|
790
814
|
this.captureSession = e;
|
|
@@ -836,8 +860,8 @@ class Ke {
|
|
|
836
860
|
console.error(t), this.error = "An error occurred in DataChannel", this.errorListeners.forEach((n) => n(t));
|
|
837
861
|
}, this.dataChannel.onmessage = (t) => {
|
|
838
862
|
this.listeners.forEach((n) => {
|
|
839
|
-
const i = new Uint8Array(t.data),
|
|
840
|
-
n(
|
|
863
|
+
const i = new Uint8Array(t.data), r = this.decoder.decode(i);
|
|
864
|
+
n(r);
|
|
841
865
|
}), this.binaryListeners.forEach((n) => {
|
|
842
866
|
n(new Uint8Array(t.data));
|
|
843
867
|
});
|
|
@@ -985,21 +1009,21 @@ class Xe extends X {
|
|
|
985
1009
|
const i = t.slice(0, 16).toString();
|
|
986
1010
|
if (i.length === 0)
|
|
987
1011
|
throw new Error("Invalid response");
|
|
988
|
-
const
|
|
989
|
-
if (
|
|
1012
|
+
const r = t.slice(16);
|
|
1013
|
+
if (r.length === 0)
|
|
990
1014
|
throw new Error("Invalid response");
|
|
991
|
-
this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i,
|
|
1015
|
+
this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, r);
|
|
992
1016
|
});
|
|
993
1017
|
}
|
|
994
1018
|
async request(t) {
|
|
995
1019
|
if (this.channel || await this.initialize(), !this.channel)
|
|
996
1020
|
throw new Error("Failed to create channel");
|
|
997
|
-
const { channel: n, requestIdToResponseMap: i, timeout:
|
|
1021
|
+
const { channel: n, requestIdToResponseMap: i, timeout: r } = this;
|
|
998
1022
|
await n.waitTilReady();
|
|
999
1023
|
const c = this.generateBinaryId(), d = c.toString();
|
|
1000
1024
|
i.set(d, !0), n.sendBinary(new Uint8Array([...c, ...t]));
|
|
1001
1025
|
const y = (/* @__PURE__ */ new Date()).getTime();
|
|
1002
|
-
for (; (/* @__PURE__ */ new Date()).getTime() < y +
|
|
1026
|
+
for (; (/* @__PURE__ */ new Date()).getTime() < y + r; )
|
|
1003
1027
|
if (await b(50), i.has(d)) {
|
|
1004
1028
|
const m = i.get(d);
|
|
1005
1029
|
if (m !== !0) {
|
|
@@ -1015,7 +1039,7 @@ class Xe extends X {
|
|
|
1015
1039
|
}
|
|
1016
1040
|
throw i.delete(d), console.error({
|
|
1017
1041
|
name: "TimeoutError",
|
|
1018
|
-
message: `Request timed out after ${
|
|
1042
|
+
message: `Request timed out after ${r / 1e3} seconds`
|
|
1019
1043
|
}), new Error("Binary request data channel request timed out");
|
|
1020
1044
|
}
|
|
1021
1045
|
}
|
|
@@ -1025,10 +1049,10 @@ class Ye extends X {
|
|
|
1025
1049
|
}
|
|
1026
1050
|
async initialize() {
|
|
1027
1051
|
this.channel = await this.device.createCustomDataChannel(this.channel_name), this.channel.addListener((e) => {
|
|
1028
|
-
const t = JSON.parse(e), { id: n, data: i, error:
|
|
1052
|
+
const t = JSON.parse(e), { id: n, data: i, error: r } = t;
|
|
1029
1053
|
if (!n)
|
|
1030
1054
|
throw new Error("Invalid response");
|
|
1031
|
-
if (!i && !
|
|
1055
|
+
if (!i && !r)
|
|
1032
1056
|
throw new Error("Invalid response");
|
|
1033
1057
|
this.requestIdToResponseMap.has(n) && this.requestIdToResponseMap.set(n, t);
|
|
1034
1058
|
});
|
|
@@ -1038,19 +1062,19 @@ class Ye extends X {
|
|
|
1038
1062
|
throw new Error("Failed to create channel");
|
|
1039
1063
|
const { channel: t, requestIdToResponseMap: n, timeout: i } = this;
|
|
1040
1064
|
await t.waitTilReady();
|
|
1041
|
-
const
|
|
1042
|
-
n.set(
|
|
1065
|
+
const r = this.generateTextId();
|
|
1066
|
+
n.set(r, !0), t.send(
|
|
1043
1067
|
JSON.stringify({
|
|
1044
|
-
id:
|
|
1068
|
+
id: r,
|
|
1045
1069
|
data: e
|
|
1046
1070
|
})
|
|
1047
1071
|
);
|
|
1048
1072
|
const c = (/* @__PURE__ */ new Date()).getTime();
|
|
1049
1073
|
for (; (/* @__PURE__ */ new Date()).getTime() < c + i; )
|
|
1050
|
-
if (await b(50), n.has(
|
|
1051
|
-
const d = n.get(
|
|
1074
|
+
if (await b(50), n.has(r)) {
|
|
1075
|
+
const d = n.get(r);
|
|
1052
1076
|
if (d !== !0) {
|
|
1053
|
-
n.delete(
|
|
1077
|
+
n.delete(r);
|
|
1054
1078
|
const { data: y, error: m } = d;
|
|
1055
1079
|
if (y)
|
|
1056
1080
|
return y;
|
|
@@ -1061,7 +1085,7 @@ class Ye extends X {
|
|
|
1061
1085
|
}), new Error("Text request datachannel adapter error");
|
|
1062
1086
|
}
|
|
1063
1087
|
}
|
|
1064
|
-
throw n.delete(
|
|
1088
|
+
throw n.delete(r), console.error({
|
|
1065
1089
|
name: "TimeoutError",
|
|
1066
1090
|
message: `Request timed out after ${i / 1e3} seconds`
|
|
1067
1091
|
}), new Error("Text request datachannel request timed out");
|
|
@@ -1121,13 +1145,13 @@ class Y extends fe {
|
|
|
1121
1145
|
return n;
|
|
1122
1146
|
}
|
|
1123
1147
|
async getRealtimeVideoStreams() {
|
|
1124
|
-
var i,
|
|
1148
|
+
var i, r, c;
|
|
1125
1149
|
const t = await this.getConfiguration(), n = [];
|
|
1126
1150
|
for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
|
|
1127
1151
|
d.rtcStreamType === "h264-video-frame" && n.push({
|
|
1128
1152
|
name: d.name
|
|
1129
1153
|
});
|
|
1130
|
-
for (const d of ((
|
|
1154
|
+
for (const d of ((r = t.teleop) == null ? void 0 : r.rosStreams) ?? [])
|
|
1131
1155
|
d.topicType == "formant/H264VideoFrame" && n.push({
|
|
1132
1156
|
name: d.topicName
|
|
1133
1157
|
}), (d.topicType === "sensor_msgs/Image" || d.topicType === "sensor_msgs/CompressedImage") && d.encodeVideo && n.push({
|
|
@@ -1215,8 +1239,8 @@ class Y extends fe {
|
|
|
1215
1239
|
const i = f(
|
|
1216
1240
|
this.rtcClient,
|
|
1217
1241
|
"Realtime connection has not been started"
|
|
1218
|
-
),
|
|
1219
|
-
i.controlRemoteStream(f(
|
|
1242
|
+
), r = await this.getRemotePeer();
|
|
1243
|
+
i.controlRemoteStream(f(r).id, {
|
|
1220
1244
|
streamName: t,
|
|
1221
1245
|
setAudioFormat: n
|
|
1222
1246
|
});
|
|
@@ -1225,9 +1249,9 @@ class Y extends fe {
|
|
|
1225
1249
|
const i = f(
|
|
1226
1250
|
this.rtcClient,
|
|
1227
1251
|
"Realtime connection has not been started"
|
|
1228
|
-
),
|
|
1252
|
+
), r = await this.getRemotePeer(), c = await new Promise((d) => {
|
|
1229
1253
|
i.createCustomDataChannel(
|
|
1230
|
-
f(
|
|
1254
|
+
f(r).id,
|
|
1231
1255
|
t,
|
|
1232
1256
|
{
|
|
1233
1257
|
ordered: !0,
|
|
@@ -1248,17 +1272,17 @@ class Y extends fe {
|
|
|
1248
1272
|
const i = f(
|
|
1249
1273
|
this.rtcClient,
|
|
1250
1274
|
"Realtime connection has not been started"
|
|
1251
|
-
),
|
|
1252
|
-
i.send(f(
|
|
1275
|
+
), r = await this.getRemotePeer();
|
|
1276
|
+
i.send(f(r).id, t, n);
|
|
1253
1277
|
}
|
|
1254
1278
|
async getRealtimeAudioStreams() {
|
|
1255
|
-
var i,
|
|
1279
|
+
var i, r, c;
|
|
1256
1280
|
const t = await this.getConfiguration(), n = [];
|
|
1257
1281
|
for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
|
|
1258
1282
|
d.rtcStreamType === "audio-chunk" && n.push({
|
|
1259
1283
|
name: d.name
|
|
1260
1284
|
});
|
|
1261
|
-
for (const d of ((
|
|
1285
|
+
for (const d of ((r = t.teleop) == null ? void 0 : r.rosStreams) ?? [])
|
|
1262
1286
|
d.topicType == "audio_common_msgs/AudioData" && n.push({
|
|
1263
1287
|
name: d.topicName
|
|
1264
1288
|
});
|
|
@@ -1276,18 +1300,18 @@ function et(a) {
|
|
|
1276
1300
|
return pe(n);
|
|
1277
1301
|
}
|
|
1278
1302
|
async function Z() {
|
|
1279
|
-
if (!
|
|
1303
|
+
if (!o.token)
|
|
1280
1304
|
throw new Error("Not authenticated");
|
|
1281
1305
|
return (await (await fetch(`${h}/v1/admin/views`, {
|
|
1282
1306
|
method: "GET",
|
|
1283
1307
|
headers: {
|
|
1284
1308
|
"Content-Type": "application/json",
|
|
1285
|
-
Authorization: "Bearer " +
|
|
1309
|
+
Authorization: "Bearer " + o.token
|
|
1286
1310
|
}
|
|
1287
1311
|
})).json()).items;
|
|
1288
1312
|
}
|
|
1289
1313
|
async function ee(a, e) {
|
|
1290
|
-
if (!
|
|
1314
|
+
if (!o.token)
|
|
1291
1315
|
throw new Error("Not authenticated");
|
|
1292
1316
|
const n = (await Z()).filter((d) => d.name === e);
|
|
1293
1317
|
if (n.length === 0)
|
|
@@ -1297,10 +1321,10 @@ async function ee(a, e) {
|
|
|
1297
1321
|
body: JSON.stringify(a),
|
|
1298
1322
|
headers: {
|
|
1299
1323
|
"Content-Type": "application/json",
|
|
1300
|
-
Authorization: "Bearer " +
|
|
1324
|
+
Authorization: "Bearer " + o.token
|
|
1301
1325
|
}
|
|
1302
|
-
}),
|
|
1303
|
-
return `${
|
|
1326
|
+
}), r = h.replace("api", "app"), { code: c } = await i.json();
|
|
1327
|
+
return `${r}/shares/${c}#${et({
|
|
1304
1328
|
viewId: n[0].id
|
|
1305
1329
|
})}`;
|
|
1306
1330
|
}
|
|
@@ -1404,32 +1428,32 @@ const nn = {
|
|
|
1404
1428
|
// bg-BG: 'dd.mm.YYYY'
|
|
1405
1429
|
a.split("/")[0] + "/" + a.split("/")[1] + "–" + e.split("/")[0] + "/" + e.split("/")[1]
|
|
1406
1430
|
);
|
|
1407
|
-
async function
|
|
1408
|
-
if (!
|
|
1431
|
+
async function M(a) {
|
|
1432
|
+
if (!o.token)
|
|
1409
1433
|
throw new Error("Not authenticated");
|
|
1410
1434
|
return (await (await fetch(`${h}/v1/admin/events/query`, {
|
|
1411
1435
|
method: "POST",
|
|
1412
1436
|
body: JSON.stringify(a),
|
|
1413
1437
|
headers: {
|
|
1414
1438
|
"Content-Type": "application/json",
|
|
1415
|
-
Authorization: "Bearer " +
|
|
1439
|
+
Authorization: "Bearer " + o.token
|
|
1416
1440
|
}
|
|
1417
1441
|
})).json()).items;
|
|
1418
1442
|
}
|
|
1419
1443
|
async function ne(a, e, t, n, i) {
|
|
1420
|
-
const
|
|
1444
|
+
const r = te[e];
|
|
1421
1445
|
return await Promise.all(
|
|
1422
1446
|
Array(t).fill(0).map(async (c, d) => {
|
|
1423
|
-
const y = new Date(n), m =
|
|
1424
|
-
|
|
1447
|
+
const y = new Date(n), m = r.sub(
|
|
1448
|
+
r.start(y),
|
|
1425
1449
|
t - d - 1
|
|
1426
|
-
), w =
|
|
1427
|
-
|
|
1450
|
+
), w = r.sub(
|
|
1451
|
+
r.end(y),
|
|
1428
1452
|
t - d - 1
|
|
1429
1453
|
), v = ct(
|
|
1430
1454
|
m.toLocaleDateString(),
|
|
1431
1455
|
w.toLocaleDateString()
|
|
1432
|
-
), C = await
|
|
1456
|
+
), C = await M({
|
|
1433
1457
|
...i,
|
|
1434
1458
|
eventTypes: a,
|
|
1435
1459
|
start: new Date(m).toISOString(),
|
|
@@ -1439,15 +1463,15 @@ async function ne(a, e, t, n, i) {
|
|
|
1439
1463
|
})
|
|
1440
1464
|
);
|
|
1441
1465
|
}
|
|
1442
|
-
async function
|
|
1443
|
-
return (await
|
|
1466
|
+
async function q(a, e) {
|
|
1467
|
+
return (await M({
|
|
1444
1468
|
...a,
|
|
1445
1469
|
eventTypes: ["annotation"]
|
|
1446
1470
|
})).filter(
|
|
1447
|
-
(
|
|
1448
|
-
).reduce((
|
|
1471
|
+
(r) => !!r.tags && Object.keys(r.tags).includes(e)
|
|
1472
|
+
).reduce((r, c) => {
|
|
1449
1473
|
const d = c.tags[e];
|
|
1450
|
-
return d in
|
|
1474
|
+
return d in r ? (r[d] += 1, r) : (r[d] = 1, r);
|
|
1451
1475
|
}, {});
|
|
1452
1476
|
}
|
|
1453
1477
|
async function ae(a, e, t) {
|
|
@@ -1456,7 +1480,7 @@ async function ae(a, e, t) {
|
|
|
1456
1480
|
end: new Date(n)
|
|
1457
1481
|
}), d = c.map((m, w) => {
|
|
1458
1482
|
const v = new Date(m).toISOString(), C = w === c.length - 1 ? new Date(Date.now()).toISOString() : new Date(c[w + 1]);
|
|
1459
|
-
return
|
|
1483
|
+
return q(
|
|
1460
1484
|
{
|
|
1461
1485
|
...a,
|
|
1462
1486
|
start: v,
|
|
@@ -1471,13 +1495,13 @@ async function ae(a, e, t) {
|
|
|
1471
1495
|
}));
|
|
1472
1496
|
}
|
|
1473
1497
|
async function ie(a, e, t, n, i) {
|
|
1474
|
-
let
|
|
1475
|
-
Array.isArray(a) || (
|
|
1498
|
+
let r = a;
|
|
1499
|
+
Array.isArray(a) || (r = [a]);
|
|
1476
1500
|
let c = e;
|
|
1477
1501
|
return Array.isArray(e) || (c = [e]), (await (await fetch(`${h}/v1/queries/queries`, {
|
|
1478
1502
|
method: "POST",
|
|
1479
1503
|
body: JSON.stringify({
|
|
1480
|
-
deviceIds:
|
|
1504
|
+
deviceIds: r,
|
|
1481
1505
|
end: n.toISOString(),
|
|
1482
1506
|
names: c,
|
|
1483
1507
|
start: t.toISOString(),
|
|
@@ -1485,14 +1509,14 @@ async function ie(a, e, t, n, i) {
|
|
|
1485
1509
|
}),
|
|
1486
1510
|
headers: {
|
|
1487
1511
|
"Content-Type": "application/json",
|
|
1488
|
-
Authorization: "Bearer " +
|
|
1512
|
+
Authorization: "Bearer " + o.token
|
|
1489
1513
|
}
|
|
1490
1514
|
})).json()).items;
|
|
1491
1515
|
}
|
|
1492
1516
|
async function oe() {
|
|
1493
|
-
if (!
|
|
1517
|
+
if (!o.token)
|
|
1494
1518
|
throw new Error("Not authenticated");
|
|
1495
|
-
const a =
|
|
1519
|
+
const a = B.get();
|
|
1496
1520
|
try {
|
|
1497
1521
|
return await a.getSessions();
|
|
1498
1522
|
} finally {
|
|
@@ -1500,9 +1524,9 @@ async function oe() {
|
|
|
1500
1524
|
}
|
|
1501
1525
|
}
|
|
1502
1526
|
async function re() {
|
|
1503
|
-
if (!
|
|
1527
|
+
if (!o.token)
|
|
1504
1528
|
throw new Error("Not authenticated");
|
|
1505
|
-
const a =
|
|
1529
|
+
const a = B.get();
|
|
1506
1530
|
try {
|
|
1507
1531
|
return await a.getPeers();
|
|
1508
1532
|
} finally {
|
|
@@ -1510,55 +1534,55 @@ async function re() {
|
|
|
1510
1534
|
}
|
|
1511
1535
|
}
|
|
1512
1536
|
async function dt(a) {
|
|
1513
|
-
if (!
|
|
1537
|
+
if (!o.token)
|
|
1514
1538
|
throw new Error("Not authenticated");
|
|
1515
1539
|
return await (await fetch(`${h}/v1/admin/devices`, {
|
|
1516
1540
|
method: "POST",
|
|
1517
1541
|
body: JSON.stringify(a),
|
|
1518
1542
|
headers: {
|
|
1519
1543
|
"Content-Type": "application/json",
|
|
1520
|
-
Authorization: "Bearer " +
|
|
1544
|
+
Authorization: "Bearer " + o.token
|
|
1521
1545
|
}
|
|
1522
1546
|
})).json();
|
|
1523
1547
|
}
|
|
1524
1548
|
async function ht(a, e) {
|
|
1525
|
-
if (!
|
|
1549
|
+
if (!o.token)
|
|
1526
1550
|
throw new Error("Not authenticated");
|
|
1527
1551
|
return await (await fetch(`${h}/v1/admin/devices/${a}`, {
|
|
1528
1552
|
method: "PATCH",
|
|
1529
1553
|
body: JSON.stringify(e),
|
|
1530
1554
|
headers: {
|
|
1531
1555
|
"Content-Type": "application/json",
|
|
1532
|
-
Authorization: "Bearer " +
|
|
1556
|
+
Authorization: "Bearer " + o.token
|
|
1533
1557
|
}
|
|
1534
1558
|
})).json();
|
|
1535
1559
|
}
|
|
1536
1560
|
async function lt() {
|
|
1537
|
-
if (!
|
|
1561
|
+
if (!o.token)
|
|
1538
1562
|
throw new Error("Not authenticated");
|
|
1539
1563
|
return (await (await fetch(`${h}/v1/admin/device-details/query`, {
|
|
1540
1564
|
method: "POST",
|
|
1541
1565
|
body: JSON.stringify({ enabled: !0, type: "default" }),
|
|
1542
1566
|
headers: {
|
|
1543
1567
|
"Content-Type": "application/json",
|
|
1544
|
-
Authorization: "Bearer " +
|
|
1568
|
+
Authorization: "Bearer " + o.token
|
|
1545
1569
|
}
|
|
1546
1570
|
})).json()).items;
|
|
1547
1571
|
}
|
|
1548
1572
|
async function ut(a) {
|
|
1549
|
-
if (!
|
|
1573
|
+
if (!o.token)
|
|
1550
1574
|
throw new Error("Not authenticated");
|
|
1551
1575
|
return (await (await fetch(`${h}/v1/admin/devices/query`, {
|
|
1552
1576
|
method: "POST",
|
|
1553
1577
|
body: JSON.stringify(a),
|
|
1554
1578
|
headers: {
|
|
1555
1579
|
"Content-Type": "application/json",
|
|
1556
|
-
Authorization: "Bearer " +
|
|
1580
|
+
Authorization: "Bearer " + o.token
|
|
1557
1581
|
}
|
|
1558
1582
|
})).json()).items;
|
|
1559
1583
|
}
|
|
1560
1584
|
async function mt(a) {
|
|
1561
|
-
if (!
|
|
1585
|
+
if (!o.token)
|
|
1562
1586
|
throw new Error("Not authenticated");
|
|
1563
1587
|
return await (await fetch(
|
|
1564
1588
|
`${h}/v1/admin/devices/${a}/disable`,
|
|
@@ -1566,12 +1590,12 @@ async function mt(a) {
|
|
|
1566
1590
|
method: "POST",
|
|
1567
1591
|
headers: {
|
|
1568
1592
|
"Content-Type": "application/json",
|
|
1569
|
-
Authorization: "Bearer " +
|
|
1593
|
+
Authorization: "Bearer " + o.token
|
|
1570
1594
|
}
|
|
1571
1595
|
}
|
|
1572
1596
|
)).json();
|
|
1573
1597
|
}
|
|
1574
|
-
class
|
|
1598
|
+
class S extends Y {
|
|
1575
1599
|
constructor(e, t, n, i) {
|
|
1576
1600
|
super(), this.id = e, this.name = t, this.organizationId = n, this.tags = i;
|
|
1577
1601
|
}
|
|
@@ -1585,7 +1609,7 @@ class E extends Y {
|
|
|
1585
1609
|
}),
|
|
1586
1610
|
headers: {
|
|
1587
1611
|
"Content-Type": "application/json",
|
|
1588
|
-
Authorization: "Bearer " +
|
|
1612
|
+
Authorization: "Bearer " + o.token
|
|
1589
1613
|
}
|
|
1590
1614
|
}
|
|
1591
1615
|
)).json()).items;
|
|
@@ -1602,7 +1626,7 @@ class E extends Y {
|
|
|
1602
1626
|
method: "GET",
|
|
1603
1627
|
headers: {
|
|
1604
1628
|
"Content-Type": "application/json",
|
|
1605
|
-
Authorization: "Bearer " +
|
|
1629
|
+
Authorization: "Bearer " + o.token
|
|
1606
1630
|
}
|
|
1607
1631
|
});
|
|
1608
1632
|
const n = await t.json();
|
|
@@ -1617,7 +1641,7 @@ class E extends Y {
|
|
|
1617
1641
|
method: "GET",
|
|
1618
1642
|
headers: {
|
|
1619
1643
|
"Content-Type": "application/json",
|
|
1620
|
-
Authorization: "Bearer " +
|
|
1644
|
+
Authorization: "Bearer " + o.token
|
|
1621
1645
|
}
|
|
1622
1646
|
}
|
|
1623
1647
|
), (await t.json()).document;
|
|
@@ -1634,7 +1658,7 @@ class E extends Y {
|
|
|
1634
1658
|
method: "GET",
|
|
1635
1659
|
headers: {
|
|
1636
1660
|
"Content-Type": "application/json",
|
|
1637
|
-
Authorization: "Bearer " +
|
|
1661
|
+
Authorization: "Bearer " + o.token
|
|
1638
1662
|
}
|
|
1639
1663
|
})).json();
|
|
1640
1664
|
return (n = t == null ? void 0 : t.state) == null ? void 0 : n.agentVersion;
|
|
@@ -1647,7 +1671,7 @@ class E extends Y {
|
|
|
1647
1671
|
}),
|
|
1648
1672
|
headers: {
|
|
1649
1673
|
"Content-Type": "application/json",
|
|
1650
|
-
Authorization: "Bearer " +
|
|
1674
|
+
Authorization: "Bearer " + o.token
|
|
1651
1675
|
}
|
|
1652
1676
|
})).json()).fileUrls;
|
|
1653
1677
|
}
|
|
@@ -1669,7 +1693,7 @@ class E extends Y {
|
|
|
1669
1693
|
sessionType: t,
|
|
1670
1694
|
deadlineMs: n = 1e4,
|
|
1671
1695
|
maxConnectRetries: i = 3
|
|
1672
|
-
} = typeof e == "number" ? { sessionType: e } : e, c =
|
|
1696
|
+
} = typeof e == "number" ? { sessionType: e } : e, c = Fe({
|
|
1673
1697
|
sessionType: t
|
|
1674
1698
|
}).get(this.handleMessage);
|
|
1675
1699
|
let d = !1;
|
|
@@ -1688,7 +1712,7 @@ class E extends Y {
|
|
|
1688
1712
|
const w = await this.getRemoteDevicePeerId(c);
|
|
1689
1713
|
this.assertNotCancelled(d);
|
|
1690
1714
|
let v;
|
|
1691
|
-
for (let
|
|
1715
|
+
for (let A = 0; A < i && (v = await c.connect(w), !v); A++)
|
|
1692
1716
|
b(100), this.assertNotCancelled(d);
|
|
1693
1717
|
if (!v)
|
|
1694
1718
|
throw new Error(
|
|
@@ -1768,7 +1792,7 @@ class E extends Y {
|
|
|
1768
1792
|
method: "GET",
|
|
1769
1793
|
headers: {
|
|
1770
1794
|
"Content-Type": "application/json",
|
|
1771
|
-
Authorization: "Bearer " +
|
|
1795
|
+
Authorization: "Bearer " + o.token
|
|
1772
1796
|
}
|
|
1773
1797
|
}
|
|
1774
1798
|
)).json()).items.map((n) => ({
|
|
@@ -1806,11 +1830,11 @@ class E extends Y {
|
|
|
1806
1830
|
deviceId: this.id,
|
|
1807
1831
|
command: c.command,
|
|
1808
1832
|
parameter: y,
|
|
1809
|
-
userId: (w =
|
|
1833
|
+
userId: (w = o.currentUser) == null ? void 0 : w.id
|
|
1810
1834
|
}),
|
|
1811
1835
|
headers: {
|
|
1812
1836
|
"Content-Type": "application/json",
|
|
1813
|
-
Authorization: "Bearer " +
|
|
1837
|
+
Authorization: "Bearer " + o.token
|
|
1814
1838
|
}
|
|
1815
1839
|
});
|
|
1816
1840
|
}
|
|
@@ -1819,7 +1843,7 @@ class E extends Y {
|
|
|
1819
1843
|
method: "GET",
|
|
1820
1844
|
headers: {
|
|
1821
1845
|
"Content-Type": "application/json",
|
|
1822
|
-
Authorization: "Bearer " +
|
|
1846
|
+
Authorization: "Bearer " + o.token
|
|
1823
1847
|
}
|
|
1824
1848
|
});
|
|
1825
1849
|
}
|
|
@@ -1833,10 +1857,10 @@ class E extends Y {
|
|
|
1833
1857
|
}),
|
|
1834
1858
|
headers: {
|
|
1835
1859
|
"Content-Type": "application/json",
|
|
1836
|
-
Authorization: "Bearer " +
|
|
1860
|
+
Authorization: "Bearer " + o.token
|
|
1837
1861
|
}
|
|
1838
1862
|
})).json();
|
|
1839
|
-
return new
|
|
1863
|
+
return new He(n);
|
|
1840
1864
|
}
|
|
1841
1865
|
async getTelemetry(e, t, n, i) {
|
|
1842
1866
|
return await ie(
|
|
@@ -1858,7 +1882,7 @@ class E extends Y {
|
|
|
1858
1882
|
}),
|
|
1859
1883
|
headers: {
|
|
1860
1884
|
"Content-Type": "application/json",
|
|
1861
|
-
Authorization: "Bearer " +
|
|
1885
|
+
Authorization: "Bearer " + o.token
|
|
1862
1886
|
}
|
|
1863
1887
|
}
|
|
1864
1888
|
), n = [], i = [];
|
|
@@ -1881,7 +1905,7 @@ class E extends Y {
|
|
|
1881
1905
|
}),
|
|
1882
1906
|
headers: {
|
|
1883
1907
|
"Content-Type": "application/json",
|
|
1884
|
-
Authorization: "Bearer " +
|
|
1908
|
+
Authorization: "Bearer " + o.token
|
|
1885
1909
|
}
|
|
1886
1910
|
}
|
|
1887
1911
|
)).json();
|
|
@@ -1898,13 +1922,13 @@ class E extends Y {
|
|
|
1898
1922
|
}),
|
|
1899
1923
|
headers: {
|
|
1900
1924
|
"Content-Type": "application/json",
|
|
1901
|
-
Authorization: "Bearer " +
|
|
1925
|
+
Authorization: "Bearer " + o.token
|
|
1902
1926
|
}
|
|
1903
1927
|
}
|
|
1904
1928
|
)).json();
|
|
1905
1929
|
}
|
|
1906
1930
|
async getAnnotationCount(e, t) {
|
|
1907
|
-
return await
|
|
1931
|
+
return await q({ ...e, deviceIds: [this.id] }, t);
|
|
1908
1932
|
}
|
|
1909
1933
|
async getAnnotationCountByIntervals(e, t, n) {
|
|
1910
1934
|
return await ae(
|
|
@@ -1913,9 +1937,9 @@ class E extends Y {
|
|
|
1913
1937
|
n
|
|
1914
1938
|
);
|
|
1915
1939
|
}
|
|
1916
|
-
async eventsCounter(e, t, n, i,
|
|
1940
|
+
async eventsCounter(e, t, n, i, r) {
|
|
1917
1941
|
return await ne(e, t, n, i, {
|
|
1918
|
-
...
|
|
1942
|
+
...r,
|
|
1919
1943
|
deviceIds: [this.id]
|
|
1920
1944
|
});
|
|
1921
1945
|
}
|
|
@@ -1923,7 +1947,7 @@ class E extends Y {
|
|
|
1923
1947
|
return e.scope.deviceIds = [this.id], await ee(e, t);
|
|
1924
1948
|
}
|
|
1925
1949
|
}
|
|
1926
|
-
s(
|
|
1950
|
+
s(S, "createDevice", dt), s(S, "patchDevice", ht), s(S, "getDevicesData", lt), s(S, "queryDevicesData", ut), s(S, "disableDevice", mt);
|
|
1927
1951
|
class ft extends Y {
|
|
1928
1952
|
constructor(t) {
|
|
1929
1953
|
super();
|
|
@@ -1935,12 +1959,12 @@ class ft extends Y {
|
|
|
1935
1959
|
async getLatestTelemetry() {
|
|
1936
1960
|
this.telemetryStreamActive || this.subscribeToTelemetry();
|
|
1937
1961
|
const t = this.streamTelemetry;
|
|
1938
|
-
return Object.entries(t).map(([i,
|
|
1962
|
+
return Object.entries(t).map(([i, r]) => ({
|
|
1939
1963
|
deviceId: this.id,
|
|
1940
1964
|
streamName: i,
|
|
1941
1965
|
streamType: "json",
|
|
1942
|
-
currentValue:
|
|
1943
|
-
currentValueTime:
|
|
1966
|
+
currentValue: r,
|
|
1967
|
+
currentValueTime: r.timestamp,
|
|
1944
1968
|
tags: {}
|
|
1945
1969
|
}));
|
|
1946
1970
|
}
|
|
@@ -1957,15 +1981,15 @@ class ft extends Y {
|
|
|
1957
1981
|
}), n.addEventListener("readystatechange", (i) => {
|
|
1958
1982
|
n.readyState === XMLHttpRequest.DONE && this.handleXHRError("closed");
|
|
1959
1983
|
}), n.addEventListener("progress", (i) => {
|
|
1960
|
-
const
|
|
1961
|
-
t =
|
|
1984
|
+
const r = i.loaded, c = r - t;
|
|
1985
|
+
t = r, n.responseText.substr(-c).split(`
|
|
1962
1986
|
`).forEach((m) => {
|
|
1963
1987
|
var w;
|
|
1964
1988
|
if (m.length > 0) {
|
|
1965
1989
|
const v = JSON.parse(m);
|
|
1966
1990
|
if ((w = v.result) != null && w.datapoint) {
|
|
1967
|
-
const C = v.result.datapoint,
|
|
1968
|
-
delete C.stream, this.streamTelemetry[
|
|
1991
|
+
const C = v.result.datapoint, A = C.stream;
|
|
1992
|
+
delete C.stream, this.streamTelemetry[A] = C;
|
|
1969
1993
|
}
|
|
1970
1994
|
}
|
|
1971
1995
|
});
|
|
@@ -1988,7 +2012,7 @@ class ft extends Y {
|
|
|
1988
2012
|
this.rtcClient && console.warn(
|
|
1989
2013
|
"overwriting existing rtcClient due to missing connectionMonitorInterval"
|
|
1990
2014
|
);
|
|
1991
|
-
const n = new
|
|
2015
|
+
const n = new R({
|
|
1992
2016
|
lanOnlyMode: !0,
|
|
1993
2017
|
receive: this.handleMessage,
|
|
1994
2018
|
sessionType: t
|
|
@@ -2027,11 +2051,11 @@ class ft extends Y {
|
|
|
2027
2051
|
if (t)
|
|
2028
2052
|
throw new Error(`Realtime connection hasn't been started for ${this.id}`);
|
|
2029
2053
|
}
|
|
2030
|
-
async sendCommand(t, n, i,
|
|
2054
|
+
async sendCommand(t, n, i, r) {
|
|
2031
2055
|
const c = {
|
|
2032
2056
|
value: n,
|
|
2033
2057
|
scrubberTime: (i || /* @__PURE__ */ new Date()).toISOString(),
|
|
2034
|
-
meta:
|
|
2058
|
+
meta: r
|
|
2035
2059
|
};
|
|
2036
2060
|
return await fetch(`${this.peerUrl}/v1/enqueue-command`, {
|
|
2037
2061
|
method: "POST",
|
|
@@ -2046,42 +2070,42 @@ class ft extends Y {
|
|
|
2046
2070
|
}
|
|
2047
2071
|
}
|
|
2048
2072
|
async function wt(a, e) {
|
|
2049
|
-
if (!
|
|
2073
|
+
if (!o.token)
|
|
2050
2074
|
throw new Error("Not authenticated");
|
|
2051
2075
|
return await (await fetch(`${h}/v1/admin/devices/${a}`, {
|
|
2052
2076
|
method: "PATCH",
|
|
2053
2077
|
body: JSON.stringify({ fleetId: e }),
|
|
2054
2078
|
headers: {
|
|
2055
2079
|
"Content-Type": "application/json",
|
|
2056
|
-
Authorization: "Bearer " +
|
|
2080
|
+
Authorization: "Bearer " + o.token
|
|
2057
2081
|
}
|
|
2058
2082
|
})).json();
|
|
2059
2083
|
}
|
|
2060
2084
|
async function pt(a) {
|
|
2061
|
-
if (!
|
|
2085
|
+
if (!o.token)
|
|
2062
2086
|
throw new Error("Not authenticated");
|
|
2063
2087
|
return (await (await fetch(`${h}/v1/queries/queries`, {
|
|
2064
2088
|
method: "POST",
|
|
2065
2089
|
body: JSON.stringify(a),
|
|
2066
2090
|
headers: {
|
|
2067
2091
|
"Content-Type": "application/json",
|
|
2068
|
-
Authorization: "Bearer " +
|
|
2092
|
+
Authorization: "Bearer " + o.token
|
|
2069
2093
|
}
|
|
2070
2094
|
})).json()).aggregates;
|
|
2071
2095
|
}
|
|
2072
2096
|
async function yt(a) {
|
|
2073
|
-
if (!
|
|
2097
|
+
if (!o.token)
|
|
2074
2098
|
throw new Error("Not authenticated");
|
|
2075
2099
|
await fetch(`${h}/v1/admin/fleets/${a}`, {
|
|
2076
2100
|
method: "DELETE",
|
|
2077
2101
|
headers: {
|
|
2078
2102
|
"Content-Type": "application/json",
|
|
2079
|
-
Authorization: "Bearer " +
|
|
2103
|
+
Authorization: "Bearer " + o.token
|
|
2080
2104
|
}
|
|
2081
2105
|
});
|
|
2082
2106
|
}
|
|
2083
2107
|
async function gt() {
|
|
2084
|
-
if (!
|
|
2108
|
+
if (!o.token)
|
|
2085
2109
|
throw new Error("Not authenticated");
|
|
2086
2110
|
return (await (await fetch(
|
|
2087
2111
|
`${h}/v1/queries/analytics/streams`,
|
|
@@ -2089,13 +2113,13 @@ async function gt() {
|
|
|
2089
2113
|
method: "GET",
|
|
2090
2114
|
headers: {
|
|
2091
2115
|
"Content-Type": "application/json",
|
|
2092
|
-
Authorization: "Bearer " +
|
|
2116
|
+
Authorization: "Bearer " + o.token
|
|
2093
2117
|
}
|
|
2094
2118
|
}
|
|
2095
2119
|
)).json()).items;
|
|
2096
2120
|
}
|
|
2097
2121
|
async function vt() {
|
|
2098
|
-
if (!
|
|
2122
|
+
if (!o.token)
|
|
2099
2123
|
throw new Error("Not authenticated");
|
|
2100
2124
|
return (await (await fetch(
|
|
2101
2125
|
`${h}/v1/admin/analytics-modules`,
|
|
@@ -2103,39 +2127,39 @@ async function vt() {
|
|
|
2103
2127
|
method: "GET",
|
|
2104
2128
|
headers: {
|
|
2105
2129
|
"Content-Type": "application/json",
|
|
2106
|
-
Authorization: "Bearer " +
|
|
2130
|
+
Authorization: "Bearer " + o.token
|
|
2107
2131
|
}
|
|
2108
2132
|
}
|
|
2109
2133
|
)).json()).items;
|
|
2110
2134
|
}
|
|
2111
2135
|
async function Tt(a) {
|
|
2112
|
-
if (!
|
|
2136
|
+
if (!o.token)
|
|
2113
2137
|
throw new Error("Not authenticated");
|
|
2114
2138
|
return await (await fetch(`${h}/v1/queries/analytics/rows`, {
|
|
2115
2139
|
method: "POST",
|
|
2116
2140
|
body: JSON.stringify(a),
|
|
2117
2141
|
headers: {
|
|
2118
2142
|
"Content-Type": "application/json",
|
|
2119
|
-
Authorization: "Bearer " +
|
|
2143
|
+
Authorization: "Bearer " + o.token
|
|
2120
2144
|
}
|
|
2121
2145
|
})).json();
|
|
2122
2146
|
}
|
|
2123
2147
|
async function se(a) {
|
|
2124
|
-
if (!
|
|
2148
|
+
if (!o.token)
|
|
2125
2149
|
throw new Error("Not authenticated");
|
|
2126
2150
|
return (await (await fetch(`${h}/v1/admin/devices/query`, {
|
|
2127
2151
|
method: "POST",
|
|
2128
2152
|
body: JSON.stringify(a),
|
|
2129
2153
|
headers: {
|
|
2130
2154
|
"Content-Type": "application/json",
|
|
2131
|
-
Authorization: "Bearer " +
|
|
2155
|
+
Authorization: "Bearer " + o.token
|
|
2132
2156
|
}
|
|
2133
2157
|
})).json()).items.map(
|
|
2134
|
-
(n) => new
|
|
2158
|
+
(n) => new S(n.id, n.name, n.organizationId, n.tags)
|
|
2135
2159
|
);
|
|
2136
2160
|
}
|
|
2137
2161
|
async function Ct() {
|
|
2138
|
-
if (!
|
|
2162
|
+
if (!o.token)
|
|
2139
2163
|
throw new Error("Not authenticated");
|
|
2140
2164
|
let a = new URLSearchParams("");
|
|
2141
2165
|
typeof window < "u" && window.location && (a = new URLSearchParams(window.location.search));
|
|
@@ -2147,7 +2171,7 @@ async function Ct() {
|
|
|
2147
2171
|
{
|
|
2148
2172
|
headers: {
|
|
2149
2173
|
"Content-Type": "application/json",
|
|
2150
|
-
Authorization: "Bearer " +
|
|
2174
|
+
Authorization: "Bearer " + o.token
|
|
2151
2175
|
}
|
|
2152
2176
|
}
|
|
2153
2177
|
), { tagKey: n, tagValue: i } = await t.json();
|
|
@@ -2157,40 +2181,40 @@ async function Ct() {
|
|
|
2157
2181
|
type: "default"
|
|
2158
2182
|
});
|
|
2159
2183
|
}
|
|
2160
|
-
async function
|
|
2161
|
-
if (!
|
|
2184
|
+
async function St(a) {
|
|
2185
|
+
if (!o.token)
|
|
2162
2186
|
throw new Error("Not authenticated");
|
|
2163
2187
|
const t = await (await fetch(`${h}/v1/admin/devices/${a}`, {
|
|
2164
2188
|
method: "GET",
|
|
2165
2189
|
headers: {
|
|
2166
2190
|
"Content-Type": "application/json",
|
|
2167
|
-
Authorization: "Bearer " +
|
|
2191
|
+
Authorization: "Bearer " + o.token
|
|
2168
2192
|
}
|
|
2169
2193
|
})).json(), n = t.name;
|
|
2170
|
-
return new
|
|
2194
|
+
return new S(a, n, t.organizationId, t.tags);
|
|
2171
2195
|
}
|
|
2172
|
-
async function
|
|
2173
|
-
if (!
|
|
2196
|
+
async function x() {
|
|
2197
|
+
if (!o.token)
|
|
2174
2198
|
throw new Error("Not authenticated");
|
|
2175
2199
|
const e = await (await fetch(`${h}/v1/admin/device-details/query`, {
|
|
2176
2200
|
method: "POST",
|
|
2177
2201
|
body: JSON.stringify({ enabled: !0, type: "default" }),
|
|
2178
2202
|
headers: {
|
|
2179
2203
|
"Content-Type": "application/json",
|
|
2180
|
-
Authorization: "Bearer " +
|
|
2204
|
+
Authorization: "Bearer " + o.token
|
|
2181
2205
|
}
|
|
2182
2206
|
})).json();
|
|
2183
2207
|
return e.items, e.items.map(
|
|
2184
|
-
(t) => new
|
|
2208
|
+
(t) => new S(
|
|
2185
2209
|
t.id,
|
|
2186
2210
|
t.name,
|
|
2187
|
-
|
|
2211
|
+
f(o.currentOrganization),
|
|
2188
2212
|
t.tags
|
|
2189
2213
|
)
|
|
2190
2214
|
);
|
|
2191
2215
|
}
|
|
2192
|
-
async function
|
|
2193
|
-
if (!
|
|
2216
|
+
async function Et(a) {
|
|
2217
|
+
if (!o.token)
|
|
2194
2218
|
throw new Error("Not authenticated");
|
|
2195
2219
|
return (await (await fetch(
|
|
2196
2220
|
`${h}/v1/admin/events/query/id=${a}`,
|
|
@@ -2198,7 +2222,7 @@ async function St(a) {
|
|
|
2198
2222
|
method: "GET",
|
|
2199
2223
|
headers: {
|
|
2200
2224
|
"Content-Type": "application/json",
|
|
2201
|
-
Authorization: "Bearer " +
|
|
2225
|
+
Authorization: "Bearer " + o.token
|
|
2202
2226
|
}
|
|
2203
2227
|
}
|
|
2204
2228
|
)).json()).items;
|
|
@@ -2211,7 +2235,7 @@ async function kt(a) {
|
|
|
2211
2235
|
}),
|
|
2212
2236
|
headers: {
|
|
2213
2237
|
"Content-Type": "application/json",
|
|
2214
|
-
Authorization: "Bearer " +
|
|
2238
|
+
Authorization: "Bearer " + o.token
|
|
2215
2239
|
}
|
|
2216
2240
|
})).json();
|
|
2217
2241
|
if (t.fileUrls.length === 0)
|
|
@@ -2219,29 +2243,29 @@ async function kt(a) {
|
|
|
2219
2243
|
return t.fileUrls[0];
|
|
2220
2244
|
}
|
|
2221
2245
|
async function Ot(a) {
|
|
2222
|
-
if (!
|
|
2246
|
+
if (!o.token)
|
|
2223
2247
|
throw new Error("Not authenticated");
|
|
2224
2248
|
return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
|
|
2225
2249
|
method: "GET",
|
|
2226
2250
|
headers: {
|
|
2227
2251
|
"Content-Type": "application/json",
|
|
2228
|
-
Authorization: "Bearer " +
|
|
2252
|
+
Authorization: "Bearer " + o.token
|
|
2229
2253
|
}
|
|
2230
2254
|
})).json();
|
|
2231
2255
|
}
|
|
2232
2256
|
async function Rt(a) {
|
|
2233
|
-
if (!
|
|
2257
|
+
if (!o.token)
|
|
2234
2258
|
throw new Error("Not authenticated");
|
|
2235
2259
|
return (await (await fetch(`${h}/v1/admin/fleets/${a}/devices`, {
|
|
2236
2260
|
method: "GET",
|
|
2237
2261
|
headers: {
|
|
2238
2262
|
"Content-Type": "application/json",
|
|
2239
|
-
Authorization: "Bearer " +
|
|
2263
|
+
Authorization: "Bearer " + o.token
|
|
2240
2264
|
}
|
|
2241
2265
|
})).json()).items;
|
|
2242
2266
|
}
|
|
2243
|
-
async function
|
|
2244
|
-
if (!
|
|
2267
|
+
async function bt() {
|
|
2268
|
+
if (!o.token)
|
|
2245
2269
|
throw new Error("Not authenticated");
|
|
2246
2270
|
return (await (await fetch(
|
|
2247
2271
|
`${h}/v1/admin/intervention-requests`,
|
|
@@ -2249,12 +2273,12 @@ async function At() {
|
|
|
2249
2273
|
method: "GET",
|
|
2250
2274
|
headers: {
|
|
2251
2275
|
"Content-Type": "application/json",
|
|
2252
|
-
Authorization: "Bearer " +
|
|
2276
|
+
Authorization: "Bearer " + o.token
|
|
2253
2277
|
}
|
|
2254
2278
|
}
|
|
2255
2279
|
)).json()).items;
|
|
2256
2280
|
}
|
|
2257
|
-
async function
|
|
2281
|
+
async function At(...a) {
|
|
2258
2282
|
const e = a.flat().filter((i) => !!i);
|
|
2259
2283
|
return e.length === 0 ? [] : (await (await fetch(
|
|
2260
2284
|
`${h}/v1/queries/stream-current-value`,
|
|
@@ -2265,52 +2289,52 @@ async function bt(...a) {
|
|
|
2265
2289
|
}),
|
|
2266
2290
|
headers: {
|
|
2267
2291
|
"Content-Type": "application/json",
|
|
2268
|
-
Authorization: "Bearer " +
|
|
2292
|
+
Authorization: "Bearer " + o.token
|
|
2269
2293
|
}
|
|
2270
2294
|
}
|
|
2271
2295
|
)).json()).items;
|
|
2272
2296
|
}
|
|
2273
2297
|
async function jt() {
|
|
2274
|
-
if (!
|
|
2298
|
+
if (!o.token)
|
|
2275
2299
|
throw new Error("Not authenticated");
|
|
2276
2300
|
const t = (await (await fetch(`${h}/v1/queries/online-devices`, {
|
|
2277
2301
|
method: "GET",
|
|
2278
2302
|
headers: {
|
|
2279
2303
|
"Content-Type": "application/json",
|
|
2280
|
-
Authorization: "Bearer " +
|
|
2304
|
+
Authorization: "Bearer " + o.token
|
|
2281
2305
|
}
|
|
2282
2306
|
})).json()).items;
|
|
2283
|
-
return (await
|
|
2307
|
+
return (await x()).filter((i) => t.includes(i.id));
|
|
2284
2308
|
}
|
|
2285
2309
|
async function Dt() {
|
|
2286
|
-
if (!
|
|
2310
|
+
if (!o.token)
|
|
2287
2311
|
throw new Error("Not authenticated");
|
|
2288
2312
|
const t = (await (await fetch(`${h}/v1/signaling/peers`, {
|
|
2289
2313
|
method: "GET",
|
|
2290
2314
|
headers: {
|
|
2291
2315
|
"Content-Type": "application/json",
|
|
2292
|
-
Authorization: "Bearer " +
|
|
2316
|
+
Authorization: "Bearer " + o.token
|
|
2293
2317
|
}
|
|
2294
2318
|
})).json()).items.map(
|
|
2295
2319
|
(i) => i.deviceId
|
|
2296
2320
|
);
|
|
2297
|
-
return (await
|
|
2321
|
+
return (await x()).filter((i) => t.includes(i.id));
|
|
2298
2322
|
}
|
|
2299
2323
|
async function Nt() {
|
|
2300
|
-
if (!
|
|
2324
|
+
if (!o.token)
|
|
2301
2325
|
throw new Error("Not authenticated");
|
|
2302
2326
|
return (await (await fetch(`${h}/v1/admin/streams`, {
|
|
2303
2327
|
method: "GET",
|
|
2304
2328
|
headers: {
|
|
2305
2329
|
"Content-Type": "application/json",
|
|
2306
|
-
Authorization: "Bearer " +
|
|
2330
|
+
Authorization: "Bearer " + o.token
|
|
2307
2331
|
}
|
|
2308
2332
|
})).json()).items.filter(
|
|
2309
2333
|
(t) => t.enabled
|
|
2310
2334
|
);
|
|
2311
2335
|
}
|
|
2312
2336
|
async function Pt(a) {
|
|
2313
|
-
if (!
|
|
2337
|
+
if (!o.token)
|
|
2314
2338
|
throw new Error("Not authenticated");
|
|
2315
2339
|
return await (await fetch(
|
|
2316
2340
|
`${h}/v1/queries/analytics/task-report-rows`,
|
|
@@ -2319,13 +2343,13 @@ async function Pt(a) {
|
|
|
2319
2343
|
body: JSON.stringify(a),
|
|
2320
2344
|
headers: {
|
|
2321
2345
|
"Content-Type": "application/json",
|
|
2322
|
-
Authorization: "Bearer " +
|
|
2346
|
+
Authorization: "Bearer " + o.token
|
|
2323
2347
|
}
|
|
2324
2348
|
}
|
|
2325
2349
|
)).json();
|
|
2326
2350
|
}
|
|
2327
2351
|
async function Lt() {
|
|
2328
|
-
if (!
|
|
2352
|
+
if (!o.token)
|
|
2329
2353
|
throw new Error("Not authenticated");
|
|
2330
2354
|
return (await (await fetch(
|
|
2331
2355
|
`${h}/v1/queries/analytics/task-reports`,
|
|
@@ -2333,36 +2357,36 @@ async function Lt() {
|
|
|
2333
2357
|
method: "GET",
|
|
2334
2358
|
headers: {
|
|
2335
2359
|
"Content-Type": "application/json",
|
|
2336
|
-
Authorization: "Bearer " +
|
|
2360
|
+
Authorization: "Bearer " + o.token
|
|
2337
2361
|
}
|
|
2338
2362
|
}
|
|
2339
2363
|
)).json()).items;
|
|
2340
2364
|
}
|
|
2341
2365
|
async function It() {
|
|
2342
|
-
if (!
|
|
2366
|
+
if (!o.token)
|
|
2343
2367
|
throw new Error("Not authenticated");
|
|
2344
2368
|
return (await (await fetch(`${h}/v1/admin/fleets`, {
|
|
2345
2369
|
method: "GET",
|
|
2346
2370
|
headers: {
|
|
2347
2371
|
"Content-Type": "application/json",
|
|
2348
|
-
Authorization: "Bearer " +
|
|
2372
|
+
Authorization: "Bearer " + o.token
|
|
2349
2373
|
}
|
|
2350
2374
|
})).json()).items;
|
|
2351
2375
|
}
|
|
2352
|
-
async function
|
|
2353
|
-
if (!
|
|
2376
|
+
async function $t(a, e) {
|
|
2377
|
+
if (!o.token)
|
|
2354
2378
|
throw new Error("Not authenticated");
|
|
2355
2379
|
return await (await fetch(`${h}/v1/admin/fleets/${a}`, {
|
|
2356
2380
|
method: "PATCH",
|
|
2357
2381
|
body: JSON.stringify(e),
|
|
2358
2382
|
headers: {
|
|
2359
2383
|
"Content-Type": "application/json",
|
|
2360
|
-
Authorization: "Bearer " +
|
|
2384
|
+
Authorization: "Bearer " + o.token
|
|
2361
2385
|
}
|
|
2362
2386
|
})).json();
|
|
2363
2387
|
}
|
|
2364
|
-
async function
|
|
2365
|
-
if (!
|
|
2388
|
+
async function zt(a) {
|
|
2389
|
+
if (!o.token)
|
|
2366
2390
|
throw new Error("Not authenticated");
|
|
2367
2391
|
return await (await fetch(
|
|
2368
2392
|
`${h}/v1/admin/streams/${a.id}`,
|
|
@@ -2371,60 +2395,60 @@ async function $t(a) {
|
|
|
2371
2395
|
body: JSON.stringify(a),
|
|
2372
2396
|
headers: {
|
|
2373
2397
|
"Content-Type": "application/json",
|
|
2374
|
-
Authorization: "Bearer " +
|
|
2398
|
+
Authorization: "Bearer " + o.token
|
|
2375
2399
|
}
|
|
2376
2400
|
}
|
|
2377
2401
|
)).json();
|
|
2378
2402
|
}
|
|
2379
|
-
async function
|
|
2380
|
-
if (!
|
|
2403
|
+
async function Bt(a) {
|
|
2404
|
+
if (!o.token)
|
|
2381
2405
|
throw new Error("Not authenticated");
|
|
2382
2406
|
return await (await fetch(`${h}/v1/admin/views/${a.id}`, {
|
|
2383
2407
|
method: "PATCH",
|
|
2384
2408
|
body: JSON.stringify(a),
|
|
2385
2409
|
headers: {
|
|
2386
2410
|
"Content-Type": "application/json",
|
|
2387
|
-
Authorization: "Bearer " +
|
|
2411
|
+
Authorization: "Bearer " + o.token
|
|
2388
2412
|
}
|
|
2389
2413
|
})).json();
|
|
2390
2414
|
}
|
|
2391
|
-
async function
|
|
2392
|
-
if (!
|
|
2415
|
+
async function Mt(a) {
|
|
2416
|
+
if (!o.token)
|
|
2393
2417
|
throw new Error("Not authenticated");
|
|
2394
2418
|
return await (await fetch(`${h}/v1/queries/analytics`, {
|
|
2395
2419
|
method: "POST",
|
|
2396
2420
|
body: JSON.stringify(a),
|
|
2397
2421
|
headers: {
|
|
2398
2422
|
"Content-Type": "application/json",
|
|
2399
|
-
Authorization: "Bearer " +
|
|
2423
|
+
Authorization: "Bearer " + o.token
|
|
2400
2424
|
}
|
|
2401
2425
|
})).json();
|
|
2402
2426
|
}
|
|
2403
|
-
async function
|
|
2404
|
-
if (!
|
|
2427
|
+
async function qt(a) {
|
|
2428
|
+
if (!o.token)
|
|
2405
2429
|
throw new Error("Not authenticated");
|
|
2406
2430
|
return await (await fetch(`${h}/v1/admin/fleets`, {
|
|
2407
2431
|
method: "POST",
|
|
2408
2432
|
body: JSON.stringify(a),
|
|
2409
2433
|
headers: {
|
|
2410
2434
|
"Content-Type": "application/json",
|
|
2411
|
-
Authorization: "Bearer " +
|
|
2435
|
+
Authorization: "Bearer " + o.token
|
|
2412
2436
|
}
|
|
2413
2437
|
})).json();
|
|
2414
2438
|
}
|
|
2415
|
-
async function
|
|
2416
|
-
if (!
|
|
2439
|
+
async function xt() {
|
|
2440
|
+
if (!o.token)
|
|
2417
2441
|
throw new Error("Not authenticated");
|
|
2418
2442
|
return (await (await fetch(`${h}/v1/admin/event-trigger-groups`, {
|
|
2419
2443
|
method: "GET",
|
|
2420
2444
|
headers: {
|
|
2421
2445
|
"Content-Type": "application/json",
|
|
2422
|
-
Authorization: "Bearer " +
|
|
2446
|
+
Authorization: "Bearer " + o.token
|
|
2423
2447
|
}
|
|
2424
2448
|
})).json()).items;
|
|
2425
2449
|
}
|
|
2426
|
-
async function
|
|
2427
|
-
if (!
|
|
2450
|
+
async function Ut(a) {
|
|
2451
|
+
if (!o.token)
|
|
2428
2452
|
throw new Error("Not authenticated");
|
|
2429
2453
|
return await (await fetch(
|
|
2430
2454
|
`${h}/v1/admin/event-trigger-groups/${a}`,
|
|
@@ -2432,13 +2456,13 @@ async function xt(a) {
|
|
|
2432
2456
|
method: "GET",
|
|
2433
2457
|
headers: {
|
|
2434
2458
|
"Content-Type": "application/json",
|
|
2435
|
-
Authorization: "Bearer " +
|
|
2459
|
+
Authorization: "Bearer " + o.token
|
|
2436
2460
|
}
|
|
2437
2461
|
}
|
|
2438
2462
|
)).json();
|
|
2439
2463
|
}
|
|
2440
|
-
async function
|
|
2441
|
-
if (!
|
|
2464
|
+
async function _t(a, e) {
|
|
2465
|
+
if (!o.token)
|
|
2442
2466
|
throw new Error("Not authenticated");
|
|
2443
2467
|
return await (await fetch(
|
|
2444
2468
|
`${h}/v1/admin/event-trigger-groups/${a}`,
|
|
@@ -2447,19 +2471,19 @@ async function Ut(a, e) {
|
|
|
2447
2471
|
body: JSON.stringify(e),
|
|
2448
2472
|
headers: {
|
|
2449
2473
|
"Content-Type": "application/json",
|
|
2450
|
-
Authorization: "Bearer " +
|
|
2474
|
+
Authorization: "Bearer " + o.token
|
|
2451
2475
|
}
|
|
2452
2476
|
}
|
|
2453
2477
|
)).json();
|
|
2454
2478
|
}
|
|
2455
|
-
const
|
|
2479
|
+
const l = class l {
|
|
2456
2480
|
static async setDefaultDevice(e) {
|
|
2457
|
-
|
|
2481
|
+
l.defaultDeviceId = e;
|
|
2458
2482
|
}
|
|
2459
2483
|
static async getCurrentDevice() {
|
|
2460
|
-
if (!
|
|
2484
|
+
if (!o.token)
|
|
2461
2485
|
throw new Error("Not authenticated");
|
|
2462
|
-
if (!
|
|
2486
|
+
if (!l.defaultDeviceId)
|
|
2463
2487
|
throw new Error("No known default device");
|
|
2464
2488
|
const n = (await (await fetch(
|
|
2465
2489
|
`${h}/v1/admin/device-details/query`,
|
|
@@ -2467,48 +2491,48 @@ const S = class {
|
|
|
2467
2491
|
method: "POST",
|
|
2468
2492
|
headers: {
|
|
2469
2493
|
"Content-Type": "application/json",
|
|
2470
|
-
Authorization: "Bearer " +
|
|
2494
|
+
Authorization: "Bearer " + o.token
|
|
2471
2495
|
}
|
|
2472
2496
|
}
|
|
2473
2497
|
)).json()).items.find(
|
|
2474
|
-
(c) => c.id ===
|
|
2475
|
-
), i = n.name,
|
|
2476
|
-
|
|
2498
|
+
(c) => c.id === l.defaultDeviceId
|
|
2499
|
+
), i = n.name, r = new S(
|
|
2500
|
+
l.defaultDeviceId,
|
|
2477
2501
|
i,
|
|
2478
|
-
f(
|
|
2502
|
+
f(o.currentOrganization),
|
|
2479
2503
|
n.tags
|
|
2480
2504
|
);
|
|
2481
|
-
return
|
|
2505
|
+
return l.knownContext.push(new WeakRef(r)), r;
|
|
2482
2506
|
}
|
|
2483
2507
|
static async getPeerDevice(e) {
|
|
2484
2508
|
const t = new ft(e);
|
|
2485
2509
|
return t.id = await t.getDeviceId(), t;
|
|
2486
2510
|
}
|
|
2487
2511
|
static async getDevice(e) {
|
|
2488
|
-
const t = await
|
|
2489
|
-
return
|
|
2512
|
+
const t = await St(e);
|
|
2513
|
+
return l.knownContext.push(new WeakRef(t)), t;
|
|
2490
2514
|
}
|
|
2491
2515
|
};
|
|
2492
|
-
|
|
2493
|
-
|
|
2516
|
+
s(l, "defaultDeviceId"), s(l, "knownContext", []), s(l, "createFleet", qt), 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", q), s(l, "getAnnotationCountByIntervals", ae), s(l, "getCurrentGroup", Ct), s(l, "getDevices", x), s(l, "getEvent", Et), s(l, "getFileUrl", kt), s(l, "getInterventions", bt), s(l, "getLatestTelemetry", At), s(l, "getOnlineDevices", jt), s(l, "getPeers", re), s(l, "getRealtimeDevices", Dt), s(l, "getRealtimeSessions", oe), s(l, "getStreams", Nt), s(l, "getTaskReportRows", Pt), s(l, "getTaskReportTables", Lt), s(l, "getTelemetry", ie), s(l, "getViews", Z), s(l, "patchStream", zt), s(l, "patchView", Bt), s(l, "queryAnalytics", Mt), s(l, "queryDevices", se), s(l, "queryEvents", M), s(l, "queryTelemetry", I), s(l, "getAllEventTriggerGroup", xt), s(l, "getEventTriggerGroup", Ut), s(l, "patchEventTriggergroup", _t);
|
|
2517
|
+
let z = l;
|
|
2494
2518
|
class an {
|
|
2495
2519
|
static async set(e, t, n) {
|
|
2496
2520
|
try {
|
|
2497
2521
|
const i = await fetch(h + "/v1/admin/key-value", {
|
|
2498
2522
|
method: "POST",
|
|
2499
2523
|
body: JSON.stringify({
|
|
2500
|
-
organizationId: f(
|
|
2524
|
+
organizationId: f(o.currentUser).organizationId,
|
|
2501
2525
|
key: e,
|
|
2502
2526
|
value: t,
|
|
2503
2527
|
tags: n
|
|
2504
2528
|
}),
|
|
2505
2529
|
headers: {
|
|
2506
2530
|
"Content-Type": "application/json",
|
|
2507
|
-
Authorization: "Bearer " +
|
|
2531
|
+
Authorization: "Bearer " + o.token
|
|
2508
2532
|
}
|
|
2509
|
-
}),
|
|
2533
|
+
}), r = await i.json();
|
|
2510
2534
|
if (i.status !== 200)
|
|
2511
|
-
throw new Error(
|
|
2535
|
+
throw new Error(r.message);
|
|
2512
2536
|
} catch (i) {
|
|
2513
2537
|
throw i;
|
|
2514
2538
|
}
|
|
@@ -2521,7 +2545,7 @@ class an {
|
|
|
2521
2545
|
method: "GET",
|
|
2522
2546
|
headers: {
|
|
2523
2547
|
"Content-Type": "application/json",
|
|
2524
|
-
Authorization: "Bearer " +
|
|
2548
|
+
Authorization: "Bearer " + o.token
|
|
2525
2549
|
}
|
|
2526
2550
|
}
|
|
2527
2551
|
), n = await t.json();
|
|
@@ -2538,7 +2562,7 @@ class an {
|
|
|
2538
2562
|
method: "GET",
|
|
2539
2563
|
headers: {
|
|
2540
2564
|
"Content-Type": "application/json",
|
|
2541
|
-
Authorization: "Bearer " +
|
|
2565
|
+
Authorization: "Bearer " + o.token
|
|
2542
2566
|
}
|
|
2543
2567
|
}), t = await e.json();
|
|
2544
2568
|
if (e.status !== 200)
|
|
@@ -2556,7 +2580,7 @@ class an {
|
|
|
2556
2580
|
method: "DELETE",
|
|
2557
2581
|
headers: {
|
|
2558
2582
|
"Content-Type": "application/json",
|
|
2559
|
-
Authorization: "Bearer " +
|
|
2583
|
+
Authorization: "Bearer " + o.token
|
|
2560
2584
|
}
|
|
2561
2585
|
}
|
|
2562
2586
|
)).ok)
|
|
@@ -2575,7 +2599,7 @@ class an {
|
|
|
2575
2599
|
body: JSON.stringify({ keys: e }),
|
|
2576
2600
|
headers: {
|
|
2577
2601
|
"Content-Type": "application/json",
|
|
2578
|
-
Authorization: "Bearer " +
|
|
2602
|
+
Authorization: "Bearer " + o.token
|
|
2579
2603
|
}
|
|
2580
2604
|
}
|
|
2581
2605
|
);
|
|
@@ -2614,10 +2638,10 @@ class on {
|
|
|
2614
2638
|
const { audioContext: n, muted: i } = this;
|
|
2615
2639
|
if (!n || e.header.stream.streamType !== Vt || i !== !1)
|
|
2616
2640
|
return;
|
|
2617
|
-
const
|
|
2641
|
+
const r = Jt(t);
|
|
2618
2642
|
try {
|
|
2619
2643
|
await n.decodeAudioData(
|
|
2620
|
-
|
|
2644
|
+
r.buffer,
|
|
2621
2645
|
this.scheduleChunk
|
|
2622
2646
|
);
|
|
2623
2647
|
} catch (d) {
|
|
@@ -2637,8 +2661,8 @@ class on {
|
|
|
2637
2661
|
const n = this.createChunk(e);
|
|
2638
2662
|
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));
|
|
2639
2663
|
});
|
|
2640
|
-
this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i,
|
|
2641
|
-
this.receive(
|
|
2664
|
+
this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, r) => {
|
|
2665
|
+
this.receive(r);
|
|
2642
2666
|
}), V() === "Safari" || V() === "IE" ? this.changeAudioWireFormat("wav") : this.changeAudioWireFormat("opus");
|
|
2643
2667
|
const n = window.AudioContext || window.webkitAudioContext;
|
|
2644
2668
|
this.audioContext = new n();
|
|
@@ -2669,65 +2693,65 @@ class on {
|
|
|
2669
2693
|
}
|
|
2670
2694
|
class rn {
|
|
2671
2695
|
static async listAccounts() {
|
|
2672
|
-
if (!
|
|
2696
|
+
if (!o.token)
|
|
2673
2697
|
throw new Error("Not authenticated");
|
|
2674
2698
|
return (await (await fetch(`${h}/v1/admin/accounts`, {
|
|
2675
2699
|
method: "GET",
|
|
2676
2700
|
headers: {
|
|
2677
2701
|
"Content-Type": "application/json",
|
|
2678
|
-
Authorization: "Bearer " +
|
|
2702
|
+
Authorization: "Bearer " + o.token
|
|
2679
2703
|
}
|
|
2680
2704
|
})).json()).items;
|
|
2681
2705
|
}
|
|
2682
2706
|
static async createAccounts(e) {
|
|
2683
|
-
if (!
|
|
2707
|
+
if (!o.token)
|
|
2684
2708
|
throw new Error("Not authenticated");
|
|
2685
2709
|
return await (await fetch(`${h}/v1/admin/accounts`, {
|
|
2686
2710
|
method: "POST",
|
|
2687
2711
|
body: JSON.stringify(e),
|
|
2688
2712
|
headers: {
|
|
2689
2713
|
"Content-Type": "application/json",
|
|
2690
|
-
Authorization: "Bearer " +
|
|
2714
|
+
Authorization: "Bearer " + o.token
|
|
2691
2715
|
}
|
|
2692
2716
|
})).json();
|
|
2693
2717
|
}
|
|
2694
2718
|
static async getAccount(e) {
|
|
2695
|
-
if (!
|
|
2719
|
+
if (!o.token)
|
|
2696
2720
|
throw new Error("Not authenticated");
|
|
2697
2721
|
return await (await fetch(`${h}/v1/admin/accounts/${e}`, {
|
|
2698
2722
|
method: "GET",
|
|
2699
2723
|
headers: {
|
|
2700
2724
|
"Content-Type": "application/json",
|
|
2701
|
-
Authorization: "Bearer " +
|
|
2725
|
+
Authorization: "Bearer " + o.token
|
|
2702
2726
|
}
|
|
2703
2727
|
})).json();
|
|
2704
2728
|
}
|
|
2705
2729
|
static async patchAccount(e, t) {
|
|
2706
|
-
if (!
|
|
2730
|
+
if (!o.token)
|
|
2707
2731
|
throw new Error("Not authenticated");
|
|
2708
2732
|
return await (await fetch(`${h}/v1/admin/accounts/${e}`, {
|
|
2709
2733
|
method: "PATCH",
|
|
2710
2734
|
body: JSON.stringify(t),
|
|
2711
2735
|
headers: {
|
|
2712
2736
|
"Content-Type": "application/json",
|
|
2713
|
-
Authorization: "Bearer " +
|
|
2737
|
+
Authorization: "Bearer " + o.token
|
|
2714
2738
|
}
|
|
2715
2739
|
})).json();
|
|
2716
2740
|
}
|
|
2717
2741
|
static async deleteAccount(e) {
|
|
2718
|
-
if (!
|
|
2742
|
+
if (!o.token)
|
|
2719
2743
|
throw new Error("Not authenticated");
|
|
2720
2744
|
if (!(await fetch(`${h}/v1/admin/accounts/${e}`, {
|
|
2721
2745
|
method: "DELETE",
|
|
2722
2746
|
headers: {
|
|
2723
2747
|
"Content-Type": "application/json",
|
|
2724
|
-
Authorization: "Bearer " +
|
|
2748
|
+
Authorization: "Bearer " + o.token
|
|
2725
2749
|
}
|
|
2726
2750
|
})).ok)
|
|
2727
2751
|
throw new Error("Unable to delete account");
|
|
2728
2752
|
}
|
|
2729
2753
|
static async getAccountTree(e) {
|
|
2730
|
-
if (!
|
|
2754
|
+
if (!o.token)
|
|
2731
2755
|
throw new Error("Not authenticated");
|
|
2732
2756
|
return await (await fetch(
|
|
2733
2757
|
`${h}/v1/admin/accounts/${e}/tree`,
|
|
@@ -2735,7 +2759,7 @@ class rn {
|
|
|
2735
2759
|
method: "GET",
|
|
2736
2760
|
headers: {
|
|
2737
2761
|
"Content-Type": "application/json",
|
|
2738
|
-
Authorization: "Bearer " +
|
|
2762
|
+
Authorization: "Bearer " + o.token
|
|
2739
2763
|
}
|
|
2740
2764
|
}
|
|
2741
2765
|
)).json();
|
|
@@ -2743,119 +2767,119 @@ class rn {
|
|
|
2743
2767
|
}
|
|
2744
2768
|
class sn {
|
|
2745
2769
|
static async listRoles() {
|
|
2746
|
-
if (!
|
|
2770
|
+
if (!o.token)
|
|
2747
2771
|
throw new Error("Not authenticated");
|
|
2748
2772
|
return (await (await fetch(`${h}/v1/admin/roles`, {
|
|
2749
2773
|
method: "GET",
|
|
2750
2774
|
headers: {
|
|
2751
2775
|
"Content-Type": "application/json",
|
|
2752
|
-
Authorization: "Bearer " +
|
|
2776
|
+
Authorization: "Bearer " + o.token
|
|
2753
2777
|
}
|
|
2754
2778
|
})).json()).items;
|
|
2755
2779
|
}
|
|
2756
2780
|
static async createRole(e) {
|
|
2757
|
-
if (!
|
|
2781
|
+
if (!o.token)
|
|
2758
2782
|
throw new Error("Not authenticated");
|
|
2759
2783
|
return await (await fetch(`${h}/v1/admin/roles`, {
|
|
2760
2784
|
method: "POST",
|
|
2761
2785
|
body: JSON.stringify(e),
|
|
2762
2786
|
headers: {
|
|
2763
2787
|
"Content-Type": "application/json",
|
|
2764
|
-
Authorization: "Bearer " +
|
|
2788
|
+
Authorization: "Bearer " + o.token
|
|
2765
2789
|
}
|
|
2766
2790
|
})).json();
|
|
2767
2791
|
}
|
|
2768
2792
|
static async getRole(e) {
|
|
2769
|
-
if (!
|
|
2793
|
+
if (!o.token)
|
|
2770
2794
|
throw new Error("Not authenticated");
|
|
2771
2795
|
return await (await fetch(`${h}/v1/admin/roles/${e}`, {
|
|
2772
2796
|
method: "GET",
|
|
2773
2797
|
headers: {
|
|
2774
2798
|
"Content-Type": "application/json",
|
|
2775
|
-
Authorization: "Bearer " +
|
|
2799
|
+
Authorization: "Bearer " + o.token
|
|
2776
2800
|
}
|
|
2777
2801
|
})).json();
|
|
2778
2802
|
}
|
|
2779
2803
|
static async patchRole(e, t) {
|
|
2780
|
-
if (!
|
|
2804
|
+
if (!o.token)
|
|
2781
2805
|
throw new Error("Not authenticated");
|
|
2782
2806
|
return await (await fetch(`${h}/v1/admin/roles/${e}`, {
|
|
2783
2807
|
method: "PATCH",
|
|
2784
2808
|
body: JSON.stringify(t),
|
|
2785
2809
|
headers: {
|
|
2786
2810
|
"Content-Type": "application/json",
|
|
2787
|
-
Authorization: "Bearer " +
|
|
2811
|
+
Authorization: "Bearer " + o.token
|
|
2788
2812
|
}
|
|
2789
2813
|
})).json();
|
|
2790
2814
|
}
|
|
2791
2815
|
static async deleteRole(e) {
|
|
2792
|
-
if (!
|
|
2816
|
+
if (!o.token)
|
|
2793
2817
|
throw new Error("Not authenticated");
|
|
2794
2818
|
await fetch(`${h}/v1/admin/roles/${e}`, {
|
|
2795
2819
|
method: "DELETE",
|
|
2796
2820
|
headers: {
|
|
2797
2821
|
"Content-Type": "application/json",
|
|
2798
|
-
Authorization: "Bearer " +
|
|
2822
|
+
Authorization: "Bearer " + o.token
|
|
2799
2823
|
}
|
|
2800
2824
|
});
|
|
2801
2825
|
}
|
|
2802
2826
|
}
|
|
2803
2827
|
class cn {
|
|
2804
2828
|
static async listUsers() {
|
|
2805
|
-
if (!
|
|
2829
|
+
if (!o.token)
|
|
2806
2830
|
throw new Error("Not authenticated");
|
|
2807
2831
|
return (await (await fetch(`${h}/v1/admin/users`, {
|
|
2808
2832
|
method: "GET",
|
|
2809
2833
|
headers: {
|
|
2810
2834
|
"Content-Type": "application/json",
|
|
2811
|
-
Authorization: "Bearer " +
|
|
2835
|
+
Authorization: "Bearer " + o.token
|
|
2812
2836
|
}
|
|
2813
2837
|
})).json()).items;
|
|
2814
2838
|
}
|
|
2815
2839
|
static async createUser(e) {
|
|
2816
|
-
if (!
|
|
2840
|
+
if (!o.token)
|
|
2817
2841
|
throw new Error("Not authenticated");
|
|
2818
2842
|
return await (await fetch(`${h}/v1/admin/users`, {
|
|
2819
2843
|
method: "POST",
|
|
2820
2844
|
body: JSON.stringify(e),
|
|
2821
2845
|
headers: {
|
|
2822
2846
|
"Content-Type": "application/json",
|
|
2823
|
-
Authorization: "Bearer " +
|
|
2847
|
+
Authorization: "Bearer " + o.token
|
|
2824
2848
|
}
|
|
2825
2849
|
})).json();
|
|
2826
2850
|
}
|
|
2827
2851
|
static async getUser(e) {
|
|
2828
|
-
if (!
|
|
2852
|
+
if (!o.token)
|
|
2829
2853
|
throw new Error("Not authenticated");
|
|
2830
2854
|
return await (await fetch(`${h}/v1/admin/users/${e}`, {
|
|
2831
2855
|
method: "GET",
|
|
2832
2856
|
headers: {
|
|
2833
2857
|
"Content-Type": "application/json",
|
|
2834
|
-
Authorization: "Bearer " +
|
|
2858
|
+
Authorization: "Bearer " + o.token
|
|
2835
2859
|
}
|
|
2836
2860
|
})).json();
|
|
2837
2861
|
}
|
|
2838
2862
|
static async patchUser(e, t) {
|
|
2839
|
-
if (!
|
|
2863
|
+
if (!o.token)
|
|
2840
2864
|
throw new Error("Not authenticated");
|
|
2841
2865
|
return await (await fetch(`${h}/v1/admin/users/${e}`, {
|
|
2842
2866
|
method: "PATCH",
|
|
2843
2867
|
body: JSON.stringify(t),
|
|
2844
2868
|
headers: {
|
|
2845
2869
|
"Content-Type": "application/json",
|
|
2846
|
-
Authorization: "Bearer " +
|
|
2870
|
+
Authorization: "Bearer " + o.token
|
|
2847
2871
|
}
|
|
2848
2872
|
})).json();
|
|
2849
2873
|
}
|
|
2850
2874
|
static async deleteUser(e) {
|
|
2851
|
-
if (!
|
|
2875
|
+
if (!o.token)
|
|
2852
2876
|
throw new Error("Not authenticated");
|
|
2853
2877
|
await fetch(`${h}/v1/admin/users/${e}`, {
|
|
2854
2878
|
method: "PATCH",
|
|
2855
2879
|
body: JSON.stringify({ enabled: !1, roleId: null, teamId: null }),
|
|
2856
2880
|
headers: {
|
|
2857
2881
|
"Content-Type": "application/json",
|
|
2858
|
-
Authorization: "Bearer " +
|
|
2882
|
+
Authorization: "Bearer " + o.token
|
|
2859
2883
|
}
|
|
2860
2884
|
});
|
|
2861
2885
|
}
|
|
@@ -2887,21 +2911,21 @@ const dn = ["viewer", "operator", "administrator"], hn = "viewer", ln = "operato
|
|
|
2887
2911
|
], yn = ["selection", "labeling", "teleop"], gn = ["info", "warning", "error", "critical"], vn = ["video/mp4"], Tn = (a) => new Promise((e) => setTimeout(e, a * 1e3));
|
|
2888
2912
|
try {
|
|
2889
2913
|
const a = typeof window < "u" && window.location ? new URLSearchParams(window.location.search) : new URLSearchParams(""), e = a.get("device");
|
|
2890
|
-
e &&
|
|
2914
|
+
e && z.setDefaultDevice(e);
|
|
2891
2915
|
const t = a.get("auth");
|
|
2892
|
-
t &&
|
|
2916
|
+
t && o.loginWithToken(t), a.get("module") && o.listenForRefresh(), typeof window < "u" && $.listenForConnectionEvents();
|
|
2893
2917
|
} catch {
|
|
2894
2918
|
}
|
|
2895
2919
|
export {
|
|
2896
2920
|
rn as Account,
|
|
2897
|
-
|
|
2921
|
+
$ as App,
|
|
2898
2922
|
on as AudioPlayer,
|
|
2899
|
-
|
|
2923
|
+
o as Authentication,
|
|
2900
2924
|
Xe as BinaryRequestDataChannel,
|
|
2901
|
-
|
|
2925
|
+
He as CaptureStream,
|
|
2902
2926
|
Ke as DataChannel,
|
|
2903
|
-
|
|
2904
|
-
|
|
2927
|
+
S as Device,
|
|
2928
|
+
z as Fleet,
|
|
2905
2929
|
an as KeyValue,
|
|
2906
2930
|
Qe as Manipulator,
|
|
2907
2931
|
ft as PeerDevice,
|