@finos/legend-application-studio 27.1.1 → 27.1.2

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 (68) hide show
  1. package/lib/components/editor/editor-group/FunctionEditor.d.ts.map +1 -1
  2. package/lib/components/editor/editor-group/FunctionEditor.js +28 -24
  3. package/lib/components/editor/editor-group/FunctionEditor.js.map +1 -1
  4. package/lib/components/editor/editor-group/connection-editor/{DatabaseBuilder.d.ts → DatabaseBuilderWizard.d.ts} +4 -11
  5. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.d.ts.map +1 -0
  6. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js +48 -0
  7. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js.map +1 -0
  8. package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.d.ts +32 -0
  9. package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.d.ts.map +1 -0
  10. package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.js +99 -0
  11. package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.js.map +1 -0
  12. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js +1 -1
  13. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
  14. package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts +0 -7
  15. package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts.map +1 -1
  16. package/lib/components/editor/panel-group/SQLPlaygroundPanel.js +20 -77
  17. package/lib/components/editor/panel-group/SQLPlaygroundPanel.js.map +1 -1
  18. package/lib/components/editor/side-bar/Explorer.js +3 -3
  19. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  20. package/lib/components/editor/side-bar/WorkflowManager.d.ts.map +1 -1
  21. package/lib/components/editor/side-bar/WorkflowManager.js +6 -1
  22. package/lib/components/editor/side-bar/WorkflowManager.js.map +1 -1
  23. package/lib/index.css +2 -2
  24. package/lib/index.css.map +1 -1
  25. package/lib/package.json +3 -3
  26. package/lib/stores/editor/ExplorerTreeState.d.ts +4 -4
  27. package/lib/stores/editor/ExplorerTreeState.d.ts.map +1 -1
  28. package/lib/stores/editor/ExplorerTreeState.js +4 -4
  29. package/lib/stores/editor/ExplorerTreeState.js.map +1 -1
  30. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts +12 -12
  31. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts.map +1 -1
  32. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js +45 -46
  33. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js.map +1 -1
  34. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts +20 -29
  35. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts.map +1 -1
  36. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js +60 -141
  37. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js.map +1 -1
  38. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts +33 -0
  39. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts.map +1 -0
  40. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js +71 -0
  41. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js.map +1 -0
  42. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts +3 -48
  43. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts.map +1 -1
  44. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js +12 -350
  45. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js.map +1 -1
  46. package/lib/stores/editor/sidebar-state/WorkflowManagerState.d.ts +5 -0
  47. package/lib/stores/editor/sidebar-state/WorkflowManagerState.d.ts.map +1 -1
  48. package/lib/stores/editor/sidebar-state/WorkflowManagerState.js +26 -0
  49. package/lib/stores/editor/sidebar-state/WorkflowManagerState.js.map +1 -1
  50. package/package.json +9 -9
  51. package/src/components/editor/editor-group/FunctionEditor.tsx +133 -118
  52. package/src/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.tsx +191 -0
  53. package/src/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.tsx +227 -0
  54. package/src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx +1 -1
  55. package/src/components/editor/panel-group/SQLPlaygroundPanel.tsx +47 -211
  56. package/src/components/editor/side-bar/Explorer.tsx +3 -3
  57. package/src/components/editor/side-bar/WorkflowManager.tsx +10 -0
  58. package/src/stores/editor/ExplorerTreeState.ts +6 -9
  59. package/src/stores/editor/editor-state/element-editor-state/FunctionEditorState.ts +44 -50
  60. package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts +88 -212
  61. package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.ts +102 -0
  62. package/src/stores/editor/panel-group/SQLPlaygroundPanelState.ts +13 -533
  63. package/src/stores/editor/sidebar-state/WorkflowManagerState.ts +47 -0
  64. package/tsconfig.json +3 -1
  65. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.d.ts.map +0 -1
  66. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js +0 -133
  67. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js.map +0 -1
  68. package/src/components/editor/editor-group/connection-editor/DatabaseBuilder.tsx +0 -397
@@ -16,16 +16,9 @@
16
16
 
17
17
  import { observer } from 'mobx-react-lite';
18
18
  import {
19
- type TreeNodeContainerProps,
20
19
  ResizablePanelGroup,
21
20
  ResizablePanel,
22
21
  ResizablePanelSplitter,
23
- TreeView,
24
- PURE_DatabaseSchemaIcon,
25
- PURE_DatabaseTableIcon,
26
- ChevronDownIcon,
27
- ChevronRightIcon,
28
- KeyIcon,
29
22
  CustomSelectorInput,
30
23
  type SelectComponent,
31
24
  createFilter,
@@ -37,9 +30,6 @@ import {
37
30
  PanelLoadingIndicator,
38
31
  BlankPanelContent,
39
32
  TrashIcon,
40
- CircleIcon,
41
- CheckCircleIcon,
42
- EmptyCircleIcon,
43
33
  PURE_DatabaseIcon,
44
34
  SyncIcon,
45
35
  } from '@finos/legend-art';
@@ -65,18 +55,9 @@ import {
65
55
  PackageableConnection,
66
56
  RelationalDatabaseConnection,
67
57
  guaranteeRelationalDatabaseConnection,
68
- stringifyDataType,
69
58
  } from '@finos/legend-graph';
70
59
  import { LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../../__lib__/LegendStudioApplicationNavigationContext.js';
71
- import {
72
- DatabaseSchemaExplorerTreeColumnNodeData,
73
- DatabaseSchemaExplorerTreeSchemaNodeData,
74
- DatabaseSchemaExplorerTreeTableNodeData,
75
- type DatabaseSchemaExplorerTreeData,
76
- type DatabaseSchemaExplorerTreeNodeData,
77
- type SQLPlaygroundPanelState,
78
- } from '../../../stores/editor/panel-group/SQLPlaygroundPanelState.js';
79
- import { renderColumnTypeIcon } from '../editor-group/connection-editor/DatabaseEditorHelper.js';
60
+ import { type SQLPlaygroundPanelState } from '../../../stores/editor/panel-group/SQLPlaygroundPanelState.js';
80
61
  import { useEditorStore } from '../EditorStoreProvider.js';
81
62
  import { PANEL_MODE } from '../../../stores/editor/EditorConfig.js';
82
63
  import { useDrag, useDrop } from 'react-dnd';
@@ -94,191 +75,35 @@ import {
94
75
  parseCSVString,
95
76
  uniqBy,
96
77
  } from '@finos/legend-shared';
97
-
98
- const getDatabaseSchemaNodeIcon = (
99
- node: DatabaseSchemaExplorerTreeNodeData,
100
- ): React.ReactNode => {
101
- if (node instanceof DatabaseSchemaExplorerTreeSchemaNodeData) {
102
- return (
103
- <div className="sql-playground__database-schema-explorer-tree__icon--schema">
104
- <PURE_DatabaseSchemaIcon />
105
- </div>
106
- );
107
- } else if (node instanceof DatabaseSchemaExplorerTreeTableNodeData) {
108
- return (
109
- <div className="sql-playground__database-schema-explorer-tree__icon--table">
110
- <PURE_DatabaseTableIcon />
111
- </div>
112
- );
113
- } else if (node instanceof DatabaseSchemaExplorerTreeColumnNodeData) {
114
- return renderColumnTypeIcon(node.column.type);
115
- }
116
- return null;
117
- };
78
+ import {
79
+ DatabaseSchemaExplorer,
80
+ DatabaseSchemaExplorerTreeNodeContainer,
81
+ type DatabaseSchemaExplorerTreeNodeContainerProps,
82
+ } from '../editor-group/connection-editor/DatabaseSchemaExplorer.js';
83
+ import { DatabaseSchemaExplorerTreeTableNodeData } from '../../../stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js';
118
84
 
119
85
  const DATABASE_NODE_DND_TYPE = 'DATABASE_NODE_DND_TYPE';
120
86
  type DatabaseNodeDragType = { text: string };
121
87
 
122
- const DatabaseSchemaExplorerTreeNodeContainer: React.FC<
123
- TreeNodeContainerProps<
124
- DatabaseSchemaExplorerTreeNodeData,
125
- {
126
- toggleCheckedNode: (node: DatabaseSchemaExplorerTreeNodeData) => void;
127
- isPartiallySelected: (
128
- node: DatabaseSchemaExplorerTreeNodeData,
129
- ) => boolean;
130
- }
131
- >
132
- > = (props) => {
133
- const { node, level, stepPaddingInRem, onNodeSelect, innerProps } = props;
134
- const { toggleCheckedNode, isPartiallySelected } = innerProps;
135
- const isExpandable =
136
- Boolean(!node.childrenIds || node.childrenIds.length) &&
137
- !(node instanceof DatabaseSchemaExplorerTreeColumnNodeData);
138
- const nodeExpandIcon = isExpandable ? (
139
- node.isOpen ? (
140
- <ChevronDownIcon />
141
- ) : (
142
- <ChevronRightIcon />
143
- )
144
- ) : (
145
- <div />
146
- );
147
- const [, nodeDragRef] = useDrag<DatabaseNodeDragType>(
148
- () => ({
149
- type: DATABASE_NODE_DND_TYPE,
150
- item: {
151
- text:
152
- node instanceof DatabaseSchemaExplorerTreeTableNodeData
153
- ? `${node.owner.name}.${node.label}`
154
- : node.label,
155
- },
156
- }),
157
- [node],
158
- );
159
- const nodeTypeIcon = getDatabaseSchemaNodeIcon(node);
160
- const toggleExpandNode = (): void => onNodeSelect?.(node);
161
- const isPrimaryKeyColumn =
162
- node instanceof DatabaseSchemaExplorerTreeColumnNodeData &&
163
- node.owner.primaryKey.includes(node.column);
164
-
165
- const renderCheckedIcon = (
166
- _node: DatabaseSchemaExplorerTreeNodeData,
167
- ): React.ReactNode => {
168
- if (_node instanceof DatabaseSchemaExplorerTreeColumnNodeData) {
169
- return null;
170
- } else if (isPartiallySelected(_node)) {
171
- return <CircleIcon />;
172
- } else if (_node.isChecked) {
173
- return <CheckCircleIcon />;
174
- }
175
- return <EmptyCircleIcon />;
176
- };
177
-
178
- return (
179
- <div
180
- className="tree-view__node__container"
181
- style={{
182
- paddingLeft: `${level * (stepPaddingInRem ?? 1)}rem`,
183
- display: 'flex',
184
- }}
185
- ref={nodeDragRef}
186
- onClick={toggleExpandNode}
187
- >
188
- <div className="tree-view__node__icon sql-playground__database-schema-explorer-tree__node__icon__group">
189
- <div className="sql-playground__database-schema-explorer-tree__expand-icon">
190
- {nodeExpandIcon}
191
- </div>
192
- <div
193
- className="sql-playground__database-schema-explorer-tree__toggle-icon"
194
- onClick={(event) => {
195
- event.stopPropagation();
196
- toggleCheckedNode(node);
197
- }}
198
- >
199
- {renderCheckedIcon(node)}
200
- </div>
201
- <div className="sql-playground__database-schema-explorer-tree__type-icon">
202
- {nodeTypeIcon}
203
- </div>
204
- </div>
205
- <div className="tree-view__node__label sql-playground__database-schema-explorer-tree__node__label">
206
- {node.label}
207
- {node instanceof DatabaseSchemaExplorerTreeColumnNodeData && (
208
- <div className="sql-playground__database-schema-explorer-tree__node__type">
209
- <div className="sql-playground__database-schema-explorer-tree__node__type__label">
210
- {stringifyDataType(node.column.type)}
211
- </div>
212
- </div>
213
- )}
214
- {isPrimaryKeyColumn && (
215
- <div
216
- className="sql-playground__database-schema-explorer-tree__node__pk"
217
- title="Primary Key"
218
- >
219
- <KeyIcon />
220
- </div>
221
- )}
222
- </div>
223
- </div>
224
- );
225
- };
226
-
227
- export const DatabaseSchemaExplorer = observer(
228
- (props: {
229
- treeData: DatabaseSchemaExplorerTreeData;
230
- playgroundState: SQLPlaygroundPanelState;
231
- }) => {
232
- const { treeData, playgroundState } = props;
233
- const applicationStore = useApplicationStore();
234
-
235
- const onNodeSelect = (node: DatabaseSchemaExplorerTreeNodeData): void => {
236
- flowResult(playgroundState.onNodeSelect(node, treeData)).catch(
237
- applicationStore.alertUnhandledError,
238
- );
239
- };
240
-
241
- const getChildNodes = (
242
- node: DatabaseSchemaExplorerTreeNodeData,
243
- ): DatabaseSchemaExplorerTreeNodeData[] =>
244
- playgroundState
245
- .getChildNodes(node, treeData)
246
- ?.sort((a, b) => a.label.localeCompare(b.label)) ?? [];
247
-
248
- const isPartiallySelected = (
249
- node: DatabaseSchemaExplorerTreeNodeData,
250
- ): boolean => {
251
- if (
252
- node instanceof DatabaseSchemaExplorerTreeSchemaNodeData &&
253
- !node.isChecked
254
- ) {
255
- return Boolean(
256
- playgroundState
257
- .getChildNodes(node, treeData)
258
- ?.find((childNode) => childNode.isChecked === true),
259
- );
260
- }
261
- return false;
262
- };
263
-
264
- const toggleCheckedNode = (
265
- node: DatabaseSchemaExplorerTreeNodeData,
266
- ): void => playgroundState.toggleCheckedNode(node, treeData);
88
+ const SQLPlaygroundDatabaseSchemaExplorerTreeNodeContainer = observer(
89
+ (props: DatabaseSchemaExplorerTreeNodeContainerProps) => {
90
+ const { node } = props;
91
+
92
+ const [, nodeDragRef] = useDrag<DatabaseNodeDragType>(
93
+ () => ({
94
+ type: DATABASE_NODE_DND_TYPE,
95
+ item: {
96
+ text:
97
+ node instanceof DatabaseSchemaExplorerTreeTableNodeData
98
+ ? `${node.owner.name}.${node.label}`
99
+ : node.label,
100
+ },
101
+ }),
102
+ [node],
103
+ );
267
104
 
268
105
  return (
269
- <TreeView
270
- className="sql-playground__database-schema-explorer-tree"
271
- components={{
272
- TreeNodeContainer: DatabaseSchemaExplorerTreeNodeContainer,
273
- }}
274
- innerProps={{
275
- toggleCheckedNode,
276
- isPartiallySelected,
277
- }}
278
- treeData={treeData}
279
- onNodeSelect={onNodeSelect}
280
- getChildNodes={getChildNodes}
281
- />
106
+ <DatabaseSchemaExplorerTreeNodeContainer {...props} ref={nodeDragRef} />
282
107
  );
283
108
  },
284
109
  );
@@ -369,9 +194,11 @@ const getDatabaseSchemaEntities = async (
369
194
  model: monacoEditorAPI.ITextModel,
370
195
  playgroundState: SQLPlaygroundPanelState,
371
196
  ): Promise<monacoLanguagesAPI.CompletionItem[]> => {
372
- if (playgroundState.treeData) {
197
+ if (playgroundState.schemaExplorerState?.treeData) {
373
198
  return uniqBy(
374
- Array.from(playgroundState.treeData.nodes.values()).map(
199
+ Array.from(
200
+ playgroundState.schemaExplorerState.treeData.nodes.values(),
201
+ ).map(
375
202
  (value) =>
376
203
  ({
377
204
  label: value.label,
@@ -700,15 +527,21 @@ export const SQLPlaygroundPanel = observer(() => {
700
527
  [handleConnectionDrop],
701
528
  );
702
529
 
703
- const updateDatabase = applicationStore.guardUnhandledError(() =>
704
- flowResult(playgroundState.updateDatabase()),
705
- );
530
+ const updateDatabase = (): void => {
531
+ if (playgroundState.schemaExplorerState) {
532
+ flowResult(playgroundState.schemaExplorerState.updateDatabase()).catch(
533
+ applicationStore.alertUnhandledError,
534
+ );
535
+ }
536
+ };
706
537
 
707
538
  useEffect(() => {
708
- flowResult(playgroundState.fetchDatabaseMetadata()).catch(
709
- applicationStore.alertUnhandledError,
710
- );
711
- }, [playgroundState, applicationStore, playgroundState.connection]);
539
+ if (playgroundState.schemaExplorerState) {
540
+ flowResult(
541
+ playgroundState.schemaExplorerState.fetchDatabaseMetadata(),
542
+ ).catch(applicationStore.alertUnhandledError);
543
+ }
544
+ }, [playgroundState, applicationStore, playgroundState.schemaExplorerState]);
712
545
 
713
546
  useConditionedApplicationNavigationContext(
714
547
  LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY.SQL_PLAYGROUND,
@@ -770,10 +603,13 @@ export const SQLPlaygroundPanel = observer(() => {
770
603
  </div>
771
604
  </div>
772
605
  <div className="sql-playground__config__schema-explorer">
773
- {playgroundState.treeData && (
606
+ {playgroundState.schemaExplorerState?.treeData && (
774
607
  <DatabaseSchemaExplorer
775
- treeData={playgroundState.treeData}
776
- playgroundState={playgroundState}
608
+ treeData={playgroundState.schemaExplorerState.treeData}
609
+ schemaExplorerState={playgroundState.schemaExplorerState}
610
+ treeNodeContainerComponent={
611
+ SQLPlaygroundDatabaseSchemaExplorerTreeNodeContainer
612
+ }
777
613
  />
778
614
  )}
779
615
  </div>
@@ -133,7 +133,7 @@ import {
133
133
  CODE_EDITOR_LANGUAGE,
134
134
  CodeEditor,
135
135
  } from '@finos/legend-lego/code-editor';
136
- import { DatabaseBuilder } from '../editor-group/connection-editor/DatabaseBuilder.js';
136
+ import { DatabaseBuilderWizard } from '../editor-group/connection-editor/DatabaseBuilderWizard.js';
137
137
  import { FunctionEditorState } from '../../../stores/editor/editor-state/element-editor-state/FunctionEditorState.js';
138
138
 
139
139
  const ElementRenamer = observer(() => {
@@ -516,7 +516,7 @@ const ExplorerContextMenu = observer(
516
516
  const buildDatabase = editorStore.applicationStore.guardUnhandledError(
517
517
  async () => {
518
518
  if (isRelationalDatabaseConnection(node?.packageableElement)) {
519
- editorStore.explorerTreeState.buildDbBuilderState(
519
+ editorStore.explorerTreeState.buildDatabase(
520
520
  guaranteeRelationalDatabaseConnection(node?.packageableElement),
521
521
  editorStore.isInViewerMode,
522
522
  );
@@ -1128,7 +1128,7 @@ const ExplorerTrees = observer(() => {
1128
1128
  <ElementRenamer />
1129
1129
  <SampleDataGenerator />
1130
1130
  {editorStore.explorerTreeState.databaseBuilderState && (
1131
- <DatabaseBuilder
1131
+ <DatabaseBuilderWizard
1132
1132
  databaseBuilderState={
1133
1133
  editorStore.explorerTreeState.databaseBuilderState
1134
1134
  }
@@ -275,6 +275,11 @@ const WorkflowExplorerContextMenu = observer(
275
275
  workflowState.cancelJob(node.workflowJob, treeData);
276
276
  }
277
277
  };
278
+ const runManualJob = (): void => {
279
+ if (node instanceof WorkflowJobTreeNodeData) {
280
+ workflowState.runManualJob(node.workflowJob, treeData);
281
+ }
282
+ };
278
283
  const viewLogs = (): void => {
279
284
  if (node instanceof WorkflowJobTreeNodeData) {
280
285
  workflowManagerState.logState.viewJobLogs(node.workflowJob);
@@ -304,6 +309,11 @@ const WorkflowExplorerContextMenu = observer(
304
309
  {node.workflowJob.status === WorkflowJobStatus.IN_PROGRESS && (
305
310
  <MenuContentItem onClick={cancelJob}>Cancel Job</MenuContentItem>
306
311
  )}
312
+ {node.workflowJob.status === WorkflowJobStatus.WAITING_MANUAL && (
313
+ <MenuContentItem onClick={runManualJob}>
314
+ Run Manual Job
315
+ </MenuContentItem>
316
+ )}
307
317
  </>
308
318
  )}
309
319
  {node instanceof WorkflowTreeNodeData && (
@@ -51,7 +51,7 @@ import {
51
51
  type RelationalDatabaseConnection,
52
52
  } from '@finos/legend-graph';
53
53
  import { APPLICATION_EVENT } from '@finos/legend-application';
54
- import { DatabaseBuilderState } from './editor-state/element-editor-state/connection/DatabaseBuilderState.js';
54
+ import { DatabaseBuilderWizardState } from './editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js';
55
55
 
56
56
  export enum ExplorerTreeRootPackageLabel {
57
57
  FILE_GENERATION = 'generated-files',
@@ -75,7 +75,7 @@ export class ExplorerTreeState {
75
75
 
76
76
  elementToRename?: PackageableElement | undefined;
77
77
  classToGenerateSampleData?: Class | undefined;
78
- databaseBuilderState: DatabaseBuilderState | undefined;
78
+ databaseBuilderState: DatabaseBuilderWizardState | undefined;
79
79
 
80
80
  constructor(editorStore: EditorStore) {
81
81
  makeObservable(this, {
@@ -103,7 +103,7 @@ export class ExplorerTreeState {
103
103
  buildTreeInTextMode: action,
104
104
  openExplorerTreeNodes: action,
105
105
  reprocess: action,
106
- buildDbBuilderState: action,
106
+ buildDatabase: action,
107
107
  setDatabaseBuilderState: action,
108
108
  onTreeNodeSelect: action,
109
109
  openNode: action,
@@ -176,14 +176,11 @@ export class ExplorerTreeState {
176
176
  this.classToGenerateSampleData = val;
177
177
  }
178
178
 
179
- setDatabaseBuilderState(val: DatabaseBuilderState | undefined): void {
179
+ setDatabaseBuilderState(val: DatabaseBuilderWizardState | undefined): void {
180
180
  this.databaseBuilderState = val;
181
181
  }
182
- buildDbBuilderState(
183
- val: RelationalDatabaseConnection,
184
- isReadOnly: boolean,
185
- ): void {
186
- const dbBuilderState = new DatabaseBuilderState(
182
+ buildDatabase(val: RelationalDatabaseConnection, isReadOnly: boolean): void {
183
+ const dbBuilderState = new DatabaseBuilderWizardState(
187
184
  this.editorStore,
188
185
  val,
189
186
  isReadOnly,
@@ -31,7 +31,6 @@ import {
31
31
  guaranteeType,
32
32
  assertType,
33
33
  StopWatch,
34
- stringifyLosslessJSON,
35
34
  filterByType,
36
35
  } from '@finos/legend-shared';
37
36
  import { ElementEditorState } from './ElementEditorState.js';
@@ -65,7 +64,6 @@ import {
65
64
  getExecutionQueryFromRawLambda,
66
65
  } from '@finos/legend-query-builder';
67
66
  import { FunctionActivatorBuilderState } from './FunctionActivatorBuilderState.js';
68
- import { DEFAULT_TAB_SIZE } from '@finos/legend-application';
69
67
 
70
68
  export enum FUNCTION_EDITOR_TAB {
71
69
  DEFINITION = 'DEFINITION',
@@ -200,11 +198,11 @@ export class FunctionParametersState extends LambdaParametersState {
200
198
  this.functionEditorState = functionEditorState;
201
199
  }
202
200
 
203
- openModal(query: RawLambda): void {
204
- this.parameterStates = this.build(query);
201
+ openModal(lambda: RawLambda): void {
202
+ this.parameterStates = this.build(lambda);
205
203
  this.parameterValuesEditorState.open(
206
204
  (): Promise<void> =>
207
- flowResult(this.functionEditorState.runQuery()).catch(
205
+ flowResult(this.functionEditorState.runFunc()).catch(
208
206
  this.functionEditorState.editorStore.applicationStore
209
207
  .alertUnhandledError,
210
208
  ),
@@ -212,9 +210,9 @@ export class FunctionParametersState extends LambdaParametersState {
212
210
  );
213
211
  }
214
212
 
215
- build(query: RawLambda): LambdaParameterState[] {
213
+ build(lambda: RawLambda): LambdaParameterState[] {
216
214
  const parameters = buildLambdaVariableExpressions(
217
- query,
215
+ lambda,
218
216
  this.functionEditorState.editorStore.graphManagerState,
219
217
  )
220
218
  .map((parameter) =>
@@ -244,32 +242,32 @@ export class FunctionEditorState extends ElementEditorState {
244
242
 
245
243
  selectedTab: FUNCTION_EDITOR_TAB;
246
244
 
247
- isRunningQuery = false;
245
+ isRunningFunc = false;
248
246
  isGeneratingPlan = false;
249
- executionResultText?: string | undefined; // NOTE: stored as lossless JSON string
247
+ executionResult?: ExecutionResult | undefined; // NOTE: stored as lossless JSON string
250
248
  executionPlanState: ExecutionPlanState;
251
249
  parametersState: FunctionParametersState;
252
- queryRunPromise: Promise<ExecutionResult> | undefined = undefined;
250
+ funcRunPromise: Promise<ExecutionResult> | undefined = undefined;
253
251
 
254
252
  constructor(editorStore: EditorStore, element: PackageableElement) {
255
253
  super(editorStore, element);
256
254
 
257
255
  makeObservable(this, {
258
256
  selectedTab: observable,
259
- isRunningQuery: observable,
257
+ isRunningFunc: observable,
260
258
  isGeneratingPlan: observable,
261
- executionResultText: observable,
259
+ executionResult: observable,
262
260
  executionPlanState: observable,
263
261
  label: override,
264
262
  functionElement: computed,
265
263
  setSelectedTab: action,
266
264
  reprocess: action,
267
- setExecutionResultText: action,
268
- setIsRunningQuery: action,
269
- runQuery: flow,
265
+ setExecutionResult: action,
266
+ setIsRunningFunc: action,
267
+ runFunc: flow,
270
268
  generatePlan: flow,
271
- handleRunQuery: flow,
272
- cancelQuery: flow,
269
+ handleRunFunc: flow,
270
+ cancelFuncRun: flow,
273
271
  });
274
272
 
275
273
  assertType(
@@ -346,21 +344,19 @@ export class FunctionEditorState extends ElementEditorState {
346
344
  return functionEditorState;
347
345
  }
348
346
 
349
- setIsRunningQuery(val: boolean): void {
350
- this.isRunningQuery = val;
347
+ setIsRunningFunc(val: boolean): void {
348
+ this.isRunningFunc = val;
351
349
  }
352
350
 
353
- setExecutionResultText = (executionResult: string | undefined): void => {
354
- this.executionResultText = executionResult;
351
+ setExecutionResult = (executionResult: ExecutionResult | undefined): void => {
352
+ this.executionResult = executionResult;
355
353
  };
356
354
 
357
- setQueryRunPromise = (
358
- promise: Promise<ExecutionResult> | undefined,
359
- ): void => {
360
- this.queryRunPromise = promise;
355
+ setFuncRunPromise = (promise: Promise<ExecutionResult> | undefined): void => {
356
+ this.funcRunPromise = promise;
361
357
  };
362
358
 
363
- get query(): RawLambda {
359
+ get bodyExpressionSequence(): RawLambda {
364
360
  return new RawLambda(
365
361
  this.functionElement.parameters.map((parameter) =>
366
362
  this.editorStore.graphManagerState.graphManager.serializeRawValueSpecification(
@@ -376,7 +372,7 @@ export class FunctionEditorState extends ElementEditorState {
376
372
  return;
377
373
  }
378
374
  try {
379
- const query = this.query;
375
+ const expressionSequence = this.bodyExpressionSequence;
380
376
  this.isGeneratingPlan = true;
381
377
  let rawPlan: RawExecutionPlan;
382
378
 
@@ -391,7 +387,7 @@ export class FunctionEditorState extends ElementEditorState {
391
387
  );
392
388
  const debugResult =
393
389
  (yield this.editorStore.graphManagerState.graphManager.debugExecutionPlanGeneration(
394
- query,
390
+ expressionSequence,
395
391
  undefined,
396
392
  undefined,
397
393
  this.editorStore.graphManagerState.graph,
@@ -405,7 +401,7 @@ export class FunctionEditorState extends ElementEditorState {
405
401
  );
406
402
  rawPlan =
407
403
  (yield this.editorStore.graphManagerState.graphManager.generateExecutionPlan(
408
- query,
404
+ expressionSequence,
409
405
  undefined,
410
406
  undefined,
411
407
  this.editorStore.graphManagerState.graph,
@@ -456,21 +452,21 @@ export class FunctionEditorState extends ElementEditorState {
456
452
  }
457
453
  }
458
454
 
459
- *handleRunQuery(): GeneratorFn<void> {
460
- if (this.isRunningQuery) {
455
+ *handleRunFunc(): GeneratorFn<void> {
456
+ if (this.isRunningFunc) {
461
457
  return;
462
458
  }
463
- const query = this.query;
464
- const parameters = (query.parameters ?? []) as object[];
459
+ const expressionSequence = this.bodyExpressionSequence;
460
+ const parameters = (expressionSequence.parameters ?? []) as object[];
465
461
  if (parameters.length) {
466
- this.parametersState.openModal(query);
462
+ this.parametersState.openModal(expressionSequence);
467
463
  } else {
468
- this.runQuery();
464
+ this.runFunc();
469
465
  }
470
466
  }
471
467
 
472
- *runQuery(): GeneratorFn<void> {
473
- if (this.isRunningQuery) {
468
+ *runFunc(): GeneratorFn<void> {
469
+ if (this.isRunningFunc) {
474
470
  return;
475
471
  }
476
472
 
@@ -480,14 +476,14 @@ export class FunctionEditorState extends ElementEditorState {
480
476
 
481
477
  let promise;
482
478
  try {
483
- this.isRunningQuery = true;
479
+ this.isRunningFunc = true;
484
480
  const stopWatch = new StopWatch();
485
481
  const report = reportGraphAnalytics(
486
482
  this.editorStore.graphManagerState.graph,
487
483
  );
488
484
  promise = this.editorStore.graphManagerState.graphManager.runQuery(
489
485
  getExecutionQueryFromRawLambda(
490
- this.query,
486
+ this.bodyExpressionSequence,
491
487
  this.parametersState.parameterStates,
492
488
  this.editorStore.graphManagerState,
493
489
  ),
@@ -495,7 +491,7 @@ export class FunctionEditorState extends ElementEditorState {
495
491
  undefined,
496
492
  this.editorStore.graphManagerState.graph,
497
493
  {
498
- useLosslessParse: true,
494
+ useLosslessParse: false,
499
495
  parameterValues: buildExecutionParameterValues(
500
496
  this.parametersState.parameterStates,
501
497
  this.editorStore.graphManagerState,
@@ -503,12 +499,10 @@ export class FunctionEditorState extends ElementEditorState {
503
499
  },
504
500
  report,
505
501
  );
506
- this.setQueryRunPromise(promise);
502
+ this.setFuncRunPromise(promise);
507
503
  const result = (yield promise) as ExecutionResult;
508
- if (this.queryRunPromise === promise) {
509
- this.setExecutionResultText(
510
- stringifyLosslessJSON(result, undefined, DEFAULT_TAB_SIZE),
511
- );
504
+ if (this.funcRunPromise === promise) {
505
+ this.setExecutionResult(result);
512
506
  this.parametersState.setParameters([]);
513
507
  // report
514
508
  report.timings =
@@ -525,7 +519,7 @@ export class FunctionEditorState extends ElementEditorState {
525
519
  // When user cancels the query by calling the cancelQuery api, it will throw an execution failure error.
526
520
  // For now, we don't want to notify users about this failure. Therefore we check to ensure the promise is still the same one.
527
521
  // When cancelled the query, we set the queryRunPromise as undefined.
528
- if (this.queryRunPromise === promise) {
522
+ if (this.funcRunPromise === promise) {
529
523
  assertErrorThrown(error);
530
524
  this.editorStore.applicationStore.logService.error(
531
525
  LogEvent.create(GRAPH_MANAGER_EVENT.EXECUTION_FAILURE),
@@ -536,13 +530,13 @@ export class FunctionEditorState extends ElementEditorState {
536
530
  );
537
531
  }
538
532
  } finally {
539
- this.isRunningQuery = false;
533
+ this.isRunningFunc = false;
540
534
  }
541
535
  }
542
536
 
543
- *cancelQuery(): GeneratorFn<void> {
544
- this.setIsRunningQuery(false);
545
- this.setQueryRunPromise(undefined);
537
+ *cancelFuncRun(): GeneratorFn<void> {
538
+ this.setIsRunningFunc(false);
539
+ this.setFuncRunPromise(undefined);
546
540
  try {
547
541
  yield this.editorStore.graphManagerState.graphManager.cancelUserExecutions(
548
542
  true,