Skip to content
PHP Ecosystem
Explore

NpmRegistryInterface

API reference › Foxy › Native › NpmRegistryInterface

interfaceFoxy\Native\NpmRegistryInterface
Sourcesrc/Native/NpmRegistryInterface.php
Implemented by 1 type

Provides access to an npm registry: package metadata, verified tarballs, and security advisories.

MethodDescriptionDefined by
fetchTarball() abstractReturns the path of a verified .tgz written inside the directory.NpmRegistryInterface
getAdvisories() abstractReturns the registry’s bulk advisories document for the given versions, as the registry wrote it.NpmRegistryInterface
getMetadata() abstractReturns the abbreviated metadata of a package.NpmRegistryInterface
prefetchTarballs() abstractDownloads the tarballs missing from the cache in parallel, verifying each before it is cached.NpmRegistryInterface
abstract public function fetchTarball(Foxy\Native\ResolvedPackage $package, string $directory): string

Returns the path of a verified .tgz written inside the directory.

Parameters

ParameterTypeDescription
$packageResolvedPackageRegistry package whose tarball URL and integrity are used.
$directorystringExisting directory that receives the tarball.

Returns

string

Throws

abstract public function getAdvisories(array<string, non-empty-list<string>> $versions): string

Returns the registry’s bulk advisories document for the given versions, as the registry wrote it.

Parameters

ParameterTypeDescription
$versionsarray<string, non-empty-list<string>>Locked versions keyed by package name.

Returns

string

Throws

abstract public function getMetadata(string $name): Foxy\Native\PackageMetadata

Returns the abbreviated metadata of a package.

Parameters

ParameterTypeDescription
$namestringPackage name, scoped names included (@scope/name).

Returns

PackageMetadata

Throws

abstract public function prefetchTarballs(list<Foxy\Native\ResolvedPackage> $packages, string $directory): void

Downloads the tarballs missing from the cache in parallel, verifying each before it is cached.

The prefetch is best-effort: a tarball that fails to download or to verify is left out of the cache, and the later fetchTarball() downloads it again and reports the error. Each download lands in the given directory until it is verified, never in a shared temporary directory.

Parameters

ParameterTypeDescription
$packageslist<ResolvedPackage>Registry packages whose tarballs are wanted.
$directorystringExisting directory that holds each tarball while it is verified.