@finos/legend-application-studio 27.1.0 → 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.
- package/lib/__lib__/LegendStudioEvent.d.ts +1 -0
- package/lib/__lib__/LegendStudioEvent.d.ts.map +1 -1
- package/lib/__lib__/LegendStudioEvent.js +1 -0
- package/lib/__lib__/LegendStudioEvent.js.map +1 -1
- package/lib/components/editor/editor-group/FunctionEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/FunctionEditor.js +28 -24
- package/lib/components/editor/editor-group/FunctionEditor.js.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/{DatabaseBuilder.d.ts → DatabaseBuilderWizard.d.ts} +4 -11
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.d.ts.map +1 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js +48 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js.map +1 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.d.ts +32 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.d.ts.map +1 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.js +99 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.js.map +1 -0
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js +1 -1
- package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js +5 -4
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js.map +1 -1
- package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js +62 -12
- package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js +101 -137
- package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js.map +1 -1
- package/lib/components/editor/editor-group/testable/TestableSharedComponents.d.ts +11 -0
- package/lib/components/editor/editor-group/testable/TestableSharedComponents.d.ts.map +1 -1
- package/lib/components/editor/editor-group/testable/TestableSharedComponents.js +27 -2
- package/lib/components/editor/editor-group/testable/TestableSharedComponents.js.map +1 -1
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts +0 -7
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts.map +1 -1
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.js +20 -77
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.js.map +1 -1
- package/lib/components/editor/side-bar/Explorer.js +3 -3
- package/lib/components/editor/side-bar/Explorer.js.map +1 -1
- package/lib/components/editor/side-bar/WorkflowManager.d.ts.map +1 -1
- package/lib/components/editor/side-bar/WorkflowManager.js +6 -1
- package/lib/components/editor/side-bar/WorkflowManager.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +3 -3
- package/lib/stores/editor/ExplorerTreeState.d.ts +4 -4
- package/lib/stores/editor/ExplorerTreeState.d.ts.map +1 -1
- package/lib/stores/editor/ExplorerTreeState.js +4 -4
- package/lib/stores/editor/ExplorerTreeState.js.map +1 -1
- package/lib/stores/editor/NewElementState.d.ts.map +1 -1
- package/lib/stores/editor/NewElementState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts +12 -12
- 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 +45 -46
- package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts +20 -29
- 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 +60 -141
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts +33 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js +71 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.d.ts +2 -2
- package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.js +2 -2
- package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts +14 -19
- package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.js +30 -65
- package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts +56 -78
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js +285 -384
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.d.ts +23 -0
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.d.ts.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.js +129 -0
- package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.js.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js +2 -2
- package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts +1 -0
- 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 +12 -2
- 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.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js +15 -8
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts +7 -4
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js +53 -10
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts +2 -1
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js +20 -16
- package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js.map +1 -1
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts +3 -48
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts.map +1 -1
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js +12 -350
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js.map +1 -1
- package/lib/stores/editor/sidebar-state/WorkflowManagerState.d.ts +5 -0
- package/lib/stores/editor/sidebar-state/WorkflowManagerState.d.ts.map +1 -1
- package/lib/stores/editor/sidebar-state/WorkflowManagerState.js +26 -0
- package/lib/stores/editor/sidebar-state/WorkflowManagerState.js.map +1 -1
- package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.d.ts +1 -1
- package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.d.ts.map +1 -1
- package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.js +3 -0
- package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.js.map +1 -1
- package/lib/stores/editor/utils/MockDataUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/MockDataUtils.js +3 -0
- package/lib/stores/editor/utils/MockDataUtils.js.map +1 -1
- package/lib/stores/editor/utils/TestableUtils.d.ts +11 -1
- package/lib/stores/editor/utils/TestableUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/TestableUtils.js +50 -1
- package/lib/stores/editor/utils/TestableUtils.js.map +1 -1
- package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.d.ts +5 -4
- package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.d.ts.map +1 -1
- package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js +4 -1
- package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js.map +1 -1
- package/package.json +9 -9
- package/src/__lib__/LegendStudioEvent.ts +1 -1
- package/src/components/editor/editor-group/FunctionEditor.tsx +133 -118
- package/src/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.tsx +191 -0
- package/src/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.tsx +227 -0
- package/src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx +1 -1
- package/src/components/editor/editor-group/data-editor/EmbeddedDataEditor.tsx +34 -37
- package/src/components/editor/editor-group/data-editor/RelationalCSVDataEditor.tsx +134 -31
- package/src/components/editor/editor-group/mapping-editor/MappingTestableEditor.tsx +296 -414
- package/src/components/editor/editor-group/testable/TestableSharedComponents.tsx +88 -3
- package/src/components/editor/panel-group/SQLPlaygroundPanel.tsx +47 -211
- package/src/components/editor/side-bar/Explorer.tsx +3 -3
- package/src/components/editor/side-bar/WorkflowManager.tsx +10 -0
- package/src/stores/editor/ExplorerTreeState.ts +6 -9
- package/src/stores/editor/NewElementState.ts +0 -1
- package/src/stores/editor/editor-state/element-editor-state/FunctionEditorState.ts +44 -50
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts +88 -212
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.ts +102 -0
- package/src/stores/editor/editor-state/element-editor-state/data/DataEditorState.ts +7 -1
- package/src/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.ts +48 -77
- package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.ts +407 -617
- package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.ts +243 -0
- package/src/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.ts +6 -2
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +18 -1
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.ts +20 -12
- package/src/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.ts +76 -18
- package/src/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.ts +29 -24
- package/src/stores/editor/panel-group/SQLPlaygroundPanelState.ts +13 -533
- package/src/stores/editor/sidebar-state/WorkflowManagerState.ts +47 -0
- package/src/stores/editor/sidebar-state/testable/GlobalTestRunnerState.ts +4 -1
- package/src/stores/editor/utils/MockDataUtils.ts +2 -0
- package/src/stores/editor/utils/TestableUtils.ts +73 -0
- package/src/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.ts +15 -12
- package/tsconfig.json +4 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.d.ts.map +0 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js +0 -133
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js.map +0 -1
- package/src/components/editor/editor-group/connection-editor/DatabaseBuilder.tsx +0 -397
package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts
CHANGED
@@ -22,22 +22,14 @@ import {
|
|
22
22
|
assertErrorThrown,
|
23
23
|
LogEvent,
|
24
24
|
addUniqueEntry,
|
25
|
-
assertNonEmptyString,
|
26
|
-
assertTrue,
|
27
25
|
guaranteeNonNullable,
|
28
26
|
isNonNullable,
|
29
27
|
filterByType,
|
30
28
|
ActionState,
|
31
29
|
getNonNullableEntry,
|
30
|
+
guaranteeType,
|
32
31
|
} from '@finos/legend-shared';
|
33
|
-
import {
|
34
|
-
observable,
|
35
|
-
action,
|
36
|
-
makeObservable,
|
37
|
-
flow,
|
38
|
-
flowResult,
|
39
|
-
computed,
|
40
|
-
} from 'mobx';
|
32
|
+
import { observable, action, makeObservable, flow, flowResult } from 'mobx';
|
41
33
|
import { LEGEND_STUDIO_APP_EVENT } from '../../../../../__lib__/LegendStudioEvent.js';
|
42
34
|
import type { EditorStore } from '../../../EditorStore.js';
|
43
35
|
import {
|
@@ -47,20 +39,18 @@ import {
|
|
47
39
|
DatabaseBuilderInput,
|
48
40
|
DatabasePattern,
|
49
41
|
TargetDatabase,
|
50
|
-
PackageableElementExplicitReference,
|
51
42
|
Column,
|
52
43
|
Database,
|
53
|
-
isValidFullPath,
|
54
44
|
resolvePackagePathAndElementName,
|
55
|
-
isStubbed_PackageableElement,
|
56
45
|
getSchema,
|
57
46
|
getNullableSchema,
|
58
47
|
getNullableTable,
|
59
48
|
} from '@finos/legend-graph';
|
60
|
-
import { connection_setStore } from '../../../../graph-modifier/DSL_Mapping_GraphModifierHelper.js';
|
61
49
|
import { GraphEditFormModeState } from '../../../GraphEditFormModeState.js';
|
62
50
|
|
63
|
-
export abstract class
|
51
|
+
export abstract class DatabaseSchemaExplorerTreeNodeData
|
52
|
+
implements TreeNodeData
|
53
|
+
{
|
64
54
|
isOpen?: boolean | undefined;
|
65
55
|
id: string;
|
66
56
|
label: string;
|
@@ -84,7 +74,7 @@ export abstract class DatabaseBuilderTreeNodeData implements TreeNodeData {
|
|
84
74
|
}
|
85
75
|
}
|
86
76
|
|
87
|
-
export class
|
77
|
+
export class DatabaseSchemaExplorerTreeSchemaNodeData extends DatabaseSchemaExplorerTreeNodeData {
|
88
78
|
schema: Schema;
|
89
79
|
|
90
80
|
constructor(id: string, schema: Schema) {
|
@@ -93,7 +83,7 @@ export class SchemaDatabaseBuilderTreeNodeData extends DatabaseBuilderTreeNodeDa
|
|
93
83
|
}
|
94
84
|
}
|
95
85
|
|
96
|
-
export class
|
86
|
+
export class DatabaseSchemaExplorerTreeTableNodeData extends DatabaseSchemaExplorerTreeNodeData {
|
97
87
|
override parentId: string;
|
98
88
|
owner: Schema;
|
99
89
|
table: Table;
|
@@ -106,7 +96,7 @@ export class TableDatabaseBuilderTreeNodeData extends DatabaseBuilderTreeNodeDat
|
|
106
96
|
}
|
107
97
|
}
|
108
98
|
|
109
|
-
export class
|
99
|
+
export class DatabaseSchemaExplorerTreeColumnNodeData extends DatabaseSchemaExplorerTreeNodeData {
|
110
100
|
override parentId: string;
|
111
101
|
owner: Table;
|
112
102
|
column: Column;
|
@@ -119,93 +109,57 @@ export class ColumnDatabaseBuilderTreeNodeData extends DatabaseBuilderTreeNodeDa
|
|
119
109
|
}
|
120
110
|
}
|
121
111
|
|
122
|
-
export interface
|
123
|
-
extends TreeData<
|
112
|
+
export interface DatabaseExplorerTreeData
|
113
|
+
extends TreeData<DatabaseSchemaExplorerTreeNodeData> {
|
124
114
|
database: Database;
|
125
115
|
}
|
126
116
|
|
127
|
-
|
128
|
-
|
129
|
-
export class DatabaseBuilderState {
|
117
|
+
export class DatabaseSchemaExplorerState {
|
130
118
|
readonly editorStore: EditorStore;
|
131
119
|
readonly connection: RelationalDatabaseConnection;
|
132
|
-
readonly
|
120
|
+
readonly database: Database;
|
133
121
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
isSavingDatabase = false;
|
138
|
-
targetDatabasePath: string;
|
139
|
-
treeData?: DatabaseBuilderTreeData | undefined;
|
122
|
+
isGeneratingDatabase = false;
|
123
|
+
isUpdatingDatabase = false;
|
124
|
+
treeData?: DatabaseExplorerTreeData | undefined;
|
140
125
|
|
141
126
|
constructor(
|
142
127
|
editorStore: EditorStore,
|
143
128
|
connection: RelationalDatabaseConnection,
|
144
|
-
isReadOnly: boolean,
|
145
129
|
) {
|
146
|
-
makeObservable
|
147
|
-
|
148
|
-
|
149
|
-
databaseGrammarCode: observable,
|
150
|
-
isBuildingDatabase: observable,
|
151
|
-
isSavingDatabase: observable,
|
152
|
-
currentDatabase: computed,
|
153
|
-
setTargetDatabasePath: action,
|
154
|
-
setShowModal: action,
|
155
|
-
setDatabaseGrammarCode: action,
|
156
|
-
setTreeData: action,
|
130
|
+
makeObservable(this, {
|
131
|
+
isGeneratingDatabase: observable,
|
132
|
+
isUpdatingDatabase: observable,
|
157
133
|
treeData: observable,
|
134
|
+
setTreeData: action,
|
158
135
|
onNodeSelect: flow,
|
159
|
-
generateDatabase: flow,
|
160
|
-
previewDatabaseModel: flow,
|
161
|
-
createOrUpdateDatabase: flow,
|
162
136
|
fetchDatabaseMetadata: flow,
|
163
137
|
fetchSchemaMetadata: flow,
|
164
138
|
fetchTableMetadata: flow,
|
139
|
+
generateDatabase: flow,
|
140
|
+
updateDatabase: flow,
|
165
141
|
});
|
166
142
|
|
167
143
|
this.connection = connection;
|
144
|
+
this.database = guaranteeType(connection.store.value, Database);
|
168
145
|
this.editorStore = editorStore;
|
169
|
-
this.targetDatabasePath =
|
170
|
-
this.currentDatabase?.path ?? DEFAULT_DATABASE_PATH;
|
171
|
-
this.isReadOnly = isReadOnly;
|
172
146
|
}
|
173
147
|
|
174
|
-
|
175
|
-
const store = this.connection.store.value;
|
176
|
-
if (store instanceof Database && !isStubbed_PackageableElement(store)) {
|
177
|
-
return store;
|
178
|
-
}
|
179
|
-
return undefined;
|
180
|
-
}
|
181
|
-
|
182
|
-
setShowModal(val: boolean): void {
|
183
|
-
this.showModal = val;
|
184
|
-
}
|
185
|
-
|
186
|
-
setTreeData(builderTreeData?: DatabaseBuilderTreeData): void {
|
148
|
+
setTreeData(builderTreeData?: DatabaseExplorerTreeData): void {
|
187
149
|
this.treeData = builderTreeData;
|
188
150
|
}
|
189
151
|
|
190
|
-
setDatabaseGrammarCode(val: string): void {
|
191
|
-
this.databaseGrammarCode = val;
|
192
|
-
}
|
193
|
-
|
194
|
-
setTargetDatabasePath(val: string): void {
|
195
|
-
this.targetDatabasePath = val;
|
196
|
-
}
|
197
|
-
|
198
152
|
*onNodeSelect(
|
199
|
-
node:
|
200
|
-
treeData:
|
153
|
+
node: DatabaseSchemaExplorerTreeNodeData,
|
154
|
+
treeData: DatabaseExplorerTreeData,
|
201
155
|
): GeneratorFn<void> {
|
202
156
|
if (
|
203
|
-
node instanceof
|
157
|
+
node instanceof DatabaseSchemaExplorerTreeSchemaNodeData &&
|
204
158
|
!node.childrenIds
|
205
159
|
) {
|
206
160
|
yield flowResult(this.fetchSchemaMetadata(node, treeData));
|
207
161
|
} else if (
|
208
|
-
node instanceof
|
162
|
+
node instanceof DatabaseSchemaExplorerTreeTableNodeData &&
|
209
163
|
!node.childrenIds
|
210
164
|
) {
|
211
165
|
yield flowResult(this.fetchTableMetadata(node, treeData));
|
@@ -215,24 +169,24 @@ export class DatabaseBuilderState {
|
|
215
169
|
}
|
216
170
|
|
217
171
|
getChildNodes(
|
218
|
-
node:
|
219
|
-
treeData:
|
220
|
-
):
|
172
|
+
node: DatabaseSchemaExplorerTreeNodeData,
|
173
|
+
treeData: DatabaseExplorerTreeData,
|
174
|
+
): DatabaseSchemaExplorerTreeNodeData[] | undefined {
|
221
175
|
return node.childrenIds
|
222
176
|
?.map((childNode) => treeData.nodes.get(childNode))
|
223
177
|
.filter(isNonNullable);
|
224
178
|
}
|
225
179
|
|
226
180
|
toggleCheckedNode(
|
227
|
-
node:
|
228
|
-
treeData:
|
181
|
+
node: DatabaseSchemaExplorerTreeNodeData,
|
182
|
+
treeData: DatabaseExplorerTreeData,
|
229
183
|
): void {
|
230
184
|
node.setChecked(!node.isChecked);
|
231
|
-
if (node instanceof
|
185
|
+
if (node instanceof DatabaseSchemaExplorerTreeSchemaNodeData) {
|
232
186
|
this.getChildNodes(node, treeData)?.forEach((childNode) => {
|
233
187
|
childNode.setChecked(node.isChecked);
|
234
188
|
});
|
235
|
-
} else if (node instanceof
|
189
|
+
} else if (node instanceof DatabaseSchemaExplorerTreeTableNodeData) {
|
236
190
|
if (node.parentId) {
|
237
191
|
const parent = treeData.nodes.get(node.parentId);
|
238
192
|
if (
|
@@ -252,12 +206,11 @@ export class DatabaseBuilderState {
|
|
252
206
|
|
253
207
|
*fetchDatabaseMetadata(): GeneratorFn<void> {
|
254
208
|
try {
|
255
|
-
this.
|
209
|
+
this.isGeneratingDatabase = true;
|
256
210
|
const databaseBuilderInput = new DatabaseBuilderInput(this.connection);
|
257
|
-
const [packagePath, databaseName] = this.getDatabasePackageAndName();
|
258
211
|
databaseBuilderInput.targetDatabase = new TargetDatabase(
|
259
|
-
|
260
|
-
|
212
|
+
guaranteeNonNullable(this.database.package).path,
|
213
|
+
this.database.name,
|
261
214
|
);
|
262
215
|
databaseBuilderInput.config.maxTables = undefined;
|
263
216
|
databaseBuilderInput.config.enrichTables = false;
|
@@ -269,14 +222,14 @@ export class DatabaseBuilderState {
|
|
269
222
|
)) as Database;
|
270
223
|
|
271
224
|
const rootIds: string[] = [];
|
272
|
-
const nodes = new Map<string,
|
225
|
+
const nodes = new Map<string, DatabaseSchemaExplorerTreeNodeData>();
|
273
226
|
database.schemas
|
274
227
|
.slice()
|
275
228
|
.sort((schemaA, schemaB) => schemaA.name.localeCompare(schemaB.name))
|
276
229
|
.forEach((schema) => {
|
277
230
|
const schemaId = schema.name;
|
278
231
|
rootIds.push(schemaId);
|
279
|
-
const schemaNode = new
|
232
|
+
const schemaNode = new DatabaseSchemaExplorerTreeSchemaNodeData(
|
280
233
|
schemaId,
|
281
234
|
schema,
|
282
235
|
);
|
@@ -284,7 +237,7 @@ export class DatabaseBuilderState {
|
|
284
237
|
|
285
238
|
schemaNode.setChecked(
|
286
239
|
Boolean(
|
287
|
-
this.
|
240
|
+
this.database.schemas.find(
|
288
241
|
(cSchema) => cSchema.name === schema.name,
|
289
242
|
),
|
290
243
|
),
|
@@ -300,23 +253,22 @@ export class DatabaseBuilderState {
|
|
300
253
|
);
|
301
254
|
this.editorStore.applicationStore.notificationService.notifyError(error);
|
302
255
|
} finally {
|
303
|
-
this.
|
256
|
+
this.isGeneratingDatabase = false;
|
304
257
|
}
|
305
258
|
}
|
306
259
|
|
307
260
|
*fetchSchemaMetadata(
|
308
|
-
schemaNode:
|
309
|
-
treeData:
|
261
|
+
schemaNode: DatabaseSchemaExplorerTreeSchemaNodeData,
|
262
|
+
treeData: DatabaseExplorerTreeData,
|
310
263
|
): GeneratorFn<void> {
|
311
264
|
try {
|
312
|
-
this.
|
265
|
+
this.isGeneratingDatabase = true;
|
313
266
|
|
314
267
|
const schema = schemaNode.schema;
|
315
268
|
const databaseBuilderInput = new DatabaseBuilderInput(this.connection);
|
316
|
-
const [packagePath, databaseName] = this.getDatabasePackageAndName();
|
317
269
|
databaseBuilderInput.targetDatabase = new TargetDatabase(
|
318
|
-
|
319
|
-
|
270
|
+
guaranteeNonNullable(this.database.package).path,
|
271
|
+
this.database.name,
|
320
272
|
);
|
321
273
|
databaseBuilderInput.config.maxTables = undefined;
|
322
274
|
databaseBuilderInput.config.enrichTables = true;
|
@@ -336,7 +288,7 @@ export class DatabaseBuilderState {
|
|
336
288
|
.forEach((table) => {
|
337
289
|
table.schema = schema;
|
338
290
|
const tableId = `${schema.name}.${table.name}`;
|
339
|
-
const tableNode = new
|
291
|
+
const tableNode = new DatabaseSchemaExplorerTreeTableNodeData(
|
340
292
|
tableId,
|
341
293
|
schemaNode.id,
|
342
294
|
schema,
|
@@ -345,21 +297,14 @@ export class DatabaseBuilderState {
|
|
345
297
|
treeData.nodes.set(tableId, tableNode);
|
346
298
|
addUniqueEntry(childrenIds, tableId);
|
347
299
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
? getNullableTable(matchingSchema, table.name)
|
357
|
-
: undefined,
|
358
|
-
),
|
359
|
-
);
|
360
|
-
} else {
|
361
|
-
tableNode.setChecked(false);
|
362
|
-
}
|
300
|
+
const matchingSchema = getNullableSchema(this.database, schema.name);
|
301
|
+
tableNode.setChecked(
|
302
|
+
Boolean(
|
303
|
+
matchingSchema
|
304
|
+
? getNullableTable(matchingSchema, table.name)
|
305
|
+
: undefined,
|
306
|
+
),
|
307
|
+
);
|
363
308
|
});
|
364
309
|
schemaNode.childrenIds = childrenIds;
|
365
310
|
this.setTreeData({ ...treeData });
|
@@ -371,24 +316,24 @@ export class DatabaseBuilderState {
|
|
371
316
|
);
|
372
317
|
this.editorStore.applicationStore.notificationService.notifyError(error);
|
373
318
|
} finally {
|
374
|
-
this.
|
319
|
+
this.isGeneratingDatabase = false;
|
375
320
|
}
|
376
321
|
}
|
377
322
|
|
378
323
|
*fetchTableMetadata(
|
379
|
-
tableNode:
|
380
|
-
treeData:
|
324
|
+
tableNode: DatabaseSchemaExplorerTreeTableNodeData,
|
325
|
+
treeData: DatabaseExplorerTreeData,
|
381
326
|
): GeneratorFn<void> {
|
382
327
|
try {
|
383
|
-
this.
|
328
|
+
this.isGeneratingDatabase = true;
|
384
329
|
|
385
330
|
const databaseBuilderInput = new DatabaseBuilderInput(this.connection);
|
386
|
-
const [packagePath,
|
387
|
-
this.
|
331
|
+
const [packagePath, name] = resolvePackagePathAndElementName(
|
332
|
+
this.database.path,
|
388
333
|
);
|
389
334
|
databaseBuilderInput.targetDatabase = new TargetDatabase(
|
390
335
|
packagePath,
|
391
|
-
|
336
|
+
name,
|
392
337
|
);
|
393
338
|
const table = tableNode.table;
|
394
339
|
const config = databaseBuilderInput.config;
|
@@ -419,7 +364,7 @@ export class DatabaseBuilderState {
|
|
419
364
|
.sort((colA, colB) => colA.name.localeCompare(colB.name))
|
420
365
|
.forEach((column) => {
|
421
366
|
const columnId = `${tableId}.${column.name}`;
|
422
|
-
const columnNode = new
|
367
|
+
const columnNode = new DatabaseSchemaExplorerTreeColumnNodeData(
|
423
368
|
columnId,
|
424
369
|
tableId,
|
425
370
|
table,
|
@@ -439,29 +384,11 @@ export class DatabaseBuilderState {
|
|
439
384
|
);
|
440
385
|
this.editorStore.applicationStore.notificationService.notifyError(error);
|
441
386
|
} finally {
|
442
|
-
this.
|
387
|
+
this.isGeneratingDatabase = false;
|
443
388
|
}
|
444
389
|
}
|
445
390
|
|
446
|
-
private
|
447
|
-
if (this.currentDatabase) {
|
448
|
-
return [
|
449
|
-
guaranteeNonNullable(this.currentDatabase.package).path,
|
450
|
-
this.currentDatabase.name,
|
451
|
-
];
|
452
|
-
}
|
453
|
-
assertNonEmptyString(this.targetDatabasePath, 'Must specify database path');
|
454
|
-
assertTrue(
|
455
|
-
isValidFullPath(this.targetDatabasePath),
|
456
|
-
'Invalid database path',
|
457
|
-
);
|
458
|
-
return resolvePackagePathAndElementName(
|
459
|
-
this.targetDatabasePath,
|
460
|
-
this.targetDatabasePath,
|
461
|
-
);
|
462
|
-
}
|
463
|
-
|
464
|
-
async buildIntermediateDatabase(
|
391
|
+
private async buildIntermediateDatabase(
|
465
392
|
databaseBuilderInput: DatabaseBuilderInput,
|
466
393
|
): Promise<Database> {
|
467
394
|
const entities =
|
@@ -483,14 +410,13 @@ export class DatabaseBuilderState {
|
|
483
410
|
|
484
411
|
*generateDatabase(): GeneratorFn<Entity> {
|
485
412
|
try {
|
486
|
-
this.
|
413
|
+
this.isGeneratingDatabase = true;
|
487
414
|
|
488
415
|
const treeData = guaranteeNonNullable(this.treeData);
|
489
416
|
const databaseBuilderInput = new DatabaseBuilderInput(this.connection);
|
490
|
-
const [packagePath, databaseName] = this.getDatabasePackageAndName();
|
491
417
|
databaseBuilderInput.targetDatabase = new TargetDatabase(
|
492
|
-
|
493
|
-
|
418
|
+
guaranteeNonNullable(this.database.package).path,
|
419
|
+
this.database.name,
|
494
420
|
);
|
495
421
|
const config = databaseBuilderInput.config;
|
496
422
|
config.maxTables = undefined;
|
@@ -501,7 +427,7 @@ export class DatabaseBuilderState {
|
|
501
427
|
.map((e) => treeData.nodes.get(e))
|
502
428
|
.filter(isNonNullable)
|
503
429
|
.forEach((schemaNode) => {
|
504
|
-
if (schemaNode instanceof
|
430
|
+
if (schemaNode instanceof DatabaseSchemaExplorerTreeSchemaNodeData) {
|
505
431
|
const tableNodes = this.getChildNodes(schemaNode, treeData);
|
506
432
|
const allChecked = tableNodes?.every((t) => t.isChecked === true);
|
507
433
|
if (
|
@@ -514,7 +440,7 @@ export class DatabaseBuilderState {
|
|
514
440
|
} else {
|
515
441
|
tableNodes?.forEach((t) => {
|
516
442
|
if (
|
517
|
-
t instanceof
|
443
|
+
t instanceof DatabaseSchemaExplorerTreeTableNodeData &&
|
518
444
|
t.isChecked
|
519
445
|
) {
|
520
446
|
config.patterns.push(
|
@@ -535,40 +461,17 @@ export class DatabaseBuilderState {
|
|
535
461
|
'Expected a database to be generated',
|
536
462
|
);
|
537
463
|
} finally {
|
538
|
-
this.
|
539
|
-
}
|
540
|
-
}
|
541
|
-
|
542
|
-
*previewDatabaseModel(): GeneratorFn<void> {
|
543
|
-
if (!this.treeData) {
|
544
|
-
return;
|
545
|
-
}
|
546
|
-
|
547
|
-
try {
|
548
|
-
this.setDatabaseGrammarCode(
|
549
|
-
(yield this.editorStore.graphManagerState.graphManager.entitiesToPureCode(
|
550
|
-
[(yield flowResult(this.generateDatabase())) as Entity],
|
551
|
-
)) as string,
|
552
|
-
);
|
553
|
-
} catch (error) {
|
554
|
-
assertErrorThrown(error);
|
555
|
-
this.editorStore.applicationStore.logService.error(
|
556
|
-
LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_BUILDER_FAILURE),
|
557
|
-
error,
|
558
|
-
);
|
559
|
-
this.editorStore.applicationStore.notificationService.notifyError(error);
|
560
|
-
} finally {
|
561
|
-
this.isBuildingDatabase = false;
|
464
|
+
this.isGeneratingDatabase = false;
|
562
465
|
}
|
563
466
|
}
|
564
467
|
|
565
|
-
*
|
468
|
+
*updateDatabase(): GeneratorFn<void> {
|
566
469
|
if (!this.treeData) {
|
567
470
|
return;
|
568
471
|
}
|
569
472
|
|
570
473
|
try {
|
571
|
-
this.
|
474
|
+
this.isUpdatingDatabase = true;
|
572
475
|
|
573
476
|
const graph = this.editorStore.graphManagerState.createNewGraph();
|
574
477
|
(yield this.editorStore.graphManagerState.graphManager.buildGraph(
|
@@ -582,40 +485,16 @@ export class DatabaseBuilderState {
|
|
582
485
|
'Expected one database to be generated from input',
|
583
486
|
);
|
584
487
|
|
585
|
-
let currentDatabase: Database;
|
586
|
-
const isUpdating = Boolean(this.currentDatabase);
|
587
|
-
if (!this.currentDatabase) {
|
588
|
-
const newDatabase = new Database(database.name);
|
589
|
-
connection_setStore(
|
590
|
-
this.connection,
|
591
|
-
PackageableElementExplicitReference.create(newDatabase),
|
592
|
-
);
|
593
|
-
const packagePath = guaranteeNonNullable(
|
594
|
-
database.package?.name,
|
595
|
-
'Database package is missing',
|
596
|
-
);
|
597
|
-
yield flowResult(
|
598
|
-
this.editorStore.graphEditorMode.addElement(
|
599
|
-
newDatabase,
|
600
|
-
packagePath,
|
601
|
-
false,
|
602
|
-
),
|
603
|
-
);
|
604
|
-
currentDatabase = newDatabase;
|
605
|
-
} else {
|
606
|
-
currentDatabase = this.currentDatabase;
|
607
|
-
}
|
608
|
-
|
609
488
|
// remove undefined schemas
|
610
489
|
const schemas = Array.from(this.treeData.nodes.values())
|
611
490
|
.map((schemaNode) => {
|
612
|
-
if (schemaNode instanceof
|
491
|
+
if (schemaNode instanceof DatabaseSchemaExplorerTreeSchemaNodeData) {
|
613
492
|
return schemaNode.schema;
|
614
493
|
}
|
615
494
|
return undefined;
|
616
495
|
})
|
617
496
|
.filter(isNonNullable);
|
618
|
-
|
497
|
+
this.database.schemas = this.database.schemas.filter((schema) => {
|
619
498
|
if (
|
620
499
|
schemas.find((item) => item.name === schema.name) &&
|
621
500
|
!database.schemas.find((s) => s.name === schema.name)
|
@@ -627,30 +506,27 @@ export class DatabaseBuilderState {
|
|
627
506
|
|
628
507
|
// update existing schemas
|
629
508
|
database.schemas.forEach((schema) => {
|
630
|
-
(schema as Writable<Schema>)._OWNER =
|
631
|
-
const currentSchemaIndex =
|
509
|
+
(schema as Writable<Schema>)._OWNER = this.database;
|
510
|
+
const currentSchemaIndex = this.database.schemas.findIndex(
|
632
511
|
(item) => item.name === schema.name,
|
633
512
|
);
|
634
513
|
if (currentSchemaIndex !== -1) {
|
635
|
-
|
514
|
+
this.database.schemas[currentSchemaIndex] = schema;
|
636
515
|
} else {
|
637
|
-
|
516
|
+
this.database.schemas.push(schema);
|
638
517
|
}
|
639
518
|
});
|
640
519
|
|
641
520
|
this.editorStore.applicationStore.notificationService.notifySuccess(
|
642
|
-
`Database successfully
|
521
|
+
`Database successfully updated`,
|
522
|
+
);
|
523
|
+
yield flowResult(
|
524
|
+
this.editorStore
|
525
|
+
.getGraphEditorMode(GraphEditFormModeState)
|
526
|
+
.globalCompile({
|
527
|
+
message: `Can't compile graph after editing database. Redirecting you to text mode`,
|
528
|
+
}),
|
643
529
|
);
|
644
|
-
if (isUpdating) {
|
645
|
-
yield flowResult(
|
646
|
-
this.editorStore
|
647
|
-
.getGraphEditorMode(GraphEditFormModeState)
|
648
|
-
.globalCompile({
|
649
|
-
message: `Can't compile graph after editing database. Redirecting you to text mode`,
|
650
|
-
}),
|
651
|
-
);
|
652
|
-
}
|
653
|
-
this.setShowModal(false);
|
654
530
|
} catch (error) {
|
655
531
|
assertErrorThrown(error);
|
656
532
|
this.editorStore.applicationStore.logService.error(
|
@@ -659,7 +535,7 @@ export class DatabaseBuilderState {
|
|
659
535
|
);
|
660
536
|
this.editorStore.applicationStore.notificationService.notifyError(error);
|
661
537
|
} finally {
|
662
|
-
this.
|
538
|
+
this.isUpdatingDatabase = false;
|
663
539
|
}
|
664
540
|
}
|
665
541
|
}
|
package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.ts
ADDED
@@ -0,0 +1,102 @@
|
|
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 { Entity } from '@finos/legend-storage';
|
18
|
+
import {
|
19
|
+
type GeneratorFn,
|
20
|
+
assertErrorThrown,
|
21
|
+
LogEvent,
|
22
|
+
} from '@finos/legend-shared';
|
23
|
+
import { observable, action, makeObservable, flow, flowResult } from 'mobx';
|
24
|
+
import { LEGEND_STUDIO_APP_EVENT } from '../../../../../__lib__/LegendStudioEvent.js';
|
25
|
+
import type { EditorStore } from '../../../EditorStore.js';
|
26
|
+
import { type RelationalDatabaseConnection } from '@finos/legend-graph';
|
27
|
+
import { DatabaseSchemaExplorerState } from './DatabaseBuilderState.js';
|
28
|
+
|
29
|
+
export class DatabaseBuilderWizardState {
|
30
|
+
readonly editorStore: EditorStore;
|
31
|
+
readonly connection: RelationalDatabaseConnection;
|
32
|
+
readonly schemaExplorerState: DatabaseSchemaExplorerState;
|
33
|
+
readonly isReadOnly: boolean;
|
34
|
+
|
35
|
+
showModal = false;
|
36
|
+
databaseGrammarCode = '';
|
37
|
+
|
38
|
+
constructor(
|
39
|
+
editorStore: EditorStore,
|
40
|
+
connection: RelationalDatabaseConnection,
|
41
|
+
isReadOnly: boolean,
|
42
|
+
) {
|
43
|
+
makeObservable(this, {
|
44
|
+
showModal: observable,
|
45
|
+
databaseGrammarCode: observable,
|
46
|
+
setShowModal: action,
|
47
|
+
setDatabaseGrammarCode: action,
|
48
|
+
previewDatabaseModel: flow,
|
49
|
+
updateDatabase: flow,
|
50
|
+
});
|
51
|
+
|
52
|
+
this.editorStore = editorStore;
|
53
|
+
this.connection = connection;
|
54
|
+
this.schemaExplorerState = new DatabaseSchemaExplorerState(
|
55
|
+
editorStore,
|
56
|
+
connection,
|
57
|
+
);
|
58
|
+
this.isReadOnly = isReadOnly;
|
59
|
+
}
|
60
|
+
|
61
|
+
setShowModal(val: boolean): void {
|
62
|
+
this.showModal = val;
|
63
|
+
}
|
64
|
+
|
65
|
+
setDatabaseGrammarCode(val: string): void {
|
66
|
+
this.databaseGrammarCode = val;
|
67
|
+
}
|
68
|
+
|
69
|
+
*previewDatabaseModel(): GeneratorFn<void> {
|
70
|
+
if (!this.schemaExplorerState.treeData) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
|
74
|
+
try {
|
75
|
+
this.setDatabaseGrammarCode(
|
76
|
+
(yield this.editorStore.graphManagerState.graphManager.entitiesToPureCode(
|
77
|
+
[
|
78
|
+
(yield flowResult(
|
79
|
+
this.schemaExplorerState.generateDatabase(),
|
80
|
+
)) as Entity,
|
81
|
+
],
|
82
|
+
)) as string,
|
83
|
+
);
|
84
|
+
} catch (error) {
|
85
|
+
assertErrorThrown(error);
|
86
|
+
this.editorStore.applicationStore.logService.error(
|
87
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_BUILDER_FAILURE),
|
88
|
+
error,
|
89
|
+
);
|
90
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
*updateDatabase(): GeneratorFn<void> {
|
95
|
+
if (!this.schemaExplorerState.treeData) {
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
|
99
|
+
yield flowResult(this.schemaExplorerState.updateDatabase());
|
100
|
+
this.setShowModal(false);
|
101
|
+
}
|
102
|
+
}
|