Entrytypeno test imports ittype Entry = { readonly rel: Path; readonly target: Path; readonly stat: Stat };One object of an inventory: its path relative to the endpoint, the path it will have at the other side, and what the store says of it.
What an endpoint holds: every object below its prefix, listed page by page, kept or left out by the filter, named relative to the prefix and, at a source, rewritten to the path it will have at the destination. The inventory is in the order of the paths, so that a plan made from two of them is the same plan wherever it is made.
import { identity } from "./inventory.ts";
// const r = await inventory(store, prefix, { keep: () => true, rewrite: identity });Entrytypeno test imports ittype Entry = { readonly rel: Path; readonly target: Path; readonly stat: Stat };One object of an inventory: its path relative to the endpoint, the path it will have at the other side, and what the store says of it.
Rewritetypeno test imports ittype Rewrite = (rel: Path) => Result<Path, string>;A rule that maps the path of a file at the source to its path at the destination, or says why it cannot.
identityconstconst identity: RewriteThe rewrite that keeps every path.
InventoryProblemtypeno test imports ittype InventoryProblem = { readonly kind: "store"; readonly problem: Problem } | { readonly kind: "rewrite"; readonly rel: Path; readonly detail: string };Why an inventory could not be made.
InventoryOptionstypeno test imports ittype InventoryOptions = { readonly keep: (rel: Path) => boolean; readonly rewrite: Rewrite; readonly pageSize: number };How an inventory is made: which files it keeps, how it names them, and how many it asks of the store at once.
keepOffunctionfunction keepOf(rails: Pick<Rails, "exclude" | "include">): (rel: Path) => booleanThe filter of a set of rails as a function: a file is kept where it matches an include, or there is none, and no exclude.
inventoryfunctionfunction inventory(store: Store<"list">, prefix: Prefix, options: InventoryOptions): Promise<Result<readonly Entry[], InventoryProblem>>Every object below prefix, in the order of their paths.