@sanity/client 6.2.0-fetch.5 → 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.
@@ -895,7 +895,7 @@ function _requestObservable(client, httpRequest, options) {
895
895
  ...options.query
896
896
  };
897
897
  }
898
- if (["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
898
+ if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
899
899
  if (config.resultSourceMap) {
900
900
  options.query = {
901
901
  resultSourceMap: true,
@@ -1107,6 +1107,16 @@ const validateApiVersion = function validateApiVersion2(apiVersion) {
1107
1107
  throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
1108
1108
  }
1109
1109
  };
1110
+ const validateApiPerspective = function validateApiPerspective2(perspective) {
1111
+ switch (perspective) {
1112
+ case "previewDrafts":
1113
+ case "published":
1114
+ case "raw":
1115
+ return;
1116
+ default:
1117
+ throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`");
1118
+ }
1119
+ };
1110
1120
  const initConfig = (config, prevConfig) => {
1111
1121
  const specifiedConfig = Object.assign({}, prevConfig, config);
1112
1122
  if (!specifiedConfig.apiVersion) {
@@ -1121,6 +1131,9 @@ const initConfig = (config, prevConfig) => {
1121
1131
  if (projectBased && !newConfig.projectId) {
1122
1132
  throw new Error("Configuration must contain `projectId`");
1123
1133
  }
1134
+ if (typeof newConfig.perspective === "string") {
1135
+ validateApiPerspective(newConfig.perspective);
1136
+ }
1124
1137
  if ("encodeSourceMapAtPath" in newConfig || "encodeSourceMap" in newConfig || "studioUrl" in newConfig || "logger" in newConfig) {
1125
1138
  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.");
1126
1139
  }