@finos/legend-application-repl 0.0.24 → 0.0.25
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/lib/components/dataCube/grid/DataCubeGrid.d.ts.map +1 -1
- package/lib/components/dataCube/grid/DataCubeGrid.js +1 -1
- package/lib/components/dataCube/grid/DataCubeGrid.js.map +1 -1
- package/lib/grid.css +1 -1
- package/lib/index.css +1 -1
- package/lib/package.json +1 -1
- package/lib/repl.css +1 -1
- package/lib/stores/dataCube/DataCubeMetaModelConst.d.ts +14 -0
- package/lib/stores/dataCube/DataCubeMetaModelConst.d.ts.map +1 -1
- package/lib/stores/dataCube/DataCubeMetaModelConst.js +15 -0
- package/lib/stores/dataCube/DataCubeMetaModelConst.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.js +250 -11
- package/lib/stores/dataCube/core/DataCubeQueryBuilder.js.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts +11 -2
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts.map +1 -1
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js +2 -0
- package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js +42 -4
- package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.d.ts.map +1 -1
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js +32 -4
- package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.js.map +1 -1
- package/package.json +4 -4
- package/src/components/dataCube/grid/DataCubeGrid.tsx +2 -0
- package/src/stores/dataCube/DataCubeMetaModelConst.ts +15 -0
- package/src/stores/dataCube/core/DataCubeQueryBuilder.ts +341 -13
- package/src/stores/dataCube/core/DataCubeQuerySnapshot.ts +12 -1
- package/src/stores/dataCube/grid/DataCubeGridClientEngine.ts +61 -4
- package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotAnalyzer.ts +40 -4
|
@@ -22,7 +22,11 @@ import type {
|
|
|
22
22
|
import type { DataCubeGridState } from './DataCubeGridState.js';
|
|
23
23
|
import {
|
|
24
24
|
cloneSnapshot,
|
|
25
|
+
type DataCubeQueryFilter,
|
|
26
|
+
type DataCubeQueryFilterCondition,
|
|
25
27
|
type DataCubeQuerySnapshot,
|
|
28
|
+
type DataCubeQuerySnapshotAggregateColumn,
|
|
29
|
+
type DataCubeQuerySnapshotColumn,
|
|
26
30
|
type DataCubeQuerySnapshotSortColumn,
|
|
27
31
|
} from '../core/DataCubeQuerySnapshot.js';
|
|
28
32
|
import {
|
|
@@ -33,8 +37,17 @@ import {
|
|
|
33
37
|
isBoolean,
|
|
34
38
|
} from '@finos/legend-shared';
|
|
35
39
|
import { buildExecutableQueryFromSnapshot } from '../core/DataCubeQueryBuilder.js';
|
|
36
|
-
import {
|
|
37
|
-
|
|
40
|
+
import {
|
|
41
|
+
type TabularDataSet,
|
|
42
|
+
V1_Lambda,
|
|
43
|
+
PRIMITIVE_TYPE,
|
|
44
|
+
extractElementNameFromPath,
|
|
45
|
+
} from '@finos/legend-graph';
|
|
46
|
+
import {
|
|
47
|
+
DATA_CUBE_COLUMN_SORT_DIRECTION,
|
|
48
|
+
DATA_CUBE_FILTER_OPERATION,
|
|
49
|
+
DATA_CUBE_FUNCTIONS,
|
|
50
|
+
} from '../DataCubeMetaModelConst.js';
|
|
38
51
|
import { APPLICATION_EVENT } from '@finos/legend-application';
|
|
39
52
|
|
|
40
53
|
export type GridClientResultCellDataType =
|
|
@@ -117,7 +130,41 @@ export class DataCubeGridClientServerSideDataSource
|
|
|
117
130
|
let createNew = false;
|
|
118
131
|
|
|
119
132
|
// --------------------------------- GROUP BY ---------------------------------
|
|
120
|
-
|
|
133
|
+
const groupByExpandedKeys = request.groupKeys;
|
|
134
|
+
const groupByColumns = request.rowGroupCols.map((r) => {
|
|
135
|
+
const column = baseSnapshot.columns.find((col) => col.name === r.id);
|
|
136
|
+
return {
|
|
137
|
+
name: r.id,
|
|
138
|
+
type: guaranteeNonNullable(column).type,
|
|
139
|
+
} as DataCubeQuerySnapshotColumn;
|
|
140
|
+
});
|
|
141
|
+
const groupByAggColumns = request.valueCols.map((v) => {
|
|
142
|
+
const type = baseSnapshot.columns.find(
|
|
143
|
+
(col) => col.name === v.field,
|
|
144
|
+
)?.type;
|
|
145
|
+
return {
|
|
146
|
+
name: v.field,
|
|
147
|
+
type: type,
|
|
148
|
+
function: v.aggFunc,
|
|
149
|
+
} as DataCubeQuerySnapshotAggregateColumn;
|
|
150
|
+
});
|
|
151
|
+
let groupByFilter: DataCubeQueryFilter | undefined;
|
|
152
|
+
|
|
153
|
+
for (let index = 0; index < groupByExpandedKeys.length; index++) {
|
|
154
|
+
const groupFilter = {
|
|
155
|
+
conditions: [
|
|
156
|
+
{
|
|
157
|
+
name: guaranteeNonNullable(groupByColumns.at(index)).name,
|
|
158
|
+
type: PRIMITIVE_TYPE.STRING,
|
|
159
|
+
operation: DATA_CUBE_FILTER_OPERATION.EQUALS,
|
|
160
|
+
value: groupByExpandedKeys.at(index),
|
|
161
|
+
} as DataCubeQueryFilterCondition,
|
|
162
|
+
],
|
|
163
|
+
groupOperation: extractElementNameFromPath(DATA_CUBE_FUNCTIONS.AND),
|
|
164
|
+
} as DataCubeQueryFilter;
|
|
165
|
+
|
|
166
|
+
groupByFilter = groupFilter;
|
|
167
|
+
}
|
|
121
168
|
|
|
122
169
|
// --------------------------------- SORT ---------------------------------
|
|
123
170
|
|
|
@@ -136,7 +183,13 @@ export class DataCubeGridClientServerSideDataSource
|
|
|
136
183
|
};
|
|
137
184
|
});
|
|
138
185
|
|
|
139
|
-
if (
|
|
186
|
+
if (
|
|
187
|
+
!deepEqual(newSortColumns, baseSnapshot.sortColumns) ||
|
|
188
|
+
!deepEqual(groupByExpandedKeys, baseSnapshot.groupByExpandedKeys) ||
|
|
189
|
+
!deepEqual(groupByColumns, baseSnapshot.groupByColumns) ||
|
|
190
|
+
!deepEqual(groupByAggColumns, baseSnapshot.groupByAggColumns) ||
|
|
191
|
+
!deepEqual(groupByFilter, baseSnapshot.groupByFilter)
|
|
192
|
+
) {
|
|
140
193
|
createNew = true;
|
|
141
194
|
}
|
|
142
195
|
|
|
@@ -145,6 +198,10 @@ export class DataCubeGridClientServerSideDataSource
|
|
|
145
198
|
if (createNew) {
|
|
146
199
|
const newSnapshot = cloneSnapshot(baseSnapshot);
|
|
147
200
|
newSnapshot.sortColumns = newSortColumns;
|
|
201
|
+
newSnapshot.groupByExpandedKeys = groupByExpandedKeys;
|
|
202
|
+
newSnapshot.groupByColumns = groupByColumns;
|
|
203
|
+
newSnapshot.groupByAggColumns = groupByAggColumns;
|
|
204
|
+
newSnapshot.groupByFilter = groupByFilter;
|
|
148
205
|
return newSnapshot;
|
|
149
206
|
}
|
|
150
207
|
return baseSnapshot;
|
|
@@ -18,6 +18,7 @@ import type { DataCubeQuerySnapshot } from '../core/DataCubeQuerySnapshot.js';
|
|
|
18
18
|
import type { GridOptions } from '@ag-grid-community/core';
|
|
19
19
|
import { DATA_CUBE_COLUMN_SORT_DIRECTION } from '../DataCubeMetaModelConst.js';
|
|
20
20
|
import { GridClientSortDirection } from './DataCubeGridClientEngine.js';
|
|
21
|
+
import { PRIMITIVE_TYPE } from '@finos/legend-graph';
|
|
21
22
|
|
|
22
23
|
// export const getTDSSortOrder = (sortOrder: string): TDS_SORT_ORDER => {
|
|
23
24
|
// switch (sortOrder) {
|
|
@@ -221,6 +222,41 @@ function buildColumnSortSpecification(
|
|
|
221
222
|
};
|
|
222
223
|
}
|
|
223
224
|
|
|
225
|
+
function getAggregationColumnCustomizations(
|
|
226
|
+
colName: string,
|
|
227
|
+
snapshot: DataCubeQuerySnapshot,
|
|
228
|
+
): string[] {
|
|
229
|
+
const columnType = snapshot.columns.find((col) => col.name === colName)?.type;
|
|
230
|
+
switch (columnType) {
|
|
231
|
+
case PRIMITIVE_TYPE.STRING:
|
|
232
|
+
return [];
|
|
233
|
+
case PRIMITIVE_TYPE.DATE:
|
|
234
|
+
case PRIMITIVE_TYPE.DATETIME:
|
|
235
|
+
case PRIMITIVE_TYPE.STRICTDATE:
|
|
236
|
+
return [];
|
|
237
|
+
case PRIMITIVE_TYPE.DECIMAL:
|
|
238
|
+
case PRIMITIVE_TYPE.INTEGER:
|
|
239
|
+
case PRIMITIVE_TYPE.FLOAT:
|
|
240
|
+
return ['count', 'sum', 'max', 'min', 'avg'];
|
|
241
|
+
default:
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function buildColumnGroupBySpecification(
|
|
247
|
+
colName: string,
|
|
248
|
+
snapshot: DataCubeQuerySnapshot,
|
|
249
|
+
) {
|
|
250
|
+
const rowGroup = snapshot.groupByColumns.find((c) => c.name === colName);
|
|
251
|
+
const aggColumn = snapshot.groupByAggColumns.find((c) => c.name === colName);
|
|
252
|
+
return {
|
|
253
|
+
rowGroup: Boolean(rowGroup),
|
|
254
|
+
hide: Boolean(rowGroup),
|
|
255
|
+
aggFunc: aggColumn ? aggColumn.function : null,
|
|
256
|
+
allowedAggFuncs: getAggregationColumnCustomizations(colName, snapshot),
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
224
260
|
export function generateGridOptionsFromSnapshot(
|
|
225
261
|
snapshot: DataCubeQuerySnapshot,
|
|
226
262
|
): GridOptions {
|
|
@@ -235,10 +271,10 @@ export function generateGridOptionsFromSnapshot(
|
|
|
235
271
|
sortable: true,
|
|
236
272
|
flex: 1,
|
|
237
273
|
resizable: true,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
274
|
+
enableRowGroup: true,
|
|
275
|
+
enableValue: true,
|
|
276
|
+
menuTabs: ['generalMenuTab', 'columnsMenuTab'],
|
|
277
|
+
...buildColumnGroupBySpecification(col.name, snapshot),
|
|
242
278
|
})),
|
|
243
279
|
};
|
|
244
280
|
return gridOptions;
|