@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
@@ -19,6 +19,8 @@ import {
19
19
  type AbstractPureGraphManager,
20
20
  type PureProtocolProcessorPlugin,
21
21
  type MappingModelCoverageAnalysisResult,
22
+ type GraphManagerOperationReport,
23
+ type FunctionAnalysisInfo,
22
24
  PureModel,
23
25
  V1_PureGraphManager,
24
26
  PureClientVersion,
@@ -36,8 +38,22 @@ import {
36
38
  V1_deserializePackageableElement,
37
39
  QueryDataSpaceExecutionContextInfo,
38
40
  V1_RemoteEngine,
41
+ LegendSDLC,
42
+ PackageableElementPointerType,
43
+ V1_PackageableElementPointer,
44
+ V1_ConcreteFunctionDefinition,
45
+ V1_buildFunctionInfoAnalysis,
46
+ GraphBuilderError,
47
+ V1_MappingAnalysisCoveragePartition,
48
+ V1_deserializeDataspaceCoveragePartition,
49
+ V1_MappingModelCoveragePartition,
50
+ V1_getFullReturnTypePath,
39
51
  } from '@finos/legend-graph';
40
- import type { Entity } from '@finos/legend-storage';
52
+ import type {
53
+ Entity,
54
+ ProjectGAVCoordinates,
55
+ StoredFileGeneration,
56
+ } from '@finos/legend-storage';
41
57
  import {
42
58
  type PlainObject,
43
59
  ActionState,
@@ -56,6 +72,7 @@ import {
56
72
  } from '../../../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
57
73
  import {
58
74
  V1_DataSpace,
75
+ V1_DataSpaceExecutionContext,
59
76
  V1_DataSpaceSupportCombinedInfo,
60
77
  V1_DataSpaceSupportEmail,
61
78
  V1_DataSpaceTemplateExecutable,
@@ -96,6 +113,8 @@ import {
96
113
  V1_DataSpaceFunctionPointerExecutableInfo,
97
114
  } from './engine/analytics/V1_DataSpaceAnalysis.js';
98
115
  import { getDiagram } from '@finos/legend-extension-dsl-diagram/graph';
116
+ import { resolveVersion } from '@finos/legend-server-depot';
117
+ import { DATASPACE_ANALYTICS_FILE_NAME } from '../../../action/analytics/DataSpaceAnalysisHelper.js';
99
118
 
100
119
  const ANALYZE_DATA_SPACE_TRACE = 'analyze data space';
101
120
  const TEMPORARY__TDS_SAMPLE_VALUES__DELIMETER = '-- e.g.';
@@ -219,6 +238,131 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
219
238
  );
220
239
  }
221
240
 
241
+ retrieveDataSpaceAnalysisFromFileGeneration = (
242
+ fileGeneration: StoredFileGeneration[],
243
+ ): PlainObject<V1_DataSpaceAnalysisResult> | undefined => {
244
+ const fileContent = fileGeneration.find((fileGen) =>
245
+ fileGen.file.path.includes(DATASPACE_ANALYTICS_FILE_NAME),
246
+ )?.file.content;
247
+
248
+ return fileContent ? JSON.parse(fileContent) : undefined;
249
+ };
250
+
251
+ retrieveExecutionContextFromTemplateQueryId(
252
+ dataSpaceAnalysisResult: PlainObject<V1_DataSpaceAnalysisResult>,
253
+ templateQueryId: string,
254
+ plugins: PureProtocolProcessorPlugin[],
255
+ ): string | undefined {
256
+ const analysisResult = V1_deserializeDataSpaceAnalysisResult(
257
+ dataSpaceAnalysisResult,
258
+ plugins,
259
+ );
260
+ let execContext = undefined;
261
+ const info = analysisResult.executables.find(
262
+ (ex) => ex.info?.id === templateQueryId,
263
+ )?.info;
264
+ if (info) {
265
+ execContext =
266
+ info.executionContextKey ?? analysisResult.defaultExecutionContext;
267
+ }
268
+ return execContext;
269
+ }
270
+
271
+ async analyzeDataSpaceCoverage(
272
+ dataSpacePath: string,
273
+ entitiesWithClassifierRetriever: () => Promise<
274
+ [PlainObject<Entity>[], PlainObject<Entity>[]]
275
+ >,
276
+ cacheRetriever?: () => Promise<PlainObject<StoredFileGeneration>[]>,
277
+ actionState?: ActionState,
278
+ graphReport?: GraphManagerOperationReport | undefined,
279
+ pureGraph?: PureModel | undefined,
280
+ executionContext?: string | undefined,
281
+ mappingPath?: string | undefined,
282
+ projectInfo?: ProjectGAVCoordinates,
283
+ templateQueryId?: string,
284
+ ): Promise<DataSpaceAnalysisResult> {
285
+ // reterieve data space artifacts (more than one file) from cache
286
+ const dataspaceArtifacts = cacheRetriever
287
+ ? (
288
+ await this.fetchDataSpaceArtifactsFromCache(
289
+ cacheRetriever,
290
+ actionState,
291
+ )
292
+ ).filter((artifact) => artifact.path === dataSpacePath)
293
+ : undefined;
294
+
295
+ let analysisResult: PlainObject<V1_DataSpaceAnalysisResult>;
296
+ let cachedAnalysisResult;
297
+ let mappingAnalysisCoveragePartition: V1_MappingAnalysisCoveragePartition[] =
298
+ [];
299
+ let mappingModelCoveragePartition: V1_MappingModelCoveragePartition[] = [];
300
+
301
+ // build the data space analytics result from the file generation
302
+ const result = this.retrieveDataSpaceAnalysisFromFileGeneration(
303
+ dataspaceArtifacts as unknown as StoredFileGeneration[],
304
+ );
305
+
306
+ if (result) {
307
+ cachedAnalysisResult = V1_deserializeDataSpaceAnalysisResult(
308
+ result,
309
+ this.graphManager.pluginManager.getPureProtocolProcessorPlugins(),
310
+ );
311
+ }
312
+ // retrieve mapping analysis coverage partition and mapping model coverage partition
313
+ const dataspaceCoveragePartition = dataspaceArtifacts?.map((artifact) =>
314
+ V1_deserializeDataspaceCoveragePartition(artifact.file as PlainObject),
315
+ );
316
+ if (dataspaceCoveragePartition) {
317
+ mappingAnalysisCoveragePartition = dataspaceCoveragePartition.filter(
318
+ (partition) => partition instanceof V1_MappingAnalysisCoveragePartition,
319
+ );
320
+ mappingModelCoveragePartition = dataspaceCoveragePartition.filter(
321
+ (partition) => partition instanceof V1_MappingModelCoveragePartition,
322
+ );
323
+ }
324
+
325
+ // when trying to build a minimal graph, we need to make sure that there is associated mapping model coverage
326
+ // for every mapping in the data space analytics result otherwise we will have to build the full graph
327
+ if (
328
+ result &&
329
+ cachedAnalysisResult?.executionContexts.every(
330
+ (e) =>
331
+ mappingModelCoveragePartition.find((p) => p.mapping === e.mapping)
332
+ ?.model !== undefined,
333
+ )
334
+ ) {
335
+ analysisResult = result;
336
+ } else {
337
+ throw new GraphBuilderError(
338
+ 'Fail to get a valid dataspace analytics json from metadata, start building full graph',
339
+ );
340
+ }
341
+ const plugins =
342
+ this.graphManager.pluginManager.getPureProtocolProcessorPlugins();
343
+ return this.buildDataSpaceAnalytics(
344
+ analysisResult,
345
+ plugins,
346
+ true,
347
+ mappingAnalysisCoveragePartition,
348
+ mappingModelCoveragePartition,
349
+ graphReport,
350
+ pureGraph,
351
+ executionContext
352
+ ? executionContext
353
+ : templateQueryId
354
+ ? this.retrieveExecutionContextFromTemplateQueryId(
355
+ analysisResult,
356
+ templateQueryId,
357
+ plugins,
358
+ )
359
+ : undefined,
360
+ mappingPath,
361
+ projectInfo,
362
+ entitiesWithClassifierRetriever,
363
+ );
364
+ }
365
+
222
366
  async retrieveDataSpaceAnalysisFromCache(
223
367
  cacheRetriever: () => Promise<PlainObject<DataSpaceAnalysisResult>>,
224
368
  actionState?: ActionState,
@@ -255,11 +399,117 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
255
399
  return cacheResult;
256
400
  }
257
401
 
402
+ private async fetchDataSpaceArtifactsFromCache(
403
+ cacheRetriever: () => Promise<PlainObject<StoredFileGeneration>[]>,
404
+ actionState?: ActionState,
405
+ ): Promise<PlainObject<StoredFileGeneration>[]> {
406
+ let cacheResult: PlainObject<StoredFileGeneration>[] = [];
407
+ try {
408
+ actionState?.setMessage('Fetching data space artifacts from cache...');
409
+ cacheResult = await cacheRetriever();
410
+ } catch (error) {
411
+ assertErrorThrown(error);
412
+ this.graphManager.logService.warn(
413
+ LogEvent.create(GRAPH_MANAGER_EVENT.CACHE_MANAGER_FAILURE),
414
+ `Can't fetch data space artifacts cache: ${error.message}`,
415
+ );
416
+ }
417
+ return cacheResult;
418
+ }
419
+
420
+ // build function analysis info by fetching functions within this project from metadata when building minimal graph
421
+ async processFunctionForMinimalGraph(
422
+ entitiesWithClassifierRetriever: () => Promise<
423
+ [PlainObject<Entity>[], PlainObject<Entity>[]]
424
+ >,
425
+ graph: PureModel,
426
+ dataSpaceAnalysisResult: DataSpaceAnalysisResult,
427
+ plugins: PureProtocolProcessorPlugin[],
428
+ ): Promise<void> {
429
+ const [functionEntities, dependencyFunctionEntities]: [
430
+ PlainObject<Entity>[],
431
+ PlainObject<Entity>[],
432
+ ] = await entitiesWithClassifierRetriever();
433
+ const functionProtocols = functionEntities.map((func) =>
434
+ guaranteeType(
435
+ V1_deserializePackageableElement(
436
+ (func.entity as Entity).content,
437
+ plugins,
438
+ ),
439
+ V1_ConcreteFunctionDefinition,
440
+ ),
441
+ );
442
+ const dependencyFunctionProtocols = dependencyFunctionEntities.map((func) =>
443
+ guaranteeType(
444
+ V1_deserializePackageableElement(
445
+ (func.entity as Entity).content,
446
+ plugins,
447
+ ),
448
+ V1_ConcreteFunctionDefinition,
449
+ ),
450
+ );
451
+ const functionInfos = V1_buildFunctionInfoAnalysis(
452
+ functionProtocols,
453
+ graph,
454
+ );
455
+ const dependencyFunctionInfos = V1_buildFunctionInfoAnalysis(
456
+ dependencyFunctionProtocols,
457
+ graph,
458
+ );
459
+ if (functionInfos.length > 0) {
460
+ const functionInfoMap = new Map<string, FunctionAnalysisInfo>();
461
+ functionInfos.forEach((funcInfo) => {
462
+ functionInfoMap.set(funcInfo.functionPath, funcInfo);
463
+ });
464
+ dataSpaceAnalysisResult.functionInfos = functionInfoMap;
465
+ }
466
+ if (dependencyFunctionInfos.length > 0) {
467
+ const dependencyFunctionInfoMap = new Map<string, FunctionAnalysisInfo>();
468
+ functionInfos.forEach((funcInfo) => {
469
+ dependencyFunctionInfoMap.set(funcInfo.functionPath, funcInfo);
470
+ });
471
+ dataSpaceAnalysisResult.dependencyFunctionInfos =
472
+ dependencyFunctionInfoMap;
473
+ }
474
+ }
475
+
258
476
  async buildDataSpaceAnalytics(
259
- json: PlainObject<V1_DataSpaceAnalysisResult>,
477
+ analytics: PlainObject<V1_DataSpaceAnalysisResult>,
260
478
  plugins: PureProtocolProcessorPlugin[],
479
+ buildMinimalGraph = false,
480
+ mappingAnalysisCoveragePartition: V1_MappingAnalysisCoveragePartition[] = [],
481
+ mappingModelCoveragePartition: V1_MappingModelCoveragePartition[] = [],
482
+ graphReport?: GraphManagerOperationReport | undefined,
483
+ pureGraph?: PureModel | undefined,
484
+ executionContext?: string | undefined,
485
+ mappingPath?: string | undefined,
486
+ projectInfo?: ProjectGAVCoordinates,
487
+ entitiesWithClassifierRetriever?: () => Promise<
488
+ [PlainObject<Entity>[], PlainObject<Entity>[]]
489
+ >,
261
490
  ): Promise<DataSpaceAnalysisResult> {
262
- const analysisResult = V1_deserializeDataSpaceAnalysisResult(json, plugins);
491
+ const analysisResult = V1_deserializeDataSpaceAnalysisResult(
492
+ analytics,
493
+ plugins,
494
+ );
495
+
496
+ // build map to quick access mapping analysis coverage partition and mapping model coverage partition
497
+ const mappingAnalysisCoveragePartitionMap = new Map<
498
+ string,
499
+ V1_MappingAnalysisCoveragePartition
500
+ >();
501
+ mappingAnalysisCoveragePartition.forEach((partition) => {
502
+ mappingAnalysisCoveragePartitionMap.set(partition.mapping, partition);
503
+ });
504
+
505
+ const mappingModelCoveragePartitionMap = new Map<
506
+ string,
507
+ V1_MappingModelCoveragePartition
508
+ >();
509
+ mappingModelCoveragePartition.forEach((partition) => {
510
+ mappingModelCoveragePartitionMap.set(partition.mapping, partition);
511
+ });
512
+
263
513
  const result = new DataSpaceAnalysisResult();
264
514
  result.name = analysisResult.name;
265
515
  result.package = analysisResult.package;
@@ -306,26 +556,32 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
306
556
  // NOTE: we will relax the check and not throw here for unknown support info type
307
557
  }
308
558
 
309
- // create an empty graph
310
- const systemModel = new SystemModel(
311
- this.graphManager.pluginManager.getPureGraphPlugins(),
312
- );
313
- const coreModel = new CoreModel(
314
- this.graphManager.pluginManager.getPureGraphPlugins(),
315
- );
316
- await this.graphManager.buildSystem(
317
- coreModel,
318
- systemModel,
319
- ActionState.create(),
320
- {},
321
- );
322
- systemModel.initializeAutoImports();
323
- const graph = new PureModel(
324
- coreModel,
325
- systemModel,
326
- this.graphManager.pluginManager.getPureGraphPlugins(),
327
- );
559
+ // indicate if the minimal graph building is successful
560
+ let isMiniGraphSuccess = false;
328
561
 
562
+ let graphEntities;
563
+ let graph: PureModel;
564
+ if (pureGraph) {
565
+ graph = pureGraph;
566
+ } else {
567
+ // create an empty graph
568
+ const extensionElementClasses =
569
+ this.graphManager.pluginManager.getPureGraphPlugins();
570
+ const systemModel = new SystemModel(extensionElementClasses);
571
+ const coreModel = new CoreModel(extensionElementClasses);
572
+ await this.graphManager.buildSystem(
573
+ coreModel,
574
+ systemModel,
575
+ ActionState.create(),
576
+ {},
577
+ );
578
+ systemModel.initializeAutoImports();
579
+ graph = new PureModel(
580
+ coreModel,
581
+ systemModel,
582
+ this.graphManager.pluginManager.getPureGraphPlugins(),
583
+ );
584
+ }
329
585
  // Create dummy mappings and runtimes
330
586
  // TODO?: these stubbed mappings and runtimes are not really useful that useful, so either we should
331
587
  // simplify the model here or potentially refactor the backend analytics endpoint to return these as model
@@ -355,55 +611,153 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
355
611
  return runtime;
356
612
  });
357
613
 
358
- // prepare the model context data
359
- const graphEntities = analysisResult.model.elements
360
- // NOTE: this is a temporary hack to fix a problem with data space analytics
361
- // where the classes for properties are not properly surveyed
362
- // We need to wait for the actual fix in backend to be merged and released
363
- // See https://github.com/finos/legend-engine/pull/836
364
- .concat(
365
- uniq(
366
- analysisResult.model.elements.flatMap((element) => {
367
- if (element instanceof V1_Class) {
368
- return element.derivedProperties
369
- .map((prop) => prop.returnType)
370
- .concat(element.properties.map((prop) => prop.type));
371
- }
372
- return [];
373
- }),
374
- )
375
- // make sure to not include types already returned by the analysis
376
- .filter(
377
- (path) =>
378
- !analysisResult.model.elements
379
- .map((el) => el.path)
380
- .includes(path),
381
- )
382
- .map((path) => {
383
- const [pkgPath, name] = resolvePackagePathAndElementName(path);
384
- if (!pkgPath) {
385
- // exclude package-less elements (i.e. primitive types)
386
- return undefined;
387
- }
388
- const _class = new V1_Class();
389
- _class.name = name;
390
- _class.package = pkgPath;
391
- return _class;
392
- })
393
- .filter(isNonNullable),
394
- )
395
- .concat(mappingModels)
396
- .concat(runtimeModels)
397
- // NOTE: if an element could be found in the graph already it means it comes from system
398
- // so we could rid of it
399
- .filter((el) => !graph.getNullableElement(el.path, false))
400
- .map((el) => this.graphManager.elementProtocolToEntity(el));
401
-
402
- await this.graphManager.buildGraph(
403
- graph,
404
- graphEntities,
405
- ActionState.create(),
614
+ // The DataSpace entity is excluded from AnalyticsResult.Json to reduce the JSON size
615
+ // because all its information can be found in V1_DataSpaceAnalysisResult.
616
+ // Therefore, we are building a simple v1_DataSpace entity based on V1_DataSpaceAnalysisResult.
617
+ const dataspaceEntity = new V1_DataSpace();
618
+ dataspaceEntity.name = analysisResult.name;
619
+ dataspaceEntity.package = analysisResult.package;
620
+ dataspaceEntity.supportInfo = analysisResult.supportInfo;
621
+ dataspaceEntity.executionContexts = analysisResult.executionContexts.map(
622
+ (execContext) => {
623
+ const contextProtocol = new V1_DataSpaceExecutionContext();
624
+ contextProtocol.name = execContext.name;
625
+ contextProtocol.title = execContext.title;
626
+ contextProtocol.description = execContext.description;
627
+ contextProtocol.mapping = new V1_PackageableElementPointer(
628
+ PackageableElementPointerType.MAPPING,
629
+ execContext.mapping,
630
+ );
631
+ contextProtocol.defaultRuntime = new V1_PackageableElementPointer(
632
+ PackageableElementPointerType.RUNTIME,
633
+ execContext.defaultRuntime,
634
+ );
635
+ return contextProtocol;
636
+ },
406
637
  );
638
+ dataspaceEntity.defaultExecutionContext =
639
+ analysisResult.defaultExecutionContext;
640
+ dataspaceEntity.title = analysisResult.title;
641
+ dataspaceEntity.description = analysisResult.description;
642
+
643
+ // fetch the PMCD based on the resolved mapping path
644
+ const resolvedMappingPath =
645
+ mappingPath ??
646
+ analysisResult.executionContexts.find(
647
+ (value) =>
648
+ value.name ===
649
+ (executionContext ?? analysisResult.defaultExecutionContext),
650
+ )?.mapping;
651
+ let pmcd;
652
+ if (resolvedMappingPath) {
653
+ const mappingModelCoverageAnalysisResult =
654
+ mappingModelCoveragePartitionMap.get(resolvedMappingPath);
655
+ pmcd = mappingModelCoverageAnalysisResult?.model;
656
+ }
657
+
658
+ // if there is a PMCD saved in metadata, we can build a minimal graph
659
+ if (pmcd && projectInfo) {
660
+ graphEntities = pmcd.elements
661
+ .concat(mappingModels)
662
+ .concat(runtimeModels)
663
+ .concat(dataspaceEntity)
664
+ // NOTE: if an element could be found in the graph already it means it comes from system
665
+ // so we could rid of it
666
+ .filter((el) => !graph.getNullableElement(el.path, false))
667
+ .map((el) => this.graphManager.elementProtocolToEntity(el));
668
+ await this.graphManager.buildGraph(
669
+ graph,
670
+ graphEntities,
671
+ ActionState.create(),
672
+ {
673
+ origin: new LegendSDLC(
674
+ projectInfo.groupId,
675
+ projectInfo.artifactId,
676
+ resolveVersion(projectInfo.versionId),
677
+ ),
678
+ },
679
+ graphReport,
680
+ );
681
+
682
+ // build extra function analysis info
683
+ if (entitiesWithClassifierRetriever) {
684
+ try {
685
+ await this.processFunctionForMinimalGraph(
686
+ entitiesWithClassifierRetriever,
687
+ graph,
688
+ result,
689
+ plugins,
690
+ );
691
+ } catch {
692
+ //do nothing
693
+ }
694
+ }
695
+ isMiniGraphSuccess = true;
696
+ } else {
697
+ const elements = analysisResult.model.elements
698
+ // NOTE: this is a temporary hack to fix a problem with data space analytics
699
+ // where the classes for properties are not properly surveyed
700
+ // We need to wait for the actual fix in backend to be merged and released
701
+ // See https://github.com/finos/legend-engine/pull/836
702
+ .concat(
703
+ uniq(
704
+ analysisResult.model.elements.flatMap((element) => {
705
+ if (element instanceof V1_Class) {
706
+ return element.derivedProperties
707
+ .map((prop) =>
708
+ V1_getFullReturnTypePath(prop.returnGenericType),
709
+ )
710
+ .concat(
711
+ element.properties.map((prop) =>
712
+ V1_getFullReturnTypePath(prop.genericType),
713
+ ),
714
+ );
715
+ }
716
+ return [];
717
+ }),
718
+ )
719
+ // make sure to not include types already returned by the analysis
720
+ .filter(
721
+ (path) =>
722
+ !analysisResult.model.elements
723
+ .map((el) => el.path)
724
+ .includes(path),
725
+ )
726
+ .map((path) => {
727
+ const [pkgPath, name] = resolvePackagePathAndElementName(path);
728
+ if (!pkgPath) {
729
+ // exclude package-less elements (i.e. primitive types)
730
+ return undefined;
731
+ }
732
+ const _class = new V1_Class();
733
+ _class.name = name;
734
+ _class.package = pkgPath;
735
+ return _class;
736
+ })
737
+ .filter(isNonNullable),
738
+ )
739
+ .concat(mappingModels)
740
+ .concat(runtimeModels);
741
+ const alreadyContainsDataspace = elements.find(
742
+ (e) => e.path === dataspaceEntity.path,
743
+ );
744
+ let allElements = elements;
745
+ if (!alreadyContainsDataspace) {
746
+ allElements = elements.concat(dataspaceEntity);
747
+ }
748
+ // prepare the model context data
749
+ graphEntities = allElements
750
+ // NOTE: if an element could be found in the graph already it means it comes from system
751
+ // so we could rid of it
752
+ .filter((el) => !graph.getNullableElement(el.path, false))
753
+ .map((el) => this.graphManager.elementProtocolToEntity(el));
754
+
755
+ await this.graphManager.buildGraph(
756
+ graph,
757
+ graphEntities,
758
+ ActionState.create(),
759
+ );
760
+ }
407
761
 
408
762
  const mappingToMappingCoverageResult = new Map<
409
763
  string,
@@ -414,11 +768,27 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
414
768
  ([key, value]) => {
415
769
  mappingToMappingCoverageResult.set(
416
770
  key,
417
- V1_buildModelCoverageAnalysisResult(value, graph.getMapping(key)),
771
+ V1_buildModelCoverageAnalysisResult(
772
+ value,
773
+ this.graphManager,
774
+ graph.getMapping(key),
775
+ mappingModelCoveragePartitionMap.get(key)?.model,
776
+ ),
418
777
  );
419
778
  },
420
779
  );
421
780
  }
781
+ mappingAnalysisCoveragePartition.forEach((partition) => {
782
+ mappingToMappingCoverageResult.set(
783
+ partition.mapping,
784
+ V1_buildModelCoverageAnalysisResult(
785
+ partition.analysisResult,
786
+ this.graphManager,
787
+ graph.getMapping(partition.mapping),
788
+ mappingModelCoveragePartitionMap.get(partition.mapping)?.model,
789
+ ),
790
+ );
791
+ });
422
792
 
423
793
  // execution context
424
794
  result.executionContextsIndex = new Map<
@@ -455,7 +825,9 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
455
825
  context.mapping,
456
826
  V1_buildModelCoverageAnalysisResult(
457
827
  context.mappingModelCoverageAnalysisResult,
828
+ this.graphManager,
458
829
  contextAnalysisResult.mapping,
830
+ mappingModelCoveragePartitionMap.get(context.mapping)?.model,
459
831
  ),
460
832
  );
461
833
  }
@@ -586,7 +958,9 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
586
958
  });
587
959
 
588
960
  // diagrams
589
- result.diagrams = analysisResult.diagrams.map((diagramProtocol) => {
961
+ result.diagrams = (
962
+ buildMinimalGraph && isMiniGraphSuccess ? [] : analysisResult.diagrams
963
+ ).map((diagramProtocol) => {
590
964
  const diagram = new DataSpaceDiagramAnalysisResult();
591
965
  diagram.title = diagramProtocol.title;
592
966
  diagram.description = diagramProtocol.description;