IF Commons GitHub

logical/inventory

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-bridge-transfer FR-001

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 });

Source: commons/anyfs-bridge/src/logical/inventory.ts

3 of 7 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Entrytypeno test imports it
type 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 it
type 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.

identityconst
const identity: Rewrite

The rewrite that keeps every path.

Imported by 15 tests of the run (15 passed, 0 failed): the library's results

InventoryProblemtypeno test imports it
type 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 it
type 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.

keepOffunction
function keepOf(rails: Pick<Rails, "exclude" | "include">): (rel: Path) => boolean

The 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.

Imported by 15 tests of the run (15 passed, 0 failed): the library's results

inventoryfunction
function inventory(store: Store<"list">, prefix: Prefix, options: InventoryOptions): Promise<Result<readonly Entry[], InventoryProblem>>

Every object below prefix, in the order of their paths.

Imported by 15 tests of the run (15 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.