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’sdenywrites it. - Files
- A release’s checked files: its text, which the processor reads, and the rest as bytes, its images among them.
- Folder
Cache - A folder the registry rules’ cache steps are answered from: releases under
@<scope>/, asFolderStorekeeps them, and versions underversions/. - Frame
File - A file a frame may load, an image or a font’s file, with its media type.
- Kept
Release - 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).
- Kept
Versions - 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.
- Local
Registry - 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’ssourceslists (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.
- Served
Pack - A pack the registry serves: its name, each version with its files by path in the package.
- Version
Info - A version of a pack, as a registry’s metadata lists it.
Enums§
- Answer
- What the host did.
- Next
- What
Resolution::next_stepsgives: 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.jsonlists, by which a registry’s search finds packs.
Functions§
- answered_
versions - The versions of
packthe registryregistryanswered its metadata’s request with,statusandbody: none when it doesn’t have the pack (404). - metadata_
url - The URL of
pack’s metadata at the registryregistry(a URL ending in/): its name with its/escaped. It is fetched withAccept:ABBREVIATED. - off_
origin - Why
tarballmay not be fetched for the registryregistry, 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
missingnames, with the host’soptions, fromcacheand, unless it isNone, the network throughclient.missingis the host’sStep::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
scopethatbody, a registry’s answer tosearch_path, lists, in its order: a name of another scope, or that isn’t a pack’s, is left out. - tarball
filesas a pack’s tarball: a tar of them underpackage/, 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.