@codemation/core-nodes-ocr
v0.2.6
Published
Azure AI Content Understanding (OCR) plugin for Codemation — prebuilt document, invoice, and image analyzers.
Readme
@codemation/core-nodes-ocr
Azure AI Content Understanding OCR integration for Codemation. Exposes three prebuilt analyzer nodes for document, invoice, and image analysis — designed to make it trivial to wire up OCR-powered workflows.
Install
pnpm add @codemation/core-nodes-ocrNodes
analyzeInvoiceNode— runs theprebuilt-invoiceanalyzer; returns markdown + structured fields. Theprebuilt-invoiceID is verified against the Azure SDK.analyzeDocumentNode— runs theprebuilt-documentanalyzer by default; accepts a customanalyzerId. The default ID follows Azure's published naming conventions but is not verified against a live resource — pass your ownanalyzerIdif Azure returns "analyzer not found."analyzeImageNode— runs theprebuilt-imageAnalyzerby default; accepts a customanalyzerId. Same caveat asanalyzeDocumentNode.
All three nodes read their input from item.binary (default key: "data") and emit { content: string; fields: Record<string, unknown> } as the item payload. Binary bytes are never put in item.json.
Credential
Register an azureContentUnderstandingCredentialType credential with:
- Endpoint (public) — your Azure resource endpoint, e.g.
https://your-resource.cognitiveservices.azure.com/ - API key (secret)
Usage
import { analyzeInvoiceNode, azureContentUnderstandingCredentialType } from "@codemation/core-nodes-ocr";
// Wire up in your workflow:
workflow
// assume a binary PDF is attached as item.binary["data"]
.then(analyzeInvoiceNode.create({ binaryField: "data" }, "Extract invoice fields"));The output item's json will contain:
{
content: "# Invoice\n\n...", // markdown text from the analyzer
fields: { // structured fields (dates, amounts, line items, etc.)
VendorName: "Acme Corp",
InvoiceTotal: 1234.56,
// ...
}
}For custom analyzer IDs (e.g. a fine-tuned model), pass analyzerId:
analyzeDocumentNode.create({ analyzerId: "my-custom-model", binaryField: "doc" }, "Analyze contract");Output shape
All three nodes return the same OcrAnalysisOutput type:
type OcrAnalysisOutput = {
content: string; // markdown representation of the document
fields: Record<string, unknown>; // structured fields from the prebuilt model
};Multi-page results are merged into a single content string; the fields property reflects the primary or first content segment unless the analyzer returns multiple segments (in which case a segments array is included).
