@finos/legend-application-studio 22.2.1 → 22.3.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/editor/StatusBar.js +1 -1
- package/lib/components/editor/StatusBar.js.map +1 -1
- package/lib/components/editor/command-center/ProjectSearchCommand.d.ts.map +1 -1
- package/lib/components/editor/command-center/ProjectSearchCommand.js +1 -0
- package/lib/components/editor/command-center/ProjectSearchCommand.js.map +1 -1
- package/lib/components/editor/edit-panel/EditPanel.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/EditPanel.js +24 -11
- package/lib/components/editor/edit-panel/EditPanel.js.map +1 -1
- package/lib/components/editor/edit-panel/GenerationSpecificationEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/GenerationSpecificationEditor.js +2 -1
- package/lib/components/editor/edit-panel/GenerationSpecificationEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/connection-editor/ConnectionEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/connection-editor/ConnectionEditor.js +1 -0
- package/lib/components/editor/edit-panel/connection-editor/ConnectionEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.js +4 -3
- package/lib/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.d.ts +32 -0
- package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.d.ts.map +1 -0
- package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.js +66 -0
- package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.js.map +1 -0
- package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.d.ts +0 -23
- package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.js +6 -58
- package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.d.ts +41 -0
- package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.d.ts.map +1 -0
- package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.js +77 -0
- package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.js.map +1 -0
- package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.d.ts +7 -0
- package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js +19 -14
- package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.js +3 -1
- package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/mapping-editor/InstanceSetImplementationSourceSelectorModal.js +3 -1
- package/lib/components/editor/edit-panel/mapping-editor/InstanceSetImplementationSourceSelectorModal.js.map +1 -1
- package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.js +3 -0
- package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.js.map +1 -1
- package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js +3 -1
- package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js.map +1 -1
- package/lib/components/editor/edit-panel/service-editor/ServiceEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/service-editor/ServiceEditor.js +51 -13
- package/lib/components/editor/edit-panel/service-editor/ServiceEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.js +18 -10
- package/lib/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.d.ts +1 -3
- package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.js +2 -20
- package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.js.map +1 -1
- package/lib/components/editor/edit-panel/uml-editor/ClassEditor.d.ts.map +1 -1
- package/lib/components/editor/edit-panel/uml-editor/ClassEditor.js +9 -3
- package/lib/components/editor/edit-panel/uml-editor/ClassEditor.js.map +1 -1
- package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
- package/lib/components/editor/side-bar/CreateNewElementModal.js +1 -0
- package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
- package/lib/components/editor/side-bar/Explorer.d.ts.map +1 -1
- package/lib/components/editor/side-bar/Explorer.js +29 -8
- package/lib/components/editor/side-bar/Explorer.js.map +1 -1
- package/lib/components/editor/side-bar/testable/GlobalTestRunner.d.ts.map +1 -1
- package/lib/components/editor/side-bar/testable/GlobalTestRunner.js +17 -3
- package/lib/components/editor/side-bar/testable/GlobalTestRunner.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/package.json +3 -3
- package/lib/stores/DSL_Generation_LegendStudioApplicationPlugin_Extension.d.ts +2 -2
- package/lib/stores/DSL_Generation_LegendStudioApplicationPlugin_Extension.d.ts.map +1 -1
- package/lib/stores/DependencyProjectViewerHelper.d.ts +19 -0
- package/lib/stores/DependencyProjectViewerHelper.d.ts.map +1 -0
- package/lib/stores/DependencyProjectViewerHelper.js +23 -0
- package/lib/stores/DependencyProjectViewerHelper.js.map +1 -0
- package/lib/stores/EditorGraphState.d.ts +9 -2
- package/lib/stores/EditorGraphState.d.ts.map +1 -1
- package/lib/stores/EditorGraphState.js +35 -97
- package/lib/stores/EditorGraphState.js.map +1 -1
- package/lib/stores/EditorStore.d.ts.map +1 -1
- package/lib/stores/EditorStore.js +7 -1
- package/lib/stores/EditorStore.js.map +1 -1
- package/lib/stores/EditorTabManagerState.d.ts +1 -1
- package/lib/stores/EditorTabManagerState.d.ts.map +1 -1
- package/lib/stores/EditorTabManagerState.js +11 -13
- package/lib/stores/EditorTabManagerState.js.map +1 -1
- package/lib/stores/ExplorerTreeState.d.ts +4 -4
- package/lib/stores/ExplorerTreeState.d.ts.map +1 -1
- package/lib/stores/ExplorerTreeState.js +12 -13
- package/lib/stores/ExplorerTreeState.js.map +1 -1
- package/lib/stores/editor/NewElementState.d.ts.map +1 -1
- package/lib/stores/editor/NewElementState.js +0 -3
- package/lib/stores/editor/NewElementState.js.map +1 -1
- package/lib/stores/editor-state/ExternalFormatState.d.ts +2 -0
- package/lib/stores/editor-state/ExternalFormatState.d.ts.map +1 -1
- package/lib/stores/editor-state/ExternalFormatState.js +6 -0
- package/lib/stores/editor-state/ExternalFormatState.js.map +1 -1
- package/lib/stores/editor-state/FileGenerationState.d.ts +18 -18
- package/lib/stores/editor-state/FileGenerationState.d.ts.map +1 -1
- package/lib/stores/editor-state/FileGenerationState.js +86 -133
- package/lib/stores/editor-state/FileGenerationState.js.map +1 -1
- package/lib/stores/editor-state/FileGenerationViewerState.d.ts +3 -3
- package/lib/stores/editor-state/FileGenerationViewerState.d.ts.map +1 -1
- package/lib/stores/editor-state/FileGenerationViewerState.js.map +1 -1
- package/lib/stores/editor-state/FileSystemState.d.ts +30 -0
- package/lib/stores/editor-state/FileSystemState.d.ts.map +1 -0
- package/lib/stores/editor-state/FileSystemState.js +82 -0
- package/lib/stores/editor-state/FileSystemState.js.map +1 -0
- package/lib/stores/editor-state/GraphGenerationState.d.ts +9 -9
- package/lib/stores/editor-state/GraphGenerationState.d.ts.map +1 -1
- package/lib/stores/editor-state/GraphGenerationState.js +14 -15
- package/lib/stores/editor-state/GraphGenerationState.js.map +1 -1
- package/lib/stores/editor-state/element-editor-state/ElementEditorState.d.ts +25 -2
- package/lib/stores/editor-state/element-editor-state/ElementEditorState.d.ts.map +1 -1
- package/lib/stores/editor-state/element-editor-state/ElementEditorState.js +50 -7
- package/lib/stores/editor-state/element-editor-state/ElementEditorState.js.map +1 -1
- package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.d.ts +44 -0
- package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.d.ts.map +1 -0
- package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.js +172 -0
- package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.js.map +1 -0
- package/lib/stores/editor-state/element-editor-state/mapping/MappingExecutionState.js +1 -1
- package/lib/stores/editor-state/element-editor-state/mapping/MappingExecutionState.js.map +1 -1
- package/lib/stores/editor-state/element-editor-state/mapping/MappingTestState.js +2 -2
- package/lib/stores/editor-state/element-editor-state/mapping/MappingTestState.js.map +1 -1
- package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.d.ts +3 -0
- package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
- package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.js +14 -2
- package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
- package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.d.ts +9 -6
- 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 +38 -28
- package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.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 +6 -3
- package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js.map +1 -1
- package/lib/stores/shared/FileSystemTreeUtils.d.ts +56 -0
- package/lib/stores/shared/FileSystemTreeUtils.d.ts.map +1 -0
- package/lib/stores/shared/{FileGenerationTreeUtils.js → FileSystemTreeUtils.js} +31 -32
- package/lib/stores/shared/FileSystemTreeUtils.js.map +1 -0
- package/lib/stores/shared/PackageTreeUtils.d.ts +6 -4
- package/lib/stores/shared/PackageTreeUtils.d.ts.map +1 -1
- package/lib/stores/shared/PackageTreeUtils.js +90 -11
- package/lib/stores/shared/PackageTreeUtils.js.map +1 -1
- package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.d.ts +3 -3
- package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.d.ts.map +1 -1
- package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.js +37 -1
- package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.js.map +1 -1
- package/package.json +12 -12
- package/src/components/editor/StatusBar.tsx +1 -1
- package/src/components/editor/command-center/ProjectSearchCommand.tsx +1 -0
- package/src/components/editor/edit-panel/EditPanel.tsx +79 -25
- package/src/components/editor/edit-panel/GenerationSpecificationEditor.tsx +2 -1
- package/src/components/editor/edit-panel/connection-editor/ConnectionEditor.tsx +1 -0
- package/src/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.tsx +5 -7
- package/src/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.tsx +194 -0
- package/src/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.tsx +6 -270
- package/src/components/editor/edit-panel/element-generation-editor/FileSystemViewer.tsx +296 -0
- package/src/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.tsx +177 -155
- package/src/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.tsx +3 -1
- package/src/components/editor/edit-panel/mapping-editor/InstanceSetImplementationSourceSelectorModal.tsx +3 -3
- package/src/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.tsx +3 -0
- package/src/components/editor/edit-panel/mapping-editor/NewMappingElementModal.tsx +3 -1
- package/src/components/editor/edit-panel/service-editor/ServiceEditor.tsx +243 -184
- package/src/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.tsx +42 -15
- package/src/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.tsx +2 -65
- package/src/components/editor/edit-panel/uml-editor/ClassEditor.tsx +9 -3
- package/src/components/editor/side-bar/CreateNewElementModal.tsx +1 -0
- package/src/components/editor/side-bar/Explorer.tsx +82 -13
- package/src/components/editor/side-bar/testable/GlobalTestRunner.tsx +31 -9
- package/src/index.ts +5 -2
- package/src/stores/DSL_Generation_LegendStudioApplicationPlugin_Extension.ts +2 -2
- package/src/stores/DependencyProjectViewerHelper.ts +39 -0
- package/src/stores/EditorGraphState.ts +56 -155
- package/src/stores/EditorStore.ts +15 -5
- package/src/stores/EditorTabManagerState.ts +17 -20
- package/src/stores/ExplorerTreeState.ts +26 -18
- package/src/stores/editor/NewElementState.ts +0 -2
- package/src/stores/editor-state/ExternalFormatState.ts +9 -0
- package/src/stores/editor-state/FileGenerationState.ts +129 -180
- package/src/stores/editor-state/FileGenerationViewerState.ts +3 -3
- package/src/stores/editor-state/FileSystemState.ts +111 -0
- package/src/stores/editor-state/GraphGenerationState.ts +35 -31
- package/src/stores/editor-state/element-editor-state/ElementEditorState.ts +91 -6
- package/src/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.ts +266 -0
- package/src/stores/editor-state/element-editor-state/mapping/MappingExecutionState.ts +1 -1
- package/src/stores/editor-state/element-editor-state/mapping/MappingTestState.ts +2 -2
- package/src/stores/editor-state/element-editor-state/service/ServiceEditorState.ts +23 -2
- package/src/stores/editor-state/element-editor-state/service/ServiceExecutionState.ts +60 -55
- package/src/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.ts +6 -2
- package/src/stores/shared/{FileGenerationTreeUtils.ts → FileSystemTreeUtils.ts} +77 -76
- package/src/stores/shared/PackageTreeUtils.ts +144 -10
- package/src/stores/sidebar-state/testable/GlobalTestRunnerState.ts +42 -3
- package/tsconfig.json +6 -1
- package/lib/stores/shared/FileGenerationTreeUtils.d.ts +0 -56
- package/lib/stores/shared/FileGenerationTreeUtils.d.ts.map +0 -1
- package/lib/stores/shared/FileGenerationTreeUtils.js.map +0 -1
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
type GeneratorFn,
|
|
23
23
|
LogEvent,
|
|
24
24
|
assertErrorThrown,
|
|
25
|
+
guaranteeNonNullable,
|
|
25
26
|
} from '@finos/legend-shared';
|
|
26
27
|
import {
|
|
27
28
|
type CompilationError,
|
|
@@ -30,6 +31,8 @@ import {
|
|
|
30
31
|
isElementReadOnly,
|
|
31
32
|
} from '@finos/legend-graph';
|
|
32
33
|
import { TAB_SIZE } from '@finos/legend-application';
|
|
34
|
+
import type { ElementFileGenerationState } from './ElementFileGenerationState.js';
|
|
35
|
+
import type { ElementXTSchemaGenerationState } from './ElementExternalFormatGenerationState.js';
|
|
33
36
|
|
|
34
37
|
const generateMultiLineCommentForError = (
|
|
35
38
|
message: string,
|
|
@@ -37,10 +40,64 @@ const generateMultiLineCommentForError = (
|
|
|
37
40
|
): string =>
|
|
38
41
|
`/**\n * ${message}. Error: ${error.message.replace(/\n/gu, '\n * ')}\n */`;
|
|
39
42
|
|
|
43
|
+
export enum ELEMENT_GENERATION_MODE {
|
|
44
|
+
FILE_GENERATION = 'FILE_GENERATION',
|
|
45
|
+
EXTERNAL_FORMAT = 'EXTERNAL_FORMAT',
|
|
46
|
+
}
|
|
47
|
+
export abstract class ElementGenerationModeState {
|
|
48
|
+
elementEditorState: ElementEditorState;
|
|
49
|
+
editorStore: EditorStore;
|
|
50
|
+
|
|
51
|
+
constructor(
|
|
52
|
+
editorStore: EditorStore,
|
|
53
|
+
elementEditorState: ElementEditorState,
|
|
54
|
+
) {
|
|
55
|
+
this.elementEditorState = elementEditorState;
|
|
56
|
+
this.editorStore = editorStore;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
abstract get label(): string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class ExternalFormatElementGenerationViewModeState extends ElementGenerationModeState {
|
|
63
|
+
generationState: ElementXTSchemaGenerationState;
|
|
64
|
+
|
|
65
|
+
constructor(
|
|
66
|
+
editorStore: EditorStore,
|
|
67
|
+
elementEditorState: ElementEditorState,
|
|
68
|
+
generationState: ElementXTSchemaGenerationState,
|
|
69
|
+
) {
|
|
70
|
+
super(editorStore, elementEditorState);
|
|
71
|
+
this.generationState = generationState;
|
|
72
|
+
}
|
|
73
|
+
get label(): string {
|
|
74
|
+
return this.generationState.description.name;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class FileGenerationViewModeState extends ElementGenerationModeState {
|
|
79
|
+
elementGenerationState: ElementFileGenerationState;
|
|
80
|
+
|
|
81
|
+
constructor(
|
|
82
|
+
editorStore: EditorStore,
|
|
83
|
+
elementEditorState: ElementEditorState,
|
|
84
|
+
elementGenerationState: ElementFileGenerationState,
|
|
85
|
+
) {
|
|
86
|
+
super(editorStore, elementEditorState);
|
|
87
|
+
this.elementGenerationState = elementGenerationState;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get label(): string {
|
|
91
|
+
return this.editorStore.graphState.graphGenerationState.getFileGenerationConfiguration(
|
|
92
|
+
this.elementGenerationState.fileGenerationType,
|
|
93
|
+
).label;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
40
97
|
export abstract class ElementEditorState extends EditorState {
|
|
41
98
|
element: PackageableElement;
|
|
42
99
|
editMode = ELEMENT_NATIVE_VIEW_MODE.FORM;
|
|
43
|
-
|
|
100
|
+
generationModeState: ElementGenerationModeState | undefined;
|
|
44
101
|
textContent = '';
|
|
45
102
|
isReadOnly = false;
|
|
46
103
|
|
|
@@ -50,15 +107,15 @@ export abstract class ElementEditorState extends EditorState {
|
|
|
50
107
|
makeObservable(this, {
|
|
51
108
|
element: observable,
|
|
52
109
|
editMode: observable,
|
|
53
|
-
generationViewMode: observable,
|
|
54
110
|
textContent: observable,
|
|
55
111
|
isReadOnly: observable,
|
|
112
|
+
generationModeState: observable,
|
|
56
113
|
label: computed,
|
|
57
114
|
description: computed,
|
|
58
115
|
elementPath: computed,
|
|
59
116
|
setTextContent: action,
|
|
60
117
|
setEditMode: action,
|
|
61
|
-
|
|
118
|
+
changeGenerationModeState: action,
|
|
62
119
|
generateElementProtocol: action,
|
|
63
120
|
generateElementGrammar: flow,
|
|
64
121
|
});
|
|
@@ -91,11 +148,39 @@ export abstract class ElementEditorState extends EditorState {
|
|
|
91
148
|
this.editMode = mode;
|
|
92
149
|
// changing edit mode will clear any existing generation view mode
|
|
93
150
|
// as edit mode always takes precedence
|
|
94
|
-
this.
|
|
151
|
+
this.setGenerationModeState(undefined);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
setGenerationModeState(state: ElementGenerationModeState | undefined): void {
|
|
155
|
+
this.generationModeState = state;
|
|
95
156
|
}
|
|
96
157
|
|
|
97
|
-
|
|
98
|
-
|
|
158
|
+
changeGenerationModeState(mode: string, type: ELEMENT_GENERATION_MODE): void {
|
|
159
|
+
if (type === ELEMENT_GENERATION_MODE.FILE_GENERATION) {
|
|
160
|
+
const elementGenerationState =
|
|
161
|
+
this.editorStore.elementGenerationStates.find(
|
|
162
|
+
(state) => state.fileGenerationType === mode,
|
|
163
|
+
);
|
|
164
|
+
this.setGenerationModeState(
|
|
165
|
+
new FileGenerationViewModeState(
|
|
166
|
+
this.editorStore,
|
|
167
|
+
this,
|
|
168
|
+
guaranteeNonNullable(elementGenerationState),
|
|
169
|
+
),
|
|
170
|
+
);
|
|
171
|
+
} else {
|
|
172
|
+
const xt =
|
|
173
|
+
this.editorStore.graphState.graphGenerationState.externalFormatState.schemaGenerationStates.find(
|
|
174
|
+
(e) => e.description.name === mode,
|
|
175
|
+
);
|
|
176
|
+
this.setGenerationModeState(
|
|
177
|
+
new ExternalFormatElementGenerationViewModeState(
|
|
178
|
+
this.editorStore,
|
|
179
|
+
this,
|
|
180
|
+
guaranteeNonNullable(xt),
|
|
181
|
+
),
|
|
182
|
+
);
|
|
183
|
+
}
|
|
99
184
|
}
|
|
100
185
|
|
|
101
186
|
generateElementProtocol(): void {
|
|
@@ -0,0 +1,266 @@
|
|
|
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
|
+
type ExternalFormatDescription,
|
|
19
|
+
type GenerationProperty,
|
|
20
|
+
type SchemaSet,
|
|
21
|
+
GenerationOutput,
|
|
22
|
+
ConfigurationProperty,
|
|
23
|
+
ModelUnit,
|
|
24
|
+
observe_ModelUnit,
|
|
25
|
+
GenerationPropertyItemType,
|
|
26
|
+
PackageableElementExplicitReference,
|
|
27
|
+
} from '@finos/legend-graph';
|
|
28
|
+
import {
|
|
29
|
+
type GeneratorFn,
|
|
30
|
+
uuid,
|
|
31
|
+
assertErrorThrown,
|
|
32
|
+
LogEvent,
|
|
33
|
+
isEmpty,
|
|
34
|
+
deepEqual,
|
|
35
|
+
AssertionError,
|
|
36
|
+
} from '@finos/legend-shared';
|
|
37
|
+
import { action, flow, flowResult, makeObservable, observable } from 'mobx';
|
|
38
|
+
import type { EditorStore } from '../../EditorStore.js';
|
|
39
|
+
import { LEGEND_STUDIO_APP_EVENT } from '../../LegendStudioAppEvent.js';
|
|
40
|
+
import { GENERATION_FILE_ROOT_NAME } from '../../shared/FileSystemTreeUtils.js';
|
|
41
|
+
import {
|
|
42
|
+
configurationProperty_addConfigurationProperty,
|
|
43
|
+
configurationProperty_setValue,
|
|
44
|
+
} from '../../shared/modifier/DSL_Generation_GraphModifierHelper.js';
|
|
45
|
+
import { GeneratedFileStructureState } from '../FileGenerationState.js';
|
|
46
|
+
import { ElementEditorState } from './ElementEditorState.js';
|
|
47
|
+
|
|
48
|
+
export class ExternalFormatConfigurationSpecification {
|
|
49
|
+
configurationProperties: ConfigurationProperty[] = [];
|
|
50
|
+
modelUnit: ModelUnit;
|
|
51
|
+
|
|
52
|
+
constructor() {
|
|
53
|
+
makeObservable(this, {
|
|
54
|
+
configurationProperties: observable,
|
|
55
|
+
});
|
|
56
|
+
this.modelUnit = observe_ModelUnit(new ModelUnit());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const getNullableFileGenerationConfig = (
|
|
61
|
+
config: ExternalFormatConfigurationSpecification,
|
|
62
|
+
name: string,
|
|
63
|
+
): ConfigurationProperty | undefined =>
|
|
64
|
+
config.configurationProperties.find((property) => name === property.name);
|
|
65
|
+
|
|
66
|
+
export class XTGenerationState extends GeneratedFileStructureState {
|
|
67
|
+
readonly elementXTSchemaGenerationState: ElementXTSchemaGenerationState;
|
|
68
|
+
readonly configSpecification: ExternalFormatConfigurationSpecification;
|
|
69
|
+
|
|
70
|
+
constructor(
|
|
71
|
+
elementXTSchemaGenerationState: ElementXTSchemaGenerationState,
|
|
72
|
+
fileGeneration: ExternalFormatConfigurationSpecification,
|
|
73
|
+
) {
|
|
74
|
+
super(
|
|
75
|
+
GENERATION_FILE_ROOT_NAME,
|
|
76
|
+
elementXTSchemaGenerationState.editorStore,
|
|
77
|
+
);
|
|
78
|
+
makeObservable(this, {
|
|
79
|
+
configSpecification: observable,
|
|
80
|
+
resetGenerator: action,
|
|
81
|
+
updateFileGenerationParameters: action,
|
|
82
|
+
generate: flow,
|
|
83
|
+
});
|
|
84
|
+
this.elementXTSchemaGenerationState = elementXTSchemaGenerationState;
|
|
85
|
+
this.configSpecification = fileGeneration;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get rootFolder(): string {
|
|
89
|
+
return '';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get generationParentId(): undefined {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
resetGenerator(): void {
|
|
97
|
+
this.configSpecification.configurationProperties = [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
*generate(): GeneratorFn<void> {
|
|
101
|
+
this.generatingAction.inProgress();
|
|
102
|
+
try {
|
|
103
|
+
const modelUnit = this.configSpecification.modelUnit;
|
|
104
|
+
const properties = [...this.configSpecification.configurationProperties];
|
|
105
|
+
this.addInferredConfigurationProperties(properties);
|
|
106
|
+
const result =
|
|
107
|
+
(yield this.editorStore.graphManagerState.graphManager.generateSchemaFromExternalFormatConfig(
|
|
108
|
+
modelUnit,
|
|
109
|
+
undefined,
|
|
110
|
+
properties,
|
|
111
|
+
this.editorStore.graphManagerState.graph,
|
|
112
|
+
)) as SchemaSet[];
|
|
113
|
+
const output = result
|
|
114
|
+
.map((schemaSet) =>
|
|
115
|
+
schemaSet.schemas.map((e) => {
|
|
116
|
+
const o = new GenerationOutput();
|
|
117
|
+
o.content = e.content;
|
|
118
|
+
o.fileName = e.location ?? '';
|
|
119
|
+
o.format = schemaSet.format;
|
|
120
|
+
return o;
|
|
121
|
+
}),
|
|
122
|
+
)
|
|
123
|
+
.flat();
|
|
124
|
+
this.processGenerationResult(output);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
assertErrorThrown(error);
|
|
127
|
+
this.fileSystemState.selectedNode = undefined;
|
|
128
|
+
this.processGenerationResult([]);
|
|
129
|
+
this.editorStore.applicationStore.log.error(
|
|
130
|
+
LogEvent.create(LEGEND_STUDIO_APP_EVENT.GENERATION_FAILURE),
|
|
131
|
+
error,
|
|
132
|
+
);
|
|
133
|
+
this.editorStore.applicationStore.notifyError(error);
|
|
134
|
+
} finally {
|
|
135
|
+
this.generatingAction.complete();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
addInferredConfigurationProperties(
|
|
140
|
+
properties: ConfigurationProperty[],
|
|
141
|
+
): void {
|
|
142
|
+
const SCHEMA_FORMAT_PROPERTY_NAME = 'format';
|
|
143
|
+
if (!properties.find((e) => e.name === SCHEMA_FORMAT_PROPERTY_NAME)) {
|
|
144
|
+
const genProperty = new ConfigurationProperty(
|
|
145
|
+
SCHEMA_FORMAT_PROPERTY_NAME,
|
|
146
|
+
this.elementXTSchemaGenerationState.description.name,
|
|
147
|
+
);
|
|
148
|
+
properties.push(genProperty);
|
|
149
|
+
}
|
|
150
|
+
this.elementXTSchemaGenerationState.description.schemaGenerationProperties
|
|
151
|
+
.filter(
|
|
152
|
+
(property) =>
|
|
153
|
+
property.required &&
|
|
154
|
+
property.defaultValue &&
|
|
155
|
+
!properties.find((pv) => pv.name === property.name),
|
|
156
|
+
)
|
|
157
|
+
.forEach((toAdd) => {
|
|
158
|
+
const value = new ConfigurationProperty(toAdd.name, toAdd.defaultValue);
|
|
159
|
+
configurationProperty_addConfigurationProperty(properties, value);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
updateFileGenerationParameters(
|
|
164
|
+
config: ExternalFormatConfigurationSpecification,
|
|
165
|
+
generationProperty: GenerationProperty,
|
|
166
|
+
newValue: unknown,
|
|
167
|
+
): void {
|
|
168
|
+
if (generationProperty.type === GenerationPropertyItemType.MAP) {
|
|
169
|
+
if (
|
|
170
|
+
!newValue ||
|
|
171
|
+
isEmpty(newValue) ||
|
|
172
|
+
deepEqual(newValue, generationProperty.defaultValue)
|
|
173
|
+
) {
|
|
174
|
+
config.configurationProperties = config.configurationProperties.filter(
|
|
175
|
+
(e) => e.name !== generationProperty.name,
|
|
176
|
+
);
|
|
177
|
+
} else {
|
|
178
|
+
const configProperty = getNullableFileGenerationConfig(
|
|
179
|
+
config,
|
|
180
|
+
generationProperty.name,
|
|
181
|
+
);
|
|
182
|
+
if (configProperty) {
|
|
183
|
+
configurationProperty_setValue(configProperty, {
|
|
184
|
+
...(newValue as object),
|
|
185
|
+
});
|
|
186
|
+
} else {
|
|
187
|
+
const newItem = new ConfigurationProperty(
|
|
188
|
+
generationProperty.name,
|
|
189
|
+
newValue,
|
|
190
|
+
);
|
|
191
|
+
configurationProperty_addConfigurationProperty(
|
|
192
|
+
config.configurationProperties,
|
|
193
|
+
newItem,
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
const configProperty = getNullableFileGenerationConfig(
|
|
199
|
+
config,
|
|
200
|
+
generationProperty.name,
|
|
201
|
+
);
|
|
202
|
+
let useDefaultValue = generationProperty.defaultValue === newValue;
|
|
203
|
+
if (generationProperty.type === GenerationPropertyItemType.BOOLEAN) {
|
|
204
|
+
useDefaultValue =
|
|
205
|
+
(generationProperty.defaultValue === 'true') ===
|
|
206
|
+
(newValue as boolean);
|
|
207
|
+
}
|
|
208
|
+
const newConfigValue = useDefaultValue ? undefined : newValue;
|
|
209
|
+
if (newConfigValue !== undefined) {
|
|
210
|
+
if (configProperty) {
|
|
211
|
+
configurationProperty_setValue(configProperty, newConfigValue);
|
|
212
|
+
} else {
|
|
213
|
+
const newItem = new ConfigurationProperty(
|
|
214
|
+
generationProperty.name,
|
|
215
|
+
newConfigValue,
|
|
216
|
+
);
|
|
217
|
+
configurationProperty_addConfigurationProperty(
|
|
218
|
+
config.configurationProperties,
|
|
219
|
+
newItem,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
} else {
|
|
223
|
+
config.configurationProperties = config.configurationProperties.filter(
|
|
224
|
+
(e) => e.name !== generationProperty.name,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export class ElementXTSchemaGenerationState {
|
|
232
|
+
readonly uuid = uuid();
|
|
233
|
+
editorStore: EditorStore;
|
|
234
|
+
description: ExternalFormatDescription;
|
|
235
|
+
xtGenerationState: XTGenerationState;
|
|
236
|
+
|
|
237
|
+
constructor(
|
|
238
|
+
editorStore: EditorStore,
|
|
239
|
+
description: ExternalFormatDescription,
|
|
240
|
+
) {
|
|
241
|
+
makeObservable(this, {
|
|
242
|
+
xtGenerationState: observable,
|
|
243
|
+
regenerate: flow,
|
|
244
|
+
});
|
|
245
|
+
this.editorStore = editorStore;
|
|
246
|
+
this.description = description;
|
|
247
|
+
|
|
248
|
+
this.xtGenerationState = new XTGenerationState(
|
|
249
|
+
this,
|
|
250
|
+
new ExternalFormatConfigurationSpecification(),
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
*regenerate(): GeneratorFn<void> {
|
|
255
|
+
const currentState = this.editorStore.tabManagerState.currentTab;
|
|
256
|
+
if (currentState instanceof ElementEditorState) {
|
|
257
|
+
this.xtGenerationState.configSpecification.modelUnit.packageableElementIncludes =
|
|
258
|
+
[PackageableElementExplicitReference.create(currentState.element)];
|
|
259
|
+
yield flowResult(this.xtGenerationState.generate());
|
|
260
|
+
} else {
|
|
261
|
+
throw new AssertionError(
|
|
262
|
+
'Generation state must have at least an element editor opened',
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
@@ -760,7 +760,7 @@ export class MappingExecutionState extends MappingEditorTabState {
|
|
|
760
760
|
) {
|
|
761
761
|
this.isExecuting = true;
|
|
762
762
|
const result =
|
|
763
|
-
(yield this.editorStore.graphManagerState.graphManager.
|
|
763
|
+
(yield this.editorStore.graphManagerState.graphManager.runQuery(
|
|
764
764
|
query,
|
|
765
765
|
this.mappingEditorState.mapping,
|
|
766
766
|
runtime,
|
|
@@ -647,7 +647,7 @@ export class MappingTestState extends MappingEditorTabState {
|
|
|
647
647
|
const runtime = this.inputDataState.runtime;
|
|
648
648
|
this.isExecutingTest = true;
|
|
649
649
|
const result =
|
|
650
|
-
(yield this.editorStore.graphManagerState.graphManager.
|
|
650
|
+
(yield this.editorStore.graphManagerState.graphManager.runQuery(
|
|
651
651
|
query,
|
|
652
652
|
this.mappingEditorState.mapping,
|
|
653
653
|
runtime,
|
|
@@ -707,7 +707,7 @@ export class MappingTestState extends MappingEditorTabState {
|
|
|
707
707
|
try {
|
|
708
708
|
const runtime = this.inputDataState.runtime;
|
|
709
709
|
this.isRunningTest = true;
|
|
710
|
-
promise = this.editorStore.graphManagerState.graphManager.
|
|
710
|
+
promise = this.editorStore.graphManagerState.graphManager.runQuery(
|
|
711
711
|
this.test.query,
|
|
712
712
|
this.mappingEditorState.mapping,
|
|
713
713
|
runtime,
|
|
@@ -14,8 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { observable, computed, action, makeObservable } from 'mobx';
|
|
18
|
-
import {
|
|
17
|
+
import { observable, computed, action, makeObservable, flow } from 'mobx';
|
|
18
|
+
import {
|
|
19
|
+
type GeneratorFn,
|
|
20
|
+
type PlainObject,
|
|
21
|
+
assertErrorThrown,
|
|
22
|
+
guaranteeType,
|
|
23
|
+
} from '@finos/legend-shared';
|
|
19
24
|
import type { EditorStore } from '../../../EditorStore.js';
|
|
20
25
|
import {
|
|
21
26
|
type ServiceExecutionState,
|
|
@@ -33,6 +38,7 @@ import {
|
|
|
33
38
|
PureMultiExecution,
|
|
34
39
|
} from '@finos/legend-graph';
|
|
35
40
|
import { ServiceTestableState } from './testable/ServiceTestableState.js';
|
|
41
|
+
import { User } from '@finos/legend-server-sdlc';
|
|
36
42
|
|
|
37
43
|
export enum SERVICE_TAB {
|
|
38
44
|
GENERAL = 'GENERAL',
|
|
@@ -59,6 +65,7 @@ export class ServiceEditorState extends ElementEditorState {
|
|
|
59
65
|
resetExecutionState: action,
|
|
60
66
|
service: computed,
|
|
61
67
|
reprocess: action,
|
|
68
|
+
searchUsers: flow,
|
|
62
69
|
});
|
|
63
70
|
|
|
64
71
|
this.executionState = this.buildExecutionState();
|
|
@@ -119,6 +126,20 @@ export class ServiceEditorState extends ElementEditorState {
|
|
|
119
126
|
);
|
|
120
127
|
}
|
|
121
128
|
|
|
129
|
+
*searchUsers(name: string): GeneratorFn<User[]> {
|
|
130
|
+
try {
|
|
131
|
+
return (
|
|
132
|
+
(yield this.editorStore.sdlcServerClient.getUsers(
|
|
133
|
+
name,
|
|
134
|
+
)) as PlainObject<User>[]
|
|
135
|
+
).map((p) => User.serialization.fromJson(p));
|
|
136
|
+
} catch (error) {
|
|
137
|
+
assertErrorThrown(error);
|
|
138
|
+
this.editorStore.applicationStore.notifyError(error);
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
122
143
|
reprocess(
|
|
123
144
|
newElement: PackageableElement,
|
|
124
145
|
editorStore: EditorStore,
|