@sanity/client 5.0.0-esm.13 → 5.0.0-esm.15
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 +60 -1
- package/dist/index.browser.cjs +75 -154
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +75 -154
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +76 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +44 -50
- package/dist/index.js +76 -155
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/SanityClient.ts +21 -23
- package/src/assets/AssetsClient.ts +28 -4
- package/src/data/dataMethods.ts +2 -2
- package/src/data/encodeQueryString.ts +15 -14
- package/src/data/patch.ts +0 -12
- package/umd/sanityClient.js +100 -179
- package/umd/sanityClient.min.js +3 -3
- package/src/auth/AuthClient.ts +0 -67
package/umd/sanityClient.js
CHANGED
|
@@ -209,19 +209,19 @@
|
|
|
209
209
|
initMiddleware.forEach(request.use);
|
|
210
210
|
return request;
|
|
211
211
|
}
|
|
212
|
-
var __accessCheck$
|
|
212
|
+
var __accessCheck$7 = (obj, member, msg) => {
|
|
213
213
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
214
214
|
};
|
|
215
|
-
var __privateGet$
|
|
216
|
-
__accessCheck$
|
|
215
|
+
var __privateGet$7 = (obj, member, getter) => {
|
|
216
|
+
__accessCheck$7(obj, member, "read from private field");
|
|
217
217
|
return getter ? getter.call(obj) : member.get(obj);
|
|
218
218
|
};
|
|
219
|
-
var __privateAdd$
|
|
219
|
+
var __privateAdd$7 = (obj, member, value) => {
|
|
220
220
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
221
221
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
222
222
|
};
|
|
223
|
-
var __privateSet$
|
|
224
|
-
__accessCheck$
|
|
223
|
+
var __privateSet$7 = (obj, member, value, setter) => {
|
|
224
|
+
__accessCheck$7(obj, member, "write to private field");
|
|
225
225
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
226
226
|
return value;
|
|
227
227
|
};
|
|
@@ -235,50 +235,50 @@
|
|
|
235
235
|
/**
|
|
236
236
|
* Private implementation details
|
|
237
237
|
*/
|
|
238
|
-
__privateAdd$
|
|
239
|
-
__privateAdd$
|
|
240
|
-
__privateAdd$
|
|
241
|
-
__privateAdd$
|
|
242
|
-
__privateAdd$
|
|
238
|
+
__privateAdd$7(this, _method, void 0);
|
|
239
|
+
__privateAdd$7(this, _url, void 0);
|
|
240
|
+
__privateAdd$7(this, _resHeaders, void 0);
|
|
241
|
+
__privateAdd$7(this, _headers, {});
|
|
242
|
+
__privateAdd$7(this, _controller, void 0);
|
|
243
243
|
}
|
|
244
244
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- _async is only declared for typings compatibility
|
|
245
245
|
open(method, url, _async) {
|
|
246
|
-
__privateSet$
|
|
247
|
-
__privateSet$
|
|
248
|
-
__privateSet$
|
|
246
|
+
__privateSet$7(this, _method, method);
|
|
247
|
+
__privateSet$7(this, _url, url);
|
|
248
|
+
__privateSet$7(this, _resHeaders, "");
|
|
249
249
|
this.readyState = 1;
|
|
250
250
|
this.onreadystatechange();
|
|
251
|
-
__privateSet$
|
|
251
|
+
__privateSet$7(this, _controller, void 0);
|
|
252
252
|
}
|
|
253
253
|
abort() {
|
|
254
|
-
if (__privateGet$
|
|
255
|
-
__privateGet$
|
|
254
|
+
if (__privateGet$7(this, _controller)) {
|
|
255
|
+
__privateGet$7(this, _controller).abort();
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
getAllResponseHeaders() {
|
|
259
|
-
return __privateGet$
|
|
259
|
+
return __privateGet$7(this, _resHeaders);
|
|
260
260
|
}
|
|
261
261
|
setRequestHeader(name, value) {
|
|
262
|
-
__privateGet$
|
|
262
|
+
__privateGet$7(this, _headers)[name] = value;
|
|
263
263
|
}
|
|
264
264
|
send(body) {
|
|
265
265
|
const textBody = this.responseType !== "arraybuffer";
|
|
266
266
|
const options = {
|
|
267
|
-
method: __privateGet$
|
|
268
|
-
headers: __privateGet$
|
|
267
|
+
method: __privateGet$7(this, _method),
|
|
268
|
+
headers: __privateGet$7(this, _headers),
|
|
269
269
|
signal: null,
|
|
270
270
|
body
|
|
271
271
|
};
|
|
272
272
|
if (typeof AbortController === "function") {
|
|
273
|
-
__privateSet$
|
|
274
|
-
options.signal = __privateGet$
|
|
273
|
+
__privateSet$7(this, _controller, new AbortController());
|
|
274
|
+
options.signal = __privateGet$7(this, _controller).signal;
|
|
275
275
|
}
|
|
276
276
|
if (typeof document !== "undefined") {
|
|
277
277
|
options.credentials = this.withCredentials ? "include" : "omit";
|
|
278
278
|
}
|
|
279
|
-
fetch(__privateGet$
|
|
279
|
+
fetch(__privateGet$7(this, _url), options).then(res => {
|
|
280
280
|
res.headers.forEach((value, key) => {
|
|
281
|
-
__privateSet$
|
|
281
|
+
__privateSet$7(this, _resHeaders, __privateGet$7(this, _resHeaders) + "".concat(key, ": ").concat(value, "\r\n"));
|
|
282
282
|
});
|
|
283
283
|
this.status = res.status;
|
|
284
284
|
this.statusText = res.statusText;
|
|
@@ -3349,60 +3349,50 @@
|
|
|
3349
3349
|
}
|
|
3350
3350
|
return tag;
|
|
3351
3351
|
};
|
|
3352
|
-
const enc = encodeURIComponent;
|
|
3353
3352
|
var encodeQueryString = _ref => {
|
|
3354
3353
|
let {
|
|
3355
3354
|
query,
|
|
3356
3355
|
params = {},
|
|
3357
3356
|
options = {}
|
|
3358
3357
|
} = _ref;
|
|
3358
|
+
const searchParams = new URLSearchParams();
|
|
3359
3359
|
const {
|
|
3360
3360
|
tag,
|
|
3361
3361
|
...opts
|
|
3362
3362
|
} = options;
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
const
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3363
|
+
if (tag) searchParams.set("tag", tag);
|
|
3364
|
+
searchParams.set("query", query);
|
|
3365
|
+
for (const [key, value] of Object.entries(params)) {
|
|
3366
|
+
searchParams.set("$".concat(key), JSON.stringify(value));
|
|
3367
|
+
}
|
|
3368
|
+
for (const [key, value] of Object.entries(opts)) {
|
|
3369
|
+
if (value) searchParams.set(key, "".concat(value));
|
|
3370
|
+
}
|
|
3371
|
+
return "?".concat(searchParams);
|
|
3369
3372
|
};
|
|
3370
|
-
var __accessCheck$
|
|
3373
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
3371
3374
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
3372
3375
|
};
|
|
3373
|
-
var __privateGet$
|
|
3374
|
-
__accessCheck$
|
|
3376
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
3377
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
3375
3378
|
return getter ? getter.call(obj) : member.get(obj);
|
|
3376
3379
|
};
|
|
3377
|
-
var __privateAdd$
|
|
3380
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
3378
3381
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
3379
3382
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
3380
3383
|
};
|
|
3381
|
-
var __privateSet$
|
|
3382
|
-
__accessCheck$
|
|
3384
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
3385
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
3383
3386
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
3384
3387
|
return value;
|
|
3385
3388
|
};
|
|
3386
|
-
var _client$
|
|
3389
|
+
var _client$5, _client2$5;
|
|
3387
3390
|
class BasePatch {
|
|
3388
3391
|
constructor(selection) {
|
|
3389
3392
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3390
3393
|
this.selection = selection;
|
|
3391
3394
|
this.operations = operations;
|
|
3392
3395
|
}
|
|
3393
|
-
/**
|
|
3394
|
-
* DEPRECATED: Don't use.
|
|
3395
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
3396
|
-
*
|
|
3397
|
-
* @deprecated - Don't use.
|
|
3398
|
-
* @param attrs - Attributes to replace
|
|
3399
|
-
*/
|
|
3400
|
-
replace(attrs) {
|
|
3401
|
-
validateObject("replace", attrs);
|
|
3402
|
-
return this._set("set", {
|
|
3403
|
-
$: attrs
|
|
3404
|
-
});
|
|
3405
|
-
}
|
|
3406
3396
|
/**
|
|
3407
3397
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
3408
3398
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
@@ -3556,8 +3546,8 @@
|
|
|
3556
3546
|
const _ObservablePatch = class extends BasePatch {
|
|
3557
3547
|
constructor(selection, operations, client) {
|
|
3558
3548
|
super(selection, operations);
|
|
3559
|
-
__privateAdd$
|
|
3560
|
-
__privateSet$
|
|
3549
|
+
__privateAdd$6(this, _client$5, void 0);
|
|
3550
|
+
__privateSet$6(this, _client$5, client);
|
|
3561
3551
|
}
|
|
3562
3552
|
/**
|
|
3563
3553
|
* Clones the patch
|
|
@@ -3565,10 +3555,10 @@
|
|
|
3565
3555
|
clone() {
|
|
3566
3556
|
return new _ObservablePatch(this.selection, {
|
|
3567
3557
|
...this.operations
|
|
3568
|
-
}, __privateGet$
|
|
3558
|
+
}, __privateGet$6(this, _client$5));
|
|
3569
3559
|
}
|
|
3570
3560
|
commit(options) {
|
|
3571
|
-
if (!__privateGet$
|
|
3561
|
+
if (!__privateGet$6(this, _client$5)) {
|
|
3572
3562
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
3573
3563
|
}
|
|
3574
3564
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -3576,18 +3566,18 @@
|
|
|
3576
3566
|
returnFirst,
|
|
3577
3567
|
returnDocuments: true
|
|
3578
3568
|
}, options);
|
|
3579
|
-
return __privateGet$
|
|
3569
|
+
return __privateGet$6(this, _client$5).mutate({
|
|
3580
3570
|
patch: this.serialize()
|
|
3581
3571
|
}, opts);
|
|
3582
3572
|
}
|
|
3583
3573
|
};
|
|
3584
3574
|
let ObservablePatch = _ObservablePatch;
|
|
3585
|
-
_client$
|
|
3575
|
+
_client$5 = new WeakMap();
|
|
3586
3576
|
const _Patch = class extends BasePatch {
|
|
3587
3577
|
constructor(selection, operations, client) {
|
|
3588
3578
|
super(selection, operations);
|
|
3589
|
-
__privateAdd$
|
|
3590
|
-
__privateSet$
|
|
3579
|
+
__privateAdd$6(this, _client2$5, void 0);
|
|
3580
|
+
__privateSet$6(this, _client2$5, client);
|
|
3591
3581
|
}
|
|
3592
3582
|
/**
|
|
3593
3583
|
* Clones the patch
|
|
@@ -3595,10 +3585,10 @@
|
|
|
3595
3585
|
clone() {
|
|
3596
3586
|
return new _Patch(this.selection, {
|
|
3597
3587
|
...this.operations
|
|
3598
|
-
}, __privateGet$
|
|
3588
|
+
}, __privateGet$6(this, _client2$5));
|
|
3599
3589
|
}
|
|
3600
3590
|
commit(options) {
|
|
3601
|
-
if (!__privateGet$
|
|
3591
|
+
if (!__privateGet$6(this, _client2$5)) {
|
|
3602
3592
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
3603
3593
|
}
|
|
3604
3594
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -3606,30 +3596,30 @@
|
|
|
3606
3596
|
returnFirst,
|
|
3607
3597
|
returnDocuments: true
|
|
3608
3598
|
}, options);
|
|
3609
|
-
return __privateGet$
|
|
3599
|
+
return __privateGet$6(this, _client2$5).mutate({
|
|
3610
3600
|
patch: this.serialize()
|
|
3611
3601
|
}, opts);
|
|
3612
3602
|
}
|
|
3613
3603
|
};
|
|
3614
3604
|
let Patch = _Patch;
|
|
3615
|
-
_client2$
|
|
3616
|
-
var __accessCheck$
|
|
3605
|
+
_client2$5 = new WeakMap();
|
|
3606
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
3617
3607
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
3618
3608
|
};
|
|
3619
|
-
var __privateGet$
|
|
3620
|
-
__accessCheck$
|
|
3609
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
3610
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
3621
3611
|
return getter ? getter.call(obj) : member.get(obj);
|
|
3622
3612
|
};
|
|
3623
|
-
var __privateAdd$
|
|
3613
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
3624
3614
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
3625
3615
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
3626
3616
|
};
|
|
3627
|
-
var __privateSet$
|
|
3628
|
-
__accessCheck$
|
|
3617
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
3618
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
3629
3619
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
3630
3620
|
return value;
|
|
3631
3621
|
};
|
|
3632
|
-
var _client$
|
|
3622
|
+
var _client$4, _client2$4;
|
|
3633
3623
|
const defaultMutateOptions = {
|
|
3634
3624
|
returnDocuments: false
|
|
3635
3625
|
};
|
|
@@ -3728,20 +3718,20 @@
|
|
|
3728
3718
|
const _Transaction = class extends BaseTransaction {
|
|
3729
3719
|
constructor(operations, client, transactionId) {
|
|
3730
3720
|
super(operations, transactionId);
|
|
3731
|
-
__privateAdd$
|
|
3732
|
-
__privateSet$
|
|
3721
|
+
__privateAdd$5(this, _client$4, void 0);
|
|
3722
|
+
__privateSet$5(this, _client$4, client);
|
|
3733
3723
|
}
|
|
3734
3724
|
/**
|
|
3735
3725
|
* Clones the transaction
|
|
3736
3726
|
*/
|
|
3737
3727
|
clone() {
|
|
3738
|
-
return new _Transaction([...this.operations], __privateGet$
|
|
3728
|
+
return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
|
|
3739
3729
|
}
|
|
3740
3730
|
commit(options) {
|
|
3741
|
-
if (!__privateGet$
|
|
3731
|
+
if (!__privateGet$5(this, _client$4)) {
|
|
3742
3732
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
3743
3733
|
}
|
|
3744
|
-
return __privateGet$
|
|
3734
|
+
return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
|
|
3745
3735
|
transactionId: this.trxId
|
|
3746
3736
|
}, defaultMutateOptions, options || {}));
|
|
3747
3737
|
}
|
|
@@ -3754,7 +3744,7 @@
|
|
|
3754
3744
|
});
|
|
3755
3745
|
}
|
|
3756
3746
|
if (isBuilder) {
|
|
3757
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$
|
|
3747
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
|
|
3758
3748
|
if (!(patch instanceof Patch)) {
|
|
3759
3749
|
throw new Error("function passed to `patch()` must return the patch");
|
|
3760
3750
|
}
|
|
@@ -3771,24 +3761,24 @@
|
|
|
3771
3761
|
}
|
|
3772
3762
|
};
|
|
3773
3763
|
let Transaction = _Transaction;
|
|
3774
|
-
_client$
|
|
3764
|
+
_client$4 = new WeakMap();
|
|
3775
3765
|
const _ObservableTransaction = class extends BaseTransaction {
|
|
3776
3766
|
constructor(operations, client, transactionId) {
|
|
3777
3767
|
super(operations, transactionId);
|
|
3778
|
-
__privateAdd$
|
|
3779
|
-
__privateSet$
|
|
3768
|
+
__privateAdd$5(this, _client2$4, void 0);
|
|
3769
|
+
__privateSet$5(this, _client2$4, client);
|
|
3780
3770
|
}
|
|
3781
3771
|
/**
|
|
3782
3772
|
* Clones the transaction
|
|
3783
3773
|
*/
|
|
3784
3774
|
clone() {
|
|
3785
|
-
return new _ObservableTransaction([...this.operations], __privateGet$
|
|
3775
|
+
return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
|
|
3786
3776
|
}
|
|
3787
3777
|
commit(options) {
|
|
3788
|
-
if (!__privateGet$
|
|
3778
|
+
if (!__privateGet$5(this, _client2$4)) {
|
|
3789
3779
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
3790
3780
|
}
|
|
3791
|
-
return __privateGet$
|
|
3781
|
+
return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
|
|
3792
3782
|
transactionId: this.trxId
|
|
3793
3783
|
}, defaultMutateOptions, options || {}));
|
|
3794
3784
|
}
|
|
@@ -3801,7 +3791,7 @@
|
|
|
3801
3791
|
});
|
|
3802
3792
|
}
|
|
3803
3793
|
if (isBuilder) {
|
|
3804
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$
|
|
3794
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
|
|
3805
3795
|
if (!(patch instanceof ObservablePatch)) {
|
|
3806
3796
|
throw new Error("function passed to `patch()` must return the patch");
|
|
3807
3797
|
}
|
|
@@ -3818,7 +3808,7 @@
|
|
|
3818
3808
|
}
|
|
3819
3809
|
};
|
|
3820
3810
|
let ObservableTransaction = _ObservableTransaction;
|
|
3821
|
-
_client2$
|
|
3811
|
+
_client2$4 = new WeakMap();
|
|
3822
3812
|
const excludeFalsey = (param, defValue) => {
|
|
3823
3813
|
const value = typeof param === "undefined" ? defValue : param;
|
|
3824
3814
|
return param === false ? void 0 : value;
|
|
@@ -3990,50 +3980,50 @@
|
|
|
3990
3980
|
const base = canUseCdn ? cdnUrl : url;
|
|
3991
3981
|
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
3992
3982
|
}
|
|
3993
|
-
var __accessCheck$
|
|
3983
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
3994
3984
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
3995
3985
|
};
|
|
3996
|
-
var __privateGet$
|
|
3997
|
-
__accessCheck$
|
|
3986
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
3987
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
3998
3988
|
return getter ? getter.call(obj) : member.get(obj);
|
|
3999
3989
|
};
|
|
4000
|
-
var __privateAdd$
|
|
3990
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
4001
3991
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
4002
3992
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
4003
3993
|
};
|
|
4004
|
-
var __privateSet$
|
|
4005
|
-
__accessCheck$
|
|
3994
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
3995
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
4006
3996
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
4007
3997
|
return value;
|
|
4008
3998
|
};
|
|
4009
|
-
var _client$
|
|
3999
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
4010
4000
|
class ObservableAssetsClient {
|
|
4011
4001
|
constructor(client, httpRequest) {
|
|
4012
|
-
__privateAdd$
|
|
4013
|
-
__privateAdd$
|
|
4014
|
-
__privateSet$
|
|
4015
|
-
__privateSet$
|
|
4002
|
+
__privateAdd$4(this, _client$3, void 0);
|
|
4003
|
+
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
4004
|
+
__privateSet$4(this, _client$3, client);
|
|
4005
|
+
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
4016
4006
|
}
|
|
4017
4007
|
upload(assetType, body, options) {
|
|
4018
|
-
return _upload(__privateGet$
|
|
4008
|
+
return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
|
|
4019
4009
|
}
|
|
4020
4010
|
}
|
|
4021
|
-
_client$
|
|
4022
|
-
_httpRequest$
|
|
4011
|
+
_client$3 = new WeakMap();
|
|
4012
|
+
_httpRequest$4 = new WeakMap();
|
|
4023
4013
|
class AssetsClient {
|
|
4024
4014
|
constructor(client, httpRequest) {
|
|
4025
|
-
__privateAdd$
|
|
4026
|
-
__privateAdd$
|
|
4027
|
-
__privateSet$
|
|
4028
|
-
__privateSet$
|
|
4015
|
+
__privateAdd$4(this, _client2$3, void 0);
|
|
4016
|
+
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
4017
|
+
__privateSet$4(this, _client2$3, client);
|
|
4018
|
+
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
4029
4019
|
}
|
|
4030
4020
|
upload(assetType, body, options) {
|
|
4031
|
-
const observable = _upload(__privateGet$
|
|
4021
|
+
const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
|
|
4032
4022
|
return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
|
|
4033
4023
|
}
|
|
4034
4024
|
}
|
|
4035
|
-
_client2$
|
|
4036
|
-
_httpRequest2$
|
|
4025
|
+
_client2$3 = new WeakMap();
|
|
4026
|
+
_httpRequest2$4 = new WeakMap();
|
|
4037
4027
|
function _upload(client, httpRequest, assetType, body) {
|
|
4038
4028
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
4039
4029
|
validateAssetType(assetType);
|
|
@@ -4087,77 +4077,6 @@
|
|
|
4087
4077
|
contentType: file.type
|
|
4088
4078
|
}, opts);
|
|
4089
4079
|
}
|
|
4090
|
-
var __accessCheck$4 = (obj, member, msg) => {
|
|
4091
|
-
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
4092
|
-
};
|
|
4093
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
4094
|
-
__accessCheck$4(obj, member, "read from private field");
|
|
4095
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
4096
|
-
};
|
|
4097
|
-
var __privateAdd$4 = (obj, member, value) => {
|
|
4098
|
-
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
4099
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
4100
|
-
};
|
|
4101
|
-
var __privateSet$4 = (obj, member, value, setter) => {
|
|
4102
|
-
__accessCheck$4(obj, member, "write to private field");
|
|
4103
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
4104
|
-
return value;
|
|
4105
|
-
};
|
|
4106
|
-
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
4107
|
-
class ObservableAuthClient {
|
|
4108
|
-
constructor(client, httpRequest) {
|
|
4109
|
-
__privateAdd$4(this, _client$3, void 0);
|
|
4110
|
-
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
4111
|
-
__privateSet$4(this, _client$3, client);
|
|
4112
|
-
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
4113
|
-
}
|
|
4114
|
-
/**
|
|
4115
|
-
* Fetch available login providers
|
|
4116
|
-
*/
|
|
4117
|
-
getLoginProviders() {
|
|
4118
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
4119
|
-
uri: "/auth/providers"
|
|
4120
|
-
});
|
|
4121
|
-
}
|
|
4122
|
-
/**
|
|
4123
|
-
* Revoke the configured session/token
|
|
4124
|
-
*/
|
|
4125
|
-
logout() {
|
|
4126
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
4127
|
-
uri: "/auth/logout",
|
|
4128
|
-
method: "POST"
|
|
4129
|
-
});
|
|
4130
|
-
}
|
|
4131
|
-
}
|
|
4132
|
-
_client$3 = new WeakMap();
|
|
4133
|
-
_httpRequest$4 = new WeakMap();
|
|
4134
|
-
class AuthClient {
|
|
4135
|
-
constructor(client, httpRequest) {
|
|
4136
|
-
__privateAdd$4(this, _client2$3, void 0);
|
|
4137
|
-
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
4138
|
-
__privateSet$4(this, _client2$3, client);
|
|
4139
|
-
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
4140
|
-
}
|
|
4141
|
-
/**
|
|
4142
|
-
* Fetch available login providers
|
|
4143
|
-
*/
|
|
4144
|
-
getLoginProviders() {
|
|
4145
|
-
return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
4146
|
-
uri: "/auth/providers"
|
|
4147
|
-
}));
|
|
4148
|
-
}
|
|
4149
|
-
/**
|
|
4150
|
-
* Revoke the configured session/token
|
|
4151
|
-
*/
|
|
4152
|
-
logout() {
|
|
4153
|
-
return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
4154
|
-
uri: "/auth/logout",
|
|
4155
|
-
method: "POST"
|
|
4156
|
-
}));
|
|
4157
|
-
}
|
|
4158
|
-
}
|
|
4159
|
-
_client2$3 = new WeakMap();
|
|
4160
|
-
_httpRequest2$4 = new WeakMap();
|
|
4161
4080
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
4162
4081
|
function generateHelpUrl(slug) {
|
|
4163
4082
|
return BASE_URL + slug;
|
|
@@ -4660,10 +4579,13 @@
|
|
|
4660
4579
|
*/
|
|
4661
4580
|
__privateAdd(this, _clientConfig, void 0);
|
|
4662
4581
|
__privateAdd(this, _httpRequest, void 0);
|
|
4582
|
+
/**
|
|
4583
|
+
* Instance properties
|
|
4584
|
+
*/
|
|
4585
|
+
this.listen = _listen;
|
|
4663
4586
|
this.config(config);
|
|
4664
4587
|
__privateSet(this, _httpRequest, httpRequest);
|
|
4665
4588
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
4666
|
-
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
4667
4589
|
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
4668
4590
|
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
4669
4591
|
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
@@ -4782,7 +4704,6 @@
|
|
|
4782
4704
|
this.config(config);
|
|
4783
4705
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
4784
4706
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
4785
|
-
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
4786
4707
|
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
4787
4708
|
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
4788
4709
|
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|