@adaptabletools/adaptable 18.1.0-canary.1 → 18.1.1

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.
@@ -1,5 +1,5 @@
1
1
  import { IRowNode } from '@ag-grid-community/core';
2
- import { AdaptableApi, BaseContext } from '../../../types';
2
+ import { BaseContext } from '../../../types';
3
3
  export type AST = AST_Expression[];
4
4
  export type PredicateType = 'VALUE_REF' | 'INFIX' | 'UNARY' | 'FUNCTION' | 'CONDITIONAL';
5
5
  /**
@@ -129,24 +129,23 @@ args: any[],
129
129
  */
130
130
  context: ExpressionContext) => any;
131
131
  export declare const isAST_Function: (node: AST_Expression) => node is AST_Function;
132
- export interface AggregatedScalarExpressionReducerContext extends BaseContext {
132
+ export interface AggregatedExpressionReducerContext extends BaseContext {
133
133
  /**
134
134
  * Current row node
135
135
  */
136
136
  rowNode: IRowNode;
137
137
  /**
138
- * Adaptable API
139
- */
140
- adaptableApi: AdaptableApi;
141
- /**
142
- * Arguments passed to the function
143
- * Column arguments are transformed to their values, e.g. [colId] -> args = [value-of-colId]
138
+ * Arguments passed to the function. Column arguments are transformed to their values, e.g. [colId] -> args = [value-of-colId]. Aggregation column and group by column are not included as they are passed as separate arguments.
144
139
  */
145
140
  args: any[];
146
141
  /**
147
142
  * Column Id of the column being aggregated
148
143
  */
149
144
  aggColumnId: string;
145
+ /**
146
+ * Column Id(s) of the column(s) being grouped by
147
+ */
148
+ groupByColumnIds?: string[];
150
149
  /**
151
150
  * Helper function to get the value of a column
152
151
  * @param colId column id
@@ -154,26 +153,53 @@ export interface AggregatedScalarExpressionReducerContext extends BaseContext {
154
153
  */
155
154
  getValueForColId: (colId: string) => any;
156
155
  }
157
- export interface AggregatedScalarExpressionProcessReducerValueContext extends BaseContext {
156
+ export interface AggregatedExpressionProcessReducerValueContext extends BaseContext {
158
157
  /**
159
- * Arguments passed to the function
158
+ * Arguments passed to the function. Aggregation column and group by column are not included as they are passed as separate arguments.
160
159
  */
161
160
  args: any[];
161
+ /**
162
+ * Column Id of the column being aggregated
163
+ */
164
+ aggColumnId: string;
165
+ /**
166
+ * Column Id(s) of the column(s) being grouped by
167
+ */
168
+ groupByColumnIds?: string[];
162
169
  }
163
- export interface AggregatedScalarExpressionPrepareRowValueContext extends BaseContext {
170
+ export interface AggregatedExpressionPrepareRowValueContext extends BaseContext {
164
171
  /**
165
- * Arguments passed to the function
172
+ * Arguments passed to the function. Column arguments are transformed to their values, e.g. [colId] -> args = [value-of-colId]. Aggregation column and group by column are not included as they are passed as separate arguments.
166
173
  */
167
174
  args: any[];
175
+ /**
176
+ * Column Id of the column being aggregated
177
+ */
168
178
  aggColumnId: string;
179
+ /**
180
+ * Column Id(s) of the column(s) being grouped by
181
+ */
182
+ groupByColumnIds?: string[];
183
+ /**
184
+ * Helper function to get the value of a column
185
+ * @param colId column id
186
+ */
169
187
  getValueForColId: (colId: string) => any;
170
188
  }
171
- export interface AggregatedScalarExpressionRowFilterContext extends BaseContext {
189
+ export interface AggregatedExpressionRowFilterContext extends BaseContext {
190
+ /**
191
+ * Arguments passed to the function. Column arguments are transformed to their values, e.g. [colId] -> args = [value-of-colId]. Aggregation column and group by column are not included as they are passed as separate arguments.
192
+ */
193
+ args: any[];
172
194
  /**
173
195
  * Column Id of the column being aggregated
174
196
  * Usualy the first Col argument, e.g. [colId]
175
197
  */
176
198
  aggColumnId: string;
199
+ /**
200
+ * Column Id(s) of the column(s) being grouped by
201
+ */
202
+ groupByColumnIds?: string[];
177
203
  /**
178
204
  * Utility function to get the value of a column
179
205
  * @param colId column id
@@ -181,7 +207,7 @@ export interface AggregatedScalarExpressionRowFilterContext extends BaseContext
181
207
  */
182
208
  getValueForColId: (colId: string) => any;
183
209
  }
184
- export interface AggregatedScalarExpressionFunction {
210
+ export interface AggregatedExpressionFunction {
185
211
  /**
186
212
  * Expression description.
187
213
  */
@@ -199,33 +225,33 @@ export interface AggregatedScalarExpressionFunction {
199
225
  */
200
226
  initialValue: any;
201
227
  /**
202
- * Reducer function which is called for each value in the Column Data.
228
+ * Reducer function which is called for each value(row) in the Column Data.
203
229
  * @param accumulator - the value returned by the previous call to the reducer function, or the initialValue if this is the first call. You return the new accumulator value from this function.
204
230
  * @param currentValue - the current value being processed in the Column Data
205
231
  * @param index - index of the current value in the Column Data
206
232
  * @param context - context object with the current row node, adaptableApi, aggColumnId and other possible custom arguments
207
233
  */
208
- reducer: (accumulator: any, currentValue: any, index: number, context: AggregatedScalarExpressionReducerContext) => any;
234
+ reducer: (accumulator: any, currentValue: any, index: number, context: AggregatedExpressionReducerContext) => any;
209
235
  /**
210
- * If specified, this function is called after the reducer has processed all values.
211
- * Can be used to change the result of the reducer based on the values array (e.g. average).
236
+ * If specified, this function is called after the reducer has processed all values (rows).
237
+ * Can be used to change the result of the reducer based on the values array (e.g. average = aggregated value / count).
212
238
  * @param aggregatedValue - result of the reducer
213
- * @param dataArray - array of values. If aggregation was grouped, this will be the array of values for the group.
239
+ * @param rowNodes - array of row nodes. If aggregation was grouped, this will be the array of row nodes for the group.
214
240
  * @param context - context object with the args
215
241
  */
216
- processReducerValue?: (aggregatedValue: any, dataArray: any[], context: AggregatedScalarExpressionProcessReducerValueContext) => number | string | Date;
242
+ processAggregatedValue?: (aggregatedValue: any, rowNodes: IRowNode[], context: AggregatedExpressionProcessReducerValueContext) => any;
217
243
  /**
218
- * If specified, this function is be called for each row.
219
- * This can be used when each row has a different value (e.g. percentage).
244
+ * If specified, this function is be called for each row AFTER the reducer() and processReducedValue() functions.
245
+ * This can be used when each row has a different aggregated value (e.g. percentage = row value / aggregated value).
220
246
  * @param rowNode - current row node
221
247
  * @param context - context object with the args, aggColumnId, getValueForColId
222
248
  * @returns return value for each individual row
223
249
  */
224
- prepareRowValue?: (rowNode: IRowNode, aggregatedValue: any, context: AggregatedScalarExpressionPrepareRowValueContext) => number | string | Date;
250
+ prepareRowValue?: (rowNode: IRowNode, aggregatedValue: any, context: AggregatedExpressionPrepareRowValueContext) => number | string | Date;
225
251
  /**
226
252
  * If specified, this function filters the rows that are included in the aggregation.
227
253
  * @param rowNode - current row node
228
254
  * @param context - context object with the aggColumnId, getValueForColId
229
255
  */
230
- rowFilter?: (rowNode: IRowNode, context: AggregatedScalarExpressionRowFilterContext) => boolean;
256
+ rowFilter?: (rowNode: IRowNode, context: AggregatedExpressionRowFilterContext) => boolean;
231
257
  }
package/src/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { ExpressionFunction, ExpressionFunctionDocBlock, ExpressionFunctionHandler, ExpressionContext, ExpressionFunctionMap, ExpressionCategory, ExpressionFunctionInputType, AggregatedScalarExpressionFunction, AggregatedScalarExpressionReducerContext, AST, AST_Function, AST_Expression, Token, } from './../src/parser/src/types';
1
+ export type { ExpressionFunction, ExpressionFunctionDocBlock, ExpressionFunctionHandler, ExpressionContext, ExpressionFunctionMap, ExpressionCategory, ExpressionFunctionInputType, AggregatedExpressionFunction, AggregatedExpressionReducerContext, AST, AST_Function, AST_Expression, Token, } from './../src/parser/src/types';
2
2
  export type { AgGridConfig } from './AdaptableInterfaces/IAdaptable';
3
3
  export type { AdaptableConfig } from './View/AdaptableWizardView/AdaptableConfigurationDialog/AdaptableConfig';
4
4
  export type { AdaptableNoCodeWizardOptions, IAdaptableNoCodeWizard, } from './AdaptableInterfaces/AdaptableNoCodeWizard';