@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.browser.cjs
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
6
6
|
var getIt = require('get-it');
|
|
7
7
|
var middleware = require('get-it/middleware');
|
|
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 envMiddleware = [];
|
|
19
|
-
class ClientError extends
|
|
18
|
+
class ClientError extends Error {
|
|
20
19
|
constructor(res) {
|
|
21
20
|
const props = extractErrorProps(res);
|
|
22
21
|
super(props.message);
|
|
@@ -24,7 +23,7 @@ class ClientError extends makeError.BaseError {
|
|
|
24
23
|
Object.assign(this, props);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
|
-
class ServerError extends
|
|
26
|
+
class ServerError extends Error {
|
|
28
27
|
constructor(res) {
|
|
29
28
|
const props = extractErrorProps(res);
|
|
30
29
|
super(props.message);
|
|
@@ -190,60 +189,50 @@ const requestTag = tag => {
|
|
|
190
189
|
}
|
|
191
190
|
return tag;
|
|
192
191
|
};
|
|
193
|
-
const enc = encodeURIComponent;
|
|
194
192
|
var encodeQueryString = _ref => {
|
|
195
193
|
let {
|
|
196
194
|
query,
|
|
197
195
|
params = {},
|
|
198
196
|
options = {}
|
|
199
197
|
} = _ref;
|
|
198
|
+
const searchParams = new URLSearchParams();
|
|
200
199
|
const {
|
|
201
200
|
tag,
|
|
202
201
|
...opts
|
|
203
202
|
} = options;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
203
|
+
if (tag) searchParams.set("tag", tag);
|
|
204
|
+
searchParams.set("query", query);
|
|
205
|
+
for (const [key, value] of Object.entries(params)) {
|
|
206
|
+
searchParams.set("$".concat(key), JSON.stringify(value));
|
|
207
|
+
}
|
|
208
|
+
for (const [key, value] of Object.entries(opts)) {
|
|
209
|
+
if (value) searchParams.set(key, "".concat(value));
|
|
210
|
+
}
|
|
211
|
+
return "?".concat(searchParams);
|
|
210
212
|
};
|
|
211
|
-
var __accessCheck$
|
|
213
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
212
214
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
213
215
|
};
|
|
214
|
-
var __privateGet$
|
|
215
|
-
__accessCheck$
|
|
216
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
217
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
216
218
|
return getter ? getter.call(obj) : member.get(obj);
|
|
217
219
|
};
|
|
218
|
-
var __privateAdd$
|
|
220
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
219
221
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
220
222
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
221
223
|
};
|
|
222
|
-
var __privateSet$
|
|
223
|
-
__accessCheck$
|
|
224
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
225
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
224
226
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
225
227
|
return value;
|
|
226
228
|
};
|
|
227
|
-
var _client$
|
|
229
|
+
var _client$5, _client2$5;
|
|
228
230
|
class BasePatch {
|
|
229
231
|
constructor(selection) {
|
|
230
232
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
231
233
|
this.selection = selection;
|
|
232
234
|
this.operations = operations;
|
|
233
235
|
}
|
|
234
|
-
/**
|
|
235
|
-
* DEPRECATED: Don't use.
|
|
236
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
237
|
-
*
|
|
238
|
-
* @deprecated - Don't use.
|
|
239
|
-
* @param attrs - Attributes to replace
|
|
240
|
-
*/
|
|
241
|
-
replace(attrs) {
|
|
242
|
-
validateObject("replace", attrs);
|
|
243
|
-
return this._set("set", {
|
|
244
|
-
$: attrs
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
236
|
/**
|
|
248
237
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
249
238
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
@@ -397,8 +386,8 @@ class BasePatch {
|
|
|
397
386
|
const _ObservablePatch = class extends BasePatch {
|
|
398
387
|
constructor(selection, operations, client) {
|
|
399
388
|
super(selection, operations);
|
|
400
|
-
__privateAdd$
|
|
401
|
-
__privateSet$
|
|
389
|
+
__privateAdd$6(this, _client$5, void 0);
|
|
390
|
+
__privateSet$6(this, _client$5, client);
|
|
402
391
|
}
|
|
403
392
|
/**
|
|
404
393
|
* Clones the patch
|
|
@@ -406,10 +395,10 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
406
395
|
clone() {
|
|
407
396
|
return new _ObservablePatch(this.selection, {
|
|
408
397
|
...this.operations
|
|
409
|
-
}, __privateGet$
|
|
398
|
+
}, __privateGet$6(this, _client$5));
|
|
410
399
|
}
|
|
411
400
|
commit(options) {
|
|
412
|
-
if (!__privateGet$
|
|
401
|
+
if (!__privateGet$6(this, _client$5)) {
|
|
413
402
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
414
403
|
}
|
|
415
404
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -417,18 +406,18 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
417
406
|
returnFirst,
|
|
418
407
|
returnDocuments: true
|
|
419
408
|
}, options);
|
|
420
|
-
return __privateGet$
|
|
409
|
+
return __privateGet$6(this, _client$5).mutate({
|
|
421
410
|
patch: this.serialize()
|
|
422
411
|
}, opts);
|
|
423
412
|
}
|
|
424
413
|
};
|
|
425
414
|
let ObservablePatch = _ObservablePatch;
|
|
426
|
-
_client$
|
|
415
|
+
_client$5 = new WeakMap();
|
|
427
416
|
const _Patch = class extends BasePatch {
|
|
428
417
|
constructor(selection, operations, client) {
|
|
429
418
|
super(selection, operations);
|
|
430
|
-
__privateAdd$
|
|
431
|
-
__privateSet$
|
|
419
|
+
__privateAdd$6(this, _client2$5, void 0);
|
|
420
|
+
__privateSet$6(this, _client2$5, client);
|
|
432
421
|
}
|
|
433
422
|
/**
|
|
434
423
|
* Clones the patch
|
|
@@ -436,10 +425,10 @@ const _Patch = class extends BasePatch {
|
|
|
436
425
|
clone() {
|
|
437
426
|
return new _Patch(this.selection, {
|
|
438
427
|
...this.operations
|
|
439
|
-
}, __privateGet$
|
|
428
|
+
}, __privateGet$6(this, _client2$5));
|
|
440
429
|
}
|
|
441
430
|
commit(options) {
|
|
442
|
-
if (!__privateGet$
|
|
431
|
+
if (!__privateGet$6(this, _client2$5)) {
|
|
443
432
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
444
433
|
}
|
|
445
434
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -447,30 +436,30 @@ const _Patch = class extends BasePatch {
|
|
|
447
436
|
returnFirst,
|
|
448
437
|
returnDocuments: true
|
|
449
438
|
}, options);
|
|
450
|
-
return __privateGet$
|
|
439
|
+
return __privateGet$6(this, _client2$5).mutate({
|
|
451
440
|
patch: this.serialize()
|
|
452
441
|
}, opts);
|
|
453
442
|
}
|
|
454
443
|
};
|
|
455
444
|
let Patch = _Patch;
|
|
456
|
-
_client2$
|
|
457
|
-
var __accessCheck$
|
|
445
|
+
_client2$5 = new WeakMap();
|
|
446
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
458
447
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
459
448
|
};
|
|
460
|
-
var __privateGet$
|
|
461
|
-
__accessCheck$
|
|
449
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
450
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
462
451
|
return getter ? getter.call(obj) : member.get(obj);
|
|
463
452
|
};
|
|
464
|
-
var __privateAdd$
|
|
453
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
465
454
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
466
455
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
467
456
|
};
|
|
468
|
-
var __privateSet$
|
|
469
|
-
__accessCheck$
|
|
457
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
458
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
470
459
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
471
460
|
return value;
|
|
472
461
|
};
|
|
473
|
-
var _client$
|
|
462
|
+
var _client$4, _client2$4;
|
|
474
463
|
const defaultMutateOptions = {
|
|
475
464
|
returnDocuments: false
|
|
476
465
|
};
|
|
@@ -569,20 +558,20 @@ class BaseTransaction {
|
|
|
569
558
|
const _Transaction = class extends BaseTransaction {
|
|
570
559
|
constructor(operations, client, transactionId) {
|
|
571
560
|
super(operations, transactionId);
|
|
572
|
-
__privateAdd$
|
|
573
|
-
__privateSet$
|
|
561
|
+
__privateAdd$5(this, _client$4, void 0);
|
|
562
|
+
__privateSet$5(this, _client$4, client);
|
|
574
563
|
}
|
|
575
564
|
/**
|
|
576
565
|
* Clones the transaction
|
|
577
566
|
*/
|
|
578
567
|
clone() {
|
|
579
|
-
return new _Transaction([...this.operations], __privateGet$
|
|
568
|
+
return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
|
|
580
569
|
}
|
|
581
570
|
commit(options) {
|
|
582
|
-
if (!__privateGet$
|
|
571
|
+
if (!__privateGet$5(this, _client$4)) {
|
|
583
572
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
584
573
|
}
|
|
585
|
-
return __privateGet$
|
|
574
|
+
return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
|
|
586
575
|
transactionId: this.trxId
|
|
587
576
|
}, defaultMutateOptions, options || {}));
|
|
588
577
|
}
|
|
@@ -595,7 +584,7 @@ const _Transaction = class extends BaseTransaction {
|
|
|
595
584
|
});
|
|
596
585
|
}
|
|
597
586
|
if (isBuilder) {
|
|
598
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$
|
|
587
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
|
|
599
588
|
if (!(patch instanceof Patch)) {
|
|
600
589
|
throw new Error("function passed to `patch()` must return the patch");
|
|
601
590
|
}
|
|
@@ -612,24 +601,24 @@ const _Transaction = class extends BaseTransaction {
|
|
|
612
601
|
}
|
|
613
602
|
};
|
|
614
603
|
let Transaction = _Transaction;
|
|
615
|
-
_client$
|
|
604
|
+
_client$4 = new WeakMap();
|
|
616
605
|
const _ObservableTransaction = class extends BaseTransaction {
|
|
617
606
|
constructor(operations, client, transactionId) {
|
|
618
607
|
super(operations, transactionId);
|
|
619
|
-
__privateAdd$
|
|
620
|
-
__privateSet$
|
|
608
|
+
__privateAdd$5(this, _client2$4, void 0);
|
|
609
|
+
__privateSet$5(this, _client2$4, client);
|
|
621
610
|
}
|
|
622
611
|
/**
|
|
623
612
|
* Clones the transaction
|
|
624
613
|
*/
|
|
625
614
|
clone() {
|
|
626
|
-
return new _ObservableTransaction([...this.operations], __privateGet$
|
|
615
|
+
return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
|
|
627
616
|
}
|
|
628
617
|
commit(options) {
|
|
629
|
-
if (!__privateGet$
|
|
618
|
+
if (!__privateGet$5(this, _client2$4)) {
|
|
630
619
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
631
620
|
}
|
|
632
|
-
return __privateGet$
|
|
621
|
+
return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
|
|
633
622
|
transactionId: this.trxId
|
|
634
623
|
}, defaultMutateOptions, options || {}));
|
|
635
624
|
}
|
|
@@ -642,7 +631,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
642
631
|
});
|
|
643
632
|
}
|
|
644
633
|
if (isBuilder) {
|
|
645
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$
|
|
634
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
|
|
646
635
|
if (!(patch instanceof ObservablePatch)) {
|
|
647
636
|
throw new Error("function passed to `patch()` must return the patch");
|
|
648
637
|
}
|
|
@@ -659,7 +648,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
659
648
|
}
|
|
660
649
|
};
|
|
661
650
|
let ObservableTransaction = _ObservableTransaction;
|
|
662
|
-
_client2$
|
|
651
|
+
_client2$4 = new WeakMap();
|
|
663
652
|
const excludeFalsey = (param, defValue) => {
|
|
664
653
|
const value = typeof param === "undefined" ? defValue : param;
|
|
665
654
|
return param === false ? void 0 : value;
|
|
@@ -807,7 +796,9 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
807
796
|
const reqOptions = getRequestOptions(config, Object.assign({}, options, {
|
|
808
797
|
url: _getUrl(client, uri, useCdn)
|
|
809
798
|
}));
|
|
810
|
-
return new rxjs.Observable(subscriber =>
|
|
799
|
+
return new rxjs.Observable(subscriber =>
|
|
800
|
+
// 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
|
|
801
|
+
httpRequest(reqOptions, config.requester).subscribe(subscriber));
|
|
811
802
|
}
|
|
812
803
|
function _request(client, httpRequest, options) {
|
|
813
804
|
const observable = _requestObservable(client, httpRequest, options).pipe(operators.filter(event => event.type === "response"), operators.map(event => event.body));
|
|
@@ -829,50 +820,50 @@ function _getUrl(client, uri) {
|
|
|
829
820
|
const base = canUseCdn ? cdnUrl : url;
|
|
830
821
|
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
831
822
|
}
|
|
832
|
-
var __accessCheck$
|
|
823
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
833
824
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
834
825
|
};
|
|
835
|
-
var __privateGet$
|
|
836
|
-
__accessCheck$
|
|
826
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
827
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
837
828
|
return getter ? getter.call(obj) : member.get(obj);
|
|
838
829
|
};
|
|
839
|
-
var __privateAdd$
|
|
830
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
840
831
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
841
832
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
842
833
|
};
|
|
843
|
-
var __privateSet$
|
|
844
|
-
__accessCheck$
|
|
834
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
835
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
845
836
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
846
837
|
return value;
|
|
847
838
|
};
|
|
848
|
-
var _client$
|
|
839
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
849
840
|
class ObservableAssetsClient {
|
|
850
841
|
constructor(client, httpRequest) {
|
|
851
|
-
__privateAdd$
|
|
852
|
-
__privateAdd$
|
|
853
|
-
__privateSet$
|
|
854
|
-
__privateSet$
|
|
842
|
+
__privateAdd$4(this, _client$3, void 0);
|
|
843
|
+
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
844
|
+
__privateSet$4(this, _client$3, client);
|
|
845
|
+
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
855
846
|
}
|
|
856
847
|
upload(assetType, body, options) {
|
|
857
|
-
return _upload(__privateGet$
|
|
848
|
+
return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
|
|
858
849
|
}
|
|
859
850
|
}
|
|
860
|
-
_client$
|
|
861
|
-
_httpRequest$
|
|
851
|
+
_client$3 = new WeakMap();
|
|
852
|
+
_httpRequest$4 = new WeakMap();
|
|
862
853
|
class AssetsClient {
|
|
863
854
|
constructor(client, httpRequest) {
|
|
864
|
-
__privateAdd$
|
|
865
|
-
__privateAdd$
|
|
866
|
-
__privateSet$
|
|
867
|
-
__privateSet$
|
|
855
|
+
__privateAdd$4(this, _client2$3, void 0);
|
|
856
|
+
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
857
|
+
__privateSet$4(this, _client2$3, client);
|
|
858
|
+
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
868
859
|
}
|
|
869
860
|
upload(assetType, body, options) {
|
|
870
|
-
const observable = _upload(__privateGet$
|
|
861
|
+
const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
|
|
871
862
|
return rxjs.lastValueFrom(observable.pipe(operators.filter(event => event.type === "response"), operators.map(event => event.body.document)));
|
|
872
863
|
}
|
|
873
864
|
}
|
|
874
|
-
_client2$
|
|
875
|
-
_httpRequest2$
|
|
865
|
+
_client2$3 = new WeakMap();
|
|
866
|
+
_httpRequest2$4 = new WeakMap();
|
|
876
867
|
function _upload(client, httpRequest, assetType, body) {
|
|
877
868
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
878
869
|
validateAssetType(assetType);
|
|
@@ -926,78 +917,7 @@ function optionsFromFile(opts, file) {
|
|
|
926
917
|
contentType: file.type
|
|
927
918
|
}, opts);
|
|
928
919
|
}
|
|
929
|
-
|
|
930
|
-
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
931
|
-
};
|
|
932
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
933
|
-
__accessCheck$4(obj, member, "read from private field");
|
|
934
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
935
|
-
};
|
|
936
|
-
var __privateAdd$4 = (obj, member, value) => {
|
|
937
|
-
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
938
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
939
|
-
};
|
|
940
|
-
var __privateSet$4 = (obj, member, value, setter) => {
|
|
941
|
-
__accessCheck$4(obj, member, "write to private field");
|
|
942
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
943
|
-
return value;
|
|
944
|
-
};
|
|
945
|
-
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
946
|
-
class ObservableAuthClient {
|
|
947
|
-
constructor(client, httpRequest) {
|
|
948
|
-
__privateAdd$4(this, _client$3, void 0);
|
|
949
|
-
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
950
|
-
__privateSet$4(this, _client$3, client);
|
|
951
|
-
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* Fetch available login providers
|
|
955
|
-
*/
|
|
956
|
-
getLoginProviders() {
|
|
957
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
958
|
-
uri: "/auth/providers"
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Revoke the configured session/token
|
|
963
|
-
*/
|
|
964
|
-
logout() {
|
|
965
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
966
|
-
uri: "/auth/logout",
|
|
967
|
-
method: "POST"
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
_client$3 = new WeakMap();
|
|
972
|
-
_httpRequest$4 = new WeakMap();
|
|
973
|
-
class AuthClient {
|
|
974
|
-
constructor(client, httpRequest) {
|
|
975
|
-
__privateAdd$4(this, _client2$3, void 0);
|
|
976
|
-
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
977
|
-
__privateSet$4(this, _client2$3, client);
|
|
978
|
-
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
979
|
-
}
|
|
980
|
-
/**
|
|
981
|
-
* Fetch available login providers
|
|
982
|
-
*/
|
|
983
|
-
getLoginProviders() {
|
|
984
|
-
return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
985
|
-
uri: "/auth/providers"
|
|
986
|
-
}));
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* Revoke the configured session/token
|
|
990
|
-
*/
|
|
991
|
-
logout() {
|
|
992
|
-
return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
993
|
-
uri: "/auth/logout",
|
|
994
|
-
method: "POST"
|
|
995
|
-
}));
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
_client2$3 = new WeakMap();
|
|
999
|
-
_httpRequest2$4 = new WeakMap();
|
|
1000
|
-
const BASE_URL = "https://docs.sanity.io/help/";
|
|
920
|
+
const BASE_URL = "https://www.sanity.io/help/";
|
|
1001
921
|
function generateHelpUrl(slug) {
|
|
1002
922
|
return BASE_URL + slug;
|
|
1003
923
|
}
|
|
@@ -1021,7 +941,7 @@ once(function () {
|
|
|
1021
941
|
}
|
|
1022
942
|
return console.warn(message.join(" "), ...args);
|
|
1023
943
|
});
|
|
1024
|
-
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"), "
|
|
944
|
+
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."]);
|
|
1025
945
|
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.")]);
|
|
1026
946
|
const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
|
|
1027
947
|
const defaultCdnHost = "apicdn.sanity.io";
|
|
@@ -1499,10 +1419,13 @@ const _ObservableSanityClient = class {
|
|
|
1499
1419
|
*/
|
|
1500
1420
|
__privateAdd(this, _clientConfig, void 0);
|
|
1501
1421
|
__privateAdd(this, _httpRequest, void 0);
|
|
1422
|
+
/**
|
|
1423
|
+
* Instance properties
|
|
1424
|
+
*/
|
|
1425
|
+
this.listen = _listen;
|
|
1502
1426
|
this.config(config);
|
|
1503
1427
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1504
1428
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
1505
|
-
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
1506
1429
|
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
1507
1430
|
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
1508
1431
|
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
@@ -1553,7 +1476,7 @@ const _ObservableSanityClient = class {
|
|
|
1553
1476
|
* Fetch multiple documents in one request.
|
|
1554
1477
|
* Should be used sparingly - performing a query is usually a better option.
|
|
1555
1478
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1556
|
-
* If
|
|
1479
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1557
1480
|
*
|
|
1558
1481
|
* @param ids - Document IDs to fetch
|
|
1559
1482
|
* @param options - Request options
|
|
@@ -1621,7 +1544,6 @@ const _SanityClient = class {
|
|
|
1621
1544
|
this.config(config);
|
|
1622
1545
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1623
1546
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
1624
|
-
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
1625
1547
|
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
1626
1548
|
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
1627
1549
|
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|
|
@@ -1676,7 +1598,7 @@ const _SanityClient = class {
|
|
|
1676
1598
|
* Fetch multiple documents in one request.
|
|
1677
1599
|
* Should be used sparingly - performing a query is usually a better option.
|
|
1678
1600
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1679
|
-
* If
|
|
1601
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1680
1602
|
*
|
|
1681
1603
|
* @param ids - Document IDs to fetch
|
|
1682
1604
|
* @param options - Request options
|