@sanity/client 6.28.0-resources.0 → 6.28.1

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.cjs CHANGED
@@ -737,20 +737,11 @@ function _create(client, httpRequest, doc, op, options = {}) {
737
737
  const mutation = { [op]: doc }, opts = Object.assign({ returnFirst: !0, returnDocuments: !0 }, options);
738
738
  return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
739
739
  }
740
- function _resourceBase(resource) {
741
- return `/${resource.type}/${resource.id}`;
742
- }
743
- function isDataRequestUri(uri, resource) {
744
- return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/`) === 0 : uri.indexOf("/data/") === 0;
745
- }
746
- function isDataQueryRequestUri(uri, resource) {
747
- return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/query`) === 0 : uri.indexOf("/data/query") === 0;
748
- }
749
740
  function _requestObservable(client, httpRequest, options) {
750
- const uri = options.url || options.uri, config$1 = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && isDataRequestUri(uri, config$1.experimental_resource) : options.canUseCdn;
741
+ const uri = options.url || options.uri, config$1 = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
751
742
  let useCdn = (options.useCdn ?? config$1.useCdn) && canUseCdn;
752
743
  const tag = options.tag && config$1.requestTagPrefix ? [config$1.requestTagPrefix, options.tag].join(".") : options.tag || config$1.requestTagPrefix;
753
- if (tag && options.tag !== null && (options.query = { tag: config.requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && isDataQueryRequestUri(uri, config$1.experimental_resource)) {
744
+ if (tag && options.tag !== null && (options.query = { tag: config.requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
754
745
  const resultSourceMap = options.resultSourceMap ?? config$1.resultSourceMap;
755
746
  resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
756
747
  const perspectiveOption = options.perspective || config$1.perspective;
@@ -777,18 +768,12 @@ function _request(client, httpRequest, options) {
777
768
  );
778
769
  }
779
770
  function _getDataUrl(client, operation, path) {
780
- const config$1 = client.config();
781
- if (config$1.experimental_resource) {
782
- const baseUri2 = `/${operation}`;
783
- return (path ? `${baseUri2}/${path}` : baseUri2).replace(/\/($|\?)/, "$1");
784
- }
785
- const catalog = config.hasDataset(config$1), baseUri = `/${operation}/${catalog}`;
771
+ const config$1 = client.config(), catalog = config.hasDataset(config$1), baseUri = `/${operation}/${catalog}`;
786
772
  return `/data${path ? `${baseUri}/${path}` : baseUri}`.replace(/\/($|\?)/, "$1");
787
773
  }
788
774
  function _getUrl(client, uri, canUseCdn = !1) {
789
- const { url, cdnUrl, experimental_resource } = client.config();
790
- let base = canUseCdn ? cdnUrl : url;
791
- return experimental_resource && (uri.indexOf("/users") !== -1 || uri.indexOf("/assets") !== -1) && (base = base.replace(_resourceBase(experimental_resource), "")), `${base}/${uri.replace(/^\//, "")}`;
775
+ const { url, cdnUrl } = client.config();
776
+ return `${canUseCdn ? cdnUrl : url}/${uri.replace(/^\//, "")}`;
792
777
  }
793
778
  function _withAbortSignal(signal) {
794
779
  return (input) => new rxjs.Observable((observer) => {
@@ -842,7 +827,7 @@ function _upload(client, httpRequest, assetType, body, opts = {}) {
842
827
  config.validateAssetType(assetType);
843
828
  let meta = opts.extract || void 0;
844
829
  meta && !meta.length && (meta = ["none"]);
845
- const config$1 = client.config(), resource = config$1.experimental_resource, dataset = resource ? void 0 : config.hasDataset(config$1), assetEndpoint = assetType === "image" ? "images" : "files", options = optionsFromFile(opts, body), { tag, label, title, description, creditLine, filename, source } = options, query = {
830
+ const dataset = config.hasDataset(client.config()), assetEndpoint = assetType === "image" ? "images" : "files", options = optionsFromFile(opts, body), { tag, label, title, description, creditLine, filename, source } = options, query = {
846
831
  label,
847
832
  title,
848
833
  description,
@@ -854,7 +839,7 @@ function _upload(client, httpRequest, assetType, body, opts = {}) {
854
839
  tag,
855
840
  method: "POST",
856
841
  timeout: options.timeout || 0,
857
- uri: resource ? `/assets/${resource.type}/${resource.id}/${assetEndpoint}` : `/assets/${assetEndpoint}/${dataset}`,
842
+ uri: `/assets/${assetEndpoint}/${dataset}`,
858
843
  headers: options.contentType ? { "Content-Type": options.contentType } : {},
859
844
  query,
860
845
  body
@@ -1109,23 +1094,6 @@ class DatasetsClient {
1109
1094
  );
1110
1095
  }
1111
1096
  }
1112
- class ThrowingDatasetsClient extends DatasetsClient {
1113
- constructor(client, httpRequest) {
1114
- super(client, httpRequest);
1115
- }
1116
- create() {
1117
- throw new Error("cannot create dataset with the current client configuration");
1118
- }
1119
- edit() {
1120
- throw new Error("cannot edit dataset with the current client configuration");
1121
- }
1122
- delete() {
1123
- throw new Error("cannot delete dataset with the current client configuration");
1124
- }
1125
- list() {
1126
- throw new Error("cannot list dataset with the current client configuration");
1127
- }
1128
- }
1129
1097
  function _modify(client, httpRequest, method, name2, options) {
1130
1098
  return config.dataset(name2), _request(client, httpRequest, {
1131
1099
  method,
@@ -1381,7 +1349,7 @@ class SanityClient {
1381
1349
  */
1382
1350
  listen = _listen;
1383
1351
  constructor(httpRequest, config$1 = config.defaultConfig) {
1384
- this.config(config$1), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = this.#clientConfig.experimental_resource ? new ThrowingDatasetsClient(this, this.#httpRequest) : new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config$1);
1352
+ this.config(config$1), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config$1);
1385
1353
  }
1386
1354
  /**
1387
1355
  * Clone the client - returns a new instance
@@ -1557,7 +1525,7 @@ function defineDeprecatedCreateClient(createClient2) {
1557
1525
  return config.printNoDefaultExport(), createClient2(config$1);
1558
1526
  };
1559
1527
  }
1560
- var name = "@sanity/client", version = "6.28.0-resources.0";
1528
+ var name = "@sanity/client", version = "6.28.1";
1561
1529
  const middleware = [
1562
1530
  middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
1563
1531
  middleware$1.headers({ "User-Agent": `${name} ${version}` }),