@sanity/client 6.4.12 → 6.5.1-canary.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.
@@ -4,13 +4,13 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SanityClient = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- const isReactNative = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
8
- const defaultOptions$1 = {
9
- timeout: isReactNative ? 6e4 : 12e4
7
+ const isReactNative$1 = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
8
+ const defaultOptions$2 = {
9
+ timeout: isReactNative$1 ? 6e4 : 12e4
10
10
  };
11
- const processOptions = function processOptions2(opts) {
11
+ const processOptions$1 = function processOptions2(opts) {
12
12
  const options = {
13
- ...defaultOptions$1,
13
+ ...defaultOptions$2,
14
14
  ...(typeof opts === "string" ? {
15
15
  url: opts
16
16
  } : opts)
@@ -18,7 +18,7 @@
18
18
  const {
19
19
  searchParams
20
20
  } = new URL(options.url, "http://localhost");
21
- options.timeout = normalizeTimeout(options.timeout);
21
+ options.timeout = normalizeTimeout$1(options.timeout);
22
22
  if (options.query) {
23
23
  for (const [key, value] of Object.entries(options.query)) {
24
24
  if (value !== void 0) {
@@ -40,7 +40,7 @@
40
40
  options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase();
41
41
  return options;
42
42
  };
43
- function normalizeTimeout(time) {
43
+ function normalizeTimeout$1(time) {
44
44
  if (time === false || time === 0) {
45
45
  return false;
46
46
  }
@@ -49,16 +49,16 @@
49
49
  }
50
50
  const delay = Number(time);
51
51
  if (isNaN(delay)) {
52
- return normalizeTimeout(defaultOptions$1.timeout);
52
+ return normalizeTimeout$1(defaultOptions$2.timeout);
53
53
  }
54
54
  return {
55
55
  connect: delay,
56
56
  socket: delay
57
57
  };
58
58
  }
59
- const validUrl = /^https?:\/\//i;
60
- const validateOptions = function validateOptions2(options) {
61
- if (!validUrl.test(options.url)) {
59
+ const validUrl$1 = /^https?:\/\//i;
60
+ const validateOptions$1 = function validateOptions2(options) {
61
+ if (!validUrl$1.test(options.url)) {
62
62
  throw new Error('"'.concat(options.url, '" is not a valid URL'));
63
63
  }
64
64
  };
@@ -147,8 +147,8 @@
147
147
  ware[name] = ware[name] || [];
148
148
  return ware;
149
149
  }, {
150
- processOptions: [processOptions],
151
- validateOptions: [validateOptions]
150
+ processOptions: [processOptions$1],
151
+ validateOptions: [validateOptions$1]
152
152
  });
153
153
  function request(opts) {
154
154
  const onResponse = (reqErr, res, ctx) => {
@@ -219,15 +219,15 @@
219
219
  initMiddleware.forEach(request.use);
220
220
  return request;
221
221
  }
222
- var __defProp$5 = Object.defineProperty;
223
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, {
222
+ var __defProp$2 = Object.defineProperty;
223
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
224
224
  enumerable: true,
225
225
  configurable: true,
226
226
  writable: true,
227
227
  value
228
228
  }) : obj[key] = value;
229
- var __publicField$5 = (obj, key, value) => {
230
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
229
+ var __publicField$2 = (obj, key, value) => {
230
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
231
231
  return value;
232
232
  };
233
233
  var __accessCheck$7 = (obj, member, msg) => {
@@ -252,20 +252,20 @@
252
252
  /**
253
253
  * Public interface, interop with real XMLHttpRequest
254
254
  */
255
- __publicField$5(this, "onabort");
256
- __publicField$5(this, "onerror");
257
- __publicField$5(this, "onreadystatechange");
258
- __publicField$5(this, "ontimeout");
255
+ __publicField$2(this, "onabort");
256
+ __publicField$2(this, "onerror");
257
+ __publicField$2(this, "onreadystatechange");
258
+ __publicField$2(this, "ontimeout");
259
259
  /**
260
260
  * https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState
261
261
  */
262
- __publicField$5(this, "readyState", 0);
263
- __publicField$5(this, "response");
264
- __publicField$5(this, "responseText");
265
- __publicField$5(this, "responseType", "");
266
- __publicField$5(this, "status");
267
- __publicField$5(this, "statusText");
268
- __publicField$5(this, "withCredentials");
262
+ __publicField$2(this, "readyState", 0);
263
+ __publicField$2(this, "response");
264
+ __publicField$2(this, "responseText");
265
+ __publicField$2(this, "responseType", "");
266
+ __publicField$2(this, "status");
267
+ __publicField$2(this, "statusText");
268
+ __publicField$2(this, "withCredentials");
269
269
  /**
270
270
  * Private implementation details
271
271
  */
@@ -498,6 +498,8 @@
498
498
  };
499
499
  const environment = "browser";
500
500
 
501
+ var middleware_browser = {};
502
+
501
503
  var browser$3 = {exports: {}};
502
504
 
503
505
  /**
@@ -1217,6 +1219,75 @@
1217
1219
  };
1218
1220
  } (browser$3, browser$3.exports));
1219
1221
 
1222
+ var browserExports = browser$3.exports;
1223
+
1224
+ var defaultOptionsValidator41aa9136 = {};
1225
+
1226
+ const isReactNative = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
1227
+ const defaultOptions$1 = {
1228
+ timeout: isReactNative ? 6e4 : 12e4
1229
+ };
1230
+ const processOptions = function processOptions2(opts) {
1231
+ const options = {
1232
+ ...defaultOptions$1,
1233
+ ...(typeof opts === "string" ? {
1234
+ url: opts
1235
+ } : opts)
1236
+ };
1237
+ const {
1238
+ searchParams
1239
+ } = new URL(options.url, "http://localhost");
1240
+ options.timeout = normalizeTimeout(options.timeout);
1241
+ if (options.query) {
1242
+ for (const [key, value] of Object.entries(options.query)) {
1243
+ if (value !== void 0) {
1244
+ if (Array.isArray(value)) {
1245
+ for (const v of value) {
1246
+ searchParams.append(key, v);
1247
+ }
1248
+ } else {
1249
+ searchParams.append(key, value);
1250
+ }
1251
+ }
1252
+ }
1253
+ }
1254
+ const [url] = options.url.split("?");
1255
+ const search = searchParams.toString();
1256
+ if (search) {
1257
+ options.url = "".concat(url, "?").concat(search);
1258
+ }
1259
+ options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase();
1260
+ return options;
1261
+ };
1262
+ function normalizeTimeout(time) {
1263
+ if (time === false || time === 0) {
1264
+ return false;
1265
+ }
1266
+ if (time.connect || time.socket) {
1267
+ return time;
1268
+ }
1269
+ const delay = Number(time);
1270
+ if (isNaN(delay)) {
1271
+ return normalizeTimeout(defaultOptions$1.timeout);
1272
+ }
1273
+ return {
1274
+ connect: delay,
1275
+ socket: delay
1276
+ };
1277
+ }
1278
+ const validUrl = /^https?:\/\//i;
1279
+ const validateOptions = function validateOptions2(options) {
1280
+ if (!validUrl.test(options.url)) {
1281
+ throw new Error('"'.concat(options.url, '" is not a valid URL'));
1282
+ }
1283
+ };
1284
+ defaultOptionsValidator41aa9136.processOptions = processOptions;
1285
+ defaultOptionsValidator41aa9136.validateOptions = validateOptions;
1286
+
1287
+ var isPlainObject$3 = {};
1288
+
1289
+ Object.defineProperty(isPlainObject$3, '__esModule', { value: true });
1290
+
1220
1291
  /*!
1221
1292
  * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
1222
1293
  *
@@ -1228,7 +1299,7 @@
1228
1299
  return Object.prototype.toString.call(o) === '[object Object]';
1229
1300
  }
1230
1301
 
1231
- function isPlainObject$1(o) {
1302
+ function isPlainObject$2(o) {
1232
1303
  var ctor,prot;
1233
1304
 
1234
1305
  if (isObject(o) === false) return false;
@@ -1250,6 +1321,184 @@
1250
1321
  return true;
1251
1322
  }
1252
1323
 
1324
+ isPlainObject$3.isPlainObject = isPlainObject$2;
1325
+
1326
+ Object.defineProperty(middleware_browser, '__esModule', {
1327
+ value: true
1328
+ });
1329
+ var debugIt = browserExports;
1330
+ var defaultOptionsValidator = defaultOptionsValidator41aa9136;
1331
+ var isPlainObject$1 = isPlainObject$3;
1332
+ function _interopDefaultCompat$1(e) {
1333
+ return e && typeof e === 'object' && 'default' in e ? e : {
1334
+ default: e
1335
+ };
1336
+ }
1337
+ var debugIt__default = /*#__PURE__*/_interopDefaultCompat$1(debugIt);
1338
+ function agent(opts) {
1339
+ return {};
1340
+ }
1341
+ const leadingSlash = /^\//;
1342
+ const trailingSlash = /\/$/;
1343
+ function base(baseUrl) {
1344
+ const baseUri = baseUrl.replace(trailingSlash, "");
1345
+ return {
1346
+ processOptions: options => {
1347
+ if (/^https?:\/\//i.test(options.url)) {
1348
+ return options;
1349
+ }
1350
+ const url = [baseUri, options.url.replace(leadingSlash, "")].join("/");
1351
+ return Object.assign({}, options, {
1352
+ url
1353
+ });
1354
+ }
1355
+ };
1356
+ }
1357
+ const SENSITIVE_HEADERS = ["cookie", "authorization"];
1358
+ const hasOwn = Object.prototype.hasOwnProperty;
1359
+ const redactKeys = (source, redacted) => {
1360
+ const target = {};
1361
+ for (const key in source) {
1362
+ if (hasOwn.call(source, key)) {
1363
+ target[key] = redacted.indexOf(key.toLowerCase()) > -1 ? "<redacted>" : source[key];
1364
+ }
1365
+ }
1366
+ return target;
1367
+ };
1368
+ function debug() {
1369
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1370
+ const verbose = opts.verbose;
1371
+ const namespace = opts.namespace || "get-it";
1372
+ const defaultLogger = debugIt__default.default(namespace);
1373
+ const log = opts.log || defaultLogger;
1374
+ const shortCircuit = log === defaultLogger && !debugIt__default.default.enabled(namespace);
1375
+ let requestId = 0;
1376
+ return {
1377
+ processOptions: options => {
1378
+ options.debug = log;
1379
+ options.requestId = options.requestId || ++requestId;
1380
+ return options;
1381
+ },
1382
+ onRequest: event => {
1383
+ if (shortCircuit || !event) {
1384
+ return event;
1385
+ }
1386
+ const options = event.options;
1387
+ log("[%s] HTTP %s %s", options.requestId, options.method, options.url);
1388
+ if (verbose && options.body && typeof options.body === "string") {
1389
+ log("[%s] Request body: %s", options.requestId, options.body);
1390
+ }
1391
+ if (verbose && options.headers) {
1392
+ const headers = opts.redactSensitiveHeaders === false ? options.headers : redactKeys(options.headers, SENSITIVE_HEADERS);
1393
+ log("[%s] Request headers: %s", options.requestId, JSON.stringify(headers, null, 2));
1394
+ }
1395
+ return event;
1396
+ },
1397
+ onResponse: (res, context) => {
1398
+ if (shortCircuit || !res) {
1399
+ return res;
1400
+ }
1401
+ const reqId = context.options.requestId;
1402
+ log("[%s] Response code: %s %s", reqId, res.statusCode, res.statusMessage);
1403
+ if (verbose && res.body) {
1404
+ log("[%s] Response body: %s", reqId, stringifyBody$1(res));
1405
+ }
1406
+ return res;
1407
+ },
1408
+ onError: (err, context) => {
1409
+ const reqId = context.options.requestId;
1410
+ if (!err) {
1411
+ log("[%s] Error encountered, but handled by an earlier middleware", reqId);
1412
+ return err;
1413
+ }
1414
+ log("[%s] ERROR: %s", reqId, err.message);
1415
+ return err;
1416
+ }
1417
+ };
1418
+ }
1419
+ function stringifyBody$1(res) {
1420
+ const contentType = (res.headers["content-type"] || "").toLowerCase();
1421
+ const isJson = contentType.indexOf("application/json") !== -1;
1422
+ return isJson ? tryFormat(res.body) : res.body;
1423
+ }
1424
+ function tryFormat(body) {
1425
+ try {
1426
+ const parsed = typeof body === "string" ? JSON.parse(body) : body;
1427
+ return JSON.stringify(parsed, null, 2);
1428
+ } catch (err) {
1429
+ return body;
1430
+ }
1431
+ }
1432
+ function headers(_headers) {
1433
+ let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1434
+ return {
1435
+ processOptions: options => {
1436
+ const existing = options.headers || {};
1437
+ options.headers = opts.override ? Object.assign({}, existing, _headers) : Object.assign({}, _headers, existing);
1438
+ return options;
1439
+ }
1440
+ };
1441
+ }
1442
+ var __defProp$1 = Object.defineProperty;
1443
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
1444
+ enumerable: true,
1445
+ configurable: true,
1446
+ writable: true,
1447
+ value
1448
+ }) : obj[key] = value;
1449
+ var __publicField$1 = (obj, key, value) => {
1450
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1451
+ return value;
1452
+ };
1453
+ class HttpError extends Error {
1454
+ constructor(res, ctx) {
1455
+ super();
1456
+ __publicField$1(this, "response");
1457
+ __publicField$1(this, "request");
1458
+ const truncatedUrl = res.url.length > 400 ? "".concat(res.url.slice(0, 399), "\u2026") : res.url;
1459
+ let msg = "".concat(res.method, "-request to ").concat(truncatedUrl, " resulted in ");
1460
+ msg += "HTTP ".concat(res.statusCode, " ").concat(res.statusMessage);
1461
+ this.message = msg.trim();
1462
+ this.response = res;
1463
+ this.request = ctx.options;
1464
+ }
1465
+ }
1466
+ function httpErrors() {
1467
+ return {
1468
+ onResponse: (res, ctx) => {
1469
+ const isHttpError = res.statusCode >= 400;
1470
+ if (!isHttpError) {
1471
+ return res;
1472
+ }
1473
+ throw new HttpError(res, ctx);
1474
+ }
1475
+ };
1476
+ }
1477
+ function injectResponse() {
1478
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1479
+ if (typeof opts.inject !== "function") {
1480
+ throw new Error("`injectResponse` middleware requires a `inject` function");
1481
+ }
1482
+ const inject = function inject2(prevValue, event) {
1483
+ const response = opts.inject(event, prevValue);
1484
+ if (!response) {
1485
+ return prevValue;
1486
+ }
1487
+ const options = event.context.options;
1488
+ return {
1489
+ body: "",
1490
+ url: options.url,
1491
+ method: options.method,
1492
+ headers: {},
1493
+ statusCode: 200,
1494
+ statusMessage: "OK",
1495
+ ...response
1496
+ };
1497
+ };
1498
+ return {
1499
+ interceptRequest: inject
1500
+ };
1501
+ }
1253
1502
  const isBuffer = typeof Buffer === "undefined" ? () => false : obj => Buffer.isBuffer(obj);
1254
1503
  const serializeTypes = ["boolean", "string", "number"];
1255
1504
  function jsonRequest() {
@@ -1260,7 +1509,7 @@
1260
1509
  return options;
1261
1510
  }
1262
1511
  const isStream = typeof body.pipe === "function";
1263
- const shouldSerialize = !isStream && !isBuffer(body) && (serializeTypes.indexOf(typeof body) !== -1 || Array.isArray(body) || isPlainObject$1(body));
1512
+ const shouldSerialize = !isStream && !isBuffer(body) && (serializeTypes.indexOf(typeof body) !== -1 || Array.isArray(body) || isPlainObject$1.isPlainObject(body));
1264
1513
  if (!shouldSerialize) {
1265
1514
  return options;
1266
1515
  }
@@ -1300,13 +1549,41 @@
1300
1549
  }
1301
1550
  }
1302
1551
  }
1552
+ function isBrowserOptions(options) {
1553
+ return typeof options === "object" && options !== null && !("protocol" in options);
1554
+ }
1555
+ function mtls() {
1556
+ let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1557
+ if (!config.ca) {
1558
+ throw new Error('Required mtls option "ca" is missing');
1559
+ }
1560
+ if (!config.cert) {
1561
+ throw new Error('Required mtls option "cert" is missing');
1562
+ }
1563
+ if (!config.key) {
1564
+ throw new Error('Required mtls option "key" is missing');
1565
+ }
1566
+ return {
1567
+ finalizeOptions: options => {
1568
+ if (isBrowserOptions(options)) {
1569
+ return options;
1570
+ }
1571
+ const mtlsOpts = {
1572
+ cert: config.cert,
1573
+ key: config.key,
1574
+ ca: config.ca
1575
+ };
1576
+ return Object.assign({}, options, mtlsOpts);
1577
+ }
1578
+ };
1579
+ }
1303
1580
  let actualGlobal = {};
1304
1581
  if (typeof globalThis !== "undefined") {
1305
1582
  actualGlobal = globalThis;
1306
1583
  } else if (typeof window !== "undefined") {
1307
1584
  actualGlobal = window;
1308
- } else if (typeof global !== "undefined") {
1309
- actualGlobal = global;
1585
+ } else if (typeof commonjsGlobal !== "undefined") {
1586
+ actualGlobal = commonjsGlobal;
1310
1587
  } else if (typeof self !== "undefined") {
1311
1588
  actualGlobal = self;
1312
1589
  }
@@ -1365,21 +1642,50 @@
1365
1642
  }
1366
1643
  };
1367
1644
  }
1368
- var __defProp$4 = Object.defineProperty;
1369
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, {
1645
+ var __defProp = Object.defineProperty;
1646
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
1370
1647
  enumerable: true,
1371
1648
  configurable: true,
1372
1649
  writable: true,
1373
1650
  value
1374
1651
  }) : obj[key] = value;
1375
- var __publicField$4 = (obj, key, value) => {
1376
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
1652
+ var __publicField = (obj, key, value) => {
1653
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1377
1654
  return value;
1378
1655
  };
1656
+ const promise = function () {
1657
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1658
+ const PromiseImplementation = options.implementation || Promise;
1659
+ if (!PromiseImplementation) {
1660
+ throw new Error("`Promise` is not available in global scope, and no implementation was passed");
1661
+ }
1662
+ return {
1663
+ onReturn: (channels, context) => new PromiseImplementation((resolve, reject) => {
1664
+ const cancel = context.options.cancelToken;
1665
+ if (cancel) {
1666
+ cancel.promise.then(reason => {
1667
+ channels.abort.publish(reason);
1668
+ reject(reason);
1669
+ });
1670
+ }
1671
+ channels.error.subscribe(reject);
1672
+ channels.response.subscribe(response => {
1673
+ resolve(options.onlyBody ? response.body : response);
1674
+ });
1675
+ setTimeout(() => {
1676
+ try {
1677
+ channels.request.publish(context);
1678
+ } catch (err) {
1679
+ reject(err);
1680
+ }
1681
+ }, 0);
1682
+ })
1683
+ };
1684
+ };
1379
1685
  class Cancel {
1380
1686
  constructor(message) {
1381
- __publicField$4(this, "__CANCEL__", true);
1382
- __publicField$4(this, "message");
1687
+ __publicField(this, "__CANCEL__", true);
1688
+ __publicField(this, "message");
1383
1689
  this.message = message;
1384
1690
  }
1385
1691
  toString() {
@@ -1388,8 +1694,8 @@
1388
1694
  }
1389
1695
  const _CancelToken = class _CancelToken {
1390
1696
  constructor(executor) {
1391
- __publicField$4(this, "promise");
1392
- __publicField$4(this, "reason");
1697
+ __publicField(this, "promise");
1698
+ __publicField(this, "reason");
1393
1699
  if (typeof executor !== "function") {
1394
1700
  throw new TypeError("executor must be a function.");
1395
1701
  }
@@ -1406,7 +1712,7 @@
1406
1712
  });
1407
1713
  }
1408
1714
  };
1409
- __publicField$4(_CancelToken, "source", () => {
1715
+ __publicField(_CancelToken, "source", () => {
1410
1716
  let cancel;
1411
1717
  const token = new _CancelToken(can => {
1412
1718
  cancel = can;
@@ -1416,6 +1722,21 @@
1416
1722
  cancel
1417
1723
  };
1418
1724
  });
1725
+ let CancelToken = _CancelToken;
1726
+ const isCancel = value => !!(value && (value == null ? void 0 : value.__CANCEL__));
1727
+ promise.Cancel = Cancel;
1728
+ promise.CancelToken = CancelToken;
1729
+ promise.isCancel = isCancel;
1730
+ function proxy(_proxy) {
1731
+ if (_proxy !== false && (!_proxy || !_proxy.host)) {
1732
+ throw new Error("Proxy middleware takes an object of host, port and auth properties");
1733
+ }
1734
+ return {
1735
+ processOptions: options => Object.assign({
1736
+ proxy: _proxy
1737
+ }, options)
1738
+ };
1739
+ }
1419
1740
  var defaultShouldRetry = (err, attempt, options) => {
1420
1741
  if (options.method !== "GET" && options.method !== "HEAD") {
1421
1742
  return false;
@@ -1460,6 +1781,88 @@
1460
1781
  });
1461
1782
  };
1462
1783
  retry.shouldRetry = defaultShouldRetry;
1784
+ function encode(data) {
1785
+ const query = new URLSearchParams();
1786
+ const nest = (name, _value) => {
1787
+ const value = _value instanceof Set ? Array.from(_value) : _value;
1788
+ if (Array.isArray(value)) {
1789
+ if (value.length) {
1790
+ for (const index in value) {
1791
+ nest("".concat(name, "[").concat(index, "]"), value[index]);
1792
+ }
1793
+ } else {
1794
+ query.append("".concat(name, "[]"), "");
1795
+ }
1796
+ } else if (typeof value === "object" && value !== null) {
1797
+ for (const [key, obj] of Object.entries(value)) {
1798
+ nest("".concat(name, "[").concat(key, "]"), obj);
1799
+ }
1800
+ } else {
1801
+ query.append(name, value);
1802
+ }
1803
+ };
1804
+ for (const [key, value] of Object.entries(data)) {
1805
+ nest(key, value);
1806
+ }
1807
+ return query.toString();
1808
+ }
1809
+ function urlEncoded() {
1810
+ return {
1811
+ processOptions: options => {
1812
+ const body = options.body;
1813
+ if (!body) {
1814
+ return options;
1815
+ }
1816
+ const isStream = typeof body.pipe === "function";
1817
+ const shouldSerialize = !isStream && !isBuffer(body) && isPlainObject$1.isPlainObject(body);
1818
+ if (!shouldSerialize) {
1819
+ return options;
1820
+ }
1821
+ return {
1822
+ ...options,
1823
+ body: encode(options.body),
1824
+ headers: {
1825
+ ...options.headers,
1826
+ "Content-Type": "application/x-www-form-urlencoded"
1827
+ }
1828
+ };
1829
+ }
1830
+ };
1831
+ }
1832
+ function buildKeepAlive(agent) {
1833
+ return function keepAlive() {
1834
+ let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1835
+ const ms = config.ms || 1e3;
1836
+ const maxFree = config.maxFree || 256;
1837
+ const agentOptions = {
1838
+ keepAlive: true,
1839
+ keepAliveMsecs: ms,
1840
+ maxFreeSockets: maxFree
1841
+ };
1842
+ return agent(agentOptions);
1843
+ };
1844
+ }
1845
+ const keepAlive = buildKeepAlive(agent);
1846
+ middleware_browser.processOptions = defaultOptionsValidator.processOptions;
1847
+ middleware_browser.validateOptions = defaultOptionsValidator.validateOptions;
1848
+ middleware_browser.Cancel = Cancel;
1849
+ middleware_browser.CancelToken = CancelToken;
1850
+ middleware_browser.agent = agent;
1851
+ middleware_browser.base = base;
1852
+ middleware_browser.debug = debug;
1853
+ middleware_browser.headers = headers;
1854
+ middleware_browser.httpErrors = httpErrors;
1855
+ middleware_browser.injectResponse = injectResponse;
1856
+ var jsonRequest_1 = middleware_browser.jsonRequest = jsonRequest;
1857
+ var jsonResponse_1 = middleware_browser.jsonResponse = jsonResponse;
1858
+ middleware_browser.keepAlive = keepAlive;
1859
+ middleware_browser.mtls = mtls;
1860
+ var observable_1 = middleware_browser.observable = observable$1;
1861
+ var progress_1 = middleware_browser.progress = progress;
1862
+ middleware_browser.promise = promise;
1863
+ middleware_browser.proxy = proxy;
1864
+ var retry_1 = middleware_browser.retry = retry;
1865
+ middleware_browser.urlEncoded = urlEncoded;
1463
1866
 
1464
1867
  /******************************************************************************
1465
1868
  Copyright (c) Microsoft Corporation.
@@ -2148,26 +2551,12 @@
2148
2551
  }
2149
2552
 
2150
2553
  var envMiddleware = [];
2151
- var __defProp$3 = Object.defineProperty;
2152
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, {
2153
- enumerable: true,
2154
- configurable: true,
2155
- writable: true,
2156
- value
2157
- }) : obj[key] = value;
2158
- var __publicField$3 = (obj, key, value) => {
2159
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
2160
- return value;
2161
- };
2162
2554
  const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
2163
2555
  class ClientError extends Error {
2164
2556
  constructor(res) {
2165
2557
  const props = extractErrorProps(res);
2166
2558
  super(props.message);
2167
- __publicField$3(this, "response");
2168
- __publicField$3(this, "statusCode", 400);
2169
- __publicField$3(this, "responseBody");
2170
- __publicField$3(this, "details");
2559
+ this.statusCode = 400;
2171
2560
  Object.assign(this, props);
2172
2561
  }
2173
2562
  }
@@ -2175,10 +2564,7 @@
2175
2564
  constructor(res) {
2176
2565
  const props = extractErrorProps(res);
2177
2566
  super(props.message);
2178
- __publicField$3(this, "response");
2179
- __publicField$3(this, "statusCode", 500);
2180
- __publicField$3(this, "responseBody");
2181
- __publicField$3(this, "details");
2567
+ this.statusCode = 500;
2182
2568
  Object.assign(this, props);
2183
2569
  }
2184
2570
  }
@@ -2255,13 +2641,13 @@
2255
2641
  maxRetries = 5,
2256
2642
  retryDelay
2257
2643
  } = _ref;
2258
- const request = getIt([maxRetries > 0 ? retry({
2644
+ const request = getIt([maxRetries > 0 ? retry_1({
2259
2645
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2260
2646
  retryDelay,
2261
2647
  // This option is typed incorrectly in get-it.
2262
2648
  maxRetries,
2263
2649
  shouldRetry
2264
- }) : {}, ...envMiddleware, printWarnings, jsonRequest(), jsonResponse(), progress(), httpError, observable$1({
2650
+ }) : {}, ...envMiddleware, printWarnings, jsonRequest_1(), jsonResponse_1(), progress_1(), httpError, observable_1({
2265
2651
  implementation: Observable
2266
2652
  })]);
2267
2653
  function httpRequest(options) {
@@ -2280,7 +2666,7 @@
2280
2666
  const isQuery = uri.startsWith("/data/query");
2281
2667
  const isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
2282
2668
  if ((isSafe || isQuery) && isRetriableResponse) return true;
2283
- return retry.shouldRetry(err, attempt, options);
2669
+ return retry_1.shouldRetry(err, attempt, options);
2284
2670
  }
2285
2671
  const BASE_URL = "https://www.sanity.io/help/";
2286
2672
  function generateHelpUrl(slug) {
@@ -2513,17 +2899,6 @@
2513
2899
  }
2514
2900
  return "?".concat(searchParams);
2515
2901
  };
2516
- var __defProp$2 = Object.defineProperty;
2517
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
2518
- enumerable: true,
2519
- configurable: true,
2520
- writable: true,
2521
- value
2522
- }) : obj[key] = value;
2523
- var __publicField$2 = (obj, key, value) => {
2524
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
2525
- return value;
2526
- };
2527
2902
  var __accessCheck$6 = (obj, member, msg) => {
2528
2903
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
2529
2904
  };
@@ -2544,8 +2919,6 @@
2544
2919
  class BasePatch {
2545
2920
  constructor(selection) {
2546
2921
  let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2547
- __publicField$2(this, "selection");
2548
- __publicField$2(this, "operations");
2549
2922
  this.selection = selection;
2550
2923
  this.operations = operations;
2551
2924
  }
@@ -2759,17 +3132,6 @@
2759
3132
  };
2760
3133
  _client2$5 = new WeakMap();
2761
3134
  let Patch = _Patch;
2762
- var __defProp$1 = Object.defineProperty;
2763
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
2764
- enumerable: true,
2765
- configurable: true,
2766
- writable: true,
2767
- value
2768
- }) : obj[key] = value;
2769
- var __publicField$1 = (obj, key, value) => {
2770
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
2771
- return value;
2772
- };
2773
3135
  var __accessCheck$5 = (obj, member, msg) => {
2774
3136
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
2775
3137
  };
@@ -2794,8 +3156,6 @@
2794
3156
  constructor() {
2795
3157
  let operations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2796
3158
  let transactionId = arguments.length > 1 ? arguments[1] : undefined;
2797
- __publicField$1(this, "operations");
2798
- __publicField$1(this, "trxId");
2799
3159
  this.operations = operations;
2800
3160
  this.trxId = transactionId;
2801
3161
  }
@@ -3148,7 +3508,7 @@
3148
3508
  const canUseCdn = typeof options.canUseCdn === "undefined" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
3149
3509
  let useCdn = config.useCdn && canUseCdn;
3150
3510
  const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
3151
- if (tag) {
3511
+ if (tag && options.tag !== null) {
3152
3512
  options.query = {
3153
3513
  tag: requestTag(tag),
3154
3514
  ...options.query
@@ -3535,7 +3895,8 @@
3535
3895
  */
3536
3896
  list() {
3537
3897
  return _request(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), {
3538
- uri: "/datasets"
3898
+ uri: "/datasets",
3899
+ tag: null
3539
3900
  });
3540
3901
  }
3541
3902
  }
@@ -3579,7 +3940,8 @@
3579
3940
  */
3580
3941
  list() {
3581
3942
  return lastValueFrom(_request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), {
3582
- uri: "/datasets"
3943
+ uri: "/datasets",
3944
+ tag: null
3583
3945
  }));
3584
3946
  }
3585
3947
  }
@@ -3590,7 +3952,8 @@
3590
3952
  return _request(client, httpRequest, {
3591
3953
  method,
3592
3954
  uri: "/datasets/".concat(name),
3593
- body: options
3955
+ body: options,
3956
+ tag: null
3594
3957
  });
3595
3958
  }
3596
3959
  var __accessCheck$2 = (obj, member, msg) => {
@@ -3719,17 +4082,6 @@
3719
4082
  }
3720
4083
  _client2 = new WeakMap();
3721
4084
  _httpRequest2$1 = new WeakMap();
3722
- var __defProp = Object.defineProperty;
3723
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
3724
- enumerable: true,
3725
- configurable: true,
3726
- writable: true,
3727
- value
3728
- }) : obj[key] = value;
3729
- var __publicField = (obj, key, value) => {
3730
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
3731
- return value;
3732
- };
3733
4085
  var __accessCheck = (obj, member, msg) => {
3734
4086
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
3735
4087
  };
@@ -3750,10 +4102,6 @@
3750
4102
  const _ObservableSanityClient = class _ObservableSanityClient {
3751
4103
  constructor(httpRequest) {
3752
4104
  let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
3753
- __publicField(this, "assets");
3754
- __publicField(this, "datasets");
3755
- __publicField(this, "projects");
3756
- __publicField(this, "users");
3757
4105
  /**
3758
4106
  * Private properties
3759
4107
  */
@@ -3762,7 +4110,7 @@
3762
4110
  /**
3763
4111
  * Instance properties
3764
4112
  */
3765
- __publicField(this, "listen", _listen);
4113
+ this.listen = _listen;
3766
4114
  this.config(config);
3767
4115
  __privateSet(this, _httpRequest, httpRequest);
3768
4116
  this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
@@ -3890,14 +4238,6 @@
3890
4238
  const _SanityClient = class _SanityClient {
3891
4239
  constructor(httpRequest) {
3892
4240
  let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
3893
- __publicField(this, "assets");
3894
- __publicField(this, "datasets");
3895
- __publicField(this, "projects");
3896
- __publicField(this, "users");
3897
- /**
3898
- * Observable version of the Sanity client, with the same configuration as the promise-based one
3899
- */
3900
- __publicField(this, "observable");
3901
4241
  /**
3902
4242
  * Private properties
3903
4243
  */
@@ -3906,7 +4246,7 @@
3906
4246
  /**
3907
4247
  * Instance properties
3908
4248
  */
3909
- __publicField(this, "listen", _listen);
4249
+ this.listen = _listen;
3910
4250
  this.config(config);
3911
4251
  __privateSet(this, _httpRequest2, httpRequest);
3912
4252
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));