@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/README.md
CHANGED
|
@@ -98,7 +98,7 @@ export async function updateDocumentTitle(_id, title) {
|
|
|
98
98
|
|
|
99
99
|
Sanity Client transpiles syntax for [modern browsers]. The JavaScript runtime must support ES6 features such as [class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters), [spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) and more. Most modern web frameworks, [browsers][modern browsers], and developer tooling supports ES6 today.
|
|
100
100
|
|
|
101
|
-
For legacy ES5 environments
|
|
101
|
+
[For legacy ES5 environments we recommend v4.](https://github.com/sanity-io/client/tree/v4.0.0#sanityclient)
|
|
102
102
|
|
|
103
103
|
## Installation
|
|
104
104
|
|
|
@@ -1157,6 +1157,65 @@ client.createIfNotExists(doc, options)
|
|
|
1157
1157
|
client.createOrReplace(doc, options)
|
|
1158
1158
|
```
|
|
1159
1159
|
|
|
1160
|
+
### `client.patch.replace` is removed, replace with `client.createOrReplace`<!-- omit in toc -->
|
|
1161
|
+
|
|
1162
|
+
Before:
|
|
1163
|
+
|
|
1164
|
+
```ts
|
|
1165
|
+
import createClient from '@sanity/client'
|
|
1166
|
+
const client = createClient()
|
|
1167
|
+
|
|
1168
|
+
client.patch('tropic-hab').replace({name: 'Tropical Habanero', ingredients: []}).commit()
|
|
1169
|
+
```
|
|
1170
|
+
|
|
1171
|
+
After:
|
|
1172
|
+
|
|
1173
|
+
```ts
|
|
1174
|
+
import {createClient} from '@sanity/client'
|
|
1175
|
+
const client = createClient()
|
|
1176
|
+
|
|
1177
|
+
client.createOrReplace({
|
|
1178
|
+
_id: 'tropic-hab',
|
|
1179
|
+
_type: 'hotsauce',
|
|
1180
|
+
name: 'Tropical Habanero',
|
|
1181
|
+
ingredients: [],
|
|
1182
|
+
})
|
|
1183
|
+
```
|
|
1184
|
+
|
|
1185
|
+
### `client.auth` is removed, replace with `client.request`<!-- omit in toc -->
|
|
1186
|
+
|
|
1187
|
+
Before:
|
|
1188
|
+
|
|
1189
|
+
```ts
|
|
1190
|
+
import createClient from '@sanity/client'
|
|
1191
|
+
const client = createClient()
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Fetch available login providers
|
|
1195
|
+
*/
|
|
1196
|
+
const loginProviders = await client.auth.getLoginProviders()
|
|
1197
|
+
/**
|
|
1198
|
+
* Revoke the configured session/token
|
|
1199
|
+
*/
|
|
1200
|
+
await client.auth.logout()
|
|
1201
|
+
```
|
|
1202
|
+
|
|
1203
|
+
After:
|
|
1204
|
+
|
|
1205
|
+
```ts
|
|
1206
|
+
import {createclient, type AuthProviderResponse} from '@sanity/client'
|
|
1207
|
+
const client = createClient()
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Fetch available login providers
|
|
1211
|
+
*/
|
|
1212
|
+
const loginProviders = await client.request<AuthProviderResponse>({uri: '/auth/providers'})
|
|
1213
|
+
/**
|
|
1214
|
+
* Revoke the configured session/token
|
|
1215
|
+
*/
|
|
1216
|
+
await client.request<void>({uri: '/auth/logout', method: 'POST'})
|
|
1217
|
+
```
|
|
1218
|
+
|
|
1160
1219
|
[modern browsers]: https://browsersl.ist/#q=%3E+0.2%25+and+supports+es6-module+and+supports+es6-module-dynamic-import+and+not+dead+and+not+IE+11
|
|
1161
1220
|
[Deno]: https://deno.land/
|
|
1162
1221
|
[Edge Runtime]: https://edge-runtime.vercel.sh/
|
package/dist/index.browser.cjs
CHANGED
|
@@ -189,60 +189,50 @@ const requestTag = tag => {
|
|
|
189
189
|
}
|
|
190
190
|
return tag;
|
|
191
191
|
};
|
|
192
|
-
const enc = encodeURIComponent;
|
|
193
192
|
var encodeQueryString = _ref => {
|
|
194
193
|
let {
|
|
195
194
|
query,
|
|
196
195
|
params = {},
|
|
197
196
|
options = {}
|
|
198
197
|
} = _ref;
|
|
198
|
+
const searchParams = new URLSearchParams();
|
|
199
199
|
const {
|
|
200
200
|
tag,
|
|
201
201
|
...opts
|
|
202
202
|
} = options;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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);
|
|
209
212
|
};
|
|
210
|
-
var __accessCheck$
|
|
213
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
211
214
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
212
215
|
};
|
|
213
|
-
var __privateGet$
|
|
214
|
-
__accessCheck$
|
|
216
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
217
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
215
218
|
return getter ? getter.call(obj) : member.get(obj);
|
|
216
219
|
};
|
|
217
|
-
var __privateAdd$
|
|
220
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
218
221
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
219
222
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
220
223
|
};
|
|
221
|
-
var __privateSet$
|
|
222
|
-
__accessCheck$
|
|
224
|
+
var __privateSet$6 = (obj, member, value, setter) => {
|
|
225
|
+
__accessCheck$6(obj, member, "write to private field");
|
|
223
226
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
224
227
|
return value;
|
|
225
228
|
};
|
|
226
|
-
var _client$
|
|
229
|
+
var _client$5, _client2$5;
|
|
227
230
|
class BasePatch {
|
|
228
231
|
constructor(selection) {
|
|
229
232
|
let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
230
233
|
this.selection = selection;
|
|
231
234
|
this.operations = operations;
|
|
232
235
|
}
|
|
233
|
-
/**
|
|
234
|
-
* DEPRECATED: Don't use.
|
|
235
|
-
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
236
|
-
*
|
|
237
|
-
* @deprecated - Don't use.
|
|
238
|
-
* @param attrs - Attributes to replace
|
|
239
|
-
*/
|
|
240
|
-
replace(attrs) {
|
|
241
|
-
validateObject("replace", attrs);
|
|
242
|
-
return this._set("set", {
|
|
243
|
-
$: attrs
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
236
|
/**
|
|
247
237
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
248
238
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
@@ -396,8 +386,8 @@ class BasePatch {
|
|
|
396
386
|
const _ObservablePatch = class extends BasePatch {
|
|
397
387
|
constructor(selection, operations, client) {
|
|
398
388
|
super(selection, operations);
|
|
399
|
-
__privateAdd$
|
|
400
|
-
__privateSet$
|
|
389
|
+
__privateAdd$6(this, _client$5, void 0);
|
|
390
|
+
__privateSet$6(this, _client$5, client);
|
|
401
391
|
}
|
|
402
392
|
/**
|
|
403
393
|
* Clones the patch
|
|
@@ -405,10 +395,10 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
405
395
|
clone() {
|
|
406
396
|
return new _ObservablePatch(this.selection, {
|
|
407
397
|
...this.operations
|
|
408
|
-
}, __privateGet$
|
|
398
|
+
}, __privateGet$6(this, _client$5));
|
|
409
399
|
}
|
|
410
400
|
commit(options) {
|
|
411
|
-
if (!__privateGet$
|
|
401
|
+
if (!__privateGet$6(this, _client$5)) {
|
|
412
402
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
413
403
|
}
|
|
414
404
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -416,18 +406,18 @@ const _ObservablePatch = class extends BasePatch {
|
|
|
416
406
|
returnFirst,
|
|
417
407
|
returnDocuments: true
|
|
418
408
|
}, options);
|
|
419
|
-
return __privateGet$
|
|
409
|
+
return __privateGet$6(this, _client$5).mutate({
|
|
420
410
|
patch: this.serialize()
|
|
421
411
|
}, opts);
|
|
422
412
|
}
|
|
423
413
|
};
|
|
424
414
|
let ObservablePatch = _ObservablePatch;
|
|
425
|
-
_client$
|
|
415
|
+
_client$5 = new WeakMap();
|
|
426
416
|
const _Patch = class extends BasePatch {
|
|
427
417
|
constructor(selection, operations, client) {
|
|
428
418
|
super(selection, operations);
|
|
429
|
-
__privateAdd$
|
|
430
|
-
__privateSet$
|
|
419
|
+
__privateAdd$6(this, _client2$5, void 0);
|
|
420
|
+
__privateSet$6(this, _client2$5, client);
|
|
431
421
|
}
|
|
432
422
|
/**
|
|
433
423
|
* Clones the patch
|
|
@@ -435,10 +425,10 @@ const _Patch = class extends BasePatch {
|
|
|
435
425
|
clone() {
|
|
436
426
|
return new _Patch(this.selection, {
|
|
437
427
|
...this.operations
|
|
438
|
-
}, __privateGet$
|
|
428
|
+
}, __privateGet$6(this, _client2$5));
|
|
439
429
|
}
|
|
440
430
|
commit(options) {
|
|
441
|
-
if (!__privateGet$
|
|
431
|
+
if (!__privateGet$6(this, _client2$5)) {
|
|
442
432
|
throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
|
|
443
433
|
}
|
|
444
434
|
const returnFirst = typeof this.selection === "string";
|
|
@@ -446,30 +436,30 @@ const _Patch = class extends BasePatch {
|
|
|
446
436
|
returnFirst,
|
|
447
437
|
returnDocuments: true
|
|
448
438
|
}, options);
|
|
449
|
-
return __privateGet$
|
|
439
|
+
return __privateGet$6(this, _client2$5).mutate({
|
|
450
440
|
patch: this.serialize()
|
|
451
441
|
}, opts);
|
|
452
442
|
}
|
|
453
443
|
};
|
|
454
444
|
let Patch = _Patch;
|
|
455
|
-
_client2$
|
|
456
|
-
var __accessCheck$
|
|
445
|
+
_client2$5 = new WeakMap();
|
|
446
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
457
447
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
458
448
|
};
|
|
459
|
-
var __privateGet$
|
|
460
|
-
__accessCheck$
|
|
449
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
450
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
461
451
|
return getter ? getter.call(obj) : member.get(obj);
|
|
462
452
|
};
|
|
463
|
-
var __privateAdd$
|
|
453
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
464
454
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
465
455
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
466
456
|
};
|
|
467
|
-
var __privateSet$
|
|
468
|
-
__accessCheck$
|
|
457
|
+
var __privateSet$5 = (obj, member, value, setter) => {
|
|
458
|
+
__accessCheck$5(obj, member, "write to private field");
|
|
469
459
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
470
460
|
return value;
|
|
471
461
|
};
|
|
472
|
-
var _client$
|
|
462
|
+
var _client$4, _client2$4;
|
|
473
463
|
const defaultMutateOptions = {
|
|
474
464
|
returnDocuments: false
|
|
475
465
|
};
|
|
@@ -568,20 +558,20 @@ class BaseTransaction {
|
|
|
568
558
|
const _Transaction = class extends BaseTransaction {
|
|
569
559
|
constructor(operations, client, transactionId) {
|
|
570
560
|
super(operations, transactionId);
|
|
571
|
-
__privateAdd$
|
|
572
|
-
__privateSet$
|
|
561
|
+
__privateAdd$5(this, _client$4, void 0);
|
|
562
|
+
__privateSet$5(this, _client$4, client);
|
|
573
563
|
}
|
|
574
564
|
/**
|
|
575
565
|
* Clones the transaction
|
|
576
566
|
*/
|
|
577
567
|
clone() {
|
|
578
|
-
return new _Transaction([...this.operations], __privateGet$
|
|
568
|
+
return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
|
|
579
569
|
}
|
|
580
570
|
commit(options) {
|
|
581
|
-
if (!__privateGet$
|
|
571
|
+
if (!__privateGet$5(this, _client$4)) {
|
|
582
572
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
583
573
|
}
|
|
584
|
-
return __privateGet$
|
|
574
|
+
return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
|
|
585
575
|
transactionId: this.trxId
|
|
586
576
|
}, defaultMutateOptions, options || {}));
|
|
587
577
|
}
|
|
@@ -594,7 +584,7 @@ const _Transaction = class extends BaseTransaction {
|
|
|
594
584
|
});
|
|
595
585
|
}
|
|
596
586
|
if (isBuilder) {
|
|
597
|
-
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$
|
|
587
|
+
const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
|
|
598
588
|
if (!(patch instanceof Patch)) {
|
|
599
589
|
throw new Error("function passed to `patch()` must return the patch");
|
|
600
590
|
}
|
|
@@ -611,24 +601,24 @@ const _Transaction = class extends BaseTransaction {
|
|
|
611
601
|
}
|
|
612
602
|
};
|
|
613
603
|
let Transaction = _Transaction;
|
|
614
|
-
_client$
|
|
604
|
+
_client$4 = new WeakMap();
|
|
615
605
|
const _ObservableTransaction = class extends BaseTransaction {
|
|
616
606
|
constructor(operations, client, transactionId) {
|
|
617
607
|
super(operations, transactionId);
|
|
618
|
-
__privateAdd$
|
|
619
|
-
__privateSet$
|
|
608
|
+
__privateAdd$5(this, _client2$4, void 0);
|
|
609
|
+
__privateSet$5(this, _client2$4, client);
|
|
620
610
|
}
|
|
621
611
|
/**
|
|
622
612
|
* Clones the transaction
|
|
623
613
|
*/
|
|
624
614
|
clone() {
|
|
625
|
-
return new _ObservableTransaction([...this.operations], __privateGet$
|
|
615
|
+
return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
|
|
626
616
|
}
|
|
627
617
|
commit(options) {
|
|
628
|
-
if (!__privateGet$
|
|
618
|
+
if (!__privateGet$5(this, _client2$4)) {
|
|
629
619
|
throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
|
|
630
620
|
}
|
|
631
|
-
return __privateGet$
|
|
621
|
+
return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
|
|
632
622
|
transactionId: this.trxId
|
|
633
623
|
}, defaultMutateOptions, options || {}));
|
|
634
624
|
}
|
|
@@ -641,7 +631,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
641
631
|
});
|
|
642
632
|
}
|
|
643
633
|
if (isBuilder) {
|
|
644
|
-
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$
|
|
634
|
+
const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
|
|
645
635
|
if (!(patch instanceof ObservablePatch)) {
|
|
646
636
|
throw new Error("function passed to `patch()` must return the patch");
|
|
647
637
|
}
|
|
@@ -658,7 +648,7 @@ const _ObservableTransaction = class extends BaseTransaction {
|
|
|
658
648
|
}
|
|
659
649
|
};
|
|
660
650
|
let ObservableTransaction = _ObservableTransaction;
|
|
661
|
-
_client2$
|
|
651
|
+
_client2$4 = new WeakMap();
|
|
662
652
|
const excludeFalsey = (param, defValue) => {
|
|
663
653
|
const value = typeof param === "undefined" ? defValue : param;
|
|
664
654
|
return param === false ? void 0 : value;
|
|
@@ -830,50 +820,50 @@ function _getUrl(client, uri) {
|
|
|
830
820
|
const base = canUseCdn ? cdnUrl : url;
|
|
831
821
|
return "".concat(base, "/").concat(uri.replace(/^\//, ""));
|
|
832
822
|
}
|
|
833
|
-
var __accessCheck$
|
|
823
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
834
824
|
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
835
825
|
};
|
|
836
|
-
var __privateGet$
|
|
837
|
-
__accessCheck$
|
|
826
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
827
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
838
828
|
return getter ? getter.call(obj) : member.get(obj);
|
|
839
829
|
};
|
|
840
|
-
var __privateAdd$
|
|
830
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
841
831
|
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
842
832
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
843
833
|
};
|
|
844
|
-
var __privateSet$
|
|
845
|
-
__accessCheck$
|
|
834
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
835
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
846
836
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
847
837
|
return value;
|
|
848
838
|
};
|
|
849
|
-
var _client$
|
|
839
|
+
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
850
840
|
class ObservableAssetsClient {
|
|
851
841
|
constructor(client, httpRequest) {
|
|
852
|
-
__privateAdd$
|
|
853
|
-
__privateAdd$
|
|
854
|
-
__privateSet$
|
|
855
|
-
__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);
|
|
856
846
|
}
|
|
857
847
|
upload(assetType, body, options) {
|
|
858
|
-
return _upload(__privateGet$
|
|
848
|
+
return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
|
|
859
849
|
}
|
|
860
850
|
}
|
|
861
|
-
_client$
|
|
862
|
-
_httpRequest$
|
|
851
|
+
_client$3 = new WeakMap();
|
|
852
|
+
_httpRequest$4 = new WeakMap();
|
|
863
853
|
class AssetsClient {
|
|
864
854
|
constructor(client, httpRequest) {
|
|
865
|
-
__privateAdd$
|
|
866
|
-
__privateAdd$
|
|
867
|
-
__privateSet$
|
|
868
|
-
__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);
|
|
869
859
|
}
|
|
870
860
|
upload(assetType, body, options) {
|
|
871
|
-
const observable = _upload(__privateGet$
|
|
861
|
+
const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
|
|
872
862
|
return rxjs.lastValueFrom(observable.pipe(operators.filter(event => event.type === "response"), operators.map(event => event.body.document)));
|
|
873
863
|
}
|
|
874
864
|
}
|
|
875
|
-
_client2$
|
|
876
|
-
_httpRequest2$
|
|
865
|
+
_client2$3 = new WeakMap();
|
|
866
|
+
_httpRequest2$4 = new WeakMap();
|
|
877
867
|
function _upload(client, httpRequest, assetType, body) {
|
|
878
868
|
let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
879
869
|
validateAssetType(assetType);
|
|
@@ -927,77 +917,6 @@ function optionsFromFile(opts, file) {
|
|
|
927
917
|
contentType: file.type
|
|
928
918
|
}, opts);
|
|
929
919
|
}
|
|
930
|
-
var __accessCheck$4 = (obj, member, msg) => {
|
|
931
|
-
if (!member.has(obj)) throw TypeError("Cannot " + msg);
|
|
932
|
-
};
|
|
933
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
934
|
-
__accessCheck$4(obj, member, "read from private field");
|
|
935
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
936
|
-
};
|
|
937
|
-
var __privateAdd$4 = (obj, member, value) => {
|
|
938
|
-
if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
|
|
939
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
940
|
-
};
|
|
941
|
-
var __privateSet$4 = (obj, member, value, setter) => {
|
|
942
|
-
__accessCheck$4(obj, member, "write to private field");
|
|
943
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
944
|
-
return value;
|
|
945
|
-
};
|
|
946
|
-
var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
|
|
947
|
-
class ObservableAuthClient {
|
|
948
|
-
constructor(client, httpRequest) {
|
|
949
|
-
__privateAdd$4(this, _client$3, void 0);
|
|
950
|
-
__privateAdd$4(this, _httpRequest$4, void 0);
|
|
951
|
-
__privateSet$4(this, _client$3, client);
|
|
952
|
-
__privateSet$4(this, _httpRequest$4, httpRequest);
|
|
953
|
-
}
|
|
954
|
-
/**
|
|
955
|
-
* Fetch available login providers
|
|
956
|
-
*/
|
|
957
|
-
getLoginProviders() {
|
|
958
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
959
|
-
uri: "/auth/providers"
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
/**
|
|
963
|
-
* Revoke the configured session/token
|
|
964
|
-
*/
|
|
965
|
-
logout() {
|
|
966
|
-
return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
|
|
967
|
-
uri: "/auth/logout",
|
|
968
|
-
method: "POST"
|
|
969
|
-
});
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
_client$3 = new WeakMap();
|
|
973
|
-
_httpRequest$4 = new WeakMap();
|
|
974
|
-
class AuthClient {
|
|
975
|
-
constructor(client, httpRequest) {
|
|
976
|
-
__privateAdd$4(this, _client2$3, void 0);
|
|
977
|
-
__privateAdd$4(this, _httpRequest2$4, void 0);
|
|
978
|
-
__privateSet$4(this, _client2$3, client);
|
|
979
|
-
__privateSet$4(this, _httpRequest2$4, httpRequest);
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* Fetch available login providers
|
|
983
|
-
*/
|
|
984
|
-
getLoginProviders() {
|
|
985
|
-
return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
986
|
-
uri: "/auth/providers"
|
|
987
|
-
}));
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* Revoke the configured session/token
|
|
991
|
-
*/
|
|
992
|
-
logout() {
|
|
993
|
-
return rxjs.lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
|
|
994
|
-
uri: "/auth/logout",
|
|
995
|
-
method: "POST"
|
|
996
|
-
}));
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
_client2$3 = new WeakMap();
|
|
1000
|
-
_httpRequest2$4 = new WeakMap();
|
|
1001
920
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
1002
921
|
function generateHelpUrl(slug) {
|
|
1003
922
|
return BASE_URL + slug;
|
|
@@ -1500,10 +1419,13 @@ const _ObservableSanityClient = class {
|
|
|
1500
1419
|
*/
|
|
1501
1420
|
__privateAdd(this, _clientConfig, void 0);
|
|
1502
1421
|
__privateAdd(this, _httpRequest, void 0);
|
|
1422
|
+
/**
|
|
1423
|
+
* Instance properties
|
|
1424
|
+
*/
|
|
1425
|
+
this.listen = _listen;
|
|
1503
1426
|
this.config(config);
|
|
1504
1427
|
__privateSet(this, _httpRequest, httpRequest);
|
|
1505
1428
|
this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
|
|
1506
|
-
this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
|
|
1507
1429
|
this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
|
|
1508
1430
|
this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
|
|
1509
1431
|
this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
@@ -1622,7 +1544,6 @@ const _SanityClient = class {
|
|
|
1622
1544
|
this.config(config);
|
|
1623
1545
|
__privateSet(this, _httpRequest2, httpRequest);
|
|
1624
1546
|
this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
|
|
1625
|
-
this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
|
|
1626
1547
|
this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
|
|
1627
1548
|
this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
|
|
1628
1549
|
this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
|