@sanity/client 6.12.3 → 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.
- package/dist/_chunks/{browserMiddleware-zDVeirri.js → browserMiddleware-Cfl3LrrI.js} +13 -4
- package/dist/_chunks/browserMiddleware-Cfl3LrrI.js.map +1 -0
- package/dist/_chunks/{browserMiddleware-IWUpjfF7.cjs → browserMiddleware-Dp4wx9CK.cjs} +13 -4
- package/dist/_chunks/browserMiddleware-Dp4wx9CK.cjs.map +1 -0
- package/dist/_chunks/{nodeMiddleware-OX5-R8Hk.js → nodeMiddleware-BN5UYAym.js} +14 -5
- package/dist/_chunks/nodeMiddleware-BN5UYAym.js.map +1 -0
- package/dist/_chunks/{nodeMiddleware-Gh18jsRe.cjs → nodeMiddleware-yTxugO4Q.cjs} +14 -5
- package/dist/_chunks/nodeMiddleware-yTxugO4Q.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-ZDmZYDbM.cjs → stegaEncodeSourceMap-D6fHf69f.cjs} +10 -12
- package/dist/_chunks/stegaEncodeSourceMap-D6fHf69f.cjs.map +1 -0
- package/dist/_chunks/{stegaEncodeSourceMap-YNx-0kzT.cjs → stegaEncodeSourceMap-DGdRCWlF.cjs} +9 -11
- package/dist/_chunks/{stegaEncodeSourceMap-YNx-0kzT.cjs.map → stegaEncodeSourceMap-DGdRCWlF.cjs.map} +1 -1
- package/dist/_chunks/{stegaEncodeSourceMap-gZIRaYar.js → stegaEncodeSourceMap-DO8ipgJw.js} +9 -11
- package/dist/_chunks/{stegaEncodeSourceMap-gZIRaYar.js.map → stegaEncodeSourceMap-DO8ipgJw.js.map} +1 -1
- package/dist/_chunks/{stegaEncodeSourceMap-OKnT3zAM.js → stegaEncodeSourceMap-MOb3TLiL.js} +10 -12
- package/dist/_chunks/stegaEncodeSourceMap-MOb3TLiL.js.map +1 -0
- 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 +10 -10
- package/src/SanityClient.ts +26 -0
- package/src/data/dataMethods.ts +12 -1
- package/src/data/encodeQueryString.ts +4 -1
- package/src/stega/stegaEncodeSourceMap.ts +7 -9
- package/src/types.ts +28 -1
- package/umd/sanityClient.js +20 -13
- package/umd/sanityClient.min.js +3 -3
- package/dist/_chunks/browserMiddleware-IWUpjfF7.cjs.map +0 -1
- package/dist/_chunks/browserMiddleware-zDVeirri.js.map +0 -1
- package/dist/_chunks/nodeMiddleware-Gh18jsRe.cjs.map +0 -1
- package/dist/_chunks/nodeMiddleware-OX5-R8Hk.js.map +0 -1
- package/dist/_chunks/stegaEncodeSourceMap-OKnT3zAM.js.map +0 -1
- package/dist/_chunks/stegaEncodeSourceMap-ZDmZYDbM.cjs.map +0 -1
package/dist/csm.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var resolveEditInfo = require('./_chunks/resolveEditInfo-
|
|
5
|
+
var resolveEditInfo = require('./_chunks/resolveEditInfo-CkO-V0Hb.cjs');
|
|
6
6
|
|
|
7
7
|
const defaultUpdateFunction = (changed) => changed;
|
|
8
8
|
function applySourceDocuments(result, resultSourceMap, getCachedDocument, updateFn = defaultUpdateFunction, perspective = "raw") {
|
package/dist/csm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { walkMap, resolveMapping, parseJsonPath, toString, DRAFTS_PREFIX, getPublishedId, get, jsonPath, studioPathToJsonPath, resolveEditInfo, createEditUrl } from './_chunks/resolveEditInfo-
|
|
2
|
-
export { jsonPathToStudioPath, studioPath } from './_chunks/resolveEditInfo-
|
|
1
|
+
import { walkMap, resolveMapping, parseJsonPath, toString, DRAFTS_PREFIX, getPublishedId, get, jsonPath, studioPathToJsonPath, resolveEditInfo, createEditUrl } from './_chunks/resolveEditInfo-BC6qdqZw.js';
|
|
2
|
+
export { jsonPathToStudioPath, studioPath } from './_chunks/resolveEditInfo-BC6qdqZw.js';
|
|
3
3
|
|
|
4
4
|
const defaultUpdateFunction = (changed) => changed;
|
|
5
5
|
function applySourceDocuments(result, resultSourceMap, getCachedDocument, updateFn = defaultUpdateFunction, perspective = "raw") {
|
package/dist/index.browser.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var browserMiddleware = require('./_chunks/browserMiddleware-
|
|
5
|
+
var browserMiddleware = require('./_chunks/browserMiddleware-Dp4wx9CK.cjs');
|
|
6
6
|
var getIt = require('get-it');
|
|
7
7
|
|
|
8
8
|
function defineDeprecatedCreateClient(createClient) {
|
package/dist/index.browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { printNoDefaultExport, defineCreateClientExports, SanityClient, envMiddleware } from './_chunks/browserMiddleware-
|
|
2
|
-
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/browserMiddleware-
|
|
1
|
+
import { printNoDefaultExport, defineCreateClientExports, SanityClient, envMiddleware } from './_chunks/browserMiddleware-Cfl3LrrI.js';
|
|
2
|
+
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/browserMiddleware-Cfl3LrrI.js';
|
|
3
3
|
export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
|
|
4
4
|
|
|
5
5
|
function defineDeprecatedCreateClient(createClient) {
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var nodeMiddleware = require('./_chunks/nodeMiddleware-
|
|
5
|
+
var nodeMiddleware = require('./_chunks/nodeMiddleware-yTxugO4Q.cjs');
|
|
6
6
|
var getIt = require('get-it');
|
|
7
7
|
|
|
8
8
|
function defineDeprecatedCreateClient(createClient) {
|
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 =
|
|
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-
|
|
2
|
-
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-
|
|
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) {
|
package/dist/stega.browser.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var browserMiddleware = require('./_chunks/browserMiddleware-
|
|
5
|
+
var browserMiddleware = require('./_chunks/browserMiddleware-Dp4wx9CK.cjs');
|
|
6
6
|
var getIt = require('get-it');
|
|
7
|
-
var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-
|
|
7
|
+
var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-DGdRCWlF.cjs');
|
|
8
8
|
|
|
9
9
|
class SanityStegaClient extends browserMiddleware.SanityClient {
|
|
10
10
|
}
|
package/dist/stega.browser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SanityClient, ObservableSanityClient, defineCreateClientExports, envMiddleware } from './_chunks/browserMiddleware-
|
|
2
|
-
export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/browserMiddleware-
|
|
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-
|
|
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-
|
|
5
|
+
var nodeMiddleware = require('./_chunks/nodeMiddleware-yTxugO4Q.cjs');
|
|
6
6
|
var getIt = require('get-it');
|
|
7
|
-
var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-
|
|
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 =
|
|
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-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-
|
|
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.
|
|
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,30 +134,30 @@
|
|
|
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",
|
|
154
154
|
"ls-engines": "^0.9.1",
|
|
155
155
|
"next": "^14.1.0",
|
|
156
156
|
"nock": "^13.5.1",
|
|
157
|
-
"prettier": "^3.2.
|
|
158
|
-
"prettier-plugin-packagejson": "^2.4.
|
|
157
|
+
"prettier": "^3.2.5",
|
|
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
|
}
|
|
@@ -24,12 +24,12 @@ export function stegaEncodeSourceMap<Result = unknown>(
|
|
|
24
24
|
const {filter, logger, enabled} = config
|
|
25
25
|
if (!enabled) {
|
|
26
26
|
const msg = "config.enabled must be true, don't call this function otherwise"
|
|
27
|
-
logger?.error?.(`[@sanity/client
|
|
27
|
+
logger?.error?.(`[@sanity/client]: ${msg}`, {result, resultSourceMap, config})
|
|
28
28
|
throw new TypeError(msg)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (!resultSourceMap) {
|
|
32
|
-
logger?.error?.('[@sanity/client
|
|
32
|
+
logger?.error?.('[@sanity/client]: Missing Content Source Map from response body', {
|
|
33
33
|
result,
|
|
34
34
|
resultSourceMap,
|
|
35
35
|
config,
|
|
@@ -39,7 +39,7 @@ export function stegaEncodeSourceMap<Result = unknown>(
|
|
|
39
39
|
|
|
40
40
|
if (!config.studioUrl) {
|
|
41
41
|
const msg = 'config.studioUrl must be defined'
|
|
42
|
-
logger?.error?.(`[@sanity/client
|
|
42
|
+
logger?.error?.(`[@sanity/client]: ${msg}`, {result, resultSourceMap, config})
|
|
43
43
|
throw new TypeError(msg)
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -109,15 +109,13 @@ export function stegaEncodeSourceMap<Result = unknown>(
|
|
|
109
109
|
const isSkipping = report.skipped.length
|
|
110
110
|
const isEncoding = report.encoded.length
|
|
111
111
|
if (isSkipping || isEncoding) {
|
|
112
|
-
;(logger?.groupCollapsed || logger.log)?.(
|
|
113
|
-
'[@sanity/client/stega]: Encoding source map into result',
|
|
114
|
-
)
|
|
112
|
+
;(logger?.groupCollapsed || logger.log)?.('[@sanity/client]: Encoding source map into result')
|
|
115
113
|
logger.log?.(
|
|
116
|
-
`[@sanity/client
|
|
114
|
+
`[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`,
|
|
117
115
|
)
|
|
118
116
|
}
|
|
119
117
|
if (report.encoded.length > 0) {
|
|
120
|
-
logger?.log?.(`[@sanity/client
|
|
118
|
+
logger?.log?.(`[@sanity/client]: Table of encoded paths`)
|
|
121
119
|
;(logger?.table || logger.log)?.(report.encoded)
|
|
122
120
|
}
|
|
123
121
|
if (report.skipped.length > 0) {
|
|
@@ -125,7 +123,7 @@ export function stegaEncodeSourceMap<Result = unknown>(
|
|
|
125
123
|
for (const {path} of report.skipped) {
|
|
126
124
|
skipped.add(path.replace(reKeySegment, '0').replace(/\[\d+\]/g, '[]'))
|
|
127
125
|
}
|
|
128
|
-
logger?.log?.(`[@sanity/client
|
|
126
|
+
logger?.log?.(`[@sanity/client]: List of skipped paths`, [...skipped.values()])
|
|
129
127
|
}
|
|
130
128
|
|
|
131
129
|
if (isSkipping || isEncoding) {
|
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'
|