@sanity/client
Advanced tools
Comparing version 6.20.1 to 6.20.2-beta.0
{ | ||
"name": "@sanity/client", | ||
"version": "6.20.1", | ||
"version": "6.20.2-beta.0", | ||
"description": "Client for retrieving, creating and patching data from Sanity.io", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import {Observable} from 'rxjs' | ||
import {domainSharder as sharder} from '../http/domainSharding' | ||
import type {ObservableSanityClient, SanityClient} from '../SanityClient' | ||
@@ -67,3 +68,7 @@ import type {Any, ListenEvent, ListenOptions, ListenParams, MutationEvent} from '../types' | ||
const uri = `${url}${_getDataUrl(this, 'listen', qs)}` | ||
let uri = `${url}${_getDataUrl(this, 'listen', qs)}` | ||
if (this.config().useDomainSharding) { | ||
uri = sharder.getShardedUrl(uri) | ||
} | ||
if (uri.length > MAX_URL_LENGTH) { | ||
@@ -95,2 +100,8 @@ return new Observable((observer) => observer.error(new Error('Query too large for listener'))) | ||
// We're about to connect, and will reuse the same shard/bucket for every reconnect henceforth. | ||
// This may seem inoptimal, but once connected we should just consider this as a "permanent" | ||
// connection, since we'll automatically retry on failures/disconnects. Once we explicitly | ||
// unsubsccribe, we can decrement the bucket and free up the shard. | ||
sharder.incrementBucketForUrl(uri) | ||
open() | ||
@@ -192,2 +203,3 @@ | ||
unsubscribed = true | ||
sharder.decrementBucketForUrl(uri) | ||
} | ||
@@ -194,0 +206,0 @@ |
@@ -36,2 +36,3 @@ import type {Middlewares} from 'get-it' | ||
retryDelay: config.retryDelay, | ||
useDomainSharding: config.useDomainSharding, | ||
...options, | ||
@@ -38,0 +39,0 @@ } as Any), |
@@ -1,1 +0,3 @@ | ||
export default [] | ||
import {domainSharder} from './domainSharding' | ||
export default [domainSharder.middleware] |
import {agent, debug, headers} from 'get-it/middleware' | ||
import {name, version} from '../../package.json' | ||
import {domainSharder} from './domainSharding' | ||
const middleware = [ | ||
domainSharder.middleware, | ||
debug({verbose: true, namespace: 'sanity:client'}), | ||
@@ -7,0 +10,0 @@ headers({'User-Agent': `${name} ${version}`}), |
@@ -50,2 +50,10 @@ // deno-lint-ignore-file no-empty-interface | ||
/** | ||
* Spread the requests over a number of hostnames to work around HTTP/1.1 limitations. | ||
* Only applicable in browsers, and for certain allowed projects. | ||
* | ||
* @alpha | ||
*/ | ||
useDomainSharding?: boolean | ||
/** | ||
* Optional request tag prefix for all request tags | ||
@@ -52,0 +60,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 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
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 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
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
2280592
98
25719
1