@finos/legend-application-studio 28.1.1 → 28.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 +1 -0
- 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__/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/connection-editor/DatabaseBuilderWizard.d.ts.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js +16 -2
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseModelBuilder.d.ts +23 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseModelBuilder.d.ts.map +1 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseModelBuilder.js +45 -0
- package/lib/components/editor/editor-group/connection-editor/DatabaseModelBuilder.js.map +1 -0
- package/lib/components/editor/side-bar/Explorer.d.ts.map +1 -1
- package/lib/components/editor/side-bar/Explorer.js +10 -10
- package/lib/components/editor/side-bar/Explorer.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/editor/ExplorerTreeState.d.ts +6 -3
- package/lib/stores/editor/ExplorerTreeState.d.ts.map +1 -1
- package/lib/stores/editor/ExplorerTreeState.js +13 -31
- package/lib/stores/editor/ExplorerTreeState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts +4 -0
- 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 +42 -7
- 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 +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js +0 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.d.ts +37 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.d.ts.map +1 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.js +111 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.js.map +1 -0
- package/package.json +2 -2
- package/src/__lib__/LegendStudioApplicationNavigationContext.ts +1 -0
- package/src/__lib__/LegendStudioEvent.ts +1 -0
- package/src/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.tsx +29 -5
- package/src/components/editor/editor-group/connection-editor/DatabaseModelBuilder.tsx +158 -0
- package/src/components/editor/side-bar/Explorer.tsx +24 -20
- package/src/stores/editor/ExplorerTreeState.ts +19 -50
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts +80 -12
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.ts +1 -2
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.ts +156 -0
- package/tsconfig.json +2 -0
package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
guaranteeNonNullable,
|
|
23
|
+
ActionState,
|
|
24
|
+
} from '@finos/legend-shared';
|
|
25
|
+
import { observable, action, makeObservable, flow, flowResult } from 'mobx';
|
|
26
|
+
import { LEGEND_STUDIO_APP_EVENT } from '../../../../../__lib__/LegendStudioEvent.js';
|
|
27
|
+
import type { EditorStore } from '../../../EditorStore.js';
|
|
28
|
+
import type { Database } from '@finos/legend-graph';
|
|
29
|
+
import { EntityChangeType, type EntityChange } from '@finos/legend-server-sdlc';
|
|
30
|
+
|
|
31
|
+
export class DatabaseModelBuilderState {
|
|
32
|
+
readonly editorStore: EditorStore;
|
|
33
|
+
readonly database: Database;
|
|
34
|
+
readonly isReadOnly: boolean;
|
|
35
|
+
generatingModelState = ActionState.create();
|
|
36
|
+
saveModelState = ActionState.create();
|
|
37
|
+
|
|
38
|
+
showModal = false;
|
|
39
|
+
generatedGrammarCode = '';
|
|
40
|
+
entities: Entity[] | undefined;
|
|
41
|
+
|
|
42
|
+
constructor(
|
|
43
|
+
editorStore: EditorStore,
|
|
44
|
+
database: Database,
|
|
45
|
+
isReadOnly: boolean,
|
|
46
|
+
) {
|
|
47
|
+
makeObservable(this, {
|
|
48
|
+
showModal: observable,
|
|
49
|
+
generatedGrammarCode: observable,
|
|
50
|
+
generatingModelState: observable,
|
|
51
|
+
saveModelState: observable,
|
|
52
|
+
close: action,
|
|
53
|
+
setShowModal: action,
|
|
54
|
+
setEntities: action,
|
|
55
|
+
setDatabaseGrammarCode: action,
|
|
56
|
+
saveModels: flow,
|
|
57
|
+
previewDatabaseModels: flow,
|
|
58
|
+
});
|
|
59
|
+
this.editorStore = editorStore;
|
|
60
|
+
this.database = database;
|
|
61
|
+
this.isReadOnly = isReadOnly;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setShowModal(val: boolean): void {
|
|
65
|
+
this.showModal = val;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setDatabaseGrammarCode(val: string): void {
|
|
69
|
+
this.generatedGrammarCode = val;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setEntities(val: Entity[] | undefined): void {
|
|
73
|
+
this.entities = val;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
close(): void {
|
|
77
|
+
this.setShowModal(false);
|
|
78
|
+
this.editorStore.explorerTreeState.setDatabaseModelBuilderState(undefined);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
*previewDatabaseModels(): GeneratorFn<void> {
|
|
82
|
+
try {
|
|
83
|
+
this.generatingModelState.isInProgress;
|
|
84
|
+
this.entities = [];
|
|
85
|
+
this.setDatabaseGrammarCode('');
|
|
86
|
+
const entities =
|
|
87
|
+
(yield this.editorStore.graphManagerState.graphManager.generateModelsFromDatabaseSpecification(
|
|
88
|
+
this.database.path,
|
|
89
|
+
this.editorStore.graphManagerState.graph,
|
|
90
|
+
)) as Entity[];
|
|
91
|
+
|
|
92
|
+
this.setEntities(entities);
|
|
93
|
+
this.setDatabaseGrammarCode(
|
|
94
|
+
(yield this.editorStore.graphManagerState.graphManager.entitiesToPureCode(
|
|
95
|
+
entities,
|
|
96
|
+
)) as string,
|
|
97
|
+
);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
assertErrorThrown(error);
|
|
100
|
+
this.editorStore.applicationStore.logService.error(
|
|
101
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_MODEL_BUILDER_FAILURE),
|
|
102
|
+
error,
|
|
103
|
+
);
|
|
104
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
|
105
|
+
} finally {
|
|
106
|
+
this.generatingModelState.complete();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
*saveModels(): GeneratorFn<void> {
|
|
111
|
+
try {
|
|
112
|
+
this.saveModelState.inProgress();
|
|
113
|
+
const entities = guaranteeNonNullable(this.entities);
|
|
114
|
+
const newEntities: EntityChange[] = [];
|
|
115
|
+
for (const entity of entities) {
|
|
116
|
+
let entityChangeType: EntityChangeType;
|
|
117
|
+
if (
|
|
118
|
+
this.editorStore.graphManagerState.graph.getNullableElement(
|
|
119
|
+
entity.path,
|
|
120
|
+
) === undefined
|
|
121
|
+
) {
|
|
122
|
+
entityChangeType = EntityChangeType.CREATE;
|
|
123
|
+
} else {
|
|
124
|
+
entityChangeType = EntityChangeType.MODIFY;
|
|
125
|
+
}
|
|
126
|
+
newEntities.push({
|
|
127
|
+
type: entityChangeType,
|
|
128
|
+
entityPath: entity.path,
|
|
129
|
+
content: entity.content,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
this.editorStore.explorerTreeState.setDatabaseModelBuilderState(
|
|
133
|
+
undefined,
|
|
134
|
+
);
|
|
135
|
+
this.setShowModal(false);
|
|
136
|
+
yield flowResult(
|
|
137
|
+
this.editorStore.graphState.loadEntityChangesToGraph(
|
|
138
|
+
newEntities,
|
|
139
|
+
undefined,
|
|
140
|
+
),
|
|
141
|
+
);
|
|
142
|
+
this.editorStore.applicationStore.notificationService.notifySuccess(
|
|
143
|
+
'Generated models successfully!',
|
|
144
|
+
);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
assertErrorThrown(error);
|
|
147
|
+
this.editorStore.applicationStore.logService.error(
|
|
148
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_MODEL_BUILDER_FAILURE),
|
|
149
|
+
error,
|
|
150
|
+
);
|
|
151
|
+
this.editorStore.applicationStore.notificationService.notifyError(error);
|
|
152
|
+
} finally {
|
|
153
|
+
this.saveModelState.complete();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
"./src/stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.ts",
|
|
98
98
|
"./src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts",
|
|
99
99
|
"./src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.ts",
|
|
100
|
+
"./src/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.ts",
|
|
100
101
|
"./src/stores/editor/editor-state/element-editor-state/connection/PostProcessorEditorState.ts",
|
|
101
102
|
"./src/stores/editor/editor-state/element-editor-state/data/DataEditorState.ts",
|
|
102
103
|
"./src/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.ts",
|
|
@@ -197,6 +198,7 @@
|
|
|
197
198
|
"./src/components/editor/editor-group/connection-editor/ConnectionEditor.tsx",
|
|
198
199
|
"./src/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.tsx",
|
|
199
200
|
"./src/components/editor/editor-group/connection-editor/DatabaseEditorHelper.tsx",
|
|
201
|
+
"./src/components/editor/editor-group/connection-editor/DatabaseModelBuilder.tsx",
|
|
200
202
|
"./src/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.tsx",
|
|
201
203
|
"./src/components/editor/editor-group/connection-editor/FlatDataConnectionEditor.tsx",
|
|
202
204
|
"./src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx",
|