@finos/legend-application-studio 26.1.11 → 27.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts +9 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.d.ts.map +1 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.js +11 -1
- package/lib/__lib__/LegendStudioApplicationNavigationContext.js.map +1 -1
- package/lib/application/LegendStudioApplicationConfig.d.ts +6 -0
- package/lib/application/LegendStudioApplicationConfig.d.ts.map +1 -1
- package/lib/application/LegendStudioApplicationConfig.js +7 -0
- package/lib/application/LegendStudioApplicationConfig.js.map +1 -1
- package/lib/components/ElementIconUtils.d.ts.map +1 -1
- package/lib/components/ElementIconUtils.js +3 -1
- package/lib/components/ElementIconUtils.js.map +1 -1
- package/lib/components/editor/editor-group/ModelImporter.d.ts.map +1 -1
- package/lib/components/editor/editor-group/ModelImporter.js +1 -0
- package/lib/components/editor/editor-group/ModelImporter.js.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.d.ts.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js +8 -10
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilder.js.map +1 -1
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js +5 -0
- package/lib/components/editor/editor-group/data-editor/EmbeddedDataEditor.js.map +1 -1
- package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js +3 -0
- package/lib/components/editor/editor-group/data-editor/RelationalCSVDataEditor.js.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js +3 -0
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.js.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.js +3 -0
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.js.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.js +3 -0
- package/lib/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.js.map +1 -1
- package/lib/components/editor/editor-group/mapping-editor/NewMappingElementModal.js +1 -2
- package/lib/components/editor/editor-group/mapping-editor/NewMappingElementModal.js.map +1 -1
- package/lib/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.js +6 -6
- package/lib/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.js.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.js +16 -5
- package/lib/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.js.map +1 -1
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.d.ts.map +1 -1
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.js +38 -6
- package/lib/components/editor/panel-group/SQLPlaygroundPanel.js.map +1 -1
- package/lib/components/editor/side-bar/CreateNewElementModal.d.ts +3 -0
- package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
- package/lib/components/editor/side-bar/CreateNewElementModal.js +43 -1
- package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
- package/lib/components/editor/side-bar/testable/GlobalTestRunner.d.ts.map +1 -1
- package/lib/components/editor/side-bar/testable/GlobalTestRunner.js +15 -14
- package/lib/components/editor/side-bar/testable/GlobalTestRunner.js.map +1 -1
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.d.ts.map +1 -1
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.js +10 -0
- package/lib/components/extensions/Core_LegendStudioApplicationPlugin.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +4 -4
- package/lib/stores/LegendStudioApplicationPlugin.d.ts +7 -7
- package/lib/stores/LegendStudioApplicationPlugin.d.ts.map +1 -1
- package/lib/stores/LegendStudioApplicationPlugin.js.map +1 -1
- package/lib/stores/editor/EditorGraphState.js +1 -1
- package/lib/stores/editor/EditorGraphState.js.map +1 -1
- package/lib/stores/editor/EditorStore.d.ts.map +1 -1
- package/lib/stores/editor/EditorStore.js +10 -2
- package/lib/stores/editor/EditorStore.js.map +1 -1
- package/lib/stores/editor/GraphEditFormModeState.d.ts.map +1 -1
- package/lib/stores/editor/GraphEditFormModeState.js +0 -1
- package/lib/stores/editor/GraphEditFormModeState.js.map +1 -1
- package/lib/stores/editor/NewElementState.d.ts +0 -1
- package/lib/stores/editor/NewElementState.d.ts.map +1 -1
- package/lib/stores/editor/NewElementState.js +47 -12
- package/lib/stores/editor/NewElementState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts +0 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js +26 -30
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.d.ts +4 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.js +5 -1
- package/lib/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServicePostValidationState.js +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/ServicePostValidationState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js +3 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.d.ts +1 -1
- package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.js +2 -2
- package/lib/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.js.map +1 -1
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts +9 -0
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.d.ts.map +1 -1
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js +149 -3
- package/lib/stores/editor/panel-group/SQLPlaygroundPanelState.js.map +1 -1
- package/lib/stores/editor/sidebar-state/BulkServiceRegistrationState.js +1 -1
- package/lib/stores/editor/sidebar-state/BulkServiceRegistrationState.js.map +1 -1
- package/lib/stores/editor/utils/MockDataUtils.d.ts +1 -1
- package/lib/stores/editor/utils/MockDataUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/MockDataUtils.js.map +1 -1
- package/lib/stores/editor/utils/ModelClassifierUtils.d.ts +2 -5
- package/lib/stores/editor/utils/ModelClassifierUtils.d.ts.map +1 -1
- package/lib/stores/editor/utils/ModelClassifierUtils.js +2 -6
- package/lib/stores/editor/utils/ModelClassifierUtils.js.map +1 -1
- package/lib/stores/editor/utils/PackageTreeUtils.js +3 -3
- package/lib/stores/editor/utils/PackageTreeUtils.js.map +1 -1
- package/package.json +14 -14
- package/src/__lib__/LegendStudioApplicationNavigationContext.ts +12 -1
- package/src/application/LegendStudioApplicationConfig.ts +8 -0
- package/src/components/ElementIconUtils.tsx +3 -0
- package/src/components/editor/editor-group/ModelImporter.tsx +4 -0
- package/src/components/editor/editor-group/connection-editor/DatabaseBuilder.tsx +12 -13
- package/src/components/editor/editor-group/data-editor/EmbeddedDataEditor.tsx +11 -1
- package/src/components/editor/editor-group/data-editor/RelationalCSVDataEditor.tsx +6 -0
- package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_BindingElementEditor.tsx +7 -0
- package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetElementEditor.tsx +6 -0
- package/src/components/editor/editor-group/external-format-editor/DSL_ExternalFormat_SchemaSetModelGenerationEditor.tsx +6 -0
- package/src/components/editor/editor-group/mapping-editor/NewMappingElementModal.tsx +1 -1
- package/src/components/editor/editor-group/project-configuration-editor/ProjectDependencyEditor.tsx +6 -10
- package/src/components/editor/editor-group/service-editor/testable/ServiceTestsEditor.tsx +22 -9
- package/src/components/editor/panel-group/SQLPlaygroundPanel.tsx +104 -18
- package/src/components/editor/side-bar/CreateNewElementModal.tsx +111 -1
- package/src/components/editor/side-bar/testable/GlobalTestRunner.tsx +21 -23
- package/src/components/extensions/Core_LegendStudioApplicationPlugin.tsx +10 -0
- package/src/stores/LegendStudioApplicationPlugin.ts +7 -11
- package/src/stores/editor/EditorGraphState.ts +1 -1
- package/src/stores/editor/EditorStore.ts +29 -17
- package/src/stores/editor/GraphEditFormModeState.ts +0 -1
- package/src/stores/editor/NewElementState.ts +115 -23
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderState.ts +33 -40
- package/src/stores/editor/editor-state/element-editor-state/mapping/MappingEditorState.ts +5 -1
- package/src/stores/editor/editor-state/element-editor-state/service/ServicePostValidationState.ts +1 -1
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestEditorState.ts +12 -2
- package/src/stores/editor/editor-state/project-configuration-editor-state/ProjectDependencyEditorState.ts +2 -2
- package/src/stores/editor/panel-group/SQLPlaygroundPanelState.ts +224 -1
- package/src/stores/editor/sidebar-state/BulkServiceRegistrationState.ts +1 -1
- package/src/stores/editor/utils/MockDataUtils.ts +1 -1
- package/src/stores/editor/utils/ModelClassifierUtils.ts +2 -6
- package/src/stores/editor/utils/PackageTreeUtils.ts +3 -3
package/src/stores/editor/editor-state/element-editor-state/service/ServicePostValidationState.ts
CHANGED
@@ -411,7 +411,7 @@ export class PostValidationState {
|
|
411
411
|
);
|
412
412
|
serviceValidation_deleteAssertion(this.validation, assertion);
|
413
413
|
this.assertionStates = this.assertionStates.filter(
|
414
|
-
(e) =>
|
414
|
+
(e) => e !== _assertionState,
|
415
415
|
);
|
416
416
|
}
|
417
417
|
}
|
@@ -254,10 +254,20 @@ export class ServiceTestSetupState {
|
|
254
254
|
),
|
255
255
|
this.editorStore.graphManagerState.graph,
|
256
256
|
);
|
257
|
-
|
258
257
|
if (valueSpec instanceof LambdaFunctionInstanceValue) {
|
259
258
|
return this.getBindingWithParamRecursively(
|
260
|
-
valueSpec.values[0]?.expressionSequence
|
259
|
+
valueSpec.values[0]?.expressionSequence.find(
|
260
|
+
(exp) =>
|
261
|
+
exp instanceof SimpleFunctionExpression &&
|
262
|
+
(matchFunctionName(
|
263
|
+
exp.functionName,
|
264
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.SERIALIZE,
|
265
|
+
) ||
|
266
|
+
matchFunctionName(
|
267
|
+
exp.functionName,
|
268
|
+
QUERY_BUILDER_SUPPORTED_FUNCTIONS.EXTERNALIZE,
|
269
|
+
)),
|
270
|
+
),
|
261
271
|
);
|
262
272
|
}
|
263
273
|
} catch (error) {
|
@@ -316,7 +316,7 @@ export class ProjectDependencyEditorState {
|
|
316
316
|
reportTab: observable,
|
317
317
|
expandConflictsState: observable,
|
318
318
|
buildConflictPathState: observable,
|
319
|
-
|
319
|
+
setReportTab: action,
|
320
320
|
expandAllConflicts: action,
|
321
321
|
setFlattenDependencyTreeData: action,
|
322
322
|
clearTrees: action,
|
@@ -356,7 +356,7 @@ export class ProjectDependencyEditorState {
|
|
356
356
|
}
|
357
357
|
}
|
358
358
|
|
359
|
-
|
359
|
+
setReportTab(tab: DEPENDENCY_REPORT_TAB | undefined): void {
|
360
360
|
this.reportTab = tab;
|
361
361
|
}
|
362
362
|
|
@@ -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((
|
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
|
}
|
@@ -152,7 +152,7 @@ export class GlobalBulkServiceRegistrationState {
|
|
152
152
|
}
|
153
153
|
|
154
154
|
setSelectAll(val: boolean): void {
|
155
|
-
this.bulkServiceRegistrationStates.
|
155
|
+
this.bulkServiceRegistrationStates.forEach(
|
156
156
|
(serviceRegistrationState) => (serviceRegistrationState.isSelected = val),
|
157
157
|
);
|
158
158
|
}
|
@@ -242,7 +242,7 @@ export const getPrimitiveTypeFromRelationalType = (
|
|
242
242
|
export const createMockDataForColumn = (
|
243
243
|
col: Column,
|
244
244
|
isPrimaryKey: boolean,
|
245
|
-
idx?: number |
|
245
|
+
idx?: number | undefined,
|
246
246
|
): string | undefined => {
|
247
247
|
const type = col.type;
|
248
248
|
|
@@ -70,10 +70,6 @@ export enum PACKAGEABLE_ELEMENT_TYPE {
|
|
70
70
|
SECTION_INDEX = 'SECTION_INDEX',
|
71
71
|
DATA = 'DATA',
|
72
72
|
|
73
|
-
|
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
|
}
|
@@ -367,7 +367,7 @@ export const openNode = (
|
|
367
367
|
let currentElement: PackageableElement | undefined = element;
|
368
368
|
let openingNode: PackageTreeNodeData | undefined;
|
369
369
|
while (currentElement.package) {
|
370
|
-
const
|
370
|
+
const currentNode: PackageTreeNodeData =
|
371
371
|
treeData.nodes.get(currentElement.path) ??
|
372
372
|
addNode(
|
373
373
|
editorStore,
|
@@ -376,8 +376,8 @@ export const openNode = (
|
|
376
376
|
childFilter,
|
377
377
|
isDependencyElement,
|
378
378
|
);
|
379
|
-
|
380
|
-
openingNode = !openingNode ?
|
379
|
+
currentNode.isOpen = currentElement instanceof Package;
|
380
|
+
openingNode = !openingNode ? currentNode : openingNode;
|
381
381
|
currentElement = currentElement.package;
|
382
382
|
}
|
383
383
|
// Open the dependency root
|