open-agreements
Version:
Open-source legal template filling CLI and library
24 lines • 1.06 kB
TypeScript
import type { DocxDocument } from '@usejunior/docx-core';
import type { FieldResolution } from './resolve.js';
export interface PatchOp {
field_id: string;
nodeId: string;
start: number;
end: number;
replaceText: string;
}
/**
* Build the patch ops for every RESOLVED occurrence. Unresolved occurrences are
* skipped here (the caller decides block/warn/skip via `failure_behavior`).
*/
export declare function buildPatchOps(fields: FieldResolution[]): PatchOp[];
/**
* Apply patch ops in place. Ops in the same paragraph are applied
* highest-offset-first so earlier offsets stay valid as text length changes.
* Overlapping spans within a paragraph are a programming/authoring error and
* throw rather than corrupt the document.
*/
export declare function applySelectorPatches(doc: DocxDocument, ops: PatchOp[]): void;
/** Serialize the patched document, stripping injected `_bk_*` bookmarks. */
export declare function serializeSelectorDoc(doc: DocxDocument, outputPath: string): Promise<void>;
//# sourceMappingURL=patch.d.ts.map