@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/_chunks-cjs/config.cjs +3 -0
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +3 -0
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +63 -10
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +115 -24
- package/dist/index.browser.d.ts +115 -24
- package/dist/index.browser.js +63 -10
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +62 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +115 -24
- package/dist/index.d.ts +115 -24
- package/dist/index.js +63 -11
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +115 -24
- package/dist/stega.browser.d.ts +115 -24
- package/dist/stega.d.cts +115 -24
- package/dist/stega.d.ts +115 -24
- package/package.json +1 -1
- package/src/SanityClient.ts +61 -21
- package/src/data/dataMethods.ts +39 -2
- package/src/defineCreateClient.ts +5 -1
- package/src/http/errors.ts +53 -0
- package/src/http/request.ts +31 -3
- package/src/types.ts +62 -5
- package/src/warnings.ts +4 -0
- package/umd/sanityClient.js +63 -10
- package/umd/sanityClient.min.js +2 -2
package/dist/stega.browser.d.cts
CHANGED
|
@@ -692,6 +692,30 @@ export declare interface ClientConfig {
|
|
|
692
692
|
*/
|
|
693
693
|
headers?: Record<string, string>
|
|
694
694
|
ignoreBrowserTokenWarning?: boolean
|
|
695
|
+
/**
|
|
696
|
+
* Ignore specific warning messages from the client.
|
|
697
|
+
*
|
|
698
|
+
* @remarks
|
|
699
|
+
* - String values perform substring matching (not exact matching) against warning messages
|
|
700
|
+
* - RegExp values are tested against the full warning message
|
|
701
|
+
* - Array values allow multiple patterns to be specified
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```typescript
|
|
705
|
+
* // Ignore warnings containing "experimental"
|
|
706
|
+
* ignoreWarnings: 'experimental'
|
|
707
|
+
*
|
|
708
|
+
* // Ignore multiple warning types
|
|
709
|
+
* ignoreWarnings: ['experimental', 'deprecated']
|
|
710
|
+
*
|
|
711
|
+
* // Use regex for exact matching
|
|
712
|
+
* ignoreWarnings: /^This is an experimental API version$/
|
|
713
|
+
*
|
|
714
|
+
* // Mix strings and regex patterns
|
|
715
|
+
* ignoreWarnings: ['rate limit', /^deprecated/i]
|
|
716
|
+
* ```
|
|
717
|
+
*/
|
|
718
|
+
ignoreWarnings?: string | RegExp | Array<string | RegExp>
|
|
695
719
|
withCredentials?: boolean
|
|
696
720
|
allowReconfigure?: boolean
|
|
697
721
|
timeout?: number
|
|
@@ -1080,16 +1104,29 @@ export declare interface CreateReleaseAction {
|
|
|
1080
1104
|
}
|
|
1081
1105
|
|
|
1082
1106
|
/**
|
|
1083
|
-
* Creates a new version of an existing document
|
|
1084
|
-
*
|
|
1107
|
+
* Creates a new version of an existing document.
|
|
1108
|
+
*
|
|
1109
|
+
* If the `document` is provided, the version is created from the document
|
|
1110
|
+
* attached to the release as given by `document._id`
|
|
1111
|
+
*
|
|
1112
|
+
* If the `baseId` and `versionId` are provided, the version is created from the base document
|
|
1113
|
+
* and the version is attached to the release as given by `publishedId` and `versionId`
|
|
1085
1114
|
*
|
|
1086
1115
|
* @public
|
|
1087
1116
|
*/
|
|
1088
|
-
export declare
|
|
1117
|
+
export declare type CreateVersionAction = {
|
|
1089
1118
|
actionType: 'sanity.action.document.version.create'
|
|
1090
1119
|
publishedId: string
|
|
1091
|
-
|
|
1092
|
-
|
|
1120
|
+
} & (
|
|
1121
|
+
| {
|
|
1122
|
+
document: IdentifiedSanityDocumentStub
|
|
1123
|
+
}
|
|
1124
|
+
| {
|
|
1125
|
+
baseId: string
|
|
1126
|
+
versionId: string
|
|
1127
|
+
ifBaseRevisionId?: string
|
|
1128
|
+
}
|
|
1129
|
+
)
|
|
1093
1130
|
|
|
1094
1131
|
/** @public */
|
|
1095
1132
|
export declare interface CurrentSanityUser {
|
|
@@ -1385,6 +1422,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
1385
1422
|
*/
|
|
1386
1423
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
1387
1424
|
|
|
1425
|
+
/**
|
|
1426
|
+
* A string constant containing the experimental API version warning message.
|
|
1427
|
+
* Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```typescript
|
|
1431
|
+
* import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
|
|
1432
|
+
*
|
|
1433
|
+
* const client = createClient({
|
|
1434
|
+
* projectId: 'your-project-id',
|
|
1435
|
+
* dataset: 'production',
|
|
1436
|
+
* apiVersion: 'vX', // experimental version
|
|
1437
|
+
* ignoreWarnings: EXPERIMENTAL_API_WARNING
|
|
1438
|
+
* })
|
|
1439
|
+
* ```
|
|
1440
|
+
*
|
|
1441
|
+
* @public
|
|
1442
|
+
*/
|
|
1443
|
+
export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
|
|
1444
|
+
|
|
1388
1445
|
/**
|
|
1389
1446
|
*
|
|
1390
1447
|
*
|
|
@@ -1849,6 +1906,25 @@ export declare interface GroqAgentActionParam {
|
|
|
1849
1906
|
params?: Record<string, string>
|
|
1850
1907
|
}
|
|
1851
1908
|
|
|
1909
|
+
/**
|
|
1910
|
+
* Shared properties for HTTP errors (eg both ClientError and ServerError)
|
|
1911
|
+
* Use `isHttpError` for type narrowing and accessing response properties.
|
|
1912
|
+
*
|
|
1913
|
+
* @public
|
|
1914
|
+
*/
|
|
1915
|
+
export declare interface HttpError {
|
|
1916
|
+
statusCode: number
|
|
1917
|
+
message: string
|
|
1918
|
+
response: {
|
|
1919
|
+
body: unknown
|
|
1920
|
+
url: string
|
|
1921
|
+
method: string
|
|
1922
|
+
headers: Record<string, string>
|
|
1923
|
+
statusCode: number
|
|
1924
|
+
statusMessage: string | null
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1852
1928
|
/** @public */
|
|
1853
1929
|
export declare type HttpRequest = {
|
|
1854
1930
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -1968,6 +2044,15 @@ export declare type InsertPatch =
|
|
|
1968
2044
|
items: Any[]
|
|
1969
2045
|
}
|
|
1970
2046
|
|
|
2047
|
+
/**
|
|
2048
|
+
* Checks if the provided error is an HTTP error.
|
|
2049
|
+
*
|
|
2050
|
+
* @param error - The error to check.
|
|
2051
|
+
* @returns `true` if the error is an HTTP error, `false` otherwise.
|
|
2052
|
+
* @public
|
|
2053
|
+
*/
|
|
2054
|
+
export declare function isHttpError(error: unknown): error is HttpError
|
|
2055
|
+
|
|
1971
2056
|
/** @internal */
|
|
1972
2057
|
export declare function isQueryParseError(error: object): error is QueryParseError
|
|
1973
2058
|
|
|
@@ -3224,6 +3309,15 @@ export declare class ObservableSanityClient {
|
|
|
3224
3309
|
},
|
|
3225
3310
|
options?: BaseActionOptions,
|
|
3226
3311
|
): Observable<SingleActionResult | MultipleActionResult>
|
|
3312
|
+
createVersion(
|
|
3313
|
+
args: {
|
|
3314
|
+
baseId: string
|
|
3315
|
+
releaseId: string
|
|
3316
|
+
publishedId: string
|
|
3317
|
+
ifBaseRevisionId?: string
|
|
3318
|
+
},
|
|
3319
|
+
options?: BaseActionOptions,
|
|
3320
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
3227
3321
|
/**
|
|
3228
3322
|
* Deletes a document with the given document ID.
|
|
3229
3323
|
* Returns an observable that resolves to the deleted document.
|
|
@@ -4951,7 +5045,8 @@ export declare class SanityClient {
|
|
|
4951
5045
|
* Creates a new version of a published document.
|
|
4952
5046
|
*
|
|
4953
5047
|
* @remarks
|
|
4954
|
-
* *
|
|
5048
|
+
* * 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.
|
|
5049
|
+
* * If `document` is provided, it must have a `_type` property.
|
|
4955
5050
|
* * Creating a version with no `releaseId` will create a new draft version of the published document.
|
|
4956
5051
|
* * 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`.
|
|
4957
5052
|
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
@@ -4960,17 +5055,18 @@ export declare class SanityClient {
|
|
|
4960
5055
|
* @category Versions
|
|
4961
5056
|
*
|
|
4962
5057
|
* @param params - Version action parameters:
|
|
5058
|
+
* - `baseId` - The ID of the published document from which to create a new version from.
|
|
5059
|
+
* - `ifBaseRevisionId` - If `baseId` is provided, this ensures the `baseId`'s revision Id is as expected before creating the new version from it.
|
|
4963
5060
|
* - `document` - The document to create as a new version (must include `_type`).
|
|
4964
5061
|
* - `publishedId` - The ID of the published document being versioned.
|
|
4965
5062
|
* - `releaseId` - The ID of the release to create the version for.
|
|
4966
5063
|
* @param options - Additional action options.
|
|
4967
5064
|
* @returns A promise that resolves to the `transactionId`.
|
|
4968
5065
|
*
|
|
4969
|
-
* @example Creating a new version of a published document
|
|
5066
|
+
* @example Creating a new version of a published document
|
|
4970
5067
|
* ```ts
|
|
4971
5068
|
* const transactionId = await client.createVersion({
|
|
4972
|
-
*
|
|
4973
|
-
* document: {_type: 'myDocument', title: 'My Document'},
|
|
5069
|
+
* baseId: 'myDocument',
|
|
4974
5070
|
* publishedId: 'myDocument',
|
|
4975
5071
|
* releaseId: 'myRelease',
|
|
4976
5072
|
* })
|
|
@@ -4983,25 +5079,11 @@ export declare class SanityClient {
|
|
|
4983
5079
|
* // }
|
|
4984
5080
|
* ```
|
|
4985
5081
|
*
|
|
4986
|
-
* @example Creating a new version of a published document with a specified version ID
|
|
4987
|
-
* ```ts
|
|
4988
|
-
* const transactionId = await client.createVersion({
|
|
4989
|
-
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
4990
|
-
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
4991
|
-
* })
|
|
4992
|
-
*
|
|
4993
|
-
* // The following document will be created:
|
|
4994
|
-
* // {
|
|
4995
|
-
* // _id: 'versions.myRelease.myDocument',
|
|
4996
|
-
* // _type: 'myDocument',
|
|
4997
|
-
* // title: 'My Document',
|
|
4998
|
-
* // }
|
|
4999
|
-
* ```
|
|
5000
5082
|
*
|
|
5001
5083
|
* @example Creating a new draft version of a published document
|
|
5002
5084
|
* ```ts
|
|
5003
5085
|
* const transactionId = await client.createVersion({
|
|
5004
|
-
*
|
|
5086
|
+
* baseId: 'myDocument',
|
|
5005
5087
|
* publishedId: 'myDocument',
|
|
5006
5088
|
* })
|
|
5007
5089
|
*
|
|
@@ -5029,6 +5111,15 @@ export declare class SanityClient {
|
|
|
5029
5111
|
},
|
|
5030
5112
|
options?: BaseActionOptions,
|
|
5031
5113
|
): Promise<SingleActionResult | MultipleActionResult>
|
|
5114
|
+
createVersion(
|
|
5115
|
+
args: {
|
|
5116
|
+
publishedId: string
|
|
5117
|
+
baseId: string
|
|
5118
|
+
releaseId: string
|
|
5119
|
+
ifBaseRevisionId?: string
|
|
5120
|
+
},
|
|
5121
|
+
options?: BaseActionOptions,
|
|
5122
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
5032
5123
|
/**
|
|
5033
5124
|
* Deletes a document with the given document ID.
|
|
5034
5125
|
* Returns a promise that resolves to the deleted document.
|
package/dist/stega.browser.d.ts
CHANGED
|
@@ -692,6 +692,30 @@ export declare interface ClientConfig {
|
|
|
692
692
|
*/
|
|
693
693
|
headers?: Record<string, string>
|
|
694
694
|
ignoreBrowserTokenWarning?: boolean
|
|
695
|
+
/**
|
|
696
|
+
* Ignore specific warning messages from the client.
|
|
697
|
+
*
|
|
698
|
+
* @remarks
|
|
699
|
+
* - String values perform substring matching (not exact matching) against warning messages
|
|
700
|
+
* - RegExp values are tested against the full warning message
|
|
701
|
+
* - Array values allow multiple patterns to be specified
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```typescript
|
|
705
|
+
* // Ignore warnings containing "experimental"
|
|
706
|
+
* ignoreWarnings: 'experimental'
|
|
707
|
+
*
|
|
708
|
+
* // Ignore multiple warning types
|
|
709
|
+
* ignoreWarnings: ['experimental', 'deprecated']
|
|
710
|
+
*
|
|
711
|
+
* // Use regex for exact matching
|
|
712
|
+
* ignoreWarnings: /^This is an experimental API version$/
|
|
713
|
+
*
|
|
714
|
+
* // Mix strings and regex patterns
|
|
715
|
+
* ignoreWarnings: ['rate limit', /^deprecated/i]
|
|
716
|
+
* ```
|
|
717
|
+
*/
|
|
718
|
+
ignoreWarnings?: string | RegExp | Array<string | RegExp>
|
|
695
719
|
withCredentials?: boolean
|
|
696
720
|
allowReconfigure?: boolean
|
|
697
721
|
timeout?: number
|
|
@@ -1080,16 +1104,29 @@ export declare interface CreateReleaseAction {
|
|
|
1080
1104
|
}
|
|
1081
1105
|
|
|
1082
1106
|
/**
|
|
1083
|
-
* Creates a new version of an existing document
|
|
1084
|
-
*
|
|
1107
|
+
* Creates a new version of an existing document.
|
|
1108
|
+
*
|
|
1109
|
+
* If the `document` is provided, the version is created from the document
|
|
1110
|
+
* attached to the release as given by `document._id`
|
|
1111
|
+
*
|
|
1112
|
+
* If the `baseId` and `versionId` are provided, the version is created from the base document
|
|
1113
|
+
* and the version is attached to the release as given by `publishedId` and `versionId`
|
|
1085
1114
|
*
|
|
1086
1115
|
* @public
|
|
1087
1116
|
*/
|
|
1088
|
-
export declare
|
|
1117
|
+
export declare type CreateVersionAction = {
|
|
1089
1118
|
actionType: 'sanity.action.document.version.create'
|
|
1090
1119
|
publishedId: string
|
|
1091
|
-
|
|
1092
|
-
|
|
1120
|
+
} & (
|
|
1121
|
+
| {
|
|
1122
|
+
document: IdentifiedSanityDocumentStub
|
|
1123
|
+
}
|
|
1124
|
+
| {
|
|
1125
|
+
baseId: string
|
|
1126
|
+
versionId: string
|
|
1127
|
+
ifBaseRevisionId?: string
|
|
1128
|
+
}
|
|
1129
|
+
)
|
|
1093
1130
|
|
|
1094
1131
|
/** @public */
|
|
1095
1132
|
export declare interface CurrentSanityUser {
|
|
@@ -1385,6 +1422,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
1385
1422
|
*/
|
|
1386
1423
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
1387
1424
|
|
|
1425
|
+
/**
|
|
1426
|
+
* A string constant containing the experimental API version warning message.
|
|
1427
|
+
* Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```typescript
|
|
1431
|
+
* import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
|
|
1432
|
+
*
|
|
1433
|
+
* const client = createClient({
|
|
1434
|
+
* projectId: 'your-project-id',
|
|
1435
|
+
* dataset: 'production',
|
|
1436
|
+
* apiVersion: 'vX', // experimental version
|
|
1437
|
+
* ignoreWarnings: EXPERIMENTAL_API_WARNING
|
|
1438
|
+
* })
|
|
1439
|
+
* ```
|
|
1440
|
+
*
|
|
1441
|
+
* @public
|
|
1442
|
+
*/
|
|
1443
|
+
export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
|
|
1444
|
+
|
|
1388
1445
|
/**
|
|
1389
1446
|
*
|
|
1390
1447
|
*
|
|
@@ -1849,6 +1906,25 @@ export declare interface GroqAgentActionParam {
|
|
|
1849
1906
|
params?: Record<string, string>
|
|
1850
1907
|
}
|
|
1851
1908
|
|
|
1909
|
+
/**
|
|
1910
|
+
* Shared properties for HTTP errors (eg both ClientError and ServerError)
|
|
1911
|
+
* Use `isHttpError` for type narrowing and accessing response properties.
|
|
1912
|
+
*
|
|
1913
|
+
* @public
|
|
1914
|
+
*/
|
|
1915
|
+
export declare interface HttpError {
|
|
1916
|
+
statusCode: number
|
|
1917
|
+
message: string
|
|
1918
|
+
response: {
|
|
1919
|
+
body: unknown
|
|
1920
|
+
url: string
|
|
1921
|
+
method: string
|
|
1922
|
+
headers: Record<string, string>
|
|
1923
|
+
statusCode: number
|
|
1924
|
+
statusMessage: string | null
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1852
1928
|
/** @public */
|
|
1853
1929
|
export declare type HttpRequest = {
|
|
1854
1930
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -1968,6 +2044,15 @@ export declare type InsertPatch =
|
|
|
1968
2044
|
items: Any[]
|
|
1969
2045
|
}
|
|
1970
2046
|
|
|
2047
|
+
/**
|
|
2048
|
+
* Checks if the provided error is an HTTP error.
|
|
2049
|
+
*
|
|
2050
|
+
* @param error - The error to check.
|
|
2051
|
+
* @returns `true` if the error is an HTTP error, `false` otherwise.
|
|
2052
|
+
* @public
|
|
2053
|
+
*/
|
|
2054
|
+
export declare function isHttpError(error: unknown): error is HttpError
|
|
2055
|
+
|
|
1971
2056
|
/** @internal */
|
|
1972
2057
|
export declare function isQueryParseError(error: object): error is QueryParseError
|
|
1973
2058
|
|
|
@@ -3224,6 +3309,15 @@ export declare class ObservableSanityClient {
|
|
|
3224
3309
|
},
|
|
3225
3310
|
options?: BaseActionOptions,
|
|
3226
3311
|
): Observable<SingleActionResult | MultipleActionResult>
|
|
3312
|
+
createVersion(
|
|
3313
|
+
args: {
|
|
3314
|
+
baseId: string
|
|
3315
|
+
releaseId: string
|
|
3316
|
+
publishedId: string
|
|
3317
|
+
ifBaseRevisionId?: string
|
|
3318
|
+
},
|
|
3319
|
+
options?: BaseActionOptions,
|
|
3320
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
3227
3321
|
/**
|
|
3228
3322
|
* Deletes a document with the given document ID.
|
|
3229
3323
|
* Returns an observable that resolves to the deleted document.
|
|
@@ -4951,7 +5045,8 @@ export declare class SanityClient {
|
|
|
4951
5045
|
* Creates a new version of a published document.
|
|
4952
5046
|
*
|
|
4953
5047
|
* @remarks
|
|
4954
|
-
* *
|
|
5048
|
+
* * 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.
|
|
5049
|
+
* * If `document` is provided, it must have a `_type` property.
|
|
4955
5050
|
* * Creating a version with no `releaseId` will create a new draft version of the published document.
|
|
4956
5051
|
* * 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`.
|
|
4957
5052
|
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
@@ -4960,17 +5055,18 @@ export declare class SanityClient {
|
|
|
4960
5055
|
* @category Versions
|
|
4961
5056
|
*
|
|
4962
5057
|
* @param params - Version action parameters:
|
|
5058
|
+
* - `baseId` - The ID of the published document from which to create a new version from.
|
|
5059
|
+
* - `ifBaseRevisionId` - If `baseId` is provided, this ensures the `baseId`'s revision Id is as expected before creating the new version from it.
|
|
4963
5060
|
* - `document` - The document to create as a new version (must include `_type`).
|
|
4964
5061
|
* - `publishedId` - The ID of the published document being versioned.
|
|
4965
5062
|
* - `releaseId` - The ID of the release to create the version for.
|
|
4966
5063
|
* @param options - Additional action options.
|
|
4967
5064
|
* @returns A promise that resolves to the `transactionId`.
|
|
4968
5065
|
*
|
|
4969
|
-
* @example Creating a new version of a published document
|
|
5066
|
+
* @example Creating a new version of a published document
|
|
4970
5067
|
* ```ts
|
|
4971
5068
|
* const transactionId = await client.createVersion({
|
|
4972
|
-
*
|
|
4973
|
-
* document: {_type: 'myDocument', title: 'My Document'},
|
|
5069
|
+
* baseId: 'myDocument',
|
|
4974
5070
|
* publishedId: 'myDocument',
|
|
4975
5071
|
* releaseId: 'myRelease',
|
|
4976
5072
|
* })
|
|
@@ -4983,25 +5079,11 @@ export declare class SanityClient {
|
|
|
4983
5079
|
* // }
|
|
4984
5080
|
* ```
|
|
4985
5081
|
*
|
|
4986
|
-
* @example Creating a new version of a published document with a specified version ID
|
|
4987
|
-
* ```ts
|
|
4988
|
-
* const transactionId = await client.createVersion({
|
|
4989
|
-
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
4990
|
-
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
4991
|
-
* })
|
|
4992
|
-
*
|
|
4993
|
-
* // The following document will be created:
|
|
4994
|
-
* // {
|
|
4995
|
-
* // _id: 'versions.myRelease.myDocument',
|
|
4996
|
-
* // _type: 'myDocument',
|
|
4997
|
-
* // title: 'My Document',
|
|
4998
|
-
* // }
|
|
4999
|
-
* ```
|
|
5000
5082
|
*
|
|
5001
5083
|
* @example Creating a new draft version of a published document
|
|
5002
5084
|
* ```ts
|
|
5003
5085
|
* const transactionId = await client.createVersion({
|
|
5004
|
-
*
|
|
5086
|
+
* baseId: 'myDocument',
|
|
5005
5087
|
* publishedId: 'myDocument',
|
|
5006
5088
|
* })
|
|
5007
5089
|
*
|
|
@@ -5029,6 +5111,15 @@ export declare class SanityClient {
|
|
|
5029
5111
|
},
|
|
5030
5112
|
options?: BaseActionOptions,
|
|
5031
5113
|
): Promise<SingleActionResult | MultipleActionResult>
|
|
5114
|
+
createVersion(
|
|
5115
|
+
args: {
|
|
5116
|
+
publishedId: string
|
|
5117
|
+
baseId: string
|
|
5118
|
+
releaseId: string
|
|
5119
|
+
ifBaseRevisionId?: string
|
|
5120
|
+
},
|
|
5121
|
+
options?: BaseActionOptions,
|
|
5122
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
5032
5123
|
/**
|
|
5033
5124
|
* Deletes a document with the given document ID.
|
|
5034
5125
|
* Returns a promise that resolves to the deleted document.
|
package/dist/stega.d.cts
CHANGED
|
@@ -692,6 +692,30 @@ export declare interface ClientConfig {
|
|
|
692
692
|
*/
|
|
693
693
|
headers?: Record<string, string>
|
|
694
694
|
ignoreBrowserTokenWarning?: boolean
|
|
695
|
+
/**
|
|
696
|
+
* Ignore specific warning messages from the client.
|
|
697
|
+
*
|
|
698
|
+
* @remarks
|
|
699
|
+
* - String values perform substring matching (not exact matching) against warning messages
|
|
700
|
+
* - RegExp values are tested against the full warning message
|
|
701
|
+
* - Array values allow multiple patterns to be specified
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```typescript
|
|
705
|
+
* // Ignore warnings containing "experimental"
|
|
706
|
+
* ignoreWarnings: 'experimental'
|
|
707
|
+
*
|
|
708
|
+
* // Ignore multiple warning types
|
|
709
|
+
* ignoreWarnings: ['experimental', 'deprecated']
|
|
710
|
+
*
|
|
711
|
+
* // Use regex for exact matching
|
|
712
|
+
* ignoreWarnings: /^This is an experimental API version$/
|
|
713
|
+
*
|
|
714
|
+
* // Mix strings and regex patterns
|
|
715
|
+
* ignoreWarnings: ['rate limit', /^deprecated/i]
|
|
716
|
+
* ```
|
|
717
|
+
*/
|
|
718
|
+
ignoreWarnings?: string | RegExp | Array<string | RegExp>
|
|
695
719
|
withCredentials?: boolean
|
|
696
720
|
allowReconfigure?: boolean
|
|
697
721
|
timeout?: number
|
|
@@ -1080,16 +1104,29 @@ export declare interface CreateReleaseAction {
|
|
|
1080
1104
|
}
|
|
1081
1105
|
|
|
1082
1106
|
/**
|
|
1083
|
-
* Creates a new version of an existing document
|
|
1084
|
-
*
|
|
1107
|
+
* Creates a new version of an existing document.
|
|
1108
|
+
*
|
|
1109
|
+
* If the `document` is provided, the version is created from the document
|
|
1110
|
+
* attached to the release as given by `document._id`
|
|
1111
|
+
*
|
|
1112
|
+
* If the `baseId` and `versionId` are provided, the version is created from the base document
|
|
1113
|
+
* and the version is attached to the release as given by `publishedId` and `versionId`
|
|
1085
1114
|
*
|
|
1086
1115
|
* @public
|
|
1087
1116
|
*/
|
|
1088
|
-
export declare
|
|
1117
|
+
export declare type CreateVersionAction = {
|
|
1089
1118
|
actionType: 'sanity.action.document.version.create'
|
|
1090
1119
|
publishedId: string
|
|
1091
|
-
|
|
1092
|
-
|
|
1120
|
+
} & (
|
|
1121
|
+
| {
|
|
1122
|
+
document: IdentifiedSanityDocumentStub
|
|
1123
|
+
}
|
|
1124
|
+
| {
|
|
1125
|
+
baseId: string
|
|
1126
|
+
versionId: string
|
|
1127
|
+
ifBaseRevisionId?: string
|
|
1128
|
+
}
|
|
1129
|
+
)
|
|
1093
1130
|
|
|
1094
1131
|
/** @public */
|
|
1095
1132
|
export declare interface CurrentSanityUser {
|
|
@@ -1385,6 +1422,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
1385
1422
|
*/
|
|
1386
1423
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
1387
1424
|
|
|
1425
|
+
/**
|
|
1426
|
+
* A string constant containing the experimental API version warning message.
|
|
1427
|
+
* Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```typescript
|
|
1431
|
+
* import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
|
|
1432
|
+
*
|
|
1433
|
+
* const client = createClient({
|
|
1434
|
+
* projectId: 'your-project-id',
|
|
1435
|
+
* dataset: 'production',
|
|
1436
|
+
* apiVersion: 'vX', // experimental version
|
|
1437
|
+
* ignoreWarnings: EXPERIMENTAL_API_WARNING
|
|
1438
|
+
* })
|
|
1439
|
+
* ```
|
|
1440
|
+
*
|
|
1441
|
+
* @public
|
|
1442
|
+
*/
|
|
1443
|
+
export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
|
|
1444
|
+
|
|
1388
1445
|
/**
|
|
1389
1446
|
*
|
|
1390
1447
|
*
|
|
@@ -1849,6 +1906,25 @@ export declare interface GroqAgentActionParam {
|
|
|
1849
1906
|
params?: Record<string, string>
|
|
1850
1907
|
}
|
|
1851
1908
|
|
|
1909
|
+
/**
|
|
1910
|
+
* Shared properties for HTTP errors (eg both ClientError and ServerError)
|
|
1911
|
+
* Use `isHttpError` for type narrowing and accessing response properties.
|
|
1912
|
+
*
|
|
1913
|
+
* @public
|
|
1914
|
+
*/
|
|
1915
|
+
export declare interface HttpError {
|
|
1916
|
+
statusCode: number
|
|
1917
|
+
message: string
|
|
1918
|
+
response: {
|
|
1919
|
+
body: unknown
|
|
1920
|
+
url: string
|
|
1921
|
+
method: string
|
|
1922
|
+
headers: Record<string, string>
|
|
1923
|
+
statusCode: number
|
|
1924
|
+
statusMessage: string | null
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1852
1928
|
/** @public */
|
|
1853
1929
|
export declare type HttpRequest = {
|
|
1854
1930
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -1968,6 +2044,15 @@ export declare type InsertPatch =
|
|
|
1968
2044
|
items: Any[]
|
|
1969
2045
|
}
|
|
1970
2046
|
|
|
2047
|
+
/**
|
|
2048
|
+
* Checks if the provided error is an HTTP error.
|
|
2049
|
+
*
|
|
2050
|
+
* @param error - The error to check.
|
|
2051
|
+
* @returns `true` if the error is an HTTP error, `false` otherwise.
|
|
2052
|
+
* @public
|
|
2053
|
+
*/
|
|
2054
|
+
export declare function isHttpError(error: unknown): error is HttpError
|
|
2055
|
+
|
|
1971
2056
|
/** @internal */
|
|
1972
2057
|
export declare function isQueryParseError(error: object): error is QueryParseError
|
|
1973
2058
|
|
|
@@ -3224,6 +3309,15 @@ export declare class ObservableSanityClient {
|
|
|
3224
3309
|
},
|
|
3225
3310
|
options?: BaseActionOptions,
|
|
3226
3311
|
): Observable<SingleActionResult | MultipleActionResult>
|
|
3312
|
+
createVersion(
|
|
3313
|
+
args: {
|
|
3314
|
+
baseId: string
|
|
3315
|
+
releaseId: string
|
|
3316
|
+
publishedId: string
|
|
3317
|
+
ifBaseRevisionId?: string
|
|
3318
|
+
},
|
|
3319
|
+
options?: BaseActionOptions,
|
|
3320
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
3227
3321
|
/**
|
|
3228
3322
|
* Deletes a document with the given document ID.
|
|
3229
3323
|
* Returns an observable that resolves to the deleted document.
|
|
@@ -4951,7 +5045,8 @@ export declare class SanityClient {
|
|
|
4951
5045
|
* Creates a new version of a published document.
|
|
4952
5046
|
*
|
|
4953
5047
|
* @remarks
|
|
4954
|
-
* *
|
|
5048
|
+
* * 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.
|
|
5049
|
+
* * If `document` is provided, it must have a `_type` property.
|
|
4955
5050
|
* * Creating a version with no `releaseId` will create a new draft version of the published document.
|
|
4956
5051
|
* * 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`.
|
|
4957
5052
|
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
@@ -4960,17 +5055,18 @@ export declare class SanityClient {
|
|
|
4960
5055
|
* @category Versions
|
|
4961
5056
|
*
|
|
4962
5057
|
* @param params - Version action parameters:
|
|
5058
|
+
* - `baseId` - The ID of the published document from which to create a new version from.
|
|
5059
|
+
* - `ifBaseRevisionId` - If `baseId` is provided, this ensures the `baseId`'s revision Id is as expected before creating the new version from it.
|
|
4963
5060
|
* - `document` - The document to create as a new version (must include `_type`).
|
|
4964
5061
|
* - `publishedId` - The ID of the published document being versioned.
|
|
4965
5062
|
* - `releaseId` - The ID of the release to create the version for.
|
|
4966
5063
|
* @param options - Additional action options.
|
|
4967
5064
|
* @returns A promise that resolves to the `transactionId`.
|
|
4968
5065
|
*
|
|
4969
|
-
* @example Creating a new version of a published document
|
|
5066
|
+
* @example Creating a new version of a published document
|
|
4970
5067
|
* ```ts
|
|
4971
5068
|
* const transactionId = await client.createVersion({
|
|
4972
|
-
*
|
|
4973
|
-
* document: {_type: 'myDocument', title: 'My Document'},
|
|
5069
|
+
* baseId: 'myDocument',
|
|
4974
5070
|
* publishedId: 'myDocument',
|
|
4975
5071
|
* releaseId: 'myRelease',
|
|
4976
5072
|
* })
|
|
@@ -4983,25 +5079,11 @@ export declare class SanityClient {
|
|
|
4983
5079
|
* // }
|
|
4984
5080
|
* ```
|
|
4985
5081
|
*
|
|
4986
|
-
* @example Creating a new version of a published document with a specified version ID
|
|
4987
|
-
* ```ts
|
|
4988
|
-
* const transactionId = await client.createVersion({
|
|
4989
|
-
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
4990
|
-
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
4991
|
-
* })
|
|
4992
|
-
*
|
|
4993
|
-
* // The following document will be created:
|
|
4994
|
-
* // {
|
|
4995
|
-
* // _id: 'versions.myRelease.myDocument',
|
|
4996
|
-
* // _type: 'myDocument',
|
|
4997
|
-
* // title: 'My Document',
|
|
4998
|
-
* // }
|
|
4999
|
-
* ```
|
|
5000
5082
|
*
|
|
5001
5083
|
* @example Creating a new draft version of a published document
|
|
5002
5084
|
* ```ts
|
|
5003
5085
|
* const transactionId = await client.createVersion({
|
|
5004
|
-
*
|
|
5086
|
+
* baseId: 'myDocument',
|
|
5005
5087
|
* publishedId: 'myDocument',
|
|
5006
5088
|
* })
|
|
5007
5089
|
*
|
|
@@ -5029,6 +5111,15 @@ export declare class SanityClient {
|
|
|
5029
5111
|
},
|
|
5030
5112
|
options?: BaseActionOptions,
|
|
5031
5113
|
): Promise<SingleActionResult | MultipleActionResult>
|
|
5114
|
+
createVersion(
|
|
5115
|
+
args: {
|
|
5116
|
+
publishedId: string
|
|
5117
|
+
baseId: string
|
|
5118
|
+
releaseId: string
|
|
5119
|
+
ifBaseRevisionId?: string
|
|
5120
|
+
},
|
|
5121
|
+
options?: BaseActionOptions,
|
|
5122
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
5032
5123
|
/**
|
|
5033
5124
|
* Deletes a document with the given document ID.
|
|
5034
5125
|
* Returns a promise that resolves to the deleted document.
|