@adaptabletools/adaptable 11.0.0-canary.5 → 11.0.0

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 (159) hide show
  1. package/agGrid.d.ts +5 -4
  2. package/agGrid.js +9 -7
  3. package/base.css +2 -2
  4. package/bundle.cjs.js +103 -98
  5. package/index.css +2 -2
  6. package/package.json +1 -1
  7. package/publishTimestamp.d.ts +1 -1
  8. package/publishTimestamp.js +1 -1
  9. package/src/AdaptableInterfaces/IAdaptable.d.ts +1 -0
  10. package/src/AdaptableOptions/AdaptableOptions.d.ts +4 -6
  11. package/src/AdaptableOptions/{QueryLanguageOptions.d.ts → AdaptableQLOptions.d.ts} +37 -5
  12. package/src/AdaptableOptions/{QueryLanguageOptions.js → AdaptableQLOptions.js} +0 -0
  13. package/src/AdaptableOptions/ContainerOptions.d.ts +1 -1
  14. package/src/AdaptableOptions/GeneralOptions.d.ts +0 -7
  15. package/src/AdaptableOptions/SearchOptions.d.ts +0 -9
  16. package/src/AdaptableOptions/SettingsPanelOptions.d.ts +4 -3
  17. package/src/AdaptableOptions/StateOptions.d.ts +7 -7
  18. package/src/AdaptableOptions/UserInterfaceOptions.d.ts +1 -1
  19. package/src/Api/AdaptableApi.d.ts +5 -0
  20. package/src/Api/CalculatedColumnApi.d.ts +2 -9
  21. package/src/Api/ColumnApi.d.ts +0 -4
  22. package/src/Api/GridApi.d.ts +11 -1
  23. package/src/Api/Implementation/AdaptableApiImpl.d.ts +2 -1
  24. package/src/Api/Implementation/AdaptableApiImpl.js +2 -0
  25. package/src/Api/Implementation/AlertApiImpl.js +4 -1
  26. package/src/Api/Implementation/ApiBase.d.ts +3 -2
  27. package/src/Api/Implementation/ApiBase.js +5 -2
  28. package/src/Api/Implementation/CalculatedColumnApiImpl.js +3 -4
  29. package/src/Api/Implementation/ColumnApiImpl.d.ts +0 -1
  30. package/src/Api/Implementation/ColumnApiImpl.js +0 -5
  31. package/src/Api/Implementation/GridApiImpl.d.ts +2 -0
  32. package/src/Api/Implementation/GridApiImpl.js +27 -4
  33. package/src/Api/Implementation/InternalApiImpl.d.ts +2 -3
  34. package/src/Api/Implementation/InternalApiImpl.js +5 -4
  35. package/src/Api/Implementation/QueryLanguageApiImpl.d.ts +4 -1
  36. package/src/Api/Implementation/QueryLanguageApiImpl.js +17 -4
  37. package/src/Api/Implementation/SettingsPanelApiImpl.d.ts +7 -0
  38. package/src/Api/Implementation/SettingsPanelApiImpl.js +15 -0
  39. package/src/Api/InternalApi.d.ts +2 -3
  40. package/src/Api/QueryApi.d.ts +2 -2
  41. package/src/Api/QueryLanguageApi.d.ts +23 -10
  42. package/src/Api/SettingsPanelApi.d.ts +16 -0
  43. package/src/Api/SettingsPanelApi.js +2 -0
  44. package/src/PredefinedConfig/AlertState.d.ts +6 -2
  45. package/src/PredefinedConfig/CalculatedColumnState.d.ts +8 -3
  46. package/src/PredefinedConfig/Common/AdaptableFormat.d.ts +3 -0
  47. package/src/PredefinedConfig/Common/AdaptableQuery.d.ts +7 -5
  48. package/src/PredefinedConfig/Common/AdaptableQuery.js +2 -6
  49. package/src/PredefinedConfig/Common/Enums.d.ts +0 -1
  50. package/src/PredefinedConfig/Common/Enums.js +0 -2
  51. package/src/PredefinedConfig/Common/SpecialColumnSettings.d.ts +1 -1
  52. package/src/PredefinedConfig/Common/Types.d.ts +6 -1
  53. package/src/PredefinedConfig/Common/Types.js +1 -0
  54. package/src/PredefinedConfig/ConditionalStyleState.d.ts +2 -2
  55. package/src/PredefinedConfig/FormatColumnState.d.ts +15 -0
  56. package/src/PredefinedConfig/Selection/GridCellRange.d.ts +3 -1
  57. package/src/PredefinedConfig/ToolPanelState.d.ts +3 -0
  58. package/src/Redux/Store/AdaptableReduxMerger.js +1 -1
  59. package/src/Redux/Store/AdaptableStore.js +27 -2
  60. package/src/Strategy/AlertModule.js +12 -3
  61. package/src/Strategy/CalculatedColumnModule.js +4 -4
  62. package/src/Strategy/ChartingModule.d.ts +3 -3
  63. package/src/Strategy/ChartingModule.js +2 -2
  64. package/src/Strategy/FlashingCellModule.js +2 -2
  65. package/src/Strategy/FreeTextColumnModule.js +1 -0
  66. package/src/Strategy/{SetingsPanelModule.d.ts → SettingsPanelModule.d.ts} +0 -0
  67. package/src/Strategy/{SetingsPanelModule.js → SettingsPanelModule.js} +0 -0
  68. package/src/Strategy/Utilities/getAlertPreviewViewItems.js +1 -1
  69. package/src/Strategy/Utilities/getExpressionViewItems.d.ts +2 -2
  70. package/src/Strategy/Utilities/getExpressionViewItems.js +2 -1
  71. package/src/Strategy/Utilities/getRuleViewItems.js +1 -2
  72. package/src/Utilities/Constants/DocumentationLinkConstants.d.ts +3 -2
  73. package/src/Utilities/Constants/DocumentationLinkConstants.js +12 -10
  74. package/src/Utilities/Defaults/DefaultAdaptableOptions.js +17 -13
  75. package/src/Utilities/ExpressionFunctions/{aggregationExpressionFunctions.d.ts → aggregatedBooleanExpressionFunctions.d.ts} +1 -1
  76. package/src/Utilities/ExpressionFunctions/{aggregationExpressionFunctions.js → aggregatedBooleanExpressionFunctions.js} +4 -4
  77. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +24 -0
  78. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +339 -0
  79. package/src/Utilities/ExpressionFunctions/deepMap.d.ts +35 -0
  80. package/src/Utilities/ExpressionFunctions/deepMap.js +283 -0
  81. package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.d.ts +2 -2
  82. package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.js +8 -8
  83. package/src/Utilities/ExpressionFunctions/groupingMap.d.ts +35 -0
  84. package/src/Utilities/ExpressionFunctions/groupingMap.js +105 -0
  85. package/src/Utilities/ExpressionFunctions/observableExpressionFunctions.js +3 -2
  86. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.d.ts +33 -0
  87. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.js +154 -0
  88. package/src/Utilities/Helpers/AdaptableHelper.js +2 -1
  89. package/src/Utilities/Services/AlertService.js +8 -4
  90. package/src/Utilities/Services/CalculatedColumnExpressionService.d.ts +7 -3
  91. package/src/Utilities/Services/CalculatedColumnExpressionService.js +143 -18
  92. package/src/Utilities/Services/Interface/IAdaptableService.d.ts +1 -1
  93. package/src/Utilities/Services/Interface/ICalculatedColumnExpressionService.d.ts +6 -3
  94. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +9 -3
  95. package/src/Utilities/Services/LicenseService.js +1 -1
  96. package/src/Utilities/Services/ModuleService.js +33 -40
  97. package/src/Utilities/Services/QueryLanguageService.d.ts +11 -4
  98. package/src/Utilities/Services/QueryLanguageService.js +84 -25
  99. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationForm.js +5 -3
  100. package/src/View/AdaptableWizardView/helper.js +2 -2
  101. package/src/View/Alert/Wizard/AlertDisplayWizardSection.d.ts +1 -0
  102. package/src/View/Alert/Wizard/AlertDisplayWizardSection.js +2 -2
  103. package/src/View/Alert/Wizard/AlertWizard.js +2 -2
  104. package/src/View/Alert/Wizard/BaseAlertRulesWizardSection.js +2 -2
  105. package/src/View/Alert/Wizard/BaseAlertScopeWizardSection.js +3 -2
  106. package/src/View/Alert/Wizard/isValidAlertRules.js +3 -3
  107. package/src/View/CalculatedColumn/CalculatedColumnSharedEntity.js +3 -3
  108. package/src/View/CalculatedColumn/CalculatedColumnSummary.js +2 -4
  109. package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +43 -12
  110. package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.js +1 -2
  111. package/src/View/CalculatedColumn/Wizard/CalculatedColumnWizard.js +2 -2
  112. package/src/View/ColorPicker.d.ts +1 -1
  113. package/src/View/Components/AdaptableDateInput/index.d.ts +1 -1
  114. package/src/View/Components/AdaptableInput/index.d.ts +1 -1
  115. package/src/View/Components/Buttons/ButtonDelete.d.ts +1 -1
  116. package/src/View/Components/EntityRulesEditor/index.js +11 -12
  117. package/src/View/Components/Forms/AdaptableFormControlTextClear.d.ts +1 -1
  118. package/src/View/Components/Panels/PanelWithImage.d.ts +1 -1
  119. package/src/View/Components/Popups/AdaptablePopup/AdaptablePopup.js +4 -8
  120. package/src/View/Components/Popups/AdaptablePopup/useMenuItems.js +1 -2
  121. package/src/View/Components/Popups/AdaptablePopupAlert.d.ts +1 -0
  122. package/src/View/Components/Popups/AdaptablePopupAlert.js +1 -1
  123. package/src/View/Components/ValueSelector/index.js +1 -1
  124. package/src/View/ConditionalStyle/Wizard/ConditionalStyleRuleWizardSection.js +2 -2
  125. package/src/View/CustomSort/Wizard/CustomSortWizard.js +1 -1
  126. package/src/View/FlashingCell/Wizard/FlashingCellRulesWizardSection.js +2 -2
  127. package/src/View/FlashingCell/Wizard/FlashingCellWizard.js +1 -1
  128. package/src/View/FormatColumn/Wizard/FormatColumnWizard.js +1 -1
  129. package/src/View/Layout/Wizard/LayoutEditor/index.js +1 -1
  130. package/src/View/License/LicenseWatermark.js +1 -1
  131. package/src/View/Query/Wizard/NamedQueryWizard.js +3 -3
  132. package/src/View/Schedule/Wizard/ScheduleWizard.js +3 -3
  133. package/src/agGrid/Adaptable.d.ts +1 -0
  134. package/src/agGrid/Adaptable.js +13 -14
  135. package/src/agGrid/agGridHelper.js +3 -7
  136. package/src/components/AdaptableFormComponent/AdaptableFormComponent.d.ts +4 -2
  137. package/src/components/AdaptableFormComponent/AdaptableFormComponent.js +4 -4
  138. package/src/components/Datepicker/index.d.ts +1 -1
  139. package/src/components/ExpressionEditor/EditorInput.d.ts +1 -1
  140. package/src/components/ExpressionEditor/EditorInput.js +5 -2
  141. package/src/components/ExpressionEditor/EditorInputReactive.d.ts +1 -1
  142. package/src/components/ExpressionEditor/EditorInputReactive.js +1 -1
  143. package/src/components/ExpressionEditor/ExpressionFunctionDocumentation.js +1 -1
  144. package/src/components/ExpressionEditor/editorButtonsAggregatedScalar.d.ts +2 -0
  145. package/src/components/ExpressionEditor/editorButtonsAggregatedScalar.js +45 -0
  146. package/src/components/ExpressionEditor/editorButtonsReactive.js +8 -13
  147. package/src/components/ExpressionEditor/index.d.ts +2 -1
  148. package/src/components/ExpressionEditor/index.js +11 -4
  149. package/src/components/Input/index.d.ts +1 -1
  150. package/src/components/List/ListGroupItem/index.d.ts +1 -1
  151. package/src/components/Logo/index.js +8 -7
  152. package/src/components/PopupWithFooter.d.ts +1 -1
  153. package/src/components/Textarea/index.d.ts +1 -1
  154. package/src/components/icons/calculated-column.js +2 -1
  155. package/src/metamodel/adaptable.metamodel.d.ts +233 -37
  156. package/src/metamodel/adaptable.metamodel.js +448 -149
  157. package/src/types.d.ts +5 -4
  158. package/version.d.ts +1 -1
  159. package/version.js +1 -1
@@ -1,5 +1,5 @@
1
- import { AdaptableScalarQuery } from '../../PredefinedConfig/Common/AdaptableQuery';
2
- export declare const getExpressionViewItems: (query: AdaptableScalarQuery) => {
1
+ import { AdaptableCalculatedColumnQuery } from '../../PredefinedConfig/CalculatedColumnState';
2
+ export declare const getExpressionViewItems: (query: AdaptableCalculatedColumnQuery) => {
3
3
  name: string;
4
4
  values: string[];
5
5
  };
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getExpressionViewItems = void 0;
4
4
  exports.getExpressionViewItems = (query) => {
5
+ var _a;
5
6
  return {
6
7
  name: 'Expression',
7
- values: [query === null || query === void 0 ? void 0 : query.ScalarExpression],
8
+ values: [(_a = query === null || query === void 0 ? void 0 : query.ScalarExpression) !== null && _a !== void 0 ? _a : query === null || query === void 0 ? void 0 : query.AggregatedScalarExpression],
8
9
  };
9
10
  };
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRuleViewItems = void 0;
4
- const AdaptableQuery_1 = require("../../PredefinedConfig/Common/AdaptableQuery");
5
4
  exports.getRuleViewItems = (rule, api) => {
6
5
  return {
7
6
  name: 'Condition',
8
7
  values: [
9
8
  rule.Predicate
10
9
  ? api.predicateApi.predicateToString(rule.Predicate)
11
- : AdaptableQuery_1.getAdaptableQueryExpression(rule),
10
+ : api.queryLanguageApi.getAdaptableQueryExpression(rule),
12
11
  ],
13
12
  };
14
13
  };
@@ -1,9 +1,10 @@
1
- export declare const HOST_URL_DOCS = "https://docs.adaptabletools.com/docs";
1
+ export declare const HOST_URL_DOCS = "https://docs.adaptabletools.com";
2
2
  export declare const ExpressionEditorDocsLink: string;
3
3
  export declare const BooleanQueryDocsLink: string;
4
4
  export declare const ScalarQueryDocsLink: string;
5
5
  export declare const ObservableQueryDocsLink: string;
6
- export declare const AggregationQueryDocsLink: string;
6
+ export declare const AggregatedBooleanQueryDocsLink: string;
7
+ export declare const AggregatedScalarQueryDocsLink: string;
7
8
  export declare const PredicateDocsLink: string;
8
9
  export declare const PrimaryKeyDocsLink: string;
9
10
  export declare const LicenseDocsLink: string;
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LicenseDocsLink = exports.PrimaryKeyDocsLink = exports.PredicateDocsLink = exports.AggregationQueryDocsLink = exports.ObservableQueryDocsLink = exports.ScalarQueryDocsLink = exports.BooleanQueryDocsLink = exports.ExpressionEditorDocsLink = exports.HOST_URL_DOCS = void 0;
4
- exports.HOST_URL_DOCS = 'https://docs.adaptabletools.com/docs';
5
- exports.ExpressionEditorDocsLink = `${exports.HOST_URL_DOCS}/adaptableql/expression-editor`;
6
- exports.BooleanQueryDocsLink = `${exports.HOST_URL_DOCS}/adaptableql/expression/#boolean-expressions`;
7
- exports.ScalarQueryDocsLink = `${exports.HOST_URL_DOCS}/adaptableql/expression/#scalar-expressions`;
8
- exports.ObservableQueryDocsLink = `${exports.HOST_URL_DOCS}/adaptableql/expression/#observable-expressions`;
9
- exports.AggregationQueryDocsLink = `${exports.HOST_URL_DOCS}/adaptableql/expression/#aggregation-expressions`;
10
- exports.PredicateDocsLink = `${exports.HOST_URL_DOCS}/adaptableql/predicate`;
11
- exports.PrimaryKeyDocsLink = `${exports.HOST_URL_DOCS}/key-topics/primary-key`;
12
- exports.LicenseDocsLink = `${exports.HOST_URL_DOCS}/getting-started/licence`;
3
+ exports.LicenseDocsLink = exports.PrimaryKeyDocsLink = exports.PredicateDocsLink = exports.AggregatedScalarQueryDocsLink = exports.AggregatedBooleanQueryDocsLink = exports.ObservableQueryDocsLink = exports.ScalarQueryDocsLink = exports.BooleanQueryDocsLink = exports.ExpressionEditorDocsLink = exports.HOST_URL_DOCS = void 0;
4
+ exports.HOST_URL_DOCS = 'https://docs.adaptabletools.com';
5
+ //export const HOST_URL_DOCS = 'http://localhost:3000';
6
+ exports.ExpressionEditorDocsLink = `${exports.HOST_URL_DOCS}/learn/ui-expression-editor`;
7
+ exports.BooleanQueryDocsLink = `${exports.HOST_URL_DOCS}/learn/adaptable-ql-expression#boolean-expressions`;
8
+ exports.ScalarQueryDocsLink = `${exports.HOST_URL_DOCS}/learn/adaptable-ql-expression#scalar-expressions`;
9
+ exports.ObservableQueryDocsLink = `${exports.HOST_URL_DOCS}/learn/adaptable-ql-expression#observable-expressions`;
10
+ exports.AggregatedBooleanQueryDocsLink = `${exports.HOST_URL_DOCS}/learn/adaptable-ql-expression#aggregation-boolean-expressions`;
11
+ exports.AggregatedScalarQueryDocsLink = `${exports.HOST_URL_DOCS}/learn/adaptable-ql-expression#aggregation-scalar-expressions`;
12
+ exports.PredicateDocsLink = `${exports.HOST_URL_DOCS}/learn/adaptable-ql-predicate`;
13
+ exports.PrimaryKeyDocsLink = `${exports.HOST_URL_DOCS}/learn/dev-guide-tutorial-primary-key`;
14
+ exports.LicenseDocsLink = `${exports.HOST_URL_DOCS}/licensing`;
@@ -8,9 +8,10 @@ const UIHelper_1 = tslib_1.__importStar(require("../../View/UIHelper"));
8
8
  const booleanExpressionFunctions_1 = require("../ExpressionFunctions/booleanExpressionFunctions");
9
9
  const scalarExpressionFunctions_1 = require("../ExpressionFunctions/scalarExpressionFunctions");
10
10
  const observableExpressionFunctions_1 = require("../ExpressionFunctions/observableExpressionFunctions");
11
- const aggregationExpressionFunctions_1 = require("../ExpressionFunctions/aggregationExpressionFunctions");
11
+ const aggregatedBooleanExpressionFunctions_1 = require("../ExpressionFunctions/aggregatedBooleanExpressionFunctions");
12
12
  const AdaptablePredicate_1 = require("../../PredefinedConfig/Common/AdaptablePredicate");
13
13
  const Enums_1 = require("../../PredefinedConfig/Common/Enums");
14
+ const aggregatedScalarExpressionFunctions_1 = require("../ExpressionFunctions/aggregatedScalarExpressionFunctions");
14
15
  exports.DefaultAdaptableOptions = {
15
16
  adaptableId: GeneralConstants.ADAPTABLE_ID,
16
17
  adaptableStateKey: undefined,
@@ -52,6 +53,21 @@ exports.DefaultAdaptableOptions = {
52
53
  BackColor: UIHelper_1.getHexForName(UIHelper_1.GRAY),
53
54
  },
54
55
  },
56
+ adaptableQLOptions: {
57
+ caseSensitiveTextComparisons: false,
58
+ externallyEvaluatedModules: [],
59
+ expressionOptions: {
60
+ defaultBooleanFunctions: booleanExpressionFunctions_1.booleanExpressionFunctions,
61
+ defaultScalarFunctions: scalarExpressionFunctions_1.scalarExpressionFunctions,
62
+ defaultObservableFunctions: observableExpressionFunctions_1.observableExpressionFunctions,
63
+ defaultAggregatedBooleanFunctions: aggregatedBooleanExpressionFunctions_1.aggregatedBooleanExpressionFunctions,
64
+ defaultAggregatedScalarFunctions: aggregatedScalarExpressionFunctions_1.aggregatedScalarExpressionFunctions,
65
+ moduleExpressionFunctions: undefined,
66
+ queryableColumns: undefined,
67
+ performExpressionValidation: true,
68
+ maxTimeframeSize: 28800000,
69
+ },
70
+ },
55
71
  containerOptions: {
56
72
  adaptableContainer: 'adaptable',
57
73
  agGridContainer: 'grid',
@@ -107,7 +123,6 @@ exports.DefaultAdaptableOptions = {
107
123
  currentCalendar: 'United Kingdom',
108
124
  cellSummaryOperations: undefined,
109
125
  customSortComparers: undefined,
110
- caseSensitiveTextComparisons: false,
111
126
  },
112
127
  layoutOptions: {
113
128
  includeExpandedRowGroups: false,
@@ -155,7 +170,6 @@ exports.DefaultAdaptableOptions = {
155
170
  },
156
171
  searchOptions: {
157
172
  excludeColumnFromQuickSearch: undefined,
158
- serverSearchOptions: undefined,
159
173
  clearSearchesOnStartUp: false,
160
174
  quickSearchPlaceholder: 'Search',
161
175
  filterResultsAfterQuickSearch: false,
@@ -208,16 +222,6 @@ exports.DefaultAdaptableOptions = {
208
222
  maxWidth: undefined,
209
223
  toolPanelOrder: ['filters', 'columns', 'adaptable'],
210
224
  },
211
- queryLanguageOptions: {
212
- defaultBooleanFunctions: booleanExpressionFunctions_1.booleanExpressionFunctions,
213
- defaultScalarFunctions: scalarExpressionFunctions_1.scalarExpressionFunctions,
214
- defaultObservableFunctions: observableExpressionFunctions_1.observableExpressionFunctions,
215
- defaultAggregationFunctions: aggregationExpressionFunctions_1.aggregationExpressionFunctions,
216
- moduleExpressionFunctions: undefined,
217
- queryableColumns: undefined,
218
- performExpressionValidation: true,
219
- maxTimeframeSize: 28800000,
220
- },
221
225
  dataChangeHistoryOptions: {
222
226
  activeByDefault: false,
223
227
  showDataChange: undefined,
@@ -2,5 +2,5 @@ import { ExpressionFunction } from '../../parser/src/types';
2
2
  declare type AggregationFunctionName = 'WHERE' | 'COL' | AggregationFunction | ComparisonFunction;
3
3
  declare type AggregationFunction = 'SUM';
4
4
  declare type ComparisonFunction = 'EQ' | 'NEQ' | 'LT' | 'GT' | 'LTE' | 'GTE';
5
- export declare const aggregationExpressionFunctions: Record<AggregationFunctionName, ExpressionFunction>;
5
+ export declare const aggregatedBooleanExpressionFunctions: Record<AggregationFunctionName, ExpressionFunction>;
6
6
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.aggregationExpressionFunctions = void 0;
3
+ exports.aggregatedBooleanExpressionFunctions = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const rxjs_1 = require("rxjs");
6
6
  const parseInt_1 = tslib_1.__importDefault(require("lodash/parseInt"));
@@ -14,7 +14,7 @@ const aggregationScalarOperandMap = {
14
14
  // 1. block containing a numeric value (any digits) (required)
15
15
  // 2. block containing a single 'K', 'M' or 'B' letter (optional) (case insensitive)
16
16
  const CRITERIA_REGEX = /^(?:\s*)(\d+)(K|M|B)?$/i;
17
- exports.aggregationExpressionFunctions = {
17
+ exports.aggregatedBooleanExpressionFunctions = {
18
18
  WHERE: {
19
19
  handler(args, context) {
20
20
  return expressionFunctionUtils_1.handleWhereFunction(args, context);
@@ -46,7 +46,7 @@ exports.aggregationExpressionFunctions = {
46
46
  handler(args, context) {
47
47
  return expressionFunctionUtils_1.handleColumnFunction(args, context);
48
48
  },
49
- description: 'References a grid column by name',
49
+ description: 'References a column by its unique identifier',
50
50
  signatures: ['[colName]', 'COL(name: string)'],
51
51
  examples: ['[col1]', "COL('col1')"],
52
52
  },
@@ -55,7 +55,7 @@ exports.aggregationExpressionFunctions = {
55
55
  return handleAggregationCondition(args, context, '=', (aggregatedValue, conditionValue) => aggregatedValue === conditionValue);
56
56
  },
57
57
  isHiddenFromMenu: true,
58
- description: 'Evaluates if the aggregation result is equals a numerical value defined either as a number or a string abbreviation for thousands(K), millions(M) or billions(B)',
58
+ 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)',
59
59
  signatures: [
60
60
  'SUM() = number',
61
61
  `SUM() = '%number%(K|M|B)'`,
@@ -0,0 +1,24 @@
1
+ import { ExpressionFunction } from '../../parser/src/types';
2
+ import { BaseParameter } from './expressionFunctionUtils';
3
+ import { RowNode } from '@ag-grid-community/all-modules';
4
+ import { AggregateParams } from './scalarAggregationHelper';
5
+ export declare type AggregatedScalarFunctionName = AggregationFunction | OperandFunction;
6
+ declare type AggregationFunction = 'SUM' | 'PERCENTAGE' | 'AVG' | 'MIN' | 'MAX' | 'CUMUL';
7
+ declare type OperandFunction = 'COL' | 'OVER' | 'GROUP_BY';
8
+ export interface AggregationParameter extends BaseParameter<'aggregation', AggregationFunction> {
9
+ value: AggregatedScalarExpressionEvaluation;
10
+ }
11
+ export interface OverParameter extends BaseParameter<'operand', 'OVER'> {
12
+ value: string;
13
+ }
14
+ export interface GroupByParameter extends BaseParameter<'operand', 'GROUP_BY'> {
15
+ value: string;
16
+ }
17
+ export interface AggregatedScalarExpressionEvaluation {
18
+ aggregationParams: AggregateParams<any, string | number>;
19
+ rowValueGetter?: (rowNode: RowNode, aggregationValue: number) => string | number | Date | boolean;
20
+ columnDependencies: string[];
21
+ cumulateOver?: string;
22
+ }
23
+ export declare const aggregatedScalarExpressionFunctions: Record<AggregatedScalarFunctionName, ExpressionFunction>;
24
+ export {};
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.aggregatedScalarExpressionFunctions = void 0;
4
+ const expressionFunctionUtils_1 = require("./expressionFunctionUtils");
5
+ const ExpressionEvaluationError_1 = require("../../parser/src/ExpressionEvaluationError");
6
+ exports.aggregatedScalarExpressionFunctions = {
7
+ SUM: {
8
+ handler(args, context) {
9
+ const sumColumnParameter = expressionFunctionUtils_1.extractColumnParameter('SUM', args);
10
+ const sumColumnName = sumColumnParameter.value;
11
+ expressionFunctionUtils_1.validateColumnType(sumColumnName, ['Number'], 'SUM', context.api);
12
+ const groupByParameter = expressionFunctionUtils_1.extractParameter('SUM', 'operand', ['GROUP_BY'], args, true);
13
+ const aggregationExpressionEvaluation = {
14
+ aggregationParams: {
15
+ reducers: {
16
+ SUM: {
17
+ name: 'SUM',
18
+ field: sumColumnName,
19
+ initialValue: 0,
20
+ reducer: (totalSum, rowValue) => {
21
+ if (!rowValue) {
22
+ return totalSum;
23
+ }
24
+ return totalSum + rowValue;
25
+ },
26
+ },
27
+ },
28
+ },
29
+ columnDependencies: [sumColumnName],
30
+ };
31
+ if (groupByParameter) {
32
+ const groupByColumnName = groupByParameter.value;
33
+ aggregationExpressionEvaluation.aggregationParams.groupBy = [
34
+ {
35
+ field: groupByColumnName,
36
+ },
37
+ ];
38
+ aggregationExpressionEvaluation.columnDependencies.push(groupByColumnName);
39
+ }
40
+ const result = {
41
+ name: 'SUM',
42
+ type: 'aggregation',
43
+ value: aggregationExpressionEvaluation,
44
+ };
45
+ return result;
46
+ },
47
+ description: 'Aggregates a column over multiple rows by summing up the column values\nOptionally the aggregation may be computed within provided individual groups',
48
+ signatures: [
49
+ 'SUM( [colName] )',
50
+ 'SUM( COL(name: string))',
51
+ 'SUM( [colNameA], GROUP_BY( [colNameB] ))',
52
+ 'SUM( COL(nameA: string), GROUP_BY( COL(nameB: string)))',
53
+ ],
54
+ examples: ['SUM([colA])', 'SUM([colA], GROUP_BY([colB]))'],
55
+ },
56
+ PERCENTAGE: {
57
+ handler(args, context) {
58
+ var _a;
59
+ const percentageColumnParameter = expressionFunctionUtils_1.extractColumnParameter('PERCENTAGE', args);
60
+ const percentageColumnName = percentageColumnParameter.value;
61
+ expressionFunctionUtils_1.validateColumnType(percentageColumnName, ['Number'], 'PERCENTAGE', context.api);
62
+ const sumOperand = expressionFunctionUtils_1.extractParameter('PERCENTAGE', 'aggregation', ['SUM'], args, true);
63
+ const groupByOperand = expressionFunctionUtils_1.extractParameter('PERCENTAGE', 'operand', ['GROUP_BY'], args, true);
64
+ if (sumOperand && groupByOperand) {
65
+ throw new ExpressionEvaluationError_1.ExpressionEvaluationError('PERCENTAGE', `expects either a SUM or a GROUP_BY argument`);
66
+ }
67
+ const sumAggregationColumnName = sumOperand
68
+ ? sumOperand.value.aggregationParams.reducers['SUM'].field
69
+ : percentageColumnName;
70
+ const groupByColumnName = groupByOperand
71
+ ? groupByOperand.value
72
+ : (_a = sumOperand === null || sumOperand === void 0 ? void 0 : sumOperand.value.aggregationParams.groupBy) === null || _a === void 0 ? void 0 : _a[0].field;
73
+ const aggregationExpressionEvaluation = {
74
+ aggregationParams: {
75
+ reducers: {
76
+ PERCENTAGE: {
77
+ name: 'PERCENTAGE',
78
+ field: sumAggregationColumnName,
79
+ initialValue: 0,
80
+ reducer: (totalSum, rowValue) => {
81
+ if (!rowValue) {
82
+ return totalSum;
83
+ }
84
+ return totalSum + rowValue;
85
+ },
86
+ },
87
+ },
88
+ },
89
+ rowValueGetter: (rowNode, aggregationValue) => {
90
+ return ((context.api.gridApi.getRawValueFromRowNode(rowNode, percentageColumnName) /
91
+ aggregationValue) *
92
+ 100);
93
+ },
94
+ columnDependencies: [...new Set([percentageColumnName, sumAggregationColumnName])],
95
+ };
96
+ if (groupByColumnName) {
97
+ aggregationExpressionEvaluation.aggregationParams.groupBy = [
98
+ {
99
+ field: groupByColumnName,
100
+ },
101
+ ];
102
+ aggregationExpressionEvaluation.columnDependencies.push(groupByColumnName);
103
+ }
104
+ const result = {
105
+ name: 'PERCENTAGE',
106
+ type: 'aggregation',
107
+ value: aggregationExpressionEvaluation,
108
+ };
109
+ return result;
110
+ },
111
+ description: 'Divides each column value by the aggregated sum of a column\nThe column with the aggregated value and the column with the percentage value do not necessarily have to be identical',
112
+ signatures: [
113
+ 'PERCENTAGE( [colName] )',
114
+ 'PERCENTAGE( [colNameA], GROUP_BY( [colNameB] ))',
115
+ 'PERCENTAGE( [colNameA], SUM ( [colNameB] ))',
116
+ 'PERCENTAGE( [colNameA], SUM ( [colNameB], GROUP_BY( [colNameC] )))',
117
+ ],
118
+ examples: [
119
+ 'PERCENTAGE( [colName] )',
120
+ 'PERCENTAGE( [colNameA], GROUP_BY( [colNameB] ))',
121
+ 'PERCENTAGE( [colNameA], SUM ( [colNameB] ))',
122
+ 'PERCENTAGE( [colNameA], SUM ( [colNameB], GROUP_BY( [colNameC] )))',
123
+ ],
124
+ },
125
+ AVG: {
126
+ handler(args, context) {
127
+ const avgColumnParameter = expressionFunctionUtils_1.extractColumnParameter('AVG', args);
128
+ const avgColumnName = avgColumnParameter.value;
129
+ expressionFunctionUtils_1.validateColumnType(avgColumnName, ['Number'], 'AVG', context.api);
130
+ const groupByParameter = expressionFunctionUtils_1.extractParameter('AVG', 'operand', ['GROUP_BY'], args, true);
131
+ const aggregationExpressionEvaluation = {
132
+ aggregationParams: {
133
+ reducers: {
134
+ SUM: {
135
+ name: 'AVG',
136
+ field: avgColumnName,
137
+ initialValue: 0,
138
+ reducer: (totalSum, rowValue) => {
139
+ if (!rowValue) {
140
+ return totalSum;
141
+ }
142
+ return totalSum + rowValue;
143
+ },
144
+ done: (value, dataArray) => {
145
+ return dataArray.length ? value / dataArray.length : 0;
146
+ },
147
+ },
148
+ },
149
+ },
150
+ columnDependencies: [avgColumnName],
151
+ };
152
+ if (groupByParameter) {
153
+ const groupByColumnName = groupByParameter.value;
154
+ aggregationExpressionEvaluation.aggregationParams.groupBy = [
155
+ {
156
+ field: groupByColumnName,
157
+ },
158
+ ];
159
+ aggregationExpressionEvaluation.columnDependencies.push(groupByColumnName);
160
+ }
161
+ const result = {
162
+ name: 'AVG',
163
+ type: 'aggregation',
164
+ value: aggregationExpressionEvaluation,
165
+ };
166
+ return result;
167
+ },
168
+ description: 'Aggregates a column over multiple rows by computing the average value (arithmetic mean) of the column values\nOptionally the aggregation may be computed within provided individual groups',
169
+ signatures: [
170
+ 'AVG( [colName] )',
171
+ 'AVG( COL(name: string))',
172
+ 'AVG( [colNameA], GROUP_BY( [colNameB] ))',
173
+ 'AVG( COL(nameA: string), GROUP_BY( COL(nameB: string)))',
174
+ ],
175
+ examples: ['AVG([colA])', 'AVG([colA], GROUP_BY([colB]))'],
176
+ },
177
+ MIN: {
178
+ handler(args, context) {
179
+ const minColumnParameter = expressionFunctionUtils_1.extractColumnParameter('MIN', args);
180
+ const minColumnName = minColumnParameter.value;
181
+ expressionFunctionUtils_1.validateColumnType(minColumnName, ['Number'], 'MIN', context.api);
182
+ const groupByParameter = expressionFunctionUtils_1.extractParameter('MIN', 'operand', ['GROUP_BY'], args, true);
183
+ const aggregationExpressionEvaluation = {
184
+ aggregationParams: {
185
+ reducers: {
186
+ SUM: {
187
+ name: 'MIN',
188
+ field: minColumnName,
189
+ initialValue: Number.MAX_VALUE,
190
+ reducer: (minValue, rowValue) => {
191
+ if (!rowValue) {
192
+ return minValue;
193
+ }
194
+ return rowValue < minValue ? rowValue : minValue;
195
+ },
196
+ },
197
+ },
198
+ },
199
+ columnDependencies: [minColumnName],
200
+ };
201
+ if (groupByParameter) {
202
+ const groupByColumnName = groupByParameter.value;
203
+ aggregationExpressionEvaluation.aggregationParams.groupBy = [
204
+ {
205
+ field: groupByColumnName,
206
+ },
207
+ ];
208
+ aggregationExpressionEvaluation.columnDependencies.push(groupByColumnName);
209
+ }
210
+ const result = {
211
+ name: 'MIN',
212
+ type: 'aggregation',
213
+ value: aggregationExpressionEvaluation,
214
+ };
215
+ return result;
216
+ },
217
+ description: 'Aggregates a column over multiple rows by computing the minimum of the column values\nOptionally the aggregation may be computed within provided individual groups',
218
+ signatures: [
219
+ 'MIN( [colName] )',
220
+ 'MIN( COL(name: string))',
221
+ 'MIN( [colNameA], GROUP_BY( [colNameB] ))',
222
+ 'MIN( COL(nameA: string), GROUP_BY( COL(nameB: string)))',
223
+ ],
224
+ examples: ['MIN([colA])', 'MIN([colA], GROUP_BY([colB]))'],
225
+ },
226
+ MAX: {
227
+ handler(args, context) {
228
+ const maxColumnParameter = expressionFunctionUtils_1.extractColumnParameter('MAX', args);
229
+ const maxColumnName = maxColumnParameter.value;
230
+ expressionFunctionUtils_1.validateColumnType(maxColumnName, ['Number'], 'MAX', context.api);
231
+ const groupByParameter = expressionFunctionUtils_1.extractParameter('MAX', 'operand', ['GROUP_BY'], args, true);
232
+ const aggregationExpressionEvaluation = {
233
+ aggregationParams: {
234
+ reducers: {
235
+ SUM: {
236
+ name: 'MAX',
237
+ field: maxColumnName,
238
+ initialValue: Number.MIN_VALUE,
239
+ reducer: (maxValue, rowValue) => {
240
+ if (!rowValue) {
241
+ return maxValue;
242
+ }
243
+ return rowValue > maxValue ? rowValue : maxValue;
244
+ },
245
+ },
246
+ },
247
+ },
248
+ columnDependencies: [maxColumnName],
249
+ };
250
+ if (groupByParameter) {
251
+ const groupByColumnName = groupByParameter.value;
252
+ aggregationExpressionEvaluation.aggregationParams.groupBy = [
253
+ {
254
+ field: groupByColumnName,
255
+ },
256
+ ];
257
+ aggregationExpressionEvaluation.columnDependencies.push(groupByColumnName);
258
+ }
259
+ const result = {
260
+ name: 'MAX',
261
+ type: 'aggregation',
262
+ value: aggregationExpressionEvaluation,
263
+ };
264
+ return result;
265
+ },
266
+ description: 'Aggregates a column over multiple rows by computing the maximum of the column values\nOptionally the aggregation may be computed within provided individual groups',
267
+ signatures: [
268
+ 'MAX( [colName] )',
269
+ 'MAX( COL(name: string))',
270
+ 'MAX( [colNameA], GROUP_BY( [colNameB] ))',
271
+ 'MAX( COL(nameA: string), GROUP_BY( COL(nameB: string)))',
272
+ ],
273
+ examples: ['MIN([colA])', 'MIN([colA], GROUP_BY([colB]))'],
274
+ },
275
+ GROUP_BY: {
276
+ handler(args, context) {
277
+ const columnParameter = expressionFunctionUtils_1.extractColumnParameter('GROUP_BY', args);
278
+ const result = {
279
+ type: 'operand',
280
+ name: 'GROUP_BY',
281
+ value: columnParameter.value,
282
+ };
283
+ return result;
284
+ },
285
+ description: 'Groups an aggregation operation within the rows that have the same value in the specified column',
286
+ signatures: ['GROUP_BY( [colName] )', 'GROUP_BY( COL(name: string))'],
287
+ examples: ['GROUP_BY( [colName] )', `GROUP_BY( COL('colName'))`],
288
+ },
289
+ CUMUL: {
290
+ handler(args, context) {
291
+ var _a;
292
+ const aggregationParameter = expressionFunctionUtils_1.extractParameter('CUMUL', 'aggregation', ['SUM', 'MIN', 'MAX', 'PERCENTAGE', 'AVG'], args);
293
+ if (aggregationParameter.name === 'AVG' || aggregationParameter.name === 'PERCENTAGE') {
294
+ throw new ExpressionEvaluationError_1.ExpressionEvaluationError('CUMUL', `supports only following aggregations: SUM, MIN, MAX`);
295
+ }
296
+ if ((_a = aggregationParameter.value.aggregationParams.groupBy) === null || _a === void 0 ? void 0 : _a.length) {
297
+ throw new ExpressionEvaluationError_1.ExpressionEvaluationError('CUMUL', `supports only aggregations without any grouping (GROUP_BY clauses)`);
298
+ }
299
+ const overColumnParameter = expressionFunctionUtils_1.extractParameter('CUMUL', 'operand', ['OVER'], args);
300
+ aggregationParameter.value.cumulateOver = overColumnParameter.value;
301
+ const result = {
302
+ name: 'CUMUL',
303
+ type: 'aggregation',
304
+ value: aggregationParameter.value,
305
+ };
306
+ return result;
307
+ },
308
+ description: 'Performs a cumulative aggregation (running total) with the given aggregation operation over a provided column',
309
+ signatures: ['CUMUL( aggregationOp: SUM|MIN|MAX, OVER( [colNameB] ))'],
310
+ examples: [
311
+ 'CUMUL( SUM([colNameA]), OVER( [colNameB] ))',
312
+ 'CUMUL( MIN([colNameA]), OVER( [colNameB] ))',
313
+ 'CUMUL( MAX([colNameA]), OVER( [colNameB] ))',
314
+ ],
315
+ },
316
+ OVER: {
317
+ handler(args, context) {
318
+ const columnParameter = expressionFunctionUtils_1.extractColumnParameter('OVER', args);
319
+ expressionFunctionUtils_1.validateColumnType(columnParameter.value, ['Number', 'Date'], 'OVER', context.api);
320
+ const result = {
321
+ type: 'operand',
322
+ name: 'OVER',
323
+ value: columnParameter.value,
324
+ };
325
+ return result;
326
+ },
327
+ description: 'Defines an accumulative dimension (order) for the enclosing cumulative aggregation',
328
+ signatures: ['OVER( [colName] )', 'OVER( COL(name: string))'],
329
+ examples: ['OVER( [colName] )', `OVER( COL('colName'))`],
330
+ },
331
+ COL: {
332
+ handler(args, context) {
333
+ return expressionFunctionUtils_1.handleColumnFunction(args, context);
334
+ },
335
+ description: 'References a column by its unique identifier',
336
+ signatures: ['[colName]', 'COL(name: string)'],
337
+ examples: ['[col1]', 'COL("col1")'],
338
+ },
339
+ };
@@ -0,0 +1,35 @@
1
+ declare type VoidFn = () => void;
2
+ declare type Pair<KeyType, ValueType> = {
3
+ value?: ValueType;
4
+ map?: Map<KeyType, Pair<KeyType, ValueType>>;
5
+ revision?: number;
6
+ };
7
+ export declare type DeepMapVisitFn<KeyType, ValueType> = (pair: Pair<KeyType, ValueType>, keys: KeyType[], next: VoidFn) => void;
8
+ export declare class DeepMap<KeyType, ValueType> {
9
+ private map;
10
+ private length;
11
+ private revision;
12
+ static clone<KeyType, ValueType>(map: DeepMap<KeyType, ValueType>): DeepMap<KeyType, ValueType>;
13
+ constructor(initial?: [KeyType[], ValueType][]);
14
+ set(keys: KeyType[] & {
15
+ length: Omit<number, 0>;
16
+ }, value: ValueType): this;
17
+ get(keys: KeyType[]): ValueType | undefined;
18
+ get size(): number;
19
+ clear(): void;
20
+ delete(keys: KeyType[]): boolean;
21
+ has(keys: KeyType[]): boolean;
22
+ private visitKey;
23
+ visit: (fn: DeepMapVisitFn<KeyType, ValueType>) => void;
24
+ visitDepthFirst: (fn: (value: ValueType, keys: KeyType[], indexInGroup: number, next?: VoidFn) => void) => void;
25
+ private visitWithNext;
26
+ private getArray;
27
+ values(): Generator<ValueType, void, unknown>;
28
+ keys(): Generator<KeyType[], void, unknown>;
29
+ entries(): Generator<[KeyType[], ValueType], void, unknown>;
30
+ topDownEntries(): [KeyType[], ValueType][];
31
+ topDownKeys(): KeyType[][];
32
+ topDownValues(): ValueType[];
33
+ private sortedIterator;
34
+ }
35
+ export {};