@formant/data-sdk 0.0.111 → 0.0.112

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.
@@ -20569,6 +20569,21 @@ const _Fleet = class {
20569
20569
  devices.items;
20570
20570
  return devices.items.map((_) => new Device(_.id, _.name, _.organizationId));
20571
20571
  }
20572
+ static async queryDevices(query) {
20573
+ if (!Authentication.token) {
20574
+ throw new Error("Not authenticated");
20575
+ }
20576
+ const data = await fetch(`${FORMANT_API_URL}/v1/admin/devices/query`, {
20577
+ method: "POST",
20578
+ body: JSON.stringify(query),
20579
+ headers: {
20580
+ "Content-Type": "application/json",
20581
+ Authorization: "Bearer " + Authentication.token
20582
+ }
20583
+ });
20584
+ const devices = await data.json();
20585
+ return devices.items.map((_) => new Device(_.id, _.name, _.organizationId));
20586
+ }
20572
20587
  static async getOnlineDevices() {
20573
20588
  if (!Authentication.token) {
20574
20589
  throw new Error("Not authenticated");
@@ -20758,6 +20773,32 @@ const _Fleet = class {
20758
20773
  });
20759
20774
  return (await interventions.json()).items;
20760
20775
  }
20776
+ static async getCurrentGroup() {
20777
+ if (!Authentication.token) {
20778
+ throw new Error("Not authenticated");
20779
+ }
20780
+ let urlParams2 = new URLSearchParams("");
20781
+ if (typeof window !== "undefined") {
20782
+ urlParams2 = new URLSearchParams(window.location.search);
20783
+ }
20784
+ const groupId = urlParams2.get("group");
20785
+ if (groupId === null || groupId.trim() === "") {
20786
+ return void 0;
20787
+ }
20788
+ const response = await fetch(`${FORMANT_API_URL}/v1/admin/groups/` + groupId, {
20789
+ headers: {
20790
+ "Content-Type": "application/json",
20791
+ Authorization: "Bearer " + Authentication.token
20792
+ }
20793
+ });
20794
+ const { tagKey, tagValue } = await response.json();
20795
+ const devices = await this.queryDevices({
20796
+ tags: { [tagKey]: [tagValue] },
20797
+ enabled: true,
20798
+ type: "default"
20799
+ });
20800
+ return devices;
20801
+ }
20761
20802
  };
20762
20803
  let Fleet = _Fleet;
20763
20804
  __publicField(Fleet, "defaultDeviceId");