@sanity/client 7.0.1-canary.2 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +102 -4
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +1352 -1654
- package/dist/index.browser.d.ts +1352 -1654
- package/dist/index.browser.js +102 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +103 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1352 -1654
- package/dist/index.d.ts +1352 -1654
- package/dist/index.js +103 -5
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +1375 -1677
- package/dist/stega.browser.d.ts +1375 -1677
- package/dist/stega.d.cts +1375 -1677
- package/dist/stega.d.ts +1375 -1677
- package/package.json +2 -1
- package/src/SanityClient.ts +34 -1102
- package/src/agent/actions/AgentActionsClient.ts +111 -0
- package/src/agent/actions/commonTypes.ts +336 -0
- package/src/agent/actions/generate.ts +274 -0
- package/src/agent/actions/transform.ts +215 -0
- package/src/agent/actions/translate.ts +165 -0
- package/src/assets/AssetsClient.ts +2 -86
- package/src/data/dataMethods.ts +1 -1
- package/src/data/transaction.ts +1 -1
- package/src/datasets/DatasetsClient.ts +2 -64
- package/src/projects/ProjectsClient.ts +4 -46
- package/src/types.ts +30 -1
- package/src/users/UsersClient.ts +2 -24
- package/umd/sanityClient.js +102 -4
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.d.cts
CHANGED
|
@@ -39,6 +39,262 @@ export declare interface ActionErrorItem {
|
|
|
39
39
|
index: number
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/** @beta */
|
|
43
|
+
declare interface AgentActionAsync {
|
|
44
|
+
/**
|
|
45
|
+
* When async: true, requests responds with status 201 and \{_id\} as response body as soon as the request is validated.
|
|
46
|
+
* The instruction operation will carry on in the background.
|
|
47
|
+
*
|
|
48
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
49
|
+
*
|
|
50
|
+
* async: true is incompatible with noWrite, as async: true does not return the resulting document
|
|
51
|
+
*/
|
|
52
|
+
async: true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** @beta */
|
|
56
|
+
export declare type AgentActionParam =
|
|
57
|
+
| string
|
|
58
|
+
| ConstantAgentActionParam
|
|
59
|
+
| FieldAgentActionParam
|
|
60
|
+
| DocumentAgentActionParam
|
|
61
|
+
| GroqAgentActionParam
|
|
62
|
+
|
|
63
|
+
/** @beta */
|
|
64
|
+
export declare type AgentActionParams = Record<string, AgentActionParam>
|
|
65
|
+
|
|
66
|
+
/** @beta */
|
|
67
|
+
export declare type AgentActionPath = AgentActionPathSegment[]
|
|
68
|
+
|
|
69
|
+
/** @beta */
|
|
70
|
+
export declare type AgentActionPathSegment =
|
|
71
|
+
| string
|
|
72
|
+
| {
|
|
73
|
+
_key: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** @beta */
|
|
77
|
+
declare interface AgentActionRequestBase {
|
|
78
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
79
|
+
schemaId: string
|
|
80
|
+
/**
|
|
81
|
+
* When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
|
|
82
|
+
*
|
|
83
|
+
* By default, Generate will not output to conditional `readOnly` and `hidden` fields,
|
|
84
|
+
* ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
|
|
85
|
+
*
|
|
86
|
+
* `conditionalPaths` param allows setting the default conditional value for
|
|
87
|
+
* `hidden` and `readOnly` to false,
|
|
88
|
+
* or individually set `hidden` and `readOnly` state for individual document paths.
|
|
89
|
+
*
|
|
90
|
+
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to Generate,
|
|
91
|
+
* and cannot be changed via conditionalPaths
|
|
92
|
+
*
|
|
93
|
+
* conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
|
|
94
|
+
*
|
|
95
|
+
* Consider using `hidden: () => true` in schema config, if a field should be writeable only by Generate and never
|
|
96
|
+
* visible in the studio – then make the field visible to the Generate using `conditionalPaths`.
|
|
97
|
+
*
|
|
98
|
+
* @see GenerateRequestBase#target
|
|
99
|
+
*/
|
|
100
|
+
conditionalPaths?: {
|
|
101
|
+
defaultReadOnly?: boolean
|
|
102
|
+
defaultHidden?: boolean
|
|
103
|
+
paths?: {
|
|
104
|
+
/** path here is not a relative path: it must be the full document path, regardless of `path` param used in targets */
|
|
105
|
+
path: AgentActionPath
|
|
106
|
+
readOnly: boolean
|
|
107
|
+
hidden: boolean
|
|
108
|
+
}[]
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* When localeSettings is provided on the request, instruct can write to date and datetime fields.
|
|
112
|
+
* Otherwise, such fields will be ignored.
|
|
113
|
+
*/
|
|
114
|
+
localeSettings?: {
|
|
115
|
+
/**
|
|
116
|
+
* A valid Unicode BCP 47 locale identifier used to interpret and format
|
|
117
|
+
* natural language inputs and date output. Examples include "en-US", "fr-FR", or "ja-JP".
|
|
118
|
+
*
|
|
119
|
+
* This affects how phrases like "next Friday" or "in two weeks" are parsed,
|
|
120
|
+
* and how resulting dates are presented (e.g., 12-hour vs 24-hour format).
|
|
121
|
+
*
|
|
122
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#getcanonicalocales
|
|
123
|
+
*/
|
|
124
|
+
locale: string
|
|
125
|
+
/**
|
|
126
|
+
* A valid IANA time zone identifier used to resolve relative and absolute
|
|
127
|
+
* date expressions to a specific point in time. Examples include
|
|
128
|
+
* "America/New_York", "Europe/Paris", or "Asia/Tokyo".
|
|
129
|
+
*
|
|
130
|
+
* This ensures phrases like "tomorrow at 9am" are interpreted correctly
|
|
131
|
+
* based on the user's local time.
|
|
132
|
+
*
|
|
133
|
+
* @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
134
|
+
*/
|
|
135
|
+
timeZone: string
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Controls how much variance the instructions will run with.
|
|
139
|
+
*
|
|
140
|
+
* Value must be in the range [0, 1] (inclusive).
|
|
141
|
+
*
|
|
142
|
+
* Defaults:
|
|
143
|
+
* - generate: 0.3
|
|
144
|
+
* - translate: 0
|
|
145
|
+
* - transform: 0
|
|
146
|
+
*/
|
|
147
|
+
temperature?: number
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** @public */
|
|
151
|
+
declare class AgentActionsClient {
|
|
152
|
+
#private
|
|
153
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
154
|
+
/**
|
|
155
|
+
* Run an instruction to generate content in a target document.
|
|
156
|
+
* @param request - instruction request
|
|
157
|
+
*/
|
|
158
|
+
generate<DocumentShape extends Record<string, Any>>(
|
|
159
|
+
request: GenerateInstruction<DocumentShape>,
|
|
160
|
+
): Promise<
|
|
161
|
+
(typeof request)['async'] extends true
|
|
162
|
+
? {
|
|
163
|
+
_id: string
|
|
164
|
+
}
|
|
165
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
166
|
+
>
|
|
167
|
+
/**
|
|
168
|
+
* Transform a target document based on a source.
|
|
169
|
+
* @param request - translation request
|
|
170
|
+
*/
|
|
171
|
+
transform<DocumentShape extends Record<string, Any>>(
|
|
172
|
+
request: TransformDocument<DocumentShape>,
|
|
173
|
+
): Promise<
|
|
174
|
+
(typeof request)['async'] extends true
|
|
175
|
+
? {
|
|
176
|
+
_id: string
|
|
177
|
+
}
|
|
178
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
179
|
+
>
|
|
180
|
+
/**
|
|
181
|
+
* Translate a target document based on a source.
|
|
182
|
+
* @param request - translation request
|
|
183
|
+
*/
|
|
184
|
+
translate<DocumentShape extends Record<string, Any>>(
|
|
185
|
+
request: TranslateDocument<DocumentShape>,
|
|
186
|
+
): Promise<
|
|
187
|
+
(typeof request)['async'] extends true
|
|
188
|
+
? {
|
|
189
|
+
_id: string
|
|
190
|
+
}
|
|
191
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
192
|
+
>
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** @beta */
|
|
196
|
+
declare interface AgentActionSync {
|
|
197
|
+
/**
|
|
198
|
+
* By default, noWrite: false.
|
|
199
|
+
* Write enabled operations will mutate the target document, and emit AI presence in the studio.
|
|
200
|
+
*
|
|
201
|
+
* When noWrite: true, the api will not mutate any documents nor emit presence.
|
|
202
|
+
* Ie, when true, no changes will be made to content-lake
|
|
203
|
+
*
|
|
204
|
+
* noWrite: true is incompatible with async: true,
|
|
205
|
+
* as noWrite implies that you will use the return value of the operation
|
|
206
|
+
*/
|
|
207
|
+
noWrite?: boolean
|
|
208
|
+
/**
|
|
209
|
+
* When async: true, requests responds with status 201 and \{_id\} as response body as soon as the request is validated.
|
|
210
|
+
* The instruction operation will carry on in the background.
|
|
211
|
+
*
|
|
212
|
+
* When async: false (default), requests respond with status 200 and the document value after instruction has been applied.
|
|
213
|
+
*
|
|
214
|
+
* async: true is incompatible with noWrite: true, as async: true does not return the resulting document
|
|
215
|
+
*/
|
|
216
|
+
async?: false
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @beta
|
|
221
|
+
*/
|
|
222
|
+
export declare interface AgentActionTarget {
|
|
223
|
+
/**
|
|
224
|
+
* Root target path.
|
|
225
|
+
*
|
|
226
|
+
* Use this to have the instruction only affect a part of the document.
|
|
227
|
+
*
|
|
228
|
+
* To further control the behavior of individual paths under the root, use `include`, `exclude`, `types.include`
|
|
229
|
+
* and `types.exclude`.
|
|
230
|
+
*
|
|
231
|
+
* Example:
|
|
232
|
+
*
|
|
233
|
+
* `path: ['body', {_key: 'someKey'}, 'nestedObject']`
|
|
234
|
+
*
|
|
235
|
+
* Here, the instruction will only write to fields under the nestedObject.
|
|
236
|
+
*
|
|
237
|
+
* Default: [] = the document itself
|
|
238
|
+
*
|
|
239
|
+
* @see #AgentActionPathSegment
|
|
240
|
+
* @see #AgentActionPath
|
|
241
|
+
* */
|
|
242
|
+
path?: AgentActionPathSegment | AgentActionPath
|
|
243
|
+
/**
|
|
244
|
+
* maxPathDepth controls how deep into the schema from the target root the instruction will affect.
|
|
245
|
+
*
|
|
246
|
+
* Depth is based on path segments:
|
|
247
|
+
* - `title` has depth 1
|
|
248
|
+
* - `array[_key="no"].title` has depth 3
|
|
249
|
+
*
|
|
250
|
+
* Be careful not to set this too high in studios with recursive document schemas, as it could have
|
|
251
|
+
* negative impact on performance; both for runtime and quality of responses.
|
|
252
|
+
*
|
|
253
|
+
* Default: 4
|
|
254
|
+
*/
|
|
255
|
+
maxPathDepth?: number
|
|
256
|
+
/**
|
|
257
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
258
|
+
* Fields or array items not on the exclude list, are implicitly included.
|
|
259
|
+
*/
|
|
260
|
+
exclude?: AgentActionPathSegment[]
|
|
261
|
+
/**
|
|
262
|
+
* Types can be used to exclude array item types or all fields directly under the target path of a certain type.
|
|
263
|
+
* If you do exclude: ['string'] all string fields under the target will be excluded, for instance.
|
|
264
|
+
*
|
|
265
|
+
* `types.include` and `types.exclude` are mutually exclusive.
|
|
266
|
+
*/
|
|
267
|
+
types?: AgentActionTypeConfig
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** @beta */
|
|
271
|
+
declare interface AgentActionTargetInclude {
|
|
272
|
+
path: AgentActionPathSegment | AgentActionPath
|
|
273
|
+
/**
|
|
274
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
275
|
+
* Fields or array items not on the exclude list, are implicitly included.
|
|
276
|
+
*/
|
|
277
|
+
exclude?: AgentActionPathSegment[]
|
|
278
|
+
/**
|
|
279
|
+
* Types can be used to exclude array item types or all fields directly under the target path of a certain type.
|
|
280
|
+
* If you do exclude: ['string'] all string fields under the target will be excluded, for instance.
|
|
281
|
+
*
|
|
282
|
+
* `types.include` and `types.exclude` are mutually exclusive.
|
|
283
|
+
*/
|
|
284
|
+
types?: AgentActionTypeConfig
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** @beta */
|
|
288
|
+
declare type AgentActionTypeConfig =
|
|
289
|
+
| {
|
|
290
|
+
include: string[]
|
|
291
|
+
exclude?: never
|
|
292
|
+
}
|
|
293
|
+
| {
|
|
294
|
+
exclude: string[]
|
|
295
|
+
include?: never
|
|
296
|
+
}
|
|
297
|
+
|
|
42
298
|
/** @internal */
|
|
43
299
|
export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
44
300
|
returnFirst: false
|
|
@@ -75,7 +331,7 @@ export declare type AssetMetadataType =
|
|
|
75
331
|
| 'none'
|
|
76
332
|
|
|
77
333
|
/** @internal */
|
|
78
|
-
export declare class AssetsClient
|
|
334
|
+
export declare class AssetsClient {
|
|
79
335
|
#private
|
|
80
336
|
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
81
337
|
/**
|
|
@@ -116,46 +372,6 @@ export declare class AssetsClient implements AssetsClientType {
|
|
|
116
372
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
117
373
|
}
|
|
118
374
|
|
|
119
|
-
/** @internal */
|
|
120
|
-
declare interface AssetsClientType {
|
|
121
|
-
/**
|
|
122
|
-
* Uploads a file asset to the configured dataset
|
|
123
|
-
*
|
|
124
|
-
* @param assetType - Asset type (file)
|
|
125
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
126
|
-
* @param options - Options to use for the upload
|
|
127
|
-
*/
|
|
128
|
-
upload(
|
|
129
|
-
assetType: 'file',
|
|
130
|
-
body: UploadBody,
|
|
131
|
-
options?: UploadClientConfig,
|
|
132
|
-
): Promise<SanityAssetDocument>
|
|
133
|
-
/**
|
|
134
|
-
* Uploads an image asset to the configured dataset
|
|
135
|
-
*
|
|
136
|
-
* @param assetType - Asset type (image)
|
|
137
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
138
|
-
* @param options - Options to use for the upload
|
|
139
|
-
*/
|
|
140
|
-
upload(
|
|
141
|
-
assetType: 'image',
|
|
142
|
-
body: UploadBody,
|
|
143
|
-
options?: UploadClientConfig,
|
|
144
|
-
): Promise<SanityImageAssetDocument>
|
|
145
|
-
/**
|
|
146
|
-
* Uploads a file or an image asset to the configured dataset
|
|
147
|
-
*
|
|
148
|
-
* @param assetType - Asset type (file/image)
|
|
149
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
150
|
-
* @param options - Options to use for the upload
|
|
151
|
-
*/
|
|
152
|
-
upload(
|
|
153
|
-
assetType: 'file' | 'image',
|
|
154
|
-
body: UploadBody,
|
|
155
|
-
options?: UploadClientConfig,
|
|
156
|
-
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
157
|
-
}
|
|
158
|
-
|
|
159
375
|
/** @internal */
|
|
160
376
|
export declare type AttributeSet = {
|
|
161
377
|
[key: string]: Any
|
|
@@ -515,6 +731,43 @@ export declare class ConnectionFailedError extends Error {
|
|
|
515
731
|
readonly name = 'ConnectionFailedError'
|
|
516
732
|
}
|
|
517
733
|
|
|
734
|
+
/**
|
|
735
|
+
* Include a string in the instruction: do not have to escape $ signs in the string.
|
|
736
|
+
*
|
|
737
|
+
* ```ts
|
|
738
|
+
* client.agent.action.generate({
|
|
739
|
+
* schemaId,
|
|
740
|
+
* documentId,
|
|
741
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nGenerate the full article.',
|
|
742
|
+
* instructionParams: {
|
|
743
|
+
* topic: {
|
|
744
|
+
* type: 'constant',
|
|
745
|
+
* value: 'Grapefruit'
|
|
746
|
+
* },
|
|
747
|
+
* },
|
|
748
|
+
* })
|
|
749
|
+
* ```
|
|
750
|
+
*
|
|
751
|
+
* `type: 'constant'` can also be provided directly as a string, as a shorthand:
|
|
752
|
+
*
|
|
753
|
+
* ```ts
|
|
754
|
+
* client.agent.action.generate({
|
|
755
|
+
* schemaId,
|
|
756
|
+
* documentId,
|
|
757
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nGenerate the full article.',
|
|
758
|
+
* instructionParams: {
|
|
759
|
+
* topic: 'Grapefruit'
|
|
760
|
+
* },
|
|
761
|
+
* })
|
|
762
|
+
* ```
|
|
763
|
+
*
|
|
764
|
+
* @beta
|
|
765
|
+
* */
|
|
766
|
+
export declare interface ConstantAgentActionParam {
|
|
767
|
+
type: 'constant'
|
|
768
|
+
value: string
|
|
769
|
+
}
|
|
770
|
+
|
|
518
771
|
/** @public */
|
|
519
772
|
export declare interface ContentSourceMap {
|
|
520
773
|
mappings: ContentSourceMapMappings
|
|
@@ -653,7 +906,7 @@ export declare type DatasetResponse = {
|
|
|
653
906
|
}
|
|
654
907
|
|
|
655
908
|
/** @internal */
|
|
656
|
-
export declare class DatasetsClient
|
|
909
|
+
export declare class DatasetsClient {
|
|
657
910
|
#private
|
|
658
911
|
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
659
912
|
/**
|
|
@@ -694,46 +947,6 @@ export declare class DatasetsClient implements DatasetsClientType {
|
|
|
694
947
|
list(): Promise<DatasetsResponse>
|
|
695
948
|
}
|
|
696
949
|
|
|
697
|
-
/** @internal */
|
|
698
|
-
declare interface DatasetsClientType {
|
|
699
|
-
/**
|
|
700
|
-
* Create a new dataset with the given name
|
|
701
|
-
*
|
|
702
|
-
* @param name - Name of the dataset to create
|
|
703
|
-
* @param options - Options for the dataset
|
|
704
|
-
*/
|
|
705
|
-
create(
|
|
706
|
-
name: string,
|
|
707
|
-
options?: {
|
|
708
|
-
aclMode?: DatasetAclMode
|
|
709
|
-
},
|
|
710
|
-
): Promise<DatasetResponse>
|
|
711
|
-
/**
|
|
712
|
-
* Edit a dataset with the given name
|
|
713
|
-
*
|
|
714
|
-
* @param name - Name of the dataset to edit
|
|
715
|
-
* @param options - New options for the dataset
|
|
716
|
-
*/
|
|
717
|
-
edit(
|
|
718
|
-
name: string,
|
|
719
|
-
options?: {
|
|
720
|
-
aclMode?: DatasetAclMode
|
|
721
|
-
},
|
|
722
|
-
): Promise<DatasetResponse>
|
|
723
|
-
/**
|
|
724
|
-
* Delete a dataset with the given name
|
|
725
|
-
*
|
|
726
|
-
* @param name - Name of the dataset to delete
|
|
727
|
-
*/
|
|
728
|
-
delete(name: string): Promise<{
|
|
729
|
-
deleted: true
|
|
730
|
-
}>
|
|
731
|
-
/**
|
|
732
|
-
* Fetch a list of datasets for the configured project
|
|
733
|
-
*/
|
|
734
|
-
list(): Promise<DatasetsResponse>
|
|
735
|
-
}
|
|
736
|
-
|
|
737
950
|
/** @public */
|
|
738
951
|
export declare type DatasetsResponse = {
|
|
739
952
|
name: string
|
|
@@ -825,6 +1038,34 @@ export declare type DisconnectEvent = {
|
|
|
825
1038
|
reason: string
|
|
826
1039
|
}
|
|
827
1040
|
|
|
1041
|
+
/**
|
|
1042
|
+
*
|
|
1043
|
+
* Includes a LLM-friendly version of the document in the instruction
|
|
1044
|
+
*
|
|
1045
|
+
* ```ts
|
|
1046
|
+
* client.agent.action.generate({
|
|
1047
|
+
* schemaId,
|
|
1048
|
+
* documentId,
|
|
1049
|
+
* instruction: 'Give the following document value:\n $document \n ---\nGenerate keywords.',
|
|
1050
|
+
* instructionParams: {
|
|
1051
|
+
* document: {
|
|
1052
|
+
* type: 'document',
|
|
1053
|
+
* },
|
|
1054
|
+
* },
|
|
1055
|
+
* target: {path: 'keywords' }
|
|
1056
|
+
* })
|
|
1057
|
+
* ```
|
|
1058
|
+
*
|
|
1059
|
+
* @beta
|
|
1060
|
+
* */
|
|
1061
|
+
export declare interface DocumentAgentActionParam {
|
|
1062
|
+
type: 'document'
|
|
1063
|
+
/**
|
|
1064
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
1065
|
+
*/
|
|
1066
|
+
documentId?: string
|
|
1067
|
+
}
|
|
1068
|
+
|
|
828
1069
|
/**
|
|
829
1070
|
* Modifies an existing draft document.
|
|
830
1071
|
* It applies the given patch to the document referenced by draftId.
|
|
@@ -867,6 +1108,41 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
867
1108
|
*/
|
|
868
1109
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
869
1110
|
|
|
1111
|
+
/**
|
|
1112
|
+
*
|
|
1113
|
+
*
|
|
1114
|
+
* Includes a LLM-friendly version of the field value in the instruction
|
|
1115
|
+
*
|
|
1116
|
+
* ```ts
|
|
1117
|
+
* client.agent.action.generate({
|
|
1118
|
+
* schemaId,
|
|
1119
|
+
* documentId,
|
|
1120
|
+
* instruction: 'Give the following field value:\n $pte \n ---\nGenerate keywords.',
|
|
1121
|
+
* instructionParams: {
|
|
1122
|
+
* pte: {
|
|
1123
|
+
* type: 'field',
|
|
1124
|
+
* path: ['pteField'],
|
|
1125
|
+
* },
|
|
1126
|
+
* },
|
|
1127
|
+
* target: {path: 'keywords' }
|
|
1128
|
+
* })
|
|
1129
|
+
*
|
|
1130
|
+
* ```
|
|
1131
|
+
*
|
|
1132
|
+
* @beta
|
|
1133
|
+
* */
|
|
1134
|
+
export declare interface FieldAgentActionParam {
|
|
1135
|
+
type: 'field'
|
|
1136
|
+
/**
|
|
1137
|
+
* Examples: 'title', ['array', \{_key: 'arrayItemKey'\}, 'field']
|
|
1138
|
+
*/
|
|
1139
|
+
path: AgentActionPathSegment | AgentActionPath
|
|
1140
|
+
/**
|
|
1141
|
+
* If omitted, implicitly uses the documentId of the instruction target
|
|
1142
|
+
*/
|
|
1143
|
+
documentId?: string
|
|
1144
|
+
}
|
|
1145
|
+
|
|
870
1146
|
/** @public */
|
|
871
1147
|
export declare type FilterDefault = (props: {
|
|
872
1148
|
/**
|
|
@@ -933,6 +1209,274 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
933
1209
|
returnDocuments?: true
|
|
934
1210
|
}
|
|
935
1211
|
|
|
1212
|
+
/** @beta */
|
|
1213
|
+
declare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
1214
|
+
| GenerateExistingDocumentRequest
|
|
1215
|
+
| GenerateTargetDocumentRequest<T>
|
|
1216
|
+
) &
|
|
1217
|
+
GenerateRequestBase &
|
|
1218
|
+
AgentActionAsync
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Instruction for an existing document.
|
|
1222
|
+
* @beta
|
|
1223
|
+
*/
|
|
1224
|
+
declare interface GenerateExistingDocumentRequest {
|
|
1225
|
+
documentId: string
|
|
1226
|
+
createDocument?: never
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
/** @beta */
|
|
1230
|
+
export declare type GenerateInstruction<T extends Record<string, Any> = Record<string, Any>> =
|
|
1231
|
+
| GenerateSyncInstruction<T>
|
|
1232
|
+
| GenerateAsyncInstruction<T>
|
|
1233
|
+
|
|
1234
|
+
/** @beta */
|
|
1235
|
+
export declare type GenerateOperation = 'set' | 'append' | 'mixed'
|
|
1236
|
+
|
|
1237
|
+
/** @beta */
|
|
1238
|
+
declare interface GenerateRequestBase extends AgentActionRequestBase {
|
|
1239
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
1240
|
+
schemaId: string
|
|
1241
|
+
/**
|
|
1242
|
+
* Instruct the LLM how it should generate content. Be as specific and detailed as needed.
|
|
1243
|
+
*
|
|
1244
|
+
* The LLM only has access to information in the instruction, plus the target schema.
|
|
1245
|
+
*
|
|
1246
|
+
* string template using $variable
|
|
1247
|
+
* */
|
|
1248
|
+
instruction: string
|
|
1249
|
+
/**
|
|
1250
|
+
* param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable"
|
|
1251
|
+
*
|
|
1252
|
+
* ### Examples
|
|
1253
|
+
*
|
|
1254
|
+
* #### Constant
|
|
1255
|
+
*
|
|
1256
|
+
* ##### Shorthand
|
|
1257
|
+
* ```ts
|
|
1258
|
+
* client.agent.action.generate({
|
|
1259
|
+
* schemaId,
|
|
1260
|
+
* documentId,
|
|
1261
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nGenerate the full article.',
|
|
1262
|
+
* instructionParams: {
|
|
1263
|
+
* topic: 'Grapefruit'
|
|
1264
|
+
* },
|
|
1265
|
+
* })
|
|
1266
|
+
* ```
|
|
1267
|
+
* ##### Object-form
|
|
1268
|
+
*
|
|
1269
|
+
* ```ts
|
|
1270
|
+
* client.agent.action.generate({
|
|
1271
|
+
* schemaId,
|
|
1272
|
+
* documentId,
|
|
1273
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nGenerate the full article.',
|
|
1274
|
+
* instructionParams: {
|
|
1275
|
+
* topic: {
|
|
1276
|
+
* type: 'constant',
|
|
1277
|
+
* value: 'Grapefruit'
|
|
1278
|
+
* },
|
|
1279
|
+
* },
|
|
1280
|
+
* })
|
|
1281
|
+
* ```
|
|
1282
|
+
* #### Field
|
|
1283
|
+
* ```ts
|
|
1284
|
+
* client.agent.action.generate({
|
|
1285
|
+
* schemaId,
|
|
1286
|
+
* documentId,
|
|
1287
|
+
* instruction: 'Give the following field value:\n $pte \n ---\nGenerate keywords.',
|
|
1288
|
+
* instructionParams: {
|
|
1289
|
+
* pte: {
|
|
1290
|
+
* type: 'field',
|
|
1291
|
+
* path: ['pteField'],
|
|
1292
|
+
* },
|
|
1293
|
+
* },
|
|
1294
|
+
* target: {path: 'keywords' }
|
|
1295
|
+
* })
|
|
1296
|
+
* ```
|
|
1297
|
+
* #### Document
|
|
1298
|
+
* ```ts
|
|
1299
|
+
* client.agent.action.generate({
|
|
1300
|
+
* schemaId,
|
|
1301
|
+
* documentId,
|
|
1302
|
+
* instruction: 'Give the following document value:\n $document \n ---\nGenerate keywords.',
|
|
1303
|
+
* instructionParams: {
|
|
1304
|
+
* document: {
|
|
1305
|
+
* type: 'document',
|
|
1306
|
+
* },
|
|
1307
|
+
* },
|
|
1308
|
+
* target: {path: 'keywords' }
|
|
1309
|
+
* })
|
|
1310
|
+
* ```
|
|
1311
|
+
*
|
|
1312
|
+
* #### GROQ
|
|
1313
|
+
* ```ts
|
|
1314
|
+
* client.agent.action.generate({
|
|
1315
|
+
* schemaId,
|
|
1316
|
+
* documentId,
|
|
1317
|
+
* instruction: 'Give the following list of titles:\n $list \n ---\nGenerate a similar title.',
|
|
1318
|
+
* instructionParams: {
|
|
1319
|
+
* list: {
|
|
1320
|
+
* type: 'groq',
|
|
1321
|
+
* query: '* [_type==$type].title',
|
|
1322
|
+
* params: {type: 'article'}
|
|
1323
|
+
* },
|
|
1324
|
+
* },
|
|
1325
|
+
* target: {path: 'title' }
|
|
1326
|
+
* })
|
|
1327
|
+
* ```
|
|
1328
|
+
* */
|
|
1329
|
+
instructionParams?: AgentActionParams
|
|
1330
|
+
/**
|
|
1331
|
+
* Target defines which parts of the document will be affected by the instruction.
|
|
1332
|
+
* It can be an array, so multiple parts of the document can be separately configured in detail.
|
|
1333
|
+
*
|
|
1334
|
+
* Omitting target implies that the document itself is the root.
|
|
1335
|
+
*
|
|
1336
|
+
* Notes:
|
|
1337
|
+
* - instruction can only affect fields up to `maxPathDepth`
|
|
1338
|
+
* - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
|
|
1339
|
+
* It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
|
|
1340
|
+
*
|
|
1341
|
+
* @see AgentActionRequestBase#conditionalPaths
|
|
1342
|
+
*/
|
|
1343
|
+
target?: GenerateTarget | GenerateTarget[]
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/** @beta */
|
|
1347
|
+
declare type GenerateSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
1348
|
+
| GenerateExistingDocumentRequest
|
|
1349
|
+
| GenerateTargetDocumentRequest<T>
|
|
1350
|
+
) &
|
|
1351
|
+
GenerateRequestBase &
|
|
1352
|
+
AgentActionSync
|
|
1353
|
+
|
|
1354
|
+
/** @beta */
|
|
1355
|
+
export declare interface GenerateTarget extends AgentActionTarget {
|
|
1356
|
+
/**
|
|
1357
|
+
* Sets the default operation for all paths in the target.
|
|
1358
|
+
* Generate runs in `'mixed'` operation mode by default:
|
|
1359
|
+
* Changes are set in all non-array fields, and append to all array fields.
|
|
1360
|
+
*
|
|
1361
|
+
* ### Operation types
|
|
1362
|
+
* - `'set'` – an *overwriting* operation, and replaces the full field value.
|
|
1363
|
+
* - `'append'`:
|
|
1364
|
+
* – array fields: appends new items to the end of the array,
|
|
1365
|
+
* - string fields: '"existing content" "new content"'
|
|
1366
|
+
* - text fields: '"existing content"\\n"new content"'
|
|
1367
|
+
* - number fields: existing + new
|
|
1368
|
+
* - other field types not mentioned will set instead (dates, url)
|
|
1369
|
+
* - `'mixed'` – (default) sets non-array fields, and appends to array fields
|
|
1370
|
+
*
|
|
1371
|
+
* The default operation can be overridden on a per-path basis using `include`.
|
|
1372
|
+
*
|
|
1373
|
+
* Nested fields inherit the operation specified by their parent and falls back to the
|
|
1374
|
+
* top level target operation if not otherwise specified.
|
|
1375
|
+
*
|
|
1376
|
+
* Use `include` to change the `operation` of individual fields or items.
|
|
1377
|
+
*
|
|
1378
|
+
* #### Appending in the middle of arrays
|
|
1379
|
+
* `target: {path: ['array'], operation: 'append'}` will append the output of the instruction to the end of the array.
|
|
1380
|
+
*
|
|
1381
|
+
* To insert in the middle of the array, use `target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append'}`.
|
|
1382
|
+
* Here, the output of the instruction will be appended after the array item with key `'appendAfterKey'`.
|
|
1383
|
+
*
|
|
1384
|
+
* @see #AgentActionTargetInclude.operation
|
|
1385
|
+
* @see #include
|
|
1386
|
+
* @see #AgentActionTargetInclude.include
|
|
1387
|
+
*/
|
|
1388
|
+
operation?: GenerateOperation
|
|
1389
|
+
/**
|
|
1390
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
1391
|
+
*
|
|
1392
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
1393
|
+
*
|
|
1394
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
1395
|
+
*/
|
|
1396
|
+
include?: (AgentActionPathSegment | GenerateTargetInclude)[]
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
/** @beta */
|
|
1400
|
+
export declare type GenerateTargetDocument<T extends Record<string, Any> = Record<string, Any>> =
|
|
1401
|
+
| {
|
|
1402
|
+
operation: 'edit'
|
|
1403
|
+
_id: string
|
|
1404
|
+
}
|
|
1405
|
+
| {
|
|
1406
|
+
operation: 'create'
|
|
1407
|
+
_id?: string
|
|
1408
|
+
_type: string
|
|
1409
|
+
initialValues?: T
|
|
1410
|
+
}
|
|
1411
|
+
| {
|
|
1412
|
+
operation: 'createIfNotExists'
|
|
1413
|
+
_id: string
|
|
1414
|
+
_type: string
|
|
1415
|
+
initialValues?: T
|
|
1416
|
+
}
|
|
1417
|
+
| {
|
|
1418
|
+
operation: 'createOrReplace'
|
|
1419
|
+
_id: string
|
|
1420
|
+
_type: string
|
|
1421
|
+
initialValues?: T
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* Instruction to create a new document
|
|
1426
|
+
* @beta
|
|
1427
|
+
*/
|
|
1428
|
+
declare interface GenerateTargetDocumentRequest<
|
|
1429
|
+
T extends Record<string, Any> = Record<string, Any>,
|
|
1430
|
+
> {
|
|
1431
|
+
targetDocument: GenerateTargetDocument<T>
|
|
1432
|
+
documentId?: never
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/** @beta */
|
|
1436
|
+
export declare interface GenerateTargetInclude extends AgentActionTargetInclude {
|
|
1437
|
+
/**
|
|
1438
|
+
* Sets the operation for this path, and all its children.
|
|
1439
|
+
* This overrides any operation set parents or the root target.
|
|
1440
|
+
* @see #GenerateTarget.operation
|
|
1441
|
+
* @see #include
|
|
1442
|
+
*/
|
|
1443
|
+
operation?: GenerateOperation
|
|
1444
|
+
/**
|
|
1445
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
1446
|
+
*
|
|
1447
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
1448
|
+
*
|
|
1449
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
1450
|
+
*/
|
|
1451
|
+
include?: (AgentActionPathSegment | GenerateTargetInclude)[]
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
/**
|
|
1455
|
+
* Includes a LLM-friendly version of GROQ query result in the instruction
|
|
1456
|
+
*
|
|
1457
|
+
* ```ts
|
|
1458
|
+
* client.agent.action.generate({
|
|
1459
|
+
* schemaId,
|
|
1460
|
+
* documentId,
|
|
1461
|
+
* instruction: 'Give the following list of titles:\n $list \n ---\nGenerate a similar title.',
|
|
1462
|
+
* instructionParams: {
|
|
1463
|
+
* list: {
|
|
1464
|
+
* type: 'groq',
|
|
1465
|
+
* query: '* [_type==$type].title',
|
|
1466
|
+
* params: {type: 'article'}
|
|
1467
|
+
* },
|
|
1468
|
+
* },
|
|
1469
|
+
* target: {path: 'title' }
|
|
1470
|
+
* })
|
|
1471
|
+
* ```
|
|
1472
|
+
* @beta
|
|
1473
|
+
* */
|
|
1474
|
+
export declare interface GroqAgentActionParam {
|
|
1475
|
+
type: 'groq'
|
|
1476
|
+
query: string
|
|
1477
|
+
params?: Record<string, string>
|
|
1478
|
+
}
|
|
1479
|
+
|
|
936
1480
|
/** @public */
|
|
937
1481
|
export declare type HttpRequest = {
|
|
938
1482
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -1062,15 +1606,6 @@ export declare interface ListenOptions {
|
|
|
1062
1606
|
* @defaultValue `false`
|
|
1063
1607
|
*/
|
|
1064
1608
|
includePreviousRevision?: boolean
|
|
1065
|
-
/**
|
|
1066
|
-
* Whether to include events for drafts and versions. As of API Version >= v2025-02-19, only events
|
|
1067
|
-
* for published documents will be included by default (see {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog})
|
|
1068
|
-
* If you need events from drafts and versions, set this to `true`.
|
|
1069
|
-
* Note: Keep in mind that additional document variants may be introduced in the future, so it's
|
|
1070
|
-
* recommended to respond to events in a way that's tolerant of potential future variants, e.g. by
|
|
1071
|
-
* explicitly checking whether the event is for a draft or a version.
|
|
1072
|
-
* @defaultValue `false`
|
|
1073
|
-
*/
|
|
1074
1609
|
includeAllVersions?: boolean
|
|
1075
1610
|
/**
|
|
1076
1611
|
* Whether events should be sent as soon as a transaction has been committed (`transaction`, default),
|
|
@@ -1365,62 +1900,55 @@ export declare type MutationSelectionQueryParams = {
|
|
|
1365
1900
|
[key: string]: Any
|
|
1366
1901
|
}
|
|
1367
1902
|
|
|
1368
|
-
/** @
|
|
1369
|
-
|
|
1903
|
+
/** @public */
|
|
1904
|
+
declare class ObservableAgentsActionClient {
|
|
1370
1905
|
#private
|
|
1371
1906
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1372
1907
|
/**
|
|
1373
|
-
*
|
|
1374
|
-
*
|
|
1375
|
-
* @param assetType - Asset type (file)
|
|
1376
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1377
|
-
* @param options - Options to use for the upload
|
|
1908
|
+
* Run an instruction to generate content in a target document.
|
|
1909
|
+
* @param request - instruction request
|
|
1378
1910
|
*/
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
body: UploadBody,
|
|
1382
|
-
options?: UploadClientConfig,
|
|
1911
|
+
generate<DocumentShape extends Record<string, Any>>(
|
|
1912
|
+
request: GenerateInstruction<DocumentShape>,
|
|
1383
1913
|
): Observable<
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1914
|
+
(typeof request)['async'] extends true
|
|
1915
|
+
? {
|
|
1916
|
+
_id: string
|
|
1917
|
+
}
|
|
1918
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
1387
1919
|
>
|
|
1388
1920
|
/**
|
|
1389
|
-
*
|
|
1390
|
-
*
|
|
1391
|
-
* @param assetType - Asset type (image)
|
|
1392
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1393
|
-
* @param options - Options to use for the upload
|
|
1921
|
+
* Transform a target document based on a source.
|
|
1922
|
+
* @param request - translation request
|
|
1394
1923
|
*/
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
body: UploadBody,
|
|
1398
|
-
options?: UploadClientConfig,
|
|
1924
|
+
transform<DocumentShape extends Record<string, Any>>(
|
|
1925
|
+
request: TransformDocument<DocumentShape>,
|
|
1399
1926
|
): Observable<
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1927
|
+
(typeof request)['async'] extends true
|
|
1928
|
+
? {
|
|
1929
|
+
_id: string
|
|
1930
|
+
}
|
|
1931
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
1403
1932
|
>
|
|
1404
1933
|
/**
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
1407
|
-
* @param assetType - Asset type (file/image)
|
|
1408
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1409
|
-
* @param options - Options to use for the upload
|
|
1934
|
+
* Translate a target document based on a source.
|
|
1935
|
+
* @param request - translation request
|
|
1410
1936
|
*/
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
body: UploadBody,
|
|
1414
|
-
options?: UploadClientConfig,
|
|
1937
|
+
translate<DocumentShape extends Record<string, Any>>(
|
|
1938
|
+
request: TranslateDocument<DocumentShape>,
|
|
1415
1939
|
): Observable<
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1940
|
+
(typeof request)['async'] extends true
|
|
1941
|
+
? {
|
|
1942
|
+
_id: string
|
|
1943
|
+
}
|
|
1944
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
1419
1945
|
>
|
|
1420
1946
|
}
|
|
1421
1947
|
|
|
1422
1948
|
/** @internal */
|
|
1423
|
-
declare
|
|
1949
|
+
export declare class ObservableAssetsClient {
|
|
1950
|
+
#private
|
|
1951
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1424
1952
|
/**
|
|
1425
1953
|
* Uploads a file asset to the configured dataset
|
|
1426
1954
|
*
|
|
@@ -1472,7 +2000,7 @@ declare interface ObservableAssetsClientType {
|
|
|
1472
2000
|
}
|
|
1473
2001
|
|
|
1474
2002
|
/** @internal */
|
|
1475
|
-
export declare class ObservableDatasetsClient
|
|
2003
|
+
export declare class ObservableDatasetsClient {
|
|
1476
2004
|
#private
|
|
1477
2005
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1478
2006
|
/**
|
|
@@ -1513,46 +2041,6 @@ export declare class ObservableDatasetsClient implements ObservableDatasetsClien
|
|
|
1513
2041
|
list(): Observable<DatasetsResponse>
|
|
1514
2042
|
}
|
|
1515
2043
|
|
|
1516
|
-
/** @internal */
|
|
1517
|
-
declare interface ObservableDatasetsClientType {
|
|
1518
|
-
/**
|
|
1519
|
-
* Create a new dataset with the given name
|
|
1520
|
-
*
|
|
1521
|
-
* @param name - Name of the dataset to create
|
|
1522
|
-
* @param options - Options for the dataset
|
|
1523
|
-
*/
|
|
1524
|
-
create(
|
|
1525
|
-
name: string,
|
|
1526
|
-
options?: {
|
|
1527
|
-
aclMode?: DatasetAclMode
|
|
1528
|
-
},
|
|
1529
|
-
): Observable<DatasetResponse>
|
|
1530
|
-
/**
|
|
1531
|
-
* Edit a dataset with the given name
|
|
1532
|
-
*
|
|
1533
|
-
* @param name - Name of the dataset to edit
|
|
1534
|
-
* @param options - New options for the dataset
|
|
1535
|
-
*/
|
|
1536
|
-
edit(
|
|
1537
|
-
name: string,
|
|
1538
|
-
options?: {
|
|
1539
|
-
aclMode?: DatasetAclMode
|
|
1540
|
-
},
|
|
1541
|
-
): Observable<DatasetResponse>
|
|
1542
|
-
/**
|
|
1543
|
-
* Delete a dataset with the given name
|
|
1544
|
-
*
|
|
1545
|
-
* @param name - Name of the dataset to delete
|
|
1546
|
-
*/
|
|
1547
|
-
delete(name: string): Observable<{
|
|
1548
|
-
deleted: true
|
|
1549
|
-
}>
|
|
1550
|
-
/**
|
|
1551
|
-
* Fetch a list of datasets for the configured project
|
|
1552
|
-
*/
|
|
1553
|
-
list(): Observable<DatasetsResponse>
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
2044
|
/** @public */
|
|
1557
2045
|
export declare class ObservablePatch extends BasePatch {
|
|
1558
2046
|
#private
|
|
@@ -1607,38 +2095,17 @@ export declare class ObservablePatch extends BasePatch {
|
|
|
1607
2095
|
export declare type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch
|
|
1608
2096
|
|
|
1609
2097
|
/** @internal */
|
|
1610
|
-
export declare class ObservableProjectsClient
|
|
2098
|
+
export declare class ObservableProjectsClient {
|
|
1611
2099
|
#private
|
|
1612
2100
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1613
2101
|
/**
|
|
1614
2102
|
* Fetch a list of projects the authenticated user has access to.
|
|
1615
2103
|
*
|
|
1616
2104
|
* @param options - Options for the list request
|
|
1617
|
-
*
|
|
1618
|
-
*/
|
|
1619
|
-
list(options?: {includeMembers?: true}): Observable<SanityProject[]>
|
|
1620
|
-
list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
|
|
1621
|
-
/**
|
|
1622
|
-
* Fetch a project by project ID
|
|
1623
|
-
*
|
|
1624
|
-
* @param projectId - ID of the project to fetch
|
|
1625
|
-
*/
|
|
1626
|
-
getById(projectId: string): Observable<SanityProject>
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
/** @internal */
|
|
1630
|
-
declare interface ObservableProjectsClientType {
|
|
1631
|
-
/**
|
|
1632
|
-
* Fetch a list of projects the authenticated user has access to.
|
|
1633
|
-
*
|
|
1634
|
-
* @param options - Options for the list request
|
|
1635
|
-
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
2105
|
+
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
1636
2106
|
*/
|
|
1637
2107
|
list(options?: {includeMembers?: true}): Observable<SanityProject[]>
|
|
1638
2108
|
list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
|
|
1639
|
-
list(options?: {
|
|
1640
|
-
includeMembers?: boolean
|
|
1641
|
-
}): Observable<SanityProject[] | Omit<SanityProject, 'members'>[]>
|
|
1642
2109
|
/**
|
|
1643
2110
|
* Fetch a project by project ID
|
|
1644
2111
|
*
|
|
@@ -1648,13 +2115,19 @@ declare interface ObservableProjectsClientType {
|
|
|
1648
2115
|
}
|
|
1649
2116
|
|
|
1650
2117
|
/** @public */
|
|
1651
|
-
export declare class ObservableSanityClient
|
|
2118
|
+
export declare class ObservableSanityClient {
|
|
1652
2119
|
#private
|
|
1653
2120
|
assets: ObservableAssetsClient
|
|
1654
2121
|
datasets: ObservableDatasetsClient
|
|
1655
2122
|
live: LiveClient
|
|
1656
2123
|
projects: ObservableProjectsClient
|
|
1657
2124
|
users: ObservableUsersClient
|
|
2125
|
+
agent: {
|
|
2126
|
+
action: ObservableAgentsActionClient
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* Instance properties
|
|
2130
|
+
*/
|
|
1658
2131
|
listen: typeof _listen
|
|
1659
2132
|
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1660
2133
|
/**
|
|
@@ -1713,7 +2186,7 @@ export declare class ObservableSanityClient implements ObservableSanityClientTyp
|
|
|
1713
2186
|
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1714
2187
|
const G extends string = string,
|
|
1715
2188
|
>(
|
|
1716
|
-
query:
|
|
2189
|
+
query: string,
|
|
1717
2190
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1718
2191
|
options: UnfilteredResponseQueryOptions,
|
|
1719
2192
|
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
@@ -2148,1516 +2621,445 @@ export declare class ObservableSanityClient implements ObservableSanityClientTyp
|
|
|
2148
2621
|
getDataUrl(operation: string, path?: string): string
|
|
2149
2622
|
}
|
|
2150
2623
|
|
|
2151
|
-
/**
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
* in cases where you might have multiple `@sanity/client` instances in your node_modules.
|
|
2156
|
-
* @public
|
|
2157
|
-
*/
|
|
2158
|
-
export declare interface ObservableSanityClientType extends SanityClientBase {
|
|
2159
|
-
assets: ObservableAssetsClientType
|
|
2160
|
-
datasets: ObservableDatasetsClientType
|
|
2161
|
-
projects: ObservableProjectsClientType
|
|
2162
|
-
users: ObservableUsersClientType
|
|
2624
|
+
/** @public */
|
|
2625
|
+
export declare class ObservableTransaction extends BaseTransaction {
|
|
2626
|
+
#private
|
|
2627
|
+
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
2163
2628
|
/**
|
|
2164
|
-
*
|
|
2629
|
+
* Clones the transaction
|
|
2165
2630
|
*/
|
|
2166
|
-
clone():
|
|
2631
|
+
clone(): ObservableTransaction
|
|
2167
2632
|
/**
|
|
2168
|
-
*
|
|
2633
|
+
* Commit the transaction, returning an observable that produces the first mutated document
|
|
2634
|
+
*
|
|
2635
|
+
* @param options - Options for the mutation operation
|
|
2169
2636
|
*/
|
|
2170
|
-
|
|
2637
|
+
commit<R extends Record<string, Any>>(
|
|
2638
|
+
options: TransactionFirstDocumentMutationOptions,
|
|
2639
|
+
): Observable<SanityDocument<R>>
|
|
2171
2640
|
/**
|
|
2172
|
-
*
|
|
2641
|
+
* Commit the transaction, returning an observable that produces an array of the mutated documents
|
|
2642
|
+
*
|
|
2643
|
+
* @param options - Options for the mutation operation
|
|
2173
2644
|
*/
|
|
2174
|
-
|
|
2645
|
+
commit<R extends Record<string, Any>>(
|
|
2646
|
+
options: TransactionAllDocumentsMutationOptions,
|
|
2647
|
+
): Observable<SanityDocument<R>[]>
|
|
2175
2648
|
/**
|
|
2176
|
-
*
|
|
2649
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2177
2650
|
*
|
|
2178
|
-
* @param
|
|
2651
|
+
* @param options - Options for the mutation operation
|
|
2179
2652
|
*/
|
|
2180
|
-
|
|
2653
|
+
commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2181
2654
|
/**
|
|
2182
|
-
*
|
|
2655
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2183
2656
|
*
|
|
2184
|
-
* @param
|
|
2657
|
+
* @param options - Options for the mutation operation
|
|
2185
2658
|
*/
|
|
2186
|
-
|
|
2187
|
-
R = Any,
|
|
2188
|
-
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
2189
|
-
const G extends string = string,
|
|
2190
|
-
>(
|
|
2191
|
-
query: G,
|
|
2192
|
-
params?: Q | QueryWithoutParams,
|
|
2193
|
-
): Observable<ClientReturn<G, R>>
|
|
2659
|
+
commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2194
2660
|
/**
|
|
2195
|
-
*
|
|
2661
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2196
2662
|
*
|
|
2197
|
-
* @param
|
|
2198
|
-
* @param params - Optional query parameters
|
|
2199
|
-
* @param options - Optional request options
|
|
2663
|
+
* @param options - Options for the mutation operation
|
|
2200
2664
|
*/
|
|
2201
|
-
|
|
2202
|
-
R = Any,
|
|
2203
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2204
|
-
const G extends string = string,
|
|
2205
|
-
>(
|
|
2206
|
-
query: G,
|
|
2207
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2208
|
-
options?: FilteredResponseQueryOptions,
|
|
2209
|
-
): Observable<ClientReturn<G, R>>
|
|
2665
|
+
commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
|
|
2210
2666
|
/**
|
|
2211
|
-
*
|
|
2667
|
+
* Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
|
|
2668
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2212
2669
|
*
|
|
2213
|
-
* @param
|
|
2214
|
-
* @param
|
|
2215
|
-
* @param options - Request options
|
|
2670
|
+
* @param documentId - Document ID to perform the patch operation on
|
|
2671
|
+
* @param patchOps - Operations to perform, or a builder function
|
|
2216
2672
|
*/
|
|
2217
|
-
|
|
2218
|
-
R = Any,
|
|
2219
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2220
|
-
const G extends string = string,
|
|
2221
|
-
>(
|
|
2222
|
-
query: G,
|
|
2223
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2224
|
-
options: UnfilteredResponseQueryOptions,
|
|
2225
|
-
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
2673
|
+
patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
|
|
2226
2674
|
/**
|
|
2227
|
-
*
|
|
2675
|
+
* Adds the given patch instance to the transaction.
|
|
2676
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2228
2677
|
*
|
|
2229
|
-
* @param
|
|
2230
|
-
* @param params - Optional query parameters
|
|
2231
|
-
* @param options - Request options
|
|
2678
|
+
* @param patch - ObservablePatch to execute
|
|
2232
2679
|
*/
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
options: UnfilteredResponseWithoutQuery,
|
|
2241
|
-
): Observable<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
2680
|
+
patch(patch: ObservablePatch): this
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
/** @public */
|
|
2684
|
+
export declare class ObservableUsersClient {
|
|
2685
|
+
#private
|
|
2686
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
2242
2687
|
/**
|
|
2243
|
-
* Fetch a
|
|
2688
|
+
* Fetch a user by user ID
|
|
2244
2689
|
*
|
|
2245
|
-
* @param id -
|
|
2246
|
-
* @param options - Request options
|
|
2690
|
+
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
2247
2691
|
*/
|
|
2248
|
-
|
|
2249
|
-
id:
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2692
|
+
getById<T extends 'me' | string>(
|
|
2693
|
+
id: T,
|
|
2694
|
+
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
/**
|
|
2698
|
+
* The listener connection has been established
|
|
2699
|
+
* note: it's usually a better option to use the 'welcome' event
|
|
2700
|
+
* @public
|
|
2701
|
+
*/
|
|
2702
|
+
export declare type OpenEvent = {
|
|
2703
|
+
type: 'open'
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
/** @public */
|
|
2707
|
+
export declare class Patch extends BasePatch {
|
|
2708
|
+
#private
|
|
2709
|
+
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
2254
2710
|
/**
|
|
2255
|
-
*
|
|
2256
|
-
* Should be used sparingly - performing a query is usually a better option.
|
|
2257
|
-
* The order/position of documents is preserved based on the original array of IDs.
|
|
2258
|
-
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
2259
|
-
*
|
|
2260
|
-
* @param ids - Document IDs to fetch
|
|
2261
|
-
* @param options - Request options
|
|
2711
|
+
* Clones the patch
|
|
2262
2712
|
*/
|
|
2263
|
-
|
|
2264
|
-
ids: string[],
|
|
2265
|
-
options?: {
|
|
2266
|
-
tag?: string
|
|
2267
|
-
},
|
|
2268
|
-
): Observable<(SanityDocument<R> | null)[]>
|
|
2713
|
+
clone(): Patch
|
|
2269
2714
|
/**
|
|
2270
|
-
*
|
|
2271
|
-
* Returns an observable that resolves to the created document.
|
|
2715
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2272
2716
|
*
|
|
2273
|
-
* @param
|
|
2274
|
-
* @param options - Mutation options
|
|
2717
|
+
* @param options - Options for the mutation operation
|
|
2275
2718
|
*/
|
|
2276
|
-
|
|
2277
|
-
document: SanityDocumentStub<R>,
|
|
2719
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2278
2720
|
options: FirstDocumentMutationOptions,
|
|
2279
|
-
):
|
|
2721
|
+
): Promise<SanityDocument<R>>
|
|
2280
2722
|
/**
|
|
2281
|
-
*
|
|
2282
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
2723
|
+
* Commit the patch, returning a promise that resolves to an array of the mutated documents
|
|
2283
2724
|
*
|
|
2284
|
-
* @param
|
|
2285
|
-
* @param options - Mutation options
|
|
2725
|
+
* @param options - Options for the mutation operation
|
|
2286
2726
|
*/
|
|
2287
|
-
|
|
2288
|
-
document: SanityDocumentStub<R>,
|
|
2289
|
-
options: AllDocumentsMutationOptions,
|
|
2290
|
-
): Observable<SanityDocument<R>[]>
|
|
2291
|
-
/**
|
|
2292
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2293
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2294
|
-
*
|
|
2295
|
-
* @param document - Document to create
|
|
2296
|
-
* @param options - Mutation options
|
|
2297
|
-
*/
|
|
2298
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2299
|
-
document: SanityDocumentStub<R>,
|
|
2300
|
-
options: FirstDocumentIdMutationOptions,
|
|
2301
|
-
): Observable<SingleMutationResult>
|
|
2302
|
-
/**
|
|
2303
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2304
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2305
|
-
*
|
|
2306
|
-
* @param document - Document to create
|
|
2307
|
-
* @param options - Mutation options
|
|
2308
|
-
*/
|
|
2309
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2310
|
-
document: SanityDocumentStub<R>,
|
|
2311
|
-
options: AllDocumentIdsMutationOptions,
|
|
2312
|
-
): Observable<MultipleMutationResult>
|
|
2313
|
-
/**
|
|
2314
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2315
|
-
* Returns an observable that resolves to the created document.
|
|
2316
|
-
*
|
|
2317
|
-
* @param document - Document to create
|
|
2318
|
-
* @param options - Mutation options
|
|
2319
|
-
*/
|
|
2320
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2321
|
-
document: SanityDocumentStub<R>,
|
|
2322
|
-
options?: BaseMutationOptions,
|
|
2323
|
-
): Observable<SanityDocument<R>>
|
|
2324
|
-
/**
|
|
2325
|
-
* Create a document if no document with the same ID already exists.
|
|
2326
|
-
* Returns an observable that resolves to the created document.
|
|
2327
|
-
*
|
|
2328
|
-
* @param document - Document to create
|
|
2329
|
-
* @param options - Mutation options
|
|
2330
|
-
*/
|
|
2331
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2332
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2333
|
-
options: FirstDocumentMutationOptions,
|
|
2334
|
-
): Observable<SanityDocument<R>>
|
|
2335
|
-
/**
|
|
2336
|
-
* Create a document if no document with the same ID already exists.
|
|
2337
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
2338
|
-
*
|
|
2339
|
-
* @param document - Document to create
|
|
2340
|
-
* @param options - Mutation options
|
|
2341
|
-
*/
|
|
2342
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2343
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2344
|
-
options: AllDocumentsMutationOptions,
|
|
2345
|
-
): Observable<SanityDocument<R>[]>
|
|
2346
|
-
/**
|
|
2347
|
-
* Create a document if no document with the same ID already exists.
|
|
2348
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2349
|
-
*
|
|
2350
|
-
* @param document - Document to create
|
|
2351
|
-
* @param options - Mutation options
|
|
2352
|
-
*/
|
|
2353
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2354
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2355
|
-
options: FirstDocumentIdMutationOptions,
|
|
2356
|
-
): Observable<SingleMutationResult>
|
|
2357
|
-
/**
|
|
2358
|
-
* Create a document if no document with the same ID already exists.
|
|
2359
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2360
|
-
*
|
|
2361
|
-
* @param document - Document to create
|
|
2362
|
-
* @param options - Mutation options
|
|
2363
|
-
*/
|
|
2364
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2365
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2366
|
-
options: AllDocumentIdsMutationOptions,
|
|
2367
|
-
): Observable<MultipleMutationResult>
|
|
2368
|
-
/**
|
|
2369
|
-
* Create a document if no document with the same ID already exists.
|
|
2370
|
-
* Returns an observable that resolves to the created document.
|
|
2371
|
-
*
|
|
2372
|
-
* @param document - Document to create
|
|
2373
|
-
* @param options - Mutation options
|
|
2374
|
-
*/
|
|
2375
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2376
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2377
|
-
options?: BaseMutationOptions,
|
|
2378
|
-
): Observable<SanityDocument<R>>
|
|
2379
|
-
/**
|
|
2380
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2381
|
-
* Returns an observable that resolves to the created document.
|
|
2382
|
-
*
|
|
2383
|
-
* @param document - Document to either create or replace
|
|
2384
|
-
* @param options - Mutation options
|
|
2385
|
-
*/
|
|
2386
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2387
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2388
|
-
options: FirstDocumentMutationOptions,
|
|
2389
|
-
): Observable<SanityDocument<R>>
|
|
2390
|
-
/**
|
|
2391
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2392
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
2393
|
-
*
|
|
2394
|
-
* @param document - Document to either create or replace
|
|
2395
|
-
* @param options - Mutation options
|
|
2396
|
-
*/
|
|
2397
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2398
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2399
|
-
options: AllDocumentsMutationOptions,
|
|
2400
|
-
): Observable<SanityDocument<R>[]>
|
|
2401
|
-
/**
|
|
2402
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2403
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2404
|
-
*
|
|
2405
|
-
* @param document - Document to either create or replace
|
|
2406
|
-
* @param options - Mutation options
|
|
2407
|
-
*/
|
|
2408
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2409
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2410
|
-
options: FirstDocumentIdMutationOptions,
|
|
2411
|
-
): Observable<SingleMutationResult>
|
|
2412
|
-
/**
|
|
2413
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2414
|
-
* Returns an observable that resolves to a mutation result object containing the created document ID.
|
|
2415
|
-
*
|
|
2416
|
-
* @param document - Document to either create or replace
|
|
2417
|
-
* @param options - Mutation options
|
|
2418
|
-
*/
|
|
2419
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2420
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2421
|
-
options: AllDocumentIdsMutationOptions,
|
|
2422
|
-
): Observable<MultipleMutationResult>
|
|
2423
|
-
/**
|
|
2424
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2425
|
-
* Returns an observable that resolves to the created document.
|
|
2426
|
-
*
|
|
2427
|
-
* @param document - Document to either create or replace
|
|
2428
|
-
* @param options - Mutation options
|
|
2429
|
-
*/
|
|
2430
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2431
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2432
|
-
options?: BaseMutationOptions,
|
|
2433
|
-
): Observable<SanityDocument<R>>
|
|
2434
|
-
/**
|
|
2435
|
-
* Deletes a document with the given document ID.
|
|
2436
|
-
* Returns an observable that resolves to the deleted document.
|
|
2437
|
-
*
|
|
2438
|
-
* @param id - Document ID to delete
|
|
2439
|
-
* @param options - Options for the mutation
|
|
2440
|
-
*/
|
|
2441
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2442
|
-
id: string,
|
|
2443
|
-
options: FirstDocumentMutationOptions,
|
|
2444
|
-
): Observable<SanityDocument<R>>
|
|
2445
|
-
/**
|
|
2446
|
-
* Deletes a document with the given document ID.
|
|
2447
|
-
* Returns an observable that resolves to an array containing the deleted document.
|
|
2448
|
-
*
|
|
2449
|
-
* @param id - Document ID to delete
|
|
2450
|
-
* @param options - Options for the mutation
|
|
2451
|
-
*/
|
|
2452
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2453
|
-
id: string,
|
|
2454
|
-
options: AllDocumentsMutationOptions,
|
|
2455
|
-
): Observable<SanityDocument<R>[]>
|
|
2456
|
-
/**
|
|
2457
|
-
* Deletes a document with the given document ID.
|
|
2458
|
-
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
2459
|
-
*
|
|
2460
|
-
* @param id - Document ID to delete
|
|
2461
|
-
* @param options - Options for the mutation
|
|
2462
|
-
*/
|
|
2463
|
-
delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2464
|
-
/**
|
|
2465
|
-
* Deletes a document with the given document ID.
|
|
2466
|
-
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
2467
|
-
*
|
|
2468
|
-
* @param id - Document ID to delete
|
|
2469
|
-
* @param options - Options for the mutation
|
|
2470
|
-
*/
|
|
2471
|
-
delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2472
|
-
/**
|
|
2473
|
-
* Deletes a document with the given document ID.
|
|
2474
|
-
* Returns an observable that resolves to the deleted document.
|
|
2475
|
-
*
|
|
2476
|
-
* @param id - Document ID to delete
|
|
2477
|
-
* @param options - Options for the mutation
|
|
2478
|
-
*/
|
|
2479
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2480
|
-
id: string,
|
|
2481
|
-
options?: BaseMutationOptions,
|
|
2482
|
-
): Observable<SanityDocument<R>>
|
|
2483
|
-
/**
|
|
2484
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2485
|
-
* Returns an observable that resolves to first deleted document.
|
|
2486
|
-
*
|
|
2487
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2488
|
-
* @param options - Options for the mutation
|
|
2489
|
-
*/
|
|
2490
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2491
|
-
selection: MutationSelection,
|
|
2492
|
-
options: FirstDocumentMutationOptions,
|
|
2493
|
-
): Observable<SanityDocument<R>>
|
|
2494
|
-
/**
|
|
2495
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2496
|
-
* Returns an observable that resolves to an array containing the deleted documents.
|
|
2497
|
-
*
|
|
2498
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2499
|
-
* @param options - Options for the mutation
|
|
2500
|
-
*/
|
|
2501
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2502
|
-
selection: MutationSelection,
|
|
2503
|
-
options: AllDocumentsMutationOptions,
|
|
2504
|
-
): Observable<SanityDocument<R>[]>
|
|
2505
|
-
/**
|
|
2506
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2507
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
|
|
2508
|
-
*
|
|
2509
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2510
|
-
* @param options - Options for the mutation
|
|
2511
|
-
*/
|
|
2512
|
-
delete(
|
|
2513
|
-
selection: MutationSelection,
|
|
2514
|
-
options: FirstDocumentIdMutationOptions,
|
|
2515
|
-
): Observable<SingleMutationResult>
|
|
2516
|
-
/**
|
|
2517
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2518
|
-
* Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
|
|
2519
|
-
*
|
|
2520
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2521
|
-
* @param options - Options for the mutation
|
|
2522
|
-
*/
|
|
2523
|
-
delete(
|
|
2524
|
-
selection: MutationSelection,
|
|
2525
|
-
options: AllDocumentIdsMutationOptions,
|
|
2526
|
-
): Observable<MultipleMutationResult>
|
|
2527
|
-
/**
|
|
2528
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2529
|
-
* Returns an observable that resolves to first deleted document.
|
|
2530
|
-
*
|
|
2531
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2532
|
-
* @param options - Options for the mutation
|
|
2533
|
-
*/
|
|
2534
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2535
|
-
selection: MutationSelection,
|
|
2536
|
-
options?: BaseMutationOptions,
|
|
2537
|
-
): Observable<SanityDocument<R>>
|
|
2538
|
-
/**
|
|
2539
|
-
* Perform mutation operations against the configured dataset
|
|
2540
|
-
* Returns an observable that resolves to the first mutated document.
|
|
2541
|
-
*
|
|
2542
|
-
* @param operations - Mutation operations to execute
|
|
2543
|
-
* @param options - Mutation options
|
|
2544
|
-
*/
|
|
2545
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2546
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2547
|
-
options: FirstDocumentMutationOptions,
|
|
2548
|
-
): Observable<SanityDocument<R>>
|
|
2549
|
-
/**
|
|
2550
|
-
* Perform mutation operations against the configured dataset.
|
|
2551
|
-
* Returns an observable that resolves to an array of the mutated documents.
|
|
2552
|
-
*
|
|
2553
|
-
* @param operations - Mutation operations to execute
|
|
2554
|
-
* @param options - Mutation options
|
|
2555
|
-
*/
|
|
2556
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2557
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2558
|
-
options: AllDocumentsMutationOptions,
|
|
2559
|
-
): Observable<SanityDocument<R>[]>
|
|
2560
|
-
/**
|
|
2561
|
-
* Perform mutation operations against the configured dataset
|
|
2562
|
-
* Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
2563
|
-
*
|
|
2564
|
-
* @param operations - Mutation operations to execute
|
|
2565
|
-
* @param options - Mutation options
|
|
2566
|
-
*/
|
|
2567
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2568
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2569
|
-
options: FirstDocumentIdMutationOptions,
|
|
2570
|
-
): Observable<SingleMutationResult>
|
|
2571
|
-
/**
|
|
2572
|
-
* Perform mutation operations against the configured dataset
|
|
2573
|
-
* Returns an observable that resolves to a mutation result object containing the mutated document IDs.
|
|
2574
|
-
*
|
|
2575
|
-
* @param operations - Mutation operations to execute
|
|
2576
|
-
* @param options - Mutation options
|
|
2577
|
-
*/
|
|
2578
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2579
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2580
|
-
options: AllDocumentIdsMutationOptions,
|
|
2581
|
-
): Observable<MultipleMutationResult>
|
|
2582
|
-
/**
|
|
2583
|
-
* Perform mutation operations against the configured dataset
|
|
2584
|
-
* Returns an observable that resolves to the first mutated document.
|
|
2585
|
-
*
|
|
2586
|
-
* @param operations - Mutation operations to execute
|
|
2587
|
-
* @param options - Mutation options
|
|
2588
|
-
*/
|
|
2589
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2590
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2591
|
-
options?: BaseMutationOptions,
|
|
2592
|
-
): Observable<SanityDocument<R>>
|
|
2593
|
-
/**
|
|
2594
|
-
* Create a new buildable patch of operations to perform
|
|
2595
|
-
*
|
|
2596
|
-
* @param documentId - Document ID to patch
|
|
2597
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2598
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2599
|
-
*/
|
|
2600
|
-
patch(documentId: string, operations?: PatchOperations): ObservablePatch
|
|
2601
|
-
/**
|
|
2602
|
-
* Create a new buildable patch of operations to perform
|
|
2603
|
-
*
|
|
2604
|
-
* @param documentIds - Array of document IDs to patch
|
|
2605
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2606
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2607
|
-
*/
|
|
2608
|
-
patch(documentIds: string[], operations?: PatchOperations): ObservablePatch
|
|
2609
|
-
/**
|
|
2610
|
-
* Create a new buildable patch of operations to perform
|
|
2611
|
-
*
|
|
2612
|
-
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
2613
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2614
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2615
|
-
*/
|
|
2616
|
-
patch(selection: MutationSelection, operations?: PatchOperations): ObservablePatch
|
|
2617
|
-
/**
|
|
2618
|
-
* Create a new buildable patch of operations to perform
|
|
2619
|
-
*
|
|
2620
|
-
* @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch
|
|
2621
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2622
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2623
|
-
*/
|
|
2624
|
-
patch(selection: PatchSelection, operations?: PatchOperations): ObservablePatch
|
|
2625
|
-
/**
|
|
2626
|
-
* Create a new transaction of mutations
|
|
2627
|
-
*
|
|
2628
|
-
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
2629
|
-
*/
|
|
2630
|
-
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
2631
|
-
operations?: Mutation<R>[],
|
|
2632
|
-
): ObservableTransaction
|
|
2633
|
-
/**
|
|
2634
|
-
* Perform action operations against the configured dataset
|
|
2635
|
-
*
|
|
2636
|
-
* @param operations - Action operation(s) to execute
|
|
2637
|
-
* @param options - Action options
|
|
2638
|
-
*/
|
|
2639
|
-
action(
|
|
2640
|
-
operations: Action | Action[],
|
|
2641
|
-
options?: BaseActionOptions,
|
|
2642
|
-
): Observable<SingleActionResult | MultipleActionResult>
|
|
2643
|
-
/**
|
|
2644
|
-
* Perform an HTTP request against the Sanity API
|
|
2645
|
-
*
|
|
2646
|
-
* @param options - Request options
|
|
2647
|
-
*/
|
|
2648
|
-
request<R = Any>(options: RawRequestOptions): Observable<R>
|
|
2649
|
-
}
|
|
2650
|
-
|
|
2651
|
-
/** @public */
|
|
2652
|
-
export declare class ObservableTransaction extends BaseTransaction {
|
|
2653
|
-
#private
|
|
2654
|
-
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
2655
|
-
/**
|
|
2656
|
-
* Clones the transaction
|
|
2657
|
-
*/
|
|
2658
|
-
clone(): ObservableTransaction
|
|
2659
|
-
/**
|
|
2660
|
-
* Commit the transaction, returning an observable that produces the first mutated document
|
|
2661
|
-
*
|
|
2662
|
-
* @param options - Options for the mutation operation
|
|
2663
|
-
*/
|
|
2664
|
-
commit<R extends Record<string, Any>>(
|
|
2665
|
-
options: TransactionFirstDocumentMutationOptions,
|
|
2666
|
-
): Observable<SanityDocument<R>>
|
|
2667
|
-
/**
|
|
2668
|
-
* Commit the transaction, returning an observable that produces an array of the mutated documents
|
|
2669
|
-
*
|
|
2670
|
-
* @param options - Options for the mutation operation
|
|
2671
|
-
*/
|
|
2672
|
-
commit<R extends Record<string, Any>>(
|
|
2673
|
-
options: TransactionAllDocumentsMutationOptions,
|
|
2674
|
-
): Observable<SanityDocument<R>[]>
|
|
2675
|
-
/**
|
|
2676
|
-
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2677
|
-
*
|
|
2678
|
-
* @param options - Options for the mutation operation
|
|
2679
|
-
*/
|
|
2680
|
-
commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2681
|
-
/**
|
|
2682
|
-
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2683
|
-
*
|
|
2684
|
-
* @param options - Options for the mutation operation
|
|
2685
|
-
*/
|
|
2686
|
-
commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2687
|
-
/**
|
|
2688
|
-
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2689
|
-
*
|
|
2690
|
-
* @param options - Options for the mutation operation
|
|
2691
|
-
*/
|
|
2692
|
-
commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
|
|
2693
|
-
/**
|
|
2694
|
-
* Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
|
|
2695
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2696
|
-
*
|
|
2697
|
-
* @param documentId - Document ID to perform the patch operation on
|
|
2698
|
-
* @param patchOps - Operations to perform, or a builder function
|
|
2699
|
-
*/
|
|
2700
|
-
patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
|
|
2701
|
-
/**
|
|
2702
|
-
* Adds the given patch instance to the transaction.
|
|
2703
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2704
|
-
*
|
|
2705
|
-
* @param patch - ObservablePatch to execute
|
|
2706
|
-
*/
|
|
2707
|
-
patch(patch: ObservablePatch): this
|
|
2708
|
-
}
|
|
2709
|
-
|
|
2710
|
-
/** @public */
|
|
2711
|
-
export declare class ObservableUsersClient implements ObservableUsersClientType {
|
|
2712
|
-
#private
|
|
2713
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
2714
|
-
/**
|
|
2715
|
-
* Fetch a user by user ID
|
|
2716
|
-
*
|
|
2717
|
-
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
2718
|
-
*/
|
|
2719
|
-
getById<T extends 'me' | string>(
|
|
2720
|
-
id: T,
|
|
2721
|
-
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
2722
|
-
}
|
|
2723
|
-
|
|
2724
|
-
/** @internal */
|
|
2725
|
-
declare interface ObservableUsersClientType {
|
|
2726
|
-
/**
|
|
2727
|
-
* Fetch a user by user ID
|
|
2728
|
-
*
|
|
2729
|
-
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
2730
|
-
*/
|
|
2731
|
-
getById<T extends 'me' | string>(
|
|
2732
|
-
id: T,
|
|
2733
|
-
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
2734
|
-
}
|
|
2735
|
-
|
|
2736
|
-
/**
|
|
2737
|
-
* The listener connection has been established
|
|
2738
|
-
* note: it's usually a better option to use the 'welcome' event
|
|
2739
|
-
* @public
|
|
2740
|
-
*/
|
|
2741
|
-
export declare type OpenEvent = {
|
|
2742
|
-
type: 'open'
|
|
2743
|
-
}
|
|
2744
|
-
|
|
2745
|
-
/** @public */
|
|
2746
|
-
export declare class Patch extends BasePatch {
|
|
2747
|
-
#private
|
|
2748
|
-
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
2749
|
-
/**
|
|
2750
|
-
* Clones the patch
|
|
2751
|
-
*/
|
|
2752
|
-
clone(): Patch
|
|
2753
|
-
/**
|
|
2754
|
-
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2755
|
-
*
|
|
2756
|
-
* @param options - Options for the mutation operation
|
|
2757
|
-
*/
|
|
2758
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2759
|
-
options: FirstDocumentMutationOptions,
|
|
2760
|
-
): Promise<SanityDocument<R>>
|
|
2761
|
-
/**
|
|
2762
|
-
* Commit the patch, returning a promise that resolves to an array of the mutated documents
|
|
2763
|
-
*
|
|
2764
|
-
* @param options - Options for the mutation operation
|
|
2765
|
-
*/
|
|
2766
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2767
|
-
options: AllDocumentsMutationOptions,
|
|
2768
|
-
): Promise<SanityDocument<R>[]>
|
|
2769
|
-
/**
|
|
2770
|
-
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2771
|
-
*
|
|
2772
|
-
* @param options - Options for the mutation operation
|
|
2773
|
-
*/
|
|
2774
|
-
commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2775
|
-
/**
|
|
2776
|
-
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2777
|
-
*
|
|
2778
|
-
* @param options - Options for the mutation operation
|
|
2779
|
-
*/
|
|
2780
|
-
commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
2781
|
-
/**
|
|
2782
|
-
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2783
|
-
*
|
|
2784
|
-
* @param options - Options for the mutation operation
|
|
2785
|
-
*/
|
|
2786
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2787
|
-
options?: BaseMutationOptions,
|
|
2788
|
-
): Promise<SanityDocument<R>>
|
|
2789
|
-
}
|
|
2790
|
-
|
|
2791
|
-
/** @public */
|
|
2792
|
-
export declare type PatchBuilder = (patch: Patch) => Patch
|
|
2793
|
-
|
|
2794
|
-
/** @internal */
|
|
2795
|
-
export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
2796
|
-
|
|
2797
|
-
/** @internal */
|
|
2798
|
-
export declare interface PatchOperations {
|
|
2799
|
-
set?: {
|
|
2800
|
-
[key: string]: Any
|
|
2801
|
-
}
|
|
2802
|
-
setIfMissing?: {
|
|
2803
|
-
[key: string]: Any
|
|
2804
|
-
}
|
|
2805
|
-
diffMatchPatch?: {
|
|
2806
|
-
[key: string]: Any
|
|
2807
|
-
}
|
|
2808
|
-
unset?: string[]
|
|
2809
|
-
inc?: {
|
|
2810
|
-
[key: string]: number
|
|
2811
|
-
}
|
|
2812
|
-
dec?: {
|
|
2813
|
-
[key: string]: number
|
|
2814
|
-
}
|
|
2815
|
-
insert?: InsertPatch
|
|
2816
|
-
ifRevisionID?: string
|
|
2817
|
-
}
|
|
2818
|
-
|
|
2819
|
-
/** @internal */
|
|
2820
|
-
export declare type PatchSelection = string | string[] | MutationSelection
|
|
2821
|
-
|
|
2822
|
-
/** @public */
|
|
2823
|
-
declare interface ProgressEvent_2 {
|
|
2824
|
-
type: 'progress'
|
|
2825
|
-
stage: 'upload' | 'download'
|
|
2826
|
-
percent: number
|
|
2827
|
-
total?: number
|
|
2828
|
-
loaded?: number
|
|
2829
|
-
lengthComputable: boolean
|
|
2830
|
-
}
|
|
2831
|
-
export {ProgressEvent_2 as ProgressEvent}
|
|
2832
|
-
|
|
2833
|
-
/** @internal */
|
|
2834
|
-
export declare class ProjectsClient implements ProjectsClientType {
|
|
2835
|
-
#private
|
|
2836
|
-
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
2837
|
-
/**
|
|
2838
|
-
* Fetch a list of projects the authenticated user has access to.
|
|
2839
|
-
*
|
|
2840
|
-
* @param options - Options for the list request
|
|
2841
|
-
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
2842
|
-
*/
|
|
2843
|
-
list(options?: {includeMembers?: true}): Promise<SanityProject[]>
|
|
2844
|
-
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
2845
|
-
/**
|
|
2846
|
-
* Fetch a project by project ID
|
|
2847
|
-
*
|
|
2848
|
-
* @param projectId - ID of the project to fetch
|
|
2849
|
-
*/
|
|
2850
|
-
getById(projectId: string): Promise<SanityProject>
|
|
2851
|
-
}
|
|
2852
|
-
|
|
2853
|
-
/** @internal */
|
|
2854
|
-
declare interface ProjectsClientType {
|
|
2855
|
-
/**
|
|
2856
|
-
* Fetch a list of projects the authenticated user has access to.
|
|
2857
|
-
*
|
|
2858
|
-
* @param options - Options for the list request
|
|
2859
|
-
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
2860
|
-
*/
|
|
2861
|
-
list(options?: {includeMembers?: true}): Promise<SanityProject[]>
|
|
2862
|
-
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
2863
|
-
list(options?: {includeMembers?: boolean}): Promise<SanityProject[]>
|
|
2864
|
-
/**
|
|
2865
|
-
* Fetch a project by project ID
|
|
2866
|
-
*
|
|
2867
|
-
* @param projectId - ID of the project to fetch
|
|
2868
|
-
*/
|
|
2869
|
-
getById(projectId: string): Promise<SanityProject>
|
|
2870
|
-
}
|
|
2871
|
-
|
|
2872
|
-
/**
|
|
2873
|
-
* Publishes a draft document.
|
|
2874
|
-
* If a published version of the document already exists this is replaced by the current draft document.
|
|
2875
|
-
* In either case the draft document is deleted.
|
|
2876
|
-
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
2877
|
-
* that the draft and/or published versions of the document have not been changed by another client.
|
|
2878
|
-
*
|
|
2879
|
-
* @public
|
|
2880
|
-
*/
|
|
2881
|
-
export declare type PublishAction = {
|
|
2882
|
-
actionType: 'sanity.action.document.publish'
|
|
2883
|
-
/**
|
|
2884
|
-
* Draft document ID to publish
|
|
2885
|
-
*/
|
|
2886
|
-
draftId: string
|
|
2887
|
-
/**
|
|
2888
|
-
* Draft revision ID to match
|
|
2889
|
-
*/
|
|
2890
|
-
ifDraftRevisionId?: string
|
|
2891
|
-
/**
|
|
2892
|
-
* Published document ID to replace
|
|
2893
|
-
*/
|
|
2894
|
-
publishedId: string
|
|
2895
|
-
/**
|
|
2896
|
-
* Published revision ID to match
|
|
2897
|
-
*/
|
|
2898
|
-
ifPublishedRevisionId?: string
|
|
2899
|
-
}
|
|
2900
|
-
|
|
2901
|
-
/** @public */
|
|
2902
|
-
export declare type QueryOptions =
|
|
2903
|
-
| FilteredResponseQueryOptions
|
|
2904
|
-
| UnfilteredResponseQueryOptions
|
|
2905
|
-
| UnfilteredResponseWithoutQuery
|
|
2906
|
-
|
|
2907
|
-
/** @public */
|
|
2908
|
-
export declare interface QueryParams {
|
|
2909
|
-
[key: string]: any
|
|
2910
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2911
|
-
body?: never
|
|
2912
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2913
|
-
cache?: 'next' extends keyof RequestInit ? never : any
|
|
2914
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2915
|
-
filterResponse?: never
|
|
2916
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2917
|
-
headers?: never
|
|
2918
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2919
|
-
method?: never
|
|
2920
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2921
|
-
next?: 'next' extends keyof RequestInit ? never : any
|
|
2922
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2923
|
-
perspective?: never
|
|
2924
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2925
|
-
query?: never
|
|
2926
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2927
|
-
resultSourceMap?: never
|
|
2928
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2929
|
-
returnQuery?: never
|
|
2930
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2931
|
-
signal?: never
|
|
2932
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2933
|
-
stega?: never
|
|
2934
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2935
|
-
tag?: never
|
|
2936
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2937
|
-
timeout?: never
|
|
2938
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2939
|
-
token?: never
|
|
2940
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2941
|
-
useCdn?: never
|
|
2942
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2943
|
-
lastLiveEventId?: never
|
|
2944
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2945
|
-
cacheMode?: never
|
|
2946
|
-
}
|
|
2947
|
-
|
|
2948
|
-
/**
|
|
2949
|
-
* This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
|
|
2950
|
-
* @public
|
|
2951
|
-
*/
|
|
2952
|
-
export declare type QueryWithoutParams = Record<string, never> | undefined
|
|
2953
|
-
|
|
2954
|
-
/** @public */
|
|
2955
|
-
export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
2956
|
-
|
|
2957
|
-
/** @public */
|
|
2958
|
-
export declare interface RawQueryResponse<R> {
|
|
2959
|
-
query: string
|
|
2960
|
-
ms: number
|
|
2961
|
-
result: R
|
|
2962
|
-
resultSourceMap?: ContentSourceMap
|
|
2963
|
-
/** Requires `apiVersion` to be `2021-03-25` or later. */
|
|
2964
|
-
syncTags?: SyncTag[]
|
|
2965
|
-
}
|
|
2966
|
-
|
|
2967
|
-
/** @internal */
|
|
2968
|
-
export declare interface RawRequestOptions {
|
|
2969
|
-
url?: string
|
|
2970
|
-
uri?: string
|
|
2971
|
-
method?: string
|
|
2972
|
-
token?: string
|
|
2973
|
-
json?: boolean
|
|
2974
|
-
tag?: string
|
|
2975
|
-
useGlobalApi?: boolean
|
|
2976
|
-
withCredentials?: boolean
|
|
2977
|
-
query?: {
|
|
2978
|
-
[key: string]: string | string[]
|
|
2979
|
-
}
|
|
2980
|
-
headers?: {
|
|
2981
|
-
[key: string]: string
|
|
2982
|
-
}
|
|
2983
|
-
timeout?: number
|
|
2984
|
-
proxy?: string
|
|
2985
|
-
body?: Any
|
|
2986
|
-
maxRedirects?: number
|
|
2987
|
-
signal?: AbortSignal
|
|
2988
|
-
}
|
|
2989
|
-
|
|
2990
|
-
/**
|
|
2991
|
-
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
2992
|
-
*
|
|
2993
|
-
* @public
|
|
2994
|
-
*/
|
|
2995
|
-
export declare type ReconnectEvent = {
|
|
2996
|
-
type: 'reconnect'
|
|
2997
|
-
}
|
|
2998
|
-
|
|
2999
|
-
/**
|
|
3000
|
-
* @public
|
|
3001
|
-
* @deprecated – The `r`-prefix is not required, use `string` instead
|
|
3002
|
-
*/
|
|
3003
|
-
export declare type ReleaseId = `r${string}`
|
|
3004
|
-
|
|
3005
|
-
/**
|
|
3006
|
-
* Replaces an existing draft document.
|
|
3007
|
-
* At least one of the draft or published versions of the document must exist.
|
|
3008
|
-
*
|
|
3009
|
-
* @public
|
|
3010
|
-
*/
|
|
3011
|
-
export declare type ReplaceDraftAction = {
|
|
3012
|
-
actionType: 'sanity.action.document.replaceDraft'
|
|
3013
|
-
/**
|
|
3014
|
-
* Published document ID to create draft from, if draft does not exist
|
|
3015
|
-
*/
|
|
3016
|
-
publishedId: string
|
|
3017
|
-
/**
|
|
3018
|
-
* Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
|
3019
|
-
*/
|
|
3020
|
-
attributes: IdentifiedSanityDocumentStub
|
|
3021
|
-
}
|
|
3022
|
-
|
|
3023
|
-
/** @public */
|
|
3024
|
-
export declare const requester: Requester
|
|
3025
|
-
|
|
3026
|
-
/** @internal */
|
|
3027
|
-
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
3028
|
-
url?: string
|
|
3029
|
-
uri?: string
|
|
3030
|
-
canUseCdn?: boolean
|
|
3031
|
-
useCdn?: boolean
|
|
3032
|
-
tag?: string
|
|
3033
|
-
returnQuery?: boolean
|
|
3034
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
3035
|
-
perspective?: ClientPerspective
|
|
3036
|
-
lastLiveEventId?: string
|
|
3037
|
-
cacheMode?: 'noStale'
|
|
3038
|
-
}
|
|
3039
|
-
|
|
3040
|
-
/** @public */
|
|
3041
|
-
export declare interface RequestOptions {
|
|
3042
|
-
timeout?: number
|
|
3043
|
-
token?: string
|
|
3044
|
-
tag?: string
|
|
3045
|
-
headers?: Record<string, string>
|
|
3046
|
-
method?: string
|
|
3047
|
-
query?: Any
|
|
3048
|
-
body?: Any
|
|
3049
|
-
signal?: AbortSignal
|
|
3050
|
-
}
|
|
3051
|
-
|
|
3052
|
-
export {ResolveStudioUrl}
|
|
3053
|
-
|
|
3054
|
-
/** @public */
|
|
3055
|
-
export declare interface ResponseEvent<T = unknown> {
|
|
3056
|
-
type: 'response'
|
|
3057
|
-
body: T
|
|
3058
|
-
url: string
|
|
3059
|
-
method: string
|
|
3060
|
-
statusCode: number
|
|
3061
|
-
statusMessage?: string
|
|
3062
|
-
headers: Record<string, string>
|
|
3063
|
-
}
|
|
3064
|
-
|
|
3065
|
-
/** @public */
|
|
3066
|
-
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
3067
|
-
perspective?: ClientPerspective
|
|
3068
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
3069
|
-
returnQuery?: boolean
|
|
3070
|
-
useCdn?: boolean
|
|
3071
|
-
stega?: boolean | StegaConfig
|
|
3072
|
-
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
3073
|
-
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
3074
|
-
lastLiveEventId?: string | string[] | null
|
|
3075
|
-
/**
|
|
3076
|
-
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
3077
|
-
* Tradeoff between latency and freshness of content.
|
|
3078
|
-
*
|
|
3079
|
-
* Only to be used with live content queries and when useCdn is true.
|
|
3080
|
-
*/
|
|
3081
|
-
cacheMode?: 'noStale'
|
|
3082
|
-
}
|
|
3083
|
-
|
|
3084
|
-
/** @internal */
|
|
3085
|
-
export declare interface SanityAssetDocument extends SanityDocument {
|
|
3086
|
-
url: string
|
|
3087
|
-
path: string
|
|
3088
|
-
size: number
|
|
3089
|
-
assetId: string
|
|
3090
|
-
mimeType: string
|
|
3091
|
-
sha1hash: string
|
|
3092
|
-
extension: string
|
|
3093
|
-
uploadId?: string
|
|
3094
|
-
originalFilename?: string
|
|
3095
|
-
}
|
|
3096
|
-
|
|
3097
|
-
/** @public */
|
|
3098
|
-
export declare class SanityClient implements SanityClientType {
|
|
3099
|
-
#private
|
|
3100
|
-
assets: AssetsClient
|
|
3101
|
-
datasets: DatasetsClient
|
|
3102
|
-
live: LiveClient
|
|
3103
|
-
projects: ProjectsClient
|
|
3104
|
-
users: UsersClient
|
|
3105
|
-
/**
|
|
3106
|
-
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
3107
|
-
*/
|
|
3108
|
-
observable: ObservableSanityClient
|
|
3109
|
-
listen: typeof _listen
|
|
3110
|
-
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
3111
|
-
/**
|
|
3112
|
-
* Clone the client - returns a new instance
|
|
3113
|
-
*/
|
|
3114
|
-
clone(): SanityClient
|
|
3115
|
-
/**
|
|
3116
|
-
* Returns the current client configuration
|
|
3117
|
-
*/
|
|
3118
|
-
config(): InitializedClientConfig
|
|
3119
|
-
/**
|
|
3120
|
-
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
3121
|
-
*/
|
|
3122
|
-
config(newConfig?: Partial<ClientConfig>): this
|
|
3123
|
-
/**
|
|
3124
|
-
* Clone the client with a new (partial) configuration.
|
|
3125
|
-
*
|
|
3126
|
-
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
3127
|
-
*/
|
|
3128
|
-
withConfig(newConfig?: Partial<ClientConfig>): SanityClient
|
|
3129
|
-
/**
|
|
3130
|
-
* Perform a GROQ-query against the configured dataset.
|
|
3131
|
-
*
|
|
3132
|
-
* @param query - GROQ-query to perform
|
|
3133
|
-
*/
|
|
3134
|
-
fetch<
|
|
3135
|
-
R = Any,
|
|
3136
|
-
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
3137
|
-
const G extends string = string,
|
|
3138
|
-
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
3139
|
-
/**
|
|
3140
|
-
* Perform a GROQ-query against the configured dataset.
|
|
3141
|
-
*
|
|
3142
|
-
* @param query - GROQ-query to perform
|
|
3143
|
-
* @param params - Optional query parameters
|
|
3144
|
-
* @param options - Optional request options
|
|
3145
|
-
*/
|
|
3146
|
-
fetch<
|
|
3147
|
-
R = Any,
|
|
3148
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
3149
|
-
const G extends string = string,
|
|
3150
|
-
>(
|
|
3151
|
-
query: G,
|
|
3152
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
3153
|
-
options?: FilteredResponseQueryOptions,
|
|
3154
|
-
): Promise<ClientReturn<G, R>>
|
|
3155
|
-
/**
|
|
3156
|
-
* Perform a GROQ-query against the configured dataset.
|
|
3157
|
-
*
|
|
3158
|
-
* @param query - GROQ-query to perform
|
|
3159
|
-
* @param params - Optional query parameters
|
|
3160
|
-
* @param options - Request options
|
|
3161
|
-
*/
|
|
3162
|
-
fetch<
|
|
3163
|
-
R = Any,
|
|
3164
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
3165
|
-
const G extends string = string,
|
|
3166
|
-
>(
|
|
3167
|
-
query: G,
|
|
3168
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
3169
|
-
options: UnfilteredResponseQueryOptions,
|
|
3170
|
-
): Promise<RawQueryResponse<ClientReturn<G, R>>>
|
|
3171
|
-
/**
|
|
3172
|
-
* Perform a GROQ-query against the configured dataset.
|
|
3173
|
-
*
|
|
3174
|
-
* @param query - GROQ-query to perform
|
|
3175
|
-
* @param params - Optional query parameters
|
|
3176
|
-
* @param options - Request options
|
|
3177
|
-
*/
|
|
3178
|
-
fetch<
|
|
3179
|
-
R = Any,
|
|
3180
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
3181
|
-
const G extends string = string,
|
|
3182
|
-
>(
|
|
3183
|
-
query: G,
|
|
3184
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
3185
|
-
options: UnfilteredResponseWithoutQuery,
|
|
3186
|
-
): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
3187
|
-
/**
|
|
3188
|
-
* Fetch a single document with the given ID.
|
|
3189
|
-
*
|
|
3190
|
-
* @param id - Document ID to fetch
|
|
3191
|
-
* @param options - Request options
|
|
3192
|
-
*/
|
|
3193
|
-
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
3194
|
-
id: string,
|
|
3195
|
-
options?: {
|
|
3196
|
-
signal?: AbortSignal
|
|
3197
|
-
tag?: string
|
|
3198
|
-
},
|
|
3199
|
-
): Promise<SanityDocument<R> | undefined>
|
|
3200
|
-
/**
|
|
3201
|
-
* Fetch multiple documents in one request.
|
|
3202
|
-
* Should be used sparingly - performing a query is usually a better option.
|
|
3203
|
-
* The order/position of documents is preserved based on the original array of IDs.
|
|
3204
|
-
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
3205
|
-
*
|
|
3206
|
-
* @param ids - Document IDs to fetch
|
|
3207
|
-
* @param options - Request options
|
|
3208
|
-
*/
|
|
3209
|
-
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
3210
|
-
ids: string[],
|
|
3211
|
-
options?: {
|
|
3212
|
-
signal?: AbortSignal
|
|
3213
|
-
tag?: string
|
|
3214
|
-
},
|
|
3215
|
-
): Promise<(SanityDocument<R> | null)[]>
|
|
3216
|
-
/**
|
|
3217
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3218
|
-
* Returns a promise that resolves to the created document.
|
|
3219
|
-
*
|
|
3220
|
-
* @param document - Document to create
|
|
3221
|
-
* @param options - Mutation options
|
|
3222
|
-
*/
|
|
3223
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3224
|
-
document: SanityDocumentStub<R>,
|
|
3225
|
-
options: FirstDocumentMutationOptions,
|
|
3226
|
-
): Promise<SanityDocument<R>>
|
|
3227
|
-
/**
|
|
3228
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3229
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
3230
|
-
*
|
|
3231
|
-
* @param document - Document to create
|
|
3232
|
-
* @param options - Mutation options
|
|
3233
|
-
*/
|
|
3234
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3235
|
-
document: SanityDocumentStub<R>,
|
|
3236
|
-
options: AllDocumentsMutationOptions,
|
|
3237
|
-
): Promise<SanityDocument<R>[]>
|
|
3238
|
-
/**
|
|
3239
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3240
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3241
|
-
*
|
|
3242
|
-
* @param document - Document to create
|
|
3243
|
-
* @param options - Mutation options
|
|
3244
|
-
*/
|
|
3245
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3246
|
-
document: SanityDocumentStub<R>,
|
|
3247
|
-
options: FirstDocumentIdMutationOptions,
|
|
3248
|
-
): Promise<SingleMutationResult>
|
|
3249
|
-
/**
|
|
3250
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3251
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3252
|
-
*
|
|
3253
|
-
* @param document - Document to create
|
|
3254
|
-
* @param options - Mutation options
|
|
3255
|
-
*/
|
|
3256
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3257
|
-
document: SanityDocumentStub<R>,
|
|
3258
|
-
options: AllDocumentIdsMutationOptions,
|
|
3259
|
-
): Promise<MultipleMutationResult>
|
|
3260
|
-
/**
|
|
3261
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3262
|
-
* Returns a promise that resolves to the created document.
|
|
3263
|
-
*
|
|
3264
|
-
* @param document - Document to create
|
|
3265
|
-
* @param options - Mutation options
|
|
3266
|
-
*/
|
|
3267
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3268
|
-
document: SanityDocumentStub<R>,
|
|
3269
|
-
options?: BaseMutationOptions,
|
|
3270
|
-
): Promise<SanityDocument<R>>
|
|
3271
|
-
/**
|
|
3272
|
-
* Create a document if no document with the same ID already exists.
|
|
3273
|
-
* Returns a promise that resolves to the created document.
|
|
3274
|
-
*
|
|
3275
|
-
* @param document - Document to create
|
|
3276
|
-
* @param options - Mutation options
|
|
3277
|
-
*/
|
|
3278
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3279
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3280
|
-
options: FirstDocumentMutationOptions,
|
|
3281
|
-
): Promise<SanityDocument<R>>
|
|
3282
|
-
/**
|
|
3283
|
-
* Create a document if no document with the same ID already exists.
|
|
3284
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
3285
|
-
*
|
|
3286
|
-
* @param document - Document to create
|
|
3287
|
-
* @param options - Mutation options
|
|
3288
|
-
*/
|
|
3289
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3290
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3291
|
-
options: AllDocumentsMutationOptions,
|
|
3292
|
-
): Promise<SanityDocument<R>[]>
|
|
3293
|
-
/**
|
|
3294
|
-
* Create a document if no document with the same ID already exists.
|
|
3295
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3296
|
-
*
|
|
3297
|
-
* @param document - Document to create
|
|
3298
|
-
* @param options - Mutation options
|
|
3299
|
-
*/
|
|
3300
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3301
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3302
|
-
options: FirstDocumentIdMutationOptions,
|
|
3303
|
-
): Promise<SingleMutationResult>
|
|
3304
|
-
/**
|
|
3305
|
-
* Create a document if no document with the same ID already exists.
|
|
3306
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3307
|
-
*
|
|
3308
|
-
* @param document - Document to create
|
|
3309
|
-
* @param options - Mutation options
|
|
3310
|
-
*/
|
|
3311
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3312
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3313
|
-
options: AllDocumentIdsMutationOptions,
|
|
3314
|
-
): Promise<MultipleMutationResult>
|
|
3315
|
-
/**
|
|
3316
|
-
* Create a document if no document with the same ID already exists.
|
|
3317
|
-
* Returns a promise that resolves to the created document.
|
|
3318
|
-
*
|
|
3319
|
-
* @param document - Document to create
|
|
3320
|
-
* @param options - Mutation options
|
|
3321
|
-
*/
|
|
3322
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3323
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3324
|
-
options?: BaseMutationOptions,
|
|
3325
|
-
): Promise<SanityDocument<R>>
|
|
3326
|
-
/**
|
|
3327
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3328
|
-
* Returns a promise that resolves to the created document.
|
|
3329
|
-
*
|
|
3330
|
-
* @param document - Document to either create or replace
|
|
3331
|
-
* @param options - Mutation options
|
|
3332
|
-
*/
|
|
3333
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3334
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3335
|
-
options: FirstDocumentMutationOptions,
|
|
3336
|
-
): Promise<SanityDocument<R>>
|
|
3337
|
-
/**
|
|
3338
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3339
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
3340
|
-
*
|
|
3341
|
-
* @param document - Document to either create or replace
|
|
3342
|
-
* @param options - Mutation options
|
|
3343
|
-
*/
|
|
3344
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3345
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3346
|
-
options: AllDocumentsMutationOptions,
|
|
3347
|
-
): Promise<SanityDocument<R>[]>
|
|
3348
|
-
/**
|
|
3349
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3350
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3351
|
-
*
|
|
3352
|
-
* @param document - Document to either create or replace
|
|
3353
|
-
* @param options - Mutation options
|
|
3354
|
-
*/
|
|
3355
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3356
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3357
|
-
options: FirstDocumentIdMutationOptions,
|
|
3358
|
-
): Promise<SingleMutationResult>
|
|
3359
|
-
/**
|
|
3360
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3361
|
-
* Returns a promise that resolves to a mutation result object containing the created document ID.
|
|
3362
|
-
*
|
|
3363
|
-
* @param document - Document to either create or replace
|
|
3364
|
-
* @param options - Mutation options
|
|
3365
|
-
*/
|
|
3366
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3367
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3368
|
-
options: AllDocumentIdsMutationOptions,
|
|
3369
|
-
): Promise<MultipleMutationResult>
|
|
3370
|
-
/**
|
|
3371
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3372
|
-
* Returns a promise that resolves to the created document.
|
|
3373
|
-
*
|
|
3374
|
-
* @param document - Document to either create or replace
|
|
3375
|
-
* @param options - Mutation options
|
|
3376
|
-
*/
|
|
3377
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3378
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3379
|
-
options?: BaseMutationOptions,
|
|
3380
|
-
): Promise<SanityDocument<R>>
|
|
3381
|
-
/**
|
|
3382
|
-
* Deletes a document with the given document ID.
|
|
3383
|
-
* Returns a promise that resolves to the deleted document.
|
|
3384
|
-
*
|
|
3385
|
-
* @param id - Document ID to delete
|
|
3386
|
-
* @param options - Options for the mutation
|
|
3387
|
-
*/
|
|
3388
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3389
|
-
id: string,
|
|
3390
|
-
options: FirstDocumentMutationOptions,
|
|
3391
|
-
): Promise<SanityDocument<R>>
|
|
3392
|
-
/**
|
|
3393
|
-
* Deletes a document with the given document ID.
|
|
3394
|
-
* Returns a promise that resolves to an array containing the deleted document.
|
|
3395
|
-
*
|
|
3396
|
-
* @param id - Document ID to delete
|
|
3397
|
-
* @param options - Options for the mutation
|
|
3398
|
-
*/
|
|
3399
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3400
|
-
id: string,
|
|
3401
|
-
options: AllDocumentsMutationOptions,
|
|
3402
|
-
): Promise<SanityDocument<R>[]>
|
|
3403
|
-
/**
|
|
3404
|
-
* Deletes a document with the given document ID.
|
|
3405
|
-
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
3406
|
-
*
|
|
3407
|
-
* @param id - Document ID to delete
|
|
3408
|
-
* @param options - Options for the mutation
|
|
3409
|
-
*/
|
|
3410
|
-
delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
3411
|
-
/**
|
|
3412
|
-
* Deletes a document with the given document ID.
|
|
3413
|
-
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
3414
|
-
*
|
|
3415
|
-
* @param id - Document ID to delete
|
|
3416
|
-
* @param options - Options for the mutation
|
|
3417
|
-
*/
|
|
3418
|
-
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
3419
|
-
/**
|
|
3420
|
-
* Deletes a document with the given document ID.
|
|
3421
|
-
* Returns a promise that resolves to the deleted document.
|
|
3422
|
-
*
|
|
3423
|
-
* @param id - Document ID to delete
|
|
3424
|
-
* @param options - Options for the mutation
|
|
3425
|
-
*/
|
|
3426
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3427
|
-
id: string,
|
|
3428
|
-
options?: BaseMutationOptions,
|
|
3429
|
-
): Promise<SanityDocument<R>>
|
|
3430
|
-
/**
|
|
3431
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
3432
|
-
* Returns a promise that resolves to first deleted document.
|
|
3433
|
-
*
|
|
3434
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3435
|
-
* @param options - Options for the mutation
|
|
3436
|
-
*/
|
|
3437
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3438
|
-
selection: MutationSelection,
|
|
3439
|
-
options: FirstDocumentMutationOptions,
|
|
3440
|
-
): Promise<SanityDocument<R>>
|
|
3441
|
-
/**
|
|
3442
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
3443
|
-
* Returns a promise that resolves to an array containing the deleted documents.
|
|
3444
|
-
*
|
|
3445
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3446
|
-
* @param options - Options for the mutation
|
|
3447
|
-
*/
|
|
3448
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3449
|
-
selection: MutationSelection,
|
|
3450
|
-
options: AllDocumentsMutationOptions,
|
|
3451
|
-
): Promise<SanityDocument<R>[]>
|
|
3452
|
-
/**
|
|
3453
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
3454
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
|
|
3455
|
-
*
|
|
3456
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3457
|
-
* @param options - Options for the mutation
|
|
3458
|
-
*/
|
|
3459
|
-
delete(
|
|
3460
|
-
selection: MutationSelection,
|
|
3461
|
-
options: FirstDocumentIdMutationOptions,
|
|
3462
|
-
): Promise<SingleMutationResult>
|
|
3463
|
-
/**
|
|
3464
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
3465
|
-
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
3466
|
-
*
|
|
3467
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3468
|
-
* @param options - Options for the mutation
|
|
3469
|
-
*/
|
|
3470
|
-
delete(
|
|
3471
|
-
selection: MutationSelection,
|
|
3472
|
-
options: AllDocumentIdsMutationOptions,
|
|
3473
|
-
): Promise<MultipleMutationResult>
|
|
3474
|
-
/**
|
|
3475
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
3476
|
-
* Returns a promise that resolves to first deleted document.
|
|
3477
|
-
*
|
|
3478
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3479
|
-
* @param options - Options for the mutation
|
|
3480
|
-
*/
|
|
3481
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3482
|
-
selection: MutationSelection,
|
|
3483
|
-
options?: BaseMutationOptions,
|
|
3484
|
-
): Promise<SanityDocument<R>>
|
|
3485
|
-
/**
|
|
3486
|
-
* Perform mutation operations against the configured dataset
|
|
3487
|
-
* Returns a promise that resolves to the first mutated document.
|
|
3488
|
-
*
|
|
3489
|
-
* @param operations - Mutation operations to execute
|
|
3490
|
-
* @param options - Mutation options
|
|
3491
|
-
*/
|
|
3492
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3493
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
3494
|
-
options: FirstDocumentMutationOptions,
|
|
3495
|
-
): Promise<SanityDocument<R>>
|
|
3496
|
-
/**
|
|
3497
|
-
* Perform mutation operations against the configured dataset.
|
|
3498
|
-
* Returns a promise that resolves to an array of the mutated documents.
|
|
3499
|
-
*
|
|
3500
|
-
* @param operations - Mutation operations to execute
|
|
3501
|
-
* @param options - Mutation options
|
|
3502
|
-
*/
|
|
3503
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3504
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
2727
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
3505
2728
|
options: AllDocumentsMutationOptions,
|
|
3506
2729
|
): Promise<SanityDocument<R>[]>
|
|
3507
2730
|
/**
|
|
3508
|
-
*
|
|
3509
|
-
* Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
2731
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
3510
2732
|
*
|
|
3511
|
-
* @param
|
|
3512
|
-
* @param options - Mutation options
|
|
2733
|
+
* @param options - Options for the mutation operation
|
|
3513
2734
|
*/
|
|
3514
|
-
|
|
3515
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
3516
|
-
options: FirstDocumentIdMutationOptions,
|
|
3517
|
-
): Promise<SingleMutationResult>
|
|
2735
|
+
commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
3518
2736
|
/**
|
|
3519
|
-
*
|
|
3520
|
-
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
2737
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
3521
2738
|
*
|
|
3522
|
-
* @param
|
|
3523
|
-
* @param options - Mutation options
|
|
2739
|
+
* @param options - Options for the mutation operation
|
|
3524
2740
|
*/
|
|
3525
|
-
|
|
3526
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
3527
|
-
options: AllDocumentIdsMutationOptions,
|
|
3528
|
-
): Promise<MultipleMutationResult>
|
|
2741
|
+
commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
3529
2742
|
/**
|
|
3530
|
-
*
|
|
3531
|
-
* Returns a promise that resolves to the first mutated document.
|
|
2743
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
3532
2744
|
*
|
|
3533
|
-
* @param
|
|
3534
|
-
* @param options - Mutation options
|
|
2745
|
+
* @param options - Options for the mutation operation
|
|
3535
2746
|
*/
|
|
3536
|
-
|
|
3537
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
2747
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
3538
2748
|
options?: BaseMutationOptions,
|
|
3539
2749
|
): Promise<SanityDocument<R>>
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
/** @public */
|
|
2753
|
+
export declare type PatchBuilder = (patch: Patch) => Patch
|
|
2754
|
+
|
|
2755
|
+
/** @internal */
|
|
2756
|
+
export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
2757
|
+
|
|
2758
|
+
/** @internal */
|
|
2759
|
+
export declare interface PatchOperations {
|
|
2760
|
+
set?: {
|
|
2761
|
+
[key: string]: Any
|
|
2762
|
+
}
|
|
2763
|
+
setIfMissing?: {
|
|
2764
|
+
[key: string]: Any
|
|
2765
|
+
}
|
|
2766
|
+
diffMatchPatch?: {
|
|
2767
|
+
[key: string]: Any
|
|
2768
|
+
}
|
|
2769
|
+
unset?: string[]
|
|
2770
|
+
inc?: {
|
|
2771
|
+
[key: string]: number
|
|
2772
|
+
}
|
|
2773
|
+
dec?: {
|
|
2774
|
+
[key: string]: number
|
|
2775
|
+
}
|
|
2776
|
+
insert?: InsertPatch
|
|
2777
|
+
ifRevisionID?: string
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
/** @internal */
|
|
2781
|
+
export declare type PatchSelection = string | string[] | MutationSelection
|
|
2782
|
+
|
|
2783
|
+
/** @public */
|
|
2784
|
+
declare interface ProgressEvent_2 {
|
|
2785
|
+
type: 'progress'
|
|
2786
|
+
stage: 'upload' | 'download'
|
|
2787
|
+
percent: number
|
|
2788
|
+
total?: number
|
|
2789
|
+
loaded?: number
|
|
2790
|
+
lengthComputable: boolean
|
|
2791
|
+
}
|
|
2792
|
+
export {ProgressEvent_2 as ProgressEvent}
|
|
2793
|
+
|
|
2794
|
+
/** @internal */
|
|
2795
|
+
export declare class ProjectsClient {
|
|
2796
|
+
#private
|
|
2797
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
3540
2798
|
/**
|
|
3541
|
-
*
|
|
3542
|
-
*
|
|
3543
|
-
* @param documentId - Document ID to patch
|
|
3544
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3545
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3546
|
-
*/
|
|
3547
|
-
patch(documentId: string, operations?: PatchOperations): Patch
|
|
3548
|
-
/**
|
|
3549
|
-
* Create a new buildable patch of operations to perform
|
|
3550
|
-
*
|
|
3551
|
-
* @param documentIds - Array of document IDs to patch
|
|
3552
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3553
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3554
|
-
*/
|
|
3555
|
-
patch(documentIds: string[], operations?: PatchOperations): Patch
|
|
3556
|
-
/**
|
|
3557
|
-
* Create a new buildable patch of operations to perform
|
|
3558
|
-
*
|
|
3559
|
-
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
3560
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3561
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3562
|
-
*/
|
|
3563
|
-
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
3564
|
-
/**
|
|
3565
|
-
* Create a new transaction of mutations
|
|
2799
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
3566
2800
|
*
|
|
3567
|
-
* @param
|
|
2801
|
+
* @param options - Options for the list request
|
|
2802
|
+
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
3568
2803
|
*/
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
): Transaction
|
|
2804
|
+
list(options?: {includeMembers?: true}): Promise<SanityProject[]>
|
|
2805
|
+
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
3572
2806
|
/**
|
|
3573
|
-
*
|
|
3574
|
-
* Returns a promise that resolves to the transaction result
|
|
2807
|
+
* Fetch a project by project ID
|
|
3575
2808
|
*
|
|
3576
|
-
* @param
|
|
3577
|
-
* @param options - Action options
|
|
2809
|
+
* @param projectId - ID of the project to fetch
|
|
3578
2810
|
*/
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
2811
|
+
getById(projectId: string): Promise<SanityProject>
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
/**
|
|
2815
|
+
* Publishes a draft document.
|
|
2816
|
+
* If a published version of the document already exists this is replaced by the current draft document.
|
|
2817
|
+
* In either case the draft document is deleted.
|
|
2818
|
+
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
2819
|
+
* that the draft and/or published versions of the document have not been changed by another client.
|
|
2820
|
+
*
|
|
2821
|
+
* @public
|
|
2822
|
+
*/
|
|
2823
|
+
export declare type PublishAction = {
|
|
2824
|
+
actionType: 'sanity.action.document.publish'
|
|
3583
2825
|
/**
|
|
3584
|
-
*
|
|
3585
|
-
* NOTE: Only use this for Sanity API endpoints, not for your own APIs!
|
|
3586
|
-
*
|
|
3587
|
-
* @param options - Request options
|
|
3588
|
-
* @returns Promise resolving to the response body
|
|
2826
|
+
* Draft document ID to publish
|
|
3589
2827
|
*/
|
|
3590
|
-
|
|
2828
|
+
draftId: string
|
|
3591
2829
|
/**
|
|
3592
|
-
*
|
|
3593
|
-
* NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
|
|
3594
|
-
*
|
|
3595
|
-
* @deprecated - Use `request()` or your own HTTP library instead
|
|
3596
|
-
* @param endpoint - Endpoint to hit (mutate, query etc)
|
|
3597
|
-
* @param body - Request body
|
|
3598
|
-
* @param options - Request options
|
|
3599
|
-
* @internal
|
|
2830
|
+
* Draft revision ID to match
|
|
3600
2831
|
*/
|
|
3601
|
-
|
|
2832
|
+
ifDraftRevisionId?: string
|
|
3602
2833
|
/**
|
|
3603
|
-
*
|
|
3604
|
-
*
|
|
3605
|
-
* @param uri - URI/path to build URL for
|
|
3606
|
-
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2834
|
+
* Published document ID to replace
|
|
3607
2835
|
*/
|
|
3608
|
-
|
|
2836
|
+
publishedId: string
|
|
3609
2837
|
/**
|
|
3610
|
-
*
|
|
3611
|
-
*
|
|
3612
|
-
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
3613
|
-
* @param path - Path to append after the operation
|
|
2838
|
+
* Published revision ID to match
|
|
3614
2839
|
*/
|
|
3615
|
-
|
|
2840
|
+
ifPublishedRevisionId?: string
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
/** @public */
|
|
2844
|
+
export declare type QueryOptions =
|
|
2845
|
+
| FilteredResponseQueryOptions
|
|
2846
|
+
| UnfilteredResponseQueryOptions
|
|
2847
|
+
| UnfilteredResponseWithoutQuery
|
|
2848
|
+
|
|
2849
|
+
/** @public */
|
|
2850
|
+
export declare interface QueryParams {
|
|
2851
|
+
[key: string]: any
|
|
2852
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2853
|
+
body?: never
|
|
2854
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2855
|
+
cache?: 'next' extends keyof RequestInit ? never : any
|
|
2856
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2857
|
+
filterResponse?: never
|
|
2858
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2859
|
+
headers?: never
|
|
2860
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2861
|
+
method?: never
|
|
2862
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2863
|
+
next?: 'next' extends keyof RequestInit ? never : any
|
|
2864
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2865
|
+
perspective?: never
|
|
2866
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2867
|
+
query?: never
|
|
2868
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2869
|
+
resultSourceMap?: never
|
|
2870
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2871
|
+
returnQuery?: never
|
|
2872
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2873
|
+
signal?: never
|
|
2874
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2875
|
+
stega?: never
|
|
2876
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2877
|
+
tag?: never
|
|
2878
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2879
|
+
timeout?: never
|
|
2880
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2881
|
+
token?: never
|
|
2882
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2883
|
+
useCdn?: never
|
|
2884
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2885
|
+
lastLiveEventId?: never
|
|
2886
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2887
|
+
cacheMode?: never
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
/**
|
|
2891
|
+
* This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
|
|
2892
|
+
* @public
|
|
2893
|
+
*/
|
|
2894
|
+
export declare type QueryWithoutParams = Record<string, never> | undefined
|
|
2895
|
+
|
|
2896
|
+
/** @public */
|
|
2897
|
+
export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
2898
|
+
|
|
2899
|
+
/** @public */
|
|
2900
|
+
export declare interface RawQueryResponse<R> {
|
|
2901
|
+
query: string
|
|
2902
|
+
ms: number
|
|
2903
|
+
result: R
|
|
2904
|
+
resultSourceMap?: ContentSourceMap
|
|
2905
|
+
/** Requires `apiVersion` to be `2021-03-25` or later. */
|
|
2906
|
+
syncTags?: SyncTag[]
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
/** @internal */
|
|
2910
|
+
export declare interface RawRequestOptions {
|
|
2911
|
+
url?: string
|
|
2912
|
+
uri?: string
|
|
2913
|
+
method?: string
|
|
2914
|
+
token?: string
|
|
2915
|
+
json?: boolean
|
|
2916
|
+
tag?: string
|
|
2917
|
+
useGlobalApi?: boolean
|
|
2918
|
+
withCredentials?: boolean
|
|
2919
|
+
query?: {
|
|
2920
|
+
[key: string]: string | string[]
|
|
2921
|
+
}
|
|
2922
|
+
headers?: {
|
|
2923
|
+
[key: string]: string
|
|
2924
|
+
}
|
|
2925
|
+
timeout?: number
|
|
2926
|
+
proxy?: string
|
|
2927
|
+
body?: Any
|
|
2928
|
+
maxRedirects?: number
|
|
2929
|
+
signal?: AbortSignal
|
|
3616
2930
|
}
|
|
3617
2931
|
|
|
3618
2932
|
/**
|
|
3619
|
-
*
|
|
3620
|
-
*
|
|
2933
|
+
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
2934
|
+
*
|
|
2935
|
+
* @public
|
|
3621
2936
|
*/
|
|
3622
|
-
declare
|
|
3623
|
-
|
|
3624
|
-
|
|
2937
|
+
export declare type ReconnectEvent = {
|
|
2938
|
+
type: 'reconnect'
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2941
|
+
/**
|
|
2942
|
+
* @public
|
|
2943
|
+
* @deprecated – The `r`-prefix is not required, use `string` instead
|
|
2944
|
+
*/
|
|
2945
|
+
export declare type ReleaseId = `r${string}`
|
|
2946
|
+
|
|
2947
|
+
/**
|
|
2948
|
+
* Replaces an existing draft document.
|
|
2949
|
+
* At least one of the draft or published versions of the document must exist.
|
|
2950
|
+
*
|
|
2951
|
+
* @public
|
|
2952
|
+
*/
|
|
2953
|
+
export declare type ReplaceDraftAction = {
|
|
2954
|
+
actionType: 'sanity.action.document.replaceDraft'
|
|
3625
2955
|
/**
|
|
3626
|
-
*
|
|
3627
|
-
*
|
|
3628
|
-
* @param uri - URI/path to build URL for
|
|
3629
|
-
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2956
|
+
* Published document ID to create draft from, if draft does not exist
|
|
3630
2957
|
*/
|
|
3631
|
-
|
|
2958
|
+
publishedId: string
|
|
3632
2959
|
/**
|
|
3633
|
-
*
|
|
2960
|
+
* Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
|
2961
|
+
*/
|
|
2962
|
+
attributes: IdentifiedSanityDocumentStub
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2965
|
+
/** @public */
|
|
2966
|
+
export declare const requester: Requester
|
|
2967
|
+
|
|
2968
|
+
/** @internal */
|
|
2969
|
+
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
2970
|
+
url?: string
|
|
2971
|
+
uri?: string
|
|
2972
|
+
canUseCdn?: boolean
|
|
2973
|
+
useCdn?: boolean
|
|
2974
|
+
tag?: string
|
|
2975
|
+
returnQuery?: boolean
|
|
2976
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2977
|
+
perspective?: ClientPerspective
|
|
2978
|
+
lastLiveEventId?: string
|
|
2979
|
+
cacheMode?: 'noStale'
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
/** @public */
|
|
2983
|
+
export declare interface RequestOptions {
|
|
2984
|
+
timeout?: number
|
|
2985
|
+
token?: string
|
|
2986
|
+
tag?: string
|
|
2987
|
+
headers?: Record<string, string>
|
|
2988
|
+
method?: string
|
|
2989
|
+
query?: Any
|
|
2990
|
+
body?: Any
|
|
2991
|
+
signal?: AbortSignal
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
export {ResolveStudioUrl}
|
|
2995
|
+
|
|
2996
|
+
/** @public */
|
|
2997
|
+
export declare interface ResponseEvent<T = unknown> {
|
|
2998
|
+
type: 'response'
|
|
2999
|
+
body: T
|
|
3000
|
+
url: string
|
|
3001
|
+
method: string
|
|
3002
|
+
statusCode: number
|
|
3003
|
+
statusMessage?: string
|
|
3004
|
+
headers: Record<string, string>
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
/** @public */
|
|
3008
|
+
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
3009
|
+
perspective?: ClientPerspective
|
|
3010
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
3011
|
+
returnQuery?: boolean
|
|
3012
|
+
useCdn?: boolean
|
|
3013
|
+
stega?: boolean | StegaConfig
|
|
3014
|
+
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
3015
|
+
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
3016
|
+
lastLiveEventId?: string | string[] | null
|
|
3017
|
+
/**
|
|
3018
|
+
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
3019
|
+
* Tradeoff between latency and freshness of content.
|
|
3634
3020
|
*
|
|
3635
|
-
*
|
|
3636
|
-
* @param path - Path to append after the operation
|
|
3021
|
+
* Only to be used with live content queries and when useCdn is true.
|
|
3637
3022
|
*/
|
|
3638
|
-
|
|
3023
|
+
cacheMode?: 'noStale'
|
|
3639
3024
|
}
|
|
3640
3025
|
|
|
3641
|
-
/**
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3026
|
+
/** @internal */
|
|
3027
|
+
export declare interface SanityAssetDocument extends SanityDocument {
|
|
3028
|
+
url: string
|
|
3029
|
+
path: string
|
|
3030
|
+
size: number
|
|
3031
|
+
assetId: string
|
|
3032
|
+
mimeType: string
|
|
3033
|
+
sha1hash: string
|
|
3034
|
+
extension: string
|
|
3035
|
+
uploadId?: string
|
|
3036
|
+
originalFilename?: string
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
/** @public */
|
|
3040
|
+
export declare class SanityClient {
|
|
3041
|
+
#private
|
|
3042
|
+
assets: AssetsClient
|
|
3043
|
+
datasets: DatasetsClient
|
|
3044
|
+
live: LiveClient
|
|
3045
|
+
projects: ProjectsClient
|
|
3046
|
+
users: UsersClient
|
|
3047
|
+
agent: {
|
|
3048
|
+
action: AgentActionsClient
|
|
3049
|
+
}
|
|
3653
3050
|
/**
|
|
3654
3051
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
3655
3052
|
*/
|
|
3656
|
-
observable:
|
|
3053
|
+
observable: ObservableSanityClient
|
|
3054
|
+
/**
|
|
3055
|
+
* Instance properties
|
|
3056
|
+
*/
|
|
3057
|
+
listen: typeof _listen
|
|
3058
|
+
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
3657
3059
|
/**
|
|
3658
3060
|
* Clone the client - returns a new instance
|
|
3659
3061
|
*/
|
|
3660
|
-
clone():
|
|
3062
|
+
clone(): SanityClient
|
|
3661
3063
|
/**
|
|
3662
3064
|
* Returns the current client configuration
|
|
3663
3065
|
*/
|
|
@@ -3665,13 +3067,13 @@ export declare interface SanityClientType extends SanityClientBase {
|
|
|
3665
3067
|
/**
|
|
3666
3068
|
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
3667
3069
|
*/
|
|
3668
|
-
config(newConfig?: Partial<ClientConfig>):
|
|
3070
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
3669
3071
|
/**
|
|
3670
3072
|
* Clone the client with a new (partial) configuration.
|
|
3671
3073
|
*
|
|
3672
3074
|
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
3673
3075
|
*/
|
|
3674
|
-
withConfig(newConfig?: Partial<ClientConfig>):
|
|
3076
|
+
withConfig(newConfig?: Partial<ClientConfig>): SanityClient
|
|
3675
3077
|
/**
|
|
3676
3078
|
* Perform a GROQ-query against the configured dataset.
|
|
3677
3079
|
*
|
|
@@ -3681,10 +3083,7 @@ export declare interface SanityClientType extends SanityClientBase {
|
|
|
3681
3083
|
R = Any,
|
|
3682
3084
|
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
3683
3085
|
const G extends string = string,
|
|
3684
|
-
>(
|
|
3685
|
-
query: G,
|
|
3686
|
-
params?: Q | QueryWithoutParams,
|
|
3687
|
-
): Promise<ClientReturn<G, R>>
|
|
3086
|
+
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
3688
3087
|
/**
|
|
3689
3088
|
* Perform a GROQ-query against the configured dataset.
|
|
3690
3089
|
*
|
|
@@ -4110,14 +3509,6 @@ export declare interface SanityClientType extends SanityClientBase {
|
|
|
4110
3509
|
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
4111
3510
|
*/
|
|
4112
3511
|
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
4113
|
-
/**
|
|
4114
|
-
* Create a new buildable patch of operations to perform
|
|
4115
|
-
*
|
|
4116
|
-
* @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch
|
|
4117
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
4118
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
4119
|
-
*/
|
|
4120
|
-
patch(selection: PatchSelection, operations?: PatchOperations): Patch
|
|
4121
3512
|
/**
|
|
4122
3513
|
* Create a new transaction of mutations
|
|
4123
3514
|
*
|
|
@@ -4156,6 +3547,20 @@ export declare interface SanityClientType extends SanityClientBase {
|
|
|
4156
3547
|
* @internal
|
|
4157
3548
|
*/
|
|
4158
3549
|
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
|
|
3550
|
+
/**
|
|
3551
|
+
* Get a Sanity API URL for the URI provided
|
|
3552
|
+
*
|
|
3553
|
+
* @param uri - URI/path to build URL for
|
|
3554
|
+
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
3555
|
+
*/
|
|
3556
|
+
getUrl(uri: string, canUseCdn?: boolean): string
|
|
3557
|
+
/**
|
|
3558
|
+
* Get a Sanity API URL for the data operation and path provided
|
|
3559
|
+
*
|
|
3560
|
+
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
3561
|
+
* @param path - Path to append after the operation
|
|
3562
|
+
*/
|
|
3563
|
+
getDataUrl(operation: string, path?: string): string
|
|
4159
3564
|
}
|
|
4160
3565
|
|
|
4161
3566
|
/** @internal */
|
|
@@ -4456,6 +3861,309 @@ export declare type TransactionMutationOptions =
|
|
|
4456
3861
|
| TransactionAllDocumentsMutationOptions
|
|
4457
3862
|
| TransactionAllDocumentIdsMutationOptions
|
|
4458
3863
|
|
|
3864
|
+
/** @beta */
|
|
3865
|
+
export declare type TransformDocument<T extends Record<string, Any> = Record<string, Any>> =
|
|
3866
|
+
| TransformDocumentSync<T>
|
|
3867
|
+
| TransformDocumentAsync
|
|
3868
|
+
|
|
3869
|
+
/** @beta */
|
|
3870
|
+
declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
3871
|
+
|
|
3872
|
+
/** @beta */
|
|
3873
|
+
declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
3874
|
+
TransformRequestBase & AgentActionSync
|
|
3875
|
+
|
|
3876
|
+
/** @beta */
|
|
3877
|
+
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
3878
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
3879
|
+
schemaId: string
|
|
3880
|
+
/**
|
|
3881
|
+
* The source document the transformation will use as input.
|
|
3882
|
+
*/
|
|
3883
|
+
documentId: string
|
|
3884
|
+
/**
|
|
3885
|
+
* The source document's content is first copied to the target,
|
|
3886
|
+
* then it is transformed according to the instruction.
|
|
3887
|
+
*
|
|
3888
|
+
* When omitted, the source document (documentId) is also the target document.
|
|
3889
|
+
*/
|
|
3890
|
+
targetDocument?: TransformTargetDocument
|
|
3891
|
+
/**
|
|
3892
|
+
* Instruct the LLM how to transform the input to th output.
|
|
3893
|
+
*
|
|
3894
|
+
* String template using $variable from instructionParams.
|
|
3895
|
+
*
|
|
3896
|
+
* Capped to 2000 characters, after variables has been injected.
|
|
3897
|
+
* */
|
|
3898
|
+
instruction: string
|
|
3899
|
+
/**
|
|
3900
|
+
*
|
|
3901
|
+
* param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable"
|
|
3902
|
+
*
|
|
3903
|
+
* ### Examples
|
|
3904
|
+
*
|
|
3905
|
+
* #### Constant
|
|
3906
|
+
*
|
|
3907
|
+
* ##### Shorthand
|
|
3908
|
+
* ```ts
|
|
3909
|
+
* client.agent.action.generate({
|
|
3910
|
+
* schemaId,
|
|
3911
|
+
* documentId,
|
|
3912
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nGenerate the full article.',
|
|
3913
|
+
* instructionParams: {
|
|
3914
|
+
* topic: 'Grapefruit'
|
|
3915
|
+
* },
|
|
3916
|
+
* })
|
|
3917
|
+
* ```
|
|
3918
|
+
* ##### Object-form
|
|
3919
|
+
*
|
|
3920
|
+
* ```ts
|
|
3921
|
+
* client.agent.action.transform({
|
|
3922
|
+
* schemaId,
|
|
3923
|
+
* documentId,
|
|
3924
|
+
* instruction: 'Give the following topic:\n $topic \n ---\nGenerate the full article.',
|
|
3925
|
+
* instructionParams: {
|
|
3926
|
+
* topic: {
|
|
3927
|
+
* type: 'constant',
|
|
3928
|
+
* value: 'Grapefruit'
|
|
3929
|
+
* },
|
|
3930
|
+
* },
|
|
3931
|
+
* })
|
|
3932
|
+
* ```
|
|
3933
|
+
* #### Field
|
|
3934
|
+
* ```ts
|
|
3935
|
+
* client.agent.action.transform({
|
|
3936
|
+
* schemaId,
|
|
3937
|
+
* documentId,
|
|
3938
|
+
* instruction: 'Give the following field value:\n $pte \n ---\nGenerate keywords.',
|
|
3939
|
+
* instructionParams: {
|
|
3940
|
+
* pte: {
|
|
3941
|
+
* type: 'field',
|
|
3942
|
+
* path: ['pteField'],
|
|
3943
|
+
* },
|
|
3944
|
+
* },
|
|
3945
|
+
* target: {path: 'keywords' }
|
|
3946
|
+
* })
|
|
3947
|
+
* ```
|
|
3948
|
+
* #### Document
|
|
3949
|
+
* ```ts
|
|
3950
|
+
* client.agent.action.transform({
|
|
3951
|
+
* schemaId,
|
|
3952
|
+
* documentId,
|
|
3953
|
+
* instruction: 'Give the following document value:\n $document \n ---\nGenerate keywords.',
|
|
3954
|
+
* instructionParams: {
|
|
3955
|
+
* document: {
|
|
3956
|
+
* type: 'document',
|
|
3957
|
+
* },
|
|
3958
|
+
* },
|
|
3959
|
+
* target: {path: 'keywords' }
|
|
3960
|
+
* })
|
|
3961
|
+
* ```
|
|
3962
|
+
*
|
|
3963
|
+
* #### GROQ
|
|
3964
|
+
* ```ts
|
|
3965
|
+
* client.agent.action.transform({
|
|
3966
|
+
* schemaId,
|
|
3967
|
+
* documentId,
|
|
3968
|
+
* instruction: 'Give the following list of titles:\n $list \n ---\nGenerate a similar title.',
|
|
3969
|
+
* instructionParams: {
|
|
3970
|
+
* list: {
|
|
3971
|
+
* type: 'groq',
|
|
3972
|
+
* query: '* [_type==$type].title',
|
|
3973
|
+
* params: {type: 'article'}
|
|
3974
|
+
* },
|
|
3975
|
+
* },
|
|
3976
|
+
* target: {path: 'title'}
|
|
3977
|
+
* })
|
|
3978
|
+
* ```
|
|
3979
|
+
* */
|
|
3980
|
+
instructionParams?: AgentActionParams
|
|
3981
|
+
/**
|
|
3982
|
+
* Target defines which parts of the document will be affected by the instruction.
|
|
3983
|
+
* It can be an array, so multiple parts of the document can be separately configured in detail.
|
|
3984
|
+
*
|
|
3985
|
+
* Omitting target implies that the document itself is the root.
|
|
3986
|
+
*
|
|
3987
|
+
* Notes:
|
|
3988
|
+
* - instruction can only affect fields up to `maxPathDepth`
|
|
3989
|
+
* - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
|
|
3990
|
+
* It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
|
|
3991
|
+
*
|
|
3992
|
+
* Default max depth for transform: 12
|
|
3993
|
+
* @see AgentActionRequestBase#conditionalPaths
|
|
3994
|
+
*/
|
|
3995
|
+
target?: TransformTarget | TransformTarget[]
|
|
3996
|
+
}
|
|
3997
|
+
|
|
3998
|
+
/** @beta */
|
|
3999
|
+
export declare interface TransformTarget extends AgentActionTarget {
|
|
4000
|
+
/**
|
|
4001
|
+
* Specifies a tailored instruction of this target.
|
|
4002
|
+
*
|
|
4003
|
+
* string template using $variable from instructionParams.
|
|
4004
|
+
* */
|
|
4005
|
+
instruction?: string
|
|
4006
|
+
/**
|
|
4007
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
4008
|
+
*
|
|
4009
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
4010
|
+
*
|
|
4011
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
4012
|
+
*/
|
|
4013
|
+
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
/** @beta */
|
|
4017
|
+
export declare type TransformTargetDocument =
|
|
4018
|
+
| {
|
|
4019
|
+
operation: 'edit'
|
|
4020
|
+
_id: string
|
|
4021
|
+
}
|
|
4022
|
+
| {
|
|
4023
|
+
operation: 'create'
|
|
4024
|
+
_id?: string
|
|
4025
|
+
}
|
|
4026
|
+
| {
|
|
4027
|
+
operation: 'createIfNotExists'
|
|
4028
|
+
_id: string
|
|
4029
|
+
}
|
|
4030
|
+
| {
|
|
4031
|
+
operation: 'createOrReplace'
|
|
4032
|
+
_id: string
|
|
4033
|
+
}
|
|
4034
|
+
|
|
4035
|
+
/** @beta */
|
|
4036
|
+
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
4037
|
+
/**
|
|
4038
|
+
* Specifies a tailored instruction of this target.
|
|
4039
|
+
*
|
|
4040
|
+
* string template using $variable from instructionParams */
|
|
4041
|
+
instruction?: string
|
|
4042
|
+
/**
|
|
4043
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
4044
|
+
*
|
|
4045
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
4046
|
+
*
|
|
4047
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
4048
|
+
*/
|
|
4049
|
+
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
4050
|
+
}
|
|
4051
|
+
|
|
4052
|
+
/** @beta */
|
|
4053
|
+
export declare type TranslateDocument<T extends Record<string, Any> = Record<string, Any>> =
|
|
4054
|
+
| TranslateDocumentSync<T>
|
|
4055
|
+
| TranslateDocumentAsync
|
|
4056
|
+
|
|
4057
|
+
/** @beta */
|
|
4058
|
+
declare type TranslateDocumentAsync = TranslateRequestBase & AgentActionAsync
|
|
4059
|
+
|
|
4060
|
+
/** @beta */
|
|
4061
|
+
declare type TranslateDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
4062
|
+
TranslateRequestBase & AgentActionSync
|
|
4063
|
+
|
|
4064
|
+
/** @beta */
|
|
4065
|
+
declare interface TranslateLanguage {
|
|
4066
|
+
/**
|
|
4067
|
+
* Language code
|
|
4068
|
+
*/
|
|
4069
|
+
id: string
|
|
4070
|
+
/**
|
|
4071
|
+
* While optional, it is recommended to provide a language title
|
|
4072
|
+
*/
|
|
4073
|
+
title?: string
|
|
4074
|
+
}
|
|
4075
|
+
|
|
4076
|
+
/** @beta */
|
|
4077
|
+
declare interface TranslateRequestBase extends AgentActionRequestBase {
|
|
4078
|
+
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
4079
|
+
schemaId: string
|
|
4080
|
+
/**
|
|
4081
|
+
* The source document the transformation will use as input.
|
|
4082
|
+
*/
|
|
4083
|
+
documentId: string
|
|
4084
|
+
/**
|
|
4085
|
+
* The target document will first get content copied over from the source,
|
|
4086
|
+
* then it is translated according to the instruction.
|
|
4087
|
+
*
|
|
4088
|
+
* When omitted, the source document (documentId) is also the target document.
|
|
4089
|
+
*/
|
|
4090
|
+
targetDocument?: TransformTargetDocument
|
|
4091
|
+
/**
|
|
4092
|
+
* While optional, it is recommended
|
|
4093
|
+
*/
|
|
4094
|
+
fromLanguage?: TranslateLanguage
|
|
4095
|
+
toLanguage: TranslateLanguage
|
|
4096
|
+
/**
|
|
4097
|
+
* `styleGuide` can be used to tailor how the translation should be preformed.
|
|
4098
|
+
*
|
|
4099
|
+
* String template using $variable from styleGuideParams.
|
|
4100
|
+
*
|
|
4101
|
+
* Capped to 2000 characters, after variables has been injected.
|
|
4102
|
+
*
|
|
4103
|
+
* @see #protectedPhrases
|
|
4104
|
+
*/
|
|
4105
|
+
styleGuide?: string
|
|
4106
|
+
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
4107
|
+
styleGuideParams?: AgentActionParams
|
|
4108
|
+
/**
|
|
4109
|
+
* When the input string contains any phrase from `protectedPhrases`, the LLM will be instructed not
|
|
4110
|
+
* to translate them.
|
|
4111
|
+
*
|
|
4112
|
+
* It is recommended to use `protectedPhrases` instead of `styleGuide` for deny-list words and phrases,
|
|
4113
|
+
* since it keeps token cost low, resulting in faster responses, and limits how much information the LLM
|
|
4114
|
+
* has to process, since only phrases that are actually in the input string will be included in the final prompt.
|
|
4115
|
+
*/
|
|
4116
|
+
protectedPhrases?: string[]
|
|
4117
|
+
/**
|
|
4118
|
+
* When specified, the `toLanguage.id` will be stored in the specified path in the target document.
|
|
4119
|
+
*
|
|
4120
|
+
* The file _can_ be hidden: true (unlike other fields in the target, which will be ignored)
|
|
4121
|
+
*/
|
|
4122
|
+
languageFieldPath?: AgentActionPathSegment | AgentActionPath
|
|
4123
|
+
/**
|
|
4124
|
+
* Target defines which parts of the document will be affected by the instruction.
|
|
4125
|
+
* It can be an array, so multiple parts of the document can be separately configured in detail.
|
|
4126
|
+
*
|
|
4127
|
+
* Omitting target implies that the document itself is the root.
|
|
4128
|
+
*
|
|
4129
|
+
* Notes:
|
|
4130
|
+
* - instruction can only affect fields up to `maxPathDepth`
|
|
4131
|
+
* - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.
|
|
4132
|
+
* It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)
|
|
4133
|
+
*
|
|
4134
|
+
* @see AgentActionRequestBase#conditionalPaths
|
|
4135
|
+
*/
|
|
4136
|
+
target?: TranslateTarget | TranslateTarget[]
|
|
4137
|
+
}
|
|
4138
|
+
|
|
4139
|
+
/** @beta */
|
|
4140
|
+
export declare interface TranslateTarget extends AgentActionTarget {
|
|
4141
|
+
/** string template using $variable from instructionParams */
|
|
4142
|
+
styleGuide?: string
|
|
4143
|
+
/**
|
|
4144
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
4145
|
+
*
|
|
4146
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
4147
|
+
*
|
|
4148
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
4149
|
+
*/
|
|
4150
|
+
include?: (AgentActionPathSegment | TranslateTargetInclude)[]
|
|
4151
|
+
}
|
|
4152
|
+
|
|
4153
|
+
/** @beta */
|
|
4154
|
+
export declare interface TranslateTargetInclude extends AgentActionTargetInclude {
|
|
4155
|
+
/** string template using $variable from instructionParams */
|
|
4156
|
+
styleGuide?: string
|
|
4157
|
+
/**
|
|
4158
|
+
* By default, all children up to `target.maxPathDepth` are included.
|
|
4159
|
+
*
|
|
4160
|
+
* When `include` is specified, only segments explicitly listed will be included.
|
|
4161
|
+
*
|
|
4162
|
+
* Fields or array items not on the include list, are implicitly excluded.
|
|
4163
|
+
*/
|
|
4164
|
+
include?: (AgentActionPathSegment | TranslateTargetInclude)[]
|
|
4165
|
+
}
|
|
4166
|
+
|
|
4459
4167
|
/** @public */
|
|
4460
4168
|
export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
4461
4169
|
filterResponse: false
|
|
@@ -4566,7 +4274,7 @@ export declare interface UploadClientConfig {
|
|
|
4566
4274
|
}
|
|
4567
4275
|
|
|
4568
4276
|
/** @public */
|
|
4569
|
-
export declare class UsersClient
|
|
4277
|
+
export declare class UsersClient {
|
|
4570
4278
|
#private
|
|
4571
4279
|
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
4572
4280
|
/**
|
|
@@ -4577,16 +4285,6 @@ export declare class UsersClient implements UsersClientType {
|
|
|
4577
4285
|
getById<T extends 'me' | string>(id: T): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
4578
4286
|
}
|
|
4579
4287
|
|
|
4580
|
-
/** @internal */
|
|
4581
|
-
declare interface UsersClientType {
|
|
4582
|
-
/**
|
|
4583
|
-
* Fetch a user by user ID
|
|
4584
|
-
*
|
|
4585
|
-
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
4586
|
-
*/
|
|
4587
|
-
getById<T extends 'me' | string>(id: T): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
4588
|
-
}
|
|
4589
|
-
|
|
4590
4288
|
/**
|
|
4591
4289
|
* @internal - it may have breaking changes in any release
|
|
4592
4290
|
*/
|