Cellv0.2.5
Document Extraction

Applying Results

Map raw extraction output to structured, persistence-ready fields

The extraction pipeline returns raw JSON from the AI model. The applyExtracted and applyExtractedQuote functions normalize this into clean, typed fields ready for persistence.

Policies

import { extractFromPdf, applyExtracted } from "@claritylabs-inc/cell";

const { extracted } = await extractFromPdf(pdfBase64);
const fields = applyExtracted(extracted);

Output fields

FieldTypeDescription
carrierstringInsurance carrier name
securitystring?Security/surplus lines carrier
underwriterstring?Underwriter name
mgastring?Managing General Agent
brokerstring?Broker name
policyNumberstringPolicy number
policyTypesstring[]Types (e.g., ["General Liability"])
documentType"policy" | "quote"Document type
policyYearnumberPolicy year
effectiveDatestringPolicy effective date
expirationDatestringPolicy expiration date
isRenewalbooleanWhether this is a renewal
coveragesCoverage[]Coverage details with limits
premiumstring?Total premium
insuredNamestringName of the insured
summarystring?AI-generated summary
metadataSourceobject?Raw metadata from pass 1
documentobject?Sections and supplementary data from pass 2-3
extractionStatus"complete"Always "complete"
extractionError""Always empty string

Quotes

import { extractQuoteFromPdf, applyExtractedQuote } from "@claritylabs-inc/cell";

const { extracted } = await extractQuoteFromPdf(pdfBase64);
const fields = applyExtractedQuote(extracted);

Additional quote fields

FieldTypeDescription
quoteNumberstringQuote number
quoteYearnumberQuote year
proposedEffectiveDatestring?Proposed effective date
proposedExpirationDatestring?Proposed expiration date
quoteExpirationDatestring?When the quote expires
premiumBreakdownPremiumLine[]?Line-by-line premium
subjectivitiesSubjectivity[]?Binding conditions
underwritingConditionsUnderwritingCondition[]?Carrier requirements

Quote coverages use proposedLimit and proposedDeductible instead of limit and deductible.

Null handling

Both functions use sanitizeNulls internally to convert null values to undefined. This is required for frameworks like Convex that reject null for optional fields. All coverages, metadata sources, and document sections are sanitized recursively.

On this page