@finos/legend-graph 10.0.0 → 10.1.0

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 (43) hide show
  1. package/lib/DSLMapping_Exports.d.ts +4 -0
  2. package/lib/DSLMapping_Exports.d.ts.map +1 -1
  3. package/lib/DSLMapping_Exports.js +4 -0
  4. package/lib/DSLMapping_Exports.js.map +1 -1
  5. package/lib/DSLService_Exports.d.ts +3 -0
  6. package/lib/DSLService_Exports.d.ts.map +1 -1
  7. package/lib/DSLService_Exports.js +3 -0
  8. package/lib/DSLService_Exports.js.map +1 -1
  9. package/lib/graph/PureGraphPlugin.d.ts +1 -1
  10. package/lib/graph/PureGraphPlugin.js +1 -1
  11. package/lib/graphManager/AbstractPureGraphManager.d.ts +7 -6
  12. package/lib/graphManager/AbstractPureGraphManager.d.ts.map +1 -1
  13. package/lib/graphManager/AbstractPureGraphManager.js +13 -0
  14. package/lib/graphManager/AbstractPureGraphManager.js.map +1 -1
  15. package/lib/graphManager/PureGraphManagerPlugin.d.ts +7 -4
  16. package/lib/graphManager/PureGraphManagerPlugin.d.ts.map +1 -1
  17. package/lib/graphManager/PureGraphManagerPlugin.js +1 -1
  18. package/lib/graphManager/PureGraphManagerPlugin.js.map +1 -1
  19. package/lib/index.d.ts +1 -1
  20. package/lib/index.d.ts.map +1 -1
  21. package/lib/index.js +1 -1
  22. package/lib/index.js.map +1 -1
  23. package/lib/models/protocols/pure/PureProtocolProcessorPlugin.d.ts +1 -1
  24. package/lib/models/protocols/pure/PureProtocolProcessorPlugin.js +1 -1
  25. package/lib/models/protocols/pure/v1/V1_PureGraphManager.d.ts +4 -4
  26. package/lib/models/protocols/pure/v1/V1_PureGraphManager.d.ts.map +1 -1
  27. package/lib/models/protocols/pure/v1/V1_PureGraphManager.js +41 -133
  28. package/lib/models/protocols/pure/v1/V1_PureGraphManager.js.map +1 -1
  29. package/lib/models/protocols/pure/v1/engine/V1_Engine.d.ts +1 -0
  30. package/lib/models/protocols/pure/v1/engine/V1_Engine.d.ts.map +1 -1
  31. package/lib/models/protocols/pure/v1/engine/V1_Engine.js +3 -0
  32. package/lib/models/protocols/pure/v1/engine/V1_Engine.js.map +1 -1
  33. package/lib/package.json +5 -1
  34. package/package.json +8 -4
  35. package/src/DSLMapping_Exports.ts +4 -0
  36. package/src/DSLService_Exports.ts +6 -0
  37. package/src/graph/PureGraphPlugin.ts +1 -1
  38. package/src/graphManager/AbstractPureGraphManager.ts +24 -18
  39. package/src/graphManager/PureGraphManagerPlugin.ts +18 -8
  40. package/src/index.ts +1 -0
  41. package/src/models/protocols/pure/PureProtocolProcessorPlugin.ts +1 -1
  42. package/src/models/protocols/pure/v1/V1_PureGraphManager.ts +169 -296
  43. package/src/models/protocols/pure/v1/engine/V1_Engine.ts +4 -0
@@ -37,11 +37,11 @@ import {
37
37
  StopWatch,
38
38
  filterByType,
39
39
  isNonNullable,
40
- guaranteeNonEmptyString,
41
40
  addUniqueEntry,
42
41
  uuid,
43
42
  deleteEntry,
44
43
  assertType,
44
+ uniq,
45
45
  } from '@finos/legend-shared';
46
46
  import type { TEMPORARY__AbstractEngineConfig } from '../../../../graphManager/action/TEMPORARY__AbstractEngineConfig.js';
47
47
  import {
@@ -51,10 +51,7 @@ import {
51
51
  type ExecutionOptions,
52
52
  } from '../../../../graphManager/AbstractPureGraphManager.js';
53
53
  import type { Mapping } from '../../../metamodels/pure/packageableElements/mapping/Mapping.js';
54
- import {
55
- type Runtime,
56
- EngineRuntime,
57
- } from '../../../metamodels/pure/packageableElements/runtime/Runtime.js';
54
+ import type { Runtime } from '../../../metamodels/pure/packageableElements/runtime/Runtime.js';
58
55
  import type {
59
56
  ImportConfigurationDescription,
60
57
  ImportMode,
@@ -82,7 +79,6 @@ import type { GenerationOutput } from '../../../../graphManager/action/generatio
82
79
  import type { ValueSpecification } from '../../../metamodels/pure/valueSpecification/ValueSpecification.js';
83
80
  import { ServiceExecutionMode } from '../../../../graphManager/action/service/ServiceExecutionMode.js';
84
81
  import {
85
- KeyedExecutionParameter,
86
82
  PureMultiExecution,
87
83
  PureSingleExecution,
88
84
  } from '../../../metamodels/pure/packageableElements/service/ServiceExecution.js';
@@ -173,7 +169,6 @@ import type { V1_Multiplicity } from './model/packageableElements/domain/V1_Mult
173
169
  import type { V1_RawVariable } from './model/rawValueSpecification/V1_RawVariable.js';
174
170
  import { V1_setupDatabaseSerialization } from './transformation/pureProtocol/serializationHelpers/V1_DatabaseSerializationHelper.js';
175
171
  import {
176
- V1_PACKAGEABLE_RUNTIME_ELEMENT_PROTOCOL_TYPE,
177
172
  V1_setupEngineRuntimeSerialization,
178
173
  V1_setupLegacyRuntimeSerialization,
179
174
  } from './transformation/pureProtocol/serializationHelpers/V1_RuntimeSerializationHelper.js';
@@ -221,23 +216,13 @@ import {
221
216
  PureClientVersion,
222
217
  SystemGraphBuilderError,
223
218
  } from '../../../../graphManager/GraphManagerUtils.js';
224
- import {
225
- PackageableElementExplicitReference,
226
- PackageableElementReference,
227
- } from '../../../metamodels/pure/packageableElements/PackageableElementReference.js';
219
+ import { PackageableElementReference } from '../../../metamodels/pure/packageableElements/PackageableElementReference.js';
228
220
  import type { GraphPluginManager } from '../../../../GraphPluginManager.js';
229
221
  import type { QuerySearchSpecification } from '../../../../graphManager/action/query/QuerySearchSpecification.js';
230
222
  import type { ExternalFormatDescription } from '../../../../graphManager/action/externalFormat/ExternalFormatDescription.js';
231
223
  import type { ConfigurationProperty } from '../../../metamodels/pure/packageableElements/fileGeneration/ConfigurationProperty.js';
232
224
  import { V1_ExternalFormatModelGenerationInput } from './engine/externalFormat/V1_ExternalFormatModelGeneration.js';
233
225
  import { GraphBuilderReport } from '../../../../graphManager/GraphBuilderReport.js';
234
- import {
235
- V1_PureMultiExecution,
236
- V1_PureSingleExecution,
237
- } from './model/packageableElements/service/V1_ServiceExecution.js';
238
- import { V1_MAPPING_ELEMENT_PROTOCOL_TYPE } from './transformation/pureProtocol/serializationHelpers/V1_MappingSerializationHelper.js';
239
- import { V1_SERVICE_ELEMENT_PROTOCOL_TYPE } from './transformation/pureProtocol/serializationHelpers/V1_ServiceSerializationHelper.js';
240
- import { MappingInclude } from '../../../metamodels/pure/packageableElements/mapping/MappingInclude.js';
241
226
  import type { ModelGenerationConfiguration } from '../../../ModelGenerationConfiguration.js';
242
227
  import type { MappingGeneration_PureProtocolProcessorPlugin_Extension } from '../MappingGeneration_PureProtocolProcessorPlugin_Extension.js';
243
228
  import type { Package } from '../../../metamodels/pure/packageableElements/domain/Package.js';
@@ -255,7 +240,6 @@ import {
255
240
  } from '../../../metamodels/pure/test/result/TestResult.js';
256
241
  import type { Service } from '../../../../DSLService_Exports.js';
257
242
  import type { Testable } from '../../../metamodels/pure/test/Testable.js';
258
- import { stub_RawLambda } from '../../../../graphManager/action/creation/RawValueSpecificationCreatorHelper.js';
259
243
  import {
260
244
  getNullableIDFromTestable,
261
245
  getNullableTestable,
@@ -266,9 +250,7 @@ import {
266
250
  type AtomicTest,
267
251
  TestSuite,
268
252
  } from '../../../metamodels/pure/test/Test.js';
269
- import { V1_getIncludedMappingPath } from './helper/V1_DSLMapping_Helper.js';
270
253
  import { pruneSourceInformation } from '../../../../MetaModelUtils.js';
271
- import { stub_Mapping } from '../../../../graphManager/action/creation/DSLMapping_ModelCreatorHelper.js';
272
254
  import {
273
255
  V1_buildModelCoverageAnalysisResult,
274
256
  V1_MappingModelCoverageAnalysisInput,
@@ -469,17 +451,23 @@ export interface V1_EngineSetupConfig {
469
451
  }
470
452
 
471
453
  export class V1_PureGraphManager extends AbstractPureGraphManager {
454
+ // Organizing these constants will help with configuring
455
+ // target protocol version in the future
456
+ // See https://github.com/finos/legend-studio/issues/475
457
+ private static readonly TARGET_PROTOCOL_VERSION = PureClientVersion.VX_X_X;
458
+
472
459
  engine: V1_Engine;
473
- extensions: V1_GraphBuilderExtensions;
460
+ graphBuilderExtensions: V1_GraphBuilderExtensions;
474
461
 
475
462
  constructor(pluginManager: GraphPluginManager, log: Log) {
476
463
  super(pluginManager, log);
477
464
  this.engine = new V1_Engine({}, log);
478
465
 
479
466
  // setup plugins
480
- this.extensions = new V1_GraphBuilderExtensions(
467
+ this.graphBuilderExtensions = new V1_GraphBuilderExtensions(
481
468
  this.pluginManager.getPureProtocolProcessorPlugins(),
482
469
  );
470
+
483
471
  // setup serialization plugins
484
472
  V1_setupPureModelContextDataSerialization(
485
473
  this.pluginManager.getPureProtocolProcessorPlugins(),
@@ -515,6 +503,10 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
515
503
  await this.engine.setup(config);
516
504
  }
517
505
 
506
+ getSupportedProtocolVersion(): string {
507
+ return PureClientVersion.V1_0_0;
508
+ }
509
+
518
510
  // --------------------------------------------- Graph Builder ---------------------------------------------
519
511
 
520
512
  async buildSystem(
@@ -552,7 +544,11 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
552
544
  const buildInputs = [
553
545
  {
554
546
  model: systemModel,
555
- data: indexPureModelContextData(report, systemData, this.extensions),
547
+ data: indexPureModelContextData(
548
+ report,
549
+ systemData,
550
+ this.graphBuilderExtensions,
551
+ ),
556
552
  },
557
553
  ];
558
554
 
@@ -634,7 +630,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
634
630
  data: indexPureModelContextData(
635
631
  report,
636
632
  dependencyData,
637
- this.extensions,
633
+ this.graphBuilderExtensions,
638
634
  ),
639
635
  }));
640
636
 
@@ -693,7 +689,11 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
693
689
  const buildInputs: V1_GraphBuilderInput[] = [
694
690
  {
695
691
  model: graph,
696
- data: indexPureModelContextData(report, data, this.extensions),
692
+ data: indexPureModelContextData(
693
+ report,
694
+ data,
695
+ this.graphBuilderExtensions,
696
+ ),
697
697
  },
698
698
  ];
699
699
 
@@ -776,7 +776,11 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
776
776
  generatedDataMap.entries(),
777
777
  ).map(([generationParentPath, generatedData]) => ({
778
778
  model: generatedModel,
779
- data: indexPureModelContextData(report, generatedData, this.extensions),
779
+ data: indexPureModelContextData(
780
+ report,
781
+ generatedData,
782
+ this.graphBuilderExtensions,
783
+ ),
780
784
  }));
781
785
 
782
786
  // build
@@ -884,7 +888,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
884
888
  return new V1_GraphBuilderContextBuilder(
885
889
  graph,
886
890
  currentSubGraph,
887
- this.extensions,
891
+ this.graphBuilderExtensions,
888
892
  this.log,
889
893
  options,
890
894
  )
@@ -932,23 +936,24 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
932
936
  ),
933
937
  );
934
938
  await Promise.all(
935
- this.extensions.sortedExtraElementBuilders.flatMap(async (builder) =>
936
- (input.data.otherElementsByBuilder.get(builder) ?? []).map(
937
- (element) =>
938
- this.visitWithGraphBuilderErrorHandling(
939
- element,
940
- new V1_ProtocolToMetaModelGraphFirstPassBuilder(
941
- this.getBuilderContext(
942
- graph,
943
- input.model,
944
- element,
945
- options,
939
+ this.graphBuilderExtensions.sortedExtraElementBuilders.flatMap(
940
+ async (builder) =>
941
+ (input.data.otherElementsByBuilder.get(builder) ?? []).map(
942
+ (element) =>
943
+ this.visitWithGraphBuilderErrorHandling(
944
+ element,
945
+ new V1_ProtocolToMetaModelGraphFirstPassBuilder(
946
+ this.getBuilderContext(
947
+ graph,
948
+ input.model,
949
+ element,
950
+ options,
951
+ ),
952
+ packageCache,
953
+ elementPathCache,
946
954
  ),
947
- packageCache,
948
- elementPathCache,
949
955
  ),
950
- ),
951
- ),
956
+ ),
952
957
  ),
953
958
  );
954
959
  }),
@@ -1317,80 +1322,82 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
1317
1322
  options?: GraphBuilderOptions,
1318
1323
  ): Promise<void> {
1319
1324
  await Promise.all(
1320
- this.extensions.sortedExtraElementBuilders.map(async (builder) => {
1321
- await Promise.all(
1322
- inputs.flatMap((input) =>
1323
- (input.data.otherElementsByBuilder.get(builder) ?? []).map(
1324
- (element) =>
1325
- this.visitWithGraphBuilderErrorHandling(
1326
- element,
1327
- new V1_ProtocolToMetaModelGraphSecondPassBuilder(
1328
- this.getBuilderContext(
1329
- graph,
1330
- input.model,
1331
- element,
1332
- options,
1325
+ this.graphBuilderExtensions.sortedExtraElementBuilders.map(
1326
+ async (builder) => {
1327
+ await Promise.all(
1328
+ inputs.flatMap((input) =>
1329
+ (input.data.otherElementsByBuilder.get(builder) ?? []).map(
1330
+ (element) =>
1331
+ this.visitWithGraphBuilderErrorHandling(
1332
+ element,
1333
+ new V1_ProtocolToMetaModelGraphSecondPassBuilder(
1334
+ this.getBuilderContext(
1335
+ graph,
1336
+ input.model,
1337
+ element,
1338
+ options,
1339
+ ),
1333
1340
  ),
1334
1341
  ),
1335
- ),
1342
+ ),
1336
1343
  ),
1337
- ),
1338
- );
1339
- await Promise.all(
1340
- inputs.flatMap((input) =>
1341
- (input.data.otherElementsByBuilder.get(builder) ?? []).map(
1342
- (element) =>
1343
- this.visitWithGraphBuilderErrorHandling(
1344
- element,
1345
- new V1_ProtocolToMetaModelGraphThirdPassBuilder(
1346
- this.getBuilderContext(
1347
- graph,
1348
- input.model,
1349
- element,
1350
- options,
1344
+ );
1345
+ await Promise.all(
1346
+ inputs.flatMap((input) =>
1347
+ (input.data.otherElementsByBuilder.get(builder) ?? []).map(
1348
+ (element) =>
1349
+ this.visitWithGraphBuilderErrorHandling(
1350
+ element,
1351
+ new V1_ProtocolToMetaModelGraphThirdPassBuilder(
1352
+ this.getBuilderContext(
1353
+ graph,
1354
+ input.model,
1355
+ element,
1356
+ options,
1357
+ ),
1351
1358
  ),
1352
1359
  ),
1353
- ),
1360
+ ),
1354
1361
  ),
1355
- ),
1356
- );
1357
- await Promise.all(
1358
- inputs.flatMap((input) =>
1359
- (input.data.otherElementsByBuilder.get(builder) ?? []).map(
1360
- (element) =>
1361
- this.visitWithGraphBuilderErrorHandling(
1362
- element,
1363
- new V1_ProtocolToMetaModelGraphFourthPassBuilder(
1364
- this.getBuilderContext(
1365
- graph,
1366
- input.model,
1367
- element,
1368
- options,
1362
+ );
1363
+ await Promise.all(
1364
+ inputs.flatMap((input) =>
1365
+ (input.data.otherElementsByBuilder.get(builder) ?? []).map(
1366
+ (element) =>
1367
+ this.visitWithGraphBuilderErrorHandling(
1368
+ element,
1369
+ new V1_ProtocolToMetaModelGraphFourthPassBuilder(
1370
+ this.getBuilderContext(
1371
+ graph,
1372
+ input.model,
1373
+ element,
1374
+ options,
1375
+ ),
1369
1376
  ),
1370
1377
  ),
1371
- ),
1378
+ ),
1372
1379
  ),
1373
- ),
1374
- );
1375
- await Promise.all(
1376
- inputs.flatMap((input) =>
1377
- (input.data.otherElementsByBuilder.get(builder) ?? []).map(
1378
- (element) =>
1379
- this.visitWithGraphBuilderErrorHandling(
1380
- element,
1381
- new V1_ProtocolToMetaModelGraphFifthPassBuilder(
1382
- this.getBuilderContext(
1383
- graph,
1384
- input.model,
1385
- element,
1386
- options,
1380
+ );
1381
+ await Promise.all(
1382
+ inputs.flatMap((input) =>
1383
+ (input.data.otherElementsByBuilder.get(builder) ?? []).map(
1384
+ (element) =>
1385
+ this.visitWithGraphBuilderErrorHandling(
1386
+ element,
1387
+ new V1_ProtocolToMetaModelGraphFifthPassBuilder(
1388
+ this.getBuilderContext(
1389
+ graph,
1390
+ input.model,
1391
+ element,
1392
+ options,
1393
+ ),
1387
1394
  ),
1388
1395
  ),
1389
- ),
1396
+ ),
1390
1397
  ),
1391
- ),
1392
- );
1393
- }),
1398
+ );
1399
+ },
1400
+ ),
1394
1401
  );
1395
1402
  }
1396
1403
 
@@ -1751,7 +1758,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
1751
1758
  new V1_GraphBuilderContextBuilder(
1752
1759
  graph,
1753
1760
  graph,
1754
- this.extensions,
1761
+ this.graphBuilderExtensions,
1755
1762
  this.log,
1756
1763
  ).build(),
1757
1764
  );
@@ -1778,7 +1785,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
1778
1785
  new V1_GraphBuilderContextBuilder(
1779
1786
  graph,
1780
1787
  graph,
1781
- this.extensions,
1788
+ this.graphBuilderExtensions,
1782
1789
  this.log,
1783
1790
  ).build(),
1784
1791
  ),
@@ -1923,21 +1930,23 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
1923
1930
  (element) => element.V1_getExtraExecutionInputCollectors?.() ?? [],
1924
1931
  )
1925
1932
  .flatMap((getter) => getter(graph, mapping, runtime, graphData));
1926
- prunedGraphData.elements = graphData.elements
1927
- .filter(
1928
- (element) =>
1929
- element instanceof V1_Class ||
1930
- element instanceof V1_Enumeration ||
1931
- element instanceof V1_Profile ||
1932
- element instanceof V1_Association ||
1933
- element instanceof V1_ConcreteFunctionDefinition ||
1934
- element instanceof V1_Measure ||
1935
- element instanceof V1_Store ||
1936
- element instanceof V1_PackageableConnection ||
1937
- element instanceof V1_PackageableRuntime ||
1938
- element instanceof V1_Mapping,
1939
- )
1940
- .concat(extraExecutionElements);
1933
+ prunedGraphData.elements = uniq(
1934
+ graphData.elements
1935
+ .filter(
1936
+ (element) =>
1937
+ element instanceof V1_Class ||
1938
+ element instanceof V1_Enumeration ||
1939
+ element instanceof V1_Profile ||
1940
+ element instanceof V1_Association ||
1941
+ element instanceof V1_ConcreteFunctionDefinition ||
1942
+ element instanceof V1_Measure ||
1943
+ element instanceof V1_Store ||
1944
+ element instanceof V1_PackageableConnection ||
1945
+ element instanceof V1_PackageableRuntime ||
1946
+ element instanceof V1_Mapping,
1947
+ )
1948
+ .concat(extraExecutionElements),
1949
+ );
1941
1950
  // NOTE: for execution, we usually will just assume that we send the connections embedded in the runtime value, since we don't want the user to have to create
1942
1951
  // packageable runtime and connection just to play with execution.
1943
1952
  executeInput.clientVersion = clientVersion;
@@ -1973,7 +1982,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
1973
1982
  mapping,
1974
1983
  lambda,
1975
1984
  runtime,
1976
- PureClientVersion.VX_X_X,
1985
+ V1_PureGraphManager.TARGET_PROTOCOL_VERSION,
1977
1986
  ),
1978
1987
  options,
1979
1988
  ),
@@ -1997,7 +2006,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
1997
2006
  mapping,
1998
2007
  lambda,
1999
2008
  runtime,
2000
- PureClientVersion.VX_X_X,
2009
+ V1_PureGraphManager.TARGET_PROTOCOL_VERSION,
2001
2010
  testDataGenerationExecuteInput,
2002
2011
  );
2003
2012
  testDataGenerationExecuteInput.parameters = parameters;
@@ -2019,7 +2028,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2019
2028
  mapping,
2020
2029
  lambda,
2021
2030
  runtime,
2022
- PureClientVersion.VX_X_X,
2031
+ V1_PureGraphManager.TARGET_PROTOCOL_VERSION,
2023
2032
  ),
2024
2033
  );
2025
2034
  }
@@ -2036,7 +2045,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2036
2045
  mapping,
2037
2046
  lambda,
2038
2047
  runtime,
2039
- PureClientVersion.VX_X_X,
2048
+ V1_PureGraphManager.TARGET_PROTOCOL_VERSION,
2040
2049
  ),
2041
2050
  );
2042
2051
  return {
@@ -2054,7 +2063,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2054
2063
  new V1_GraphBuilderContextBuilder(
2055
2064
  graph,
2056
2065
  graph,
2057
- this.extensions,
2066
+ this.graphBuilderExtensions,
2058
2067
  this.log,
2059
2068
  ).build(),
2060
2069
  );
@@ -2225,17 +2234,14 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2225
2234
  V1_transformQuerySearchSpecification(searchSpecification),
2226
2235
  )
2227
2236
  ).map((protocol) =>
2228
- V1_buildLightQuery(
2229
- protocol,
2230
- this.engine.getEngineServerClient().currentUserId,
2231
- ),
2237
+ V1_buildLightQuery(protocol, this.engine.getCurrentUserId()),
2232
2238
  );
2233
2239
  }
2234
2240
 
2235
2241
  async getLightQuery(queryId: string): Promise<LightQuery> {
2236
2242
  return V1_buildLightQuery(
2237
2243
  await this.engine.getQuery(queryId),
2238
- this.engine.getEngineServerClient().currentUserId,
2244
+ this.engine.getCurrentUserId(),
2239
2245
  );
2240
2246
  }
2241
2247
 
@@ -2279,7 +2285,11 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2279
2285
  const dependencyGraphBuilderInput: V1_GraphBuilderInput[] = Array.from(
2280
2286
  dependencyDataMap.entries(),
2281
2287
  ).map(([dependencyKey, dependencyData]) => ({
2282
- data: indexPureModelContextData(report, dependencyData, this.extensions),
2288
+ data: indexPureModelContextData(
2289
+ report,
2290
+ dependencyData,
2291
+ this.graphBuilderExtensions,
2292
+ ),
2283
2293
  model: graph.dependencyManager.getModel(dependencyKey),
2284
2294
  }));
2285
2295
  // build main pmcd
@@ -2292,7 +2302,11 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2292
2302
  const mainGraphBuilderInput: V1_GraphBuilderInput[] = [
2293
2303
  {
2294
2304
  model: graph,
2295
- data: indexPureModelContextData(report, data, this.extensions),
2305
+ data: indexPureModelContextData(
2306
+ report,
2307
+ data,
2308
+ this.graphBuilderExtensions,
2309
+ ),
2296
2310
  },
2297
2311
  ];
2298
2312
  const graphBuilderInput = [
@@ -2303,157 +2317,13 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2303
2317
  return graphBuilderInput;
2304
2318
  }
2305
2319
 
2306
- // We could optimize this further by omitting parts of the entities we don't need
2307
- async buildGraphForCreateQuerySetup(
2308
- graph: PureModel,
2309
- entities: Entity[],
2310
- dependencyEntities: Map<string, Entity[]>,
2311
- ): Promise<void> {
2312
- try {
2313
- const graphBuilderInput = await this.indexEntitiesWithDependencyIntoGraph(
2314
- graph,
2315
- entities,
2316
- dependencyEntities,
2317
- (entity: Entity): boolean =>
2318
- ((entity.content as PlainObject<V1_PackageableElement>)
2319
- ._type as string) === V1_MAPPING_ELEMENT_PROTOCOL_TYPE ||
2320
- ((entity.content as PlainObject<V1_PackageableElement>)
2321
- ._type as string) === V1_PACKAGEABLE_RUNTIME_ELEMENT_PROTOCOL_TYPE,
2322
- );
2323
- // handle mapping includes
2324
- const mappings = [
2325
- ...graph.ownMappings,
2326
- ...graph.dependencyManager.mappings,
2327
- ];
2328
- const v1Mappings = graphBuilderInput
2329
- .map((e) => e.data.elements.filter(filterByType(V1_Mapping)))
2330
- .flat();
2331
- const context = new V1_GraphBuilderContextBuilder(
2332
- graph,
2333
- graph,
2334
- this.extensions,
2335
- this.log,
2336
- ).build();
2337
- // build include index for compatible runtime analysis
2338
- v1Mappings.forEach((element) => {
2339
- const mapping = mappings.find((e) => e.path === element.path);
2340
- if (mapping) {
2341
- mapping.includes = element.includedMappings.map(
2342
- (i) =>
2343
- new MappingInclude(
2344
- mapping,
2345
- context.resolveMapping(
2346
- guaranteeNonEmptyString(
2347
- V1_getIncludedMappingPath(i),
2348
- `Mapping include path is missing or empty`,
2349
- ),
2350
- ),
2351
- ),
2352
- );
2353
- }
2354
- });
2355
- // handle runtimes
2356
- const runtimes = [
2357
- ...graph.ownRuntimes,
2358
- ...graph.dependencyManager.runtimes,
2359
- ];
2360
- const v1Runtimes = graphBuilderInput
2361
- .map((e) => e.data.elements.filter(filterByType(V1_PackageableRuntime)))
2362
- .flat();
2363
- v1Runtimes.forEach((element) => {
2364
- const runtime = runtimes.find((e) => e.path === element.path);
2365
- if (runtime) {
2366
- const runtimeValue = new EngineRuntime();
2367
- runtime.runtimeValue = runtimeValue;
2368
- runtimeValue.mappings = element.runtimeValue.mappings.map((mapping) =>
2369
- context.resolveMapping(mapping.path),
2370
- );
2371
- }
2372
- });
2373
- } catch (error) {
2374
- assertErrorThrown(error);
2375
- /**
2376
- * Wrap all error with `GraphBuilderError`, as we throw a lot of assertion error in the graph builder
2377
- * But we might want to rethink this decision in the future and throw appropriate type of error
2378
- */
2379
- throw error instanceof GraphBuilderError
2380
- ? error
2381
- : new GraphBuilderError(error);
2382
- }
2383
- }
2384
-
2385
- // We could optimize this further by omitting parts of the entities we don't need
2386
- // i.e service entity would only keep execution
2387
- async buildGraphForServiceQuerySetup(
2388
- graph: PureModel,
2389
- entities: Entity[],
2390
- dependencyEntities: Map<string, Entity[]>,
2391
- ): Promise<void> {
2392
- try {
2393
- const graphBuilderInput = await this.indexEntitiesWithDependencyIntoGraph(
2394
- graph,
2395
- entities,
2396
- dependencyEntities,
2397
- (entity: Entity): boolean =>
2398
- ((entity.content as PlainObject<V1_PackageableElement>)
2399
- ._type as string) === V1_SERVICE_ELEMENT_PROTOCOL_TYPE,
2400
- );
2401
- // handle servicess
2402
- const services = [
2403
- ...graph.ownServices,
2404
- ...graph.dependencyManager.services,
2405
- ];
2406
- const v1Services = graphBuilderInput
2407
- .map((e) => e.data.elements.filter(filterByType(V1_Service)))
2408
- .flat();
2409
- // build service multi execution keys
2410
- v1Services.forEach((element) => {
2411
- const service = services.find((e) => e.path === element.path);
2412
- if (service) {
2413
- const serviceExecution = element.execution;
2414
- if (serviceExecution instanceof V1_PureMultiExecution) {
2415
- const execution = new PureMultiExecution(
2416
- serviceExecution.executionKey,
2417
- stub_RawLambda(),
2418
- service,
2419
- );
2420
- execution.executionParameters =
2421
- serviceExecution.executionParameters.map(
2422
- (keyedExecutionParameter) =>
2423
- new KeyedExecutionParameter(
2424
- keyedExecutionParameter.key,
2425
- PackageableElementExplicitReference.create(stub_Mapping()),
2426
- new EngineRuntime(),
2427
- ),
2428
- );
2429
- service.execution = execution;
2430
- } else if (serviceExecution instanceof V1_PureSingleExecution) {
2431
- service.execution = new PureSingleExecution(
2432
- stub_RawLambda(),
2433
- service,
2434
- PackageableElementExplicitReference.create(stub_Mapping()),
2435
- new EngineRuntime(),
2436
- );
2437
- }
2438
- }
2439
- });
2440
- } catch (error) {
2441
- assertErrorThrown(error);
2442
- /**
2443
- * Wrap all error with `GraphBuilderError`, as we throw a lot of assertion error in the graph builder
2444
- * But we might want to rethink this decision in the future and throw appropriate type of error
2445
- */
2446
- throw error instanceof GraphBuilderError
2447
- ? error
2448
- : new GraphBuilderError(error);
2449
- }
2450
- }
2320
+ // --------------------------------------------- Query ------------------------------------------------------
2451
2321
 
2452
2322
  async getQuery(queryId: string, graph: PureModel): Promise<Query> {
2453
2323
  return V1_buildQuery(
2454
2324
  await this.engine.getQuery(queryId),
2455
2325
  graph,
2456
- this.engine.getEngineServerClient().currentUserId,
2326
+ this.engine.getCurrentUserId(),
2457
2327
  );
2458
2328
  }
2459
2329
 
@@ -2465,7 +2335,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2465
2335
  return V1_buildQuery(
2466
2336
  await this.engine.createQuery(V1_transformQuery(query)),
2467
2337
  graph,
2468
- this.engine.getEngineServerClient().currentUserId,
2338
+ this.engine.getCurrentUserId(),
2469
2339
  );
2470
2340
  }
2471
2341
 
@@ -2473,7 +2343,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2473
2343
  return V1_buildQuery(
2474
2344
  await this.engine.updateQuery(V1_transformQuery(query)),
2475
2345
  graph,
2476
- this.engine.getEngineServerClient().currentUserId,
2346
+ this.engine.getCurrentUserId(),
2477
2347
  );
2478
2348
  }
2479
2349
 
@@ -2514,19 +2384,21 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2514
2384
  [],
2515
2385
  )
2516
2386
  .flatMap((getter) => getter(graph, graphData));
2517
- prunedGraphData.elements = this.getFullGraphModelData(graph)
2518
- .elements.filter(
2519
- (element) =>
2520
- element instanceof V1_Class ||
2521
- element instanceof V1_Enumeration ||
2522
- element instanceof V1_Profile ||
2523
- element instanceof V1_Association ||
2524
- element instanceof V1_ConcreteFunctionDefinition ||
2525
- element instanceof V1_Measure ||
2526
- element instanceof V1_Store ||
2527
- element instanceof V1_Mapping,
2528
- )
2529
- .concat(extraElements);
2387
+ prunedGraphData.elements = uniq(
2388
+ this.getFullGraphModelData(graph)
2389
+ .elements.filter(
2390
+ (element) =>
2391
+ element instanceof V1_Class ||
2392
+ element instanceof V1_Enumeration ||
2393
+ element instanceof V1_Profile ||
2394
+ element instanceof V1_Association ||
2395
+ element instanceof V1_ConcreteFunctionDefinition ||
2396
+ element instanceof V1_Measure ||
2397
+ element instanceof V1_Store ||
2398
+ element instanceof V1_Mapping,
2399
+ )
2400
+ .concat(extraElements),
2401
+ );
2530
2402
  return prunedGraphData;
2531
2403
  };
2532
2404
 
@@ -2536,7 +2408,8 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2536
2408
  ): Promise<MappingModelCoverageAnalysisResult> {
2537
2409
  const modelCoverageAnalysisInput =
2538
2410
  new V1_MappingModelCoverageAnalysisInput();
2539
- modelCoverageAnalysisInput.clientVersion = PureClientVersion.VX_X_X;
2411
+ modelCoverageAnalysisInput.clientVersion =
2412
+ V1_PureGraphManager.TARGET_PROTOCOL_VERSION;
2540
2413
  modelCoverageAnalysisInput.mapping = mapping.path;
2541
2414
  modelCoverageAnalysisInput.model =
2542
2415
  this.buildMappingModelCoverageAnalysisInputContextData(graph);