import { ITableProperties } from '@cassandratypes/cassandra' ; import { flatten , unflatten } from 'flat' ; import { has , pickBy } from 'lodash' ; returns export function mergeTableProperties ( object , advancedProps , simpleProps , useAdvanced ) { const defaultData = flatten < ITableProperties , any > ( useAdvanced ? advancedProps : simpleProps ) ; const includedValues = pickBy ( flatten ( object ) , ( _value , propPath ) => propPath . split ( '.' ) . reduce ( ( prev , curr , index ) => { if ( prev . length === 0 ) { prev . push ( curr ) ; } else { prev . push ( `${ prev [ index - 1 ] }.${ curr }` ) ; } return prev ; } , new Array < string > ( ) ) . some ( ( segment ) => has ( defaultData , segment ) ) ) ; const result = { ... defaultData , ... includedValues } ; return unflatten ( result ) ; } const defaultProperties = { comment : '' , compaction : { } as any , compression : { class : 'LZ4Compressor' , chunk_length_kb : 16 , } , speculativeRetry : '99percentile' , defaultTtl : 0 , } ; export function getDefaultTableProperties ( ) { return JSON . parse ( JSON . stringify ( defaultProperties ) ) ; }