@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
@@ -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 */
@@ -892,6 +975,29 @@ export declare type CreateAction = {
892
975
  /** @public */
893
976
  export declare const createClient: (config: ClientConfig) => SanityClient
894
977
 
978
+ /**
979
+ * Creates a new release under the given id, with metadata.
980
+ *
981
+ * @public
982
+ */
983
+ export declare interface CreateReleaseAction {
984
+ actionType: 'sanity.action.release.create'
985
+ releaseId: string
986
+ metadata?: Partial<ReleaseDocument['metadata']>
987
+ }
988
+
989
+ /**
990
+ * Creates a new version of an existing document, attached to the release as given
991
+ * by `document._id`
992
+ *
993
+ * @public
994
+ */
995
+ export declare interface CreateVersionAction {
996
+ actionType: 'sanity.action.document.version.create'
997
+ publishedId: string
998
+ document: IdentifiedSanityDocumentStub
999
+ }
1000
+
895
1001
  /** @public */
896
1002
  export declare interface CurrentSanityUser {
897
1003
  id: string
@@ -987,6 +1093,16 @@ export declare type DeleteAction = {
987
1093
  purge?: boolean
988
1094
  }
989
1095
 
1096
+ /**
1097
+ * Deletes a `archived` or `published` release, and all the release documents versions.
1098
+ *
1099
+ * @public
1100
+ */
1101
+ export declare interface DeleteReleaseAction {
1102
+ actionType: 'sanity.action.release.delete'
1103
+ releaseId: string
1104
+ }
1105
+
990
1106
  /**
991
1107
  * @public
992
1108
  * @deprecated Use the named export `createClient` instead of the `default` export
@@ -1004,6 +1120,7 @@ declare type DeprecatedPreviewDrafts = 'previewDrafts'
1004
1120
  * It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
1005
1121
  *
1006
1122
  * @public
1123
+ * @deprecated Use {@link DiscardVersionAction} instead
1007
1124
  */
1008
1125
  export declare type DiscardAction = {
1009
1126
  actionType: 'sanity.action.document.discard'
@@ -1017,6 +1134,17 @@ export declare type DiscardAction = {
1017
1134
  purge?: boolean
1018
1135
  }
1019
1136
 
1137
+ /**
1138
+ * Delete a version of a document.
1139
+ *
1140
+ * @public
1141
+ */
1142
+ export declare interface DiscardVersionAction {
1143
+ actionType: 'sanity.action.document.version.discard'
1144
+ versionId: string
1145
+ purge?: boolean
1146
+ }
1147
+
1020
1148
  /**
1021
1149
  * The listener has been told to explicitly disconnect.
1022
1150
  * This is a rare situation, but may occur if the API knows reconnect attempts will fail,
@@ -1043,6 +1171,23 @@ export declare type DisconnectEvent = {
1043
1171
  reason: string
1044
1172
  }
1045
1173
 
1174
+ declare type DocIdParam<
1175
+ TParamConfig extends {
1176
+ docIdRequired: boolean
1177
+ } = {
1178
+ docIdRequired: false
1179
+ },
1180
+ > = TParamConfig['docIdRequired'] extends true
1181
+ ? {
1182
+ documentId: string
1183
+ }
1184
+ : {
1185
+ /**
1186
+ * If omitted, implicitly uses the documentId of the instruction target
1187
+ */
1188
+ documentId?: string
1189
+ }
1190
+
1046
1191
  /**
1047
1192
  *
1048
1193
  * Includes a LLM-friendly version of the document in the instruction
@@ -1063,12 +1208,23 @@ export declare type DisconnectEvent = {
1063
1208
  *
1064
1209
  * @beta
1065
1210
  * */
1066
- export declare interface DocumentAgentActionParam {
1211
+ export declare type DocumentAgentActionParam<
1212
+ TParamConfig extends {
1213
+ docIdRequired: boolean
1214
+ } = {
1215
+ docIdRequired: false
1216
+ },
1217
+ > = {
1067
1218
  type: 'document'
1068
- /**
1069
- * If omitted, implicitly uses the documentId of the instruction target
1070
- */
1071
- documentId?: string
1219
+ } & DocIdParam<TParamConfig>
1220
+
1221
+ /** @internal */
1222
+ export declare type EditableReleaseDocument = Omit<
1223
+ PartialExcept<ReleaseDocument, '_id'>,
1224
+ 'metadata' | '_type'
1225
+ > & {
1226
+ _id: string
1227
+ metadata: Partial<ReleaseDocument['metadata']>
1072
1228
  }
1073
1229
 
1074
1230
  /**
@@ -1094,6 +1250,25 @@ export declare type EditAction = {
1094
1250
  patch: PatchOperations
1095
1251
  }
1096
1252
 
1253
+ /**
1254
+ * Edits an existing release, updating the metadata.
1255
+ *
1256
+ * @public
1257
+ */
1258
+ export declare interface EditReleaseAction {
1259
+ actionType: 'sanity.action.release.edit'
1260
+ releaseId: string
1261
+ patch: PatchOperations
1262
+ }
1263
+
1264
+ /** @public */
1265
+ export declare interface EmulatedResponseQueryOptions extends ResponseQueryOptions {
1266
+ useEmulate: boolean
1267
+ connections?: ViewConnectionOverride[] | undefined
1268
+ filterResponse?: false
1269
+ returnQuery?: false
1270
+ }
1271
+
1097
1272
  /** @public */
1098
1273
  export declare interface ErrorProps {
1099
1274
  message: string
@@ -1136,17 +1311,19 @@ export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSo
1136
1311
  *
1137
1312
  * @beta
1138
1313
  * */
1139
- export declare interface FieldAgentActionParam {
1314
+ export declare type FieldAgentActionParam<
1315
+ TParamConfig extends {
1316
+ docIdRequired: boolean
1317
+ } = {
1318
+ docIdRequired: false
1319
+ },
1320
+ > = {
1140
1321
  type: 'field'
1141
1322
  /**
1142
1323
  * Examples: 'title', ['array', \{_key: 'arrayItemKey'\}, 'field']
1143
1324
  */
1144
1325
  path: AgentActionPathSegment | AgentActionPath
1145
- /**
1146
- * If omitted, implicitly uses the documentId of the instruction target
1147
- */
1148
- documentId?: string
1149
- }
1326
+ } & DocIdParam<TParamConfig>
1150
1327
 
1151
1328
  /** @public */
1152
1329
  export declare type FilterDefault = (props: {
@@ -1214,6 +1391,16 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
1214
1391
  returnDocuments?: true
1215
1392
  }
1216
1393
 
1394
+ /**
1395
+ * Formats a GROQ query parse error into a human-readable string.
1396
+ *
1397
+ * @param error - The error object containing details about the parse error.
1398
+ * @param tag - An optional tag to include in the error message.
1399
+ * @returns A formatted error message string.
1400
+ * @public
1401
+ */
1402
+ export declare function formatQueryParseError(error: QueryParseError, tag?: string | null): string
1403
+
1217
1404
  /** @beta */
1218
1405
  declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
1219
1406
  | GenerateExistingDocumentRequest
@@ -1227,8 +1414,11 @@ declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<str
1227
1414
  * @beta
1228
1415
  */
1229
1416
  declare interface GenerateExistingDocumentRequest {
1417
+ /**
1418
+ * @see #AgentActionSchema.forcePublishedWrite
1419
+ */
1230
1420
  documentId: string
1231
- createDocument?: never
1421
+ targetDocument?: never
1232
1422
  }
1233
1423
 
1234
1424
  /** @beta */
@@ -1248,7 +1438,7 @@ declare interface GenerateRequestBase extends AgentActionRequestBase {
1248
1438
  *
1249
1439
  * The LLM only has access to information in the instruction, plus the target schema.
1250
1440
  *
1251
- * string template using $variable
1441
+ * String template with support for $variable from `instructionParams`.
1252
1442
  * */
1253
1443
  instruction: string
1254
1444
  /**
@@ -1343,6 +1533,21 @@ declare interface GenerateRequestBase extends AgentActionRequestBase {
1343
1533
  * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
1344
1534
  * It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
1345
1535
  *
1536
+ * ## Generating images
1537
+ *
1538
+ * Generate will generate images the same was as AI Assist, for images that have been configured using
1539
+ * [AI Assist schema options](https://github.com/sanity-io/assist/tree/main/plugin#image-generation).
1540
+ *
1541
+ * To generate images _without_ changing the schema, directly target an image asset path.
1542
+ *
1543
+ * For example, all the following will generate an image into the provided asset:
1544
+ * * `target: {path: ['image', 'asset'] }`
1545
+ * * `target: {path: 'image', include: ['asset'] }`
1546
+ *
1547
+ * Image generation can be combined with regular content targets:
1548
+ * * `target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]`
1549
+ *
1550
+ * Since Generate happens in a single LLM pass, the image will be contextually related to other generated content.
1346
1551
  * @see AgentActionRequestBase#conditionalPaths
1347
1552
  */
1348
1553
  target?: GenerateTarget | GenerateTarget[]
@@ -1389,6 +1594,7 @@ export declare interface GenerateTarget extends AgentActionTarget {
1389
1594
  * @see #AgentActionTargetInclude.operation
1390
1595
  * @see #include
1391
1596
  * @see #AgentActionTargetInclude.include
1597
+ * @see #AgentActionSchema.forcePublishedWrite
1392
1598
  */
1393
1599
  operation?: GenerateOperation
1394
1600
  /**
@@ -1405,22 +1611,34 @@ export declare interface GenerateTarget extends AgentActionTarget {
1405
1611
  export declare type GenerateTargetDocument<T extends Record<string, Any> = Record<string, Any>> =
1406
1612
  | {
1407
1613
  operation: 'edit'
1614
+ /**
1615
+ * @see #AgentActionSchema.forcePublishedWrite
1616
+ */
1408
1617
  _id: string
1409
1618
  }
1410
1619
  | {
1411
1620
  operation: 'create'
1621
+ /**
1622
+ * @see #AgentActionSchema.forcePublishedWrite
1623
+ */
1412
1624
  _id?: string
1413
1625
  _type: string
1414
1626
  initialValues?: T
1415
1627
  }
1416
1628
  | {
1417
1629
  operation: 'createIfNotExists'
1630
+ /**
1631
+ * @see #AgentActionSchema.forcePublishedWrite
1632
+ */
1418
1633
  _id: string
1419
1634
  _type: string
1420
1635
  initialValues?: T
1421
1636
  }
1422
1637
  | {
1423
1638
  operation: 'createOrReplace'
1639
+ /**
1640
+ * @see #AgentActionSchema.forcePublishedWrite
1641
+ */
1424
1642
  _id: string
1425
1643
  _type: string
1426
1644
  initialValues?: T
@@ -1433,6 +1651,9 @@ export declare type GenerateTargetDocument<T extends Record<string, Any> = Recor
1433
1651
  declare interface GenerateTargetDocumentRequest<
1434
1652
  T extends Record<string, Any> = Record<string, Any>,
1435
1653
  > {
1654
+ /**
1655
+ * @see #AgentActionSchema.forcePublishedWrite
1656
+ */
1436
1657
  targetDocument: GenerateTargetDocument<T>
1437
1658
  documentId?: never
1438
1659
  }
@@ -1499,6 +1720,24 @@ export declare type IdentifiedSanityDocumentStub<
1499
1720
  _id: string
1500
1721
  } & SanityDocumentStub
1501
1722
 
1723
+ /**
1724
+ *
1725
+ * @see #TransformOperation
1726
+ * @beta
1727
+ */
1728
+ export declare interface ImageDescriptionOperation {
1729
+ type: 'image-description'
1730
+ /**
1731
+ * When omitted, parent image value will be inferred from the arget path.
1732
+ *
1733
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1734
+ * - `['image']`
1735
+ * - `['wrapper', 'mainImage']`
1736
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1737
+ */
1738
+ sourcePath?: AgentActionPath
1739
+ }
1740
+
1502
1741
  /** @public */
1503
1742
  export declare interface InitializedClientConfig extends ClientConfig {
1504
1743
  apiHost: string
@@ -1521,6 +1760,12 @@ export declare interface InitializedClientConfig extends ClientConfig {
1521
1760
  * The fully initialized stega config, can be used to check if stega is enabled
1522
1761
  */
1523
1762
  stega: InitializedStegaConfig
1763
+ /**
1764
+ * Default headers to include with all requests
1765
+ *
1766
+ * @remarks request-specific headers will override any default headers with the same name.
1767
+ */
1768
+ headers?: Record<string, string>
1524
1769
  }
1525
1770
 
1526
1771
  /** @public */
@@ -1542,6 +1787,9 @@ export declare type InsertPatch =
1542
1787
  items: Any[]
1543
1788
  }
1544
1789
 
1790
+ /** @internal */
1791
+ export declare function isQueryParseError(error: object): error is QueryParseError
1792
+
1545
1793
  /**
1546
1794
  * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
1547
1795
  *
@@ -1775,11 +2023,9 @@ export declare type Mutation<R extends Record<string, Any> = Record<string, Any>
1775
2023
 
1776
2024
  /** @internal */
1777
2025
  export declare interface MutationError {
1778
- error: {
1779
- type: 'mutationError'
1780
- description: string
1781
- items?: MutationErrorItem[]
1782
- }
2026
+ type: 'mutationError'
2027
+ description: string
2028
+ items?: MutationErrorItem[]
1783
2029
  }
1784
2030
 
1785
2031
  /** @internal */
@@ -2120,43 +2366,344 @@ export declare class ObservableProjectsClient {
2120
2366
  }
2121
2367
 
2122
2368
  /** @public */
2123
- export declare class ObservableSanityClient {
2369
+ declare class ObservableReleasesClient {
2124
2370
  #private
2125
- assets: ObservableAssetsClient
2126
- datasets: ObservableDatasetsClient
2127
- live: LiveClient
2128
- projects: ObservableProjectsClient
2129
- users: ObservableUsersClient
2130
- agent: {
2131
- action: ObservableAgentsActionClient
2132
- }
2133
- /**
2134
- * Instance properties
2135
- */
2136
- listen: typeof _listen
2137
- constructor(httpRequest: HttpRequest, config?: ClientConfig)
2371
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
2138
2372
  /**
2139
- * Clone the client - returns a new instance
2373
+ * @public
2374
+ *
2375
+ * Retrieve a release by id.
2376
+ *
2377
+ * @category Releases
2378
+ *
2379
+ * @param params - Release action parameters:
2380
+ * - `releaseId` - The id of the release to retrieve.
2381
+ * @param options - Additional query options including abort signal and query tag.
2382
+ * @returns An observable that resolves to the release document {@link ReleaseDocument}.
2383
+ *
2384
+ * @example Retrieving a release by id
2385
+ * ```ts
2386
+ * client.observable.releases.get({releaseId: 'my-release'}).pipe(
2387
+ * tap((release) => console.log(release)),
2388
+ * // {
2389
+ * // _id: '_.releases.my-release',
2390
+ * // name: 'my-release'
2391
+ * // _type: 'system.release',
2392
+ * // metadata: {releaseType: 'asap'},
2393
+ * // _createdAt: '2021-01-01T00:00:00.000Z',
2394
+ * // ...
2395
+ * // }
2396
+ * ).subscribe()
2397
+ * ```
2140
2398
  */
2141
- clone(): ObservableSanityClient
2399
+ get(
2400
+ {
2401
+ releaseId,
2402
+ }: {
2403
+ releaseId: string
2404
+ },
2405
+ options?: {
2406
+ signal?: AbortSignal
2407
+ tag?: string
2408
+ },
2409
+ ): Observable<ReleaseDocument | undefined>
2142
2410
  /**
2143
- * Returns the current client configuration
2411
+ * @public
2412
+ *
2413
+ * Creates a new release under the given id, with metadata.
2414
+ *
2415
+ * @remarks
2416
+ * * If no releaseId is provided, a release id will be generated.
2417
+ * * If no metadata is provided, then an `undecided` releaseType will be used.
2418
+ *
2419
+ * @category Releases
2420
+ *
2421
+ * @param params - Release action parameters:
2422
+ * - `releaseId` - The id of the release to create.
2423
+ * - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
2424
+ * @param options - Additional action options.
2425
+ * @returns An observable that resolves to the `transactionId` and the release id and metadata.
2426
+ *
2427
+ * @example Creating a release with a custom id and metadata
2428
+ * ```ts
2429
+ * const releaseId = 'my-release'
2430
+ * const metadata: ReleaseDocument['metadata'] = {
2431
+ * releaseType: 'asap',
2432
+ * }
2433
+ *
2434
+ * client.observable.releases.create({releaseId, metadata}).pipe(
2435
+ * tap(({transactionId, releaseId, metadata}) => console.log(transactionId, releaseId, metadata)),
2436
+ * // {
2437
+ * // transactionId: 'transaction-id',
2438
+ * // releaseId: 'my-release',
2439
+ * // metadata: {releaseType: 'asap'},
2440
+ * // }
2441
+ * ).subscribe()
2442
+ * ```
2443
+ *
2444
+ * @example Creating a release with generated id and metadata
2445
+ * ```ts
2446
+ * client.observable.releases.create().pipe(
2447
+ * tap(({metadata}) => console.log(metadata)),
2448
+ * // {
2449
+ * // metadata: {releaseType: 'undecided'},
2450
+ * // }
2451
+ * ).subscribe()
2452
+ * ```
2453
+ *
2454
+ * @example Creating a release using a custom transaction id
2455
+ * ```ts
2456
+ * client.observable.releases.create({transactionId: 'my-transaction-id'}).pipe(
2457
+ * tap(({transactionId, metadata}) => console.log(transactionId, metadata)),
2458
+ * // {
2459
+ * // transactionId: 'my-transaction-id',
2460
+ * // metadata: {releaseType: 'undecided'},
2461
+ * // }
2462
+ * ).subscribe()
2463
+ * ```
2144
2464
  */
2145
- config(): InitializedClientConfig
2465
+ create(options: BaseActionOptions): Observable<
2466
+ SingleActionResult & {
2467
+ releaseId: string
2468
+ metadata: ReleaseDocument['metadata']
2469
+ }
2470
+ >
2471
+ create(
2472
+ release: {
2473
+ releaseId?: string
2474
+ metadata?: Partial<ReleaseDocument['metadata']>
2475
+ },
2476
+ options?: BaseActionOptions,
2477
+ ): Observable<
2478
+ SingleActionResult & {
2479
+ releaseId: string
2480
+ metadata: ReleaseDocument['metadata']
2481
+ }
2482
+ >
2146
2483
  /**
2147
- * Reconfigure the client. Note that this _mutates_ the current client.
2484
+ * @public
2485
+ *
2486
+ * Edits an existing release, updating the metadata.
2487
+ *
2488
+ * @category Releases
2489
+ *
2490
+ * @param params - Release action parameters:
2491
+ * - `releaseId` - The id of the release to edit.
2492
+ * - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
2493
+ * @param options - Additional action options.
2494
+ * @returns An observable that resolves to the `transactionId`.
2148
2495
  */
2149
- config(newConfig?: Partial<ClientConfig>): this
2496
+ edit(
2497
+ {
2498
+ releaseId,
2499
+ patch,
2500
+ }: {
2501
+ releaseId: string
2502
+ patch: PatchOperations
2503
+ },
2504
+ options?: BaseActionOptions,
2505
+ ): Observable<SingleActionResult>
2150
2506
  /**
2151
- * Clone the client with a new (partial) configuration.
2507
+ * @public
2152
2508
  *
2153
- * @param newConfig - New client configuration properties, shallowly merged with existing configuration
2509
+ * Publishes all documents in a release at once. For larger releases the effect of the publish
2510
+ * will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
2511
+ * documents and creation of the corresponding published documents with the new content may
2512
+ * take some time.
2513
+ *
2514
+ * During this period both the source and target documents are locked and cannot be
2515
+ * modified through any other means.
2516
+ *
2517
+ * @category Releases
2518
+ *
2519
+ * @param params - Release action parameters:
2520
+ * - `releaseId` - The id of the release to publish.
2521
+ * @param options - Additional action options.
2522
+ * @returns An observable that resolves to the `transactionId`.
2154
2523
  */
2155
- withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
2524
+ publish(
2525
+ {
2526
+ releaseId,
2527
+ }: {
2528
+ releaseId: string
2529
+ },
2530
+ options?: BaseActionOptions,
2531
+ ): Observable<SingleActionResult>
2156
2532
  /**
2157
- * Perform a GROQ-query against the configured dataset.
2533
+ * @public
2158
2534
  *
2159
- * @param query - GROQ-query to perform
2535
+ * An archive action removes an active release. The documents that comprise the release
2536
+ * are deleted and therefore no longer queryable.
2537
+ *
2538
+ * While the documents remain in retention the last version can still be accessed using document history endpoint.
2539
+ *
2540
+ * @category Releases
2541
+ *
2542
+ * @param params - Release action parameters:
2543
+ * - `releaseId` - The id of the release to archive.
2544
+ * @param options - Additional action options.
2545
+ * @returns An observable that resolves to the `transactionId`.
2546
+ */
2547
+ archive(
2548
+ {
2549
+ releaseId,
2550
+ }: {
2551
+ releaseId: string
2552
+ },
2553
+ options?: BaseActionOptions,
2554
+ ): Observable<SingleActionResult>
2555
+ /**
2556
+ * @public
2557
+ *
2558
+ * An unarchive action restores an archived release and all documents
2559
+ * with the content they had just prior to archiving.
2560
+ *
2561
+ * @category Releases
2562
+ *
2563
+ * @param params - Release action parameters:
2564
+ * - `releaseId` - The id of the release to unarchive.
2565
+ * @param options - Additional action options.
2566
+ * @returns An observable that resolves to the `transactionId`.
2567
+ */
2568
+ unarchive(
2569
+ {
2570
+ releaseId,
2571
+ }: {
2572
+ releaseId: string
2573
+ },
2574
+ options?: BaseActionOptions,
2575
+ ): Observable<SingleActionResult>
2576
+ /**
2577
+ * @public
2578
+ *
2579
+ * A schedule action queues a release for publishing at the given future time.
2580
+ * The release is locked such that no documents in the release can be modified and
2581
+ * no documents that it references can be deleted as this would make the publish fail.
2582
+ * At the given time, the same logic as for the publish action is triggered.
2583
+ *
2584
+ * @category Releases
2585
+ *
2586
+ * @param params - Release action parameters:
2587
+ * - `releaseId` - The id of the release to schedule.
2588
+ * - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
2589
+ * @param options - Additional action options.
2590
+ * @returns An observable that resolves to the `transactionId`.
2591
+ */
2592
+ schedule(
2593
+ {
2594
+ releaseId,
2595
+ publishAt,
2596
+ }: {
2597
+ releaseId: string
2598
+ publishAt: string
2599
+ },
2600
+ options?: BaseActionOptions,
2601
+ ): Observable<SingleActionResult>
2602
+ /**
2603
+ * @public
2604
+ *
2605
+ * An unschedule action stops a release from being published.
2606
+ * The documents in the release are considered unlocked and can be edited again.
2607
+ * This may fail if another release is scheduled to be published after this one and
2608
+ * has a reference to a document created by this one.
2609
+ *
2610
+ * @category Releases
2611
+ *
2612
+ * @param params - Release action parameters:
2613
+ * - `releaseId` - The id of the release to unschedule.
2614
+ * @param options - Additional action options.
2615
+ * @returns An observable that resolves to the `transactionId`.
2616
+ */
2617
+ unschedule(
2618
+ {
2619
+ releaseId,
2620
+ }: {
2621
+ releaseId: string
2622
+ },
2623
+ options?: BaseActionOptions,
2624
+ ): Observable<SingleActionResult>
2625
+ /**
2626
+ * @public
2627
+ *
2628
+ * A delete action removes a published or archived release.
2629
+ * The backing system document will be removed from the dataset.
2630
+ *
2631
+ * @category Releases
2632
+ *
2633
+ * @param params - Release action parameters:
2634
+ * - `releaseId` - The id of the release to delete.
2635
+ * @param options - Additional action options.
2636
+ * @returns An observable that resolves to the `transactionId`.
2637
+ */
2638
+ delete(
2639
+ {
2640
+ releaseId,
2641
+ }: {
2642
+ releaseId: string
2643
+ },
2644
+ options?: BaseActionOptions,
2645
+ ): Observable<SingleActionResult>
2646
+ /**
2647
+ * @public
2648
+ *
2649
+ * Fetch the documents in a release by release id.
2650
+ *
2651
+ * @category Releases
2652
+ *
2653
+ * @param params - Release action parameters:
2654
+ * - `releaseId` - The id of the release to fetch documents for.
2655
+ * @param options - Additional mutation options {@link BaseMutationOptions}.
2656
+ * @returns An observable that resolves to the documents in the release.
2657
+ */
2658
+ fetchDocuments(
2659
+ {
2660
+ releaseId,
2661
+ }: {
2662
+ releaseId: string
2663
+ },
2664
+ options?: BaseMutationOptions,
2665
+ ): Observable<RawQueryResponse<SanityDocument[]>>
2666
+ }
2667
+
2668
+ /** @public */
2669
+ export declare class ObservableSanityClient {
2670
+ #private
2671
+ assets: ObservableAssetsClient
2672
+ datasets: ObservableDatasetsClient
2673
+ live: LiveClient
2674
+ projects: ObservableProjectsClient
2675
+ users: ObservableUsersClient
2676
+ agent: {
2677
+ action: ObservableAgentsActionClient
2678
+ }
2679
+ releases: ObservableReleasesClient
2680
+ /**
2681
+ * Instance properties
2682
+ */
2683
+ listen: typeof _listen
2684
+ constructor(httpRequest: HttpRequest, config?: ClientConfig)
2685
+ /**
2686
+ * Clone the client - returns a new instance
2687
+ */
2688
+ clone(): ObservableSanityClient
2689
+ /**
2690
+ * Returns the current client configuration
2691
+ */
2692
+ config(): InitializedClientConfig
2693
+ /**
2694
+ * Reconfigure the client. Note that this _mutates_ the current client.
2695
+ */
2696
+ config(newConfig?: Partial<ClientConfig>): this
2697
+ /**
2698
+ * Clone the client with a new (partial) configuration.
2699
+ *
2700
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
2701
+ */
2702
+ withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
2703
+ /**
2704
+ * Perform a GROQ-query against the configured dataset.
2705
+ *
2706
+ * @param query - GROQ-query to perform
2160
2707
  */
2161
2708
  fetch<
2162
2709
  R = Any,
@@ -2220,7 +2767,9 @@ export declare class ObservableSanityClient {
2220
2767
  getDocument<R extends Record<string, Any> = Record<string, Any>>(
2221
2768
  id: string,
2222
2769
  options?: {
2770
+ signal?: AbortSignal
2223
2771
  tag?: string
2772
+ releaseId?: string
2224
2773
  },
2225
2774
  ): Observable<SanityDocument<R> | undefined>
2226
2775
  /**
@@ -2403,6 +2952,90 @@ export declare class ObservableSanityClient {
2403
2952
  document: IdentifiedSanityDocumentStub<R>,
2404
2953
  options?: BaseMutationOptions,
2405
2954
  ): Observable<SanityDocument<R>>
2955
+ /**
2956
+ * @public
2957
+ *
2958
+ * Creates a new version of a published document.
2959
+ *
2960
+ * @remarks
2961
+ * * Requires a document with a `_type` property.
2962
+ * * Creating a version with no `releaseId` will create a new draft version of the published document.
2963
+ * * 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`.
2964
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
2965
+ * * To create a version of an unpublished document, use the `client.create` method.
2966
+ *
2967
+ * @category Versions
2968
+ *
2969
+ * @param params - Version action parameters:
2970
+ * - `document` - The document to create as a new version (must include `_type`).
2971
+ * - `publishedId` - The ID of the published document being versioned.
2972
+ * - `releaseId` - The ID of the release to create the version for.
2973
+ * @param options - Additional action options.
2974
+ * @returns an observable that resolves to the `transactionId`.
2975
+ *
2976
+ * @example Creating a new version of a published document with a generated version ID
2977
+ * ```ts
2978
+ * client.observable.createVersion({
2979
+ * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
2980
+ * document: {_type: 'myDocument', title: 'My Document'},
2981
+ * publishedId: 'myDocument',
2982
+ * releaseId: 'myRelease',
2983
+ * })
2984
+ *
2985
+ * // The following document will be created:
2986
+ * // {
2987
+ * // _id: 'versions.myRelease.myDocument',
2988
+ * // _type: 'myDocument',
2989
+ * // title: 'My Document',
2990
+ * // }
2991
+ * ```
2992
+ *
2993
+ * @example Creating a new version of a published document with a specified version ID
2994
+ * ```ts
2995
+ * client.observable.createVersion({
2996
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
2997
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
2998
+ * })
2999
+ *
3000
+ * // The following document will be created:
3001
+ * // {
3002
+ * // _id: 'versions.myRelease.myDocument',
3003
+ * // _type: 'myDocument',
3004
+ * // title: 'My Document',
3005
+ * // }
3006
+ * ```
3007
+ *
3008
+ * @example Creating a new draft version of a published document
3009
+ * ```ts
3010
+ * client.observable.createVersion({
3011
+ * document: {_type: 'myDocument', title: 'My Document'},
3012
+ * publishedId: 'myDocument',
3013
+ * })
3014
+ *
3015
+ * // The following document will be created:
3016
+ * // {
3017
+ * // _id: 'drafts.myDocument',
3018
+ * // _type: 'myDocument',
3019
+ * // title: 'My Document',
3020
+ * // }
3021
+ * ```
3022
+ */
3023
+ createVersion<R extends Record<string, Any>>(
3024
+ args: {
3025
+ document: SanityDocumentStub<R>
3026
+ publishedId: string
3027
+ releaseId?: string
3028
+ },
3029
+ options?: BaseActionOptions,
3030
+ ): Observable<SingleActionResult | MultipleActionResult>
3031
+ createVersion<R extends Record<string, Any>>(
3032
+ args: {
3033
+ document: IdentifiedSanityDocumentStub<R>
3034
+ publishedId?: string
3035
+ releaseId?: string
3036
+ },
3037
+ options?: BaseActionOptions,
3038
+ ): Observable<SingleActionResult | MultipleActionResult>
2406
3039
  /**
2407
3040
  * Deletes a document with the given document ID.
2408
3041
  * Returns an observable that resolves to the deleted document.
@@ -2507,6 +3140,157 @@ export declare class ObservableSanityClient {
2507
3140
  selection: MutationSelection,
2508
3141
  options?: BaseMutationOptions,
2509
3142
  ): Observable<SanityDocument<R>>
3143
+ /**
3144
+ * @public
3145
+ *
3146
+ * Deletes the draft or release version of a document.
3147
+ *
3148
+ * @remarks
3149
+ * * Discarding a version with no `releaseId` will discard the draft version of the published document.
3150
+ * * If the draft or release version does not exist, any error will throw.
3151
+ *
3152
+ * @param params - Version action parameters:
3153
+ * - `releaseId` - The ID of the release to discard the document from.
3154
+ * - `publishedId` - The published ID of the document to discard.
3155
+ * @param purge - if `true` the document history is also discarded.
3156
+ * @param options - Additional action options.
3157
+ * @returns an observable that resolves to the `transactionId`.
3158
+ *
3159
+ * @example Discarding a release version of a document
3160
+ * ```ts
3161
+ * client.observable.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
3162
+ * // The document with the ID `versions.myRelease.myDocument` will be discarded.
3163
+ * ```
3164
+ *
3165
+ * @example Discarding a draft version of a document
3166
+ * ```ts
3167
+ * client.observable.discardVersion({publishedId: 'myDocument'})
3168
+ * // The document with the ID `drafts.myDocument` will be discarded.
3169
+ * ```
3170
+ */
3171
+ discardVersion(
3172
+ {
3173
+ releaseId,
3174
+ publishedId,
3175
+ }: {
3176
+ releaseId?: string
3177
+ publishedId: string
3178
+ },
3179
+ purge?: boolean,
3180
+ options?: BaseActionOptions,
3181
+ ): Observable<SingleActionResult | MultipleActionResult>
3182
+ /**
3183
+ * @public
3184
+ *
3185
+ * Replaces an existing version document.
3186
+ *
3187
+ * @remarks
3188
+ * * Requires a document with a `_type` property.
3189
+ * * 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`.
3190
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
3191
+ * * Replacing a version with no `releaseId` will replace the draft version of the published document.
3192
+ * * At least one of the **version** or **published** documents must exist.
3193
+ *
3194
+ * @param params - Version action parameters:
3195
+ * - `document` - The new document to replace the version with.
3196
+ * - `releaseId` - The ID of the release where the document version is replaced.
3197
+ * - `publishedId` - The ID of the published document to replace.
3198
+ * @param options - Additional action options.
3199
+ * @returns an observable that resolves to the `transactionId`.
3200
+ *
3201
+ * @example Replacing a release version of a published document with a generated version ID
3202
+ * ```ts
3203
+ * client.observable.replaceVersion({
3204
+ * document: {_type: 'myDocument', title: 'My Document'},
3205
+ * publishedId: 'myDocument',
3206
+ * releaseId: 'myRelease',
3207
+ * })
3208
+ *
3209
+ * // The following document will be patched:
3210
+ * // {
3211
+ * // _id: 'versions.myRelease.myDocument',
3212
+ * // _type: 'myDocument',
3213
+ * // title: 'My Document',
3214
+ * // }
3215
+ * ```
3216
+ *
3217
+ * @example Replacing a release version of a published document with a specified version ID
3218
+ * ```ts
3219
+ * client.observable.replaceVersion({
3220
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
3221
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
3222
+ * })
3223
+ *
3224
+ * // The following document will be patched:
3225
+ * // {
3226
+ * // _id: 'versions.myRelease.myDocument',
3227
+ * // _type: 'myDocument',
3228
+ * // title: 'My Document',
3229
+ * // }
3230
+ * ```
3231
+ *
3232
+ * @example Replacing a draft version of a published document
3233
+ * ```ts
3234
+ * client.observable.replaceVersion({
3235
+ * document: {_type: 'myDocument', title: 'My Document'},
3236
+ * publishedId: 'myDocument',
3237
+ * })
3238
+ *
3239
+ * // The following document will be patched:
3240
+ * // {
3241
+ * // _id: 'drafts.myDocument',
3242
+ * // _type: 'myDocument',
3243
+ * // title: 'My Document',
3244
+ * // }
3245
+ * ```
3246
+ */
3247
+ replaceVersion<R extends Record<string, Any>>(
3248
+ args: {
3249
+ document: SanityDocumentStub<R>
3250
+ publishedId: string
3251
+ releaseId?: string
3252
+ },
3253
+ options?: BaseActionOptions,
3254
+ ): Observable<SingleActionResult | MultipleActionResult>
3255
+ replaceVersion<R extends Record<string, Any>>(
3256
+ args: {
3257
+ document: IdentifiedSanityDocumentStub<R>
3258
+ publishedId?: string
3259
+ releaseId?: string
3260
+ },
3261
+ options?: BaseActionOptions,
3262
+ ): Observable<SingleActionResult | MultipleActionResult>
3263
+ /**
3264
+ * @public
3265
+ *
3266
+ * Used to indicate when a document within a release should be unpublished when
3267
+ * the release is run.
3268
+ *
3269
+ * @remarks
3270
+ * * If the published document does not exist, an error will be thrown.
3271
+ *
3272
+ * @param params - Version action parameters:
3273
+ * - `releaseId` - The ID of the release to unpublish the document from.
3274
+ * - `publishedId` - The published ID of the document to unpublish.
3275
+ * @param options - Additional action options.
3276
+ * @returns an observable that resolves to the `transactionId`.
3277
+ *
3278
+ * @example Unpublishing a release version of a published document
3279
+ * ```ts
3280
+ * client.observable.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
3281
+ * // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
3282
+ * ```
3283
+ */
3284
+ unpublishVersion(
3285
+ {
3286
+ releaseId,
3287
+ publishedId,
3288
+ }: {
3289
+ releaseId: string
3290
+ publishedId: string
3291
+ },
3292
+ options?: BaseActionOptions,
3293
+ ): Observable<SingleActionResult | MultipleActionResult>
2510
3294
  /**
2511
3295
  * Perform mutation operations against the configured dataset
2512
3296
  * Returns an observable that resolves to the first mutated document.
@@ -2708,6 +3492,9 @@ export declare type OpenEvent = {
2708
3492
  type: 'open'
2709
3493
  }
2710
3494
 
3495
+ /** @internal */
3496
+ export declare type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>
3497
+
2711
3498
  /** @public */
2712
3499
  export declare class Patch extends BasePatch {
2713
3500
  #private
@@ -2757,9 +3544,45 @@ export declare class Patch extends BasePatch {
2757
3544
  /** @public */
2758
3545
  export declare type PatchBuilder = (patch: Patch) => Patch
2759
3546
 
3547
+ /** @beta */
3548
+ export declare type PatchDocument<T extends Record<string, Any> = Record<string, Any>> =
3549
+ | PatchDocumentSync<T>
3550
+ | PatchDocumentAsync<T>
3551
+
3552
+ /** @beta */
3553
+ declare type PatchDocumentAsync<T extends Record<string, Any> = Record<string, Any>> = (
3554
+ | PatchExistingDocumentRequest
3555
+ | PatchTargetDocumentRequest<T>
3556
+ ) &
3557
+ PatchRequestBase &
3558
+ AgentActionAsync
3559
+
3560
+ /** @beta */
3561
+ declare type PatchDocumentSync<T extends Record<string, Any> = Record<string, Any>> = (
3562
+ | PatchExistingDocumentRequest
3563
+ | PatchTargetDocumentRequest<T>
3564
+ ) &
3565
+ PatchRequestBase &
3566
+ AgentActionSync
3567
+
3568
+ /**
3569
+ * Patches an existing document
3570
+ * @beta
3571
+ */
3572
+ declare interface PatchExistingDocumentRequest {
3573
+ /**
3574
+ * @see #AgentActionSchema.forcePublishedWrite
3575
+ */
3576
+ documentId: string
3577
+ targetDocument?: never
3578
+ }
3579
+
2760
3580
  /** @internal */
2761
3581
  export declare type PatchMutationOperation = PatchOperations & MutationSelection
2762
3582
 
3583
+ /** @beta */
3584
+ export declare type PatchOperation = 'set' | 'append' | 'mixed' | 'unset'
3585
+
2763
3586
  /** @internal */
2764
3587
  export declare interface PatchOperations {
2765
3588
  set?: {
@@ -2782,9 +3605,80 @@ export declare interface PatchOperations {
2782
3605
  ifRevisionID?: string
2783
3606
  }
2784
3607
 
3608
+ /** @beta */
3609
+ declare interface PatchRequestBase extends AgentActionSchema {
3610
+ /**
3611
+ * Target defines which parts of the document will be affected by the instruction.
3612
+ * It can be an array, so multiple parts of the document can be separately configured in detail.
3613
+ *
3614
+ * Omitting target implies that the document itself is the root.
3615
+ *
3616
+ * Notes:
3617
+ * - instruction can only affect fields up to `maxPathDepth`
3618
+ * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
3619
+ * It is therefore an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
3620
+ *
3621
+ * @see AgentActionRequestBase#conditionalPaths
3622
+ */
3623
+ target: PatchTarget | PatchTarget[]
3624
+ }
3625
+
2785
3626
  /** @internal */
2786
3627
  export declare type PatchSelection = string | string[] | MutationSelection
2787
3628
 
3629
+ /** @beta */
3630
+ export declare type PatchTarget = {
3631
+ /**
3632
+ * Determines how the target path will be patched.
3633
+ *
3634
+ * ### Operation types
3635
+ * - `'set'` – an *overwriting* operation: sets the full field value for primitive targets, and merges the provided value with existing values for objects
3636
+ * - `'append'`:
3637
+ * – array fields: appends new items to the end of the array,
3638
+ * - string fields: '"existing content" "new content"'
3639
+ * - text fields: '"existing content"\\n"new content"'
3640
+ * - number fields: existing + new
3641
+ * - other field types not mentioned will set instead (dates, url)
3642
+ * - `'mixed'` – sets non-array fields, and appends to array fields
3643
+ * - `'unset'` – removes whatever value is on the target path
3644
+ *
3645
+ * All operations except unset requires a `value`.
3646
+ *
3647
+ * #### Appending in the middle of arrays
3648
+ * To append to an array, use the 'append' operation, and provide an array value with one or more array items.
3649
+ *
3650
+ * `target: {path: ['array'], operation: 'append', value: [{_type: 'item' _key: 'a'}]}` will append the items in the value to the existing array.
3651
+ *
3652
+ * To insert in the middle of the array, use `target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append', value: [{_type: 'item' _key: 'a'}]}`.
3653
+ * Here, `{_type: 'item' _key: 'a'}` will be appended after the array item with key `'appendAfterKey'`
3654
+ *
3655
+ * It is optional to provide a _key for inserted array items; if one isn't provided, it will be generated.
3656
+ */
3657
+ operation: PatchOperation
3658
+ path: AgentActionPathSegment | AgentActionPath
3659
+ } & (
3660
+ | {
3661
+ operation: 'unset'
3662
+ value?: never
3663
+ }
3664
+ | {
3665
+ operation: Exclude<PatchOperation, 'unset'>
3666
+ value: AnyNonNullable
3667
+ }
3668
+ )
3669
+
3670
+ /**
3671
+ * Create a new document, then patch it
3672
+ * @beta
3673
+ */
3674
+ declare interface PatchTargetDocumentRequest<T extends Record<string, Any> = Record<string, Any>> {
3675
+ /**
3676
+ * @see #AgentActionSchema.forcePublishedWrite
3677
+ */
3678
+ targetDocument: GenerateTargetDocument<T>
3679
+ documentId?: never
3680
+ }
3681
+
2788
3682
  /** @public */
2789
3683
  declare interface ProgressEvent_2 {
2790
3684
  type: 'progress'
@@ -2816,6 +3710,131 @@ export declare class ProjectsClient {
2816
3710
  getById(projectId: string): Promise<SanityProject>
2817
3711
  }
2818
3712
 
3713
+ /**
3714
+ * @beta
3715
+ */
3716
+ declare interface PromptJsonResponse<T extends Record<string, Any> = Record<string, Any>> {
3717
+ /**
3718
+ *
3719
+ * When true, the response body will be json according to the instruction.
3720
+ * When false, the response is the raw text response to the instruction.
3721
+ *
3722
+ * Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
3723
+ */
3724
+ format: 'json'
3725
+ }
3726
+
3727
+ /** @beta */
3728
+ export declare type PromptRequest<T extends Record<string, Any> = Record<string, Any>> = (
3729
+ | PromptTextResponse
3730
+ | PromptJsonResponse<T>
3731
+ ) &
3732
+ PromptRequestBase
3733
+
3734
+ /** @beta */
3735
+ declare interface PromptRequestBase {
3736
+ /**
3737
+ * Instruct the LLM how it should generate content. Be as specific and detailed as needed.
3738
+ *
3739
+ * The LLM only has access to information in the instruction, plus the target schema.
3740
+ *
3741
+ * String template with support for $variable from `instructionParams`.
3742
+ * */
3743
+ instruction: string
3744
+ /**
3745
+ * param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable"
3746
+ *
3747
+ * ### Examples
3748
+ *
3749
+ * #### Constant
3750
+ *
3751
+ * ##### Shorthand
3752
+ * ```ts
3753
+ * client.agent.action.prompt({
3754
+ * instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it',
3755
+ * instructionParams: {
3756
+ * topic: 'Grapefruit'
3757
+ * },
3758
+ * })
3759
+ * ```
3760
+ * ##### Object-form
3761
+ *
3762
+ * ```ts
3763
+ * client.agent.action.prompt({
3764
+ * instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it.',
3765
+ * instructionParams: {
3766
+ * topic: {
3767
+ * type: 'constant',
3768
+ * value: 'Grapefruit'
3769
+ * },
3770
+ * },
3771
+ * })
3772
+ * ```
3773
+ * #### Field
3774
+ * ```ts
3775
+ * client.agent.action.prompt({
3776
+ * instruction: 'Give the following field value:\n $pte \n ---\nGenerate keywords.',
3777
+ * instructionParams: {
3778
+ * pte: {
3779
+ * type: 'field',
3780
+ * path: ['pteField'],
3781
+ * documentId: 'someSanityDocId'
3782
+ * },
3783
+ * },
3784
+ * })
3785
+ * ```
3786
+ * #### Document
3787
+ * ```ts
3788
+ * client.agent.action.prompt({
3789
+ * json: true,
3790
+ * instruction: 'Given the following document:$document\nCreate a JSON string[] array with keywords describing it.',
3791
+ * instructionParams: {
3792
+ * document: {
3793
+ * type: 'document',
3794
+ * documentId: 'someSanityDocId'
3795
+ * },
3796
+ * },
3797
+ * })
3798
+ * ```
3799
+ *
3800
+ * #### GROQ
3801
+ * ```ts
3802
+ * client.agent.action.prompt({
3803
+ * instruction: 'Return the best title amongst these: $titles.',
3804
+ * instructionParams: {
3805
+ * titles: {
3806
+ * type: 'groq',
3807
+ * query: '* [_type==$type].title',
3808
+ * params: {type: 'article'}
3809
+ * },
3810
+ * },
3811
+ * })
3812
+ * ```
3813
+ * */
3814
+ instructionParams?: AgentActionParams<{
3815
+ docIdRequired: true
3816
+ }>
3817
+ /**
3818
+ * Controls how much variance the instructions will run with.
3819
+ *
3820
+ * Value must be in the range [0, 1] (inclusive).
3821
+ *
3822
+ * Default: 0.3
3823
+ */
3824
+ temperature?: number
3825
+ }
3826
+
3827
+ declare interface PromptTextResponse {
3828
+ /**
3829
+ *
3830
+ * When true, the response body will be json according to the instruction.
3831
+ * When false, the response is the raw text response to the instruction.
3832
+ *
3833
+ * Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
3834
+ */
3835
+ format?: 'text'
3836
+ }
3837
+
2819
3838
  /**
2820
3839
  * Publishes a draft document.
2821
3840
  * If a published version of the document already exists this is replaced by the current draft document.
@@ -2845,11 +3864,22 @@ export declare type PublishAction = {
2845
3864
  ifPublishedRevisionId?: string
2846
3865
  }
2847
3866
 
3867
+ /**
3868
+ * Publishes all documents in a release at once.
3869
+ *
3870
+ * @public
3871
+ */
3872
+ export declare interface PublishReleaseAction {
3873
+ actionType: 'sanity.action.release.publish'
3874
+ releaseId: string
3875
+ }
3876
+
2848
3877
  /** @public */
2849
3878
  export declare type QueryOptions =
2850
3879
  | FilteredResponseQueryOptions
2851
3880
  | UnfilteredResponseQueryOptions
2852
3881
  | UnfilteredResponseWithoutQuery
3882
+ | EmulatedResponseQueryOptions
2853
3883
 
2854
3884
  /** @public */
2855
3885
  export declare interface QueryParams {
@@ -2892,68 +3922,441 @@ export declare interface QueryParams {
2892
3922
  cacheMode?: never
2893
3923
  }
2894
3924
 
2895
- /**
2896
- * This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
2897
- * @public
2898
- */
2899
- export declare type QueryWithoutParams = Record<string, never> | undefined
2900
-
2901
- /** @public */
2902
- export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
2903
-
2904
- /** @public */
2905
- export declare interface RawQueryResponse<R> {
2906
- query: string
2907
- ms: number
2908
- result: R
2909
- resultSourceMap?: ContentSourceMap
2910
- /** Requires `apiVersion` to be `2021-03-25` or later. */
2911
- syncTags?: SyncTag[]
2912
- }
3925
+ /**
3926
+ * Returned from the Content Lake API when a query is malformed, usually with a start
3927
+ * and end column to indicate where the error occurred, but not always. Can we used to
3928
+ * provide a more structured error message to the user.
3929
+ *
3930
+ * This will be located under the response `error` property.
3931
+ *
3932
+ * @public
3933
+ */
3934
+ export declare interface QueryParseError {
3935
+ type: 'queryParseError'
3936
+ description: string
3937
+ start?: number
3938
+ end?: number
3939
+ query?: string
3940
+ }
3941
+
3942
+ /**
3943
+ * This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
3944
+ * @public
3945
+ */
3946
+ export declare type QueryWithoutParams = Record<string, never> | undefined
3947
+
3948
+ /** @public */
3949
+ export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
3950
+
3951
+ /** @public */
3952
+ export declare interface RawQueryResponse<R> {
3953
+ query: string
3954
+ ms: number
3955
+ result: R
3956
+ resultSourceMap?: ContentSourceMap
3957
+ /** Requires `apiVersion` to be `2021-03-25` or later. */
3958
+ syncTags?: SyncTag[]
3959
+ }
3960
+
3961
+ /** @internal */
3962
+ export declare interface RawRequestOptions {
3963
+ url?: string
3964
+ uri?: string
3965
+ method?: string
3966
+ token?: string
3967
+ json?: boolean
3968
+ tag?: string
3969
+ useGlobalApi?: boolean
3970
+ withCredentials?: boolean
3971
+ query?: {
3972
+ [key: string]: string | string[]
3973
+ }
3974
+ headers?: {
3975
+ [key: string]: string
3976
+ }
3977
+ timeout?: number
3978
+ proxy?: string
3979
+ body?: Any
3980
+ maxRedirects?: number
3981
+ signal?: AbortSignal
3982
+ }
3983
+
3984
+ /**
3985
+ * The listener has been disconnected, and a reconnect attempt is scheduled.
3986
+ *
3987
+ * @public
3988
+ */
3989
+ export declare type ReconnectEvent = {
3990
+ type: 'reconnect'
3991
+ }
3992
+
3993
+ /** @public */
3994
+ export declare type ReleaseAction =
3995
+ | CreateReleaseAction
3996
+ | EditReleaseAction
3997
+ | PublishReleaseAction
3998
+ | ArchiveReleaseAction
3999
+ | UnarchiveReleaseAction
4000
+ | ScheduleReleaseAction
4001
+ | UnscheduleReleaseAction
4002
+ | DeleteReleaseAction
4003
+
4004
+ /** @internal */
4005
+ export declare interface ReleaseDocument extends SanityDocument {
4006
+ /**
4007
+ * typically
4008
+ * `_.releases.<name>`
4009
+ */
4010
+ _id: string
4011
+ /**
4012
+ * where a release has _id `_.releases.foo`, the name is `foo`
4013
+ */
4014
+ name: string
4015
+ _type: 'system.release'
4016
+ _createdAt: string
4017
+ _updatedAt: string
4018
+ _rev: string
4019
+ state: ReleaseState
4020
+ error?: {
4021
+ message: string
4022
+ }
4023
+ finalDocumentStates?: {
4024
+ /** Document ID */
4025
+ id: string
4026
+ }[]
4027
+ /**
4028
+ * If defined, it takes precedence over the intendedPublishAt, the state should be 'scheduled'
4029
+ */
4030
+ publishAt?: string
4031
+ /**
4032
+ * If defined, it provides the time the release was actually published
4033
+ */
4034
+ publishedAt?: string
4035
+ metadata: {
4036
+ title?: string
4037
+ description?: string
4038
+ intendedPublishAt?: string
4039
+ releaseType: ReleaseType
4040
+ }
4041
+ }
4042
+
4043
+ /**
4044
+ * @public
4045
+ * @deprecated – The `r`-prefix is not required, use `string` instead
4046
+ */
4047
+ export declare type ReleaseId = `r${string}`
4048
+
4049
+ /** @public */
4050
+ declare class ReleasesClient {
4051
+ #private
4052
+ constructor(client: SanityClient, httpRequest: HttpRequest)
4053
+ /**
4054
+ * @public
4055
+ *
4056
+ * Retrieve a release by id.
4057
+ *
4058
+ * @category Releases
4059
+ *
4060
+ * @param params - Release action parameters:
4061
+ * - `releaseId` - The id of the release to retrieve.
4062
+ * @param options - Additional query options including abort signal and query tag.
4063
+ * @returns A promise that resolves to the release document {@link ReleaseDocument}.
4064
+ *
4065
+ * @example Retrieving a release by id
4066
+ * ```ts
4067
+ * const release = await client.releases.get({releaseId: 'my-release'})
4068
+ * console.log(release)
4069
+ * // {
4070
+ * // _id: '_.releases.my-release',
4071
+ * // name: 'my-release'
4072
+ * // _type: 'system.release',
4073
+ * // metadata: {releaseType: 'asap'},
4074
+ * // _createdAt: '2021-01-01T00:00:00.000Z',
4075
+ * // ...
4076
+ * // }
4077
+ * ```
4078
+ */
4079
+ get(
4080
+ {
4081
+ releaseId,
4082
+ }: {
4083
+ releaseId: string
4084
+ },
4085
+ options?: {
4086
+ signal?: AbortSignal
4087
+ tag?: string
4088
+ },
4089
+ ): Promise<ReleaseDocument | undefined>
4090
+ /**
4091
+ * @public
4092
+ *
4093
+ * Creates a new release under the given id, with metadata.
4094
+ *
4095
+ * @remarks
4096
+ * * If no releaseId is provided, a release id will be generated.
4097
+ * * If no metadata is provided, then an `undecided` releaseType will be used.
4098
+ *
4099
+ * @category Releases
4100
+ *
4101
+ * @param params - Release action parameters:
4102
+ * - `releaseId` - The id of the release to create.
4103
+ * - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
4104
+ * @param options - Additional action options.
4105
+ * @returns A promise that resolves to the `transactionId` and the release id and metadata.
4106
+ *
4107
+ * @example Creating a release with a custom id and metadata
4108
+ * ```ts
4109
+ * const releaseId = 'my-release'
4110
+ * const releaseMetadata: ReleaseDocument['metadata'] = {
4111
+ * releaseType: 'asap',
4112
+ * }
4113
+ *
4114
+ * const result =
4115
+ * await client.releases.create({releaseId, metadata: releaseMetadata})
4116
+ * console.log(result)
4117
+ * // {
4118
+ * // transactionId: 'transaction-id',
4119
+ * // releaseId: 'my-release',
4120
+ * // metadata: {releaseType: 'asap'},
4121
+ * // }
4122
+ * ```
4123
+ *
4124
+ * @example Creating a release with generated id and metadata
4125
+ * ```ts
4126
+ * const {metadata} = await client.releases.create()
4127
+ * console.log(metadata.releaseType) // 'undecided'
4128
+ * ```
4129
+ *
4130
+ * @example Creating a release with a custom transaction id
4131
+ * ```ts
4132
+ * const {transactionId, metadata} = await client.releases.create({transactionId: 'my-transaction-id'})
4133
+ * console.log(metadata.releaseType) // 'undecided'
4134
+ * console.log(transactionId) // 'my-transaction-id'
4135
+ * ```
4136
+ */
4137
+ create(options: BaseActionOptions): Promise<
4138
+ SingleActionResult & {
4139
+ releaseId: string
4140
+ metadata: ReleaseDocument['metadata']
4141
+ }
4142
+ >
4143
+ create(
4144
+ release: {
4145
+ releaseId?: string
4146
+ metadata?: Partial<ReleaseDocument['metadata']>
4147
+ },
4148
+ options?: BaseActionOptions,
4149
+ ): Promise<
4150
+ SingleActionResult & {
4151
+ releaseId: string
4152
+ metadata: ReleaseDocument['metadata']
4153
+ }
4154
+ >
4155
+ /**
4156
+ * @public
4157
+ *
4158
+ * Edits an existing release, updating the metadata.
4159
+ *
4160
+ * @category Releases
4161
+ *
4162
+ * @param params - Release action parameters:
4163
+ * - `releaseId` - The id of the release to edit.
4164
+ * - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
4165
+ * @param options - Additional action options.
4166
+ * @returns A promise that resolves to the `transactionId`.
4167
+ */
4168
+ edit(
4169
+ {
4170
+ releaseId,
4171
+ patch,
4172
+ }: {
4173
+ releaseId: string
4174
+ patch: PatchOperations
4175
+ },
4176
+ options?: BaseActionOptions,
4177
+ ): Promise<SingleActionResult>
4178
+ /**
4179
+ * @public
4180
+ *
4181
+ * Publishes all documents in a release at once. For larger releases the effect of the publish
4182
+ * will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
4183
+ * documents and creation of the corresponding published documents with the new content may
4184
+ * take some time.
4185
+ *
4186
+ * During this period both the source and target documents are locked and cannot be
4187
+ * modified through any other means.
4188
+ *
4189
+ * @category Releases
4190
+ *
4191
+ * @param params - Release action parameters:
4192
+ * - `releaseId` - The id of the release to publish.
4193
+ * @param options - Additional action options.
4194
+ * @returns A promise that resolves to the `transactionId`.
4195
+ */
4196
+ publish(
4197
+ {
4198
+ releaseId,
4199
+ }: {
4200
+ releaseId: string
4201
+ },
4202
+ options?: BaseActionOptions,
4203
+ ): Promise<SingleActionResult>
4204
+ /**
4205
+ * @public
4206
+ *
4207
+ * An archive action removes an active release. The documents that comprise the release
4208
+ * are deleted and therefore no longer queryable.
4209
+ *
4210
+ * While the documents remain in retention the last version can still be accessed using document history endpoint.
4211
+ *
4212
+ * @category Releases
4213
+ *
4214
+ * @param params - Release action parameters:
4215
+ * - `releaseId` - The id of the release to archive.
4216
+ * @param options - Additional action options.
4217
+ * @returns A promise that resolves to the `transactionId`.
4218
+ */
4219
+ archive(
4220
+ {
4221
+ releaseId,
4222
+ }: {
4223
+ releaseId: string
4224
+ },
4225
+ options?: BaseActionOptions,
4226
+ ): Promise<SingleActionResult>
4227
+ /**
4228
+ * @public
4229
+ *
4230
+ * An unarchive action restores an archived release and all documents
4231
+ * with the content they had just prior to archiving.
4232
+ *
4233
+ * @category Releases
4234
+ *
4235
+ * @param params - Release action parameters:
4236
+ * - `releaseId` - The id of the release to unarchive.
4237
+ * @param options - Additional action options.
4238
+ * @returns A promise that resolves to the `transactionId`.
4239
+ */
4240
+ unarchive(
4241
+ {
4242
+ releaseId,
4243
+ }: {
4244
+ releaseId: string
4245
+ },
4246
+ options?: BaseActionOptions,
4247
+ ): Promise<SingleActionResult>
4248
+ /**
4249
+ * @public
4250
+ *
4251
+ * A schedule action queues a release for publishing at the given future time.
4252
+ * The release is locked such that no documents in the release can be modified and
4253
+ * no documents that it references can be deleted as this would make the publish fail.
4254
+ * At the given time, the same logic as for the publish action is triggered.
4255
+ *
4256
+ * @category Releases
4257
+ *
4258
+ * @param params - Release action parameters:
4259
+ * - `releaseId` - The id of the release to schedule.
4260
+ * - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
4261
+ * @param options - Additional action options.
4262
+ * @returns A promise that resolves to the `transactionId`.
4263
+ */
4264
+ schedule(
4265
+ {
4266
+ releaseId,
4267
+ publishAt,
4268
+ }: {
4269
+ releaseId: string
4270
+ publishAt: string
4271
+ },
4272
+ options?: BaseActionOptions,
4273
+ ): Promise<SingleActionResult>
4274
+ /**
4275
+ * @public
4276
+ *
4277
+ * An unschedule action stops a release from being published.
4278
+ * The documents in the release are considered unlocked and can be edited again.
4279
+ * This may fail if another release is scheduled to be published after this one and
4280
+ * has a reference to a document created by this one.
4281
+ *
4282
+ * @category Releases
4283
+ *
4284
+ * @param params - Release action parameters:
4285
+ * - `releaseId` - The id of the release to unschedule.
4286
+ * @param options - Additional action options.
4287
+ * @returns A promise that resolves to the `transactionId`.
4288
+ */
4289
+ unschedule(
4290
+ {
4291
+ releaseId,
4292
+ }: {
4293
+ releaseId: string
4294
+ },
4295
+ options?: BaseActionOptions,
4296
+ ): Promise<SingleActionResult>
4297
+ /**
4298
+ * @public
4299
+ *
4300
+ * A delete action removes a published or archived release.
4301
+ * The backing system document will be removed from the dataset.
4302
+ *
4303
+ * @category Releases
4304
+ *
4305
+ * @param params - Release action parameters:
4306
+ * - `releaseId` - The id of the release to delete.
4307
+ * @param options - Additional action options.
4308
+ * @returns A promise that resolves to the `transactionId`.
4309
+ */
4310
+ delete(
4311
+ {
4312
+ releaseId,
4313
+ }: {
4314
+ releaseId: string
4315
+ },
4316
+ options?: BaseActionOptions,
4317
+ ): Promise<SingleActionResult>
4318
+ /**
4319
+ * @public
4320
+ *
4321
+ * Fetch the documents in a release by release id.
4322
+ *
4323
+ * @category Releases
4324
+ *
4325
+ * @param params - Release action parameters:
4326
+ * - `releaseId` - The id of the release to fetch documents for.
4327
+ * @param options - Additional mutation options {@link BaseMutationOptions}.
4328
+ * @returns A promise that resolves to the documents in the release.
4329
+ */
4330
+ fetchDocuments(
4331
+ {
4332
+ releaseId,
4333
+ }: {
4334
+ releaseId: string
4335
+ },
4336
+ options?: BaseMutationOptions,
4337
+ ): Promise<RawQueryResponse<SanityDocument[]>>
4338
+ }
4339
+
4340
+ /** @beta */
4341
+ export declare type ReleaseState =
4342
+ | 'active'
4343
+ | 'archiving'
4344
+ | 'unarchiving'
4345
+ | 'archived'
4346
+ | 'published'
4347
+ | 'publishing'
4348
+ | 'scheduled'
4349
+ | 'scheduling'
2913
4350
 
2914
4351
  /** @internal */
2915
- export declare interface RawRequestOptions {
2916
- url?: string
2917
- uri?: string
2918
- method?: string
2919
- token?: string
2920
- json?: boolean
2921
- tag?: string
2922
- useGlobalApi?: boolean
2923
- withCredentials?: boolean
2924
- query?: {
2925
- [key: string]: string | string[]
2926
- }
2927
- headers?: {
2928
- [key: string]: string
2929
- }
2930
- timeout?: number
2931
- proxy?: string
2932
- body?: Any
2933
- maxRedirects?: number
2934
- signal?: AbortSignal
2935
- }
2936
-
2937
- /**
2938
- * The listener has been disconnected, and a reconnect attempt is scheduled.
2939
- *
2940
- * @public
2941
- */
2942
- export declare type ReconnectEvent = {
2943
- type: 'reconnect'
2944
- }
2945
-
2946
- /**
2947
- * @public
2948
- * @deprecated – The `r`-prefix is not required, use `string` instead
2949
- */
2950
- export declare type ReleaseId = `r${string}`
4352
+ export declare type ReleaseType = 'asap' | 'scheduled' | 'undecided'
2951
4353
 
2952
4354
  /**
2953
4355
  * Replaces an existing draft document.
2954
4356
  * At least one of the draft or published versions of the document must exist.
2955
4357
  *
2956
4358
  * @public
4359
+ * @deprecated Use {@link ReplaceVersionAction} instead
2957
4360
  */
2958
4361
  export declare type ReplaceDraftAction = {
2959
4362
  actionType: 'sanity.action.document.replaceDraft'
@@ -2967,6 +4370,16 @@ export declare type ReplaceDraftAction = {
2967
4370
  attributes: IdentifiedSanityDocumentStub
2968
4371
  }
2969
4372
 
4373
+ /**
4374
+ * Replace an existing version of a document.
4375
+ *
4376
+ * @public
4377
+ */
4378
+ export declare interface ReplaceVersionAction {
4379
+ actionType: 'sanity.action.document.version.replace'
4380
+ document: IdentifiedSanityDocumentStub
4381
+ }
4382
+
2970
4383
  /** @public */
2971
4384
  export declare const requester: Requester
2972
4385
 
@@ -3052,6 +4465,7 @@ export declare class SanityClient {
3052
4465
  agent: {
3053
4466
  action: AgentActionsClient
3054
4467
  }
4468
+ releases: ReleasesClient
3055
4469
  /**
3056
4470
  * Observable version of the Sanity client, with the same configuration as the promise-based one
3057
4471
  */
@@ -3148,6 +4562,7 @@ export declare class SanityClient {
3148
4562
  options?: {
3149
4563
  signal?: AbortSignal
3150
4564
  tag?: string
4565
+ releaseId?: string
3151
4566
  },
3152
4567
  ): Promise<SanityDocument<R> | undefined>
3153
4568
  /**
@@ -3331,6 +4746,90 @@ export declare class SanityClient {
3331
4746
  document: IdentifiedSanityDocumentStub<R>,
3332
4747
  options?: BaseMutationOptions,
3333
4748
  ): Promise<SanityDocument<R>>
4749
+ /**
4750
+ * @public
4751
+ *
4752
+ * Creates a new version of a published document.
4753
+ *
4754
+ * @remarks
4755
+ * * Requires a document with a `_type` property.
4756
+ * * Creating a version with no `releaseId` will create a new draft version of the published document.
4757
+ * * 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`.
4758
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
4759
+ * * To create a version of an unpublished document, use the `client.create` method.
4760
+ *
4761
+ * @category Versions
4762
+ *
4763
+ * @param params - Version action parameters:
4764
+ * - `document` - The document to create as a new version (must include `_type`).
4765
+ * - `publishedId` - The ID of the published document being versioned.
4766
+ * - `releaseId` - The ID of the release to create the version for.
4767
+ * @param options - Additional action options.
4768
+ * @returns A promise that resolves to the `transactionId`.
4769
+ *
4770
+ * @example Creating a new version of a published document with a generated version ID
4771
+ * ```ts
4772
+ * const transactionId = await client.createVersion({
4773
+ * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
4774
+ * document: {_type: 'myDocument', title: 'My Document'},
4775
+ * publishedId: 'myDocument',
4776
+ * releaseId: 'myRelease',
4777
+ * })
4778
+ *
4779
+ * // The following document will be created:
4780
+ * // {
4781
+ * // _id: 'versions.myRelease.myDocument',
4782
+ * // _type: 'myDocument',
4783
+ * // title: 'My Document',
4784
+ * // }
4785
+ * ```
4786
+ *
4787
+ * @example Creating a new version of a published document with a specified version ID
4788
+ * ```ts
4789
+ * const transactionId = await client.createVersion({
4790
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
4791
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
4792
+ * })
4793
+ *
4794
+ * // The following document will be created:
4795
+ * // {
4796
+ * // _id: 'versions.myRelease.myDocument',
4797
+ * // _type: 'myDocument',
4798
+ * // title: 'My Document',
4799
+ * // }
4800
+ * ```
4801
+ *
4802
+ * @example Creating a new draft version of a published document
4803
+ * ```ts
4804
+ * const transactionId = await client.createVersion({
4805
+ * document: {_type: 'myDocument', title: 'My Document'},
4806
+ * publishedId: 'myDocument',
4807
+ * })
4808
+ *
4809
+ * // The following document will be created:
4810
+ * // {
4811
+ * // _id: 'drafts.myDocument',
4812
+ * // _type: 'myDocument',
4813
+ * // title: 'My Document',
4814
+ * // }
4815
+ * ```
4816
+ */
4817
+ createVersion<R extends Record<string, Any>>(
4818
+ args: {
4819
+ document: SanityDocumentStub<R>
4820
+ publishedId: string
4821
+ releaseId?: string
4822
+ },
4823
+ options?: BaseActionOptions,
4824
+ ): Promise<SingleActionResult | MultipleActionResult>
4825
+ createVersion<R extends Record<string, Any>>(
4826
+ args: {
4827
+ document: IdentifiedSanityDocumentStub<R>
4828
+ publishedId?: string
4829
+ releaseId?: string
4830
+ },
4831
+ options?: BaseActionOptions,
4832
+ ): Promise<SingleActionResult | MultipleActionResult>
3334
4833
  /**
3335
4834
  * Deletes a document with the given document ID.
3336
4835
  * Returns a promise that resolves to the deleted document.
@@ -3435,6 +4934,157 @@ export declare class SanityClient {
3435
4934
  selection: MutationSelection,
3436
4935
  options?: BaseMutationOptions,
3437
4936
  ): Promise<SanityDocument<R>>
4937
+ /**
4938
+ * @public
4939
+ *
4940
+ * Deletes the draft or release version of a document.
4941
+ *
4942
+ * @remarks
4943
+ * * Discarding a version with no `releaseId` will discard the draft version of the published document.
4944
+ * * If the draft or release version does not exist, any error will throw.
4945
+ *
4946
+ * @param params - Version action parameters:
4947
+ * - `releaseId` - The ID of the release to discard the document from.
4948
+ * - `publishedId` - The published ID of the document to discard.
4949
+ * @param purge - if `true` the document history is also discarded.
4950
+ * @param options - Additional action options.
4951
+ * @returns a promise that resolves to the `transactionId`.
4952
+ *
4953
+ * @example Discarding a release version of a document
4954
+ * ```ts
4955
+ * client.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
4956
+ * // The document with the ID `versions.myRelease.myDocument` will be discarded.
4957
+ * ```
4958
+ *
4959
+ * @example Discarding a draft version of a document
4960
+ * ```ts
4961
+ * client.discardVersion({publishedId: 'myDocument'})
4962
+ * // The document with the ID `drafts.myDocument` will be discarded.
4963
+ * ```
4964
+ */
4965
+ discardVersion(
4966
+ {
4967
+ releaseId,
4968
+ publishedId,
4969
+ }: {
4970
+ releaseId?: string
4971
+ publishedId: string
4972
+ },
4973
+ purge?: boolean,
4974
+ options?: BaseActionOptions,
4975
+ ): Promise<SingleActionResult | MultipleActionResult>
4976
+ /**
4977
+ * @public
4978
+ *
4979
+ * Replaces an existing version document.
4980
+ *
4981
+ * @remarks
4982
+ * * Requires a document with a `_type` property.
4983
+ * * 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`.
4984
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
4985
+ * * Replacing a version with no `releaseId` will replace the draft version of the published document.
4986
+ * * At least one of the **version** or **published** documents must exist.
4987
+ *
4988
+ * @param params - Version action parameters:
4989
+ * - `document` - The new document to replace the version with.
4990
+ * - `releaseId` - The ID of the release where the document version is replaced.
4991
+ * - `publishedId` - The ID of the published document to replace.
4992
+ * @param options - Additional action options.
4993
+ * @returns a promise that resolves to the `transactionId`.
4994
+ *
4995
+ * @example Replacing a release version of a published document with a generated version ID
4996
+ * ```ts
4997
+ * await client.replaceVersion({
4998
+ * document: {_type: 'myDocument', title: 'My Document'},
4999
+ * publishedId: 'myDocument',
5000
+ * releaseId: 'myRelease',
5001
+ * })
5002
+ *
5003
+ * // The following document will be patched:
5004
+ * // {
5005
+ * // _id: 'versions.myRelease.myDocument',
5006
+ * // _type: 'myDocument',
5007
+ * // title: 'My Document',
5008
+ * // }
5009
+ * ```
5010
+ *
5011
+ * @example Replacing a release version of a published document with a specified version ID
5012
+ * ```ts
5013
+ * await client.replaceVersion({
5014
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
5015
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
5016
+ * })
5017
+ *
5018
+ * // The following document will be patched:
5019
+ * // {
5020
+ * // _id: 'versions.myRelease.myDocument',
5021
+ * // _type: 'myDocument',
5022
+ * // title: 'My Document',
5023
+ * // }
5024
+ * ```
5025
+ *
5026
+ * @example Replacing a draft version of a published document
5027
+ * ```ts
5028
+ * await client.replaceVersion({
5029
+ * document: {_type: 'myDocument', title: 'My Document'},
5030
+ * publishedId: 'myDocument',
5031
+ * })
5032
+ *
5033
+ * // The following document will be patched:
5034
+ * // {
5035
+ * // _id: 'drafts.myDocument',
5036
+ * // _type: 'myDocument',
5037
+ * // title: 'My Document',
5038
+ * // }
5039
+ * ```
5040
+ */
5041
+ replaceVersion<R extends Record<string, Any>>(
5042
+ args: {
5043
+ document: SanityDocumentStub<R>
5044
+ publishedId: string
5045
+ releaseId?: string
5046
+ },
5047
+ options?: BaseActionOptions,
5048
+ ): Promise<SingleActionResult | MultipleActionResult>
5049
+ replaceVersion<R extends Record<string, Any>>(
5050
+ args: {
5051
+ document: IdentifiedSanityDocumentStub<R>
5052
+ publishedId?: string
5053
+ releaseId?: string
5054
+ },
5055
+ options?: BaseActionOptions,
5056
+ ): Promise<SingleActionResult | MultipleActionResult>
5057
+ /**
5058
+ * @public
5059
+ *
5060
+ * Used to indicate when a document within a release should be unpublished when
5061
+ * the release is run.
5062
+ *
5063
+ * @remarks
5064
+ * * If the published document does not exist, an error will be thrown.
5065
+ *
5066
+ * @param params - Version action parameters:
5067
+ * - `releaseId` - The ID of the release to unpublish the document from.
5068
+ * - `publishedId` - The published ID of the document to unpublish.
5069
+ * @param options - Additional action options.
5070
+ * @returns a promise that resolves to the `transactionId`.
5071
+ *
5072
+ * @example Unpublishing a release version of a published document
5073
+ * ```ts
5074
+ * await client.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
5075
+ * // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
5076
+ * ```
5077
+ */
5078
+ unpublishVersion(
5079
+ {
5080
+ releaseId,
5081
+ publishedId,
5082
+ }: {
5083
+ releaseId: string
5084
+ publishedId: string
5085
+ },
5086
+ options?: BaseActionOptions,
5087
+ ): Promise<SingleActionResult | MultipleActionResult>
3438
5088
  /**
3439
5089
  * Perform mutation operations against the configured dataset
3440
5090
  * Returns a promise that resolves to the first mutated document.
@@ -3475,7 +5125,7 @@ export declare class SanityClient {
3475
5125
  * @param operations - Mutation operations to execute
3476
5126
  * @param options - Mutation options
3477
5127
  */
3478
- mutate<R extends Record<string, Any>>(
5128
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
3479
5129
  operations: Mutation<R>[] | Patch | Transaction,
3480
5130
  options: AllDocumentIdsMutationOptions,
3481
5131
  ): Promise<MultipleMutationResult>
@@ -3691,6 +5341,17 @@ export declare interface SanityUser {
3691
5341
  isCurrentUser: boolean
3692
5342
  }
3693
5343
 
5344
+ /**
5345
+ * Queues release for publishing at the given future time.
5346
+ *
5347
+ * @public
5348
+ */
5349
+ export declare interface ScheduleReleaseAction {
5350
+ actionType: 'sanity.action.release.schedule'
5351
+ releaseId: string
5352
+ publishAt: string
5353
+ }
5354
+
3694
5355
  /** @public */
3695
5356
  export declare class ServerError extends Error {
3696
5357
  response: ErrorProps['response']
@@ -3878,12 +5539,47 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
3878
5539
  declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
3879
5540
  TransformRequestBase & AgentActionSync
3880
5541
 
5542
+ /**
5543
+ *
5544
+ * ## `set` by default
5545
+ * By default, Transform will change the value of every target field in place using a set operation.
5546
+ *
5547
+ * ## Image description
5548
+ *
5549
+ * ### Targeting image fields
5550
+ * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
5551
+ * with `operation: {type: 'image-description'}`.
5552
+ *
5553
+ * Custom instructions for image description targets will be used to generate the description.
5554
+ *
5555
+ * Such targets must be a descendant field of an image object.
5556
+ *
5557
+ * For example:
5558
+ * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
5559
+ * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
5560
+ * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
5561
+ *
5562
+ * ### Targeting non-image fields
5563
+ * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
5564
+ * `sourcePath` must be an image or image asset field.
5565
+ *
5566
+ * For example:
5567
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
5568
+ * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5569
+ * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5570
+ *
5571
+ * @beta
5572
+ */
5573
+ export declare type TransformOperation = 'set' | ImageDescriptionOperation
5574
+
3881
5575
  /** @beta */
3882
5576
  declare interface TransformRequestBase extends AgentActionRequestBase {
3883
5577
  /** schemaId as reported by sanity deploy / sanity schema store */
3884
5578
  schemaId: string
3885
5579
  /**
3886
5580
  * The source document the transformation will use as input.
5581
+ *
5582
+ * @see #AgentActionSchema.forcePublishedWrite
3887
5583
  */
3888
5584
  documentId: string
3889
5585
  /**
@@ -3891,12 +5587,14 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
3891
5587
  * then it is transformed according to the instruction.
3892
5588
  *
3893
5589
  * When omitted, the source document (documentId) is also the target document.
5590
+ *
5591
+ * @see #AgentActionSchema.forcePublishedWrite
3894
5592
  */
3895
5593
  targetDocument?: TransformTargetDocument
3896
5594
  /**
3897
5595
  * Instruct the LLM how to transform the input to th output.
3898
5596
  *
3899
- * String template using $variable from instructionParams.
5597
+ * String template with support for $variable from `instructionParams`.
3900
5598
  *
3901
5599
  * Capped to 2000 characters, after variables has been injected.
3902
5600
  * */
@@ -3995,17 +5693,35 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
3995
5693
  * It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
3996
5694
  *
3997
5695
  * Default max depth for transform: 12
5696
+ *
5697
+ * ## Transforming images
5698
+ *
5699
+ * To transform an existing image, directly target an image asset path.
5700
+ *
5701
+ * For example, all the following will transform the image into the provided asset:
5702
+ * * `target: {path: ['image', 'asset'] }`
5703
+ * * `target: {path: 'image', include: ['asset'] }`
5704
+ *
5705
+ * Image transform can be combined with regular content targets:
5706
+ * * `target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]`
5707
+ *
5708
+ * Image transform can have per-path instructions, just like any other target paths:
5709
+ * * `target: [{path: ['image', 'asset'], instruction: 'Make the sky blue' }`
5710
+ *
3998
5711
  * @see AgentActionRequestBase#conditionalPaths
3999
5712
  */
4000
5713
  target?: TransformTarget | TransformTarget[]
4001
5714
  }
4002
5715
 
4003
- /** @beta */
5716
+ /**
5717
+ * @see #TransformOperation
5718
+ * @beta
5719
+ * */
4004
5720
  export declare interface TransformTarget extends AgentActionTarget {
4005
5721
  /**
4006
5722
  * Specifies a tailored instruction of this target.
4007
5723
  *
4008
- * string template using $variable from instructionParams.
5724
+ * String template with support for $variable from `instructionParams`.
4009
5725
  * */
4010
5726
  instruction?: string
4011
5727
  /**
@@ -4016,9 +5732,18 @@ export declare interface TransformTarget extends AgentActionTarget {
4016
5732
  * Fields or array items not on the include list, are implicitly excluded.
4017
5733
  */
4018
5734
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
5735
+ /**
5736
+ * Default: `set`
5737
+ * @see #TransformOperation
5738
+ */
5739
+ operation?: TransformOperation
4019
5740
  }
4020
5741
 
4021
- /** @beta */
5742
+ /**
5743
+ * @see #AgentActionSchema.forcePublishedWrite
5744
+ *
5745
+ * @beta
5746
+ */
4022
5747
  export declare type TransformTargetDocument =
4023
5748
  | {
4024
5749
  operation: 'edit'
@@ -4037,12 +5762,15 @@ export declare type TransformTargetDocument =
4037
5762
  _id: string
4038
5763
  }
4039
5764
 
4040
- /** @beta */
5765
+ /**
5766
+ * @see #TransformOperation
5767
+ * @beta
5768
+ * */
4041
5769
  export declare interface TransformTargetInclude extends AgentActionTargetInclude {
4042
5770
  /**
4043
5771
  * Specifies a tailored instruction of this target.
4044
5772
  *
4045
- * string template using $variable from instructionParams */
5773
+ * String template with support for $variable from `instructionParams`. */
4046
5774
  instruction?: string
4047
5775
  /**
4048
5776
  * By default, all children up to `target.maxPathDepth` are included.
@@ -4052,6 +5780,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
4052
5780
  * Fields or array items not on the include list, are implicitly excluded.
4053
5781
  */
4054
5782
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
5783
+ /**
5784
+ * Default: `set`
5785
+ * @see #TransformOperation
5786
+ */
5787
+ operation?: TransformOperation
4055
5788
  }
4056
5789
 
4057
5790
  /** @beta */
@@ -4084,6 +5817,7 @@ declare interface TranslateRequestBase extends AgentActionRequestBase {
4084
5817
  schemaId: string
4085
5818
  /**
4086
5819
  * The source document the transformation will use as input.
5820
+ * @see #AgentActionSchema.forcePublishedWrite
4087
5821
  */
4088
5822
  documentId: string
4089
5823
  /**
@@ -4091,6 +5825,8 @@ declare interface TranslateRequestBase extends AgentActionRequestBase {
4091
5825
  * then it is translated according to the instruction.
4092
5826
  *
4093
5827
  * When omitted, the source document (documentId) is also the target document.
5828
+ *
5829
+ * @see #AgentActionSchema.forcePublishedWrite
4094
5830
  */
4095
5831
  targetDocument?: TransformTargetDocument
4096
5832
  /**
@@ -4143,7 +5879,7 @@ declare interface TranslateRequestBase extends AgentActionRequestBase {
4143
5879
 
4144
5880
  /** @beta */
4145
5881
  export declare interface TranslateTarget extends AgentActionTarget {
4146
- /** string template using $variable from instructionParams */
5882
+ /** String template using $variable from styleGuideParams. */
4147
5883
  styleGuide?: string
4148
5884
  /**
4149
5885
  * By default, all children up to `target.maxPathDepth` are included.
@@ -4157,7 +5893,7 @@ export declare interface TranslateTarget extends AgentActionTarget {
4157
5893
 
4158
5894
  /** @beta */
4159
5895
  export declare interface TranslateTargetInclude extends AgentActionTargetInclude {
4160
- /** string template using $variable from instructionParams */
5896
+ /** String template using $variable from styleGuideParams. */
4161
5897
  styleGuide?: string
4162
5898
  /**
4163
5899
  * By default, all children up to `target.maxPathDepth` are included.
@@ -4169,6 +5905,16 @@ export declare interface TranslateTargetInclude extends AgentActionTargetInclude
4169
5905
  include?: (AgentActionPathSegment | TranslateTargetInclude)[]
4170
5906
  }
4171
5907
 
5908
+ /**
5909
+ * Unarchived an `archived` release, and restores all the release documents.
5910
+ *
5911
+ * @public
5912
+ */
5913
+ export declare interface UnarchiveReleaseAction {
5914
+ actionType: 'sanity.action.release.unarchive'
5915
+ releaseId: string
5916
+ }
5917
+
4172
5918
  /** @public */
4173
5919
  export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
4174
5920
  filterResponse: false
@@ -4210,6 +5956,28 @@ export declare type UnpublishAction = {
4210
5956
  publishedId: string
4211
5957
  }
4212
5958
 
5959
+ /**
5960
+ * Identify that a version of a document should be unpublished when
5961
+ * the release that version is contained within is published.
5962
+ *
5963
+ * @public
5964
+ */
5965
+ export declare interface UnpublishVersionAction {
5966
+ actionType: 'sanity.action.document.version.unpublish'
5967
+ versionId: string
5968
+ publishedId: string
5969
+ }
5970
+
5971
+ /**
5972
+ * Unschedules a `scheduled` release, stopping it from being published.
5973
+ *
5974
+ * @public
5975
+ */
5976
+ export declare interface UnscheduleReleaseAction {
5977
+ actionType: 'sanity.action.release.unschedule'
5978
+ releaseId: string
5979
+ }
5980
+
4213
5981
  export {unstable__adapter}
4214
5982
 
4215
5983
  export {unstable__environment}
@@ -4297,6 +6065,37 @@ export declare function validateApiPerspective(
4297
6065
  perspective: unknown,
4298
6066
  ): asserts perspective is ClientPerspective
4299
6067
 
6068
+ /** @public */
6069
+ export declare type VersionAction =
6070
+ | CreateVersionAction
6071
+ | DiscardVersionAction
6072
+ | ReplaceVersionAction
6073
+ | UnpublishVersionAction
6074
+
6075
+ /** @public */
6076
+ export declare type ViewConnectionOverride = {
6077
+ query: string
6078
+ resourceType: ViewResourceType
6079
+ resourceId: string
6080
+ }
6081
+
6082
+ /** @public */
6083
+ export declare type ViewOverride = {
6084
+ id: string
6085
+ connections: ViewConnectionOverride[]
6086
+ }
6087
+
6088
+ /** @public */
6089
+ export declare type ViewQueryOptions = Pick<
6090
+ EmulatedResponseQueryOptions,
6091
+ 'perspective' | 'resultSourceMap' | 'filterResponse'
6092
+ >
6093
+
6094
+ /** @public */
6095
+ export declare enum ViewResourceType {
6096
+ Dataset = 'dataset',
6097
+ }
6098
+
4300
6099
  /**
4301
6100
  * The listener has been established, and will start receiving events.
4302
6101
  * Note that this is also emitted upon _reconnection_.