@finos/legend-extension-dsl-data-space 10.3.85 → 10.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/DSL_DataSpace_LegendApplicationPlugin.d.ts +1 -1
- package/lib/components/DSL_DataSpace_LegendApplicationPlugin.d.ts.map +1 -1
- package/lib/components/DSL_DataSpace_LegendApplicationPlugin.js +4 -3
- package/lib/components/DSL_DataSpace_LegendApplicationPlugin.js.map +1 -1
- package/lib/components/query-builder/DataSpaceQueryBuilder.d.ts.map +1 -1
- package/lib/components/query-builder/DataSpaceQueryBuilder.js +20 -6
- package/lib/components/query-builder/DataSpaceQueryBuilder.js.map +1 -1
- package/lib/components/query-builder/DataSpaceQueryBuilderTemplateQueryPanelContent.js +1 -1
- package/lib/components/query-builder/DataSpaceQueryBuilderTemplateQueryPanelContent.js.map +1 -1
- package/lib/graph-manager/index.d.ts +1 -0
- package/lib/graph-manager/index.d.ts.map +1 -1
- package/lib/graph-manager/index.js +1 -0
- package/lib/graph-manager/index.js.map +1 -1
- package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.d.ts +6 -2
- package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.d.ts +15 -3
- package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.js +185 -48
- package/lib/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/query-builder/DataSpaceQueryBuilderState.d.ts +5 -11
- package/lib/stores/query-builder/DataSpaceQueryBuilderState.d.ts.map +1 -1
- package/lib/stores/query-builder/DataSpaceQueryBuilderState.js +19 -30
- package/lib/stores/query-builder/DataSpaceQueryBuilderState.js.map +1 -1
- package/package.json +7 -7
- package/src/components/DSL_DataSpace_LegendApplicationPlugin.tsx +6 -8
- package/src/components/query-builder/DataSpaceQueryBuilder.tsx +40 -9
- package/src/components/query-builder/DataSpaceQueryBuilderTemplateQueryPanelContent.tsx +1 -1
- package/src/graph-manager/index.ts +4 -0
- package/src/graph-manager/protocol/pure/DSL_DataSpace_PureGraphManagerExtension.ts +19 -1
- package/src/graph-manager/protocol/pure/v1/V1_DSL_DataSpace_PureGraphManagerExtension.ts +359 -79
- 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,13 @@ 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,
|
39
46
|
} from '@finos/legend-graph';
|
40
|
-
import type { Entity } from '@finos/legend-storage';
|
47
|
+
import type { Entity, ProjectGAVCoordinates } from '@finos/legend-storage';
|
41
48
|
import {
|
42
49
|
type PlainObject,
|
43
50
|
ActionState,
|
@@ -56,6 +63,7 @@ import {
|
|
56
63
|
} from '../../../../graph/metamodel/pure/model/packageableElements/dataSpace/DSL_DataSpace_DataSpace.js';
|
57
64
|
import {
|
58
65
|
V1_DataSpace,
|
66
|
+
V1_DataSpaceExecutionContext,
|
59
67
|
V1_DataSpaceSupportCombinedInfo,
|
60
68
|
V1_DataSpaceSupportEmail,
|
61
69
|
V1_DataSpaceTemplateExecutable,
|
@@ -96,6 +104,7 @@ import {
|
|
96
104
|
V1_DataSpaceFunctionPointerExecutableInfo,
|
97
105
|
} from './engine/analytics/V1_DataSpaceAnalysis.js';
|
98
106
|
import { getDiagram } from '@finos/legend-extension-dsl-diagram/graph';
|
107
|
+
import { resolveVersion } from '@finos/legend-server-depot';
|
99
108
|
|
100
109
|
const ANALYZE_DATA_SPACE_TRACE = 'analyze data space';
|
101
110
|
const TEMPORARY__TDS_SAMPLE_VALUES__DELIMETER = '-- e.g.';
|
@@ -219,6 +228,112 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
|
|
219
228
|
);
|
220
229
|
}
|
221
230
|
|
231
|
+
retrieveExecutionContextFromTemplateQueryId(
|
232
|
+
dataSpaceAnalysisResult: PlainObject<V1_DataSpaceAnalysisResult>,
|
233
|
+
templateQueryId: string,
|
234
|
+
plugins: PureProtocolProcessorPlugin[],
|
235
|
+
): string | undefined {
|
236
|
+
const analysisResult = V1_deserializeDataSpaceAnalysisResult(
|
237
|
+
dataSpaceAnalysisResult,
|
238
|
+
plugins,
|
239
|
+
);
|
240
|
+
let execContext = undefined;
|
241
|
+
const info = analysisResult.executables.find(
|
242
|
+
(ex) => ex.info?.id === templateQueryId,
|
243
|
+
)?.info;
|
244
|
+
if (info) {
|
245
|
+
execContext =
|
246
|
+
info.executionContextKey ?? analysisResult.defaultExecutionContext;
|
247
|
+
}
|
248
|
+
return execContext;
|
249
|
+
}
|
250
|
+
|
251
|
+
async analyzeDataSpaceCoverage(
|
252
|
+
dataSpacePath: string,
|
253
|
+
entitiesRetriever: () => Promise<Entity[]>,
|
254
|
+
entitiesWithClassifierRetriever: () => Promise<
|
255
|
+
[PlainObject<Entity>[], PlainObject<Entity>[]]
|
256
|
+
>,
|
257
|
+
cacheRetriever?: () => Promise<PlainObject<DataSpaceAnalysisResult>>,
|
258
|
+
actionState?: ActionState,
|
259
|
+
graphReport?: GraphManagerOperationReport | undefined,
|
260
|
+
pureGraph?: PureModel | undefined,
|
261
|
+
executionContext?: string | undefined,
|
262
|
+
mappingPath?: string | undefined,
|
263
|
+
projectInfo?: ProjectGAVCoordinates,
|
264
|
+
templateQueryId?: string,
|
265
|
+
): Promise<DataSpaceAnalysisResult> {
|
266
|
+
const cacheResult = cacheRetriever
|
267
|
+
? await this.fetchDataSpaceAnalysisFromCache(cacheRetriever, actionState)
|
268
|
+
: undefined;
|
269
|
+
const engineClient = guaranteeType(
|
270
|
+
this.graphManager.engine,
|
271
|
+
V1_RemoteEngine,
|
272
|
+
'analyzeDataSpaceCoverage is only supported by remote engine',
|
273
|
+
).getEngineServerClient();
|
274
|
+
let analysisResult: PlainObject<V1_DataSpaceAnalysisResult>;
|
275
|
+
let cachedAnalysisResult;
|
276
|
+
if (cacheResult) {
|
277
|
+
cachedAnalysisResult = V1_deserializeDataSpaceAnalysisResult(
|
278
|
+
cacheResult,
|
279
|
+
this.graphManager.pluginManager.getPureProtocolProcessorPlugins(),
|
280
|
+
);
|
281
|
+
}
|
282
|
+
if (
|
283
|
+
cacheResult &&
|
284
|
+
cachedAnalysisResult?.executionContexts.every(
|
285
|
+
(e) =>
|
286
|
+
e.mappingModelCoverageAnalysisResult?.model !== undefined ||
|
287
|
+
cachedAnalysisResult.mappingToMappingCoverageResult?.get(e.mapping)
|
288
|
+
?.model !== undefined,
|
289
|
+
)
|
290
|
+
) {
|
291
|
+
analysisResult = cacheResult;
|
292
|
+
} else {
|
293
|
+
actionState?.setMessage('Fetching project entities and dependencies...');
|
294
|
+
const entities = await entitiesRetriever();
|
295
|
+
actionState?.setMessage('Analyzing data space...');
|
296
|
+
analysisResult = await engineClient.postWithTracing<
|
297
|
+
PlainObject<V1_DataSpaceAnalysisResult>
|
298
|
+
>(
|
299
|
+
engineClient.getTraceData(ANALYZE_DATA_SPACE_TRACE),
|
300
|
+
`${engineClient._pure()}/analytics/dataSpace/coverage`,
|
301
|
+
{
|
302
|
+
clientVersion: V1_PureGraphManager.DEV_PROTOCOL_VERSION,
|
303
|
+
dataSpace: dataSpacePath,
|
304
|
+
model: {
|
305
|
+
_type: V1_PureModelContextType.DATA,
|
306
|
+
elements: entities.map((entity) => entity.content),
|
307
|
+
},
|
308
|
+
},
|
309
|
+
{},
|
310
|
+
undefined,
|
311
|
+
undefined,
|
312
|
+
{ enableCompression: true },
|
313
|
+
);
|
314
|
+
}
|
315
|
+
const plugins =
|
316
|
+
this.graphManager.pluginManager.getPureProtocolProcessorPlugins();
|
317
|
+
return this.buildDataSpaceAnalytics(
|
318
|
+
analysisResult,
|
319
|
+
plugins,
|
320
|
+
graphReport,
|
321
|
+
pureGraph,
|
322
|
+
executionContext
|
323
|
+
? executionContext
|
324
|
+
: templateQueryId
|
325
|
+
? this.retrieveExecutionContextFromTemplateQueryId(
|
326
|
+
analysisResult,
|
327
|
+
templateQueryId,
|
328
|
+
plugins,
|
329
|
+
)
|
330
|
+
: undefined,
|
331
|
+
mappingPath,
|
332
|
+
projectInfo,
|
333
|
+
entitiesWithClassifierRetriever,
|
334
|
+
);
|
335
|
+
}
|
336
|
+
|
222
337
|
async retrieveDataSpaceAnalysisFromCache(
|
223
338
|
cacheRetriever: () => Promise<PlainObject<DataSpaceAnalysisResult>>,
|
224
339
|
actionState?: ActionState,
|
@@ -255,11 +370,78 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
|
|
255
370
|
return cacheResult;
|
256
371
|
}
|
257
372
|
|
373
|
+
// build function analysis info by fetching functions within this project from metadata when building minimal graph
|
374
|
+
async processFunctionForMinimalGraph(
|
375
|
+
entitiesWithClassifierRetriever: () => Promise<
|
376
|
+
[PlainObject<Entity>[], PlainObject<Entity>[]]
|
377
|
+
>,
|
378
|
+
graph: PureModel,
|
379
|
+
dataSpaceAnalysisResult: DataSpaceAnalysisResult,
|
380
|
+
plugins: PureProtocolProcessorPlugin[],
|
381
|
+
): Promise<void> {
|
382
|
+
const [functionEntities, dependencyFunctionEntities]: [
|
383
|
+
PlainObject<Entity>[],
|
384
|
+
PlainObject<Entity>[],
|
385
|
+
] = await entitiesWithClassifierRetriever();
|
386
|
+
const functionProtocols = functionEntities.map((func) =>
|
387
|
+
guaranteeType(
|
388
|
+
V1_deserializePackageableElement(
|
389
|
+
(func.entity as Entity).content,
|
390
|
+
plugins,
|
391
|
+
),
|
392
|
+
V1_ConcreteFunctionDefinition,
|
393
|
+
),
|
394
|
+
);
|
395
|
+
const dependencyFunctionProtocols = dependencyFunctionEntities.map((func) =>
|
396
|
+
guaranteeType(
|
397
|
+
V1_deserializePackageableElement(
|
398
|
+
(func.entity as Entity).content,
|
399
|
+
plugins,
|
400
|
+
),
|
401
|
+
V1_ConcreteFunctionDefinition,
|
402
|
+
),
|
403
|
+
);
|
404
|
+
const functionInfos = V1_buildFunctionInfoAnalysis(
|
405
|
+
functionProtocols,
|
406
|
+
graph,
|
407
|
+
);
|
408
|
+
const dependencyFunctionInfos = V1_buildFunctionInfoAnalysis(
|
409
|
+
dependencyFunctionProtocols,
|
410
|
+
graph,
|
411
|
+
);
|
412
|
+
if (functionInfos.length > 0) {
|
413
|
+
const functionInfoMap = new Map<string, FunctionAnalysisInfo>();
|
414
|
+
functionInfos.forEach((funcInfo) => {
|
415
|
+
functionInfoMap.set(funcInfo.functionPath, funcInfo);
|
416
|
+
});
|
417
|
+
dataSpaceAnalysisResult.functionInfos = functionInfoMap;
|
418
|
+
}
|
419
|
+
if (dependencyFunctionInfos.length > 0) {
|
420
|
+
const dependencyFunctionInfoMap = new Map<string, FunctionAnalysisInfo>();
|
421
|
+
functionInfos.forEach((funcInfo) => {
|
422
|
+
dependencyFunctionInfoMap.set(funcInfo.functionPath, funcInfo);
|
423
|
+
});
|
424
|
+
dataSpaceAnalysisResult.dependencyFunctionInfos =
|
425
|
+
dependencyFunctionInfoMap;
|
426
|
+
}
|
427
|
+
}
|
428
|
+
|
258
429
|
async buildDataSpaceAnalytics(
|
259
|
-
|
430
|
+
analytics: PlainObject<V1_DataSpaceAnalysisResult>,
|
260
431
|
plugins: PureProtocolProcessorPlugin[],
|
432
|
+
graphReport?: GraphManagerOperationReport | undefined,
|
433
|
+
pureGraph?: PureModel | undefined,
|
434
|
+
executionContext?: string | undefined,
|
435
|
+
mappingPath?: string | undefined,
|
436
|
+
projectInfo?: ProjectGAVCoordinates,
|
437
|
+
entitiesWithClassifierRetriever?: () => Promise<
|
438
|
+
[PlainObject<Entity>[], PlainObject<Entity>[]]
|
439
|
+
>,
|
261
440
|
): Promise<DataSpaceAnalysisResult> {
|
262
|
-
const analysisResult = V1_deserializeDataSpaceAnalysisResult(
|
441
|
+
const analysisResult = V1_deserializeDataSpaceAnalysisResult(
|
442
|
+
analytics,
|
443
|
+
plugins,
|
444
|
+
);
|
263
445
|
const result = new DataSpaceAnalysisResult();
|
264
446
|
result.name = analysisResult.name;
|
265
447
|
result.package = analysisResult.package;
|
@@ -306,26 +488,30 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
|
|
306
488
|
// NOTE: we will relax the check and not throw here for unknown support info type
|
307
489
|
}
|
308
490
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
)
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
systemModel
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
491
|
+
let graphEntities;
|
492
|
+
let graph: PureModel;
|
493
|
+
let minialGraph = false;
|
494
|
+
if (pureGraph) {
|
495
|
+
graph = pureGraph;
|
496
|
+
} else {
|
497
|
+
// create an empty graph
|
498
|
+
const extensionElementClasses =
|
499
|
+
this.graphManager.pluginManager.getPureGraphPlugins();
|
500
|
+
const systemModel = new SystemModel(extensionElementClasses);
|
501
|
+
const coreModel = new CoreModel(extensionElementClasses);
|
502
|
+
await this.graphManager.buildSystem(
|
503
|
+
coreModel,
|
504
|
+
systemModel,
|
505
|
+
ActionState.create(),
|
506
|
+
{},
|
507
|
+
);
|
508
|
+
systemModel.initializeAutoImports();
|
509
|
+
graph = new PureModel(
|
510
|
+
coreModel,
|
511
|
+
systemModel,
|
512
|
+
this.graphManager.pluginManager.getPureGraphPlugins(),
|
513
|
+
);
|
514
|
+
}
|
329
515
|
// Create dummy mappings and runtimes
|
330
516
|
// TODO?: these stubbed mappings and runtimes are not really useful that useful, so either we should
|
331
517
|
// simplify the model here or potentially refactor the backend analytics endpoint to return these as model
|
@@ -355,55 +541,142 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
|
|
355
541
|
return runtime;
|
356
542
|
});
|
357
543
|
|
358
|
-
//
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
)
|
375
|
-
|
376
|
-
.
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
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(),
|
544
|
+
// The DataSpace entity is excluded from AnalyticsResult.Json to reduce the JSON size
|
545
|
+
// because all its information can be found in V1_DataSpaceAnalysisResult.
|
546
|
+
// Therefore, we are building a simple v1_DataSpace entity based on V1_DataSpaceAnalysisResult.
|
547
|
+
const dataspaceEntity = new V1_DataSpace();
|
548
|
+
dataspaceEntity.name = analysisResult.name;
|
549
|
+
dataspaceEntity.package = analysisResult.package;
|
550
|
+
dataspaceEntity.supportInfo = analysisResult.supportInfo;
|
551
|
+
dataspaceEntity.executionContexts = analysisResult.executionContexts.map(
|
552
|
+
(execContext) => {
|
553
|
+
const contextProtocol = new V1_DataSpaceExecutionContext();
|
554
|
+
contextProtocol.name = execContext.name;
|
555
|
+
contextProtocol.title = execContext.title;
|
556
|
+
contextProtocol.description = execContext.description;
|
557
|
+
contextProtocol.mapping = new V1_PackageableElementPointer(
|
558
|
+
PackageableElementPointerType.MAPPING,
|
559
|
+
execContext.mapping,
|
560
|
+
);
|
561
|
+
contextProtocol.defaultRuntime = new V1_PackageableElementPointer(
|
562
|
+
PackageableElementPointerType.RUNTIME,
|
563
|
+
execContext.defaultRuntime,
|
564
|
+
);
|
565
|
+
return contextProtocol;
|
566
|
+
},
|
406
567
|
);
|
568
|
+
dataspaceEntity.defaultExecutionContext =
|
569
|
+
analysisResult.defaultExecutionContext;
|
570
|
+
dataspaceEntity.title = analysisResult.title;
|
571
|
+
dataspaceEntity.description = analysisResult.description;
|
572
|
+
|
573
|
+
const resolvedMappingPath =
|
574
|
+
mappingPath ??
|
575
|
+
analysisResult.executionContexts.find(
|
576
|
+
(value) =>
|
577
|
+
value.name ===
|
578
|
+
(executionContext ?? analysisResult.defaultExecutionContext),
|
579
|
+
)?.mapping;
|
580
|
+
let pmcd;
|
581
|
+
if (resolvedMappingPath) {
|
582
|
+
const mappingModelCoverageAnalysisResult =
|
583
|
+
analysisResult.mappingToMappingCoverageResult?.get(resolvedMappingPath);
|
584
|
+
pmcd = mappingModelCoverageAnalysisResult?.model;
|
585
|
+
}
|
586
|
+
if (pmcd && projectInfo) {
|
587
|
+
graphEntities = pmcd.elements
|
588
|
+
.concat(mappingModels)
|
589
|
+
.concat(runtimeModels)
|
590
|
+
.concat(dataspaceEntity)
|
591
|
+
// NOTE: if an element could be found in the graph already it means it comes from system
|
592
|
+
// so we could rid of it
|
593
|
+
.filter((el) => !graph.getNullableElement(el.path, false))
|
594
|
+
.map((el) => this.graphManager.elementProtocolToEntity(el));
|
595
|
+
await this.graphManager.buildGraph(
|
596
|
+
graph,
|
597
|
+
graphEntities,
|
598
|
+
ActionState.create(),
|
599
|
+
{
|
600
|
+
origin: new LegendSDLC(
|
601
|
+
projectInfo.groupId,
|
602
|
+
projectInfo.artifactId,
|
603
|
+
resolveVersion(projectInfo.versionId),
|
604
|
+
),
|
605
|
+
},
|
606
|
+
graphReport,
|
607
|
+
);
|
608
|
+
if (entitiesWithClassifierRetriever) {
|
609
|
+
try {
|
610
|
+
await this.processFunctionForMinimalGraph(
|
611
|
+
entitiesWithClassifierRetriever,
|
612
|
+
graph,
|
613
|
+
result,
|
614
|
+
plugins,
|
615
|
+
);
|
616
|
+
} catch {
|
617
|
+
//do nothing
|
618
|
+
}
|
619
|
+
}
|
620
|
+
minialGraph = true;
|
621
|
+
} else {
|
622
|
+
const elements = analysisResult.model.elements
|
623
|
+
// NOTE: this is a temporary hack to fix a problem with data space analytics
|
624
|
+
// where the classes for properties are not properly surveyed
|
625
|
+
// We need to wait for the actual fix in backend to be merged and released
|
626
|
+
// See https://github.com/finos/legend-engine/pull/836
|
627
|
+
.concat(
|
628
|
+
uniq(
|
629
|
+
analysisResult.model.elements.flatMap((element) => {
|
630
|
+
if (element instanceof V1_Class) {
|
631
|
+
return element.derivedProperties
|
632
|
+
.map((prop) => prop.returnType)
|
633
|
+
.concat(element.properties.map((prop) => prop.type));
|
634
|
+
}
|
635
|
+
return [];
|
636
|
+
}),
|
637
|
+
)
|
638
|
+
// make sure to not include types already returned by the analysis
|
639
|
+
.filter(
|
640
|
+
(path) =>
|
641
|
+
!analysisResult.model.elements
|
642
|
+
.map((el) => el.path)
|
643
|
+
.includes(path),
|
644
|
+
)
|
645
|
+
.map((path) => {
|
646
|
+
const [pkgPath, name] = resolvePackagePathAndElementName(path);
|
647
|
+
if (!pkgPath) {
|
648
|
+
// exclude package-less elements (i.e. primitive types)
|
649
|
+
return undefined;
|
650
|
+
}
|
651
|
+
const _class = new V1_Class();
|
652
|
+
_class.name = name;
|
653
|
+
_class.package = pkgPath;
|
654
|
+
return _class;
|
655
|
+
})
|
656
|
+
.filter(isNonNullable),
|
657
|
+
)
|
658
|
+
.concat(mappingModels)
|
659
|
+
.concat(runtimeModels);
|
660
|
+
const alreadyContainsDataspace = elements.find(
|
661
|
+
(e) => e.path === dataspaceEntity.path,
|
662
|
+
);
|
663
|
+
let allElements = elements;
|
664
|
+
if (!alreadyContainsDataspace) {
|
665
|
+
allElements = elements.concat(dataspaceEntity);
|
666
|
+
}
|
667
|
+
// prepare the model context data
|
668
|
+
graphEntities = allElements
|
669
|
+
// NOTE: if an element could be found in the graph already it means it comes from system
|
670
|
+
// so we could rid of it
|
671
|
+
.filter((el) => !graph.getNullableElement(el.path, false))
|
672
|
+
.map((el) => this.graphManager.elementProtocolToEntity(el));
|
673
|
+
|
674
|
+
await this.graphManager.buildGraph(
|
675
|
+
graph,
|
676
|
+
graphEntities,
|
677
|
+
ActionState.create(),
|
678
|
+
);
|
679
|
+
}
|
407
680
|
|
408
681
|
const mappingToMappingCoverageResult = new Map<
|
409
682
|
string,
|
@@ -414,7 +687,11 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
|
|
414
687
|
([key, value]) => {
|
415
688
|
mappingToMappingCoverageResult.set(
|
416
689
|
key,
|
417
|
-
V1_buildModelCoverageAnalysisResult(
|
690
|
+
V1_buildModelCoverageAnalysisResult(
|
691
|
+
value,
|
692
|
+
this.graphManager,
|
693
|
+
graph.getMapping(key),
|
694
|
+
),
|
418
695
|
);
|
419
696
|
},
|
420
697
|
);
|
@@ -455,6 +732,7 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
|
|
455
732
|
context.mapping,
|
456
733
|
V1_buildModelCoverageAnalysisResult(
|
457
734
|
context.mappingModelCoverageAnalysisResult,
|
735
|
+
this.graphManager,
|
458
736
|
contextAnalysisResult.mapping,
|
459
737
|
),
|
460
738
|
);
|
@@ -586,13 +864,15 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
|
|
586
864
|
});
|
587
865
|
|
588
866
|
// diagrams
|
589
|
-
result.diagrams = analysisResult.diagrams.map(
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
867
|
+
result.diagrams = (minialGraph ? [] : analysisResult.diagrams).map(
|
868
|
+
(diagramProtocol) => {
|
869
|
+
const diagram = new DataSpaceDiagramAnalysisResult();
|
870
|
+
diagram.title = diagramProtocol.title;
|
871
|
+
diagram.description = diagramProtocol.description;
|
872
|
+
diagram.diagram = getDiagram(diagramProtocol.diagram, graph);
|
873
|
+
return diagram;
|
874
|
+
},
|
875
|
+
);
|
596
876
|
|
597
877
|
// executables
|
598
878
|
result.executables = analysisResult.executables.map(
|
@@ -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
|
-
|
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
|
-
|
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():
|