Skip to main content
The @doclo/schemas package includes pre-built schemas for common document types that you can use directly or extend.

Installation

pnpm add @doclo/schemas

Available Schemas

Bunker Delivery Note (BDN)

The BDN schema extracts comprehensive data from maritime fuel delivery notes.
import { bdnSchema, BDNData } from '@doclo/schemas';
import { createFlow, extract } from '@doclo/flows';

const flow = createFlow()
  .step('extract', extract<BDNData>({
    provider: vlmProvider,
    schema: bdnSchema
  }))
  .build();

const result = await flow.run({ base64: bdnDocument });
// result.output is typed as BDNData

BDN Schema Fields

SectionFields
ReferencerefNumber
SuppliersupplierName, supplierLegalName, supplierLicenseNumber, supplierAddress, supplierPhoneNumber1, supplierEmail1
VesselsreceivingVessel.vesselName, receivingVessel.imoNumber, deliveringBarge.bargeName
BunkeringdeliveredQuantityMT, deliveryDate, port, anchorage
ProductproductName, productGrade, sulphurContent

Using BDN Schema from Registry

import { getSchemaByRef } from '@doclo/schemas';

const schema = getSchemaByRef('bdn@1.0.0');

const flow = createFlow()
  .step('extract', extract({
    provider: vlmProvider,
    schema: { ref: 'bdn@1.0.0' }  // Reference by ID
  }))
  .build();

Schema Registry

Built-in schemas are automatically registered when you import @doclo/schemas. Access them using the registry functions:
import {
  getSchema,
  getSchemaByRef,
  getLatestSchema,
  SCHEMA_REGISTRY
} from '@doclo/schemas';

// Get specific version
const v1 = getSchemaByRef('bdn@1.0.0');

// Get latest version of a schema
const latest = getLatestSchema('bdn');

// Check available schemas
console.log(SCHEMA_REGISTRY.listSchemas());

Extending Built-in Schemas

Add custom fields to built-in schemas:
import { bdnSchema } from '@doclo/schemas';

const extendedBdnSchema = {
  ...bdnSchema,
  properties: {
    ...bdnSchema.properties,
    customField: {
      type: 'string',
      description: 'My custom field'
    }
  }
};

Creating Custom Schemas

See Defining Schemas for how to create your own schemas for document types like invoices, receipts, contracts, and more.

Next Steps