@sanity/client 6.1.2 → 6.1.3-perspective.1

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
@@ -8,19 +8,33 @@ var getIt = require('get-it');
8
8
  var rxjs = require('rxjs');
9
9
  var operators = require('rxjs/operators');
10
10
  var name = "@sanity/client";
11
- var version = "6.1.2";
11
+ var version = "6.1.3-perspective.1";
12
12
  const middleware = [middleware$1.debug({
13
13
  verbose: true,
14
14
  namespace: "sanity:client"
15
15
  }), middleware$1.headers({
16
16
  "User-Agent": "".concat(name, " ").concat(version)
17
17
  })];
18
+ var __defProp$3 = Object.defineProperty;
19
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value
24
+ }) : obj[key] = value;
25
+ var __publicField$3 = (obj, key, value) => {
26
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
27
+ return value;
28
+ };
18
29
  const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
19
30
  class ClientError extends Error {
20
31
  constructor(res) {
21
32
  const props = extractErrorProps(res);
22
33
  super(props.message);
23
- this.statusCode = 400;
34
+ __publicField$3(this, "response");
35
+ __publicField$3(this, "statusCode", 400);
36
+ __publicField$3(this, "responseBody");
37
+ __publicField$3(this, "details");
24
38
  Object.assign(this, props);
25
39
  }
26
40
  }
@@ -28,7 +42,10 @@ class ServerError extends Error {
28
42
  constructor(res) {
29
43
  const props = extractErrorProps(res);
30
44
  super(props.message);
31
- this.statusCode = 500;
45
+ __publicField$3(this, "response");
46
+ __publicField$3(this, "statusCode", 500);
47
+ __publicField$3(this, "responseBody");
48
+ __publicField$3(this, "details");
32
49
  Object.assign(this, props);
33
50
  }
34
51
  }
@@ -249,6 +266,17 @@ const encodeQueryString = _ref2 => {
249
266
  }
250
267
  return "?".concat(searchParams);
251
268
  };
269
+ var __defProp$2 = Object.defineProperty;
270
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
271
+ enumerable: true,
272
+ configurable: true,
273
+ writable: true,
274
+ value
275
+ }) : obj[key] = value;
276
+ var __publicField$2 = (obj, key, value) => {
277
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
278
+ return value;
279
+ };
252
280
  var __accessCheck$6 = (obj, member, msg) => {
253
281
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
254
282
  };
@@ -269,6 +297,8 @@ var _client$5, _client2$5;
269
297
  class BasePatch {
270
298
  constructor(selection) {
271
299
  let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
300
+ __publicField$2(this, "selection");
301
+ __publicField$2(this, "operations");
272
302
  this.selection = selection;
273
303
  this.operations = operations;
274
304
  }
@@ -422,7 +452,7 @@ class BasePatch {
422
452
  return this._assign(op, props, false);
423
453
  }
424
454
  }
425
- const _ObservablePatch = class extends BasePatch {
455
+ const _ObservablePatch = class _ObservablePatch extends BasePatch {
426
456
  constructor(selection, operations, client) {
427
457
  super(selection, operations);
428
458
  __privateAdd$6(this, _client$5, void 0);
@@ -450,9 +480,9 @@ const _ObservablePatch = class extends BasePatch {
450
480
  }, opts);
451
481
  }
452
482
  };
453
- let ObservablePatch = _ObservablePatch;
454
483
  _client$5 = new WeakMap();
455
- const _Patch = class extends BasePatch {
484
+ let ObservablePatch = _ObservablePatch;
485
+ const _Patch = class _Patch extends BasePatch {
456
486
  constructor(selection, operations, client) {
457
487
  super(selection, operations);
458
488
  __privateAdd$6(this, _client2$5, void 0);
@@ -480,8 +510,19 @@ const _Patch = class extends BasePatch {
480
510
  }, opts);
481
511
  }
482
512
  };
483
- let Patch = _Patch;
484
513
  _client2$5 = new WeakMap();
514
+ let Patch = _Patch;
515
+ var __defProp$1 = Object.defineProperty;
516
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
517
+ enumerable: true,
518
+ configurable: true,
519
+ writable: true,
520
+ value
521
+ }) : obj[key] = value;
522
+ var __publicField$1 = (obj, key, value) => {
523
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
524
+ return value;
525
+ };
485
526
  var __accessCheck$5 = (obj, member, msg) => {
486
527
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
487
528
  };
@@ -506,6 +547,8 @@ class BaseTransaction {
506
547
  constructor() {
507
548
  let operations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
508
549
  let transactionId = arguments.length > 1 ? arguments[1] : undefined;
550
+ __publicField$1(this, "operations");
551
+ __publicField$1(this, "trxId");
509
552
  this.operations = operations;
510
553
  this.trxId = transactionId;
511
554
  }
@@ -594,7 +637,7 @@ class BaseTransaction {
594
637
  return this;
595
638
  }
596
639
  }
597
- const _Transaction = class extends BaseTransaction {
640
+ const _Transaction = class _Transaction extends BaseTransaction {
598
641
  constructor(operations, client, transactionId) {
599
642
  super(operations, transactionId);
600
643
  __privateAdd$5(this, _client$4, void 0);
@@ -639,9 +682,9 @@ const _Transaction = class extends BaseTransaction {
639
682
  });
640
683
  }
641
684
  };
642
- let Transaction = _Transaction;
643
685
  _client$4 = new WeakMap();
644
- const _ObservableTransaction = class extends BaseTransaction {
686
+ let Transaction = _Transaction;
687
+ const _ObservableTransaction = class _ObservableTransaction extends BaseTransaction {
645
688
  constructor(operations, client, transactionId) {
646
689
  super(operations, transactionId);
647
690
  __privateAdd$5(this, _client2$4, void 0);
@@ -686,8 +729,8 @@ const _ObservableTransaction = class extends BaseTransaction {
686
729
  });
687
730
  }
688
731
  };
689
- let ObservableTransaction = _ObservableTransaction;
690
732
  _client2$4 = new WeakMap();
733
+ let ObservableTransaction = _ObservableTransaction;
691
734
  const excludeFalsey = (param, defValue) => {
692
735
  const value = typeof param === "undefined" ? defValue : param;
693
736
  return param === false ? void 0 : value;
@@ -849,7 +892,7 @@ function _requestObservable(client, httpRequest, options) {
849
892
  ...options.query
850
893
  };
851
894
  }
852
- if (typeof config.perspective === "string" && config.perspective !== "all") {
895
+ if (typeof config.perspective === "string" && config.perspective !== "raw") {
853
896
  options.query = {
854
897
  perspective: config.perspective,
855
898
  ...options.query
@@ -1500,6 +1543,17 @@ class UsersClient {
1500
1543
  }
1501
1544
  _client2 = new WeakMap();
1502
1545
  _httpRequest2$1 = new WeakMap();
1546
+ var __defProp = Object.defineProperty;
1547
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
1548
+ enumerable: true,
1549
+ configurable: true,
1550
+ writable: true,
1551
+ value
1552
+ }) : obj[key] = value;
1553
+ var __publicField = (obj, key, value) => {
1554
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1555
+ return value;
1556
+ };
1503
1557
  var __accessCheck = (obj, member, msg) => {
1504
1558
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
1505
1559
  };
@@ -1517,9 +1571,13 @@ var __privateSet = (obj, member, value, setter) => {
1517
1571
  return value;
1518
1572
  };
1519
1573
  var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
1520
- const _ObservableSanityClient = class {
1574
+ const _ObservableSanityClient = class _ObservableSanityClient {
1521
1575
  constructor(httpRequest) {
1522
1576
  let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
1577
+ __publicField(this, "assets");
1578
+ __publicField(this, "datasets");
1579
+ __publicField(this, "projects");
1580
+ __publicField(this, "users");
1523
1581
  /**
1524
1582
  * Private properties
1525
1583
  */
@@ -1528,7 +1586,7 @@ const _ObservableSanityClient = class {
1528
1586
  /**
1529
1587
  * Instance properties
1530
1588
  */
1531
- this.listen = _listen;
1589
+ __publicField(this, "listen", _listen);
1532
1590
  this.config(config);
1533
1591
  __privateSet(this, _httpRequest, httpRequest);
1534
1592
  this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
@@ -1650,12 +1708,20 @@ const _ObservableSanityClient = class {
1650
1708
  return _getDataUrl(this, operation, path);
1651
1709
  }
1652
1710
  };
1653
- let ObservableSanityClient = _ObservableSanityClient;
1654
1711
  _clientConfig = new WeakMap();
1655
1712
  _httpRequest = new WeakMap();
1656
- const _SanityClient = class {
1713
+ let ObservableSanityClient = _ObservableSanityClient;
1714
+ const _SanityClient = class _SanityClient {
1657
1715
  constructor(httpRequest) {
1658
1716
  let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
1717
+ __publicField(this, "assets");
1718
+ __publicField(this, "datasets");
1719
+ __publicField(this, "projects");
1720
+ __publicField(this, "users");
1721
+ /**
1722
+ * Observable version of the Sanity client, with the same configuration as the promise-based one
1723
+ */
1724
+ __publicField(this, "observable");
1659
1725
  /**
1660
1726
  * Private properties
1661
1727
  */
@@ -1664,7 +1730,7 @@ const _SanityClient = class {
1664
1730
  /**
1665
1731
  * Instance properties
1666
1732
  */
1667
- this.listen = _listen;
1733
+ __publicField(this, "listen", _listen);
1668
1734
  this.config(config);
1669
1735
  __privateSet(this, _httpRequest2, httpRequest);
1670
1736
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
@@ -1804,9 +1870,9 @@ const _SanityClient = class {
1804
1870
  return _getDataUrl(this, operation, path);
1805
1871
  }
1806
1872
  };
1807
- let SanityClient = _SanityClient;
1808
1873
  _clientConfig2 = new WeakMap();
1809
1874
  _httpRequest2 = new WeakMap();
1875
+ let SanityClient = _SanityClient;
1810
1876
  const httpRequest = defineHttpRequest(middleware, {});
1811
1877
  const requester = httpRequest.defaultRequester;
1812
1878
  const createClient = config => new SanityClient(defineHttpRequest(middleware, {