Skip to content

createSyncPlan

function createSyncPlan(options: CreateSyncPlanOptions): TransferPlan;

Defined in: src/sync/createSyncPlan.ts:109

Builds a TransferPlan that reconciles two remote subtrees.

Plan steps are derived from a RemoteTreeDiff; the function does not perform any I/O. Direction, delete policy, and conflict policy control which entries become executable transfers and which become skip steps.

ParameterTypeDescription
optionsCreateSyncPlanOptionsInputs and policies that shape the plan.

TransferPlan

Transfer plan ready for createTransferJobsFromPlan or queue execution.

ConfigurationError When conflictPolicy: "error" encounters a conflict.

import {
createSyncPlan,
diffRemoteTrees,
summarizeTransferPlan,
} from "@zero-transfer/sdk";
const diff = await diffRemoteTrees(
srcSession.fs, "/dist",
dstSession.fs, "/releases/current",
);
const plan = createSyncPlan({
id: "release-mirror",
diff,
source: { provider: "sftp", rootPath: "/dist" },
destination: { provider: "s3", rootPath: "/releases/current" },
deletePolicy: "mirror",
conflictPolicy: "overwrite",
});
console.table(summarizeTransferPlan(plan));