@finos/legend-application-studio 28.5.2 → 28.5.4
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/components/editor/editor-group/RuntimeEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/RuntimeEditor.js +3 -2
- package/lib/components/editor/editor-group/RuntimeEditor.js.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js +2 -2
- package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseModelBuilder.d.ts.map +1 -1
- package/lib/components/editor/editor-group/connection-editor/DatabaseModelBuilder.js +19 -5
- package/lib/components/editor/editor-group/connection-editor/DatabaseModelBuilder.js.map +1 -1
- package/lib/components/editor/editor-group/service-editor/ServiceExecutionEditor.d.ts.map +1 -1
- package/lib/components/editor/editor-group/service-editor/ServiceExecutionEditor.js +2 -1
- package/lib/components/editor/editor-group/service-editor/ServiceExecutionEditor.js.map +1 -1
- package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
- package/lib/components/editor/side-bar/CreateNewElementModal.js +11 -3
- package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +2 -2
- package/lib/stores/editor/NewElementState.d.ts +9 -0
- package/lib/stores/editor/NewElementState.d.ts.map +1 -1
- package/lib/stores/editor/NewElementState.js +26 -5
- package/lib/stores/editor/NewElementState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.js +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/RuntimeEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/RuntimeEditorState.js +2 -1
- package/lib/stores/editor/editor-state/element-editor-state/RuntimeEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.d.ts +3 -0
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.js +10 -3
- package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.js.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js +11 -12
- package/lib/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.js.map +1 -1
- package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.js +1 -1
- package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.js.map +1 -1
- package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityDiffViewState.d.ts.map +1 -1
- package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityDiffViewState.js +2 -2
- package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityDiffViewState.js.map +1 -1
- package/package.json +7 -7
- package/src/components/editor/editor-group/RuntimeEditor.tsx +3 -2
- package/src/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.tsx +3 -3
- package/src/components/editor/editor-group/connection-editor/DatabaseModelBuilder.tsx +57 -7
- package/src/components/editor/editor-group/service-editor/ServiceExecutionEditor.tsx +2 -1
- package/src/components/editor/side-bar/CreateNewElementModal.tsx +45 -11
- package/src/stores/editor/NewElementState.ts +40 -6
- package/src/stores/editor/editor-state/element-editor-state/ElementEditorState.ts +1 -0
- package/src/stores/editor/editor-state/element-editor-state/RuntimeEditorState.ts +2 -1
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.ts +1 -0
- package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.ts +12 -1
- package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts +15 -12
- package/src/stores/editor/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.ts +1 -0
- package/src/stores/editor/editor-state/entity-diff-editor-state/EntityDiffViewState.ts +2 -0
@@ -111,6 +111,7 @@ import {
|
|
111
111
|
runtime_deleteIdentifiedConnection,
|
112
112
|
} from '../../../stores/graph-modifier/DSL_Mapping_GraphModifierHelper.js';
|
113
113
|
import { LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../../__lib__/LegendStudioApplicationNavigationContext.js';
|
114
|
+
import { CUSTOM_LABEL } from '../../../stores/editor/NewElementState.js';
|
114
115
|
|
115
116
|
const getConnectionTooltipText = (
|
116
117
|
connection: Connection,
|
@@ -379,7 +380,7 @@ const RuntimeExplorer = observer(
|
|
379
380
|
const runtimeName =
|
380
381
|
runtime instanceof RuntimePointer
|
381
382
|
? runtime.packageableRuntime.value.name
|
382
|
-
:
|
383
|
+
: CUSTOM_LABEL;
|
383
384
|
// explorer tree data
|
384
385
|
const treeData = runtimeEditorState.explorerTreeData;
|
385
386
|
const onNodeSelect = (node: RuntimeExplorerTreeNodeData): void =>
|
@@ -494,7 +495,7 @@ const IdentifiedConnectionEditor = observer(
|
|
494
495
|
<div className="runtime-connection-editor__connection-option--custom">
|
495
496
|
<CogIcon />
|
496
497
|
<div className="runtime-connection-editor__connection-option--custom__label">
|
497
|
-
|
498
|
+
{CUSTOM_LABEL}
|
498
499
|
</div>
|
499
500
|
</div>
|
500
501
|
);
|
@@ -147,8 +147,8 @@ export const DatabaseBuilderWizard = observer(
|
|
147
147
|
<Panel className="database-builder__model">
|
148
148
|
<PanelHeader title="database model" />
|
149
149
|
<PanelContent>
|
150
|
-
<div className="database-
|
151
|
-
<div className="panel__content__form__section database-
|
150
|
+
<div className="database-builder__modeler">
|
151
|
+
<div className="panel__content__form__section database-builder__modeler__path">
|
152
152
|
<div className="panel__content__form__section__header__label">
|
153
153
|
Target Database Path
|
154
154
|
</div>
|
@@ -165,7 +165,7 @@ export const DatabaseBuilderWizard = observer(
|
|
165
165
|
error={elementAlreadyExistsMessage}
|
166
166
|
/>
|
167
167
|
</div>
|
168
|
-
<div className="database-
|
168
|
+
<div className="database-builder__modeler__preview">
|
169
169
|
{databaseBuilderState.databaseGrammarCode && (
|
170
170
|
<CodeEditor
|
171
171
|
language={CODE_EDITOR_LANGUAGE.PURE}
|
@@ -19,6 +19,7 @@ import type { DatabaseModelBuilderState } from '../../../../stores/editor/editor
|
|
19
19
|
import {
|
20
20
|
BlankPanelContent,
|
21
21
|
Dialog,
|
22
|
+
InputWithInlineValidation,
|
22
23
|
Modal,
|
23
24
|
ModalBody,
|
24
25
|
ModalFooter,
|
@@ -32,6 +33,7 @@ import {
|
|
32
33
|
PanelLoadingIndicator,
|
33
34
|
ResizablePanel,
|
34
35
|
ResizablePanelGroup,
|
36
|
+
ResizablePanelSplitter,
|
35
37
|
TimesIcon,
|
36
38
|
} from '@finos/legend-art';
|
37
39
|
import { LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../../../__lib__/LegendStudioApplicationNavigationContext.js';
|
@@ -40,12 +42,13 @@ import {
|
|
40
42
|
useConditionedApplicationNavigationContext,
|
41
43
|
} from '@finos/legend-application';
|
42
44
|
import { flowResult } from 'mobx';
|
43
|
-
import { useEffect } from 'react';
|
45
|
+
import { useEffect, useMemo } from 'react';
|
44
46
|
import {
|
45
47
|
CODE_EDITOR_LANGUAGE,
|
46
48
|
CodeEditor,
|
47
49
|
} from '@finos/legend-lego/code-editor';
|
48
|
-
import { noop } from '@finos/legend-shared';
|
50
|
+
import { debounce, noop } from '@finos/legend-shared';
|
51
|
+
import { isValidPath } from '@finos/legend-graph';
|
49
52
|
|
50
53
|
export const DatabaseModelBuilder = observer(
|
51
54
|
(props: {
|
@@ -55,9 +58,19 @@ export const DatabaseModelBuilder = observer(
|
|
55
58
|
const { databaseModelBuilderState, isReadOnly } = props;
|
56
59
|
|
57
60
|
const applicationStore = useApplicationStore();
|
58
|
-
const
|
59
|
-
|
61
|
+
const debouncedRegenerate = useMemo(
|
62
|
+
() =>
|
63
|
+
debounce(
|
64
|
+
() => flowResult(databaseModelBuilderState.previewDatabaseModels()),
|
65
|
+
500,
|
66
|
+
),
|
67
|
+
[databaseModelBuilderState],
|
60
68
|
);
|
69
|
+
const preview = (): void => {
|
70
|
+
debouncedRegenerate.cancel();
|
71
|
+
debouncedRegenerate()?.catch(applicationStore.alertUnhandledError);
|
72
|
+
};
|
73
|
+
|
61
74
|
const saveModels = applicationStore.guardUnhandledError(() =>
|
62
75
|
flowResult(databaseModelBuilderState.saveModels()),
|
63
76
|
);
|
@@ -65,6 +78,19 @@ export const DatabaseModelBuilder = observer(
|
|
65
78
|
databaseModelBuilderState.close();
|
66
79
|
};
|
67
80
|
|
81
|
+
const targetPackageValidationMessage =
|
82
|
+
!databaseModelBuilderState.targetPackage
|
83
|
+
? `Target package path can't be empty`
|
84
|
+
: !isValidPath(databaseModelBuilderState.targetPackage)
|
85
|
+
? 'Invalid target package path'
|
86
|
+
: undefined;
|
87
|
+
|
88
|
+
const changeTargetPackage: React.ChangeEventHandler<HTMLInputElement> = (
|
89
|
+
event,
|
90
|
+
) => {
|
91
|
+
databaseModelBuilderState.setTargetPackage(event.target.value);
|
92
|
+
debouncedRegenerate()?.catch(applicationStore.alertUnhandledError);
|
93
|
+
};
|
68
94
|
const isExecutingAction =
|
69
95
|
databaseModelBuilderState.generatingModelState.isInProgress ||
|
70
96
|
databaseModelBuilderState.saveModelState.isInProgress;
|
@@ -105,14 +131,38 @@ export const DatabaseModelBuilder = observer(
|
|
105
131
|
</ModalHeaderActions>
|
106
132
|
</ModalHeader>
|
107
133
|
<ModalBody className="database-builder__content">
|
108
|
-
<PanelLoadingIndicator isLoading={isExecutingAction} />
|
109
134
|
<ResizablePanelGroup orientation="vertical">
|
135
|
+
<ResizablePanel size={450}>
|
136
|
+
<div className="database-builder__config">
|
137
|
+
<PanelHeader title="schema explorer" />
|
138
|
+
<PanelContent className="database-builder__config__content">
|
139
|
+
<div className="panel__content__form__section">
|
140
|
+
<div className="panel__content__form__section__header__label">
|
141
|
+
{'Target Package'}
|
142
|
+
</div>
|
143
|
+
<div className="panel__content__form__section__header__prompt">
|
144
|
+
{'Target Package of Mapping and Models Generated'}
|
145
|
+
</div>
|
146
|
+
<InputWithInlineValidation
|
147
|
+
className="query-builder__variables__variable__name__input input-group__input"
|
148
|
+
spellCheck={false}
|
149
|
+
value={databaseModelBuilderState.targetPackage}
|
150
|
+
onChange={changeTargetPackage}
|
151
|
+
placeholder="Target package path"
|
152
|
+
error={targetPackageValidationMessage}
|
153
|
+
/>
|
154
|
+
</div>
|
155
|
+
</PanelContent>
|
156
|
+
</div>
|
157
|
+
</ResizablePanel>
|
158
|
+
<ResizablePanelSplitter />
|
110
159
|
<ResizablePanel>
|
111
160
|
<Panel className="database-builder__model">
|
112
161
|
<PanelHeader title="database model" />
|
113
162
|
<PanelContent>
|
114
|
-
<
|
115
|
-
|
163
|
+
<PanelLoadingIndicator isLoading={isExecutingAction} />
|
164
|
+
<div className="database-builder__modeler">
|
165
|
+
<div className="database-builder__modeler__preview">
|
116
166
|
{databaseModelBuilderState.generatedGrammarCode && (
|
117
167
|
<CodeEditor
|
118
168
|
language={CODE_EDITOR_LANGUAGE.PURE}
|
@@ -79,6 +79,7 @@ import {
|
|
79
79
|
buildElementOption,
|
80
80
|
type PackageableElementOption,
|
81
81
|
} from '@finos/legend-lego/graph-editor';
|
82
|
+
import { CUSTOM_LABEL } from '../../../../stores/editor/NewElementState.js';
|
82
83
|
|
83
84
|
const PureExecutionContextConfigurationEditor = observer(
|
84
85
|
(props: {
|
@@ -132,7 +133,7 @@ const PureExecutionContextConfigurationEditor = observer(
|
|
132
133
|
<div className="service-execution-editor__configuration__runtime-option--custom">
|
133
134
|
<CogIcon />
|
134
135
|
<div className="service-execution-editor__configuration__runtime-option--custom__label">
|
135
|
-
|
136
|
+
{CUSTOM_LABEL}
|
136
137
|
</div>
|
137
138
|
</div>
|
138
139
|
);
|
@@ -26,10 +26,15 @@ import {
|
|
26
26
|
NewDataElementDriver,
|
27
27
|
NewServiceDriver,
|
28
28
|
CONNECTION_TYPE,
|
29
|
+
type RuntimeOption,
|
29
30
|
} from '../../../stores/editor/NewElementState.js';
|
30
31
|
import { Dialog, compareLabelFn, CustomSelectorInput } from '@finos/legend-art';
|
31
32
|
import type { EditorStore } from '../../../stores/editor/EditorStore.js';
|
32
|
-
import {
|
33
|
+
import {
|
34
|
+
guaranteeNonNullable,
|
35
|
+
prettyCONSTName,
|
36
|
+
toTitleCase,
|
37
|
+
} from '@finos/legend-shared';
|
33
38
|
import type { DSL_LegendStudioApplicationPlugin_Extension } from '../../../stores/LegendStudioApplicationPlugin.js';
|
34
39
|
import { useEditorStore } from '../EditorStoreProvider.js';
|
35
40
|
import {
|
@@ -347,10 +352,16 @@ const NewConnectionDriverEditor = observer(() => {
|
|
347
352
|
|
348
353
|
const NewServiceDriverEditor = observer(() => {
|
349
354
|
const editorStore = useEditorStore();
|
355
|
+
const runtimeSelectorPlaceholder = 'Choose a compatible runtime...';
|
350
356
|
const newServiceDriver =
|
351
357
|
editorStore.newElementState.getNewElementDriver(NewServiceDriver);
|
358
|
+
// runtime
|
359
|
+
const onRuntimeChange = (val: RuntimeOption | null): void => {
|
360
|
+
if (val) {
|
361
|
+
newServiceDriver.setRuntimeOption(val);
|
362
|
+
}
|
363
|
+
};
|
352
364
|
// mapping
|
353
|
-
const currentMappingOption = newServiceDriver.mappingOption;
|
354
365
|
const mappingOptions =
|
355
366
|
editorStore.graphManagerState.usableMappings.map(buildElementOption);
|
356
367
|
const onMappingChange = (
|
@@ -361,17 +372,40 @@ const NewServiceDriverEditor = observer(() => {
|
|
361
372
|
} else {
|
362
373
|
newServiceDriver.setMappingOption(val);
|
363
374
|
}
|
375
|
+
//reset runtime
|
376
|
+
newServiceDriver.setRuntimeOption(
|
377
|
+
guaranteeNonNullable(newServiceDriver.runtimeOptions[0]),
|
378
|
+
);
|
364
379
|
};
|
380
|
+
|
365
381
|
return (
|
366
|
-
|
367
|
-
<
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
382
|
+
<>
|
383
|
+
<div className="panel__content__form__section__header__label">
|
384
|
+
Mapping
|
385
|
+
</div>
|
386
|
+
<div className="explorer__new-element-modal__driver">
|
387
|
+
<CustomSelectorInput
|
388
|
+
className="explorer__new-element-modal__driver__dropdown"
|
389
|
+
options={mappingOptions}
|
390
|
+
onChange={onMappingChange}
|
391
|
+
value={newServiceDriver.mappingOption}
|
392
|
+
darkMode={true}
|
393
|
+
/>
|
394
|
+
</div>
|
395
|
+
<div className="panel__content__form__section__header__label">
|
396
|
+
Runtime
|
397
|
+
</div>
|
398
|
+
<div className="explorer__new-element-modal__driver">
|
399
|
+
<CustomSelectorInput
|
400
|
+
className="explorer__new-element-modal__driver__dropdown"
|
401
|
+
options={newServiceDriver.runtimeOptions}
|
402
|
+
onChange={onRuntimeChange}
|
403
|
+
value={newServiceDriver.runtimeOption}
|
404
|
+
darkMode={true}
|
405
|
+
placeholder={runtimeSelectorPlaceholder}
|
406
|
+
/>
|
407
|
+
</div>
|
408
|
+
</>
|
375
409
|
);
|
376
410
|
});
|
377
411
|
|
@@ -80,6 +80,7 @@ import {
|
|
80
80
|
ConnectionPointer,
|
81
81
|
IdentifiedConnection,
|
82
82
|
generateIdentifiedConnectionId,
|
83
|
+
getMappingCompatibleRuntimes,
|
83
84
|
} from '@finos/legend-graph';
|
84
85
|
import type { DSL_Mapping_LegendStudioApplicationPlugin_Extension } from '../extensions/DSL_Mapping_LegendStudioApplicationPlugin_Extension.js';
|
85
86
|
import {
|
@@ -105,6 +106,13 @@ import {
|
|
105
106
|
import { EmbeddedDataType } from './editor-state/ExternalFormatState.js';
|
106
107
|
import { createEmbeddedData } from './editor-state/element-editor-state/data/EmbeddedDataState.js';
|
107
108
|
|
109
|
+
export const CUSTOM_LABEL = '(custom)';
|
110
|
+
|
111
|
+
export type RuntimeOption = {
|
112
|
+
label: string;
|
113
|
+
value: PackageableRuntime | undefined;
|
114
|
+
};
|
115
|
+
|
108
116
|
export const resolvePackageAndElementName = (
|
109
117
|
_package: Package,
|
110
118
|
isPackageRoot: boolean,
|
@@ -471,23 +479,53 @@ export class NewPackageableConnectionDriver extends NewElementDriver<Packageable
|
|
471
479
|
|
472
480
|
export class NewServiceDriver extends NewElementDriver<Service> {
|
473
481
|
mappingOption?: PackageableElementOption<Mapping> | undefined;
|
482
|
+
runtimeOption: RuntimeOption;
|
474
483
|
constructor(editorStore: EditorStore) {
|
475
484
|
super(editorStore);
|
476
485
|
|
477
486
|
makeObservable(this, {
|
478
487
|
mappingOption: observable,
|
488
|
+
runtimeOption: observable,
|
479
489
|
setMappingOption: action,
|
490
|
+
setRuntimeOption: action,
|
491
|
+
runtimeOptions: computed,
|
480
492
|
isValid: computed,
|
481
493
|
createElement: action,
|
482
494
|
});
|
483
495
|
this.mappingOption =
|
484
496
|
editorStore.graphManagerState.usableMappings.map(buildElementOption)[0];
|
497
|
+
this.runtimeOption = guaranteeNonNullable(this.runtimeOptions[0]);
|
485
498
|
}
|
486
499
|
|
487
500
|
setMappingOption(val: PackageableElementOption<Mapping> | undefined): void {
|
488
501
|
this.mappingOption = val;
|
489
502
|
}
|
490
503
|
|
504
|
+
setRuntimeOption(val: RuntimeOption): void {
|
505
|
+
this.runtimeOption = val;
|
506
|
+
}
|
507
|
+
|
508
|
+
get compatibleMappingRuntimes(): PackageableRuntime[] {
|
509
|
+
return this.mappingOption?.value
|
510
|
+
? getMappingCompatibleRuntimes(
|
511
|
+
this.mappingOption.value,
|
512
|
+
this.editorStore.graphManagerState.usableRuntimes,
|
513
|
+
)
|
514
|
+
: [];
|
515
|
+
}
|
516
|
+
|
517
|
+
get runtimeOptions(): RuntimeOption[] {
|
518
|
+
return [
|
519
|
+
...this.compatibleMappingRuntimes.map((runtime) =>
|
520
|
+
buildElementOption(runtime),
|
521
|
+
),
|
522
|
+
{
|
523
|
+
label: CUSTOM_LABEL,
|
524
|
+
value: undefined,
|
525
|
+
},
|
526
|
+
];
|
527
|
+
}
|
528
|
+
|
491
529
|
get isValid(): boolean {
|
492
530
|
return Boolean(this.mappingOption);
|
493
531
|
}
|
@@ -497,13 +535,9 @@ export class NewServiceDriver extends NewElementDriver<Service> {
|
|
497
535
|
const _mapping = mappingOption.value;
|
498
536
|
const mapping = PackageableElementExplicitReference.create(_mapping);
|
499
537
|
const service = new Service(name);
|
500
|
-
const runtimes = this.editorStore.graphManagerState.usableRuntimes;
|
501
|
-
const compatibleRuntimes = runtimes.filter((runtime) =>
|
502
|
-
runtime.runtimeValue.mappings.map((m) => m.value).includes(_mapping),
|
503
|
-
);
|
504
538
|
let runtimeValue: Runtime;
|
505
|
-
if (
|
506
|
-
runtimeValue =
|
539
|
+
if (this.runtimeOption.value) {
|
540
|
+
runtimeValue = this.runtimeOption.value.runtimeValue;
|
507
541
|
} else {
|
508
542
|
const engineRuntime = new EngineRuntime();
|
509
543
|
runtime_addMapping(engineRuntime, mapping);
|
@@ -75,6 +75,7 @@ import {
|
|
75
75
|
runtime_deleteIdentifiedConnection,
|
76
76
|
runtime_deleteMapping,
|
77
77
|
} from '../../../graph-modifier/DSL_Mapping_GraphModifierHelper.js';
|
78
|
+
import { CUSTOM_LABEL } from '../../NewElementState.js';
|
78
79
|
|
79
80
|
export const getClassMappingStore = (
|
80
81
|
setImplementation: SetImplementation,
|
@@ -276,7 +277,7 @@ export const getRuntimeExplorerTreeData = (
|
|
276
277
|
label:
|
277
278
|
runtime instanceof RuntimePointer
|
278
279
|
? runtime.packageableRuntime.value.name
|
279
|
-
:
|
280
|
+
: CUSTOM_LABEL,
|
280
281
|
isOpen: true,
|
281
282
|
childrenIds: [] as string[],
|
282
283
|
};
|
package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.ts
CHANGED
@@ -28,6 +28,8 @@ import type { EditorStore } from '../../../EditorStore.js';
|
|
28
28
|
import type { Database } from '@finos/legend-graph';
|
29
29
|
import { EntityChangeType, type EntityChange } from '@finos/legend-server-sdlc';
|
30
30
|
|
31
|
+
export const GENERATED = 'generated';
|
32
|
+
|
31
33
|
export class DatabaseModelBuilderState {
|
32
34
|
readonly editorStore: EditorStore;
|
33
35
|
readonly database: Database;
|
@@ -38,6 +40,7 @@ export class DatabaseModelBuilderState {
|
|
38
40
|
showModal = false;
|
39
41
|
generatedGrammarCode = '';
|
40
42
|
entities: Entity[] | undefined;
|
43
|
+
targetPackage: string;
|
41
44
|
|
42
45
|
constructor(
|
43
46
|
editorStore: EditorStore,
|
@@ -49,16 +52,19 @@ export class DatabaseModelBuilderState {
|
|
49
52
|
generatedGrammarCode: observable,
|
50
53
|
generatingModelState: observable,
|
51
54
|
saveModelState: observable,
|
55
|
+
targetPackage: observable,
|
52
56
|
close: action,
|
53
57
|
setShowModal: action,
|
54
58
|
setEntities: action,
|
55
59
|
setDatabaseGrammarCode: action,
|
60
|
+
setTargetPackage: action,
|
56
61
|
saveModels: flow,
|
57
62
|
previewDatabaseModels: flow,
|
58
63
|
});
|
59
64
|
this.editorStore = editorStore;
|
60
65
|
this.database = database;
|
61
66
|
this.isReadOnly = isReadOnly;
|
67
|
+
this.targetPackage = database.package?.path ?? GENERATED;
|
62
68
|
}
|
63
69
|
|
64
70
|
setShowModal(val: boolean): void {
|
@@ -78,14 +84,18 @@ export class DatabaseModelBuilderState {
|
|
78
84
|
this.editorStore.explorerTreeState.setDatabaseModelBuilderState(undefined);
|
79
85
|
}
|
80
86
|
|
87
|
+
setTargetPackage(val: string): void {
|
88
|
+
this.targetPackage = val;
|
89
|
+
}
|
90
|
+
|
81
91
|
*previewDatabaseModels(): GeneratorFn<void> {
|
82
92
|
try {
|
83
93
|
this.generatingModelState.isInProgress;
|
84
94
|
this.entities = [];
|
85
|
-
this.setDatabaseGrammarCode('');
|
86
95
|
const entities =
|
87
96
|
(yield this.editorStore.graphManagerState.graphManager.generateModelsFromDatabaseSpecification(
|
88
97
|
this.database.path,
|
98
|
+
this.targetPackage,
|
89
99
|
this.editorStore.graphManagerState.graph,
|
90
100
|
)) as Entity[];
|
91
101
|
|
@@ -93,6 +103,7 @@ export class DatabaseModelBuilderState {
|
|
93
103
|
this.setDatabaseGrammarCode(
|
94
104
|
(yield this.editorStore.graphManagerState.graphManager.entitiesToPureCode(
|
95
105
|
entities,
|
106
|
+
{ pretty: true },
|
96
107
|
)) as string,
|
97
108
|
);
|
98
109
|
} catch (error) {
|
package/src/stores/editor/editor-state/element-editor-state/service/testable/ServiceTestDataState.ts
CHANGED
@@ -52,6 +52,7 @@ import {
|
|
52
52
|
RowIdentifier,
|
53
53
|
ColumnValuePair,
|
54
54
|
TablePtr,
|
55
|
+
getAllIncludedDatabases,
|
55
56
|
} from '@finos/legend-graph';
|
56
57
|
import {
|
57
58
|
type GeneratorFn,
|
@@ -65,6 +66,7 @@ import {
|
|
65
66
|
assertType,
|
66
67
|
assertTrue,
|
67
68
|
uuid,
|
69
|
+
uniq,
|
68
70
|
} from '@finos/legend-shared';
|
69
71
|
import { action, flow, flowResult, makeObservable, observable } from 'mobx';
|
70
72
|
import type { EditorStore } from '../../../../EditorStore.js';
|
@@ -363,18 +365,19 @@ export class ConnectionTestDataState {
|
|
363
365
|
}
|
364
366
|
|
365
367
|
getAvailableTables(): Table[] {
|
366
|
-
const
|
367
|
-
this.
|
368
|
-
.
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
368
|
+
const databases = uniq(
|
369
|
+
this.getAllIdentifiedConnections()
|
370
|
+
.map((idCon) => idCon.connection)
|
371
|
+
.flatMap((_c) => _c.store.value)
|
372
|
+
.filter(filterByType(Database))
|
373
|
+
.map((db) => Array.from(getAllIncludedDatabases(db)))
|
374
|
+
.flat(),
|
375
|
+
);
|
376
|
+
return uniq(
|
377
|
+
databases
|
378
|
+
.flatMap((_db) => _db.schemas)
|
379
|
+
.flatMap((schema) => schema.tables),
|
380
|
+
);
|
378
381
|
}
|
379
382
|
|
380
383
|
setUseSharedModal(val: boolean): void {
|
package/src/stores/editor/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.ts
CHANGED
@@ -426,6 +426,7 @@ export class EntityChangeConflictEditorState extends EntityDiffViewerState {
|
|
426
426
|
const elementGrammar =
|
427
427
|
(yield this.editorStore.graphManagerState.graphManager.entitiesToPureCode(
|
428
428
|
[entity],
|
429
|
+
{ pretty: true },
|
429
430
|
)) as string;
|
430
431
|
return elementGrammar;
|
431
432
|
}
|
@@ -202,6 +202,7 @@ export class EntityDiffViewState extends EntityDiffViewerState {
|
|
202
202
|
const elementGrammar =
|
203
203
|
(yield this.editorStore.graphManagerState.graphManager.entitiesToPureCode(
|
204
204
|
[this.fromEntity],
|
205
|
+
{ pretty: true },
|
205
206
|
)) as string;
|
206
207
|
this.setFromGrammarText(elementGrammar);
|
207
208
|
} catch (error) {
|
@@ -225,6 +226,7 @@ export class EntityDiffViewState extends EntityDiffViewerState {
|
|
225
226
|
const elementGrammar =
|
226
227
|
(yield this.editorStore.graphManagerState.graphManager.entitiesToPureCode(
|
227
228
|
[this.toEntity],
|
229
|
+
{ pretty: true },
|
228
230
|
)) as string;
|
229
231
|
this.setToGrammarText(elementGrammar);
|
230
232
|
} catch (error) {
|