@finos/legend-application-studio 28.5.3 → 28.5.5

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 (53) hide show
  1. package/lib/components/editor/editor-group/RuntimeEditor.d.ts.map +1 -1
  2. package/lib/components/editor/editor-group/RuntimeEditor.js +3 -2
  3. package/lib/components/editor/editor-group/RuntimeEditor.js.map +1 -1
  4. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js +2 -2
  5. package/lib/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.js.map +1 -1
  6. package/lib/components/editor/editor-group/connection-editor/DatabaseModelBuilder.d.ts.map +1 -1
  7. package/lib/components/editor/editor-group/connection-editor/DatabaseModelBuilder.js +19 -5
  8. package/lib/components/editor/editor-group/connection-editor/DatabaseModelBuilder.js.map +1 -1
  9. package/lib/components/editor/editor-group/service-editor/ServiceExecutionEditor.d.ts.map +1 -1
  10. package/lib/components/editor/editor-group/service-editor/ServiceExecutionEditor.js +2 -1
  11. package/lib/components/editor/editor-group/service-editor/ServiceExecutionEditor.js.map +1 -1
  12. package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
  13. package/lib/components/editor/side-bar/CreateNewElementModal.js +11 -3
  14. package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
  15. package/lib/index.css +2 -2
  16. package/lib/index.css.map +1 -1
  17. package/lib/package.json +1 -1
  18. package/lib/stores/editor/NewElementState.d.ts +9 -0
  19. package/lib/stores/editor/NewElementState.d.ts.map +1 -1
  20. package/lib/stores/editor/NewElementState.js +26 -5
  21. package/lib/stores/editor/NewElementState.js.map +1 -1
  22. package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.d.ts.map +1 -1
  23. package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.js +1 -1
  24. package/lib/stores/editor/editor-state/element-editor-state/ElementEditorState.js.map +1 -1
  25. package/lib/stores/editor/editor-state/element-editor-state/RuntimeEditorState.d.ts.map +1 -1
  26. package/lib/stores/editor/editor-state/element-editor-state/RuntimeEditorState.js +2 -1
  27. package/lib/stores/editor/editor-state/element-editor-state/RuntimeEditorState.js.map +1 -1
  28. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.d.ts.map +1 -1
  29. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js +1 -1
  30. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.js.map +1 -1
  31. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.d.ts +3 -0
  32. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.d.ts.map +1 -1
  33. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.js +10 -3
  34. package/lib/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.js.map +1 -1
  35. package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.d.ts.map +1 -1
  36. package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.js +1 -1
  37. package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.js.map +1 -1
  38. package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityDiffViewState.d.ts.map +1 -1
  39. package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityDiffViewState.js +2 -2
  40. package/lib/stores/editor/editor-state/entity-diff-editor-state/EntityDiffViewState.js.map +1 -1
  41. package/package.json +4 -4
  42. package/src/components/editor/editor-group/RuntimeEditor.tsx +3 -2
  43. package/src/components/editor/editor-group/connection-editor/DatabaseBuilderWizard.tsx +3 -3
  44. package/src/components/editor/editor-group/connection-editor/DatabaseModelBuilder.tsx +57 -7
  45. package/src/components/editor/editor-group/service-editor/ServiceExecutionEditor.tsx +2 -1
  46. package/src/components/editor/side-bar/CreateNewElementModal.tsx +45 -11
  47. package/src/stores/editor/NewElementState.ts +43 -6
  48. package/src/stores/editor/editor-state/element-editor-state/ElementEditorState.ts +1 -0
  49. package/src/stores/editor/editor-state/element-editor-state/RuntimeEditorState.ts +2 -1
  50. package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseBuilderWizardState.ts +1 -0
  51. package/src/stores/editor/editor-state/element-editor-state/connection/DatabaseModelBuilderState.ts +12 -1
  52. package/src/stores/editor/editor-state/entity-diff-editor-state/EntityChangeConflictEditorState.ts +1 -0
  53. package/src/stores/editor/editor-state/entity-diff-editor-state/EntityDiffViewState.ts +2 -0
@@ -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 { prettyCONSTName, toTitleCase } from '@finos/legend-shared';
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
- <div className="explorer__new-element-modal__driver">
367
- <CustomSelectorInput
368
- className="explorer__new-element-modal__driver__dropdown"
369
- options={mappingOptions}
370
- onChange={onMappingChange}
371
- value={currentMappingOption}
372
- darkMode={true}
373
- />
374
- </div>
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,8 @@ import {
80
80
  ConnectionPointer,
81
81
  IdentifiedConnection,
82
82
  generateIdentifiedConnectionId,
83
+ getMappingCompatibleRuntimes,
84
+ RuntimePointer,
83
85
  } from '@finos/legend-graph';
84
86
  import type { DSL_Mapping_LegendStudioApplicationPlugin_Extension } from '../extensions/DSL_Mapping_LegendStudioApplicationPlugin_Extension.js';
85
87
  import {
@@ -105,6 +107,13 @@ import {
105
107
  import { EmbeddedDataType } from './editor-state/ExternalFormatState.js';
106
108
  import { createEmbeddedData } from './editor-state/element-editor-state/data/EmbeddedDataState.js';
107
109
 
110
+ export const CUSTOM_LABEL = '(custom)';
111
+
112
+ export type RuntimeOption = {
113
+ label: string;
114
+ value: PackageableRuntime | undefined;
115
+ };
116
+
108
117
  export const resolvePackageAndElementName = (
109
118
  _package: Package,
110
119
  isPackageRoot: boolean,
@@ -471,23 +480,53 @@ export class NewPackageableConnectionDriver extends NewElementDriver<Packageable
471
480
 
472
481
  export class NewServiceDriver extends NewElementDriver<Service> {
473
482
  mappingOption?: PackageableElementOption<Mapping> | undefined;
483
+ runtimeOption: RuntimeOption;
474
484
  constructor(editorStore: EditorStore) {
475
485
  super(editorStore);
476
486
 
477
487
  makeObservable(this, {
478
488
  mappingOption: observable,
489
+ runtimeOption: observable,
479
490
  setMappingOption: action,
491
+ setRuntimeOption: action,
492
+ runtimeOptions: computed,
480
493
  isValid: computed,
481
494
  createElement: action,
482
495
  });
483
496
  this.mappingOption =
484
497
  editorStore.graphManagerState.usableMappings.map(buildElementOption)[0];
498
+ this.runtimeOption = guaranteeNonNullable(this.runtimeOptions[0]);
485
499
  }
486
500
 
487
501
  setMappingOption(val: PackageableElementOption<Mapping> | undefined): void {
488
502
  this.mappingOption = val;
489
503
  }
490
504
 
505
+ setRuntimeOption(val: RuntimeOption): void {
506
+ this.runtimeOption = val;
507
+ }
508
+
509
+ get compatibleMappingRuntimes(): PackageableRuntime[] {
510
+ return this.mappingOption?.value
511
+ ? getMappingCompatibleRuntimes(
512
+ this.mappingOption.value,
513
+ this.editorStore.graphManagerState.usableRuntimes,
514
+ )
515
+ : [];
516
+ }
517
+
518
+ get runtimeOptions(): RuntimeOption[] {
519
+ return [
520
+ ...this.compatibleMappingRuntimes.map((runtime) =>
521
+ buildElementOption(runtime),
522
+ ),
523
+ {
524
+ label: CUSTOM_LABEL,
525
+ value: undefined,
526
+ },
527
+ ];
528
+ }
529
+
491
530
  get isValid(): boolean {
492
531
  return Boolean(this.mappingOption);
493
532
  }
@@ -497,13 +536,11 @@ export class NewServiceDriver extends NewElementDriver<Service> {
497
536
  const _mapping = mappingOption.value;
498
537
  const mapping = PackageableElementExplicitReference.create(_mapping);
499
538
  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
539
  let runtimeValue: Runtime;
505
- if (compatibleRuntimes.length) {
506
- runtimeValue = (compatibleRuntimes[0] as PackageableRuntime).runtimeValue;
540
+ if (this.runtimeOption.value) {
541
+ runtimeValue = new RuntimePointer(
542
+ PackageableElementExplicitReference.create(this.runtimeOption.value),
543
+ );
507
544
  } else {
508
545
  const engineRuntime = new EngineRuntime();
509
546
  runtime_addMapping(engineRuntime, mapping);
@@ -219,6 +219,7 @@ export abstract class ElementEditorState extends EditorState {
219
219
  this.element,
220
220
  ),
221
221
  ],
222
+ { pretty: true },
222
223
  )) as string;
223
224
  this.setTextContent(grammar);
224
225
  } catch (error) {
@@ -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
- : '(custom)',
280
+ : CUSTOM_LABEL,
280
281
  isOpen: true,
281
282
  childrenIds: [] as string[],
282
283
  };
@@ -78,6 +78,7 @@ export class DatabaseBuilderWizardState {
78
78
  this.schemaExplorerState.generateDatabase(),
79
79
  )) as Entity,
80
80
  ],
81
+ { pretty: true },
81
82
  )) as string,
82
83
  );
83
84
  } catch (error) {
@@ -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) {
@@ -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) {