@sanity/client 5.0.0-esm.0 → 5.0.0-esm.2

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/dist/index.d.ts CHANGED
@@ -56,9 +56,17 @@ export declare type AttributeSet = {
56
56
  [key: string]: any
57
57
  }
58
58
 
59
- export declare class AuthClient extends BaseAuthClient {
60
- client: SanityClient
61
- constructor(client: SanityClient)
59
+ export declare class AuthClient {
60
+ #private
61
+ constructor(client: SanityClient, httpRequest: HttpRequest)
62
+ /**
63
+ * Fetch available login providers
64
+ */
65
+ getLoginProviders<R = AuthProviderResponse>(): Promise<R>
66
+ /**
67
+ * Revoke the configured session/token
68
+ */
69
+ logout<R = any>(): Promise<R>
62
70
  }
63
71
 
64
72
  export declare interface AuthProvider {
@@ -71,20 +79,6 @@ export declare type AuthProviderResponse = {
71
79
  providers: AuthProvider[]
72
80
  }
73
81
 
74
- export declare class BaseAuthClient {
75
- client: SanityClient | ObservableSanityClient
76
- /**
77
- * Fetch available login providers
78
- */
79
- getLoginProviders(this: AuthClient): Promise<AuthProviderResponse>
80
- getLoginProviders(this: ObservableAuthClient): Observable<AuthProviderResponse>
81
- /**
82
- * Revoke the configured session/token
83
- */
84
- logout(this: AuthClient): Promise<any>
85
- logout(this: ObservableAuthClient): Observable<any>
86
- }
87
-
88
82
  export declare class BaseDatasetsClient {
89
83
  #private
90
84
  client: SanityClient | ObservableSanityClient
@@ -282,35 +276,6 @@ export declare class BaseProjectsClient {
282
276
  getById(this: ObservableProjectsClient, projectId: string): Observable<SanityProject>
283
277
  }
284
278
 
285
- export declare class BaseSanityClient {
286
- #private
287
- constructor(config: ClientConfig)
288
- /** @internal */
289
- protected config(newConfig?: Partial<ClientConfig>): ClientConfig | this
290
- /**
291
- * Returns whether or not this client is using the Promise API (otherwise it is using observables)
292
- * @internal
293
- * @deprecated Internals, should not be used externally
294
- */
295
- isPromiseAPI(): this is SanityClient
296
- /**
297
- * DEPRECATED: Get a Sanity API URL for the URI provided
298
- *
299
- * @deprecated Should be an internal concern
300
- * @param uri URI/path to build URL for
301
- * @param canUseCdn Whether or not to allow using the API CDN for this route
302
- */
303
- getUrl(uri: string, canUseCdn?: boolean): string
304
- /**
305
- * DEPRECATED: Get a Sanity API URL for the data operation and path provided
306
- *
307
- * @deprecated Should be an internal concern
308
- * @param operation Data operation
309
- * @param path Path to append
310
- */
311
- getDataUrl(operation: string, path?: string): string
312
- }
313
-
314
279
  export declare class BaseTransaction {
315
280
  protected operations: Mutation[]
316
281
  protected trxId?: string
@@ -669,9 +634,17 @@ export declare class ObservableAssetsClient {
669
634
  >
670
635
  }
671
636
 
672
- export declare class ObservableAuthClient extends BaseAuthClient {
673
- client: ObservableSanityClient
674
- constructor(client: ObservableSanityClient)
637
+ export declare class ObservableAuthClient {
638
+ #private
639
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
640
+ /**
641
+ * Fetch available login providers
642
+ */
643
+ getLoginProviders<R = AuthProviderResponse>(): Observable<R>
644
+ /**
645
+ * Revoke the configured session/token
646
+ */
647
+ logout<R = any>(): Observable<R>
675
648
  }
676
649
 
677
650
  export declare class ObservableDatasetsClient extends BaseDatasetsClient {
@@ -735,7 +708,7 @@ export declare class ObservableProjectsClient extends BaseProjectsClient {
735
708
  constructor(client: ObservableSanityClient)
736
709
  }
737
710
 
738
- export declare class ObservableSanityClient extends BaseSanityClient {
711
+ export declare class ObservableSanityClient {
739
712
  #private
740
713
  assets: ObservableAssetsClient
741
714
  auth: ObservableAuthClient
@@ -1171,6 +1144,22 @@ export declare class ObservableSanityClient extends BaseSanityClient {
1171
1144
  * @param options Request options
1172
1145
  */
1173
1146
  request<R = any>(options: RawRequestOptions): Observable<R>
1147
+ /**
1148
+ * DEPRECATED: Get a Sanity API URL for the URI provided
1149
+ *
1150
+ * @deprecated Should be an internal concern
1151
+ * @param uri URI/path to build URL for
1152
+ * @param canUseCdn Whether or not to allow using the API CDN for this route
1153
+ */
1154
+ getUrl(uri: string, canUseCdn?: boolean): string
1155
+ /**
1156
+ * DEPRECATED: Get a Sanity API URL for the data operation and path provided
1157
+ *
1158
+ * @deprecated Should be an internal concern
1159
+ * @param operation Data operation
1160
+ * @param path Path to append
1161
+ */
1162
+ getDataUrl(operation: string, path?: string): string
1174
1163
  }
1175
1164
 
1176
1165
  export declare class ObservableTransaction extends BaseTransaction {
@@ -1399,7 +1388,7 @@ export declare interface SanityAssetDocument extends SanityDocument {
1399
1388
  originalFilename?: string
1400
1389
  }
1401
1390
 
1402
- export declare class SanityClient extends BaseSanityClient {
1391
+ export declare class SanityClient {
1403
1392
  #private
1404
1393
  assets: AssetsClient
1405
1394
  auth: AuthClient
@@ -1852,6 +1841,22 @@ export declare class SanityClient extends BaseSanityClient {
1852
1841
  * @param options Request options
1853
1842
  */
1854
1843
  dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<any>
1844
+ /**
1845
+ * DEPRECATED: Get a Sanity API URL for the URI provided
1846
+ *
1847
+ * @deprecated Should be an internal concern
1848
+ * @param uri URI/path to build URL for
1849
+ * @param canUseCdn Whether or not to allow using the API CDN for this route
1850
+ */
1851
+ getUrl(uri: string, canUseCdn?: boolean): string
1852
+ /**
1853
+ * DEPRECATED: Get a Sanity API URL for the data operation and path provided
1854
+ *
1855
+ * @deprecated Should be an internal concern
1856
+ * @param operation Data operation
1857
+ * @param path Path to append
1858
+ */
1859
+ getDataUrl(operation: string, path?: string): string
1855
1860
  }
1856
1861
 
1857
1862
  export declare type SanityDocument<T extends Record<string, any> = Record<string, any>> = {
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { BaseError } from 'make-error';
5
5
  import { map, filter } from 'rxjs/operators';
6
6
  import polyfilledEventSource from '@sanity/eventsource';
7
7
  var name = "@sanity/client";
8
- var version = "5.0.0-esm.0";
8
+ var version = "5.0.0-esm.2";
9
9
  const middleware = [debug({
10
10
  verbose: true,
11
11
  namespace: "sanity:client"
@@ -206,23 +206,23 @@ var encodeQueryString = _ref => {
206
206
  return options[option] ? "".concat(qs, "&").concat(enc(option), "=").concat(enc(options[option])) : qs;
207
207
  }, qString);
208
208
  };
209
- var __accessCheck$4 = (obj, member, msg) => {
209
+ var __accessCheck$5 = (obj, member, msg) => {
210
210
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
211
211
  };
212
- var __privateGet$3 = (obj, member, getter) => {
213
- __accessCheck$4(obj, member, "read from private field");
212
+ var __privateGet$4 = (obj, member, getter) => {
213
+ __accessCheck$5(obj, member, "read from private field");
214
214
  return getter ? getter.call(obj) : member.get(obj);
215
215
  };
216
- var __privateAdd$4 = (obj, member, value) => {
216
+ var __privateAdd$5 = (obj, member, value) => {
217
217
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
218
218
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
219
219
  };
220
- var __privateSet$3 = (obj, member, value, setter) => {
221
- __accessCheck$4(obj, member, "write to private field");
220
+ var __privateSet$4 = (obj, member, value, setter) => {
221
+ __accessCheck$5(obj, member, "write to private field");
222
222
  setter ? setter.call(obj, value) : member.set(obj, value);
223
223
  return value;
224
224
  };
225
- var _client$2, _client2$2;
225
+ var _client$3, _client2$3;
226
226
  class BasePatch {
227
227
  constructor(selection) {
228
228
  let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -313,16 +313,16 @@ class BasePatch {
313
313
  const _ObservablePatch = class extends BasePatch {
314
314
  constructor(selection, operations, client) {
315
315
  super(selection, operations);
316
- __privateAdd$4(this, _client$2, void 0);
317
- __privateSet$3(this, _client$2, client);
316
+ __privateAdd$5(this, _client$3, void 0);
317
+ __privateSet$4(this, _client$3, client);
318
318
  }
319
319
  clone() {
320
320
  return new _ObservablePatch(this.selection, {
321
321
  ...this.operations
322
- }, __privateGet$3(this, _client$2));
322
+ }, __privateGet$4(this, _client$3));
323
323
  }
324
324
  commit(options) {
325
- if (!__privateGet$3(this, _client$2)) {
325
+ if (!__privateGet$4(this, _client$3)) {
326
326
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
327
327
  }
328
328
  const returnFirst = typeof this.selection === "string";
@@ -330,26 +330,26 @@ const _ObservablePatch = class extends BasePatch {
330
330
  returnFirst,
331
331
  returnDocuments: true
332
332
  }, options);
333
- return __privateGet$3(this, _client$2).mutate({
333
+ return __privateGet$4(this, _client$3).mutate({
334
334
  patch: this.serialize()
335
335
  }, opts);
336
336
  }
337
337
  };
338
338
  let ObservablePatch = _ObservablePatch;
339
- _client$2 = new WeakMap();
339
+ _client$3 = new WeakMap();
340
340
  const _Patch = class extends BasePatch {
341
341
  constructor(selection, operations, client) {
342
342
  super(selection, operations);
343
- __privateAdd$4(this, _client2$2, void 0);
344
- __privateSet$3(this, _client2$2, client);
343
+ __privateAdd$5(this, _client2$3, void 0);
344
+ __privateSet$4(this, _client2$3, client);
345
345
  }
346
346
  clone() {
347
347
  return new _Patch(this.selection, {
348
348
  ...this.operations
349
- }, __privateGet$3(this, _client2$2));
349
+ }, __privateGet$4(this, _client2$3));
350
350
  }
351
351
  commit(options) {
352
- if (!__privateGet$3(this, _client2$2)) {
352
+ if (!__privateGet$4(this, _client2$3)) {
353
353
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
354
354
  }
355
355
  const returnFirst = typeof this.selection === "string";
@@ -357,30 +357,30 @@ const _Patch = class extends BasePatch {
357
357
  returnFirst,
358
358
  returnDocuments: true
359
359
  }, options);
360
- return __privateGet$3(this, _client2$2).mutate({
360
+ return __privateGet$4(this, _client2$3).mutate({
361
361
  patch: this.serialize()
362
362
  }, opts);
363
363
  }
364
364
  };
365
365
  let Patch = _Patch;
366
- _client2$2 = new WeakMap();
367
- var __accessCheck$3 = (obj, member, msg) => {
366
+ _client2$3 = new WeakMap();
367
+ var __accessCheck$4 = (obj, member, msg) => {
368
368
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
369
369
  };
370
- var __privateGet$2 = (obj, member, getter) => {
371
- __accessCheck$3(obj, member, "read from private field");
370
+ var __privateGet$3 = (obj, member, getter) => {
371
+ __accessCheck$4(obj, member, "read from private field");
372
372
  return getter ? getter.call(obj) : member.get(obj);
373
373
  };
374
- var __privateAdd$3 = (obj, member, value) => {
374
+ var __privateAdd$4 = (obj, member, value) => {
375
375
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
376
376
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
377
377
  };
378
- var __privateSet$2 = (obj, member, value, setter) => {
379
- __accessCheck$3(obj, member, "write to private field");
378
+ var __privateSet$3 = (obj, member, value, setter) => {
379
+ __accessCheck$4(obj, member, "write to private field");
380
380
  setter ? setter.call(obj, value) : member.set(obj, value);
381
381
  return value;
382
382
  };
383
- var _client$1, _client2$1;
383
+ var _client$2, _client2$2;
384
384
  const defaultMutateOptions = {
385
385
  returnDocuments: false
386
386
  };
@@ -446,17 +446,17 @@ class BaseTransaction {
446
446
  const _Transaction = class extends BaseTransaction {
447
447
  constructor(operations, client, transactionId) {
448
448
  super(operations, transactionId);
449
- __privateAdd$3(this, _client$1, void 0);
450
- __privateSet$2(this, _client$1, client);
449
+ __privateAdd$4(this, _client$2, void 0);
450
+ __privateSet$3(this, _client$2, client);
451
451
  }
452
452
  clone() {
453
- return new _Transaction([...this.operations], __privateGet$2(this, _client$1), this.trxId);
453
+ return new _Transaction([...this.operations], __privateGet$3(this, _client$2), this.trxId);
454
454
  }
455
455
  commit(options) {
456
- if (!__privateGet$2(this, _client$1)) {
456
+ if (!__privateGet$3(this, _client$2)) {
457
457
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
458
458
  }
459
- return __privateGet$2(this, _client$1).mutate(this.serialize(), Object.assign({
459
+ return __privateGet$3(this, _client$2).mutate(this.serialize(), Object.assign({
460
460
  transactionId: this.trxId
461
461
  }, defaultMutateOptions, options || {}));
462
462
  }
@@ -469,7 +469,7 @@ const _Transaction = class extends BaseTransaction {
469
469
  });
470
470
  }
471
471
  if (isBuilder) {
472
- const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$2(this, _client$1)));
472
+ const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$3(this, _client$2)));
473
473
  if (!(patch instanceof Patch)) {
474
474
  throw new Error("function passed to `patch()` must return the patch");
475
475
  }
@@ -486,21 +486,21 @@ const _Transaction = class extends BaseTransaction {
486
486
  }
487
487
  };
488
488
  let Transaction = _Transaction;
489
- _client$1 = new WeakMap();
489
+ _client$2 = new WeakMap();
490
490
  const _ObservableTransaction = class extends BaseTransaction {
491
491
  constructor(operations, client, transactionId) {
492
492
  super(operations, transactionId);
493
- __privateAdd$3(this, _client2$1, void 0);
494
- __privateSet$2(this, _client2$1, client);
493
+ __privateAdd$4(this, _client2$2, void 0);
494
+ __privateSet$3(this, _client2$2, client);
495
495
  }
496
496
  clone() {
497
- return new _ObservableTransaction([...this.operations], __privateGet$2(this, _client2$1), this.trxId);
497
+ return new _ObservableTransaction([...this.operations], __privateGet$3(this, _client2$2), this.trxId);
498
498
  }
499
499
  commit(options) {
500
- if (!__privateGet$2(this, _client2$1)) {
500
+ if (!__privateGet$3(this, _client2$2)) {
501
501
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
502
502
  }
503
- return __privateGet$2(this, _client2$1).mutate(this.serialize(), Object.assign({
503
+ return __privateGet$3(this, _client2$2).mutate(this.serialize(), Object.assign({
504
504
  transactionId: this.trxId
505
505
  }, defaultMutateOptions, options || {}));
506
506
  }
@@ -513,7 +513,7 @@ const _ObservableTransaction = class extends BaseTransaction {
513
513
  });
514
514
  }
515
515
  if (isBuilder) {
516
- const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$2(this, _client2$1)));
516
+ const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$3(this, _client2$2)));
517
517
  if (!(patch instanceof ObservablePatch)) {
518
518
  throw new Error("function passed to `patch()` must return the patch");
519
519
  }
@@ -530,7 +530,7 @@ const _ObservableTransaction = class extends BaseTransaction {
530
530
  }
531
531
  };
532
532
  let ObservableTransaction = _ObservableTransaction;
533
- _client2$1 = new WeakMap();
533
+ _client2$2 = new WeakMap();
534
534
  const excludeFalsey = (param, defValue) => {
535
535
  const value = typeof param === "undefined" ? defValue : param;
536
536
  return param === false ? void 0 : value;
@@ -684,50 +684,50 @@ function _request(client, httpRequest, options) {
684
684
  const observable = _requestObservable(client, httpRequest, options).pipe(filter(event => event.type === "response"), map(event => event.body));
685
685
  return observable;
686
686
  }
687
- var __accessCheck$2 = (obj, member, msg) => {
687
+ var __accessCheck$3 = (obj, member, msg) => {
688
688
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
689
689
  };
690
- var __privateGet$1 = (obj, member, getter) => {
691
- __accessCheck$2(obj, member, "read from private field");
690
+ var __privateGet$2 = (obj, member, getter) => {
691
+ __accessCheck$3(obj, member, "read from private field");
692
692
  return getter ? getter.call(obj) : member.get(obj);
693
693
  };
694
- var __privateAdd$2 = (obj, member, value) => {
694
+ var __privateAdd$3 = (obj, member, value) => {
695
695
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
696
696
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
697
697
  };
698
- var __privateSet$1 = (obj, member, value, setter) => {
699
- __accessCheck$2(obj, member, "write to private field");
698
+ var __privateSet$2 = (obj, member, value, setter) => {
699
+ __accessCheck$3(obj, member, "write to private field");
700
700
  setter ? setter.call(obj, value) : member.set(obj, value);
701
701
  return value;
702
702
  };
703
- var _client, _httpRequest$1, _client2, _httpRequest2$1;
703
+ var _client$1, _httpRequest$2, _client2$1, _httpRequest2$2;
704
704
  class ObservableAssetsClient {
705
705
  constructor(client, httpRequest) {
706
- __privateAdd$2(this, _client, void 0);
707
- __privateAdd$2(this, _httpRequest$1, void 0);
708
- __privateSet$1(this, _client, client);
709
- __privateSet$1(this, _httpRequest$1, httpRequest);
706
+ __privateAdd$3(this, _client$1, void 0);
707
+ __privateAdd$3(this, _httpRequest$2, void 0);
708
+ __privateSet$2(this, _client$1, client);
709
+ __privateSet$2(this, _httpRequest$2, httpRequest);
710
710
  }
711
711
  upload(assetType, body, options) {
712
- return _upload(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), assetType, body, options);
712
+ return _upload(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), assetType, body, options);
713
713
  }
714
714
  }
715
- _client = new WeakMap();
716
- _httpRequest$1 = new WeakMap();
715
+ _client$1 = new WeakMap();
716
+ _httpRequest$2 = new WeakMap();
717
717
  class AssetsClient {
718
718
  constructor(client, httpRequest) {
719
- __privateAdd$2(this, _client2, void 0);
720
- __privateAdd$2(this, _httpRequest2$1, void 0);
721
- __privateSet$1(this, _client2, client);
722
- __privateSet$1(this, _httpRequest2$1, httpRequest);
719
+ __privateAdd$3(this, _client2$1, void 0);
720
+ __privateAdd$3(this, _httpRequest2$2, void 0);
721
+ __privateSet$2(this, _client2$1, client);
722
+ __privateSet$2(this, _httpRequest2$2, httpRequest);
723
723
  }
724
724
  upload(assetType, body, options) {
725
- const observable = _upload(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), assetType, body, options);
725
+ const observable = _upload(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), assetType, body, options);
726
726
  return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
727
727
  }
728
728
  }
729
- _client2 = new WeakMap();
730
- _httpRequest2$1 = new WeakMap();
729
+ _client2$1 = new WeakMap();
730
+ _httpRequest2$2 = new WeakMap();
731
731
  function _upload(client, httpRequest, assetType, body) {
732
732
  let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
733
733
  validateAssetType(assetType);
@@ -781,31 +781,65 @@ function optionsFromFile(opts, file) {
781
781
  contentType: file.type
782
782
  }, opts);
783
783
  }
784
- class BaseAuthClient {
784
+ var __accessCheck$2 = (obj, member, msg) => {
785
+ if (!member.has(obj)) throw TypeError("Cannot " + msg);
786
+ };
787
+ var __privateGet$1 = (obj, member, getter) => {
788
+ __accessCheck$2(obj, member, "read from private field");
789
+ return getter ? getter.call(obj) : member.get(obj);
790
+ };
791
+ var __privateAdd$2 = (obj, member, value) => {
792
+ if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
793
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
794
+ };
795
+ var __privateSet$1 = (obj, member, value, setter) => {
796
+ __accessCheck$2(obj, member, "write to private field");
797
+ setter ? setter.call(obj, value) : member.set(obj, value);
798
+ return value;
799
+ };
800
+ var _client, _httpRequest$1, _client2, _httpRequest2$1;
801
+ class ObservableAuthClient {
802
+ constructor(client, httpRequest) {
803
+ __privateAdd$2(this, _client, void 0);
804
+ __privateAdd$2(this, _httpRequest$1, void 0);
805
+ __privateSet$1(this, _client, client);
806
+ __privateSet$1(this, _httpRequest$1, httpRequest);
807
+ }
785
808
  getLoginProviders() {
786
- return this.client.request({
809
+ return _request(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), {
787
810
  uri: "/auth/providers"
788
811
  });
789
812
  }
790
813
  logout() {
791
- return this.client.request({
814
+ return _request(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), {
792
815
  uri: "/auth/logout",
793
816
  method: "POST"
794
817
  });
795
818
  }
796
819
  }
797
- class ObservableAuthClient extends BaseAuthClient {
798
- constructor(client) {
799
- super();
800
- this.client = client;
820
+ _client = new WeakMap();
821
+ _httpRequest$1 = new WeakMap();
822
+ class AuthClient {
823
+ constructor(client, httpRequest) {
824
+ __privateAdd$2(this, _client2, void 0);
825
+ __privateAdd$2(this, _httpRequest2$1, void 0);
826
+ __privateSet$1(this, _client2, client);
827
+ __privateSet$1(this, _httpRequest2$1, httpRequest);
801
828
  }
802
- }
803
- class AuthClient extends BaseAuthClient {
804
- constructor(client) {
805
- super();
806
- this.client = client;
829
+ getLoginProviders() {
830
+ return lastValueFrom(_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
831
+ uri: "/auth/providers"
832
+ }));
833
+ }
834
+ logout() {
835
+ return lastValueFrom(_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
836
+ uri: "/auth/logout",
837
+ method: "POST"
838
+ }));
807
839
  }
808
840
  }
841
+ _client2 = new WeakMap();
842
+ _httpRequest2$1 = new WeakMap();
809
843
  const BASE_URL = "https://docs.sanity.io/help/";
810
844
  function generateHelpUrl(slug) {
811
845
  return BASE_URL + slug;
@@ -1149,11 +1183,21 @@ var __privateSet = (obj, member, value, setter) => {
1149
1183
  setter ? setter.call(obj, value) : member.set(obj, value);
1150
1184
  return value;
1151
1185
  };
1152
- var _clientConfig, _httpRequest, _httpRequest2;
1153
- class BaseSanityClient {
1154
- constructor(config) {
1186
+ var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
1187
+ const _ObservableSanityClient = class {
1188
+ constructor(httpRequest, config) {
1155
1189
  __privateAdd(this, _clientConfig, void 0);
1190
+ __privateAdd(this, _httpRequest, void 0);
1156
1191
  this.config(config);
1192
+ __privateSet(this, _httpRequest, httpRequest);
1193
+ this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
1194
+ this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
1195
+ this.datasets = new ObservableDatasetsClient(this);
1196
+ this.projects = new ObservableProjectsClient(this);
1197
+ this.users = new ObservableUsersClient(this);
1198
+ }
1199
+ clone() {
1200
+ return new _ObservableSanityClient(__privateGet(this, _httpRequest), this.config());
1157
1201
  }
1158
1202
  config(newConfig) {
1159
1203
  if (newConfig === void 0) {
@@ -1167,40 +1211,6 @@ class BaseSanityClient {
1167
1211
  __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {}));
1168
1212
  return this;
1169
1213
  }
1170
- isPromiseAPI() {
1171
- return this instanceof SanityClient;
1172
- }
1173
- getUrl(uri) {
1174
- let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1175
- const base = canUseCdn ? __privateGet(this, _clientConfig).cdnUrl : __privateGet(this, _clientConfig).url;
1176
- return "".concat(base, "/").concat(uri.replace(/^\//, ""));
1177
- }
1178
- getDataUrl(operation, path) {
1179
- const config = this.config();
1180
- const catalog = hasDataset(config);
1181
- const baseUri = "/".concat(operation, "/").concat(catalog);
1182
- const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
1183
- return "/data".concat(uri).replace(/\/($|\?)/, "$1");
1184
- }
1185
- }
1186
- _clientConfig = new WeakMap();
1187
- const _ObservableSanityClient = class extends BaseSanityClient {
1188
- constructor(httpRequest, config) {
1189
- super(config);
1190
- __privateAdd(this, _httpRequest, void 0);
1191
- __privateSet(this, _httpRequest, httpRequest);
1192
- this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
1193
- this.auth = new ObservableAuthClient(this);
1194
- this.datasets = new ObservableDatasetsClient(this);
1195
- this.projects = new ObservableProjectsClient(this);
1196
- this.users = new ObservableUsersClient(this);
1197
- }
1198
- clone() {
1199
- return new _ObservableSanityClient(__privateGet(this, _httpRequest), this.config());
1200
- }
1201
- config(newConfig) {
1202
- return super.config(newConfig);
1203
- }
1204
1214
  withConfig(newConfig) {
1205
1215
  return new _ObservableSanityClient(__privateGet(this, _httpRequest), {
1206
1216
  ...this.config(),
@@ -1241,30 +1251,51 @@ const _ObservableSanityClient = class extends BaseSanityClient {
1241
1251
  request(options) {
1242
1252
  return _request(this, __privateGet(this, _httpRequest), options);
1243
1253
  }
1254
+ getUrl(uri) {
1255
+ let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1256
+ const base = canUseCdn ? __privateGet(this, _clientConfig).cdnUrl : __privateGet(this, _clientConfig).url;
1257
+ return "".concat(base, "/").concat(uri.replace(/^\//, ""));
1258
+ }
1259
+ getDataUrl(operation, path) {
1260
+ const config = this.config();
1261
+ const catalog = hasDataset(config);
1262
+ const baseUri = "/".concat(operation, "/").concat(catalog);
1263
+ const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
1264
+ return "/data".concat(uri).replace(/\/($|\?)/, "$1");
1265
+ }
1244
1266
  };
1245
1267
  let ObservableSanityClient = _ObservableSanityClient;
1268
+ _clientConfig = new WeakMap();
1246
1269
  _httpRequest = new WeakMap();
1247
- const _SanityClient = class extends BaseSanityClient {
1270
+ const _SanityClient = class {
1248
1271
  constructor(httpRequest, config) {
1249
- super(config);
1272
+ __privateAdd(this, _clientConfig2, void 0);
1250
1273
  __privateAdd(this, _httpRequest2, void 0);
1251
1274
  this.listen = _listen;
1275
+ this.observable = new ObservableSanityClient(httpRequest, config);
1276
+ this.config(config);
1252
1277
  __privateSet(this, _httpRequest2, httpRequest);
1253
1278
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
1254
- this.auth = new AuthClient(this);
1279
+ this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
1255
1280
  this.datasets = new DatasetsClient(this);
1256
1281
  this.projects = new ProjectsClient(this);
1257
1282
  this.users = new UsersClient(this);
1258
- this.observable = new ObservableSanityClient(httpRequest, this.config());
1259
1283
  }
1260
1284
  clone() {
1261
1285
  return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
1262
1286
  }
1263
1287
  config(newConfig) {
1264
- if (newConfig) {
1265
- this.observable.config(newConfig);
1288
+ if (newConfig === void 0) {
1289
+ return {
1290
+ ...__privateGet(this, _clientConfig2)
1291
+ };
1266
1292
  }
1267
- return super.config(newConfig);
1293
+ if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
1294
+ throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
1295
+ }
1296
+ this.observable.config(newConfig);
1297
+ __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {}));
1298
+ return this;
1268
1299
  }
1269
1300
  withConfig(newConfig) {
1270
1301
  return new _SanityClient(__privateGet(this, _httpRequest2), {
@@ -1309,13 +1340,26 @@ const _SanityClient = class extends BaseSanityClient {
1309
1340
  dataRequest(endpoint, body, options) {
1310
1341
  return lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
1311
1342
  }
1343
+ getUrl(uri) {
1344
+ let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1345
+ const base = canUseCdn ? __privateGet(this, _clientConfig2).cdnUrl : __privateGet(this, _clientConfig2).url;
1346
+ return "".concat(base, "/").concat(uri.replace(/^\//, ""));
1347
+ }
1348
+ getDataUrl(operation, path) {
1349
+ const config = this.config();
1350
+ const catalog = hasDataset(config);
1351
+ const baseUri = "/".concat(operation, "/").concat(catalog);
1352
+ const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
1353
+ return "/data".concat(uri).replace(/\/($|\?)/, "$1");
1354
+ }
1312
1355
  };
1313
1356
  let SanityClient = _SanityClient;
1357
+ _clientConfig2 = new WeakMap();
1314
1358
  _httpRequest2 = new WeakMap();
1315
1359
  const httpRequest = defineHttpRequest(middleware);
1316
1360
  const requester = httpRequest.defaultRequester;
1317
1361
  function createClient(config) {
1318
1362
  return new SanityClient(httpRequest, config);
1319
1363
  }
1320
- export { BasePatch, BaseSanityClient, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, createClient, requester };
1364
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, createClient, requester };
1321
1365
  //# sourceMappingURL=index.js.map