@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.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 +13 -13
- 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 +13 -11
- package/umd/sanityClient.min.js +1 -1
- package/src/migrationNotice.ts +0 -9
package/dist/index.browser.cjs
CHANGED
|
@@ -94,7 +94,7 @@ function defineHttpRequest(envMiddleware) {
|
|
|
94
94
|
return httpRequest;
|
|
95
95
|
}
|
|
96
96
|
const projectHeader = "X-Sanity-Project-ID";
|
|
97
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
1749
|
+
exports.default = deprecatedCreateClient;
|
|
1748
1750
|
exports.requester = requester;
|
|
1749
1751
|
//# sourceMappingURL=index.browser.cjs.map
|