/* auto-generated by NAPI-RS */ /* eslint-disable */ /** * `code` on the `Error` a failed conversion rejects with. Conversion fails * only when no complete Markdown could be produced; producer quirks are * recovered or skipped instead. */ export type ConvertErrorCode = /** Unknown format, or one that cannot be converted. */ | 'unsupported' /** * Pages of a PDF are scanned or image-only and need OCR, which anydoc does * not do. The error is a `NeedsOcrError` naming them. */ | 'needsOcr' /** Structurally unusable: no meaningful content could be extracted. */ | 'malformed' /** Encrypted or password-protected. */ | 'encrypted' /** Crossed a fixed safety limit (decompression, nesting, node count). */ | 'resourceLimit' /** A part required for any meaningful output is absent. */ | 'missingPart' /** The file could not be read, from `toMarkdown` only. */ | 'io' /** `ocr: 'hosted'` could not get the document through Firecrawl Parse. */ | 'hosted' /** The rejection for a PDF with pages that need OCR. */ export interface NeedsOcrError extends Error { code: 'needsOcr' /** 1-indexed pages that need OCR. */ pages: number[] /** Pages in the document. */ pageCount: number } /** * An embedded binary asset (image, object payload). Bytes are always * retained, so a document stays self-contained. */ export interface Asset { /** Index into `Document.assets`, as referenced by an image source. */ id: number /** MIME type, e.g. `image/png`. */ mediaType: string /** Package part or stream the asset came from, for provenance. */ originPart: string data: Buffer } export interface Block { kind: BlockKind /** heading: 1-6. */ level?: number /** heading: stable anchor id when the document targets this heading. */ anchor?: string /** heading, paragraph. */ content?: Array list?: List table?: Table /** blockQuote. */ blocks?: Array /** codeBlock. */ lang?: string /** codeBlock, math (LaTeX source without delimiters). */ text?: string } export declare const enum BlockKind { heading = 'heading', paragraph = 'paragraph', list = 'list', table = 'table', blockQuote = 'blockQuote', codeBlock = 'codeBlock', rule = 'rule', math = 'math' } export interface Cell { blocks: Array colSpan: number rowSpan: number } export interface CellSlot { kind: CellSlotKind /** origin. */ cell?: Cell /** covered: row of the origin this position belongs to. */ originRow?: number /** covered: column of the origin this position belongs to. */ originCol?: number } export declare const enum CellSlotKind { origin = 'origin', covered = 'covered' } export interface Document { blocks: Array /** * Footnote and endnote bodies, referenced from text by a `noteRef` * inline. */ notes: Array assets: Array } /** * Input format, named after the extension that identifies it. Container * variants that share a parser (`.docm`, `.xlsm`, `.ppsx`, ...) map onto * these. */ export declare const enum Format { doc = 'doc', docx = 'docx', odt = 'odt', /** * Converted with pdf-inspector, which emits Markdown directly: * `toDocument` is unsupported for PDFs. Scanned or image-only pages * need OCR, which anydoc does not do: the document rejects with * `needsOcr` naming them. */ pdf = 'pdf', ppt = 'ppt', pptx = 'pptx', rtf = 'rtf', epub = 'epub', xlsx = 'xlsx', ods = 'ods', odp = 'odp', csv = 'csv' } /** * Detect the format from the content itself: the signature and identity each * container specification designates (PDF header, RTF open group, OLE stream * names, ZIP package mimetype/content types). Plain-text formats (CSV) carry * no signature and return `null`; so does anything unrecognized. */ export declare function formatFromBytes(bytes: Uint8Array): Format | null /** The format an extension names, with or without a leading dot. */ export declare function formatFromExtension(extension: string): Format | null /** The format a path's extension names. */ export declare function formatFromPath(path: string): Format | null export interface ImageSource { kind: ImageSourceKind /** external. */ url?: string /** asset: index into `Document.assets`. */ assetId?: number } export declare const enum ImageSourceKind { /** Absolute URL with a scheme. */ external = 'external', /** Embedded image, carried in `Document.assets`. */ asset = 'asset', /** * No usable source: the image's part is missing or unreadable and it has * no URL. Only the alt text remains. */ unavailable = 'unavailable' } export interface Inline { kind: InlineKind /** text; math (LaTeX source without delimiters). */ text?: string /** text. */ style?: Style /** link. */ content?: Array /** link. */ target?: LinkTarget /** image. */ alt?: string /** image. */ source?: ImageSource /** anchor: the anchor id. */ anchor?: string /** noteRef: the id of the note in `Document.notes`. */ noteId?: string /** checkbox: its state. */ checked?: boolean } export declare const enum InlineKind { text = 'text', link = 'link', image = 'image', /** Zero-width marker for an internal link target at this position. */ anchor = 'anchor', noteRef = 'noteRef', lineBreak = 'lineBreak', /** An inline formula. */ math = 'math', /** A checkbox control. */ checkbox = 'checkbox' } export interface LinkTarget { kind: LinkTargetKind /** The URL, relative reference, or anchor id. */ value: string } export declare const enum LinkTargetKind { /** Absolute URL with a scheme. */ external = 'external', /** Scheme-less relative reference, preserved as written. */ relative = 'relative', /** Internal target: a heading anchor or an `anchor` inline. */ anchor = 'anchor' } export interface List { marker: MarkerKind /** Ordinal the first item counts from. */ start: number items: Array } export interface ListItem { blocks: Array /** * Literal marker text that overrides the list marker when the source * number text cannot be reproduced from the marker and position alone * (composite number text such as `1-a)`). */ markerLabel?: string } /** The marker family a list uses in the source document. */ export declare const enum MarkerKind { bullet = 'bullet', decimal = 'decimal', lowerAlpha = 'lowerAlpha', upperAlpha = 'upperAlpha', lowerRoman = 'lowerRoman', upperRoman = 'upperRoman' } export interface Note { id: string kind: NoteKind blocks: Array } export declare const enum NoteKind { footnote = 'footnote', endnote = 'endnote' } /** Fully resolved character style. */ export interface Style { bold: boolean italic: boolean strike: boolean code: boolean } /** * Canonical table grid: every logical grid position appears exactly once. * Content and spans live on the origin slot, and each position a span covers * holds a `covered` slot pointing back at that origin. */ export interface Table { grid: Array> /** Number of leading rows that are header rows (0 = no header). */ headerRows: number kind: TableKind } export declare const enum TableKind { /** A real data table. */ data = 'data', /** Layout scaffolding (text boxes, positioning tables). */ layout = 'layout' } /** * Parse an in-memory document into the document model, which also carries * the embedded assets. Without a format, it is detected from the content. * * Unsupported for `pdf`: PDF conversion produces Markdown directly and has * no document-model form; use `toMarkdownBytes`. * * Rejects with an `Error` carrying a `ConvertErrorCode` on `code`. */ export declare function toDocument(bytes: Uint8Array, format?: Format | undefined | null): Promise /** * Convert a document file to Markdown. The format is detected from the file * content; the extension is the fallback for signature-less formats (CSV) * and unrecognizable containers. * * Rejects with an `Error` carrying a `ConvertErrorCode` on `code`; a file * that cannot be read is `'io'`. */ export declare function toMarkdown(path: string): Promise /** * Convert an in-memory document to Markdown. Without a format, it is * detected from the content, which signature-less formats (CSV) have to name * explicitly. * * Rejects with an `Error` carrying a `ConvertErrorCode` on `code`. */ export declare function toMarkdownBytes(bytes: Uint8Array, format?: Format | undefined | null): Promise