@sanity/client 6.28.3-resources.0 → 6.28.3-resources.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.browser.cjs +10 -11
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +10 -11
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +11 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -12
- package/dist/index.js.map +1 -1
- package/package.json +6 -25
- package/src/data/dataMethods.ts +23 -25
- package/umd/sanityClient.js +10 -11
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -871,17 +871,16 @@ function _create(client, httpRequest, doc, op, options = {}) {
|
|
|
871
871
|
const mutation = { [op]: doc }, opts = Object.assign({ returnFirst: !0, returnDocuments: !0 }, options);
|
|
872
872
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
873
873
|
}
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
), isData = (config, uri) => uri.startsWith("/data/") || isQuery(config, uri) || isMutate(config, uri) || isDoc(config, uri) || isListener(config, uri) || isHistory(config, uri);
|
|
874
|
+
const resourceDatasetRegex = /^\/projects\/([^/]+)\/datasets\/([^/]+)\/([^/^?]+)\/?/, isResourceDataEndpoint = (config, uri, endpoint) => {
|
|
875
|
+
if (!config["~experimental_resource"])
|
|
876
|
+
return !1;
|
|
877
|
+
if (uri.startsWith(
|
|
878
|
+
`/${config["~experimental_resource"].type}/${config["~experimental_resource"].id}/${endpoint}`
|
|
879
|
+
))
|
|
880
|
+
return !0;
|
|
881
|
+
const match = uri.match(resourceDatasetRegex);
|
|
882
|
+
return match ? match[3] === endpoint : !1;
|
|
883
|
+
}, isQuery = (config, uri) => uri.startsWith("/data/query/") || isResourceDataEndpoint(config, uri, "query"), isMutate = (config, uri) => uri.startsWith("/data/mutate/") || isResourceDataEndpoint(config, uri, "mutate"), isDoc = (config, uri) => uri.startsWith("/data/doc/") || isResourceDataEndpoint(config, uri, "doc"), isListener = (config, uri) => uri.startsWith("/data/listen/") || isResourceDataEndpoint(config, uri, "listen"), isHistory = (config, uri) => uri.startsWith("/data/history/") || isResourceDataEndpoint(config, uri, "history"), isData = (config, uri) => uri.startsWith("/data/") || isQuery(config, uri) || isMutate(config, uri) || isDoc(config, uri) || isListener(config, uri) || isHistory(config, uri);
|
|
885
884
|
function _requestObservable(client, httpRequest, options) {
|
|
886
885
|
const uri = options.url || options.uri, config = client.config(), canUseCdn = typeof options.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && isData(config, uri) : options.canUseCdn;
|
|
887
886
|
let useCdn = (options.useCdn ?? config.useCdn) && canUseCdn;
|