@sanity/client 6.11.2 → 6.11.3

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.
Files changed (35) hide show
  1. package/dist/_chunks/{browserMiddleware-hi8PGbSU.cjs → browserMiddleware-1MULg59S.cjs} +377 -420
  2. package/dist/_chunks/{browserMiddleware-hi8PGbSU.cjs.map → browserMiddleware-1MULg59S.cjs.map} +1 -1
  3. package/dist/_chunks/{browserMiddleware-eLzHI4Fk.js → browserMiddleware-heyg-fDk.js} +377 -420
  4. package/dist/_chunks/{browserMiddleware-eLzHI4Fk.js.map → browserMiddleware-heyg-fDk.js.map} +1 -1
  5. package/dist/_chunks/{nodeMiddleware-SFcV9llR.cjs → nodeMiddleware-CHxg1-zH.cjs} +396 -440
  6. package/dist/_chunks/{nodeMiddleware-SFcV9llR.cjs.map → nodeMiddleware-CHxg1-zH.cjs.map} +1 -1
  7. package/dist/_chunks/{nodeMiddleware-dn4ZacKV.js → nodeMiddleware-u_fUUnxa.js} +396 -440
  8. package/dist/_chunks/{nodeMiddleware-dn4ZacKV.js.map → nodeMiddleware-u_fUUnxa.js.map} +1 -1
  9. package/dist/_chunks/{resolveEditInfo-TYjTkHKU.cjs → resolveEditInfo-dELeeJBE.cjs} +47 -70
  10. package/dist/_chunks/{resolveEditInfo-TYjTkHKU.cjs.map → resolveEditInfo-dELeeJBE.cjs.map} +1 -1
  11. package/dist/_chunks/{resolveEditInfo-FaeuCV4M.js → resolveEditInfo-uXvm6eWd.js} +47 -70
  12. package/dist/_chunks/{resolveEditInfo-FaeuCV4M.js.map → resolveEditInfo-uXvm6eWd.js.map} +1 -1
  13. package/dist/csm.cjs +20 -30
  14. package/dist/csm.cjs.map +1 -1
  15. package/dist/csm.js +19 -28
  16. package/dist/csm.js.map +1 -1
  17. package/dist/index.browser.cjs +8 -10
  18. package/dist/index.browser.cjs.map +1 -1
  19. package/dist/index.browser.js +5 -2
  20. package/dist/index.browser.js.map +1 -1
  21. package/dist/index.cjs +8 -10
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.js +5 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/stega.browser.cjs +224 -257
  26. package/dist/stega.browser.cjs.map +1 -1
  27. package/dist/stega.browser.js +221 -249
  28. package/dist/stega.browser.js.map +1 -1
  29. package/dist/stega.cjs +193 -217
  30. package/dist/stega.cjs.map +1 -1
  31. package/dist/stega.js +190 -209
  32. package/dist/stega.js.map +1 -1
  33. package/package.json +3 -3
  34. package/umd/sanityClient.js +494 -528
  35. package/umd/sanityClient.min.js +3 -3
@@ -5,19 +5,13 @@
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
7
  const isReactNative = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
8
- const defaultOptions$1 = {
9
- timeout: isReactNative ? 6e4 : 12e4
10
- };
8
+ const defaultOptions$1 = { timeout: isReactNative ? 6e4 : 12e4 };
11
9
  const processOptions = function processOptions2(opts) {
12
10
  const options = {
13
11
  ...defaultOptions$1,
14
- ...(typeof opts === "string" ? {
15
- url: opts
16
- } : opts)
12
+ ...typeof opts === "string" ? { url: opts } : opts
17
13
  };
18
- const {
19
- searchParams
20
- } = new URL(options.url, "http://localhost");
14
+ const { searchParams } = new URL(options.url, "http://localhost");
21
15
  options.timeout = normalizeTimeout(options.timeout);
22
16
  if (options.query) {
23
17
  for (const [key, value] of Object.entries(options.query)) {
@@ -51,11 +45,9 @@
51
45
  if (isNaN(delay)) {
52
46
  return normalizeTimeout(defaultOptions$1.timeout);
53
47
  }
54
- return {
55
- connect: delay,
56
- socket: delay
57
- };
48
+ return { connect: delay, socket: delay };
58
49
  }
50
+
59
51
  const validUrl = /^https?:\/\//i;
60
52
  const validateOptions = function validateOptions2(options) {
61
53
  if (!validUrl.test(options.url)) {
@@ -104,12 +96,9 @@
104
96
 
105
97
  var parseHeaders$1 = /*@__PURE__*/getDefaultExportFromCjs(parseHeaders);
106
98
 
107
- const middlewareReducer = middleware => function applyMiddleware(hook, defaultValue) {
99
+ const middlewareReducer = (middleware) => function applyMiddleware(hook, defaultValue, ...args) {
108
100
  const bailEarly = hook === "onError";
109
101
  let value = defaultValue;
110
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
111
- args[_key - 2] = arguments[_key];
112
- }
113
102
  for (let i = 0; i < middleware[hook].length; i++) {
114
103
  const handler = middleware[hook][i];
115
104
  value = handler(value, ...args);
@@ -119,8 +108,9 @@
119
108
  }
120
109
  return value;
121
110
  };
111
+
122
112
  function createPubSub() {
123
- const subscribers = /* @__PURE__ */Object.create(null);
113
+ const subscribers = /* @__PURE__ */ Object.create(null);
124
114
  let nextId = 0;
125
115
  function subscribe(subscriber) {
126
116
  const id = nextId++;
@@ -139,17 +129,37 @@
139
129
  subscribe
140
130
  };
141
131
  }
142
- const channelNames = ["request", "response", "progress", "error", "abort"];
143
- const middlehooks = ["processOptions", "validateOptions", "interceptRequest", "finalizeOptions", "onRequest", "onResponse", "onError", "onReturn", "onHeaders"];
132
+
133
+ const channelNames = [
134
+ "request",
135
+ "response",
136
+ "progress",
137
+ "error",
138
+ "abort"
139
+ ];
140
+ const middlehooks = [
141
+ "processOptions",
142
+ "validateOptions",
143
+ "interceptRequest",
144
+ "finalizeOptions",
145
+ "onRequest",
146
+ "onResponse",
147
+ "onError",
148
+ "onReturn",
149
+ "onHeaders"
150
+ ];
144
151
  function createRequester(initMiddleware, httpRequest) {
145
152
  const loadedMiddleware = [];
146
- const middleware = middlehooks.reduce((ware, name) => {
147
- ware[name] = ware[name] || [];
148
- return ware;
149
- }, {
150
- processOptions: [processOptions],
151
- validateOptions: [validateOptions]
152
- });
153
+ const middleware = middlehooks.reduce(
154
+ (ware, name) => {
155
+ ware[name] = ware[name] || [];
156
+ return ware;
157
+ },
158
+ {
159
+ processOptions: [processOptions],
160
+ validateOptions: [validateOptions]
161
+ }
162
+ );
153
163
  function request(opts) {
154
164
  const onResponse = (reqErr, res, ctx) => {
155
165
  let error = reqErr;
@@ -176,13 +186,9 @@
176
186
  const applyMiddleware = middlewareReducer(middleware);
177
187
  const options = applyMiddleware("processOptions", opts);
178
188
  applyMiddleware("validateOptions", options);
179
- const context = {
180
- options,
181
- channels,
182
- applyMiddleware
183
- };
189
+ const context = { options, channels, applyMiddleware };
184
190
  let ongoingRequest;
185
- const unsubscribe = channels.request.subscribe(ctx => {
191
+ const unsubscribe = channels.request.subscribe((ctx) => {
186
192
  ongoingRequest = httpRequest(ctx, (err, res) => onResponse(err, res, ctx));
187
193
  });
188
194
  channels.abort.subscribe(() => {
@@ -202,12 +208,16 @@
202
208
  throw new Error("Tried to add middleware that resolved to falsey value");
203
209
  }
204
210
  if (typeof newMiddleware === "function") {
205
- throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");
211
+ throw new Error(
212
+ "Tried to add middleware that was a function. It probably expects you to pass options to it."
213
+ );
206
214
  }
207
215
  if (newMiddleware.onReturn && middleware.onReturn.length > 0) {
208
- throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");
216
+ throw new Error(
217
+ "Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event"
218
+ );
209
219
  }
210
- middlehooks.forEach(key => {
220
+ middlehooks.forEach((key) => {
211
221
  if (newMiddleware[key]) {
212
222
  middleware[key].push(newMiddleware[key]);
213
223
  }
@@ -219,15 +229,18 @@
219
229
  initMiddleware.forEach(request.use);
220
230
  return request;
221
231
  }
232
+
222
233
  var __accessCheck$7 = (obj, member, msg) => {
223
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
234
+ if (!member.has(obj))
235
+ throw TypeError("Cannot " + msg);
224
236
  };
225
237
  var __privateGet$7 = (obj, member, getter) => {
226
238
  __accessCheck$7(obj, member, "read from private field");
227
239
  return getter ? getter.call(obj) : member.get(obj);
228
240
  };
229
241
  var __privateAdd$7 = (obj, member, value) => {
230
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
242
+ if (member.has(obj))
243
+ throw TypeError("Cannot add the same private member more than once");
231
244
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
232
245
  };
233
246
  var __privateSet$7 = (obj, member, value, setter) => {
@@ -275,8 +288,7 @@
275
288
  __privateGet$7(this, _headers)[name] = value;
276
289
  }
277
290
  // Allow setting extra fetch init options, needed for runtimes such as Vercel Edge to set `cache` and other options in React Server Components
278
- setInit(init) {
279
- let useAbortSignal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
291
+ setInit(init, useAbortSignal = true) {
280
292
  __privateSet$7(this, _init, init);
281
293
  __privateSet$7(this, _useAbortSignal, useAbortSignal);
282
294
  }
@@ -297,7 +309,7 @@
297
309
  if (typeof document !== "undefined") {
298
310
  options.credentials = this.withCredentials ? "include" : "omit";
299
311
  }
300
- fetch(__privateGet$7(this, _url), options).then(res => {
312
+ fetch(__privateGet$7(this, _url), options).then((res) => {
301
313
  res.headers.forEach((value, key) => {
302
314
  __privateSet$7(this, _resHeaders, __privateGet$7(this, _resHeaders) + "".concat(key, ": ").concat(value, "\r\n"));
303
315
  });
@@ -305,7 +317,7 @@
305
317
  this.statusText = res.statusText;
306
318
  this.readyState = 3;
307
319
  return textBody ? res.text() : res.arrayBuffer();
308
- }).then(resBody => {
320
+ }).then((resBody) => {
309
321
  if (typeof resBody === "string") {
310
322
  this.responseText = resBody;
311
323
  } else {
@@ -313,7 +325,7 @@
313
325
  }
314
326
  this.readyState = 4;
315
327
  this.onreadystatechange();
316
- }).catch(err => {
328
+ }).catch((err) => {
317
329
  var _a;
318
330
  if (err.name === "AbortError") {
319
331
  this.onabort();
@@ -330,6 +342,7 @@
330
342
  _controller = new WeakMap();
331
343
  _init = new WeakMap();
332
344
  _useAbortSignal = new WeakMap();
345
+
333
346
  const adapter = typeof XMLHttpRequest === "function" ? "xhr" : "fetch";
334
347
  const XmlHttpRequest = adapter === "xhr" ? XMLHttpRequest : FetchXhr;
335
348
  const httpRequester = (context, callback) => {
@@ -344,9 +357,7 @@
344
357
  if (injectedResponse) {
345
358
  const cbTimer = setTimeout(callback, 0, null, injectedResponse);
346
359
  const cancel = () => clearTimeout(cbTimer);
347
- return {
348
- abort: cancel
349
- };
360
+ return { abort: cancel };
350
361
  }
351
362
  let xhr = new XmlHttpRequest();
352
363
  if (xhr instanceof FetchXhr && typeof options.fetch === "object") {
@@ -357,11 +368,19 @@
357
368
  let aborted = false;
358
369
  let loaded = false;
359
370
  let timedOut = false;
360
- xhr.onerror = event => {
361
- onError(new Error("Request error while attempting to reach ".concat(options.url).concat(event.lengthComputable ? "(".concat(event.loaded, " of ").concat(event.total, " bytes transferred)") : "")));
371
+ xhr.onerror = (event) => {
372
+ onError(
373
+ new Error(
374
+ "Request error while attempting to reach ".concat(options.url).concat(event.lengthComputable ? "(".concat(event.loaded, " of ").concat(event.total, " bytes transferred)") : "")
375
+ )
376
+ );
362
377
  };
363
- xhr.ontimeout = event => {
364
- onError(new Error("Request timeout while attempting to reach ".concat(options.url).concat(event.lengthComputable ? "(".concat(event.loaded, " of ").concat(event.total, " bytes transferred)") : "")));
378
+ xhr.ontimeout = (event) => {
379
+ onError(
380
+ new Error(
381
+ "Request timeout while attempting to reach ".concat(options.url).concat(event.lengthComputable ? "(".concat(event.loaded, " of ").concat(event.total, " bytes transferred)") : "")
382
+ )
383
+ );
365
384
  };
366
385
  xhr.onabort = () => {
367
386
  stopTimers(true);
@@ -377,8 +396,11 @@
377
396
  }
378
397
  onLoad();
379
398
  };
380
- xhr.open(options.method, options.url, true
381
- // Always async
399
+ xhr.open(
400
+ options.method,
401
+ options.url,
402
+ true
403
+ // Always async
382
404
  );
383
405
  xhr.withCredentials = !!options.withCredentials;
384
406
  if (headers && xhr.setRequestHeader) {
@@ -391,19 +413,12 @@
391
413
  if (options.rawBody) {
392
414
  xhr.responseType = "arraybuffer";
393
415
  }
394
- context.applyMiddleware("onRequest", {
395
- options,
396
- adapter,
397
- request: xhr,
398
- context
399
- });
416
+ context.applyMiddleware("onRequest", { options, adapter, request: xhr, context });
400
417
  xhr.send(options.body || null);
401
418
  if (delays) {
402
419
  timers.connect = setTimeout(() => timeoutRequest("ETIMEDOUT"), delays.connect);
403
420
  }
404
- return {
405
- abort
406
- };
421
+ return { abort };
407
422
  function abort() {
408
423
  aborted = true;
409
424
  if (xhr) {
@@ -413,7 +428,9 @@
413
428
  function timeoutRequest(code) {
414
429
  timedOut = true;
415
430
  xhr.abort();
416
- const error = new Error(code === "ESOCKETTIMEDOUT" ? "Socket timed out on request to ".concat(options.url) : "Connection timed out on request to ".concat(options.url));
431
+ const error = new Error(
432
+ code === "ESOCKETTIMEDOUT" ? "Socket timed out on request to ".concat(options.url) : "Connection timed out on request to ".concat(options.url)
433
+ );
417
434
  error.code = code;
418
435
  context.channels.error.publish(error);
419
436
  }
@@ -467,11 +484,8 @@
467
484
  callback(null, reduceResponse());
468
485
  }
469
486
  };
470
- const getIt = function () {
471
- let initMiddleware = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
472
- let httpRequest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : httpRequester;
473
- return createRequester(initMiddleware, httpRequest);
474
- };
487
+
488
+ const getIt = (initMiddleware = [], httpRequest = httpRequester) => createRequester(initMiddleware, httpRequest);
475
489
  const environment = "browser";
476
490
 
477
491
  var browser$3 = {exports: {}};
@@ -1226,11 +1240,12 @@
1226
1240
  return true;
1227
1241
  }
1228
1242
 
1229
- const isBuffer = typeof Buffer === "undefined" ? () => false : obj => Buffer.isBuffer(obj);
1243
+ const isBuffer = typeof Buffer === "undefined" ? () => false : (obj) => Buffer.isBuffer(obj);
1244
+
1230
1245
  const serializeTypes = ["boolean", "string", "number"];
1231
1246
  function jsonRequest() {
1232
1247
  return {
1233
- processOptions: options => {
1248
+ processOptions: (options) => {
1234
1249
  const body = options.body;
1235
1250
  if (!body) {
1236
1251
  return options;
@@ -1249,22 +1264,19 @@
1249
1264
  }
1250
1265
  };
1251
1266
  }
1267
+
1252
1268
  function jsonResponse(opts) {
1253
1269
  return {
1254
- onResponse: response => {
1270
+ onResponse: (response) => {
1255
1271
  const contentType = response.headers["content-type"] || "";
1256
1272
  const shouldDecode = opts && opts.force || contentType.indexOf("application/json") !== -1;
1257
1273
  if (!response.body || !contentType || !shouldDecode) {
1258
1274
  return response;
1259
1275
  }
1260
- return Object.assign({}, response, {
1261
- body: tryParse(response.body)
1262
- });
1276
+ return Object.assign({}, response, { body: tryParse(response.body) });
1263
1277
  },
1264
- processOptions: options => Object.assign({}, options, {
1265
- headers: Object.assign({
1266
- Accept: "application/json"
1267
- }, options.headers)
1278
+ processOptions: (options) => Object.assign({}, options, {
1279
+ headers: Object.assign({ Accept: "application/json" }, options.headers)
1268
1280
  })
1269
1281
  };
1270
1282
  function tryParse(body) {
@@ -1276,6 +1288,7 @@
1276
1288
  }
1277
1289
  }
1278
1290
  }
1291
+
1279
1292
  let actualGlobal = {};
1280
1293
  if (typeof globalThis !== "undefined") {
1281
1294
  actualGlobal = globalThis;
@@ -1287,24 +1300,25 @@
1287
1300
  actualGlobal = self;
1288
1301
  }
1289
1302
  var global$1 = actualGlobal;
1290
- function observable$1() {
1291
- let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1292
- const Observable =
1293
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- @TODO consider dropping checking for a global Observable since it's not on a standards track
1294
- opts.implementation || global$1.Observable;
1303
+
1304
+ function observable$1(opts = {}) {
1305
+ const Observable = (
1306
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- @TODO consider dropping checking for a global Observable since it's not on a standards track
1307
+ opts.implementation || global$1.Observable
1308
+ );
1295
1309
  if (!Observable) {
1296
- throw new Error("`Observable` is not available in global scope, and no implementation was passed");
1310
+ throw new Error(
1311
+ "`Observable` is not available in global scope, and no implementation was passed"
1312
+ );
1297
1313
  }
1298
1314
  return {
1299
- onReturn: (channels, context) => new Observable(observer => {
1300
- channels.error.subscribe(err => observer.error(err));
1301
- channels.progress.subscribe(event => observer.next(Object.assign({
1302
- type: "progress"
1303
- }, event)));
1304
- channels.response.subscribe(response => {
1305
- observer.next(Object.assign({
1306
- type: "response"
1307
- }, response));
1315
+ onReturn: (channels, context) => new Observable((observer) => {
1316
+ channels.error.subscribe((err) => observer.error(err));
1317
+ channels.progress.subscribe(
1318
+ (event) => observer.next(Object.assign({ type: "progress" }, event))
1319
+ );
1320
+ channels.response.subscribe((response) => {
1321
+ observer.next(Object.assign({ type: "response" }, response));
1308
1322
  observer.complete();
1309
1323
  });
1310
1324
  channels.request.publish(context);
@@ -1312,9 +1326,10 @@
1312
1326
  })
1313
1327
  };
1314
1328
  }
1329
+
1315
1330
  function progress() {
1316
1331
  return {
1317
- onRequest: evt => {
1332
+ onRequest: (evt) => {
1318
1333
  if (evt.adapter !== "xhr") {
1319
1334
  return;
1320
1335
  }
@@ -1327,7 +1342,7 @@
1327
1342
  xhr.onprogress = handleProgress("download");
1328
1343
  }
1329
1344
  function handleProgress(stage) {
1330
- return event => {
1345
+ return (event) => {
1331
1346
  const percent = event.lengthComputable ? event.loaded / event.total * 100 : -1;
1332
1347
  context.channels.progress.publish({
1333
1348
  stage,
@@ -1356,10 +1371,10 @@
1356
1371
  throw new TypeError("executor must be a function.");
1357
1372
  }
1358
1373
  let resolvePromise = null;
1359
- this.promise = new Promise(resolve => {
1374
+ this.promise = new Promise((resolve) => {
1360
1375
  resolvePromise = resolve;
1361
1376
  });
1362
- executor(message => {
1377
+ executor((message) => {
1363
1378
  if (this.reason) {
1364
1379
  return;
1365
1380
  }
@@ -1370,7 +1385,7 @@
1370
1385
  };
1371
1386
  _CancelToken.source = () => {
1372
1387
  let cancel;
1373
- const token = new _CancelToken(can => {
1388
+ const token = new _CancelToken((can) => {
1374
1389
  cancel = can;
1375
1390
  });
1376
1391
  return {
@@ -1378,14 +1393,16 @@
1378
1393
  cancel
1379
1394
  };
1380
1395
  };
1396
+
1381
1397
  var defaultShouldRetry = (err, attempt, options) => {
1382
1398
  if (options.method !== "GET" && options.method !== "HEAD") {
1383
1399
  return false;
1384
1400
  }
1385
1401
  return err.isNetworkError || false;
1386
1402
  };
1387
- const isStream = stream => stream !== null && typeof stream === "object" && typeof stream.pipe === "function";
1388
- var sharedRetry = opts => {
1403
+
1404
+ const isStream = (stream) => stream !== null && typeof stream === "object" && typeof stream.pipe === "function";
1405
+ var sharedRetry = (opts) => {
1389
1406
  const maxRetries = opts.maxRetries || 5;
1390
1407
  const retryDelay = opts.retryDelay || getRetryDelay;
1391
1408
  const allowRetry = opts.shouldRetry;
@@ -1402,9 +1419,7 @@
1402
1419
  return err;
1403
1420
  }
1404
1421
  const newContext = Object.assign({}, context, {
1405
- options: Object.assign({}, options, {
1406
- attemptNumber: attemptNumber + 1
1407
- })
1422
+ options: Object.assign({}, options, { attemptNumber: attemptNumber + 1 })
1408
1423
  });
1409
1424
  setTimeout(() => context.channels.request.publish(newContext), retryDelay(attemptNumber));
1410
1425
  return null;
@@ -1414,13 +1429,8 @@
1414
1429
  function getRetryDelay(attemptNum) {
1415
1430
  return 100 * Math.pow(2, attemptNum) + Math.random() * 100;
1416
1431
  }
1417
- const retry = function () {
1418
- let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1419
- return sharedRetry({
1420
- shouldRetry: defaultShouldRetry,
1421
- ...opts
1422
- });
1423
- };
1432
+
1433
+ const retry = (opts = {}) => sharedRetry({ shouldRetry: defaultShouldRetry, ...opts });
1424
1434
  retry.shouldRetry = defaultShouldRetry;
1425
1435
 
1426
1436
  /******************************************************************************
@@ -2137,7 +2147,7 @@
2137
2147
  }
2138
2148
  if (isMutationError(body)) {
2139
2149
  const allItems = body.error.items || [];
2140
- const items = allItems.slice(0, MAX_ITEMS_IN_ERROR_MESSAGE).map(item => {
2150
+ const items = allItems.slice(0, MAX_ITEMS_IN_ERROR_MESSAGE).map((item) => {
2141
2151
  var _a;
2142
2152
  return (_a = item.error) == null ? void 0 : _a.description;
2143
2153
  }).filter(Boolean);
@@ -2172,8 +2182,9 @@
2172
2182
  const isJson = contentType.indexOf("application/json") !== -1;
2173
2183
  return isJson ? JSON.stringify(body, null, 2) : body;
2174
2184
  }
2185
+
2175
2186
  const httpError = {
2176
- onResponse: res => {
2187
+ onResponse: (res) => {
2177
2188
  if (res.statusCode >= 500) {
2178
2189
  throw new ServerError(res);
2179
2190
  } else if (res.statusCode >= 400) {
@@ -2183,33 +2194,35 @@
2183
2194
  }
2184
2195
  };
2185
2196
  const printWarnings = {
2186
- onResponse: res => {
2197
+ onResponse: (res) => {
2187
2198
  const warn = res.headers["x-sanity-warning"];
2188
2199
  const warnings = Array.isArray(warn) ? warn : [warn];
2189
- warnings.filter(Boolean).forEach(msg => console.warn(msg));
2200
+ warnings.filter(Boolean).forEach((msg) => console.warn(msg));
2190
2201
  return res;
2191
2202
  }
2192
2203
  };
2193
- function defineHttpRequest(envMiddleware, _ref) {
2194
- let {
2195
- maxRetries = 5,
2196
- retryDelay
2197
- } = _ref;
2198
- const request = getIt([maxRetries > 0 ? retry({
2199
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2200
- retryDelay,
2201
- // This option is typed incorrectly in get-it.
2202
- maxRetries,
2203
- shouldRetry
2204
- }) : {}, ...envMiddleware, printWarnings, jsonRequest(), jsonResponse(), progress(), httpError, observable$1({
2205
- implementation: Observable
2206
- })]);
2207
- function httpRequest(options) {
2208
- let requester = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : request;
2209
- return requester({
2210
- maxRedirects: 0,
2211
- ...options
2212
- });
2204
+ function defineHttpRequest(envMiddleware, {
2205
+ maxRetries = 5,
2206
+ retryDelay
2207
+ }) {
2208
+ const request = getIt([
2209
+ maxRetries > 0 ? retry({
2210
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2211
+ retryDelay,
2212
+ // This option is typed incorrectly in get-it.
2213
+ maxRetries,
2214
+ shouldRetry
2215
+ }) : {},
2216
+ ...envMiddleware,
2217
+ printWarnings,
2218
+ jsonRequest(),
2219
+ jsonResponse(),
2220
+ progress(),
2221
+ httpError,
2222
+ observable$1({ implementation: Observable })
2223
+ ]);
2224
+ function httpRequest(options, requester = request) {
2225
+ return requester({ maxRedirects: 0, ...options });
2213
2226
  }
2214
2227
  httpRequest.defaultRequester = request;
2215
2228
  return httpRequest;
@@ -2219,39 +2232,41 @@
2219
2232
  const uri = options.uri || options.url;
2220
2233
  const isQuery = uri.startsWith("/data/query");
2221
2234
  const isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
2222
- if ((isSafe || isQuery) && isRetriableResponse) return true;
2235
+ if ((isSafe || isQuery) && isRetriableResponse)
2236
+ return true;
2223
2237
  return retry.shouldRetry(err, attempt, options);
2224
2238
  }
2239
+
2225
2240
  function getSelection(sel) {
2226
2241
  if (typeof sel === "string" || Array.isArray(sel)) {
2227
- return {
2228
- id: sel
2229
- };
2242
+ return { id: sel };
2230
2243
  }
2231
2244
  if (typeof sel === "object" && sel !== null && "query" in sel && typeof sel.query === "string") {
2232
- return "params" in sel && typeof sel.params === "object" && sel.params !== null ? {
2233
- query: sel.query,
2234
- params: sel.params
2235
- } : {
2236
- query: sel.query
2237
- };
2245
+ return "params" in sel && typeof sel.params === "object" && sel.params !== null ? { query: sel.query, params: sel.params } : { query: sel.query };
2238
2246
  }
2239
- const selectionOpts = ["* Document ID (<docId>)", "* Array of document IDs", "* Object containing `query`"].join("\n");
2247
+ const selectionOpts = [
2248
+ "* Document ID (<docId>)",
2249
+ "* Array of document IDs",
2250
+ "* Object containing `query`"
2251
+ ].join("\n");
2240
2252
  throw new Error("Unknown selection - must be one of:\n\n".concat(selectionOpts));
2241
2253
  }
2254
+
2242
2255
  const VALID_ASSET_TYPES = ["image", "file"];
2243
2256
  const VALID_INSERT_LOCATIONS = ["before", "after", "replace"];
2244
- const dataset = name => {
2257
+ const dataset = (name) => {
2245
2258
  if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name)) {
2246
- throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters");
2259
+ throw new Error(
2260
+ "Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters"
2261
+ );
2247
2262
  }
2248
2263
  };
2249
- const projectId = id => {
2264
+ const projectId = (id) => {
2250
2265
  if (!/^[-a-z0-9]+$/i.test(id)) {
2251
2266
  throw new Error("`projectId` can only contain only a-z, 0-9 and dashes");
2252
2267
  }
2253
2268
  };
2254
- const validateAssetType = type => {
2269
+ const validateAssetType = (type) => {
2255
2270
  if (VALID_ASSET_TYPES.indexOf(type) === -1) {
2256
2271
  throw new Error("Invalid asset type: ".concat(type, ". Must be one of ").concat(VALID_ASSET_TYPES.join(", ")));
2257
2272
  }
@@ -2275,7 +2290,7 @@
2275
2290
  const validateInsert = (at, selector, items) => {
2276
2291
  const signature = "insert(at, selector, items)";
2277
2292
  if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {
2278
- const valid = VALID_INSERT_LOCATIONS.map(loc => '"'.concat(loc, '"')).join(", ");
2293
+ const valid = VALID_INSERT_LOCATIONS.map((loc) => '"'.concat(loc, '"')).join(", ");
2279
2294
  throw new Error("".concat(signature, ' takes an "at"-argument which is one of: ').concat(valid));
2280
2295
  }
2281
2296
  if (typeof selector !== "string") {
@@ -2285,27 +2300,32 @@
2285
2300
  throw new Error("".concat(signature, ' takes an "items"-argument which must be an array'));
2286
2301
  }
2287
2302
  };
2288
- const hasDataset = config => {
2303
+ const hasDataset = (config) => {
2289
2304
  if (!config.dataset) {
2290
2305
  throw new Error("`dataset` must be provided to perform queries");
2291
2306
  }
2292
2307
  return config.dataset || "";
2293
2308
  };
2294
- const requestTag = tag => {
2309
+ const requestTag = (tag) => {
2295
2310
  if (typeof tag !== "string" || !/^[a-z0-9._-]{1,75}$/i.test(tag)) {
2296
- throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");
2311
+ throw new Error(
2312
+ "Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long."
2313
+ );
2297
2314
  }
2298
2315
  return tag;
2299
2316
  };
2317
+
2300
2318
  var __accessCheck$6 = (obj, member, msg) => {
2301
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
2319
+ if (!member.has(obj))
2320
+ throw TypeError("Cannot " + msg);
2302
2321
  };
2303
2322
  var __privateGet$6 = (obj, member, getter) => {
2304
2323
  __accessCheck$6(obj, member, "read from private field");
2305
2324
  return getter ? getter.call(obj) : member.get(obj);
2306
2325
  };
2307
2326
  var __privateAdd$6 = (obj, member, value) => {
2308
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
2327
+ if (member.has(obj))
2328
+ throw TypeError("Cannot add the same private member more than once");
2309
2329
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2310
2330
  };
2311
2331
  var __privateSet$6 = (obj, member, value, setter) => {
@@ -2315,8 +2335,7 @@
2315
2335
  };
2316
2336
  var _client$5, _client2$5;
2317
2337
  class BasePatch {
2318
- constructor(selection) {
2319
- let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2338
+ constructor(selection, operations = {}) {
2320
2339
  this.selection = selection;
2321
2340
  this.operations = operations;
2322
2341
  }
@@ -2358,9 +2377,7 @@
2358
2377
  if (!Array.isArray(attrs)) {
2359
2378
  throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");
2360
2379
  }
2361
- this.operations = Object.assign({}, this.operations, {
2362
- unset: attrs
2363
- });
2380
+ this.operations = Object.assign({}, this.operations, { unset: attrs });
2364
2381
  return this;
2365
2382
  }
2366
2383
  /**
@@ -2388,10 +2405,7 @@
2388
2405
  */
2389
2406
  insert(at, selector, items) {
2390
2407
  validateInsert(at, selector, items);
2391
- return this._assign("insert", {
2392
- [at]: selector,
2393
- items
2394
- });
2408
+ return this._assign("insert", { [at]: selector, items });
2395
2409
  }
2396
2410
  /**
2397
2411
  * Append the given items to the array at the given JSONPath
@@ -2440,10 +2454,7 @@
2440
2454
  * Return a plain JSON representation of the patch
2441
2455
  */
2442
2456
  serialize() {
2443
- return {
2444
- ...getSelection(this.selection),
2445
- ...this.operations
2446
- };
2457
+ return { ...getSelection(this.selection), ...this.operations };
2447
2458
  }
2448
2459
  /**
2449
2460
  * Return a plain JSON representation of the patch
@@ -2458,8 +2469,7 @@
2458
2469
  this.operations = {};
2459
2470
  return this;
2460
2471
  }
2461
- _assign(op, props) {
2462
- let merge = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
2472
+ _assign(op, props, merge = true) {
2463
2473
  validateObject(op, props);
2464
2474
  this.operations = Object.assign({}, this.operations, {
2465
2475
  [op]: Object.assign({}, merge && this.operations[op] || {}, props)
@@ -2480,22 +2490,17 @@
2480
2490
  * Clones the patch
2481
2491
  */
2482
2492
  clone() {
2483
- return new _ObservablePatch(this.selection, {
2484
- ...this.operations
2485
- }, __privateGet$6(this, _client$5));
2493
+ return new _ObservablePatch(this.selection, { ...this.operations }, __privateGet$6(this, _client$5));
2486
2494
  }
2487
2495
  commit(options) {
2488
2496
  if (!__privateGet$6(this, _client$5)) {
2489
- throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
2497
+ throw new Error(
2498
+ "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
2499
+ );
2490
2500
  }
2491
2501
  const returnFirst = typeof this.selection === "string";
2492
- const opts = Object.assign({
2493
- returnFirst,
2494
- returnDocuments: true
2495
- }, options);
2496
- return __privateGet$6(this, _client$5).mutate({
2497
- patch: this.serialize()
2498
- }, opts);
2502
+ const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
2503
+ return __privateGet$6(this, _client$5).mutate({ patch: this.serialize() }, opts);
2499
2504
  }
2500
2505
  };
2501
2506
  _client$5 = new WeakMap();
@@ -2510,35 +2515,33 @@
2510
2515
  * Clones the patch
2511
2516
  */
2512
2517
  clone() {
2513
- return new _Patch(this.selection, {
2514
- ...this.operations
2515
- }, __privateGet$6(this, _client2$5));
2518
+ return new _Patch(this.selection, { ...this.operations }, __privateGet$6(this, _client2$5));
2516
2519
  }
2517
2520
  commit(options) {
2518
2521
  if (!__privateGet$6(this, _client2$5)) {
2519
- throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
2522
+ throw new Error(
2523
+ "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
2524
+ );
2520
2525
  }
2521
2526
  const returnFirst = typeof this.selection === "string";
2522
- const opts = Object.assign({
2523
- returnFirst,
2524
- returnDocuments: true
2525
- }, options);
2526
- return __privateGet$6(this, _client2$5).mutate({
2527
- patch: this.serialize()
2528
- }, opts);
2527
+ const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
2528
+ return __privateGet$6(this, _client2$5).mutate({ patch: this.serialize() }, opts);
2529
2529
  }
2530
2530
  };
2531
2531
  _client2$5 = new WeakMap();
2532
2532
  let Patch = _Patch;
2533
+
2533
2534
  var __accessCheck$5 = (obj, member, msg) => {
2534
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
2535
+ if (!member.has(obj))
2536
+ throw TypeError("Cannot " + msg);
2535
2537
  };
2536
2538
  var __privateGet$5 = (obj, member, getter) => {
2537
2539
  __accessCheck$5(obj, member, "read from private field");
2538
2540
  return getter ? getter.call(obj) : member.get(obj);
2539
2541
  };
2540
2542
  var __privateAdd$5 = (obj, member, value) => {
2541
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
2543
+ if (member.has(obj))
2544
+ throw TypeError("Cannot add the same private member more than once");
2542
2545
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2543
2546
  };
2544
2547
  var __privateSet$5 = (obj, member, value, setter) => {
@@ -2547,13 +2550,9 @@
2547
2550
  return value;
2548
2551
  };
2549
2552
  var _client$4, _client2$4;
2550
- const defaultMutateOptions = {
2551
- returnDocuments: false
2552
- };
2553
+ const defaultMutateOptions = { returnDocuments: false };
2553
2554
  class BaseTransaction {
2554
- constructor() {
2555
- let operations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2556
- let transactionId = arguments.length > 1 ? arguments[1] : undefined;
2555
+ constructor(operations = [], transactionId) {
2557
2556
  this.operations = operations;
2558
2557
  this.trxId = transactionId;
2559
2558
  }
@@ -2565,9 +2564,7 @@
2565
2564
  */
2566
2565
  create(doc) {
2567
2566
  validateObject("create", doc);
2568
- return this._add({
2569
- create: doc
2570
- });
2567
+ return this._add({ create: doc });
2571
2568
  }
2572
2569
  /**
2573
2570
  * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
@@ -2579,9 +2576,7 @@
2579
2576
  const op = "createIfNotExists";
2580
2577
  validateObject(op, doc);
2581
2578
  requireDocumentId(op, doc);
2582
- return this._add({
2583
- [op]: doc
2584
- });
2579
+ return this._add({ [op]: doc });
2585
2580
  }
2586
2581
  /**
2587
2582
  * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.
@@ -2593,9 +2588,7 @@
2593
2588
  const op = "createOrReplace";
2594
2589
  validateObject(op, doc);
2595
2590
  requireDocumentId(op, doc);
2596
- return this._add({
2597
- [op]: doc
2598
- });
2591
+ return this._add({ [op]: doc });
2599
2592
  }
2600
2593
  /**
2601
2594
  * Deletes the document with the given document ID
@@ -2605,11 +2598,7 @@
2605
2598
  */
2606
2599
  delete(documentId) {
2607
2600
  validateDocumentId("delete", documentId);
2608
- return this._add({
2609
- delete: {
2610
- id: documentId
2611
- }
2612
- });
2601
+ return this._add({ delete: { id: documentId } });
2613
2602
  }
2614
2603
  transactionId(id) {
2615
2604
  if (!id) {
@@ -2656,35 +2645,29 @@
2656
2645
  }
2657
2646
  commit(options) {
2658
2647
  if (!__privateGet$5(this, _client$4)) {
2659
- throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
2648
+ throw new Error(
2649
+ "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
2650
+ );
2660
2651
  }
2661
- return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
2662
- transactionId: this.trxId
2663
- }, defaultMutateOptions, options || {}));
2652
+ return __privateGet$5(this, _client$4).mutate(
2653
+ this.serialize(),
2654
+ Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
2655
+ );
2664
2656
  }
2665
2657
  patch(patchOrDocumentId, patchOps) {
2666
2658
  const isBuilder = typeof patchOps === "function";
2667
2659
  const isPatch = typeof patchOrDocumentId !== "string" && patchOrDocumentId instanceof Patch;
2668
2660
  if (isPatch) {
2669
- return this._add({
2670
- patch: patchOrDocumentId.serialize()
2671
- });
2661
+ return this._add({ patch: patchOrDocumentId.serialize() });
2672
2662
  }
2673
2663
  if (isBuilder) {
2674
2664
  const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
2675
2665
  if (!(patch instanceof Patch)) {
2676
2666
  throw new Error("function passed to `patch()` must return the patch");
2677
2667
  }
2678
- return this._add({
2679
- patch: patch.serialize()
2680
- });
2668
+ return this._add({ patch: patch.serialize() });
2681
2669
  }
2682
- return this._add({
2683
- patch: {
2684
- id: patchOrDocumentId,
2685
- ...patchOps
2686
- }
2687
- });
2670
+ return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
2688
2671
  }
2689
2672
  };
2690
2673
  _client$4 = new WeakMap();
@@ -2703,68 +2686,79 @@
2703
2686
  }
2704
2687
  commit(options) {
2705
2688
  if (!__privateGet$5(this, _client2$4)) {
2706
- throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
2689
+ throw new Error(
2690
+ "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
2691
+ );
2707
2692
  }
2708
- return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
2709
- transactionId: this.trxId
2710
- }, defaultMutateOptions, options || {}));
2693
+ return __privateGet$5(this, _client2$4).mutate(
2694
+ this.serialize(),
2695
+ Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
2696
+ );
2711
2697
  }
2712
2698
  patch(patchOrDocumentId, patchOps) {
2713
2699
  const isBuilder = typeof patchOps === "function";
2714
2700
  const isPatch = typeof patchOrDocumentId !== "string" && patchOrDocumentId instanceof ObservablePatch;
2715
2701
  if (isPatch) {
2716
- return this._add({
2717
- patch: patchOrDocumentId.serialize()
2718
- });
2702
+ return this._add({ patch: patchOrDocumentId.serialize() });
2719
2703
  }
2720
2704
  if (isBuilder) {
2721
2705
  const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
2722
2706
  if (!(patch instanceof ObservablePatch)) {
2723
2707
  throw new Error("function passed to `patch()` must return the patch");
2724
2708
  }
2725
- return this._add({
2726
- patch: patch.serialize()
2727
- });
2709
+ return this._add({ patch: patch.serialize() });
2728
2710
  }
2729
- return this._add({
2730
- patch: {
2731
- id: patchOrDocumentId,
2732
- ...patchOps
2733
- }
2734
- });
2711
+ return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
2735
2712
  }
2736
2713
  };
2737
2714
  _client2$4 = new WeakMap();
2738
2715
  let ObservableTransaction = _ObservableTransaction;
2716
+
2739
2717
  const BASE_URL = "https://www.sanity.io/help/";
2740
2718
  function generateHelpUrl(slug) {
2741
2719
  return BASE_URL + slug;
2742
2720
  }
2721
+
2743
2722
  function once(fn) {
2744
2723
  let didCall = false;
2745
2724
  let returnValue;
2746
- return function () {
2725
+ return (...args) => {
2747
2726
  if (didCall) {
2748
2727
  return returnValue;
2749
2728
  }
2750
- returnValue = fn(...arguments);
2729
+ returnValue = fn(...args);
2751
2730
  didCall = true;
2752
2731
  return returnValue;
2753
2732
  };
2754
2733
  }
2755
- const createWarningPrinter = message =>
2756
- // eslint-disable-next-line no-console
2757
- once(function () {
2758
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2759
- args[_key] = arguments[_key];
2760
- }
2761
- return console.warn(message.join(" "), ...args);
2762
- });
2763
- 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."]);
2764
- const printCdnPreviewDraftsWarning = createWarningPrinter(["The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.", "The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."]);
2765
- 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.")]);
2766
- const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
2767
- const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]);
2734
+
2735
+ const createWarningPrinter = (message) => (
2736
+ // eslint-disable-next-line no-console
2737
+ once((...args) => console.warn(message.join(" "), ...args))
2738
+ );
2739
+ const printCdnWarning = createWarningPrinter([
2740
+ "Since you haven't set a value for `useCdn`, we will deliver content using our",
2741
+ "global, edge-cached API-CDN. If you wish to have content delivered faster, set",
2742
+ "`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."
2743
+ ]);
2744
+ const printCdnPreviewDraftsWarning = createWarningPrinter([
2745
+ "The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.",
2746
+ "The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."
2747
+ ]);
2748
+ const printBrowserTokenWarning = createWarningPrinter([
2749
+ "You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
2750
+ "See ".concat(generateHelpUrl(
2751
+ "js-client-browser-token"
2752
+ ), " for more information and how to hide this warning.")
2753
+ ]);
2754
+ const printNoApiVersionSpecifiedWarning = createWarningPrinter([
2755
+ "Using the Sanity client without specifying an API version is deprecated.",
2756
+ "See ".concat(generateHelpUrl("js-client-api-version"))
2757
+ ]);
2758
+ const printNoDefaultExport = createWarningPrinter([
2759
+ "The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."
2760
+ ]);
2761
+
2768
2762
  const defaultCdnHost = "apicdn.sanity.io";
2769
2763
  const defaultConfig = {
2770
2764
  apiHost: "https://api.sanity.io",
@@ -2772,7 +2766,7 @@
2772
2766
  useProjectHostname: true
2773
2767
  };
2774
2768
  const LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"];
2775
- const isLocal = host => LOCALHOSTS.indexOf(host) !== -1;
2769
+ const isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
2776
2770
  const validateApiVersion = function validateApiVersion2(apiVersion) {
2777
2771
  if (apiVersion === "1" || apiVersion === "X") {
2778
2772
  return;
@@ -2790,7 +2784,9 @@
2790
2784
  case "raw":
2791
2785
  return;
2792
2786
  default:
2793
- throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`");
2787
+ throw new TypeError(
2788
+ "Invalid API perspective string, expected `published`, `previewDrafts` or `raw`"
2789
+ );
2794
2790
  }
2795
2791
  };
2796
2792
  const initConfig = (config, prevConfig) => {
@@ -2811,10 +2807,14 @@
2811
2807
  validateApiPerspective(newConfig.perspective);
2812
2808
  }
2813
2809
  if ("encodeSourceMapAtPath" in newConfig || "encodeSourceMap" in newConfig || "studioUrl" in newConfig || "logger" in newConfig) {
2814
- throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client', such as 'encodeSourceMapAtPath', 'encodeSourceMap', 'studioUrl' and 'logger'. Make sure you're using the right import.");
2810
+ throw new Error(
2811
+ "It looks like you're using options meant for '@sanity/preview-kit/client', such as 'encodeSourceMapAtPath', 'encodeSourceMap', 'studioUrl' and 'logger'. Make sure you're using the right import."
2812
+ );
2815
2813
  }
2816
2814
  if ("stega" in newConfig && newConfig["stega"] !== void 0 && newConfig["stega"] !== false) {
2817
- throw new Error("It looks like you're using options meant for '@sanity/client/stega'. Make sure you're using the right import. Or set 'stega' in 'createClient' to 'false'.");
2815
+ throw new Error(
2816
+ "It looks like you're using options meant for '@sanity/client/stega'. Make sure you're using the right import. Or set 'stega' in 'createClient' to 'false'."
2817
+ );
2818
2818
  }
2819
2819
  const isBrowser = typeof window !== "undefined" && window.location && window.location.hostname;
2820
2820
  const isLocalhost = isBrowser && isLocal(window.location.hostname);
@@ -2849,9 +2849,9 @@
2849
2849
  }
2850
2850
  return newConfig;
2851
2851
  };
2852
+
2852
2853
  const projectHeader = "X-Sanity-Project-ID";
2853
- function requestOptions(config) {
2854
- let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2854
+ function requestOptions(config, overrides = {}) {
2855
2855
  const headers = {};
2856
2856
  const token = overrides.token || config.token;
2857
2857
  if (token) {
@@ -2860,7 +2860,9 @@
2860
2860
  if (!overrides.useGlobalApi && !config.useProjectHostname && config.projectId) {
2861
2861
  headers[projectHeader] = config.projectId;
2862
2862
  }
2863
- const withCredentials = Boolean(typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials);
2863
+ const withCredentials = Boolean(
2864
+ typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials
2865
+ );
2864
2866
  const timeout = typeof overrides.timeout === "undefined" ? config.timeout : overrides.timeout;
2865
2867
  return Object.assign({}, overrides, {
2866
2868
  headers: Object.assign({}, headers, overrides.headers || {}),
@@ -2868,39 +2870,35 @@
2868
2870
  proxy: overrides.proxy || config.proxy,
2869
2871
  json: true,
2870
2872
  withCredentials,
2871
- fetch: typeof overrides.fetch === "object" && typeof config.fetch === "object" ? {
2872
- ...config.fetch,
2873
- ...overrides.fetch
2874
- } : overrides.fetch || config.fetch
2873
+ fetch: typeof overrides.fetch === "object" && typeof config.fetch === "object" ? { ...config.fetch, ...overrides.fetch } : overrides.fetch || config.fetch
2875
2874
  });
2876
2875
  }
2877
- const encodeQueryString = _ref2 => {
2878
- let {
2879
- query,
2880
- params = {},
2881
- options = {}
2882
- } = _ref2;
2876
+
2877
+ const encodeQueryString = ({
2878
+ query,
2879
+ params = {},
2880
+ options = {}
2881
+ }) => {
2883
2882
  const searchParams = new URLSearchParams();
2884
- const {
2885
- tag,
2886
- ...opts
2887
- } = options;
2888
- if (tag) searchParams.append("tag", tag);
2883
+ const { tag, ...opts } = options;
2884
+ if (tag)
2885
+ searchParams.append("tag", tag);
2889
2886
  searchParams.append("query", query);
2890
2887
  for (const [key, value] of Object.entries(params)) {
2891
2888
  searchParams.append("$".concat(key), JSON.stringify(value));
2892
2889
  }
2893
2890
  for (const [key, value] of Object.entries(opts)) {
2894
- if (value) searchParams.append(key, "".concat(value));
2891
+ if (value)
2892
+ searchParams.append(key, "".concat(value));
2895
2893
  }
2896
2894
  return "?".concat(searchParams);
2897
2895
  };
2896
+
2898
2897
  const excludeFalsey = (param, defValue) => {
2899
2898
  const value = typeof param === "undefined" ? defValue : param;
2900
2899
  return param === false ? void 0 : value;
2901
2900
  };
2902
- const getMutationQuery = function () {
2903
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2901
+ const getMutationQuery = (options = {}) => {
2904
2902
  return {
2905
2903
  dryRun: options.dryRun,
2906
2904
  returnIds: true,
@@ -2910,61 +2908,45 @@
2910
2908
  skipCrossDatasetReferenceValidation: options.skipCrossDatasetReferenceValidation
2911
2909
  };
2912
2910
  };
2913
- const isResponse = event => event.type === "response";
2914
- const getBody = event => event.body;
2911
+ const isResponse = (event) => event.type === "response";
2912
+ const getBody = (event) => event.body;
2915
2913
  const indexBy = (docs, attr) => docs.reduce((indexed, doc) => {
2916
2914
  indexed[attr(doc)] = doc;
2917
2915
  return indexed;
2918
- }, /* @__PURE__ */Object.create(null));
2916
+ }, /* @__PURE__ */ Object.create(null));
2919
2917
  const getQuerySizeLimit = 11264;
2920
- function _fetch(client, httpRequest, query, params) {
2921
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
2918
+ function _fetch(client, httpRequest, query, params, options = {}) {
2922
2919
  if ("stega" in options && options["stega"] !== void 0 && options["stega"] !== false) {
2923
- throw new Error("It looks like you're using options meant for '@sanity/client/stega'. Make sure you're using the right import. Or set 'stega' in 'fetch' to 'false'.");
2924
- }
2925
- const mapResponse = options.filterResponse === false ? res => res : res => res.result;
2926
- const {
2927
- cache,
2928
- next,
2929
- ...opts
2930
- } = {
2920
+ throw new Error(
2921
+ "It looks like you're using options meant for '@sanity/client/stega'. Make sure you're using the right import. Or set 'stega' in 'fetch' to 'false'."
2922
+ );
2923
+ }
2924
+ const mapResponse = options.filterResponse === false ? (res) => res : (res) => res.result;
2925
+ const { cache, next, ...opts } = {
2931
2926
  // Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
2932
2927
  // This is necessary in React Server Components to avoid opting out of Request Memoization.
2933
2928
  useAbortSignal: typeof options.signal !== "undefined",
2934
2929
  ...options
2935
2930
  };
2936
- const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? {
2937
- ...opts,
2938
- fetch: {
2939
- cache,
2940
- next
2941
- }
2942
- } : opts;
2943
- return _dataRequest(client, httpRequest, "query", {
2944
- query,
2945
- params
2946
- }, reqOpts).pipe(map(mapResponse));
2931
+ const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? { ...opts, fetch: { cache, next } } : opts;
2932
+ return _dataRequest(client, httpRequest, "query", { query, params }, reqOpts).pipe(map(mapResponse));
2947
2933
  }
2948
- function _getDocument(client, httpRequest, id) {
2949
- let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2950
- const options = {
2951
- uri: _getDataUrl(client, "doc", id),
2952
- json: true,
2953
- tag: opts.tag
2954
- };
2955
- return _requestObservable(client, httpRequest, options).pipe(filter(isResponse), map(event => event.body.documents && event.body.documents[0]));
2934
+ function _getDocument(client, httpRequest, id, opts = {}) {
2935
+ const options = { uri: _getDataUrl(client, "doc", id), json: true, tag: opts.tag };
2936
+ return _requestObservable(client, httpRequest, options).pipe(
2937
+ filter(isResponse),
2938
+ map((event) => event.body.documents && event.body.documents[0])
2939
+ );
2956
2940
  }
2957
- function _getDocuments(client, httpRequest, ids) {
2958
- let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2959
- const options = {
2960
- uri: _getDataUrl(client, "doc", ids.join(",")),
2961
- json: true,
2962
- tag: opts.tag
2963
- };
2964
- return _requestObservable(client, httpRequest, options).pipe(filter(isResponse), map(event => {
2965
- const indexed = indexBy(event.body.documents || [], doc => doc._id);
2966
- return ids.map(id => indexed[id] || null);
2967
- }));
2941
+ function _getDocuments(client, httpRequest, ids, opts = {}) {
2942
+ const options = { uri: _getDataUrl(client, "doc", ids.join(",")), json: true, tag: opts.tag };
2943
+ return _requestObservable(client, httpRequest, options).pipe(
2944
+ filter(isResponse),
2945
+ map((event) => {
2946
+ const indexed = indexBy(event.body.documents || [], (doc) => doc._id);
2947
+ return ids.map((id) => indexed[id] || null);
2948
+ })
2949
+ );
2968
2950
  }
2969
2951
  function _createIfNotExists(client, httpRequest, doc, options) {
2970
2952
  requireDocumentId("createIfNotExists", doc);
@@ -2975,18 +2957,18 @@
2975
2957
  return _create(client, httpRequest, doc, "createOrReplace", options);
2976
2958
  }
2977
2959
  function _delete(client, httpRequest, selection, options) {
2978
- return _dataRequest(client, httpRequest, "mutate", {
2979
- mutations: [{
2980
- delete: getSelection(selection)
2981
- }]
2982
- }, options);
2960
+ return _dataRequest(
2961
+ client,
2962
+ httpRequest,
2963
+ "mutate",
2964
+ { mutations: [{ delete: getSelection(selection) }] },
2965
+ options
2966
+ );
2983
2967
  }
2984
2968
  function _mutate(client, httpRequest, mutations, options) {
2985
2969
  let mut;
2986
2970
  if (mutations instanceof Patch || mutations instanceof ObservablePatch) {
2987
- mut = {
2988
- patch: mutations.serialize()
2989
- };
2971
+ mut = { patch: mutations.serialize() };
2990
2972
  } else if (mutations instanceof Transaction || mutations instanceof ObservableTransaction) {
2991
2973
  mut = mutations.serialize();
2992
2974
  } else {
@@ -2994,25 +2976,16 @@
2994
2976
  }
2995
2977
  const muts = Array.isArray(mut) ? mut : [mut];
2996
2978
  const transactionId = options && options.transactionId || void 0;
2997
- return _dataRequest(client, httpRequest, "mutate", {
2998
- mutations: muts,
2999
- transactionId
3000
- }, options);
2979
+ return _dataRequest(client, httpRequest, "mutate", { mutations: muts, transactionId }, options);
3001
2980
  }
3002
- function _dataRequest(client, httpRequest, endpoint, body) {
3003
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
2981
+ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
3004
2982
  const isMutation = endpoint === "mutate";
3005
2983
  const isQuery = endpoint === "query";
3006
2984
  const strQuery = isMutation ? "" : encodeQueryString(body);
3007
2985
  const useGet = !isMutation && strQuery.length < getQuerySizeLimit;
3008
2986
  const stringQuery = useGet ? strQuery : "";
3009
2987
  const returnFirst = options.returnFirst;
3010
- const {
3011
- timeout,
3012
- token,
3013
- tag,
3014
- headers
3015
- } = options;
2988
+ const { timeout, token, tag, headers } = options;
3016
2989
  const uri = _getDataUrl(client, endpoint, stringQuery);
3017
2990
  const reqOptions = {
3018
2991
  method: useGet ? "GET" : "POST",
@@ -3032,35 +3005,31 @@
3032
3005
  useAbortSignal: options.useAbortSignal,
3033
3006
  useCdn: options.useCdn
3034
3007
  };
3035
- return _requestObservable(client, httpRequest, reqOptions).pipe(filter(isResponse), map(getBody), map(res => {
3036
- if (!isMutation) {
3037
- return res;
3038
- }
3039
- const results = res.results || [];
3040
- if (options.returnDocuments) {
3041
- return returnFirst ? results[0] && results[0].document : results.map(mut => mut.document);
3042
- }
3043
- const key = returnFirst ? "documentId" : "documentIds";
3044
- const ids = returnFirst ? results[0] && results[0].id : results.map(mut => mut.id);
3045
- return {
3046
- transactionId: res.transactionId,
3047
- results,
3048
- [key]: ids
3049
- };
3050
- }));
3008
+ return _requestObservable(client, httpRequest, reqOptions).pipe(
3009
+ filter(isResponse),
3010
+ map(getBody),
3011
+ map((res) => {
3012
+ if (!isMutation) {
3013
+ return res;
3014
+ }
3015
+ const results = res.results || [];
3016
+ if (options.returnDocuments) {
3017
+ return returnFirst ? results[0] && results[0].document : results.map((mut) => mut.document);
3018
+ }
3019
+ const key = returnFirst ? "documentId" : "documentIds";
3020
+ const ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
3021
+ return {
3022
+ transactionId: res.transactionId,
3023
+ results,
3024
+ [key]: ids
3025
+ };
3026
+ })
3027
+ );
3051
3028
  }
3052
- function _create(client, httpRequest, doc, op) {
3053
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
3054
- const mutation = {
3055
- [op]: doc
3056
- };
3057
- const opts = Object.assign({
3058
- returnFirst: true,
3059
- returnDocuments: true
3060
- }, options);
3061
- return _dataRequest(client, httpRequest, "mutate", {
3062
- mutations: [mutation]
3063
- }, opts);
3029
+ function _create(client, httpRequest, doc, op, options = {}) {
3030
+ const mutation = { [op]: doc };
3031
+ const opts = Object.assign({ returnFirst: true, returnDocuments: true }, options);
3032
+ return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
3064
3033
  }
3065
3034
  function _requestObservable(client, httpRequest, options) {
3066
3035
  var _a, _b;
@@ -3070,40 +3039,39 @@
3070
3039
  let useCdn = ((_a = options.useCdn) != null ? _a : config.useCdn) && canUseCdn;
3071
3040
  const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
3072
3041
  if (tag && options.tag !== null) {
3073
- options.query = {
3074
- tag: requestTag(tag),
3075
- ...options.query
3076
- };
3042
+ options.query = { tag: requestTag(tag), ...options.query };
3077
3043
  }
3078
3044
  if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
3079
3045
  const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
3080
3046
  if (resultSourceMap !== void 0 && resultSourceMap !== false) {
3081
- options.query = {
3082
- resultSourceMap,
3083
- ...options.query
3084
- };
3047
+ options.query = { resultSourceMap, ...options.query };
3085
3048
  }
3086
3049
  const perspective = options.perspective || config.perspective;
3087
3050
  if (typeof perspective === "string" && perspective !== "raw") {
3088
3051
  validateApiPerspective(perspective);
3089
- options.query = {
3090
- perspective,
3091
- ...options.query
3092
- };
3052
+ options.query = { perspective, ...options.query };
3093
3053
  if (perspective === "previewDrafts" && useCdn) {
3094
3054
  useCdn = false;
3095
3055
  printCdnPreviewDraftsWarning();
3096
3056
  }
3097
3057
  }
3098
3058
  }
3099
- const reqOptions = requestOptions(config, Object.assign({}, options, {
3100
- url: _getUrl(client, uri, useCdn)
3101
- }));
3102
- const request = new Observable(subscriber => httpRequest(reqOptions, config.requester).subscribe(subscriber));
3059
+ const reqOptions = requestOptions(
3060
+ config,
3061
+ Object.assign({}, options, {
3062
+ url: _getUrl(client, uri, useCdn)
3063
+ })
3064
+ );
3065
+ const request = new Observable(
3066
+ (subscriber) => httpRequest(reqOptions, config.requester).subscribe(subscriber)
3067
+ );
3103
3068
  return options.signal ? request.pipe(_withAbortSignal(options.signal)) : request;
3104
3069
  }
3105
3070
  function _request(client, httpRequest, options) {
3106
- const observable = _requestObservable(client, httpRequest, options).pipe(filter(event => event.type === "response"), map(event => event.body));
3071
+ const observable = _requestObservable(client, httpRequest, options).pipe(
3072
+ filter((event) => event.type === "response"),
3073
+ map((event) => event.body)
3074
+ );
3107
3075
  return observable;
3108
3076
  }
3109
3077
  function _getDataUrl(client, operation, path) {
@@ -3113,18 +3081,14 @@
3113
3081
  const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
3114
3082
  return "/data".concat(uri).replace(/\/($|\?)/, "$1");
3115
3083
  }
3116
- function _getUrl(client, uri) {
3117
- let canUseCdn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3118
- const {
3119
- url,
3120
- cdnUrl
3121
- } = client.config();
3084
+ function _getUrl(client, uri, canUseCdn = false) {
3085
+ const { url, cdnUrl } = client.config();
3122
3086
  const base = canUseCdn ? cdnUrl : url;
3123
3087
  return "".concat(base, "/").concat(uri.replace(/^\//, ""));
3124
3088
  }
3125
3089
  function _withAbortSignal(signal) {
3126
- return input => {
3127
- return new Observable(observer => {
3090
+ return (input) => {
3091
+ return new Observable((observer) => {
3128
3092
  const abort = () => observer.error(_createAbortError(signal));
3129
3093
  if (signal && signal.aborted) {
3130
3094
  abort();
@@ -3149,15 +3113,18 @@
3149
3113
  error.name = "AbortError";
3150
3114
  return error;
3151
3115
  }
3116
+
3152
3117
  var __accessCheck$4 = (obj, member, msg) => {
3153
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
3118
+ if (!member.has(obj))
3119
+ throw TypeError("Cannot " + msg);
3154
3120
  };
3155
3121
  var __privateGet$4 = (obj, member, getter) => {
3156
3122
  __accessCheck$4(obj, member, "read from private field");
3157
3123
  return getter ? getter.call(obj) : member.get(obj);
3158
3124
  };
3159
3125
  var __privateAdd$4 = (obj, member, value) => {
3160
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
3126
+ if (member.has(obj))
3127
+ throw TypeError("Cannot add the same private member more than once");
3161
3128
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3162
3129
  };
3163
3130
  var __privateSet$4 = (obj, member, value, setter) => {
@@ -3188,13 +3155,19 @@
3188
3155
  }
3189
3156
  upload(assetType, body, options) {
3190
3157
  const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
3191
- return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
3158
+ return lastValueFrom(
3159
+ observable.pipe(
3160
+ filter((event) => event.type === "response"),
3161
+ map(
3162
+ (event) => event.body.document
3163
+ )
3164
+ )
3165
+ );
3192
3166
  }
3193
3167
  }
3194
3168
  _client2$3 = new WeakMap();
3195
3169
  _httpRequest2$4 = new WeakMap();
3196
- function _upload(client, httpRequest, assetType, body) {
3197
- let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
3170
+ function _upload(client, httpRequest, assetType, body, opts = {}) {
3198
3171
  validateAssetType(assetType);
3199
3172
  let meta = opts.extract || void 0;
3200
3173
  if (meta && !meta.length) {
@@ -3203,15 +3176,7 @@
3203
3176
  const dataset = hasDataset(client.config());
3204
3177
  const assetEndpoint = assetType === "image" ? "images" : "files";
3205
3178
  const options = optionsFromFile(opts, body);
3206
- const {
3207
- tag,
3208
- label,
3209
- title,
3210
- description,
3211
- creditLine,
3212
- filename,
3213
- source
3214
- } = options;
3179
+ const { tag, label, title, description, creditLine, filename, source } = options;
3215
3180
  const query = {
3216
3181
  label,
3217
3182
  title,
@@ -3230,9 +3195,7 @@
3230
3195
  method: "POST",
3231
3196
  timeout: options.timeout || 0,
3232
3197
  uri: "/assets/".concat(assetEndpoint, "/").concat(dataset),
3233
- headers: options.contentType ? {
3234
- "Content-Type": options.contentType
3235
- } : {},
3198
+ headers: options.contentType ? { "Content-Type": options.contentType } : {},
3236
3199
  query,
3237
3200
  body
3238
3201
  });
@@ -3241,15 +3204,20 @@
3241
3204
  if (typeof File === "undefined" || !(file instanceof File)) {
3242
3205
  return opts;
3243
3206
  }
3244
- return Object.assign({
3245
- filename: opts.preserveFilename === false ? void 0 : file.name,
3246
- contentType: file.type
3247
- }, opts);
3207
+ return Object.assign(
3208
+ {
3209
+ filename: opts.preserveFilename === false ? void 0 : file.name,
3210
+ contentType: file.type
3211
+ },
3212
+ opts
3213
+ );
3248
3214
  }
3215
+
3249
3216
  var defaults = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj)).reduce((target, prop) => {
3250
3217
  target[prop] = typeof obj[prop] === "undefined" ? defaults[prop] : obj[prop];
3251
3218
  return target;
3252
3219
  }, {});
3220
+
3253
3221
  const pick = (obj, props) => props.reduce((selection, prop) => {
3254
3222
  if (typeof obj[prop] === "undefined") {
3255
3223
  return selection;
@@ -3257,36 +3225,27 @@
3257
3225
  selection[prop] = obj[prop];
3258
3226
  return selection;
3259
3227
  }, {});
3228
+
3260
3229
  const MAX_URL_LENGTH = 16e3 - 1200;
3261
- const possibleOptions = ["includePreviousRevision", "includeResult", "visibility", "effectFormat", "tag"];
3230
+ const possibleOptions = [
3231
+ "includePreviousRevision",
3232
+ "includeResult",
3233
+ "visibility",
3234
+ "effectFormat",
3235
+ "tag"
3236
+ ];
3262
3237
  const defaultOptions = {
3263
3238
  includeResult: true
3264
3239
  };
3265
- function _listen(query, params) {
3266
- let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3267
- const {
3268
- url,
3269
- token,
3270
- withCredentials,
3271
- requestTagPrefix
3272
- } = this.config();
3240
+ function _listen(query, params, opts = {}) {
3241
+ const { url, token, withCredentials, requestTagPrefix } = this.config();
3273
3242
  const tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag;
3274
- const options = {
3275
- ...defaults(opts, defaultOptions),
3276
- tag
3277
- };
3243
+ const options = { ...defaults(opts, defaultOptions), tag };
3278
3244
  const listenOpts = pick(options, possibleOptions);
3279
- const qs = encodeQueryString({
3280
- query,
3281
- params,
3282
- options: {
3283
- tag,
3284
- ...listenOpts
3285
- }
3286
- });
3245
+ const qs = encodeQueryString({ query, params, options: { tag, ...listenOpts } });
3287
3246
  const uri = "".concat(url).concat(_getDataUrl(this, "listen", qs));
3288
3247
  if (uri.length > MAX_URL_LENGTH) {
3289
- return new Observable(observer => observer.error(new Error("Query too large for listener")));
3248
+ return new Observable((observer) => observer.error(new Error("Query too large for listener")));
3290
3249
  }
3291
3250
  const listenFor = options.events ? options.events : ["mutation"];
3292
3251
  const shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1;
@@ -3299,11 +3258,11 @@
3299
3258
  Authorization: "Bearer ".concat(token)
3300
3259
  };
3301
3260
  }
3302
- return new Observable(observer => {
3261
+ return new Observable((observer) => {
3303
3262
  let es;
3304
- getEventSource().then(eventSource => {
3263
+ getEventSource().then((eventSource) => {
3305
3264
  es = eventSource;
3306
- }).catch(reason => {
3265
+ }).catch((reason) => {
3307
3266
  observer.error(reason);
3308
3267
  stop();
3309
3268
  });
@@ -3336,35 +3295,32 @@
3336
3295
  observer.complete();
3337
3296
  }
3338
3297
  function unsubscribe() {
3339
- if (!es) return;
3298
+ if (!es)
3299
+ return;
3340
3300
  es.removeEventListener("error", onError);
3341
3301
  es.removeEventListener("channelError", onChannelError);
3342
3302
  es.removeEventListener("disconnect", onDisconnect);
3343
- listenFor.forEach(type => es.removeEventListener(type, onMessage));
3303
+ listenFor.forEach((type) => es.removeEventListener(type, onMessage));
3344
3304
  es.close();
3345
3305
  }
3346
3306
  function emitReconnect() {
3347
3307
  if (shouldEmitReconnect) {
3348
- observer.next({
3349
- type: "reconnect"
3350
- });
3308
+ observer.next({ type: "reconnect" });
3351
3309
  }
3352
3310
  }
3353
3311
  async function getEventSource() {
3354
- const {
3355
- default: EventSource
3356
- } = await Promise.resolve().then(function () { return browser$2; });
3312
+ const { default: EventSource } = await Promise.resolve().then(function () { return browser$2; });
3357
3313
  const evs = new EventSource(uri, esOptions);
3358
3314
  evs.addEventListener("error", onError);
3359
3315
  evs.addEventListener("channelError", onChannelError);
3360
3316
  evs.addEventListener("disconnect", onDisconnect);
3361
- listenFor.forEach(type => evs.addEventListener(type, onMessage));
3317
+ listenFor.forEach((type) => evs.addEventListener(type, onMessage));
3362
3318
  return evs;
3363
3319
  }
3364
3320
  function open() {
3365
- getEventSource().then(eventSource => {
3321
+ getEventSource().then((eventSource) => {
3366
3322
  es = eventSource;
3367
- }).catch(reason => {
3323
+ }).catch((reason) => {
3368
3324
  observer.error(reason);
3369
3325
  stop();
3370
3326
  });
@@ -3379,9 +3335,7 @@
3379
3335
  function parseEvent(event) {
3380
3336
  try {
3381
3337
  const data = event.data && JSON.parse(event.data) || {};
3382
- return Object.assign({
3383
- type: event.type
3384
- }, data);
3338
+ return Object.assign({ type: event.type }, data);
3385
3339
  } catch (err) {
3386
3340
  return err;
3387
3341
  }
@@ -3402,15 +3356,18 @@
3402
3356
  }
3403
3357
  return typeof err.error === "string" ? err.error : JSON.stringify(err.error, null, 2);
3404
3358
  }
3359
+
3405
3360
  var __accessCheck$3 = (obj, member, msg) => {
3406
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
3361
+ if (!member.has(obj))
3362
+ throw TypeError("Cannot " + msg);
3407
3363
  };
3408
3364
  var __privateGet$3 = (obj, member, getter) => {
3409
3365
  __accessCheck$3(obj, member, "read from private field");
3410
3366
  return getter ? getter.call(obj) : member.get(obj);
3411
3367
  };
3412
3368
  var __privateAdd$3 = (obj, member, value) => {
3413
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
3369
+ if (member.has(obj))
3370
+ throw TypeError("Cannot add the same private member more than once");
3414
3371
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3415
3372
  };
3416
3373
  var __privateSet$3 = (obj, member, value, setter) => {
@@ -3478,7 +3435,9 @@
3478
3435
  * @param options - Options for the dataset
3479
3436
  */
3480
3437
  create(name, options) {
3481
- return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name, options));
3438
+ return lastValueFrom(
3439
+ _modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name, options)
3440
+ );
3482
3441
  }
3483
3442
  /**
3484
3443
  * Edit a dataset with the given name
@@ -3487,7 +3446,9 @@
3487
3446
  * @param options - New options for the dataset
3488
3447
  */
3489
3448
  edit(name, options) {
3490
- return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name, options));
3449
+ return lastValueFrom(
3450
+ _modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name, options)
3451
+ );
3491
3452
  }
3492
3453
  /**
3493
3454
  * Delete a dataset with the given name
@@ -3501,10 +3462,9 @@
3501
3462
  * Fetch a list of datasets for the configured project
3502
3463
  */
3503
3464
  list() {
3504
- return lastValueFrom(_request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), {
3505
- uri: "/datasets",
3506
- tag: null
3507
- }));
3465
+ return lastValueFrom(
3466
+ _request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), { uri: "/datasets", tag: null })
3467
+ );
3508
3468
  }
3509
3469
  }
3510
3470
  _client2$2 = new WeakMap();
@@ -3518,15 +3478,18 @@
3518
3478
  tag: null
3519
3479
  });
3520
3480
  }
3481
+
3521
3482
  var __accessCheck$2 = (obj, member, msg) => {
3522
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
3483
+ if (!member.has(obj))
3484
+ throw TypeError("Cannot " + msg);
3523
3485
  };
3524
3486
  var __privateGet$2 = (obj, member, getter) => {
3525
3487
  __accessCheck$2(obj, member, "read from private field");
3526
3488
  return getter ? getter.call(obj) : member.get(obj);
3527
3489
  };
3528
3490
  var __privateAdd$2 = (obj, member, value) => {
3529
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
3491
+ if (member.has(obj))
3492
+ throw TypeError("Cannot add the same private member more than once");
3530
3493
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3531
3494
  };
3532
3495
  var __privateSet$2 = (obj, member, value, setter) => {
@@ -3544,9 +3507,7 @@
3544
3507
  }
3545
3508
  list(options) {
3546
3509
  const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
3547
- return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), {
3548
- uri
3549
- });
3510
+ return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri });
3550
3511
  }
3551
3512
  /**
3552
3513
  * Fetch a project by project ID
@@ -3554,9 +3515,7 @@
3554
3515
  * @param projectId - ID of the project to fetch
3555
3516
  */
3556
3517
  getById(projectId) {
3557
- return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), {
3558
- uri: "/projects/".concat(projectId)
3559
- });
3518
+ return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: "/projects/".concat(projectId) });
3560
3519
  }
3561
3520
  }
3562
3521
  _client$1 = new WeakMap();
@@ -3570,9 +3529,7 @@
3570
3529
  }
3571
3530
  list(options) {
3572
3531
  const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
3573
- return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), {
3574
- uri
3575
- }));
3532
+ return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri }));
3576
3533
  }
3577
3534
  /**
3578
3535
  * Fetch a project by project ID
@@ -3580,22 +3537,25 @@
3580
3537
  * @param projectId - ID of the project to fetch
3581
3538
  */
3582
3539
  getById(projectId) {
3583
- return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), {
3584
- uri: "/projects/".concat(projectId)
3585
- }));
3540
+ return lastValueFrom(
3541
+ _request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: "/projects/".concat(projectId) })
3542
+ );
3586
3543
  }
3587
3544
  }
3588
3545
  _client2$1 = new WeakMap();
3589
3546
  _httpRequest2$2 = new WeakMap();
3547
+
3590
3548
  var __accessCheck$1 = (obj, member, msg) => {
3591
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
3549
+ if (!member.has(obj))
3550
+ throw TypeError("Cannot " + msg);
3592
3551
  };
3593
3552
  var __privateGet$1 = (obj, member, getter) => {
3594
3553
  __accessCheck$1(obj, member, "read from private field");
3595
3554
  return getter ? getter.call(obj) : member.get(obj);
3596
3555
  };
3597
3556
  var __privateAdd$1 = (obj, member, value) => {
3598
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
3557
+ if (member.has(obj))
3558
+ throw TypeError("Cannot add the same private member more than once");
3599
3559
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3600
3560
  };
3601
3561
  var __privateSet$1 = (obj, member, value, setter) => {
@@ -3617,9 +3577,11 @@
3617
3577
  * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
3618
3578
  */
3619
3579
  getById(id) {
3620
- return _request(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), {
3621
- uri: "/users/".concat(id)
3622
- });
3580
+ return _request(
3581
+ __privateGet$1(this, _client),
3582
+ __privateGet$1(this, _httpRequest$1),
3583
+ { uri: "/users/".concat(id) }
3584
+ );
3623
3585
  }
3624
3586
  }
3625
3587
  _client = new WeakMap();
@@ -3637,22 +3599,27 @@
3637
3599
  * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
3638
3600
  */
3639
3601
  getById(id) {
3640
- return lastValueFrom(_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
3641
- uri: "/users/".concat(id)
3642
- }));
3602
+ return lastValueFrom(
3603
+ _request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
3604
+ uri: "/users/".concat(id)
3605
+ })
3606
+ );
3643
3607
  }
3644
3608
  }
3645
3609
  _client2 = new WeakMap();
3646
3610
  _httpRequest2$1 = new WeakMap();
3611
+
3647
3612
  var __accessCheck = (obj, member, msg) => {
3648
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
3613
+ if (!member.has(obj))
3614
+ throw TypeError("Cannot " + msg);
3649
3615
  };
3650
3616
  var __privateGet = (obj, member, getter) => {
3651
3617
  __accessCheck(obj, member, "read from private field");
3652
3618
  return getter ? getter.call(obj) : member.get(obj);
3653
3619
  };
3654
3620
  var __privateAdd = (obj, member, value) => {
3655
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
3621
+ if (member.has(obj))
3622
+ throw TypeError("Cannot add the same private member more than once");
3656
3623
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3657
3624
  };
3658
3625
  var __privateSet = (obj, member, value, setter) => {
@@ -3662,8 +3629,7 @@
3662
3629
  };
3663
3630
  var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
3664
3631
  const _ObservableSanityClient = class _ObservableSanityClient {
3665
- constructor(httpRequest) {
3666
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
3632
+ constructor(httpRequest, config = defaultConfig) {
3667
3633
  /**
3668
3634
  * Private properties
3669
3635
  */
@@ -3688,12 +3654,12 @@
3688
3654
  }
3689
3655
  config(newConfig) {
3690
3656
  if (newConfig === void 0) {
3691
- return {
3692
- ...__privateGet(this, _clientConfig)
3693
- };
3657
+ return { ...__privateGet(this, _clientConfig) };
3694
3658
  }
3695
3659
  if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === false) {
3696
- throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
3660
+ throw new Error(
3661
+ "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
3662
+ );
3697
3663
  }
3698
3664
  __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {}));
3699
3665
  return this;
@@ -3704,13 +3670,9 @@
3704
3670
  * @param newConfig - New client configuration properties, shallowly merged with existing configuration
3705
3671
  */
3706
3672
  withConfig(newConfig) {
3707
- return new _ObservableSanityClient(__privateGet(this, _httpRequest), {
3708
- ...this.config(),
3709
- ...newConfig
3710
- });
3673
+ return new _ObservableSanityClient(__privateGet(this, _httpRequest), { ...this.config(), ...newConfig });
3711
3674
  }
3712
- fetch(query, params) {
3713
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3675
+ fetch(query, params, options = {}) {
3714
3676
  return _fetch(this, __privateGet(this, _httpRequest), query, params, options);
3715
3677
  }
3716
3678
  /**
@@ -3798,8 +3760,7 @@
3798
3760
  _httpRequest = new WeakMap();
3799
3761
  let ObservableSanityClient = _ObservableSanityClient;
3800
3762
  const _SanityClient = class _SanityClient {
3801
- constructor(httpRequest) {
3802
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
3763
+ constructor(httpRequest, config = defaultConfig) {
3803
3764
  /**
3804
3765
  * Private properties
3805
3766
  */
@@ -3825,12 +3786,12 @@
3825
3786
  }
3826
3787
  config(newConfig) {
3827
3788
  if (newConfig === void 0) {
3828
- return {
3829
- ...__privateGet(this, _clientConfig2)
3830
- };
3789
+ return { ...__privateGet(this, _clientConfig2) };
3831
3790
  }
3832
3791
  if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
3833
- throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
3792
+ throw new Error(
3793
+ "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
3794
+ );
3834
3795
  }
3835
3796
  if (this.observable) {
3836
3797
  this.observable.config(newConfig);
@@ -3844,13 +3805,9 @@
3844
3805
  * @param newConfig - New client configuration properties, shallowly merged with existing configuration
3845
3806
  */
3846
3807
  withConfig(newConfig) {
3847
- return new _SanityClient(__privateGet(this, _httpRequest2), {
3848
- ...this.config(),
3849
- ...newConfig
3850
- });
3808
+ return new _SanityClient(__privateGet(this, _httpRequest2), { ...this.config(), ...newConfig });
3851
3809
  }
3852
- fetch(query, params) {
3853
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3810
+ fetch(query, params, options = {}) {
3854
3811
  return lastValueFrom(_fetch(this, __privateGet(this, _httpRequest2), query, params, options));
3855
3812
  }
3856
3813
  /**
@@ -3875,13 +3832,19 @@
3875
3832
  return lastValueFrom(_getDocuments(this, __privateGet(this, _httpRequest2), ids, options));
3876
3833
  }
3877
3834
  create(document, options) {
3878
- return lastValueFrom(_create(this, __privateGet(this, _httpRequest2), document, "create", options));
3835
+ return lastValueFrom(
3836
+ _create(this, __privateGet(this, _httpRequest2), document, "create", options)
3837
+ );
3879
3838
  }
3880
3839
  createIfNotExists(document, options) {
3881
- return lastValueFrom(_createIfNotExists(this, __privateGet(this, _httpRequest2), document, options));
3840
+ return lastValueFrom(
3841
+ _createIfNotExists(this, __privateGet(this, _httpRequest2), document, options)
3842
+ );
3882
3843
  }
3883
3844
  createOrReplace(document, options) {
3884
- return lastValueFrom(_createOrReplace(this, __privateGet(this, _httpRequest2), document, options));
3845
+ return lastValueFrom(
3846
+ _createOrReplace(this, __privateGet(this, _httpRequest2), document, options)
3847
+ );
3885
3848
  }
3886
3849
  delete(selection, options) {
3887
3850
  return lastValueFrom(_delete(this, __privateGet(this, _httpRequest2), selection, options));
@@ -3952,18 +3915,20 @@
3952
3915
  _clientConfig2 = new WeakMap();
3953
3916
  _httpRequest2 = new WeakMap();
3954
3917
  let SanityClient = _SanityClient;
3918
+
3955
3919
  function defineCreateClientExports(envMiddleware, ClassConstructor) {
3956
3920
  const httpRequest = defineHttpRequest(envMiddleware, {});
3957
3921
  const requester = httpRequest.defaultRequester;
3958
- const createClient = config => new ClassConstructor(defineHttpRequest(envMiddleware, {
3959
- maxRetries: config.maxRetries,
3960
- retryDelay: config.retryDelay
3961
- }), config);
3962
- return {
3963
- requester,
3964
- createClient
3965
- };
3922
+ const createClient = (config) => new ClassConstructor(
3923
+ defineHttpRequest(envMiddleware, {
3924
+ maxRetries: config.maxRetries,
3925
+ retryDelay: config.retryDelay
3926
+ }),
3927
+ config
3928
+ );
3929
+ return { requester, createClient };
3966
3930
  }
3931
+
3967
3932
  var envMiddleware = [];
3968
3933
 
3969
3934
  function defineDeprecatedCreateClient(createClient) {
@@ -3972,6 +3937,7 @@
3972
3937
  return createClient(config);
3973
3938
  };
3974
3939
  }
3940
+
3975
3941
  const exp = defineCreateClientExports(envMiddleware, SanityClient);
3976
3942
  const requester = exp.requester;
3977
3943
  const createClient = exp.createClient;