@sanity/client 5.2.0 → 5.2.1

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.js CHANGED
@@ -4,7 +4,7 @@ import { Observable, lastValueFrom } from 'rxjs';
4
4
  import { map, filter } from 'rxjs/operators';
5
5
  import polyfilledEventSource from '@sanity/eventsource';
6
6
  var name = "@sanity/client";
7
- var version = "5.2.0";
7
+ var version = "5.2.1";
8
8
  const middleware = [debug({
9
9
  verbose: true,
10
10
  namespace: "sanity:client"
@@ -92,7 +92,7 @@ function defineHttpRequest(envMiddleware) {
92
92
  return httpRequest;
93
93
  }
94
94
  const projectHeader = "X-Sanity-Project-ID";
95
- var getRequestOptions = function (config) {
95
+ function requestOptions(config) {
96
96
  let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
97
97
  const headers = {};
98
98
  const token = overrides.token || config.token;
@@ -111,7 +111,7 @@ var getRequestOptions = function (config) {
111
111
  json: true,
112
112
  withCredentials
113
113
  });
114
- };
114
+ }
115
115
  function getSelection(sel) {
116
116
  if (typeof sel === "string" || Array.isArray(sel)) {
117
117
  return {
@@ -187,7 +187,7 @@ const requestTag = tag => {
187
187
  }
188
188
  return tag;
189
189
  };
190
- var encodeQueryString = _ref => {
190
+ const encodeQueryString = _ref => {
191
191
  let {
192
192
  query,
193
193
  params = {},
@@ -792,7 +792,7 @@ function _requestObservable(client, httpRequest, options) {
792
792
  ...options.query
793
793
  };
794
794
  }
795
- const reqOptions = getRequestOptions(config, Object.assign({}, options, {
795
+ const reqOptions = requestOptions(config, Object.assign({}, options, {
796
796
  url: _getUrl(client, uri, useCdn)
797
797
  }));
798
798
  const request = new Observable(subscriber =>
@@ -948,7 +948,7 @@ const BASE_URL = "https://www.sanity.io/help/";
948
948
  function generateHelpUrl(slug) {
949
949
  return BASE_URL + slug;
950
950
  }
951
- var once = fn => {
951
+ function once(fn) {
952
952
  let didCall = false;
953
953
  let returnValue;
954
954
  return function () {
@@ -959,7 +959,7 @@ var once = fn => {
959
959
  didCall = true;
960
960
  return returnValue;
961
961
  };
962
- };
962
+ }
963
963
  const createWarningPrinter = message =>
964
964
  // eslint-disable-next-line no-console
965
965
  once(function () {
@@ -971,6 +971,7 @@ once(function () {
971
971
  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."]);
972
972
  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.")]);
973
973
  const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
974
+ const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead"]);
974
975
  const defaultCdnHost = "apicdn.sanity.io";
975
976
  const defaultConfig = {
976
977
  apiHost: "https://api.sanity.io",
@@ -1040,7 +1041,7 @@ var defaults = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj))
1040
1041
  target[prop] = typeof obj[prop] === "undefined" ? defaults[prop] : obj[prop];
1041
1042
  return target;
1042
1043
  }, {});
1043
- var pick = (obj, props) => props.reduce((selection, prop) => {
1044
+ const pick = (obj, props) => props.reduce((selection, prop) => {
1044
1045
  if (typeof obj[prop] === "undefined") {
1045
1046
  return selection;
1046
1047
  }
@@ -1725,11 +1726,12 @@ const _SanityClient = class {
1725
1726
  let SanityClient = _SanityClient;
1726
1727
  _clientConfig2 = new WeakMap();
1727
1728
  _httpRequest2 = new WeakMap();
1728
- function migrationNotice() {
1729
- throw new TypeError("The default export of @sanity/client has been deprecated. Use the named export `createClient` instead");
1730
- }
1731
1729
  const httpRequest = defineHttpRequest(middleware);
1732
1730
  const requester = httpRequest.defaultRequester;
1733
1731
  const createClient = config => new SanityClient(httpRequest, config);
1734
- export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, createClient, migrationNotice as default, requester };
1732
+ function deprecatedCreateClient(config) {
1733
+ printNoDefaultExport();
1734
+ return new SanityClient(httpRequest, config);
1735
+ }
1736
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, createClient, deprecatedCreateClient as default, requester };
1735
1737
  //# sourceMappingURL=index.js.map