@finos/legend-graph 32.1.33 → 32.1.34

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.
@@ -76,6 +76,7 @@ import { INTERNAL__UnknownStore } from './metamodel/pure/packageableElements/sto
76
76
  import type { PureGraphPlugin } from './PureGraphPlugin.js';
77
77
  import { INTERNAL__UnknownElement } from './metamodel/pure/packageableElements/INTERNAL__UnknownElement.js';
78
78
  import { DataProduct } from './metamodel/pure/dataProduct/DataProduct.js';
79
+ import { IngestDefinition } from './metamodel/pure/packageableElements/ingest/IngestDefinition.js';
79
80
 
80
81
  const FORBIDDEN_EXTENSION_ELEMENT_CLASS = new Set([
81
82
  PackageableElement,
@@ -255,6 +256,12 @@ export abstract class BasicModel {
255
256
  get ownExecutionEnvironments(): ExecutionEnvironmentInstance[] {
256
257
  return Array.from(this.executionEnvironmentsIndex.values());
257
258
  }
259
+ get ownIngests(): IngestDefinition[] {
260
+ return Array.from(this.INTERNAL__unknownElementsIndex.values()).filter(
261
+ filterByType(IngestDefinition),
262
+ );
263
+ }
264
+
258
265
  get ownGenerationSpecifications(): GenerationSpecification[] {
259
266
  return Array.from(this.generationSpecificationsIndex.values());
260
267
  }
@@ -46,6 +46,7 @@ import { LegendSDLC, type GraphDataOrigin } from './GraphDataOrigin.js';
46
46
  import type { FunctionActivator } from './metamodel/pure/packageableElements/function/FunctionActivator.js';
47
47
  import type { PureGraphPlugin } from './PureGraphPlugin.js';
48
48
  import type { Testable } from './metamodel/pure/test/Testable.js';
49
+ import type { IngestDefinition } from './metamodel/pure/packageableElements/ingest/IngestDefinition.js';
49
50
 
50
51
  export const DEPENDENCY_ROOT_PACKAGE_PREFIX = '@dependency__';
51
52
  export const generateDependencyRootPackageName = (
@@ -306,6 +307,9 @@ export class DependencyManager {
306
307
  get executionEnvironments(): ExecutionEnvironmentInstance[] {
307
308
  return this.dependencyGraphs.flatMap((dep) => dep.ownExecutionEnvironments);
308
309
  }
310
+ get ingests(): IngestDefinition[] {
311
+ return this.dependencyGraphs.flatMap((dep) => dep.ownIngests);
312
+ }
309
313
 
310
314
  getExtensionElements<T extends PackageableElement>(
311
315
  extensionElementClass: Clazz<T>,
@@ -61,6 +61,7 @@ import type { SectionIndex } from '../graph/metamodel/pure/packageableElements/s
61
61
  import type { PropertyOwner } from './metamodel/pure/packageableElements/domain/AbstractProperty.js';
62
62
  import type { ExecutionEnvironmentInstance } from './metamodel/pure/packageableElements/service/ExecutionEnvironmentInstance.js';
63
63
  import { FunctionActivator } from './metamodel/pure/packageableElements/function/FunctionActivator.js';
64
+ import type { IngestDefinition } from './metamodel/pure/packageableElements/ingest/IngestDefinition.js';
64
65
 
65
66
  export interface GraphTextInputOption {
66
67
  graphGrammar: string | undefined;
@@ -353,6 +354,16 @@ export class PureModel extends BasicModel {
353
354
  ];
354
355
  }
355
356
 
357
+ get ingests(): IngestDefinition[] {
358
+ return [
359
+ ...this.coreModel.ownIngests,
360
+ ...this.systemModel.ownIngests,
361
+ ...this.dependencyManager.ingests,
362
+ ...this.ownIngests,
363
+ ...this.generationModel.ownIngests,
364
+ ];
365
+ }
366
+
356
367
  get allElements(): PackageableElement[] {
357
368
  return [
358
369
  ...this.coreModel.allOwnElements,
@@ -794,6 +794,13 @@ export abstract class AbstractPureGraphManager {
794
794
  },
795
795
  ): Entity;
796
796
 
797
+ abstract elementsToPureCode(
798
+ elements: PackageableElement[],
799
+ options?: {
800
+ pruneSourceInformation?: boolean;
801
+ },
802
+ ): Promise<string>;
803
+
797
804
  async createBasicGraph(options?: {
798
805
  initializeSystem?: boolean;
799
806
  }): Promise<PureModel> {
@@ -4224,6 +4224,23 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
4224
4224
  return entity;
4225
4225
  };
4226
4226
 
4227
+ override async elementsToPureCode(
4228
+ elements: PackageableElement[],
4229
+ options?: { pruneSourceInformation?: boolean; pretty?: boolean },
4230
+ ): Promise<string> {
4231
+ const graphData = new V1_PureModelContextData();
4232
+ graphData.elements = elements.map((element) =>
4233
+ this.elementToProtocol(element, {
4234
+ keepSourceInformation: !options?.pruneSourceInformation,
4235
+ }),
4236
+ );
4237
+ const jsonToGrammar = await this.engine.transformPureModelContextDataToCode(
4238
+ graphData,
4239
+ Boolean(options?.pretty),
4240
+ );
4241
+ return jsonToGrammar;
4242
+ }
4243
+
4227
4244
  private prunePureModelContextData = (
4228
4245
  data: V1_PureModelContextData,
4229
4246
  elementFilter?: (val: V1_PackageableElement) => boolean,