@sanity/client 7.0.1-canary.1 → 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 +1366 -1538
- package/dist/index.browser.d.ts +1366 -1538
- 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 +1366 -1538
- package/dist/index.d.ts +1366 -1538
- package/dist/index.js +103 -5
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +1373 -1545
- package/dist/stega.browser.d.ts +1373 -1545
- package/dist/stega.d.cts +1373 -1545
- package/dist/stega.d.ts +1373 -1545
- package/package.json +2 -1
- package/src/SanityClient.ts +30 -1078
- 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 -98
- package/src/data/dataMethods.ts +1 -1
- package/src/data/transaction.ts +1 -1
- package/src/projects/ProjectsClient.ts +2 -2
- package/src/types.ts +30 -1
- 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,52 +372,6 @@ export declare class AssetsClient implements AssetsClientType {
|
|
|
116
372
|
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
117
373
|
}
|
|
118
374
|
|
|
119
|
-
/**
|
|
120
|
-
* The interface implemented by the `AssetsClient` class.
|
|
121
|
-
* When writing code that wants to take an instance of `AssetsClient` as input it's better to use this type,
|
|
122
|
-
* as the `AssetsClient` class has private properties and thus TypeScript will consider the type incompatible
|
|
123
|
-
* in cases where you might have multiple `@sanity/client` instances in your node_modules.
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
declare interface AssetsClientType {
|
|
127
|
-
/**
|
|
128
|
-
* Uploads a file asset to the configured dataset
|
|
129
|
-
*
|
|
130
|
-
* @param assetType - Asset type (file)
|
|
131
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
132
|
-
* @param options - Options to use for the upload
|
|
133
|
-
*/
|
|
134
|
-
upload(
|
|
135
|
-
assetType: 'file',
|
|
136
|
-
body: UploadBody,
|
|
137
|
-
options?: UploadClientConfig,
|
|
138
|
-
): Promise<SanityAssetDocument>
|
|
139
|
-
/**
|
|
140
|
-
* Uploads an image asset to the configured dataset
|
|
141
|
-
*
|
|
142
|
-
* @param assetType - Asset type (image)
|
|
143
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
144
|
-
* @param options - Options to use for the upload
|
|
145
|
-
*/
|
|
146
|
-
upload(
|
|
147
|
-
assetType: 'image',
|
|
148
|
-
body: UploadBody,
|
|
149
|
-
options?: UploadClientConfig,
|
|
150
|
-
): Promise<SanityImageAssetDocument>
|
|
151
|
-
/**
|
|
152
|
-
* Uploads a file or an image asset to the configured dataset
|
|
153
|
-
*
|
|
154
|
-
* @param assetType - Asset type (file/image)
|
|
155
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
156
|
-
* @param options - Options to use for the upload
|
|
157
|
-
*/
|
|
158
|
-
upload(
|
|
159
|
-
assetType: 'file' | 'image',
|
|
160
|
-
body: UploadBody,
|
|
161
|
-
options?: UploadClientConfig,
|
|
162
|
-
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
163
|
-
}
|
|
164
|
-
|
|
165
375
|
/** @internal */
|
|
166
376
|
export declare type AttributeSet = {
|
|
167
377
|
[key: string]: Any
|
|
@@ -521,6 +731,43 @@ export declare class ConnectionFailedError extends Error {
|
|
|
521
731
|
readonly name = 'ConnectionFailedError'
|
|
522
732
|
}
|
|
523
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
|
+
|
|
524
771
|
/** @public */
|
|
525
772
|
export declare interface ContentSourceMap {
|
|
526
773
|
mappings: ContentSourceMapMappings
|
|
@@ -791,6 +1038,34 @@ export declare type DisconnectEvent = {
|
|
|
791
1038
|
reason: string
|
|
792
1039
|
}
|
|
793
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
|
+
|
|
794
1069
|
/**
|
|
795
1070
|
* Modifies an existing draft document.
|
|
796
1071
|
* It applies the given patch to the document referenced by draftId.
|
|
@@ -833,6 +1108,41 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
|
|
|
833
1108
|
*/
|
|
834
1109
|
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
835
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
|
+
|
|
836
1146
|
/** @public */
|
|
837
1147
|
export declare type FilterDefault = (props: {
|
|
838
1148
|
/**
|
|
@@ -899,6 +1209,274 @@ export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
|
899
1209
|
returnDocuments?: true
|
|
900
1210
|
}
|
|
901
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
|
+
|
|
902
1480
|
/** @public */
|
|
903
1481
|
export declare type HttpRequest = {
|
|
904
1482
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
@@ -1028,15 +1606,6 @@ export declare interface ListenOptions {
|
|
|
1028
1606
|
* @defaultValue `false`
|
|
1029
1607
|
*/
|
|
1030
1608
|
includePreviousRevision?: boolean
|
|
1031
|
-
/**
|
|
1032
|
-
* Whether to include events for drafts and versions. As of API Version >= v2025-02-19, only events
|
|
1033
|
-
* for published documents will be included by default (see {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog})
|
|
1034
|
-
* If you need events from drafts and versions, set this to `true`.
|
|
1035
|
-
* Note: Keep in mind that additional document variants may be introduced in the future, so it's
|
|
1036
|
-
* recommended to respond to events in a way that's tolerant of potential future variants, e.g. by
|
|
1037
|
-
* explicitly checking whether the event is for a draft or a version.
|
|
1038
|
-
* @defaultValue `false`
|
|
1039
|
-
*/
|
|
1040
1609
|
includeAllVersions?: boolean
|
|
1041
1610
|
/**
|
|
1042
1611
|
* Whether events should be sent as soon as a transaction has been committed (`transaction`, default),
|
|
@@ -1331,8 +1900,53 @@ export declare type MutationSelectionQueryParams = {
|
|
|
1331
1900
|
[key: string]: Any
|
|
1332
1901
|
}
|
|
1333
1902
|
|
|
1903
|
+
/** @public */
|
|
1904
|
+
declare class ObservableAgentsActionClient {
|
|
1905
|
+
#private
|
|
1906
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1907
|
+
/**
|
|
1908
|
+
* Run an instruction to generate content in a target document.
|
|
1909
|
+
* @param request - instruction request
|
|
1910
|
+
*/
|
|
1911
|
+
generate<DocumentShape extends Record<string, Any>>(
|
|
1912
|
+
request: GenerateInstruction<DocumentShape>,
|
|
1913
|
+
): Observable<
|
|
1914
|
+
(typeof request)['async'] extends true
|
|
1915
|
+
? {
|
|
1916
|
+
_id: string
|
|
1917
|
+
}
|
|
1918
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
1919
|
+
>
|
|
1920
|
+
/**
|
|
1921
|
+
* Transform a target document based on a source.
|
|
1922
|
+
* @param request - translation request
|
|
1923
|
+
*/
|
|
1924
|
+
transform<DocumentShape extends Record<string, Any>>(
|
|
1925
|
+
request: TransformDocument<DocumentShape>,
|
|
1926
|
+
): Observable<
|
|
1927
|
+
(typeof request)['async'] extends true
|
|
1928
|
+
? {
|
|
1929
|
+
_id: string
|
|
1930
|
+
}
|
|
1931
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
1932
|
+
>
|
|
1933
|
+
/**
|
|
1934
|
+
* Translate a target document based on a source.
|
|
1935
|
+
* @param request - translation request
|
|
1936
|
+
*/
|
|
1937
|
+
translate<DocumentShape extends Record<string, Any>>(
|
|
1938
|
+
request: TranslateDocument<DocumentShape>,
|
|
1939
|
+
): Observable<
|
|
1940
|
+
(typeof request)['async'] extends true
|
|
1941
|
+
? {
|
|
1942
|
+
_id: string
|
|
1943
|
+
}
|
|
1944
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
1945
|
+
>
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1334
1948
|
/** @internal */
|
|
1335
|
-
export declare class ObservableAssetsClient
|
|
1949
|
+
export declare class ObservableAssetsClient {
|
|
1336
1950
|
#private
|
|
1337
1951
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1338
1952
|
/**
|
|
@@ -1385,73 +1999,15 @@ export declare class ObservableAssetsClient implements ObservableAssetsClientTyp
|
|
|
1385
1999
|
>
|
|
1386
2000
|
}
|
|
1387
2001
|
|
|
1388
|
-
/**
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
* in cases where you might have multiple `@sanity/client` instances in your node_modules.
|
|
1393
|
-
* @public
|
|
1394
|
-
*/
|
|
1395
|
-
declare interface ObservableAssetsClientType {
|
|
2002
|
+
/** @internal */
|
|
2003
|
+
export declare class ObservableDatasetsClient {
|
|
2004
|
+
#private
|
|
2005
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1396
2006
|
/**
|
|
1397
|
-
*
|
|
2007
|
+
* Create a new dataset with the given name
|
|
1398
2008
|
*
|
|
1399
|
-
* @param
|
|
1400
|
-
* @param
|
|
1401
|
-
* @param options - Options to use for the upload
|
|
1402
|
-
*/
|
|
1403
|
-
upload(
|
|
1404
|
-
assetType: 'file',
|
|
1405
|
-
body: UploadBody,
|
|
1406
|
-
options?: UploadClientConfig,
|
|
1407
|
-
): Observable<
|
|
1408
|
-
HttpRequestEvent<{
|
|
1409
|
-
document: SanityAssetDocument
|
|
1410
|
-
}>
|
|
1411
|
-
>
|
|
1412
|
-
/**
|
|
1413
|
-
* Uploads an image asset to the configured dataset
|
|
1414
|
-
*
|
|
1415
|
-
* @param assetType - Asset type (image)
|
|
1416
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1417
|
-
* @param options - Options to use for the upload
|
|
1418
|
-
*/
|
|
1419
|
-
upload(
|
|
1420
|
-
assetType: 'image',
|
|
1421
|
-
body: UploadBody,
|
|
1422
|
-
options?: UploadClientConfig,
|
|
1423
|
-
): Observable<
|
|
1424
|
-
HttpRequestEvent<{
|
|
1425
|
-
document: SanityImageAssetDocument
|
|
1426
|
-
}>
|
|
1427
|
-
>
|
|
1428
|
-
/**
|
|
1429
|
-
* Uploads a file or an image asset to the configured dataset
|
|
1430
|
-
*
|
|
1431
|
-
* @param assetType - Asset type (file/image)
|
|
1432
|
-
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1433
|
-
* @param options - Options to use for the upload
|
|
1434
|
-
*/
|
|
1435
|
-
upload(
|
|
1436
|
-
assetType: 'file' | 'image',
|
|
1437
|
-
body: UploadBody,
|
|
1438
|
-
options?: UploadClientConfig,
|
|
1439
|
-
): Observable<
|
|
1440
|
-
HttpRequestEvent<{
|
|
1441
|
-
document: SanityAssetDocument | SanityImageAssetDocument
|
|
1442
|
-
}>
|
|
1443
|
-
>
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
/** @internal */
|
|
1447
|
-
export declare class ObservableDatasetsClient {
|
|
1448
|
-
#private
|
|
1449
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1450
|
-
/**
|
|
1451
|
-
* Create a new dataset with the given name
|
|
1452
|
-
*
|
|
1453
|
-
* @param name - Name of the dataset to create
|
|
1454
|
-
* @param options - Options for the dataset
|
|
2009
|
+
* @param name - Name of the dataset to create
|
|
2010
|
+
* @param options - Options for the dataset
|
|
1455
2011
|
*/
|
|
1456
2012
|
create(
|
|
1457
2013
|
name: string,
|
|
@@ -1546,7 +2102,7 @@ export declare class ObservableProjectsClient {
|
|
|
1546
2102
|
* Fetch a list of projects the authenticated user has access to.
|
|
1547
2103
|
*
|
|
1548
2104
|
* @param options - Options for the list request
|
|
1549
|
-
*
|
|
2105
|
+
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
1550
2106
|
*/
|
|
1551
2107
|
list(options?: {includeMembers?: true}): Observable<SanityProject[]>
|
|
1552
2108
|
list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
|
|
@@ -1559,13 +2115,19 @@ export declare class ObservableProjectsClient {
|
|
|
1559
2115
|
}
|
|
1560
2116
|
|
|
1561
2117
|
/** @public */
|
|
1562
|
-
export declare class ObservableSanityClient
|
|
2118
|
+
export declare class ObservableSanityClient {
|
|
1563
2119
|
#private
|
|
1564
2120
|
assets: ObservableAssetsClient
|
|
1565
2121
|
datasets: ObservableDatasetsClient
|
|
1566
2122
|
live: LiveClient
|
|
1567
2123
|
projects: ObservableProjectsClient
|
|
1568
2124
|
users: ObservableUsersClient
|
|
2125
|
+
agent: {
|
|
2126
|
+
action: ObservableAgentsActionClient
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* Instance properties
|
|
2130
|
+
*/
|
|
1569
2131
|
listen: typeof _listen
|
|
1570
2132
|
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1571
2133
|
/**
|
|
@@ -1624,7 +2186,7 @@ export declare class ObservableSanityClient implements ObservableSanityClientTyp
|
|
|
1624
2186
|
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1625
2187
|
const G extends string = string,
|
|
1626
2188
|
>(
|
|
1627
|
-
query:
|
|
2189
|
+
query: string,
|
|
1628
2190
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1629
2191
|
options: UnfilteredResponseQueryOptions,
|
|
1630
2192
|
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
@@ -2059,1485 +2621,445 @@ export declare class ObservableSanityClient implements ObservableSanityClientTyp
|
|
|
2059
2621
|
getDataUrl(operation: string, path?: string): string
|
|
2060
2622
|
}
|
|
2061
2623
|
|
|
2062
|
-
/**
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
* in cases where you might have multiple `@sanity/client` instances in your node_modules.
|
|
2067
|
-
* @public
|
|
2068
|
-
*/
|
|
2069
|
-
export declare interface ObservableSanityClientType extends SanityClientBase {
|
|
2070
|
-
assets: ObservableAssetsClient
|
|
2071
|
-
datasets: ObservableDatasetsClient
|
|
2072
|
-
projects: ObservableProjectsClient
|
|
2073
|
-
users: ObservableUsersClient
|
|
2624
|
+
/** @public */
|
|
2625
|
+
export declare class ObservableTransaction extends BaseTransaction {
|
|
2626
|
+
#private
|
|
2627
|
+
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
2074
2628
|
/**
|
|
2075
|
-
*
|
|
2629
|
+
* Clones the transaction
|
|
2076
2630
|
*/
|
|
2077
|
-
clone():
|
|
2631
|
+
clone(): ObservableTransaction
|
|
2078
2632
|
/**
|
|
2079
|
-
*
|
|
2633
|
+
* Commit the transaction, returning an observable that produces the first mutated document
|
|
2634
|
+
*
|
|
2635
|
+
* @param options - Options for the mutation operation
|
|
2080
2636
|
*/
|
|
2081
|
-
|
|
2637
|
+
commit<R extends Record<string, Any>>(
|
|
2638
|
+
options: TransactionFirstDocumentMutationOptions,
|
|
2639
|
+
): Observable<SanityDocument<R>>
|
|
2082
2640
|
/**
|
|
2083
|
-
*
|
|
2641
|
+
* Commit the transaction, returning an observable that produces an array of the mutated documents
|
|
2642
|
+
*
|
|
2643
|
+
* @param options - Options for the mutation operation
|
|
2084
2644
|
*/
|
|
2085
|
-
|
|
2645
|
+
commit<R extends Record<string, Any>>(
|
|
2646
|
+
options: TransactionAllDocumentsMutationOptions,
|
|
2647
|
+
): Observable<SanityDocument<R>[]>
|
|
2086
2648
|
/**
|
|
2087
|
-
*
|
|
2649
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2088
2650
|
*
|
|
2089
|
-
* @param
|
|
2651
|
+
* @param options - Options for the mutation operation
|
|
2090
2652
|
*/
|
|
2091
|
-
|
|
2653
|
+
commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2092
2654
|
/**
|
|
2093
|
-
*
|
|
2655
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2094
2656
|
*
|
|
2095
|
-
* @param
|
|
2657
|
+
* @param options - Options for the mutation operation
|
|
2096
2658
|
*/
|
|
2097
|
-
|
|
2098
|
-
R = Any,
|
|
2099
|
-
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
2100
|
-
const G extends string = string,
|
|
2101
|
-
>(
|
|
2102
|
-
query: G,
|
|
2103
|
-
params?: Q | QueryWithoutParams,
|
|
2104
|
-
): Observable<ClientReturn<G, R>>
|
|
2659
|
+
commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2105
2660
|
/**
|
|
2106
|
-
*
|
|
2661
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2107
2662
|
*
|
|
2108
|
-
* @param
|
|
2109
|
-
* @param params - Optional query parameters
|
|
2110
|
-
* @param options - Optional request options
|
|
2663
|
+
* @param options - Options for the mutation operation
|
|
2111
2664
|
*/
|
|
2112
|
-
|
|
2113
|
-
R = Any,
|
|
2114
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2115
|
-
const G extends string = string,
|
|
2116
|
-
>(
|
|
2117
|
-
query: G,
|
|
2118
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2119
|
-
options?: FilteredResponseQueryOptions,
|
|
2120
|
-
): Observable<ClientReturn<G, R>>
|
|
2665
|
+
commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
|
|
2121
2666
|
/**
|
|
2122
|
-
*
|
|
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()`
|
|
2123
2669
|
*
|
|
2124
|
-
* @param
|
|
2125
|
-
* @param
|
|
2126
|
-
* @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
|
|
2127
2672
|
*/
|
|
2128
|
-
|
|
2129
|
-
R = Any,
|
|
2130
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2131
|
-
const G extends string = string,
|
|
2132
|
-
>(
|
|
2133
|
-
query: G,
|
|
2134
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2135
|
-
options: UnfilteredResponseQueryOptions,
|
|
2136
|
-
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
2673
|
+
patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
|
|
2137
2674
|
/**
|
|
2138
|
-
*
|
|
2675
|
+
* Adds the given patch instance to the transaction.
|
|
2676
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2139
2677
|
*
|
|
2140
|
-
* @param
|
|
2141
|
-
* @param params - Optional query parameters
|
|
2142
|
-
* @param options - Request options
|
|
2678
|
+
* @param patch - ObservablePatch to execute
|
|
2143
2679
|
*/
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
options: UnfilteredResponseWithoutQuery,
|
|
2152
|
-
): 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)
|
|
2153
2687
|
/**
|
|
2154
|
-
* Fetch a
|
|
2688
|
+
* Fetch a user by user ID
|
|
2155
2689
|
*
|
|
2156
|
-
* @param id -
|
|
2157
|
-
* @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.
|
|
2158
2691
|
*/
|
|
2159
|
-
|
|
2160
|
-
id:
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
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)
|
|
2165
2710
|
/**
|
|
2166
|
-
*
|
|
2167
|
-
* Should be used sparingly - performing a query is usually a better option.
|
|
2168
|
-
* The order/position of documents is preserved based on the original array of IDs.
|
|
2169
|
-
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
2170
|
-
*
|
|
2171
|
-
* @param ids - Document IDs to fetch
|
|
2172
|
-
* @param options - Request options
|
|
2711
|
+
* Clones the patch
|
|
2173
2712
|
*/
|
|
2174
|
-
|
|
2175
|
-
ids: string[],
|
|
2176
|
-
options?: {
|
|
2177
|
-
tag?: string
|
|
2178
|
-
},
|
|
2179
|
-
): Observable<(SanityDocument<R> | null)[]>
|
|
2713
|
+
clone(): Patch
|
|
2180
2714
|
/**
|
|
2181
|
-
*
|
|
2182
|
-
* Returns an observable that resolves to the created document.
|
|
2715
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2183
2716
|
*
|
|
2184
|
-
* @param
|
|
2185
|
-
* @param options - Mutation options
|
|
2717
|
+
* @param options - Options for the mutation operation
|
|
2186
2718
|
*/
|
|
2187
|
-
|
|
2188
|
-
document: SanityDocumentStub<R>,
|
|
2719
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2189
2720
|
options: FirstDocumentMutationOptions,
|
|
2190
|
-
):
|
|
2721
|
+
): Promise<SanityDocument<R>>
|
|
2191
2722
|
/**
|
|
2192
|
-
*
|
|
2193
|
-
* 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
|
|
2194
2724
|
*
|
|
2195
|
-
* @param
|
|
2196
|
-
* @param options - Mutation options
|
|
2725
|
+
* @param options - Options for the mutation operation
|
|
2197
2726
|
*/
|
|
2198
|
-
|
|
2199
|
-
document: SanityDocumentStub<R>,
|
|
2727
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2200
2728
|
options: AllDocumentsMutationOptions,
|
|
2201
|
-
):
|
|
2729
|
+
): Promise<SanityDocument<R>[]>
|
|
2202
2730
|
/**
|
|
2203
|
-
*
|
|
2204
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2731
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2205
2732
|
*
|
|
2206
|
-
* @param
|
|
2207
|
-
* @param options - Mutation options
|
|
2733
|
+
* @param options - Options for the mutation operation
|
|
2208
2734
|
*/
|
|
2209
|
-
|
|
2210
|
-
document: SanityDocumentStub<R>,
|
|
2211
|
-
options: FirstDocumentIdMutationOptions,
|
|
2212
|
-
): Observable<SingleMutationResult>
|
|
2735
|
+
commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2213
2736
|
/**
|
|
2214
|
-
*
|
|
2215
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2737
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2216
2738
|
*
|
|
2217
|
-
* @param
|
|
2218
|
-
* @param options - Mutation options
|
|
2739
|
+
* @param options - Options for the mutation operation
|
|
2219
2740
|
*/
|
|
2220
|
-
|
|
2221
|
-
document: SanityDocumentStub<R>,
|
|
2222
|
-
options: AllDocumentIdsMutationOptions,
|
|
2223
|
-
): Observable<MultipleMutationResult>
|
|
2741
|
+
commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
2224
2742
|
/**
|
|
2225
|
-
*
|
|
2226
|
-
* Returns an observable that resolves to the created document.
|
|
2743
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2227
2744
|
*
|
|
2228
|
-
* @param
|
|
2229
|
-
* @param options - Mutation options
|
|
2745
|
+
* @param options - Options for the mutation operation
|
|
2230
2746
|
*/
|
|
2231
|
-
|
|
2232
|
-
document: SanityDocumentStub<R>,
|
|
2233
|
-
options?: BaseMutationOptions,
|
|
2234
|
-
): Observable<SanityDocument<R>>
|
|
2235
|
-
/**
|
|
2236
|
-
* Create a document if no document with the same ID already exists.
|
|
2237
|
-
* Returns an observable that resolves to the created document.
|
|
2238
|
-
*
|
|
2239
|
-
* @param document - Document to create
|
|
2240
|
-
* @param options - Mutation options
|
|
2241
|
-
*/
|
|
2242
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2243
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2244
|
-
options: FirstDocumentMutationOptions,
|
|
2245
|
-
): Observable<SanityDocument<R>>
|
|
2246
|
-
/**
|
|
2247
|
-
* Create a document if no document with the same ID already exists.
|
|
2248
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
2249
|
-
*
|
|
2250
|
-
* @param document - Document to create
|
|
2251
|
-
* @param options - Mutation options
|
|
2252
|
-
*/
|
|
2253
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2254
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2255
|
-
options: AllDocumentsMutationOptions,
|
|
2256
|
-
): Observable<SanityDocument<R>[]>
|
|
2257
|
-
/**
|
|
2258
|
-
* Create a document if no document with the same ID already exists.
|
|
2259
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2260
|
-
*
|
|
2261
|
-
* @param document - Document to create
|
|
2262
|
-
* @param options - Mutation options
|
|
2263
|
-
*/
|
|
2264
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2265
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2266
|
-
options: FirstDocumentIdMutationOptions,
|
|
2267
|
-
): Observable<SingleMutationResult>
|
|
2268
|
-
/**
|
|
2269
|
-
* Create a document if no document with the same ID already exists.
|
|
2270
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2271
|
-
*
|
|
2272
|
-
* @param document - Document to create
|
|
2273
|
-
* @param options - Mutation options
|
|
2274
|
-
*/
|
|
2275
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2276
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2277
|
-
options: AllDocumentIdsMutationOptions,
|
|
2278
|
-
): Observable<MultipleMutationResult>
|
|
2279
|
-
/**
|
|
2280
|
-
* Create a document if no document with the same ID already exists.
|
|
2281
|
-
* Returns an observable that resolves to the created document.
|
|
2282
|
-
*
|
|
2283
|
-
* @param document - Document to create
|
|
2284
|
-
* @param options - Mutation options
|
|
2285
|
-
*/
|
|
2286
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2287
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2288
|
-
options?: BaseMutationOptions,
|
|
2289
|
-
): Observable<SanityDocument<R>>
|
|
2290
|
-
/**
|
|
2291
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2292
|
-
* Returns an observable that resolves to the created document.
|
|
2293
|
-
*
|
|
2294
|
-
* @param document - Document to either create or replace
|
|
2295
|
-
* @param options - Mutation options
|
|
2296
|
-
*/
|
|
2297
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2298
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2299
|
-
options: FirstDocumentMutationOptions,
|
|
2300
|
-
): Observable<SanityDocument<R>>
|
|
2301
|
-
/**
|
|
2302
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2303
|
-
* Returns an observable that resolves to an array containing the created document.
|
|
2304
|
-
*
|
|
2305
|
-
* @param document - Document to either create or replace
|
|
2306
|
-
* @param options - Mutation options
|
|
2307
|
-
*/
|
|
2308
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2309
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2310
|
-
options: AllDocumentsMutationOptions,
|
|
2311
|
-
): Observable<SanityDocument<R>[]>
|
|
2312
|
-
/**
|
|
2313
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2314
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
2315
|
-
*
|
|
2316
|
-
* @param document - Document to either create or replace
|
|
2317
|
-
* @param options - Mutation options
|
|
2318
|
-
*/
|
|
2319
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2320
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2321
|
-
options: FirstDocumentIdMutationOptions,
|
|
2322
|
-
): Observable<SingleMutationResult>
|
|
2323
|
-
/**
|
|
2324
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2325
|
-
* Returns an observable that resolves to a mutation result object containing the created document ID.
|
|
2326
|
-
*
|
|
2327
|
-
* @param document - Document to either create or replace
|
|
2328
|
-
* @param options - Mutation options
|
|
2329
|
-
*/
|
|
2330
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2331
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2332
|
-
options: AllDocumentIdsMutationOptions,
|
|
2333
|
-
): Observable<MultipleMutationResult>
|
|
2334
|
-
/**
|
|
2335
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2336
|
-
* Returns an observable that resolves to the created document.
|
|
2337
|
-
*
|
|
2338
|
-
* @param document - Document to either create or replace
|
|
2339
|
-
* @param options - Mutation options
|
|
2340
|
-
*/
|
|
2341
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2342
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
2343
|
-
options?: BaseMutationOptions,
|
|
2344
|
-
): Observable<SanityDocument<R>>
|
|
2345
|
-
/**
|
|
2346
|
-
* Deletes a document with the given document ID.
|
|
2347
|
-
* Returns an observable that resolves to the deleted document.
|
|
2348
|
-
*
|
|
2349
|
-
* @param id - Document ID to delete
|
|
2350
|
-
* @param options - Options for the mutation
|
|
2351
|
-
*/
|
|
2352
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2353
|
-
id: string,
|
|
2354
|
-
options: FirstDocumentMutationOptions,
|
|
2355
|
-
): Observable<SanityDocument<R>>
|
|
2356
|
-
/**
|
|
2357
|
-
* Deletes a document with the given document ID.
|
|
2358
|
-
* Returns an observable that resolves to an array containing the deleted document.
|
|
2359
|
-
*
|
|
2360
|
-
* @param id - Document ID to delete
|
|
2361
|
-
* @param options - Options for the mutation
|
|
2362
|
-
*/
|
|
2363
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2364
|
-
id: string,
|
|
2365
|
-
options: AllDocumentsMutationOptions,
|
|
2366
|
-
): Observable<SanityDocument<R>[]>
|
|
2367
|
-
/**
|
|
2368
|
-
* Deletes a document with the given document ID.
|
|
2369
|
-
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
2370
|
-
*
|
|
2371
|
-
* @param id - Document ID to delete
|
|
2372
|
-
* @param options - Options for the mutation
|
|
2373
|
-
*/
|
|
2374
|
-
delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2375
|
-
/**
|
|
2376
|
-
* Deletes a document with the given document ID.
|
|
2377
|
-
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
2378
|
-
*
|
|
2379
|
-
* @param id - Document ID to delete
|
|
2380
|
-
* @param options - Options for the mutation
|
|
2381
|
-
*/
|
|
2382
|
-
delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2383
|
-
/**
|
|
2384
|
-
* Deletes a document with the given document ID.
|
|
2385
|
-
* Returns an observable that resolves to the deleted document.
|
|
2386
|
-
*
|
|
2387
|
-
* @param id - Document ID to delete
|
|
2388
|
-
* @param options - Options for the mutation
|
|
2389
|
-
*/
|
|
2390
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2391
|
-
id: string,
|
|
2392
|
-
options?: BaseMutationOptions,
|
|
2393
|
-
): Observable<SanityDocument<R>>
|
|
2394
|
-
/**
|
|
2395
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2396
|
-
* Returns an observable that resolves to first deleted document.
|
|
2397
|
-
*
|
|
2398
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2399
|
-
* @param options - Options for the mutation
|
|
2400
|
-
*/
|
|
2401
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2402
|
-
selection: MutationSelection,
|
|
2403
|
-
options: FirstDocumentMutationOptions,
|
|
2404
|
-
): Observable<SanityDocument<R>>
|
|
2405
|
-
/**
|
|
2406
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2407
|
-
* Returns an observable that resolves to an array containing the deleted documents.
|
|
2408
|
-
*
|
|
2409
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2410
|
-
* @param options - Options for the mutation
|
|
2411
|
-
*/
|
|
2412
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2413
|
-
selection: MutationSelection,
|
|
2414
|
-
options: AllDocumentsMutationOptions,
|
|
2415
|
-
): Observable<SanityDocument<R>[]>
|
|
2416
|
-
/**
|
|
2417
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2418
|
-
* Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
|
|
2419
|
-
*
|
|
2420
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2421
|
-
* @param options - Options for the mutation
|
|
2422
|
-
*/
|
|
2423
|
-
delete(
|
|
2424
|
-
selection: MutationSelection,
|
|
2425
|
-
options: FirstDocumentIdMutationOptions,
|
|
2426
|
-
): Observable<SingleMutationResult>
|
|
2427
|
-
/**
|
|
2428
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2429
|
-
* Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
|
|
2430
|
-
*
|
|
2431
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2432
|
-
* @param options - Options for the mutation
|
|
2433
|
-
*/
|
|
2434
|
-
delete(
|
|
2435
|
-
selection: MutationSelection,
|
|
2436
|
-
options: AllDocumentIdsMutationOptions,
|
|
2437
|
-
): Observable<MultipleMutationResult>
|
|
2438
|
-
/**
|
|
2439
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
2440
|
-
* Returns an observable that resolves to first deleted document.
|
|
2441
|
-
*
|
|
2442
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2443
|
-
* @param options - Options for the mutation
|
|
2444
|
-
*/
|
|
2445
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2446
|
-
selection: MutationSelection,
|
|
2447
|
-
options?: BaseMutationOptions,
|
|
2448
|
-
): Observable<SanityDocument<R>>
|
|
2449
|
-
/**
|
|
2450
|
-
* Perform mutation operations against the configured dataset
|
|
2451
|
-
* Returns an observable that resolves to the first mutated document.
|
|
2452
|
-
*
|
|
2453
|
-
* @param operations - Mutation operations to execute
|
|
2454
|
-
* @param options - Mutation options
|
|
2455
|
-
*/
|
|
2456
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2457
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2458
|
-
options: FirstDocumentMutationOptions,
|
|
2459
|
-
): Observable<SanityDocument<R>>
|
|
2460
|
-
/**
|
|
2461
|
-
* Perform mutation operations against the configured dataset.
|
|
2462
|
-
* Returns an observable that resolves to an array of the mutated documents.
|
|
2463
|
-
*
|
|
2464
|
-
* @param operations - Mutation operations to execute
|
|
2465
|
-
* @param options - Mutation options
|
|
2466
|
-
*/
|
|
2467
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2468
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2469
|
-
options: AllDocumentsMutationOptions,
|
|
2470
|
-
): Observable<SanityDocument<R>[]>
|
|
2471
|
-
/**
|
|
2472
|
-
* Perform mutation operations against the configured dataset
|
|
2473
|
-
* Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
2474
|
-
*
|
|
2475
|
-
* @param operations - Mutation operations to execute
|
|
2476
|
-
* @param options - Mutation options
|
|
2477
|
-
*/
|
|
2478
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2479
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2480
|
-
options: FirstDocumentIdMutationOptions,
|
|
2481
|
-
): Observable<SingleMutationResult>
|
|
2482
|
-
/**
|
|
2483
|
-
* Perform mutation operations against the configured dataset
|
|
2484
|
-
* Returns an observable that resolves to a mutation result object containing the mutated document IDs.
|
|
2485
|
-
*
|
|
2486
|
-
* @param operations - Mutation operations to execute
|
|
2487
|
-
* @param options - Mutation options
|
|
2488
|
-
*/
|
|
2489
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2490
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2491
|
-
options: AllDocumentIdsMutationOptions,
|
|
2492
|
-
): Observable<MultipleMutationResult>
|
|
2493
|
-
/**
|
|
2494
|
-
* Perform mutation operations against the configured dataset
|
|
2495
|
-
* Returns an observable that resolves to the first mutated document.
|
|
2496
|
-
*
|
|
2497
|
-
* @param operations - Mutation operations to execute
|
|
2498
|
-
* @param options - Mutation options
|
|
2499
|
-
*/
|
|
2500
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2501
|
-
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2502
|
-
options?: BaseMutationOptions,
|
|
2503
|
-
): Observable<SanityDocument<R>>
|
|
2504
|
-
/**
|
|
2505
|
-
* Create a new buildable patch of operations to perform
|
|
2506
|
-
*
|
|
2507
|
-
* @param documentId - Document ID to patch
|
|
2508
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2509
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2510
|
-
*/
|
|
2511
|
-
patch(documentId: string, operations?: PatchOperations): ObservablePatch
|
|
2512
|
-
/**
|
|
2513
|
-
* Create a new buildable patch of operations to perform
|
|
2514
|
-
*
|
|
2515
|
-
* @param documentIds - Array of document IDs to patch
|
|
2516
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2517
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2518
|
-
*/
|
|
2519
|
-
patch(documentIds: string[], operations?: PatchOperations): ObservablePatch
|
|
2520
|
-
/**
|
|
2521
|
-
* Create a new buildable patch of operations to perform
|
|
2522
|
-
*
|
|
2523
|
-
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
2524
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2525
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2526
|
-
*/
|
|
2527
|
-
patch(selection: MutationSelection, operations?: PatchOperations): ObservablePatch
|
|
2528
|
-
/**
|
|
2529
|
-
* Create a new buildable patch of operations to perform
|
|
2530
|
-
*
|
|
2531
|
-
* @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch
|
|
2532
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2533
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2534
|
-
*/
|
|
2535
|
-
patch(selection: PatchSelection, operations?: PatchOperations): ObservablePatch
|
|
2536
|
-
/**
|
|
2537
|
-
* Create a new transaction of mutations
|
|
2538
|
-
*
|
|
2539
|
-
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
2540
|
-
*/
|
|
2541
|
-
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
2542
|
-
operations?: Mutation<R>[],
|
|
2543
|
-
): ObservableTransaction
|
|
2544
|
-
/**
|
|
2545
|
-
* Perform action operations against the configured dataset
|
|
2546
|
-
*
|
|
2547
|
-
* @param operations - Action operation(s) to execute
|
|
2548
|
-
* @param options - Action options
|
|
2549
|
-
*/
|
|
2550
|
-
action(
|
|
2551
|
-
operations: Action | Action[],
|
|
2552
|
-
options?: BaseActionOptions,
|
|
2553
|
-
): Observable<SingleActionResult | MultipleActionResult>
|
|
2554
|
-
/**
|
|
2555
|
-
* Perform an HTTP request against the Sanity API
|
|
2556
|
-
*
|
|
2557
|
-
* @param options - Request options
|
|
2558
|
-
*/
|
|
2559
|
-
request<R = Any>(options: RawRequestOptions): Observable<R>
|
|
2560
|
-
}
|
|
2561
|
-
|
|
2562
|
-
/** @public */
|
|
2563
|
-
export declare class ObservableTransaction extends BaseTransaction {
|
|
2564
|
-
#private
|
|
2565
|
-
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
2566
|
-
/**
|
|
2567
|
-
* Clones the transaction
|
|
2568
|
-
*/
|
|
2569
|
-
clone(): ObservableTransaction
|
|
2570
|
-
/**
|
|
2571
|
-
* Commit the transaction, returning an observable that produces the first mutated document
|
|
2572
|
-
*
|
|
2573
|
-
* @param options - Options for the mutation operation
|
|
2574
|
-
*/
|
|
2575
|
-
commit<R extends Record<string, Any>>(
|
|
2576
|
-
options: TransactionFirstDocumentMutationOptions,
|
|
2577
|
-
): Observable<SanityDocument<R>>
|
|
2578
|
-
/**
|
|
2579
|
-
* Commit the transaction, returning an observable that produces an array of the mutated documents
|
|
2580
|
-
*
|
|
2581
|
-
* @param options - Options for the mutation operation
|
|
2582
|
-
*/
|
|
2583
|
-
commit<R extends Record<string, Any>>(
|
|
2584
|
-
options: TransactionAllDocumentsMutationOptions,
|
|
2585
|
-
): Observable<SanityDocument<R>[]>
|
|
2586
|
-
/**
|
|
2587
|
-
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2588
|
-
*
|
|
2589
|
-
* @param options - Options for the mutation operation
|
|
2590
|
-
*/
|
|
2591
|
-
commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2592
|
-
/**
|
|
2593
|
-
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2594
|
-
*
|
|
2595
|
-
* @param options - Options for the mutation operation
|
|
2596
|
-
*/
|
|
2597
|
-
commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2598
|
-
/**
|
|
2599
|
-
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2600
|
-
*
|
|
2601
|
-
* @param options - Options for the mutation operation
|
|
2602
|
-
*/
|
|
2603
|
-
commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
|
|
2604
|
-
/**
|
|
2605
|
-
* Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
|
|
2606
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2607
|
-
*
|
|
2608
|
-
* @param documentId - Document ID to perform the patch operation on
|
|
2609
|
-
* @param patchOps - Operations to perform, or a builder function
|
|
2610
|
-
*/
|
|
2611
|
-
patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
|
|
2612
|
-
/**
|
|
2613
|
-
* Adds the given patch instance to the transaction.
|
|
2614
|
-
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2615
|
-
*
|
|
2616
|
-
* @param patch - ObservablePatch to execute
|
|
2617
|
-
*/
|
|
2618
|
-
patch(patch: ObservablePatch): this
|
|
2619
|
-
}
|
|
2620
|
-
|
|
2621
|
-
/** @public */
|
|
2622
|
-
export declare class ObservableUsersClient {
|
|
2623
|
-
#private
|
|
2624
|
-
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
2625
|
-
/**
|
|
2626
|
-
* Fetch a user by user ID
|
|
2627
|
-
*
|
|
2628
|
-
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
2629
|
-
*/
|
|
2630
|
-
getById<T extends 'me' | string>(
|
|
2631
|
-
id: T,
|
|
2632
|
-
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
2633
|
-
}
|
|
2634
|
-
|
|
2635
|
-
/**
|
|
2636
|
-
* The listener connection has been established
|
|
2637
|
-
* note: it's usually a better option to use the 'welcome' event
|
|
2638
|
-
* @public
|
|
2639
|
-
*/
|
|
2640
|
-
export declare type OpenEvent = {
|
|
2641
|
-
type: 'open'
|
|
2642
|
-
}
|
|
2643
|
-
|
|
2644
|
-
/** @public */
|
|
2645
|
-
export declare class Patch extends BasePatch {
|
|
2646
|
-
#private
|
|
2647
|
-
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
2648
|
-
/**
|
|
2649
|
-
* Clones the patch
|
|
2650
|
-
*/
|
|
2651
|
-
clone(): Patch
|
|
2652
|
-
/**
|
|
2653
|
-
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2654
|
-
*
|
|
2655
|
-
* @param options - Options for the mutation operation
|
|
2656
|
-
*/
|
|
2657
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2658
|
-
options: FirstDocumentMutationOptions,
|
|
2659
|
-
): Promise<SanityDocument<R>>
|
|
2660
|
-
/**
|
|
2661
|
-
* Commit the patch, returning a promise that resolves to an array of the mutated documents
|
|
2662
|
-
*
|
|
2663
|
-
* @param options - Options for the mutation operation
|
|
2664
|
-
*/
|
|
2665
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2666
|
-
options: AllDocumentsMutationOptions,
|
|
2667
|
-
): Promise<SanityDocument<R>[]>
|
|
2668
|
-
/**
|
|
2669
|
-
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2670
|
-
*
|
|
2671
|
-
* @param options - Options for the mutation operation
|
|
2672
|
-
*/
|
|
2673
|
-
commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2674
|
-
/**
|
|
2675
|
-
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2676
|
-
*
|
|
2677
|
-
* @param options - Options for the mutation operation
|
|
2678
|
-
*/
|
|
2679
|
-
commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
2680
|
-
/**
|
|
2681
|
-
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2682
|
-
*
|
|
2683
|
-
* @param options - Options for the mutation operation
|
|
2684
|
-
*/
|
|
2685
|
-
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2686
|
-
options?: BaseMutationOptions,
|
|
2687
|
-
): Promise<SanityDocument<R>>
|
|
2688
|
-
}
|
|
2689
|
-
|
|
2690
|
-
/** @public */
|
|
2691
|
-
export declare type PatchBuilder = (patch: Patch) => Patch
|
|
2692
|
-
|
|
2693
|
-
/** @internal */
|
|
2694
|
-
export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
2695
|
-
|
|
2696
|
-
/** @internal */
|
|
2697
|
-
export declare interface PatchOperations {
|
|
2698
|
-
set?: {
|
|
2699
|
-
[key: string]: Any
|
|
2700
|
-
}
|
|
2701
|
-
setIfMissing?: {
|
|
2702
|
-
[key: string]: Any
|
|
2703
|
-
}
|
|
2704
|
-
diffMatchPatch?: {
|
|
2705
|
-
[key: string]: Any
|
|
2706
|
-
}
|
|
2707
|
-
unset?: string[]
|
|
2708
|
-
inc?: {
|
|
2709
|
-
[key: string]: number
|
|
2710
|
-
}
|
|
2711
|
-
dec?: {
|
|
2712
|
-
[key: string]: number
|
|
2713
|
-
}
|
|
2714
|
-
insert?: InsertPatch
|
|
2715
|
-
ifRevisionID?: string
|
|
2716
|
-
}
|
|
2717
|
-
|
|
2718
|
-
/** @internal */
|
|
2719
|
-
export declare type PatchSelection = string | string[] | MutationSelection
|
|
2720
|
-
|
|
2721
|
-
/** @public */
|
|
2722
|
-
declare interface ProgressEvent_2 {
|
|
2723
|
-
type: 'progress'
|
|
2724
|
-
stage: 'upload' | 'download'
|
|
2725
|
-
percent: number
|
|
2726
|
-
total?: number
|
|
2727
|
-
loaded?: number
|
|
2728
|
-
lengthComputable: boolean
|
|
2729
|
-
}
|
|
2730
|
-
export {ProgressEvent_2 as ProgressEvent}
|
|
2731
|
-
|
|
2732
|
-
/** @internal */
|
|
2733
|
-
export declare class ProjectsClient {
|
|
2734
|
-
#private
|
|
2735
|
-
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
2736
|
-
/**
|
|
2737
|
-
* Fetch a list of projects the authenticated user has access to.
|
|
2738
|
-
*
|
|
2739
|
-
* @param options - Options for the list request
|
|
2740
|
-
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
2741
|
-
*/
|
|
2742
|
-
list(options?: {includeMembers?: true}): Promise<SanityProject[]>
|
|
2743
|
-
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
2744
|
-
/**
|
|
2745
|
-
* Fetch a project by project ID
|
|
2746
|
-
*
|
|
2747
|
-
* @param projectId - ID of the project to fetch
|
|
2748
|
-
*/
|
|
2749
|
-
getById(projectId: string): Promise<SanityProject>
|
|
2750
|
-
}
|
|
2751
|
-
|
|
2752
|
-
/**
|
|
2753
|
-
* Publishes a draft document.
|
|
2754
|
-
* If a published version of the document already exists this is replaced by the current draft document.
|
|
2755
|
-
* In either case the draft document is deleted.
|
|
2756
|
-
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
2757
|
-
* that the draft and/or published versions of the document have not been changed by another client.
|
|
2758
|
-
*
|
|
2759
|
-
* @public
|
|
2760
|
-
*/
|
|
2761
|
-
export declare type PublishAction = {
|
|
2762
|
-
actionType: 'sanity.action.document.publish'
|
|
2763
|
-
/**
|
|
2764
|
-
* Draft document ID to publish
|
|
2765
|
-
*/
|
|
2766
|
-
draftId: string
|
|
2767
|
-
/**
|
|
2768
|
-
* Draft revision ID to match
|
|
2769
|
-
*/
|
|
2770
|
-
ifDraftRevisionId?: string
|
|
2771
|
-
/**
|
|
2772
|
-
* Published document ID to replace
|
|
2773
|
-
*/
|
|
2774
|
-
publishedId: string
|
|
2775
|
-
/**
|
|
2776
|
-
* Published revision ID to match
|
|
2777
|
-
*/
|
|
2778
|
-
ifPublishedRevisionId?: string
|
|
2779
|
-
}
|
|
2780
|
-
|
|
2781
|
-
/** @public */
|
|
2782
|
-
export declare type QueryOptions =
|
|
2783
|
-
| FilteredResponseQueryOptions
|
|
2784
|
-
| UnfilteredResponseQueryOptions
|
|
2785
|
-
| UnfilteredResponseWithoutQuery
|
|
2786
|
-
|
|
2787
|
-
/** @public */
|
|
2788
|
-
export declare interface QueryParams {
|
|
2789
|
-
[key: string]: any
|
|
2790
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2791
|
-
body?: never
|
|
2792
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2793
|
-
cache?: 'next' extends keyof RequestInit ? never : any
|
|
2794
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2795
|
-
filterResponse?: never
|
|
2796
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2797
|
-
headers?: never
|
|
2798
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2799
|
-
method?: never
|
|
2800
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2801
|
-
next?: 'next' extends keyof RequestInit ? never : any
|
|
2802
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2803
|
-
perspective?: never
|
|
2804
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2805
|
-
query?: never
|
|
2806
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2807
|
-
resultSourceMap?: never
|
|
2808
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2809
|
-
returnQuery?: never
|
|
2810
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2811
|
-
signal?: never
|
|
2812
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2813
|
-
stega?: never
|
|
2814
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2815
|
-
tag?: never
|
|
2816
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2817
|
-
timeout?: never
|
|
2818
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2819
|
-
token?: never
|
|
2820
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2821
|
-
useCdn?: never
|
|
2822
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2823
|
-
lastLiveEventId?: never
|
|
2824
|
-
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2825
|
-
cacheMode?: never
|
|
2826
|
-
}
|
|
2827
|
-
|
|
2828
|
-
/**
|
|
2829
|
-
* This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
|
|
2830
|
-
* @public
|
|
2831
|
-
*/
|
|
2832
|
-
export declare type QueryWithoutParams = Record<string, never> | undefined
|
|
2833
|
-
|
|
2834
|
-
/** @public */
|
|
2835
|
-
export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
2836
|
-
|
|
2837
|
-
/** @public */
|
|
2838
|
-
export declare interface RawQueryResponse<R> {
|
|
2839
|
-
query: string
|
|
2840
|
-
ms: number
|
|
2841
|
-
result: R
|
|
2842
|
-
resultSourceMap?: ContentSourceMap
|
|
2843
|
-
/** Requires `apiVersion` to be `2021-03-25` or later. */
|
|
2844
|
-
syncTags?: SyncTag[]
|
|
2845
|
-
}
|
|
2846
|
-
|
|
2847
|
-
/** @internal */
|
|
2848
|
-
export declare interface RawRequestOptions {
|
|
2849
|
-
url?: string
|
|
2850
|
-
uri?: string
|
|
2851
|
-
method?: string
|
|
2852
|
-
token?: string
|
|
2853
|
-
json?: boolean
|
|
2854
|
-
tag?: string
|
|
2855
|
-
useGlobalApi?: boolean
|
|
2856
|
-
withCredentials?: boolean
|
|
2857
|
-
query?: {
|
|
2858
|
-
[key: string]: string | string[]
|
|
2859
|
-
}
|
|
2860
|
-
headers?: {
|
|
2861
|
-
[key: string]: string
|
|
2862
|
-
}
|
|
2863
|
-
timeout?: number
|
|
2864
|
-
proxy?: string
|
|
2865
|
-
body?: Any
|
|
2866
|
-
maxRedirects?: number
|
|
2867
|
-
signal?: AbortSignal
|
|
2868
|
-
}
|
|
2869
|
-
|
|
2870
|
-
/**
|
|
2871
|
-
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
2872
|
-
*
|
|
2873
|
-
* @public
|
|
2874
|
-
*/
|
|
2875
|
-
export declare type ReconnectEvent = {
|
|
2876
|
-
type: 'reconnect'
|
|
2877
|
-
}
|
|
2878
|
-
|
|
2879
|
-
/**
|
|
2880
|
-
* @public
|
|
2881
|
-
* @deprecated – The `r`-prefix is not required, use `string` instead
|
|
2882
|
-
*/
|
|
2883
|
-
export declare type ReleaseId = `r${string}`
|
|
2884
|
-
|
|
2885
|
-
/**
|
|
2886
|
-
* Replaces an existing draft document.
|
|
2887
|
-
* At least one of the draft or published versions of the document must exist.
|
|
2888
|
-
*
|
|
2889
|
-
* @public
|
|
2890
|
-
*/
|
|
2891
|
-
export declare type ReplaceDraftAction = {
|
|
2892
|
-
actionType: 'sanity.action.document.replaceDraft'
|
|
2893
|
-
/**
|
|
2894
|
-
* Published document ID to create draft from, if draft does not exist
|
|
2895
|
-
*/
|
|
2896
|
-
publishedId: string
|
|
2897
|
-
/**
|
|
2898
|
-
* Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
|
2899
|
-
*/
|
|
2900
|
-
attributes: IdentifiedSanityDocumentStub
|
|
2901
|
-
}
|
|
2902
|
-
|
|
2903
|
-
/** @public */
|
|
2904
|
-
export declare const requester: Requester
|
|
2905
|
-
|
|
2906
|
-
/** @internal */
|
|
2907
|
-
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
2908
|
-
url?: string
|
|
2909
|
-
uri?: string
|
|
2910
|
-
canUseCdn?: boolean
|
|
2911
|
-
useCdn?: boolean
|
|
2912
|
-
tag?: string
|
|
2913
|
-
returnQuery?: boolean
|
|
2914
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2915
|
-
perspective?: ClientPerspective
|
|
2916
|
-
lastLiveEventId?: string
|
|
2917
|
-
cacheMode?: 'noStale'
|
|
2918
|
-
}
|
|
2919
|
-
|
|
2920
|
-
/** @public */
|
|
2921
|
-
export declare interface RequestOptions {
|
|
2922
|
-
timeout?: number
|
|
2923
|
-
token?: string
|
|
2924
|
-
tag?: string
|
|
2925
|
-
headers?: Record<string, string>
|
|
2926
|
-
method?: string
|
|
2927
|
-
query?: Any
|
|
2928
|
-
body?: Any
|
|
2929
|
-
signal?: AbortSignal
|
|
2930
|
-
}
|
|
2931
|
-
|
|
2932
|
-
export {ResolveStudioUrl}
|
|
2933
|
-
|
|
2934
|
-
/** @public */
|
|
2935
|
-
export declare interface ResponseEvent<T = unknown> {
|
|
2936
|
-
type: 'response'
|
|
2937
|
-
body: T
|
|
2938
|
-
url: string
|
|
2939
|
-
method: string
|
|
2940
|
-
statusCode: number
|
|
2941
|
-
statusMessage?: string
|
|
2942
|
-
headers: Record<string, string>
|
|
2943
|
-
}
|
|
2944
|
-
|
|
2945
|
-
/** @public */
|
|
2946
|
-
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
2947
|
-
perspective?: ClientPerspective
|
|
2948
|
-
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2949
|
-
returnQuery?: boolean
|
|
2950
|
-
useCdn?: boolean
|
|
2951
|
-
stega?: boolean | StegaConfig
|
|
2952
|
-
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2953
|
-
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2954
|
-
lastLiveEventId?: string | string[] | null
|
|
2955
|
-
/**
|
|
2956
|
-
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
2957
|
-
* Tradeoff between latency and freshness of content.
|
|
2958
|
-
*
|
|
2959
|
-
* Only to be used with live content queries and when useCdn is true.
|
|
2960
|
-
*/
|
|
2961
|
-
cacheMode?: 'noStale'
|
|
2962
|
-
}
|
|
2963
|
-
|
|
2964
|
-
/** @internal */
|
|
2965
|
-
export declare interface SanityAssetDocument extends SanityDocument {
|
|
2966
|
-
url: string
|
|
2967
|
-
path: string
|
|
2968
|
-
size: number
|
|
2969
|
-
assetId: string
|
|
2970
|
-
mimeType: string
|
|
2971
|
-
sha1hash: string
|
|
2972
|
-
extension: string
|
|
2973
|
-
uploadId?: string
|
|
2974
|
-
originalFilename?: string
|
|
2975
|
-
}
|
|
2976
|
-
|
|
2977
|
-
/** @public */
|
|
2978
|
-
export declare class SanityClient implements SanityClientType {
|
|
2979
|
-
#private
|
|
2980
|
-
assets: AssetsClient
|
|
2981
|
-
datasets: DatasetsClient
|
|
2982
|
-
live: LiveClient
|
|
2983
|
-
projects: ProjectsClient
|
|
2984
|
-
users: UsersClient
|
|
2985
|
-
/**
|
|
2986
|
-
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2987
|
-
*/
|
|
2988
|
-
observable: ObservableSanityClient
|
|
2989
|
-
listen: typeof _listen
|
|
2990
|
-
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
2991
|
-
/**
|
|
2992
|
-
* Clone the client - returns a new instance
|
|
2993
|
-
*/
|
|
2994
|
-
clone(): SanityClient
|
|
2995
|
-
/**
|
|
2996
|
-
* Returns the current client configuration
|
|
2997
|
-
*/
|
|
2998
|
-
config(): InitializedClientConfig
|
|
2999
|
-
/**
|
|
3000
|
-
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
3001
|
-
*/
|
|
3002
|
-
config(newConfig?: Partial<ClientConfig>): this
|
|
3003
|
-
/**
|
|
3004
|
-
* Clone the client with a new (partial) configuration.
|
|
3005
|
-
*
|
|
3006
|
-
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
3007
|
-
*/
|
|
3008
|
-
withConfig(newConfig?: Partial<ClientConfig>): SanityClient
|
|
3009
|
-
/**
|
|
3010
|
-
* Perform a GROQ-query against the configured dataset.
|
|
3011
|
-
*
|
|
3012
|
-
* @param query - GROQ-query to perform
|
|
3013
|
-
*/
|
|
3014
|
-
fetch<
|
|
3015
|
-
R = Any,
|
|
3016
|
-
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
3017
|
-
const G extends string = string,
|
|
3018
|
-
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
3019
|
-
/**
|
|
3020
|
-
* Perform a GROQ-query against the configured dataset.
|
|
3021
|
-
*
|
|
3022
|
-
* @param query - GROQ-query to perform
|
|
3023
|
-
* @param params - Optional query parameters
|
|
3024
|
-
* @param options - Optional request options
|
|
3025
|
-
*/
|
|
3026
|
-
fetch<
|
|
3027
|
-
R = Any,
|
|
3028
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
3029
|
-
const G extends string = string,
|
|
3030
|
-
>(
|
|
3031
|
-
query: G,
|
|
3032
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
3033
|
-
options?: FilteredResponseQueryOptions,
|
|
3034
|
-
): Promise<ClientReturn<G, R>>
|
|
3035
|
-
/**
|
|
3036
|
-
* Perform a GROQ-query against the configured dataset.
|
|
3037
|
-
*
|
|
3038
|
-
* @param query - GROQ-query to perform
|
|
3039
|
-
* @param params - Optional query parameters
|
|
3040
|
-
* @param options - Request options
|
|
3041
|
-
*/
|
|
3042
|
-
fetch<
|
|
3043
|
-
R = Any,
|
|
3044
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
3045
|
-
const G extends string = string,
|
|
3046
|
-
>(
|
|
3047
|
-
query: G,
|
|
3048
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
3049
|
-
options: UnfilteredResponseQueryOptions,
|
|
3050
|
-
): Promise<RawQueryResponse<ClientReturn<G, R>>>
|
|
3051
|
-
/**
|
|
3052
|
-
* Perform a GROQ-query against the configured dataset.
|
|
3053
|
-
*
|
|
3054
|
-
* @param query - GROQ-query to perform
|
|
3055
|
-
* @param params - Optional query parameters
|
|
3056
|
-
* @param options - Request options
|
|
3057
|
-
*/
|
|
3058
|
-
fetch<
|
|
3059
|
-
R = Any,
|
|
3060
|
-
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
3061
|
-
const G extends string = string,
|
|
3062
|
-
>(
|
|
3063
|
-
query: G,
|
|
3064
|
-
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
3065
|
-
options: UnfilteredResponseWithoutQuery,
|
|
3066
|
-
): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
3067
|
-
/**
|
|
3068
|
-
* Fetch a single document with the given ID.
|
|
3069
|
-
*
|
|
3070
|
-
* @param id - Document ID to fetch
|
|
3071
|
-
* @param options - Request options
|
|
3072
|
-
*/
|
|
3073
|
-
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
3074
|
-
id: string,
|
|
3075
|
-
options?: {
|
|
3076
|
-
signal?: AbortSignal
|
|
3077
|
-
tag?: string
|
|
3078
|
-
},
|
|
3079
|
-
): Promise<SanityDocument<R> | undefined>
|
|
3080
|
-
/**
|
|
3081
|
-
* Fetch multiple documents in one request.
|
|
3082
|
-
* Should be used sparingly - performing a query is usually a better option.
|
|
3083
|
-
* The order/position of documents is preserved based on the original array of IDs.
|
|
3084
|
-
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
3085
|
-
*
|
|
3086
|
-
* @param ids - Document IDs to fetch
|
|
3087
|
-
* @param options - Request options
|
|
3088
|
-
*/
|
|
3089
|
-
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
3090
|
-
ids: string[],
|
|
3091
|
-
options?: {
|
|
3092
|
-
signal?: AbortSignal
|
|
3093
|
-
tag?: string
|
|
3094
|
-
},
|
|
3095
|
-
): Promise<(SanityDocument<R> | null)[]>
|
|
3096
|
-
/**
|
|
3097
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3098
|
-
* Returns a promise that resolves to the created document.
|
|
3099
|
-
*
|
|
3100
|
-
* @param document - Document to create
|
|
3101
|
-
* @param options - Mutation options
|
|
3102
|
-
*/
|
|
3103
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3104
|
-
document: SanityDocumentStub<R>,
|
|
3105
|
-
options: FirstDocumentMutationOptions,
|
|
3106
|
-
): Promise<SanityDocument<R>>
|
|
3107
|
-
/**
|
|
3108
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3109
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
3110
|
-
*
|
|
3111
|
-
* @param document - Document to create
|
|
3112
|
-
* @param options - Mutation options
|
|
3113
|
-
*/
|
|
3114
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3115
|
-
document: SanityDocumentStub<R>,
|
|
3116
|
-
options: AllDocumentsMutationOptions,
|
|
3117
|
-
): Promise<SanityDocument<R>[]>
|
|
3118
|
-
/**
|
|
3119
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3120
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3121
|
-
*
|
|
3122
|
-
* @param document - Document to create
|
|
3123
|
-
* @param options - Mutation options
|
|
3124
|
-
*/
|
|
3125
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3126
|
-
document: SanityDocumentStub<R>,
|
|
3127
|
-
options: FirstDocumentIdMutationOptions,
|
|
3128
|
-
): Promise<SingleMutationResult>
|
|
3129
|
-
/**
|
|
3130
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3131
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3132
|
-
*
|
|
3133
|
-
* @param document - Document to create
|
|
3134
|
-
* @param options - Mutation options
|
|
3135
|
-
*/
|
|
3136
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3137
|
-
document: SanityDocumentStub<R>,
|
|
3138
|
-
options: AllDocumentIdsMutationOptions,
|
|
3139
|
-
): Promise<MultipleMutationResult>
|
|
3140
|
-
/**
|
|
3141
|
-
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
3142
|
-
* Returns a promise that resolves to the created document.
|
|
3143
|
-
*
|
|
3144
|
-
* @param document - Document to create
|
|
3145
|
-
* @param options - Mutation options
|
|
3146
|
-
*/
|
|
3147
|
-
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
3148
|
-
document: SanityDocumentStub<R>,
|
|
3149
|
-
options?: BaseMutationOptions,
|
|
3150
|
-
): Promise<SanityDocument<R>>
|
|
3151
|
-
/**
|
|
3152
|
-
* Create a document if no document with the same ID already exists.
|
|
3153
|
-
* Returns a promise that resolves to the created document.
|
|
3154
|
-
*
|
|
3155
|
-
* @param document - Document to create
|
|
3156
|
-
* @param options - Mutation options
|
|
3157
|
-
*/
|
|
3158
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3159
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3160
|
-
options: FirstDocumentMutationOptions,
|
|
3161
|
-
): Promise<SanityDocument<R>>
|
|
3162
|
-
/**
|
|
3163
|
-
* Create a document if no document with the same ID already exists.
|
|
3164
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
3165
|
-
*
|
|
3166
|
-
* @param document - Document to create
|
|
3167
|
-
* @param options - Mutation options
|
|
3168
|
-
*/
|
|
3169
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3170
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3171
|
-
options: AllDocumentsMutationOptions,
|
|
3172
|
-
): Promise<SanityDocument<R>[]>
|
|
3173
|
-
/**
|
|
3174
|
-
* Create a document if no document with the same ID already exists.
|
|
3175
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3176
|
-
*
|
|
3177
|
-
* @param document - Document to create
|
|
3178
|
-
* @param options - Mutation options
|
|
3179
|
-
*/
|
|
3180
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3181
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3182
|
-
options: FirstDocumentIdMutationOptions,
|
|
3183
|
-
): Promise<SingleMutationResult>
|
|
3184
|
-
/**
|
|
3185
|
-
* Create a document if no document with the same ID already exists.
|
|
3186
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3187
|
-
*
|
|
3188
|
-
* @param document - Document to create
|
|
3189
|
-
* @param options - Mutation options
|
|
3190
|
-
*/
|
|
3191
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3192
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3193
|
-
options: AllDocumentIdsMutationOptions,
|
|
3194
|
-
): Promise<MultipleMutationResult>
|
|
3195
|
-
/**
|
|
3196
|
-
* Create a document if no document with the same ID already exists.
|
|
3197
|
-
* Returns a promise that resolves to the created document.
|
|
3198
|
-
*
|
|
3199
|
-
* @param document - Document to create
|
|
3200
|
-
* @param options - Mutation options
|
|
3201
|
-
*/
|
|
3202
|
-
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
3203
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3204
|
-
options?: BaseMutationOptions,
|
|
3205
|
-
): Promise<SanityDocument<R>>
|
|
3206
|
-
/**
|
|
3207
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3208
|
-
* Returns a promise that resolves to the created document.
|
|
3209
|
-
*
|
|
3210
|
-
* @param document - Document to either create or replace
|
|
3211
|
-
* @param options - Mutation options
|
|
3212
|
-
*/
|
|
3213
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3214
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3215
|
-
options: FirstDocumentMutationOptions,
|
|
3216
|
-
): Promise<SanityDocument<R>>
|
|
3217
|
-
/**
|
|
3218
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3219
|
-
* Returns a promise that resolves to an array containing the created document.
|
|
3220
|
-
*
|
|
3221
|
-
* @param document - Document to either create or replace
|
|
3222
|
-
* @param options - Mutation options
|
|
3223
|
-
*/
|
|
3224
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3225
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3226
|
-
options: AllDocumentsMutationOptions,
|
|
3227
|
-
): Promise<SanityDocument<R>[]>
|
|
3228
|
-
/**
|
|
3229
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3230
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
3231
|
-
*
|
|
3232
|
-
* @param document - Document to either create or replace
|
|
3233
|
-
* @param options - Mutation options
|
|
3234
|
-
*/
|
|
3235
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3236
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3237
|
-
options: FirstDocumentIdMutationOptions,
|
|
3238
|
-
): Promise<SingleMutationResult>
|
|
3239
|
-
/**
|
|
3240
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3241
|
-
* Returns a promise that resolves to a mutation result object containing the created document ID.
|
|
3242
|
-
*
|
|
3243
|
-
* @param document - Document to either create or replace
|
|
3244
|
-
* @param options - Mutation options
|
|
3245
|
-
*/
|
|
3246
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3247
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3248
|
-
options: AllDocumentIdsMutationOptions,
|
|
3249
|
-
): Promise<MultipleMutationResult>
|
|
3250
|
-
/**
|
|
3251
|
-
* Create a document if it does not exist, or replace a document with the same document ID
|
|
3252
|
-
* Returns a promise that resolves to the created document.
|
|
3253
|
-
*
|
|
3254
|
-
* @param document - Document to either create or replace
|
|
3255
|
-
* @param options - Mutation options
|
|
3256
|
-
*/
|
|
3257
|
-
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
3258
|
-
document: IdentifiedSanityDocumentStub<R>,
|
|
3259
|
-
options?: BaseMutationOptions,
|
|
3260
|
-
): Promise<SanityDocument<R>>
|
|
3261
|
-
/**
|
|
3262
|
-
* Deletes a document with the given document ID.
|
|
3263
|
-
* Returns a promise that resolves to the deleted document.
|
|
3264
|
-
*
|
|
3265
|
-
* @param id - Document ID to delete
|
|
3266
|
-
* @param options - Options for the mutation
|
|
3267
|
-
*/
|
|
3268
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3269
|
-
id: string,
|
|
3270
|
-
options: FirstDocumentMutationOptions,
|
|
3271
|
-
): Promise<SanityDocument<R>>
|
|
3272
|
-
/**
|
|
3273
|
-
* Deletes a document with the given document ID.
|
|
3274
|
-
* Returns a promise that resolves to an array containing the deleted document.
|
|
3275
|
-
*
|
|
3276
|
-
* @param id - Document ID to delete
|
|
3277
|
-
* @param options - Options for the mutation
|
|
3278
|
-
*/
|
|
3279
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3280
|
-
id: string,
|
|
3281
|
-
options: AllDocumentsMutationOptions,
|
|
3282
|
-
): Promise<SanityDocument<R>[]>
|
|
3283
|
-
/**
|
|
3284
|
-
* Deletes a document with the given document ID.
|
|
3285
|
-
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
3286
|
-
*
|
|
3287
|
-
* @param id - Document ID to delete
|
|
3288
|
-
* @param options - Options for the mutation
|
|
3289
|
-
*/
|
|
3290
|
-
delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
3291
|
-
/**
|
|
3292
|
-
* Deletes a document with the given document ID.
|
|
3293
|
-
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
3294
|
-
*
|
|
3295
|
-
* @param id - Document ID to delete
|
|
3296
|
-
* @param options - Options for the mutation
|
|
3297
|
-
*/
|
|
3298
|
-
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
3299
|
-
/**
|
|
3300
|
-
* Deletes a document with the given document ID.
|
|
3301
|
-
* Returns a promise that resolves to the deleted document.
|
|
3302
|
-
*
|
|
3303
|
-
* @param id - Document ID to delete
|
|
3304
|
-
* @param options - Options for the mutation
|
|
3305
|
-
*/
|
|
3306
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3307
|
-
id: string,
|
|
3308
|
-
options?: BaseMutationOptions,
|
|
3309
|
-
): Promise<SanityDocument<R>>
|
|
3310
|
-
/**
|
|
3311
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
3312
|
-
* Returns a promise that resolves to first deleted document.
|
|
3313
|
-
*
|
|
3314
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3315
|
-
* @param options - Options for the mutation
|
|
3316
|
-
*/
|
|
3317
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3318
|
-
selection: MutationSelection,
|
|
3319
|
-
options: FirstDocumentMutationOptions,
|
|
3320
|
-
): Promise<SanityDocument<R>>
|
|
3321
|
-
/**
|
|
3322
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
3323
|
-
* Returns a promise that resolves to an array containing the deleted documents.
|
|
3324
|
-
*
|
|
3325
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3326
|
-
* @param options - Options for the mutation
|
|
3327
|
-
*/
|
|
3328
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3329
|
-
selection: MutationSelection,
|
|
3330
|
-
options: AllDocumentsMutationOptions,
|
|
3331
|
-
): Promise<SanityDocument<R>[]>
|
|
3332
|
-
/**
|
|
3333
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
3334
|
-
* Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
|
|
3335
|
-
*
|
|
3336
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3337
|
-
* @param options - Options for the mutation
|
|
3338
|
-
*/
|
|
3339
|
-
delete(
|
|
3340
|
-
selection: MutationSelection,
|
|
3341
|
-
options: FirstDocumentIdMutationOptions,
|
|
3342
|
-
): Promise<SingleMutationResult>
|
|
3343
|
-
/**
|
|
3344
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
3345
|
-
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
3346
|
-
*
|
|
3347
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3348
|
-
* @param options - Options for the mutation
|
|
3349
|
-
*/
|
|
3350
|
-
delete(
|
|
3351
|
-
selection: MutationSelection,
|
|
3352
|
-
options: AllDocumentIdsMutationOptions,
|
|
3353
|
-
): Promise<MultipleMutationResult>
|
|
3354
|
-
/**
|
|
3355
|
-
* Deletes one or more documents matching the given query or document ID.
|
|
3356
|
-
* Returns a promise that resolves to first deleted document.
|
|
3357
|
-
*
|
|
3358
|
-
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
3359
|
-
* @param options - Options for the mutation
|
|
3360
|
-
*/
|
|
3361
|
-
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
3362
|
-
selection: MutationSelection,
|
|
3363
|
-
options?: BaseMutationOptions,
|
|
3364
|
-
): Promise<SanityDocument<R>>
|
|
3365
|
-
/**
|
|
3366
|
-
* Perform mutation operations against the configured dataset
|
|
3367
|
-
* Returns a promise that resolves to the first mutated document.
|
|
3368
|
-
*
|
|
3369
|
-
* @param operations - Mutation operations to execute
|
|
3370
|
-
* @param options - Mutation options
|
|
3371
|
-
*/
|
|
3372
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3373
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
3374
|
-
options: FirstDocumentMutationOptions,
|
|
3375
|
-
): Promise<SanityDocument<R>>
|
|
3376
|
-
/**
|
|
3377
|
-
* Perform mutation operations against the configured dataset.
|
|
3378
|
-
* Returns a promise that resolves to an array of the mutated documents.
|
|
3379
|
-
*
|
|
3380
|
-
* @param operations - Mutation operations to execute
|
|
3381
|
-
* @param options - Mutation options
|
|
3382
|
-
*/
|
|
3383
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3384
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
3385
|
-
options: AllDocumentsMutationOptions,
|
|
3386
|
-
): Promise<SanityDocument<R>[]>
|
|
3387
|
-
/**
|
|
3388
|
-
* Perform mutation operations against the configured dataset
|
|
3389
|
-
* Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
3390
|
-
*
|
|
3391
|
-
* @param operations - Mutation operations to execute
|
|
3392
|
-
* @param options - Mutation options
|
|
3393
|
-
*/
|
|
3394
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3395
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
3396
|
-
options: FirstDocumentIdMutationOptions,
|
|
3397
|
-
): Promise<SingleMutationResult>
|
|
3398
|
-
/**
|
|
3399
|
-
* Perform mutation operations against the configured dataset
|
|
3400
|
-
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
3401
|
-
*
|
|
3402
|
-
* @param operations - Mutation operations to execute
|
|
3403
|
-
* @param options - Mutation options
|
|
3404
|
-
*/
|
|
3405
|
-
mutate<R extends Record<string, Any>>(
|
|
3406
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
3407
|
-
options: AllDocumentIdsMutationOptions,
|
|
3408
|
-
): Promise<MultipleMutationResult>
|
|
3409
|
-
/**
|
|
3410
|
-
* Perform mutation operations against the configured dataset
|
|
3411
|
-
* Returns a promise that resolves to the first mutated document.
|
|
3412
|
-
*
|
|
3413
|
-
* @param operations - Mutation operations to execute
|
|
3414
|
-
* @param options - Mutation options
|
|
3415
|
-
*/
|
|
3416
|
-
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
3417
|
-
operations: Mutation<R>[] | Patch | Transaction,
|
|
2747
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
3418
2748
|
options?: BaseMutationOptions,
|
|
3419
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)
|
|
3420
2798
|
/**
|
|
3421
|
-
*
|
|
3422
|
-
*
|
|
3423
|
-
* @param documentId - Document ID to patch
|
|
3424
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3425
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3426
|
-
*/
|
|
3427
|
-
patch(documentId: string, operations?: PatchOperations): Patch
|
|
3428
|
-
/**
|
|
3429
|
-
* Create a new buildable patch of operations to perform
|
|
3430
|
-
*
|
|
3431
|
-
* @param documentIds - Array of document IDs to patch
|
|
3432
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3433
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3434
|
-
*/
|
|
3435
|
-
patch(documentIds: string[], operations?: PatchOperations): Patch
|
|
3436
|
-
/**
|
|
3437
|
-
* Create a new buildable patch of operations to perform
|
|
3438
|
-
*
|
|
3439
|
-
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
3440
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3441
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3442
|
-
*/
|
|
3443
|
-
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
3444
|
-
/**
|
|
3445
|
-
* Create a new transaction of mutations
|
|
2799
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
3446
2800
|
*
|
|
3447
|
-
* @param
|
|
2801
|
+
* @param options - Options for the list request
|
|
2802
|
+
* - `includeMembers` - Whether to include members in the response (default: true)
|
|
3448
2803
|
*/
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
): Transaction
|
|
2804
|
+
list(options?: {includeMembers?: true}): Promise<SanityProject[]>
|
|
2805
|
+
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
3452
2806
|
/**
|
|
3453
|
-
*
|
|
3454
|
-
* Returns a promise that resolves to the transaction result
|
|
2807
|
+
* Fetch a project by project ID
|
|
3455
2808
|
*
|
|
3456
|
-
* @param
|
|
3457
|
-
* @param options - Action options
|
|
2809
|
+
* @param projectId - ID of the project to fetch
|
|
3458
2810
|
*/
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
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'
|
|
3463
2825
|
/**
|
|
3464
|
-
*
|
|
3465
|
-
* NOTE: Only use this for Sanity API endpoints, not for your own APIs!
|
|
3466
|
-
*
|
|
3467
|
-
* @param options - Request options
|
|
3468
|
-
* @returns Promise resolving to the response body
|
|
2826
|
+
* Draft document ID to publish
|
|
3469
2827
|
*/
|
|
3470
|
-
|
|
2828
|
+
draftId: string
|
|
3471
2829
|
/**
|
|
3472
|
-
*
|
|
3473
|
-
* NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
|
|
3474
|
-
*
|
|
3475
|
-
* @deprecated - Use `request()` or your own HTTP library instead
|
|
3476
|
-
* @param endpoint - Endpoint to hit (mutate, query etc)
|
|
3477
|
-
* @param body - Request body
|
|
3478
|
-
* @param options - Request options
|
|
3479
|
-
* @internal
|
|
2830
|
+
* Draft revision ID to match
|
|
3480
2831
|
*/
|
|
3481
|
-
|
|
2832
|
+
ifDraftRevisionId?: string
|
|
3482
2833
|
/**
|
|
3483
|
-
*
|
|
3484
|
-
*
|
|
3485
|
-
* @param uri - URI/path to build URL for
|
|
3486
|
-
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2834
|
+
* Published document ID to replace
|
|
3487
2835
|
*/
|
|
3488
|
-
|
|
2836
|
+
publishedId: string
|
|
3489
2837
|
/**
|
|
3490
|
-
*
|
|
3491
|
-
*
|
|
3492
|
-
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
3493
|
-
* @param path - Path to append after the operation
|
|
2838
|
+
* Published revision ID to match
|
|
3494
2839
|
*/
|
|
3495
|
-
|
|
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
|
|
3496
2930
|
}
|
|
3497
2931
|
|
|
3498
2932
|
/**
|
|
3499
|
-
*
|
|
3500
|
-
*
|
|
2933
|
+
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
2934
|
+
*
|
|
2935
|
+
* @public
|
|
3501
2936
|
*/
|
|
3502
|
-
declare
|
|
3503
|
-
|
|
3504
|
-
|
|
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'
|
|
3505
2955
|
/**
|
|
3506
|
-
*
|
|
3507
|
-
*
|
|
3508
|
-
* @param uri - URI/path to build URL for
|
|
3509
|
-
* @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
|
|
3510
2957
|
*/
|
|
3511
|
-
|
|
2958
|
+
publishedId: string
|
|
3512
2959
|
/**
|
|
3513
|
-
*
|
|
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.
|
|
3514
3020
|
*
|
|
3515
|
-
*
|
|
3516
|
-
* @param path - Path to append after the operation
|
|
3021
|
+
* Only to be used with live content queries and when useCdn is true.
|
|
3517
3022
|
*/
|
|
3518
|
-
|
|
3023
|
+
cacheMode?: 'noStale'
|
|
3519
3024
|
}
|
|
3520
3025
|
|
|
3521
|
-
/**
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
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
|
|
3529
3042
|
assets: AssetsClient
|
|
3530
3043
|
datasets: DatasetsClient
|
|
3044
|
+
live: LiveClient
|
|
3531
3045
|
projects: ProjectsClient
|
|
3532
3046
|
users: UsersClient
|
|
3047
|
+
agent: {
|
|
3048
|
+
action: AgentActionsClient
|
|
3049
|
+
}
|
|
3533
3050
|
/**
|
|
3534
3051
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
3535
3052
|
*/
|
|
3536
|
-
observable:
|
|
3053
|
+
observable: ObservableSanityClient
|
|
3054
|
+
/**
|
|
3055
|
+
* Instance properties
|
|
3056
|
+
*/
|
|
3057
|
+
listen: typeof _listen
|
|
3058
|
+
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
3537
3059
|
/**
|
|
3538
3060
|
* Clone the client - returns a new instance
|
|
3539
3061
|
*/
|
|
3540
|
-
clone():
|
|
3062
|
+
clone(): SanityClient
|
|
3541
3063
|
/**
|
|
3542
3064
|
* Returns the current client configuration
|
|
3543
3065
|
*/
|
|
@@ -3545,13 +3067,13 @@ export declare interface SanityClientType extends SanityClientBase {
|
|
|
3545
3067
|
/**
|
|
3546
3068
|
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
3547
3069
|
*/
|
|
3548
|
-
config(newConfig?: Partial<ClientConfig>):
|
|
3070
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
3549
3071
|
/**
|
|
3550
3072
|
* Clone the client with a new (partial) configuration.
|
|
3551
3073
|
*
|
|
3552
3074
|
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
3553
3075
|
*/
|
|
3554
|
-
withConfig(newConfig?: Partial<ClientConfig>):
|
|
3076
|
+
withConfig(newConfig?: Partial<ClientConfig>): SanityClient
|
|
3555
3077
|
/**
|
|
3556
3078
|
* Perform a GROQ-query against the configured dataset.
|
|
3557
3079
|
*
|
|
@@ -3561,10 +3083,7 @@ export declare interface SanityClientType extends SanityClientBase {
|
|
|
3561
3083
|
R = Any,
|
|
3562
3084
|
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
3563
3085
|
const G extends string = string,
|
|
3564
|
-
>(
|
|
3565
|
-
query: G,
|
|
3566
|
-
params?: Q | QueryWithoutParams,
|
|
3567
|
-
): Promise<ClientReturn<G, R>>
|
|
3086
|
+
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
3568
3087
|
/**
|
|
3569
3088
|
* Perform a GROQ-query against the configured dataset.
|
|
3570
3089
|
*
|
|
@@ -3990,14 +3509,6 @@ export declare interface SanityClientType extends SanityClientBase {
|
|
|
3990
3509
|
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3991
3510
|
*/
|
|
3992
3511
|
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
3993
|
-
/**
|
|
3994
|
-
* Create a new buildable patch of operations to perform
|
|
3995
|
-
*
|
|
3996
|
-
* @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch
|
|
3997
|
-
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
3998
|
-
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
3999
|
-
*/
|
|
4000
|
-
patch(selection: PatchSelection, operations?: PatchOperations): Patch
|
|
4001
3512
|
/**
|
|
4002
3513
|
* Create a new transaction of mutations
|
|
4003
3514
|
*
|
|
@@ -4036,6 +3547,20 @@ export declare interface SanityClientType extends SanityClientBase {
|
|
|
4036
3547
|
* @internal
|
|
4037
3548
|
*/
|
|
4038
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
|
|
4039
3564
|
}
|
|
4040
3565
|
|
|
4041
3566
|
/** @internal */
|
|
@@ -4336,6 +3861,309 @@ export declare type TransactionMutationOptions =
|
|
|
4336
3861
|
| TransactionAllDocumentsMutationOptions
|
|
4337
3862
|
| TransactionAllDocumentIdsMutationOptions
|
|
4338
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
|
+
|
|
4339
4167
|
/** @public */
|
|
4340
4168
|
export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
4341
4169
|
filterResponse: false
|