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