@sanity/client 6.4.8 → 6.4.9
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 +6 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +6 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +7 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/data/dataMethods.ts +7 -1
- package/src/warnings.ts +5 -0
- package/umd/sanityClient.js +6 -1
- package/umd/sanityClient.min.js +3 -3
package/dist/index.browser.js
CHANGED
|
@@ -221,6 +221,7 @@ once(function () {
|
|
|
221
221
|
return console.warn(message.join(" "), ...args);
|
|
222
222
|
});
|
|
223
223
|
const printCdnWarning = createWarningPrinter(["Since you haven't set a value for `useCdn`, we will deliver content using our", "global, edge-cached API-CDN. If you wish to have content delivered faster, set", "`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."]);
|
|
224
|
+
const printCdnPreviewDraftsWarning = createWarningPrinter(["The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.", "The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."]);
|
|
224
225
|
const printBrowserTokenWarning = createWarningPrinter(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.", "See ".concat(generateHelpUrl("js-client-browser-token"), " for more information and how to hide this warning.")]);
|
|
225
226
|
const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
|
|
226
227
|
const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]);
|
|
@@ -1001,7 +1002,7 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
1001
1002
|
const uri = options.url || options.uri;
|
|
1002
1003
|
const config = client.config();
|
|
1003
1004
|
const canUseCdn = typeof options.canUseCdn === "undefined" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
|
|
1004
|
-
|
|
1005
|
+
let useCdn = config.useCdn && canUseCdn;
|
|
1005
1006
|
const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
|
|
1006
1007
|
if (tag) {
|
|
1007
1008
|
options.query = {
|
|
@@ -1023,6 +1024,10 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
1023
1024
|
perspective,
|
|
1024
1025
|
...options.query
|
|
1025
1026
|
};
|
|
1027
|
+
if (perspective === "previewDrafts" && useCdn) {
|
|
1028
|
+
useCdn = false;
|
|
1029
|
+
printCdnPreviewDraftsWarning();
|
|
1030
|
+
}
|
|
1026
1031
|
}
|
|
1027
1032
|
}
|
|
1028
1033
|
const reqOptions = requestOptions(config, Object.assign({}, options, {
|