@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.d.cts CHANGED
@@ -811,6 +811,32 @@ export declare interface ClientConfig {
811
811
  * Lineage token for recursion control
812
812
  */
813
813
  lineage?: string
814
+ /**
815
+ * A custom request handler that intercepts all HTTP requests made by the client.
816
+ *
817
+ * Useful for logging, adding custom headers, refreshing auth tokens, rate limiting, etc.
818
+ *
819
+ * When using `withConfig()`, the new handler **replaces** the previous one (it does not
820
+ * wrap it). To compose handlers, you can chain them manually:
821
+ *
822
+ * ```ts
823
+ * const parent = createClient({...config, _requestHandler: handlerA})
824
+ * const child = parent.withConfig({
825
+ * _requestHandler: (req, defaultRequester) =>
826
+ * handlerB(req, (opts) => handlerA(opts, defaultRequester)),
827
+ * })
828
+ * ```
829
+ *
830
+ * Setting `_requestHandler` to `undefined` via `withConfig()` removes the handler.
831
+ *
832
+ * Note: This only applies to HTTP requests. Real-time listener connections
833
+ * (`client.listen()`) use EventSource and are not intercepted by this handler.
834
+ *
835
+ * @internal
836
+ * @deprecated Don't use outside of Sanity internals
837
+ * @see {@link RequestHandler}
838
+ */
839
+ _requestHandler?: RequestHandler
814
840
  }
815
841
 
816
842
  declare type ClientConfigResource =
@@ -2134,6 +2160,13 @@ export declare type ListenParams = {
2134
2160
  [key: string]: Any
2135
2161
  }
2136
2162
 
2163
+ declare type ListOptions = {
2164
+ includeMembers?: boolean
2165
+ includeFeatures?: boolean
2166
+ organizationId?: string
2167
+ onlyExplicitMembership?: boolean
2168
+ }
2169
+
2137
2170
  /**
2138
2171
  * @public
2139
2172
  */
@@ -2146,6 +2179,7 @@ export declare class LiveClient {
2146
2179
  events({
2147
2180
  includeDrafts,
2148
2181
  tag: _tag,
2182
+ waitFor,
2149
2183
  }?: {
2150
2184
  includeDrafts?: boolean
2151
2185
  /**
@@ -2154,6 +2188,11 @@ export declare class LiveClient {
2154
2188
  * @defaultValue `undefined`
2155
2189
  */
2156
2190
  tag?: string
2191
+ /**
2192
+ * Delays events until after a Sanity Function has processed them and called the callback endpoint.
2193
+ * When omitted, events are delivered immediately.
2194
+ */
2195
+ waitFor?: 'function'
2157
2196
  }): Observable<LiveEvent>
2158
2197
  }
2159
2198
 
@@ -2690,19 +2729,13 @@ export declare class ObservableProjectsClient {
2690
2729
  *
2691
2730
  * @param options - Options for the list request
2692
2731
  * - `includeMembers` - Whether to include members in the response (default: true)
2732
+ * - `includeFeatures` - Whether to include features in the response (default: true)
2693
2733
  * - `organizationId` - ID of the organization to fetch projects for
2694
- * - `onlyExplicitMembership` - Only include projects where the user has explicit membership (default: false)
2695
- */
2696
- list(options?: {
2697
- includeMembers?: true
2698
- organizationId?: string
2699
- onlyExplicitMembership?: boolean
2700
- }): Observable<SanityProject[]>
2701
- list(options?: {
2702
- includeMembers?: false
2703
- organizationId?: string
2704
- onlyExplicitMembership?: boolean
2705
- }): Observable<Omit<SanityProject, 'members'>[]>
2734
+ * - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
2735
+ */
2736
+ list<T extends ListOptions>(
2737
+ options?: T,
2738
+ ): Observable<Omit<SanityProject, OmittedProjectFields<T>>[]>
2706
2739
  /**
2707
2740
  * Fetch a project by project ID
2708
2741
  *
@@ -3857,6 +3890,18 @@ export declare class ObservableUsersClient {
3857
3890
  ): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
3858
3891
  }
3859
3892
 
3893
+ declare type OmittedProjectFields<T extends ListOptions | undefined> =
3894
+ | (T extends {
3895
+ includeMembers: false
3896
+ }
3897
+ ? 'members'
3898
+ : never)
3899
+ | (T extends {
3900
+ includeFeatures: false
3901
+ }
3902
+ ? 'features'
3903
+ : never)
3904
+
3860
3905
  /**
3861
3906
  * The listener connection has been established
3862
3907
  * note: it's usually a better option to use the 'welcome' event
@@ -4073,19 +4118,11 @@ export declare class ProjectsClient {
4073
4118
  *
4074
4119
  * @param options - Options for the list request
4075
4120
  * - `includeMembers` - Whether to include members in the response (default: true)
4121
+ * - `includeFeatures` - Whether to include features in the response (default: true)
4076
4122
  * - `organizationId` - ID of the organization to fetch projects for
4077
- * - `onlyExplicitMembership` - Only include projects where the user has explicit membership (default: false)
4078
- */
4079
- list(options?: {
4080
- includeMembers?: true
4081
- organizationId?: string
4082
- onlyExplicitMembership?: boolean
4083
- }): Promise<SanityProject[]>
4084
- list(options?: {
4085
- includeMembers?: false
4086
- organizationId?: string
4087
- onlyExplicitMembership?: boolean
4088
- }): Promise<Omit<SanityProject, 'members'>[]>
4123
+ * - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
4124
+ */
4125
+ list<T extends ListOptions>(options?: T): Promise<Omit<SanityProject, OmittedProjectFields<T>>[]>
4089
4126
  /**
4090
4127
  * Fetch a project by project ID
4091
4128
  *
@@ -4765,6 +4802,44 @@ export declare interface ReplaceVersionAction {
4765
4802
  /** @public */
4766
4803
  export declare const requester: Requester
4767
4804
 
4805
+ /**
4806
+ * A function that intercepts HTTP requests made by the client.
4807
+ *
4808
+ * Receives the resolved request options, a `defaultRequester` function that
4809
+ * executes the request through the normal pipeline, and a `client` instance
4810
+ * without a `_requestHandler` (to avoid recursive interception).
4811
+ *
4812
+ * The consumer can:
4813
+ * - Modify request options before calling `defaultRequester`
4814
+ * - Transform the response stream (e.g. via `pipe`)
4815
+ * - Skip `defaultRequester` entirely and return a custom Observable
4816
+ * - Use `client` to make additional requests (e.g. refresh an auth token on 401)
4817
+ *
4818
+ * When set via `withConfig()`, the new handler **replaces** (not wraps) the previous one.
4819
+ *
4820
+ * Note: This only applies to HTTP requests. Real-time listener connections
4821
+ * (`client.listen()`) use EventSource and are not intercepted by this handler.
4822
+ *
4823
+ * @param request - The resolved request options including `url`
4824
+ * @param defaultRequester - Executes the request through the normal pipeline
4825
+ * @param client - A client instance with the same configuration but without a `_requestHandler`,
4826
+ * useful for making side requests (e.g. token refresh) without triggering the handler recursively
4827
+ *
4828
+ * @internal
4829
+ * @deprecated Don't use outside of Sanity internals
4830
+ */
4831
+ export declare type RequestHandler = (
4832
+ request: RequestOptions & {
4833
+ url: string
4834
+ },
4835
+ defaultRequester: (
4836
+ options: RequestOptions & {
4837
+ url: string
4838
+ },
4839
+ ) => Observable<HttpRequestEvent>,
4840
+ client: SanityClient,
4841
+ ) => Observable<HttpRequestEvent>
4842
+
4768
4843
  /** @internal */
4769
4844
  export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
4770
4845
  url?: string
@@ -5738,6 +5813,7 @@ export declare interface SanityProject {
5738
5813
  pendingInvites?: number
5739
5814
  maxRetentionDays?: number
5740
5815
  members: SanityProjectMember[]
5816
+ features: string[]
5741
5817
  metadata: {
5742
5818
  cliInitializedAt?: string
5743
5819
  color?: string
package/dist/index.d.ts CHANGED
@@ -811,6 +811,32 @@ export declare interface ClientConfig {
811
811
  * Lineage token for recursion control
812
812
  */
813
813
  lineage?: string
814
+ /**
815
+ * A custom request handler that intercepts all HTTP requests made by the client.
816
+ *
817
+ * Useful for logging, adding custom headers, refreshing auth tokens, rate limiting, etc.
818
+ *
819
+ * When using `withConfig()`, the new handler **replaces** the previous one (it does not
820
+ * wrap it). To compose handlers, you can chain them manually:
821
+ *
822
+ * ```ts
823
+ * const parent = createClient({...config, _requestHandler: handlerA})
824
+ * const child = parent.withConfig({
825
+ * _requestHandler: (req, defaultRequester) =>
826
+ * handlerB(req, (opts) => handlerA(opts, defaultRequester)),
827
+ * })
828
+ * ```
829
+ *
830
+ * Setting `_requestHandler` to `undefined` via `withConfig()` removes the handler.
831
+ *
832
+ * Note: This only applies to HTTP requests. Real-time listener connections
833
+ * (`client.listen()`) use EventSource and are not intercepted by this handler.
834
+ *
835
+ * @internal
836
+ * @deprecated Don't use outside of Sanity internals
837
+ * @see {@link RequestHandler}
838
+ */
839
+ _requestHandler?: RequestHandler
814
840
  }
815
841
 
816
842
  declare type ClientConfigResource =
@@ -2134,6 +2160,13 @@ export declare type ListenParams = {
2134
2160
  [key: string]: Any
2135
2161
  }
2136
2162
 
2163
+ declare type ListOptions = {
2164
+ includeMembers?: boolean
2165
+ includeFeatures?: boolean
2166
+ organizationId?: string
2167
+ onlyExplicitMembership?: boolean
2168
+ }
2169
+
2137
2170
  /**
2138
2171
  * @public
2139
2172
  */
@@ -2146,6 +2179,7 @@ export declare class LiveClient {
2146
2179
  events({
2147
2180
  includeDrafts,
2148
2181
  tag: _tag,
2182
+ waitFor,
2149
2183
  }?: {
2150
2184
  includeDrafts?: boolean
2151
2185
  /**
@@ -2154,6 +2188,11 @@ export declare class LiveClient {
2154
2188
  * @defaultValue `undefined`
2155
2189
  */
2156
2190
  tag?: string
2191
+ /**
2192
+ * Delays events until after a Sanity Function has processed them and called the callback endpoint.
2193
+ * When omitted, events are delivered immediately.
2194
+ */
2195
+ waitFor?: 'function'
2157
2196
  }): Observable<LiveEvent>
2158
2197
  }
2159
2198
 
@@ -2690,19 +2729,13 @@ export declare class ObservableProjectsClient {
2690
2729
  *
2691
2730
  * @param options - Options for the list request
2692
2731
  * - `includeMembers` - Whether to include members in the response (default: true)
2732
+ * - `includeFeatures` - Whether to include features in the response (default: true)
2693
2733
  * - `organizationId` - ID of the organization to fetch projects for
2694
- * - `onlyExplicitMembership` - Only include projects where the user has explicit membership (default: false)
2695
- */
2696
- list(options?: {
2697
- includeMembers?: true
2698
- organizationId?: string
2699
- onlyExplicitMembership?: boolean
2700
- }): Observable<SanityProject[]>
2701
- list(options?: {
2702
- includeMembers?: false
2703
- organizationId?: string
2704
- onlyExplicitMembership?: boolean
2705
- }): Observable<Omit<SanityProject, 'members'>[]>
2734
+ * - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
2735
+ */
2736
+ list<T extends ListOptions>(
2737
+ options?: T,
2738
+ ): Observable<Omit<SanityProject, OmittedProjectFields<T>>[]>
2706
2739
  /**
2707
2740
  * Fetch a project by project ID
2708
2741
  *
@@ -3857,6 +3890,18 @@ export declare class ObservableUsersClient {
3857
3890
  ): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
3858
3891
  }
3859
3892
 
3893
+ declare type OmittedProjectFields<T extends ListOptions | undefined> =
3894
+ | (T extends {
3895
+ includeMembers: false
3896
+ }
3897
+ ? 'members'
3898
+ : never)
3899
+ | (T extends {
3900
+ includeFeatures: false
3901
+ }
3902
+ ? 'features'
3903
+ : never)
3904
+
3860
3905
  /**
3861
3906
  * The listener connection has been established
3862
3907
  * note: it's usually a better option to use the 'welcome' event
@@ -4073,19 +4118,11 @@ export declare class ProjectsClient {
4073
4118
  *
4074
4119
  * @param options - Options for the list request
4075
4120
  * - `includeMembers` - Whether to include members in the response (default: true)
4121
+ * - `includeFeatures` - Whether to include features in the response (default: true)
4076
4122
  * - `organizationId` - ID of the organization to fetch projects for
4077
- * - `onlyExplicitMembership` - Only include projects where the user has explicit membership (default: false)
4078
- */
4079
- list(options?: {
4080
- includeMembers?: true
4081
- organizationId?: string
4082
- onlyExplicitMembership?: boolean
4083
- }): Promise<SanityProject[]>
4084
- list(options?: {
4085
- includeMembers?: false
4086
- organizationId?: string
4087
- onlyExplicitMembership?: boolean
4088
- }): Promise<Omit<SanityProject, 'members'>[]>
4123
+ * - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
4124
+ */
4125
+ list<T extends ListOptions>(options?: T): Promise<Omit<SanityProject, OmittedProjectFields<T>>[]>
4089
4126
  /**
4090
4127
  * Fetch a project by project ID
4091
4128
  *
@@ -4765,6 +4802,44 @@ export declare interface ReplaceVersionAction {
4765
4802
  /** @public */
4766
4803
  export declare const requester: Requester
4767
4804
 
4805
+ /**
4806
+ * A function that intercepts HTTP requests made by the client.
4807
+ *
4808
+ * Receives the resolved request options, a `defaultRequester` function that
4809
+ * executes the request through the normal pipeline, and a `client` instance
4810
+ * without a `_requestHandler` (to avoid recursive interception).
4811
+ *
4812
+ * The consumer can:
4813
+ * - Modify request options before calling `defaultRequester`
4814
+ * - Transform the response stream (e.g. via `pipe`)
4815
+ * - Skip `defaultRequester` entirely and return a custom Observable
4816
+ * - Use `client` to make additional requests (e.g. refresh an auth token on 401)
4817
+ *
4818
+ * When set via `withConfig()`, the new handler **replaces** (not wraps) the previous one.
4819
+ *
4820
+ * Note: This only applies to HTTP requests. Real-time listener connections
4821
+ * (`client.listen()`) use EventSource and are not intercepted by this handler.
4822
+ *
4823
+ * @param request - The resolved request options including `url`
4824
+ * @param defaultRequester - Executes the request through the normal pipeline
4825
+ * @param client - A client instance with the same configuration but without a `_requestHandler`,
4826
+ * useful for making side requests (e.g. token refresh) without triggering the handler recursively
4827
+ *
4828
+ * @internal
4829
+ * @deprecated Don't use outside of Sanity internals
4830
+ */
4831
+ export declare type RequestHandler = (
4832
+ request: RequestOptions & {
4833
+ url: string
4834
+ },
4835
+ defaultRequester: (
4836
+ options: RequestOptions & {
4837
+ url: string
4838
+ },
4839
+ ) => Observable<HttpRequestEvent>,
4840
+ client: SanityClient,
4841
+ ) => Observable<HttpRequestEvent>
4842
+
4768
4843
  /** @internal */
4769
4844
  export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
4770
4845
  url?: string
@@ -5738,6 +5813,7 @@ export declare interface SanityProject {
5738
5813
  pendingInvites?: number
5739
5814
  maxRetentionDays?: number
5740
5815
  members: SanityProjectMember[]
5816
+ features: string[]
5741
5817
  metadata: {
5742
5818
  cliInitializedAt?: string
5743
5819
  color?: string
package/dist/index.js CHANGED
@@ -1269,7 +1269,8 @@ class LiveClient {
1269
1269
  */
1270
1270
  events({
1271
1271
  includeDrafts = !1,
1272
- tag: _tag
1272
+ tag: _tag,
1273
+ waitFor
1273
1274
  } = {}) {
1274
1275
  const {
1275
1276
  projectId,
@@ -1288,7 +1289,7 @@ class LiveClient {
1288
1289
  "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."
1289
1290
  );
1290
1291
  const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, !1)), tag = _tag && requestTagPrefix ? [requestTagPrefix, _tag].join(".") : _tag;
1291
- tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true");
1292
+ tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true"), waitFor && url.searchParams.set("waitFor", waitFor);
1292
1293
  const esOptions = {};
1293
1294
  includeDrafts && withCredentials && (esOptions.withCredentials = !0), (includeDrafts && token || configHeaders) && (esOptions.headers = {}, includeDrafts && token && (esOptions.headers.Authorization = `Bearer ${token}`), configHeaders && Object.assign(esOptions.headers, configHeaders));
1294
1295
  const key = `${url.href}::${JSON.stringify(esOptions)}`, existing = eventsCache.get(key);
@@ -1589,9 +1590,18 @@ class ObservableProjectsClient {
1589
1590
  constructor(client, httpRequest) {
1590
1591
  this.#client = client, this.#httpRequest = httpRequest;
1591
1592
  }
1593
+ /**
1594
+ * Fetch a list of projects the authenticated user has access to.
1595
+ *
1596
+ * @param options - Options for the list request
1597
+ * - `includeMembers` - Whether to include members in the response (default: true)
1598
+ * - `includeFeatures` - Whether to include features in the response (default: true)
1599
+ * - `organizationId` - ID of the organization to fetch projects for
1600
+ * - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
1601
+ */
1592
1602
  list(options) {
1593
1603
  const query = {}, uri = "/projects";
1594
- 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 });
1604
+ 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 });
1595
1605
  }
1596
1606
  /**
1597
1607
  * Fetch a project by project ID
@@ -1608,9 +1618,20 @@ class ProjectsClient {
1608
1618
  constructor(client, httpRequest) {
1609
1619
  this.#client = client, this.#httpRequest = httpRequest;
1610
1620
  }
1621
+ /**
1622
+ * Fetch a list of projects the authenticated user has access to.
1623
+ *
1624
+ * @param options - Options for the list request
1625
+ * - `includeMembers` - Whether to include members in the response (default: true)
1626
+ * - `includeFeatures` - Whether to include features in the response (default: true)
1627
+ * - `organizationId` - ID of the organization to fetch projects for
1628
+ * - `onlyExplicitMembership` - Whether to include only projects with explicit membership (default: false)
1629
+ */
1611
1630
  list(options) {
1612
1631
  const query = {}, uri = "/projects";
1613
- return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership === !0 && (query.onlyExplicitMembership = "true"), lastValueFrom(_request(this.#client, this.#httpRequest, { uri, query }));
1632
+ return options?.includeMembers === !1 && (query.includeMembers = "false"), options?.includeFeatures === !1 && (query.includeFeatures = "false"), options?.organizationId && (query.organizationId = options.organizationId), options?.onlyExplicitMembership && (query.onlyExplicitMembership = "true"), lastValueFrom(
1633
+ _request(this.#client, this.#httpRequest, { uri, query })
1634
+ );
1614
1635
  }
1615
1636
  /**
1616
1637
  * Fetch a project by project ID
@@ -2166,13 +2187,22 @@ class ObservableSanityClient {
2166
2187
  * Private properties
2167
2188
  */
2168
2189
  #clientConfig;
2190
+ #originalHttpRequest;
2169
2191
  #httpRequest;
2170
2192
  /**
2171
2193
  * Instance properties
2172
2194
  */
2173
2195
  listen = _listen;
2174
2196
  constructor(httpRequest, config = defaultConfig) {
2175
- this.config(config), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
2197
+ this.config(config), this.#originalHttpRequest = httpRequest;
2198
+ const requestHandler = config._requestHandler;
2199
+ this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
2200
+ let bareClient;
2201
+ return (options, requester2) => {
2202
+ const opts = options;
2203
+ return bareClient || (bareClient = new SanityClient(httpRequest, { ...config, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
2204
+ };
2205
+ })() : httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
2176
2206
  video: new ObservableMediaLibraryVideoClient(this, this.#httpRequest)
2177
2207
  }, this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.agent = {
2178
2208
  action: new ObservableAgentsActionClient(this, this.#httpRequest)
@@ -2182,7 +2212,7 @@ class ObservableSanityClient {
2182
2212
  * Clone the client - returns a new instance
2183
2213
  */
2184
2214
  clone() {
2185
- return new ObservableSanityClient(this.#httpRequest, this.config());
2215
+ return new ObservableSanityClient(this.#originalHttpRequest, this.config());
2186
2216
  }
2187
2217
  config(newConfig) {
2188
2218
  if (newConfig === void 0)
@@ -2200,7 +2230,7 @@ class ObservableSanityClient {
2200
2230
  */
2201
2231
  withConfig(newConfig) {
2202
2232
  const thisConfig = this.config();
2203
- return new ObservableSanityClient(this.#httpRequest, {
2233
+ return new ObservableSanityClient(this.#originalHttpRequest, {
2204
2234
  ...thisConfig,
2205
2235
  ...newConfig,
2206
2236
  stega: {
@@ -2430,13 +2460,22 @@ class SanityClient {
2430
2460
  * Private properties
2431
2461
  */
2432
2462
  #clientConfig;
2463
+ #originalHttpRequest;
2433
2464
  #httpRequest;
2434
2465
  /**
2435
2466
  * Instance properties
2436
2467
  */
2437
2468
  listen = _listen;
2438
2469
  constructor(httpRequest, config = defaultConfig) {
2439
- this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
2470
+ this.config(config), this.#originalHttpRequest = httpRequest;
2471
+ const requestHandler = config._requestHandler;
2472
+ this.#httpRequest = requestHandler ? /* @__PURE__ */ (() => {
2473
+ let bareClient;
2474
+ return (options, requester2) => {
2475
+ const opts = options;
2476
+ return bareClient || (bareClient = new SanityClient(httpRequest, { ...config, _requestHandler: void 0 })), requestHandler(opts, (o) => httpRequest(o, requester2), bareClient);
2477
+ };
2478
+ })() : httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.mediaLibrary = {
2440
2479
  video: new MediaLibraryVideoClient(this, this.#httpRequest)
2441
2480
  }, this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.agent = {
2442
2481
  action: new AgentActionsClient(this, this.#httpRequest)
@@ -2446,7 +2485,7 @@ class SanityClient {
2446
2485
  * Clone the client - returns a new instance
2447
2486
  */
2448
2487
  clone() {
2449
- return new SanityClient(this.#httpRequest, this.config());
2488
+ return new SanityClient(this.#originalHttpRequest, this.config());
2450
2489
  }
2451
2490
  config(newConfig) {
2452
2491
  if (newConfig === void 0)
@@ -2464,7 +2503,7 @@ class SanityClient {
2464
2503
  */
2465
2504
  withConfig(newConfig) {
2466
2505
  const thisConfig = this.config();
2467
- return new SanityClient(this.#httpRequest, {
2506
+ return new SanityClient(this.#originalHttpRequest, {
2468
2507
  ...thisConfig,
2469
2508
  ...newConfig,
2470
2509
  stega: {
@@ -2735,7 +2774,7 @@ function defineDeprecatedCreateClient(createClient2) {
2735
2774
  return printNoDefaultExport(), createClient2(config);
2736
2775
  };
2737
2776
  }
2738
- var name = "@sanity/client", version = "7.19.0";
2777
+ var name = "@sanity/client", version = "7.21.0";
2739
2778
  const middleware = [
2740
2779
  debug({ verbose: !0, namespace: "sanity:client" }),
2741
2780
  headers({ "User-Agent": `${name} ${version}` }),