@sanity/client 6.2.0-fetch.4 → 6.2.0-fetch.6
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 +14 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +14 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/config.ts +18 -1
- package/src/data/dataMethods.ts +4 -1
- package/umd/sanityClient.js +14 -1
- package/umd/sanityClient.min.js +3 -3
package/dist/index.browser.js
CHANGED
|
@@ -891,7 +891,7 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
891
891
|
...options.query
|
|
892
892
|
};
|
|
893
893
|
}
|
|
894
|
-
if (["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
894
|
+
if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
895
895
|
if (config.resultSourceMap) {
|
|
896
896
|
options.query = {
|
|
897
897
|
resultSourceMap: true,
|
|
@@ -1103,6 +1103,16 @@ const validateApiVersion = function validateApiVersion2(apiVersion) {
|
|
|
1103
1103
|
throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
|
|
1104
1104
|
}
|
|
1105
1105
|
};
|
|
1106
|
+
const validateApiPerspective = function validateApiPerspective2(perspective) {
|
|
1107
|
+
switch (perspective) {
|
|
1108
|
+
case "previewDrafts":
|
|
1109
|
+
case "published":
|
|
1110
|
+
case "raw":
|
|
1111
|
+
return;
|
|
1112
|
+
default:
|
|
1113
|
+
throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`");
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1106
1116
|
const initConfig = (config, prevConfig) => {
|
|
1107
1117
|
const specifiedConfig = Object.assign({}, prevConfig, config);
|
|
1108
1118
|
if (!specifiedConfig.apiVersion) {
|
|
@@ -1117,6 +1127,9 @@ const initConfig = (config, prevConfig) => {
|
|
|
1117
1127
|
if (projectBased && !newConfig.projectId) {
|
|
1118
1128
|
throw new Error("Configuration must contain `projectId`");
|
|
1119
1129
|
}
|
|
1130
|
+
if (typeof newConfig.perspective === "string") {
|
|
1131
|
+
validateApiPerspective(newConfig.perspective);
|
|
1132
|
+
}
|
|
1120
1133
|
if ("encodeSourceMapAtPath" in newConfig || "encodeSourceMap" in newConfig || "studioUrl" in newConfig || "logger" in newConfig) {
|
|
1121
1134
|
throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client', such as 'encodeSourceMapAtPath', 'encodeSourceMap', 'studioUrl' and 'logger'. Make sure you're using the right import.");
|
|
1122
1135
|
}
|