IF Commons GitHub

logical/diff

Written to: 5 requirements: 5 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-bridge-transfer FR-003, 0003-bridge-transfer FR-004, 0003-bridge-transfer FR-005, 0003-bridge-transfer FR-006, 0003-bridge-transfer FR-007

The plan of a transfer: two inventories, compared, become a list of actions and nothing is changed. copy makes what is missing or different at the destination and never deletes; sync also makes the destination equal, within an allowance of deletes that is refused where it is exceeded; move is a copy that then removes the source, and needs a comparator that is sure; check lists the differences. The plan says how each file was compared, what the destination would not keep of it, and holds every rail the caller set. A plan is made from two lists and the comparisons, and is the same wherever it is made.

import { diff } from "./diff.ts";
// const plan = await diff({ kind: "copy" }, { store: a, prefix: ROOT }, { store: b, prefix: ROOT });

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

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

Sourcetypeno test imports it
type Source = Store<"read" | "list" | "stat">;

A source: a store that can be read and listed, and where it is read from.

Desttype
type Dest = Store<"read" | "write" | "list" | "stat" | "delete">;

A destination: a store that can be written.

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

Endpointtypeno test imports it
type Endpoint<S> = { readonly store: S; readonly prefix: Prefix };

A store with a prefix: one end of a transfer.

SourceFortypeno test imports it
type SourceFor<M extends Mode> = M extends { readonly kind: "move" } ? Store<"read" | "list" | "stat" | "delete"> : Source;

The source a mode needs: a move removes the source, so it must be able to delete.

DestFortypeno test imports it
type DestFor<M extends Mode> = M extends { readonly kind: "check" } ? Source : Dest;

The destination a mode needs: a check changes nothing, so it only reads.

DiffOptionstypeno test imports it
type DiffOptions = { /** The comparators in order; where none decides, the files are taken to differ. Default: the rev… (693 characters)
type DiffOptions = {
  /** The comparators in order; where none decides, the files are taken to differ. Default: the revisions where both are hashes, then the bytes. */
  readonly comparators?: readonly Comparator[];
  readonly rails?: Rails;
  /** Maps the path at the source to the path at the destination. Default: the same path. */
  readonly rewrite?: Rewrite;
  /** Rename a file at the destination that has the content of a missing one, in a sync, where the destination can rename. Default: true. */
  readonly renames?: boolean;
  readonly cache?: DigestCache;
  readonly pageSize?: number;
  /** Refuse a plan that loses anything at the destination. */
  readonly strict?: boolean;
};

How a plan is made.

DEFAULT_COMPARATORSconstno test imports it
const DEFAULT_COMPARATORS: readonly ("content-hash" | "native-digest" | "size-mtime")[]

The comparators a plan uses where none is given: the revisions, then the bytes.

Preparedtypeno test imports it
type Prepared = {
  readonly plan: Plan;
  readonly mode: Mode;
  readonly source: Endpoint<Source>;
  readonly dest: Endpoint<Dest>;
  readonly replan: () => Promise<Result<Plan, PlanRefusal>>;
};

A plan with the stores it was made from and the means to make it again: what an apply is given.

actionKeyconstno test imports it
const actionKey: (a: Action) => Path

The path an action is about, for ordering.

difffunction
function diff<M extends Mode>(mode: M, source: Endpoint<SourceFor<M>>, dest: Endpoint<DestFor<M>>, options?: DiffOptions): Promise<Result<Plan, PlanRefusal>>

Makes the plan of a transfer and nothing else.

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

preparefunction
function prepare<M extends Mode>(mode: M, source: Endpoint<SourceFor<M>>, dest: Endpoint<DestFor<M>>, options?: DiffOptions): Promise<Result<Prepared, PlanRefusal>>

Makes the plan and what an apply needs to check it again: the stores, the mode and the means to make the plan once more.

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

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