@sanity/client 6.1.6 → 6.1.7
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 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +13 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +14 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/config.ts +18 -1
- package/umd/sanityClient.js +13 -0
- package/umd/sanityClient.min.js +3 -3
package/dist/index.browser.js
CHANGED
|
@@ -1086,6 +1086,16 @@ const validateApiVersion = function validateApiVersion2(apiVersion) {
|
|
|
1086
1086
|
throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
|
|
1087
1087
|
}
|
|
1088
1088
|
};
|
|
1089
|
+
const validateApiPerspective = function validateApiPerspective2(perspective) {
|
|
1090
|
+
switch (perspective) {
|
|
1091
|
+
case "previewDrafts":
|
|
1092
|
+
case "published":
|
|
1093
|
+
case "raw":
|
|
1094
|
+
return;
|
|
1095
|
+
default:
|
|
1096
|
+
throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`");
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1089
1099
|
const initConfig = (config, prevConfig) => {
|
|
1090
1100
|
const specifiedConfig = Object.assign({}, prevConfig, config);
|
|
1091
1101
|
if (!specifiedConfig.apiVersion) {
|
|
@@ -1100,6 +1110,9 @@ const initConfig = (config, prevConfig) => {
|
|
|
1100
1110
|
if (projectBased && !newConfig.projectId) {
|
|
1101
1111
|
throw new Error("Configuration must contain `projectId`");
|
|
1102
1112
|
}
|
|
1113
|
+
if (typeof newConfig.perspective === "string") {
|
|
1114
|
+
validateApiPerspective(newConfig.perspective);
|
|
1115
|
+
}
|
|
1103
1116
|
if ("encodeSourceMapAtPath" in newConfig || "encodeSourceMap" in newConfig || "studioUrl" in newConfig || "logger" in newConfig) {
|
|
1104
1117
|
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.");
|
|
1105
1118
|
}
|