@sanity/client 5.0.0-esm.9 → 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 +141 -65
- package/dist/index.browser.cjs +82 -162
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +82 -162
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +83 -163
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +51 -58
- package/dist/index.js +83 -163
- package/dist/index.js.map +1 -1
- package/package.json +22 -23
- package/src/SanityClient.ts +23 -25
- package/src/assets/AssetsClient.ts +29 -5
- package/src/data/dataMethods.ts +2 -2
- package/src/data/encodeQueryString.ts +15 -14
- package/src/data/listen.ts +4 -4
- package/src/data/patch.ts +1 -13
- package/src/datasets/DatasetsClient.ts +1 -1
- package/src/generateHelpUrl.ts +1 -1
- package/src/http/errors.ts +3 -5
- package/src/http/request.ts +1 -1
- package/src/projects/ProjectsClient.ts +1 -1
- package/src/users/UsersClient.ts +1 -1
- package/src/warnings.ts +1 -1
- package/umd/sanityClient.js +109 -414
- package/umd/sanityClient.min.js +3 -3
- package/src/auth/AuthClient.ts +0 -67
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { debug, headers, retry, jsonRequest, jsonResponse, progress, observable } from 'get-it/middleware';
|
|
2
2
|
import { getIt } from 'get-it';
|
|
3
3
|
import { Observable, lastValueFrom } from 'rxjs';
|
|
4
|
-
import { BaseError } from 'make-error';
|
|
5
4
|
import { map, filter } from 'rxjs/operators';
|
|
6
5
|
import polyfilledEventSource from '@sanity/eventsource';
|
|
7
6
|
var name = "@sanity/client";
|
|
8
|
-
var version = "5.0.0
|
|
7
|
+
var version = "5.0.0";
|
|
9
8
|
const middleware = [debug({
|
|
10
9
|
verbose: true,
|
|
11
10
|
namespace: "sanity:client"
|
|
@@ -14,7 +13,7 @@ const middleware = [debug({
|
|
|
14
13
|
}), retry({
|
|
15
14
|
maxRetries: 3
|
|
16
15
|
})];
|
|
17
|
-
class ClientError extends
|
|
16
|
+
class ClientError extends Error {
|
|
18
17
|
constructor(res) {
|
|
19
18
|
const props = extractErrorProps(res);
|
|
20
19
|
super(props.message);
|
|
@@ -22,7 +21,7 @@ class ClientError extends BaseError {
|
|
|
22
21
|
Object.assign(this, props);
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
class ServerError extends
|
|
24
|
+
class ServerError extends Error {
|
|
26
25
|
constructor(res) {
|
|
27
26
|
const props = extractErrorProps(res);
|
|
28
27
|
super(props.message);
|
|
@@ -188,60 +187,50 @@ const requestTag = tag => {
|
|
|
188
187
|
}
|
|
189
188
|
return tag;
|
|
190
189
|
};
|
|
191
|
-
const enc = encodeURIComponent;
|
|
192
190
|
var encodeQueryString = _ref => {
|
|
193
191
|
let {
|
|
194
192
|
query,
|
|
195
193
|
params = {},
|
|
196
194
|
options = {}
|
|
197
195
|
} = _ref;
|
|
196
|
+
const searchParams = new URLSearchParams();
|
|
198
197
|
const {
|
|
199
198
|
tag,
|
|
200
199
|
...opts
|
|
201
200
|
} = options;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
201
|
+
if (tag) searchParams.set("tag", tag);
|
|
202
|
+
searchParams.set("query", query);
|
|
203
|
+
for (const [key, value] of Object.entries(params)) {
|
|
204
|
+
searchParams.set("$".concat(key), JSON.stringify(value));
|
|
205
|
+
}
|
|
206
|
+
for (const [key, value] of Object.entries(opts)) {
|
|
207
|
+
if (value) searchParams.set(key, "".concat(value));
|
|
208
|
+
}
|
|
209
|
+
return "?".concat(searchParams);
|
|
208
210
|
};
|
|
209
|
-
var __accessCheck$
|
|
211
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
210
212
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
211
213
|
};
|
|
212
|
-
var __privateGet$
|
|
213
|
-
__accessCheck$
|
|
214
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
215
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
214
216
|
return getter ? getter.call(obj) : member.get(obj);
|
|
215
217
|
};
|
|
216
|
-
var __privateAdd$
|
|
218
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
217
219
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
218
220
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
219
221
|
};
|
|
220
|
-
var __privateSet$
|
|
221
|
-
__accessCheck$
|
|
222
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
223
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
222
224
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
223
225
|
return value;
|
|
224
226
|
};
|
|
225
|
-
var _client$
|
|
227
|
+
var _client$5, _client2$5;
|
|
226
228
|
class BasePatch {
|
|
227
229
|
constructor(selection) {
|
|
228
230
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
229
231
|
this.selection = selection;
|
|
230
232
|
this.operations = operations;
|
|
231
233
|
}
|
|
232
|
-
/**
|
|
233
|
-
* DEPRECATED: Don't use.
|
|
234
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
235
|
-
*
|
|
236
|
-
* @deprecated - Don't use.
|
|
237
|
-
* @param attrs - Attributes to replace
|
|
238
|
-
*/
|
|
239
|
-
replace(attrs) {
|
|
240
|
-
validateObject("replace", attrs);
|
|
241
|
-
return this._set("set", {
|
|
242
|
-
$: attrs
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
234
|
/**
|
|
246
235
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
247
236
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
@@ -339,7 +328,7 @@ class BasePatch {
|
|
|
339
328
|
* @param selector - Attribute or JSONPath expression for array
|
|
340
329
|
* @param start - Index at which to start changing the array (with origin 0). If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end of the array (with origin -1) and will be set to 0 if absolute value is greater than the length of the array.x
|
|
341
330
|
* @param deleteCount - An integer indicating the number of old array elements to remove.
|
|
342
|
-
* @param items - The elements to add to the array, beginning at the start index. If you don't specify
|
|
331
|
+
* @param items - The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array.
|
|
343
332
|
*/
|
|
344
333
|
splice(selector, start, deleteCount, items) {
|
|
345
334
|
const delAll = typeof deleteCount === "undefined" || deleteCount === -1;
|
|
@@ -395,8 +384,8 @@ class BasePatch {
|
|
|
395
384
|
const _ObservablePatch = class extends BasePatch {
|
|
396
385
|
constructor(selection, operations, client) {
|
|
397
386
|
super(selection, operations);
|
|
398
|
-
__privateAdd$
|
|
399
|
-
__privateSet$
|
|
387
|
+
__privateAdd$6(this, _client$5, void 0);
|
|
388
|
+
__privateSet$6(this, _client$5, client);
|
|
400
389
|
}
|
|
401
390
|
/**
|
|
402
391
|
* Clones the patch
|
|
@@ -404,10 +393,10 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
404
393
|
clone() {
|
|
405
394
|
return new _ObservablePatch(this.selection, {
|
|
406
395
|
...this.operations
|
|
407
|
-
}, __privateGet$
|
|
396
|
+
}, __privateGet$6(this, _client$5));
|
|
408
397
|
}
|
|
409
398
|
commit(options) {
|
|
410
|
-
if (!__privateGet$
|
|
399
|
+
if (!__privateGet$6(this, _client$5)) {
|
|
411
400
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
412
401
|
}
|
|
413
402
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -415,18 +404,18 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
415
404
|
returnFirst,
|
|
416
405
|
returnDocuments: true
|
|
417
406
|
}, options);
|
|
418
|
-
return __privateGet$
|
|
407
|
+
return __privateGet$6(this, _client$5).mutate({
|
|
419
408
|
patch: this.serialize()
|
|
420
409
|
}, opts);
|
|
421
410
|
}
|
|
422
411
|
};
|
|
423
412
|
let ObservablePatch = _ObservablePatch;
|
|
424
|
-
_client$
|
|
413
|
+
_client$5 = new WeakMap();
|
|
425
414
|
const _Patch = class extends BasePatch {
|
|
426
415
|
constructor(selection, operations, client) {
|
|
427
416
|
super(selection, operations);
|
|
428
|
-
__privateAdd$
|
|
429
|
-
__privateSet$
|
|
417
|
+
__privateAdd$6(this, _client2$5, void 0);
|
|
418
|
+
__privateSet$6(this, _client2$5, client);
|
|
430
419
|
}
|
|
431
420
|
/**
|
|
432
421
|
* Clones the patch
|
|
@@ -434,10 +423,10 @@ const _Patch = class extends BasePatch {
|
|
|
434
423
|
clone() {
|
|
435
424
|
return new _Patch(this.selection, {
|
|
436
425
|
...this.operations
|
|
437
|
-
}, __privateGet$
|
|
426
|
+
}, __privateGet$6(this, _client2$5));
|
|
438
427
|
}
|
|
439
428
|
commit(options) {
|
|
440
|
-
if (!__privateGet$
|
|
429
|
+
if (!__privateGet$6(this, _client2$5)) {
|
|
441
430
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
442
431
|
}
|
|
443
432
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -445,30 +434,30 @@ const _Patch = class extends BasePatch {
|
|
|
445
434
|
returnFirst,
|
|
446
435
|
returnDocuments: true
|
|
447
436
|
}, options);
|
|
448
|
-
return __privateGet$
|
|
437
|
+
return __privateGet$6(this, _client2$5).mutate({
|
|
449
438
|
patch: this.serialize()
|
|
450
439
|
}, opts);
|
|
451
440
|
}
|
|
452
441
|
};
|
|
453
442
|
let Patch = _Patch;
|
|
454
|
-
_client2$
|
|
455
|
-
var __accessCheck$
|
|
443
|
+
_client2$5 = new WeakMap();
|
|
444
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
456
445
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
457
446
|
};
|
|
458
|
-
var __privateGet$
|
|
459
|
-
__accessCheck$
|
|
447
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
448
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
460
449
|
return getter ? getter.call(obj) : member.get(obj);
|
|
461
450
|
};
|
|
462
|
-
var __privateAdd$
|
|
451
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
463
452
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
464
453
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
465
454
|
};
|
|
466
|
-
var __privateSet$
|
|
467
|
-
__accessCheck$
|
|
455
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
456
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
468
457
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
469
458
|
return value;
|
|
470
459
|
};
|
|
471
|
-
var _client$
|
|
460
|
+
var _client$4, _client2$4;
|
|
472
461
|
const defaultMutateOptions = {
|
|
473
462
|
returnDocuments: false
|
|
474
463
|
};
|
|
@@ -567,20 +556,20 @@ class BaseTransaction {
|
|
|
567
556
|
const _Transaction = class extends BaseTransaction {
|
|
568
557
|
constructor(operations, client, transactionId) {
|
|
569
558
|
super(operations, transactionId);
|
|
570
|
-
__privateAdd$
|
|
571
|
-
__privateSet$
|
|
559
|
+
__privateAdd$5(this, _client$4, void 0);
|
|
560
|
+
__privateSet$5(this, _client$4, client);
|
|
572
561
|
}
|
|
573
562
|
/**
|
|
574
563
|
* Clones the transaction
|
|
575
564
|
*/
|
|
576
565
|
clone() {
|
|
577
|
-
return new _Transaction([...this.operations], __privateGet$
|
|
566
|
+
return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
|
|
578
567
|
}
|
|
579
568
|
commit(options) {
|
|
580
|
-
if (!__privateGet$
|
|
569
|
+
if (!__privateGet$5(this, _client$4)) {
|
|
581
570
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
582
571
|
}
|
|
583
|
-
return __privateGet$
|
|
572
|
+
return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
|
|
584
573
|
transactionId: this.trxId
|
|
585
574
|
}, defaultMutateOptions, options || {}));
|
|
586
575
|
}
|
|
@@ -593,7 +582,7 @@ const _Transaction = class extends BaseTransaction {
|
|
|
593
582
|
});
|
|
594
583
|
}
|
|
595
584
|
if (isBuilder) {
|
|
596
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$
|
|
585
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
|
|
597
586
|
if (!(patch instanceof Patch)) {
|
|
598
587
|
throw new Error("function passed to `patch()` must return the patch");
|
|
599
588
|
}
|
|
@@ -610,24 +599,24 @@ const _Transaction = class extends BaseTransaction {
|
|
|
610
599
|
}
|
|
611
600
|
};
|
|
612
601
|
let Transaction = _Transaction;
|
|
613
|
-
_client$
|
|
602
|
+
_client$4 = new WeakMap();
|
|
614
603
|
const _ObservableTransaction = class extends BaseTransaction {
|
|
615
604
|
constructor(operations, client, transactionId) {
|
|
616
605
|
super(operations, transactionId);
|
|
617
|
-
__privateAdd$
|
|
618
|
-
__privateSet$
|
|
606
|
+
__privateAdd$5(this, _client2$4, void 0);
|
|
607
|
+
__privateSet$5(this, _client2$4, client);
|
|
619
608
|
}
|
|
620
609
|
/**
|
|
621
610
|
* Clones the transaction
|
|
622
611
|
*/
|
|
623
612
|
clone() {
|
|
624
|
-
return new _ObservableTransaction([...this.operations], __privateGet$
|
|
613
|
+
return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
|
|
625
614
|
}
|
|
626
615
|
commit(options) {
|
|
627
|
-
if (!__privateGet$
|
|
616
|
+
if (!__privateGet$5(this, _client2$4)) {
|
|
628
617
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
629
618
|
}
|
|
630
|
-
return __privateGet$
|
|
619
|
+
return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
|
|
631
620
|
transactionId: this.trxId
|
|
632
621
|
}, defaultMutateOptions, options || {}));
|
|
633
622
|
}
|
|
@@ -640,7 +629,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
640
629
|
});
|
|
641
630
|
}
|
|
642
631
|
if (isBuilder) {
|
|
643
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$
|
|
632
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
|
|
644
633
|
if (!(patch instanceof ObservablePatch)) {
|
|
645
634
|
throw new Error("function passed to `patch()` must return the patch");
|
|
646
635
|
}
|
|
@@ -657,7 +646,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
657
646
|
}
|
|
658
647
|
};
|
|
659
648
|
let ObservableTransaction = _ObservableTransaction;
|
|
660
|
-
_client2$
|
|
649
|
+
_client2$4 = new WeakMap();
|
|
661
650
|
const excludeFalsey = (param, defValue) => {
|
|
662
651
|
const value = typeof param === "undefined" ? defValue : param;
|
|
663
652
|
return param === false ? void 0 : value;
|
|
@@ -829,50 +818,50 @@ function _getUrl(client, uri) {
|
|
|
829
818
|
const base = canUseCdn ? cdnUrl : url;
|
|
830
819
|
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
831
820
|
}
|
|
832
|
-
var __accessCheck$
|
|
821
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
833
822
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
834
823
|
};
|
|
835
|
-
var __privateGet$
|
|
836
|
-
__accessCheck$
|
|
824
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
825
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
837
826
|
return getter ? getter.call(obj) : member.get(obj);
|
|
838
827
|
};
|
|
839
|
-
var __privateAdd$
|
|
828
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
840
829
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
841
830
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
842
831
|
};
|
|
843
|
-
var __privateSet$
|
|
844
|
-
__accessCheck$
|
|
832
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
833
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
845
834
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
846
835
|
return value;
|
|
847
836
|
};
|
|
848
|
-
var _client$
|
|
837
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
849
838
|
class ObservableAssetsClient {
|
|
850
839
|
constructor(client, httpRequest) {
|
|
851
|
-
__privateAdd$
|
|
852
|
-
__privateAdd$
|
|
853
|
-
__privateSet$
|
|
854
|
-
__privateSet$
|
|
840
|
+
__privateAdd$4(this, _client$3, void 0);
|
|
841
|
+
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
842
|
+
__privateSet$4(this, _client$3, client);
|
|
843
|
+
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
855
844
|
}
|
|
856
845
|
upload(assetType, body, options) {
|
|
857
|
-
return _upload(__privateGet$
|
|
846
|
+
return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
|
|
858
847
|
}
|
|
859
848
|
}
|
|
860
|
-
_client$
|
|
861
|
-
_httpRequest$
|
|
849
|
+
_client$3 = new WeakMap();
|
|
850
|
+
_httpRequest$4 = new WeakMap();
|
|
862
851
|
class AssetsClient {
|
|
863
852
|
constructor(client, httpRequest) {
|
|
864
|
-
__privateAdd$
|
|
865
|
-
__privateAdd$
|
|
866
|
-
__privateSet$
|
|
867
|
-
__privateSet$
|
|
853
|
+
__privateAdd$4(this, _client2$3, void 0);
|
|
854
|
+
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
855
|
+
__privateSet$4(this, _client2$3, client);
|
|
856
|
+
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
868
857
|
}
|
|
869
858
|
upload(assetType, body, options) {
|
|
870
|
-
const observable = _upload(__privateGet$
|
|
859
|
+
const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
|
|
871
860
|
return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
|
|
872
861
|
}
|
|
873
862
|
}
|
|
874
|
-
_client2$
|
|
875
|
-
_httpRequest2$
|
|
863
|
+
_client2$3 = new WeakMap();
|
|
864
|
+
_httpRequest2$4 = new WeakMap();
|
|
876
865
|
function _upload(client, httpRequest, assetType, body) {
|
|
877
866
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
878
867
|
validateAssetType(assetType);
|
|
@@ -926,78 +915,7 @@ function optionsFromFile(opts, file) {
|
|
|
926
915
|
contentType: file.type
|
|
927
916
|
}, opts);
|
|
928
917
|
}
|
|
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 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 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/";
|
|
918
|
+
const BASE_URL = "https://www.sanity.io/help/";
|
|
1001
919
|
function generateHelpUrl(slug) {
|
|
1002
920
|
return BASE_URL + slug;
|
|
1003
921
|
}
|
|
@@ -1021,7 +939,7 @@ once(function () {
|
|
|
1021
939
|
}
|
|
1022
940
|
return console.warn(message.join(" "), ...args);
|
|
1023
941
|
});
|
|
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"), "
|
|
942
|
+
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
943
|
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
944
|
const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
|
|
1027
945
|
const defaultCdnHost = "apicdn.sanity.io";
|
|
@@ -1499,10 +1417,13 @@ const _ObservableSanityClient = class {
|
|
|
1499
1417
|
*/
|
|
1500
1418
|
__privateAdd(this, _clientConfig, void 0);
|
|
1501
1419
|
__privateAdd(this, _httpRequest, void 0);
|
|
1420
|
+
/**
|
|
1421
|
+
* Instance properties
|
|
1422
|
+
*/
|
|
1423
|
+
this.listen = _listen;
|
|
1502
1424
|
this.config(config);
|
|
1503
1425
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1504
1426
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
1505
|
-
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
1506
1427
|
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
1507
1428
|
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
1508
1429
|
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
@@ -1553,7 +1474,7 @@ const _ObservableSanityClient = class {
|
|
|
1553
1474
|
* Fetch multiple documents in one request.
|
|
1554
1475
|
* Should be used sparingly - performing a query is usually a better option.
|
|
1555
1476
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1556
|
-
* If
|
|
1477
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1557
1478
|
*
|
|
1558
1479
|
* @param ids - Document IDs to fetch
|
|
1559
1480
|
* @param options - Request options
|
|
@@ -1621,7 +1542,6 @@ const _SanityClient = class {
|
|
|
1621
1542
|
this.config(config);
|
|
1622
1543
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1623
1544
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
1624
|
-
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
1625
1545
|
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
1626
1546
|
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
1627
1547
|
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|
|
@@ -1676,7 +1596,7 @@ const _SanityClient = class {
|
|
|
1676
1596
|
* Fetch multiple documents in one request.
|
|
1677
1597
|
* Should be used sparingly - performing a query is usually a better option.
|
|
1678
1598
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1679
|
-
* If
|
|
1599
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1680
1600
|
*
|
|
1681
1601
|
* @param ids - Document IDs to fetch
|
|
1682
1602
|
* @param options - Request options
|