Schema

Schema Overview

Understand the top-level structure of a NextReport schema including page configuration, locale, and data sources.

Top-level structure

Every report starts with a schema object that describes the report’s metadata, page layout, and content bands:

{
  version: '1.0',        // Schema version
  type: 'report',        // Always "report" for now
  locale: 'en-US',       // Optional, affects formatting
  page: { ... },         // Page size, orientation, margins
  dataSource: 'invoice', // Optional label for the data context
  bands: [ ... ],        // Array of band definitions
}

Version

The version field identifies the schema version for forward compatibility. Currently, the only supported version is "1.0".

Type

The type field is always "report". Future versions may introduce other document types.

Locale

The optional locale field controls how built-in formatting functions behave. It accepts a BCP 47 language tag:

locale: 'en-US'  // US English (default)
locale: 'tr-TR'  // Turkish
locale: 'de-DE'  // German

When set, functions like formatCurrency, formatDate, and formatNumber automatically use the locale’s number separators, date patterns, and currency symbols.

Page configuration

The page object defines the physical page layout:

page: {
  size: 'A4',
  orientation: 'portrait',
  margins: { top: 20, right: 20, bottom: 20, left: 20 },
}

Supported page sizes

SizeWidth (mm)Height (mm)
A4210297
A3297420
Letter216279
Legal216356

Orientation

  • portrait (default) — height is the long dimension
  • landscape — width and height are swapped

Margins

All margin values are in millimeters. Each side can be set independently:

margins: {
  top: 30,
  right: 20,
  bottom: 30,
  left: 20,
}

Data source

The optional dataSource field is a label for the data context passed at render time. It is primarily used for documentation and tooling:

dataSource: 'invoice'

The actual data is passed as the second argument to renderReport(schema, data).

Bands

The bands array contains the report’s content sections. Each band has a type, a height, and an array of components. See the Bands reference for full details.

bands: [
  { type: 'header',  height: 80,  components: [...] },
  { type: 'detail',  height: 30,  dataBinding: 'items', components: [...] },
  { type: 'footer',  height: 50,  components: [...] },
]

Complete minimal example

{
  version: '1.0',
  type: 'report',
  page: {
    size: 'A4',
    orientation: 'portrait',
    margins: { top: 20, right: 20, bottom: 20, left: 20 },
  },
  bands: [
    {
      type: 'header',
      height: 40,
      components: [
        {
          type: 'text',
          position: { x: 0, y: 10, width: 200, height: 20 },
          content: 'Hello, NextReport!',
          fontSize: 18,
          fontWeight: 'bold',
        },
      ],
    },
  ],
}

Next steps

  • Bands — header, detail, footer, and planned band types
  • Components — text, table, and planned component types
  • Expressions — dynamic content with {{...}} syntax