@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/README.md +159 -0
- package/dist/index.browser.cjs +83 -17
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +83 -17
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +84 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +84 -18
- package/dist/index.js.map +1 -1
- package/package.json +18 -18
- package/src/data/dataMethods.ts +1 -1
- package/src/types.ts +9 -1
- package/umd/sanityClient.js +151 -85
- package/umd/sanityClient.min.js +3 -3
package/dist/index.browser.js
CHANGED
|
@@ -4,12 +4,26 @@ import { retry, jsonRequest, jsonResponse, progress, observable } from 'get-it/m
|
|
|
4
4
|
import { Observable, lastValueFrom } from 'rxjs';
|
|
5
5
|
import { map, filter } from 'rxjs/operators';
|
|
6
6
|
var envMiddleware = [];
|
|
7
|
+
var __defProp$3 = Object.defineProperty;
|
|
8
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value
|
|
13
|
+
}) : obj[key] = value;
|
|
14
|
+
var __publicField$3 = (obj, key, value) => {
|
|
15
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
16
|
+
return value;
|
|
17
|
+
};
|
|
7
18
|
const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
|
|
8
19
|
class ClientError extends Error {
|
|
9
20
|
constructor(res) {
|
|
10
21
|
const props = extractErrorProps(res);
|
|
11
22
|
super(props.message);
|
|
12
|
-
this
|
|
23
|
+
__publicField$3(this, "response");
|
|
24
|
+
__publicField$3(this, "statusCode", 400);
|
|
25
|
+
__publicField$3(this, "responseBody");
|
|
26
|
+
__publicField$3(this, "details");
|
|
13
27
|
Object.assign(this, props);
|
|
14
28
|
}
|
|
15
29
|
}
|
|
@@ -17,7 +31,10 @@ class ServerError extends Error {
|
|
|
17
31
|
constructor(res) {
|
|
18
32
|
const props = extractErrorProps(res);
|
|
19
33
|
super(props.message);
|
|
20
|
-
this
|
|
34
|
+
__publicField$3(this, "response");
|
|
35
|
+
__publicField$3(this, "statusCode", 500);
|
|
36
|
+
__publicField$3(this, "responseBody");
|
|
37
|
+
__publicField$3(this, "details");
|
|
21
38
|
Object.assign(this, props);
|
|
22
39
|
}
|
|
23
40
|
}
|
|
@@ -238,6 +255,17 @@ const encodeQueryString = _ref2 => {
|
|
|
238
255
|
}
|
|
239
256
|
return "?".concat(searchParams);
|
|
240
257
|
};
|
|
258
|
+
var __defProp$2 = Object.defineProperty;
|
|
259
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
|
|
260
|
+
enumerable: true,
|
|
261
|
+
configurable: true,
|
|
262
|
+
writable: true,
|
|
263
|
+
value
|
|
264
|
+
}) : obj[key] = value;
|
|
265
|
+
var __publicField$2 = (obj, key, value) => {
|
|
266
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
267
|
+
return value;
|
|
268
|
+
};
|
|
241
269
|
var __accessCheck$6 = (obj, member, msg) => {
|
|
242
270
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
243
271
|
};
|
|
@@ -258,6 +286,8 @@ var _client$5, _client2$5;
|
|
|
258
286
|
class BasePatch {
|
|
259
287
|
constructor(selection) {
|
|
260
288
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
289
|
+
__publicField$2(this, "selection");
|
|
290
|
+
__publicField$2(this, "operations");
|
|
261
291
|
this.selection = selection;
|
|
262
292
|
this.operations = operations;
|
|
263
293
|
}
|
|
@@ -411,7 +441,7 @@ class BasePatch {
|
|
|
411
441
|
return this._assign(op, props, false);
|
|
412
442
|
}
|
|
413
443
|
}
|
|
414
|
-
const _ObservablePatch = class extends BasePatch {
|
|
444
|
+
const _ObservablePatch = class _ObservablePatch extends BasePatch {
|
|
415
445
|
constructor(selection, operations, client) {
|
|
416
446
|
super(selection, operations);
|
|
417
447
|
__privateAdd$6(this, _client$5, void 0);
|
|
@@ -439,9 +469,9 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
439
469
|
}, opts);
|
|
440
470
|
}
|
|
441
471
|
};
|
|
442
|
-
let ObservablePatch = _ObservablePatch;
|
|
443
472
|
_client$5 = new WeakMap();
|
|
444
|
-
|
|
473
|
+
let ObservablePatch = _ObservablePatch;
|
|
474
|
+
const _Patch = class _Patch extends BasePatch {
|
|
445
475
|
constructor(selection, operations, client) {
|
|
446
476
|
super(selection, operations);
|
|
447
477
|
__privateAdd$6(this, _client2$5, void 0);
|
|
@@ -469,8 +499,19 @@ const _Patch = class extends BasePatch {
|
|
|
469
499
|
}, opts);
|
|
470
500
|
}
|
|
471
501
|
};
|
|
472
|
-
let Patch = _Patch;
|
|
473
502
|
_client2$5 = new WeakMap();
|
|
503
|
+
let Patch = _Patch;
|
|
504
|
+
var __defProp$1 = Object.defineProperty;
|
|
505
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
|
|
506
|
+
enumerable: true,
|
|
507
|
+
configurable: true,
|
|
508
|
+
writable: true,
|
|
509
|
+
value
|
|
510
|
+
}) : obj[key] = value;
|
|
511
|
+
var __publicField$1 = (obj, key, value) => {
|
|
512
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
513
|
+
return value;
|
|
514
|
+
};
|
|
474
515
|
var __accessCheck$5 = (obj, member, msg) => {
|
|
475
516
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
476
517
|
};
|
|
@@ -495,6 +536,8 @@ class BaseTransaction {
|
|
|
495
536
|
constructor() {
|
|
496
537
|
let operations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
497
538
|
let transactionId = arguments.length > 1 ? arguments[1] : undefined;
|
|
539
|
+
__publicField$1(this, "operations");
|
|
540
|
+
__publicField$1(this, "trxId");
|
|
498
541
|
this.operations = operations;
|
|
499
542
|
this.trxId = transactionId;
|
|
500
543
|
}
|
|
@@ -583,7 +626,7 @@ class BaseTransaction {
|
|
|
583
626
|
return this;
|
|
584
627
|
}
|
|
585
628
|
}
|
|
586
|
-
const _Transaction = class extends BaseTransaction {
|
|
629
|
+
const _Transaction = class _Transaction extends BaseTransaction {
|
|
587
630
|
constructor(operations, client, transactionId) {
|
|
588
631
|
super(operations, transactionId);
|
|
589
632
|
__privateAdd$5(this, _client$4, void 0);
|
|
@@ -628,9 +671,9 @@ const _Transaction = class extends BaseTransaction {
|
|
|
628
671
|
});
|
|
629
672
|
}
|
|
630
673
|
};
|
|
631
|
-
let Transaction = _Transaction;
|
|
632
674
|
_client$4 = new WeakMap();
|
|
633
|
-
|
|
675
|
+
let Transaction = _Transaction;
|
|
676
|
+
const _ObservableTransaction = class _ObservableTransaction extends BaseTransaction {
|
|
634
677
|
constructor(operations, client, transactionId) {
|
|
635
678
|
super(operations, transactionId);
|
|
636
679
|
__privateAdd$5(this, _client2$4, void 0);
|
|
@@ -675,8 +718,8 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
675
718
|
});
|
|
676
719
|
}
|
|
677
720
|
};
|
|
678
|
-
let ObservableTransaction = _ObservableTransaction;
|
|
679
721
|
_client2$4 = new WeakMap();
|
|
722
|
+
let ObservableTransaction = _ObservableTransaction;
|
|
680
723
|
const excludeFalsey = (param, defValue) => {
|
|
681
724
|
const value = typeof param === "undefined" ? defValue : param;
|
|
682
725
|
return param === false ? void 0 : value;
|
|
@@ -838,7 +881,7 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
838
881
|
...options.query
|
|
839
882
|
};
|
|
840
883
|
}
|
|
841
|
-
if (typeof config.perspective === "string" && config.perspective !== "
|
|
884
|
+
if (typeof config.perspective === "string" && config.perspective !== "raw") {
|
|
842
885
|
options.query = {
|
|
843
886
|
perspective: config.perspective,
|
|
844
887
|
...options.query
|
|
@@ -1489,6 +1532,17 @@ class UsersClient {
|
|
|
1489
1532
|
}
|
|
1490
1533
|
_client2 = new WeakMap();
|
|
1491
1534
|
_httpRequest2$1 = new WeakMap();
|
|
1535
|
+
var __defProp = Object.defineProperty;
|
|
1536
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
1537
|
+
enumerable: true,
|
|
1538
|
+
configurable: true,
|
|
1539
|
+
writable: true,
|
|
1540
|
+
value
|
|
1541
|
+
}) : obj[key] = value;
|
|
1542
|
+
var __publicField = (obj, key, value) => {
|
|
1543
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1544
|
+
return value;
|
|
1545
|
+
};
|
|
1492
1546
|
var __accessCheck = (obj, member, msg) => {
|
|
1493
1547
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
1494
1548
|
};
|
|
@@ -1506,9 +1560,13 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1506
1560
|
return value;
|
|
1507
1561
|
};
|
|
1508
1562
|
var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
|
|
1509
|
-
const _ObservableSanityClient = class {
|
|
1563
|
+
const _ObservableSanityClient = class _ObservableSanityClient {
|
|
1510
1564
|
constructor(httpRequest) {
|
|
1511
1565
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
|
|
1566
|
+
__publicField(this, "assets");
|
|
1567
|
+
__publicField(this, "datasets");
|
|
1568
|
+
__publicField(this, "projects");
|
|
1569
|
+
__publicField(this, "users");
|
|
1512
1570
|
/**
|
|
1513
1571
|
* Private properties
|
|
1514
1572
|
*/
|
|
@@ -1517,7 +1575,7 @@ const _ObservableSanityClient = class {
|
|
|
1517
1575
|
/**
|
|
1518
1576
|
* Instance properties
|
|
1519
1577
|
*/
|
|
1520
|
-
this
|
|
1578
|
+
__publicField(this, "listen", _listen);
|
|
1521
1579
|
this.config(config);
|
|
1522
1580
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1523
1581
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
@@ -1639,12 +1697,20 @@ const _ObservableSanityClient = class {
|
|
|
1639
1697
|
return _getDataUrl(this, operation, path);
|
|
1640
1698
|
}
|
|
1641
1699
|
};
|
|
1642
|
-
let ObservableSanityClient = _ObservableSanityClient;
|
|
1643
1700
|
_clientConfig = new WeakMap();
|
|
1644
1701
|
_httpRequest = new WeakMap();
|
|
1645
|
-
|
|
1702
|
+
let ObservableSanityClient = _ObservableSanityClient;
|
|
1703
|
+
const _SanityClient = class _SanityClient {
|
|
1646
1704
|
constructor(httpRequest) {
|
|
1647
1705
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
|
|
1706
|
+
__publicField(this, "assets");
|
|
1707
|
+
__publicField(this, "datasets");
|
|
1708
|
+
__publicField(this, "projects");
|
|
1709
|
+
__publicField(this, "users");
|
|
1710
|
+
/**
|
|
1711
|
+
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
1712
|
+
*/
|
|
1713
|
+
__publicField(this, "observable");
|
|
1648
1714
|
/**
|
|
1649
1715
|
* Private properties
|
|
1650
1716
|
*/
|
|
@@ -1653,7 +1719,7 @@ const _SanityClient = class {
|
|
|
1653
1719
|
/**
|
|
1654
1720
|
* Instance properties
|
|
1655
1721
|
*/
|
|
1656
|
-
this
|
|
1722
|
+
__publicField(this, "listen", _listen);
|
|
1657
1723
|
this.config(config);
|
|
1658
1724
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1659
1725
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
@@ -1793,9 +1859,9 @@ const _SanityClient = class {
|
|
|
1793
1859
|
return _getDataUrl(this, operation, path);
|
|
1794
1860
|
}
|
|
1795
1861
|
};
|
|
1796
|
-
let SanityClient = _SanityClient;
|
|
1797
1862
|
_clientConfig2 = new WeakMap();
|
|
1798
1863
|
_httpRequest2 = new WeakMap();
|
|
1864
|
+
let SanityClient = _SanityClient;
|
|
1799
1865
|
const httpRequest = defineHttpRequest(envMiddleware, {});
|
|
1800
1866
|
const requester = httpRequest.defaultRequester;
|
|
1801
1867
|
const createClient = config => new SanityClient(defineHttpRequest(envMiddleware, {
|