@sanity/client 6.23.0 → 6.24.0-canary.0

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.
@@ -538,8 +538,17 @@ function validateApiVersion(apiVersion) {
538
538
  throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
539
539
  }
540
540
  const validateApiPerspective = function(perspective) {
541
+ if (Array.isArray(perspective)) {
542
+ for (const perspectiveValue of perspective)
543
+ if (perspectiveValue !== "published" && perspectiveValue !== "drafts" && !(typeof perspectiveValue == "string" && perspectiveValue.startsWith("r") && perspectiveValue !== "raw"))
544
+ throw new TypeError(
545
+ "Invalid API perspective value, expected `published`, `drafts` or a valid release identifier string"
546
+ );
547
+ return;
548
+ }
541
549
  switch (perspective) {
542
550
  case "previewDrafts":
551
+ case "drafts":
543
552
  case "published":
544
553
  case "raw":
545
554
  return;
@@ -568,7 +577,7 @@ const validateApiPerspective = function(perspective) {
568
577
  }
569
578
  if (projectBased && !newConfig.projectId)
570
579
  throw new Error("Configuration must contain `projectId`");
571
- if (typeof newConfig.perspective == "string" && validateApiPerspective(newConfig.perspective), "encodeSourceMap" in newConfig)
580
+ if (typeof newConfig.perspective < "u" && validateApiPerspective(newConfig.perspective), "encodeSourceMap" in newConfig)
572
581
  throw new Error(
573
582
  "It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client'. Did you mean 'stega.enabled'?"
574
583
  );
@@ -766,8 +775,11 @@ function _requestObservable(client, httpRequest, options) {
766
775
  if (tag && options.tag !== null && (options.query = { tag: requestTag(tag), ...options.query }), ["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
767
776
  const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
768
777
  resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
769
- const perspective = options.perspective || config.perspective;
770
- typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query });
778
+ const perspectiveOption = options.perspective || config.perspective;
779
+ typeof perspectiveOption < "u" && (validateApiPerspective(perspectiveOption), options.query = {
780
+ perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
781
+ ...options.query
782
+ }, perspectiveOption === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query }), useCdn && options.cacheMode == "noStale" && (options.query = { cacheMode: "noStale", ...options.query });
771
783
  }
772
784
  const reqOptions = requestOptions(
773
785
  config,