@sanity/client 6.20.2 → 6.21.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.map +1 -1
- package/dist/index.browser.d.cts +60 -25
- package/dist/index.browser.d.ts +60 -25
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -25
- package/dist/index.d.ts +60 -25
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/SanityClient.ts +60 -29
- package/src/types.ts +9 -0
package/dist/index.browser.d.cts
CHANGED
|
@@ -394,6 +394,12 @@ export declare class ClientError extends Error {
|
|
|
394
394
|
/** @public */
|
|
395
395
|
export declare type ClientPerspective = 'previewDrafts' | 'published' | 'raw'
|
|
396
396
|
|
|
397
|
+
/** @public */
|
|
398
|
+
export declare type ClientReturn<
|
|
399
|
+
GroqString extends string,
|
|
400
|
+
Fallback = Any,
|
|
401
|
+
> = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
|
|
402
|
+
|
|
397
403
|
/** @public */
|
|
398
404
|
export declare interface ContentSourceMap {
|
|
399
405
|
mappings: ContentSourceMapMappings
|
|
@@ -1300,10 +1306,11 @@ export declare class ObservableSanityClient {
|
|
|
1300
1306
|
*
|
|
1301
1307
|
* @param query - GROQ-query to perform
|
|
1302
1308
|
*/
|
|
1303
|
-
fetch<
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1309
|
+
fetch<
|
|
1310
|
+
R = Any,
|
|
1311
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
1312
|
+
const G extends string = string,
|
|
1313
|
+
>(query: G, params?: Q | QueryWithoutParams): Observable<ClientReturn<G, R>>
|
|
1307
1314
|
/**
|
|
1308
1315
|
* Perform a GROQ-query against the configured dataset.
|
|
1309
1316
|
*
|
|
@@ -1311,11 +1318,15 @@ export declare class ObservableSanityClient {
|
|
|
1311
1318
|
* @param params - Optional query parameters
|
|
1312
1319
|
* @param options - Optional request options
|
|
1313
1320
|
*/
|
|
1314
|
-
fetch<
|
|
1315
|
-
|
|
1321
|
+
fetch<
|
|
1322
|
+
R = Any,
|
|
1323
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1324
|
+
const G extends string = string,
|
|
1325
|
+
>(
|
|
1326
|
+
query: G,
|
|
1316
1327
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1317
1328
|
options?: FilteredResponseQueryOptions,
|
|
1318
|
-
): Observable<R
|
|
1329
|
+
): Observable<ClientReturn<G, R>>
|
|
1319
1330
|
/**
|
|
1320
1331
|
* Perform a GROQ-query against the configured dataset.
|
|
1321
1332
|
*
|
|
@@ -1323,11 +1334,15 @@ export declare class ObservableSanityClient {
|
|
|
1323
1334
|
* @param params - Optional query parameters
|
|
1324
1335
|
* @param options - Request options
|
|
1325
1336
|
*/
|
|
1326
|
-
fetch<
|
|
1337
|
+
fetch<
|
|
1338
|
+
R = Any,
|
|
1339
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1340
|
+
const G extends string = string,
|
|
1341
|
+
>(
|
|
1327
1342
|
query: string,
|
|
1328
1343
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1329
1344
|
options: UnfilteredResponseQueryOptions,
|
|
1330
|
-
): Observable<RawQueryResponse<R
|
|
1345
|
+
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
1331
1346
|
/**
|
|
1332
1347
|
* Perform a GROQ-query against the configured dataset.
|
|
1333
1348
|
*
|
|
@@ -1335,11 +1350,15 @@ export declare class ObservableSanityClient {
|
|
|
1335
1350
|
* @param params - Optional query parameters
|
|
1336
1351
|
* @param options - Request options
|
|
1337
1352
|
*/
|
|
1338
|
-
fetch<
|
|
1339
|
-
|
|
1353
|
+
fetch<
|
|
1354
|
+
R = Any,
|
|
1355
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1356
|
+
const G extends string = string,
|
|
1357
|
+
>(
|
|
1358
|
+
query: G,
|
|
1340
1359
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1341
1360
|
options: UnfilteredResponseWithoutQuery,
|
|
1342
|
-
): Observable<RawQuerylessQueryResponse<R
|
|
1361
|
+
): Observable<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
1343
1362
|
/**
|
|
1344
1363
|
* Fetch a single document with the given ID.
|
|
1345
1364
|
*
|
|
@@ -2184,10 +2203,11 @@ export declare class SanityClient {
|
|
|
2184
2203
|
*
|
|
2185
2204
|
* @param query - GROQ-query to perform
|
|
2186
2205
|
*/
|
|
2187
|
-
fetch<
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2206
|
+
fetch<
|
|
2207
|
+
R = Any,
|
|
2208
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
2209
|
+
const G extends string = string,
|
|
2210
|
+
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
2191
2211
|
/**
|
|
2192
2212
|
* Perform a GROQ-query against the configured dataset.
|
|
2193
2213
|
*
|
|
@@ -2195,11 +2215,15 @@ export declare class SanityClient {
|
|
|
2195
2215
|
* @param params - Optional query parameters
|
|
2196
2216
|
* @param options - Optional request options
|
|
2197
2217
|
*/
|
|
2198
|
-
fetch<
|
|
2199
|
-
|
|
2218
|
+
fetch<
|
|
2219
|
+
R = Any,
|
|
2220
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2221
|
+
const G extends string = string,
|
|
2222
|
+
>(
|
|
2223
|
+
query: G,
|
|
2200
2224
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2201
2225
|
options?: FilteredResponseQueryOptions,
|
|
2202
|
-
): Promise<R
|
|
2226
|
+
): Promise<ClientReturn<G, R>>
|
|
2203
2227
|
/**
|
|
2204
2228
|
* Perform a GROQ-query against the configured dataset.
|
|
2205
2229
|
*
|
|
@@ -2207,11 +2231,15 @@ export declare class SanityClient {
|
|
|
2207
2231
|
* @param params - Optional query parameters
|
|
2208
2232
|
* @param options - Request options
|
|
2209
2233
|
*/
|
|
2210
|
-
fetch<
|
|
2211
|
-
|
|
2234
|
+
fetch<
|
|
2235
|
+
R = Any,
|
|
2236
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2237
|
+
const G extends string = string,
|
|
2238
|
+
>(
|
|
2239
|
+
query: G,
|
|
2212
2240
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2213
2241
|
options: UnfilteredResponseQueryOptions,
|
|
2214
|
-
): Promise<RawQueryResponse<R
|
|
2242
|
+
): Promise<RawQueryResponse<ClientReturn<G, R>>>
|
|
2215
2243
|
/**
|
|
2216
2244
|
* Perform a GROQ-query against the configured dataset.
|
|
2217
2245
|
*
|
|
@@ -2219,11 +2247,15 @@ export declare class SanityClient {
|
|
|
2219
2247
|
* @param params - Optional query parameters
|
|
2220
2248
|
* @param options - Request options
|
|
2221
2249
|
*/
|
|
2222
|
-
fetch<
|
|
2223
|
-
|
|
2250
|
+
fetch<
|
|
2251
|
+
R = Any,
|
|
2252
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2253
|
+
const G extends string = string,
|
|
2254
|
+
>(
|
|
2255
|
+
query: G,
|
|
2224
2256
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2225
2257
|
options: UnfilteredResponseWithoutQuery,
|
|
2226
|
-
): Promise<RawQuerylessQueryResponse<R
|
|
2258
|
+
): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
2227
2259
|
/**
|
|
2228
2260
|
* Fetch a single document with the given ID.
|
|
2229
2261
|
*
|
|
@@ -2746,6 +2778,9 @@ export declare interface SanityProjectMember {
|
|
|
2746
2778
|
isCurrentUser: boolean
|
|
2747
2779
|
}
|
|
2748
2780
|
|
|
2781
|
+
/** @public */
|
|
2782
|
+
export declare interface SanityQueries {}
|
|
2783
|
+
|
|
2749
2784
|
/** @internal */
|
|
2750
2785
|
export declare interface SanityReference {
|
|
2751
2786
|
_ref: string
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -394,6 +394,12 @@ export declare class ClientError extends Error {
|
|
|
394
394
|
/** @public */
|
|
395
395
|
export declare type ClientPerspective = 'previewDrafts' | 'published' | 'raw'
|
|
396
396
|
|
|
397
|
+
/** @public */
|
|
398
|
+
export declare type ClientReturn<
|
|
399
|
+
GroqString extends string,
|
|
400
|
+
Fallback = Any,
|
|
401
|
+
> = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
|
|
402
|
+
|
|
397
403
|
/** @public */
|
|
398
404
|
export declare interface ContentSourceMap {
|
|
399
405
|
mappings: ContentSourceMapMappings
|
|
@@ -1300,10 +1306,11 @@ export declare class ObservableSanityClient {
|
|
|
1300
1306
|
*
|
|
1301
1307
|
* @param query - GROQ-query to perform
|
|
1302
1308
|
*/
|
|
1303
|
-
fetch<
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1309
|
+
fetch<
|
|
1310
|
+
R = Any,
|
|
1311
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
1312
|
+
const G extends string = string,
|
|
1313
|
+
>(query: G, params?: Q | QueryWithoutParams): Observable<ClientReturn<G, R>>
|
|
1307
1314
|
/**
|
|
1308
1315
|
* Perform a GROQ-query against the configured dataset.
|
|
1309
1316
|
*
|
|
@@ -1311,11 +1318,15 @@ export declare class ObservableSanityClient {
|
|
|
1311
1318
|
* @param params - Optional query parameters
|
|
1312
1319
|
* @param options - Optional request options
|
|
1313
1320
|
*/
|
|
1314
|
-
fetch<
|
|
1315
|
-
|
|
1321
|
+
fetch<
|
|
1322
|
+
R = Any,
|
|
1323
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1324
|
+
const G extends string = string,
|
|
1325
|
+
>(
|
|
1326
|
+
query: G,
|
|
1316
1327
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1317
1328
|
options?: FilteredResponseQueryOptions,
|
|
1318
|
-
): Observable<R
|
|
1329
|
+
): Observable<ClientReturn<G, R>>
|
|
1319
1330
|
/**
|
|
1320
1331
|
* Perform a GROQ-query against the configured dataset.
|
|
1321
1332
|
*
|
|
@@ -1323,11 +1334,15 @@ export declare class ObservableSanityClient {
|
|
|
1323
1334
|
* @param params - Optional query parameters
|
|
1324
1335
|
* @param options - Request options
|
|
1325
1336
|
*/
|
|
1326
|
-
fetch<
|
|
1337
|
+
fetch<
|
|
1338
|
+
R = Any,
|
|
1339
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1340
|
+
const G extends string = string,
|
|
1341
|
+
>(
|
|
1327
1342
|
query: string,
|
|
1328
1343
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1329
1344
|
options: UnfilteredResponseQueryOptions,
|
|
1330
|
-
): Observable<RawQueryResponse<R
|
|
1345
|
+
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
1331
1346
|
/**
|
|
1332
1347
|
* Perform a GROQ-query against the configured dataset.
|
|
1333
1348
|
*
|
|
@@ -1335,11 +1350,15 @@ export declare class ObservableSanityClient {
|
|
|
1335
1350
|
* @param params - Optional query parameters
|
|
1336
1351
|
* @param options - Request options
|
|
1337
1352
|
*/
|
|
1338
|
-
fetch<
|
|
1339
|
-
|
|
1353
|
+
fetch<
|
|
1354
|
+
R = Any,
|
|
1355
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
1356
|
+
const G extends string = string,
|
|
1357
|
+
>(
|
|
1358
|
+
query: G,
|
|
1340
1359
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1341
1360
|
options: UnfilteredResponseWithoutQuery,
|
|
1342
|
-
): Observable<RawQuerylessQueryResponse<R
|
|
1361
|
+
): Observable<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
1343
1362
|
/**
|
|
1344
1363
|
* Fetch a single document with the given ID.
|
|
1345
1364
|
*
|
|
@@ -2184,10 +2203,11 @@ export declare class SanityClient {
|
|
|
2184
2203
|
*
|
|
2185
2204
|
* @param query - GROQ-query to perform
|
|
2186
2205
|
*/
|
|
2187
|
-
fetch<
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2206
|
+
fetch<
|
|
2207
|
+
R = Any,
|
|
2208
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
2209
|
+
const G extends string = string,
|
|
2210
|
+
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
2191
2211
|
/**
|
|
2192
2212
|
* Perform a GROQ-query against the configured dataset.
|
|
2193
2213
|
*
|
|
@@ -2195,11 +2215,15 @@ export declare class SanityClient {
|
|
|
2195
2215
|
* @param params - Optional query parameters
|
|
2196
2216
|
* @param options - Optional request options
|
|
2197
2217
|
*/
|
|
2198
|
-
fetch<
|
|
2199
|
-
|
|
2218
|
+
fetch<
|
|
2219
|
+
R = Any,
|
|
2220
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2221
|
+
const G extends string = string,
|
|
2222
|
+
>(
|
|
2223
|
+
query: G,
|
|
2200
2224
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2201
2225
|
options?: FilteredResponseQueryOptions,
|
|
2202
|
-
): Promise<R
|
|
2226
|
+
): Promise<ClientReturn<G, R>>
|
|
2203
2227
|
/**
|
|
2204
2228
|
* Perform a GROQ-query against the configured dataset.
|
|
2205
2229
|
*
|
|
@@ -2207,11 +2231,15 @@ export declare class SanityClient {
|
|
|
2207
2231
|
* @param params - Optional query parameters
|
|
2208
2232
|
* @param options - Request options
|
|
2209
2233
|
*/
|
|
2210
|
-
fetch<
|
|
2211
|
-
|
|
2234
|
+
fetch<
|
|
2235
|
+
R = Any,
|
|
2236
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2237
|
+
const G extends string = string,
|
|
2238
|
+
>(
|
|
2239
|
+
query: G,
|
|
2212
2240
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2213
2241
|
options: UnfilteredResponseQueryOptions,
|
|
2214
|
-
): Promise<RawQueryResponse<R
|
|
2242
|
+
): Promise<RawQueryResponse<ClientReturn<G, R>>>
|
|
2215
2243
|
/**
|
|
2216
2244
|
* Perform a GROQ-query against the configured dataset.
|
|
2217
2245
|
*
|
|
@@ -2219,11 +2247,15 @@ export declare class SanityClient {
|
|
|
2219
2247
|
* @param params - Optional query parameters
|
|
2220
2248
|
* @param options - Request options
|
|
2221
2249
|
*/
|
|
2222
|
-
fetch<
|
|
2223
|
-
|
|
2250
|
+
fetch<
|
|
2251
|
+
R = Any,
|
|
2252
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
2253
|
+
const G extends string = string,
|
|
2254
|
+
>(
|
|
2255
|
+
query: G,
|
|
2224
2256
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2225
2257
|
options: UnfilteredResponseWithoutQuery,
|
|
2226
|
-
): Promise<RawQuerylessQueryResponse<R
|
|
2258
|
+
): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
2227
2259
|
/**
|
|
2228
2260
|
* Fetch a single document with the given ID.
|
|
2229
2261
|
*
|
|
@@ -2746,6 +2778,9 @@ export declare interface SanityProjectMember {
|
|
|
2746
2778
|
isCurrentUser: boolean
|
|
2747
2779
|
}
|
|
2748
2780
|
|
|
2781
|
+
/** @public */
|
|
2782
|
+
export declare interface SanityQueries {}
|
|
2783
|
+
|
|
2749
2784
|
/** @internal */
|
|
2750
2785
|
export declare interface SanityReference {
|
|
2751
2786
|
_ref: string
|