Skip to main content
The extraction library, @bijectionhq/library-extraction, extracts typed fields from your app’s documents. An extraction({...}) instance is a subtree: its tables (tables.runs, tables.revisions), continuations and runs functions take their paths where you place it.
bijection/invoices.ts
A run reads its document (a t.file, or text) under the instance’s label, and its result, issues and every revision are stored there: a result is readable exactly where its document is. The method’s receiver must be cleared for the label. One instance holds one label.

Definitions and methods

  • definition({ name, revision, fields, instructions, questions? }) declares the fields as value types; a t.maybe field may be absent. questions gives queriesMethod a question per field. Its digest covers the declaration.
  • layoutMethod(ai, key) reads the document’s layout, tables and form fields through the instance’s reader, stores the analysis as a File at the label (tables.layouts, reused by later attempts over the same document), then asks a catalog language model with the structured capability over the layout as text. It suits scans, photos and long PDFs.
  • queriesMethod() asks the reader one question per field and keeps the most confident answers, read as each field’s type. No model is asked.
  • modelMethod(ai, key) uses a catalog language model with the structured capability, plus documents or images for files, sending the file inline (at most 10 MiB).
  • method({ name, to, args, decode, file? }) uses any target. The args callback builds the target arguments, and decode reads the answer into field values. With file: "reference", the callback receives the File at document.ref without reading its bytes.

The document reader

reader: { engine } places a document-analysis@1 slot at <instance>.reader, at the instance’s label. The protocol is engine-neutral: analyze takes the File by reference and answers the whole document normalized (pages, lines, words, layout blocks, tables, form fields, query answers, page-relative boxes), metered in pages. The engine is code: it is on the slot’s line in bijection.lock, and deploy refuses a provider that does not serve it. Who runs it is placement, in the installation’s bindings file: For placement.aws.account, set staging.bucket to the name of a dedicated S3 bucket with no versioning history. Grant the role s3:GetBucketVersioning on that bucket. The host gives a send at most ten seconds for processing and cleanup. Asynchronous analyses that exceed that window can leave the call with an unknown outcome. Document labels can require evidence for the provider’s region, tenancy, custody, or retention. Both managed and explicit bindings meet the same requirements. A standalone reader for other uses is documentReader({ label, engine }). Every answer is checked field by field. Conforming values are kept; a missing or non-conforming field becomes an issue { field, problem }. A method never writes a value its definition refuses. Operators start, retry and correct; readers (the operators by default) read.

Review

With review, every revision asks the Approvals app with the run’s subject, the revision’s digest and a requirement. The decision is recorded on the run when it is for the current revision and its digest matches: approved, rejected, or void (Withdrawn, Expired or any refusal). A correction asks again.
A protected instance lowers only the subject and digest, through review.release. The functions that ask declare that release.