@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.
package/dist/index.d.cts CHANGED
@@ -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.
package/dist/index.d.ts CHANGED
@@ -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.
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { getIt } from "get-it";
2
2
  import { adapter, environment } from "get-it";
3
3
  import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } 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
- import { validateObject, validateInsert, requireDocumentId, validateDocumentId, requestTag, validateApiPerspective, printCdnPreviewDraftsWarning, hasDataset, validateAssetType, dataset, defaultConfig, initConfig, printNoDefaultExport } from "./_chunks-es/config.js";
7
+ import { validateObject, validateInsert, requireDocumentId, validateDocumentId, hasDataset, requestTag, printPreviewDraftsDeprecationWarning, validateApiPerspective, printCdnPreviewDraftsWarning, validateAssetType, dataset, defaultConfig, initConfig, printNoDefaultExport } from "./_chunks-es/config.js";
8
8
  class ClientError extends Error {
9
9
  response;
10
10
  statusCode = 400;
@@ -728,10 +728,11 @@ function _requestObservable(client, httpRequest, options) {
728
728
  const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap;
729
729
  resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
730
730
  const perspectiveOption = options.perspective || config.perspective;
731
- typeof perspectiveOption < "u" && (validateApiPerspective(perspectiveOption), options.query = {
731
+ typeof perspectiveOption < "u" && (perspectiveOption === "previewDrafts" && printPreviewDraftsDeprecationWarning(), validateApiPerspective(perspectiveOption), options.query = {
732
732
  perspective: Array.isArray(perspectiveOption) ? perspectiveOption.join(",") : perspectiveOption,
733
733
  ...options.query
734
- }, 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 });
734
+ }, (Array.isArray(perspectiveOption) && perspectiveOption.length > 0 || // previewDrafts was renamed to drafts, but keep for backwards compat
735
+ 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 });
735
736
  }
736
737
  const reqOptions = requestOptions(
737
738
  config,
@@ -1507,7 +1508,7 @@ function defineDeprecatedCreateClient(createClient2) {
1507
1508
  return printNoDefaultExport(), createClient2(config);
1508
1509
  };
1509
1510
  }
1510
- var name = "@sanity/client", version = "6.27.3-canary.2";
1511
+ var name = "@sanity/client", version = "6.28.0";
1511
1512
  const middleware = [
1512
1513
  debug({ verbose: !0, namespace: "sanity:client" }),
1513
1514
  headers({ "User-Agent": `${name} ${version}` }),