Skip to content

feat(registry): add discovery.transformInfo and hide package.json from ~static - #1606

Merged
ricardo-devis-agullo merged 3 commits into
masterfrom
feat/discovery-transform-info
Nov 19, 2026
Merged

ricardo-devis-agullo merged 3 commits into
masterfrom
feat/discovery-transform-info

Conversation

@ricardo-devis-agullo

Copy link
Copy Markdown
Collaborator

Summary

  • Add a discovery.transformInfo registry 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 private owners list) or add their own:
    discovery: {
      transformInfo: ({ author, owners, ...info }) => ({ ...info, team: 'payments' })
    }
  • Runs for GET /:name[/:version]/~info (JSON) and GET /?meta=.... With ?meta=a,b, fields are picked from the transformed output, so removed fields can't be requested.
  • Does not run for the HTML UI (if the UI is enabled it shows everything; disable it if you need privacy), the component-published event, onComponentRequest or rendering.
  • Sync or async. Throwing, rejecting or not returning an object responds with a 500 (TRANSFORM_INFO_FAILED) and fires an error event; it never falls back to the raw package.json.
  • href and requestVersion are added by the registry after the transform. With ?meta=true, state/publishDate are omitted if the transform removes oc (previously a missing oc.date would throw).
  • Non-function values are rejected by config validation. ComponentInfo and TransformInfo types are exported.
  • The root package.json now returns 404 on the ~static route, which otherwise redirected to the raw file and bypassed the transform. Nested files like public/package.json are 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

  • New unit tests for transformInfo on ~info and GET /?meta=... (sync/async, field picking, removed oc, no-meta skip, 500 on throw/reject/non-object)
  • Validator and options-sanitiser tests for the new option
  • ~static tests for root package.json variants being blocked and nested package.json still served
  • npm run build (lint + tsc) and full oc test suite (1201 passing)

Generated with Devin

ricardo-devis-agullo and others added 3 commits November 19, 2026 09:47
…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>
@ricardo-devis-agullo
ricardo-devis-agullo merged commit 1d43858 into master Nov 19, 2026
3 checks passed
@ricardo-devis-agullo
ricardo-devis-agullo deleted the feat/discovery-transform-info branch November 19, 2026 09:00
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.

1 participant