@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
@@ -2,6 +2,7 @@ import { getIt } from 'get-it';
2
2
  import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } from 'get-it/middleware';
3
3
  import { Observable, lastValueFrom } from 'rxjs';
4
4
  import { map, filter } from 'rxjs/operators';
5
+
5
6
  const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
6
7
  class ClientError extends Error {
7
8
  constructor(res) {
@@ -34,7 +35,7 @@ function extractErrorProps(res) {
34
35
  }
35
36
  if (isMutationError(body)) {
36
37
  const allItems = body.error.items || [];
37
- const items = allItems.slice(0, MAX_ITEMS_IN_ERROR_MESSAGE).map(item => {
38
+ const items = allItems.slice(0, MAX_ITEMS_IN_ERROR_MESSAGE).map((item) => {
38
39
  var _a;
39
40
  return (_a = item.error) == null ? void 0 : _a.description;
40
41
  }).filter(Boolean);
@@ -69,8 +70,9 @@ function stringifyBody(body, res) {
69
70
  const isJson = contentType.indexOf("application/json") !== -1;
70
71
  return isJson ? JSON.stringify(body, null, 2) : body;
71
72
  }
73
+
72
74
  const httpError = {
73
- onResponse: res => {
75
+ onResponse: (res) => {
74
76
  if (res.statusCode >= 500) {
75
77
  throw new ServerError(res);
76
78
  } else if (res.statusCode >= 400) {
@@ -80,33 +82,35 @@ const httpError = {
80
82
  }
81
83
  };
82
84
  const printWarnings = {
83
- onResponse: res => {
85
+ onResponse: (res) => {
84
86
  const warn = res.headers["x-sanity-warning"];
85
87
  const warnings = Array.isArray(warn) ? warn : [warn];
86
- warnings.filter(Boolean).forEach(msg => console.warn(msg));
88
+ warnings.filter(Boolean).forEach((msg) => console.warn(msg));
87
89
  return res;
88
90
  }
89
91
  };
90
- function defineHttpRequest(envMiddleware, _ref) {
91
- let {
92
- maxRetries = 5,
93
- retryDelay
94
- } = _ref;
95
- const request = getIt([maxRetries > 0 ? retry({
96
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
- retryDelay,
98
- // This option is typed incorrectly in get-it.
99
- maxRetries,
100
- shouldRetry
101
- }) : {}, ...envMiddleware, printWarnings, jsonRequest(), jsonResponse(), progress(), httpError, observable({
102
- implementation: Observable
103
- })]);
104
- function httpRequest(options) {
105
- let requester = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : request;
106
- return requester({
107
- maxRedirects: 0,
108
- ...options
109
- });
92
+ function defineHttpRequest(envMiddleware, {
93
+ maxRetries = 5,
94
+ retryDelay
95
+ }) {
96
+ const request = getIt([
97
+ maxRetries > 0 ? retry({
98
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
+ retryDelay,
100
+ // This option is typed incorrectly in get-it.
101
+ maxRetries,
102
+ shouldRetry
103
+ }) : {},
104
+ ...envMiddleware,
105
+ printWarnings,
106
+ jsonRequest(),
107
+ jsonResponse(),
108
+ progress(),
109
+ httpError,
110
+ observable({ implementation: Observable })
111
+ ]);
112
+ function httpRequest(options, requester = request) {
113
+ return requester({ maxRedirects: 0, ...options });
110
114
  }
111
115
  httpRequest.defaultRequester = request;
112
116
  return httpRequest;
@@ -116,39 +120,41 @@ function shouldRetry(err, attempt, options) {
116
120
  const uri = options.uri || options.url;
117
121
  const isQuery = uri.startsWith("/data/query");
118
122
  const isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
119
- if ((isSafe || isQuery) && isRetriableResponse) return true;
123
+ if ((isSafe || isQuery) && isRetriableResponse)
124
+ return true;
120
125
  return retry.shouldRetry(err, attempt, options);
121
126
  }
127
+
122
128
  function getSelection(sel) {
123
129
  if (typeof sel === "string" || Array.isArray(sel)) {
124
- return {
125
- id: sel
126
- };
130
+ return { id: sel };
127
131
  }
128
132
  if (typeof sel === "object" && sel !== null && "query" in sel && typeof sel.query === "string") {
129
- return "params" in sel && typeof sel.params === "object" && sel.params !== null ? {
130
- query: sel.query,
131
- params: sel.params
132
- } : {
133
- query: sel.query
134
- };
133
+ return "params" in sel && typeof sel.params === "object" && sel.params !== null ? { query: sel.query, params: sel.params } : { query: sel.query };
135
134
  }
136
- const selectionOpts = ["* Document ID (<docId>)", "* Array of document IDs", "* Object containing `query`"].join("\n");
135
+ const selectionOpts = [
136
+ "* Document ID (<docId>)",
137
+ "* Array of document IDs",
138
+ "* Object containing `query`"
139
+ ].join("\n");
137
140
  throw new Error("Unknown selection - must be one of:\n\n".concat(selectionOpts));
138
141
  }
142
+
139
143
  const VALID_ASSET_TYPES = ["image", "file"];
140
144
  const VALID_INSERT_LOCATIONS = ["before", "after", "replace"];
141
- const dataset = name => {
145
+ const dataset = (name) => {
142
146
  if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name)) {
143
- throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters");
147
+ throw new Error(
148
+ "Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters"
149
+ );
144
150
  }
145
151
  };
146
- const projectId = id => {
152
+ const projectId = (id) => {
147
153
  if (!/^[-a-z0-9]+$/i.test(id)) {
148
154
  throw new Error("`projectId` can only contain only a-z, 0-9 and dashes");
149
155
  }
150
156
  };
151
- const validateAssetType = type => {
157
+ const validateAssetType = (type) => {
152
158
  if (VALID_ASSET_TYPES.indexOf(type) === -1) {
153
159
  throw new Error("Invalid asset type: ".concat(type, ". Must be one of ").concat(VALID_ASSET_TYPES.join(", ")));
154
160
  }
@@ -172,7 +178,7 @@ const requireDocumentId = (op, doc) => {
172
178
  const validateInsert = (at, selector, items) => {
173
179
  const signature = "insert(at, selector, items)";
174
180
  if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {
175
- const valid = VALID_INSERT_LOCATIONS.map(loc => '"'.concat(loc, '"')).join(", ");
181
+ const valid = VALID_INSERT_LOCATIONS.map((loc) => '"'.concat(loc, '"')).join(", ");
176
182
  throw new Error("".concat(signature, ' takes an "at"-argument which is one of: ').concat(valid));
177
183
  }
178
184
  if (typeof selector !== "string") {
@@ -182,27 +188,32 @@ const validateInsert = (at, selector, items) => {
182
188
  throw new Error("".concat(signature, ' takes an "items"-argument which must be an array'));
183
189
  }
184
190
  };
185
- const hasDataset = config => {
191
+ const hasDataset = (config) => {
186
192
  if (!config.dataset) {
187
193
  throw new Error("`dataset` must be provided to perform queries");
188
194
  }
189
195
  return config.dataset || "";
190
196
  };
191
- const requestTag = tag => {
197
+ const requestTag = (tag) => {
192
198
  if (typeof tag !== "string" || !/^[a-z0-9._-]{1,75}$/i.test(tag)) {
193
- throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");
199
+ throw new Error(
200
+ "Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long."
201
+ );
194
202
  }
195
203
  return tag;
196
204
  };
205
+
197
206
  var __accessCheck$6 = (obj, member, msg) => {
198
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
207
+ if (!member.has(obj))
208
+ throw TypeError("Cannot " + msg);
199
209
  };
200
210
  var __privateGet$6 = (obj, member, getter) => {
201
211
  __accessCheck$6(obj, member, "read from private field");
202
212
  return getter ? getter.call(obj) : member.get(obj);
203
213
  };
204
214
  var __privateAdd$6 = (obj, member, value) => {
205
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
215
+ if (member.has(obj))
216
+ throw TypeError("Cannot add the same private member more than once");
206
217
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
207
218
  };
208
219
  var __privateSet$6 = (obj, member, value, setter) => {
@@ -212,8 +223,7 @@ var __privateSet$6 = (obj, member, value, setter) => {
212
223
  };
213
224
  var _client$5, _client2$5;
214
225
  class BasePatch {
215
- constructor(selection) {
216
- let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
226
+ constructor(selection, operations = {}) {
217
227
  this.selection = selection;
218
228
  this.operations = operations;
219
229
  }
@@ -255,9 +265,7 @@ class BasePatch {
255
265
  if (!Array.isArray(attrs)) {
256
266
  throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");
257
267
  }
258
- this.operations = Object.assign({}, this.operations, {
259
- unset: attrs
260
- });
268
+ this.operations = Object.assign({}, this.operations, { unset: attrs });
261
269
  return this;
262
270
  }
263
271
  /**
@@ -285,10 +293,7 @@ class BasePatch {
285
293
  */
286
294
  insert(at, selector, items) {
287
295
  validateInsert(at, selector, items);
288
- return this._assign("insert", {
289
- [at]: selector,
290
- items
291
- });
296
+ return this._assign("insert", { [at]: selector, items });
292
297
  }
293
298
  /**
294
299
  * Append the given items to the array at the given JSONPath
@@ -337,10 +342,7 @@ class BasePatch {
337
342
  * Return a plain JSON representation of the patch
338
343
  */
339
344
  serialize() {
340
- return {
341
- ...getSelection(this.selection),
342
- ...this.operations
343
- };
345
+ return { ...getSelection(this.selection), ...this.operations };
344
346
  }
345
347
  /**
346
348
  * Return a plain JSON representation of the patch
@@ -355,8 +357,7 @@ class BasePatch {
355
357
  this.operations = {};
356
358
  return this;
357
359
  }
358
- _assign(op, props) {
359
- let merge = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
360
+ _assign(op, props, merge = true) {
360
361
  validateObject(op, props);
361
362
  this.operations = Object.assign({}, this.operations, {
362
363
  [op]: Object.assign({}, merge && this.operations[op] || {}, props)
@@ -377,22 +378,17 @@ const _ObservablePatch = class _ObservablePatch extends BasePatch {
377
378
  * Clones the patch
378
379
  */
379
380
  clone() {
380
- return new _ObservablePatch(this.selection, {
381
- ...this.operations
382
- }, __privateGet$6(this, _client$5));
381
+ return new _ObservablePatch(this.selection, { ...this.operations }, __privateGet$6(this, _client$5));
383
382
  }
384
383
  commit(options) {
385
384
  if (!__privateGet$6(this, _client$5)) {
386
- throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
385
+ throw new Error(
386
+ "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
387
+ );
387
388
  }
388
389
  const returnFirst = typeof this.selection === "string";
389
- const opts = Object.assign({
390
- returnFirst,
391
- returnDocuments: true
392
- }, options);
393
- return __privateGet$6(this, _client$5).mutate({
394
- patch: this.serialize()
395
- }, opts);
390
+ const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
391
+ return __privateGet$6(this, _client$5).mutate({ patch: this.serialize() }, opts);
396
392
  }
397
393
  };
398
394
  _client$5 = new WeakMap();
@@ -407,35 +403,33 @@ const _Patch = class _Patch extends BasePatch {
407
403
  * Clones the patch
408
404
  */
409
405
  clone() {
410
- return new _Patch(this.selection, {
411
- ...this.operations
412
- }, __privateGet$6(this, _client2$5));
406
+ return new _Patch(this.selection, { ...this.operations }, __privateGet$6(this, _client2$5));
413
407
  }
414
408
  commit(options) {
415
409
  if (!__privateGet$6(this, _client2$5)) {
416
- throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
410
+ throw new Error(
411
+ "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
412
+ );
417
413
  }
418
414
  const returnFirst = typeof this.selection === "string";
419
- const opts = Object.assign({
420
- returnFirst,
421
- returnDocuments: true
422
- }, options);
423
- return __privateGet$6(this, _client2$5).mutate({
424
- patch: this.serialize()
425
- }, opts);
415
+ const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
416
+ return __privateGet$6(this, _client2$5).mutate({ patch: this.serialize() }, opts);
426
417
  }
427
418
  };
428
419
  _client2$5 = new WeakMap();
429
420
  let Patch = _Patch;
421
+
430
422
  var __accessCheck$5 = (obj, member, msg) => {
431
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
423
+ if (!member.has(obj))
424
+ throw TypeError("Cannot " + msg);
432
425
  };
433
426
  var __privateGet$5 = (obj, member, getter) => {
434
427
  __accessCheck$5(obj, member, "read from private field");
435
428
  return getter ? getter.call(obj) : member.get(obj);
436
429
  };
437
430
  var __privateAdd$5 = (obj, member, value) => {
438
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
431
+ if (member.has(obj))
432
+ throw TypeError("Cannot add the same private member more than once");
439
433
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
440
434
  };
441
435
  var __privateSet$5 = (obj, member, value, setter) => {
@@ -444,13 +438,9 @@ var __privateSet$5 = (obj, member, value, setter) => {
444
438
  return value;
445
439
  };
446
440
  var _client$4, _client2$4;
447
- const defaultMutateOptions = {
448
- returnDocuments: false
449
- };
441
+ const defaultMutateOptions = { returnDocuments: false };
450
442
  class BaseTransaction {
451
- constructor() {
452
- let operations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
453
- let transactionId = arguments.length > 1 ? arguments[1] : undefined;
443
+ constructor(operations = [], transactionId) {
454
444
  this.operations = operations;
455
445
  this.trxId = transactionId;
456
446
  }
@@ -462,9 +452,7 @@ class BaseTransaction {
462
452
  */
463
453
  create(doc) {
464
454
  validateObject("create", doc);
465
- return this._add({
466
- create: doc
467
- });
455
+ return this._add({ create: doc });
468
456
  }
469
457
  /**
470
458
  * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
@@ -476,9 +464,7 @@ class BaseTransaction {
476
464
  const op = "createIfNotExists";
477
465
  validateObject(op, doc);
478
466
  requireDocumentId(op, doc);
479
- return this._add({
480
- [op]: doc
481
- });
467
+ return this._add({ [op]: doc });
482
468
  }
483
469
  /**
484
470
  * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.
@@ -490,9 +476,7 @@ class BaseTransaction {
490
476
  const op = "createOrReplace";
491
477
  validateObject(op, doc);
492
478
  requireDocumentId(op, doc);
493
- return this._add({
494
- [op]: doc
495
- });
479
+ return this._add({ [op]: doc });
496
480
  }
497
481
  /**
498
482
  * Deletes the document with the given document ID
@@ -502,11 +486,7 @@ class BaseTransaction {
502
486
  */
503
487
  delete(documentId) {
504
488
  validateDocumentId("delete", documentId);
505
- return this._add({
506
- delete: {
507
- id: documentId
508
- }
509
- });
489
+ return this._add({ delete: { id: documentId } });
510
490
  }
511
491
  transactionId(id) {
512
492
  if (!id) {
@@ -553,35 +533,29 @@ const _Transaction = class _Transaction extends BaseTransaction {
553
533
  }
554
534
  commit(options) {
555
535
  if (!__privateGet$5(this, _client$4)) {
556
- throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
536
+ throw new Error(
537
+ "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
538
+ );
557
539
  }
558
- return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
559
- transactionId: this.trxId
560
- }, defaultMutateOptions, options || {}));
540
+ return __privateGet$5(this, _client$4).mutate(
541
+ this.serialize(),
542
+ Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
543
+ );
561
544
  }
562
545
  patch(patchOrDocumentId, patchOps) {
563
546
  const isBuilder = typeof patchOps === "function";
564
547
  const isPatch = typeof patchOrDocumentId !== "string" && patchOrDocumentId instanceof Patch;
565
548
  if (isPatch) {
566
- return this._add({
567
- patch: patchOrDocumentId.serialize()
568
- });
549
+ return this._add({ patch: patchOrDocumentId.serialize() });
569
550
  }
570
551
  if (isBuilder) {
571
552
  const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
572
553
  if (!(patch instanceof Patch)) {
573
554
  throw new Error("function passed to `patch()` must return the patch");
574
555
  }
575
- return this._add({
576
- patch: patch.serialize()
577
- });
556
+ return this._add({ patch: patch.serialize() });
578
557
  }
579
- return this._add({
580
- patch: {
581
- id: patchOrDocumentId,
582
- ...patchOps
583
- }
584
- });
558
+ return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
585
559
  }
586
560
  };
587
561
  _client$4 = new WeakMap();
@@ -600,68 +574,79 @@ const _ObservableTransaction = class _ObservableTransaction extends BaseTransact
600
574
  }
601
575
  commit(options) {
602
576
  if (!__privateGet$5(this, _client2$4)) {
603
- throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
577
+ throw new Error(
578
+ "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
579
+ );
604
580
  }
605
- return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
606
- transactionId: this.trxId
607
- }, defaultMutateOptions, options || {}));
581
+ return __privateGet$5(this, _client2$4).mutate(
582
+ this.serialize(),
583
+ Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
584
+ );
608
585
  }
609
586
  patch(patchOrDocumentId, patchOps) {
610
587
  const isBuilder = typeof patchOps === "function";
611
588
  const isPatch = typeof patchOrDocumentId !== "string" && patchOrDocumentId instanceof ObservablePatch;
612
589
  if (isPatch) {
613
- return this._add({
614
- patch: patchOrDocumentId.serialize()
615
- });
590
+ return this._add({ patch: patchOrDocumentId.serialize() });
616
591
  }
617
592
  if (isBuilder) {
618
593
  const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
619
594
  if (!(patch instanceof ObservablePatch)) {
620
595
  throw new Error("function passed to `patch()` must return the patch");
621
596
  }
622
- return this._add({
623
- patch: patch.serialize()
624
- });
597
+ return this._add({ patch: patch.serialize() });
625
598
  }
626
- return this._add({
627
- patch: {
628
- id: patchOrDocumentId,
629
- ...patchOps
630
- }
631
- });
599
+ return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
632
600
  }
633
601
  };
634
602
  _client2$4 = new WeakMap();
635
603
  let ObservableTransaction = _ObservableTransaction;
604
+
636
605
  const BASE_URL = "https://www.sanity.io/help/";
637
606
  function generateHelpUrl(slug) {
638
607
  return BASE_URL + slug;
639
608
  }
609
+
640
610
  function once(fn) {
641
611
  let didCall = false;
642
612
  let returnValue;
643
- return function () {
613
+ return (...args) => {
644
614
  if (didCall) {
645
615
  return returnValue;
646
616
  }
647
- returnValue = fn(...arguments);
617
+ returnValue = fn(...args);
648
618
  didCall = true;
649
619
  return returnValue;
650
620
  };
651
621
  }
652
- const createWarningPrinter = message =>
653
- // eslint-disable-next-line no-console
654
- once(function () {
655
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
656
- args[_key] = arguments[_key];
657
- }
658
- return console.warn(message.join(" "), ...args);
659
- });
660
- 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."]);
661
- 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."]);
662
- 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.")]);
663
- const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
664
- const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]);
622
+
623
+ const createWarningPrinter = (message) => (
624
+ // eslint-disable-next-line no-console
625
+ once((...args) => console.warn(message.join(" "), ...args))
626
+ );
627
+ const printCdnWarning = createWarningPrinter([
628
+ "Since you haven't set a value for `useCdn`, we will deliver content using our",
629
+ "global, edge-cached API-CDN. If you wish to have content delivered faster, set",
630
+ "`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."
631
+ ]);
632
+ const printCdnPreviewDraftsWarning = createWarningPrinter([
633
+ "The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.",
634
+ "The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."
635
+ ]);
636
+ const printBrowserTokenWarning = createWarningPrinter([
637
+ "You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
638
+ "See ".concat(generateHelpUrl(
639
+ "js-client-browser-token"
640
+ ), " for more information and how to hide this warning.")
641
+ ]);
642
+ const printNoApiVersionSpecifiedWarning = createWarningPrinter([
643
+ "Using the Sanity client without specifying an API version is deprecated.",
644
+ "See ".concat(generateHelpUrl("js-client-api-version"))
645
+ ]);
646
+ const printNoDefaultExport = createWarningPrinter([
647
+ "The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."
648
+ ]);
649
+
665
650
  const defaultCdnHost = "apicdn.sanity.io";
666
651
  const defaultConfig = {
667
652
  apiHost: "https://api.sanity.io",
@@ -669,7 +654,7 @@ const defaultConfig = {
669
654
  useProjectHostname: true
670
655
  };
671
656
  const LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"];
672
- const isLocal = host => LOCALHOSTS.indexOf(host) !== -1;
657
+ const isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
673
658
  const validateApiVersion = function validateApiVersion2(apiVersion) {
674
659
  if (apiVersion === "1" || apiVersion === "X") {
675
660
  return;
@@ -687,7 +672,9 @@ const validateApiPerspective = function validateApiPerspective2(perspective) {
687
672
  case "raw":
688
673
  return;
689
674
  default:
690
- throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`");
675
+ throw new TypeError(
676
+ "Invalid API perspective string, expected `published`, `previewDrafts` or `raw`"
677
+ );
691
678
  }
692
679
  };
693
680
  const initConfig = (config, prevConfig) => {
@@ -708,10 +695,14 @@ const initConfig = (config, prevConfig) => {
708
695
  validateApiPerspective(newConfig.perspective);
709
696
  }
710
697
  if ("encodeSourceMapAtPath" in newConfig || "encodeSourceMap" in newConfig || "studioUrl" in newConfig || "logger" in newConfig) {
711
- 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.");
698
+ throw new Error(
699
+ "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."
700
+ );
712
701
  }
713
702
  if ("stega" in newConfig && newConfig["stega"] !== void 0 && newConfig["stega"] !== false) {
714
- 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'.");
703
+ throw new Error(
704
+ "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'."
705
+ );
715
706
  }
716
707
  const isBrowser = typeof window !== "undefined" && window.location && window.location.hostname;
717
708
  const isLocalhost = isBrowser && isLocal(window.location.hostname);
@@ -746,9 +737,9 @@ const initConfig = (config, prevConfig) => {
746
737
  }
747
738
  return newConfig;
748
739
  };
740
+
749
741
  const projectHeader = "X-Sanity-Project-ID";
750
- function requestOptions(config) {
751
- let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
742
+ function requestOptions(config, overrides = {}) {
752
743
  const headers = {};
753
744
  const token = overrides.token || config.token;
754
745
  if (token) {
@@ -757,7 +748,9 @@ function requestOptions(config) {
757
748
  if (!overrides.useGlobalApi && !config.useProjectHostname && config.projectId) {
758
749
  headers[projectHeader] = config.projectId;
759
750
  }
760
- const withCredentials = Boolean(typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials);
751
+ const withCredentials = Boolean(
752
+ typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials
753
+ );
761
754
  const timeout = typeof overrides.timeout === "undefined" ? config.timeout : overrides.timeout;
762
755
  return Object.assign({}, overrides, {
763
756
  headers: Object.assign({}, headers, overrides.headers || {}),
@@ -765,39 +758,35 @@ function requestOptions(config) {
765
758
  proxy: overrides.proxy || config.proxy,
766
759
  json: true,
767
760
  withCredentials,
768
- fetch: typeof overrides.fetch === "object" && typeof config.fetch === "object" ? {
769
- ...config.fetch,
770
- ...overrides.fetch
771
- } : overrides.fetch || config.fetch
761
+ fetch: typeof overrides.fetch === "object" && typeof config.fetch === "object" ? { ...config.fetch, ...overrides.fetch } : overrides.fetch || config.fetch
772
762
  });
773
763
  }
774
- const encodeQueryString = _ref2 => {
775
- let {
776
- query,
777
- params = {},
778
- options = {}
779
- } = _ref2;
764
+
765
+ const encodeQueryString = ({
766
+ query,
767
+ params = {},
768
+ options = {}
769
+ }) => {
780
770
  const searchParams = new URLSearchParams();
781
- const {
782
- tag,
783
- ...opts
784
- } = options;
785
- if (tag) searchParams.append("tag", tag);
771
+ const { tag, ...opts } = options;
772
+ if (tag)
773
+ searchParams.append("tag", tag);
786
774
  searchParams.append("query", query);
787
775
  for (const [key, value] of Object.entries(params)) {
788
776
  searchParams.append("$".concat(key), JSON.stringify(value));
789
777
  }
790
778
  for (const [key, value] of Object.entries(opts)) {
791
- if (value) searchParams.append(key, "".concat(value));
779
+ if (value)
780
+ searchParams.append(key, "".concat(value));
792
781
  }
793
782
  return "?".concat(searchParams);
794
783
  };
784
+
795
785
  const excludeFalsey = (param, defValue) => {
796
786
  const value = typeof param === "undefined" ? defValue : param;
797
787
  return param === false ? void 0 : value;
798
788
  };
799
- const getMutationQuery = function () {
800
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
789
+ const getMutationQuery = (options = {}) => {
801
790
  return {
802
791
  dryRun: options.dryRun,
803
792
  returnIds: true,
@@ -807,61 +796,45 @@ const getMutationQuery = function () {
807
796
  skipCrossDatasetReferenceValidation: options.skipCrossDatasetReferenceValidation
808
797
  };
809
798
  };
810
- const isResponse = event => event.type === "response";
811
- const getBody = event => event.body;
799
+ const isResponse = (event) => event.type === "response";
800
+ const getBody = (event) => event.body;
812
801
  const indexBy = (docs, attr) => docs.reduce((indexed, doc) => {
813
802
  indexed[attr(doc)] = doc;
814
803
  return indexed;
815
- }, /* @__PURE__ */Object.create(null));
804
+ }, /* @__PURE__ */ Object.create(null));
816
805
  const getQuerySizeLimit = 11264;
817
- function _fetch(client, httpRequest, query, params) {
818
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
806
+ function _fetch(client, httpRequest, query, params, options = {}) {
819
807
  if ("stega" in options && options["stega"] !== void 0 && options["stega"] !== false) {
820
- 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'.");
821
- }
822
- const mapResponse = options.filterResponse === false ? res => res : res => res.result;
823
- const {
824
- cache,
825
- next,
826
- ...opts
827
- } = {
808
+ throw new Error(
809
+ "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'."
810
+ );
811
+ }
812
+ const mapResponse = options.filterResponse === false ? (res) => res : (res) => res.result;
813
+ const { cache, next, ...opts } = {
828
814
  // Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
829
815
  // This is necessary in React Server Components to avoid opting out of Request Memoization.
830
816
  useAbortSignal: typeof options.signal !== "undefined",
831
817
  ...options
832
818
  };
833
- const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? {
834
- ...opts,
835
- fetch: {
836
- cache,
837
- next
838
- }
839
- } : opts;
840
- return _dataRequest(client, httpRequest, "query", {
841
- query,
842
- params
843
- }, reqOpts).pipe(map(mapResponse));
819
+ const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? { ...opts, fetch: { cache, next } } : opts;
820
+ return _dataRequest(client, httpRequest, "query", { query, params }, reqOpts).pipe(map(mapResponse));
844
821
  }
845
- function _getDocument(client, httpRequest, id) {
846
- let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
847
- const options = {
848
- uri: _getDataUrl(client, "doc", id),
849
- json: true,
850
- tag: opts.tag
851
- };
852
- return _requestObservable(client, httpRequest, options).pipe(filter(isResponse), map(event => event.body.documents && event.body.documents[0]));
822
+ function _getDocument(client, httpRequest, id, opts = {}) {
823
+ const options = { uri: _getDataUrl(client, "doc", id), json: true, tag: opts.tag };
824
+ return _requestObservable(client, httpRequest, options).pipe(
825
+ filter(isResponse),
826
+ map((event) => event.body.documents && event.body.documents[0])
827
+ );
853
828
  }
854
- function _getDocuments(client, httpRequest, ids) {
855
- let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
856
- const options = {
857
- uri: _getDataUrl(client, "doc", ids.join(",")),
858
- json: true,
859
- tag: opts.tag
860
- };
861
- return _requestObservable(client, httpRequest, options).pipe(filter(isResponse), map(event => {
862
- const indexed = indexBy(event.body.documents || [], doc => doc._id);
863
- return ids.map(id => indexed[id] || null);
864
- }));
829
+ function _getDocuments(client, httpRequest, ids, opts = {}) {
830
+ const options = { uri: _getDataUrl(client, "doc", ids.join(",")), json: true, tag: opts.tag };
831
+ return _requestObservable(client, httpRequest, options).pipe(
832
+ filter(isResponse),
833
+ map((event) => {
834
+ const indexed = indexBy(event.body.documents || [], (doc) => doc._id);
835
+ return ids.map((id) => indexed[id] || null);
836
+ })
837
+ );
865
838
  }
866
839
  function _createIfNotExists(client, httpRequest, doc, options) {
867
840
  requireDocumentId("createIfNotExists", doc);
@@ -872,18 +845,18 @@ function _createOrReplace(client, httpRequest, doc, options) {
872
845
  return _create(client, httpRequest, doc, "createOrReplace", options);
873
846
  }
874
847
  function _delete(client, httpRequest, selection, options) {
875
- return _dataRequest(client, httpRequest, "mutate", {
876
- mutations: [{
877
- delete: getSelection(selection)
878
- }]
879
- }, options);
848
+ return _dataRequest(
849
+ client,
850
+ httpRequest,
851
+ "mutate",
852
+ { mutations: [{ delete: getSelection(selection) }] },
853
+ options
854
+ );
880
855
  }
881
856
  function _mutate(client, httpRequest, mutations, options) {
882
857
  let mut;
883
858
  if (mutations instanceof Patch || mutations instanceof ObservablePatch) {
884
- mut = {
885
- patch: mutations.serialize()
886
- };
859
+ mut = { patch: mutations.serialize() };
887
860
  } else if (mutations instanceof Transaction || mutations instanceof ObservableTransaction) {
888
861
  mut = mutations.serialize();
889
862
  } else {
@@ -891,25 +864,16 @@ function _mutate(client, httpRequest, mutations, options) {
891
864
  }
892
865
  const muts = Array.isArray(mut) ? mut : [mut];
893
866
  const transactionId = options && options.transactionId || void 0;
894
- return _dataRequest(client, httpRequest, "mutate", {
895
- mutations: muts,
896
- transactionId
897
- }, options);
867
+ return _dataRequest(client, httpRequest, "mutate", { mutations: muts, transactionId }, options);
898
868
  }
899
- function _dataRequest(client, httpRequest, endpoint, body) {
900
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
869
+ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
901
870
  const isMutation = endpoint === "mutate";
902
871
  const isQuery = endpoint === "query";
903
872
  const strQuery = isMutation ? "" : encodeQueryString(body);
904
873
  const useGet = !isMutation && strQuery.length < getQuerySizeLimit;
905
874
  const stringQuery = useGet ? strQuery : "";
906
875
  const returnFirst = options.returnFirst;
907
- const {
908
- timeout,
909
- token,
910
- tag,
911
- headers
912
- } = options;
876
+ const { timeout, token, tag, headers } = options;
913
877
  const uri = _getDataUrl(client, endpoint, stringQuery);
914
878
  const reqOptions = {
915
879
  method: useGet ? "GET" : "POST",
@@ -929,35 +893,31 @@ function _dataRequest(client, httpRequest, endpoint, body) {
929
893
  useAbortSignal: options.useAbortSignal,
930
894
  useCdn: options.useCdn
931
895
  };
932
- return _requestObservable(client, httpRequest, reqOptions).pipe(filter(isResponse), map(getBody), map(res => {
933
- if (!isMutation) {
934
- return res;
935
- }
936
- const results = res.results || [];
937
- if (options.returnDocuments) {
938
- return returnFirst ? results[0] && results[0].document : results.map(mut => mut.document);
939
- }
940
- const key = returnFirst ? "documentId" : "documentIds";
941
- const ids = returnFirst ? results[0] && results[0].id : results.map(mut => mut.id);
942
- return {
943
- transactionId: res.transactionId,
944
- results,
945
- [key]: ids
946
- };
947
- }));
896
+ return _requestObservable(client, httpRequest, reqOptions).pipe(
897
+ filter(isResponse),
898
+ map(getBody),
899
+ map((res) => {
900
+ if (!isMutation) {
901
+ return res;
902
+ }
903
+ const results = res.results || [];
904
+ if (options.returnDocuments) {
905
+ return returnFirst ? results[0] && results[0].document : results.map((mut) => mut.document);
906
+ }
907
+ const key = returnFirst ? "documentId" : "documentIds";
908
+ const ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
909
+ return {
910
+ transactionId: res.transactionId,
911
+ results,
912
+ [key]: ids
913
+ };
914
+ })
915
+ );
948
916
  }
949
- function _create(client, httpRequest, doc, op) {
950
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
951
- const mutation = {
952
- [op]: doc
953
- };
954
- const opts = Object.assign({
955
- returnFirst: true,
956
- returnDocuments: true
957
- }, options);
958
- return _dataRequest(client, httpRequest, "mutate", {
959
- mutations: [mutation]
960
- }, opts);
917
+ function _create(client, httpRequest, doc, op, options = {}) {
918
+ const mutation = { [op]: doc };
919
+ const opts = Object.assign({ returnFirst: true, returnDocuments: true }, options);
920
+ return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
961
921
  }
962
922
  function _requestObservable(client, httpRequest, options) {
963
923
  var _a, _b;
@@ -967,40 +927,39 @@ function _requestObservable(client, httpRequest, options) {
967
927
  let useCdn = ((_a = options.useCdn) != null ? _a : config.useCdn) && canUseCdn;
968
928
  const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
969
929
  if (tag && options.tag !== null) {
970
- options.query = {
971
- tag: requestTag(tag),
972
- ...options.query
973
- };
930
+ options.query = { tag: requestTag(tag), ...options.query };
974
931
  }
975
932
  if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
976
933
  const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
977
934
  if (resultSourceMap !== void 0 && resultSourceMap !== false) {
978
- options.query = {
979
- resultSourceMap,
980
- ...options.query
981
- };
935
+ options.query = { resultSourceMap, ...options.query };
982
936
  }
983
937
  const perspective = options.perspective || config.perspective;
984
938
  if (typeof perspective === "string" && perspective !== "raw") {
985
939
  validateApiPerspective(perspective);
986
- options.query = {
987
- perspective,
988
- ...options.query
989
- };
940
+ options.query = { perspective, ...options.query };
990
941
  if (perspective === "previewDrafts" && useCdn) {
991
942
  useCdn = false;
992
943
  printCdnPreviewDraftsWarning();
993
944
  }
994
945
  }
995
946
  }
996
- const reqOptions = requestOptions(config, Object.assign({}, options, {
997
- url: _getUrl(client, uri, useCdn)
998
- }));
999
- const request = new Observable(subscriber => httpRequest(reqOptions, config.requester).subscribe(subscriber));
947
+ const reqOptions = requestOptions(
948
+ config,
949
+ Object.assign({}, options, {
950
+ url: _getUrl(client, uri, useCdn)
951
+ })
952
+ );
953
+ const request = new Observable(
954
+ (subscriber) => httpRequest(reqOptions, config.requester).subscribe(subscriber)
955
+ );
1000
956
  return options.signal ? request.pipe(_withAbortSignal(options.signal)) : request;
1001
957
  }
1002
958
  function _request(client, httpRequest, options) {
1003
- const observable = _requestObservable(client, httpRequest, options).pipe(filter(event => event.type === "response"), map(event => event.body));
959
+ const observable = _requestObservable(client, httpRequest, options).pipe(
960
+ filter((event) => event.type === "response"),
961
+ map((event) => event.body)
962
+ );
1004
963
  return observable;
1005
964
  }
1006
965
  function _getDataUrl(client, operation, path) {
@@ -1010,18 +969,14 @@ function _getDataUrl(client, operation, path) {
1010
969
  const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
1011
970
  return "/data".concat(uri).replace(/\/($|\?)/, "$1");
1012
971
  }
1013
- function _getUrl(client, uri) {
1014
- let canUseCdn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1015
- const {
1016
- url,
1017
- cdnUrl
1018
- } = client.config();
972
+ function _getUrl(client, uri, canUseCdn = false) {
973
+ const { url, cdnUrl } = client.config();
1019
974
  const base = canUseCdn ? cdnUrl : url;
1020
975
  return "".concat(base, "/").concat(uri.replace(/^\//, ""));
1021
976
  }
1022
977
  function _withAbortSignal(signal) {
1023
- return input => {
1024
- return new Observable(observer => {
978
+ return (input) => {
979
+ return new Observable((observer) => {
1025
980
  const abort = () => observer.error(_createAbortError(signal));
1026
981
  if (signal && signal.aborted) {
1027
982
  abort();
@@ -1046,15 +1001,18 @@ function _createAbortError(signal) {
1046
1001
  error.name = "AbortError";
1047
1002
  return error;
1048
1003
  }
1004
+
1049
1005
  var __accessCheck$4 = (obj, member, msg) => {
1050
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
1006
+ if (!member.has(obj))
1007
+ throw TypeError("Cannot " + msg);
1051
1008
  };
1052
1009
  var __privateGet$4 = (obj, member, getter) => {
1053
1010
  __accessCheck$4(obj, member, "read from private field");
1054
1011
  return getter ? getter.call(obj) : member.get(obj);
1055
1012
  };
1056
1013
  var __privateAdd$4 = (obj, member, value) => {
1057
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
1014
+ if (member.has(obj))
1015
+ throw TypeError("Cannot add the same private member more than once");
1058
1016
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1059
1017
  };
1060
1018
  var __privateSet$4 = (obj, member, value, setter) => {
@@ -1085,13 +1043,19 @@ class AssetsClient {
1085
1043
  }
1086
1044
  upload(assetType, body, options) {
1087
1045
  const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
1088
- return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
1046
+ return lastValueFrom(
1047
+ observable.pipe(
1048
+ filter((event) => event.type === "response"),
1049
+ map(
1050
+ (event) => event.body.document
1051
+ )
1052
+ )
1053
+ );
1089
1054
  }
1090
1055
  }
1091
1056
  _client2$3 = new WeakMap();
1092
1057
  _httpRequest2$4 = new WeakMap();
1093
- function _upload(client, httpRequest, assetType, body) {
1094
- let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1058
+ function _upload(client, httpRequest, assetType, body, opts = {}) {
1095
1059
  validateAssetType(assetType);
1096
1060
  let meta = opts.extract || void 0;
1097
1061
  if (meta && !meta.length) {
@@ -1100,15 +1064,7 @@ function _upload(client, httpRequest, assetType, body) {
1100
1064
  const dataset = hasDataset(client.config());
1101
1065
  const assetEndpoint = assetType === "image" ? "images" : "files";
1102
1066
  const options = optionsFromFile(opts, body);
1103
- const {
1104
- tag,
1105
- label,
1106
- title,
1107
- description,
1108
- creditLine,
1109
- filename,
1110
- source
1111
- } = options;
1067
+ const { tag, label, title, description, creditLine, filename, source } = options;
1112
1068
  const query = {
1113
1069
  label,
1114
1070
  title,
@@ -1127,9 +1083,7 @@ function _upload(client, httpRequest, assetType, body) {
1127
1083
  method: "POST",
1128
1084
  timeout: options.timeout || 0,
1129
1085
  uri: "/assets/".concat(assetEndpoint, "/").concat(dataset),
1130
- headers: options.contentType ? {
1131
- "Content-Type": options.contentType
1132
- } : {},
1086
+ headers: options.contentType ? { "Content-Type": options.contentType } : {},
1133
1087
  query,
1134
1088
  body
1135
1089
  });
@@ -1138,15 +1092,20 @@ function optionsFromFile(opts, file) {
1138
1092
  if (typeof File === "undefined" || !(file instanceof File)) {
1139
1093
  return opts;
1140
1094
  }
1141
- return Object.assign({
1142
- filename: opts.preserveFilename === false ? void 0 : file.name,
1143
- contentType: file.type
1144
- }, opts);
1095
+ return Object.assign(
1096
+ {
1097
+ filename: opts.preserveFilename === false ? void 0 : file.name,
1098
+ contentType: file.type
1099
+ },
1100
+ opts
1101
+ );
1145
1102
  }
1103
+
1146
1104
  var defaults = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj)).reduce((target, prop) => {
1147
1105
  target[prop] = typeof obj[prop] === "undefined" ? defaults[prop] : obj[prop];
1148
1106
  return target;
1149
1107
  }, {});
1108
+
1150
1109
  const pick = (obj, props) => props.reduce((selection, prop) => {
1151
1110
  if (typeof obj[prop] === "undefined") {
1152
1111
  return selection;
@@ -1154,36 +1113,27 @@ const pick = (obj, props) => props.reduce((selection, prop) => {
1154
1113
  selection[prop] = obj[prop];
1155
1114
  return selection;
1156
1115
  }, {});
1116
+
1157
1117
  const MAX_URL_LENGTH = 16e3 - 1200;
1158
- const possibleOptions = ["includePreviousRevision", "includeResult", "visibility", "effectFormat", "tag"];
1118
+ const possibleOptions = [
1119
+ "includePreviousRevision",
1120
+ "includeResult",
1121
+ "visibility",
1122
+ "effectFormat",
1123
+ "tag"
1124
+ ];
1159
1125
  const defaultOptions = {
1160
1126
  includeResult: true
1161
1127
  };
1162
- function _listen(query, params) {
1163
- let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1164
- const {
1165
- url,
1166
- token,
1167
- withCredentials,
1168
- requestTagPrefix
1169
- } = this.config();
1128
+ function _listen(query, params, opts = {}) {
1129
+ const { url, token, withCredentials, requestTagPrefix } = this.config();
1170
1130
  const tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag;
1171
- const options = {
1172
- ...defaults(opts, defaultOptions),
1173
- tag
1174
- };
1131
+ const options = { ...defaults(opts, defaultOptions), tag };
1175
1132
  const listenOpts = pick(options, possibleOptions);
1176
- const qs = encodeQueryString({
1177
- query,
1178
- params,
1179
- options: {
1180
- tag,
1181
- ...listenOpts
1182
- }
1183
- });
1133
+ const qs = encodeQueryString({ query, params, options: { tag, ...listenOpts } });
1184
1134
  const uri = "".concat(url).concat(_getDataUrl(this, "listen", qs));
1185
1135
  if (uri.length > MAX_URL_LENGTH) {
1186
- return new Observable(observer => observer.error(new Error("Query too large for listener")));
1136
+ return new Observable((observer) => observer.error(new Error("Query too large for listener")));
1187
1137
  }
1188
1138
  const listenFor = options.events ? options.events : ["mutation"];
1189
1139
  const shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1;
@@ -1196,11 +1146,11 @@ function _listen(query, params) {
1196
1146
  Authorization: "Bearer ".concat(token)
1197
1147
  };
1198
1148
  }
1199
- return new Observable(observer => {
1149
+ return new Observable((observer) => {
1200
1150
  let es;
1201
- getEventSource().then(eventSource => {
1151
+ getEventSource().then((eventSource) => {
1202
1152
  es = eventSource;
1203
- }).catch(reason => {
1153
+ }).catch((reason) => {
1204
1154
  observer.error(reason);
1205
1155
  stop();
1206
1156
  });
@@ -1233,35 +1183,32 @@ function _listen(query, params) {
1233
1183
  observer.complete();
1234
1184
  }
1235
1185
  function unsubscribe() {
1236
- if (!es) return;
1186
+ if (!es)
1187
+ return;
1237
1188
  es.removeEventListener("error", onError);
1238
1189
  es.removeEventListener("channelError", onChannelError);
1239
1190
  es.removeEventListener("disconnect", onDisconnect);
1240
- listenFor.forEach(type => es.removeEventListener(type, onMessage));
1191
+ listenFor.forEach((type) => es.removeEventListener(type, onMessage));
1241
1192
  es.close();
1242
1193
  }
1243
1194
  function emitReconnect() {
1244
1195
  if (shouldEmitReconnect) {
1245
- observer.next({
1246
- type: "reconnect"
1247
- });
1196
+ observer.next({ type: "reconnect" });
1248
1197
  }
1249
1198
  }
1250
1199
  async function getEventSource() {
1251
- const {
1252
- default: EventSource
1253
- } = await import('@sanity/eventsource');
1200
+ const { default: EventSource } = await import('@sanity/eventsource');
1254
1201
  const evs = new EventSource(uri, esOptions);
1255
1202
  evs.addEventListener("error", onError);
1256
1203
  evs.addEventListener("channelError", onChannelError);
1257
1204
  evs.addEventListener("disconnect", onDisconnect);
1258
- listenFor.forEach(type => evs.addEventListener(type, onMessage));
1205
+ listenFor.forEach((type) => evs.addEventListener(type, onMessage));
1259
1206
  return evs;
1260
1207
  }
1261
1208
  function open() {
1262
- getEventSource().then(eventSource => {
1209
+ getEventSource().then((eventSource) => {
1263
1210
  es = eventSource;
1264
- }).catch(reason => {
1211
+ }).catch((reason) => {
1265
1212
  observer.error(reason);
1266
1213
  stop();
1267
1214
  });
@@ -1276,9 +1223,7 @@ function _listen(query, params) {
1276
1223
  function parseEvent(event) {
1277
1224
  try {
1278
1225
  const data = event.data && JSON.parse(event.data) || {};
1279
- return Object.assign({
1280
- type: event.type
1281
- }, data);
1226
+ return Object.assign({ type: event.type }, data);
1282
1227
  } catch (err) {
1283
1228
  return err;
1284
1229
  }
@@ -1299,15 +1244,18 @@ function extractErrorMessage(err) {
1299
1244
  }
1300
1245
  return typeof err.error === "string" ? err.error : JSON.stringify(err.error, null, 2);
1301
1246
  }
1247
+
1302
1248
  var __accessCheck$3 = (obj, member, msg) => {
1303
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
1249
+ if (!member.has(obj))
1250
+ throw TypeError("Cannot " + msg);
1304
1251
  };
1305
1252
  var __privateGet$3 = (obj, member, getter) => {
1306
1253
  __accessCheck$3(obj, member, "read from private field");
1307
1254
  return getter ? getter.call(obj) : member.get(obj);
1308
1255
  };
1309
1256
  var __privateAdd$3 = (obj, member, value) => {
1310
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
1257
+ if (member.has(obj))
1258
+ throw TypeError("Cannot add the same private member more than once");
1311
1259
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1312
1260
  };
1313
1261
  var __privateSet$3 = (obj, member, value, setter) => {
@@ -1375,7 +1323,9 @@ class DatasetsClient {
1375
1323
  * @param options - Options for the dataset
1376
1324
  */
1377
1325
  create(name, options) {
1378
- return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name, options));
1326
+ return lastValueFrom(
1327
+ _modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name, options)
1328
+ );
1379
1329
  }
1380
1330
  /**
1381
1331
  * Edit a dataset with the given name
@@ -1384,7 +1334,9 @@ class DatasetsClient {
1384
1334
  * @param options - New options for the dataset
1385
1335
  */
1386
1336
  edit(name, options) {
1387
- return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name, options));
1337
+ return lastValueFrom(
1338
+ _modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name, options)
1339
+ );
1388
1340
  }
1389
1341
  /**
1390
1342
  * Delete a dataset with the given name
@@ -1398,10 +1350,9 @@ class DatasetsClient {
1398
1350
  * Fetch a list of datasets for the configured project
1399
1351
  */
1400
1352
  list() {
1401
- return lastValueFrom(_request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), {
1402
- uri: "/datasets",
1403
- tag: null
1404
- }));
1353
+ return lastValueFrom(
1354
+ _request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), { uri: "/datasets", tag: null })
1355
+ );
1405
1356
  }
1406
1357
  }
1407
1358
  _client2$2 = new WeakMap();
@@ -1415,15 +1366,18 @@ function _modify(client, httpRequest, method, name, options) {
1415
1366
  tag: null
1416
1367
  });
1417
1368
  }
1369
+
1418
1370
  var __accessCheck$2 = (obj, member, msg) => {
1419
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
1371
+ if (!member.has(obj))
1372
+ throw TypeError("Cannot " + msg);
1420
1373
  };
1421
1374
  var __privateGet$2 = (obj, member, getter) => {
1422
1375
  __accessCheck$2(obj, member, "read from private field");
1423
1376
  return getter ? getter.call(obj) : member.get(obj);
1424
1377
  };
1425
1378
  var __privateAdd$2 = (obj, member, value) => {
1426
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
1379
+ if (member.has(obj))
1380
+ throw TypeError("Cannot add the same private member more than once");
1427
1381
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1428
1382
  };
1429
1383
  var __privateSet$2 = (obj, member, value, setter) => {
@@ -1441,9 +1395,7 @@ class ObservableProjectsClient {
1441
1395
  }
1442
1396
  list(options) {
1443
1397
  const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
1444
- return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), {
1445
- uri
1446
- });
1398
+ return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri });
1447
1399
  }
1448
1400
  /**
1449
1401
  * Fetch a project by project ID
@@ -1451,9 +1403,7 @@ class ObservableProjectsClient {
1451
1403
  * @param projectId - ID of the project to fetch
1452
1404
  */
1453
1405
  getById(projectId) {
1454
- return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), {
1455
- uri: "/projects/".concat(projectId)
1456
- });
1406
+ return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: "/projects/".concat(projectId) });
1457
1407
  }
1458
1408
  }
1459
1409
  _client$1 = new WeakMap();
@@ -1467,9 +1417,7 @@ class ProjectsClient {
1467
1417
  }
1468
1418
  list(options) {
1469
1419
  const uri = (options == null ? void 0 : options.includeMembers) === false ? "/projects?includeMembers=false" : "/projects";
1470
- return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), {
1471
- uri
1472
- }));
1420
+ return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri }));
1473
1421
  }
1474
1422
  /**
1475
1423
  * Fetch a project by project ID
@@ -1477,22 +1425,25 @@ class ProjectsClient {
1477
1425
  * @param projectId - ID of the project to fetch
1478
1426
  */
1479
1427
  getById(projectId) {
1480
- return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), {
1481
- uri: "/projects/".concat(projectId)
1482
- }));
1428
+ return lastValueFrom(
1429
+ _request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: "/projects/".concat(projectId) })
1430
+ );
1483
1431
  }
1484
1432
  }
1485
1433
  _client2$1 = new WeakMap();
1486
1434
  _httpRequest2$2 = new WeakMap();
1435
+
1487
1436
  var __accessCheck$1 = (obj, member, msg) => {
1488
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
1437
+ if (!member.has(obj))
1438
+ throw TypeError("Cannot " + msg);
1489
1439
  };
1490
1440
  var __privateGet$1 = (obj, member, getter) => {
1491
1441
  __accessCheck$1(obj, member, "read from private field");
1492
1442
  return getter ? getter.call(obj) : member.get(obj);
1493
1443
  };
1494
1444
  var __privateAdd$1 = (obj, member, value) => {
1495
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
1445
+ if (member.has(obj))
1446
+ throw TypeError("Cannot add the same private member more than once");
1496
1447
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1497
1448
  };
1498
1449
  var __privateSet$1 = (obj, member, value, setter) => {
@@ -1514,9 +1465,11 @@ class ObservableUsersClient {
1514
1465
  * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
1515
1466
  */
1516
1467
  getById(id) {
1517
- return _request(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), {
1518
- uri: "/users/".concat(id)
1519
- });
1468
+ return _request(
1469
+ __privateGet$1(this, _client),
1470
+ __privateGet$1(this, _httpRequest$1),
1471
+ { uri: "/users/".concat(id) }
1472
+ );
1520
1473
  }
1521
1474
  }
1522
1475
  _client = new WeakMap();
@@ -1534,22 +1487,27 @@ class UsersClient {
1534
1487
  * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
1535
1488
  */
1536
1489
  getById(id) {
1537
- return lastValueFrom(_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
1538
- uri: "/users/".concat(id)
1539
- }));
1490
+ return lastValueFrom(
1491
+ _request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
1492
+ uri: "/users/".concat(id)
1493
+ })
1494
+ );
1540
1495
  }
1541
1496
  }
1542
1497
  _client2 = new WeakMap();
1543
1498
  _httpRequest2$1 = new WeakMap();
1499
+
1544
1500
  var __accessCheck = (obj, member, msg) => {
1545
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
1501
+ if (!member.has(obj))
1502
+ throw TypeError("Cannot " + msg);
1546
1503
  };
1547
1504
  var __privateGet = (obj, member, getter) => {
1548
1505
  __accessCheck(obj, member, "read from private field");
1549
1506
  return getter ? getter.call(obj) : member.get(obj);
1550
1507
  };
1551
1508
  var __privateAdd = (obj, member, value) => {
1552
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
1509
+ if (member.has(obj))
1510
+ throw TypeError("Cannot add the same private member more than once");
1553
1511
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1554
1512
  };
1555
1513
  var __privateSet = (obj, member, value, setter) => {
@@ -1559,8 +1517,7 @@ var __privateSet = (obj, member, value, setter) => {
1559
1517
  };
1560
1518
  var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
1561
1519
  const _ObservableSanityClient = class _ObservableSanityClient {
1562
- constructor(httpRequest) {
1563
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
1520
+ constructor(httpRequest, config = defaultConfig) {
1564
1521
  /**
1565
1522
  * Private properties
1566
1523
  */
@@ -1585,12 +1542,12 @@ const _ObservableSanityClient = class _ObservableSanityClient {
1585
1542
  }
1586
1543
  config(newConfig) {
1587
1544
  if (newConfig === void 0) {
1588
- return {
1589
- ...__privateGet(this, _clientConfig)
1590
- };
1545
+ return { ...__privateGet(this, _clientConfig) };
1591
1546
  }
1592
1547
  if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === false) {
1593
- throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
1548
+ throw new Error(
1549
+ "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
1550
+ );
1594
1551
  }
1595
1552
  __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {}));
1596
1553
  return this;
@@ -1601,13 +1558,9 @@ const _ObservableSanityClient = class _ObservableSanityClient {
1601
1558
  * @param newConfig - New client configuration properties, shallowly merged with existing configuration
1602
1559
  */
1603
1560
  withConfig(newConfig) {
1604
- return new _ObservableSanityClient(__privateGet(this, _httpRequest), {
1605
- ...this.config(),
1606
- ...newConfig
1607
- });
1561
+ return new _ObservableSanityClient(__privateGet(this, _httpRequest), { ...this.config(), ...newConfig });
1608
1562
  }
1609
- fetch(query, params) {
1610
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1563
+ fetch(query, params, options = {}) {
1611
1564
  return _fetch(this, __privateGet(this, _httpRequest), query, params, options);
1612
1565
  }
1613
1566
  /**
@@ -1695,8 +1648,7 @@ _clientConfig = new WeakMap();
1695
1648
  _httpRequest = new WeakMap();
1696
1649
  let ObservableSanityClient = _ObservableSanityClient;
1697
1650
  const _SanityClient = class _SanityClient {
1698
- constructor(httpRequest) {
1699
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
1651
+ constructor(httpRequest, config = defaultConfig) {
1700
1652
  /**
1701
1653
  * Private properties
1702
1654
  */
@@ -1722,12 +1674,12 @@ const _SanityClient = class _SanityClient {
1722
1674
  }
1723
1675
  config(newConfig) {
1724
1676
  if (newConfig === void 0) {
1725
- return {
1726
- ...__privateGet(this, _clientConfig2)
1727
- };
1677
+ return { ...__privateGet(this, _clientConfig2) };
1728
1678
  }
1729
1679
  if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
1730
- throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
1680
+ throw new Error(
1681
+ "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
1682
+ );
1731
1683
  }
1732
1684
  if (this.observable) {
1733
1685
  this.observable.config(newConfig);
@@ -1741,13 +1693,9 @@ const _SanityClient = class _SanityClient {
1741
1693
  * @param newConfig - New client configuration properties, shallowly merged with existing configuration
1742
1694
  */
1743
1695
  withConfig(newConfig) {
1744
- return new _SanityClient(__privateGet(this, _httpRequest2), {
1745
- ...this.config(),
1746
- ...newConfig
1747
- });
1696
+ return new _SanityClient(__privateGet(this, _httpRequest2), { ...this.config(), ...newConfig });
1748
1697
  }
1749
- fetch(query, params) {
1750
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1698
+ fetch(query, params, options = {}) {
1751
1699
  return lastValueFrom(_fetch(this, __privateGet(this, _httpRequest2), query, params, options));
1752
1700
  }
1753
1701
  /**
@@ -1772,13 +1720,19 @@ const _SanityClient = class _SanityClient {
1772
1720
  return lastValueFrom(_getDocuments(this, __privateGet(this, _httpRequest2), ids, options));
1773
1721
  }
1774
1722
  create(document, options) {
1775
- return lastValueFrom(_create(this, __privateGet(this, _httpRequest2), document, "create", options));
1723
+ return lastValueFrom(
1724
+ _create(this, __privateGet(this, _httpRequest2), document, "create", options)
1725
+ );
1776
1726
  }
1777
1727
  createIfNotExists(document, options) {
1778
- return lastValueFrom(_createIfNotExists(this, __privateGet(this, _httpRequest2), document, options));
1728
+ return lastValueFrom(
1729
+ _createIfNotExists(this, __privateGet(this, _httpRequest2), document, options)
1730
+ );
1779
1731
  }
1780
1732
  createOrReplace(document, options) {
1781
- return lastValueFrom(_createOrReplace(this, __privateGet(this, _httpRequest2), document, options));
1733
+ return lastValueFrom(
1734
+ _createOrReplace(this, __privateGet(this, _httpRequest2), document, options)
1735
+ );
1782
1736
  }
1783
1737
  delete(selection, options) {
1784
1738
  return lastValueFrom(_delete(this, __privateGet(this, _httpRequest2), selection, options));
@@ -1849,38 +1803,40 @@ const _SanityClient = class _SanityClient {
1849
1803
  _clientConfig2 = new WeakMap();
1850
1804
  _httpRequest2 = new WeakMap();
1851
1805
  let SanityClient = _SanityClient;
1806
+
1852
1807
  function defineCreateClientExports(envMiddleware, ClassConstructor) {
1853
1808
  const httpRequest = defineHttpRequest(envMiddleware, {});
1854
1809
  const requester = httpRequest.defaultRequester;
1855
- const createClient = config => new ClassConstructor(defineHttpRequest(envMiddleware, {
1856
- maxRetries: config.maxRetries,
1857
- retryDelay: config.retryDelay
1858
- }), config);
1859
- return {
1860
- requester,
1861
- createClient
1862
- };
1810
+ const createClient = (config) => new ClassConstructor(
1811
+ defineHttpRequest(envMiddleware, {
1812
+ maxRetries: config.maxRetries,
1813
+ retryDelay: config.retryDelay
1814
+ }),
1815
+ config
1816
+ );
1817
+ return { requester, createClient };
1863
1818
  }
1819
+
1864
1820
  var name = "@sanity/client";
1865
- var version = "6.11.2";
1866
- const middleware = [debug({
1867
- verbose: true,
1868
- namespace: "sanity:client"
1869
- }), headers({
1870
- "User-Agent": "".concat(name, " ").concat(version)
1871
- }),
1872
- // Enable keep-alive, and in addition limit the number of sockets that can be opened.
1873
- // This avoids opening too many connections to the server if someone tries to execute
1874
- // a bunch of requests in parallel. It's recommended to have a concurrency limit
1875
- // at a "higher limit" (i.e. you shouldn't actually execute hundreds of requests in parallel),
1876
- // and this is mainly to minimize the impact for the network and server.
1877
- //
1878
- // We're currently matching the same defaults as browsers:
1879
- // https://stackoverflow.com/questions/26003756/is-there-a-limit-practical-or-otherwise-to-the-number-of-web-sockets-a-page-op
1880
- agent({
1881
- keepAlive: true,
1882
- maxSockets: 30,
1883
- maxTotalSockets: 256
1884
- })];
1821
+ var version = "6.11.3";
1822
+
1823
+ const middleware = [
1824
+ debug({ verbose: true, namespace: "sanity:client" }),
1825
+ headers({ "User-Agent": "".concat(name, " ").concat(version) }),
1826
+ // Enable keep-alive, and in addition limit the number of sockets that can be opened.
1827
+ // This avoids opening too many connections to the server if someone tries to execute
1828
+ // a bunch of requests in parallel. It's recommended to have a concurrency limit
1829
+ // at a "higher limit" (i.e. you shouldn't actually execute hundreds of requests in parallel),
1830
+ // and this is mainly to minimize the impact for the network and server.
1831
+ //
1832
+ // We're currently matching the same defaults as browsers:
1833
+ // https://stackoverflow.com/questions/26003756/is-there-a-limit-practical-or-otherwise-to-the-number-of-web-sockets-a-page-op
1834
+ agent({
1835
+ keepAlive: true,
1836
+ maxSockets: 30,
1837
+ maxTotalSockets: 256
1838
+ })
1839
+ ];
1840
+
1885
1841
  export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, defaultConfig, defineCreateClientExports, middleware, printNoDefaultExport };
1886
- //# sourceMappingURL=nodeMiddleware-dn4ZacKV.js.map
1842
+ //# sourceMappingURL=nodeMiddleware-u_fUUnxa.js.map