@sanity/client 5.2.0 → 5.2.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.
@@ -94,7 +94,7 @@ function defineHttpRequest(envMiddleware) {
94
94
  return httpRequest;
95
95
  }
96
96
  const projectHeader = "X-Sanity-Project-ID";
97
- var getRequestOptions = function (config) {
97
+ function requestOptions(config) {
98
98
  let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
99
99
  const headers = {};
100
100
  const token = overrides.token || config.token;
@@ -113,7 +113,7 @@ var getRequestOptions = function (config) {
113
113
  json: true,
114
114
  withCredentials
115
115
  });
116
- };
116
+ }
117
117
  function getSelection(sel) {
118
118
  if (typeof sel === "string" || Array.isArray(sel)) {
119
119
  return {
@@ -189,7 +189,7 @@ const requestTag = tag => {
189
189
  }
190
190
  return tag;
191
191
  };
192
- var encodeQueryString = _ref => {
192
+ const encodeQueryString = _ref => {
193
193
  let {
194
194
  query,
195
195
  params = {},
@@ -794,7 +794,7 @@ function _requestObservable(client, httpRequest, options) {
794
794
  ...options.query
795
795
  };
796
796
  }
797
- const reqOptions = getRequestOptions(config, Object.assign({}, options, {
797
+ const reqOptions = requestOptions(config, Object.assign({}, options, {
798
798
  url: _getUrl(client, uri, useCdn)
799
799
  }));
800
800
  const request = new rxjs.Observable(subscriber =>
@@ -950,7 +950,7 @@ const BASE_URL = "https://www.sanity.io/help/";
950
950
  function generateHelpUrl(slug) {
951
951
  return BASE_URL + slug;
952
952
  }
953
- var once = fn => {
953
+ function once(fn) {
954
954
  let didCall = false;
955
955
  let returnValue;
956
956
  return function () {
@@ -961,7 +961,7 @@ var once = fn => {
961
961
  didCall = true;
962
962
  return returnValue;
963
963
  };
964
- };
964
+ }
965
965
  const createWarningPrinter = message =>
966
966
  // eslint-disable-next-line no-console
967
967
  once(function () {
@@ -973,6 +973,7 @@ once(function () {
973
973
  const printCdnWarning = createWarningPrinter(["You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and", "cheaper. Think about it! For more info, see ".concat(generateHelpUrl("js-client-cdn-configuration"), " "), "To hide this warning, please set the `useCdn` option to either `true` or `false` when creating", "the client."]);
974
974
  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.")]);
975
975
  const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
976
+ const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead"]);
976
977
  const defaultCdnHost = "apicdn.sanity.io";
977
978
  const defaultConfig = {
978
979
  apiHost: "https://api.sanity.io",
@@ -1042,7 +1043,7 @@ var defaults = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj))
1042
1043
  target[prop] = typeof obj[prop] === "undefined" ? defaults[prop] : obj[prop];
1043
1044
  return target;
1044
1045
  }, {});
1045
- var pick = (obj, props) => props.reduce((selection, prop) => {
1046
+ const pick = (obj, props) => props.reduce((selection, prop) => {
1046
1047
  if (typeof obj[prop] === "undefined") {
1047
1048
  return selection;
1048
1049
  }
@@ -1727,12 +1728,13 @@ const _SanityClient = class {
1727
1728
  let SanityClient = _SanityClient;
1728
1729
  _clientConfig2 = new WeakMap();
1729
1730
  _httpRequest2 = new WeakMap();
1730
- function migrationNotice() {
1731
- throw new TypeError("The default export of @sanity/client has been deprecated. Use the named export `createClient` instead");
1732
- }
1733
1731
  const httpRequest = defineHttpRequest(envMiddleware);
1734
1732
  const requester = httpRequest.defaultRequester;
1735
1733
  const createClient = config => new SanityClient(httpRequest, config);
1734
+ function deprecatedCreateClient(config) {
1735
+ printNoDefaultExport();
1736
+ return new SanityClient(httpRequest, config);
1737
+ }
1736
1738
  exports.BasePatch = BasePatch;
1737
1739
  exports.BaseTransaction = BaseTransaction;
1738
1740
  exports.ClientError = ClientError;
@@ -1744,6 +1746,6 @@ exports.SanityClient = SanityClient;
1744
1746
  exports.ServerError = ServerError;
1745
1747
  exports.Transaction = Transaction;
1746
1748
  exports.createClient = createClient;
1747
- exports.default = migrationNotice;
1749
+ exports.default = deprecatedCreateClient;
1748
1750
  exports.requester = requester;
1749
1751
  //# sourceMappingURL=index.browser.cjs.map