NpmRegistryInterface
API reference › Foxy › Native › NpmRegistryInterface
Implemented by 1 type
Provides access to an npm registry: package metadata, verified tarballs, and security advisories.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
fetchTarball() abstract | Returns the path of a verified .tgz written inside the directory. | NpmRegistryInterface |
getAdvisories() abstract | Returns the registry’s bulk advisories document for the given versions, as the registry wrote it. | NpmRegistryInterface |
getMetadata() abstract | Returns the abbreviated metadata of a package. | NpmRegistryInterface |
prefetchTarballs() abstract | Downloads the tarballs missing from the cache in parallel, verifying each before it is cached. | NpmRegistryInterface |
Method details
Section titled “Method details”fetchTarball()
Section titled “fetchTarball() ”abstract public function fetchTarball(Foxy\Native\ResolvedPackage $package, string $directory): stringReturns the path of a verified .tgz written inside the directory.
Parameters
| Parameter | Type | Description |
|---|---|---|
$package | ResolvedPackage | Registry package whose tarball URL and integrity are used. |
$directory | string | Existing directory that receives the tarball. |
Returns
string
Throws
Foxy\Exception\RuntimeException: if the request fails or the tarball does not match its integrity value.
getAdvisories()
Section titled “getAdvisories() ”abstract public function getAdvisories(array<string, non-empty-list<string>> $versions): stringReturns the registry’s bulk advisories document for the given versions, as the registry wrote it.
Parameters
| Parameter | Type | Description |
|---|---|---|
$versions | array<string, | Locked versions keyed by package name. |
Returns
string
Throws
Foxy\Exception\RuntimeException: if the request fails.
getMetadata()
Section titled “getMetadata() ”abstract public function getMetadata(string $name): Foxy\Native\PackageMetadataReturns the abbreviated metadata of a package.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Package name, scoped names included (@scope/name). |
Returns
Throws
Foxy\Exception\RuntimeException: if the package is unknown, the request fails, or the metadata is malformed.
prefetchTarballs()
Section titled “prefetchTarballs() ”abstract public function prefetchTarballs(list<Foxy\Native\ResolvedPackage> $packages, string $directory): voidDownloads 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
| Parameter | Type | Description |
|---|---|---|
$packages | list<ResolvedPackage> | Registry packages whose tarballs are wanted. |
$directory | string | Existing directory that holds each tarball while it is verified. |