@finos/legend-application-studio 27.1.0 → 27.1.2

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 (156) hide show
  1. package/lib/__lib__/LegendStudioEvent.d.ts +1 -0
  2. package/lib/__lib__/LegendStudioEvent.d.ts.map +1 -1
  3. package/lib/__lib__/LegendStudioEvent.js +1 -0
  4. package/lib/__lib__/LegendStudioEvent.js.map +1 -1
  5. package/lib/components/editor/editor-group/FunctionEditor.d.ts.map +1 -1
  6. package/lib/components/editor/editor-group/FunctionEditor.js +28 -24
  7. package/lib/components/editor/editor-group/FunctionEditor.js.map +1 -1
  8. package/lib/components/editor/editor-group/connection-editor/{DatabaseBuilder.d.ts → DatabaseBuilderWizard.d.ts} +4 -11
  9. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.d.ts.map +1 -0
  10. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js +48 -0
  11. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js.map +1 -0
  12. package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.d.ts +32 -0
  13. package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.d.ts.map +1 -0
  14. package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.js +99 -0
  15. package/lib/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.js.map +1 -0
  16. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js +1 -1
  17. package/lib/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.js.map +1 -1
  18. package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.d.ts.map +1 -1
  19. package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js +5 -4
  20. package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js.map +1 -1
  21. package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.d.ts.map +1 -1
  22. package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js +62 -12
  23. package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js.map +1 -1
  24. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts +1 -1
  25. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts.map +1 -1
  26. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js +101 -137
  27. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js.map +1 -1
  28. package/lib/components/editor/editor-group/testable/TestableSharedComponents.d.ts +11 -0
  29. package/lib/components/editor/editor-group/testable/TestableSharedComponents.d.ts.map +1 -1
  30. package/lib/components/editor/editor-group/testable/TestableSharedComponents.js +27 -2
  31. package/lib/components/editor/editor-group/testable/TestableSharedComponents.js.map +1 -1
  32. package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts +0 -7
  33. package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts.map +1 -1
  34. package/lib/components/editor/panel-group/SQLPlaygroundPanel.js +20 -77
  35. package/lib/components/editor/panel-group/SQLPlaygroundPanel.js.map +1 -1
  36. package/lib/components/editor/side-bar/Explorer.js +3 -3
  37. package/lib/components/editor/side-bar/Explorer.js.map +1 -1
  38. package/lib/components/editor/side-bar/WorkflowManager.d.ts.map +1 -1
  39. package/lib/components/editor/side-bar/WorkflowManager.js +6 -1
  40. package/lib/components/editor/side-bar/WorkflowManager.js.map +1 -1
  41. package/lib/index.css +2 -2
  42. package/lib/index.css.map +1 -1
  43. package/lib/package.json +3 -3
  44. package/lib/stores/editor/ExplorerTreeState.d.ts +4 -4
  45. package/lib/stores/editor/ExplorerTreeState.d.ts.map +1 -1
  46. package/lib/stores/editor/ExplorerTreeState.js +4 -4
  47. package/lib/stores/editor/ExplorerTreeState.js.map +1 -1
  48. package/lib/stores/editor/NewElementState.d.ts.map +1 -1
  49. package/lib/stores/editor/NewElementState.js.map +1 -1
  50. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts +12 -12
  51. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.d.ts.map +1 -1
  52. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js +45 -46
  53. package/lib/stores/editor/editor-state/element-editor-state/FunctionEditorState.js.map +1 -1
  54. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts +20 -29
  55. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts.map +1 -1
  56. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js +60 -141
  57. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js.map +1 -1
  58. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts +33 -0
  59. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts.map +1 -0
  60. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js +71 -0
  61. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js.map +1 -0
  62. package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.d.ts +2 -2
  63. package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.d.ts.map +1 -1
  64. package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.js +2 -2
  65. package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.js.map +1 -1
  66. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts +14 -19
  67. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts.map +1 -1
  68. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.js +30 -65
  69. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.js.map +1 -1
  70. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts +56 -78
  71. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts.map +1 -1
  72. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js +285 -384
  73. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js.map +1 -1
  74. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.d.ts +23 -0
  75. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.d.ts.map +1 -0
  76. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.js +129 -0
  77. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.js.map +1 -0
  78. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
  79. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js +2 -2
  80. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
  81. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts +1 -0
  82. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts.map +1 -1
  83. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js +12 -2
  84. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js.map +1 -1
  85. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.d.ts.map +1 -1
  86. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js +15 -8
  87. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js.map +1 -1
  88. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts +7 -4
  89. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts.map +1 -1
  90. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js +53 -10
  91. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js.map +1 -1
  92. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts +2 -1
  93. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts.map +1 -1
  94. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js +20 -16
  95. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js.map +1 -1
  96. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts +3 -48
  97. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts.map +1 -1
  98. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js +12 -350
  99. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js.map +1 -1
  100. package/lib/stores/editor/sidebar-state/WorkflowManagerState.d.ts +5 -0
  101. package/lib/stores/editor/sidebar-state/WorkflowManagerState.d.ts.map +1 -1
  102. package/lib/stores/editor/sidebar-state/WorkflowManagerState.js +26 -0
  103. package/lib/stores/editor/sidebar-state/WorkflowManagerState.js.map +1 -1
  104. package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.d.ts +1 -1
  105. package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.d.ts.map +1 -1
  106. package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.js +3 -0
  107. package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.js.map +1 -1
  108. package/lib/stores/editor/utils/MockDataUtils.d.ts.map +1 -1
  109. package/lib/stores/editor/utils/MockDataUtils.js +3 -0
  110. package/lib/stores/editor/utils/MockDataUtils.js.map +1 -1
  111. package/lib/stores/editor/utils/TestableUtils.d.ts +11 -1
  112. package/lib/stores/editor/utils/TestableUtils.d.ts.map +1 -1
  113. package/lib/stores/editor/utils/TestableUtils.js +50 -1
  114. package/lib/stores/editor/utils/TestableUtils.js.map +1 -1
  115. package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.d.ts +5 -4
  116. package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.d.ts.map +1 -1
  117. package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js +4 -1
  118. package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js.map +1 -1
  119. package/package.json +9 -9
  120. package/src/__lib__/LegendStudioEvent.ts +1 -1
  121. package/src/components/editor/editor-group/FunctionEditor.tsx +133 -118
  122. package/src/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.tsx +191 -0
  123. package/src/components/editor/editor-group/connection-editor/DatabaseSchemaExplorer.tsx +227 -0
  124. package/src/components/editor/editor-group/connection-editor/RelationalDatabaseConnectionEditor.tsx +1 -1
  125. package/src/components/editor/editor-group/data-editor/EmbeddedDataEditor.tsx +34 -37
  126. package/src/components/editor/editor-group/data-editor/RelationalCSVDataEditor.tsx +134 -31
  127. package/src/components/editor/editor-group/mapping-editor/MappingTestableEditor.tsx +296 -414
  128. package/src/components/editor/editor-group/testable/TestableSharedComponents.tsx +88 -3
  129. package/src/components/editor/panel-group/SQLPlaygroundPanel.tsx +47 -211
  130. package/src/components/editor/side-bar/Explorer.tsx +3 -3
  131. package/src/components/editor/side-bar/WorkflowManager.tsx +10 -0
  132. package/src/stores/editor/ExplorerTreeState.ts +6 -9
  133. package/src/stores/editor/NewElementState.ts +0 -1
  134. package/src/stores/editor/editor-state/element-editor-state/FunctionEditorState.ts +44 -50
  135. package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts +88 -212
  136. package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.ts +102 -0
  137. package/src/stores/editor/editor-state/element-editor-state/data/DataEditorState.ts +7 -1
  138. package/src/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.ts +48 -77
  139. package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.ts +407 -617
  140. package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.ts +243 -0
  141. package/src/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.ts +6 -2
  142. package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +18 -1
  143. package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.ts +20 -12
  144. package/src/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.ts +76 -18
  145. package/src/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.ts +29 -24
  146. package/src/stores/editor/panel-group/SQLPlaygroundPanelState.ts +13 -533
  147. package/src/stores/editor/sidebar-state/WorkflowManagerState.ts +47 -0
  148. package/src/stores/editor/sidebar-state/testable/GlobalTestRunnerState.ts +4 -1
  149. package/src/stores/editor/utils/MockDataUtils.ts +2 -0
  150. package/src/stores/editor/utils/TestableUtils.ts +73 -0
  151. package/src/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.ts +15 -12
  152. package/tsconfig.json +4 -1
  153. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.d.ts.map +0 -1
  154. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js +0 -133
  155. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js.map +0 -1
  156. package/src/components/editor/editor-group/connection-editor/DatabaseBuilder.tsx +0 -397
@@ -14,40 +14,21 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import type { TreeData, TreeNodeData } from '@finos/legend-art';
18
17
  import {
19
18
  type GeneratorFn,
20
19
  assertErrorThrown,
21
20
  LogEvent,
22
- addUniqueEntry,
23
- isNonNullable,
24
- filterByType,
25
- ActionState,
26
- getNonNullableEntry,
27
21
  getNullableLastEntry,
28
- type Writable,
29
- guaranteeNonNullable,
30
- IllegalStateError,
31
22
  } from '@finos/legend-shared';
32
23
  import { observable, makeObservable, flow, flowResult, action } from 'mobx';
33
24
  import { editor as monacoEditorAPI } from 'monaco-editor';
34
25
  import {
35
- type Schema,
36
- type Table,
37
26
  type Database,
38
27
  type PackageableConnection,
39
- DatabaseBuilderInput,
40
- DatabasePattern,
41
- TargetDatabase,
42
- Column,
43
- getSchema,
44
28
  guaranteeRelationalDatabaseConnection,
45
29
  GRAPH_MANAGER_EVENT,
46
- getNullableSchema,
47
- getNullableTable,
48
30
  } from '@finos/legend-graph';
49
31
  import type { EditorStore } from '../EditorStore.js';
50
- import { LEGEND_STUDIO_APP_EVENT } from '../../../__lib__/LegendStudioEvent.js';
51
32
  import {
52
33
  CODE_EDITOR_LANGUAGE,
53
34
  moveCursorToPosition,
@@ -55,77 +36,8 @@ import {
55
36
  import type { CommandRegistrar } from '@finos/legend-application';
56
37
  import { STO_RELATIONAL_LEGEND_STUDIO_COMMAND_KEY } from '../../../__lib__/STO_Relational_LegendStudioCommand.js';
57
38
  import { PANEL_MODE } from '../EditorConfig.js';
58
- import type { Entity } from '@finos/legend-storage';
59
- import { GraphEditFormModeState } from '../GraphEditFormModeState.js';
39
+ import { DatabaseSchemaExplorerState } from '../editor-state/element-editor-state/connection/DatabaseBuilderState.js';
60
40
 
61
- export abstract class DatabaseSchemaExplorerTreeNodeData
62
- implements TreeNodeData
63
- {
64
- isOpen?: boolean | undefined;
65
- id: string;
66
- label: string;
67
- parentId?: string | undefined;
68
- childrenIds?: string[] | undefined;
69
- isChecked = false;
70
-
71
- constructor(id: string, label: string, parentId: string | undefined) {
72
- makeObservable(this, {
73
- isChecked: observable,
74
- setChecked: action,
75
- });
76
-
77
- this.id = id;
78
- this.label = label;
79
- this.parentId = parentId;
80
- }
81
-
82
- setChecked(val: boolean): void {
83
- this.isChecked = val;
84
- }
85
- }
86
-
87
- export class DatabaseSchemaExplorerTreeSchemaNodeData extends DatabaseSchemaExplorerTreeNodeData {
88
- schema: Schema;
89
-
90
- constructor(id: string, schema: Schema) {
91
- super(id, schema.name, undefined);
92
- this.schema = schema;
93
- }
94
- }
95
-
96
- export class DatabaseSchemaExplorerTreeTableNodeData extends DatabaseSchemaExplorerTreeNodeData {
97
- override parentId: string;
98
- owner: Schema;
99
- table: Table;
100
-
101
- constructor(id: string, parentId: string, owner: Schema, table: Table) {
102
- super(id, table.name, parentId);
103
- this.parentId = parentId;
104
- this.owner = owner;
105
- this.table = table;
106
- }
107
- }
108
-
109
- export class DatabaseSchemaExplorerTreeColumnNodeData extends DatabaseSchemaExplorerTreeNodeData {
110
- override parentId: string;
111
- owner: Table;
112
- column: Column;
113
-
114
- constructor(id: string, parentId: string, owner: Table, column: Column) {
115
- super(id, column.name, parentId);
116
- this.parentId = parentId;
117
- this.owner = owner;
118
- this.column = column;
119
- }
120
- }
121
-
122
- export interface DatabaseSchemaExplorerTreeData
123
- extends TreeData<DatabaseSchemaExplorerTreeNodeData> {
124
- database: Database;
125
- }
126
-
127
- const DUMMY_DATABASE_PACKAGE = 'dummy';
128
- const DUMMY_DATABASE_NAME = 'DummyDB';
129
41
  const DEFAULT_SQL_TEXT = `--Start building your SQL. Note that you can also drag-and-drop nodes from schema explorer\n`;
130
42
 
131
43
  export class SQLPlaygroundPanelState implements CommandRegistrar {
@@ -136,7 +48,8 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
136
48
 
137
49
  connection?: PackageableConnection | undefined;
138
50
  database?: Database | undefined;
139
- treeData?: DatabaseSchemaExplorerTreeData | undefined;
51
+ schemaExplorerState?: DatabaseSchemaExplorerState | undefined;
52
+
140
53
  readonly sqlEditorTextModel: monacoEditorAPI.ITextModel;
141
54
  sqlEditor?: monacoEditorAPI.IStandaloneCodeEditor | undefined;
142
55
  sqlEditorViewState?: monacoEditorAPI.ICodeEditorViewState | undefined;
@@ -152,26 +65,17 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
152
65
  isExecutingRawSQL: observable,
153
66
  connection: observable,
154
67
  database: observable,
155
- treeData: observable,
68
+ schemaExplorerState: observable,
156
69
  sqlText: observable,
157
70
  resetSQL: action,
158
71
  sqlExecutionResult: observable,
159
72
  sqlEditor: observable.ref,
160
73
  sqlEditorViewState: observable.ref,
161
- isBuildingDatabase: observable,
162
- isUpdatingDatabase: observable,
163
- setTreeData: action,
164
74
  setConnection: action,
165
75
  setSQLEditor: action,
166
76
  setSQLEditorViewState: action,
167
77
  setSQLText: action,
168
- onNodeSelect: flow,
169
- fetchDatabaseMetadata: flow,
170
- fetchSchemaMetadata: flow,
171
- fetchTableMetadata: flow,
172
78
  executeRawSQL: flow,
173
- generateDatabase: flow,
174
- updateDatabase: flow,
175
79
  });
176
80
 
177
81
  this.editorStore = editorStore;
@@ -181,14 +85,18 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
181
85
  );
182
86
  }
183
87
 
184
- setTreeData(val?: DatabaseSchemaExplorerTreeData): void {
185
- this.treeData = val;
186
- }
187
-
188
88
  setConnection(val: PackageableConnection | undefined): void {
189
89
  this.connection = val;
190
90
  if (val) {
191
- this.database = guaranteeRelationalDatabaseConnection(val).store.value;
91
+ const connection = guaranteeRelationalDatabaseConnection(val);
92
+ this.database = connection.store.value;
93
+ this.schemaExplorerState = new DatabaseSchemaExplorerState(
94
+ this.editorStore,
95
+ connection,
96
+ );
97
+ } else {
98
+ this.database = undefined;
99
+ this.schemaExplorerState = undefined;
192
100
  }
193
101
  this.sqlEditorTextModel.setValue(DEFAULT_SQL_TEXT);
194
102
  }
@@ -243,291 +151,6 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
243
151
  );
244
152
  }
245
153
 
246
- *onNodeSelect(
247
- node: DatabaseSchemaExplorerTreeNodeData,
248
- treeData: DatabaseSchemaExplorerTreeData,
249
- ): GeneratorFn<void> {
250
- if (
251
- node instanceof DatabaseSchemaExplorerTreeSchemaNodeData &&
252
- !node.childrenIds
253
- ) {
254
- yield flowResult(this.fetchSchemaMetadata(node, treeData));
255
- } else if (
256
- node instanceof DatabaseSchemaExplorerTreeTableNodeData &&
257
- !node.childrenIds
258
- ) {
259
- yield flowResult(this.fetchTableMetadata(node, treeData));
260
- }
261
- node.isOpen = !node.isOpen;
262
- this.setTreeData({ ...treeData });
263
- }
264
-
265
- getChildNodes(
266
- node: DatabaseSchemaExplorerTreeNodeData,
267
- treeData: DatabaseSchemaExplorerTreeData,
268
- ): DatabaseSchemaExplorerTreeNodeData[] | undefined {
269
- return node.childrenIds
270
- ?.map((childNode) => treeData.nodes.get(childNode))
271
- .filter(isNonNullable);
272
- }
273
-
274
- toggleCheckedNode(
275
- node: DatabaseSchemaExplorerTreeNodeData,
276
- treeData: DatabaseSchemaExplorerTreeData,
277
- ): void {
278
- node.setChecked(!node.isChecked);
279
- if (node instanceof DatabaseSchemaExplorerTreeSchemaNodeData) {
280
- this.getChildNodes(node, treeData)?.forEach((childNode) => {
281
- childNode.setChecked(node.isChecked);
282
- });
283
- } else if (node instanceof DatabaseSchemaExplorerTreeTableNodeData) {
284
- if (node.parentId) {
285
- const parent = treeData.nodes.get(node.parentId);
286
- if (
287
- parent &&
288
- this.getChildNodes(parent, treeData)?.every(
289
- (e) => e.isChecked === node.isChecked,
290
- )
291
- ) {
292
- parent.setChecked(node.isChecked);
293
- }
294
- }
295
- }
296
-
297
- // TODO: support toggling check for columns
298
- this.setTreeData({ ...treeData });
299
- }
300
-
301
- *fetchDatabaseMetadata(): GeneratorFn<void> {
302
- if (!this.connection) {
303
- return;
304
- }
305
-
306
- try {
307
- this.isFetchingSchema = true;
308
-
309
- const databaseBuilderInput = new DatabaseBuilderInput(
310
- guaranteeRelationalDatabaseConnection(this.connection),
311
- );
312
- databaseBuilderInput.targetDatabase = new TargetDatabase(
313
- DUMMY_DATABASE_PACKAGE,
314
- DUMMY_DATABASE_NAME,
315
- );
316
- databaseBuilderInput.config.maxTables = undefined;
317
- databaseBuilderInput.config.enrichTables = false;
318
- databaseBuilderInput.config.patterns = [
319
- new DatabasePattern(undefined, undefined),
320
- ];
321
-
322
- const database = (yield this.buildIntermediateDatabase(
323
- databaseBuilderInput,
324
- )) as Database;
325
- const rootIds: string[] = [];
326
- const nodes = new Map<string, DatabaseSchemaExplorerTreeNodeData>();
327
- database.schemas
328
- .slice()
329
- .sort((schemaA, schemaB) => schemaA.name.localeCompare(schemaB.name))
330
- .forEach((dbSchema) => {
331
- const schemaId = dbSchema.name;
332
- rootIds.push(schemaId);
333
- const schemaNode = new DatabaseSchemaExplorerTreeSchemaNodeData(
334
- schemaId,
335
- dbSchema,
336
- );
337
- nodes.set(schemaId, schemaNode);
338
-
339
- schemaNode.setChecked(
340
- Boolean(
341
- this.database?.schemas.find(
342
- (schema) => schema.name === dbSchema.name,
343
- ),
344
- ),
345
- );
346
- });
347
- const treeData = { rootIds, nodes, database };
348
- this.setTreeData(treeData);
349
- } catch (error) {
350
- assertErrorThrown(error);
351
- this.editorStore.applicationStore.logService.error(
352
- LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_BUILDER_FAILURE),
353
- error,
354
- );
355
- this.editorStore.applicationStore.notificationService.notifyError(error);
356
- } finally {
357
- this.isFetchingSchema = false;
358
- }
359
- }
360
-
361
- *fetchSchemaMetadata(
362
- schemaNode: DatabaseSchemaExplorerTreeSchemaNodeData,
363
- treeData: DatabaseSchemaExplorerTreeData,
364
- ): GeneratorFn<void> {
365
- if (!this.connection) {
366
- return;
367
- }
368
-
369
- try {
370
- this.isFetchingSchema = true;
371
-
372
- const schema = schemaNode.schema;
373
- const databaseBuilderInput = new DatabaseBuilderInput(
374
- guaranteeRelationalDatabaseConnection(this.connection),
375
- );
376
- databaseBuilderInput.targetDatabase = new TargetDatabase(
377
- DUMMY_DATABASE_PACKAGE,
378
- DUMMY_DATABASE_NAME,
379
- );
380
- databaseBuilderInput.config.maxTables = undefined;
381
- databaseBuilderInput.config.enrichTables = true;
382
- databaseBuilderInput.config.patterns = [
383
- new DatabasePattern(schema.name, undefined),
384
- ];
385
-
386
- const database = (yield this.buildIntermediateDatabase(
387
- databaseBuilderInput,
388
- )) as Database;
389
- const tables = getSchema(database, schema.name).tables;
390
- const childrenIds = schemaNode.childrenIds ?? [];
391
- schema.tables = tables;
392
- tables
393
- .slice()
394
- .sort((tableA, tableB) => tableA.name.localeCompare(tableB.name))
395
- .forEach((table) => {
396
- table.schema = schema;
397
- const tableId = `${schema.name}.${table.name}`;
398
- const tableNode = new DatabaseSchemaExplorerTreeTableNodeData(
399
- tableId,
400
- schemaNode.id,
401
- schema,
402
- table,
403
- );
404
- treeData.nodes.set(tableId, tableNode);
405
- addUniqueEntry(childrenIds, tableId);
406
-
407
- if (this.database) {
408
- const matchingSchema = getNullableSchema(
409
- this.database,
410
- schema.name,
411
- );
412
- tableNode.setChecked(
413
- Boolean(
414
- matchingSchema
415
- ? getNullableTable(matchingSchema, table.name)
416
- : undefined,
417
- ),
418
- );
419
- } else {
420
- tableNode.setChecked(false);
421
- }
422
- });
423
- schemaNode.childrenIds = childrenIds;
424
- this.setTreeData({ ...treeData });
425
- } catch (error) {
426
- assertErrorThrown(error);
427
- this.editorStore.applicationStore.logService.error(
428
- LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_BUILDER_FAILURE),
429
- error,
430
- );
431
- this.editorStore.applicationStore.notificationService.notifyError(error);
432
- } finally {
433
- this.isFetchingSchema = false;
434
- }
435
- }
436
-
437
- *fetchTableMetadata(
438
- tableNode: DatabaseSchemaExplorerTreeTableNodeData,
439
- treeData: DatabaseSchemaExplorerTreeData,
440
- ): GeneratorFn<void> {
441
- if (!this.connection) {
442
- return;
443
- }
444
-
445
- try {
446
- this.isFetchingSchema = true;
447
-
448
- const table = tableNode.table;
449
- const databaseBuilderInput = new DatabaseBuilderInput(
450
- guaranteeRelationalDatabaseConnection(this.connection),
451
- );
452
- databaseBuilderInput.targetDatabase = new TargetDatabase(
453
- DUMMY_DATABASE_PACKAGE,
454
- DUMMY_DATABASE_NAME,
455
- );
456
- const config = databaseBuilderInput.config;
457
- config.maxTables = undefined;
458
- config.enrichTables = true;
459
- config.enrichColumns = true;
460
- config.enrichPrimaryKeys = true;
461
- config.patterns = [new DatabasePattern(table.schema.name, table.name)];
462
- const database = (yield this.buildIntermediateDatabase(
463
- databaseBuilderInput,
464
- )) as Database;
465
-
466
- const enrichedTable = database.schemas
467
- .find((schema) => table.schema.name === schema.name)
468
- ?.tables.find((t) => t.name === table.name);
469
- if (enrichedTable) {
470
- table.primaryKey = enrichedTable.primaryKey;
471
- const columns = enrichedTable.columns.filter(filterByType(Column));
472
- tableNode.table.columns = columns;
473
- tableNode.childrenIds?.forEach((c) => treeData.nodes.delete(c));
474
- tableNode.childrenIds = undefined;
475
- const childrenIds: string[] = [];
476
- const tableId = tableNode.id;
477
- columns
478
- .slice()
479
- .sort((colA, colB) => colA.name.localeCompare(colB.name))
480
- .forEach((col) => {
481
- const columnId = `${tableId}.${col.name}`;
482
- const columnNode = new DatabaseSchemaExplorerTreeColumnNodeData(
483
- columnId,
484
- tableId,
485
- table,
486
- col,
487
- );
488
- col.owner = tableNode.table;
489
- treeData.nodes.set(columnId, columnNode);
490
- addUniqueEntry(childrenIds, columnId);
491
- });
492
- tableNode.childrenIds = childrenIds;
493
- }
494
- } catch (error) {
495
- assertErrorThrown(error);
496
- this.editorStore.applicationStore.logService.error(
497
- LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_BUILDER_FAILURE),
498
- error,
499
- );
500
- this.editorStore.applicationStore.notificationService.notifyError(error);
501
- } finally {
502
- this.isFetchingSchema = false;
503
- }
504
- }
505
-
506
- /**
507
- * This will build the intermediate database from the specified
508
- * schema exploration input; this information can be further used
509
- * to enrich the explorer tree
510
- */
511
- private async buildIntermediateDatabase(
512
- input: DatabaseBuilderInput,
513
- ): Promise<Database> {
514
- const entities =
515
- await this.editorStore.graphManagerState.graphManager.buildDatabase(
516
- input,
517
- );
518
- const graph = this.editorStore.graphManagerState.createNewGraph();
519
- await this.editorStore.graphManagerState.graphManager.buildGraph(
520
- graph,
521
- entities,
522
- ActionState.create(),
523
- );
524
- return getNonNullableEntry(
525
- graph.ownDatabases,
526
- 0,
527
- 'Expected one database to be generated from input',
528
- );
529
- }
530
-
531
154
  *executeRawSQL(): GeneratorFn<void> {
532
155
  if (!this.connection || this.isExecutingRawSQL) {
533
156
  return;
@@ -562,147 +185,4 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
562
185
  this.isExecutingRawSQL = false;
563
186
  }
564
187
  }
565
-
566
- *generateDatabase(): GeneratorFn<Entity> {
567
- if (!this.database || !this.connection || !this.treeData) {
568
- throw new IllegalStateError(
569
- `Can't build database: builder is not properly set up`,
570
- );
571
- }
572
-
573
- try {
574
- this.isBuildingDatabase = true;
575
-
576
- const treeData = this.treeData;
577
- const databaseBuilderInput = new DatabaseBuilderInput(
578
- guaranteeRelationalDatabaseConnection(this.connection),
579
- );
580
- const packagePath = guaranteeNonNullable(this.database.package).path;
581
- const databaseName = this.database.name;
582
- databaseBuilderInput.targetDatabase = new TargetDatabase(
583
- packagePath,
584
- databaseName,
585
- );
586
- const config = databaseBuilderInput.config;
587
- config.maxTables = undefined;
588
- config.enrichTables = true;
589
- config.enrichColumns = true;
590
- config.enrichPrimaryKeys = true;
591
- treeData.rootIds
592
- .map((e) => treeData.nodes.get(e))
593
- .filter(isNonNullable)
594
- .forEach((schemaNode) => {
595
- if (schemaNode instanceof DatabaseSchemaExplorerTreeSchemaNodeData) {
596
- const tableNodes = this.getChildNodes(schemaNode, treeData);
597
- const allChecked = tableNodes?.every((t) => t.isChecked === true);
598
- if (
599
- allChecked ||
600
- (schemaNode.isChecked && !schemaNode.childrenIds)
601
- ) {
602
- config.patterns.push(
603
- new DatabasePattern(schemaNode.schema.name, undefined),
604
- );
605
- } else {
606
- tableNodes?.forEach((t) => {
607
- if (
608
- t instanceof DatabaseSchemaExplorerTreeTableNodeData &&
609
- t.isChecked
610
- ) {
611
- config.patterns.push(
612
- new DatabasePattern(schemaNode.schema.name, t.table.name),
613
- );
614
- }
615
- });
616
- }
617
- }
618
- });
619
- const entities =
620
- (yield this.editorStore.graphManagerState.graphManager.buildDatabase(
621
- databaseBuilderInput,
622
- )) as Entity[];
623
- return getNonNullableEntry(
624
- entities,
625
- 0,
626
- 'Expected a database to be generated',
627
- );
628
- } finally {
629
- this.isBuildingDatabase = false;
630
- }
631
- }
632
-
633
- *updateDatabase(): GeneratorFn<void> {
634
- if (!this.treeData || !this.database || !this.connection) {
635
- return;
636
- }
637
-
638
- try {
639
- this.isUpdatingDatabase = true;
640
-
641
- const graph = this.editorStore.graphManagerState.createNewGraph();
642
- (yield this.editorStore.graphManagerState.graphManager.buildGraph(
643
- graph,
644
- [(yield flowResult(this.generateDatabase())) as Entity],
645
- ActionState.create(),
646
- )) as Entity[];
647
- const generatedDatabase = getNonNullableEntry(
648
- graph.ownDatabases,
649
- 0,
650
- 'Expected one database to be generated from input',
651
- );
652
-
653
- const currentDatabase = this.database;
654
-
655
- // remove undefined schemas
656
- const schemas = Array.from(this.treeData.nodes.values())
657
- .map((schemaNode) => {
658
- if (schemaNode instanceof DatabaseSchemaExplorerTreeSchemaNodeData) {
659
- return schemaNode.schema;
660
- }
661
- return undefined;
662
- })
663
- .filter(isNonNullable);
664
- currentDatabase.schemas = currentDatabase.schemas.filter((schema) => {
665
- if (
666
- schemas.find((item) => item.name === schema.name) &&
667
- !generatedDatabase.schemas.find((s) => s.name === schema.name)
668
- ) {
669
- return false;
670
- }
671
- return true;
672
- });
673
-
674
- // update existing schemas
675
- generatedDatabase.schemas.forEach((schema) => {
676
- (schema as Writable<Schema>)._OWNER = currentDatabase;
677
- const currentSchemaIndex = currentDatabase.schemas.findIndex(
678
- (item) => item.name === schema.name,
679
- );
680
- if (currentSchemaIndex !== -1) {
681
- currentDatabase.schemas[currentSchemaIndex] = schema;
682
- } else {
683
- currentDatabase.schemas.push(schema);
684
- }
685
- });
686
-
687
- this.editorStore.applicationStore.notificationService.notifySuccess(
688
- `Database successfully updated`,
689
- );
690
- yield flowResult(
691
- this.editorStore
692
- .getGraphEditorMode(GraphEditFormModeState)
693
- .globalCompile({
694
- message: `Can't compile graph after editing database. Redirecting you to text mode`,
695
- }),
696
- );
697
- } catch (error) {
698
- assertErrorThrown(error);
699
- this.editorStore.applicationStore.logService.error(
700
- LogEvent.create(LEGEND_STUDIO_APP_EVENT.DATABASE_BUILDER_FAILURE),
701
- error,
702
- );
703
- this.editorStore.applicationStore.notificationService.notifyError(error);
704
- } finally {
705
- this.isUpdatingDatabase = false;
706
- }
707
- }
708
188
  }
@@ -204,6 +204,7 @@ export class WorkflowState {
204
204
  cancelJob: flow,
205
205
  refreshWorkflow: flow,
206
206
  retryJob: flow,
207
+ runManualJob: flow,
207
208
  });
208
209
 
209
210
  this.editorStore = editorStore;
@@ -325,6 +326,26 @@ export class WorkflowState {
325
326
  this.isExecutingWorkflowRequest = false;
326
327
  }
327
328
  }
329
+
330
+ *runManualJob(
331
+ workflowJob: WorkflowJob,
332
+ treeData: TreeData<WorkflowExplorerTreeNodeData>,
333
+ ): GeneratorFn<void> {
334
+ try {
335
+ this.isExecutingWorkflowRequest = true;
336
+ yield flowResult(this.workflowManagerState.runManualJob(workflowJob));
337
+ yield flowResult(this.refreshWorkflow(workflowJob.workflowId, treeData));
338
+ } catch (error) {
339
+ assertErrorThrown(error);
340
+ this.editorStore.applicationStore.logService.error(
341
+ LogEvent.create(LEGEND_STUDIO_APP_EVENT.SDLC_MANAGER_FAILURE),
342
+ error,
343
+ );
344
+ this.editorStore.applicationStore.notificationService.notifyError(error);
345
+ } finally {
346
+ this.isExecutingWorkflowRequest = false;
347
+ }
348
+ }
328
349
  }
329
350
 
330
351
  export abstract class WorkflowManagerState {
@@ -346,6 +367,7 @@ export abstract class WorkflowManagerState {
346
367
  getJob: flow,
347
368
  retryJob: flow,
348
369
  cancelJob: flow,
370
+ runManualJob: flow,
349
371
  getJobLogs: flow,
350
372
  });
351
373
 
@@ -365,6 +387,7 @@ export abstract class WorkflowManagerState {
365
387
  abstract getJobs(workflowId: string): GeneratorFn<WorkflowJob[]>;
366
388
  abstract getJob(job: WorkflowJob): GeneratorFn<WorkflowJob[]>;
367
389
  abstract retryJob(workflowJob: WorkflowJob): GeneratorFn<void>;
390
+ abstract runManualJob(workflowJob: WorkflowJob): GeneratorFn<void>;
368
391
  abstract cancelJob(workflowJob: WorkflowJob): GeneratorFn<void>;
369
392
  abstract getJobLogs(workflowJob: WorkflowJob): GeneratorFn<string>;
370
393
 
@@ -475,6 +498,14 @@ export class WorkspaceWorkflowManagerState extends WorkflowManagerState {
475
498
  )) as PlainObject<WorkflowJob>[];
476
499
  }
477
500
 
501
+ override *runManualJob(workflowJob: WorkflowJob): GeneratorFn<void> {
502
+ (yield this.editorStore.sdlcServerClient.runManualWorkflowJob(
503
+ this.sdlcState.activeProject.projectId,
504
+ this.sdlcState.activeWorkspace,
505
+ workflowJob,
506
+ )) as PlainObject<WorkflowJob>[];
507
+ }
508
+
478
509
  override *cancelJob(workflowJob: WorkflowJob): GeneratorFn<void> {
479
510
  (yield this.editorStore.sdlcServerClient.cancelWorkflowJob(
480
511
  this.sdlcState.activeProject.projectId,
@@ -556,6 +587,14 @@ export class ProjectVersionWorkflowManagerState extends WorkflowManagerState {
556
587
  )) as PlainObject<WorkflowJob>[];
557
588
  }
558
589
 
590
+ override *runManualJob(workflowJob: WorkflowJob): GeneratorFn<void> {
591
+ (yield this.editorStore.sdlcServerClient.runManualWorkflowJobByVersion(
592
+ this.sdlcState.activeProject.projectId,
593
+ this.version.id.id,
594
+ workflowJob,
595
+ )) as PlainObject<WorkflowJob>[];
596
+ }
597
+
559
598
  override *cancelJob(workflowJob: WorkflowJob): GeneratorFn<void> {
560
599
  (yield this.editorStore.sdlcServerClient.cancelWorkflowJobByVersion(
561
600
  this.sdlcState.activeProject.projectId,
@@ -627,6 +666,14 @@ export class ProjectWorkflowManagerState extends WorkflowManagerState {
627
666
  )) as PlainObject<WorkflowJob>[];
628
667
  }
629
668
 
669
+ override *runManualJob(workflowJob: WorkflowJob): GeneratorFn<void> {
670
+ (yield this.editorStore.sdlcServerClient.runManualWorkflowJob(
671
+ this.sdlcState.activeProject.projectId,
672
+ undefined,
673
+ workflowJob,
674
+ )) as PlainObject<WorkflowJob>[];
675
+ }
676
+
630
677
  override *cancelJob(workflowJob: WorkflowJob): GeneratorFn<void> {
631
678
  (yield this.editorStore.sdlcServerClient.cancelWorkflowJob(
632
679
  this.sdlcState.activeProject.projectId,