ConusAI vendor v0.1.0-dev.20261027+9b1131fb
ci / gate (push) Waiting to run

This commit is contained in:
ConusAI vendor v0.1.0-dev.20261027+9b1131fb
2026-10-27 18:05:17 +00:00
commit 3102273ec7
538 changed files with 80203 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
// The part of an OCR result this module reads, as a schema: what is kept as the OCR stage's cached
// artefact, so a file read once is not paid for twice. Words and polygons are not kept, and the
// SDK's own `OcrDocument` is assignable to the type this yields.
import { z } from "zod"
import { PAGE_CLASSES } from "../contract/index.js"
import type { ReadDocument } from "./ports.js"
const lineSchema = z.object({
text: z.string(),
bbox: z.tuple([z.number(), z.number(), z.number(), z.number()]),
confidence: z.number(),
order: z.number(),
repeated: z.boolean(),
})
const blockSchema = z.object({
id: z.string().min(1),
bbox: z.tuple([z.number(), z.number(), z.number(), z.number()]),
order: z.number(),
lines: z.array(z.number().int().min(0)),
})
const pageSchema = z.object({
index: z.number().int().min(0),
width: z.number(),
height: z.number(),
class: z.enum(PAGE_CLASSES),
source: z.enum(["ocr", "text_layer", "spreadsheet"]).optional(),
text: z.string(),
lines: z.array(lineSchema),
blocks: z.array(blockSchema),
})
export const readDocumentSchema: z.ZodType<ReadDocument> = z.object({
engine: z.object({ name: z.string(), version: z.string() }),
page_count: z.number().int().min(0),
pages: z.array(pageSchema),
})
/** What of a document is worth keeping: exactly the fields of `ReadDocument`, and no more. */
export const projectDocument = (document: ReadDocument): ReadDocument => readDocumentSchema.parse(document)