@sanity/client 5.0.0-esm.2 → 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 +243 -169
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +243 -169
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +244 -170
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +128 -154
- package/dist/index.js +244 -170
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/SanityClient.ts +9 -75
- 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 +243 -169
- package/umd/sanityClient.min.js +3 -3
package/dist/index.browser.cjs
CHANGED
|
@@ -208,23 +208,23 @@ var encodeQueryString = _ref => {
|
|
|
208
208
|
return options[option] ? "".concat(qs, "&").concat(enc(option), "=").concat(enc(options[option])) : qs;
|
|
209
209
|
}, qString);
|
|
210
210
|
};
|
|
211
|
-
var __accessCheck$
|
|
211
|
+
var __accessCheck$7 = (obj, member, msg) => {
|
|
212
212
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
213
213
|
};
|
|
214
|
-
var __privateGet$
|
|
215
|
-
__accessCheck$
|
|
214
|
+
var __privateGet$7 = (obj, member, getter) => {
|
|
215
|
+
__accessCheck$7(obj, member, "read from private field");
|
|
216
216
|
return getter ? getter.call(obj) : member.get(obj);
|
|
217
217
|
};
|
|
218
|
-
var __privateAdd$
|
|
218
|
+
var __privateAdd$7 = (obj, member, value) => {
|
|
219
219
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
220
220
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
221
221
|
};
|
|
222
|
-
var __privateSet$
|
|
223
|
-
__accessCheck$
|
|
222
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
|
223
|
+
__accessCheck$7(obj, member, "write to private field");
|
|
224
224
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
225
225
|
return value;
|
|
226
226
|
};
|
|
227
|
-
var _client$
|
|
227
|
+
var _client$6, _client2$6;
|
|
228
228
|
class BasePatch {
|
|
229
229
|
constructor(selection) {
|
|
230
230
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -315,16 +315,16 @@ class BasePatch {
|
|
|
315
315
|
const _ObservablePatch = class extends BasePatch {
|
|
316
316
|
constructor(selection, operations, client) {
|
|
317
317
|
super(selection, operations);
|
|
318
|
-
__privateAdd$
|
|
319
|
-
__privateSet$
|
|
318
|
+
__privateAdd$7(this, _client$6, void 0);
|
|
319
|
+
__privateSet$7(this, _client$6, client);
|
|
320
320
|
}
|
|
321
321
|
clone() {
|
|
322
322
|
return new _ObservablePatch(this.selection, {
|
|
323
323
|
...this.operations
|
|
324
|
-
}, __privateGet$
|
|
324
|
+
}, __privateGet$7(this, _client$6));
|
|
325
325
|
}
|
|
326
326
|
commit(options) {
|
|
327
|
-
if (!__privateGet$
|
|
327
|
+
if (!__privateGet$7(this, _client$6)) {
|
|
328
328
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
329
329
|
}
|
|
330
330
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -332,26 +332,26 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
332
332
|
returnFirst,
|
|
333
333
|
returnDocuments: true
|
|
334
334
|
}, options);
|
|
335
|
-
return __privateGet$
|
|
335
|
+
return __privateGet$7(this, _client$6).mutate({
|
|
336
336
|
patch: this.serialize()
|
|
337
337
|
}, opts);
|
|
338
338
|
}
|
|
339
339
|
};
|
|
340
340
|
let ObservablePatch = _ObservablePatch;
|
|
341
|
-
_client$
|
|
341
|
+
_client$6 = new WeakMap();
|
|
342
342
|
const _Patch = class extends BasePatch {
|
|
343
343
|
constructor(selection, operations, client) {
|
|
344
344
|
super(selection, operations);
|
|
345
|
-
__privateAdd$
|
|
346
|
-
__privateSet$
|
|
345
|
+
__privateAdd$7(this, _client2$6, void 0);
|
|
346
|
+
__privateSet$7(this, _client2$6, client);
|
|
347
347
|
}
|
|
348
348
|
clone() {
|
|
349
349
|
return new _Patch(this.selection, {
|
|
350
350
|
...this.operations
|
|
351
|
-
}, __privateGet$
|
|
351
|
+
}, __privateGet$7(this, _client2$6));
|
|
352
352
|
}
|
|
353
353
|
commit(options) {
|
|
354
|
-
if (!__privateGet$
|
|
354
|
+
if (!__privateGet$7(this, _client2$6)) {
|
|
355
355
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
356
356
|
}
|
|
357
357
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -359,30 +359,30 @@ const _Patch = class extends BasePatch {
|
|
|
359
359
|
returnFirst,
|
|
360
360
|
returnDocuments: true
|
|
361
361
|
}, options);
|
|
362
|
-
return __privateGet$
|
|
362
|
+
return __privateGet$7(this, _client2$6).mutate({
|
|
363
363
|
patch: this.serialize()
|
|
364
364
|
}, opts);
|
|
365
365
|
}
|
|
366
366
|
};
|
|
367
367
|
let Patch = _Patch;
|
|
368
|
-
_client2$
|
|
369
|
-
var __accessCheck$
|
|
368
|
+
_client2$6 = new WeakMap();
|
|
369
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
370
370
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
371
371
|
};
|
|
372
|
-
var __privateGet$
|
|
373
|
-
__accessCheck$
|
|
372
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
373
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
374
374
|
return getter ? getter.call(obj) : member.get(obj);
|
|
375
375
|
};
|
|
376
|
-
var __privateAdd$
|
|
376
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
377
377
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
378
378
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
379
379
|
};
|
|
380
|
-
var __privateSet$
|
|
381
|
-
__accessCheck$
|
|
380
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
381
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
382
382
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
383
383
|
return value;
|
|
384
384
|
};
|
|
385
|
-
var _client$
|
|
385
|
+
var _client$5, _client2$5;
|
|
386
386
|
const defaultMutateOptions = {
|
|
387
387
|
returnDocuments: false
|
|
388
388
|
};
|
|
@@ -448,17 +448,17 @@ class BaseTransaction {
|
|
|
448
448
|
const _Transaction = class extends BaseTransaction {
|
|
449
449
|
constructor(operations, client, transactionId) {
|
|
450
450
|
super(operations, transactionId);
|
|
451
|
-
__privateAdd$
|
|
452
|
-
__privateSet$
|
|
451
|
+
__privateAdd$6(this, _client$5, void 0);
|
|
452
|
+
__privateSet$6(this, _client$5, client);
|
|
453
453
|
}
|
|
454
454
|
clone() {
|
|
455
|
-
return new _Transaction([...this.operations], __privateGet$
|
|
455
|
+
return new _Transaction([...this.operations], __privateGet$6(this, _client$5), this.trxId);
|
|
456
456
|
}
|
|
457
457
|
commit(options) {
|
|
458
|
-
if (!__privateGet$
|
|
458
|
+
if (!__privateGet$6(this, _client$5)) {
|
|
459
459
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
460
460
|
}
|
|
461
|
-
return __privateGet$
|
|
461
|
+
return __privateGet$6(this, _client$5).mutate(this.serialize(), Object.assign({
|
|
462
462
|
transactionId: this.trxId
|
|
463
463
|
}, defaultMutateOptions, options || {}));
|
|
464
464
|
}
|
|
@@ -471,7 +471,7 @@ const _Transaction = class extends BaseTransaction {
|
|
|
471
471
|
});
|
|
472
472
|
}
|
|
473
473
|
if (isBuilder) {
|
|
474
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$
|
|
474
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
|
|
475
475
|
if (!(patch instanceof Patch)) {
|
|
476
476
|
throw new Error("function passed to `patch()` must return the patch");
|
|
477
477
|
}
|
|
@@ -488,21 +488,21 @@ const _Transaction = class extends BaseTransaction {
|
|
|
488
488
|
}
|
|
489
489
|
};
|
|
490
490
|
let Transaction = _Transaction;
|
|
491
|
-
_client$
|
|
491
|
+
_client$5 = new WeakMap();
|
|
492
492
|
const _ObservableTransaction = class extends BaseTransaction {
|
|
493
493
|
constructor(operations, client, transactionId) {
|
|
494
494
|
super(operations, transactionId);
|
|
495
|
-
__privateAdd$
|
|
496
|
-
__privateSet$
|
|
495
|
+
__privateAdd$6(this, _client2$5, void 0);
|
|
496
|
+
__privateSet$6(this, _client2$5, client);
|
|
497
497
|
}
|
|
498
498
|
clone() {
|
|
499
|
-
return new _ObservableTransaction([...this.operations], __privateGet$
|
|
499
|
+
return new _ObservableTransaction([...this.operations], __privateGet$6(this, _client2$5), this.trxId);
|
|
500
500
|
}
|
|
501
501
|
commit(options) {
|
|
502
|
-
if (!__privateGet$
|
|
502
|
+
if (!__privateGet$6(this, _client2$5)) {
|
|
503
503
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
504
504
|
}
|
|
505
|
-
return __privateGet$
|
|
505
|
+
return __privateGet$6(this, _client2$5).mutate(this.serialize(), Object.assign({
|
|
506
506
|
transactionId: this.trxId
|
|
507
507
|
}, defaultMutateOptions, options || {}));
|
|
508
508
|
}
|
|
@@ -515,7 +515,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
517
|
if (isBuilder) {
|
|
518
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$
|
|
518
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$5)));
|
|
519
519
|
if (!(patch instanceof ObservablePatch)) {
|
|
520
520
|
throw new Error("function passed to `patch()` must return the patch");
|
|
521
521
|
}
|
|
@@ -532,7 +532,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
532
532
|
}
|
|
533
533
|
};
|
|
534
534
|
let ObservableTransaction = _ObservableTransaction;
|
|
535
|
-
_client2$
|
|
535
|
+
_client2$5 = new WeakMap();
|
|
536
536
|
const excludeFalsey = (param, defValue) => {
|
|
537
537
|
const value = typeof param === "undefined" ? defValue : param;
|
|
538
538
|
return param === false ? void 0 : value;
|
|
@@ -566,7 +566,7 @@ function _fetch(client, httpRequest, query, params) {
|
|
|
566
566
|
function _getDocument(client, httpRequest, id) {
|
|
567
567
|
let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
568
568
|
const options = {
|
|
569
|
-
uri: client
|
|
569
|
+
uri: _getDataUrl(client, "doc", id),
|
|
570
570
|
json: true,
|
|
571
571
|
tag: opts.tag
|
|
572
572
|
};
|
|
@@ -575,7 +575,7 @@ function _getDocument(client, httpRequest, id) {
|
|
|
575
575
|
function _getDocuments(client, httpRequest, ids) {
|
|
576
576
|
let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
577
577
|
const options = {
|
|
578
|
-
uri: client
|
|
578
|
+
uri: _getDataUrl(client, "doc", ids.join(",")),
|
|
579
579
|
json: true,
|
|
580
580
|
tag: opts.tag
|
|
581
581
|
};
|
|
@@ -622,7 +622,7 @@ function _dataRequest(client, httpRequest, endpoint, body) {
|
|
|
622
622
|
tag,
|
|
623
623
|
headers
|
|
624
624
|
} = options;
|
|
625
|
-
const uri = client
|
|
625
|
+
const uri = _getDataUrl(client, endpoint, stringQuery);
|
|
626
626
|
const reqOptions = {
|
|
627
627
|
method: useGet ? "GET" : "POST",
|
|
628
628
|
uri,
|
|
@@ -678,7 +678,7 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
678
678
|
};
|
|
679
679
|
}
|
|
680
680
|
const reqOptions = getRequestOptions(config, Object.assign({}, options, {
|
|
681
|
-
url: client
|
|
681
|
+
url: _getUrl(client, uri, useCdn)
|
|
682
682
|
}));
|
|
683
683
|
return new rxjs.Observable(subscriber => httpRequest(reqOptions, config.requester).subscribe(subscriber));
|
|
684
684
|
}
|
|
@@ -686,50 +686,66 @@ function _request(client, httpRequest, options) {
|
|
|
686
686
|
const observable = _requestObservable(client, httpRequest, options).pipe(operators.filter(event => event.type === "response"), operators.map(event => event.body));
|
|
687
687
|
return observable;
|
|
688
688
|
}
|
|
689
|
-
|
|
689
|
+
function _getDataUrl(client, operation, path) {
|
|
690
|
+
const config = client.config();
|
|
691
|
+
const catalog = hasDataset(config);
|
|
692
|
+
const baseUri = "/".concat(operation, "/").concat(catalog);
|
|
693
|
+
const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
|
|
694
|
+
return "/data".concat(uri).replace(/\/($|\?)/, "$1");
|
|
695
|
+
}
|
|
696
|
+
function _getUrl(client, uri) {
|
|
697
|
+
let canUseCdn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
698
|
+
const {
|
|
699
|
+
url,
|
|
700
|
+
cdnUrl
|
|
701
|
+
} = client.config();
|
|
702
|
+
const base = canUseCdn ? cdnUrl : url;
|
|
703
|
+
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
704
|
+
}
|
|
705
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
690
706
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
691
707
|
};
|
|
692
|
-
var __privateGet$
|
|
693
|
-
__accessCheck$
|
|
708
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
709
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
694
710
|
return getter ? getter.call(obj) : member.get(obj);
|
|
695
711
|
};
|
|
696
|
-
var __privateAdd$
|
|
712
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
697
713
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
698
714
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
699
715
|
};
|
|
700
|
-
var __privateSet$
|
|
701
|
-
__accessCheck$
|
|
716
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
717
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
702
718
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
703
719
|
return value;
|
|
704
720
|
};
|
|
705
|
-
var _client$
|
|
721
|
+
var _client$4, _httpRequest$5, _client2$4, _httpRequest2$5;
|
|
706
722
|
class ObservableAssetsClient {
|
|
707
723
|
constructor(client, httpRequest) {
|
|
708
|
-
__privateAdd$
|
|
709
|
-
__privateAdd$
|
|
710
|
-
__privateSet$
|
|
711
|
-
__privateSet$
|
|
724
|
+
__privateAdd$5(this, _client$4, void 0);
|
|
725
|
+
__privateAdd$5(this, _httpRequest$5, void 0);
|
|
726
|
+
__privateSet$5(this, _client$4, client);
|
|
727
|
+
__privateSet$5(this, _httpRequest$5, httpRequest);
|
|
712
728
|
}
|
|
713
729
|
upload(assetType, body, options) {
|
|
714
|
-
return _upload(__privateGet$
|
|
730
|
+
return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$5), assetType, body, options);
|
|
715
731
|
}
|
|
716
732
|
}
|
|
717
|
-
_client$
|
|
718
|
-
_httpRequest$
|
|
733
|
+
_client$4 = new WeakMap();
|
|
734
|
+
_httpRequest$5 = new WeakMap();
|
|
719
735
|
class AssetsClient {
|
|
720
736
|
constructor(client, httpRequest) {
|
|
721
|
-
__privateAdd$
|
|
722
|
-
__privateAdd$
|
|
723
|
-
__privateSet$
|
|
724
|
-
__privateSet$
|
|
737
|
+
__privateAdd$5(this, _client2$4, void 0);
|
|
738
|
+
__privateAdd$5(this, _httpRequest2$5, void 0);
|
|
739
|
+
__privateSet$5(this, _client2$4, client);
|
|
740
|
+
__privateSet$5(this, _httpRequest2$5, httpRequest);
|
|
725
741
|
}
|
|
726
742
|
upload(assetType, body, options) {
|
|
727
|
-
const observable = _upload(__privateGet$
|
|
743
|
+
const observable = _upload(__privateGet$5(this, _client2$4), __privateGet$5(this, _httpRequest2$5), assetType, body, options);
|
|
728
744
|
return rxjs.lastValueFrom(observable.pipe(operators.filter(event => event.type === "response"), operators.map(event => event.body.document)));
|
|
729
745
|
}
|
|
730
746
|
}
|
|
731
|
-
_client2$
|
|
732
|
-
_httpRequest2$
|
|
747
|
+
_client2$4 = new WeakMap();
|
|
748
|
+
_httpRequest2$5 = new WeakMap();
|
|
733
749
|
function _upload(client, httpRequest, assetType, body) {
|
|
734
750
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
735
751
|
validateAssetType(assetType);
|
|
@@ -783,65 +799,65 @@ function optionsFromFile(opts, file) {
|
|
|
783
799
|
contentType: file.type
|
|
784
800
|
}, opts);
|
|
785
801
|
}
|
|
786
|
-
var __accessCheck$
|
|
802
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
787
803
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
788
804
|
};
|
|
789
|
-
var __privateGet$
|
|
790
|
-
__accessCheck$
|
|
805
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
806
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
791
807
|
return getter ? getter.call(obj) : member.get(obj);
|
|
792
808
|
};
|
|
793
|
-
var __privateAdd$
|
|
809
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
794
810
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
795
811
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
796
812
|
};
|
|
797
|
-
var __privateSet$
|
|
798
|
-
__accessCheck$
|
|
813
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
814
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
799
815
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
800
816
|
return value;
|
|
801
817
|
};
|
|
802
|
-
var _client, _httpRequest$
|
|
818
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
803
819
|
class ObservableAuthClient {
|
|
804
820
|
constructor(client, httpRequest) {
|
|
805
|
-
__privateAdd$
|
|
806
|
-
__privateAdd$
|
|
807
|
-
__privateSet$
|
|
808
|
-
__privateSet$
|
|
821
|
+
__privateAdd$4(this, _client$3, void 0);
|
|
822
|
+
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
823
|
+
__privateSet$4(this, _client$3, client);
|
|
824
|
+
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
809
825
|
}
|
|
810
826
|
getLoginProviders() {
|
|
811
|
-
return _request(__privateGet$
|
|
827
|
+
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
812
828
|
uri: "/auth/providers"
|
|
813
829
|
});
|
|
814
830
|
}
|
|
815
831
|
logout() {
|
|
816
|
-
return _request(__privateGet$
|
|
832
|
+
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
817
833
|
uri: "/auth/logout",
|
|
818
834
|
method: "POST"
|
|
819
835
|
});
|
|
820
836
|
}
|
|
821
837
|
}
|
|
822
|
-
_client = new WeakMap();
|
|
823
|
-
_httpRequest$
|
|
838
|
+
_client$3 = new WeakMap();
|
|
839
|
+
_httpRequest$4 = new WeakMap();
|
|
824
840
|
class AuthClient {
|
|
825
841
|
constructor(client, httpRequest) {
|
|
826
|
-
__privateAdd$
|
|
827
|
-
__privateAdd$
|
|
828
|
-
__privateSet$
|
|
829
|
-
__privateSet$
|
|
842
|
+
__privateAdd$4(this, _client2$3, void 0);
|
|
843
|
+
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
844
|
+
__privateSet$4(this, _client2$3, client);
|
|
845
|
+
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
830
846
|
}
|
|
831
847
|
getLoginProviders() {
|
|
832
|
-
return rxjs.lastValueFrom(_request(__privateGet$
|
|
848
|
+
return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
833
849
|
uri: "/auth/providers"
|
|
834
850
|
}));
|
|
835
851
|
}
|
|
836
852
|
logout() {
|
|
837
|
-
return rxjs.lastValueFrom(_request(__privateGet$
|
|
853
|
+
return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
838
854
|
uri: "/auth/logout",
|
|
839
855
|
method: "POST"
|
|
840
856
|
}));
|
|
841
857
|
}
|
|
842
858
|
}
|
|
843
|
-
_client2 = new WeakMap();
|
|
844
|
-
_httpRequest2$
|
|
859
|
+
_client2$3 = new WeakMap();
|
|
860
|
+
_httpRequest2$4 = new WeakMap();
|
|
845
861
|
const BASE_URL = "https://docs.sanity.io/help/";
|
|
846
862
|
function generateHelpUrl(slug) {
|
|
847
863
|
return BASE_URL + slug;
|
|
@@ -971,7 +987,7 @@ function _listen(query, params) {
|
|
|
971
987
|
...listenOpts
|
|
972
988
|
}
|
|
973
989
|
});
|
|
974
|
-
const uri = "".concat(url).concat(this
|
|
990
|
+
const uri = "".concat(url).concat(_getDataUrl(this, "listen", qs));
|
|
975
991
|
if (uri.length > MAX_URL_LENGTH) {
|
|
976
992
|
return new rxjs.Observable(observer => observer.error(new Error("Query too large for listener")));
|
|
977
993
|
}
|
|
@@ -1074,101 +1090,183 @@ function extractErrorMessage(err) {
|
|
|
1074
1090
|
}
|
|
1075
1091
|
return typeof err.error === "string" ? err.error : JSON.stringify(err.error, null, 2);
|
|
1076
1092
|
}
|
|
1077
|
-
var __accessCheck$
|
|
1093
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
|
1078
1094
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
1079
1095
|
};
|
|
1080
|
-
var
|
|
1096
|
+
var __privateGet$3 = (obj, member, getter) => {
|
|
1097
|
+
__accessCheck$3(obj, member, "read from private field");
|
|
1098
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
1099
|
+
};
|
|
1100
|
+
var __privateAdd$3 = (obj, member, value) => {
|
|
1081
1101
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
1082
1102
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1083
1103
|
};
|
|
1084
|
-
var
|
|
1085
|
-
__accessCheck$
|
|
1086
|
-
|
|
1104
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
|
1105
|
+
__accessCheck$3(obj, member, "write to private field");
|
|
1106
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1107
|
+
return value;
|
|
1087
1108
|
};
|
|
1088
|
-
var
|
|
1089
|
-
class
|
|
1090
|
-
constructor() {
|
|
1091
|
-
__privateAdd$
|
|
1109
|
+
var _client$2, _httpRequest$3, _client2$2, _httpRequest2$3;
|
|
1110
|
+
class ObservableDatasetsClient {
|
|
1111
|
+
constructor(client, httpRequest) {
|
|
1112
|
+
__privateAdd$3(this, _client$2, void 0);
|
|
1113
|
+
__privateAdd$3(this, _httpRequest$3, void 0);
|
|
1114
|
+
__privateSet$3(this, _client$2, client);
|
|
1115
|
+
__privateSet$3(this, _httpRequest$3, httpRequest);
|
|
1092
1116
|
}
|
|
1093
1117
|
create(name, options) {
|
|
1094
|
-
return
|
|
1118
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PUT", name, options);
|
|
1095
1119
|
}
|
|
1096
1120
|
edit(name, options) {
|
|
1097
|
-
return
|
|
1121
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "PATCH", name, options);
|
|
1098
1122
|
}
|
|
1099
1123
|
delete(name) {
|
|
1100
|
-
return
|
|
1124
|
+
return _modify(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), "DELETE", name);
|
|
1101
1125
|
}
|
|
1102
1126
|
list() {
|
|
1103
|
-
return this
|
|
1127
|
+
return _request(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), {
|
|
1104
1128
|
uri: "/datasets"
|
|
1105
1129
|
});
|
|
1106
1130
|
}
|
|
1107
1131
|
}
|
|
1108
|
-
|
|
1109
|
-
|
|
1132
|
+
_client$2 = new WeakMap();
|
|
1133
|
+
_httpRequest$3 = new WeakMap();
|
|
1134
|
+
class DatasetsClient {
|
|
1135
|
+
constructor(client, httpRequest) {
|
|
1136
|
+
__privateAdd$3(this, _client2$2, void 0);
|
|
1137
|
+
__privateAdd$3(this, _httpRequest2$3, void 0);
|
|
1138
|
+
__privateSet$3(this, _client2$2, client);
|
|
1139
|
+
__privateSet$3(this, _httpRequest2$3, httpRequest);
|
|
1140
|
+
}
|
|
1141
|
+
create(name, options) {
|
|
1142
|
+
return rxjs.lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PUT", name, options));
|
|
1143
|
+
}
|
|
1144
|
+
edit(name, options) {
|
|
1145
|
+
return rxjs.lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "PATCH", name, options));
|
|
1146
|
+
}
|
|
1147
|
+
delete(name) {
|
|
1148
|
+
return rxjs.lastValueFrom(_modify(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), "DELETE", name));
|
|
1149
|
+
}
|
|
1150
|
+
list() {
|
|
1151
|
+
return rxjs.lastValueFrom(_request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), {
|
|
1152
|
+
uri: "/datasets"
|
|
1153
|
+
}));
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
_client2$2 = new WeakMap();
|
|
1157
|
+
_httpRequest2$3 = new WeakMap();
|
|
1158
|
+
function _modify(client, httpRequest, method, name, options) {
|
|
1110
1159
|
dataset(name);
|
|
1111
|
-
return
|
|
1160
|
+
return _request(client, httpRequest, {
|
|
1112
1161
|
method,
|
|
1113
1162
|
uri: "/datasets/".concat(name),
|
|
1114
1163
|
body: options
|
|
1115
1164
|
});
|
|
1116
|
-
};
|
|
1117
|
-
class ObservableDatasetsClient extends BaseDatasetsClient {
|
|
1118
|
-
constructor(client) {
|
|
1119
|
-
super();
|
|
1120
|
-
this.client = client;
|
|
1121
|
-
}
|
|
1122
1165
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1166
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
|
1167
|
+
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
1168
|
+
};
|
|
1169
|
+
var __privateGet$2 = (obj, member, getter) => {
|
|
1170
|
+
__accessCheck$2(obj, member, "read from private field");
|
|
1171
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
1172
|
+
};
|
|
1173
|
+
var __privateAdd$2 = (obj, member, value) => {
|
|
1174
|
+
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
1175
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1176
|
+
};
|
|
1177
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
|
1178
|
+
__accessCheck$2(obj, member, "write to private field");
|
|
1179
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1180
|
+
return value;
|
|
1181
|
+
};
|
|
1182
|
+
var _client$1, _httpRequest$2, _client2$1, _httpRequest2$2;
|
|
1183
|
+
class ObservableProjectsClient {
|
|
1184
|
+
constructor(client, httpRequest) {
|
|
1185
|
+
__privateAdd$2(this, _client$1, void 0);
|
|
1186
|
+
__privateAdd$2(this, _httpRequest$2, void 0);
|
|
1187
|
+
__privateSet$2(this, _client$1, client);
|
|
1188
|
+
__privateSet$2(this, _httpRequest$2, httpRequest);
|
|
1127
1189
|
}
|
|
1128
|
-
}
|
|
1129
|
-
class BaseProjectsClient {
|
|
1130
1190
|
list() {
|
|
1131
|
-
return this
|
|
1191
|
+
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), {
|
|
1132
1192
|
uri: "/projects"
|
|
1133
1193
|
});
|
|
1134
1194
|
}
|
|
1135
1195
|
getById(projectId) {
|
|
1136
|
-
return this
|
|
1196
|
+
return _request(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), {
|
|
1137
1197
|
uri: "/projects/".concat(projectId)
|
|
1138
1198
|
});
|
|
1139
1199
|
}
|
|
1140
1200
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1201
|
+
_client$1 = new WeakMap();
|
|
1202
|
+
_httpRequest$2 = new WeakMap();
|
|
1203
|
+
class ProjectsClient {
|
|
1204
|
+
constructor(client, httpRequest) {
|
|
1205
|
+
__privateAdd$2(this, _client2$1, void 0);
|
|
1206
|
+
__privateAdd$2(this, _httpRequest2$2, void 0);
|
|
1207
|
+
__privateSet$2(this, _client2$1, client);
|
|
1208
|
+
__privateSet$2(this, _httpRequest2$2, httpRequest);
|
|
1145
1209
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1210
|
+
list() {
|
|
1211
|
+
return rxjs.lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), {
|
|
1212
|
+
uri: "/projects"
|
|
1213
|
+
}));
|
|
1214
|
+
}
|
|
1215
|
+
getById(projectId) {
|
|
1216
|
+
return rxjs.lastValueFrom(_request(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), {
|
|
1217
|
+
uri: "/projects/".concat(projectId)
|
|
1218
|
+
}));
|
|
1151
1219
|
}
|
|
1152
1220
|
}
|
|
1153
|
-
|
|
1221
|
+
_client2$1 = new WeakMap();
|
|
1222
|
+
_httpRequest2$2 = new WeakMap();
|
|
1223
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
|
1224
|
+
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
1225
|
+
};
|
|
1226
|
+
var __privateGet$1 = (obj, member, getter) => {
|
|
1227
|
+
__accessCheck$1(obj, member, "read from private field");
|
|
1228
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
1229
|
+
};
|
|
1230
|
+
var __privateAdd$1 = (obj, member, value) => {
|
|
1231
|
+
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
1232
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1233
|
+
};
|
|
1234
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
|
1235
|
+
__accessCheck$1(obj, member, "write to private field");
|
|
1236
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1237
|
+
return value;
|
|
1238
|
+
};
|
|
1239
|
+
var _client, _httpRequest$1, _client2, _httpRequest2$1;
|
|
1240
|
+
class ObservableUsersClient {
|
|
1241
|
+
constructor(client, httpRequest) {
|
|
1242
|
+
__privateAdd$1(this, _client, void 0);
|
|
1243
|
+
__privateAdd$1(this, _httpRequest$1, void 0);
|
|
1244
|
+
__privateSet$1(this, _client, client);
|
|
1245
|
+
__privateSet$1(this, _httpRequest$1, httpRequest);
|
|
1246
|
+
}
|
|
1154
1247
|
getById(id) {
|
|
1155
|
-
return this
|
|
1248
|
+
return _request(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), {
|
|
1156
1249
|
uri: "/users/".concat(id)
|
|
1157
1250
|
});
|
|
1158
1251
|
}
|
|
1159
1252
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1253
|
+
_client = new WeakMap();
|
|
1254
|
+
_httpRequest$1 = new WeakMap();
|
|
1255
|
+
class UsersClient {
|
|
1256
|
+
constructor(client, httpRequest) {
|
|
1257
|
+
__privateAdd$1(this, _client2, void 0);
|
|
1258
|
+
__privateAdd$1(this, _httpRequest2$1, void 0);
|
|
1259
|
+
__privateSet$1(this, _client2, client);
|
|
1260
|
+
__privateSet$1(this, _httpRequest2$1, httpRequest);
|
|
1164
1261
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
this.client = client;
|
|
1262
|
+
getById(id) {
|
|
1263
|
+
return rxjs.lastValueFrom(_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
|
|
1264
|
+
uri: "/users/".concat(id)
|
|
1265
|
+
}));
|
|
1170
1266
|
}
|
|
1171
1267
|
}
|
|
1268
|
+
_client2 = new WeakMap();
|
|
1269
|
+
_httpRequest2$1 = new WeakMap();
|
|
1172
1270
|
var __accessCheck = (obj, member, msg) => {
|
|
1173
1271
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
1174
1272
|
};
|
|
@@ -1194,9 +1292,9 @@ const _ObservableSanityClient = class {
|
|
|
1194
1292
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1195
1293
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
1196
1294
|
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
1197
|
-
this.datasets = new ObservableDatasetsClient(this);
|
|
1198
|
-
this.projects = new ObservableProjectsClient(this);
|
|
1199
|
-
this.users = new ObservableUsersClient(this);
|
|
1295
|
+
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
1296
|
+
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
1297
|
+
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
1200
1298
|
}
|
|
1201
1299
|
clone() {
|
|
1202
1300
|
return new _ObservableSanityClient(__privateGet(this, _httpRequest), this.config());
|
|
@@ -1253,18 +1351,6 @@ const _ObservableSanityClient = class {
|
|
|
1253
1351
|
request(options) {
|
|
1254
1352
|
return _request(this, __privateGet(this, _httpRequest), options);
|
|
1255
1353
|
}
|
|
1256
|
-
getUrl(uri) {
|
|
1257
|
-
let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1258
|
-
const base = canUseCdn ? __privateGet(this, _clientConfig).cdnUrl : __privateGet(this, _clientConfig).url;
|
|
1259
|
-
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
1260
|
-
}
|
|
1261
|
-
getDataUrl(operation, path) {
|
|
1262
|
-
const config = this.config();
|
|
1263
|
-
const catalog = hasDataset(config);
|
|
1264
|
-
const baseUri = "/".concat(operation, "/").concat(catalog);
|
|
1265
|
-
const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
|
|
1266
|
-
return "/data".concat(uri).replace(/\/($|\?)/, "$1");
|
|
1267
|
-
}
|
|
1268
1354
|
};
|
|
1269
1355
|
let ObservableSanityClient = _ObservableSanityClient;
|
|
1270
1356
|
_clientConfig = new WeakMap();
|
|
@@ -1279,9 +1365,9 @@ const _SanityClient = class {
|
|
|
1279
1365
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1280
1366
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
1281
1367
|
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
1282
|
-
this.datasets = new DatasetsClient(this);
|
|
1283
|
-
this.projects = new ProjectsClient(this);
|
|
1284
|
-
this.users = new UsersClient(this);
|
|
1368
|
+
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
1369
|
+
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
1370
|
+
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|
|
1285
1371
|
}
|
|
1286
1372
|
clone() {
|
|
1287
1373
|
return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
|
|
@@ -1342,18 +1428,6 @@ const _SanityClient = class {
|
|
|
1342
1428
|
dataRequest(endpoint, body, options) {
|
|
1343
1429
|
return rxjs.lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
|
|
1344
1430
|
}
|
|
1345
|
-
getUrl(uri) {
|
|
1346
|
-
let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1347
|
-
const base = canUseCdn ? __privateGet(this, _clientConfig2).cdnUrl : __privateGet(this, _clientConfig2).url;
|
|
1348
|
-
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
1349
|
-
}
|
|
1350
|
-
getDataUrl(operation, path) {
|
|
1351
|
-
const config = this.config();
|
|
1352
|
-
const catalog = hasDataset(config);
|
|
1353
|
-
const baseUri = "/".concat(operation, "/").concat(catalog);
|
|
1354
|
-
const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
|
|
1355
|
-
return "/data".concat(uri).replace(/\/($|\?)/, "$1");
|
|
1356
|
-
}
|
|
1357
1431
|
};
|
|
1358
1432
|
let SanityClient = _SanityClient;
|
|
1359
1433
|
_clientConfig2 = new WeakMap();
|