@sanity/client 7.19.0 → 7.21.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/dist/index.cjs CHANGED
@@ -1283,7 +1283,8 @@ class LiveClient {
1283
1283
  */
1284
1284
  events({
1285
1285
  includeDrafts = !1,
1286
- tag: _tag
1286
+ tag: _tag,
1287
+ waitFor
1287
1288
  } = {}) {
1288
1289
  const {
1289
1290
  projectId,
@@ -1302,7 +1303,7 @@ class LiveClient {
1302
1303
  "The live events API requires a token or withCredentials when 'includeDrafts: true'. Please update your client configuration. The token should have the lowest possible access role."
1303
1304
  );
1304
1305
  const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, !1)), tag = _tag && requestTagPrefix ? [requestTagPrefix, _tag].join(".") : _tag;
1305
- tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true");
1306
+ tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true"), waitFor && url.searchParams.set("waitFor", waitFor);
1306
1307
  const esOptions = {};
1307
1308
  includeDrafts && withCredentials && (esOptions.withCredentials = !0), (includeDrafts && token || configHeaders) && (esOptions.headers = {}, includeDrafts && token && (esOptions.headers.Authorization = `Bearer ${token}`), configHeaders && Object.assign(esOptions.headers, configHeaders));
1308
1309
  const key = `${url.href}::${JSON.stringify(esOptions)}`, existing = eventsCache.get(key);
@@ -1603,9 +1604,18 @@ class ObservableProjectsClient {
1603
1604
  constructor(client, httpRequest) {
1604
1605
  this.#client = client, this.#httpRequest = httpRequest;
1605
1606
  }
1607
+ /**
1608
+ * Fetch a list of projects the authenticated user has access to.
1609
+ *
1610
+ * @param options - Options for the list request
1611
+ * - `includeMembers` - Whether to include members in the response (default: true)
1612
+ * - `includeFeatures` - Whether to include features in the response (default: true)
1613
+ * - `organizationId` - ID of the organization to fetch projects for
1614
+ * - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
1615
+ */
1606
1616
  list(options) {
1607
1617
  const query = {}, uri = "/projects";
1608
- return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership === !0 && (query.onlyExplicitMembership = "true"), _request(this.#client, this.#httpRequest, { uri, query });
1618
+ return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.includeFeatures === !1 && (query.includeFeatures = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership && (query.onlyExplicitMembership = "true"), _request(this.#client, this.#httpRequest, { uri, query });
1609
1619
  }
1610
1620
  /**
1611
1621
  * Fetch a project by project ID
@@ -1622,9 +1632,20 @@ class ProjectsClient {
1622
1632
  constructor(client, httpRequest) {
1623
1633
  this.#client = client, this.#httpRequest = httpRequest;
1624
1634
  }
1635
+ /**
1636
+ * Fetch a list of projects the authenticated user has access to.
1637
+ *
1638
+ * @param options - Options for the list request
1639
+ * - `includeMembers` - Whether to include members in the response (default: true)
1640
+ * - `includeFeatures` - Whether to include features in the response (default: true)
1641
+ * - `organizationId` - ID of the organization to fetch projects for
1642
+ * - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
1643
+ */
1625
1644
  list(options) {
1626
1645
  const query = {}, uri = "/projects";
1627
- return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership === !0 && (query.onlyExplicitMembership = "true"), rxjs.lastValueFrom(_request(this.#client, this.#httpRequest, { uri, query }));
1646
+ return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.includeFeatures === !1 && (query.includeFeatures = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership && (query.onlyExplicitMembership = "true"), rxjs.lastValueFrom(
1647
+ _request(this.#client, this.#httpRequest, { uri, query })
1648
+ );
1628
1649
  }
1629
1650
  /**
1630
1651
  * Fetch a project by project ID
@@ -2180,13 +2201,22 @@ class ObservableSanityClient {
2180
2201
  * Private properties
2181
2202
  */
2182
2203
  #clientConfig;
2204
+ #originalHttpRequest;
2183
2205
  #httpRequest;
2184
2206
  /**
2185
2207
  * Instance properties
2186
2208
  */
2187
2209
  listen = _listen;
2188
2210
  constructor(httpRequest, config$1 = config.defaultConfig) {
2189
- this.config(config$1), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
2211
+ this.config(config$1), this.#originalHttpRequest = httpRequest;
2212
+ const requestHandler = config$1._requestHandler;
2213
+ this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
2214
+ let bareClient;
2215
+ return (options, requester2) => {
2216
+ const opts = options;
2217
+ return bareClient || (bareClient = new SanityClient(httpRequest, { ...config$1, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
2218
+ };
2219
+ })() : httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
2190
2220
  video: new ObservableMediaLibraryVideoClient(this, this.#httpRequest)
2191
2221
  }, this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.agent = {
2192
2222
  action: new ObservableAgentsActionClient(this, this.#httpRequest)
@@ -2196,7 +2226,7 @@ class ObservableSanityClient {
2196
2226
  * Clone the client - returns a new instance
2197
2227
  */
2198
2228
  clone() {
2199
- return new ObservableSanityClient(this.#httpRequest, this.config());
2229
+ return new ObservableSanityClient(this.#originalHttpRequest, this.config());
2200
2230
  }
2201
2231
  config(newConfig) {
2202
2232
  if (newConfig === void 0)
@@ -2214,7 +2244,7 @@ class ObservableSanityClient {
2214
2244
  */
2215
2245
  withConfig(newConfig) {
2216
2246
  const thisConfig = this.config();
2217
- return new ObservableSanityClient(this.#httpRequest, {
2247
+ return new ObservableSanityClient(this.#originalHttpRequest, {
2218
2248
  ...thisConfig,
2219
2249
  ...newConfig,
2220
2250
  stega: {
@@ -2444,13 +2474,22 @@ class SanityClient {
2444
2474
  * Private properties
2445
2475
  */
2446
2476
  #clientConfig;
2477
+ #originalHttpRequest;
2447
2478
  #httpRequest;
2448
2479
  /**
2449
2480
  * Instance properties
2450
2481
  */
2451
2482
  listen = _listen;
2452
2483
  constructor(httpRequest, config$1 = config.defaultConfig) {
2453
- this.config(config$1), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
2484
+ this.config(config$1), this.#originalHttpRequest = httpRequest;
2485
+ const requestHandler = config$1._requestHandler;
2486
+ this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
2487
+ let bareClient;
2488
+ return (options, requester2) => {
2489
+ const opts = options;
2490
+ return bareClient || (bareClient = new SanityClient(httpRequest, { ...config$1, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
2491
+ };
2492
+ })() : httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
2454
2493
  video: new MediaLibraryVideoClient(this, this.#httpRequest)
2455
2494
  }, this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.agent = {
2456
2495
  action: new AgentActionsClient(this, this.#httpRequest)
@@ -2460,7 +2499,7 @@ class SanityClient {
2460
2499
  * Clone the client - returns a new instance
2461
2500
  */
2462
2501
  clone() {
2463
- return new SanityClient(this.#httpRequest, this.config());
2502
+ return new SanityClient(this.#originalHttpRequest, this.config());
2464
2503
  }
2465
2504
  config(newConfig) {
2466
2505
  if (newConfig === void 0)
@@ -2478,7 +2517,7 @@ class SanityClient {
2478
2517
  */
2479
2518
  withConfig(newConfig) {
2480
2519
  const thisConfig = this.config();
2481
- return new SanityClient(this.#httpRequest, {
2520
+ return new SanityClient(this.#originalHttpRequest, {
2482
2521
  ...thisConfig,
2483
2522
  ...newConfig,
2484
2523
  stega: {
@@ -2749,7 +2788,7 @@ function defineDeprecatedCreateClient(createClient2) {
2749
2788
  return config.printNoDefaultExport(), createClient2(config$1);
2750
2789
  };
2751
2790
  }
2752
- var name = "@sanity/client", version = "7.19.0";
2791
+ var name = "@sanity/client", version = "7.21.0";
2753
2792
  const middleware = [
2754
2793
  middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
2755
2794
  middleware$1.headers({ "User-Agent": `${name} ${version}` }),