@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.browser.cjs +13 -11
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +13 -11
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +14 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +128 -128
- package/dist/index.js +14 -12
- package/dist/index.js.map +1 -1
- package/package.json +15 -15
- package/src/SanityClient.ts +80 -80
- package/src/assets/AssetsClient.ts +4 -4
- package/src/config.ts +1 -1
- package/src/data/dataMethods.ts +31 -31
- package/src/data/encodeQueryString.ts +3 -3
- package/src/data/listen.ts +11 -11
- package/src/data/patch.ts +18 -18
- package/src/data/transaction.ts +13 -15
- package/src/generateHelpUrl.ts +1 -1
- package/src/http/errors.ts +7 -7
- package/src/http/request.ts +4 -4
- package/src/http/requestOptions.ts +3 -3
- package/src/index.browser.ts +9 -1
- package/src/index.ts +9 -1
- package/src/types.ts +27 -28
- package/src/util/defaults.ts +3 -3
- package/src/util/getSelection.ts +1 -1
- package/src/util/once.ts +4 -4
- package/src/util/pick.ts +3 -3
- package/src/validators.ts +4 -4
- package/src/warnings.ts +8 -4
- package/umd/sanityClient.js +14 -27
- package/umd/sanityClient.min.js +3 -3
- package/src/migrationNotice.ts +0 -9
package/dist/index.browser.js
CHANGED
|
@@ -83,7 +83,7 @@ function defineHttpRequest(envMiddleware) {
|
|
|
83
83
|
return httpRequest;
|
|
84
84
|
}
|
|
85
85
|
const projectHeader = "X-Sanity-Project-ID";
|
|
86
|
-
|
|
86
|
+
function requestOptions(config) {
|
|
87
87
|
let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
88
88
|
const headers = {};
|
|
89
89
|
const token = overrides.token || config.token;
|
|
@@ -102,7 +102,7 @@ var getRequestOptions = function (config) {
|
|
|
102
102
|
json: true,
|
|
103
103
|
withCredentials
|
|
104
104
|
});
|
|
105
|
-
}
|
|
105
|
+
}
|
|
106
106
|
function getSelection(sel) {
|
|
107
107
|
if (typeof sel === "string" || Array.isArray(sel)) {
|
|
108
108
|
return {
|
|
@@ -178,7 +178,7 @@ const requestTag = tag => {
|
|
|
178
178
|
}
|
|
179
179
|
return tag;
|
|
180
180
|
};
|
|
181
|
-
|
|
181
|
+
const encodeQueryString = _ref => {
|
|
182
182
|
let {
|
|
183
183
|
query,
|
|
184
184
|
params = {},
|
|
@@ -783,7 +783,7 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
783
783
|
...options.query
|
|
784
784
|
};
|
|
785
785
|
}
|
|
786
|
-
const reqOptions =
|
|
786
|
+
const reqOptions = requestOptions(config, Object.assign({}, options, {
|
|
787
787
|
url: _getUrl(client, uri, useCdn)
|
|
788
788
|
}));
|
|
789
789
|
const request = new Observable(subscriber =>
|
|
@@ -939,7 +939,7 @@ const BASE_URL = "https://www.sanity.io/help/";
|
|
|
939
939
|
function generateHelpUrl(slug) {
|
|
940
940
|
return BASE_URL + slug;
|
|
941
941
|
}
|
|
942
|
-
|
|
942
|
+
function once(fn) {
|
|
943
943
|
let didCall = false;
|
|
944
944
|
let returnValue;
|
|
945
945
|
return function () {
|
|
@@ -950,7 +950,7 @@ var once = fn => {
|
|
|
950
950
|
didCall = true;
|
|
951
951
|
return returnValue;
|
|
952
952
|
};
|
|
953
|
-
}
|
|
953
|
+
}
|
|
954
954
|
const createWarningPrinter = message =>
|
|
955
955
|
// eslint-disable-next-line no-console
|
|
956
956
|
once(function () {
|
|
@@ -962,6 +962,7 @@ once(function () {
|
|
|
962
962
|
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."]);
|
|
963
963
|
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.")]);
|
|
964
964
|
const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
|
|
965
|
+
const printNoDefaultExport = createWarningPrinter(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead"]);
|
|
965
966
|
const defaultCdnHost = "apicdn.sanity.io";
|
|
966
967
|
const defaultConfig = {
|
|
967
968
|
apiHost: "https://api.sanity.io",
|
|
@@ -1031,7 +1032,7 @@ var defaults = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj))
|
|
|
1031
1032
|
target[prop] = typeof obj[prop] === "undefined" ? defaults[prop] : obj[prop];
|
|
1032
1033
|
return target;
|
|
1033
1034
|
}, {});
|
|
1034
|
-
|
|
1035
|
+
const pick = (obj, props) => props.reduce((selection, prop) => {
|
|
1035
1036
|
if (typeof obj[prop] === "undefined") {
|
|
1036
1037
|
return selection;
|
|
1037
1038
|
}
|
|
@@ -1716,11 +1717,12 @@ const _SanityClient = class {
|
|
|
1716
1717
|
let SanityClient = _SanityClient;
|
|
1717
1718
|
_clientConfig2 = new WeakMap();
|
|
1718
1719
|
_httpRequest2 = new WeakMap();
|
|
1719
|
-
function migrationNotice() {
|
|
1720
|
-
throw new TypeError("The default export of @sanity/client has been deprecated. Use the named export `createClient` instead");
|
|
1721
|
-
}
|
|
1722
1720
|
const httpRequest = defineHttpRequest(envMiddleware);
|
|
1723
1721
|
const requester = httpRequest.defaultRequester;
|
|
1724
1722
|
const createClient = config => new SanityClient(httpRequest, config);
|
|
1725
|
-
|
|
1723
|
+
function deprecatedCreateClient(config) {
|
|
1724
|
+
printNoDefaultExport();
|
|
1725
|
+
return new SanityClient(httpRequest, config);
|
|
1726
|
+
}
|
|
1727
|
+
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, SanityClient, ServerError, Transaction, createClient, deprecatedCreateClient as default, requester };
|
|
1726
1728
|
//# sourceMappingURL=index.browser.js.map
|