@finos/legend-application-repl 0.0.40 → 0.0.41

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 (184) hide show
  1. package/lib/application/LegendREPL.d.ts +2 -2
  2. package/lib/application/LegendREPL.d.ts.map +1 -1
  3. package/lib/application/LegendREPL.js.map +1 -1
  4. package/lib/application/LegendREPLApplicationConfig.d.ts.map +1 -1
  5. package/lib/application/LegendREPLDocumentation.d.ts +2 -1
  6. package/lib/application/LegendREPLDocumentation.d.ts.map +1 -1
  7. package/lib/application/LegendREPLDocumentation.js +1 -0
  8. package/lib/application/LegendREPLDocumentation.js.map +1 -1
  9. package/lib/application/LegendREPLPluginManager.d.ts.map +1 -1
  10. package/lib/application/LegendREPLPluginManager.js.map +1 -1
  11. package/lib/components/LegendREPLApplication.js +2 -2
  12. package/lib/components/LegendREPLApplication.js.map +1 -1
  13. package/lib/components/LegendREPLFrameworkProvider.d.ts +3 -2
  14. package/lib/components/LegendREPLFrameworkProvider.d.ts.map +1 -1
  15. package/lib/components/LegendREPLFrameworkProvider.js +1 -1
  16. package/lib/components/LegendREPLFrameworkProvider.js.map +1 -1
  17. package/lib/components/REPLStoreProvider.d.ts.map +1 -1
  18. package/lib/components/REPLStoreProvider.js.map +1 -1
  19. package/lib/components/dataCube/DataCube.js.map +1 -1
  20. package/lib/components/dataCube/editor/DataCubeEditor.js.map +1 -1
  21. package/lib/components/dataCube/editor/DataCubeEditorCodePanel.js +3 -3
  22. package/lib/components/dataCube/editor/DataCubeEditorCodePanel.js.map +1 -1
  23. package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.d.ts.map +1 -1
  24. package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js +14 -12
  25. package/lib/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.js.map +1 -1
  26. package/lib/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.js +4 -4
  27. package/lib/components/dataCube/grid/DataCubeGrid.d.ts.map +1 -1
  28. package/lib/components/dataCube/grid/DataCubeGrid.js +1 -1
  29. package/lib/components/dataCube/grid/DataCubeGrid.js.map +1 -1
  30. package/lib/components/repl/Alert.d.ts +14 -2
  31. package/lib/components/repl/Alert.d.ts.map +1 -1
  32. package/lib/components/repl/Alert.js +42 -24
  33. package/lib/components/repl/Alert.js.map +1 -1
  34. package/lib/components/repl/DocumentationPanel.d.ts +0 -5
  35. package/lib/components/repl/DocumentationPanel.d.ts.map +1 -1
  36. package/lib/components/repl/DocumentationPanel.js +2 -28
  37. package/lib/components/repl/DocumentationPanel.js.map +1 -1
  38. package/lib/components/repl/Form.d.ts +5 -0
  39. package/lib/components/repl/Form.d.ts.map +1 -1
  40. package/lib/components/repl/Form.js +27 -0
  41. package/lib/components/repl/Form.js.map +1 -1
  42. package/lib/components/repl/SettingsPanel.d.ts.map +1 -1
  43. package/lib/components/repl/SettingsPanel.js +6 -3
  44. package/lib/components/repl/SettingsPanel.js.map +1 -1
  45. package/lib/index.css +1 -1
  46. package/lib/index.d.ts +4 -3
  47. package/lib/index.d.ts.map +1 -1
  48. package/lib/index.js +1 -1
  49. package/lib/index.js.map +1 -1
  50. package/lib/package.json +1 -1
  51. package/lib/server/REPLEngine.d.ts +1 -0
  52. package/lib/server/REPLEngine.d.ts.map +1 -1
  53. package/lib/server/REPLEngine.js.map +1 -1
  54. package/lib/stores/LayoutManagerState.d.ts +2 -1
  55. package/lib/stores/LayoutManagerState.d.ts.map +1 -1
  56. package/lib/stores/LayoutManagerState.js +8 -1
  57. package/lib/stores/LayoutManagerState.js.map +1 -1
  58. package/lib/stores/LegendREPLApplicationPlugin.d.ts +2 -1
  59. package/lib/stores/LegendREPLApplicationPlugin.d.ts.map +1 -1
  60. package/lib/stores/REPLStore.d.ts +17 -2
  61. package/lib/stores/REPLStore.d.ts.map +1 -1
  62. package/lib/stores/REPLStore.js +15 -5
  63. package/lib/stores/REPLStore.js.map +1 -1
  64. package/lib/stores/dataCube/DataCubeEngine.d.ts +6 -1
  65. package/lib/stores/dataCube/DataCubeEngine.d.ts.map +1 -1
  66. package/lib/stores/dataCube/DataCubeEngine.js +19 -7
  67. package/lib/stores/dataCube/DataCubeEngine.js.map +1 -1
  68. package/lib/stores/dataCube/DataCubeState.d.ts.map +1 -1
  69. package/lib/stores/dataCube/DataCubeState.js +1 -0
  70. package/lib/stores/dataCube/DataCubeState.js.map +1 -1
  71. package/lib/stores/dataCube/core/DataCubeConfiguration.d.ts +2 -3
  72. package/lib/stores/dataCube/core/DataCubeConfiguration.d.ts.map +1 -1
  73. package/lib/stores/dataCube/core/DataCubeConfiguration.js +2 -4
  74. package/lib/stores/dataCube/core/DataCubeConfiguration.js.map +1 -1
  75. package/lib/stores/dataCube/core/DataCubeCoreState.d.ts.map +1 -1
  76. package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts +4 -4
  77. package/lib/stores/dataCube/core/DataCubeQueryBuilder.d.ts.map +1 -1
  78. package/lib/stores/dataCube/core/DataCubeQueryBuilder.js +70 -12
  79. package/lib/stores/dataCube/core/DataCubeQueryBuilder.js.map +1 -1
  80. package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts +8 -2
  81. package/lib/stores/dataCube/core/DataCubeQueryEngine.d.ts.map +1 -1
  82. package/lib/stores/dataCube/core/DataCubeQueryEngine.js +20 -15
  83. package/lib/stores/dataCube/core/DataCubeQueryEngine.js.map +1 -1
  84. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts +5 -4
  85. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.d.ts.map +1 -1
  86. package/lib/stores/dataCube/core/DataCubeQuerySnapshot.js.map +1 -1
  87. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.d.ts +2 -1
  88. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.d.ts.map +1 -1
  89. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js +131 -11
  90. package/lib/stores/dataCube/core/DataCubeQuerySnapshotBuilder.js.map +1 -1
  91. package/lib/stores/dataCube/core/DataCubeQuerySnapshotManager.d.ts.map +1 -1
  92. package/lib/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.d.ts.map +1 -1
  93. package/lib/stores/dataCube/editor/DataCubeEditorCodePanelState.d.ts.map +1 -1
  94. package/lib/stores/dataCube/editor/DataCubeEditorCodePanelState.js.map +1 -1
  95. package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.d.ts +1 -1
  96. package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.d.ts.map +1 -1
  97. package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.js +28 -0
  98. package/lib/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.js.map +1 -1
  99. package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.d.ts.map +1 -1
  100. package/lib/stores/dataCube/editor/DataCubeEditorColumnsPanelState.js.map +1 -1
  101. package/lib/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.d.ts.map +1 -1
  102. package/lib/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.d.ts.map +1 -1
  103. package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.d.ts.map +1 -1
  104. package/lib/stores/dataCube/editor/DataCubeEditorSortsPanelState.js.map +1 -1
  105. package/lib/stores/dataCube/editor/DataCubeEditorState.d.ts.map +1 -1
  106. package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.d.ts.map +1 -1
  107. package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.js +2 -1
  108. package/lib/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.js.map +1 -1
  109. package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.d.ts +9 -4
  110. package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.d.ts.map +1 -1
  111. package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.js +20 -4
  112. package/lib/stores/dataCube/editor/DataCubeMutableConfiguration.js.map +1 -1
  113. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts +3 -0
  114. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.d.ts.map +1 -1
  115. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js +64 -9
  116. package/lib/stores/dataCube/grid/DataCubeGridClientEngine.js.map +1 -1
  117. package/lib/stores/dataCube/grid/DataCubeGridClientExportEngine.d.ts.map +1 -1
  118. package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.d.ts.map +1 -1
  119. package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.js +23 -27
  120. package/lib/stores/dataCube/grid/DataCubeGridConfigurationBuilder.js.map +1 -1
  121. package/lib/stores/dataCube/grid/DataCubeGridControllerState.d.ts.map +1 -1
  122. package/lib/stores/dataCube/grid/DataCubeGridControllerState.js +2 -9
  123. package/lib/stores/dataCube/grid/DataCubeGridControllerState.js.map +1 -1
  124. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.d.ts +2 -1
  125. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.d.ts.map +1 -1
  126. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js +63 -11
  127. package/lib/stores/dataCube/grid/DataCubeGridQueryBuilder.js.map +1 -1
  128. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.d.ts +3 -1
  129. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.d.ts.map +1 -1
  130. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js +14 -26
  131. package/lib/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.js.map +1 -1
  132. package/lib/stores/dataCube/grid/DataCubeGridState.d.ts +1 -1
  133. package/lib/stores/dataCube/grid/DataCubeGridState.d.ts.map +1 -1
  134. package/lib/stores/dataCube/grid/DataCubeGridState.js +16 -2
  135. package/lib/stores/dataCube/grid/DataCubeGridState.js.map +1 -1
  136. package/package.json +6 -6
  137. package/src/application/LegendREPL.tsx +3 -6
  138. package/src/application/LegendREPLApplicationConfig.ts +1 -1
  139. package/src/application/LegendREPLDocumentation.ts +1 -0
  140. package/src/application/LegendREPLPluginManager.ts +7 -9
  141. package/src/components/LegendREPLApplication.tsx +2 -2
  142. package/src/components/LegendREPLFrameworkProvider.tsx +2 -5
  143. package/src/components/REPLStoreProvider.tsx +1 -1
  144. package/src/components/dataCube/DataCube.tsx +1 -1
  145. package/src/components/dataCube/editor/DataCubeEditor.tsx +2 -2
  146. package/src/components/dataCube/editor/DataCubeEditorCodePanel.tsx +3 -3
  147. package/src/components/dataCube/editor/DataCubeEditorColumnPropertiesPanel.tsx +35 -12
  148. package/src/components/dataCube/editor/DataCubeEditorGeneralPropertiesPanel.tsx +6 -6
  149. package/src/components/dataCube/grid/DataCubeGrid.tsx +4 -6
  150. package/src/components/repl/Alert.tsx +138 -94
  151. package/src/components/repl/DocumentationPanel.tsx +2 -50
  152. package/src/components/repl/Form.tsx +47 -0
  153. package/src/components/repl/SettingsPanel.tsx +42 -8
  154. package/src/index.tsx +4 -8
  155. package/src/server/REPLEngine.ts +1 -0
  156. package/src/stores/LayoutManagerState.ts +12 -4
  157. package/src/stores/LegendREPLApplicationPlugin.ts +2 -2
  158. package/src/stores/REPLStore.tsx +54 -7
  159. package/src/stores/dataCube/DataCubeEngine.ts +30 -13
  160. package/src/stores/dataCube/DataCubeState.ts +5 -4
  161. package/src/stores/dataCube/core/DataCubeConfiguration.ts +2 -6
  162. package/src/stores/dataCube/core/DataCubeCoreState.ts +3 -3
  163. package/src/stores/dataCube/core/DataCubeQueryBuilder.ts +89 -17
  164. package/src/stores/dataCube/core/DataCubeQueryEngine.ts +11 -2
  165. package/src/stores/dataCube/core/DataCubeQuerySnapshot.ts +11 -9
  166. package/src/stores/dataCube/core/DataCubeQuerySnapshotBuilder.ts +154 -15
  167. package/src/stores/dataCube/core/DataCubeQuerySnapshotManager.ts +6 -6
  168. package/src/stores/dataCube/core/DataCubeQuerySnapshotSubscriber.ts +3 -3
  169. package/src/stores/dataCube/editor/DataCubeEditorCodePanelState.ts +4 -6
  170. package/src/stores/dataCube/editor/DataCubeEditorColumnPropertiesPanelState.ts +43 -12
  171. package/src/stores/dataCube/editor/DataCubeEditorColumnsPanelState.ts +6 -8
  172. package/src/stores/dataCube/editor/DataCubeEditorColumnsSelectorState.ts +4 -4
  173. package/src/stores/dataCube/editor/DataCubeEditorGeneralPropertiesPanelState.ts +5 -5
  174. package/src/stores/dataCube/editor/DataCubeEditorSortsPanelState.ts +5 -7
  175. package/src/stores/dataCube/editor/DataCubeEditorState.tsx +4 -4
  176. package/src/stores/dataCube/editor/DataCubeEditorVerticalPivotsPanelState.ts +4 -3
  177. package/src/stores/dataCube/editor/DataCubeMutableConfiguration.ts +102 -87
  178. package/src/stores/dataCube/grid/DataCubeGridClientEngine.ts +75 -15
  179. package/src/stores/dataCube/grid/DataCubeGridClientExportEngine.ts +2 -2
  180. package/src/stores/dataCube/grid/DataCubeGridConfigurationBuilder.tsx +28 -29
  181. package/src/stores/dataCube/grid/DataCubeGridControllerState.ts +7 -16
  182. package/src/stores/dataCube/grid/DataCubeGridQueryBuilder.ts +72 -10
  183. package/src/stores/dataCube/grid/DataCubeGridQuerySnapshotBuilder.ts +27 -37
  184. package/src/stores/dataCube/grid/DataCubeGridState.ts +27 -9
@@ -52,13 +52,14 @@ import {
52
52
  INTERNAL__GRID_CLIENT_TOOLTIP_SHOW_DELAY,
53
53
  INTERNAL__GRID_CLIENT_SIDE_BAR_WIDTH,
54
54
  INTERNAL__GRID_CLIENT_ROW_GROUPING_COUNT_AGG_COLUMN_ID,
55
+ INTERNAL__GRID_CLIENT_MISSING_VALUE,
55
56
  } from './DataCubeGridClientEngine.js';
56
57
  import { PRIMITIVE_TYPE } from '@finos/legend-graph';
57
58
  import {
58
59
  getQueryParameters,
59
60
  getQueryParameterValue,
60
- IllegalStateError,
61
61
  isNonNullable,
62
+ isNullable,
62
63
  isNumber,
63
64
  isValidUrl,
64
65
  } from '@finos/legend-shared';
@@ -67,7 +68,6 @@ import type {
67
68
  DataCubeConfiguration,
68
69
  } from '../core/DataCubeConfiguration.js';
69
70
  import {
70
- DataCubeAggregateFunction,
71
71
  DataCubeColumnDataType,
72
72
  DataCubeColumnPinPlacement,
73
73
  DataCubeNumberScale,
@@ -76,6 +76,7 @@ import {
76
76
  getDataType,
77
77
  DataCubeQuerySortOperation,
78
78
  DataCubeColumnKind,
79
+ DEFAULT_MISSING_VALUE_DISPLAY_TEXT,
79
80
  } from '../core/DataCubeQueryEngine.js';
80
81
  import type { CustomLoadingCellRendererProps } from '@ag-grid-community/react';
81
82
  import { DataCubeIcon } from '@finos/legend-art';
@@ -83,7 +84,7 @@ import type { DataCubeState } from '../DataCubeState.js';
83
84
 
84
85
  // --------------------------------- UTILITIES ---------------------------------
85
86
 
86
- // See https://www.ag-grid.com/javascript-data-grid/cell-data-types/
87
+ // See https://www.ag-grid.com/react-data-grid/cell-data-types/
87
88
  function _cellDataType(column: DataCubeQuerySnapshotColumn) {
88
89
  switch (column.type) {
89
90
  case PRIMITIVE_TYPE.NUMBER:
@@ -124,25 +125,6 @@ function _allowedAggFuncs(column: DataCubeQuerySnapshotColumn) {
124
125
  }
125
126
  }
126
127
 
127
- function _aggFunc(
128
- func: DataCubeAggregateFunction,
129
- ): GridClientAggregateOperation {
130
- switch (func) {
131
- case DataCubeAggregateFunction.AVERAGE:
132
- return GridClientAggregateOperation.AVERAGE;
133
- case DataCubeAggregateFunction.COUNT:
134
- return GridClientAggregateOperation.COUNT;
135
- case DataCubeAggregateFunction.MAX:
136
- return GridClientAggregateOperation.MAX;
137
- case DataCubeAggregateFunction.MIN:
138
- return GridClientAggregateOperation.MIN;
139
- case DataCubeAggregateFunction.SUM:
140
- return GridClientAggregateOperation.SUM;
141
- default:
142
- throw new IllegalStateError(`Unsupported aggregate function '${func}'`);
143
- }
144
- }
145
-
146
128
  function scaleNumber(
147
129
  value: number,
148
130
  type: DataCubeNumberScale | undefined,
@@ -267,8 +249,15 @@ function _displaySpec(columnData: ColumnData) {
267
249
  dataType === DataCubeColumnDataType.NUMBER
268
250
  ? (params) => {
269
251
  const value = params.value as number | null | undefined;
270
- if (value === null || value === undefined) {
271
- return null;
252
+ if (
253
+ isNullable(value) ||
254
+ (value as unknown as string) ===
255
+ INTERNAL__GRID_CLIENT_MISSING_VALUE
256
+ ) {
257
+ return (
258
+ column.missingValueDisplayText ??
259
+ DEFAULT_MISSING_VALUE_DISPLAY_TEXT
260
+ );
272
261
  }
273
262
  const showNegativeNumberInParens =
274
263
  column.negativeNumberInParens && value < 0;
@@ -296,7 +285,11 @@ function _displaySpec(columnData: ColumnData) {
296
285
  (scaledNumber.unit ? ` ${scaledNumber.unit}` : '')
297
286
  );
298
287
  }
299
- : (params) => params.value,
288
+ : (params) =>
289
+ params.value === INTERNAL__GRID_CLIENT_MISSING_VALUE
290
+ ? (column.missingValueDisplayText ??
291
+ DEFAULT_MISSING_VALUE_DISPLAY_TEXT)
292
+ : params.value,
300
293
  loadingCellRenderer: DataCubeGridLoadingCellRenderer,
301
294
  cellClassRules: {
302
295
  [generateFontFamilyUtilityClassName(fontFamily)]: () => true,
@@ -355,7 +348,8 @@ function _displaySpec(columnData: ColumnData) {
355
348
  : GridClientPinnedAlignement.LEFT
356
349
  : null,
357
350
  tooltipValueGetter: (params) =>
358
- isNonNullable(params.value)
351
+ isNonNullable(params.value) &&
352
+ params.value !== INTERNAL__GRID_CLIENT_MISSING_VALUE
359
353
  ? `Value = ${params.value === '' ? "''" : params.value === true ? 'TRUE' : params.value === false ? 'FALSE' : params.value}`
360
354
  : `Missing Value`,
361
355
  } as ColDef;
@@ -410,9 +404,15 @@ function _rowGroupSpec(columnData: ColumnData) {
410
404
  enableRowGroup: column.kind === DataCubeColumnKind.DIMENSION,
411
405
  enableValue: column.kind === DataCubeColumnKind.MEASURE,
412
406
  rowGroup: Boolean(groupByCol),
413
- // TODO: @akphi - add this from configuration object
407
+ rowGroupIndex: groupByCol
408
+ ? (data.groupBy?.columns.indexOf(groupByCol) ?? null)
409
+ : null,
410
+ // NOTE: we don't quite care about populating these accurately
411
+ // since ag-grid aggregation does not support parameters, so
412
+ // its set of supported aggregators will never match that specified
413
+ // in the editor, so we just assign dummy values here
414
414
  aggFunc: aggCol
415
- ? _aggFunc(aggCol.function)
415
+ ? aggCol.operation
416
416
  : rowGroupColumn
417
417
  ? (
418
418
  [
@@ -425,7 +425,6 @@ function _rowGroupSpec(columnData: ColumnData) {
425
425
  ? GridClientAggregateOperation.SUM
426
426
  : null
427
427
  : null,
428
- // TODO: @akphi - add this from configuration object
429
428
  allowedAggFuncs: rowGroupColumn ? _allowedAggFuncs(rowGroupColumn) : [],
430
429
  } satisfies ColDef;
431
430
  }
@@ -34,6 +34,7 @@ import type {
34
34
  } from '@ag-grid-community/core';
35
35
  import type { DataCubeState } from '../DataCubeState.js';
36
36
  import { generateMenuBuilder } from './DataCubeGridMenuBuilder.js';
37
+ import { _groupByAggCols } from './DataCubeGridQuerySnapshotBuilder.js';
37
38
 
38
39
  /**
39
40
  * This state is responsible for capturing edition to the data cube query
@@ -96,7 +97,7 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotSubscriber
96
97
  this.applyChanges();
97
98
  }
98
99
 
99
- showColumn(colName: string | undefined, isVisible: boolean): void {
100
+ showColumn(colName: string | undefined, isVisible: boolean) {
100
101
  const columnConfiguration = this.getColumnConfiguration(colName);
101
102
  if (columnConfiguration) {
102
103
  columnConfiguration.hideFromView = !isVisible;
@@ -184,7 +185,7 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotSubscriber
184
185
  this.applyChanges();
185
186
  }
186
187
 
187
- private applyChanges(): void {
188
+ private applyChanges() {
188
189
  const baseSnapshot = guaranteeNonNullable(this.getLatestSnapshot());
189
190
  const snapshot = baseSnapshot.clone();
190
191
 
@@ -197,20 +198,10 @@ export class DataCubeGridControllerState extends DataCubeQuerySnapshotSubscriber
197
198
  snapshot.data.groupBy = this.verticalPivotedColumns.length
198
199
  ? {
199
200
  columns: this.verticalPivotedColumns,
200
- aggColumns: this.configuration.columns
201
- .filter(
202
- (column) =>
203
- column.kind === DataCubeColumnKind.MEASURE &&
204
- column.aggregateFunction !== undefined &&
205
- !this.verticalPivotedColumns.find(
206
- (col) => col.name === column.name,
207
- ),
208
- )
209
- .map((column) => ({
210
- name: column.name,
211
- type: column.type,
212
- function: guaranteeNonNullable(column.aggregateFunction),
213
- })),
201
+ aggColumns: _groupByAggCols(
202
+ baseSnapshot.data.groupBy,
203
+ this.configuration,
204
+ ),
214
205
  }
215
206
  : undefined;
216
207
 
@@ -15,6 +15,7 @@
15
15
  */
16
16
 
17
17
  import {
18
+ PRIMITIVE_TYPE,
18
19
  type V1_AppliedFunction,
19
20
  extractElementNameFromPath as _name,
20
21
  } from '@finos/legend-graph';
@@ -25,9 +26,9 @@ import {
25
26
  DataCubeFunction,
26
27
  type DataCubeQueryFunctionMap,
27
28
  } from '../core/DataCubeQueryEngine.js';
28
- import { guaranteeNonNullable } from '@finos/legend-shared';
29
+ import { guaranteeNonNullable, isNullable } from '@finos/legend-shared';
29
30
  import {
30
- _aggCols,
31
+ _groupByAggCols,
31
32
  _colSpec,
32
33
  _cols,
33
34
  _filter,
@@ -36,7 +37,11 @@ import {
36
37
  _lambda,
37
38
  _var,
38
39
  } from '../core/DataCubeQueryBuilder.js';
39
- import { INTERNAL__GRID_CLIENT_ROW_GROUPING_COUNT_AGG_COLUMN_ID } from './DataCubeGridClientEngine.js';
40
+ import {
41
+ INTERNAL__GRID_CLIENT_MISSING_VALUE,
42
+ INTERNAL__GRID_CLIENT_ROW_GROUPING_COUNT_AGG_COLUMN_ID,
43
+ } from './DataCubeGridClientEngine.js';
44
+ import type { DataCubeConfiguration } from '../core/DataCubeConfiguration.js';
40
45
 
41
46
  /*****************************************************************************
42
47
  * [GRID]
@@ -60,12 +65,13 @@ function _rowGroupingCountCol() {
60
65
  // --------------------------------- MAIN ---------------------------------
61
66
 
62
67
  export function generateRowGroupingDrilldownExecutableQueryPostProcessor(
63
- drilldownValues: string[],
68
+ drilldownValues: (string | null | undefined)[],
64
69
  ) {
65
70
  return (
66
71
  snapshot: DataCubeQuerySnapshot,
67
72
  sequence: V1_AppliedFunction[],
68
73
  funcMap: DataCubeQueryFunctionMap,
74
+ configuration: DataCubeConfiguration,
69
75
  ) => {
70
76
  const _unprocess = (funcMapKey: keyof DataCubeQueryFunctionMap) => {
71
77
  const func = funcMap[funcMapKey];
@@ -91,11 +97,64 @@ export function generateRowGroupingDrilldownExecutableQueryPostProcessor(
91
97
  [_var()],
92
98
  [
93
99
  _filter({
94
- conditions: drilldownValues.map((drilldownValue, i) => ({
95
- ...guaranteeNonNullable(groupBy.columns[i]),
96
- operation: DataCubeQueryFilterOperation.EQUAL,
97
- value: drilldownValue,
98
- })),
100
+ conditions: drilldownValues.map((value, i) => {
101
+ const groupByColumn = guaranteeNonNullable(
102
+ groupBy.columns[i],
103
+ );
104
+ if (
105
+ isNullable(value) ||
106
+ value === INTERNAL__GRID_CLIENT_MISSING_VALUE
107
+ ) {
108
+ return {
109
+ ...groupByColumn,
110
+ operation: DataCubeQueryFilterOperation.BLANK,
111
+ value: undefined,
112
+ };
113
+ }
114
+ const condition = {
115
+ ...groupByColumn,
116
+ operation: DataCubeQueryFilterOperation.EQUAL,
117
+ value: undefined,
118
+ };
119
+ switch (groupByColumn.type) {
120
+ case PRIMITIVE_TYPE.BOOLEAN:
121
+ return {
122
+ ...condition,
123
+ value: {
124
+ type: PRIMITIVE_TYPE.BOOLEAN,
125
+ value: value === 'true',
126
+ },
127
+ };
128
+ case PRIMITIVE_TYPE.INTEGER:
129
+ return {
130
+ ...condition,
131
+ value: {
132
+ type: groupByColumn.type,
133
+ value: parseInt(value, 10),
134
+ },
135
+ };
136
+ case PRIMITIVE_TYPE.NUMBER:
137
+ case PRIMITIVE_TYPE.DECIMAL:
138
+ case PRIMITIVE_TYPE.FLOAT:
139
+ return {
140
+ ...condition,
141
+ value: {
142
+ type: groupByColumn.type,
143
+ value: parseFloat(value),
144
+ },
145
+ };
146
+ case PRIMITIVE_TYPE.STRING:
147
+ case PRIMITIVE_TYPE.DATE:
148
+ case PRIMITIVE_TYPE.DATETIME:
149
+ case PRIMITIVE_TYPE.STRICTDATE:
150
+ case PRIMITIVE_TYPE.STRICTTIME:
151
+ default:
152
+ return {
153
+ ...condition,
154
+ value: { type: groupByColumn.type, value },
155
+ };
156
+ }
157
+ }),
99
158
  groupOperation: DataCubeQueryFilterGroupOperation.AND,
100
159
  }),
101
160
  ],
@@ -113,7 +172,10 @@ export function generateRowGroupingDrilldownExecutableQueryPostProcessor(
113
172
  );
114
173
  const groupByFunc = _function(_name(DataCubeFunction.GROUP_BY), [
115
174
  _cols(groupByColumns.map((col) => _colSpec(col.name))),
116
- _cols([..._aggCols(groupBy.aggColumns), _rowGroupingCountCol()]),
175
+ _cols([
176
+ ..._groupByAggCols(groupBy.aggColumns),
177
+ _rowGroupingCountCol(),
178
+ ]),
117
179
  ]);
118
180
  sequence[groupByIdx] = groupByFunc;
119
181
  funcMap.groupBy = groupByFunc;
@@ -24,41 +24,34 @@
24
24
  import type { IServerSideGetRowsRequest } from '@ag-grid-community/core';
25
25
  import {
26
26
  type DataCubeQuerySnapshot,
27
+ type DataCubeQuerySnapshotGroupBy,
27
28
  _getCol,
28
29
  } from '../core/DataCubeQuerySnapshot.js';
30
+ import { GridClientSortDirection } from './DataCubeGridClientEngine.js';
29
31
  import {
30
- IllegalStateError,
31
- guaranteeNonNullable,
32
- isNonNullable,
33
- } from '@finos/legend-shared';
34
- import {
35
- GridClientAggregateOperation,
36
- GridClientSortDirection,
37
- } from './DataCubeGridClientEngine.js';
38
- import {
32
+ DataCubeColumnKind,
39
33
  DataCubeQuerySortOperation,
40
- DataCubeAggregateFunction,
41
34
  } from '../core/DataCubeQueryEngine.js';
35
+ import { DataCubeConfiguration } from '../core/DataCubeConfiguration.js';
36
+ import { _defaultAggCol } from '../core/DataCubeQuerySnapshotBuilder.js';
37
+ import { isNonNullable } from '@finos/legend-shared';
42
38
 
43
- // --------------------------------- UTILITIES ---------------------------------
44
-
45
- function _aggFunc(
46
- func: GridClientAggregateOperation,
47
- ): DataCubeAggregateFunction {
48
- switch (func) {
49
- case GridClientAggregateOperation.AVERAGE:
50
- return DataCubeAggregateFunction.AVERAGE;
51
- case GridClientAggregateOperation.COUNT:
52
- return DataCubeAggregateFunction.COUNT;
53
- case GridClientAggregateOperation.MAX:
54
- return DataCubeAggregateFunction.MAX;
55
- case GridClientAggregateOperation.MIN:
56
- return DataCubeAggregateFunction.MIN;
57
- case GridClientAggregateOperation.SUM:
58
- return DataCubeAggregateFunction.SUM;
59
- default:
60
- throw new IllegalStateError(`Unsupported aggregate function '${func}'`);
61
- }
39
+ export function _groupByAggCols(
40
+ groupBy: DataCubeQuerySnapshotGroupBy | undefined,
41
+ configuration: DataCubeConfiguration,
42
+ ) {
43
+ return configuration.columns
44
+ .filter(
45
+ (column) =>
46
+ column.kind === DataCubeColumnKind.MEASURE &&
47
+ !groupBy?.columns.find((col) => col.name === column.name),
48
+ )
49
+ .map(
50
+ (column) =>
51
+ groupBy?.aggColumns.find((col) => col.name === column.name) ??
52
+ _defaultAggCol(column.name, column.type),
53
+ )
54
+ .filter(isNonNullable);
62
55
  }
63
56
 
64
57
  // --------------------------------- MAIN ---------------------------------
@@ -66,7 +59,10 @@ function _aggFunc(
66
59
  export function buildQuerySnapshot(
67
60
  request: IServerSideGetRowsRequest,
68
61
  baseSnapshot: DataCubeQuerySnapshot,
69
- ): DataCubeQuerySnapshot {
62
+ ) {
63
+ const configuration = DataCubeConfiguration.serialization.fromJson(
64
+ baseSnapshot.data.configuration,
65
+ );
70
66
  const snapshot = baseSnapshot.clone();
71
67
 
72
68
  // --------------------------------- GROUP BY ---------------------------------
@@ -78,13 +74,7 @@ export function buildQuerySnapshot(
78
74
  name: col.id,
79
75
  type: _getCol(availableCols, col.id).type,
80
76
  })),
81
- aggColumns: request.valueCols
82
- .filter((col) => isNonNullable(col.field) && isNonNullable(col.aggFunc))
83
- .map((col) => ({
84
- name: guaranteeNonNullable(col.field),
85
- type: _getCol(availableCols, guaranteeNonNullable(col.field)).type,
86
- function: _aggFunc(col.aggFunc as GridClientAggregateOperation),
87
- })),
77
+ aggColumns: _groupByAggCols(baseSnapshot.data.groupBy, configuration),
88
78
  };
89
79
  } else {
90
80
  snapshot.data.groupBy = undefined;
@@ -18,7 +18,11 @@ import { guaranteeNonNullable, hashArray } from '@finos/legend-shared';
18
18
  import { action, makeObservable, observable, runInAction } from 'mobx';
19
19
  import type { GridApi } from '@ag-grid-community/core';
20
20
  import type { DataCubeState } from '../DataCubeState.js';
21
- import { DataCubeGridClientServerSideDataSource } from './DataCubeGridClientEngine.js';
21
+ import {
22
+ DataCubeGridClientServerSideDataSource,
23
+ INTERNAL__GRID_CLIENT_DEFAULT_CACHE_BLOCK_SIZE,
24
+ INTERNAL__GRID_CLIENT_MAX_CACHE_BLOCK_SIZE,
25
+ } from './DataCubeGridClientEngine.js';
22
26
  import { DataCubeQuerySnapshotSubscriber } from '../core/DataCubeQuerySnapshotSubscriber.js';
23
27
  import type { DataCubeQuerySnapshot } from '../core/DataCubeQuerySnapshot.js';
24
28
  import { generateGridOptionsFromSnapshot } from './DataCubeGridConfigurationBuilder.js';
@@ -37,7 +41,7 @@ class DataCubeGridDatasourceConfiguration {
37
41
  this.limit = snapshot?.data.limit;
38
42
  }
39
43
 
40
- get hashCode(): string {
44
+ get hashCode() {
41
45
  return hashArray([`limit: ${this.limit ?? ''}`]);
42
46
  }
43
47
  }
@@ -76,7 +80,7 @@ export class DataCubeGridState extends DataCubeQuerySnapshotSubscriber {
76
80
  this.clientDataSource = new DataCubeGridClientServerSideDataSource(this);
77
81
  }
78
82
 
79
- setPaginationEnabled(val: boolean): void {
83
+ setPaginationEnabled(val: boolean) {
80
84
  this.isPaginationEnabled = val;
81
85
 
82
86
  // hard reset the grid, this will force the grid to fetch data again
@@ -84,24 +88,31 @@ export class DataCubeGridState extends DataCubeQuerySnapshotSubscriber {
84
88
  // for how many page that we loaded when pagination is off, the datasource
85
89
  // will fire that many data fetch operations which is expensive.
86
90
  this.clientDataSource = new DataCubeGridClientServerSideDataSource(this);
91
+ // NOTE: ag-grid uses the cache block size as page size, so it's important to set this
92
+ // in corresponding to the pagination setting, else it would cause unexpected scrolling behavior
93
+ this.client.updateGridOptions({
94
+ cacheBlockSize: val
95
+ ? INTERNAL__GRID_CLIENT_DEFAULT_CACHE_BLOCK_SIZE
96
+ : INTERNAL__GRID_CLIENT_MAX_CACHE_BLOCK_SIZE,
97
+ });
87
98
  }
88
99
 
89
- setScrollHintText(val: string | undefined): void {
100
+ setScrollHintText(val: string | undefined) {
90
101
  this.scrollHintText = val;
91
102
  }
92
103
 
93
- get client(): GridApi {
104
+ get client() {
94
105
  return guaranteeNonNullable(this._client, 'Grid client is not configured');
95
106
  }
96
107
 
97
- configureClient(val: GridApi | undefined): void {
108
+ configureClient(val: GridApi | undefined) {
98
109
  this._client = val;
99
110
  }
100
111
 
101
112
  override async applySnapshot(
102
113
  snapshot: DataCubeQuerySnapshot,
103
114
  previousSnapshot: DataCubeQuerySnapshot | undefined,
104
- ): Promise<void> {
115
+ ) {
105
116
  const existingExtraConfiguration = this.datasourceConfiguration;
106
117
  const queryConfiguration = DataCubeConfiguration.serialization.fromJson(
107
118
  snapshot.data.configuration,
@@ -130,10 +141,17 @@ export class DataCubeGridState extends DataCubeQuerySnapshotSubscriber {
130
141
  queryConfiguration,
131
142
  this.dataCube,
132
143
  );
133
- this.client.updateGridOptions(gridOptions);
144
+ this.client.updateGridOptions({
145
+ ...gridOptions,
146
+ // NOTE: ag-grid uses the cache block size as page size, so it's important to set this
147
+ // in corresponding to the pagination setting, else it would cause unexpected scrolling behavior
148
+ cacheBlockSize: this.isPaginationEnabled
149
+ ? INTERNAL__GRID_CLIENT_DEFAULT_CACHE_BLOCK_SIZE
150
+ : INTERNAL__GRID_CLIENT_MAX_CACHE_BLOCK_SIZE,
151
+ });
134
152
  }
135
153
 
136
- override async initialize(): Promise<void> {
154
+ override async initialize() {
137
155
  // do nothing
138
156
  }
139
157
  }