@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.
@@ -196,42 +196,29 @@ var encodeQueryString = _ref => {
196
196
  return options[option] ? "".concat(qs, "&").concat(enc(option), "=").concat(enc(options[option])) : qs;
197
197
  }, qString);
198
198
  };
199
- var __accessCheck$7 = (obj, member, msg) => {
199
+ var __accessCheck$6 = (obj, member, msg) => {
200
200
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
201
201
  };
202
- var __privateGet$7 = (obj, member, getter) => {
203
- __accessCheck$7(obj, member, "read from private field");
202
+ var __privateGet$6 = (obj, member, getter) => {
203
+ __accessCheck$6(obj, member, "read from private field");
204
204
  return getter ? getter.call(obj) : member.get(obj);
205
205
  };
206
- var __privateAdd$7 = (obj, member, value) => {
206
+ var __privateAdd$6 = (obj, member, value) => {
207
207
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
208
208
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
209
209
  };
210
- var __privateSet$7 = (obj, member, value, setter) => {
211
- __accessCheck$7(obj, member, "write to private field");
210
+ var __privateSet$6 = (obj, member, value, setter) => {
211
+ __accessCheck$6(obj, member, "write to private field");
212
212
  setter ? setter.call(obj, value) : member.set(obj, value);
213
213
  return value;
214
214
  };
215
- var _client$6, _client2$6;
215
+ var _client$5, _client2$5;
216
216
  class BasePatch {
217
217
  constructor(selection) {
218
218
  let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
219
219
  this.selection = selection;
220
220
  this.operations = operations;
221
221
  }
222
- /**
223
- * DEPRECATED: Don't use.
224
- * The operation is added to the current patch, ready to be commited by `commit()`
225
- *
226
- * @deprecated - Don't use.
227
- * @param attrs - Attributes to replace
228
- */
229
- replace(attrs) {
230
- validateObject("replace", attrs);
231
- return this._set("set", {
232
- $: attrs
233
- });
234
- }
235
222
  /**
236
223
  * Sets the given attributes to the document. Does NOT merge objects.
237
224
  * The operation is added to the current patch, ready to be commited by `commit()`
@@ -385,8 +372,8 @@ class BasePatch {
385
372
  const _ObservablePatch = class extends BasePatch {
386
373
  constructor(selection, operations, client) {
387
374
  super(selection, operations);
388
- __privateAdd$7(this, _client$6, void 0);
389
- __privateSet$7(this, _client$6, client);
375
+ __privateAdd$6(this, _client$5, void 0);
376
+ __privateSet$6(this, _client$5, client);
390
377
  }
391
378
  /**
392
379
  * Clones the patch
@@ -394,10 +381,10 @@ const _ObservablePatch = class extends BasePatch {
394
381
  clone() {
395
382
  return new _ObservablePatch(this.selection, {
396
383
  ...this.operations
397
- }, __privateGet$7(this, _client$6));
384
+ }, __privateGet$6(this, _client$5));
398
385
  }
399
386
  commit(options) {
400
- if (!__privateGet$7(this, _client$6)) {
387
+ if (!__privateGet$6(this, _client$5)) {
401
388
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
402
389
  }
403
390
  const returnFirst = typeof this.selection === "string";
@@ -405,18 +392,18 @@ const _ObservablePatch = class extends BasePatch {
405
392
  returnFirst,
406
393
  returnDocuments: true
407
394
  }, options);
408
- return __privateGet$7(this, _client$6).mutate({
395
+ return __privateGet$6(this, _client$5).mutate({
409
396
  patch: this.serialize()
410
397
  }, opts);
411
398
  }
412
399
  };
413
400
  let ObservablePatch = _ObservablePatch;
414
- _client$6 = new WeakMap();
401
+ _client$5 = new WeakMap();
415
402
  const _Patch = class extends BasePatch {
416
403
  constructor(selection, operations, client) {
417
404
  super(selection, operations);
418
- __privateAdd$7(this, _client2$6, void 0);
419
- __privateSet$7(this, _client2$6, client);
405
+ __privateAdd$6(this, _client2$5, void 0);
406
+ __privateSet$6(this, _client2$5, client);
420
407
  }
421
408
  /**
422
409
  * Clones the patch
@@ -424,10 +411,10 @@ const _Patch = class extends BasePatch {
424
411
  clone() {
425
412
  return new _Patch(this.selection, {
426
413
  ...this.operations
427
- }, __privateGet$7(this, _client2$6));
414
+ }, __privateGet$6(this, _client2$5));
428
415
  }
429
416
  commit(options) {
430
- if (!__privateGet$7(this, _client2$6)) {
417
+ if (!__privateGet$6(this, _client2$5)) {
431
418
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
432
419
  }
433
420
  const returnFirst = typeof this.selection === "string";
@@ -435,30 +422,30 @@ const _Patch = class extends BasePatch {
435
422
  returnFirst,
436
423
  returnDocuments: true
437
424
  }, options);
438
- return __privateGet$7(this, _client2$6).mutate({
425
+ return __privateGet$6(this, _client2$5).mutate({
439
426
  patch: this.serialize()
440
427
  }, opts);
441
428
  }
442
429
  };
443
430
  let Patch = _Patch;
444
- _client2$6 = new WeakMap();
445
- var __accessCheck$6 = (obj, member, msg) => {
431
+ _client2$5 = new WeakMap();
432
+ var __accessCheck$5 = (obj, member, msg) => {
446
433
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
447
434
  };
448
- var __privateGet$6 = (obj, member, getter) => {
449
- __accessCheck$6(obj, member, "read from private field");
435
+ var __privateGet$5 = (obj, member, getter) => {
436
+ __accessCheck$5(obj, member, "read from private field");
450
437
  return getter ? getter.call(obj) : member.get(obj);
451
438
  };
452
- var __privateAdd$6 = (obj, member, value) => {
439
+ var __privateAdd$5 = (obj, member, value) => {
453
440
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
454
441
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
455
442
  };
456
- var __privateSet$6 = (obj, member, value, setter) => {
457
- __accessCheck$6(obj, member, "write to private field");
443
+ var __privateSet$5 = (obj, member, value, setter) => {
444
+ __accessCheck$5(obj, member, "write to private field");
458
445
  setter ? setter.call(obj, value) : member.set(obj, value);
459
446
  return value;
460
447
  };
461
- var _client$5, _client2$5;
448
+ var _client$4, _client2$4;
462
449
  const defaultMutateOptions = {
463
450
  returnDocuments: false
464
451
  };
@@ -557,20 +544,20 @@ class BaseTransaction {
557
544
  const _Transaction = class extends BaseTransaction {
558
545
  constructor(operations, client, transactionId) {
559
546
  super(operations, transactionId);
560
- __privateAdd$6(this, _client$5, void 0);
561
- __privateSet$6(this, _client$5, client);
547
+ __privateAdd$5(this, _client$4, void 0);
548
+ __privateSet$5(this, _client$4, client);
562
549
  }
563
550
  /**
564
551
  * Clones the transaction
565
552
  */
566
553
  clone() {
567
- return new _Transaction([...this.operations], __privateGet$6(this, _client$5), this.trxId);
554
+ return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
568
555
  }
569
556
  commit(options) {
570
- if (!__privateGet$6(this, _client$5)) {
557
+ if (!__privateGet$5(this, _client$4)) {
571
558
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
572
559
  }
573
- return __privateGet$6(this, _client$5).mutate(this.serialize(), Object.assign({
560
+ return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
574
561
  transactionId: this.trxId
575
562
  }, defaultMutateOptions, options || {}));
576
563
  }
@@ -583,7 +570,7 @@ const _Transaction = class extends BaseTransaction {
583
570
  });
584
571
  }
585
572
  if (isBuilder) {
586
- const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
573
+ const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
587
574
  if (!(patch instanceof Patch)) {
588
575
  throw new Error("function passed to `patch()` must return the patch");
589
576
  }
@@ -600,24 +587,24 @@ const _Transaction = class extends BaseTransaction {
600
587
  }
601
588
  };
602
589
  let Transaction = _Transaction;
603
- _client$5 = new WeakMap();
590
+ _client$4 = new WeakMap();
604
591
  const _ObservableTransaction = class extends BaseTransaction {
605
592
  constructor(operations, client, transactionId) {
606
593
  super(operations, transactionId);
607
- __privateAdd$6(this, _client2$5, void 0);
608
- __privateSet$6(this, _client2$5, client);
594
+ __privateAdd$5(this, _client2$4, void 0);
595
+ __privateSet$5(this, _client2$4, client);
609
596
  }
610
597
  /**
611
598
  * Clones the transaction
612
599
  */
613
600
  clone() {
614
- return new _ObservableTransaction([...this.operations], __privateGet$6(this, _client2$5), this.trxId);
601
+ return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
615
602
  }
616
603
  commit(options) {
617
- if (!__privateGet$6(this, _client2$5)) {
604
+ if (!__privateGet$5(this, _client2$4)) {
618
605
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
619
606
  }
620
- return __privateGet$6(this, _client2$5).mutate(this.serialize(), Object.assign({
607
+ return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
621
608
  transactionId: this.trxId
622
609
  }, defaultMutateOptions, options || {}));
623
610
  }
@@ -630,7 +617,7 @@ const _ObservableTransaction = class extends BaseTransaction {
630
617
  });
631
618
  }
632
619
  if (isBuilder) {
633
- const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$5)));
620
+ const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
634
621
  if (!(patch instanceof ObservablePatch)) {
635
622
  throw new Error("function passed to `patch()` must return the patch");
636
623
  }
@@ -647,7 +634,7 @@ const _ObservableTransaction = class extends BaseTransaction {
647
634
  }
648
635
  };
649
636
  let ObservableTransaction = _ObservableTransaction;
650
- _client2$5 = new WeakMap();
637
+ _client2$4 = new WeakMap();
651
638
  const excludeFalsey = (param, defValue) => {
652
639
  const value = typeof param === "undefined" ? defValue : param;
653
640
  return param === false ? void 0 : value;
@@ -819,50 +806,50 @@ function _getUrl(client, uri) {
819
806
  const base = canUseCdn ? cdnUrl : url;
820
807
  return "".concat(base, "/").concat(uri.replace(/^\//, ""));
821
808
  }
822
- var __accessCheck$5 = (obj, member, msg) => {
809
+ var __accessCheck$4 = (obj, member, msg) => {
823
810
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
824
811
  };
825
- var __privateGet$5 = (obj, member, getter) => {
826
- __accessCheck$5(obj, member, "read from private field");
812
+ var __privateGet$4 = (obj, member, getter) => {
813
+ __accessCheck$4(obj, member, "read from private field");
827
814
  return getter ? getter.call(obj) : member.get(obj);
828
815
  };
829
- var __privateAdd$5 = (obj, member, value) => {
816
+ var __privateAdd$4 = (obj, member, value) => {
830
817
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
831
818
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
832
819
  };
833
- var __privateSet$5 = (obj, member, value, setter) => {
834
- __accessCheck$5(obj, member, "write to private field");
820
+ var __privateSet$4 = (obj, member, value, setter) => {
821
+ __accessCheck$4(obj, member, "write to private field");
835
822
  setter ? setter.call(obj, value) : member.set(obj, value);
836
823
  return value;
837
824
  };
838
- var _client$4, _httpRequest$5, _client2$4, _httpRequest2$5;
825
+ var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
839
826
  class ObservableAssetsClient {
840
827
  constructor(client, httpRequest) {
841
- __privateAdd$5(this, _client$4, void 0);
842
- __privateAdd$5(this, _httpRequest$5, void 0);
843
- __privateSet$5(this, _client$4, client);
844
- __privateSet$5(this, _httpRequest$5, httpRequest);
828
+ __privateAdd$4(this, _client$3, void 0);
829
+ __privateAdd$4(this, _httpRequest$4, void 0);
830
+ __privateSet$4(this, _client$3, client);
831
+ __privateSet$4(this, _httpRequest$4, httpRequest);
845
832
  }
846
833
  upload(assetType, body, options) {
847
- return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$5), assetType, body, options);
834
+ return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
848
835
  }
849
836
  }
850
- _client$4 = new WeakMap();
851
- _httpRequest$5 = new WeakMap();
837
+ _client$3 = new WeakMap();
838
+ _httpRequest$4 = new WeakMap();
852
839
  class AssetsClient {
853
840
  constructor(client, httpRequest) {
854
- __privateAdd$5(this, _client2$4, void 0);
855
- __privateAdd$5(this, _httpRequest2$5, void 0);
856
- __privateSet$5(this, _client2$4, client);
857
- __privateSet$5(this, _httpRequest2$5, httpRequest);
841
+ __privateAdd$4(this, _client2$3, void 0);
842
+ __privateAdd$4(this, _httpRequest2$4, void 0);
843
+ __privateSet$4(this, _client2$3, client);
844
+ __privateSet$4(this, _httpRequest2$4, httpRequest);
858
845
  }
859
846
  upload(assetType, body, options) {
860
- const observable = _upload(__privateGet$5(this, _client2$4), __privateGet$5(this, _httpRequest2$5), assetType, body, options);
847
+ const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
861
848
  return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
862
849
  }
863
850
  }
864
- _client2$4 = new WeakMap();
865
- _httpRequest2$5 = new WeakMap();
851
+ _client2$3 = new WeakMap();
852
+ _httpRequest2$4 = new WeakMap();
866
853
  function _upload(client, httpRequest, assetType, body) {
867
854
  let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
868
855
  validateAssetType(assetType);
@@ -916,77 +903,6 @@ function optionsFromFile(opts, file) {
916
903
  contentType: file.type
917
904
  }, opts);
918
905
  }
919
- var __accessCheck$4 = (obj, member, msg) => {
920
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
921
- };
922
- var __privateGet$4 = (obj, member, getter) => {
923
- __accessCheck$4(obj, member, "read from private field");
924
- return getter ? getter.call(obj) : member.get(obj);
925
- };
926
- var __privateAdd$4 = (obj, member, value) => {
927
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
928
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
929
- };
930
- var __privateSet$4 = (obj, member, value, setter) => {
931
- __accessCheck$4(obj, member, "write to private field");
932
- setter ? setter.call(obj, value) : member.set(obj, value);
933
- return value;
934
- };
935
- var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
936
- class ObservableAuthClient {
937
- constructor(client, httpRequest) {
938
- __privateAdd$4(this, _client$3, void 0);
939
- __privateAdd$4(this, _httpRequest$4, void 0);
940
- __privateSet$4(this, _client$3, client);
941
- __privateSet$4(this, _httpRequest$4, httpRequest);
942
- }
943
- /**
944
- * Fetch available login providers
945
- */
946
- getLoginProviders() {
947
- return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
948
- uri: "/auth/providers"
949
- });
950
- }
951
- /**
952
- * Revoke the configured session/token
953
- */
954
- logout() {
955
- return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
956
- uri: "/auth/logout",
957
- method: "POST"
958
- });
959
- }
960
- }
961
- _client$3 = new WeakMap();
962
- _httpRequest$4 = new WeakMap();
963
- class AuthClient {
964
- constructor(client, httpRequest) {
965
- __privateAdd$4(this, _client2$3, void 0);
966
- __privateAdd$4(this, _httpRequest2$4, void 0);
967
- __privateSet$4(this, _client2$3, client);
968
- __privateSet$4(this, _httpRequest2$4, httpRequest);
969
- }
970
- /**
971
- * Fetch available login providers
972
- */
973
- getLoginProviders() {
974
- return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
975
- uri: "/auth/providers"
976
- }));
977
- }
978
- /**
979
- * Revoke the configured session/token
980
- */
981
- logout() {
982
- return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
983
- uri: "/auth/logout",
984
- method: "POST"
985
- }));
986
- }
987
- }
988
- _client2$3 = new WeakMap();
989
- _httpRequest2$4 = new WeakMap();
990
906
  const BASE_URL = "https://www.sanity.io/help/";
991
907
  function generateHelpUrl(slug) {
992
908
  return BASE_URL + slug;
@@ -1492,7 +1408,6 @@ const _ObservableSanityClient = class {
1492
1408
  this.config(config);
1493
1409
  __privateSet(this, _httpRequest, httpRequest);
1494
1410
  this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
1495
- this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
1496
1411
  this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
1497
1412
  this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
1498
1413
  this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
@@ -1611,7 +1526,6 @@ const _SanityClient = class {
1611
1526
  this.config(config);
1612
1527
  __privateSet(this, _httpRequest2, httpRequest);
1613
1528
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
1614
- this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
1615
1529
  this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
1616
1530
  this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
1617
1531
  this.users = new UsersClient(this, __privateGet(this, _httpRequest2));