@sanity/client 6.21.1 → 6.21.3-bundle-perspective

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,19 +2,26 @@ import { getIt } from "get-it";
2
2
  import { adapter, environment } from "get-it";
3
3
  import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } from "get-it/middleware";
4
4
  import { Observable, from, lastValueFrom } from "rxjs";
5
- import { combineLatestWith, map, filter } from "rxjs/operators";
6
5
  import { stegaClean } from "./_chunks-es/stegaClean.js";
7
- var __defProp$3 = Object.defineProperty, __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$3 = (obj, key, value) => (__defNormalProp$3(obj, typeof key != "symbol" ? key + "" : key, value), value);
6
+ import { combineLatestWith, map, filter } from "rxjs/operators";
8
7
  class ClientError extends Error {
8
+ response;
9
+ statusCode = 400;
10
+ responseBody;
11
+ details;
9
12
  constructor(res) {
10
13
  const props = extractErrorProps(res);
11
- super(props.message), __publicField$3(this, "response"), __publicField$3(this, "statusCode", 400), __publicField$3(this, "responseBody"), __publicField$3(this, "details"), Object.assign(this, props);
14
+ super(props.message), Object.assign(this, props);
12
15
  }
13
16
  }
14
17
  class ServerError extends Error {
18
+ response;
19
+ statusCode = 500;
20
+ responseBody;
21
+ details;
15
22
  constructor(res) {
16
23
  const props = extractErrorProps(res);
17
- super(props.message), __publicField$3(this, "response"), __publicField$3(this, "statusCode", 500), __publicField$3(this, "responseBody"), __publicField$3(this, "details"), Object.assign(this, props);
24
+ super(props.message), Object.assign(this, props);
18
25
  }
19
26
  }
20
27
  function extractErrorProps(res) {
@@ -28,10 +35,7 @@ function extractErrorProps(res) {
28
35
  if (body.error && body.message)
29
36
  return props.message = `${body.error} - ${body.message}`, props;
30
37
  if (isMutationError(body) || isActionError(body)) {
31
- const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) => {
32
- var _a;
33
- return (_a = item.error) == null ? void 0 : _a.description;
34
- }).filter(Boolean);
38
+ const allItems = body.error.items || [], items = allItems.slice(0, 5).map((item) => item.error?.description).filter(Boolean);
35
39
  let itemsStr = items.length ? `:
36
40
  - ${items.join(`
37
41
  - `)}` : "";
@@ -83,8 +87,7 @@ function defineHttpRequest(envMiddleware) {
83
87
  ]);
84
88
  }
85
89
  function shouldRetry(err, attempt, options) {
86
- if (options.maxRetries === 0)
87
- return !1;
90
+ if (options.maxRetries === 0) return !1;
88
91
  const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
89
92
  return (isSafe || isQuery) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options);
90
93
  }
@@ -147,17 +150,11 @@ const VALID_ASSET_TYPES = ["image", "file"], VALID_INSERT_LOCATIONS = ["before",
147
150
  );
148
151
  return tag;
149
152
  };
150
- var __defProp$2 = Object.defineProperty, __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$2 = (obj, key, value) => (__defNormalProp$2(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck$7 = (obj, member, msg) => {
151
- if (!member.has(obj))
152
- throw TypeError("Cannot " + msg);
153
- }, __privateGet$7 = (obj, member, getter) => (__accessCheck$7(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$7 = (obj, member, value) => {
154
- if (member.has(obj))
155
- throw TypeError("Cannot add the same private member more than once");
156
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
157
- }, __privateSet$7 = (obj, member, value, setter) => (__accessCheck$7(obj, member, "write to private field"), member.set(obj, value), value);
158
153
  class BasePatch {
154
+ selection;
155
+ operations;
159
156
  constructor(selection, operations = {}) {
160
- __publicField$2(this, "selection"), __publicField$2(this, "operations"), this.selection = selection, this.operations = operations;
157
+ this.selection = selection, this.operations = operations;
161
158
  }
162
159
  /**
163
160
  * Sets the given attributes to the document. Does NOT merge objects.
@@ -288,62 +285,52 @@ class BasePatch {
288
285
  return this._assign(op, props, !1);
289
286
  }
290
287
  }
291
- var _client$6;
292
- const _ObservablePatch = class _ObservablePatch2 extends BasePatch {
288
+ class ObservablePatch extends BasePatch {
289
+ #client;
293
290
  constructor(selection, operations, client) {
294
- super(selection, operations), __privateAdd$7(this, _client$6, void 0), __privateSet$7(this, _client$6, client);
291
+ super(selection, operations), this.#client = client;
295
292
  }
296
293
  /**
297
294
  * Clones the patch
298
295
  */
299
296
  clone() {
300
- return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$7(this, _client$6));
297
+ return new ObservablePatch(this.selection, { ...this.operations }, this.#client);
301
298
  }
302
299
  commit(options) {
303
- if (!__privateGet$7(this, _client$6))
300
+ if (!this.#client)
304
301
  throw new Error(
305
302
  "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
306
303
  );
307
304
  const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
308
- return __privateGet$7(this, _client$6).mutate({ patch: this.serialize() }, opts);
305
+ return this.#client.mutate({ patch: this.serialize() }, opts);
309
306
  }
310
- };
311
- _client$6 = /* @__PURE__ */ new WeakMap();
312
- let ObservablePatch = _ObservablePatch;
313
- var _client2$5;
314
- const _Patch = class _Patch2 extends BasePatch {
307
+ }
308
+ class Patch extends BasePatch {
309
+ #client;
315
310
  constructor(selection, operations, client) {
316
- super(selection, operations), __privateAdd$7(this, _client2$5, void 0), __privateSet$7(this, _client2$5, client);
311
+ super(selection, operations), this.#client = client;
317
312
  }
318
313
  /**
319
314
  * Clones the patch
320
315
  */
321
316
  clone() {
322
- return new _Patch2(this.selection, { ...this.operations }, __privateGet$7(this, _client2$5));
317
+ return new Patch(this.selection, { ...this.operations }, this.#client);
323
318
  }
324
319
  commit(options) {
325
- if (!__privateGet$7(this, _client2$5))
320
+ if (!this.#client)
326
321
  throw new Error(
327
322
  "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
328
323
  );
329
324
  const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
330
- return __privateGet$7(this, _client2$5).mutate({ patch: this.serialize() }, opts);
325
+ return this.#client.mutate({ patch: this.serialize() }, opts);
331
326
  }
332
- };
333
- _client2$5 = /* @__PURE__ */ new WeakMap();
334
- let Patch = _Patch;
335
- var __defProp$1 = Object.defineProperty, __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$1 = (obj, key, value) => (__defNormalProp$1(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck$6 = (obj, member, msg) => {
336
- if (!member.has(obj))
337
- throw TypeError("Cannot " + msg);
338
- }, __privateGet$6 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$6 = (obj, member, value) => {
339
- if (member.has(obj))
340
- throw TypeError("Cannot add the same private member more than once");
341
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
342
- }, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
327
+ }
343
328
  const defaultMutateOptions = { returnDocuments: !1 };
344
329
  class BaseTransaction {
330
+ operations;
331
+ trxId;
345
332
  constructor(operations = [], transactionId) {
346
- __publicField$1(this, "operations"), __publicField$1(this, "trxId"), this.operations = operations, this.trxId = transactionId;
333
+ this.operations = operations, this.trxId = transactionId;
347
334
  }
348
335
  /**
349
336
  * Creates a new Sanity document. If `_id` is provided and already exists, the mutation will fail. If no `_id` is given, one will automatically be generated by the database.
@@ -408,23 +395,23 @@ class BaseTransaction {
408
395
  return this.operations.push(mut), this;
409
396
  }
410
397
  }
411
- var _client$5;
412
- const _Transaction = class _Transaction2 extends BaseTransaction {
398
+ class Transaction extends BaseTransaction {
399
+ #client;
413
400
  constructor(operations, client, transactionId) {
414
- super(operations, transactionId), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
401
+ super(operations, transactionId), this.#client = client;
415
402
  }
416
403
  /**
417
404
  * Clones the transaction
418
405
  */
419
406
  clone() {
420
- return new _Transaction2([...this.operations], __privateGet$6(this, _client$5), this.trxId);
407
+ return new Transaction([...this.operations], this.#client, this.trxId);
421
408
  }
422
409
  commit(options) {
423
- if (!__privateGet$6(this, _client$5))
410
+ if (!this.#client)
424
411
  throw new Error(
425
412
  "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
426
413
  );
427
- return __privateGet$6(this, _client$5).mutate(
414
+ return this.#client.mutate(
428
415
  this.serialize(),
429
416
  Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
430
417
  );
@@ -434,33 +421,31 @@ const _Transaction = class _Transaction2 extends BaseTransaction {
434
421
  if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
435
422
  return this._add({ patch: patchOrDocumentId.serialize() });
436
423
  if (isBuilder) {
437
- const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
424
+ const patch = patchOps(new Patch(patchOrDocumentId, {}, this.#client));
438
425
  if (!(patch instanceof Patch))
439
426
  throw new Error("function passed to `patch()` must return the patch");
440
427
  return this._add({ patch: patch.serialize() });
441
428
  }
442
429
  return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
443
430
  }
444
- };
445
- _client$5 = /* @__PURE__ */ new WeakMap();
446
- let Transaction = _Transaction;
447
- var _client2$4;
448
- const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
431
+ }
432
+ class ObservableTransaction extends BaseTransaction {
433
+ #client;
449
434
  constructor(operations, client, transactionId) {
450
- super(operations, transactionId), __privateAdd$6(this, _client2$4, void 0), __privateSet$6(this, _client2$4, client);
435
+ super(operations, transactionId), this.#client = client;
451
436
  }
452
437
  /**
453
438
  * Clones the transaction
454
439
  */
455
440
  clone() {
456
- return new _ObservableTransaction2([...this.operations], __privateGet$6(this, _client2$4), this.trxId);
441
+ return new ObservableTransaction([...this.operations], this.#client, this.trxId);
457
442
  }
458
443
  commit(options) {
459
- if (!__privateGet$6(this, _client2$4))
444
+ if (!this.#client)
460
445
  throw new Error(
461
446
  "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
462
447
  );
463
- return __privateGet$6(this, _client2$4).mutate(
448
+ return this.#client.mutate(
464
449
  this.serialize(),
465
450
  Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
466
451
  );
@@ -470,16 +455,14 @@ const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransac
470
455
  if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
471
456
  return this._add({ patch: patchOrDocumentId.serialize() });
472
457
  if (isBuilder) {
473
- const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$4)));
458
+ const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, this.#client));
474
459
  if (!(patch instanceof ObservablePatch))
475
460
  throw new Error("function passed to `patch()` must return the patch");
476
461
  return this._add({ patch: patch.serialize() });
477
462
  }
478
463
  return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
479
464
  }
480
- };
481
- _client2$4 = /* @__PURE__ */ new WeakMap();
482
- let ObservableTransaction = _ObservableTransaction;
465
+ }
483
466
  const BASE_URL = "https://www.sanity.io/help/";
484
467
  function generateHelpUrl(slug) {
485
468
  return BASE_URL + slug;
@@ -643,14 +626,24 @@ function _fetch(client, httpRequest, _stega, query, _params = {}, options = {})
643
626
  ) : $request.pipe(map(mapResponse));
644
627
  }
645
628
  function _getDocument(client, httpRequest, id, opts = {}) {
646
- const options = { uri: _getDataUrl(client, "doc", id), json: !0, tag: opts.tag };
629
+ const options = {
630
+ uri: _getDataUrl(client, "doc", id),
631
+ json: !0,
632
+ tag: opts.tag,
633
+ signal: opts.signal
634
+ };
647
635
  return _requestObservable(client, httpRequest, options).pipe(
648
636
  filter(isResponse),
649
637
  map((event) => event.body.documents && event.body.documents[0])
650
638
  );
651
639
  }
652
640
  function _getDocuments(client, httpRequest, ids, opts = {}) {
653
- const options = { uri: _getDataUrl(client, "doc", ids.join(",")), json: !0, tag: opts.tag };
641
+ const options = {
642
+ uri: _getDataUrl(client, "doc", ids.join(",")),
643
+ json: !0,
644
+ tag: opts.tag,
645
+ signal: opts.signal
646
+ };
654
647
  return _requestObservable(client, httpRequest, options).pipe(
655
648
  filter(isResponse),
656
649
  map((event) => {
@@ -703,6 +696,7 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
703
696
  tag,
704
697
  returnQuery,
705
698
  perspective: options.perspective,
699
+ bundlePerspective: options.bundlePerspective,
706
700
  resultSourceMap: options.resultSourceMap,
707
701
  lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
708
702
  canUseCdn: isQuery,
@@ -734,15 +728,14 @@ function _create(client, httpRequest, doc, op, options = {}) {
734
728
  return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
735
729
  }
736
730
  function _requestObservable(client, httpRequest, options) {
737
- var _a, _b;
738
731
  const uri = options.url || options.uri, config = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
739
- let useCdn = ((_a = options.useCdn) != null ? _a : config.useCdn) && canUseCdn;
732
+ let useCdn = (options.useCdn ?? config.useCdn) && canUseCdn;
740
733
  const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
741
734
  if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
742
- const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
735
+ const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
743
736
  resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
744
- const perspective = options.perspective || config.perspective;
745
- typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query });
737
+ const perspective = options.perspective || config.perspective, bundlePerspective = options.bundlePerspective || config.bundlePerspective;
738
+ typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), typeof bundlePerspective == "string" && (options.query = { perspective: void 0, bundlePerspective, ...options.query }), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query });
746
739
  }
747
740
  const reqOptions = requestOptions(
748
741
  config,
@@ -783,36 +776,29 @@ function _withAbortSignal(signal) {
783
776
  }
784
777
  const isDomExceptionSupported = !!globalThis.DOMException;
785
778
  function _createAbortError(signal) {
786
- var _a, _b;
787
779
  if (isDomExceptionSupported)
788
- return new DOMException((_a = signal == null ? void 0 : signal.reason) != null ? _a : "The operation was aborted.", "AbortError");
789
- const error = new Error((_b = signal == null ? void 0 : signal.reason) != null ? _b : "The operation was aborted.");
780
+ return new DOMException(signal?.reason ?? "The operation was aborted.", "AbortError");
781
+ const error = new Error(signal?.reason ?? "The operation was aborted.");
790
782
  return error.name = "AbortError", error;
791
783
  }
792
- var __accessCheck$5 = (obj, member, msg) => {
793
- if (!member.has(obj))
794
- throw TypeError("Cannot " + msg);
795
- }, __privateGet$5 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$5 = (obj, member, value) => {
796
- if (member.has(obj))
797
- throw TypeError("Cannot add the same private member more than once");
798
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
799
- }, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value), _client$4, _httpRequest$4;
800
784
  class ObservableAssetsClient {
785
+ #client;
786
+ #httpRequest;
801
787
  constructor(client, httpRequest) {
802
- __privateAdd$5(this, _client$4, void 0), __privateAdd$5(this, _httpRequest$4, void 0), __privateSet$5(this, _client$4, client), __privateSet$5(this, _httpRequest$4, httpRequest);
788
+ this.#client = client, this.#httpRequest = httpRequest;
803
789
  }
804
790
  upload(assetType, body, options) {
805
- return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$4), assetType, body, options);
791
+ return _upload(this.#client, this.#httpRequest, assetType, body, options);
806
792
  }
807
793
  }
808
- _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
809
- var _client2$3, _httpRequest2$4;
810
794
  class AssetsClient {
795
+ #client;
796
+ #httpRequest;
811
797
  constructor(client, httpRequest) {
812
- __privateAdd$5(this, _client2$3, void 0), __privateAdd$5(this, _httpRequest2$4, void 0), __privateSet$5(this, _client2$3, client), __privateSet$5(this, _httpRequest2$4, httpRequest);
798
+ this.#client = client, this.#httpRequest = httpRequest;
813
799
  }
814
800
  upload(assetType, body, options) {
815
- const observable2 = _upload(__privateGet$5(this, _client2$3), __privateGet$5(this, _httpRequest2$4), assetType, body, options);
801
+ const observable2 = _upload(this.#client, this.#httpRequest, assetType, body, options);
816
802
  return lastValueFrom(
817
803
  observable2.pipe(
818
804
  filter((event) => event.type === "response"),
@@ -823,7 +809,6 @@ class AssetsClient {
823
809
  );
824
810
  }
825
811
  }
826
- _client2$3 = /* @__PURE__ */ new WeakMap(), _httpRequest2$4 = /* @__PURE__ */ new WeakMap();
827
812
  function _upload(client, httpRequest, assetType, body, opts = {}) {
828
813
  validateAssetType(assetType);
829
814
  let meta = opts.extract || void 0;
@@ -932,30 +917,22 @@ function cooerceError(err) {
932
917
  function extractErrorMessage(err) {
933
918
  return err.error ? err.error.description ? err.error.description : typeof err.error == "string" ? err.error : JSON.stringify(err.error, null, 2) : err.message || "Unknown listener error";
934
919
  }
935
- var __accessCheck$4 = (obj, member, msg) => {
936
- if (!member.has(obj))
937
- throw TypeError("Cannot " + msg);
938
- }, __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$4 = (obj, member, value) => {
939
- if (member.has(obj))
940
- throw TypeError("Cannot add the same private member more than once");
941
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
942
- }, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
943
920
  const requiredApiVersion = "2021-03-26";
944
- var _client$3;
945
921
  class LiveClient {
922
+ #client;
946
923
  constructor(client) {
947
- __privateAdd$4(this, _client$3, void 0), __privateSet$4(this, _client$3, client);
924
+ this.#client = client;
948
925
  }
949
926
  /**
950
927
  * Requires `apiVersion` to be `2021-03-26` or later.
951
928
  */
952
929
  events() {
953
- const apiVersion = __privateGet$4(this, _client$3).config().apiVersion.replace(/^v/, "");
930
+ const apiVersion = this.#client.config().apiVersion.replace(/^v/, "");
954
931
  if (apiVersion !== "X" && apiVersion < requiredApiVersion)
955
932
  throw new Error(
956
933
  `The live events API requires API version ${requiredApiVersion} or later. The current API version is ${apiVersion}. Please update your API version to use this feature.`
957
934
  );
958
- const path = _getDataUrl(__privateGet$4(this, _client$3), "live/events"), url = new URL(__privateGet$4(this, _client$3).getUrl(path, !1)), listenFor = ["restart", "message"];
935
+ const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, !1)), listenFor = ["restart", "message"];
959
936
  return new Observable((observer) => {
960
937
  let es, reconnectTimer, stopped = !1, unsubscribed = !1;
961
938
  open();
@@ -1004,7 +981,6 @@ class LiveClient {
1004
981
  });
1005
982
  }
1006
983
  }
1007
- _client$3 = /* @__PURE__ */ new WeakMap();
1008
984
  function parseEvent(event) {
1009
985
  try {
1010
986
  const data = event.data && JSON.parse(event.data) || {};
@@ -1013,17 +989,11 @@ function parseEvent(event) {
1013
989
  return err;
1014
990
  }
1015
991
  }
1016
- var __accessCheck$3 = (obj, member, msg) => {
1017
- if (!member.has(obj))
1018
- throw TypeError("Cannot " + msg);
1019
- }, __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$3 = (obj, member, value) => {
1020
- if (member.has(obj))
1021
- throw TypeError("Cannot add the same private member more than once");
1022
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1023
- }, __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value), _client$2, _httpRequest$3;
1024
992
  class ObservableDatasetsClient {
993
+ #client;
994
+ #httpRequest;
1025
995
  constructor(client, httpRequest) {
1026
- __privateAdd$3(this, _client$2, void 0), __privateAdd$3(this, _httpRequest$3, void 0), __privateSet$3(this, _client$2, client), __privateSet$3(this, _httpRequest$3, httpRequest);
996
+ this.#client = client, this.#httpRequest = httpRequest;
1027
997
  }
1028
998
  /**
1029
999
  * Create a new dataset with the given name
@@ -1032,7 +1002,7 @@ class ObservableDatasetsClient {
1032
1002
  * @param options - Options for the dataset
1033
1003
  */
1034
1004
  create(name2, options) {
1035
- return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PUT", name2, options);
1005
+ return _modify(this.#client, this.#httpRequest, "PUT", name2, options);
1036
1006
  }
1037
1007
  /**
1038
1008
  * Edit a dataset with the given name
@@ -1041,7 +1011,7 @@ class ObservableDatasetsClient {
1041
1011
  * @param options - New options for the dataset
1042
1012
  */
1043
1013
  edit(name2, options) {
1044
- return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PATCH", name2, options);
1014
+ return _modify(this.#client, this.#httpRequest, "PATCH", name2, options);
1045
1015
  }
1046
1016
  /**
1047
1017
  * Delete a dataset with the given name
@@ -1049,23 +1019,23 @@ class ObservableDatasetsClient {
1049
1019
  * @param name - Name of the dataset to delete
1050
1020
  */
1051
1021
  delete(name2) {
1052
- return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "DELETE", name2);
1022
+ return _modify(this.#client, this.#httpRequest, "DELETE", name2);
1053
1023
  }
1054
1024
  /**
1055
1025
  * Fetch a list of datasets for the configured project
1056
1026
  */
1057
1027
  list() {
1058
- return _request(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), {
1028
+ return _request(this.#client, this.#httpRequest, {
1059
1029
  uri: "/datasets",
1060
1030
  tag: null
1061
1031
  });
1062
1032
  }
1063
1033
  }
1064
- _client$2 = /* @__PURE__ */ new WeakMap(), _httpRequest$3 = /* @__PURE__ */ new WeakMap();
1065
- var _client2$2, _httpRequest2$3;
1066
1034
  class DatasetsClient {
1035
+ #client;
1036
+ #httpRequest;
1067
1037
  constructor(client, httpRequest) {
1068
- __privateAdd$3(this, _client2$2, void 0), __privateAdd$3(this, _httpRequest2$3, void 0), __privateSet$3(this, _client2$2, client), __privateSet$3(this, _httpRequest2$3, httpRequest);
1038
+ this.#client = client, this.#httpRequest = httpRequest;
1069
1039
  }
1070
1040
  /**
1071
1041
  * Create a new dataset with the given name
@@ -1075,7 +1045,7 @@ class DatasetsClient {
1075
1045
  */
1076
1046
  create(name2, options) {
1077
1047
  return lastValueFrom(
1078
- _modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name2, options)
1048
+ _modify(this.#client, this.#httpRequest, "PUT", name2, options)
1079
1049
  );
1080
1050
  }
1081
1051
  /**
@@ -1086,7 +1056,7 @@ class DatasetsClient {
1086
1056
  */
1087
1057
  edit(name2, options) {
1088
1058
  return lastValueFrom(
1089
- _modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name2, options)
1059
+ _modify(this.#client, this.#httpRequest, "PATCH", name2, options)
1090
1060
  );
1091
1061
  }
1092
1062
  /**
@@ -1095,18 +1065,17 @@ class DatasetsClient {
1095
1065
  * @param name - Name of the dataset to delete
1096
1066
  */
1097
1067
  delete(name2) {
1098
- return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "DELETE", name2));
1068
+ return lastValueFrom(_modify(this.#client, this.#httpRequest, "DELETE", name2));
1099
1069
  }
1100
1070
  /**
1101
1071
  * Fetch a list of datasets for the configured project
1102
1072
  */
1103
1073
  list() {
1104
1074
  return lastValueFrom(
1105
- _request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), { uri: "/datasets", tag: null })
1075
+ _request(this.#client, this.#httpRequest, { uri: "/datasets", tag: null })
1106
1076
  );
1107
1077
  }
1108
1078
  }
1109
- _client2$2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$3 = /* @__PURE__ */ new WeakMap();
1110
1079
  function _modify(client, httpRequest, method, name2, options) {
1111
1080
  return dataset(name2), _request(client, httpRequest, {
1112
1081
  method,
@@ -1115,21 +1084,15 @@ function _modify(client, httpRequest, method, name2, options) {
1115
1084
  tag: null
1116
1085
  });
1117
1086
  }
1118
- var __accessCheck$2 = (obj, member, msg) => {
1119
- if (!member.has(obj))
1120
- throw TypeError("Cannot " + msg);
1121
- }, __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$2 = (obj, member, value) => {
1122
- if (member.has(obj))
1123
- throw TypeError("Cannot add the same private member more than once");
1124
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1125
- }, __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value), _client$1, _httpRequest$2;
1126
1087
  class ObservableProjectsClient {
1088
+ #client;
1089
+ #httpRequest;
1127
1090
  constructor(client, httpRequest) {
1128
- __privateAdd$2(this, _client$1, void 0), __privateAdd$2(this, _httpRequest$2, void 0), __privateSet$2(this, _client$1, client), __privateSet$2(this, _httpRequest$2, httpRequest);
1091
+ this.#client = client, this.#httpRequest = httpRequest;
1129
1092
  }
1130
1093
  list(options) {
1131
- const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
1132
- return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri });
1094
+ const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
1095
+ return _request(this.#client, this.#httpRequest, { uri });
1133
1096
  }
1134
1097
  /**
1135
1098
  * Fetch a project by project ID
@@ -1137,18 +1100,18 @@ class ObservableProjectsClient {
1137
1100
  * @param projectId - ID of the project to fetch
1138
1101
  */
1139
1102
  getById(projectId2) {
1140
- return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), { uri: `/projects/${projectId2}` });
1103
+ return _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` });
1141
1104
  }
1142
1105
  }
1143
- _client$1 = /* @__PURE__ */ new WeakMap(), _httpRequest$2 = /* @__PURE__ */ new WeakMap();
1144
- var _client2$1, _httpRequest2$2;
1145
1106
  class ProjectsClient {
1107
+ #client;
1108
+ #httpRequest;
1146
1109
  constructor(client, httpRequest) {
1147
- __privateAdd$2(this, _client2$1, void 0), __privateAdd$2(this, _httpRequest2$2, void 0), __privateSet$2(this, _client2$1, client), __privateSet$2(this, _httpRequest2$2, httpRequest);
1110
+ this.#client = client, this.#httpRequest = httpRequest;
1148
1111
  }
1149
1112
  list(options) {
1150
- const uri = (options == null ? void 0 : options.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects";
1151
- return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri }));
1113
+ const uri = options?.includeMembers === !1 ? "/projects?includeMembers=false" : "/projects";
1114
+ return lastValueFrom(_request(this.#client, this.#httpRequest, { uri }));
1152
1115
  }
1153
1116
  /**
1154
1117
  * Fetch a project by project ID
@@ -1157,22 +1120,15 @@ class ProjectsClient {
1157
1120
  */
1158
1121
  getById(projectId2) {
1159
1122
  return lastValueFrom(
1160
- _request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), { uri: `/projects/${projectId2}` })
1123
+ _request(this.#client, this.#httpRequest, { uri: `/projects/${projectId2}` })
1161
1124
  );
1162
1125
  }
1163
1126
  }
1164
- _client2$1 = /* @__PURE__ */ new WeakMap(), _httpRequest2$2 = /* @__PURE__ */ new WeakMap();
1165
- var __accessCheck$1 = (obj, member, msg) => {
1166
- if (!member.has(obj))
1167
- throw TypeError("Cannot " + msg);
1168
- }, __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$1 = (obj, member, value) => {
1169
- if (member.has(obj))
1170
- throw TypeError("Cannot add the same private member more than once");
1171
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1172
- }, __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value), _client, _httpRequest$1;
1173
1127
  class ObservableUsersClient {
1128
+ #client;
1129
+ #httpRequest;
1174
1130
  constructor(client, httpRequest) {
1175
- __privateAdd$1(this, _client, void 0), __privateAdd$1(this, _httpRequest$1, void 0), __privateSet$1(this, _client, client), __privateSet$1(this, _httpRequest$1, httpRequest);
1131
+ this.#client = client, this.#httpRequest = httpRequest;
1176
1132
  }
1177
1133
  /**
1178
1134
  * Fetch a user by user ID
@@ -1181,17 +1137,17 @@ class ObservableUsersClient {
1181
1137
  */
1182
1138
  getById(id) {
1183
1139
  return _request(
1184
- __privateGet$1(this, _client),
1185
- __privateGet$1(this, _httpRequest$1),
1140
+ this.#client,
1141
+ this.#httpRequest,
1186
1142
  { uri: `/users/${id}` }
1187
1143
  );
1188
1144
  }
1189
1145
  }
1190
- _client = /* @__PURE__ */ new WeakMap(), _httpRequest$1 = /* @__PURE__ */ new WeakMap();
1191
- var _client2, _httpRequest2$1;
1192
1146
  class UsersClient {
1147
+ #client;
1148
+ #httpRequest;
1193
1149
  constructor(client, httpRequest) {
1194
- __privateAdd$1(this, _client2, void 0), __privateAdd$1(this, _httpRequest2$1, void 0), __privateSet$1(this, _client2, client), __privateSet$1(this, _httpRequest2$1, httpRequest);
1150
+ this.#client = client, this.#httpRequest = httpRequest;
1195
1151
  }
1196
1152
  /**
1197
1153
  * Fetch a user by user ID
@@ -1200,39 +1156,44 @@ class UsersClient {
1200
1156
  */
1201
1157
  getById(id) {
1202
1158
  return lastValueFrom(
1203
- _request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
1159
+ _request(this.#client, this.#httpRequest, {
1204
1160
  uri: `/users/${id}`
1205
1161
  })
1206
1162
  );
1207
1163
  }
1208
1164
  }
1209
- _client2 = /* @__PURE__ */ new WeakMap(), _httpRequest2$1 = /* @__PURE__ */ new WeakMap();
1210
- var __defProp = Object.defineProperty, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField = (obj, key, value) => (__defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck = (obj, member, msg) => {
1211
- if (!member.has(obj))
1212
- throw TypeError("Cannot " + msg);
1213
- }, __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => {
1214
- if (member.has(obj))
1215
- throw TypeError("Cannot add the same private member more than once");
1216
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1217
- }, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), _clientConfig, _httpRequest;
1218
- const _ObservableSanityClient = class _ObservableSanityClient2 {
1165
+ class ObservableSanityClient {
1166
+ assets;
1167
+ datasets;
1168
+ live;
1169
+ projects;
1170
+ users;
1171
+ /**
1172
+ * Private properties
1173
+ */
1174
+ #clientConfig;
1175
+ #httpRequest;
1176
+ /**
1177
+ * Instance properties
1178
+ */
1179
+ listen = _listen;
1219
1180
  constructor(httpRequest, config = defaultConfig) {
1220
- __publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "live"), __publicField(this, "projects"), __publicField(this, "users"), __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest, httpRequest), this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest)), this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest)), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest)), this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
1181
+ this.config(config), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest);
1221
1182
  }
1222
1183
  /**
1223
1184
  * Clone the client - returns a new instance
1224
1185
  */
1225
1186
  clone() {
1226
- return new _ObservableSanityClient2(__privateGet(this, _httpRequest), this.config());
1187
+ return new ObservableSanityClient(this.#httpRequest, this.config());
1227
1188
  }
1228
1189
  config(newConfig) {
1229
1190
  if (newConfig === void 0)
1230
- return { ...__privateGet(this, _clientConfig) };
1231
- if (__privateGet(this, _clientConfig) && __privateGet(this, _clientConfig).allowReconfigure === !1)
1191
+ return { ...this.#clientConfig };
1192
+ if (this.#clientConfig && this.#clientConfig.allowReconfigure === !1)
1232
1193
  throw new Error(
1233
1194
  "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
1234
1195
  );
1235
- return __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {})), this;
1196
+ return this.#clientConfig = initConfig(newConfig, this.#clientConfig || {}), this;
1236
1197
  }
1237
1198
  /**
1238
1199
  * Clone the client with a new (partial) configuration.
@@ -1241,20 +1202,20 @@ const _ObservableSanityClient = class _ObservableSanityClient2 {
1241
1202
  */
1242
1203
  withConfig(newConfig) {
1243
1204
  const thisConfig = this.config();
1244
- return new _ObservableSanityClient2(__privateGet(this, _httpRequest), {
1205
+ return new ObservableSanityClient(this.#httpRequest, {
1245
1206
  ...thisConfig,
1246
1207
  ...newConfig,
1247
1208
  stega: {
1248
1209
  ...thisConfig.stega || {},
1249
- ...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
1210
+ ...typeof newConfig?.stega == "boolean" ? { enabled: newConfig.stega } : newConfig?.stega || {}
1250
1211
  }
1251
1212
  });
1252
1213
  }
1253
1214
  fetch(query, params, options) {
1254
1215
  return _fetch(
1255
1216
  this,
1256
- __privateGet(this, _httpRequest),
1257
- __privateGet(this, _clientConfig).stega,
1217
+ this.#httpRequest,
1218
+ this.#clientConfig.stega,
1258
1219
  query,
1259
1220
  params,
1260
1221
  options
@@ -1267,7 +1228,7 @@ const _ObservableSanityClient = class _ObservableSanityClient2 {
1267
1228
  * @param options - Request options
1268
1229
  */
1269
1230
  getDocument(id, options) {
1270
- return _getDocument(this, __privateGet(this, _httpRequest), id, options);
1231
+ return _getDocument(this, this.#httpRequest, id, options);
1271
1232
  }
1272
1233
  /**
1273
1234
  * Fetch multiple documents in one request.
@@ -1279,22 +1240,22 @@ const _ObservableSanityClient = class _ObservableSanityClient2 {
1279
1240
  * @param options - Request options
1280
1241
  */
1281
1242
  getDocuments(ids, options) {
1282
- return _getDocuments(this, __privateGet(this, _httpRequest), ids, options);
1243
+ return _getDocuments(this, this.#httpRequest, ids, options);
1283
1244
  }
1284
1245
  create(document, options) {
1285
- return _create(this, __privateGet(this, _httpRequest), document, "create", options);
1246
+ return _create(this, this.#httpRequest, document, "create", options);
1286
1247
  }
1287
1248
  createIfNotExists(document, options) {
1288
- return _createIfNotExists(this, __privateGet(this, _httpRequest), document, options);
1249
+ return _createIfNotExists(this, this.#httpRequest, document, options);
1289
1250
  }
1290
1251
  createOrReplace(document, options) {
1291
- return _createOrReplace(this, __privateGet(this, _httpRequest), document, options);
1252
+ return _createOrReplace(this, this.#httpRequest, document, options);
1292
1253
  }
1293
1254
  delete(selection, options) {
1294
- return _delete(this, __privateGet(this, _httpRequest), selection, options);
1255
+ return _delete(this, this.#httpRequest, selection, options);
1295
1256
  }
1296
1257
  mutate(operations, options) {
1297
- return _mutate(this, __privateGet(this, _httpRequest), operations, options);
1258
+ return _mutate(this, this.#httpRequest, operations, options);
1298
1259
  }
1299
1260
  /**
1300
1261
  * Create a new buildable patch of operations to perform
@@ -1321,7 +1282,7 @@ const _ObservableSanityClient = class _ObservableSanityClient2 {
1321
1282
  * @param options - Action options
1322
1283
  */
1323
1284
  action(operations, options) {
1324
- return _action(this, __privateGet(this, _httpRequest), operations, options);
1285
+ return _action(this, this.#httpRequest, operations, options);
1325
1286
  }
1326
1287
  /**
1327
1288
  * Perform an HTTP request against the Sanity API
@@ -1329,7 +1290,7 @@ const _ObservableSanityClient = class _ObservableSanityClient2 {
1329
1290
  * @param options - Request options
1330
1291
  */
1331
1292
  request(options) {
1332
- return _request(this, __privateGet(this, _httpRequest), options);
1293
+ return _request(this, this.#httpRequest, options);
1333
1294
  }
1334
1295
  /**
1335
1296
  * Get a Sanity API URL for the URI provided
@@ -1349,28 +1310,43 @@ const _ObservableSanityClient = class _ObservableSanityClient2 {
1349
1310
  getDataUrl(operation, path) {
1350
1311
  return _getDataUrl(this, operation, path);
1351
1312
  }
1352
- };
1353
- _clientConfig = /* @__PURE__ */ new WeakMap(), _httpRequest = /* @__PURE__ */ new WeakMap();
1354
- let ObservableSanityClient = _ObservableSanityClient;
1355
- var _clientConfig2, _httpRequest2;
1356
- const _SanityClient = class _SanityClient2 {
1313
+ }
1314
+ class SanityClient {
1315
+ assets;
1316
+ datasets;
1317
+ live;
1318
+ projects;
1319
+ users;
1320
+ /**
1321
+ * Observable version of the Sanity client, with the same configuration as the promise-based one
1322
+ */
1323
+ observable;
1324
+ /**
1325
+ * Private properties
1326
+ */
1327
+ #clientConfig;
1328
+ #httpRequest;
1329
+ /**
1330
+ * Instance properties
1331
+ */
1332
+ listen = _listen;
1357
1333
  constructor(httpRequest, config = defaultConfig) {
1358
- __publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "live"), __publicField(this, "projects"), __publicField(this, "users"), __publicField(this, "observable"), __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest2, httpRequest), this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2)), this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2)), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2)), this.users = new UsersClient(this, __privateGet(this, _httpRequest2)), this.observable = new ObservableSanityClient(httpRequest, config);
1334
+ this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config);
1359
1335
  }
1360
1336
  /**
1361
1337
  * Clone the client - returns a new instance
1362
1338
  */
1363
1339
  clone() {
1364
- return new _SanityClient2(__privateGet(this, _httpRequest2), this.config());
1340
+ return new SanityClient(this.#httpRequest, this.config());
1365
1341
  }
1366
1342
  config(newConfig) {
1367
1343
  if (newConfig === void 0)
1368
- return { ...__privateGet(this, _clientConfig2) };
1369
- if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === !1)
1344
+ return { ...this.#clientConfig };
1345
+ if (this.#clientConfig && this.#clientConfig.allowReconfigure === !1)
1370
1346
  throw new Error(
1371
1347
  "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client"
1372
1348
  );
1373
- return this.observable && this.observable.config(newConfig), __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {})), this;
1349
+ return this.observable && this.observable.config(newConfig), this.#clientConfig = initConfig(newConfig, this.#clientConfig || {}), this;
1374
1350
  }
1375
1351
  /**
1376
1352
  * Clone the client with a new (partial) configuration.
@@ -1379,12 +1355,12 @@ const _SanityClient = class _SanityClient2 {
1379
1355
  */
1380
1356
  withConfig(newConfig) {
1381
1357
  const thisConfig = this.config();
1382
- return new _SanityClient2(__privateGet(this, _httpRequest2), {
1358
+ return new SanityClient(this.#httpRequest, {
1383
1359
  ...thisConfig,
1384
1360
  ...newConfig,
1385
1361
  stega: {
1386
1362
  ...thisConfig.stega || {},
1387
- ...typeof (newConfig == null ? void 0 : newConfig.stega) == "boolean" ? { enabled: newConfig.stega } : (newConfig == null ? void 0 : newConfig.stega) || {}
1363
+ ...typeof newConfig?.stega == "boolean" ? { enabled: newConfig.stega } : newConfig?.stega || {}
1388
1364
  }
1389
1365
  });
1390
1366
  }
@@ -1392,8 +1368,8 @@ const _SanityClient = class _SanityClient2 {
1392
1368
  return lastValueFrom(
1393
1369
  _fetch(
1394
1370
  this,
1395
- __privateGet(this, _httpRequest2),
1396
- __privateGet(this, _clientConfig2).stega,
1371
+ this.#httpRequest,
1372
+ this.#clientConfig.stega,
1397
1373
  query,
1398
1374
  params,
1399
1375
  options
@@ -1407,7 +1383,7 @@ const _SanityClient = class _SanityClient2 {
1407
1383
  * @param options - Request options
1408
1384
  */
1409
1385
  getDocument(id, options) {
1410
- return lastValueFrom(_getDocument(this, __privateGet(this, _httpRequest2), id, options));
1386
+ return lastValueFrom(_getDocument(this, this.#httpRequest, id, options));
1411
1387
  }
1412
1388
  /**
1413
1389
  * Fetch multiple documents in one request.
@@ -1419,28 +1395,28 @@ const _SanityClient = class _SanityClient2 {
1419
1395
  * @param options - Request options
1420
1396
  */
1421
1397
  getDocuments(ids, options) {
1422
- return lastValueFrom(_getDocuments(this, __privateGet(this, _httpRequest2), ids, options));
1398
+ return lastValueFrom(_getDocuments(this, this.#httpRequest, ids, options));
1423
1399
  }
1424
1400
  create(document, options) {
1425
1401
  return lastValueFrom(
1426
- _create(this, __privateGet(this, _httpRequest2), document, "create", options)
1402
+ _create(this, this.#httpRequest, document, "create", options)
1427
1403
  );
1428
1404
  }
1429
1405
  createIfNotExists(document, options) {
1430
1406
  return lastValueFrom(
1431
- _createIfNotExists(this, __privateGet(this, _httpRequest2), document, options)
1407
+ _createIfNotExists(this, this.#httpRequest, document, options)
1432
1408
  );
1433
1409
  }
1434
1410
  createOrReplace(document, options) {
1435
1411
  return lastValueFrom(
1436
- _createOrReplace(this, __privateGet(this, _httpRequest2), document, options)
1412
+ _createOrReplace(this, this.#httpRequest, document, options)
1437
1413
  );
1438
1414
  }
1439
1415
  delete(selection, options) {
1440
- return lastValueFrom(_delete(this, __privateGet(this, _httpRequest2), selection, options));
1416
+ return lastValueFrom(_delete(this, this.#httpRequest, selection, options));
1441
1417
  }
1442
1418
  mutate(operations, options) {
1443
- return lastValueFrom(_mutate(this, __privateGet(this, _httpRequest2), operations, options));
1419
+ return lastValueFrom(_mutate(this, this.#httpRequest, operations, options));
1444
1420
  }
1445
1421
  /**
1446
1422
  * Create a new buildable patch of operations to perform
@@ -1468,7 +1444,7 @@ const _SanityClient = class _SanityClient2 {
1468
1444
  * @param options - Action options
1469
1445
  */
1470
1446
  action(operations, options) {
1471
- return lastValueFrom(_action(this, __privateGet(this, _httpRequest2), operations, options));
1447
+ return lastValueFrom(_action(this, this.#httpRequest, operations, options));
1472
1448
  }
1473
1449
  /**
1474
1450
  * Perform a request against the Sanity API
@@ -1478,7 +1454,7 @@ const _SanityClient = class _SanityClient2 {
1478
1454
  * @returns Promise resolving to the response body
1479
1455
  */
1480
1456
  request(options) {
1481
- return lastValueFrom(_request(this, __privateGet(this, _httpRequest2), options));
1457
+ return lastValueFrom(_request(this, this.#httpRequest, options));
1482
1458
  }
1483
1459
  /**
1484
1460
  * Perform an HTTP request a `/data` sub-endpoint
@@ -1491,7 +1467,7 @@ const _SanityClient = class _SanityClient2 {
1491
1467
  * @internal
1492
1468
  */
1493
1469
  dataRequest(endpoint, body, options) {
1494
- return lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
1470
+ return lastValueFrom(_dataRequest(this, this.#httpRequest, endpoint, body, options));
1495
1471
  }
1496
1472
  /**
1497
1473
  * Get a Sanity API URL for the URI provided
@@ -1511,9 +1487,7 @@ const _SanityClient = class _SanityClient2 {
1511
1487
  getDataUrl(operation, path) {
1512
1488
  return _getDataUrl(this, operation, path);
1513
1489
  }
1514
- };
1515
- _clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
1516
- let SanityClient = _SanityClient;
1490
+ }
1517
1491
  function defineCreateClientExports(envMiddleware, ClassConstructor) {
1518
1492
  const defaultRequester = defineHttpRequest(envMiddleware);
1519
1493
  return { requester: defaultRequester, createClient: (config) => new ClassConstructor(
@@ -1531,7 +1505,7 @@ function defineDeprecatedCreateClient(createClient2) {
1531
1505
  return printNoDefaultExport(), createClient2(config);
1532
1506
  };
1533
1507
  }
1534
- var name = "@sanity/client", version = "6.21.1";
1508
+ var name = "@sanity/client", version = "6.21.3-bundle-perspective";
1535
1509
  const middleware = [
1536
1510
  debug({ verbose: !0, namespace: "sanity:client" }),
1537
1511
  headers({ "User-Agent": `${name} ${version}` }),