@finos/legend-application-studio 27.0.0 → 27.1.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 (176) hide show
  1. package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts +9 -1
  2. package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts.map +1 -1
  3. package/lib/__lib__/LegendStudioApplicationNavigationContext.js +11 -1
  4. package/lib/__lib__/LegendStudioApplicationNavigationContext.js.map +1 -1
  5. package/lib/__lib__/LegendStudioEvent.d.ts +1 -0
  6. package/lib/__lib__/LegendStudioEvent.d.ts.map +1 -1
  7. package/lib/__lib__/LegendStudioEvent.js +1 -0
  8. package/lib/__lib__/LegendStudioEvent.js.map +1 -1
  9. package/lib/application/LegendStudioApplicationConfig.d.ts +6 -0
  10. package/lib/application/LegendStudioApplicationConfig.d.ts.map +1 -1
  11. package/lib/application/LegendStudioApplicationConfig.js +7 -0
  12. package/lib/application/LegendStudioApplicationConfig.js.map +1 -1
  13. package/lib/components/ElementIconUtils.d.ts.map +1 -1
  14. package/lib/components/ElementIconUtils.js +3 -1
  15. package/lib/components/ElementIconUtils.js.map +1 -1
  16. package/lib/components/editor/editor-group/ModelImporter.d.ts.map +1 -1
  17. package/lib/components/editor/editor-group/ModelImporter.js +1 -0
  18. package/lib/components/editor/editor-group/ModelImporter.js.map +1 -1
  19. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.d.ts.map +1 -1
  20. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js +8 -10
  21. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js.map +1 -1
  22. package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.d.ts.map +1 -1
  23. package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js +10 -4
  24. package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js.map +1 -1
  25. package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.d.ts.map +1 -1
  26. package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js +65 -12
  27. package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js.map +1 -1
  28. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.d.ts.map +1 -1
  29. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js +3 -0
  30. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js.map +1 -1
  31. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.d.ts.map +1 -1
  32. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.js +3 -0
  33. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.js.map +1 -1
  34. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.d.ts.map +1 -1
  35. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.js +3 -0
  36. package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.js.map +1 -1
  37. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts +1 -1
  38. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.d.ts.map +1 -1
  39. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js +101 -137
  40. package/lib/components/editor/editor-group/mapping-editor/MappingTestableEditor.js.map +1 -1
  41. package/lib/components/editor/editor-group/mapping-editor/NewMappingElementModal.js +1 -2
  42. package/lib/components/editor/editor-group/mapping-editor/NewMappingElementModal.js.map +1 -1
  43. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.d.ts.map +1 -1
  44. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.js +9 -4
  45. package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.js.map +1 -1
  46. package/lib/components/editor/editor-group/testable/TestableSharedComponents.d.ts +11 -0
  47. package/lib/components/editor/editor-group/testable/TestableSharedComponents.d.ts.map +1 -1
  48. package/lib/components/editor/editor-group/testable/TestableSharedComponents.js +27 -2
  49. package/lib/components/editor/editor-group/testable/TestableSharedComponents.js.map +1 -1
  50. package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts.map +1 -1
  51. package/lib/components/editor/panel-group/SQLPlaygroundPanel.js +38 -6
  52. package/lib/components/editor/panel-group/SQLPlaygroundPanel.js.map +1 -1
  53. package/lib/components/editor/side-bar/CreateNewElementModal.d.ts +3 -0
  54. package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
  55. package/lib/components/editor/side-bar/CreateNewElementModal.js +43 -1
  56. package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
  57. package/lib/components/extensions/Core_LegendStudioApplicationPlugin.d.ts.map +1 -1
  58. package/lib/components/extensions/Core_LegendStudioApplicationPlugin.js +10 -0
  59. package/lib/components/extensions/Core_LegendStudioApplicationPlugin.js.map +1 -1
  60. package/lib/index.css +2 -2
  61. package/lib/index.css.map +1 -1
  62. package/lib/package.json +1 -1
  63. package/lib/stores/editor/EditorGraphState.js +1 -1
  64. package/lib/stores/editor/EditorGraphState.js.map +1 -1
  65. package/lib/stores/editor/EditorStore.d.ts.map +1 -1
  66. package/lib/stores/editor/EditorStore.js +10 -2
  67. package/lib/stores/editor/EditorStore.js.map +1 -1
  68. package/lib/stores/editor/NewElementState.d.ts +0 -1
  69. package/lib/stores/editor/NewElementState.d.ts.map +1 -1
  70. package/lib/stores/editor/NewElementState.js +43 -10
  71. package/lib/stores/editor/NewElementState.js.map +1 -1
  72. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts +0 -1
  73. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts.map +1 -1
  74. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js +26 -30
  75. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js.map +1 -1
  76. package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.d.ts +2 -2
  77. package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.d.ts.map +1 -1
  78. package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.js +2 -2
  79. package/lib/stores/editor/editor-state/element-editor-state/data/DataEditorState.js.map +1 -1
  80. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts +14 -19
  81. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.d.ts.map +1 -1
  82. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.js +30 -65
  83. package/lib/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.js.map +1 -1
  84. package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.d.ts +4 -1
  85. package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.d.ts.map +1 -1
  86. package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.js +5 -1
  87. package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.js.map +1 -1
  88. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts +56 -78
  89. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.d.ts.map +1 -1
  90. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js +285 -384
  91. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.js.map +1 -1
  92. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.d.ts +23 -0
  93. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.d.ts.map +1 -0
  94. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.js +129 -0
  95. package/lib/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.js.map +1 -0
  96. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.d.ts.map +1 -1
  97. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js +2 -2
  98. package/lib/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.js.map +1 -1
  99. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts +1 -0
  100. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts.map +1 -1
  101. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js +12 -2
  102. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js.map +1 -1
  103. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.d.ts.map +1 -1
  104. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js +15 -8
  105. package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.js.map +1 -1
  106. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts +7 -4
  107. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.d.ts.map +1 -1
  108. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js +53 -10
  109. package/lib/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.js.map +1 -1
  110. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts +2 -1
  111. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.d.ts.map +1 -1
  112. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js +20 -16
  113. package/lib/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.js.map +1 -1
  114. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts +9 -0
  115. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts.map +1 -1
  116. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js +149 -3
  117. package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js.map +1 -1
  118. package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.d.ts +1 -1
  119. package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.d.ts.map +1 -1
  120. package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.js +3 -0
  121. package/lib/stores/editor/sidebar-state/testable/GlobalTestRunnerState.js.map +1 -1
  122. package/lib/stores/editor/utils/MockDataUtils.d.ts.map +1 -1
  123. package/lib/stores/editor/utils/MockDataUtils.js +3 -0
  124. package/lib/stores/editor/utils/MockDataUtils.js.map +1 -1
  125. package/lib/stores/editor/utils/ModelClassifierUtils.d.ts +2 -5
  126. package/lib/stores/editor/utils/ModelClassifierUtils.d.ts.map +1 -1
  127. package/lib/stores/editor/utils/ModelClassifierUtils.js +2 -6
  128. package/lib/stores/editor/utils/ModelClassifierUtils.js.map +1 -1
  129. package/lib/stores/editor/utils/TestableUtils.d.ts +11 -1
  130. package/lib/stores/editor/utils/TestableUtils.d.ts.map +1 -1
  131. package/lib/stores/editor/utils/TestableUtils.js +50 -1
  132. package/lib/stores/editor/utils/TestableUtils.js.map +1 -1
  133. package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.d.ts +5 -4
  134. package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.d.ts.map +1 -1
  135. package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js +4 -1
  136. package/lib/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js.map +1 -1
  137. package/package.json +6 -6
  138. package/src/__lib__/LegendStudioApplicationNavigationContext.ts +12 -1
  139. package/src/__lib__/LegendStudioEvent.ts +1 -1
  140. package/src/application/LegendStudioApplicationConfig.ts +8 -0
  141. package/src/components/ElementIconUtils.tsx +3 -0
  142. package/src/components/editor/editor-group/ModelImporter.tsx +4 -0
  143. package/src/components/editor/editor-group/connection-editor/DatabaseBuilder.tsx +12 -13
  144. package/src/components/editor/editor-group/data-editor/EmbeddedDataEditor.tsx +45 -38
  145. package/src/components/editor/editor-group/data-editor/RelationalCSVDataEditor.tsx +140 -31
  146. package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.tsx +7 -0
  147. package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.tsx +6 -0
  148. package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.tsx +6 -0
  149. package/src/components/editor/editor-group/mapping-editor/MappingTestableEditor.tsx +296 -414
  150. package/src/components/editor/editor-group/mapping-editor/NewMappingElementModal.tsx +1 -1
  151. package/src/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.tsx +12 -7
  152. package/src/components/editor/editor-group/testable/TestableSharedComponents.tsx +88 -3
  153. package/src/components/editor/panel-group/SQLPlaygroundPanel.tsx +104 -18
  154. package/src/components/editor/side-bar/CreateNewElementModal.tsx +111 -1
  155. package/src/components/extensions/Core_LegendStudioApplicationPlugin.tsx +10 -0
  156. package/src/stores/editor/EditorGraphState.ts +1 -1
  157. package/src/stores/editor/EditorStore.ts +29 -17
  158. package/src/stores/editor/NewElementState.ts +109 -21
  159. package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts +33 -40
  160. package/src/stores/editor/editor-state/element-editor-state/data/DataEditorState.ts +7 -1
  161. package/src/stores/editor/editor-state/element-editor-state/data/EmbeddedDataState.ts +48 -77
  162. package/src/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.ts +5 -1
  163. package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.ts +407 -617
  164. package/src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.ts +243 -0
  165. package/src/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.ts +6 -2
  166. package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +18 -1
  167. package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestableState.ts +20 -12
  168. package/src/stores/editor/editor-state/element-editor-state/testable/TestAssertionState.ts +76 -18
  169. package/src/stores/editor/editor-state/element-editor-state/testable/TestableEditorState.ts +29 -24
  170. package/src/stores/editor/panel-group/SQLPlaygroundPanelState.ts +224 -1
  171. package/src/stores/editor/sidebar-state/testable/GlobalTestRunnerState.ts +4 -1
  172. package/src/stores/editor/utils/MockDataUtils.ts +2 -0
  173. package/src/stores/editor/utils/ModelClassifierUtils.ts +2 -6
  174. package/src/stores/editor/utils/TestableUtils.ts +73 -0
  175. package/src/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.ts +15 -12
  176. package/tsconfig.json +1 -0
@@ -25,6 +25,9 @@ import {
25
25
  ActionState,
26
26
  getNonNullableEntry,
27
27
  getNullableLastEntry,
28
+ type Writable,
29
+ guaranteeNonNullable,
30
+ IllegalStateError,
28
31
  } from '@finos/legend-shared';
29
32
  import { observable, makeObservable, flow, flowResult, action } from 'mobx';
30
33
  import { editor as monacoEditorAPI } from 'monaco-editor';
@@ -40,6 +43,8 @@ import {
40
43
  getSchema,
41
44
  guaranteeRelationalDatabaseConnection,
42
45
  GRAPH_MANAGER_EVENT,
46
+ getNullableSchema,
47
+ getNullableTable,
43
48
  } from '@finos/legend-graph';
44
49
  import type { EditorStore } from '../EditorStore.js';
45
50
  import { LEGEND_STUDIO_APP_EVENT } from '../../../__lib__/LegendStudioEvent.js';
@@ -50,6 +55,8 @@ import {
50
55
  import type { CommandRegistrar } from '@finos/legend-application';
51
56
  import { STO_RELATIONAL_LEGEND_STUDIO_COMMAND_KEY } from '../../../__lib__/STO_Relational_LegendStudioCommand.js';
52
57
  import { PANEL_MODE } from '../EditorConfig.js';
58
+ import type { Entity } from '@finos/legend-storage';
59
+ import { GraphEditFormModeState } from '../GraphEditFormModeState.js';
53
60
 
54
61
  export abstract class DatabaseSchemaExplorerTreeNodeData
55
62
  implements TreeNodeData
@@ -59,12 +66,22 @@ export abstract class DatabaseSchemaExplorerTreeNodeData
59
66
  label: string;
60
67
  parentId?: string | undefined;
61
68
  childrenIds?: string[] | undefined;
69
+ isChecked = false;
62
70
 
63
71
  constructor(id: string, label: string, parentId: string | undefined) {
72
+ makeObservable(this, {
73
+ isChecked: observable,
74
+ setChecked: action,
75
+ });
76
+
64
77
  this.id = id;
65
78
  this.label = label;
66
79
  this.parentId = parentId;
67
80
  }
81
+
82
+ setChecked(val: boolean): void {
83
+ this.isChecked = val;
84
+ }
68
85
  }
69
86
 
70
87
  export class DatabaseSchemaExplorerTreeSchemaNodeData extends DatabaseSchemaExplorerTreeNodeData {
@@ -118,6 +135,7 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
118
135
  isExecutingRawSQL = false;
119
136
 
120
137
  connection?: PackageableConnection | undefined;
138
+ database?: Database | undefined;
121
139
  treeData?: DatabaseSchemaExplorerTreeData | undefined;
122
140
  readonly sqlEditorTextModel: monacoEditorAPI.ITextModel;
123
141
  sqlEditor?: monacoEditorAPI.IStandaloneCodeEditor | undefined;
@@ -125,17 +143,23 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
125
143
  sqlText = DEFAULT_SQL_TEXT;
126
144
  sqlExecutionResult?: string | undefined;
127
145
 
146
+ isBuildingDatabase = false;
147
+ isUpdatingDatabase = false;
148
+
128
149
  constructor(editorStore: EditorStore) {
129
150
  makeObservable(this, {
130
151
  isFetchingSchema: observable,
131
152
  isExecutingRawSQL: observable,
132
153
  connection: observable,
154
+ database: observable,
133
155
  treeData: observable,
134
156
  sqlText: observable,
135
157
  resetSQL: action,
136
158
  sqlExecutionResult: observable,
137
159
  sqlEditor: observable.ref,
138
160
  sqlEditorViewState: observable.ref,
161
+ isBuildingDatabase: observable,
162
+ isUpdatingDatabase: observable,
139
163
  setTreeData: action,
140
164
  setConnection: action,
141
165
  setSQLEditor: action,
@@ -146,6 +170,8 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
146
170
  fetchSchemaMetadata: flow,
147
171
  fetchTableMetadata: flow,
148
172
  executeRawSQL: flow,
173
+ generateDatabase: flow,
174
+ updateDatabase: flow,
149
175
  });
150
176
 
151
177
  this.editorStore = editorStore;
@@ -161,6 +187,9 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
161
187
 
162
188
  setConnection(val: PackageableConnection | undefined): void {
163
189
  this.connection = val;
190
+ if (val) {
191
+ this.database = guaranteeRelationalDatabaseConnection(val).store.value;
192
+ }
164
193
  this.sqlEditorTextModel.setValue(DEFAULT_SQL_TEXT);
165
194
  }
166
195
 
@@ -238,10 +267,37 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
238
267
  treeData: DatabaseSchemaExplorerTreeData,
239
268
  ): DatabaseSchemaExplorerTreeNodeData[] | undefined {
240
269
  return node.childrenIds
241
- ?.map((n) => treeData.nodes.get(n))
270
+ ?.map((childNode) => treeData.nodes.get(childNode))
242
271
  .filter(isNonNullable);
243
272
  }
244
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
+
245
301
  *fetchDatabaseMetadata(): GeneratorFn<void> {
246
302
  if (!this.connection) {
247
303
  return;
@@ -279,6 +335,14 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
279
335
  dbSchema,
280
336
  );
281
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
+ );
282
346
  });
283
347
  const treeData = { rootIds, nodes, database };
284
348
  this.setTreeData(treeData);
@@ -339,6 +403,22 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
339
403
  );
340
404
  treeData.nodes.set(tableId, tableNode);
341
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
+ }
342
422
  });
343
423
  schemaNode.childrenIds = childrenIds;
344
424
  this.setTreeData({ ...treeData });
@@ -482,4 +562,147 @@ export class SQLPlaygroundPanelState implements CommandRegistrar {
482
562
  this.isExecutingRawSQL = false;
483
563
  }
484
564
  }
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
+ }
485
708
  }
@@ -326,8 +326,11 @@ export const getTestableResultFromAssertionStatus = (
326
326
  return TESTABLE_RESULT.DID_NOT_RUN;
327
327
  };
328
328
  export const getTestableResultFromTestResults = (
329
- testResults: (TestResult | undefined)[],
329
+ testResults: (TestResult | undefined)[] | undefined,
330
330
  ): TESTABLE_RESULT => {
331
+ if (testResults === undefined || !testResults.length) {
332
+ return TESTABLE_RESULT.DID_NOT_RUN;
333
+ }
331
334
  if (
332
335
  testResults.every(
333
336
  (t) =>
@@ -308,6 +308,8 @@ export const createMockDataForMappingElementSource = (
308
308
  srcElement.relation instanceof Table
309
309
  ) {
310
310
  return createMockDataForTable(srcElement.relation);
311
+ } else if (srcElement instanceof Table) {
312
+ return createMockDataForTable(srcElement);
311
313
  }
312
314
  editorStore.applicationStore.notificationService.notifyWarning(
313
315
  new UnsupportedOperationError(
@@ -70,10 +70,6 @@ export enum PACKAGEABLE_ELEMENT_TYPE {
70
70
  SECTION_INDEX = 'SECTION_INDEX',
71
71
  DATA = 'DATA',
72
72
 
73
- UNKNOWN = 'UNKNOWN',
74
- }
75
-
76
- export enum BASIC_SET_IMPLEMENTATION_TYPE {
77
- OPERATION = 'operation',
78
- INSTANCE = 'instance',
73
+ TEMPORARY__LOCAL_CONNECTION = 'LOCAL_CONNECTION',
74
+ INTERNAL__UNKNOWN = 'UNKNOWN',
79
75
  }
@@ -28,6 +28,7 @@ import {
28
28
  type TestAssertion,
29
29
  type AtomicTest,
30
30
  type Class,
31
+ type EmbeddedDataVisitor,
31
32
  ExternalFormatData,
32
33
  RelationalCSVData,
33
34
  ConnectionTestData,
@@ -36,6 +37,14 @@ import {
36
37
  RelationalCSVDataTable,
37
38
  type INTERNAL__UnknownConnection,
38
39
  getAllIdentifiedConnectionsFromRuntime,
40
+ ModelStoreData,
41
+ ModelEmbeddedData,
42
+ PackageableElementExplicitReference,
43
+ type DataElementReference,
44
+ type INTERNAL__UnknownEmbeddedData,
45
+ type TestResult,
46
+ TestExecuted,
47
+ TestExecutionStatus,
39
48
  } from '@finos/legend-graph';
40
49
  import {
41
50
  assertTrue,
@@ -58,6 +67,7 @@ export const validateTestableId = (
58
67
  id: string | undefined,
59
68
  possibleIds: string[] | undefined,
60
69
  ): string | undefined => {
70
+ // undefined in this case means user has yet to write anything so we shouldnt show any error message
61
71
  if (id === undefined) {
62
72
  return undefined;
63
73
  }
@@ -101,6 +111,64 @@ export const createEmbeddedDataFromClass = (
101
111
  return data;
102
112
  };
103
113
 
114
+ export const createBareModelStoreData = (
115
+ _class: Class,
116
+ editorStore: EditorStore,
117
+ ): ModelStoreData => {
118
+ const embeddedData = createEmbeddedDataFromClass(_class, editorStore);
119
+ const modelStoreData = new ModelStoreData();
120
+ const modelData = new ModelEmbeddedData();
121
+ modelData.data = embeddedData;
122
+ modelData.model = PackageableElementExplicitReference.create(_class);
123
+ modelStoreData.modelData = [modelData];
124
+ return modelStoreData;
125
+ };
126
+
127
+ export class EmbeddedDataCreatorFromEmbeddedData
128
+ implements EmbeddedDataVisitor<EmbeddedData>
129
+ {
130
+ visit_EmbeddedData(data: EmbeddedData): EmbeddedData {
131
+ throw new Error('Method not implemented.');
132
+ }
133
+ visit_INTERNAL__UnknownEmbeddedData(
134
+ data: INTERNAL__UnknownEmbeddedData,
135
+ ): EmbeddedData {
136
+ throw new Error('Method not implemented.');
137
+ }
138
+ visit_ExternalFormatData(data: ExternalFormatData): EmbeddedData {
139
+ const val = new ExternalFormatData();
140
+ val.contentType = data.contentType;
141
+ val.data = '';
142
+ return val;
143
+ }
144
+ visit_ModelStoreData(data: ModelStoreData): EmbeddedData {
145
+ const val = new ModelStoreData();
146
+ val.modelData = data.modelData
147
+ ?.map((e) => {
148
+ if (e instanceof ModelEmbeddedData) {
149
+ const v = new ModelEmbeddedData();
150
+ v.model = PackageableElementExplicitReference.create(e.model.value);
151
+ v.data = e.data.accept_EmbeddedDataVisitor(
152
+ new EmbeddedDataCreatorFromEmbeddedData(),
153
+ );
154
+ return v;
155
+ }
156
+ return undefined;
157
+ })
158
+ .filter(isNonNullable);
159
+ return val;
160
+ }
161
+ visit_DataElementReference(data: DataElementReference): EmbeddedData {
162
+ return data.dataElement.value.data.accept_EmbeddedDataVisitor(
163
+ new EmbeddedDataCreatorFromEmbeddedData(),
164
+ );
165
+ }
166
+ visit_RelationalCSVData(data: RelationalCSVData): EmbeddedData {
167
+ const val = new RelationalCSVData();
168
+ return val;
169
+ }
170
+ }
171
+
104
172
  // NOTE: this will all move to `engine` once engine support generating test data for all connections
105
173
  // Throws if unable to generate test data
106
174
  export class TEMPORARY__EmbeddedDataConnectionVisitor
@@ -251,3 +319,8 @@ export const TEMPORARY__createRelationalDataFromCSV = (
251
319
  });
252
320
  return data;
253
321
  };
322
+
323
+ // test result
324
+ export const isTestPassing = (testResult: TestResult): boolean =>
325
+ testResult instanceof TestExecuted &&
326
+ testResult.testExecutionStatus === TestExecutionStatus.PASS;
@@ -78,11 +78,10 @@ import {
78
78
  PrimitiveType,
79
79
  type MappingTestSuite,
80
80
  observe_MappingTestSuite,
81
- type MappingQueryTestSuite,
82
- type MappingQueryTest,
83
- type MappingDataTestSuite,
84
- type MappingDataTest,
85
81
  type StoreTestData,
82
+ type MappingTest,
83
+ type EmbeddedData,
84
+ observe_EmbeddedData,
86
85
  } from '@finos/legend-graph';
87
86
  import {
88
87
  addUniqueEntry,
@@ -203,25 +202,29 @@ export const mapping_deleteTestSuite = action(
203
202
  );
204
203
 
205
204
  export const mappingTestable_setQuery = action(
206
- (test: MappingQueryTest | MappingQueryTestSuite, value: RawLambda): void => {
205
+ (test: MappingTestSuite, value: RawLambda): void => {
207
206
  test.func = observe_RawLambda(value);
208
207
  },
209
208
  );
210
209
 
211
210
  export const mappingTestable_deleteStoreTestData = action(
212
- (
213
- dataHolder: MappingDataTestSuite | MappingDataTest,
214
- val: StoreTestData,
215
- ): void => {
211
+ (dataHolder: MappingTest, val: StoreTestData): void => {
216
212
  deleteEntry(dataHolder.storeTestData, val);
217
213
  },
218
214
  );
219
215
 
220
- export const mappingTestable_addStoreTestData = action(
216
+ export const mappingTestable_setEmbeddedData = action(
221
217
  (
222
- dataHolder: MappingDataTestSuite | MappingDataTest,
223
- val: StoreTestData,
218
+ store: StoreTestData,
219
+ embeddedData: EmbeddedData,
220
+ observerContext: ObserverContext,
224
221
  ): void => {
222
+ store.data = observe_EmbeddedData(embeddedData, observerContext);
223
+ },
224
+ );
225
+
226
+ export const mappingTestable_addStoreTestData = action(
227
+ (dataHolder: MappingTest, val: StoreTestData): void => {
225
228
  addUniqueEntry(dataHolder.storeTestData, val);
226
229
  },
227
230
  );
package/tsconfig.json CHANGED
@@ -112,6 +112,7 @@
112
112
  "./src/stores/editor/editor-state/element-editor-state/mapping/UnsupportedInstanceSetImplementationState.ts",
113
113
  "./src/stores/editor/editor-state/element-editor-state/mapping/relational/RelationalInstanceSetImplementationState.ts",
114
114
  "./src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestableState.ts",
115
+ "./src/stores/editor/editor-state/element-editor-state/mapping/testable/MappingTestingHelper.ts",
115
116
  "./src/stores/editor/editor-state/element-editor-state/service/ServiceEditorState.ts",
116
117
  "./src/stores/editor/editor-state/element-editor-state/service/ServiceExecutionState.ts",
117
118
  "./src/stores/editor/editor-state/element-editor-state/service/ServicePostValidationState.ts",