export interface RowItem { label : string ; type : string ; } export interface Link { row : string ; column : RowItem ; } export interface MatrixModel { rows : string [ ] ; columns : RowItem [ ] ; links : Link [ ] ; } export function createMatrixModel ( rowsToRowItems ) { const rows = [ ] , columns = [ ] , links = [ ] ; rowsToRowItems . forEach ( ( rowItems , { label : row } ) => { rows . push ( row ) ; rowItems . forEach ( ( column ) => { if ( ! columns . some ( ( x ) => x . label == column . label ) ) { columns . push ( column ) ; } links . push ( { row , column } ) ; } ) ; } ) ; return { rows , columns , links } ; }