@sanity/client 5.0.0-esm.1 → 5.0.0-esm.3
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 +244 -170
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +244 -170
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +245 -171
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +128 -154
- package/dist/index.js +245 -171
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/SanityClient.ts +11 -77
- package/src/auth/AuthClient.ts +13 -9
- package/src/data/dataMethods.ts +29 -4
- package/src/data/listen.ts +4 -3
- package/src/datasets/DatasetsClient.ts +73 -57
- package/src/projects/ProjectsClient.ts +37 -23
- package/src/users/UsersClient.ts +37 -28
- package/umd/sanityClient.js +244 -170
- package/umd/sanityClient.min.js +3 -3
package/umd/sanityClient.js
CHANGED
|
@@ -4312,23 +4312,23 @@
|
|
|
4312
4312
|
return options[option] ? "".concat(qs, "&").concat(enc(option), "=").concat(enc(options[option])) : qs;
|
|
4313
4313
|
}, qString);
|
|
4314
4314
|
};
|
|
4315
|
-
var __accessCheck$
|
|
4315
|
+
var __accessCheck$7 = (obj, member, msg) => {
|
|
4316
4316
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
4317
4317
|
};
|
|
4318
|
-
var __privateGet$
|
|
4319
|
-
__accessCheck$
|
|
4318
|
+
var __privateGet$7 = (obj, member, getter) => {
|
|
4319
|
+
__accessCheck$7(obj, member, "read from private field");
|
|
4320
4320
|
return getter ? getter.call(obj) : member.get(obj);
|
|
4321
4321
|
};
|
|
4322
|
-
var __privateAdd$
|
|
4322
|
+
var __privateAdd$7 = (obj, member, value) => {
|
|
4323
4323
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
4324
4324
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
4325
4325
|
};
|
|
4326
|
-
var __privateSet$
|
|
4327
|
-
__accessCheck$
|
|
4326
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
|
4327
|
+
__accessCheck$7(obj, member, "write to private field");
|
|
4328
4328
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
4329
4329
|
return value;
|
|
4330
4330
|
};
|
|
4331
|
-
var _client$
|
|
4331
|
+
var _client$6, _client2$6;
|
|
4332
4332
|
class BasePatch {
|
|
4333
4333
|
constructor(selection) {
|
|
4334
4334
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -4419,16 +4419,16 @@
|
|
|
4419
4419
|
const _ObservablePatch = class extends BasePatch {
|
|
4420
4420
|
constructor(selection, operations, client) {
|
|
4421
4421
|
super(selection, operations);
|
|
4422
|
-
__privateAdd$
|
|
4423
|
-
__privateSet$
|
|
4422
|
+
__privateAdd$7(this, _client$6, void 0);
|
|
4423
|
+
__privateSet$7(this, _client$6, client);
|
|
4424
4424
|
}
|
|
4425
4425
|
clone() {
|
|
4426
4426
|
return new _ObservablePatch(this.selection, {
|
|
4427
4427
|
...this.operations
|
|
4428
|
-
}, __privateGet$
|
|
4428
|
+
}, __privateGet$7(this, _client$6));
|
|
4429
4429
|
}
|
|
4430
4430
|
commit(options) {
|
|
4431
|
-
if (!__privateGet$
|
|
4431
|
+
if (!__privateGet$7(this, _client$6)) {
|
|
4432
4432
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
4433
4433
|
}
|
|
4434
4434
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -4436,26 +4436,26 @@
|
|
|
4436
4436
|
returnFirst,
|
|
4437
4437
|
returnDocuments: true
|
|
4438
4438
|
}, options);
|
|
4439
|
-
return __privateGet$
|
|
4439
|
+
return __privateGet$7(this, _client$6).mutate({
|
|
4440
4440
|
patch: this.serialize()
|
|
4441
4441
|
}, opts);
|
|
4442
4442
|
}
|
|
4443
4443
|
};
|
|
4444
4444
|
let ObservablePatch = _ObservablePatch;
|
|
4445
|
-
_client$
|
|
4445
|
+
_client$6 = new WeakMap();
|
|
4446
4446
|
const _Patch = class extends BasePatch {
|
|
4447
4447
|
constructor(selection, operations, client) {
|
|
4448
4448
|
super(selection, operations);
|
|
4449
|
-
__privateAdd$
|
|
4450
|
-
__privateSet$
|
|
4449
|
+
__privateAdd$7(this, _client2$6, void 0);
|
|
4450
|
+
__privateSet$7(this, _client2$6, client);
|
|
4451
4451
|
}
|
|
4452
4452
|
clone() {
|
|
4453
4453
|
return new _Patch(this.selection, {
|
|
4454
4454
|
...this.operations
|
|
4455
|
-
}, __privateGet$
|
|
4455
|
+
}, __privateGet$7(this, _client2$6));
|
|
4456
4456
|
}
|
|
4457
4457
|
commit(options) {
|
|
4458
|
-
if (!__privateGet$
|
|
4458
|
+
if (!__privateGet$7(this, _client2$6)) {
|
|
4459
4459
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
4460
4460
|
}
|
|
4461
4461
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -4463,30 +4463,30 @@
|
|
|
4463
4463
|
returnFirst,
|
|
4464
4464
|
returnDocuments: true
|
|
4465
4465
|
}, options);
|
|
4466
|
-
return __privateGet$
|
|
4466
|
+
return __privateGet$7(this, _client2$6).mutate({
|
|
4467
4467
|
patch: this.serialize()
|
|
4468
4468
|
}, opts);
|
|
4469
4469
|
}
|
|
4470
4470
|
};
|
|
4471
4471
|
let Patch = _Patch;
|
|
4472
|
-
_client2$
|
|
4473
|
-
var __accessCheck$
|
|
4472
|
+
_client2$6 = new WeakMap();
|
|
4473
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
4474
4474
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
4475
4475
|
};
|
|
4476
|
-
var __privateGet$
|
|
4477
|
-
__accessCheck$
|
|
4476
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
4477
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
4478
4478
|
return getter ? getter.call(obj) : member.get(obj);
|
|
4479
4479
|
};
|
|
4480
|
-
var __privateAdd$
|
|
4480
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
4481
4481
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
4482
4482
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
4483
4483
|
};
|
|
4484
|
-
var __privateSet$
|
|
4485
|
-
__accessCheck$
|
|
4484
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
4485
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
4486
4486
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
4487
4487
|
return value;
|
|
4488
4488
|
};
|
|
4489
|
-
var _client$
|
|
4489
|
+
var _client$5, _client2$5;
|
|
4490
4490
|
const defaultMutateOptions = {
|
|
4491
4491
|
returnDocuments: false
|
|
4492
4492
|
};
|
|
@@ -4552,17 +4552,17 @@
|
|
|
4552
4552
|
const _Transaction = class extends BaseTransaction {
|
|
4553
4553
|
constructor(operations, client, transactionId) {
|
|
4554
4554
|
super(operations, transactionId);
|
|
4555
|
-
__privateAdd$
|
|
4556
|
-
__privateSet$
|
|
4555
|
+
__privateAdd$6(this, _client$5, void 0);
|
|
4556
|
+
__privateSet$6(this, _client$5, client);
|
|
4557
4557
|
}
|
|
4558
4558
|
clone() {
|
|
4559
|
-
return new _Transaction([...this.operations], __privateGet$
|
|
4559
|
+
return new _Transaction([...this.operations], __privateGet$6(this, _client$5), this.trxId);
|
|
4560
4560
|
}
|
|
4561
4561
|
commit(options) {
|
|
4562
|
-
if (!__privateGet$
|
|
4562
|
+
if (!__privateGet$6(this, _client$5)) {
|
|
4563
4563
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
4564
4564
|
}
|
|
4565
|
-
return __privateGet$
|
|
4565
|
+
return __privateGet$6(this, _client$5).mutate(this.serialize(), Object.assign({
|
|
4566
4566
|
transactionId: this.trxId
|
|
4567
4567
|
}, defaultMutateOptions, options || {}));
|
|
4568
4568
|
}
|
|
@@ -4575,7 +4575,7 @@
|
|
|
4575
4575
|
});
|
|
4576
4576
|
}
|
|
4577
4577
|
if (isBuilder) {
|
|
4578
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$
|
|
4578
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
|
|
4579
4579
|
if (!(patch instanceof Patch)) {
|
|
4580
4580
|
throw new Error("function passed to `patch()` must return the patch");
|
|
4581
4581
|
}
|
|
@@ -4592,21 +4592,21 @@
|
|
|
4592
4592
|
}
|
|
4593
4593
|
};
|
|
4594
4594
|
let Transaction = _Transaction;
|
|
4595
|
-
_client$
|
|
4595
|
+
_client$5 = new WeakMap();
|
|
4596
4596
|
const _ObservableTransaction = class extends BaseTransaction {
|
|
4597
4597
|
constructor(operations, client, transactionId) {
|
|
4598
4598
|
super(operations, transactionId);
|
|
4599
|
-
__privateAdd$
|
|
4600
|
-
__privateSet$
|
|
4599
|
+
__privateAdd$6(this, _client2$5, void 0);
|
|
4600
|
+
__privateSet$6(this, _client2$5, client);
|
|
4601
4601
|
}
|
|
4602
4602
|
clone() {
|
|
4603
|
-
return new _ObservableTransaction([...this.operations], __privateGet$
|
|
4603
|
+
return new _ObservableTransaction([...this.operations], __privateGet$6(this, _client2$5), this.trxId);
|
|
4604
4604
|
}
|
|
4605
4605
|
commit(options) {
|
|
4606
|
-
if (!__privateGet$
|
|
4606
|
+
if (!__privateGet$6(this, _client2$5)) {
|
|
4607
4607
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
4608
4608
|
}
|
|
4609
|
-
return __privateGet$
|
|
4609
|
+
return __privateGet$6(this, _client2$5).mutate(this.serialize(), Object.assign({
|
|
4610
4610
|
transactionId: this.trxId
|
|
4611
4611
|
}, defaultMutateOptions, options || {}));
|
|
4612
4612
|
}
|
|
@@ -4619,7 +4619,7 @@
|
|
|
4619
4619
|
});
|
|
4620
4620
|
}
|
|
4621
4621
|
if (isBuilder) {
|
|
4622
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$
|
|
4622
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$5)));
|
|
4623
4623
|
if (!(patch instanceof ObservablePatch)) {
|
|
4624
4624
|
throw new Error("function passed to `patch()` must return the patch");
|
|
4625
4625
|
}
|
|
@@ -4636,7 +4636,7 @@
|
|
|
4636
4636
|
}
|
|
4637
4637
|
};
|
|
4638
4638
|
let ObservableTransaction = _ObservableTransaction;
|
|
4639
|
-
_client2$
|
|
4639
|
+
_client2$5 = new WeakMap();
|
|
4640
4640
|
const excludeFalsey = (param, defValue) => {
|
|
4641
4641
|
const value = typeof param === "undefined" ? defValue : param;
|
|
4642
4642
|
return param === false ? void 0 : value;
|
|
@@ -4670,7 +4670,7 @@
|
|
|
4670
4670
|
function _getDocument(client, httpRequest, id) {
|
|
4671
4671
|
let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
4672
4672
|
const options = {
|
|
4673
|
-
uri: client
|
|
4673
|
+
uri: _getDataUrl(client, "doc", id),
|
|
4674
4674
|
json: true,
|
|
4675
4675
|
tag: opts.tag
|
|
4676
4676
|
};
|
|
@@ -4679,7 +4679,7 @@
|
|
|
4679
4679
|
function _getDocuments(client, httpRequest, ids) {
|
|
4680
4680
|
let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
4681
4681
|
const options = {
|
|
4682
|
-
uri: client
|
|
4682
|
+
uri: _getDataUrl(client, "doc", ids.join(",")),
|
|
4683
4683
|
json: true,
|
|
4684
4684
|
tag: opts.tag
|
|
4685
4685
|
};
|
|
@@ -4726,7 +4726,7 @@
|
|
|
4726
4726
|
tag,
|
|
4727
4727
|
headers
|
|
4728
4728
|
} = options;
|
|
4729
|
-
const uri = client
|
|
4729
|
+
const uri = _getDataUrl(client, endpoint, stringQuery);
|
|
4730
4730
|
const reqOptions = {
|
|
4731
4731
|
method: useGet ? "GET" : "POST",
|
|
4732
4732
|
uri,
|
|
@@ -4782,7 +4782,7 @@
|
|
|
4782
4782
|
};
|
|
4783
4783
|
}
|
|
4784
4784
|
const reqOptions = getRequestOptions(config, Object.assign({}, options, {
|
|
4785
|
-
url: client
|
|
4785
|
+
url: _getUrl(client, uri, useCdn)
|
|
4786
4786
|
}));
|
|
4787
4787
|
return new Observable(subscriber => httpRequest(reqOptions, config.requester).subscribe(subscriber));
|
|
4788
4788
|
}
|
|
@@ -4790,50 +4790,66 @@
|
|
|
4790
4790
|
const observable = _requestObservable(client, httpRequest, options).pipe(filter(event => event.type === "response"), map(event => event.body));
|
|
4791
4791
|
return observable;
|
|
4792
4792
|
}
|
|
4793
|
-
|
|
4793
|
+
function _getDataUrl(client, operation, path) {
|
|
4794
|
+
const config = client.config();
|
|
4795
|
+
const catalog = hasDataset(config);
|
|
4796
|
+
const baseUri = "/".concat(operation, "/").concat(catalog);
|
|
4797
|
+
const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
|
|
4798
|
+
return "/data".concat(uri).replace(/\/($|\?)/, "$1");
|
|
4799
|
+
}
|
|
4800
|
+
function _getUrl(client, uri) {
|
|
4801
|
+
let canUseCdn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
4802
|
+
const {
|
|
4803
|
+
url,
|
|
4804
|
+
cdnUrl
|
|
4805
|
+
} = client.config();
|
|
4806
|
+
const base = canUseCdn ? cdnUrl : url;
|
|
4807
|
+
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
4808
|
+
}
|
|
4809
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
4794
4810
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
4795
4811
|
};
|
|
4796
|
-
var __privateGet$
|
|
4797
|
-
__accessCheck$
|
|
4812
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
4813
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
4798
4814
|
return getter ? getter.call(obj) : member.get(obj);
|
|
4799
4815
|
};
|
|
4800
|
-
var __privateAdd$
|
|
4816
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
4801
4817
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
4802
4818
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
4803
4819
|
};
|
|
4804
|
-
var __privateSet$
|
|
4805
|
-
__accessCheck$
|
|
4820
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
4821
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
4806
4822
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
4807
4823
|
return value;
|
|
4808
4824
|
};
|
|
4809
|
-
var _client$
|
|
4825
|
+
var _client$4, _httpRequest$5, _client2$4, _httpRequest2$5;
|
|
4810
4826
|
class ObservableAssetsClient {
|
|
4811
4827
|
constructor(client, httpRequest) {
|
|
4812
|
-
__privateAdd$
|
|
4813
|
-
__privateAdd$
|
|
4814
|
-
__privateSet$
|
|
4815
|
-
__privateSet$
|
|
4828
|
+
__privateAdd$5(this, _client$4, void 0);
|
|
4829
|
+
__privateAdd$5(this, _httpRequest$5, void 0);
|
|
4830
|
+
__privateSet$5(this, _client$4, client);
|
|
4831
|
+
__privateSet$5(this, _httpRequest$5, httpRequest);
|
|
4816
4832
|
}
|
|
4817
4833
|
upload(assetType, body, options) {
|
|
4818
|
-
return _upload(__privateGet$
|
|
4834
|
+
return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$5), assetType, body, options);
|
|
4819
4835
|
}
|
|
4820
4836
|
}
|
|
4821
|
-
_client$
|
|
4822
|
-
_httpRequest$
|
|
4837
|
+
_client$4 = new WeakMap();
|
|
4838
|
+
_httpRequest$5 = new WeakMap();
|
|
4823
4839
|
class AssetsClient {
|
|
4824
4840
|
constructor(client, httpRequest) {
|
|
4825
|
-
__privateAdd$
|
|
4826
|
-
__privateAdd$
|
|
4827
|
-
__privateSet$
|
|
4828
|
-
__privateSet$
|
|
4841
|
+
__privateAdd$5(this, _client2$4, void 0);
|
|
4842
|
+
__privateAdd$5(this, _httpRequest2$5, void 0);
|
|
4843
|
+
__privateSet$5(this, _client2$4, client);
|
|
4844
|
+
__privateSet$5(this, _httpRequest2$5, httpRequest);
|
|
4829
4845
|
}
|
|
4830
4846
|
upload(assetType, body, options) {
|
|
4831
|
-
const observable = _upload(__privateGet$
|
|
4847
|
+
const observable = _upload(__privateGet$5(this, _client2$4), __privateGet$5(this, _httpRequest2$5), assetType, body, options);
|
|
4832
4848
|
return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
|
|
4833
4849
|
}
|
|
4834
4850
|
}
|
|
4835
|
-
_client2$
|
|
4836
|
-
_httpRequest2$
|
|
4851
|
+
_client2$4 = new WeakMap();
|
|
4852
|
+
_httpRequest2$5 = new WeakMap();
|
|
4837
4853
|
function _upload(client, httpRequest, assetType, body) {
|
|
4838
4854
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
4839
4855
|
validateAssetType(assetType);
|
|
@@ -4887,65 +4903,65 @@
|
|
|
4887
4903
|
contentType: file.type
|
|
4888
4904
|
}, opts);
|
|
4889
4905
|
}
|
|
4890
|
-
var __accessCheck$
|
|
4906
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
4891
4907
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
4892
4908
|
};
|
|
4893
|
-
var __privateGet$
|
|
4894
|
-
__accessCheck$
|
|
4909
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
4910
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
4895
4911
|
return getter ? getter.call(obj) : member.get(obj);
|
|
4896
4912
|
};
|
|
4897
|
-
var __privateAdd$
|
|
4913
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
4898
4914
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
4899
4915
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
4900
4916
|
};
|
|
4901
|
-
var __privateSet$
|
|
4902
|
-
__accessCheck$
|
|
4917
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
4918
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
4903
4919
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
4904
4920
|
return value;
|
|
4905
4921
|
};
|
|
4906
|
-
var _client, _httpRequest$
|
|
4922
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
4907
4923
|
class ObservableAuthClient {
|
|
4908
4924
|
constructor(client, httpRequest) {
|
|
4909
|
-
__privateAdd$
|
|
4910
|
-
__privateAdd$
|
|
4911
|
-
__privateSet$
|
|
4912
|
-
__privateSet$
|
|
4925
|
+
__privateAdd$4(this, _client$3, void 0);
|
|
4926
|
+
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
4927
|
+
__privateSet$4(this, _client$3, client);
|
|
4928
|
+
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
4913
4929
|
}
|
|
4914
4930
|
getLoginProviders() {
|
|
4915
|
-
return _request(__privateGet$
|
|
4931
|
+
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
4916
4932
|
uri: "/auth/providers"
|
|
4917
4933
|
});
|
|
4918
4934
|
}
|
|
4919
4935
|
logout() {
|
|
4920
|
-
return _request(__privateGet$
|
|
4936
|
+
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
4921
4937
|
uri: "/auth/logout",
|
|
4922
4938
|
method: "POST"
|
|
4923
4939
|
});
|
|
4924
4940
|
}
|
|
4925
4941
|
}
|
|
4926
|
-
_client = new WeakMap();
|
|
4927
|
-
_httpRequest$
|
|
4942
|
+
_client$3 = new WeakMap();
|
|
4943
|
+
_httpRequest$4 = new WeakMap();
|
|
4928
4944
|
class AuthClient {
|
|
4929
4945
|
constructor(client, httpRequest) {
|
|
4930
|
-
__privateAdd$
|
|
4931
|
-
__privateAdd$
|
|
4932
|
-
__privateSet$
|
|
4933
|
-
__privateSet$
|
|
4946
|
+
__privateAdd$4(this, _client2$3, void 0);
|
|
4947
|
+
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
4948
|
+
__privateSet$4(this, _client2$3, client);
|
|
4949
|
+
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
4934
4950
|
}
|
|
4935
4951
|
getLoginProviders() {
|
|
4936
|
-
return lastValueFrom(_request(__privateGet$
|
|
4952
|
+
return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
4937
4953
|
uri: "/auth/providers"
|
|
4938
4954
|
}));
|
|
4939
4955
|
}
|
|
4940
4956
|
logout() {
|
|
4941
|
-
return lastValueFrom(_request(__privateGet$
|
|
4957
|
+
return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
4942
4958
|
uri: "/auth/logout",
|
|
4943
4959
|
method: "POST"
|
|
4944
4960
|
}));
|
|
4945
4961
|
}
|
|
4946
4962
|
}
|
|
4947
|
-
_client2 = new WeakMap();
|
|
4948
|
-
_httpRequest2$
|
|
4963
|
+
_client2$3 = new WeakMap();
|
|
4964
|
+
_httpRequest2$4 = new WeakMap();
|
|
4949
4965
|
const BASE_URL = "https://docs.sanity.io/help/";
|
|
4950
4966
|
function generateHelpUrl(slug) {
|
|
4951
4967
|
return BASE_URL + slug;
|
|
@@ -5075,7 +5091,7 @@
|
|
|
5075
5091
|
...listenOpts
|
|
5076
5092
|
}
|
|
5077
5093
|
});
|
|
5078
|
-
const uri = "".concat(url).concat(this
|
|
5094
|
+
const uri = "".concat(url).concat(_getDataUrl(this, "listen", qs));
|
|
5079
5095
|
if (uri.length > MAX_URL_LENGTH) {
|
|
5080
5096
|
return new Observable(observer => observer.error(new Error("Query too large for listener")));
|
|
5081
5097
|
}
|
|
@@ -5178,101 +5194,183 @@
|
|
|
5178
5194
|
}
|
|
5179
5195
|
return typeof err.error === "string" ? err.error : JSON.stringify(err.error, null, 2);
|
|
5180
5196
|
}
|
|
5181
|
-
var __accessCheck$
|
|
5197
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
|
5182
5198
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
5183
5199
|
};
|
|
5184
|
-
var
|
|
5200
|
+
var __privateGet$3 = (obj, member, getter) => {
|
|
5201
|
+
__accessCheck$3(obj, member, "read from private field");
|
|
5202
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
5203
|
+
};
|
|
5204
|
+
var __privateAdd$3 = (obj, member, value) => {
|
|
5185
5205
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
5186
5206
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
5187
5207
|
};
|
|
5188
|
-
var
|
|
5189
|
-
__accessCheck$
|
|
5190
|
-
|
|
5208
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
|
5209
|
+
__accessCheck$3(obj, member, "write to private field");
|
|
5210
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
5211
|
+
return value;
|
|
5191
5212
|
};
|
|
5192
|
-
var
|
|
5193
|
-
class
|
|
5194
|
-
constructor() {
|
|
5195
|
-
__privateAdd$
|
|
5213
|
+
var _client$2, _httpRequest$3, _client2$2, _httpRequest2$3;
|
|
5214
|
+
class ObservableDatasetsClient {
|
|
5215
|
+
constructor(client, httpRequest) {
|
|
5216
|
+
__privateAdd$3(this, _client$2, void 0);
|
|
5217
|
+
__privateAdd$3(this, _httpRequest$3, void 0);
|
|
5218
|
+
__privateSet$3(this, _client$2, client);
|
|
5219
|
+
__privateSet$3(this, _httpRequest$3, httpRequest);
|
|
5196
5220
|
}
|
|
5197
5221
|
create(name, options) {
|
|
5198
|
-
return
|
|
5222
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PUT", name, options);
|
|
5199
5223
|
}
|
|
5200
5224
|
edit(name, options) {
|
|
5201
|
-
return
|
|
5225
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PATCH", name, options);
|
|
5202
5226
|
}
|
|
5203
5227
|
delete(name) {
|
|
5204
|
-
return
|
|
5228
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "DELETE", name);
|
|
5205
5229
|
}
|
|
5206
5230
|
list() {
|
|
5207
|
-
return this
|
|
5231
|
+
return _request(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), {
|
|
5208
5232
|
uri: "/datasets"
|
|
5209
5233
|
});
|
|
5210
5234
|
}
|
|
5211
5235
|
}
|
|
5212
|
-
|
|
5213
|
-
|
|
5236
|
+
_client$2 = new WeakMap();
|
|
5237
|
+
_httpRequest$3 = new WeakMap();
|
|
5238
|
+
class DatasetsClient {
|
|
5239
|
+
constructor(client, httpRequest) {
|
|
5240
|
+
__privateAdd$3(this, _client2$2, void 0);
|
|
5241
|
+
__privateAdd$3(this, _httpRequest2$3, void 0);
|
|
5242
|
+
__privateSet$3(this, _client2$2, client);
|
|
5243
|
+
__privateSet$3(this, _httpRequest2$3, httpRequest);
|
|
5244
|
+
}
|
|
5245
|
+
create(name, options) {
|
|
5246
|
+
return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name, options));
|
|
5247
|
+
}
|
|
5248
|
+
edit(name, options) {
|
|
5249
|
+
return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name, options));
|
|
5250
|
+
}
|
|
5251
|
+
delete(name) {
|
|
5252
|
+
return lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "DELETE", name));
|
|
5253
|
+
}
|
|
5254
|
+
list() {
|
|
5255
|
+
return lastValueFrom(_request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), {
|
|
5256
|
+
uri: "/datasets"
|
|
5257
|
+
}));
|
|
5258
|
+
}
|
|
5259
|
+
}
|
|
5260
|
+
_client2$2 = new WeakMap();
|
|
5261
|
+
_httpRequest2$3 = new WeakMap();
|
|
5262
|
+
function _modify(client, httpRequest, method, name, options) {
|
|
5214
5263
|
dataset(name);
|
|
5215
|
-
return
|
|
5264
|
+
return _request(client, httpRequest, {
|
|
5216
5265
|
method,
|
|
5217
5266
|
uri: "/datasets/".concat(name),
|
|
5218
5267
|
body: options
|
|
5219
5268
|
});
|
|
5220
|
-
};
|
|
5221
|
-
class ObservableDatasetsClient extends BaseDatasetsClient {
|
|
5222
|
-
constructor(client) {
|
|
5223
|
-
super();
|
|
5224
|
-
this.client = client;
|
|
5225
|
-
}
|
|
5226
5269
|
}
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5270
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
|
5271
|
+
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
5272
|
+
};
|
|
5273
|
+
var __privateGet$2 = (obj, member, getter) => {
|
|
5274
|
+
__accessCheck$2(obj, member, "read from private field");
|
|
5275
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
5276
|
+
};
|
|
5277
|
+
var __privateAdd$2 = (obj, member, value) => {
|
|
5278
|
+
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
5279
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
5280
|
+
};
|
|
5281
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
|
5282
|
+
__accessCheck$2(obj, member, "write to private field");
|
|
5283
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
5284
|
+
return value;
|
|
5285
|
+
};
|
|
5286
|
+
var _client$1, _httpRequest$2, _client2$1, _httpRequest2$2;
|
|
5287
|
+
class ObservableProjectsClient {
|
|
5288
|
+
constructor(client, httpRequest) {
|
|
5289
|
+
__privateAdd$2(this, _client$1, void 0);
|
|
5290
|
+
__privateAdd$2(this, _httpRequest$2, void 0);
|
|
5291
|
+
__privateSet$2(this, _client$1, client);
|
|
5292
|
+
__privateSet$2(this, _httpRequest$2, httpRequest);
|
|
5231
5293
|
}
|
|
5232
|
-
}
|
|
5233
|
-
class BaseProjectsClient {
|
|
5234
5294
|
list() {
|
|
5235
|
-
return this
|
|
5295
|
+
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), {
|
|
5236
5296
|
uri: "/projects"
|
|
5237
5297
|
});
|
|
5238
5298
|
}
|
|
5239
5299
|
getById(projectId) {
|
|
5240
|
-
return this
|
|
5300
|
+
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), {
|
|
5241
5301
|
uri: "/projects/".concat(projectId)
|
|
5242
5302
|
});
|
|
5243
5303
|
}
|
|
5244
5304
|
}
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5305
|
+
_client$1 = new WeakMap();
|
|
5306
|
+
_httpRequest$2 = new WeakMap();
|
|
5307
|
+
class ProjectsClient {
|
|
5308
|
+
constructor(client, httpRequest) {
|
|
5309
|
+
__privateAdd$2(this, _client2$1, void 0);
|
|
5310
|
+
__privateAdd$2(this, _httpRequest2$2, void 0);
|
|
5311
|
+
__privateSet$2(this, _client2$1, client);
|
|
5312
|
+
__privateSet$2(this, _httpRequest2$2, httpRequest);
|
|
5249
5313
|
}
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5314
|
+
list() {
|
|
5315
|
+
return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), {
|
|
5316
|
+
uri: "/projects"
|
|
5317
|
+
}));
|
|
5318
|
+
}
|
|
5319
|
+
getById(projectId) {
|
|
5320
|
+
return lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), {
|
|
5321
|
+
uri: "/projects/".concat(projectId)
|
|
5322
|
+
}));
|
|
5255
5323
|
}
|
|
5256
5324
|
}
|
|
5257
|
-
|
|
5325
|
+
_client2$1 = new WeakMap();
|
|
5326
|
+
_httpRequest2$2 = new WeakMap();
|
|
5327
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
|
5328
|
+
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
5329
|
+
};
|
|
5330
|
+
var __privateGet$1 = (obj, member, getter) => {
|
|
5331
|
+
__accessCheck$1(obj, member, "read from private field");
|
|
5332
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
5333
|
+
};
|
|
5334
|
+
var __privateAdd$1 = (obj, member, value) => {
|
|
5335
|
+
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
5336
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
5337
|
+
};
|
|
5338
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
|
5339
|
+
__accessCheck$1(obj, member, "write to private field");
|
|
5340
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
5341
|
+
return value;
|
|
5342
|
+
};
|
|
5343
|
+
var _client, _httpRequest$1, _client2, _httpRequest2$1;
|
|
5344
|
+
class ObservableUsersClient {
|
|
5345
|
+
constructor(client, httpRequest) {
|
|
5346
|
+
__privateAdd$1(this, _client, void 0);
|
|
5347
|
+
__privateAdd$1(this, _httpRequest$1, void 0);
|
|
5348
|
+
__privateSet$1(this, _client, client);
|
|
5349
|
+
__privateSet$1(this, _httpRequest$1, httpRequest);
|
|
5350
|
+
}
|
|
5258
5351
|
getById(id) {
|
|
5259
|
-
return this
|
|
5352
|
+
return _request(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), {
|
|
5260
5353
|
uri: "/users/".concat(id)
|
|
5261
5354
|
});
|
|
5262
5355
|
}
|
|
5263
5356
|
}
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5357
|
+
_client = new WeakMap();
|
|
5358
|
+
_httpRequest$1 = new WeakMap();
|
|
5359
|
+
class UsersClient {
|
|
5360
|
+
constructor(client, httpRequest) {
|
|
5361
|
+
__privateAdd$1(this, _client2, void 0);
|
|
5362
|
+
__privateAdd$1(this, _httpRequest2$1, void 0);
|
|
5363
|
+
__privateSet$1(this, _client2, client);
|
|
5364
|
+
__privateSet$1(this, _httpRequest2$1, httpRequest);
|
|
5268
5365
|
}
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
this.client = client;
|
|
5366
|
+
getById(id) {
|
|
5367
|
+
return lastValueFrom(_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
|
|
5368
|
+
uri: "/users/".concat(id)
|
|
5369
|
+
}));
|
|
5274
5370
|
}
|
|
5275
5371
|
}
|
|
5372
|
+
_client2 = new WeakMap();
|
|
5373
|
+
_httpRequest2$1 = new WeakMap();
|
|
5276
5374
|
var __accessCheck = (obj, member, msg) => {
|
|
5277
5375
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
5278
5376
|
};
|
|
@@ -5298,9 +5396,9 @@
|
|
|
5298
5396
|
__privateSet(this, _httpRequest, httpRequest);
|
|
5299
5397
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
5300
5398
|
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
5301
|
-
this.datasets = new ObservableDatasetsClient(this);
|
|
5302
|
-
this.projects = new ObservableProjectsClient(this);
|
|
5303
|
-
this.users = new ObservableUsersClient(this);
|
|
5399
|
+
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
5400
|
+
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
5401
|
+
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
5304
5402
|
}
|
|
5305
5403
|
clone() {
|
|
5306
5404
|
return new _ObservableSanityClient(__privateGet(this, _httpRequest), this.config());
|
|
@@ -5357,18 +5455,6 @@
|
|
|
5357
5455
|
request(options) {
|
|
5358
5456
|
return _request(this, __privateGet(this, _httpRequest), options);
|
|
5359
5457
|
}
|
|
5360
|
-
getUrl(uri) {
|
|
5361
|
-
let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
5362
|
-
const base = canUseCdn ? __privateGet(this, _clientConfig).cdnUrl : __privateGet(this, _clientConfig).url;
|
|
5363
|
-
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
5364
|
-
}
|
|
5365
|
-
getDataUrl(operation, path) {
|
|
5366
|
-
const config = this.config();
|
|
5367
|
-
const catalog = hasDataset(config);
|
|
5368
|
-
const baseUri = "/".concat(operation, "/").concat(catalog);
|
|
5369
|
-
const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
|
|
5370
|
-
return "/data".concat(uri).replace(/\/($|\?)/, "$1");
|
|
5371
|
-
}
|
|
5372
5458
|
};
|
|
5373
5459
|
let ObservableSanityClient = _ObservableSanityClient;
|
|
5374
5460
|
_clientConfig = new WeakMap();
|
|
@@ -5378,14 +5464,14 @@
|
|
|
5378
5464
|
__privateAdd(this, _clientConfig2, void 0);
|
|
5379
5465
|
__privateAdd(this, _httpRequest2, void 0);
|
|
5380
5466
|
this.listen = _listen;
|
|
5467
|
+
this.observable = new ObservableSanityClient(httpRequest, config);
|
|
5381
5468
|
this.config(config);
|
|
5382
5469
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
5383
5470
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
5384
5471
|
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
5385
|
-
this.datasets = new DatasetsClient(this);
|
|
5386
|
-
this.projects = new ProjectsClient(this);
|
|
5387
|
-
this.users = new UsersClient(this);
|
|
5388
|
-
this.observable = new ObservableSanityClient(httpRequest, this.config());
|
|
5472
|
+
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
5473
|
+
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
5474
|
+
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|
|
5389
5475
|
}
|
|
5390
5476
|
clone() {
|
|
5391
5477
|
return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
|
|
@@ -5446,18 +5532,6 @@
|
|
|
5446
5532
|
dataRequest(endpoint, body, options) {
|
|
5447
5533
|
return lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
|
|
5448
5534
|
}
|
|
5449
|
-
getUrl(uri) {
|
|
5450
|
-
let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
5451
|
-
const base = canUseCdn ? __privateGet(this, _clientConfig2).cdnUrl : __privateGet(this, _clientConfig2).url;
|
|
5452
|
-
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
5453
|
-
}
|
|
5454
|
-
getDataUrl(operation, path) {
|
|
5455
|
-
const config = this.config();
|
|
5456
|
-
const catalog = hasDataset(config);
|
|
5457
|
-
const baseUri = "/".concat(operation, "/").concat(catalog);
|
|
5458
|
-
const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
|
|
5459
|
-
return "/data".concat(uri).replace(/\/($|\?)/, "$1");
|
|
5460
|
-
}
|
|
5461
5535
|
};
|
|
5462
5536
|
let SanityClient = _SanityClient;
|
|
5463
5537
|
_clientConfig2 = new WeakMap();
|