@sanity/client 6.1.0-scope.0 → 6.1.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/index.browser.cjs +15 -12
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +15 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +16 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +16 -13
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/data/dataMethods.ts +8 -6
- package/src/http/request.ts +2 -1
- package/src/types.ts +1 -6
- package/umd/sanityClient.js +21 -14
- package/umd/sanityClient.min.js +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -283,6 +283,7 @@ export declare interface ClientConfig {
|
|
|
283
283
|
/** @defaultValue true */
|
|
284
284
|
useCdn?: boolean
|
|
285
285
|
token?: string
|
|
286
|
+
perspective?: 'previewDrafts' | 'published' | 'all'
|
|
286
287
|
apiHost?: string
|
|
287
288
|
apiVersion?: string
|
|
288
289
|
proxy?: string
|
|
@@ -314,11 +315,6 @@ export declare interface ClientConfig {
|
|
|
314
315
|
* Adds a `resultSourceMap` key to the API response, with the type `ContentSourceMap`
|
|
315
316
|
*/
|
|
316
317
|
resultSourceMap?: boolean
|
|
317
|
-
/**
|
|
318
|
-
* Experimental, requires apiHost: 'https://api.sanity.work'.
|
|
319
|
-
* @alpha
|
|
320
|
-
*/
|
|
321
|
-
scope?: 'published' | 'previewDrafts'
|
|
322
318
|
}
|
|
323
319
|
|
|
324
320
|
/** @public */
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { adapter as unstable__adapter, environment as unstable__environment } fr
|
|
|
4
4
|
import { Observable, lastValueFrom } from 'rxjs';
|
|
5
5
|
import { map, filter } from 'rxjs/operators';
|
|
6
6
|
var name = "@sanity/client";
|
|
7
|
-
var version = "6.1.
|
|
7
|
+
var version = "6.1.1";
|
|
8
8
|
const middleware = [debug({
|
|
9
9
|
verbose: true,
|
|
10
10
|
namespace: "sanity:client"
|
|
@@ -122,7 +122,8 @@ function defineHttpRequest(envMiddleware, _ref) {
|
|
|
122
122
|
}
|
|
123
123
|
function shouldRetry(err, attempt, options) {
|
|
124
124
|
const isSafe = options.method === "GET" || options.method === "HEAD";
|
|
125
|
-
const
|
|
125
|
+
const uri = options.uri || options.url;
|
|
126
|
+
const isQuery = uri.startsWith("/data/query");
|
|
126
127
|
const isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
|
|
127
128
|
if ((isSafe || isQuery) && isRetriableResponse) return true;
|
|
128
129
|
return retry.shouldRetry(err, attempt, options);
|
|
@@ -837,17 +838,19 @@ function _requestObservable(client, httpRequest, options) {
|
|
|
837
838
|
...options.query
|
|
838
839
|
};
|
|
839
840
|
}
|
|
840
|
-
if (
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
841
|
+
if (["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
842
|
+
if (config.resultSourceMap) {
|
|
843
|
+
options.query = {
|
|
844
|
+
resultSourceMap: true,
|
|
845
|
+
...options.query
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
if (typeof config.perspective === "string" && config.perspective !== "all") {
|
|
849
|
+
options.query = {
|
|
850
|
+
perspective: config.perspective,
|
|
851
|
+
...options.query
|
|
852
|
+
};
|
|
853
|
+
}
|
|
851
854
|
}
|
|
852
855
|
const reqOptions = requestOptions(config, Object.assign({}, options, {
|
|
853
856
|
url: _getUrl(client, uri, useCdn)
|