Switch NuGet API to V3 Registration for version queries and V3 Flat Container for downloads#32
Merged
Merged
Conversation
…Container - Replace V3 Flat Container index with V3 Registration API (registration5-gz-semver2) for version queries, adding listing-awareness to exclude unlisted packages - Switch package downloads from V2 API (www.nuget.org/api/v2/package/) to V3 Flat Container (api.nuget.org/v3-flatcontainer/), fixing User-Agent not appearing in NuGet.org download statistics - Handle paginated Registration API responses for packages with 128+ versions by fetching external pages in parallel - Extract fetchJsonWithGzip helper for reusable HTTP+gzip+JSON fetching - Extract parseRegistrationIndex as pure testable function - Add 12 new unit tests covering registration parsing and HTTP pagination Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
User-Agent: ALCops-VSCode/{version}header added in v1.3.0 does not appear in NuGet.org download statistics. Investigation revealed two issues:Downloads used the V2 API (
www.nuget.org/api/v2/package/), which redirects toglobalcdn.nuget.org. NuGet.org tracks download statistics from CDN logs onapi.nuget.org(V3 Flat Container), so V2 downloads are not captured in the client breakdown.Version queries used the V3 Flat Container index, which returns all versions including unlisted ones. This is a latent bug: the extension could suggest unlisted versions for update.
Changes
Version queries: V3 Flat Container → V3 Registration API
registration5-gz-semver2hive which providescatalogEntry.listedper versionzlib.gunzipSync)Promise.all.Downloads: V2 → V3 Flat Container
www.nuget.org/api/v2/package/{id}/{version}toapi.nuget.org/v3-flatcontainer/{id}/{version}/{id}.{version}.nupkgCode quality
fetchJsonWithGzip<T>()helper for reusable HTTP+gzip+JSON fetchingparseRegistrationIndex()as a pure testable functionTesting
npm run lint✅npm run typecheck✅npm run unit-test✅ (30/30 pass)npm run bundle✅