@openparser/schema
v1.0.2
Published
Zod schemas and TypeScript types for openparser@1 documents and raw OCR envelopes
Maintainers
Readme
@openparser/schema
Zod schemas and TypeScript types for openparser@1 document graphs and the
generic raw OCR result envelope.
Use this package to validate parse results at runtime, type document graphs in TypeScript, and share one canonical graph definition across providers and runtimes.
Install
npm install @openparser/schemaImport
Import from the package root (@openparser/schema):
import {
ParsedDocumentSchema,
RawParseResultSchema,
OcrOutputFormatSchema,
type ParsedDocument,
type RawParseResult,
type ParsedDocumentWithElementKinds,
} from '@openparser/schema';Validate at runtime with ParsedDocumentSchema.parse(json). Narrow adapter
output with ParsedDocumentWithElementKinds<'text' | 'table'> when you know
which element kinds a converter may emit.
openparser@1
The canonical result is a document graph:
pagesdefine explicit coordinate spaces and reading order.elementspreserve text down to words/symbols plus tables, figures, formulas, key-values, query answers, selections, signatures, barcodes, links, sections, and provider-defined fallback elements.relationsretain hierarchy and semantic links without duplicating trees.text_annotationspreserve range-based languages and styles.assetsretain page and figure images by URI or base64 payload.- normalized confidence records retain their original value and scale and are
explicitly uncalibrated across providers. Page-level OCR aggregates use
pages[].confidence; image-quality scores/defects usepages[].quality.
text is plain reading-order text. Every span is a half-open UTF-16 code-unit
range into that string, so JavaScript consumers can use text.slice(start, end)
without provider-specific indexing logic. markdown is the canonical
best-effort rendering of the graph; the untouched provider response remains
available through the separate raw output format.
pages[].reading_order is an ordered subset of that page's element_ids and
contains top-level content, not both a parent and all of its descendants.
Word- and symbol-level elements are present only when the provider and requested
options return them. Relation directions are explicit: contains points from
parent to child, while caption_of and footnote_of point from the annotation
to its target.
Geometry always includes a bounding box and may additionally retain the native polygon.
All published object schemas are strict. Adding a field or otherwise changing a
shape in a way that an existing schema rejects requires a new output_format
revision; openparser@1 will not silently grow incompatible fields.
Table validation rejects overlapping cells and enforces a structural row-coverage limit during overlap checks.
