@sanity/client 5.0.0-esm.8 → 5.0.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/README.md +247 -118
- package/dist/index.browser.cjs +84 -162
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +84 -162
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +85 -163
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +168 -169
- package/dist/index.js +85 -163
- package/dist/index.js.map +1 -1
- package/package.json +23 -24
- package/src/SanityClient.ts +97 -98
- package/src/assets/AssetsClient.ts +33 -8
- package/src/config.ts +1 -0
- package/src/data/dataMethods.ts +30 -28
- package/src/data/encodeQueryString.ts +17 -16
- package/src/data/listen.ts +13 -13
- package/src/data/patch.ts +17 -28
- package/src/data/transaction.ts +15 -12
- package/src/datasets/DatasetsClient.ts +1 -1
- package/src/generateHelpUrl.ts +1 -1
- package/src/http/errors.ts +9 -11
- package/src/http/request.ts +5 -5
- package/src/http/requestOptions.ts +4 -2
- package/src/projects/ProjectsClient.ts +1 -1
- package/src/types.ts +36 -30
- package/src/users/UsersClient.ts +1 -1
- package/src/util/defaults.ts +4 -2
- package/src/util/once.ts +5 -3
- package/src/util/pick.ts +4 -2
- package/src/validators.ts +4 -4
- package/src/warnings.ts +3 -2
- package/umd/sanityClient.js +111 -414
- package/umd/sanityClient.min.js +3 -3
- package/src/auth/AuthClient.ts +0 -67
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
6
6
|
var middleware$1 = require('get-it/middleware');
|
|
7
7
|
var getIt = require('get-it');
|
|
8
8
|
var rxjs = require('rxjs');
|
|
9
|
-
var makeError = require('make-error');
|
|
10
9
|
var operators = require('rxjs/operators');
|
|
11
10
|
var polyfilledEventSource = require('@sanity/eventsource');
|
|
12
11
|
function _interopDefaultCompat(e) {
|
|
@@ -16,7 +15,7 @@ function _interopDefaultCompat(e) {
|
|
|
16
15
|
}
|
|
17
16
|
var polyfilledEventSource__default = /*#__PURE__*/_interopDefaultCompat(polyfilledEventSource);
|
|
18
17
|
var name = "@sanity/client";
|
|
19
|
-
var version = "5.0.0
|
|
18
|
+
var version = "5.0.0";
|
|
20
19
|
const middleware = [middleware$1.debug({
|
|
21
20
|
verbose: true,
|
|
22
21
|
namespace: "sanity:client"
|
|
@@ -25,7 +24,7 @@ const middleware = [middleware$1.debug({
|
|
|
25
24
|
}), middleware$1.retry({
|
|
26
25
|
maxRetries: 3
|
|
27
26
|
})];
|
|
28
|
-
class ClientError extends
|
|
27
|
+
class ClientError extends Error {
|
|
29
28
|
constructor(res) {
|
|
30
29
|
const props = extractErrorProps(res);
|
|
31
30
|
super(props.message);
|
|
@@ -33,7 +32,7 @@ class ClientError extends makeError.BaseError {
|
|
|
33
32
|
Object.assign(this, props);
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
class ServerError extends
|
|
35
|
+
class ServerError extends Error {
|
|
37
36
|
constructor(res) {
|
|
38
37
|
const props = extractErrorProps(res);
|
|
39
38
|
super(props.message);
|
|
@@ -199,60 +198,50 @@ const requestTag = tag => {
|
|
|
199
198
|
}
|
|
200
199
|
return tag;
|
|
201
200
|
};
|
|
202
|
-
const enc = encodeURIComponent;
|
|
203
201
|
var encodeQueryString = _ref => {
|
|
204
202
|
let {
|
|
205
203
|
query,
|
|
206
204
|
params = {},
|
|
207
205
|
options = {}
|
|
208
206
|
} = _ref;
|
|
207
|
+
const searchParams = new URLSearchParams();
|
|
209
208
|
const {
|
|
210
209
|
tag,
|
|
211
210
|
...opts
|
|
212
211
|
} = options;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
212
|
+
if (tag) searchParams.set("tag", tag);
|
|
213
|
+
searchParams.set("query", query);
|
|
214
|
+
for (const [key, value] of Object.entries(params)) {
|
|
215
|
+
searchParams.set("$".concat(key), JSON.stringify(value));
|
|
216
|
+
}
|
|
217
|
+
for (const [key, value] of Object.entries(opts)) {
|
|
218
|
+
if (value) searchParams.set(key, "".concat(value));
|
|
219
|
+
}
|
|
220
|
+
return "?".concat(searchParams);
|
|
219
221
|
};
|
|
220
|
-
var __accessCheck$
|
|
222
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
221
223
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
222
224
|
};
|
|
223
|
-
var __privateGet$
|
|
224
|
-
__accessCheck$
|
|
225
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
226
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
225
227
|
return getter ? getter.call(obj) : member.get(obj);
|
|
226
228
|
};
|
|
227
|
-
var __privateAdd$
|
|
229
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
228
230
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
229
231
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
230
232
|
};
|
|
231
|
-
var __privateSet$
|
|
232
|
-
__accessCheck$
|
|
233
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
234
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
233
235
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
234
236
|
return value;
|
|
235
237
|
};
|
|
236
|
-
var _client$
|
|
238
|
+
var _client$5, _client2$5;
|
|
237
239
|
class BasePatch {
|
|
238
240
|
constructor(selection) {
|
|
239
241
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
240
242
|
this.selection = selection;
|
|
241
243
|
this.operations = operations;
|
|
242
244
|
}
|
|
243
|
-
/**
|
|
244
|
-
* DEPRECATED: Don't use.
|
|
245
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
246
|
-
*
|
|
247
|
-
* @deprecated - Don't use.
|
|
248
|
-
* @param attrs - Attributes to replace
|
|
249
|
-
*/
|
|
250
|
-
replace(attrs) {
|
|
251
|
-
validateObject("replace", attrs);
|
|
252
|
-
return this._set("set", {
|
|
253
|
-
$: attrs
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
245
|
/**
|
|
257
246
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
258
247
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
@@ -406,8 +395,8 @@ class BasePatch {
|
|
|
406
395
|
const _ObservablePatch = class extends BasePatch {
|
|
407
396
|
constructor(selection, operations, client) {
|
|
408
397
|
super(selection, operations);
|
|
409
|
-
__privateAdd$
|
|
410
|
-
__privateSet$
|
|
398
|
+
__privateAdd$6(this, _client$5, void 0);
|
|
399
|
+
__privateSet$6(this, _client$5, client);
|
|
411
400
|
}
|
|
412
401
|
/**
|
|
413
402
|
* Clones the patch
|
|
@@ -415,10 +404,10 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
415
404
|
clone() {
|
|
416
405
|
return new _ObservablePatch(this.selection, {
|
|
417
406
|
...this.operations
|
|
418
|
-
}, __privateGet$
|
|
407
|
+
}, __privateGet$6(this, _client$5));
|
|
419
408
|
}
|
|
420
409
|
commit(options) {
|
|
421
|
-
if (!__privateGet$
|
|
410
|
+
if (!__privateGet$6(this, _client$5)) {
|
|
422
411
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
423
412
|
}
|
|
424
413
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -426,18 +415,18 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
426
415
|
returnFirst,
|
|
427
416
|
returnDocuments: true
|
|
428
417
|
}, options);
|
|
429
|
-
return __privateGet$
|
|
418
|
+
return __privateGet$6(this, _client$5).mutate({
|
|
430
419
|
patch: this.serialize()
|
|
431
420
|
}, opts);
|
|
432
421
|
}
|
|
433
422
|
};
|
|
434
423
|
let ObservablePatch = _ObservablePatch;
|
|
435
|
-
_client$
|
|
424
|
+
_client$5 = new WeakMap();
|
|
436
425
|
const _Patch = class extends BasePatch {
|
|
437
426
|
constructor(selection, operations, client) {
|
|
438
427
|
super(selection, operations);
|
|
439
|
-
__privateAdd$
|
|
440
|
-
__privateSet$
|
|
428
|
+
__privateAdd$6(this, _client2$5, void 0);
|
|
429
|
+
__privateSet$6(this, _client2$5, client);
|
|
441
430
|
}
|
|
442
431
|
/**
|
|
443
432
|
* Clones the patch
|
|
@@ -445,10 +434,10 @@ const _Patch = class extends BasePatch {
|
|
|
445
434
|
clone() {
|
|
446
435
|
return new _Patch(this.selection, {
|
|
447
436
|
...this.operations
|
|
448
|
-
}, __privateGet$
|
|
437
|
+
}, __privateGet$6(this, _client2$5));
|
|
449
438
|
}
|
|
450
439
|
commit(options) {
|
|
451
|
-
if (!__privateGet$
|
|
440
|
+
if (!__privateGet$6(this, _client2$5)) {
|
|
452
441
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
453
442
|
}
|
|
454
443
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -456,30 +445,30 @@ const _Patch = class extends BasePatch {
|
|
|
456
445
|
returnFirst,
|
|
457
446
|
returnDocuments: true
|
|
458
447
|
}, options);
|
|
459
|
-
return __privateGet$
|
|
448
|
+
return __privateGet$6(this, _client2$5).mutate({
|
|
460
449
|
patch: this.serialize()
|
|
461
450
|
}, opts);
|
|
462
451
|
}
|
|
463
452
|
};
|
|
464
453
|
let Patch = _Patch;
|
|
465
|
-
_client2$
|
|
466
|
-
var __accessCheck$
|
|
454
|
+
_client2$5 = new WeakMap();
|
|
455
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
467
456
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
468
457
|
};
|
|
469
|
-
var __privateGet$
|
|
470
|
-
__accessCheck$
|
|
458
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
459
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
471
460
|
return getter ? getter.call(obj) : member.get(obj);
|
|
472
461
|
};
|
|
473
|
-
var __privateAdd$
|
|
462
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
474
463
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
475
464
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
476
465
|
};
|
|
477
|
-
var __privateSet$
|
|
478
|
-
__accessCheck$
|
|
466
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
467
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
479
468
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
480
469
|
return value;
|
|
481
470
|
};
|
|
482
|
-
var _client$
|
|
471
|
+
var _client$4, _client2$4;
|
|
483
472
|
const defaultMutateOptions = {
|
|
484
473
|
returnDocuments: false
|
|
485
474
|
};
|
|
@@ -578,20 +567,20 @@ class BaseTransaction {
|
|
|
578
567
|
const _Transaction = class extends BaseTransaction {
|
|
579
568
|
constructor(operations, client, transactionId) {
|
|
580
569
|
super(operations, transactionId);
|
|
581
|
-
__privateAdd$
|
|
582
|
-
__privateSet$
|
|
570
|
+
__privateAdd$5(this, _client$4, void 0);
|
|
571
|
+
__privateSet$5(this, _client$4, client);
|
|
583
572
|
}
|
|
584
573
|
/**
|
|
585
574
|
* Clones the transaction
|
|
586
575
|
*/
|
|
587
576
|
clone() {
|
|
588
|
-
return new _Transaction([...this.operations], __privateGet$
|
|
577
|
+
return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
|
|
589
578
|
}
|
|
590
579
|
commit(options) {
|
|
591
|
-
if (!__privateGet$
|
|
580
|
+
if (!__privateGet$5(this, _client$4)) {
|
|
592
581
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
593
582
|
}
|
|
594
|
-
return __privateGet$
|
|
583
|
+
return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
|
|
595
584
|
transactionId: this.trxId
|
|
596
585
|
}, defaultMutateOptions, options || {}));
|
|
597
586
|
}
|
|
@@ -604,7 +593,7 @@ const _Transaction = class extends BaseTransaction {
|
|
|
604
593
|
});
|
|
605
594
|
}
|
|
606
595
|
if (isBuilder) {
|
|
607
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$
|
|
596
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
|
|
608
597
|
if (!(patch instanceof Patch)) {
|
|
609
598
|
throw new Error("function passed to `patch()` must return the patch");
|
|
610
599
|
}
|
|
@@ -621,24 +610,24 @@ const _Transaction = class extends BaseTransaction {
|
|
|
621
610
|
}
|
|
622
611
|
};
|
|
623
612
|
let Transaction = _Transaction;
|
|
624
|
-
_client$
|
|
613
|
+
_client$4 = new WeakMap();
|
|
625
614
|
const _ObservableTransaction = class extends BaseTransaction {
|
|
626
615
|
constructor(operations, client, transactionId) {
|
|
627
616
|
super(operations, transactionId);
|
|
628
|
-
__privateAdd$
|
|
629
|
-
__privateSet$
|
|
617
|
+
__privateAdd$5(this, _client2$4, void 0);
|
|
618
|
+
__privateSet$5(this, _client2$4, client);
|
|
630
619
|
}
|
|
631
620
|
/**
|
|
632
621
|
* Clones the transaction
|
|
633
622
|
*/
|
|
634
623
|
clone() {
|
|
635
|
-
return new _ObservableTransaction([...this.operations], __privateGet$
|
|
624
|
+
return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
|
|
636
625
|
}
|
|
637
626
|
commit(options) {
|
|
638
|
-
if (!__privateGet$
|
|
627
|
+
if (!__privateGet$5(this, _client2$4)) {
|
|
639
628
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
640
629
|
}
|
|
641
|
-
return __privateGet$
|
|
630
|
+
return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
|
|
642
631
|
transactionId: this.trxId
|
|
643
632
|
}, defaultMutateOptions, options || {}));
|
|
644
633
|
}
|
|
@@ -651,7 +640,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
651
640
|
});
|
|
652
641
|
}
|
|
653
642
|
if (isBuilder) {
|
|
654
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$
|
|
643
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
|
|
655
644
|
if (!(patch instanceof ObservablePatch)) {
|
|
656
645
|
throw new Error("function passed to `patch()` must return the patch");
|
|
657
646
|
}
|
|
@@ -668,7 +657,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
668
657
|
}
|
|
669
658
|
};
|
|
670
659
|
let ObservableTransaction = _ObservableTransaction;
|
|
671
|
-
_client2$
|
|
660
|
+
_client2$4 = new WeakMap();
|
|
672
661
|
const excludeFalsey = (param, defValue) => {
|
|
673
662
|
const value = typeof param === "undefined" ? defValue : param;
|
|
674
663
|
return param === false ? void 0 : value;
|
|
@@ -816,7 +805,9 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
816
805
|
const reqOptions = getRequestOptions(config, Object.assign({}, options, {
|
|
817
806
|
url: _getUrl(client, uri, useCdn)
|
|
818
807
|
}));
|
|
819
|
-
return new rxjs.Observable(subscriber =>
|
|
808
|
+
return new rxjs.Observable(subscriber =>
|
|
809
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- the typings thinks it's optional because it's not required to specify it when calling createClient, but it's always defined in practice since SanityClient provides a default
|
|
810
|
+
httpRequest(reqOptions, config.requester).subscribe(subscriber));
|
|
820
811
|
}
|
|
821
812
|
function _request(client, httpRequest, options) {
|
|
822
813
|
const observable = _requestObservable(client, httpRequest, options).pipe(operators.filter(event => event.type === "response"), operators.map(event => event.body));
|
|
@@ -838,50 +829,50 @@ function _getUrl(client, uri) {
|
|
|
838
829
|
const base = canUseCdn ? cdnUrl : url;
|
|
839
830
|
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
840
831
|
}
|
|
841
|
-
var __accessCheck$
|
|
832
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
842
833
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
843
834
|
};
|
|
844
|
-
var __privateGet$
|
|
845
|
-
__accessCheck$
|
|
835
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
836
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
846
837
|
return getter ? getter.call(obj) : member.get(obj);
|
|
847
838
|
};
|
|
848
|
-
var __privateAdd$
|
|
839
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
849
840
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
850
841
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
851
842
|
};
|
|
852
|
-
var __privateSet$
|
|
853
|
-
__accessCheck$
|
|
843
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
844
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
854
845
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
855
846
|
return value;
|
|
856
847
|
};
|
|
857
|
-
var _client$
|
|
848
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
858
849
|
class ObservableAssetsClient {
|
|
859
850
|
constructor(client, httpRequest) {
|
|
860
|
-
__privateAdd$
|
|
861
|
-
__privateAdd$
|
|
862
|
-
__privateSet$
|
|
863
|
-
__privateSet$
|
|
851
|
+
__privateAdd$4(this, _client$3, void 0);
|
|
852
|
+
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
853
|
+
__privateSet$4(this, _client$3, client);
|
|
854
|
+
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
864
855
|
}
|
|
865
856
|
upload(assetType, body, options) {
|
|
866
|
-
return _upload(__privateGet$
|
|
857
|
+
return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
|
|
867
858
|
}
|
|
868
859
|
}
|
|
869
|
-
_client$
|
|
870
|
-
_httpRequest$
|
|
860
|
+
_client$3 = new WeakMap();
|
|
861
|
+
_httpRequest$4 = new WeakMap();
|
|
871
862
|
class AssetsClient {
|
|
872
863
|
constructor(client, httpRequest) {
|
|
873
|
-
__privateAdd$
|
|
874
|
-
__privateAdd$
|
|
875
|
-
__privateSet$
|
|
876
|
-
__privateSet$
|
|
864
|
+
__privateAdd$4(this, _client2$3, void 0);
|
|
865
|
+
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
866
|
+
__privateSet$4(this, _client2$3, client);
|
|
867
|
+
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
877
868
|
}
|
|
878
869
|
upload(assetType, body, options) {
|
|
879
|
-
const observable = _upload(__privateGet$
|
|
870
|
+
const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
|
|
880
871
|
return rxjs.lastValueFrom(observable.pipe(operators.filter(event => event.type === "response"), operators.map(event => event.body.document)));
|
|
881
872
|
}
|
|
882
873
|
}
|
|
883
|
-
_client2$
|
|
884
|
-
_httpRequest2$
|
|
874
|
+
_client2$3 = new WeakMap();
|
|
875
|
+
_httpRequest2$4 = new WeakMap();
|
|
885
876
|
function _upload(client, httpRequest, assetType, body) {
|
|
886
877
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
887
878
|
validateAssetType(assetType);
|
|
@@ -935,78 +926,7 @@ function optionsFromFile(opts, file) {
|
|
|
935
926
|
contentType: file.type
|
|
936
927
|
}, opts);
|
|
937
928
|
}
|
|
938
|
-
|
|
939
|
-
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
940
|
-
};
|
|
941
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
942
|
-
__accessCheck$4(obj, member, "read from private field");
|
|
943
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
944
|
-
};
|
|
945
|
-
var __privateAdd$4 = (obj, member, value) => {
|
|
946
|
-
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
947
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
948
|
-
};
|
|
949
|
-
var __privateSet$4 = (obj, member, value, setter) => {
|
|
950
|
-
__accessCheck$4(obj, member, "write to private field");
|
|
951
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
952
|
-
return value;
|
|
953
|
-
};
|
|
954
|
-
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
955
|
-
class ObservableAuthClient {
|
|
956
|
-
constructor(client, httpRequest) {
|
|
957
|
-
__privateAdd$4(this, _client$3, void 0);
|
|
958
|
-
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
959
|
-
__privateSet$4(this, _client$3, client);
|
|
960
|
-
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
961
|
-
}
|
|
962
|
-
/**
|
|
963
|
-
* Fetch available login providers
|
|
964
|
-
*/
|
|
965
|
-
getLoginProviders() {
|
|
966
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
967
|
-
uri: "/auth/providers"
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* Revoke the configured session/token
|
|
972
|
-
*/
|
|
973
|
-
logout() {
|
|
974
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
975
|
-
uri: "/auth/logout",
|
|
976
|
-
method: "POST"
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
_client$3 = new WeakMap();
|
|
981
|
-
_httpRequest$4 = new WeakMap();
|
|
982
|
-
class AuthClient {
|
|
983
|
-
constructor(client, httpRequest) {
|
|
984
|
-
__privateAdd$4(this, _client2$3, void 0);
|
|
985
|
-
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
986
|
-
__privateSet$4(this, _client2$3, client);
|
|
987
|
-
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* Fetch available login providers
|
|
991
|
-
*/
|
|
992
|
-
getLoginProviders() {
|
|
993
|
-
return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
994
|
-
uri: "/auth/providers"
|
|
995
|
-
}));
|
|
996
|
-
}
|
|
997
|
-
/**
|
|
998
|
-
* Revoke the configured session/token
|
|
999
|
-
*/
|
|
1000
|
-
logout() {
|
|
1001
|
-
return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
1002
|
-
uri: "/auth/logout",
|
|
1003
|
-
method: "POST"
|
|
1004
|
-
}));
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
_client2$3 = new WeakMap();
|
|
1008
|
-
_httpRequest2$4 = new WeakMap();
|
|
1009
|
-
const BASE_URL = "https://docs.sanity.io/help/";
|
|
929
|
+
const BASE_URL = "https://www.sanity.io/help/";
|
|
1010
930
|
function generateHelpUrl(slug) {
|
|
1011
931
|
return BASE_URL + slug;
|
|
1012
932
|
}
|
|
@@ -1030,7 +950,7 @@ once(function () {
|
|
|
1030
950
|
}
|
|
1031
951
|
return console.warn(message.join(" "), ...args);
|
|
1032
952
|
});
|
|
1033
|
-
const printCdnWarning = createWarningPrinter(["You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and", "cheaper. Think about it! For more info, see ".concat(generateHelpUrl("js-client-cdn-configuration"), "
|
|
953
|
+
const printCdnWarning = createWarningPrinter(["You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and", "cheaper. Think about it! For more info, see ".concat(generateHelpUrl("js-client-cdn-configuration"), " "), "To hide this warning, please set the `useCdn` option to either `true` or `false` when creating", "the client."]);
|
|
1034
954
|
const printBrowserTokenWarning = createWarningPrinter(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.", "See ".concat(generateHelpUrl("js-client-browser-token"), " for more information and how to hide this warning.")]);
|
|
1035
955
|
const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
|
|
1036
956
|
const defaultCdnHost = "apicdn.sanity.io";
|
|
@@ -1508,10 +1428,13 @@ const _ObservableSanityClient = class {
|
|
|
1508
1428
|
*/
|
|
1509
1429
|
__privateAdd(this, _clientConfig, void 0);
|
|
1510
1430
|
__privateAdd(this, _httpRequest, void 0);
|
|
1431
|
+
/**
|
|
1432
|
+
* Instance properties
|
|
1433
|
+
*/
|
|
1434
|
+
this.listen = _listen;
|
|
1511
1435
|
this.config(config);
|
|
1512
1436
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1513
1437
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
1514
|
-
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
1515
1438
|
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
1516
1439
|
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
1517
1440
|
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
@@ -1562,7 +1485,7 @@ const _ObservableSanityClient = class {
|
|
|
1562
1485
|
* Fetch multiple documents in one request.
|
|
1563
1486
|
* Should be used sparingly - performing a query is usually a better option.
|
|
1564
1487
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1565
|
-
* If
|
|
1488
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1566
1489
|
*
|
|
1567
1490
|
* @param ids - Document IDs to fetch
|
|
1568
1491
|
* @param options - Request options
|
|
@@ -1630,7 +1553,6 @@ const _SanityClient = class {
|
|
|
1630
1553
|
this.config(config);
|
|
1631
1554
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1632
1555
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
1633
|
-
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
1634
1556
|
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
1635
1557
|
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
1636
1558
|
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|
|
@@ -1685,7 +1607,7 @@ const _SanityClient = class {
|
|
|
1685
1607
|
* Fetch multiple documents in one request.
|
|
1686
1608
|
* Should be used sparingly - performing a query is usually a better option.
|
|
1687
1609
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1688
|
-
* If
|
|
1610
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1689
1611
|
*
|
|
1690
1612
|
* @param ids - Document IDs to fetch
|
|
1691
1613
|
* @param options - Request options
|