@sanity/client 7.1.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -19,6 +19,8 @@ export declare type Action =
19
19
  | DiscardAction
20
20
  | PublishAction
21
21
  | UnpublishAction
22
+ | VersionAction
23
+ | ReleaseAction
22
24
 
23
25
  /** @internal */
24
26
  export declare interface ActionError {
@@ -320,6 +322,16 @@ export declare interface ApiError {
320
322
  statusCode: number
321
323
  }
322
324
 
325
+ /**
326
+ * Archives an `active` release, and deletes all the release documents.
327
+ *
328
+ * @public
329
+ */
330
+ export declare interface ArchiveReleaseAction {
331
+ actionType: 'sanity.action.release.archive'
332
+ releaseId: string
333
+ }
334
+
323
335
  /** @public */
324
336
  export declare type AssetMetadataType =
325
337
  | 'location'
@@ -891,6 +903,29 @@ export declare type CreateAction = {
891
903
  */
892
904
  export declare const createClient: (config: ClientConfig) => SanityClient
893
905
 
906
+ /**
907
+ * Creates a new release under the given id, with metadata.
908
+ *
909
+ * @public
910
+ */
911
+ export declare interface CreateReleaseAction {
912
+ actionType: 'sanity.action.release.create'
913
+ releaseId: string
914
+ metadata?: Partial<ReleaseDocument['metadata']>
915
+ }
916
+
917
+ /**
918
+ * Creates a new version of an existing document, attached to the release as given
919
+ * by `document._id`
920
+ *
921
+ * @public
922
+ */
923
+ export declare interface CreateVersionAction {
924
+ actionType: 'sanity.action.document.version.create'
925
+ publishedId: string
926
+ document: IdentifiedSanityDocumentStub
927
+ }
928
+
894
929
  /** @public */
895
930
  export declare interface CurrentSanityUser {
896
931
  id: string
@@ -986,6 +1021,16 @@ export declare type DeleteAction = {
986
1021
  purge?: boolean
987
1022
  }
988
1023
 
1024
+ /**
1025
+ * Deletes a `archived` or `published` release, and all the release documents versions.
1026
+ *
1027
+ * @public
1028
+ */
1029
+ export declare interface DeleteReleaseAction {
1030
+ actionType: 'sanity.action.release.delete'
1031
+ releaseId: string
1032
+ }
1033
+
989
1034
  /**
990
1035
  * @public
991
1036
  * @deprecated Use the named export `createClient` instead of the `default` export
@@ -1003,6 +1048,7 @@ declare type DeprecatedPreviewDrafts = 'previewDrafts'
1003
1048
  * It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
1004
1049
  *
1005
1050
  * @public
1051
+ * @deprecated Use {@link DiscardVersionAction} instead
1006
1052
  */
1007
1053
  export declare type DiscardAction = {
1008
1054
  actionType: 'sanity.action.document.discard'
@@ -1016,6 +1062,17 @@ export declare type DiscardAction = {
1016
1062
  purge?: boolean
1017
1063
  }
1018
1064
 
1065
+ /**
1066
+ * Delete a version of a document.
1067
+ *
1068
+ * @public
1069
+ */
1070
+ export declare interface DiscardVersionAction {
1071
+ actionType: 'sanity.action.document.version.discard'
1072
+ versionId: string
1073
+ purge?: boolean
1074
+ }
1075
+
1019
1076
  /**
1020
1077
  * The listener has been told to explicitly disconnect.
1021
1078
  * This is a rare situation, but may occur if the API knows reconnect attempts will fail,
@@ -1070,6 +1127,15 @@ export declare interface DocumentAgentActionParam {
1070
1127
  documentId?: string
1071
1128
  }
1072
1129
 
1130
+ /** @internal */
1131
+ export declare type EditableReleaseDocument = Omit<
1132
+ PartialExcept<ReleaseDocument, '_id'>,
1133
+ 'metadata' | '_type'
1134
+ > & {
1135
+ _id: string
1136
+ metadata: Partial<ReleaseDocument['metadata']>
1137
+ }
1138
+
1073
1139
  /**
1074
1140
  * Modifies an existing draft document.
1075
1141
  * It applies the given patch to the document referenced by draftId.
@@ -1093,6 +1159,17 @@ export declare type EditAction = {
1093
1159
  patch: PatchOperations
1094
1160
  }
1095
1161
 
1162
+ /**
1163
+ * Edits an existing release, updating the metadata.
1164
+ *
1165
+ * @public
1166
+ */
1167
+ export declare interface EditReleaseAction {
1168
+ actionType: 'sanity.action.release.edit'
1169
+ releaseId: string
1170
+ patch: PatchOperations
1171
+ }
1172
+
1096
1173
  /** @public */
1097
1174
  export declare interface ErrorProps {
1098
1175
  message: string
@@ -2118,6 +2195,306 @@ export declare class ObservableProjectsClient {
2118
2195
  getById(projectId: string): Observable<SanityProject>
2119
2196
  }
2120
2197
 
2198
+ /** @public */
2199
+ declare class ObservableReleasesClient {
2200
+ #private
2201
+ constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
2202
+ /**
2203
+ * @public
2204
+ *
2205
+ * Retrieve a release by id.
2206
+ *
2207
+ * @category Releases
2208
+ *
2209
+ * @param params - Release action parameters:
2210
+ * - `releaseId` - The id of the release to retrieve.
2211
+ * @param options - Additional query options including abort signal and query tag.
2212
+ * @returns An observable that resolves to the release document {@link ReleaseDocument}.
2213
+ *
2214
+ * @example Retrieving a release by id
2215
+ * ```ts
2216
+ * client.observable.releases.get({releaseId: 'my-release'}).pipe(
2217
+ * tap((release) => console.log(release)),
2218
+ * // {
2219
+ * // _id: '_.releases.my-release',
2220
+ * // name: 'my-release'
2221
+ * // _type: 'system.release',
2222
+ * // metadata: {releaseType: 'asap'},
2223
+ * // _createdAt: '2021-01-01T00:00:00.000Z',
2224
+ * // ...
2225
+ * // }
2226
+ * ).subscribe()
2227
+ * ```
2228
+ */
2229
+ get(
2230
+ {
2231
+ releaseId,
2232
+ }: {
2233
+ releaseId: string
2234
+ },
2235
+ options?: {
2236
+ signal?: AbortSignal
2237
+ tag?: string
2238
+ },
2239
+ ): Observable<ReleaseDocument | undefined>
2240
+ /**
2241
+ * @public
2242
+ *
2243
+ * Creates a new release under the given id, with metadata.
2244
+ *
2245
+ * @remarks
2246
+ * * If no releaseId is provided, a release id will be generated.
2247
+ * * If no metadata is provided, then an `undecided` releaseType will be used.
2248
+ *
2249
+ * @category Releases
2250
+ *
2251
+ * @param params - Release action parameters:
2252
+ * - `releaseId` - The id of the release to create.
2253
+ * - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
2254
+ * @param options - Additional action options.
2255
+ * @returns An observable that resolves to the `transactionId` and the release id and metadata.
2256
+ *
2257
+ * @example Creating a release with a custom id and metadata
2258
+ * ```ts
2259
+ * const releaseId = 'my-release'
2260
+ * const metadata: ReleaseDocument['metadata'] = {
2261
+ * releaseType: 'asap',
2262
+ * }
2263
+ *
2264
+ * client.observable.releases.create({releaseId, metadata}).pipe(
2265
+ * tap(({transactionId, releaseId, metadata}) => console.log(transactionId, releaseId, metadata)),
2266
+ * // {
2267
+ * // transactionId: 'transaction-id',
2268
+ * // releaseId: 'my-release',
2269
+ * // metadata: {releaseType: 'asap'},
2270
+ * // }
2271
+ * ).subscribe()
2272
+ * ```
2273
+ *
2274
+ * @example Creating a release with generated id and metadata
2275
+ * ```ts
2276
+ * client.observable.releases.create().pipe(
2277
+ * tap(({metadata}) => console.log(metadata)),
2278
+ * // {
2279
+ * // metadata: {releaseType: 'undecided'},
2280
+ * // }
2281
+ * ).subscribe()
2282
+ * ```
2283
+ *
2284
+ * @example Creating a release using a custom transaction id
2285
+ * ```ts
2286
+ * client.observable.releases.create({transactionId: 'my-transaction-id'}).pipe(
2287
+ * tap(({transactionId, metadata}) => console.log(transactionId, metadata)),
2288
+ * // {
2289
+ * // transactionId: 'my-transaction-id',
2290
+ * // metadata: {releaseType: 'undecided'},
2291
+ * // }
2292
+ * ).subscribe()
2293
+ * ```
2294
+ */
2295
+ create(options: BaseActionOptions): Observable<
2296
+ SingleActionResult & {
2297
+ releaseId: string
2298
+ metadata: ReleaseDocument['metadata']
2299
+ }
2300
+ >
2301
+ create(
2302
+ release: {
2303
+ releaseId?: string
2304
+ metadata?: Partial<ReleaseDocument['metadata']>
2305
+ },
2306
+ options?: BaseActionOptions,
2307
+ ): Observable<
2308
+ SingleActionResult & {
2309
+ releaseId: string
2310
+ metadata: ReleaseDocument['metadata']
2311
+ }
2312
+ >
2313
+ /**
2314
+ * @public
2315
+ *
2316
+ * Edits an existing release, updating the metadata.
2317
+ *
2318
+ * @category Releases
2319
+ *
2320
+ * @param params - Release action parameters:
2321
+ * - `releaseId` - The id of the release to edit.
2322
+ * - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
2323
+ * @param options - Additional action options.
2324
+ * @returns An observable that resolves to the `transactionId`.
2325
+ */
2326
+ edit(
2327
+ {
2328
+ releaseId,
2329
+ patch,
2330
+ }: {
2331
+ releaseId: string
2332
+ patch: PatchOperations
2333
+ },
2334
+ options?: BaseActionOptions,
2335
+ ): Observable<SingleActionResult>
2336
+ /**
2337
+ * @public
2338
+ *
2339
+ * Publishes all documents in a release at once. For larger releases the effect of the publish
2340
+ * will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
2341
+ * documents and creation of the corresponding published documents with the new content may
2342
+ * take some time.
2343
+ *
2344
+ * During this period both the source and target documents are locked and cannot be
2345
+ * modified through any other means.
2346
+ *
2347
+ * @category Releases
2348
+ *
2349
+ * @param params - Release action parameters:
2350
+ * - `releaseId` - The id of the release to publish.
2351
+ * @param options - Additional action options.
2352
+ * @returns An observable that resolves to the `transactionId`.
2353
+ */
2354
+ publish(
2355
+ {
2356
+ releaseId,
2357
+ }: {
2358
+ releaseId: string
2359
+ },
2360
+ options?: BaseActionOptions,
2361
+ ): Observable<SingleActionResult>
2362
+ /**
2363
+ * @public
2364
+ *
2365
+ * An archive action removes an active release. The documents that comprise the release
2366
+ * are deleted and therefore no longer queryable.
2367
+ *
2368
+ * While the documents remain in retention the last version can still be accessed using document history endpoint.
2369
+ *
2370
+ * @category Releases
2371
+ *
2372
+ * @param params - Release action parameters:
2373
+ * - `releaseId` - The id of the release to archive.
2374
+ * @param options - Additional action options.
2375
+ * @returns An observable that resolves to the `transactionId`.
2376
+ */
2377
+ archive(
2378
+ {
2379
+ releaseId,
2380
+ }: {
2381
+ releaseId: string
2382
+ },
2383
+ options?: BaseActionOptions,
2384
+ ): Observable<SingleActionResult>
2385
+ /**
2386
+ * @public
2387
+ *
2388
+ * An unarchive action restores an archived release and all documents
2389
+ * with the content they had just prior to archiving.
2390
+ *
2391
+ * @category Releases
2392
+ *
2393
+ * @param params - Release action parameters:
2394
+ * - `releaseId` - The id of the release to unarchive.
2395
+ * @param options - Additional action options.
2396
+ * @returns An observable that resolves to the `transactionId`.
2397
+ */
2398
+ unarchive(
2399
+ {
2400
+ releaseId,
2401
+ }: {
2402
+ releaseId: string
2403
+ },
2404
+ options?: BaseActionOptions,
2405
+ ): Observable<SingleActionResult>
2406
+ /**
2407
+ * @public
2408
+ *
2409
+ * A schedule action queues a release for publishing at the given future time.
2410
+ * The release is locked such that no documents in the release can be modified and
2411
+ * no documents that it references can be deleted as this would make the publish fail.
2412
+ * At the given time, the same logic as for the publish action is triggered.
2413
+ *
2414
+ * @category Releases
2415
+ *
2416
+ * @param params - Release action parameters:
2417
+ * - `releaseId` - The id of the release to schedule.
2418
+ * - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
2419
+ * @param options - Additional action options.
2420
+ * @returns An observable that resolves to the `transactionId`.
2421
+ */
2422
+ schedule(
2423
+ {
2424
+ releaseId,
2425
+ publishAt,
2426
+ }: {
2427
+ releaseId: string
2428
+ publishAt: string
2429
+ },
2430
+ options?: BaseActionOptions,
2431
+ ): Observable<SingleActionResult>
2432
+ /**
2433
+ * @public
2434
+ *
2435
+ * An unschedule action stops a release from being published.
2436
+ * The documents in the release are considered unlocked and can be edited again.
2437
+ * This may fail if another release is scheduled to be published after this one and
2438
+ * has a reference to a document created by this one.
2439
+ *
2440
+ * @category Releases
2441
+ *
2442
+ * @param params - Release action parameters:
2443
+ * - `releaseId` - The id of the release to unschedule.
2444
+ * @param options - Additional action options.
2445
+ * @returns An observable that resolves to the `transactionId`.
2446
+ */
2447
+ unschedule(
2448
+ {
2449
+ releaseId,
2450
+ }: {
2451
+ releaseId: string
2452
+ },
2453
+ options?: BaseActionOptions,
2454
+ ): Observable<SingleActionResult>
2455
+ /**
2456
+ * @public
2457
+ *
2458
+ * A delete action removes a published or archived release.
2459
+ * The backing system document will be removed from the dataset.
2460
+ *
2461
+ * @category Releases
2462
+ *
2463
+ * @param params - Release action parameters:
2464
+ * - `releaseId` - The id of the release to delete.
2465
+ * @param options - Additional action options.
2466
+ * @returns An observable that resolves to the `transactionId`.
2467
+ */
2468
+ delete(
2469
+ {
2470
+ releaseId,
2471
+ }: {
2472
+ releaseId: string
2473
+ },
2474
+ options?: BaseActionOptions,
2475
+ ): Observable<SingleActionResult>
2476
+ /**
2477
+ * @public
2478
+ *
2479
+ * Fetch the documents in a release by release id.
2480
+ *
2481
+ * @category Releases
2482
+ *
2483
+ * @param params - Release action parameters:
2484
+ * - `releaseId` - The id of the release to fetch documents for.
2485
+ * @param options - Additional mutation options {@link BaseMutationOptions}.
2486
+ * @returns An observable that resolves to the documents in the release.
2487
+ */
2488
+ fetchDocuments(
2489
+ {
2490
+ releaseId,
2491
+ }: {
2492
+ releaseId: string
2493
+ },
2494
+ options?: BaseMutationOptions,
2495
+ ): Observable<RawQueryResponse<SanityDocument[]>>
2496
+ }
2497
+
2121
2498
  /** @public */
2122
2499
  export declare class ObservableSanityClient {
2123
2500
  #private
@@ -2129,6 +2506,7 @@ export declare class ObservableSanityClient {
2129
2506
  agent: {
2130
2507
  action: ObservableAgentsActionClient
2131
2508
  }
2509
+ releases: ObservableReleasesClient
2132
2510
  /**
2133
2511
  * Instance properties
2134
2512
  */
@@ -2219,7 +2597,9 @@ export declare class ObservableSanityClient {
2219
2597
  getDocument<R extends Record<string, Any> = Record<string, Any>>(
2220
2598
  id: string,
2221
2599
  options?: {
2600
+ signal?: AbortSignal
2222
2601
  tag?: string
2602
+ releaseId?: string
2223
2603
  },
2224
2604
  ): Observable<SanityDocument<R> | undefined>
2225
2605
  /**
@@ -2402,6 +2782,90 @@ export declare class ObservableSanityClient {
2402
2782
  document: IdentifiedSanityDocumentStub<R>,
2403
2783
  options?: BaseMutationOptions,
2404
2784
  ): Observable<SanityDocument<R>>
2785
+ /**
2786
+ * @public
2787
+ *
2788
+ * Creates a new version of a published document.
2789
+ *
2790
+ * @remarks
2791
+ * * Requires a document with a `_type` property.
2792
+ * * Creating a version with no `releaseId` will create a new draft version of the published document.
2793
+ * * 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`.
2794
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
2795
+ * * To create a version of an unpublished document, use the `client.create` method.
2796
+ *
2797
+ * @category Versions
2798
+ *
2799
+ * @param params - Version action parameters:
2800
+ * - `document` - The document to create as a new version (must include `_type`).
2801
+ * - `publishedId` - The ID of the published document being versioned.
2802
+ * - `releaseId` - The ID of the release to create the version for.
2803
+ * @param options - Additional action options.
2804
+ * @returns an observable that resolves to the `transactionId`.
2805
+ *
2806
+ * @example Creating a new version of a published document with a generated version ID
2807
+ * ```ts
2808
+ * client.observable.createVersion({
2809
+ * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
2810
+ * document: {_type: 'myDocument', title: 'My Document'},
2811
+ * publishedId: 'myDocument',
2812
+ * releaseId: 'myRelease',
2813
+ * })
2814
+ *
2815
+ * // The following document will be created:
2816
+ * // {
2817
+ * // _id: 'versions.myRelease.myDocument',
2818
+ * // _type: 'myDocument',
2819
+ * // title: 'My Document',
2820
+ * // }
2821
+ * ```
2822
+ *
2823
+ * @example Creating a new version of a published document with a specified version ID
2824
+ * ```ts
2825
+ * client.observable.createVersion({
2826
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
2827
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
2828
+ * })
2829
+ *
2830
+ * // The following document will be created:
2831
+ * // {
2832
+ * // _id: 'versions.myRelease.myDocument',
2833
+ * // _type: 'myDocument',
2834
+ * // title: 'My Document',
2835
+ * // }
2836
+ * ```
2837
+ *
2838
+ * @example Creating a new draft version of a published document
2839
+ * ```ts
2840
+ * client.observable.createVersion({
2841
+ * document: {_type: 'myDocument', title: 'My Document'},
2842
+ * publishedId: 'myDocument',
2843
+ * })
2844
+ *
2845
+ * // The following document will be created:
2846
+ * // {
2847
+ * // _id: 'drafts.myDocument',
2848
+ * // _type: 'myDocument',
2849
+ * // title: 'My Document',
2850
+ * // }
2851
+ * ```
2852
+ */
2853
+ createVersion<R extends Record<string, Any>>(
2854
+ args: {
2855
+ document: SanityDocumentStub<R>
2856
+ publishedId: string
2857
+ releaseId?: string
2858
+ },
2859
+ options?: BaseActionOptions,
2860
+ ): Observable<SingleActionResult | MultipleActionResult>
2861
+ createVersion<R extends Record<string, Any>>(
2862
+ args: {
2863
+ document: IdentifiedSanityDocumentStub<R>
2864
+ publishedId?: string
2865
+ releaseId?: string
2866
+ },
2867
+ options?: BaseActionOptions,
2868
+ ): Observable<SingleActionResult | MultipleActionResult>
2405
2869
  /**
2406
2870
  * Deletes a document with the given document ID.
2407
2871
  * Returns an observable that resolves to the deleted document.
@@ -2506,6 +2970,157 @@ export declare class ObservableSanityClient {
2506
2970
  selection: MutationSelection,
2507
2971
  options?: BaseMutationOptions,
2508
2972
  ): Observable<SanityDocument<R>>
2973
+ /**
2974
+ * @public
2975
+ *
2976
+ * Deletes the draft or release version of a document.
2977
+ *
2978
+ * @remarks
2979
+ * * Discarding a version with no `releaseId` will discard the draft version of the published document.
2980
+ * * If the draft or release version does not exist, any error will throw.
2981
+ *
2982
+ * @param params - Version action parameters:
2983
+ * - `releaseId` - The ID of the release to discard the document from.
2984
+ * - `publishedId` - The published ID of the document to discard.
2985
+ * @param purge - if `true` the document history is also discarded.
2986
+ * @param options - Additional action options.
2987
+ * @returns an observable that resolves to the `transactionId`.
2988
+ *
2989
+ * @example Discarding a release version of a document
2990
+ * ```ts
2991
+ * client.observable.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
2992
+ * // The document with the ID `versions.myRelease.myDocument` will be discarded.
2993
+ * ```
2994
+ *
2995
+ * @example Discarding a draft version of a document
2996
+ * ```ts
2997
+ * client.observable.discardVersion({publishedId: 'myDocument'})
2998
+ * // The document with the ID `drafts.myDocument` will be discarded.
2999
+ * ```
3000
+ */
3001
+ discardVersion(
3002
+ {
3003
+ releaseId,
3004
+ publishedId,
3005
+ }: {
3006
+ releaseId?: string
3007
+ publishedId: string
3008
+ },
3009
+ purge?: boolean,
3010
+ options?: BaseActionOptions,
3011
+ ): Observable<SingleActionResult | MultipleActionResult>
3012
+ /**
3013
+ * @public
3014
+ *
3015
+ * Replaces an existing version document.
3016
+ *
3017
+ * @remarks
3018
+ * * Requires a document with a `_type` property.
3019
+ * * 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`.
3020
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
3021
+ * * Replacing a version with no `releaseId` will replace the draft version of the published document.
3022
+ * * At least one of the **version** or **published** documents must exist.
3023
+ *
3024
+ * @param params - Version action parameters:
3025
+ * - `document` - The new document to replace the version with.
3026
+ * - `releaseId` - The ID of the release where the document version is replaced.
3027
+ * - `publishedId` - The ID of the published document to replace.
3028
+ * @param options - Additional action options.
3029
+ * @returns an observable that resolves to the `transactionId`.
3030
+ *
3031
+ * @example Replacing a release version of a published document with a generated version ID
3032
+ * ```ts
3033
+ * client.observable.replaceVersion({
3034
+ * document: {_type: 'myDocument', title: 'My Document'},
3035
+ * publishedId: 'myDocument',
3036
+ * releaseId: 'myRelease',
3037
+ * })
3038
+ *
3039
+ * // The following document will be patched:
3040
+ * // {
3041
+ * // _id: 'versions.myRelease.myDocument',
3042
+ * // _type: 'myDocument',
3043
+ * // title: 'My Document',
3044
+ * // }
3045
+ * ```
3046
+ *
3047
+ * @example Replacing a release version of a published document with a specified version ID
3048
+ * ```ts
3049
+ * client.observable.replaceVersion({
3050
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
3051
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
3052
+ * })
3053
+ *
3054
+ * // The following document will be patched:
3055
+ * // {
3056
+ * // _id: 'versions.myRelease.myDocument',
3057
+ * // _type: 'myDocument',
3058
+ * // title: 'My Document',
3059
+ * // }
3060
+ * ```
3061
+ *
3062
+ * @example Replacing a draft version of a published document
3063
+ * ```ts
3064
+ * client.observable.replaceVersion({
3065
+ * document: {_type: 'myDocument', title: 'My Document'},
3066
+ * publishedId: 'myDocument',
3067
+ * })
3068
+ *
3069
+ * // The following document will be patched:
3070
+ * // {
3071
+ * // _id: 'drafts.myDocument',
3072
+ * // _type: 'myDocument',
3073
+ * // title: 'My Document',
3074
+ * // }
3075
+ * ```
3076
+ */
3077
+ replaceVersion<R extends Record<string, Any>>(
3078
+ args: {
3079
+ document: SanityDocumentStub<R>
3080
+ publishedId: string
3081
+ releaseId?: string
3082
+ },
3083
+ options?: BaseActionOptions,
3084
+ ): Observable<SingleActionResult | MultipleActionResult>
3085
+ replaceVersion<R extends Record<string, Any>>(
3086
+ args: {
3087
+ document: IdentifiedSanityDocumentStub<R>
3088
+ publishedId?: string
3089
+ releaseId?: string
3090
+ },
3091
+ options?: BaseActionOptions,
3092
+ ): Observable<SingleActionResult | MultipleActionResult>
3093
+ /**
3094
+ * @public
3095
+ *
3096
+ * Used to indicate when a document within a release should be unpublished when
3097
+ * the release is run.
3098
+ *
3099
+ * @remarks
3100
+ * * If the published document does not exist, an error will be thrown.
3101
+ *
3102
+ * @param params - Version action parameters:
3103
+ * - `releaseId` - The ID of the release to unpublish the document from.
3104
+ * - `publishedId` - The published ID of the document to unpublish.
3105
+ * @param options - Additional action options.
3106
+ * @returns an observable that resolves to the `transactionId`.
3107
+ *
3108
+ * @example Unpublishing a release version of a published document
3109
+ * ```ts
3110
+ * client.observable.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
3111
+ * // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
3112
+ * ```
3113
+ */
3114
+ unpublishVersion(
3115
+ {
3116
+ releaseId,
3117
+ publishedId,
3118
+ }: {
3119
+ releaseId: string
3120
+ publishedId: string
3121
+ },
3122
+ options?: BaseActionOptions,
3123
+ ): Observable<SingleActionResult | MultipleActionResult>
2509
3124
  /**
2510
3125
  * Perform mutation operations against the configured dataset
2511
3126
  * Returns an observable that resolves to the first mutated document.
@@ -2707,6 +3322,9 @@ export declare type OpenEvent = {
2707
3322
  type: 'open'
2708
3323
  }
2709
3324
 
3325
+ /** @internal */
3326
+ export declare type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>
3327
+
2710
3328
  /** @public */
2711
3329
  export declare class Patch extends BasePatch {
2712
3330
  #private
@@ -2844,6 +3462,16 @@ export declare type PublishAction = {
2844
3462
  ifPublishedRevisionId?: string
2845
3463
  }
2846
3464
 
3465
+ /**
3466
+ * Publishes all documents in a release at once.
3467
+ *
3468
+ * @public
3469
+ */
3470
+ export declare interface PublishReleaseAction {
3471
+ actionType: 'sanity.action.release.publish'
3472
+ releaseId: string
3473
+ }
3474
+
2847
3475
  /** @public */
2848
3476
  export declare type QueryOptions =
2849
3477
  | FilteredResponseQueryOptions
@@ -2942,17 +3570,373 @@ export declare type ReconnectEvent = {
2942
3570
  type: 'reconnect'
2943
3571
  }
2944
3572
 
3573
+ /** @public */
3574
+ export declare type ReleaseAction =
3575
+ | CreateReleaseAction
3576
+ | EditReleaseAction
3577
+ | PublishReleaseAction
3578
+ | ArchiveReleaseAction
3579
+ | UnarchiveReleaseAction
3580
+ | ScheduleReleaseAction
3581
+ | UnscheduleReleaseAction
3582
+ | DeleteReleaseAction
3583
+
3584
+ /** @internal */
3585
+ export declare interface ReleaseDocument extends SanityDocument {
3586
+ /**
3587
+ * typically
3588
+ * `_.releases.<name>`
3589
+ */
3590
+ _id: string
3591
+ /**
3592
+ * where a release has _id `_.releases.foo`, the name is `foo`
3593
+ */
3594
+ name: string
3595
+ _type: 'system.release'
3596
+ _createdAt: string
3597
+ _updatedAt: string
3598
+ _rev: string
3599
+ state: ReleaseState
3600
+ error?: {
3601
+ message: string
3602
+ }
3603
+ finalDocumentStates?: {
3604
+ /** Document ID */
3605
+ id: string
3606
+ }[]
3607
+ /**
3608
+ * If defined, it takes precedence over the intendedPublishAt, the state should be 'scheduled'
3609
+ */
3610
+ publishAt?: string
3611
+ /**
3612
+ * If defined, it provides the time the release was actually published
3613
+ */
3614
+ publishedAt?: string
3615
+ metadata: {
3616
+ title?: string
3617
+ description?: string
3618
+ intendedPublishAt?: string
3619
+ releaseType: ReleaseType
3620
+ }
3621
+ }
3622
+
2945
3623
  /**
2946
3624
  * @public
2947
3625
  * @deprecated – The `r`-prefix is not required, use `string` instead
2948
3626
  */
2949
3627
  export declare type ReleaseId = `r${string}`
2950
3628
 
3629
+ /** @public */
3630
+ declare class ReleasesClient {
3631
+ #private
3632
+ constructor(client: SanityClient, httpRequest: HttpRequest)
3633
+ /**
3634
+ * @public
3635
+ *
3636
+ * Retrieve a release by id.
3637
+ *
3638
+ * @category Releases
3639
+ *
3640
+ * @param params - Release action parameters:
3641
+ * - `releaseId` - The id of the release to retrieve.
3642
+ * @param options - Additional query options including abort signal and query tag.
3643
+ * @returns A promise that resolves to the release document {@link ReleaseDocument}.
3644
+ *
3645
+ * @example Retrieving a release by id
3646
+ * ```ts
3647
+ * const release = await client.releases.get({releaseId: 'my-release'})
3648
+ * console.log(release)
3649
+ * // {
3650
+ * // _id: '_.releases.my-release',
3651
+ * // name: 'my-release'
3652
+ * // _type: 'system.release',
3653
+ * // metadata: {releaseType: 'asap'},
3654
+ * // _createdAt: '2021-01-01T00:00:00.000Z',
3655
+ * // ...
3656
+ * // }
3657
+ * ```
3658
+ */
3659
+ get(
3660
+ {
3661
+ releaseId,
3662
+ }: {
3663
+ releaseId: string
3664
+ },
3665
+ options?: {
3666
+ signal?: AbortSignal
3667
+ tag?: string
3668
+ },
3669
+ ): Promise<ReleaseDocument | undefined>
3670
+ /**
3671
+ * @public
3672
+ *
3673
+ * Creates a new release under the given id, with metadata.
3674
+ *
3675
+ * @remarks
3676
+ * * If no releaseId is provided, a release id will be generated.
3677
+ * * If no metadata is provided, then an `undecided` releaseType will be used.
3678
+ *
3679
+ * @category Releases
3680
+ *
3681
+ * @param params - Release action parameters:
3682
+ * - `releaseId` - The id of the release to create.
3683
+ * - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
3684
+ * @param options - Additional action options.
3685
+ * @returns A promise that resolves to the `transactionId` and the release id and metadata.
3686
+ *
3687
+ * @example Creating a release with a custom id and metadata
3688
+ * ```ts
3689
+ * const releaseId = 'my-release'
3690
+ * const releaseMetadata: ReleaseDocument['metadata'] = {
3691
+ * releaseType: 'asap',
3692
+ * }
3693
+ *
3694
+ * const result =
3695
+ * await client.releases.create({releaseId, metadata: releaseMetadata})
3696
+ * console.log(result)
3697
+ * // {
3698
+ * // transactionId: 'transaction-id',
3699
+ * // releaseId: 'my-release',
3700
+ * // metadata: {releaseType: 'asap'},
3701
+ * // }
3702
+ * ```
3703
+ *
3704
+ * @example Creating a release with generated id and metadata
3705
+ * ```ts
3706
+ * const {metadata} = await client.releases.create()
3707
+ * console.log(metadata.releaseType) // 'undecided'
3708
+ * ```
3709
+ *
3710
+ * @example Creating a release with a custom transaction id
3711
+ * ```ts
3712
+ * const {transactionId, metadata} = await client.releases.create({transactionId: 'my-transaction-id'})
3713
+ * console.log(metadata.releaseType) // 'undecided'
3714
+ * console.log(transactionId) // 'my-transaction-id'
3715
+ * ```
3716
+ */
3717
+ create(options: BaseActionOptions): Promise<
3718
+ SingleActionResult & {
3719
+ releaseId: string
3720
+ metadata: ReleaseDocument['metadata']
3721
+ }
3722
+ >
3723
+ create(
3724
+ release: {
3725
+ releaseId?: string
3726
+ metadata?: Partial<ReleaseDocument['metadata']>
3727
+ },
3728
+ options?: BaseActionOptions,
3729
+ ): Promise<
3730
+ SingleActionResult & {
3731
+ releaseId: string
3732
+ metadata: ReleaseDocument['metadata']
3733
+ }
3734
+ >
3735
+ /**
3736
+ * @public
3737
+ *
3738
+ * Edits an existing release, updating the metadata.
3739
+ *
3740
+ * @category Releases
3741
+ *
3742
+ * @param params - Release action parameters:
3743
+ * - `releaseId` - The id of the release to edit.
3744
+ * - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
3745
+ * @param options - Additional action options.
3746
+ * @returns A promise that resolves to the `transactionId`.
3747
+ */
3748
+ edit(
3749
+ {
3750
+ releaseId,
3751
+ patch,
3752
+ }: {
3753
+ releaseId: string
3754
+ patch: PatchOperations
3755
+ },
3756
+ options?: BaseActionOptions,
3757
+ ): Promise<SingleActionResult>
3758
+ /**
3759
+ * @public
3760
+ *
3761
+ * Publishes all documents in a release at once. For larger releases the effect of the publish
3762
+ * will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
3763
+ * documents and creation of the corresponding published documents with the new content may
3764
+ * take some time.
3765
+ *
3766
+ * During this period both the source and target documents are locked and cannot be
3767
+ * modified through any other means.
3768
+ *
3769
+ * @category Releases
3770
+ *
3771
+ * @param params - Release action parameters:
3772
+ * - `releaseId` - The id of the release to publish.
3773
+ * @param options - Additional action options.
3774
+ * @returns A promise that resolves to the `transactionId`.
3775
+ */
3776
+ publish(
3777
+ {
3778
+ releaseId,
3779
+ }: {
3780
+ releaseId: string
3781
+ },
3782
+ options?: BaseActionOptions,
3783
+ ): Promise<SingleActionResult>
3784
+ /**
3785
+ * @public
3786
+ *
3787
+ * An archive action removes an active release. The documents that comprise the release
3788
+ * are deleted and therefore no longer queryable.
3789
+ *
3790
+ * While the documents remain in retention the last version can still be accessed using document history endpoint.
3791
+ *
3792
+ * @category Releases
3793
+ *
3794
+ * @param params - Release action parameters:
3795
+ * - `releaseId` - The id of the release to archive.
3796
+ * @param options - Additional action options.
3797
+ * @returns A promise that resolves to the `transactionId`.
3798
+ */
3799
+ archive(
3800
+ {
3801
+ releaseId,
3802
+ }: {
3803
+ releaseId: string
3804
+ },
3805
+ options?: BaseActionOptions,
3806
+ ): Promise<SingleActionResult>
3807
+ /**
3808
+ * @public
3809
+ *
3810
+ * An unarchive action restores an archived release and all documents
3811
+ * with the content they had just prior to archiving.
3812
+ *
3813
+ * @category Releases
3814
+ *
3815
+ * @param params - Release action parameters:
3816
+ * - `releaseId` - The id of the release to unarchive.
3817
+ * @param options - Additional action options.
3818
+ * @returns A promise that resolves to the `transactionId`.
3819
+ */
3820
+ unarchive(
3821
+ {
3822
+ releaseId,
3823
+ }: {
3824
+ releaseId: string
3825
+ },
3826
+ options?: BaseActionOptions,
3827
+ ): Promise<SingleActionResult>
3828
+ /**
3829
+ * @public
3830
+ *
3831
+ * A schedule action queues a release for publishing at the given future time.
3832
+ * The release is locked such that no documents in the release can be modified and
3833
+ * no documents that it references can be deleted as this would make the publish fail.
3834
+ * At the given time, the same logic as for the publish action is triggered.
3835
+ *
3836
+ * @category Releases
3837
+ *
3838
+ * @param params - Release action parameters:
3839
+ * - `releaseId` - The id of the release to schedule.
3840
+ * - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
3841
+ * @param options - Additional action options.
3842
+ * @returns A promise that resolves to the `transactionId`.
3843
+ */
3844
+ schedule(
3845
+ {
3846
+ releaseId,
3847
+ publishAt,
3848
+ }: {
3849
+ releaseId: string
3850
+ publishAt: string
3851
+ },
3852
+ options?: BaseActionOptions,
3853
+ ): Promise<SingleActionResult>
3854
+ /**
3855
+ * @public
3856
+ *
3857
+ * An unschedule action stops a release from being published.
3858
+ * The documents in the release are considered unlocked and can be edited again.
3859
+ * This may fail if another release is scheduled to be published after this one and
3860
+ * has a reference to a document created by this one.
3861
+ *
3862
+ * @category Releases
3863
+ *
3864
+ * @param params - Release action parameters:
3865
+ * - `releaseId` - The id of the release to unschedule.
3866
+ * @param options - Additional action options.
3867
+ * @returns A promise that resolves to the `transactionId`.
3868
+ */
3869
+ unschedule(
3870
+ {
3871
+ releaseId,
3872
+ }: {
3873
+ releaseId: string
3874
+ },
3875
+ options?: BaseActionOptions,
3876
+ ): Promise<SingleActionResult>
3877
+ /**
3878
+ * @public
3879
+ *
3880
+ * A delete action removes a published or archived release.
3881
+ * The backing system document will be removed from the dataset.
3882
+ *
3883
+ * @category Releases
3884
+ *
3885
+ * @param params - Release action parameters:
3886
+ * - `releaseId` - The id of the release to delete.
3887
+ * @param options - Additional action options.
3888
+ * @returns A promise that resolves to the `transactionId`.
3889
+ */
3890
+ delete(
3891
+ {
3892
+ releaseId,
3893
+ }: {
3894
+ releaseId: string
3895
+ },
3896
+ options?: BaseActionOptions,
3897
+ ): Promise<SingleActionResult>
3898
+ /**
3899
+ * @public
3900
+ *
3901
+ * Fetch the documents in a release by release id.
3902
+ *
3903
+ * @category Releases
3904
+ *
3905
+ * @param params - Release action parameters:
3906
+ * - `releaseId` - The id of the release to fetch documents for.
3907
+ * @param options - Additional mutation options {@link BaseMutationOptions}.
3908
+ * @returns A promise that resolves to the documents in the release.
3909
+ */
3910
+ fetchDocuments(
3911
+ {
3912
+ releaseId,
3913
+ }: {
3914
+ releaseId: string
3915
+ },
3916
+ options?: BaseMutationOptions,
3917
+ ): Promise<RawQueryResponse<SanityDocument[]>>
3918
+ }
3919
+
3920
+ /** @beta */
3921
+ export declare type ReleaseState =
3922
+ | 'active'
3923
+ | 'archiving'
3924
+ | 'unarchiving'
3925
+ | 'archived'
3926
+ | 'published'
3927
+ | 'publishing'
3928
+ | 'scheduled'
3929
+ | 'scheduling'
3930
+
3931
+ /** @internal */
3932
+ export declare type ReleaseType = 'asap' | 'scheduled' | 'undecided'
3933
+
2951
3934
  /**
2952
3935
  * Replaces an existing draft document.
2953
3936
  * At least one of the draft or published versions of the document must exist.
2954
3937
  *
2955
3938
  * @public
3939
+ * @deprecated Use {@link ReplaceVersionAction} instead
2956
3940
  */
2957
3941
  export declare type ReplaceDraftAction = {
2958
3942
  actionType: 'sanity.action.document.replaceDraft'
@@ -2966,6 +3950,16 @@ export declare type ReplaceDraftAction = {
2966
3950
  attributes: IdentifiedSanityDocumentStub
2967
3951
  }
2968
3952
 
3953
+ /**
3954
+ * Replace an existing version of a document.
3955
+ *
3956
+ * @public
3957
+ */
3958
+ export declare interface ReplaceVersionAction {
3959
+ actionType: 'sanity.action.document.version.replace'
3960
+ document: IdentifiedSanityDocumentStub
3961
+ }
3962
+
2969
3963
  /** @public */
2970
3964
  export declare const requester: Requester
2971
3965
 
@@ -3051,6 +4045,7 @@ export declare class SanityClient {
3051
4045
  agent: {
3052
4046
  action: AgentActionsClient
3053
4047
  }
4048
+ releases: ReleasesClient
3054
4049
  /**
3055
4050
  * Observable version of the Sanity client, with the same configuration as the promise-based one
3056
4051
  */
@@ -3147,6 +4142,7 @@ export declare class SanityClient {
3147
4142
  options?: {
3148
4143
  signal?: AbortSignal
3149
4144
  tag?: string
4145
+ releaseId?: string
3150
4146
  },
3151
4147
  ): Promise<SanityDocument<R> | undefined>
3152
4148
  /**
@@ -3330,6 +4326,90 @@ export declare class SanityClient {
3330
4326
  document: IdentifiedSanityDocumentStub<R>,
3331
4327
  options?: BaseMutationOptions,
3332
4328
  ): Promise<SanityDocument<R>>
4329
+ /**
4330
+ * @public
4331
+ *
4332
+ * Creates a new version of a published document.
4333
+ *
4334
+ * @remarks
4335
+ * * Requires a document with a `_type` property.
4336
+ * * Creating a version with no `releaseId` will create a new draft version of the published document.
4337
+ * * 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`.
4338
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
4339
+ * * To create a version of an unpublished document, use the `client.create` method.
4340
+ *
4341
+ * @category Versions
4342
+ *
4343
+ * @param params - Version action parameters:
4344
+ * - `document` - The document to create as a new version (must include `_type`).
4345
+ * - `publishedId` - The ID of the published document being versioned.
4346
+ * - `releaseId` - The ID of the release to create the version for.
4347
+ * @param options - Additional action options.
4348
+ * @returns A promise that resolves to the `transactionId`.
4349
+ *
4350
+ * @example Creating a new version of a published document with a generated version ID
4351
+ * ```ts
4352
+ * const transactionId = await client.createVersion({
4353
+ * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
4354
+ * document: {_type: 'myDocument', title: 'My Document'},
4355
+ * publishedId: 'myDocument',
4356
+ * releaseId: 'myRelease',
4357
+ * })
4358
+ *
4359
+ * // The following document will be created:
4360
+ * // {
4361
+ * // _id: 'versions.myRelease.myDocument',
4362
+ * // _type: 'myDocument',
4363
+ * // title: 'My Document',
4364
+ * // }
4365
+ * ```
4366
+ *
4367
+ * @example Creating a new version of a published document with a specified version ID
4368
+ * ```ts
4369
+ * const transactionId = await client.createVersion({
4370
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
4371
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
4372
+ * })
4373
+ *
4374
+ * // The following document will be created:
4375
+ * // {
4376
+ * // _id: 'versions.myRelease.myDocument',
4377
+ * // _type: 'myDocument',
4378
+ * // title: 'My Document',
4379
+ * // }
4380
+ * ```
4381
+ *
4382
+ * @example Creating a new draft version of a published document
4383
+ * ```ts
4384
+ * const transactionId = await client.createVersion({
4385
+ * document: {_type: 'myDocument', title: 'My Document'},
4386
+ * publishedId: 'myDocument',
4387
+ * })
4388
+ *
4389
+ * // The following document will be created:
4390
+ * // {
4391
+ * // _id: 'drafts.myDocument',
4392
+ * // _type: 'myDocument',
4393
+ * // title: 'My Document',
4394
+ * // }
4395
+ * ```
4396
+ */
4397
+ createVersion<R extends Record<string, Any>>(
4398
+ args: {
4399
+ document: SanityDocumentStub<R>
4400
+ publishedId: string
4401
+ releaseId?: string
4402
+ },
4403
+ options?: BaseActionOptions,
4404
+ ): Promise<SingleActionResult | MultipleActionResult>
4405
+ createVersion<R extends Record<string, Any>>(
4406
+ args: {
4407
+ document: IdentifiedSanityDocumentStub<R>
4408
+ publishedId?: string
4409
+ releaseId?: string
4410
+ },
4411
+ options?: BaseActionOptions,
4412
+ ): Promise<SingleActionResult | MultipleActionResult>
3333
4413
  /**
3334
4414
  * Deletes a document with the given document ID.
3335
4415
  * Returns a promise that resolves to the deleted document.
@@ -3434,6 +4514,157 @@ export declare class SanityClient {
3434
4514
  selection: MutationSelection,
3435
4515
  options?: BaseMutationOptions,
3436
4516
  ): Promise<SanityDocument<R>>
4517
+ /**
4518
+ * @public
4519
+ *
4520
+ * Deletes the draft or release version of a document.
4521
+ *
4522
+ * @remarks
4523
+ * * Discarding a version with no `releaseId` will discard the draft version of the published document.
4524
+ * * If the draft or release version does not exist, any error will throw.
4525
+ *
4526
+ * @param params - Version action parameters:
4527
+ * - `releaseId` - The ID of the release to discard the document from.
4528
+ * - `publishedId` - The published ID of the document to discard.
4529
+ * @param purge - if `true` the document history is also discarded.
4530
+ * @param options - Additional action options.
4531
+ * @returns a promise that resolves to the `transactionId`.
4532
+ *
4533
+ * @example Discarding a release version of a document
4534
+ * ```ts
4535
+ * client.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
4536
+ * // The document with the ID `versions.myRelease.myDocument` will be discarded.
4537
+ * ```
4538
+ *
4539
+ * @example Discarding a draft version of a document
4540
+ * ```ts
4541
+ * client.discardVersion({publishedId: 'myDocument'})
4542
+ * // The document with the ID `drafts.myDocument` will be discarded.
4543
+ * ```
4544
+ */
4545
+ discardVersion(
4546
+ {
4547
+ releaseId,
4548
+ publishedId,
4549
+ }: {
4550
+ releaseId?: string
4551
+ publishedId: string
4552
+ },
4553
+ purge?: boolean,
4554
+ options?: BaseActionOptions,
4555
+ ): Promise<SingleActionResult | MultipleActionResult>
4556
+ /**
4557
+ * @public
4558
+ *
4559
+ * Replaces an existing version document.
4560
+ *
4561
+ * @remarks
4562
+ * * Requires a document with a `_type` property.
4563
+ * * 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`.
4564
+ * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
4565
+ * * Replacing a version with no `releaseId` will replace the draft version of the published document.
4566
+ * * At least one of the **version** or **published** documents must exist.
4567
+ *
4568
+ * @param params - Version action parameters:
4569
+ * - `document` - The new document to replace the version with.
4570
+ * - `releaseId` - The ID of the release where the document version is replaced.
4571
+ * - `publishedId` - The ID of the published document to replace.
4572
+ * @param options - Additional action options.
4573
+ * @returns a promise that resolves to the `transactionId`.
4574
+ *
4575
+ * @example Replacing a release version of a published document with a generated version ID
4576
+ * ```ts
4577
+ * await client.replaceVersion({
4578
+ * document: {_type: 'myDocument', title: 'My Document'},
4579
+ * publishedId: 'myDocument',
4580
+ * releaseId: 'myRelease',
4581
+ * })
4582
+ *
4583
+ * // The following document will be patched:
4584
+ * // {
4585
+ * // _id: 'versions.myRelease.myDocument',
4586
+ * // _type: 'myDocument',
4587
+ * // title: 'My Document',
4588
+ * // }
4589
+ * ```
4590
+ *
4591
+ * @example Replacing a release version of a published document with a specified version ID
4592
+ * ```ts
4593
+ * await client.replaceVersion({
4594
+ * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
4595
+ * // `publishedId` and `releaseId` are not required since `document._id` has been specified
4596
+ * })
4597
+ *
4598
+ * // The following document will be patched:
4599
+ * // {
4600
+ * // _id: 'versions.myRelease.myDocument',
4601
+ * // _type: 'myDocument',
4602
+ * // title: 'My Document',
4603
+ * // }
4604
+ * ```
4605
+ *
4606
+ * @example Replacing a draft version of a published document
4607
+ * ```ts
4608
+ * await client.replaceVersion({
4609
+ * document: {_type: 'myDocument', title: 'My Document'},
4610
+ * publishedId: 'myDocument',
4611
+ * })
4612
+ *
4613
+ * // The following document will be patched:
4614
+ * // {
4615
+ * // _id: 'drafts.myDocument',
4616
+ * // _type: 'myDocument',
4617
+ * // title: 'My Document',
4618
+ * // }
4619
+ * ```
4620
+ */
4621
+ replaceVersion<R extends Record<string, Any>>(
4622
+ args: {
4623
+ document: SanityDocumentStub<R>
4624
+ publishedId: string
4625
+ releaseId?: string
4626
+ },
4627
+ options?: BaseActionOptions,
4628
+ ): Promise<SingleActionResult | MultipleActionResult>
4629
+ replaceVersion<R extends Record<string, Any>>(
4630
+ args: {
4631
+ document: IdentifiedSanityDocumentStub<R>
4632
+ publishedId?: string
4633
+ releaseId?: string
4634
+ },
4635
+ options?: BaseActionOptions,
4636
+ ): Promise<SingleActionResult | MultipleActionResult>
4637
+ /**
4638
+ * @public
4639
+ *
4640
+ * Used to indicate when a document within a release should be unpublished when
4641
+ * the release is run.
4642
+ *
4643
+ * @remarks
4644
+ * * If the published document does not exist, an error will be thrown.
4645
+ *
4646
+ * @param params - Version action parameters:
4647
+ * - `releaseId` - The ID of the release to unpublish the document from.
4648
+ * - `publishedId` - The published ID of the document to unpublish.
4649
+ * @param options - Additional action options.
4650
+ * @returns a promise that resolves to the `transactionId`.
4651
+ *
4652
+ * @example Unpublishing a release version of a published document
4653
+ * ```ts
4654
+ * await client.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
4655
+ * // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
4656
+ * ```
4657
+ */
4658
+ unpublishVersion(
4659
+ {
4660
+ releaseId,
4661
+ publishedId,
4662
+ }: {
4663
+ releaseId: string
4664
+ publishedId: string
4665
+ },
4666
+ options?: BaseActionOptions,
4667
+ ): Promise<SingleActionResult | MultipleActionResult>
3437
4668
  /**
3438
4669
  * Perform mutation operations against the configured dataset
3439
4670
  * Returns a promise that resolves to the first mutated document.
@@ -3474,7 +4705,7 @@ export declare class SanityClient {
3474
4705
  * @param operations - Mutation operations to execute
3475
4706
  * @param options - Mutation options
3476
4707
  */
3477
- mutate<R extends Record<string, Any>>(
4708
+ mutate<R extends Record<string, Any> = Record<string, Any>>(
3478
4709
  operations: Mutation<R>[] | Patch | Transaction,
3479
4710
  options: AllDocumentIdsMutationOptions,
3480
4711
  ): Promise<MultipleMutationResult>
@@ -3690,6 +4921,17 @@ export declare interface SanityUser {
3690
4921
  isCurrentUser: boolean
3691
4922
  }
3692
4923
 
4924
+ /**
4925
+ * Queues release for publishing at the given future time.
4926
+ *
4927
+ * @public
4928
+ */
4929
+ export declare interface ScheduleReleaseAction {
4930
+ actionType: 'sanity.action.release.schedule'
4931
+ releaseId: string
4932
+ publishAt: string
4933
+ }
4934
+
3693
4935
  /** @public */
3694
4936
  export declare class ServerError extends Error {
3695
4937
  response: ErrorProps['response']
@@ -4168,6 +5410,16 @@ export declare interface TranslateTargetInclude extends AgentActionTargetInclude
4168
5410
  include?: (AgentActionPathSegment | TranslateTargetInclude)[]
4169
5411
  }
4170
5412
 
5413
+ /**
5414
+ * Unarchived an `archived` release, and restores all the release documents.
5415
+ *
5416
+ * @public
5417
+ */
5418
+ export declare interface UnarchiveReleaseAction {
5419
+ actionType: 'sanity.action.release.unarchive'
5420
+ releaseId: string
5421
+ }
5422
+
4171
5423
  /** @public */
4172
5424
  export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
4173
5425
  filterResponse: false
@@ -4209,6 +5461,28 @@ export declare type UnpublishAction = {
4209
5461
  publishedId: string
4210
5462
  }
4211
5463
 
5464
+ /**
5465
+ * Identify that a version of a document should be unpublished when
5466
+ * the release that version is contained within is published.
5467
+ *
5468
+ * @public
5469
+ */
5470
+ export declare interface UnpublishVersionAction {
5471
+ actionType: 'sanity.action.document.version.unpublish'
5472
+ versionId: string
5473
+ publishedId: string
5474
+ }
5475
+
5476
+ /**
5477
+ * Unschedules a `scheduled` release, stopping it from being published.
5478
+ *
5479
+ * @public
5480
+ */
5481
+ export declare interface UnscheduleReleaseAction {
5482
+ actionType: 'sanity.action.release.unschedule'
5483
+ releaseId: string
5484
+ }
5485
+
4212
5486
  export {unstable__adapter}
4213
5487
 
4214
5488
  export {unstable__environment}
@@ -4296,6 +5570,13 @@ export declare function validateApiPerspective(
4296
5570
  perspective: unknown,
4297
5571
  ): asserts perspective is ClientPerspective
4298
5572
 
5573
+ /** @public */
5574
+ export declare type VersionAction =
5575
+ | CreateVersionAction
5576
+ | DiscardVersionAction
5577
+ | ReplaceVersionAction
5578
+ | UnpublishVersionAction
5579
+
4299
5580
  /**
4300
5581
  * The listener has been established, and will start receiving events.
4301
5582
  * Note that this is also emitted upon _reconnection_.