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

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 +810 -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 +1950 -149
  29. package/dist/index.browser.d.ts +1950 -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 +1950 -149
  35. package/dist/index.d.ts +1950 -149
  36. package/dist/index.js +826 -31
  37. package/dist/index.js.map +1 -1
  38. package/dist/stega.browser.d.cts +1950 -149
  39. package/dist/stega.browser.d.ts +1950 -149
  40. package/dist/stega.d.cts +1950 -149
  41. package/dist/stega.d.ts +1950 -149
  42. package/dist/views.cjs +21 -5
  43. package/dist/views.cjs.map +1 -1
  44. package/dist/views.d.cts +54 -36
  45. package/dist/views.d.ts +54 -36
  46. package/dist/views.js +22 -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 +293 -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 +65 -15
  79. package/umd/sanityClient.js +1067 -61
  80. package/umd/sanityClient.min.js +2 -2
package/dist/stega.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {ClientConfig as ClientConfig_2} from '@sanity/client'
2
+ import type {HttpContext} from 'get-it'
2
3
  import {Observable} from 'rxjs'
3
4
  import {Requester} from 'get-it'
4
5
  import {adapter as unstable__adapter} from 'get-it'
@@ -13,14 +14,14 @@ export declare type Action =
13
14
  | DiscardAction
14
15
  | PublishAction
15
16
  | UnpublishAction
17
+ | VersionAction
18
+ | ReleaseAction
16
19
 
17
20
  /** @internal */
18
21
  export declare interface ActionError {
19
- error: {
20
- type: 'actionError'
21
- description: string
22
- items?: ActionErrorItem[]
23
- }
22
+ type: 'actionError'
23
+ description: string
24
+ items?: ActionErrorItem[]
24
25
  }
25
26
 
26
27
  /** @internal */
@@ -47,15 +48,27 @@ declare interface AgentActionAsync {
47
48
  }
48
49
 
49
50
  /** @beta */
50
- export declare type AgentActionParam =
51
+ export declare type AgentActionParam<
52
+ TParamConfig extends {
53
+ docIdRequired: boolean
54
+ } = {
55
+ docIdRequired: false
56
+ },
57
+ > =
51
58
  | string
52
59
  | ConstantAgentActionParam
53
- | FieldAgentActionParam
54
- | DocumentAgentActionParam
60
+ | FieldAgentActionParam<TParamConfig>
61
+ | DocumentAgentActionParam<TParamConfig>
55
62
  | GroqAgentActionParam
56
63
 
57
64
  /** @beta */
58
- export declare type AgentActionParams = Record<string, AgentActionParam>
65
+ export declare type AgentActionParams<
66
+ TParamConfig extends {
67
+ docIdRequired: boolean
68
+ } = {
69
+ docIdRequired: false
70
+ },
71
+ > = Record<string, AgentActionParam<TParamConfig>>
59
72
 
60
73
  /** @beta */
61
74
  export declare type AgentActionPath = AgentActionPathSegment[]
@@ -68,39 +81,7 @@ export declare type AgentActionPathSegment =
68
81
  }
69
82
 
70
83
  /** @beta */
71
- declare interface AgentActionRequestBase {
72
- /** schemaId as reported by sanity deploy / sanity schema store */
73
- schemaId: string
74
- /**
75
- * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
76
- *
77
- * By default, Generate will not output to conditional `readOnly` and `hidden` fields,
78
- * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
79
- *
80
- * `conditionalPaths` param allows setting the default conditional value for
81
- * `hidden` and `readOnly` to false,
82
- * or individually set `hidden` and `readOnly` state for individual document paths.
83
- *
84
- * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to Generate,
85
- * and cannot be changed via conditionalPaths
86
- *
87
- * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
88
- *
89
- * Consider using `hidden: () => true` in schema config, if a field should be writeable only by Generate and never
90
- * visible in the studio – then make the field visible to the Generate using `conditionalPaths`.
91
- *
92
- * @see GenerateRequestBase#target
93
- */
94
- conditionalPaths?: {
95
- defaultReadOnly?: boolean
96
- defaultHidden?: boolean
97
- paths?: {
98
- /** path here is not a relative path: it must be the full document path, regardless of `path` param used in targets */
99
- path: AgentActionPath
100
- readOnly: boolean
101
- hidden: boolean
102
- }[]
103
- }
84
+ declare interface AgentActionRequestBase extends AgentActionSchema {
104
85
  /**
105
86
  * When localeSettings is provided on the request, instruct can write to date and datetime fields.
106
87
  * Otherwise, such fields will be ignored.
@@ -141,6 +122,68 @@ declare interface AgentActionRequestBase {
141
122
  temperature?: number
142
123
  }
143
124
 
125
+ /** @beta */
126
+ declare interface AgentActionSchema {
127
+ /** schemaId as reported by sanity deploy / sanity schema store */
128
+ schemaId: string
129
+ /**
130
+ * ### forcePublishedWrite: false (default)
131
+ * By default, agent actions will never write to a published document.
132
+ *
133
+ * Instead, they will force the use of a draft ID ("drafts.some-id") instead of the published ID ("some-id"),
134
+ * even when a published ID is provided.
135
+ *
136
+ * Actions will use state from an existing draft if it exists,
137
+ * or use the published document to create a draft, if no draft exists.
138
+ *
139
+ * Successful responses contains the _id that was mutated by the action.
140
+ *
141
+ *
142
+ * ### forcePublishedWrite: true
143
+ *
144
+ * When forcePublishedWrite: true an agent action will write to the exact id provided.
145
+ * The action will also not fallback to published state for draft ids.
146
+ *
147
+ *
148
+ * ### Versioned ids (releases)
149
+ *
150
+ * When an ID on the form "versions.<release>.some-id" is provided, agent actions will
151
+ * always behave as if `forcePublishedWrite: true`.
152
+ * That is, only the exact document state of the id provided is considered and mutated.
153
+ * */
154
+ forcePublishedWrite?: boolean
155
+ /**
156
+ * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
157
+ *
158
+ * By default, Generate will not output to conditional `readOnly` and `hidden` fields,
159
+ * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
160
+ *
161
+ * `conditionalPaths` param allows setting the default conditional value for
162
+ * `hidden` and `readOnly` to false,
163
+ * or individually set `hidden` and `readOnly` state for individual document paths.
164
+ *
165
+ * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to Generate,
166
+ * and cannot be changed via conditionalPaths
167
+ *
168
+ * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
169
+ *
170
+ * Consider using `hidden: () => true` in schema config, if a field should be writeable only by Generate and never
171
+ * visible in the studio – then make the field visible to the Generate using `conditionalPaths`.
172
+ *
173
+ * @see GenerateRequestBase#target
174
+ */
175
+ conditionalPaths?: {
176
+ defaultReadOnly?: boolean
177
+ defaultHidden?: boolean
178
+ paths?: {
179
+ /** path here is not a relative path: it must be the full document path, regardless of `path` param used in targets */
180
+ path: AgentActionPath
181
+ readOnly: boolean
182
+ hidden: boolean
183
+ }[]
184
+ }
185
+ }
186
+
144
187
  /** @public */
145
188
  declare class AgentActionsClient {
146
189
  #private
@@ -184,6 +227,27 @@ declare class AgentActionsClient {
184
227
  }
185
228
  : IdentifiedSanityDocumentStub & DocumentShape
186
229
  >
230
+ /**
231
+ * Run a raw instruction and return the result either as text or json
232
+ * @param request - prompt request
233
+ */
234
+ prompt<const DocumentShape extends Record<string, Any>>(
235
+ request: PromptRequest<DocumentShape>,
236
+ ): Promise<(typeof request)['format'] extends 'json' ? DocumentShape : string>
237
+ /**
238
+ * Patch a document using a schema aware API.
239
+ * Does not use an LLM, but uses the schema to ensure paths and values matches the schema.
240
+ * @param request - instruction request
241
+ */
242
+ patch<DocumentShape extends Record<string, Any>>(
243
+ request: PatchDocument<DocumentShape>,
244
+ ): Promise<
245
+ (typeof request)['async'] extends true
246
+ ? {
247
+ _id: string
248
+ }
249
+ : IdentifiedSanityDocumentStub & DocumentShape
250
+ >
187
251
  }
188
252
 
189
253
  /** @beta */
@@ -307,6 +371,8 @@ export declare type AllDocumentsMutationOptions = BaseMutationOptions & {
307
371
  */
308
372
  export declare type Any = any
309
373
 
374
+ declare type AnyNonNullable = Exclude<any, null | undefined>
375
+
310
376
  /** @internal */
311
377
  export declare interface ApiError {
312
378
  error: string
@@ -314,6 +380,16 @@ export declare interface ApiError {
314
380
  statusCode: number
315
381
  }
316
382
 
383
+ /**
384
+ * Archives an `active` release, and deletes all the release documents.
385
+ *
386
+ * @public
387
+ */
388
+ export declare interface ArchiveReleaseAction {
389
+ actionType: 'sanity.action.release.archive'
390
+ releaseId: string
391
+ }
392
+
317
393
  /** @public */
318
394
  export declare type AssetMetadataType =
319
395
  | 'location'
@@ -610,6 +686,12 @@ export declare interface ClientConfig {
610
686
  * Optional request tag prefix for all request tags
611
687
  */
612
688
  requestTagPrefix?: string
689
+ /**
690
+ * Optional default headers to include with all requests
691
+ *
692
+ * @remarks request-specific headers will override any default headers with the same name.
693
+ */
694
+ headers?: Record<string, string>
613
695
  ignoreBrowserTokenWarning?: boolean
614
696
  withCredentials?: boolean
615
697
  allowReconfigure?: boolean
@@ -672,6 +754,7 @@ declare type ClientConfigResource =
672
754
  | {
673
755
  type: 'view'
674
756
  id: string
757
+ useEmulate?: boolean
675
758
  }
676
759
 
677
760
  /** @public */
@@ -680,7 +763,7 @@ export declare class ClientError extends Error {
680
763
  statusCode: ErrorProps['statusCode']
681
764
  responseBody: ErrorProps['responseBody']
682
765
  details: ErrorProps['details']
683
- constructor(res: Any)
766
+ constructor(res: Any, context?: HttpContext)
684
767
  }
685
768
 
686
769
  /** @public */
@@ -991,6 +1074,29 @@ export declare type CreateAction = {
991
1074
  */
992
1075
  export declare const createClient: (config: ClientConfig_2) => SanityClient
993
1076
 
1077
+ /**
1078
+ * Creates a new release under the given id, with metadata.
1079
+ *
1080
+ * @public
1081
+ */
1082
+ export declare interface CreateReleaseAction {
1083
+ actionType: 'sanity.action.release.create'
1084
+ releaseId: string
1085
+ metadata?: Partial<ReleaseDocument['metadata']>
1086
+ }
1087
+
1088
+ /**
1089
+ * Creates a new version of an existing document, attached to the release as given
1090
+ * by `document._id`
1091
+ *
1092
+ * @public
1093
+ */
1094
+ export declare interface CreateVersionAction {
1095
+ actionType: 'sanity.action.document.version.create'
1096
+ publishedId: string
1097
+ document: IdentifiedSanityDocumentStub
1098
+ }
1099
+
994
1100
  /** @public */
995
1101
  export declare interface CurrentSanityUser {
996
1102
  id: string
@@ -1086,6 +1192,16 @@ export declare type DeleteAction = {
1086
1192
  purge?: boolean
1087
1193
  }
1088
1194
 
1195
+ /**
1196
+ * Deletes a `archived` or `published` release, and all the release documents versions.
1197
+ *
1198
+ * @public
1199
+ */
1200
+ export declare interface DeleteReleaseAction {
1201
+ actionType: 'sanity.action.release.delete'
1202
+ releaseId: string
1203
+ }
1204
+
1089
1205
  /**
1090
1206
  * @deprecated use 'drafts' instead
1091
1207
  */
@@ -1096,6 +1212,7 @@ declare type DeprecatedPreviewDrafts = 'previewDrafts'
1096
1212
  * It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
1097
1213
  *
1098
1214
  * @public
1215
+ * @deprecated Use {@link DiscardVersionAction} instead
1099
1216
  */
1100
1217
  export declare type DiscardAction = {
1101
1218
  actionType: 'sanity.action.document.discard'
@@ -1109,6 +1226,17 @@ export declare type DiscardAction = {
1109
1226
  purge?: boolean
1110
1227
  }
1111
1228
 
1229
+ /**
1230
+ * Delete a version of a document.
1231
+ *
1232
+ * @public
1233
+ */
1234
+ export declare interface DiscardVersionAction {
1235
+ actionType: 'sanity.action.document.version.discard'
1236
+ versionId: string
1237
+ purge?: boolean
1238
+ }
1239
+
1112
1240
  /**
1113
1241
  * The listener has been told to explicitly disconnect.
1114
1242
  * This is a rare situation, but may occur if the API knows reconnect attempts will fail,
@@ -1135,6 +1263,23 @@ export declare type DisconnectEvent = {
1135
1263
  reason: string
1136
1264
  }
1137
1265
 
1266
+ declare type DocIdParam<
1267
+ TParamConfig extends {
1268
+ docIdRequired: boolean
1269
+ } = {
1270
+ docIdRequired: false
1271
+ },
1272
+ > = TParamConfig['docIdRequired'] extends true
1273
+ ? {
1274
+ documentId: string
1275
+ }
1276
+ : {
1277
+ /**
1278
+ * If omitted, implicitly uses the documentId of the instruction target
1279
+ */
1280
+ documentId?: string
1281
+ }
1282
+
1138
1283
  /**
1139
1284
  *
1140
1285
  * Includes a LLM-friendly version of the document in the instruction
@@ -1155,12 +1300,23 @@ export declare type DisconnectEvent = {
1155
1300
  *
1156
1301
  * @beta
1157
1302
  * */
1158
- export declare interface DocumentAgentActionParam {
1303
+ export declare type DocumentAgentActionParam<
1304
+ TParamConfig extends {
1305
+ docIdRequired: boolean
1306
+ } = {
1307
+ docIdRequired: false
1308
+ },
1309
+ > = {
1159
1310
  type: 'document'
1160
- /**
1161
- * If omitted, implicitly uses the documentId of the instruction target
1162
- */
1163
- documentId?: string
1311
+ } & DocIdParam<TParamConfig>
1312
+
1313
+ /** @internal */
1314
+ export declare type EditableReleaseDocument = Omit<
1315
+ PartialExcept<ReleaseDocument, '_id'>,
1316
+ 'metadata' | '_type'
1317
+ > & {
1318
+ _id: string
1319
+ metadata: Partial<ReleaseDocument['metadata']>
1164
1320
  }
1165
1321
 
1166
1322
  /**
@@ -1186,6 +1342,25 @@ export declare type EditAction = {
1186
1342
  patch: PatchOperations
1187
1343
  }
1188
1344
 
1345
+ /**
1346
+ * Edits an existing release, updating the metadata.
1347
+ *
1348
+ * @public
1349
+ */
1350
+ export declare interface EditReleaseAction {
1351
+ actionType: 'sanity.action.release.edit'
1352
+ releaseId: string
1353
+ patch: PatchOperations
1354
+ }
1355
+
1356
+ /** @public */
1357
+ export declare interface EmulatedResponseQueryOptions extends ResponseQueryOptions {
1358
+ useEmulate: boolean
1359
+ connections?: ViewConnectionOverride[] | undefined
1360
+ filterResponse?: false
1361
+ returnQuery?: false
1362
+ }
1363
+
1189
1364
  /**
1190
1365
  * @internal
1191
1366
  */
@@ -1247,17 +1422,19 @@ export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSo
1247
1422
  *
1248
1423
  * @beta
1249
1424
  * */
1250
- export declare interface FieldAgentActionParam {
1425
+ export declare type FieldAgentActionParam<
1426
+ TParamConfig extends {
1427
+ docIdRequired: boolean
1428
+ } = {
1429
+ docIdRequired: false
1430
+ },
1431
+ > = {
1251
1432
  type: 'field'
1252
1433
  /**
1253
1434
  * Examples: 'title', ['array', \{_key: 'arrayItemKey'\}, 'field']
1254
1435
  */
1255
1436
  path: AgentActionPathSegment | AgentActionPath
1256
- /**
1257
- * If omitted, implicitly uses the documentId of the instruction target
1258
- */
1259
- documentId?: string
1260
- }
1437
+ } & DocIdParam<TParamConfig>
1261
1438
 
1262
1439
  /** @public */
1263
1440
  export declare type FilterDefault = (props: {
@@ -1374,6 +1551,16 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
1374
1551
  returnDocuments?: true
1375
1552
  }
1376
1553
 
1554
+ /**
1555
+ * Formats a GROQ query parse error into a human-readable string.
1556
+ *
1557
+ * @param error - The error object containing details about the parse error.
1558
+ * @param tag - An optional tag to include in the error message.
1559
+ * @returns A formatted error message string.
1560
+ * @public
1561
+ */
1562
+ export declare function formatQueryParseError(error: QueryParseError, tag?: string | null): string
1563
+
1377
1564
  /** @beta */
1378
1565
  declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
1379
1566
  | GenerateExistingDocumentRequest
@@ -1387,8 +1574,11 @@ declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<str
1387
1574
  * @beta
1388
1575
  */
1389
1576
  declare interface GenerateExistingDocumentRequest {
1577
+ /**
1578
+ * @see #AgentActionSchema.forcePublishedWrite
1579
+ */
1390
1580
  documentId: string
1391
- createDocument?: never
1581
+ targetDocument?: never
1392
1582
  }
1393
1583
 
1394
1584
  /** @beta */
@@ -1408,7 +1598,7 @@ declare interface GenerateRequestBase extends AgentActionRequestBase {
1408
1598
  *
1409
1599
  * The LLM only has access to information in the instruction, plus the target schema.
1410
1600
  *
1411
- * string template using $variable
1601
+ * String template with support for $variable from `instructionParams`.
1412
1602
  * */
1413
1603
  instruction: string
1414
1604
  /**
@@ -1503,6 +1693,21 @@ declare interface GenerateRequestBase extends AgentActionRequestBase {
1503
1693
  * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
1504
1694
  * It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
1505
1695
  *
1696
+ * ## Generating images
1697
+ *
1698
+ * Generate will generate images the same was as AI Assist, for images that have been configured using
1699
+ * [AI Assist schema options](https://github.com/sanity-io/assist/tree/main/plugin#image-generation).
1700
+ *
1701
+ * To generate images _without_ changing the schema, directly target an image asset path.
1702
+ *
1703
+ * For example, all the following will generate an image into the provided asset:
1704
+ * * `target: {path: ['image', 'asset'] }`
1705
+ * * `target: {path: 'image', include: ['asset'] }`
1706
+ *
1707
+ * Image generation can be combined with regular content targets:
1708
+ * * `target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]`
1709
+ *
1710
+ * Since Generate happens in a single LLM pass, the image will be contextually related to other generated content.
1506
1711
  * @see AgentActionRequestBase#conditionalPaths
1507
1712
  */
1508
1713
  target?: GenerateTarget | GenerateTarget[]
@@ -1549,6 +1754,7 @@ export declare interface GenerateTarget extends AgentActionTarget {
1549
1754
  * @see #AgentActionTargetInclude.operation
1550
1755
  * @see #include
1551
1756
  * @see #AgentActionTargetInclude.include
1757
+ * @see #AgentActionSchema.forcePublishedWrite
1552
1758
  */
1553
1759
  operation?: GenerateOperation
1554
1760
  /**
@@ -1565,22 +1771,34 @@ export declare interface GenerateTarget extends AgentActionTarget {
1565
1771
  export declare type GenerateTargetDocument<T extends Record<string, Any> = Record<string, Any>> =
1566
1772
  | {
1567
1773
  operation: 'edit'
1774
+ /**
1775
+ * @see #AgentActionSchema.forcePublishedWrite
1776
+ */
1568
1777
  _id: string
1569
1778
  }
1570
1779
  | {
1571
1780
  operation: 'create'
1781
+ /**
1782
+ * @see #AgentActionSchema.forcePublishedWrite
1783
+ */
1572
1784
  _id?: string
1573
1785
  _type: string
1574
1786
  initialValues?: T
1575
1787
  }
1576
1788
  | {
1577
1789
  operation: 'createIfNotExists'
1790
+ /**
1791
+ * @see #AgentActionSchema.forcePublishedWrite
1792
+ */
1578
1793
  _id: string
1579
1794
  _type: string
1580
1795
  initialValues?: T
1581
1796
  }
1582
1797
  | {
1583
1798
  operation: 'createOrReplace'
1799
+ /**
1800
+ * @see #AgentActionSchema.forcePublishedWrite
1801
+ */
1584
1802
  _id: string
1585
1803
  _type: string
1586
1804
  initialValues?: T
@@ -1593,6 +1811,9 @@ export declare type GenerateTargetDocument<T extends Record<string, Any> = Recor
1593
1811
  declare interface GenerateTargetDocumentRequest<
1594
1812
  T extends Record<string, Any> = Record<string, Any>,
1595
1813
  > {
1814
+ /**
1815
+ * @see #AgentActionSchema.forcePublishedWrite
1816
+ */
1596
1817
  targetDocument: GenerateTargetDocument<T>
1597
1818
  documentId?: never
1598
1819
  }
@@ -1659,6 +1880,24 @@ export declare type IdentifiedSanityDocumentStub<
1659
1880
  _id: string
1660
1881
  } & SanityDocumentStub
1661
1882
 
1883
+ /**
1884
+ *
1885
+ * @see #TransformOperation
1886
+ * @beta
1887
+ */
1888
+ export declare interface ImageDescriptionOperation {
1889
+ type: 'image-description'
1890
+ /**
1891
+ * When omitted, parent image value will be inferred from the arget path.
1892
+ *
1893
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1894
+ * - `['image']`
1895
+ * - `['wrapper', 'mainImage']`
1896
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1897
+ */
1898
+ sourcePath?: AgentActionPath
1899
+ }
1900
+
1662
1901
  /** @public */
1663
1902
  export declare interface InitializedClientConfig extends ClientConfig {
1664
1903
  apiHost: string
@@ -1681,6 +1920,12 @@ export declare interface InitializedClientConfig extends ClientConfig {
1681
1920
  * The fully initialized stega config, can be used to check if stega is enabled
1682
1921
  */
1683
1922
  stega: InitializedStegaConfig
1923
+ /**
1924
+ * Default headers to include with all requests
1925
+ *
1926
+ * @remarks request-specific headers will override any default headers with the same name.
1927
+ */
1928
+ headers?: Record<string, string>
1684
1929
  }
1685
1930
 
1686
1931
  /**
@@ -1712,6 +1957,9 @@ export declare type InsertPatch =
1712
1957
  items: Any[]
1713
1958
  }
1714
1959
 
1960
+ /** @internal */
1961
+ export declare function isQueryParseError(error: object): error is QueryParseError
1962
+
1715
1963
  /**
1716
1964
  * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
1717
1965
  *
@@ -1952,11 +2200,9 @@ export declare type Mutation<R extends Record<string, Any> = Record<string, Any>
1952
2200
 
1953
2201
  /** @internal */
1954
2202
  export declare interface MutationError {
1955
- error: {
1956
- type: 'mutationError'
1957
- description: string
1958
- items?: MutationErrorItem[]
1959
- }
2203
+ type: 'mutationError'
2204
+ description: string
2205
+ items?: MutationErrorItem[]
1960
2206
  }
1961
2207
 
1962
2208
  /** @internal */
@@ -2297,43 +2543,344 @@ export declare class ObservableProjectsClient {
2297
2543
  }
2298
2544
 
2299
2545
  /** @public */
2300
- export declare class ObservableSanityClient {
2546
+ declare class ObservableReleasesClient {
2301
2547
  #private
2302
- assets: ObservableAssetsClient
2303
- datasets: ObservableDatasetsClient
2304
- live: LiveClient
2305
- projects: ObservableProjectsClient
2306
- users: ObservableUsersClient
2307
- agent: {
2308
- action: ObservableAgentsActionClient
2309
- }
2310
- /**
2311
- * Instance properties
2312
- */
2313
- listen: typeof _listen
2314
- constructor(httpRequest: HttpRequest, config?: ClientConfig)
2548
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
2315
2549
  /**
2316
- * Clone the client - returns a new instance
2550
+ * @public
2551
+ *
2552
+ * Retrieve a release by id.
2553
+ *
2554
+ * @category Releases
2555
+ *
2556
+ * @param params - Release action parameters:
2557
+ * - `releaseId` - The id of the release to retrieve.
2558
+ * @param options - Additional query options including abort signal and query tag.
2559
+ * @returns An observable that resolves to the release document {@link ReleaseDocument}.
2560
+ *
2561
+ * @example Retrieving a release by id
2562
+ * ```ts
2563
+ * client.observable.releases.get({releaseId: 'my-release'}).pipe(
2564
+ * tap((release) => console.log(release)),
2565
+ * // {
2566
+ * // _id: '_.releases.my-release',
2567
+ * // name: 'my-release'
2568
+ * // _type: 'system.release',
2569
+ * // metadata: {releaseType: 'asap'},
2570
+ * // _createdAt: '2021-01-01T00:00:00.000Z',
2571
+ * // ...
2572
+ * // }
2573
+ * ).subscribe()
2574
+ * ```
2317
2575
  */
2318
- clone(): ObservableSanityClient
2576
+ get(
2577
+ {
2578
+ releaseId,
2579
+ }: {
2580
+ releaseId: string
2581
+ },
2582
+ options?: {
2583
+ signal?: AbortSignal
2584
+ tag?: string
2585
+ },
2586
+ ): Observable<ReleaseDocument | undefined>
2319
2587
  /**
2320
- * Returns the current client configuration
2588
+ * @public
2589
+ *
2590
+ * Creates a new release under the given id, with metadata.
2591
+ *
2592
+ * @remarks
2593
+ * * If no releaseId is provided, a release id will be generated.
2594
+ * * If no metadata is provided, then an `undecided` releaseType will be used.
2595
+ *
2596
+ * @category Releases
2597
+ *
2598
+ * @param params - Release action parameters:
2599
+ * - `releaseId` - The id of the release to create.
2600
+ * - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
2601
+ * @param options - Additional action options.
2602
+ * @returns An observable that resolves to the `transactionId` and the release id and metadata.
2603
+ *
2604
+ * @example Creating a release with a custom id and metadata
2605
+ * ```ts
2606
+ * const releaseId = 'my-release'
2607
+ * const metadata: ReleaseDocument['metadata'] = {
2608
+ * releaseType: 'asap',
2609
+ * }
2610
+ *
2611
+ * client.observable.releases.create({releaseId, metadata}).pipe(
2612
+ * tap(({transactionId, releaseId, metadata}) => console.log(transactionId, releaseId, metadata)),
2613
+ * // {
2614
+ * // transactionId: 'transaction-id',
2615
+ * // releaseId: 'my-release',
2616
+ * // metadata: {releaseType: 'asap'},
2617
+ * // }
2618
+ * ).subscribe()
2619
+ * ```
2620
+ *
2621
+ * @example Creating a release with generated id and metadata
2622
+ * ```ts
2623
+ * client.observable.releases.create().pipe(
2624
+ * tap(({metadata}) => console.log(metadata)),
2625
+ * // {
2626
+ * // metadata: {releaseType: 'undecided'},
2627
+ * // }
2628
+ * ).subscribe()
2629
+ * ```
2630
+ *
2631
+ * @example Creating a release using a custom transaction id
2632
+ * ```ts
2633
+ * client.observable.releases.create({transactionId: 'my-transaction-id'}).pipe(
2634
+ * tap(({transactionId, metadata}) => console.log(transactionId, metadata)),
2635
+ * // {
2636
+ * // transactionId: 'my-transaction-id',
2637
+ * // metadata: {releaseType: 'undecided'},
2638
+ * // }
2639
+ * ).subscribe()
2640
+ * ```
2321
2641
  */
2322
- config(): InitializedClientConfig
2642
+ create(options: BaseActionOptions): Observable<
2643
+ SingleActionResult & {
2644
+ releaseId: string
2645
+ metadata: ReleaseDocument['metadata']
2646
+ }
2647
+ >
2648
+ create(
2649
+ release: {
2650
+ releaseId?: string
2651
+ metadata?: Partial<ReleaseDocument['metadata']>
2652
+ },
2653
+ options?: BaseActionOptions,
2654
+ ): Observable<
2655
+ SingleActionResult & {
2656
+ releaseId: string
2657
+ metadata: ReleaseDocument['metadata']
2658
+ }
2659
+ >
2323
2660
  /**
2324
- * Reconfigure the client. Note that this _mutates_ the current client.
2661
+ * @public
2662
+ *
2663
+ * Edits an existing release, updating the metadata.
2664
+ *
2665
+ * @category Releases
2666
+ *
2667
+ * @param params - Release action parameters:
2668
+ * - `releaseId` - The id of the release to edit.
2669
+ * - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
2670
+ * @param options - Additional action options.
2671
+ * @returns An observable that resolves to the `transactionId`.
2325
2672
  */
2326
- config(newConfig?: Partial<ClientConfig>): this
2673
+ edit(
2674
+ {
2675
+ releaseId,
2676
+ patch,
2677
+ }: {
2678
+ releaseId: string
2679
+ patch: PatchOperations
2680
+ },
2681
+ options?: BaseActionOptions,
2682
+ ): Observable<SingleActionResult>
2327
2683
  /**
2328
- * Clone the client with a new (partial) configuration.
2684
+ * @public
2329
2685
  *
2330
- * @param newConfig - New client configuration properties, shallowly merged with existing configuration
2686
+ * Publishes all documents in a release at once. For larger releases the effect of the publish
2687
+ * will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
2688
+ * documents and creation of the corresponding published documents with the new content may
2689
+ * take some time.
2690
+ *
2691
+ * During this period both the source and target documents are locked and cannot be
2692
+ * modified through any other means.
2693
+ *
2694
+ * @category Releases
2695
+ *
2696
+ * @param params - Release action parameters:
2697
+ * - `releaseId` - The id of the release to publish.
2698
+ * @param options - Additional action options.
2699
+ * @returns An observable that resolves to the `transactionId`.
2331
2700
  */
2332
- withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
2701
+ publish(
2702
+ {
2703
+ releaseId,
2704
+ }: {
2705
+ releaseId: string
2706
+ },
2707
+ options?: BaseActionOptions,
2708
+ ): Observable<SingleActionResult>
2333
2709
  /**
2334
- * Perform a GROQ-query against the configured dataset.
2710
+ * @public
2335
2711
  *
2336
- * @param query - GROQ-query to perform
2712
+ * An archive action removes an active release. The documents that comprise the release
2713
+ * are deleted and therefore no longer queryable.
2714
+ *
2715
+ * While the documents remain in retention the last version can still be accessed using document history endpoint.
2716
+ *
2717
+ * @category Releases
2718
+ *
2719
+ * @param params - Release action parameters:
2720
+ * - `releaseId` - The id of the release to archive.
2721
+ * @param options - Additional action options.
2722
+ * @returns An observable that resolves to the `transactionId`.
2723
+ */
2724
+ archive(
2725
+ {
2726
+ releaseId,
2727
+ }: {
2728
+ releaseId: string
2729
+ },
2730
+ options?: BaseActionOptions,
2731
+ ): Observable<SingleActionResult>
2732
+ /**
2733
+ * @public
2734
+ *
2735
+ * An unarchive action restores an archived release and all documents
2736
+ * with the content they had just prior to archiving.
2737
+ *
2738
+ * @category Releases
2739
+ *
2740
+ * @param params - Release action parameters:
2741
+ * - `releaseId` - The id of the release to unarchive.
2742
+ * @param options - Additional action options.
2743
+ * @returns An observable that resolves to the `transactionId`.
2744
+ */
2745
+ unarchive(
2746
+ {
2747
+ releaseId,
2748
+ }: {
2749
+ releaseId: string
2750
+ },
2751
+ options?: BaseActionOptions,
2752
+ ): Observable<SingleActionResult>
2753
+ /**
2754
+ * @public
2755
+ *
2756
+ * A schedule action queues a release for publishing at the given future time.
2757
+ * The release is locked such that no documents in the release can be modified and
2758
+ * no documents that it references can be deleted as this would make the publish fail.
2759
+ * At the given time, the same logic as for the publish action is triggered.
2760
+ *
2761
+ * @category Releases
2762
+ *
2763
+ * @param params - Release action parameters:
2764
+ * - `releaseId` - The id of the release to schedule.
2765
+ * - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
2766
+ * @param options - Additional action options.
2767
+ * @returns An observable that resolves to the `transactionId`.
2768
+ */
2769
+ schedule(
2770
+ {
2771
+ releaseId,
2772
+ publishAt,
2773
+ }: {
2774
+ releaseId: string
2775
+ publishAt: string
2776
+ },
2777
+ options?: BaseActionOptions,
2778
+ ): Observable<SingleActionResult>
2779
+ /**
2780
+ * @public
2781
+ *
2782
+ * An unschedule action stops a release from being published.
2783
+ * The documents in the release are considered unlocked and can be edited again.
2784
+ * This may fail if another release is scheduled to be published after this one and
2785
+ * has a reference to a document created by this one.
2786
+ *
2787
+ * @category Releases
2788
+ *
2789
+ * @param params - Release action parameters:
2790
+ * - `releaseId` - The id of the release to unschedule.
2791
+ * @param options - Additional action options.
2792
+ * @returns An observable that resolves to the `transactionId`.
2793
+ */
2794
+ unschedule(
2795
+ {
2796
+ releaseId,
2797
+ }: {
2798
+ releaseId: string
2799
+ },
2800
+ options?: BaseActionOptions,
2801
+ ): Observable<SingleActionResult>
2802
+ /**
2803
+ * @public
2804
+ *
2805
+ * A delete action removes a published or archived release.
2806
+ * The backing system document will be removed from the dataset.
2807
+ *
2808
+ * @category Releases
2809
+ *
2810
+ * @param params - Release action parameters:
2811
+ * - `releaseId` - The id of the release to delete.
2812
+ * @param options - Additional action options.
2813
+ * @returns An observable that resolves to the `transactionId`.
2814
+ */
2815
+ delete(
2816
+ {
2817
+ releaseId,
2818
+ }: {
2819
+ releaseId: string
2820
+ },
2821
+ options?: BaseActionOptions,
2822
+ ): Observable<SingleActionResult>
2823
+ /**
2824
+ * @public
2825
+ *
2826
+ * Fetch the documents in a release by release id.
2827
+ *
2828
+ * @category Releases
2829
+ *
2830
+ * @param params - Release action parameters:
2831
+ * - `releaseId` - The id of the release to fetch documents for.
2832
+ * @param options - Additional mutation options {@link BaseMutationOptions}.
2833
+ * @returns An observable that resolves to the documents in the release.
2834
+ */
2835
+ fetchDocuments(
2836
+ {
2837
+ releaseId,
2838
+ }: {
2839
+ releaseId: string
2840
+ },
2841
+ options?: BaseMutationOptions,
2842
+ ): Observable<RawQueryResponse<SanityDocument[]>>
2843
+ }
2844
+
2845
+ /** @public */
2846
+ export declare class ObservableSanityClient {
2847
+ #private
2848
+ assets: ObservableAssetsClient
2849
+ datasets: ObservableDatasetsClient
2850
+ live: LiveClient
2851
+ projects: ObservableProjectsClient
2852
+ users: ObservableUsersClient
2853
+ agent: {
2854
+ action: ObservableAgentsActionClient
2855
+ }
2856
+ releases: ObservableReleasesClient
2857
+ /**
2858
+ * Instance properties
2859
+ */
2860
+ listen: typeof _listen
2861
+ constructor(httpRequest: HttpRequest, config?: ClientConfig)
2862
+ /**
2863
+ * Clone the client - returns a new instance
2864
+ */
2865
+ clone(): ObservableSanityClient
2866
+ /**
2867
+ * Returns the current client configuration
2868
+ */
2869
+ config(): InitializedClientConfig
2870
+ /**
2871
+ * Reconfigure the client. Note that this _mutates_ the current client.
2872
+ */
2873
+ config(newConfig?: Partial<ClientConfig>): this
2874
+ /**
2875
+ * Clone the client with a new (partial) configuration.
2876
+ *
2877
+ * @param newConfig - New client configuration properties, shallowly merged with existing configuration
2878
+ */
2879
+ withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
2880
+ /**
2881
+ * Perform a GROQ-query against the configured dataset.
2882
+ *
2883
+ * @param query - GROQ-query to perform
2337
2884
  */
2338
2885
  fetch<
2339
2886
  R = Any,
@@ -2397,7 +2944,9 @@ export declare class ObservableSanityClient {
2397
2944
  getDocument<R extends Record<string, Any> = Record<string, Any>>(
2398
2945
  id: string,
2399
2946
  options?: {
2947
+ signal?: AbortSignal
2400
2948
  tag?: string
2949
+ releaseId?: string
2401
2950
  },
2402
2951
  ): Observable<SanityDocument<R> | undefined>
2403
2952
  /**
@@ -2580,6 +3129,90 @@ export declare class ObservableSanityClient {
2580
3129
  document: IdentifiedSanityDocumentStub<R>,
2581
3130
  options?: BaseMutationOptions,
2582
3131
  ): Observable<SanityDocument<R>>
3132
+ /**
3133
+ * @public
3134
+ *
3135
+ * Creates a new version of a published document.
3136
+ *
3137
+ * @remarks
3138
+ * * Requires a document with a `_type` property.
3139
+ * * Creating a version with no `releaseId` will create a new draft version of the published document.
3140
+ * * 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`.
3141
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
3142
+ * * To create a version of an unpublished document, use the `client.create` method.
3143
+ *
3144
+ * @category Versions
3145
+ *
3146
+ * @param params - Version action parameters:
3147
+ * - `document` - The document to create as a new version (must include `_type`).
3148
+ * - `publishedId` - The ID of the published document being versioned.
3149
+ * - `releaseId` - The ID of the release to create the version for.
3150
+ * @param options - Additional action options.
3151
+ * @returns an observable that resolves to the `transactionId`.
3152
+ *
3153
+ * @example Creating a new version of a published document with a generated version ID
3154
+ * ```ts
3155
+ * client.observable.createVersion({
3156
+ * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
3157
+ * document: {_type: 'myDocument', title: 'My Document'},
3158
+ * publishedId: 'myDocument',
3159
+ * releaseId: 'myRelease',
3160
+ * })
3161
+ *
3162
+ * // The following document will be created:
3163
+ * // {
3164
+ * // _id: 'versions.myRelease.myDocument',
3165
+ * // _type: 'myDocument',
3166
+ * // title: 'My Document',
3167
+ * // }
3168
+ * ```
3169
+ *
3170
+ * @example Creating a new version of a published document with a specified version ID
3171
+ * ```ts
3172
+ * client.observable.createVersion({
3173
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
3174
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
3175
+ * })
3176
+ *
3177
+ * // The following document will be created:
3178
+ * // {
3179
+ * // _id: 'versions.myRelease.myDocument',
3180
+ * // _type: 'myDocument',
3181
+ * // title: 'My Document',
3182
+ * // }
3183
+ * ```
3184
+ *
3185
+ * @example Creating a new draft version of a published document
3186
+ * ```ts
3187
+ * client.observable.createVersion({
3188
+ * document: {_type: 'myDocument', title: 'My Document'},
3189
+ * publishedId: 'myDocument',
3190
+ * })
3191
+ *
3192
+ * // The following document will be created:
3193
+ * // {
3194
+ * // _id: 'drafts.myDocument',
3195
+ * // _type: 'myDocument',
3196
+ * // title: 'My Document',
3197
+ * // }
3198
+ * ```
3199
+ */
3200
+ createVersion<R extends Record<string, Any>>(
3201
+ args: {
3202
+ document: SanityDocumentStub<R>
3203
+ publishedId: string
3204
+ releaseId?: string
3205
+ },
3206
+ options?: BaseActionOptions,
3207
+ ): Observable<SingleActionResult | MultipleActionResult>
3208
+ createVersion<R extends Record<string, Any>>(
3209
+ args: {
3210
+ document: IdentifiedSanityDocumentStub<R>
3211
+ publishedId?: string
3212
+ releaseId?: string
3213
+ },
3214
+ options?: BaseActionOptions,
3215
+ ): Observable<SingleActionResult | MultipleActionResult>
2583
3216
  /**
2584
3217
  * Deletes a document with the given document ID.
2585
3218
  * Returns an observable that resolves to the deleted document.
@@ -2684,6 +3317,157 @@ export declare class ObservableSanityClient {
2684
3317
  selection: MutationSelection,
2685
3318
  options?: BaseMutationOptions,
2686
3319
  ): Observable<SanityDocument<R>>
3320
+ /**
3321
+ * @public
3322
+ *
3323
+ * Deletes the draft or release version of a document.
3324
+ *
3325
+ * @remarks
3326
+ * * Discarding a version with no `releaseId` will discard the draft version of the published document.
3327
+ * * If the draft or release version does not exist, any error will throw.
3328
+ *
3329
+ * @param params - Version action parameters:
3330
+ * - `releaseId` - The ID of the release to discard the document from.
3331
+ * - `publishedId` - The published ID of the document to discard.
3332
+ * @param purge - if `true` the document history is also discarded.
3333
+ * @param options - Additional action options.
3334
+ * @returns an observable that resolves to the `transactionId`.
3335
+ *
3336
+ * @example Discarding a release version of a document
3337
+ * ```ts
3338
+ * client.observable.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
3339
+ * // The document with the ID `versions.myRelease.myDocument` will be discarded.
3340
+ * ```
3341
+ *
3342
+ * @example Discarding a draft version of a document
3343
+ * ```ts
3344
+ * client.observable.discardVersion({publishedId: 'myDocument'})
3345
+ * // The document with the ID `drafts.myDocument` will be discarded.
3346
+ * ```
3347
+ */
3348
+ discardVersion(
3349
+ {
3350
+ releaseId,
3351
+ publishedId,
3352
+ }: {
3353
+ releaseId?: string
3354
+ publishedId: string
3355
+ },
3356
+ purge?: boolean,
3357
+ options?: BaseActionOptions,
3358
+ ): Observable<SingleActionResult | MultipleActionResult>
3359
+ /**
3360
+ * @public
3361
+ *
3362
+ * Replaces an existing version document.
3363
+ *
3364
+ * @remarks
3365
+ * * Requires a document with a `_type` property.
3366
+ * * 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`.
3367
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
3368
+ * * Replacing a version with no `releaseId` will replace the draft version of the published document.
3369
+ * * At least one of the **version** or **published** documents must exist.
3370
+ *
3371
+ * @param params - Version action parameters:
3372
+ * - `document` - The new document to replace the version with.
3373
+ * - `releaseId` - The ID of the release where the document version is replaced.
3374
+ * - `publishedId` - The ID of the published document to replace.
3375
+ * @param options - Additional action options.
3376
+ * @returns an observable that resolves to the `transactionId`.
3377
+ *
3378
+ * @example Replacing a release version of a published document with a generated version ID
3379
+ * ```ts
3380
+ * client.observable.replaceVersion({
3381
+ * document: {_type: 'myDocument', title: 'My Document'},
3382
+ * publishedId: 'myDocument',
3383
+ * releaseId: 'myRelease',
3384
+ * })
3385
+ *
3386
+ * // The following document will be patched:
3387
+ * // {
3388
+ * // _id: 'versions.myRelease.myDocument',
3389
+ * // _type: 'myDocument',
3390
+ * // title: 'My Document',
3391
+ * // }
3392
+ * ```
3393
+ *
3394
+ * @example Replacing a release version of a published document with a specified version ID
3395
+ * ```ts
3396
+ * client.observable.replaceVersion({
3397
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
3398
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
3399
+ * })
3400
+ *
3401
+ * // The following document will be patched:
3402
+ * // {
3403
+ * // _id: 'versions.myRelease.myDocument',
3404
+ * // _type: 'myDocument',
3405
+ * // title: 'My Document',
3406
+ * // }
3407
+ * ```
3408
+ *
3409
+ * @example Replacing a draft version of a published document
3410
+ * ```ts
3411
+ * client.observable.replaceVersion({
3412
+ * document: {_type: 'myDocument', title: 'My Document'},
3413
+ * publishedId: 'myDocument',
3414
+ * })
3415
+ *
3416
+ * // The following document will be patched:
3417
+ * // {
3418
+ * // _id: 'drafts.myDocument',
3419
+ * // _type: 'myDocument',
3420
+ * // title: 'My Document',
3421
+ * // }
3422
+ * ```
3423
+ */
3424
+ replaceVersion<R extends Record<string, Any>>(
3425
+ args: {
3426
+ document: SanityDocumentStub<R>
3427
+ publishedId: string
3428
+ releaseId?: string
3429
+ },
3430
+ options?: BaseActionOptions,
3431
+ ): Observable<SingleActionResult | MultipleActionResult>
3432
+ replaceVersion<R extends Record<string, Any>>(
3433
+ args: {
3434
+ document: IdentifiedSanityDocumentStub<R>
3435
+ publishedId?: string
3436
+ releaseId?: string
3437
+ },
3438
+ options?: BaseActionOptions,
3439
+ ): Observable<SingleActionResult | MultipleActionResult>
3440
+ /**
3441
+ * @public
3442
+ *
3443
+ * Used to indicate when a document within a release should be unpublished when
3444
+ * the release is run.
3445
+ *
3446
+ * @remarks
3447
+ * * If the published document does not exist, an error will be thrown.
3448
+ *
3449
+ * @param params - Version action parameters:
3450
+ * - `releaseId` - The ID of the release to unpublish the document from.
3451
+ * - `publishedId` - The published ID of the document to unpublish.
3452
+ * @param options - Additional action options.
3453
+ * @returns an observable that resolves to the `transactionId`.
3454
+ *
3455
+ * @example Unpublishing a release version of a published document
3456
+ * ```ts
3457
+ * client.observable.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
3458
+ * // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
3459
+ * ```
3460
+ */
3461
+ unpublishVersion(
3462
+ {
3463
+ releaseId,
3464
+ publishedId,
3465
+ }: {
3466
+ releaseId: string
3467
+ publishedId: string
3468
+ },
3469
+ options?: BaseActionOptions,
3470
+ ): Observable<SingleActionResult | MultipleActionResult>
2687
3471
  /**
2688
3472
  * Perform mutation operations against the configured dataset
2689
3473
  * Returns an observable that resolves to the first mutated document.
@@ -2891,6 +3675,9 @@ export declare type OpenEvent = {
2891
3675
  type: 'open'
2892
3676
  }
2893
3677
 
3678
+ /** @internal */
3679
+ export declare type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>
3680
+
2894
3681
  /** @public */
2895
3682
  export declare class Patch extends BasePatch {
2896
3683
  #private
@@ -2940,9 +3727,45 @@ export declare class Patch extends BasePatch {
2940
3727
  /** @public */
2941
3728
  export declare type PatchBuilder = (patch: Patch) => Patch
2942
3729
 
3730
+ /** @beta */
3731
+ export declare type PatchDocument<T extends Record<string, Any> = Record<string, Any>> =
3732
+ | PatchDocumentSync<T>
3733
+ | PatchDocumentAsync<T>
3734
+
3735
+ /** @beta */
3736
+ declare type PatchDocumentAsync<T extends Record<string, Any> = Record<string, Any>> = (
3737
+ | PatchExistingDocumentRequest
3738
+ | PatchTargetDocumentRequest<T>
3739
+ ) &
3740
+ PatchRequestBase &
3741
+ AgentActionAsync
3742
+
3743
+ /** @beta */
3744
+ declare type PatchDocumentSync<T extends Record<string, Any> = Record<string, Any>> = (
3745
+ | PatchExistingDocumentRequest
3746
+ | PatchTargetDocumentRequest<T>
3747
+ ) &
3748
+ PatchRequestBase &
3749
+ AgentActionSync
3750
+
3751
+ /**
3752
+ * Patches an existing document
3753
+ * @beta
3754
+ */
3755
+ declare interface PatchExistingDocumentRequest {
3756
+ /**
3757
+ * @see #AgentActionSchema.forcePublishedWrite
3758
+ */
3759
+ documentId: string
3760
+ targetDocument?: never
3761
+ }
3762
+
2943
3763
  /** @internal */
2944
3764
  export declare type PatchMutationOperation = PatchOperations & MutationSelection
2945
3765
 
3766
+ /** @beta */
3767
+ export declare type PatchOperation = 'set' | 'append' | 'mixed' | 'unset'
3768
+
2946
3769
  /** @internal */
2947
3770
  export declare interface PatchOperations {
2948
3771
  set?: {
@@ -2965,9 +3788,80 @@ export declare interface PatchOperations {
2965
3788
  ifRevisionID?: string
2966
3789
  }
2967
3790
 
3791
+ /** @beta */
3792
+ declare interface PatchRequestBase extends AgentActionSchema {
3793
+ /**
3794
+ * Target defines which parts of the document will be affected by the instruction.
3795
+ * It can be an array, so multiple parts of the document can be separately configured in detail.
3796
+ *
3797
+ * Omitting target implies that the document itself is the root.
3798
+ *
3799
+ * Notes:
3800
+ * - instruction can only affect fields up to `maxPathDepth`
3801
+ * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
3802
+ * It is therefore an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
3803
+ *
3804
+ * @see AgentActionRequestBase#conditionalPaths
3805
+ */
3806
+ target: PatchTarget | PatchTarget[]
3807
+ }
3808
+
2968
3809
  /** @internal */
2969
3810
  export declare type PatchSelection = string | string[] | MutationSelection
2970
3811
 
3812
+ /** @beta */
3813
+ export declare type PatchTarget = {
3814
+ /**
3815
+ * Determines how the target path will be patched.
3816
+ *
3817
+ * ### Operation types
3818
+ * - `'set'` – an *overwriting* operation: sets the full field value for primitive targets, and merges the provided value with existing values for objects
3819
+ * - `'append'`:
3820
+ * – array fields: appends new items to the end of the array,
3821
+ * - string fields: '"existing content" "new content"'
3822
+ * - text fields: '"existing content"\\n"new content"'
3823
+ * - number fields: existing + new
3824
+ * - other field types not mentioned will set instead (dates, url)
3825
+ * - `'mixed'` – sets non-array fields, and appends to array fields
3826
+ * - `'unset'` – removes whatever value is on the target path
3827
+ *
3828
+ * All operations except unset requires a `value`.
3829
+ *
3830
+ * #### Appending in the middle of arrays
3831
+ * To append to an array, use the 'append' operation, and provide an array value with one or more array items.
3832
+ *
3833
+ * `target: {path: ['array'], operation: 'append', value: [{_type: 'item' _key: 'a'}]}` will append the items in the value to the existing array.
3834
+ *
3835
+ * To insert in the middle of the array, use `target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append', value: [{_type: 'item' _key: 'a'}]}`.
3836
+ * Here, `{_type: 'item' _key: 'a'}` will be appended after the array item with key `'appendAfterKey'`
3837
+ *
3838
+ * It is optional to provide a _key for inserted array items; if one isn't provided, it will be generated.
3839
+ */
3840
+ operation: PatchOperation
3841
+ path: AgentActionPathSegment | AgentActionPath
3842
+ } & (
3843
+ | {
3844
+ operation: 'unset'
3845
+ value?: never
3846
+ }
3847
+ | {
3848
+ operation: Exclude<PatchOperation, 'unset'>
3849
+ value: AnyNonNullable
3850
+ }
3851
+ )
3852
+
3853
+ /**
3854
+ * Create a new document, then patch it
3855
+ * @beta
3856
+ */
3857
+ declare interface PatchTargetDocumentRequest<T extends Record<string, Any> = Record<string, Any>> {
3858
+ /**
3859
+ * @see #AgentActionSchema.forcePublishedWrite
3860
+ */
3861
+ targetDocument: GenerateTargetDocument<T>
3862
+ documentId?: never
3863
+ }
3864
+
2971
3865
  /** @public */
2972
3866
  declare interface ProgressEvent_2 {
2973
3867
  type: 'progress'
@@ -2999,6 +3893,131 @@ export declare class ProjectsClient {
2999
3893
  getById(projectId: string): Promise<SanityProject>
3000
3894
  }
3001
3895
 
3896
+ /**
3897
+ * @beta
3898
+ */
3899
+ declare interface PromptJsonResponse<T extends Record<string, Any> = Record<string, Any>> {
3900
+ /**
3901
+ *
3902
+ * When true, the response body will be json according to the instruction.
3903
+ * When false, the response is the raw text response to the instruction.
3904
+ *
3905
+ * Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
3906
+ */
3907
+ format: 'json'
3908
+ }
3909
+
3910
+ /** @beta */
3911
+ export declare type PromptRequest<T extends Record<string, Any> = Record<string, Any>> = (
3912
+ | PromptTextResponse
3913
+ | PromptJsonResponse<T>
3914
+ ) &
3915
+ PromptRequestBase
3916
+
3917
+ /** @beta */
3918
+ declare interface PromptRequestBase {
3919
+ /**
3920
+ * Instruct the LLM how it should generate content. Be as specific and detailed as needed.
3921
+ *
3922
+ * The LLM only has access to information in the instruction, plus the target schema.
3923
+ *
3924
+ * String template with support for $variable from `instructionParams`.
3925
+ * */
3926
+ instruction: string
3927
+ /**
3928
+ * param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable"
3929
+ *
3930
+ * ### Examples
3931
+ *
3932
+ * #### Constant
3933
+ *
3934
+ * ##### Shorthand
3935
+ * ```ts
3936
+ * client.agent.action.prompt({
3937
+ * instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it',
3938
+ * instructionParams: {
3939
+ * topic: 'Grapefruit'
3940
+ * },
3941
+ * })
3942
+ * ```
3943
+ * ##### Object-form
3944
+ *
3945
+ * ```ts
3946
+ * client.agent.action.prompt({
3947
+ * instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it.',
3948
+ * instructionParams: {
3949
+ * topic: {
3950
+ * type: 'constant',
3951
+ * value: 'Grapefruit'
3952
+ * },
3953
+ * },
3954
+ * })
3955
+ * ```
3956
+ * #### Field
3957
+ * ```ts
3958
+ * client.agent.action.prompt({
3959
+ * instruction: 'Give the following field value:\n $pte \n ---\nGenerate keywords.',
3960
+ * instructionParams: {
3961
+ * pte: {
3962
+ * type: 'field',
3963
+ * path: ['pteField'],
3964
+ * documentId: 'someSanityDocId'
3965
+ * },
3966
+ * },
3967
+ * })
3968
+ * ```
3969
+ * #### Document
3970
+ * ```ts
3971
+ * client.agent.action.prompt({
3972
+ * json: true,
3973
+ * instruction: 'Given the following document:$document\nCreate a JSON string[] array with keywords describing it.',
3974
+ * instructionParams: {
3975
+ * document: {
3976
+ * type: 'document',
3977
+ * documentId: 'someSanityDocId'
3978
+ * },
3979
+ * },
3980
+ * })
3981
+ * ```
3982
+ *
3983
+ * #### GROQ
3984
+ * ```ts
3985
+ * client.agent.action.prompt({
3986
+ * instruction: 'Return the best title amongst these: $titles.',
3987
+ * instructionParams: {
3988
+ * titles: {
3989
+ * type: 'groq',
3990
+ * query: '* [_type==$type].title',
3991
+ * params: {type: 'article'}
3992
+ * },
3993
+ * },
3994
+ * })
3995
+ * ```
3996
+ * */
3997
+ instructionParams?: AgentActionParams<{
3998
+ docIdRequired: true
3999
+ }>
4000
+ /**
4001
+ * Controls how much variance the instructions will run with.
4002
+ *
4003
+ * Value must be in the range [0, 1] (inclusive).
4004
+ *
4005
+ * Default: 0.3
4006
+ */
4007
+ temperature?: number
4008
+ }
4009
+
4010
+ declare interface PromptTextResponse {
4011
+ /**
4012
+ *
4013
+ * When true, the response body will be json according to the instruction.
4014
+ * When false, the response is the raw text response to the instruction.
4015
+ *
4016
+ * Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
4017
+ */
4018
+ format?: 'text'
4019
+ }
4020
+
3002
4021
  /**
3003
4022
  * Publishes a draft document.
3004
4023
  * If a published version of the document already exists this is replaced by the current draft document.
@@ -3028,11 +4047,22 @@ export declare type PublishAction = {
3028
4047
  ifPublishedRevisionId?: string
3029
4048
  }
3030
4049
 
4050
+ /**
4051
+ * Publishes all documents in a release at once.
4052
+ *
4053
+ * @public
4054
+ */
4055
+ export declare interface PublishReleaseAction {
4056
+ actionType: 'sanity.action.release.publish'
4057
+ releaseId: string
4058
+ }
4059
+
3031
4060
  /** @public */
3032
4061
  export declare type QueryOptions =
3033
4062
  | FilteredResponseQueryOptions
3034
4063
  | UnfilteredResponseQueryOptions
3035
4064
  | UnfilteredResponseWithoutQuery
4065
+ | EmulatedResponseQueryOptions
3036
4066
 
3037
4067
  /** @public */
3038
4068
  export declare interface QueryParams {
@@ -3075,68 +4105,441 @@ export declare interface QueryParams {
3075
4105
  cacheMode?: never
3076
4106
  }
3077
4107
 
3078
- /**
3079
- * This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
3080
- * @public
3081
- */
3082
- export declare type QueryWithoutParams = Record<string, never> | undefined
3083
-
3084
- /** @public */
3085
- export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
3086
-
3087
- /** @public */
3088
- export declare interface RawQueryResponse<R> {
3089
- query: string
3090
- ms: number
3091
- result: R
3092
- resultSourceMap?: ContentSourceMap
3093
- /** Requires `apiVersion` to be `2021-03-25` or later. */
3094
- syncTags?: SyncTag[]
3095
- }
4108
+ /**
4109
+ * Returned from the Content Lake API when a query is malformed, usually with a start
4110
+ * and end column to indicate where the error occurred, but not always. Can we used to
4111
+ * provide a more structured error message to the user.
4112
+ *
4113
+ * This will be located under the response `error` property.
4114
+ *
4115
+ * @public
4116
+ */
4117
+ export declare interface QueryParseError {
4118
+ type: 'queryParseError'
4119
+ description: string
4120
+ start?: number
4121
+ end?: number
4122
+ query?: string
4123
+ }
4124
+
4125
+ /**
4126
+ * This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
4127
+ * @public
4128
+ */
4129
+ export declare type QueryWithoutParams = Record<string, never> | undefined
4130
+
4131
+ /** @public */
4132
+ export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
4133
+
4134
+ /** @public */
4135
+ export declare interface RawQueryResponse<R> {
4136
+ query: string
4137
+ ms: number
4138
+ result: R
4139
+ resultSourceMap?: ContentSourceMap
4140
+ /** Requires `apiVersion` to be `2021-03-25` or later. */
4141
+ syncTags?: SyncTag[]
4142
+ }
4143
+
4144
+ /** @internal */
4145
+ export declare interface RawRequestOptions {
4146
+ url?: string
4147
+ uri?: string
4148
+ method?: string
4149
+ token?: string
4150
+ json?: boolean
4151
+ tag?: string
4152
+ useGlobalApi?: boolean
4153
+ withCredentials?: boolean
4154
+ query?: {
4155
+ [key: string]: string | string[]
4156
+ }
4157
+ headers?: {
4158
+ [key: string]: string
4159
+ }
4160
+ timeout?: number
4161
+ proxy?: string
4162
+ body?: Any
4163
+ maxRedirects?: number
4164
+ signal?: AbortSignal
4165
+ }
4166
+
4167
+ /**
4168
+ * The listener has been disconnected, and a reconnect attempt is scheduled.
4169
+ *
4170
+ * @public
4171
+ */
4172
+ export declare type ReconnectEvent = {
4173
+ type: 'reconnect'
4174
+ }
4175
+
4176
+ /** @public */
4177
+ export declare type ReleaseAction =
4178
+ | CreateReleaseAction
4179
+ | EditReleaseAction
4180
+ | PublishReleaseAction
4181
+ | ArchiveReleaseAction
4182
+ | UnarchiveReleaseAction
4183
+ | ScheduleReleaseAction
4184
+ | UnscheduleReleaseAction
4185
+ | DeleteReleaseAction
4186
+
4187
+ /** @internal */
4188
+ export declare interface ReleaseDocument extends SanityDocument {
4189
+ /**
4190
+ * typically
4191
+ * `_.releases.<name>`
4192
+ */
4193
+ _id: string
4194
+ /**
4195
+ * where a release has _id `_.releases.foo`, the name is `foo`
4196
+ */
4197
+ name: string
4198
+ _type: 'system.release'
4199
+ _createdAt: string
4200
+ _updatedAt: string
4201
+ _rev: string
4202
+ state: ReleaseState
4203
+ error?: {
4204
+ message: string
4205
+ }
4206
+ finalDocumentStates?: {
4207
+ /** Document ID */
4208
+ id: string
4209
+ }[]
4210
+ /**
4211
+ * If defined, it takes precedence over the intendedPublishAt, the state should be 'scheduled'
4212
+ */
4213
+ publishAt?: string
4214
+ /**
4215
+ * If defined, it provides the time the release was actually published
4216
+ */
4217
+ publishedAt?: string
4218
+ metadata: {
4219
+ title?: string
4220
+ description?: string
4221
+ intendedPublishAt?: string
4222
+ releaseType: ReleaseType
4223
+ }
4224
+ }
4225
+
4226
+ /**
4227
+ * @public
4228
+ * @deprecated – The `r`-prefix is not required, use `string` instead
4229
+ */
4230
+ export declare type ReleaseId = `r${string}`
4231
+
4232
+ /** @public */
4233
+ declare class ReleasesClient {
4234
+ #private
4235
+ constructor(client: SanityClient, httpRequest: HttpRequest)
4236
+ /**
4237
+ * @public
4238
+ *
4239
+ * Retrieve a release by id.
4240
+ *
4241
+ * @category Releases
4242
+ *
4243
+ * @param params - Release action parameters:
4244
+ * - `releaseId` - The id of the release to retrieve.
4245
+ * @param options - Additional query options including abort signal and query tag.
4246
+ * @returns A promise that resolves to the release document {@link ReleaseDocument}.
4247
+ *
4248
+ * @example Retrieving a release by id
4249
+ * ```ts
4250
+ * const release = await client.releases.get({releaseId: 'my-release'})
4251
+ * console.log(release)
4252
+ * // {
4253
+ * // _id: '_.releases.my-release',
4254
+ * // name: 'my-release'
4255
+ * // _type: 'system.release',
4256
+ * // metadata: {releaseType: 'asap'},
4257
+ * // _createdAt: '2021-01-01T00:00:00.000Z',
4258
+ * // ...
4259
+ * // }
4260
+ * ```
4261
+ */
4262
+ get(
4263
+ {
4264
+ releaseId,
4265
+ }: {
4266
+ releaseId: string
4267
+ },
4268
+ options?: {
4269
+ signal?: AbortSignal
4270
+ tag?: string
4271
+ },
4272
+ ): Promise<ReleaseDocument | undefined>
4273
+ /**
4274
+ * @public
4275
+ *
4276
+ * Creates a new release under the given id, with metadata.
4277
+ *
4278
+ * @remarks
4279
+ * * If no releaseId is provided, a release id will be generated.
4280
+ * * If no metadata is provided, then an `undecided` releaseType will be used.
4281
+ *
4282
+ * @category Releases
4283
+ *
4284
+ * @param params - Release action parameters:
4285
+ * - `releaseId` - The id of the release to create.
4286
+ * - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
4287
+ * @param options - Additional action options.
4288
+ * @returns A promise that resolves to the `transactionId` and the release id and metadata.
4289
+ *
4290
+ * @example Creating a release with a custom id and metadata
4291
+ * ```ts
4292
+ * const releaseId = 'my-release'
4293
+ * const releaseMetadata: ReleaseDocument['metadata'] = {
4294
+ * releaseType: 'asap',
4295
+ * }
4296
+ *
4297
+ * const result =
4298
+ * await client.releases.create({releaseId, metadata: releaseMetadata})
4299
+ * console.log(result)
4300
+ * // {
4301
+ * // transactionId: 'transaction-id',
4302
+ * // releaseId: 'my-release',
4303
+ * // metadata: {releaseType: 'asap'},
4304
+ * // }
4305
+ * ```
4306
+ *
4307
+ * @example Creating a release with generated id and metadata
4308
+ * ```ts
4309
+ * const {metadata} = await client.releases.create()
4310
+ * console.log(metadata.releaseType) // 'undecided'
4311
+ * ```
4312
+ *
4313
+ * @example Creating a release with a custom transaction id
4314
+ * ```ts
4315
+ * const {transactionId, metadata} = await client.releases.create({transactionId: 'my-transaction-id'})
4316
+ * console.log(metadata.releaseType) // 'undecided'
4317
+ * console.log(transactionId) // 'my-transaction-id'
4318
+ * ```
4319
+ */
4320
+ create(options: BaseActionOptions): Promise<
4321
+ SingleActionResult & {
4322
+ releaseId: string
4323
+ metadata: ReleaseDocument['metadata']
4324
+ }
4325
+ >
4326
+ create(
4327
+ release: {
4328
+ releaseId?: string
4329
+ metadata?: Partial<ReleaseDocument['metadata']>
4330
+ },
4331
+ options?: BaseActionOptions,
4332
+ ): Promise<
4333
+ SingleActionResult & {
4334
+ releaseId: string
4335
+ metadata: ReleaseDocument['metadata']
4336
+ }
4337
+ >
4338
+ /**
4339
+ * @public
4340
+ *
4341
+ * Edits an existing release, updating the metadata.
4342
+ *
4343
+ * @category Releases
4344
+ *
4345
+ * @param params - Release action parameters:
4346
+ * - `releaseId` - The id of the release to edit.
4347
+ * - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
4348
+ * @param options - Additional action options.
4349
+ * @returns A promise that resolves to the `transactionId`.
4350
+ */
4351
+ edit(
4352
+ {
4353
+ releaseId,
4354
+ patch,
4355
+ }: {
4356
+ releaseId: string
4357
+ patch: PatchOperations
4358
+ },
4359
+ options?: BaseActionOptions,
4360
+ ): Promise<SingleActionResult>
4361
+ /**
4362
+ * @public
4363
+ *
4364
+ * Publishes all documents in a release at once. For larger releases the effect of the publish
4365
+ * will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
4366
+ * documents and creation of the corresponding published documents with the new content may
4367
+ * take some time.
4368
+ *
4369
+ * During this period both the source and target documents are locked and cannot be
4370
+ * modified through any other means.
4371
+ *
4372
+ * @category Releases
4373
+ *
4374
+ * @param params - Release action parameters:
4375
+ * - `releaseId` - The id of the release to publish.
4376
+ * @param options - Additional action options.
4377
+ * @returns A promise that resolves to the `transactionId`.
4378
+ */
4379
+ publish(
4380
+ {
4381
+ releaseId,
4382
+ }: {
4383
+ releaseId: string
4384
+ },
4385
+ options?: BaseActionOptions,
4386
+ ): Promise<SingleActionResult>
4387
+ /**
4388
+ * @public
4389
+ *
4390
+ * An archive action removes an active release. The documents that comprise the release
4391
+ * are deleted and therefore no longer queryable.
4392
+ *
4393
+ * While the documents remain in retention the last version can still be accessed using document history endpoint.
4394
+ *
4395
+ * @category Releases
4396
+ *
4397
+ * @param params - Release action parameters:
4398
+ * - `releaseId` - The id of the release to archive.
4399
+ * @param options - Additional action options.
4400
+ * @returns A promise that resolves to the `transactionId`.
4401
+ */
4402
+ archive(
4403
+ {
4404
+ releaseId,
4405
+ }: {
4406
+ releaseId: string
4407
+ },
4408
+ options?: BaseActionOptions,
4409
+ ): Promise<SingleActionResult>
4410
+ /**
4411
+ * @public
4412
+ *
4413
+ * An unarchive action restores an archived release and all documents
4414
+ * with the content they had just prior to archiving.
4415
+ *
4416
+ * @category Releases
4417
+ *
4418
+ * @param params - Release action parameters:
4419
+ * - `releaseId` - The id of the release to unarchive.
4420
+ * @param options - Additional action options.
4421
+ * @returns A promise that resolves to the `transactionId`.
4422
+ */
4423
+ unarchive(
4424
+ {
4425
+ releaseId,
4426
+ }: {
4427
+ releaseId: string
4428
+ },
4429
+ options?: BaseActionOptions,
4430
+ ): Promise<SingleActionResult>
4431
+ /**
4432
+ * @public
4433
+ *
4434
+ * A schedule action queues a release for publishing at the given future time.
4435
+ * The release is locked such that no documents in the release can be modified and
4436
+ * no documents that it references can be deleted as this would make the publish fail.
4437
+ * At the given time, the same logic as for the publish action is triggered.
4438
+ *
4439
+ * @category Releases
4440
+ *
4441
+ * @param params - Release action parameters:
4442
+ * - `releaseId` - The id of the release to schedule.
4443
+ * - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
4444
+ * @param options - Additional action options.
4445
+ * @returns A promise that resolves to the `transactionId`.
4446
+ */
4447
+ schedule(
4448
+ {
4449
+ releaseId,
4450
+ publishAt,
4451
+ }: {
4452
+ releaseId: string
4453
+ publishAt: string
4454
+ },
4455
+ options?: BaseActionOptions,
4456
+ ): Promise<SingleActionResult>
4457
+ /**
4458
+ * @public
4459
+ *
4460
+ * An unschedule action stops a release from being published.
4461
+ * The documents in the release are considered unlocked and can be edited again.
4462
+ * This may fail if another release is scheduled to be published after this one and
4463
+ * has a reference to a document created by this one.
4464
+ *
4465
+ * @category Releases
4466
+ *
4467
+ * @param params - Release action parameters:
4468
+ * - `releaseId` - The id of the release to unschedule.
4469
+ * @param options - Additional action options.
4470
+ * @returns A promise that resolves to the `transactionId`.
4471
+ */
4472
+ unschedule(
4473
+ {
4474
+ releaseId,
4475
+ }: {
4476
+ releaseId: string
4477
+ },
4478
+ options?: BaseActionOptions,
4479
+ ): Promise<SingleActionResult>
4480
+ /**
4481
+ * @public
4482
+ *
4483
+ * A delete action removes a published or archived release.
4484
+ * The backing system document will be removed from the dataset.
4485
+ *
4486
+ * @category Releases
4487
+ *
4488
+ * @param params - Release action parameters:
4489
+ * - `releaseId` - The id of the release to delete.
4490
+ * @param options - Additional action options.
4491
+ * @returns A promise that resolves to the `transactionId`.
4492
+ */
4493
+ delete(
4494
+ {
4495
+ releaseId,
4496
+ }: {
4497
+ releaseId: string
4498
+ },
4499
+ options?: BaseActionOptions,
4500
+ ): Promise<SingleActionResult>
4501
+ /**
4502
+ * @public
4503
+ *
4504
+ * Fetch the documents in a release by release id.
4505
+ *
4506
+ * @category Releases
4507
+ *
4508
+ * @param params - Release action parameters:
4509
+ * - `releaseId` - The id of the release to fetch documents for.
4510
+ * @param options - Additional mutation options {@link BaseMutationOptions}.
4511
+ * @returns A promise that resolves to the documents in the release.
4512
+ */
4513
+ fetchDocuments(
4514
+ {
4515
+ releaseId,
4516
+ }: {
4517
+ releaseId: string
4518
+ },
4519
+ options?: BaseMutationOptions,
4520
+ ): Promise<RawQueryResponse<SanityDocument[]>>
4521
+ }
4522
+
4523
+ /** @beta */
4524
+ export declare type ReleaseState =
4525
+ | 'active'
4526
+ | 'archiving'
4527
+ | 'unarchiving'
4528
+ | 'archived'
4529
+ | 'published'
4530
+ | 'publishing'
4531
+ | 'scheduled'
4532
+ | 'scheduling'
3096
4533
 
3097
4534
  /** @internal */
3098
- export declare interface RawRequestOptions {
3099
- url?: string
3100
- uri?: string
3101
- method?: string
3102
- token?: string
3103
- json?: boolean
3104
- tag?: string
3105
- useGlobalApi?: boolean
3106
- withCredentials?: boolean
3107
- query?: {
3108
- [key: string]: string | string[]
3109
- }
3110
- headers?: {
3111
- [key: string]: string
3112
- }
3113
- timeout?: number
3114
- proxy?: string
3115
- body?: Any
3116
- maxRedirects?: number
3117
- signal?: AbortSignal
3118
- }
3119
-
3120
- /**
3121
- * The listener has been disconnected, and a reconnect attempt is scheduled.
3122
- *
3123
- * @public
3124
- */
3125
- export declare type ReconnectEvent = {
3126
- type: 'reconnect'
3127
- }
3128
-
3129
- /**
3130
- * @public
3131
- * @deprecated – The `r`-prefix is not required, use `string` instead
3132
- */
3133
- export declare type ReleaseId = `r${string}`
4535
+ export declare type ReleaseType = 'asap' | 'scheduled' | 'undecided'
3134
4536
 
3135
4537
  /**
3136
4538
  * Replaces an existing draft document.
3137
4539
  * At least one of the draft or published versions of the document must exist.
3138
4540
  *
3139
4541
  * @public
4542
+ * @deprecated Use {@link ReplaceVersionAction} instead
3140
4543
  */
3141
4544
  export declare type ReplaceDraftAction = {
3142
4545
  actionType: 'sanity.action.document.replaceDraft'
@@ -3150,6 +4553,16 @@ export declare type ReplaceDraftAction = {
3150
4553
  attributes: IdentifiedSanityDocumentStub
3151
4554
  }
3152
4555
 
4556
+ /**
4557
+ * Replace an existing version of a document.
4558
+ *
4559
+ * @public
4560
+ */
4561
+ export declare interface ReplaceVersionAction {
4562
+ actionType: 'sanity.action.document.version.replace'
4563
+ document: IdentifiedSanityDocumentStub
4564
+ }
4565
+
3153
4566
  /**
3154
4567
  * @deprecated -- Use `import {requester} from '@sanity/client'` instead
3155
4568
  * @public
@@ -3241,6 +4654,7 @@ export declare class SanityClient {
3241
4654
  agent: {
3242
4655
  action: AgentActionsClient
3243
4656
  }
4657
+ releases: ReleasesClient
3244
4658
  /**
3245
4659
  * Observable version of the Sanity client, with the same configuration as the promise-based one
3246
4660
  */
@@ -3337,6 +4751,7 @@ export declare class SanityClient {
3337
4751
  options?: {
3338
4752
  signal?: AbortSignal
3339
4753
  tag?: string
4754
+ releaseId?: string
3340
4755
  },
3341
4756
  ): Promise<SanityDocument<R> | undefined>
3342
4757
  /**
@@ -3520,6 +4935,90 @@ export declare class SanityClient {
3520
4935
  document: IdentifiedSanityDocumentStub<R>,
3521
4936
  options?: BaseMutationOptions,
3522
4937
  ): Promise<SanityDocument<R>>
4938
+ /**
4939
+ * @public
4940
+ *
4941
+ * Creates a new version of a published document.
4942
+ *
4943
+ * @remarks
4944
+ * * Requires a document with a `_type` property.
4945
+ * * Creating a version with no `releaseId` will create a new draft version of the published document.
4946
+ * * 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`.
4947
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
4948
+ * * To create a version of an unpublished document, use the `client.create` method.
4949
+ *
4950
+ * @category Versions
4951
+ *
4952
+ * @param params - Version action parameters:
4953
+ * - `document` - The document to create as a new version (must include `_type`).
4954
+ * - `publishedId` - The ID of the published document being versioned.
4955
+ * - `releaseId` - The ID of the release to create the version for.
4956
+ * @param options - Additional action options.
4957
+ * @returns A promise that resolves to the `transactionId`.
4958
+ *
4959
+ * @example Creating a new version of a published document with a generated version ID
4960
+ * ```ts
4961
+ * const transactionId = await client.createVersion({
4962
+ * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
4963
+ * document: {_type: 'myDocument', title: 'My Document'},
4964
+ * publishedId: 'myDocument',
4965
+ * releaseId: 'myRelease',
4966
+ * })
4967
+ *
4968
+ * // The following document will be created:
4969
+ * // {
4970
+ * // _id: 'versions.myRelease.myDocument',
4971
+ * // _type: 'myDocument',
4972
+ * // title: 'My Document',
4973
+ * // }
4974
+ * ```
4975
+ *
4976
+ * @example Creating a new version of a published document with a specified version ID
4977
+ * ```ts
4978
+ * const transactionId = await client.createVersion({
4979
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
4980
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
4981
+ * })
4982
+ *
4983
+ * // The following document will be created:
4984
+ * // {
4985
+ * // _id: 'versions.myRelease.myDocument',
4986
+ * // _type: 'myDocument',
4987
+ * // title: 'My Document',
4988
+ * // }
4989
+ * ```
4990
+ *
4991
+ * @example Creating a new draft version of a published document
4992
+ * ```ts
4993
+ * const transactionId = await client.createVersion({
4994
+ * document: {_type: 'myDocument', title: 'My Document'},
4995
+ * publishedId: 'myDocument',
4996
+ * })
4997
+ *
4998
+ * // The following document will be created:
4999
+ * // {
5000
+ * // _id: 'drafts.myDocument',
5001
+ * // _type: 'myDocument',
5002
+ * // title: 'My Document',
5003
+ * // }
5004
+ * ```
5005
+ */
5006
+ createVersion<R extends Record<string, Any>>(
5007
+ args: {
5008
+ document: SanityDocumentStub<R>
5009
+ publishedId: string
5010
+ releaseId?: string
5011
+ },
5012
+ options?: BaseActionOptions,
5013
+ ): Promise<SingleActionResult | MultipleActionResult>
5014
+ createVersion<R extends Record<string, Any>>(
5015
+ args: {
5016
+ document: IdentifiedSanityDocumentStub<R>
5017
+ publishedId?: string
5018
+ releaseId?: string
5019
+ },
5020
+ options?: BaseActionOptions,
5021
+ ): Promise<SingleActionResult | MultipleActionResult>
3523
5022
  /**
3524
5023
  * Deletes a document with the given document ID.
3525
5024
  * Returns a promise that resolves to the deleted document.
@@ -3624,6 +5123,157 @@ export declare class SanityClient {
3624
5123
  selection: MutationSelection,
3625
5124
  options?: BaseMutationOptions,
3626
5125
  ): Promise<SanityDocument<R>>
5126
+ /**
5127
+ * @public
5128
+ *
5129
+ * Deletes the draft or release version of a document.
5130
+ *
5131
+ * @remarks
5132
+ * * Discarding a version with no `releaseId` will discard the draft version of the published document.
5133
+ * * If the draft or release version does not exist, any error will throw.
5134
+ *
5135
+ * @param params - Version action parameters:
5136
+ * - `releaseId` - The ID of the release to discard the document from.
5137
+ * - `publishedId` - The published ID of the document to discard.
5138
+ * @param purge - if `true` the document history is also discarded.
5139
+ * @param options - Additional action options.
5140
+ * @returns a promise that resolves to the `transactionId`.
5141
+ *
5142
+ * @example Discarding a release version of a document
5143
+ * ```ts
5144
+ * client.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
5145
+ * // The document with the ID `versions.myRelease.myDocument` will be discarded.
5146
+ * ```
5147
+ *
5148
+ * @example Discarding a draft version of a document
5149
+ * ```ts
5150
+ * client.discardVersion({publishedId: 'myDocument'})
5151
+ * // The document with the ID `drafts.myDocument` will be discarded.
5152
+ * ```
5153
+ */
5154
+ discardVersion(
5155
+ {
5156
+ releaseId,
5157
+ publishedId,
5158
+ }: {
5159
+ releaseId?: string
5160
+ publishedId: string
5161
+ },
5162
+ purge?: boolean,
5163
+ options?: BaseActionOptions,
5164
+ ): Promise<SingleActionResult | MultipleActionResult>
5165
+ /**
5166
+ * @public
5167
+ *
5168
+ * Replaces an existing version document.
5169
+ *
5170
+ * @remarks
5171
+ * * Requires a document with a `_type` property.
5172
+ * * 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`.
5173
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
5174
+ * * Replacing a version with no `releaseId` will replace the draft version of the published document.
5175
+ * * At least one of the **version** or **published** documents must exist.
5176
+ *
5177
+ * @param params - Version action parameters:
5178
+ * - `document` - The new document to replace the version with.
5179
+ * - `releaseId` - The ID of the release where the document version is replaced.
5180
+ * - `publishedId` - The ID of the published document to replace.
5181
+ * @param options - Additional action options.
5182
+ * @returns a promise that resolves to the `transactionId`.
5183
+ *
5184
+ * @example Replacing a release version of a published document with a generated version ID
5185
+ * ```ts
5186
+ * await client.replaceVersion({
5187
+ * document: {_type: 'myDocument', title: 'My Document'},
5188
+ * publishedId: 'myDocument',
5189
+ * releaseId: 'myRelease',
5190
+ * })
5191
+ *
5192
+ * // The following document will be patched:
5193
+ * // {
5194
+ * // _id: 'versions.myRelease.myDocument',
5195
+ * // _type: 'myDocument',
5196
+ * // title: 'My Document',
5197
+ * // }
5198
+ * ```
5199
+ *
5200
+ * @example Replacing a release version of a published document with a specified version ID
5201
+ * ```ts
5202
+ * await client.replaceVersion({
5203
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
5204
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
5205
+ * })
5206
+ *
5207
+ * // The following document will be patched:
5208
+ * // {
5209
+ * // _id: 'versions.myRelease.myDocument',
5210
+ * // _type: 'myDocument',
5211
+ * // title: 'My Document',
5212
+ * // }
5213
+ * ```
5214
+ *
5215
+ * @example Replacing a draft version of a published document
5216
+ * ```ts
5217
+ * await client.replaceVersion({
5218
+ * document: {_type: 'myDocument', title: 'My Document'},
5219
+ * publishedId: 'myDocument',
5220
+ * })
5221
+ *
5222
+ * // The following document will be patched:
5223
+ * // {
5224
+ * // _id: 'drafts.myDocument',
5225
+ * // _type: 'myDocument',
5226
+ * // title: 'My Document',
5227
+ * // }
5228
+ * ```
5229
+ */
5230
+ replaceVersion<R extends Record<string, Any>>(
5231
+ args: {
5232
+ document: SanityDocumentStub<R>
5233
+ publishedId: string
5234
+ releaseId?: string
5235
+ },
5236
+ options?: BaseActionOptions,
5237
+ ): Promise<SingleActionResult | MultipleActionResult>
5238
+ replaceVersion<R extends Record<string, Any>>(
5239
+ args: {
5240
+ document: IdentifiedSanityDocumentStub<R>
5241
+ publishedId?: string
5242
+ releaseId?: string
5243
+ },
5244
+ options?: BaseActionOptions,
5245
+ ): Promise<SingleActionResult | MultipleActionResult>
5246
+ /**
5247
+ * @public
5248
+ *
5249
+ * Used to indicate when a document within a release should be unpublished when
5250
+ * the release is run.
5251
+ *
5252
+ * @remarks
5253
+ * * If the published document does not exist, an error will be thrown.
5254
+ *
5255
+ * @param params - Version action parameters:
5256
+ * - `releaseId` - The ID of the release to unpublish the document from.
5257
+ * - `publishedId` - The published ID of the document to unpublish.
5258
+ * @param options - Additional action options.
5259
+ * @returns a promise that resolves to the `transactionId`.
5260
+ *
5261
+ * @example Unpublishing a release version of a published document
5262
+ * ```ts
5263
+ * await client.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
5264
+ * // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
5265
+ * ```
5266
+ */
5267
+ unpublishVersion(
5268
+ {
5269
+ releaseId,
5270
+ publishedId,
5271
+ }: {
5272
+ releaseId: string
5273
+ publishedId: string
5274
+ },
5275
+ options?: BaseActionOptions,
5276
+ ): Promise<SingleActionResult | MultipleActionResult>
3627
5277
  /**
3628
5278
  * Perform mutation operations against the configured dataset
3629
5279
  * Returns a promise that resolves to the first mutated document.
@@ -3664,7 +5314,7 @@ export declare class SanityClient {
3664
5314
  * @param operations - Mutation operations to execute
3665
5315
  * @param options - Mutation options
3666
5316
  */
3667
- mutate<R extends Record<string, Any>>(
5317
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
3668
5318
  operations: Mutation<R>[] | Patch | Transaction,
3669
5319
  options: AllDocumentIdsMutationOptions,
3670
5320
  ): Promise<MultipleMutationResult>
@@ -3886,6 +5536,17 @@ export declare interface SanityUser {
3886
5536
  isCurrentUser: boolean
3887
5537
  }
3888
5538
 
5539
+ /**
5540
+ * Queues release for publishing at the given future time.
5541
+ *
5542
+ * @public
5543
+ */
5544
+ export declare interface ScheduleReleaseAction {
5545
+ actionType: 'sanity.action.release.schedule'
5546
+ releaseId: string
5547
+ publishAt: string
5548
+ }
5549
+
3889
5550
  /** @public */
3890
5551
  export declare class ServerError extends Error {
3891
5552
  response: ErrorProps['response']
@@ -4136,12 +5797,47 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
4136
5797
  declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
4137
5798
  TransformRequestBase & AgentActionSync
4138
5799
 
5800
+ /**
5801
+ *
5802
+ * ## `set` by default
5803
+ * By default, Transform will change the value of every target field in place using a set operation.
5804
+ *
5805
+ * ## Image description
5806
+ *
5807
+ * ### Targeting image fields
5808
+ * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
5809
+ * with `operation: {type: 'image-description'}`.
5810
+ *
5811
+ * Custom instructions for image description targets will be used to generate the description.
5812
+ *
5813
+ * Such targets must be a descendant field of an image object.
5814
+ *
5815
+ * For example:
5816
+ * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
5817
+ * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
5818
+ * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
5819
+ *
5820
+ * ### Targeting non-image fields
5821
+ * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
5822
+ * `sourcePath` must be an image or image asset field.
5823
+ *
5824
+ * For example:
5825
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
5826
+ * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5827
+ * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5828
+ *
5829
+ * @beta
5830
+ */
5831
+ export declare type TransformOperation = 'set' | ImageDescriptionOperation
5832
+
4139
5833
  /** @beta */
4140
5834
  declare interface TransformRequestBase extends AgentActionRequestBase {
4141
5835
  /** schemaId as reported by sanity deploy / sanity schema store */
4142
5836
  schemaId: string
4143
5837
  /**
4144
5838
  * The source document the transformation will use as input.
5839
+ *
5840
+ * @see #AgentActionSchema.forcePublishedWrite
4145
5841
  */
4146
5842
  documentId: string
4147
5843
  /**
@@ -4149,12 +5845,14 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
4149
5845
  * then it is transformed according to the instruction.
4150
5846
  *
4151
5847
  * When omitted, the source document (documentId) is also the target document.
5848
+ *
5849
+ * @see #AgentActionSchema.forcePublishedWrite
4152
5850
  */
4153
5851
  targetDocument?: TransformTargetDocument
4154
5852
  /**
4155
5853
  * Instruct the LLM how to transform the input to th output.
4156
5854
  *
4157
- * String template using $variable from instructionParams.
5855
+ * String template with support for $variable from `instructionParams`.
4158
5856
  *
4159
5857
  * Capped to 2000 characters, after variables has been injected.
4160
5858
  * */
@@ -4253,17 +5951,35 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
4253
5951
  * It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
4254
5952
  *
4255
5953
  * Default max depth for transform: 12
5954
+ *
5955
+ * ## Transforming images
5956
+ *
5957
+ * To transform an existing image, directly target an image asset path.
5958
+ *
5959
+ * For example, all the following will transform the image into the provided asset:
5960
+ * * `target: {path: ['image', 'asset'] }`
5961
+ * * `target: {path: 'image', include: ['asset'] }`
5962
+ *
5963
+ * Image transform can be combined with regular content targets:
5964
+ * * `target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]`
5965
+ *
5966
+ * Image transform can have per-path instructions, just like any other target paths:
5967
+ * * `target: [{path: ['image', 'asset'], instruction: 'Make the sky blue' }`
5968
+ *
4256
5969
  * @see AgentActionRequestBase#conditionalPaths
4257
5970
  */
4258
5971
  target?: TransformTarget | TransformTarget[]
4259
5972
  }
4260
5973
 
4261
- /** @beta */
5974
+ /**
5975
+ * @see #TransformOperation
5976
+ * @beta
5977
+ * */
4262
5978
  export declare interface TransformTarget extends AgentActionTarget {
4263
5979
  /**
4264
5980
  * Specifies a tailored instruction of this target.
4265
5981
  *
4266
- * string template using $variable from instructionParams.
5982
+ * String template with support for $variable from `instructionParams`.
4267
5983
  * */
4268
5984
  instruction?: string
4269
5985
  /**
@@ -4274,9 +5990,18 @@ export declare interface TransformTarget extends AgentActionTarget {
4274
5990
  * Fields or array items not on the include list, are implicitly excluded.
4275
5991
  */
4276
5992
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
5993
+ /**
5994
+ * Default: `set`
5995
+ * @see #TransformOperation
5996
+ */
5997
+ operation?: TransformOperation
4277
5998
  }
4278
5999
 
4279
- /** @beta */
6000
+ /**
6001
+ * @see #AgentActionSchema.forcePublishedWrite
6002
+ *
6003
+ * @beta
6004
+ */
4280
6005
  export declare type TransformTargetDocument =
4281
6006
  | {
4282
6007
  operation: 'edit'
@@ -4295,12 +6020,15 @@ export declare type TransformTargetDocument =
4295
6020
  _id: string
4296
6021
  }
4297
6022
 
4298
- /** @beta */
6023
+ /**
6024
+ * @see #TransformOperation
6025
+ * @beta
6026
+ * */
4299
6027
  export declare interface TransformTargetInclude extends AgentActionTargetInclude {
4300
6028
  /**
4301
6029
  * Specifies a tailored instruction of this target.
4302
6030
  *
4303
- * string template using $variable from instructionParams */
6031
+ * String template with support for $variable from `instructionParams`. */
4304
6032
  instruction?: string
4305
6033
  /**
4306
6034
  * By default, all children up to `target.maxPathDepth` are included.
@@ -4310,6 +6038,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
4310
6038
  * Fields or array items not on the include list, are implicitly excluded.
4311
6039
  */
4312
6040
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
6041
+ /**
6042
+ * Default: `set`
6043
+ * @see #TransformOperation
6044
+ */
6045
+ operation?: TransformOperation
4313
6046
  }
4314
6047
 
4315
6048
  /** @beta */
@@ -4342,6 +6075,7 @@ declare interface TranslateRequestBase extends AgentActionRequestBase {
4342
6075
  schemaId: string
4343
6076
  /**
4344
6077
  * The source document the transformation will use as input.
6078
+ * @see #AgentActionSchema.forcePublishedWrite
4345
6079
  */
4346
6080
  documentId: string
4347
6081
  /**
@@ -4349,6 +6083,8 @@ declare interface TranslateRequestBase extends AgentActionRequestBase {
4349
6083
  * then it is translated according to the instruction.
4350
6084
  *
4351
6085
  * When omitted, the source document (documentId) is also the target document.
6086
+ *
6087
+ * @see #AgentActionSchema.forcePublishedWrite
4352
6088
  */
4353
6089
  targetDocument?: TransformTargetDocument
4354
6090
  /**
@@ -4401,7 +6137,7 @@ declare interface TranslateRequestBase extends AgentActionRequestBase {
4401
6137
 
4402
6138
  /** @beta */
4403
6139
  export declare interface TranslateTarget extends AgentActionTarget {
4404
- /** string template using $variable from instructionParams */
6140
+ /** String template using $variable from styleGuideParams. */
4405
6141
  styleGuide?: string
4406
6142
  /**
4407
6143
  * By default, all children up to `target.maxPathDepth` are included.
@@ -4415,7 +6151,7 @@ export declare interface TranslateTarget extends AgentActionTarget {
4415
6151
 
4416
6152
  /** @beta */
4417
6153
  export declare interface TranslateTargetInclude extends AgentActionTargetInclude {
4418
- /** string template using $variable from instructionParams */
6154
+ /** String template using $variable from styleGuideParams. */
4419
6155
  styleGuide?: string
4420
6156
  /**
4421
6157
  * By default, all children up to `target.maxPathDepth` are included.
@@ -4427,6 +6163,16 @@ export declare interface TranslateTargetInclude extends AgentActionTargetInclude
4427
6163
  include?: (AgentActionPathSegment | TranslateTargetInclude)[]
4428
6164
  }
4429
6165
 
6166
+ /**
6167
+ * Unarchived an `archived` release, and restores all the release documents.
6168
+ *
6169
+ * @public
6170
+ */
6171
+ export declare interface UnarchiveReleaseAction {
6172
+ actionType: 'sanity.action.release.unarchive'
6173
+ releaseId: string
6174
+ }
6175
+
4430
6176
  /** @public */
4431
6177
  export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
4432
6178
  filterResponse: false
@@ -4468,6 +6214,28 @@ export declare type UnpublishAction = {
4468
6214
  publishedId: string
4469
6215
  }
4470
6216
 
6217
+ /**
6218
+ * Identify that a version of a document should be unpublished when
6219
+ * the release that version is contained within is published.
6220
+ *
6221
+ * @public
6222
+ */
6223
+ export declare interface UnpublishVersionAction {
6224
+ actionType: 'sanity.action.document.version.unpublish'
6225
+ versionId: string
6226
+ publishedId: string
6227
+ }
6228
+
6229
+ /**
6230
+ * Unschedules a `scheduled` release, stopping it from being published.
6231
+ *
6232
+ * @public
6233
+ */
6234
+ export declare interface UnscheduleReleaseAction {
6235
+ actionType: 'sanity.action.release.unschedule'
6236
+ releaseId: string
6237
+ }
6238
+
4471
6239
  export {unstable__adapter}
4472
6240
 
4473
6241
  export {unstable__environment}
@@ -4563,6 +6331,39 @@ export declare function validateApiPerspective(
4563
6331
  */
4564
6332
  export declare const vercelStegaCleanAll: typeof stegaClean
4565
6333
 
6334
+ /** @public */
6335
+ export declare type VersionAction =
6336
+ | CreateVersionAction
6337
+ | DiscardVersionAction
6338
+ | ReplaceVersionAction
6339
+ | UnpublishVersionAction
6340
+
6341
+ /** @public */
6342
+ export declare type ViewConnectionOverride = {
6343
+ query: string
6344
+ resourceType: ViewResourceType
6345
+ resourceId: string
6346
+ }
6347
+
6348
+ /** @public */
6349
+ export declare type ViewOverride = {
6350
+ resourceType: ViewResourceType.View
6351
+ resourceId: string
6352
+ connections: ViewConnectionOverride[]
6353
+ }
6354
+
6355
+ /** @public */
6356
+ export declare type ViewQueryOptions = Pick<
6357
+ EmulatedResponseQueryOptions,
6358
+ 'perspective' | 'resultSourceMap' | 'filterResponse'
6359
+ >
6360
+
6361
+ /** @public */
6362
+ export declare enum ViewResourceType {
6363
+ Dataset = 'dataset',
6364
+ View = 'view',
6365
+ }
6366
+
4566
6367
  /**
4567
6368
  * The listener has been established, and will start receiving events.
4568
6369
  * Note that this is also emitted upon _reconnection_.