Skip to main content

Module registry

Module registry 

Source
Expand description

The registry rules (the registry rules; hosting, H1): resolving a request’s packs from registries, the policy before any download, checking a tarball and reading it, once, for every host. The rules do no I/O: a Resolution says what it needs next, and the host does it its own way, synchronously on a thread of its own or awaited, and gives the answer back.

use std::collections::BTreeMap;
use compmd_host::registry::{Answer, Next, Options, Resolution, Step};

let options = Options::new(BTreeMap::from([("*".to_owned(), "https://registry.npmjs.org/".to_owned())]));
let mut resolution = Resolution::new(options);
let resolved = loop {
    match resolution.next_steps() {
        Next::Steps(steps) => {
            for step in steps {
                // The host's I/O: here, a request that imports nothing.
                let answer = match step {
                    Step::Missing { .. } => Answer::Missing { packs: Vec::new() },
                    _ => Answer::Done,
                };
                resolution.give(step.id(), answer);
            }
        }
        Next::Done(resolved) => break resolved,
    }
};
assert!(resolved.releases.is_empty());

Structs§

Client
A client of npm registries: blocking, so a host runs it on a thread of its own.
Denied
A pack the host’s policy denies, all versions or those in version, as its configuration’s deny writes it.
Files
A release’s checked files: its text, which the processor reads, and the rest as bytes, its images among them.
FolderCache
A folder the registry rules’ cache steps are answered from: releases under @<scope>/, as FolderStore keeps them, and versions under versions/.
FrameFile
A file a frame may load, an image or a font’s file, with its media type.
KeptRelease
A release as a host’s cache keeps it: its pack, version and tarball’s integrity, so one pack’s files are never given as another’s, whatever integrity an import pins (audit S4).
KeptVersions
A pack’s versions as a host’s cache keeps them, and whether the list is fresh enough to use without asking the registry: the host’s clock says.
LocalRegistry
A registry serving packs on the machine until it is dropped.
Metadata
A registry’s answer to a request for a pack’s metadata.
Needed
A pack an import, or a pack’s peerDependencies, names that the request has no release of: what the processor’s sources lists (NeededPack).
Options
A host’s settings for resolving.
Problem
Something that couldn’t be got, for the host’s logs; the document is told by the processor’s diagnostics.
Proxy
The proxy of a host’s registries.
Release
A release for the request’s packs, as the processor takes one (PackRelease).
Resolution
One resolution of a request’s packs.
Resolved
What a resolution gave.
ServedPack
A pack the registry serves: its name, each version with its files by path in the package.
VersionInfo
A version of a pack, as a registry’s metadata lists it.

Enums§

Answer
What the host did.
Next
What Resolution::next_steps gives: steps for the host, or what the resolution gave.
Step
What the resolution needs the host to do.

Constants§

ABBREVIATED
The abbreviated form of npm’s metadata, which lists every version with its tarball and integrity.
DEFAULT_MAX_PACK_SIZE
The size cap when the host sets none: Mermaid 12’s module as one file is 7 MB, with its layout engines.
PACK_KEYWORD
The keyword a pack’s package.json lists, by which a registry’s search finds packs.

Functions§

answered_versions
The versions of pack the registry registry answered its metadata’s request with, status and body: none when it doesn’t have the pack (404).
metadata_url
The URL of pack’s metadata at the registry registry (a URL ending in /): its name with its / escaped. It is fetched with Accept: ABBREVIATED.
off_origin
Why tarball may not be fetched for the registry registry, if so: a tarball is fetched only from its registry’s origin, so a host’s headers for it (a private registry’s token) go nowhere else. A registry that speaks npm’s protocol checks it before it fetches a tarball.
resolve
Resolves the packs missing names, with the host’s options, from cache and, unless it is None, the network through client. missing is the host’s Step::Missing: given the releases and refusals resolved since it was last asked, it says which packs the request still has no release of.
search_path
The path of the search, under a registry’s URL, for the packs of scope (@kit).
searched
The packs of scope that body, a registry’s answer to search_path, lists, in its order: a name of another scope, or that isn’t a pack’s, is left out.
tarball
files as a pack’s tarball: a tar of them under package/, gzipped, as npm publishes one.
versions_of
The versions body, a registry’s abbreviated metadata, lists, each with a tarball, its URL resolved against the registry’s.

Type Aliases§

StepId
A step, by the number the resolution gave it: the host answers it with the same number.