@sanity/client 6.24.2 → 6.24.4
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/csm.d.cts +99 -34
- package/dist/csm.d.ts +99 -34
- package/dist/index.browser.cjs +188 -128
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +112 -4
- package/dist/index.browser.d.ts +112 -4
- package/dist/index.browser.js +189 -129
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +189 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +112 -4
- package/dist/index.d.ts +112 -4
- package/dist/index.js +190 -130
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +3419 -96
- package/dist/stega.browser.d.ts +3419 -96
- package/dist/stega.d.cts +3419 -96
- package/dist/stega.d.ts +3419 -96
- package/package.json +4 -4
- package/src/data/eventsource.ts +255 -0
- package/src/data/eventsourcePolyfill.ts +7 -0
- package/src/data/listen.ts +31 -142
- package/src/data/live.ts +60 -120
- package/src/data/reconnectOnConnectionFailure.ts +30 -0
- package/src/data/transaction.ts +26 -1
- package/src/defineCreateClient.ts +11 -0
- package/src/types.ts +10 -0
- package/umd/sanityClient.js +988 -144
- package/umd/sanityClient.min.js +2 -2
package/dist/stega.browser.d.cts
CHANGED
|
@@ -1,17 +1,411 @@
|
|
|
1
|
-
import {ClientConfig} from '@sanity/client'
|
|
2
|
-
import
|
|
3
|
-
import type {ContentSourceMapDocuments} from '@sanity/client/csm'
|
|
4
|
-
import {ContentSourceMapParsedPath} from '@sanity/client/csm'
|
|
5
|
-
import {ContentSourceMapParsedPathKeyedSegment} from '@sanity/client/csm'
|
|
6
|
-
import type {InitializedClientConfig} from '@sanity/client'
|
|
7
|
-
import {ObservableSanityClient} from '@sanity/client'
|
|
8
|
-
import type {RawQueryResponse} from '@sanity/client'
|
|
1
|
+
import {ClientConfig as ClientConfig_2} from '@sanity/client'
|
|
2
|
+
import {Observable} from 'rxjs'
|
|
9
3
|
import {Requester} from 'get-it'
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
import {adapter as unstable__adapter} from 'get-it'
|
|
5
|
+
import {environment as unstable__environment} from 'get-it'
|
|
6
|
+
|
|
7
|
+
/** @public */
|
|
8
|
+
export declare type Action =
|
|
9
|
+
| CreateAction
|
|
10
|
+
| ReplaceDraftAction
|
|
11
|
+
| EditAction
|
|
12
|
+
| DeleteAction
|
|
13
|
+
| DiscardAction
|
|
14
|
+
| PublishAction
|
|
15
|
+
| UnpublishAction
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
export declare interface ActionError {
|
|
19
|
+
error: {
|
|
20
|
+
type: 'actionError'
|
|
21
|
+
description: string
|
|
22
|
+
items?: ActionErrorItem[]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @internal */
|
|
27
|
+
export declare interface ActionErrorItem {
|
|
28
|
+
error: {
|
|
29
|
+
type: string
|
|
30
|
+
description: string
|
|
31
|
+
value?: unknown
|
|
32
|
+
}
|
|
33
|
+
index: number
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** @internal */
|
|
37
|
+
export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
38
|
+
returnFirst: false
|
|
39
|
+
returnDocuments: false
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @internal */
|
|
43
|
+
export declare type AllDocumentsMutationOptions = BaseMutationOptions & {
|
|
44
|
+
returnFirst: false
|
|
45
|
+
returnDocuments?: true
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export declare type Any = any
|
|
53
|
+
|
|
54
|
+
/** @internal */
|
|
55
|
+
export declare interface ApiError {
|
|
56
|
+
error: string
|
|
57
|
+
message: string
|
|
58
|
+
statusCode: number
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** @public */
|
|
62
|
+
export declare type AssetMetadataType =
|
|
63
|
+
| 'location'
|
|
64
|
+
| 'exif'
|
|
65
|
+
| 'image'
|
|
66
|
+
| 'palette'
|
|
67
|
+
| 'lqip'
|
|
68
|
+
| 'blurhash'
|
|
69
|
+
| 'none'
|
|
70
|
+
|
|
71
|
+
/** @internal */
|
|
72
|
+
export declare class AssetsClient {
|
|
73
|
+
#private
|
|
74
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
75
|
+
/**
|
|
76
|
+
* Uploads a file asset to the configured dataset
|
|
77
|
+
*
|
|
78
|
+
* @param assetType - Asset type (file)
|
|
79
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
80
|
+
* @param options - Options to use for the upload
|
|
81
|
+
*/
|
|
82
|
+
upload(
|
|
83
|
+
assetType: 'file',
|
|
84
|
+
body: UploadBody,
|
|
85
|
+
options?: UploadClientConfig,
|
|
86
|
+
): Promise<SanityAssetDocument>
|
|
87
|
+
/**
|
|
88
|
+
* Uploads an image asset to the configured dataset
|
|
89
|
+
*
|
|
90
|
+
* @param assetType - Asset type (image)
|
|
91
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
92
|
+
* @param options - Options to use for the upload
|
|
93
|
+
*/
|
|
94
|
+
upload(
|
|
95
|
+
assetType: 'image',
|
|
96
|
+
body: UploadBody,
|
|
97
|
+
options?: UploadClientConfig,
|
|
98
|
+
): Promise<SanityImageAssetDocument>
|
|
99
|
+
/**
|
|
100
|
+
* Uploads a file or an image asset to the configured dataset
|
|
101
|
+
*
|
|
102
|
+
* @param assetType - Asset type (file/image)
|
|
103
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
104
|
+
* @param options - Options to use for the upload
|
|
105
|
+
*/
|
|
106
|
+
upload(
|
|
107
|
+
assetType: 'file' | 'image',
|
|
108
|
+
body: UploadBody,
|
|
109
|
+
options?: UploadClientConfig,
|
|
110
|
+
): Promise<SanityAssetDocument | SanityImageAssetDocument>
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** @internal */
|
|
114
|
+
export declare type AttributeSet = {
|
|
115
|
+
[key: string]: Any
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** @internal */
|
|
119
|
+
export declare interface AuthProvider {
|
|
120
|
+
name: string
|
|
121
|
+
title: string
|
|
122
|
+
url: string
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** @internal */
|
|
126
|
+
export declare type AuthProviderResponse = {
|
|
127
|
+
providers: AuthProvider[]
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** @internal */
|
|
131
|
+
export declare type BaseActionOptions = RequestOptions & {
|
|
132
|
+
transactionId?: string
|
|
133
|
+
skipCrossDatasetReferenceValidation?: boolean
|
|
134
|
+
dryRun?: boolean
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** @internal */
|
|
138
|
+
export declare type BaseMutationOptions = RequestOptions & {
|
|
139
|
+
visibility?: 'sync' | 'async' | 'deferred'
|
|
140
|
+
returnDocuments?: boolean
|
|
141
|
+
returnFirst?: boolean
|
|
142
|
+
dryRun?: boolean
|
|
143
|
+
autoGenerateArrayKeys?: boolean
|
|
144
|
+
skipCrossDatasetReferenceValidation?: boolean
|
|
145
|
+
transactionId?: string
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** @internal */
|
|
149
|
+
export declare class BasePatch {
|
|
150
|
+
protected selection: PatchSelection
|
|
151
|
+
protected operations: PatchOperations
|
|
152
|
+
constructor(selection: PatchSelection, operations?: PatchOperations)
|
|
153
|
+
/**
|
|
154
|
+
* Sets the given attributes to the document. Does NOT merge objects.
|
|
155
|
+
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
156
|
+
*
|
|
157
|
+
* @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
|
|
158
|
+
*/
|
|
159
|
+
set(attrs: AttributeSet): this
|
|
160
|
+
/**
|
|
161
|
+
* Sets the given attributes to the document if they are not currently set. Does NOT merge objects.
|
|
162
|
+
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
163
|
+
*
|
|
164
|
+
* @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
|
|
165
|
+
*/
|
|
166
|
+
setIfMissing(attrs: AttributeSet): this
|
|
167
|
+
/**
|
|
168
|
+
* Performs a "diff-match-patch" operation on the string attributes provided.
|
|
169
|
+
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
170
|
+
*
|
|
171
|
+
* @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "dmp"\}
|
|
172
|
+
*/
|
|
173
|
+
diffMatchPatch(attrs: AttributeSet): this
|
|
174
|
+
/**
|
|
175
|
+
* Unsets the attribute paths provided.
|
|
176
|
+
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
177
|
+
*
|
|
178
|
+
* @param attrs - Attribute paths to unset.
|
|
179
|
+
*/
|
|
180
|
+
unset(attrs: string[]): this
|
|
181
|
+
/**
|
|
182
|
+
* Increment a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.
|
|
183
|
+
*
|
|
184
|
+
* @param attrs - Object of attribute paths to increment, values representing the number to increment by.
|
|
185
|
+
*/
|
|
186
|
+
inc(attrs: {[key: string]: number}): this
|
|
187
|
+
/**
|
|
188
|
+
* Decrement a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.
|
|
189
|
+
*
|
|
190
|
+
* @param attrs - Object of attribute paths to decrement, values representing the number to decrement by.
|
|
191
|
+
*/
|
|
192
|
+
dec(attrs: {[key: string]: number}): this
|
|
193
|
+
/**
|
|
194
|
+
* Provides methods for modifying arrays, by inserting, appending and replacing elements via a JSONPath expression.
|
|
195
|
+
*
|
|
196
|
+
* @param at - Location to insert at, relative to the given selector, or 'replace' the matched path
|
|
197
|
+
* @param selector - JSONPath expression, eg `comments[-1]` or `blocks[_key=="abc123"]`
|
|
198
|
+
* @param items - Array of items to insert/replace
|
|
199
|
+
*/
|
|
200
|
+
insert(at: 'before' | 'after' | 'replace', selector: string, items: Any[]): this
|
|
201
|
+
/**
|
|
202
|
+
* Append the given items to the array at the given JSONPath
|
|
203
|
+
*
|
|
204
|
+
* @param selector - Attribute/path to append to, eg `comments` or `person.hobbies`
|
|
205
|
+
* @param items - Array of items to append to the array
|
|
206
|
+
*/
|
|
207
|
+
append(selector: string, items: Any[]): this
|
|
208
|
+
/**
|
|
209
|
+
* Prepend the given items to the array at the given JSONPath
|
|
210
|
+
*
|
|
211
|
+
* @param selector - Attribute/path to prepend to, eg `comments` or `person.hobbies`
|
|
212
|
+
* @param items - Array of items to prepend to the array
|
|
213
|
+
*/
|
|
214
|
+
prepend(selector: string, items: Any[]): this
|
|
215
|
+
/**
|
|
216
|
+
* Change the contents of an array by removing existing elements and/or adding new elements.
|
|
217
|
+
*
|
|
218
|
+
* @param selector - Attribute or JSONPath expression for array
|
|
219
|
+
* @param start - Index at which to start changing the array (with origin 0). If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end of the array (with origin -1) and will be set to 0 if absolute value is greater than the length of the array.x
|
|
220
|
+
* @param deleteCount - An integer indicating the number of old array elements to remove.
|
|
221
|
+
* @param items - The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array.
|
|
222
|
+
*/
|
|
223
|
+
splice(selector: string, start: number, deleteCount?: number, items?: Any[]): this
|
|
224
|
+
/**
|
|
225
|
+
* Adds a revision clause, preventing the document from being patched if the `_rev` property does not match the given value
|
|
226
|
+
*
|
|
227
|
+
* @param rev - Revision to lock the patch to
|
|
228
|
+
*/
|
|
229
|
+
ifRevisionId(rev: string): this
|
|
230
|
+
/**
|
|
231
|
+
* Return a plain JSON representation of the patch
|
|
232
|
+
*/
|
|
233
|
+
serialize(): PatchMutationOperation
|
|
234
|
+
/**
|
|
235
|
+
* Return a plain JSON representation of the patch
|
|
236
|
+
*/
|
|
237
|
+
toJSON(): PatchMutationOperation
|
|
238
|
+
/**
|
|
239
|
+
* Clears the patch of all operations
|
|
240
|
+
*/
|
|
241
|
+
reset(): this
|
|
242
|
+
protected _assign(op: keyof PatchOperations, props: Any, merge?: boolean): this
|
|
243
|
+
protected _set(op: keyof PatchOperations, props: Any): this
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** @internal */
|
|
247
|
+
export declare class BaseTransaction {
|
|
248
|
+
protected operations: Mutation[]
|
|
249
|
+
protected trxId?: string
|
|
250
|
+
constructor(operations?: Mutation[], transactionId?: string)
|
|
251
|
+
/**
|
|
252
|
+
* Creates a new Sanity document. If `_id` is provided and already exists, the mutation will fail. If no `_id` is given, one will automatically be generated by the database.
|
|
253
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
254
|
+
*
|
|
255
|
+
* @param doc - Document to create. Requires a `_type` property.
|
|
256
|
+
*/
|
|
257
|
+
create<R extends Record<string, Any> = Record<string, Any>>(doc: SanityDocumentStub<R>): this
|
|
258
|
+
/**
|
|
259
|
+
* Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.
|
|
260
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
261
|
+
*
|
|
262
|
+
* @param doc - Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
|
263
|
+
*/
|
|
264
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
265
|
+
doc: IdentifiedSanityDocumentStub<R>,
|
|
266
|
+
): this
|
|
267
|
+
/**
|
|
268
|
+
* Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.
|
|
269
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
270
|
+
*
|
|
271
|
+
* @param doc - Document to create or replace. Requires `_id` and `_type` properties.
|
|
272
|
+
*/
|
|
273
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
274
|
+
doc: IdentifiedSanityDocumentStub<R>,
|
|
275
|
+
): this
|
|
276
|
+
/**
|
|
277
|
+
* Deletes the document with the given document ID
|
|
278
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
279
|
+
*
|
|
280
|
+
* @param documentId - Document ID to delete
|
|
281
|
+
*/
|
|
282
|
+
delete(documentId: string): this
|
|
283
|
+
/**
|
|
284
|
+
* Gets the current transaction ID, if any
|
|
285
|
+
*/
|
|
286
|
+
transactionId(): string | undefined
|
|
287
|
+
/**
|
|
288
|
+
* Set the ID of this transaction.
|
|
289
|
+
*
|
|
290
|
+
* @param id - Transaction ID
|
|
291
|
+
*/
|
|
292
|
+
transactionId(id: string): this
|
|
293
|
+
/**
|
|
294
|
+
* Return a plain JSON representation of the transaction
|
|
295
|
+
*/
|
|
296
|
+
serialize(): Mutation[]
|
|
297
|
+
/**
|
|
298
|
+
* Return a plain JSON representation of the transaction
|
|
299
|
+
*/
|
|
300
|
+
toJSON(): Mutation[]
|
|
301
|
+
/**
|
|
302
|
+
* Clears the transaction of all operations
|
|
303
|
+
*/
|
|
304
|
+
reset(): this
|
|
305
|
+
protected _add(mut: Mutation): this
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* @public
|
|
310
|
+
* The server sent a `channelError` message. Usually indicative of a bad or malformed request
|
|
311
|
+
*/
|
|
312
|
+
export declare class ChannelError extends Error {
|
|
313
|
+
readonly name = 'ChannelError'
|
|
314
|
+
readonly data?: unknown
|
|
315
|
+
constructor(message: string, data: unknown)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* An error occurred. This is different from a network-level error (which will be emitted as 'error').
|
|
320
|
+
* Possible causes are things such as malformed filters, non-existant datasets or similar.
|
|
321
|
+
*
|
|
322
|
+
* @public
|
|
323
|
+
*/
|
|
324
|
+
export declare type ChannelErrorEvent = {
|
|
325
|
+
type: 'channelError'
|
|
326
|
+
message: string
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** @public */
|
|
330
|
+
export declare interface ClientConfig {
|
|
331
|
+
projectId?: string
|
|
332
|
+
dataset?: string
|
|
333
|
+
/** @defaultValue true */
|
|
334
|
+
useCdn?: boolean
|
|
335
|
+
token?: string
|
|
336
|
+
/** @defaultValue 'raw' */
|
|
337
|
+
perspective?: ClientPerspective
|
|
338
|
+
apiHost?: string
|
|
339
|
+
apiVersion?: string
|
|
340
|
+
proxy?: string
|
|
341
|
+
/**
|
|
342
|
+
* Optional request tag prefix for all request tags
|
|
343
|
+
*/
|
|
344
|
+
requestTagPrefix?: string
|
|
345
|
+
ignoreBrowserTokenWarning?: boolean
|
|
346
|
+
withCredentials?: boolean
|
|
347
|
+
allowReconfigure?: boolean
|
|
348
|
+
timeout?: number
|
|
349
|
+
/** Number of retries for requests. Defaults to 5. */
|
|
350
|
+
maxRetries?: number
|
|
351
|
+
/**
|
|
352
|
+
* The amount of time, in milliseconds, to wait before retrying, given an attemptNumber (starting at 0).
|
|
353
|
+
*
|
|
354
|
+
* Defaults to exponential back-off, starting at 100ms, doubling for each attempt, together with random
|
|
355
|
+
* jitter between 0 and 100 milliseconds. More specifically the following algorithm is used:
|
|
356
|
+
*
|
|
357
|
+
* Delay = 100 * 2^attemptNumber + randomNumberBetween0and100
|
|
358
|
+
*/
|
|
359
|
+
retryDelay?: (attemptNumber: number) => number
|
|
360
|
+
/**
|
|
361
|
+
* @deprecated Don't use
|
|
362
|
+
*/
|
|
363
|
+
useProjectHostname?: boolean
|
|
364
|
+
/**
|
|
365
|
+
* @deprecated Don't use
|
|
366
|
+
*/
|
|
367
|
+
requester?: Requester
|
|
368
|
+
/**
|
|
369
|
+
* Adds a `resultSourceMap` key to the API response, with the type `ContentSourceMap`
|
|
370
|
+
*/
|
|
371
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
372
|
+
/**
|
|
373
|
+
*@deprecated set `cache` and `next` options on `client.fetch` instead
|
|
374
|
+
*/
|
|
375
|
+
fetch?:
|
|
376
|
+
| {
|
|
377
|
+
cache?: ResponseQueryOptions['cache']
|
|
378
|
+
next?: ResponseQueryOptions['next']
|
|
379
|
+
}
|
|
380
|
+
| boolean
|
|
381
|
+
/**
|
|
382
|
+
* Options for how, if enabled, Content Source Maps are encoded into query results using steganography
|
|
383
|
+
*/
|
|
384
|
+
stega?: StegaConfig | boolean
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** @public */
|
|
388
|
+
export declare class ClientError extends Error {
|
|
389
|
+
response: ErrorProps['response']
|
|
390
|
+
statusCode: ErrorProps['statusCode']
|
|
391
|
+
responseBody: ErrorProps['responseBody']
|
|
392
|
+
details: ErrorProps['details']
|
|
393
|
+
constructor(res: Any)
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** @public */
|
|
397
|
+
export declare type ClientPerspective =
|
|
398
|
+
| 'previewDrafts'
|
|
399
|
+
| 'published'
|
|
400
|
+
| 'drafts'
|
|
401
|
+
| 'raw'
|
|
402
|
+
| ('published' | 'drafts' | ReleaseId)[]
|
|
403
|
+
|
|
404
|
+
/** @public */
|
|
405
|
+
export declare type ClientReturn<
|
|
406
|
+
GroqString extends string,
|
|
407
|
+
Fallback = Any,
|
|
408
|
+
> = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
|
|
15
409
|
|
|
16
410
|
/**
|
|
17
411
|
* @public
|
|
@@ -19,127 +413,2775 @@ import {StudioUrl} from '@sanity/client/csm'
|
|
|
19
413
|
*/
|
|
20
414
|
export declare interface ClientStegaConfig extends ClientConfig {}
|
|
21
415
|
|
|
22
|
-
|
|
416
|
+
/**
|
|
417
|
+
* Sanity API specific EventSource handler shared between the listen and live APIs
|
|
418
|
+
*
|
|
419
|
+
* Since the `EventSource` API is not provided by all environments, this function enables custom initialization of the EventSource instance
|
|
420
|
+
* for runtimes that requires polyfilling or custom setup logic (e.g. custom HTTP headers)
|
|
421
|
+
* via the passed `initEventSource` function which must return an EventSource instance.
|
|
422
|
+
*
|
|
423
|
+
* Possible errors to be thrown on the returned observable are:
|
|
424
|
+
* - {@link MessageError}
|
|
425
|
+
* - {@link MessageParseError}
|
|
426
|
+
* - {@link ChannelError}
|
|
427
|
+
* - {@link DisconnectError}
|
|
428
|
+
* - {@link ConnectionFailedError}
|
|
429
|
+
*
|
|
430
|
+
* @param initEventSource - A function that returns an EventSource instance or an Observable that resolves to an EventSource instance
|
|
431
|
+
* @param events - an array of named events from the API to listen for.
|
|
432
|
+
*
|
|
433
|
+
* @internal
|
|
434
|
+
*/
|
|
435
|
+
export declare function connectEventSource<EventName extends string>(
|
|
436
|
+
initEventSource: () => EventSourceInstance | Observable<EventSourceInstance>,
|
|
437
|
+
events: EventName[],
|
|
438
|
+
): Observable<ServerSentEvent<EventName>>
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* @public
|
|
442
|
+
* Thrown if the EventSource connection could not be established.
|
|
443
|
+
* Note that ConnectionFailedErrors are rare, and disconnects will normally be handled by the EventSource instance itself and emitted as `reconnect` events.
|
|
444
|
+
*/
|
|
445
|
+
export declare class ConnectionFailedError extends Error {
|
|
446
|
+
readonly name = 'ConnectionFailedError'
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/** @public */
|
|
450
|
+
export declare interface ContentSourceMap {
|
|
451
|
+
mappings: ContentSourceMapMappings
|
|
452
|
+
documents: ContentSourceMapDocuments
|
|
453
|
+
paths: ContentSourceMapPaths
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/** @public */
|
|
457
|
+
declare interface ContentSourceMap_2 {
|
|
458
|
+
mappings: ContentSourceMapMappings_2
|
|
459
|
+
documents: ContentSourceMapDocuments_2
|
|
460
|
+
paths: ContentSourceMapPaths_2
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/** @public */
|
|
464
|
+
export declare interface ContentSourceMapDocument extends ContentSourceMapDocumentBase {
|
|
465
|
+
_projectId?: undefined
|
|
466
|
+
_dataset?: undefined
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/** @public */
|
|
470
|
+
declare interface ContentSourceMapDocument_2 extends ContentSourceMapDocumentBase_2 {
|
|
471
|
+
_projectId?: undefined
|
|
472
|
+
_dataset?: undefined
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/** @public */
|
|
476
|
+
export declare interface ContentSourceMapDocumentBase {
|
|
477
|
+
_id: string
|
|
478
|
+
_type: string
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/** @public */
|
|
482
|
+
declare interface ContentSourceMapDocumentBase_2 {
|
|
483
|
+
_id: string
|
|
484
|
+
_type: string
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** @public */
|
|
488
|
+
export declare type ContentSourceMapDocuments = (
|
|
489
|
+
| ContentSourceMapDocument
|
|
490
|
+
| ContentSourceMapRemoteDocument
|
|
491
|
+
)[]
|
|
492
|
+
|
|
493
|
+
/** @public */
|
|
494
|
+
declare type ContentSourceMapDocuments_2 = (
|
|
495
|
+
| ContentSourceMapDocument_2
|
|
496
|
+
| ContentSourceMapRemoteDocument_2
|
|
497
|
+
)[]
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* DocumentValueSource is a path to a value within a document
|
|
501
|
+
* @public
|
|
502
|
+
*/
|
|
503
|
+
export declare interface ContentSourceMapDocumentValueSource {
|
|
504
|
+
type: 'documentValue'
|
|
505
|
+
document: number
|
|
506
|
+
path: number
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* DocumentValueSource is a path to a value within a document
|
|
511
|
+
* @public
|
|
512
|
+
*/
|
|
513
|
+
declare interface ContentSourceMapDocumentValueSource_2 {
|
|
514
|
+
type: 'documentValue'
|
|
515
|
+
document: number
|
|
516
|
+
path: number
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* When a value is not from a source, its a literal
|
|
521
|
+
* @public
|
|
522
|
+
*/
|
|
523
|
+
export declare interface ContentSourceMapLiteralSource {
|
|
524
|
+
type: 'literal'
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* When a value is not from a source, its a literal
|
|
529
|
+
* @public
|
|
530
|
+
*/
|
|
531
|
+
declare interface ContentSourceMapLiteralSource_2 {
|
|
532
|
+
type: 'literal'
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/** @public */
|
|
536
|
+
export declare type ContentSourceMapMapping = ContentSourceMapValueMapping
|
|
537
|
+
|
|
538
|
+
/** @public */
|
|
539
|
+
declare type ContentSourceMapMapping_2 = ContentSourceMapValueMapping_2
|
|
540
|
+
|
|
541
|
+
/** @public */
|
|
542
|
+
export declare type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>
|
|
543
|
+
|
|
544
|
+
/** @public */
|
|
545
|
+
declare type ContentSourceMapMappings_2 = Record<string, ContentSourceMapMapping_2>
|
|
546
|
+
|
|
547
|
+
/** @alpha */
|
|
548
|
+
export declare type ContentSourceMapParsedPath = (
|
|
549
|
+
| string
|
|
550
|
+
| number
|
|
551
|
+
| ContentSourceMapParsedPathKeyedSegment
|
|
552
|
+
)[]
|
|
23
553
|
|
|
24
|
-
|
|
554
|
+
/** @alpha */
|
|
555
|
+
export declare type ContentSourceMapParsedPathKeyedSegment = {
|
|
556
|
+
_key: string
|
|
557
|
+
_index: number
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** @public */
|
|
561
|
+
export declare type ContentSourceMapPaths = string[]
|
|
25
562
|
|
|
26
|
-
|
|
563
|
+
/** @public */
|
|
564
|
+
declare type ContentSourceMapPaths_2 = string[]
|
|
27
565
|
|
|
28
566
|
/** @public */
|
|
29
567
|
export declare type ContentSourceMapQueryResponse =
|
|
30
568
|
| RawQueryResponse<unknown>
|
|
31
569
|
| Pick<RawQueryResponse<unknown>, 'result' | 'resultSourceMap'>
|
|
32
570
|
|
|
571
|
+
/** @public */
|
|
572
|
+
export declare interface ContentSourceMapRemoteDocument extends ContentSourceMapDocumentBase {
|
|
573
|
+
_projectId: string
|
|
574
|
+
_dataset: string
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** @public */
|
|
578
|
+
declare interface ContentSourceMapRemoteDocument_2 extends ContentSourceMapDocumentBase_2 {
|
|
579
|
+
_projectId: string
|
|
580
|
+
_dataset: string
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** @public */
|
|
584
|
+
export declare type ContentSourceMapSource =
|
|
585
|
+
| ContentSourceMapDocumentValueSource
|
|
586
|
+
| ContentSourceMapLiteralSource
|
|
587
|
+
| ContentSourceMapUnknownSource
|
|
588
|
+
|
|
589
|
+
/** @public */
|
|
590
|
+
declare type ContentSourceMapSource_2 =
|
|
591
|
+
| ContentSourceMapDocumentValueSource_2
|
|
592
|
+
| ContentSourceMapLiteralSource_2
|
|
593
|
+
| ContentSourceMapUnknownSource_2
|
|
594
|
+
|
|
33
595
|
/**
|
|
34
|
-
*
|
|
596
|
+
* When a field source is unknown
|
|
35
597
|
* @public
|
|
36
598
|
*/
|
|
37
|
-
export declare
|
|
599
|
+
export declare interface ContentSourceMapUnknownSource {
|
|
600
|
+
type: 'unknown'
|
|
601
|
+
}
|
|
38
602
|
|
|
39
603
|
/**
|
|
40
|
-
*
|
|
604
|
+
* When a field source is unknown
|
|
605
|
+
* @public
|
|
41
606
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
encoder: Encoder,
|
|
46
|
-
): Result
|
|
607
|
+
declare interface ContentSourceMapUnknownSource_2 {
|
|
608
|
+
type: 'unknown'
|
|
609
|
+
}
|
|
47
610
|
|
|
48
611
|
/**
|
|
49
|
-
*
|
|
612
|
+
* ValueMapping is a mapping when for value that is from a single source value
|
|
613
|
+
* It may refer to a field within a document or a literal value
|
|
614
|
+
* @public
|
|
50
615
|
*/
|
|
51
|
-
export declare
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
616
|
+
export declare interface ContentSourceMapValueMapping {
|
|
617
|
+
type: 'value'
|
|
618
|
+
source: ContentSourceMapSource
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* ValueMapping is a mapping when for value that is from a single source value
|
|
623
|
+
* It may refer to a field within a document or a literal value
|
|
624
|
+
* @public
|
|
625
|
+
*/
|
|
626
|
+
declare interface ContentSourceMapValueMapping_2 {
|
|
627
|
+
type: 'value'
|
|
628
|
+
source: ContentSourceMapSource_2
|
|
629
|
+
}
|
|
57
630
|
|
|
58
631
|
/** @public */
|
|
59
|
-
export declare
|
|
632
|
+
export declare class CorsOriginError extends Error {
|
|
633
|
+
projectId: string
|
|
634
|
+
addOriginUrl?: URL
|
|
635
|
+
constructor({projectId}: {projectId: string})
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Creates a new draft document. The published version of the document must not already exist.
|
|
640
|
+
* If the draft version of the document already exists the action will fail by default, but
|
|
641
|
+
* this can be adjusted to instead leave the existing document in place.
|
|
642
|
+
*
|
|
643
|
+
* @public
|
|
644
|
+
*/
|
|
645
|
+
export declare type CreateAction = {
|
|
646
|
+
actionType: 'sanity.action.document.create'
|
|
647
|
+
/**
|
|
648
|
+
* ID of the published document to create a draft for.
|
|
649
|
+
*/
|
|
650
|
+
publishedId: string
|
|
651
|
+
/**
|
|
652
|
+
* Document to create. Requires a `_type` property.
|
|
653
|
+
*/
|
|
654
|
+
attributes: IdentifiedSanityDocumentStub
|
|
655
|
+
/**
|
|
656
|
+
* ifExists controls what to do if the draft already exists
|
|
657
|
+
*/
|
|
658
|
+
ifExists: 'fail' | 'ignore'
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* @deprecated -- Use `import {createClient} from '@sanity/client'` instead
|
|
663
|
+
* @public
|
|
664
|
+
*/
|
|
665
|
+
export declare const createClient: (config: ClientConfig_2) => SanityClient
|
|
666
|
+
|
|
667
|
+
/** @internal */
|
|
668
|
+
export declare interface CurrentSanityUser {
|
|
669
|
+
id: string
|
|
670
|
+
name: string
|
|
671
|
+
email: string
|
|
672
|
+
profileImage: string | null
|
|
673
|
+
role: string
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/** @internal */
|
|
677
|
+
export declare type DatasetAclMode = 'public' | 'private' | 'custom'
|
|
678
|
+
|
|
679
|
+
/** @internal */
|
|
680
|
+
export declare type DatasetResponse = {
|
|
681
|
+
datasetName: string
|
|
682
|
+
aclMode: DatasetAclMode
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/** @internal */
|
|
686
|
+
export declare class DatasetsClient {
|
|
687
|
+
#private
|
|
688
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
689
|
+
/**
|
|
690
|
+
* Create a new dataset with the given name
|
|
691
|
+
*
|
|
692
|
+
* @param name - Name of the dataset to create
|
|
693
|
+
* @param options - Options for the dataset
|
|
694
|
+
*/
|
|
695
|
+
create(
|
|
696
|
+
name: string,
|
|
697
|
+
options?: {
|
|
698
|
+
aclMode?: DatasetAclMode
|
|
699
|
+
},
|
|
700
|
+
): Promise<DatasetResponse>
|
|
701
|
+
/**
|
|
702
|
+
* Edit a dataset with the given name
|
|
703
|
+
*
|
|
704
|
+
* @param name - Name of the dataset to edit
|
|
705
|
+
* @param options - New options for the dataset
|
|
706
|
+
*/
|
|
707
|
+
edit(
|
|
708
|
+
name: string,
|
|
709
|
+
options?: {
|
|
710
|
+
aclMode?: DatasetAclMode
|
|
711
|
+
},
|
|
712
|
+
): Promise<DatasetResponse>
|
|
713
|
+
/**
|
|
714
|
+
* Delete a dataset with the given name
|
|
715
|
+
*
|
|
716
|
+
* @param name - Name of the dataset to delete
|
|
717
|
+
*/
|
|
718
|
+
delete(name: string): Promise<{
|
|
719
|
+
deleted: true
|
|
720
|
+
}>
|
|
721
|
+
/**
|
|
722
|
+
* Fetch a list of datasets for the configured project
|
|
723
|
+
*/
|
|
724
|
+
list(): Promise<DatasetsResponse>
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/** @internal */
|
|
728
|
+
export declare type DatasetsResponse = {
|
|
729
|
+
name: string
|
|
730
|
+
aclMode: DatasetAclMode
|
|
731
|
+
createdAt: string
|
|
732
|
+
createdByUserId: string
|
|
733
|
+
addonFor: string | null
|
|
734
|
+
datasetProfile: string
|
|
735
|
+
features: string[]
|
|
736
|
+
tags: string[]
|
|
737
|
+
}[]
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Deletes the published version of a document and optionally some (likely all known) draft versions.
|
|
741
|
+
* If any draft version exists that is not specified for deletion this is an error.
|
|
742
|
+
* If the purge flag is set then the document history is also deleted.
|
|
743
|
+
*
|
|
744
|
+
* @public
|
|
745
|
+
*/
|
|
746
|
+
export declare type DeleteAction = {
|
|
747
|
+
actionType: 'sanity.action.document.delete'
|
|
748
|
+
/**
|
|
749
|
+
* Published document ID to delete
|
|
750
|
+
*/
|
|
751
|
+
publishedId: string
|
|
752
|
+
/**
|
|
753
|
+
* Draft document ID to delete
|
|
754
|
+
*/
|
|
755
|
+
includeDrafts: string[]
|
|
756
|
+
/**
|
|
757
|
+
* Delete document history
|
|
758
|
+
*/
|
|
759
|
+
purge?: boolean
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Delete the draft version of a document.
|
|
764
|
+
* It is an error if it does not exist. If the purge flag is set, the document history is also deleted.
|
|
765
|
+
*
|
|
766
|
+
* @public
|
|
767
|
+
*/
|
|
768
|
+
export declare type DiscardAction = {
|
|
769
|
+
actionType: 'sanity.action.document.discard'
|
|
770
|
+
/**
|
|
771
|
+
* Draft document ID to delete
|
|
772
|
+
*/
|
|
773
|
+
draftId: string
|
|
774
|
+
/**
|
|
775
|
+
* Delete document history
|
|
776
|
+
*/
|
|
777
|
+
purge?: boolean
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* The listener has been told to explicitly disconnect.
|
|
782
|
+
* This is a rare situation, but may occur if the API knows reconnect attempts will fail,
|
|
783
|
+
* eg in the case of a deleted dataset, a blocked project or similar events.
|
|
784
|
+
* @public
|
|
785
|
+
*/
|
|
786
|
+
export declare class DisconnectError extends Error {
|
|
787
|
+
readonly name = 'DisconnectError'
|
|
788
|
+
readonly reason?: string
|
|
789
|
+
constructor(message: string, reason?: string, options?: ErrorOptions)
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* The listener has been told to explicitly disconnect and not reconnect.
|
|
794
|
+
* This is a rare situation, but may occur if the API knows reconnect attempts will fail,
|
|
795
|
+
* eg in the case of a deleted dataset, a blocked project or similar events.
|
|
796
|
+
*
|
|
797
|
+
* Note that this is not treated as an error on the observable, but will complete the observable.
|
|
798
|
+
*
|
|
799
|
+
* @public
|
|
800
|
+
*/
|
|
801
|
+
export declare type DisconnectEvent = {
|
|
802
|
+
type: 'disconnect'
|
|
803
|
+
reason: string
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Modifies an existing draft document.
|
|
808
|
+
* It applies the given patch to the document referenced by draftId.
|
|
809
|
+
* If there is no such document then one is created using the current state of the published version and then that is updated accordingly.
|
|
810
|
+
*
|
|
811
|
+
* @public
|
|
812
|
+
*/
|
|
813
|
+
export declare type EditAction = {
|
|
814
|
+
actionType: 'sanity.action.document.edit'
|
|
815
|
+
/**
|
|
816
|
+
* Draft document ID to edit
|
|
817
|
+
*/
|
|
818
|
+
draftId: string
|
|
819
|
+
/**
|
|
820
|
+
* Published document ID to create draft from, if draft does not exist
|
|
821
|
+
*/
|
|
822
|
+
publishedId: string
|
|
823
|
+
/**
|
|
824
|
+
* Patch operations to apply
|
|
825
|
+
*/
|
|
826
|
+
patch: PatchOperations
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* @internal
|
|
831
|
+
*/
|
|
832
|
+
export declare function encodeIntoResult<Result>(
|
|
833
|
+
result: Result,
|
|
834
|
+
csm: ContentSourceMap_2,
|
|
835
|
+
encoder: Encoder,
|
|
836
|
+
): Result
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* @internal
|
|
840
|
+
*/
|
|
841
|
+
export declare type Encoder = (context: {
|
|
842
|
+
sourcePath: ContentSourceMapParsedPath
|
|
843
|
+
sourceDocument: ContentSourceMapDocuments_2[number]
|
|
844
|
+
resultPath: ContentSourceMapParsedPath
|
|
845
|
+
value: string
|
|
846
|
+
}) => string
|
|
847
|
+
|
|
848
|
+
/** @public */
|
|
849
|
+
export declare interface ErrorProps {
|
|
850
|
+
message: string
|
|
851
|
+
response: Any
|
|
852
|
+
statusCode: number
|
|
853
|
+
responseBody: Any
|
|
854
|
+
details: Any
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* @internal
|
|
859
|
+
*/
|
|
860
|
+
export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name>
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* @internal
|
|
864
|
+
*/
|
|
865
|
+
export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
|
|
866
|
+
|
|
867
|
+
/** @public */
|
|
868
|
+
export declare type FilterDefault = (props: {
|
|
869
|
+
/**
|
|
870
|
+
* The path to the value in the source document, for example if you queried for a document like this:
|
|
871
|
+
* `*[_type == "author"][0]{"slug": slug.current}`
|
|
872
|
+
* Then the `sourcePath` for `result.slug` would be `['slug', 'current']`.
|
|
873
|
+
*
|
|
874
|
+
*/
|
|
875
|
+
sourcePath: ContentSourceMapParsedPath
|
|
876
|
+
/**
|
|
877
|
+
* If `sourcePath` alone isn't enough to tell you if it's safe to contain stega strings, then you can use `sourceDocument`
|
|
878
|
+
* for additional metadata.
|
|
879
|
+
* It'll always have a `_type` property, which can be used to trace it to the Studio Schema that were used initially.
|
|
880
|
+
* It also has `_id` to help you debug and look at the whole document when troubleshooting.
|
|
881
|
+
* Finally, if the document origins in a Cross Dataset Reference you'll also have `_projectId` and `_dataset` properties to help you trace it.
|
|
882
|
+
*/
|
|
883
|
+
sourceDocument: ContentSourceMapDocuments_2[number]
|
|
884
|
+
/**
|
|
885
|
+
* If you don't colocate your Studio Schemas with your GROQ queries it might be hard to make sense of `sourcePath`,
|
|
886
|
+
* as it operates on the original shape of a document.
|
|
887
|
+
* In that case `resultPath` can be used, as it mirrors the path to the value in the result.
|
|
888
|
+
* For example in a query like this:
|
|
889
|
+
* `*[_type == "author"][0]{"slug": slug.current}`
|
|
890
|
+
* The `resultPath` for `result.slug` would be `['slug']`, while `sourcePath` will be `['slug', 'current']`.
|
|
891
|
+
*/
|
|
892
|
+
resultPath: ContentSourceMapParsedPath
|
|
893
|
+
/**
|
|
894
|
+
* You can also use your own string validation logic to determine if it's safe.
|
|
895
|
+
*/
|
|
896
|
+
value: string
|
|
897
|
+
/**
|
|
898
|
+
* If you want to keep the default filtering behavior, but only override it for a specific path, you can use `filterDefault` to do that.
|
|
899
|
+
* For example, here all "icon" documents in a Page Builder skips encoding:
|
|
900
|
+
* ```ts
|
|
901
|
+
{
|
|
902
|
+
filter: (props) => {
|
|
903
|
+
switch (props.sourceDocument._type) {
|
|
904
|
+
case 'icon':
|
|
905
|
+
return false
|
|
906
|
+
default:
|
|
907
|
+
return props.filterDefault(props)
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
* ```
|
|
912
|
+
*/
|
|
913
|
+
filterDefault: FilterDefault
|
|
914
|
+
}) => boolean
|
|
915
|
+
|
|
916
|
+
/** @public */
|
|
917
|
+
declare type FilterDefault_2 = (props: {
|
|
918
|
+
/**
|
|
919
|
+
* The path to the value in the source document, for example if you queried for a document like this:
|
|
920
|
+
* `*[_type == "author"][0]{"slug": slug.current}`
|
|
921
|
+
* Then the `sourcePath` for `result.slug` would be `['slug', 'current']`.
|
|
922
|
+
*
|
|
923
|
+
*/
|
|
924
|
+
sourcePath: ContentSourceMapParsedPath
|
|
925
|
+
/**
|
|
926
|
+
* If `sourcePath` alone isn't enough to tell you if it's safe to contain stega strings, then you can use `sourceDocument`
|
|
927
|
+
* for additional metadata.
|
|
928
|
+
* It'll always have a `_type` property, which can be used to trace it to the Studio Schema that were used initially.
|
|
929
|
+
* It also has `_id` to help you debug and look at the whole document when troubleshooting.
|
|
930
|
+
* Finally, if the document origins in a Cross Dataset Reference you'll also have `_projectId` and `_dataset` properties to help you trace it.
|
|
931
|
+
*/
|
|
932
|
+
sourceDocument: ContentSourceMapDocuments_2[number]
|
|
933
|
+
/**
|
|
934
|
+
* If you don't colocate your Studio Schemas with your GROQ queries it might be hard to make sense of `sourcePath`,
|
|
935
|
+
* as it operates on the original shape of a document.
|
|
936
|
+
* In that case `resultPath` can be used, as it mirrors the path to the value in the result.
|
|
937
|
+
* For example in a query like this:
|
|
938
|
+
* `*[_type == "author"][0]{"slug": slug.current}`
|
|
939
|
+
* The `resultPath` for `result.slug` would be `['slug']`, while `sourcePath` will be `['slug', 'current']`.
|
|
940
|
+
*/
|
|
941
|
+
resultPath: ContentSourceMapParsedPath
|
|
942
|
+
/**
|
|
943
|
+
* You can also use your own string validation logic to determine if it's safe.
|
|
944
|
+
*/
|
|
945
|
+
value: string
|
|
946
|
+
/**
|
|
947
|
+
* If you want to keep the default filtering behavior, but only override it for a specific path, you can use `filterDefault` to do that.
|
|
948
|
+
* For example, here all "icon" documents in a Page Builder skips encoding:
|
|
949
|
+
* ```ts
|
|
950
|
+
{
|
|
951
|
+
filter: (props) => {
|
|
952
|
+
switch (props.sourceDocument._type) {
|
|
953
|
+
case 'icon':
|
|
954
|
+
return false
|
|
955
|
+
default:
|
|
956
|
+
return props.filterDefault(props)
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
* ```
|
|
961
|
+
*/
|
|
962
|
+
filterDefault: FilterDefault_2
|
|
963
|
+
}) => boolean
|
|
964
|
+
|
|
965
|
+
/** @public */
|
|
966
|
+
export declare interface FilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
967
|
+
filterResponse?: true
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
/** @internal */
|
|
971
|
+
export declare type FirstDocumentIdMutationOptions = BaseMutationOptions & {
|
|
972
|
+
returnFirst?: true
|
|
973
|
+
returnDocuments: false
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
/** @internal */
|
|
977
|
+
export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
978
|
+
returnFirst?: true
|
|
979
|
+
returnDocuments?: true
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/** @public */
|
|
983
|
+
export declare type HttpRequest = {
|
|
984
|
+
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/** @public */
|
|
988
|
+
export declare type HttpRequestEvent<T = unknown> = ResponseEvent<T> | ProgressEvent_2
|
|
989
|
+
|
|
990
|
+
/** @public */
|
|
991
|
+
export declare type IdentifiedSanityDocumentStub<
|
|
992
|
+
T extends Record<string, Any> = Record<string, Any>,
|
|
993
|
+
> = {
|
|
994
|
+
[P in keyof T]: T[P]
|
|
995
|
+
} & {
|
|
996
|
+
_id: string
|
|
997
|
+
} & SanityDocumentStub
|
|
998
|
+
|
|
999
|
+
/** @public */
|
|
1000
|
+
export declare interface InitializedClientConfig extends ClientConfig {
|
|
1001
|
+
apiHost: string
|
|
1002
|
+
apiVersion: string
|
|
1003
|
+
useProjectHostname: boolean
|
|
1004
|
+
useCdn: boolean
|
|
1005
|
+
/**
|
|
1006
|
+
* @deprecated Internal, don't use
|
|
1007
|
+
*/
|
|
1008
|
+
isDefaultApi: boolean
|
|
1009
|
+
/**
|
|
1010
|
+
* @deprecated Internal, don't use
|
|
1011
|
+
*/
|
|
1012
|
+
url: string
|
|
1013
|
+
/**
|
|
1014
|
+
* @deprecated Internal, don't use
|
|
1015
|
+
*/
|
|
1016
|
+
cdnUrl: string
|
|
1017
|
+
/**
|
|
1018
|
+
* The fully initialized stega config, can be used to check if stega is enabled
|
|
1019
|
+
*/
|
|
1020
|
+
stega: InitializedStegaConfig
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* @public
|
|
1025
|
+
* @deprecated -- use `InitializedClientConfig` instead
|
|
1026
|
+
*/
|
|
1027
|
+
export declare interface InitializedClientStegaConfig extends InitializedClientConfig {}
|
|
1028
|
+
|
|
1029
|
+
/** @public */
|
|
1030
|
+
export declare type InitializedStegaConfig = Omit<StegaConfig, StegaConfigRequiredKeys> &
|
|
1031
|
+
Required<Pick<StegaConfig, StegaConfigRequiredKeys>>
|
|
1032
|
+
|
|
1033
|
+
/** @public */
|
|
1034
|
+
declare type InitializedStegaConfig_2 = Omit<StegaConfig_2, StegaConfigRequiredKeys_2> &
|
|
1035
|
+
Required<Pick<StegaConfig_2, StegaConfigRequiredKeys_2>>
|
|
1036
|
+
|
|
1037
|
+
/** @internal */
|
|
1038
|
+
export declare type InsertPatch =
|
|
1039
|
+
| {
|
|
1040
|
+
before: string
|
|
1041
|
+
items: Any[]
|
|
1042
|
+
}
|
|
1043
|
+
| {
|
|
1044
|
+
after: string
|
|
1045
|
+
items: Any[]
|
|
1046
|
+
}
|
|
1047
|
+
| {
|
|
1048
|
+
replace: string
|
|
1049
|
+
items: Any[]
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
1054
|
+
*
|
|
1055
|
+
* @param query - GROQ-filter to listen to changes for
|
|
1056
|
+
* @param params - Optional query parameters
|
|
1057
|
+
* @param options - Optional listener options
|
|
1058
|
+
* @public
|
|
1059
|
+
*/
|
|
1060
|
+
export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
1061
|
+
this: SanityClient | ObservableSanityClient,
|
|
1062
|
+
query: string,
|
|
1063
|
+
params?: ListenParams,
|
|
1064
|
+
): Observable<MutationEvent<R>>
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
1068
|
+
*
|
|
1069
|
+
* @param query - GROQ-filter to listen to changes for
|
|
1070
|
+
* @param params - Optional query parameters
|
|
1071
|
+
* @param options - Optional listener options
|
|
1072
|
+
* @public
|
|
1073
|
+
*/
|
|
1074
|
+
export declare function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
1075
|
+
this: SanityClient | ObservableSanityClient,
|
|
1076
|
+
query: string,
|
|
1077
|
+
params?: ListenParams,
|
|
1078
|
+
options?: ListenOptions,
|
|
1079
|
+
): Observable<ListenEvent<R>>
|
|
1080
|
+
|
|
1081
|
+
/** @public */
|
|
1082
|
+
export declare type ListenEvent<R extends Record<string, Any>> =
|
|
1083
|
+
| MutationEvent<R>
|
|
1084
|
+
| ChannelErrorEvent
|
|
1085
|
+
| DisconnectEvent
|
|
1086
|
+
| ReconnectEvent
|
|
1087
|
+
| WelcomeEvent
|
|
1088
|
+
| OpenEvent
|
|
1089
|
+
|
|
1090
|
+
/** @public */
|
|
1091
|
+
export declare type ListenEventName =
|
|
1092
|
+
/** A mutation was performed */
|
|
1093
|
+
| 'mutation'
|
|
1094
|
+
/** The listener has been (re)established */
|
|
1095
|
+
| 'welcome'
|
|
1096
|
+
/** The listener has been disconnected, and a reconnect attempt is scheduled */
|
|
1097
|
+
| 'reconnect'
|
|
1098
|
+
|
|
1099
|
+
/** @public */
|
|
1100
|
+
export declare interface ListenOptions {
|
|
1101
|
+
/**
|
|
1102
|
+
* Whether or not to include the resulting document in addition to the mutations performed.
|
|
1103
|
+
* If you do not need the actual document, set this to `false` to reduce bandwidth usage.
|
|
1104
|
+
* The result will be available on the `.result` property of the events.
|
|
1105
|
+
* @defaultValue `true`
|
|
1106
|
+
*/
|
|
1107
|
+
includeResult?: boolean
|
|
1108
|
+
/**
|
|
1109
|
+
* Whether or not to include the mutations that was performed.
|
|
1110
|
+
* If you do not need the mutations, set this to `false` to reduce bandwidth usage.
|
|
1111
|
+
* @defaultValue `true`
|
|
1112
|
+
*/
|
|
1113
|
+
includeMutations?: boolean
|
|
1114
|
+
/**
|
|
1115
|
+
* Whether or not to include the document as it looked before the mutation event.
|
|
1116
|
+
* The previous revision will be available on the `.previous` property of the events,
|
|
1117
|
+
* and may be `null` in the case of a new document.
|
|
1118
|
+
* @defaultValue `false`
|
|
1119
|
+
*/
|
|
1120
|
+
includePreviousRevision?: boolean
|
|
1121
|
+
/**
|
|
1122
|
+
* Whether events should be sent as soon as a transaction has been committed (`transaction`, default),
|
|
1123
|
+
* or only after they are available for queries (query). Note that this is on a best-effort basis,
|
|
1124
|
+
* and listeners with `query` may in certain cases (notably with deferred transactions) receive events
|
|
1125
|
+
* that are not yet visible to queries.
|
|
1126
|
+
*
|
|
1127
|
+
* @defaultValue `'transaction'`
|
|
1128
|
+
*/
|
|
1129
|
+
visibility?: 'transaction' | 'query'
|
|
1130
|
+
/**
|
|
1131
|
+
* Array of event names to include in the observable. By default, only mutation events are included.
|
|
1132
|
+
*
|
|
1133
|
+
* @defaultValue `['mutation']`
|
|
1134
|
+
*/
|
|
1135
|
+
events?: ListenEventName[]
|
|
1136
|
+
/**
|
|
1137
|
+
* Format of "effects", eg the resulting changes of a mutation.
|
|
1138
|
+
* Currently only `mendoza` is supported, and (if set) will include `apply` and `revert` arrays
|
|
1139
|
+
* in the mutation events under the `effects` property.
|
|
1140
|
+
*
|
|
1141
|
+
* See {@link https://github.com/sanity-io/mendoza | The mendoza docs} for more info
|
|
1142
|
+
*
|
|
1143
|
+
* @defaultValue `undefined`
|
|
1144
|
+
*/
|
|
1145
|
+
effectFormat?: 'mendoza'
|
|
1146
|
+
/**
|
|
1147
|
+
* Optional request tag for the listener. Use to identify the request in logs.
|
|
1148
|
+
*
|
|
1149
|
+
* @defaultValue `undefined`
|
|
1150
|
+
*/
|
|
1151
|
+
tag?: string
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
/** @public */
|
|
1155
|
+
export declare type ListenParams = {
|
|
1156
|
+
[key: string]: Any
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* @public
|
|
1161
|
+
*/
|
|
1162
|
+
export declare class LiveClient {
|
|
1163
|
+
#private
|
|
1164
|
+
constructor(client: SanityClient | ObservableSanityClient)
|
|
1165
|
+
/**
|
|
1166
|
+
* Requires `apiVersion` to be `2021-03-26` or later.
|
|
1167
|
+
*/
|
|
1168
|
+
events({
|
|
1169
|
+
includeDrafts,
|
|
1170
|
+
tag: _tag,
|
|
1171
|
+
}?: {
|
|
1172
|
+
/** @alpha this API is experimental and may change or even be removed */
|
|
1173
|
+
includeDrafts?: boolean
|
|
1174
|
+
/**
|
|
1175
|
+
* Optional request tag for the listener. Use to identify the request in logs.
|
|
1176
|
+
*
|
|
1177
|
+
* @defaultValue `undefined`
|
|
1178
|
+
*/
|
|
1179
|
+
tag?: string
|
|
1180
|
+
}): Observable<LiveEventMessage | LiveEventRestart | LiveEventReconnect | LiveEventWelcome>
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/** @public */
|
|
1184
|
+
export declare interface LiveEventMessage {
|
|
1185
|
+
type: 'message'
|
|
1186
|
+
id: string
|
|
1187
|
+
tags: SyncTag[]
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/** @public */
|
|
1191
|
+
export declare interface LiveEventReconnect {
|
|
1192
|
+
type: 'reconnect'
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/** @public */
|
|
1196
|
+
export declare interface LiveEventRestart {
|
|
1197
|
+
type: 'restart'
|
|
1198
|
+
id: string
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
/** @public */
|
|
1202
|
+
export declare interface LiveEventWelcome {
|
|
1203
|
+
type: 'welcome'
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/** @public */
|
|
1207
|
+
export declare type Logger =
|
|
1208
|
+
| typeof console
|
|
1209
|
+
| Partial<
|
|
1210
|
+
Pick<typeof console, 'debug' | 'error' | 'groupCollapsed' | 'groupEnd' | 'log' | 'table'>
|
|
1211
|
+
>
|
|
1212
|
+
|
|
1213
|
+
/** @public */
|
|
1214
|
+
declare type Logger_2 =
|
|
1215
|
+
| typeof console
|
|
1216
|
+
| Partial<
|
|
1217
|
+
Pick<typeof console, 'debug' | 'error' | 'groupCollapsed' | 'groupEnd' | 'log' | 'table'>
|
|
1218
|
+
>
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* @public
|
|
1222
|
+
* The server sent an `error`-event to tell the client that an unexpected error has happened.
|
|
1223
|
+
*/
|
|
1224
|
+
export declare class MessageError extends Error {
|
|
1225
|
+
readonly name = 'MessageError'
|
|
1226
|
+
readonly data?: unknown
|
|
1227
|
+
constructor(message: string, data: unknown, options?: ErrorOptions)
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* @public
|
|
1232
|
+
* An error occurred while parsing the message sent by the server as JSON. Should normally not happen.
|
|
1233
|
+
*/
|
|
1234
|
+
export declare class MessageParseError extends Error {
|
|
1235
|
+
readonly name = 'MessageParseError'
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
/** @internal */
|
|
1239
|
+
export declare interface MultipleActionResult {
|
|
1240
|
+
transactionId: string
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/** @internal */
|
|
1244
|
+
export declare interface MultipleMutationResult {
|
|
1245
|
+
transactionId: string
|
|
1246
|
+
documentIds: string[]
|
|
1247
|
+
results: {
|
|
1248
|
+
id: string
|
|
1249
|
+
operation: MutationOperation
|
|
1250
|
+
}[]
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/** @public */
|
|
1254
|
+
export declare type Mutation<R extends Record<string, Any> = Record<string, Any>> =
|
|
1255
|
+
| {
|
|
1256
|
+
create: SanityDocumentStub<R>
|
|
1257
|
+
}
|
|
1258
|
+
| {
|
|
1259
|
+
createOrReplace: IdentifiedSanityDocumentStub<R>
|
|
1260
|
+
}
|
|
1261
|
+
| {
|
|
1262
|
+
createIfNotExists: IdentifiedSanityDocumentStub<R>
|
|
1263
|
+
}
|
|
1264
|
+
| {
|
|
1265
|
+
delete: MutationSelection
|
|
1266
|
+
}
|
|
1267
|
+
| {
|
|
1268
|
+
patch: PatchMutationOperation
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/** @internal */
|
|
1272
|
+
export declare interface MutationError {
|
|
1273
|
+
error: {
|
|
1274
|
+
type: 'mutationError'
|
|
1275
|
+
description: string
|
|
1276
|
+
items?: MutationErrorItem[]
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/** @internal */
|
|
1281
|
+
export declare interface MutationErrorItem {
|
|
1282
|
+
error: {
|
|
1283
|
+
type: string
|
|
1284
|
+
description: string
|
|
1285
|
+
value?: unknown
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* A mutation was performed. Note that when updating multiple documents in a transaction,
|
|
1291
|
+
* each document affected will get a separate mutation event.
|
|
1292
|
+
*
|
|
1293
|
+
* @public
|
|
1294
|
+
*/
|
|
1295
|
+
export declare type MutationEvent<R extends Record<string, Any> = Record<string, Any>> = {
|
|
1296
|
+
type: 'mutation'
|
|
1297
|
+
/**
|
|
1298
|
+
* The ID of the document that was affected
|
|
1299
|
+
*/
|
|
1300
|
+
documentId: string
|
|
1301
|
+
/**
|
|
1302
|
+
* A unique ID for this event
|
|
1303
|
+
*/
|
|
1304
|
+
eventId: string
|
|
1305
|
+
/**
|
|
1306
|
+
* The user ID of the user that performed the mutation
|
|
1307
|
+
*/
|
|
1308
|
+
identity: string
|
|
1309
|
+
/**
|
|
1310
|
+
* An array of mutations that were performed. Note that this can differ slightly from the
|
|
1311
|
+
* mutations sent to the server, as the server may perform some mutations automatically.
|
|
1312
|
+
*/
|
|
1313
|
+
mutations: Mutation[]
|
|
1314
|
+
/**
|
|
1315
|
+
* The revision ID of the document before the mutation was performed
|
|
1316
|
+
*/
|
|
1317
|
+
previousRev?: string
|
|
1318
|
+
/**
|
|
1319
|
+
* The revision ID of the document after the mutation was performed
|
|
1320
|
+
*/
|
|
1321
|
+
resultRev?: string
|
|
1322
|
+
/**
|
|
1323
|
+
* The document as it looked after the mutation was performed. This is only included if
|
|
1324
|
+
* the listener was configured with `includeResult: true`.
|
|
1325
|
+
*/
|
|
1326
|
+
result?: SanityDocument<R>
|
|
1327
|
+
/**
|
|
1328
|
+
* The document as it looked before the mutation was performed. This is only included if
|
|
1329
|
+
* the listener was configured with `includePreviousRevision: true`.
|
|
1330
|
+
*/
|
|
1331
|
+
previous?: SanityDocument<R> | null
|
|
1332
|
+
/**
|
|
1333
|
+
* The effects of the mutation, if the listener was configured with `effectFormat: 'mendoza'`.
|
|
1334
|
+
* Object with `apply` and `revert` arrays, see {@link https://github.com/sanity-io/mendoza}.
|
|
1335
|
+
*/
|
|
1336
|
+
effects?: {
|
|
1337
|
+
apply: unknown[]
|
|
1338
|
+
revert: unknown[]
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* A timestamp for when the mutation was performed
|
|
1342
|
+
*/
|
|
1343
|
+
timestamp: string
|
|
1344
|
+
/**
|
|
1345
|
+
* The transaction ID for the mutation
|
|
1346
|
+
*/
|
|
1347
|
+
transactionId: string
|
|
1348
|
+
/**
|
|
1349
|
+
* The type of transition the document went through.
|
|
1350
|
+
*
|
|
1351
|
+
* - `update` means the document was previously part of the subscribed set of documents,
|
|
1352
|
+
* and still is.
|
|
1353
|
+
* - `appear` means the document was not previously part of the subscribed set of documents,
|
|
1354
|
+
* but is now. This can happen both on create or if updating to a state where it now matches
|
|
1355
|
+
* the filter provided to the listener.
|
|
1356
|
+
* - `disappear` means the document was previously part of the subscribed set of documents,
|
|
1357
|
+
* but is no longer. This can happen both on delete or if updating to a state where it no
|
|
1358
|
+
* longer matches the filter provided to the listener.
|
|
1359
|
+
*/
|
|
1360
|
+
transition: 'update' | 'appear' | 'disappear'
|
|
1361
|
+
/**
|
|
1362
|
+
* Whether the change that triggered this event is visible to queries (query) or only to
|
|
1363
|
+
* subsequent transactions (transaction). The listener client can specify a preferred visibility
|
|
1364
|
+
* through the `visibility` parameter on the listener, but this is only on a best-effort basis,
|
|
1365
|
+
* and may yet not be accurate.
|
|
1366
|
+
*/
|
|
1367
|
+
visibility: 'query' | 'transaction'
|
|
1368
|
+
/**
|
|
1369
|
+
* The total number of events that will be sent for this transaction.
|
|
1370
|
+
* Note that this may differ from the amount of _documents_ affected by the transaction, as this
|
|
1371
|
+
* number only includes the documents that matches the given filter.
|
|
1372
|
+
*
|
|
1373
|
+
* This can be useful if you need to perform changes to all matched documents atomically,
|
|
1374
|
+
* eg you would wait for `transactionTotalEvents` events with the same `transactionId` before
|
|
1375
|
+
* applying the changes locally.
|
|
1376
|
+
*/
|
|
1377
|
+
transactionTotalEvents: number
|
|
1378
|
+
/**
|
|
1379
|
+
* The index of this event within the transaction. Note that events may be delivered out of order,
|
|
1380
|
+
* and that the index is zero-based.
|
|
1381
|
+
*/
|
|
1382
|
+
transactionCurrentEvent: number
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
/** @internal */
|
|
1386
|
+
export declare type MutationOperation = 'create' | 'delete' | 'update' | 'none'
|
|
1387
|
+
|
|
1388
|
+
/** @internal */
|
|
1389
|
+
export declare type MutationSelection =
|
|
1390
|
+
| {
|
|
1391
|
+
query: string
|
|
1392
|
+
params?: MutationSelectionQueryParams
|
|
1393
|
+
}
|
|
1394
|
+
| {
|
|
1395
|
+
id: string | string[]
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
/** @internal */
|
|
1399
|
+
export declare type MutationSelectionQueryParams = {
|
|
1400
|
+
[key: string]: Any
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
/** @internal */
|
|
1404
|
+
export declare class ObservableAssetsClient {
|
|
1405
|
+
#private
|
|
1406
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1407
|
+
/**
|
|
1408
|
+
* Uploads a file asset to the configured dataset
|
|
1409
|
+
*
|
|
1410
|
+
* @param assetType - Asset type (file)
|
|
1411
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1412
|
+
* @param options - Options to use for the upload
|
|
1413
|
+
*/
|
|
1414
|
+
upload(
|
|
1415
|
+
assetType: 'file',
|
|
1416
|
+
body: UploadBody,
|
|
1417
|
+
options?: UploadClientConfig,
|
|
1418
|
+
): Observable<
|
|
1419
|
+
HttpRequestEvent<{
|
|
1420
|
+
document: SanityAssetDocument
|
|
1421
|
+
}>
|
|
1422
|
+
>
|
|
1423
|
+
/**
|
|
1424
|
+
* Uploads an image asset to the configured dataset
|
|
1425
|
+
*
|
|
1426
|
+
* @param assetType - Asset type (image)
|
|
1427
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1428
|
+
* @param options - Options to use for the upload
|
|
1429
|
+
*/
|
|
1430
|
+
upload(
|
|
1431
|
+
assetType: 'image',
|
|
1432
|
+
body: UploadBody,
|
|
1433
|
+
options?: UploadClientConfig,
|
|
1434
|
+
): Observable<
|
|
1435
|
+
HttpRequestEvent<{
|
|
1436
|
+
document: SanityImageAssetDocument
|
|
1437
|
+
}>
|
|
1438
|
+
>
|
|
1439
|
+
/**
|
|
1440
|
+
* Uploads a file or an image asset to the configured dataset
|
|
1441
|
+
*
|
|
1442
|
+
* @param assetType - Asset type (file/image)
|
|
1443
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
1444
|
+
* @param options - Options to use for the upload
|
|
1445
|
+
*/
|
|
1446
|
+
upload(
|
|
1447
|
+
assetType: 'file' | 'image',
|
|
1448
|
+
body: UploadBody,
|
|
1449
|
+
options?: UploadClientConfig,
|
|
1450
|
+
): Observable<
|
|
1451
|
+
HttpRequestEvent<{
|
|
1452
|
+
document: SanityAssetDocument | SanityImageAssetDocument
|
|
1453
|
+
}>
|
|
1454
|
+
>
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
/** @internal */
|
|
1458
|
+
export declare class ObservableDatasetsClient {
|
|
1459
|
+
#private
|
|
1460
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1461
|
+
/**
|
|
1462
|
+
* Create a new dataset with the given name
|
|
1463
|
+
*
|
|
1464
|
+
* @param name - Name of the dataset to create
|
|
1465
|
+
* @param options - Options for the dataset
|
|
1466
|
+
*/
|
|
1467
|
+
create(
|
|
1468
|
+
name: string,
|
|
1469
|
+
options?: {
|
|
1470
|
+
aclMode?: DatasetAclMode
|
|
1471
|
+
},
|
|
1472
|
+
): Observable<DatasetResponse>
|
|
1473
|
+
/**
|
|
1474
|
+
* Edit a dataset with the given name
|
|
1475
|
+
*
|
|
1476
|
+
* @param name - Name of the dataset to edit
|
|
1477
|
+
* @param options - New options for the dataset
|
|
1478
|
+
*/
|
|
1479
|
+
edit(
|
|
1480
|
+
name: string,
|
|
1481
|
+
options?: {
|
|
1482
|
+
aclMode?: DatasetAclMode
|
|
1483
|
+
},
|
|
1484
|
+
): Observable<DatasetResponse>
|
|
1485
|
+
/**
|
|
1486
|
+
* Delete a dataset with the given name
|
|
1487
|
+
*
|
|
1488
|
+
* @param name - Name of the dataset to delete
|
|
1489
|
+
*/
|
|
1490
|
+
delete(name: string): Observable<{
|
|
1491
|
+
deleted: true
|
|
1492
|
+
}>
|
|
1493
|
+
/**
|
|
1494
|
+
* Fetch a list of datasets for the configured project
|
|
1495
|
+
*/
|
|
1496
|
+
list(): Observable<DatasetsResponse>
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
/** @public */
|
|
1500
|
+
export declare class ObservablePatch extends BasePatch {
|
|
1501
|
+
#private
|
|
1502
|
+
constructor(
|
|
1503
|
+
selection: PatchSelection,
|
|
1504
|
+
operations?: PatchOperations,
|
|
1505
|
+
client?: ObservableSanityClient,
|
|
1506
|
+
)
|
|
1507
|
+
/**
|
|
1508
|
+
* Clones the patch
|
|
1509
|
+
*/
|
|
1510
|
+
clone(): ObservablePatch
|
|
1511
|
+
/**
|
|
1512
|
+
* Commit the patch, returning an observable that produces the first patched document
|
|
1513
|
+
*
|
|
1514
|
+
* @param options - Options for the mutation operation
|
|
1515
|
+
*/
|
|
1516
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1517
|
+
options: FirstDocumentMutationOptions,
|
|
1518
|
+
): Observable<SanityDocument<R>>
|
|
1519
|
+
/**
|
|
1520
|
+
* Commit the patch, returning an observable that produces an array of the mutated documents
|
|
1521
|
+
*
|
|
1522
|
+
* @param options - Options for the mutation operation
|
|
1523
|
+
*/
|
|
1524
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1525
|
+
options: AllDocumentsMutationOptions,
|
|
1526
|
+
): Observable<SanityDocument<R>[]>
|
|
1527
|
+
/**
|
|
1528
|
+
* Commit the patch, returning an observable that produces a mutation result object
|
|
1529
|
+
*
|
|
1530
|
+
* @param options - Options for the mutation operation
|
|
1531
|
+
*/
|
|
1532
|
+
commit(options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
1533
|
+
/**
|
|
1534
|
+
* Commit the patch, returning an observable that produces a mutation result object
|
|
1535
|
+
*
|
|
1536
|
+
* @param options - Options for the mutation operation
|
|
1537
|
+
*/
|
|
1538
|
+
commit(options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
1539
|
+
/**
|
|
1540
|
+
* Commit the patch, returning an observable that produces the first patched document
|
|
1541
|
+
*
|
|
1542
|
+
* @param options - Options for the mutation operation
|
|
1543
|
+
*/
|
|
1544
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
1545
|
+
options?: BaseMutationOptions,
|
|
1546
|
+
): Observable<SanityDocument<R>>
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
/** @public */
|
|
1550
|
+
export declare type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch
|
|
1551
|
+
|
|
1552
|
+
/** @internal */
|
|
1553
|
+
export declare class ObservableProjectsClient {
|
|
1554
|
+
#private
|
|
1555
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1556
|
+
/**
|
|
1557
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
1558
|
+
*
|
|
1559
|
+
* @param options - Options for the list request
|
|
1560
|
+
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
1561
|
+
*/
|
|
1562
|
+
list(options?: {includeMembers?: true}): Observable<SanityProject[]>
|
|
1563
|
+
list(options?: {includeMembers?: false}): Observable<Omit<SanityProject, 'members'>[]>
|
|
1564
|
+
/**
|
|
1565
|
+
* Fetch a project by project ID
|
|
1566
|
+
*
|
|
1567
|
+
* @param projectId - ID of the project to fetch
|
|
1568
|
+
*/
|
|
1569
|
+
getById(projectId: string): Observable<SanityProject>
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
/** @public */
|
|
1573
|
+
export declare class ObservableSanityClient {
|
|
1574
|
+
#private
|
|
1575
|
+
assets: ObservableAssetsClient
|
|
1576
|
+
datasets: ObservableDatasetsClient
|
|
1577
|
+
live: LiveClient
|
|
1578
|
+
projects: ObservableProjectsClient
|
|
1579
|
+
users: ObservableUsersClient
|
|
1580
|
+
/**
|
|
1581
|
+
* Instance properties
|
|
1582
|
+
*/
|
|
1583
|
+
listen: typeof _listen
|
|
1584
|
+
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1585
|
+
/**
|
|
1586
|
+
* Clone the client - returns a new instance
|
|
1587
|
+
*/
|
|
1588
|
+
clone(): ObservableSanityClient
|
|
1589
|
+
/**
|
|
1590
|
+
* Returns the current client configuration
|
|
1591
|
+
*/
|
|
1592
|
+
config(): InitializedClientConfig
|
|
1593
|
+
/**
|
|
1594
|
+
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
1595
|
+
*/
|
|
1596
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
1597
|
+
/**
|
|
1598
|
+
* Clone the client with a new (partial) configuration.
|
|
1599
|
+
*
|
|
1600
|
+
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
1601
|
+
*/
|
|
1602
|
+
withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
|
|
1603
|
+
/**
|
|
1604
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1605
|
+
*
|
|
1606
|
+
* @param query - GROQ-query to perform
|
|
1607
|
+
*/
|
|
1608
|
+
fetch<
|
|
1609
|
+
R = Any,
|
|
1610
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
1611
|
+
const G extends string = string,
|
|
1612
|
+
>(query: G, params?: Q | QueryWithoutParams): Observable<ClientReturn<G, R>>
|
|
1613
|
+
/**
|
|
1614
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1615
|
+
*
|
|
1616
|
+
* @param query - GROQ-query to perform
|
|
1617
|
+
* @param params - Optional query parameters
|
|
1618
|
+
* @param options - Optional request options
|
|
1619
|
+
*/
|
|
1620
|
+
fetch<
|
|
1621
|
+
R = Any,
|
|
1622
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1623
|
+
const G extends string = string,
|
|
1624
|
+
>(
|
|
1625
|
+
query: G,
|
|
1626
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1627
|
+
options?: FilteredResponseQueryOptions,
|
|
1628
|
+
): Observable<ClientReturn<G, R>>
|
|
1629
|
+
/**
|
|
1630
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1631
|
+
*
|
|
1632
|
+
* @param query - GROQ-query to perform
|
|
1633
|
+
* @param params - Optional query parameters
|
|
1634
|
+
* @param options - Request options
|
|
1635
|
+
*/
|
|
1636
|
+
fetch<
|
|
1637
|
+
R = Any,
|
|
1638
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1639
|
+
const G extends string = string,
|
|
1640
|
+
>(
|
|
1641
|
+
query: string,
|
|
1642
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1643
|
+
options: UnfilteredResponseQueryOptions,
|
|
1644
|
+
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
1645
|
+
/**
|
|
1646
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1647
|
+
*
|
|
1648
|
+
* @param query - GROQ-query to perform
|
|
1649
|
+
* @param params - Optional query parameters
|
|
1650
|
+
* @param options - Request options
|
|
1651
|
+
*/
|
|
1652
|
+
fetch<
|
|
1653
|
+
R = Any,
|
|
1654
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1655
|
+
const G extends string = string,
|
|
1656
|
+
>(
|
|
1657
|
+
query: G,
|
|
1658
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1659
|
+
options: UnfilteredResponseWithoutQuery,
|
|
1660
|
+
): Observable<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
1661
|
+
/**
|
|
1662
|
+
* Fetch a single document with the given ID.
|
|
1663
|
+
*
|
|
1664
|
+
* @param id - Document ID to fetch
|
|
1665
|
+
* @param options - Request options
|
|
1666
|
+
*/
|
|
1667
|
+
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
1668
|
+
id: string,
|
|
1669
|
+
options?: {
|
|
1670
|
+
tag?: string
|
|
1671
|
+
},
|
|
1672
|
+
): Observable<SanityDocument<R> | undefined>
|
|
1673
|
+
/**
|
|
1674
|
+
* Fetch multiple documents in one request.
|
|
1675
|
+
* Should be used sparingly - performing a query is usually a better option.
|
|
1676
|
+
* The order/position of documents is preserved based on the original array of IDs.
|
|
1677
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1678
|
+
*
|
|
1679
|
+
* @param ids - Document IDs to fetch
|
|
1680
|
+
* @param options - Request options
|
|
1681
|
+
*/
|
|
1682
|
+
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
1683
|
+
ids: string[],
|
|
1684
|
+
options?: {
|
|
1685
|
+
tag?: string
|
|
1686
|
+
},
|
|
1687
|
+
): Observable<(SanityDocument<R> | null)[]>
|
|
1688
|
+
/**
|
|
1689
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1690
|
+
* Returns an observable that resolves to the created document.
|
|
1691
|
+
*
|
|
1692
|
+
* @param document - Document to create
|
|
1693
|
+
* @param options - Mutation options
|
|
1694
|
+
*/
|
|
1695
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1696
|
+
document: SanityDocumentStub<R>,
|
|
1697
|
+
options: FirstDocumentMutationOptions,
|
|
1698
|
+
): Observable<SanityDocument<R>>
|
|
1699
|
+
/**
|
|
1700
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1701
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
1702
|
+
*
|
|
1703
|
+
* @param document - Document to create
|
|
1704
|
+
* @param options - Mutation options
|
|
1705
|
+
*/
|
|
1706
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1707
|
+
document: SanityDocumentStub<R>,
|
|
1708
|
+
options: AllDocumentsMutationOptions,
|
|
1709
|
+
): Observable<SanityDocument<R>[]>
|
|
1710
|
+
/**
|
|
1711
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1712
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1713
|
+
*
|
|
1714
|
+
* @param document - Document to create
|
|
1715
|
+
* @param options - Mutation options
|
|
1716
|
+
*/
|
|
1717
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1718
|
+
document: SanityDocumentStub<R>,
|
|
1719
|
+
options: FirstDocumentIdMutationOptions,
|
|
1720
|
+
): Observable<SingleMutationResult>
|
|
1721
|
+
/**
|
|
1722
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1723
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1724
|
+
*
|
|
1725
|
+
* @param document - Document to create
|
|
1726
|
+
* @param options - Mutation options
|
|
1727
|
+
*/
|
|
1728
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1729
|
+
document: SanityDocumentStub<R>,
|
|
1730
|
+
options: AllDocumentIdsMutationOptions,
|
|
1731
|
+
): Observable<MultipleMutationResult>
|
|
1732
|
+
/**
|
|
1733
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1734
|
+
* Returns an observable that resolves to the created document.
|
|
1735
|
+
*
|
|
1736
|
+
* @param document - Document to create
|
|
1737
|
+
* @param options - Mutation options
|
|
1738
|
+
*/
|
|
1739
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
1740
|
+
document: SanityDocumentStub<R>,
|
|
1741
|
+
options?: BaseMutationOptions,
|
|
1742
|
+
): Observable<SanityDocument<R>>
|
|
1743
|
+
/**
|
|
1744
|
+
* Create a document if no document with the same ID already exists.
|
|
1745
|
+
* Returns an observable that resolves to the created document.
|
|
1746
|
+
*
|
|
1747
|
+
* @param document - Document to create
|
|
1748
|
+
* @param options - Mutation options
|
|
1749
|
+
*/
|
|
1750
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1751
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1752
|
+
options: FirstDocumentMutationOptions,
|
|
1753
|
+
): Observable<SanityDocument<R>>
|
|
1754
|
+
/**
|
|
1755
|
+
* Create a document if no document with the same ID already exists.
|
|
1756
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
1757
|
+
*
|
|
1758
|
+
* @param document - Document to create
|
|
1759
|
+
* @param options - Mutation options
|
|
1760
|
+
*/
|
|
1761
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1762
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1763
|
+
options: AllDocumentsMutationOptions,
|
|
1764
|
+
): Observable<SanityDocument<R>[]>
|
|
1765
|
+
/**
|
|
1766
|
+
* Create a document if no document with the same ID already exists.
|
|
1767
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1768
|
+
*
|
|
1769
|
+
* @param document - Document to create
|
|
1770
|
+
* @param options - Mutation options
|
|
1771
|
+
*/
|
|
1772
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1773
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1774
|
+
options: FirstDocumentIdMutationOptions,
|
|
1775
|
+
): Observable<SingleMutationResult>
|
|
1776
|
+
/**
|
|
1777
|
+
* Create a document if no document with the same ID already exists.
|
|
1778
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1779
|
+
*
|
|
1780
|
+
* @param document - Document to create
|
|
1781
|
+
* @param options - Mutation options
|
|
1782
|
+
*/
|
|
1783
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1784
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1785
|
+
options: AllDocumentIdsMutationOptions,
|
|
1786
|
+
): Observable<MultipleMutationResult>
|
|
1787
|
+
/**
|
|
1788
|
+
* Create a document if no document with the same ID already exists.
|
|
1789
|
+
* Returns an observable that resolves to the created document.
|
|
1790
|
+
*
|
|
1791
|
+
* @param document - Document to create
|
|
1792
|
+
* @param options - Mutation options
|
|
1793
|
+
*/
|
|
1794
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
1795
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1796
|
+
options?: BaseMutationOptions,
|
|
1797
|
+
): Observable<SanityDocument<R>>
|
|
1798
|
+
/**
|
|
1799
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1800
|
+
* Returns an observable that resolves to the created document.
|
|
1801
|
+
*
|
|
1802
|
+
* @param document - Document to either create or replace
|
|
1803
|
+
* @param options - Mutation options
|
|
1804
|
+
*/
|
|
1805
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1806
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1807
|
+
options: FirstDocumentMutationOptions,
|
|
1808
|
+
): Observable<SanityDocument<R>>
|
|
1809
|
+
/**
|
|
1810
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1811
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
1812
|
+
*
|
|
1813
|
+
* @param document - Document to either create or replace
|
|
1814
|
+
* @param options - Mutation options
|
|
1815
|
+
*/
|
|
1816
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1817
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1818
|
+
options: AllDocumentsMutationOptions,
|
|
1819
|
+
): Observable<SanityDocument<R>[]>
|
|
1820
|
+
/**
|
|
1821
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1822
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
1823
|
+
*
|
|
1824
|
+
* @param document - Document to either create or replace
|
|
1825
|
+
* @param options - Mutation options
|
|
1826
|
+
*/
|
|
1827
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1828
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1829
|
+
options: FirstDocumentIdMutationOptions,
|
|
1830
|
+
): Observable<SingleMutationResult>
|
|
1831
|
+
/**
|
|
1832
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1833
|
+
* Returns an observable that resolves to a mutation result object containing the created document ID.
|
|
1834
|
+
*
|
|
1835
|
+
* @param document - Document to either create or replace
|
|
1836
|
+
* @param options - Mutation options
|
|
1837
|
+
*/
|
|
1838
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1839
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1840
|
+
options: AllDocumentIdsMutationOptions,
|
|
1841
|
+
): Observable<MultipleMutationResult>
|
|
1842
|
+
/**
|
|
1843
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1844
|
+
* Returns an observable that resolves to the created document.
|
|
1845
|
+
*
|
|
1846
|
+
* @param document - Document to either create or replace
|
|
1847
|
+
* @param options - Mutation options
|
|
1848
|
+
*/
|
|
1849
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
1850
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1851
|
+
options?: BaseMutationOptions,
|
|
1852
|
+
): Observable<SanityDocument<R>>
|
|
1853
|
+
/**
|
|
1854
|
+
* Deletes a document with the given document ID.
|
|
1855
|
+
* Returns an observable that resolves to the deleted document.
|
|
1856
|
+
*
|
|
1857
|
+
* @param id - Document ID to delete
|
|
1858
|
+
* @param options - Options for the mutation
|
|
1859
|
+
*/
|
|
1860
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1861
|
+
id: string,
|
|
1862
|
+
options: FirstDocumentMutationOptions,
|
|
1863
|
+
): Observable<SanityDocument<R>>
|
|
1864
|
+
/**
|
|
1865
|
+
* Deletes a document with the given document ID.
|
|
1866
|
+
* Returns an observable that resolves to an array containing the deleted document.
|
|
1867
|
+
*
|
|
1868
|
+
* @param id - Document ID to delete
|
|
1869
|
+
* @param options - Options for the mutation
|
|
1870
|
+
*/
|
|
1871
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1872
|
+
id: string,
|
|
1873
|
+
options: AllDocumentsMutationOptions,
|
|
1874
|
+
): Observable<SanityDocument<R>[]>
|
|
1875
|
+
/**
|
|
1876
|
+
* Deletes a document with the given document ID.
|
|
1877
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
1878
|
+
*
|
|
1879
|
+
* @param id - Document ID to delete
|
|
1880
|
+
* @param options - Options for the mutation
|
|
1881
|
+
*/
|
|
1882
|
+
delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
1883
|
+
/**
|
|
1884
|
+
* Deletes a document with the given document ID.
|
|
1885
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
1886
|
+
*
|
|
1887
|
+
* @param id - Document ID to delete
|
|
1888
|
+
* @param options - Options for the mutation
|
|
1889
|
+
*/
|
|
1890
|
+
delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
1891
|
+
/**
|
|
1892
|
+
* Deletes a document with the given document ID.
|
|
1893
|
+
* Returns an observable that resolves to the deleted document.
|
|
1894
|
+
*
|
|
1895
|
+
* @param id - Document ID to delete
|
|
1896
|
+
* @param options - Options for the mutation
|
|
1897
|
+
*/
|
|
1898
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1899
|
+
id: string,
|
|
1900
|
+
options?: BaseMutationOptions,
|
|
1901
|
+
): Observable<SanityDocument<R>>
|
|
1902
|
+
/**
|
|
1903
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1904
|
+
* Returns an observable that resolves to first deleted document.
|
|
1905
|
+
*
|
|
1906
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1907
|
+
* @param options - Options for the mutation
|
|
1908
|
+
*/
|
|
1909
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1910
|
+
selection: MutationSelection,
|
|
1911
|
+
options: FirstDocumentMutationOptions,
|
|
1912
|
+
): Observable<SanityDocument<R>>
|
|
1913
|
+
/**
|
|
1914
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1915
|
+
* Returns an observable that resolves to an array containing the deleted documents.
|
|
1916
|
+
*
|
|
1917
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1918
|
+
* @param options - Options for the mutation
|
|
1919
|
+
*/
|
|
1920
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1921
|
+
selection: MutationSelection,
|
|
1922
|
+
options: AllDocumentsMutationOptions,
|
|
1923
|
+
): Observable<SanityDocument<R>[]>
|
|
1924
|
+
/**
|
|
1925
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1926
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
|
|
1927
|
+
*
|
|
1928
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1929
|
+
* @param options - Options for the mutation
|
|
1930
|
+
*/
|
|
1931
|
+
delete(
|
|
1932
|
+
selection: MutationSelection,
|
|
1933
|
+
options: FirstDocumentIdMutationOptions,
|
|
1934
|
+
): Observable<SingleMutationResult>
|
|
1935
|
+
/**
|
|
1936
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1937
|
+
* Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
|
|
1938
|
+
*
|
|
1939
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1940
|
+
* @param options - Options for the mutation
|
|
1941
|
+
*/
|
|
1942
|
+
delete(
|
|
1943
|
+
selection: MutationSelection,
|
|
1944
|
+
options: AllDocumentIdsMutationOptions,
|
|
1945
|
+
): Observable<MultipleMutationResult>
|
|
1946
|
+
/**
|
|
1947
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1948
|
+
* Returns an observable that resolves to first deleted document.
|
|
1949
|
+
*
|
|
1950
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1951
|
+
* @param options - Options for the mutation
|
|
1952
|
+
*/
|
|
1953
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
1954
|
+
selection: MutationSelection,
|
|
1955
|
+
options?: BaseMutationOptions,
|
|
1956
|
+
): Observable<SanityDocument<R>>
|
|
1957
|
+
/**
|
|
1958
|
+
* Perform mutation operations against the configured dataset
|
|
1959
|
+
* Returns an observable that resolves to the first mutated document.
|
|
1960
|
+
*
|
|
1961
|
+
* @param operations - Mutation operations to execute
|
|
1962
|
+
* @param options - Mutation options
|
|
1963
|
+
*/
|
|
1964
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1965
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1966
|
+
options: FirstDocumentMutationOptions,
|
|
1967
|
+
): Observable<SanityDocument<R>>
|
|
1968
|
+
/**
|
|
1969
|
+
* Perform mutation operations against the configured dataset.
|
|
1970
|
+
* Returns an observable that resolves to an array of the mutated documents.
|
|
1971
|
+
*
|
|
1972
|
+
* @param operations - Mutation operations to execute
|
|
1973
|
+
* @param options - Mutation options
|
|
1974
|
+
*/
|
|
1975
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1976
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1977
|
+
options: AllDocumentsMutationOptions,
|
|
1978
|
+
): Observable<SanityDocument<R>[]>
|
|
1979
|
+
/**
|
|
1980
|
+
* Perform mutation operations against the configured dataset
|
|
1981
|
+
* Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
1982
|
+
*
|
|
1983
|
+
* @param operations - Mutation operations to execute
|
|
1984
|
+
* @param options - Mutation options
|
|
1985
|
+
*/
|
|
1986
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1987
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1988
|
+
options: FirstDocumentIdMutationOptions,
|
|
1989
|
+
): Observable<SingleMutationResult>
|
|
1990
|
+
/**
|
|
1991
|
+
* Perform mutation operations against the configured dataset
|
|
1992
|
+
* Returns an observable that resolves to a mutation result object containing the mutated document IDs.
|
|
1993
|
+
*
|
|
1994
|
+
* @param operations - Mutation operations to execute
|
|
1995
|
+
* @param options - Mutation options
|
|
1996
|
+
*/
|
|
1997
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
1998
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
1999
|
+
options: AllDocumentIdsMutationOptions,
|
|
2000
|
+
): Observable<MultipleMutationResult>
|
|
2001
|
+
/**
|
|
2002
|
+
* Perform mutation operations against the configured dataset
|
|
2003
|
+
* Returns an observable that resolves to the first mutated document.
|
|
2004
|
+
*
|
|
2005
|
+
* @param operations - Mutation operations to execute
|
|
2006
|
+
* @param options - Mutation options
|
|
2007
|
+
*/
|
|
2008
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2009
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
2010
|
+
options?: BaseMutationOptions,
|
|
2011
|
+
): Observable<SanityDocument<R>>
|
|
2012
|
+
/**
|
|
2013
|
+
* Create a new buildable patch of operations to perform
|
|
2014
|
+
*
|
|
2015
|
+
* @param documentId - Document ID to patch
|
|
2016
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2017
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2018
|
+
*/
|
|
2019
|
+
patch(documentId: string, operations?: PatchOperations): ObservablePatch
|
|
2020
|
+
/**
|
|
2021
|
+
* Create a new buildable patch of operations to perform
|
|
2022
|
+
*
|
|
2023
|
+
* @param documentIds - Array of document IDs to patch
|
|
2024
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2025
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2026
|
+
*/
|
|
2027
|
+
patch(documentIds: string[], operations?: PatchOperations): ObservablePatch
|
|
2028
|
+
/**
|
|
2029
|
+
* Create a new buildable patch of operations to perform
|
|
2030
|
+
*
|
|
2031
|
+
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
2032
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2033
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2034
|
+
*/
|
|
2035
|
+
patch(selection: MutationSelection, operations?: PatchOperations): ObservablePatch
|
|
2036
|
+
/**
|
|
2037
|
+
* Create a new transaction of mutations
|
|
2038
|
+
*
|
|
2039
|
+
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
2040
|
+
*/
|
|
2041
|
+
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
2042
|
+
operations?: Mutation<R>[],
|
|
2043
|
+
): ObservableTransaction
|
|
2044
|
+
/**
|
|
2045
|
+
* Perform action operations against the configured dataset
|
|
2046
|
+
*
|
|
2047
|
+
* @param operations - Action operation(s) to execute
|
|
2048
|
+
* @param options - Action options
|
|
2049
|
+
*/
|
|
2050
|
+
action(
|
|
2051
|
+
operations: Action | Action[],
|
|
2052
|
+
options?: BaseActionOptions,
|
|
2053
|
+
): Observable<SingleActionResult | MultipleActionResult>
|
|
2054
|
+
/**
|
|
2055
|
+
* Perform an HTTP request against the Sanity API
|
|
2056
|
+
*
|
|
2057
|
+
* @param options - Request options
|
|
2058
|
+
*/
|
|
2059
|
+
request<R = Any>(options: RawRequestOptions): Observable<R>
|
|
2060
|
+
/**
|
|
2061
|
+
* Get a Sanity API URL for the URI provided
|
|
2062
|
+
*
|
|
2063
|
+
* @param uri - URI/path to build URL for
|
|
2064
|
+
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
2065
|
+
*/
|
|
2066
|
+
getUrl(uri: string, canUseCdn?: boolean): string
|
|
2067
|
+
/**
|
|
2068
|
+
* Get a Sanity API URL for the data operation and path provided
|
|
2069
|
+
*
|
|
2070
|
+
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
2071
|
+
* @param path - Path to append after the operation
|
|
2072
|
+
*/
|
|
2073
|
+
getDataUrl(operation: string, path?: string): string
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
/**
|
|
2077
|
+
* @deprecated -- Use `import {ObservableSanityClient} from '@sanity/client'` instead
|
|
2078
|
+
* @public
|
|
2079
|
+
*/
|
|
2080
|
+
export declare class ObservableSanityStegaClient extends ObservableSanityClient {}
|
|
2081
|
+
|
|
2082
|
+
/** @public */
|
|
2083
|
+
export declare class ObservableTransaction extends BaseTransaction {
|
|
2084
|
+
#private
|
|
2085
|
+
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
2086
|
+
/**
|
|
2087
|
+
* Clones the transaction
|
|
2088
|
+
*/
|
|
2089
|
+
clone(): ObservableTransaction
|
|
2090
|
+
/**
|
|
2091
|
+
* Commit the transaction, returning an observable that produces the first mutated document
|
|
2092
|
+
*
|
|
2093
|
+
* @param options - Options for the mutation operation
|
|
2094
|
+
*/
|
|
2095
|
+
commit<R extends Record<string, Any>>(
|
|
2096
|
+
options: TransactionFirstDocumentMutationOptions,
|
|
2097
|
+
): Observable<SanityDocument<R>>
|
|
2098
|
+
/**
|
|
2099
|
+
* Commit the transaction, returning an observable that produces an array of the mutated documents
|
|
2100
|
+
*
|
|
2101
|
+
* @param options - Options for the mutation operation
|
|
2102
|
+
*/
|
|
2103
|
+
commit<R extends Record<string, Any>>(
|
|
2104
|
+
options: TransactionAllDocumentsMutationOptions,
|
|
2105
|
+
): Observable<SanityDocument<R>[]>
|
|
2106
|
+
/**
|
|
2107
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2108
|
+
*
|
|
2109
|
+
* @param options - Options for the mutation operation
|
|
2110
|
+
*/
|
|
2111
|
+
commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
2112
|
+
/**
|
|
2113
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2114
|
+
*
|
|
2115
|
+
* @param options - Options for the mutation operation
|
|
2116
|
+
*/
|
|
2117
|
+
commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
2118
|
+
/**
|
|
2119
|
+
* Commit the transaction, returning an observable that produces a mutation result object
|
|
2120
|
+
*
|
|
2121
|
+
* @param options - Options for the mutation operation
|
|
2122
|
+
*/
|
|
2123
|
+
commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>
|
|
2124
|
+
/**
|
|
2125
|
+
* Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
|
|
2126
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2127
|
+
*
|
|
2128
|
+
* @param documentId - Document ID to perform the patch operation on
|
|
2129
|
+
* @param patchOps - Operations to perform, or a builder function
|
|
2130
|
+
*/
|
|
2131
|
+
patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this
|
|
2132
|
+
/**
|
|
2133
|
+
* Adds the given patch instance to the transaction.
|
|
2134
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
2135
|
+
*
|
|
2136
|
+
* @param patch - ObservablePatch to execute
|
|
2137
|
+
*/
|
|
2138
|
+
patch(patch: ObservablePatch): this
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
/** @public */
|
|
2142
|
+
export declare class ObservableUsersClient {
|
|
2143
|
+
#private
|
|
2144
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
2145
|
+
/**
|
|
2146
|
+
* Fetch a user by user ID
|
|
2147
|
+
*
|
|
2148
|
+
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
2149
|
+
*/
|
|
2150
|
+
getById<T extends 'me' | string>(
|
|
2151
|
+
id: T,
|
|
2152
|
+
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
/**
|
|
2156
|
+
* The listener connection has been established
|
|
2157
|
+
* note: it's usually a better option to use the 'welcome' event
|
|
2158
|
+
* @public
|
|
2159
|
+
*/
|
|
2160
|
+
export declare type OpenEvent = {
|
|
2161
|
+
type: 'open'
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
/** @public */
|
|
2165
|
+
export declare class Patch extends BasePatch {
|
|
2166
|
+
#private
|
|
2167
|
+
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
2168
|
+
/**
|
|
2169
|
+
* Clones the patch
|
|
2170
|
+
*/
|
|
2171
|
+
clone(): Patch
|
|
2172
|
+
/**
|
|
2173
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2174
|
+
*
|
|
2175
|
+
* @param options - Options for the mutation operation
|
|
2176
|
+
*/
|
|
2177
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2178
|
+
options: FirstDocumentMutationOptions,
|
|
2179
|
+
): Promise<SanityDocument<R>>
|
|
2180
|
+
/**
|
|
2181
|
+
* Commit the patch, returning a promise that resolves to an array of the mutated documents
|
|
2182
|
+
*
|
|
2183
|
+
* @param options - Options for the mutation operation
|
|
2184
|
+
*/
|
|
2185
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2186
|
+
options: AllDocumentsMutationOptions,
|
|
2187
|
+
): Promise<SanityDocument<R>[]>
|
|
2188
|
+
/**
|
|
2189
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2190
|
+
*
|
|
2191
|
+
* @param options - Options for the mutation operation
|
|
2192
|
+
*/
|
|
2193
|
+
commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2194
|
+
/**
|
|
2195
|
+
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
2196
|
+
*
|
|
2197
|
+
* @param options - Options for the mutation operation
|
|
2198
|
+
*/
|
|
2199
|
+
commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
2200
|
+
/**
|
|
2201
|
+
* Commit the patch, returning a promise that resolves to the first patched document
|
|
2202
|
+
*
|
|
2203
|
+
* @param options - Options for the mutation operation
|
|
2204
|
+
*/
|
|
2205
|
+
commit<R extends Record<string, Any> = Record<string, Any>>(
|
|
2206
|
+
options?: BaseMutationOptions,
|
|
2207
|
+
): Promise<SanityDocument<R>>
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
/** @public */
|
|
2211
|
+
export declare type PatchBuilder = (patch: Patch) => Patch
|
|
2212
|
+
|
|
2213
|
+
/** @internal */
|
|
2214
|
+
export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
2215
|
+
|
|
2216
|
+
/** @internal */
|
|
2217
|
+
export declare interface PatchOperations {
|
|
2218
|
+
set?: {
|
|
2219
|
+
[key: string]: Any
|
|
2220
|
+
}
|
|
2221
|
+
setIfMissing?: {
|
|
2222
|
+
[key: string]: Any
|
|
2223
|
+
}
|
|
2224
|
+
diffMatchPatch?: {
|
|
2225
|
+
[key: string]: Any
|
|
2226
|
+
}
|
|
2227
|
+
unset?: string[]
|
|
2228
|
+
inc?: {
|
|
2229
|
+
[key: string]: number
|
|
2230
|
+
}
|
|
2231
|
+
dec?: {
|
|
2232
|
+
[key: string]: number
|
|
2233
|
+
}
|
|
2234
|
+
insert?: InsertPatch
|
|
2235
|
+
ifRevisionID?: string
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
/** @internal */
|
|
2239
|
+
export declare type PatchSelection = string | string[] | MutationSelection
|
|
2240
|
+
|
|
2241
|
+
/** @public */
|
|
2242
|
+
declare interface ProgressEvent_2 {
|
|
2243
|
+
type: 'progress'
|
|
2244
|
+
stage: 'upload' | 'download'
|
|
2245
|
+
percent: number
|
|
2246
|
+
total?: number
|
|
2247
|
+
loaded?: number
|
|
2248
|
+
lengthComputable: boolean
|
|
2249
|
+
}
|
|
2250
|
+
export {ProgressEvent_2 as ProgressEvent}
|
|
2251
|
+
|
|
2252
|
+
/** @internal */
|
|
2253
|
+
export declare class ProjectsClient {
|
|
2254
|
+
#private
|
|
2255
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
2256
|
+
/**
|
|
2257
|
+
* Fetch a list of projects the authenticated user has access to.
|
|
2258
|
+
*
|
|
2259
|
+
* @param options - Options for the list request
|
|
2260
|
+
* @param options.includeMembers - Whether to include members in the response (default: true)
|
|
2261
|
+
*/
|
|
2262
|
+
list(options?: {includeMembers?: true}): Promise<SanityProject[]>
|
|
2263
|
+
list(options?: {includeMembers?: false}): Promise<Omit<SanityProject, 'members'>[]>
|
|
2264
|
+
/**
|
|
2265
|
+
* Fetch a project by project ID
|
|
2266
|
+
*
|
|
2267
|
+
* @param projectId - ID of the project to fetch
|
|
2268
|
+
*/
|
|
2269
|
+
getById(projectId: string): Promise<SanityProject>
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* Publishes a draft document.
|
|
2274
|
+
* If a published version of the document already exists this is replaced by the current draft document.
|
|
2275
|
+
* In either case the draft document is deleted.
|
|
2276
|
+
* The optional revision id parameters can be used for optimistic locking to ensure
|
|
2277
|
+
* that the draft and/or published versions of the document have not been changed by another client.
|
|
2278
|
+
*
|
|
2279
|
+
* @public
|
|
2280
|
+
*/
|
|
2281
|
+
export declare type PublishAction = {
|
|
2282
|
+
actionType: 'sanity.action.document.publish'
|
|
2283
|
+
/**
|
|
2284
|
+
* Draft document ID to publish
|
|
2285
|
+
*/
|
|
2286
|
+
draftId: string
|
|
2287
|
+
/**
|
|
2288
|
+
* Draft revision ID to match
|
|
2289
|
+
*/
|
|
2290
|
+
ifDraftRevisionId?: string
|
|
2291
|
+
/**
|
|
2292
|
+
* Published document ID to replace
|
|
2293
|
+
*/
|
|
2294
|
+
publishedId: string
|
|
2295
|
+
/**
|
|
2296
|
+
* Published revision ID to match
|
|
2297
|
+
*/
|
|
2298
|
+
ifPublishedRevisionId?: string
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
/** @public */
|
|
2302
|
+
export declare type QueryOptions =
|
|
2303
|
+
| FilteredResponseQueryOptions
|
|
2304
|
+
| UnfilteredResponseQueryOptions
|
|
2305
|
+
| UnfilteredResponseWithoutQuery
|
|
2306
|
+
|
|
2307
|
+
/** @public */
|
|
2308
|
+
export declare interface QueryParams {
|
|
2309
|
+
[key: string]: any
|
|
2310
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2311
|
+
body?: never
|
|
2312
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2313
|
+
cache?: 'next' extends keyof RequestInit ? never : any
|
|
2314
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2315
|
+
filterResponse?: never
|
|
2316
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2317
|
+
headers?: never
|
|
2318
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2319
|
+
method?: never
|
|
2320
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2321
|
+
next?: 'next' extends keyof RequestInit ? never : any
|
|
2322
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2323
|
+
perspective?: never
|
|
2324
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2325
|
+
query?: never
|
|
2326
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2327
|
+
resultSourceMap?: never
|
|
2328
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2329
|
+
returnQuery?: never
|
|
2330
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2331
|
+
signal?: never
|
|
2332
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2333
|
+
stega?: never
|
|
2334
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2335
|
+
tag?: never
|
|
2336
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2337
|
+
timeout?: never
|
|
2338
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2339
|
+
token?: never
|
|
2340
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2341
|
+
useCdn?: never
|
|
2342
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2343
|
+
lastLiveEventId?: never
|
|
2344
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
2345
|
+
cacheMode?: never
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
/**
|
|
2349
|
+
* This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.
|
|
2350
|
+
* @public
|
|
2351
|
+
*/
|
|
2352
|
+
export declare type QueryWithoutParams = Record<string, never> | undefined
|
|
2353
|
+
|
|
2354
|
+
/** @public */
|
|
2355
|
+
export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
2356
|
+
|
|
2357
|
+
/** @public */
|
|
2358
|
+
export declare interface RawQueryResponse<R> {
|
|
2359
|
+
query: string
|
|
2360
|
+
ms: number
|
|
2361
|
+
result: R
|
|
2362
|
+
resultSourceMap?: ContentSourceMap
|
|
2363
|
+
/** Requires `apiVersion` to be `2021-03-26` or later. */
|
|
2364
|
+
syncTags?: SyncTag[]
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
/** @internal */
|
|
2368
|
+
export declare interface RawRequestOptions {
|
|
2369
|
+
url?: string
|
|
2370
|
+
uri?: string
|
|
2371
|
+
method?: string
|
|
2372
|
+
token?: string
|
|
2373
|
+
json?: boolean
|
|
2374
|
+
tag?: string
|
|
2375
|
+
useGlobalApi?: boolean
|
|
2376
|
+
withCredentials?: boolean
|
|
2377
|
+
query?: {
|
|
2378
|
+
[key: string]: string | string[]
|
|
2379
|
+
}
|
|
2380
|
+
headers?: {
|
|
2381
|
+
[key: string]: string
|
|
2382
|
+
}
|
|
2383
|
+
timeout?: number
|
|
2384
|
+
proxy?: string
|
|
2385
|
+
body?: Any
|
|
2386
|
+
maxRedirects?: number
|
|
2387
|
+
signal?: AbortSignal
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
/**
|
|
2391
|
+
* The listener has been disconnected, and a reconnect attempt is scheduled.
|
|
2392
|
+
*
|
|
2393
|
+
* @public
|
|
2394
|
+
*/
|
|
2395
|
+
export declare type ReconnectEvent = {
|
|
2396
|
+
type: 'reconnect'
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
/** @public */
|
|
2400
|
+
export declare type ReleaseId = `r${string}`
|
|
2401
|
+
|
|
2402
|
+
/**
|
|
2403
|
+
* Replaces an existing draft document.
|
|
2404
|
+
* At least one of the draft or published versions of the document must exist.
|
|
2405
|
+
*
|
|
2406
|
+
* @public
|
|
2407
|
+
*/
|
|
2408
|
+
export declare type ReplaceDraftAction = {
|
|
2409
|
+
actionType: 'sanity.action.document.replaceDraft'
|
|
2410
|
+
/**
|
|
2411
|
+
* Published document ID to create draft from, if draft does not exist
|
|
2412
|
+
*/
|
|
2413
|
+
publishedId: string
|
|
2414
|
+
/**
|
|
2415
|
+
* Document to create if it does not already exist. Requires `_id` and `_type` properties.
|
|
2416
|
+
*/
|
|
2417
|
+
attributes: IdentifiedSanityDocumentStub
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
/**
|
|
2421
|
+
* @deprecated -- Use `import {requester} from '@sanity/client'` instead
|
|
2422
|
+
* @public
|
|
2423
|
+
*/
|
|
2424
|
+
export declare const requester: Requester
|
|
2425
|
+
|
|
2426
|
+
/** @internal */
|
|
2427
|
+
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
2428
|
+
url?: string
|
|
2429
|
+
uri?: string
|
|
2430
|
+
canUseCdn?: boolean
|
|
2431
|
+
useCdn?: boolean
|
|
2432
|
+
tag?: string
|
|
2433
|
+
returnQuery?: boolean
|
|
2434
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2435
|
+
perspective?: ClientPerspective
|
|
2436
|
+
lastLiveEventId?: string
|
|
2437
|
+
cacheMode?: 'noStale'
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
/** @public */
|
|
2441
|
+
export declare interface RequestOptions {
|
|
2442
|
+
timeout?: number
|
|
2443
|
+
token?: string
|
|
2444
|
+
tag?: string
|
|
2445
|
+
headers?: Record<string, string>
|
|
2446
|
+
method?: string
|
|
2447
|
+
query?: Any
|
|
2448
|
+
body?: Any
|
|
2449
|
+
signal?: AbortSignal
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
/** @alpha */
|
|
2453
|
+
export declare type ResolveStudioUrl = (
|
|
2454
|
+
sourceDocument: ContentSourceMapDocuments_2[number],
|
|
2455
|
+
) => StudioUrl
|
|
2456
|
+
|
|
2457
|
+
/** @public */
|
|
2458
|
+
export declare interface ResponseEvent<T = unknown> {
|
|
2459
|
+
type: 'response'
|
|
2460
|
+
body: T
|
|
2461
|
+
url: string
|
|
2462
|
+
method: string
|
|
2463
|
+
statusCode: number
|
|
2464
|
+
statusMessage?: string
|
|
2465
|
+
headers: Record<string, string>
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
/** @public */
|
|
2469
|
+
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
2470
|
+
perspective?: ClientPerspective
|
|
2471
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
2472
|
+
returnQuery?: boolean
|
|
2473
|
+
useCdn?: boolean
|
|
2474
|
+
stega?: boolean | StegaConfig
|
|
2475
|
+
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
2476
|
+
next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
|
|
2477
|
+
lastLiveEventId?: string | string[] | null
|
|
2478
|
+
/**
|
|
2479
|
+
* When set to `noStale`, APICDN will not return a cached response if the content is stale.
|
|
2480
|
+
* Tradeoff between latency and freshness of content.
|
|
2481
|
+
*
|
|
2482
|
+
* Only to be used with live content queries and when useCdn is true.
|
|
2483
|
+
*/
|
|
2484
|
+
cacheMode?: 'noStale'
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2487
|
+
/** @internal */
|
|
2488
|
+
export declare interface SanityAssetDocument extends SanityDocument {
|
|
2489
|
+
url: string
|
|
2490
|
+
path: string
|
|
2491
|
+
size: number
|
|
2492
|
+
assetId: string
|
|
2493
|
+
mimeType: string
|
|
2494
|
+
sha1hash: string
|
|
2495
|
+
extension: string
|
|
2496
|
+
uploadId?: string
|
|
2497
|
+
originalFilename?: string
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
/** @public */
|
|
2501
|
+
export declare class SanityClient {
|
|
2502
|
+
#private
|
|
2503
|
+
assets: AssetsClient
|
|
2504
|
+
datasets: DatasetsClient
|
|
2505
|
+
live: LiveClient
|
|
2506
|
+
projects: ProjectsClient
|
|
2507
|
+
users: UsersClient
|
|
2508
|
+
/**
|
|
2509
|
+
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
2510
|
+
*/
|
|
2511
|
+
observable: ObservableSanityClient
|
|
2512
|
+
/**
|
|
2513
|
+
* Instance properties
|
|
2514
|
+
*/
|
|
2515
|
+
listen: typeof _listen
|
|
2516
|
+
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
2517
|
+
/**
|
|
2518
|
+
* Clone the client - returns a new instance
|
|
2519
|
+
*/
|
|
2520
|
+
clone(): SanityClient
|
|
2521
|
+
/**
|
|
2522
|
+
* Returns the current client configuration
|
|
2523
|
+
*/
|
|
2524
|
+
config(): InitializedClientConfig
|
|
2525
|
+
/**
|
|
2526
|
+
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
2527
|
+
*/
|
|
2528
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
2529
|
+
/**
|
|
2530
|
+
* Clone the client with a new (partial) configuration.
|
|
2531
|
+
*
|
|
2532
|
+
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
2533
|
+
*/
|
|
2534
|
+
withConfig(newConfig?: Partial<ClientConfig>): SanityClient
|
|
2535
|
+
/**
|
|
2536
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2537
|
+
*
|
|
2538
|
+
* @param query - GROQ-query to perform
|
|
2539
|
+
*/
|
|
2540
|
+
fetch<
|
|
2541
|
+
R = Any,
|
|
2542
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
2543
|
+
const G extends string = string,
|
|
2544
|
+
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
2545
|
+
/**
|
|
2546
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2547
|
+
*
|
|
2548
|
+
* @param query - GROQ-query to perform
|
|
2549
|
+
* @param params - Optional query parameters
|
|
2550
|
+
* @param options - Optional request options
|
|
2551
|
+
*/
|
|
2552
|
+
fetch<
|
|
2553
|
+
R = Any,
|
|
2554
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2555
|
+
const G extends string = string,
|
|
2556
|
+
>(
|
|
2557
|
+
query: G,
|
|
2558
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2559
|
+
options?: FilteredResponseQueryOptions,
|
|
2560
|
+
): Promise<ClientReturn<G, R>>
|
|
2561
|
+
/**
|
|
2562
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2563
|
+
*
|
|
2564
|
+
* @param query - GROQ-query to perform
|
|
2565
|
+
* @param params - Optional query parameters
|
|
2566
|
+
* @param options - Request options
|
|
2567
|
+
*/
|
|
2568
|
+
fetch<
|
|
2569
|
+
R = Any,
|
|
2570
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2571
|
+
const G extends string = string,
|
|
2572
|
+
>(
|
|
2573
|
+
query: G,
|
|
2574
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2575
|
+
options: UnfilteredResponseQueryOptions,
|
|
2576
|
+
): Promise<RawQueryResponse<ClientReturn<G, R>>>
|
|
2577
|
+
/**
|
|
2578
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2579
|
+
*
|
|
2580
|
+
* @param query - GROQ-query to perform
|
|
2581
|
+
* @param params - Optional query parameters
|
|
2582
|
+
* @param options - Request options
|
|
2583
|
+
*/
|
|
2584
|
+
fetch<
|
|
2585
|
+
R = Any,
|
|
2586
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2587
|
+
const G extends string = string,
|
|
2588
|
+
>(
|
|
2589
|
+
query: G,
|
|
2590
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2591
|
+
options: UnfilteredResponseWithoutQuery,
|
|
2592
|
+
): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
2593
|
+
/**
|
|
2594
|
+
* Fetch a single document with the given ID.
|
|
2595
|
+
*
|
|
2596
|
+
* @param id - Document ID to fetch
|
|
2597
|
+
* @param options - Request options
|
|
2598
|
+
*/
|
|
2599
|
+
getDocument<R extends Record<string, Any> = Record<string, Any>>(
|
|
2600
|
+
id: string,
|
|
2601
|
+
options?: {
|
|
2602
|
+
signal?: AbortSignal
|
|
2603
|
+
tag?: string
|
|
2604
|
+
},
|
|
2605
|
+
): Promise<SanityDocument<R> | undefined>
|
|
2606
|
+
/**
|
|
2607
|
+
* Fetch multiple documents in one request.
|
|
2608
|
+
* Should be used sparingly - performing a query is usually a better option.
|
|
2609
|
+
* The order/position of documents is preserved based on the original array of IDs.
|
|
2610
|
+
* If any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
2611
|
+
*
|
|
2612
|
+
* @param ids - Document IDs to fetch
|
|
2613
|
+
* @param options - Request options
|
|
2614
|
+
*/
|
|
2615
|
+
getDocuments<R extends Record<string, Any> = Record<string, Any>>(
|
|
2616
|
+
ids: string[],
|
|
2617
|
+
options?: {
|
|
2618
|
+
signal?: AbortSignal
|
|
2619
|
+
tag?: string
|
|
2620
|
+
},
|
|
2621
|
+
): Promise<(SanityDocument<R> | null)[]>
|
|
2622
|
+
/**
|
|
2623
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2624
|
+
* Returns a promise that resolves to the created document.
|
|
2625
|
+
*
|
|
2626
|
+
* @param document - Document to create
|
|
2627
|
+
* @param options - Mutation options
|
|
2628
|
+
*/
|
|
2629
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2630
|
+
document: SanityDocumentStub<R>,
|
|
2631
|
+
options: FirstDocumentMutationOptions,
|
|
2632
|
+
): Promise<SanityDocument<R>>
|
|
2633
|
+
/**
|
|
2634
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2635
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
2636
|
+
*
|
|
2637
|
+
* @param document - Document to create
|
|
2638
|
+
* @param options - Mutation options
|
|
2639
|
+
*/
|
|
2640
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2641
|
+
document: SanityDocumentStub<R>,
|
|
2642
|
+
options: AllDocumentsMutationOptions,
|
|
2643
|
+
): Promise<SanityDocument<R>[]>
|
|
2644
|
+
/**
|
|
2645
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2646
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2647
|
+
*
|
|
2648
|
+
* @param document - Document to create
|
|
2649
|
+
* @param options - Mutation options
|
|
2650
|
+
*/
|
|
2651
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2652
|
+
document: SanityDocumentStub<R>,
|
|
2653
|
+
options: FirstDocumentIdMutationOptions,
|
|
2654
|
+
): Promise<SingleMutationResult>
|
|
2655
|
+
/**
|
|
2656
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2657
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2658
|
+
*
|
|
2659
|
+
* @param document - Document to create
|
|
2660
|
+
* @param options - Mutation options
|
|
2661
|
+
*/
|
|
2662
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2663
|
+
document: SanityDocumentStub<R>,
|
|
2664
|
+
options: AllDocumentIdsMutationOptions,
|
|
2665
|
+
): Promise<MultipleMutationResult>
|
|
2666
|
+
/**
|
|
2667
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
2668
|
+
* Returns a promise that resolves to the created document.
|
|
2669
|
+
*
|
|
2670
|
+
* @param document - Document to create
|
|
2671
|
+
* @param options - Mutation options
|
|
2672
|
+
*/
|
|
2673
|
+
create<R extends Record<string, Any> = Record<string, Any>>(
|
|
2674
|
+
document: SanityDocumentStub<R>,
|
|
2675
|
+
options?: BaseMutationOptions,
|
|
2676
|
+
): Promise<SanityDocument<R>>
|
|
2677
|
+
/**
|
|
2678
|
+
* Create a document if no document with the same ID already exists.
|
|
2679
|
+
* Returns a promise that resolves to the created document.
|
|
2680
|
+
*
|
|
2681
|
+
* @param document - Document to create
|
|
2682
|
+
* @param options - Mutation options
|
|
2683
|
+
*/
|
|
2684
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2685
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2686
|
+
options: FirstDocumentMutationOptions,
|
|
2687
|
+
): Promise<SanityDocument<R>>
|
|
2688
|
+
/**
|
|
2689
|
+
* Create a document if no document with the same ID already exists.
|
|
2690
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
2691
|
+
*
|
|
2692
|
+
* @param document - Document to create
|
|
2693
|
+
* @param options - Mutation options
|
|
2694
|
+
*/
|
|
2695
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2696
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2697
|
+
options: AllDocumentsMutationOptions,
|
|
2698
|
+
): Promise<SanityDocument<R>[]>
|
|
2699
|
+
/**
|
|
2700
|
+
* Create a document if no document with the same ID already exists.
|
|
2701
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2702
|
+
*
|
|
2703
|
+
* @param document - Document to create
|
|
2704
|
+
* @param options - Mutation options
|
|
2705
|
+
*/
|
|
2706
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2707
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2708
|
+
options: FirstDocumentIdMutationOptions,
|
|
2709
|
+
): Promise<SingleMutationResult>
|
|
2710
|
+
/**
|
|
2711
|
+
* Create a document if no document with the same ID already exists.
|
|
2712
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2713
|
+
*
|
|
2714
|
+
* @param document - Document to create
|
|
2715
|
+
* @param options - Mutation options
|
|
2716
|
+
*/
|
|
2717
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2718
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2719
|
+
options: AllDocumentIdsMutationOptions,
|
|
2720
|
+
): Promise<MultipleMutationResult>
|
|
2721
|
+
/**
|
|
2722
|
+
* Create a document if no document with the same ID already exists.
|
|
2723
|
+
* Returns a promise that resolves to the created document.
|
|
2724
|
+
*
|
|
2725
|
+
* @param document - Document to create
|
|
2726
|
+
* @param options - Mutation options
|
|
2727
|
+
*/
|
|
2728
|
+
createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(
|
|
2729
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2730
|
+
options?: BaseMutationOptions,
|
|
2731
|
+
): Promise<SanityDocument<R>>
|
|
2732
|
+
/**
|
|
2733
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2734
|
+
* Returns a promise that resolves to the created document.
|
|
2735
|
+
*
|
|
2736
|
+
* @param document - Document to either create or replace
|
|
2737
|
+
* @param options - Mutation options
|
|
2738
|
+
*/
|
|
2739
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2740
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2741
|
+
options: FirstDocumentMutationOptions,
|
|
2742
|
+
): Promise<SanityDocument<R>>
|
|
2743
|
+
/**
|
|
2744
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2745
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
2746
|
+
*
|
|
2747
|
+
* @param document - Document to either create or replace
|
|
2748
|
+
* @param options - Mutation options
|
|
2749
|
+
*/
|
|
2750
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2751
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2752
|
+
options: AllDocumentsMutationOptions,
|
|
2753
|
+
): Promise<SanityDocument<R>[]>
|
|
2754
|
+
/**
|
|
2755
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2756
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
2757
|
+
*
|
|
2758
|
+
* @param document - Document to either create or replace
|
|
2759
|
+
* @param options - Mutation options
|
|
2760
|
+
*/
|
|
2761
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2762
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2763
|
+
options: FirstDocumentIdMutationOptions,
|
|
2764
|
+
): Promise<SingleMutationResult>
|
|
2765
|
+
/**
|
|
2766
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2767
|
+
* Returns a promise that resolves to a mutation result object containing the created document ID.
|
|
2768
|
+
*
|
|
2769
|
+
* @param document - Document to either create or replace
|
|
2770
|
+
* @param options - Mutation options
|
|
2771
|
+
*/
|
|
2772
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2773
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2774
|
+
options: AllDocumentIdsMutationOptions,
|
|
2775
|
+
): Promise<MultipleMutationResult>
|
|
2776
|
+
/**
|
|
2777
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
2778
|
+
* Returns a promise that resolves to the created document.
|
|
2779
|
+
*
|
|
2780
|
+
* @param document - Document to either create or replace
|
|
2781
|
+
* @param options - Mutation options
|
|
2782
|
+
*/
|
|
2783
|
+
createOrReplace<R extends Record<string, Any> = Record<string, Any>>(
|
|
2784
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
2785
|
+
options?: BaseMutationOptions,
|
|
2786
|
+
): Promise<SanityDocument<R>>
|
|
2787
|
+
/**
|
|
2788
|
+
* Deletes a document with the given document ID.
|
|
2789
|
+
* Returns a promise that resolves to the deleted document.
|
|
2790
|
+
*
|
|
2791
|
+
* @param id - Document ID to delete
|
|
2792
|
+
* @param options - Options for the mutation
|
|
2793
|
+
*/
|
|
2794
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2795
|
+
id: string,
|
|
2796
|
+
options: FirstDocumentMutationOptions,
|
|
2797
|
+
): Promise<SanityDocument<R>>
|
|
2798
|
+
/**
|
|
2799
|
+
* Deletes a document with the given document ID.
|
|
2800
|
+
* Returns a promise that resolves to an array containing the deleted document.
|
|
2801
|
+
*
|
|
2802
|
+
* @param id - Document ID to delete
|
|
2803
|
+
* @param options - Options for the mutation
|
|
2804
|
+
*/
|
|
2805
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2806
|
+
id: string,
|
|
2807
|
+
options: AllDocumentsMutationOptions,
|
|
2808
|
+
): Promise<SanityDocument<R>[]>
|
|
2809
|
+
/**
|
|
2810
|
+
* Deletes a document with the given document ID.
|
|
2811
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
2812
|
+
*
|
|
2813
|
+
* @param id - Document ID to delete
|
|
2814
|
+
* @param options - Options for the mutation
|
|
2815
|
+
*/
|
|
2816
|
+
delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
2817
|
+
/**
|
|
2818
|
+
* Deletes a document with the given document ID.
|
|
2819
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
2820
|
+
*
|
|
2821
|
+
* @param id - Document ID to delete
|
|
2822
|
+
* @param options - Options for the mutation
|
|
2823
|
+
*/
|
|
2824
|
+
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
2825
|
+
/**
|
|
2826
|
+
* Deletes a document with the given document ID.
|
|
2827
|
+
* Returns a promise that resolves to the deleted document.
|
|
2828
|
+
*
|
|
2829
|
+
* @param id - Document ID to delete
|
|
2830
|
+
* @param options - Options for the mutation
|
|
2831
|
+
*/
|
|
2832
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2833
|
+
id: string,
|
|
2834
|
+
options?: BaseMutationOptions,
|
|
2835
|
+
): Promise<SanityDocument<R>>
|
|
2836
|
+
/**
|
|
2837
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2838
|
+
* Returns a promise that resolves to first deleted document.
|
|
2839
|
+
*
|
|
2840
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2841
|
+
* @param options - Options for the mutation
|
|
2842
|
+
*/
|
|
2843
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2844
|
+
selection: MutationSelection,
|
|
2845
|
+
options: FirstDocumentMutationOptions,
|
|
2846
|
+
): Promise<SanityDocument<R>>
|
|
2847
|
+
/**
|
|
2848
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2849
|
+
* Returns a promise that resolves to an array containing the deleted documents.
|
|
2850
|
+
*
|
|
2851
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2852
|
+
* @param options - Options for the mutation
|
|
2853
|
+
*/
|
|
2854
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2855
|
+
selection: MutationSelection,
|
|
2856
|
+
options: AllDocumentsMutationOptions,
|
|
2857
|
+
): Promise<SanityDocument<R>[]>
|
|
2858
|
+
/**
|
|
2859
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2860
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
|
|
2861
|
+
*
|
|
2862
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2863
|
+
* @param options - Options for the mutation
|
|
2864
|
+
*/
|
|
2865
|
+
delete(
|
|
2866
|
+
selection: MutationSelection,
|
|
2867
|
+
options: FirstDocumentIdMutationOptions,
|
|
2868
|
+
): Promise<SingleMutationResult>
|
|
60
2869
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* Then the `sourcePath` for `result.slug` would be `['slug', 'current']`.
|
|
2870
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2871
|
+
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
64
2872
|
*
|
|
2873
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2874
|
+
* @param options - Options for the mutation
|
|
65
2875
|
*/
|
|
66
|
-
|
|
2876
|
+
delete(
|
|
2877
|
+
selection: MutationSelection,
|
|
2878
|
+
options: AllDocumentIdsMutationOptions,
|
|
2879
|
+
): Promise<MultipleMutationResult>
|
|
67
2880
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
2881
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
2882
|
+
* Returns a promise that resolves to first deleted document.
|
|
2883
|
+
*
|
|
2884
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
2885
|
+
* @param options - Options for the mutation
|
|
73
2886
|
*/
|
|
74
|
-
|
|
2887
|
+
delete<R extends Record<string, Any> = Record<string, Any>>(
|
|
2888
|
+
selection: MutationSelection,
|
|
2889
|
+
options?: BaseMutationOptions,
|
|
2890
|
+
): Promise<SanityDocument<R>>
|
|
75
2891
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* The `resultPath` for `result.slug` would be `['slug']`, while `sourcePath` will be `['slug', 'current']`.
|
|
2892
|
+
* Perform mutation operations against the configured dataset
|
|
2893
|
+
* Returns a promise that resolves to the first mutated document.
|
|
2894
|
+
*
|
|
2895
|
+
* @param operations - Mutation operations to execute
|
|
2896
|
+
* @param options - Mutation options
|
|
82
2897
|
*/
|
|
83
|
-
|
|
2898
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2899
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
2900
|
+
options: FirstDocumentMutationOptions,
|
|
2901
|
+
): Promise<SanityDocument<R>>
|
|
84
2902
|
/**
|
|
85
|
-
*
|
|
2903
|
+
* Perform mutation operations against the configured dataset.
|
|
2904
|
+
* Returns a promise that resolves to an array of the mutated documents.
|
|
2905
|
+
*
|
|
2906
|
+
* @param operations - Mutation operations to execute
|
|
2907
|
+
* @param options - Mutation options
|
|
86
2908
|
*/
|
|
87
|
-
|
|
2909
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2910
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
2911
|
+
options: AllDocumentsMutationOptions,
|
|
2912
|
+
): Promise<SanityDocument<R>[]>
|
|
88
2913
|
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
2914
|
+
* Perform mutation operations against the configured dataset
|
|
2915
|
+
* Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
2916
|
+
*
|
|
2917
|
+
* @param operations - Mutation operations to execute
|
|
2918
|
+
* @param options - Mutation options
|
|
2919
|
+
*/
|
|
2920
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2921
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
2922
|
+
options: FirstDocumentIdMutationOptions,
|
|
2923
|
+
): Promise<SingleMutationResult>
|
|
2924
|
+
/**
|
|
2925
|
+
* Perform mutation operations against the configured dataset
|
|
2926
|
+
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
2927
|
+
*
|
|
2928
|
+
* @param operations - Mutation operations to execute
|
|
2929
|
+
* @param options - Mutation options
|
|
2930
|
+
*/
|
|
2931
|
+
mutate<R extends Record<string, Any>>(
|
|
2932
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
2933
|
+
options: AllDocumentIdsMutationOptions,
|
|
2934
|
+
): Promise<MultipleMutationResult>
|
|
2935
|
+
/**
|
|
2936
|
+
* Perform mutation operations against the configured dataset
|
|
2937
|
+
* Returns a promise that resolves to the first mutated document.
|
|
2938
|
+
*
|
|
2939
|
+
* @param operations - Mutation operations to execute
|
|
2940
|
+
* @param options - Mutation options
|
|
2941
|
+
*/
|
|
2942
|
+
mutate<R extends Record<string, Any> = Record<string, Any>>(
|
|
2943
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
2944
|
+
options?: BaseMutationOptions,
|
|
2945
|
+
): Promise<SanityDocument<R>>
|
|
2946
|
+
/**
|
|
2947
|
+
* Create a new buildable patch of operations to perform
|
|
2948
|
+
*
|
|
2949
|
+
* @param documentId - Document ID to patch
|
|
2950
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2951
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2952
|
+
*/
|
|
2953
|
+
patch(documentId: string, operations?: PatchOperations): Patch
|
|
2954
|
+
/**
|
|
2955
|
+
* Create a new buildable patch of operations to perform
|
|
2956
|
+
*
|
|
2957
|
+
* @param documentIds - Array of document IDs to patch
|
|
2958
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2959
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2960
|
+
*/
|
|
2961
|
+
patch(documentIds: string[], operations?: PatchOperations): Patch
|
|
2962
|
+
/**
|
|
2963
|
+
* Create a new buildable patch of operations to perform
|
|
2964
|
+
*
|
|
2965
|
+
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
2966
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
2967
|
+
* @returns Patch instance - call `.commit()` to perform the operations defined
|
|
2968
|
+
*/
|
|
2969
|
+
patch(selection: MutationSelection, operations?: PatchOperations): Patch
|
|
2970
|
+
/**
|
|
2971
|
+
* Create a new transaction of mutations
|
|
2972
|
+
*
|
|
2973
|
+
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
2974
|
+
*/
|
|
2975
|
+
transaction<R extends Record<string, Any> = Record<string, Any>>(
|
|
2976
|
+
operations?: Mutation<R>[],
|
|
2977
|
+
): Transaction
|
|
2978
|
+
/**
|
|
2979
|
+
* Perform action operations against the configured dataset
|
|
2980
|
+
* Returns a promise that resolves to the transaction result
|
|
2981
|
+
*
|
|
2982
|
+
* @param operations - Action operation(s) to execute
|
|
2983
|
+
* @param options - Action options
|
|
2984
|
+
*/
|
|
2985
|
+
action(
|
|
2986
|
+
operations: Action | Action[],
|
|
2987
|
+
options?: BaseActionOptions,
|
|
2988
|
+
): Promise<SingleActionResult | MultipleActionResult>
|
|
2989
|
+
/**
|
|
2990
|
+
* Perform a request against the Sanity API
|
|
2991
|
+
* NOTE: Only use this for Sanity API endpoints, not for your own APIs!
|
|
2992
|
+
*
|
|
2993
|
+
* @param options - Request options
|
|
2994
|
+
* @returns Promise resolving to the response body
|
|
2995
|
+
*/
|
|
2996
|
+
request<R = Any>(options: RawRequestOptions): Promise<R>
|
|
2997
|
+
/**
|
|
2998
|
+
* Perform an HTTP request a `/data` sub-endpoint
|
|
2999
|
+
* NOTE: Considered internal, thus marked as deprecated. Use `request` instead.
|
|
3000
|
+
*
|
|
3001
|
+
* @deprecated - Use `request()` or your own HTTP library instead
|
|
3002
|
+
* @param endpoint - Endpoint to hit (mutate, query etc)
|
|
3003
|
+
* @param body - Request body
|
|
3004
|
+
* @param options - Request options
|
|
3005
|
+
* @internal
|
|
3006
|
+
*/
|
|
3007
|
+
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>
|
|
3008
|
+
/**
|
|
3009
|
+
* Get a Sanity API URL for the URI provided
|
|
3010
|
+
*
|
|
3011
|
+
* @param uri - URI/path to build URL for
|
|
3012
|
+
* @param canUseCdn - Whether or not to allow using the API CDN for this route
|
|
3013
|
+
*/
|
|
3014
|
+
getUrl(uri: string, canUseCdn?: boolean): string
|
|
3015
|
+
/**
|
|
3016
|
+
* Get a Sanity API URL for the data operation and path provided
|
|
3017
|
+
*
|
|
3018
|
+
* @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)
|
|
3019
|
+
* @param path - Path to append after the operation
|
|
3020
|
+
*/
|
|
3021
|
+
getDataUrl(operation: string, path?: string): string
|
|
3022
|
+
}
|
|
106
3023
|
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
3024
|
+
/** @internal */
|
|
3025
|
+
export declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = {
|
|
3026
|
+
[P in keyof T]: T[P]
|
|
3027
|
+
} & {
|
|
3028
|
+
_id: string
|
|
3029
|
+
_rev: string
|
|
3030
|
+
_type: string
|
|
3031
|
+
_createdAt: string
|
|
3032
|
+
_updatedAt: string
|
|
3033
|
+
/**
|
|
3034
|
+
* Present when `perspective` is set to `previewDrafts`
|
|
3035
|
+
*/
|
|
3036
|
+
_originalId?: string
|
|
3037
|
+
}
|
|
112
3038
|
|
|
113
3039
|
/** @public */
|
|
114
|
-
export declare type
|
|
115
|
-
|
|
3040
|
+
export declare type SanityDocumentStub<T extends Record<string, Any> = Record<string, Any>> = {
|
|
3041
|
+
[P in keyof T]: T[P]
|
|
3042
|
+
} & {
|
|
3043
|
+
_type: string
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
/** @internal */
|
|
3047
|
+
export declare interface SanityImageAssetDocument extends SanityAssetDocument {
|
|
3048
|
+
metadata: {
|
|
3049
|
+
_type: 'sanity.imageMetadata'
|
|
3050
|
+
hasAlpha: boolean
|
|
3051
|
+
isOpaque: boolean
|
|
3052
|
+
lqip?: string
|
|
3053
|
+
blurHash?: string
|
|
3054
|
+
dimensions: {
|
|
3055
|
+
_type: 'sanity.imageDimensions'
|
|
3056
|
+
aspectRatio: number
|
|
3057
|
+
height: number
|
|
3058
|
+
width: number
|
|
3059
|
+
}
|
|
3060
|
+
palette?: {
|
|
3061
|
+
_type: 'sanity.imagePalette'
|
|
3062
|
+
darkMuted?: SanityImagePalette
|
|
3063
|
+
darkVibrant?: SanityImagePalette
|
|
3064
|
+
dominant?: SanityImagePalette
|
|
3065
|
+
lightMuted?: SanityImagePalette
|
|
3066
|
+
lightVibrant?: SanityImagePalette
|
|
3067
|
+
muted?: SanityImagePalette
|
|
3068
|
+
vibrant?: SanityImagePalette
|
|
3069
|
+
}
|
|
3070
|
+
image?: {
|
|
3071
|
+
_type: 'sanity.imageExifTags'
|
|
3072
|
+
[key: string]: Any
|
|
3073
|
+
}
|
|
3074
|
+
exif?: {
|
|
3075
|
+
_type: 'sanity.imageExifMetadata'
|
|
3076
|
+
[key: string]: Any
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
/** @internal */
|
|
3082
|
+
export declare interface SanityImagePalette {
|
|
3083
|
+
background: string
|
|
3084
|
+
foreground: string
|
|
3085
|
+
population: number
|
|
3086
|
+
title: string
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
/** @internal */
|
|
3090
|
+
export declare interface SanityProject {
|
|
3091
|
+
id: string
|
|
3092
|
+
displayName: string
|
|
3093
|
+
/**
|
|
3094
|
+
* @deprecated Use the `/user-applications` endpoint instead, which lists all deployed studios/applications
|
|
3095
|
+
* @see https://www.sanity.io/help/studio-host-user-applications
|
|
3096
|
+
*/
|
|
3097
|
+
studioHost: string | null
|
|
3098
|
+
organizationId: string | null
|
|
3099
|
+
isBlocked: boolean
|
|
3100
|
+
isDisabled: boolean
|
|
3101
|
+
isDisabledByUser: boolean
|
|
3102
|
+
createdAt: string
|
|
3103
|
+
pendingInvites?: number
|
|
3104
|
+
maxRetentionDays?: number
|
|
3105
|
+
members: SanityProjectMember[]
|
|
3106
|
+
metadata: {
|
|
3107
|
+
cliInitializedAt?: string
|
|
3108
|
+
color?: string
|
|
3109
|
+
/**
|
|
3110
|
+
* @deprecated Use the `/user-applications` endpoint instead, which lists all deployed studios/applications
|
|
3111
|
+
* @see https://www.sanity.io/help/studio-host-user-applications
|
|
3112
|
+
*/
|
|
3113
|
+
externalStudioHost?: string
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
|
|
3117
|
+
/** @internal */
|
|
3118
|
+
export declare interface SanityProjectMember {
|
|
3119
|
+
id: string
|
|
3120
|
+
role: string
|
|
3121
|
+
isRobot: boolean
|
|
3122
|
+
isCurrentUser: boolean
|
|
3123
|
+
}
|
|
116
3124
|
|
|
117
3125
|
/** @public */
|
|
118
|
-
export declare
|
|
119
|
-
| typeof console
|
|
120
|
-
| Partial<
|
|
121
|
-
Pick<typeof console, 'debug' | 'error' | 'groupCollapsed' | 'groupEnd' | 'log' | 'table'>
|
|
122
|
-
>
|
|
3126
|
+
export declare interface SanityQueries {}
|
|
123
3127
|
|
|
124
|
-
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
export declare class ObservableSanityStegaClient extends ObservableSanityClient {}
|
|
3128
|
+
/** @internal */
|
|
3129
|
+
export declare interface SanityReference {
|
|
3130
|
+
_ref: string
|
|
3131
|
+
}
|
|
129
3132
|
|
|
130
3133
|
/**
|
|
131
|
-
* @deprecated -- Use `import {
|
|
3134
|
+
* @deprecated -- Use `import {SanityClient} from '@sanity/client'` instead
|
|
132
3135
|
* @public
|
|
133
3136
|
*/
|
|
134
|
-
export declare
|
|
3137
|
+
export declare class SanityStegaClient extends SanityClient {}
|
|
3138
|
+
|
|
3139
|
+
/** @internal */
|
|
3140
|
+
export declare interface SanityUser {
|
|
3141
|
+
id: string
|
|
3142
|
+
projectId: string
|
|
3143
|
+
displayName: string
|
|
3144
|
+
familyName: string | null
|
|
3145
|
+
givenName: string | null
|
|
3146
|
+
middleName: string | null
|
|
3147
|
+
imageUrl: string | null
|
|
3148
|
+
createdAt: string
|
|
3149
|
+
updatedAt: string
|
|
3150
|
+
isCurrentUser: boolean
|
|
3151
|
+
}
|
|
135
3152
|
|
|
136
|
-
|
|
3153
|
+
/** @public */
|
|
3154
|
+
export declare class ServerError extends Error {
|
|
3155
|
+
response: ErrorProps['response']
|
|
3156
|
+
statusCode: ErrorProps['statusCode']
|
|
3157
|
+
responseBody: ErrorProps['responseBody']
|
|
3158
|
+
details: ErrorProps['details']
|
|
3159
|
+
constructor(res: Any)
|
|
3160
|
+
}
|
|
137
3161
|
|
|
138
3162
|
/**
|
|
139
|
-
* @deprecated -- Use `import {SanityClient} from '@sanity/client'` instead
|
|
140
3163
|
* @public
|
|
141
3164
|
*/
|
|
142
|
-
export declare
|
|
3165
|
+
export declare interface ServerSentEvent<Name extends string> {
|
|
3166
|
+
type: Name
|
|
3167
|
+
id?: string
|
|
3168
|
+
data?: unknown
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
/** @internal */
|
|
3172
|
+
export declare interface SingleActionResult {
|
|
3173
|
+
transactionId: string
|
|
3174
|
+
}
|
|
3175
|
+
|
|
3176
|
+
/** @internal */
|
|
3177
|
+
export declare interface SingleMutationResult {
|
|
3178
|
+
transactionId: string
|
|
3179
|
+
documentId: string
|
|
3180
|
+
results: {
|
|
3181
|
+
id: string
|
|
3182
|
+
operation: MutationOperation
|
|
3183
|
+
}[]
|
|
3184
|
+
}
|
|
143
3185
|
|
|
144
3186
|
/**
|
|
145
3187
|
* Can take a `result` JSON from a `const {result} = client.fetch(query, params, {filterResponse: false})`
|
|
@@ -178,9 +3220,42 @@ export declare interface StegaConfig {
|
|
|
178
3220
|
omitCrossDatasetReferenceData?: boolean
|
|
179
3221
|
}
|
|
180
3222
|
|
|
3223
|
+
/** @public */
|
|
3224
|
+
declare interface StegaConfig_2 {
|
|
3225
|
+
/**
|
|
3226
|
+
* Enable or disable stega encoded strings in query results
|
|
3227
|
+
* ```ts
|
|
3228
|
+
{
|
|
3229
|
+
enabled: process.env.VERCEL_ENV !== 'production'
|
|
3230
|
+
}
|
|
3231
|
+
* ```
|
|
3232
|
+
* @defaultValue `false`
|
|
3233
|
+
*/
|
|
3234
|
+
enabled?: boolean
|
|
3235
|
+
/**
|
|
3236
|
+
* Where the Studio is hosted.
|
|
3237
|
+
* If it's embedded in the app, use the base path for example `/studio`.
|
|
3238
|
+
* Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.
|
|
3239
|
+
*
|
|
3240
|
+
*/
|
|
3241
|
+
studioUrl?: StudioUrl | ResolveStudioUrl
|
|
3242
|
+
filter?: FilterDefault_2
|
|
3243
|
+
/**
|
|
3244
|
+
* Specify a `console.log` compatible logger to see debug logs, which keys are encoded and which are not.
|
|
3245
|
+
*/
|
|
3246
|
+
logger?: Logger_2
|
|
3247
|
+
/**
|
|
3248
|
+
* Set to `true` to omit cross dataset reference specific data from encoded strings
|
|
3249
|
+
*/
|
|
3250
|
+
omitCrossDatasetReferenceData?: boolean
|
|
3251
|
+
}
|
|
3252
|
+
|
|
181
3253
|
/** @public */
|
|
182
3254
|
export declare type StegaConfigRequiredKeys = Extract<keyof StegaConfig, 'enabled'>
|
|
183
3255
|
|
|
3256
|
+
/** @public */
|
|
3257
|
+
declare type StegaConfigRequiredKeys_2 = Extract<keyof StegaConfig_2, 'enabled'>
|
|
3258
|
+
|
|
184
3259
|
/**
|
|
185
3260
|
* Uses `@vercel/stega` to embed edit info JSON into strings in your query result.
|
|
186
3261
|
* The JSON payloads are added using invisible characters so they don't show up visually.
|
|
@@ -189,15 +3264,254 @@ export declare type StegaConfigRequiredKeys = Extract<keyof StegaConfig, 'enable
|
|
|
189
3264
|
*/
|
|
190
3265
|
export declare function stegaEncodeSourceMap<Result = unknown>(
|
|
191
3266
|
result: Result,
|
|
192
|
-
resultSourceMap:
|
|
193
|
-
config:
|
|
3267
|
+
resultSourceMap: ContentSourceMap_2 | undefined,
|
|
3268
|
+
config: InitializedStegaConfig_2,
|
|
194
3269
|
): Result
|
|
195
3270
|
|
|
196
|
-
|
|
3271
|
+
/** @alpha */
|
|
3272
|
+
export declare type StudioBaseRoute = {
|
|
3273
|
+
baseUrl: StudioBaseUrl
|
|
3274
|
+
workspace?: string
|
|
3275
|
+
tool?: string
|
|
3276
|
+
}
|
|
3277
|
+
|
|
3278
|
+
/** @alpha */
|
|
3279
|
+
export declare type StudioBaseUrl =
|
|
3280
|
+
| `/${string}`
|
|
3281
|
+
| `${string}.sanity.studio`
|
|
3282
|
+
| `https://${string}`
|
|
3283
|
+
| string
|
|
3284
|
+
|
|
3285
|
+
/** @alpha */
|
|
3286
|
+
export declare type StudioUrl = StudioBaseUrl | StudioBaseRoute
|
|
3287
|
+
|
|
3288
|
+
/** @public */
|
|
3289
|
+
export declare type SyncTag = `s1:${string}`
|
|
3290
|
+
|
|
3291
|
+
/** @public */
|
|
3292
|
+
export declare class Transaction extends BaseTransaction {
|
|
3293
|
+
#private
|
|
3294
|
+
constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string)
|
|
3295
|
+
/**
|
|
3296
|
+
* Clones the transaction
|
|
3297
|
+
*/
|
|
3298
|
+
clone(): Transaction
|
|
3299
|
+
/**
|
|
3300
|
+
* Commit the transaction, returning a promise that resolves to the first mutated document
|
|
3301
|
+
*
|
|
3302
|
+
* @param options - Options for the mutation operation
|
|
3303
|
+
*/
|
|
3304
|
+
commit<R extends Record<string, Any>>(
|
|
3305
|
+
options: TransactionFirstDocumentMutationOptions,
|
|
3306
|
+
): Promise<SanityDocument<R>>
|
|
3307
|
+
/**
|
|
3308
|
+
* Commit the transaction, returning a promise that resolves to an array of the mutated documents
|
|
3309
|
+
*
|
|
3310
|
+
* @param options - Options for the mutation operation
|
|
3311
|
+
*/
|
|
3312
|
+
commit<R extends Record<string, Any>>(
|
|
3313
|
+
options: TransactionAllDocumentsMutationOptions,
|
|
3314
|
+
): Promise<SanityDocument<R>[]>
|
|
3315
|
+
/**
|
|
3316
|
+
* Commit the transaction, returning a promise that resolves to a mutation result object
|
|
3317
|
+
*
|
|
3318
|
+
* @param options - Options for the mutation operation
|
|
3319
|
+
*/
|
|
3320
|
+
commit(options: TransactionFirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
3321
|
+
/**
|
|
3322
|
+
* Commit the transaction, returning a promise that resolves to a mutation result object
|
|
3323
|
+
*
|
|
3324
|
+
* @param options - Options for the mutation operation
|
|
3325
|
+
*/
|
|
3326
|
+
commit(options: TransactionAllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
3327
|
+
/**
|
|
3328
|
+
* Commit the transaction, returning a promise that resolves to a mutation result object
|
|
3329
|
+
*
|
|
3330
|
+
* @param options - Options for the mutation operation
|
|
3331
|
+
*/
|
|
3332
|
+
commit(options?: BaseMutationOptions): Promise<MultipleMutationResult>
|
|
3333
|
+
/**
|
|
3334
|
+
* Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.
|
|
3335
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
3336
|
+
*
|
|
3337
|
+
* @param documentId - Document ID to perform the patch operation on
|
|
3338
|
+
* @param patchOps - Operations to perform, or a builder function
|
|
3339
|
+
*/
|
|
3340
|
+
patch(documentId: string, patchOps?: PatchBuilder | PatchOperations): this
|
|
3341
|
+
/**
|
|
3342
|
+
* Performs a patch on the given selection. Can either be a builder function or an object of patch operations.
|
|
3343
|
+
*
|
|
3344
|
+
* @param selection - An object with `query` and optional `params`, defining which document(s) to patch
|
|
3345
|
+
* @param patchOps - Operations to perform, or a builder function
|
|
3346
|
+
*/
|
|
3347
|
+
patch(patch: MutationSelection, patchOps?: PatchBuilder | PatchOperations): this
|
|
3348
|
+
/**
|
|
3349
|
+
* Adds the given patch instance to the transaction.
|
|
3350
|
+
* The operation is added to the current transaction, ready to be commited by `commit()`
|
|
3351
|
+
*
|
|
3352
|
+
* @param patch - Patch to execute
|
|
3353
|
+
*/
|
|
3354
|
+
patch(patch: Patch): this
|
|
3355
|
+
}
|
|
3356
|
+
|
|
3357
|
+
/** @internal */
|
|
3358
|
+
export declare type TransactionAllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
3359
|
+
returnFirst?: false
|
|
3360
|
+
returnDocuments?: false
|
|
3361
|
+
}
|
|
3362
|
+
|
|
3363
|
+
/** @internal */
|
|
3364
|
+
export declare type TransactionAllDocumentsMutationOptions = BaseMutationOptions & {
|
|
3365
|
+
returnFirst?: false
|
|
3366
|
+
returnDocuments: true
|
|
3367
|
+
}
|
|
3368
|
+
|
|
3369
|
+
/** @internal */
|
|
3370
|
+
export declare type TransactionFirstDocumentIdMutationOptions = BaseMutationOptions & {
|
|
3371
|
+
returnFirst: true
|
|
3372
|
+
returnDocuments?: false
|
|
3373
|
+
}
|
|
3374
|
+
|
|
3375
|
+
/** @internal */
|
|
3376
|
+
export declare type TransactionFirstDocumentMutationOptions = BaseMutationOptions & {
|
|
3377
|
+
returnFirst: true
|
|
3378
|
+
returnDocuments: true
|
|
3379
|
+
}
|
|
3380
|
+
|
|
3381
|
+
/** @internal */
|
|
3382
|
+
export declare type TransactionMutationOptions =
|
|
3383
|
+
| TransactionFirstDocumentMutationOptions
|
|
3384
|
+
| TransactionFirstDocumentIdMutationOptions
|
|
3385
|
+
| TransactionAllDocumentsMutationOptions
|
|
3386
|
+
| TransactionAllDocumentIdsMutationOptions
|
|
3387
|
+
|
|
3388
|
+
/** @public */
|
|
3389
|
+
export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
3390
|
+
filterResponse: false
|
|
3391
|
+
/**
|
|
3392
|
+
* When `filterResponse` is `false`, `returnQuery` also defaults to `true` for
|
|
3393
|
+
* backwards compatibility (on the client side, not from the content lake API).
|
|
3394
|
+
* Can also explicitly be set to `true`.
|
|
3395
|
+
*/
|
|
3396
|
+
returnQuery?: true
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
/**
|
|
3400
|
+
* When using `filterResponse: false`, but you do not wish to receive back the query from
|
|
3401
|
+
* the content lake API.
|
|
3402
|
+
*
|
|
3403
|
+
* @public
|
|
3404
|
+
*/
|
|
3405
|
+
export declare interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {
|
|
3406
|
+
filterResponse: false
|
|
3407
|
+
returnQuery: false
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3410
|
+
/**
|
|
3411
|
+
* Retract a published document.
|
|
3412
|
+
* If there is no draft version then this is created from the published version.
|
|
3413
|
+
* In either case the published version is deleted.
|
|
3414
|
+
*
|
|
3415
|
+
* @public
|
|
3416
|
+
*/
|
|
3417
|
+
export declare type UnpublishAction = {
|
|
3418
|
+
actionType: 'sanity.action.document.unpublish'
|
|
3419
|
+
/**
|
|
3420
|
+
* Draft document ID to replace the published document with
|
|
3421
|
+
*/
|
|
3422
|
+
draftId: string
|
|
3423
|
+
/**
|
|
3424
|
+
* Published document ID to delete
|
|
3425
|
+
*/
|
|
3426
|
+
publishedId: string
|
|
3427
|
+
}
|
|
3428
|
+
|
|
3429
|
+
export {unstable__adapter}
|
|
3430
|
+
|
|
3431
|
+
export {unstable__environment}
|
|
3432
|
+
|
|
3433
|
+
/** @public */
|
|
3434
|
+
export declare type UploadBody = File | Blob | Buffer | NodeJS.ReadableStream
|
|
3435
|
+
|
|
3436
|
+
/** @public */
|
|
3437
|
+
export declare interface UploadClientConfig {
|
|
3438
|
+
/**
|
|
3439
|
+
* Optional request tag for the upload
|
|
3440
|
+
*/
|
|
3441
|
+
tag?: string
|
|
3442
|
+
/**
|
|
3443
|
+
* Whether or not to preserve the original filename (default: true)
|
|
3444
|
+
*/
|
|
3445
|
+
preserveFilename?: boolean
|
|
3446
|
+
/**
|
|
3447
|
+
* Filename for this file (optional)
|
|
3448
|
+
*/
|
|
3449
|
+
filename?: string
|
|
3450
|
+
/**
|
|
3451
|
+
* Milliseconds to wait before timing the request out
|
|
3452
|
+
*/
|
|
3453
|
+
timeout?: number
|
|
3454
|
+
/**
|
|
3455
|
+
* Mime type of the file
|
|
3456
|
+
*/
|
|
3457
|
+
contentType?: string
|
|
3458
|
+
/**
|
|
3459
|
+
* Array of metadata parts to extract from asset
|
|
3460
|
+
*/
|
|
3461
|
+
extract?: AssetMetadataType[]
|
|
3462
|
+
/**
|
|
3463
|
+
* Optional freeform label for the asset. Generally not used.
|
|
3464
|
+
*/
|
|
3465
|
+
label?: string
|
|
3466
|
+
/**
|
|
3467
|
+
* Optional title for the asset
|
|
3468
|
+
*/
|
|
3469
|
+
title?: string
|
|
3470
|
+
/**
|
|
3471
|
+
* Optional description for the asset
|
|
3472
|
+
*/
|
|
3473
|
+
description?: string
|
|
3474
|
+
/**
|
|
3475
|
+
* The credit to person(s) and/or organization(s) required by the supplier of the asset to be used when published
|
|
3476
|
+
*/
|
|
3477
|
+
creditLine?: string
|
|
3478
|
+
/**
|
|
3479
|
+
* Source data (when the asset is from an external service)
|
|
3480
|
+
*/
|
|
3481
|
+
source?: {
|
|
3482
|
+
/**
|
|
3483
|
+
* The (u)id of the asset within the source, i.e. 'i-f323r1E'
|
|
3484
|
+
*/
|
|
3485
|
+
id: string
|
|
3486
|
+
/**
|
|
3487
|
+
* The name of the source, i.e. 'unsplash'
|
|
3488
|
+
*/
|
|
3489
|
+
name: string
|
|
3490
|
+
/**
|
|
3491
|
+
* A url to where to find the asset, or get more info about it in the source
|
|
3492
|
+
*/
|
|
3493
|
+
url?: string
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
197
3496
|
|
|
198
|
-
|
|
3497
|
+
/** @public */
|
|
3498
|
+
export declare class UsersClient {
|
|
3499
|
+
#private
|
|
3500
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
3501
|
+
/**
|
|
3502
|
+
* Fetch a user by user ID
|
|
3503
|
+
*
|
|
3504
|
+
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
3505
|
+
*/
|
|
3506
|
+
getById<T extends 'me' | string>(id: T): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
3507
|
+
}
|
|
199
3508
|
|
|
200
|
-
|
|
3509
|
+
/**
|
|
3510
|
+
* @internal - it may have breaking changes in any release
|
|
3511
|
+
*/
|
|
3512
|
+
export declare function validateApiPerspective(
|
|
3513
|
+
perspective: unknown,
|
|
3514
|
+
): asserts perspective is ClientPerspective
|
|
201
3515
|
|
|
202
3516
|
/**
|
|
203
3517
|
* Can take a `result` JSON from a `const {result} = client.fetch(query, params, {filterResponse: false})`
|
|
@@ -207,6 +3521,15 @@ export {StudioUrl}
|
|
|
207
3521
|
*/
|
|
208
3522
|
export declare const vercelStegaCleanAll: typeof stegaClean
|
|
209
3523
|
|
|
210
|
-
|
|
3524
|
+
/**
|
|
3525
|
+
* The listener has been established, and will start receiving events.
|
|
3526
|
+
* Note that this is also emitted upon _reconnection_.
|
|
3527
|
+
*
|
|
3528
|
+
* @public
|
|
3529
|
+
*/
|
|
3530
|
+
export declare type WelcomeEvent = {
|
|
3531
|
+
type: 'welcome'
|
|
3532
|
+
listenerName: string
|
|
3533
|
+
}
|
|
211
3534
|
|
|
212
3535
|
export {}
|