@finos/legend-application-studio 28.8.0 → 28.9.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 (81) hide show
  1. package/lib/__lib__/LegendStudioNavigation.d.ts +6 -0
  2. package/lib/__lib__/LegendStudioNavigation.d.ts.map +1 -1
  3. package/lib/__lib__/LegendStudioNavigation.js +5 -0
  4. package/lib/__lib__/LegendStudioNavigation.js.map +1 -1
  5. package/lib/components/LegendStudioWebApplication.d.ts.map +1 -1
  6. package/lib/components/LegendStudioWebApplication.js +4 -1
  7. package/lib/components/LegendStudioWebApplication.js.map +1 -1
  8. package/lib/components/ShowcaseManager.d.ts.map +1 -1
  9. package/lib/components/ShowcaseManager.js +6 -1
  10. package/lib/components/ShowcaseManager.js.map +1 -1
  11. package/lib/components/editor/editor-group/GrammarTextEditor.js +1 -1
  12. package/lib/components/editor/editor-group/GrammarTextEditor.js.map +1 -1
  13. package/lib/components/editor/side-bar/Explorer.d.ts.map +1 -1
  14. package/lib/components/editor/side-bar/Explorer.js +3 -2
  15. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  16. package/lib/components/project-view/ProjectViewer.d.ts.map +1 -1
  17. package/lib/components/project-view/ProjectViewer.js +37 -5
  18. package/lib/components/project-view/ProjectViewer.js.map +1 -1
  19. package/lib/components/showcase/ShowcaseViewer.d.ts +18 -0
  20. package/lib/components/showcase/ShowcaseViewer.d.ts.map +1 -0
  21. package/lib/components/showcase/ShowcaseViewer.js +147 -0
  22. package/lib/components/showcase/ShowcaseViewer.js.map +1 -0
  23. package/lib/components/showcase/ShowcaseViewerStoreProvider.d.ts +23 -0
  24. package/lib/components/showcase/ShowcaseViewerStoreProvider.d.ts.map +1 -0
  25. package/lib/components/showcase/ShowcaseViewerStoreProvider.js +36 -0
  26. package/lib/components/showcase/ShowcaseViewerStoreProvider.js.map +1 -0
  27. package/lib/index.css +2 -2
  28. package/lib/index.css.map +1 -1
  29. package/lib/package.json +1 -1
  30. package/lib/stores/LegendStudioBaseStore.d.ts.map +1 -1
  31. package/lib/stores/LegendStudioBaseStore.js +1 -0
  32. package/lib/stores/LegendStudioBaseStore.js.map +1 -1
  33. package/lib/stores/editor/EditorMode.d.ts +4 -0
  34. package/lib/stores/editor/EditorMode.d.ts.map +1 -1
  35. package/lib/stores/editor/EditorMode.js +9 -0
  36. package/lib/stores/editor/EditorMode.js.map +1 -1
  37. package/lib/stores/editor/EditorStore.d.ts.map +1 -1
  38. package/lib/stores/editor/EditorStore.js +1 -3
  39. package/lib/stores/editor/EditorStore.js.map +1 -1
  40. package/lib/stores/editor/StandardEditorMode.d.ts +1 -0
  41. package/lib/stores/editor/StandardEditorMode.d.ts.map +1 -1
  42. package/lib/stores/editor/StandardEditorMode.js +4 -0
  43. package/lib/stores/editor/StandardEditorMode.js.map +1 -1
  44. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts.map +1 -1
  45. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js +20 -4
  46. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js.map +1 -1
  47. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.d.ts +3 -0
  48. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.d.ts.map +1 -1
  49. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.js +17 -2
  50. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.js.map +1 -1
  51. package/lib/stores/project-view/ProjectViewerEditorMode.d.ts +3 -0
  52. package/lib/stores/project-view/ProjectViewerEditorMode.d.ts.map +1 -1
  53. package/lib/stores/project-view/ProjectViewerEditorMode.js +10 -0
  54. package/lib/stores/project-view/ProjectViewerEditorMode.js.map +1 -1
  55. package/lib/stores/showcase/ShowcaseViewerEditorMode.d.ts +28 -0
  56. package/lib/stores/showcase/ShowcaseViewerEditorMode.d.ts.map +1 -0
  57. package/lib/stores/showcase/ShowcaseViewerEditorMode.js +40 -0
  58. package/lib/stores/showcase/ShowcaseViewerEditorMode.js.map +1 -0
  59. package/lib/stores/showcase/ShowcaseViewerStore.d.ts +32 -0
  60. package/lib/stores/showcase/ShowcaseViewerStore.d.ts.map +1 -0
  61. package/lib/stores/showcase/ShowcaseViewerStore.js +189 -0
  62. package/lib/stores/showcase/ShowcaseViewerStore.js.map +1 -0
  63. package/package.json +7 -7
  64. package/src/__lib__/LegendStudioNavigation.ts +11 -0
  65. package/src/components/LegendStudioWebApplication.tsx +11 -1
  66. package/src/components/ShowcaseManager.tsx +26 -2
  67. package/src/components/editor/editor-group/GrammarTextEditor.tsx +1 -1
  68. package/src/components/editor/side-bar/Explorer.tsx +20 -12
  69. package/src/components/project-view/ProjectViewer.tsx +139 -4
  70. package/src/components/showcase/ShowcaseViewer.tsx +418 -0
  71. package/src/components/showcase/ShowcaseViewerStoreProvider.tsx +56 -0
  72. package/src/stores/LegendStudioBaseStore.ts +1 -0
  73. package/src/stores/editor/EditorMode.ts +14 -0
  74. package/src/stores/editor/EditorStore.ts +1 -8
  75. package/src/stores/editor/StandardEditorMode.ts +7 -0
  76. package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.ts +31 -9
  77. package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.ts +23 -0
  78. package/src/stores/project-view/ProjectViewerEditorMode.ts +17 -0
  79. package/src/stores/showcase/ShowcaseViewerEditorMode.ts +51 -0
  80. package/src/stores/showcase/ShowcaseViewerStore.ts +285 -0
  81. package/tsconfig.json +4 -0
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import type { ProjectDependency } from '@finos/legend-server-sdlc';
18
+ import { EditorMode } from '../editor/EditorMode.js';
19
+ import type { ShowcaseViewerStore } from './ShowcaseViewerStore.js';
20
+ import { generateShowcasePath } from '../../__lib__/LegendStudioNavigation.js';
21
+
22
+ export class ShowcaseViewerEditorMode extends EditorMode {
23
+ readonly showcaseViewerStore: ShowcaseViewerStore;
24
+
25
+ constructor(showcaseViewerStore: ShowcaseViewerStore) {
26
+ super();
27
+ this.showcaseViewerStore = showcaseViewerStore;
28
+ }
29
+
30
+ override generateElementLink(elementPath: string): string {
31
+ return generateShowcasePath(this.showcaseViewerStore.showcase.path);
32
+ }
33
+ override generateDependencyElementLink(
34
+ elementPath: string,
35
+ dependencyProject: ProjectDependency,
36
+ ): string {
37
+ return generateShowcasePath(this.showcaseViewerStore.showcase.path);
38
+ }
39
+
40
+ override get isInitialized(): boolean {
41
+ return Boolean(this.showcaseViewerStore._showcase);
42
+ }
43
+
44
+ override get supportSdlcOperations(): boolean {
45
+ return false;
46
+ }
47
+
48
+ override get label(): string {
49
+ return 'Showcase View';
50
+ }
51
+ }
@@ -0,0 +1,285 @@
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
+ guaranteeNonNullable,
19
+ type GeneratorFn,
20
+ assertErrorThrown,
21
+ StopWatch,
22
+ LogEvent,
23
+ assertNonEmptyString,
24
+ } from '@finos/legend-shared';
25
+ import type { EditorStore } from '../editor/EditorStore.js';
26
+ import { flow, flowResult, makeObservable, observable } from 'mobx';
27
+ import type { ShowcaseViewerPathParams } from '../../__lib__/LegendStudioNavigation.js';
28
+ import { LEGEND_STUDIO_APP_EVENT } from '../../__lib__/LegendStudioEvent.js';
29
+ import {
30
+ ShowcaseRegistryServerClient,
31
+ type Showcase,
32
+ } from '@finos/legend-server-showcase';
33
+ import {
34
+ DependencyGraphBuilderError,
35
+ GRAPH_MANAGER_EVENT,
36
+ GraphBuilderError,
37
+ GraphDataDeserializationError,
38
+ createGraphBuilderReport,
39
+ } from '@finos/legend-graph';
40
+ import { DEFAULT_TAB_SIZE } from '@finos/legend-application';
41
+ import { payloadDebugger } from '../editor/panel-group/DevToolPanelState.js';
42
+ import { LegendStudioTelemetryHelper } from '../../__lib__/LegendStudioTelemetryHelper.js';
43
+ import { GRAPH_EDITOR_MODE } from '../editor/EditorConfig.js';
44
+ import type { Entity } from '@finos/legend-storage';
45
+
46
+ export class ShowcaseViewerStore {
47
+ readonly editorStore: EditorStore;
48
+ private readonly showcaseServerClient?: ShowcaseRegistryServerClient;
49
+ _showcase: Showcase | undefined;
50
+
51
+ constructor(editorStore: EditorStore) {
52
+ this.editorStore = editorStore;
53
+ makeObservable(this, {
54
+ _showcase: observable,
55
+ initialize: flow,
56
+ buildGraph: flow,
57
+ });
58
+ if (this.editorStore.applicationStore.config.showcaseServerUrl) {
59
+ this.showcaseServerClient = new ShowcaseRegistryServerClient({
60
+ baseUrl: this.editorStore.applicationStore.config.showcaseServerUrl,
61
+ });
62
+ }
63
+ }
64
+
65
+ private get client(): ShowcaseRegistryServerClient {
66
+ return guaranteeNonNullable(
67
+ this.showcaseServerClient,
68
+ `Showcase registry server client is not configured`,
69
+ );
70
+ }
71
+
72
+ get showcase(): Showcase {
73
+ return guaranteeNonNullable(this._showcase);
74
+ }
75
+
76
+ setShowcase(val: Showcase): void {
77
+ this._showcase = val;
78
+ }
79
+
80
+ *initialize(params: ShowcaseViewerPathParams): GeneratorFn<void> {
81
+ if (!this.editorStore.initState.isInInitialState) {
82
+ return;
83
+ }
84
+
85
+ const showcasePath = params[0];
86
+ this.editorStore.initState.inProgress();
87
+ const onLeave = (hasBuildSucceeded: boolean): void => {
88
+ this.editorStore.initState.complete(hasBuildSucceeded);
89
+ };
90
+
91
+ try {
92
+ const stopWatch = new StopWatch();
93
+ assertNonEmptyString(showcasePath, 'Showcase path expected');
94
+ // fetch showcase
95
+ this.editorStore.initState.setMessage(`Fetching Showcase Data...`);
96
+ this._showcase = (yield this.client.getShowcase(
97
+ showcasePath,
98
+ )) as Showcase;
99
+ // initialize graph manager
100
+ yield this.editorStore.graphManagerState.graphManager.initialize(
101
+ {
102
+ env: this.editorStore.applicationStore.config.env,
103
+ tabSize: DEFAULT_TAB_SIZE,
104
+ clientConfig: {
105
+ baseUrl: this.editorStore.applicationStore.config.engineServerUrl,
106
+ queryBaseUrl:
107
+ this.editorStore.applicationStore.config.engineQueryServerUrl,
108
+ enableCompression: true,
109
+ payloadDebugger,
110
+ },
111
+ },
112
+ {
113
+ tracerService: this.editorStore.applicationStore.tracerService,
114
+ },
115
+ );
116
+ // convert code to entities
117
+ stopWatch.record();
118
+ const grammar = this.showcase.code;
119
+ this.editorStore.initState.setMessage(
120
+ `Converting showcase code to entities...`,
121
+ );
122
+ const entities =
123
+ (yield this.editorStore.graphManagerState.graphManager.pureCodeToEntities(
124
+ grammar,
125
+ )) as Entity[];
126
+ this.editorStore.initState.setMessage(undefined);
127
+ stopWatch.record(GRAPH_MANAGER_EVENT.FETCH_GRAPH_ENTITIES__SUCCESS);
128
+ const graphBuilderResult = (yield flowResult(
129
+ this.buildGraph(entities),
130
+ )) as boolean;
131
+
132
+ if (!graphBuilderResult) {
133
+ onLeave(false);
134
+ return;
135
+ }
136
+ this.editorStore.initState.setMessage(`Generating elements...`);
137
+ if (
138
+ this.editorStore.graphManagerState.graph.ownGenerationSpecifications
139
+ .length
140
+ ) {
141
+ yield flowResult(
142
+ this.editorStore.graphState.graphGenerationState.globalGenerate(),
143
+ );
144
+ }
145
+
146
+ // build explorer tree
147
+ this.editorStore.explorerTreeState.buildImmutableModelTrees();
148
+ this.editorStore.explorerTreeState.build();
149
+
150
+ // complete actions
151
+ this.editorStore.initState.setMessage(undefined);
152
+ onLeave(true);
153
+ } catch (error) {
154
+ assertErrorThrown(error);
155
+ this.editorStore.applicationStore.logService.error(
156
+ LogEvent.create(LEGEND_STUDIO_APP_EVENT.SDLC_MANAGER_FAILURE),
157
+ error,
158
+ );
159
+ this.editorStore.applicationStore.notificationService.notifyError(error);
160
+ onLeave(false);
161
+ }
162
+ }
163
+
164
+ *buildGraph(entities: Entity[]): GeneratorFn<boolean> {
165
+ try {
166
+ const stopWatch = new StopWatch();
167
+ yield this.editorStore.graphManagerState.initializeSystem();
168
+
169
+ // reset
170
+ this.editorStore.graphManagerState.resetGraph();
171
+
172
+ // build dependencies
173
+ stopWatch.record();
174
+ const dependencyManager =
175
+ this.editorStore.graphManagerState.graphManager.createDependencyManager();
176
+ this.editorStore.graphManagerState.graph.dependencyManager =
177
+ dependencyManager;
178
+
179
+ const dependency_buildReport = createGraphBuilderReport();
180
+ yield this.editorStore.graphManagerState.graphManager.buildDependencies(
181
+ this.editorStore.graphManagerState.coreModel,
182
+ this.editorStore.graphManagerState.systemModel,
183
+ dependencyManager,
184
+ new Map(),
185
+ this.editorStore.graphManagerState.dependenciesBuildState,
186
+ {},
187
+ dependency_buildReport,
188
+ );
189
+
190
+ // build graph
191
+ const graph_buildReport = createGraphBuilderReport();
192
+ yield this.editorStore.graphManagerState.graphManager.buildGraph(
193
+ this.editorStore.graphManagerState.graph,
194
+ entities,
195
+ this.editorStore.graphManagerState.graphBuildState,
196
+ undefined,
197
+ graph_buildReport,
198
+ );
199
+
200
+ // report
201
+ stopWatch.record(GRAPH_MANAGER_EVENT.INITIALIZE_GRAPH__SUCCESS);
202
+ const graphBuilderReportData = {
203
+ timings:
204
+ this.editorStore.applicationStore.timeService.finalizeTimingsRecord(
205
+ stopWatch,
206
+ ),
207
+ dependencies: dependency_buildReport,
208
+ dependenciesCount:
209
+ this.editorStore.graphManagerState.graph.dependencyManager
210
+ .numberOfDependencies,
211
+ graph: graph_buildReport,
212
+ };
213
+ LegendStudioTelemetryHelper.logEvent_GraphInitializationSucceeded(
214
+ this.editorStore.applicationStore.telemetryService,
215
+ graphBuilderReportData,
216
+ );
217
+
218
+ this.editorStore.applicationStore.logService.info(
219
+ LogEvent.create(GRAPH_MANAGER_EVENT.INITIALIZE_GRAPH__SUCCESS),
220
+ graphBuilderReportData,
221
+ );
222
+
223
+ // fetch available editor configurations
224
+ yield Promise.all([
225
+ this.editorStore.graphState.graphGenerationState.globalFileGenerationState.fetchAvailableFileGenerationDescriptions(),
226
+ this.editorStore.graphState.graphGenerationState.externalFormatState.fetchExternalFormatDescriptions(),
227
+ this.editorStore.graphState.graphGenerationState.externalFormatState.fetchExternalFormatDescriptions(),
228
+ this.editorStore.graphState.fetchAvailableFunctionActivatorConfigurations(),
229
+ ]);
230
+
231
+ return true;
232
+ } catch (error) {
233
+ assertErrorThrown(error);
234
+
235
+ // if graph builder fails, we fall back to text-mode
236
+ this.editorStore.applicationStore.logService.error(
237
+ LogEvent.create(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_FAILURE),
238
+ error,
239
+ );
240
+ if (error instanceof DependencyGraphBuilderError) {
241
+ // no recovery if dependency models cannot be built, this makes assumption that all dependencies models are compiled successfully
242
+ // TODO: we might want to handle this more gracefully when we can show people the dependency model element in the future
243
+ this.editorStore.applicationStore.notificationService.notifyError(
244
+ `Can't initialize dependency models. Error: ${error.message}`,
245
+ );
246
+ this.editorStore.applicationStore.alertService.setBlockingAlert({
247
+ message: `Can't initialize dependencies`,
248
+ prompt: 'Please use editor to better invesigate the issue',
249
+ });
250
+ } else if (error instanceof GraphDataDeserializationError) {
251
+ // if something goes wrong with de-serialization, we can't really do anything but to alert
252
+ this.editorStore.applicationStore.notificationService.notifyError(
253
+ `Can't deserialize graph. Error: ${error.message}`,
254
+ );
255
+ this.editorStore.applicationStore.alertService.setBlockingAlert({
256
+ message: `Can't deserialize graph`,
257
+ prompt: 'Please use editor to better invesigate the issue',
258
+ });
259
+ } else if (error instanceof GraphBuilderError) {
260
+ // TODO: we should split this into 2 notifications when we support multiple notifications
261
+ this.editorStore.applicationStore.notificationService.notifyError(
262
+ `Can't build graph. Redirected to text mode for debugging. Error: ${error.message}`,
263
+ );
264
+ yield flowResult(
265
+ this.editorStore.switchModes(GRAPH_EDITOR_MODE.GRAMMAR_TEXT, {
266
+ isGraphBuildFailure: true,
267
+ }),
268
+ );
269
+ if (this.editorStore.graphEditorMode.mode === GRAPH_EDITOR_MODE.FORM) {
270
+ // nothing we can do here so we will just block the user
271
+ this.editorStore.applicationStore.alertService.setBlockingAlert({
272
+ message: `Can't compose Pure code from graph models`,
273
+ prompt: 'Please use editor to better invesigate the issue',
274
+ });
275
+ return false;
276
+ }
277
+ } else {
278
+ this.editorStore.applicationStore.notificationService.notifyError(
279
+ error,
280
+ );
281
+ }
282
+ return false;
283
+ }
284
+ }
285
+ }
package/tsconfig.json CHANGED
@@ -168,6 +168,8 @@
168
168
  "./src/stores/graph-modifier/Testable_GraphModifierHelper.ts",
169
169
  "./src/stores/project-view/ProjectViewerEditorMode.ts",
170
170
  "./src/stores/project-view/ProjectViewerStore.ts",
171
+ "./src/stores/showcase/ShowcaseViewerEditorMode.ts",
172
+ "./src/stores/showcase/ShowcaseViewerStore.ts",
171
173
  "./src/stores/workspace-review/WorkspaceReviewStore.ts",
172
174
  "./src/stores/workspace-setup/ProjectConfigurationStatus.ts",
173
175
  "./src/stores/workspace-setup/WorkspaceSetupStore.ts",
@@ -283,6 +285,8 @@
283
285
  "./src/components/extensions/DSL_ExternalFormat_LegendStudioApplicationPlugin.tsx",
284
286
  "./src/components/project-view/ProjectViewer.tsx",
285
287
  "./src/components/project-view/ProjectViewerStoreProvider.tsx",
288
+ "./src/components/showcase/ShowcaseViewer.tsx",
289
+ "./src/components/showcase/ShowcaseViewerStoreProvider.tsx",
286
290
  "./src/components/workspace-review/WorkspaceReview.tsx",
287
291
  "./src/components/workspace-review/WorkspaceReviewPanel.tsx",
288
292
  "./src/components/workspace-review/WorkspaceReviewSideBar.tsx",