open-agreements
Version:
Open-source legal template filling CLI and library
49 lines • 2.63 kB
TypeScript
/** Resolve a LibreOffice binary, or null if none is available (callers skip the oracle). */
export declare function resolveSoffice(): string | null;
/** Pack a bare `word/document.xml` string into a minimal valid .docx package. */
export declare function packMinimalDocx(documentXml: string): Promise<Buffer>;
/** Read `word/document.xml` back out of a .docx package. */
export declare function extractDocumentXml(docx: Buffer): Promise<string>;
/**
* `accept` / `reject` dispatch the corresponding resolve-all command before saving — the oracle's
* normal voting mode. `identity` loads and saves WITHOUT any dispatch, so unresolved tracked
* changes flow through LibreOffice's import/export: it exists to characterize the oracle's
* trust boundary (LibreOffice's save round-trip mangles some unresolved revision shapes — see
* libreoffice-oracle-trust-boundary.test.ts), NOT to vote on engine behavior.
*
* DOCX jobs carry a bare `word/document.xml` (packed into a minimal package and read back out);
* ODT jobs carry a complete `.odt` package buffer (ODF packaging — mimetype-first STORED — is
* the caller's concern) and return its post-op `content.xml`.
*
* CONVERSION jobs (`docx` + `saveAs: 'odt'`) carry a complete `.docx` package buffer and save
* through LibreOffice's `writer8` filter, returning the converted `content.xml` — the reference
* path for differential-testing odf-core's native DOCX→ODT converter (issue #331).
*/
type OracleOp = 'accept' | 'reject' | 'identity';
export type OracleJob = {
op: OracleOp;
documentXml: string;
} | {
op: OracleOp;
odt: Buffer;
} | {
op: OracleOp;
docx: Buffer;
saveAs: 'odt';
};
/**
* Run LibreOffice over a batch of jobs in ONE headless launch and return each job's resulting
* main XML part — `word/document.xml` for DOCX jobs, `content.xml` for ODT jobs. Throws if the
* binary is missing or the macro did not run.
*/
export declare function runLibreOfficeOracle(jobs: OracleJob[], soffice?: string | null): Promise<string[]>;
/**
* Structural projection of a `word/document.xml`: one entry per top-level body paragraph,
* recording whether it carries visible text (a non-whitespace `w:t` descendant). This captures
* the paragraph-collapse claim the oracle is authoritative for — how many paragraphs survive and
* which collapsed to empty — without depending on revision-markup or formatting details (which
* LibreOffice rewrites). `[]`-length is the paragraph count.
*/
export declare function paragraphShape(documentXml: string): boolean[];
export {};
//# sourceMappingURL=libreoffice-oracle.d.ts.map