@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.cjs
CHANGED
|
@@ -889,17 +889,16 @@ function _create(client, httpRequest, doc, op, options = {}) {
|
|
|
889
889
|
const mutation = { [op]: doc }, opts = Object.assign({ returnFirst: !0, returnDocuments: !0 }, options);
|
|
890
890
|
return _dataRequest(client, httpRequest, "mutate", { mutations: [mutation] }, opts);
|
|
891
891
|
}
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
), isData = (config, uri) => uri.startsWith("/data/") || isQuery(config, uri) || isMutate(config, uri) || isDoc(config, uri) || isListener(config, uri) || isHistory(config, uri);
|
|
892
|
+
const resourceDatasetRegex = /^\/projects\/([^/]+)\/datasets\/([^/]+)\/([^/^?]+)\/?/, isResourceDataEndpoint = (config, uri, endpoint) => {
|
|
893
|
+
if (!config["~experimental_resource"])
|
|
894
|
+
return !1;
|
|
895
|
+
if (uri.startsWith(
|
|
896
|
+
`/${config["~experimental_resource"].type}/${config["~experimental_resource"].id}/${endpoint}`
|
|
897
|
+
))
|
|
898
|
+
return !0;
|
|
899
|
+
const match = uri.match(resourceDatasetRegex);
|
|
900
|
+
return match ? match[3] === endpoint : !1;
|
|
901
|
+
}, 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);
|
|
903
902
|
function _requestObservable(client, httpRequest, options) {
|
|
904
903
|
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;
|
|
905
904
|
let useCdn = (options.useCdn ?? config.useCdn) && canUseCdn;
|