@sanity/client 7.1.0-views.0 → 7.1.0-views.1

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.
Files changed (80) hide show
  1. package/README.md +668 -40
  2. package/dist/_chunks-cjs/config.cjs +14 -0
  3. package/dist/_chunks-cjs/config.cjs.map +1 -1
  4. package/dist/_chunks-cjs/dataMethods.cjs +197 -32
  5. package/dist/_chunks-cjs/dataMethods.cjs.map +1 -1
  6. package/dist/_chunks-cjs/isRecord.cjs +6 -0
  7. package/dist/_chunks-cjs/isRecord.cjs.map +1 -0
  8. package/dist/_chunks-cjs/resolveEditInfo.cjs +3 -5
  9. package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
  10. package/dist/_chunks-cjs/stegaClean.cjs +4 -0
  11. package/dist/_chunks-cjs/stegaClean.cjs.map +1 -1
  12. package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +2 -5
  13. package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
  14. package/dist/_chunks-es/config.js +15 -1
  15. package/dist/_chunks-es/config.js.map +1 -1
  16. package/dist/_chunks-es/dataMethods.js +200 -33
  17. package/dist/_chunks-es/dataMethods.js.map +1 -1
  18. package/dist/_chunks-es/isRecord.js +7 -0
  19. package/dist/_chunks-es/isRecord.js.map +1 -0
  20. package/dist/_chunks-es/resolveEditInfo.js +1 -3
  21. package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
  22. package/dist/_chunks-es/stegaClean.js +4 -0
  23. package/dist/_chunks-es/stegaClean.js.map +1 -1
  24. package/dist/_chunks-es/stegaEncodeSourceMap.js +1 -4
  25. package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
  26. package/dist/index.browser.cjs +1019 -59
  27. package/dist/index.browser.cjs.map +1 -1
  28. package/dist/index.browser.d.cts +1948 -149
  29. package/dist/index.browser.d.ts +1948 -149
  30. package/dist/index.browser.js +1021 -60
  31. package/dist/index.browser.js.map +1 -1
  32. package/dist/index.cjs +825 -29
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +1948 -149
  35. package/dist/index.d.ts +1948 -149
  36. package/dist/index.js +826 -31
  37. package/dist/index.js.map +1 -1
  38. package/dist/stega.browser.d.cts +1948 -149
  39. package/dist/stega.browser.d.ts +1948 -149
  40. package/dist/stega.d.cts +1948 -149
  41. package/dist/stega.d.ts +1948 -149
  42. package/dist/views.cjs +13 -5
  43. package/dist/views.cjs.map +1 -1
  44. package/dist/views.d.cts +51 -36
  45. package/dist/views.d.ts +51 -36
  46. package/dist/views.js +14 -5
  47. package/dist/views.js.map +1 -1
  48. package/package.json +2 -1
  49. package/src/SanityClient.ts +652 -12
  50. package/src/agent/actions/AgentActionsClient.ts +29 -2
  51. package/src/agent/actions/commonTypes.ts +57 -17
  52. package/src/agent/actions/generate.ts +36 -2
  53. package/src/agent/actions/patch.ts +136 -0
  54. package/src/agent/actions/prompt.ts +145 -0
  55. package/src/agent/actions/transform.ts +105 -7
  56. package/src/agent/actions/translate.ts +5 -2
  57. package/src/config.ts +3 -1
  58. package/src/csm/walkMap.ts +1 -1
  59. package/src/data/dataMethods.ts +170 -12
  60. package/src/data/encodeQueryString.ts +1 -1
  61. package/src/data/eventsource.ts +16 -7
  62. package/src/data/listen.ts +10 -4
  63. package/src/data/live.ts +13 -5
  64. package/src/datasets/DatasetsClient.ts +4 -1
  65. package/src/defineCreateClient.ts +7 -1
  66. package/src/http/errors.ts +92 -27
  67. package/src/http/request.ts +3 -3
  68. package/src/http/requestOptions.ts +4 -0
  69. package/src/projects/ProjectsClient.ts +6 -2
  70. package/src/releases/ReleasesClient.ts +693 -0
  71. package/src/releases/createRelease.ts +53 -0
  72. package/src/types.ts +291 -10
  73. package/src/users/UsersClient.ts +7 -3
  74. package/src/util/codeFrame.ts +174 -0
  75. package/src/util/createVersionId.ts +79 -0
  76. package/src/{csm → util}/isRecord.ts +1 -1
  77. package/src/validators.ts +23 -1
  78. package/src/views/index.ts +51 -15
  79. package/umd/sanityClient.js +1067 -61
  80. package/umd/sanityClient.min.js +2 -2
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type {ContentSourceMapDocuments as ContentSourceMapDocuments_2} from '@sanity/client/csm'
2
2
  import {ContentSourceMapParsedPath} from '@sanity/client/csm'
3
3
  import {ContentSourceMapParsedPathKeyedSegment} from '@sanity/client/csm'
4
+ import type {HttpContext} from 'get-it'
4
5
  import {Observable} from 'rxjs'
5
6
  import {Requester} from 'get-it'
6
7
  import type {ResolveStudioUrl} from '@sanity/client/csm'
@@ -19,14 +20,14 @@ export declare type Action =
19
20
  | DiscardAction
20
21
  | PublishAction
21
22
  | UnpublishAction
23
+ | VersionAction
24
+ | ReleaseAction
22
25
 
23
26
  /** @internal */
24
27
  export declare interface ActionError {
25
- error: {
26
- type: 'actionError'
27
- description: string
28
- items?: ActionErrorItem[]
29
- }
28
+ type: 'actionError'
29
+ description: string
30
+ items?: ActionErrorItem[]
30
31
  }
31
32
 
32
33
  /** @internal */
@@ -53,15 +54,27 @@ declare interface AgentActionAsync {
53
54
  }
54
55
 
55
56
  /** @beta */
56
- export declare type AgentActionParam =
57
+ export declare type AgentActionParam<
58
+ TParamConfig extends {
59
+ docIdRequired: boolean
60
+ } = {
61
+ docIdRequired: false
62
+ },
63
+ > =
57
64
  | string
58
65
  | ConstantAgentActionParam
59
- | FieldAgentActionParam
60
- | DocumentAgentActionParam
66
+ | FieldAgentActionParam<TParamConfig>
67
+ | DocumentAgentActionParam<TParamConfig>
61
68
  | GroqAgentActionParam
62
69
 
63
70
  /** @beta */
64
- export declare type AgentActionParams = Record<string, AgentActionParam>
71
+ export declare type AgentActionParams<
72
+ TParamConfig extends {
73
+ docIdRequired: boolean
74
+ } = {
75
+ docIdRequired: false
76
+ },
77
+ > = Record<string, AgentActionParam<TParamConfig>>
65
78
 
66
79
  /** @beta */
67
80
  export declare type AgentActionPath = AgentActionPathSegment[]
@@ -74,39 +87,7 @@ export declare type AgentActionPathSegment =
74
87
  }
75
88
 
76
89
  /** @beta */
77
- declare interface AgentActionRequestBase {
78
- /** schemaId as reported by sanity deploy / sanity schema store */
79
- schemaId: string
80
- /**
81
- * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
82
- *
83
- * By default, Generate will not output to conditional `readOnly` and `hidden` fields,
84
- * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
85
- *
86
- * `conditionalPaths` param allows setting the default conditional value for
87
- * `hidden` and `readOnly` to false,
88
- * or individually set `hidden` and `readOnly` state for individual document paths.
89
- *
90
- * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to Generate,
91
- * and cannot be changed via conditionalPaths
92
- *
93
- * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
94
- *
95
- * Consider using `hidden: () => true` in schema config, if a field should be writeable only by Generate and never
96
- * visible in the studio – then make the field visible to the Generate using `conditionalPaths`.
97
- *
98
- * @see GenerateRequestBase#target
99
- */
100
- conditionalPaths?: {
101
- defaultReadOnly?: boolean
102
- defaultHidden?: boolean
103
- paths?: {
104
- /** path here is not a relative path: it must be the full document path, regardless of `path` param used in targets */
105
- path: AgentActionPath
106
- readOnly: boolean
107
- hidden: boolean
108
- }[]
109
- }
90
+ declare interface AgentActionRequestBase extends AgentActionSchema {
110
91
  /**
111
92
  * When localeSettings is provided on the request, instruct can write to date and datetime fields.
112
93
  * Otherwise, such fields will be ignored.
@@ -147,6 +128,68 @@ declare interface AgentActionRequestBase {
147
128
  temperature?: number
148
129
  }
149
130
 
131
+ /** @beta */
132
+ declare interface AgentActionSchema {
133
+ /** schemaId as reported by sanity deploy / sanity schema store */
134
+ schemaId: string
135
+ /**
136
+ * ### forcePublishedWrite: false (default)
137
+ * By default, agent actions will never write to a published document.
138
+ *
139
+ * Instead, they will force the use of a draft ID ("drafts.some-id") instead of the published ID ("some-id"),
140
+ * even when a published ID is provided.
141
+ *
142
+ * Actions will use state from an existing draft if it exists,
143
+ * or use the published document to create a draft, if no draft exists.
144
+ *
145
+ * Successful responses contains the _id that was mutated by the action.
146
+ *
147
+ *
148
+ * ### forcePublishedWrite: true
149
+ *
150
+ * When forcePublishedWrite: true an agent action will write to the exact id provided.
151
+ * The action will also not fallback to published state for draft ids.
152
+ *
153
+ *
154
+ * ### Versioned ids (releases)
155
+ *
156
+ * When an ID on the form "versions.<release>.some-id" is provided, agent actions will
157
+ * always behave as if `forcePublishedWrite: true`.
158
+ * That is, only the exact document state of the id provided is considered and mutated.
159
+ * */
160
+ forcePublishedWrite?: boolean
161
+ /**
162
+ * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
163
+ *
164
+ * By default, Generate will not output to conditional `readOnly` and `hidden` fields,
165
+ * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
166
+ *
167
+ * `conditionalPaths` param allows setting the default conditional value for
168
+ * `hidden` and `readOnly` to false,
169
+ * or individually set `hidden` and `readOnly` state for individual document paths.
170
+ *
171
+ * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to Generate,
172
+ * and cannot be changed via conditionalPaths
173
+ *
174
+ * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
175
+ *
176
+ * Consider using `hidden: () => true` in schema config, if a field should be writeable only by Generate and never
177
+ * visible in the studio – then make the field visible to the Generate using `conditionalPaths`.
178
+ *
179
+ * @see GenerateRequestBase#target
180
+ */
181
+ conditionalPaths?: {
182
+ defaultReadOnly?: boolean
183
+ defaultHidden?: boolean
184
+ paths?: {
185
+ /** path here is not a relative path: it must be the full document path, regardless of `path` param used in targets */
186
+ path: AgentActionPath
187
+ readOnly: boolean
188
+ hidden: boolean
189
+ }[]
190
+ }
191
+ }
192
+
150
193
  /** @public */
151
194
  declare class AgentActionsClient {
152
195
  #private
@@ -190,6 +233,27 @@ declare class AgentActionsClient {
190
233
  }
191
234
  : IdentifiedSanityDocumentStub & DocumentShape
192
235
  >
236
+ /**
237
+ * Run a raw instruction and return the result either as text or json
238
+ * @param request - prompt request
239
+ */
240
+ prompt<const DocumentShape extends Record<string, Any>>(
241
+ request: PromptRequest<DocumentShape>,
242
+ ): Promise<(typeof request)['format'] extends 'json' ? DocumentShape : string>
243
+ /**
244
+ * Patch a document using a schema aware API.
245
+ * Does not use an LLM, but uses the schema to ensure paths and values matches the schema.
246
+ * @param request - instruction request
247
+ */
248
+ patch<DocumentShape extends Record<string, Any>>(
249
+ request: PatchDocument<DocumentShape>,
250
+ ): Promise<
251
+ (typeof request)['async'] extends true
252
+ ? {
253
+ _id: string
254
+ }
255
+ : IdentifiedSanityDocumentStub & DocumentShape
256
+ >
193
257
  }
194
258
 
195
259
  /** @beta */
@@ -313,6 +377,8 @@ export declare type AllDocumentsMutationOptions = BaseMutationOptions & {
313
377
  */
314
378
  export declare type Any = any
315
379
 
380
+ declare type AnyNonNullable = Exclude<any, null | undefined>
381
+
316
382
  /** @internal */
317
383
  export declare interface ApiError {
318
384
  error: string
@@ -320,6 +386,16 @@ export declare interface ApiError {
320
386
  statusCode: number
321
387
  }
322
388
 
389
+ /**
390
+ * Archives an `active` release, and deletes all the release documents.
391
+ *
392
+ * @public
393
+ */
394
+ export declare interface ArchiveReleaseAction {
395
+ actionType: 'sanity.action.release.archive'
396
+ releaseId: string
397
+ }
398
+
323
399
  /** @public */
324
400
  export declare type AssetMetadataType =
325
401
  | 'location'
@@ -616,6 +692,12 @@ export declare interface ClientConfig {
616
692
  * Optional request tag prefix for all request tags
617
693
  */
618
694
  requestTagPrefix?: string
695
+ /**
696
+ * Optional default headers to include with all requests
697
+ *
698
+ * @remarks request-specific headers will override any default headers with the same name.
699
+ */
700
+ headers?: Record<string, string>
619
701
  ignoreBrowserTokenWarning?: boolean
620
702
  withCredentials?: boolean
621
703
  allowReconfigure?: boolean
@@ -678,6 +760,7 @@ declare type ClientConfigResource =
678
760
  | {
679
761
  type: 'view'
680
762
  id: string
763
+ useEmulate?: boolean
681
764
  }
682
765
 
683
766
  /** @public */
@@ -686,7 +769,7 @@ export declare class ClientError extends Error {
686
769
  statusCode: ErrorProps['statusCode']
687
770
  responseBody: ErrorProps['responseBody']
688
771
  details: ErrorProps['details']
689
- constructor(res: Any)
772
+ constructor(res: Any, context?: HttpContext)
690
773
  }
691
774
 
692
775
  /** @public */
@@ -896,6 +979,29 @@ export declare type CreateAction = {
896
979
  */
897
980
  export declare const createClient: (config: ClientConfig) => SanityClient
898
981
 
982
+ /**
983
+ * Creates a new release under the given id, with metadata.
984
+ *
985
+ * @public
986
+ */
987
+ export declare interface CreateReleaseAction {
988
+ actionType: 'sanity.action.release.create'
989
+ releaseId: string
990
+ metadata?: Partial<ReleaseDocument['metadata']>
991
+ }
992
+
993
+ /**
994
+ * Creates a new version of an existing document, attached to the release as given
995
+ * by `document._id`
996
+ *
997
+ * @public
998
+ */
999
+ export declare interface CreateVersionAction {
1000
+ actionType: 'sanity.action.document.version.create'
1001
+ publishedId: string
1002
+ document: IdentifiedSanityDocumentStub
1003
+ }
1004
+
899
1005
  /** @public */
900
1006
  export declare interface CurrentSanityUser {
901
1007
  id: string
@@ -991,6 +1097,16 @@ export declare type DeleteAction = {
991
1097
  purge?: boolean
992
1098
  }
993
1099
 
1100
+ /**
1101
+ * Deletes a `archived` or `published` release, and all the release documents versions.
1102
+ *
1103
+ * @public
1104
+ */
1105
+ export declare interface DeleteReleaseAction {
1106
+ actionType: 'sanity.action.release.delete'
1107
+ releaseId: string
1108
+ }
1109
+
994
1110
  /**
995
1111
  * @public
996
1112
  * @deprecated Use the named export `createClient` instead of the `default` export
@@ -1008,6 +1124,7 @@ declare type DeprecatedPreviewDrafts = 'previewDrafts'
1008
1124
  * It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
1009
1125
  *
1010
1126
  * @public
1127
+ * @deprecated Use {@link DiscardVersionAction} instead
1011
1128
  */
1012
1129
  export declare type DiscardAction = {
1013
1130
  actionType: 'sanity.action.document.discard'
@@ -1021,6 +1138,17 @@ export declare type DiscardAction = {
1021
1138
  purge?: boolean
1022
1139
  }
1023
1140
 
1141
+ /**
1142
+ * Delete a version of a document.
1143
+ *
1144
+ * @public
1145
+ */
1146
+ export declare interface DiscardVersionAction {
1147
+ actionType: 'sanity.action.document.version.discard'
1148
+ versionId: string
1149
+ purge?: boolean
1150
+ }
1151
+
1024
1152
  /**
1025
1153
  * The listener has been told to explicitly disconnect.
1026
1154
  * This is a rare situation, but may occur if the API knows reconnect attempts will fail,
@@ -1047,6 +1175,23 @@ export declare type DisconnectEvent = {
1047
1175
  reason: string
1048
1176
  }
1049
1177
 
1178
+ declare type DocIdParam<
1179
+ TParamConfig extends {
1180
+ docIdRequired: boolean
1181
+ } = {
1182
+ docIdRequired: false
1183
+ },
1184
+ > = TParamConfig['docIdRequired'] extends true
1185
+ ? {
1186
+ documentId: string
1187
+ }
1188
+ : {
1189
+ /**
1190
+ * If omitted, implicitly uses the documentId of the instruction target
1191
+ */
1192
+ documentId?: string
1193
+ }
1194
+
1050
1195
  /**
1051
1196
  *
1052
1197
  * Includes a LLM-friendly version of the document in the instruction
@@ -1067,12 +1212,23 @@ export declare type DisconnectEvent = {
1067
1212
  *
1068
1213
  * @beta
1069
1214
  * */
1070
- export declare interface DocumentAgentActionParam {
1215
+ export declare type DocumentAgentActionParam<
1216
+ TParamConfig extends {
1217
+ docIdRequired: boolean
1218
+ } = {
1219
+ docIdRequired: false
1220
+ },
1221
+ > = {
1071
1222
  type: 'document'
1072
- /**
1073
- * If omitted, implicitly uses the documentId of the instruction target
1074
- */
1075
- documentId?: string
1223
+ } & DocIdParam<TParamConfig>
1224
+
1225
+ /** @internal */
1226
+ export declare type EditableReleaseDocument = Omit<
1227
+ PartialExcept<ReleaseDocument, '_id'>,
1228
+ 'metadata' | '_type'
1229
+ > & {
1230
+ _id: string
1231
+ metadata: Partial<ReleaseDocument['metadata']>
1076
1232
  }
1077
1233
 
1078
1234
  /**
@@ -1098,6 +1254,25 @@ export declare type EditAction = {
1098
1254
  patch: PatchOperations
1099
1255
  }
1100
1256
 
1257
+ /**
1258
+ * Edits an existing release, updating the metadata.
1259
+ *
1260
+ * @public
1261
+ */
1262
+ export declare interface EditReleaseAction {
1263
+ actionType: 'sanity.action.release.edit'
1264
+ releaseId: string
1265
+ patch: PatchOperations
1266
+ }
1267
+
1268
+ /** @public */
1269
+ export declare interface EmulatedResponseQueryOptions extends ResponseQueryOptions {
1270
+ useEmulate: boolean
1271
+ connections?: ViewConnectionOverride[] | undefined
1272
+ filterResponse?: false
1273
+ returnQuery?: false
1274
+ }
1275
+
1101
1276
  /** @public */
1102
1277
  export declare interface ErrorProps {
1103
1278
  message: string
@@ -1140,17 +1315,19 @@ export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSo
1140
1315
  *
1141
1316
  * @beta
1142
1317
  * */
1143
- export declare interface FieldAgentActionParam {
1318
+ export declare type FieldAgentActionParam<
1319
+ TParamConfig extends {
1320
+ docIdRequired: boolean
1321
+ } = {
1322
+ docIdRequired: false
1323
+ },
1324
+ > = {
1144
1325
  type: 'field'
1145
1326
  /**
1146
1327
  * Examples: 'title', ['array', \{_key: 'arrayItemKey'\}, 'field']
1147
1328
  */
1148
1329
  path: AgentActionPathSegment | AgentActionPath
1149
- /**
1150
- * If omitted, implicitly uses the documentId of the instruction target
1151
- */
1152
- documentId?: string
1153
- }
1330
+ } & DocIdParam<TParamConfig>
1154
1331
 
1155
1332
  /** @public */
1156
1333
  export declare type FilterDefault = (props: {
@@ -1218,6 +1395,16 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
1218
1395
  returnDocuments?: true
1219
1396
  }
1220
1397
 
1398
+ /**
1399
+ * Formats a GROQ query parse error into a human-readable string.
1400
+ *
1401
+ * @param error - The error object containing details about the parse error.
1402
+ * @param tag - An optional tag to include in the error message.
1403
+ * @returns A formatted error message string.
1404
+ * @public
1405
+ */
1406
+ export declare function formatQueryParseError(error: QueryParseError, tag?: string | null): string
1407
+
1221
1408
  /** @beta */
1222
1409
  declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
1223
1410
  | GenerateExistingDocumentRequest
@@ -1231,8 +1418,11 @@ declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<str
1231
1418
  * @beta
1232
1419
  */
1233
1420
  declare interface GenerateExistingDocumentRequest {
1421
+ /**
1422
+ * @see #AgentActionSchema.forcePublishedWrite
1423
+ */
1234
1424
  documentId: string
1235
- createDocument?: never
1425
+ targetDocument?: never
1236
1426
  }
1237
1427
 
1238
1428
  /** @beta */
@@ -1252,7 +1442,7 @@ declare interface GenerateRequestBase extends AgentActionRequestBase {
1252
1442
  *
1253
1443
  * The LLM only has access to information in the instruction, plus the target schema.
1254
1444
  *
1255
- * string template using $variable
1445
+ * String template with support for $variable from `instructionParams`.
1256
1446
  * */
1257
1447
  instruction: string
1258
1448
  /**
@@ -1347,6 +1537,21 @@ declare interface GenerateRequestBase extends AgentActionRequestBase {
1347
1537
  * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
1348
1538
  * It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
1349
1539
  *
1540
+ * ## Generating images
1541
+ *
1542
+ * Generate will generate images the same was as AI Assist, for images that have been configured using
1543
+ * [AI Assist schema options](https://github.com/sanity-io/assist/tree/main/plugin#image-generation).
1544
+ *
1545
+ * To generate images _without_ changing the schema, directly target an image asset path.
1546
+ *
1547
+ * For example, all the following will generate an image into the provided asset:
1548
+ * * `target: {path: ['image', 'asset'] }`
1549
+ * * `target: {path: 'image', include: ['asset'] }`
1550
+ *
1551
+ * Image generation can be combined with regular content targets:
1552
+ * * `target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]`
1553
+ *
1554
+ * Since Generate happens in a single LLM pass, the image will be contextually related to other generated content.
1350
1555
  * @see AgentActionRequestBase#conditionalPaths
1351
1556
  */
1352
1557
  target?: GenerateTarget | GenerateTarget[]
@@ -1393,6 +1598,7 @@ export declare interface GenerateTarget extends AgentActionTarget {
1393
1598
  * @see #AgentActionTargetInclude.operation
1394
1599
  * @see #include
1395
1600
  * @see #AgentActionTargetInclude.include
1601
+ * @see #AgentActionSchema.forcePublishedWrite
1396
1602
  */
1397
1603
  operation?: GenerateOperation
1398
1604
  /**
@@ -1409,22 +1615,34 @@ export declare interface GenerateTarget extends AgentActionTarget {
1409
1615
  export declare type GenerateTargetDocument<T extends Record<string, Any> = Record<string, Any>> =
1410
1616
  | {
1411
1617
  operation: 'edit'
1618
+ /**
1619
+ * @see #AgentActionSchema.forcePublishedWrite
1620
+ */
1412
1621
  _id: string
1413
1622
  }
1414
1623
  | {
1415
1624
  operation: 'create'
1625
+ /**
1626
+ * @see #AgentActionSchema.forcePublishedWrite
1627
+ */
1416
1628
  _id?: string
1417
1629
  _type: string
1418
1630
  initialValues?: T
1419
1631
  }
1420
1632
  | {
1421
1633
  operation: 'createIfNotExists'
1634
+ /**
1635
+ * @see #AgentActionSchema.forcePublishedWrite
1636
+ */
1422
1637
  _id: string
1423
1638
  _type: string
1424
1639
  initialValues?: T
1425
1640
  }
1426
1641
  | {
1427
1642
  operation: 'createOrReplace'
1643
+ /**
1644
+ * @see #AgentActionSchema.forcePublishedWrite
1645
+ */
1428
1646
  _id: string
1429
1647
  _type: string
1430
1648
  initialValues?: T
@@ -1437,6 +1655,9 @@ export declare type GenerateTargetDocument<T extends Record<string, Any> = Recor
1437
1655
  declare interface GenerateTargetDocumentRequest<
1438
1656
  T extends Record<string, Any> = Record<string, Any>,
1439
1657
  > {
1658
+ /**
1659
+ * @see #AgentActionSchema.forcePublishedWrite
1660
+ */
1440
1661
  targetDocument: GenerateTargetDocument<T>
1441
1662
  documentId?: never
1442
1663
  }
@@ -1503,6 +1724,24 @@ export declare type IdentifiedSanityDocumentStub<
1503
1724
  _id: string
1504
1725
  } & SanityDocumentStub
1505
1726
 
1727
+ /**
1728
+ *
1729
+ * @see #TransformOperation
1730
+ * @beta
1731
+ */
1732
+ export declare interface ImageDescriptionOperation {
1733
+ type: 'image-description'
1734
+ /**
1735
+ * When omitted, parent image value will be inferred from the arget path.
1736
+ *
1737
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1738
+ * - `['image']`
1739
+ * - `['wrapper', 'mainImage']`
1740
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1741
+ */
1742
+ sourcePath?: AgentActionPath
1743
+ }
1744
+
1506
1745
  /** @public */
1507
1746
  export declare interface InitializedClientConfig extends ClientConfig {
1508
1747
  apiHost: string
@@ -1525,6 +1764,12 @@ export declare interface InitializedClientConfig extends ClientConfig {
1525
1764
  * The fully initialized stega config, can be used to check if stega is enabled
1526
1765
  */
1527
1766
  stega: InitializedStegaConfig
1767
+ /**
1768
+ * Default headers to include with all requests
1769
+ *
1770
+ * @remarks request-specific headers will override any default headers with the same name.
1771
+ */
1772
+ headers?: Record<string, string>
1528
1773
  }
1529
1774
 
1530
1775
  /** @public */
@@ -1546,6 +1791,9 @@ export declare type InsertPatch =
1546
1791
  items: Any[]
1547
1792
  }
1548
1793
 
1794
+ /** @internal */
1795
+ export declare function isQueryParseError(error: object): error is QueryParseError
1796
+
1549
1797
  /**
1550
1798
  * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
1551
1799
  *
@@ -1779,11 +2027,9 @@ export declare type Mutation<R extends Record<string, Any> = Record<string, Any>
1779
2027
 
1780
2028
  /** @internal */
1781
2029
  export declare interface MutationError {
1782
- error: {
1783
- type: 'mutationError'
1784
- description: string
1785
- items?: MutationErrorItem[]
1786
- }
2030
+ type: 'mutationError'
2031
+ description: string
2032
+ items?: MutationErrorItem[]
1787
2033
  }
1788
2034
 
1789
2035
  /** @internal */
@@ -2124,43 +2370,344 @@ export declare class ObservableProjectsClient {
2124
2370
  }
2125
2371
 
2126
2372
  /** @public */
2127
- export declare class ObservableSanityClient {
2373
+ declare class ObservableReleasesClient {
2128
2374
  #private
2129
- assets: ObservableAssetsClient
2130
- datasets: ObservableDatasetsClient
2131
- live: LiveClient
2132
- projects: ObservableProjectsClient
2133
- users: ObservableUsersClient
2134
- agent: {
2135
- action: ObservableAgentsActionClient
2136
- }
2137
- /**
2138
- * Instance properties
2139
- */
2140
- listen: typeof _listen
2141
- constructor(httpRequest: HttpRequest, config?: ClientConfig)
2375
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
2142
2376
  /**
2143
- * Clone the client - returns a new instance
2377
+ * @public
2378
+ *
2379
+ * Retrieve a release by id.
2380
+ *
2381
+ * @category Releases
2382
+ *
2383
+ * @param params - Release action parameters:
2384
+ * - `releaseId` - The id of the release to retrieve.
2385
+ * @param options - Additional query options including abort signal and query tag.
2386
+ * @returns An observable that resolves to the release document {@link ReleaseDocument}.
2387
+ *
2388
+ * @example Retrieving a release by id
2389
+ * ```ts
2390
+ * client.observable.releases.get({releaseId: 'my-release'}).pipe(
2391
+ * tap((release) => console.log(release)),
2392
+ * // {
2393
+ * // _id: '_.releases.my-release',
2394
+ * // name: 'my-release'
2395
+ * // _type: 'system.release',
2396
+ * // metadata: {releaseType: 'asap'},
2397
+ * // _createdAt: '2021-01-01T00:00:00.000Z',
2398
+ * // ...
2399
+ * // }
2400
+ * ).subscribe()
2401
+ * ```
2144
2402
  */
2145
- clone(): ObservableSanityClient
2403
+ get(
2404
+ {
2405
+ releaseId,
2406
+ }: {
2407
+ releaseId: string
2408
+ },
2409
+ options?: {
2410
+ signal?: AbortSignal
2411
+ tag?: string
2412
+ },
2413
+ ): Observable<ReleaseDocument | undefined>
2146
2414
  /**
2147
- * Returns the current client configuration
2415
+ * @public
2416
+ *
2417
+ * Creates a new release under the given id, with metadata.
2418
+ *
2419
+ * @remarks
2420
+ * * If no releaseId is provided, a release id will be generated.
2421
+ * * If no metadata is provided, then an `undecided` releaseType will be used.
2422
+ *
2423
+ * @category Releases
2424
+ *
2425
+ * @param params - Release action parameters:
2426
+ * - `releaseId` - The id of the release to create.
2427
+ * - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
2428
+ * @param options - Additional action options.
2429
+ * @returns An observable that resolves to the `transactionId` and the release id and metadata.
2430
+ *
2431
+ * @example Creating a release with a custom id and metadata
2432
+ * ```ts
2433
+ * const releaseId = 'my-release'
2434
+ * const metadata: ReleaseDocument['metadata'] = {
2435
+ * releaseType: 'asap',
2436
+ * }
2437
+ *
2438
+ * client.observable.releases.create({releaseId, metadata}).pipe(
2439
+ * tap(({transactionId, releaseId, metadata}) => console.log(transactionId, releaseId, metadata)),
2440
+ * // {
2441
+ * // transactionId: 'transaction-id',
2442
+ * // releaseId: 'my-release',
2443
+ * // metadata: {releaseType: 'asap'},
2444
+ * // }
2445
+ * ).subscribe()
2446
+ * ```
2447
+ *
2448
+ * @example Creating a release with generated id and metadata
2449
+ * ```ts
2450
+ * client.observable.releases.create().pipe(
2451
+ * tap(({metadata}) => console.log(metadata)),
2452
+ * // {
2453
+ * // metadata: {releaseType: 'undecided'},
2454
+ * // }
2455
+ * ).subscribe()
2456
+ * ```
2457
+ *
2458
+ * @example Creating a release using a custom transaction id
2459
+ * ```ts
2460
+ * client.observable.releases.create({transactionId: 'my-transaction-id'}).pipe(
2461
+ * tap(({transactionId, metadata}) => console.log(transactionId, metadata)),
2462
+ * // {
2463
+ * // transactionId: 'my-transaction-id',
2464
+ * // metadata: {releaseType: 'undecided'},
2465
+ * // }
2466
+ * ).subscribe()
2467
+ * ```
2148
2468
  */
2149
- config(): InitializedClientConfig
2469
+ create(options: BaseActionOptions): Observable<
2470
+ SingleActionResult & {
2471
+ releaseId: string
2472
+ metadata: ReleaseDocument['metadata']
2473
+ }
2474
+ >
2475
+ create(
2476
+ release: {
2477
+ releaseId?: string
2478
+ metadata?: Partial<ReleaseDocument['metadata']>
2479
+ },
2480
+ options?: BaseActionOptions,
2481
+ ): Observable<
2482
+ SingleActionResult & {
2483
+ releaseId: string
2484
+ metadata: ReleaseDocument['metadata']
2485
+ }
2486
+ >
2150
2487
  /**
2151
- * Reconfigure the client. Note that this _mutates_ the current client.
2488
+ * @public
2489
+ *
2490
+ * Edits an existing release, updating the metadata.
2491
+ *
2492
+ * @category Releases
2493
+ *
2494
+ * @param params - Release action parameters:
2495
+ * - `releaseId` - The id of the release to edit.
2496
+ * - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
2497
+ * @param options - Additional action options.
2498
+ * @returns An observable that resolves to the `transactionId`.
2152
2499
  */
2153
- config(newConfig?: Partial<ClientConfig>): this
2500
+ edit(
2501
+ {
2502
+ releaseId,
2503
+ patch,
2504
+ }: {
2505
+ releaseId: string
2506
+ patch: PatchOperations
2507
+ },
2508
+ options?: BaseActionOptions,
2509
+ ): Observable<SingleActionResult>
2154
2510
  /**
2155
- * Clone the client with a new (partial) configuration.
2511
+ * @public
2156
2512
  *
2157
- * @param newConfig - New client configuration properties, shallowly merged with existing configuration
2513
+ * Publishes all documents in a release at once. For larger releases the effect of the publish
2514
+ * will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
2515
+ * documents and creation of the corresponding published documents with the new content may
2516
+ * take some time.
2517
+ *
2518
+ * During this period both the source and target documents are locked and cannot be
2519
+ * modified through any other means.
2520
+ *
2521
+ * @category Releases
2522
+ *
2523
+ * @param params - Release action parameters:
2524
+ * - `releaseId` - The id of the release to publish.
2525
+ * @param options - Additional action options.
2526
+ * @returns An observable that resolves to the `transactionId`.
2158
2527
  */
2159
- withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
2528
+ publish(
2529
+ {
2530
+ releaseId,
2531
+ }: {
2532
+ releaseId: string
2533
+ },
2534
+ options?: BaseActionOptions,
2535
+ ): Observable<SingleActionResult>
2160
2536
  /**
2161
- * Perform a GROQ-query against the configured dataset.
2537
+ * @public
2162
2538
  *
2163
- * @param query - GROQ-query to perform
2539
+ * An archive action removes an active release. The documents that comprise the release
2540
+ * are deleted and therefore no longer queryable.
2541
+ *
2542
+ * While the documents remain in retention the last version can still be accessed using document history endpoint.
2543
+ *
2544
+ * @category Releases
2545
+ *
2546
+ * @param params - Release action parameters:
2547
+ * - `releaseId` - The id of the release to archive.
2548
+ * @param options - Additional action options.
2549
+ * @returns An observable that resolves to the `transactionId`.
2550
+ */
2551
+ archive(
2552
+ {
2553
+ releaseId,
2554
+ }: {
2555
+ releaseId: string
2556
+ },
2557
+ options?: BaseActionOptions,
2558
+ ): Observable<SingleActionResult>
2559
+ /**
2560
+ * @public
2561
+ *
2562
+ * An unarchive action restores an archived release and all documents
2563
+ * with the content they had just prior to archiving.
2564
+ *
2565
+ * @category Releases
2566
+ *
2567
+ * @param params - Release action parameters:
2568
+ * - `releaseId` - The id of the release to unarchive.
2569
+ * @param options - Additional action options.
2570
+ * @returns An observable that resolves to the `transactionId`.
2571
+ */
2572
+ unarchive(
2573
+ {
2574
+ releaseId,
2575
+ }: {
2576
+ releaseId: string
2577
+ },
2578
+ options?: BaseActionOptions,
2579
+ ): Observable<SingleActionResult>
2580
+ /**
2581
+ * @public
2582
+ *
2583
+ * A schedule action queues a release for publishing at the given future time.
2584
+ * The release is locked such that no documents in the release can be modified and
2585
+ * no documents that it references can be deleted as this would make the publish fail.
2586
+ * At the given time, the same logic as for the publish action is triggered.
2587
+ *
2588
+ * @category Releases
2589
+ *
2590
+ * @param params - Release action parameters:
2591
+ * - `releaseId` - The id of the release to schedule.
2592
+ * - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
2593
+ * @param options - Additional action options.
2594
+ * @returns An observable that resolves to the `transactionId`.
2595
+ */
2596
+ schedule(
2597
+ {
2598
+ releaseId,
2599
+ publishAt,
2600
+ }: {
2601
+ releaseId: string
2602
+ publishAt: string
2603
+ },
2604
+ options?: BaseActionOptions,
2605
+ ): Observable<SingleActionResult>
2606
+ /**
2607
+ * @public
2608
+ *
2609
+ * An unschedule action stops a release from being published.
2610
+ * The documents in the release are considered unlocked and can be edited again.
2611
+ * This may fail if another release is scheduled to be published after this one and
2612
+ * has a reference to a document created by this one.
2613
+ *
2614
+ * @category Releases
2615
+ *
2616
+ * @param params - Release action parameters:
2617
+ * - `releaseId` - The id of the release to unschedule.
2618
+ * @param options - Additional action options.
2619
+ * @returns An observable that resolves to the `transactionId`.
2620
+ */
2621
+ unschedule(
2622
+ {
2623
+ releaseId,
2624
+ }: {
2625
+ releaseId: string
2626
+ },
2627
+ options?: BaseActionOptions,
2628
+ ): Observable<SingleActionResult>
2629
+ /**
2630
+ * @public
2631
+ *
2632
+ * A delete action removes a published or archived release.
2633
+ * The backing system document will be removed from the dataset.
2634
+ *
2635
+ * @category Releases
2636
+ *
2637
+ * @param params - Release action parameters:
2638
+ * - `releaseId` - The id of the release to delete.
2639
+ * @param options - Additional action options.
2640
+ * @returns An observable that resolves to the `transactionId`.
2641
+ */
2642
+ delete(
2643
+ {
2644
+ releaseId,
2645
+ }: {
2646
+ releaseId: string
2647
+ },
2648
+ options?: BaseActionOptions,
2649
+ ): Observable<SingleActionResult>
2650
+ /**
2651
+ * @public
2652
+ *
2653
+ * Fetch the documents in a release by release id.
2654
+ *
2655
+ * @category Releases
2656
+ *
2657
+ * @param params - Release action parameters:
2658
+ * - `releaseId` - The id of the release to fetch documents for.
2659
+ * @param options - Additional mutation options {@link BaseMutationOptions}.
2660
+ * @returns An observable that resolves to the documents in the release.
2661
+ */
2662
+ fetchDocuments(
2663
+ {
2664
+ releaseId,
2665
+ }: {
2666
+ releaseId: string
2667
+ },
2668
+ options?: BaseMutationOptions,
2669
+ ): Observable<RawQueryResponse<SanityDocument[]>>
2670
+ }
2671
+
2672
+ /** @public */
2673
+ export declare class ObservableSanityClient {
2674
+ #private
2675
+ assets: ObservableAssetsClient
2676
+ datasets: ObservableDatasetsClient
2677
+ live: LiveClient
2678
+ projects: ObservableProjectsClient
2679
+ users: ObservableUsersClient
2680
+ agent: {
2681
+ action: ObservableAgentsActionClient
2682
+ }
2683
+ releases: ObservableReleasesClient
2684
+ /**
2685
+ * Instance properties
2686
+ */
2687
+ listen: typeof _listen
2688
+ constructor(httpRequest: HttpRequest, config?: ClientConfig)
2689
+ /**
2690
+ * Clone the client - returns a new instance
2691
+ */
2692
+ clone(): ObservableSanityClient
2693
+ /**
2694
+ * Returns the current client configuration
2695
+ */
2696
+ config(): InitializedClientConfig
2697
+ /**
2698
+ * Reconfigure the client. Note that this _mutates_ the current client.
2699
+ */
2700
+ config(newConfig?: Partial<ClientConfig>): this
2701
+ /**
2702
+ * Clone the client with a new (partial) configuration.
2703
+ *
2704
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
2705
+ */
2706
+ withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
2707
+ /**
2708
+ * Perform a GROQ-query against the configured dataset.
2709
+ *
2710
+ * @param query - GROQ-query to perform
2164
2711
  */
2165
2712
  fetch<
2166
2713
  R = Any,
@@ -2224,7 +2771,9 @@ export declare class ObservableSanityClient {
2224
2771
  getDocument<R extends Record<string, Any> = Record<string, Any>>(
2225
2772
  id: string,
2226
2773
  options?: {
2774
+ signal?: AbortSignal
2227
2775
  tag?: string
2776
+ releaseId?: string
2228
2777
  },
2229
2778
  ): Observable<SanityDocument<R> | undefined>
2230
2779
  /**
@@ -2407,6 +2956,90 @@ export declare class ObservableSanityClient {
2407
2956
  document: IdentifiedSanityDocumentStub<R>,
2408
2957
  options?: BaseMutationOptions,
2409
2958
  ): Observable<SanityDocument<R>>
2959
+ /**
2960
+ * @public
2961
+ *
2962
+ * Creates a new version of a published document.
2963
+ *
2964
+ * @remarks
2965
+ * * Requires a document with a `_type` property.
2966
+ * * Creating a version with no `releaseId` will create a new draft version of the published document.
2967
+ * * 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`.
2968
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
2969
+ * * To create a version of an unpublished document, use the `client.create` method.
2970
+ *
2971
+ * @category Versions
2972
+ *
2973
+ * @param params - Version action parameters:
2974
+ * - `document` - The document to create as a new version (must include `_type`).
2975
+ * - `publishedId` - The ID of the published document being versioned.
2976
+ * - `releaseId` - The ID of the release to create the version for.
2977
+ * @param options - Additional action options.
2978
+ * @returns an observable that resolves to the `transactionId`.
2979
+ *
2980
+ * @example Creating a new version of a published document with a generated version ID
2981
+ * ```ts
2982
+ * client.observable.createVersion({
2983
+ * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
2984
+ * document: {_type: 'myDocument', title: 'My Document'},
2985
+ * publishedId: 'myDocument',
2986
+ * releaseId: 'myRelease',
2987
+ * })
2988
+ *
2989
+ * // The following document will be created:
2990
+ * // {
2991
+ * // _id: 'versions.myRelease.myDocument',
2992
+ * // _type: 'myDocument',
2993
+ * // title: 'My Document',
2994
+ * // }
2995
+ * ```
2996
+ *
2997
+ * @example Creating a new version of a published document with a specified version ID
2998
+ * ```ts
2999
+ * client.observable.createVersion({
3000
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
3001
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
3002
+ * })
3003
+ *
3004
+ * // The following document will be created:
3005
+ * // {
3006
+ * // _id: 'versions.myRelease.myDocument',
3007
+ * // _type: 'myDocument',
3008
+ * // title: 'My Document',
3009
+ * // }
3010
+ * ```
3011
+ *
3012
+ * @example Creating a new draft version of a published document
3013
+ * ```ts
3014
+ * client.observable.createVersion({
3015
+ * document: {_type: 'myDocument', title: 'My Document'},
3016
+ * publishedId: 'myDocument',
3017
+ * })
3018
+ *
3019
+ * // The following document will be created:
3020
+ * // {
3021
+ * // _id: 'drafts.myDocument',
3022
+ * // _type: 'myDocument',
3023
+ * // title: 'My Document',
3024
+ * // }
3025
+ * ```
3026
+ */
3027
+ createVersion<R extends Record<string, Any>>(
3028
+ args: {
3029
+ document: SanityDocumentStub<R>
3030
+ publishedId: string
3031
+ releaseId?: string
3032
+ },
3033
+ options?: BaseActionOptions,
3034
+ ): Observable<SingleActionResult | MultipleActionResult>
3035
+ createVersion<R extends Record<string, Any>>(
3036
+ args: {
3037
+ document: IdentifiedSanityDocumentStub<R>
3038
+ publishedId?: string
3039
+ releaseId?: string
3040
+ },
3041
+ options?: BaseActionOptions,
3042
+ ): Observable<SingleActionResult | MultipleActionResult>
2410
3043
  /**
2411
3044
  * Deletes a document with the given document ID.
2412
3045
  * Returns an observable that resolves to the deleted document.
@@ -2511,6 +3144,157 @@ export declare class ObservableSanityClient {
2511
3144
  selection: MutationSelection,
2512
3145
  options?: BaseMutationOptions,
2513
3146
  ): Observable<SanityDocument<R>>
3147
+ /**
3148
+ * @public
3149
+ *
3150
+ * Deletes the draft or release version of a document.
3151
+ *
3152
+ * @remarks
3153
+ * * Discarding a version with no `releaseId` will discard the draft version of the published document.
3154
+ * * If the draft or release version does not exist, any error will throw.
3155
+ *
3156
+ * @param params - Version action parameters:
3157
+ * - `releaseId` - The ID of the release to discard the document from.
3158
+ * - `publishedId` - The published ID of the document to discard.
3159
+ * @param purge - if `true` the document history is also discarded.
3160
+ * @param options - Additional action options.
3161
+ * @returns an observable that resolves to the `transactionId`.
3162
+ *
3163
+ * @example Discarding a release version of a document
3164
+ * ```ts
3165
+ * client.observable.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
3166
+ * // The document with the ID `versions.myRelease.myDocument` will be discarded.
3167
+ * ```
3168
+ *
3169
+ * @example Discarding a draft version of a document
3170
+ * ```ts
3171
+ * client.observable.discardVersion({publishedId: 'myDocument'})
3172
+ * // The document with the ID `drafts.myDocument` will be discarded.
3173
+ * ```
3174
+ */
3175
+ discardVersion(
3176
+ {
3177
+ releaseId,
3178
+ publishedId,
3179
+ }: {
3180
+ releaseId?: string
3181
+ publishedId: string
3182
+ },
3183
+ purge?: boolean,
3184
+ options?: BaseActionOptions,
3185
+ ): Observable<SingleActionResult | MultipleActionResult>
3186
+ /**
3187
+ * @public
3188
+ *
3189
+ * Replaces an existing version document.
3190
+ *
3191
+ * @remarks
3192
+ * * Requires a document with a `_type` property.
3193
+ * * 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`.
3194
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
3195
+ * * Replacing a version with no `releaseId` will replace the draft version of the published document.
3196
+ * * At least one of the **version** or **published** documents must exist.
3197
+ *
3198
+ * @param params - Version action parameters:
3199
+ * - `document` - The new document to replace the version with.
3200
+ * - `releaseId` - The ID of the release where the document version is replaced.
3201
+ * - `publishedId` - The ID of the published document to replace.
3202
+ * @param options - Additional action options.
3203
+ * @returns an observable that resolves to the `transactionId`.
3204
+ *
3205
+ * @example Replacing a release version of a published document with a generated version ID
3206
+ * ```ts
3207
+ * client.observable.replaceVersion({
3208
+ * document: {_type: 'myDocument', title: 'My Document'},
3209
+ * publishedId: 'myDocument',
3210
+ * releaseId: 'myRelease',
3211
+ * })
3212
+ *
3213
+ * // The following document will be patched:
3214
+ * // {
3215
+ * // _id: 'versions.myRelease.myDocument',
3216
+ * // _type: 'myDocument',
3217
+ * // title: 'My Document',
3218
+ * // }
3219
+ * ```
3220
+ *
3221
+ * @example Replacing a release version of a published document with a specified version ID
3222
+ * ```ts
3223
+ * client.observable.replaceVersion({
3224
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
3225
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
3226
+ * })
3227
+ *
3228
+ * // The following document will be patched:
3229
+ * // {
3230
+ * // _id: 'versions.myRelease.myDocument',
3231
+ * // _type: 'myDocument',
3232
+ * // title: 'My Document',
3233
+ * // }
3234
+ * ```
3235
+ *
3236
+ * @example Replacing a draft version of a published document
3237
+ * ```ts
3238
+ * client.observable.replaceVersion({
3239
+ * document: {_type: 'myDocument', title: 'My Document'},
3240
+ * publishedId: 'myDocument',
3241
+ * })
3242
+ *
3243
+ * // The following document will be patched:
3244
+ * // {
3245
+ * // _id: 'drafts.myDocument',
3246
+ * // _type: 'myDocument',
3247
+ * // title: 'My Document',
3248
+ * // }
3249
+ * ```
3250
+ */
3251
+ replaceVersion<R extends Record<string, Any>>(
3252
+ args: {
3253
+ document: SanityDocumentStub<R>
3254
+ publishedId: string
3255
+ releaseId?: string
3256
+ },
3257
+ options?: BaseActionOptions,
3258
+ ): Observable<SingleActionResult | MultipleActionResult>
3259
+ replaceVersion<R extends Record<string, Any>>(
3260
+ args: {
3261
+ document: IdentifiedSanityDocumentStub<R>
3262
+ publishedId?: string
3263
+ releaseId?: string
3264
+ },
3265
+ options?: BaseActionOptions,
3266
+ ): Observable<SingleActionResult | MultipleActionResult>
3267
+ /**
3268
+ * @public
3269
+ *
3270
+ * Used to indicate when a document within a release should be unpublished when
3271
+ * the release is run.
3272
+ *
3273
+ * @remarks
3274
+ * * If the published document does not exist, an error will be thrown.
3275
+ *
3276
+ * @param params - Version action parameters:
3277
+ * - `releaseId` - The ID of the release to unpublish the document from.
3278
+ * - `publishedId` - The published ID of the document to unpublish.
3279
+ * @param options - Additional action options.
3280
+ * @returns an observable that resolves to the `transactionId`.
3281
+ *
3282
+ * @example Unpublishing a release version of a published document
3283
+ * ```ts
3284
+ * client.observable.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
3285
+ * // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
3286
+ * ```
3287
+ */
3288
+ unpublishVersion(
3289
+ {
3290
+ releaseId,
3291
+ publishedId,
3292
+ }: {
3293
+ releaseId: string
3294
+ publishedId: string
3295
+ },
3296
+ options?: BaseActionOptions,
3297
+ ): Observable<SingleActionResult | MultipleActionResult>
2514
3298
  /**
2515
3299
  * Perform mutation operations against the configured dataset
2516
3300
  * Returns an observable that resolves to the first mutated document.
@@ -2712,6 +3496,9 @@ export declare type OpenEvent = {
2712
3496
  type: 'open'
2713
3497
  }
2714
3498
 
3499
+ /** @internal */
3500
+ export declare type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>
3501
+
2715
3502
  /** @public */
2716
3503
  export declare class Patch extends BasePatch {
2717
3504
  #private
@@ -2761,9 +3548,45 @@ export declare class Patch extends BasePatch {
2761
3548
  /** @public */
2762
3549
  export declare type PatchBuilder = (patch: Patch) => Patch
2763
3550
 
3551
+ /** @beta */
3552
+ export declare type PatchDocument<T extends Record<string, Any> = Record<string, Any>> =
3553
+ | PatchDocumentSync<T>
3554
+ | PatchDocumentAsync<T>
3555
+
3556
+ /** @beta */
3557
+ declare type PatchDocumentAsync<T extends Record<string, Any> = Record<string, Any>> = (
3558
+ | PatchExistingDocumentRequest
3559
+ | PatchTargetDocumentRequest<T>
3560
+ ) &
3561
+ PatchRequestBase &
3562
+ AgentActionAsync
3563
+
3564
+ /** @beta */
3565
+ declare type PatchDocumentSync<T extends Record<string, Any> = Record<string, Any>> = (
3566
+ | PatchExistingDocumentRequest
3567
+ | PatchTargetDocumentRequest<T>
3568
+ ) &
3569
+ PatchRequestBase &
3570
+ AgentActionSync
3571
+
3572
+ /**
3573
+ * Patches an existing document
3574
+ * @beta
3575
+ */
3576
+ declare interface PatchExistingDocumentRequest {
3577
+ /**
3578
+ * @see #AgentActionSchema.forcePublishedWrite
3579
+ */
3580
+ documentId: string
3581
+ targetDocument?: never
3582
+ }
3583
+
2764
3584
  /** @internal */
2765
3585
  export declare type PatchMutationOperation = PatchOperations & MutationSelection
2766
3586
 
3587
+ /** @beta */
3588
+ export declare type PatchOperation = 'set' | 'append' | 'mixed' | 'unset'
3589
+
2767
3590
  /** @internal */
2768
3591
  export declare interface PatchOperations {
2769
3592
  set?: {
@@ -2786,9 +3609,80 @@ export declare interface PatchOperations {
2786
3609
  ifRevisionID?: string
2787
3610
  }
2788
3611
 
3612
+ /** @beta */
3613
+ declare interface PatchRequestBase extends AgentActionSchema {
3614
+ /**
3615
+ * Target defines which parts of the document will be affected by the instruction.
3616
+ * It can be an array, so multiple parts of the document can be separately configured in detail.
3617
+ *
3618
+ * Omitting target implies that the document itself is the root.
3619
+ *
3620
+ * Notes:
3621
+ * - instruction can only affect fields up to `maxPathDepth`
3622
+ * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
3623
+ * It is therefore an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
3624
+ *
3625
+ * @see AgentActionRequestBase#conditionalPaths
3626
+ */
3627
+ target: PatchTarget | PatchTarget[]
3628
+ }
3629
+
2789
3630
  /** @internal */
2790
3631
  export declare type PatchSelection = string | string[] | MutationSelection
2791
3632
 
3633
+ /** @beta */
3634
+ export declare type PatchTarget = {
3635
+ /**
3636
+ * Determines how the target path will be patched.
3637
+ *
3638
+ * ### Operation types
3639
+ * - `'set'` – an *overwriting* operation: sets the full field value for primitive targets, and merges the provided value with existing values for objects
3640
+ * - `'append'`:
3641
+ * – array fields: appends new items to the end of the array,
3642
+ * - string fields: '"existing content" "new content"'
3643
+ * - text fields: '"existing content"\\n"new content"'
3644
+ * - number fields: existing + new
3645
+ * - other field types not mentioned will set instead (dates, url)
3646
+ * - `'mixed'` – sets non-array fields, and appends to array fields
3647
+ * - `'unset'` – removes whatever value is on the target path
3648
+ *
3649
+ * All operations except unset requires a `value`.
3650
+ *
3651
+ * #### Appending in the middle of arrays
3652
+ * To append to an array, use the 'append' operation, and provide an array value with one or more array items.
3653
+ *
3654
+ * `target: {path: ['array'], operation: 'append', value: [{_type: 'item' _key: 'a'}]}` will append the items in the value to the existing array.
3655
+ *
3656
+ * To insert in the middle of the array, use `target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append', value: [{_type: 'item' _key: 'a'}]}`.
3657
+ * Here, `{_type: 'item' _key: 'a'}` will be appended after the array item with key `'appendAfterKey'`
3658
+ *
3659
+ * It is optional to provide a _key for inserted array items; if one isn't provided, it will be generated.
3660
+ */
3661
+ operation: PatchOperation
3662
+ path: AgentActionPathSegment | AgentActionPath
3663
+ } & (
3664
+ | {
3665
+ operation: 'unset'
3666
+ value?: never
3667
+ }
3668
+ | {
3669
+ operation: Exclude<PatchOperation, 'unset'>
3670
+ value: AnyNonNullable
3671
+ }
3672
+ )
3673
+
3674
+ /**
3675
+ * Create a new document, then patch it
3676
+ * @beta
3677
+ */
3678
+ declare interface PatchTargetDocumentRequest<T extends Record<string, Any> = Record<string, Any>> {
3679
+ /**
3680
+ * @see #AgentActionSchema.forcePublishedWrite
3681
+ */
3682
+ targetDocument: GenerateTargetDocument<T>
3683
+ documentId?: never
3684
+ }
3685
+
2792
3686
  /** @public */
2793
3687
  declare interface ProgressEvent_2 {
2794
3688
  type: 'progress'
@@ -2820,6 +3714,131 @@ export declare class ProjectsClient {
2820
3714
  getById(projectId: string): Promise<SanityProject>
2821
3715
  }
2822
3716
 
3717
+ /**
3718
+ * @beta
3719
+ */
3720
+ declare interface PromptJsonResponse<T extends Record<string, Any> = Record<string, Any>> {
3721
+ /**
3722
+ *
3723
+ * When true, the response body will be json according to the instruction.
3724
+ * When false, the response is the raw text response to the instruction.
3725
+ *
3726
+ * Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
3727
+ */
3728
+ format: 'json'
3729
+ }
3730
+
3731
+ /** @beta */
3732
+ export declare type PromptRequest<T extends Record<string, Any> = Record<string, Any>> = (
3733
+ | PromptTextResponse
3734
+ | PromptJsonResponse<T>
3735
+ ) &
3736
+ PromptRequestBase
3737
+
3738
+ /** @beta */
3739
+ declare interface PromptRequestBase {
3740
+ /**
3741
+ * Instruct the LLM how it should generate content. Be as specific and detailed as needed.
3742
+ *
3743
+ * The LLM only has access to information in the instruction, plus the target schema.
3744
+ *
3745
+ * String template with support for $variable from `instructionParams`.
3746
+ * */
3747
+ instruction: string
3748
+ /**
3749
+ * param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable"
3750
+ *
3751
+ * ### Examples
3752
+ *
3753
+ * #### Constant
3754
+ *
3755
+ * ##### Shorthand
3756
+ * ```ts
3757
+ * client.agent.action.prompt({
3758
+ * instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it',
3759
+ * instructionParams: {
3760
+ * topic: 'Grapefruit'
3761
+ * },
3762
+ * })
3763
+ * ```
3764
+ * ##### Object-form
3765
+ *
3766
+ * ```ts
3767
+ * client.agent.action.prompt({
3768
+ * instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it.',
3769
+ * instructionParams: {
3770
+ * topic: {
3771
+ * type: 'constant',
3772
+ * value: 'Grapefruit'
3773
+ * },
3774
+ * },
3775
+ * })
3776
+ * ```
3777
+ * #### Field
3778
+ * ```ts
3779
+ * client.agent.action.prompt({
3780
+ * instruction: 'Give the following field value:\n $pte \n ---\nGenerate keywords.',
3781
+ * instructionParams: {
3782
+ * pte: {
3783
+ * type: 'field',
3784
+ * path: ['pteField'],
3785
+ * documentId: 'someSanityDocId'
3786
+ * },
3787
+ * },
3788
+ * })
3789
+ * ```
3790
+ * #### Document
3791
+ * ```ts
3792
+ * client.agent.action.prompt({
3793
+ * json: true,
3794
+ * instruction: 'Given the following document:$document\nCreate a JSON string[] array with keywords describing it.',
3795
+ * instructionParams: {
3796
+ * document: {
3797
+ * type: 'document',
3798
+ * documentId: 'someSanityDocId'
3799
+ * },
3800
+ * },
3801
+ * })
3802
+ * ```
3803
+ *
3804
+ * #### GROQ
3805
+ * ```ts
3806
+ * client.agent.action.prompt({
3807
+ * instruction: 'Return the best title amongst these: $titles.',
3808
+ * instructionParams: {
3809
+ * titles: {
3810
+ * type: 'groq',
3811
+ * query: '* [_type==$type].title',
3812
+ * params: {type: 'article'}
3813
+ * },
3814
+ * },
3815
+ * })
3816
+ * ```
3817
+ * */
3818
+ instructionParams?: AgentActionParams<{
3819
+ docIdRequired: true
3820
+ }>
3821
+ /**
3822
+ * Controls how much variance the instructions will run with.
3823
+ *
3824
+ * Value must be in the range [0, 1] (inclusive).
3825
+ *
3826
+ * Default: 0.3
3827
+ */
3828
+ temperature?: number
3829
+ }
3830
+
3831
+ declare interface PromptTextResponse {
3832
+ /**
3833
+ *
3834
+ * When true, the response body will be json according to the instruction.
3835
+ * When false, the response is the raw text response to the instruction.
3836
+ *
3837
+ * Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
3838
+ */
3839
+ format?: 'text'
3840
+ }
3841
+
2823
3842
  /**
2824
3843
  * Publishes a draft document.
2825
3844
  * If a published version of the document already exists this is replaced by the current draft document.
@@ -2849,11 +3868,22 @@ export declare type PublishAction = {
2849
3868
  ifPublishedRevisionId?: string
2850
3869
  }
2851
3870
 
3871
+ /**
3872
+ * Publishes all documents in a release at once.
3873
+ *
3874
+ * @public
3875
+ */
3876
+ export declare interface PublishReleaseAction {
3877
+ actionType: 'sanity.action.release.publish'
3878
+ releaseId: string
3879
+ }
3880
+
2852
3881
  /** @public */
2853
3882
  export declare type QueryOptions =
2854
3883
  | FilteredResponseQueryOptions
2855
3884
  | UnfilteredResponseQueryOptions
2856
3885
  | UnfilteredResponseWithoutQuery
3886
+ | EmulatedResponseQueryOptions
2857
3887
 
2858
3888
  /** @public */
2859
3889
  export declare interface QueryParams {
@@ -2896,68 +3926,441 @@ export declare interface QueryParams {
2896
3926
  cacheMode?: never
2897
3927
  }
2898
3928
 
2899
- /**
2900
- * This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
2901
- * @public
2902
- */
2903
- export declare type QueryWithoutParams = Record<string, never> | undefined
2904
-
2905
- /** @public */
2906
- export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
2907
-
2908
- /** @public */
2909
- export declare interface RawQueryResponse<R> {
2910
- query: string
2911
- ms: number
2912
- result: R
2913
- resultSourceMap?: ContentSourceMap
2914
- /** Requires `apiVersion` to be `2021-03-25` or later. */
2915
- syncTags?: SyncTag[]
2916
- }
3929
+ /**
3930
+ * Returned from the Content Lake API when a query is malformed, usually with a start
3931
+ * and end column to indicate where the error occurred, but not always. Can we used to
3932
+ * provide a more structured error message to the user.
3933
+ *
3934
+ * This will be located under the response `error` property.
3935
+ *
3936
+ * @public
3937
+ */
3938
+ export declare interface QueryParseError {
3939
+ type: 'queryParseError'
3940
+ description: string
3941
+ start?: number
3942
+ end?: number
3943
+ query?: string
3944
+ }
3945
+
3946
+ /**
3947
+ * This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
3948
+ * @public
3949
+ */
3950
+ export declare type QueryWithoutParams = Record<string, never> | undefined
3951
+
3952
+ /** @public */
3953
+ export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
3954
+
3955
+ /** @public */
3956
+ export declare interface RawQueryResponse<R> {
3957
+ query: string
3958
+ ms: number
3959
+ result: R
3960
+ resultSourceMap?: ContentSourceMap
3961
+ /** Requires `apiVersion` to be `2021-03-25` or later. */
3962
+ syncTags?: SyncTag[]
3963
+ }
3964
+
3965
+ /** @internal */
3966
+ export declare interface RawRequestOptions {
3967
+ url?: string
3968
+ uri?: string
3969
+ method?: string
3970
+ token?: string
3971
+ json?: boolean
3972
+ tag?: string
3973
+ useGlobalApi?: boolean
3974
+ withCredentials?: boolean
3975
+ query?: {
3976
+ [key: string]: string | string[]
3977
+ }
3978
+ headers?: {
3979
+ [key: string]: string
3980
+ }
3981
+ timeout?: number
3982
+ proxy?: string
3983
+ body?: Any
3984
+ maxRedirects?: number
3985
+ signal?: AbortSignal
3986
+ }
3987
+
3988
+ /**
3989
+ * The listener has been disconnected, and a reconnect attempt is scheduled.
3990
+ *
3991
+ * @public
3992
+ */
3993
+ export declare type ReconnectEvent = {
3994
+ type: 'reconnect'
3995
+ }
3996
+
3997
+ /** @public */
3998
+ export declare type ReleaseAction =
3999
+ | CreateReleaseAction
4000
+ | EditReleaseAction
4001
+ | PublishReleaseAction
4002
+ | ArchiveReleaseAction
4003
+ | UnarchiveReleaseAction
4004
+ | ScheduleReleaseAction
4005
+ | UnscheduleReleaseAction
4006
+ | DeleteReleaseAction
4007
+
4008
+ /** @internal */
4009
+ export declare interface ReleaseDocument extends SanityDocument {
4010
+ /**
4011
+ * typically
4012
+ * `_.releases.<name>`
4013
+ */
4014
+ _id: string
4015
+ /**
4016
+ * where a release has _id `_.releases.foo`, the name is `foo`
4017
+ */
4018
+ name: string
4019
+ _type: 'system.release'
4020
+ _createdAt: string
4021
+ _updatedAt: string
4022
+ _rev: string
4023
+ state: ReleaseState
4024
+ error?: {
4025
+ message: string
4026
+ }
4027
+ finalDocumentStates?: {
4028
+ /** Document ID */
4029
+ id: string
4030
+ }[]
4031
+ /**
4032
+ * If defined, it takes precedence over the intendedPublishAt, the state should be 'scheduled'
4033
+ */
4034
+ publishAt?: string
4035
+ /**
4036
+ * If defined, it provides the time the release was actually published
4037
+ */
4038
+ publishedAt?: string
4039
+ metadata: {
4040
+ title?: string
4041
+ description?: string
4042
+ intendedPublishAt?: string
4043
+ releaseType: ReleaseType
4044
+ }
4045
+ }
4046
+
4047
+ /**
4048
+ * @public
4049
+ * @deprecated – The `r`-prefix is not required, use `string` instead
4050
+ */
4051
+ export declare type ReleaseId = `r${string}`
4052
+
4053
+ /** @public */
4054
+ declare class ReleasesClient {
4055
+ #private
4056
+ constructor(client: SanityClient, httpRequest: HttpRequest)
4057
+ /**
4058
+ * @public
4059
+ *
4060
+ * Retrieve a release by id.
4061
+ *
4062
+ * @category Releases
4063
+ *
4064
+ * @param params - Release action parameters:
4065
+ * - `releaseId` - The id of the release to retrieve.
4066
+ * @param options - Additional query options including abort signal and query tag.
4067
+ * @returns A promise that resolves to the release document {@link ReleaseDocument}.
4068
+ *
4069
+ * @example Retrieving a release by id
4070
+ * ```ts
4071
+ * const release = await client.releases.get({releaseId: 'my-release'})
4072
+ * console.log(release)
4073
+ * // {
4074
+ * // _id: '_.releases.my-release',
4075
+ * // name: 'my-release'
4076
+ * // _type: 'system.release',
4077
+ * // metadata: {releaseType: 'asap'},
4078
+ * // _createdAt: '2021-01-01T00:00:00.000Z',
4079
+ * // ...
4080
+ * // }
4081
+ * ```
4082
+ */
4083
+ get(
4084
+ {
4085
+ releaseId,
4086
+ }: {
4087
+ releaseId: string
4088
+ },
4089
+ options?: {
4090
+ signal?: AbortSignal
4091
+ tag?: string
4092
+ },
4093
+ ): Promise<ReleaseDocument | undefined>
4094
+ /**
4095
+ * @public
4096
+ *
4097
+ * Creates a new release under the given id, with metadata.
4098
+ *
4099
+ * @remarks
4100
+ * * If no releaseId is provided, a release id will be generated.
4101
+ * * If no metadata is provided, then an `undecided` releaseType will be used.
4102
+ *
4103
+ * @category Releases
4104
+ *
4105
+ * @param params - Release action parameters:
4106
+ * - `releaseId` - The id of the release to create.
4107
+ * - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
4108
+ * @param options - Additional action options.
4109
+ * @returns A promise that resolves to the `transactionId` and the release id and metadata.
4110
+ *
4111
+ * @example Creating a release with a custom id and metadata
4112
+ * ```ts
4113
+ * const releaseId = 'my-release'
4114
+ * const releaseMetadata: ReleaseDocument['metadata'] = {
4115
+ * releaseType: 'asap',
4116
+ * }
4117
+ *
4118
+ * const result =
4119
+ * await client.releases.create({releaseId, metadata: releaseMetadata})
4120
+ * console.log(result)
4121
+ * // {
4122
+ * // transactionId: 'transaction-id',
4123
+ * // releaseId: 'my-release',
4124
+ * // metadata: {releaseType: 'asap'},
4125
+ * // }
4126
+ * ```
4127
+ *
4128
+ * @example Creating a release with generated id and metadata
4129
+ * ```ts
4130
+ * const {metadata} = await client.releases.create()
4131
+ * console.log(metadata.releaseType) // 'undecided'
4132
+ * ```
4133
+ *
4134
+ * @example Creating a release with a custom transaction id
4135
+ * ```ts
4136
+ * const {transactionId, metadata} = await client.releases.create({transactionId: 'my-transaction-id'})
4137
+ * console.log(metadata.releaseType) // 'undecided'
4138
+ * console.log(transactionId) // 'my-transaction-id'
4139
+ * ```
4140
+ */
4141
+ create(options: BaseActionOptions): Promise<
4142
+ SingleActionResult & {
4143
+ releaseId: string
4144
+ metadata: ReleaseDocument['metadata']
4145
+ }
4146
+ >
4147
+ create(
4148
+ release: {
4149
+ releaseId?: string
4150
+ metadata?: Partial<ReleaseDocument['metadata']>
4151
+ },
4152
+ options?: BaseActionOptions,
4153
+ ): Promise<
4154
+ SingleActionResult & {
4155
+ releaseId: string
4156
+ metadata: ReleaseDocument['metadata']
4157
+ }
4158
+ >
4159
+ /**
4160
+ * @public
4161
+ *
4162
+ * Edits an existing release, updating the metadata.
4163
+ *
4164
+ * @category Releases
4165
+ *
4166
+ * @param params - Release action parameters:
4167
+ * - `releaseId` - The id of the release to edit.
4168
+ * - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
4169
+ * @param options - Additional action options.
4170
+ * @returns A promise that resolves to the `transactionId`.
4171
+ */
4172
+ edit(
4173
+ {
4174
+ releaseId,
4175
+ patch,
4176
+ }: {
4177
+ releaseId: string
4178
+ patch: PatchOperations
4179
+ },
4180
+ options?: BaseActionOptions,
4181
+ ): Promise<SingleActionResult>
4182
+ /**
4183
+ * @public
4184
+ *
4185
+ * Publishes all documents in a release at once. For larger releases the effect of the publish
4186
+ * will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
4187
+ * documents and creation of the corresponding published documents with the new content may
4188
+ * take some time.
4189
+ *
4190
+ * During this period both the source and target documents are locked and cannot be
4191
+ * modified through any other means.
4192
+ *
4193
+ * @category Releases
4194
+ *
4195
+ * @param params - Release action parameters:
4196
+ * - `releaseId` - The id of the release to publish.
4197
+ * @param options - Additional action options.
4198
+ * @returns A promise that resolves to the `transactionId`.
4199
+ */
4200
+ publish(
4201
+ {
4202
+ releaseId,
4203
+ }: {
4204
+ releaseId: string
4205
+ },
4206
+ options?: BaseActionOptions,
4207
+ ): Promise<SingleActionResult>
4208
+ /**
4209
+ * @public
4210
+ *
4211
+ * An archive action removes an active release. The documents that comprise the release
4212
+ * are deleted and therefore no longer queryable.
4213
+ *
4214
+ * While the documents remain in retention the last version can still be accessed using document history endpoint.
4215
+ *
4216
+ * @category Releases
4217
+ *
4218
+ * @param params - Release action parameters:
4219
+ * - `releaseId` - The id of the release to archive.
4220
+ * @param options - Additional action options.
4221
+ * @returns A promise that resolves to the `transactionId`.
4222
+ */
4223
+ archive(
4224
+ {
4225
+ releaseId,
4226
+ }: {
4227
+ releaseId: string
4228
+ },
4229
+ options?: BaseActionOptions,
4230
+ ): Promise<SingleActionResult>
4231
+ /**
4232
+ * @public
4233
+ *
4234
+ * An unarchive action restores an archived release and all documents
4235
+ * with the content they had just prior to archiving.
4236
+ *
4237
+ * @category Releases
4238
+ *
4239
+ * @param params - Release action parameters:
4240
+ * - `releaseId` - The id of the release to unarchive.
4241
+ * @param options - Additional action options.
4242
+ * @returns A promise that resolves to the `transactionId`.
4243
+ */
4244
+ unarchive(
4245
+ {
4246
+ releaseId,
4247
+ }: {
4248
+ releaseId: string
4249
+ },
4250
+ options?: BaseActionOptions,
4251
+ ): Promise<SingleActionResult>
4252
+ /**
4253
+ * @public
4254
+ *
4255
+ * A schedule action queues a release for publishing at the given future time.
4256
+ * The release is locked such that no documents in the release can be modified and
4257
+ * no documents that it references can be deleted as this would make the publish fail.
4258
+ * At the given time, the same logic as for the publish action is triggered.
4259
+ *
4260
+ * @category Releases
4261
+ *
4262
+ * @param params - Release action parameters:
4263
+ * - `releaseId` - The id of the release to schedule.
4264
+ * - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
4265
+ * @param options - Additional action options.
4266
+ * @returns A promise that resolves to the `transactionId`.
4267
+ */
4268
+ schedule(
4269
+ {
4270
+ releaseId,
4271
+ publishAt,
4272
+ }: {
4273
+ releaseId: string
4274
+ publishAt: string
4275
+ },
4276
+ options?: BaseActionOptions,
4277
+ ): Promise<SingleActionResult>
4278
+ /**
4279
+ * @public
4280
+ *
4281
+ * An unschedule action stops a release from being published.
4282
+ * The documents in the release are considered unlocked and can be edited again.
4283
+ * This may fail if another release is scheduled to be published after this one and
4284
+ * has a reference to a document created by this one.
4285
+ *
4286
+ * @category Releases
4287
+ *
4288
+ * @param params - Release action parameters:
4289
+ * - `releaseId` - The id of the release to unschedule.
4290
+ * @param options - Additional action options.
4291
+ * @returns A promise that resolves to the `transactionId`.
4292
+ */
4293
+ unschedule(
4294
+ {
4295
+ releaseId,
4296
+ }: {
4297
+ releaseId: string
4298
+ },
4299
+ options?: BaseActionOptions,
4300
+ ): Promise<SingleActionResult>
4301
+ /**
4302
+ * @public
4303
+ *
4304
+ * A delete action removes a published or archived release.
4305
+ * The backing system document will be removed from the dataset.
4306
+ *
4307
+ * @category Releases
4308
+ *
4309
+ * @param params - Release action parameters:
4310
+ * - `releaseId` - The id of the release to delete.
4311
+ * @param options - Additional action options.
4312
+ * @returns A promise that resolves to the `transactionId`.
4313
+ */
4314
+ delete(
4315
+ {
4316
+ releaseId,
4317
+ }: {
4318
+ releaseId: string
4319
+ },
4320
+ options?: BaseActionOptions,
4321
+ ): Promise<SingleActionResult>
4322
+ /**
4323
+ * @public
4324
+ *
4325
+ * Fetch the documents in a release by release id.
4326
+ *
4327
+ * @category Releases
4328
+ *
4329
+ * @param params - Release action parameters:
4330
+ * - `releaseId` - The id of the release to fetch documents for.
4331
+ * @param options - Additional mutation options {@link BaseMutationOptions}.
4332
+ * @returns A promise that resolves to the documents in the release.
4333
+ */
4334
+ fetchDocuments(
4335
+ {
4336
+ releaseId,
4337
+ }: {
4338
+ releaseId: string
4339
+ },
4340
+ options?: BaseMutationOptions,
4341
+ ): Promise<RawQueryResponse<SanityDocument[]>>
4342
+ }
4343
+
4344
+ /** @beta */
4345
+ export declare type ReleaseState =
4346
+ | 'active'
4347
+ | 'archiving'
4348
+ | 'unarchiving'
4349
+ | 'archived'
4350
+ | 'published'
4351
+ | 'publishing'
4352
+ | 'scheduled'
4353
+ | 'scheduling'
2917
4354
 
2918
4355
  /** @internal */
2919
- export declare interface RawRequestOptions {
2920
- url?: string
2921
- uri?: string
2922
- method?: string
2923
- token?: string
2924
- json?: boolean
2925
- tag?: string
2926
- useGlobalApi?: boolean
2927
- withCredentials?: boolean
2928
- query?: {
2929
- [key: string]: string | string[]
2930
- }
2931
- headers?: {
2932
- [key: string]: string
2933
- }
2934
- timeout?: number
2935
- proxy?: string
2936
- body?: Any
2937
- maxRedirects?: number
2938
- signal?: AbortSignal
2939
- }
2940
-
2941
- /**
2942
- * The listener has been disconnected, and a reconnect attempt is scheduled.
2943
- *
2944
- * @public
2945
- */
2946
- export declare type ReconnectEvent = {
2947
- type: 'reconnect'
2948
- }
2949
-
2950
- /**
2951
- * @public
2952
- * @deprecated – The `r`-prefix is not required, use `string` instead
2953
- */
2954
- export declare type ReleaseId = `r${string}`
4356
+ export declare type ReleaseType = 'asap' | 'scheduled' | 'undecided'
2955
4357
 
2956
4358
  /**
2957
4359
  * Replaces an existing draft document.
2958
4360
  * At least one of the draft or published versions of the document must exist.
2959
4361
  *
2960
4362
  * @public
4363
+ * @deprecated Use {@link ReplaceVersionAction} instead
2961
4364
  */
2962
4365
  export declare type ReplaceDraftAction = {
2963
4366
  actionType: 'sanity.action.document.replaceDraft'
@@ -2971,6 +4374,16 @@ export declare type ReplaceDraftAction = {
2971
4374
  attributes: IdentifiedSanityDocumentStub
2972
4375
  }
2973
4376
 
4377
+ /**
4378
+ * Replace an existing version of a document.
4379
+ *
4380
+ * @public
4381
+ */
4382
+ export declare interface ReplaceVersionAction {
4383
+ actionType: 'sanity.action.document.version.replace'
4384
+ document: IdentifiedSanityDocumentStub
4385
+ }
4386
+
2974
4387
  /** @public */
2975
4388
  export declare const requester: Requester
2976
4389
 
@@ -3056,6 +4469,7 @@ export declare class SanityClient {
3056
4469
  agent: {
3057
4470
  action: AgentActionsClient
3058
4471
  }
4472
+ releases: ReleasesClient
3059
4473
  /**
3060
4474
  * Observable version of the Sanity client, with the same configuration as the promise-based one
3061
4475
  */
@@ -3152,6 +4566,7 @@ export declare class SanityClient {
3152
4566
  options?: {
3153
4567
  signal?: AbortSignal
3154
4568
  tag?: string
4569
+ releaseId?: string
3155
4570
  },
3156
4571
  ): Promise<SanityDocument<R> | undefined>
3157
4572
  /**
@@ -3335,6 +4750,90 @@ export declare class SanityClient {
3335
4750
  document: IdentifiedSanityDocumentStub<R>,
3336
4751
  options?: BaseMutationOptions,
3337
4752
  ): Promise<SanityDocument<R>>
4753
+ /**
4754
+ * @public
4755
+ *
4756
+ * Creates a new version of a published document.
4757
+ *
4758
+ * @remarks
4759
+ * * Requires a document with a `_type` property.
4760
+ * * Creating a version with no `releaseId` will create a new draft version of the published document.
4761
+ * * 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`.
4762
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
4763
+ * * To create a version of an unpublished document, use the `client.create` method.
4764
+ *
4765
+ * @category Versions
4766
+ *
4767
+ * @param params - Version action parameters:
4768
+ * - `document` - The document to create as a new version (must include `_type`).
4769
+ * - `publishedId` - The ID of the published document being versioned.
4770
+ * - `releaseId` - The ID of the release to create the version for.
4771
+ * @param options - Additional action options.
4772
+ * @returns A promise that resolves to the `transactionId`.
4773
+ *
4774
+ * @example Creating a new version of a published document with a generated version ID
4775
+ * ```ts
4776
+ * const transactionId = await client.createVersion({
4777
+ * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
4778
+ * document: {_type: 'myDocument', title: 'My Document'},
4779
+ * publishedId: 'myDocument',
4780
+ * releaseId: 'myRelease',
4781
+ * })
4782
+ *
4783
+ * // The following document will be created:
4784
+ * // {
4785
+ * // _id: 'versions.myRelease.myDocument',
4786
+ * // _type: 'myDocument',
4787
+ * // title: 'My Document',
4788
+ * // }
4789
+ * ```
4790
+ *
4791
+ * @example Creating a new version of a published document with a specified version ID
4792
+ * ```ts
4793
+ * const transactionId = await client.createVersion({
4794
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
4795
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
4796
+ * })
4797
+ *
4798
+ * // The following document will be created:
4799
+ * // {
4800
+ * // _id: 'versions.myRelease.myDocument',
4801
+ * // _type: 'myDocument',
4802
+ * // title: 'My Document',
4803
+ * // }
4804
+ * ```
4805
+ *
4806
+ * @example Creating a new draft version of a published document
4807
+ * ```ts
4808
+ * const transactionId = await client.createVersion({
4809
+ * document: {_type: 'myDocument', title: 'My Document'},
4810
+ * publishedId: 'myDocument',
4811
+ * })
4812
+ *
4813
+ * // The following document will be created:
4814
+ * // {
4815
+ * // _id: 'drafts.myDocument',
4816
+ * // _type: 'myDocument',
4817
+ * // title: 'My Document',
4818
+ * // }
4819
+ * ```
4820
+ */
4821
+ createVersion<R extends Record<string, Any>>(
4822
+ args: {
4823
+ document: SanityDocumentStub<R>
4824
+ publishedId: string
4825
+ releaseId?: string
4826
+ },
4827
+ options?: BaseActionOptions,
4828
+ ): Promise<SingleActionResult | MultipleActionResult>
4829
+ createVersion<R extends Record<string, Any>>(
4830
+ args: {
4831
+ document: IdentifiedSanityDocumentStub<R>
4832
+ publishedId?: string
4833
+ releaseId?: string
4834
+ },
4835
+ options?: BaseActionOptions,
4836
+ ): Promise<SingleActionResult | MultipleActionResult>
3338
4837
  /**
3339
4838
  * Deletes a document with the given document ID.
3340
4839
  * Returns a promise that resolves to the deleted document.
@@ -3439,6 +4938,157 @@ export declare class SanityClient {
3439
4938
  selection: MutationSelection,
3440
4939
  options?: BaseMutationOptions,
3441
4940
  ): Promise<SanityDocument<R>>
4941
+ /**
4942
+ * @public
4943
+ *
4944
+ * Deletes the draft or release version of a document.
4945
+ *
4946
+ * @remarks
4947
+ * * Discarding a version with no `releaseId` will discard the draft version of the published document.
4948
+ * * If the draft or release version does not exist, any error will throw.
4949
+ *
4950
+ * @param params - Version action parameters:
4951
+ * - `releaseId` - The ID of the release to discard the document from.
4952
+ * - `publishedId` - The published ID of the document to discard.
4953
+ * @param purge - if `true` the document history is also discarded.
4954
+ * @param options - Additional action options.
4955
+ * @returns a promise that resolves to the `transactionId`.
4956
+ *
4957
+ * @example Discarding a release version of a document
4958
+ * ```ts
4959
+ * client.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
4960
+ * // The document with the ID `versions.myRelease.myDocument` will be discarded.
4961
+ * ```
4962
+ *
4963
+ * @example Discarding a draft version of a document
4964
+ * ```ts
4965
+ * client.discardVersion({publishedId: 'myDocument'})
4966
+ * // The document with the ID `drafts.myDocument` will be discarded.
4967
+ * ```
4968
+ */
4969
+ discardVersion(
4970
+ {
4971
+ releaseId,
4972
+ publishedId,
4973
+ }: {
4974
+ releaseId?: string
4975
+ publishedId: string
4976
+ },
4977
+ purge?: boolean,
4978
+ options?: BaseActionOptions,
4979
+ ): Promise<SingleActionResult | MultipleActionResult>
4980
+ /**
4981
+ * @public
4982
+ *
4983
+ * Replaces an existing version document.
4984
+ *
4985
+ * @remarks
4986
+ * * Requires a document with a `_type` property.
4987
+ * * 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`.
4988
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
4989
+ * * Replacing a version with no `releaseId` will replace the draft version of the published document.
4990
+ * * At least one of the **version** or **published** documents must exist.
4991
+ *
4992
+ * @param params - Version action parameters:
4993
+ * - `document` - The new document to replace the version with.
4994
+ * - `releaseId` - The ID of the release where the document version is replaced.
4995
+ * - `publishedId` - The ID of the published document to replace.
4996
+ * @param options - Additional action options.
4997
+ * @returns a promise that resolves to the `transactionId`.
4998
+ *
4999
+ * @example Replacing a release version of a published document with a generated version ID
5000
+ * ```ts
5001
+ * await client.replaceVersion({
5002
+ * document: {_type: 'myDocument', title: 'My Document'},
5003
+ * publishedId: 'myDocument',
5004
+ * releaseId: 'myRelease',
5005
+ * })
5006
+ *
5007
+ * // The following document will be patched:
5008
+ * // {
5009
+ * // _id: 'versions.myRelease.myDocument',
5010
+ * // _type: 'myDocument',
5011
+ * // title: 'My Document',
5012
+ * // }
5013
+ * ```
5014
+ *
5015
+ * @example Replacing a release version of a published document with a specified version ID
5016
+ * ```ts
5017
+ * await client.replaceVersion({
5018
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
5019
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
5020
+ * })
5021
+ *
5022
+ * // The following document will be patched:
5023
+ * // {
5024
+ * // _id: 'versions.myRelease.myDocument',
5025
+ * // _type: 'myDocument',
5026
+ * // title: 'My Document',
5027
+ * // }
5028
+ * ```
5029
+ *
5030
+ * @example Replacing a draft version of a published document
5031
+ * ```ts
5032
+ * await client.replaceVersion({
5033
+ * document: {_type: 'myDocument', title: 'My Document'},
5034
+ * publishedId: 'myDocument',
5035
+ * })
5036
+ *
5037
+ * // The following document will be patched:
5038
+ * // {
5039
+ * // _id: 'drafts.myDocument',
5040
+ * // _type: 'myDocument',
5041
+ * // title: 'My Document',
5042
+ * // }
5043
+ * ```
5044
+ */
5045
+ replaceVersion<R extends Record<string, Any>>(
5046
+ args: {
5047
+ document: SanityDocumentStub<R>
5048
+ publishedId: string
5049
+ releaseId?: string
5050
+ },
5051
+ options?: BaseActionOptions,
5052
+ ): Promise<SingleActionResult | MultipleActionResult>
5053
+ replaceVersion<R extends Record<string, Any>>(
5054
+ args: {
5055
+ document: IdentifiedSanityDocumentStub<R>
5056
+ publishedId?: string
5057
+ releaseId?: string
5058
+ },
5059
+ options?: BaseActionOptions,
5060
+ ): Promise<SingleActionResult | MultipleActionResult>
5061
+ /**
5062
+ * @public
5063
+ *
5064
+ * Used to indicate when a document within a release should be unpublished when
5065
+ * the release is run.
5066
+ *
5067
+ * @remarks
5068
+ * * If the published document does not exist, an error will be thrown.
5069
+ *
5070
+ * @param params - Version action parameters:
5071
+ * - `releaseId` - The ID of the release to unpublish the document from.
5072
+ * - `publishedId` - The published ID of the document to unpublish.
5073
+ * @param options - Additional action options.
5074
+ * @returns a promise that resolves to the `transactionId`.
5075
+ *
5076
+ * @example Unpublishing a release version of a published document
5077
+ * ```ts
5078
+ * await client.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
5079
+ * // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
5080
+ * ```
5081
+ */
5082
+ unpublishVersion(
5083
+ {
5084
+ releaseId,
5085
+ publishedId,
5086
+ }: {
5087
+ releaseId: string
5088
+ publishedId: string
5089
+ },
5090
+ options?: BaseActionOptions,
5091
+ ): Promise<SingleActionResult | MultipleActionResult>
3442
5092
  /**
3443
5093
  * Perform mutation operations against the configured dataset
3444
5094
  * Returns a promise that resolves to the first mutated document.
@@ -3479,7 +5129,7 @@ export declare class SanityClient {
3479
5129
  * @param operations - Mutation operations to execute
3480
5130
  * @param options - Mutation options
3481
5131
  */
3482
- mutate<R extends Record<string, Any>>(
5132
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
3483
5133
  operations: Mutation<R>[] | Patch | Transaction,
3484
5134
  options: AllDocumentIdsMutationOptions,
3485
5135
  ): Promise<MultipleMutationResult>
@@ -3695,6 +5345,17 @@ export declare interface SanityUser {
3695
5345
  isCurrentUser: boolean
3696
5346
  }
3697
5347
 
5348
+ /**
5349
+ * Queues release for publishing at the given future time.
5350
+ *
5351
+ * @public
5352
+ */
5353
+ export declare interface ScheduleReleaseAction {
5354
+ actionType: 'sanity.action.release.schedule'
5355
+ releaseId: string
5356
+ publishAt: string
5357
+ }
5358
+
3698
5359
  /** @public */
3699
5360
  export declare class ServerError extends Error {
3700
5361
  response: ErrorProps['response']
@@ -3882,12 +5543,47 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
3882
5543
  declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
3883
5544
  TransformRequestBase & AgentActionSync
3884
5545
 
5546
+ /**
5547
+ *
5548
+ * ## `set` by default
5549
+ * By default, Transform will change the value of every target field in place using a set operation.
5550
+ *
5551
+ * ## Image description
5552
+ *
5553
+ * ### Targeting image fields
5554
+ * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
5555
+ * with `operation: {type: 'image-description'}`.
5556
+ *
5557
+ * Custom instructions for image description targets will be used to generate the description.
5558
+ *
5559
+ * Such targets must be a descendant field of an image object.
5560
+ *
5561
+ * For example:
5562
+ * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
5563
+ * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
5564
+ * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
5565
+ *
5566
+ * ### Targeting non-image fields
5567
+ * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
5568
+ * `sourcePath` must be an image or image asset field.
5569
+ *
5570
+ * For example:
5571
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
5572
+ * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5573
+ * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5574
+ *
5575
+ * @beta
5576
+ */
5577
+ export declare type TransformOperation = 'set' | ImageDescriptionOperation
5578
+
3885
5579
  /** @beta */
3886
5580
  declare interface TransformRequestBase extends AgentActionRequestBase {
3887
5581
  /** schemaId as reported by sanity deploy / sanity schema store */
3888
5582
  schemaId: string
3889
5583
  /**
3890
5584
  * The source document the transformation will use as input.
5585
+ *
5586
+ * @see #AgentActionSchema.forcePublishedWrite
3891
5587
  */
3892
5588
  documentId: string
3893
5589
  /**
@@ -3895,12 +5591,14 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
3895
5591
  * then it is transformed according to the instruction.
3896
5592
  *
3897
5593
  * When omitted, the source document (documentId) is also the target document.
5594
+ *
5595
+ * @see #AgentActionSchema.forcePublishedWrite
3898
5596
  */
3899
5597
  targetDocument?: TransformTargetDocument
3900
5598
  /**
3901
5599
  * Instruct the LLM how to transform the input to th output.
3902
5600
  *
3903
- * String template using $variable from instructionParams.
5601
+ * String template with support for $variable from `instructionParams`.
3904
5602
  *
3905
5603
  * Capped to 2000 characters, after variables has been injected.
3906
5604
  * */
@@ -3999,17 +5697,35 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
3999
5697
  * It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
4000
5698
  *
4001
5699
  * Default max depth for transform: 12
5700
+ *
5701
+ * ## Transforming images
5702
+ *
5703
+ * To transform an existing image, directly target an image asset path.
5704
+ *
5705
+ * For example, all the following will transform the image into the provided asset:
5706
+ * * `target: {path: ['image', 'asset'] }`
5707
+ * * `target: {path: 'image', include: ['asset'] }`
5708
+ *
5709
+ * Image transform can be combined with regular content targets:
5710
+ * * `target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]`
5711
+ *
5712
+ * Image transform can have per-path instructions, just like any other target paths:
5713
+ * * `target: [{path: ['image', 'asset'], instruction: 'Make the sky blue' }`
5714
+ *
4002
5715
  * @see AgentActionRequestBase#conditionalPaths
4003
5716
  */
4004
5717
  target?: TransformTarget | TransformTarget[]
4005
5718
  }
4006
5719
 
4007
- /** @beta */
5720
+ /**
5721
+ * @see #TransformOperation
5722
+ * @beta
5723
+ * */
4008
5724
  export declare interface TransformTarget extends AgentActionTarget {
4009
5725
  /**
4010
5726
  * Specifies a tailored instruction of this target.
4011
5727
  *
4012
- * string template using $variable from instructionParams.
5728
+ * String template with support for $variable from `instructionParams`.
4013
5729
  * */
4014
5730
  instruction?: string
4015
5731
  /**
@@ -4020,9 +5736,18 @@ export declare interface TransformTarget extends AgentActionTarget {
4020
5736
  * Fields or array items not on the include list, are implicitly excluded.
4021
5737
  */
4022
5738
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
5739
+ /**
5740
+ * Default: `set`
5741
+ * @see #TransformOperation
5742
+ */
5743
+ operation?: TransformOperation
4023
5744
  }
4024
5745
 
4025
- /** @beta */
5746
+ /**
5747
+ * @see #AgentActionSchema.forcePublishedWrite
5748
+ *
5749
+ * @beta
5750
+ */
4026
5751
  export declare type TransformTargetDocument =
4027
5752
  | {
4028
5753
  operation: 'edit'
@@ -4041,12 +5766,15 @@ export declare type TransformTargetDocument =
4041
5766
  _id: string
4042
5767
  }
4043
5768
 
4044
- /** @beta */
5769
+ /**
5770
+ * @see #TransformOperation
5771
+ * @beta
5772
+ * */
4045
5773
  export declare interface TransformTargetInclude extends AgentActionTargetInclude {
4046
5774
  /**
4047
5775
  * Specifies a tailored instruction of this target.
4048
5776
  *
4049
- * string template using $variable from instructionParams */
5777
+ * String template with support for $variable from `instructionParams`. */
4050
5778
  instruction?: string
4051
5779
  /**
4052
5780
  * By default, all children up to `target.maxPathDepth` are included.
@@ -4056,6 +5784,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
4056
5784
  * Fields or array items not on the include list, are implicitly excluded.
4057
5785
  */
4058
5786
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
5787
+ /**
5788
+ * Default: `set`
5789
+ * @see #TransformOperation
5790
+ */
5791
+ operation?: TransformOperation
4059
5792
  }
4060
5793
 
4061
5794
  /** @beta */
@@ -4088,6 +5821,7 @@ declare interface TranslateRequestBase extends AgentActionRequestBase {
4088
5821
  schemaId: string
4089
5822
  /**
4090
5823
  * The source document the transformation will use as input.
5824
+ * @see #AgentActionSchema.forcePublishedWrite
4091
5825
  */
4092
5826
  documentId: string
4093
5827
  /**
@@ -4095,6 +5829,8 @@ declare interface TranslateRequestBase extends AgentActionRequestBase {
4095
5829
  * then it is translated according to the instruction.
4096
5830
  *
4097
5831
  * When omitted, the source document (documentId) is also the target document.
5832
+ *
5833
+ * @see #AgentActionSchema.forcePublishedWrite
4098
5834
  */
4099
5835
  targetDocument?: TransformTargetDocument
4100
5836
  /**
@@ -4147,7 +5883,7 @@ declare interface TranslateRequestBase extends AgentActionRequestBase {
4147
5883
 
4148
5884
  /** @beta */
4149
5885
  export declare interface TranslateTarget extends AgentActionTarget {
4150
- /** string template using $variable from instructionParams */
5886
+ /** String template using $variable from styleGuideParams. */
4151
5887
  styleGuide?: string
4152
5888
  /**
4153
5889
  * By default, all children up to `target.maxPathDepth` are included.
@@ -4161,7 +5897,7 @@ export declare interface TranslateTarget extends AgentActionTarget {
4161
5897
 
4162
5898
  /** @beta */
4163
5899
  export declare interface TranslateTargetInclude extends AgentActionTargetInclude {
4164
- /** string template using $variable from instructionParams */
5900
+ /** String template using $variable from styleGuideParams. */
4165
5901
  styleGuide?: string
4166
5902
  /**
4167
5903
  * By default, all children up to `target.maxPathDepth` are included.
@@ -4173,6 +5909,16 @@ export declare interface TranslateTargetInclude extends AgentActionTargetInclude
4173
5909
  include?: (AgentActionPathSegment | TranslateTargetInclude)[]
4174
5910
  }
4175
5911
 
5912
+ /**
5913
+ * Unarchived an `archived` release, and restores all the release documents.
5914
+ *
5915
+ * @public
5916
+ */
5917
+ export declare interface UnarchiveReleaseAction {
5918
+ actionType: 'sanity.action.release.unarchive'
5919
+ releaseId: string
5920
+ }
5921
+
4176
5922
  /** @public */
4177
5923
  export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
4178
5924
  filterResponse: false
@@ -4214,6 +5960,28 @@ export declare type UnpublishAction = {
4214
5960
  publishedId: string
4215
5961
  }
4216
5962
 
5963
+ /**
5964
+ * Identify that a version of a document should be unpublished when
5965
+ * the release that version is contained within is published.
5966
+ *
5967
+ * @public
5968
+ */
5969
+ export declare interface UnpublishVersionAction {
5970
+ actionType: 'sanity.action.document.version.unpublish'
5971
+ versionId: string
5972
+ publishedId: string
5973
+ }
5974
+
5975
+ /**
5976
+ * Unschedules a `scheduled` release, stopping it from being published.
5977
+ *
5978
+ * @public
5979
+ */
5980
+ export declare interface UnscheduleReleaseAction {
5981
+ actionType: 'sanity.action.release.unschedule'
5982
+ releaseId: string
5983
+ }
5984
+
4217
5985
  export {unstable__adapter}
4218
5986
 
4219
5987
  export {unstable__environment}
@@ -4301,6 +6069,37 @@ export declare function validateApiPerspective(
4301
6069
  perspective: unknown,
4302
6070
  ): asserts perspective is ClientPerspective
4303
6071
 
6072
+ /** @public */
6073
+ export declare type VersionAction =
6074
+ | CreateVersionAction
6075
+ | DiscardVersionAction
6076
+ | ReplaceVersionAction
6077
+ | UnpublishVersionAction
6078
+
6079
+ /** @public */
6080
+ export declare type ViewConnectionOverride = {
6081
+ query: string
6082
+ resourceType: ViewResourceType
6083
+ resourceId: string
6084
+ }
6085
+
6086
+ /** @public */
6087
+ export declare type ViewOverride = {
6088
+ id: string
6089
+ connections: ViewConnectionOverride[]
6090
+ }
6091
+
6092
+ /** @public */
6093
+ export declare type ViewQueryOptions = Pick<
6094
+ EmulatedResponseQueryOptions,
6095
+ 'perspective' | 'resultSourceMap' | 'filterResponse'
6096
+ >
6097
+
6098
+ /** @public */
6099
+ export declare enum ViewResourceType {
6100
+ Dataset = 'dataset',
6101
+ }
6102
+
4304
6103
  /**
4305
6104
  * The listener has been established, and will start receiving events.
4306
6105
  * Note that this is also emitted upon _reconnection_.