Sourcetypeno test imports ittype Source = Store<"read" | "list" | "stat">;A source: a store that can be read and listed, and where it is read from.
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 });Sourcetypeno test imports ittype Source = Store<"read" | "list" | "stat">;A source: a store that can be read and listed, and where it is read from.
Desttypetype Dest = Store<"read" | "write" | "list" | "stat" | "delete">;A destination: a store that can be written.
Endpointtypeno test imports ittype Endpoint<S> = { readonly store: S; readonly prefix: Prefix };A store with a prefix: one end of a transfer.
SourceFortypeno test imports ittype 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 ittype 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 ittype 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 itconst 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 ittype 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 itconst actionKey: (a: Action) => PathThe path an action is about, for ordering.
difffunctionfunction 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.
preparefunctionfunction 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.