@sanity/client 6.28.0-resources-projects.1 → 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/index.browser.cjs +11 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +11 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +12 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/data/dataMethods.ts +20 -6
- package/umd/sanityClient.js +11 -2
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.cjs
CHANGED
|
@@ -907,7 +907,7 @@ function isDataRequestUri(uri, resource) {
|
|
|
907
907
|
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/`) === 0 : uri.indexOf("/data/") === 0;
|
|
908
908
|
}
|
|
909
909
|
function isDataQueryRequestUri(uri, resource) {
|
|
910
|
-
return resource && resource.type
|
|
910
|
+
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;
|
|
911
911
|
}
|
|
912
912
|
function _requestObservable(client, httpRequest, options) {
|
|
913
913
|
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;
|
|
@@ -942,6 +942,11 @@ function _request(client, httpRequest, options) {
|
|
|
942
942
|
function _getDataUrl(client, operation, path) {
|
|
943
943
|
const config = client.config();
|
|
944
944
|
if (config.experimental_resource) {
|
|
945
|
+
const resource = config.experimental_resource;
|
|
946
|
+
if (resource.type === "projects" && "dataset" in resource) {
|
|
947
|
+
const baseUri3 = `${_resourceBase(resource)}/${operation}`;
|
|
948
|
+
return (path ? `${baseUri3}/${path}` : baseUri3).replace(/\/($|\?)/, "$1");
|
|
949
|
+
}
|
|
945
950
|
const baseUri2 = `/${operation}`;
|
|
946
951
|
return (path ? `${baseUri2}/${path}` : baseUri2).replace(/\/($|\?)/, "$1");
|
|
947
952
|
}
|
|
@@ -951,7 +956,11 @@ function _getDataUrl(client, operation, path) {
|
|
|
951
956
|
function _getUrl(client, uri, canUseCdn = !1) {
|
|
952
957
|
const { url, cdnUrl, experimental_resource } = client.config();
|
|
953
958
|
let base = canUseCdn ? cdnUrl : url;
|
|
954
|
-
|
|
959
|
+
if (experimental_resource) {
|
|
960
|
+
const resourceBase = _resourceBase(experimental_resource);
|
|
961
|
+
(uri.indexOf("/users") !== -1 || uri.indexOf("/assets") !== -1 || experimental_resource.type === "projects" && uri.indexOf(resourceBase) === 0) && (base = base.replace(resourceBase, ""));
|
|
962
|
+
}
|
|
963
|
+
return `${base}/${uri.replace(/^\//, "")}`;
|
|
955
964
|
}
|
|
956
965
|
function _withAbortSignal(signal) {
|
|
957
966
|
return (input) => new rxjs.Observable((observer) => {
|