@sanity/client 6.4.7 → 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.cjs CHANGED
@@ -8,7 +8,7 @@ var getIt = require('get-it');
8
8
  var rxjs = require('rxjs');
9
9
  var operators = require('rxjs/operators');
10
10
  var name = "@sanity/client";
11
- var version = "6.4.7";
11
+ var version = "6.4.9";
12
12
  const middleware = [middleware$1.debug({
13
13
  verbose: true,
14
14
  namespace: "sanity:client"
@@ -245,6 +245,7 @@ once(function () {
245
245
  return console.warn(message.join(" "), ...args);
246
246
  });
247
247
  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."]);
248
+ 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."]);
248
249
  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.")]);
249
250
  const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
250
251
  const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]);
@@ -1025,7 +1026,7 @@ function _requestObservable(client, httpRequest, options) {
1025
1026
  const uri = options.url || options.uri;
1026
1027
  const config = client.config();
1027
1028
  const canUseCdn = typeof options.canUseCdn === "undefined" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
1028
- const useCdn = config.useCdn && canUseCdn;
1029
+ let useCdn = config.useCdn && canUseCdn;
1029
1030
  const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
1030
1031
  if (tag) {
1031
1032
  options.query = {
@@ -1047,6 +1048,10 @@ function _requestObservable(client, httpRequest, options) {
1047
1048
  perspective,
1048
1049
  ...options.query
1049
1050
  };
1051
+ if (perspective === "previewDrafts" && useCdn) {
1052
+ useCdn = false;
1053
+ printCdnPreviewDraftsWarning();
1054
+ }
1050
1055
  }
1051
1056
  }
1052
1057
  const reqOptions = requestOptions(config, Object.assign({}, options, {