open-agreements
Version:
Open-source legal template filling CLI and library
32 lines • 1.38 kB
TypeScript
import { DocxDocument, type DocumentViewNode, type LocatorResolution } from '@usejunior/docx-core';
import type { FieldSelectorManifest } from './manifest-schema.js';
export interface OccurrenceResolution {
index: number;
resolution: LocatorResolution;
}
export interface FieldResolution {
field_id: string;
occurrences: OccurrenceResolution[];
/** True when any occurrence locator resolved to zero or more than one span. */
unresolved: boolean;
/** Assertion failures across all occurrences (each a drift signal). */
assertionFailures: Array<{
occurrenceIndex: number;
kind: string;
detail?: string;
}>;
}
export interface ResolveResult {
/** The loaded, bookmarked document — the caller patches and serializes it. */
doc: DocxDocument;
view: DocumentViewNode[];
fields: FieldResolution[];
}
export declare function resolveFieldAgainstView(view: DocumentViewNode[], manifest: FieldSelectorManifest): FieldResolution;
/**
* Load `cleanedDocxPath`, bookmark its paragraphs, build the view, and resolve
* every occurrence locator. Returns the loaded document so the caller can patch
* the resolved spans and serialize once.
*/
export declare function resolveSelectorContracts(cleanedDocxPath: string, manifests: FieldSelectorManifest[]): Promise<ResolveResult>;
//# sourceMappingURL=resolve.d.ts.map