@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.js
CHANGED
|
@@ -889,7 +889,7 @@ function isDataRequestUri(uri, resource) {
|
|
|
889
889
|
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/`) === 0 : uri.indexOf("/data/") === 0;
|
|
890
890
|
}
|
|
891
891
|
function isDataQueryRequestUri(uri, resource) {
|
|
892
|
-
return resource && resource.type
|
|
892
|
+
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;
|
|
893
893
|
}
|
|
894
894
|
function _requestObservable(client, httpRequest, options) {
|
|
895
895
|
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;
|
|
@@ -924,6 +924,11 @@ function _request(client, httpRequest, options) {
|
|
|
924
924
|
function _getDataUrl(client, operation, path) {
|
|
925
925
|
const config = client.config();
|
|
926
926
|
if (config.experimental_resource) {
|
|
927
|
+
const resource = config.experimental_resource;
|
|
928
|
+
if (resource.type === "projects" && "dataset" in resource) {
|
|
929
|
+
const baseUri3 = `${_resourceBase(resource)}/${operation}`;
|
|
930
|
+
return (path ? `${baseUri3}/${path}` : baseUri3).replace(/\/($|\?)/, "$1");
|
|
931
|
+
}
|
|
927
932
|
const baseUri2 = `/${operation}`;
|
|
928
933
|
return (path ? `${baseUri2}/${path}` : baseUri2).replace(/\/($|\?)/, "$1");
|
|
929
934
|
}
|
|
@@ -933,7 +938,11 @@ function _getDataUrl(client, operation, path) {
|
|
|
933
938
|
function _getUrl(client, uri, canUseCdn = !1) {
|
|
934
939
|
const { url, cdnUrl, experimental_resource } = client.config();
|
|
935
940
|
let base = canUseCdn ? cdnUrl : url;
|
|
936
|
-
|
|
941
|
+
if (experimental_resource) {
|
|
942
|
+
const resourceBase = _resourceBase(experimental_resource);
|
|
943
|
+
(uri.indexOf("/users") !== -1 || uri.indexOf("/assets") !== -1 || experimental_resource.type === "projects" && uri.indexOf(resourceBase) === 0) && (base = base.replace(resourceBase, ""));
|
|
944
|
+
}
|
|
945
|
+
return `${base}/${uri.replace(/^\//, "")}`;
|
|
937
946
|
}
|
|
938
947
|
function _withAbortSignal(signal) {
|
|
939
948
|
return (input) => new Observable((observer) => {
|