Documentation
¶
Overview ¶
Package registry wraps public package-registry APIs used to detect whether a contributor publishes packages under their handle. v1 covers npm; pypi is a deliberate gap (no public reverse-lookup API).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("registry: user not found or has no packages")
ErrNotFound is returned when the registry has no packages for the requested user. Distinguishes "user genuinely publishes nothing" (or never registered the handle) from a transport / decode error, so callers can cache the empty result without retrying.
Functions ¶
This section is empty.
Types ¶
type NPMClient ¶
type NPMClient struct {
// contains filtered or unexported fields
}
NPMClient queries the npm registry for a user's published packages.
func NewNPMClient ¶
NewNPMClient returns an NPMClient with the given timeout. Negative or zero timeout falls back to a sane default; callers should not run unbounded against the registry.
func (*NPMClient) FetchUserPackages ¶
func (c *NPMClient) FetchUserPackages(ctx context.Context, username string, topLimit int) (total int, top []Package, err error)
FetchUserPackages returns the published packages owned by the given npm username. The npm endpoint returns a JSON map of package-name to permission (npmRoleWrite / "read"); we surface only npmRoleWrite roles (the publisher relationship), sorted alphabetically and capped at topLimit for display. The full count is preserved in the returned total regardless of cap. Returns ErrNotFound on 404 (user has no publisher account).
We assume the npm username matches the GitHub username — common (Sindre, dominictarr, isaacs, etc.) but not universal. v1 limitation; we may add owned-repo cross-reference fallback later.