@formant/data-sdk 1.81.6 → 1.81.7
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 +1 -1
- package/dist/data-sdk.cjs.js.map +1 -1
- package/dist/data-sdk.es.js +196 -133
- package/dist/data-sdk.es.js.map +1 -1
- package/dist/data-sdk.es6.js +196 -133
- package/dist/data-sdk.umd.js +1 -1
- package/dist/types/data-sdk/src/devices/Device.d.ts +12 -0
- package/package.json +1 -1
package/dist/data-sdk.es.js
CHANGED
|
@@ -25597,8 +25597,21 @@ class BaseDevice extends EventEmitter {
|
|
|
25597
25597
|
}
|
|
25598
25598
|
}
|
|
25599
25599
|
class Device extends BaseDevice {
|
|
25600
|
-
constructor(
|
|
25601
|
-
super()
|
|
25600
|
+
constructor(n, r, o, s) {
|
|
25601
|
+
super();
|
|
25602
|
+
/**
|
|
25603
|
+
* Connection monitor state.
|
|
25604
|
+
*
|
|
25605
|
+
* The original implementation would disconnect on the very first 1s tick if:
|
|
25606
|
+
* - the connection wasn't "ready" yet, OR
|
|
25607
|
+
* - RTC stats weren't available yet.
|
|
25608
|
+
*
|
|
25609
|
+
* On Firefox and iOS Safari, those conditions can be transient immediately after ICE reports "connected".
|
|
25610
|
+
* That creates the "connect then disconnect after ~1s" pattern.
|
|
25611
|
+
*/
|
|
25612
|
+
_e(this, "connectionMonitorStartedAtMs", 0);
|
|
25613
|
+
_e(this, "connectionMonitorConsecutiveFailures", 0);
|
|
25614
|
+
this.id = n, this.name = r, this.organizationId = o, this.tags = s;
|
|
25602
25615
|
}
|
|
25603
25616
|
async getLatestTelemetry() {
|
|
25604
25617
|
return (await (await fetch(
|
|
@@ -25622,22 +25635,22 @@ class Device extends BaseDevice {
|
|
|
25622
25635
|
* @returns {Promise<ConfigurationDocument>} A promise that resolves to the configuration document
|
|
25623
25636
|
* @throws {Error} Throws an error if the device has no configuration or has never been turned on
|
|
25624
25637
|
*/
|
|
25625
|
-
async getConfiguration(
|
|
25626
|
-
let
|
|
25638
|
+
async getConfiguration(n = !1) {
|
|
25639
|
+
let r = await fetch(`${FORMANT_API_URL}/v1/admin/devices/${this.id}`, {
|
|
25627
25640
|
method: "GET",
|
|
25628
25641
|
headers: {
|
|
25629
25642
|
"Content-Type": "application/json",
|
|
25630
25643
|
Authorization: "Bearer " + Authentication.token
|
|
25631
25644
|
}
|
|
25632
25645
|
});
|
|
25633
|
-
const
|
|
25634
|
-
if (!
|
|
25646
|
+
const o = await r.json();
|
|
25647
|
+
if (!o.state.reportedConfiguration)
|
|
25635
25648
|
throw new Error(
|
|
25636
25649
|
"Device has no configuration, has it ever been turned on?"
|
|
25637
25650
|
);
|
|
25638
|
-
const
|
|
25639
|
-
return
|
|
25640
|
-
`${FORMANT_API_URL}/v1/admin/devices/${this.id}/configurations/${
|
|
25651
|
+
const s = n ? o.desiredConfigurationVersion : o.state.reportedConfiguration.version;
|
|
25652
|
+
return r = await fetch(
|
|
25653
|
+
`${FORMANT_API_URL}/v1/admin/devices/${this.id}/configurations/${s}`,
|
|
25641
25654
|
{
|
|
25642
25655
|
method: "GET",
|
|
25643
25656
|
headers: {
|
|
@@ -25645,7 +25658,7 @@ class Device extends BaseDevice {
|
|
|
25645
25658
|
Authorization: "Bearer " + Authentication.token
|
|
25646
25659
|
}
|
|
25647
25660
|
}
|
|
25648
|
-
), (await
|
|
25661
|
+
), (await r.json()).document;
|
|
25649
25662
|
}
|
|
25650
25663
|
/**
|
|
25651
25664
|
* Asynchronously retrieves the device's agent version string
|
|
@@ -25654,21 +25667,24 @@ class Device extends BaseDevice {
|
|
|
25654
25667
|
* @throws {Error} Throws an error if the device info cannot be fetched
|
|
25655
25668
|
*/
|
|
25656
25669
|
async getAgentVersion() {
|
|
25657
|
-
var
|
|
25658
|
-
const
|
|
25659
|
-
|
|
25660
|
-
|
|
25661
|
-
|
|
25662
|
-
|
|
25670
|
+
var o;
|
|
25671
|
+
const r = await (await fetch(
|
|
25672
|
+
`${FORMANT_API_URL}/v1/admin/devices/${this.id}`,
|
|
25673
|
+
{
|
|
25674
|
+
method: "GET",
|
|
25675
|
+
headers: {
|
|
25676
|
+
"Content-Type": "application/json",
|
|
25677
|
+
Authorization: "Bearer " + Authentication.token
|
|
25678
|
+
}
|
|
25663
25679
|
}
|
|
25664
|
-
|
|
25665
|
-
return (
|
|
25680
|
+
)).json();
|
|
25681
|
+
return (o = r == null ? void 0 : r.state) == null ? void 0 : o.agentVersion;
|
|
25666
25682
|
}
|
|
25667
|
-
async getFileUrl(
|
|
25683
|
+
async getFileUrl(n) {
|
|
25668
25684
|
return (await (await fetch(`${FORMANT_API_URL}/v1/admin/files/query`, {
|
|
25669
25685
|
method: "POST",
|
|
25670
25686
|
body: JSON.stringify({
|
|
25671
|
-
fileIds: [
|
|
25687
|
+
fileIds: [n]
|
|
25672
25688
|
}),
|
|
25673
25689
|
headers: {
|
|
25674
25690
|
"Content-Type": "application/json",
|
|
@@ -25682,7 +25698,7 @@ class Device extends BaseDevice {
|
|
|
25682
25698
|
* @throws `Error` If the connection could not be established or if a connection already exists.
|
|
25683
25699
|
* @returns {void}
|
|
25684
25700
|
*/
|
|
25685
|
-
async startRealtimeConnection(
|
|
25701
|
+
async startRealtimeConnection(n = {}) {
|
|
25686
25702
|
if (console.debug(`${(/* @__PURE__ */ new Date()).toISOString()} :: Connection start requested`), this.rtcClient && this.connectionMonitorInterval !== void 0)
|
|
25687
25703
|
throw new Error(
|
|
25688
25704
|
`Already created realtime connection to device ${this.id}`
|
|
@@ -25691,102 +25707,149 @@ class Device extends BaseDevice {
|
|
|
25691
25707
|
"overwriting existing rtcClient due to missing connectionMonitorInterval"
|
|
25692
25708
|
);
|
|
25693
25709
|
const {
|
|
25694
|
-
sessionType:
|
|
25695
|
-
deadlineMs:
|
|
25696
|
-
maxConnectRetries:
|
|
25697
|
-
} = typeof
|
|
25698
|
-
sessionType:
|
|
25710
|
+
sessionType: r,
|
|
25711
|
+
deadlineMs: o = 1e4,
|
|
25712
|
+
maxConnectRetries: s = 3
|
|
25713
|
+
} = typeof n == "number" ? { sessionType: n } : n, l = getRtcClientPool({
|
|
25714
|
+
sessionType: r
|
|
25699
25715
|
}).get(this.handleMessage);
|
|
25700
|
-
let
|
|
25701
|
-
const
|
|
25702
|
-
(
|
|
25703
|
-
|
|
25716
|
+
let u = !1;
|
|
25717
|
+
const d = new Promise(
|
|
25718
|
+
(R, y) => setTimeout(() => {
|
|
25719
|
+
u = !0, y(
|
|
25704
25720
|
new Error(
|
|
25705
25721
|
"Connection timed out: the connection could not be finalized in time, possibly due to network issues or misconfigured settings."
|
|
25706
25722
|
)
|
|
25707
25723
|
);
|
|
25708
|
-
},
|
|
25709
|
-
),
|
|
25710
|
-
if ("isReady" in
|
|
25711
|
-
for (; !
|
|
25712
|
-
this.assertNotCancelled(
|
|
25713
|
-
const
|
|
25714
|
-
this.assertNotCancelled(
|
|
25715
|
-
let
|
|
25716
|
-
for (let
|
|
25717
|
-
delay$1(100), this.assertNotCancelled(
|
|
25718
|
-
if (!
|
|
25724
|
+
}, o)
|
|
25725
|
+
), h = async () => {
|
|
25726
|
+
if ("isReady" in l)
|
|
25727
|
+
for (; !l.isReady(); )
|
|
25728
|
+
this.assertNotCancelled(u), await delay$1(100);
|
|
25729
|
+
const R = await this.getRemoteDevicePeerId(l);
|
|
25730
|
+
this.assertNotCancelled(u);
|
|
25731
|
+
let y;
|
|
25732
|
+
for (let f = 0; f < s && (y = await l.connect(R), !y); f++)
|
|
25733
|
+
delay$1(100), this.assertNotCancelled(u);
|
|
25734
|
+
if (!y)
|
|
25719
25735
|
throw new Error(
|
|
25720
|
-
`Session could not be created: exhausted ${
|
|
25736
|
+
`Session could not be created: exhausted ${s} retries`
|
|
25721
25737
|
);
|
|
25722
|
-
let
|
|
25723
|
-
for (; !
|
|
25724
|
-
await delay$1(100),
|
|
25725
|
-
return this.assertNotCancelled(
|
|
25726
|
-
`${(/* @__PURE__ */ new Date()).toISOString()} :: Connection completed after ${
|
|
25727
|
-
),
|
|
25738
|
+
let Q = 0;
|
|
25739
|
+
for (; !u && l.getConnectionStatus(R) !== "connected"; )
|
|
25740
|
+
await delay$1(100), Q += 1;
|
|
25741
|
+
return this.assertNotCancelled(u), console.debug(
|
|
25742
|
+
`${(/* @__PURE__ */ new Date()).toISOString()} :: Connection completed after ${Q} retries`
|
|
25743
|
+
), R;
|
|
25728
25744
|
};
|
|
25729
|
-
return Promise.race([
|
|
25730
|
-
this.remoteDevicePeerId =
|
|
25731
|
-
}).catch((
|
|
25745
|
+
return Promise.race([h(), d]).then((R) => {
|
|
25746
|
+
this.remoteDevicePeerId = R, this.rtcClient = l, this.connectionMonitorStartedAtMs = Date.now(), this.connectionMonitorConsecutiveFailures = 0, this.initConnectionMonitoring(), this.emit("connect");
|
|
25747
|
+
}).catch((R) => {
|
|
25732
25748
|
throw console.debug(
|
|
25733
25749
|
`${(/* @__PURE__ */ new Date()).toISOString()} :: Connection failed: %o`,
|
|
25734
|
-
|
|
25735
|
-
), this.remoteDevicePeerId = null,
|
|
25736
|
-
console.error("rtcClient cannot shutdown: %o",
|
|
25737
|
-
}), this.emit("connection_failed",
|
|
25750
|
+
R
|
|
25751
|
+
), this.remoteDevicePeerId = null, l.shutdown().catch((y) => {
|
|
25752
|
+
console.error("rtcClient cannot shutdown: %o", y);
|
|
25753
|
+
}), this.emit("connection_failed", R), R;
|
|
25738
25754
|
});
|
|
25739
25755
|
}
|
|
25740
|
-
async getRemoteDevicePeerId(
|
|
25741
|
-
const
|
|
25742
|
-
if (!isRtcPeer(
|
|
25756
|
+
async getRemoteDevicePeerId(n) {
|
|
25757
|
+
const o = (await n.getPeers()).find((s) => s.deviceId === this.id);
|
|
25758
|
+
if (!isRtcPeer(o))
|
|
25743
25759
|
throw new Error("Cannot find peer, is the robot offline?");
|
|
25744
|
-
return
|
|
25760
|
+
return o.id;
|
|
25745
25761
|
}
|
|
25746
25762
|
initConnectionMonitoring() {
|
|
25747
25763
|
this.connectionMonitorInterval = setInterval(async () => {
|
|
25748
|
-
let
|
|
25764
|
+
let o = !1, s = !1, c = !1;
|
|
25749
25765
|
if (this.rtcClient) {
|
|
25750
|
-
const
|
|
25751
|
-
(
|
|
25766
|
+
const h = this.rtcClient.getConnections().find(
|
|
25767
|
+
(R) => R.getRemotePeerId() === this.remoteDevicePeerId && R.isActive()
|
|
25752
25768
|
);
|
|
25753
|
-
(
|
|
25769
|
+
(h === void 0 || !h.isReady()) && (console.debug(`${(/* @__PURE__ */ new Date()).toISOString()} :: data channel closed`), o = !0, s = !0);
|
|
25754
25770
|
}
|
|
25755
|
-
(!this.rtcClient || !this.remoteDevicePeerId
|
|
25756
|
-
this.
|
|
25757
|
-
|
|
25758
|
-
|
|
25759
|
-
|
|
25771
|
+
if (!this.rtcClient || !this.remoteDevicePeerId) {
|
|
25772
|
+
this.emit("disconnect"), this.stopRealtimeConnection().catch((d) => console.error(d));
|
|
25773
|
+
return;
|
|
25774
|
+
}
|
|
25775
|
+
try {
|
|
25776
|
+
c = await this.rtcClient.getConnectionStatsInfo(
|
|
25777
|
+
this.remoteDevicePeerId
|
|
25778
|
+
) === void 0;
|
|
25779
|
+
} catch {
|
|
25780
|
+
c = !0;
|
|
25781
|
+
}
|
|
25782
|
+
const l = Date.now() - (this.connectionMonitorStartedAtMs || 0);
|
|
25783
|
+
if (o || s) {
|
|
25784
|
+
if (l < 6e3) {
|
|
25785
|
+
console.debug(
|
|
25786
|
+
`${(/* @__PURE__ */ new Date()).toISOString()} :: connection monitor unhealthy (grace)`,
|
|
25787
|
+
{
|
|
25788
|
+
elapsed: l,
|
|
25789
|
+
connectionNotReady: s,
|
|
25790
|
+
statsUnavailable: c,
|
|
25791
|
+
dataChannelClosed: o,
|
|
25792
|
+
consecutiveFailures: this.connectionMonitorConsecutiveFailures
|
|
25793
|
+
}
|
|
25794
|
+
);
|
|
25795
|
+
return;
|
|
25796
|
+
}
|
|
25797
|
+
if (this.connectionMonitorConsecutiveFailures += 1, this.connectionMonitorConsecutiveFailures < 3) {
|
|
25798
|
+
console.debug(
|
|
25799
|
+
`${(/* @__PURE__ */ new Date()).toISOString()} :: connection monitor unhealthy (retrying)`,
|
|
25800
|
+
{
|
|
25801
|
+
elapsed: l,
|
|
25802
|
+
connectionNotReady: s,
|
|
25803
|
+
statsUnavailable: c,
|
|
25804
|
+
dataChannelClosed: o,
|
|
25805
|
+
consecutiveFailures: this.connectionMonitorConsecutiveFailures
|
|
25806
|
+
}
|
|
25807
|
+
);
|
|
25808
|
+
return;
|
|
25809
|
+
}
|
|
25810
|
+
console.debug(
|
|
25811
|
+
`${(/* @__PURE__ */ new Date()).toISOString()} :: connection monitor disconnecting`,
|
|
25812
|
+
{
|
|
25813
|
+
elapsed: l,
|
|
25814
|
+
connectionNotReady: s,
|
|
25815
|
+
statsUnavailable: c,
|
|
25816
|
+
dataChannelClosed: o,
|
|
25817
|
+
consecutiveFailures: this.connectionMonitorConsecutiveFailures
|
|
25818
|
+
}
|
|
25819
|
+
), this.emit("disconnect"), this.stopRealtimeConnection().catch((d) => console.error(d));
|
|
25820
|
+
return;
|
|
25821
|
+
}
|
|
25822
|
+
this.connectionMonitorConsecutiveFailures = 0;
|
|
25760
25823
|
}, 1e3);
|
|
25761
25824
|
}
|
|
25762
25825
|
async getRemotePeer() {
|
|
25763
|
-
const
|
|
25826
|
+
const r = (await defined$1(
|
|
25764
25827
|
this.rtcClient,
|
|
25765
25828
|
"Realtime connection has not been started"
|
|
25766
|
-
).getPeers()).find((
|
|
25829
|
+
).getPeers()).find((o) => o.deviceId === this.id);
|
|
25767
25830
|
return defined$1(
|
|
25768
|
-
|
|
25831
|
+
r,
|
|
25769
25832
|
"Could not find remote peer for device " + this.id
|
|
25770
25833
|
);
|
|
25771
25834
|
}
|
|
25772
25835
|
async stopRealtimeConnection() {
|
|
25773
|
-
let
|
|
25836
|
+
let n = !1;
|
|
25774
25837
|
if (this.rtcClient) {
|
|
25775
|
-
this.stopConnectionMonitoring(), this.remoteDevicePeerId ? (await this.rtcClient.disconnect(this.remoteDevicePeerId), this.remoteDevicePeerId = null) :
|
|
25838
|
+
this.stopConnectionMonitoring(), this.remoteDevicePeerId ? (await this.rtcClient.disconnect(this.remoteDevicePeerId), this.remoteDevicePeerId = null) : n = !0;
|
|
25776
25839
|
try {
|
|
25777
25840
|
await this.rtcClient.shutdown();
|
|
25778
25841
|
} finally {
|
|
25779
25842
|
this.rtcClient = void 0;
|
|
25780
25843
|
}
|
|
25781
25844
|
}
|
|
25782
|
-
if (
|
|
25845
|
+
if (n)
|
|
25783
25846
|
throw new Error(`Realtime connection hasn't been started for ${this.id}`);
|
|
25784
25847
|
}
|
|
25785
25848
|
async isInRealtimeSession() {
|
|
25786
|
-
const
|
|
25787
|
-
return
|
|
25849
|
+
const n = await getPeers(), r = await getRealtimeSessions(), o = n.find((s) => s.deviceId === this.id);
|
|
25850
|
+
return o ? r[o.id].length > 0 : !1;
|
|
25788
25851
|
}
|
|
25789
|
-
async getAvailableCommands(
|
|
25852
|
+
async getAvailableCommands(n = !0) {
|
|
25790
25853
|
return (await (await fetch(
|
|
25791
25854
|
`${FORMANT_API_URL}/v1/admin/command-templates/`,
|
|
25792
25855
|
{
|
|
@@ -25796,32 +25859,32 @@ class Device extends BaseDevice {
|
|
|
25796
25859
|
Authorization: "Bearer " + Authentication.token
|
|
25797
25860
|
}
|
|
25798
25861
|
}
|
|
25799
|
-
)).json()).items.filter((
|
|
25862
|
+
)).json()).items.filter((s) => n ? !0 : s.enabled);
|
|
25800
25863
|
}
|
|
25801
|
-
async sendCommand(
|
|
25802
|
-
var
|
|
25803
|
-
const
|
|
25804
|
-
if (!
|
|
25805
|
-
throw new Error(`Could not find command with name "${
|
|
25806
|
-
let
|
|
25807
|
-
|
|
25808
|
-
|
|
25809
|
-
value:
|
|
25810
|
-
scrubberTime: (
|
|
25864
|
+
async sendCommand(n, r, o, s, c) {
|
|
25865
|
+
var y;
|
|
25866
|
+
const u = (await this.getAvailableCommands(!1)).find((Q) => c ? Q.id === c : Q.name === n);
|
|
25867
|
+
if (!u)
|
|
25868
|
+
throw new Error(`Could not find command with name "${n}"`);
|
|
25869
|
+
let d = "";
|
|
25870
|
+
r === void 0 ? u.parameterEnabled && u.parameterValue && (d = u.parameterValue) : d = r;
|
|
25871
|
+
const h = {
|
|
25872
|
+
value: d,
|
|
25873
|
+
scrubberTime: (o || /* @__PURE__ */ new Date()).toISOString(),
|
|
25811
25874
|
meta: {
|
|
25812
|
-
...
|
|
25813
|
-
...
|
|
25875
|
+
...u.parameterMeta,
|
|
25876
|
+
...s
|
|
25814
25877
|
}
|
|
25815
25878
|
};
|
|
25816
25879
|
return await fetch(`${FORMANT_API_URL}/v1/admin/commands`, {
|
|
25817
25880
|
method: "POST",
|
|
25818
25881
|
body: JSON.stringify({
|
|
25819
|
-
commandTemplateId:
|
|
25882
|
+
commandTemplateId: u.id,
|
|
25820
25883
|
organizationId: this.organizationId,
|
|
25821
25884
|
deviceId: this.id,
|
|
25822
|
-
command:
|
|
25823
|
-
parameter:
|
|
25824
|
-
userId: (
|
|
25885
|
+
command: u.command,
|
|
25886
|
+
parameter: h,
|
|
25887
|
+
userId: (y = Authentication.currentUser) == null ? void 0 : y.id
|
|
25825
25888
|
}),
|
|
25826
25889
|
headers: {
|
|
25827
25890
|
"Content-Type": "application/json",
|
|
@@ -25829,8 +25892,8 @@ class Device extends BaseDevice {
|
|
|
25829
25892
|
}
|
|
25830
25893
|
});
|
|
25831
25894
|
}
|
|
25832
|
-
async getCommand(
|
|
25833
|
-
return await fetch(`${FORMANT_API_URL}/v1/admin/commands/${
|
|
25895
|
+
async getCommand(n) {
|
|
25896
|
+
return await fetch(`${FORMANT_API_URL}/v1/admin/commands/${n}`, {
|
|
25834
25897
|
method: "GET",
|
|
25835
25898
|
headers: {
|
|
25836
25899
|
"Content-Type": "application/json",
|
|
@@ -25838,12 +25901,12 @@ class Device extends BaseDevice {
|
|
|
25838
25901
|
}
|
|
25839
25902
|
});
|
|
25840
25903
|
}
|
|
25841
|
-
async createCaptureStream(
|
|
25842
|
-
const
|
|
25904
|
+
async createCaptureStream(n) {
|
|
25905
|
+
const o = await (await fetch(`${FORMANT_API_URL}/v1/admin/capture-sessions`, {
|
|
25843
25906
|
method: "POST",
|
|
25844
25907
|
body: JSON.stringify({
|
|
25845
25908
|
deviceId: this.id,
|
|
25846
|
-
streamName:
|
|
25909
|
+
streamName: n,
|
|
25847
25910
|
tags: {}
|
|
25848
25911
|
}),
|
|
25849
25912
|
headers: {
|
|
@@ -25851,28 +25914,28 @@ class Device extends BaseDevice {
|
|
|
25851
25914
|
Authorization: "Bearer " + Authentication.token
|
|
25852
25915
|
}
|
|
25853
25916
|
})).json();
|
|
25854
|
-
return new CaptureStream(
|
|
25917
|
+
return new CaptureStream(o);
|
|
25855
25918
|
}
|
|
25856
|
-
async getTelemetry(
|
|
25857
|
-
if (
|
|
25919
|
+
async getTelemetry(n, r, o, s, c, l, u) {
|
|
25920
|
+
if (c !== void 0 || l !== void 0)
|
|
25858
25921
|
throw new Error("Limit and offset are not supported in this method");
|
|
25859
25922
|
return await getTelemetry(
|
|
25860
25923
|
this.id,
|
|
25861
|
-
t,
|
|
25862
25924
|
n,
|
|
25863
25925
|
r,
|
|
25864
25926
|
o,
|
|
25865
|
-
|
|
25927
|
+
s,
|
|
25928
|
+
u
|
|
25866
25929
|
);
|
|
25867
25930
|
}
|
|
25868
|
-
async queryEvents(
|
|
25869
|
-
if (
|
|
25931
|
+
async queryEvents(n) {
|
|
25932
|
+
if (n.deviceIds)
|
|
25870
25933
|
throw new Error("Cannot filter multiple devices via Device class");
|
|
25871
|
-
return
|
|
25934
|
+
return n.deviceIds = [this.id], queryEvents(n);
|
|
25872
25935
|
}
|
|
25873
25936
|
async getTelemetryStreams() {
|
|
25874
|
-
var
|
|
25875
|
-
const
|
|
25937
|
+
var u, d;
|
|
25938
|
+
const n = await this.getConfiguration(), r = await fetch(
|
|
25876
25939
|
`${FORMANT_API_URL}/v1/queries/metadata/stream-names`,
|
|
25877
25940
|
{
|
|
25878
25941
|
method: "POST",
|
|
@@ -25884,23 +25947,23 @@ class Device extends BaseDevice {
|
|
|
25884
25947
|
Authorization: "Bearer " + Authentication.token
|
|
25885
25948
|
}
|
|
25886
25949
|
}
|
|
25887
|
-
),
|
|
25888
|
-
return (
|
|
25889
|
-
|
|
25890
|
-
}), console.log(
|
|
25950
|
+
), o = [], s = [];
|
|
25951
|
+
return (d = (u = n.telemetry) == null ? void 0 : u.streams) == null || d.forEach((h) => {
|
|
25952
|
+
h.disabled !== !0 && o.push(h.name), h.onDemand === !0 && s.push(h.name);
|
|
25953
|
+
}), console.log(s), (await r.json()).items.filter((h) => !o.includes(h)).map((h) => ({ name: h, onDemand: s.includes(h) }));
|
|
25891
25954
|
}
|
|
25892
|
-
async createInterventionRequest(
|
|
25955
|
+
async createInterventionRequest(n, r, o, s) {
|
|
25893
25956
|
return await (await fetch(
|
|
25894
25957
|
`${FORMANT_API_URL}/v1/admin/intervention-requests`,
|
|
25895
25958
|
{
|
|
25896
25959
|
method: "POST",
|
|
25897
25960
|
body: JSON.stringify({
|
|
25898
|
-
message:
|
|
25899
|
-
interventionType:
|
|
25961
|
+
message: n,
|
|
25962
|
+
interventionType: r,
|
|
25900
25963
|
time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
25901
25964
|
deviceId: this.id,
|
|
25902
|
-
tags:
|
|
25903
|
-
data:
|
|
25965
|
+
tags: s,
|
|
25966
|
+
data: o
|
|
25904
25967
|
}),
|
|
25905
25968
|
headers: {
|
|
25906
25969
|
"Content-Type": "application/json",
|
|
@@ -25909,15 +25972,15 @@ class Device extends BaseDevice {
|
|
|
25909
25972
|
}
|
|
25910
25973
|
)).json();
|
|
25911
25974
|
}
|
|
25912
|
-
async addInterventionResponse(
|
|
25975
|
+
async addInterventionResponse(n, r, o) {
|
|
25913
25976
|
return await (await fetch(
|
|
25914
25977
|
`${FORMANT_API_URL}/v1/admin/intervention-responses`,
|
|
25915
25978
|
{
|
|
25916
25979
|
method: "POST",
|
|
25917
25980
|
body: JSON.stringify({
|
|
25918
|
-
interventionId:
|
|
25919
|
-
interventionType:
|
|
25920
|
-
data:
|
|
25981
|
+
interventionId: n,
|
|
25982
|
+
interventionType: r,
|
|
25983
|
+
data: o
|
|
25921
25984
|
}),
|
|
25922
25985
|
headers: {
|
|
25923
25986
|
"Content-Type": "application/json",
|
|
@@ -25926,24 +25989,24 @@ class Device extends BaseDevice {
|
|
|
25926
25989
|
}
|
|
25927
25990
|
)).json();
|
|
25928
25991
|
}
|
|
25929
|
-
async getAnnotationCount(
|
|
25930
|
-
return await getAnnotationCount({ ...
|
|
25992
|
+
async getAnnotationCount(n, r) {
|
|
25993
|
+
return await getAnnotationCount({ ...n, deviceIds: [this.id] }, r);
|
|
25931
25994
|
}
|
|
25932
|
-
async getAnnotationCountByIntervals(
|
|
25995
|
+
async getAnnotationCountByIntervals(n, r, o) {
|
|
25933
25996
|
return await getAnnotationCountByIntervals(
|
|
25934
|
-
{ ...
|
|
25935
|
-
|
|
25936
|
-
|
|
25997
|
+
{ ...n, deviceIds: [this.id] },
|
|
25998
|
+
r,
|
|
25999
|
+
o
|
|
25937
26000
|
);
|
|
25938
26001
|
}
|
|
25939
|
-
async eventsCounter(
|
|
25940
|
-
return await eventsCounter(
|
|
25941
|
-
...
|
|
26002
|
+
async eventsCounter(n, r, o, s, c) {
|
|
26003
|
+
return await eventsCounter(n, r, o, s, {
|
|
26004
|
+
...c,
|
|
25942
26005
|
deviceIds: [this.id]
|
|
25943
26006
|
});
|
|
25944
26007
|
}
|
|
25945
|
-
async createShareLink(
|
|
25946
|
-
return
|
|
26008
|
+
async createShareLink(n, r) {
|
|
26009
|
+
return n.scope.deviceIds = [this.id], await createShareLink(n, r);
|
|
25947
26010
|
}
|
|
25948
26011
|
}
|
|
25949
26012
|
_e(Device, "createDevice", createDevice), _e(Device, "patchDevice", patchDevice), _e(Device, "getDevicesData", getDevicesData), _e(Device, "queryDevicesData", queryDevicesData), _e(Device, "disableDevice", disableDevice);
|