@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.
- package/agGrid.d.ts +5 -4
- package/agGrid.js +9 -7
- package/base.css +2 -2
- package/bundle.cjs.js +103 -98
- package/index.css +2 -2
- package/package.json +1 -1
- package/publishTimestamp.d.ts +1 -1
- package/publishTimestamp.js +1 -1
- package/src/AdaptableInterfaces/IAdaptable.d.ts +1 -0
- package/src/AdaptableOptions/AdaptableOptions.d.ts +4 -6
- package/src/AdaptableOptions/{QueryLanguageOptions.d.ts → AdaptableQLOptions.d.ts} +37 -5
- package/src/AdaptableOptions/{QueryLanguageOptions.js → AdaptableQLOptions.js} +0 -0
- package/src/AdaptableOptions/ContainerOptions.d.ts +1 -1
- package/src/AdaptableOptions/GeneralOptions.d.ts +0 -7
- package/src/AdaptableOptions/SearchOptions.d.ts +0 -9
- package/src/AdaptableOptions/SettingsPanelOptions.d.ts +4 -3
- package/src/AdaptableOptions/StateOptions.d.ts +7 -7
- package/src/AdaptableOptions/UserInterfaceOptions.d.ts +1 -1
- package/src/Api/AdaptableApi.d.ts +5 -0
- package/src/Api/CalculatedColumnApi.d.ts +2 -9
- package/src/Api/ColumnApi.d.ts +0 -4
- package/src/Api/GridApi.d.ts +11 -1
- package/src/Api/Implementation/AdaptableApiImpl.d.ts +2 -1
- package/src/Api/Implementation/AdaptableApiImpl.js +2 -0
- package/src/Api/Implementation/AlertApiImpl.js +4 -1
- package/src/Api/Implementation/ApiBase.d.ts +3 -2
- package/src/Api/Implementation/ApiBase.js +5 -2
- package/src/Api/Implementation/CalculatedColumnApiImpl.js +3 -4
- package/src/Api/Implementation/ColumnApiImpl.d.ts +0 -1
- package/src/Api/Implementation/ColumnApiImpl.js +0 -5
- package/src/Api/Implementation/GridApiImpl.d.ts +2 -0
- package/src/Api/Implementation/GridApiImpl.js +27 -4
- package/src/Api/Implementation/InternalApiImpl.d.ts +2 -3
- package/src/Api/Implementation/InternalApiImpl.js +5 -4
- package/src/Api/Implementation/QueryLanguageApiImpl.d.ts +4 -1
- package/src/Api/Implementation/QueryLanguageApiImpl.js +17 -4
- package/src/Api/Implementation/SettingsPanelApiImpl.d.ts +7 -0
- package/src/Api/Implementation/SettingsPanelApiImpl.js +15 -0
- package/src/Api/InternalApi.d.ts +2 -3
- package/src/Api/QueryApi.d.ts +2 -2
- package/src/Api/QueryLanguageApi.d.ts +23 -10
- package/src/Api/SettingsPanelApi.d.ts +16 -0
- package/src/Api/SettingsPanelApi.js +2 -0
- package/src/PredefinedConfig/AlertState.d.ts +6 -2
- package/src/PredefinedConfig/CalculatedColumnState.d.ts +8 -3
- package/src/PredefinedConfig/Common/AdaptableFormat.d.ts +3 -0
- package/src/PredefinedConfig/Common/AdaptableQuery.d.ts +7 -5
- package/src/PredefinedConfig/Common/AdaptableQuery.js +2 -6
- package/src/PredefinedConfig/Common/Enums.d.ts +0 -1
- package/src/PredefinedConfig/Common/Enums.js +0 -2
- package/src/PredefinedConfig/Common/SpecialColumnSettings.d.ts +1 -1
- package/src/PredefinedConfig/Common/Types.d.ts +6 -1
- package/src/PredefinedConfig/Common/Types.js +1 -0
- package/src/PredefinedConfig/ConditionalStyleState.d.ts +2 -2
- package/src/PredefinedConfig/FormatColumnState.d.ts +15 -0
- package/src/PredefinedConfig/Selection/GridCellRange.d.ts +3 -1
- package/src/PredefinedConfig/ToolPanelState.d.ts +3 -0
- package/src/Redux/Store/AdaptableReduxMerger.js +1 -1
- package/src/Redux/Store/AdaptableStore.js +27 -2
- package/src/Strategy/AlertModule.js +12 -3
- package/src/Strategy/CalculatedColumnModule.js +4 -4
- package/src/Strategy/ChartingModule.d.ts +3 -3
- package/src/Strategy/ChartingModule.js +2 -2
- package/src/Strategy/FlashingCellModule.js +2 -2
- package/src/Strategy/FreeTextColumnModule.js +1 -0
- package/src/Strategy/{SetingsPanelModule.d.ts → SettingsPanelModule.d.ts} +0 -0
- package/src/Strategy/{SetingsPanelModule.js → SettingsPanelModule.js} +0 -0
- package/src/Strategy/Utilities/getAlertPreviewViewItems.js +1 -1
- package/src/Strategy/Utilities/getExpressionViewItems.d.ts +2 -2
- package/src/Strategy/Utilities/getExpressionViewItems.js +2 -1
- package/src/Strategy/Utilities/getRuleViewItems.js +1 -2
- package/src/Utilities/Constants/DocumentationLinkConstants.d.ts +3 -2
- package/src/Utilities/Constants/DocumentationLinkConstants.js +12 -10
- package/src/Utilities/Defaults/DefaultAdaptableOptions.js +17 -13
- package/src/Utilities/ExpressionFunctions/{aggregationExpressionFunctions.d.ts → aggregatedBooleanExpressionFunctions.d.ts} +1 -1
- package/src/Utilities/ExpressionFunctions/{aggregationExpressionFunctions.js → aggregatedBooleanExpressionFunctions.js} +4 -4
- package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +24 -0
- package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +339 -0
- package/src/Utilities/ExpressionFunctions/deepMap.d.ts +35 -0
- package/src/Utilities/ExpressionFunctions/deepMap.js +283 -0
- package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.d.ts +2 -2
- package/src/Utilities/ExpressionFunctions/expressionFunctionUtils.js +8 -8
- package/src/Utilities/ExpressionFunctions/groupingMap.d.ts +35 -0
- package/src/Utilities/ExpressionFunctions/groupingMap.js +105 -0
- package/src/Utilities/ExpressionFunctions/observableExpressionFunctions.js +3 -2
- package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.d.ts +33 -0
- package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.js +154 -0
- package/src/Utilities/Helpers/AdaptableHelper.js +2 -1
- package/src/Utilities/Services/AlertService.js +8 -4
- package/src/Utilities/Services/CalculatedColumnExpressionService.d.ts +7 -3
- package/src/Utilities/Services/CalculatedColumnExpressionService.js +143 -18
- package/src/Utilities/Services/Interface/IAdaptableService.d.ts +1 -1
- package/src/Utilities/Services/Interface/ICalculatedColumnExpressionService.d.ts +6 -3
- package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +9 -3
- package/src/Utilities/Services/LicenseService.js +1 -1
- package/src/Utilities/Services/ModuleService.js +33 -40
- package/src/Utilities/Services/QueryLanguageService.d.ts +11 -4
- package/src/Utilities/Services/QueryLanguageService.js +84 -25
- package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationForm.js +5 -3
- package/src/View/AdaptableWizardView/helper.js +2 -2
- package/src/View/Alert/Wizard/AlertDisplayWizardSection.d.ts +1 -0
- package/src/View/Alert/Wizard/AlertDisplayWizardSection.js +2 -2
- package/src/View/Alert/Wizard/AlertWizard.js +2 -2
- package/src/View/Alert/Wizard/BaseAlertRulesWizardSection.js +2 -2
- package/src/View/Alert/Wizard/BaseAlertScopeWizardSection.js +3 -2
- package/src/View/Alert/Wizard/isValidAlertRules.js +3 -3
- package/src/View/CalculatedColumn/CalculatedColumnSharedEntity.js +3 -3
- package/src/View/CalculatedColumn/CalculatedColumnSummary.js +2 -4
- package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +43 -12
- package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.js +1 -2
- package/src/View/CalculatedColumn/Wizard/CalculatedColumnWizard.js +2 -2
- package/src/View/ColorPicker.d.ts +1 -1
- package/src/View/Components/AdaptableDateInput/index.d.ts +1 -1
- package/src/View/Components/AdaptableInput/index.d.ts +1 -1
- package/src/View/Components/Buttons/ButtonDelete.d.ts +1 -1
- package/src/View/Components/EntityRulesEditor/index.js +11 -12
- package/src/View/Components/Forms/AdaptableFormControlTextClear.d.ts +1 -1
- package/src/View/Components/Panels/PanelWithImage.d.ts +1 -1
- package/src/View/Components/Popups/AdaptablePopup/AdaptablePopup.js +4 -8
- package/src/View/Components/Popups/AdaptablePopup/useMenuItems.js +1 -2
- package/src/View/Components/Popups/AdaptablePopupAlert.d.ts +1 -0
- package/src/View/Components/Popups/AdaptablePopupAlert.js +1 -1
- package/src/View/Components/ValueSelector/index.js +1 -1
- package/src/View/ConditionalStyle/Wizard/ConditionalStyleRuleWizardSection.js +2 -2
- package/src/View/CustomSort/Wizard/CustomSortWizard.js +1 -1
- package/src/View/FlashingCell/Wizard/FlashingCellRulesWizardSection.js +2 -2
- package/src/View/FlashingCell/Wizard/FlashingCellWizard.js +1 -1
- package/src/View/FormatColumn/Wizard/FormatColumnWizard.js +1 -1
- package/src/View/Layout/Wizard/LayoutEditor/index.js +1 -1
- package/src/View/License/LicenseWatermark.js +1 -1
- package/src/View/Query/Wizard/NamedQueryWizard.js +3 -3
- package/src/View/Schedule/Wizard/ScheduleWizard.js +3 -3
- package/src/agGrid/Adaptable.d.ts +1 -0
- package/src/agGrid/Adaptable.js +13 -14
- package/src/agGrid/agGridHelper.js +3 -7
- package/src/components/AdaptableFormComponent/AdaptableFormComponent.d.ts +4 -2
- package/src/components/AdaptableFormComponent/AdaptableFormComponent.js +4 -4
- package/src/components/Datepicker/index.d.ts +1 -1
- package/src/components/ExpressionEditor/EditorInput.d.ts +1 -1
- package/src/components/ExpressionEditor/EditorInput.js +5 -2
- package/src/components/ExpressionEditor/EditorInputReactive.d.ts +1 -1
- package/src/components/ExpressionEditor/EditorInputReactive.js +1 -1
- package/src/components/ExpressionEditor/ExpressionFunctionDocumentation.js +1 -1
- package/src/components/ExpressionEditor/editorButtonsAggregatedScalar.d.ts +2 -0
- package/src/components/ExpressionEditor/editorButtonsAggregatedScalar.js +45 -0
- package/src/components/ExpressionEditor/editorButtonsReactive.js +8 -13
- package/src/components/ExpressionEditor/index.d.ts +2 -1
- package/src/components/ExpressionEditor/index.js +11 -4
- package/src/components/Input/index.d.ts +1 -1
- package/src/components/List/ListGroupItem/index.d.ts +1 -1
- package/src/components/Logo/index.js +8 -7
- package/src/components/PopupWithFooter.d.ts +1 -1
- package/src/components/Textarea/index.d.ts +1 -1
- package/src/components/icons/calculated-column.js +2 -1
- package/src/metamodel/adaptable.metamodel.d.ts +233 -37
- package/src/metamodel/adaptable.metamodel.js +448 -149
- package/src/types.d.ts +5 -4
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeepMap = void 0;
|
|
4
|
+
const SORT_ASC_REVISION = (p1, p2) => sortAscending(p1.revision, p2.revision);
|
|
5
|
+
class DeepMap {
|
|
6
|
+
constructor(initial) {
|
|
7
|
+
this.map = new Map();
|
|
8
|
+
this.length = 0;
|
|
9
|
+
this.revision = 0;
|
|
10
|
+
this.visit = (fn) => {
|
|
11
|
+
this.map.forEach((_, k) => this.visitKey(k, this.map, [], fn));
|
|
12
|
+
};
|
|
13
|
+
this.visitDepthFirst = (fn) => {
|
|
14
|
+
this.visitWithNext([], fn);
|
|
15
|
+
};
|
|
16
|
+
this.visitWithNext = (parentKeys, fn, currentMap = this.map) => {
|
|
17
|
+
if (!currentMap) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let i = 0;
|
|
21
|
+
currentMap.forEach((_, key) => {
|
|
22
|
+
const pair = currentMap.get(key);
|
|
23
|
+
if (!pair) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const { map } = pair;
|
|
27
|
+
const keys = [...parentKeys, key];
|
|
28
|
+
const next = map ? () => this.visitWithNext(keys, fn, map) : undefined;
|
|
29
|
+
if (pair.hasOwnProperty('value')) {
|
|
30
|
+
fn(pair.value, keys, i, next);
|
|
31
|
+
i++;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
next === null || next === void 0 ? void 0 : next();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
if (initial) {
|
|
39
|
+
initial.forEach((entry) => {
|
|
40
|
+
const [keys, value] = entry;
|
|
41
|
+
this.set(keys, value);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
static clone(map) {
|
|
46
|
+
const clone = new DeepMap();
|
|
47
|
+
map.visit((pair, keys) => {
|
|
48
|
+
clone.set(keys, pair.value);
|
|
49
|
+
});
|
|
50
|
+
return clone;
|
|
51
|
+
}
|
|
52
|
+
set(keys, value) {
|
|
53
|
+
let currentMap = this.map;
|
|
54
|
+
if (!keys.length) {
|
|
55
|
+
throw `Cannot set given keys - please provide a non-empty keys array.`;
|
|
56
|
+
// currentMap.set((EMPTY_KEY as unknown) as K, { value });
|
|
57
|
+
// this.length++;
|
|
58
|
+
// return this;
|
|
59
|
+
}
|
|
60
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
61
|
+
const key = keys[i];
|
|
62
|
+
const last = i === len - 1;
|
|
63
|
+
if (last) {
|
|
64
|
+
const pair = currentMap.has(key) ? currentMap.get(key) : {};
|
|
65
|
+
pair.revision = this.revision++;
|
|
66
|
+
pair.value = value;
|
|
67
|
+
currentMap.set(key, pair);
|
|
68
|
+
this.length++;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const pair = currentMap.has(key) ? currentMap.get(key) : {};
|
|
72
|
+
if (!pair.map) {
|
|
73
|
+
pair.map = new Map();
|
|
74
|
+
currentMap.set(key, pair);
|
|
75
|
+
}
|
|
76
|
+
currentMap = pair.map;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
get(keys) {
|
|
82
|
+
var _a;
|
|
83
|
+
let currentMap = this.map;
|
|
84
|
+
if (!keys.length) {
|
|
85
|
+
throw `Cannot get given keys - please provide a non-empty keys array.`;
|
|
86
|
+
// return currentMap.get((EMPTY_KEY as unknown) as K)?.value;
|
|
87
|
+
}
|
|
88
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
89
|
+
const key = keys[i];
|
|
90
|
+
const last = i === len - 1;
|
|
91
|
+
if (last) {
|
|
92
|
+
return (_a = currentMap.get(key)) === null || _a === void 0 ? void 0 : _a.value;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const pair = currentMap.get(key);
|
|
96
|
+
if (!pair || !pair.map) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
currentMap = pair.map;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
get size() {
|
|
105
|
+
return this.length;
|
|
106
|
+
}
|
|
107
|
+
clear() {
|
|
108
|
+
const clearMap = (map) => {
|
|
109
|
+
map.forEach((value, _key) => {
|
|
110
|
+
const { map } = value;
|
|
111
|
+
if (map) {
|
|
112
|
+
clearMap(map);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
map.clear();
|
|
116
|
+
};
|
|
117
|
+
clearMap(this.map);
|
|
118
|
+
this.length = 0;
|
|
119
|
+
this.revision = 0;
|
|
120
|
+
}
|
|
121
|
+
delete(keys) {
|
|
122
|
+
keys = [...keys];
|
|
123
|
+
let currentMap = this.map;
|
|
124
|
+
if (!keys.length) {
|
|
125
|
+
throw `Cannot delete given keys - please provide a non-empty keys array.`;
|
|
126
|
+
// if (currentMap.has(EMPTY_KEY as unknown as K)) {
|
|
127
|
+
// this.length--;
|
|
128
|
+
// }
|
|
129
|
+
// return currentMap.delete((EMPTY_KEY as unknown) as K);
|
|
130
|
+
}
|
|
131
|
+
let maps = [currentMap];
|
|
132
|
+
let result = false;
|
|
133
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
134
|
+
const key = keys[i];
|
|
135
|
+
const last = i === len - 1;
|
|
136
|
+
if (last) {
|
|
137
|
+
const pair = currentMap.get(key);
|
|
138
|
+
if (pair) {
|
|
139
|
+
if (pair.hasOwnProperty('value')) {
|
|
140
|
+
delete pair.value;
|
|
141
|
+
delete pair.revision;
|
|
142
|
+
result = true;
|
|
143
|
+
this.length--;
|
|
144
|
+
}
|
|
145
|
+
if (pair.map && pair.map.size === 0) {
|
|
146
|
+
delete pair.map;
|
|
147
|
+
}
|
|
148
|
+
if (!pair.map) {
|
|
149
|
+
// pair is empty, so we can remove it altogether
|
|
150
|
+
currentMap.delete(key);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const pair = currentMap.get(key);
|
|
157
|
+
if (!pair || !pair.map) {
|
|
158
|
+
result = false;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
currentMap = pair.map;
|
|
162
|
+
maps.push(currentMap);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
while (maps.length) {
|
|
166
|
+
let map = maps.pop();
|
|
167
|
+
let key = keys.pop();
|
|
168
|
+
if (key && (map === null || map === void 0 ? void 0 : map.size) === 0) {
|
|
169
|
+
let parentMap = maps[maps.length - 1];
|
|
170
|
+
let pair = parentMap === null || parentMap === void 0 ? void 0 : parentMap.get(key);
|
|
171
|
+
if (pair) {
|
|
172
|
+
// pair.map === map ; which can be deleted
|
|
173
|
+
delete pair.map;
|
|
174
|
+
if (!pair.hasOwnProperty('value')) {
|
|
175
|
+
// whole pair can be successfully deleted from parentMap
|
|
176
|
+
parentMap.delete(key);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
has(keys) {
|
|
184
|
+
let currentMap = this.map;
|
|
185
|
+
if (!keys.length) {
|
|
186
|
+
throw `Cannot find existing given keys - please provide a non-empty keys array.`;
|
|
187
|
+
// return (
|
|
188
|
+
// currentMap.has((EMPTY_KEY as unknown) as K) &&
|
|
189
|
+
// currentMap.get((EMPTY_KEY as unknown) as K)?.value !== undefined
|
|
190
|
+
// );
|
|
191
|
+
}
|
|
192
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
193
|
+
const key = keys[i];
|
|
194
|
+
const last = i === len - 1;
|
|
195
|
+
if (last) {
|
|
196
|
+
const pair = currentMap.get(key);
|
|
197
|
+
return !!pair && pair.hasOwnProperty('value');
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const pair = currentMap.get(key);
|
|
201
|
+
if (!pair || !pair.map) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
currentMap = pair.map;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
visitKey(key, currentMap, parentKeys, fn) {
|
|
210
|
+
const pair = currentMap.get(key);
|
|
211
|
+
if (!pair) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const { map } = pair;
|
|
215
|
+
const keys = [...parentKeys, key];
|
|
216
|
+
const next = once(() => {
|
|
217
|
+
if (map) {
|
|
218
|
+
map.forEach((_, k) => {
|
|
219
|
+
this.visitKey(k, map, keys, fn);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
if (pair.hasOwnProperty('value')) {
|
|
224
|
+
fn(pair, keys, next);
|
|
225
|
+
}
|
|
226
|
+
// if it was called by fn, it won't be called again, as it's once-d
|
|
227
|
+
next();
|
|
228
|
+
}
|
|
229
|
+
getArray(fn) {
|
|
230
|
+
const result = [];
|
|
231
|
+
this.visit((pair, keys) => {
|
|
232
|
+
result.push(fn(Object.assign(Object.assign({}, pair), { keys })));
|
|
233
|
+
});
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
values() {
|
|
237
|
+
return this.sortedIterator((pair) => pair.value);
|
|
238
|
+
}
|
|
239
|
+
keys() {
|
|
240
|
+
const keys = this.sortedIterator((pair) => pair.keys);
|
|
241
|
+
return keys;
|
|
242
|
+
}
|
|
243
|
+
entries() {
|
|
244
|
+
return this.sortedIterator((pair) => [pair.keys, pair.value]);
|
|
245
|
+
}
|
|
246
|
+
topDownEntries() {
|
|
247
|
+
return this.getArray((pair) => [pair.keys, pair.value]);
|
|
248
|
+
}
|
|
249
|
+
topDownKeys() {
|
|
250
|
+
return this.getArray((pair) => pair.keys);
|
|
251
|
+
}
|
|
252
|
+
topDownValues() {
|
|
253
|
+
return this.getArray((pair) => pair.value);
|
|
254
|
+
}
|
|
255
|
+
sortedIterator(fn) {
|
|
256
|
+
const result = [];
|
|
257
|
+
this.visit((pair, keys) => {
|
|
258
|
+
result.push(Object.assign(Object.assign({}, pair), { keys }));
|
|
259
|
+
});
|
|
260
|
+
result.sort(SORT_ASC_REVISION);
|
|
261
|
+
function* makeIterator() {
|
|
262
|
+
for (let i = 0, len = result.length; i < len; i++) {
|
|
263
|
+
yield fn(result[i]);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return makeIterator();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
exports.DeepMap = DeepMap;
|
|
270
|
+
function once(fn) {
|
|
271
|
+
let called = false;
|
|
272
|
+
let result = null;
|
|
273
|
+
const onceFn = () => {
|
|
274
|
+
if (called) {
|
|
275
|
+
return result;
|
|
276
|
+
}
|
|
277
|
+
called = true;
|
|
278
|
+
result = fn();
|
|
279
|
+
return result;
|
|
280
|
+
};
|
|
281
|
+
return onceFn;
|
|
282
|
+
}
|
|
283
|
+
const sortAscending = (a, b) => a - b;
|
|
@@ -14,8 +14,8 @@ export declare const getStringValue: (context: ExpressionContext, stringArgument
|
|
|
14
14
|
export declare const isTextSearchCaseInsensitive: (context: ExpressionContext) => boolean;
|
|
15
15
|
export declare const getDataChangeLog$: (context: ExpressionContext, columnNameFilter: string) => Observable<DataChangedInfo>;
|
|
16
16
|
export declare const handleWhereFunction: (args: any[], context: ExpressionContext) => any;
|
|
17
|
-
export declare const extractColumnParameter: (consumingFunctionName: string, args: BaseParameter[]
|
|
18
|
-
export declare const extractParameter: <T extends BaseParameter<string, string>>(consumingFunctionName: string, allowedType:
|
|
17
|
+
export declare const extractColumnParameter: (consumingFunctionName: string, args: BaseParameter[]) => ColumnParameter;
|
|
18
|
+
export declare const extractParameter: <T extends BaseParameter<string, string>>(consumingFunctionName: string, allowedType: T["type"], allowedOperands: T["name"][], args: BaseParameter[], isOptional?: boolean) => T;
|
|
19
19
|
export declare const handleColumnFunction: (args: any[], context: ExpressionContext) => ColumnParameter;
|
|
20
20
|
export declare const getNumericValue: (input: unknown) => number;
|
|
21
21
|
export declare const validateColumnType: (columnId: string, validColumnTypes: ('Number' | 'String' | 'Date')[], consumingFunction: string, api: AdaptableApi) => void;
|
|
@@ -49,19 +49,19 @@ exports.handleWhereFunction = (args, context) => {
|
|
|
49
49
|
filterFn,
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
-
exports.extractColumnParameter = (consumingFunctionName, args
|
|
53
|
-
|
|
54
|
-
if (validateType) {
|
|
55
|
-
}
|
|
56
|
-
return result;
|
|
52
|
+
exports.extractColumnParameter = (consumingFunctionName, args) => {
|
|
53
|
+
return exports.extractParameter(consumingFunctionName, 'config', ['COL'], args);
|
|
57
54
|
};
|
|
58
|
-
exports.extractParameter = (consumingFunctionName, allowedType, allowedOperands, args
|
|
55
|
+
exports.extractParameter = (consumingFunctionName, allowedType, allowedOperands, args, isOptional) => {
|
|
59
56
|
const result = args.filter((arg) => (arg === null || arg === void 0 ? void 0 : arg.type) === allowedType && allowedOperands.includes(arg === null || arg === void 0 ? void 0 : arg.name));
|
|
57
|
+
if (isOptional && !result.length) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
60
|
if (result.length > 1) {
|
|
61
|
-
throw new ExpressionEvaluationError_1.ExpressionEvaluationError(consumingFunctionName, `expects only 1 argument of type '${[...new Set(result.map((op) => op.name))].join(' / ')}'`);
|
|
61
|
+
throw new ExpressionEvaluationError_1.ExpressionEvaluationError(consumingFunctionName, `expects only 1 argument of type '${[...new Set(result.map((op) => op.name))].join(`' / '`)}'`);
|
|
62
62
|
}
|
|
63
63
|
if (!result.length) {
|
|
64
|
-
throw new ExpressionEvaluationError_1.ExpressionEvaluationError(consumingFunctionName, `expects an argument of type '${allowedOperands.join(' / ')}'`);
|
|
64
|
+
throw new ExpressionEvaluationError_1.ExpressionEvaluationError(consumingFunctionName, `expects an argument of type '${allowedOperands.join(`' / '`)}'`);
|
|
65
65
|
}
|
|
66
66
|
return result[0];
|
|
67
67
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DeepMap } from './deepMap';
|
|
2
|
+
export declare type GroupKeyType<T extends any = any> = T;
|
|
3
|
+
export declare type GroupBy<DataType, KeyType> = {
|
|
4
|
+
field: keyof DataType;
|
|
5
|
+
toKey?: (value: any, data: DataType) => GroupKeyType<KeyType>;
|
|
6
|
+
};
|
|
7
|
+
export declare type GroupParams<DataType, KeyType> = {
|
|
8
|
+
groupBy: GroupBy<DataType, KeyType>[];
|
|
9
|
+
defaultToKey?: (value: any, item: DataType) => GroupKeyType<KeyType>;
|
|
10
|
+
reducers?: Record<string, DataSourceAggregationReducer<DataType, any>>;
|
|
11
|
+
};
|
|
12
|
+
export declare type DataSourceAggregationReducer<T, AggregationResultType> = {
|
|
13
|
+
name?: string;
|
|
14
|
+
field?: keyof T;
|
|
15
|
+
initialValue?: AggregationResultType;
|
|
16
|
+
getter?: (data: T) => any;
|
|
17
|
+
reducer: string | ((accumulator: any, value: any, data: T) => AggregationResultType | any);
|
|
18
|
+
done?: (accumulatedValue: AggregationResultType | any, array: T[]) => AggregationResultType;
|
|
19
|
+
};
|
|
20
|
+
export declare type DataGroupResult<DataType, KeyType extends any> = {
|
|
21
|
+
deepMap: DeepMap<GroupKeyType<KeyType>, DeepMapGroupValueType<DataType, KeyType>>;
|
|
22
|
+
groupParams: GroupParams<DataType, KeyType>;
|
|
23
|
+
initialData: DataType[];
|
|
24
|
+
reducerResults?: Record<string, any>;
|
|
25
|
+
};
|
|
26
|
+
export declare type DeepMapGroupValueType<DataType, KeyType> = {
|
|
27
|
+
items: DataType[];
|
|
28
|
+
commonData?: Partial<DataType>;
|
|
29
|
+
reducerResults: Record<string, any>;
|
|
30
|
+
};
|
|
31
|
+
export declare type AggregationReducerResult<AggregationResultType extends any = any> = {
|
|
32
|
+
value: AggregationResultType;
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function group<DataType, KeyType = any>(groupParams: GroupParams<DataType, KeyType>, data: DataType[]): DataGroupResult<DataType, KeyType>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.group = void 0;
|
|
4
|
+
const deepMap_1 = require("./deepMap");
|
|
5
|
+
function DEFAULT_TO_KEY(value) {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
function group(groupParams, data) {
|
|
9
|
+
const { groupBy, defaultToKey = DEFAULT_TO_KEY, reducers } = groupParams;
|
|
10
|
+
const groupByLength = groupBy.length;
|
|
11
|
+
const deepMap = new deepMap_1.DeepMap();
|
|
12
|
+
let currentGroupKeys = [];
|
|
13
|
+
const initialReducerValue = initReducers(reducers);
|
|
14
|
+
const globalReducerResults = Object.assign({}, initialReducerValue);
|
|
15
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
|
16
|
+
let item = data[i];
|
|
17
|
+
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
18
|
+
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
19
|
+
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
20
|
+
currentGroupKeys.push(key);
|
|
21
|
+
if (!deepMap.has(currentGroupKeys)) {
|
|
22
|
+
const deepMapGroupValue = {
|
|
23
|
+
items: [],
|
|
24
|
+
reducerResults: Object.assign({}, initialReducerValue),
|
|
25
|
+
};
|
|
26
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
27
|
+
}
|
|
28
|
+
const { items: currentGroupItems, reducerResults } = deepMap.get(currentGroupKeys);
|
|
29
|
+
currentGroupItems.push(item);
|
|
30
|
+
if (reducers) {
|
|
31
|
+
computeReducersFor(item, reducers, reducerResults);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (reducers) {
|
|
35
|
+
computeReducersFor(item, reducers, globalReducerResults);
|
|
36
|
+
}
|
|
37
|
+
currentGroupKeys.length = 0;
|
|
38
|
+
}
|
|
39
|
+
const hasReducersWithDoneFn = reducers && Object.values(reducers).some((reducer) => reducer.done);
|
|
40
|
+
if (hasReducersWithDoneFn) {
|
|
41
|
+
deepMap.visitDepthFirst((deepMapValue, _keys, _indexInGroup, next) => {
|
|
42
|
+
completeReducers(reducers, deepMapValue.reducerResults, deepMapValue.items);
|
|
43
|
+
next === null || next === void 0 ? void 0 : next();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (hasReducersWithDoneFn) {
|
|
47
|
+
completeReducers(reducers, globalReducerResults, data);
|
|
48
|
+
}
|
|
49
|
+
const result = {
|
|
50
|
+
deepMap,
|
|
51
|
+
groupParams,
|
|
52
|
+
initialData: data,
|
|
53
|
+
reducerResults: globalReducerResults,
|
|
54
|
+
};
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
exports.group = group;
|
|
58
|
+
function initReducers(reducers) {
|
|
59
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
const result = {};
|
|
63
|
+
for (let key in reducers)
|
|
64
|
+
if (reducers.hasOwnProperty(key)) {
|
|
65
|
+
result[key] = reducers[key].initialValue;
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* This fn mutates the reducerResults array!!!
|
|
72
|
+
*
|
|
73
|
+
* @param data data item
|
|
74
|
+
* @param reducers an array of reducers
|
|
75
|
+
* @param reducerResults the results on which to operate
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
function computeReducersFor(data, reducers, reducerResults) {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
for (let key in reducers)
|
|
84
|
+
if (reducers.hasOwnProperty(key)) {
|
|
85
|
+
const reducer = reducers[key];
|
|
86
|
+
if (typeof reducer.reducer !== 'function') {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const currentValue = reducerResults[key];
|
|
90
|
+
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) === null || _a === void 0 ? void 0 : _a.call(reducer, data)) !== null && _b !== void 0 ? _b : null;
|
|
91
|
+
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function completeReducers(reducers, reducerResults, items) {
|
|
95
|
+
if (reducers) {
|
|
96
|
+
for (let key in reducers)
|
|
97
|
+
if (reducers.hasOwnProperty(key)) {
|
|
98
|
+
const reducer = reducers[key];
|
|
99
|
+
if (reducer.done) {
|
|
100
|
+
reducerResults[key] = reducer.done(reducerResults[key], items);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return reducerResults;
|
|
105
|
+
}
|
|
@@ -105,7 +105,7 @@ exports.observableExpressionFunctions = {
|
|
|
105
105
|
handler(args, context) {
|
|
106
106
|
return expressionFunctionUtils_1.handleColumnFunction(args, context);
|
|
107
107
|
},
|
|
108
|
-
description: 'References a
|
|
108
|
+
description: 'References a column by its unique identifier',
|
|
109
109
|
signatures: ['[colName]', 'COL(name: string)'],
|
|
110
110
|
examples: ['[col1]', "COL('col1')"],
|
|
111
111
|
},
|
|
@@ -417,7 +417,8 @@ const getSlidingTimeframe$ = (source$, timeframeDuration, onTimeframeEnter, onTi
|
|
|
417
417
|
}));
|
|
418
418
|
};
|
|
419
419
|
const getMaxTimeframeSize = (expressionValue, context) => {
|
|
420
|
-
let maxTimeframeSize = context.api.internalApi.getAdaptableOptions().
|
|
420
|
+
let maxTimeframeSize = context.api.internalApi.getAdaptableOptions().adaptableQLOptions.expressionOptions
|
|
421
|
+
.maxTimeframeSize;
|
|
421
422
|
if (maxTimeframeSize > SYSTEM_MAX_TIMEFRAME_SIZE) {
|
|
422
423
|
maxTimeframeSize = SYSTEM_MAX_TIMEFRAME_SIZE;
|
|
423
424
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DeepMap } from './deepMap';
|
|
2
|
+
export declare type GroupKeyType<T extends any = any> = T;
|
|
3
|
+
export declare type GroupBy<DataType, KeyType> = {
|
|
4
|
+
field: keyof DataType & string;
|
|
5
|
+
toKey?: (value: any, data: DataType) => GroupKeyType<KeyType>;
|
|
6
|
+
};
|
|
7
|
+
export declare type AggregateParams<DataType, KeyType> = {
|
|
8
|
+
reducers: Record<string, DataAggregationReducer<DataType, any>>;
|
|
9
|
+
groupBy?: GroupBy<DataType, KeyType>[];
|
|
10
|
+
defaultToKey?: (value: any, item: DataType) => GroupKeyType<KeyType>;
|
|
11
|
+
};
|
|
12
|
+
export declare type DataAggregationReducer<T, AggregationResultType> = {
|
|
13
|
+
name?: string;
|
|
14
|
+
field?: keyof T & string;
|
|
15
|
+
initialValue?: AggregationResultType;
|
|
16
|
+
getter?: (data: T) => any;
|
|
17
|
+
reducer: string | ((accumulator: any, value: any, data: T) => AggregationResultType | any);
|
|
18
|
+
done?: (accumulatedValue: AggregationResultType | any, array: T[]) => AggregationResultType;
|
|
19
|
+
};
|
|
20
|
+
export declare type DataAggregationResult<DataType, KeyType extends any> = {
|
|
21
|
+
deepMap: DeepMap<GroupKeyType<KeyType>, DeepMapAggregationValueType<DataType, KeyType>>;
|
|
22
|
+
aggregateParams: AggregateParams<DataType, KeyType>;
|
|
23
|
+
initialData: DataType[];
|
|
24
|
+
reducerResults?: Record<string, AggregationReducerResult>;
|
|
25
|
+
};
|
|
26
|
+
export declare type DeepMapAggregationValueType<DataType, KeyType> = {
|
|
27
|
+
items: DataType[];
|
|
28
|
+
commonData?: Partial<DataType>;
|
|
29
|
+
reducerResults: Record<string, AggregationReducerResult>;
|
|
30
|
+
};
|
|
31
|
+
export declare type AggregationReducerResult = number;
|
|
32
|
+
export declare function aggregate<DataType, KeyType = any>(aggregateParams: AggregateParams<DataType, KeyType>, data: DataType[]): DataAggregationResult<DataType, KeyType>;
|
|
33
|
+
export declare function cumulate<DataType, KeyType = any>(aggregateParams: AggregateParams<DataType, KeyType>, data: DataType[]): DataAggregationResult<DataType, KeyType>;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cumulate = exports.aggregate = void 0;
|
|
4
|
+
const deepMap_1 = require("./deepMap");
|
|
5
|
+
function DEFAULT_TO_KEY(value) {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
function aggregate(aggregateParams, data) {
|
|
9
|
+
const { groupBy = [], defaultToKey = DEFAULT_TO_KEY, reducers } = aggregateParams;
|
|
10
|
+
const groupByLength = groupBy.length;
|
|
11
|
+
const deepMap = new deepMap_1.DeepMap();
|
|
12
|
+
let currentGroupKeys = [];
|
|
13
|
+
const initialReducerValue = initReducers(reducers);
|
|
14
|
+
const globalReducerResults = Object.assign({}, initialReducerValue);
|
|
15
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
|
16
|
+
let item = data[i];
|
|
17
|
+
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
18
|
+
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
19
|
+
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
20
|
+
currentGroupKeys.push(key);
|
|
21
|
+
if (!deepMap.has(currentGroupKeys)) {
|
|
22
|
+
const deepMapGroupValue = {
|
|
23
|
+
items: [],
|
|
24
|
+
reducerResults: Object.assign({}, initialReducerValue),
|
|
25
|
+
};
|
|
26
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
27
|
+
}
|
|
28
|
+
const { items: currentGroupItems, reducerResults } = deepMap.get(currentGroupKeys);
|
|
29
|
+
currentGroupItems.push(item);
|
|
30
|
+
if (reducers) {
|
|
31
|
+
computeReducersFor(item, reducers, reducerResults);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (reducers) {
|
|
35
|
+
computeReducersFor(item, reducers, globalReducerResults);
|
|
36
|
+
}
|
|
37
|
+
currentGroupKeys.length = 0;
|
|
38
|
+
}
|
|
39
|
+
if (reducers) {
|
|
40
|
+
deepMap.visitDepthFirst((deepMapValue, _keys, _indexInGroup, next) => {
|
|
41
|
+
completeReducers(reducers, deepMapValue.reducerResults, deepMapValue.items);
|
|
42
|
+
next === null || next === void 0 ? void 0 : next();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (reducers) {
|
|
46
|
+
completeReducers(reducers, globalReducerResults, data);
|
|
47
|
+
}
|
|
48
|
+
const result = {
|
|
49
|
+
deepMap,
|
|
50
|
+
aggregateParams,
|
|
51
|
+
initialData: data,
|
|
52
|
+
reducerResults: globalReducerResults,
|
|
53
|
+
};
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
exports.aggregate = aggregate;
|
|
57
|
+
function cumulate(aggregateParams, data) {
|
|
58
|
+
const { groupBy = [], defaultToKey = DEFAULT_TO_KEY, reducers } = aggregateParams;
|
|
59
|
+
const groupByLength = groupBy.length;
|
|
60
|
+
const deepMap = new deepMap_1.DeepMap();
|
|
61
|
+
let currentGroupKeys = [];
|
|
62
|
+
let initialReducerValue = initReducers(reducers);
|
|
63
|
+
const globalReducerResults = Object.assign({}, initialReducerValue);
|
|
64
|
+
for (let i = 0, len = data.length; i < len; i++) {
|
|
65
|
+
let item = data[i];
|
|
66
|
+
for (let groupByIndex = 0; groupByIndex < groupByLength; groupByIndex++) {
|
|
67
|
+
const { field: groupByProperty, toKey: groupToKey } = groupBy[groupByIndex];
|
|
68
|
+
const key = (groupToKey || defaultToKey)(item[groupByProperty], item);
|
|
69
|
+
currentGroupKeys.push(key);
|
|
70
|
+
if (!deepMap.has(currentGroupKeys)) {
|
|
71
|
+
const deepMapGroupValue = {
|
|
72
|
+
items: [],
|
|
73
|
+
reducerResults: Object.assign({}, initialReducerValue),
|
|
74
|
+
};
|
|
75
|
+
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
76
|
+
}
|
|
77
|
+
const { items: currentGroupItems, reducerResults } = deepMap.get(currentGroupKeys);
|
|
78
|
+
currentGroupItems.push(item);
|
|
79
|
+
if (reducers) {
|
|
80
|
+
computeReducersFor(item, reducers, reducerResults);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (reducers) {
|
|
84
|
+
computeReducersFor(item, reducers, globalReducerResults);
|
|
85
|
+
}
|
|
86
|
+
initialReducerValue = Object.assign({}, deepMap.get(currentGroupKeys).reducerResults);
|
|
87
|
+
currentGroupKeys.length = 0;
|
|
88
|
+
}
|
|
89
|
+
if (reducers) {
|
|
90
|
+
deepMap.visitDepthFirst((deepMapValue, _keys, _indexInGroup, next) => {
|
|
91
|
+
completeReducers(reducers, deepMapValue.reducerResults, deepMapValue.items);
|
|
92
|
+
next === null || next === void 0 ? void 0 : next();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (reducers) {
|
|
96
|
+
completeReducers(reducers, globalReducerResults, data);
|
|
97
|
+
}
|
|
98
|
+
const result = {
|
|
99
|
+
deepMap,
|
|
100
|
+
aggregateParams,
|
|
101
|
+
initialData: data,
|
|
102
|
+
reducerResults: globalReducerResults,
|
|
103
|
+
};
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
exports.cumulate = cumulate;
|
|
107
|
+
function initReducers(reducers) {
|
|
108
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
109
|
+
return {};
|
|
110
|
+
}
|
|
111
|
+
const result = {};
|
|
112
|
+
for (let key in reducers)
|
|
113
|
+
if (reducers.hasOwnProperty(key)) {
|
|
114
|
+
result[key] = reducers[key].initialValue;
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
*
|
|
120
|
+
* This fn mutates the reducerResults array!!!
|
|
121
|
+
*
|
|
122
|
+
* @param data data item
|
|
123
|
+
* @param reducers an array of reducers
|
|
124
|
+
* @param reducerResults the results on which to operate
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
function computeReducersFor(data, reducers, reducerResults) {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
for (let key in reducers)
|
|
133
|
+
if (reducers.hasOwnProperty(key)) {
|
|
134
|
+
const reducer = reducers[key];
|
|
135
|
+
if (typeof reducer.reducer !== 'function') {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const currentValue = reducerResults[key];
|
|
139
|
+
const value = reducer.field ? data[reducer.field] : (_b = (_a = reducer.getter) === null || _a === void 0 ? void 0 : _a.call(reducer, data)) !== null && _b !== void 0 ? _b : null;
|
|
140
|
+
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function completeReducers(reducers, reducerResults, items) {
|
|
144
|
+
if (reducers) {
|
|
145
|
+
for (let key in reducers)
|
|
146
|
+
if (reducers.hasOwnProperty(key)) {
|
|
147
|
+
const reducer = reducers[key];
|
|
148
|
+
if (reducer.done) {
|
|
149
|
+
reducerResults[key] = reducer.done(reducerResults[key], items);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return reducerResults;
|
|
154
|
+
}
|