@adaptabletools/adaptable 18.1.0 → 18.1.2

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,103 +129,148 @@ 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 AggregatedExpressionFunction {
133
133
  /**
134
- * Current row node
134
+ * Expression description
135
135
  */
136
- rowNode: IRowNode;
136
+ description?: string;
137
+ /**
138
+ * Example Signatures for the function
139
+ */
140
+ signatures?: string[];
141
+ /**
142
+ * Examples how the function can be used
143
+ */
144
+ examples?: string[];
145
+ /**
146
+ * Mandaatory Initial Value for the aggregation
147
+ */
148
+ initialValue: any;
149
+ /**
150
+ * Mandatory Reducer function which is called for each value(row) in the Column Data
151
+ */
152
+ reducer: (context: AggregatedExpressionReducerContext) => any;
153
+ /**
154
+ * Called AFTER the reducer() has processed all values / rows
155
+ * Can be used to change result of reducer based on the values array (e.g. average = aggregated value / count)
156
+ */
157
+ processAggregatedValue?: (context: AggregatedExpressionProcessAggregatedValueContext) => any;
158
+ /**
159
+ * Called for each row AFTER the reducer() and processAggregatedValue() functions
160
+ * Can be used when each row has a different aggregated value (e.g. percentage = row value / aggregated value).
161
+ * Returns return value for each individual row
162
+ */
163
+ prepareRowValue?: (context: AggregatedExpressionPrepareRowValueContext) => number | string | Date | undefined;
137
164
  /**
138
- * Adaptable API
165
+ * Optional filter which is applied to each row before the reducer is called. If the filter returns false, the row is NOT included in the aggregation.
139
166
  */
140
- adaptableApi: AdaptableApi;
167
+ filterRow?: (context: AggregatedExpressionFilteRowContext) => boolean;
168
+ }
169
+ export interface AggregatedExpressionReducerContext extends BaseContext {
141
170
  /**
142
- * Arguments passed to the function
143
- * Column arguments are transformed to their values, e.g. [colId] -> args = [value-of-colId]
171
+ * 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.
172
+ */
173
+ accumulator: any;
174
+ /**
175
+ * Current value being processed in the Column Data
176
+ */
177
+ currentValue: any;
178
+ /**
179
+ * Index of the current value in the Column Data
180
+ */
181
+ index: number;
182
+ /**
183
+ * Current row node
184
+ */
185
+ rowNode: IRowNode;
186
+ /**
187
+ * 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
188
  */
145
189
  args: any[];
146
190
  /**
147
191
  * Column Id of the column being aggregated
148
192
  */
149
193
  aggColumnId: string;
194
+ /**
195
+ * Column Id(s) of the column(s) being grouped by
196
+ */
197
+ groupByColumnIds?: string[];
150
198
  /**
151
199
  * Helper function to get the value of a column
152
200
  * @param colId column id
153
- * @returns
154
201
  */
155
202
  getValueForColId: (colId: string) => any;
156
203
  }
157
- export interface AggregatedScalarExpressionProcessReducerValueContext extends BaseContext {
204
+ export interface AggregatedExpressionProcessAggregatedValueContext extends BaseContext {
158
205
  /**
159
- * Arguments passed to the function
206
+ * Result of the reducer
160
207
  */
161
- args: any[];
162
- }
163
- export interface AggregatedScalarExpressionPrepareRowValueContext extends BaseContext {
208
+ aggregatedValue: any;
164
209
  /**
165
- * Arguments passed to the function
210
+ * Array of row nodes; if aggregation is grouped, this will be the array of row nodes for the group
211
+ */
212
+ rowNodes: IRowNode[];
213
+ /**
214
+ * Arguments passed to the function. Aggregation column and group by column are not included as they are passed as separate arguments.
166
215
  */
167
216
  args: any[];
168
- aggColumnId: string;
169
- getValueForColId: (colId: string) => any;
170
- }
171
- export interface AggregatedScalarExpressionRowFilterContext extends BaseContext {
172
217
  /**
173
218
  * Column Id of the column being aggregated
174
- * Usualy the first Col argument, e.g. [colId]
175
219
  */
176
220
  aggColumnId: string;
177
221
  /**
178
- * Utility function to get the value of a column
179
- * @param colId column id
180
- * @returns
222
+ * Column Id(s) of the column(s) being grouped by
181
223
  */
182
- getValueForColId: (colId: string) => any;
224
+ groupByColumnIds?: string[];
183
225
  }
184
- export interface AggregatedScalarExpressionFunction {
226
+ export interface AggregatedExpressionPrepareRowValueContext extends BaseContext {
185
227
  /**
186
- * Expression description.
228
+ * Current Row Node
187
229
  */
188
- description?: string;
230
+ rowNode: IRowNode;
189
231
  /**
190
- * Examples how this function ca be used.
232
+ * Result of the reducer
191
233
  */
192
- signatures?: string[];
234
+ aggregatedValue: any;
193
235
  /**
194
- * How the function can be used.
236
+ * 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.
195
237
  */
196
- examples?: string[];
238
+ args: any[];
197
239
  /**
198
- * Initial Value for the aggregation
240
+ * Column Id of the column being aggregated
199
241
  */
200
- initialValue: any;
242
+ aggColumnId: string;
201
243
  /**
202
- * Reducer function which is called for each value in the Column Data.
203
- * @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
- * @param currentValue - the current value being processed in the Column Data
205
- * @param index - index of the current value in the Column Data
206
- * @param context - context object with the current row node, adaptableApi, aggColumnId and other possible custom arguments
244
+ * Column Id(s) of the column(s) being grouped by
207
245
  */
208
- reducer: (accumulator: any, currentValue: any, index: number, context: AggregatedScalarExpressionReducerContext) => any;
246
+ groupByColumnIds?: string[];
209
247
  /**
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).
212
- * @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.
214
- * @param context - context object with the args
248
+ * Helper function to get the value of a column
249
+ * @param colId column id
215
250
  */
216
- processReducerValue?: (aggregatedValue: any, dataArray: any[], context: AggregatedScalarExpressionProcessReducerValueContext) => number | string | Date;
251
+ getValueForColId: (colId: string) => any;
252
+ }
253
+ export interface AggregatedExpressionFilteRowContext extends BaseContext {
254
+ /**
255
+ * Current row node
256
+ */
257
+ rowNode: IRowNode;
258
+ /**
259
+ * 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.
260
+ */
261
+ args: any[];
262
+ /**
263
+ * Column Id of the column being aggregated
264
+ * Usually the first Col argument, e.g. [colId]
265
+ */
266
+ aggColumnId: string;
217
267
  /**
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).
220
- * @param rowNode - current row node
221
- * @param context - context object with the args, aggColumnId, getValueForColId
222
- * @returns return value for each individual row
268
+ * Column Id(s) of the column(s) being grouped by
223
269
  */
224
- prepareRowValue?: (rowNode: IRowNode, aggregatedValue: any, context: AggregatedScalarExpressionPrepareRowValueContext) => number | string | Date;
270
+ groupByColumnIds?: string[];
225
271
  /**
226
- * If specified, this function filters the rows that are included in the aggregation.
227
- * @param rowNode - current row node
228
- * @param context - context object with the aggColumnId, getValueForColId
272
+ * Utility function to get the value of a column
273
+ * @param colId column id
229
274
  */
230
- rowFilter?: (rowNode: IRowNode, context: AggregatedScalarExpressionRowFilterContext) => boolean;
275
+ getValueForColId: (colId: string) => any;
231
276
  }
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, AggregatedExpressionProcessAggregatedValueContext, AggregatedExpressionPrepareRowValueContext, AggregatedExpressionFilteRowContext, 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';