@finos/legend-extension-dsl-data-space 10.4.4 → 10.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. package/lib/components/DSL_DataSpace_LegendApplicationPlugin.d.ts +1 -1
  2. package/lib/components/DSL_DataSpace_LegendApplicationPlugin.d.ts.map +1 -1
  3. package/lib/components/DSL_DataSpace_LegendApplicationPlugin.js +4 -3
  4. package/lib/components/DSL_DataSpace_LegendApplicationPlugin.js.map +1 -1
  5. package/lib/components/query-builder/DataSpaceQueryBuilder.d.ts.map +1 -1
  6. package/lib/components/query-builder/DataSpaceQueryBuilder.js +20 -6
  7. package/lib/components/query-builder/DataSpaceQueryBuilder.js.map +1 -1
  8. package/lib/components/query-builder/DataSpaceQueryBuilderTemplateQueryPanelContent.js +1 -1
  9. package/lib/components/query-builder/DataSpaceQueryBuilderTemplateQueryPanelContent.js.map +1 -1
  10. package/lib/graph-manager/action/analytics/DataSpaceAnalysisHelper.d.ts +3 -0
  11. package/lib/graph-manager/action/analytics/DataSpaceAnalysisHelper.d.ts.map +1 -1
  12. package/lib/graph-manager/action/analytics/DataSpaceAnalysisHelper.js +4 -1
  13. package/lib/graph-manager/action/analytics/DataSpaceAnalysisHelper.js.map +1 -1
  14. package/lib/graph-manager/index.d.ts +1 -0
  15. package/lib/graph-manager/index.d.ts.map +1 -1
  16. package/lib/graph-manager/index.js +1 -0
  17. package/lib/graph-manager/index.js.map +1 -1
  18. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.d.ts +6 -2
  19. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.d.ts.map +1 -1
  20. package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.js.map +1 -1
  21. package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.d.ts +17 -3
  22. package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.d.ts.map +1 -1
  23. package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.js +219 -48
  24. package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.js.map +1 -1
  25. package/lib/index.css +1 -1
  26. package/lib/package.json +3 -3
  27. package/lib/stores/query-builder/DataSpaceQueryBuilderState.d.ts +5 -11
  28. package/lib/stores/query-builder/DataSpaceQueryBuilderState.d.ts.map +1 -1
  29. package/lib/stores/query-builder/DataSpaceQueryBuilderState.js +19 -30
  30. package/lib/stores/query-builder/DataSpaceQueryBuilderState.js.map +1 -1
  31. package/package.json +15 -15
  32. package/src/components/DSL_DataSpace_LegendApplicationPlugin.tsx +6 -8
  33. package/src/components/query-builder/DataSpaceQueryBuilder.tsx +40 -9
  34. package/src/components/query-builder/DataSpaceQueryBuilderTemplateQueryPanelContent.tsx +1 -1
  35. package/src/graph-manager/action/analytics/DataSpaceAnalysisHelper.ts +14 -1
  36. package/src/graph-manager/index.ts +4 -0
  37. package/src/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.ts +24 -3
  38. package/src/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.ts +446 -72
  39. package/src/stores/query-builder/DataSpaceQueryBuilderState.ts +32 -40
@@ -34,7 +34,6 @@ import {
34
34
  Package,
35
35
  QueryDataSpaceExecutionContext,
36
36
  elementBelongsToPackage,
37
- RuntimePointer,
38
37
  } from '@finos/legend-graph';
39
38
  import {
40
39
  type DepotServerClient,
@@ -47,7 +46,6 @@ import {
47
46
  ActionState,
48
47
  assertErrorThrown,
49
48
  filterByType,
50
- getNullableFirstEntry,
51
49
  } from '@finos/legend-shared';
52
50
  import { action, flow, makeObservable, observable } from 'mobx';
53
51
  import { renderDataSpaceQueryBuilderSetupPanelContent } from '../../components/query-builder/DataSpaceQueryBuilder.js';
@@ -88,11 +86,34 @@ export const resolveUsableDataSpaceClasses = (
88
86
  dataSpace: DataSpace,
89
87
  mapping: Mapping,
90
88
  graphManagerState: GraphManagerState,
89
+ queryBuilderState?: DataSpaceQueryBuilderState,
91
90
  ): Class[] => {
92
- const compatibleClasses = getMappingCompatibleClasses(
91
+ let compatibleClasses = getMappingCompatibleClasses(
93
92
  mapping,
94
93
  graphManagerState.usableClasses,
95
94
  );
95
+ const mappingModelCoverageAnalysisResult =
96
+ queryBuilderState?.dataSpaceAnalysisResult?.mappingToMappingCoverageResult?.get(
97
+ mapping.path,
98
+ );
99
+ if (
100
+ // This check is to make sure that we have `info` field present in `MappedEntity` which
101
+ // contains information about the mapped class path
102
+ mappingModelCoverageAnalysisResult?.mappedEntities.some(
103
+ (m) => m.info !== undefined,
104
+ )
105
+ ) {
106
+ const compatibleClassPaths =
107
+ mappingModelCoverageAnalysisResult.mappedEntities.map(
108
+ (e) => e.info?.classPath,
109
+ );
110
+ const uniqueCompatibleClasses = compatibleClassPaths.filter(
111
+ (val, index) => compatibleClassPaths.indexOf(val) === index,
112
+ );
113
+ compatibleClasses = graphManagerState.graph.classes.filter((c) =>
114
+ uniqueCompatibleClasses.includes(c.path),
115
+ );
116
+ }
96
117
  if (dataSpace.elements?.length) {
97
118
  const elements = dataSpace.elements;
98
119
  return compatibleClasses.filter((_class) => {
@@ -335,7 +356,7 @@ export class DataSpacesDepotRepository extends DataSpacesBuilderRepoistory {
335
356
  }
336
357
 
337
358
  export class DataSpaceQueryBuilderState extends QueryBuilderState {
338
- readonly onDataSpaceChange: (val: DataSpaceInfo) => void;
359
+ readonly onDataSpaceChange: (val: DataSpaceInfo) => Promise<void>;
339
360
  readonly onExecutionContextChange?:
340
361
  | ((val: DataSpaceExecutionContext) => void)
341
362
  | undefined;
@@ -351,6 +372,7 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
351
372
  executionContext!: DataSpaceExecutionContext;
352
373
  showRuntimeSelector = false;
353
374
  isTemplateQueryDialogOpen = false;
375
+ isLightGraphEnabled!: boolean;
354
376
  displayedTemplateQueries: DataSpaceExecutableAnalysisResult[] | undefined;
355
377
 
356
378
  constructor(
@@ -360,8 +382,9 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
360
382
  actionConfig: QueryBuilderActionConfig,
361
383
  dataSpace: DataSpace,
362
384
  executionContext: DataSpaceExecutionContext,
385
+ isLightGraphEnabled: boolean,
363
386
  dataSpaceRepo: DataSpacesBuilderRepoistory | undefined,
364
- onDataSpaceChange: (val: DataSpaceInfo) => void,
387
+ onDataSpaceChange: (val: DataSpaceInfo) => Promise<void>,
365
388
  dataSpaceAnalysisResult?: DataSpaceAnalysisResult | undefined,
366
389
  onExecutionContextChange?:
367
390
  | ((val: DataSpaceExecutionContext) => void)
@@ -377,10 +400,12 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
377
400
  executionContext: observable,
378
401
  showRuntimeSelector: observable,
379
402
  isTemplateQueryDialogOpen: observable,
403
+ isLightGraphEnabled: observable,
380
404
  displayedTemplateQueries: observable,
381
405
  setExecutionContext: action,
382
406
  setShowRuntimeSelector: action,
383
407
  setTemplateQueryDialogOpen: action,
408
+ setIsLightGraphEnabled: action,
384
409
  intialize: flow,
385
410
  });
386
411
 
@@ -425,41 +450,8 @@ export class DataSpaceQueryBuilderState extends QueryBuilderState {
425
450
  this.showRuntimeSelector = val;
426
451
  }
427
452
 
428
- /**
429
- * Propagation after changing the execution context:
430
- * - The mapping will be updated to the mapping of the execution context
431
- * - The runtime will be updated to the default runtime of the execution context
432
- * - If no class is chosen, try to choose a compatible class
433
- * - If the chosen class is compatible with the new selected execution context mapping, do nothing, otherwise, try to choose a compatible class
434
- */
435
- propagateExecutionContextChange(
436
- executionContext: DataSpaceExecutionContext,
437
- ): void {
438
- const mapping = executionContext.mapping.value;
439
- this.changeMapping(mapping);
440
- const mappingModelCoverageAnalysisResult =
441
- this.dataSpaceAnalysisResult?.mappingToMappingCoverageResult?.get(
442
- mapping.path,
443
- );
444
- if (mappingModelCoverageAnalysisResult) {
445
- this.explorerState.mappingModelCoverageAnalysisResult =
446
- mappingModelCoverageAnalysisResult;
447
- }
448
- this.changeRuntime(new RuntimePointer(executionContext.defaultRuntime));
449
-
450
- const compatibleClasses = resolveUsableDataSpaceClasses(
451
- this.dataSpace,
452
- mapping,
453
- this.graphManagerState,
454
- );
455
- // if there is no chosen class or the chosen one is not compatible
456
- // with the mapping then pick a compatible class if possible
457
- if (!this.class || !compatibleClasses.includes(this.class)) {
458
- const possibleNewClass = getNullableFirstEntry(compatibleClasses);
459
- if (possibleNewClass) {
460
- this.changeClass(possibleNewClass);
461
- }
462
- }
453
+ setIsLightGraphEnabled(val: boolean): void {
454
+ this.isLightGraphEnabled = val;
463
455
  }
464
456
 
465
457
  override buildFunctionAnalysisInfo():