@sanity/client 6.28.0-resources-projects.0 → 6.28.0-resources-projects.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/_chunks-cjs/config.cjs +5 -1
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +5 -1
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +17 -4
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +17 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +13 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +3 -1
- package/src/data/dataMethods.ts +25 -2
- package/umd/sanityClient.js +17 -4
- package/umd/sanityClient.min.js +2 -2
package/dist/index.js
CHANGED
|
@@ -721,13 +721,13 @@ function _create(client, httpRequest, doc, op, options = {}) {
|
|
|
721
721
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
722
722
|
}
|
|
723
723
|
function _resourceBase(resource) {
|
|
724
|
-
return `/${resource.type}/${resource.id}`;
|
|
724
|
+
return resource.type === "projects" && "dataset" in resource ? `/projects/${resource.id}/datasets/${resource.dataset}` : `/${resource.type}/${resource.id}`;
|
|
725
725
|
}
|
|
726
726
|
function isDataRequestUri(uri, resource) {
|
|
727
727
|
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/`) === 0 : uri.indexOf("/data/") === 0;
|
|
728
728
|
}
|
|
729
729
|
function isDataQueryRequestUri(uri, resource) {
|
|
730
|
-
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/query`) === 0 : uri.indexOf("/data/query") === 0;
|
|
730
|
+
return resource && resource.type === "projects" && "dataset" in resource ? uri.indexOf(`/projects/${resource.id}/datasets/${resource.dataset}/query`) === 0 : resource ? uri.indexOf(`/${_resourceBase(resource)}/data/query`) === 0 : uri.indexOf("/data/query") === 0;
|
|
731
731
|
}
|
|
732
732
|
function _requestObservable(client, httpRequest, options) {
|
|
733
733
|
const uri = options.url || options.uri, config = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && isDataRequestUri(uri, config.experimental_resource) : options.canUseCdn;
|
|
@@ -762,6 +762,11 @@ function _request(client, httpRequest, options) {
|
|
|
762
762
|
function _getDataUrl(client, operation, path) {
|
|
763
763
|
const config = client.config();
|
|
764
764
|
if (config.experimental_resource) {
|
|
765
|
+
const resource = config.experimental_resource;
|
|
766
|
+
if (resource.type === "projects" && "dataset" in resource) {
|
|
767
|
+
const baseUri3 = `${_resourceBase(resource)}/${operation}`;
|
|
768
|
+
return (path ? `${baseUri3}/${path}` : baseUri3).replace(/\/($|\?)/, "$1");
|
|
769
|
+
}
|
|
765
770
|
const baseUri2 = `/${operation}`;
|
|
766
771
|
return (path ? `${baseUri2}/${path}` : baseUri2).replace(/\/($|\?)/, "$1");
|
|
767
772
|
}
|
|
@@ -771,7 +776,11 @@ function _getDataUrl(client, operation, path) {
|
|
|
771
776
|
function _getUrl(client, uri, canUseCdn = !1) {
|
|
772
777
|
const { url, cdnUrl, experimental_resource } = client.config();
|
|
773
778
|
let base = canUseCdn ? cdnUrl : url;
|
|
774
|
-
|
|
779
|
+
if (experimental_resource) {
|
|
780
|
+
const resourceBase = _resourceBase(experimental_resource);
|
|
781
|
+
(uri.indexOf("/users") !== -1 || uri.indexOf("/assets") !== -1 || experimental_resource.type === "projects" && uri.indexOf(resourceBase) === 0) && (base = base.replace(resourceBase, ""));
|
|
782
|
+
}
|
|
783
|
+
return `${base}/${uri.replace(/^\//, "")}`;
|
|
775
784
|
}
|
|
776
785
|
function _withAbortSignal(signal) {
|
|
777
786
|
return (input) => new Observable((observer) => {
|
|
@@ -1540,7 +1549,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1540
1549
|
return printNoDefaultExport(), createClient2(config);
|
|
1541
1550
|
};
|
|
1542
1551
|
}
|
|
1543
|
-
var name = "@sanity/client", version = "6.28.0-resources-projects.
|
|
1552
|
+
var name = "@sanity/client", version = "6.28.0-resources-projects.2";
|
|
1544
1553
|
const middleware = [
|
|
1545
1554
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1546
1555
|
headers({ "User-Agent": `${name} ${version}` }),
|