@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.
@@ -4312,23 +4312,23 @@
4312
4312
  return options[option] ? "".concat(qs, "&").concat(enc(option), "=").concat(enc(options[option])) : qs;
4313
4313
  }, qString);
4314
4314
  };
4315
- var __accessCheck$4 = (obj, member, msg) => {
4315
+ var __accessCheck$5 = (obj, member, msg) => {
4316
4316
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
4317
4317
  };
4318
- var __privateGet$3 = (obj, member, getter) => {
4319
- __accessCheck$4(obj, member, "read from private field");
4318
+ var __privateGet$4 = (obj, member, getter) => {
4319
+ __accessCheck$5(obj, member, "read from private field");
4320
4320
  return getter ? getter.call(obj) : member.get(obj);
4321
4321
  };
4322
- var __privateAdd$4 = (obj, member, value) => {
4322
+ var __privateAdd$5 = (obj, member, value) => {
4323
4323
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
4324
4324
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4325
4325
  };
4326
- var __privateSet$3 = (obj, member, value, setter) => {
4327
- __accessCheck$4(obj, member, "write to private field");
4326
+ var __privateSet$4 = (obj, member, value, setter) => {
4327
+ __accessCheck$5(obj, member, "write to private field");
4328
4328
  setter ? setter.call(obj, value) : member.set(obj, value);
4329
4329
  return value;
4330
4330
  };
4331
- var _client$2, _client2$2;
4331
+ var _client$3, _client2$3;
4332
4332
  class BasePatch {
4333
4333
  constructor(selection) {
4334
4334
  let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -4419,16 +4419,16 @@
4419
4419
  const _ObservablePatch = class extends BasePatch {
4420
4420
  constructor(selection, operations, client) {
4421
4421
  super(selection, operations);
4422
- __privateAdd$4(this, _client$2, void 0);
4423
- __privateSet$3(this, _client$2, client);
4422
+ __privateAdd$5(this, _client$3, void 0);
4423
+ __privateSet$4(this, _client$3, client);
4424
4424
  }
4425
4425
  clone() {
4426
4426
  return new _ObservablePatch(this.selection, {
4427
4427
  ...this.operations
4428
- }, __privateGet$3(this, _client$2));
4428
+ }, __privateGet$4(this, _client$3));
4429
4429
  }
4430
4430
  commit(options) {
4431
- if (!__privateGet$3(this, _client$2)) {
4431
+ if (!__privateGet$4(this, _client$3)) {
4432
4432
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
4433
4433
  }
4434
4434
  const returnFirst = typeof this.selection === "string";
@@ -4436,26 +4436,26 @@
4436
4436
  returnFirst,
4437
4437
  returnDocuments: true
4438
4438
  }, options);
4439
- return __privateGet$3(this, _client$2).mutate({
4439
+ return __privateGet$4(this, _client$3).mutate({
4440
4440
  patch: this.serialize()
4441
4441
  }, opts);
4442
4442
  }
4443
4443
  };
4444
4444
  let ObservablePatch = _ObservablePatch;
4445
- _client$2 = new WeakMap();
4445
+ _client$3 = new WeakMap();
4446
4446
  const _Patch = class extends BasePatch {
4447
4447
  constructor(selection, operations, client) {
4448
4448
  super(selection, operations);
4449
- __privateAdd$4(this, _client2$2, void 0);
4450
- __privateSet$3(this, _client2$2, client);
4449
+ __privateAdd$5(this, _client2$3, void 0);
4450
+ __privateSet$4(this, _client2$3, client);
4451
4451
  }
4452
4452
  clone() {
4453
4453
  return new _Patch(this.selection, {
4454
4454
  ...this.operations
4455
- }, __privateGet$3(this, _client2$2));
4455
+ }, __privateGet$4(this, _client2$3));
4456
4456
  }
4457
4457
  commit(options) {
4458
- if (!__privateGet$3(this, _client2$2)) {
4458
+ if (!__privateGet$4(this, _client2$3)) {
4459
4459
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
4460
4460
  }
4461
4461
  const returnFirst = typeof this.selection === "string";
@@ -4463,30 +4463,30 @@
4463
4463
  returnFirst,
4464
4464
  returnDocuments: true
4465
4465
  }, options);
4466
- return __privateGet$3(this, _client2$2).mutate({
4466
+ return __privateGet$4(this, _client2$3).mutate({
4467
4467
  patch: this.serialize()
4468
4468
  }, opts);
4469
4469
  }
4470
4470
  };
4471
4471
  let Patch = _Patch;
4472
- _client2$2 = new WeakMap();
4473
- var __accessCheck$3 = (obj, member, msg) => {
4472
+ _client2$3 = new WeakMap();
4473
+ var __accessCheck$4 = (obj, member, msg) => {
4474
4474
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
4475
4475
  };
4476
- var __privateGet$2 = (obj, member, getter) => {
4477
- __accessCheck$3(obj, member, "read from private field");
4476
+ var __privateGet$3 = (obj, member, getter) => {
4477
+ __accessCheck$4(obj, member, "read from private field");
4478
4478
  return getter ? getter.call(obj) : member.get(obj);
4479
4479
  };
4480
- var __privateAdd$3 = (obj, member, value) => {
4480
+ var __privateAdd$4 = (obj, member, value) => {
4481
4481
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
4482
4482
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4483
4483
  };
4484
- var __privateSet$2 = (obj, member, value, setter) => {
4485
- __accessCheck$3(obj, member, "write to private field");
4484
+ var __privateSet$3 = (obj, member, value, setter) => {
4485
+ __accessCheck$4(obj, member, "write to private field");
4486
4486
  setter ? setter.call(obj, value) : member.set(obj, value);
4487
4487
  return value;
4488
4488
  };
4489
- var _client$1, _client2$1;
4489
+ var _client$2, _client2$2;
4490
4490
  const defaultMutateOptions = {
4491
4491
  returnDocuments: false
4492
4492
  };
@@ -4552,17 +4552,17 @@
4552
4552
  const _Transaction = class extends BaseTransaction {
4553
4553
  constructor(operations, client, transactionId) {
4554
4554
  super(operations, transactionId);
4555
- __privateAdd$3(this, _client$1, void 0);
4556
- __privateSet$2(this, _client$1, client);
4555
+ __privateAdd$4(this, _client$2, void 0);
4556
+ __privateSet$3(this, _client$2, client);
4557
4557
  }
4558
4558
  clone() {
4559
- return new _Transaction([...this.operations], __privateGet$2(this, _client$1), this.trxId);
4559
+ return new _Transaction([...this.operations], __privateGet$3(this, _client$2), this.trxId);
4560
4560
  }
4561
4561
  commit(options) {
4562
- if (!__privateGet$2(this, _client$1)) {
4562
+ if (!__privateGet$3(this, _client$2)) {
4563
4563
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
4564
4564
  }
4565
- return __privateGet$2(this, _client$1).mutate(this.serialize(), Object.assign({
4565
+ return __privateGet$3(this, _client$2).mutate(this.serialize(), Object.assign({
4566
4566
  transactionId: this.trxId
4567
4567
  }, defaultMutateOptions, options || {}));
4568
4568
  }
@@ -4575,7 +4575,7 @@
4575
4575
  });
4576
4576
  }
4577
4577
  if (isBuilder) {
4578
- const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$2(this, _client$1)));
4578
+ const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$3(this, _client$2)));
4579
4579
  if (!(patch instanceof Patch)) {
4580
4580
  throw new Error("function passed to `patch()` must return the patch");
4581
4581
  }
@@ -4592,21 +4592,21 @@
4592
4592
  }
4593
4593
  };
4594
4594
  let Transaction = _Transaction;
4595
- _client$1 = new WeakMap();
4595
+ _client$2 = new WeakMap();
4596
4596
  const _ObservableTransaction = class extends BaseTransaction {
4597
4597
  constructor(operations, client, transactionId) {
4598
4598
  super(operations, transactionId);
4599
- __privateAdd$3(this, _client2$1, void 0);
4600
- __privateSet$2(this, _client2$1, client);
4599
+ __privateAdd$4(this, _client2$2, void 0);
4600
+ __privateSet$3(this, _client2$2, client);
4601
4601
  }
4602
4602
  clone() {
4603
- return new _ObservableTransaction([...this.operations], __privateGet$2(this, _client2$1), this.trxId);
4603
+ return new _ObservableTransaction([...this.operations], __privateGet$3(this, _client2$2), this.trxId);
4604
4604
  }
4605
4605
  commit(options) {
4606
- if (!__privateGet$2(this, _client2$1)) {
4606
+ if (!__privateGet$3(this, _client2$2)) {
4607
4607
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
4608
4608
  }
4609
- return __privateGet$2(this, _client2$1).mutate(this.serialize(), Object.assign({
4609
+ return __privateGet$3(this, _client2$2).mutate(this.serialize(), Object.assign({
4610
4610
  transactionId: this.trxId
4611
4611
  }, defaultMutateOptions, options || {}));
4612
4612
  }
@@ -4619,7 +4619,7 @@
4619
4619
  });
4620
4620
  }
4621
4621
  if (isBuilder) {
4622
- const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$2(this, _client2$1)));
4622
+ const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$3(this, _client2$2)));
4623
4623
  if (!(patch instanceof ObservablePatch)) {
4624
4624
  throw new Error("function passed to `patch()` must return the patch");
4625
4625
  }
@@ -4636,7 +4636,7 @@
4636
4636
  }
4637
4637
  };
4638
4638
  let ObservableTransaction = _ObservableTransaction;
4639
- _client2$1 = new WeakMap();
4639
+ _client2$2 = new WeakMap();
4640
4640
  const excludeFalsey = (param, defValue) => {
4641
4641
  const value = typeof param === "undefined" ? defValue : param;
4642
4642
  return param === false ? void 0 : value;
@@ -4790,50 +4790,50 @@
4790
4790
  const observable = _requestObservable(client, httpRequest, options).pipe(filter(event => event.type === "response"), map(event => event.body));
4791
4791
  return observable;
4792
4792
  }
4793
- var __accessCheck$2 = (obj, member, msg) => {
4793
+ var __accessCheck$3 = (obj, member, msg) => {
4794
4794
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
4795
4795
  };
4796
- var __privateGet$1 = (obj, member, getter) => {
4797
- __accessCheck$2(obj, member, "read from private field");
4796
+ var __privateGet$2 = (obj, member, getter) => {
4797
+ __accessCheck$3(obj, member, "read from private field");
4798
4798
  return getter ? getter.call(obj) : member.get(obj);
4799
4799
  };
4800
- var __privateAdd$2 = (obj, member, value) => {
4800
+ var __privateAdd$3 = (obj, member, value) => {
4801
4801
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
4802
4802
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4803
4803
  };
4804
- var __privateSet$1 = (obj, member, value, setter) => {
4805
- __accessCheck$2(obj, member, "write to private field");
4804
+ var __privateSet$2 = (obj, member, value, setter) => {
4805
+ __accessCheck$3(obj, member, "write to private field");
4806
4806
  setter ? setter.call(obj, value) : member.set(obj, value);
4807
4807
  return value;
4808
4808
  };
4809
- var _client, _httpRequest$1, _client2, _httpRequest2$1;
4809
+ var _client$1, _httpRequest$2, _client2$1, _httpRequest2$2;
4810
4810
  class ObservableAssetsClient {
4811
4811
  constructor(client, httpRequest) {
4812
- __privateAdd$2(this, _client, void 0);
4813
- __privateAdd$2(this, _httpRequest$1, void 0);
4814
- __privateSet$1(this, _client, client);
4815
- __privateSet$1(this, _httpRequest$1, httpRequest);
4812
+ __privateAdd$3(this, _client$1, void 0);
4813
+ __privateAdd$3(this, _httpRequest$2, void 0);
4814
+ __privateSet$2(this, _client$1, client);
4815
+ __privateSet$2(this, _httpRequest$2, httpRequest);
4816
4816
  }
4817
4817
  upload(assetType, body, options) {
4818
- return _upload(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), assetType, body, options);
4818
+ return _upload(__privateGet$2(this, _client$1), __privateGet$2(this, _httpRequest$2), assetType, body, options);
4819
4819
  }
4820
4820
  }
4821
- _client = new WeakMap();
4822
- _httpRequest$1 = new WeakMap();
4821
+ _client$1 = new WeakMap();
4822
+ _httpRequest$2 = new WeakMap();
4823
4823
  class AssetsClient {
4824
4824
  constructor(client, httpRequest) {
4825
- __privateAdd$2(this, _client2, void 0);
4826
- __privateAdd$2(this, _httpRequest2$1, void 0);
4827
- __privateSet$1(this, _client2, client);
4828
- __privateSet$1(this, _httpRequest2$1, httpRequest);
4825
+ __privateAdd$3(this, _client2$1, void 0);
4826
+ __privateAdd$3(this, _httpRequest2$2, void 0);
4827
+ __privateSet$2(this, _client2$1, client);
4828
+ __privateSet$2(this, _httpRequest2$2, httpRequest);
4829
4829
  }
4830
4830
  upload(assetType, body, options) {
4831
- const observable = _upload(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), assetType, body, options);
4831
+ const observable = _upload(__privateGet$2(this, _client2$1), __privateGet$2(this, _httpRequest2$2), assetType, body, options);
4832
4832
  return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
4833
4833
  }
4834
4834
  }
4835
- _client2 = new WeakMap();
4836
- _httpRequest2$1 = new WeakMap();
4835
+ _client2$1 = new WeakMap();
4836
+ _httpRequest2$2 = new WeakMap();
4837
4837
  function _upload(client, httpRequest, assetType, body) {
4838
4838
  let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
4839
4839
  validateAssetType(assetType);
@@ -4887,31 +4887,65 @@
4887
4887
  contentType: file.type
4888
4888
  }, opts);
4889
4889
  }
4890
- class BaseAuthClient {
4890
+ var __accessCheck$2 = (obj, member, msg) => {
4891
+ if (!member.has(obj)) throw TypeError("Cannot " + msg);
4892
+ };
4893
+ var __privateGet$1 = (obj, member, getter) => {
4894
+ __accessCheck$2(obj, member, "read from private field");
4895
+ return getter ? getter.call(obj) : member.get(obj);
4896
+ };
4897
+ var __privateAdd$2 = (obj, member, value) => {
4898
+ if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
4899
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4900
+ };
4901
+ var __privateSet$1 = (obj, member, value, setter) => {
4902
+ __accessCheck$2(obj, member, "write to private field");
4903
+ setter ? setter.call(obj, value) : member.set(obj, value);
4904
+ return value;
4905
+ };
4906
+ var _client, _httpRequest$1, _client2, _httpRequest2$1;
4907
+ class ObservableAuthClient {
4908
+ constructor(client, httpRequest) {
4909
+ __privateAdd$2(this, _client, void 0);
4910
+ __privateAdd$2(this, _httpRequest$1, void 0);
4911
+ __privateSet$1(this, _client, client);
4912
+ __privateSet$1(this, _httpRequest$1, httpRequest);
4913
+ }
4891
4914
  getLoginProviders() {
4892
- return this.client.request({
4915
+ return _request(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), {
4893
4916
  uri: "/auth/providers"
4894
4917
  });
4895
4918
  }
4896
4919
  logout() {
4897
- return this.client.request({
4920
+ return _request(__privateGet$1(this, _client), __privateGet$1(this, _httpRequest$1), {
4898
4921
  uri: "/auth/logout",
4899
4922
  method: "POST"
4900
4923
  });
4901
4924
  }
4902
4925
  }
4903
- class ObservableAuthClient extends BaseAuthClient {
4904
- constructor(client) {
4905
- super();
4906
- this.client = client;
4926
+ _client = new WeakMap();
4927
+ _httpRequest$1 = new WeakMap();
4928
+ class AuthClient {
4929
+ constructor(client, httpRequest) {
4930
+ __privateAdd$2(this, _client2, void 0);
4931
+ __privateAdd$2(this, _httpRequest2$1, void 0);
4932
+ __privateSet$1(this, _client2, client);
4933
+ __privateSet$1(this, _httpRequest2$1, httpRequest);
4907
4934
  }
4908
- }
4909
- class AuthClient extends BaseAuthClient {
4910
- constructor(client) {
4911
- super();
4912
- this.client = client;
4935
+ getLoginProviders() {
4936
+ return lastValueFrom(_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
4937
+ uri: "/auth/providers"
4938
+ }));
4939
+ }
4940
+ logout() {
4941
+ return lastValueFrom(_request(__privateGet$1(this, _client2), __privateGet$1(this, _httpRequest2$1), {
4942
+ uri: "/auth/logout",
4943
+ method: "POST"
4944
+ }));
4913
4945
  }
4914
4946
  }
4947
+ _client2 = new WeakMap();
4948
+ _httpRequest2$1 = new WeakMap();
4915
4949
  const BASE_URL = "https://docs.sanity.io/help/";
4916
4950
  function generateHelpUrl(slug) {
4917
4951
  return BASE_URL + slug;
@@ -5255,11 +5289,21 @@
5255
5289
  setter ? setter.call(obj, value) : member.set(obj, value);
5256
5290
  return value;
5257
5291
  };
5258
- var _clientConfig, _httpRequest, _httpRequest2;
5259
- class BaseSanityClient {
5260
- constructor(config) {
5292
+ var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
5293
+ const _ObservableSanityClient = class {
5294
+ constructor(httpRequest, config) {
5261
5295
  __privateAdd(this, _clientConfig, void 0);
5296
+ __privateAdd(this, _httpRequest, void 0);
5262
5297
  this.config(config);
5298
+ __privateSet(this, _httpRequest, httpRequest);
5299
+ this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
5300
+ this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
5301
+ this.datasets = new ObservableDatasetsClient(this);
5302
+ this.projects = new ObservableProjectsClient(this);
5303
+ this.users = new ObservableUsersClient(this);
5304
+ }
5305
+ clone() {
5306
+ return new _ObservableSanityClient(__privateGet(this, _httpRequest), this.config());
5263
5307
  }
5264
5308
  config(newConfig) {
5265
5309
  if (newConfig === void 0) {
@@ -5273,40 +5317,6 @@
5273
5317
  __privateSet(this, _clientConfig, initConfig(newConfig, __privateGet(this, _clientConfig) || {}));
5274
5318
  return this;
5275
5319
  }
5276
- isPromiseAPI() {
5277
- return this instanceof SanityClient;
5278
- }
5279
- getUrl(uri) {
5280
- let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5281
- const base = canUseCdn ? __privateGet(this, _clientConfig).cdnUrl : __privateGet(this, _clientConfig).url;
5282
- return "".concat(base, "/").concat(uri.replace(/^\//, ""));
5283
- }
5284
- getDataUrl(operation, path) {
5285
- const config = this.config();
5286
- const catalog = hasDataset(config);
5287
- const baseUri = "/".concat(operation, "/").concat(catalog);
5288
- const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
5289
- return "/data".concat(uri).replace(/\/($|\?)/, "$1");
5290
- }
5291
- }
5292
- _clientConfig = new WeakMap();
5293
- const _ObservableSanityClient = class extends BaseSanityClient {
5294
- constructor(httpRequest, config) {
5295
- super(config);
5296
- __privateAdd(this, _httpRequest, void 0);
5297
- __privateSet(this, _httpRequest, httpRequest);
5298
- this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
5299
- this.auth = new ObservableAuthClient(this);
5300
- this.datasets = new ObservableDatasetsClient(this);
5301
- this.projects = new ObservableProjectsClient(this);
5302
- this.users = new ObservableUsersClient(this);
5303
- }
5304
- clone() {
5305
- return new _ObservableSanityClient(__privateGet(this, _httpRequest), this.config());
5306
- }
5307
- config(newConfig) {
5308
- return super.config(newConfig);
5309
- }
5310
5320
  withConfig(newConfig) {
5311
5321
  return new _ObservableSanityClient(__privateGet(this, _httpRequest), {
5312
5322
  ...this.config(),
@@ -5347,30 +5357,51 @@
5347
5357
  request(options) {
5348
5358
  return _request(this, __privateGet(this, _httpRequest), options);
5349
5359
  }
5360
+ getUrl(uri) {
5361
+ let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5362
+ const base = canUseCdn ? __privateGet(this, _clientConfig).cdnUrl : __privateGet(this, _clientConfig).url;
5363
+ return "".concat(base, "/").concat(uri.replace(/^\//, ""));
5364
+ }
5365
+ getDataUrl(operation, path) {
5366
+ const config = this.config();
5367
+ const catalog = hasDataset(config);
5368
+ const baseUri = "/".concat(operation, "/").concat(catalog);
5369
+ const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
5370
+ return "/data".concat(uri).replace(/\/($|\?)/, "$1");
5371
+ }
5350
5372
  };
5351
5373
  let ObservableSanityClient = _ObservableSanityClient;
5374
+ _clientConfig = new WeakMap();
5352
5375
  _httpRequest = new WeakMap();
5353
- const _SanityClient = class extends BaseSanityClient {
5376
+ const _SanityClient = class {
5354
5377
  constructor(httpRequest, config) {
5355
- super(config);
5378
+ __privateAdd(this, _clientConfig2, void 0);
5356
5379
  __privateAdd(this, _httpRequest2, void 0);
5357
5380
  this.listen = _listen;
5381
+ this.observable = new ObservableSanityClient(httpRequest, config);
5382
+ this.config(config);
5358
5383
  __privateSet(this, _httpRequest2, httpRequest);
5359
5384
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
5360
- this.auth = new AuthClient(this);
5385
+ this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
5361
5386
  this.datasets = new DatasetsClient(this);
5362
5387
  this.projects = new ProjectsClient(this);
5363
5388
  this.users = new UsersClient(this);
5364
- this.observable = new ObservableSanityClient(httpRequest, this.config());
5365
5389
  }
5366
5390
  clone() {
5367
5391
  return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
5368
5392
  }
5369
5393
  config(newConfig) {
5370
- if (newConfig) {
5371
- this.observable.config(newConfig);
5394
+ if (newConfig === void 0) {
5395
+ return {
5396
+ ...__privateGet(this, _clientConfig2)
5397
+ };
5372
5398
  }
5373
- return super.config(newConfig);
5399
+ if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
5400
+ throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
5401
+ }
5402
+ this.observable.config(newConfig);
5403
+ __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {}));
5404
+ return this;
5374
5405
  }
5375
5406
  withConfig(newConfig) {
5376
5407
  return new _SanityClient(__privateGet(this, _httpRequest2), {
@@ -5415,8 +5446,21 @@
5415
5446
  dataRequest(endpoint, body, options) {
5416
5447
  return lastValueFrom(_dataRequest(this, __privateGet(this, _httpRequest2), endpoint, body, options));
5417
5448
  }
5449
+ getUrl(uri) {
5450
+ let canUseCdn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5451
+ const base = canUseCdn ? __privateGet(this, _clientConfig2).cdnUrl : __privateGet(this, _clientConfig2).url;
5452
+ return "".concat(base, "/").concat(uri.replace(/^\//, ""));
5453
+ }
5454
+ getDataUrl(operation, path) {
5455
+ const config = this.config();
5456
+ const catalog = hasDataset(config);
5457
+ const baseUri = "/".concat(operation, "/").concat(catalog);
5458
+ const uri = path ? "".concat(baseUri, "/").concat(path) : baseUri;
5459
+ return "/data".concat(uri).replace(/\/($|\?)/, "$1");
5460
+ }
5418
5461
  };
5419
5462
  let SanityClient = _SanityClient;
5463
+ _clientConfig2 = new WeakMap();
5420
5464
  _httpRequest2 = new WeakMap();
5421
5465
  const httpRequest = defineHttpRequest(envMiddleware);
5422
5466
  const requester = httpRequest.defaultRequester;
@@ -5425,7 +5469,6 @@
5425
5469
  }
5426
5470
 
5427
5471
  exports.BasePatch = BasePatch;
5428
- exports.BaseSanityClient = BaseSanityClient;
5429
5472
  exports.BaseTransaction = BaseTransaction;
5430
5473
  exports.ClientError = ClientError;
5431
5474
  exports.ObservablePatch = ObservablePatch;