open-agreements
Version:
Open-source legal template filling CLI and library
134 lines • 5.43 kB
TypeScript
export interface SyntheticDocxOptions {
paragraphs: string[];
footnoteOnParagraph?: number;
footnoteText?: string;
endnoteOnParagraph?: number;
endnoteText?: string;
commentOnParagraph?: number;
commentText?: string;
commentAuthor?: string;
commentAncillaryParts?: boolean;
/**
* Threaded reply to the root comment (w:id="1"). Emits a second
* <w:comment w:id="2"> with paraId 00000002 and, when commentAncillaryParts
* is also set, a <w15:commentEx w15:paraIdParent="00000001"> linkage and a
* second <w15:person> for the reply author. Reply comments deliberately
* have NO <w:commentReference> in document.xml — that's the issue #108
* shape: replies are discoverable only via paraIdParent threading.
*/
replyText?: string;
replyAuthor?: string;
/**
* Cross-paragraph comment span. The comment opens at the start of
* paragraphs[start] and closes at the end of paragraphs[end]. The
* commentReference run is appended to paragraphs[end].
*
* Mutually exclusive with commentOnParagraph.
*/
commentSpanParagraphs?: {
start: number;
end: number;
};
/**
* Bookmark spanning a single paragraph (start and end inside the same w:p).
* Used to verify paragraph-internal bookmark preservation through rebuild.
*/
bookmarkOnParagraph?: {
paragraph: number;
name: string;
id?: number;
};
/**
* Body-level (sibling of <w:p>) bookmark inserted between
* paragraphs[index - 1] and paragraphs[index]. Used to verify scaffold
* markers do not leak into reconstructed paragraphs.
*/
siblingBookmarkBefore?: {
index: number;
name: string;
id?: number;
};
/**
* Multi-paragraph comment range with body-level markers: the
* commentRangeStart is emitted as a sibling of <w:p> before
* paragraphs[startBeforeParagraph] and the commentRangeEnd as a sibling
* after paragraphs[endAfterParagraph]. The commentReference run is
* appended inside paragraphs[endAfterParagraph]. This is the issue #103
* shape: range markers spanning whole paragraphs sit outside any <w:p>.
*
* Mutually exclusive with commentOnParagraph and commentSpanParagraphs.
*/
siblingCommentRange?: {
startBeforeParagraph: number;
endAfterParagraph: number;
};
/**
* Pre-existing tracked move with explicit in-paragraph range markers.
* paragraphs[from]'s text is wrapped in <w:moveFrom> (as w:delText)
* bracketed by w:moveFromRangeStart/End; paragraphs[to]'s text is wrapped
* in <w:moveTo> bracketed by w:moveToRangeStart/End. All four markers are
* direct children of their <w:p>, sharing the given w:name. Callers should
* pass identical text for paragraphs[from] and paragraphs[to] so the shape
* matches what Word produces for a real tracked move. Used to verify
* explicit move-range marker reconstruction (issue #110).
*/
trackedMove?: {
from: number;
to: number;
name: string;
author?: string;
firstId?: number;
};
/**
* Range permission spanning paragraphs. permStart opens at the start of
* paragraphs[start] and permEnd closes at the end of paragraphs[end].
* start === end yields a single-paragraph span around that paragraph's run.
*/
permSpanParagraphs?: {
start: number;
end: number;
id?: number;
};
/**
* Body-level (sibling of <w:p>) permStart/permEnd pair inserted between
* paragraphs[index - 1] and paragraphs[index]. Used to verify scaffold
* perm markers do not leak into reconstructed paragraphs.
*/
siblingPermBefore?: {
index: number;
id?: number;
};
}
export declare function buildSyntheticDocx(opts: SyntheticDocxOptions): Promise<Buffer>;
/** Parts for {@link buildDocxFromParts}. Only the body XML is required. */
export interface DocxPartsOptions {
/** Raw `<w:body>` children (paragraphs/tables), without the `<w:body>` wrapper. */
bodyXml: string;
/** Full `word/styles.xml` content. */
stylesXml?: string;
/** Full `word/numbering.xml` content. */
numberingXml?: string;
/** Extra `<Relationship …/>` entries for `word/_rels/document.xml.rels` (e.g. hyperlinks). */
documentRelEntries?: string[];
}
/**
* Build a loadable DOCX from raw part XML. The `testing/ooxml-fixtures.ts`
* `buildDocxFromBodyXml` covers the body-only case for docx-core's own tests, but it lives
* in the build-excluded testing tree; this builder is exported from the package root for
* downstream suites (odf-core's DOCX→ODT conversion tests) and additionally accepts the
* optional styles/numbering/relationship parts those tests exercise.
*/
export declare function buildDocxFromParts(opts: DocxPartsOptions): Promise<Buffer>;
export interface SyntheticResultParts {
documentXml: string;
footnotesXml: string | null;
endnotesXml: string | null;
commentsXml: string | null;
commentsExtendedXml: string | null;
commentsIdsXml: string | null;
peopleXml: string | null;
contentTypesXml: string | null;
relsXml: string | null;
}
export declare function getResultParts(resultBuffer: Buffer): Promise<SyntheticResultParts>;
//# sourceMappingURL=synthetic-docx-fixture.d.ts.map