@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.
@@ -874,7 +874,7 @@ function _requestObservable(client, httpRequest, options) {
874
874
  ...options.query
875
875
  };
876
876
  }
877
- if (["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
877
+ if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
878
878
  if (config.resultSourceMap) {
879
879
  options.query = {
880
880
  resultSourceMap: true,
@@ -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
  }