@sanity/client
Advanced tools
Comparing version 6.15.16 to 6.15.17-canary.0
{ | ||
"name": "@sanity/client", | ||
"version": "6.15.16", | ||
"version": "6.15.17-canary.0", | ||
"description": "Client for retrieving, creating and patching data from Sanity.io", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -27,15 +27,8 @@ import type {Middlewares} from 'get-it' | ||
// Set the http client to use for requests, and its environment specific middleware | ||
const httpRequest = defineHttpRequest(envMiddleware, {}) | ||
const httpRequest = defineHttpRequest(envMiddleware) | ||
const requester = httpRequest.defaultRequester | ||
const createClient = (config: ClientConfigType) => | ||
new ClassConstructor( | ||
defineHttpRequest(envMiddleware, { | ||
maxRetries: config.maxRetries, | ||
retryDelay: config.retryDelay, | ||
}), | ||
config, | ||
) | ||
const createClient = (config: ClientConfigType) => new ClassConstructor(httpRequest, config) | ||
return {requester, createClient} | ||
} |
@@ -30,18 +30,5 @@ import {getIt, type Middlewares} from 'get-it' | ||
/** @internal */ | ||
export function defineHttpRequest( | ||
envMiddleware: Middlewares, | ||
{ | ||
maxRetries = 5, | ||
retryDelay, | ||
}: {maxRetries?: number; retryDelay?: (attemptNumber: number) => number}, | ||
): HttpRequest { | ||
export function defineHttpRequest(envMiddleware: Middlewares): HttpRequest { | ||
const request = getIt([ | ||
maxRetries > 0 | ||
? retry({ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
retryDelay: retryDelay as any, // This option is typed incorrectly in get-it. | ||
maxRetries, | ||
shouldRetry, | ||
}) | ||
: {}, | ||
retry({shouldRetry}), | ||
...envMiddleware, | ||
@@ -67,2 +54,5 @@ printWarnings, | ||
function shouldRetry(err: any, attempt: number, options: any) { | ||
// Allow opting out of retries | ||
if (options.maxRetries === 0) return false | ||
// By default `retry.shouldRetry` doesn't retry on server errors so we add our own logic. | ||
@@ -69,0 +59,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2134129
23963
1