export interface DocumentTemplate {
  pageConfig?: any;
  styles?: any;
  content: (TableSection | TextSection)[];
}

type SectionType = 'table' | 'text' | 'image';

export interface Section {
  type: SectionType;
  data?: any;
  asyncData?: SectionAsyncData;
  margin?: number[];
}

export interface TextSection extends Section {
  type: 'text';
  content: string;
  justify?: Position;
  fontSize?: number;
  bold?: boolean;
  italic?: boolean;
  underline?: boolean;
  color?: string;
}

export interface ImageSection {
  type: 'image';
  url: string;
  size: number;
  align?: Position;
}

export interface TableSection extends Section {
  type: 'table';
  columns: Column[];
  data?: Collection[];
}

export interface SectionAsyncData {
  queryUrl: string;
  queryParams?: Record<string, any>;
  formatFn?: string; // (data: any) => any;
}

export interface Column {
  header: string;
  key: string;
  align?: Position;
  width?: number | 'auto';
  formatFn?: string; // (val: any) => string;
}

export type Position = 'left' | 'center' | 'right';
export type Collection = Record<string, any>[];
