@sanity/client 5.0.0-esm.13 → 5.0.0-esm.14

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.cjs CHANGED
@@ -15,7 +15,7 @@ function _interopDefaultCompat(e) {
15
15
  }
16
16
  var polyfilledEventSource__default = /*#__PURE__*/_interopDefaultCompat(polyfilledEventSource);
17
17
  var name = "@sanity/client";
18
- var version = "5.0.0-esm.13";
18
+ var version = "5.0.0-esm.14";
19
19
  const middleware = [middleware$1.debug({
20
20
  verbose: true,
21
21
  namespace: "sanity:client"
@@ -216,42 +216,29 @@ var encodeQueryString = _ref => {
216
216
  return options[option] ? "".concat(qs, "&").concat(enc(option), "=").concat(enc(options[option])) : qs;
217
217
  }, qString);
218
218
  };
219
- var __accessCheck$7 = (obj, member, msg) => {
219
+ var __accessCheck$6 = (obj, member, msg) => {
220
220
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
221
221
  };
222
- var __privateGet$7 = (obj, member, getter) => {
223
- __accessCheck$7(obj, member, "read from private field");
222
+ var __privateGet$6 = (obj, member, getter) => {
223
+ __accessCheck$6(obj, member, "read from private field");
224
224
  return getter ? getter.call(obj) : member.get(obj);
225
225
  };
226
- var __privateAdd$7 = (obj, member, value) => {
226
+ var __privateAdd$6 = (obj, member, value) => {
227
227
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
228
228
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
229
229
  };
230
- var __privateSet$7 = (obj, member, value, setter) => {
231
- __accessCheck$7(obj, member, "write to private field");
230
+ var __privateSet$6 = (obj, member, value, setter) => {
231
+ __accessCheck$6(obj, member, "write to private field");
232
232
  setter ? setter.call(obj, value) : member.set(obj, value);
233
233
  return value;
234
234
  };
235
- var _client$6, _client2$6;
235
+ var _client$5, _client2$5;
236
236
  class BasePatch {
237
237
  constructor(selection) {
238
238
  let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
239
239
  this.selection = selection;
240
240
  this.operations = operations;
241
241
  }
242
- /**
243
- * DEPRECATED: Don't use.
244
- * The operation is added to the current patch, ready to be commited by `commit()`
245
- *
246
- * @deprecated - Don't use.
247
- * @param attrs - Attributes to replace
248
- */
249
- replace(attrs) {
250
- validateObject("replace", attrs);
251
- return this._set("set", {
252
- $: attrs
253
- });
254
- }
255
242
  /**
256
243
  * Sets the given attributes to the document. Does NOT merge objects.
257
244
  * The operation is added to the current patch, ready to be commited by `commit()`
@@ -405,8 +392,8 @@ class BasePatch {
405
392
  const _ObservablePatch = class extends BasePatch {
406
393
  constructor(selection, operations, client) {
407
394
  super(selection, operations);
408
- __privateAdd$7(this, _client$6, void 0);
409
- __privateSet$7(this, _client$6, client);
395
+ __privateAdd$6(this, _client$5, void 0);
396
+ __privateSet$6(this, _client$5, client);
410
397
  }
411
398
  /**
412
399
  * Clones the patch
@@ -414,10 +401,10 @@ const _ObservablePatch = class extends BasePatch {
414
401
  clone() {
415
402
  return new _ObservablePatch(this.selection, {
416
403
  ...this.operations
417
- }, __privateGet$7(this, _client$6));
404
+ }, __privateGet$6(this, _client$5));
418
405
  }
419
406
  commit(options) {
420
- if (!__privateGet$7(this, _client$6)) {
407
+ if (!__privateGet$6(this, _client$5)) {
421
408
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
422
409
  }
423
410
  const returnFirst = typeof this.selection === "string";
@@ -425,18 +412,18 @@ const _ObservablePatch = class extends BasePatch {
425
412
  returnFirst,
426
413
  returnDocuments: true
427
414
  }, options);
428
- return __privateGet$7(this, _client$6).mutate({
415
+ return __privateGet$6(this, _client$5).mutate({
429
416
  patch: this.serialize()
430
417
  }, opts);
431
418
  }
432
419
  };
433
420
  let ObservablePatch = _ObservablePatch;
434
- _client$6 = new WeakMap();
421
+ _client$5 = new WeakMap();
435
422
  const _Patch = class extends BasePatch {
436
423
  constructor(selection, operations, client) {
437
424
  super(selection, operations);
438
- __privateAdd$7(this, _client2$6, void 0);
439
- __privateSet$7(this, _client2$6, client);
425
+ __privateAdd$6(this, _client2$5, void 0);
426
+ __privateSet$6(this, _client2$5, client);
440
427
  }
441
428
  /**
442
429
  * Clones the patch
@@ -444,10 +431,10 @@ const _Patch = class extends BasePatch {
444
431
  clone() {
445
432
  return new _Patch(this.selection, {
446
433
  ...this.operations
447
- }, __privateGet$7(this, _client2$6));
434
+ }, __privateGet$6(this, _client2$5));
448
435
  }
449
436
  commit(options) {
450
- if (!__privateGet$7(this, _client2$6)) {
437
+ if (!__privateGet$6(this, _client2$5)) {
451
438
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
452
439
  }
453
440
  const returnFirst = typeof this.selection === "string";
@@ -455,30 +442,30 @@ const _Patch = class extends BasePatch {
455
442
  returnFirst,
456
443
  returnDocuments: true
457
444
  }, options);
458
- return __privateGet$7(this, _client2$6).mutate({
445
+ return __privateGet$6(this, _client2$5).mutate({
459
446
  patch: this.serialize()
460
447
  }, opts);
461
448
  }
462
449
  };
463
450
  let Patch = _Patch;
464
- _client2$6 = new WeakMap();
465
- var __accessCheck$6 = (obj, member, msg) => {
451
+ _client2$5 = new WeakMap();
452
+ var __accessCheck$5 = (obj, member, msg) => {
466
453
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
467
454
  };
468
- var __privateGet$6 = (obj, member, getter) => {
469
- __accessCheck$6(obj, member, "read from private field");
455
+ var __privateGet$5 = (obj, member, getter) => {
456
+ __accessCheck$5(obj, member, "read from private field");
470
457
  return getter ? getter.call(obj) : member.get(obj);
471
458
  };
472
- var __privateAdd$6 = (obj, member, value) => {
459
+ var __privateAdd$5 = (obj, member, value) => {
473
460
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
474
461
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
475
462
  };
476
- var __privateSet$6 = (obj, member, value, setter) => {
477
- __accessCheck$6(obj, member, "write to private field");
463
+ var __privateSet$5 = (obj, member, value, setter) => {
464
+ __accessCheck$5(obj, member, "write to private field");
478
465
  setter ? setter.call(obj, value) : member.set(obj, value);
479
466
  return value;
480
467
  };
481
- var _client$5, _client2$5;
468
+ var _client$4, _client2$4;
482
469
  const defaultMutateOptions = {
483
470
  returnDocuments: false
484
471
  };
@@ -577,20 +564,20 @@ class BaseTransaction {
577
564
  const _Transaction = class extends BaseTransaction {
578
565
  constructor(operations, client, transactionId) {
579
566
  super(operations, transactionId);
580
- __privateAdd$6(this, _client$5, void 0);
581
- __privateSet$6(this, _client$5, client);
567
+ __privateAdd$5(this, _client$4, void 0);
568
+ __privateSet$5(this, _client$4, client);
582
569
  }
583
570
  /**
584
571
  * Clones the transaction
585
572
  */
586
573
  clone() {
587
- return new _Transaction([...this.operations], __privateGet$6(this, _client$5), this.trxId);
574
+ return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
588
575
  }
589
576
  commit(options) {
590
- if (!__privateGet$6(this, _client$5)) {
577
+ if (!__privateGet$5(this, _client$4)) {
591
578
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
592
579
  }
593
- return __privateGet$6(this, _client$5).mutate(this.serialize(), Object.assign({
580
+ return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
594
581
  transactionId: this.trxId
595
582
  }, defaultMutateOptions, options || {}));
596
583
  }
@@ -603,7 +590,7 @@ const _Transaction = class extends BaseTransaction {
603
590
  });
604
591
  }
605
592
  if (isBuilder) {
606
- const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
593
+ const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
607
594
  if (!(patch instanceof Patch)) {
608
595
  throw new Error("function passed to `patch()` must return the patch");
609
596
  }
@@ -620,24 +607,24 @@ const _Transaction = class extends BaseTransaction {
620
607
  }
621
608
  };
622
609
  let Transaction = _Transaction;
623
- _client$5 = new WeakMap();
610
+ _client$4 = new WeakMap();
624
611
  const _ObservableTransaction = class extends BaseTransaction {
625
612
  constructor(operations, client, transactionId) {
626
613
  super(operations, transactionId);
627
- __privateAdd$6(this, _client2$5, void 0);
628
- __privateSet$6(this, _client2$5, client);
614
+ __privateAdd$5(this, _client2$4, void 0);
615
+ __privateSet$5(this, _client2$4, client);
629
616
  }
630
617
  /**
631
618
  * Clones the transaction
632
619
  */
633
620
  clone() {
634
- return new _ObservableTransaction([...this.operations], __privateGet$6(this, _client2$5), this.trxId);
621
+ return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
635
622
  }
636
623
  commit(options) {
637
- if (!__privateGet$6(this, _client2$5)) {
624
+ if (!__privateGet$5(this, _client2$4)) {
638
625
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
639
626
  }
640
- return __privateGet$6(this, _client2$5).mutate(this.serialize(), Object.assign({
627
+ return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
641
628
  transactionId: this.trxId
642
629
  }, defaultMutateOptions, options || {}));
643
630
  }
@@ -650,7 +637,7 @@ const _ObservableTransaction = class extends BaseTransaction {
650
637
  });
651
638
  }
652
639
  if (isBuilder) {
653
- const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$5)));
640
+ const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
654
641
  if (!(patch instanceof ObservablePatch)) {
655
642
  throw new Error("function passed to `patch()` must return the patch");
656
643
  }
@@ -667,7 +654,7 @@ const _ObservableTransaction = class extends BaseTransaction {
667
654
  }
668
655
  };
669
656
  let ObservableTransaction = _ObservableTransaction;
670
- _client2$5 = new WeakMap();
657
+ _client2$4 = new WeakMap();
671
658
  const excludeFalsey = (param, defValue) => {
672
659
  const value = typeof param === "undefined" ? defValue : param;
673
660
  return param === false ? void 0 : value;
@@ -839,50 +826,50 @@ function _getUrl(client, uri) {
839
826
  const base = canUseCdn ? cdnUrl : url;
840
827
  return "".concat(base, "/").concat(uri.replace(/^\//, ""));
841
828
  }
842
- var __accessCheck$5 = (obj, member, msg) => {
829
+ var __accessCheck$4 = (obj, member, msg) => {
843
830
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
844
831
  };
845
- var __privateGet$5 = (obj, member, getter) => {
846
- __accessCheck$5(obj, member, "read from private field");
832
+ var __privateGet$4 = (obj, member, getter) => {
833
+ __accessCheck$4(obj, member, "read from private field");
847
834
  return getter ? getter.call(obj) : member.get(obj);
848
835
  };
849
- var __privateAdd$5 = (obj, member, value) => {
836
+ var __privateAdd$4 = (obj, member, value) => {
850
837
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
851
838
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
852
839
  };
853
- var __privateSet$5 = (obj, member, value, setter) => {
854
- __accessCheck$5(obj, member, "write to private field");
840
+ var __privateSet$4 = (obj, member, value, setter) => {
841
+ __accessCheck$4(obj, member, "write to private field");
855
842
  setter ? setter.call(obj, value) : member.set(obj, value);
856
843
  return value;
857
844
  };
858
- var _client$4, _httpRequest$5, _client2$4, _httpRequest2$5;
845
+ var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
859
846
  class ObservableAssetsClient {
860
847
  constructor(client, httpRequest) {
861
- __privateAdd$5(this, _client$4, void 0);
862
- __privateAdd$5(this, _httpRequest$5, void 0);
863
- __privateSet$5(this, _client$4, client);
864
- __privateSet$5(this, _httpRequest$5, httpRequest);
848
+ __privateAdd$4(this, _client$3, void 0);
849
+ __privateAdd$4(this, _httpRequest$4, void 0);
850
+ __privateSet$4(this, _client$3, client);
851
+ __privateSet$4(this, _httpRequest$4, httpRequest);
865
852
  }
866
853
  upload(assetType, body, options) {
867
- return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$5), assetType, body, options);
854
+ return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
868
855
  }
869
856
  }
870
- _client$4 = new WeakMap();
871
- _httpRequest$5 = new WeakMap();
857
+ _client$3 = new WeakMap();
858
+ _httpRequest$4 = new WeakMap();
872
859
  class AssetsClient {
873
860
  constructor(client, httpRequest) {
874
- __privateAdd$5(this, _client2$4, void 0);
875
- __privateAdd$5(this, _httpRequest2$5, void 0);
876
- __privateSet$5(this, _client2$4, client);
877
- __privateSet$5(this, _httpRequest2$5, httpRequest);
861
+ __privateAdd$4(this, _client2$3, void 0);
862
+ __privateAdd$4(this, _httpRequest2$4, void 0);
863
+ __privateSet$4(this, _client2$3, client);
864
+ __privateSet$4(this, _httpRequest2$4, httpRequest);
878
865
  }
879
866
  upload(assetType, body, options) {
880
- const observable = _upload(__privateGet$5(this, _client2$4), __privateGet$5(this, _httpRequest2$5), assetType, body, options);
867
+ const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
881
868
  return rxjs.lastValueFrom(observable.pipe(operators.filter(event => event.type === "response"), operators.map(event => event.body.document)));
882
869
  }
883
870
  }
884
- _client2$4 = new WeakMap();
885
- _httpRequest2$5 = new WeakMap();
871
+ _client2$3 = new WeakMap();
872
+ _httpRequest2$4 = new WeakMap();
886
873
  function _upload(client, httpRequest, assetType, body) {
887
874
  let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
888
875
  validateAssetType(assetType);
@@ -936,77 +923,6 @@ function optionsFromFile(opts, file) {
936
923
  contentType: file.type
937
924
  }, opts);
938
925
  }
939
- var __accessCheck$4 = (obj, member, msg) => {
940
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
941
- };
942
- var __privateGet$4 = (obj, member, getter) => {
943
- __accessCheck$4(obj, member, "read from private field");
944
- return getter ? getter.call(obj) : member.get(obj);
945
- };
946
- var __privateAdd$4 = (obj, member, value) => {
947
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
948
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
949
- };
950
- var __privateSet$4 = (obj, member, value, setter) => {
951
- __accessCheck$4(obj, member, "write to private field");
952
- setter ? setter.call(obj, value) : member.set(obj, value);
953
- return value;
954
- };
955
- var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
956
- class ObservableAuthClient {
957
- constructor(client, httpRequest) {
958
- __privateAdd$4(this, _client$3, void 0);
959
- __privateAdd$4(this, _httpRequest$4, void 0);
960
- __privateSet$4(this, _client$3, client);
961
- __privateSet$4(this, _httpRequest$4, httpRequest);
962
- }
963
- /**
964
- * Fetch available login providers
965
- */
966
- getLoginProviders() {
967
- return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
968
- uri: "/auth/providers"
969
- });
970
- }
971
- /**
972
- * Revoke the configured session/token
973
- */
974
- logout() {
975
- return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
976
- uri: "/auth/logout",
977
- method: "POST"
978
- });
979
- }
980
- }
981
- _client$3 = new WeakMap();
982
- _httpRequest$4 = new WeakMap();
983
- class AuthClient {
984
- constructor(client, httpRequest) {
985
- __privateAdd$4(this, _client2$3, void 0);
986
- __privateAdd$4(this, _httpRequest2$4, void 0);
987
- __privateSet$4(this, _client2$3, client);
988
- __privateSet$4(this, _httpRequest2$4, httpRequest);
989
- }
990
- /**
991
- * Fetch available login providers
992
- */
993
- getLoginProviders() {
994
- return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
995
- uri: "/auth/providers"
996
- }));
997
- }
998
- /**
999
- * Revoke the configured session/token
1000
- */
1001
- logout() {
1002
- return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
1003
- uri: "/auth/logout",
1004
- method: "POST"
1005
- }));
1006
- }
1007
- }
1008
- _client2$3 = new WeakMap();
1009
- _httpRequest2$4 = new WeakMap();
1010
926
  const BASE_URL = "https://www.sanity.io/help/";
1011
927
  function generateHelpUrl(slug) {
1012
928
  return BASE_URL + slug;
@@ -1512,7 +1428,6 @@ const _ObservableSanityClient = class {
1512
1428
  this.config(config);
1513
1429
  __privateSet(this, _httpRequest, httpRequest);
1514
1430
  this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
1515
- this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
1516
1431
  this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
1517
1432
  this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
1518
1433
  this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
@@ -1631,7 +1546,6 @@ const _SanityClient = class {
1631
1546
  this.config(config);
1632
1547
  __privateSet(this, _httpRequest2, httpRequest);
1633
1548
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
1634
- this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
1635
1549
  this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
1636
1550
  this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
1637
1551
  this.users = new UsersClient(this, __privateGet(this, _httpRequest2));