registry

package
v0.26.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

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

View Source
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

func NewNPMClient(timeout time.Duration) *NPMClient

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.

type Package

type Package struct {
	Name string
	Role string
	URL  string
}

Package is one entry in a publisher's package list as parsed from the registry response. Role mirrors the registry's permission vocabulary (npm: "write" / "read"; "write" implies maintainer authority on the package).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL