@sanity/client 5.0.0-esm.3 → 5.0.0-esm.4
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 +442 -17
- package/dist/index.browser.cjs +9 -7
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +9 -7
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +10 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +297 -213
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/package.json +24 -21
- package/src/SanityClient.ts +172 -167
- package/src/assets/AssetsClient.ts +14 -12
- package/src/auth/AuthClient.ts +2 -0
- package/src/config.ts +2 -2
- package/src/data/dataMethods.ts +4 -1
- package/src/data/listen.ts +6 -6
- package/src/data/patch.ts +34 -31
- package/src/data/transaction.ts +5 -0
- package/src/datasets/DatasetsClient.ts +2 -0
- package/src/http/errors.ts +2 -0
- package/src/http/request.ts +1 -3
- package/src/index.browser.ts +3 -3
- package/src/index.ts +3 -42
- package/src/projects/ProjectsClient.ts +2 -0
- package/src/types.ts +60 -0
- package/src/users/UsersClient.ts +2 -2
- package/src/validators.ts +4 -2
- package/umd/sanityClient.js +5449 -5470
- package/umd/sanityClient.min.js +12 -12
package/dist/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ function _interopDefaultCompat(e) {
|
|
|
16
16
|
}
|
|
17
17
|
var polyfilledEventSource__default = /*#__PURE__*/_interopDefaultCompat(polyfilledEventSource);
|
|
18
18
|
var name = "@sanity/client";
|
|
19
|
-
var version = "5.0.0-esm.
|
|
19
|
+
var version = "5.0.0-esm.4";
|
|
20
20
|
const middleware = [middleware$1.debug({
|
|
21
21
|
verbose: true,
|
|
22
22
|
namespace: "sanity:client"
|
|
@@ -1294,7 +1294,8 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
1294
1294
|
};
|
|
1295
1295
|
var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
|
|
1296
1296
|
const _ObservableSanityClient = class {
|
|
1297
|
-
constructor(httpRequest
|
|
1297
|
+
constructor(httpRequest) {
|
|
1298
|
+
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
|
|
1298
1299
|
__privateAdd(this, _clientConfig, void 0);
|
|
1299
1300
|
__privateAdd(this, _httpRequest, void 0);
|
|
1300
1301
|
this.config(config);
|
|
@@ -1365,11 +1366,11 @@ let ObservableSanityClient = _ObservableSanityClient;
|
|
|
1365
1366
|
_clientConfig = new WeakMap();
|
|
1366
1367
|
_httpRequest = new WeakMap();
|
|
1367
1368
|
const _SanityClient = class {
|
|
1368
|
-
constructor(httpRequest
|
|
1369
|
+
constructor(httpRequest) {
|
|
1370
|
+
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
|
|
1369
1371
|
__privateAdd(this, _clientConfig2, void 0);
|
|
1370
1372
|
__privateAdd(this, _httpRequest2, void 0);
|
|
1371
1373
|
this.listen = _listen;
|
|
1372
|
-
this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1373
1374
|
this.config(config);
|
|
1374
1375
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1375
1376
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
@@ -1377,6 +1378,7 @@ const _SanityClient = class {
|
|
|
1377
1378
|
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
1378
1379
|
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
1379
1380
|
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|
|
1381
|
+
this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1380
1382
|
}
|
|
1381
1383
|
clone() {
|
|
1382
1384
|
return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
|
|
@@ -1390,7 +1392,9 @@ const _SanityClient = class {
|
|
|
1390
1392
|
if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
|
|
1391
1393
|
throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
|
|
1392
1394
|
}
|
|
1393
|
-
this.observable
|
|
1395
|
+
if (this.observable) {
|
|
1396
|
+
this.observable.config(newConfig);
|
|
1397
|
+
}
|
|
1394
1398
|
__privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {}));
|
|
1395
1399
|
return this;
|
|
1396
1400
|
}
|
|
@@ -1443,9 +1447,7 @@ _clientConfig2 = new WeakMap();
|
|
|
1443
1447
|
_httpRequest2 = new WeakMap();
|
|
1444
1448
|
const httpRequest = defineHttpRequest(middleware);
|
|
1445
1449
|
const requester = httpRequest.defaultRequester;
|
|
1446
|
-
|
|
1447
|
-
return new SanityClient(httpRequest, config);
|
|
1448
|
-
}
|
|
1450
|
+
const createClient = config => new SanityClient(httpRequest, config);
|
|
1449
1451
|
exports.BasePatch = BasePatch;
|
|
1450
1452
|
exports.BaseTransaction = BaseTransaction;
|
|
1451
1453
|
exports.ClientError = ClientError;
|