import { PlainObject } from '@xh/hoist/core'; import { AggregationContext, Aggregator, AverageAggregator, AverageStrictAggregator, ChildCountAggregator, Field, FieldSpec, LeafCountAggregator, MaxAggregator, MinAggregator, NullAggregator, SingleAggregator, SumAggregator, SumStrictAggregator, UniqueAggregator } from '@xh/hoist/data'; export interface CubeFieldSpec extends FieldSpec { /** Instance of a Hoist Cube {@link Aggregator} or string token alias for one. */ aggregator?: Aggregator | AggregatorToken; /** Function to determine if aggregation should be performed at a given level of a query result. */ canAggregateFn?: CanAggregateFn; /** True if any further groupings below this dimension would be derivative (have only one member). */ isLeafDimension?: boolean; /** * Name of field that is a 'parent' dimension of this dimension. This marks this dimension as a * sub-dimension of the parent dimension (e.g. 'asset group' and 'asset'). This allows the view * to skip creating derivative nodes when a parent node has a single identical child node. */ parentDimension?: string; } /** Convenient (and serializable) alias for one of Hoist's Cube {@link Aggregator} classes. */ export type AggregatorToken = 'AVG' | 'AVG_STRICT' | 'CHILD_COUNT' | 'LEAF_COUNT' | 'MAX' | 'MIN' | 'NULL' | 'SINGLE' | 'SUM' | 'SUM_STRICT' | 'UNIQUE'; /** * @param dimension - dimension of aggregation * @param value - value of record on dimension * @param appliedDims - *all* applied dimension values for this record * @param context - current aggregation context */ export type CanAggregateFn = (dimension: string, value: any, appliedDims: PlainObject, context: AggregationContext) => boolean; /** * Metadata used to define a measure or dimension in Cube. For properties present on raw data source * objects to be included in a Cube, the Cube must be configured with a matching Field that tells * it to extract the data from the source objects and how to aggregate or filter on that data. * * @mcpHint field with aggregation metadata for use within a Cube */ export declare class CubeField extends Field { aggregator: Aggregator; canAggregateFn: CanAggregateFn; isLeafDimension: boolean; parentDimension: string; static averageAggregator: AverageAggregator; static averageStrictAggregator: AverageStrictAggregator; static childCountAggregator: ChildCountAggregator; static leafCountAggregator: LeafCountAggregator; static maxAggregator: MaxAggregator; static minAggregator: MinAggregator; static nullAggregator: NullAggregator; static singleAggregator: SingleAggregator; static sumAggregator: SumAggregator; static sumStrictAggregator: SumStrictAggregator; static uniqueAggregator: UniqueAggregator; constructor({ aggregator, canAggregateFn, isLeafDimension, parentDimension, ...fieldArgs }: CubeFieldSpec); private parseAggregator; }