@finos/legend-application-studio 22.2.1 → 22.3.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.
Files changed (212) hide show
  1. package/lib/components/editor/StatusBar.js +1 -1
  2. package/lib/components/editor/StatusBar.js.map +1 -1
  3. package/lib/components/editor/command-center/ProjectSearchCommand.d.ts.map +1 -1
  4. package/lib/components/editor/command-center/ProjectSearchCommand.js +1 -0
  5. package/lib/components/editor/command-center/ProjectSearchCommand.js.map +1 -1
  6. package/lib/components/editor/edit-panel/EditPanel.d.ts.map +1 -1
  7. package/lib/components/editor/edit-panel/EditPanel.js +24 -11
  8. package/lib/components/editor/edit-panel/EditPanel.js.map +1 -1
  9. package/lib/components/editor/edit-panel/GenerationSpecificationEditor.d.ts.map +1 -1
  10. package/lib/components/editor/edit-panel/GenerationSpecificationEditor.js +2 -1
  11. package/lib/components/editor/edit-panel/GenerationSpecificationEditor.js.map +1 -1
  12. package/lib/components/editor/edit-panel/connection-editor/ConnectionEditor.d.ts.map +1 -1
  13. package/lib/components/editor/edit-panel/connection-editor/ConnectionEditor.js +1 -0
  14. package/lib/components/editor/edit-panel/connection-editor/ConnectionEditor.js.map +1 -1
  15. package/lib/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.d.ts.map +1 -1
  16. package/lib/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.js +4 -3
  17. package/lib/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.js.map +1 -1
  18. package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.d.ts +32 -0
  19. package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.d.ts.map +1 -0
  20. package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.js +66 -0
  21. package/lib/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.js.map +1 -0
  22. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.d.ts +0 -23
  23. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.d.ts.map +1 -1
  24. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.js +6 -58
  25. package/lib/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.js.map +1 -1
  26. package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.d.ts +41 -0
  27. package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.d.ts.map +1 -0
  28. package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.js +77 -0
  29. package/lib/components/editor/edit-panel/element-generation-editor/FileSystemViewer.js.map +1 -0
  30. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.d.ts +7 -0
  31. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.d.ts.map +1 -1
  32. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js +19 -14
  33. package/lib/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js.map +1 -1
  34. package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.d.ts.map +1 -1
  35. package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.js +3 -1
  36. package/lib/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.js.map +1 -1
  37. package/lib/components/editor/edit-panel/mapping-editor/InstanceSetImplementationSourceSelectorModal.js +3 -1
  38. package/lib/components/editor/edit-panel/mapping-editor/InstanceSetImplementationSourceSelectorModal.js.map +1 -1
  39. package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.d.ts.map +1 -1
  40. package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.js +3 -0
  41. package/lib/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.js.map +1 -1
  42. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.d.ts.map +1 -1
  43. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js +3 -1
  44. package/lib/components/editor/edit-panel/mapping-editor/NewMappingElementModal.js.map +1 -1
  45. package/lib/components/editor/edit-panel/service-editor/ServiceEditor.d.ts.map +1 -1
  46. package/lib/components/editor/edit-panel/service-editor/ServiceEditor.js +51 -13
  47. package/lib/components/editor/edit-panel/service-editor/ServiceEditor.js.map +1 -1
  48. package/lib/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.d.ts.map +1 -1
  49. package/lib/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.js +18 -10
  50. package/lib/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.js.map +1 -1
  51. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.d.ts +1 -3
  52. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.d.ts.map +1 -1
  53. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.js +2 -20
  54. package/lib/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.js.map +1 -1
  55. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.d.ts.map +1 -1
  56. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.js +9 -3
  57. package/lib/components/editor/edit-panel/uml-editor/ClassEditor.js.map +1 -1
  58. package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
  59. package/lib/components/editor/side-bar/CreateNewElementModal.js +1 -0
  60. package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
  61. package/lib/components/editor/side-bar/Explorer.d.ts.map +1 -1
  62. package/lib/components/editor/side-bar/Explorer.js +29 -8
  63. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  64. package/lib/components/editor/side-bar/testable/GlobalTestRunner.d.ts.map +1 -1
  65. package/lib/components/editor/side-bar/testable/GlobalTestRunner.js +17 -3
  66. package/lib/components/editor/side-bar/testable/GlobalTestRunner.js.map +1 -1
  67. package/lib/index.css +2 -2
  68. package/lib/index.css.map +1 -1
  69. package/lib/index.d.ts +2 -2
  70. package/lib/index.d.ts.map +1 -1
  71. package/lib/index.js +2 -2
  72. package/lib/index.js.map +1 -1
  73. package/lib/package.json +3 -3
  74. package/lib/stores/DSL_Generation_LegendStudioApplicationPlugin_Extension.d.ts +2 -2
  75. package/lib/stores/DSL_Generation_LegendStudioApplicationPlugin_Extension.d.ts.map +1 -1
  76. package/lib/stores/DependencyProjectViewerHelper.d.ts +19 -0
  77. package/lib/stores/DependencyProjectViewerHelper.d.ts.map +1 -0
  78. package/lib/stores/DependencyProjectViewerHelper.js +23 -0
  79. package/lib/stores/DependencyProjectViewerHelper.js.map +1 -0
  80. package/lib/stores/EditorGraphState.d.ts +9 -2
  81. package/lib/stores/EditorGraphState.d.ts.map +1 -1
  82. package/lib/stores/EditorGraphState.js +35 -95
  83. package/lib/stores/EditorGraphState.js.map +1 -1
  84. package/lib/stores/EditorStore.d.ts.map +1 -1
  85. package/lib/stores/EditorStore.js +7 -1
  86. package/lib/stores/EditorStore.js.map +1 -1
  87. package/lib/stores/EditorTabManagerState.d.ts +1 -1
  88. package/lib/stores/EditorTabManagerState.d.ts.map +1 -1
  89. package/lib/stores/EditorTabManagerState.js +11 -13
  90. package/lib/stores/EditorTabManagerState.js.map +1 -1
  91. package/lib/stores/ExplorerTreeState.d.ts +4 -4
  92. package/lib/stores/ExplorerTreeState.d.ts.map +1 -1
  93. package/lib/stores/ExplorerTreeState.js +12 -13
  94. package/lib/stores/ExplorerTreeState.js.map +1 -1
  95. package/lib/stores/editor/NewElementState.d.ts.map +1 -1
  96. package/lib/stores/editor/NewElementState.js +0 -3
  97. package/lib/stores/editor/NewElementState.js.map +1 -1
  98. package/lib/stores/editor-state/ExternalFormatState.d.ts +2 -0
  99. package/lib/stores/editor-state/ExternalFormatState.d.ts.map +1 -1
  100. package/lib/stores/editor-state/ExternalFormatState.js +6 -0
  101. package/lib/stores/editor-state/ExternalFormatState.js.map +1 -1
  102. package/lib/stores/editor-state/FileGenerationState.d.ts +18 -18
  103. package/lib/stores/editor-state/FileGenerationState.d.ts.map +1 -1
  104. package/lib/stores/editor-state/FileGenerationState.js +86 -133
  105. package/lib/stores/editor-state/FileGenerationState.js.map +1 -1
  106. package/lib/stores/editor-state/FileGenerationViewerState.d.ts +3 -3
  107. package/lib/stores/editor-state/FileGenerationViewerState.d.ts.map +1 -1
  108. package/lib/stores/editor-state/FileGenerationViewerState.js.map +1 -1
  109. package/lib/stores/editor-state/FileSystemState.d.ts +30 -0
  110. package/lib/stores/editor-state/FileSystemState.d.ts.map +1 -0
  111. package/lib/stores/editor-state/FileSystemState.js +82 -0
  112. package/lib/stores/editor-state/FileSystemState.js.map +1 -0
  113. package/lib/stores/editor-state/GraphGenerationState.d.ts +9 -9
  114. package/lib/stores/editor-state/GraphGenerationState.d.ts.map +1 -1
  115. package/lib/stores/editor-state/GraphGenerationState.js +14 -15
  116. package/lib/stores/editor-state/GraphGenerationState.js.map +1 -1
  117. package/lib/stores/editor-state/element-editor-state/ElementEditorState.d.ts +25 -2
  118. package/lib/stores/editor-state/element-editor-state/ElementEditorState.d.ts.map +1 -1
  119. package/lib/stores/editor-state/element-editor-state/ElementEditorState.js +50 -7
  120. package/lib/stores/editor-state/element-editor-state/ElementEditorState.js.map +1 -1
  121. package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.d.ts +44 -0
  122. package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.d.ts.map +1 -0
  123. package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.js +172 -0
  124. package/lib/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.js.map +1 -0
  125. package/lib/stores/editor-state/element-editor-state/RuntimeEditorState.d.ts.map +1 -1
  126. package/lib/stores/editor-state/element-editor-state/RuntimeEditorState.js +7 -3
  127. package/lib/stores/editor-state/element-editor-state/RuntimeEditorState.js.map +1 -1
  128. package/lib/stores/editor-state/element-editor-state/mapping/MappingExecutionState.js +1 -1
  129. package/lib/stores/editor-state/element-editor-state/mapping/MappingExecutionState.js.map +1 -1
  130. package/lib/stores/editor-state/element-editor-state/mapping/MappingTestState.js +2 -2
  131. package/lib/stores/editor-state/element-editor-state/mapping/MappingTestState.js.map +1 -1
  132. package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.d.ts +3 -0
  133. package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
  134. package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.js +14 -2
  135. package/lib/stores/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
  136. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.d.ts +9 -6
  137. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.d.ts.map +1 -1
  138. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.js +39 -29
  139. package/lib/stores/editor-state/element-editor-state/service/ServiceExecutionState.js.map +1 -1
  140. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.js +2 -2
  141. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.js.map +1 -1
  142. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.d.ts.map +1 -1
  143. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js +6 -3
  144. package/lib/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js.map +1 -1
  145. package/lib/stores/shared/FileSystemTreeUtils.d.ts +56 -0
  146. package/lib/stores/shared/FileSystemTreeUtils.d.ts.map +1 -0
  147. package/lib/stores/shared/{FileGenerationTreeUtils.js → FileSystemTreeUtils.js} +31 -32
  148. package/lib/stores/shared/FileSystemTreeUtils.js.map +1 -0
  149. package/lib/stores/shared/PackageTreeUtils.d.ts +6 -4
  150. package/lib/stores/shared/PackageTreeUtils.d.ts.map +1 -1
  151. package/lib/stores/shared/PackageTreeUtils.js +90 -11
  152. package/lib/stores/shared/PackageTreeUtils.js.map +1 -1
  153. package/lib/stores/shared/testable/TestableUtils.d.ts +1 -1
  154. package/lib/stores/shared/testable/TestableUtils.d.ts.map +1 -1
  155. package/lib/stores/shared/testable/TestableUtils.js +6 -4
  156. package/lib/stores/shared/testable/TestableUtils.js.map +1 -1
  157. package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.d.ts +3 -3
  158. package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.d.ts.map +1 -1
  159. package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.js +37 -1
  160. package/lib/stores/sidebar-state/testable/GlobalTestRunnerState.js.map +1 -1
  161. package/package.json +12 -12
  162. package/src/components/editor/StatusBar.tsx +1 -1
  163. package/src/components/editor/command-center/ProjectSearchCommand.tsx +1 -0
  164. package/src/components/editor/edit-panel/EditPanel.tsx +79 -25
  165. package/src/components/editor/edit-panel/GenerationSpecificationEditor.tsx +2 -1
  166. package/src/components/editor/edit-panel/connection-editor/ConnectionEditor.tsx +1 -0
  167. package/src/components/editor/edit-panel/element-generation-editor/ElementGenerationEditor.tsx +5 -7
  168. package/src/components/editor/edit-panel/element-generation-editor/ElementXTGenerationEditor.tsx +194 -0
  169. package/src/components/editor/edit-panel/element-generation-editor/FileGenerationEditor.tsx +6 -270
  170. package/src/components/editor/edit-panel/element-generation-editor/FileSystemViewer.tsx +296 -0
  171. package/src/components/editor/edit-panel/external-format-editor/DSL_ExternalFormat_BindingElementEditor.tsx +177 -155
  172. package/src/components/editor/edit-panel/mapping-editor/EnumerationMappingEditor.tsx +3 -1
  173. package/src/components/editor/edit-panel/mapping-editor/InstanceSetImplementationSourceSelectorModal.tsx +3 -3
  174. package/src/components/editor/edit-panel/mapping-editor/MappingExecutionQueryBuilder.tsx +3 -0
  175. package/src/components/editor/edit-panel/mapping-editor/NewMappingElementModal.tsx +3 -1
  176. package/src/components/editor/edit-panel/service-editor/ServiceEditor.tsx +243 -184
  177. package/src/components/editor/edit-panel/service-editor/ServiceExecutionQueryEditor.tsx +42 -15
  178. package/src/components/editor/edit-panel/service-editor/testable/ServiceTestableEditor.tsx +2 -65
  179. package/src/components/editor/edit-panel/uml-editor/ClassEditor.tsx +9 -3
  180. package/src/components/editor/side-bar/CreateNewElementModal.tsx +1 -0
  181. package/src/components/editor/side-bar/Explorer.tsx +82 -13
  182. package/src/components/editor/side-bar/testable/GlobalTestRunner.tsx +31 -9
  183. package/src/index.ts +5 -2
  184. package/src/stores/DSL_Generation_LegendStudioApplicationPlugin_Extension.ts +2 -2
  185. package/src/stores/DependencyProjectViewerHelper.ts +39 -0
  186. package/src/stores/EditorGraphState.ts +56 -153
  187. package/src/stores/EditorStore.ts +15 -5
  188. package/src/stores/EditorTabManagerState.ts +17 -20
  189. package/src/stores/ExplorerTreeState.ts +26 -18
  190. package/src/stores/editor/NewElementState.ts +0 -2
  191. package/src/stores/editor-state/ExternalFormatState.ts +9 -0
  192. package/src/stores/editor-state/FileGenerationState.ts +129 -180
  193. package/src/stores/editor-state/FileGenerationViewerState.ts +3 -3
  194. package/src/stores/editor-state/FileSystemState.ts +111 -0
  195. package/src/stores/editor-state/GraphGenerationState.ts +35 -31
  196. package/src/stores/editor-state/element-editor-state/ElementEditorState.ts +91 -6
  197. package/src/stores/editor-state/element-editor-state/ElementExternalFormatGenerationState.ts +266 -0
  198. package/src/stores/editor-state/element-editor-state/RuntimeEditorState.ts +10 -8
  199. package/src/stores/editor-state/element-editor-state/mapping/MappingExecutionState.ts +1 -1
  200. package/src/stores/editor-state/element-editor-state/mapping/MappingTestState.ts +2 -2
  201. package/src/stores/editor-state/element-editor-state/service/ServiceEditorState.ts +23 -2
  202. package/src/stores/editor-state/element-editor-state/service/ServiceExecutionState.ts +61 -56
  203. package/src/stores/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +2 -2
  204. package/src/stores/editor-state/element-editor-state/service/testable/ServiceTestEditorState.ts +6 -2
  205. package/src/stores/shared/{FileGenerationTreeUtils.ts → FileSystemTreeUtils.ts} +77 -76
  206. package/src/stores/shared/PackageTreeUtils.ts +144 -10
  207. package/src/stores/shared/testable/TestableUtils.ts +8 -4
  208. package/src/stores/sidebar-state/testable/GlobalTestRunnerState.ts +42 -3
  209. package/tsconfig.json +6 -1
  210. package/lib/stores/shared/FileGenerationTreeUtils.d.ts +0 -56
  211. package/lib/stores/shared/FileGenerationTreeUtils.d.ts.map +0 -1
  212. package/lib/stores/shared/FileGenerationTreeUtils.js.map +0 -1
@@ -17,25 +17,21 @@
17
17
  import type { EditorStore } from '../EditorStore.js';
18
18
  import { observable, action, makeObservable, flow } from 'mobx';
19
19
  import { LEGEND_STUDIO_APP_EVENT } from '../LegendStudioAppEvent.js';
20
- import type { TreeData } from '@finos/legend-art';
21
20
  import {
22
- type GenerationTreeNodeData,
23
- type GenerationFile,
24
- type GenerationOutputResult,
25
- GenerationDirectory,
21
+ type FileSystem_File,
22
+ type FileResult,
23
+ FileSystem_Directory,
26
24
  GENERATION_FILE_ROOT_NAME,
27
- getGenerationTreeData,
28
- openNode,
29
- populateDirectoryTreeNodeChildren,
30
- buildGenerationDirectory,
31
- reprocessOpenNodes,
32
- } from '../shared/FileGenerationTreeUtils.js';
25
+ getFileSystemTreeData,
26
+ buildFileSystemDirectory,
27
+ } from '../shared/FileSystemTreeUtils.js';
33
28
  import {
34
29
  type GeneratorFn,
35
30
  assertErrorThrown,
36
31
  deepEqual,
37
32
  isEmpty,
38
33
  LogEvent,
34
+ ActionState,
39
35
  } from '@finos/legend-shared';
40
36
  import {
41
37
  type FileGenerationSpecification,
@@ -55,113 +51,40 @@ import {
55
51
  fileGeneration_addScopeElement,
56
52
  fileGeneration_deleteScopeElement,
57
53
  } from '../shared/modifier/DSL_Generation_GraphModifierHelper.js';
54
+ import { FileSystemState } from './FileSystemState.js';
58
55
 
59
- export class FileGenerationState {
56
+ export abstract class GeneratedFileStructureState {
60
57
  readonly editorStore: EditorStore;
61
- readonly fileGeneration: FileGenerationSpecification;
62
-
63
- isGenerating = false;
64
- root: GenerationDirectory;
65
- directoryTreeData?: TreeData<GenerationTreeNodeData> | undefined;
66
- selectedNode?: GenerationTreeNodeData | undefined;
67
- filesIndex = new Map<string, GenerationFile>();
68
-
69
- constructor(
70
- editorStore: EditorStore,
71
- fileGeneration: FileGenerationSpecification,
72
- ) {
73
- makeObservable(this, {
74
- isGenerating: observable,
75
- root: observable,
76
- directoryTreeData: observable.ref,
77
- selectedNode: observable.ref,
78
- filesIndex: observable,
79
- resetFileGeneration: action,
80
- setIsGeneration: action,
81
- setDirectoryTreeData: action,
82
- processGenerationResult: action,
83
- reprocessNodeTree: action,
84
- setSelectedNode: action,
85
- onTreeNodeSelect: action,
86
- addScopeElement: action,
87
- deleteScopeElement: action,
88
- updateFileGenerationParameters: action,
89
- generate: flow,
90
- });
58
+ fileSystemState: FileSystemState;
59
+ generatingAction = ActionState.create();
60
+ rootDirectoryName: string;
91
61
 
62
+ constructor(rootDirectory: string, editorStore: EditorStore) {
63
+ this.rootDirectoryName = rootDirectory;
64
+ this.fileSystemState = new FileSystemState(rootDirectory);
92
65
  this.editorStore = editorStore;
93
- this.fileGeneration = fileGeneration;
94
- this.root = new GenerationDirectory(GENERATION_FILE_ROOT_NAME);
95
66
  }
96
67
 
97
- getOrCreateDirectory(directoryName: string): GenerationDirectory {
98
- return GenerationDirectory.getOrCreateDirectory(
99
- this.root,
100
- directoryName,
101
- true,
102
- );
103
- }
68
+ abstract resetGenerator(): void;
104
69
 
105
- resetFileGeneration(): void {
106
- this.fileGeneration.configurationProperties = [];
107
- }
70
+ abstract generate(): GeneratorFn<void>;
108
71
 
109
- setIsGeneration(isGenerating: boolean): void {
110
- this.isGenerating = isGenerating;
111
- }
72
+ abstract get rootFolder(): string;
112
73
 
113
- setDirectoryTreeData(
114
- directoryTreeData: TreeData<GenerationTreeNodeData>,
115
- ): void {
116
- this.directoryTreeData = directoryTreeData;
117
- }
118
-
119
- *generate(): GeneratorFn<void> {
120
- this.isGenerating = true;
121
- try {
122
- // avoid wasting a network call when the scope is empty, we can short-circuit this
123
- if (!this.fileGeneration.scopeElements.length) {
124
- this.selectedNode = undefined;
125
- this.processGenerationResult([]);
126
- return;
127
- }
128
- const mode =
129
- this.editorStore.graphState.graphGenerationState.getFileGenerationConfiguration(
130
- this.fileGeneration.type,
131
- ).generationMode;
132
- const result =
133
- (yield this.editorStore.graphManagerState.graphManager.generateFile(
134
- this.fileGeneration,
135
- mode,
136
- this.editorStore.graphManagerState.graph,
137
- )) as GenerationOutput[];
138
- this.processGenerationResult(result);
139
- } catch (error) {
140
- assertErrorThrown(error);
141
- this.selectedNode = undefined;
142
- this.processGenerationResult([]);
143
- this.editorStore.applicationStore.log.error(
144
- LogEvent.create(LEGEND_STUDIO_APP_EVENT.GENERATION_FAILURE),
145
- error,
146
- );
147
- this.editorStore.applicationStore.notifyError(error);
148
- } finally {
149
- this.isGenerating = false;
150
- }
151
- }
74
+ abstract get generationParentId(): string | undefined;
152
75
 
153
76
  processGenerationResult(output: GenerationOutput[]): void {
154
- this.root = new GenerationDirectory(GENERATION_FILE_ROOT_NAME);
155
- this.filesIndex = new Map<string, GenerationFile>();
156
- const openedNodeIds = this.directoryTreeData
157
- ? Array.from(this.directoryTreeData.nodes.values())
77
+ this.fileSystemState.root = new FileSystem_Directory(
78
+ this.rootDirectoryName,
79
+ );
80
+ this.fileSystemState.filesIndex = new Map<string, FileSystem_File>();
81
+ const openedNodeIds = this.fileSystemState.directoryTreeData
82
+ ? Array.from(this.fileSystemState.directoryTreeData.nodes.values())
158
83
  .filter((node) => node.isOpen)
159
84
  .map((node) => node.id)
160
85
  : [];
161
- const generationResultIndex = new Map<string, GenerationOutputResult>();
162
- const rootFolder =
163
- this.fileGeneration.generationOutputPath ??
164
- this.fileGeneration.path.split(ELEMENT_PATH_DELIMITER).join('_');
86
+ const generationResultIndex = new Map<string, FileResult>();
87
+ const rootFolder = this.rootFolder;
165
88
  output.forEach((entry) => {
166
89
  entry.cleanFileName(rootFolder);
167
90
  if (generationResultIndex.has(entry.fileName)) {
@@ -171,98 +94,61 @@ export class FileGenerationState {
171
94
  );
172
95
  }
173
96
  generationResultIndex.set(entry.fileName, {
174
- generationOutput: entry,
175
- parentId: this.fileGeneration.path,
97
+ value: entry,
98
+ parentId: this.generationParentId,
176
99
  });
177
100
  });
178
101
  // take generation outputs and put them into the root directory
179
- buildGenerationDirectory(this.root, generationResultIndex, this.filesIndex);
180
- this.directoryTreeData = getGenerationTreeData(this.root);
181
- this.reprocessNodeTree(
102
+ buildFileSystemDirectory(
103
+ this.fileSystemState.root,
104
+ generationResultIndex,
105
+ this.fileSystemState.filesIndex,
106
+ );
107
+ this.fileSystemState.directoryTreeData = getFileSystemTreeData(
108
+ this.fileSystemState.root,
109
+ );
110
+ this.fileSystemState.reprocessNodeTree(
182
111
  Array.from(generationResultIndex.values()),
183
- this.directoryTreeData,
112
+ this.fileSystemState.directoryTreeData,
184
113
  openedNodeIds,
185
114
  );
186
115
  }
116
+ }
187
117
 
188
- reprocessNodeTree(
189
- generationResult: GenerationOutputResult[],
190
- treeData: TreeData<GenerationTreeNodeData>,
191
- openedNodeIds: string[],
192
- ): void {
193
- reprocessOpenNodes(treeData, this.filesIndex, this.root, openedNodeIds);
194
- // select the current file node if available, else select the first output
195
- const selectedFileNodePath =
196
- generationResult.length === 1 ||
197
- (this.selectedNode === undefined && generationResult.length !== 0)
198
- ? (generationResult[0] as GenerationOutputResult).generationOutput
199
- .fileName
200
- : this.selectedNode?.fileNode.path;
201
- if (selectedFileNodePath) {
202
- const file = this.filesIndex.get(selectedFileNodePath);
203
- if (file) {
204
- const node = openNode(file, treeData);
205
- if (node) {
206
- this.onTreeNodeSelect(node, treeData);
207
- }
208
- } else {
209
- this.selectedNode = undefined;
210
- }
211
- }
212
- this.setDirectoryTreeData({ ...treeData });
213
- }
214
-
215
- setSelectedNode(node?: GenerationTreeNodeData): void {
216
- if (this.selectedNode) {
217
- this.selectedNode.isSelected = false;
218
- }
219
- if (node) {
220
- node.isSelected = true;
221
- }
222
- this.selectedNode = node;
223
- }
118
+ export class FileGenerationState extends GeneratedFileStructureState {
119
+ readonly fileGeneration: FileGenerationSpecification;
224
120
 
225
- onTreeNodeSelect(
226
- node: GenerationTreeNodeData,
227
- treeData: TreeData<GenerationTreeNodeData>,
228
- ): void {
229
- if (node.childrenIds?.length) {
230
- node.isOpen = !node.isOpen;
231
- if (node.fileNode instanceof GenerationDirectory) {
232
- populateDirectoryTreeNodeChildren(node, treeData);
233
- }
234
- }
235
- this.setSelectedNode(node);
236
- this.setDirectoryTreeData({ ...treeData });
121
+ constructor(
122
+ editorStore: EditorStore,
123
+ fileGeneration: FileGenerationSpecification,
124
+ ) {
125
+ super(GENERATION_FILE_ROOT_NAME, editorStore);
126
+ makeObservable(this, {
127
+ generatingAction: observable,
128
+ fileSystemState: observable,
129
+ resetGenerator: action,
130
+ processGenerationResult: action,
131
+ addScopeElement: action,
132
+ deleteScopeElement: action,
133
+ updateFileGenerationParameters: action,
134
+ generate: flow,
135
+ });
136
+ this.fileGeneration = fileGeneration;
237
137
  }
238
138
 
239
- getScopeElement(
240
- element: PackageableElement | string,
241
- ): PackageableElementReference<PackageableElement> | string | undefined {
242
- return this.fileGeneration.scopeElements.find((el) =>
243
- el instanceof PackageableElementReference
244
- ? el.value === element
245
- : element === el,
139
+ get rootFolder(): string {
140
+ return (
141
+ this.fileGeneration.generationOutputPath ??
142
+ this.fileGeneration.path.split(ELEMENT_PATH_DELIMITER).join('_')
246
143
  );
247
144
  }
248
145
 
249
- addScopeElement(element: PackageableElement | string): void {
250
- const el = this.getScopeElement(element);
251
- if (!el) {
252
- fileGeneration_addScopeElement(
253
- this.fileGeneration,
254
- element instanceof PackageableElement
255
- ? PackageableElementExplicitReference.create(element)
256
- : element,
257
- );
258
- }
146
+ get generationParentId(): string | undefined {
147
+ return this.fileGeneration.path;
259
148
  }
260
149
 
261
- deleteScopeElement(element: PackageableElement | string): void {
262
- const el = this.getScopeElement(element);
263
- if (el) {
264
- fileGeneration_deleteScopeElement(this.fileGeneration, el);
265
- }
150
+ resetGenerator(): void {
151
+ this.fileGeneration.configurationProperties = [];
266
152
  }
267
153
 
268
154
  updateFileGenerationParameters(
@@ -333,4 +219,67 @@ export class FileGenerationState {
333
219
  }
334
220
  }
335
221
  }
222
+
223
+ *generate(): GeneratorFn<void> {
224
+ this.generatingAction.inProgress();
225
+ try {
226
+ // avoid wasting a network call when the scope is empty, we can short-circuit this
227
+ if (!this.fileGeneration.scopeElements.length) {
228
+ this.fileSystemState.selectedNode = undefined;
229
+ this.processGenerationResult([]);
230
+ return;
231
+ }
232
+ const mode =
233
+ this.editorStore.graphState.graphGenerationState.getFileGenerationConfiguration(
234
+ this.fileGeneration.type,
235
+ ).generationMode;
236
+ const result =
237
+ (yield this.editorStore.graphManagerState.graphManager.generateFile(
238
+ this.fileGeneration,
239
+ mode,
240
+ this.editorStore.graphManagerState.graph,
241
+ )) as GenerationOutput[];
242
+ this.processGenerationResult(result);
243
+ } catch (error) {
244
+ assertErrorThrown(error);
245
+ this.fileSystemState.selectedNode = undefined;
246
+ this.processGenerationResult([]);
247
+ this.editorStore.applicationStore.log.error(
248
+ LogEvent.create(LEGEND_STUDIO_APP_EVENT.GENERATION_FAILURE),
249
+ error,
250
+ );
251
+ this.editorStore.applicationStore.notifyError(error);
252
+ } finally {
253
+ this.generatingAction.complete();
254
+ }
255
+ }
256
+
257
+ getScopeElement(
258
+ element: PackageableElement | string,
259
+ ): PackageableElementReference<PackageableElement> | string | undefined {
260
+ return this.fileGeneration.scopeElements.find((el) =>
261
+ el instanceof PackageableElementReference
262
+ ? el.value === element
263
+ : element === el,
264
+ );
265
+ }
266
+
267
+ addScopeElement(element: PackageableElement | string): void {
268
+ const el = this.getScopeElement(element);
269
+ if (!el) {
270
+ fileGeneration_addScopeElement(
271
+ this.fileGeneration,
272
+ element instanceof PackageableElement
273
+ ? PackageableElementExplicitReference.create(element)
274
+ : element,
275
+ );
276
+ }
277
+ }
278
+
279
+ deleteScopeElement(element: PackageableElement | string): void {
280
+ const el = this.getScopeElement(element);
281
+ if (el) {
282
+ fileGeneration_deleteScopeElement(this.fileGeneration, el);
283
+ }
284
+ }
336
285
  }
@@ -17,7 +17,7 @@
17
17
  import type { EditorStore } from '../EditorStore.js';
18
18
  import { EditorState } from './EditorState.js';
19
19
  import { observable, makeObservable, computed } from 'mobx';
20
- import type { GenerationFile } from '../shared/FileGenerationTreeUtils.js';
20
+ import type { FileSystem_File } from '../shared/FileSystemTreeUtils.js';
21
21
  import { EDITOR_LANGUAGE, TAB_SIZE } from '@finos/legend-application';
22
22
  import { returnUndefOnError } from '@finos/legend-shared';
23
23
 
@@ -51,9 +51,9 @@ export const getEditorLanguageForFormat = (
51
51
  };
52
52
 
53
53
  export class FileGenerationViewerState extends EditorState {
54
- file: GenerationFile;
54
+ file: FileSystem_File;
55
55
 
56
- constructor(editorStore: EditorStore, file: GenerationFile) {
56
+ constructor(editorStore: EditorStore, file: FileSystem_File) {
57
57
  super(editorStore);
58
58
 
59
59
  makeObservable(this, {
@@ -0,0 +1,111 @@
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 { TreeData } from '@finos/legend-art';
18
+ import { action, makeObservable, observable } from 'mobx';
19
+ import {
20
+ type FileResult,
21
+ type FileSystemTreeNodeData,
22
+ type FileSystem_File,
23
+ FileSystem_Directory,
24
+ openNode,
25
+ populateDirectoryTreeNodeChildren,
26
+ reprocessOpenNodes,
27
+ } from '../shared/FileSystemTreeUtils.js';
28
+
29
+ export class FileSystemState {
30
+ root: FileSystem_Directory;
31
+ directoryTreeData?: TreeData<FileSystemTreeNodeData> | undefined;
32
+ selectedNode?: FileSystemTreeNodeData | undefined;
33
+ filesIndex = new Map<string, FileSystem_File>();
34
+
35
+ constructor(root: string) {
36
+ this.root = new FileSystem_Directory(root);
37
+ makeObservable(this, {
38
+ root: observable,
39
+ directoryTreeData: observable.ref,
40
+ selectedNode: observable.ref,
41
+ reprocessNodeTree: action,
42
+ setDirectoryTreeData: action,
43
+ onTreeNodeSelect: action,
44
+ setSelectedNode: action,
45
+ });
46
+ }
47
+
48
+ getOrCreateDirectory(directoryName: string): FileSystem_Directory {
49
+ return FileSystem_Directory.getOrCreateDirectory(
50
+ this.root,
51
+ directoryName,
52
+ true,
53
+ );
54
+ }
55
+
56
+ setDirectoryTreeData(
57
+ directoryTreeData: TreeData<FileSystemTreeNodeData>,
58
+ ): void {
59
+ this.directoryTreeData = directoryTreeData;
60
+ }
61
+
62
+ reprocessNodeTree(
63
+ generationResult: FileResult[],
64
+ treeData: TreeData<FileSystemTreeNodeData>,
65
+ openedNodeIds: string[],
66
+ ): void {
67
+ reprocessOpenNodes(treeData, this.filesIndex, this.root, openedNodeIds);
68
+ // select the current file node if available, else select the first output
69
+ const selectedFileNodePath =
70
+ generationResult.length === 1 ||
71
+ (this.selectedNode === undefined && generationResult.length !== 0)
72
+ ? (generationResult[0] as FileResult).value.fileName
73
+ : this.selectedNode?.fileNode.path;
74
+ if (selectedFileNodePath) {
75
+ const file = this.filesIndex.get(selectedFileNodePath);
76
+ if (file) {
77
+ const node = openNode(file, treeData);
78
+ if (node) {
79
+ this.onTreeNodeSelect(node, treeData);
80
+ }
81
+ } else {
82
+ this.selectedNode = undefined;
83
+ }
84
+ }
85
+ this.setDirectoryTreeData({ ...treeData });
86
+ }
87
+
88
+ onTreeNodeSelect(
89
+ node: FileSystemTreeNodeData,
90
+ treeData: TreeData<FileSystemTreeNodeData>,
91
+ ): void {
92
+ if (node.childrenIds?.length) {
93
+ node.isOpen = !node.isOpen;
94
+ if (node.fileNode instanceof FileSystem_Directory) {
95
+ populateDirectoryTreeNodeChildren(node, treeData);
96
+ }
97
+ }
98
+ this.setSelectedNode(node);
99
+ this.setDirectoryTreeData({ ...treeData });
100
+ }
101
+
102
+ setSelectedNode(node?: FileSystemTreeNodeData): void {
103
+ if (this.selectedNode) {
104
+ this.selectedNode.isSelected = false;
105
+ }
106
+ if (node) {
107
+ node.isSelected = true;
108
+ }
109
+ this.selectedNode = node;
110
+ }
111
+ }
@@ -29,20 +29,21 @@ import {
29
29
  assertErrorThrown,
30
30
  guaranteeNonNullable,
31
31
  isNonNullable,
32
+ ActionState,
32
33
  } from '@finos/legend-shared';
33
34
  import { LEGEND_STUDIO_APP_EVENT } from '../LegendStudioAppEvent.js';
34
35
  import {
35
- type GenerationTreeNodeData,
36
- type GenerationOutputResult,
37
- GenerationDirectory,
36
+ type FileSystemTreeNodeData,
37
+ type FileResult,
38
+ FileSystem_Directory,
38
39
  GENERATION_FILE_ROOT_NAME,
39
- GenerationFile,
40
+ FileSystem_File,
40
41
  openNode,
41
42
  populateDirectoryTreeNodeChildren,
42
- buildGenerationDirectory,
43
+ buildFileSystemDirectory,
43
44
  reprocessOpenNodes,
44
- getGenerationTreeData,
45
- } from '../shared/FileGenerationTreeUtils.js';
45
+ getFileSystemTreeData,
46
+ } from '../shared/FileSystemTreeUtils.js';
46
47
  import type { TreeData } from '@finos/legend-art';
47
48
  import type { EditorStore } from '../EditorStore.js';
48
49
  import { FileGenerationViewerState } from './FileGenerationViewerState.js';
@@ -80,21 +81,21 @@ export class GraphGenerationState {
80
81
  editorStore: EditorStore;
81
82
  isRunningGlobalGenerate = false;
82
83
  generatedEntities = new Map<string, Entity[]>();
83
- isClearingGenerationEntities = false;
84
+ clearingGenerationEntitiesState = ActionState.create();
84
85
  externalFormatState: ExternalFormatState;
85
86
  // NOTE: this will eventually be removed once we also do model/schema import using external format
86
87
  // See https://github.com/finos/legend-studio/issues/866
87
88
  fileGenerationConfigurations: GenerationConfigurationDescription[] = [];
88
89
  // file generation output
89
- rootFileDirectory: GenerationDirectory;
90
- filesIndex = new Map<string, GenerationFile>();
91
- selectedNode?: GenerationTreeNodeData | undefined;
90
+ rootFileDirectory: FileSystem_Directory;
91
+ filesIndex = new Map<string, FileSystem_File>();
92
+ selectedNode?: FileSystemTreeNodeData | undefined;
92
93
 
93
94
  constructor(editorStore: EditorStore) {
94
95
  makeObservable<GraphGenerationState>(this, {
95
96
  isRunningGlobalGenerate: observable,
96
97
  generatedEntities: observable.shallow,
97
- isClearingGenerationEntities: observable,
98
+ clearingGenerationEntitiesState: observable,
98
99
  fileGenerationConfigurations: observable,
99
100
  externalFormatState: observable,
100
101
  rootFileDirectory: observable,
@@ -118,7 +119,9 @@ export class GraphGenerationState {
118
119
  });
119
120
 
120
121
  this.editorStore = editorStore;
121
- this.rootFileDirectory = new GenerationDirectory(GENERATION_FILE_ROOT_NAME);
122
+ this.rootFileDirectory = new FileSystem_Directory(
123
+ GENERATION_FILE_ROOT_NAME,
124
+ );
122
125
  this.externalFormatState = new ExternalFormatState(editorStore);
123
126
  }
124
127
 
@@ -349,13 +352,13 @@ export class GraphGenerationState {
349
352
  * Used to clear generation entities as well as the generation model
350
353
  */
351
354
  *clearGenerations(): GeneratorFn<void> {
352
- this.isClearingGenerationEntities = true;
355
+ this.clearingGenerationEntitiesState.inProgress();
353
356
  this.generatedEntities = new Map<string, Entity[]>();
354
357
  this.emptyFileGeneration();
355
358
  yield flowResult(
356
359
  this.editorStore.graphState.updateGenerationGraphAndApplication(),
357
360
  );
358
- this.isClearingGenerationEntities = false;
361
+ this.clearingGenerationEntitiesState.complete();
359
362
  }
360
363
 
361
364
  /**
@@ -416,7 +419,7 @@ export class GraphGenerationState {
416
419
  .map((node) => node.id)
417
420
  : [];
418
421
  // we read the generation outputs and clean
419
- const generationResultIndex = new Map<string, GenerationOutputResult>();
422
+ const generationResultIndex = new Map<string, FileResult>();
420
423
  Array.from(generationOutputIndex.entries()).forEach((entry) => {
421
424
  const fileGeneration =
422
425
  this.editorStore.graphManagerState.graph.getNullableFileGeneration(
@@ -435,20 +438,20 @@ export class GraphGenerationState {
435
438
  );
436
439
  }
437
440
  generationResultIndex.set(genOutput.fileName, {
438
- generationOutput: genOutput,
441
+ value: genOutput,
439
442
  parentId: fileGeneration?.path,
440
443
  });
441
444
  });
442
445
  });
443
446
  // take generation outputs and put them into the root directory
444
- buildGenerationDirectory(
447
+ buildFileSystemDirectory(
445
448
  this.rootFileDirectory,
446
449
  generationResultIndex,
447
450
  this.filesIndex,
448
451
  );
449
452
  // after building root directory set the generation tree data
450
453
  this.editorStore.graphState.editorStore.explorerTreeState.setFileGenerationTreeData(
451
- getGenerationTreeData(
454
+ getFileSystemTreeData(
452
455
  this.editorStore.graphState.graphGenerationState.rootFileDirectory,
453
456
  ExplorerTreeRootPackageLabel.FILE_GENERATION,
454
457
  ),
@@ -482,10 +485,10 @@ export class GraphGenerationState {
482
485
  }
483
486
 
484
487
  reprocessNodeTree(
485
- generationResult: GenerationOutputResult[],
486
- treeData: TreeData<GenerationTreeNodeData>,
488
+ generationResult: FileResult[],
489
+ treeData: TreeData<FileSystemTreeNodeData>,
487
490
  openedNodeIds: string[],
488
- ): TreeData<GenerationTreeNodeData> {
491
+ ): TreeData<FileSystemTreeNodeData> {
489
492
  reprocessOpenNodes(
490
493
  treeData,
491
494
  this.filesIndex,
@@ -496,8 +499,7 @@ export class GraphGenerationState {
496
499
  const selectedFileNodePath =
497
500
  this.selectedNode?.fileNode.path ??
498
501
  (generationResult.length === 1
499
- ? (generationResult[0] as GenerationOutputResult).generationOutput
500
- .fileName
502
+ ? (generationResult[0] as FileResult).value.fileName
501
503
  : undefined);
502
504
  if (selectedFileNodePath) {
503
505
  const file = this.filesIndex.get(selectedFileNodePath);
@@ -514,17 +516,17 @@ export class GraphGenerationState {
514
516
  }
515
517
 
516
518
  onTreeNodeSelect(
517
- node: GenerationTreeNodeData,
518
- treeData: TreeData<GenerationTreeNodeData>,
519
+ node: FileSystemTreeNodeData,
520
+ treeData: TreeData<FileSystemTreeNodeData>,
519
521
  reprocess?: boolean,
520
522
  ): void {
521
523
  if (node.childrenIds?.length) {
522
524
  node.isOpen = !node.isOpen;
523
- if (node.fileNode instanceof GenerationDirectory) {
525
+ if (node.fileNode instanceof FileSystem_Directory) {
524
526
  populateDirectoryTreeNodeChildren(node, treeData);
525
527
  }
526
528
  }
527
- if (!reprocess && node.fileNode instanceof GenerationFile) {
529
+ if (!reprocess && node.fileNode instanceof FileSystem_File) {
528
530
  this.editorStore.tabManagerState.openTab(
529
531
  new FileGenerationViewerState(this.editorStore, node.fileNode),
530
532
  );
@@ -535,7 +537,7 @@ export class GraphGenerationState {
535
537
  );
536
538
  }
537
539
 
538
- setSelectedNode(node?: GenerationTreeNodeData): void {
540
+ setSelectedNode(node?: FileSystemTreeNodeData): void {
539
541
  if (this.selectedNode) {
540
542
  this.selectedNode.isSelected = false;
541
543
  }
@@ -546,7 +548,9 @@ export class GraphGenerationState {
546
548
  }
547
549
 
548
550
  emptyFileGeneration(): void {
549
- this.filesIndex = new Map<string, GenerationFile>();
550
- this.rootFileDirectory = new GenerationDirectory(GENERATION_FILE_ROOT_NAME);
551
+ this.filesIndex = new Map<string, FileSystem_File>();
552
+ this.rootFileDirectory = new FileSystem_Directory(
553
+ GENERATION_FILE_ROOT_NAME,
554
+ );
551
555
  }
552
556
  }