@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.js
CHANGED
|
@@ -4,7 +4,7 @@ export { adapter as unstable__adapter, environment as unstable__environment } fr
|
|
|
4
4
|
import { Observable, lastValueFrom } from 'rxjs';
|
|
5
5
|
import { map, filter } from 'rxjs/operators';
|
|
6
6
|
var name = "@sanity/client";
|
|
7
|
-
var version = "6.2.0-fetch.
|
|
7
|
+
var version = "6.2.0-fetch.6";
|
|
8
8
|
const middleware = [debug({
|
|
9
9
|
verbose: true,
|
|
10
10
|
namespace: "sanity:client"
|
|
@@ -898,7 +898,7 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
898
898
|
...options.query
|
|
899
899
|
};
|
|
900
900
|
}
|
|
901
|
-
if (["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
901
|
+
if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
902
902
|
if (config.resultSourceMap) {
|
|
903
903
|
options.query = {
|
|
904
904
|
resultSourceMap: true,
|
|
@@ -1110,6 +1110,16 @@ const validateApiVersion = function validateApiVersion2(apiVersion) {
|
|
|
1110
1110
|
throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
|
|
1111
1111
|
}
|
|
1112
1112
|
};
|
|
1113
|
+
const validateApiPerspective = function validateApiPerspective2(perspective) {
|
|
1114
|
+
switch (perspective) {
|
|
1115
|
+
case "previewDrafts":
|
|
1116
|
+
case "published":
|
|
1117
|
+
case "raw":
|
|
1118
|
+
return;
|
|
1119
|
+
default:
|
|
1120
|
+
throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`");
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1113
1123
|
const initConfig = (config, prevConfig) => {
|
|
1114
1124
|
const specifiedConfig = Object.assign({}, prevConfig, config);
|
|
1115
1125
|
if (!specifiedConfig.apiVersion) {
|
|
@@ -1124,6 +1134,9 @@ const initConfig = (config, prevConfig) => {
|
|
|
1124
1134
|
if (projectBased && !newConfig.projectId) {
|
|
1125
1135
|
throw new Error("Configuration must contain `projectId`");
|
|
1126
1136
|
}
|
|
1137
|
+
if (typeof newConfig.perspective === "string") {
|
|
1138
|
+
validateApiPerspective(newConfig.perspective);
|
|
1139
|
+
}
|
|
1127
1140
|
if ("encodeSourceMapAtPath" in newConfig || "encodeSourceMap" in newConfig || "studioUrl" in newConfig || "logger" in newConfig) {
|
|
1128
1141
|
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.");
|
|
1129
1142
|
}
|