@sanity/client 6.12.4 → 6.13.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.
Files changed (43) hide show
  1. package/dist/_chunks/{browserMiddleware-FL0Mlm8l.js → browserMiddleware-Cfl3LrrI.js} +13 -4
  2. package/dist/_chunks/browserMiddleware-Cfl3LrrI.js.map +1 -0
  3. package/dist/_chunks/{browserMiddleware-dqqEd6vl.cjs → browserMiddleware-Dp4wx9CK.cjs} +13 -4
  4. package/dist/_chunks/browserMiddleware-Dp4wx9CK.cjs.map +1 -0
  5. package/dist/_chunks/{nodeMiddleware-scsxYdRh.js → nodeMiddleware-BN5UYAym.js} +14 -5
  6. package/dist/_chunks/nodeMiddleware-BN5UYAym.js.map +1 -0
  7. package/dist/_chunks/{nodeMiddleware-iUs-kdpz.cjs → nodeMiddleware-yTxugO4Q.cjs} +14 -5
  8. package/dist/_chunks/nodeMiddleware-yTxugO4Q.cjs.map +1 -0
  9. package/dist/_chunks/{resolveEditInfo-uXvm6eWd.js → resolveEditInfo-BC6qdqZw.js} +1 -1
  10. package/dist/_chunks/{resolveEditInfo-uXvm6eWd.js.map → resolveEditInfo-BC6qdqZw.js.map} +1 -1
  11. package/dist/_chunks/{resolveEditInfo-dELeeJBE.cjs → resolveEditInfo-CkO-V0Hb.cjs} +1 -1
  12. package/dist/_chunks/{resolveEditInfo-dELeeJBE.cjs.map → resolveEditInfo-CkO-V0Hb.cjs.map} +1 -1
  13. package/dist/_chunks/{stegaEncodeSourceMap-hWSK_ZZK.cjs → stegaEncodeSourceMap-D6fHf69f.cjs} +3 -3
  14. package/dist/_chunks/{stegaEncodeSourceMap-hWSK_ZZK.cjs.map → stegaEncodeSourceMap-D6fHf69f.cjs.map} +1 -1
  15. package/dist/_chunks/{stegaEncodeSourceMap-oPlkdofZ.cjs → stegaEncodeSourceMap-DGdRCWlF.cjs} +2 -2
  16. package/dist/_chunks/{stegaEncodeSourceMap-oPlkdofZ.cjs.map → stegaEncodeSourceMap-DGdRCWlF.cjs.map} +1 -1
  17. package/dist/_chunks/{stegaEncodeSourceMap-LDHMEOVo.js → stegaEncodeSourceMap-DO8ipgJw.js} +2 -2
  18. package/dist/_chunks/{stegaEncodeSourceMap-LDHMEOVo.js.map → stegaEncodeSourceMap-DO8ipgJw.js.map} +1 -1
  19. package/dist/_chunks/{stegaEncodeSourceMap-OHUCEAgw.js → stegaEncodeSourceMap-MOb3TLiL.js} +3 -3
  20. package/dist/_chunks/{stegaEncodeSourceMap-OHUCEAgw.js.map → stegaEncodeSourceMap-MOb3TLiL.js.map} +1 -1
  21. package/dist/csm.cjs +1 -1
  22. package/dist/csm.js +2 -2
  23. package/dist/index.browser.cjs +1 -1
  24. package/dist/index.browser.js +2 -2
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.d.ts +51 -1
  27. package/dist/index.js +2 -2
  28. package/dist/stega.browser.cjs +2 -2
  29. package/dist/stega.browser.js +3 -3
  30. package/dist/stega.cjs +2 -2
  31. package/dist/stega.d.ts +51 -1
  32. package/dist/stega.js +3 -3
  33. package/package.json +8 -8
  34. package/src/SanityClient.ts +26 -0
  35. package/src/data/dataMethods.ts +12 -1
  36. package/src/data/encodeQueryString.ts +4 -1
  37. package/src/types.ts +28 -1
  38. package/umd/sanityClient.js +13 -4
  39. package/umd/sanityClient.min.js +3 -3
  40. package/dist/_chunks/browserMiddleware-FL0Mlm8l.js.map +0 -1
  41. package/dist/_chunks/browserMiddleware-dqqEd6vl.cjs.map +0 -1
  42. package/dist/_chunks/nodeMiddleware-iUs-kdpz.cjs.map +0 -1
  43. package/dist/_chunks/nodeMiddleware-scsxYdRh.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1169,6 +1169,18 @@ export declare class ObservableSanityClient {
1169
1169
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
1170
1170
  options: UnfilteredResponseQueryOptions,
1171
1171
  ): Observable<RawQueryResponse<R>>
1172
+ /**
1173
+ * Perform a GROQ-query against the configured dataset.
1174
+ *
1175
+ * @param query - GROQ-query to perform
1176
+ * @param params - Optional query parameters
1177
+ * @param options - Request options
1178
+ */
1179
+ fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
1180
+ query: string,
1181
+ params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
1182
+ options: UnfilteredResponseWithoutQuery,
1183
+ ): Observable<RawQuerylessQueryResponse<R>>
1172
1184
  /**
1173
1185
  * Fetch a single document with the given ID.
1174
1186
  *
@@ -1756,7 +1768,10 @@ export declare class ProjectsClient {
1756
1768
  }
1757
1769
 
1758
1770
  /** @public */
1759
- export declare type QueryOptions = FilteredResponseQueryOptions | UnfilteredResponseQueryOptions
1771
+ export declare type QueryOptions =
1772
+ | FilteredResponseQueryOptions
1773
+ | UnfilteredResponseQueryOptions
1774
+ | UnfilteredResponseWithoutQuery
1760
1775
 
1761
1776
  /** @public */
1762
1777
  export declare interface QueryParams {
@@ -1780,6 +1795,8 @@ export declare interface QueryParams {
1780
1795
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1781
1796
  resultSourceMap?: never
1782
1797
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1798
+ returnQuery?: never
1799
+ /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1783
1800
  signal?: never
1784
1801
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1785
1802
  stega?: never
@@ -1799,6 +1816,9 @@ export declare interface QueryParams {
1799
1816
  */
1800
1817
  export declare type QueryWithoutParams = Record<string, never> | undefined
1801
1818
 
1819
+ /** @public */
1820
+ export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
1821
+
1802
1822
  /** @public */
1803
1823
  export declare interface RawQueryResponse<R> {
1804
1824
  query: string
@@ -1884,6 +1904,7 @@ export declare interface ResponseEvent<T = unknown> {
1884
1904
  export declare interface ResponseQueryOptions extends RequestOptions {
1885
1905
  perspective?: ClientPerspective
1886
1906
  resultSourceMap?: boolean | 'withKeyArraySelector'
1907
+ returnQuery?: boolean
1887
1908
  useCdn?: boolean
1888
1909
  stega?: boolean | StegaConfig
1889
1910
  cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
@@ -1970,6 +1991,18 @@ export declare class SanityClient {
1970
1991
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
1971
1992
  options: UnfilteredResponseQueryOptions,
1972
1993
  ): Promise<RawQueryResponse<R>>
1994
+ /**
1995
+ * Perform a GROQ-query against the configured dataset.
1996
+ *
1997
+ * @param query - GROQ-query to perform
1998
+ * @param params - Optional query parameters
1999
+ * @param options - Request options
2000
+ */
2001
+ fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
2002
+ query: string,
2003
+ params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
2004
+ options: UnfilteredResponseWithoutQuery,
2005
+ ): Promise<RawQuerylessQueryResponse<R>>
1973
2006
  /**
1974
2007
  * Fetch a single document with the given ID.
1975
2008
  *
@@ -2657,6 +2690,23 @@ export declare type TransactionMutationOptions =
2657
2690
  /** @public */
2658
2691
  export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
2659
2692
  filterResponse: false
2693
+ /**
2694
+ * When `filterResponse` is `false`, `returnQuery` also defaults to `true` for
2695
+ * backwards compatibility (on the client side, not from the content lake API).
2696
+ * Can also explicitly be set to `true`.
2697
+ */
2698
+ returnQuery?: true
2699
+ }
2700
+
2701
+ /**
2702
+ * When using `filterResponse: false`, but you do not wish to receive back the query from
2703
+ * the content lake API.
2704
+ *
2705
+ * @public
2706
+ */
2707
+ export declare interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {
2708
+ filterResponse: false
2709
+ returnQuery: false
2660
2710
  }
2661
2711
 
2662
2712
  export {unstable__adapter}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { printNoDefaultExport, defineCreateClientExports, SanityClient, middleware } from './_chunks/nodeMiddleware-scsxYdRh.js';
2
- export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-scsxYdRh.js';
1
+ import { printNoDefaultExport, defineCreateClientExports, SanityClient, middleware } from './_chunks/nodeMiddleware-BN5UYAym.js';
2
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-BN5UYAym.js';
3
3
  export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
4
4
 
5
5
  function defineDeprecatedCreateClient(createClient) {
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var browserMiddleware = require('./_chunks/browserMiddleware-dqqEd6vl.cjs');
5
+ var browserMiddleware = require('./_chunks/browserMiddleware-Dp4wx9CK.cjs');
6
6
  var getIt = require('get-it');
7
- var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-oPlkdofZ.cjs');
7
+ var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-DGdRCWlF.cjs');
8
8
 
9
9
  class SanityStegaClient extends browserMiddleware.SanityClient {
10
10
  }
@@ -1,7 +1,7 @@
1
- import { SanityClient, ObservableSanityClient, defineCreateClientExports, envMiddleware } from './_chunks/browserMiddleware-FL0Mlm8l.js';
2
- export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/browserMiddleware-FL0Mlm8l.js';
1
+ import { SanityClient, ObservableSanityClient, defineCreateClientExports, envMiddleware } from './_chunks/browserMiddleware-Cfl3LrrI.js';
2
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/browserMiddleware-Cfl3LrrI.js';
3
3
  export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
4
- export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-LDHMEOVo.js';
4
+ export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-DO8ipgJw.js';
5
5
 
6
6
  class SanityStegaClient extends SanityClient {
7
7
  }
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-iUs-kdpz.cjs');
5
+ var nodeMiddleware = require('./_chunks/nodeMiddleware-yTxugO4Q.cjs');
6
6
  var getIt = require('get-it');
7
- var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-hWSK_ZZK.cjs');
7
+ var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-D6fHf69f.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 = FilteredResponseQueryOptions | UnfilteredResponseQueryOptions
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-scsxYdRh.js';
2
- export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/nodeMiddleware-scsxYdRh.js';
1
+ import { SanityClient, ObservableSanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-BN5UYAym.js';
2
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/nodeMiddleware-BN5UYAym.js';
3
3
  export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
4
- export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-OHUCEAgw.js';
4
+ export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-MOb3TLiL.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.12.4",
3
+ "version": "6.13.0",
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.8",
138
- "@edge-runtime/vm": "^3.1.8",
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.1.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": "^6.21.0",
145
- "@typescript-eslint/parser": "^6.21.0",
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": "^10.0.0",
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.9.6",
160
+ "rollup": "^4.10.0",
161
161
  "sse-channel": "^4.0.0",
162
162
  "terser": "^5.27.0",
163
163
  "typescript": "^5.3.3",
@@ -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>(
@@ -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(client, httpRequest, 'query', {query, params}, reqOpts)
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 = FilteredResponseQueryOptions | UnfilteredResponseQueryOptions
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'
@@ -3406,7 +3406,7 @@
3406
3406
  options = {}
3407
3407
  }) => {
3408
3408
  const searchParams = new URLSearchParams();
3409
- const { tag, ...opts } = options;
3409
+ const { tag, returnQuery, ...opts } = options;
3410
3410
  if (tag)
3411
3411
  searchParams.append("tag", tag);
3412
3412
  searchParams.append("query", query);
@@ -3417,6 +3417,8 @@
3417
3417
  if (value)
3418
3418
  searchParams.append(key, "".concat(value));
3419
3419
  }
3420
+ if (returnQuery === false)
3421
+ searchParams.append("returnQuery", "false");
3420
3422
  return "?".concat(searchParams);
3421
3423
  };
3422
3424
 
@@ -3448,6 +3450,7 @@
3448
3450
  } : _stega;
3449
3451
  const params = stega.enabled ? vercelStegaCleanAll(_params) : _params;
3450
3452
  const mapResponse = options.filterResponse === false ? (res) => res : (res) => res.result;
3453
+ const returnQuery = options.filterResponse === false && options.returnQuery !== false;
3451
3454
  const { cache, next, ...opts } = {
3452
3455
  // Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
3453
3456
  // This is necessary in React Server Components to avoid opting out of Request Memoization.
@@ -3457,11 +3460,17 @@
3457
3460
  ...options
3458
3461
  };
3459
3462
  const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? { ...opts, fetch: { cache, next } } : opts;
3460
- const $request = _dataRequest(client, httpRequest, "query", { query, params }, reqOpts);
3463
+ const $request = _dataRequest(
3464
+ client,
3465
+ httpRequest,
3466
+ "query",
3467
+ { query, params, options: { returnQuery } },
3468
+ reqOpts
3469
+ );
3461
3470
  return stega.enabled ? $request.pipe(
3462
3471
  combineLatestWith(
3463
3472
  from(
3464
- Promise.resolve().then(function () { return stegaEncodeSourceMapLDHMEOVo; }).then(function (n) { return n.stegaEncodeSourceMap$1; }).then(
3473
+ Promise.resolve().then(function () { return stegaEncodeSourceMapDO8ipgJw; }).then(function (n) { return n.stegaEncodeSourceMap$1; }).then(
3465
3474
  ({ stegaEncodeSourceMap }) => stegaEncodeSourceMap
3466
3475
  )
3467
3476
  )
@@ -4987,7 +4996,7 @@
4987
4996
  stegaEncodeSourceMap: stegaEncodeSourceMap
4988
4997
  });
4989
4998
 
4990
- var stegaEncodeSourceMapLDHMEOVo = /*#__PURE__*/Object.freeze({
4999
+ var stegaEncodeSourceMapDO8ipgJw = /*#__PURE__*/Object.freeze({
4991
5000
  __proto__: null,
4992
5001
  encodeIntoResult: encodeIntoResult,
4993
5002
  stegaEncodeSourceMap: stegaEncodeSourceMap,