@sanity/client 4.0.1 → 5.0.0-esm.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +1335 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.js +1312 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.cjs +1344 -0
- package/dist/index.cjs.js +15 -0
- package/dist/index.cjs.map +1 -0
- package/{sanityClient.d.ts → dist/index.d.ts} +991 -1117
- package/dist/index.js +1321 -0
- package/dist/index.js.map +1 -0
- package/package.json +81 -73
- package/src/SanityClient.ts +1261 -0
- package/src/assets/AssetsClient.ts +164 -0
- package/src/auth/AuthClient.ts +43 -0
- package/src/config.ts +95 -0
- package/src/data/dataMethods.ts +328 -0
- package/src/data/encodeQueryString.ts +28 -0
- package/src/data/listen.ts +195 -0
- package/src/data/patch.ts +353 -0
- package/src/data/transaction.ts +352 -0
- package/src/datasets/DatasetsClient.ts +97 -0
- package/src/generateHelpUrl.ts +5 -0
- package/src/http/browserMiddleware.ts +1 -0
- package/src/http/errors.ts +68 -0
- package/src/http/nodeMiddleware.ts +11 -0
- package/src/http/request.ts +50 -0
- package/src/http/requestOptions.ts +31 -0
- package/src/index.browser.ts +18 -0
- package/src/index.ts +57 -0
- package/src/projects/ProjectsClient.ts +45 -0
- package/src/types.ts +502 -0
- package/src/users/UsersClient.ts +46 -0
- package/src/util/defaults.ts +8 -0
- package/src/util/getSelection.ts +21 -0
- package/src/util/once.ts +12 -0
- package/src/util/pick.ts +9 -0
- package/src/validators.ts +76 -0
- package/src/warnings.ts +25 -0
- package/umd/sanityClient.js +5199 -5302
- package/umd/sanityClient.min.js +13 -13
- package/dist/sanityClient.browser.mjs +0 -2806
- package/dist/sanityClient.browser.mjs.map +0 -7
- package/index.js +0 -7
- package/lib/assets/assetsClient.js +0 -145
- package/lib/auth/authClient.js +0 -26
- package/lib/config.js +0 -88
- package/lib/data/dataMethods.js +0 -205
- package/lib/data/encodeQueryString.js +0 -31
- package/lib/data/listen.js +0 -164
- package/lib/data/patch.js +0 -121
- package/lib/data/transaction.js +0 -117
- package/lib/datasets/datasetsClient.js +0 -41
- package/lib/generateHelpUrl.js +0 -11
- package/lib/http/browserMiddleware.js +0 -9
- package/lib/http/errors.js +0 -56
- package/lib/http/nodeMiddleware.js +0 -22
- package/lib/http/queryString.js +0 -17
- package/lib/http/request.js +0 -52
- package/lib/http/requestOptions.js +0 -30
- package/lib/projects/projectsClient.js +0 -25
- package/lib/sanityClient.js +0 -118
- package/lib/users/usersClient.js +0 -20
- package/lib/util/defaults.js +0 -14
- package/lib/util/getSelection.js +0 -24
- package/lib/util/once.js +0 -20
- package/lib/util/pick.js +0 -17
- package/lib/validators.js +0 -76
- package/lib/warnings.js +0 -27
|
@@ -0,0 +1,1261 @@
|
|
|
1
|
+
import {lastValueFrom, Observable} from 'rxjs'
|
|
2
|
+
|
|
3
|
+
import {AssetsClient, ObservableAssetsClient} from './assets/AssetsClient'
|
|
4
|
+
import {AuthClient, BaseAuthClient, ObservableAuthClient} from './auth/AuthClient'
|
|
5
|
+
import {initConfig} from './config'
|
|
6
|
+
import * as dataMethods from './data/dataMethods'
|
|
7
|
+
import {_listen} from './data/listen'
|
|
8
|
+
import {ObservablePatch, Patch} from './data/patch'
|
|
9
|
+
import {ObservableTransaction, Transaction} from './data/transaction'
|
|
10
|
+
import {
|
|
11
|
+
BaseDatasetsClient,
|
|
12
|
+
DatasetsClient,
|
|
13
|
+
ObservableDatasetsClient,
|
|
14
|
+
} from './datasets/DatasetsClient'
|
|
15
|
+
import {
|
|
16
|
+
BaseProjectsClient,
|
|
17
|
+
ObservableProjectsClient,
|
|
18
|
+
ProjectsClient,
|
|
19
|
+
} from './projects/ProjectsClient'
|
|
20
|
+
import type {
|
|
21
|
+
AllDocumentIdsMutationOptions,
|
|
22
|
+
AllDocumentsMutationOptions,
|
|
23
|
+
BaseMutationOptions,
|
|
24
|
+
ClientConfig,
|
|
25
|
+
FilteredResponseQueryOptions,
|
|
26
|
+
FirstDocumentIdMutationOptions,
|
|
27
|
+
FirstDocumentMutationOptions,
|
|
28
|
+
HttpRequest,
|
|
29
|
+
IdentifiedSanityDocumentStub,
|
|
30
|
+
InitializedClientConfig,
|
|
31
|
+
MultipleMutationResult,
|
|
32
|
+
Mutation,
|
|
33
|
+
MutationSelection,
|
|
34
|
+
PatchOperations,
|
|
35
|
+
QueryParams,
|
|
36
|
+
RawQueryResponse,
|
|
37
|
+
RawRequestOptions,
|
|
38
|
+
SanityDocument,
|
|
39
|
+
SanityDocumentStub,
|
|
40
|
+
SingleMutationResult,
|
|
41
|
+
UnfilteredResponseQueryOptions,
|
|
42
|
+
} from './types'
|
|
43
|
+
import {BaseUsersClient, ObservableUsersClient, UsersClient} from './users/UsersClient'
|
|
44
|
+
import * as validators from './validators'
|
|
45
|
+
|
|
46
|
+
export type {
|
|
47
|
+
_listen,
|
|
48
|
+
AssetsClient,
|
|
49
|
+
AuthClient,
|
|
50
|
+
BaseAuthClient,
|
|
51
|
+
BaseDatasetsClient,
|
|
52
|
+
BaseProjectsClient,
|
|
53
|
+
BaseUsersClient,
|
|
54
|
+
DatasetsClient,
|
|
55
|
+
ObservableAssetsClient,
|
|
56
|
+
ObservableAuthClient,
|
|
57
|
+
ObservableDatasetsClient,
|
|
58
|
+
ObservableProjectsClient,
|
|
59
|
+
ObservableUsersClient,
|
|
60
|
+
ProjectsClient,
|
|
61
|
+
UsersClient,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class BaseSanityClient {
|
|
65
|
+
#clientConfig: InitializedClientConfig
|
|
66
|
+
|
|
67
|
+
constructor(config: ClientConfig) {
|
|
68
|
+
this.config(config)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** @internal */
|
|
72
|
+
protected config(newConfig?: Partial<ClientConfig>): ClientConfig | this {
|
|
73
|
+
if (newConfig === undefined) {
|
|
74
|
+
return {...this.#clientConfig}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (this.#clientConfig && this.#clientConfig.allowReconfigure === false) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
'Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client'
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
this.#clientConfig = initConfig(newConfig, this.#clientConfig || {})
|
|
84
|
+
return this
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Returns whether or not this client is using the Promise API (otherwise it is using observables)
|
|
89
|
+
* @internal
|
|
90
|
+
* @deprecated Internals, should not be used externally
|
|
91
|
+
*/
|
|
92
|
+
// @TODO check if this can be deleted
|
|
93
|
+
isPromiseAPI(): this is SanityClient {
|
|
94
|
+
return this instanceof SanityClient
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* DEPRECATED: Get a Sanity API URL for the URI provided
|
|
99
|
+
*
|
|
100
|
+
* @deprecated Should be an internal concern
|
|
101
|
+
* @param uri URI/path to build URL for
|
|
102
|
+
* @param canUseCdn Whether or not to allow using the API CDN for this route
|
|
103
|
+
*/
|
|
104
|
+
getUrl(uri: string, canUseCdn = false) {
|
|
105
|
+
const base = canUseCdn ? this.#clientConfig.cdnUrl : this.#clientConfig.url
|
|
106
|
+
return `${base}/${uri.replace(/^\//, '')}`
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* DEPRECATED: Get a Sanity API URL for the data operation and path provided
|
|
111
|
+
*
|
|
112
|
+
* @deprecated Should be an internal concern
|
|
113
|
+
* @param operation Data operation
|
|
114
|
+
* @param path Path to append
|
|
115
|
+
*/
|
|
116
|
+
getDataUrl(operation: string, path?: string): string {
|
|
117
|
+
const config = this.config()
|
|
118
|
+
const catalog = validators.hasDataset(config)
|
|
119
|
+
const baseUri = `/${operation}/${catalog}`
|
|
120
|
+
const uri = path ? `${baseUri}/${path}` : baseUri
|
|
121
|
+
return `/data${uri}`.replace(/\/($|\?)/, '$1')
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export class ObservableSanityClient extends BaseSanityClient {
|
|
126
|
+
assets: ObservableAssetsClient
|
|
127
|
+
auth: ObservableAuthClient
|
|
128
|
+
datasets: ObservableDatasetsClient
|
|
129
|
+
projects: ObservableProjectsClient
|
|
130
|
+
users: ObservableUsersClient
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Private properties
|
|
134
|
+
*/
|
|
135
|
+
#httpRequest: HttpRequest
|
|
136
|
+
|
|
137
|
+
constructor(httpRequest: HttpRequest, config: ClientConfig) {
|
|
138
|
+
super(config)
|
|
139
|
+
|
|
140
|
+
this.#httpRequest = httpRequest
|
|
141
|
+
|
|
142
|
+
this.assets = new ObservableAssetsClient(this, this.#httpRequest)
|
|
143
|
+
this.auth = new ObservableAuthClient(this)
|
|
144
|
+
this.datasets = new ObservableDatasetsClient(this)
|
|
145
|
+
this.projects = new ObservableProjectsClient(this)
|
|
146
|
+
this.users = new ObservableUsersClient(this)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Clone the client - returns a new instance
|
|
151
|
+
*/
|
|
152
|
+
clone(): ObservableSanityClient {
|
|
153
|
+
return new ObservableSanityClient(this.#httpRequest, this.config())
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Returns the current client configuration
|
|
158
|
+
*/
|
|
159
|
+
config(): InitializedClientConfig
|
|
160
|
+
/**
|
|
161
|
+
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
162
|
+
*/
|
|
163
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
164
|
+
config(newConfig?: Partial<ClientConfig>): ClientConfig | this {
|
|
165
|
+
return super.config(newConfig)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Clone the client with a new (partial) configuration.
|
|
170
|
+
*
|
|
171
|
+
* @param newConfig New client configuration properties, shallowly merged with existing configuration
|
|
172
|
+
*/
|
|
173
|
+
withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient {
|
|
174
|
+
return new ObservableSanityClient(this.#httpRequest, {...this.config(), ...newConfig})
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Perform a GROQ-query against the configured dataset.
|
|
179
|
+
*
|
|
180
|
+
* @param query GROQ-query to perform
|
|
181
|
+
*/
|
|
182
|
+
fetch<R = any>(query: string): Observable<R>
|
|
183
|
+
/**
|
|
184
|
+
* Perform a GROQ-query against the configured dataset.
|
|
185
|
+
*
|
|
186
|
+
* @param query GROQ-query to perform
|
|
187
|
+
* @param params Query parameters
|
|
188
|
+
*/
|
|
189
|
+
fetch<R = any>(query: string, params: QueryParams): Observable<R>
|
|
190
|
+
/**
|
|
191
|
+
* Perform a GROQ-query against the configured dataset.
|
|
192
|
+
*
|
|
193
|
+
* @param query GROQ-query to perform
|
|
194
|
+
* @param params Query parameters
|
|
195
|
+
* @param options Request options
|
|
196
|
+
*/
|
|
197
|
+
fetch<R = any>(
|
|
198
|
+
query: string,
|
|
199
|
+
params: QueryParams | undefined,
|
|
200
|
+
options: FilteredResponseQueryOptions
|
|
201
|
+
): Observable<R>
|
|
202
|
+
/**
|
|
203
|
+
* Perform a GROQ-query against the configured dataset.
|
|
204
|
+
*
|
|
205
|
+
* @param query GROQ-query to perform
|
|
206
|
+
* @param params Query parameters
|
|
207
|
+
* @param options Request options
|
|
208
|
+
*/
|
|
209
|
+
fetch<R = any>(
|
|
210
|
+
query: string,
|
|
211
|
+
params: QueryParams | undefined,
|
|
212
|
+
options: UnfilteredResponseQueryOptions
|
|
213
|
+
): Observable<RawQueryResponse<R>>
|
|
214
|
+
fetch<R = any>(
|
|
215
|
+
query: string,
|
|
216
|
+
params?: QueryParams,
|
|
217
|
+
options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {}
|
|
218
|
+
): Observable<RawQueryResponse<R> | R> {
|
|
219
|
+
return dataMethods._fetch<R>(this, this.#httpRequest, query, params, options)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Fetch a single document with the given ID.
|
|
224
|
+
*
|
|
225
|
+
* @param id Document ID to fetch
|
|
226
|
+
* @param options Request options
|
|
227
|
+
*/
|
|
228
|
+
getDocument<R extends Record<string, any> = Record<string, any>>(
|
|
229
|
+
id: string,
|
|
230
|
+
options?: {tag?: string}
|
|
231
|
+
): Observable<SanityDocument<R> | undefined> {
|
|
232
|
+
return dataMethods._getDocument<R>(this, this.#httpRequest, id, options)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Fetch multiple documents in one request.
|
|
237
|
+
* Should be used sparingly - performing a query is usually a better option.
|
|
238
|
+
* The order/position of documents is preserved based on the original array of IDs.
|
|
239
|
+
* If a any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
240
|
+
*
|
|
241
|
+
* @param ids Document IDs to fetch
|
|
242
|
+
* @param options Request options
|
|
243
|
+
*/
|
|
244
|
+
getDocuments<R extends Record<string, any> = Record<string, any>>(
|
|
245
|
+
ids: string[],
|
|
246
|
+
options?: {tag?: string}
|
|
247
|
+
): Observable<(SanityDocument<R> | null)[]> {
|
|
248
|
+
return dataMethods._getDocuments<R>(this, this.#httpRequest, ids, options)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
253
|
+
* Returns an observable that resolves to the created document.
|
|
254
|
+
*
|
|
255
|
+
* @param document Document to create
|
|
256
|
+
* @param options Mutation options
|
|
257
|
+
*/
|
|
258
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
259
|
+
document: SanityDocumentStub<R>,
|
|
260
|
+
options: FirstDocumentMutationOptions
|
|
261
|
+
): Observable<SanityDocument<R>>
|
|
262
|
+
/**
|
|
263
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
264
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
265
|
+
*
|
|
266
|
+
* @param document Document to create
|
|
267
|
+
* @param options Mutation options
|
|
268
|
+
*/
|
|
269
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
270
|
+
document: SanityDocumentStub<R>,
|
|
271
|
+
options: AllDocumentsMutationOptions
|
|
272
|
+
): Observable<SanityDocument<R>[]>
|
|
273
|
+
/**
|
|
274
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
275
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
276
|
+
*
|
|
277
|
+
* @param document Document to create
|
|
278
|
+
* @param options Mutation options
|
|
279
|
+
*/
|
|
280
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
281
|
+
document: SanityDocumentStub<R>,
|
|
282
|
+
options: FirstDocumentIdMutationOptions
|
|
283
|
+
): Observable<SingleMutationResult>
|
|
284
|
+
/**
|
|
285
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
286
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
287
|
+
*
|
|
288
|
+
* @param document Document to create
|
|
289
|
+
* @param options Mutation options
|
|
290
|
+
*/
|
|
291
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
292
|
+
document: SanityDocumentStub<R>,
|
|
293
|
+
options: AllDocumentIdsMutationOptions
|
|
294
|
+
): Observable<MultipleMutationResult>
|
|
295
|
+
/**
|
|
296
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
297
|
+
* Returns an observable that resolves to the created document.
|
|
298
|
+
*
|
|
299
|
+
* @param document Document to create
|
|
300
|
+
* @param options Mutation options
|
|
301
|
+
*/
|
|
302
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
303
|
+
document: SanityDocumentStub<R>,
|
|
304
|
+
options?: BaseMutationOptions
|
|
305
|
+
): Observable<SanityDocument<R>>
|
|
306
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
307
|
+
document: SanityDocumentStub<R>,
|
|
308
|
+
options?:
|
|
309
|
+
| AllDocumentIdsMutationOptions
|
|
310
|
+
| AllDocumentsMutationOptions
|
|
311
|
+
| BaseMutationOptions
|
|
312
|
+
| FirstDocumentIdMutationOptions
|
|
313
|
+
| FirstDocumentMutationOptions
|
|
314
|
+
): Observable<
|
|
315
|
+
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
316
|
+
> {
|
|
317
|
+
return dataMethods._create<R>(this, this.#httpRequest, document, 'create', options)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Create a document if no document with the same ID already exists.
|
|
322
|
+
* Returns an observable that resolves to the created document.
|
|
323
|
+
*
|
|
324
|
+
* @param document Document to create
|
|
325
|
+
* @param options Mutation options
|
|
326
|
+
*/
|
|
327
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
328
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
329
|
+
options: FirstDocumentMutationOptions
|
|
330
|
+
): Observable<SanityDocument<R>>
|
|
331
|
+
/**
|
|
332
|
+
* Create a document if no document with the same ID already exists.
|
|
333
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
334
|
+
*
|
|
335
|
+
* @param document Document to create
|
|
336
|
+
* @param options Mutation options
|
|
337
|
+
*/
|
|
338
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
339
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
340
|
+
options: AllDocumentsMutationOptions
|
|
341
|
+
): Observable<SanityDocument<R>[]>
|
|
342
|
+
/**
|
|
343
|
+
* Create a document if no document with the same ID already exists.
|
|
344
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
345
|
+
*
|
|
346
|
+
* @param document Document to create
|
|
347
|
+
* @param options Mutation options
|
|
348
|
+
*/
|
|
349
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
350
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
351
|
+
options: FirstDocumentIdMutationOptions
|
|
352
|
+
): Observable<SingleMutationResult>
|
|
353
|
+
/**
|
|
354
|
+
* Create a document if no document with the same ID already exists.
|
|
355
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
356
|
+
*
|
|
357
|
+
* @param document Document to create
|
|
358
|
+
* @param options Mutation options
|
|
359
|
+
*/
|
|
360
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
361
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
362
|
+
options: AllDocumentIdsMutationOptions
|
|
363
|
+
): Observable<MultipleMutationResult>
|
|
364
|
+
/**
|
|
365
|
+
* Create a document if no document with the same ID already exists.
|
|
366
|
+
* Returns an observable that resolves to the created document.
|
|
367
|
+
*
|
|
368
|
+
* @param document Document to create
|
|
369
|
+
* @param options Mutation options
|
|
370
|
+
*/
|
|
371
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
372
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
373
|
+
options?: BaseMutationOptions
|
|
374
|
+
): Observable<SanityDocument<R>>
|
|
375
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
376
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
377
|
+
options?:
|
|
378
|
+
| AllDocumentIdsMutationOptions
|
|
379
|
+
| AllDocumentsMutationOptions
|
|
380
|
+
| BaseMutationOptions
|
|
381
|
+
| FirstDocumentIdMutationOptions
|
|
382
|
+
| FirstDocumentMutationOptions
|
|
383
|
+
): Observable<
|
|
384
|
+
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
385
|
+
> {
|
|
386
|
+
return dataMethods._createIfNotExists<R>(this, this.#httpRequest, document, options)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
391
|
+
* Returns an observable that resolves to the created document.
|
|
392
|
+
*
|
|
393
|
+
* @param document Document to either create or replace
|
|
394
|
+
* @param options Mutation options
|
|
395
|
+
*/
|
|
396
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
397
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
398
|
+
options: FirstDocumentMutationOptions
|
|
399
|
+
): Observable<SanityDocument<R>>
|
|
400
|
+
/**
|
|
401
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
402
|
+
* Returns an observable that resolves to an array containing the created document.
|
|
403
|
+
*
|
|
404
|
+
* @param document Document to either create or replace
|
|
405
|
+
* @param options Mutation options
|
|
406
|
+
*/
|
|
407
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
408
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
409
|
+
options: AllDocumentsMutationOptions
|
|
410
|
+
): Observable<SanityDocument<R>[]>
|
|
411
|
+
/**
|
|
412
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
413
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the created document.
|
|
414
|
+
*
|
|
415
|
+
* @param document Document to either create or replace
|
|
416
|
+
* @param options Mutation options
|
|
417
|
+
*/
|
|
418
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
419
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
420
|
+
options: FirstDocumentIdMutationOptions
|
|
421
|
+
): Observable<SingleMutationResult>
|
|
422
|
+
/**
|
|
423
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
424
|
+
* Returns an observable that resolves to a mutation result object containing the created document ID.
|
|
425
|
+
*
|
|
426
|
+
* @param document Document to either create or replace
|
|
427
|
+
* @param options Mutation options
|
|
428
|
+
*/
|
|
429
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
430
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
431
|
+
options: AllDocumentIdsMutationOptions
|
|
432
|
+
): Observable<MultipleMutationResult>
|
|
433
|
+
/**
|
|
434
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
435
|
+
* Returns an observable that resolves to the created document.
|
|
436
|
+
*
|
|
437
|
+
* @param document Document to either create or replace
|
|
438
|
+
* @param options Mutation options
|
|
439
|
+
*/
|
|
440
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
441
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
442
|
+
options?: BaseMutationOptions
|
|
443
|
+
): Observable<SanityDocument<R>>
|
|
444
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
445
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
446
|
+
options?:
|
|
447
|
+
| AllDocumentIdsMutationOptions
|
|
448
|
+
| AllDocumentsMutationOptions
|
|
449
|
+
| BaseMutationOptions
|
|
450
|
+
| FirstDocumentIdMutationOptions
|
|
451
|
+
| FirstDocumentMutationOptions
|
|
452
|
+
): Observable<
|
|
453
|
+
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
454
|
+
> {
|
|
455
|
+
return dataMethods._createOrReplace<R>(this, this.#httpRequest, document, options)
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Deletes a document with the given document ID.
|
|
460
|
+
* Returns an observable that resolves to the deleted document.
|
|
461
|
+
*
|
|
462
|
+
* @param id Document ID to delete
|
|
463
|
+
* @param options Options for the mutation
|
|
464
|
+
*/
|
|
465
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
466
|
+
id: string,
|
|
467
|
+
options: FirstDocumentMutationOptions
|
|
468
|
+
): Observable<SanityDocument<R>>
|
|
469
|
+
/**
|
|
470
|
+
* Deletes a document with the given document ID.
|
|
471
|
+
* Returns an observable that resolves to an array containing the deleted document.
|
|
472
|
+
*
|
|
473
|
+
* @param id Document ID to delete
|
|
474
|
+
* @param options Options for the mutation
|
|
475
|
+
*/
|
|
476
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
477
|
+
id: string,
|
|
478
|
+
options: AllDocumentsMutationOptions
|
|
479
|
+
): Observable<SanityDocument<R>[]>
|
|
480
|
+
/**
|
|
481
|
+
* Deletes a document with the given document ID.
|
|
482
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
483
|
+
*
|
|
484
|
+
* @param id Document ID to delete
|
|
485
|
+
* @param options Options for the mutation
|
|
486
|
+
*/
|
|
487
|
+
delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>
|
|
488
|
+
/**
|
|
489
|
+
* Deletes a document with the given document ID.
|
|
490
|
+
* Returns an observable that resolves to a mutation result object containing the deleted document ID.
|
|
491
|
+
*
|
|
492
|
+
* @param id Document ID to delete
|
|
493
|
+
* @param options Options for the mutation
|
|
494
|
+
*/
|
|
495
|
+
delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>
|
|
496
|
+
/**
|
|
497
|
+
* Deletes a document with the given document ID.
|
|
498
|
+
* Returns an observable that resolves to the deleted document.
|
|
499
|
+
*
|
|
500
|
+
* @param id Document ID to delete
|
|
501
|
+
* @param options Options for the mutation
|
|
502
|
+
*/
|
|
503
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
504
|
+
id: string,
|
|
505
|
+
options?: BaseMutationOptions
|
|
506
|
+
): Observable<SanityDocument<R>>
|
|
507
|
+
/**
|
|
508
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
509
|
+
* Returns an observable that resolves to first deleted document.
|
|
510
|
+
*
|
|
511
|
+
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
512
|
+
* @param options Options for the mutation
|
|
513
|
+
*/
|
|
514
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
515
|
+
selection: MutationSelection,
|
|
516
|
+
options: FirstDocumentMutationOptions
|
|
517
|
+
): Observable<SanityDocument<R>>
|
|
518
|
+
/**
|
|
519
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
520
|
+
* Returns an observable that resolves to an array containing the deleted documents.
|
|
521
|
+
*
|
|
522
|
+
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
523
|
+
* @param options Options for the mutation
|
|
524
|
+
*/
|
|
525
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
526
|
+
selection: MutationSelection,
|
|
527
|
+
options: AllDocumentsMutationOptions
|
|
528
|
+
): Observable<SanityDocument<R>[]>
|
|
529
|
+
/**
|
|
530
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
531
|
+
* Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.
|
|
532
|
+
*
|
|
533
|
+
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
534
|
+
* @param options Options for the mutation
|
|
535
|
+
*/
|
|
536
|
+
delete(
|
|
537
|
+
selection: MutationSelection,
|
|
538
|
+
options: FirstDocumentIdMutationOptions
|
|
539
|
+
): Observable<SingleMutationResult>
|
|
540
|
+
/**
|
|
541
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
542
|
+
* Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.
|
|
543
|
+
*
|
|
544
|
+
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
545
|
+
* @param options Options for the mutation
|
|
546
|
+
*/
|
|
547
|
+
delete(
|
|
548
|
+
selection: MutationSelection,
|
|
549
|
+
options: AllDocumentIdsMutationOptions
|
|
550
|
+
): Observable<MultipleMutationResult>
|
|
551
|
+
/**
|
|
552
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
553
|
+
* Returns an observable that resolves to first deleted document.
|
|
554
|
+
*
|
|
555
|
+
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
556
|
+
* @param options Options for the mutation
|
|
557
|
+
*/
|
|
558
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
559
|
+
selection: MutationSelection,
|
|
560
|
+
options?: BaseMutationOptions
|
|
561
|
+
): Observable<SanityDocument<R>>
|
|
562
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
563
|
+
selection: string | MutationSelection,
|
|
564
|
+
options?:
|
|
565
|
+
| AllDocumentIdsMutationOptions
|
|
566
|
+
| AllDocumentsMutationOptions
|
|
567
|
+
| BaseMutationOptions
|
|
568
|
+
| FirstDocumentIdMutationOptions
|
|
569
|
+
| FirstDocumentMutationOptions
|
|
570
|
+
): Observable<
|
|
571
|
+
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
572
|
+
> {
|
|
573
|
+
return dataMethods._delete<R>(this, this.#httpRequest, selection, options)
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Perform mutation operations against the configured dataset
|
|
578
|
+
* Returns an observable that resolves to the first mutated document.
|
|
579
|
+
*
|
|
580
|
+
* @param operations Mutation operations to execute
|
|
581
|
+
* @param options Mutation options
|
|
582
|
+
*/
|
|
583
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
584
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
585
|
+
options: FirstDocumentMutationOptions
|
|
586
|
+
): Observable<SanityDocument<R>>
|
|
587
|
+
/**
|
|
588
|
+
* Perform mutation operations against the configured dataset.
|
|
589
|
+
* Returns an observable that resolves to an array of the mutated documents.
|
|
590
|
+
*
|
|
591
|
+
* @param operations Mutation operations to execute
|
|
592
|
+
* @param options Mutation options
|
|
593
|
+
*/
|
|
594
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
595
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
596
|
+
options: AllDocumentsMutationOptions
|
|
597
|
+
): Observable<SanityDocument<R>[]>
|
|
598
|
+
/**
|
|
599
|
+
* Perform mutation operations against the configured dataset
|
|
600
|
+
* Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
601
|
+
*
|
|
602
|
+
* @param operations Mutation operations to execute
|
|
603
|
+
* @param options Mutation options
|
|
604
|
+
*/
|
|
605
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
606
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
607
|
+
options: FirstDocumentIdMutationOptions
|
|
608
|
+
): Observable<SingleMutationResult>
|
|
609
|
+
/**
|
|
610
|
+
* Perform mutation operations against the configured dataset
|
|
611
|
+
* Returns an observable that resolves to a mutation result object containing the mutated document IDs.
|
|
612
|
+
*
|
|
613
|
+
* @param operations Mutation operations to execute
|
|
614
|
+
* @param options Mutation options
|
|
615
|
+
*/
|
|
616
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
617
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
618
|
+
options: AllDocumentIdsMutationOptions
|
|
619
|
+
): Observable<MultipleMutationResult>
|
|
620
|
+
/**
|
|
621
|
+
* Perform mutation operations against the configured dataset
|
|
622
|
+
* Returns an observable that resolves to the first mutated document.
|
|
623
|
+
*
|
|
624
|
+
* @param operations Mutation operations to execute
|
|
625
|
+
* @param options Mutation options
|
|
626
|
+
*/
|
|
627
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
628
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
629
|
+
options?: BaseMutationOptions
|
|
630
|
+
): Observable<SanityDocument<R>>
|
|
631
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
632
|
+
operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,
|
|
633
|
+
options?:
|
|
634
|
+
| FirstDocumentMutationOptions
|
|
635
|
+
| AllDocumentsMutationOptions
|
|
636
|
+
| FirstDocumentIdMutationOptions
|
|
637
|
+
| AllDocumentIdsMutationOptions
|
|
638
|
+
| BaseMutationOptions
|
|
639
|
+
): Observable<
|
|
640
|
+
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
641
|
+
> {
|
|
642
|
+
return dataMethods._mutate<R>(this, this.#httpRequest, operations, options)
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Create a new buildable patch of operations to perform
|
|
647
|
+
*
|
|
648
|
+
* @param documentId Document ID to patch
|
|
649
|
+
* @param operations Optional object of patch operations to initialize the patch instance with
|
|
650
|
+
*/
|
|
651
|
+
patch(documentId: string | MutationSelection, operations?: PatchOperations): ObservablePatch {
|
|
652
|
+
return new ObservablePatch(documentId, operations, this)
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Create a new transaction of mutations
|
|
657
|
+
*
|
|
658
|
+
* @param operations Optional array of mutation operations to initialize the transaction instance with
|
|
659
|
+
*/
|
|
660
|
+
transaction<R extends Record<string, any> = Record<string, any>>(
|
|
661
|
+
operations?: Mutation<R>[]
|
|
662
|
+
): ObservableTransaction {
|
|
663
|
+
return new ObservableTransaction(operations, this)
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* DEPRECATED: Perform an HTTP request against the Sanity API
|
|
668
|
+
*
|
|
669
|
+
* @deprecated Use your own request library!
|
|
670
|
+
* @param options Request options
|
|
671
|
+
*/
|
|
672
|
+
request<R = any>(options: RawRequestOptions): Observable<R> {
|
|
673
|
+
return dataMethods._request(this, this.#httpRequest, options)
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
export class SanityClient extends BaseSanityClient {
|
|
678
|
+
assets: AssetsClient
|
|
679
|
+
auth: AuthClient
|
|
680
|
+
datasets: DatasetsClient
|
|
681
|
+
projects: ProjectsClient
|
|
682
|
+
users: UsersClient
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
686
|
+
*/
|
|
687
|
+
observable: ObservableSanityClient
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Private properties
|
|
691
|
+
*/
|
|
692
|
+
#httpRequest: HttpRequest
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Instance properties
|
|
696
|
+
*/
|
|
697
|
+
listen = _listen
|
|
698
|
+
|
|
699
|
+
constructor(httpRequest: HttpRequest, config: ClientConfig) {
|
|
700
|
+
super(config)
|
|
701
|
+
|
|
702
|
+
this.#httpRequest = httpRequest
|
|
703
|
+
|
|
704
|
+
this.assets = new AssetsClient(this, this.#httpRequest)
|
|
705
|
+
this.auth = new AuthClient(this)
|
|
706
|
+
this.datasets = new DatasetsClient(this)
|
|
707
|
+
this.projects = new ProjectsClient(this)
|
|
708
|
+
this.users = new UsersClient(this)
|
|
709
|
+
|
|
710
|
+
this.observable = new ObservableSanityClient(httpRequest, this.config())
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Clone the client - returns a new instance
|
|
715
|
+
*/
|
|
716
|
+
clone(): SanityClient {
|
|
717
|
+
return new SanityClient(this.#httpRequest, this.config())
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Returns the current client configuration
|
|
722
|
+
*/
|
|
723
|
+
config(): InitializedClientConfig
|
|
724
|
+
/**
|
|
725
|
+
* Reconfigure the client. Note that this _mutates_ the current client.
|
|
726
|
+
*/
|
|
727
|
+
config(newConfig?: Partial<ClientConfig>): this
|
|
728
|
+
config(newConfig?: Partial<ClientConfig>): ClientConfig | this {
|
|
729
|
+
if (newConfig) {
|
|
730
|
+
this.observable.config(newConfig)
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
return super.config(newConfig)
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Clone the client with a new (partial) configuration.
|
|
738
|
+
*
|
|
739
|
+
* @param newConfig New client configuration properties, shallowly merged with existing configuration
|
|
740
|
+
*/
|
|
741
|
+
withConfig(newConfig?: Partial<ClientConfig>): SanityClient {
|
|
742
|
+
return new SanityClient(this.#httpRequest, {...this.config(), ...newConfig})
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Perform a GROQ-query against the configured dataset.
|
|
747
|
+
*
|
|
748
|
+
* @param query GROQ-query to perform
|
|
749
|
+
*/
|
|
750
|
+
fetch<R = any>(query: string): Promise<R>
|
|
751
|
+
/**
|
|
752
|
+
* Perform a GROQ-query against the configured dataset.
|
|
753
|
+
*
|
|
754
|
+
* @param query GROQ-query to perform
|
|
755
|
+
* @param params Optional query parameters
|
|
756
|
+
*/
|
|
757
|
+
fetch<R = any>(query: string, params: QueryParams): Promise<R>
|
|
758
|
+
/**
|
|
759
|
+
* Perform a GROQ-query against the configured dataset.
|
|
760
|
+
*
|
|
761
|
+
* @param query GROQ-query to perform
|
|
762
|
+
* @param params Optional query parameters
|
|
763
|
+
* @param options Request options
|
|
764
|
+
*/
|
|
765
|
+
fetch<R = any>(
|
|
766
|
+
query: string,
|
|
767
|
+
params: QueryParams | undefined,
|
|
768
|
+
options: FilteredResponseQueryOptions
|
|
769
|
+
): Promise<R>
|
|
770
|
+
/**
|
|
771
|
+
* Perform a GROQ-query against the configured dataset.
|
|
772
|
+
*
|
|
773
|
+
* @param query GROQ-query to perform
|
|
774
|
+
* @param params Optional query parameters
|
|
775
|
+
* @param options Request options
|
|
776
|
+
*/
|
|
777
|
+
fetch<R = any>(
|
|
778
|
+
query: string,
|
|
779
|
+
params: QueryParams | undefined,
|
|
780
|
+
options: UnfilteredResponseQueryOptions
|
|
781
|
+
): Promise<RawQueryResponse<R>>
|
|
782
|
+
fetch<R = any>(
|
|
783
|
+
query: string,
|
|
784
|
+
params?: QueryParams,
|
|
785
|
+
options: FilteredResponseQueryOptions | UnfilteredResponseQueryOptions = {}
|
|
786
|
+
): Promise<RawQueryResponse<R> | R> {
|
|
787
|
+
return lastValueFrom(dataMethods._fetch<R>(this, this.#httpRequest, query, params, options))
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Fetch a single document with the given ID.
|
|
792
|
+
*
|
|
793
|
+
* @param id Document ID to fetch
|
|
794
|
+
* @param options Request options
|
|
795
|
+
*/
|
|
796
|
+
getDocument<R extends Record<string, any> = Record<string, any>>(
|
|
797
|
+
id: string,
|
|
798
|
+
options?: {tag?: string}
|
|
799
|
+
): Promise<SanityDocument<R> | undefined> {
|
|
800
|
+
return lastValueFrom(dataMethods._getDocument<R>(this, this.#httpRequest, id, options))
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Fetch multiple documents in one request.
|
|
805
|
+
* Should be used sparingly - performing a query is usually a better option.
|
|
806
|
+
* The order/position of documents is preserved based on the original array of IDs.
|
|
807
|
+
* If a any of the documents are missing, they will be replaced by a `null` entry in the returned array
|
|
808
|
+
*
|
|
809
|
+
* @param ids Document IDs to fetch
|
|
810
|
+
* @param options Request options
|
|
811
|
+
*/
|
|
812
|
+
getDocuments<R extends Record<string, any> = Record<string, any>>(
|
|
813
|
+
ids: string[],
|
|
814
|
+
options?: {tag?: string}
|
|
815
|
+
): Promise<(SanityDocument<R> | null)[]> {
|
|
816
|
+
return lastValueFrom(dataMethods._getDocuments<R>(this, this.#httpRequest, ids, options))
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
821
|
+
* Returns a promise that resolves to the created document.
|
|
822
|
+
*
|
|
823
|
+
* @param document Document to create
|
|
824
|
+
* @param options Mutation options
|
|
825
|
+
*/
|
|
826
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
827
|
+
document: SanityDocumentStub<R>,
|
|
828
|
+
options: FirstDocumentMutationOptions
|
|
829
|
+
): Promise<SanityDocument<R>>
|
|
830
|
+
/**
|
|
831
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
832
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
833
|
+
*
|
|
834
|
+
* @param document Document to create
|
|
835
|
+
* @param options Mutation options
|
|
836
|
+
*/
|
|
837
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
838
|
+
document: SanityDocumentStub<R>,
|
|
839
|
+
options: AllDocumentsMutationOptions
|
|
840
|
+
): Promise<SanityDocument<R>[]>
|
|
841
|
+
/**
|
|
842
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
843
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
844
|
+
*
|
|
845
|
+
* @param document Document to create
|
|
846
|
+
* @param options Mutation options
|
|
847
|
+
*/
|
|
848
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
849
|
+
document: SanityDocumentStub<R>,
|
|
850
|
+
options: FirstDocumentIdMutationOptions
|
|
851
|
+
): Promise<SingleMutationResult>
|
|
852
|
+
/**
|
|
853
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
854
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
855
|
+
*
|
|
856
|
+
* @param document Document to create
|
|
857
|
+
* @param options Mutation options
|
|
858
|
+
*/
|
|
859
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
860
|
+
document: SanityDocumentStub<R>,
|
|
861
|
+
options: AllDocumentIdsMutationOptions
|
|
862
|
+
): Promise<MultipleMutationResult>
|
|
863
|
+
/**
|
|
864
|
+
* Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.
|
|
865
|
+
* Returns a promise that resolves to the created document.
|
|
866
|
+
*
|
|
867
|
+
* @param document Document to create
|
|
868
|
+
* @param options Mutation options
|
|
869
|
+
*/
|
|
870
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
871
|
+
document: SanityDocumentStub<R>,
|
|
872
|
+
options?: BaseMutationOptions
|
|
873
|
+
): Promise<SanityDocument<R>>
|
|
874
|
+
create<R extends Record<string, any> = Record<string, any>>(
|
|
875
|
+
document: SanityDocumentStub<R>,
|
|
876
|
+
options?:
|
|
877
|
+
| AllDocumentIdsMutationOptions
|
|
878
|
+
| AllDocumentsMutationOptions
|
|
879
|
+
| BaseMutationOptions
|
|
880
|
+
| FirstDocumentIdMutationOptions
|
|
881
|
+
| FirstDocumentMutationOptions
|
|
882
|
+
): Promise<
|
|
883
|
+
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
884
|
+
> {
|
|
885
|
+
return lastValueFrom(
|
|
886
|
+
dataMethods._create<R>(this, this.#httpRequest, document, 'create', options)
|
|
887
|
+
)
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Create a document if no document with the same ID already exists.
|
|
892
|
+
* Returns a promise that resolves to the created document.
|
|
893
|
+
*
|
|
894
|
+
* @param document Document to create
|
|
895
|
+
* @param options Mutation options
|
|
896
|
+
*/
|
|
897
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
898
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
899
|
+
options: FirstDocumentMutationOptions
|
|
900
|
+
): Promise<SanityDocument<R>>
|
|
901
|
+
/**
|
|
902
|
+
* Create a document if no document with the same ID already exists.
|
|
903
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
904
|
+
*
|
|
905
|
+
* @param document Document to create
|
|
906
|
+
* @param options Mutation options
|
|
907
|
+
*/
|
|
908
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
909
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
910
|
+
options: AllDocumentsMutationOptions
|
|
911
|
+
): Promise<SanityDocument<R>[]>
|
|
912
|
+
/**
|
|
913
|
+
* Create a document if no document with the same ID already exists.
|
|
914
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
915
|
+
*
|
|
916
|
+
* @param document Document to create
|
|
917
|
+
* @param options Mutation options
|
|
918
|
+
*/
|
|
919
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
920
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
921
|
+
options: FirstDocumentIdMutationOptions
|
|
922
|
+
): Promise<SingleMutationResult>
|
|
923
|
+
/**
|
|
924
|
+
* Create a document if no document with the same ID already exists.
|
|
925
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
926
|
+
*
|
|
927
|
+
* @param document Document to create
|
|
928
|
+
* @param options Mutation options
|
|
929
|
+
*/
|
|
930
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
931
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
932
|
+
options: AllDocumentIdsMutationOptions
|
|
933
|
+
): Promise<MultipleMutationResult>
|
|
934
|
+
/**
|
|
935
|
+
* Create a document if no document with the same ID already exists.
|
|
936
|
+
* Returns a promise that resolves to the created document.
|
|
937
|
+
*
|
|
938
|
+
* @param document Document to create
|
|
939
|
+
* @param options Mutation options
|
|
940
|
+
*/
|
|
941
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
942
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
943
|
+
options?: BaseMutationOptions
|
|
944
|
+
): Promise<SanityDocument<R>>
|
|
945
|
+
createIfNotExists<R extends Record<string, any> = Record<string, any>>(
|
|
946
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
947
|
+
options?:
|
|
948
|
+
| AllDocumentIdsMutationOptions
|
|
949
|
+
| AllDocumentsMutationOptions
|
|
950
|
+
| BaseMutationOptions
|
|
951
|
+
| FirstDocumentIdMutationOptions
|
|
952
|
+
| FirstDocumentMutationOptions
|
|
953
|
+
): Promise<
|
|
954
|
+
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
955
|
+
> {
|
|
956
|
+
return lastValueFrom(
|
|
957
|
+
dataMethods._createIfNotExists<R>(this, this.#httpRequest, document, options)
|
|
958
|
+
)
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
963
|
+
* Returns a promise that resolves to the created document.
|
|
964
|
+
*
|
|
965
|
+
* @param document Document to either create or replace
|
|
966
|
+
* @param options Mutation options
|
|
967
|
+
*/
|
|
968
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
969
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
970
|
+
options: FirstDocumentMutationOptions
|
|
971
|
+
): Promise<SanityDocument<R>>
|
|
972
|
+
/**
|
|
973
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
974
|
+
* Returns a promise that resolves to an array containing the created document.
|
|
975
|
+
*
|
|
976
|
+
* @param document Document to either create or replace
|
|
977
|
+
* @param options Mutation options
|
|
978
|
+
*/
|
|
979
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
980
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
981
|
+
options: AllDocumentsMutationOptions
|
|
982
|
+
): Promise<SanityDocument<R>[]>
|
|
983
|
+
/**
|
|
984
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
985
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the created document.
|
|
986
|
+
*
|
|
987
|
+
* @param document Document to either create or replace
|
|
988
|
+
* @param options Mutation options
|
|
989
|
+
*/
|
|
990
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
991
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
992
|
+
options: FirstDocumentIdMutationOptions
|
|
993
|
+
): Promise<SingleMutationResult>
|
|
994
|
+
/**
|
|
995
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
996
|
+
* Returns a promise that resolves to a mutation result object containing the created document ID.
|
|
997
|
+
*
|
|
998
|
+
* @param document Document to either create or replace
|
|
999
|
+
* @param options Mutation options
|
|
1000
|
+
*/
|
|
1001
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
1002
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1003
|
+
options: AllDocumentIdsMutationOptions
|
|
1004
|
+
): Promise<MultipleMutationResult>
|
|
1005
|
+
/**
|
|
1006
|
+
* Create a document if it does not exist, or replace a document with the same document ID
|
|
1007
|
+
* Returns a promise that resolves to the created document.
|
|
1008
|
+
*
|
|
1009
|
+
* @param document Document to either create or replace
|
|
1010
|
+
* @param options Mutation options
|
|
1011
|
+
*/
|
|
1012
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
1013
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1014
|
+
options?: BaseMutationOptions
|
|
1015
|
+
): Promise<SanityDocument<R>>
|
|
1016
|
+
createOrReplace<R extends Record<string, any> = Record<string, any>>(
|
|
1017
|
+
document: IdentifiedSanityDocumentStub<R>,
|
|
1018
|
+
options?:
|
|
1019
|
+
| AllDocumentIdsMutationOptions
|
|
1020
|
+
| AllDocumentsMutationOptions
|
|
1021
|
+
| BaseMutationOptions
|
|
1022
|
+
| FirstDocumentIdMutationOptions
|
|
1023
|
+
| FirstDocumentMutationOptions
|
|
1024
|
+
): Promise<
|
|
1025
|
+
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
1026
|
+
> {
|
|
1027
|
+
return lastValueFrom(
|
|
1028
|
+
dataMethods._createOrReplace<R>(this, this.#httpRequest, document, options)
|
|
1029
|
+
)
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Deletes a document with the given document ID.
|
|
1034
|
+
* Returns a promise that resolves to the deleted document.
|
|
1035
|
+
*
|
|
1036
|
+
* @param id Document ID to delete
|
|
1037
|
+
* @param options Options for the mutation
|
|
1038
|
+
*/
|
|
1039
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1040
|
+
id: string,
|
|
1041
|
+
options: FirstDocumentMutationOptions
|
|
1042
|
+
): Promise<SanityDocument<R>>
|
|
1043
|
+
/**
|
|
1044
|
+
* Deletes a document with the given document ID.
|
|
1045
|
+
* Returns a promise that resolves to an array containing the deleted document.
|
|
1046
|
+
*
|
|
1047
|
+
* @param id Document ID to delete
|
|
1048
|
+
* @param options Options for the mutation
|
|
1049
|
+
*/
|
|
1050
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1051
|
+
id: string,
|
|
1052
|
+
options: AllDocumentsMutationOptions
|
|
1053
|
+
): Promise<SanityDocument<R>[]>
|
|
1054
|
+
/**
|
|
1055
|
+
* Deletes a document with the given document ID.
|
|
1056
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
1057
|
+
*
|
|
1058
|
+
* @param id Document ID to delete
|
|
1059
|
+
* @param options Options for the mutation
|
|
1060
|
+
*/
|
|
1061
|
+
delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>
|
|
1062
|
+
/**
|
|
1063
|
+
* Deletes a document with the given document ID.
|
|
1064
|
+
* Returns a promise that resolves to a mutation result object containing the deleted document ID.
|
|
1065
|
+
*
|
|
1066
|
+
* @param id Document ID to delete
|
|
1067
|
+
* @param options Options for the mutation
|
|
1068
|
+
*/
|
|
1069
|
+
delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>
|
|
1070
|
+
/**
|
|
1071
|
+
* Deletes a document with the given document ID.
|
|
1072
|
+
* Returns a promise that resolves to the deleted document.
|
|
1073
|
+
*
|
|
1074
|
+
* @param id Document ID to delete
|
|
1075
|
+
* @param options Options for the mutation
|
|
1076
|
+
*/
|
|
1077
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1078
|
+
id: string,
|
|
1079
|
+
options?: BaseMutationOptions
|
|
1080
|
+
): Promise<SanityDocument<R>>
|
|
1081
|
+
/**
|
|
1082
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1083
|
+
* Returns a promise that resolves to first deleted document.
|
|
1084
|
+
*
|
|
1085
|
+
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1086
|
+
* @param options Options for the mutation
|
|
1087
|
+
*/
|
|
1088
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1089
|
+
selection: MutationSelection,
|
|
1090
|
+
options: FirstDocumentMutationOptions
|
|
1091
|
+
): Promise<SanityDocument<R>>
|
|
1092
|
+
/**
|
|
1093
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1094
|
+
* Returns a promise that resolves to an array containing the deleted documents.
|
|
1095
|
+
*
|
|
1096
|
+
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1097
|
+
* @param options Options for the mutation
|
|
1098
|
+
*/
|
|
1099
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1100
|
+
selection: MutationSelection,
|
|
1101
|
+
options: AllDocumentsMutationOptions
|
|
1102
|
+
): Promise<SanityDocument<R>[]>
|
|
1103
|
+
/**
|
|
1104
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1105
|
+
* Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.
|
|
1106
|
+
*
|
|
1107
|
+
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1108
|
+
* @param options Options for the mutation
|
|
1109
|
+
*/
|
|
1110
|
+
delete(
|
|
1111
|
+
selection: MutationSelection,
|
|
1112
|
+
options: FirstDocumentIdMutationOptions
|
|
1113
|
+
): Promise<SingleMutationResult>
|
|
1114
|
+
/**
|
|
1115
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1116
|
+
* Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.
|
|
1117
|
+
*
|
|
1118
|
+
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1119
|
+
* @param options Options for the mutation
|
|
1120
|
+
*/
|
|
1121
|
+
delete(
|
|
1122
|
+
selection: MutationSelection,
|
|
1123
|
+
options: AllDocumentIdsMutationOptions
|
|
1124
|
+
): Promise<MultipleMutationResult>
|
|
1125
|
+
/**
|
|
1126
|
+
* Deletes one or more documents matching the given query or document ID.
|
|
1127
|
+
* Returns a promise that resolves to first deleted document.
|
|
1128
|
+
*
|
|
1129
|
+
* @param selection An object with either an `id` or `query` key defining what to delete
|
|
1130
|
+
* @param options Options for the mutation
|
|
1131
|
+
*/
|
|
1132
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1133
|
+
selection: MutationSelection,
|
|
1134
|
+
options?: BaseMutationOptions
|
|
1135
|
+
): Promise<SanityDocument<R>>
|
|
1136
|
+
delete<R extends Record<string, any> = Record<string, any>>(
|
|
1137
|
+
selection: string | MutationSelection,
|
|
1138
|
+
options?:
|
|
1139
|
+
| AllDocumentIdsMutationOptions
|
|
1140
|
+
| AllDocumentsMutationOptions
|
|
1141
|
+
| BaseMutationOptions
|
|
1142
|
+
| FirstDocumentIdMutationOptions
|
|
1143
|
+
| FirstDocumentMutationOptions
|
|
1144
|
+
): Promise<
|
|
1145
|
+
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
1146
|
+
> {
|
|
1147
|
+
return lastValueFrom(dataMethods._delete<R>(this, this.#httpRequest, selection, options))
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* Perform mutation operations against the configured dataset
|
|
1152
|
+
* Returns a promise that resolves to the first mutated document.
|
|
1153
|
+
*
|
|
1154
|
+
* @param operations Mutation operations to execute
|
|
1155
|
+
* @param options Mutation options
|
|
1156
|
+
*/
|
|
1157
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1158
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
1159
|
+
options: FirstDocumentMutationOptions
|
|
1160
|
+
): Promise<SanityDocument<R>>
|
|
1161
|
+
/**
|
|
1162
|
+
* Perform mutation operations against the configured dataset.
|
|
1163
|
+
* Returns a promise that resolves to an array of the mutated documents.
|
|
1164
|
+
*
|
|
1165
|
+
* @param operations Mutation operations to execute
|
|
1166
|
+
* @param options Mutation options
|
|
1167
|
+
*/
|
|
1168
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1169
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
1170
|
+
options: AllDocumentsMutationOptions
|
|
1171
|
+
): Promise<SanityDocument<R>[]>
|
|
1172
|
+
/**
|
|
1173
|
+
* Perform mutation operations against the configured dataset
|
|
1174
|
+
* Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.
|
|
1175
|
+
*
|
|
1176
|
+
* @param operations Mutation operations to execute
|
|
1177
|
+
* @param options Mutation options
|
|
1178
|
+
*/
|
|
1179
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1180
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
1181
|
+
options: FirstDocumentIdMutationOptions
|
|
1182
|
+
): Promise<SingleMutationResult>
|
|
1183
|
+
/**
|
|
1184
|
+
* Perform mutation operations against the configured dataset
|
|
1185
|
+
* Returns a promise that resolves to a mutation result object containing the mutated document IDs.
|
|
1186
|
+
*
|
|
1187
|
+
* @param operations Mutation operations to execute
|
|
1188
|
+
* @param options Mutation options
|
|
1189
|
+
*/
|
|
1190
|
+
mutate<R extends Record<string, any>>(
|
|
1191
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
1192
|
+
options: AllDocumentIdsMutationOptions
|
|
1193
|
+
): Promise<MultipleMutationResult>
|
|
1194
|
+
/**
|
|
1195
|
+
* Perform mutation operations against the configured dataset
|
|
1196
|
+
* Returns a promise that resolves to the first mutated document.
|
|
1197
|
+
*
|
|
1198
|
+
* @param operations Mutation operations to execute
|
|
1199
|
+
* @param options Mutation options
|
|
1200
|
+
*/
|
|
1201
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1202
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
1203
|
+
options?: BaseMutationOptions
|
|
1204
|
+
): Promise<SanityDocument<R>>
|
|
1205
|
+
mutate<R extends Record<string, any> = Record<string, any>>(
|
|
1206
|
+
operations: Mutation<R>[] | Patch | Transaction,
|
|
1207
|
+
options?:
|
|
1208
|
+
| FirstDocumentMutationOptions
|
|
1209
|
+
| AllDocumentsMutationOptions
|
|
1210
|
+
| FirstDocumentIdMutationOptions
|
|
1211
|
+
| AllDocumentIdsMutationOptions
|
|
1212
|
+
| BaseMutationOptions
|
|
1213
|
+
): Promise<
|
|
1214
|
+
SanityDocument<R> | SanityDocument<R>[] | SingleMutationResult | MultipleMutationResult
|
|
1215
|
+
> {
|
|
1216
|
+
return lastValueFrom(dataMethods._mutate<R>(this, this.#httpRequest, operations, options))
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* Create a new buildable patch of operations to perform
|
|
1221
|
+
*
|
|
1222
|
+
* @param documentId Document ID to patch
|
|
1223
|
+
* @param operations Optional object of patch operations to initialize the patch instance with
|
|
1224
|
+
*/
|
|
1225
|
+
patch(documentId: string | MutationSelection, operations?: PatchOperations): Patch {
|
|
1226
|
+
return new Patch(documentId, operations, this)
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* Create a new transaction of mutations
|
|
1231
|
+
*
|
|
1232
|
+
* @param operations Optional array of mutation operations to initialize the transaction instance with
|
|
1233
|
+
*/
|
|
1234
|
+
transaction<R extends Record<string, any> = Record<string, any>>(
|
|
1235
|
+
operations?: Mutation<R>[]
|
|
1236
|
+
): Transaction {
|
|
1237
|
+
return new Transaction(operations, this)
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* DEPRECATED: Perform an HTTP request against the Sanity API
|
|
1242
|
+
*
|
|
1243
|
+
* @deprecated Use your own request library!
|
|
1244
|
+
* @param options Request options
|
|
1245
|
+
*/
|
|
1246
|
+
request<R = any>(options: RawRequestOptions): Promise<R> {
|
|
1247
|
+
return lastValueFrom(dataMethods._request<R>(this, this.#httpRequest, options))
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* DEPRECATED: Perform an HTTP request a `/data` sub-endpoint
|
|
1252
|
+
*
|
|
1253
|
+
* @deprecated Use your own request library!
|
|
1254
|
+
* @param endpoint Endpoint to hit (mutate, query etc)
|
|
1255
|
+
* @param body Request body
|
|
1256
|
+
* @param options Request options
|
|
1257
|
+
*/
|
|
1258
|
+
dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<any> {
|
|
1259
|
+
return lastValueFrom(dataMethods._dataRequest(this, this.#httpRequest, endpoint, body, options))
|
|
1260
|
+
}
|
|
1261
|
+
}
|