/** * JSON schema for generating documents from templates by replacing variables */ export interface Template { /** * Optional output settings to override template defaults */ output?: Output; /** * ID of the template to use (original format) */ templateId?: string; /** * MinIO path to template file (processed format) */ templatePath?: string; /** * Variables to replace in the template. Use {{varName}} in template. Supports strings, * images, tables, and lists. */ variables?: { [key: string]: VariableValue }; } /** * Optional output settings to override template defaults */ export interface Output { /** * Override the output filename */ filename?: string; /** * Output document format */ type?: OutputType; } /** * Output document format */ export type OutputType = "docx" | "pdf"; export type VariableValue = VariableClass | string; /** * Image to replace placeholder * * Table data to populate template table rows * * List items to insert at placeholder position * * QR code to generate and insert at placeholder position */ export interface VariableClass { /** * Alternative text for accessibility */ alt?: string; /** * Image height in pixels */ height?: number; /** * Image file path (storage URL starting with /image/ or public HTTP/HTTPS URL) */ src?: string; /** * Image replacement * * Dynamic table data * * List of items * * QR code to generate and insert */ type: VariableType; /** * Image width in pixels */ width?: number; /** * Array of row objects with properties matching template column placeholders * * QR code data (structure depends on qrType) */ data?: Data; /** * List items to insert */ items?: string[]; /** * 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; } export type Data = { [key: string]: any }[] | { [key: string]: any }; /** * Error correction level: L (~7%), M (~15%), Q (~25%), H (~30%) */ export type ErrorCorrection = "L" | "M" | "Q" | "H"; /** * Type of QR code: url (link), wifi (WiFi credentials), vcard (contact card) */ export type QrType = "url" | "wifi" | "vcard"; export type VariableType = "image" | "table" | "list" | "qrcode";