@sanity/client 6.12.4 → 6.13.1
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/_chunks/{browserMiddleware-dqqEd6vl.cjs → browserMiddleware-CMmbH4hX.cjs} +17 -5
- package/dist/_chunks/browserMiddleware-CMmbH4hX.cjs.map +1 -0
- package/dist/_chunks/{browserMiddleware-FL0Mlm8l.js → browserMiddleware-a-wo4gir.js} +17 -5
- package/dist/_chunks/browserMiddleware-a-wo4gir.js.map +1 -0
- package/dist/_chunks/{nodeMiddleware-scsxYdRh.js → nodeMiddleware-8EaNvibV.js} +18 -6
- package/dist/_chunks/nodeMiddleware-8EaNvibV.js.map +1 -0
- package/dist/_chunks/{nodeMiddleware-iUs-kdpz.cjs → nodeMiddleware-D6EzVTKT.cjs} +18 -6
- package/dist/_chunks/nodeMiddleware-D6EzVTKT.cjs.map +1 -0
- package/dist/_chunks/{resolveEditInfo-uXvm6eWd.js → resolveEditInfo-BC6qdqZw.js} +1 -1
- package/dist/_chunks/{resolveEditInfo-uXvm6eWd.js.map → resolveEditInfo-BC6qdqZw.js.map} +1 -1
- package/dist/_chunks/{resolveEditInfo-dELeeJBE.cjs → resolveEditInfo-CkO-V0Hb.cjs} +1 -1
- package/dist/_chunks/{resolveEditInfo-dELeeJBE.cjs.map → resolveEditInfo-CkO-V0Hb.cjs.map} +1 -1
- package/dist/_chunks/{stegaEncodeSourceMap-LDHMEOVo.js → stegaEncodeSourceMap-BiY3WTdp.js} +2 -2
- package/dist/_chunks/{stegaEncodeSourceMap-LDHMEOVo.js.map → stegaEncodeSourceMap-BiY3WTdp.js.map} +1 -1
- package/dist/_chunks/{stegaEncodeSourceMap-oPlkdofZ.cjs → stegaEncodeSourceMap-C1igPjw7.cjs} +2 -2
- package/dist/_chunks/{stegaEncodeSourceMap-oPlkdofZ.cjs.map → stegaEncodeSourceMap-C1igPjw7.cjs.map} +1 -1
- package/dist/_chunks/{stegaEncodeSourceMap-OHUCEAgw.js → stegaEncodeSourceMap-CVUvJGR6.js} +3 -3
- package/dist/_chunks/{stegaEncodeSourceMap-OHUCEAgw.js.map → stegaEncodeSourceMap-CVUvJGR6.js.map} +1 -1
- package/dist/_chunks/{stegaEncodeSourceMap-hWSK_ZZK.cjs → stegaEncodeSourceMap-D6UeeGR0.cjs} +3 -3
- package/dist/_chunks/{stegaEncodeSourceMap-hWSK_ZZK.cjs.map → stegaEncodeSourceMap-D6UeeGR0.cjs.map} +1 -1
- package/dist/csm.cjs +1 -1
- package/dist/csm.js +2 -2
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +2 -2
- package/dist/stega.browser.cjs +2 -2
- package/dist/stega.browser.js +3 -3
- package/dist/stega.cjs +2 -2
- package/dist/stega.d.ts +51 -1
- package/dist/stega.js +3 -3
- package/package.json +8 -8
- package/src/SanityClient.ts +26 -0
- package/src/data/dataMethods.ts +12 -1
- package/src/data/encodeQueryString.ts +4 -1
- package/src/types.ts +28 -1
- package/src/util/getSelection.ts +5 -1
- package/umd/sanityClient.js +17 -5
- package/umd/sanityClient.min.js +3 -3
- package/dist/_chunks/browserMiddleware-FL0Mlm8l.js.map +0 -1
- package/dist/_chunks/browserMiddleware-dqqEd6vl.cjs.map +0 -1
- package/dist/_chunks/nodeMiddleware-iUs-kdpz.cjs.map +0 -1
- package/dist/_chunks/nodeMiddleware-scsxYdRh.js.map +0 -1
package/dist/stega.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var nodeMiddleware = require('./_chunks/nodeMiddleware-
|
|
5
|
+
var nodeMiddleware = require('./_chunks/nodeMiddleware-D6EzVTKT.cjs');
|
|
6
6
|
var getIt = require('get-it');
|
|
7
|
-
var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-
|
|
7
|
+
var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-D6UeeGR0.cjs');
|
|
8
8
|
|
|
9
9
|
class SanityStegaClient extends nodeMiddleware.SanityClient {
|
|
10
10
|
}
|
package/dist/stega.d.ts
CHANGED
|
@@ -1198,6 +1198,18 @@ export declare class ObservableSanityClient {
|
|
|
1198
1198
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1199
1199
|
options: UnfilteredResponseQueryOptions,
|
|
1200
1200
|
): Observable<RawQueryResponse<R>>
|
|
1201
|
+
/**
|
|
1202
|
+
* Perform a GROQ-query against the configured dataset.
|
|
1203
|
+
*
|
|
1204
|
+
* @param query - GROQ-query to perform
|
|
1205
|
+
* @param params - Optional query parameters
|
|
1206
|
+
* @param options - Request options
|
|
1207
|
+
*/
|
|
1208
|
+
fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
|
|
1209
|
+
query: string,
|
|
1210
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
1211
|
+
options: UnfilteredResponseWithoutQuery,
|
|
1212
|
+
): Observable<RawQuerylessQueryResponse<R>>
|
|
1201
1213
|
/**
|
|
1202
1214
|
* Fetch a single document with the given ID.
|
|
1203
1215
|
*
|
|
@@ -1791,7 +1803,10 @@ export declare class ProjectsClient {
|
|
|
1791
1803
|
}
|
|
1792
1804
|
|
|
1793
1805
|
/** @public */
|
|
1794
|
-
export declare type QueryOptions =
|
|
1806
|
+
export declare type QueryOptions =
|
|
1807
|
+
| FilteredResponseQueryOptions
|
|
1808
|
+
| UnfilteredResponseQueryOptions
|
|
1809
|
+
| UnfilteredResponseWithoutQuery
|
|
1795
1810
|
|
|
1796
1811
|
/** @public */
|
|
1797
1812
|
export declare interface QueryParams {
|
|
@@ -1815,6 +1830,8 @@ export declare interface QueryParams {
|
|
|
1815
1830
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
1816
1831
|
resultSourceMap?: never
|
|
1817
1832
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
1833
|
+
returnQuery?: never
|
|
1834
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
1818
1835
|
signal?: never
|
|
1819
1836
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
1820
1837
|
stega?: never
|
|
@@ -1834,6 +1851,9 @@ export declare interface QueryParams {
|
|
|
1834
1851
|
*/
|
|
1835
1852
|
export declare type QueryWithoutParams = Record<string, never> | undefined
|
|
1836
1853
|
|
|
1854
|
+
/** @public */
|
|
1855
|
+
export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
1856
|
+
|
|
1837
1857
|
/** @public */
|
|
1838
1858
|
export declare interface RawQueryResponse<R> {
|
|
1839
1859
|
query: string
|
|
@@ -1919,6 +1939,7 @@ export declare interface ResponseEvent<T = unknown> {
|
|
|
1919
1939
|
export declare interface ResponseQueryOptions extends RequestOptions {
|
|
1920
1940
|
perspective?: ClientPerspective
|
|
1921
1941
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
1942
|
+
returnQuery?: boolean
|
|
1922
1943
|
useCdn?: boolean
|
|
1923
1944
|
stega?: boolean | StegaConfig
|
|
1924
1945
|
cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
|
|
@@ -2005,6 +2026,18 @@ export declare class SanityClient {
|
|
|
2005
2026
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2006
2027
|
options: UnfilteredResponseQueryOptions,
|
|
2007
2028
|
): Promise<RawQueryResponse<R>>
|
|
2029
|
+
/**
|
|
2030
|
+
* Perform a GROQ-query against the configured dataset.
|
|
2031
|
+
*
|
|
2032
|
+
* @param query - GROQ-query to perform
|
|
2033
|
+
* @param params - Optional query parameters
|
|
2034
|
+
* @param options - Request options
|
|
2035
|
+
*/
|
|
2036
|
+
fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
|
|
2037
|
+
query: string,
|
|
2038
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
2039
|
+
options: UnfilteredResponseWithoutQuery,
|
|
2040
|
+
): Promise<RawQuerylessQueryResponse<R>>
|
|
2008
2041
|
/**
|
|
2009
2042
|
* Fetch a single document with the given ID.
|
|
2010
2043
|
*
|
|
@@ -2710,6 +2743,23 @@ export declare type TransactionMutationOptions =
|
|
|
2710
2743
|
/** @public */
|
|
2711
2744
|
export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
2712
2745
|
filterResponse: false
|
|
2746
|
+
/**
|
|
2747
|
+
* When `filterResponse` is `false`, `returnQuery` also defaults to `true` for
|
|
2748
|
+
* backwards compatibility (on the client side, not from the content lake API).
|
|
2749
|
+
* Can also explicitly be set to `true`.
|
|
2750
|
+
*/
|
|
2751
|
+
returnQuery?: true
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
/**
|
|
2755
|
+
* When using `filterResponse: false`, but you do not wish to receive back the query from
|
|
2756
|
+
* the content lake API.
|
|
2757
|
+
*
|
|
2758
|
+
* @public
|
|
2759
|
+
*/
|
|
2760
|
+
export declare interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {
|
|
2761
|
+
filterResponse: false
|
|
2762
|
+
returnQuery: false
|
|
2713
2763
|
}
|
|
2714
2764
|
|
|
2715
2765
|
export {unstable__adapter}
|
package/dist/stega.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SanityClient, ObservableSanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-
|
|
2
|
-
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/nodeMiddleware-
|
|
1
|
+
import { SanityClient, ObservableSanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-8EaNvibV.js';
|
|
2
|
+
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/nodeMiddleware-8EaNvibV.js';
|
|
3
3
|
export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
|
|
4
|
-
export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-
|
|
4
|
+
export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-CVUvJGR6.js';
|
|
5
5
|
|
|
6
6
|
class SanityStegaClient extends SanityClient {
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.13.1",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -134,20 +134,20 @@
|
|
|
134
134
|
"rxjs": "^7.0.0"
|
|
135
135
|
},
|
|
136
136
|
"devDependencies": {
|
|
137
|
-
"@edge-runtime/types": "^2.2.
|
|
138
|
-
"@edge-runtime/vm": "^3.
|
|
137
|
+
"@edge-runtime/types": "^2.2.9",
|
|
138
|
+
"@edge-runtime/vm": "^3.2.0",
|
|
139
139
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
140
140
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
141
|
-
"@sanity/pkg-utils": "^4.
|
|
141
|
+
"@sanity/pkg-utils": "^4.2.0",
|
|
142
142
|
"@types/json-diff": "^1.0.3",
|
|
143
143
|
"@types/node": "^20.8.8",
|
|
144
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
145
|
-
"@typescript-eslint/parser": "^
|
|
144
|
+
"@typescript-eslint/eslint-plugin": "^7.0.1",
|
|
145
|
+
"@typescript-eslint/parser": "^7.0.1",
|
|
146
146
|
"@vitest/coverage-v8": "1.2.2",
|
|
147
147
|
"eslint": "^8.56.0",
|
|
148
148
|
"eslint-config-prettier": "^9.1.0",
|
|
149
149
|
"eslint-plugin-prettier": "^5.1.3",
|
|
150
|
-
"eslint-plugin-simple-import-sort": "^
|
|
150
|
+
"eslint-plugin-simple-import-sort": "^12.0.0",
|
|
151
151
|
"faucet": "^0.0.4",
|
|
152
152
|
"happy-dom": "^12.10.3",
|
|
153
153
|
"json-diff": "^1.0.6",
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
"prettier": "^3.2.5",
|
|
158
158
|
"prettier-plugin-packagejson": "^2.4.10",
|
|
159
159
|
"rimraf": "^5.0.1",
|
|
160
|
-
"rollup": "^4.
|
|
160
|
+
"rollup": "^4.10.0",
|
|
161
161
|
"sse-channel": "^4.0.0",
|
|
162
162
|
"terser": "^5.27.0",
|
|
163
163
|
"typescript": "^5.3.3",
|
package/src/SanityClient.ts
CHANGED
|
@@ -28,12 +28,14 @@ import type {
|
|
|
28
28
|
QueryOptions,
|
|
29
29
|
QueryParams,
|
|
30
30
|
QueryWithoutParams,
|
|
31
|
+
RawQuerylessQueryResponse,
|
|
31
32
|
RawQueryResponse,
|
|
32
33
|
RawRequestOptions,
|
|
33
34
|
SanityDocument,
|
|
34
35
|
SanityDocumentStub,
|
|
35
36
|
SingleMutationResult,
|
|
36
37
|
UnfilteredResponseQueryOptions,
|
|
38
|
+
UnfilteredResponseWithoutQuery,
|
|
37
39
|
} from './types'
|
|
38
40
|
import {ObservableUsersClient, UsersClient} from './users/UsersClient'
|
|
39
41
|
|
|
@@ -160,6 +162,18 @@ export class ObservableSanityClient {
|
|
|
160
162
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
161
163
|
options: UnfilteredResponseQueryOptions,
|
|
162
164
|
): Observable<RawQueryResponse<R>>
|
|
165
|
+
/**
|
|
166
|
+
* Perform a GROQ-query against the configured dataset.
|
|
167
|
+
*
|
|
168
|
+
* @param query - GROQ-query to perform
|
|
169
|
+
* @param params - Optional query parameters
|
|
170
|
+
* @param options - Request options
|
|
171
|
+
*/
|
|
172
|
+
fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
|
|
173
|
+
query: string,
|
|
174
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
175
|
+
options: UnfilteredResponseWithoutQuery,
|
|
176
|
+
): Observable<RawQuerylessQueryResponse<R>>
|
|
163
177
|
fetch<R, Q>(
|
|
164
178
|
query: string,
|
|
165
179
|
params?: Q,
|
|
@@ -799,6 +813,18 @@ export class SanityClient {
|
|
|
799
813
|
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
800
814
|
options: UnfilteredResponseQueryOptions,
|
|
801
815
|
): Promise<RawQueryResponse<R>>
|
|
816
|
+
/**
|
|
817
|
+
* Perform a GROQ-query against the configured dataset.
|
|
818
|
+
*
|
|
819
|
+
* @param query - GROQ-query to perform
|
|
820
|
+
* @param params - Optional query parameters
|
|
821
|
+
* @param options - Request options
|
|
822
|
+
*/
|
|
823
|
+
fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
|
|
824
|
+
query: string,
|
|
825
|
+
params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
|
|
826
|
+
options: UnfilteredResponseWithoutQuery,
|
|
827
|
+
): Promise<RawQuerylessQueryResponse<R>>
|
|
802
828
|
fetch<R, Q>(query: string, params?: Q, options?: QueryOptions): Promise<RawQueryResponse<R> | R> {
|
|
803
829
|
return lastValueFrom(
|
|
804
830
|
dataMethods._fetch<R, Q>(
|
package/src/data/dataMethods.ts
CHANGED
|
@@ -80,6 +80,11 @@ export function _fetch<R, Q>(
|
|
|
80
80
|
const params = stega.enabled ? vercelStegaCleanAll(_params) : _params
|
|
81
81
|
const mapResponse =
|
|
82
82
|
options.filterResponse === false ? (res: Any) => res : (res: Any) => res.result
|
|
83
|
+
|
|
84
|
+
// Default to not returning the query, unless `filterResponse` is `false`,
|
|
85
|
+
// or `returnQuery` is explicitly set. `true` is the default in Content Lake, so skip if truthy
|
|
86
|
+
const returnQuery = options.filterResponse === false && options.returnQuery !== false
|
|
87
|
+
|
|
83
88
|
const {cache, next, ...opts} = {
|
|
84
89
|
// Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
|
|
85
90
|
// This is necessary in React Server Components to avoid opting out of Request Memoization.
|
|
@@ -93,7 +98,13 @@ export function _fetch<R, Q>(
|
|
|
93
98
|
? {...opts, fetch: {cache, next}}
|
|
94
99
|
: opts
|
|
95
100
|
|
|
96
|
-
const $request = _dataRequest(
|
|
101
|
+
const $request = _dataRequest(
|
|
102
|
+
client,
|
|
103
|
+
httpRequest,
|
|
104
|
+
'query',
|
|
105
|
+
{query, params, options: {returnQuery}},
|
|
106
|
+
reqOpts,
|
|
107
|
+
)
|
|
97
108
|
return stega.enabled
|
|
98
109
|
? $request.pipe(
|
|
99
110
|
combineLatestWith(
|
|
@@ -11,7 +11,7 @@ export const encodeQueryString = ({
|
|
|
11
11
|
}) => {
|
|
12
12
|
const searchParams = new URLSearchParams()
|
|
13
13
|
// We generally want tag at the start of the query string
|
|
14
|
-
const {tag, ...opts} = options
|
|
14
|
+
const {tag, returnQuery, ...opts} = options
|
|
15
15
|
// We're using `append` instead of `set` to support React Native: https://github.com/facebook/react-native/blob/1982c4722fcc51aa87e34cf562672ee4aff540f1/packages/react-native/Libraries/Blob/URL.js#L86-L88
|
|
16
16
|
if (tag) searchParams.append('tag', tag)
|
|
17
17
|
searchParams.append('query', query)
|
|
@@ -26,5 +26,8 @@ export const encodeQueryString = ({
|
|
|
26
26
|
if (value) searchParams.append(key, `${value}`)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// `returnQuery` is default `true`, so needs an explicit `false` handling
|
|
30
|
+
if (returnQuery === false) searchParams.append('returnQuery', 'false')
|
|
31
|
+
|
|
29
32
|
return `?${searchParams}`
|
|
30
33
|
}
|
package/src/types.ts
CHANGED
|
@@ -452,6 +452,8 @@ export interface QueryParams {
|
|
|
452
452
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
453
453
|
resultSourceMap?: never
|
|
454
454
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
455
|
+
returnQuery?: never
|
|
456
|
+
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
455
457
|
signal?: never
|
|
456
458
|
/** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
|
|
457
459
|
stega?: never
|
|
@@ -721,6 +723,7 @@ export interface ListenOptions {
|
|
|
721
723
|
export interface ResponseQueryOptions extends RequestOptions {
|
|
722
724
|
perspective?: ClientPerspective
|
|
723
725
|
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
726
|
+
returnQuery?: boolean
|
|
724
727
|
useCdn?: boolean
|
|
725
728
|
stega?: boolean | StegaConfig
|
|
726
729
|
// The `cache` and `next` options are specific to the Next.js App Router integration
|
|
@@ -736,10 +739,31 @@ export interface FilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
|
736
739
|
/** @public */
|
|
737
740
|
export interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
|
|
738
741
|
filterResponse: false
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* When `filterResponse` is `false`, `returnQuery` also defaults to `true` for
|
|
745
|
+
* backwards compatibility (on the client side, not from the content lake API).
|
|
746
|
+
* Can also explicitly be set to `true`.
|
|
747
|
+
*/
|
|
748
|
+
returnQuery?: true
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* When using `filterResponse: false`, but you do not wish to receive back the query from
|
|
753
|
+
* the content lake API.
|
|
754
|
+
*
|
|
755
|
+
* @public
|
|
756
|
+
*/
|
|
757
|
+
export interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {
|
|
758
|
+
filterResponse: false
|
|
759
|
+
returnQuery: false
|
|
739
760
|
}
|
|
740
761
|
|
|
741
762
|
/** @public */
|
|
742
|
-
export type QueryOptions =
|
|
763
|
+
export type QueryOptions =
|
|
764
|
+
| FilteredResponseQueryOptions
|
|
765
|
+
| UnfilteredResponseQueryOptions
|
|
766
|
+
| UnfilteredResponseWithoutQuery
|
|
743
767
|
|
|
744
768
|
/** @public */
|
|
745
769
|
export interface RawQueryResponse<R> {
|
|
@@ -749,6 +773,9 @@ export interface RawQueryResponse<R> {
|
|
|
749
773
|
resultSourceMap?: ContentSourceMap
|
|
750
774
|
}
|
|
751
775
|
|
|
776
|
+
/** @public */
|
|
777
|
+
export type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
|
|
778
|
+
|
|
752
779
|
/** @internal */
|
|
753
780
|
export type BaseMutationOptions = RequestOptions & {
|
|
754
781
|
visibility?: 'sync' | 'async' | 'deferred'
|
package/src/util/getSelection.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type {MutationSelection} from '../types'
|
|
2
2
|
|
|
3
3
|
export function getSelection(sel: unknown): MutationSelection {
|
|
4
|
-
if (typeof sel === 'string'
|
|
4
|
+
if (typeof sel === 'string') {
|
|
5
5
|
return {id: sel}
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
if (Array.isArray(sel)) {
|
|
9
|
+
return {query: '*[_id in $ids]', params: {ids: sel}}
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
if (typeof sel === 'object' && sel !== null && 'query' in sel && typeof sel.query === 'string') {
|
|
9
13
|
return 'params' in sel && typeof sel.params === 'object' && sel.params !== null
|
|
10
14
|
? {query: sel.query, params: sel.params}
|
package/umd/sanityClient.js
CHANGED
|
@@ -2726,9 +2726,12 @@
|
|
|
2726
2726
|
}
|
|
2727
2727
|
|
|
2728
2728
|
function getSelection(sel) {
|
|
2729
|
-
if (typeof sel === "string"
|
|
2729
|
+
if (typeof sel === "string") {
|
|
2730
2730
|
return { id: sel };
|
|
2731
2731
|
}
|
|
2732
|
+
if (Array.isArray(sel)) {
|
|
2733
|
+
return { query: "*[_id in $ids]", params: { ids: sel } };
|
|
2734
|
+
}
|
|
2732
2735
|
if (typeof sel === "object" && sel !== null && "query" in sel && typeof sel.query === "string") {
|
|
2733
2736
|
return "params" in sel && typeof sel.params === "object" && sel.params !== null ? { query: sel.query, params: sel.params } : { query: sel.query };
|
|
2734
2737
|
}
|
|
@@ -3406,7 +3409,7 @@
|
|
|
3406
3409
|
options = {}
|
|
3407
3410
|
}) => {
|
|
3408
3411
|
const searchParams = new URLSearchParams();
|
|
3409
|
-
const { tag, ...opts } = options;
|
|
3412
|
+
const { tag, returnQuery, ...opts } = options;
|
|
3410
3413
|
if (tag)
|
|
3411
3414
|
searchParams.append("tag", tag);
|
|
3412
3415
|
searchParams.append("query", query);
|
|
@@ -3417,6 +3420,8 @@
|
|
|
3417
3420
|
if (value)
|
|
3418
3421
|
searchParams.append(key, "".concat(value));
|
|
3419
3422
|
}
|
|
3423
|
+
if (returnQuery === false)
|
|
3424
|
+
searchParams.append("returnQuery", "false");
|
|
3420
3425
|
return "?".concat(searchParams);
|
|
3421
3426
|
};
|
|
3422
3427
|
|
|
@@ -3448,6 +3453,7 @@
|
|
|
3448
3453
|
} : _stega;
|
|
3449
3454
|
const params = stega.enabled ? vercelStegaCleanAll(_params) : _params;
|
|
3450
3455
|
const mapResponse = options.filterResponse === false ? (res) => res : (res) => res.result;
|
|
3456
|
+
const returnQuery = options.filterResponse === false && options.returnQuery !== false;
|
|
3451
3457
|
const { cache, next, ...opts } = {
|
|
3452
3458
|
// Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
|
|
3453
3459
|
// This is necessary in React Server Components to avoid opting out of Request Memoization.
|
|
@@ -3457,11 +3463,17 @@
|
|
|
3457
3463
|
...options
|
|
3458
3464
|
};
|
|
3459
3465
|
const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? { ...opts, fetch: { cache, next } } : opts;
|
|
3460
|
-
const $request = _dataRequest(
|
|
3466
|
+
const $request = _dataRequest(
|
|
3467
|
+
client,
|
|
3468
|
+
httpRequest,
|
|
3469
|
+
"query",
|
|
3470
|
+
{ query, params, options: { returnQuery } },
|
|
3471
|
+
reqOpts
|
|
3472
|
+
);
|
|
3461
3473
|
return stega.enabled ? $request.pipe(
|
|
3462
3474
|
combineLatestWith(
|
|
3463
3475
|
from(
|
|
3464
|
-
Promise.resolve().then(function () { return
|
|
3476
|
+
Promise.resolve().then(function () { return stegaEncodeSourceMapBiY3WTdp; }).then(function (n) { return n.stegaEncodeSourceMap$1; }).then(
|
|
3465
3477
|
({ stegaEncodeSourceMap }) => stegaEncodeSourceMap
|
|
3466
3478
|
)
|
|
3467
3479
|
)
|
|
@@ -4987,7 +4999,7 @@
|
|
|
4987
4999
|
stegaEncodeSourceMap: stegaEncodeSourceMap
|
|
4988
5000
|
});
|
|
4989
5001
|
|
|
4990
|
-
var
|
|
5002
|
+
var stegaEncodeSourceMapBiY3WTdp = /*#__PURE__*/Object.freeze({
|
|
4991
5003
|
__proto__: null,
|
|
4992
5004
|
encodeIntoResult: encodeIntoResult,
|
|
4993
5005
|
stegaEncodeSourceMap: stegaEncodeSourceMap,
|