@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/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,10 +735,13 @@ 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
|
|
741
|
+
/**
|
|
742
|
+
* Instance properties
|
|
743
|
+
*/
|
|
744
|
+
listen: typeof _listen
|
|
750
745
|
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
751
746
|
/**
|
|
752
747
|
* Clone the client - returns a new instance
|
|
@@ -778,7 +773,7 @@ export declare class ObservableSanityClient {
|
|
|
778
773
|
* @param query - GROQ-query to perform
|
|
779
774
|
* @param params - Query parameters
|
|
780
775
|
*/
|
|
781
|
-
fetch<R = FIXME>(query: string, params:
|
|
776
|
+
fetch<R = FIXME, Q = QueryParams>(query: string, params: Q): Observable<R>
|
|
782
777
|
/**
|
|
783
778
|
* Perform a GROQ-query against the configured dataset.
|
|
784
779
|
*
|
|
@@ -786,9 +781,9 @@ export declare class ObservableSanityClient {
|
|
|
786
781
|
* @param params - Query parameters
|
|
787
782
|
* @param options - Request options
|
|
788
783
|
*/
|
|
789
|
-
fetch<R = FIXME>(
|
|
784
|
+
fetch<R = FIXME, Q = QueryParams>(
|
|
790
785
|
query: string,
|
|
791
|
-
params:
|
|
786
|
+
params: Q | undefined,
|
|
792
787
|
options: FilteredResponseQueryOptions
|
|
793
788
|
): Observable<R>
|
|
794
789
|
/**
|
|
@@ -798,9 +793,9 @@ export declare class ObservableSanityClient {
|
|
|
798
793
|
* @param params - Query parameters
|
|
799
794
|
* @param options - Request options
|
|
800
795
|
*/
|
|
801
|
-
fetch<R = FIXME>(
|
|
796
|
+
fetch<R = FIXME, Q = QueryParams>(
|
|
802
797
|
query: string,
|
|
803
|
-
params:
|
|
798
|
+
params: Q | undefined,
|
|
804
799
|
options: UnfilteredResponseQueryOptions
|
|
805
800
|
): Observable<RawQueryResponse<R>>
|
|
806
801
|
/**
|
|
@@ -1444,7 +1439,6 @@ export declare interface SanityAssetDocument extends SanityDocument {
|
|
|
1444
1439
|
export declare class SanityClient {
|
|
1445
1440
|
#private
|
|
1446
1441
|
assets: AssetsClient
|
|
1447
|
-
auth: AuthClient
|
|
1448
1442
|
datasets: DatasetsClient
|
|
1449
1443
|
projects: ProjectsClient
|
|
1450
1444
|
users: UsersClient
|
|
@@ -1487,7 +1481,7 @@ export declare class SanityClient {
|
|
|
1487
1481
|
* @param query - GROQ-query to perform
|
|
1488
1482
|
* @param params - Optional query parameters
|
|
1489
1483
|
*/
|
|
1490
|
-
fetch<R = FIXME>(query: string, params:
|
|
1484
|
+
fetch<R = FIXME, Q = QueryParams>(query: string, params: Q): Promise<R>
|
|
1491
1485
|
/**
|
|
1492
1486
|
* Perform a GROQ-query against the configured dataset.
|
|
1493
1487
|
*
|
|
@@ -1495,9 +1489,9 @@ export declare class SanityClient {
|
|
|
1495
1489
|
* @param params - Optional query parameters
|
|
1496
1490
|
* @param options - Request options
|
|
1497
1491
|
*/
|
|
1498
|
-
fetch<R = FIXME>(
|
|
1492
|
+
fetch<R = FIXME, Q = QueryParams>(
|
|
1499
1493
|
query: string,
|
|
1500
|
-
params:
|
|
1494
|
+
params: Q | undefined,
|
|
1501
1495
|
options: FilteredResponseQueryOptions
|
|
1502
1496
|
): Promise<R>
|
|
1503
1497
|
/**
|
|
@@ -1507,9 +1501,9 @@ export declare class SanityClient {
|
|
|
1507
1501
|
* @param params - Optional query parameters
|
|
1508
1502
|
* @param options - Request options
|
|
1509
1503
|
*/
|
|
1510
|
-
fetch<R = FIXME>(
|
|
1504
|
+
fetch<R = FIXME, Q = QueryParams>(
|
|
1511
1505
|
query: string,
|
|
1512
|
-
params:
|
|
1506
|
+
params: Q | undefined,
|
|
1513
1507
|
options: UnfilteredResponseQueryOptions
|
|
1514
1508
|
): Promise<RawQueryResponse<R>>
|
|
1515
1509
|
/**
|
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.15";
|
|
8
8
|
const middleware = [debug({
|
|
9
9
|
verbose: true,
|
|
10
10
|
namespace: "sanity:client"
|
|
@@ -187,60 +187,50 @@ const requestTag = tag => {
|
|
|
187
187
|
}
|
|
188
188
|
return tag;
|
|
189
189
|
};
|
|
190
|
-
const enc = encodeURIComponent;
|
|
191
190
|
var encodeQueryString = _ref => {
|
|
192
191
|
let {
|
|
193
192
|
query,
|
|
194
193
|
params = {},
|
|
195
194
|
options = {}
|
|
196
195
|
} = _ref;
|
|
196
|
+
const searchParams = new URLSearchParams();
|
|
197
197
|
const {
|
|
198
198
|
tag,
|
|
199
199
|
...opts
|
|
200
200
|
} = options;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
if (tag) searchParams.set("tag", tag);
|
|
202
|
+
searchParams.set("query", query);
|
|
203
|
+
for (const [key, value] of Object.entries(params)) {
|
|
204
|
+
searchParams.set("$".concat(key), JSON.stringify(value));
|
|
205
|
+
}
|
|
206
|
+
for (const [key, value] of Object.entries(opts)) {
|
|
207
|
+
if (value) searchParams.set(key, "".concat(value));
|
|
208
|
+
}
|
|
209
|
+
return "?".concat(searchParams);
|
|
207
210
|
};
|
|
208
|
-
var __accessCheck$
|
|
211
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
209
212
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
210
213
|
};
|
|
211
|
-
var __privateGet$
|
|
212
|
-
__accessCheck$
|
|
214
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
215
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
213
216
|
return getter ? getter.call(obj) : member.get(obj);
|
|
214
217
|
};
|
|
215
|
-
var __privateAdd$
|
|
218
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
216
219
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
217
220
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
218
221
|
};
|
|
219
|
-
var __privateSet$
|
|
220
|
-
__accessCheck$
|
|
222
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
223
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
221
224
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
222
225
|
return value;
|
|
223
226
|
};
|
|
224
|
-
var _client$
|
|
227
|
+
var _client$5, _client2$5;
|
|
225
228
|
class BasePatch {
|
|
226
229
|
constructor(selection) {
|
|
227
230
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
228
231
|
this.selection = selection;
|
|
229
232
|
this.operations = operations;
|
|
230
233
|
}
|
|
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
234
|
/**
|
|
245
235
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
246
236
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
@@ -394,8 +384,8 @@ class BasePatch {
|
|
|
394
384
|
const _ObservablePatch = class extends BasePatch {
|
|
395
385
|
constructor(selection, operations, client) {
|
|
396
386
|
super(selection, operations);
|
|
397
|
-
__privateAdd$
|
|
398
|
-
__privateSet$
|
|
387
|
+
__privateAdd$6(this, _client$5, void 0);
|
|
388
|
+
__privateSet$6(this, _client$5, client);
|
|
399
389
|
}
|
|
400
390
|
/**
|
|
401
391
|
* Clones the patch
|
|
@@ -403,10 +393,10 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
403
393
|
clone() {
|
|
404
394
|
return new _ObservablePatch(this.selection, {
|
|
405
395
|
...this.operations
|
|
406
|
-
}, __privateGet$
|
|
396
|
+
}, __privateGet$6(this, _client$5));
|
|
407
397
|
}
|
|
408
398
|
commit(options) {
|
|
409
|
-
if (!__privateGet$
|
|
399
|
+
if (!__privateGet$6(this, _client$5)) {
|
|
410
400
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
411
401
|
}
|
|
412
402
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -414,18 +404,18 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
414
404
|
returnFirst,
|
|
415
405
|
returnDocuments: true
|
|
416
406
|
}, options);
|
|
417
|
-
return __privateGet$
|
|
407
|
+
return __privateGet$6(this, _client$5).mutate({
|
|
418
408
|
patch: this.serialize()
|
|
419
409
|
}, opts);
|
|
420
410
|
}
|
|
421
411
|
};
|
|
422
412
|
let ObservablePatch = _ObservablePatch;
|
|
423
|
-
_client$
|
|
413
|
+
_client$5 = new WeakMap();
|
|
424
414
|
const _Patch = class extends BasePatch {
|
|
425
415
|
constructor(selection, operations, client) {
|
|
426
416
|
super(selection, operations);
|
|
427
|
-
__privateAdd$
|
|
428
|
-
__privateSet$
|
|
417
|
+
__privateAdd$6(this, _client2$5, void 0);
|
|
418
|
+
__privateSet$6(this, _client2$5, client);
|
|
429
419
|
}
|
|
430
420
|
/**
|
|
431
421
|
* Clones the patch
|
|
@@ -433,10 +423,10 @@ const _Patch = class extends BasePatch {
|
|
|
433
423
|
clone() {
|
|
434
424
|
return new _Patch(this.selection, {
|
|
435
425
|
...this.operations
|
|
436
|
-
}, __privateGet$
|
|
426
|
+
}, __privateGet$6(this, _client2$5));
|
|
437
427
|
}
|
|
438
428
|
commit(options) {
|
|
439
|
-
if (!__privateGet$
|
|
429
|
+
if (!__privateGet$6(this, _client2$5)) {
|
|
440
430
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
441
431
|
}
|
|
442
432
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -444,30 +434,30 @@ const _Patch = class extends BasePatch {
|
|
|
444
434
|
returnFirst,
|
|
445
435
|
returnDocuments: true
|
|
446
436
|
}, options);
|
|
447
|
-
return __privateGet$
|
|
437
|
+
return __privateGet$6(this, _client2$5).mutate({
|
|
448
438
|
patch: this.serialize()
|
|
449
439
|
}, opts);
|
|
450
440
|
}
|
|
451
441
|
};
|
|
452
442
|
let Patch = _Patch;
|
|
453
|
-
_client2$
|
|
454
|
-
var __accessCheck$
|
|
443
|
+
_client2$5 = new WeakMap();
|
|
444
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
455
445
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
456
446
|
};
|
|
457
|
-
var __privateGet$
|
|
458
|
-
__accessCheck$
|
|
447
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
448
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
459
449
|
return getter ? getter.call(obj) : member.get(obj);
|
|
460
450
|
};
|
|
461
|
-
var __privateAdd$
|
|
451
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
462
452
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
463
453
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
464
454
|
};
|
|
465
|
-
var __privateSet$
|
|
466
|
-
__accessCheck$
|
|
455
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
456
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
467
457
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
468
458
|
return value;
|
|
469
459
|
};
|
|
470
|
-
var _client$
|
|
460
|
+
var _client$4, _client2$4;
|
|
471
461
|
const defaultMutateOptions = {
|
|
472
462
|
returnDocuments: false
|
|
473
463
|
};
|
|
@@ -566,20 +556,20 @@ class BaseTransaction {
|
|
|
566
556
|
const _Transaction = class extends BaseTransaction {
|
|
567
557
|
constructor(operations, client, transactionId) {
|
|
568
558
|
super(operations, transactionId);
|
|
569
|
-
__privateAdd$
|
|
570
|
-
__privateSet$
|
|
559
|
+
__privateAdd$5(this, _client$4, void 0);
|
|
560
|
+
__privateSet$5(this, _client$4, client);
|
|
571
561
|
}
|
|
572
562
|
/**
|
|
573
563
|
* Clones the transaction
|
|
574
564
|
*/
|
|
575
565
|
clone() {
|
|
576
|
-
return new _Transaction([...this.operations], __privateGet$
|
|
566
|
+
return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
|
|
577
567
|
}
|
|
578
568
|
commit(options) {
|
|
579
|
-
if (!__privateGet$
|
|
569
|
+
if (!__privateGet$5(this, _client$4)) {
|
|
580
570
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
581
571
|
}
|
|
582
|
-
return __privateGet$
|
|
572
|
+
return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
|
|
583
573
|
transactionId: this.trxId
|
|
584
574
|
}, defaultMutateOptions, options || {}));
|
|
585
575
|
}
|
|
@@ -592,7 +582,7 @@ const _Transaction = class extends BaseTransaction {
|
|
|
592
582
|
});
|
|
593
583
|
}
|
|
594
584
|
if (isBuilder) {
|
|
595
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$
|
|
585
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
|
|
596
586
|
if (!(patch instanceof Patch)) {
|
|
597
587
|
throw new Error("function passed to `patch()` must return the patch");
|
|
598
588
|
}
|
|
@@ -609,24 +599,24 @@ const _Transaction = class extends BaseTransaction {
|
|
|
609
599
|
}
|
|
610
600
|
};
|
|
611
601
|
let Transaction = _Transaction;
|
|
612
|
-
_client$
|
|
602
|
+
_client$4 = new WeakMap();
|
|
613
603
|
const _ObservableTransaction = class extends BaseTransaction {
|
|
614
604
|
constructor(operations, client, transactionId) {
|
|
615
605
|
super(operations, transactionId);
|
|
616
|
-
__privateAdd$
|
|
617
|
-
__privateSet$
|
|
606
|
+
__privateAdd$5(this, _client2$4, void 0);
|
|
607
|
+
__privateSet$5(this, _client2$4, client);
|
|
618
608
|
}
|
|
619
609
|
/**
|
|
620
610
|
* Clones the transaction
|
|
621
611
|
*/
|
|
622
612
|
clone() {
|
|
623
|
-
return new _ObservableTransaction([...this.operations], __privateGet$
|
|
613
|
+
return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
|
|
624
614
|
}
|
|
625
615
|
commit(options) {
|
|
626
|
-
if (!__privateGet$
|
|
616
|
+
if (!__privateGet$5(this, _client2$4)) {
|
|
627
617
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
628
618
|
}
|
|
629
|
-
return __privateGet$
|
|
619
|
+
return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
|
|
630
620
|
transactionId: this.trxId
|
|
631
621
|
}, defaultMutateOptions, options || {}));
|
|
632
622
|
}
|
|
@@ -639,7 +629,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
639
629
|
});
|
|
640
630
|
}
|
|
641
631
|
if (isBuilder) {
|
|
642
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$
|
|
632
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
|
|
643
633
|
if (!(patch instanceof ObservablePatch)) {
|
|
644
634
|
throw new Error("function passed to `patch()` must return the patch");
|
|
645
635
|
}
|
|
@@ -656,7 +646,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
656
646
|
}
|
|
657
647
|
};
|
|
658
648
|
let ObservableTransaction = _ObservableTransaction;
|
|
659
|
-
_client2$
|
|
649
|
+
_client2$4 = new WeakMap();
|
|
660
650
|
const excludeFalsey = (param, defValue) => {
|
|
661
651
|
const value = typeof param === "undefined" ? defValue : param;
|
|
662
652
|
return param === false ? void 0 : value;
|
|
@@ -828,50 +818,50 @@ function _getUrl(client, uri) {
|
|
|
828
818
|
const base = canUseCdn ? cdnUrl : url;
|
|
829
819
|
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
830
820
|
}
|
|
831
|
-
var __accessCheck$
|
|
821
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
832
822
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
833
823
|
};
|
|
834
|
-
var __privateGet$
|
|
835
|
-
__accessCheck$
|
|
824
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
825
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
836
826
|
return getter ? getter.call(obj) : member.get(obj);
|
|
837
827
|
};
|
|
838
|
-
var __privateAdd$
|
|
828
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
839
829
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
840
830
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
841
831
|
};
|
|
842
|
-
var __privateSet$
|
|
843
|
-
__accessCheck$
|
|
832
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
833
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
844
834
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
845
835
|
return value;
|
|
846
836
|
};
|
|
847
|
-
var _client$
|
|
837
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
848
838
|
class ObservableAssetsClient {
|
|
849
839
|
constructor(client, httpRequest) {
|
|
850
|
-
__privateAdd$
|
|
851
|
-
__privateAdd$
|
|
852
|
-
__privateSet$
|
|
853
|
-
__privateSet$
|
|
840
|
+
__privateAdd$4(this, _client$3, void 0);
|
|
841
|
+
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
842
|
+
__privateSet$4(this, _client$3, client);
|
|
843
|
+
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
854
844
|
}
|
|
855
845
|
upload(assetType, body, options) {
|
|
856
|
-
return _upload(__privateGet$
|
|
846
|
+
return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
|
|
857
847
|
}
|
|
858
848
|
}
|
|
859
|
-
_client$
|
|
860
|
-
_httpRequest$
|
|
849
|
+
_client$3 = new WeakMap();
|
|
850
|
+
_httpRequest$4 = new WeakMap();
|
|
861
851
|
class AssetsClient {
|
|
862
852
|
constructor(client, httpRequest) {
|
|
863
|
-
__privateAdd$
|
|
864
|
-
__privateAdd$
|
|
865
|
-
__privateSet$
|
|
866
|
-
__privateSet$
|
|
853
|
+
__privateAdd$4(this, _client2$3, void 0);
|
|
854
|
+
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
855
|
+
__privateSet$4(this, _client2$3, client);
|
|
856
|
+
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
867
857
|
}
|
|
868
858
|
upload(assetType, body, options) {
|
|
869
|
-
const observable = _upload(__privateGet$
|
|
859
|
+
const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
|
|
870
860
|
return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
|
|
871
861
|
}
|
|
872
862
|
}
|
|
873
|
-
_client2$
|
|
874
|
-
_httpRequest2$
|
|
863
|
+
_client2$3 = new WeakMap();
|
|
864
|
+
_httpRequest2$4 = new WeakMap();
|
|
875
865
|
function _upload(client, httpRequest, assetType, body) {
|
|
876
866
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
877
867
|
validateAssetType(assetType);
|
|
@@ -925,77 +915,6 @@ function optionsFromFile(opts, file) {
|
|
|
925
915
|
contentType: file.type
|
|
926
916
|
}, opts);
|
|
927
917
|
}
|
|
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
918
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
1000
919
|
function generateHelpUrl(slug) {
|
|
1001
920
|
return BASE_URL + slug;
|
|
@@ -1498,10 +1417,13 @@ const _ObservableSanityClient = class {
|
|
|
1498
1417
|
*/
|
|
1499
1418
|
__privateAdd(this, _clientConfig, void 0);
|
|
1500
1419
|
__privateAdd(this, _httpRequest, void 0);
|
|
1420
|
+
/**
|
|
1421
|
+
* Instance properties
|
|
1422
|
+
*/
|
|
1423
|
+
this.listen = _listen;
|
|
1501
1424
|
this.config(config);
|
|
1502
1425
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1503
1426
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
1504
|
-
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
1505
1427
|
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
1506
1428
|
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
1507
1429
|
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
@@ -1620,7 +1542,6 @@ const _SanityClient = class {
|
|
|
1620
1542
|
this.config(config);
|
|
1621
1543
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1622
1544
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
1623
|
-
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
1624
1545
|
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
1625
1546
|
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
1626
1547
|
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|