@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.
package/dist/index.cjs CHANGED
@@ -15,7 +15,7 @@ function _interopDefaultCompat(e) {
15
15
  }
16
16
  var polyfilledEventSource__default = /*#__PURE__*/_interopDefaultCompat(polyfilledEventSource);
17
17
  var name = "@sanity/client";
18
- var version = "5.2.0";
18
+ var version = "5.2.2";
19
19
  const middleware = [middleware$1.debug({
20
20
  verbose: true,
21
21
  namespace: "sanity:client"
@@ -103,7 +103,7 @@ function defineHttpRequest(envMiddleware) {
103
103
  return httpRequest;
104
104
  }
105
105
  const projectHeader = "X-Sanity-Project-ID";
106
- var getRequestOptions = function (config) {
106
+ function requestOptions(config) {
107
107
  let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
108
108
  const headers = {};
109
109
  const token = overrides.token || config.token;
@@ -122,7 +122,7 @@ var getRequestOptions = function (config) {
122
122
  json: true,
123
123
  withCredentials
124
124
  });
125
- };
125
+ }
126
126
  function getSelection(sel) {
127
127
  if (typeof sel === "string" || Array.isArray(sel)) {
128
128
  return {
@@ -198,7 +198,7 @@ const requestTag = tag => {
198
198
  }
199
199
  return tag;
200
200
  };
201
- var encodeQueryString = _ref => {
201
+ const encodeQueryString = _ref => {
202
202
  let {
203
203
  query,
204
204
  params = {},
@@ -803,7 +803,7 @@ function _requestObservable(client, httpRequest, options) {
803
803
  ...options.query
804
804
  };
805
805
  }
806
- const reqOptions = getRequestOptions(config, Object.assign({}, options, {
806
+ const reqOptions = requestOptions(config, Object.assign({}, options, {
807
807
  url: _getUrl(client, uri, useCdn)
808
808
  }));
809
809
  const request = new rxjs.Observable(subscriber =>
@@ -959,7 +959,7 @@ const BASE_URL = "https://www.sanity.io/help/";
959
959
  function generateHelpUrl(slug) {
960
960
  return BASE_URL + slug;
961
961
  }
962
- var once = fn => {
962
+ function once(fn) {
963
963
  let didCall = false;
964
964
  let returnValue;
965
965
  return function () {
@@ -970,7 +970,7 @@ var once = fn => {
970
970
  didCall = true;
971
971
  return returnValue;
972
972
  };
973
- };
973
+ }
974
974
  const createWarningPrinter = message =>
975
975
  // eslint-disable-next-line no-console
976
976
  once(function () {
@@ -982,6 +982,7 @@ once(function () {
982
982
  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."]);
983
983
  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.")]);
984
984
  const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
985
+ const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead"]);
985
986
  const defaultCdnHost = "apicdn.sanity.io";
986
987
  const defaultConfig = {
987
988
  apiHost: "https://api.sanity.io",
@@ -1051,7 +1052,7 @@ var defaults = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj))
1051
1052
  target[prop] = typeof obj[prop] === "undefined" ? defaults[prop] : obj[prop];
1052
1053
  return target;
1053
1054
  }, {});
1054
- var pick = (obj, props) => props.reduce((selection, prop) => {
1055
+ const pick = (obj, props) => props.reduce((selection, prop) => {
1055
1056
  if (typeof obj[prop] === "undefined") {
1056
1057
  return selection;
1057
1058
  }
@@ -1736,12 +1737,13 @@ const _SanityClient = class {
1736
1737
  let SanityClient = _SanityClient;
1737
1738
  _clientConfig2 = new WeakMap();
1738
1739
  _httpRequest2 = new WeakMap();
1739
- function migrationNotice() {
1740
- throw new TypeError("The default export of @sanity/client has been deprecated. Use the named export `createClient` instead");
1741
- }
1742
1740
  const httpRequest = defineHttpRequest(middleware);
1743
1741
  const requester = httpRequest.defaultRequester;
1744
1742
  const createClient = config => new SanityClient(httpRequest, config);
1743
+ function deprecatedCreateClient(config) {
1744
+ printNoDefaultExport();
1745
+ return new SanityClient(httpRequest, config);
1746
+ }
1745
1747
  exports.BasePatch = BasePatch;
1746
1748
  exports.BaseTransaction = BaseTransaction;
1747
1749
  exports.ClientError = ClientError;
@@ -1753,6 +1755,6 @@ exports.SanityClient = SanityClient;
1753
1755
  exports.ServerError = ServerError;
1754
1756
  exports.Transaction = Transaction;
1755
1757
  exports.createClient = createClient;
1756
- exports.default = migrationNotice;
1758
+ exports.default = deprecatedCreateClient;
1757
1759
  exports.requester = requester;
1758
1760
  //# sourceMappingURL=index.cjs.map