/** * Wiki sync — recursively copy a wiki subtree to a target location. * * Primary: server-side copy via `wiki nodes copy` (fast, same-space). * Fallback: block-level copy (preserves ALL styles including images). */ import { type FailedImage } from "./block-copy.js"; import { type SyncState } from "./sync-state.js"; import type { RefMaps } from "./fix-refs.js"; import type { WikiClient } from "./wiki-client.js"; import type { WikiNode, SyncNodeResult, SyncOptions } from "./wiki-types.js"; /** * Recursively sync a wiki subtree from source to target. */ export declare function syncTree(wikiClient: WikiClient, sourceNode: WikiNode, targetParentToken: string, targetSpaceId: string, opts: SyncOptions, refs?: RefMaps, onTargetCreated?: (info: TargetCreatedInfo) => void): Promise; /** * Print the source tree in dry-run mode. */ export declare function printTree(wikiClient: WikiClient, sourceNode: WikiNode, indent?: number): void; /** * Copy the source node's page content into the target node (mirror semantics). * Clears existing target content, then block-copies from source. */ export declare function syncRootContent(wikiClient: WikiClient, sourceNode: WikiNode, targetNode: WikiNode, opts: SyncOptions, refs?: RefMaps): Promise<{ ok: boolean; created: number; failedImages: FailedImage[]; }>; /** * Incremental sync — only create new nodes and update modified ones. * Compares source tree against saved state to skip unchanged pages. * * `visited` accumulates every source nodeToken seen this run; the caller * uses it after the top-level call to detect orphans in state.pages. */ export declare function syncTreeIncremental(wikiClient: WikiClient, sourceNode: WikiNode, targetNode: WikiNode, state: SyncState, opts: SyncOptions, refs?: RefMaps, onProgress?: () => void, visited?: Set, rootFailedImagesOut?: FailedImage[], presentTargets?: Set): Promise; export interface TargetCreatedInfo { sourceToken: string; targetNodeToken: string; targetObjToken: string; sourceObjToken: string; title: string; objType: string; objEditTime: string; } export interface Orphan { sourceToken: string; targetNodeToken: string; title: string; } /** * Find pages in state.pages whose source nodeToken was NOT visited this run. * These represent source pages that have been deleted or moved out of the * subtree. The caller decides whether to report or prune. */ export declare function findOrphans(state: SyncState, visited: Set): Orphan[]; /** Remove orphaned entries from state.pages (state-only, does not touch target). */ export declare function pruneOrphansFromState(state: SyncState, orphans: Orphan[]): void; /** Walk sync results recursively and populate state.pages with the mapping. */ export declare function recordResultsInState(state: SyncState, results: SyncNodeResult[], refs: RefMaps, wikiClient: WikiClient): void; export declare function printSummary(results: SyncNodeResult[], rootFailedImages?: FailedImage[]): void; export type CheckKind = "new" | "modified" | "retry" | "rename" | "orphan" | "missing"; export interface CheckChange { kind: CheckKind; title: string; sourceToken?: string; targetToken?: string; reason?: string; } export interface CheckReport { rootChanged: boolean; changes: CheckChange[]; unchangedCount: number; totalSourcePages: number; } /** * Walk source tree and compare against saved state without writing anything. * Mirrors the classification logic of syncTreeIncremental so the report * matches what a real sync would do. * * Also walks the target tree to detect pages that were deleted out-of-band * (e.g., user removed them in the Feishu UI). These are reported as * "missing" and will be auto-healed by the next `sync` that touches them. */ export declare function checkSync(wikiClient: WikiClient, sourceNode: WikiNode, targetNode: WikiNode, state: SyncState): CheckReport; /** * Public wrapper: walk the target subtree once and return every present * nodeToken. Used by the sync command to pre-detect MISSING pages so the * incremental loop can heal them even when the source is unchanged. */ export declare function buildPresentTargets(wikiClient: WikiClient, targetRoot: WikiNode): Set; /** * Print the check report. Returns true if the target is in sync with source. */ export declare function printCheckReport(report: CheckReport, sourceTitle: string, targetTitle: string, state: SyncState): boolean; //# sourceMappingURL=sync.d.ts.map