Repository navigation
feat(registry): add discovery.transformInfo and hide package.json from ~static - #1606
Merged
Merged
Conversation
…m ~static Lets registry owners decide what the discovery API returns for each component (e.g. removing author or private owner lists, or adding their own fields) without affecting internal consumers like the component-published event. The root package.json is also no longer reachable through the ~static redirect, which would otherwise bypass it. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…Info return type Encoded characters like %3F or %23 in a ~static path were decoded and then sent unescaped in the CDN redirect, so `package.json%3Fx` reached the root package.json as a query string. Each segment is now re-encoded before redirecting. transformInfo returned Record<string, unknown>, which rejects interfaces without an index signature; it now accepts any object. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
3 tasks done
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.
Summary
discovery.transformInforegistry option. It receives a component's package.json and returns the object the discovery API sends, so registries can remove fields (e.g.author, a privateownerslist) or add their own:GET /:name[/:version]/~info(JSON) andGET /?meta=.... With?meta=a,b, fields are picked from the transformed output, so removed fields can't be requested.component-publishedevent,onComponentRequestor rendering.TRANSFORM_INFO_FAILED) and fires anerrorevent; it never falls back to the raw package.json.hrefandrequestVersionare added by the registry after the transform. With?meta=true,state/publishDateare omitted if the transform removesoc(previously a missingoc.datewould throw).ComponentInfoandTransformInfotypes are exported.package.jsonnow returns 404 on the~staticroute, which otherwise redirected to the raw file and bypassed the transform. Nested files likepublic/package.jsonare still served.Note: the raw package.json is still publicly readable straight from the storage CDN (uploaded as a public file); this PR doesn't change storage.
Test plan
transformInfoon~infoandGET /?meta=...(sync/async, field picking, removedoc, no-meta skip, 500 on throw/reject/non-object)~statictests for rootpackage.jsonvariants being blocked and nestedpackage.jsonstill servednpm run build(lint + tsc) and fulloctest suite (1201 passing)Generated with Devin