@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/index.d.ts
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 {
|
|
@@ -53,15 +55,27 @@ declare interface AgentActionAsync {
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
/** @beta */
|
|
56
|
-
export declare type AgentActionParam
|
|
58
|
+
export declare type AgentActionParam<
|
|
59
|
+
TParamConfig extends {
|
|
60
|
+
docIdRequired: boolean
|
|
61
|
+
} = {
|
|
62
|
+
docIdRequired: false
|
|
63
|
+
},
|
|
64
|
+
> =
|
|
57
65
|
| string
|
|
58
66
|
| ConstantAgentActionParam
|
|
59
|
-
| FieldAgentActionParam
|
|
60
|
-
| DocumentAgentActionParam
|
|
67
|
+
| FieldAgentActionParam<TParamConfig>
|
|
68
|
+
| DocumentAgentActionParam<TParamConfig>
|
|
61
69
|
| GroqAgentActionParam
|
|
62
70
|
|
|
63
71
|
/** @beta */
|
|
64
|
-
export declare type AgentActionParams
|
|
72
|
+
export declare type AgentActionParams<
|
|
73
|
+
TParamConfig extends {
|
|
74
|
+
docIdRequired: boolean
|
|
75
|
+
} = {
|
|
76
|
+
docIdRequired: false
|
|
77
|
+
},
|
|
78
|
+
> = Record<string, AgentActionParam<TParamConfig>>
|
|
65
79
|
|
|
66
80
|
/** @beta */
|
|
67
81
|
export declare type AgentActionPath = AgentActionPathSegment[]
|
|
@@ -190,6 +204,13 @@ declare class AgentActionsClient {
|
|
|
190
204
|
}
|
|
191
205
|
: IdentifiedSanityDocumentStub & DocumentShape
|
|
192
206
|
>
|
|
207
|
+
/**
|
|
208
|
+
* Run a raw instruction and return the result either as text or json
|
|
209
|
+
* @param request - prompt request
|
|
210
|
+
*/
|
|
211
|
+
prompt<DocumentShape extends Record<string, Any>>(
|
|
212
|
+
request: PromptRequest<DocumentShape>,
|
|
213
|
+
): Promise<(typeof request)['json'] extends true ? DocumentShape : string>
|
|
193
214
|
}
|
|
194
215
|
|
|
195
216
|
/** @beta */
|
|
@@ -320,6 +341,16 @@ export declare interface ApiError {
|
|
|
320
341
|
statusCode: number
|
|
321
342
|
}
|
|
322
343
|
|
|
344
|
+
/**
|
|
345
|
+
* Archives an `active` release, and deletes all the release documents.
|
|
346
|
+
*
|
|
347
|
+
* @public
|
|
348
|
+
*/
|
|
349
|
+
export declare interface ArchiveReleaseAction {
|
|
350
|
+
actionType: 'sanity.action.release.archive'
|
|
351
|
+
releaseId: string
|
|
352
|
+
}
|
|
353
|
+
|
|
323
354
|
/** @public */
|
|
324
355
|
export declare type AssetMetadataType =
|
|
325
356
|
| 'location'
|
|
@@ -891,6 +922,29 @@ export declare type CreateAction = {
|
|
|
891
922
|
*/
|
|
892
923
|
export declare const createClient: (config: ClientConfig) => SanityClient
|
|
893
924
|
|
|
925
|
+
/**
|
|
926
|
+
* Creates a new release under the given id, with metadata.
|
|
927
|
+
*
|
|
928
|
+
* @public
|
|
929
|
+
*/
|
|
930
|
+
export declare interface CreateReleaseAction {
|
|
931
|
+
actionType: 'sanity.action.release.create'
|
|
932
|
+
releaseId: string
|
|
933
|
+
metadata?: Partial<ReleaseDocument['metadata']>
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Creates a new version of an existing document, attached to the release as given
|
|
938
|
+
* by `document._id`
|
|
939
|
+
*
|
|
940
|
+
* @public
|
|
941
|
+
*/
|
|
942
|
+
export declare interface CreateVersionAction {
|
|
943
|
+
actionType: 'sanity.action.document.version.create'
|
|
944
|
+
publishedId: string
|
|
945
|
+
document: IdentifiedSanityDocumentStub
|
|
946
|
+
}
|
|
947
|
+
|
|
894
948
|
/** @public */
|
|
895
949
|
export declare interface CurrentSanityUser {
|
|
896
950
|
id: string
|
|
@@ -986,6 +1040,16 @@ export declare type DeleteAction = {
|
|
|
986
1040
|
purge?: boolean
|
|
987
1041
|
}
|
|
988
1042
|
|
|
1043
|
+
/**
|
|
1044
|
+
* Deletes a `archived` or `published` release, and all the release documents versions.
|
|
1045
|
+
*
|
|
1046
|
+
* @public
|
|
1047
|
+
*/
|
|
1048
|
+
export declare interface DeleteReleaseAction {
|
|
1049
|
+
actionType: 'sanity.action.release.delete'
|
|
1050
|
+
releaseId: string
|
|
1051
|
+
}
|
|
1052
|
+
|
|
989
1053
|
/**
|
|
990
1054
|
* @public
|
|
991
1055
|
* @deprecated Use the named export `createClient` instead of the `default` export
|
|
@@ -1003,6 +1067,7 @@ declare type DeprecatedPreviewDrafts = 'previewDrafts'
|
|
|
1003
1067
|
* It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
|
|
1004
1068
|
*
|
|
1005
1069
|
* @public
|
|
1070
|
+
* @deprecated Use {@link DiscardVersionAction} instead
|
|
1006
1071
|
*/
|
|
1007
1072
|
export declare type DiscardAction = {
|
|
1008
1073
|
actionType: 'sanity.action.document.discard'
|
|
@@ -1016,6 +1081,17 @@ export declare type DiscardAction = {
|
|
|
1016
1081
|
purge?: boolean
|
|
1017
1082
|
}
|
|
1018
1083
|
|
|
1084
|
+
/**
|
|
1085
|
+
* Delete a version of a document.
|
|
1086
|
+
*
|
|
1087
|
+
* @public
|
|
1088
|
+
*/
|
|
1089
|
+
export declare interface DiscardVersionAction {
|
|
1090
|
+
actionType: 'sanity.action.document.version.discard'
|
|
1091
|
+
versionId: string
|
|
1092
|
+
purge?: boolean
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1019
1095
|
/**
|
|
1020
1096
|
* The listener has been told to explicitly disconnect.
|
|
1021
1097
|
* This is a rare situation, but may occur if the API knows reconnect attempts will fail,
|
|
@@ -1042,6 +1118,23 @@ export declare type DisconnectEvent = {
|
|
|
1042
1118
|
reason: string
|
|
1043
1119
|
}
|
|
1044
1120
|
|
|
1121
|
+
declare type DocIdParam<
|
|
1122
|
+
TParamConfig extends {
|
|
1123
|
+
docIdRequired: boolean
|
|
1124
|
+
} = {
|
|
1125
|
+
docIdRequired: false
|
|
1126
|
+
},
|
|
1127
|
+
> = TParamConfig['docIdRequired'] extends true
|
|
1128
|
+
? {
|
|
1129
|
+
documentId: string
|
|
1130
|
+
}
|
|
1131
|
+
: {
|
|
1132
|
+
/**
|
|
1133
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
1134
|
+
*/
|
|
1135
|
+
documentId?: string
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1045
1138
|
/**
|
|
1046
1139
|
*
|
|
1047
1140
|
* Includes a LLM-friendly version of the document in the instruction
|
|
@@ -1062,12 +1155,23 @@ export declare type DisconnectEvent = {
|
|
|
1062
1155
|
*
|
|
1063
1156
|
* @beta
|
|
1064
1157
|
* */
|
|
1065
|
-
export declare
|
|
1158
|
+
export declare type DocumentAgentActionParam<
|
|
1159
|
+
TParamConfig extends {
|
|
1160
|
+
docIdRequired: boolean
|
|
1161
|
+
} = {
|
|
1162
|
+
docIdRequired: false
|
|
1163
|
+
},
|
|
1164
|
+
> = {
|
|
1066
1165
|
type: 'document'
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1166
|
+
} & DocIdParam<TParamConfig>
|
|
1167
|
+
|
|
1168
|
+
/** @internal */
|
|
1169
|
+
export declare type EditableReleaseDocument = Omit<
|
|
1170
|
+
PartialExcept<ReleaseDocument, '_id'>,
|
|
1171
|
+
'metadata' | '_type'
|
|
1172
|
+
> & {
|
|
1173
|
+
_id: string
|
|
1174
|
+
metadata: Partial<ReleaseDocument['metadata']>
|
|
1071
1175
|
}
|
|
1072
1176
|
|
|
1073
1177
|
/**
|
|
@@ -1093,6 +1197,17 @@ export declare type EditAction = {
|
|
|
1093
1197
|
patch: PatchOperations
|
|
1094
1198
|
}
|
|
1095
1199
|
|
|
1200
|
+
/**
|
|
1201
|
+
* Edits an existing release, updating the metadata.
|
|
1202
|
+
*
|
|
1203
|
+
* @public
|
|
1204
|
+
*/
|
|
1205
|
+
export declare interface EditReleaseAction {
|
|
1206
|
+
actionType: 'sanity.action.release.edit'
|
|
1207
|
+
releaseId: string
|
|
1208
|
+
patch: PatchOperations
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1096
1211
|
/** @public */
|
|
1097
1212
|
export declare interface ErrorProps {
|
|
1098
1213
|
message: string
|
|
@@ -1135,17 +1250,19 @@ export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSo
|
|
|
1135
1250
|
*
|
|
1136
1251
|
* @beta
|
|
1137
1252
|
* */
|
|
1138
|
-
export declare
|
|
1253
|
+
export declare type FieldAgentActionParam<
|
|
1254
|
+
TParamConfig extends {
|
|
1255
|
+
docIdRequired: boolean
|
|
1256
|
+
} = {
|
|
1257
|
+
docIdRequired: false
|
|
1258
|
+
},
|
|
1259
|
+
> = {
|
|
1139
1260
|
type: 'field'
|
|
1140
1261
|
/**
|
|
1141
1262
|
* Examples: 'title', ['array', \{_key: 'arrayItemKey'\}, 'field']
|
|
1142
1263
|
*/
|
|
1143
1264
|
path: AgentActionPathSegment | AgentActionPath
|
|
1144
|
-
|
|
1145
|
-
* If omitted, implicitly uses the documentId of the instruction target
|
|
1146
|
-
*/
|
|
1147
|
-
documentId?: string
|
|
1148
|
-
}
|
|
1265
|
+
} & DocIdParam<TParamConfig>
|
|
1149
1266
|
|
|
1150
1267
|
/** @public */
|
|
1151
1268
|
export declare type FilterDefault = (props: {
|
|
@@ -2118,6 +2235,306 @@ export declare class ObservableProjectsClient {
|
|
|
2118
2235
|
getById(projectId: string): Observable<SanityProject>
|
|
2119
2236
|
}
|
|
2120
2237
|
|
|
2238
|
+
/** @public */
|
|
2239
|
+
declare class ObservableReleasesClient {
|
|
2240
|
+
#private
|
|
2241
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
2242
|
+
/**
|
|
2243
|
+
* @public
|
|
2244
|
+
*
|
|
2245
|
+
* Retrieve a release by id.
|
|
2246
|
+
*
|
|
2247
|
+
* @category Releases
|
|
2248
|
+
*
|
|
2249
|
+
* @param params - Release action parameters:
|
|
2250
|
+
* - `releaseId` - The id of the release to retrieve.
|
|
2251
|
+
* @param options - Additional query options including abort signal and query tag.
|
|
2252
|
+
* @returns An observable that resolves to the release document {@link ReleaseDocument}.
|
|
2253
|
+
*
|
|
2254
|
+
* @example Retrieving a release by id
|
|
2255
|
+
* ```ts
|
|
2256
|
+
* client.observable.releases.get({releaseId: 'my-release'}).pipe(
|
|
2257
|
+
* tap((release) => console.log(release)),
|
|
2258
|
+
* // {
|
|
2259
|
+
* // _id: '_.releases.my-release',
|
|
2260
|
+
* // name: 'my-release'
|
|
2261
|
+
* // _type: 'system.release',
|
|
2262
|
+
* // metadata: {releaseType: 'asap'},
|
|
2263
|
+
* // _createdAt: '2021-01-01T00:00:00.000Z',
|
|
2264
|
+
* // ...
|
|
2265
|
+
* // }
|
|
2266
|
+
* ).subscribe()
|
|
2267
|
+
* ```
|
|
2268
|
+
*/
|
|
2269
|
+
get(
|
|
2270
|
+
{
|
|
2271
|
+
releaseId,
|
|
2272
|
+
}: {
|
|
2273
|
+
releaseId: string
|
|
2274
|
+
},
|
|
2275
|
+
options?: {
|
|
2276
|
+
signal?: AbortSignal
|
|
2277
|
+
tag?: string
|
|
2278
|
+
},
|
|
2279
|
+
): Observable<ReleaseDocument | undefined>
|
|
2280
|
+
/**
|
|
2281
|
+
* @public
|
|
2282
|
+
*
|
|
2283
|
+
* Creates a new release under the given id, with metadata.
|
|
2284
|
+
*
|
|
2285
|
+
* @remarks
|
|
2286
|
+
* * If no releaseId is provided, a release id will be generated.
|
|
2287
|
+
* * If no metadata is provided, then an `undecided` releaseType will be used.
|
|
2288
|
+
*
|
|
2289
|
+
* @category Releases
|
|
2290
|
+
*
|
|
2291
|
+
* @param params - Release action parameters:
|
|
2292
|
+
* - `releaseId` - The id of the release to create.
|
|
2293
|
+
* - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
|
|
2294
|
+
* @param options - Additional action options.
|
|
2295
|
+
* @returns An observable that resolves to the `transactionId` and the release id and metadata.
|
|
2296
|
+
*
|
|
2297
|
+
* @example Creating a release with a custom id and metadata
|
|
2298
|
+
* ```ts
|
|
2299
|
+
* const releaseId = 'my-release'
|
|
2300
|
+
* const metadata: ReleaseDocument['metadata'] = {
|
|
2301
|
+
* releaseType: 'asap',
|
|
2302
|
+
* }
|
|
2303
|
+
*
|
|
2304
|
+
* client.observable.releases.create({releaseId, metadata}).pipe(
|
|
2305
|
+
* tap(({transactionId, releaseId, metadata}) => console.log(transactionId, releaseId, metadata)),
|
|
2306
|
+
* // {
|
|
2307
|
+
* // transactionId: 'transaction-id',
|
|
2308
|
+
* // releaseId: 'my-release',
|
|
2309
|
+
* // metadata: {releaseType: 'asap'},
|
|
2310
|
+
* // }
|
|
2311
|
+
* ).subscribe()
|
|
2312
|
+
* ```
|
|
2313
|
+
*
|
|
2314
|
+
* @example Creating a release with generated id and metadata
|
|
2315
|
+
* ```ts
|
|
2316
|
+
* client.observable.releases.create().pipe(
|
|
2317
|
+
* tap(({metadata}) => console.log(metadata)),
|
|
2318
|
+
* // {
|
|
2319
|
+
* // metadata: {releaseType: 'undecided'},
|
|
2320
|
+
* // }
|
|
2321
|
+
* ).subscribe()
|
|
2322
|
+
* ```
|
|
2323
|
+
*
|
|
2324
|
+
* @example Creating a release using a custom transaction id
|
|
2325
|
+
* ```ts
|
|
2326
|
+
* client.observable.releases.create({transactionId: 'my-transaction-id'}).pipe(
|
|
2327
|
+
* tap(({transactionId, metadata}) => console.log(transactionId, metadata)),
|
|
2328
|
+
* // {
|
|
2329
|
+
* // transactionId: 'my-transaction-id',
|
|
2330
|
+
* // metadata: {releaseType: 'undecided'},
|
|
2331
|
+
* // }
|
|
2332
|
+
* ).subscribe()
|
|
2333
|
+
* ```
|
|
2334
|
+
*/
|
|
2335
|
+
create(options: BaseActionOptions): Observable<
|
|
2336
|
+
SingleActionResult & {
|
|
2337
|
+
releaseId: string
|
|
2338
|
+
metadata: ReleaseDocument['metadata']
|
|
2339
|
+
}
|
|
2340
|
+
>
|
|
2341
|
+
create(
|
|
2342
|
+
release: {
|
|
2343
|
+
releaseId?: string
|
|
2344
|
+
metadata?: Partial<ReleaseDocument['metadata']>
|
|
2345
|
+
},
|
|
2346
|
+
options?: BaseActionOptions,
|
|
2347
|
+
): Observable<
|
|
2348
|
+
SingleActionResult & {
|
|
2349
|
+
releaseId: string
|
|
2350
|
+
metadata: ReleaseDocument['metadata']
|
|
2351
|
+
}
|
|
2352
|
+
>
|
|
2353
|
+
/**
|
|
2354
|
+
* @public
|
|
2355
|
+
*
|
|
2356
|
+
* Edits an existing release, updating the metadata.
|
|
2357
|
+
*
|
|
2358
|
+
* @category Releases
|
|
2359
|
+
*
|
|
2360
|
+
* @param params - Release action parameters:
|
|
2361
|
+
* - `releaseId` - The id of the release to edit.
|
|
2362
|
+
* - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
|
|
2363
|
+
* @param options - Additional action options.
|
|
2364
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2365
|
+
*/
|
|
2366
|
+
edit(
|
|
2367
|
+
{
|
|
2368
|
+
releaseId,
|
|
2369
|
+
patch,
|
|
2370
|
+
}: {
|
|
2371
|
+
releaseId: string
|
|
2372
|
+
patch: PatchOperations
|
|
2373
|
+
},
|
|
2374
|
+
options?: BaseActionOptions,
|
|
2375
|
+
): Observable<SingleActionResult>
|
|
2376
|
+
/**
|
|
2377
|
+
* @public
|
|
2378
|
+
*
|
|
2379
|
+
* Publishes all documents in a release at once. For larger releases the effect of the publish
|
|
2380
|
+
* will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
|
|
2381
|
+
* documents and creation of the corresponding published documents with the new content may
|
|
2382
|
+
* take some time.
|
|
2383
|
+
*
|
|
2384
|
+
* During this period both the source and target documents are locked and cannot be
|
|
2385
|
+
* modified through any other means.
|
|
2386
|
+
*
|
|
2387
|
+
* @category Releases
|
|
2388
|
+
*
|
|
2389
|
+
* @param params - Release action parameters:
|
|
2390
|
+
* - `releaseId` - The id of the release to publish.
|
|
2391
|
+
* @param options - Additional action options.
|
|
2392
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2393
|
+
*/
|
|
2394
|
+
publish(
|
|
2395
|
+
{
|
|
2396
|
+
releaseId,
|
|
2397
|
+
}: {
|
|
2398
|
+
releaseId: string
|
|
2399
|
+
},
|
|
2400
|
+
options?: BaseActionOptions,
|
|
2401
|
+
): Observable<SingleActionResult>
|
|
2402
|
+
/**
|
|
2403
|
+
* @public
|
|
2404
|
+
*
|
|
2405
|
+
* An archive action removes an active release. The documents that comprise the release
|
|
2406
|
+
* are deleted and therefore no longer queryable.
|
|
2407
|
+
*
|
|
2408
|
+
* While the documents remain in retention the last version can still be accessed using document history endpoint.
|
|
2409
|
+
*
|
|
2410
|
+
* @category Releases
|
|
2411
|
+
*
|
|
2412
|
+
* @param params - Release action parameters:
|
|
2413
|
+
* - `releaseId` - The id of the release to archive.
|
|
2414
|
+
* @param options - Additional action options.
|
|
2415
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2416
|
+
*/
|
|
2417
|
+
archive(
|
|
2418
|
+
{
|
|
2419
|
+
releaseId,
|
|
2420
|
+
}: {
|
|
2421
|
+
releaseId: string
|
|
2422
|
+
},
|
|
2423
|
+
options?: BaseActionOptions,
|
|
2424
|
+
): Observable<SingleActionResult>
|
|
2425
|
+
/**
|
|
2426
|
+
* @public
|
|
2427
|
+
*
|
|
2428
|
+
* An unarchive action restores an archived release and all documents
|
|
2429
|
+
* with the content they had just prior to archiving.
|
|
2430
|
+
*
|
|
2431
|
+
* @category Releases
|
|
2432
|
+
*
|
|
2433
|
+
* @param params - Release action parameters:
|
|
2434
|
+
* - `releaseId` - The id of the release to unarchive.
|
|
2435
|
+
* @param options - Additional action options.
|
|
2436
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2437
|
+
*/
|
|
2438
|
+
unarchive(
|
|
2439
|
+
{
|
|
2440
|
+
releaseId,
|
|
2441
|
+
}: {
|
|
2442
|
+
releaseId: string
|
|
2443
|
+
},
|
|
2444
|
+
options?: BaseActionOptions,
|
|
2445
|
+
): Observable<SingleActionResult>
|
|
2446
|
+
/**
|
|
2447
|
+
* @public
|
|
2448
|
+
*
|
|
2449
|
+
* A schedule action queues a release for publishing at the given future time.
|
|
2450
|
+
* The release is locked such that no documents in the release can be modified and
|
|
2451
|
+
* no documents that it references can be deleted as this would make the publish fail.
|
|
2452
|
+
* At the given time, the same logic as for the publish action is triggered.
|
|
2453
|
+
*
|
|
2454
|
+
* @category Releases
|
|
2455
|
+
*
|
|
2456
|
+
* @param params - Release action parameters:
|
|
2457
|
+
* - `releaseId` - The id of the release to schedule.
|
|
2458
|
+
* - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
|
|
2459
|
+
* @param options - Additional action options.
|
|
2460
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2461
|
+
*/
|
|
2462
|
+
schedule(
|
|
2463
|
+
{
|
|
2464
|
+
releaseId,
|
|
2465
|
+
publishAt,
|
|
2466
|
+
}: {
|
|
2467
|
+
releaseId: string
|
|
2468
|
+
publishAt: string
|
|
2469
|
+
},
|
|
2470
|
+
options?: BaseActionOptions,
|
|
2471
|
+
): Observable<SingleActionResult>
|
|
2472
|
+
/**
|
|
2473
|
+
* @public
|
|
2474
|
+
*
|
|
2475
|
+
* An unschedule action stops a release from being published.
|
|
2476
|
+
* The documents in the release are considered unlocked and can be edited again.
|
|
2477
|
+
* This may fail if another release is scheduled to be published after this one and
|
|
2478
|
+
* has a reference to a document created by this one.
|
|
2479
|
+
*
|
|
2480
|
+
* @category Releases
|
|
2481
|
+
*
|
|
2482
|
+
* @param params - Release action parameters:
|
|
2483
|
+
* - `releaseId` - The id of the release to unschedule.
|
|
2484
|
+
* @param options - Additional action options.
|
|
2485
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2486
|
+
*/
|
|
2487
|
+
unschedule(
|
|
2488
|
+
{
|
|
2489
|
+
releaseId,
|
|
2490
|
+
}: {
|
|
2491
|
+
releaseId: string
|
|
2492
|
+
},
|
|
2493
|
+
options?: BaseActionOptions,
|
|
2494
|
+
): Observable<SingleActionResult>
|
|
2495
|
+
/**
|
|
2496
|
+
* @public
|
|
2497
|
+
*
|
|
2498
|
+
* A delete action removes a published or archived release.
|
|
2499
|
+
* The backing system document will be removed from the dataset.
|
|
2500
|
+
*
|
|
2501
|
+
* @category Releases
|
|
2502
|
+
*
|
|
2503
|
+
* @param params - Release action parameters:
|
|
2504
|
+
* - `releaseId` - The id of the release to delete.
|
|
2505
|
+
* @param options - Additional action options.
|
|
2506
|
+
* @returns An observable that resolves to the `transactionId`.
|
|
2507
|
+
*/
|
|
2508
|
+
delete(
|
|
2509
|
+
{
|
|
2510
|
+
releaseId,
|
|
2511
|
+
}: {
|
|
2512
|
+
releaseId: string
|
|
2513
|
+
},
|
|
2514
|
+
options?: BaseActionOptions,
|
|
2515
|
+
): Observable<SingleActionResult>
|
|
2516
|
+
/**
|
|
2517
|
+
* @public
|
|
2518
|
+
*
|
|
2519
|
+
* Fetch the documents in a release by release id.
|
|
2520
|
+
*
|
|
2521
|
+
* @category Releases
|
|
2522
|
+
*
|
|
2523
|
+
* @param params - Release action parameters:
|
|
2524
|
+
* - `releaseId` - The id of the release to fetch documents for.
|
|
2525
|
+
* @param options - Additional mutation options {@link BaseMutationOptions}.
|
|
2526
|
+
* @returns An observable that resolves to the documents in the release.
|
|
2527
|
+
*/
|
|
2528
|
+
fetchDocuments(
|
|
2529
|
+
{
|
|
2530
|
+
releaseId,
|
|
2531
|
+
}: {
|
|
2532
|
+
releaseId: string
|
|
2533
|
+
},
|
|
2534
|
+
options?: BaseMutationOptions,
|
|
2535
|
+
): Observable<RawQueryResponse<SanityDocument[]>>
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2121
2538
|
/** @public */
|
|
2122
2539
|
export declare class ObservableSanityClient {
|
|
2123
2540
|
#private
|
|
@@ -2129,6 +2546,7 @@ export declare class ObservableSanityClient {
|
|
|
2129
2546
|
agent: {
|
|
2130
2547
|
action: ObservableAgentsActionClient
|
|
2131
2548
|
}
|
|
2549
|
+
releases: ObservableReleasesClient
|
|
2132
2550
|
/**
|
|
2133
2551
|
* Instance properties
|
|
2134
2552
|
*/
|
|
@@ -2219,7 +2637,9 @@ export declare class ObservableSanityClient {
|
|
|
2219
2637
|
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
2220
2638
|
id: string,
|
|
2221
2639
|
options?: {
|
|
2640
|
+
signal?: AbortSignal
|
|
2222
2641
|
tag?: string
|
|
2642
|
+
releaseId?: string
|
|
2223
2643
|
},
|
|
2224
2644
|
): Observable<SanityDocument<R> | undefined>
|
|
2225
2645
|
/**
|
|
@@ -2402,6 +2822,90 @@ export declare class ObservableSanityClient {
|
|
|
2402
2822
|
document: IdentifiedSanityDocumentStub<R>,
|
|
2403
2823
|
options?: BaseMutationOptions,
|
|
2404
2824
|
): Observable<SanityDocument<R>>
|
|
2825
|
+
/**
|
|
2826
|
+
* @public
|
|
2827
|
+
*
|
|
2828
|
+
* Creates a new version of a published document.
|
|
2829
|
+
*
|
|
2830
|
+
* @remarks
|
|
2831
|
+
* * Requires a document with a `_type` property.
|
|
2832
|
+
* * Creating a version with no `releaseId` will create a new draft version of the published document.
|
|
2833
|
+
* * 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`.
|
|
2834
|
+
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
2835
|
+
* * To create a version of an unpublished document, use the `client.create` method.
|
|
2836
|
+
*
|
|
2837
|
+
* @category Versions
|
|
2838
|
+
*
|
|
2839
|
+
* @param params - Version action parameters:
|
|
2840
|
+
* - `document` - The document to create as a new version (must include `_type`).
|
|
2841
|
+
* - `publishedId` - The ID of the published document being versioned.
|
|
2842
|
+
* - `releaseId` - The ID of the release to create the version for.
|
|
2843
|
+
* @param options - Additional action options.
|
|
2844
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
2845
|
+
*
|
|
2846
|
+
* @example Creating a new version of a published document with a generated version ID
|
|
2847
|
+
* ```ts
|
|
2848
|
+
* client.observable.createVersion({
|
|
2849
|
+
* // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
|
|
2850
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
2851
|
+
* publishedId: 'myDocument',
|
|
2852
|
+
* releaseId: 'myRelease',
|
|
2853
|
+
* })
|
|
2854
|
+
*
|
|
2855
|
+
* // The following document will be created:
|
|
2856
|
+
* // {
|
|
2857
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
2858
|
+
* // _type: 'myDocument',
|
|
2859
|
+
* // title: 'My Document',
|
|
2860
|
+
* // }
|
|
2861
|
+
* ```
|
|
2862
|
+
*
|
|
2863
|
+
* @example Creating a new version of a published document with a specified version ID
|
|
2864
|
+
* ```ts
|
|
2865
|
+
* client.observable.createVersion({
|
|
2866
|
+
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
2867
|
+
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
2868
|
+
* })
|
|
2869
|
+
*
|
|
2870
|
+
* // The following document will be created:
|
|
2871
|
+
* // {
|
|
2872
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
2873
|
+
* // _type: 'myDocument',
|
|
2874
|
+
* // title: 'My Document',
|
|
2875
|
+
* // }
|
|
2876
|
+
* ```
|
|
2877
|
+
*
|
|
2878
|
+
* @example Creating a new draft version of a published document
|
|
2879
|
+
* ```ts
|
|
2880
|
+
* client.observable.createVersion({
|
|
2881
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
2882
|
+
* publishedId: 'myDocument',
|
|
2883
|
+
* })
|
|
2884
|
+
*
|
|
2885
|
+
* // The following document will be created:
|
|
2886
|
+
* // {
|
|
2887
|
+
* // _id: 'drafts.myDocument',
|
|
2888
|
+
* // _type: 'myDocument',
|
|
2889
|
+
* // title: 'My Document',
|
|
2890
|
+
* // }
|
|
2891
|
+
* ```
|
|
2892
|
+
*/
|
|
2893
|
+
createVersion<R extends Record<string, Any>>(
|
|
2894
|
+
args: {
|
|
2895
|
+
document: SanityDocumentStub<R>
|
|
2896
|
+
publishedId: string
|
|
2897
|
+
releaseId?: string
|
|
2898
|
+
},
|
|
2899
|
+
options?: BaseActionOptions,
|
|
2900
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
2901
|
+
createVersion<R extends Record<string, Any>>(
|
|
2902
|
+
args: {
|
|
2903
|
+
document: IdentifiedSanityDocumentStub<R>
|
|
2904
|
+
publishedId?: string
|
|
2905
|
+
releaseId?: string
|
|
2906
|
+
},
|
|
2907
|
+
options?: BaseActionOptions,
|
|
2908
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
2405
2909
|
/**
|
|
2406
2910
|
* Deletes a document with the given document ID.
|
|
2407
2911
|
* Returns an observable that resolves to the deleted document.
|
|
@@ -2506,6 +3010,157 @@ export declare class ObservableSanityClient {
|
|
|
2506
3010
|
selection: MutationSelection,
|
|
2507
3011
|
options?: BaseMutationOptions,
|
|
2508
3012
|
): Observable<SanityDocument<R>>
|
|
3013
|
+
/**
|
|
3014
|
+
* @public
|
|
3015
|
+
*
|
|
3016
|
+
* Deletes the draft or release version of a document.
|
|
3017
|
+
*
|
|
3018
|
+
* @remarks
|
|
3019
|
+
* * Discarding a version with no `releaseId` will discard the draft version of the published document.
|
|
3020
|
+
* * If the draft or release version does not exist, any error will throw.
|
|
3021
|
+
*
|
|
3022
|
+
* @param params - Version action parameters:
|
|
3023
|
+
* - `releaseId` - The ID of the release to discard the document from.
|
|
3024
|
+
* - `publishedId` - The published ID of the document to discard.
|
|
3025
|
+
* @param purge - if `true` the document history is also discarded.
|
|
3026
|
+
* @param options - Additional action options.
|
|
3027
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
3028
|
+
*
|
|
3029
|
+
* @example Discarding a release version of a document
|
|
3030
|
+
* ```ts
|
|
3031
|
+
* client.observable.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
3032
|
+
* // The document with the ID `versions.myRelease.myDocument` will be discarded.
|
|
3033
|
+
* ```
|
|
3034
|
+
*
|
|
3035
|
+
* @example Discarding a draft version of a document
|
|
3036
|
+
* ```ts
|
|
3037
|
+
* client.observable.discardVersion({publishedId: 'myDocument'})
|
|
3038
|
+
* // The document with the ID `drafts.myDocument` will be discarded.
|
|
3039
|
+
* ```
|
|
3040
|
+
*/
|
|
3041
|
+
discardVersion(
|
|
3042
|
+
{
|
|
3043
|
+
releaseId,
|
|
3044
|
+
publishedId,
|
|
3045
|
+
}: {
|
|
3046
|
+
releaseId?: string
|
|
3047
|
+
publishedId: string
|
|
3048
|
+
},
|
|
3049
|
+
purge?: boolean,
|
|
3050
|
+
options?: BaseActionOptions,
|
|
3051
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
3052
|
+
/**
|
|
3053
|
+
* @public
|
|
3054
|
+
*
|
|
3055
|
+
* Replaces an existing version document.
|
|
3056
|
+
*
|
|
3057
|
+
* @remarks
|
|
3058
|
+
* * Requires a document with a `_type` property.
|
|
3059
|
+
* * 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`.
|
|
3060
|
+
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
3061
|
+
* * Replacing a version with no `releaseId` will replace the draft version of the published document.
|
|
3062
|
+
* * At least one of the **version** or **published** documents must exist.
|
|
3063
|
+
*
|
|
3064
|
+
* @param params - Version action parameters:
|
|
3065
|
+
* - `document` - The new document to replace the version with.
|
|
3066
|
+
* - `releaseId` - The ID of the release where the document version is replaced.
|
|
3067
|
+
* - `publishedId` - The ID of the published document to replace.
|
|
3068
|
+
* @param options - Additional action options.
|
|
3069
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
3070
|
+
*
|
|
3071
|
+
* @example Replacing a release version of a published document with a generated version ID
|
|
3072
|
+
* ```ts
|
|
3073
|
+
* client.observable.replaceVersion({
|
|
3074
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
3075
|
+
* publishedId: 'myDocument',
|
|
3076
|
+
* releaseId: 'myRelease',
|
|
3077
|
+
* })
|
|
3078
|
+
*
|
|
3079
|
+
* // The following document will be patched:
|
|
3080
|
+
* // {
|
|
3081
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
3082
|
+
* // _type: 'myDocument',
|
|
3083
|
+
* // title: 'My Document',
|
|
3084
|
+
* // }
|
|
3085
|
+
* ```
|
|
3086
|
+
*
|
|
3087
|
+
* @example Replacing a release version of a published document with a specified version ID
|
|
3088
|
+
* ```ts
|
|
3089
|
+
* client.observable.replaceVersion({
|
|
3090
|
+
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
3091
|
+
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
3092
|
+
* })
|
|
3093
|
+
*
|
|
3094
|
+
* // The following document will be patched:
|
|
3095
|
+
* // {
|
|
3096
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
3097
|
+
* // _type: 'myDocument',
|
|
3098
|
+
* // title: 'My Document',
|
|
3099
|
+
* // }
|
|
3100
|
+
* ```
|
|
3101
|
+
*
|
|
3102
|
+
* @example Replacing a draft version of a published document
|
|
3103
|
+
* ```ts
|
|
3104
|
+
* client.observable.replaceVersion({
|
|
3105
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
3106
|
+
* publishedId: 'myDocument',
|
|
3107
|
+
* })
|
|
3108
|
+
*
|
|
3109
|
+
* // The following document will be patched:
|
|
3110
|
+
* // {
|
|
3111
|
+
* // _id: 'drafts.myDocument',
|
|
3112
|
+
* // _type: 'myDocument',
|
|
3113
|
+
* // title: 'My Document',
|
|
3114
|
+
* // }
|
|
3115
|
+
* ```
|
|
3116
|
+
*/
|
|
3117
|
+
replaceVersion<R extends Record<string, Any>>(
|
|
3118
|
+
args: {
|
|
3119
|
+
document: SanityDocumentStub<R>
|
|
3120
|
+
publishedId: string
|
|
3121
|
+
releaseId?: string
|
|
3122
|
+
},
|
|
3123
|
+
options?: BaseActionOptions,
|
|
3124
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
3125
|
+
replaceVersion<R extends Record<string, Any>>(
|
|
3126
|
+
args: {
|
|
3127
|
+
document: IdentifiedSanityDocumentStub<R>
|
|
3128
|
+
publishedId?: string
|
|
3129
|
+
releaseId?: string
|
|
3130
|
+
},
|
|
3131
|
+
options?: BaseActionOptions,
|
|
3132
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
3133
|
+
/**
|
|
3134
|
+
* @public
|
|
3135
|
+
*
|
|
3136
|
+
* Used to indicate when a document within a release should be unpublished when
|
|
3137
|
+
* the release is run.
|
|
3138
|
+
*
|
|
3139
|
+
* @remarks
|
|
3140
|
+
* * If the published document does not exist, an error will be thrown.
|
|
3141
|
+
*
|
|
3142
|
+
* @param params - Version action parameters:
|
|
3143
|
+
* - `releaseId` - The ID of the release to unpublish the document from.
|
|
3144
|
+
* - `publishedId` - The published ID of the document to unpublish.
|
|
3145
|
+
* @param options - Additional action options.
|
|
3146
|
+
* @returns an observable that resolves to the `transactionId`.
|
|
3147
|
+
*
|
|
3148
|
+
* @example Unpublishing a release version of a published document
|
|
3149
|
+
* ```ts
|
|
3150
|
+
* client.observable.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
3151
|
+
* // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
|
|
3152
|
+
* ```
|
|
3153
|
+
*/
|
|
3154
|
+
unpublishVersion(
|
|
3155
|
+
{
|
|
3156
|
+
releaseId,
|
|
3157
|
+
publishedId,
|
|
3158
|
+
}: {
|
|
3159
|
+
releaseId: string
|
|
3160
|
+
publishedId: string
|
|
3161
|
+
},
|
|
3162
|
+
options?: BaseActionOptions,
|
|
3163
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
2509
3164
|
/**
|
|
2510
3165
|
* Perform mutation operations against the configured dataset
|
|
2511
3166
|
* Returns an observable that resolves to the first mutated document.
|
|
@@ -2707,6 +3362,9 @@ export declare type OpenEvent = {
|
|
|
2707
3362
|
type: 'open'
|
|
2708
3363
|
}
|
|
2709
3364
|
|
|
3365
|
+
/** @internal */
|
|
3366
|
+
export declare type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>
|
|
3367
|
+
|
|
2710
3368
|
/** @public */
|
|
2711
3369
|
export declare class Patch extends BasePatch {
|
|
2712
3370
|
#private
|
|
@@ -2816,26 +3474,156 @@ export declare class ProjectsClient {
|
|
|
2816
3474
|
}
|
|
2817
3475
|
|
|
2818
3476
|
/**
|
|
2819
|
-
*
|
|
2820
|
-
* If a published version of the document already exists this is replaced by the current draft document.
|
|
2821
|
-
* In either case the draft document is deleted.
|
|
2822
|
-
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
2823
|
-
* that the draft and/or published versions of the document have not been changed by another client.
|
|
2824
|
-
*
|
|
2825
|
-
* @public
|
|
3477
|
+
* @beta
|
|
2826
3478
|
*/
|
|
2827
|
-
|
|
2828
|
-
actionType: 'sanity.action.document.publish'
|
|
2829
|
-
/**
|
|
2830
|
-
* Draft document ID to publish
|
|
2831
|
-
*/
|
|
2832
|
-
draftId: string
|
|
3479
|
+
declare interface PromptJsonResponse<T extends Record<string, Any> = Record<string, Any>> {
|
|
2833
3480
|
/**
|
|
2834
|
-
*
|
|
3481
|
+
*
|
|
3482
|
+
* When true, the response body will be json according to the instruction.
|
|
3483
|
+
* When false, the response is the raw text response to the instruction.
|
|
3484
|
+
*
|
|
3485
|
+
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
2835
3486
|
*/
|
|
2836
|
-
|
|
3487
|
+
json: true
|
|
3488
|
+
}
|
|
3489
|
+
|
|
3490
|
+
/** @beta */
|
|
3491
|
+
export declare type PromptRequest<T extends Record<string, Any> = Record<string, Any>> = (
|
|
3492
|
+
| PromptTextResponse
|
|
3493
|
+
| PromptJsonResponse<T>
|
|
3494
|
+
) &
|
|
3495
|
+
PromptRequestBase
|
|
3496
|
+
|
|
3497
|
+
/** @beta */
|
|
3498
|
+
declare interface PromptRequestBase {
|
|
2837
3499
|
/**
|
|
2838
|
-
*
|
|
3500
|
+
* Instruct the LLM how it should generate content. Be as specific and detailed as needed.
|
|
3501
|
+
*
|
|
3502
|
+
* The LLM only has access to information in the instruction, plus the target schema.
|
|
3503
|
+
*
|
|
3504
|
+
* string template using $variable
|
|
3505
|
+
* */
|
|
3506
|
+
instruction: string
|
|
3507
|
+
/**
|
|
3508
|
+
* param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable"
|
|
3509
|
+
*
|
|
3510
|
+
* ### Examples
|
|
3511
|
+
*
|
|
3512
|
+
* #### Constant
|
|
3513
|
+
*
|
|
3514
|
+
* ##### Shorthand
|
|
3515
|
+
* ```ts
|
|
3516
|
+
* client.agent.action.generate({
|
|
3517
|
+
* schemaId,
|
|
3518
|
+
* documentId,
|
|
3519
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it',
|
|
3520
|
+
* instructionParams: {
|
|
3521
|
+
* topic: 'Grapefruit'
|
|
3522
|
+
* },
|
|
3523
|
+
* })
|
|
3524
|
+
* ```
|
|
3525
|
+
* ##### Object-form
|
|
3526
|
+
*
|
|
3527
|
+
* ```ts
|
|
3528
|
+
* client.agent.action.prompt({
|
|
3529
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nReturns some facts about it.',
|
|
3530
|
+
* instructionParams: {
|
|
3531
|
+
* topic: {
|
|
3532
|
+
* type: 'constant',
|
|
3533
|
+
* value: 'Grapefruit'
|
|
3534
|
+
* },
|
|
3535
|
+
* },
|
|
3536
|
+
* })
|
|
3537
|
+
* ```
|
|
3538
|
+
* #### Field
|
|
3539
|
+
* ```ts
|
|
3540
|
+
* client.agent.action.prompt({
|
|
3541
|
+
* instruction: 'Give the following field value:\n $pte \n ---\nGenerate keywords.',
|
|
3542
|
+
* instructionParams: {
|
|
3543
|
+
* pte: {
|
|
3544
|
+
* type: 'field',
|
|
3545
|
+
* path: ['pteField'],
|
|
3546
|
+
* documentId: 'someSanityDocId'
|
|
3547
|
+
* },
|
|
3548
|
+
* },
|
|
3549
|
+
* })
|
|
3550
|
+
* ```
|
|
3551
|
+
* #### Document
|
|
3552
|
+
* ```ts
|
|
3553
|
+
* client.agent.action.prompt({
|
|
3554
|
+
* json: true,
|
|
3555
|
+
* instruction: 'Given the following document:$document\nCreate a JSON string[] array with keywords describing it.',
|
|
3556
|
+
* instructionParams: {
|
|
3557
|
+
* document: {
|
|
3558
|
+
* type: 'document',
|
|
3559
|
+
* documentId: 'someSanityDocId'
|
|
3560
|
+
* },
|
|
3561
|
+
* },
|
|
3562
|
+
* })
|
|
3563
|
+
* ```
|
|
3564
|
+
*
|
|
3565
|
+
* #### GROQ
|
|
3566
|
+
* ```ts
|
|
3567
|
+
* client.agent.action.prompt({
|
|
3568
|
+
* instruction: 'Return the best title amongst these: $titles.',
|
|
3569
|
+
* instructionParams: {
|
|
3570
|
+
* titles: {
|
|
3571
|
+
* type: 'groq',
|
|
3572
|
+
* query: '* [_type==$type].title',
|
|
3573
|
+
* params: {type: 'article'}
|
|
3574
|
+
* },
|
|
3575
|
+
* },
|
|
3576
|
+
* })
|
|
3577
|
+
* ```
|
|
3578
|
+
* */
|
|
3579
|
+
instructionParams?: AgentActionParams<{
|
|
3580
|
+
docIdRequired: true
|
|
3581
|
+
}>
|
|
3582
|
+
/**
|
|
3583
|
+
* Controls how much variance the instructions will run with.
|
|
3584
|
+
*
|
|
3585
|
+
* Value must be in the range [0, 1] (inclusive).
|
|
3586
|
+
*
|
|
3587
|
+
* Defaults:
|
|
3588
|
+
* - generate: 0.3
|
|
3589
|
+
* - translate: 0
|
|
3590
|
+
* - transform: 0
|
|
3591
|
+
*/
|
|
3592
|
+
temperature?: number
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3595
|
+
declare interface PromptTextResponse {
|
|
3596
|
+
/**
|
|
3597
|
+
*
|
|
3598
|
+
* When true, the response body will be json according to the instruction.
|
|
3599
|
+
* When false, the response is the raw text response to the instruction.
|
|
3600
|
+
*
|
|
3601
|
+
* Note: In addition to setting this to true, `instruction` MUST include the word 'JSON', or 'json' for this to work.
|
|
3602
|
+
*/
|
|
3603
|
+
json?: false
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
/**
|
|
3607
|
+
* Publishes a draft document.
|
|
3608
|
+
* If a published version of the document already exists this is replaced by the current draft document.
|
|
3609
|
+
* In either case the draft document is deleted.
|
|
3610
|
+
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
3611
|
+
* that the draft and/or published versions of the document have not been changed by another client.
|
|
3612
|
+
*
|
|
3613
|
+
* @public
|
|
3614
|
+
*/
|
|
3615
|
+
export declare type PublishAction = {
|
|
3616
|
+
actionType: 'sanity.action.document.publish'
|
|
3617
|
+
/**
|
|
3618
|
+
* Draft document ID to publish
|
|
3619
|
+
*/
|
|
3620
|
+
draftId: string
|
|
3621
|
+
/**
|
|
3622
|
+
* Draft revision ID to match
|
|
3623
|
+
*/
|
|
3624
|
+
ifDraftRevisionId?: string
|
|
3625
|
+
/**
|
|
3626
|
+
* Published document ID to replace
|
|
2839
3627
|
*/
|
|
2840
3628
|
publishedId: string
|
|
2841
3629
|
/**
|
|
@@ -2844,6 +3632,16 @@ export declare type PublishAction = {
|
|
|
2844
3632
|
ifPublishedRevisionId?: string
|
|
2845
3633
|
}
|
|
2846
3634
|
|
|
3635
|
+
/**
|
|
3636
|
+
* Publishes all documents in a release at once.
|
|
3637
|
+
*
|
|
3638
|
+
* @public
|
|
3639
|
+
*/
|
|
3640
|
+
export declare interface PublishReleaseAction {
|
|
3641
|
+
actionType: 'sanity.action.release.publish'
|
|
3642
|
+
releaseId: string
|
|
3643
|
+
}
|
|
3644
|
+
|
|
2847
3645
|
/** @public */
|
|
2848
3646
|
export declare type QueryOptions =
|
|
2849
3647
|
| FilteredResponseQueryOptions
|
|
@@ -2942,17 +3740,373 @@ export declare type ReconnectEvent = {
|
|
|
2942
3740
|
type: 'reconnect'
|
|
2943
3741
|
}
|
|
2944
3742
|
|
|
3743
|
+
/** @public */
|
|
3744
|
+
export declare type ReleaseAction =
|
|
3745
|
+
| CreateReleaseAction
|
|
3746
|
+
| EditReleaseAction
|
|
3747
|
+
| PublishReleaseAction
|
|
3748
|
+
| ArchiveReleaseAction
|
|
3749
|
+
| UnarchiveReleaseAction
|
|
3750
|
+
| ScheduleReleaseAction
|
|
3751
|
+
| UnscheduleReleaseAction
|
|
3752
|
+
| DeleteReleaseAction
|
|
3753
|
+
|
|
3754
|
+
/** @internal */
|
|
3755
|
+
export declare interface ReleaseDocument extends SanityDocument {
|
|
3756
|
+
/**
|
|
3757
|
+
* typically
|
|
3758
|
+
* `_.releases.<name>`
|
|
3759
|
+
*/
|
|
3760
|
+
_id: string
|
|
3761
|
+
/**
|
|
3762
|
+
* where a release has _id `_.releases.foo`, the name is `foo`
|
|
3763
|
+
*/
|
|
3764
|
+
name: string
|
|
3765
|
+
_type: 'system.release'
|
|
3766
|
+
_createdAt: string
|
|
3767
|
+
_updatedAt: string
|
|
3768
|
+
_rev: string
|
|
3769
|
+
state: ReleaseState
|
|
3770
|
+
error?: {
|
|
3771
|
+
message: string
|
|
3772
|
+
}
|
|
3773
|
+
finalDocumentStates?: {
|
|
3774
|
+
/** Document ID */
|
|
3775
|
+
id: string
|
|
3776
|
+
}[]
|
|
3777
|
+
/**
|
|
3778
|
+
* If defined, it takes precedence over the intendedPublishAt, the state should be 'scheduled'
|
|
3779
|
+
*/
|
|
3780
|
+
publishAt?: string
|
|
3781
|
+
/**
|
|
3782
|
+
* If defined, it provides the time the release was actually published
|
|
3783
|
+
*/
|
|
3784
|
+
publishedAt?: string
|
|
3785
|
+
metadata: {
|
|
3786
|
+
title?: string
|
|
3787
|
+
description?: string
|
|
3788
|
+
intendedPublishAt?: string
|
|
3789
|
+
releaseType: ReleaseType
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
|
|
2945
3793
|
/**
|
|
2946
3794
|
* @public
|
|
2947
3795
|
* @deprecated – The `r`-prefix is not required, use `string` instead
|
|
2948
3796
|
*/
|
|
2949
3797
|
export declare type ReleaseId = `r${string}`
|
|
2950
3798
|
|
|
3799
|
+
/** @public */
|
|
3800
|
+
declare class ReleasesClient {
|
|
3801
|
+
#private
|
|
3802
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
3803
|
+
/**
|
|
3804
|
+
* @public
|
|
3805
|
+
*
|
|
3806
|
+
* Retrieve a release by id.
|
|
3807
|
+
*
|
|
3808
|
+
* @category Releases
|
|
3809
|
+
*
|
|
3810
|
+
* @param params - Release action parameters:
|
|
3811
|
+
* - `releaseId` - The id of the release to retrieve.
|
|
3812
|
+
* @param options - Additional query options including abort signal and query tag.
|
|
3813
|
+
* @returns A promise that resolves to the release document {@link ReleaseDocument}.
|
|
3814
|
+
*
|
|
3815
|
+
* @example Retrieving a release by id
|
|
3816
|
+
* ```ts
|
|
3817
|
+
* const release = await client.releases.get({releaseId: 'my-release'})
|
|
3818
|
+
* console.log(release)
|
|
3819
|
+
* // {
|
|
3820
|
+
* // _id: '_.releases.my-release',
|
|
3821
|
+
* // name: 'my-release'
|
|
3822
|
+
* // _type: 'system.release',
|
|
3823
|
+
* // metadata: {releaseType: 'asap'},
|
|
3824
|
+
* // _createdAt: '2021-01-01T00:00:00.000Z',
|
|
3825
|
+
* // ...
|
|
3826
|
+
* // }
|
|
3827
|
+
* ```
|
|
3828
|
+
*/
|
|
3829
|
+
get(
|
|
3830
|
+
{
|
|
3831
|
+
releaseId,
|
|
3832
|
+
}: {
|
|
3833
|
+
releaseId: string
|
|
3834
|
+
},
|
|
3835
|
+
options?: {
|
|
3836
|
+
signal?: AbortSignal
|
|
3837
|
+
tag?: string
|
|
3838
|
+
},
|
|
3839
|
+
): Promise<ReleaseDocument | undefined>
|
|
3840
|
+
/**
|
|
3841
|
+
* @public
|
|
3842
|
+
*
|
|
3843
|
+
* Creates a new release under the given id, with metadata.
|
|
3844
|
+
*
|
|
3845
|
+
* @remarks
|
|
3846
|
+
* * If no releaseId is provided, a release id will be generated.
|
|
3847
|
+
* * If no metadata is provided, then an `undecided` releaseType will be used.
|
|
3848
|
+
*
|
|
3849
|
+
* @category Releases
|
|
3850
|
+
*
|
|
3851
|
+
* @param params - Release action parameters:
|
|
3852
|
+
* - `releaseId` - The id of the release to create.
|
|
3853
|
+
* - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.
|
|
3854
|
+
* @param options - Additional action options.
|
|
3855
|
+
* @returns A promise that resolves to the `transactionId` and the release id and metadata.
|
|
3856
|
+
*
|
|
3857
|
+
* @example Creating a release with a custom id and metadata
|
|
3858
|
+
* ```ts
|
|
3859
|
+
* const releaseId = 'my-release'
|
|
3860
|
+
* const releaseMetadata: ReleaseDocument['metadata'] = {
|
|
3861
|
+
* releaseType: 'asap',
|
|
3862
|
+
* }
|
|
3863
|
+
*
|
|
3864
|
+
* const result =
|
|
3865
|
+
* await client.releases.create({releaseId, metadata: releaseMetadata})
|
|
3866
|
+
* console.log(result)
|
|
3867
|
+
* // {
|
|
3868
|
+
* // transactionId: 'transaction-id',
|
|
3869
|
+
* // releaseId: 'my-release',
|
|
3870
|
+
* // metadata: {releaseType: 'asap'},
|
|
3871
|
+
* // }
|
|
3872
|
+
* ```
|
|
3873
|
+
*
|
|
3874
|
+
* @example Creating a release with generated id and metadata
|
|
3875
|
+
* ```ts
|
|
3876
|
+
* const {metadata} = await client.releases.create()
|
|
3877
|
+
* console.log(metadata.releaseType) // 'undecided'
|
|
3878
|
+
* ```
|
|
3879
|
+
*
|
|
3880
|
+
* @example Creating a release with a custom transaction id
|
|
3881
|
+
* ```ts
|
|
3882
|
+
* const {transactionId, metadata} = await client.releases.create({transactionId: 'my-transaction-id'})
|
|
3883
|
+
* console.log(metadata.releaseType) // 'undecided'
|
|
3884
|
+
* console.log(transactionId) // 'my-transaction-id'
|
|
3885
|
+
* ```
|
|
3886
|
+
*/
|
|
3887
|
+
create(options: BaseActionOptions): Promise<
|
|
3888
|
+
SingleActionResult & {
|
|
3889
|
+
releaseId: string
|
|
3890
|
+
metadata: ReleaseDocument['metadata']
|
|
3891
|
+
}
|
|
3892
|
+
>
|
|
3893
|
+
create(
|
|
3894
|
+
release: {
|
|
3895
|
+
releaseId?: string
|
|
3896
|
+
metadata?: Partial<ReleaseDocument['metadata']>
|
|
3897
|
+
},
|
|
3898
|
+
options?: BaseActionOptions,
|
|
3899
|
+
): Promise<
|
|
3900
|
+
SingleActionResult & {
|
|
3901
|
+
releaseId: string
|
|
3902
|
+
metadata: ReleaseDocument['metadata']
|
|
3903
|
+
}
|
|
3904
|
+
>
|
|
3905
|
+
/**
|
|
3906
|
+
* @public
|
|
3907
|
+
*
|
|
3908
|
+
* Edits an existing release, updating the metadata.
|
|
3909
|
+
*
|
|
3910
|
+
* @category Releases
|
|
3911
|
+
*
|
|
3912
|
+
* @param params - Release action parameters:
|
|
3913
|
+
* - `releaseId` - The id of the release to edit.
|
|
3914
|
+
* - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.
|
|
3915
|
+
* @param options - Additional action options.
|
|
3916
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
3917
|
+
*/
|
|
3918
|
+
edit(
|
|
3919
|
+
{
|
|
3920
|
+
releaseId,
|
|
3921
|
+
patch,
|
|
3922
|
+
}: {
|
|
3923
|
+
releaseId: string
|
|
3924
|
+
patch: PatchOperations
|
|
3925
|
+
},
|
|
3926
|
+
options?: BaseActionOptions,
|
|
3927
|
+
): Promise<SingleActionResult>
|
|
3928
|
+
/**
|
|
3929
|
+
* @public
|
|
3930
|
+
*
|
|
3931
|
+
* Publishes all documents in a release at once. For larger releases the effect of the publish
|
|
3932
|
+
* will be visible immediately when querying but the removal of the `versions.<releasesId>.*`
|
|
3933
|
+
* documents and creation of the corresponding published documents with the new content may
|
|
3934
|
+
* take some time.
|
|
3935
|
+
*
|
|
3936
|
+
* During this period both the source and target documents are locked and cannot be
|
|
3937
|
+
* modified through any other means.
|
|
3938
|
+
*
|
|
3939
|
+
* @category Releases
|
|
3940
|
+
*
|
|
3941
|
+
* @param params - Release action parameters:
|
|
3942
|
+
* - `releaseId` - The id of the release to publish.
|
|
3943
|
+
* @param options - Additional action options.
|
|
3944
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
3945
|
+
*/
|
|
3946
|
+
publish(
|
|
3947
|
+
{
|
|
3948
|
+
releaseId,
|
|
3949
|
+
}: {
|
|
3950
|
+
releaseId: string
|
|
3951
|
+
},
|
|
3952
|
+
options?: BaseActionOptions,
|
|
3953
|
+
): Promise<SingleActionResult>
|
|
3954
|
+
/**
|
|
3955
|
+
* @public
|
|
3956
|
+
*
|
|
3957
|
+
* An archive action removes an active release. The documents that comprise the release
|
|
3958
|
+
* are deleted and therefore no longer queryable.
|
|
3959
|
+
*
|
|
3960
|
+
* While the documents remain in retention the last version can still be accessed using document history endpoint.
|
|
3961
|
+
*
|
|
3962
|
+
* @category Releases
|
|
3963
|
+
*
|
|
3964
|
+
* @param params - Release action parameters:
|
|
3965
|
+
* - `releaseId` - The id of the release to archive.
|
|
3966
|
+
* @param options - Additional action options.
|
|
3967
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
3968
|
+
*/
|
|
3969
|
+
archive(
|
|
3970
|
+
{
|
|
3971
|
+
releaseId,
|
|
3972
|
+
}: {
|
|
3973
|
+
releaseId: string
|
|
3974
|
+
},
|
|
3975
|
+
options?: BaseActionOptions,
|
|
3976
|
+
): Promise<SingleActionResult>
|
|
3977
|
+
/**
|
|
3978
|
+
* @public
|
|
3979
|
+
*
|
|
3980
|
+
* An unarchive action restores an archived release and all documents
|
|
3981
|
+
* with the content they had just prior to archiving.
|
|
3982
|
+
*
|
|
3983
|
+
* @category Releases
|
|
3984
|
+
*
|
|
3985
|
+
* @param params - Release action parameters:
|
|
3986
|
+
* - `releaseId` - The id of the release to unarchive.
|
|
3987
|
+
* @param options - Additional action options.
|
|
3988
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
3989
|
+
*/
|
|
3990
|
+
unarchive(
|
|
3991
|
+
{
|
|
3992
|
+
releaseId,
|
|
3993
|
+
}: {
|
|
3994
|
+
releaseId: string
|
|
3995
|
+
},
|
|
3996
|
+
options?: BaseActionOptions,
|
|
3997
|
+
): Promise<SingleActionResult>
|
|
3998
|
+
/**
|
|
3999
|
+
* @public
|
|
4000
|
+
*
|
|
4001
|
+
* A schedule action queues a release for publishing at the given future time.
|
|
4002
|
+
* The release is locked such that no documents in the release can be modified and
|
|
4003
|
+
* no documents that it references can be deleted as this would make the publish fail.
|
|
4004
|
+
* At the given time, the same logic as for the publish action is triggered.
|
|
4005
|
+
*
|
|
4006
|
+
* @category Releases
|
|
4007
|
+
*
|
|
4008
|
+
* @param params - Release action parameters:
|
|
4009
|
+
* - `releaseId` - The id of the release to schedule.
|
|
4010
|
+
* - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.
|
|
4011
|
+
* @param options - Additional action options.
|
|
4012
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4013
|
+
*/
|
|
4014
|
+
schedule(
|
|
4015
|
+
{
|
|
4016
|
+
releaseId,
|
|
4017
|
+
publishAt,
|
|
4018
|
+
}: {
|
|
4019
|
+
releaseId: string
|
|
4020
|
+
publishAt: string
|
|
4021
|
+
},
|
|
4022
|
+
options?: BaseActionOptions,
|
|
4023
|
+
): Promise<SingleActionResult>
|
|
4024
|
+
/**
|
|
4025
|
+
* @public
|
|
4026
|
+
*
|
|
4027
|
+
* An unschedule action stops a release from being published.
|
|
4028
|
+
* The documents in the release are considered unlocked and can be edited again.
|
|
4029
|
+
* This may fail if another release is scheduled to be published after this one and
|
|
4030
|
+
* has a reference to a document created by this one.
|
|
4031
|
+
*
|
|
4032
|
+
* @category Releases
|
|
4033
|
+
*
|
|
4034
|
+
* @param params - Release action parameters:
|
|
4035
|
+
* - `releaseId` - The id of the release to unschedule.
|
|
4036
|
+
* @param options - Additional action options.
|
|
4037
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4038
|
+
*/
|
|
4039
|
+
unschedule(
|
|
4040
|
+
{
|
|
4041
|
+
releaseId,
|
|
4042
|
+
}: {
|
|
4043
|
+
releaseId: string
|
|
4044
|
+
},
|
|
4045
|
+
options?: BaseActionOptions,
|
|
4046
|
+
): Promise<SingleActionResult>
|
|
4047
|
+
/**
|
|
4048
|
+
* @public
|
|
4049
|
+
*
|
|
4050
|
+
* A delete action removes a published or archived release.
|
|
4051
|
+
* The backing system document will be removed from the dataset.
|
|
4052
|
+
*
|
|
4053
|
+
* @category Releases
|
|
4054
|
+
*
|
|
4055
|
+
* @param params - Release action parameters:
|
|
4056
|
+
* - `releaseId` - The id of the release to delete.
|
|
4057
|
+
* @param options - Additional action options.
|
|
4058
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4059
|
+
*/
|
|
4060
|
+
delete(
|
|
4061
|
+
{
|
|
4062
|
+
releaseId,
|
|
4063
|
+
}: {
|
|
4064
|
+
releaseId: string
|
|
4065
|
+
},
|
|
4066
|
+
options?: BaseActionOptions,
|
|
4067
|
+
): Promise<SingleActionResult>
|
|
4068
|
+
/**
|
|
4069
|
+
* @public
|
|
4070
|
+
*
|
|
4071
|
+
* Fetch the documents in a release by release id.
|
|
4072
|
+
*
|
|
4073
|
+
* @category Releases
|
|
4074
|
+
*
|
|
4075
|
+
* @param params - Release action parameters:
|
|
4076
|
+
* - `releaseId` - The id of the release to fetch documents for.
|
|
4077
|
+
* @param options - Additional mutation options {@link BaseMutationOptions}.
|
|
4078
|
+
* @returns A promise that resolves to the documents in the release.
|
|
4079
|
+
*/
|
|
4080
|
+
fetchDocuments(
|
|
4081
|
+
{
|
|
4082
|
+
releaseId,
|
|
4083
|
+
}: {
|
|
4084
|
+
releaseId: string
|
|
4085
|
+
},
|
|
4086
|
+
options?: BaseMutationOptions,
|
|
4087
|
+
): Promise<RawQueryResponse<SanityDocument[]>>
|
|
4088
|
+
}
|
|
4089
|
+
|
|
4090
|
+
/** @beta */
|
|
4091
|
+
export declare type ReleaseState =
|
|
4092
|
+
| 'active'
|
|
4093
|
+
| 'archiving'
|
|
4094
|
+
| 'unarchiving'
|
|
4095
|
+
| 'archived'
|
|
4096
|
+
| 'published'
|
|
4097
|
+
| 'publishing'
|
|
4098
|
+
| 'scheduled'
|
|
4099
|
+
| 'scheduling'
|
|
4100
|
+
|
|
4101
|
+
/** @internal */
|
|
4102
|
+
export declare type ReleaseType = 'asap' | 'scheduled' | 'undecided'
|
|
4103
|
+
|
|
2951
4104
|
/**
|
|
2952
4105
|
* Replaces an existing draft document.
|
|
2953
4106
|
* At least one of the draft or published versions of the document must exist.
|
|
2954
4107
|
*
|
|
2955
4108
|
* @public
|
|
4109
|
+
* @deprecated Use {@link ReplaceVersionAction} instead
|
|
2956
4110
|
*/
|
|
2957
4111
|
export declare type ReplaceDraftAction = {
|
|
2958
4112
|
actionType: 'sanity.action.document.replaceDraft'
|
|
@@ -2966,6 +4120,16 @@ export declare type ReplaceDraftAction = {
|
|
|
2966
4120
|
attributes: IdentifiedSanityDocumentStub
|
|
2967
4121
|
}
|
|
2968
4122
|
|
|
4123
|
+
/**
|
|
4124
|
+
* Replace an existing version of a document.
|
|
4125
|
+
*
|
|
4126
|
+
* @public
|
|
4127
|
+
*/
|
|
4128
|
+
export declare interface ReplaceVersionAction {
|
|
4129
|
+
actionType: 'sanity.action.document.version.replace'
|
|
4130
|
+
document: IdentifiedSanityDocumentStub
|
|
4131
|
+
}
|
|
4132
|
+
|
|
2969
4133
|
/** @public */
|
|
2970
4134
|
export declare const requester: Requester
|
|
2971
4135
|
|
|
@@ -3051,6 +4215,7 @@ export declare class SanityClient {
|
|
|
3051
4215
|
agent: {
|
|
3052
4216
|
action: AgentActionsClient
|
|
3053
4217
|
}
|
|
4218
|
+
releases: ReleasesClient
|
|
3054
4219
|
/**
|
|
3055
4220
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
3056
4221
|
*/
|
|
@@ -3147,6 +4312,7 @@ export declare class SanityClient {
|
|
|
3147
4312
|
options?: {
|
|
3148
4313
|
signal?: AbortSignal
|
|
3149
4314
|
tag?: string
|
|
4315
|
+
releaseId?: string
|
|
3150
4316
|
},
|
|
3151
4317
|
): Promise<SanityDocument<R> | undefined>
|
|
3152
4318
|
/**
|
|
@@ -3330,6 +4496,90 @@ export declare class SanityClient {
|
|
|
3330
4496
|
document: IdentifiedSanityDocumentStub<R>,
|
|
3331
4497
|
options?: BaseMutationOptions,
|
|
3332
4498
|
): Promise<SanityDocument<R>>
|
|
4499
|
+
/**
|
|
4500
|
+
* @public
|
|
4501
|
+
*
|
|
4502
|
+
* Creates a new version of a published document.
|
|
4503
|
+
*
|
|
4504
|
+
* @remarks
|
|
4505
|
+
* * Requires a document with a `_type` property.
|
|
4506
|
+
* * Creating a version with no `releaseId` will create a new draft version of the published document.
|
|
4507
|
+
* * 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`.
|
|
4508
|
+
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
4509
|
+
* * To create a version of an unpublished document, use the `client.create` method.
|
|
4510
|
+
*
|
|
4511
|
+
* @category Versions
|
|
4512
|
+
*
|
|
4513
|
+
* @param params - Version action parameters:
|
|
4514
|
+
* - `document` - The document to create as a new version (must include `_type`).
|
|
4515
|
+
* - `publishedId` - The ID of the published document being versioned.
|
|
4516
|
+
* - `releaseId` - The ID of the release to create the version for.
|
|
4517
|
+
* @param options - Additional action options.
|
|
4518
|
+
* @returns A promise that resolves to the `transactionId`.
|
|
4519
|
+
*
|
|
4520
|
+
* @example Creating a new version of a published document with a generated version ID
|
|
4521
|
+
* ```ts
|
|
4522
|
+
* const transactionId = await client.createVersion({
|
|
4523
|
+
* // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`
|
|
4524
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
4525
|
+
* publishedId: 'myDocument',
|
|
4526
|
+
* releaseId: 'myRelease',
|
|
4527
|
+
* })
|
|
4528
|
+
*
|
|
4529
|
+
* // The following document will be created:
|
|
4530
|
+
* // {
|
|
4531
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
4532
|
+
* // _type: 'myDocument',
|
|
4533
|
+
* // title: 'My Document',
|
|
4534
|
+
* // }
|
|
4535
|
+
* ```
|
|
4536
|
+
*
|
|
4537
|
+
* @example Creating a new version of a published document with a specified version ID
|
|
4538
|
+
* ```ts
|
|
4539
|
+
* const transactionId = await client.createVersion({
|
|
4540
|
+
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
4541
|
+
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
4542
|
+
* })
|
|
4543
|
+
*
|
|
4544
|
+
* // The following document will be created:
|
|
4545
|
+
* // {
|
|
4546
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
4547
|
+
* // _type: 'myDocument',
|
|
4548
|
+
* // title: 'My Document',
|
|
4549
|
+
* // }
|
|
4550
|
+
* ```
|
|
4551
|
+
*
|
|
4552
|
+
* @example Creating a new draft version of a published document
|
|
4553
|
+
* ```ts
|
|
4554
|
+
* const transactionId = await client.createVersion({
|
|
4555
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
4556
|
+
* publishedId: 'myDocument',
|
|
4557
|
+
* })
|
|
4558
|
+
*
|
|
4559
|
+
* // The following document will be created:
|
|
4560
|
+
* // {
|
|
4561
|
+
* // _id: 'drafts.myDocument',
|
|
4562
|
+
* // _type: 'myDocument',
|
|
4563
|
+
* // title: 'My Document',
|
|
4564
|
+
* // }
|
|
4565
|
+
* ```
|
|
4566
|
+
*/
|
|
4567
|
+
createVersion<R extends Record<string, Any>>(
|
|
4568
|
+
args: {
|
|
4569
|
+
document: SanityDocumentStub<R>
|
|
4570
|
+
publishedId: string
|
|
4571
|
+
releaseId?: string
|
|
4572
|
+
},
|
|
4573
|
+
options?: BaseActionOptions,
|
|
4574
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
4575
|
+
createVersion<R extends Record<string, Any>>(
|
|
4576
|
+
args: {
|
|
4577
|
+
document: IdentifiedSanityDocumentStub<R>
|
|
4578
|
+
publishedId?: string
|
|
4579
|
+
releaseId?: string
|
|
4580
|
+
},
|
|
4581
|
+
options?: BaseActionOptions,
|
|
4582
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
3333
4583
|
/**
|
|
3334
4584
|
* Deletes a document with the given document ID.
|
|
3335
4585
|
* Returns a promise that resolves to the deleted document.
|
|
@@ -3434,6 +4684,157 @@ export declare class SanityClient {
|
|
|
3434
4684
|
selection: MutationSelection,
|
|
3435
4685
|
options?: BaseMutationOptions,
|
|
3436
4686
|
): Promise<SanityDocument<R>>
|
|
4687
|
+
/**
|
|
4688
|
+
* @public
|
|
4689
|
+
*
|
|
4690
|
+
* Deletes the draft or release version of a document.
|
|
4691
|
+
*
|
|
4692
|
+
* @remarks
|
|
4693
|
+
* * Discarding a version with no `releaseId` will discard the draft version of the published document.
|
|
4694
|
+
* * If the draft or release version does not exist, any error will throw.
|
|
4695
|
+
*
|
|
4696
|
+
* @param params - Version action parameters:
|
|
4697
|
+
* - `releaseId` - The ID of the release to discard the document from.
|
|
4698
|
+
* - `publishedId` - The published ID of the document to discard.
|
|
4699
|
+
* @param purge - if `true` the document history is also discarded.
|
|
4700
|
+
* @param options - Additional action options.
|
|
4701
|
+
* @returns a promise that resolves to the `transactionId`.
|
|
4702
|
+
*
|
|
4703
|
+
* @example Discarding a release version of a document
|
|
4704
|
+
* ```ts
|
|
4705
|
+
* client.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
4706
|
+
* // The document with the ID `versions.myRelease.myDocument` will be discarded.
|
|
4707
|
+
* ```
|
|
4708
|
+
*
|
|
4709
|
+
* @example Discarding a draft version of a document
|
|
4710
|
+
* ```ts
|
|
4711
|
+
* client.discardVersion({publishedId: 'myDocument'})
|
|
4712
|
+
* // The document with the ID `drafts.myDocument` will be discarded.
|
|
4713
|
+
* ```
|
|
4714
|
+
*/
|
|
4715
|
+
discardVersion(
|
|
4716
|
+
{
|
|
4717
|
+
releaseId,
|
|
4718
|
+
publishedId,
|
|
4719
|
+
}: {
|
|
4720
|
+
releaseId?: string
|
|
4721
|
+
publishedId: string
|
|
4722
|
+
},
|
|
4723
|
+
purge?: boolean,
|
|
4724
|
+
options?: BaseActionOptions,
|
|
4725
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
4726
|
+
/**
|
|
4727
|
+
* @public
|
|
4728
|
+
*
|
|
4729
|
+
* Replaces an existing version document.
|
|
4730
|
+
*
|
|
4731
|
+
* @remarks
|
|
4732
|
+
* * Requires a document with a `_type` property.
|
|
4733
|
+
* * 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`.
|
|
4734
|
+
* * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.
|
|
4735
|
+
* * Replacing a version with no `releaseId` will replace the draft version of the published document.
|
|
4736
|
+
* * At least one of the **version** or **published** documents must exist.
|
|
4737
|
+
*
|
|
4738
|
+
* @param params - Version action parameters:
|
|
4739
|
+
* - `document` - The new document to replace the version with.
|
|
4740
|
+
* - `releaseId` - The ID of the release where the document version is replaced.
|
|
4741
|
+
* - `publishedId` - The ID of the published document to replace.
|
|
4742
|
+
* @param options - Additional action options.
|
|
4743
|
+
* @returns a promise that resolves to the `transactionId`.
|
|
4744
|
+
*
|
|
4745
|
+
* @example Replacing a release version of a published document with a generated version ID
|
|
4746
|
+
* ```ts
|
|
4747
|
+
* await client.replaceVersion({
|
|
4748
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
4749
|
+
* publishedId: 'myDocument',
|
|
4750
|
+
* releaseId: 'myRelease',
|
|
4751
|
+
* })
|
|
4752
|
+
*
|
|
4753
|
+
* // The following document will be patched:
|
|
4754
|
+
* // {
|
|
4755
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
4756
|
+
* // _type: 'myDocument',
|
|
4757
|
+
* // title: 'My Document',
|
|
4758
|
+
* // }
|
|
4759
|
+
* ```
|
|
4760
|
+
*
|
|
4761
|
+
* @example Replacing a release version of a published document with a specified version ID
|
|
4762
|
+
* ```ts
|
|
4763
|
+
* await client.replaceVersion({
|
|
4764
|
+
* document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},
|
|
4765
|
+
* // `publishedId` and `releaseId` are not required since `document._id` has been specified
|
|
4766
|
+
* })
|
|
4767
|
+
*
|
|
4768
|
+
* // The following document will be patched:
|
|
4769
|
+
* // {
|
|
4770
|
+
* // _id: 'versions.myRelease.myDocument',
|
|
4771
|
+
* // _type: 'myDocument',
|
|
4772
|
+
* // title: 'My Document',
|
|
4773
|
+
* // }
|
|
4774
|
+
* ```
|
|
4775
|
+
*
|
|
4776
|
+
* @example Replacing a draft version of a published document
|
|
4777
|
+
* ```ts
|
|
4778
|
+
* await client.replaceVersion({
|
|
4779
|
+
* document: {_type: 'myDocument', title: 'My Document'},
|
|
4780
|
+
* publishedId: 'myDocument',
|
|
4781
|
+
* })
|
|
4782
|
+
*
|
|
4783
|
+
* // The following document will be patched:
|
|
4784
|
+
* // {
|
|
4785
|
+
* // _id: 'drafts.myDocument',
|
|
4786
|
+
* // _type: 'myDocument',
|
|
4787
|
+
* // title: 'My Document',
|
|
4788
|
+
* // }
|
|
4789
|
+
* ```
|
|
4790
|
+
*/
|
|
4791
|
+
replaceVersion<R extends Record<string, Any>>(
|
|
4792
|
+
args: {
|
|
4793
|
+
document: SanityDocumentStub<R>
|
|
4794
|
+
publishedId: string
|
|
4795
|
+
releaseId?: string
|
|
4796
|
+
},
|
|
4797
|
+
options?: BaseActionOptions,
|
|
4798
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
4799
|
+
replaceVersion<R extends Record<string, Any>>(
|
|
4800
|
+
args: {
|
|
4801
|
+
document: IdentifiedSanityDocumentStub<R>
|
|
4802
|
+
publishedId?: string
|
|
4803
|
+
releaseId?: string
|
|
4804
|
+
},
|
|
4805
|
+
options?: BaseActionOptions,
|
|
4806
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
4807
|
+
/**
|
|
4808
|
+
* @public
|
|
4809
|
+
*
|
|
4810
|
+
* Used to indicate when a document within a release should be unpublished when
|
|
4811
|
+
* the release is run.
|
|
4812
|
+
*
|
|
4813
|
+
* @remarks
|
|
4814
|
+
* * If the published document does not exist, an error will be thrown.
|
|
4815
|
+
*
|
|
4816
|
+
* @param params - Version action parameters:
|
|
4817
|
+
* - `releaseId` - The ID of the release to unpublish the document from.
|
|
4818
|
+
* - `publishedId` - The published ID of the document to unpublish.
|
|
4819
|
+
* @param options - Additional action options.
|
|
4820
|
+
* @returns a promise that resolves to the `transactionId`.
|
|
4821
|
+
*
|
|
4822
|
+
* @example Unpublishing a release version of a published document
|
|
4823
|
+
* ```ts
|
|
4824
|
+
* await client.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})
|
|
4825
|
+
* // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.
|
|
4826
|
+
* ```
|
|
4827
|
+
*/
|
|
4828
|
+
unpublishVersion(
|
|
4829
|
+
{
|
|
4830
|
+
releaseId,
|
|
4831
|
+
publishedId,
|
|
4832
|
+
}: {
|
|
4833
|
+
releaseId: string
|
|
4834
|
+
publishedId: string
|
|
4835
|
+
},
|
|
4836
|
+
options?: BaseActionOptions,
|
|
4837
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
3437
4838
|
/**
|
|
3438
4839
|
* Perform mutation operations against the configured dataset
|
|
3439
4840
|
* Returns a promise that resolves to the first mutated document.
|
|
@@ -3474,7 +4875,7 @@ export declare class SanityClient {
|
|
|
3474
4875
|
* @param operations - Mutation operations to execute
|
|
3475
4876
|
* @param options - Mutation options
|
|
3476
4877
|
*/
|
|
3477
|
-
mutate<R extends Record<string, Any>>(
|
|
4878
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3478
4879
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
3479
4880
|
options: AllDocumentIdsMutationOptions,
|
|
3480
4881
|
): Promise<MultipleMutationResult>
|
|
@@ -3690,6 +5091,17 @@ export declare interface SanityUser {
|
|
|
3690
5091
|
isCurrentUser: boolean
|
|
3691
5092
|
}
|
|
3692
5093
|
|
|
5094
|
+
/**
|
|
5095
|
+
* Queues release for publishing at the given future time.
|
|
5096
|
+
*
|
|
5097
|
+
* @public
|
|
5098
|
+
*/
|
|
5099
|
+
export declare interface ScheduleReleaseAction {
|
|
5100
|
+
actionType: 'sanity.action.release.schedule'
|
|
5101
|
+
releaseId: string
|
|
5102
|
+
publishAt: string
|
|
5103
|
+
}
|
|
5104
|
+
|
|
3693
5105
|
/** @public */
|
|
3694
5106
|
export declare class ServerError extends Error {
|
|
3695
5107
|
response: ErrorProps['response']
|
|
@@ -4168,6 +5580,16 @@ export declare interface TranslateTargetInclude extends AgentActionTargetInclude
|
|
|
4168
5580
|
include?: (AgentActionPathSegment | TranslateTargetInclude)[]
|
|
4169
5581
|
}
|
|
4170
5582
|
|
|
5583
|
+
/**
|
|
5584
|
+
* Unarchived an `archived` release, and restores all the release documents.
|
|
5585
|
+
*
|
|
5586
|
+
* @public
|
|
5587
|
+
*/
|
|
5588
|
+
export declare interface UnarchiveReleaseAction {
|
|
5589
|
+
actionType: 'sanity.action.release.unarchive'
|
|
5590
|
+
releaseId: string
|
|
5591
|
+
}
|
|
5592
|
+
|
|
4171
5593
|
/** @public */
|
|
4172
5594
|
export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
4173
5595
|
filterResponse: false
|
|
@@ -4209,6 +5631,28 @@ export declare type UnpublishAction = {
|
|
|
4209
5631
|
publishedId: string
|
|
4210
5632
|
}
|
|
4211
5633
|
|
|
5634
|
+
/**
|
|
5635
|
+
* Identify that a version of a document should be unpublished when
|
|
5636
|
+
* the release that version is contained within is published.
|
|
5637
|
+
*
|
|
5638
|
+
* @public
|
|
5639
|
+
*/
|
|
5640
|
+
export declare interface UnpublishVersionAction {
|
|
5641
|
+
actionType: 'sanity.action.document.version.unpublish'
|
|
5642
|
+
versionId: string
|
|
5643
|
+
publishedId: string
|
|
5644
|
+
}
|
|
5645
|
+
|
|
5646
|
+
/**
|
|
5647
|
+
* Unschedules a `scheduled` release, stopping it from being published.
|
|
5648
|
+
*
|
|
5649
|
+
* @public
|
|
5650
|
+
*/
|
|
5651
|
+
export declare interface UnscheduleReleaseAction {
|
|
5652
|
+
actionType: 'sanity.action.release.unschedule'
|
|
5653
|
+
releaseId: string
|
|
5654
|
+
}
|
|
5655
|
+
|
|
4212
5656
|
export {unstable__adapter}
|
|
4213
5657
|
|
|
4214
5658
|
export {unstable__environment}
|
|
@@ -4296,6 +5740,13 @@ export declare function validateApiPerspective(
|
|
|
4296
5740
|
perspective: unknown,
|
|
4297
5741
|
): asserts perspective is ClientPerspective
|
|
4298
5742
|
|
|
5743
|
+
/** @public */
|
|
5744
|
+
export declare type VersionAction =
|
|
5745
|
+
| CreateVersionAction
|
|
5746
|
+
| DiscardVersionAction
|
|
5747
|
+
| ReplaceVersionAction
|
|
5748
|
+
| UnpublishVersionAction
|
|
5749
|
+
|
|
4299
5750
|
/**
|
|
4300
5751
|
* The listener has been established, and will start receiving events.
|
|
4301
5752
|
* Note that this is also emitted upon _reconnection_.
|