@finos/legend-graph 32.4.2 → 32.5.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 (122) hide show
  1. package/lib/graph/Core_HashUtils.d.ts +1 -0
  2. package/lib/graph/Core_HashUtils.d.ts.map +1 -1
  3. package/lib/graph/Core_HashUtils.js +1 -0
  4. package/lib/graph/Core_HashUtils.js.map +1 -1
  5. package/lib/graph/helpers/STO_Relational_Helper.d.ts +2 -0
  6. package/lib/graph/helpers/STO_Relational_Helper.d.ts.map +1 -1
  7. package/lib/graph/helpers/STO_Relational_Helper.js +37 -0
  8. package/lib/graph/helpers/STO_Relational_Helper.js.map +1 -1
  9. package/lib/graph/metamodel/pure/packageableElements/relation/Accessor.d.ts +61 -0
  10. package/lib/graph/metamodel/pure/packageableElements/relation/Accessor.d.ts.map +1 -0
  11. package/lib/graph/metamodel/pure/packageableElements/relation/Accessor.js +91 -0
  12. package/lib/graph/metamodel/pure/packageableElements/relation/Accessor.js.map +1 -0
  13. package/lib/graph/metamodel/pure/packageableElements/service/Service.d.ts +1 -0
  14. package/lib/graph/metamodel/pure/packageableElements/service/Service.d.ts.map +1 -1
  15. package/lib/graph/metamodel/pure/packageableElements/service/Service.js +2 -0
  16. package/lib/graph/metamodel/pure/packageableElements/service/Service.js.map +1 -1
  17. package/lib/graph/metamodel/pure/valueSpecification/ValueSpecification.d.ts +2 -0
  18. package/lib/graph/metamodel/pure/valueSpecification/ValueSpecification.d.ts.map +1 -1
  19. package/lib/graph/metamodel/pure/valueSpecification/ValueSpecification.js.map +1 -1
  20. package/lib/graph-manager/AbstractPureGraphManager.d.ts +6 -0
  21. package/lib/graph-manager/AbstractPureGraphManager.d.ts.map +1 -1
  22. package/lib/graph-manager/AbstractPureGraphManager.js.map +1 -1
  23. package/lib/graph-manager/action/changeDetection/DSL_Service_ObserverHelper.d.ts.map +1 -1
  24. package/lib/graph-manager/action/changeDetection/DSL_Service_ObserverHelper.js +1 -0
  25. package/lib/graph-manager/action/changeDetection/DSL_Service_ObserverHelper.js.map +1 -1
  26. package/lib/graph-manager/action/changeDetection/ValueSpecificationObserver.d.ts.map +1 -1
  27. package/lib/graph-manager/action/changeDetection/ValueSpecificationObserver.js +3 -0
  28. package/lib/graph-manager/action/changeDetection/ValueSpecificationObserver.js.map +1 -1
  29. package/lib/graph-manager/action/service/ServiceDetail.d.ts +54 -0
  30. package/lib/graph-manager/action/service/ServiceDetail.d.ts.map +1 -0
  31. package/lib/graph-manager/action/service/ServiceDetail.js +91 -0
  32. package/lib/graph-manager/action/service/ServiceDetail.js.map +1 -0
  33. package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.d.ts +6 -0
  34. package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.d.ts.map +1 -1
  35. package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.js +13 -0
  36. package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.js.map +1 -1
  37. package/lib/graph-manager/protocol/pure/v1/engine/V1_EngineServerClient.d.ts +3 -0
  38. package/lib/graph-manager/protocol/pure/v1/engine/V1_EngineServerClient.d.ts.map +1 -1
  39. package/lib/graph-manager/protocol/pure/v1/engine/V1_EngineServerClient.js +7 -0
  40. package/lib/graph-manager/protocol/pure/v1/engine/V1_EngineServerClient.js.map +1 -1
  41. package/lib/graph-manager/protocol/pure/v1/helpers/V1_AccessorHelper.d.ts +28 -0
  42. package/lib/graph-manager/protocol/pure/v1/helpers/V1_AccessorHelper.d.ts.map +1 -0
  43. package/lib/graph-manager/protocol/pure/v1/helpers/V1_AccessorHelper.js +104 -0
  44. package/lib/graph-manager/protocol/pure/v1/helpers/V1_AccessorHelper.js.map +1 -0
  45. package/lib/graph-manager/protocol/pure/v1/helpers/V1_ValueSpecificationObserver.d.ts +1 -1
  46. package/lib/graph-manager/protocol/pure/v1/helpers/V1_ValueSpecificationObserver.d.ts.map +1 -1
  47. package/lib/graph-manager/protocol/pure/v1/helpers/V1_ValueSpecificationObserver.js +3 -2
  48. package/lib/graph-manager/protocol/pure/v1/helpers/V1_ValueSpecificationObserver.js.map +1 -1
  49. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/ingest/V1_IngestDefinition.d.ts +11 -9
  50. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/ingest/V1_IngestDefinition.d.ts.map +1 -1
  51. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/ingest/V1_IngestDefinition.js +16 -0
  52. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/ingest/V1_IngestDefinition.js.map +1 -1
  53. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/service/V1_Service.d.ts +1 -0
  54. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/service/V1_Service.d.ts.map +1 -1
  55. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/service/V1_Service.js +2 -0
  56. package/lib/graph-manager/protocol/pure/v1/model/packageableElements/service/V1_Service.js.map +1 -1
  57. package/lib/graph-manager/protocol/pure/v1/model/valueSpecification/raw/classInstance/relation/V1_ColSpec.d.ts +3 -3
  58. package/lib/graph-manager/protocol/pure/v1/model/valueSpecification/raw/classInstance/relation/V1_ColSpec.d.ts.map +1 -1
  59. package/lib/graph-manager/protocol/pure/v1/model/valueSpecification/raw/classInstance/relation/V1_ColSpec.js.map +1 -1
  60. package/lib/graph-manager/protocol/pure/v1/model/valueSpecification/raw/classInstance/relation/V1_RelationStoreAccessor.d.ts +14 -4
  61. package/lib/graph-manager/protocol/pure/v1/model/valueSpecification/raw/classInstance/relation/V1_RelationStoreAccessor.d.ts.map +1 -1
  62. package/lib/graph-manager/protocol/pure/v1/model/valueSpecification/raw/classInstance/relation/V1_RelationStoreAccessor.js +21 -4
  63. package/lib/graph-manager/protocol/pure/v1/model/valueSpecification/raw/classInstance/relation/V1_RelationStoreAccessor.js.map +1 -1
  64. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_ServiceTransformer.d.ts.map +1 -1
  65. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_ServiceTransformer.js +6 -5
  66. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_ServiceTransformer.js.map +1 -1
  67. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_ValueSpecificationTransformer.d.ts.map +1 -1
  68. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_ValueSpecificationTransformer.js +30 -2
  69. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_ValueSpecificationTransformer.js.map +1 -1
  70. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.d.ts.map +1 -1
  71. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.js +1 -0
  72. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.js.map +1 -1
  73. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_ValueSpecificationBuilderHelper.d.ts.map +1 -1
  74. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_ValueSpecificationBuilderHelper.js +67 -1
  75. package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_ValueSpecificationBuilderHelper.js.map +1 -1
  76. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_IngestSerializationHelper.d.ts +5 -1
  77. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_IngestSerializationHelper.d.ts.map +1 -1
  78. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_IngestSerializationHelper.js +22 -2
  79. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_IngestSerializationHelper.js.map +1 -1
  80. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_ServiceSerializationHelper.d.ts.map +1 -1
  81. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_ServiceSerializationHelper.js +5 -4
  82. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_ServiceSerializationHelper.js.map +1 -1
  83. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_TypeSerializationHelper.d.ts +2 -1
  84. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_TypeSerializationHelper.d.ts.map +1 -1
  85. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_TypeSerializationHelper.js +1 -1
  86. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_TypeSerializationHelper.js.map +1 -1
  87. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_ValueSpecificationSerializer.d.ts.map +1 -1
  88. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_ValueSpecificationSerializer.js +16 -4
  89. package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_ValueSpecificationSerializer.js.map +1 -1
  90. package/lib/index.d.ts +8 -2
  91. package/lib/index.d.ts.map +1 -1
  92. package/lib/index.js +8 -2
  93. package/lib/index.js.map +1 -1
  94. package/lib/package.json +1 -1
  95. package/package.json +1 -1
  96. package/src/graph/Core_HashUtils.ts +1 -0
  97. package/src/graph/helpers/STO_Relational_Helper.ts +44 -0
  98. package/src/graph/metamodel/pure/packageableElements/relation/Accessor.ts +133 -0
  99. package/src/graph/metamodel/pure/packageableElements/service/Service.ts +2 -0
  100. package/src/graph/metamodel/pure/valueSpecification/ValueSpecification.ts +4 -0
  101. package/src/graph-manager/AbstractPureGraphManager.ts +13 -0
  102. package/src/graph-manager/action/changeDetection/DSL_Service_ObserverHelper.ts +1 -0
  103. package/src/graph-manager/action/changeDetection/ValueSpecificationObserver.ts +6 -0
  104. package/src/graph-manager/action/service/ServiceDetail.ts +133 -0
  105. package/src/graph-manager/protocol/pure/v1/V1_PureGraphManager.ts +31 -0
  106. package/src/graph-manager/protocol/pure/v1/engine/V1_EngineServerClient.ts +11 -0
  107. package/src/graph-manager/protocol/pure/v1/helpers/V1_AccessorHelper.ts +156 -0
  108. package/src/graph-manager/protocol/pure/v1/helpers/V1_ValueSpecificationObserver.ts +3 -3
  109. package/src/graph-manager/protocol/pure/v1/model/packageableElements/ingest/V1_IngestDefinition.ts +15 -11
  110. package/src/graph-manager/protocol/pure/v1/model/packageableElements/service/V1_Service.ts +2 -0
  111. package/src/graph-manager/protocol/pure/v1/model/valueSpecification/raw/classInstance/relation/V1_ColSpec.ts +3 -3
  112. package/src/graph-manager/protocol/pure/v1/model/valueSpecification/raw/classInstance/relation/V1_RelationStoreAccessor.ts +29 -4
  113. package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_ServiceTransformer.ts +8 -7
  114. package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_ValueSpecificationTransformer.ts +49 -2
  115. package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.ts +1 -0
  116. package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_ValueSpecificationBuilderHelper.ts +129 -0
  117. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_IngestSerializationHelper.ts +51 -1
  118. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_ServiceSerializationHelper.ts +5 -4
  119. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_TypeSerializationHelper.ts +1 -1
  120. package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_ValueSpecificationSerializer.ts +29 -3
  121. package/src/index.ts +31 -2
  122. package/tsconfig.json +3 -0
@@ -30,6 +30,7 @@ import type {
30
30
  } from './compilation/V1_LambdaReturnType.js';
31
31
  import type { V1_ServiceRegistrationResult } from './service/V1_ServiceRegistrationResult.js';
32
32
  import type { V1_ServiceConfigurationInfo } from './service/V1_ServiceConfiguration.js';
33
+ import { ServiceDetail } from '../../../../action/service/ServiceDetail.js';
33
34
  import type { V1_CompileResult } from './compilation/V1_CompileResult.js';
34
35
  import type { V1_RawLambda } from '../model/rawValueSpecification/V1_RawLambda.js';
35
36
  import type { V1_GenerateFileInput } from './generation/V1_FileGenerationInput.js';
@@ -1238,4 +1239,14 @@ export class V1_EngineServerClient extends AbstractServerClient {
1238
1239
  `${this._devMetadata()}`,
1239
1240
  request,
1240
1241
  );
1242
+
1243
+ // ------------------------------------------- Legend Services List -------------------------------------------
1244
+
1245
+ private readonly getServicesDetailsFromCache = (): Promise<PlainObject[]> =>
1246
+ this.get(`${this._service()}/list/detailsFromCache`);
1247
+
1248
+ getServicesInfo = async (): Promise<ServiceDetail[]> => {
1249
+ const raw = await this.getServicesDetailsFromCache();
1250
+ return raw.map((r) => ServiceDetail.fromJson(r));
1251
+ };
1241
1252
  }
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ type Accessor,
19
+ IngestionAccessor,
20
+ RelationalStoreAccessor,
21
+ type AccessorOwner,
22
+ } from '../../../../../graph/metamodel/pure/packageableElements/relation/Accessor.js';
23
+ import {
24
+ RelationType,
25
+ RelationColumn,
26
+ } from '../../../../../graph/metamodel/pure/packageableElements/relation/RelationType.js';
27
+ import { GenericType } from '../../../../../graph/metamodel/pure/packageableElements/domain/GenericType.js';
28
+ import { GenericTypeExplicitReference } from '../../../../../graph/metamodel/pure/packageableElements/domain/GenericTypeReference.js';
29
+ import { IngestDefinition } from '../../../../../graph/metamodel/pure/packageableElements/ingest/IngestDefinition.js';
30
+ import { Database } from '../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Database.js';
31
+ import { Column } from '../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Column.js';
32
+ import type { Table } from '../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Table.js';
33
+ import { mapRelationalDataTypeToPrimitiveType } from '../../../../../graph/helpers/STO_Relational_Helper.js';
34
+ import type { V1_IngestDataset } from '../model/packageableElements/ingest/V1_IngestDefinition.js';
35
+ import type { V1_GraphBuilderContext } from '../transformation/pureGraph/to/V1_GraphBuilderContext.js';
36
+ import { V1_GenericType as V1_GenericTypeProtocol } from '../model/packageableElements/type/V1_GenericType.js';
37
+ import { V1_PackageableType } from '../model/packageableElements/type/V1_PackageableType.js';
38
+ import { returnUndefOnError } from '@finos/legend-shared';
39
+ import { V1_deserializeIngestDefinitionContent } from '../transformation/pureProtocol/serializationHelpers/V1_IngestSerializationHelper.js';
40
+
41
+ const buildV1GenericType = (fullPath: string): V1_GenericTypeProtocol => {
42
+ // Strip package prefix — primitive types are indexed by simple name
43
+ const typeName = fullPath.includes('::')
44
+ ? fullPath.substring(fullPath.lastIndexOf('::') + 2)
45
+ : fullPath;
46
+ const rawType = new V1_PackageableType();
47
+ rawType.fullPath = typeName;
48
+ const genericType = new V1_GenericTypeProtocol();
49
+ genericType.rawType = rawType;
50
+ return genericType;
51
+ };
52
+
53
+ const buildRelationTypeFromIngestDataset = (
54
+ dataset: V1_IngestDataset,
55
+ context: V1_GraphBuilderContext,
56
+ ): RelationType => {
57
+ const relationType = new RelationType('__ingest_dataset__');
58
+ relationType.columns = dataset.source.schema.columns.map((col) => {
59
+ const rawTypePath =
60
+ col.genericType.rawType instanceof V1_PackageableType
61
+ ? col.genericType.rawType.fullPath
62
+ : 'String';
63
+ const v1GenericType = buildV1GenericType(rawTypePath);
64
+ const resolvedGenericType =
65
+ returnUndefOnError(() =>
66
+ context.resolveGenericTypeFromProtocolWithRelationType(v1GenericType),
67
+ ) ??
68
+ context.resolveGenericTypeFromProtocolWithRelationType(
69
+ buildV1GenericType('String'),
70
+ );
71
+ return new RelationColumn(col.name, resolvedGenericType);
72
+ });
73
+ return relationType;
74
+ };
75
+
76
+ const buildRelationTypeFromTable = (table: Table): RelationType => {
77
+ const relationType = new RelationType('__database_table__');
78
+ relationType.columns = table.columns
79
+ .filter((col): col is Column => col instanceof Column)
80
+ .map(
81
+ (col) =>
82
+ new RelationColumn(
83
+ col.name,
84
+ GenericTypeExplicitReference.create(
85
+ new GenericType(mapRelationalDataTypeToPrimitiveType(col.type)),
86
+ ),
87
+ ),
88
+ );
89
+ return relationType;
90
+ };
91
+ // TODO: move to pure graph
92
+ /**
93
+ * Creates an appropriate Accessor from a packageable element.
94
+ *
95
+ * For IngestDefinition: requires `datasetName` to identify the dataset.
96
+ * For Database: requires `schemaName` and `tableName` to identify the table.
97
+ */
98
+ export const V1_createAccessorFromPackageableElement = (
99
+ element: AccessorOwner,
100
+ context: V1_GraphBuilderContext,
101
+ options?: {
102
+ schemaName?: string | undefined;
103
+ tableName?: string | undefined;
104
+ },
105
+ ): Accessor | undefined => {
106
+ if (element instanceof IngestDefinition) {
107
+ const content = returnUndefOnError(() =>
108
+ V1_deserializeIngestDefinitionContent(element.content),
109
+ );
110
+ // if unable to serialize we dont fall hard, we return undefined. we may want to revisit and fall hard on this.
111
+ if (!content) {
112
+ return undefined;
113
+ }
114
+ const datasetName = options?.tableName;
115
+ const dataset = datasetName
116
+ ? content.datasets?.find((ds) => ds.name === datasetName)
117
+ : content.datasets?.[0];
118
+ if (!dataset) {
119
+ return undefined;
120
+ }
121
+ const relationType = buildRelationTypeFromIngestDataset(dataset, context);
122
+ return new IngestionAccessor(
123
+ element.path,
124
+ undefined,
125
+ dataset.name,
126
+ relationType,
127
+ element,
128
+ );
129
+ }
130
+ if (element instanceof Database) {
131
+ const schemaName = options?.schemaName;
132
+ const tableName = options?.tableName;
133
+ let table: Table | undefined;
134
+ if (schemaName && tableName) {
135
+ const schema = element.schemas.find((s) => s.name === schemaName);
136
+ if (!schema) {
137
+ return undefined;
138
+ }
139
+ table = schema.tables.find((t) => t.name === tableName);
140
+ }
141
+ const tables = element.schemas.map((e) => e.tables).flat();
142
+ table = tableName ? tables.find((t) => t.name === tableName) : tables[0];
143
+ if (!table) {
144
+ return undefined;
145
+ }
146
+ const relationType = buildRelationTypeFromTable(table);
147
+ return new RelationalStoreAccessor(
148
+ element.path,
149
+ table.schema.name,
150
+ table.name,
151
+ relationType,
152
+ element,
153
+ );
154
+ }
155
+ return undefined;
156
+ };
@@ -20,7 +20,7 @@ import {
20
20
  type V1_ValueSpecificationVisitor,
21
21
  } from '../model/valueSpecification/V1_ValueSpecification.js';
22
22
  import type { V1_Variable } from '../model/valueSpecification/V1_Variable.js';
23
- import type { V1_Lambda } from '../model/valueSpecification/raw/V1_Lambda.js';
23
+ import { V1_Lambda } from '../model/valueSpecification/raw/V1_Lambda.js';
24
24
  import type { V1_EnumValue } from '../model/valueSpecification/raw/V1_EnumValue.js';
25
25
  import type { V1_AppliedFunction } from '../model/valueSpecification/application/V1_AppliedFunction.js';
26
26
  import type { V1_Collection } from '../model/valueSpecification/raw/V1_Collection.js';
@@ -380,10 +380,10 @@ function _V1_observe_ColSpec(metamodel: V1_ColSpec): V1_ColSpec {
380
380
  function2: observable,
381
381
  });
382
382
 
383
- if (metamodel.function1) {
383
+ if (metamodel.function1 && metamodel.function1 instanceof V1_Lambda) {
384
384
  V1_observe_Lambda(metamodel.function1);
385
385
  }
386
- if (metamodel.function2) {
386
+ if (metamodel.function2 && metamodel.function2 instanceof V1_Lambda) {
387
387
  V1_observe_Lambda(metamodel.function2);
388
388
  }
389
389
 
@@ -30,18 +30,22 @@ export class V1_IngestDefinition extends V1_INTERNAL__UnknownPackageableElement
30
30
  return visitor.visit_IngestDefinition(this);
31
31
  }
32
32
  }
33
- export interface V1_IngestDataset {
34
- name: string;
35
- primaryKey: string[];
36
- source: {
37
- _type: string;
38
- schema: {
39
- _type: string;
40
- columns: V1_RelationTypeColumn[];
41
- };
42
- };
33
+ export class V1_IngestDatasetSchema {
34
+ _type!: string;
35
+ columns: V1_RelationTypeColumn[] = [];
43
36
  }
44
37
 
45
- export interface V1_IngestDefinitionContent {
38
+ export class V1_IngestDatasetSource {
39
+ _type!: string;
40
+ schema!: V1_IngestDatasetSchema;
41
+ }
42
+
43
+ export class V1_IngestDataset {
44
+ name!: string;
45
+ primaryKey: string[] = [];
46
+ source!: V1_IngestDatasetSource;
47
+ }
48
+
49
+ export class V1_IngestDefinitionContent {
46
50
  datasets?: V1_IngestDataset[];
47
51
  }
@@ -35,6 +35,7 @@ export class V1_Service extends V1_PackageableElement implements Hashable {
35
35
  owners: string[] = [];
36
36
  ownership?: V1_ServiceOwnership | undefined;
37
37
  documentation!: string;
38
+ title?: string | undefined;
38
39
  mcpServer?: string | undefined;
39
40
  autoActivateUpdates = true;
40
41
  execution!: V1_ServiceExecution;
@@ -56,6 +57,7 @@ export class V1_Service extends V1_PackageableElement implements Hashable {
56
57
  this.execution,
57
58
  this.test ?? '',
58
59
  this.mcpServer ?? '',
60
+ this.title ?? '',
59
61
  hashArray(this.testSuites),
60
62
  hashArray(this.postValidations),
61
63
  hashArray(this.taggedValues),
@@ -14,11 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import type { V1_Lambda } from '../../V1_Lambda.js';
17
+ import type { V1_ValueSpecification } from '../../../V1_ValueSpecification.js';
18
18
 
19
19
  export class V1_ColSpec {
20
20
  name!: string;
21
21
  type?: string | undefined;
22
- function1?: V1_Lambda | undefined;
23
- function2?: V1_Lambda | undefined;
22
+ function1?: V1_ValueSpecification | undefined;
23
+ function2?: V1_ValueSpecification | undefined;
24
24
  }
@@ -14,16 +14,41 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export class V1_RelationStoreAccessor {
17
+ import { V1_ClassInstanceType } from '../../../../../transformation/pureProtocol/serializationHelpers/V1_ValueSpecificationSerializer.js';
18
+
19
+ export abstract class V1_Accessor {
18
20
  path: string[] = [];
21
+
22
+ abstract INSTANCE_TYPE: V1_ClassInstanceType;
23
+ }
24
+
25
+ export class V1_RelationStoreAccessor extends V1_Accessor {
19
26
  metadata?: boolean;
27
+
28
+ get INSTANCE_TYPE(): V1_ClassInstanceType {
29
+ return V1_ClassInstanceType.RELATION_STORE_ACCESSOR;
30
+ }
20
31
  }
21
32
 
22
- export class V1_DataProductAccessor {
23
- path: string[] = [];
33
+ export class V1_DataProductAccessor extends V1_Accessor {
24
34
  parameters: string[] = [];
35
+ get INSTANCE_TYPE(): V1_ClassInstanceType {
36
+ return V1_ClassInstanceType.DATA_PRODUCT_ACCESSOR;
37
+ }
25
38
  }
26
39
 
27
- export class V1_SQLAccessor {
40
+ export class V1_IngestDefinitionAccessor extends V1_Accessor {
41
+ metadata = false;
42
+
43
+ get INSTANCE_TYPE(): V1_ClassInstanceType {
44
+ return V1_ClassInstanceType.INGEST_ACCESSOR;
45
+ }
46
+ }
47
+
48
+ export class V1_SQLAccessor extends V1_Accessor {
28
49
  sql!: string;
50
+
51
+ get INSTANCE_TYPE(): V1_ClassInstanceType {
52
+ return V1_ClassInstanceType.SQL_ACCESSOR;
53
+ }
29
54
  }
@@ -329,25 +329,26 @@ export const V1_transformService = (
329
329
  ): V1_Service => {
330
330
  const service = new V1_Service();
331
331
  V1_initPackageableElement(service, element);
332
- service.stereotypes = element.stereotypes.map(V1_transformStereotype);
333
- service.taggedValues = element.taggedValues.map(V1_transformTaggedValue);
334
332
  service.autoActivateUpdates = element.autoActivateUpdates;
335
- service.mcpServer = element.mcpServer;
336
333
  service.documentation = element.documentation;
337
334
  service.execution = transformServiceExecution(element.execution, context);
335
+ service.mcpServer = element.mcpServer;
336
+ service.owners = element.owners;
338
337
  if (element.ownership) {
339
338
  service.ownership = transformServiceOwnership(element.ownership);
340
339
  }
341
- service.owners = element.owners;
342
340
  service.pattern = element.pattern;
341
+ service.postValidations = element.postValidations.map((postValidation) =>
342
+ V1_transformPostValidation(postValidation, context),
343
+ );
344
+ service.stereotypes = element.stereotypes.map(V1_transformStereotype);
345
+ service.taggedValues = element.taggedValues.map(V1_transformTaggedValue);
343
346
  if (element.test) {
344
347
  service.test = transformLegacyServiceTest(element.test, context);
345
348
  }
346
349
  service.testSuites = element.tests.map((testSuite) =>
347
350
  V1_transformTestSuite(testSuite, context),
348
351
  );
349
- service.postValidations = element.postValidations.map((postValidation) =>
350
- V1_transformPostValidation(postValidation, context),
351
- );
352
+ service.title = element.title;
352
353
  return service;
353
354
  };
@@ -94,6 +94,39 @@ import { V1_ColSpecArray } from '../../../model/valueSpecification/raw/classInst
94
94
  import { V1_ColSpec } from '../../../model/valueSpecification/raw/classInstance/relation/V1_ColSpec.js';
95
95
  import { RelationColumn } from '../../../../../../../graph/metamodel/pure/packageableElements/relation/RelationType.js';
96
96
  import { V1_createGenericTypeWithElementPath } from '../../../helpers/V1_DomainHelper.js';
97
+ import {
98
+ type Accessor,
99
+ type AccessorInstanceValue,
100
+ DataProductAccessor,
101
+ IngestionAccessor,
102
+ RelationalStoreAccessor,
103
+ } from '../../../../../../../graph/metamodel/pure/packageableElements/relation/Accessor.js';
104
+ import {
105
+ type V1_Accessor,
106
+ V1_DataProductAccessor,
107
+ V1_IngestDefinitionAccessor,
108
+ V1_RelationStoreAccessor,
109
+ } from '../../../model/valueSpecification/raw/classInstance/relation/V1_RelationStoreAccessor.js';
110
+
111
+ const transformAccessor = (accessor: Accessor): V1_Accessor => {
112
+ if (accessor instanceof DataProductAccessor) {
113
+ const v1Accessor = new V1_DataProductAccessor();
114
+ v1Accessor.path = accessor.path;
115
+ return v1Accessor;
116
+ } else if (accessor instanceof IngestionAccessor) {
117
+ const v1Accessor = new V1_IngestDefinitionAccessor();
118
+ v1Accessor.path = accessor.path;
119
+ return v1Accessor;
120
+ } else if (accessor instanceof RelationalStoreAccessor) {
121
+ const v1Accessor = new V1_RelationStoreAccessor();
122
+ v1Accessor.path = accessor.path;
123
+ return v1Accessor;
124
+ }
125
+ throw new UnsupportedOperationError(
126
+ `Can't transform accessor: unsupported accessor type`,
127
+ accessor,
128
+ );
129
+ };
97
130
 
98
131
  class V1_ValueSpecificationTransformer
99
132
  implements ValueSpecificationVisitor<V1_ValueSpecification>
@@ -254,6 +287,20 @@ class V1_ValueSpecificationTransformer
254
287
  );
255
288
  }
256
289
 
290
+ visit_AccessorInstanceValue(
291
+ valueAccessorInstanceValue: AccessorInstanceValue,
292
+ ): V1_ValueSpecification {
293
+ const accessor = guaranteeNonNullable(
294
+ valueAccessorInstanceValue.values[0],
295
+ 'Accessor required in AccessorInstanceValue',
296
+ );
297
+ const v1Accessor = transformAccessor(accessor);
298
+ const classInstance = new V1_ClassInstance();
299
+ classInstance.type = v1Accessor.INSTANCE_TYPE;
300
+ classInstance.value = v1Accessor;
301
+ return classInstance;
302
+ }
303
+
257
304
  visit_CollectionInstanceValue(
258
305
  valueSpecification: CollectionInstanceValue,
259
306
  ): V1_ValueSpecification {
@@ -428,10 +475,10 @@ class V1_ValueSpecificationTransformer
428
475
  ),
429
476
  );
430
477
  if (fun1) {
431
- colProtocol.function1 = guaranteeType(fun1, V1_Lambda);
478
+ colProtocol.function1 = fun1;
432
479
  }
433
480
  if (fun2) {
434
- colProtocol.function2 = guaranteeType(fun2, V1_Lambda);
481
+ colProtocol.function2 = fun2;
435
482
  }
436
483
  return colProtocol;
437
484
  });
@@ -619,6 +619,7 @@ export class V1_ElementSecondPassBuilder
619
619
  .map((taggedValue) => V1_buildTaggedValue(taggedValue, this.context))
620
620
  .filter(isNonNullable);
621
621
  service.pattern = element.pattern;
622
+ service.title = element.title;
622
623
  service.owners = element.owners.slice();
623
624
  service.documentation = element.documentation;
624
625
  service.autoActivateUpdates = element.autoActivateUpdates;
@@ -116,9 +116,21 @@ import {
116
116
  } from '../../../../helpers/V1_DomainHelper.js';
117
117
  import {
118
118
  ColSpec,
119
+ ColSpecArray,
120
+ ColSpecArrayInstance,
119
121
  ColSpecInstanceValue,
120
122
  } from '../../../../../../../../graph/metamodel/pure/valueSpecification/RelationValueSpecification.js';
121
123
  import { V1_ColSpec } from '../../../../model/valueSpecification/raw/classInstance/relation/V1_ColSpec.js';
124
+ import { V1_ColSpecArray } from '../../../../model/valueSpecification/raw/classInstance/relation/V1_ColSpecArray.js';
125
+ import {
126
+ V1_RelationStoreAccessor,
127
+ V1_IngestDefinitionAccessor,
128
+ V1_DataProductAccessor,
129
+ } from '../../../../model/valueSpecification/raw/classInstance/relation/V1_RelationStoreAccessor.js';
130
+ import { AccessorInstanceValue } from '../../../../../../../../graph/metamodel/pure/packageableElements/relation/Accessor.js';
131
+ import { V1_createAccessorFromPackageableElement } from '../../../../helpers/V1_AccessorHelper.js';
132
+ import { Database } from '../../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Database.js';
133
+ import { IngestDefinition } from '../../../../../../../../graph/metamodel/pure/packageableElements/ingest/IngestDefinition.js';
122
134
 
123
135
  const buildPrimtiveInstanceValue = (
124
136
  type: PRIMITIVE_TYPE,
@@ -471,9 +483,125 @@ export class V1_ValueSpecificationBuilder
471
483
  const protocol = guaranteeType(valueSpecification.value, V1_ColSpec);
472
484
  const value = new ColSpec();
473
485
  value.name = protocol.name;
486
+ value.type = protocol.type;
487
+ value.function1 = protocol.function1
488
+ ? protocol.function1.accept_ValueSpecificationVisitor(
489
+ new V1_ValueSpecificationBuilder(
490
+ this.context,
491
+ this.processingContext,
492
+ this.openVariables,
493
+ ),
494
+ )
495
+ : undefined;
496
+ value.function2 = protocol.function2
497
+ ? protocol.function2.accept_ValueSpecificationVisitor(
498
+ new V1_ValueSpecificationBuilder(
499
+ this.context,
500
+ this.processingContext,
501
+ this.openVariables,
502
+ ),
503
+ )
504
+ : undefined;
474
505
  instanceValue.values = [value];
475
506
  return instanceValue;
476
507
  }
508
+ case V1_ClassInstanceType.COL_SPEC_ARRAY: {
509
+ const instanceValue = new ColSpecArrayInstance(
510
+ Multiplicity.ONE,
511
+ undefined,
512
+ );
513
+ const protocol = guaranteeType(
514
+ valueSpecification.value,
515
+ V1_ColSpecArray,
516
+ );
517
+ const value = new ColSpecArray();
518
+ value.colSpecs = protocol.colSpecs.map((colSpec) => {
519
+ const colSpecInstance = new ColSpec();
520
+ colSpecInstance.name = colSpec.name;
521
+ colSpecInstance.type = colSpec.type;
522
+ colSpecInstance.function1 = colSpec.function1
523
+ ? colSpec.function1.accept_ValueSpecificationVisitor(
524
+ new V1_ValueSpecificationBuilder(
525
+ this.context,
526
+ this.processingContext,
527
+ this.openVariables,
528
+ ),
529
+ )
530
+ : undefined;
531
+ colSpecInstance.function2 = colSpec.function2
532
+ ? colSpec.function2.accept_ValueSpecificationVisitor(
533
+ new V1_ValueSpecificationBuilder(
534
+ this.context,
535
+ this.processingContext,
536
+ this.openVariables,
537
+ ),
538
+ )
539
+ : undefined;
540
+ return colSpecInstance;
541
+ });
542
+ instanceValue.values = [value];
543
+ return instanceValue;
544
+ }
545
+ case V1_ClassInstanceType.RELATION_STORE_ACCESSOR: {
546
+ const protocol = guaranteeType(
547
+ valueSpecification.value,
548
+ V1_RelationStoreAccessor,
549
+ );
550
+ const dbPath = guaranteeNonNullable(protocol.path[0]);
551
+ const schemaName = protocol.path[1];
552
+ const tableName = protocol.path[2];
553
+ const db = guaranteeType(
554
+ this.context.resolveElement(dbPath, false).value,
555
+ Database,
556
+ );
557
+ const accessor = guaranteeNonNullable(
558
+ V1_createAccessorFromPackageableElement(db, this.context, {
559
+ schemaName,
560
+ tableName,
561
+ }),
562
+ `Can't build accessor for database '${dbPath}'`,
563
+ );
564
+ const accessorInstanceValue = new AccessorInstanceValue();
565
+ accessorInstanceValue.values = [accessor];
566
+ accessorInstanceValue.genericType = GenericTypeExplicitReference.create(
567
+ new GenericType(accessor.relationType),
568
+ );
569
+ return accessorInstanceValue;
570
+ }
571
+ case V1_ClassInstanceType.INGEST_ACCESSOR: {
572
+ const protocol = guaranteeType(
573
+ valueSpecification.value,
574
+ V1_IngestDefinitionAccessor,
575
+ );
576
+ const ingestPath = guaranteeNonNullable(protocol.path[0]);
577
+ const datasetName = protocol.path[1];
578
+ const ingestDef = guaranteeType(
579
+ this.context.resolveElement(ingestPath, false).value,
580
+ IngestDefinition,
581
+ );
582
+ const accessor = guaranteeNonNullable(
583
+ V1_createAccessorFromPackageableElement(ingestDef, this.context, {
584
+ tableName: datasetName,
585
+ }),
586
+ `Can't build accessor for ingest definition '${ingestPath}'`,
587
+ );
588
+ const accessorInstanceValue = new AccessorInstanceValue();
589
+ accessorInstanceValue.values = [accessor];
590
+ accessorInstanceValue.genericType = GenericTypeExplicitReference.create(
591
+ new GenericType(accessor.relationType),
592
+ );
593
+ return accessorInstanceValue;
594
+ }
595
+ case V1_ClassInstanceType.DATA_PRODUCT_ACCESSOR: {
596
+ const protocol = guaranteeType(
597
+ valueSpecification.value,
598
+ V1_DataProductAccessor,
599
+ );
600
+ const _path = protocol.path;
601
+ throw new UnsupportedOperationError(
602
+ `Can't build accessor for data product with path '${_path.join('.')}': data product accessor building is not yet supported`,
603
+ );
604
+ }
477
605
  default: {
478
606
  const builders = this.context.extensions.plugins.flatMap(
479
607
  (plugin) => plugin.V1_getExtraClassInstanceValueBuilders?.() ?? [],
@@ -609,6 +737,7 @@ export function V1_processProperty(
609
737
  const _funcExp = new FunctionExpression(col.name);
610
738
  _funcExp.func = col;
611
739
  _funcExp.parametersValues = processedParameters;
740
+ _funcExp.genericType = col.genericType;
612
741
  return _funcExp;
613
742
  }
614
743
  throw new UnsupportedOperationError(
@@ -20,7 +20,13 @@ import {
20
20
  usingModelSchema,
21
21
  type PlainObject,
22
22
  } from '@finos/legend-shared';
23
- import { V1_IngestDefinition } from '../../../model/packageableElements/ingest/V1_IngestDefinition.js';
23
+ import {
24
+ V1_IngestDataset,
25
+ V1_IngestDatasetSchema,
26
+ V1_IngestDatasetSource,
27
+ V1_IngestDefinition,
28
+ V1_IngestDefinitionContent,
29
+ } from '../../../model/packageableElements/ingest/V1_IngestDefinition.js';
24
30
  import type { V1_PackageableElement } from '../../../model/packageableElements/V1_PackageableElement.js';
25
31
  import type { V1_AppDirNode } from '../../../lakehouse/entitlements/V1_CoreEntitlements.js';
26
32
  import { V1_AppDirNodeModelSchema } from './lakehouse/V1_CoreEntitlementsSerializationHelper.js';
@@ -28,9 +34,12 @@ import {
28
34
  createModelSchema,
29
35
  custom,
30
36
  deserialize,
37
+ list,
38
+ optional,
31
39
  primitive,
32
40
  serialize,
33
41
  } from 'serializr';
42
+ import { V1_relationTypeColumnModelSchema } from './V1_TypeSerializationHelper.js';
34
43
  import {
35
44
  type V1_IngestEnvironment,
36
45
  V1_AWSSnowflakeIngestEnvironment,
@@ -167,3 +176,44 @@ export const V1_deserializeProducerEnvironment = (
167
176
  throw new Error(`Unknown V1_ProducerEnvironment type: ${json._type}`);
168
177
  }
169
178
  };
179
+
180
+ // --------------------------------------------- Ingest Dataset Content ---------------------------------------------
181
+
182
+ const V1_IngestDatasetSchemaModelSchema = createModelSchema(
183
+ V1_IngestDatasetSchema,
184
+ {
185
+ _type: primitive(),
186
+ columns: list(usingModelSchema(V1_relationTypeColumnModelSchema)),
187
+ },
188
+ );
189
+
190
+ const V1_IngestDatasetSourceModelSchema = createModelSchema(
191
+ V1_IngestDatasetSource,
192
+ {
193
+ _type: primitive(),
194
+ schema: usingModelSchema(V1_IngestDatasetSchemaModelSchema),
195
+ },
196
+ );
197
+
198
+ export const V1_IngestDatasetModelSchema = createModelSchema(V1_IngestDataset, {
199
+ name: primitive(),
200
+ primaryKey: list(primitive()),
201
+ source: usingModelSchema(V1_IngestDatasetSourceModelSchema),
202
+ });
203
+
204
+ export const V1_IngestDefinitionContentModelSchema = createModelSchema(
205
+ V1_IngestDefinitionContent,
206
+ {
207
+ datasets: optional(list(usingModelSchema(V1_IngestDatasetModelSchema))),
208
+ },
209
+ );
210
+
211
+ export const V1_deserializeIngestDefinitionContent = (
212
+ json: PlainObject<V1_IngestDefinitionContent>,
213
+ ): V1_IngestDefinitionContent =>
214
+ deserialize(V1_IngestDefinitionContentModelSchema, json);
215
+
216
+ export const V1_serializeIngestDefinitionContent = (
217
+ content: V1_IngestDefinitionContent,
218
+ ): PlainObject<V1_IngestDefinitionContent> =>
219
+ serialize(V1_IngestDefinitionContentModelSchema, content);