@finos/legend-application-studio 26.1.1 → 26.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts +2 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts.map +1 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.js +1 -0
- package/lib/__lib__/LegendStudioApplicationNavigationContext.js.map +1 -1
- package/lib/__lib__/STO_Relational_LegendStudioCommand.d.ts +21 -0
- package/lib/__lib__/STO_Relational_LegendStudioCommand.d.ts.map +1 -0
- package/lib/__lib__/STO_Relational_LegendStudioCommand.js +28 -0
- package/lib/__lib__/STO_Relational_LegendStudioCommand.js.map +1 -0
- package/lib/application/LegendStudioApplicationConfig.d.ts +5 -0
- package/lib/application/LegendStudioApplicationConfig.d.ts.map +1 -1
- package/lib/application/LegendStudioApplicationConfig.js +6 -0
- package/lib/application/LegendStudioApplicationConfig.js.map +1 -1
- package/lib/components/ElementIconUtils.d.ts +13 -2
- package/lib/components/ElementIconUtils.d.ts.map +1 -1
- package/lib/components/ElementIconUtils.js +15 -6
- package/lib/components/ElementIconUtils.js.map +1 -1
- package/lib/components/editor/Editor.d.ts.map +1 -1
- package/lib/components/editor/Editor.js +2 -1
- package/lib/components/editor/Editor.js.map +1 -1
- package/lib/components/editor/QuickInput.d.ts +19 -0
- package/lib/components/editor/QuickInput.d.ts.map +1 -0
- package/lib/components/editor/QuickInput.js +51 -0
- package/lib/components/editor/QuickInput.js.map +1 -0
- package/lib/components/editor/__test-utils__/EditorComponentTestUtils.d.ts.map +1 -1
- package/lib/components/editor/__test-utils__/EditorComponentTestUtils.js +5 -1
- package/lib/components/editor/__test-utils__/EditorComponentTestUtils.js.map +1 -1
- package/lib/components/editor/command-center/ProjectSearchCommand.js +3 -3
- package/lib/components/editor/command-center/ProjectSearchCommand.js.map +1 -1
- package/lib/components/editor/editor-group/EditorGroup.d.ts.map +1 -1
- package/lib/components/editor/editor-group/EditorGroup.js +11 -4
- package/lib/components/editor/editor-group/EditorGroup.js.map +1 -1
- package/lib/components/editor/editor-group/FunctionEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/FunctionEditor.js +30 -8
- package/lib/components/editor/editor-group/FunctionEditor.js.map +1 -1
- package/lib/components/editor/editor-group/GenerationSpecificationEditor.js +1 -1
- package/lib/components/editor/editor-group/GenerationSpecificationEditor.js.map +1 -1
- package/lib/components/editor/editor-group/GrammarTextEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/GrammarTextEditor.js +99 -100
- package/lib/components/editor/editor-group/GrammarTextEditor.js.map +1 -1
- package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.d.ts.map +1 -1
- package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.js +5 -5
- package/lib/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.js.map +1 -1
- package/lib/components/editor/editor-group/RuntimeEditor.js +1 -1
- package/lib/components/editor/editor-group/RuntimeEditor.js.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.d.ts.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js +27 -19
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js +2 -2
- package/lib/components/editor/editor-group/diff-editor/EntityChangeConflictEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/diff-editor/EntityChangeConflictEditor.js +5 -5
- package/lib/components/editor/editor-group/diff-editor/EntityChangeConflictEditor.js.map +1 -1
- package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.js +2 -2
- package/lib/components/editor/editor-group/element-generation-editor/FileGenerationEditor.js.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/ClassMappingEditor.js +1 -1
- package/lib/components/editor/editor-group/mapping-editor/ClassMappingEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingExplorer.js +2 -2
- package/lib/components/editor/editor-group/mapping-editor/MappingExplorer.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/PropertyMappingsEditor.js +1 -1
- package/lib/components/editor/editor-group/mapping-editor/PropertyMappingsEditor.js.map +1 -1
- package/lib/components/editor/editor-group/service-editor/ServiceExecutionQueryEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/service-editor/ServiceExecutionQueryEditor.js +4 -6
- package/lib/components/editor/editor-group/service-editor/ServiceExecutionQueryEditor.js.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.js +2 -2
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.js.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.js +2 -2
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.js.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/AssociationEditor.js +2 -2
- package/lib/components/editor/editor-group/uml-editor/AssociationEditor.js.map +1 -1
- package/lib/components/editor/editor-group/uml-editor/ClassEditor.js +4 -4
- package/lib/components/editor/editor-group/uml-editor/ClassEditor.js.map +1 -1
- package/lib/components/editor/panel-group/PanelGroup.d.ts +2 -0
- package/lib/components/editor/panel-group/PanelGroup.d.ts.map +1 -1
- package/lib/components/editor/panel-group/PanelGroup.js +18 -3
- package/lib/components/editor/panel-group/PanelGroup.js.map +1 -1
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts +26 -0
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts.map +1 -0
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.js +339 -0
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.js.map +1 -0
- package/lib/components/editor/side-bar/Explorer.js +5 -6
- package/lib/components/editor/side-bar/Explorer.js.map +1 -1
- package/lib/components/editor/side-bar/testable/GlobalTestRunner.js +1 -1
- package/lib/components/editor/side-bar/testable/GlobalTestRunner.js.map +1 -1
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.d.ts.map +1 -1
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.js +5 -1
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +2 -2
- package/lib/stores/editor/EditorConfig.d.ts +2 -1
- package/lib/stores/editor/EditorConfig.d.ts.map +1 -1
- package/lib/stores/editor/EditorConfig.js +1 -0
- package/lib/stores/editor/EditorConfig.js.map +1 -1
- package/lib/stores/editor/EditorStore.d.ts +8 -2
- package/lib/stores/editor/EditorStore.d.ts.map +1 -1
- package/lib/stores/editor/EditorStore.js +19 -4
- package/lib/stores/editor/EditorStore.js.map +1 -1
- package/lib/stores/editor/GraphEditFormModeState.d.ts.map +1 -1
- package/lib/stores/editor/GraphEditFormModeState.js +1 -0
- package/lib/stores/editor/GraphEditFormModeState.js.map +1 -1
- package/lib/stores/editor/QuickInputState.d.ts +28 -0
- package/lib/stores/editor/QuickInputState.d.ts.map +1 -0
- package/lib/stores/editor/QuickInputState.js +17 -0
- package/lib/stores/editor/QuickInputState.js.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts +22 -2
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js +181 -4
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.js +6 -2
- package/lib/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts +19 -18
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js +167 -157
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingElementDecorator.d.ts +3 -3
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingElementDecorator.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingElementDecorator.js +2 -2
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingElementDecorator.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceExecutionState.d.ts +8 -9
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceExecutionState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceExecutionState.js +9 -14
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceExecutionState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts +4 -4
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js +7 -8
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.d.ts +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js +3 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js.map +1 -1
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts +82 -0
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts.map +1 -0
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js +328 -0
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js.map +1 -0
- package/lib/stores/graph-modifier/DSL_Service_GraphModifierHelper.d.ts +1 -1
- package/lib/stores/graph-modifier/DSL_Service_GraphModifierHelper.d.ts.map +1 -1
- package/lib/stores/graph-modifier/DSL_Service_GraphModifierHelper.js +8 -2
- package/lib/stores/graph-modifier/DSL_Service_GraphModifierHelper.js.map +1 -1
- package/package.json +12 -12
- package/src/__lib__/LegendStudioApplicationNavigationContext.ts +2 -0
- package/src/__lib__/STO_Relational_LegendStudioCommand.ts +30 -0
- package/src/application/LegendStudioApplicationConfig.ts +7 -0
- package/src/components/ElementIconUtils.tsx +23 -8
- package/src/components/editor/Editor.tsx +2 -0
- package/src/components/editor/QuickInput.tsx +91 -0
- package/src/components/editor/__test-utils__/EditorComponentTestUtils.tsx +5 -1
- package/src/components/editor/command-center/ProjectSearchCommand.tsx +4 -4
- package/src/components/editor/editor-group/EditorGroup.tsx +41 -1
- package/src/components/editor/editor-group/FunctionEditor.tsx +145 -5
- package/src/components/editor/editor-group/GenerationSpecificationEditor.tsx +1 -1
- package/src/components/editor/editor-group/GrammarTextEditor.tsx +134 -131
- package/src/components/editor/editor-group/INTERNAL__UnknownFunctionActivatorEdtior.tsx +26 -13
- package/src/components/editor/editor-group/RuntimeEditor.tsx +1 -1
- package/src/components/editor/editor-group/connection-editor/DatabaseBuilder.tsx +193 -150
- package/src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx +2 -2
- package/src/components/editor/editor-group/diff-editor/EntityChangeConflictEditor.tsx +6 -5
- package/src/components/editor/editor-group/element-generation-editor/FileGenerationEditor.tsx +1 -1
- package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.tsx +1 -1
- package/src/components/editor/editor-group/mapping-editor/ClassMappingEditor.tsx +1 -1
- package/src/components/editor/editor-group/mapping-editor/MappingExplorer.tsx +2 -2
- package/src/components/editor/editor-group/mapping-editor/PropertyMappingsEditor.tsx +1 -1
- package/src/components/editor/editor-group/service-editor/ServiceExecutionQueryEditor.tsx +8 -10
- package/src/components/editor/editor-group/service-editor/testable/ServiceTestDataEditor.tsx +2 -2
- package/src/components/editor/editor-group/service-editor/testable/ServiceTestableEditor.tsx +9 -3
- package/src/components/editor/editor-group/uml-editor/AssociationEditor.tsx +2 -2
- package/src/components/editor/editor-group/uml-editor/ClassEditor.tsx +4 -4
- package/src/components/editor/panel-group/PanelGroup.tsx +35 -3
- package/src/components/editor/panel-group/SQLPlaygroundPanel.tsx +730 -0
- package/src/components/editor/side-bar/Explorer.tsx +5 -5
- package/src/components/editor/side-bar/testable/GlobalTestRunner.tsx +1 -1
- package/src/components/extensions/Core_LegendStudioApplicationPlugin.tsx +9 -3
- package/src/stores/editor/EditorConfig.ts +1 -0
- package/src/stores/editor/EditorStore.ts +23 -4
- package/src/stores/editor/GraphEditFormModeState.ts +1 -0
- package/src/stores/editor/QuickInputState.ts +24 -0
- package/src/stores/editor/editor-state/element-editor-state/FunctionEditorState.ts +317 -3
- package/src/stores/editor/editor-state/element-editor-state/ProtocolValueBuilderState.ts +11 -2
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts +262 -249
- package/src/stores/editor/editor-state/element-editor-state/mapping/MappingElementDecorator.ts +5 -5
- package/src/stores/editor/editor-state/element-editor-state/service/ServiceExecutionState.ts +19 -23
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +9 -9
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.ts +4 -2
- package/src/stores/editor/panel-group/SQLPlaygroundPanelState.ts +485 -0
- package/src/stores/graph-modifier/DSL_Service_GraphModifierHelper.ts +13 -1
- package/tsconfig.json +5 -0
@@ -0,0 +1,485 @@
|
|
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 { TreeData, TreeNodeData } from '@finos/legend-art';
|
18
|
+
import {
|
19
|
+
type GeneratorFn,
|
20
|
+
assertErrorThrown,
|
21
|
+
LogEvent,
|
22
|
+
addUniqueEntry,
|
23
|
+
isNonNullable,
|
24
|
+
filterByType,
|
25
|
+
ActionState,
|
26
|
+
getNonNullableEntry,
|
27
|
+
getNullableLastEntry,
|
28
|
+
} from '@finos/legend-shared';
|
29
|
+
import { observable, makeObservable, flow, flowResult, action } from 'mobx';
|
30
|
+
import { editor as monacoEditorAPI } from 'monaco-editor';
|
31
|
+
import {
|
32
|
+
type Schema,
|
33
|
+
type Table,
|
34
|
+
type Database,
|
35
|
+
type PackageableConnection,
|
36
|
+
DatabaseBuilderInput,
|
37
|
+
DatabasePattern,
|
38
|
+
TargetDatabase,
|
39
|
+
Column,
|
40
|
+
getSchema,
|
41
|
+
guaranteeRelationalDatabaseConnection,
|
42
|
+
GRAPH_MANAGER_EVENT,
|
43
|
+
} from '@finos/legend-graph';
|
44
|
+
import type { EditorStore } from '../EditorStore.js';
|
45
|
+
import { LEGEND_STUDIO_APP_EVENT } from '../../../__lib__/LegendStudioEvent.js';
|
46
|
+
import {
|
47
|
+
CODE_EDITOR_LANGUAGE,
|
48
|
+
moveCursorToPosition,
|
49
|
+
} from '@finos/legend-lego/code-editor';
|
50
|
+
import type { CommandRegistrar } from '@finos/legend-application';
|
51
|
+
import { STO_RELATIONAL_LEGEND_STUDIO_COMMAND_KEY } from '../../../__lib__/STO_Relational_LegendStudioCommand.js';
|
52
|
+
import { PANEL_MODE } from '../EditorConfig.js';
|
53
|
+
|
54
|
+
export abstract class DatabaseSchemaExplorerTreeNodeData
|
55
|
+
implements TreeNodeData
|
56
|
+
{
|
57
|
+
isOpen?: boolean | undefined;
|
58
|
+
id: string;
|
59
|
+
label: string;
|
60
|
+
parentId?: string | undefined;
|
61
|
+
childrenIds?: string[] | undefined;
|
62
|
+
|
63
|
+
constructor(id: string, label: string, parentId: string | undefined) {
|
64
|
+
this.id = id;
|
65
|
+
this.label = label;
|
66
|
+
this.parentId = parentId;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
export class DatabaseSchemaExplorerTreeSchemaNodeData extends DatabaseSchemaExplorerTreeNodeData {
|
71
|
+
schema: Schema;
|
72
|
+
|
73
|
+
constructor(id: string, schema: Schema) {
|
74
|
+
super(id, schema.name, undefined);
|
75
|
+
this.schema = schema;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
export class DatabaseSchemaExplorerTreeTableNodeData extends DatabaseSchemaExplorerTreeNodeData {
|
80
|
+
override parentId: string;
|
81
|
+
owner: Schema;
|
82
|
+
table: Table;
|
83
|
+
|
84
|
+
constructor(id: string, parentId: string, owner: Schema, table: Table) {
|
85
|
+
super(id, table.name, parentId);
|
86
|
+
this.parentId = parentId;
|
87
|
+
this.owner = owner;
|
88
|
+
this.table = table;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
export class DatabaseSchemaExplorerTreeColumnNodeData extends DatabaseSchemaExplorerTreeNodeData {
|
93
|
+
override parentId: string;
|
94
|
+
owner: Table;
|
95
|
+
column: Column;
|
96
|
+
|
97
|
+
constructor(id: string, parentId: string, owner: Table, column: Column) {
|
98
|
+
super(id, column.name, parentId);
|
99
|
+
this.parentId = parentId;
|
100
|
+
this.owner = owner;
|
101
|
+
this.column = column;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
export interface DatabaseSchemaExplorerTreeData
|
106
|
+
extends TreeData<DatabaseSchemaExplorerTreeNodeData> {
|
107
|
+
database: Database;
|
108
|
+
}
|
109
|
+
|
110
|
+
const DUMMY_DATABASE_PACKAGE = 'dummy';
|
111
|
+
const DUMMY_DATABASE_NAME = 'DummyDB';
|
112
|
+
const DEFAULT_SQL_TEXT = `--Start building your SQL. Note that you can also drag-and-drop nodes from schema explorer\n`;
|
113
|
+
|
114
|
+
export class SQLPlaygroundPanelState implements CommandRegistrar {
|
115
|
+
readonly editorStore: EditorStore;
|
116
|
+
|
117
|
+
isFetchingSchema = false;
|
118
|
+
isExecutingRawSQL = false;
|
119
|
+
|
120
|
+
connection?: PackageableConnection | undefined;
|
121
|
+
treeData?: DatabaseSchemaExplorerTreeData | undefined;
|
122
|
+
readonly sqlEditorTextModel: monacoEditorAPI.ITextModel;
|
123
|
+
sqlEditor?: monacoEditorAPI.IStandaloneCodeEditor | undefined;
|
124
|
+
sqlEditorViewState?: monacoEditorAPI.ICodeEditorViewState | undefined;
|
125
|
+
sqlText = DEFAULT_SQL_TEXT;
|
126
|
+
sqlExecutionResult?: string | undefined;
|
127
|
+
|
128
|
+
constructor(editorStore: EditorStore) {
|
129
|
+
makeObservable(this, {
|
130
|
+
isFetchingSchema: observable,
|
131
|
+
isExecutingRawSQL: observable,
|
132
|
+
connection: observable,
|
133
|
+
treeData: observable,
|
134
|
+
sqlText: observable,
|
135
|
+
resetSQL: action,
|
136
|
+
sqlExecutionResult: observable,
|
137
|
+
sqlEditor: observable.ref,
|
138
|
+
sqlEditorViewState: observable.ref,
|
139
|
+
setTreeData: action,
|
140
|
+
setConnection: action,
|
141
|
+
setSQLEditor: action,
|
142
|
+
setSQLEditorViewState: action,
|
143
|
+
setSQLText: action,
|
144
|
+
onNodeSelect: flow,
|
145
|
+
fetchDatabaseMetadata: flow,
|
146
|
+
fetchSchemaMetadata: flow,
|
147
|
+
fetchTableMetadata: flow,
|
148
|
+
executeRawSQL: flow,
|
149
|
+
});
|
150
|
+
|
151
|
+
this.editorStore = editorStore;
|
152
|
+
this.sqlEditorTextModel = monacoEditorAPI.createModel(
|
153
|
+
this.sqlText,
|
154
|
+
CODE_EDITOR_LANGUAGE.SQL,
|
155
|
+
);
|
156
|
+
}
|
157
|
+
|
158
|
+
setTreeData(val?: DatabaseSchemaExplorerTreeData): void {
|
159
|
+
this.treeData = val;
|
160
|
+
}
|
161
|
+
|
162
|
+
setConnection(val: PackageableConnection | undefined): void {
|
163
|
+
this.connection = val;
|
164
|
+
this.sqlEditorTextModel.setValue(DEFAULT_SQL_TEXT);
|
165
|
+
}
|
166
|
+
|
167
|
+
setSQLText(val: string): void {
|
168
|
+
this.sqlText = val;
|
169
|
+
}
|
170
|
+
|
171
|
+
setSQLEditor(val: monacoEditorAPI.IStandaloneCodeEditor | undefined): void {
|
172
|
+
this.sqlEditor = val;
|
173
|
+
if (val) {
|
174
|
+
const lines = this.sqlText.split('\n');
|
175
|
+
moveCursorToPosition(val, {
|
176
|
+
lineNumber: lines.length,
|
177
|
+
column: getNullableLastEntry(lines)?.length ?? 0,
|
178
|
+
});
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
resetSQL(): void {
|
183
|
+
this.setSQLText(DEFAULT_SQL_TEXT);
|
184
|
+
this.sqlEditorTextModel.setValue(DEFAULT_SQL_TEXT);
|
185
|
+
this.sqlExecutionResult = undefined;
|
186
|
+
}
|
187
|
+
|
188
|
+
setSQLEditorViewState(
|
189
|
+
val: monacoEditorAPI.ICodeEditorViewState | undefined,
|
190
|
+
): void {
|
191
|
+
this.sqlEditorViewState = val;
|
192
|
+
}
|
193
|
+
|
194
|
+
registerCommands(): void {
|
195
|
+
this.editorStore.applicationStore.commandService.registerCommand({
|
196
|
+
key: STO_RELATIONAL_LEGEND_STUDIO_COMMAND_KEY.SQL_PLAYGROUND_EXECUTE,
|
197
|
+
trigger: () =>
|
198
|
+
this.editorStore.isInitialized &&
|
199
|
+
this.editorStore.activePanelMode === PANEL_MODE.SQL_PLAYGROUND &&
|
200
|
+
Boolean(this.connection) &&
|
201
|
+
Boolean(this.sqlText.length),
|
202
|
+
action: () => {
|
203
|
+
flowResult(this.executeRawSQL()).catch(
|
204
|
+
this.editorStore.applicationStore.alertUnhandledError,
|
205
|
+
);
|
206
|
+
},
|
207
|
+
});
|
208
|
+
}
|
209
|
+
|
210
|
+
deregisterCommands(): void {
|
211
|
+
[STO_RELATIONAL_LEGEND_STUDIO_COMMAND_KEY.SQL_PLAYGROUND_EXECUTE].forEach(
|
212
|
+
(key) =>
|
213
|
+
this.editorStore.applicationStore.commandService.deregisterCommand(key),
|
214
|
+
);
|
215
|
+
}
|
216
|
+
|
217
|
+
*onNodeSelect(
|
218
|
+
node: DatabaseSchemaExplorerTreeNodeData,
|
219
|
+
treeData: DatabaseSchemaExplorerTreeData,
|
220
|
+
): GeneratorFn<void> {
|
221
|
+
if (
|
222
|
+
node instanceof DatabaseSchemaExplorerTreeSchemaNodeData &&
|
223
|
+
!node.childrenIds
|
224
|
+
) {
|
225
|
+
yield flowResult(this.fetchSchemaMetadata(node, treeData));
|
226
|
+
} else if (
|
227
|
+
node instanceof DatabaseSchemaExplorerTreeTableNodeData &&
|
228
|
+
!node.childrenIds
|
229
|
+
) {
|
230
|
+
yield flowResult(this.fetchTableMetadata(node, treeData));
|
231
|
+
}
|
232
|
+
node.isOpen = !node.isOpen;
|
233
|
+
this.setTreeData({ ...treeData });
|
234
|
+
}
|
235
|
+
|
236
|
+
getChildNodes(
|
237
|
+
node: DatabaseSchemaExplorerTreeNodeData,
|
238
|
+
treeData: DatabaseSchemaExplorerTreeData,
|
239
|
+
): DatabaseSchemaExplorerTreeNodeData[] | undefined {
|
240
|
+
return node.childrenIds
|
241
|
+
?.map((n) => treeData.nodes.get(n))
|
242
|
+
.filter(isNonNullable);
|
243
|
+
}
|
244
|
+
|
245
|
+
*fetchDatabaseMetadata(): GeneratorFn<void> {
|
246
|
+
if (!this.connection) {
|
247
|
+
return;
|
248
|
+
}
|
249
|
+
|
250
|
+
try {
|
251
|
+
this.isFetchingSchema = true;
|
252
|
+
|
253
|
+
const databaseBuilderInput = new DatabaseBuilderInput(
|
254
|
+
guaranteeRelationalDatabaseConnection(this.connection),
|
255
|
+
);
|
256
|
+
databaseBuilderInput.targetDatabase = new TargetDatabase(
|
257
|
+
DUMMY_DATABASE_PACKAGE,
|
258
|
+
DUMMY_DATABASE_NAME,
|
259
|
+
);
|
260
|
+
databaseBuilderInput.config.maxTables = undefined;
|
261
|
+
databaseBuilderInput.config.enrichTables = false;
|
262
|
+
databaseBuilderInput.config.patterns = [
|
263
|
+
new DatabasePattern(undefined, undefined),
|
264
|
+
];
|
265
|
+
|
266
|
+
const database = (yield this.buildIntermediateDatabase(
|
267
|
+
databaseBuilderInput,
|
268
|
+
)) as Database;
|
269
|
+
const rootIds: string[] = [];
|
270
|
+
const nodes = new Map<string, DatabaseSchemaExplorerTreeNodeData>();
|
271
|
+
database.schemas
|
272
|
+
.slice()
|
273
|
+
.sort((schemaA, schemaB) => schemaA.name.localeCompare(schemaB.name))
|
274
|
+
.forEach((dbSchema) => {
|
275
|
+
const schemaId = dbSchema.name;
|
276
|
+
rootIds.push(schemaId);
|
277
|
+
const schemaNode = new DatabaseSchemaExplorerTreeSchemaNodeData(
|
278
|
+
schemaId,
|
279
|
+
dbSchema,
|
280
|
+
);
|
281
|
+
nodes.set(schemaId, schemaNode);
|
282
|
+
});
|
283
|
+
const treeData = { rootIds, nodes, database };
|
284
|
+
this.setTreeData(treeData);
|
285
|
+
} catch (error) {
|
286
|
+
assertErrorThrown(error);
|
287
|
+
this.editorStore.applicationStore.logService.error(
|
288
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_BUILDER_FAILURE),
|
289
|
+
error,
|
290
|
+
);
|
291
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
292
|
+
} finally {
|
293
|
+
this.isFetchingSchema = false;
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
*fetchSchemaMetadata(
|
298
|
+
schemaNode: DatabaseSchemaExplorerTreeSchemaNodeData,
|
299
|
+
treeData: DatabaseSchemaExplorerTreeData,
|
300
|
+
): GeneratorFn<void> {
|
301
|
+
if (!this.connection) {
|
302
|
+
return;
|
303
|
+
}
|
304
|
+
|
305
|
+
try {
|
306
|
+
this.isFetchingSchema = true;
|
307
|
+
|
308
|
+
const schema = schemaNode.schema;
|
309
|
+
const databaseBuilderInput = new DatabaseBuilderInput(
|
310
|
+
guaranteeRelationalDatabaseConnection(this.connection),
|
311
|
+
);
|
312
|
+
databaseBuilderInput.targetDatabase = new TargetDatabase(
|
313
|
+
DUMMY_DATABASE_PACKAGE,
|
314
|
+
DUMMY_DATABASE_NAME,
|
315
|
+
);
|
316
|
+
databaseBuilderInput.config.maxTables = undefined;
|
317
|
+
databaseBuilderInput.config.enrichTables = true;
|
318
|
+
databaseBuilderInput.config.patterns = [
|
319
|
+
new DatabasePattern(schema.name, undefined),
|
320
|
+
];
|
321
|
+
|
322
|
+
const database = (yield this.buildIntermediateDatabase(
|
323
|
+
databaseBuilderInput,
|
324
|
+
)) as Database;
|
325
|
+
const tables = getSchema(database, schema.name).tables;
|
326
|
+
const childrenIds = schemaNode.childrenIds ?? [];
|
327
|
+
schema.tables = tables;
|
328
|
+
tables
|
329
|
+
.slice()
|
330
|
+
.sort((tableA, tableB) => tableA.name.localeCompare(tableB.name))
|
331
|
+
.forEach((table) => {
|
332
|
+
table.schema = schema;
|
333
|
+
const tableId = `${schema.name}.${table.name}`;
|
334
|
+
const tableNode = new DatabaseSchemaExplorerTreeTableNodeData(
|
335
|
+
tableId,
|
336
|
+
schemaNode.id,
|
337
|
+
schema,
|
338
|
+
table,
|
339
|
+
);
|
340
|
+
treeData.nodes.set(tableId, tableNode);
|
341
|
+
addUniqueEntry(childrenIds, tableId);
|
342
|
+
});
|
343
|
+
schemaNode.childrenIds = childrenIds;
|
344
|
+
this.setTreeData({ ...treeData });
|
345
|
+
} catch (error) {
|
346
|
+
assertErrorThrown(error);
|
347
|
+
this.editorStore.applicationStore.logService.error(
|
348
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_BUILDER_FAILURE),
|
349
|
+
error,
|
350
|
+
);
|
351
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
352
|
+
} finally {
|
353
|
+
this.isFetchingSchema = false;
|
354
|
+
}
|
355
|
+
}
|
356
|
+
|
357
|
+
*fetchTableMetadata(
|
358
|
+
tableNode: DatabaseSchemaExplorerTreeTableNodeData,
|
359
|
+
treeData: DatabaseSchemaExplorerTreeData,
|
360
|
+
): GeneratorFn<void> {
|
361
|
+
if (!this.connection) {
|
362
|
+
return;
|
363
|
+
}
|
364
|
+
|
365
|
+
try {
|
366
|
+
this.isFetchingSchema = true;
|
367
|
+
|
368
|
+
const table = tableNode.table;
|
369
|
+
const databaseBuilderInput = new DatabaseBuilderInput(
|
370
|
+
guaranteeRelationalDatabaseConnection(this.connection),
|
371
|
+
);
|
372
|
+
databaseBuilderInput.targetDatabase = new TargetDatabase(
|
373
|
+
DUMMY_DATABASE_PACKAGE,
|
374
|
+
DUMMY_DATABASE_NAME,
|
375
|
+
);
|
376
|
+
const config = databaseBuilderInput.config;
|
377
|
+
config.maxTables = undefined;
|
378
|
+
config.enrichTables = true;
|
379
|
+
config.enrichColumns = true;
|
380
|
+
config.enrichPrimaryKeys = true;
|
381
|
+
config.patterns = [new DatabasePattern(table.schema.name, table.name)];
|
382
|
+
const database = (yield this.buildIntermediateDatabase(
|
383
|
+
databaseBuilderInput,
|
384
|
+
)) as Database;
|
385
|
+
|
386
|
+
const enrichedTable = database.schemas
|
387
|
+
.find((schema) => table.schema.name === schema.name)
|
388
|
+
?.tables.find((t) => t.name === table.name);
|
389
|
+
if (enrichedTable) {
|
390
|
+
table.primaryKey = enrichedTable.primaryKey;
|
391
|
+
const columns = enrichedTable.columns.filter(filterByType(Column));
|
392
|
+
tableNode.table.columns = columns;
|
393
|
+
tableNode.childrenIds?.forEach((c) => treeData.nodes.delete(c));
|
394
|
+
tableNode.childrenIds = undefined;
|
395
|
+
const childrenIds: string[] = [];
|
396
|
+
const tableId = tableNode.id;
|
397
|
+
columns
|
398
|
+
.slice()
|
399
|
+
.sort((colA, colB) => colA.name.localeCompare(colB.name))
|
400
|
+
.forEach((col) => {
|
401
|
+
const columnId = `${tableId}.${col.name}`;
|
402
|
+
const columnNode = new DatabaseSchemaExplorerTreeColumnNodeData(
|
403
|
+
columnId,
|
404
|
+
tableId,
|
405
|
+
table,
|
406
|
+
col,
|
407
|
+
);
|
408
|
+
col.owner = tableNode.table;
|
409
|
+
treeData.nodes.set(columnId, columnNode);
|
410
|
+
addUniqueEntry(childrenIds, columnId);
|
411
|
+
});
|
412
|
+
tableNode.childrenIds = childrenIds;
|
413
|
+
}
|
414
|
+
} catch (error) {
|
415
|
+
assertErrorThrown(error);
|
416
|
+
this.editorStore.applicationStore.logService.error(
|
417
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_BUILDER_FAILURE),
|
418
|
+
error,
|
419
|
+
);
|
420
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
421
|
+
} finally {
|
422
|
+
this.isFetchingSchema = false;
|
423
|
+
}
|
424
|
+
}
|
425
|
+
|
426
|
+
/**
|
427
|
+
* This will build the intermediate database from the specified
|
428
|
+
* schema exploration input; this information can be further used
|
429
|
+
* to enrich the explorer tree
|
430
|
+
*/
|
431
|
+
private async buildIntermediateDatabase(
|
432
|
+
input: DatabaseBuilderInput,
|
433
|
+
): Promise<Database> {
|
434
|
+
const entities =
|
435
|
+
await this.editorStore.graphManagerState.graphManager.buildDatabase(
|
436
|
+
input,
|
437
|
+
);
|
438
|
+
const graph = this.editorStore.graphManagerState.createNewGraph();
|
439
|
+
await this.editorStore.graphManagerState.graphManager.buildGraph(
|
440
|
+
graph,
|
441
|
+
entities,
|
442
|
+
ActionState.create(),
|
443
|
+
);
|
444
|
+
return getNonNullableEntry(
|
445
|
+
graph.ownDatabases,
|
446
|
+
0,
|
447
|
+
'Expected one database to be generated from input',
|
448
|
+
);
|
449
|
+
}
|
450
|
+
|
451
|
+
*executeRawSQL(): GeneratorFn<void> {
|
452
|
+
if (!this.connection || this.isExecutingRawSQL) {
|
453
|
+
return;
|
454
|
+
}
|
455
|
+
|
456
|
+
try {
|
457
|
+
this.isExecutingRawSQL = true;
|
458
|
+
|
459
|
+
let sql = this.sqlText;
|
460
|
+
const currentSelection = this.sqlEditor?.getSelection();
|
461
|
+
if (currentSelection) {
|
462
|
+
const selectionValue =
|
463
|
+
this.sqlEditorTextModel.getValueInRange(currentSelection);
|
464
|
+
if (selectionValue.trim() !== '') {
|
465
|
+
sql = selectionValue;
|
466
|
+
}
|
467
|
+
}
|
468
|
+
|
469
|
+
this.sqlExecutionResult =
|
470
|
+
(yield this.editorStore.graphManagerState.graphManager.executeRawSQL(
|
471
|
+
guaranteeRelationalDatabaseConnection(this.connection),
|
472
|
+
sql,
|
473
|
+
)) as string;
|
474
|
+
} catch (error) {
|
475
|
+
assertErrorThrown(error);
|
476
|
+
this.editorStore.applicationStore.logService.error(
|
477
|
+
LogEvent.create(GRAPH_MANAGER_EVENT.EXECUTION_FAILURE),
|
478
|
+
error,
|
479
|
+
);
|
480
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
481
|
+
} finally {
|
482
|
+
this.isExecutingRawSQL = false;
|
483
|
+
}
|
484
|
+
}
|
485
|
+
}
|
@@ -45,6 +45,8 @@ import {
|
|
45
45
|
observe_EmbeddedData,
|
46
46
|
observe_PostValidation,
|
47
47
|
observe_PostValidationAssertion,
|
48
|
+
TestData,
|
49
|
+
observe_TestData,
|
48
50
|
} from '@finos/legend-graph';
|
49
51
|
import { addUniqueEntry, deleteEntry, uuid } from '@finos/legend-shared';
|
50
52
|
import { action } from 'mobx';
|
@@ -55,6 +57,9 @@ export const service_addConnectionTestData = action(
|
|
55
57
|
val: ConnectionTestData,
|
56
58
|
observerContext: ObserverContext,
|
57
59
|
): void => {
|
60
|
+
if (!suite.testData) {
|
61
|
+
suite.testData = observe_TestData(new TestData(), observerContext);
|
62
|
+
}
|
58
63
|
addUniqueEntry(
|
59
64
|
suite.testData.connectionsTestData,
|
60
65
|
observe_ConnectionTestData(val, observerContext),
|
@@ -63,7 +68,14 @@ export const service_addConnectionTestData = action(
|
|
63
68
|
);
|
64
69
|
|
65
70
|
export const service_setConnectionTestData = action(
|
66
|
-
(
|
71
|
+
(
|
72
|
+
suite: ServiceTestSuite,
|
73
|
+
val: ConnectionTestData[],
|
74
|
+
observerContext: ObserverContext,
|
75
|
+
): void => {
|
76
|
+
if (!suite.testData) {
|
77
|
+
suite.testData = observe_TestData(new TestData(), observerContext);
|
78
|
+
}
|
67
79
|
suite.testData.connectionsTestData = val;
|
68
80
|
},
|
69
81
|
);
|
package/tsconfig.json
CHANGED
@@ -46,6 +46,7 @@
|
|
46
46
|
"./src/__lib__/LegendStudioSetting.ts",
|
47
47
|
"./src/__lib__/LegendStudioTelemetryHelper.ts",
|
48
48
|
"./src/__lib__/LegendStudioTesting.ts",
|
49
|
+
"./src/__lib__/STO_Relational_LegendStudioCommand.ts",
|
49
50
|
"./src/application/LegendStudioApplicationConfig.ts",
|
50
51
|
"./src/application/LegendStudioPluginManager.ts",
|
51
52
|
"./src/components/__test-utils__/EmbeddedQueryBuilderTestUtils.ts",
|
@@ -67,6 +68,7 @@
|
|
67
68
|
"./src/stores/editor/GraphEditGrammarModeState.ts",
|
68
69
|
"./src/stores/editor/GraphEditorMode.ts",
|
69
70
|
"./src/stores/editor/NewElementState.ts",
|
71
|
+
"./src/stores/editor/QuickInputState.ts",
|
70
72
|
"./src/stores/editor/StandardEditorMode.ts",
|
71
73
|
"./src/stores/editor/__test-utils__/EditorStoreTestUtils.ts",
|
72
74
|
"./src/stores/editor/editor-state/EditorState.ts",
|
@@ -126,6 +128,7 @@
|
|
126
128
|
"./src/stores/editor/editor-state/project-configuration-editor-state/ProjectConfigurationEditorState.ts",
|
127
129
|
"./src/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.ts",
|
128
130
|
"./src/stores/editor/panel-group/DevToolPanelState.ts",
|
131
|
+
"./src/stores/editor/panel-group/SQLPlaygroundPanelState.ts",
|
129
132
|
"./src/stores/editor/sidebar-state/BulkServiceRegistrationState.ts",
|
130
133
|
"./src/stores/editor/sidebar-state/LocalChangesState.ts",
|
131
134
|
"./src/stores/editor/sidebar-state/ProjectOverviewState.ts",
|
@@ -173,6 +176,7 @@
|
|
173
176
|
"./src/components/editor/ActivityBar.tsx",
|
174
177
|
"./src/components/editor/Editor.tsx",
|
175
178
|
"./src/components/editor/EditorStoreProvider.tsx",
|
179
|
+
"./src/components/editor/QuickInput.tsx",
|
176
180
|
"./src/components/editor/StatusBar.tsx",
|
177
181
|
"./src/components/editor/__test-utils__/EditorComponentTestUtils.tsx",
|
178
182
|
"./src/components/editor/command-center/ProjectSearchCommand.tsx",
|
@@ -253,6 +257,7 @@
|
|
253
257
|
"./src/components/editor/panel-group/DevToolPanel.tsx",
|
254
258
|
"./src/components/editor/panel-group/PanelGroup.tsx",
|
255
259
|
"./src/components/editor/panel-group/ProblemsPanel.tsx",
|
260
|
+
"./src/components/editor/panel-group/SQLPlaygroundPanel.tsx",
|
256
261
|
"./src/components/editor/side-bar/CreateNewElementModal.tsx",
|
257
262
|
"./src/components/editor/side-bar/Explorer.tsx",
|
258
263
|
"./src/components/editor/side-bar/LocalChanges.tsx",
|