Skip to content

feat: Add API endpoint to look up versions by integrity hash#1659

Open
abhinavgautam01 wants to merge 1 commit into
ecosyste-ms:mainfrom
abhinavgautam01:issue-1631-version-lookup
Open

feat: Add API endpoint to look up versions by integrity hash#1659
abhinavgautam01 wants to merge 1 commit into
ecosyste-ms:mainfrom
abhinavgautam01:issue-1631-version-lookup

Conversation

@abhinavgautam01
Copy link
Copy Markdown
Contributor

fixes #1631
depends on #1630...

Description

this PR introduces a new endpoint to find versions by their artifact hash (integrity). this is particularly useful for identifying a package from a tarball hash or cross-referencing the same artifact published across multiple registries...

Changes Made

  • Database: Added a concurrent, partial B-tree index on versions.integrity (WHERE integrity IS NOT NULL) to support performant lookups across the large table without locking it during migration...
  • API Controller: Implemented GET /api/v1/versions/lookup in the VersionsController. It handles exact integrity (SRI format) matches and normalizes bare hex digests provided via sha256, sha1, and sha512 query parameters.
  • Jbuilder View: Added lookup.json.jbuilder to structure the JSON response cleanly, ensuring the parent package and registry details are nested so the response is usable standalone.
  • OpenAPI Specs: Updated openapi/api/v1/openapi.yaml to document the new /versions/lookup endpoint and its schema parameters.

Fixes ecosyste-ms#1631
- Adds concurrent B-tree index on versions.integrity
- Adds GET /api/v1/versions/lookup endpoint
- Supports exact matching and normalizes hex digests into SRI format
- Adds standalone OpenAPI documentation and payload view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API: look up versions by integrity hash

1 participant