@adaptabletools/adaptable 11.0.0-canary.5 → 11.0.0-canary.6
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 +1 -1
- package/agGrid.js +3 -3
- package/bundle.cjs.js +117 -117
- package/package.json +1 -1
- package/publishTimestamp.d.ts +1 -1
- package/publishTimestamp.js +1 -1
- package/src/AdaptableOptions/AdaptableOptions.d.ts +1 -1
- package/src/AdaptableOptions/ContainerOptions.d.ts +1 -1
- package/src/AdaptableOptions/QueryLanguageOptions.d.ts +3 -3
- package/src/AdaptableOptions/UserInterfaceOptions.d.ts +1 -1
- package/src/Api/AdaptableApi.d.ts +5 -0
- package/src/Api/ColumnApi.d.ts +0 -4
- 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/ColumnApiImpl.d.ts +0 -1
- package/src/Api/Implementation/ColumnApiImpl.js +0 -5
- package/src/Api/Implementation/QueryLanguageApiImpl.d.ts +1 -1
- package/src/Api/Implementation/QueryLanguageApiImpl.js +2 -2
- package/src/Api/Implementation/SettingsPanelApiImpl.d.ts +7 -0
- package/src/Api/Implementation/SettingsPanelApiImpl.js +15 -0
- package/src/Api/QueryLanguageApi.d.ts +10 -10
- package/src/Api/SettingsPanelApi.d.ts +17 -0
- package/src/Api/SettingsPanelApi.js +2 -0
- package/src/PredefinedConfig/AlertState.d.ts +2 -2
- package/src/PredefinedConfig/Common/AdaptableQuery.d.ts +7 -4
- package/src/PredefinedConfig/Common/AdaptableQuery.js +3 -3
- package/src/PredefinedConfig/Common/Enums.d.ts +0 -1
- package/src/PredefinedConfig/Common/Enums.js +0 -2
- package/src/Strategy/AlertModule.js +9 -0
- package/src/Utilities/Defaults/DefaultAdaptableOptions.js +2 -2
- package/src/Utilities/ExpressionFunctions/{aggregationExpressionFunctions.d.ts → aggregatedBooleanExpressionFunctions.d.ts} +1 -1
- package/src/Utilities/ExpressionFunctions/{aggregationExpressionFunctions.js → aggregatedBooleanExpressionFunctions.js} +3 -3
- package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +7 -0
- package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +42 -0
- package/src/Utilities/ExpressionFunctions/deepMap.d.ts +35 -0
- package/src/Utilities/ExpressionFunctions/deepMap.js +283 -0
- package/src/Utilities/ExpressionFunctions/groupingMap.d.ts +36 -0
- package/src/Utilities/ExpressionFunctions/groupingMap.js +104 -0
- package/src/Utilities/Services/AlertService.js +3 -3
- package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +2 -2
- package/src/Utilities/Services/QueryLanguageService.d.ts +2 -2
- package/src/Utilities/Services/QueryLanguageService.js +6 -6
- package/src/View/AdaptableWizardView/helper.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/Wizard/CalculatedColumnWizard.js +2 -2
- package/src/View/Components/EntityRulesEditor/index.js +9 -9
- 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/Query/Wizard/NamedQueryWizard.js +3 -3
- package/src/agGrid/Adaptable.js +1 -2
- package/src/agGrid/agGridHelper.js +1 -5
- package/src/components/ExpressionEditor/EditorInputReactive.d.ts +1 -1
- package/src/components/ExpressionEditor/EditorInputReactive.js +1 -1
- package/src/components/ExpressionEditor/index.d.ts +1 -1
- package/src/components/ExpressionEditor/index.js +3 -3
- package/src/metamodel/adaptable.metamodel.d.ts +11 -0
- package/src/metamodel/adaptable.metamodel.js +36 -16
- package/src/types.d.ts +2 -1
- 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;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
column?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type GroupParams<DataType, KeyType> = {
|
|
9
|
+
groupBy: GroupBy<DataType, KeyType>[];
|
|
10
|
+
defaultToKey?: (value: any, item: DataType) => GroupKeyType<KeyType>;
|
|
11
|
+
reducers?: Record<string, DataSourceAggregationReducer<DataType, any>>;
|
|
12
|
+
};
|
|
13
|
+
export declare type DataSourceAggregationReducer<T, AggregationResultType> = {
|
|
14
|
+
name?: string;
|
|
15
|
+
field?: keyof T;
|
|
16
|
+
initialValue?: AggregationResultType;
|
|
17
|
+
getter?: (data: T) => any;
|
|
18
|
+
reducer: string | ((accumulator: any, value: any, data: T) => AggregationResultType | any);
|
|
19
|
+
done?: (accumulatedValue: AggregationResultType | any, array: T[]) => AggregationResultType;
|
|
20
|
+
};
|
|
21
|
+
export declare type DataGroupResult<DataType, KeyType extends any> = {
|
|
22
|
+
deepMap: DeepMap<GroupKeyType<KeyType>, DeepMapGroupValueType<DataType, KeyType>>;
|
|
23
|
+
groupParams: GroupParams<DataType, KeyType>;
|
|
24
|
+
initialData: DataType[];
|
|
25
|
+
reducerResults?: Record<string, AggregationReducerResult>;
|
|
26
|
+
};
|
|
27
|
+
export declare type DeepMapGroupValueType<DataType, KeyType> = {
|
|
28
|
+
items: DataType[];
|
|
29
|
+
commonData?: Partial<DataType>;
|
|
30
|
+
reducerResults: Record<string, AggregationReducerResult>;
|
|
31
|
+
};
|
|
32
|
+
export declare type AggregationReducerResult<AggregationResultType extends any = any> = {
|
|
33
|
+
value: AggregationResultType;
|
|
34
|
+
id: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function group<DataType, KeyType = any>(groupParams: GroupParams<DataType, KeyType>, data: DataType[]): DataGroupResult<DataType, KeyType>;
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
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
|
+
groupParams,
|
|
51
|
+
initialData: data,
|
|
52
|
+
reducerResults: globalReducerResults,
|
|
53
|
+
};
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
exports.group = group;
|
|
57
|
+
function initReducers(reducers) {
|
|
58
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
const result = {};
|
|
62
|
+
for (let key in reducers)
|
|
63
|
+
if (reducers.hasOwnProperty(key)) {
|
|
64
|
+
result[key] = reducers[key].initialValue;
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* This fn mutates the reducerResults array!!!
|
|
71
|
+
*
|
|
72
|
+
* @param data data item
|
|
73
|
+
* @param reducers an array of reducers
|
|
74
|
+
* @param reducerResults the results on which to operate
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
function computeReducersFor(data, reducers, reducerResults) {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
if (!reducers || !Object.keys(reducers).length) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
for (let key in reducers)
|
|
83
|
+
if (reducers.hasOwnProperty(key)) {
|
|
84
|
+
const reducer = reducers[key];
|
|
85
|
+
if (typeof reducer.reducer !== 'function') {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const currentValue = reducerResults[key];
|
|
89
|
+
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;
|
|
90
|
+
reducerResults[key] = reducer.reducer(currentValue, value, data);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function completeReducers(reducers, reducerResults, items) {
|
|
94
|
+
if (reducers) {
|
|
95
|
+
for (let key in reducers)
|
|
96
|
+
if (reducers.hasOwnProperty(key)) {
|
|
97
|
+
const reducer = reducers[key];
|
|
98
|
+
if (reducer.done) {
|
|
99
|
+
reducerResults[key] = reducer.done(reducerResults[key], items);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return reducerResults;
|
|
104
|
+
}
|
|
@@ -55,8 +55,8 @@ class AlertService {
|
|
|
55
55
|
isValidExpression(rule) {
|
|
56
56
|
return rule.ObservableExpression
|
|
57
57
|
? this.adaptable.api.queryLanguageApi.isValidObservableExpression(rule.ObservableExpression, ModuleConstants_1.AlertModuleId, `Invalid Alert rule with observable expression `)
|
|
58
|
-
: rule.
|
|
59
|
-
? this.adaptable.api.queryLanguageApi.
|
|
58
|
+
: rule.AggregatedBooleanExpression
|
|
59
|
+
? this.adaptable.api.queryLanguageApi.isValidAggregatedBooleanExpression(rule.AggregatedBooleanExpression, ModuleConstants_1.AlertModuleId, `Invalid Alert rule with aggregation expression `)
|
|
60
60
|
: false;
|
|
61
61
|
}
|
|
62
62
|
evaluateReactiveExpression(rule) {
|
|
@@ -66,7 +66,7 @@ class AlertService {
|
|
|
66
66
|
.evaluateObservableExpression(rule.ObservableExpression, ModuleConstants_1.AlertModuleId)
|
|
67
67
|
: this.adaptable.api.internalApi
|
|
68
68
|
.getQueryLanguageService()
|
|
69
|
-
.
|
|
69
|
+
.evaluateAggregatedBooleanExpression(rule.AggregatedBooleanExpression, ModuleConstants_1.AlertModuleId);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
exports.AlertService = AlertService;
|
|
@@ -8,7 +8,7 @@ export interface IQueryLanguageService extends IAdaptableService {
|
|
|
8
8
|
evaluateBooleanExpression(expression: string, module: AdaptableModule, rowNode: RowNode): boolean;
|
|
9
9
|
evaluateScalarExpression(expression: string, module: AdaptableModule, rowNode: RowNode): any;
|
|
10
10
|
evaluateObservableExpression(expression: string, module: AdaptableModule): Observable<DataChangedInfo>;
|
|
11
|
-
|
|
11
|
+
evaluateAggregatedBooleanExpression(expression: string, module: AdaptableModule): Observable<DataChangedInfo>;
|
|
12
12
|
validateBoolean(expression: string, module: AdaptableModule, config?: {
|
|
13
13
|
force?: boolean;
|
|
14
14
|
}): {
|
|
@@ -19,7 +19,7 @@ export interface IQueryLanguageService extends IAdaptableService {
|
|
|
19
19
|
isValid: boolean;
|
|
20
20
|
errorMessage: string;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
validateAggregatedBoolean(expression: string, module: AdaptableModule): {
|
|
23
23
|
isValid: boolean;
|
|
24
24
|
errorMessage: string;
|
|
25
25
|
};
|
|
@@ -15,7 +15,7 @@ export declare class QueryLanguageService implements IQueryLanguageService {
|
|
|
15
15
|
evaluateBooleanExpression(expression: string, module: AdaptableModule, rowNode: any): any;
|
|
16
16
|
evaluateScalarExpression(expression: string, module: AdaptableModule, rowNode: RowNode): any;
|
|
17
17
|
evaluateObservableExpression(reactiveExpression: string, module: AdaptableModule): Observable<DataChangedInfo>;
|
|
18
|
-
|
|
18
|
+
evaluateAggregatedBooleanExpression(aggregationExpression: string, module: AdaptableModule): Observable<DataChangedInfo>;
|
|
19
19
|
validateBoolean(expressionInput: string, module: AdaptableModule, config?: {
|
|
20
20
|
force?: boolean;
|
|
21
21
|
}): {
|
|
@@ -26,7 +26,7 @@ export declare class QueryLanguageService implements IQueryLanguageService {
|
|
|
26
26
|
isValid: boolean;
|
|
27
27
|
errorMessage: string;
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
validateAggregatedBoolean(expressionInput: string, module: AdaptableModule): {
|
|
30
30
|
isValid: boolean;
|
|
31
31
|
errorMessage: string;
|
|
32
32
|
};
|
|
@@ -37,13 +37,13 @@ class QueryLanguageService {
|
|
|
37
37
|
});
|
|
38
38
|
return reactiveExpression$;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
evaluateAggregatedBooleanExpression(aggregationExpression, module) {
|
|
41
41
|
const moduleExpressionFunctions = this.getModuleExpressionFunctions(module);
|
|
42
42
|
const booleanAndScalarFunctions = this.getBooleanAndScalarFunctions(moduleExpressionFunctions);
|
|
43
43
|
const aggregationExpression$ = parser.evaluate(aggregationExpression, {
|
|
44
44
|
node: aggregationExpression,
|
|
45
45
|
api: this.adaptable.api,
|
|
46
|
-
functions: moduleExpressionFunctions.
|
|
46
|
+
functions: moduleExpressionFunctions.aggregatedBooleanFunctions,
|
|
47
47
|
whereClauseFunctions: booleanAndScalarFunctions,
|
|
48
48
|
});
|
|
49
49
|
return aggregationExpression$;
|
|
@@ -146,7 +146,7 @@ class QueryLanguageService {
|
|
|
146
146
|
return result;
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
validateAggregatedBoolean(expressionInput = '', module) {
|
|
150
150
|
const cacheKey = this.getExpressionCacheKey(expressionInput, module);
|
|
151
151
|
if (this.cacheAggregationValidation.has(cacheKey)) {
|
|
152
152
|
return this.cacheAggregationValidation.get(cacheKey);
|
|
@@ -161,7 +161,7 @@ class QueryLanguageService {
|
|
|
161
161
|
return result;
|
|
162
162
|
}
|
|
163
163
|
try {
|
|
164
|
-
const aggregationExpression = this.
|
|
164
|
+
const aggregationExpression = this.evaluateAggregatedBooleanExpression(expression, module);
|
|
165
165
|
if (!rxjs_1.isObservable(aggregationExpression)) {
|
|
166
166
|
const result = {
|
|
167
167
|
isValid: false,
|
|
@@ -199,7 +199,7 @@ class QueryLanguageService {
|
|
|
199
199
|
booleanFunctions: this.adaptable.adaptableOptions.queryLanguageOptions.defaultBooleanFunctions,
|
|
200
200
|
scalarFunctions: this.adaptable.adaptableOptions.queryLanguageOptions.defaultScalarFunctions,
|
|
201
201
|
observableFunctions: this.adaptable.adaptableOptions.queryLanguageOptions.defaultObservableFunctions,
|
|
202
|
-
|
|
202
|
+
aggregatedBooleanFunctions: this.adaptable.adaptableOptions.queryLanguageOptions.defaultAggregatedBooleanFunctions,
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
let cachedResult = this.cacheModuleSpecificExpressionFunctions.get(module);
|
|
@@ -211,7 +211,7 @@ class QueryLanguageService {
|
|
|
211
211
|
booleanFunctions: (_c = moduleSpecificOptions.booleanFunctions) !== null && _c !== void 0 ? _c : this.adaptable.adaptableOptions.queryLanguageOptions.defaultBooleanFunctions,
|
|
212
212
|
scalarFunctions: (_d = moduleSpecificOptions.scalarFunctions) !== null && _d !== void 0 ? _d : this.adaptable.adaptableOptions.queryLanguageOptions.defaultScalarFunctions,
|
|
213
213
|
observableFunctions: (_e = moduleSpecificOptions.observableFunctions) !== null && _e !== void 0 ? _e : this.adaptable.adaptableOptions.queryLanguageOptions.defaultObservableFunctions,
|
|
214
|
-
|
|
214
|
+
aggregatedBooleanFunctions: (_f = moduleSpecificOptions.aggregatedBooleanFunctions) !== null && _f !== void 0 ? _f : this.adaptable.adaptableOptions.queryLanguageOptions.defaultAggregatedBooleanFunctions,
|
|
215
215
|
};
|
|
216
216
|
this.cacheModuleSpecificExpressionFunctions.set(module, moduleSpecificFunctions);
|
|
217
217
|
return moduleSpecificFunctions;
|
|
@@ -51,7 +51,7 @@ const typeToColType = {
|
|
|
51
51
|
boolean: 'abColDefBoolean',
|
|
52
52
|
date: 'abColDefDate',
|
|
53
53
|
};
|
|
54
|
-
const
|
|
54
|
+
const abColDefCustom = 'abColDefCustom';
|
|
55
55
|
exports.getColTypeFromValue = (value) => {
|
|
56
56
|
const dataType = typeof value;
|
|
57
57
|
let columnType = typeToColType[dataType] || typeToColType.string;
|
|
@@ -59,7 +59,7 @@ exports.getColTypeFromValue = (value) => {
|
|
|
59
59
|
columnType = typeToColType.date;
|
|
60
60
|
}
|
|
61
61
|
if (Array.isArray(value) && value.length && typeof value[0] === 'number') {
|
|
62
|
-
columnType =
|
|
62
|
+
columnType = abColDefCustom;
|
|
63
63
|
}
|
|
64
64
|
return columnType;
|
|
65
65
|
};
|
|
@@ -26,7 +26,7 @@ exports.AlertWizard = (props) => {
|
|
|
26
26
|
: ObjectFactory_1.default.CreateEmptyAlertDefinition();
|
|
27
27
|
if (!alertDefinition.Rule.BooleanExpression &&
|
|
28
28
|
!alertDefinition.Rule.ObservableExpression &&
|
|
29
|
-
!alertDefinition.Rule.
|
|
29
|
+
!alertDefinition.Rule.AggregatedBooleanExpression &&
|
|
30
30
|
!alertDefinition.Rule.Predicate) {
|
|
31
31
|
alertDefinition.Rule.BooleanExpression = '';
|
|
32
32
|
}
|
|
@@ -72,7 +72,7 @@ exports.AlertWizard = (props) => {
|
|
|
72
72
|
title: 'Type & Display',
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
|
-
details: 'Configure
|
|
75
|
+
details: 'Configure Behaviour for the Alert',
|
|
76
76
|
title: 'Behaviour',
|
|
77
77
|
render: () => (React.createElement(rebass_1.Box, { padding: 2 },
|
|
78
78
|
React.createElement(AlertBehaviourWizardSection_1.AlertBehaviourWizardSection, { onChange: setAlertDefinition }))),
|
|
@@ -20,8 +20,8 @@ exports.BaseAlertRulesWizardSection = (props) => {
|
|
|
20
20
|
React.createElement("i", null, "Scope"),
|
|
21
21
|
" is 'Whole Row' - so any data change may be evaluated in a complex ObservableExpression")),
|
|
22
22
|
useAggregationQuery: (React.createElement(React.Fragment, null,
|
|
23
|
-
"Use an
|
|
23
|
+
"Use an AggregatedBooleanQuery if ",
|
|
24
24
|
React.createElement("i", null, "Scope"),
|
|
25
|
-
" is 'Whole Row' - so any data change may be evaluated in a complex
|
|
25
|
+
" is 'Whole Row' - so any data change may be evaluated in a complex AggregatedBooleanExpression")),
|
|
26
26
|
} }));
|
|
27
27
|
};
|
|
@@ -29,11 +29,12 @@ exports.BaseAlertScopeWizardSection = (props) => {
|
|
|
29
29
|
delete newData.Rule.ObservableExpression;
|
|
30
30
|
newData.Rule.BooleanExpression = '';
|
|
31
31
|
}
|
|
32
|
-
if (newData.Rule.
|
|
32
|
+
if (newData.Rule.AggregatedBooleanExpression !== undefined &&
|
|
33
|
+
!api.scopeApi.scopeIsAll(Scope)) {
|
|
33
34
|
// if it had aggregation expression and the scope is changed to partial
|
|
34
35
|
// we need to reset to not be an aggregation expression, as aggregation is not supported
|
|
35
36
|
// for partial scope
|
|
36
|
-
delete newData.Rule.
|
|
37
|
+
delete newData.Rule.AggregatedBooleanExpression;
|
|
37
38
|
newData.Rule.BooleanExpression = '';
|
|
38
39
|
}
|
|
39
40
|
props.onChange(newData);
|
|
@@ -7,7 +7,7 @@ exports.isValidAlertRules = (alert, api, context) => {
|
|
|
7
7
|
if (!alert.Rule.Predicate &&
|
|
8
8
|
!alert.Rule.BooleanExpression &&
|
|
9
9
|
!alert.Rule.ObservableExpression &&
|
|
10
|
-
!alert.Rule.
|
|
10
|
+
!alert.Rule.AggregatedBooleanExpression) {
|
|
11
11
|
return 'No condition defined for alert';
|
|
12
12
|
}
|
|
13
13
|
if (valid && alert.Rule.Predicate) {
|
|
@@ -35,8 +35,8 @@ exports.isValidAlertRules = (alert, api, context) => {
|
|
|
35
35
|
return 'The query is not a valid observable query';
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
if (valid && alert.Rule.
|
|
39
|
-
valid = api.queryLanguageApi.
|
|
38
|
+
if (valid && alert.Rule.AggregatedBooleanExpression) {
|
|
39
|
+
valid = api.queryLanguageApi.isValidAggregatedBooleanExpression(alert.Rule.AggregatedBooleanExpression, ModuleConstants_1.AlertModuleId);
|
|
40
40
|
if (!valid) {
|
|
41
41
|
return 'The query is not a valid aggregation query';
|
|
42
42
|
}
|
|
@@ -44,7 +44,7 @@ exports.CalculatedColumnWizard = (props) => {
|
|
|
44
44
|
return (React.createElement(OnePageAdaptableWizard_1.OnePageAdaptableWizard, { defaultCurrentSectionName: props.defaultCurrentSectionName, moduleInfo: props.moduleInfo, data: calculatedColumn, onHide: props.onCloseWizard, onFinish: handleFinish, sections: [
|
|
45
45
|
{
|
|
46
46
|
title: 'Expression',
|
|
47
|
-
details: 'Specify the
|
|
47
|
+
details: 'Specify the Calculated Column Expression',
|
|
48
48
|
isValid: CalculatedColumnExpressionWizardSection_1.isValidCalculatedColumnExpression,
|
|
49
49
|
renderSummary: CalculatedColumnExpressionWizardSection_1.renderCalculatedColumnExpressionSummary,
|
|
50
50
|
render: () => {
|
|
@@ -53,7 +53,7 @@ exports.CalculatedColumnWizard = (props) => {
|
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
title: 'Settings',
|
|
56
|
-
details: 'Specify
|
|
56
|
+
details: 'Specify Column details and properties',
|
|
57
57
|
isValid: CalculatedColumnSettingsWizardSection_1.isValidCalculatedColumnSettings,
|
|
58
58
|
renderSummary: CalculatedColumnSettingsWizardSection_1.renderCalculatedColumnSettingsSummary,
|
|
59
59
|
render: () => {
|