@sanity/client
Advanced tools
+2
-2
| { | ||
| "name": "@sanity/client", | ||
| "version": "7.22.1", | ||
| "version": "7.23.0", | ||
| "description": "Client for retrieving, creating and patching data from Sanity.io", | ||
@@ -133,3 +133,3 @@ "keywords": [ | ||
| "@sanity/eventsource": "^5.0.2", | ||
| "get-it": "^8.7.2", | ||
| "get-it": "^8.8.0", | ||
| "nanoid": "^3.3.11", | ||
@@ -136,0 +136,0 @@ "rxjs": "^7.0.0" |
| import {getDraftId, getVersionFromId, getVersionId, isDraftId} from '@sanity/client/csm' | ||
| import {from, type MonoTypeOperatorFunction, Observable} from 'rxjs' | ||
| import {combineLatestWith, filter, map} from 'rxjs/operators' | ||
| import {from, type MonoTypeOperatorFunction, Observable, of} from 'rxjs' | ||
| import {combineLatestWith, concatMap, filter, map, reduce} from 'rxjs/operators' | ||
@@ -234,3 +234,48 @@ import {validateApiPerspective} from '../config' | ||
| const DOCUMENTS_EXISTS_BATCH_SIZE = 100 | ||
| /** @internal */ | ||
| export function _documentsExists( | ||
| client: Client, | ||
| httpRequest: HttpRequest, | ||
| ids: string[], | ||
| opts: {signal?: AbortSignal; tag?: string} = {}, | ||
| ): Observable<Set<string>> { | ||
| if (ids.length === 0) { | ||
| return of(new Set<string>()) | ||
| } | ||
| const batches: string[][] = [] | ||
| for (let i = 0; i < ids.length; i += DOCUMENTS_EXISTS_BATCH_SIZE) { | ||
| batches.push(ids.slice(i, i + DOCUMENTS_EXISTS_BATCH_SIZE)) | ||
| } | ||
| const fetchBatch = (batchIds: string[]) => | ||
| _requestObservable<Any>(client, httpRequest, { | ||
| uri: _getDataUrl(client, 'doc', batchIds.map(encodeURIComponent).join(',')), | ||
| tag: opts.tag, | ||
| signal: opts.signal, | ||
| query: {excludeContent: true}, | ||
| }).pipe( | ||
| filter(isResponse), | ||
| map((event: Any) => { | ||
| const missing = new Set<string>() | ||
| for (const omitted of event.body.omitted || []) { | ||
| if (omitted.reason !== 'existence') continue | ||
| missing.add(omitted.id) | ||
| } | ||
| return new Set(batchIds.filter((id) => !missing.has(id))) | ||
| }), | ||
| ) | ||
| return from(batches).pipe( | ||
| concatMap(fetchBatch), | ||
| reduce((acc, set) => { | ||
| for (const id of set) acc.add(id) | ||
| return acc | ||
| }, new Set<string>()), | ||
| ) | ||
| } | ||
| /** @internal */ | ||
| export function _getReleaseDocuments<R extends Record<string, Any>>( | ||
@@ -602,2 +647,7 @@ client: ObservableSanityClient | SanityClient, | ||
| ): Observable<HttpRequestEvent<R>> { | ||
| // Capture the call-site error here, where the caller's code is still | ||
| // on the synchronous call stack, and pass it through to get-it so errors | ||
| // include the originating call site rather than just internal plumbing. | ||
| const callSiteStack = new Error() | ||
| const uri = options.url || (options.uri as string) | ||
@@ -672,2 +722,3 @@ const config = client.config() | ||
| url: _getUrl(client, uri, useCdn), | ||
| callSiteStack, | ||
| }), | ||
@@ -674,0 +725,0 @@ ) as RequestOptions |
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 too big to display
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 too big to display
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 too big to display
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 too big to display
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 too big to display
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 too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
5102863
0.68%59763
0.78%Updated