@sanity/client 5.0.0-esm.2 → 5.0.0-esm.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/README.md +442 -17
- package/dist/index.browser.cjs +252 -176
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +252 -176
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +253 -177
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +425 -367
- package/dist/index.js +253 -177
- package/dist/index.js.map +1 -1
- package/package.json +32 -29
- package/src/SanityClient.ts +181 -242
- package/src/assets/AssetsClient.ts +14 -12
- package/src/auth/AuthClient.ts +15 -9
- package/src/config.ts +2 -2
- package/src/data/dataMethods.ts +32 -4
- package/src/data/listen.ts +10 -9
- package/src/data/patch.ts +34 -31
- package/src/data/transaction.ts +5 -0
- package/src/datasets/DatasetsClient.ts +75 -57
- package/src/http/errors.ts +2 -0
- package/src/http/request.ts +1 -3
- package/src/index.browser.ts +3 -3
- package/src/index.ts +3 -42
- package/src/projects/ProjectsClient.ts +39 -23
- package/src/types.ts +60 -0
- package/src/users/UsersClient.ts +37 -28
- package/src/validators.ts +4 -2
- package/umd/sanityClient.js +5449 -5396
- package/umd/sanityClient.min.js +12 -12
package/dist/index.d.ts
CHANGED
|
@@ -4,16 +4,19 @@ import {BaseError} from 'make-error'
|
|
|
4
4
|
import {Observable} from 'rxjs'
|
|
5
5
|
import {Requester} from 'get-it'
|
|
6
6
|
|
|
7
|
+
/** @internal */
|
|
7
8
|
export declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
8
9
|
returnFirst: false
|
|
9
10
|
returnDocuments: false
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
/** @internal */
|
|
12
14
|
export declare type AllDocumentsMutationOptions = BaseMutationOptions & {
|
|
13
15
|
returnFirst: false
|
|
14
16
|
returnDocuments?: true
|
|
15
17
|
}
|
|
16
18
|
|
|
19
|
+
/** @public */
|
|
17
20
|
export declare type AssetMetadataType =
|
|
18
21
|
| 'location'
|
|
19
22
|
| 'exif'
|
|
@@ -23,15 +26,16 @@ export declare type AssetMetadataType =
|
|
|
23
26
|
| 'blurhash'
|
|
24
27
|
| 'none'
|
|
25
28
|
|
|
29
|
+
/** @internal */
|
|
26
30
|
export declare class AssetsClient {
|
|
27
31
|
#private
|
|
28
32
|
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
29
33
|
/**
|
|
30
34
|
* Uploads a file asset to the configured dataset
|
|
31
35
|
*
|
|
32
|
-
* @param assetType Asset type (file/image)
|
|
33
|
-
* @param body Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
34
|
-
* @param options Options to use for the upload
|
|
36
|
+
* @param assetType - Asset type (file/image)
|
|
37
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
38
|
+
* @param options - Options to use for the upload
|
|
35
39
|
*/
|
|
36
40
|
upload(
|
|
37
41
|
assetType: 'file',
|
|
@@ -41,9 +45,9 @@ export declare class AssetsClient {
|
|
|
41
45
|
/**
|
|
42
46
|
* Uploads an image asset to the configured dataset
|
|
43
47
|
*
|
|
44
|
-
* @param assetType Asset type (file/image)
|
|
45
|
-
* @param body Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
46
|
-
* @param options Options to use for the upload
|
|
48
|
+
* @param assetType - Asset type (file/image)
|
|
49
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
50
|
+
* @param options - Options to use for the upload
|
|
47
51
|
*/
|
|
48
52
|
upload(
|
|
49
53
|
assetType: 'image',
|
|
@@ -52,100 +56,38 @@ export declare class AssetsClient {
|
|
|
52
56
|
): Promise<SanityImageAssetDocument>
|
|
53
57
|
}
|
|
54
58
|
|
|
59
|
+
/** @internal */
|
|
55
60
|
export declare type AttributeSet = {
|
|
56
61
|
[key: string]: any
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
/** @internal */
|
|
59
65
|
export declare class AuthClient {
|
|
60
66
|
#private
|
|
61
67
|
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
62
68
|
/**
|
|
63
69
|
* Fetch available login providers
|
|
64
70
|
*/
|
|
65
|
-
getLoginProviders
|
|
71
|
+
getLoginProviders(): Promise<AuthProviderResponse>
|
|
66
72
|
/**
|
|
67
73
|
* Revoke the configured session/token
|
|
68
74
|
*/
|
|
69
|
-
logout
|
|
75
|
+
logout(): Promise<void>
|
|
70
76
|
}
|
|
71
77
|
|
|
78
|
+
/** @internal */
|
|
72
79
|
export declare interface AuthProvider {
|
|
73
80
|
name: string
|
|
74
81
|
title: string
|
|
75
82
|
url: string
|
|
76
83
|
}
|
|
77
84
|
|
|
85
|
+
/** @internal */
|
|
78
86
|
export declare type AuthProviderResponse = {
|
|
79
87
|
providers: AuthProvider[]
|
|
80
88
|
}
|
|
81
89
|
|
|
82
|
-
|
|
83
|
-
#private
|
|
84
|
-
client: SanityClient | ObservableSanityClient
|
|
85
|
-
/**
|
|
86
|
-
* Create a new dataset with the given name
|
|
87
|
-
*
|
|
88
|
-
* @param name - Name of the dataset to create
|
|
89
|
-
* @param options - Options for the dataset
|
|
90
|
-
*/
|
|
91
|
-
create(
|
|
92
|
-
this: DatasetsClient,
|
|
93
|
-
name: string,
|
|
94
|
-
options?: {
|
|
95
|
-
aclMode?: DatasetAclMode
|
|
96
|
-
}
|
|
97
|
-
): Promise<DatasetResponse>
|
|
98
|
-
create(
|
|
99
|
-
this: ObservableDatasetsClient,
|
|
100
|
-
name: string,
|
|
101
|
-
options?: {
|
|
102
|
-
aclMode?: DatasetAclMode
|
|
103
|
-
}
|
|
104
|
-
): Observable<DatasetResponse>
|
|
105
|
-
/**
|
|
106
|
-
* Edit a dataset with the given name
|
|
107
|
-
*
|
|
108
|
-
* @param name - Name of the dataset to edit
|
|
109
|
-
* @param options - New options for the dataset
|
|
110
|
-
*/
|
|
111
|
-
edit(
|
|
112
|
-
this: DatasetsClient,
|
|
113
|
-
name: string,
|
|
114
|
-
options?: {
|
|
115
|
-
aclMode?: DatasetAclMode
|
|
116
|
-
}
|
|
117
|
-
): Promise<DatasetResponse>
|
|
118
|
-
edit(
|
|
119
|
-
this: ObservableDatasetsClient,
|
|
120
|
-
name: string,
|
|
121
|
-
options?: {
|
|
122
|
-
aclMode?: DatasetAclMode
|
|
123
|
-
}
|
|
124
|
-
): Observable<DatasetResponse>
|
|
125
|
-
/**
|
|
126
|
-
* Delete a dataset with the given name
|
|
127
|
-
*
|
|
128
|
-
* @param name - Name of the dataset to delete
|
|
129
|
-
*/
|
|
130
|
-
delete(
|
|
131
|
-
this: DatasetsClient,
|
|
132
|
-
name: string
|
|
133
|
-
): Promise<{
|
|
134
|
-
deleted: true
|
|
135
|
-
}>
|
|
136
|
-
delete(
|
|
137
|
-
this: ObservableDatasetsClient,
|
|
138
|
-
name: string
|
|
139
|
-
): Observable<{
|
|
140
|
-
deleted: true
|
|
141
|
-
}>
|
|
142
|
-
/**
|
|
143
|
-
* Fetch a list of datasets for the configured project
|
|
144
|
-
*/
|
|
145
|
-
list(this: DatasetsClient): Promise<DatasetsResponse>
|
|
146
|
-
list(this: ObservableDatasetsClient): Observable<DatasetsResponse>
|
|
147
|
-
}
|
|
148
|
-
|
|
90
|
+
/** @internal */
|
|
149
91
|
export declare type BaseMutationOptions = RequestOptions & {
|
|
150
92
|
visibility?: 'sync' | 'async' | 'deferred'
|
|
151
93
|
returnDocuments?: boolean
|
|
@@ -155,6 +97,7 @@ export declare type BaseMutationOptions = RequestOptions & {
|
|
|
155
97
|
skipCrossDatasetReferenceValidation?: boolean
|
|
156
98
|
}
|
|
157
99
|
|
|
100
|
+
/** @internal */
|
|
158
101
|
export declare class BasePatch {
|
|
159
102
|
protected selection: PatchSelection
|
|
160
103
|
protected operations: PatchOperations
|
|
@@ -163,85 +106,85 @@ export declare class BasePatch {
|
|
|
163
106
|
* DEPRECATED: Don't use.
|
|
164
107
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
165
108
|
*
|
|
166
|
-
* @deprecated
|
|
167
|
-
* @param attrs Attributes to replace
|
|
109
|
+
* @deprecated - Don't use.
|
|
110
|
+
* @param attrs - Attributes to replace
|
|
168
111
|
*/
|
|
169
112
|
replace(attrs: AttributeSet): this
|
|
170
113
|
/**
|
|
171
114
|
* Sets the given attributes to the document. Does NOT merge objects.
|
|
172
115
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
173
116
|
*
|
|
174
|
-
* @param attrs Attributes to set. To set a deep attribute, use JSONMatch, eg: {"nested.prop": "value"}
|
|
117
|
+
* @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
|
|
175
118
|
*/
|
|
176
119
|
set(attrs: AttributeSet): this
|
|
177
120
|
/**
|
|
178
121
|
* Sets the given attributes to the document if they are not currently set. Does NOT merge objects.
|
|
179
122
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
180
123
|
*
|
|
181
|
-
* @param attrs Attributes to set. To set a deep attribute, use JSONMatch, eg: {"nested.prop": "value"}
|
|
124
|
+
* @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\}
|
|
182
125
|
*/
|
|
183
126
|
setIfMissing(attrs: AttributeSet): this
|
|
184
127
|
/**
|
|
185
128
|
* Performs a "diff-match-patch" operation on the string attributes provided.
|
|
186
129
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
187
130
|
*
|
|
188
|
-
* @param attrs Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: {"nested.prop": "dmp"}
|
|
131
|
+
* @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "dmp"\}
|
|
189
132
|
*/
|
|
190
133
|
diffMatchPatch(attrs: AttributeSet): this
|
|
191
134
|
/**
|
|
192
135
|
* Unsets the attribute paths provided.
|
|
193
136
|
* The operation is added to the current patch, ready to be commited by `commit()`
|
|
194
137
|
*
|
|
195
|
-
* @param attrs Attribute paths to unset.
|
|
138
|
+
* @param attrs - Attribute paths to unset.
|
|
196
139
|
*/
|
|
197
140
|
unset(attrs: string[]): this
|
|
198
141
|
/**
|
|
199
142
|
* 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.
|
|
200
143
|
*
|
|
201
|
-
* @param attrs Object of attribute paths to increment, values representing the number to increment by.
|
|
144
|
+
* @param attrs - Object of attribute paths to increment, values representing the number to increment by.
|
|
202
145
|
*/
|
|
203
146
|
inc(attrs: {[key: string]: number}): this
|
|
204
147
|
/**
|
|
205
148
|
* 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.
|
|
206
149
|
*
|
|
207
|
-
* @param attrs Object of attribute paths to decrement, values representing the number to decrement by.
|
|
150
|
+
* @param attrs - Object of attribute paths to decrement, values representing the number to decrement by.
|
|
208
151
|
*/
|
|
209
152
|
dec(attrs: {[key: string]: number}): this
|
|
210
153
|
/**
|
|
211
154
|
* Provides methods for modifying arrays, by inserting, appending and replacing elements via a JSONPath expression.
|
|
212
155
|
*
|
|
213
|
-
* @param at Location to insert at, relative to the given selector, or 'replace' the matched path
|
|
214
|
-
* @param selector JSONPath expression, eg `comments[-1]` or `blocks[_key=="abc123"]`
|
|
215
|
-
* @param items Array of items to insert/replace
|
|
156
|
+
* @param at - Location to insert at, relative to the given selector, or 'replace' the matched path
|
|
157
|
+
* @param selector - JSONPath expression, eg `comments[-1]` or `blocks[_key=="abc123"]`
|
|
158
|
+
* @param items - Array of items to insert/replace
|
|
216
159
|
*/
|
|
217
160
|
insert(at: 'before' | 'after' | 'replace', selector: string, items: any[]): this
|
|
218
161
|
/**
|
|
219
162
|
* Append the given items to the array at the given JSONPath
|
|
220
163
|
*
|
|
221
|
-
* @param selector Attribute/path to append to, eg `comments` or `person.hobbies`
|
|
222
|
-
* @param items Array of items to append to the array
|
|
164
|
+
* @param selector - Attribute/path to append to, eg `comments` or `person.hobbies`
|
|
165
|
+
* @param items - Array of items to append to the array
|
|
223
166
|
*/
|
|
224
167
|
append(selector: string, items: any[]): this
|
|
225
168
|
/**
|
|
226
169
|
* Prepend the given items to the array at the given JSONPath
|
|
227
170
|
*
|
|
228
|
-
* @param selector Attribute/path to prepend to, eg `comments` or `person.hobbies`
|
|
229
|
-
* @param items Array of items to prepend to the array
|
|
171
|
+
* @param selector - Attribute/path to prepend to, eg `comments` or `person.hobbies`
|
|
172
|
+
* @param items - Array of items to prepend to the array
|
|
230
173
|
*/
|
|
231
174
|
prepend(selector: string, items: any[]): this
|
|
232
175
|
/**
|
|
233
176
|
* Change the contents of an array by removing existing elements and/or adding new elements.
|
|
234
177
|
*
|
|
235
|
-
* @param selector Attribute or JSONPath expression for array
|
|
236
|
-
* @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
|
|
237
|
-
* @param deleteCount An integer indicating the number of old array elements to remove.
|
|
238
|
-
* @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.
|
|
178
|
+
* @param selector - Attribute or JSONPath expression for array
|
|
179
|
+
* @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
|
|
180
|
+
* @param deleteCount - An integer indicating the number of old array elements to remove.
|
|
181
|
+
* @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.
|
|
239
182
|
*/
|
|
240
|
-
splice(selector: string, start: number, deleteCount
|
|
183
|
+
splice(selector: string, start: number, deleteCount?: number, items?: any[]): this
|
|
241
184
|
/**
|
|
242
185
|
* Adds a revision clause, preventing the document from being patched if the `_rev` property does not match the given value
|
|
243
186
|
*
|
|
244
|
-
* @param rev Revision to lock the patch to
|
|
187
|
+
* @param rev - Revision to lock the patch to
|
|
245
188
|
*/
|
|
246
189
|
ifRevisionId(rev: string): this
|
|
247
190
|
/**
|
|
@@ -260,22 +203,7 @@ export declare class BasePatch {
|
|
|
260
203
|
protected _set(op: keyof PatchOperations, props: any): this
|
|
261
204
|
}
|
|
262
205
|
|
|
263
|
-
|
|
264
|
-
client: SanityClient | ObservableSanityClient
|
|
265
|
-
/**
|
|
266
|
-
* Fetch a list of projects the authenticated user has access to
|
|
267
|
-
*/
|
|
268
|
-
list(this: ProjectsClient): Promise<SanityProject[]>
|
|
269
|
-
list(this: ObservableProjectsClient): Observable<SanityProject[]>
|
|
270
|
-
/**
|
|
271
|
-
* Fetch a project by project ID
|
|
272
|
-
*
|
|
273
|
-
* @param projectId - ID of the project to fetch
|
|
274
|
-
*/
|
|
275
|
-
getById(this: ProjectsClient, projectId: string): Promise<SanityProject>
|
|
276
|
-
getById(this: ObservableProjectsClient, projectId: string): Observable<SanityProject>
|
|
277
|
-
}
|
|
278
|
-
|
|
206
|
+
/** @internal */
|
|
279
207
|
export declare class BaseTransaction {
|
|
280
208
|
protected operations: Mutation[]
|
|
281
209
|
protected trxId?: string
|
|
@@ -337,28 +265,13 @@ export declare class BaseTransaction {
|
|
|
337
265
|
protected _add(mut: Mutation): this
|
|
338
266
|
}
|
|
339
267
|
|
|
340
|
-
|
|
341
|
-
client: SanityClient | ObservableSanityClient
|
|
342
|
-
/**
|
|
343
|
-
* Fetch a user by user ID
|
|
344
|
-
*
|
|
345
|
-
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
346
|
-
*/
|
|
347
|
-
getById<T extends 'me' | string>(
|
|
348
|
-
this: UsersClient,
|
|
349
|
-
id: T
|
|
350
|
-
): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
351
|
-
getById<T extends 'me' | string>(
|
|
352
|
-
this: ObservableUsersClient,
|
|
353
|
-
id: T
|
|
354
|
-
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
355
|
-
}
|
|
356
|
-
|
|
268
|
+
/** @public */
|
|
357
269
|
export declare type ChannelErrorEvent = {
|
|
358
270
|
type: 'channelError'
|
|
359
271
|
message: string
|
|
360
272
|
}
|
|
361
273
|
|
|
274
|
+
/** @public */
|
|
362
275
|
export declare interface ClientConfig {
|
|
363
276
|
projectId?: string
|
|
364
277
|
dataset?: string
|
|
@@ -382,6 +295,7 @@ export declare interface ClientConfig {
|
|
|
382
295
|
requester?: Requester
|
|
383
296
|
}
|
|
384
297
|
|
|
298
|
+
/** @public */
|
|
385
299
|
export declare class ClientError extends BaseError {
|
|
386
300
|
response: ErrorProps['response']
|
|
387
301
|
statusCode: ErrorProps['statusCode']
|
|
@@ -390,8 +304,10 @@ export declare class ClientError extends BaseError {
|
|
|
390
304
|
constructor(res: any)
|
|
391
305
|
}
|
|
392
306
|
|
|
393
|
-
|
|
307
|
+
/** @public */
|
|
308
|
+
export declare const createClient: (config: ClientConfig) => SanityClient
|
|
394
309
|
|
|
310
|
+
/** @internal */
|
|
395
311
|
export declare interface CurrentSanityUser {
|
|
396
312
|
id: string
|
|
397
313
|
name: string
|
|
@@ -400,28 +316,70 @@ export declare interface CurrentSanityUser {
|
|
|
400
316
|
role: string
|
|
401
317
|
}
|
|
402
318
|
|
|
319
|
+
/** @internal */
|
|
403
320
|
export declare type DatasetAclMode = 'public' | 'private' | 'custom'
|
|
404
321
|
|
|
322
|
+
/** @internal */
|
|
405
323
|
export declare type DatasetResponse = {
|
|
406
324
|
datasetName: string
|
|
407
325
|
aclMode: DatasetAclMode
|
|
408
326
|
}
|
|
409
327
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
328
|
+
/** @internal */
|
|
329
|
+
export declare class DatasetsClient {
|
|
330
|
+
#private
|
|
331
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
332
|
+
/**
|
|
333
|
+
* Create a new dataset with the given name
|
|
334
|
+
*
|
|
335
|
+
* @param name - Name of the dataset to create
|
|
336
|
+
* @param options - Options for the dataset
|
|
337
|
+
*/
|
|
338
|
+
create(
|
|
339
|
+
name: string,
|
|
340
|
+
options?: {
|
|
341
|
+
aclMode?: DatasetAclMode
|
|
342
|
+
}
|
|
343
|
+
): Promise<DatasetResponse>
|
|
344
|
+
/**
|
|
345
|
+
* Edit a dataset with the given name
|
|
346
|
+
*
|
|
347
|
+
* @param name - Name of the dataset to edit
|
|
348
|
+
* @param options - New options for the dataset
|
|
349
|
+
*/
|
|
350
|
+
edit(
|
|
351
|
+
name: string,
|
|
352
|
+
options?: {
|
|
353
|
+
aclMode?: DatasetAclMode
|
|
354
|
+
}
|
|
355
|
+
): Promise<DatasetResponse>
|
|
356
|
+
/**
|
|
357
|
+
* Delete a dataset with the given name
|
|
358
|
+
*
|
|
359
|
+
* @param name - Name of the dataset to delete
|
|
360
|
+
*/
|
|
361
|
+
delete(name: string): Promise<{
|
|
362
|
+
deleted: true
|
|
363
|
+
}>
|
|
364
|
+
/**
|
|
365
|
+
* Fetch a list of datasets for the configured project
|
|
366
|
+
*/
|
|
367
|
+
list(): Promise<DatasetsResponse>
|
|
413
368
|
}
|
|
414
369
|
|
|
370
|
+
/** @internal */
|
|
415
371
|
export declare type DatasetsResponse = {
|
|
416
372
|
name: string
|
|
417
373
|
aclMode: DatasetAclMode
|
|
418
374
|
}[]
|
|
419
375
|
|
|
376
|
+
/** @public */
|
|
420
377
|
export declare type DisconnectEvent = {
|
|
421
378
|
type: 'disconnect'
|
|
422
379
|
reason: string
|
|
423
380
|
}
|
|
424
381
|
|
|
382
|
+
/** @public */
|
|
425
383
|
export declare interface ErrorProps {
|
|
426
384
|
message: string
|
|
427
385
|
response: any
|
|
@@ -430,27 +388,33 @@ export declare interface ErrorProps {
|
|
|
430
388
|
details: any
|
|
431
389
|
}
|
|
432
390
|
|
|
391
|
+
/** @internal */
|
|
433
392
|
export declare type FilteredResponseQueryOptions = RequestOptions & {
|
|
434
393
|
filterResponse?: true
|
|
435
394
|
}
|
|
436
395
|
|
|
396
|
+
/** @internal */
|
|
437
397
|
export declare type FirstDocumentIdMutationOptions = BaseMutationOptions & {
|
|
438
398
|
returnFirst?: true
|
|
439
399
|
returnDocuments: false
|
|
440
400
|
}
|
|
441
401
|
|
|
402
|
+
/** @internal */
|
|
442
403
|
export declare type FirstDocumentMutationOptions = BaseMutationOptions & {
|
|
443
404
|
returnFirst?: true
|
|
444
405
|
returnDocuments?: true
|
|
445
406
|
}
|
|
446
407
|
|
|
408
|
+
/** @public */
|
|
447
409
|
export declare type HttpRequest = {
|
|
448
410
|
defaultRequester: Requester
|
|
449
411
|
(options: RequestOptions, requester: Requester): ReturnType<Requester>
|
|
450
412
|
}
|
|
451
413
|
|
|
414
|
+
/** @public */
|
|
452
415
|
export declare type HttpRequestEvent<T = unknown> = ResponseEvent<T> | ProgressEvent_2
|
|
453
416
|
|
|
417
|
+
/** @public */
|
|
454
418
|
export declare type IdentifiedSanityDocumentStub<
|
|
455
419
|
T extends Record<string, any> = Record<string, any>
|
|
456
420
|
> = {
|
|
@@ -459,6 +423,7 @@ export declare type IdentifiedSanityDocumentStub<
|
|
|
459
423
|
_id: string
|
|
460
424
|
} & SanityDocumentStub
|
|
461
425
|
|
|
426
|
+
/** @public */
|
|
462
427
|
export declare interface InitializedClientConfig extends ClientConfig {
|
|
463
428
|
apiHost: string
|
|
464
429
|
apiVersion: string
|
|
@@ -478,6 +443,7 @@ export declare interface InitializedClientConfig extends ClientConfig {
|
|
|
478
443
|
cdnUrl: string
|
|
479
444
|
}
|
|
480
445
|
|
|
446
|
+
/** @internal */
|
|
481
447
|
export declare type InsertPatch =
|
|
482
448
|
| {
|
|
483
449
|
before: string
|
|
@@ -495,9 +461,9 @@ export declare type InsertPatch =
|
|
|
495
461
|
/**
|
|
496
462
|
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
497
463
|
*
|
|
498
|
-
* @param query GROQ-filter to listen to changes for
|
|
499
|
-
* @param params Optional query parameters
|
|
500
|
-
* @param options Listener options
|
|
464
|
+
* @param query - GROQ-filter to listen to changes for
|
|
465
|
+
* @param params - Optional query parameters
|
|
466
|
+
* @param options - Listener options
|
|
501
467
|
* @internal
|
|
502
468
|
*/
|
|
503
469
|
export declare function _listen<R extends Record<string, any> = Record<string, any>>(
|
|
@@ -509,9 +475,9 @@ export declare function _listen<R extends Record<string, any> = Record<string, a
|
|
|
509
475
|
/**
|
|
510
476
|
* Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.
|
|
511
477
|
*
|
|
512
|
-
* @param query GROQ-filter to listen to changes for
|
|
513
|
-
* @param params Optional query parameters
|
|
514
|
-
* @param options Listener options
|
|
478
|
+
* @param query - GROQ-filter to listen to changes for
|
|
479
|
+
* @param params - Optional query parameters
|
|
480
|
+
* @param options - Listener options
|
|
515
481
|
* @internal
|
|
516
482
|
*/
|
|
517
483
|
export declare function _listen<R extends Record<string, any> = Record<string, any>>(
|
|
@@ -521,6 +487,7 @@ export declare function _listen<R extends Record<string, any> = Record<string, a
|
|
|
521
487
|
options?: ListenOptions
|
|
522
488
|
): Observable<ListenEvent<R>>
|
|
523
489
|
|
|
490
|
+
/** @public */
|
|
524
491
|
export declare type ListenEvent<R extends Record<string, any>> =
|
|
525
492
|
| MutationEvent_2<R>
|
|
526
493
|
| ChannelErrorEvent
|
|
@@ -528,8 +495,10 @@ export declare type ListenEvent<R extends Record<string, any>> =
|
|
|
528
495
|
| ReconnectEvent
|
|
529
496
|
| WelcomeEvent
|
|
530
497
|
|
|
498
|
+
/** @public */
|
|
531
499
|
export declare type ListenEventName = 'mutation' | 'welcome' | 'reconnect'
|
|
532
500
|
|
|
501
|
+
/** @public */
|
|
533
502
|
export declare interface ListenOptions {
|
|
534
503
|
includeResult?: boolean
|
|
535
504
|
includePreviousRevision?: boolean
|
|
@@ -539,6 +508,7 @@ export declare interface ListenOptions {
|
|
|
539
508
|
tag?: string
|
|
540
509
|
}
|
|
541
510
|
|
|
511
|
+
/** @internal */
|
|
542
512
|
export declare interface MultipleMutationResult {
|
|
543
513
|
transactionId: string
|
|
544
514
|
documentIds: string[]
|
|
@@ -548,6 +518,7 @@ export declare interface MultipleMutationResult {
|
|
|
548
518
|
}[]
|
|
549
519
|
}
|
|
550
520
|
|
|
521
|
+
/** @public */
|
|
551
522
|
export declare type Mutation<R extends Record<string, any> = Record<string, any>> =
|
|
552
523
|
| {
|
|
553
524
|
create: SanityDocumentStub<R>
|
|
@@ -565,6 +536,7 @@ export declare type Mutation<R extends Record<string, any> = Record<string, any>
|
|
|
565
536
|
patch: PatchMutationOperation
|
|
566
537
|
}
|
|
567
538
|
|
|
539
|
+
/** @public */
|
|
568
540
|
declare type MutationEvent_2<R extends Record<string, any> = Record<string, any>> = {
|
|
569
541
|
type: 'mutation'
|
|
570
542
|
documentId: string
|
|
@@ -586,8 +558,10 @@ declare type MutationEvent_2<R extends Record<string, any> = Record<string, any>
|
|
|
586
558
|
}
|
|
587
559
|
export {MutationEvent_2 as MutationEvent}
|
|
588
560
|
|
|
561
|
+
/** @internal */
|
|
589
562
|
export declare type MutationOperation = 'create' | 'delete' | 'update' | 'none'
|
|
590
563
|
|
|
564
|
+
/** @internal */
|
|
591
565
|
export declare type MutationSelection =
|
|
592
566
|
| {
|
|
593
567
|
query: string
|
|
@@ -597,15 +571,16 @@ export declare type MutationSelection =
|
|
|
597
571
|
id: string | string[]
|
|
598
572
|
}
|
|
599
573
|
|
|
574
|
+
/** @internal */
|
|
600
575
|
export declare class ObservableAssetsClient {
|
|
601
576
|
#private
|
|
602
577
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
603
578
|
/**
|
|
604
579
|
* Uploads a file asset to the configured dataset
|
|
605
580
|
*
|
|
606
|
-
* @param assetType Asset type (file/image)
|
|
607
|
-
* @param body Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
608
|
-
* @param options Options to use for the upload
|
|
581
|
+
* @param assetType - Asset type (file/image)
|
|
582
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
583
|
+
* @param options - Options to use for the upload
|
|
609
584
|
*/
|
|
610
585
|
upload(
|
|
611
586
|
assetType: 'file',
|
|
@@ -619,9 +594,9 @@ export declare class ObservableAssetsClient {
|
|
|
619
594
|
/**
|
|
620
595
|
* Uploads an image asset to the configured dataset
|
|
621
596
|
*
|
|
622
|
-
* @param assetType Asset type (file/image)
|
|
623
|
-
* @param body Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
624
|
-
* @param options Options to use for the upload
|
|
597
|
+
* @param assetType - Asset type (file/image)
|
|
598
|
+
* @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.
|
|
599
|
+
* @param options - Options to use for the upload
|
|
625
600
|
*/
|
|
626
601
|
upload(
|
|
627
602
|
assetType: 'image',
|
|
@@ -634,24 +609,63 @@ export declare class ObservableAssetsClient {
|
|
|
634
609
|
>
|
|
635
610
|
}
|
|
636
611
|
|
|
612
|
+
/** @internal */
|
|
637
613
|
export declare class ObservableAuthClient {
|
|
638
614
|
#private
|
|
639
615
|
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
640
616
|
/**
|
|
641
617
|
* Fetch available login providers
|
|
642
618
|
*/
|
|
643
|
-
getLoginProviders
|
|
619
|
+
getLoginProviders(): Observable<AuthProviderResponse>
|
|
644
620
|
/**
|
|
645
621
|
* Revoke the configured session/token
|
|
646
622
|
*/
|
|
647
|
-
logout
|
|
623
|
+
logout(): Observable<void>
|
|
648
624
|
}
|
|
649
625
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
626
|
+
/** @internal */
|
|
627
|
+
export declare class ObservableDatasetsClient {
|
|
628
|
+
#private
|
|
629
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
630
|
+
/**
|
|
631
|
+
* Create a new dataset with the given name
|
|
632
|
+
*
|
|
633
|
+
* @param name - Name of the dataset to create
|
|
634
|
+
* @param options - Options for the dataset
|
|
635
|
+
*/
|
|
636
|
+
create(
|
|
637
|
+
name: string,
|
|
638
|
+
options?: {
|
|
639
|
+
aclMode?: DatasetAclMode
|
|
640
|
+
}
|
|
641
|
+
): Observable<DatasetResponse>
|
|
642
|
+
/**
|
|
643
|
+
* Edit a dataset with the given name
|
|
644
|
+
*
|
|
645
|
+
* @param name - Name of the dataset to edit
|
|
646
|
+
* @param options - New options for the dataset
|
|
647
|
+
*/
|
|
648
|
+
edit(
|
|
649
|
+
name: string,
|
|
650
|
+
options?: {
|
|
651
|
+
aclMode?: DatasetAclMode
|
|
652
|
+
}
|
|
653
|
+
): Observable<DatasetResponse>
|
|
654
|
+
/**
|
|
655
|
+
* Delete a dataset with the given name
|
|
656
|
+
*
|
|
657
|
+
* @param name - Name of the dataset to delete
|
|
658
|
+
*/
|
|
659
|
+
delete(name: string): Observable<{
|
|
660
|
+
deleted: true
|
|
661
|
+
}>
|
|
662
|
+
/**
|
|
663
|
+
* Fetch a list of datasets for the configured project
|
|
664
|
+
*/
|
|
665
|
+
list(): Observable<DatasetsResponse>
|
|
653
666
|
}
|
|
654
667
|
|
|
668
|
+
/** @public */
|
|
655
669
|
export declare class ObservablePatch extends BasePatch {
|
|
656
670
|
#private
|
|
657
671
|
constructor(
|
|
@@ -666,7 +680,7 @@ export declare class ObservablePatch extends BasePatch {
|
|
|
666
680
|
/**
|
|
667
681
|
* Commit the patch, returning an observable that produces the first patched document
|
|
668
682
|
*
|
|
669
|
-
* @param options Options for the mutation operation
|
|
683
|
+
* @param options - Options for the mutation operation
|
|
670
684
|
*/
|
|
671
685
|
commit<R extends Record<string, any> = Record<string, any>>(
|
|
672
686
|
options: FirstDocumentMutationOptions
|
|
@@ -674,7 +688,7 @@ export declare class ObservablePatch extends BasePatch {
|
|
|
674
688
|
/**
|
|
675
689
|
* Commit the patch, returning an observable that produces an array of the mutated documents
|
|
676
690
|
*
|
|
677
|
-
* @param options Options for the mutation operation
|
|
691
|
+
* @param options - Options for the mutation operation
|
|
678
692
|
*/
|
|
679
693
|
commit<R extends Record<string, any> = Record<string, any>>(
|
|
680
694
|
options: AllDocumentsMutationOptions
|
|
@@ -682,32 +696,45 @@ export declare class ObservablePatch extends BasePatch {
|
|
|
682
696
|
/**
|
|
683
697
|
* Commit the patch, returning an observable that produces a mutation result object
|
|
684
698
|
*
|
|
685
|
-
* @param options Options for the mutation operation
|
|
699
|
+
* @param options - Options for the mutation operation
|
|
686
700
|
*/
|
|
687
701
|
commit(options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
688
702
|
/**
|
|
689
703
|
* Commit the patch, returning an observable that produces a mutation result object
|
|
690
704
|
*
|
|
691
|
-
* @param options Options for the mutation operation
|
|
705
|
+
* @param options - Options for the mutation operation
|
|
692
706
|
*/
|
|
693
707
|
commit(options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
694
708
|
/**
|
|
695
709
|
* Commit the patch, returning an observable that produces the first patched document
|
|
696
710
|
*
|
|
697
|
-
* @param options Options for the mutation operation
|
|
711
|
+
* @param options - Options for the mutation operation
|
|
698
712
|
*/
|
|
699
713
|
commit<R extends Record<string, any> = Record<string, any>>(
|
|
700
714
|
options?: BaseMutationOptions
|
|
701
715
|
): Observable<SanityDocument<R>>
|
|
702
716
|
}
|
|
703
717
|
|
|
718
|
+
/** @public */
|
|
704
719
|
export declare type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch
|
|
705
720
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
721
|
+
/** @internal */
|
|
722
|
+
export declare class ObservableProjectsClient {
|
|
723
|
+
#private
|
|
724
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
725
|
+
/**
|
|
726
|
+
* Fetch a list of projects the authenticated user has access to
|
|
727
|
+
*/
|
|
728
|
+
list(): Observable<SanityProject[]>
|
|
729
|
+
/**
|
|
730
|
+
* Fetch a project by project ID
|
|
731
|
+
*
|
|
732
|
+
* @param projectId - ID of the project to fetch
|
|
733
|
+
*/
|
|
734
|
+
getById(projectId: string): Observable<SanityProject>
|
|
709
735
|
}
|
|
710
736
|
|
|
737
|
+
/** @public */
|
|
711
738
|
export declare class ObservableSanityClient {
|
|
712
739
|
#private
|
|
713
740
|
assets: ObservableAssetsClient
|
|
@@ -715,7 +742,7 @@ export declare class ObservableSanityClient {
|
|
|
715
742
|
datasets: ObservableDatasetsClient
|
|
716
743
|
projects: ObservableProjectsClient
|
|
717
744
|
users: ObservableUsersClient
|
|
718
|
-
constructor(httpRequest: HttpRequest, config
|
|
745
|
+
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
719
746
|
/**
|
|
720
747
|
* Clone the client - returns a new instance
|
|
721
748
|
*/
|
|
@@ -731,28 +758,28 @@ export declare class ObservableSanityClient {
|
|
|
731
758
|
/**
|
|
732
759
|
* Clone the client with a new (partial) configuration.
|
|
733
760
|
*
|
|
734
|
-
* @param newConfig New client configuration properties, shallowly merged with existing configuration
|
|
761
|
+
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
735
762
|
*/
|
|
736
763
|
withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient
|
|
737
764
|
/**
|
|
738
765
|
* Perform a GROQ-query against the configured dataset.
|
|
739
766
|
*
|
|
740
|
-
* @param query GROQ-query to perform
|
|
767
|
+
* @param query - GROQ-query to perform
|
|
741
768
|
*/
|
|
742
769
|
fetch<R = any>(query: string): Observable<R>
|
|
743
770
|
/**
|
|
744
771
|
* Perform a GROQ-query against the configured dataset.
|
|
745
772
|
*
|
|
746
|
-
* @param query GROQ-query to perform
|
|
747
|
-
* @param params Query parameters
|
|
773
|
+
* @param query - GROQ-query to perform
|
|
774
|
+
* @param params - Query parameters
|
|
748
775
|
*/
|
|
749
776
|
fetch<R = any>(query: string, params: QueryParams): Observable<R>
|
|
750
777
|
/**
|
|
751
778
|
* Perform a GROQ-query against the configured dataset.
|
|
752
779
|
*
|
|
753
|
-
* @param query GROQ-query to perform
|
|
754
|
-
* @param params Query parameters
|
|
755
|
-
* @param options Request options
|
|
780
|
+
* @param query - GROQ-query to perform
|
|
781
|
+
* @param params - Query parameters
|
|
782
|
+
* @param options - Request options
|
|
756
783
|
*/
|
|
757
784
|
fetch<R = any>(
|
|
758
785
|
query: string,
|
|
@@ -762,9 +789,9 @@ export declare class ObservableSanityClient {
|
|
|
762
789
|
/**
|
|
763
790
|
* Perform a GROQ-query against the configured dataset.
|
|
764
791
|
*
|
|
765
|
-
* @param query GROQ-query to perform
|
|
766
|
-
* @param params Query parameters
|
|
767
|
-
* @param options Request options
|
|
792
|
+
* @param query - GROQ-query to perform
|
|
793
|
+
* @param params - Query parameters
|
|
794
|
+
* @param options - Request options
|
|
768
795
|
*/
|
|
769
796
|
fetch<R = any>(
|
|
770
797
|
query: string,
|
|
@@ -774,8 +801,8 @@ export declare class ObservableSanityClient {
|
|
|
774
801
|
/**
|
|
775
802
|
* Fetch a single document with the given ID.
|
|
776
803
|
*
|
|
777
|
-
* @param id Document ID to fetch
|
|
778
|
-
* @param options Request options
|
|
804
|
+
* @param id - Document ID to fetch
|
|
805
|
+
* @param options - Request options
|
|
779
806
|
*/
|
|
780
807
|
getDocument<R extends Record<string, any> = Record<string, any>>(
|
|
781
808
|
id: string,
|
|
@@ -789,8 +816,8 @@ export declare class ObservableSanityClient {
|
|
|
789
816
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
790
817
|
* If a any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
791
818
|
*
|
|
792
|
-
* @param ids Document IDs to fetch
|
|
793
|
-
* @param options Request options
|
|
819
|
+
* @param ids - Document IDs to fetch
|
|
820
|
+
* @param options - Request options
|
|
794
821
|
*/
|
|
795
822
|
getDocuments<R extends Record<string, any> = Record<string, any>>(
|
|
796
823
|
ids: string[],
|
|
@@ -802,8 +829,8 @@ export declare class ObservableSanityClient {
|
|
|
802
829
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
803
830
|
* Returns an observable that resolves to the created document.
|
|
804
831
|
*
|
|
805
|
-
* @param document Document to create
|
|
806
|
-
* @param options Mutation options
|
|
832
|
+
* @param document - Document to create
|
|
833
|
+
* @param options - Mutation options
|
|
807
834
|
*/
|
|
808
835
|
create<R extends Record<string, any> = Record<string, any>>(
|
|
809
836
|
document: SanityDocumentStub<R>,
|
|
@@ -813,8 +840,8 @@ export declare class ObservableSanityClient {
|
|
|
813
840
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
814
841
|
* Returns an observable that resolves to an array containing the created document.
|
|
815
842
|
*
|
|
816
|
-
* @param document Document to create
|
|
817
|
-
* @param options Mutation options
|
|
843
|
+
* @param document - Document to create
|
|
844
|
+
* @param options - Mutation options
|
|
818
845
|
*/
|
|
819
846
|
create<R extends Record<string, any> = Record<string, any>>(
|
|
820
847
|
document: SanityDocumentStub<R>,
|
|
@@ -824,8 +851,8 @@ export declare class ObservableSanityClient {
|
|
|
824
851
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
825
852
|
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
826
853
|
*
|
|
827
|
-
* @param document Document to create
|
|
828
|
-
* @param options Mutation options
|
|
854
|
+
* @param document - Document to create
|
|
855
|
+
* @param options - Mutation options
|
|
829
856
|
*/
|
|
830
857
|
create<R extends Record<string, any> = Record<string, any>>(
|
|
831
858
|
document: SanityDocumentStub<R>,
|
|
@@ -835,8 +862,8 @@ export declare class ObservableSanityClient {
|
|
|
835
862
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
836
863
|
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
837
864
|
*
|
|
838
|
-
* @param document Document to create
|
|
839
|
-
* @param options Mutation options
|
|
865
|
+
* @param document - Document to create
|
|
866
|
+
* @param options - Mutation options
|
|
840
867
|
*/
|
|
841
868
|
create<R extends Record<string, any> = Record<string, any>>(
|
|
842
869
|
document: SanityDocumentStub<R>,
|
|
@@ -846,8 +873,8 @@ export declare class ObservableSanityClient {
|
|
|
846
873
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
847
874
|
* Returns an observable that resolves to the created document.
|
|
848
875
|
*
|
|
849
|
-
* @param document Document to create
|
|
850
|
-
* @param options Mutation options
|
|
876
|
+
* @param document - Document to create
|
|
877
|
+
* @param options - Mutation options
|
|
851
878
|
*/
|
|
852
879
|
create<R extends Record<string, any> = Record<string, any>>(
|
|
853
880
|
document: SanityDocumentStub<R>,
|
|
@@ -857,8 +884,8 @@ export declare class ObservableSanityClient {
|
|
|
857
884
|
* Create a document if no document with the same ID already exists.
|
|
858
885
|
* Returns an observable that resolves to the created document.
|
|
859
886
|
*
|
|
860
|
-
* @param document Document to create
|
|
861
|
-
* @param options Mutation options
|
|
887
|
+
* @param document - Document to create
|
|
888
|
+
* @param options - Mutation options
|
|
862
889
|
*/
|
|
863
890
|
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
864
891
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -868,8 +895,8 @@ export declare class ObservableSanityClient {
|
|
|
868
895
|
* Create a document if no document with the same ID already exists.
|
|
869
896
|
* Returns an observable that resolves to an array containing the created document.
|
|
870
897
|
*
|
|
871
|
-
* @param document Document to create
|
|
872
|
-
* @param options Mutation options
|
|
898
|
+
* @param document - Document to create
|
|
899
|
+
* @param options - Mutation options
|
|
873
900
|
*/
|
|
874
901
|
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
875
902
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -879,8 +906,8 @@ export declare class ObservableSanityClient {
|
|
|
879
906
|
* Create a document if no document with the same ID already exists.
|
|
880
907
|
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
881
908
|
*
|
|
882
|
-
* @param document Document to create
|
|
883
|
-
* @param options Mutation options
|
|
909
|
+
* @param document - Document to create
|
|
910
|
+
* @param options - Mutation options
|
|
884
911
|
*/
|
|
885
912
|
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
886
913
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -890,8 +917,8 @@ export declare class ObservableSanityClient {
|
|
|
890
917
|
* Create a document if no document with the same ID already exists.
|
|
891
918
|
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
892
919
|
*
|
|
893
|
-
* @param document Document to create
|
|
894
|
-
* @param options Mutation options
|
|
920
|
+
* @param document - Document to create
|
|
921
|
+
* @param options - Mutation options
|
|
895
922
|
*/
|
|
896
923
|
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
897
924
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -901,8 +928,8 @@ export declare class ObservableSanityClient {
|
|
|
901
928
|
* Create a document if no document with the same ID already exists.
|
|
902
929
|
* Returns an observable that resolves to the created document.
|
|
903
930
|
*
|
|
904
|
-
* @param document Document to create
|
|
905
|
-
* @param options Mutation options
|
|
931
|
+
* @param document - Document to create
|
|
932
|
+
* @param options - Mutation options
|
|
906
933
|
*/
|
|
907
934
|
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
908
935
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -912,8 +939,8 @@ export declare class ObservableSanityClient {
|
|
|
912
939
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
913
940
|
* Returns an observable that resolves to the created document.
|
|
914
941
|
*
|
|
915
|
-
* @param document Document to either create or replace
|
|
916
|
-
* @param options Mutation options
|
|
942
|
+
* @param document - Document to either create or replace
|
|
943
|
+
* @param options - Mutation options
|
|
917
944
|
*/
|
|
918
945
|
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
919
946
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -923,8 +950,8 @@ export declare class ObservableSanityClient {
|
|
|
923
950
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
924
951
|
* Returns an observable that resolves to an array containing the created document.
|
|
925
952
|
*
|
|
926
|
-
* @param document Document to either create or replace
|
|
927
|
-
* @param options Mutation options
|
|
953
|
+
* @param document - Document to either create or replace
|
|
954
|
+
* @param options - Mutation options
|
|
928
955
|
*/
|
|
929
956
|
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
930
957
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -934,8 +961,8 @@ export declare class ObservableSanityClient {
|
|
|
934
961
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
935
962
|
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
936
963
|
*
|
|
937
|
-
* @param document Document to either create or replace
|
|
938
|
-
* @param options Mutation options
|
|
964
|
+
* @param document - Document to either create or replace
|
|
965
|
+
* @param options - Mutation options
|
|
939
966
|
*/
|
|
940
967
|
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
941
968
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -945,8 +972,8 @@ export declare class ObservableSanityClient {
|
|
|
945
972
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
946
973
|
* Returns an observable that resolves to a mutation result object containing the created document ID.
|
|
947
974
|
*
|
|
948
|
-
* @param document Document to either create or replace
|
|
949
|
-
* @param options Mutation options
|
|
975
|
+
* @param document - Document to either create or replace
|
|
976
|
+
* @param options - Mutation options
|
|
950
977
|
*/
|
|
951
978
|
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
952
979
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -956,8 +983,8 @@ export declare class ObservableSanityClient {
|
|
|
956
983
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
957
984
|
* Returns an observable that resolves to the created document.
|
|
958
985
|
*
|
|
959
|
-
* @param document Document to either create or replace
|
|
960
|
-
* @param options Mutation options
|
|
986
|
+
* @param document - Document to either create or replace
|
|
987
|
+
* @param options - Mutation options
|
|
961
988
|
*/
|
|
962
989
|
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
963
990
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -967,8 +994,8 @@ export declare class ObservableSanityClient {
|
|
|
967
994
|
* Deletes a document with the given document ID.
|
|
968
995
|
* Returns an observable that resolves to the deleted document.
|
|
969
996
|
*
|
|
970
|
-
* @param id Document ID to delete
|
|
971
|
-
* @param options Options for the mutation
|
|
997
|
+
* @param id - Document ID to delete
|
|
998
|
+
* @param options - Options for the mutation
|
|
972
999
|
*/
|
|
973
1000
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
974
1001
|
id: string,
|
|
@@ -978,8 +1005,8 @@ export declare class ObservableSanityClient {
|
|
|
978
1005
|
* Deletes a document with the given document ID.
|
|
979
1006
|
* Returns an observable that resolves to an array containing the deleted document.
|
|
980
1007
|
*
|
|
981
|
-
* @param id Document ID to delete
|
|
982
|
-
* @param options Options for the mutation
|
|
1008
|
+
* @param id - Document ID to delete
|
|
1009
|
+
* @param options - Options for the mutation
|
|
983
1010
|
*/
|
|
984
1011
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
985
1012
|
id: string,
|
|
@@ -989,24 +1016,24 @@ export declare class ObservableSanityClient {
|
|
|
989
1016
|
* Deletes a document with the given document ID.
|
|
990
1017
|
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
991
1018
|
*
|
|
992
|
-
* @param id Document ID to delete
|
|
993
|
-
* @param options Options for the mutation
|
|
1019
|
+
* @param id - Document ID to delete
|
|
1020
|
+
* @param options - Options for the mutation
|
|
994
1021
|
*/
|
|
995
1022
|
delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
996
1023
|
/**
|
|
997
1024
|
* Deletes a document with the given document ID.
|
|
998
1025
|
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
999
1026
|
*
|
|
1000
|
-
* @param id Document ID to delete
|
|
1001
|
-
* @param options Options for the mutation
|
|
1027
|
+
* @param id - Document ID to delete
|
|
1028
|
+
* @param options - Options for the mutation
|
|
1002
1029
|
*/
|
|
1003
1030
|
delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
1004
1031
|
/**
|
|
1005
1032
|
* Deletes a document with the given document ID.
|
|
1006
1033
|
* Returns an observable that resolves to the deleted document.
|
|
1007
1034
|
*
|
|
1008
|
-
* @param id Document ID to delete
|
|
1009
|
-
* @param options Options for the mutation
|
|
1035
|
+
* @param id - Document ID to delete
|
|
1036
|
+
* @param options - Options for the mutation
|
|
1010
1037
|
*/
|
|
1011
1038
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1012
1039
|
id: string,
|
|
@@ -1016,8 +1043,8 @@ export declare class ObservableSanityClient {
|
|
|
1016
1043
|
* Deletes one or more documents matching the given query or document ID.
|
|
1017
1044
|
* Returns an observable that resolves to first deleted document.
|
|
1018
1045
|
*
|
|
1019
|
-
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1020
|
-
* @param options Options for the mutation
|
|
1046
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1047
|
+
* @param options - Options for the mutation
|
|
1021
1048
|
*/
|
|
1022
1049
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1023
1050
|
selection: MutationSelection,
|
|
@@ -1027,8 +1054,8 @@ export declare class ObservableSanityClient {
|
|
|
1027
1054
|
* Deletes one or more documents matching the given query or document ID.
|
|
1028
1055
|
* Returns an observable that resolves to an array containing the deleted documents.
|
|
1029
1056
|
*
|
|
1030
|
-
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1031
|
-
* @param options Options for the mutation
|
|
1057
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1058
|
+
* @param options - Options for the mutation
|
|
1032
1059
|
*/
|
|
1033
1060
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1034
1061
|
selection: MutationSelection,
|
|
@@ -1038,8 +1065,8 @@ export declare class ObservableSanityClient {
|
|
|
1038
1065
|
* Deletes one or more documents matching the given query or document ID.
|
|
1039
1066
|
* Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
|
|
1040
1067
|
*
|
|
1041
|
-
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1042
|
-
* @param options Options for the mutation
|
|
1068
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1069
|
+
* @param options - Options for the mutation
|
|
1043
1070
|
*/
|
|
1044
1071
|
delete(
|
|
1045
1072
|
selection: MutationSelection,
|
|
@@ -1049,8 +1076,8 @@ export declare class ObservableSanityClient {
|
|
|
1049
1076
|
* Deletes one or more documents matching the given query or document ID.
|
|
1050
1077
|
* Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
|
|
1051
1078
|
*
|
|
1052
|
-
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1053
|
-
* @param options Options for the mutation
|
|
1079
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1080
|
+
* @param options - Options for the mutation
|
|
1054
1081
|
*/
|
|
1055
1082
|
delete(
|
|
1056
1083
|
selection: MutationSelection,
|
|
@@ -1060,8 +1087,8 @@ export declare class ObservableSanityClient {
|
|
|
1060
1087
|
* Deletes one or more documents matching the given query or document ID.
|
|
1061
1088
|
* Returns an observable that resolves to first deleted document.
|
|
1062
1089
|
*
|
|
1063
|
-
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1064
|
-
* @param options Options for the mutation
|
|
1090
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1091
|
+
* @param options - Options for the mutation
|
|
1065
1092
|
*/
|
|
1066
1093
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1067
1094
|
selection: MutationSelection,
|
|
@@ -1071,8 +1098,8 @@ export declare class ObservableSanityClient {
|
|
|
1071
1098
|
* Perform mutation operations against the configured dataset
|
|
1072
1099
|
* Returns an observable that resolves to the first mutated document.
|
|
1073
1100
|
*
|
|
1074
|
-
* @param operations Mutation operations to execute
|
|
1075
|
-
* @param options Mutation options
|
|
1101
|
+
* @param operations - Mutation operations to execute
|
|
1102
|
+
* @param options - Mutation options
|
|
1076
1103
|
*/
|
|
1077
1104
|
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1078
1105
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
@@ -1082,8 +1109,8 @@ export declare class ObservableSanityClient {
|
|
|
1082
1109
|
* Perform mutation operations against the configured dataset.
|
|
1083
1110
|
* Returns an observable that resolves to an array of the mutated documents.
|
|
1084
1111
|
*
|
|
1085
|
-
* @param operations Mutation operations to execute
|
|
1086
|
-
* @param options Mutation options
|
|
1112
|
+
* @param operations - Mutation operations to execute
|
|
1113
|
+
* @param options - Mutation options
|
|
1087
1114
|
*/
|
|
1088
1115
|
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1089
1116
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
@@ -1093,8 +1120,8 @@ export declare class ObservableSanityClient {
|
|
|
1093
1120
|
* Perform mutation operations against the configured dataset
|
|
1094
1121
|
* Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
1095
1122
|
*
|
|
1096
|
-
* @param operations Mutation operations to execute
|
|
1097
|
-
* @param options Mutation options
|
|
1123
|
+
* @param operations - Mutation operations to execute
|
|
1124
|
+
* @param options - Mutation options
|
|
1098
1125
|
*/
|
|
1099
1126
|
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1100
1127
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
@@ -1104,8 +1131,8 @@ export declare class ObservableSanityClient {
|
|
|
1104
1131
|
* Perform mutation operations against the configured dataset
|
|
1105
1132
|
* Returns an observable that resolves to a mutation result object containing the mutated document IDs.
|
|
1106
1133
|
*
|
|
1107
|
-
* @param operations Mutation operations to execute
|
|
1108
|
-
* @param options Mutation options
|
|
1134
|
+
* @param operations - Mutation operations to execute
|
|
1135
|
+
* @param options - Mutation options
|
|
1109
1136
|
*/
|
|
1110
1137
|
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1111
1138
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
@@ -1115,8 +1142,8 @@ export declare class ObservableSanityClient {
|
|
|
1115
1142
|
* Perform mutation operations against the configured dataset
|
|
1116
1143
|
* Returns an observable that resolves to the first mutated document.
|
|
1117
1144
|
*
|
|
1118
|
-
* @param operations Mutation operations to execute
|
|
1119
|
-
* @param options Mutation options
|
|
1145
|
+
* @param operations - Mutation operations to execute
|
|
1146
|
+
* @param options - Mutation options
|
|
1120
1147
|
*/
|
|
1121
1148
|
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1122
1149
|
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
@@ -1125,14 +1152,14 @@ export declare class ObservableSanityClient {
|
|
|
1125
1152
|
/**
|
|
1126
1153
|
* Create a new buildable patch of operations to perform
|
|
1127
1154
|
*
|
|
1128
|
-
* @param documentId Document ID to patch
|
|
1129
|
-
* @param operations Optional object of patch operations to initialize the patch instance with
|
|
1155
|
+
* @param documentId - Document ID(s) to patch
|
|
1156
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1130
1157
|
*/
|
|
1131
|
-
patch(documentId:
|
|
1158
|
+
patch(documentId: PatchSelection, operations?: PatchOperations): ObservablePatch
|
|
1132
1159
|
/**
|
|
1133
1160
|
* Create a new transaction of mutations
|
|
1134
1161
|
*
|
|
1135
|
-
* @param operations Optional array of mutation operations to initialize the transaction instance with
|
|
1162
|
+
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
1136
1163
|
*/
|
|
1137
1164
|
transaction<R extends Record<string, any> = Record<string, any>>(
|
|
1138
1165
|
operations?: Mutation<R>[]
|
|
@@ -1141,27 +1168,12 @@ export declare class ObservableSanityClient {
|
|
|
1141
1168
|
* DEPRECATED: Perform an HTTP request against the Sanity API
|
|
1142
1169
|
*
|
|
1143
1170
|
* @deprecated Use your own request library!
|
|
1144
|
-
* @param options Request options
|
|
1171
|
+
* @param options - Request options
|
|
1145
1172
|
*/
|
|
1146
1173
|
request<R = any>(options: RawRequestOptions): Observable<R>
|
|
1147
|
-
/**
|
|
1148
|
-
* DEPRECATED: Get a Sanity API URL for the URI provided
|
|
1149
|
-
*
|
|
1150
|
-
* @deprecated Should be an internal concern
|
|
1151
|
-
* @param uri URI/path to build URL for
|
|
1152
|
-
* @param canUseCdn Whether or not to allow using the API CDN for this route
|
|
1153
|
-
*/
|
|
1154
|
-
getUrl(uri: string, canUseCdn?: boolean): string
|
|
1155
|
-
/**
|
|
1156
|
-
* DEPRECATED: Get a Sanity API URL for the data operation and path provided
|
|
1157
|
-
*
|
|
1158
|
-
* @deprecated Should be an internal concern
|
|
1159
|
-
* @param operation Data operation
|
|
1160
|
-
* @param path Path to append
|
|
1161
|
-
*/
|
|
1162
|
-
getDataUrl(operation: string, path?: string): string
|
|
1163
1174
|
}
|
|
1164
1175
|
|
|
1176
|
+
/** @public */
|
|
1165
1177
|
export declare class ObservableTransaction extends BaseTransaction {
|
|
1166
1178
|
#private
|
|
1167
1179
|
constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)
|
|
@@ -1220,11 +1232,21 @@ export declare class ObservableTransaction extends BaseTransaction {
|
|
|
1220
1232
|
patch(patch: ObservablePatch): this
|
|
1221
1233
|
}
|
|
1222
1234
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1235
|
+
/** @public */
|
|
1236
|
+
export declare class ObservableUsersClient {
|
|
1237
|
+
#private
|
|
1238
|
+
constructor(client: ObservableSanityClient, httpRequest: HttpRequest)
|
|
1239
|
+
/**
|
|
1240
|
+
* Fetch a user by user ID
|
|
1241
|
+
*
|
|
1242
|
+
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
1243
|
+
*/
|
|
1244
|
+
getById<T extends 'me' | string>(
|
|
1245
|
+
id: T
|
|
1246
|
+
): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
1226
1247
|
}
|
|
1227
1248
|
|
|
1249
|
+
/** @public */
|
|
1228
1250
|
export declare class Patch extends BasePatch {
|
|
1229
1251
|
#private
|
|
1230
1252
|
constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)
|
|
@@ -1235,7 +1257,7 @@ export declare class Patch extends BasePatch {
|
|
|
1235
1257
|
/**
|
|
1236
1258
|
* Commit the patch, returning a promise that resolves to the first patched document
|
|
1237
1259
|
*
|
|
1238
|
-
* @param options Options for the mutation operation
|
|
1260
|
+
* @param options - Options for the mutation operation
|
|
1239
1261
|
*/
|
|
1240
1262
|
commit<R extends Record<string, any> = Record<string, any>>(
|
|
1241
1263
|
options: FirstDocumentMutationOptions
|
|
@@ -1243,7 +1265,7 @@ export declare class Patch extends BasePatch {
|
|
|
1243
1265
|
/**
|
|
1244
1266
|
* Commit the patch, returning a promise that resolves to an array of the mutated documents
|
|
1245
1267
|
*
|
|
1246
|
-
* @param options Options for the mutation operation
|
|
1268
|
+
* @param options - Options for the mutation operation
|
|
1247
1269
|
*/
|
|
1248
1270
|
commit<R extends Record<string, any> = Record<string, any>>(
|
|
1249
1271
|
options: AllDocumentsMutationOptions
|
|
@@ -1251,29 +1273,32 @@ export declare class Patch extends BasePatch {
|
|
|
1251
1273
|
/**
|
|
1252
1274
|
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
1253
1275
|
*
|
|
1254
|
-
* @param options Options for the mutation operation
|
|
1276
|
+
* @param options - Options for the mutation operation
|
|
1255
1277
|
*/
|
|
1256
1278
|
commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
1257
1279
|
/**
|
|
1258
1280
|
* Commit the patch, returning a promise that resolves to a mutation result object
|
|
1259
1281
|
*
|
|
1260
|
-
* @param options Options for the mutation operation
|
|
1282
|
+
* @param options - Options for the mutation operation
|
|
1261
1283
|
*/
|
|
1262
1284
|
commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
1263
1285
|
/**
|
|
1264
1286
|
* Commit the patch, returning a promise that resolves to the first patched document
|
|
1265
1287
|
*
|
|
1266
|
-
* @param options Options for the mutation operation
|
|
1288
|
+
* @param options - Options for the mutation operation
|
|
1267
1289
|
*/
|
|
1268
1290
|
commit<R extends Record<string, any> = Record<string, any>>(
|
|
1269
1291
|
options?: BaseMutationOptions
|
|
1270
1292
|
): Promise<SanityDocument<R>>
|
|
1271
1293
|
}
|
|
1272
1294
|
|
|
1295
|
+
/** @public */
|
|
1273
1296
|
export declare type PatchBuilder = (patch: Patch) => Patch
|
|
1274
1297
|
|
|
1298
|
+
/** @internal */
|
|
1275
1299
|
export declare type PatchMutationOperation = PatchOperations & MutationSelection
|
|
1276
1300
|
|
|
1301
|
+
/** @internal */
|
|
1277
1302
|
export declare interface PatchOperations {
|
|
1278
1303
|
set?: {
|
|
1279
1304
|
[key: string]: any
|
|
@@ -1295,8 +1320,10 @@ export declare interface PatchOperations {
|
|
|
1295
1320
|
ifRevisionID?: string
|
|
1296
1321
|
}
|
|
1297
1322
|
|
|
1323
|
+
/** @internal */
|
|
1298
1324
|
export declare type PatchSelection = string | string[] | MutationSelection
|
|
1299
1325
|
|
|
1326
|
+
/** @public */
|
|
1300
1327
|
declare interface ProgressEvent_2 {
|
|
1301
1328
|
type: 'progress'
|
|
1302
1329
|
stage: 'upload' | 'download'
|
|
@@ -1307,21 +1334,35 @@ declare interface ProgressEvent_2 {
|
|
|
1307
1334
|
}
|
|
1308
1335
|
export {ProgressEvent_2 as ProgressEvent}
|
|
1309
1336
|
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1337
|
+
/** @internal */
|
|
1338
|
+
export declare class ProjectsClient {
|
|
1339
|
+
#private
|
|
1340
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
1341
|
+
/**
|
|
1342
|
+
* Fetch a list of projects the authenticated user has access to
|
|
1343
|
+
*/
|
|
1344
|
+
list(): Promise<SanityProject[]>
|
|
1345
|
+
/**
|
|
1346
|
+
* Fetch a project by project ID
|
|
1347
|
+
*
|
|
1348
|
+
* @param projectId - ID of the project to fetch
|
|
1349
|
+
*/
|
|
1350
|
+
getById(projectId: string): Promise<SanityProject>
|
|
1313
1351
|
}
|
|
1314
1352
|
|
|
1353
|
+
/** @public */
|
|
1315
1354
|
export declare type QueryParams = {
|
|
1316
1355
|
[key: string]: any
|
|
1317
1356
|
}
|
|
1318
1357
|
|
|
1358
|
+
/** @internal */
|
|
1319
1359
|
export declare interface RawQueryResponse<R> {
|
|
1320
1360
|
q: string
|
|
1321
1361
|
ms: number
|
|
1322
1362
|
result: R
|
|
1323
1363
|
}
|
|
1324
1364
|
|
|
1365
|
+
/** @internal */
|
|
1325
1366
|
export declare interface RawRequestOptions {
|
|
1326
1367
|
url?: string
|
|
1327
1368
|
uri?: string
|
|
@@ -1343,12 +1384,15 @@ export declare interface RawRequestOptions {
|
|
|
1343
1384
|
maxRedirects?: number
|
|
1344
1385
|
}
|
|
1345
1386
|
|
|
1387
|
+
/** @public */
|
|
1346
1388
|
export declare type ReconnectEvent = {
|
|
1347
1389
|
type: 'reconnect'
|
|
1348
1390
|
}
|
|
1349
1391
|
|
|
1392
|
+
/** @public */
|
|
1350
1393
|
export declare const requester: Requester
|
|
1351
1394
|
|
|
1395
|
+
/** @internal */
|
|
1352
1396
|
export declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
|
|
1353
1397
|
url?: string
|
|
1354
1398
|
uri?: string
|
|
@@ -1356,6 +1400,7 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
|
|
|
1356
1400
|
tag?: string
|
|
1357
1401
|
}
|
|
1358
1402
|
|
|
1403
|
+
/** @public */
|
|
1359
1404
|
export declare interface RequestOptions {
|
|
1360
1405
|
timeout?: number
|
|
1361
1406
|
token?: string
|
|
@@ -1366,6 +1411,7 @@ export declare interface RequestOptions {
|
|
|
1366
1411
|
body?: any
|
|
1367
1412
|
}
|
|
1368
1413
|
|
|
1414
|
+
/** @public */
|
|
1369
1415
|
export declare interface ResponseEvent<T = unknown> {
|
|
1370
1416
|
type: 'response'
|
|
1371
1417
|
body: T
|
|
@@ -1376,6 +1422,7 @@ export declare interface ResponseEvent<T = unknown> {
|
|
|
1376
1422
|
headers: Record<string, string>
|
|
1377
1423
|
}
|
|
1378
1424
|
|
|
1425
|
+
/** @internal */
|
|
1379
1426
|
export declare interface SanityAssetDocument extends SanityDocument {
|
|
1380
1427
|
url: string
|
|
1381
1428
|
path: string
|
|
@@ -1388,6 +1435,7 @@ export declare interface SanityAssetDocument extends SanityDocument {
|
|
|
1388
1435
|
originalFilename?: string
|
|
1389
1436
|
}
|
|
1390
1437
|
|
|
1438
|
+
/** @public */
|
|
1391
1439
|
export declare class SanityClient {
|
|
1392
1440
|
#private
|
|
1393
1441
|
assets: AssetsClient
|
|
@@ -1403,7 +1451,7 @@ export declare class SanityClient {
|
|
|
1403
1451
|
* Instance properties
|
|
1404
1452
|
*/
|
|
1405
1453
|
listen: typeof _listen
|
|
1406
|
-
constructor(httpRequest: HttpRequest, config
|
|
1454
|
+
constructor(httpRequest: HttpRequest, config?: ClientConfig)
|
|
1407
1455
|
/**
|
|
1408
1456
|
* Clone the client - returns a new instance
|
|
1409
1457
|
*/
|
|
@@ -1419,28 +1467,28 @@ export declare class SanityClient {
|
|
|
1419
1467
|
/**
|
|
1420
1468
|
* Clone the client with a new (partial) configuration.
|
|
1421
1469
|
*
|
|
1422
|
-
* @param newConfig New client configuration properties, shallowly merged with existing configuration
|
|
1470
|
+
* @param newConfig - New client configuration properties, shallowly merged with existing configuration
|
|
1423
1471
|
*/
|
|
1424
1472
|
withConfig(newConfig?: Partial<ClientConfig>): SanityClient
|
|
1425
1473
|
/**
|
|
1426
1474
|
* Perform a GROQ-query against the configured dataset.
|
|
1427
1475
|
*
|
|
1428
|
-
* @param query GROQ-query to perform
|
|
1476
|
+
* @param query - GROQ-query to perform
|
|
1429
1477
|
*/
|
|
1430
1478
|
fetch<R = any>(query: string): Promise<R>
|
|
1431
1479
|
/**
|
|
1432
1480
|
* Perform a GROQ-query against the configured dataset.
|
|
1433
1481
|
*
|
|
1434
|
-
* @param query GROQ-query to perform
|
|
1435
|
-
* @param params Optional query parameters
|
|
1482
|
+
* @param query - GROQ-query to perform
|
|
1483
|
+
* @param params - Optional query parameters
|
|
1436
1484
|
*/
|
|
1437
1485
|
fetch<R = any>(query: string, params: QueryParams): Promise<R>
|
|
1438
1486
|
/**
|
|
1439
1487
|
* Perform a GROQ-query against the configured dataset.
|
|
1440
1488
|
*
|
|
1441
|
-
* @param query GROQ-query to perform
|
|
1442
|
-
* @param params Optional query parameters
|
|
1443
|
-
* @param options Request options
|
|
1489
|
+
* @param query - GROQ-query to perform
|
|
1490
|
+
* @param params - Optional query parameters
|
|
1491
|
+
* @param options - Request options
|
|
1444
1492
|
*/
|
|
1445
1493
|
fetch<R = any>(
|
|
1446
1494
|
query: string,
|
|
@@ -1450,9 +1498,9 @@ export declare class SanityClient {
|
|
|
1450
1498
|
/**
|
|
1451
1499
|
* Perform a GROQ-query against the configured dataset.
|
|
1452
1500
|
*
|
|
1453
|
-
* @param query GROQ-query to perform
|
|
1454
|
-
* @param params Optional query parameters
|
|
1455
|
-
* @param options Request options
|
|
1501
|
+
* @param query - GROQ-query to perform
|
|
1502
|
+
* @param params - Optional query parameters
|
|
1503
|
+
* @param options - Request options
|
|
1456
1504
|
*/
|
|
1457
1505
|
fetch<R = any>(
|
|
1458
1506
|
query: string,
|
|
@@ -1462,8 +1510,8 @@ export declare class SanityClient {
|
|
|
1462
1510
|
/**
|
|
1463
1511
|
* Fetch a single document with the given ID.
|
|
1464
1512
|
*
|
|
1465
|
-
* @param id Document ID to fetch
|
|
1466
|
-
* @param options Request options
|
|
1513
|
+
* @param id - Document ID to fetch
|
|
1514
|
+
* @param options - Request options
|
|
1467
1515
|
*/
|
|
1468
1516
|
getDocument<R extends Record<string, any> = Record<string, any>>(
|
|
1469
1517
|
id: string,
|
|
@@ -1477,8 +1525,8 @@ export declare class SanityClient {
|
|
|
1477
1525
|
* The order/position of documents is preserved based on the original array of IDs.
|
|
1478
1526
|
* If a any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
1479
1527
|
*
|
|
1480
|
-
* @param ids Document IDs to fetch
|
|
1481
|
-
* @param options Request options
|
|
1528
|
+
* @param ids - Document IDs to fetch
|
|
1529
|
+
* @param options - Request options
|
|
1482
1530
|
*/
|
|
1483
1531
|
getDocuments<R extends Record<string, any> = Record<string, any>>(
|
|
1484
1532
|
ids: string[],
|
|
@@ -1490,8 +1538,8 @@ export declare class SanityClient {
|
|
|
1490
1538
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1491
1539
|
* Returns a promise that resolves to the created document.
|
|
1492
1540
|
*
|
|
1493
|
-
* @param document Document to create
|
|
1494
|
-
* @param options Mutation options
|
|
1541
|
+
* @param document - Document to create
|
|
1542
|
+
* @param options - Mutation options
|
|
1495
1543
|
*/
|
|
1496
1544
|
create<R extends Record<string, any> = Record<string, any>>(
|
|
1497
1545
|
document: SanityDocumentStub<R>,
|
|
@@ -1501,8 +1549,8 @@ export declare class SanityClient {
|
|
|
1501
1549
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1502
1550
|
* Returns a promise that resolves to an array containing the created document.
|
|
1503
1551
|
*
|
|
1504
|
-
* @param document Document to create
|
|
1505
|
-
* @param options Mutation options
|
|
1552
|
+
* @param document - Document to create
|
|
1553
|
+
* @param options - Mutation options
|
|
1506
1554
|
*/
|
|
1507
1555
|
create<R extends Record<string, any> = Record<string, any>>(
|
|
1508
1556
|
document: SanityDocumentStub<R>,
|
|
@@ -1512,8 +1560,8 @@ export declare class SanityClient {
|
|
|
1512
1560
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1513
1561
|
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
1514
1562
|
*
|
|
1515
|
-
* @param document Document to create
|
|
1516
|
-
* @param options Mutation options
|
|
1563
|
+
* @param document - Document to create
|
|
1564
|
+
* @param options - Mutation options
|
|
1517
1565
|
*/
|
|
1518
1566
|
create<R extends Record<string, any> = Record<string, any>>(
|
|
1519
1567
|
document: SanityDocumentStub<R>,
|
|
@@ -1523,8 +1571,8 @@ export declare class SanityClient {
|
|
|
1523
1571
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1524
1572
|
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
1525
1573
|
*
|
|
1526
|
-
* @param document Document to create
|
|
1527
|
-
* @param options Mutation options
|
|
1574
|
+
* @param document - Document to create
|
|
1575
|
+
* @param options - Mutation options
|
|
1528
1576
|
*/
|
|
1529
1577
|
create<R extends Record<string, any> = Record<string, any>>(
|
|
1530
1578
|
document: SanityDocumentStub<R>,
|
|
@@ -1534,8 +1582,8 @@ export declare class SanityClient {
|
|
|
1534
1582
|
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
1535
1583
|
* Returns a promise that resolves to the created document.
|
|
1536
1584
|
*
|
|
1537
|
-
* @param document Document to create
|
|
1538
|
-
* @param options Mutation options
|
|
1585
|
+
* @param document - Document to create
|
|
1586
|
+
* @param options - Mutation options
|
|
1539
1587
|
*/
|
|
1540
1588
|
create<R extends Record<string, any> = Record<string, any>>(
|
|
1541
1589
|
document: SanityDocumentStub<R>,
|
|
@@ -1545,8 +1593,8 @@ export declare class SanityClient {
|
|
|
1545
1593
|
* Create a document if no document with the same ID already exists.
|
|
1546
1594
|
* Returns a promise that resolves to the created document.
|
|
1547
1595
|
*
|
|
1548
|
-
* @param document Document to create
|
|
1549
|
-
* @param options Mutation options
|
|
1596
|
+
* @param document - Document to create
|
|
1597
|
+
* @param options - Mutation options
|
|
1550
1598
|
*/
|
|
1551
1599
|
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
1552
1600
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -1556,8 +1604,8 @@ export declare class SanityClient {
|
|
|
1556
1604
|
* Create a document if no document with the same ID already exists.
|
|
1557
1605
|
* Returns a promise that resolves to an array containing the created document.
|
|
1558
1606
|
*
|
|
1559
|
-
* @param document Document to create
|
|
1560
|
-
* @param options Mutation options
|
|
1607
|
+
* @param document - Document to create
|
|
1608
|
+
* @param options - Mutation options
|
|
1561
1609
|
*/
|
|
1562
1610
|
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
1563
1611
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -1567,8 +1615,8 @@ export declare class SanityClient {
|
|
|
1567
1615
|
* Create a document if no document with the same ID already exists.
|
|
1568
1616
|
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
1569
1617
|
*
|
|
1570
|
-
* @param document Document to create
|
|
1571
|
-
* @param options Mutation options
|
|
1618
|
+
* @param document - Document to create
|
|
1619
|
+
* @param options - Mutation options
|
|
1572
1620
|
*/
|
|
1573
1621
|
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
1574
1622
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -1578,8 +1626,8 @@ export declare class SanityClient {
|
|
|
1578
1626
|
* Create a document if no document with the same ID already exists.
|
|
1579
1627
|
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
1580
1628
|
*
|
|
1581
|
-
* @param document Document to create
|
|
1582
|
-
* @param options Mutation options
|
|
1629
|
+
* @param document - Document to create
|
|
1630
|
+
* @param options - Mutation options
|
|
1583
1631
|
*/
|
|
1584
1632
|
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
1585
1633
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -1589,8 +1637,8 @@ export declare class SanityClient {
|
|
|
1589
1637
|
* Create a document if no document with the same ID already exists.
|
|
1590
1638
|
* Returns a promise that resolves to the created document.
|
|
1591
1639
|
*
|
|
1592
|
-
* @param document Document to create
|
|
1593
|
-
* @param options Mutation options
|
|
1640
|
+
* @param document - Document to create
|
|
1641
|
+
* @param options - Mutation options
|
|
1594
1642
|
*/
|
|
1595
1643
|
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
1596
1644
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -1600,8 +1648,8 @@ export declare class SanityClient {
|
|
|
1600
1648
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1601
1649
|
* Returns a promise that resolves to the created document.
|
|
1602
1650
|
*
|
|
1603
|
-
* @param document Document to either create or replace
|
|
1604
|
-
* @param options Mutation options
|
|
1651
|
+
* @param document - Document to either create or replace
|
|
1652
|
+
* @param options - Mutation options
|
|
1605
1653
|
*/
|
|
1606
1654
|
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
1607
1655
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -1611,8 +1659,8 @@ export declare class SanityClient {
|
|
|
1611
1659
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1612
1660
|
* Returns a promise that resolves to an array containing the created document.
|
|
1613
1661
|
*
|
|
1614
|
-
* @param document Document to either create or replace
|
|
1615
|
-
* @param options Mutation options
|
|
1662
|
+
* @param document - Document to either create or replace
|
|
1663
|
+
* @param options - Mutation options
|
|
1616
1664
|
*/
|
|
1617
1665
|
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
1618
1666
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -1622,8 +1670,8 @@ export declare class SanityClient {
|
|
|
1622
1670
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1623
1671
|
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
1624
1672
|
*
|
|
1625
|
-
* @param document Document to either create or replace
|
|
1626
|
-
* @param options Mutation options
|
|
1673
|
+
* @param document - Document to either create or replace
|
|
1674
|
+
* @param options - Mutation options
|
|
1627
1675
|
*/
|
|
1628
1676
|
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
1629
1677
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -1633,8 +1681,8 @@ export declare class SanityClient {
|
|
|
1633
1681
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1634
1682
|
* Returns a promise that resolves to a mutation result object containing the created document ID.
|
|
1635
1683
|
*
|
|
1636
|
-
* @param document Document to either create or replace
|
|
1637
|
-
* @param options Mutation options
|
|
1684
|
+
* @param document - Document to either create or replace
|
|
1685
|
+
* @param options - Mutation options
|
|
1638
1686
|
*/
|
|
1639
1687
|
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
1640
1688
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -1644,8 +1692,8 @@ export declare class SanityClient {
|
|
|
1644
1692
|
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1645
1693
|
* Returns a promise that resolves to the created document.
|
|
1646
1694
|
*
|
|
1647
|
-
* @param document Document to either create or replace
|
|
1648
|
-
* @param options Mutation options
|
|
1695
|
+
* @param document - Document to either create or replace
|
|
1696
|
+
* @param options - Mutation options
|
|
1649
1697
|
*/
|
|
1650
1698
|
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
1651
1699
|
document: IdentifiedSanityDocumentStub<R>,
|
|
@@ -1655,8 +1703,8 @@ export declare class SanityClient {
|
|
|
1655
1703
|
* Deletes a document with the given document ID.
|
|
1656
1704
|
* Returns a promise that resolves to the deleted document.
|
|
1657
1705
|
*
|
|
1658
|
-
* @param id Document ID to delete
|
|
1659
|
-
* @param options Options for the mutation
|
|
1706
|
+
* @param id - Document ID to delete
|
|
1707
|
+
* @param options - Options for the mutation
|
|
1660
1708
|
*/
|
|
1661
1709
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1662
1710
|
id: string,
|
|
@@ -1666,8 +1714,8 @@ export declare class SanityClient {
|
|
|
1666
1714
|
* Deletes a document with the given document ID.
|
|
1667
1715
|
* Returns a promise that resolves to an array containing the deleted document.
|
|
1668
1716
|
*
|
|
1669
|
-
* @param id Document ID to delete
|
|
1670
|
-
* @param options Options for the mutation
|
|
1717
|
+
* @param id - Document ID to delete
|
|
1718
|
+
* @param options - Options for the mutation
|
|
1671
1719
|
*/
|
|
1672
1720
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1673
1721
|
id: string,
|
|
@@ -1677,24 +1725,24 @@ export declare class SanityClient {
|
|
|
1677
1725
|
* Deletes a document with the given document ID.
|
|
1678
1726
|
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
1679
1727
|
*
|
|
1680
|
-
* @param id Document ID to delete
|
|
1681
|
-
* @param options Options for the mutation
|
|
1728
|
+
* @param id - Document ID to delete
|
|
1729
|
+
* @param options - Options for the mutation
|
|
1682
1730
|
*/
|
|
1683
1731
|
delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
1684
1732
|
/**
|
|
1685
1733
|
* Deletes a document with the given document ID.
|
|
1686
1734
|
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
1687
1735
|
*
|
|
1688
|
-
* @param id Document ID to delete
|
|
1689
|
-
* @param options Options for the mutation
|
|
1736
|
+
* @param id - Document ID to delete
|
|
1737
|
+
* @param options - Options for the mutation
|
|
1690
1738
|
*/
|
|
1691
1739
|
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
1692
1740
|
/**
|
|
1693
1741
|
* Deletes a document with the given document ID.
|
|
1694
1742
|
* Returns a promise that resolves to the deleted document.
|
|
1695
1743
|
*
|
|
1696
|
-
* @param id Document ID to delete
|
|
1697
|
-
* @param options Options for the mutation
|
|
1744
|
+
* @param id - Document ID to delete
|
|
1745
|
+
* @param options - Options for the mutation
|
|
1698
1746
|
*/
|
|
1699
1747
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1700
1748
|
id: string,
|
|
@@ -1704,8 +1752,8 @@ export declare class SanityClient {
|
|
|
1704
1752
|
* Deletes one or more documents matching the given query or document ID.
|
|
1705
1753
|
* Returns a promise that resolves to first deleted document.
|
|
1706
1754
|
*
|
|
1707
|
-
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1708
|
-
* @param options Options for the mutation
|
|
1755
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1756
|
+
* @param options - Options for the mutation
|
|
1709
1757
|
*/
|
|
1710
1758
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1711
1759
|
selection: MutationSelection,
|
|
@@ -1715,8 +1763,8 @@ export declare class SanityClient {
|
|
|
1715
1763
|
* Deletes one or more documents matching the given query or document ID.
|
|
1716
1764
|
* Returns a promise that resolves to an array containing the deleted documents.
|
|
1717
1765
|
*
|
|
1718
|
-
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1719
|
-
* @param options Options for the mutation
|
|
1766
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1767
|
+
* @param options - Options for the mutation
|
|
1720
1768
|
*/
|
|
1721
1769
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1722
1770
|
selection: MutationSelection,
|
|
@@ -1726,8 +1774,8 @@ export declare class SanityClient {
|
|
|
1726
1774
|
* Deletes one or more documents matching the given query or document ID.
|
|
1727
1775
|
* Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
|
|
1728
1776
|
*
|
|
1729
|
-
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1730
|
-
* @param options Options for the mutation
|
|
1777
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1778
|
+
* @param options - Options for the mutation
|
|
1731
1779
|
*/
|
|
1732
1780
|
delete(
|
|
1733
1781
|
selection: MutationSelection,
|
|
@@ -1737,8 +1785,8 @@ export declare class SanityClient {
|
|
|
1737
1785
|
* Deletes one or more documents matching the given query or document ID.
|
|
1738
1786
|
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
1739
1787
|
*
|
|
1740
|
-
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1741
|
-
* @param options Options for the mutation
|
|
1788
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1789
|
+
* @param options - Options for the mutation
|
|
1742
1790
|
*/
|
|
1743
1791
|
delete(
|
|
1744
1792
|
selection: MutationSelection,
|
|
@@ -1748,8 +1796,8 @@ export declare class SanityClient {
|
|
|
1748
1796
|
* Deletes one or more documents matching the given query or document ID.
|
|
1749
1797
|
* Returns a promise that resolves to first deleted document.
|
|
1750
1798
|
*
|
|
1751
|
-
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1752
|
-
* @param options Options for the mutation
|
|
1799
|
+
* @param selection - An object with either an `id` or `query` key defining what to delete
|
|
1800
|
+
* @param options - Options for the mutation
|
|
1753
1801
|
*/
|
|
1754
1802
|
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1755
1803
|
selection: MutationSelection,
|
|
@@ -1759,8 +1807,8 @@ export declare class SanityClient {
|
|
|
1759
1807
|
* Perform mutation operations against the configured dataset
|
|
1760
1808
|
* Returns a promise that resolves to the first mutated document.
|
|
1761
1809
|
*
|
|
1762
|
-
* @param operations Mutation operations to execute
|
|
1763
|
-
* @param options Mutation options
|
|
1810
|
+
* @param operations - Mutation operations to execute
|
|
1811
|
+
* @param options - Mutation options
|
|
1764
1812
|
*/
|
|
1765
1813
|
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1766
1814
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
@@ -1770,8 +1818,8 @@ export declare class SanityClient {
|
|
|
1770
1818
|
* Perform mutation operations against the configured dataset.
|
|
1771
1819
|
* Returns a promise that resolves to an array of the mutated documents.
|
|
1772
1820
|
*
|
|
1773
|
-
* @param operations Mutation operations to execute
|
|
1774
|
-
* @param options Mutation options
|
|
1821
|
+
* @param operations - Mutation operations to execute
|
|
1822
|
+
* @param options - Mutation options
|
|
1775
1823
|
*/
|
|
1776
1824
|
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1777
1825
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
@@ -1781,8 +1829,8 @@ export declare class SanityClient {
|
|
|
1781
1829
|
* Perform mutation operations against the configured dataset
|
|
1782
1830
|
* Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
1783
1831
|
*
|
|
1784
|
-
* @param operations Mutation operations to execute
|
|
1785
|
-
* @param options Mutation options
|
|
1832
|
+
* @param operations - Mutation operations to execute
|
|
1833
|
+
* @param options - Mutation options
|
|
1786
1834
|
*/
|
|
1787
1835
|
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1788
1836
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
@@ -1792,8 +1840,8 @@ export declare class SanityClient {
|
|
|
1792
1840
|
* Perform mutation operations against the configured dataset
|
|
1793
1841
|
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
1794
1842
|
*
|
|
1795
|
-
* @param operations Mutation operations to execute
|
|
1796
|
-
* @param options Mutation options
|
|
1843
|
+
* @param operations - Mutation operations to execute
|
|
1844
|
+
* @param options - Mutation options
|
|
1797
1845
|
*/
|
|
1798
1846
|
mutate<R extends Record<string, any>>(
|
|
1799
1847
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
@@ -1803,8 +1851,8 @@ export declare class SanityClient {
|
|
|
1803
1851
|
* Perform mutation operations against the configured dataset
|
|
1804
1852
|
* Returns a promise that resolves to the first mutated document.
|
|
1805
1853
|
*
|
|
1806
|
-
* @param operations Mutation operations to execute
|
|
1807
|
-
* @param options Mutation options
|
|
1854
|
+
* @param operations - Mutation operations to execute
|
|
1855
|
+
* @param options - Mutation options
|
|
1808
1856
|
*/
|
|
1809
1857
|
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1810
1858
|
operations: Mutation<R>[] | Patch | Transaction,
|
|
@@ -1813,14 +1861,14 @@ export declare class SanityClient {
|
|
|
1813
1861
|
/**
|
|
1814
1862
|
* Create a new buildable patch of operations to perform
|
|
1815
1863
|
*
|
|
1816
|
-
* @param documentId Document ID
|
|
1817
|
-
* @param operations Optional object of patch operations to initialize the patch instance with
|
|
1864
|
+
* @param documentId - Document ID(s)to patch
|
|
1865
|
+
* @param operations - Optional object of patch operations to initialize the patch instance with
|
|
1818
1866
|
*/
|
|
1819
|
-
patch(documentId:
|
|
1867
|
+
patch(documentId: PatchSelection, operations?: PatchOperations): Patch
|
|
1820
1868
|
/**
|
|
1821
1869
|
* Create a new transaction of mutations
|
|
1822
1870
|
*
|
|
1823
|
-
* @param operations Optional array of mutation operations to initialize the transaction instance with
|
|
1871
|
+
* @param operations - Optional array of mutation operations to initialize the transaction instance with
|
|
1824
1872
|
*/
|
|
1825
1873
|
transaction<R extends Record<string, any> = Record<string, any>>(
|
|
1826
1874
|
operations?: Mutation<R>[]
|
|
@@ -1829,36 +1877,21 @@ export declare class SanityClient {
|
|
|
1829
1877
|
* DEPRECATED: Perform an HTTP request against the Sanity API
|
|
1830
1878
|
*
|
|
1831
1879
|
* @deprecated Use your own request library!
|
|
1832
|
-
* @param options Request options
|
|
1880
|
+
* @param options - Request options
|
|
1833
1881
|
*/
|
|
1834
1882
|
request<R = any>(options: RawRequestOptions): Promise<R>
|
|
1835
1883
|
/**
|
|
1836
1884
|
* DEPRECATED: Perform an HTTP request a `/data` sub-endpoint
|
|
1837
1885
|
*
|
|
1838
1886
|
* @deprecated Use your own request library!
|
|
1839
|
-
* @param endpoint Endpoint to hit (mutate, query etc)
|
|
1840
|
-
* @param body Request body
|
|
1841
|
-
* @param options Request options
|
|
1887
|
+
* @param endpoint - Endpoint to hit (mutate, query etc)
|
|
1888
|
+
* @param body - Request body
|
|
1889
|
+
* @param options - Request options
|
|
1842
1890
|
*/
|
|
1843
1891
|
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<any>
|
|
1844
|
-
/**
|
|
1845
|
-
* DEPRECATED: Get a Sanity API URL for the URI provided
|
|
1846
|
-
*
|
|
1847
|
-
* @deprecated Should be an internal concern
|
|
1848
|
-
* @param uri URI/path to build URL for
|
|
1849
|
-
* @param canUseCdn Whether or not to allow using the API CDN for this route
|
|
1850
|
-
*/
|
|
1851
|
-
getUrl(uri: string, canUseCdn?: boolean): string
|
|
1852
|
-
/**
|
|
1853
|
-
* DEPRECATED: Get a Sanity API URL for the data operation and path provided
|
|
1854
|
-
*
|
|
1855
|
-
* @deprecated Should be an internal concern
|
|
1856
|
-
* @param operation Data operation
|
|
1857
|
-
* @param path Path to append
|
|
1858
|
-
*/
|
|
1859
|
-
getDataUrl(operation: string, path?: string): string
|
|
1860
1892
|
}
|
|
1861
1893
|
|
|
1894
|
+
/** @internal */
|
|
1862
1895
|
export declare type SanityDocument<T extends Record<string, any> = Record<string, any>> = {
|
|
1863
1896
|
[P in keyof T]: T[P]
|
|
1864
1897
|
} & {
|
|
@@ -1869,12 +1902,14 @@ export declare type SanityDocument<T extends Record<string, any> = Record<string
|
|
|
1869
1902
|
_updatedAt: string
|
|
1870
1903
|
}
|
|
1871
1904
|
|
|
1905
|
+
/** @public */
|
|
1872
1906
|
export declare type SanityDocumentStub<T extends Record<string, any> = Record<string, any>> = {
|
|
1873
1907
|
[P in keyof T]: T[P]
|
|
1874
1908
|
} & {
|
|
1875
1909
|
_type: string
|
|
1876
1910
|
}
|
|
1877
1911
|
|
|
1912
|
+
/** @internal */
|
|
1878
1913
|
export declare interface SanityImageAssetDocument extends SanityAssetDocument {
|
|
1879
1914
|
metadata: {
|
|
1880
1915
|
_type: 'sanity.imageMetadata'
|
|
@@ -1909,6 +1944,7 @@ export declare interface SanityImageAssetDocument extends SanityAssetDocument {
|
|
|
1909
1944
|
}
|
|
1910
1945
|
}
|
|
1911
1946
|
|
|
1947
|
+
/** @internal */
|
|
1912
1948
|
export declare interface SanityImagePalette {
|
|
1913
1949
|
background: string
|
|
1914
1950
|
foreground: string
|
|
@@ -1916,6 +1952,7 @@ export declare interface SanityImagePalette {
|
|
|
1916
1952
|
title: string
|
|
1917
1953
|
}
|
|
1918
1954
|
|
|
1955
|
+
/** @internal */
|
|
1919
1956
|
export declare interface SanityProject {
|
|
1920
1957
|
id: string
|
|
1921
1958
|
displayName: string
|
|
@@ -1934,6 +1971,7 @@ export declare interface SanityProject {
|
|
|
1934
1971
|
}
|
|
1935
1972
|
}
|
|
1936
1973
|
|
|
1974
|
+
/** @internal */
|
|
1937
1975
|
export declare interface SanityProjectMember {
|
|
1938
1976
|
id: string
|
|
1939
1977
|
role: string
|
|
@@ -1941,10 +1979,12 @@ export declare interface SanityProjectMember {
|
|
|
1941
1979
|
isCurrentUser: boolean
|
|
1942
1980
|
}
|
|
1943
1981
|
|
|
1982
|
+
/** @internal */
|
|
1944
1983
|
export declare interface SanityReference {
|
|
1945
1984
|
_ref: string
|
|
1946
1985
|
}
|
|
1947
1986
|
|
|
1987
|
+
/** @internal */
|
|
1948
1988
|
export declare interface SanityUser {
|
|
1949
1989
|
id: string
|
|
1950
1990
|
projectId: string
|
|
@@ -1958,6 +1998,7 @@ export declare interface SanityUser {
|
|
|
1958
1998
|
isCurrentUser: boolean
|
|
1959
1999
|
}
|
|
1960
2000
|
|
|
2001
|
+
/** @public */
|
|
1961
2002
|
export declare class ServerError extends BaseError {
|
|
1962
2003
|
response: ErrorProps['response']
|
|
1963
2004
|
statusCode: ErrorProps['statusCode']
|
|
@@ -1966,6 +2007,7 @@ export declare class ServerError extends BaseError {
|
|
|
1966
2007
|
constructor(res: any)
|
|
1967
2008
|
}
|
|
1968
2009
|
|
|
2010
|
+
/** @internal */
|
|
1969
2011
|
export declare interface SingleMutationResult {
|
|
1970
2012
|
transactionId: string
|
|
1971
2013
|
documentId: string
|
|
@@ -1975,6 +2017,7 @@ export declare interface SingleMutationResult {
|
|
|
1975
2017
|
}[]
|
|
1976
2018
|
}
|
|
1977
2019
|
|
|
2020
|
+
/** @public */
|
|
1978
2021
|
export declare class Transaction extends BaseTransaction {
|
|
1979
2022
|
#private
|
|
1980
2023
|
constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string)
|
|
@@ -2033,36 +2076,43 @@ export declare class Transaction extends BaseTransaction {
|
|
|
2033
2076
|
patch(patch: Patch): this
|
|
2034
2077
|
}
|
|
2035
2078
|
|
|
2079
|
+
/** @internal */
|
|
2036
2080
|
export declare type TransactionAllDocumentIdsMutationOptions = BaseMutationOptions & {
|
|
2037
2081
|
returnFirst?: false
|
|
2038
2082
|
returnDocuments?: false
|
|
2039
2083
|
}
|
|
2040
2084
|
|
|
2085
|
+
/** @internal */
|
|
2041
2086
|
export declare type TransactionAllDocumentsMutationOptions = BaseMutationOptions & {
|
|
2042
2087
|
returnFirst?: false
|
|
2043
2088
|
returnDocuments: true
|
|
2044
2089
|
}
|
|
2045
2090
|
|
|
2091
|
+
/** @internal */
|
|
2046
2092
|
export declare type TransactionFirstDocumentIdMutationOptions = BaseMutationOptions & {
|
|
2047
2093
|
returnFirst: true
|
|
2048
2094
|
returnDocuments?: false
|
|
2049
2095
|
}
|
|
2050
2096
|
|
|
2097
|
+
/** @internal */
|
|
2051
2098
|
export declare type TransactionFirstDocumentMutationOptions = BaseMutationOptions & {
|
|
2052
2099
|
returnFirst: true
|
|
2053
2100
|
returnDocuments: true
|
|
2054
2101
|
}
|
|
2055
2102
|
|
|
2103
|
+
/** @internal */
|
|
2056
2104
|
export declare type TransactionMutationOptions =
|
|
2057
2105
|
| TransactionFirstDocumentMutationOptions
|
|
2058
2106
|
| TransactionFirstDocumentIdMutationOptions
|
|
2059
2107
|
| TransactionAllDocumentsMutationOptions
|
|
2060
2108
|
| TransactionAllDocumentIdsMutationOptions
|
|
2061
2109
|
|
|
2110
|
+
/** @internal */
|
|
2062
2111
|
export declare type UnfilteredResponseQueryOptions = RequestOptions & {
|
|
2063
2112
|
filterResponse: false
|
|
2064
2113
|
}
|
|
2065
2114
|
|
|
2115
|
+
/** @public */
|
|
2066
2116
|
export declare interface UploadClientConfig {
|
|
2067
2117
|
/**
|
|
2068
2118
|
* Optional request tag for the upload
|
|
@@ -2123,11 +2173,19 @@ export declare interface UploadClientConfig {
|
|
|
2123
2173
|
}
|
|
2124
2174
|
}
|
|
2125
2175
|
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2176
|
+
/** @public */
|
|
2177
|
+
export declare class UsersClient {
|
|
2178
|
+
#private
|
|
2179
|
+
constructor(client: SanityClient, httpRequest: HttpRequest)
|
|
2180
|
+
/**
|
|
2181
|
+
* Fetch a user by user ID
|
|
2182
|
+
*
|
|
2183
|
+
* @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.
|
|
2184
|
+
*/
|
|
2185
|
+
getById<T extends 'me' | string>(id: T): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>
|
|
2129
2186
|
}
|
|
2130
2187
|
|
|
2188
|
+
/** @public */
|
|
2131
2189
|
export declare type WelcomeEvent = {
|
|
2132
2190
|
type: 'welcome'
|
|
2133
2191
|
}
|