@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.
@@ -197,23 +197,23 @@ var encodeQueryString = _ref => {
197
197
  return options[option] ? "".concat(qs, "&").concat(enc(option), "=").concat(enc(options[option])) : qs;
198
198
  }, qString);
199
199
  };
200
- var __accessCheck$4 = (obj, member, msg) => {
200
+ var __accessCheck$5 = (obj, member, msg) => {
201
201
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
202
202
  };
203
- var __privateGet$3 = (obj, member, getter) => {
204
- __accessCheck$4(obj, member, "read from private field");
203
+ var __privateGet$4 = (obj, member, getter) => {
204
+ __accessCheck$5(obj, member, "read from private field");
205
205
  return getter ? getter.call(obj) : member.get(obj);
206
206
  };
207
- var __privateAdd$4 = (obj, member, value) => {
207
+ var __privateAdd$5 = (obj, member, value) => {
208
208
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
209
209
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
210
210
  };
211
- var __privateSet$3 = (obj, member, value, setter) => {
212
- __accessCheck$4(obj, member, "write to private field");
211
+ var __privateSet$4 = (obj, member, value, setter) => {
212
+ __accessCheck$5(obj, member, "write to private field");
213
213
  setter ? setter.call(obj, value) : member.set(obj, value);
214
214
  return value;
215
215
  };
216
- var _client$2, _client2$2;
216
+ var _client$3, _client2$3;
217
217
  class BasePatch {
218
218
  constructor(selection) {
219
219
  let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -304,16 +304,16 @@ class BasePatch {
304
304
  const _ObservablePatch = class extends BasePatch {
305
305
  constructor(selection, operations, client) {
306
306
  super(selection, operations);
307
- __privateAdd$4(this, _client$2, void 0);
308
- __privateSet$3(this, _client$2, client);
307
+ __privateAdd$5(this, _client$3, void 0);
308
+ __privateSet$4(this, _client$3, client);
309
309
  }
310
310
  clone() {
311
311
  return new _ObservablePatch(this.selection, {
312
312
  ...this.operations
313
- }, __privateGet$3(this, _client$2));
313
+ }, __privateGet$4(this, _client$3));
314
314
  }
315
315
  commit(options) {
316
- if (!__privateGet$3(this, _client$2)) {
316
+ if (!__privateGet$4(this, _client$3)) {
317
317
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
318
318
  }
319
319
  const returnFirst = typeof this.selection === "string";
@@ -321,26 +321,26 @@ const _ObservablePatch = class extends BasePatch {
321
321
  returnFirst,
322
322
  returnDocuments: true
323
323
  }, options);
324
- return __privateGet$3(this, _client$2).mutate({
324
+ return __privateGet$4(this, _client$3).mutate({
325
325
  patch: this.serialize()
326
326
  }, opts);
327
327
  }
328
328
  };
329
329
  let ObservablePatch = _ObservablePatch;
330
- _client$2 = new WeakMap();
330
+ _client$3 = new WeakMap();
331
331
  const _Patch = class extends BasePatch {
332
332
  constructor(selection, operations, client) {
333
333
  super(selection, operations);
334
- __privateAdd$4(this, _client2$2, void 0);
335
- __privateSet$3(this, _client2$2, client);
334
+ __privateAdd$5(this, _client2$3, void 0);
335
+ __privateSet$4(this, _client2$3, client);
336
336
  }
337
337
  clone() {
338
338
  return new _Patch(this.selection, {
339
339
  ...this.operations
340
- }, __privateGet$3(this, _client2$2));
340
+ }, __privateGet$4(this, _client2$3));
341
341
  }
342
342
  commit(options) {
343
- if (!__privateGet$3(this, _client2$2)) {
343
+ if (!__privateGet$4(this, _client2$3)) {
344
344
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
345
345
  }
346
346
  const returnFirst = typeof this.selection === "string";
@@ -348,30 +348,30 @@ const _Patch = class extends BasePatch {
348
348
  returnFirst,
349
349
  returnDocuments: true
350
350
  }, options);
351
- return __privateGet$3(this, _client2$2).mutate({
351
+ return __privateGet$4(this, _client2$3).mutate({
352
352
  patch: this.serialize()
353
353
  }, opts);
354
354
  }
355
355
  };
356
356
  let Patch = _Patch;
357
- _client2$2 = new WeakMap();
358
- var __accessCheck$3 = (obj, member, msg) => {
357
+ _client2$3 = new WeakMap();
358
+ var __accessCheck$4 = (obj, member, msg) => {
359
359
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
360
360
  };
361
- var __privateGet$2 = (obj, member, getter) => {
362
- __accessCheck$3(obj, member, "read from private field");
361
+ var __privateGet$3 = (obj, member, getter) => {
362
+ __accessCheck$4(obj, member, "read from private field");
363
363
  return getter ? getter.call(obj) : member.get(obj);
364
364
  };
365
- var __privateAdd$3 = (obj, member, value) => {
365
+ var __privateAdd$4 = (obj, member, value) => {
366
366
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
367
367
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
368
368
  };
369
- var __privateSet$2 = (obj, member, value, setter) => {
370
- __accessCheck$3(obj, member, "write to private field");
369
+ var __privateSet$3 = (obj, member, value, setter) => {
370
+ __accessCheck$4(obj, member, "write to private field");
371
371
  setter ? setter.call(obj, value) : member.set(obj, value);
372
372
  return value;
373
373
  };
374
- var _client$1, _client2$1;
374
+ var _client$2, _client2$2;
375
375
  const defaultMutateOptions = {
376
376
  returnDocuments: false
377
377
  };
@@ -437,17 +437,17 @@ class BaseTransaction {
437
437
  const _Transaction = class extends BaseTransaction {
438
438
  constructor(operations, client, transactionId) {
439
439
  super(operations, transactionId);
440
- __privateAdd$3(this, _client$1, void 0);
441
- __privateSet$2(this, _client$1, client);
440
+ __privateAdd$4(this, _client$2, void 0);
441
+ __privateSet$3(this, _client$2, client);
442
442
  }
443
443
  clone() {
444
- return new _Transaction([...this.operations], __privateGet$2(this, _client$1), this.trxId);
444
+ return new _Transaction([...this.operations], __privateGet$3(this, _client$2), this.trxId);
445
445
  }
446
446
  commit(options) {
447
- if (!__privateGet$2(this, _client$1)) {
447
+ if (!__privateGet$3(this, _client$2)) {
448
448
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
449
449
  }
450
- return __privateGet$2(this, _client$1).mutate(this.serialize(), Object.assign({
450
+ return __privateGet$3(this, _client$2).mutate(this.serialize(), Object.assign({
451
451
  transactionId: this.trxId
452
452
  }, defaultMutateOptions, options || {}));
453
453
  }
@@ -460,7 +460,7 @@ const _Transaction = class extends BaseTransaction {
460
460
  });
461
461
  }
462
462
  if (isBuilder) {
463
- const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$2(this, _client$1)));
463
+ const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$3(this, _client$2)));
464
464
  if (!(patch instanceof Patch)) {
465
465
  throw new Error("function passed to `patch()` must return the patch");
466
466
  }
@@ -477,21 +477,21 @@ const _Transaction = class extends BaseTransaction {
477
477
  }
478
478
  };
479
479
  let Transaction = _Transaction;
480
- _client$1 = new WeakMap();
480
+ _client$2 = new WeakMap();
481
481
  const _ObservableTransaction = class extends BaseTransaction {
482
482
  constructor(operations, client, transactionId) {
483
483
  super(operations, transactionId);
484
- __privateAdd$3(this, _client2$1, void 0);
485
- __privateSet$2(this, _client2$1, client);
484
+ __privateAdd$4(this, _client2$2, void 0);
485
+ __privateSet$3(this, _client2$2, client);
486
486
  }
487
487
  clone() {
488
- return new _ObservableTransaction([...this.operations], __privateGet$2(this, _client2$1), this.trxId);
488
+ return new _ObservableTransaction([...this.operations], __privateGet$3(this, _client2$2), this.trxId);
489
489
  }
490
490
  commit(options) {
491
- if (!__privateGet$2(this, _client2$1)) {
491
+ if (!__privateGet$3(this, _client2$2)) {
492
492
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
493
493
  }
494
- return __privateGet$2(this, _client2$1).mutate(this.serialize(), Object.assign({
494
+ return __privateGet$3(this, _client2$2).mutate(this.serialize(), Object.assign({
495
495
  transactionId: this.trxId
496
496
  }, defaultMutateOptions, options || {}));
497
497
  }
@@ -504,7 +504,7 @@ const _ObservableTransaction = class extends BaseTransaction {
504
504
  });
505
505
  }
506
506
  if (isBuilder) {
507
- const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$2(this, _client2$1)));
507
+ const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$3(this, _client2$2)));
508
508
  if (!(patch instanceof ObservablePatch)) {
509
509
  throw new Error("function passed to `patch()` must return the patch");
510
510
  }
@@ -521,7 +521,7 @@ const _ObservableTransaction = class extends BaseTransaction {
521
521
  }
522
522
  };
523
523
  let ObservableTransaction = _ObservableTransaction;
524
- _client2$1 = new WeakMap();
524
+ _client2$2 = new WeakMap();
525
525
  const excludeFalsey = (param, defValue) => {
526
526
  const value = typeof param === "undefined" ? defValue : param;
527
527
  return param === false ? void 0 : value;
@@ -675,50 +675,50 @@ function _request(client, httpRequest, options) {
675
675
  const observable = _requestObservable(client, httpRequest, options).pipe(filter(event => event.type === "response"), map(event => event.body));
676
676
  return observable;
677
677
  }
678
- var __accessCheck$2 = (obj, member, msg) => {
678
+ var __accessCheck$3 = (obj, member, msg) => {
679
679
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
680
680
  };
681
- var __privateGet$1 = (obj, member, getter) => {
682
- __accessCheck$2(obj, member, "read from private field");
681
+ var __privateGet$2 = (obj, member, getter) => {
682
+ __accessCheck$3(obj, member, "read from private field");
683
683
  return getter ? getter.call(obj) : member.get(obj);
684
684
  };
685
- var __privateAdd$2 = (obj, member, value) => {
685
+ var __privateAdd$3 = (obj, member, value) => {
686
686
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
687
687
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
688
688
  };
689
- var __privateSet$1 = (obj, member, value, setter) => {
690
- __accessCheck$2(obj, member, "write to private field");
689
+ var __privateSet$2 = (obj, member, value, setter) => {
690
+ __accessCheck$3(obj, member, "write to private field");
691
691
  setter ? setter.call(obj, value) : member.set(obj, value);
692
692
  return value;
693
693
  };
694
- var _client, _httpRequest$1, _client2, _httpRequest2$1;
694
+ var _client$1, _httpRequest$2, _client2$1, _httpRequest2$2;
695
695
  class ObservableAssetsClient {
696
696
  constructor(client, httpRequest) {
697
- __privateAdd$2(this, _client, void 0);
698
- __privateAdd$2(this, _httpRequest$1, void 0);
699
- __privateSet$1(this, _client, client);
700
- __privateSet$1(this, _httpRequest$1, httpRequest);
697
+ __privateAdd$3(this, _client$1, void 0);
698
+ __privateAdd$3(this, _httpRequest$2, void 0);
699
+ __privateSet$2(this, _client$1, client);
700
+ __privateSet$2(this, _httpRequest$2, httpRequest);
701
701
  }
702
702
  upload(assetType, body, options) {
703
- return _upload(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), assetType, body, options);
703
+ return _upload(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), assetType, body, options);
704
704
  }
705
705
  }
706
- _client = new WeakMap();
707
- _httpRequest$1 = new WeakMap();
706
+ _client$1 = new WeakMap();
707
+ _httpRequest$2 = new WeakMap();
708
708
  class AssetsClient {
709
709
  constructor(client, httpRequest) {
710
- __privateAdd$2(this, _client2, void 0);
711
- __privateAdd$2(this, _httpRequest2$1, void 0);
712
- __privateSet$1(this, _client2, client);
713
- __privateSet$1(this, _httpRequest2$1, httpRequest);
710
+ __privateAdd$3(this, _client2$1, void 0);
711
+ __privateAdd$3(this, _httpRequest2$2, void 0);
712
+ __privateSet$2(this, _client2$1, client);
713
+ __privateSet$2(this, _httpRequest2$2, httpRequest);
714
714
  }
715
715
  upload(assetType, body, options) {
716
- const observable = _upload(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), assetType, body, options);
716
+ const observable = _upload(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), assetType, body, options);
717
717
  return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
718
718
  }
719
719
  }
720
- _client2 = new WeakMap();
721
- _httpRequest2$1 = new WeakMap();
720
+ _client2$1 = new WeakMap();
721
+ _httpRequest2$2 = new WeakMap();
722
722
  function _upload(client, httpRequest, assetType, body) {
723
723
  let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
724
724
  validateAssetType(assetType);
@@ -772,31 +772,65 @@ function optionsFromFile(opts, file) {
772
772
  contentType: file.type
773
773
  }, opts);
774
774
  }
775
- class BaseAuthClient {
775
+ var __accessCheck$2 = (obj, member, msg) => {
776
+ if (!member.has(obj)) throw TypeError("Cannot " + msg);
777
+ };
778
+ var __privateGet$1 = (obj, member, getter) => {
779
+ __accessCheck$2(obj, member, "read from private field");
780
+ return getter ? getter.call(obj) : member.get(obj);
781
+ };
782
+ var __privateAdd$2 = (obj, member, value) => {
783
+ if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
784
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
785
+ };
786
+ var __privateSet$1 = (obj, member, value, setter) => {
787
+ __accessCheck$2(obj, member, "write to private field");
788
+ setter ? setter.call(obj, value) : member.set(obj, value);
789
+ return value;
790
+ };
791
+ var _client, _httpRequest$1, _client2, _httpRequest2$1;
792
+ class ObservableAuthClient {
793
+ constructor(client, httpRequest) {
794
+ __privateAdd$2(this, _client, void 0);
795
+ __privateAdd$2(this, _httpRequest$1, void 0);
796
+ __privateSet$1(this, _client, client);
797
+ __privateSet$1(this, _httpRequest$1, httpRequest);
798
+ }
776
799
  getLoginProviders() {
777
- return this.client.request({
800
+ return _request(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), {
778
801
  uri: "/auth/providers"
779
802
  });
780
803
  }
781
804
  logout() {
782
- return this.client.request({
805
+ return _request(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), {
783
806
  uri: "/auth/logout",
784
807
  method: "POST"
785
808
  });
786
809
  }
787
810
  }
788
- class ObservableAuthClient extends BaseAuthClient {
789
- constructor(client) {
790
- super();
791
- this.client = client;
811
+ _client = new WeakMap();
812
+ _httpRequest$1 = new WeakMap();
813
+ class AuthClient {
814
+ constructor(client, httpRequest) {
815
+ __privateAdd$2(this, _client2, void 0);
816
+ __privateAdd$2(this, _httpRequest2$1, void 0);
817
+ __privateSet$1(this, _client2, client);
818
+ __privateSet$1(this, _httpRequest2$1, httpRequest);
792
819
  }
793
- }
794
- class AuthClient extends BaseAuthClient {
795
- constructor(client) {
796
- super();
797
- this.client = client;
820
+ getLoginProviders() {
821
+ return lastValueFrom(_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
822
+ uri: "/auth/providers"
823
+ }));
824
+ }
825
+ logout() {
826
+ return lastValueFrom(_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
827
+ uri: "/auth/logout",
828
+ method: "POST"
829
+ }));
798
830
  }
799
831
  }
832
+ _client2 = new WeakMap();
833
+ _httpRequest2$1 = new WeakMap();
800
834
  const BASE_URL = "https://docs.sanity.io/help/";
801
835
  function generateHelpUrl(slug) {
802
836
  return BASE_URL + slug;
@@ -1140,11 +1174,21 @@ var __privateSet = (obj, member, value, setter) => {
1140
1174
  setter ? setter.call(obj, value) : member.set(obj, value);
1141
1175
  return value;
1142
1176
  };
1143
- var _clientConfig, _httpRequest, _httpRequest2;
1144
- class BaseSanityClient {
1145
- constructor(config) {
1177
+ var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
1178
+ const _ObservableSanityClient = class {
1179
+ constructor(httpRequest, config) {
1146
1180
  __privateAdd(this, _clientConfig, void 0);
1181
+ __privateAdd(this, _httpRequest, void 0);
1147
1182
  this.config(config);
1183
+ __privateSet(this, _httpRequest, httpRequest);
1184
+ this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
1185
+ this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
1186
+ this.datasets = new ObservableDatasetsClient(this);
1187
+ this.projects = new ObservableProjectsClient(this);
1188
+ this.users = new ObservableUsersClient(this);
1189
+ }
1190
+ clone() {
1191
+ return new _ObservableSanityClient(__privateGet(this, _httpRequest), this.config());
1148
1192
  }
1149
1193
  config(newConfig) {
1150
1194
  if (newConfig === void 0) {
@@ -1158,40 +1202,6 @@ class BaseSanityClient {
1158
1202
  __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {}));
1159
1203
  return this;
1160
1204
  }
1161
- isPromiseAPI() {
1162
- return this instanceof SanityClient;
1163
- }
1164
- getUrl(uri) {
1165
- let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1166
- const base = canUseCdn ? __privateGet(this, _clientConfig).cdnUrl : __privateGet(this, _clientConfig).url;
1167
- return "".concat(base, "/").concat(uri.replace(/^\//, ""));
1168
- }
1169
- getDataUrl(operation, path) {
1170
- const config = this.config();
1171
- const catalog = hasDataset(config);
1172
- const baseUri = "/".concat(operation, "/").concat(catalog);
1173
- const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
1174
- return "/data".concat(uri).replace(/\/($|\?)/, "$1");
1175
- }
1176
- }
1177
- _clientConfig = new WeakMap();
1178
- const _ObservableSanityClient = class extends BaseSanityClient {
1179
- constructor(httpRequest, config) {
1180
- super(config);
1181
- __privateAdd(this, _httpRequest, void 0);
1182
- __privateSet(this, _httpRequest, httpRequest);
1183
- this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
1184
- this.auth = new ObservableAuthClient(this);
1185
- this.datasets = new ObservableDatasetsClient(this);
1186
- this.projects = new ObservableProjectsClient(this);
1187
- this.users = new ObservableUsersClient(this);
1188
- }
1189
- clone() {
1190
- return new _ObservableSanityClient(__privateGet(this, _httpRequest), this.config());
1191
- }
1192
- config(newConfig) {
1193
- return super.config(newConfig);
1194
- }
1195
1205
  withConfig(newConfig) {
1196
1206
  return new _ObservableSanityClient(__privateGet(this, _httpRequest), {
1197
1207
  ...this.config(),
@@ -1232,30 +1242,51 @@ const _ObservableSanityClient = class extends BaseSanityClient {
1232
1242
  request(options) {
1233
1243
  return _request(this, __privateGet(this, _httpRequest), options);
1234
1244
  }
1245
+ getUrl(uri) {
1246
+ let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1247
+ const base = canUseCdn ? __privateGet(this, _clientConfig).cdnUrl : __privateGet(this, _clientConfig).url;
1248
+ return "".concat(base, "/").concat(uri.replace(/^\//, ""));
1249
+ }
1250
+ getDataUrl(operation, path) {
1251
+ const config = this.config();
1252
+ const catalog = hasDataset(config);
1253
+ const baseUri = "/".concat(operation, "/").concat(catalog);
1254
+ const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
1255
+ return "/data".concat(uri).replace(/\/($|\?)/, "$1");
1256
+ }
1235
1257
  };
1236
1258
  let ObservableSanityClient = _ObservableSanityClient;
1259
+ _clientConfig = new WeakMap();
1237
1260
  _httpRequest = new WeakMap();
1238
- const _SanityClient = class extends BaseSanityClient {
1261
+ const _SanityClient = class {
1239
1262
  constructor(httpRequest, config) {
1240
- super(config);
1263
+ __privateAdd(this, _clientConfig2, void 0);
1241
1264
  __privateAdd(this, _httpRequest2, void 0);
1242
1265
  this.listen = _listen;
1266
+ this.observable = new ObservableSanityClient(httpRequest, config);
1267
+ this.config(config);
1243
1268
  __privateSet(this, _httpRequest2, httpRequest);
1244
1269
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
1245
- this.auth = new AuthClient(this);
1270
+ this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
1246
1271
  this.datasets = new DatasetsClient(this);
1247
1272
  this.projects = new ProjectsClient(this);
1248
1273
  this.users = new UsersClient(this);
1249
- this.observable = new ObservableSanityClient(httpRequest, this.config());
1250
1274
  }
1251
1275
  clone() {
1252
1276
  return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
1253
1277
  }
1254
1278
  config(newConfig) {
1255
- if (newConfig) {
1256
- this.observable.config(newConfig);
1279
+ if (newConfig === void 0) {
1280
+ return {
1281
+ ...__privateGet(this, _clientConfig2)
1282
+ };
1257
1283
  }
1258
- return super.config(newConfig);
1284
+ if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
1285
+ throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
1286
+ }
1287
+ this.observable.config(newConfig);
1288
+ __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {}));
1289
+ return this;
1259
1290
  }
1260
1291
  withConfig(newConfig) {
1261
1292
  return new _SanityClient(__privateGet(this, _httpRequest2), {
@@ -1300,13 +1331,26 @@ const _SanityClient = class extends BaseSanityClient {
1300
1331
  dataRequest(endpoint, body, options) {
1301
1332
  return lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
1302
1333
  }
1334
+ getUrl(uri) {
1335
+ let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1336
+ const base = canUseCdn ? __privateGet(this, _clientConfig2).cdnUrl : __privateGet(this, _clientConfig2).url;
1337
+ return "".concat(base, "/").concat(uri.replace(/^\//, ""));
1338
+ }
1339
+ getDataUrl(operation, path) {
1340
+ const config = this.config();
1341
+ const catalog = hasDataset(config);
1342
+ const baseUri = "/".concat(operation, "/").concat(catalog);
1343
+ const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
1344
+ return "/data".concat(uri).replace(/\/($|\?)/, "$1");
1345
+ }
1303
1346
  };
1304
1347
  let SanityClient = _SanityClient;
1348
+ _clientConfig2 = new WeakMap();
1305
1349
  _httpRequest2 = new WeakMap();
1306
1350
  const httpRequest = defineHttpRequest(envMiddleware);
1307
1351
  const requester = httpRequest.defaultRequester;
1308
1352
  function createClient(config) {
1309
1353
  return new SanityClient(httpRequest, config);
1310
1354
  }
1311
- export { BasePatch, BaseSanityClient, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, createClient, requester };
1355
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, createClient, requester };
1312
1356
  //# sourceMappingURL=index.browser.js.map