@sanity/client 6.2.0-fetch.4 → 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.
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.2.0-fetch.4";
11
+ var version = "6.2.0-fetch.6";
12
12
  const middleware = [middleware$1.debug({
13
13
  verbose: true,
14
14
  namespace: "sanity:client"
@@ -902,7 +902,7 @@ function _requestObservable(client, httpRequest, options) {
902
902
  ...options.query
903
903
  };
904
904
  }
905
- if (["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
905
+ if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
906
906
  if (config.resultSourceMap) {
907
907
  options.query = {
908
908
  resultSourceMap: true,
@@ -1114,6 +1114,16 @@ const validateApiVersion = function validateApiVersion2(apiVersion) {
1114
1114
  throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
1115
1115
  }
1116
1116
  };
1117
+ const validateApiPerspective = function validateApiPerspective2(perspective) {
1118
+ switch (perspective) {
1119
+ case "previewDrafts":
1120
+ case "published":
1121
+ case "raw":
1122
+ return;
1123
+ default:
1124
+ throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`");
1125
+ }
1126
+ };
1117
1127
  const initConfig = (config, prevConfig) => {
1118
1128
  const specifiedConfig = Object.assign({}, prevConfig, config);
1119
1129
  if (!specifiedConfig.apiVersion) {
@@ -1128,6 +1138,9 @@ const initConfig = (config, prevConfig) => {
1128
1138
  if (projectBased && !newConfig.projectId) {
1129
1139
  throw new Error("Configuration must contain `projectId`");
1130
1140
  }
1141
+ if (typeof newConfig.perspective === "string") {
1142
+ validateApiPerspective(newConfig.perspective);
1143
+ }
1131
1144
  if ("encodeSourceMapAtPath" in newConfig || "encodeSourceMap" in newConfig || "studioUrl" in newConfig || "logger" in newConfig) {
1132
1145
  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.");
1133
1146
  }