import { Bucket , BucketType , CategoryMeasureBucket , CategorySegmentsHolder , EnumMeasureBucket , MeasureBucket , NumericSegmentsHolder , NumericValueBucket , NumericValueMeasureBucket , RangeBucketValueIncluding } from './bucket-types' ; import { MeasureMethod } from './indicator-types' ; import { QueryBucket } from './query-bucket-types' ; export const isNumericValueBucket = ( bucket ) : bucket is NumericValueBucket => { return bucket . type === BucketType . VALUE ; } ; export const isNumericValueMeasureBucket = ( bucket ) : bucket is NumericValueMeasureBucket => { return bucket . type === BucketType . VALUE_MEASURE ; } ; export const isCategoryMeasureBucket = ( bucket ) : bucket is CategoryMeasureBucket => { return bucket . type === BucketType . CATEGORY_MEASURE ; } ; export const isEnumMeasureBucket = ( bucket ) : bucket is EnumMeasureBucket => { return bucket . type === BucketType . ENUM_MEASURE ; } ; export const isMeasureBucket = ( bucket ) : bucket is MeasureBucket => { return isNumericValueMeasureBucket ( bucket ) || isCategoryMeasureBucket ( bucket ) || isEnumMeasureBucket ( bucket ) ; } ; export const isNumericSegmentsHolder = ( bucket ) : bucket is NumericSegmentsHolder => { return isNumericValueBucket ( bucket ) || isNumericValueMeasureBucket ( bucket ) ; } ; export const isCategorySegmentsHolder = ( bucket ) : bucket is CategorySegmentsHolder => { return isCategoryMeasureBucket ( bucket ) || isEnumMeasureBucket ( bucket ) ; } ; export const defendNumericValueSegmentsHolder = ( holder ) => { holder . include = holder . include ?? RangeBucketValueIncluding . INCLUDE_MIN ; holder . segments = [ { name : '' , value : { max : '0' } } , { name : '' , value : { min : '0' } } ] ; } ; export const defendNumericValueMeasureBucket = ( bucket ) => { delete bucket . measure ; defendNumericValueSegmentsHolder ( bucket ) ; } ; export const defendCategoryMeasureBucket = ( bucket ) => { delete bucket . measure ; bucket . segments = [ ] ; } ; export const defendEnumMeasureBucket = ( bucket ) => { bucket . measure = MeasureMethod . ENUM ; bucket . segments = [ ] ; } ;