@finos/legend-application-repl 0.0.19 → 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
@@ -14,9 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { useRef, useEffect, useState, useMemo } from 'react';
18
17
  import { observer } from 'mobx-react-lite';
19
- import { clsx } from '@finos/legend-art';
18
+ import { flowResult } from 'mobx';
19
+ import { PlayIcon, clsx } from '@finos/legend-art';
20
+ import { useRef, useEffect, useState, useMemo } from 'react';
20
21
  import {
21
22
  getBaseCodeEditorOptions,
22
23
  getCodeEditorValue,
@@ -26,69 +27,23 @@ import {
26
27
  CODE_EDITOR_LANGUAGE,
27
28
  CODE_EDITOR_THEME,
28
29
  disposeCodeEditor,
30
+ CodeEditor,
29
31
  } from '@finos/legend-lego/code-editor';
30
- import { SourceInformation, type ParserError } from '@finos/legend-graph';
31
- import { debounce, uuid } from '@finos/legend-shared';
32
- import { action, flowResult, makeObservable, observable } from 'mobx';
32
+ import { debounce } from '@finos/legend-shared';
33
33
  import { DEFAULT_TAB_SIZE } from '@finos/legend-application';
34
- import { useREPLGridClientStore } from './REPLGridClientStoreProvider.js';
34
+ import { useREPLGridClientStore } from '../REPLGridClientStoreProvider.js';
35
35
  import {
36
36
  editor as monacoEditorAPI,
37
37
  type IDisposable,
38
38
  languages as monacoLanguagesAPI,
39
39
  } from 'monaco-editor';
40
+ import type { REPLGridClientStore } from '../../stores/REPLGridClientStore.js';
40
41
 
41
- export class QueryEditorState {
42
- uuid = uuid();
43
- query: string;
44
- parserError?: ParserError | undefined;
45
-
46
- constructor(query: string) {
47
- makeObservable(this, {
48
- query: observable,
49
- parserError: observable,
50
- setQuery: action,
51
- setParserError: action,
52
- });
53
-
54
- this.query = query;
55
- }
56
-
57
- setQuery(val: string): void {
58
- this.query = val;
59
- }
60
-
61
- setParserError(parserError: ParserError | undefined): void {
62
- // account for the lambda prefix offset in source information
63
- if (parserError?.sourceInformation) {
64
- parserError.sourceInformation = this.processSourceInformation(
65
- parserError.sourceInformation,
66
- );
67
- }
68
- this.parserError = parserError;
69
- }
70
-
71
- processSourceInformation(
72
- sourceInformation: SourceInformation,
73
- ): SourceInformation {
74
- const { sourceId, startLine, startColumn, endLine, endColumn } =
75
- sourceInformation;
76
- const lineOffset = 0;
77
- const columnOffset = 0;
78
- return new SourceInformation(
79
- sourceId,
80
- startLine + lineOffset,
81
- startColumn - (startLine === 1 ? columnOffset : 0),
82
- endLine + lineOffset,
83
- endColumn - (endLine === 1 ? columnOffset : 0),
84
- );
85
- }
86
- }
87
-
88
- export const QueryEditor = observer(() => {
42
+ const QueryEditor = observer(() => {
89
43
  const editorStore = useREPLGridClientStore();
90
44
  const applicationStore = editorStore.applicationStore;
91
- const queryEditorState = editorStore.replGridState.queryEditorState;
45
+ const dataCubeState = editorStore.dataCubeState;
46
+ const queryEditorState = dataCubeState.queryTextEditorState.queryEditorState;
92
47
  const onDidChangeModelContentEventDisposer = useRef<IDisposable | undefined>(
93
48
  undefined,
94
49
  );
@@ -105,11 +60,11 @@ export const QueryEditor = observer(() => {
105
60
  const debouncedParseQuery = useMemo(
106
61
  () =>
107
62
  debounce((): void => {
108
- flowResult(editorStore.parseQuery()).catch(
63
+ flowResult(dataCubeState.parseQuery()).catch(
109
64
  editorStore.applicationStore.alertUnhandledError,
110
65
  );
111
66
  }, 1000),
112
- [editorStore],
67
+ [dataCubeState, editorStore.applicationStore.alertUnhandledError],
113
68
  );
114
69
 
115
70
  if (editor) {
@@ -141,7 +96,7 @@ export const QueryEditor = observer(() => {
141
96
  triggerCharacters: ['>', '.', '$', '~'],
142
97
  provideCompletionItems: async (model, position, context) => {
143
98
  const suggestions: monacoLanguagesAPI.CompletionItem[] =
144
- await editorStore.getTypeaheadResults(position, model);
99
+ await dataCubeState.getTypeaheadResults(position, model);
145
100
  return { suggestions };
146
101
  },
147
102
  },
@@ -203,3 +158,77 @@ export const QueryEditor = observer(() => {
203
158
  </div>
204
159
  );
205
160
  });
161
+
162
+ export const DataCubeQueryTextEditor = observer(
163
+ (props: { editorStore: REPLGridClientStore }) => {
164
+ const { editorStore } = props;
165
+ const dataCubeState = editorStore.dataCubeState;
166
+
167
+ const executeLambda = (): void => {
168
+ flowResult(dataCubeState.executeLambda()).catch(
169
+ editorStore.applicationStore.alertUnhandledError,
170
+ );
171
+ };
172
+
173
+ const isLightTheme =
174
+ editorStore.applicationStore.layoutService
175
+ .TEMPORARY__isLightColorThemeEnabled;
176
+
177
+ return (
178
+ <div className="repl__content__query">
179
+ <div className="repl__query">
180
+ <div className="repl__query__editor">
181
+ <div className="repl__query__header">
182
+ <div className="repl__query__label">Curent Query</div>
183
+ <div className="repl__query__execute-btn btn__dropdown-combo btn__dropdown-combo--primary">
184
+ <button
185
+ className="btn__dropdown-combo__label"
186
+ onClick={executeLambda}
187
+ tabIndex={-1}
188
+ >
189
+ <PlayIcon className="btn__dropdown-combo__label__icon" />
190
+ <div className="btn__dropdown-combo__label__title">
191
+ Run Query
192
+ </div>
193
+ </button>
194
+ </div>
195
+ </div>
196
+ <div className="repl__query__content">
197
+ <QueryEditor />
198
+ </div>
199
+ </div>
200
+ </div>
201
+ {dataCubeState.queryTextEditorState.currentSubQuery !== undefined && (
202
+ <div className="repl__query">
203
+ <div className="repl__query__editor">
204
+ <div className="repl__query__header">
205
+ <div className="repl__query__label__sub__query">
206
+ Current Row Group Sub Query
207
+ </div>
208
+ <div className="repl__query__label__sub__query__read--only">
209
+ Read Only
210
+ </div>
211
+ </div>
212
+ <div className="repl__query__content">
213
+ <CodeEditor
214
+ lightTheme={
215
+ isLightTheme
216
+ ? CODE_EDITOR_THEME.BUILT_IN__VSCODE_HC_LIGHT
217
+ : CODE_EDITOR_THEME.BUILT_IN__VSCODE_HC_BLACK
218
+ }
219
+ language={CODE_EDITOR_LANGUAGE.PURE}
220
+ isReadOnly={true}
221
+ inputValue={
222
+ dataCubeState.queryTextEditorState.currentSubQuery
223
+ }
224
+ hideActionBar={true}
225
+ hidePadding={true}
226
+ />
227
+ </div>
228
+ </div>
229
+ </div>
230
+ )}
231
+ </div>
232
+ );
233
+ },
234
+ );
@@ -15,6 +15,7 @@
15
15
  */
16
16
 
17
17
  import {
18
+ type TDSRequest,
18
19
  TDS_AGGREGATION_FUNCTION,
19
20
  TDS_FILTER_OPERATION,
20
21
  TDS_SORT_ORDER,
@@ -48,6 +49,17 @@ export const getTDSSortOrder = (sortOrder: string): TDS_SORT_ORDER => {
48
49
  }
49
50
  };
50
51
 
52
+ const getTDSSortModel = (sort: TDS_SORT_ORDER): string => {
53
+ switch (sort) {
54
+ case TDS_SORT_ORDER.ASCENDING:
55
+ return 'asc';
56
+ case TDS_SORT_ORDER.DESCENDING:
57
+ return 'desc';
58
+ default:
59
+ throw new Error(`Unsupported`);
60
+ }
61
+ };
62
+
51
63
  export const getAggregationFunction = (
52
64
  aggFunc: string,
53
65
  ): TDS_AGGREGATION_FUNCTION => {
@@ -113,14 +125,46 @@ export const getFilterColumnType = (type: string): PRIMITIVE_TYPE => {
113
125
  }
114
126
  };
115
127
 
116
- export const getAggregationTDSColumnCustomizations = (
117
- isAgGridLicenseEnabled: boolean,
128
+ export const getFilterModeltype = (type: PRIMITIVE_TYPE): string => {
129
+ switch (type) {
130
+ case PRIMITIVE_TYPE.STRING:
131
+ return 'text';
132
+ case PRIMITIVE_TYPE.NUMBER:
133
+ return 'number';
134
+ case PRIMITIVE_TYPE.BOOLEAN:
135
+ return 'boolean';
136
+ case PRIMITIVE_TYPE.DATE:
137
+ return 'date';
138
+ default:
139
+ throw new Error(`Unsupported filter type ${type}`);
140
+ }
141
+ };
142
+
143
+ export const getTDSColumnCustomizations = (
118
144
  result: TDSExecutionResult,
119
145
  columnName: string,
146
+ tdsRequest?: TDSRequest | undefined,
120
147
  ): object => {
121
- if (!isAgGridLicenseEnabled) {
148
+ if (!tdsRequest) {
122
149
  return {};
123
150
  }
151
+ const sort = tdsRequest.sort.find((c) => c.column === columnName)?.order;
152
+ const rowGroup = tdsRequest.groupBy.columns.find((c) => c === columnName);
153
+ const aggFunc = tdsRequest.groupBy.aggregations.find(
154
+ (c) => c.column === columnName,
155
+ );
156
+ return {
157
+ sort: sort ? getTDSSortModel(sort) : undefined,
158
+ rowGroup: Boolean(rowGroup),
159
+ hide: Boolean(rowGroup),
160
+ aggFunc: aggFunc?.function,
161
+ };
162
+ };
163
+
164
+ export const getAggregationTDSColumnCustomizations = (
165
+ result: TDSExecutionResult,
166
+ columnName: string,
167
+ ): object => {
124
168
  const columnType = result.builder.columns.find(
125
169
  (col) => col.name === columnName,
126
170
  )?.type;
@@ -27,6 +27,7 @@ import {
27
27
  TDSSort,
28
28
  TDSFilterCondition,
29
29
  TDS_FILTER_GROUP,
30
+ TDSColumn,
30
31
  } from './TDSRequest.js';
31
32
  import {
32
33
  guaranteeNonNullable,
@@ -70,18 +71,30 @@ export class ServerSideDataSource implements IServerSideDatasource {
70
71
  params: IServerSideGetRowsParams<unknown, unknown>,
71
72
  ): GeneratorFn<void> {
72
73
  try {
73
- if (this.executions > 0) {
74
+ if (
75
+ this.executions > 0 ||
76
+ this.editorStore?.dataCubeState.gridState.currentQueryTDSRequest
77
+ ) {
74
78
  if (this.editorStore) {
75
79
  const request = this.extractRequest(params);
80
+ this.editorStore.dataCubeState.gridState.setLastQueryTDSRequest(
81
+ request,
82
+ );
76
83
  if (request) {
77
- yield flowResult(this.editorStore.getREPLGridServerResult(request));
78
- const result = this.editorStore.replGridState.currentResult;
84
+ yield flowResult(
85
+ this.editorStore.dataCubeState.getREPLGridServerResult(request),
86
+ );
87
+ const result =
88
+ this.editorStore.dataCubeState.gridState.currentResult;
79
89
  const rowData = getTDSRowData(guaranteeNonNullable(result).result);
80
90
  params.success({ rowData: rowData });
81
91
  } else {
82
92
  params.fail();
83
93
  }
84
94
  }
95
+ this.editorStore?.dataCubeState.gridState.setCurrentQueryTDSRequest(
96
+ undefined,
97
+ );
85
98
  } else {
86
99
  params.success({ rowData: this.rowData });
87
100
  }
@@ -163,7 +176,7 @@ export class ServerSideDataSource implements IServerSideDatasource {
163
176
  });
164
177
  }
165
178
  const tdsRequest = new TDSRequest(
166
- columns ?? [],
179
+ columns?.map((col) => new TDSColumn(col)) ?? [],
167
180
  filter,
168
181
  sort,
169
182
  groupBy,
@@ -444,7 +444,11 @@ export const buildLambdaExpressions = (
444
444
  request.filter.push(groupFilter);
445
445
  }
446
446
  processFilterOperations(expressions, request.filter);
447
- processGroupByOperations(expressions, request.groupBy, request.columns);
447
+ processGroupByOperations(
448
+ expressions,
449
+ request.groupBy,
450
+ request.columns.map((col) => col.name),
451
+ );
448
452
  processSortOperations(expressions, request.sort, request.groupBy);
449
453
  const lambda = new V1_Lambda();
450
454
  lambda.body = expressions;
@@ -0,0 +1,37 @@
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 V1_Lambda, V1_lambdaModelSchema } from '@finos/legend-graph';
18
+ import { TDSRequest } from './TDSRequest.js';
19
+ import { SerializationFactory, usingModelSchema } from '@finos/legend-shared';
20
+ import { createModelSchema } from 'serializr';
21
+
22
+ export class TDSQuery {
23
+ initialQuery!: V1_Lambda;
24
+ currentQueryInfo!: TDSRequest;
25
+
26
+ constructor(initialQuery: V1_Lambda, currentQueryInfo: TDSRequest) {
27
+ this.initialQuery = initialQuery;
28
+ this.currentQueryInfo = currentQueryInfo;
29
+ }
30
+
31
+ static readonly serialization = new SerializationFactory(
32
+ createModelSchema(TDSQuery, {
33
+ initialQuery: usingModelSchema(V1_lambdaModelSchema([])),
34
+ currentQueryInfo: usingModelSchema(TDSRequest.serialization.schema),
35
+ }),
36
+ );
37
+ }
@@ -15,6 +15,9 @@
15
15
  */
16
16
 
17
17
  import type { PRIMITIVE_TYPE } from '@finos/legend-graph';
18
+ import { SerializationFactory, usingModelSchema } from '@finos/legend-shared';
19
+ import { observable, makeObservable, action } from 'mobx';
20
+ import { createModelSchema, list, optional, primitive } from 'serializr';
18
21
 
19
22
  export enum TDS_FILTER_OPERATION {
20
23
  EQUALS = 'equal',
@@ -64,6 +67,13 @@ export class TDSFilterCondition {
64
67
  this.operation = operation;
65
68
  this.value = value;
66
69
  }
70
+
71
+ static readonly serialization = new SerializationFactory(
72
+ createModelSchema(TDSFilterCondition, {
73
+ operation: primitive(),
74
+ value: primitive(),
75
+ }),
76
+ );
67
77
  }
68
78
 
69
79
  export class TDSFilter {
@@ -83,6 +93,17 @@ export class TDSFilter {
83
93
  this.conditions = conditions;
84
94
  this.groupOperation = groupOperation;
85
95
  }
96
+
97
+ static readonly serialization = new SerializationFactory(
98
+ createModelSchema(TDSFilter, {
99
+ column: primitive(),
100
+ columnType: primitive(),
101
+ conditions: list(
102
+ usingModelSchema(TDSFilterCondition.serialization.schema),
103
+ ),
104
+ groupOperation: primitive(),
105
+ }),
106
+ );
86
107
  }
87
108
 
88
109
  export class TDSSort {
@@ -90,9 +111,25 @@ export class TDSSort {
90
111
  order!: TDS_SORT_ORDER;
91
112
 
92
113
  constructor(column: string, order: TDS_SORT_ORDER) {
114
+ makeObservable(this, {
115
+ column: observable,
116
+ order: observable,
117
+ setOrder: action,
118
+ });
93
119
  this.column = column;
94
120
  this.order = order;
95
121
  }
122
+
123
+ setOrder(val: TDS_SORT_ORDER): void {
124
+ this.order = val;
125
+ }
126
+
127
+ static readonly serialization = new SerializationFactory(
128
+ createModelSchema(TDSSort, {
129
+ column: primitive(),
130
+ order: primitive(),
131
+ }),
132
+ );
96
133
  }
97
134
 
98
135
  export class TDSAggregation {
@@ -109,6 +146,14 @@ export class TDSAggregation {
109
146
  this.columnType = columnType;
110
147
  this.function = _function;
111
148
  }
149
+
150
+ static readonly serialization = new SerializationFactory(
151
+ createModelSchema(TDSAggregation, {
152
+ column: primitive(),
153
+ columnType: primitive(),
154
+ function: primitive(),
155
+ }),
156
+ );
112
157
  }
113
158
 
114
159
  export class TDSGroupby {
@@ -125,18 +170,40 @@ export class TDSGroupby {
125
170
  this.groupKeys = groupKeys;
126
171
  this.aggregations = aggregations;
127
172
  }
173
+
174
+ static readonly serialization = new SerializationFactory(
175
+ createModelSchema(TDSGroupby, {
176
+ columns: list(primitive()),
177
+ groupKeys: list(primitive()),
178
+ aggregations: list(usingModelSchema(TDSAggregation.serialization.schema)),
179
+ }),
180
+ );
181
+ }
182
+
183
+ export class TDSColumn {
184
+ name!: string;
185
+
186
+ constructor(name: string) {
187
+ this.name = name;
188
+ }
189
+
190
+ static readonly serialization = new SerializationFactory(
191
+ createModelSchema(TDSColumn, {
192
+ name: primitive(),
193
+ }),
194
+ );
128
195
  }
129
196
 
130
197
  export class TDSRequest {
131
198
  startRow?: number | undefined;
132
199
  endRow?: number | undefined;
133
- columns!: string[];
200
+ columns!: TDSColumn[];
134
201
  filter!: TDSFilter[];
135
202
  sort!: TDSSort[];
136
203
  groupBy!: TDSGroupby;
137
204
 
138
205
  constructor(
139
- columns: string[],
206
+ columns: TDSColumn[],
140
207
  filter: TDSFilter[],
141
208
  sort: TDSSort[],
142
209
  groupBy: TDSGroupby,
@@ -150,4 +217,15 @@ export class TDSRequest {
150
217
  this.sort = sort;
151
218
  this.groupBy = groupBy;
152
219
  }
220
+
221
+ static readonly serialization = new SerializationFactory(
222
+ createModelSchema(TDSRequest, {
223
+ startRow: optional(primitive()),
224
+ endRow: optional(primitive()),
225
+ columns: list(usingModelSchema(TDSColumn.serialization.schema)),
226
+ filter: list(usingModelSchema(TDSFilter.serialization.schema)),
227
+ sort: list(usingModelSchema(TDSSort.serialization.schema)),
228
+ groupBy: usingModelSchema(TDSGroupby.serialization.schema),
229
+ }),
230
+ );
153
231
  }
@@ -22,6 +22,7 @@ import {
22
22
  import type { REPLGridServerResult } from '../components/grid/REPLGridServerResult.js';
23
23
  import type { V1_Lambda } from '@finos/legend-graph';
24
24
  import type { CompletionItem } from '../stores/CompletionResult.js';
25
+ import type { TDSQuery } from '../components/grid/TDSQuery.js';
25
26
 
26
27
  export class REPLServerClient {
27
28
  private readonly networkClient: NetworkClient;
@@ -101,4 +102,20 @@ export class REPLServerClient {
101
102
  undefined,
102
103
  undefined,
103
104
  );
105
+
106
+ getREPLQuery = (queryId: string): Promise<PlainObject<TDSQuery>> =>
107
+ this.networkClient.get(
108
+ `${this.baseUrl}/query/${queryId}`,
109
+ undefined,
110
+ undefined,
111
+ undefined,
112
+ );
113
+
114
+ saveQuery = (tdsQuery: PlainObject<TDSQuery>): Promise<string> =>
115
+ this.networkClient.post(
116
+ `${this.baseUrl}/saveQuery`,
117
+ tdsQuery,
118
+ undefined,
119
+ undefined,
120
+ );
104
121
  }