@sanity/client 6.27.3-canary.2 → 6.28.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.
@@ -401,7 +401,7 @@ export declare class ClientError extends Error {
401
401
 
402
402
  /** @public */
403
403
  export declare type ClientPerspective =
404
- | 'previewDrafts'
404
+ | DeprecatedPreviewDrafts
405
405
  | 'published'
406
406
  | 'drafts'
407
407
  | 'raw'
@@ -667,6 +667,11 @@ export declare type DeleteAction = {
667
667
  declare const deprecatedCreateClient: (config: ClientConfig) => SanityClient
668
668
  export default deprecatedCreateClient
669
669
 
670
+ /**
671
+ * @deprecated use 'drafts' instead
672
+ */
673
+ declare type DeprecatedPreviewDrafts = 'previewDrafts'
674
+
670
675
  /**
671
676
  * Delete the draft version of a document.
672
677
  * It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
@@ -401,7 +401,7 @@ export declare class ClientError extends Error {
401
401
 
402
402
  /** @public */
403
403
  export declare type ClientPerspective =
404
- | 'previewDrafts'
404
+ | DeprecatedPreviewDrafts
405
405
  | 'published'
406
406
  | 'drafts'
407
407
  | 'raw'
@@ -667,6 +667,11 @@ export declare type DeleteAction = {
667
667
  declare const deprecatedCreateClient: (config: ClientConfig) => SanityClient
668
668
  export default deprecatedCreateClient
669
669
 
670
+ /**
671
+ * @deprecated use 'drafts' instead
672
+ */
673
+ declare type DeprecatedPreviewDrafts = 'previewDrafts'
674
+
670
675
  /**
671
676
  * Delete the draft version of a document.
672
677
  * It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
@@ -1,7 +1,7 @@
1
1
  import { getIt } from "get-it";
2
2
  import { adapter, environment } from "get-it";
3
3
  import { retry, jsonRequest, jsonResponse, progress, observable } from "get-it/middleware";
4
- import { Observable, defer, isObservable, of, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, timer, throwError, tap, finalize, share, merge, EMPTY } from "rxjs";
4
+ import { Observable, defer, of, isObservable, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, throwError, timer, tap, finalize, share, merge, EMPTY } from "rxjs";
5
5
  import { stegaClean } from "./_chunks-es/stegaClean.js";
6
6
  import { combineLatestWith, map, filter, finalize as finalize$1 } from "rxjs/operators";
7
7
  class ClientError extends Error {
@@ -171,8 +171,10 @@ const createWarningPrinter = (message) => (
171
171
  "global, edge-cached API-CDN. If you wish to have content delivered faster, set",
172
172
  "`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."
173
173
  ]), printCdnPreviewDraftsWarning = createWarningPrinter([
174
- "The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.",
174
+ "The Sanity client is configured with the `perspective` set to `drafts` or `previewDrafts`, which doesn't support the API-CDN.",
175
175
  "The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."
176
+ ]), printPreviewDraftsDeprecationWarning = createWarningPrinter([
177
+ "The `previewDrafts` perspective has been renamed to `drafts` and will be removed in a future API version"
176
178
  ]), printBrowserTokenWarning = createWarningPrinter([
177
179
  "You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
178
180
  `See ${generateHelpUrl(
@@ -870,10 +872,11 @@ function _requestObservable(client, httpRequest, options) {
870
872
  const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
871
873
  resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
872
874
  const perspectiveOption = options.perspective || config.perspective;
873
- typeof perspectiveOption < "u" && (validateApiPerspective(perspectiveOption), options.query = {
875
+ typeof perspectiveOption < "u" && (perspectiveOption === "previewDrafts" && printPreviewDraftsDeprecationWarning(), validateApiPerspective(perspectiveOption), options.query = {
874
876
  perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
875
877
  ...options.query
876
- }, 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 });
878
+ }, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
879
+ perspectiveOption === "previewDrafts" || perspectiveOption === "drafts") && 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 });
877
880
  }
878
881
  const reqOptions = requestOptions(
879
882
  config,