@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.
@@ -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
@@ -981,16 +1005,29 @@ export declare interface CreateReleaseAction {
981
1005
  }
982
1006
 
983
1007
  /**
984
- * Creates a new version of an existing document, attached to the release as given
985
- * by `document._id`
1008
+ * Creates a new version of an existing document.
1009
+ *
1010
+ * If the `document` is provided, the version is created from the document
1011
+ * attached to the release as given by `document._id`
1012
+ *
1013
+ * If the `baseId` and `versionId` are provided, the version is created from the base document
1014
+ * and the version is attached to the release as given by `publishedId` and `versionId`
986
1015
  *
987
1016
  * @public
988
1017
  */
989
- export declare interface CreateVersionAction {
1018
+ export declare type CreateVersionAction = {
990
1019
  actionType: 'sanity.action.document.version.create'
991
1020
  publishedId: string
992
- document: IdentifiedSanityDocumentStub
993
- }
1021
+ } & (
1022
+ | {
1023
+ document: IdentifiedSanityDocumentStub
1024
+ }
1025
+ | {
1026
+ baseId: string
1027
+ versionId: string
1028
+ ifBaseRevisionId?: string
1029
+ }
1030
+ )
994
1031
 
995
1032
  /** @public */
996
1033
  export declare interface CurrentSanityUser {
@@ -1274,6 +1311,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
1274
1311
  */
1275
1312
  export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
1276
1313
 
1314
+ /**
1315
+ * A string constant containing the experimental API version warning message.
1316
+ * Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
1317
+ *
1318
+ * @example
1319
+ * ```typescript
1320
+ * import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
1321
+ *
1322
+ * const client = createClient({
1323
+ * projectId: 'your-project-id',
1324
+ * dataset: 'production',
1325
+ * apiVersion: 'vX', // experimental version
1326
+ * ignoreWarnings: EXPERIMENTAL_API_WARNING
1327
+ * })
1328
+ * ```
1329
+ *
1330
+ * @public
1331
+ */
1332
+ export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
1333
+
1277
1334
  /**
1278
1335
  *
1279
1336
  *
@@ -1689,6 +1746,25 @@ export declare interface GroqAgentActionParam {
1689
1746
  params?: Record<string, string>
1690
1747
  }
1691
1748
 
1749
+ /**
1750
+ * Shared properties for HTTP errors (eg both ClientError and ServerError)
1751
+ * Use `isHttpError` for type narrowing and accessing response properties.
1752
+ *
1753
+ * @public
1754
+ */
1755
+ export declare interface HttpError {
1756
+ statusCode: number
1757
+ message: string
1758
+ response: {
1759
+ body: unknown
1760
+ url: string
1761
+ method: string
1762
+ headers: Record<string, string>
1763
+ statusCode: number
1764
+ statusMessage: string | null
1765
+ }
1766
+ }
1767
+
1692
1768
  /** @public */
1693
1769
  export declare type HttpRequest = {
1694
1770
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1798,6 +1874,15 @@ export declare type InsertPatch =
1798
1874
  items: Any[]
1799
1875
  }
1800
1876
 
1877
+ /**
1878
+ * Checks if the provided error is an HTTP error.
1879
+ *
1880
+ * @param error - The error to check.
1881
+ * @returns `true` if the error is an HTTP error, `false` otherwise.
1882
+ * @public
1883
+ */
1884
+ export declare function isHttpError(error: unknown): error is HttpError
1885
+
1801
1886
  /** @internal */
1802
1887
  export declare function isQueryParseError(error: object): error is QueryParseError
1803
1888
 
@@ -3047,6 +3132,15 @@ export declare class ObservableSanityClient {
3047
3132
  },
3048
3133
  options?: BaseActionOptions,
3049
3134
  ): Observable<SingleActionResult | MultipleActionResult>
3135
+ createVersion(
3136
+ args: {
3137
+ baseId: string
3138
+ releaseId: string
3139
+ publishedId: string
3140
+ ifBaseRevisionId?: string
3141
+ },
3142
+ options?: BaseActionOptions,
3143
+ ): Observable<SingleActionResult | MultipleActionResult>
3050
3144
  /**
3051
3145
  * Deletes a document with the given document ID.
3052
3146
  * Returns an observable that resolves to the deleted document.
@@ -4762,7 +4856,8 @@ export declare class SanityClient {
4762
4856
  * Creates a new version of a published document.
4763
4857
  *
4764
4858
  * @remarks
4765
- * * Requires a document with a `_type` property.
4859
+ * * 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.
4860
+ * * If `document` is provided, it must have a `_type` property.
4766
4861
  * * Creating a version with no `releaseId` will create a new draft version of the published document.
4767
4862
  * * 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`.
4768
4863
  * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
@@ -4771,17 +4866,18 @@ export declare class SanityClient {
4771
4866
  * @category Versions
4772
4867
  *
4773
4868
  * @param params - Version action parameters:
4869
+ * - `baseId` - The ID of the published document from which to create a new version from.
4870
+ * - `ifBaseRevisionId` - If `baseId` is provided, this ensures the `baseId`'s revision Id is as expected before creating the new version from it.
4774
4871
  * - `document` - The document to create as a new version (must include `_type`).
4775
4872
  * - `publishedId` - The ID of the published document being versioned.
4776
4873
  * - `releaseId` - The ID of the release to create the version for.
4777
4874
  * @param options - Additional action options.
4778
4875
  * @returns A promise that resolves to the `transactionId`.
4779
4876
  *
4780
- * @example Creating a new version of a published document with a generated version ID
4877
+ * @example Creating a new version of a published document
4781
4878
  * ```ts
4782
4879
  * const transactionId = await client.createVersion({
4783
- * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
4784
- * document: {_type: 'myDocument', title: 'My Document'},
4880
+ * baseId: 'myDocument',
4785
4881
  * publishedId: 'myDocument',
4786
4882
  * releaseId: 'myRelease',
4787
4883
  * })
@@ -4794,25 +4890,11 @@ export declare class SanityClient {
4794
4890
  * // }
4795
4891
  * ```
4796
4892
  *
4797
- * @example Creating a new version of a published document with a specified version ID
4798
- * ```ts
4799
- * const transactionId = await client.createVersion({
4800
- * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
4801
- * // `publishedId` and `releaseId` are not required since `document._id` has been specified
4802
- * })
4803
- *
4804
- * // The following document will be created:
4805
- * // {
4806
- * // _id: 'versions.myRelease.myDocument',
4807
- * // _type: 'myDocument',
4808
- * // title: 'My Document',
4809
- * // }
4810
- * ```
4811
4893
  *
4812
4894
  * @example Creating a new draft version of a published document
4813
4895
  * ```ts
4814
4896
  * const transactionId = await client.createVersion({
4815
- * document: {_type: 'myDocument', title: 'My Document'},
4897
+ * baseId: 'myDocument',
4816
4898
  * publishedId: 'myDocument',
4817
4899
  * })
4818
4900
  *
@@ -4840,6 +4922,15 @@ export declare class SanityClient {
4840
4922
  },
4841
4923
  options?: BaseActionOptions,
4842
4924
  ): Promise<SingleActionResult | MultipleActionResult>
4925
+ createVersion(
4926
+ args: {
4927
+ publishedId: string
4928
+ baseId: string
4929
+ releaseId: string
4930
+ ifBaseRevisionId?: string
4931
+ },
4932
+ options?: BaseActionOptions,
4933
+ ): Promise<SingleActionResult | MultipleActionResult>
4843
4934
  /**
4844
4935
  * Deletes a document with the given document ID.
4845
4936
  * Returns a promise that resolves to the deleted document.
@@ -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
@@ -981,16 +1005,29 @@ export declare interface CreateReleaseAction {
981
1005
  }
982
1006
 
983
1007
  /**
984
- * Creates a new version of an existing document, attached to the release as given
985
- * by `document._id`
1008
+ * Creates a new version of an existing document.
1009
+ *
1010
+ * If the `document` is provided, the version is created from the document
1011
+ * attached to the release as given by `document._id`
1012
+ *
1013
+ * If the `baseId` and `versionId` are provided, the version is created from the base document
1014
+ * and the version is attached to the release as given by `publishedId` and `versionId`
986
1015
  *
987
1016
  * @public
988
1017
  */
989
- export declare interface CreateVersionAction {
1018
+ export declare type CreateVersionAction = {
990
1019
  actionType: 'sanity.action.document.version.create'
991
1020
  publishedId: string
992
- document: IdentifiedSanityDocumentStub
993
- }
1021
+ } & (
1022
+ | {
1023
+ document: IdentifiedSanityDocumentStub
1024
+ }
1025
+ | {
1026
+ baseId: string
1027
+ versionId: string
1028
+ ifBaseRevisionId?: string
1029
+ }
1030
+ )
994
1031
 
995
1032
  /** @public */
996
1033
  export declare interface CurrentSanityUser {
@@ -1274,6 +1311,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
1274
1311
  */
1275
1312
  export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
1276
1313
 
1314
+ /**
1315
+ * A string constant containing the experimental API version warning message.
1316
+ * Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
1317
+ *
1318
+ * @example
1319
+ * ```typescript
1320
+ * import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
1321
+ *
1322
+ * const client = createClient({
1323
+ * projectId: 'your-project-id',
1324
+ * dataset: 'production',
1325
+ * apiVersion: 'vX', // experimental version
1326
+ * ignoreWarnings: EXPERIMENTAL_API_WARNING
1327
+ * })
1328
+ * ```
1329
+ *
1330
+ * @public
1331
+ */
1332
+ export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
1333
+
1277
1334
  /**
1278
1335
  *
1279
1336
  *
@@ -1689,6 +1746,25 @@ export declare interface GroqAgentActionParam {
1689
1746
  params?: Record<string, string>
1690
1747
  }
1691
1748
 
1749
+ /**
1750
+ * Shared properties for HTTP errors (eg both ClientError and ServerError)
1751
+ * Use `isHttpError` for type narrowing and accessing response properties.
1752
+ *
1753
+ * @public
1754
+ */
1755
+ export declare interface HttpError {
1756
+ statusCode: number
1757
+ message: string
1758
+ response: {
1759
+ body: unknown
1760
+ url: string
1761
+ method: string
1762
+ headers: Record<string, string>
1763
+ statusCode: number
1764
+ statusMessage: string | null
1765
+ }
1766
+ }
1767
+
1692
1768
  /** @public */
1693
1769
  export declare type HttpRequest = {
1694
1770
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1798,6 +1874,15 @@ export declare type InsertPatch =
1798
1874
  items: Any[]
1799
1875
  }
1800
1876
 
1877
+ /**
1878
+ * Checks if the provided error is an HTTP error.
1879
+ *
1880
+ * @param error - The error to check.
1881
+ * @returns `true` if the error is an HTTP error, `false` otherwise.
1882
+ * @public
1883
+ */
1884
+ export declare function isHttpError(error: unknown): error is HttpError
1885
+
1801
1886
  /** @internal */
1802
1887
  export declare function isQueryParseError(error: object): error is QueryParseError
1803
1888
 
@@ -3047,6 +3132,15 @@ export declare class ObservableSanityClient {
3047
3132
  },
3048
3133
  options?: BaseActionOptions,
3049
3134
  ): Observable<SingleActionResult | MultipleActionResult>
3135
+ createVersion(
3136
+ args: {
3137
+ baseId: string
3138
+ releaseId: string
3139
+ publishedId: string
3140
+ ifBaseRevisionId?: string
3141
+ },
3142
+ options?: BaseActionOptions,
3143
+ ): Observable<SingleActionResult | MultipleActionResult>
3050
3144
  /**
3051
3145
  * Deletes a document with the given document ID.
3052
3146
  * Returns an observable that resolves to the deleted document.
@@ -4762,7 +4856,8 @@ export declare class SanityClient {
4762
4856
  * Creates a new version of a published document.
4763
4857
  *
4764
4858
  * @remarks
4765
- * * Requires a document with a `_type` property.
4859
+ * * 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.
4860
+ * * If `document` is provided, it must have a `_type` property.
4766
4861
  * * Creating a version with no `releaseId` will create a new draft version of the published document.
4767
4862
  * * 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`.
4768
4863
  * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
@@ -4771,17 +4866,18 @@ export declare class SanityClient {
4771
4866
  * @category Versions
4772
4867
  *
4773
4868
  * @param params - Version action parameters:
4869
+ * - `baseId` - The ID of the published document from which to create a new version from.
4870
+ * - `ifBaseRevisionId` - If `baseId` is provided, this ensures the `baseId`'s revision Id is as expected before creating the new version from it.
4774
4871
  * - `document` - The document to create as a new version (must include `_type`).
4775
4872
  * - `publishedId` - The ID of the published document being versioned.
4776
4873
  * - `releaseId` - The ID of the release to create the version for.
4777
4874
  * @param options - Additional action options.
4778
4875
  * @returns A promise that resolves to the `transactionId`.
4779
4876
  *
4780
- * @example Creating a new version of a published document with a generated version ID
4877
+ * @example Creating a new version of a published document
4781
4878
  * ```ts
4782
4879
  * const transactionId = await client.createVersion({
4783
- * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
4784
- * document: {_type: 'myDocument', title: 'My Document'},
4880
+ * baseId: 'myDocument',
4785
4881
  * publishedId: 'myDocument',
4786
4882
  * releaseId: 'myRelease',
4787
4883
  * })
@@ -4794,25 +4890,11 @@ export declare class SanityClient {
4794
4890
  * // }
4795
4891
  * ```
4796
4892
  *
4797
- * @example Creating a new version of a published document with a specified version ID
4798
- * ```ts
4799
- * const transactionId = await client.createVersion({
4800
- * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
4801
- * // `publishedId` and `releaseId` are not required since `document._id` has been specified
4802
- * })
4803
- *
4804
- * // The following document will be created:
4805
- * // {
4806
- * // _id: 'versions.myRelease.myDocument',
4807
- * // _type: 'myDocument',
4808
- * // title: 'My Document',
4809
- * // }
4810
- * ```
4811
4893
  *
4812
4894
  * @example Creating a new draft version of a published document
4813
4895
  * ```ts
4814
4896
  * const transactionId = await client.createVersion({
4815
- * document: {_type: 'myDocument', title: 'My Document'},
4897
+ * baseId: 'myDocument',
4816
4898
  * publishedId: 'myDocument',
4817
4899
  * })
4818
4900
  *
@@ -4840,6 +4922,15 @@ export declare class SanityClient {
4840
4922
  },
4841
4923
  options?: BaseActionOptions,
4842
4924
  ): Promise<SingleActionResult | MultipleActionResult>
4925
+ createVersion(
4926
+ args: {
4927
+ publishedId: string
4928
+ baseId: string
4929
+ releaseId: string
4930
+ ifBaseRevisionId?: string
4931
+ },
4932
+ options?: BaseActionOptions,
4933
+ ): Promise<SingleActionResult | MultipleActionResult>
4843
4934
  /**
4844
4935
  * Deletes a document with the given document ID.
4845
4936
  * Returns a promise that resolves to the deleted document.
@@ -75,6 +75,12 @@ function columnToLine(column, lines) {
75
75
  };
76
76
  }
77
77
  const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
78
+ function isHttpError(error) {
79
+ if (!isRecord(error))
80
+ return !1;
81
+ const response = error.response;
82
+ 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");
83
+ }
78
84
  class ClientError extends Error {
79
85
  response;
80
86
  statusCode = 400;
@@ -175,22 +181,22 @@ const httpError = {
175
181
  return res;
176
182
  }
177
183
  };
178
- function printWarnings() {
179
- const seen = {};
184
+ function printWarnings(config = {}) {
185
+ 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);
180
186
  return {
181
187
  onResponse: (res) => {
182
188
  const warn = res.headers["x-sanity-warning"], warnings = Array.isArray(warn) ? warn : [warn];
183
189
  for (const msg of warnings)
184
- !msg || seen[msg] || (seen[msg] = !0, console.warn(msg));
190
+ !msg || seen[msg] || shouldIgnoreWarning(msg) || (seen[msg] = !0, console.warn(msg));
185
191
  return res;
186
192
  }
187
193
  };
188
194
  }
189
- function defineHttpRequest(envMiddleware2) {
195
+ function defineHttpRequest(envMiddleware2, config = {}) {
190
196
  return getIt([
191
197
  retry({ shouldRetry }),
192
198
  ...envMiddleware2,
193
- printWarnings(),
199
+ printWarnings(config),
194
200
  jsonRequest(),
195
201
  jsonResponse(),
196
202
  progress(),
@@ -280,7 +286,7 @@ const VALID_ASSET_TYPES = ["image", "file"], VALID_INSERT_LOCATIONS = ["before",
280
286
  }, resourceGuard = (service, config) => {
281
287
  if (config["~experimental_resource"])
282
288
  throw new Error(`\`${service}\` does not support resource-based operations`);
283
- };
289
+ }, EXPERIMENTAL_API_WARNING = "This is an experimental API version";
284
290
  function once(fn) {
285
291
  let didCall = !1, returnValue;
286
292
  return (...args) => (didCall || (returnValue = fn(...args), didCall = !0), returnValue);
@@ -313,6 +319,8 @@ const createWarningPrinter = (message) => (
313
319
  `See ${generateHelpUrl("js-client-api-version")}`
314
320
  ]), printNoDefaultExport = createWarningPrinter([
315
321
  "The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."
322
+ ]), printCreateVersionWithBaseIdWarning = createWarningPrinter([
323
+ "You have called `createVersion()` with a defined `document`. The recommended approach is to provide a `baseId` and `releaseId` instead."
316
324
  ]), defaultCdnHost = "apicdn.sanity.io", defaultConfig = {
317
325
  apiHost: "https://api.sanity.io",
318
326
  apiVersion: "1",
@@ -948,12 +956,27 @@ function _createOrReplace(client, httpRequest, doc, options) {
948
956
  return requireDocumentId("createOrReplace", doc), _create(client, httpRequest, doc, "createOrReplace", options);
949
957
  }
950
958
  function _createVersion(client, httpRequest, doc, publishedId, options) {
951
- return requireDocumentId("createVersion", doc), requireDocumentType("createVersion", doc), _action(client, httpRequest, {
959
+ return requireDocumentId("createVersion", doc), requireDocumentType("createVersion", doc), printCreateVersionWithBaseIdWarning(), _action(client, httpRequest, {
952
960
  actionType: "sanity.action.document.version.create",
953
961
  publishedId,
954
962
  document: doc
955
963
  }, options);
956
964
  }
965
+ function _createVersionFromBase(client, httpRequest, publishedId, baseId, releaseId, ifBaseRevisionId, options) {
966
+ if (!baseId)
967
+ throw new Error("`createVersion()` requires `baseId` when no `document` is provided");
968
+ if (!publishedId)
969
+ throw new Error("`createVersion()` requires `publishedId` when `baseId` is provided");
970
+ validateDocumentId("createVersion", baseId), validateDocumentId("createVersion", publishedId);
971
+ const createVersionAction = {
972
+ actionType: "sanity.action.document.version.create",
973
+ publishedId,
974
+ baseId,
975
+ versionId: releaseId ? getVersionId(publishedId, releaseId) : getDraftId(publishedId),
976
+ ifBaseRevisionId
977
+ };
978
+ return _action(client, httpRequest, createVersionAction, options);
979
+ }
957
980
  function _delete(client, httpRequest, selection, options) {
958
981
  return _dataRequest(
959
982
  client,
@@ -2239,8 +2262,20 @@ class ObservableSanityClient {
2239
2262
  createVersion({
2240
2263
  document,
2241
2264
  publishedId,
2242
- releaseId
2265
+ releaseId,
2266
+ baseId,
2267
+ ifBaseRevisionId
2243
2268
  }, options) {
2269
+ if (!document)
2270
+ return _createVersionFromBase(
2271
+ this,
2272
+ this.#httpRequest,
2273
+ publishedId,
2274
+ baseId,
2275
+ releaseId,
2276
+ ifBaseRevisionId,
2277
+ options
2278
+ );
2244
2279
  const documentVersionId = deriveDocumentVersionId("createVersion", {
2245
2280
  document,
2246
2281
  publishedId,
@@ -2491,8 +2526,22 @@ class SanityClient {
2491
2526
  createVersion({
2492
2527
  document,
2493
2528
  publishedId,
2494
- releaseId
2529
+ releaseId,
2530
+ baseId,
2531
+ ifBaseRevisionId
2495
2532
  }, options) {
2533
+ if (!document)
2534
+ return firstValueFrom(
2535
+ _createVersionFromBase(
2536
+ this,
2537
+ this.#httpRequest,
2538
+ publishedId,
2539
+ baseId,
2540
+ releaseId,
2541
+ ifBaseRevisionId,
2542
+ options
2543
+ )
2544
+ );
2496
2545
  const documentVersionId = deriveDocumentVersionId("createVersion", {
2497
2546
  document,
2498
2547
  publishedId,
@@ -2661,7 +2710,9 @@ class SanityClient {
2661
2710
  }
2662
2711
  function defineCreateClientExports(envMiddleware2, ClassConstructor) {
2663
2712
  return { requester: defineHttpRequest(envMiddleware2), createClient: (config) => {
2664
- const clientRequester = defineHttpRequest(envMiddleware2);
2713
+ const clientRequester = defineHttpRequest(envMiddleware2, {
2714
+ ignoreWarnings: config.ignoreWarnings
2715
+ });
2665
2716
  return new ClassConstructor(
2666
2717
  (options, requester2) => (requester2 || clientRequester)({
2667
2718
  maxRedirects: 0,
@@ -2688,6 +2739,7 @@ export {
2688
2739
  ConnectionFailedError,
2689
2740
  CorsOriginError,
2690
2741
  DisconnectError,
2742
+ EXPERIMENTAL_API_WARNING,
2691
2743
  MessageError,
2692
2744
  MessageParseError,
2693
2745
  ObservablePatch,
@@ -2701,6 +2753,7 @@ export {
2701
2753
  createClient,
2702
2754
  deprecatedCreateClient as default,
2703
2755
  formatQueryParseError,
2756
+ isHttpError,
2704
2757
  isQueryParseError,
2705
2758
  requester,
2706
2759
  adapter as unstable__adapter,