@finos/legend-application-studio 13.1.2 → 15.0.1
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/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/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/side-bar/Explorer.js +4 -4
- package/lib/components/editor/side-bar/Explorer.js.map +1 -1
- package/lib/index.css +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 +7 -7
- 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/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/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/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/package.json +15 -15
- package/src/components/EditorComponentTestUtils.tsx +2 -29
- 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/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/side-bar/Explorer.tsx +8 -8
- package/src/index.ts +1 -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/editor-state/ExternalFormatState.ts +15 -12
- package/src/stores/editor-state/ModelImporterState.ts +514 -0
- package/src/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.ts +203 -46
- package/src/stores/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.ts +1 -1
- package/src/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.ts +5 -0
- 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
|
@@ -1,280 +0,0 @@
|
|
|
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 { observable, action, flow, makeObservable } from 'mobx';
|
|
18
|
-
import { EditorState } from './EditorState.js';
|
|
19
|
-
import {
|
|
20
|
-
type GeneratorFn,
|
|
21
|
-
assertErrorThrown,
|
|
22
|
-
LogEvent,
|
|
23
|
-
UnsupportedOperationError,
|
|
24
|
-
isNonNullable,
|
|
25
|
-
} from '@finos/legend-shared';
|
|
26
|
-
import { LEGEND_STUDIO_APP_EVENT } from '../LegendStudioAppEvent.js';
|
|
27
|
-
import type { EditorStore } from '../EditorStore.js';
|
|
28
|
-
import type { Entity } from '@finos/legend-storage';
|
|
29
|
-
import {
|
|
30
|
-
type ImportConfigurationDescription,
|
|
31
|
-
ImportMode,
|
|
32
|
-
} from '@finos/legend-graph';
|
|
33
|
-
import { TAB_SIZE } from '@finos/legend-application';
|
|
34
|
-
import type {
|
|
35
|
-
ModelLoaderExtensionConfiguration,
|
|
36
|
-
LegendStudioApplicationPlugin,
|
|
37
|
-
} from '../LegendStudioApplicationPlugin.js';
|
|
38
|
-
|
|
39
|
-
export enum MODEL_UPDATER_INPUT_TYPE {
|
|
40
|
-
ENTITIES = 'ENTITIES',
|
|
41
|
-
PURE_PROTOCOL = 'PURE_PROTOCOL',
|
|
42
|
-
PURE_GRAMMAR = 'PURE_GRAMMAR',
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export class ModelLoaderState extends EditorState {
|
|
46
|
-
modelText = this.getExampleEntitiesInputText();
|
|
47
|
-
currentModelLoadType: MODEL_UPDATER_INPUT_TYPE | string =
|
|
48
|
-
MODEL_UPDATER_INPUT_TYPE.ENTITIES;
|
|
49
|
-
// TODO: remove model import in favor of external formats
|
|
50
|
-
modelImportDescriptions: ImportConfigurationDescription[] = [];
|
|
51
|
-
modelLoaderExtensionConfigurations: ModelLoaderExtensionConfiguration[] = [];
|
|
52
|
-
replace = true;
|
|
53
|
-
isLoadingModel = false;
|
|
54
|
-
|
|
55
|
-
constructor(editorStore: EditorStore) {
|
|
56
|
-
super(editorStore);
|
|
57
|
-
|
|
58
|
-
makeObservable(this, {
|
|
59
|
-
modelText: observable,
|
|
60
|
-
currentModelLoadType: observable,
|
|
61
|
-
modelImportDescriptions: observable,
|
|
62
|
-
modelLoaderExtensionConfigurations: observable,
|
|
63
|
-
replace: observable,
|
|
64
|
-
isLoadingModel: observable,
|
|
65
|
-
setReplaceFlag: action,
|
|
66
|
-
setModelText: action,
|
|
67
|
-
loadCurrentProjectEntities: flow,
|
|
68
|
-
loadModel: flow,
|
|
69
|
-
fetchAvailableModelImportDescriptions: flow,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
//extensions
|
|
73
|
-
this.modelLoaderExtensionConfigurations = this.editorStore.pluginManager
|
|
74
|
-
.getApplicationPlugins()
|
|
75
|
-
.flatMap(
|
|
76
|
-
(plugin: LegendStudioApplicationPlugin) =>
|
|
77
|
-
plugin.getExtraModelLoaderExtensionConfigurations?.() ?? [],
|
|
78
|
-
)
|
|
79
|
-
.filter(isNonNullable);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
get headerName(): string {
|
|
83
|
-
return 'Model Loader';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
getImportConfigurationDescription(
|
|
87
|
-
key: string,
|
|
88
|
-
): ImportConfigurationDescription | undefined {
|
|
89
|
-
return this.modelImportDescriptions.find(
|
|
90
|
-
(description) => description.key === key,
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
getLoaderExtensionConfiguration(
|
|
94
|
-
key: string,
|
|
95
|
-
): ModelLoaderExtensionConfiguration | undefined {
|
|
96
|
-
return this.modelLoaderExtensionConfigurations.find(
|
|
97
|
-
(config) => config.key === key,
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
setReplaceFlag(val: boolean): void {
|
|
101
|
-
this.replace = val;
|
|
102
|
-
}
|
|
103
|
-
setModelText(modelText: string): void {
|
|
104
|
-
this.modelText = modelText;
|
|
105
|
-
}
|
|
106
|
-
setCurrentModelLoadType(
|
|
107
|
-
modelLoadType: MODEL_UPDATER_INPUT_TYPE | string,
|
|
108
|
-
): void {
|
|
109
|
-
if (modelLoadType !== this.currentModelLoadType) {
|
|
110
|
-
this.currentModelLoadType = modelLoadType;
|
|
111
|
-
this.modelText = this.getExampleText(modelLoadType);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
getExampleText(inputType: MODEL_UPDATER_INPUT_TYPE | string): string {
|
|
116
|
-
if (inputType === MODEL_UPDATER_INPUT_TYPE.PURE_PROTOCOL) {
|
|
117
|
-
return this.getExamplePureProtocolInputText();
|
|
118
|
-
} else if (inputType === MODEL_UPDATER_INPUT_TYPE.ENTITIES) {
|
|
119
|
-
return this.getExampleEntitiesInputText();
|
|
120
|
-
} else if (this.getImportConfigurationDescription(inputType)) {
|
|
121
|
-
return this.getExampleExternalFormatInputText();
|
|
122
|
-
}
|
|
123
|
-
return '';
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Current project entities will be taken from the current graph
|
|
127
|
-
* If graph is not parsable, we will fall back to model loader
|
|
128
|
-
*/
|
|
129
|
-
*loadCurrentProjectEntities(): GeneratorFn<void> {
|
|
130
|
-
switch (this.currentModelLoadType) {
|
|
131
|
-
case MODEL_UPDATER_INPUT_TYPE.PURE_PROTOCOL: {
|
|
132
|
-
const graphEntities = this.editorStore.graphManagerState.graphBuildState
|
|
133
|
-
.hasSucceeded
|
|
134
|
-
? this.editorStore.graphManagerState.graph.allOwnElements.map(
|
|
135
|
-
(element) =>
|
|
136
|
-
this.editorStore.graphManagerState.graphManager.elementToEntity(
|
|
137
|
-
element,
|
|
138
|
-
),
|
|
139
|
-
)
|
|
140
|
-
: this.editorStore.changeDetectionState
|
|
141
|
-
.workspaceLocalLatestRevisionState.entities;
|
|
142
|
-
this.modelText =
|
|
143
|
-
(yield this.editorStore.graphManagerState.graphManager.entitiesToPureProtocolText(
|
|
144
|
-
graphEntities,
|
|
145
|
-
)) as string;
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
case MODEL_UPDATER_INPUT_TYPE.ENTITIES: {
|
|
149
|
-
const graphEntities = this.editorStore.graphManagerState.graphBuildState
|
|
150
|
-
.hasSucceeded
|
|
151
|
-
? this.editorStore.graphManagerState.graph.allOwnElements.map(
|
|
152
|
-
(element) =>
|
|
153
|
-
this.editorStore.graphManagerState.graphManager.elementToEntity(
|
|
154
|
-
element,
|
|
155
|
-
),
|
|
156
|
-
)
|
|
157
|
-
: this.editorStore.changeDetectionState
|
|
158
|
-
.workspaceLocalLatestRevisionState.entities;
|
|
159
|
-
this.modelText = JSON.stringify(graphEntities, undefined, TAB_SIZE);
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
case MODEL_UPDATER_INPUT_TYPE.PURE_GRAMMAR: {
|
|
163
|
-
this.modelText =
|
|
164
|
-
(yield this.editorStore.graphManagerState.graphManager.graphToPureCode(
|
|
165
|
-
this.editorStore.graphManagerState.graph,
|
|
166
|
-
)) as string;
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
default:
|
|
170
|
-
throw new UnsupportedOperationError(
|
|
171
|
-
`Can't load current project entities for input type of type '${this.currentModelLoadType}'`,
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
*loadModel(): GeneratorFn<void> {
|
|
177
|
-
try {
|
|
178
|
-
this.isLoadingModel = true;
|
|
179
|
-
this.editorStore.setBlockingAlert({
|
|
180
|
-
message: 'Loading model...',
|
|
181
|
-
prompt: 'Please do not close the application',
|
|
182
|
-
showLoading: true,
|
|
183
|
-
});
|
|
184
|
-
let entities: Entity[];
|
|
185
|
-
const externalConfigType = this.getImportConfigurationDescription(
|
|
186
|
-
this.currentModelLoadType,
|
|
187
|
-
);
|
|
188
|
-
if (externalConfigType) {
|
|
189
|
-
entities =
|
|
190
|
-
(yield this.editorStore.graphManagerState.graphManager.externalFormatTextToEntities(
|
|
191
|
-
this.modelText,
|
|
192
|
-
externalConfigType.key,
|
|
193
|
-
ImportMode.SCHEMA_IMPORT,
|
|
194
|
-
)) as Entity[];
|
|
195
|
-
} else {
|
|
196
|
-
switch (this.currentModelLoadType) {
|
|
197
|
-
case MODEL_UPDATER_INPUT_TYPE.PURE_PROTOCOL: {
|
|
198
|
-
entities =
|
|
199
|
-
this.editorStore.graphManagerState.graphManager.pureProtocolTextToEntities(
|
|
200
|
-
this.modelText,
|
|
201
|
-
);
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
case MODEL_UPDATER_INPUT_TYPE.ENTITIES: {
|
|
205
|
-
entities = JSON.parse(this.modelText) as Entity[];
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
case MODEL_UPDATER_INPUT_TYPE.PURE_GRAMMAR: {
|
|
209
|
-
entities =
|
|
210
|
-
(yield this.editorStore.graphManagerState.graphManager.pureCodeToEntities(
|
|
211
|
-
this.modelText,
|
|
212
|
-
)) as Entity[];
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
default:
|
|
216
|
-
throw new UnsupportedOperationError(
|
|
217
|
-
`Can't load model for input of type '${this.currentModelLoadType}'`,
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const message = `loading entities from ${
|
|
222
|
-
this.editorStore.applicationStore.config.appName
|
|
223
|
-
} [${this.replace ? `potentially affected ` : ''} ${
|
|
224
|
-
entities.length
|
|
225
|
-
} entities]`;
|
|
226
|
-
yield this.editorStore.sdlcServerClient.updateEntities(
|
|
227
|
-
this.editorStore.sdlcState.activeProject.projectId,
|
|
228
|
-
this.editorStore.sdlcState.activeWorkspace,
|
|
229
|
-
{ replace: this.replace, entities, message },
|
|
230
|
-
);
|
|
231
|
-
this.editorStore.applicationStore.navigator.reload();
|
|
232
|
-
} catch (error) {
|
|
233
|
-
assertErrorThrown(error);
|
|
234
|
-
this.editorStore.applicationStore.log.error(
|
|
235
|
-
LogEvent.create(LEGEND_STUDIO_APP_EVENT.MODEL_LOADER_FAILURE),
|
|
236
|
-
error,
|
|
237
|
-
);
|
|
238
|
-
this.editorStore.applicationStore.notifyError(error);
|
|
239
|
-
} finally {
|
|
240
|
-
this.isLoadingModel = false;
|
|
241
|
-
this.editorStore.setBlockingAlert(undefined);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
*fetchAvailableModelImportDescriptions(): GeneratorFn<void> {
|
|
246
|
-
try {
|
|
247
|
-
this.modelImportDescriptions =
|
|
248
|
-
(yield this.editorStore.graphManagerState.graphManager.getAvailableImportConfigurationDescriptions()) as ImportConfigurationDescription[];
|
|
249
|
-
} catch (error) {
|
|
250
|
-
assertErrorThrown(error);
|
|
251
|
-
this.editorStore.applicationStore.log.error(
|
|
252
|
-
LogEvent.create(LEGEND_STUDIO_APP_EVENT.MODEL_LOADER_FAILURE),
|
|
253
|
-
error,
|
|
254
|
-
);
|
|
255
|
-
this.editorStore.applicationStore.notifyError(error);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
private getExampleEntitiesInputText(): string {
|
|
260
|
-
return `// example entity\n${JSON.stringify(
|
|
261
|
-
[
|
|
262
|
-
{
|
|
263
|
-
classifierPath: 'string',
|
|
264
|
-
content: {},
|
|
265
|
-
path: 'string',
|
|
266
|
-
} as Entity,
|
|
267
|
-
],
|
|
268
|
-
undefined,
|
|
269
|
-
TAB_SIZE,
|
|
270
|
-
)}`;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
private getExamplePureProtocolInputText(): string {
|
|
274
|
-
return `// example Pure model context data\n${this.editorStore.graphManagerState.graphManager.getExamplePureProtocolText()}`;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
private getExampleExternalFormatInputText(): string {
|
|
278
|
-
return `// example external format import data\n${this.editorStore.graphManagerState.graphManager.getExampleExternalFormatImportText()}`;
|
|
279
|
-
}
|
|
280
|
-
}
|