@finos/legend-application-repl 0.0.20 → 0.0.21

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 (116) hide show
  1. package/lib/application/LegendREPLGridClient.d.ts +0 -2
  2. package/lib/application/LegendREPLGridClient.d.ts.map +1 -1
  3. package/lib/application/LegendREPLGridClient.js +6 -33
  4. package/lib/application/LegendREPLGridClient.js.map +1 -1
  5. package/lib/components/AgGrid.d.ts +3 -2
  6. package/lib/components/AgGrid.d.ts.map +1 -1
  7. package/lib/components/AgGrid.js +1 -1
  8. package/lib/components/AgGrid.js.map +1 -1
  9. package/lib/components/LegendREPLGridClientApplication.d.ts +7 -0
  10. package/lib/components/LegendREPLGridClientApplication.d.ts.map +1 -1
  11. package/lib/components/LegendREPLGridClientApplication.js +12 -5
  12. package/lib/components/LegendREPLGridClientApplication.js.map +1 -1
  13. package/lib/components/REPLGridClient.d.ts +11 -2
  14. package/lib/components/REPLGridClient.d.ts.map +1 -1
  15. package/lib/components/REPLGridClient.js +107 -30
  16. package/lib/components/REPLGridClient.js.map +1 -1
  17. package/lib/components/dataCube/DataCubeGridEditor.d.ts +22 -0
  18. package/lib/components/dataCube/DataCubeGridEditor.d.ts.map +1 -0
  19. package/lib/components/dataCube/DataCubeGridEditor.js +37 -0
  20. package/lib/components/dataCube/DataCubeGridEditor.js.map +1 -0
  21. package/lib/components/dataCube/DataCubeQueryTextEditor.d.ts +22 -0
  22. package/lib/components/dataCube/DataCubeQueryTextEditor.d.ts.map +1 -0
  23. package/lib/components/{REPLQueryEditor.js → dataCube/DataCubeQueryTextEditor.js} +26 -44
  24. package/lib/components/dataCube/DataCubeQueryTextEditor.js.map +1 -0
  25. package/lib/components/grid/GridUtils.d.ts +4 -2
  26. package/lib/components/grid/GridUtils.d.ts.map +1 -1
  27. package/lib/components/grid/GridUtils.js +37 -2
  28. package/lib/components/grid/GridUtils.js.map +1 -1
  29. package/lib/components/grid/ServerSideDataSource.d.ts.map +1 -1
  30. package/lib/components/grid/ServerSideDataSource.js +8 -5
  31. package/lib/components/grid/ServerSideDataSource.js.map +1 -1
  32. package/lib/components/grid/TDSLambdaBuilder.d.ts.map +1 -1
  33. package/lib/components/grid/TDSLambdaBuilder.js +1 -1
  34. package/lib/components/grid/TDSLambdaBuilder.js.map +1 -1
  35. package/lib/components/grid/TDSQuery.d.ts +25 -0
  36. package/lib/components/grid/TDSQuery.d.ts.map +1 -0
  37. package/lib/components/grid/TDSQuery.js +32 -0
  38. package/lib/components/grid/TDSQuery.js.map +1 -0
  39. package/lib/components/grid/TDSRequest.d.ts +15 -2
  40. package/lib/components/grid/TDSRequest.d.ts.map +1 -1
  41. package/lib/components/grid/TDSRequest.js +52 -0
  42. package/lib/components/grid/TDSRequest.js.map +1 -1
  43. package/lib/grid.css +1 -1
  44. package/lib/index.css +2 -2
  45. package/lib/index.css.map +1 -1
  46. package/lib/package.json +12 -12
  47. package/lib/repl.css +2 -2
  48. package/lib/repl.css.map +1 -1
  49. package/lib/server/REPLServerClient.d.ts +3 -0
  50. package/lib/server/REPLServerClient.d.ts.map +1 -1
  51. package/lib/server/REPLServerClient.js +2 -0
  52. package/lib/server/REPLServerClient.js.map +1 -1
  53. package/lib/stores/REPLGridClientStore.d.ts +2 -13
  54. package/lib/stores/REPLGridClientStore.d.ts.map +1 -1
  55. package/lib/stores/REPLGridClientStore.js +6 -144
  56. package/lib/stores/REPLGridClientStore.js.map +1 -1
  57. package/lib/stores/dataCube/DataCubeConfigState.d.ts +32 -0
  58. package/lib/stores/dataCube/DataCubeConfigState.d.ts.map +1 -0
  59. package/lib/stores/dataCube/DataCubeConfigState.js +62 -0
  60. package/lib/stores/dataCube/DataCubeConfigState.js.map +1 -0
  61. package/lib/stores/{REPLGridState.d.ts → dataCube/DataCubeGridState.d.ts} +11 -12
  62. package/lib/stores/dataCube/DataCubeGridState.d.ts.map +1 -0
  63. package/lib/stores/dataCube/DataCubeGridState.js +108 -0
  64. package/lib/stores/dataCube/DataCubeGridState.js.map +1 -0
  65. package/lib/stores/dataCube/DataCubePanelState.d.ts +23 -0
  66. package/lib/stores/dataCube/DataCubePanelState.d.ts.map +1 -0
  67. package/lib/stores/dataCube/DataCubePanelState.js +22 -0
  68. package/lib/stores/dataCube/DataCubePanelState.js.map +1 -0
  69. package/lib/stores/dataCube/DataCubePropertiesPanelState.d.ts +34 -0
  70. package/lib/stores/dataCube/DataCubePropertiesPanelState.d.ts.map +1 -0
  71. package/lib/stores/dataCube/DataCubePropertiesPanelState.js +57 -0
  72. package/lib/stores/dataCube/DataCubePropertiesPanelState.js.map +1 -0
  73. package/lib/{components/REPLQueryEditor.d.ts → stores/dataCube/DataCubeQueryEditorState.d.ts} +2 -5
  74. package/lib/stores/dataCube/DataCubeQueryEditorState.d.ts.map +1 -0
  75. package/lib/stores/dataCube/DataCubeQueryEditorState.js +49 -0
  76. package/lib/stores/dataCube/DataCubeQueryEditorState.js.map +1 -0
  77. package/lib/stores/dataCube/DataCubeQueryTextEditorState.d.ts +25 -0
  78. package/lib/stores/dataCube/DataCubeQueryTextEditorState.d.ts.map +1 -0
  79. package/lib/stores/dataCube/DataCubeQueryTextEditorState.js +35 -0
  80. package/lib/stores/dataCube/DataCubeQueryTextEditorState.js.map +1 -0
  81. package/lib/stores/dataCube/DataCubeState.d.ts +41 -0
  82. package/lib/stores/dataCube/DataCubeState.d.ts.map +1 -0
  83. package/lib/stores/dataCube/DataCubeState.js +208 -0
  84. package/lib/stores/dataCube/DataCubeState.js.map +1 -0
  85. package/lib/stores/dataCube/HPivotAndSortPanelState.d.ts +40 -0
  86. package/lib/stores/dataCube/HPivotAndSortPanelState.d.ts.map +1 -0
  87. package/lib/stores/dataCube/HPivotAndSortPanelState.js +130 -0
  88. package/lib/stores/dataCube/HPivotAndSortPanelState.js.map +1 -0
  89. package/package.json +18 -18
  90. package/src/application/LegendREPLGridClient.tsx +5 -55
  91. package/src/components/AgGrid.tsx +2 -6
  92. package/src/components/LegendREPLGridClientApplication.tsx +18 -1
  93. package/src/components/REPLGridClient.tsx +445 -111
  94. package/src/components/dataCube/DataCubeGridEditor.tsx +69 -0
  95. package/src/components/{REPLQueryEditor.tsx → dataCube/DataCubeQueryTextEditor.tsx} +87 -58
  96. package/src/components/grid/GridUtils.ts +47 -3
  97. package/src/components/grid/ServerSideDataSource.ts +17 -4
  98. package/src/components/grid/TDSLambdaBuilder.ts +5 -1
  99. package/src/components/grid/TDSQuery.ts +37 -0
  100. package/src/components/grid/TDSRequest.ts +80 -2
  101. package/src/server/REPLServerClient.ts +17 -0
  102. package/src/stores/REPLGridClientStore.ts +6 -248
  103. package/src/stores/dataCube/DataCubeConfigState.ts +79 -0
  104. package/src/stores/{REPLGridState.ts → dataCube/DataCubeGridState.ts} +65 -30
  105. package/src/stores/dataCube/DataCubePanelState.ts +28 -0
  106. package/src/stores/dataCube/DataCubePropertiesPanelState.ts +65 -0
  107. package/src/stores/dataCube/DataCubeQueryEditorState.ts +66 -0
  108. package/src/stores/dataCube/DataCubeQueryTextEditorState.ts +41 -0
  109. package/src/stores/dataCube/DataCubeState.ts +333 -0
  110. package/src/stores/dataCube/HPivotAndSortPanelState.ts +170 -0
  111. package/tsconfig.json +11 -2
  112. package/lib/components/REPLQueryEditor.d.ts.map +0 -1
  113. package/lib/components/REPLQueryEditor.js.map +0 -1
  114. package/lib/stores/REPLGridState.d.ts.map +0 -1
  115. package/lib/stores/REPLGridState.js +0 -86
  116. package/lib/stores/REPLGridState.js.map +0 -1
@@ -16,62 +16,18 @@
16
16
 
17
17
  import type { LegendREPLGridClientApplicationStore } from './LegendREPLGridClientBaseStore.js';
18
18
  import { REPLServerClient } from '../server/REPLServerClient.js';
19
- import {
20
- NetworkClient,
21
- type GeneratorFn,
22
- type PlainObject,
23
- assertErrorThrown,
24
- LogEvent,
25
- guaranteeNonNullable,
26
- guaranteeType,
27
- ActionState,
28
- HttpStatus,
29
- NetworkClientError,
30
- } from '@finos/legend-shared';
31
- import type { TDSRequest } from '../components/grid/TDSRequest.js';
32
- import { flow, flowResult, makeObservable, observable } from 'mobx';
33
- import { REPLGridServerResult } from '../components/grid/REPLGridServerResult.js';
34
- import {
35
- LEGEND_APPLICATION_REPL_SETTING_KEY,
36
- LEGEND_REPL_EVENT,
37
- } from '../Const.js';
38
- import { REPLGridState } from './REPLGridState.js';
39
- import { buildLambdaExpressions } from '../components/grid/TDSLambdaBuilder.js';
40
- import {
41
- type V1_TDSExecutionResult,
42
- TDSExecutionResult,
43
- V1_Lambda,
44
- V1_buildExecutionResult,
45
- V1_deserializeValueSpecification,
46
- V1_serializeExecutionResult,
47
- V1_serializeValueSpecification,
48
- V1_ParserError,
49
- ParserError,
50
- SourceInformation,
51
- } from '@finos/legend-graph';
52
- import { CompletionItem } from './CompletionResult.js';
53
- import {
54
- languages as monacoLanguagesAPI,
55
- type IPosition,
56
- type editor as monacoEditorAPI,
57
- } from 'monaco-editor';
19
+ import { NetworkClient } from '@finos/legend-shared';
20
+ import { makeObservable, observable } from 'mobx';
21
+ import { DataCubeState } from './dataCube/DataCubeState.js';
58
22
 
59
23
  export class REPLGridClientStore {
60
24
  readonly applicationStore: LegendREPLGridClientApplicationStore;
61
25
  readonly client: REPLServerClient;
62
- replGridState!: REPLGridState;
63
- executeAction = ActionState.create();
26
+ dataCubeState!: DataCubeState;
64
27
 
65
28
  constructor(applicationStore: LegendREPLGridClientApplicationStore) {
66
29
  makeObservable(this, {
67
- replGridState: observable,
68
- executeAction: observable,
69
- getREPLGridServerResult: flow,
70
- getInitialQueryLambda: flow,
71
- getInitialREPLGridServerResult: flow,
72
- getLicenseKey: flow,
73
- executeLambda: flow,
74
- parseQuery: flow,
30
+ dataCubeState: observable,
75
31
  });
76
32
  this.applicationStore = applicationStore;
77
33
  this.client = new REPLServerClient(
@@ -82,204 +38,6 @@ export class REPLGridClientStore {
82
38
  : this.applicationStore.config.replUrl,
83
39
  }),
84
40
  );
85
- const isPaginationEnabled =
86
- applicationStore.settingService.getBooleanValue(
87
- LEGEND_APPLICATION_REPL_SETTING_KEY.PAGINATION,
88
- ) ?? true;
89
- this.replGridState = new REPLGridState(isPaginationEnabled);
90
- }
91
-
92
- *getREPLGridServerResult(tdsRequest: TDSRequest): GeneratorFn<void> {
93
- try {
94
- const isSubQuery = tdsRequest.groupBy.groupKeys.length !== 0;
95
- const lambda = buildLambdaExpressions(
96
- guaranteeNonNullable(this.replGridState.initialQueryLambda?.body[0]),
97
- tdsRequest,
98
- this.replGridState.isPaginationEnabled,
99
- );
100
- const resultObj = (yield flowResult(
101
- this.client.getREPLGridServerResult(
102
- V1_serializeValueSpecification(lambda, []),
103
- ),
104
- )) as PlainObject<REPLGridServerResult>;
105
- const replGridResult =
106
- REPLGridServerResult.serialization.fromJson(resultObj);
107
- const tdsResult = JSON.parse(
108
- replGridResult.result,
109
- ) as PlainObject<V1_TDSExecutionResult>;
110
- this.replGridState.setCurrentResult(
111
- guaranteeType(
112
- V1_buildExecutionResult(V1_serializeExecutionResult(tdsResult)),
113
- TDSExecutionResult,
114
- ),
115
- );
116
- if (isSubQuery) {
117
- this.replGridState.setCurrentSubQuery(replGridResult.currentQuery);
118
- } else {
119
- this.replGridState.queryEditorState.setQuery(
120
- replGridResult.currentQuery.substring(1),
121
- );
122
- this.replGridState.setCurrentSubQuery(undefined);
123
- }
124
- } catch (error) {
125
- assertErrorThrown(error);
126
- this.applicationStore.notificationService.notifyError(error);
127
- this.applicationStore.logService.error(
128
- LogEvent.create(LEGEND_REPL_EVENT.FETCH_TDS_FAILURE),
129
- error,
130
- );
131
- }
132
- }
133
-
134
- async getTypeaheadResults(
135
- position: IPosition,
136
- model: monacoEditorAPI.ITextModel,
137
- ): Promise<monacoLanguagesAPI.CompletionItem[]> {
138
- try {
139
- const textUntilPosition = model.getValueInRange({
140
- startLineNumber: 1,
141
- startColumn: 1,
142
- endLineNumber: position.lineNumber,
143
- endColumn: position.column,
144
- });
145
- const resultObj =
146
- await this.client.getTypeaheadResults(textUntilPosition);
147
- const result = resultObj.map((res) =>
148
- CompletionItem.serialization.fromJson(res),
149
- );
150
- const currentWord = model.getWordUntilPosition(position);
151
- return result.map((res) => ({
152
- label: res.display,
153
- kind: monacoLanguagesAPI.CompletionItemKind.Text,
154
- range: {
155
- startLineNumber: position.lineNumber,
156
- startColumn: currentWord.startColumn + 1,
157
- endLineNumber: position.lineNumber,
158
- endColumn: currentWord.endColumn + 1,
159
- },
160
- insertText: res.completion,
161
- })) as monacoLanguagesAPI.CompletionItem[];
162
- } catch (e) {
163
- return [];
164
- }
165
- }
166
-
167
- *executeLambda(): GeneratorFn<void> {
168
- try {
169
- this.executeAction.inProgress();
170
- const resultObj = (yield this.client.executeLambda(
171
- this.replGridState.queryEditorState.query,
172
- this.replGridState.isPaginationEnabled,
173
- )) as PlainObject<REPLGridServerResult>;
174
- const replGridResult =
175
- REPLGridServerResult.serialization.fromJson(resultObj);
176
- const tdsResultObj = JSON.parse(
177
- replGridResult.result,
178
- ) as PlainObject<V1_TDSExecutionResult>;
179
- const tdsResult = guaranteeType(
180
- V1_buildExecutionResult(V1_serializeExecutionResult(tdsResultObj)),
181
- TDSExecutionResult,
182
- );
183
- this.replGridState.setInitialResult(tdsResult);
184
- this.replGridState.queryEditorState.setQuery(
185
- replGridResult.currentQuery.substring(1),
186
- );
187
- this.replGridState.setCurrentSubQuery(undefined);
188
- this.replGridState.setColumns(tdsResult.result.columns);
189
-
190
- yield flowResult(this.getInitialQueryLambda());
191
- this.executeAction.complete();
192
- } catch (error) {
193
- this.executeAction.fail();
194
- assertErrorThrown(error);
195
- this.applicationStore.notificationService.notifyError(error);
196
- this.applicationStore.logService.error(
197
- LogEvent.create(LEGEND_REPL_EVENT.FETCH_TDS_FAILURE),
198
- error,
199
- );
200
- }
201
- }
202
-
203
- *parseQuery(): GeneratorFn<void> {
204
- try {
205
- this.replGridState.queryEditorState.setParserError(undefined);
206
- yield flowResult(
207
- this.client.parseQuery(`|${this.replGridState.queryEditorState.query}`),
208
- );
209
- } catch (error) {
210
- assertErrorThrown(error);
211
- if (
212
- error instanceof NetworkClientError &&
213
- error.response.status === HttpStatus.BAD_REQUEST
214
- ) {
215
- const protocol = V1_ParserError.serialization.fromJson(
216
- error.payload as PlainObject<V1_ParserError>,
217
- );
218
- const parserError = new ParserError(protocol.message);
219
- if (protocol.sourceInformation) {
220
- parserError.sourceInformation = new SourceInformation(
221
- protocol.sourceInformation.sourceId,
222
- protocol.sourceInformation.startLine,
223
- protocol.sourceInformation.startColumn,
224
- protocol.sourceInformation.endLine,
225
- protocol.sourceInformation.endColumn,
226
- );
227
- }
228
- this.replGridState.queryEditorState.setParserError(parserError);
229
- }
230
- }
231
- }
232
-
233
- *getInitialQueryLambda(): GeneratorFn<void> {
234
- const lambdaObj =
235
- (yield this.client.getIntialQueryLambda()) as PlainObject<V1_Lambda>;
236
- const lambda = V1_deserializeValueSpecification(lambdaObj, []);
237
- if (lambda instanceof V1_Lambda) {
238
- this.replGridState.setInitialQueryLambda(lambda);
239
- }
240
- }
241
-
242
- *getInitialREPLGridServerResult(): GeneratorFn<void> {
243
- try {
244
- this.executeAction.inProgress();
245
- if (!this.replGridState.licenseKey) {
246
- yield flowResult(this.getLicenseKey());
247
- }
248
-
249
- yield flowResult(this.getInitialQueryLambda());
250
-
251
- const resultObj = (yield this.client.getInitialREPLGridServerResult(
252
- this.replGridState.isPaginationEnabled,
253
- )) as PlainObject<REPLGridServerResult>;
254
- const replGridResult =
255
- REPLGridServerResult.serialization.fromJson(resultObj);
256
- const tdsResultObj = JSON.parse(
257
- replGridResult.result,
258
- ) as PlainObject<V1_TDSExecutionResult>;
259
- const tdsResult = guaranteeType(
260
- V1_buildExecutionResult(V1_serializeExecutionResult(tdsResultObj)),
261
- TDSExecutionResult,
262
- );
263
- this.replGridState.setInitialResult(tdsResult);
264
- this.replGridState.queryEditorState.setQuery(
265
- replGridResult.currentQuery.substring(1),
266
- );
267
- this.replGridState.setCurrentSubQuery(undefined);
268
- this.replGridState.setColumns(tdsResult.result.columns);
269
- this.executeAction.complete();
270
- } catch (error) {
271
- this.executeAction.fail();
272
- assertErrorThrown(error);
273
- this.applicationStore.notificationService.notifyError(error);
274
- this.applicationStore.logService.error(
275
- LogEvent.create(LEGEND_REPL_EVENT.FETCH_TDS_FAILURE),
276
- error,
277
- );
278
- }
279
- }
280
-
281
- *getLicenseKey(): GeneratorFn<void> {
282
- const licenseKey = (yield this.client.getLicenseKey()) as string;
283
- this.replGridState.setLicenseKey(licenseKey);
41
+ this.dataCubeState = new DataCubeState(this);
284
42
  }
285
43
  }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { action, makeObservable, observable } from 'mobx';
18
+ import type { GridApi } from '@ag-grid-community/core';
19
+ import type { DataCubeState } from './DataCubeState.js';
20
+ import { LEGEND_APPLICATION_REPL_SETTING_KEY } from '../../Const.js';
21
+
22
+ export class DataCubeConfigState {
23
+ readonly dataCubeState!: DataCubeState;
24
+
25
+ licenseKey?: string | undefined;
26
+ isPaginationEnabled!: boolean;
27
+ gridApi?: GridApi | undefined;
28
+
29
+ isPivotPanelOpened = false;
30
+
31
+ constructor(dataCubeState: DataCubeState) {
32
+ makeObservable(this, {
33
+ licenseKey: observable,
34
+ isPaginationEnabled: observable,
35
+ gridApi: observable,
36
+ isPivotPanelOpened: observable,
37
+ setGridApi: action,
38
+ setLicenseKey: action,
39
+ setIsPaginationEnabled: action,
40
+ setIsPivotPanelOpened: action,
41
+ openPanel: action,
42
+ closePanel: action,
43
+ });
44
+
45
+ this.dataCubeState = dataCubeState;
46
+ this.isPaginationEnabled =
47
+ dataCubeState.editorStore.applicationStore.settingService.getBooleanValue(
48
+ LEGEND_APPLICATION_REPL_SETTING_KEY.PAGINATION,
49
+ ) ?? true;
50
+ }
51
+
52
+ setIsPivotPanelOpened(val: boolean): void {
53
+ this.isPivotPanelOpened = val;
54
+ }
55
+
56
+ setGridApi(val: GridApi | undefined): void {
57
+ this.gridApi = val;
58
+ }
59
+
60
+ setLicenseKey(val: string | undefined): void {
61
+ this.licenseKey = val;
62
+ }
63
+
64
+ setIsPaginationEnabled(val: boolean): void {
65
+ this.isPaginationEnabled = val;
66
+ }
67
+
68
+ openPanel(): void {
69
+ this.dataCubeState.configState.setIsPivotPanelOpened(true);
70
+ this.dataCubeState.propertiesPanelState.hpivotAndSortPanelState.initialize();
71
+ }
72
+
73
+ closePanel(): void {
74
+ this.dataCubeState.configState.setIsPivotPanelOpened(false);
75
+ this.dataCubeState.propertiesPanelState.hpivotAndSortPanelState.setIsInitialized(
76
+ false,
77
+ );
78
+ }
79
+ }
@@ -17,55 +17,65 @@
17
17
  import { guaranteeNonNullable } from '@finos/legend-shared';
18
18
  import {
19
19
  getAggregationTDSColumnCustomizations,
20
+ getFilterModeltype,
21
+ getTDSColumnCustomizations,
20
22
  getTDSRowData,
21
23
  type TDSRowDataType,
22
- } from '../components/grid/GridUtils.js';
24
+ } from '../../components/grid/GridUtils.js';
23
25
  import { action, computed, makeObservable, observable } from 'mobx';
24
26
  import type { ColDef } from '@ag-grid-community/core';
25
27
  import type { V1_Lambda, TDSExecutionResult } from '@finos/legend-graph';
26
- import { QueryEditorState } from '../components/REPLQueryEditor.js';
28
+ import {
29
+ TDS_FILTER_GROUP,
30
+ type TDSRequest,
31
+ } from '../../components/grid/TDSRequest.js';
32
+ import type { DataCubeState } from './DataCubeState.js';
33
+
34
+ interface FilterModel {
35
+ [key: string]: object;
36
+ }
37
+
38
+ export class DataCubeGridState {
39
+ readonly dataCubeState!: DataCubeState;
27
40
 
28
- export class REPLGridState {
29
41
  initialResult?: TDSExecutionResult | undefined;
30
42
  currentResult?: TDSExecutionResult | undefined;
31
43
  columns?: string[] | undefined;
32
- queryEditorState: QueryEditorState;
33
- currentSubQuery?: string | undefined;
34
- licenseKey?: string | undefined;
35
44
  initialQueryLambda?: V1_Lambda | undefined;
36
- isPaginationEnabled!: boolean;
45
+ currentQueryTDSRequest?: TDSRequest | undefined;
46
+ lastQueryTDSRequest?: TDSRequest | undefined;
37
47
 
38
- constructor(isPaginationEnabled: boolean) {
48
+ constructor(dataCubeState: DataCubeState) {
39
49
  makeObservable(this, {
40
50
  initialResult: observable,
41
51
  initialQueryLambda: observable,
42
52
  currentResult: observable,
43
- currentSubQuery: observable,
44
- licenseKey: observable,
45
53
  columns: observable,
46
- isPaginationEnabled: observable,
47
- queryEditorState: observable,
54
+ currentQueryTDSRequest: observable,
55
+ lastQueryTDSRequest: observable,
48
56
  setInitialResult: action,
49
- setCurrentSubQuery: action,
50
57
  setColumns: action,
51
58
  setInitialQueryLambda: action,
52
59
  setCurrentResult: action,
53
- setLicenseKey: action,
54
- setIsPaginationEnabled: action,
60
+ setCurrentQueryTDSRequest: action,
61
+ setLastQueryTDSRequest: action,
55
62
  rowData: computed,
56
63
  columnDefs: computed,
57
64
  });
58
65
 
59
- this.queryEditorState = new QueryEditorState('');
60
- this.isPaginationEnabled = isPaginationEnabled;
66
+ this.dataCubeState = dataCubeState;
61
67
  }
62
68
 
63
- setInitialQueryLambda(val: V1_Lambda | undefined): void {
64
- this.initialQueryLambda = val;
69
+ setLastQueryTDSRequest(val: TDSRequest | undefined): void {
70
+ this.lastQueryTDSRequest = val;
71
+ }
72
+
73
+ setCurrentQueryTDSRequest(val: TDSRequest | undefined): void {
74
+ this.currentQueryTDSRequest = val;
65
75
  }
66
76
 
67
- setCurrentSubQuery(val: string | undefined): void {
68
- this.currentSubQuery = val;
77
+ setInitialQueryLambda(val: V1_Lambda | undefined): void {
78
+ this.initialQueryLambda = val;
69
79
  }
70
80
 
71
81
  setInitialResult(val: TDSExecutionResult | undefined): void {
@@ -80,28 +90,53 @@ export class REPLGridState {
80
90
  this.columns = val;
81
91
  }
82
92
 
83
- setLicenseKey(val: string | undefined): void {
84
- this.licenseKey = val;
85
- }
86
-
87
- setIsPaginationEnabled(val: boolean): void {
88
- this.isPaginationEnabled = val;
89
- }
90
-
91
93
  get rowData(): TDSRowDataType[] {
92
94
  return this.initialResult ? getTDSRowData(this.initialResult.result) : [];
93
95
  }
94
96
 
95
97
  get columnDefs(): ColDef[] {
98
+ const filterModel: FilterModel = {};
99
+ this.currentQueryTDSRequest?.filter.forEach((filter) => {
100
+ if (filter.conditions.length === 1) {
101
+ filterModel[filter.column] = {
102
+ filter: filter.conditions[0]?.value,
103
+ filterType: getFilterModeltype(filter.columnType),
104
+ type: filter.conditions[0]?.operation,
105
+ };
106
+ } else {
107
+ filterModel[filter.column] = {
108
+ filterType: getFilterModeltype(filter.columnType),
109
+ operator:
110
+ filter.groupOperation === TDS_FILTER_GROUP.AND ? 'AND' : 'OR',
111
+ condition1: {
112
+ filter: filter.conditions[0]?.value,
113
+ filterType: getFilterModeltype(filter.columnType),
114
+ type: filter.conditions[0]?.operation,
115
+ },
116
+ condition2: {
117
+ filter: filter.conditions[1]?.value,
118
+ filterType: getFilterModeltype(filter.columnType),
119
+ type: filter.conditions[1]?.operation,
120
+ },
121
+ };
122
+ }
123
+ });
124
+ if (this.currentQueryTDSRequest) {
125
+ this.dataCubeState.configState.gridApi?.setFilterModel(filterModel);
126
+ }
96
127
  return this.columns
97
128
  ? this.columns.map((c) => ({
98
129
  field: c,
99
130
  headerName: c,
100
131
  ...getAggregationTDSColumnCustomizations(
101
- this.licenseKey ? true : false,
102
132
  guaranteeNonNullable(this.initialResult),
103
133
  c,
104
134
  ),
135
+ ...getTDSColumnCustomizations(
136
+ guaranteeNonNullable(this.initialResult),
137
+ c,
138
+ this.currentQueryTDSRequest,
139
+ ),
105
140
  }))
106
141
  : [];
107
142
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import type { DataCubeState } from './DataCubeState.js';
18
+
19
+ export abstract class DataCubePanelState {
20
+ readonly dataCubeState!: DataCubeState;
21
+
22
+ constructor(dataCubeState: DataCubeState) {
23
+ this.dataCubeState = dataCubeState;
24
+ }
25
+
26
+ abstract initialize(): void;
27
+ abstract applyChanges(): void;
28
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { action, makeObservable, observable } from 'mobx';
18
+ import type { DataCubeState } from './DataCubeState.js';
19
+ import { HPivotAndSortPanelState } from './HPivotAndSortPanelState.js';
20
+
21
+ export enum PIVOT_PANEL_TABS {
22
+ COLUMNS_AND_PIVOTS = 'Colums/Pivots',
23
+ HPIVOTS_AND_SORTS = 'HPivots/Sorts',
24
+ GENERAL_PROPERTIES = 'General Properties',
25
+ COLUMN_PROPERTIES = 'Column Properties',
26
+ DEVELOPER_OPTIONS = 'Developer',
27
+ PIVOT_LAYOUT = 'Pivot Layout',
28
+ }
29
+
30
+ export class DataCubePropertiesPanelState {
31
+ readonly dataCubeState!: DataCubeState;
32
+ selectedPivotPanelTab = PIVOT_PANEL_TABS.COLUMNS_AND_PIVOTS;
33
+ hpivotAndSortPanelState!: HPivotAndSortPanelState;
34
+
35
+ constructor(dataCubeState: DataCubeState) {
36
+ makeObservable(this, {
37
+ selectedPivotPanelTab: observable,
38
+ hpivotAndSortPanelState: observable,
39
+ setSelectedPivotPanelTab: action,
40
+ applyChanges: action,
41
+ });
42
+
43
+ this.dataCubeState = dataCubeState;
44
+ this.hpivotAndSortPanelState = new HPivotAndSortPanelState(
45
+ this.dataCubeState,
46
+ );
47
+ }
48
+
49
+ setSelectedPivotPanelTab(val: PIVOT_PANEL_TABS): void {
50
+ this.selectedPivotPanelTab = val;
51
+ switch (val) {
52
+ case PIVOT_PANEL_TABS.HPIVOTS_AND_SORTS: {
53
+ this.hpivotAndSortPanelState.initialize();
54
+ break;
55
+ }
56
+ default: {
57
+ return;
58
+ }
59
+ }
60
+ }
61
+
62
+ applyChanges(): void {
63
+ this.hpivotAndSortPanelState.applyChanges();
64
+ }
65
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { SourceInformation, type ParserError } from '@finos/legend-graph';
18
+ import { uuid } from '@finos/legend-shared';
19
+ import { action, makeObservable, observable } from 'mobx';
20
+
21
+ export class DataCubeQueryEditorState {
22
+ uuid = uuid();
23
+ query: string;
24
+ parserError?: ParserError | undefined;
25
+
26
+ constructor(query: string) {
27
+ makeObservable(this, {
28
+ query: observable,
29
+ parserError: observable,
30
+ setQuery: action,
31
+ setParserError: action,
32
+ });
33
+
34
+ this.query = query;
35
+ }
36
+
37
+ setQuery(val: string): void {
38
+ this.query = val;
39
+ }
40
+
41
+ setParserError(parserError: ParserError | undefined): void {
42
+ // account for the lambda prefix offset in source information
43
+ if (parserError?.sourceInformation) {
44
+ parserError.sourceInformation = this.processSourceInformation(
45
+ parserError.sourceInformation,
46
+ );
47
+ }
48
+ this.parserError = parserError;
49
+ }
50
+
51
+ processSourceInformation(
52
+ sourceInformation: SourceInformation,
53
+ ): SourceInformation {
54
+ const { sourceId, startLine, startColumn, endLine, endColumn } =
55
+ sourceInformation;
56
+ const lineOffset = 0;
57
+ const columnOffset = 0;
58
+ return new SourceInformation(
59
+ sourceId,
60
+ startLine + lineOffset,
61
+ startColumn - (startLine === 1 ? columnOffset : 0),
62
+ endLine + lineOffset,
63
+ endColumn - (endLine === 1 ? columnOffset : 0),
64
+ );
65
+ }
66
+ }