@sanity/client 6.4.8 → 6.4.10-canary.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.
@@ -225,6 +225,7 @@ once(function () {
225
225
  return console.warn(message.join(" "), ...args);
226
226
  });
227
227
  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."]);
228
+ 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."]);
228
229
  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.")]);
229
230
  const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
230
231
  const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]);
@@ -1005,7 +1006,7 @@ function _requestObservable(client, httpRequest, options) {
1005
1006
  const uri = options.url || options.uri;
1006
1007
  const config = client.config();
1007
1008
  const canUseCdn = typeof options.canUseCdn === "undefined" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
1008
- const useCdn = config.useCdn && canUseCdn;
1009
+ let useCdn = config.useCdn && canUseCdn;
1009
1010
  const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
1010
1011
  if (tag) {
1011
1012
  options.query = {
@@ -1027,6 +1028,10 @@ function _requestObservable(client, httpRequest, options) {
1027
1028
  perspective,
1028
1029
  ...options.query
1029
1030
  };
1031
+ if (perspective === "previewDrafts" && useCdn) {
1032
+ useCdn = false;
1033
+ printCdnPreviewDraftsWarning();
1034
+ }
1030
1035
  }
1031
1036
  }
1032
1037
  const reqOptions = requestOptions(config, Object.assign({}, options, {