@sanity/client 5.0.0-esm.13 → 5.0.0-esm.14
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 +61 -147
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +61 -147
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +62 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +30 -40
- package/dist/index.js +62 -148
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/SanityClient.ts +0 -7
- package/src/assets/AssetsClient.ts +28 -4
- package/src/data/patch.ts +0 -12
- package/umd/sanityClient.js +86 -172
- package/umd/sanityClient.min.js +3 -3
- package/src/auth/AuthClient.ts +0 -67
package/dist/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare class AssetsClient {
|
|
|
32
32
|
/**
|
|
33
33
|
* Uploads a file asset to the configured dataset
|
|
34
34
|
*
|
|
35
|
-
* @param assetType - Asset type (file
|
|
35
|
+
* @param assetType - Asset type (file)
|
|
36
36
|
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
37
37
|
* @param options - Options to use for the upload
|
|
38
38
|
*/
|
|
@@ -44,7 +44,7 @@ export declare class AssetsClient {
|
|
|
44
44
|
/**
|
|
45
45
|
* Uploads an image asset to the configured dataset
|
|
46
46
|
*
|
|
47
|
-
* @param assetType - Asset type (
|
|
47
|
+
* @param assetType - Asset type (image)
|
|
48
48
|
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
49
49
|
* @param options - Options to use for the upload
|
|
50
50
|
*/
|
|
@@ -53,6 +53,18 @@ export declare class AssetsClient {
|
|
|
53
53
|
body: File | Blob | Buffer | NodeJS.ReadableStream,
|
|
54
54
|
options?: UploadClientConfig
|
|
55
55
|
): Promise<SanityImageAssetDocument>
|
|
56
|
+
/**
|
|
57
|
+
* Uploads a file or an image asset to the configured dataset
|
|
58
|
+
*
|
|
59
|
+
* @param assetType - Asset type (file/image)
|
|
60
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
61
|
+
* @param options - Options to use for the upload
|
|
62
|
+
*/
|
|
63
|
+
upload(
|
|
64
|
+
assetType: 'file' | 'image',
|
|
65
|
+
body: File | Blob | Buffer | NodeJS.ReadableStream,
|
|
66
|
+
options?: UploadClientConfig
|
|
67
|
+
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
56
68
|
}
|
|
57
69
|
|
|
58
70
|
/** @internal */
|
|
@@ -60,20 +72,6 @@ export declare type AttributeSet = {
|
|
|
60
72
|
[key: string]: FIXME
|
|
61
73
|
}
|
|
62
74
|
|
|
63
|
-
/** @internal */
|
|
64
|
-
export declare class AuthClient {
|
|
65
|
-
#private
|
|
66
|
-
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
67
|
-
/**
|
|
68
|
-
* Fetch available login providers
|
|
69
|
-
*/
|
|
70
|
-
getLoginProviders(): Promise<AuthProviderResponse>
|
|
71
|
-
/**
|
|
72
|
-
* Revoke the configured session/token
|
|
73
|
-
*/
|
|
74
|
-
logout(): Promise<void>
|
|
75
|
-
}
|
|
76
|
-
|
|
77
75
|
/** @internal */
|
|
78
76
|
export declare interface AuthProvider {
|
|
79
77
|
name: string
|
|
@@ -101,14 +99,6 @@ export declare class BasePatch {
|
|
|
101
99
|
protected selection: PatchSelection
|
|
102
100
|
protected operations: PatchOperations
|
|
103
101
|
constructor(selection: PatchSelection, operations?: PatchOperations)
|
|
104
|
-
/**
|
|
105
|
-
* DEPRECATED: Don't use.
|
|
106
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
107
|
-
*
|
|
108
|
-
* @deprecated - Don't use.
|
|
109
|
-
* @param attrs - Attributes to replace
|
|
110
|
-
*/
|
|
111
|
-
replace(attrs: AttributeSet): this
|
|
112
102
|
/**
|
|
113
103
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
114
104
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
@@ -583,7 +573,7 @@ export declare class ObservableAssetsClient {
|
|
|
583
573
|
/**
|
|
584
574
|
* Uploads a file asset to the configured dataset
|
|
585
575
|
*
|
|
586
|
-
* @param assetType - Asset type (file
|
|
576
|
+
* @param assetType - Asset type (file)
|
|
587
577
|
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
588
578
|
* @param options - Options to use for the upload
|
|
589
579
|
*/
|
|
@@ -599,7 +589,7 @@ export declare class ObservableAssetsClient {
|
|
|
599
589
|
/**
|
|
600
590
|
* Uploads an image asset to the configured dataset
|
|
601
591
|
*
|
|
602
|
-
* @param assetType - Asset type (
|
|
592
|
+
* @param assetType - Asset type (image)
|
|
603
593
|
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
604
594
|
* @param options - Options to use for the upload
|
|
605
595
|
*/
|
|
@@ -612,20 +602,22 @@ export declare class ObservableAssetsClient {
|
|
|
612
602
|
document: SanityImageAssetDocument
|
|
613
603
|
}>
|
|
614
604
|
>
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
/** @internal */
|
|
618
|
-
export declare class ObservableAuthClient {
|
|
619
|
-
#private
|
|
620
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
621
|
-
/**
|
|
622
|
-
* Fetch available login providers
|
|
623
|
-
*/
|
|
624
|
-
getLoginProviders(): Observable<AuthProviderResponse>
|
|
625
605
|
/**
|
|
626
|
-
*
|
|
606
|
+
* Uploads a file or an image asset to the configured dataset
|
|
607
|
+
*
|
|
608
|
+
* @param assetType - Asset type (file/image)
|
|
609
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
610
|
+
* @param options - Options to use for the upload
|
|
627
611
|
*/
|
|
628
|
-
|
|
612
|
+
upload(
|
|
613
|
+
assetType: 'file' | 'image',
|
|
614
|
+
body: File | Blob | Buffer | NodeJS.ReadableStream,
|
|
615
|
+
options?: UploadClientConfig
|
|
616
|
+
): Observable<
|
|
617
|
+
HttpRequestEvent<{
|
|
618
|
+
document: SanityAssetDocument | SanityImageAssetDocument
|
|
619
|
+
}>
|
|
620
|
+
>
|
|
629
621
|
}
|
|
630
622
|
|
|
631
623
|
/** @internal */
|
|
@@ -743,7 +735,6 @@ export declare class ObservableProjectsClient {
|
|
|
743
735
|
export declare class ObservableSanityClient {
|
|
744
736
|
#private
|
|
745
737
|
assets: ObservableAssetsClient
|
|
746
|
-
auth: ObservableAuthClient
|
|
747
738
|
datasets: ObservableDatasetsClient
|
|
748
739
|
projects: ObservableProjectsClient
|
|
749
740
|
users: ObservableUsersClient
|
|
@@ -1444,7 +1435,6 @@ export declare interface SanityAssetDocument extends SanityDocument {
|
|
|
1444
1435
|
export declare class SanityClient {
|
|
1445
1436
|
#private
|
|
1446
1437
|
assets: AssetsClient
|
|
1447
|
-
auth: AuthClient
|
|
1448
1438
|
datasets: DatasetsClient
|
|
1449
1439
|
projects: ProjectsClient
|
|
1450
1440
|
users: UsersClient
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Observable, lastValueFrom } from 'rxjs';
|
|
|
4
4
|
import { map, filter } from 'rxjs/operators';
|
|
5
5
|
import polyfilledEventSource from '@sanity/eventsource';
|
|
6
6
|
var name = "@sanity/client";
|
|
7
|
-
var version = "5.0.0-esm.
|
|
7
|
+
var version = "5.0.0-esm.14";
|
|
8
8
|
const middleware = [debug({
|
|
9
9
|
verbose: true,
|
|
10
10
|
namespace: "sanity:client"
|
|
@@ -205,42 +205,29 @@ var encodeQueryString = _ref => {
|
|
|
205
205
|
return options[option] ? "".concat(qs, "&").concat(enc(option), "=").concat(enc(options[option])) : qs;
|
|
206
206
|
}, qString);
|
|
207
207
|
};
|
|
208
|
-
var __accessCheck$
|
|
208
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
209
209
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
210
210
|
};
|
|
211
|
-
var __privateGet$
|
|
212
|
-
__accessCheck$
|
|
211
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
212
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
213
213
|
return getter ? getter.call(obj) : member.get(obj);
|
|
214
214
|
};
|
|
215
|
-
var __privateAdd$
|
|
215
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
216
216
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
217
217
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
218
218
|
};
|
|
219
|
-
var __privateSet$
|
|
220
|
-
__accessCheck$
|
|
219
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
220
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
221
221
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
222
222
|
return value;
|
|
223
223
|
};
|
|
224
|
-
var _client$
|
|
224
|
+
var _client$5, _client2$5;
|
|
225
225
|
class BasePatch {
|
|
226
226
|
constructor(selection) {
|
|
227
227
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
228
228
|
this.selection = selection;
|
|
229
229
|
this.operations = operations;
|
|
230
230
|
}
|
|
231
|
-
/**
|
|
232
|
-
* DEPRECATED: Don't use.
|
|
233
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
234
|
-
*
|
|
235
|
-
* @deprecated - Don't use.
|
|
236
|
-
* @param attrs - Attributes to replace
|
|
237
|
-
*/
|
|
238
|
-
replace(attrs) {
|
|
239
|
-
validateObject("replace", attrs);
|
|
240
|
-
return this._set("set", {
|
|
241
|
-
$: attrs
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
231
|
/**
|
|
245
232
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
246
233
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
@@ -394,8 +381,8 @@ class BasePatch {
|
|
|
394
381
|
const _ObservablePatch = class extends BasePatch {
|
|
395
382
|
constructor(selection, operations, client) {
|
|
396
383
|
super(selection, operations);
|
|
397
|
-
__privateAdd$
|
|
398
|
-
__privateSet$
|
|
384
|
+
__privateAdd$6(this, _client$5, void 0);
|
|
385
|
+
__privateSet$6(this, _client$5, client);
|
|
399
386
|
}
|
|
400
387
|
/**
|
|
401
388
|
* Clones the patch
|
|
@@ -403,10 +390,10 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
403
390
|
clone() {
|
|
404
391
|
return new _ObservablePatch(this.selection, {
|
|
405
392
|
...this.operations
|
|
406
|
-
}, __privateGet$
|
|
393
|
+
}, __privateGet$6(this, _client$5));
|
|
407
394
|
}
|
|
408
395
|
commit(options) {
|
|
409
|
-
if (!__privateGet$
|
|
396
|
+
if (!__privateGet$6(this, _client$5)) {
|
|
410
397
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
411
398
|
}
|
|
412
399
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -414,18 +401,18 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
414
401
|
returnFirst,
|
|
415
402
|
returnDocuments: true
|
|
416
403
|
}, options);
|
|
417
|
-
return __privateGet$
|
|
404
|
+
return __privateGet$6(this, _client$5).mutate({
|
|
418
405
|
patch: this.serialize()
|
|
419
406
|
}, opts);
|
|
420
407
|
}
|
|
421
408
|
};
|
|
422
409
|
let ObservablePatch = _ObservablePatch;
|
|
423
|
-
_client$
|
|
410
|
+
_client$5 = new WeakMap();
|
|
424
411
|
const _Patch = class extends BasePatch {
|
|
425
412
|
constructor(selection, operations, client) {
|
|
426
413
|
super(selection, operations);
|
|
427
|
-
__privateAdd$
|
|
428
|
-
__privateSet$
|
|
414
|
+
__privateAdd$6(this, _client2$5, void 0);
|
|
415
|
+
__privateSet$6(this, _client2$5, client);
|
|
429
416
|
}
|
|
430
417
|
/**
|
|
431
418
|
* Clones the patch
|
|
@@ -433,10 +420,10 @@ const _Patch = class extends BasePatch {
|
|
|
433
420
|
clone() {
|
|
434
421
|
return new _Patch(this.selection, {
|
|
435
422
|
...this.operations
|
|
436
|
-
}, __privateGet$
|
|
423
|
+
}, __privateGet$6(this, _client2$5));
|
|
437
424
|
}
|
|
438
425
|
commit(options) {
|
|
439
|
-
if (!__privateGet$
|
|
426
|
+
if (!__privateGet$6(this, _client2$5)) {
|
|
440
427
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
441
428
|
}
|
|
442
429
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -444,30 +431,30 @@ const _Patch = class extends BasePatch {
|
|
|
444
431
|
returnFirst,
|
|
445
432
|
returnDocuments: true
|
|
446
433
|
}, options);
|
|
447
|
-
return __privateGet$
|
|
434
|
+
return __privateGet$6(this, _client2$5).mutate({
|
|
448
435
|
patch: this.serialize()
|
|
449
436
|
}, opts);
|
|
450
437
|
}
|
|
451
438
|
};
|
|
452
439
|
let Patch = _Patch;
|
|
453
|
-
_client2$
|
|
454
|
-
var __accessCheck$
|
|
440
|
+
_client2$5 = new WeakMap();
|
|
441
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
455
442
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
456
443
|
};
|
|
457
|
-
var __privateGet$
|
|
458
|
-
__accessCheck$
|
|
444
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
445
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
459
446
|
return getter ? getter.call(obj) : member.get(obj);
|
|
460
447
|
};
|
|
461
|
-
var __privateAdd$
|
|
448
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
462
449
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
463
450
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
464
451
|
};
|
|
465
|
-
var __privateSet$
|
|
466
|
-
__accessCheck$
|
|
452
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
453
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
467
454
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
468
455
|
return value;
|
|
469
456
|
};
|
|
470
|
-
var _client$
|
|
457
|
+
var _client$4, _client2$4;
|
|
471
458
|
const defaultMutateOptions = {
|
|
472
459
|
returnDocuments: false
|
|
473
460
|
};
|
|
@@ -566,20 +553,20 @@ class BaseTransaction {
|
|
|
566
553
|
const _Transaction = class extends BaseTransaction {
|
|
567
554
|
constructor(operations, client, transactionId) {
|
|
568
555
|
super(operations, transactionId);
|
|
569
|
-
__privateAdd$
|
|
570
|
-
__privateSet$
|
|
556
|
+
__privateAdd$5(this, _client$4, void 0);
|
|
557
|
+
__privateSet$5(this, _client$4, client);
|
|
571
558
|
}
|
|
572
559
|
/**
|
|
573
560
|
* Clones the transaction
|
|
574
561
|
*/
|
|
575
562
|
clone() {
|
|
576
|
-
return new _Transaction([...this.operations], __privateGet$
|
|
563
|
+
return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
|
|
577
564
|
}
|
|
578
565
|
commit(options) {
|
|
579
|
-
if (!__privateGet$
|
|
566
|
+
if (!__privateGet$5(this, _client$4)) {
|
|
580
567
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
581
568
|
}
|
|
582
|
-
return __privateGet$
|
|
569
|
+
return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
|
|
583
570
|
transactionId: this.trxId
|
|
584
571
|
}, defaultMutateOptions, options || {}));
|
|
585
572
|
}
|
|
@@ -592,7 +579,7 @@ const _Transaction = class extends BaseTransaction {
|
|
|
592
579
|
});
|
|
593
580
|
}
|
|
594
581
|
if (isBuilder) {
|
|
595
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$
|
|
582
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
|
|
596
583
|
if (!(patch instanceof Patch)) {
|
|
597
584
|
throw new Error("function passed to `patch()` must return the patch");
|
|
598
585
|
}
|
|
@@ -609,24 +596,24 @@ const _Transaction = class extends BaseTransaction {
|
|
|
609
596
|
}
|
|
610
597
|
};
|
|
611
598
|
let Transaction = _Transaction;
|
|
612
|
-
_client$
|
|
599
|
+
_client$4 = new WeakMap();
|
|
613
600
|
const _ObservableTransaction = class extends BaseTransaction {
|
|
614
601
|
constructor(operations, client, transactionId) {
|
|
615
602
|
super(operations, transactionId);
|
|
616
|
-
__privateAdd$
|
|
617
|
-
__privateSet$
|
|
603
|
+
__privateAdd$5(this, _client2$4, void 0);
|
|
604
|
+
__privateSet$5(this, _client2$4, client);
|
|
618
605
|
}
|
|
619
606
|
/**
|
|
620
607
|
* Clones the transaction
|
|
621
608
|
*/
|
|
622
609
|
clone() {
|
|
623
|
-
return new _ObservableTransaction([...this.operations], __privateGet$
|
|
610
|
+
return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
|
|
624
611
|
}
|
|
625
612
|
commit(options) {
|
|
626
|
-
if (!__privateGet$
|
|
613
|
+
if (!__privateGet$5(this, _client2$4)) {
|
|
627
614
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
628
615
|
}
|
|
629
|
-
return __privateGet$
|
|
616
|
+
return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
|
|
630
617
|
transactionId: this.trxId
|
|
631
618
|
}, defaultMutateOptions, options || {}));
|
|
632
619
|
}
|
|
@@ -639,7 +626,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
639
626
|
});
|
|
640
627
|
}
|
|
641
628
|
if (isBuilder) {
|
|
642
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$
|
|
629
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
|
|
643
630
|
if (!(patch instanceof ObservablePatch)) {
|
|
644
631
|
throw new Error("function passed to `patch()` must return the patch");
|
|
645
632
|
}
|
|
@@ -656,7 +643,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
656
643
|
}
|
|
657
644
|
};
|
|
658
645
|
let ObservableTransaction = _ObservableTransaction;
|
|
659
|
-
_client2$
|
|
646
|
+
_client2$4 = new WeakMap();
|
|
660
647
|
const excludeFalsey = (param, defValue) => {
|
|
661
648
|
const value = typeof param === "undefined" ? defValue : param;
|
|
662
649
|
return param === false ? void 0 : value;
|
|
@@ -828,50 +815,50 @@ function _getUrl(client, uri) {
|
|
|
828
815
|
const base = canUseCdn ? cdnUrl : url;
|
|
829
816
|
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
830
817
|
}
|
|
831
|
-
var __accessCheck$
|
|
818
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
832
819
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
833
820
|
};
|
|
834
|
-
var __privateGet$
|
|
835
|
-
__accessCheck$
|
|
821
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
822
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
836
823
|
return getter ? getter.call(obj) : member.get(obj);
|
|
837
824
|
};
|
|
838
|
-
var __privateAdd$
|
|
825
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
839
826
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
840
827
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
841
828
|
};
|
|
842
|
-
var __privateSet$
|
|
843
|
-
__accessCheck$
|
|
829
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
830
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
844
831
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
845
832
|
return value;
|
|
846
833
|
};
|
|
847
|
-
var _client$
|
|
834
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
848
835
|
class ObservableAssetsClient {
|
|
849
836
|
constructor(client, httpRequest) {
|
|
850
|
-
__privateAdd$
|
|
851
|
-
__privateAdd$
|
|
852
|
-
__privateSet$
|
|
853
|
-
__privateSet$
|
|
837
|
+
__privateAdd$4(this, _client$3, void 0);
|
|
838
|
+
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
839
|
+
__privateSet$4(this, _client$3, client);
|
|
840
|
+
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
854
841
|
}
|
|
855
842
|
upload(assetType, body, options) {
|
|
856
|
-
return _upload(__privateGet$
|
|
843
|
+
return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
|
|
857
844
|
}
|
|
858
845
|
}
|
|
859
|
-
_client$
|
|
860
|
-
_httpRequest$
|
|
846
|
+
_client$3 = new WeakMap();
|
|
847
|
+
_httpRequest$4 = new WeakMap();
|
|
861
848
|
class AssetsClient {
|
|
862
849
|
constructor(client, httpRequest) {
|
|
863
|
-
__privateAdd$
|
|
864
|
-
__privateAdd$
|
|
865
|
-
__privateSet$
|
|
866
|
-
__privateSet$
|
|
850
|
+
__privateAdd$4(this, _client2$3, void 0);
|
|
851
|
+
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
852
|
+
__privateSet$4(this, _client2$3, client);
|
|
853
|
+
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
867
854
|
}
|
|
868
855
|
upload(assetType, body, options) {
|
|
869
|
-
const observable = _upload(__privateGet$
|
|
856
|
+
const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
|
|
870
857
|
return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
|
|
871
858
|
}
|
|
872
859
|
}
|
|
873
|
-
_client2$
|
|
874
|
-
_httpRequest2$
|
|
860
|
+
_client2$3 = new WeakMap();
|
|
861
|
+
_httpRequest2$4 = new WeakMap();
|
|
875
862
|
function _upload(client, httpRequest, assetType, body) {
|
|
876
863
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
877
864
|
validateAssetType(assetType);
|
|
@@ -925,77 +912,6 @@ function optionsFromFile(opts, file) {
|
|
|
925
912
|
contentType: file.type
|
|
926
913
|
}, opts);
|
|
927
914
|
}
|
|
928
|
-
var __accessCheck$4 = (obj, member, msg) => {
|
|
929
|
-
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
930
|
-
};
|
|
931
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
932
|
-
__accessCheck$4(obj, member, "read from private field");
|
|
933
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
934
|
-
};
|
|
935
|
-
var __privateAdd$4 = (obj, member, value) => {
|
|
936
|
-
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
937
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
938
|
-
};
|
|
939
|
-
var __privateSet$4 = (obj, member, value, setter) => {
|
|
940
|
-
__accessCheck$4(obj, member, "write to private field");
|
|
941
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
942
|
-
return value;
|
|
943
|
-
};
|
|
944
|
-
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
945
|
-
class ObservableAuthClient {
|
|
946
|
-
constructor(client, httpRequest) {
|
|
947
|
-
__privateAdd$4(this, _client$3, void 0);
|
|
948
|
-
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
949
|
-
__privateSet$4(this, _client$3, client);
|
|
950
|
-
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
951
|
-
}
|
|
952
|
-
/**
|
|
953
|
-
* Fetch available login providers
|
|
954
|
-
*/
|
|
955
|
-
getLoginProviders() {
|
|
956
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
957
|
-
uri: "/auth/providers"
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* Revoke the configured session/token
|
|
962
|
-
*/
|
|
963
|
-
logout() {
|
|
964
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
965
|
-
uri: "/auth/logout",
|
|
966
|
-
method: "POST"
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
_client$3 = new WeakMap();
|
|
971
|
-
_httpRequest$4 = new WeakMap();
|
|
972
|
-
class AuthClient {
|
|
973
|
-
constructor(client, httpRequest) {
|
|
974
|
-
__privateAdd$4(this, _client2$3, void 0);
|
|
975
|
-
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
976
|
-
__privateSet$4(this, _client2$3, client);
|
|
977
|
-
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
978
|
-
}
|
|
979
|
-
/**
|
|
980
|
-
* Fetch available login providers
|
|
981
|
-
*/
|
|
982
|
-
getLoginProviders() {
|
|
983
|
-
return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
984
|
-
uri: "/auth/providers"
|
|
985
|
-
}));
|
|
986
|
-
}
|
|
987
|
-
/**
|
|
988
|
-
* Revoke the configured session/token
|
|
989
|
-
*/
|
|
990
|
-
logout() {
|
|
991
|
-
return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
992
|
-
uri: "/auth/logout",
|
|
993
|
-
method: "POST"
|
|
994
|
-
}));
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
_client2$3 = new WeakMap();
|
|
998
|
-
_httpRequest2$4 = new WeakMap();
|
|
999
915
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
1000
916
|
function generateHelpUrl(slug) {
|
|
1001
917
|
return BASE_URL + slug;
|
|
@@ -1501,7 +1417,6 @@ const _ObservableSanityClient = class {
|
|
|
1501
1417
|
this.config(config);
|
|
1502
1418
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1503
1419
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
1504
|
-
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
1505
1420
|
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
1506
1421
|
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
1507
1422
|
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
@@ -1620,7 +1535,6 @@ const _SanityClient = class {
|
|
|
1620
1535
|
this.config(config);
|
|
1621
1536
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1622
1537
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
1623
|
-
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
1624
1538
|
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
1625
1539
|
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
1626
1540
|
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|