@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.21.0",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -122,8 +122,8 @@
|
|
|
122
122
|
"rxjs": "^7.0.0"
|
|
123
123
|
},
|
|
124
124
|
"devDependencies": {
|
|
125
|
-
"@edge-runtime/types": "^
|
|
126
|
-
"@edge-runtime/vm": "^
|
|
125
|
+
"@edge-runtime/types": "^3.0.0",
|
|
126
|
+
"@edge-runtime/vm": "^4.0.0",
|
|
127
127
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
128
128
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
129
129
|
"@sanity/pkg-utils": "^6.9.3",
|
package/src/SanityClient.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
BaseActionOptions,
|
|
18
18
|
BaseMutationOptions,
|
|
19
19
|
ClientConfig,
|
|
20
|
+
ClientReturn,
|
|
20
21
|
FilteredResponseQueryOptions,
|
|
21
22
|
FirstDocumentIdMutationOptions,
|
|
22
23
|
FirstDocumentMutationOptions,
|
|
@@ -142,10 +143,11 @@ export class ObservableSanityClient {
|
|
|
142
143
|
*
|
|
143
144
|
* @param query - GROQ-query to perform
|
|
144
145
|
*/
|
|
145
|
-
fetch<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
fetch<
|
|
147
|
+
R = Any,
|
|
148
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
149
|
+
const G extends string = string,
|
|
150
|
+
>(query: G, params?: Q | QueryWithoutParams): Observable<ClientReturn<G, R>>
|
|
149
151
|
/**
|
|
150
152
|
* Perform a GROQ-query against the configured dataset.
|
|
151
153
|
*
|
|
@@ -153,11 +155,15 @@ export class ObservableSanityClient {
|
|
|
153
155
|
* @param params - Optional query parameters
|
|
154
156
|
* @param options - Optional request options
|
|
155
157
|
*/
|
|
156
|
-
fetch<
|
|
157
|
-
|
|
158
|
+
fetch<
|
|
159
|
+
R = Any,
|
|
160
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
161
|
+
const G extends string = string,
|
|
162
|
+
>(
|
|
163
|
+
query: G,
|
|
158
164
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
159
165
|
options?: FilteredResponseQueryOptions,
|
|
160
|
-
): Observable<R
|
|
166
|
+
): Observable<ClientReturn<G, R>>
|
|
161
167
|
/**
|
|
162
168
|
* Perform a GROQ-query against the configured dataset.
|
|
163
169
|
*
|
|
@@ -165,11 +171,15 @@ export class ObservableSanityClient {
|
|
|
165
171
|
* @param params - Optional query parameters
|
|
166
172
|
* @param options - Request options
|
|
167
173
|
*/
|
|
168
|
-
fetch<
|
|
174
|
+
fetch<
|
|
175
|
+
R = Any,
|
|
176
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
177
|
+
const G extends string = string,
|
|
178
|
+
>(
|
|
169
179
|
query: string,
|
|
170
180
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
171
181
|
options: UnfilteredResponseQueryOptions,
|
|
172
|
-
): Observable<RawQueryResponse<R
|
|
182
|
+
): Observable<RawQueryResponse<ClientReturn<G, R>>>
|
|
173
183
|
/**
|
|
174
184
|
* Perform a GROQ-query against the configured dataset.
|
|
175
185
|
*
|
|
@@ -177,13 +187,17 @@ export class ObservableSanityClient {
|
|
|
177
187
|
* @param params - Optional query parameters
|
|
178
188
|
* @param options - Request options
|
|
179
189
|
*/
|
|
180
|
-
fetch<
|
|
181
|
-
|
|
190
|
+
fetch<
|
|
191
|
+
R = Any,
|
|
192
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
193
|
+
const G extends string = string,
|
|
194
|
+
>(
|
|
195
|
+
query: G,
|
|
182
196
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
183
197
|
options: UnfilteredResponseWithoutQuery,
|
|
184
|
-
): Observable<RawQuerylessQueryResponse<R
|
|
185
|
-
fetch<R, Q>(
|
|
186
|
-
query:
|
|
198
|
+
): Observable<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
199
|
+
fetch<R, Q, const G extends string>(
|
|
200
|
+
query: G,
|
|
187
201
|
params?: Q,
|
|
188
202
|
options?: QueryOptions,
|
|
189
203
|
): Observable<RawQueryResponse<R> | R> {
|
|
@@ -808,10 +822,11 @@ export class SanityClient {
|
|
|
808
822
|
*
|
|
809
823
|
* @param query - GROQ-query to perform
|
|
810
824
|
*/
|
|
811
|
-
fetch<
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
825
|
+
fetch<
|
|
826
|
+
R = Any,
|
|
827
|
+
Q extends QueryWithoutParams = QueryWithoutParams,
|
|
828
|
+
const G extends string = string,
|
|
829
|
+
>(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
|
|
815
830
|
/**
|
|
816
831
|
* Perform a GROQ-query against the configured dataset.
|
|
817
832
|
*
|
|
@@ -819,11 +834,15 @@ export class SanityClient {
|
|
|
819
834
|
* @param params - Optional query parameters
|
|
820
835
|
* @param options - Optional request options
|
|
821
836
|
*/
|
|
822
|
-
fetch<
|
|
823
|
-
|
|
837
|
+
fetch<
|
|
838
|
+
R = Any,
|
|
839
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
840
|
+
const G extends string = string,
|
|
841
|
+
>(
|
|
842
|
+
query: G,
|
|
824
843
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
825
844
|
options?: FilteredResponseQueryOptions,
|
|
826
|
-
): Promise<R
|
|
845
|
+
): Promise<ClientReturn<G, R>>
|
|
827
846
|
/**
|
|
828
847
|
* Perform a GROQ-query against the configured dataset.
|
|
829
848
|
*
|
|
@@ -831,11 +850,15 @@ export class SanityClient {
|
|
|
831
850
|
* @param params - Optional query parameters
|
|
832
851
|
* @param options - Request options
|
|
833
852
|
*/
|
|
834
|
-
fetch<
|
|
835
|
-
|
|
853
|
+
fetch<
|
|
854
|
+
R = Any,
|
|
855
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
856
|
+
const G extends string = string,
|
|
857
|
+
>(
|
|
858
|
+
query: G,
|
|
836
859
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
837
860
|
options: UnfilteredResponseQueryOptions,
|
|
838
|
-
): Promise<RawQueryResponse<R
|
|
861
|
+
): Promise<RawQueryResponse<ClientReturn<G, R>>>
|
|
839
862
|
/**
|
|
840
863
|
* Perform a GROQ-query against the configured dataset.
|
|
841
864
|
*
|
|
@@ -843,14 +866,22 @@ export class SanityClient {
|
|
|
843
866
|
* @param params - Optional query parameters
|
|
844
867
|
* @param options - Request options
|
|
845
868
|
*/
|
|
846
|
-
fetch<
|
|
847
|
-
|
|
869
|
+
fetch<
|
|
870
|
+
R = Any,
|
|
871
|
+
Q extends QueryWithoutParams | QueryParams = QueryParams,
|
|
872
|
+
const G extends string = string,
|
|
873
|
+
>(
|
|
874
|
+
query: G,
|
|
848
875
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
849
876
|
options: UnfilteredResponseWithoutQuery,
|
|
850
|
-
): Promise<RawQuerylessQueryResponse<R
|
|
851
|
-
fetch<R, Q
|
|
877
|
+
): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>
|
|
878
|
+
fetch<R, Q, const G extends string>(
|
|
879
|
+
query: G,
|
|
880
|
+
params?: Q,
|
|
881
|
+
options?: QueryOptions,
|
|
882
|
+
): Promise<RawQueryResponse<ClientReturn<G, R>> | ClientReturn<G, R>> {
|
|
852
883
|
return lastValueFrom(
|
|
853
|
-
dataMethods._fetch<
|
|
884
|
+
dataMethods._fetch<ClientReturn<G, R>, Q>(
|
|
854
885
|
this,
|
|
855
886
|
this.#httpRequest,
|
|
856
887
|
this.#clientConfig.stega,
|
package/src/types.ts
CHANGED
|
@@ -1236,6 +1236,15 @@ export interface LiveEventMessage {
|
|
|
1236
1236
|
tags: SyncTag[]
|
|
1237
1237
|
}
|
|
1238
1238
|
|
|
1239
|
+
/** @public */
|
|
1240
|
+
export interface SanityQueries {}
|
|
1241
|
+
|
|
1242
|
+
/** @public */
|
|
1243
|
+
export type ClientReturn<
|
|
1244
|
+
GroqString extends string,
|
|
1245
|
+
Fallback = Any,
|
|
1246
|
+
> = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
|
|
1247
|
+
|
|
1239
1248
|
export type {
|
|
1240
1249
|
ContentSourceMapParsedPath,
|
|
1241
1250
|
ContentSourceMapParsedPathKeyedSegment,
|