@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.browser.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { getIt } from 'get-it';
|
|
2
2
|
import { jsonRequest, jsonResponse, progress, observable } from 'get-it/middleware';
|
|
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 envMiddleware = [];
|
|
8
|
-
class ClientError extends
|
|
7
|
+
class ClientError extends Error {
|
|
9
8
|
constructor(res) {
|
|
10
9
|
const props = extractErrorProps(res);
|
|
11
10
|
super(props.message);
|
|
@@ -13,7 +12,7 @@ class ClientError extends BaseError {
|
|
|
13
12
|
Object.assign(this, props);
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
|
-
class ServerError extends
|
|
15
|
+
class ServerError extends Error {
|
|
17
16
|
constructor(res) {
|
|
18
17
|
const props = extractErrorProps(res);
|
|
19
18
|
super(props.message);
|
|
@@ -179,60 +178,50 @@ const requestTag = tag => {
|
|
|
179
178
|
}
|
|
180
179
|
return tag;
|
|
181
180
|
};
|
|
182
|
-
const enc = encodeURIComponent;
|
|
183
181
|
var encodeQueryString = _ref => {
|
|
184
182
|
let {
|
|
185
183
|
query,
|
|
186
184
|
params = {},
|
|
187
185
|
options = {}
|
|
188
186
|
} = _ref;
|
|
187
|
+
const searchParams = new URLSearchParams();
|
|
189
188
|
const {
|
|
190
189
|
tag,
|
|
191
190
|
...opts
|
|
192
191
|
} = options;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
192
|
+
if (tag) searchParams.set("tag", tag);
|
|
193
|
+
searchParams.set("query", query);
|
|
194
|
+
for (const [key, value] of Object.entries(params)) {
|
|
195
|
+
searchParams.set("$".concat(key), JSON.stringify(value));
|
|
196
|
+
}
|
|
197
|
+
for (const [key, value] of Object.entries(opts)) {
|
|
198
|
+
if (value) searchParams.set(key, "".concat(value));
|
|
199
|
+
}
|
|
200
|
+
return "?".concat(searchParams);
|
|
199
201
|
};
|
|
200
|
-
var __accessCheck$
|
|
202
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
201
203
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
202
204
|
};
|
|
203
|
-
var __privateGet$
|
|
204
|
-
__accessCheck$
|
|
205
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
206
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
205
207
|
return getter ? getter.call(obj) : member.get(obj);
|
|
206
208
|
};
|
|
207
|
-
var __privateAdd$
|
|
209
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
208
210
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
209
211
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
210
212
|
};
|
|
211
|
-
var __privateSet$
|
|
212
|
-
__accessCheck$
|
|
213
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
214
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
213
215
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
214
216
|
return value;
|
|
215
217
|
};
|
|
216
|
-
var _client$
|
|
218
|
+
var _client$5, _client2$5;
|
|
217
219
|
class BasePatch {
|
|
218
220
|
constructor(selection) {
|
|
219
221
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
220
222
|
this.selection = selection;
|
|
221
223
|
this.operations = operations;
|
|
222
224
|
}
|
|
223
|
-
/**
|
|
224
|
-
* DEPRECATED: Don't use.
|
|
225
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
226
|
-
*
|
|
227
|
-
* @deprecated - Don't use.
|
|
228
|
-
* @param attrs - Attributes to replace
|
|
229
|
-
*/
|
|
230
|
-
replace(attrs) {
|
|
231
|
-
validateObject("replace", attrs);
|
|
232
|
-
return this._set("set", {
|
|
233
|
-
$: attrs
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
225
|
/**
|
|
237
226
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
238
227
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
@@ -330,7 +319,7 @@ class BasePatch {
|
|
|
330
319
|
* @param selector - Attribute or JSONPath expression for array
|
|
331
320
|
* @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
|
|
332
321
|
* @param deleteCount - An integer indicating the number of old array elements to remove.
|
|
333
|
-
* @param items - The elements to add to the array, beginning at the start index. If you don't specify
|
|
322
|
+
* @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.
|
|
334
323
|
*/
|
|
335
324
|
splice(selector, start, deleteCount, items) {
|
|
336
325
|
const delAll = typeof deleteCount === "undefined" || deleteCount === -1;
|
|
@@ -386,8 +375,8 @@ class BasePatch {
|
|
|
386
375
|
const _ObservablePatch = class extends BasePatch {
|
|
387
376
|
constructor(selection, operations, client) {
|
|
388
377
|
super(selection, operations);
|
|
389
|
-
__privateAdd$
|
|
390
|
-
__privateSet$
|
|
378
|
+
__privateAdd$6(this, _client$5, void 0);
|
|
379
|
+
__privateSet$6(this, _client$5, client);
|
|
391
380
|
}
|
|
392
381
|
/**
|
|
393
382
|
* Clones the patch
|
|
@@ -395,10 +384,10 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
395
384
|
clone() {
|
|
396
385
|
return new _ObservablePatch(this.selection, {
|
|
397
386
|
...this.operations
|
|
398
|
-
}, __privateGet$
|
|
387
|
+
}, __privateGet$6(this, _client$5));
|
|
399
388
|
}
|
|
400
389
|
commit(options) {
|
|
401
|
-
if (!__privateGet$
|
|
390
|
+
if (!__privateGet$6(this, _client$5)) {
|
|
402
391
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
403
392
|
}
|
|
404
393
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -406,18 +395,18 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
406
395
|
returnFirst,
|
|
407
396
|
returnDocuments: true
|
|
408
397
|
}, options);
|
|
409
|
-
return __privateGet$
|
|
398
|
+
return __privateGet$6(this, _client$5).mutate({
|
|
410
399
|
patch: this.serialize()
|
|
411
400
|
}, opts);
|
|
412
401
|
}
|
|
413
402
|
};
|
|
414
403
|
let ObservablePatch = _ObservablePatch;
|
|
415
|
-
_client$
|
|
404
|
+
_client$5 = new WeakMap();
|
|
416
405
|
const _Patch = class extends BasePatch {
|
|
417
406
|
constructor(selection, operations, client) {
|
|
418
407
|
super(selection, operations);
|
|
419
|
-
__privateAdd$
|
|
420
|
-
__privateSet$
|
|
408
|
+
__privateAdd$6(this, _client2$5, void 0);
|
|
409
|
+
__privateSet$6(this, _client2$5, client);
|
|
421
410
|
}
|
|
422
411
|
/**
|
|
423
412
|
* Clones the patch
|
|
@@ -425,10 +414,10 @@ const _Patch = class extends BasePatch {
|
|
|
425
414
|
clone() {
|
|
426
415
|
return new _Patch(this.selection, {
|
|
427
416
|
...this.operations
|
|
428
|
-
}, __privateGet$
|
|
417
|
+
}, __privateGet$6(this, _client2$5));
|
|
429
418
|
}
|
|
430
419
|
commit(options) {
|
|
431
|
-
if (!__privateGet$
|
|
420
|
+
if (!__privateGet$6(this, _client2$5)) {
|
|
432
421
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
433
422
|
}
|
|
434
423
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -436,30 +425,30 @@ const _Patch = class extends BasePatch {
|
|
|
436
425
|
returnFirst,
|
|
437
426
|
returnDocuments: true
|
|
438
427
|
}, options);
|
|
439
|
-
return __privateGet$
|
|
428
|
+
return __privateGet$6(this, _client2$5).mutate({
|
|
440
429
|
patch: this.serialize()
|
|
441
430
|
}, opts);
|
|
442
431
|
}
|
|
443
432
|
};
|
|
444
433
|
let Patch = _Patch;
|
|
445
|
-
_client2$
|
|
446
|
-
var __accessCheck$
|
|
434
|
+
_client2$5 = new WeakMap();
|
|
435
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
447
436
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
448
437
|
};
|
|
449
|
-
var __privateGet$
|
|
450
|
-
__accessCheck$
|
|
438
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
439
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
451
440
|
return getter ? getter.call(obj) : member.get(obj);
|
|
452
441
|
};
|
|
453
|
-
var __privateAdd$
|
|
442
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
454
443
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
455
444
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
456
445
|
};
|
|
457
|
-
var __privateSet$
|
|
458
|
-
__accessCheck$
|
|
446
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
447
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
459
448
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
460
449
|
return value;
|
|
461
450
|
};
|
|
462
|
-
var _client$
|
|
451
|
+
var _client$4, _client2$4;
|
|
463
452
|
const defaultMutateOptions = {
|
|
464
453
|
returnDocuments: false
|
|
465
454
|
};
|
|
@@ -558,20 +547,20 @@ class BaseTransaction {
|
|
|
558
547
|
const _Transaction = class extends BaseTransaction {
|
|
559
548
|
constructor(operations, client, transactionId) {
|
|
560
549
|
super(operations, transactionId);
|
|
561
|
-
__privateAdd$
|
|
562
|
-
__privateSet$
|
|
550
|
+
__privateAdd$5(this, _client$4, void 0);
|
|
551
|
+
__privateSet$5(this, _client$4, client);
|
|
563
552
|
}
|
|
564
553
|
/**
|
|
565
554
|
* Clones the transaction
|
|
566
555
|
*/
|
|
567
556
|
clone() {
|
|
568
|
-
return new _Transaction([...this.operations], __privateGet$
|
|
557
|
+
return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
|
|
569
558
|
}
|
|
570
559
|
commit(options) {
|
|
571
|
-
if (!__privateGet$
|
|
560
|
+
if (!__privateGet$5(this, _client$4)) {
|
|
572
561
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
573
562
|
}
|
|
574
|
-
return __privateGet$
|
|
563
|
+
return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
|
|
575
564
|
transactionId: this.trxId
|
|
576
565
|
}, defaultMutateOptions, options || {}));
|
|
577
566
|
}
|
|
@@ -584,7 +573,7 @@ const _Transaction = class extends BaseTransaction {
|
|
|
584
573
|
});
|
|
585
574
|
}
|
|
586
575
|
if (isBuilder) {
|
|
587
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$
|
|
576
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
|
|
588
577
|
if (!(patch instanceof Patch)) {
|
|
589
578
|
throw new Error("function passed to `patch()` must return the patch");
|
|
590
579
|
}
|
|
@@ -601,24 +590,24 @@ const _Transaction = class extends BaseTransaction {
|
|
|
601
590
|
}
|
|
602
591
|
};
|
|
603
592
|
let Transaction = _Transaction;
|
|
604
|
-
_client$
|
|
593
|
+
_client$4 = new WeakMap();
|
|
605
594
|
const _ObservableTransaction = class extends BaseTransaction {
|
|
606
595
|
constructor(operations, client, transactionId) {
|
|
607
596
|
super(operations, transactionId);
|
|
608
|
-
__privateAdd$
|
|
609
|
-
__privateSet$
|
|
597
|
+
__privateAdd$5(this, _client2$4, void 0);
|
|
598
|
+
__privateSet$5(this, _client2$4, client);
|
|
610
599
|
}
|
|
611
600
|
/**
|
|
612
601
|
* Clones the transaction
|
|
613
602
|
*/
|
|
614
603
|
clone() {
|
|
615
|
-
return new _ObservableTransaction([...this.operations], __privateGet$
|
|
604
|
+
return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
|
|
616
605
|
}
|
|
617
606
|
commit(options) {
|
|
618
|
-
if (!__privateGet$
|
|
607
|
+
if (!__privateGet$5(this, _client2$4)) {
|
|
619
608
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
620
609
|
}
|
|
621
|
-
return __privateGet$
|
|
610
|
+
return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
|
|
622
611
|
transactionId: this.trxId
|
|
623
612
|
}, defaultMutateOptions, options || {}));
|
|
624
613
|
}
|
|
@@ -631,7 +620,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
631
620
|
});
|
|
632
621
|
}
|
|
633
622
|
if (isBuilder) {
|
|
634
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$
|
|
623
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
|
|
635
624
|
if (!(patch instanceof ObservablePatch)) {
|
|
636
625
|
throw new Error("function passed to `patch()` must return the patch");
|
|
637
626
|
}
|
|
@@ -648,7 +637,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
648
637
|
}
|
|
649
638
|
};
|
|
650
639
|
let ObservableTransaction = _ObservableTransaction;
|
|
651
|
-
_client2$
|
|
640
|
+
_client2$4 = new WeakMap();
|
|
652
641
|
const excludeFalsey = (param, defValue) => {
|
|
653
642
|
const value = typeof param === "undefined" ? defValue : param;
|
|
654
643
|
return param === false ? void 0 : value;
|
|
@@ -820,50 +809,50 @@ function _getUrl(client, uri) {
|
|
|
820
809
|
const base = canUseCdn ? cdnUrl : url;
|
|
821
810
|
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
822
811
|
}
|
|
823
|
-
var __accessCheck$
|
|
812
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
824
813
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
825
814
|
};
|
|
826
|
-
var __privateGet$
|
|
827
|
-
__accessCheck$
|
|
815
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
816
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
828
817
|
return getter ? getter.call(obj) : member.get(obj);
|
|
829
818
|
};
|
|
830
|
-
var __privateAdd$
|
|
819
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
831
820
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
832
821
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
833
822
|
};
|
|
834
|
-
var __privateSet$
|
|
835
|
-
__accessCheck$
|
|
823
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
824
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
836
825
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
837
826
|
return value;
|
|
838
827
|
};
|
|
839
|
-
var _client$
|
|
828
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
840
829
|
class ObservableAssetsClient {
|
|
841
830
|
constructor(client, httpRequest) {
|
|
842
|
-
__privateAdd$
|
|
843
|
-
__privateAdd$
|
|
844
|
-
__privateSet$
|
|
845
|
-
__privateSet$
|
|
831
|
+
__privateAdd$4(this, _client$3, void 0);
|
|
832
|
+
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
833
|
+
__privateSet$4(this, _client$3, client);
|
|
834
|
+
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
846
835
|
}
|
|
847
836
|
upload(assetType, body, options) {
|
|
848
|
-
return _upload(__privateGet$
|
|
837
|
+
return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
|
|
849
838
|
}
|
|
850
839
|
}
|
|
851
|
-
_client$
|
|
852
|
-
_httpRequest$
|
|
840
|
+
_client$3 = new WeakMap();
|
|
841
|
+
_httpRequest$4 = new WeakMap();
|
|
853
842
|
class AssetsClient {
|
|
854
843
|
constructor(client, httpRequest) {
|
|
855
|
-
__privateAdd$
|
|
856
|
-
__privateAdd$
|
|
857
|
-
__privateSet$
|
|
858
|
-
__privateSet$
|
|
844
|
+
__privateAdd$4(this, _client2$3, void 0);
|
|
845
|
+
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
846
|
+
__privateSet$4(this, _client2$3, client);
|
|
847
|
+
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
859
848
|
}
|
|
860
849
|
upload(assetType, body, options) {
|
|
861
|
-
const observable = _upload(__privateGet$
|
|
850
|
+
const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
|
|
862
851
|
return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
|
|
863
852
|
}
|
|
864
853
|
}
|
|
865
|
-
_client2$
|
|
866
|
-
_httpRequest2$
|
|
854
|
+
_client2$3 = new WeakMap();
|
|
855
|
+
_httpRequest2$4 = new WeakMap();
|
|
867
856
|
function _upload(client, httpRequest, assetType, body) {
|
|
868
857
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
869
858
|
validateAssetType(assetType);
|
|
@@ -917,78 +906,7 @@ function optionsFromFile(opts, file) {
|
|
|
917
906
|
contentType: file.type
|
|
918
907
|
}, opts);
|
|
919
908
|
}
|
|
920
|
-
|
|
921
|
-
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
922
|
-
};
|
|
923
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
924
|
-
__accessCheck$4(obj, member, "read from private field");
|
|
925
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
926
|
-
};
|
|
927
|
-
var __privateAdd$4 = (obj, member, value) => {
|
|
928
|
-
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
929
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
930
|
-
};
|
|
931
|
-
var __privateSet$4 = (obj, member, value, setter) => {
|
|
932
|
-
__accessCheck$4(obj, member, "write to private field");
|
|
933
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
934
|
-
return value;
|
|
935
|
-
};
|
|
936
|
-
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
937
|
-
class ObservableAuthClient {
|
|
938
|
-
constructor(client, httpRequest) {
|
|
939
|
-
__privateAdd$4(this, _client$3, void 0);
|
|
940
|
-
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
941
|
-
__privateSet$4(this, _client$3, client);
|
|
942
|
-
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
943
|
-
}
|
|
944
|
-
/**
|
|
945
|
-
* Fetch available login providers
|
|
946
|
-
*/
|
|
947
|
-
getLoginProviders() {
|
|
948
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
949
|
-
uri: "/auth/providers"
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
/**
|
|
953
|
-
* Revoke the configured session/token
|
|
954
|
-
*/
|
|
955
|
-
logout() {
|
|
956
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
957
|
-
uri: "/auth/logout",
|
|
958
|
-
method: "POST"
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
_client$3 = new WeakMap();
|
|
963
|
-
_httpRequest$4 = new WeakMap();
|
|
964
|
-
class AuthClient {
|
|
965
|
-
constructor(client, httpRequest) {
|
|
966
|
-
__privateAdd$4(this, _client2$3, void 0);
|
|
967
|
-
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
968
|
-
__privateSet$4(this, _client2$3, client);
|
|
969
|
-
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
* Fetch available login providers
|
|
973
|
-
*/
|
|
974
|
-
getLoginProviders() {
|
|
975
|
-
return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
976
|
-
uri: "/auth/providers"
|
|
977
|
-
}));
|
|
978
|
-
}
|
|
979
|
-
/**
|
|
980
|
-
* Revoke the configured session/token
|
|
981
|
-
*/
|
|
982
|
-
logout() {
|
|
983
|
-
return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
984
|
-
uri: "/auth/logout",
|
|
985
|
-
method: "POST"
|
|
986
|
-
}));
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
_client2$3 = new WeakMap();
|
|
990
|
-
_httpRequest2$4 = new WeakMap();
|
|
991
|
-
const BASE_URL = "https://docs.sanity.io/help/";
|
|
909
|
+
const BASE_URL = "https://www.sanity.io/help/";
|
|
992
910
|
function generateHelpUrl(slug) {
|
|
993
911
|
return BASE_URL + slug;
|
|
994
912
|
}
|
|
@@ -1012,7 +930,7 @@ once(function () {
|
|
|
1012
930
|
}
|
|
1013
931
|
return console.warn(message.join(" "), ...args);
|
|
1014
932
|
});
|
|
1015
|
-
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"), "
|
|
933
|
+
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."]);
|
|
1016
934
|
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.")]);
|
|
1017
935
|
const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
|
|
1018
936
|
const defaultCdnHost = "apicdn.sanity.io";
|
|
@@ -1490,10 +1408,13 @@ const _ObservableSanityClient = class {
|
|
|
1490
1408
|
*/
|
|
1491
1409
|
__privateAdd(this, _clientConfig, void 0);
|
|
1492
1410
|
__privateAdd(this, _httpRequest, void 0);
|
|
1411
|
+
/**
|
|
1412
|
+
* Instance properties
|
|
1413
|
+
*/
|
|
1414
|
+
this.listen = _listen;
|
|
1493
1415
|
this.config(config);
|
|
1494
1416
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1495
1417
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
1496
|
-
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
1497
1418
|
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
1498
1419
|
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
1499
1420
|
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
@@ -1544,7 +1465,7 @@ const _ObservableSanityClient = class {
|
|
|
1544
1465
|
* Fetch multiple documents in one request.
|
|
1545
1466
|
* Should be used sparingly - performing a query is usually a better option.
|
|
1546
1467
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1547
|
-
* If
|
|
1468
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1548
1469
|
*
|
|
1549
1470
|
* @param ids - Document IDs to fetch
|
|
1550
1471
|
* @param options - Request options
|
|
@@ -1612,7 +1533,6 @@ const _SanityClient = class {
|
|
|
1612
1533
|
this.config(config);
|
|
1613
1534
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1614
1535
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
1615
|
-
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
1616
1536
|
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
1617
1537
|
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
1618
1538
|
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|
|
@@ -1667,7 +1587,7 @@ const _SanityClient = class {
|
|
|
1667
1587
|
* Fetch multiple documents in one request.
|
|
1668
1588
|
* Should be used sparingly - performing a query is usually a better option.
|
|
1669
1589
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1670
|
-
* If
|
|
1590
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1671
1591
|
*
|
|
1672
1592
|
* @param ids - Document IDs to fetch
|
|
1673
1593
|
* @param options - Request options
|