@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.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()`
|
|
@@ -341,7 +330,7 @@ class BasePatch {
|
|
|
341
330
|
* @param selector - Attribute or JSONPath expression for array
|
|
342
331
|
* @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
|
|
343
332
|
* @param deleteCount - An integer indicating the number of old array elements to remove.
|
|
344
|
-
* @param items - The elements to add to the array, beginning at the start index. If you don't specify
|
|
333
|
+
* @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.
|
|
345
334
|
*/
|
|
346
335
|
splice(selector, start, deleteCount, items) {
|
|
347
336
|
const delAll = typeof deleteCount === "undefined" || deleteCount === -1;
|
|
@@ -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;
|
|
@@ -831,50 +820,50 @@ function _getUrl(client, uri) {
|
|
|
831
820
|
const base = canUseCdn ? cdnUrl : url;
|
|
832
821
|
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
833
822
|
}
|
|
834
|
-
var __accessCheck$
|
|
823
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
835
824
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
836
825
|
};
|
|
837
|
-
var __privateGet$
|
|
838
|
-
__accessCheck$
|
|
826
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
827
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
839
828
|
return getter ? getter.call(obj) : member.get(obj);
|
|
840
829
|
};
|
|
841
|
-
var __privateAdd$
|
|
830
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
842
831
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
843
832
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
844
833
|
};
|
|
845
|
-
var __privateSet$
|
|
846
|
-
__accessCheck$
|
|
834
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
835
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
847
836
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
848
837
|
return value;
|
|
849
838
|
};
|
|
850
|
-
var _client$
|
|
839
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
851
840
|
class ObservableAssetsClient {
|
|
852
841
|
constructor(client, httpRequest) {
|
|
853
|
-
__privateAdd$
|
|
854
|
-
__privateAdd$
|
|
855
|
-
__privateSet$
|
|
856
|
-
__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);
|
|
857
846
|
}
|
|
858
847
|
upload(assetType, body, options) {
|
|
859
|
-
return _upload(__privateGet$
|
|
848
|
+
return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
|
|
860
849
|
}
|
|
861
850
|
}
|
|
862
|
-
_client$
|
|
863
|
-
_httpRequest$
|
|
851
|
+
_client$3 = new WeakMap();
|
|
852
|
+
_httpRequest$4 = new WeakMap();
|
|
864
853
|
class AssetsClient {
|
|
865
854
|
constructor(client, httpRequest) {
|
|
866
|
-
__privateAdd$
|
|
867
|
-
__privateAdd$
|
|
868
|
-
__privateSet$
|
|
869
|
-
__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);
|
|
870
859
|
}
|
|
871
860
|
upload(assetType, body, options) {
|
|
872
|
-
const observable = _upload(__privateGet$
|
|
861
|
+
const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
|
|
873
862
|
return rxjs.lastValueFrom(observable.pipe(operators.filter(event => event.type === "response"), operators.map(event => event.body.document)));
|
|
874
863
|
}
|
|
875
864
|
}
|
|
876
|
-
_client2$
|
|
877
|
-
_httpRequest2$
|
|
865
|
+
_client2$3 = new WeakMap();
|
|
866
|
+
_httpRequest2$4 = new WeakMap();
|
|
878
867
|
function _upload(client, httpRequest, assetType, body) {
|
|
879
868
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
880
869
|
validateAssetType(assetType);
|
|
@@ -928,78 +917,7 @@ function optionsFromFile(opts, file) {
|
|
|
928
917
|
contentType: file.type
|
|
929
918
|
}, opts);
|
|
930
919
|
}
|
|
931
|
-
|
|
932
|
-
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
933
|
-
};
|
|
934
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
935
|
-
__accessCheck$4(obj, member, "read from private field");
|
|
936
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
937
|
-
};
|
|
938
|
-
var __privateAdd$4 = (obj, member, value) => {
|
|
939
|
-
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
940
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
941
|
-
};
|
|
942
|
-
var __privateSet$4 = (obj, member, value, setter) => {
|
|
943
|
-
__accessCheck$4(obj, member, "write to private field");
|
|
944
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
945
|
-
return value;
|
|
946
|
-
};
|
|
947
|
-
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
948
|
-
class ObservableAuthClient {
|
|
949
|
-
constructor(client, httpRequest) {
|
|
950
|
-
__privateAdd$4(this, _client$3, void 0);
|
|
951
|
-
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
952
|
-
__privateSet$4(this, _client$3, client);
|
|
953
|
-
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Fetch available login providers
|
|
957
|
-
*/
|
|
958
|
-
getLoginProviders() {
|
|
959
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
960
|
-
uri: "/auth/providers"
|
|
961
|
-
});
|
|
962
|
-
}
|
|
963
|
-
/**
|
|
964
|
-
* Revoke the configured session/token
|
|
965
|
-
*/
|
|
966
|
-
logout() {
|
|
967
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
968
|
-
uri: "/auth/logout",
|
|
969
|
-
method: "POST"
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
_client$3 = new WeakMap();
|
|
974
|
-
_httpRequest$4 = new WeakMap();
|
|
975
|
-
class AuthClient {
|
|
976
|
-
constructor(client, httpRequest) {
|
|
977
|
-
__privateAdd$4(this, _client2$3, void 0);
|
|
978
|
-
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
979
|
-
__privateSet$4(this, _client2$3, client);
|
|
980
|
-
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* Fetch available login providers
|
|
984
|
-
*/
|
|
985
|
-
getLoginProviders() {
|
|
986
|
-
return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
987
|
-
uri: "/auth/providers"
|
|
988
|
-
}));
|
|
989
|
-
}
|
|
990
|
-
/**
|
|
991
|
-
* Revoke the configured session/token
|
|
992
|
-
*/
|
|
993
|
-
logout() {
|
|
994
|
-
return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
995
|
-
uri: "/auth/logout",
|
|
996
|
-
method: "POST"
|
|
997
|
-
}));
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
_client2$3 = new WeakMap();
|
|
1001
|
-
_httpRequest2$4 = new WeakMap();
|
|
1002
|
-
const BASE_URL = "https://docs.sanity.io/help/";
|
|
920
|
+
const BASE_URL = "https://www.sanity.io/help/";
|
|
1003
921
|
function generateHelpUrl(slug) {
|
|
1004
922
|
return BASE_URL + slug;
|
|
1005
923
|
}
|
|
@@ -1023,7 +941,7 @@ once(function () {
|
|
|
1023
941
|
}
|
|
1024
942
|
return console.warn(message.join(" "), ...args);
|
|
1025
943
|
});
|
|
1026
|
-
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."]);
|
|
1027
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.")]);
|
|
1028
946
|
const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
|
|
1029
947
|
const defaultCdnHost = "apicdn.sanity.io";
|
|
@@ -1501,10 +1419,13 @@ const _ObservableSanityClient = class {
|
|
|
1501
1419
|
*/
|
|
1502
1420
|
__privateAdd(this, _clientConfig, void 0);
|
|
1503
1421
|
__privateAdd(this, _httpRequest, void 0);
|
|
1422
|
+
/**
|
|
1423
|
+
* Instance properties
|
|
1424
|
+
*/
|
|
1425
|
+
this.listen = _listen;
|
|
1504
1426
|
this.config(config);
|
|
1505
1427
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1506
1428
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
1507
|
-
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
1508
1429
|
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
1509
1430
|
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
1510
1431
|
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
@@ -1555,7 +1476,7 @@ const _ObservableSanityClient = class {
|
|
|
1555
1476
|
* Fetch multiple documents in one request.
|
|
1556
1477
|
* Should be used sparingly - performing a query is usually a better option.
|
|
1557
1478
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1558
|
-
* If
|
|
1479
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1559
1480
|
*
|
|
1560
1481
|
* @param ids - Document IDs to fetch
|
|
1561
1482
|
* @param options - Request options
|
|
@@ -1623,7 +1544,6 @@ const _SanityClient = class {
|
|
|
1623
1544
|
this.config(config);
|
|
1624
1545
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1625
1546
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
1626
|
-
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
1627
1547
|
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
1628
1548
|
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
1629
1549
|
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|
|
@@ -1678,7 +1598,7 @@ const _SanityClient = class {
|
|
|
1678
1598
|
* Fetch multiple documents in one request.
|
|
1679
1599
|
* Should be used sparingly - performing a query is usually a better option.
|
|
1680
1600
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1681
|
-
* If
|
|
1601
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1682
1602
|
*
|
|
1683
1603
|
* @param ids - Document IDs to fetch
|
|
1684
1604
|
* @param options - Request options
|