@sanity/client 6.1.5 → 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.
@@ -878,7 +878,7 @@ function _requestObservable(client, httpRequest, options) {
878
878
  ...options.query
879
879
  };
880
880
  }
881
- if (["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
881
+ if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
882
882
  if (config.resultSourceMap) {
883
883
  options.query = {
884
884
  resultSourceMap: true,
@@ -1090,6 +1090,16 @@ const validateApiVersion = function validateApiVersion2(apiVersion) {
1090
1090
  throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
1091
1091
  }
1092
1092
  };
1093
+ const validateApiPerspective = function validateApiPerspective2(perspective) {
1094
+ switch (perspective) {
1095
+ case "previewDrafts":
1096
+ case "published":
1097
+ case "raw":
1098
+ return;
1099
+ default:
1100
+ throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`");
1101
+ }
1102
+ };
1093
1103
  const initConfig = (config, prevConfig) => {
1094
1104
  const specifiedConfig = Object.assign({}, prevConfig, config);
1095
1105
  if (!specifiedConfig.apiVersion) {
@@ -1104,6 +1114,9 @@ const initConfig = (config, prevConfig) => {
1104
1114
  if (projectBased && !newConfig.projectId) {
1105
1115
  throw new Error("Configuration must contain `projectId`");
1106
1116
  }
1117
+ if (typeof newConfig.perspective === "string") {
1118
+ validateApiPerspective(newConfig.perspective);
1119
+ }
1107
1120
  if ("encodeSourceMapAtPath" in newConfig || "encodeSourceMap" in newConfig || "studioUrl" in newConfig || "logger" in newConfig) {
1108
1121
  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.");
1109
1122
  }