@finos/legend-application-studio 28.19.1 → 28.19.3

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 (33) hide show
  1. package/lib/application/LegendIngestionConfiguration.d.ts +1 -0
  2. package/lib/application/LegendIngestionConfiguration.d.ts.map +1 -1
  3. package/lib/application/LegendIngestionConfiguration.js +2 -0
  4. package/lib/application/LegendIngestionConfiguration.js.map +1 -1
  5. package/lib/components/editor/editor-group/RuntimeEditor.d.ts +8 -1
  6. package/lib/components/editor/editor-group/RuntimeEditor.d.ts.map +1 -1
  7. package/lib/components/editor/editor-group/RuntimeEditor.js +102 -29
  8. package/lib/components/editor/editor-group/RuntimeEditor.js.map +1 -1
  9. package/lib/components/editor/side-bar/CreateNewElementModal.d.ts.map +1 -1
  10. package/lib/components/editor/side-bar/CreateNewElementModal.js +18 -7
  11. package/lib/components/editor/side-bar/CreateNewElementModal.js.map +1 -1
  12. package/lib/index.css +1 -1
  13. package/lib/package.json +1 -1
  14. package/lib/stores/editor/NewElementState.d.ts +6 -0
  15. package/lib/stores/editor/NewElementState.d.ts.map +1 -1
  16. package/lib/stores/editor/NewElementState.js +28 -5
  17. package/lib/stores/editor/NewElementState.js.map +1 -1
  18. package/lib/stores/editor/editor-state/element-editor-state/RuntimeEditorState.d.ts +44 -14
  19. package/lib/stores/editor/editor-state/element-editor-state/RuntimeEditorState.d.ts.map +1 -1
  20. package/lib/stores/editor/editor-state/element-editor-state/RuntimeEditorState.js +111 -20
  21. package/lib/stores/editor/editor-state/element-editor-state/RuntimeEditorState.js.map +1 -1
  22. package/lib/stores/graph-modifier/DSL_LakehouseRuntime_GraphModifierHelper.d.ts +20 -0
  23. package/lib/stores/graph-modifier/DSL_LakehouseRuntime_GraphModifierHelper.d.ts.map +1 -0
  24. package/lib/stores/graph-modifier/DSL_LakehouseRuntime_GraphModifierHelper.js +30 -0
  25. package/lib/stores/graph-modifier/DSL_LakehouseRuntime_GraphModifierHelper.js.map +1 -0
  26. package/package.json +14 -14
  27. package/src/application/LegendIngestionConfiguration.ts +2 -0
  28. package/src/components/editor/editor-group/RuntimeEditor.tsx +221 -28
  29. package/src/components/editor/side-bar/CreateNewElementModal.tsx +56 -16
  30. package/src/stores/editor/NewElementState.ts +30 -5
  31. package/src/stores/editor/editor-state/element-editor-state/RuntimeEditorState.ts +143 -29
  32. package/src/stores/graph-modifier/DSL_LakehouseRuntime_GraphModifierHelper.ts +49 -0
  33. package/tsconfig.json +1 -0
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { useRef } from 'react';
17
+ import React, { useRef } from 'react';
18
18
  import { LEGEND_STUDIO_TEST_ID } from '../../../__lib__/LegendStudioTesting.js';
19
19
  import { observer } from 'mobx-react-lite';
20
20
  import {
@@ -28,6 +28,7 @@ import {
28
28
  CONNECTION_TYPE,
29
29
  type RuntimeOption,
30
30
  NewLakehouseDataProductDriver,
31
+ NewRuntimeType,
31
32
  } from '../../../stores/editor/NewElementState.js';
32
33
  import { Dialog, compareLabelFn, CustomSelectorInput } from '@finos/legend-art';
33
34
  import type { EditorStore } from '../../../stores/editor/EditorStore.js';
@@ -178,7 +179,23 @@ const NewRuntimeDriverEditor = observer(() => {
178
179
  const newRuntimeDriver = editorStore.newElementState.getNewElementDriver(
179
180
  NewPackageableRuntimeDriver,
180
181
  );
182
+ const type = newRuntimeDriver.type;
183
+ const typeOptions = Object.values(NewRuntimeType).map((typeOption) => ({
184
+ label: prettyCONSTName(typeOption),
185
+ value: typeOption,
186
+ }));
187
+ const typeOption = {
188
+ value: type,
189
+ label: prettyCONSTName(type),
190
+ };
191
+ const onTypeChange = (val: {
192
+ value: NewRuntimeType;
193
+ label: string;
194
+ }): void => {
195
+ newRuntimeDriver.setType(val.value);
196
+ };
181
197
  // mapping
198
+ const isStandard = type === NewRuntimeType.LEGACY;
182
199
  const mapping = newRuntimeDriver.mapping;
183
200
  const mappingOptions =
184
201
  editorStore.graphManagerState.usableMappings.map(buildElementOption);
@@ -193,22 +210,45 @@ const NewRuntimeDriverEditor = observer(() => {
193
210
  }
194
211
  };
195
212
 
196
- if (!mapping) {
197
- // TODO: show warning
198
- return <div>no mapping found</div>;
199
- }
200
213
  return (
201
- <div className="explorer__new-element-modal__driver">
202
- <CustomSelectorInput
203
- className="explorer__new-element-modal__driver__dropdown"
204
- options={mappingOptions}
205
- onChange={onMappingSelectionChange}
206
- value={selectedMappingOption}
207
- darkMode={
208
- !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
209
- }
210
- />
211
- </div>
214
+ <>
215
+ <div className="panel__content__form__section__header__label">
216
+ Runtime Type
217
+ </div>
218
+ <div className="explorer__new-element-modal__driver">
219
+ <CustomSelectorInput
220
+ className="explorer__new-element-modal__driver__dropdown"
221
+ options={typeOptions}
222
+ onChange={onTypeChange}
223
+ value={typeOption}
224
+ darkMode={
225
+ !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled
226
+ }
227
+ />
228
+ </div>
229
+ {isStandard &&
230
+ (mapping ? (
231
+ <>
232
+ <div className="panel__content__form__section__header__label">
233
+ Mapping
234
+ </div>
235
+ <div className="explorer__new-element-modal__driver">
236
+ <CustomSelectorInput
237
+ className="explorer__new-element-modal__driver__dropdown"
238
+ options={mappingOptions}
239
+ onChange={onMappingSelectionChange}
240
+ value={selectedMappingOption}
241
+ darkMode={
242
+ !applicationStore.layoutService
243
+ .TEMPORARY__isLightColorThemeEnabled
244
+ }
245
+ />
246
+ </div>
247
+ </>
248
+ ) : (
249
+ <div>no mapping found</div>
250
+ ))}
251
+ </>
212
252
  );
213
253
  });
214
254
 
@@ -39,7 +39,6 @@ import {
39
39
  } from './editor-state/GraphGenerationState.js';
40
40
  import {
41
41
  type PackageableElement,
42
- type Runtime,
43
42
  type Store,
44
43
  ModelStore,
45
44
  type Connection,
@@ -85,6 +84,8 @@ import {
85
84
  GenericTypeExplicitReference,
86
85
  GenericType,
87
86
  DataProduct,
87
+ LakehouseRuntime,
88
+ type Runtime,
88
89
  } from '@finos/legend-graph';
89
90
  import type { DSL_Mapping_LegendStudioApplicationPlugin_Extension } from '../extensions/DSL_Mapping_LegendStudioApplicationPlugin_Extension.js';
90
91
  import {
@@ -203,8 +204,14 @@ export abstract class NewElementDriver<T extends PackageableElement> {
203
204
  abstract createElement(name: string): T;
204
205
  }
205
206
 
207
+ export enum NewRuntimeType {
208
+ LEGACY = 'LEGACY',
209
+ LAKEHOUSE = 'LAKEHOUSE',
210
+ }
211
+
206
212
  export class NewPackageableRuntimeDriver extends NewElementDriver<PackageableRuntime> {
207
213
  mapping?: Mapping | undefined;
214
+ type = NewRuntimeType.LEGACY;
208
215
 
209
216
  constructor(editorStore: EditorStore) {
210
217
  super(editorStore);
@@ -213,24 +220,42 @@ export class NewPackageableRuntimeDriver extends NewElementDriver<PackageableRun
213
220
  mapping: observable,
214
221
  setMapping: action,
215
222
  isValid: computed,
223
+ type: observable,
224
+ setType: action,
216
225
  });
217
226
 
218
- const mappings = this.editorStore.graphManagerState.graph.mappings;
219
- if (mappings.length) {
220
- this.mapping = mappings[0];
227
+ const firstMapping = this.editorStore.graphManagerState.graph.mappings[0];
228
+ this.mapping = firstMapping;
229
+ if (!firstMapping) {
230
+ this.type = NewRuntimeType.LAKEHOUSE;
221
231
  }
222
232
  }
223
233
 
234
+ setType(val: NewRuntimeType): void {
235
+ this.type = val;
236
+ }
237
+
224
238
  setMapping(mapping: Mapping): void {
225
239
  this.mapping = mapping;
226
240
  }
227
241
 
228
242
  get isValid(): boolean {
229
- return Boolean(this.mapping);
243
+ if (this.type === NewRuntimeType.LEGACY) {
244
+ return Boolean(this.mapping);
245
+ }
246
+ return true;
230
247
  }
231
248
 
232
249
  createElement(name: string): PackageableRuntime {
233
250
  const runtime = new PackageableRuntime(name);
251
+ if (this.type === NewRuntimeType.LAKEHOUSE) {
252
+ const lakehouseRuntime = new LakehouseRuntime();
253
+ lakehouseRuntime.environment = '';
254
+ lakehouseRuntime.warehouse = '';
255
+ lakehouseRuntime.connectionPointer = undefined;
256
+ runtime.runtimeValue = lakehouseRuntime;
257
+ return runtime;
258
+ }
234
259
  runtime.runtimeValue = new EngineRuntime();
235
260
  runtime_addMapping(
236
261
  runtime.runtimeValue,
@@ -14,8 +14,9 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { computed, action, observable, makeObservable } from 'mobx';
17
+ import { computed, action, observable, makeObservable, flow } from 'mobx';
18
18
  import type { EditorStore } from '../../EditorStore.js';
19
+ import type { IngestDeploymentServerConfig } from '@finos/legend-server-lakehouse';
19
20
  import {
20
21
  guaranteeType,
21
22
  uuid,
@@ -25,6 +26,8 @@ import {
25
26
  addUniqueEntry,
26
27
  assertErrorThrown,
27
28
  filterByType,
29
+ type GeneratorFn,
30
+ removeSuffix,
28
31
  } from '@finos/legend-shared';
29
32
  import { ElementEditorState } from './ElementEditorState.js';
30
33
  import type { RuntimeExplorerTreeNodeData } from '../../utils/TreeUtils.js';
@@ -65,6 +68,7 @@ import {
65
68
  isStubbed_StoreConnections,
66
69
  getAllIdentifiedConnections,
67
70
  generateIdentifiedConnectionId,
71
+ LakehouseRuntime,
68
72
  } from '@finos/legend-graph';
69
73
  import type { DSL_Mapping_LegendStudioApplicationPlugin_Extension } from '../../../extensions/DSL_Mapping_LegendStudioApplicationPlugin_Extension.js';
70
74
  import { packageableElementReference_setValue } from '../../../graph-modifier/DomainGraphModifierHelper.js';
@@ -76,6 +80,7 @@ import {
76
80
  runtime_deleteMapping,
77
81
  } from '../../../graph-modifier/DSL_Mapping_GraphModifierHelper.js';
78
82
  import { CUSTOM_LABEL } from '../../NewElementState.js';
83
+ import { lakehouseRuntime_setConnection } from '../../../graph-modifier/DSL_LakehouseRuntime_GraphModifierHelper.js';
79
84
 
80
85
  export const getClassMappingStore = (
81
86
  setImplementation: SetImplementation,
@@ -341,11 +346,11 @@ export const getRuntimeExplorerTreeData = (
341
346
  export abstract class RuntimeEditorTabState {
342
347
  readonly uuid = uuid();
343
348
  editorStore: EditorStore;
344
- runtimeEditorState: RuntimeEditorState;
349
+ runtimeEditorState: EngineRuntimeEditorState;
345
350
 
346
351
  constructor(
347
352
  editorStore: EditorStore,
348
- runtimeEditorState: RuntimeEditorState,
353
+ runtimeEditorState: EngineRuntimeEditorState,
349
354
  ) {
350
355
  this.editorStore = editorStore;
351
356
  this.runtimeEditorState = runtimeEditorState;
@@ -375,7 +380,7 @@ export abstract class IdentifiedConnectionsEditorTabState extends RuntimeEditorT
375
380
 
376
381
  constructor(
377
382
  editorStore: EditorStore,
378
- runtimeEditorState: RuntimeEditorState,
383
+ runtimeEditorState: EngineRuntimeEditorState,
379
384
  ) {
380
385
  super(editorStore, runtimeEditorState);
381
386
 
@@ -454,7 +459,7 @@ export class IdentifiedConnectionsPerStoreEditorTabState extends IdentifiedConne
454
459
 
455
460
  constructor(
456
461
  editorStore: EditorStore,
457
- runtimeEditorState: RuntimeEditorState,
462
+ runtimeEditorState: EngineRuntimeEditorState,
458
463
  store: Store,
459
464
  ) {
460
465
  super(editorStore, runtimeEditorState);
@@ -557,7 +562,7 @@ export class IdentifiedConnectionsPerClassEditorTabState extends IdentifiedConne
557
562
 
558
563
  constructor(
559
564
  editorStore: EditorStore,
560
- runtimeEditorState: RuntimeEditorState,
565
+ runtimeEditorState: EngineRuntimeEditorState,
561
566
  _class: Class,
562
567
  ) {
563
568
  super(editorStore, runtimeEditorState);
@@ -641,23 +646,17 @@ export class IdentifiedConnectionsPerClassEditorTabState extends IdentifiedConne
641
646
 
642
647
  export class RuntimeEditorRuntimeTabState extends RuntimeEditorTabState {}
643
648
 
644
- export class RuntimeEditorState {
645
- /**
646
- * NOTE: used to force component remount on state change
647
- */
648
- readonly uuid = uuid();
649
+ export class EngineRuntimeEditorState {
649
650
  editorStore: EditorStore;
650
- runtime: Runtime;
651
+ state: RuntimeEditorState;
651
652
  runtimeValue: EngineRuntime;
652
- isEmbeddedRuntime: boolean;
653
653
  explorerTreeData: TreeData<RuntimeExplorerTreeNodeData>;
654
654
  currentTabState?: RuntimeEditorTabState | undefined;
655
655
 
656
- constructor(
657
- editorStore: EditorStore,
658
- runtime: Runtime,
659
- isEmbeddedRuntime: boolean,
660
- ) {
656
+ constructor(state: RuntimeEditorState, value: EngineRuntime) {
657
+ this.editorStore = state.editorStore;
658
+ this.state = state;
659
+ this.runtimeValue = value;
661
660
  makeObservable(this, {
662
661
  explorerTreeData: observable.ref,
663
662
  currentTabState: observable,
@@ -672,17 +671,9 @@ export class RuntimeEditorState {
672
671
  reprocessRuntimeExplorerTree: action,
673
672
  reprocessCurrentTabState: action,
674
673
  });
675
-
676
- this.editorStore = editorStore;
677
- this.runtime = runtime;
678
- this.isEmbeddedRuntime = isEmbeddedRuntime;
679
- this.runtimeValue =
680
- runtime instanceof RuntimePointer
681
- ? runtime.packageableRuntime.value.runtimeValue
682
- : guaranteeType(runtime, EngineRuntime);
683
674
  this.explorerTreeData = getRuntimeExplorerTreeData(
684
- this.runtime,
685
- this.editorStore,
675
+ this.runtimeValue,
676
+ this.state.editorStore,
686
677
  );
687
678
  this.openTabFor(this.runtimeValue); // open runtime tab on init
688
679
  }
@@ -855,7 +846,10 @@ export class RuntimeEditorState {
855
846
  const openedTreeNodeIds = Array.from(this.explorerTreeData.nodes.values())
856
847
  .filter((node) => node.isOpen)
857
848
  .map((node) => node.id);
858
- const treeData = getRuntimeExplorerTreeData(this.runtime, this.editorStore);
849
+ const treeData = getRuntimeExplorerTreeData(
850
+ this.runtimeValue,
851
+ this.editorStore,
852
+ );
859
853
  openedTreeNodeIds.forEach((nodeId) => {
860
854
  const node = treeData.nodes.get(nodeId);
861
855
  if (node && !node.isOpen) {
@@ -897,6 +891,126 @@ export class RuntimeEditorState {
897
891
  }
898
892
  }
899
893
 
894
+ export enum LakehouseRuntimeType {
895
+ ENVIRONMENT = 'ENVIRONMENT',
896
+ CONNECTION = 'CONNECTION',
897
+ }
898
+
899
+ export class LakehouseRuntimeEditorState extends EngineRuntimeEditorState {
900
+ declare runtimeValue: LakehouseRuntime;
901
+ availableEnvs: IngestDeploymentServerConfig[] | undefined;
902
+ lakehouseRuntimeType = LakehouseRuntimeType.ENVIRONMENT;
903
+
904
+ constructor(state: RuntimeEditorState, value: LakehouseRuntime) {
905
+ super(state, value);
906
+ makeObservable(this, {
907
+ availableEnvs: observable,
908
+ fetchLakehouseSummaries: flow,
909
+ setEnvSummaries: action,
910
+ lakehouseRuntimeType: observable,
911
+ setLakehouseRuntimeType: action,
912
+ envOptions: computed,
913
+ });
914
+ this.runtimeValue = value;
915
+ // fix when metamodel is more clear on this
916
+ if (value.connectionPointer) {
917
+ this.lakehouseRuntimeType = LakehouseRuntimeType.CONNECTION;
918
+ }
919
+ }
920
+
921
+ setLakehouseRuntimeType(val: LakehouseRuntimeType): void {
922
+ if (val !== this.lakehouseRuntimeType) {
923
+ this.lakehouseRuntimeType = val;
924
+ if (val === LakehouseRuntimeType.CONNECTION) {
925
+ this.runtimeValue.environment = undefined;
926
+ this.runtimeValue.warehouse = undefined;
927
+ } else {
928
+ this.setConnection(undefined);
929
+ }
930
+ }
931
+ }
932
+
933
+ setConnection(val: PackageableConnection | undefined): void {
934
+ lakehouseRuntime_setConnection(this.runtimeValue, val);
935
+ }
936
+
937
+ get envOptions(): { label: string; value: string }[] {
938
+ return this.availableEnvs?.map((e) => this.convertEnvToOption(e)) ?? [];
939
+ }
940
+
941
+ convertEnvToOption(val: IngestDeploymentServerConfig): {
942
+ label: string;
943
+ value: string;
944
+ } {
945
+ const discoveryUrlSuffix =
946
+ this.editorStore.applicationStore.config.options.ingestDeploymentConfig
947
+ ?.discoveryUrlSuffix;
948
+ const host = new URL(val.ingestServerUrl).host;
949
+ const value = discoveryUrlSuffix
950
+ ? removeSuffix(host, discoveryUrlSuffix)
951
+ : host;
952
+ return {
953
+ label: value,
954
+ value,
955
+ };
956
+ }
957
+
958
+ setEnvSummaries(val: IngestDeploymentServerConfig[] | undefined): void {
959
+ this.availableEnvs = val;
960
+ }
961
+
962
+ *fetchLakehouseSummaries(token?: string | undefined): GeneratorFn<void> {
963
+ try {
964
+ const ingestionManager = this.editorStore.ingestionManager;
965
+ this.setEnvSummaries(undefined);
966
+ if (ingestionManager) {
967
+ const res = (yield ingestionManager.fetchLakehouseEnvironmentSummaries(
968
+ token,
969
+ )) as unknown as IngestDeploymentServerConfig[] | undefined;
970
+ this.setEnvSummaries(res);
971
+ if (!this.runtimeValue.environment && this.envOptions.length) {
972
+ this.runtimeValue.environment = this.envOptions[0]?.value;
973
+ }
974
+ }
975
+ } catch (error) {
976
+ assertErrorThrown(error);
977
+ }
978
+ }
979
+ }
980
+
981
+ export class RuntimeEditorState {
982
+ /**
983
+ * NOTE: used to force component remount on state change
984
+ */
985
+ readonly uuid = uuid();
986
+ editorStore: EditorStore;
987
+ runtime: Runtime;
988
+ runtimeValueEditorState: EngineRuntimeEditorState;
989
+ isEmbeddedRuntime: boolean;
990
+
991
+ constructor(
992
+ editorStore: EditorStore,
993
+ runtime: Runtime,
994
+ isEmbeddedRuntime: boolean,
995
+ ) {
996
+ makeObservable(this, {
997
+ runtimeValueEditorState: observable,
998
+ });
999
+
1000
+ this.editorStore = editorStore;
1001
+ this.runtime = runtime;
1002
+ this.isEmbeddedRuntime = isEmbeddedRuntime;
1003
+ const runtimeValue =
1004
+ runtime instanceof RuntimePointer
1005
+ ? runtime.packageableRuntime.value.runtimeValue
1006
+ : guaranteeType(runtime, EngineRuntime);
1007
+ this.runtimeValueEditorState =
1008
+ runtimeValue instanceof LakehouseRuntime
1009
+ ? new LakehouseRuntimeEditorState(this, runtimeValue)
1010
+ : new EngineRuntimeEditorState(this, runtimeValue);
1011
+ }
1012
+ }
1013
+
900
1014
  export class PackageableRuntimeEditorState extends ElementEditorState {
901
1015
  runtimeEditorState: RuntimeEditorState;
902
1016
 
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ ConnectionPointer,
19
+ type PackageableConnection,
20
+ PackageableElementExplicitReference,
21
+ type LakehouseRuntime,
22
+ } from '@finos/legend-graph';
23
+ import { action } from 'mobx';
24
+
25
+ export const lakehouseRuntime_setWarehouse = action(
26
+ (runtime: LakehouseRuntime, warehouse: string | undefined) => {
27
+ runtime.warehouse = warehouse;
28
+ },
29
+ );
30
+
31
+ export const lakehouseRuntime_setEnvironment = action(
32
+ (runtime: LakehouseRuntime, environment: string | undefined) => {
33
+ runtime.environment = environment;
34
+ },
35
+ );
36
+
37
+ export const lakehouseRuntime_setConnection = action(
38
+ (
39
+ runtime: LakehouseRuntime,
40
+ connection: PackageableConnection | undefined,
41
+ ) => {
42
+ runtime.connectionPointer =
43
+ connection !== undefined
44
+ ? new ConnectionPointer(
45
+ PackageableElementExplicitReference.create(connection),
46
+ )
47
+ : undefined;
48
+ },
49
+ );
package/tsconfig.json CHANGED
@@ -198,6 +198,7 @@
198
198
  "./src/stores/graph-modifier/DSL_ExternalFormat_GraphModifierHelper.ts",
199
199
  "./src/stores/graph-modifier/DSL_FunctionActivator_GraphModifierHelper.ts",
200
200
  "./src/stores/graph-modifier/DSL_Generation_GraphModifierHelper.ts",
201
+ "./src/stores/graph-modifier/DSL_LakehouseRuntime_GraphModifierHelper.ts",
201
202
  "./src/stores/graph-modifier/DSL_Mapping_GraphModifierHelper.ts",
202
203
  "./src/stores/graph-modifier/DSL_Service_GraphModifierHelper.ts",
203
204
  "./src/stores/graph-modifier/DomainGraphModifierHelper.ts",