@formant/data-sdk 1.13.2 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-sdk.cjs.js +2 -2
- package/dist/data-sdk.cjs.js.map +1 -1
- package/dist/data-sdk.es.js +38 -30
- package/dist/data-sdk.es.js.map +1 -1
- package/dist/data-sdk.es6.js +18 -10
- package/dist/data-sdk.umd.js +2 -2
- package/dist/types/data-sdk/src/devices/Device.d.ts +8 -1
- package/package.json +1 -1
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 b, 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";
|
|
@@ -346,7 +346,7 @@ function Re(a, e) {
|
|
|
346
346
|
after: e || 0
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function be(a) {
|
|
350
350
|
const e = k();
|
|
351
351
|
if (!e)
|
|
352
352
|
throw new Error("No module context");
|
|
@@ -356,7 +356,7 @@ function Ae(a) {
|
|
|
356
356
|
menus: a
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function Ae(a) {
|
|
360
360
|
T({ type: "show_message", message: a });
|
|
361
361
|
}
|
|
362
362
|
function De(a, e) {
|
|
@@ -641,7 +641,7 @@ const q = class {
|
|
|
641
641
|
};
|
|
642
642
|
let g = q;
|
|
643
643
|
s(g, "getCurrentModuleContext", k), // senders
|
|
644
|
-
s(g, "disableAnalyticsBottomBar", Ce), s(g, "goToDevice", Se), s(g, "goToTime", Ee), s(g, "refreshAuthToken", H), s(g, "requestModuleData", ke), s(g, "sendChannelData", Oe), s(g, "setModuleDateTimeRange", Re), s(g, "setupModuleMenus",
|
|
644
|
+
s(g, "disableAnalyticsBottomBar", Ce), s(g, "goToDevice", Se), s(g, "goToTime", Ee), s(g, "refreshAuthToken", H), s(g, "requestModuleData", ke), s(g, "sendChannelData", Oe), s(g, "setModuleDateTimeRange", Re), s(g, "setupModuleMenus", be), s(g, "showMessage", Ae), // listeners
|
|
645
645
|
s(g, "addAccessTokenRefreshListener", F), s(g, "addChannelDataListener", De), s(g, "addMenuListener", je), s(g, "addModuleConfigurationListener", Ne), s(g, "addModuleDataListener", Pe), s(g, "addOverviewDeviceListener", Le), s(g, "addStreamListener", Ue), // bidirectional
|
|
646
646
|
s(g, "getDate", Je), s(g, "prompt", Ve), s(g, "_isOnline", null);
|
|
647
647
|
function f(a, e) {
|
|
@@ -730,7 +730,7 @@ Gt = O;
|
|
|
730
730
|
const P = async () => f(r.token, "Realtime when user isn't authorized"), R = {
|
|
731
731
|
[p.UNKNOWN]: new N({
|
|
732
732
|
ttlMs: 2500,
|
|
733
|
-
createClient: (a) => new
|
|
733
|
+
createClient: (a) => new b({
|
|
734
734
|
signalingClient: new j(h),
|
|
735
735
|
getToken: P,
|
|
736
736
|
sessionType: p.UNKNOWN,
|
|
@@ -739,7 +739,7 @@ const P = async () => f(r.token, "Realtime when user isn't authorized"), R = {
|
|
|
739
739
|
}),
|
|
740
740
|
[p.TELEOP]: new N({
|
|
741
741
|
ttlMs: 2500,
|
|
742
|
-
createClient: (a) => new
|
|
742
|
+
createClient: (a) => new b({
|
|
743
743
|
signalingClient: new j(h),
|
|
744
744
|
getToken: P,
|
|
745
745
|
sessionType: p.TELEOP,
|
|
@@ -748,7 +748,7 @@ const P = async () => f(r.token, "Realtime when user isn't authorized"), R = {
|
|
|
748
748
|
}),
|
|
749
749
|
[p.PORT_FORWARD]: new N({
|
|
750
750
|
ttlMs: 2500,
|
|
751
|
-
createClient: (a) => new
|
|
751
|
+
createClient: (a) => new b({
|
|
752
752
|
signalingClient: new j(h),
|
|
753
753
|
getToken: P,
|
|
754
754
|
sessionType: p.PORT_FORWARD,
|
|
@@ -757,7 +757,7 @@ const P = async () => f(r.token, "Realtime when user isn't authorized"), R = {
|
|
|
757
757
|
}),
|
|
758
758
|
[p.OBSERVE]: new N({
|
|
759
759
|
ttlMs: 2500,
|
|
760
|
-
createClient: (a) => new
|
|
760
|
+
createClient: (a) => new b({
|
|
761
761
|
signalingClient: new j(h),
|
|
762
762
|
getToken: P,
|
|
763
763
|
sessionType: p.OBSERVE,
|
|
@@ -766,7 +766,7 @@ const P = async () => f(r.token, "Realtime when user isn't authorized"), R = {
|
|
|
766
766
|
}),
|
|
767
767
|
[p.HEADLESS]: new N({
|
|
768
768
|
ttlMs: 2500,
|
|
769
|
-
createClient: (a) => new
|
|
769
|
+
createClient: (a) => new b({
|
|
770
770
|
signalingClient: new j(h),
|
|
771
771
|
getToken: P,
|
|
772
772
|
sessionType: p.HEADLESS,
|
|
@@ -814,7 +814,7 @@ class Fe {
|
|
|
814
814
|
});
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
|
-
function
|
|
817
|
+
function A(a) {
|
|
818
818
|
return new Promise((e) => setTimeout(e, a));
|
|
819
819
|
}
|
|
820
820
|
const We = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
|
|
@@ -1000,7 +1000,7 @@ class Xe extends X {
|
|
|
1000
1000
|
i.set(d, !0), n.sendBinary(new Uint8Array([...c, ...t]));
|
|
1001
1001
|
const y = (/* @__PURE__ */ new Date()).getTime();
|
|
1002
1002
|
for (; (/* @__PURE__ */ new Date()).getTime() < y + o; )
|
|
1003
|
-
if (await
|
|
1003
|
+
if (await A(50), i.has(d)) {
|
|
1004
1004
|
const m = i.get(d);
|
|
1005
1005
|
if (m !== !0) {
|
|
1006
1006
|
i.delete(d);
|
|
@@ -1047,7 +1047,7 @@ class Ye extends X {
|
|
|
1047
1047
|
);
|
|
1048
1048
|
const c = (/* @__PURE__ */ new Date()).getTime();
|
|
1049
1049
|
for (; (/* @__PURE__ */ new Date()).getTime() < c + i; )
|
|
1050
|
-
if (await
|
|
1050
|
+
if (await A(50), n.has(o)) {
|
|
1051
1051
|
const d = n.get(o);
|
|
1052
1052
|
if (d !== !0) {
|
|
1053
1053
|
n.delete(o);
|
|
@@ -1590,22 +1590,29 @@ class S extends Y {
|
|
|
1590
1590
|
}
|
|
1591
1591
|
)).json()).items;
|
|
1592
1592
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1593
|
+
/**
|
|
1594
|
+
* Asynchronously retrieves the configuration document for a device.
|
|
1595
|
+
*
|
|
1596
|
+
* @param {boolean} getDesiredConfigurationVersion - Whether to retrieve the desired configuration version
|
|
1597
|
+
* @returns {Promise<ConfigurationDocument>} A promise that resolves to the configuration document
|
|
1598
|
+
* @throws {Error} Throws an error if the device has no configuration or has never been turned on
|
|
1599
|
+
*/
|
|
1600
|
+
async getConfiguration(e = !1) {
|
|
1601
|
+
let t = await fetch(`${h}/v1/admin/devices/${this.id}`, {
|
|
1595
1602
|
method: "GET",
|
|
1596
1603
|
headers: {
|
|
1597
1604
|
"Content-Type": "application/json",
|
|
1598
1605
|
Authorization: "Bearer " + r.token
|
|
1599
1606
|
}
|
|
1600
1607
|
});
|
|
1601
|
-
const
|
|
1602
|
-
if (!
|
|
1608
|
+
const n = await t.json();
|
|
1609
|
+
if (!n.state.reportedConfiguration)
|
|
1603
1610
|
throw new Error(
|
|
1604
1611
|
"Device has no configuration, has it ever been turned on?"
|
|
1605
1612
|
);
|
|
1606
|
-
const
|
|
1607
|
-
return
|
|
1608
|
-
`${h}/v1/admin/devices/${this.id}/configurations/${
|
|
1613
|
+
const i = e ? n.desiredConfigurationVersion : n.state.reportedConfiguration.version;
|
|
1614
|
+
return t = await fetch(
|
|
1615
|
+
`${h}/v1/admin/devices/${this.id}/configurations/${i}`,
|
|
1609
1616
|
{
|
|
1610
1617
|
method: "GET",
|
|
1611
1618
|
headers: {
|
|
@@ -1613,7 +1620,7 @@ class S extends Y {
|
|
|
1613
1620
|
Authorization: "Bearer " + r.token
|
|
1614
1621
|
}
|
|
1615
1622
|
}
|
|
1616
|
-
), (await
|
|
1623
|
+
), (await t.json()).document;
|
|
1617
1624
|
}
|
|
1618
1625
|
async getFileUrl(e) {
|
|
1619
1626
|
return (await (await fetch(`${h}/v1/admin/files/query`, {
|
|
@@ -1660,19 +1667,19 @@ class S extends Y {
|
|
|
1660
1667
|
), m = async () => {
|
|
1661
1668
|
if ("isReady" in c)
|
|
1662
1669
|
for (; !c.isReady(); )
|
|
1663
|
-
this.assertNotCancelled(d), await
|
|
1670
|
+
this.assertNotCancelled(d), await A(100);
|
|
1664
1671
|
const w = await this.getRemoteDevicePeerId(c);
|
|
1665
1672
|
this.assertNotCancelled(d);
|
|
1666
1673
|
let v;
|
|
1667
1674
|
for (let D = 0; D < i && (v = await c.connect(w), !v); D++)
|
|
1668
|
-
|
|
1675
|
+
A(100), this.assertNotCancelled(d);
|
|
1669
1676
|
if (!v)
|
|
1670
1677
|
throw new Error(
|
|
1671
1678
|
`Session could not be created: exhausted ${i} retries`
|
|
1672
1679
|
);
|
|
1673
1680
|
let C = 0;
|
|
1674
1681
|
for (; !d && c.getConnectionStatus(w) !== "connected"; )
|
|
1675
|
-
await
|
|
1682
|
+
await A(100), C += 1;
|
|
1676
1683
|
return this.assertNotCancelled(d), console.debug(
|
|
1677
1684
|
`${(/* @__PURE__ */ new Date()).toISOString()} :: Connection completed after ${C} retries`
|
|
1678
1685
|
), w;
|
|
@@ -1964,13 +1971,13 @@ class ft extends Y {
|
|
|
1964
1971
|
this.rtcClient && console.warn(
|
|
1965
1972
|
"overwriting existing rtcClient due to missing connectionMonitorInterval"
|
|
1966
1973
|
);
|
|
1967
|
-
const n = new
|
|
1974
|
+
const n = new b({
|
|
1968
1975
|
lanOnlyMode: !0,
|
|
1969
1976
|
receive: this.handleMessage,
|
|
1970
1977
|
sessionType: t
|
|
1971
1978
|
});
|
|
1972
1979
|
for (await n.connectLan(this.peerUrl); n.getConnectionStatus(this.peerUrl) !== "connected"; )
|
|
1973
|
-
await
|
|
1980
|
+
await A(100);
|
|
1974
1981
|
this.rtcClient = n, this.initConnectionMonitoring();
|
|
1975
1982
|
}
|
|
1976
1983
|
initConnectionMonitoring() {
|
|
@@ -2216,7 +2223,7 @@ async function Rt(a) {
|
|
|
2216
2223
|
}
|
|
2217
2224
|
})).json()).items;
|
|
2218
2225
|
}
|
|
2219
|
-
async function
|
|
2226
|
+
async function bt() {
|
|
2220
2227
|
if (!r.token)
|
|
2221
2228
|
throw new Error("Not authenticated");
|
|
2222
2229
|
return (await (await fetch(
|
|
@@ -2230,7 +2237,7 @@ async function At() {
|
|
|
2230
2237
|
}
|
|
2231
2238
|
)).json()).items;
|
|
2232
2239
|
}
|
|
2233
|
-
async function
|
|
2240
|
+
async function At(...a) {
|
|
2234
2241
|
const e = a.flat().filter((i) => !!i);
|
|
2235
2242
|
return e.length === 0 ? [] : (await (await fetch(
|
|
2236
2243
|
`${h}/v1/queries/stream-current-value`,
|
|
@@ -2466,7 +2473,7 @@ const E = class {
|
|
|
2466
2473
|
}
|
|
2467
2474
|
};
|
|
2468
2475
|
let l = E;
|
|
2469
|
-
s(l, "defaultDeviceId"), s(l, "knownContext", []), s(l, "createFleet", Mt), 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", B), s(l, "getAnnotationCountByIntervals", ae), s(l, "getCurrentGroup", Ct), s(l, "getDevices", M), s(l, "getEvent", Et), s(l, "getFileUrl", kt), s(l, "getInterventions",
|
|
2476
|
+
s(l, "defaultDeviceId"), s(l, "knownContext", []), s(l, "createFleet", Mt), 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", B), s(l, "getAnnotationCountByIntervals", ae), s(l, "getCurrentGroup", Ct), s(l, "getDevices", M), s(l, "getEvent", Et), s(l, "getFileUrl", kt), s(l, "getInterventions", bt), s(l, "getLatestTelemetry", At), s(l, "getOnlineDevices", Dt), s(l, "getPeers", re), s(l, "getRealtimeDevices", jt), 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", $t), s(l, "patchView", zt), s(l, "queryAnalytics", Bt), s(l, "queryDevices", se), s(l, "queryEvents", z), s(l, "queryTelemetry", _), s(l, "getAllEventTriggerGroup", qt), s(l, "getEventTriggerGroup", xt), s(l, "patchEventTriggergroup", Ut);
|
|
2470
2477
|
class an {
|
|
2471
2478
|
static async set(e, t, n) {
|
|
2472
2479
|
try {
|
|
@@ -2693,13 +2700,14 @@ class rn {
|
|
|
2693
2700
|
static async deleteAccount(e) {
|
|
2694
2701
|
if (!r.token)
|
|
2695
2702
|
throw new Error("Not authenticated");
|
|
2696
|
-
await fetch(`${h}/v1/admin/accounts/${e}`, {
|
|
2703
|
+
if (!(await fetch(`${h}/v1/admin/accounts/${e}`, {
|
|
2697
2704
|
method: "DELETE",
|
|
2698
2705
|
headers: {
|
|
2699
2706
|
"Content-Type": "application/json",
|
|
2700
2707
|
Authorization: "Bearer " + r.token
|
|
2701
2708
|
}
|
|
2702
|
-
})
|
|
2709
|
+
})).ok)
|
|
2710
|
+
throw new Error("Unable to delete account");
|
|
2703
2711
|
}
|
|
2704
2712
|
static async getAccountTree(e) {
|
|
2705
2713
|
if (!r.token)
|