@adaptabletools/adaptable 12.1.6 → 12.1.8-canary.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.
Files changed (203) hide show
  1. package/base.css +11 -49
  2. package/bundle.cjs.js +106 -106
  3. package/index.css +13 -60
  4. package/package.json +1 -1
  5. package/publishTimestamp.d.ts +1 -1
  6. package/publishTimestamp.js +1 -1
  7. package/src/AdaptableInterfaces/IAdaptable.d.ts +2 -0
  8. package/src/AdaptableOptions/ColumnOptions.d.ts +2 -4
  9. package/src/AdaptableOptions/FilterOptions.d.ts +12 -0
  10. package/src/AdaptableOptions/FinancePluginOptions.d.ts +22 -1
  11. package/src/AdaptableOptions/StateOptions.d.ts +25 -12
  12. package/src/Api/ColumnApi.d.ts +5 -0
  13. package/src/Api/ExportApi.d.ts +5 -0
  14. package/src/Api/FilterApi.d.ts +23 -0
  15. package/src/Api/FlashingCellApi.d.ts +8 -0
  16. package/src/Api/GridApi.d.ts +1 -0
  17. package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -0
  18. package/src/Api/Implementation/ColumnApiImpl.js +5 -1
  19. package/src/Api/Implementation/ExportApiImpl.d.ts +3 -1
  20. package/src/Api/Implementation/ExportApiImpl.js +19 -3
  21. package/src/Api/Implementation/FilterApiImpl.d.ts +5 -0
  22. package/src/Api/Implementation/FilterApiImpl.js +35 -3
  23. package/src/Api/Implementation/FlashingCellApiImpl.d.ts +1 -0
  24. package/src/Api/Implementation/FlashingCellApiImpl.js +4 -0
  25. package/src/Api/Implementation/GridApiImpl.d.ts +1 -0
  26. package/src/Api/Implementation/InternalApiImpl.d.ts +0 -1
  27. package/src/Api/Implementation/InternalApiImpl.js +0 -3
  28. package/src/Api/Implementation/PredicateApiImpl.js +4 -0
  29. package/src/Api/Implementation/QueryLanguageApiImpl.js +9 -1
  30. package/src/Api/InternalApi.d.ts +0 -1
  31. package/src/Api/SystemStatusApi.d.ts +1 -1
  32. package/src/Api/ToolPanelApi.d.ts +1 -1
  33. package/src/PredefinedConfig/CalculatedColumnState.d.ts +2 -2
  34. package/src/PredefinedConfig/Common/AdaptablePredicate.js +30 -10
  35. package/src/PredefinedConfig/Common/AdaptableQuery.js +1 -1
  36. package/src/PredefinedConfig/Common/AggregationColumns.d.ts +6 -0
  37. package/src/PredefinedConfig/Common/AggregationColumns.js +4 -0
  38. package/src/PredefinedConfig/Common/ColumnFilter.d.ts +2 -2
  39. package/src/PredefinedConfig/Common/Enums.d.ts +0 -15
  40. package/src/PredefinedConfig/Common/Enums.js +1 -18
  41. package/src/PredefinedConfig/Common/SpecialColumnSettings.d.ts +6 -6
  42. package/src/PredefinedConfig/ExportState.d.ts +12 -4
  43. package/src/PredefinedConfig/LayoutState.d.ts +2 -1
  44. package/src/PredefinedConfig/PopupState.d.ts +1 -2
  45. package/src/Redux/ActionsReducers/AlertRedux.d.ts +1 -1
  46. package/src/Redux/ActionsReducers/AlertRedux.js +1 -1
  47. package/src/Redux/ActionsReducers/ConditionalStyleRedux.d.ts +1 -1
  48. package/src/Redux/ActionsReducers/ConditionalStyleRedux.js +1 -1
  49. package/src/Redux/ActionsReducers/CustomSortRedux.d.ts +1 -1
  50. package/src/Redux/ActionsReducers/CustomSortRedux.js +1 -1
  51. package/src/Redux/ActionsReducers/FlashingCellRedux.d.ts +1 -1
  52. package/src/Redux/ActionsReducers/FlashingCellRedux.js +1 -1
  53. package/src/Redux/ActionsReducers/FormatColumnRedux.d.ts +1 -1
  54. package/src/Redux/ActionsReducers/FormatColumnRedux.js +1 -1
  55. package/src/Redux/ActionsReducers/LayoutRedux.d.ts +28 -0
  56. package/src/Redux/ActionsReducers/LayoutRedux.js +80 -2
  57. package/src/Redux/ActionsReducers/PlusMinusRedux.d.ts +1 -1
  58. package/src/Redux/ActionsReducers/PlusMinusRedux.js +1 -1
  59. package/src/Redux/ActionsReducers/PopupRedux.d.ts +0 -2
  60. package/src/Redux/ActionsReducers/PopupRedux.js +1 -28
  61. package/src/Redux/ActionsReducers/ScheduleRedux.d.ts +5 -5
  62. package/src/Redux/ActionsReducers/ScheduleRedux.js +5 -5
  63. package/src/Redux/ActionsReducers/ShortcutRedux.d.ts +1 -1
  64. package/src/Redux/ActionsReducers/ShortcutRedux.js +1 -1
  65. package/src/Redux/ActionsReducers/SystemRedux.d.ts +1 -2
  66. package/src/Redux/ActionsReducers/SystemRedux.js +1 -2
  67. package/src/Redux/Store/AdaptableStore.js +20 -6
  68. package/src/Strategy/AlertModule.d.ts +1 -0
  69. package/src/Strategy/AlertModule.js +20 -0
  70. package/src/Strategy/CalculatedColumnModule.js +2 -2
  71. package/src/Strategy/ExportModule.d.ts +0 -1
  72. package/src/Strategy/ExportModule.js +0 -16
  73. package/src/Strategy/FilterModule.js +6 -0
  74. package/src/Strategy/FlashingCellModule.js +2 -2
  75. package/src/Strategy/Interface/IModule.d.ts +4 -0
  76. package/src/Strategy/LayoutModule.js +20 -20
  77. package/src/Strategy/Utilities/FormatColumn/getFormatColumnStyleViewItems.js +16 -1
  78. package/src/Strategy/Utilities/Layout/getLayoutFilterViewItems.js +15 -11
  79. package/src/Utilities/Constants/DocumentationLinkConstants.d.ts +1 -0
  80. package/src/Utilities/Constants/DocumentationLinkConstants.js +2 -1
  81. package/src/Utilities/Defaults/DefaultAdaptableOptions.js +2 -0
  82. package/src/Utilities/ExpressionFunctions/aggregatedBooleanExpressionFunctions.d.ts +12 -2
  83. package/src/Utilities/ExpressionFunctions/aggregatedBooleanExpressionFunctions.js +30 -66
  84. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +22 -6
  85. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +423 -220
  86. package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.d.ts +7 -1
  87. package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.js +23 -7
  88. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.d.ts +0 -1
  89. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.js +6 -54
  90. package/src/Utilities/ExpressionFunctions/scalarExpressionFunctions.js +17 -5
  91. package/src/Utilities/Helpers/CalendarHelper.js +10 -7
  92. package/src/Utilities/Helpers/DateHelper.d.ts +0 -26
  93. package/src/Utilities/Helpers/DateHelper.js +2 -32
  94. package/src/Utilities/Interface/MessagePopups.d.ts +0 -4
  95. package/src/Utilities/ObjectFactory.d.ts +6 -4
  96. package/src/Utilities/ObjectFactory.js +30 -17
  97. package/src/Utilities/Services/AggregatedScalarLiveValue.d.ts +25 -0
  98. package/src/Utilities/Services/AggregatedScalarLiveValue.js +103 -0
  99. package/src/Utilities/Services/AlertService.d.ts +0 -1
  100. package/src/Utilities/Services/AlertService.js +5 -17
  101. package/src/Utilities/Services/CalculatedColumnExpressionService.d.ts +4 -4
  102. package/src/Utilities/Services/CalculatedColumnExpressionService.js +29 -154
  103. package/src/Utilities/Services/Interface/ICalculatedColumnExpressionService.d.ts +2 -2
  104. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +6 -3
  105. package/src/Utilities/Services/QueryLanguageService.d.ts +6 -3
  106. package/src/Utilities/Services/QueryLanguageService.js +23 -6
  107. package/src/Utilities/Services/ReportService.js +47 -46
  108. package/src/View/AdaptableView.js +1 -2
  109. package/src/View/CalculatedColumn/Utilities/getCalculatedColumnSettingsTags.d.ts +2 -0
  110. package/src/View/CalculatedColumn/Utilities/{getCalculatedColumnSettingTags.js → getCalculatedColumnSettingsTags.js} +5 -3
  111. package/src/View/CalculatedColumn/Wizard/CalculatedColumnDefinitionWizardSection.d.ts +10 -0
  112. package/src/View/CalculatedColumn/Wizard/CalculatedColumnDefinitionWizardSection.js +80 -0
  113. package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +21 -15
  114. package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.d.ts +1 -2
  115. package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.js +10 -53
  116. package/src/View/CalculatedColumn/Wizard/CalculatedColumnWizard.js +14 -3
  117. package/src/View/Components/AdaptableDateInput/index.js +1 -1
  118. package/src/View/Components/AdaptableObjectList/AdaptableObjectCompactList.js +42 -6
  119. package/src/View/Components/AdaptableObjectList/AdaptableObjectList.js +1 -1
  120. package/src/View/Components/EntityRulesEditor/index.js +26 -5
  121. package/src/View/Components/FilterForm/FilterForm.js +8 -4
  122. package/src/View/Components/FilterForm/ListBoxFilterForm.js +1 -0
  123. package/src/View/Components/FilterForm/QuickFilterForm.js +10 -6
  124. package/src/View/Components/PermittedValuesSelector/PermitedValuesSelector.d.ts +9 -0
  125. package/src/View/Components/PermittedValuesSelector/PermitedValuesSelector.js +28 -0
  126. package/src/View/Components/PermittedValuesSelector/index.d.ts +1 -0
  127. package/src/View/Components/PermittedValuesSelector/index.js +5 -0
  128. package/src/View/Components/Popups/AdaptablePopup/Navigation.js +2 -2
  129. package/src/View/Components/Popups/AdaptableToaster.js +2 -7
  130. package/src/View/Components/Popups/WindowPopups/windowFactory.d.ts +0 -1
  131. package/src/View/Components/Popups/WindowPopups/windowFactory.js +1 -4
  132. package/src/View/Export/ExportViewPanel.d.ts +1 -2
  133. package/src/View/Export/ExportViewPanel.js +2 -6
  134. package/src/View/Export/Wizard/ReportColumnTypeWizard.d.ts +1 -2
  135. package/src/View/Export/Wizard/ReportColumnTypeWizard.js +11 -12
  136. package/src/View/Export/Wizard/ReportRowTypeWizard.d.ts +1 -2
  137. package/src/View/Export/Wizard/ReportRowTypeWizard.js +12 -13
  138. package/src/View/Export/Wizard/ReportSettingsWizard.js +1 -2
  139. package/src/View/Filter/FilterViewPanel.js +20 -4
  140. package/src/View/FormatColumn/Wizard/FormatColumnFormatWizardSection.js +1 -1
  141. package/src/View/FreeTextColumn/FreeTextColumnSummary.js +1 -2
  142. package/src/View/FreeTextColumn/Wizard/FreeTextColumnSettingsWizardSection.d.ts +1 -1
  143. package/src/View/FreeTextColumn/Wizard/FreeTextColumnWizard.js +1 -1
  144. package/src/View/Layout/Wizard/{LayoutEditor → Components}/ColumnLabels.d.ts +0 -0
  145. package/src/View/Layout/Wizard/{LayoutEditor → Components}/ColumnLabels.js +0 -0
  146. package/src/View/Layout/Wizard/LayoutWizard.js +1 -0
  147. package/src/View/Layout/Wizard/sections/AggregationsSection.d.ts +1 -0
  148. package/src/View/Layout/Wizard/sections/AggregationsSection.js +69 -8
  149. package/src/View/Layout/Wizard/sections/ColumnsSection.js +1 -1
  150. package/src/View/Query/QueryViewPanel.js +1 -1
  151. package/src/agGrid/Adaptable.d.ts +11 -3
  152. package/src/agGrid/Adaptable.js +224 -150
  153. package/src/agGrid/agGridHelper.d.ts +1 -0
  154. package/src/agGrid/agGridHelper.js +5 -3
  155. package/src/agGrid/agGridMenuHelper.d.ts +1 -0
  156. package/src/agGrid/agGridMenuHelper.js +4 -2
  157. package/src/agGrid/weightedAverage.d.ts +6 -0
  158. package/src/agGrid/weightedAverage.js +66 -0
  159. package/src/bundle-dependencies/bundles/react-toastify/index.js +1 -1
  160. package/src/components/ExpressionEditor/BaseEditorInput.d.ts +1 -0
  161. package/src/components/ExpressionEditor/BaseEditorInput.js +2 -3
  162. package/src/components/ExpressionEditor/EditorInput.d.ts +1 -1
  163. package/src/components/ExpressionEditor/EditorInput.js +24 -4
  164. package/src/components/ExpressionEditor/{EditorInputReactive.d.ts → EditorInputWithWhereClause.d.ts} +3 -3
  165. package/src/components/ExpressionEditor/{EditorInputReactive.js → EditorInputWithWhereClause.js} +6 -5
  166. package/src/components/ExpressionEditor/editorButtonsAggregatedBoolean.d.ts +2 -0
  167. package/src/components/ExpressionEditor/{editorButtonsReactive.js → editorButtonsAggregatedBoolean.js} +22 -37
  168. package/src/components/ExpressionEditor/editorButtonsAggregatedScalar.js +5 -10
  169. package/src/components/ExpressionEditor/editorButtonsCumulativeAggregatedScalar.d.ts +2 -0
  170. package/src/components/ExpressionEditor/editorButtonsCumulativeAggregatedScalar.js +50 -0
  171. package/src/components/ExpressionEditor/editorButtonsObservable.d.ts +2 -0
  172. package/src/components/ExpressionEditor/editorButtonsObservable.js +40 -0
  173. package/src/components/ExpressionEditor/index.d.ts +1 -1
  174. package/src/components/ExpressionEditor/index.js +26 -5
  175. package/src/metamodel/adaptable.metamodel.d.ts +55 -1
  176. package/src/metamodel/adaptable.metamodel.js +1 -1
  177. package/src/types.d.ts +3 -3
  178. package/version.d.ts +1 -1
  179. package/version.js +1 -1
  180. package/src/View/CalculatedColumn/Utilities/getCalculatedColumnSettingTags.d.ts +0 -2
  181. package/src/View/Layout/LayoutEditorStandalonePopup.d.ts +0 -3
  182. package/src/View/Layout/LayoutEditorStandalonePopup.js +0 -78
  183. package/src/View/Layout/Wizard/LayoutEditor/ColumnList.d.ts +0 -27
  184. package/src/View/Layout/Wizard/LayoutEditor/ColumnList.js +0 -86
  185. package/src/View/Layout/Wizard/LayoutEditor/ColumnSortList.d.ts +0 -16
  186. package/src/View/Layout/Wizard/LayoutEditor/ColumnSortList.js +0 -89
  187. package/src/View/Layout/Wizard/LayoutEditor/PivotList.d.ts +0 -15
  188. package/src/View/Layout/Wizard/LayoutEditor/PivotList.js +0 -70
  189. package/src/View/Layout/Wizard/LayoutEditor/RowGroupsList.d.ts +0 -15
  190. package/src/View/Layout/Wizard/LayoutEditor/RowGroupsList.js +0 -70
  191. package/src/View/Layout/Wizard/LayoutEditor/droppableIds.d.ts +0 -7
  192. package/src/View/Layout/Wizard/LayoutEditor/droppableIds.js +0 -11
  193. package/src/View/Layout/Wizard/LayoutEditor/getItemStyle.d.ts +0 -6
  194. package/src/View/Layout/Wizard/LayoutEditor/getItemStyle.js +0 -26
  195. package/src/View/Layout/Wizard/LayoutEditor/index.d.ts +0 -9
  196. package/src/View/Layout/Wizard/LayoutEditor/index.js +0 -367
  197. package/src/View/Layout/Wizard/LayoutEditor/reducer.d.ts +0 -28
  198. package/src/View/Layout/Wizard/LayoutEditor/reducer.js +0 -46
  199. package/src/View/Layout/Wizard/LayoutEditor/utils.d.ts +0 -10
  200. package/src/View/Layout/Wizard/LayoutEditor/utils.js +0 -14
  201. package/src/View/Layout/Wizard/LayoutEditorWizard.d.ts +0 -30
  202. package/src/View/Layout/Wizard/LayoutEditorWizard.js +0 -132
  203. package/src/components/ExpressionEditor/editorButtonsReactive.d.ts +0 -2
@@ -1,9 +1,19 @@
1
1
  import { ExpressionFunction } from '../../parser/src/types';
2
+ import { BaseParameter } from './expressionFunctionUtils';
3
+ import { AggregatedScalarExpressionEvaluation } from './aggregatedScalarExpressionFunctions';
2
4
  /**
3
5
  * List of all the Aggregation Functions available in AdaptableQL
4
6
  */
5
- export declare type AggregationFunctionName = 'WHERE' | 'COL' | AggregationFunction | ComparisonFunction;
6
- declare type AggregationFunction = 'SUM';
7
+ export declare type AggregationFunctionName = 'WHERE' | 'COL' | 'GROUP_BY' | AggregationFunction | ComparisonFunction;
8
+ declare type AggregationFunction = 'SUM' | 'MIN' | 'MAX' | 'AVG';
7
9
  declare type ComparisonFunction = 'EQ' | 'NEQ' | 'LT' | 'GT' | 'LTE' | 'GTE';
10
+ export interface BooleanAggregationParameter extends BaseParameter<'aggregationBoolean', AggregationFunction> {
11
+ scalarAggregation: ScalarAggregationOperand;
12
+ conditionValue: number;
13
+ conditionFn: (aggregatedValue: number, conditionValue: number) => boolean;
14
+ }
15
+ export interface ScalarAggregationOperand extends BaseParameter<'aggregationScalar', AggregationFunction> {
16
+ value: AggregatedScalarExpressionEvaluation;
17
+ }
8
18
  export declare const aggregatedBooleanExpressionFunctions: Record<AggregationFunctionName, ExpressionFunction>;
9
19
  export {};
@@ -2,13 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.aggregatedBooleanExpressionFunctions = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const rxjs_1 = require("rxjs");
6
5
  const parseInt_1 = tslib_1.__importDefault(require("lodash/parseInt"));
7
6
  const ExpressionEvaluationError_1 = require("../../parser/src/ExpressionEvaluationError");
8
- const operators_1 = require("rxjs/operators");
9
7
  const expressionFunctionUtils_1 = require("./expressionFunctionUtils");
8
+ const aggregatedScalarExpressionFunctions_1 = require("./aggregatedScalarExpressionFunctions");
9
+ const SUPPORTED_AGGREGATION_FNS = ['SUM', 'MIN', 'MAX', 'AVG'];
10
10
  const aggregationScalarOperandMap = {
11
11
  SUM: ['string', 'number'],
12
+ MIN: ['string', 'number'],
13
+ MAX: ['string', 'number'],
14
+ AVG: ['string', 'number'],
12
15
  };
13
16
  // 0. optional non-capturing block of empty spaces
14
17
  // 1. block containing a numeric value (any digits) (required)
@@ -25,23 +28,11 @@ exports.aggregatedBooleanExpressionFunctions = {
25
28
  examples: ['<main_query> WHERE <boolean_query>', '<main_query> WHERE QUERY("abc")'],
26
29
  hasEagerEvaluation: true,
27
30
  },
28
- SUM: {
29
- handler(args, context) {
30
- const columnParameter = expressionFunctionUtils_1.extractColumnParameter('SUM', args);
31
- expressionFunctionUtils_1.validateColumnType(columnParameter.value, ['Number'], 'SUM', context.adaptableApi);
32
- const sumAggregationFn = (dataSource$) => getSumAggregation$(dataSource$, getColumnValueSum(columnParameter.value, context));
33
- const result = {
34
- type: 'aggregation',
35
- name: 'SUM',
36
- column: columnParameter.value,
37
- aggregationFn: sumAggregationFn,
38
- };
39
- return result;
40
- },
41
- description: 'Aggregates a column over multiple rows by summing up the column values',
42
- signatures: ['SUM( [colName] )', 'SUM( COL(name: string) )'],
43
- examples: ['SUM( [colA] )', "SUM( COL('col1') )"],
44
- },
31
+ SUM: aggregatedScalarExpressionFunctions_1.aggregatedScalarExpressionFunctions['SUM'],
32
+ MIN: aggregatedScalarExpressionFunctions_1.aggregatedScalarExpressionFunctions['MIN'],
33
+ MAX: aggregatedScalarExpressionFunctions_1.aggregatedScalarExpressionFunctions['MAX'],
34
+ AVG: aggregatedScalarExpressionFunctions_1.aggregatedScalarExpressionFunctions['AVG'],
35
+ GROUP_BY: aggregatedScalarExpressionFunctions_1.aggregatedScalarExpressionFunctions['GROUP_BY'],
45
36
  COL: {
46
37
  handler(args, context) {
47
38
  return expressionFunctionUtils_1.handleColumnFunction(args, context);
@@ -52,7 +43,7 @@ exports.aggregatedBooleanExpressionFunctions = {
52
43
  },
53
44
  EQ: {
54
45
  handler(args, context) {
55
- return handleAggregationCondition(args, context, '=', (aggregatedValue, conditionValue) => aggregatedValue === conditionValue);
46
+ return buildBooleanAggregationParameter(args, context, '=', (aggregatedValue, conditionValue) => aggregatedValue === conditionValue);
56
47
  },
57
48
  isHiddenFromMenu: true,
58
49
  description: 'Evaluates if the aggregation result equals a numerical value defined either as a number or a string abbreviation for thousands(K), millions(M) or billions(B)',
@@ -66,7 +57,7 @@ exports.aggregatedBooleanExpressionFunctions = {
66
57
  },
67
58
  NEQ: {
68
59
  handler(args, context) {
69
- return handleAggregationCondition(args, context, '!=', (aggregatedValue, conditionValue) => aggregatedValue !== conditionValue);
60
+ return buildBooleanAggregationParameter(args, context, '!=', (aggregatedValue, conditionValue) => aggregatedValue !== conditionValue);
70
61
  },
71
62
  isHiddenFromMenu: true,
72
63
  description: 'Evaluates if the aggregation result is NOT equal with a numerical value defined either as a number or a string abbreviation for thousands(K), millions(M) or billions(B)',
@@ -80,7 +71,7 @@ exports.aggregatedBooleanExpressionFunctions = {
80
71
  },
81
72
  LT: {
82
73
  handler(args, context) {
83
- return handleAggregationCondition(args, context, '<', (aggregatedValue, conditionValue) => aggregatedValue < conditionValue);
74
+ return buildBooleanAggregationParameter(args, context, '<', (aggregatedValue, conditionValue) => aggregatedValue < conditionValue);
84
75
  },
85
76
  isHiddenFromMenu: true,
86
77
  description: 'Evaluates if the aggregation result is less than a numerical value defined either as a number or a string abbreviation for thousands(K), millions(M) or billions(B)',
@@ -94,7 +85,7 @@ exports.aggregatedBooleanExpressionFunctions = {
94
85
  },
95
86
  LTE: {
96
87
  handler(args, context) {
97
- return handleAggregationCondition(args, context, '<=', (aggregatedValue, conditionValue) => aggregatedValue <= conditionValue);
88
+ return buildBooleanAggregationParameter(args, context, '<=', (aggregatedValue, conditionValue) => aggregatedValue <= conditionValue);
98
89
  },
99
90
  isHiddenFromMenu: true,
100
91
  description: 'Evaluates if the aggregation result is less than or equals a numerical value defined either as a number or a string abbreviation for thousands(K), millions(M) or billions(B)',
@@ -108,7 +99,7 @@ exports.aggregatedBooleanExpressionFunctions = {
108
99
  },
109
100
  GT: {
110
101
  handler(args, context) {
111
- return handleAggregationCondition(args, context, '>', (aggregatedValue, conditionValue) => aggregatedValue > conditionValue);
102
+ return buildBooleanAggregationParameter(args, context, '>', (aggregatedValue, conditionValue) => aggregatedValue > conditionValue);
112
103
  },
113
104
  isHiddenFromMenu: true,
114
105
  description: 'Evaluates if the aggregation result is greater than a numerical value defined either as a number or a string abbreviation for thousands(K), millions(M) or billions(B)',
@@ -122,7 +113,7 @@ exports.aggregatedBooleanExpressionFunctions = {
122
113
  },
123
114
  GTE: {
124
115
  handler(args, context) {
125
- return handleAggregationCondition(args, context, '>=', (aggregatedValue, conditionValue) => aggregatedValue >= conditionValue);
116
+ return buildBooleanAggregationParameter(args, context, '>=', (aggregatedValue, conditionValue) => aggregatedValue >= conditionValue);
126
117
  },
127
118
  isHiddenFromMenu: true,
128
119
  description: 'Evaluates if the aggregation result is greater than or equals a numerical value defined either as a number or a string abbreviation for thousands(K), millions(M) or billions(B)',
@@ -135,24 +126,25 @@ exports.aggregatedBooleanExpressionFunctions = {
135
126
  examples: [`SUM([col1]) >= '5M'`, 'GTE( SUM([col1]), 250000)'],
136
127
  },
137
128
  };
138
- const handleAggregationCondition = (args, context, comparisonOperator, conditionFn) => {
129
+ const buildBooleanAggregationParameter = (args, context, comparisonOperator, conditionFn) => {
139
130
  // LHS
140
- const aggregationOperand = extractAggregationOperand(comparisonOperator, ['SUM'], args[0]);
131
+ const aggregationOperand = extractScalarAggregationOperand(comparisonOperator, args[0]);
141
132
  // RHS
142
133
  const scalarOperand = extractScalarOperand(comparisonOperator, args[1], aggregationScalarOperandMap[aggregationOperand.name]);
143
- let dataChangeLog$ = expressionFunctionUtils_1.getDataChangeLog$(context, aggregationOperand.column);
144
- const aggregatedValue$ = aggregationOperand.aggregationFn(dataChangeLog$);
145
- return dataChangeLog$.pipe(operators_1.withLatestFrom(aggregatedValue$), operators_1.filter(([_, currentAggregationValue]) => {
146
- // check if new aggregated value satisfies the criteria
147
- return conditionFn(currentAggregationValue, scalarOperand);
148
- }), operators_1.map(([source]) => source));
134
+ return {
135
+ type: 'aggregationBoolean',
136
+ name: aggregationOperand.name,
137
+ scalarAggregation: aggregationOperand,
138
+ conditionValue: scalarOperand,
139
+ conditionFn,
140
+ };
149
141
  };
150
- const extractAggregationOperand = (consumingFunctionName, allowedAggregations, argument) => {
142
+ const extractScalarAggregationOperand = (consumingFunctionName, argument) => {
151
143
  const result = argument;
152
- if (argument == undefined ||
153
- argument.type !== 'aggregation' ||
154
- !allowedAggregations.includes(argument.name)) {
155
- throw new ExpressionEvaluationError_1.ExpressionEvaluationError(consumingFunctionName, `comparison operator expects as a left-hand operand an aggregation function of type '${allowedAggregations.join(' | ')}'`);
144
+ if (result == undefined ||
145
+ result.type !== 'aggregationScalar' ||
146
+ !SUPPORTED_AGGREGATION_FNS.includes(result.name)) {
147
+ throw new ExpressionEvaluationError_1.ExpressionEvaluationError(consumingFunctionName, `comparison operator expects as a left-hand operand an aggregation function of type '${SUPPORTED_AGGREGATION_FNS.join(' | ')}'`);
156
148
  }
157
149
  return result;
158
150
  };
@@ -182,31 +174,3 @@ const extractScalarOperand = (consumingFunctionName, value, allowedTypes) => {
182
174
  // numeric value
183
175
  return parseInt_1.default(numericString) * numberUnitRatios[largeNumberUnit.toLowerCase()];
184
176
  };
185
- const getSumAggregation$ = (source$, initialSum) => {
186
- return rxjs_1.defer(() => {
187
- let sumValue = initialSum;
188
- const updateSum = (dataChangeLog) => {
189
- const oldValue = expressionFunctionUtils_1.getNumericValue(dataChangeLog.oldValue);
190
- const newValue = expressionFunctionUtils_1.getNumericValue(dataChangeLog.newValue);
191
- sumValue = sumValue - oldValue + newValue;
192
- };
193
- return source$.pipe(operators_1.tap((dataChangeLog) => updateSum(dataChangeLog)), operators_1.map(() => sumValue));
194
- });
195
- };
196
- const getColumnValueSum = (column, context) => {
197
- let sum = 0;
198
- context.adaptableApi.internalApi.forAllRowNodesDo((rowNode) => {
199
- // if there is a WHERE clause defined, check if the current rowNode satisfies the condition
200
- if (context.filterFn && !context.filterFn(rowNode)) {
201
- return;
202
- }
203
- if (context.adaptableApi.gridApi.isGroupRowNode(rowNode)) {
204
- return;
205
- }
206
- const cellValue = context.adaptableApi.gridApi.getRawValueFromRowNode(rowNode, column);
207
- if (cellValue != undefined) {
208
- sum = sum + expressionFunctionUtils_1.getNumericValue(rowNode.data[column]);
209
- }
210
- });
211
- return sum;
212
- };
@@ -5,25 +5,41 @@ import { AggregateParams } from './scalarAggregationHelper';
5
5
  /**
6
6
  * List of all the AggregatedScalar Functions available in AdaptableQL
7
7
  */
8
- export declare type AggregatedScalarFunctionName = AggregationFunction | OperandFunction;
9
- declare type AggregationFunction = 'SUM' | 'PERCENTAGE' | 'QUANT' | 'AVG' | 'MIN' | 'MAX' | 'CUMUL';
10
- declare type OperandFunction = 'COL' | 'OVER' | 'GROUP_BY';
11
- export interface AggregationParameter extends BaseParameter<'aggregation', AggregationFunction> {
8
+ export declare type AggregatedScalarFunctionName = ScalarAggregationFunction | OperandFunction;
9
+ export declare type ScalarAggregationFunction = 'SUM' | 'PERCENTAGE' | 'QUANT' | 'AVG' | 'MIN' | 'MAX' | 'CUMUL';
10
+ declare type OperandFunction = 'COL' | 'OVER' | 'GROUP_BY' | 'WEIGHT';
11
+ export interface ScalarAggregationParameter extends BaseParameter<'aggregationScalar', ScalarAggregationFunction> {
12
12
  value: AggregatedScalarExpressionEvaluation;
13
13
  }
14
14
  export interface OverParameter extends BaseParameter<'operand', 'OVER'> {
15
15
  value: string;
16
16
  }
17
17
  export interface GroupByParameter extends BaseParameter<'operand', 'GROUP_BY'> {
18
+ value: string[];
19
+ }
20
+ export interface WeightParameter extends BaseParameter<'operand', 'WEIGHT'> {
18
21
  value: string;
19
22
  }
20
23
  export interface AggregatedScalarExpressionEvaluation {
21
24
  aggregationParams: AggregateParams<any, string | number>;
22
25
  rowValueGetter?: (rowNode: RowNode, aggregatedValue: any) => string | number | Date | boolean;
26
+ /**
27
+ * @deprecated remove this
28
+ */
23
29
  columnDependencies: string[];
24
- cumulateOver?: string;
30
+ context?: {
31
+ weightParam?: WeightParameter;
32
+ };
25
33
  sortByColumn?: string;
26
- filterUndefinedValues?: boolean;
34
+ rowFilterFn?: (rowNode: RowNode) => boolean;
35
+ }
36
+ export interface CumulatedAggregationValue {
37
+ currentValue: number;
38
+ cumulatedValues: Record<number | string, number>;
39
+ numberOfCumulatedValues?: number;
40
+ totalAggregationValue?: number;
27
41
  }
42
+ export declare const cumulativeAggregatedExpressionFunctions: AggregatedScalarFunctionName[];
43
+ export declare const aggregatedExpressionFunctions: AggregatedScalarFunctionName[];
28
44
  export declare const aggregatedScalarExpressionFunctions: Record<AggregatedScalarFunctionName, ExpressionFunction>;
29
45
  export {};