@sanity/client 7.1.0 → 7.2.1-agent-actions.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/README.md +516 -40
- package/dist/_chunks-cjs/config.cjs +14 -0
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +15 -1
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +765 -5
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +1483 -32
- package/dist/index.browser.d.ts +1483 -32
- package/dist/index.browser.js +767 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +754 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1483 -32
- package/dist/index.d.ts +1483 -32
- package/dist/index.js +757 -7
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +1483 -32
- package/dist/stega.browser.d.ts +1483 -32
- package/dist/stega.d.cts +1483 -32
- package/dist/stega.d.ts +1483 -32
- package/package.json +3 -1
- package/src/SanityClient.ts +592 -4
- package/src/agent/actions/AgentActionsClient.ts +11 -0
- package/src/agent/actions/commonTypes.ts +26 -16
- package/src/agent/actions/prompt.ts +150 -0
- package/src/data/dataMethods.ts +126 -2
- package/src/releases/ReleasesClient.ts +687 -0
- package/src/releases/createRelease.ts +53 -0
- package/src/types.ts +216 -0
- package/src/util/createVersionId.ts +79 -0
- package/src/validators.ts +23 -1
- package/umd/sanityClient.js +829 -4
- package/umd/sanityClient.min.js +2 -2
package/dist/stega.browser.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare type Action =
|
|
|
13
13
|
| DiscardAction
|
|
14
14
|
| PublishAction
|
|
15
15
|
| UnpublishAction
|
|
16
|
+
| VersionAction
|
|
17
|
+
| ReleaseAction
|
|
16
18
|
|
|
17
19
|
/** @internal */
|
|
18
20
|
export declare interface ActionError {
|
|
@@ -47,15 +49,27 @@ declare interface AgentActionAsync {
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
/** @beta */
|
|
50
|
-
export declare type AgentActionParam
|
|
52
|
+
export declare type AgentActionParam<
|
|
53
|
+
TParamConfig extends {
|
|
54
|
+
docIdRequired: boolean
|
|
55
|
+
} = {
|
|
56
|
+
docIdRequired: false
|
|
57
|
+
},
|
|
58
|
+
> =
|
|
51
59
|
| string
|
|
52
60
|
| ConstantAgentActionParam
|
|
53
|
-
| FieldAgentActionParam
|
|
54
|
-
| DocumentAgentActionParam
|
|
61
|
+
| FieldAgentActionParam<TParamConfig>
|
|
62
|
+
| DocumentAgentActionParam<TParamConfig>
|
|
55
63
|
| GroqAgentActionParam
|
|
56
64
|
|
|
57
65
|
/** @beta */
|
|
58
|
-
export declare type AgentActionParams
|
|
66
|
+
export declare type AgentActionParams<
|
|
67
|
+
TParamConfig extends {
|
|
68
|
+
docIdRequired: boolean
|
|
69
|
+
} = {
|
|
70
|
+
docIdRequired: false
|
|
71
|
+
},
|
|
72
|
+
> = Record<string, AgentActionParam<TParamConfig>>
|
|
59
73
|
|
|
60
74
|
/** @beta */
|
|
61
75
|
export declare type AgentActionPath = AgentActionPathSegment[]
|
|
@@ -184,6 +198,13 @@ declare class AgentActionsClient {
|
|
|
184
198
|
}
|
|
185
199
|
: IdentifiedSanityDocumentStub & DocumentShape
|
|
186
200
|
>
|
|
201
|
+
/**
|
|
202
|
+
* Run a raw instruction and return the result either as text or json
|
|
203
|
+
* @param request - prompt request
|
|
204
|
+
*/
|
|
205
|
+
prompt<DocumentShape extends Record<string, Any>>(
|
|
206
|
+
request: PromptRequest<DocumentShape>,
|
|
207
|
+
): Promise<(typeof request)['json'] extends true ? DocumentShape : string>
|
|
187
208
|
}
|
|
188
209
|
|
|
189
210
|
/** @beta */
|
|
@@ -314,6 +335,16 @@ export declare interface ApiError {
|
|
|
314
335
|
statusCode: number
|
|
315
336
|
}
|
|
316
337
|
|
|
338
|
+
/**
|
|
339
|
+
* Archives an `active` release, and deletes all the release documents.
|
|
340
|
+
*
|
|
341
|
+
* @public
|
|
342
|
+
*/
|
|
343
|
+
export declare interface ArchiveReleaseAction {
|
|
344
|
+
actionType: 'sanity.action.release.archive'
|
|
345
|
+
releaseId: string
|
|
346
|
+
}
|
|
347
|
+
|
|
317
348
|
/** @public */
|
|
318
349
|
export declare type AssetMetadataType =
|
|
319
350
|
| 'location'
|
|
@@ -986,6 +1017,29 @@ export declare type CreateAction = {
|
|
|
986
1017
|
*/
|
|
987
1018
|
export declare const createClient: (config: ClientConfig_2) => SanityClient
|
|
988
1019
|
|
|
1020
|
+
/**
|
|
1021
|
+
* Creates a new release under the given id, with metadata.
|
|
1022
|
+
*
|
|
1023
|
+
* @public
|
|
1024
|
+
*/
|
|
1025
|
+
export declare interface CreateReleaseAction {
|
|
1026
|
+
actionType: 'sanity.action.release.create'
|
|
1027
|
+
releaseId: string
|
|
1028
|
+
metadata?: Partial<ReleaseDocument['metadata']>
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Creates a new version of an existing document, attached to the release as given
|
|
1033
|
+
* by `document._id`
|
|
1034
|
+
*
|
|
1035
|
+
* @public
|
|
1036
|
+
*/
|
|
1037
|
+
export declare interface CreateVersionAction {
|
|
1038
|
+
actionType: 'sanity.action.document.version.create'
|
|
1039
|
+
publishedId: string
|
|
1040
|
+
document: IdentifiedSanityDocumentStub
|
|
1041
|
+
}
|
|
1042
|
+
|
|
989
1043
|
/** @public */
|
|
990
1044
|
export declare interface CurrentSanityUser {
|
|
991
1045
|
id: string
|
|
@@ -1081,6 +1135,16 @@ export declare type DeleteAction = {
|
|
|
1081
1135
|
purge?: boolean
|
|
1082
1136
|
}
|
|
1083
1137
|
|
|
1138
|
+
/**
|
|
1139
|
+
* Deletes a `archived` or `published` release, and all the release documents versions.
|
|
1140
|
+
*
|
|
1141
|
+
* @public
|
|
1142
|
+
*/
|
|
1143
|
+
export declare interface DeleteReleaseAction {
|
|
1144
|
+
actionType: 'sanity.action.release.delete'
|
|
1145
|
+
releaseId: string
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1084
1148
|
/**
|
|
1085
1149
|
* @deprecated use 'drafts' instead
|
|
1086
1150
|
*/
|
|
@@ -1091,6 +1155,7 @@ declare type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
|
1091
1155
|
* It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
|
|
1092
1156
|
*
|
|
1093
1157
|
* @public
|
|
1158
|
+
* @deprecated Use {@link DiscardVersionAction} instead
|
|
1094
1159
|
*/
|
|
1095
1160
|
export declare type DiscardAction = {
|
|
1096
1161
|
actionType: 'sanity.action.document.discard'
|
|
@@ -1104,6 +1169,17 @@ export declare type DiscardAction = {
|
|
|
1104
1169
|
purge?: boolean
|
|
1105
1170
|
}
|
|
1106
1171
|
|
|
1172
|
+
/**
|
|
1173
|
+
* Delete a version of a document.
|
|
1174
|
+
*
|
|
1175
|
+
* @public
|
|
1176
|
+
*/
|
|
1177
|
+
export declare interface DiscardVersionAction {
|
|
1178
|
+
actionType: 'sanity.action.document.version.discard'
|
|
1179
|
+
versionId: string
|
|
1180
|
+
purge?: boolean
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1107
1183
|
/**
|
|
1108
1184
|
* The listener has been told to explicitly disconnect.
|
|
1109
1185
|
* This is a rare situation, but may occur if the API knows reconnect attempts will fail,
|
|
@@ -1130,6 +1206,23 @@ export declare type DisconnectEvent = {
|
|
|
1130
1206
|
reason: string
|
|
1131
1207
|
}
|
|
1132
1208
|
|
|
1209
|
+
declare type DocIdParam<
|
|
1210
|
+
TParamConfig extends {
|
|
1211
|
+
docIdRequired: boolean
|
|
1212
|
+
} = {
|
|
1213
|
+
docIdRequired: false
|
|
1214
|
+
},
|
|
1215
|
+
> = TParamConfig['docIdRequired'] extends true
|
|
1216
|
+
? {
|
|
1217
|
+
documentId: string
|
|
1218
|
+
}
|
|
1219
|
+
: {
|
|
1220
|
+
/**
|
|
1221
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
1222
|
+
*/
|
|
1223
|
+
documentId?: string
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1133
1226
|
/**
|
|
1134
1227
|
*
|
|
1135
1228
|
* Includes a LLM-friendly version of the document in the instruction
|
|
@@ -1150,12 +1243,23 @@ export declare type DisconnectEvent = {
|
|
|
1150
1243
|
*
|
|
1151
1244
|
* @beta
|
|
1152
1245
|
* */
|
|
1153
|
-
export declare
|
|
1246
|
+
export declare type DocumentAgentActionParam<
|
|
1247
|
+
TParamConfig extends {
|
|
1248
|
+
docIdRequired: boolean
|
|
1249
|
+
} = {
|
|
1250
|
+
docIdRequired: false
|
|
1251
|
+
},
|
|
1252
|
+
> = {
|
|
1154
1253
|
type: 'document'
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1254
|
+
} & DocIdParam<TParamConfig>
|
|
1255
|
+
|
|
1256
|
+
/** @internal */
|
|
1257
|
+
export declare type EditableReleaseDocument = Omit<
|
|
1258
|
+
PartialExcept<ReleaseDocument, '_id'>,
|
|
1259
|
+
'metadata' | '_type'
|
|
1260
|
+
> & {
|
|
1261
|
+
_id: string
|
|
1262
|
+
metadata: Partial<ReleaseDocument['metadata']>
|
|
1159
1263
|
}
|
|
1160
1264
|
|
|
1161
1265
|
/**
|
|
@@ -1181,6 +1285,17 @@ export declare type EditAction = {
|
|
|
1181
1285
|
patch: PatchOperations
|
|
1182
1286
|
}
|
|
1183
1287
|
|
|
1288
|
+
/**
|
|
1289
|
+
* Edits an existing release, updating the metadata.
|
|
1290
|
+
*
|
|
1291
|
+
* @public
|
|
1292
|
+
*/
|
|
1293
|
+
export declare interface EditReleaseAction {
|
|
1294
|
+
actionType: 'sanity.action.release.edit'
|
|
1295
|
+
releaseId: string
|
|
1296
|
+
patch: PatchOperations
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1184
1299
|
/**
|
|
1185
1300
|
* @internal
|
|
1186
1301
|
*/
|
|
@@ -1242,17 +1357,19 @@ export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSo
|
|
|
1242
1357
|
*
|
|
1243
1358
|
* @beta
|
|
1244
1359
|
* */
|
|
1245
|
-
export declare
|
|
1360
|
+
export declare type FieldAgentActionParam<
|
|
1361
|
+
TParamConfig extends {
|
|
1362
|
+
docIdRequired: boolean
|
|
1363
|
+
} = {
|
|
1364
|
+
docIdRequired: false
|
|
1365
|
+
},
|
|
1366
|
+
> = {
|
|
1246
1367
|
type: 'field'
|
|
1247
1368
|
/**
|
|
1248
1369
|
* Examples: 'title', ['array', \{_key: 'arrayItemKey'\}, 'field']
|
|
1249
1370
|
*/
|
|
1250
1371
|
path: AgentActionPathSegment | AgentActionPath
|
|
1251
|
-
|
|
1252
|
-
* If omitted, implicitly uses the documentId of the instruction target
|
|
1253
|
-
*/
|
|
1254
|
-
documentId?: string
|
|
1255
|
-
}
|
|
1372
|
+
} & DocIdParam<TParamConfig>
|
|
1256
1373
|
|
|
1257
1374
|
/** @public */
|
|
1258
1375
|
export declare type FilterDefault = (props: {
|
|
@@ -2291,6 +2408,306 @@ export declare class ObservableProjectsClient {
|
|
|
2291
2408
|
getById(projectId: string): Observable<SanityProject>
|
|
2292
2409
|
}
|
|
2293
2410
|
|
|
2411
|
+
/** @public */
|
|
2412
|
+
declare class ObservableReleasesClient {
|
|
2413
|
+
#private
|
|
2414
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
2415
|
+
/**
|
|
2416
|
+
* @public
|
|
2417
|
+
*
|
|
2418
|
+
* Retrieve a release by id.
|
|
2419
|
+
*
|
|
2420
|
+
* @category Releases
|
|
2421
|
+
*
|
|
2422
|
+
* @param params - Release action parameters:
|
|
2423
|
+
* - `releaseId` - The id of the release to retrieve.
|
|
2424
|
+
* @param options - Additional query options including abort signal and query tag.
|
|
2425
|
+
* @returns An observable that resolves to the release document {@link ReleaseDocument}.
|
|
2426
|
+
*
|
|
2427
|
+
* @example Retrieving a release by id
|
|
2428
|
+
* ```ts
|
|
2429
|
+
* client.observable.releases.get({releaseId: 'my-release'}).pipe(
|
|
2430
|
+
* tap((release) => console.log(release)),
|
|
2431
|
+
* // {
|
|
2432
|
+
* // _id: '_.releases.my-release',
|
|
2433
|
+
* // name: 'my-release'
|
|
2434
|
+
* // _type: 'system.release',
|
|
2435
|
+
* // metadata: {releaseType: 'asap'},
|
|
2436
|
+
* // _createdAt: '2021-01-01T00:00:00.000Z',
|
|
2437
|
+
* // ...
|
|
2438
|
+
* // }
|
|
2439
|
+
* ).subscribe()
|
|
2440
|
+
* ```
|
|
2441
|
+
*/
|
|
2442
|
+
get(
|
|
2443
|
+
{
|
|
2444
|
+
releaseId,
|
|
2445
|
+
}: {
|
|
2446
|
+
releaseId: string
|
|
2447
|
+
},
|
|
2448
|
+
options?: {
|
|
2449
|
+
signal?: AbortSignal
|
|
2450
|
+
tag?: string
|
|
2451
|
+
},
|
|
2452
|
+
): Observable<ReleaseDocument | undefined>
|
|
2453
|
+
/**
|
|
2454
|
+
* @public
|
|
2455
|
+
*
|
|
2456
|
+
* Creates a new release under the given id, with metadata.
|
|
2457
|
+
*
|
|
2458
|
+
* @remarks
|
|
2459
|
+
* * If no releaseId is provided, a release id will be generated.
|
|
2460
|
+
* * If no metadata is provided, then an `undecided` releaseType will be used.
|
|
2461
|
+
*
|
|
2462
|
+
* @category Releases
|
|
2463
|
+
*
|
|
2464
|
+
* @param params - Release action parameters:
|
|
2465
|
+
* - `releaseId` - The id of the release to create.
|
|
2466
|
+
* - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
|
|
2467
|
+
* @param options - Additional action options.
|
|
2468
|
+
* @returns An observable that resolves to the `transactionId` and the release id and metadata.
|
|
2469
|
+
*
|
|
2470
|
+
* @example Creating a release with a custom id and metadata
|
|
2471
|
+
* ```ts
|
|
2472
|
+
* const releaseId = 'my-release'
|
|
2473
|
+
* const metadata: ReleaseDocument['metadata'] = {
|
|
2474
|
+
* releaseType: 'asap',
|
|
2475
|
+
* }
|
|
2476
|
+
*
|
|
2477
|
+
* client.observable.releases.create({releaseId, metadata}).pipe(
|
|
2478
|
+
* tap(({transactionId, releaseId, metadata}) => console.log(transactionId, releaseId, metadata)),
|
|
2479
|
+
* // {
|
|
2480
|
+
* // transactionId: 'transaction-id',
|
|
2481
|
+
* // releaseId: 'my-release',
|
|
2482
|
+
* // metadata: {releaseType: 'asap'},
|
|
2483
|
+
* // }
|
|
2484
|
+
* ).subscribe()
|
|
2485
|
+
* ```
|
|
2486
|
+
*
|
|
2487
|
+
* @example Creating a release with generated id and metadata
|
|
2488
|
+
* ```ts
|
|
2489
|
+
* client.observable.releases.create().pipe(
|
|
2490
|
+
* tap(({metadata}) => console.log(metadata)),
|
|
2491
|
+
* // {
|
|
2492
|
+
* // metadata: {releaseType: 'undecided'},
|
|
2493
|
+
* // }
|
|
2494
|
+
* ).subscribe()
|
|
2495
|
+
* ```
|
|
2496
|
+
*
|
|
2497
|
+
* @example Creating a release using a custom transaction id
|
|
2498
|
+
* ```ts
|
|
2499
|
+
* client.observable.releases.create({transactionId: 'my-transaction-id'}).pipe(
|
|
2500
|
+
* tap(({transactionId, metadata}) => console.log(transactionId, metadata)),
|
|
2501
|
+
* // {
|
|
2502
|
+
* // transactionId: 'my-transaction-id',
|
|
2503
|
+
* // metadata: {releaseType: 'undecided'},
|
|
2504
|
+
* // }
|
|
2505
|
+
* ).subscribe()
|
|
2506
|
+
* ```
|
|
2507
|
+
*/
|
|
2508
|
+
create(options: BaseActionOptions): Observable<
|
|
2509
|
+
SingleActionResult & {
|
|
2510
|
+
releaseId: string
|
|
2511
|
+
metadata: ReleaseDocument['metadata']
|
|
2512
|
+
}
|
|
2513
|
+
>
|
|
2514
|
+
create(
|
|
2515
|
+
release: {
|
|
2516
|
+
releaseId?: string
|
|
2517
|
+
metadata?: Partial<ReleaseDocument['metadata']>
|
|
2518
|
+
},
|
|
2519
|
+
options?: BaseActionOptions,
|
|
2520
|
+
): Observable<
|
|
2521
|
+
SingleActionResult & {
|
|
2522
|
+
releaseId: string
|
|
2523
|
+
metadata: ReleaseDocument['metadata']
|
|
2524
|
+
}
|
|
2525
|
+
>
|
|
2526
|
+
/**
|
|
2527
|
+
* @public
|
|
2528
|
+
*
|
|
2529
|
+
* Edits an existing release, updating the metadata.
|
|
2530
|
+
*
|
|
2531
|
+
* @category Releases
|
|
2532
|
+
*
|
|
2533
|
+
* @param params - Release action parameters:
|
|
2534
|
+
* - `releaseId` - The id of the release to edit.
|
|
2535
|
+
* - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
|
|
2536
|
+
* @param options - Additional action options.
|
|
2537
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2538
|
+
*/
|
|
2539
|
+
edit(
|
|
2540
|
+
{
|
|
2541
|
+
releaseId,
|
|
2542
|
+
patch,
|
|
2543
|
+
}: {
|
|
2544
|
+
releaseId: string
|
|
2545
|
+
patch: PatchOperations
|
|
2546
|
+
},
|
|
2547
|
+
options?: BaseActionOptions,
|
|
2548
|
+
): Observable<SingleActionResult>
|
|
2549
|
+
/**
|
|
2550
|
+
* @public
|
|
2551
|
+
*
|
|
2552
|
+
* Publishes all documents in a release at once. For larger releases the effect of the publish
|
|
2553
|
+
* will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
|
|
2554
|
+
* documents and creation of the corresponding published documents with the new content may
|
|
2555
|
+
* take some time.
|
|
2556
|
+
*
|
|
2557
|
+
* During this period both the source and target documents are locked and cannot be
|
|
2558
|
+
* modified through any other means.
|
|
2559
|
+
*
|
|
2560
|
+
* @category Releases
|
|
2561
|
+
*
|
|
2562
|
+
* @param params - Release action parameters:
|
|
2563
|
+
* - `releaseId` - The id of the release to publish.
|
|
2564
|
+
* @param options - Additional action options.
|
|
2565
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2566
|
+
*/
|
|
2567
|
+
publish(
|
|
2568
|
+
{
|
|
2569
|
+
releaseId,
|
|
2570
|
+
}: {
|
|
2571
|
+
releaseId: string
|
|
2572
|
+
},
|
|
2573
|
+
options?: BaseActionOptions,
|
|
2574
|
+
): Observable<SingleActionResult>
|
|
2575
|
+
/**
|
|
2576
|
+
* @public
|
|
2577
|
+
*
|
|
2578
|
+
* An archive action removes an active release. The documents that comprise the release
|
|
2579
|
+
* are deleted and therefore no longer queryable.
|
|
2580
|
+
*
|
|
2581
|
+
* While the documents remain in retention the last version can still be accessed using document history endpoint.
|
|
2582
|
+
*
|
|
2583
|
+
* @category Releases
|
|
2584
|
+
*
|
|
2585
|
+
* @param params - Release action parameters:
|
|
2586
|
+
* - `releaseId` - The id of the release to archive.
|
|
2587
|
+
* @param options - Additional action options.
|
|
2588
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2589
|
+
*/
|
|
2590
|
+
archive(
|
|
2591
|
+
{
|
|
2592
|
+
releaseId,
|
|
2593
|
+
}: {
|
|
2594
|
+
releaseId: string
|
|
2595
|
+
},
|
|
2596
|
+
options?: BaseActionOptions,
|
|
2597
|
+
): Observable<SingleActionResult>
|
|
2598
|
+
/**
|
|
2599
|
+
* @public
|
|
2600
|
+
*
|
|
2601
|
+
* An unarchive action restores an archived release and all documents
|
|
2602
|
+
* with the content they had just prior to archiving.
|
|
2603
|
+
*
|
|
2604
|
+
* @category Releases
|
|
2605
|
+
*
|
|
2606
|
+
* @param params - Release action parameters:
|
|
2607
|
+
* - `releaseId` - The id of the release to unarchive.
|
|
2608
|
+
* @param options - Additional action options.
|
|
2609
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2610
|
+
*/
|
|
2611
|
+
unarchive(
|
|
2612
|
+
{
|
|
2613
|
+
releaseId,
|
|
2614
|
+
}: {
|
|
2615
|
+
releaseId: string
|
|
2616
|
+
},
|
|
2617
|
+
options?: BaseActionOptions,
|
|
2618
|
+
): Observable<SingleActionResult>
|
|
2619
|
+
/**
|
|
2620
|
+
* @public
|
|
2621
|
+
*
|
|
2622
|
+
* A schedule action queues a release for publishing at the given future time.
|
|
2623
|
+
* The release is locked such that no documents in the release can be modified and
|
|
2624
|
+
* no documents that it references can be deleted as this would make the publish fail.
|
|
2625
|
+
* At the given time, the same logic as for the publish action is triggered.
|
|
2626
|
+
*
|
|
2627
|
+
* @category Releases
|
|
2628
|
+
*
|
|
2629
|
+
* @param params - Release action parameters:
|
|
2630
|
+
* - `releaseId` - The id of the release to schedule.
|
|
2631
|
+
* - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
|
|
2632
|
+
* @param options - Additional action options.
|
|
2633
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2634
|
+
*/
|
|
2635
|
+
schedule(
|
|
2636
|
+
{
|
|
2637
|
+
releaseId,
|
|
2638
|
+
publishAt,
|
|
2639
|
+
}: {
|
|
2640
|
+
releaseId: string
|
|
2641
|
+
publishAt: string
|
|
2642
|
+
},
|
|
2643
|
+
options?: BaseActionOptions,
|
|
2644
|
+
): Observable<SingleActionResult>
|
|
2645
|
+
/**
|
|
2646
|
+
* @public
|
|
2647
|
+
*
|
|
2648
|
+
* An unschedule action stops a release from being published.
|
|
2649
|
+
* The documents in the release are considered unlocked and can be edited again.
|
|
2650
|
+
* This may fail if another release is scheduled to be published after this one and
|
|
2651
|
+
* has a reference to a document created by this one.
|
|
2652
|
+
*
|
|
2653
|
+
* @category Releases
|
|
2654
|
+
*
|
|
2655
|
+
* @param params - Release action parameters:
|
|
2656
|
+
* - `releaseId` - The id of the release to unschedule.
|
|
2657
|
+
* @param options - Additional action options.
|
|
2658
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2659
|
+
*/
|
|
2660
|
+
unschedule(
|
|
2661
|
+
{
|
|
2662
|
+
releaseId,
|
|
2663
|
+
}: {
|
|
2664
|
+
releaseId: string
|
|
2665
|
+
},
|
|
2666
|
+
options?: BaseActionOptions,
|
|
2667
|
+
): Observable<SingleActionResult>
|
|
2668
|
+
/**
|
|
2669
|
+
* @public
|
|
2670
|
+
*
|
|
2671
|
+
* A delete action removes a published or archived release.
|
|
2672
|
+
* The backing system document will be removed from the dataset.
|
|
2673
|
+
*
|
|
2674
|
+
* @category Releases
|
|
2675
|
+
*
|
|
2676
|
+
* @param params - Release action parameters:
|
|
2677
|
+
* - `releaseId` - The id of the release to delete.
|
|
2678
|
+
* @param options - Additional action options.
|
|
2679
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2680
|
+
*/
|
|
2681
|
+
delete(
|
|
2682
|
+
{
|
|
2683
|
+
releaseId,
|
|
2684
|
+
}: {
|
|
2685
|
+
releaseId: string
|
|
2686
|
+
},
|
|
2687
|
+
options?: BaseActionOptions,
|
|
2688
|
+
): Observable<SingleActionResult>
|
|
2689
|
+
/**
|
|
2690
|
+
* @public
|
|
2691
|
+
*
|
|
2692
|
+
* Fetch the documents in a release by release id.
|
|
2693
|
+
*
|
|
2694
|
+
* @category Releases
|
|
2695
|
+
*
|
|
2696
|
+
* @param params - Release action parameters:
|
|
2697
|
+
* - `releaseId` - The id of the release to fetch documents for.
|
|
2698
|
+
* @param options - Additional mutation options {@link BaseMutationOptions}.
|
|
2699
|
+
* @returns An observable that resolves to the documents in the release.
|
|
2700
|
+
*/
|
|
2701
|
+
fetchDocuments(
|
|
2702
|
+
{
|
|
2703
|
+
releaseId,
|
|
2704
|
+
}: {
|
|
2705
|
+
releaseId: string
|
|
2706
|
+
},
|
|
2707
|
+
options?: BaseMutationOptions,
|
|
2708
|
+
): Observable<RawQueryResponse<SanityDocument[]>>
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2294
2711
|
/** @public */
|
|
2295
2712
|
export declare class ObservableSanityClient {
|
|
2296
2713
|
#private
|
|
@@ -2302,6 +2719,7 @@ export declare class ObservableSanityClient {
|
|
|
2302
2719
|
agent: {
|
|
2303
2720
|
action: ObservableAgentsActionClient
|
|
2304
2721
|
}
|
|
2722
|
+
releases: ObservableReleasesClient
|
|
2305
2723
|
/**
|
|
2306
2724
|
* Instance properties
|
|
2307
2725
|
*/
|
|
@@ -2392,7 +2810,9 @@ export declare class ObservableSanityClient {
|
|
|
2392
2810
|
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
2393
2811
|
id: string,
|
|
2394
2812
|
options?: {
|
|
2813
|
+
signal?: AbortSignal
|
|
2395
2814
|
tag?: string
|
|
2815
|
+
releaseId?: string
|
|
2396
2816
|
},
|
|
2397
2817
|
): Observable<SanityDocument<R> | undefined>
|
|
2398
2818
|
/**
|
|
@@ -2575,6 +2995,90 @@ export declare class ObservableSanityClient {
|
|
|
2575
2995
|
document: IdentifiedSanityDocumentStub<R>,
|
|
2576
2996
|
options?: BaseMutationOptions,
|
|
2577
2997
|
): Observable<SanityDocument<R>>
|
|
2998
|
+
/**
|
|
2999
|
+
* @public
|
|
3000
|
+
*
|
|
3001
|
+
* Creates a new version of a published document.
|
|
3002
|
+
*
|
|
3003
|
+
* @remarks
|
|
3004
|
+
* * Requires a document with a `_type` property.
|
|
3005
|
+
* * Creating a version with no `releaseId` will create a new draft version of the published document.
|
|
3006
|
+
* * 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`.
|
|
3007
|
+
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
3008
|
+
* * To create a version of an unpublished document, use the `client.create` method.
|
|
3009
|
+
*
|
|
3010
|
+
* @category Versions
|
|
3011
|
+
*
|
|
3012
|
+
* @param params - Version action parameters:
|
|
3013
|
+
* - `document` - The document to create as a new version (must include `_type`).
|
|
3014
|
+
* - `publishedId` - The ID of the published document being versioned.
|
|
3015
|
+
* - `releaseId` - The ID of the release to create the version for.
|
|
3016
|
+
* @param options - Additional action options.
|
|
3017
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
3018
|
+
*
|
|
3019
|
+
* @example Creating a new version of a published document with a generated version ID
|
|
3020
|
+
* ```ts
|
|
3021
|
+
* client.observable.createVersion({
|
|
3022
|
+
* // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
|
|
3023
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
3024
|
+
* publishedId: 'myDocument',
|
|
3025
|
+
* releaseId: 'myRelease',
|
|
3026
|
+
* })
|
|
3027
|
+
*
|
|
3028
|
+
* // The following document will be created:
|
|
3029
|
+
* // {
|
|
3030
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
3031
|
+
* // _type: 'myDocument',
|
|
3032
|
+
* // title: 'My Document',
|
|
3033
|
+
* // }
|
|
3034
|
+
* ```
|
|
3035
|
+
*
|
|
3036
|
+
* @example Creating a new version of a published document with a specified version ID
|
|
3037
|
+
* ```ts
|
|
3038
|
+
* client.observable.createVersion({
|
|
3039
|
+
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
3040
|
+
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
3041
|
+
* })
|
|
3042
|
+
*
|
|
3043
|
+
* // The following document will be created:
|
|
3044
|
+
* // {
|
|
3045
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
3046
|
+
* // _type: 'myDocument',
|
|
3047
|
+
* // title: 'My Document',
|
|
3048
|
+
* // }
|
|
3049
|
+
* ```
|
|
3050
|
+
*
|
|
3051
|
+
* @example Creating a new draft version of a published document
|
|
3052
|
+
* ```ts
|
|
3053
|
+
* client.observable.createVersion({
|
|
3054
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
3055
|
+
* publishedId: 'myDocument',
|
|
3056
|
+
* })
|
|
3057
|
+
*
|
|
3058
|
+
* // The following document will be created:
|
|
3059
|
+
* // {
|
|
3060
|
+
* // _id: 'drafts.myDocument',
|
|
3061
|
+
* // _type: 'myDocument',
|
|
3062
|
+
* // title: 'My Document',
|
|
3063
|
+
* // }
|
|
3064
|
+
* ```
|
|
3065
|
+
*/
|
|
3066
|
+
createVersion<R extends Record<string, Any>>(
|
|
3067
|
+
args: {
|
|
3068
|
+
document: SanityDocumentStub<R>
|
|
3069
|
+
publishedId: string
|
|
3070
|
+
releaseId?: string
|
|
3071
|
+
},
|
|
3072
|
+
options?: BaseActionOptions,
|
|
3073
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
3074
|
+
createVersion<R extends Record<string, Any>>(
|
|
3075
|
+
args: {
|
|
3076
|
+
document: IdentifiedSanityDocumentStub<R>
|
|
3077
|
+
publishedId?: string
|
|
3078
|
+
releaseId?: string
|
|
3079
|
+
},
|
|
3080
|
+
options?: BaseActionOptions,
|
|
3081
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
2578
3082
|
/**
|
|
2579
3083
|
* Deletes a document with the given document ID.
|
|
2580
3084
|
* Returns an observable that resolves to the deleted document.
|
|
@@ -2679,6 +3183,157 @@ export declare class ObservableSanityClient {
|
|
|
2679
3183
|
selection: MutationSelection,
|
|
2680
3184
|
options?: BaseMutationOptions,
|
|
2681
3185
|
): Observable<SanityDocument<R>>
|
|
3186
|
+
/**
|
|
3187
|
+
* @public
|
|
3188
|
+
*
|
|
3189
|
+
* Deletes the draft or release version of a document.
|
|
3190
|
+
*
|
|
3191
|
+
* @remarks
|
|
3192
|
+
* * Discarding a version with no `releaseId` will discard the draft version of the published document.
|
|
3193
|
+
* * If the draft or release version does not exist, any error will throw.
|
|
3194
|
+
*
|
|
3195
|
+
* @param params - Version action parameters:
|
|
3196
|
+
* - `releaseId` - The ID of the release to discard the document from.
|
|
3197
|
+
* - `publishedId` - The published ID of the document to discard.
|
|
3198
|
+
* @param purge - if `true` the document history is also discarded.
|
|
3199
|
+
* @param options - Additional action options.
|
|
3200
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
3201
|
+
*
|
|
3202
|
+
* @example Discarding a release version of a document
|
|
3203
|
+
* ```ts
|
|
3204
|
+
* client.observable.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
3205
|
+
* // The document with the ID `versions.myRelease.myDocument` will be discarded.
|
|
3206
|
+
* ```
|
|
3207
|
+
*
|
|
3208
|
+
* @example Discarding a draft version of a document
|
|
3209
|
+
* ```ts
|
|
3210
|
+
* client.observable.discardVersion({publishedId: 'myDocument'})
|
|
3211
|
+
* // The document with the ID `drafts.myDocument` will be discarded.
|
|
3212
|
+
* ```
|
|
3213
|
+
*/
|
|
3214
|
+
discardVersion(
|
|
3215
|
+
{
|
|
3216
|
+
releaseId,
|
|
3217
|
+
publishedId,
|
|
3218
|
+
}: {
|
|
3219
|
+
releaseId?: string
|
|
3220
|
+
publishedId: string
|
|
3221
|
+
},
|
|
3222
|
+
purge?: boolean,
|
|
3223
|
+
options?: BaseActionOptions,
|
|
3224
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
3225
|
+
/**
|
|
3226
|
+
* @public
|
|
3227
|
+
*
|
|
3228
|
+
* Replaces an existing version document.
|
|
3229
|
+
*
|
|
3230
|
+
* @remarks
|
|
3231
|
+
* * Requires a document with a `_type` property.
|
|
3232
|
+
* * 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`.
|
|
3233
|
+
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
3234
|
+
* * Replacing a version with no `releaseId` will replace the draft version of the published document.
|
|
3235
|
+
* * At least one of the **version** or **published** documents must exist.
|
|
3236
|
+
*
|
|
3237
|
+
* @param params - Version action parameters:
|
|
3238
|
+
* - `document` - The new document to replace the version with.
|
|
3239
|
+
* - `releaseId` - The ID of the release where the document version is replaced.
|
|
3240
|
+
* - `publishedId` - The ID of the published document to replace.
|
|
3241
|
+
* @param options - Additional action options.
|
|
3242
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
3243
|
+
*
|
|
3244
|
+
* @example Replacing a release version of a published document with a generated version ID
|
|
3245
|
+
* ```ts
|
|
3246
|
+
* client.observable.replaceVersion({
|
|
3247
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
3248
|
+
* publishedId: 'myDocument',
|
|
3249
|
+
* releaseId: 'myRelease',
|
|
3250
|
+
* })
|
|
3251
|
+
*
|
|
3252
|
+
* // The following document will be patched:
|
|
3253
|
+
* // {
|
|
3254
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
3255
|
+
* // _type: 'myDocument',
|
|
3256
|
+
* // title: 'My Document',
|
|
3257
|
+
* // }
|
|
3258
|
+
* ```
|
|
3259
|
+
*
|
|
3260
|
+
* @example Replacing a release version of a published document with a specified version ID
|
|
3261
|
+
* ```ts
|
|
3262
|
+
* client.observable.replaceVersion({
|
|
3263
|
+
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
3264
|
+
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
3265
|
+
* })
|
|
3266
|
+
*
|
|
3267
|
+
* // The following document will be patched:
|
|
3268
|
+
* // {
|
|
3269
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
3270
|
+
* // _type: 'myDocument',
|
|
3271
|
+
* // title: 'My Document',
|
|
3272
|
+
* // }
|
|
3273
|
+
* ```
|
|
3274
|
+
*
|
|
3275
|
+
* @example Replacing a draft version of a published document
|
|
3276
|
+
* ```ts
|
|
3277
|
+
* client.observable.replaceVersion({
|
|
3278
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
3279
|
+
* publishedId: 'myDocument',
|
|
3280
|
+
* })
|
|
3281
|
+
*
|
|
3282
|
+
* // The following document will be patched:
|
|
3283
|
+
* // {
|
|
3284
|
+
* // _id: 'drafts.myDocument',
|
|
3285
|
+
* // _type: 'myDocument',
|
|
3286
|
+
* // title: 'My Document',
|
|
3287
|
+
* // }
|
|
3288
|
+
* ```
|
|
3289
|
+
*/
|
|
3290
|
+
replaceVersion<R extends Record<string, Any>>(
|
|
3291
|
+
args: {
|
|
3292
|
+
document: SanityDocumentStub<R>
|
|
3293
|
+
publishedId: string
|
|
3294
|
+
releaseId?: string
|
|
3295
|
+
},
|
|
3296
|
+
options?: BaseActionOptions,
|
|
3297
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
3298
|
+
replaceVersion<R extends Record<string, Any>>(
|
|
3299
|
+
args: {
|
|
3300
|
+
document: IdentifiedSanityDocumentStub<R>
|
|
3301
|
+
publishedId?: string
|
|
3302
|
+
releaseId?: string
|
|
3303
|
+
},
|
|
3304
|
+
options?: BaseActionOptions,
|
|
3305
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
3306
|
+
/**
|
|
3307
|
+
* @public
|
|
3308
|
+
*
|
|
3309
|
+
* Used to indicate when a document within a release should be unpublished when
|
|
3310
|
+
* the release is run.
|
|
3311
|
+
*
|
|
3312
|
+
* @remarks
|
|
3313
|
+
* * If the published document does not exist, an error will be thrown.
|
|
3314
|
+
*
|
|
3315
|
+
* @param params - Version action parameters:
|
|
3316
|
+
* - `releaseId` - The ID of the release to unpublish the document from.
|
|
3317
|
+
* - `publishedId` - The published ID of the document to unpublish.
|
|
3318
|
+
* @param options - Additional action options.
|
|
3319
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
3320
|
+
*
|
|
3321
|
+
* @example Unpublishing a release version of a published document
|
|
3322
|
+
* ```ts
|
|
3323
|
+
* client.observable.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
3324
|
+
* // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
|
|
3325
|
+
* ```
|
|
3326
|
+
*/
|
|
3327
|
+
unpublishVersion(
|
|
3328
|
+
{
|
|
3329
|
+
releaseId,
|
|
3330
|
+
publishedId,
|
|
3331
|
+
}: {
|
|
3332
|
+
releaseId: string
|
|
3333
|
+
publishedId: string
|
|
3334
|
+
},
|
|
3335
|
+
options?: BaseActionOptions,
|
|
3336
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
2682
3337
|
/**
|
|
2683
3338
|
* Perform mutation operations against the configured dataset
|
|
2684
3339
|
* Returns an observable that resolves to the first mutated document.
|
|
@@ -2886,6 +3541,9 @@ export declare type OpenEvent = {
|
|
|
2886
3541
|
type: 'open'
|
|
2887
3542
|
}
|
|
2888
3543
|
|
|
3544
|
+
/** @internal */
|
|
3545
|
+
export declare type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>
|
|
3546
|
+
|
|
2889
3547
|
/** @public */
|
|
2890
3548
|
export declare class Patch extends BasePatch {
|
|
2891
3549
|
#private
|
|
@@ -2995,26 +3653,156 @@ export declare class ProjectsClient {
|
|
|
2995
3653
|
}
|
|
2996
3654
|
|
|
2997
3655
|
/**
|
|
2998
|
-
*
|
|
2999
|
-
* If a published version of the document already exists this is replaced by the current draft document.
|
|
3000
|
-
* In either case the draft document is deleted.
|
|
3001
|
-
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
3002
|
-
* that the draft and/or published versions of the document have not been changed by another client.
|
|
3003
|
-
*
|
|
3004
|
-
* @public
|
|
3656
|
+
* @beta
|
|
3005
3657
|
*/
|
|
3006
|
-
|
|
3007
|
-
actionType: 'sanity.action.document.publish'
|
|
3008
|
-
/**
|
|
3009
|
-
* Draft document ID to publish
|
|
3010
|
-
*/
|
|
3011
|
-
draftId: string
|
|
3658
|
+
declare interface PromptJsonResponse<T extends Record<string, Any> = Record<string, Any>> {
|
|
3012
3659
|
/**
|
|
3013
|
-
*
|
|
3660
|
+
*
|
|
3661
|
+
* When true, the response body will be json according to the instruction.
|
|
3662
|
+
* When false, the response is the raw text response to the instruction.
|
|
3663
|
+
*
|
|
3664
|
+
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3014
3665
|
*/
|
|
3015
|
-
|
|
3666
|
+
json: true
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
/** @beta */
|
|
3670
|
+
export declare type PromptRequest<T extends Record<string, Any> = Record<string, Any>> = (
|
|
3671
|
+
| PromptTextResponse
|
|
3672
|
+
| PromptJsonResponse<T>
|
|
3673
|
+
) &
|
|
3674
|
+
PromptRequestBase
|
|
3675
|
+
|
|
3676
|
+
/** @beta */
|
|
3677
|
+
declare interface PromptRequestBase {
|
|
3016
3678
|
/**
|
|
3017
|
-
*
|
|
3679
|
+
* Instruct the LLM how it should generate content. Be as specific and detailed as needed.
|
|
3680
|
+
*
|
|
3681
|
+
* The LLM only has access to information in the instruction, plus the target schema.
|
|
3682
|
+
*
|
|
3683
|
+
* string template using $variable
|
|
3684
|
+
* */
|
|
3685
|
+
instruction: string
|
|
3686
|
+
/**
|
|
3687
|
+
* param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable"
|
|
3688
|
+
*
|
|
3689
|
+
* ### Examples
|
|
3690
|
+
*
|
|
3691
|
+
* #### Constant
|
|
3692
|
+
*
|
|
3693
|
+
* ##### Shorthand
|
|
3694
|
+
* ```ts
|
|
3695
|
+
* client.agent.action.generate({
|
|
3696
|
+
* schemaId,
|
|
3697
|
+
* documentId,
|
|
3698
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it',
|
|
3699
|
+
* instructionParams: {
|
|
3700
|
+
* topic: 'Grapefruit'
|
|
3701
|
+
* },
|
|
3702
|
+
* })
|
|
3703
|
+
* ```
|
|
3704
|
+
* ##### Object-form
|
|
3705
|
+
*
|
|
3706
|
+
* ```ts
|
|
3707
|
+
* client.agent.action.prompt({
|
|
3708
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it.',
|
|
3709
|
+
* instructionParams: {
|
|
3710
|
+
* topic: {
|
|
3711
|
+
* type: 'constant',
|
|
3712
|
+
* value: 'Grapefruit'
|
|
3713
|
+
* },
|
|
3714
|
+
* },
|
|
3715
|
+
* })
|
|
3716
|
+
* ```
|
|
3717
|
+
* #### Field
|
|
3718
|
+
* ```ts
|
|
3719
|
+
* client.agent.action.prompt({
|
|
3720
|
+
* instruction: 'Give the following field value:\n $pte \n ---\nGenerate keywords.',
|
|
3721
|
+
* instructionParams: {
|
|
3722
|
+
* pte: {
|
|
3723
|
+
* type: 'field',
|
|
3724
|
+
* path: ['pteField'],
|
|
3725
|
+
* documentId: 'someSanityDocId'
|
|
3726
|
+
* },
|
|
3727
|
+
* },
|
|
3728
|
+
* })
|
|
3729
|
+
* ```
|
|
3730
|
+
* #### Document
|
|
3731
|
+
* ```ts
|
|
3732
|
+
* client.agent.action.prompt({
|
|
3733
|
+
* json: true,
|
|
3734
|
+
* instruction: 'Given the following document:$document\nCreate a JSON string[] array with keywords describing it.',
|
|
3735
|
+
* instructionParams: {
|
|
3736
|
+
* document: {
|
|
3737
|
+
* type: 'document',
|
|
3738
|
+
* documentId: 'someSanityDocId'
|
|
3739
|
+
* },
|
|
3740
|
+
* },
|
|
3741
|
+
* })
|
|
3742
|
+
* ```
|
|
3743
|
+
*
|
|
3744
|
+
* #### GROQ
|
|
3745
|
+
* ```ts
|
|
3746
|
+
* client.agent.action.prompt({
|
|
3747
|
+
* instruction: 'Return the best title amongst these: $titles.',
|
|
3748
|
+
* instructionParams: {
|
|
3749
|
+
* titles: {
|
|
3750
|
+
* type: 'groq',
|
|
3751
|
+
* query: '* [_type==$type].title',
|
|
3752
|
+
* params: {type: 'article'}
|
|
3753
|
+
* },
|
|
3754
|
+
* },
|
|
3755
|
+
* })
|
|
3756
|
+
* ```
|
|
3757
|
+
* */
|
|
3758
|
+
instructionParams?: AgentActionParams<{
|
|
3759
|
+
docIdRequired: true
|
|
3760
|
+
}>
|
|
3761
|
+
/**
|
|
3762
|
+
* Controls how much variance the instructions will run with.
|
|
3763
|
+
*
|
|
3764
|
+
* Value must be in the range [0, 1] (inclusive).
|
|
3765
|
+
*
|
|
3766
|
+
* Defaults:
|
|
3767
|
+
* - generate: 0.3
|
|
3768
|
+
* - translate: 0
|
|
3769
|
+
* - transform: 0
|
|
3770
|
+
*/
|
|
3771
|
+
temperature?: number
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3774
|
+
declare interface PromptTextResponse {
|
|
3775
|
+
/**
|
|
3776
|
+
*
|
|
3777
|
+
* When true, the response body will be json according to the instruction.
|
|
3778
|
+
* When false, the response is the raw text response to the instruction.
|
|
3779
|
+
*
|
|
3780
|
+
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3781
|
+
*/
|
|
3782
|
+
json?: false
|
|
3783
|
+
}
|
|
3784
|
+
|
|
3785
|
+
/**
|
|
3786
|
+
* Publishes a draft document.
|
|
3787
|
+
* If a published version of the document already exists this is replaced by the current draft document.
|
|
3788
|
+
* In either case the draft document is deleted.
|
|
3789
|
+
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
3790
|
+
* that the draft and/or published versions of the document have not been changed by another client.
|
|
3791
|
+
*
|
|
3792
|
+
* @public
|
|
3793
|
+
*/
|
|
3794
|
+
export declare type PublishAction = {
|
|
3795
|
+
actionType: 'sanity.action.document.publish'
|
|
3796
|
+
/**
|
|
3797
|
+
* Draft document ID to publish
|
|
3798
|
+
*/
|
|
3799
|
+
draftId: string
|
|
3800
|
+
/**
|
|
3801
|
+
* Draft revision ID to match
|
|
3802
|
+
*/
|
|
3803
|
+
ifDraftRevisionId?: string
|
|
3804
|
+
/**
|
|
3805
|
+
* Published document ID to replace
|
|
3018
3806
|
*/
|
|
3019
3807
|
publishedId: string
|
|
3020
3808
|
/**
|
|
@@ -3023,6 +3811,16 @@ export declare type PublishAction = {
|
|
|
3023
3811
|
ifPublishedRevisionId?: string
|
|
3024
3812
|
}
|
|
3025
3813
|
|
|
3814
|
+
/**
|
|
3815
|
+
* Publishes all documents in a release at once.
|
|
3816
|
+
*
|
|
3817
|
+
* @public
|
|
3818
|
+
*/
|
|
3819
|
+
export declare interface PublishReleaseAction {
|
|
3820
|
+
actionType: 'sanity.action.release.publish'
|
|
3821
|
+
releaseId: string
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3026
3824
|
/** @public */
|
|
3027
3825
|
export declare type QueryOptions =
|
|
3028
3826
|
| FilteredResponseQueryOptions
|
|
@@ -3121,17 +3919,373 @@ export declare type ReconnectEvent = {
|
|
|
3121
3919
|
type: 'reconnect'
|
|
3122
3920
|
}
|
|
3123
3921
|
|
|
3922
|
+
/** @public */
|
|
3923
|
+
export declare type ReleaseAction =
|
|
3924
|
+
| CreateReleaseAction
|
|
3925
|
+
| EditReleaseAction
|
|
3926
|
+
| PublishReleaseAction
|
|
3927
|
+
| ArchiveReleaseAction
|
|
3928
|
+
| UnarchiveReleaseAction
|
|
3929
|
+
| ScheduleReleaseAction
|
|
3930
|
+
| UnscheduleReleaseAction
|
|
3931
|
+
| DeleteReleaseAction
|
|
3932
|
+
|
|
3933
|
+
/** @internal */
|
|
3934
|
+
export declare interface ReleaseDocument extends SanityDocument {
|
|
3935
|
+
/**
|
|
3936
|
+
* typically
|
|
3937
|
+
* `_.releases.<name>`
|
|
3938
|
+
*/
|
|
3939
|
+
_id: string
|
|
3940
|
+
/**
|
|
3941
|
+
* where a release has _id `_.releases.foo`, the name is `foo`
|
|
3942
|
+
*/
|
|
3943
|
+
name: string
|
|
3944
|
+
_type: 'system.release'
|
|
3945
|
+
_createdAt: string
|
|
3946
|
+
_updatedAt: string
|
|
3947
|
+
_rev: string
|
|
3948
|
+
state: ReleaseState
|
|
3949
|
+
error?: {
|
|
3950
|
+
message: string
|
|
3951
|
+
}
|
|
3952
|
+
finalDocumentStates?: {
|
|
3953
|
+
/** Document ID */
|
|
3954
|
+
id: string
|
|
3955
|
+
}[]
|
|
3956
|
+
/**
|
|
3957
|
+
* If defined, it takes precedence over the intendedPublishAt, the state should be 'scheduled'
|
|
3958
|
+
*/
|
|
3959
|
+
publishAt?: string
|
|
3960
|
+
/**
|
|
3961
|
+
* If defined, it provides the time the release was actually published
|
|
3962
|
+
*/
|
|
3963
|
+
publishedAt?: string
|
|
3964
|
+
metadata: {
|
|
3965
|
+
title?: string
|
|
3966
|
+
description?: string
|
|
3967
|
+
intendedPublishAt?: string
|
|
3968
|
+
releaseType: ReleaseType
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
|
|
3124
3972
|
/**
|
|
3125
3973
|
* @public
|
|
3126
3974
|
* @deprecated – The `r`-prefix is not required, use `string` instead
|
|
3127
3975
|
*/
|
|
3128
3976
|
export declare type ReleaseId = `r${string}`
|
|
3129
3977
|
|
|
3978
|
+
/** @public */
|
|
3979
|
+
declare class ReleasesClient {
|
|
3980
|
+
#private
|
|
3981
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
3982
|
+
/**
|
|
3983
|
+
* @public
|
|
3984
|
+
*
|
|
3985
|
+
* Retrieve a release by id.
|
|
3986
|
+
*
|
|
3987
|
+
* @category Releases
|
|
3988
|
+
*
|
|
3989
|
+
* @param params - Release action parameters:
|
|
3990
|
+
* - `releaseId` - The id of the release to retrieve.
|
|
3991
|
+
* @param options - Additional query options including abort signal and query tag.
|
|
3992
|
+
* @returns A promise that resolves to the release document {@link ReleaseDocument}.
|
|
3993
|
+
*
|
|
3994
|
+
* @example Retrieving a release by id
|
|
3995
|
+
* ```ts
|
|
3996
|
+
* const release = await client.releases.get({releaseId: 'my-release'})
|
|
3997
|
+
* console.log(release)
|
|
3998
|
+
* // {
|
|
3999
|
+
* // _id: '_.releases.my-release',
|
|
4000
|
+
* // name: 'my-release'
|
|
4001
|
+
* // _type: 'system.release',
|
|
4002
|
+
* // metadata: {releaseType: 'asap'},
|
|
4003
|
+
* // _createdAt: '2021-01-01T00:00:00.000Z',
|
|
4004
|
+
* // ...
|
|
4005
|
+
* // }
|
|
4006
|
+
* ```
|
|
4007
|
+
*/
|
|
4008
|
+
get(
|
|
4009
|
+
{
|
|
4010
|
+
releaseId,
|
|
4011
|
+
}: {
|
|
4012
|
+
releaseId: string
|
|
4013
|
+
},
|
|
4014
|
+
options?: {
|
|
4015
|
+
signal?: AbortSignal
|
|
4016
|
+
tag?: string
|
|
4017
|
+
},
|
|
4018
|
+
): Promise<ReleaseDocument | undefined>
|
|
4019
|
+
/**
|
|
4020
|
+
* @public
|
|
4021
|
+
*
|
|
4022
|
+
* Creates a new release under the given id, with metadata.
|
|
4023
|
+
*
|
|
4024
|
+
* @remarks
|
|
4025
|
+
* * If no releaseId is provided, a release id will be generated.
|
|
4026
|
+
* * If no metadata is provided, then an `undecided` releaseType will be used.
|
|
4027
|
+
*
|
|
4028
|
+
* @category Releases
|
|
4029
|
+
*
|
|
4030
|
+
* @param params - Release action parameters:
|
|
4031
|
+
* - `releaseId` - The id of the release to create.
|
|
4032
|
+
* - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
|
|
4033
|
+
* @param options - Additional action options.
|
|
4034
|
+
* @returns A promise that resolves to the `transactionId` and the release id and metadata.
|
|
4035
|
+
*
|
|
4036
|
+
* @example Creating a release with a custom id and metadata
|
|
4037
|
+
* ```ts
|
|
4038
|
+
* const releaseId = 'my-release'
|
|
4039
|
+
* const releaseMetadata: ReleaseDocument['metadata'] = {
|
|
4040
|
+
* releaseType: 'asap',
|
|
4041
|
+
* }
|
|
4042
|
+
*
|
|
4043
|
+
* const result =
|
|
4044
|
+
* await client.releases.create({releaseId, metadata: releaseMetadata})
|
|
4045
|
+
* console.log(result)
|
|
4046
|
+
* // {
|
|
4047
|
+
* // transactionId: 'transaction-id',
|
|
4048
|
+
* // releaseId: 'my-release',
|
|
4049
|
+
* // metadata: {releaseType: 'asap'},
|
|
4050
|
+
* // }
|
|
4051
|
+
* ```
|
|
4052
|
+
*
|
|
4053
|
+
* @example Creating a release with generated id and metadata
|
|
4054
|
+
* ```ts
|
|
4055
|
+
* const {metadata} = await client.releases.create()
|
|
4056
|
+
* console.log(metadata.releaseType) // 'undecided'
|
|
4057
|
+
* ```
|
|
4058
|
+
*
|
|
4059
|
+
* @example Creating a release with a custom transaction id
|
|
4060
|
+
* ```ts
|
|
4061
|
+
* const {transactionId, metadata} = await client.releases.create({transactionId: 'my-transaction-id'})
|
|
4062
|
+
* console.log(metadata.releaseType) // 'undecided'
|
|
4063
|
+
* console.log(transactionId) // 'my-transaction-id'
|
|
4064
|
+
* ```
|
|
4065
|
+
*/
|
|
4066
|
+
create(options: BaseActionOptions): Promise<
|
|
4067
|
+
SingleActionResult & {
|
|
4068
|
+
releaseId: string
|
|
4069
|
+
metadata: ReleaseDocument['metadata']
|
|
4070
|
+
}
|
|
4071
|
+
>
|
|
4072
|
+
create(
|
|
4073
|
+
release: {
|
|
4074
|
+
releaseId?: string
|
|
4075
|
+
metadata?: Partial<ReleaseDocument['metadata']>
|
|
4076
|
+
},
|
|
4077
|
+
options?: BaseActionOptions,
|
|
4078
|
+
): Promise<
|
|
4079
|
+
SingleActionResult & {
|
|
4080
|
+
releaseId: string
|
|
4081
|
+
metadata: ReleaseDocument['metadata']
|
|
4082
|
+
}
|
|
4083
|
+
>
|
|
4084
|
+
/**
|
|
4085
|
+
* @public
|
|
4086
|
+
*
|
|
4087
|
+
* Edits an existing release, updating the metadata.
|
|
4088
|
+
*
|
|
4089
|
+
* @category Releases
|
|
4090
|
+
*
|
|
4091
|
+
* @param params - Release action parameters:
|
|
4092
|
+
* - `releaseId` - The id of the release to edit.
|
|
4093
|
+
* - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
|
|
4094
|
+
* @param options - Additional action options.
|
|
4095
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4096
|
+
*/
|
|
4097
|
+
edit(
|
|
4098
|
+
{
|
|
4099
|
+
releaseId,
|
|
4100
|
+
patch,
|
|
4101
|
+
}: {
|
|
4102
|
+
releaseId: string
|
|
4103
|
+
patch: PatchOperations
|
|
4104
|
+
},
|
|
4105
|
+
options?: BaseActionOptions,
|
|
4106
|
+
): Promise<SingleActionResult>
|
|
4107
|
+
/**
|
|
4108
|
+
* @public
|
|
4109
|
+
*
|
|
4110
|
+
* Publishes all documents in a release at once. For larger releases the effect of the publish
|
|
4111
|
+
* will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
|
|
4112
|
+
* documents and creation of the corresponding published documents with the new content may
|
|
4113
|
+
* take some time.
|
|
4114
|
+
*
|
|
4115
|
+
* During this period both the source and target documents are locked and cannot be
|
|
4116
|
+
* modified through any other means.
|
|
4117
|
+
*
|
|
4118
|
+
* @category Releases
|
|
4119
|
+
*
|
|
4120
|
+
* @param params - Release action parameters:
|
|
4121
|
+
* - `releaseId` - The id of the release to publish.
|
|
4122
|
+
* @param options - Additional action options.
|
|
4123
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4124
|
+
*/
|
|
4125
|
+
publish(
|
|
4126
|
+
{
|
|
4127
|
+
releaseId,
|
|
4128
|
+
}: {
|
|
4129
|
+
releaseId: string
|
|
4130
|
+
},
|
|
4131
|
+
options?: BaseActionOptions,
|
|
4132
|
+
): Promise<SingleActionResult>
|
|
4133
|
+
/**
|
|
4134
|
+
* @public
|
|
4135
|
+
*
|
|
4136
|
+
* An archive action removes an active release. The documents that comprise the release
|
|
4137
|
+
* are deleted and therefore no longer queryable.
|
|
4138
|
+
*
|
|
4139
|
+
* While the documents remain in retention the last version can still be accessed using document history endpoint.
|
|
4140
|
+
*
|
|
4141
|
+
* @category Releases
|
|
4142
|
+
*
|
|
4143
|
+
* @param params - Release action parameters:
|
|
4144
|
+
* - `releaseId` - The id of the release to archive.
|
|
4145
|
+
* @param options - Additional action options.
|
|
4146
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4147
|
+
*/
|
|
4148
|
+
archive(
|
|
4149
|
+
{
|
|
4150
|
+
releaseId,
|
|
4151
|
+
}: {
|
|
4152
|
+
releaseId: string
|
|
4153
|
+
},
|
|
4154
|
+
options?: BaseActionOptions,
|
|
4155
|
+
): Promise<SingleActionResult>
|
|
4156
|
+
/**
|
|
4157
|
+
* @public
|
|
4158
|
+
*
|
|
4159
|
+
* An unarchive action restores an archived release and all documents
|
|
4160
|
+
* with the content they had just prior to archiving.
|
|
4161
|
+
*
|
|
4162
|
+
* @category Releases
|
|
4163
|
+
*
|
|
4164
|
+
* @param params - Release action parameters:
|
|
4165
|
+
* - `releaseId` - The id of the release to unarchive.
|
|
4166
|
+
* @param options - Additional action options.
|
|
4167
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4168
|
+
*/
|
|
4169
|
+
unarchive(
|
|
4170
|
+
{
|
|
4171
|
+
releaseId,
|
|
4172
|
+
}: {
|
|
4173
|
+
releaseId: string
|
|
4174
|
+
},
|
|
4175
|
+
options?: BaseActionOptions,
|
|
4176
|
+
): Promise<SingleActionResult>
|
|
4177
|
+
/**
|
|
4178
|
+
* @public
|
|
4179
|
+
*
|
|
4180
|
+
* A schedule action queues a release for publishing at the given future time.
|
|
4181
|
+
* The release is locked such that no documents in the release can be modified and
|
|
4182
|
+
* no documents that it references can be deleted as this would make the publish fail.
|
|
4183
|
+
* At the given time, the same logic as for the publish action is triggered.
|
|
4184
|
+
*
|
|
4185
|
+
* @category Releases
|
|
4186
|
+
*
|
|
4187
|
+
* @param params - Release action parameters:
|
|
4188
|
+
* - `releaseId` - The id of the release to schedule.
|
|
4189
|
+
* - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
|
|
4190
|
+
* @param options - Additional action options.
|
|
4191
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4192
|
+
*/
|
|
4193
|
+
schedule(
|
|
4194
|
+
{
|
|
4195
|
+
releaseId,
|
|
4196
|
+
publishAt,
|
|
4197
|
+
}: {
|
|
4198
|
+
releaseId: string
|
|
4199
|
+
publishAt: string
|
|
4200
|
+
},
|
|
4201
|
+
options?: BaseActionOptions,
|
|
4202
|
+
): Promise<SingleActionResult>
|
|
4203
|
+
/**
|
|
4204
|
+
* @public
|
|
4205
|
+
*
|
|
4206
|
+
* An unschedule action stops a release from being published.
|
|
4207
|
+
* The documents in the release are considered unlocked and can be edited again.
|
|
4208
|
+
* This may fail if another release is scheduled to be published after this one and
|
|
4209
|
+
* has a reference to a document created by this one.
|
|
4210
|
+
*
|
|
4211
|
+
* @category Releases
|
|
4212
|
+
*
|
|
4213
|
+
* @param params - Release action parameters:
|
|
4214
|
+
* - `releaseId` - The id of the release to unschedule.
|
|
4215
|
+
* @param options - Additional action options.
|
|
4216
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4217
|
+
*/
|
|
4218
|
+
unschedule(
|
|
4219
|
+
{
|
|
4220
|
+
releaseId,
|
|
4221
|
+
}: {
|
|
4222
|
+
releaseId: string
|
|
4223
|
+
},
|
|
4224
|
+
options?: BaseActionOptions,
|
|
4225
|
+
): Promise<SingleActionResult>
|
|
4226
|
+
/**
|
|
4227
|
+
* @public
|
|
4228
|
+
*
|
|
4229
|
+
* A delete action removes a published or archived release.
|
|
4230
|
+
* The backing system document will be removed from the dataset.
|
|
4231
|
+
*
|
|
4232
|
+
* @category Releases
|
|
4233
|
+
*
|
|
4234
|
+
* @param params - Release action parameters:
|
|
4235
|
+
* - `releaseId` - The id of the release to delete.
|
|
4236
|
+
* @param options - Additional action options.
|
|
4237
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4238
|
+
*/
|
|
4239
|
+
delete(
|
|
4240
|
+
{
|
|
4241
|
+
releaseId,
|
|
4242
|
+
}: {
|
|
4243
|
+
releaseId: string
|
|
4244
|
+
},
|
|
4245
|
+
options?: BaseActionOptions,
|
|
4246
|
+
): Promise<SingleActionResult>
|
|
4247
|
+
/**
|
|
4248
|
+
* @public
|
|
4249
|
+
*
|
|
4250
|
+
* Fetch the documents in a release by release id.
|
|
4251
|
+
*
|
|
4252
|
+
* @category Releases
|
|
4253
|
+
*
|
|
4254
|
+
* @param params - Release action parameters:
|
|
4255
|
+
* - `releaseId` - The id of the release to fetch documents for.
|
|
4256
|
+
* @param options - Additional mutation options {@link BaseMutationOptions}.
|
|
4257
|
+
* @returns A promise that resolves to the documents in the release.
|
|
4258
|
+
*/
|
|
4259
|
+
fetchDocuments(
|
|
4260
|
+
{
|
|
4261
|
+
releaseId,
|
|
4262
|
+
}: {
|
|
4263
|
+
releaseId: string
|
|
4264
|
+
},
|
|
4265
|
+
options?: BaseMutationOptions,
|
|
4266
|
+
): Promise<RawQueryResponse<SanityDocument[]>>
|
|
4267
|
+
}
|
|
4268
|
+
|
|
4269
|
+
/** @beta */
|
|
4270
|
+
export declare type ReleaseState =
|
|
4271
|
+
| 'active'
|
|
4272
|
+
| 'archiving'
|
|
4273
|
+
| 'unarchiving'
|
|
4274
|
+
| 'archived'
|
|
4275
|
+
| 'published'
|
|
4276
|
+
| 'publishing'
|
|
4277
|
+
| 'scheduled'
|
|
4278
|
+
| 'scheduling'
|
|
4279
|
+
|
|
4280
|
+
/** @internal */
|
|
4281
|
+
export declare type ReleaseType = 'asap' | 'scheduled' | 'undecided'
|
|
4282
|
+
|
|
3130
4283
|
/**
|
|
3131
4284
|
* Replaces an existing draft document.
|
|
3132
4285
|
* At least one of the draft or published versions of the document must exist.
|
|
3133
4286
|
*
|
|
3134
4287
|
* @public
|
|
4288
|
+
* @deprecated Use {@link ReplaceVersionAction} instead
|
|
3135
4289
|
*/
|
|
3136
4290
|
export declare type ReplaceDraftAction = {
|
|
3137
4291
|
actionType: 'sanity.action.document.replaceDraft'
|
|
@@ -3145,6 +4299,16 @@ export declare type ReplaceDraftAction = {
|
|
|
3145
4299
|
attributes: IdentifiedSanityDocumentStub
|
|
3146
4300
|
}
|
|
3147
4301
|
|
|
4302
|
+
/**
|
|
4303
|
+
* Replace an existing version of a document.
|
|
4304
|
+
*
|
|
4305
|
+
* @public
|
|
4306
|
+
*/
|
|
4307
|
+
export declare interface ReplaceVersionAction {
|
|
4308
|
+
actionType: 'sanity.action.document.version.replace'
|
|
4309
|
+
document: IdentifiedSanityDocumentStub
|
|
4310
|
+
}
|
|
4311
|
+
|
|
3148
4312
|
/**
|
|
3149
4313
|
* @deprecated -- Use `import {requester} from '@sanity/client'` instead
|
|
3150
4314
|
* @public
|
|
@@ -3236,6 +4400,7 @@ export declare class SanityClient {
|
|
|
3236
4400
|
agent: {
|
|
3237
4401
|
action: AgentActionsClient
|
|
3238
4402
|
}
|
|
4403
|
+
releases: ReleasesClient
|
|
3239
4404
|
/**
|
|
3240
4405
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
3241
4406
|
*/
|
|
@@ -3332,6 +4497,7 @@ export declare class SanityClient {
|
|
|
3332
4497
|
options?: {
|
|
3333
4498
|
signal?: AbortSignal
|
|
3334
4499
|
tag?: string
|
|
4500
|
+
releaseId?: string
|
|
3335
4501
|
},
|
|
3336
4502
|
): Promise<SanityDocument<R> | undefined>
|
|
3337
4503
|
/**
|
|
@@ -3515,6 +4681,90 @@ export declare class SanityClient {
|
|
|
3515
4681
|
document: IdentifiedSanityDocumentStub<R>,
|
|
3516
4682
|
options?: BaseMutationOptions,
|
|
3517
4683
|
): Promise<SanityDocument<R>>
|
|
4684
|
+
/**
|
|
4685
|
+
* @public
|
|
4686
|
+
*
|
|
4687
|
+
* Creates a new version of a published document.
|
|
4688
|
+
*
|
|
4689
|
+
* @remarks
|
|
4690
|
+
* * Requires a document with a `_type` property.
|
|
4691
|
+
* * Creating a version with no `releaseId` will create a new draft version of the published document.
|
|
4692
|
+
* * 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`.
|
|
4693
|
+
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
4694
|
+
* * To create a version of an unpublished document, use the `client.create` method.
|
|
4695
|
+
*
|
|
4696
|
+
* @category Versions
|
|
4697
|
+
*
|
|
4698
|
+
* @param params - Version action parameters:
|
|
4699
|
+
* - `document` - The document to create as a new version (must include `_type`).
|
|
4700
|
+
* - `publishedId` - The ID of the published document being versioned.
|
|
4701
|
+
* - `releaseId` - The ID of the release to create the version for.
|
|
4702
|
+
* @param options - Additional action options.
|
|
4703
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4704
|
+
*
|
|
4705
|
+
* @example Creating a new version of a published document with a generated version ID
|
|
4706
|
+
* ```ts
|
|
4707
|
+
* const transactionId = await client.createVersion({
|
|
4708
|
+
* // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
|
|
4709
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
4710
|
+
* publishedId: 'myDocument',
|
|
4711
|
+
* releaseId: 'myRelease',
|
|
4712
|
+
* })
|
|
4713
|
+
*
|
|
4714
|
+
* // The following document will be created:
|
|
4715
|
+
* // {
|
|
4716
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
4717
|
+
* // _type: 'myDocument',
|
|
4718
|
+
* // title: 'My Document',
|
|
4719
|
+
* // }
|
|
4720
|
+
* ```
|
|
4721
|
+
*
|
|
4722
|
+
* @example Creating a new version of a published document with a specified version ID
|
|
4723
|
+
* ```ts
|
|
4724
|
+
* const transactionId = await client.createVersion({
|
|
4725
|
+
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
4726
|
+
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
4727
|
+
* })
|
|
4728
|
+
*
|
|
4729
|
+
* // The following document will be created:
|
|
4730
|
+
* // {
|
|
4731
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
4732
|
+
* // _type: 'myDocument',
|
|
4733
|
+
* // title: 'My Document',
|
|
4734
|
+
* // }
|
|
4735
|
+
* ```
|
|
4736
|
+
*
|
|
4737
|
+
* @example Creating a new draft version of a published document
|
|
4738
|
+
* ```ts
|
|
4739
|
+
* const transactionId = await client.createVersion({
|
|
4740
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
4741
|
+
* publishedId: 'myDocument',
|
|
4742
|
+
* })
|
|
4743
|
+
*
|
|
4744
|
+
* // The following document will be created:
|
|
4745
|
+
* // {
|
|
4746
|
+
* // _id: 'drafts.myDocument',
|
|
4747
|
+
* // _type: 'myDocument',
|
|
4748
|
+
* // title: 'My Document',
|
|
4749
|
+
* // }
|
|
4750
|
+
* ```
|
|
4751
|
+
*/
|
|
4752
|
+
createVersion<R extends Record<string, Any>>(
|
|
4753
|
+
args: {
|
|
4754
|
+
document: SanityDocumentStub<R>
|
|
4755
|
+
publishedId: string
|
|
4756
|
+
releaseId?: string
|
|
4757
|
+
},
|
|
4758
|
+
options?: BaseActionOptions,
|
|
4759
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
4760
|
+
createVersion<R extends Record<string, Any>>(
|
|
4761
|
+
args: {
|
|
4762
|
+
document: IdentifiedSanityDocumentStub<R>
|
|
4763
|
+
publishedId?: string
|
|
4764
|
+
releaseId?: string
|
|
4765
|
+
},
|
|
4766
|
+
options?: BaseActionOptions,
|
|
4767
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
3518
4768
|
/**
|
|
3519
4769
|
* Deletes a document with the given document ID.
|
|
3520
4770
|
* Returns a promise that resolves to the deleted document.
|
|
@@ -3619,6 +4869,157 @@ export declare class SanityClient {
|
|
|
3619
4869
|
selection: MutationSelection,
|
|
3620
4870
|
options?: BaseMutationOptions,
|
|
3621
4871
|
): Promise<SanityDocument<R>>
|
|
4872
|
+
/**
|
|
4873
|
+
* @public
|
|
4874
|
+
*
|
|
4875
|
+
* Deletes the draft or release version of a document.
|
|
4876
|
+
*
|
|
4877
|
+
* @remarks
|
|
4878
|
+
* * Discarding a version with no `releaseId` will discard the draft version of the published document.
|
|
4879
|
+
* * If the draft or release version does not exist, any error will throw.
|
|
4880
|
+
*
|
|
4881
|
+
* @param params - Version action parameters:
|
|
4882
|
+
* - `releaseId` - The ID of the release to discard the document from.
|
|
4883
|
+
* - `publishedId` - The published ID of the document to discard.
|
|
4884
|
+
* @param purge - if `true` the document history is also discarded.
|
|
4885
|
+
* @param options - Additional action options.
|
|
4886
|
+
* @returns a promise that resolves to the `transactionId`.
|
|
4887
|
+
*
|
|
4888
|
+
* @example Discarding a release version of a document
|
|
4889
|
+
* ```ts
|
|
4890
|
+
* client.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
4891
|
+
* // The document with the ID `versions.myRelease.myDocument` will be discarded.
|
|
4892
|
+
* ```
|
|
4893
|
+
*
|
|
4894
|
+
* @example Discarding a draft version of a document
|
|
4895
|
+
* ```ts
|
|
4896
|
+
* client.discardVersion({publishedId: 'myDocument'})
|
|
4897
|
+
* // The document with the ID `drafts.myDocument` will be discarded.
|
|
4898
|
+
* ```
|
|
4899
|
+
*/
|
|
4900
|
+
discardVersion(
|
|
4901
|
+
{
|
|
4902
|
+
releaseId,
|
|
4903
|
+
publishedId,
|
|
4904
|
+
}: {
|
|
4905
|
+
releaseId?: string
|
|
4906
|
+
publishedId: string
|
|
4907
|
+
},
|
|
4908
|
+
purge?: boolean,
|
|
4909
|
+
options?: BaseActionOptions,
|
|
4910
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
4911
|
+
/**
|
|
4912
|
+
* @public
|
|
4913
|
+
*
|
|
4914
|
+
* Replaces an existing version document.
|
|
4915
|
+
*
|
|
4916
|
+
* @remarks
|
|
4917
|
+
* * Requires a document with a `_type` property.
|
|
4918
|
+
* * 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`.
|
|
4919
|
+
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
4920
|
+
* * Replacing a version with no `releaseId` will replace the draft version of the published document.
|
|
4921
|
+
* * At least one of the **version** or **published** documents must exist.
|
|
4922
|
+
*
|
|
4923
|
+
* @param params - Version action parameters:
|
|
4924
|
+
* - `document` - The new document to replace the version with.
|
|
4925
|
+
* - `releaseId` - The ID of the release where the document version is replaced.
|
|
4926
|
+
* - `publishedId` - The ID of the published document to replace.
|
|
4927
|
+
* @param options - Additional action options.
|
|
4928
|
+
* @returns a promise that resolves to the `transactionId`.
|
|
4929
|
+
*
|
|
4930
|
+
* @example Replacing a release version of a published document with a generated version ID
|
|
4931
|
+
* ```ts
|
|
4932
|
+
* await client.replaceVersion({
|
|
4933
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
4934
|
+
* publishedId: 'myDocument',
|
|
4935
|
+
* releaseId: 'myRelease',
|
|
4936
|
+
* })
|
|
4937
|
+
*
|
|
4938
|
+
* // The following document will be patched:
|
|
4939
|
+
* // {
|
|
4940
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
4941
|
+
* // _type: 'myDocument',
|
|
4942
|
+
* // title: 'My Document',
|
|
4943
|
+
* // }
|
|
4944
|
+
* ```
|
|
4945
|
+
*
|
|
4946
|
+
* @example Replacing a release version of a published document with a specified version ID
|
|
4947
|
+
* ```ts
|
|
4948
|
+
* await client.replaceVersion({
|
|
4949
|
+
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
4950
|
+
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
4951
|
+
* })
|
|
4952
|
+
*
|
|
4953
|
+
* // The following document will be patched:
|
|
4954
|
+
* // {
|
|
4955
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
4956
|
+
* // _type: 'myDocument',
|
|
4957
|
+
* // title: 'My Document',
|
|
4958
|
+
* // }
|
|
4959
|
+
* ```
|
|
4960
|
+
*
|
|
4961
|
+
* @example Replacing a draft version of a published document
|
|
4962
|
+
* ```ts
|
|
4963
|
+
* await client.replaceVersion({
|
|
4964
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
4965
|
+
* publishedId: 'myDocument',
|
|
4966
|
+
* })
|
|
4967
|
+
*
|
|
4968
|
+
* // The following document will be patched:
|
|
4969
|
+
* // {
|
|
4970
|
+
* // _id: 'drafts.myDocument',
|
|
4971
|
+
* // _type: 'myDocument',
|
|
4972
|
+
* // title: 'My Document',
|
|
4973
|
+
* // }
|
|
4974
|
+
* ```
|
|
4975
|
+
*/
|
|
4976
|
+
replaceVersion<R extends Record<string, Any>>(
|
|
4977
|
+
args: {
|
|
4978
|
+
document: SanityDocumentStub<R>
|
|
4979
|
+
publishedId: string
|
|
4980
|
+
releaseId?: string
|
|
4981
|
+
},
|
|
4982
|
+
options?: BaseActionOptions,
|
|
4983
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
4984
|
+
replaceVersion<R extends Record<string, Any>>(
|
|
4985
|
+
args: {
|
|
4986
|
+
document: IdentifiedSanityDocumentStub<R>
|
|
4987
|
+
publishedId?: string
|
|
4988
|
+
releaseId?: string
|
|
4989
|
+
},
|
|
4990
|
+
options?: BaseActionOptions,
|
|
4991
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
4992
|
+
/**
|
|
4993
|
+
* @public
|
|
4994
|
+
*
|
|
4995
|
+
* Used to indicate when a document within a release should be unpublished when
|
|
4996
|
+
* the release is run.
|
|
4997
|
+
*
|
|
4998
|
+
* @remarks
|
|
4999
|
+
* * If the published document does not exist, an error will be thrown.
|
|
5000
|
+
*
|
|
5001
|
+
* @param params - Version action parameters:
|
|
5002
|
+
* - `releaseId` - The ID of the release to unpublish the document from.
|
|
5003
|
+
* - `publishedId` - The published ID of the document to unpublish.
|
|
5004
|
+
* @param options - Additional action options.
|
|
5005
|
+
* @returns a promise that resolves to the `transactionId`.
|
|
5006
|
+
*
|
|
5007
|
+
* @example Unpublishing a release version of a published document
|
|
5008
|
+
* ```ts
|
|
5009
|
+
* await client.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
5010
|
+
* // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
|
|
5011
|
+
* ```
|
|
5012
|
+
*/
|
|
5013
|
+
unpublishVersion(
|
|
5014
|
+
{
|
|
5015
|
+
releaseId,
|
|
5016
|
+
publishedId,
|
|
5017
|
+
}: {
|
|
5018
|
+
releaseId: string
|
|
5019
|
+
publishedId: string
|
|
5020
|
+
},
|
|
5021
|
+
options?: BaseActionOptions,
|
|
5022
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
3622
5023
|
/**
|
|
3623
5024
|
* Perform mutation operations against the configured dataset
|
|
3624
5025
|
* Returns a promise that resolves to the first mutated document.
|
|
@@ -3659,7 +5060,7 @@ export declare class SanityClient {
|
|
|
3659
5060
|
* @param operations - Mutation operations to execute
|
|
3660
5061
|
* @param options - Mutation options
|
|
3661
5062
|
*/
|
|
3662
|
-
mutate<R extends Record<string, Any>>(
|
|
5063
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3663
5064
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
3664
5065
|
options: AllDocumentIdsMutationOptions,
|
|
3665
5066
|
): Promise<MultipleMutationResult>
|
|
@@ -3881,6 +5282,17 @@ export declare interface SanityUser {
|
|
|
3881
5282
|
isCurrentUser: boolean
|
|
3882
5283
|
}
|
|
3883
5284
|
|
|
5285
|
+
/**
|
|
5286
|
+
* Queues release for publishing at the given future time.
|
|
5287
|
+
*
|
|
5288
|
+
* @public
|
|
5289
|
+
*/
|
|
5290
|
+
export declare interface ScheduleReleaseAction {
|
|
5291
|
+
actionType: 'sanity.action.release.schedule'
|
|
5292
|
+
releaseId: string
|
|
5293
|
+
publishAt: string
|
|
5294
|
+
}
|
|
5295
|
+
|
|
3884
5296
|
/** @public */
|
|
3885
5297
|
export declare class ServerError extends Error {
|
|
3886
5298
|
response: ErrorProps['response']
|
|
@@ -4422,6 +5834,16 @@ export declare interface TranslateTargetInclude extends AgentActionTargetInclude
|
|
|
4422
5834
|
include?: (AgentActionPathSegment | TranslateTargetInclude)[]
|
|
4423
5835
|
}
|
|
4424
5836
|
|
|
5837
|
+
/**
|
|
5838
|
+
* Unarchived an `archived` release, and restores all the release documents.
|
|
5839
|
+
*
|
|
5840
|
+
* @public
|
|
5841
|
+
*/
|
|
5842
|
+
export declare interface UnarchiveReleaseAction {
|
|
5843
|
+
actionType: 'sanity.action.release.unarchive'
|
|
5844
|
+
releaseId: string
|
|
5845
|
+
}
|
|
5846
|
+
|
|
4425
5847
|
/** @public */
|
|
4426
5848
|
export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
4427
5849
|
filterResponse: false
|
|
@@ -4463,6 +5885,28 @@ export declare type UnpublishAction = {
|
|
|
4463
5885
|
publishedId: string
|
|
4464
5886
|
}
|
|
4465
5887
|
|
|
5888
|
+
/**
|
|
5889
|
+
* Identify that a version of a document should be unpublished when
|
|
5890
|
+
* the release that version is contained within is published.
|
|
5891
|
+
*
|
|
5892
|
+
* @public
|
|
5893
|
+
*/
|
|
5894
|
+
export declare interface UnpublishVersionAction {
|
|
5895
|
+
actionType: 'sanity.action.document.version.unpublish'
|
|
5896
|
+
versionId: string
|
|
5897
|
+
publishedId: string
|
|
5898
|
+
}
|
|
5899
|
+
|
|
5900
|
+
/**
|
|
5901
|
+
* Unschedules a `scheduled` release, stopping it from being published.
|
|
5902
|
+
*
|
|
5903
|
+
* @public
|
|
5904
|
+
*/
|
|
5905
|
+
export declare interface UnscheduleReleaseAction {
|
|
5906
|
+
actionType: 'sanity.action.release.unschedule'
|
|
5907
|
+
releaseId: string
|
|
5908
|
+
}
|
|
5909
|
+
|
|
4466
5910
|
export {unstable__adapter}
|
|
4467
5911
|
|
|
4468
5912
|
export {unstable__environment}
|
|
@@ -4558,6 +6002,13 @@ export declare function validateApiPerspective(
|
|
|
4558
6002
|
*/
|
|
4559
6003
|
export declare const vercelStegaCleanAll: typeof stegaClean
|
|
4560
6004
|
|
|
6005
|
+
/** @public */
|
|
6006
|
+
export declare type VersionAction =
|
|
6007
|
+
| CreateVersionAction
|
|
6008
|
+
| DiscardVersionAction
|
|
6009
|
+
| ReplaceVersionAction
|
|
6010
|
+
| UnpublishVersionAction
|
|
6011
|
+
|
|
4561
6012
|
/**
|
|
4562
6013
|
* The listener has been established, and will start receiving events.
|
|
4563
6014
|
* Note that this is also emitted upon _reconnection_.
|