@formant/data-sdk 1.5.2 → 1.5.4
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/README.md +2 -2
- package/dist/data-sdk.cjs.js +2 -2
- package/dist/data-sdk.cjs.js.map +1 -1
- package/dist/data-sdk.es.js +396 -368
- package/dist/data-sdk.es.js.map +1 -1
- package/dist/data-sdk.es6.js +54 -26
- package/dist/data-sdk.umd.js +1 -1
- package/dist/types/data-sdk/src/DataChannel.d.ts +1 -0
- package/dist/types/data-sdk/src/api/createDevice.d.ts +2 -0
- package/dist/types/data-sdk/src/api/getDevicesData.d.ts +2 -0
- package/dist/types/data-sdk/src/api/patchDevice.d.ts +2 -0
- package/dist/types/data-sdk/src/api/queryDevicesData.d.ts +3 -0
- package/dist/types/data-sdk/src/devices/Device.d.ts +8 -3
- package/dist/types/data-sdk/src/main.d.ts +6 -0
- package/package.json +1 -1
package/dist/data-sdk.es6.js
CHANGED
|
@@ -20248,7 +20248,7 @@ class DataChannel {
|
|
|
20248
20248
|
be(this, "error");
|
|
20249
20249
|
be(this, "decoder", new TextDecoder());
|
|
20250
20250
|
this.dataChannel = t, this.dataChannel.binaryType = "arraybuffer", this.dataChannel.onopen = () => {
|
|
20251
|
-
this.
|
|
20251
|
+
this.setReady();
|
|
20252
20252
|
}, this.dataChannel.onclose = () => {
|
|
20253
20253
|
this.ready = !1, this.closeListeners.forEach((n) => n());
|
|
20254
20254
|
}, this.dataChannel.onerror = (n) => {
|
|
@@ -20262,6 +20262,9 @@ class DataChannel {
|
|
|
20262
20262
|
});
|
|
20263
20263
|
};
|
|
20264
20264
|
}
|
|
20265
|
+
setReady() {
|
|
20266
|
+
this.ready = !0, this.openListeners.forEach((t) => t());
|
|
20267
|
+
}
|
|
20265
20268
|
addOpenListener(t) {
|
|
20266
20269
|
this.openListeners.push(t);
|
|
20267
20270
|
}
|
|
@@ -20283,7 +20286,7 @@ class DataChannel {
|
|
|
20283
20286
|
async waitTilReady() {
|
|
20284
20287
|
return this.ready ? !0 : new Promise((n, r) => {
|
|
20285
20288
|
let o = setInterval(() => {
|
|
20286
|
-
this.ready && (clearInterval(o), n(!0)), this.error && r(this.error);
|
|
20289
|
+
this.dataChannel.readyState === "open" && this.setReady(), this.ready && (clearInterval(o), n(!0)), this.error && r(this.error);
|
|
20287
20290
|
}, 10);
|
|
20288
20291
|
});
|
|
20289
20292
|
}
|
|
@@ -22776,6 +22779,54 @@ async function getPeers() {
|
|
|
22776
22779
|
await e.shutdown();
|
|
22777
22780
|
}
|
|
22778
22781
|
}
|
|
22782
|
+
async function createDevice(e) {
|
|
22783
|
+
if (!Authentication.token)
|
|
22784
|
+
throw new Error("Not authenticated");
|
|
22785
|
+
return await (await fetch(`${FORMANT_API_URL}/v1/admin/devices`, {
|
|
22786
|
+
method: "POST",
|
|
22787
|
+
body: JSON.stringify(e),
|
|
22788
|
+
headers: {
|
|
22789
|
+
"Content-Type": "application/json",
|
|
22790
|
+
Authorization: "Bearer " + Authentication.token
|
|
22791
|
+
}
|
|
22792
|
+
})).json();
|
|
22793
|
+
}
|
|
22794
|
+
async function patchDevice(e, t) {
|
|
22795
|
+
if (!Authentication.token)
|
|
22796
|
+
throw new Error("Not authenticated");
|
|
22797
|
+
return await (await fetch(`${FORMANT_API_URL}/v1/admin/devices/${e}`, {
|
|
22798
|
+
method: "PATCH",
|
|
22799
|
+
body: JSON.stringify(t),
|
|
22800
|
+
headers: {
|
|
22801
|
+
"Content-Type": "application/json",
|
|
22802
|
+
Authorization: "Bearer " + Authentication.token
|
|
22803
|
+
}
|
|
22804
|
+
})).json();
|
|
22805
|
+
}
|
|
22806
|
+
async function getDevicesData() {
|
|
22807
|
+
if (!Authentication.token)
|
|
22808
|
+
throw new Error("Not authenticated");
|
|
22809
|
+
return (await (await fetch(`${FORMANT_API_URL}/v1/admin/device-details/query`, {
|
|
22810
|
+
method: "POST",
|
|
22811
|
+
body: JSON.stringify({ enabled: !0, type: "default" }),
|
|
22812
|
+
headers: {
|
|
22813
|
+
"Content-Type": "application/json",
|
|
22814
|
+
Authorization: "Bearer " + Authentication.token
|
|
22815
|
+
}
|
|
22816
|
+
})).json()).items;
|
|
22817
|
+
}
|
|
22818
|
+
async function queryDevicesData(e) {
|
|
22819
|
+
if (!Authentication.token)
|
|
22820
|
+
throw new Error("Not authenticated");
|
|
22821
|
+
return (await (await fetch(`${FORMANT_API_URL}/v1/admin/devices/query`, {
|
|
22822
|
+
method: "POST",
|
|
22823
|
+
body: JSON.stringify(e),
|
|
22824
|
+
headers: {
|
|
22825
|
+
"Content-Type": "application/json",
|
|
22826
|
+
Authorization: "Bearer " + Authentication.token
|
|
22827
|
+
}
|
|
22828
|
+
})).json()).items;
|
|
22829
|
+
}
|
|
22779
22830
|
class Device extends BaseDevice {
|
|
22780
22831
|
constructor(t, n, r, o) {
|
|
22781
22832
|
super(), this.id = t, this.name = n, this.organizationId = r, this.tags = o;
|
|
@@ -23103,31 +23154,8 @@ class Device extends BaseDevice {
|
|
|
23103
23154
|
async createShareLink(t, n) {
|
|
23104
23155
|
return t.scope.deviceIds = [this.id], await createShareLink(t, n);
|
|
23105
23156
|
}
|
|
23106
|
-
async createDevice(t) {
|
|
23107
|
-
if (!Authentication.token)
|
|
23108
|
-
throw new Error("Not authenticated");
|
|
23109
|
-
return await (await fetch(`${FORMANT_API_URL}/v1/admin/devices`, {
|
|
23110
|
-
method: "POST",
|
|
23111
|
-
body: JSON.stringify(t),
|
|
23112
|
-
headers: {
|
|
23113
|
-
"Content-Type": "application/json",
|
|
23114
|
-
Authorization: "Bearer " + Authentication.token
|
|
23115
|
-
}
|
|
23116
|
-
})).json();
|
|
23117
|
-
}
|
|
23118
|
-
async patchDevice(t, n) {
|
|
23119
|
-
if (!Authentication.token)
|
|
23120
|
-
throw new Error("Not authenticated");
|
|
23121
|
-
return await (await fetch(`${FORMANT_API_URL}/v1/admin/devices/${t}`, {
|
|
23122
|
-
method: "PATCH",
|
|
23123
|
-
body: JSON.stringify(n),
|
|
23124
|
-
headers: {
|
|
23125
|
-
"Content-Type": "application/json",
|
|
23126
|
-
Authorization: "Bearer " + Authentication.token
|
|
23127
|
-
}
|
|
23128
|
-
})).json();
|
|
23129
|
-
}
|
|
23130
23157
|
}
|
|
23158
|
+
be(Device, "createDevice", createDevice), be(Device, "patchDevice", patchDevice), be(Device, "getDevicesData", getDevicesData), be(Device, "queryDevicesData", queryDevicesData);
|
|
23131
23159
|
class PeerDevice extends BaseDevice {
|
|
23132
23160
|
constructor(n) {
|
|
23133
23161
|
super();
|