@sanity/client 7.8.2 → 7.9.0

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 CHANGED
@@ -2047,7 +2047,7 @@ await client.agent.action.generate({
2047
2047
  type: 'groq',
2048
2048
  query: '*[_type==$type].title',
2049
2049
  params: {type: 'article'},
2050
- perspective: 'drafts' // optional
2050
+ perspective: 'drafts', // optional
2051
2051
  },
2052
2052
  },
2053
2053
  target: {path: ['body']},
@@ -1551,8 +1551,11 @@ class ObservableDatasetsClient {
1551
1551
  * Fetch a list of datasets for the configured project
1552
1552
  */
1553
1553
  list() {
1554
- return _request(this.#client, this.#httpRequest, {
1555
- uri: "/datasets",
1554
+ resourceGuard("dataset", this.#client.config());
1555
+ const config = this.#client.config(), projectId2 = config.projectId;
1556
+ let uri = "/datasets";
1557
+ return config.useProjectHostname === !1 && (uri = `/projects/${projectId2}/datasets`), _request(this.#client, this.#httpRequest, {
1558
+ uri,
1556
1559
  tag: null
1557
1560
  });
1558
1561
  }
@@ -1597,8 +1600,11 @@ class DatasetsClient {
1597
1600
  * Fetch a list of datasets for the configured project
1598
1601
  */
1599
1602
  list() {
1600
- return resourceGuard("dataset", this.#client.config()), rxjs.lastValueFrom(
1601
- _request(this.#client, this.#httpRequest, { uri: "/datasets", tag: null })
1603
+ resourceGuard("dataset", this.#client.config());
1604
+ const config = this.#client.config(), projectId2 = config.projectId;
1605
+ let uri = "/datasets";
1606
+ return config.useProjectHostname === !1 && (uri = `/projects/${projectId2}/datasets`), rxjs.lastValueFrom(
1607
+ _request(this.#client, this.#httpRequest, { uri, tag: null })
1602
1608
  );
1603
1609
  }
1604
1610
  }
@@ -1617,7 +1623,6 @@ class ObservableProjectsClient {
1617
1623
  this.#client = client, this.#httpRequest = httpRequest;
1618
1624
  }
1619
1625
  list(options) {
1620
- resourceGuard("projects", this.#client.config());
1621
1626
  const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
1622
1627
  return _request(this.#client, this.#httpRequest, { uri });
1623
1628
  }
@@ -1627,7 +1632,7 @@ class ObservableProjectsClient {
1627
1632
  * @param projectId - ID of the project to fetch
1628
1633
  */
1629
1634
  getById(projectId2) {
1630
- return resourceGuard("projects", this.#client.config()), _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` });
1635
+ return _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` });
1631
1636
  }
1632
1637
  }
1633
1638
  class ProjectsClient {
@@ -1637,7 +1642,6 @@ class ProjectsClient {
1637
1642
  this.#client = client, this.#httpRequest = httpRequest;
1638
1643
  }
1639
1644
  list(options) {
1640
- resourceGuard("projects", this.#client.config());
1641
1645
  const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
1642
1646
  return rxjs.lastValueFrom(_request(this.#client, this.#httpRequest, { uri }));
1643
1647
  }
@@ -1647,7 +1651,7 @@ class ProjectsClient {
1647
1651
  * @param projectId - ID of the project to fetch
1648
1652
  */
1649
1653
  getById(projectId2) {
1650
- return resourceGuard("projects", this.#client.config()), rxjs.lastValueFrom(
1654
+ return rxjs.lastValueFrom(
1651
1655
  _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` })
1652
1656
  );
1653
1657
  }