@sanity/client 7.6.0 → 7.8.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
@@ -698,6 +698,30 @@ export declare interface ClientConfig {
698
698
  */
699
699
  headers?: Record<string, string>
700
700
  ignoreBrowserTokenWarning?: boolean
701
+ /**
702
+ * Ignore specific warning messages from the client.
703
+ *
704
+ * @remarks
705
+ * - String values perform substring matching (not exact matching) against warning messages
706
+ * - RegExp values are tested against the full warning message
707
+ * - Array values allow multiple patterns to be specified
708
+ *
709
+ * @example
710
+ * ```typescript
711
+ * // Ignore warnings containing "experimental"
712
+ * ignoreWarnings: 'experimental'
713
+ *
714
+ * // Ignore multiple warning types
715
+ * ignoreWarnings: ['experimental', 'deprecated']
716
+ *
717
+ * // Use regex for exact matching
718
+ * ignoreWarnings: /^This is an experimental API version$/
719
+ *
720
+ * // Mix strings and regex patterns
721
+ * ignoreWarnings: ['rate limit', /^deprecated/i]
722
+ * ```
723
+ */
724
+ ignoreWarnings?: string | RegExp | Array<string | RegExp>
701
725
  withCredentials?: boolean
702
726
  allowReconfigure?: boolean
703
727
  timeout?: number
@@ -985,16 +1009,29 @@ export declare interface CreateReleaseAction {
985
1009
  }
986
1010
 
987
1011
  /**
988
- * Creates a new version of an existing document, attached to the release as given
989
- * by `document._id`
1012
+ * Creates a new version of an existing document.
1013
+ *
1014
+ * If the `document` is provided, the version is created from the document
1015
+ * attached to the release as given by `document._id`
1016
+ *
1017
+ * If the `baseId` and `versionId` are provided, the version is created from the base document
1018
+ * and the version is attached to the release as given by `publishedId` and `versionId`
990
1019
  *
991
1020
  * @public
992
1021
  */
993
- export declare interface CreateVersionAction {
1022
+ export declare type CreateVersionAction = {
994
1023
  actionType: 'sanity.action.document.version.create'
995
1024
  publishedId: string
996
- document: IdentifiedSanityDocumentStub
997
- }
1025
+ } & (
1026
+ | {
1027
+ document: IdentifiedSanityDocumentStub
1028
+ }
1029
+ | {
1030
+ baseId: string
1031
+ versionId: string
1032
+ ifBaseRevisionId?: string
1033
+ }
1034
+ )
998
1035
 
999
1036
  /** @public */
1000
1037
  export declare interface CurrentSanityUser {
@@ -1278,6 +1315,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
1278
1315
  */
1279
1316
  export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
1280
1317
 
1318
+ /**
1319
+ * A string constant containing the experimental API version warning message.
1320
+ * Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
1321
+ *
1322
+ * @example
1323
+ * ```typescript
1324
+ * import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
1325
+ *
1326
+ * const client = createClient({
1327
+ * projectId: 'your-project-id',
1328
+ * dataset: 'production',
1329
+ * apiVersion: 'vX', // experimental version
1330
+ * ignoreWarnings: EXPERIMENTAL_API_WARNING
1331
+ * })
1332
+ * ```
1333
+ *
1334
+ * @public
1335
+ */
1336
+ export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
1337
+
1281
1338
  /**
1282
1339
  *
1283
1340
  *
@@ -1693,6 +1750,25 @@ export declare interface GroqAgentActionParam {
1693
1750
  params?: Record<string, string>
1694
1751
  }
1695
1752
 
1753
+ /**
1754
+ * Shared properties for HTTP errors (eg both ClientError and ServerError)
1755
+ * Use `isHttpError` for type narrowing and accessing response properties.
1756
+ *
1757
+ * @public
1758
+ */
1759
+ export declare interface HttpError {
1760
+ statusCode: number
1761
+ message: string
1762
+ response: {
1763
+ body: unknown
1764
+ url: string
1765
+ method: string
1766
+ headers: Record<string, string>
1767
+ statusCode: number
1768
+ statusMessage: string | null
1769
+ }
1770
+ }
1771
+
1696
1772
  /** @public */
1697
1773
  export declare type HttpRequest = {
1698
1774
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1802,6 +1878,15 @@ export declare type InsertPatch =
1802
1878
  items: Any[]
1803
1879
  }
1804
1880
 
1881
+ /**
1882
+ * Checks if the provided error is an HTTP error.
1883
+ *
1884
+ * @param error - The error to check.
1885
+ * @returns `true` if the error is an HTTP error, `false` otherwise.
1886
+ * @public
1887
+ */
1888
+ export declare function isHttpError(error: unknown): error is HttpError
1889
+
1805
1890
  /** @internal */
1806
1891
  export declare function isQueryParseError(error: object): error is QueryParseError
1807
1892
 
@@ -3051,6 +3136,15 @@ export declare class ObservableSanityClient {
3051
3136
  },
3052
3137
  options?: BaseActionOptions,
3053
3138
  ): Observable<SingleActionResult | MultipleActionResult>
3139
+ createVersion(
3140
+ args: {
3141
+ baseId: string
3142
+ releaseId: string
3143
+ publishedId: string
3144
+ ifBaseRevisionId?: string
3145
+ },
3146
+ options?: BaseActionOptions,
3147
+ ): Observable<SingleActionResult | MultipleActionResult>
3054
3148
  /**
3055
3149
  * Deletes a document with the given document ID.
3056
3150
  * Returns an observable that resolves to the deleted document.
@@ -4766,7 +4860,8 @@ export declare class SanityClient {
4766
4860
  * Creates a new version of a published document.
4767
4861
  *
4768
4862
  * @remarks
4769
- * * Requires a document with a `_type` property.
4863
+ * * The preferred approach is to use `baseId` to refer to the existing published document, but it is also possible to provide a complete `document` instead.
4864
+ * * If `document` is provided, it must have a `_type` property.
4770
4865
  * * Creating a version with no `releaseId` will create a new draft version of the published document.
4771
4866
  * * If the `document._id` is defined, it should be a draft or release version ID that matches the version ID generated from `publishedId` and `releaseId`.
4772
4867
  * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
@@ -4775,17 +4870,18 @@ export declare class SanityClient {
4775
4870
  * @category Versions
4776
4871
  *
4777
4872
  * @param params - Version action parameters:
4873
+ * - `baseId` - The ID of the published document from which to create a new version from.
4874
+ * - `ifBaseRevisionId` - If `baseId` is provided, this ensures the `baseId`'s revision Id is as expected before creating the new version from it.
4778
4875
  * - `document` - The document to create as a new version (must include `_type`).
4779
4876
  * - `publishedId` - The ID of the published document being versioned.
4780
4877
  * - `releaseId` - The ID of the release to create the version for.
4781
4878
  * @param options - Additional action options.
4782
4879
  * @returns A promise that resolves to the `transactionId`.
4783
4880
  *
4784
- * @example Creating a new version of a published document with a generated version ID
4881
+ * @example Creating a new version of a published document
4785
4882
  * ```ts
4786
4883
  * const transactionId = await client.createVersion({
4787
- * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
4788
- * document: {_type: 'myDocument', title: 'My Document'},
4884
+ * baseId: 'myDocument',
4789
4885
  * publishedId: 'myDocument',
4790
4886
  * releaseId: 'myRelease',
4791
4887
  * })
@@ -4798,25 +4894,11 @@ export declare class SanityClient {
4798
4894
  * // }
4799
4895
  * ```
4800
4896
  *
4801
- * @example Creating a new version of a published document with a specified version ID
4802
- * ```ts
4803
- * const transactionId = await client.createVersion({
4804
- * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
4805
- * // `publishedId` and `releaseId` are not required since `document._id` has been specified
4806
- * })
4807
- *
4808
- * // The following document will be created:
4809
- * // {
4810
- * // _id: 'versions.myRelease.myDocument',
4811
- * // _type: 'myDocument',
4812
- * // title: 'My Document',
4813
- * // }
4814
- * ```
4815
4897
  *
4816
4898
  * @example Creating a new draft version of a published document
4817
4899
  * ```ts
4818
4900
  * const transactionId = await client.createVersion({
4819
- * document: {_type: 'myDocument', title: 'My Document'},
4901
+ * baseId: 'myDocument',
4820
4902
  * publishedId: 'myDocument',
4821
4903
  * })
4822
4904
  *
@@ -4844,6 +4926,15 @@ export declare class SanityClient {
4844
4926
  },
4845
4927
  options?: BaseActionOptions,
4846
4928
  ): Promise<SingleActionResult | MultipleActionResult>
4929
+ createVersion(
4930
+ args: {
4931
+ publishedId: string
4932
+ baseId: string
4933
+ releaseId: string
4934
+ ifBaseRevisionId?: string
4935
+ },
4936
+ options?: BaseActionOptions,
4937
+ ): Promise<SingleActionResult | MultipleActionResult>
4847
4938
  /**
4848
4939
  * Deletes a document with the given document ID.
4849
4940
  * Returns a promise that resolves to the deleted document.
package/dist/index.d.ts CHANGED
@@ -698,6 +698,30 @@ export declare interface ClientConfig {
698
698
  */
699
699
  headers?: Record<string, string>
700
700
  ignoreBrowserTokenWarning?: boolean
701
+ /**
702
+ * Ignore specific warning messages from the client.
703
+ *
704
+ * @remarks
705
+ * - String values perform substring matching (not exact matching) against warning messages
706
+ * - RegExp values are tested against the full warning message
707
+ * - Array values allow multiple patterns to be specified
708
+ *
709
+ * @example
710
+ * ```typescript
711
+ * // Ignore warnings containing "experimental"
712
+ * ignoreWarnings: 'experimental'
713
+ *
714
+ * // Ignore multiple warning types
715
+ * ignoreWarnings: ['experimental', 'deprecated']
716
+ *
717
+ * // Use regex for exact matching
718
+ * ignoreWarnings: /^This is an experimental API version$/
719
+ *
720
+ * // Mix strings and regex patterns
721
+ * ignoreWarnings: ['rate limit', /^deprecated/i]
722
+ * ```
723
+ */
724
+ ignoreWarnings?: string | RegExp | Array<string | RegExp>
701
725
  withCredentials?: boolean
702
726
  allowReconfigure?: boolean
703
727
  timeout?: number
@@ -985,16 +1009,29 @@ export declare interface CreateReleaseAction {
985
1009
  }
986
1010
 
987
1011
  /**
988
- * Creates a new version of an existing document, attached to the release as given
989
- * by `document._id`
1012
+ * Creates a new version of an existing document.
1013
+ *
1014
+ * If the `document` is provided, the version is created from the document
1015
+ * attached to the release as given by `document._id`
1016
+ *
1017
+ * If the `baseId` and `versionId` are provided, the version is created from the base document
1018
+ * and the version is attached to the release as given by `publishedId` and `versionId`
990
1019
  *
991
1020
  * @public
992
1021
  */
993
- export declare interface CreateVersionAction {
1022
+ export declare type CreateVersionAction = {
994
1023
  actionType: 'sanity.action.document.version.create'
995
1024
  publishedId: string
996
- document: IdentifiedSanityDocumentStub
997
- }
1025
+ } & (
1026
+ | {
1027
+ document: IdentifiedSanityDocumentStub
1028
+ }
1029
+ | {
1030
+ baseId: string
1031
+ versionId: string
1032
+ ifBaseRevisionId?: string
1033
+ }
1034
+ )
998
1035
 
999
1036
  /** @public */
1000
1037
  export declare interface CurrentSanityUser {
@@ -1278,6 +1315,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
1278
1315
  */
1279
1316
  export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
1280
1317
 
1318
+ /**
1319
+ * A string constant containing the experimental API version warning message.
1320
+ * Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
1321
+ *
1322
+ * @example
1323
+ * ```typescript
1324
+ * import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
1325
+ *
1326
+ * const client = createClient({
1327
+ * projectId: 'your-project-id',
1328
+ * dataset: 'production',
1329
+ * apiVersion: 'vX', // experimental version
1330
+ * ignoreWarnings: EXPERIMENTAL_API_WARNING
1331
+ * })
1332
+ * ```
1333
+ *
1334
+ * @public
1335
+ */
1336
+ export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
1337
+
1281
1338
  /**
1282
1339
  *
1283
1340
  *
@@ -1693,6 +1750,25 @@ export declare interface GroqAgentActionParam {
1693
1750
  params?: Record<string, string>
1694
1751
  }
1695
1752
 
1753
+ /**
1754
+ * Shared properties for HTTP errors (eg both ClientError and ServerError)
1755
+ * Use `isHttpError` for type narrowing and accessing response properties.
1756
+ *
1757
+ * @public
1758
+ */
1759
+ export declare interface HttpError {
1760
+ statusCode: number
1761
+ message: string
1762
+ response: {
1763
+ body: unknown
1764
+ url: string
1765
+ method: string
1766
+ headers: Record<string, string>
1767
+ statusCode: number
1768
+ statusMessage: string | null
1769
+ }
1770
+ }
1771
+
1696
1772
  /** @public */
1697
1773
  export declare type HttpRequest = {
1698
1774
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1802,6 +1878,15 @@ export declare type InsertPatch =
1802
1878
  items: Any[]
1803
1879
  }
1804
1880
 
1881
+ /**
1882
+ * Checks if the provided error is an HTTP error.
1883
+ *
1884
+ * @param error - The error to check.
1885
+ * @returns `true` if the error is an HTTP error, `false` otherwise.
1886
+ * @public
1887
+ */
1888
+ export declare function isHttpError(error: unknown): error is HttpError
1889
+
1805
1890
  /** @internal */
1806
1891
  export declare function isQueryParseError(error: object): error is QueryParseError
1807
1892
 
@@ -3051,6 +3136,15 @@ export declare class ObservableSanityClient {
3051
3136
  },
3052
3137
  options?: BaseActionOptions,
3053
3138
  ): Observable<SingleActionResult | MultipleActionResult>
3139
+ createVersion(
3140
+ args: {
3141
+ baseId: string
3142
+ releaseId: string
3143
+ publishedId: string
3144
+ ifBaseRevisionId?: string
3145
+ },
3146
+ options?: BaseActionOptions,
3147
+ ): Observable<SingleActionResult | MultipleActionResult>
3054
3148
  /**
3055
3149
  * Deletes a document with the given document ID.
3056
3150
  * Returns an observable that resolves to the deleted document.
@@ -4766,7 +4860,8 @@ export declare class SanityClient {
4766
4860
  * Creates a new version of a published document.
4767
4861
  *
4768
4862
  * @remarks
4769
- * * Requires a document with a `_type` property.
4863
+ * * The preferred approach is to use `baseId` to refer to the existing published document, but it is also possible to provide a complete `document` instead.
4864
+ * * If `document` is provided, it must have a `_type` property.
4770
4865
  * * Creating a version with no `releaseId` will create a new draft version of the published document.
4771
4866
  * * If the `document._id` is defined, it should be a draft or release version ID that matches the version ID generated from `publishedId` and `releaseId`.
4772
4867
  * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
@@ -4775,17 +4870,18 @@ export declare class SanityClient {
4775
4870
  * @category Versions
4776
4871
  *
4777
4872
  * @param params - Version action parameters:
4873
+ * - `baseId` - The ID of the published document from which to create a new version from.
4874
+ * - `ifBaseRevisionId` - If `baseId` is provided, this ensures the `baseId`'s revision Id is as expected before creating the new version from it.
4778
4875
  * - `document` - The document to create as a new version (must include `_type`).
4779
4876
  * - `publishedId` - The ID of the published document being versioned.
4780
4877
  * - `releaseId` - The ID of the release to create the version for.
4781
4878
  * @param options - Additional action options.
4782
4879
  * @returns A promise that resolves to the `transactionId`.
4783
4880
  *
4784
- * @example Creating a new version of a published document with a generated version ID
4881
+ * @example Creating a new version of a published document
4785
4882
  * ```ts
4786
4883
  * const transactionId = await client.createVersion({
4787
- * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
4788
- * document: {_type: 'myDocument', title: 'My Document'},
4884
+ * baseId: 'myDocument',
4789
4885
  * publishedId: 'myDocument',
4790
4886
  * releaseId: 'myRelease',
4791
4887
  * })
@@ -4798,25 +4894,11 @@ export declare class SanityClient {
4798
4894
  * // }
4799
4895
  * ```
4800
4896
  *
4801
- * @example Creating a new version of a published document with a specified version ID
4802
- * ```ts
4803
- * const transactionId = await client.createVersion({
4804
- * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
4805
- * // `publishedId` and `releaseId` are not required since `document._id` has been specified
4806
- * })
4807
- *
4808
- * // The following document will be created:
4809
- * // {
4810
- * // _id: 'versions.myRelease.myDocument',
4811
- * // _type: 'myDocument',
4812
- * // title: 'My Document',
4813
- * // }
4814
- * ```
4815
4897
  *
4816
4898
  * @example Creating a new draft version of a published document
4817
4899
  * ```ts
4818
4900
  * const transactionId = await client.createVersion({
4819
- * document: {_type: 'myDocument', title: 'My Document'},
4901
+ * baseId: 'myDocument',
4820
4902
  * publishedId: 'myDocument',
4821
4903
  * })
4822
4904
  *
@@ -4844,6 +4926,15 @@ export declare class SanityClient {
4844
4926
  },
4845
4927
  options?: BaseActionOptions,
4846
4928
  ): Promise<SingleActionResult | MultipleActionResult>
4929
+ createVersion(
4930
+ args: {
4931
+ publishedId: string
4932
+ baseId: string
4933
+ releaseId: string
4934
+ ifBaseRevisionId?: string
4935
+ },
4936
+ options?: BaseActionOptions,
4937
+ ): Promise<SingleActionResult | MultipleActionResult>
4847
4938
  /**
4848
4939
  * Deletes a document with the given document ID.
4849
4940
  * Returns a promise that resolves to the deleted document.
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { stegaClean } from "./_chunks-es/stegaClean.js";
7
7
  import { combineLatestWith, map, filter, finalize as finalize$1 } from "rxjs/operators";
8
8
  import { getVersionFromId, isDraftId, getVersionId, getDraftId, isVersionId, getPublishedId } from "@sanity/client/csm";
9
9
  import { customAlphabet } from "nanoid";
10
- import { validateObject, validateInsert, requireDocumentId, validateDocumentId, requireDocumentType, resourceConfig, hasDataset, requestTag, printPreviewDraftsDeprecationWarning, validateApiPerspective, printCdnPreviewDraftsWarning, validateAssetType, resourceGuard, dataset, validateVersionIdMatch, defaultConfig, initConfig, printNoDefaultExport } from "./_chunks-es/config.js";
10
+ import { validateObject, validateInsert, requireDocumentId, validateDocumentId, requireDocumentType, printCreateVersionWithBaseIdWarning, resourceConfig, hasDataset, requestTag, printPreviewDraftsDeprecationWarning, validateApiPerspective, printCdnPreviewDraftsWarning, validateAssetType, resourceGuard, dataset, validateVersionIdMatch, defaultConfig, initConfig, printNoDefaultExport } from "./_chunks-es/config.js";
11
11
  const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
12
12
  function codeFrame(query, location2, message) {
13
13
  const lines = query.split(NEWLINE), loc = {
@@ -77,6 +77,12 @@ function columnToLine(column, lines) {
77
77
  };
78
78
  }
79
79
  const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
80
+ function isHttpError(error) {
81
+ if (!isRecord(error))
82
+ return !1;
83
+ const response = error.response;
84
+ return !(typeof error.statusCode != "number" || typeof error.message != "string" || !isRecord(response) || typeof response.body > "u" || typeof response.url != "string" || typeof response.method != "string" || typeof response.headers != "object" || typeof response.statusCode != "number");
85
+ }
80
86
  class ClientError extends Error {
81
87
  response;
82
88
  statusCode = 400;
@@ -177,22 +183,22 @@ const httpError = {
177
183
  return res;
178
184
  }
179
185
  };
180
- function printWarnings() {
181
- const seen = {};
186
+ function printWarnings(config = {}) {
187
+ const seen = {}, shouldIgnoreWarning = (message) => config.ignoreWarnings === void 0 ? !1 : (Array.isArray(config.ignoreWarnings) ? config.ignoreWarnings : [config.ignoreWarnings]).some((pattern) => typeof pattern == "string" ? message.includes(pattern) : pattern instanceof RegExp ? pattern.test(message) : !1);
182
188
  return {
183
189
  onResponse: (res) => {
184
190
  const warn = res.headers["x-sanity-warning"], warnings = Array.isArray(warn) ? warn : [warn];
185
191
  for (const msg of warnings)
186
- !msg || seen[msg] || (seen[msg] = !0, console.warn(msg));
192
+ !msg || seen[msg] || shouldIgnoreWarning(msg) || (seen[msg] = !0, console.warn(msg));
187
193
  return res;
188
194
  }
189
195
  };
190
196
  }
191
- function defineHttpRequest(envMiddleware) {
197
+ function defineHttpRequest(envMiddleware, config = {}) {
192
198
  return getIt([
193
199
  retry({ shouldRetry }),
194
200
  ...envMiddleware,
195
- printWarnings(),
201
+ printWarnings(config),
196
202
  jsonRequest(),
197
203
  jsonResponse(),
198
204
  progress(),
@@ -205,6 +211,7 @@ function shouldRetry(err, attempt, options) {
205
211
  const isSafe = options.method === "GET" || options.method === "HEAD", isQuery2 = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
206
212
  return (isSafe || isQuery2) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options);
207
213
  }
214
+ const EXPERIMENTAL_API_WARNING = "This is an experimental API version";
208
215
  class ConnectionFailedError extends Error {
209
216
  name = "ConnectionFailedError";
210
217
  }
@@ -780,12 +787,27 @@ function _createOrReplace(client, httpRequest, doc, options) {
780
787
  return requireDocumentId("createOrReplace", doc), _create(client, httpRequest, doc, "createOrReplace", options);
781
788
  }
782
789
  function _createVersion(client, httpRequest, doc, publishedId, options) {
783
- return requireDocumentId("createVersion", doc), requireDocumentType("createVersion", doc), _action(client, httpRequest, {
790
+ return requireDocumentId("createVersion", doc), requireDocumentType("createVersion", doc), printCreateVersionWithBaseIdWarning(), _action(client, httpRequest, {
784
791
  actionType: "sanity.action.document.version.create",
785
792
  publishedId,
786
793
  document: doc
787
794
  }, options);
788
795
  }
796
+ function _createVersionFromBase(client, httpRequest, publishedId, baseId, releaseId, ifBaseRevisionId, options) {
797
+ if (!baseId)
798
+ throw new Error("`createVersion()` requires `baseId` when no `document` is provided");
799
+ if (!publishedId)
800
+ throw new Error("`createVersion()` requires `publishedId` when `baseId` is provided");
801
+ validateDocumentId("createVersion", baseId), validateDocumentId("createVersion", publishedId);
802
+ const createVersionAction = {
803
+ actionType: "sanity.action.document.version.create",
804
+ publishedId,
805
+ baseId,
806
+ versionId: releaseId ? getVersionId(publishedId, releaseId) : getDraftId(publishedId),
807
+ ifBaseRevisionId
808
+ };
809
+ return _action(client, httpRequest, createVersionAction, options);
810
+ }
789
811
  function _delete(client, httpRequest, selection, options) {
790
812
  return _dataRequest(
791
813
  client,
@@ -2071,8 +2093,20 @@ class ObservableSanityClient {
2071
2093
  createVersion({
2072
2094
  document,
2073
2095
  publishedId,
2074
- releaseId
2096
+ releaseId,
2097
+ baseId,
2098
+ ifBaseRevisionId
2075
2099
  }, options) {
2100
+ if (!document)
2101
+ return _createVersionFromBase(
2102
+ this,
2103
+ this.#httpRequest,
2104
+ publishedId,
2105
+ baseId,
2106
+ releaseId,
2107
+ ifBaseRevisionId,
2108
+ options
2109
+ );
2076
2110
  const documentVersionId = deriveDocumentVersionId("createVersion", {
2077
2111
  document,
2078
2112
  publishedId,
@@ -2323,8 +2357,22 @@ class SanityClient {
2323
2357
  createVersion({
2324
2358
  document,
2325
2359
  publishedId,
2326
- releaseId
2360
+ releaseId,
2361
+ baseId,
2362
+ ifBaseRevisionId
2327
2363
  }, options) {
2364
+ if (!document)
2365
+ return firstValueFrom(
2366
+ _createVersionFromBase(
2367
+ this,
2368
+ this.#httpRequest,
2369
+ publishedId,
2370
+ baseId,
2371
+ releaseId,
2372
+ ifBaseRevisionId,
2373
+ options
2374
+ )
2375
+ );
2328
2376
  const documentVersionId = deriveDocumentVersionId("createVersion", {
2329
2377
  document,
2330
2378
  publishedId,
@@ -2493,7 +2541,9 @@ class SanityClient {
2493
2541
  }
2494
2542
  function defineCreateClientExports(envMiddleware, ClassConstructor) {
2495
2543
  return { requester: defineHttpRequest(envMiddleware), createClient: (config) => {
2496
- const clientRequester = defineHttpRequest(envMiddleware);
2544
+ const clientRequester = defineHttpRequest(envMiddleware, {
2545
+ ignoreWarnings: config.ignoreWarnings
2546
+ });
2497
2547
  return new ClassConstructor(
2498
2548
  (options, requester2) => (requester2 || clientRequester)({
2499
2549
  maxRedirects: 0,
@@ -2510,7 +2560,7 @@ function defineDeprecatedCreateClient(createClient2) {
2510
2560
  return printNoDefaultExport(), createClient2(config);
2511
2561
  };
2512
2562
  }
2513
- var name = "@sanity/client", version = "7.6.0";
2563
+ var name = "@sanity/client", version = "7.8.0";
2514
2564
  const middleware = [
2515
2565
  debug({ verbose: !0, namespace: "sanity:client" }),
2516
2566
  headers({ "User-Agent": `${name} ${version}` }),
@@ -2536,6 +2586,7 @@ export {
2536
2586
  ConnectionFailedError,
2537
2587
  CorsOriginError,
2538
2588
  DisconnectError,
2589
+ EXPERIMENTAL_API_WARNING,
2539
2590
  MessageError,
2540
2591
  MessageParseError,
2541
2592
  ObservablePatch,
@@ -2549,6 +2600,7 @@ export {
2549
2600
  createClient,
2550
2601
  deprecatedCreateClient as default,
2551
2602
  formatQueryParseError,
2603
+ isHttpError,
2552
2604
  isQueryParseError,
2553
2605
  requester,
2554
2606
  adapter as unstable__adapter,