import { CidrMask } from '../lib/cidr_mask' ; import { IBucketAggConfig } from '../bucket_agg_type' ; import { IpRangeKey } from '../lib/ip_range' ; import { buildRangeFilter , RangeFilterParams } from '../../../../../common' ; export const createFilterIpRange = ( aggConfig , key ) => { let range ; if ( key . type === 'mask' ) { range = new CidrMask ( key . mask ) . getRange ( ) ; } else { range = { from : key . from ? key . from : - Infinity , to : key . to ? key . to : Infinity , } ; } return buildRangeFilter ( aggConfig . params . field , { gte : range . from , lte : range . to } , aggConfig . getIndexPattern ( ) ) ; } ;