@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.cjs CHANGED
@@ -8,7 +8,7 @@ var getIt = require('get-it');
8
8
  var rxjs = require('rxjs');
9
9
  var operators = require('rxjs/operators');
10
10
  var name = "@sanity/client";
11
- var version = "6.1.6";
11
+ var version = "6.1.7";
12
12
  const middleware = [middleware$1.debug({
13
13
  verbose: true,
14
14
  namespace: "sanity:client"
@@ -1097,6 +1097,16 @@ const validateApiVersion = function validateApiVersion2(apiVersion) {
1097
1097
  throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
1098
1098
  }
1099
1099
  };
1100
+ const validateApiPerspective = function validateApiPerspective2(perspective) {
1101
+ switch (perspective) {
1102
+ case "previewDrafts":
1103
+ case "published":
1104
+ case "raw":
1105
+ return;
1106
+ default:
1107
+ throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`");
1108
+ }
1109
+ };
1100
1110
  const initConfig = (config, prevConfig) => {
1101
1111
  const specifiedConfig = Object.assign({}, prevConfig, config);
1102
1112
  if (!specifiedConfig.apiVersion) {
@@ -1111,6 +1121,9 @@ const initConfig = (config, prevConfig) => {
1111
1121
  if (projectBased && !newConfig.projectId) {
1112
1122
  throw new Error("Configuration must contain `projectId`");
1113
1123
  }
1124
+ if (typeof newConfig.perspective === "string") {
1125
+ validateApiPerspective(newConfig.perspective);
1126
+ }
1114
1127
  if ("encodeSourceMapAtPath" in newConfig || "encodeSourceMap" in newConfig || "studioUrl" in newConfig || "logger" in newConfig) {
1115
1128
  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.");
1116
1129
  }