@formant/data-sdk 1.14.0 → 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.
@@ -1590,22 +1590,29 @@ class S extends Y {
1590
1590
  }
1591
1591
  )).json()).items;
1592
1592
  }
1593
- async getConfiguration() {
1594
- let e = await fetch(`${h}/v1/admin/devices/${this.id}`, {
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 t = await e.json();
1602
- if (!t.state.reportedConfiguration)
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 n = t.state.reportedConfiguration.version;
1607
- return e = await fetch(
1608
- `${h}/v1/admin/devices/${this.id}/configurations/${n}`,
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 e.json()).document;
1623
+ ), (await t.json()).document;
1617
1624
  }
1618
1625
  async getFileUrl(e) {
1619
1626
  return (await (await fetch(`${h}/v1/admin/files/query`, {