@finos/legend-application-studio 13.1.1 → 15.0.0
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/components/EditorComponentTestUtils.d.ts +3 -13
- package/lib/components/EditorComponentTestUtils.d.ts.map +1 -1
- package/lib/components/EditorComponentTestUtils.js +3 -22
- package/lib/components/EditorComponentTestUtils.js.map +1 -1
- package/lib/components/LegendStudioApplication.js +1 -1
- package/lib/components/LegendStudioApplication.js.map +1 -1
- package/lib/components/editor/edit-panel/EditPanel.js +4 -4
- package/lib/components/editor/edit-panel/EditPanel.js.map +1 -1
- package/lib/components/editor/edit-panel/{ModelLoader.d.ts → ModelImporter.d.ts} +2 -2
- package/lib/components/editor/edit-panel/ModelImporter.d.ts.map +1 -0
- package/lib/components/editor/edit-panel/ModelImporter.js +127 -0
- package/lib/components/editor/edit-panel/ModelImporter.js.map +1 -0
- package/lib/components/editor/edit-panel/connection-editor/RelationalDatabaseConnectionEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/connection-editor/RelationalDatabaseConnectionEditor.js +10 -2
- package/lib/components/editor/edit-panel/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.d.ts +7 -0
- package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.js +18 -42
- package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.d.ts +24 -0
- package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.d.ts.map +1 -0
- package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.js +75 -0
- package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.js.map +1 -0
- package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js +1 -2
- package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js.map +1 -1
- package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestDataEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestDataEditor.js +6 -4
- package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestDataEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.js +2 -4
- package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.js.map +1 -1
- package/lib/components/editor/side-bar/Explorer.js +4 -4
- package/lib/components/editor/side-bar/Explorer.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/package.json +6 -6
- package/lib/stores/EditorGraphState.d.ts +1 -1
- package/lib/stores/EditorGraphState.d.ts.map +1 -1
- package/lib/stores/EditorGraphState.js +10 -10
- package/lib/stores/EditorGraphState.js.map +1 -1
- package/lib/stores/EditorStore.d.ts +3 -3
- package/lib/stores/EditorStore.d.ts.map +1 -1
- package/lib/stores/EditorStore.js +6 -8
- package/lib/stores/EditorStore.js.map +1 -1
- package/lib/stores/LegendStudioApplicationPlugin.d.ts +7 -5
- package/lib/stores/LegendStudioApplicationPlugin.d.ts.map +1 -1
- package/lib/stores/LegendStudioApplicationPlugin.js.map +1 -1
- package/lib/stores/LegendStudioBaseStore.d.ts +8 -3
- package/lib/stores/LegendStudioBaseStore.d.ts.map +1 -1
- package/lib/stores/LegendStudioBaseStore.js +105 -9
- package/lib/stores/LegendStudioBaseStore.js.map +1 -1
- package/lib/stores/editor/NewElementState.d.ts.map +1 -1
- package/lib/stores/editor/NewElementState.js +4 -3
- package/lib/stores/editor/NewElementState.js.map +1 -1
- package/lib/stores/editor-state/ExternalFormatState.d.ts +3 -2
- package/lib/stores/editor-state/ExternalFormatState.d.ts.map +1 -1
- package/lib/stores/editor-state/ExternalFormatState.js +11 -8
- package/lib/stores/editor-state/ExternalFormatState.js.map +1 -1
- package/lib/stores/editor-state/ModelImporterState.d.ts +100 -0
- package/lib/stores/editor-state/ModelImporterState.d.ts.map +1 -0
- package/lib/stores/editor-state/ModelImporterState.js +358 -0
- package/lib/stores/editor-state/ModelImporterState.js.map +1 -0
- package/lib/stores/editor-state/element-editor-state/connection/ConnectionEditorState.d.ts +2 -1
- package/lib/stores/editor-state/element-editor-state/connection/ConnectionEditorState.d.ts.map +1 -1
- package/lib/stores/editor-state/element-editor-state/connection/ConnectionEditorState.js +9 -1
- package/lib/stores/editor-state/element-editor-state/connection/ConnectionEditorState.js.map +1 -1
- package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.d.ts +35 -12
- package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.d.ts.map +1 -1
- package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.js +141 -34
- package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.js.map +1 -1
- package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.d.ts.map +1 -1
- package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.js +1 -1
- package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.js.map +1 -1
- package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts.map +1 -1
- package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.js +2 -2
- package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.js.map +1 -1
- package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.d.ts.map +1 -1
- package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js +3 -3
- package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js.map +1 -1
- package/lib/stores/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.js +1 -1
- package/lib/stores/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.js.map +1 -1
- package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.d.ts +1 -0
- package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.d.ts.map +1 -1
- package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.js +3 -0
- package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.js.map +1 -1
- package/lib/stores/graphModifier/StoreRelational_GraphModifierHelper.d.ts +2 -1
- package/lib/stores/graphModifier/StoreRelational_GraphModifierHelper.d.ts.map +1 -1
- package/lib/stores/graphModifier/StoreRelational_GraphModifierHelper.js +3 -0
- package/lib/stores/graphModifier/StoreRelational_GraphModifierHelper.js.map +1 -1
- package/lib/stores/shared/testable/TestableUtils.d.ts.map +1 -1
- package/lib/stores/shared/testable/TestableUtils.js +2 -3
- package/lib/stores/shared/testable/TestableUtils.js.map +1 -1
- package/package.json +14 -14
- package/src/components/EditorComponentTestUtils.tsx +2 -29
- package/src/components/LegendStudioApplication.tsx +2 -2
- package/src/components/editor/edit-panel/EditPanel.tsx +4 -4
- package/src/components/editor/edit-panel/ModelImporter.tsx +372 -0
- package/src/components/editor/edit-panel/connection-editor/RelationalDatabaseConnectionEditor.tsx +36 -0
- package/src/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.tsx +47 -163
- package/src/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.tsx +226 -0
- package/src/components/editor/edit-panel/mapping-editor/NewMappingElementModal.tsx +1 -2
- package/src/components/editor/edit-panel/service-editor/testable/ServiceTestDataEditor.tsx +63 -36
- package/src/components/editor/edit-panel/uml-editor/AssociationEditor.tsx +1 -7
- package/src/components/editor/side-bar/Explorer.tsx +8 -8
- package/src/index.ts +5 -0
- package/src/stores/EditorGraphState.ts +13 -12
- package/src/stores/EditorStore.ts +7 -9
- package/src/stores/LegendStudioApplicationPlugin.ts +16 -7
- package/src/stores/LegendStudioBaseStore.ts +147 -20
- package/src/stores/editor/NewElementState.ts +4 -3
- package/src/stores/editor-state/ExternalFormatState.ts +15 -12
- package/src/stores/editor-state/ModelImporterState.ts +516 -0
- package/src/stores/editor-state/element-editor-state/connection/ConnectionEditorState.ts +10 -0
- package/src/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.ts +203 -46
- package/src/stores/editor-state/element-editor-state/service/ServiceExecutionState.ts +1 -0
- package/src/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +2 -1
- package/src/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.ts +12 -3
- package/src/stores/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.ts +1 -1
- package/src/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.ts +5 -0
- package/src/stores/graphModifier/StoreRelational_GraphModifierHelper.ts +10 -0
- package/src/stores/shared/testable/TestableUtils.ts +4 -3
- package/tsconfig.json +3 -2
- package/lib/components/editor/edit-panel/ModelLoader.d.ts.map +0 -1
- package/lib/components/editor/edit-panel/ModelLoader.js +0 -95
- package/lib/components/editor/edit-panel/ModelLoader.js.map +0 -1
- package/lib/stores/editor-state/ModelLoaderState.d.ts +0 -52
- package/lib/stores/editor-state/ModelLoaderState.d.ts.map +0 -1
- package/lib/stores/editor-state/ModelLoaderState.js +0 -199
- package/lib/stores/editor-state/ModelLoaderState.js.map +0 -1
- package/src/components/editor/edit-panel/ModelLoader.tsx +0 -259
- package/src/stores/editor-state/ModelLoaderState.ts +0 -280
|
@@ -0,0 +1,516 @@
|
|
|
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 {
|
|
18
|
+
observable,
|
|
19
|
+
action,
|
|
20
|
+
flow,
|
|
21
|
+
makeObservable,
|
|
22
|
+
computed,
|
|
23
|
+
flowResult,
|
|
24
|
+
} from 'mobx';
|
|
25
|
+
import { EditorState } from './EditorState.js';
|
|
26
|
+
import {
|
|
27
|
+
type GeneratorFn,
|
|
28
|
+
assertErrorThrown,
|
|
29
|
+
LogEvent,
|
|
30
|
+
UnsupportedOperationError,
|
|
31
|
+
isNonNullable,
|
|
32
|
+
ActionState,
|
|
33
|
+
assertTrue,
|
|
34
|
+
} from '@finos/legend-shared';
|
|
35
|
+
import { LEGEND_STUDIO_APP_EVENT } from '../LegendStudioAppEvent.js';
|
|
36
|
+
import type { EditorStore } from '../EditorStore.js';
|
|
37
|
+
import type { Entity } from '@finos/legend-storage';
|
|
38
|
+
import { TAB_SIZE } from '@finos/legend-application';
|
|
39
|
+
import type {
|
|
40
|
+
ModelImporterExtensionConfiguration,
|
|
41
|
+
LegendStudioApplicationPlugin,
|
|
42
|
+
} from '../LegendStudioApplicationPlugin.js';
|
|
43
|
+
import {
|
|
44
|
+
type ExternalFormatDescription,
|
|
45
|
+
type PureModel,
|
|
46
|
+
SchemaSet,
|
|
47
|
+
observe_SchemaSet,
|
|
48
|
+
} from '@finos/legend-graph';
|
|
49
|
+
import {
|
|
50
|
+
externalFormat_schemaSet_setFormat,
|
|
51
|
+
externalFormat_schemaSet_setSchemas,
|
|
52
|
+
} from '../graphModifier/DSLExternalFormat_GraphModifierHelper.js';
|
|
53
|
+
import { InnerSchemaSetEditorState } from './element-editor-state/external-format/SchemaSetEditorState.js';
|
|
54
|
+
|
|
55
|
+
export enum MODEL_IMPORT_NATIVE_INPUT_TYPE {
|
|
56
|
+
ENTITIES = 'ENTITIES',
|
|
57
|
+
PURE_PROTOCOL = 'PURE_PROTOCOL',
|
|
58
|
+
PURE_GRAMMAR = 'PURE_GRAMMAR',
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export enum MODEL_IMPORT_TYPE {
|
|
62
|
+
NATIVE = 'NATIVE',
|
|
63
|
+
EXTERNAL_FORMAT = 'EXTERNAL_FORMAT',
|
|
64
|
+
EXTENSIONS = 'EXTENSIONS',
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export abstract class ModelImporterEditorState {
|
|
68
|
+
readonly editorStore: EditorStore;
|
|
69
|
+
readonly modelImporterState: ModelImporterState;
|
|
70
|
+
loadModelActionState = ActionState.create();
|
|
71
|
+
|
|
72
|
+
constructor(modelImporterState: ModelImporterState) {
|
|
73
|
+
this.editorStore = modelImporterState.editorStore;
|
|
74
|
+
this.modelImporterState = modelImporterState;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
abstract get label(): string;
|
|
78
|
+
|
|
79
|
+
abstract get allowHardReplace(): boolean;
|
|
80
|
+
|
|
81
|
+
abstract get isLoadingDisabled(): boolean;
|
|
82
|
+
|
|
83
|
+
abstract loadModel(): GeneratorFn<void>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class NativeModelImporterEditorState extends ModelImporterEditorState {
|
|
87
|
+
nativeType = MODEL_IMPORT_NATIVE_INPUT_TYPE.ENTITIES;
|
|
88
|
+
modelText: string;
|
|
89
|
+
loadCurrentProjectActionState = ActionState.create();
|
|
90
|
+
|
|
91
|
+
constructor(modelImporterState: ModelImporterState) {
|
|
92
|
+
super(modelImporterState);
|
|
93
|
+
this.modelText = this.getExampleEntitiesInputText();
|
|
94
|
+
makeObservable(this, {
|
|
95
|
+
nativeType: observable,
|
|
96
|
+
modelText: observable,
|
|
97
|
+
loadModelActionState: observable,
|
|
98
|
+
setModelText: action,
|
|
99
|
+
setNativeImportType: action,
|
|
100
|
+
isLoadingDisabled: computed,
|
|
101
|
+
loadModel: flow,
|
|
102
|
+
loadCurrentProjectEntities: flow,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get label(): string {
|
|
107
|
+
return this.nativeType;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get allowHardReplace(): boolean {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
get isLoadingDisabled(): boolean {
|
|
115
|
+
return this.loadCurrentProjectActionState.isInProgress;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setModelText(val: string): void {
|
|
119
|
+
this.modelText = val;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
setNativeImportType(nativeImportType: MODEL_IMPORT_NATIVE_INPUT_TYPE): void {
|
|
123
|
+
if (this.nativeType !== nativeImportType) {
|
|
124
|
+
this.nativeType = nativeImportType;
|
|
125
|
+
this.modelText = this.getNativeImportExampleText(nativeImportType);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
getNativeImportExampleText(
|
|
130
|
+
inputType: MODEL_IMPORT_NATIVE_INPUT_TYPE,
|
|
131
|
+
): string {
|
|
132
|
+
switch (inputType) {
|
|
133
|
+
case MODEL_IMPORT_NATIVE_INPUT_TYPE.PURE_PROTOCOL:
|
|
134
|
+
return this.getExamplePureProtocolInputText();
|
|
135
|
+
case MODEL_IMPORT_NATIVE_INPUT_TYPE.ENTITIES:
|
|
136
|
+
return this.getExampleEntitiesInputText();
|
|
137
|
+
case MODEL_IMPORT_NATIVE_INPUT_TYPE.PURE_GRAMMAR:
|
|
138
|
+
return this.getExamplePureGrammarText();
|
|
139
|
+
default:
|
|
140
|
+
return '';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async loadEntites(): Promise<Entity[]> {
|
|
145
|
+
switch (this.nativeType) {
|
|
146
|
+
case MODEL_IMPORT_NATIVE_INPUT_TYPE.PURE_PROTOCOL: {
|
|
147
|
+
return this.editorStore.graphManagerState.graphManager.pureProtocolTextToEntities(
|
|
148
|
+
this.modelText,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
case MODEL_IMPORT_NATIVE_INPUT_TYPE.ENTITIES: {
|
|
152
|
+
return JSON.parse(this.modelText) as Entity[];
|
|
153
|
+
}
|
|
154
|
+
case MODEL_IMPORT_NATIVE_INPUT_TYPE.PURE_GRAMMAR: {
|
|
155
|
+
return await this.editorStore.graphManagerState.graphManager.pureCodeToEntities(
|
|
156
|
+
this.modelText,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
default:
|
|
160
|
+
throw new UnsupportedOperationError(
|
|
161
|
+
`Can't load model for input of type '${this.nativeType}'`,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
*loadCurrentProjectEntities(): GeneratorFn<void> {
|
|
167
|
+
this.loadCurrentProjectActionState.inProgress();
|
|
168
|
+
switch (this.nativeType) {
|
|
169
|
+
case MODEL_IMPORT_NATIVE_INPUT_TYPE.PURE_PROTOCOL: {
|
|
170
|
+
const graphEntities = this.editorStore.graphManagerState.graphBuildState
|
|
171
|
+
.hasSucceeded
|
|
172
|
+
? this.editorStore.graphManagerState.graph.allOwnElements.map(
|
|
173
|
+
(element) =>
|
|
174
|
+
this.editorStore.graphManagerState.graphManager.elementToEntity(
|
|
175
|
+
element,
|
|
176
|
+
),
|
|
177
|
+
)
|
|
178
|
+
: this.editorStore.changeDetectionState
|
|
179
|
+
.workspaceLocalLatestRevisionState.entities;
|
|
180
|
+
this.modelText =
|
|
181
|
+
(yield this.editorStore.graphManagerState.graphManager.entitiesToPureProtocolText(
|
|
182
|
+
graphEntities,
|
|
183
|
+
)) as string;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
case MODEL_IMPORT_NATIVE_INPUT_TYPE.ENTITIES: {
|
|
187
|
+
const graphEntities = this.editorStore.graphManagerState.graphBuildState
|
|
188
|
+
.hasSucceeded
|
|
189
|
+
? this.editorStore.graphManagerState.graph.allOwnElements.map(
|
|
190
|
+
(element) =>
|
|
191
|
+
this.editorStore.graphManagerState.graphManager.elementToEntity(
|
|
192
|
+
element,
|
|
193
|
+
),
|
|
194
|
+
)
|
|
195
|
+
: this.editorStore.changeDetectionState
|
|
196
|
+
.workspaceLocalLatestRevisionState.entities;
|
|
197
|
+
this.modelText = JSON.stringify(graphEntities, undefined, TAB_SIZE);
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case MODEL_IMPORT_NATIVE_INPUT_TYPE.PURE_GRAMMAR: {
|
|
201
|
+
this.modelText =
|
|
202
|
+
(yield this.editorStore.graphManagerState.graphManager.graphToPureCode(
|
|
203
|
+
this.editorStore.graphManagerState.graph,
|
|
204
|
+
)) as string;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
default:
|
|
208
|
+
this.loadCurrentProjectActionState.fail();
|
|
209
|
+
throw new UnsupportedOperationError(
|
|
210
|
+
`Can't load current project entities for input type of type '${this.nativeType}'`,
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
this.loadCurrentProjectActionState.complete();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private getExampleEntitiesInputText(): string {
|
|
217
|
+
return `${JSON.stringify(
|
|
218
|
+
[
|
|
219
|
+
{
|
|
220
|
+
classifierPath: 'string',
|
|
221
|
+
content: {},
|
|
222
|
+
path: 'string',
|
|
223
|
+
} as Entity,
|
|
224
|
+
],
|
|
225
|
+
undefined,
|
|
226
|
+
TAB_SIZE,
|
|
227
|
+
)}`;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
private getExamplePureProtocolInputText(): string {
|
|
231
|
+
return `${this.editorStore.graphManagerState.graphManager.getExamplePureProtocolText()}`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private getExamplePureGrammarText(): string {
|
|
235
|
+
return `###Pure\n Class model::A\n {\n\n}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
*loadModel(): GeneratorFn<void> {
|
|
239
|
+
try {
|
|
240
|
+
this.loadModelActionState.inProgress();
|
|
241
|
+
this.editorStore.setBlockingAlert({
|
|
242
|
+
message: 'Loading model...',
|
|
243
|
+
prompt: 'Please do not close the application',
|
|
244
|
+
showLoading: true,
|
|
245
|
+
});
|
|
246
|
+
const entities = (yield this.loadEntites()) as Entity[];
|
|
247
|
+
const message = `loading entities from ${
|
|
248
|
+
this.editorStore.applicationStore.config.appName
|
|
249
|
+
} [${this.modelImporterState.replace ? `potentially affected ` : ''} ${
|
|
250
|
+
entities.length
|
|
251
|
+
} entities]`;
|
|
252
|
+
yield this.editorStore.sdlcServerClient.updateEntities(
|
|
253
|
+
this.editorStore.sdlcState.activeProject.projectId,
|
|
254
|
+
this.editorStore.sdlcState.activeWorkspace,
|
|
255
|
+
{ replace: this.modelImporterState.replace, entities, message },
|
|
256
|
+
);
|
|
257
|
+
this.editorStore.applicationStore.navigator.reload();
|
|
258
|
+
} catch (error) {
|
|
259
|
+
assertErrorThrown(error);
|
|
260
|
+
this.editorStore.applicationStore.log.error(
|
|
261
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.MODEL_LOADER_FAILURE),
|
|
262
|
+
error,
|
|
263
|
+
);
|
|
264
|
+
this.editorStore.applicationStore.notifyError(error);
|
|
265
|
+
} finally {
|
|
266
|
+
this.loadModelActionState.complete();
|
|
267
|
+
this.editorStore.setBlockingAlert(undefined);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export abstract class ExtensionModelImportRendererState {
|
|
273
|
+
externalFormatModelImporterState: ExternalFormatModelImporterState;
|
|
274
|
+
|
|
275
|
+
constructor(
|
|
276
|
+
externalFormatModelImporterState: ExternalFormatModelImporterState,
|
|
277
|
+
) {
|
|
278
|
+
this.externalFormatModelImporterState = externalFormatModelImporterState;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
export class ExtensionModelImporterEditorState extends ModelImporterEditorState {
|
|
282
|
+
config: ModelImporterExtensionConfiguration;
|
|
283
|
+
rendererState: ExtensionModelImportRendererState;
|
|
284
|
+
|
|
285
|
+
constructor(
|
|
286
|
+
config: ModelImporterExtensionConfiguration,
|
|
287
|
+
rendererState: ExtensionModelImportRendererState,
|
|
288
|
+
modelImporterState: ModelImporterState,
|
|
289
|
+
) {
|
|
290
|
+
super(modelImporterState);
|
|
291
|
+
this.config = config;
|
|
292
|
+
this.rendererState = rendererState;
|
|
293
|
+
makeObservable(this, {
|
|
294
|
+
config: observable,
|
|
295
|
+
modelImporterState: observable,
|
|
296
|
+
loadModelActionState: observable,
|
|
297
|
+
rendererState: observable,
|
|
298
|
+
isLoadingDisabled: computed,
|
|
299
|
+
setExtension: action,
|
|
300
|
+
loadModel: flow,
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
get label(): string {
|
|
305
|
+
return this.config.label ?? this.config.key;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
get allowHardReplace(): boolean {
|
|
309
|
+
return Boolean(this.config.allowHardReplace);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
get isLoadingDisabled(): boolean {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
setExtension(
|
|
317
|
+
extensionConfiguration: ModelImporterExtensionConfiguration,
|
|
318
|
+
): void {
|
|
319
|
+
this.config = extensionConfiguration;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
*loadModel(): GeneratorFn<void> {
|
|
323
|
+
flowResult(this.config.loadModel(this.rendererState));
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const DEFAULT_SCHEMA_PACKAGE = '__internal__';
|
|
328
|
+
const DEFAULT_SCHEMA_NAME = 'MyShemaSet';
|
|
329
|
+
|
|
330
|
+
export class ExternalFormatModelImporterState extends ModelImporterEditorState {
|
|
331
|
+
schemaSet: SchemaSet;
|
|
332
|
+
schemaSetEditorState: InnerSchemaSetEditorState;
|
|
333
|
+
description: ExternalFormatDescription;
|
|
334
|
+
isolatedSchemaGraph: PureModel;
|
|
335
|
+
|
|
336
|
+
constructor(
|
|
337
|
+
description: ExternalFormatDescription,
|
|
338
|
+
modelImporterState: ModelImporterState,
|
|
339
|
+
) {
|
|
340
|
+
super(modelImporterState);
|
|
341
|
+
this.description = description;
|
|
342
|
+
this.schemaSet = new SchemaSet(DEFAULT_SCHEMA_NAME);
|
|
343
|
+
this.schemaSet.format = description.name;
|
|
344
|
+
|
|
345
|
+
observe_SchemaSet(this.schemaSet);
|
|
346
|
+
const emptyGraph = this.editorStore.graphManagerState.createEmptyGraph();
|
|
347
|
+
emptyGraph.addElement(this.schemaSet, DEFAULT_SCHEMA_PACKAGE);
|
|
348
|
+
this.isolatedSchemaGraph = emptyGraph;
|
|
349
|
+
this.schemaSetEditorState = new InnerSchemaSetEditorState(
|
|
350
|
+
false,
|
|
351
|
+
this.schemaSet,
|
|
352
|
+
this.editorStore,
|
|
353
|
+
this.isolatedSchemaGraph,
|
|
354
|
+
);
|
|
355
|
+
makeObservable(this, {
|
|
356
|
+
schemaSet: observable,
|
|
357
|
+
schemaSetEditorState: observable,
|
|
358
|
+
loadModelActionState: observable,
|
|
359
|
+
description: observable,
|
|
360
|
+
isolatedSchemaGraph: observable,
|
|
361
|
+
setExternalFormat: action,
|
|
362
|
+
setDescription: action,
|
|
363
|
+
isLoadingDisabled: computed,
|
|
364
|
+
loadModel: flow,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
get allowHardReplace(): boolean {
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
get label(): string {
|
|
372
|
+
return this.schemaSet.format;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
get isLoadingDisabled(): boolean {
|
|
376
|
+
return (
|
|
377
|
+
!this.schemaSetEditorState.schemaSetModelGenerationState.canGenerate ||
|
|
378
|
+
this.schemaSetEditorState.schemaSetModelGenerationState
|
|
379
|
+
.generatingModelsState.isInProgress ||
|
|
380
|
+
this.schemaSetEditorState.schemaSetModelGenerationState
|
|
381
|
+
.importGeneratedElementsState.isInProgress
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
setDescription(val: ExternalFormatDescription): void {
|
|
386
|
+
this.description = val;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
setExternalFormat(description: ExternalFormatDescription): void {
|
|
390
|
+
if (description !== this.description) {
|
|
391
|
+
this.setDescription(description);
|
|
392
|
+
externalFormat_schemaSet_setFormat(this.schemaSet, this.description.name);
|
|
393
|
+
externalFormat_schemaSet_setSchemas(this.schemaSet, []);
|
|
394
|
+
this.schemaSetEditorState.reset();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
*loadModel(): GeneratorFn<void> {
|
|
399
|
+
this.loadModelActionState.inProgress();
|
|
400
|
+
try {
|
|
401
|
+
this.loadModelActionState.inProgress();
|
|
402
|
+
this.editorStore.setBlockingAlert({
|
|
403
|
+
message: 'Loading model...',
|
|
404
|
+
prompt: 'Please do not close the application',
|
|
405
|
+
showLoading: true,
|
|
406
|
+
});
|
|
407
|
+
const modelgenerationstate =
|
|
408
|
+
this.schemaSetEditorState.schemaSetModelGenerationState;
|
|
409
|
+
const entities = (yield flowResult(
|
|
410
|
+
modelgenerationstate.getImportEntities(),
|
|
411
|
+
)) as Entity[];
|
|
412
|
+
if (modelgenerationstate.targetBinding) {
|
|
413
|
+
const schemaEntity = (yield flowResult(
|
|
414
|
+
this.editorStore.graphManagerState.graphManager.elementToEntity(
|
|
415
|
+
this.schemaSet,
|
|
416
|
+
),
|
|
417
|
+
)) as Entity;
|
|
418
|
+
entities.push(schemaEntity);
|
|
419
|
+
}
|
|
420
|
+
assertTrue(Boolean(entities.length), 'No entities to load');
|
|
421
|
+
const message = `loading entities from ${
|
|
422
|
+
this.editorStore.applicationStore.config.appName
|
|
423
|
+
} [${this.modelImporterState.replace ? `potentially affected ` : ''} ${
|
|
424
|
+
entities.length
|
|
425
|
+
} entities]`;
|
|
426
|
+
yield this.editorStore.sdlcServerClient.updateEntities(
|
|
427
|
+
this.editorStore.sdlcState.activeProject.projectId,
|
|
428
|
+
this.editorStore.sdlcState.activeWorkspace,
|
|
429
|
+
{ replace: this.modelImporterState.replace, entities, message },
|
|
430
|
+
);
|
|
431
|
+
this.editorStore.applicationStore.navigator.reload();
|
|
432
|
+
} catch (error) {
|
|
433
|
+
assertErrorThrown(error);
|
|
434
|
+
this.editorStore.applicationStore.notifyError(error);
|
|
435
|
+
} finally {
|
|
436
|
+
this.loadModelActionState.complete();
|
|
437
|
+
this.editorStore.setBlockingAlert(undefined);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export class ModelImporterState extends EditorState {
|
|
443
|
+
replace = true;
|
|
444
|
+
modelImportEditorState: ModelImporterEditorState;
|
|
445
|
+
extensionConfigs: ModelImporterExtensionConfiguration[] = [];
|
|
446
|
+
|
|
447
|
+
constructor(editorStore: EditorStore) {
|
|
448
|
+
super(editorStore);
|
|
449
|
+
|
|
450
|
+
makeObservable(this, {
|
|
451
|
+
replace: observable,
|
|
452
|
+
modelImportEditorState: observable,
|
|
453
|
+
extensionConfigs: observable,
|
|
454
|
+
setReplaceFlag: action,
|
|
455
|
+
setModelImporterExtension: action,
|
|
456
|
+
setNativeImportType: action,
|
|
457
|
+
setExternalFormatImportFormat: action,
|
|
458
|
+
setImportEditorState: action,
|
|
459
|
+
});
|
|
460
|
+
this.modelImportEditorState = new NativeModelImporterEditorState(this);
|
|
461
|
+
this.extensionConfigs = this.editorStore.pluginManager
|
|
462
|
+
.getApplicationPlugins()
|
|
463
|
+
.flatMap(
|
|
464
|
+
(plugin: LegendStudioApplicationPlugin) =>
|
|
465
|
+
plugin.getExtraModelImporterExtensionConfigurations?.() ?? [],
|
|
466
|
+
)
|
|
467
|
+
.filter(isNonNullable);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
get headerName(): string {
|
|
471
|
+
return 'Model Importer';
|
|
472
|
+
}
|
|
473
|
+
setReplaceFlag(val: boolean): void {
|
|
474
|
+
this.replace = val;
|
|
475
|
+
}
|
|
476
|
+
setImportEditorState(val: ModelImporterEditorState): void {
|
|
477
|
+
this.modelImportEditorState = val;
|
|
478
|
+
}
|
|
479
|
+
setNativeImportType(
|
|
480
|
+
nativeImportType: MODEL_IMPORT_NATIVE_INPUT_TYPE,
|
|
481
|
+
): NativeModelImporterEditorState {
|
|
482
|
+
const nativeEditorState =
|
|
483
|
+
this.modelImportEditorState instanceof NativeModelImporterEditorState
|
|
484
|
+
? this.modelImportEditorState
|
|
485
|
+
: new NativeModelImporterEditorState(this);
|
|
486
|
+
nativeEditorState.setNativeImportType(nativeImportType);
|
|
487
|
+
this.setImportEditorState(nativeEditorState);
|
|
488
|
+
return nativeEditorState;
|
|
489
|
+
}
|
|
490
|
+
setExternalFormatImportFormat(
|
|
491
|
+
externalFormat: ExternalFormatDescription,
|
|
492
|
+
): ExternalFormatModelImporterState {
|
|
493
|
+
const extensionEditorState =
|
|
494
|
+
this.modelImportEditorState instanceof ExternalFormatModelImporterState
|
|
495
|
+
? this.modelImportEditorState
|
|
496
|
+
: new ExternalFormatModelImporterState(externalFormat, this);
|
|
497
|
+
extensionEditorState.setExternalFormat(externalFormat);
|
|
498
|
+
this.setImportEditorState(extensionEditorState);
|
|
499
|
+
return extensionEditorState;
|
|
500
|
+
}
|
|
501
|
+
setModelImporterExtension(
|
|
502
|
+
extension: ModelImporterExtensionConfiguration,
|
|
503
|
+
): ExtensionModelImporterEditorState {
|
|
504
|
+
const externalEditorState =
|
|
505
|
+
this.modelImportEditorState instanceof ExtensionModelImporterEditorState
|
|
506
|
+
? this.modelImportEditorState
|
|
507
|
+
: new ExtensionModelImporterEditorState(
|
|
508
|
+
extension,
|
|
509
|
+
extension.getExtensionModelImportRendererStateCreator(this),
|
|
510
|
+
this,
|
|
511
|
+
);
|
|
512
|
+
externalEditorState.setExtension(extension);
|
|
513
|
+
this.setImportEditorState(externalEditorState);
|
|
514
|
+
return externalEditorState;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
SnowflakePublicAuthenticationStrategy,
|
|
43
43
|
GCPApplicationDefaultCredentialsAuthenticationStrategy,
|
|
44
44
|
GCPWorkloadIdentityFederationAuthenticationStrategy,
|
|
45
|
+
MiddleTierUsernamePasswordAuthenticationStrategy,
|
|
45
46
|
EmbeddedH2DatasourceSpecification,
|
|
46
47
|
LocalH2DatasourceSpecification,
|
|
47
48
|
DatabricksDatasourceSpecification,
|
|
@@ -94,6 +95,7 @@ export enum CORE_AUTHENTICATION_STRATEGY_TYPE {
|
|
|
94
95
|
OAUTH = 'OAUTH',
|
|
95
96
|
USERNAME_PASSWORD = 'USERNAME_PASSWORD',
|
|
96
97
|
GCP_WORKLOAD_IDENTITY_FEDERATION = 'GCP_WORKLOAD_IDENTITY_FEDERATION',
|
|
98
|
+
MIDDLE_TIER_USERNAME_PASSWORD = 'MIDDLE_TIER_USERNAME_PASSWORD',
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
export class RelationalDatabaseConnectionValueState extends ConnectionValueState {
|
|
@@ -262,6 +264,10 @@ export class RelationalDatabaseConnectionValueState extends ConnectionValueState
|
|
|
262
264
|
auth instanceof GCPWorkloadIdentityFederationAuthenticationStrategy
|
|
263
265
|
) {
|
|
264
266
|
return CORE_AUTHENTICATION_STRATEGY_TYPE.GCP_WORKLOAD_IDENTITY_FEDERATION;
|
|
267
|
+
} else if (
|
|
268
|
+
auth instanceof MiddleTierUsernamePasswordAuthenticationStrategy
|
|
269
|
+
) {
|
|
270
|
+
return CORE_AUTHENTICATION_STRATEGY_TYPE.MIDDLE_TIER_USERNAME_PASSWORD;
|
|
265
271
|
}
|
|
266
272
|
|
|
267
273
|
const extraAuthenticationStrategyTypeGetters =
|
|
@@ -326,6 +332,10 @@ export class RelationalDatabaseConnectionValueState extends ConnectionValueState
|
|
|
326
332
|
authStrategy = new OAuthAuthenticationStrategy('', '');
|
|
327
333
|
break;
|
|
328
334
|
}
|
|
335
|
+
case CORE_AUTHENTICATION_STRATEGY_TYPE.MIDDLE_TIER_USERNAME_PASSWORD: {
|
|
336
|
+
authStrategy = new MiddleTierUsernamePasswordAuthenticationStrategy('');
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
329
339
|
default: {
|
|
330
340
|
const extraAuthenticationStrategyCreators =
|
|
331
341
|
this.editorStore.pluginManager
|