@docexdev/protocol
v0.1.0
Published
Public types, constants, and helpers for the Docex document extraction protocol
Maintainers
Readme
@docexdev/protocol
Public types, constants, and helpers for the Docex document extraction protocol.
Install
npm install @docexdev/protocolUsage
import {
SUPPORTED_INPUT_FILE_TYPES,
SUPPORTED_OUTPUT_FORMATS,
PRICE_USD_PER_PAGE,
validateInputFileType,
validateOutputFormat,
createUsage,
createExtractionEnvelope,
} from "@docexdev/protocol";API
| Export | Description |
|---|---|
| PROTOCOL_VERSION | Current protocol version string |
| SUPPORTED_INPUT_FILE_TYPES | ["jpeg", "jpg", "png", "heic", "pdf"] |
| SUPPORTED_OUTPUT_FORMATS | ["json", "text"] |
| COST_USD_PER_PAGE | Raw cost per page |
| PRICE_USD_PER_PAGE | Billed price per page |
| validateInputFileType(fileName) | Validates and normalizes a file extension |
| validateOutputFormat(format) | Validates an output format string |
| createUsage({ pages }) | Builds a usage/billing object |
| calculateConfidence(found, expected) | Computes extraction confidence score |
| normalizeFlatObject(record) | Trims strings, coerces numbers and dates |
| createExtractionEnvelope(opts) | Wraps an extraction result in the standard envelope |
| formatTextResult(docType, record) | Formats a record as plain text |
License
MIT
