@xh/hoist 80.0.0-SNAPSHOT.1768264663674 → 80.0.0-SNAPSHOT.1768323341476

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -20,6 +20,7 @@
20
20
  * Added new `AppMenuButton.renderWithUserProfile` prop as a built-in alternative to the default
21
21
  hamburger menu. Set to `true` to render the current user's initials instead or provide a function
22
22
  to render a custom element for the user.
23
+ * Added `AggregationContext` as an additional argument to `CubeField.canAggregateFn`.
23
24
 
24
25
  ### ⚙️ Typescript API Adjustments
25
26
 
@@ -1,5 +1,5 @@
1
1
  import { PlainObject } from '@xh/hoist/core';
2
- import { Aggregator, AverageAggregator, AverageStrictAggregator, ChildCountAggregator, Field, FieldSpec, LeafCountAggregator, MaxAggregator, MinAggregator, NullAggregator, SingleAggregator, SumAggregator, SumStrictAggregator, UniqueAggregator } from '@xh/hoist/data';
2
+ import { AggregationContext, Aggregator, AverageAggregator, AverageStrictAggregator, ChildCountAggregator, Field, FieldSpec, LeafCountAggregator, MaxAggregator, MinAggregator, NullAggregator, SingleAggregator, SumAggregator, SumStrictAggregator, UniqueAggregator } from '@xh/hoist/data';
3
3
  export interface CubeFieldSpec extends FieldSpec {
4
4
  /** True to allow this field to be used for grouping.*/
5
5
  isDimension?: boolean;
@@ -22,8 +22,9 @@ export type AggregatorToken = 'AVG' | 'AVG_STRICT' | 'CHILD_COUNT' | 'LEAF_COUNT
22
22
  * @param dimension - dimension of aggregation
23
23
  * @param value - value of record on dimension
24
24
  * @param appliedDims - *all* applied dimension values for this record
25
+ * @param context - current aggregation context
25
26
  */
26
- export type CanAggregateFn = (dimension: string, value: any, appliedDims: PlainObject) => boolean;
27
+ export type CanAggregateFn = (dimension: string, value: any, appliedDims: PlainObject, context: AggregationContext) => boolean;
27
28
  /**
28
29
  * Metadata used to define a measure or dimension in Cube. For properties present on raw data source
29
30
  * objects to be included in a Cube, the Cube must be configured with a matching Field that tells
@@ -10,6 +10,7 @@ export * from './filter/FieldFilter';
10
10
  export * from './filter/FunctionFilter';
11
11
  export * from './filter/Types';
12
12
  export * from './filter/Utils';
13
+ export * from './cube/aggregate/AggregationContext';
13
14
  export * from './cube/aggregate/Aggregator';
14
15
  export * from './cube/aggregate/AverageAggregator';
15
16
  export * from './cube/aggregate/AverageStrictAggregator';
@@ -7,6 +7,7 @@
7
7
 
8
8
  import {PlainObject} from '@xh/hoist/core';
9
9
  import {
10
+ AggregationContext,
10
11
  Aggregator,
11
12
  AverageAggregator,
12
13
  AverageStrictAggregator,
@@ -63,8 +64,14 @@ export type AggregatorToken =
63
64
  * @param dimension - dimension of aggregation
64
65
  * @param value - value of record on dimension
65
66
  * @param appliedDims - *all* applied dimension values for this record
67
+ * @param context - current aggregation context
66
68
  */
67
- export type CanAggregateFn = (dimension: string, value: any, appliedDims: PlainObject) => boolean;
69
+ export type CanAggregateFn = (
70
+ dimension: string,
71
+ value: any,
72
+ appliedDims: PlainObject,
73
+ context: AggregationContext
74
+ ) => boolean;
68
75
 
69
76
  /**
70
77
  * Metadata used to define a measure or dimension in Cube. For properties present on raw data source
@@ -152,11 +152,13 @@ export abstract class BaseRow {
152
152
  if (appliedDimensions.hasOwnProperty(name)) {
153
153
  ret[name] = false;
154
154
  } else {
155
- const {aggregator, canAggregateFn} = field;
155
+ const {aggregator, canAggregateFn} = field,
156
+ ctx = view._aggContext;
157
+
156
158
  ret[name] =
157
159
  aggregator &&
158
160
  (!canAggregateFn ||
159
- canAggregateFn(dimOrBucketName, val, appliedDimensions));
161
+ canAggregateFn(dimOrBucketName, val, appliedDimensions, ctx));
160
162
  }
161
163
  return ret;
162
164
  },
package/data/index.ts CHANGED
@@ -19,6 +19,7 @@ export * from './filter/FunctionFilter';
19
19
  export * from './filter/Types';
20
20
  export * from './filter/Utils';
21
21
 
22
+ export * from './cube/aggregate/AggregationContext';
22
23
  export * from './cube/aggregate/Aggregator';
23
24
  export * from './cube/aggregate/AverageAggregator';
24
25
  export * from './cube/aggregate/AverageStrictAggregator';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "80.0.0-SNAPSHOT.1768264663674",
3
+ "version": "80.0.0-SNAPSHOT.1768323341476",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",