@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.cjs
CHANGED
|
@@ -738,13 +738,13 @@ function _create(client, httpRequest, doc, op, options = {}) {
|
|
|
738
738
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
739
739
|
}
|
|
740
740
|
function _resourceBase(resource) {
|
|
741
|
-
return `/${resource.type}/${resource.id}`;
|
|
741
|
+
return resource.type === "projects" && "dataset" in resource ? `/projects/${resource.id}/datasets/${resource.dataset}` : `/${resource.type}/${resource.id}`;
|
|
742
742
|
}
|
|
743
743
|
function isDataRequestUri(uri, resource) {
|
|
744
744
|
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/`) === 0 : uri.indexOf("/data/") === 0;
|
|
745
745
|
}
|
|
746
746
|
function isDataQueryRequestUri(uri, resource) {
|
|
747
|
-
return resource ? uri.indexOf(`/${_resourceBase(resource)}/data/query`) === 0 : uri.indexOf("/data/query") === 0;
|
|
747
|
+
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;
|
|
748
748
|
}
|
|
749
749
|
function _requestObservable(client, httpRequest, options) {
|
|
750
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;
|
|
@@ -779,6 +779,11 @@ function _request(client, httpRequest, options) {
|
|
|
779
779
|
function _getDataUrl(client, operation, path) {
|
|
780
780
|
const config$1 = client.config();
|
|
781
781
|
if (config$1.experimental_resource) {
|
|
782
|
+
const resource = config$1.experimental_resource;
|
|
783
|
+
if (resource.type === "projects" && "dataset" in resource) {
|
|
784
|
+
const baseUri3 = `${_resourceBase(resource)}/${operation}`;
|
|
785
|
+
return (path ? `${baseUri3}/${path}` : baseUri3).replace(/\/($|\?)/, "$1");
|
|
786
|
+
}
|
|
782
787
|
const baseUri2 = `/${operation}`;
|
|
783
788
|
return (path ? `${baseUri2}/${path}` : baseUri2).replace(/\/($|\?)/, "$1");
|
|
784
789
|
}
|
|
@@ -788,7 +793,11 @@ function _getDataUrl(client, operation, path) {
|
|
|
788
793
|
function _getUrl(client, uri, canUseCdn = !1) {
|
|
789
794
|
const { url, cdnUrl, experimental_resource } = client.config();
|
|
790
795
|
let base = canUseCdn ? cdnUrl : url;
|
|
791
|
-
|
|
796
|
+
if (experimental_resource) {
|
|
797
|
+
const resourceBase = _resourceBase(experimental_resource);
|
|
798
|
+
(uri.indexOf("/users") !== -1 || uri.indexOf("/assets") !== -1 || experimental_resource.type === "projects" && uri.indexOf(resourceBase) === 0) && (base = base.replace(resourceBase, ""));
|
|
799
|
+
}
|
|
800
|
+
return `${base}/${uri.replace(/^\//, "")}`;
|
|
792
801
|
}
|
|
793
802
|
function _withAbortSignal(signal) {
|
|
794
803
|
return (input) => new rxjs.Observable((observer) => {
|
|
@@ -1557,7 +1566,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1557
1566
|
return config.printNoDefaultExport(), createClient2(config$1);
|
|
1558
1567
|
};
|
|
1559
1568
|
}
|
|
1560
|
-
var name = "@sanity/client", version = "6.28.0-resources-projects.
|
|
1569
|
+
var name = "@sanity/client", version = "6.28.0-resources-projects.2";
|
|
1561
1570
|
const middleware = [
|
|
1562
1571
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1563
1572
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|