@sanity/client 5.4.2 → 5.4.3-dev.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "5.4.2",
3
+ "version": "5.4.3-dev.1",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -33,6 +33,7 @@
33
33
  "import": "./dist/index.browser.js"
34
34
  },
35
35
  "deno": "./dist/index.browser.js",
36
+ "edge": "./dist/index.browser.js",
36
37
  "edge-light": "./dist/index.browser.js",
37
38
  "worker": "./dist/index.browser.js",
38
39
  "source": "./src/index.ts",
@@ -103,23 +104,23 @@
103
104
  "@types/node": "^18.15.10",
104
105
  "@typescript-eslint/eslint-plugin": "^5.57.0",
105
106
  "@typescript-eslint/parser": "^5.57.0",
106
- "@vitest/coverage-c8": "^0.29.8",
107
+ "@vitest/coverage-c8": "^0.30.0",
107
108
  "eslint": "^8.36.0",
108
109
  "eslint-config-prettier": "^8.8.0",
109
110
  "eslint-plugin-prettier": "^4.2.1",
110
111
  "eslint-plugin-simple-import-sort": "^10.0.0",
111
112
  "faucet": "^0.0.4",
112
- "happy-dom": "^8.9.0",
113
+ "happy-dom": "^9.0.0",
113
114
  "ls-engines": "^0.9.0",
114
115
  "nock": "^13.3.0",
115
116
  "prettier": "^2.8.7",
116
117
  "prettier-plugin-packagejson": "^2.4.3",
117
- "rimraf": "^4.4.1",
118
+ "rimraf": "^5.0.0",
118
119
  "rollup": "^3.20.2",
119
120
  "sse-channel": "^4.0.0",
120
121
  "terser": "^5.16.8",
121
122
  "typescript": "^5.0.2",
122
- "vitest": "^0.29.8",
123
+ "vitest": "^0.30.0",
123
124
  "vitest-github-actions-reporter": "^0.10.0"
124
125
  },
125
126
  "engines": {
@@ -1210,22 +1210,25 @@ export class SanityClient {
1210
1210
  }
1211
1211
 
1212
1212
  /**
1213
- * DEPRECATED: Perform an HTTP request against the Sanity API
1213
+ * Perform a request against the Sanity API
1214
+ * NOTE: Only use this for Sanity API endpoints, not for your own APIs!
1214
1215
  *
1215
- * @deprecated Use your own request library!
1216
1216
  * @param options - Request options
1217
+ * @returns Promise resolving to the response body
1217
1218
  */
1218
1219
  request<R = Any>(options: RawRequestOptions): Promise<R> {
1219
1220
  return lastValueFrom(dataMethods._request<R>(this, this.#httpRequest, options))
1220
1221
  }
1221
1222
 
1222
1223
  /**
1223
- * DEPRECATED: Perform an HTTP request a `/data` sub-endpoint
1224
+ * Perform an HTTP request a `/data` sub-endpoint
1225
+ * NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
1224
1226
  *
1225
- * @deprecated Use your own request library!
1227
+ * @deprecated - Use `request()` or your own HTTP library instead
1226
1228
  * @param endpoint - Endpoint to hit (mutate, query etc)
1227
1229
  * @param body - Request body
1228
1230
  * @param options - Request options
1231
+ * @internal
1229
1232
  */
1230
1233
  dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any> {
1231
1234
  return lastValueFrom(dataMethods._dataRequest(this, this.#httpRequest, endpoint, body, options))
package/src/config.ts CHANGED
@@ -75,7 +75,8 @@ export const initConfig = (
75
75
 
76
76
  newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, '')
77
77
  newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost
78
- newConfig.useCdn = Boolean(newConfig.useCdn) && !newConfig.withCredentials
78
+ // If `useCdn` is undefined, we treat it as `true`
79
+ newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials
79
80
 
80
81
  validateApiVersion(newConfig.apiVersion)
81
82
 
@@ -302,6 +302,10 @@ export function _requestObservable<R>(
302
302
  options.query = {tag: validate.requestTag(tag), ...options.query}
303
303
  }
304
304
 
305
+ if (config.resultSourceMap) {
306
+ options.query = {resultSourceMap: true, ...options.query}
307
+ }
308
+
305
309
  const reqOptions = requestOptions(
306
310
  config,
307
311
  Object.assign({}, options, {
@@ -1,11 +1,10 @@
1
- import {debug, headers, retry} from 'get-it/middleware'
1
+ import {debug, headers} from 'get-it/middleware'
2
2
 
3
3
  import {name, version} from '../../package.json'
4
4
 
5
5
  const middleware = [
6
6
  debug({verbose: true, namespace: 'sanity:client'}),
7
7
  headers({'User-Agent': `${name} ${version}`}),
8
- retry({maxRetries: 3}),
9
8
  ]
10
9
 
11
10
  export default middleware
@@ -1,5 +1,5 @@
1
1
  import {getIt, type Middlewares} from 'get-it'
2
- import {jsonRequest, jsonResponse, observable, progress} from 'get-it/middleware'
2
+ import {jsonRequest, jsonResponse, observable, progress, retry} from 'get-it/middleware'
3
3
  import {Observable} from 'rxjs'
4
4
 
5
5
  import type {Any, HttpRequest, RequestOptions} from '../types'
@@ -27,8 +27,22 @@ const printWarnings = {
27
27
  }
28
28
 
29
29
  /** @internal */
30
- export function defineHttpRequest(envMiddleware: Middlewares): HttpRequest {
30
+ export function defineHttpRequest(
31
+ envMiddleware: Middlewares,
32
+ {
33
+ maxRetries = 5,
34
+ retryDelay,
35
+ }: {maxRetries?: number; retryDelay?: (attemptNumber: number) => number}
36
+ ): HttpRequest {
31
37
  const request = getIt([
38
+ maxRetries > 0
39
+ ? retry({
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ retryDelay: retryDelay as any, // This option is typed incorrectly in get-it.
42
+ maxRetries,
43
+ shouldRetry,
44
+ })
45
+ : {},
32
46
  ...envMiddleware,
33
47
  printWarnings,
34
48
  jsonRequest(),
@@ -46,3 +60,29 @@ export function defineHttpRequest(envMiddleware: Middlewares): HttpRequest {
46
60
 
47
61
  return httpRequest
48
62
  }
63
+
64
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
+ function shouldRetry(err: any, attempt: number, options: any) {
66
+ // By default `retry.shouldRetry` doesn't retry on server errors so we add our own logic.
67
+
68
+ const isSafe = options.method === 'GET' || options.method === 'HEAD'
69
+ const isQuery = options.uri.startsWith('/data/query')
70
+ const isRetriableResponse =
71
+ err.response &&
72
+ (err.response.statusCode === 429 ||
73
+ err.response.statusCode === 502 ||
74
+ err.response.statusCode === 503)
75
+
76
+ // We retry the following errors:
77
+ // - 429 means that the request was rate limited. It's a bit difficult
78
+ // to know exactly how long it makes sense to wait and/or how many
79
+ // attempts we should retry, but the backoff should alleviate the
80
+ // additional load.
81
+ // - 502/503 can occur when certain components struggle to talk to their
82
+ // upstream dependencies. This is most likely a temporary problem
83
+ // and retrying makes sense.
84
+
85
+ if ((isSafe || isQuery) && isRetriableResponse) return true
86
+
87
+ return retry.shouldRetry(err, attempt, options)
88
+ }
@@ -11,12 +11,19 @@ export * from './SanityClient'
11
11
  export * from './types'
12
12
 
13
13
  // Set the http client to use for requests, and its environment specific middleware
14
- const httpRequest = defineHttpRequest(envMiddleware)
14
+ const httpRequest = defineHttpRequest(envMiddleware, {})
15
15
  /** @public */
16
16
  export const requester = httpRequest.defaultRequester
17
17
 
18
18
  /** @public */
19
- export const createClient = (config: ClientConfig) => new SanityClient(httpRequest, config)
19
+ export const createClient = (config: ClientConfig) =>
20
+ new SanityClient(
21
+ defineHttpRequest(envMiddleware, {
22
+ maxRetries: config.maxRetries,
23
+ retryDelay: config.retryDelay,
24
+ }),
25
+ config
26
+ )
20
27
 
21
28
  /**
22
29
  * @public
package/src/index.ts CHANGED
@@ -11,12 +11,19 @@ export * from './SanityClient'
11
11
  export * from './types'
12
12
 
13
13
  // Set the http client to use for requests, and its environment specific middleware
14
- const httpRequest = defineHttpRequest(envMiddleware)
14
+ const httpRequest = defineHttpRequest(envMiddleware, {})
15
15
  /** @public */
16
16
  export const requester = httpRequest.defaultRequester
17
17
 
18
18
  /** @public */
19
- export const createClient = (config: ClientConfig) => new SanityClient(httpRequest, config)
19
+ export const createClient = (config: ClientConfig) =>
20
+ new SanityClient(
21
+ defineHttpRequest(envMiddleware, {
22
+ maxRetries: config.maxRetries,
23
+ retryDelay: config.retryDelay,
24
+ }),
25
+ config
26
+ )
20
27
 
21
28
  /**
22
29
  * @public
@@ -1,6 +1,9 @@
1
+ // @TODO the types in this file should be split into their own files, that's why the file is named `_legacy`
1
2
  // deno-lint-ignore-file no-empty-interface
2
3
  import type {Requester} from 'get-it'
3
4
 
5
+ import type {ContentSourceMap} from './resultSourceMap'
6
+
4
7
  /**
5
8
  * Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
6
9
  * @internal
@@ -31,6 +34,7 @@ export interface RequestOptions {
31
34
  export interface ClientConfig {
32
35
  projectId?: string
33
36
  dataset?: string
37
+ /** @defaultValue true */
34
38
  useCdn?: boolean
35
39
  token?: string
36
40
  apiHost?: string
@@ -42,6 +46,19 @@ export interface ClientConfig {
42
46
  allowReconfigure?: boolean
43
47
  timeout?: number
44
48
 
49
+ /** Number of retries for requests. Defaults to 5. */
50
+ maxRetries?: number
51
+
52
+ /**
53
+ * The amount of time, in milliseconds, to wait before retrying, given an attemptNumber (starting at 0).
54
+ *
55
+ * Defaults to exponential back-off, starting at 100ms, doubling for each attempt, together with random
56
+ * jitter between 0 and 100 milliseconds. More specifically the following algorithm is used:
57
+ *
58
+ * Delay = 100 * 2^attemptNumber + randomNumberBetween0and100
59
+ */
60
+ retryDelay?: (attemptNumber: number) => number
61
+
45
62
  /**
46
63
  * @deprecated Don't use
47
64
  */
@@ -51,6 +68,8 @@ export interface ClientConfig {
51
68
  * @deprecated Don't use
52
69
  */
53
70
  requester?: Requester
71
+
72
+ resultSourceMap?: boolean
54
73
  }
55
74
 
56
75
  /** @public */
@@ -456,21 +475,22 @@ export interface ListenOptions {
456
475
  tag?: string
457
476
  }
458
477
 
459
- /** @internal */
478
+ /** @public */
460
479
  export type FilteredResponseQueryOptions = RequestOptions & {
461
480
  filterResponse?: true
462
481
  }
463
482
 
464
- /** @internal */
483
+ /** @public */
465
484
  export type UnfilteredResponseQueryOptions = RequestOptions & {
466
485
  filterResponse: false
467
486
  }
468
487
 
469
- /** @internal */
488
+ /** @public */
470
489
  export interface RawQueryResponse<R> {
471
490
  q: string
472
491
  ms: number
473
492
  result: R
493
+ resultSourceMap: ContentSourceMap
474
494
  }
475
495
 
476
496
  /** @internal */
@@ -0,0 +1,2 @@
1
+ export type * from './_legacy'
2
+ export type * from './resultSourceMap'
@@ -0,0 +1,60 @@
1
+ import type {SanityDocument} from './_legacy'
2
+
3
+ /**
4
+ * DocumentValueSource is a path to a value within a document
5
+ * @public
6
+ */
7
+ export type ContentSourceMapDocumentValueSource = {
8
+ type: 'documentValue'
9
+ // index location of the document
10
+ document: number
11
+ // index location of the path
12
+ path: number
13
+ }
14
+ /**
15
+ * When a value is not from a source, its a literal
16
+ * @public
17
+ */
18
+ export type ContentSourceMapLiteralSource = {
19
+ type: 'literal'
20
+ }
21
+ /**
22
+ * When a field source is unknown
23
+ * @public
24
+ */
25
+ export type ContentSourceMapUnknownSource = {
26
+ type: 'unknown'
27
+ }
28
+ /** @public */
29
+ export type ContentSourceMapSource =
30
+ | ContentSourceMapDocumentValueSource
31
+ | ContentSourceMapLiteralSource
32
+ | ContentSourceMapUnknownSource
33
+ /**
34
+ * ValueMapping is a mapping when for value that is from a single source value
35
+ * It may refer to a field within a document or a literal value
36
+ * @public
37
+ */
38
+ export type ContentSourceMapValueMapping = {
39
+ type: 'value'
40
+ // source of the value
41
+ source: ContentSourceMapSource
42
+ }
43
+ /** @public */
44
+ export type ContentSourceMapMapping = ContentSourceMapValueMapping
45
+
46
+ /** @public */
47
+ export type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>
48
+
49
+ /** @public */
50
+ export type ContentSourceMapDocuments = SanityDocument[]
51
+
52
+ /** @public */
53
+ export type ContentSourceMapPaths = string[]
54
+
55
+ /** @public */
56
+ export type ContentSourceMap = {
57
+ mappings: ContentSourceMapMappings
58
+ documents: ContentSourceMapDocuments
59
+ paths: ContentSourceMapPaths
60
+ }
package/src/warnings.ts CHANGED
@@ -7,10 +7,9 @@ const createWarningPrinter = (message: string[]) =>
7
7
  once((...args: Any[]) => console.warn(message.join(' '), ...args))
8
8
 
9
9
  export const printCdnWarning = createWarningPrinter([
10
- 'You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and',
11
- `cheaper. Think about it! For more info, see ${generateHelpUrl('js-client-cdn-configuration')} `,
12
- 'To hide this warning, please set the `useCdn` option to either `true` or `false` when creating',
13
- 'the client.',
10
+ `Since you haven't set a value for \`useCdn\`, we will deliver content using our`,
11
+ `global, edge-cached API-CDN. If you wish to have content delivered faster, set`,
12
+ `\`useCdn: false\` to use the Live API. Note: You may incur higher costs using the live API.`,
14
13
  ])
15
14
 
16
15
  export const printBrowserTokenWarning = createWarningPrinter([
@@ -26,5 +25,5 @@ export const printNoApiVersionSpecifiedWarning = createWarningPrinter([
26
25
  ])
27
26
 
28
27
  export const printNoDefaultExport = createWarningPrinter([
29
- 'The default export of @sanity/client has been deprecated. Use the named export `createClient` instead',
28
+ 'The default export of @sanity/client has been deprecated. Use the named export `createClient` instead.',
30
29
  ])
@@ -4,21 +4,6 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SanityClient = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- function _mergeNamespaces(n, m) {
8
- m.forEach(function (e) {
9
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
10
- if (k !== 'default' && !(k in n)) {
11
- var d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: function () { return e[k]; }
15
- });
16
- }
17
- });
18
- });
19
- return Object.freeze(n);
20
- }
21
-
22
7
  const isReactNative = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
23
8
  const defaultOptions$1 = {
24
9
  timeout: isReactNative ? 6e4 : 12e4
@@ -1372,6 +1357,50 @@
1372
1357
  cancel
1373
1358
  };
1374
1359
  };
1360
+ var defaultShouldRetry = (err, attempt, options) => {
1361
+ if (options.method !== "GET" && options.method !== "HEAD") {
1362
+ return false;
1363
+ }
1364
+ return err.isNetworkError || false;
1365
+ };
1366
+ const isStream = stream => stream !== null && typeof stream === "object" && typeof stream.pipe === "function";
1367
+ var sharedRetry = opts => {
1368
+ const maxRetries = opts.maxRetries || 5;
1369
+ const retryDelay = opts.retryDelay || getRetryDelay;
1370
+ const allowRetry = opts.shouldRetry;
1371
+ return {
1372
+ onError: (err, context) => {
1373
+ const options = context.options;
1374
+ const max = options.maxRetries || maxRetries;
1375
+ const shouldRetry = options.shouldRetry || allowRetry;
1376
+ const attemptNumber = options.attemptNumber || 0;
1377
+ if (isStream(options.body)) {
1378
+ return err;
1379
+ }
1380
+ if (!shouldRetry(err, attemptNumber, options) || attemptNumber >= max) {
1381
+ return err;
1382
+ }
1383
+ const newContext = Object.assign({}, context, {
1384
+ options: Object.assign({}, options, {
1385
+ attemptNumber: attemptNumber + 1
1386
+ })
1387
+ });
1388
+ setTimeout(() => context.channels.request.publish(newContext), retryDelay(attemptNumber));
1389
+ return null;
1390
+ }
1391
+ };
1392
+ };
1393
+ function getRetryDelay(attemptNum) {
1394
+ return 100 * Math.pow(2, attemptNum) + Math.random() * 100;
1395
+ }
1396
+ const retry = function () {
1397
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1398
+ return sharedRetry({
1399
+ shouldRetry: defaultShouldRetry,
1400
+ ...opts
1401
+ });
1402
+ };
1403
+ retry.shouldRetry = defaultShouldRetry;
1375
1404
 
1376
1405
  /******************************************************************************
1377
1406
  Copyright (c) Microsoft Corporation.
@@ -2140,8 +2169,18 @@
2140
2169
  return res;
2141
2170
  }
2142
2171
  };
2143
- function defineHttpRequest(envMiddleware) {
2144
- const request = getIt([...envMiddleware, printWarnings, jsonRequest(), jsonResponse(), progress(), httpError, observable$1({
2172
+ function defineHttpRequest(envMiddleware, _ref) {
2173
+ let {
2174
+ maxRetries = 5,
2175
+ retryDelay
2176
+ } = _ref;
2177
+ const request = getIt([maxRetries > 0 ? retry({
2178
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2179
+ retryDelay,
2180
+ // This option is typed incorrectly in get-it.
2181
+ maxRetries,
2182
+ shouldRetry
2183
+ }) : {}, ...envMiddleware, printWarnings, jsonRequest(), jsonResponse(), progress(), httpError, observable$1({
2145
2184
  implementation: Observable
2146
2185
  })]);
2147
2186
  function httpRequest(options) {
@@ -2154,6 +2193,13 @@
2154
2193
  httpRequest.defaultRequester = request;
2155
2194
  return httpRequest;
2156
2195
  }
2196
+ function shouldRetry(err, attempt, options) {
2197
+ const isSafe = options.method === "GET" || options.method === "HEAD";
2198
+ const isQuery = options.uri.startsWith("/data/query");
2199
+ const isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
2200
+ if ((isSafe || isQuery) && isRetriableResponse) return true;
2201
+ return retry.shouldRetry(err, attempt, options);
2202
+ }
2157
2203
  const projectHeader = "X-Sanity-Project-ID";
2158
2204
  function requestOptions(config) {
2159
2205
  let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -2250,12 +2296,12 @@
2250
2296
  }
2251
2297
  return tag;
2252
2298
  };
2253
- const encodeQueryString = _ref => {
2299
+ const encodeQueryString = _ref2 => {
2254
2300
  let {
2255
2301
  query,
2256
2302
  params = {},
2257
2303
  options = {}
2258
- } = _ref;
2304
+ } = _ref2;
2259
2305
  const searchParams = new URLSearchParams();
2260
2306
  const {
2261
2307
  tag,
@@ -2864,6 +2910,12 @@
2864
2910
  ...options.query
2865
2911
  };
2866
2912
  }
2913
+ if (config.resultSourceMap) {
2914
+ options.query = {
2915
+ resultSourceMap: true,
2916
+ ...options.query
2917
+ };
2918
+ }
2867
2919
  const reqOptions = requestOptions(config, Object.assign({}, options, {
2868
2920
  url: _getUrl(client, uri, useCdn)
2869
2921
  }));
@@ -3040,10 +3092,10 @@
3040
3092
  }
3041
3093
  return console.warn(message.join(" "), ...args);
3042
3094
  });
3043
- const printCdnWarning = createWarningPrinter(["You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and", "cheaper. Think about it! For more info, see ".concat(generateHelpUrl("js-client-cdn-configuration"), " "), "To hide this warning, please set the `useCdn` option to either `true` or `false` when creating", "the client."]);
3095
+ const printCdnWarning = createWarningPrinter(["Since you haven't set a value for `useCdn`, we will deliver content using our", "global, edge-cached API-CDN. If you wish to have content delivered faster, set", "`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."]);
3044
3096
  const printBrowserTokenWarning = createWarningPrinter(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.", "See ".concat(generateHelpUrl("js-client-browser-token"), " for more information and how to hide this warning.")]);
3045
3097
  const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
3046
- const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead"]);
3098
+ const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]);
3047
3099
  const defaultCdnHost = "apicdn.sanity.io";
3048
3100
  const defaultConfig = {
3049
3101
  apiHost: "https://api.sanity.io",
@@ -3094,7 +3146,7 @@
3094
3146
  }
3095
3147
  newConfig.apiVersion = "".concat(newConfig.apiVersion).replace(/^v/, "");
3096
3148
  newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost;
3097
- newConfig.useCdn = Boolean(newConfig.useCdn) && !newConfig.withCredentials;
3149
+ newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials;
3098
3150
  validateApiVersion(newConfig.apiVersion);
3099
3151
  const hostParts = newConfig.apiHost.split("://", 2);
3100
3152
  const protocol = hostParts[0];
@@ -3771,21 +3823,24 @@
3771
3823
  return new Transaction(operations, this);
3772
3824
  }
3773
3825
  /**
3774
- * DEPRECATED: Perform an HTTP request against the Sanity API
3826
+ * Perform a request against the Sanity API
3827
+ * NOTE: Only use this for Sanity API endpoints, not for your own APIs!
3775
3828
  *
3776
- * @deprecated Use your own request library!
3777
3829
  * @param options - Request options
3830
+ * @returns Promise resolving to the response body
3778
3831
  */
3779
3832
  request(options) {
3780
3833
  return lastValueFrom(_request(this, __privateGet(this, _httpRequest2), options));
3781
3834
  }
3782
3835
  /**
3783
- * DEPRECATED: Perform an HTTP request a `/data` sub-endpoint
3836
+ * Perform an HTTP request a `/data` sub-endpoint
3837
+ * NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
3784
3838
  *
3785
- * @deprecated Use your own request library!
3839
+ * @deprecated - Use `request()` or your own HTTP library instead
3786
3840
  * @param endpoint - Endpoint to hit (mutate, query etc)
3787
3841
  * @param body - Request body
3788
3842
  * @param options - Request options
3843
+ * @internal
3789
3844
  */
3790
3845
  dataRequest(endpoint, body, options) {
3791
3846
  return lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
@@ -3812,9 +3867,12 @@
3812
3867
  let SanityClient = _SanityClient;
3813
3868
  _clientConfig2 = new WeakMap();
3814
3869
  _httpRequest2 = new WeakMap();
3815
- const httpRequest = defineHttpRequest(envMiddleware);
3870
+ const httpRequest = defineHttpRequest(envMiddleware, {});
3816
3871
  const requester = httpRequest.defaultRequester;
3817
- const createClient = config => new SanityClient(httpRequest, config);
3872
+ const createClient = config => new SanityClient(defineHttpRequest(envMiddleware, {
3873
+ maxRetries: config.maxRetries,
3874
+ retryDelay: config.retryDelay
3875
+ }), config);
3818
3876
  function deprecatedCreateClient(config) {
3819
3877
  printNoDefaultExport();
3820
3878
  return new SanityClient(httpRequest, config);
@@ -4872,10 +4930,10 @@
4872
4930
 
4873
4931
  var browser = eventsourceExports.EventSourcePolyfill;
4874
4932
 
4875
- var browser$1 = /*#__PURE__*/_mergeNamespaces({
4933
+ var browser$1 = /*#__PURE__*/Object.freeze({
4876
4934
  __proto__: null,
4877
4935
  default: browser
4878
- }, [browser]);
4936
+ });
4879
4937
 
4880
4938
  exports.BasePatch = BasePatch;
4881
4939
  exports.BaseTransaction = BaseTransaction;