/** * JSON schema for document generation (PDF, DOCX) */ export interface Document { defaults?: Defaults; document: DocumentClass; sections: Section[]; /** * Variables for text replacement. Use {{varName}} in text. Built-in: {{pageNumber}}, * {{totalPages}} */ variables?: { [key: string]: string }; } export interface Defaults { chart?: Chart; /** * Default text color in hex format */ color?: string; /** * Default font family */ fontFamily?: string; /** * Default font size in pt */ fontSize?: number; footer?: Footer; header?: HeaderObject; /** * Default line height multiplier */ lineHeight?: number; /** * Global spacing defaults in pt */ spacing?: Spacing; styles?: Styles; } export interface Chart { /** * Default border colors for chart datasets (hex colors, used in order and cycled). */ borderColors?: string[]; /** * Default fill colors for chart datasets (hex colors, used in order and cycled). */ colors?: string[]; } export interface Footer { /** * Override alignment for all footer content (overrides default left/center/right * positioning) */ align?: FooterAlign; /** * Center column content */ center?: HeaderFooterContent; /** * Exclude footer from first page */ excludeFirstPage?: boolean; /** * Left column content */ left?: HeaderFooterContent; /** * Right column content */ right?: HeaderFooterContent; [property: string]: any; } /** * Override alignment for all footer content (overrides default left/center/right * positioning) * * Image alignment within the column * * Text alignment within the column * * Override alignment for all header content (overrides default left/center/right * positioning) * * Header text alignment * * Row text alignment */ export type FooterAlign = "left" | "center" | "right"; /** * Center column content * * Left column content * * Right column content */ export type HeaderFooterContent = HeaderFooterContentClass | string; export interface HeaderFooterContentClass { /** * Array of text lines with individual styling */ content?: Content[]; /** * Text content type * * Image content type */ type: HeaderFooterContentType; /** * Image alignment within the column */ align?: FooterAlign; /** * Alternative text for accessibility */ alt?: string; /** * Image height in pixels (max 200 for headers/footers) */ height?: number; /** * Image file path (storage URL starting with /image/ or public HTTP/HTTPS URL) */ src?: string; /** * Image width in pixels (max 500 for headers/footers) */ width?: number; } export interface Content { /** * Text alignment within the column */ align?: FooterAlign; /** * Text color in hex format */ color?: string; /** * Font family for this line */ fontFamily?: string; /** * Font size in points */ fontSize?: number; /** * Font style */ fontStyle?: FontStyle; /** * Font weight */ fontWeight?: FontWeight; /** * Text line (supports {{variables}} and markdown) */ text: string; } /** * Font style * * Header font style * * Row font style */ export type FontStyle = "normal" | "italic"; /** * Font weight * * Header font weight * * Row font weight */ export type FontWeight = "normal" | "bold"; export type HeaderFooterContentType = "text" | "image"; export interface HeaderObject { /** * Override alignment for all header content (overrides default left/center/right * positioning) */ align?: FooterAlign; /** * Center column content */ center?: HeaderFooterContent; /** * Exclude header from first page */ excludeFirstPage?: boolean; /** * Left column content */ left?: HeaderFooterContent; /** * Right column content */ right?: HeaderFooterContent; [property: string]: any; } /** * Global spacing defaults in pt */ export interface Spacing { after?: After; before?: Before; } export interface After { chart?: number; code?: number; h1?: number; h2?: number; h3?: number; h4?: number; h5?: number; h6?: number; image?: number; list?: number; math?: number; qrcode?: number; table?: number; text?: number; text2?: number; } export interface Before { chart?: number; code?: number; h1?: number; h2?: number; h3?: number; h4?: number; h5?: number; h6?: number; image?: number; list?: number; math?: number; qrcode?: number; table?: number; text?: number; text2?: number; } export interface Styles { h1?: TextStyle; h2?: TextStyle; h3?: TextStyle; h4?: TextStyle; h5?: TextStyle; h6?: TextStyle; math?: TextStyle; table?: TableStyle; text2?: TextStyle; [property: string]: any; } export interface TextStyle { /** * Text alignment */ align?: H1Align; /** * Text color in hex format */ color?: string; /** * Font family name */ fontFamily?: string; /** * Font size in pt */ fontSize?: number; /** * Font weight */ fontWeight?: FontWeight; } /** * Text alignment * * Horizontal alignment of the math block * * Image alignment * * QR code alignment * * Chart alignment * * Code block alignment (for rendered images) */ export type H1Align = "left" | "center" | "right" | "justify"; export interface TableStyle { borders?: TableBorders; cellPadding?: TableCellPadding; header?: TableHeader; rows?: TableRows; } export interface TableBorders { inner?: PurpleInner; outer?: PurpleOuter; } export interface PurpleInner { /** * Border color in hex */ color?: string; /** * Border style */ style?: StyleEnum; /** * Border width in pt */ width?: number; } /** * Border style */ export type StyleEnum = "solid" | "dashed" | "dotted"; export interface PurpleOuter { /** * Border color in hex */ color?: string; /** * Border style */ style?: StyleEnum; /** * Border width in pt */ width?: number; } export interface TableCellPadding { /** * Cell padding bottom in pt */ bottom?: number; /** * Cell padding left in pt */ left?: number; /** * Cell padding right in pt */ right?: number; /** * Cell padding top in pt */ top?: number; } export interface TableHeader { /** * Header text alignment */ align?: FooterAlign; /** * Header background color in hex */ backgroundColor?: string; /** * Header text color in hex */ color?: string; /** * Header font size in pt */ fontSize?: number; /** * Header font style */ fontStyle?: FontStyle; /** * Header font weight */ fontWeight?: FontWeight; } export interface TableRows { /** * Row text alignment */ align?: FooterAlign; /** * Alternate row background color for striped tables */ alternateBackgroundColor?: string; /** * Row background color in hex */ backgroundColor?: string; /** * Row text color in hex */ color?: string; /** * Row font size in pt */ fontSize?: number; /** * Row font style */ fontStyle?: FontStyle; /** * Row font weight */ fontWeight?: FontWeight; } export interface DocumentClass { /** * Document author */ author?: string; /** * Output filename without extension */ filename?: string; /** * Document keywords */ keywords?: string[]; /** * Bottom margin in cm */ marginBottom?: number; /** * Left margin in cm */ marginLeft?: number; /** * Right margin in cm */ marginRight?: number; /** * Top margin in cm */ marginTop?: number; /** * Page orientation */ orientation?: Orientation; /** * Page size */ size?: Size; /** * Document subject */ subject?: string; /** * Document title */ title?: string; /** * Output document format */ type: DocumentType; } /** * Page orientation * * Page orientation after break */ export type Orientation = "portrait" | "landscape"; /** * Page size */ export type Size = "A4" | "A3" | "A5" | "Letter" | "Legal"; /** * Output document format */ export type DocumentType = "pdf" | "docx" | "odt"; /** * Styled single page with custom positioning * * Flowing content across multiple pages */ export interface Section { /** * Vertical alignment of page content */ align?: SectionAlign; /** * Page content elements * * Flow content elements */ content: Element[]; /** * Y position in cm (overrides align) */ startY?: number; type: SectionType; /** * Start this section on a new page (default: true) */ newPage?: boolean; } /** * Vertical alignment of page content */ export type SectionAlign = "top" | "center" | "bottom"; export interface Element { /** * Text alignment * * Horizontal alignment of the math block * * Image alignment * * QR code alignment * * Chart alignment * * Code block alignment (for rendered images) */ align?: H1Align; /** * Text color in hex format */ color?: string; /** * Font family for this specific element */ fontFamily?: string; /** * Font size in points */ fontSize?: number; /** * Font weight */ fontWeight?: FontWeight; spacing?: SpacingOverride; /** * Text with markdown: **bold**, *italic*, [link](url) */ text?: string; /** * Text element type * * Math element type (block-level LaTeX formula) * * Image element type * * Table element type * * List element type * * QR code element type * * Chart element type (rendered via internal Chart API) * * Code block element (optionally rendered via internal render API as image) * * Page break element type */ type: ElementType; /** * LaTeX formula string (e.g. E = mc^2) */ latex?: string; /** * Alternative text for accessibility */ alt?: string; /** * Image height in pixels * * Rendered chart image height in pixels */ height?: number; /** * Image file path (storage URL starting with /image/ or public HTTP/HTTPS URL) */ src?: string; /** * Image width in pixels * * Rendered chart image width in pixels * * Rendered code image width in pixels (when renderAsImage=true) */ width?: number; /** * Table caption */ caption?: string; /** * Table headers */ headers?: string[]; /** * Table data rows */ rows?: Array; style?: StyleClass; /** * List items */ items?: ListItem[]; /** * true = ordered (1,2,3), false = unordered (bullets) */ ordered?: boolean; /** * QR code data (structure depends on qrType) */ data?: { [key: string]: any }; /** * Error correction level: L (~7%), M (~15%), Q (~25%), H (~30%) */ errorCorrection?: ErrorCorrection; /** * Type of QR code: url (link), wifi (WiFi credentials), vcard (contact card) */ qrType?: QrType; /** * QR code size in pixels (width and height, always 1:1 ratio) */ size?: number; config?: ChartConfig; /** * Background color for rendered code image in hex format */ backgroundColor?: string; /** * Code content to render or display */ code?: string; /** * Programming language key for syntax highlighting (highlight.js language id) */ language?: string; /** * If true, the code block will be rendered as an image via the internal render API */ renderAsImage?: boolean; /** * Page orientation after break */ orientation?: Orientation; } export interface ChartConfig { /** * Canvas background color (CSS color string) */ backgroundColor?: string; data: Data; height?: number; /** * Chart.js options object */ options?: { [key: string]: any }; /** * Chart.js chart type */ type: ConfigType; width?: number; } export interface Data { datasets: Dataset[]; labels?: X[]; } export interface Dataset { data: Datum[]; label?: string; [property: string]: any; } export type Datum = Point | number | string; export interface Point { r?: number; x: X; y: X; } export type X = number | string; /** * Chart.js chart type */ export type ConfigType = "line" | "bar" | "pie" | "doughnut" | "radar" | "polarArea" | "scatter" | "bubble"; /** * Error correction level: L (~7%), M (~15%), Q (~25%), H (~30%) */ export type ErrorCorrection = "L" | "M" | "Q" | "H"; export interface ListItemClass { /** * Nested list items */ items?: ListItem[]; /** * Item text (supports markdown) */ text: string; } export type ListItem = ListItemClass | string; /** * Type of QR code: url (link), wifi (WiFi credentials), vcard (contact card) */ export type QrType = "url" | "wifi" | "vcard"; export interface SpacingOverride { /** * Spacing after element in pt */ after?: number; /** * Spacing before element in pt */ before?: number; } export interface StyleClass { borders?: StyleBorders; cellPadding?: StyleCellPadding; header?: StyleHeader; rows?: StyleRows; } export interface StyleBorders { inner?: FluffyInner; outer?: FluffyOuter; } export interface FluffyInner { /** * Border color in hex */ color?: string; /** * Border style */ style?: StyleEnum; /** * Border width in pt */ width?: number; } export interface FluffyOuter { /** * Border color in hex */ color?: string; /** * Border style */ style?: StyleEnum; /** * Border width in pt */ width?: number; } export interface StyleCellPadding { /** * Cell padding bottom in pt */ bottom?: number; /** * Cell padding left in pt */ left?: number; /** * Cell padding right in pt */ right?: number; /** * Cell padding top in pt */ top?: number; } export interface StyleHeader { /** * Header text alignment */ align?: FooterAlign; /** * Header background color in hex */ backgroundColor?: string; /** * Header text color in hex */ color?: string; /** * Header font size in pt */ fontSize?: number; /** * Header font style */ fontStyle?: FontStyle; /** * Header font weight */ fontWeight?: FontWeight; } export interface StyleRows { /** * Row text alignment */ align?: FooterAlign; /** * Alternate row background color for striped tables */ alternateBackgroundColor?: string; /** * Row background color in hex */ backgroundColor?: string; /** * Row text color in hex */ color?: string; /** * Row font size in pt */ fontSize?: number; /** * Row font style */ fontStyle?: FontStyle; /** * Row font weight */ fontWeight?: FontWeight; } /** * Text element type */ export type ElementType = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "text" | "text2" | "math" | "image" | "table" | "list" | "qrcode" | "chart" | "code" | "pageBreak"; export type SectionType = "page" | "flow";