@sanity/client 6.1.3 → 6.2.0-fetch.0
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.browser.cjs +97 -18
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +97 -18
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +98 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +98 -19
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/data/dataMethods.ts +7 -1
- package/src/types.ts +8 -2
- package/umd/sanityClient.js +147 -69
- package/umd/sanityClient.min.js +3 -3
package/dist/index.browser.cjs
CHANGED
|
@@ -8,12 +8,26 @@ var middleware = require('get-it/middleware');
|
|
|
8
8
|
var rxjs = require('rxjs');
|
|
9
9
|
var operators = require('rxjs/operators');
|
|
10
10
|
var envMiddleware = [];
|
|
11
|
+
var __defProp$3 = Object.defineProperty;
|
|
12
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value
|
|
17
|
+
}) : obj[key] = value;
|
|
18
|
+
var __publicField$3 = (obj, key, value) => {
|
|
19
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
11
22
|
const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
|
|
12
23
|
class ClientError extends Error {
|
|
13
24
|
constructor(res) {
|
|
14
25
|
const props = extractErrorProps(res);
|
|
15
26
|
super(props.message);
|
|
16
|
-
this
|
|
27
|
+
__publicField$3(this, "response");
|
|
28
|
+
__publicField$3(this, "statusCode", 400);
|
|
29
|
+
__publicField$3(this, "responseBody");
|
|
30
|
+
__publicField$3(this, "details");
|
|
17
31
|
Object.assign(this, props);
|
|
18
32
|
}
|
|
19
33
|
}
|
|
@@ -21,7 +35,10 @@ class ServerError extends Error {
|
|
|
21
35
|
constructor(res) {
|
|
22
36
|
const props = extractErrorProps(res);
|
|
23
37
|
super(props.message);
|
|
24
|
-
this
|
|
38
|
+
__publicField$3(this, "response");
|
|
39
|
+
__publicField$3(this, "statusCode", 500);
|
|
40
|
+
__publicField$3(this, "responseBody");
|
|
41
|
+
__publicField$3(this, "details");
|
|
25
42
|
Object.assign(this, props);
|
|
26
43
|
}
|
|
27
44
|
}
|
|
@@ -242,6 +259,17 @@ const encodeQueryString = _ref2 => {
|
|
|
242
259
|
}
|
|
243
260
|
return "?".concat(searchParams);
|
|
244
261
|
};
|
|
262
|
+
var __defProp$2 = Object.defineProperty;
|
|
263
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
|
|
264
|
+
enumerable: true,
|
|
265
|
+
configurable: true,
|
|
266
|
+
writable: true,
|
|
267
|
+
value
|
|
268
|
+
}) : obj[key] = value;
|
|
269
|
+
var __publicField$2 = (obj, key, value) => {
|
|
270
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
271
|
+
return value;
|
|
272
|
+
};
|
|
245
273
|
var __accessCheck$6 = (obj, member, msg) => {
|
|
246
274
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
247
275
|
};
|
|
@@ -262,6 +290,8 @@ var _client$5, _client2$5;
|
|
|
262
290
|
class BasePatch {
|
|
263
291
|
constructor(selection) {
|
|
264
292
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
293
|
+
__publicField$2(this, "selection");
|
|
294
|
+
__publicField$2(this, "operations");
|
|
265
295
|
this.selection = selection;
|
|
266
296
|
this.operations = operations;
|
|
267
297
|
}
|
|
@@ -415,7 +445,7 @@ class BasePatch {
|
|
|
415
445
|
return this._assign(op, props, false);
|
|
416
446
|
}
|
|
417
447
|
}
|
|
418
|
-
const _ObservablePatch = class extends BasePatch {
|
|
448
|
+
const _ObservablePatch = class _ObservablePatch extends BasePatch {
|
|
419
449
|
constructor(selection, operations, client) {
|
|
420
450
|
super(selection, operations);
|
|
421
451
|
__privateAdd$6(this, _client$5, void 0);
|
|
@@ -443,9 +473,9 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
443
473
|
}, opts);
|
|
444
474
|
}
|
|
445
475
|
};
|
|
446
|
-
let ObservablePatch = _ObservablePatch;
|
|
447
476
|
_client$5 = new WeakMap();
|
|
448
|
-
|
|
477
|
+
let ObservablePatch = _ObservablePatch;
|
|
478
|
+
const _Patch = class _Patch extends BasePatch {
|
|
449
479
|
constructor(selection, operations, client) {
|
|
450
480
|
super(selection, operations);
|
|
451
481
|
__privateAdd$6(this, _client2$5, void 0);
|
|
@@ -473,8 +503,19 @@ const _Patch = class extends BasePatch {
|
|
|
473
503
|
}, opts);
|
|
474
504
|
}
|
|
475
505
|
};
|
|
476
|
-
let Patch = _Patch;
|
|
477
506
|
_client2$5 = new WeakMap();
|
|
507
|
+
let Patch = _Patch;
|
|
508
|
+
var __defProp$1 = Object.defineProperty;
|
|
509
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
|
|
510
|
+
enumerable: true,
|
|
511
|
+
configurable: true,
|
|
512
|
+
writable: true,
|
|
513
|
+
value
|
|
514
|
+
}) : obj[key] = value;
|
|
515
|
+
var __publicField$1 = (obj, key, value) => {
|
|
516
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
517
|
+
return value;
|
|
518
|
+
};
|
|
478
519
|
var __accessCheck$5 = (obj, member, msg) => {
|
|
479
520
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
480
521
|
};
|
|
@@ -499,6 +540,8 @@ class BaseTransaction {
|
|
|
499
540
|
constructor() {
|
|
500
541
|
let operations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
501
542
|
let transactionId = arguments.length > 1 ? arguments[1] : undefined;
|
|
543
|
+
__publicField$1(this, "operations");
|
|
544
|
+
__publicField$1(this, "trxId");
|
|
502
545
|
this.operations = operations;
|
|
503
546
|
this.trxId = transactionId;
|
|
504
547
|
}
|
|
@@ -587,7 +630,7 @@ class BaseTransaction {
|
|
|
587
630
|
return this;
|
|
588
631
|
}
|
|
589
632
|
}
|
|
590
|
-
const _Transaction = class extends BaseTransaction {
|
|
633
|
+
const _Transaction = class _Transaction extends BaseTransaction {
|
|
591
634
|
constructor(operations, client, transactionId) {
|
|
592
635
|
super(operations, transactionId);
|
|
593
636
|
__privateAdd$5(this, _client$4, void 0);
|
|
@@ -632,9 +675,9 @@ const _Transaction = class extends BaseTransaction {
|
|
|
632
675
|
});
|
|
633
676
|
}
|
|
634
677
|
};
|
|
635
|
-
let Transaction = _Transaction;
|
|
636
678
|
_client$4 = new WeakMap();
|
|
637
|
-
|
|
679
|
+
let Transaction = _Transaction;
|
|
680
|
+
const _ObservableTransaction = class _ObservableTransaction extends BaseTransaction {
|
|
638
681
|
constructor(operations, client, transactionId) {
|
|
639
682
|
super(operations, transactionId);
|
|
640
683
|
__privateAdd$5(this, _client2$4, void 0);
|
|
@@ -679,8 +722,8 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
679
722
|
});
|
|
680
723
|
}
|
|
681
724
|
};
|
|
682
|
-
let ObservableTransaction = _ObservableTransaction;
|
|
683
725
|
_client2$4 = new WeakMap();
|
|
726
|
+
let ObservableTransaction = _ObservableTransaction;
|
|
684
727
|
const excludeFalsey = (param, defValue) => {
|
|
685
728
|
const value = typeof param === "undefined" ? defValue : param;
|
|
686
729
|
return param === false ? void 0 : value;
|
|
@@ -706,10 +749,22 @@ const getQuerySizeLimit = 11264;
|
|
|
706
749
|
function _fetch(client, httpRequest, query, params) {
|
|
707
750
|
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
708
751
|
const mapResponse = options.filterResponse === false ? res => res : res => res.result;
|
|
752
|
+
const {
|
|
753
|
+
cache,
|
|
754
|
+
next,
|
|
755
|
+
...opts
|
|
756
|
+
} = options;
|
|
757
|
+
const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? {
|
|
758
|
+
...opts,
|
|
759
|
+
fetch: {
|
|
760
|
+
cache,
|
|
761
|
+
next
|
|
762
|
+
}
|
|
763
|
+
} : opts;
|
|
709
764
|
return _dataRequest(client, httpRequest, "query", {
|
|
710
765
|
query,
|
|
711
766
|
params
|
|
712
|
-
},
|
|
767
|
+
}, reqOpts).pipe(operators.map(mapResponse));
|
|
713
768
|
}
|
|
714
769
|
function _getDocument(client, httpRequest, id) {
|
|
715
770
|
let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
@@ -791,7 +846,8 @@ function _dataRequest(client, httpRequest, endpoint, body) {
|
|
|
791
846
|
token,
|
|
792
847
|
tag,
|
|
793
848
|
canUseCdn: isQuery,
|
|
794
|
-
signal: options.signal
|
|
849
|
+
signal: options.signal,
|
|
850
|
+
fetch: options.fetch
|
|
795
851
|
};
|
|
796
852
|
return _requestObservable(client, httpRequest, reqOptions).pipe(operators.filter(isResponse), operators.map(getBody), operators.map(res => {
|
|
797
853
|
if (!isMutation) {
|
|
@@ -1493,6 +1549,17 @@ class UsersClient {
|
|
|
1493
1549
|
}
|
|
1494
1550
|
_client2 = new WeakMap();
|
|
1495
1551
|
_httpRequest2$1 = new WeakMap();
|
|
1552
|
+
var __defProp = Object.defineProperty;
|
|
1553
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
1554
|
+
enumerable: true,
|
|
1555
|
+
configurable: true,
|
|
1556
|
+
writable: true,
|
|
1557
|
+
value
|
|
1558
|
+
}) : obj[key] = value;
|
|
1559
|
+
var __publicField = (obj, key, value) => {
|
|
1560
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1561
|
+
return value;
|
|
1562
|
+
};
|
|
1496
1563
|
var __accessCheck = (obj, member, msg) => {
|
|
1497
1564
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
1498
1565
|
};
|
|
@@ -1510,9 +1577,13 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1510
1577
|
return value;
|
|
1511
1578
|
};
|
|
1512
1579
|
var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
|
|
1513
|
-
const _ObservableSanityClient = class {
|
|
1580
|
+
const _ObservableSanityClient = class _ObservableSanityClient {
|
|
1514
1581
|
constructor(httpRequest) {
|
|
1515
1582
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
|
|
1583
|
+
__publicField(this, "assets");
|
|
1584
|
+
__publicField(this, "datasets");
|
|
1585
|
+
__publicField(this, "projects");
|
|
1586
|
+
__publicField(this, "users");
|
|
1516
1587
|
/**
|
|
1517
1588
|
* Private properties
|
|
1518
1589
|
*/
|
|
@@ -1521,7 +1592,7 @@ const _ObservableSanityClient = class {
|
|
|
1521
1592
|
/**
|
|
1522
1593
|
* Instance properties
|
|
1523
1594
|
*/
|
|
1524
|
-
this
|
|
1595
|
+
__publicField(this, "listen", _listen);
|
|
1525
1596
|
this.config(config);
|
|
1526
1597
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1527
1598
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
@@ -1643,12 +1714,20 @@ const _ObservableSanityClient = class {
|
|
|
1643
1714
|
return _getDataUrl(this, operation, path);
|
|
1644
1715
|
}
|
|
1645
1716
|
};
|
|
1646
|
-
let ObservableSanityClient = _ObservableSanityClient;
|
|
1647
1717
|
_clientConfig = new WeakMap();
|
|
1648
1718
|
_httpRequest = new WeakMap();
|
|
1649
|
-
|
|
1719
|
+
let ObservableSanityClient = _ObservableSanityClient;
|
|
1720
|
+
const _SanityClient = class _SanityClient {
|
|
1650
1721
|
constructor(httpRequest) {
|
|
1651
1722
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
|
|
1723
|
+
__publicField(this, "assets");
|
|
1724
|
+
__publicField(this, "datasets");
|
|
1725
|
+
__publicField(this, "projects");
|
|
1726
|
+
__publicField(this, "users");
|
|
1727
|
+
/**
|
|
1728
|
+
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1729
|
+
*/
|
|
1730
|
+
__publicField(this, "observable");
|
|
1652
1731
|
/**
|
|
1653
1732
|
* Private properties
|
|
1654
1733
|
*/
|
|
@@ -1657,7 +1736,7 @@ const _SanityClient = class {
|
|
|
1657
1736
|
/**
|
|
1658
1737
|
* Instance properties
|
|
1659
1738
|
*/
|
|
1660
|
-
this
|
|
1739
|
+
__publicField(this, "listen", _listen);
|
|
1661
1740
|
this.config(config);
|
|
1662
1741
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1663
1742
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
@@ -1797,9 +1876,9 @@ const _SanityClient = class {
|
|
|
1797
1876
|
return _getDataUrl(this, operation, path);
|
|
1798
1877
|
}
|
|
1799
1878
|
};
|
|
1800
|
-
let SanityClient = _SanityClient;
|
|
1801
1879
|
_clientConfig2 = new WeakMap();
|
|
1802
1880
|
_httpRequest2 = new WeakMap();
|
|
1881
|
+
let SanityClient = _SanityClient;
|
|
1803
1882
|
const httpRequest = defineHttpRequest(envMiddleware, {});
|
|
1804
1883
|
const requester = httpRequest.defaultRequester;
|
|
1805
1884
|
const createClient = config => new SanityClient(defineHttpRequest(envMiddleware, {
|