add ability for custom meta query #1448
Merged
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.
Add Selective Metadata Support to Registry API
Overview
This PR enhances the OpenComponents registry's discovery API by introducing selective metadata retrieval capabilities. The changes allow API consumers to request specific component metadata fields instead of receiving either all metadata or just component URLs.
Changes Made
Core Functionality
metaquery parameterdependencies,devDependencies) from metadata responsesmeta=trueandmeta=falseparametersCode Quality Improvements
componentNamesvscomponents,processedComponentsvscomponentsInfo)API Usage
The registry's
GET /endpoint now supports three metadata modes:GET /- Returns array of component URLsGET /?meta=true- Returns complete component metadataGET /?meta=name,version,author- Returns only specified fieldsExample Requests:
Example Response (selective metadata):
{ "href": "https://registry.example.com/", "ocVersion": "0.50.13", "type": "oc-registry", "components": [ { "href": "https://registry.example.com/my-component/1.0.0", "name": "my-component", "version": "1.0.0", "author": "John Doe" } ] }Security Considerations
The implementation automatically excludes potentially sensitive fields (
dependencies,devDependencies) from selective metadata responses, preventing accidental exposure of internal component dependencies while still allowing access to other useful metadata fields.Motivation
This enhancement addresses the need for more efficient API consumption by allowing clients to request only the metadata they require, reducing payload size and improving performance for applications that don't need complete component information. The selective approach is particularly valuable for:
The changes maintain full backward compatibility while providing a more flexible and efficient API surface.