@finos/legend-application-studio 13.1.0 → 14.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.
Files changed (115) hide show
  1. package/lib/components/EditorComponentTestUtils.d.ts +3 -13
  2. package/lib/components/EditorComponentTestUtils.d.ts.map +1 -1
  3. package/lib/components/EditorComponentTestUtils.js +3 -22
  4. package/lib/components/EditorComponentTestUtils.js.map +1 -1
  5. package/lib/components/editor/edit-panel/EditPanel.js +4 -4
  6. package/lib/components/editor/edit-panel/EditPanel.js.map +1 -1
  7. package/lib/components/editor/edit-panel/{ModelLoader.d.ts → ModelImporter.d.ts} +2 -2
  8. package/lib/components/editor/edit-panel/ModelImporter.d.ts.map +1 -0
  9. package/lib/components/editor/edit-panel/ModelImporter.js +132 -0
  10. package/lib/components/editor/edit-panel/ModelImporter.js.map +1 -0
  11. package/lib/components/editor/edit-panel/connection-editor/RelationalDatabaseConnectionEditor.d.ts.map +1 -1
  12. package/lib/components/editor/edit-panel/connection-editor/RelationalDatabaseConnectionEditor.js +10 -2
  13. package/lib/components/editor/edit-panel/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
  14. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.d.ts +7 -0
  15. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.d.ts.map +1 -1
  16. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.js +18 -42
  17. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.js.map +1 -1
  18. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.d.ts +24 -0
  19. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.d.ts.map +1 -0
  20. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.js +75 -0
  21. package/lib/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.js.map +1 -0
  22. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestDataEditor.d.ts.map +1 -1
  23. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestDataEditor.js +6 -4
  24. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestDataEditor.js.map +1 -1
  25. package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.d.ts.map +1 -1
  26. package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.js +2 -4
  27. package/lib/components/editor/edit-panel/uml-editor/AssociationEditor.js.map +1 -1
  28. package/lib/components/editor/side-bar/Explorer.js +4 -4
  29. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  30. package/lib/index.css +2 -2
  31. package/lib/index.css.map +1 -1
  32. package/lib/package.json +1 -1
  33. package/lib/stores/EditorGraphState.d.ts +1 -1
  34. package/lib/stores/EditorGraphState.d.ts.map +1 -1
  35. package/lib/stores/EditorGraphState.js +10 -10
  36. package/lib/stores/EditorGraphState.js.map +1 -1
  37. package/lib/stores/EditorStore.d.ts +3 -3
  38. package/lib/stores/EditorStore.d.ts.map +1 -1
  39. package/lib/stores/EditorStore.js +6 -8
  40. package/lib/stores/EditorStore.js.map +1 -1
  41. package/lib/stores/LegendStudioApplicationPlugin.d.ts +3 -3
  42. package/lib/stores/LegendStudioApplicationPlugin.d.ts.map +1 -1
  43. package/lib/stores/editor/NewElementState.d.ts.map +1 -1
  44. package/lib/stores/editor/NewElementState.js +4 -3
  45. package/lib/stores/editor/NewElementState.js.map +1 -1
  46. package/lib/stores/editor-state/ExternalFormatState.d.ts +3 -2
  47. package/lib/stores/editor-state/ExternalFormatState.d.ts.map +1 -1
  48. package/lib/stores/editor-state/ExternalFormatState.js +11 -8
  49. package/lib/stores/editor-state/ExternalFormatState.js.map +1 -1
  50. package/lib/stores/editor-state/ModelImporterState.d.ts +95 -0
  51. package/lib/stores/editor-state/ModelImporterState.d.ts.map +1 -0
  52. package/lib/stores/editor-state/ModelImporterState.js +358 -0
  53. package/lib/stores/editor-state/ModelImporterState.js.map +1 -0
  54. package/lib/stores/editor-state/element-editor-state/connection/ConnectionEditorState.d.ts +2 -1
  55. package/lib/stores/editor-state/element-editor-state/connection/ConnectionEditorState.d.ts.map +1 -1
  56. package/lib/stores/editor-state/element-editor-state/connection/ConnectionEditorState.js +9 -1
  57. package/lib/stores/editor-state/element-editor-state/connection/ConnectionEditorState.js.map +1 -1
  58. package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.d.ts +35 -12
  59. package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.d.ts.map +1 -1
  60. package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.js +141 -34
  61. package/lib/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.js.map +1 -1
  62. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.d.ts.map +1 -1
  63. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.js +1 -1
  64. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.js.map +1 -1
  65. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts.map +1 -1
  66. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.js +2 -2
  67. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.js.map +1 -1
  68. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.d.ts.map +1 -1
  69. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js +3 -3
  70. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js.map +1 -1
  71. package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.d.ts +1 -0
  72. package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.d.ts.map +1 -1
  73. package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.js +3 -0
  74. package/lib/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.js.map +1 -1
  75. package/lib/stores/graphModifier/StoreRelational_GraphModifierHelper.d.ts +2 -1
  76. package/lib/stores/graphModifier/StoreRelational_GraphModifierHelper.d.ts.map +1 -1
  77. package/lib/stores/graphModifier/StoreRelational_GraphModifierHelper.js +3 -0
  78. package/lib/stores/graphModifier/StoreRelational_GraphModifierHelper.js.map +1 -1
  79. package/lib/stores/shared/testable/TestableUtils.d.ts.map +1 -1
  80. package/lib/stores/shared/testable/TestableUtils.js +2 -3
  81. package/lib/stores/shared/testable/TestableUtils.js.map +1 -1
  82. package/package.json +9 -9
  83. package/src/components/EditorComponentTestUtils.tsx +2 -29
  84. package/src/components/editor/edit-panel/EditPanel.tsx +4 -4
  85. package/src/components/editor/edit-panel/ModelImporter.tsx +376 -0
  86. package/src/components/editor/edit-panel/connection-editor/RelationalDatabaseConnectionEditor.tsx +36 -0
  87. package/src/components/editor/edit-panel/external-format-editor/SchemaSetElementEditor.tsx +47 -163
  88. package/src/components/editor/edit-panel/external-format-editor/SchemaSetModelGenerationEditor.tsx +226 -0
  89. package/src/components/editor/edit-panel/service-editor/testable/ServiceTestDataEditor.tsx +63 -36
  90. package/src/components/editor/edit-panel/uml-editor/AssociationEditor.tsx +1 -7
  91. package/src/components/editor/side-bar/Explorer.tsx +8 -8
  92. package/src/stores/EditorGraphState.ts +13 -12
  93. package/src/stores/EditorStore.ts +7 -9
  94. package/src/stores/LegendStudioApplicationPlugin.ts +4 -4
  95. package/src/stores/editor/NewElementState.ts +4 -3
  96. package/src/stores/editor-state/ExternalFormatState.ts +15 -12
  97. package/src/stores/editor-state/ModelImporterState.ts +506 -0
  98. package/src/stores/editor-state/element-editor-state/connection/ConnectionEditorState.ts +10 -0
  99. package/src/stores/editor-state/element-editor-state/external-format/SchemaSetEditorState.ts +203 -46
  100. package/src/stores/editor-state/element-editor-state/service/ServiceExecutionState.ts +1 -0
  101. package/src/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +2 -1
  102. package/src/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.ts +12 -3
  103. package/src/stores/graphModifier/DSLExternalFormat_GraphModifierHelper.ts +5 -0
  104. package/src/stores/graphModifier/StoreRelational_GraphModifierHelper.ts +10 -0
  105. package/src/stores/shared/testable/TestableUtils.ts +4 -3
  106. package/tsconfig.json +3 -2
  107. package/lib/components/editor/edit-panel/ModelLoader.d.ts.map +0 -1
  108. package/lib/components/editor/edit-panel/ModelLoader.js +0 -95
  109. package/lib/components/editor/edit-panel/ModelLoader.js.map +0 -1
  110. package/lib/stores/editor-state/ModelLoaderState.d.ts +0 -52
  111. package/lib/stores/editor-state/ModelLoaderState.d.ts.map +0 -1
  112. package/lib/stores/editor-state/ModelLoaderState.js +0 -199
  113. package/lib/stores/editor-state/ModelLoaderState.js.map +0 -1
  114. package/src/components/editor/edit-panel/ModelLoader.tsx +0 -259
  115. 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
- }