diff --git a/.changeset/soft-candles-obey.md b/.changeset/soft-candles-obey.md new file mode 100644 index 0000000000..006955d16e --- /dev/null +++ b/.changeset/soft-candles-obey.md @@ -0,0 +1,4 @@ +--- +'@finos/legend-extension-dsl-persistence': patch +'@finos/legend-graph': patch +--- diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_Persistence.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_Persistence.ts index 8c67ab5af6..6561c27145 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_Persistence.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_Persistence.ts @@ -19,6 +19,7 @@ import type { V1_Persister } from './V1_DSL_Persistence_Persister.js'; import type { V1_Trigger } from './V1_DSL_Persistence_Trigger.js'; import { V1_PackageableElement, + type V1_PackageableElementPointer, type V1_PackageableElementVisitor, } from '@finos/legend-graph'; import { type Hashable, hashArray } from '@finos/legend-shared'; @@ -29,7 +30,7 @@ import type { V1_ServiceOutputTarget as V1_ServiceOutputTarget } from './V1_DSL_ export class V1_Persistence extends V1_PackageableElement implements Hashable { documentation!: string; trigger!: V1_Trigger; - service!: string; + service!: V1_PackageableElementPointer; persister?: V1_Persister | undefined; serviceOutputTargets?: V1_ServiceOutputTarget[] | undefined; notifier!: V1_Notifier; @@ -40,7 +41,7 @@ export class V1_Persistence extends V1_PackageableElement implements Hashable { PERSISTENCE_HASH_STRUCTURE.PERSISTENCE, this.documentation, this.trigger, - this.service, + this.service.path, hashArray(this.serviceOutputTargets ?? []), this.persister ?? '', this.notifier, diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_PersistentTarget.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_PersistentTarget.ts index 874b2351ef..0d9d22d7ff 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_PersistentTarget.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_PersistentTarget.ts @@ -17,6 +17,7 @@ import { type Hashable, hashArray } from '@finos/legend-shared'; import { PERSISTENCE_HASH_STRUCTURE } from '../../../../../../../graph/DSL_Persistence_HashUtils.js'; import type { V1_Temporality } from './V1_DSL_Persistence_Temporality.js'; +import type { V1_PackageableElementPointer } from '@finos/legend-graph'; export abstract class V1_PersistenceTarget implements Hashable { abstract get hashCode(): string; @@ -27,14 +28,14 @@ export class V1_RelationalPersistenceTarget implements Hashable { table!: string; - database!: string; + database!: V1_PackageableElementPointer; temporality!: V1_Temporality; get hashCode(): string { return hashArray([ PERSISTENCE_HASH_STRUCTURE.RELATIONAL_PERSISTENCE_TARGET, this.table, - this.database, + this.database.path, this.temporality, ]); } diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_Sink.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_Sink.ts index 2e50d9f683..f154fd1fcc 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_Sink.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/model/packageableElements/persistence/V1_DSL_Persistence_Sink.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import type { V1_PackageableElementPointer } from '@finos/legend-graph'; import { PERSISTENCE_HASH_STRUCTURE } from '../../../../../../../graph/DSL_Persistence_HashUtils.js'; import { type Hashable, hashArray } from '@finos/legend-shared'; @@ -22,23 +23,23 @@ export abstract class V1_Sink implements Hashable { } export class V1_RelationalSink extends V1_Sink implements Hashable { - database!: string; + database!: V1_PackageableElementPointer; override get hashCode(): string { return hashArray([ PERSISTENCE_HASH_STRUCTURE.RELATIONAL_SINK, - this.database, + this.database.path, ]); } } export class V1_ObjectStorageSink extends V1_Sink implements Hashable { - binding!: string; + binding!: V1_PackageableElementPointer; override get hashCode(): string { return hashArray([ PERSISTENCE_HASH_STRUCTURE.OBJECT_STORAGE_SINK, - this.binding, + this.binding.path, ]); } } diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DSL_Persistence_TransformerHelper.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DSL_Persistence_TransformerHelper.ts index 339fb8ab2f..4c5f039c9a 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DSL_Persistence_TransformerHelper.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DSL_Persistence_TransformerHelper.ts @@ -154,6 +154,8 @@ import { V1_transformEmbeddedData, V1_transformTestAssertion, V1_transformAtomicTest, + PackageableElementPointerType, + V1_PackageableElementPointer, } from '@finos/legend-graph'; import { guaranteeType, UnsupportedOperationError } from '@finos/legend-shared'; import type { PersistenceTestBatch } from '../../../../../../../graph/metamodel/pure/model/packageableElements/persistence/DSL_Persistence_PersistenceTestBatch.js'; @@ -357,7 +359,10 @@ export const V1_transformRelationalSink = ( context: V1_GraphTransformerContext, ): V1_RelationalSink => { const protocol = new V1_RelationalSink(); - protocol.database = element.database.value.path; + protocol.database = new V1_PackageableElementPointer( + PackageableElementPointerType.STORE, + element.database.value.path, + ); return protocol; }; @@ -366,7 +371,10 @@ export const V1_transformObjectStorageSink = ( context: V1_GraphTransformerContext, ): V1_ObjectStorageSink => { const protocol = new V1_ObjectStorageSink(); - protocol.binding = element.binding.value.path; + protocol.binding = new V1_PackageableElementPointer( + PackageableElementPointerType.BINDING, + element.binding.value.path, + ); return protocol; }; @@ -963,7 +971,11 @@ export const V1_transformPersistenceTarget = ( ): V1_PersistenceTarget => { if (element instanceof RelationalPersistenceTarget) { const protocol = new V1_RelationalPersistenceTarget(); - protocol.database = element.database; + protocol.database = new V1_PackageableElementPointer( + PackageableElementPointerType.STORE, + element.database, + ); + protocol.table = element.table; protocol.temporality = V1_transformTemporality( element.temporality, @@ -1252,7 +1264,10 @@ export const V1_transformPersistence = ( protocol.documentation = element.documentation; protocol.notifier = V1_transformNotifier(element.notifier, context); protocol.persister = V1_transformPersister(element.persister, context); - protocol.service = element.service.valueForSerialization ?? ''; + protocol.service = new V1_PackageableElementPointer( + PackageableElementPointerType.SERVICE, + element.service.valueForSerialization ?? '', + ); protocol.serviceOutputTargets = V1_transformServiceOutputTargets( element.serviceOutputTargets, context, diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_DSL_Persistence_BuilderHelper.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_DSL_Persistence_BuilderHelper.ts index 28f1a90e71..c6bb09e611 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_DSL_Persistence_BuilderHelper.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_DSL_Persistence_BuilderHelper.ts @@ -368,7 +368,7 @@ export const V1_buildRelationalSink = ( ): RelationalSink => { const sink = new RelationalSink(); sink.database = context.resolveElement( - protocol.database, + protocol.database.path, false, ) as PackageableElementImplicitReference; return sink; @@ -380,7 +380,7 @@ export const V1_buildObjectStorageSink = ( ): ObjectStorageSink => { const sink = new ObjectStorageSink(); sink.binding = context.resolveElement( - protocol.binding, + protocol.binding.path, false, ) as PackageableElementImplicitReference; return sink; @@ -1164,7 +1164,7 @@ export const V1_buildPersistenceTarget = ( ): PersistenceTarget => { if (protocol instanceof V1_RelationalPersistenceTarget) { const persistentTarget = new RelationalPersistenceTarget(); - persistentTarget.database = protocol.database; + persistentTarget.database = protocol.database.path; persistentTarget.table = protocol.table; persistentTarget.temporality = V1_buildTemporality( protocol.temporality, @@ -1222,7 +1222,7 @@ export const V1_buildPersistence = ( ); persistence.notifier = V1_buildNotifier(protocol.notifier, context); persistence.persister = V1_buildPersister(protocol.persister, context); - persistence.service = context.resolveService(protocol.service); + persistence.service = context.resolveService(protocol.service.path); persistence.serviceOutputTargets = V1_buildServiceOutputTargets( protocol.serviceOutputTargets, context, diff --git a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_Persistence_ProtocolHelper.ts b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_Persistence_ProtocolHelper.ts index 404156eefb..4b1e07aa32 100644 --- a/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_Persistence_ProtocolHelper.ts +++ b/packages/legend-extension-dsl-persistence/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/V1_DSL_Persistence_ProtocolHelper.ts @@ -92,6 +92,9 @@ import { V1_externalFormatDataModelSchema, V1_serializeAtomicTest, V1_deserializeAtomicTest, + V1_packageableElementPointerModelSchema, + V1_serializePackageableElementPointer, + PackageableElementPointerType, } from '@finos/legend-graph'; import { type PlainObject, @@ -777,7 +780,14 @@ const V1_relationalSinkModelSchema = ( ): ModelSchema => createModelSchema(V1_RelationalSink, { _type: usingConstantValueSchema(V1_SinkType.RELATIONAL_SINK), - database: primitive(), + database: custom( + (val) => serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.STORE, + ), + ), }); const V1_objectStorageSinkModelSchema = ( @@ -785,7 +795,14 @@ const V1_objectStorageSinkModelSchema = ( ): ModelSchema => createModelSchema(V1_ObjectStorageSink, { _type: usingConstantValueSchema(V1_SinkType.OBJECT_STORAGE_SINK), - binding: primitive(), + binding: custom( + (val) => serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.BINDING, + ), + ), }); export const V1_serializeSink = ( @@ -1599,7 +1616,14 @@ export const V1_relationalPersistenceTargetModelSchema = ( _type: usingConstantValueSchema( V1_PersistentTargetType.RELATIONAL_PERSISTENCE_TARGET, ), - database: primitive(), + database: custom( + (val) => serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.STORE, + ), + ), table: primitive(), temporality: custom( (val) => V1_serializeTemporality(val, plugins), @@ -2134,7 +2158,14 @@ export const V1_persistenceModelSchema = ( (val) => V1_serializePersister(val, plugins), (val) => V1_deserializePersister(val, plugins), ), - service: primitive(), + service: custom( + (val) => serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.SERVICE, + ), + ), serviceOutputTargets: optionalCustomList( (val: V1_ServiceOutputTarget) => V1_serializeServiceOutputTarget(val, plugins), diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/domain/V1_Class.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/domain/V1_Class.ts index 250053cde3..44625b111f 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/domain/V1_Class.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/domain/V1_Class.ts @@ -20,6 +20,7 @@ import type { V1_Property } from '../../../model/packageableElements/domain/V1_P import type { V1_StereotypePtr } from '../../../model/packageableElements/domain/V1_StereotypePtr.js'; import { type V1_PackageableElementVisitor, + type V1_PackageableElementPointer, V1_PackageableElement, } from '../../../model/packageableElements/V1_PackageableElement.js'; import type { V1_TaggedValue } from '../../../model/packageableElements/domain/V1_TaggedValue.js'; @@ -27,7 +28,7 @@ import type { V1_Constraint } from '../../../model/packageableElements/domain/V1 import type { V1_DerivedProperty } from './V1_DerivedProperty.js'; export class V1_Class extends V1_PackageableElement implements Hashable { - superTypes: string[] = []; + superTypes: V1_PackageableElementPointer[] = []; properties: V1_Property[] = []; derivedProperties: V1_DerivedProperty[] = []; stereotypes: V1_StereotypePtr[] = []; @@ -40,7 +41,7 @@ export class V1_Class extends V1_PackageableElement implements Hashable { this.path, hashArray(this.properties), hashArray(this.derivedProperties), - hashArray(this.superTypes), + hashArray(this.superTypes.map((e) => e.path)), hashArray(this.constraints), hashArray(this.stereotypes), hashArray(this.taggedValues), diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/domain/V1_Profile.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/domain/V1_Profile.ts index cc0cffeef6..2eeb64d33f 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/domain/V1_Profile.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/domain/V1_Profile.ts @@ -21,16 +21,31 @@ import { V1_PackageableElement, } from '../../../model/packageableElements/V1_PackageableElement.js'; +export class V1_ProfileStereotype { + value!: string; + + constructor(value: string) { + this.value = value; + } +} + +export class V1_ProfileTag { + value!: string; + constructor(value: string) { + this.value = value; + } +} + export class V1_Profile extends V1_PackageableElement implements Hashable { - stereotypes: string[] = []; - tags: string[] = []; + stereotypes: V1_ProfileStereotype[] = []; + tags: V1_ProfileTag[] = []; override get hashCode(): string { return hashArray([ CORE_HASH_STRUCTURE.PROFILE, this.path, - hashArray(this.stereotypes), - hashArray(this.tags), + hashArray(this.stereotypes.map((e) => e.value)), + hashArray(this.tags.map((e) => e.value)), ]); } diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_AssociationMapping.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_AssociationMapping.ts index 3553934f22..019fafe12a 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_AssociationMapping.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_AssociationMapping.ts @@ -16,16 +16,17 @@ import { hashArray, type Hashable } from '@finos/legend-shared'; import { CORE_HASH_STRUCTURE } from '../../../../../../../graph/Core_HashUtils.js'; +import type { V1_PackageableElementPointer } from '../V1_PackageableElement.js'; export abstract class V1_AssociationMapping implements Hashable { id?: string | undefined; - association!: string; + association!: V1_PackageableElementPointer; stores: string[] = []; get hashCode(): string { return hashArray([ CORE_HASH_STRUCTURE.ASSOCIATION_IMPLEMENTATION, - this.association, + this.association.path, this.id ?? '', hashArray(this.stores), ]); diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_EnumerationMapping.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_EnumerationMapping.ts index 2a2cd2ad1f..a90ec6becf 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_EnumerationMapping.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_EnumerationMapping.ts @@ -24,10 +24,11 @@ import { type V1_EnumValueMapping, V1_getEnumValueMappingSourceValueType, } from '../../../model/packageableElements/mapping/V1_EnumValueMapping.js'; +import type { V1_PackageableElementPointer } from '../V1_PackageableElement.js'; export class V1_EnumerationMapping implements Hashable { id?: string | undefined; - enumeration!: string; + enumeration!: V1_PackageableElementPointer; /** * NOTE: the order is important, during deserialization, we want sourceType to be already available * @deprecated since v1_11_0 @@ -41,7 +42,7 @@ export class V1_EnumerationMapping implements Hashable { return hashArray([ CORE_HASH_STRUCTURE.ENUMERATION_MAPPING, this.id ?? '', - this.enumeration, + this.enumeration.path, // NOTE: older protocol formats have information about source type so we have to account for those, // otherwise, we don't need to account for the source type in hash computation // If there is no enum value mapping, ignore the source type since it's synthetic and used by the editor diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_MappingStoreTestData.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_MappingStoreTestData.ts index c67b290289..ab9d6c3ea7 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_MappingStoreTestData.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/mapping/V1_MappingStoreTestData.ts @@ -17,15 +17,16 @@ import { hashArray, type Hashable } from '@finos/legend-shared'; import { CORE_HASH_STRUCTURE } from '../../../../../../../graph/Core_HashUtils.js'; import type { V1_EmbeddedData } from '../../data/V1_EmbeddedData.js'; +import type { V1_PackageableElementPointer } from '../V1_PackageableElement.js'; export class V1_MappingStoreTestData implements Hashable { - store!: string; + store!: V1_PackageableElementPointer; data!: V1_EmbeddedData; get hashCode(): string { return hashArray([ CORE_HASH_STRUCTURE.STORE_TEST_DATA, - this.store, + this.store.path, this.data, ]); } diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/V1_Store.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/V1_Store.ts index 73efb3d6e7..7f9ec3b643 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/V1_Store.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/V1_Store.ts @@ -15,11 +15,14 @@ */ import type { Hashable } from '@finos/legend-shared'; -import { V1_PackageableElement } from '../../../model/packageableElements/V1_PackageableElement.js'; +import { + V1_PackageableElement, + type V1_PackageableElementPointer, +} from '../../../model/packageableElements/V1_PackageableElement.js'; export abstract class V1_Store extends V1_PackageableElement implements Hashable { - includedStores: string[] = []; + includedStores: V1_PackageableElementPointer[] = []; } diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/flatData/model/V1_FlatData.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/flatData/model/V1_FlatData.ts index 5418c8c1c2..adeab08c18 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/flatData/model/V1_FlatData.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/flatData/model/V1_FlatData.ts @@ -27,7 +27,7 @@ export class V1_FlatData extends V1_Store implements Hashable { return hashArray([ CORE_HASH_STRUCTURE.FLAT_DATA, this.path, - hashArray(this.includedStores), + hashArray(this.includedStores.map((e) => e.path)), hashArray(this.sections), ]); } diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_Database.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_Database.ts index 570a88c7df..5254522799 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_Database.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_Database.ts @@ -33,7 +33,7 @@ export class V1_Database extends V1_Store implements Hashable { return hashArray([ CORE_HASH_STRUCTURE.DATABASE, this.path, - hashArray(this.includedStores), + hashArray(this.includedStores.map((e) => e.path)), hashArray(this.schemas), hashArray(this.joins), hashArray(this.filters), diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DatabaseTransformer.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DatabaseTransformer.ts index d6a5df2b41..b9eb457f82 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DatabaseTransformer.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DatabaseTransformer.ts @@ -48,6 +48,7 @@ import { RelationalOperationElementWithJoin, extractLine, } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/RelationalOperationElement.js'; +import { PackageableElementPointerType } from '../../../../../../../graph/MetaModelConst.js'; import type { Table } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Table.js'; import type { Column } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Column.js'; import type { Filter } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Filter.js'; @@ -107,6 +108,7 @@ import { V1_FilterMapping } from '../../../model/packageableElements/store/relat import { V1_FilterPointer } from '../../../model/packageableElements/store/relational/mapping/V1_FilterPointer.js'; import type { TablePtr } from '../../../../../../../graph/metamodel/pure/packageableElements/service/TablePtr.js'; import { V1_transformStereotype } from './V1_DomainTransformer.js'; +import { V1_PackageableElementPointer } from '../../../model/packageableElements/V1_PackageableElement.js'; const transformRelationalDataType = ( type: RelationalDataType, @@ -429,7 +431,11 @@ export const V1_transformDatabase = ( V1_transformStereotype(stereotype), ); database.includedStores = element.includes.map( - (store) => store.valueForSerialization ?? '', + (store) => + new V1_PackageableElementPointer( + PackageableElementPointerType.STORE, + store.valueForSerialization ?? '', + ), ); return database; }; diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DomainTransformer.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DomainTransformer.ts index 35225bfcd4..6be74a31e7 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DomainTransformer.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DomainTransformer.ts @@ -29,7 +29,11 @@ import type { Class } from '../../../../../../../graph/metamodel/pure/packageabl import type { Association } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Association.js'; import type { ConcreteFunctionDefinition } from '../../../../../../../graph/metamodel/pure/packageableElements/function/ConcreteFunctionDefinition.js'; import type { Property } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Property.js'; -import { V1_Profile } from '../../../model/packageableElements/domain/V1_Profile.js'; +import { + V1_Profile, + V1_ProfileStereotype, + V1_ProfileTag, +} from '../../../model/packageableElements/domain/V1_Profile.js'; import { V1_StereotypePtr } from '../../../model/packageableElements/domain/V1_StereotypePtr.js'; import { V1_initPackageableElement, @@ -73,6 +77,7 @@ import { V1_transformTestAssertion } from './V1_TestTransformer.js'; import { V1_DefaultValue } from '../../../model/packageableElements/domain/V1_DefaultValue.js'; import { PackageableElementPointerType } from '../../../../../../../graph/MetaModelConst.js'; import { V1_createGenericTypeWithElementPath } from '../../../helpers/V1_DomainHelper.js'; +import { V1_PackageableElementPointer } from '../../../model/packageableElements/V1_PackageableElement.js'; export const V1_createRawGenericTypeWithElementPath = ( path: string, @@ -87,8 +92,10 @@ export const V1_createRawGenericTypeWithElementPath = ( export const V1_transformProfile = (element: Profile): V1_Profile => { const profile = new V1_Profile(); V1_initPackageableElement(profile, element); - profile.stereotypes = element.p_stereotypes.map((s) => s.value); - profile.tags = element.p_tags.map((t) => t.value); + profile.stereotypes = element.p_stereotypes.map( + (s) => new V1_ProfileStereotype(s.value), + ); + profile.tags = element.p_tags.map((t) => new V1_ProfileTag(t.value)); return profile; }; @@ -238,7 +245,11 @@ export const V1_transformClass = ( _class.stereotypes = element.stereotypes.map(V1_transformStereotype); _class.taggedValues = element.taggedValues.map(V1_transformTaggedValue); _class.superTypes = element.generalizations.map( - (e) => e.ownerReference.valueForSerialization ?? '', + (e) => + new V1_PackageableElementPointer( + PackageableElementPointerType.CLASS, + e.ownerReference.valueForSerialization ?? '', + ), ); _class.derivedProperties = element.derivedProperties.map((dp) => transformDerivedProperty(dp, context), diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_MappingTransformer.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_MappingTransformer.ts index 61fc193827..a77eb9e6c9 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_MappingTransformer.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_MappingTransformer.ts @@ -174,6 +174,7 @@ import { INTERNAL__UnknownPropertyMapping } from '../../../../../../../graph/met import { V1_INTERNAL__UnknownPropertyMapping } from '../../../model/packageableElements/mapping/V1_INTERNAL__UnknownPropertyMapping.js'; import type { INTERNAL__UnknownSetImplementation } from '../../../../../../../graph/metamodel/pure/packageableElements/mapping/INTERNAL__UnknownSetImplementation.js'; import { V1_INTERNAL__UnknownClassMapping } from '../../../model/packageableElements/mapping/V1_INTERNAL__UnknownClassMapping.js'; +import { V1_PackageableElementPointer } from '../../../model/packageableElements/V1_PackageableElement.js'; export const V1_transformPropertyReference = ( element: PropertyReference, @@ -245,8 +246,10 @@ const transformEnumerationMapping = ( enumerationMapping.enumValueMappings = element.enumValueMappings .filter((e) => !isStubbed_EnumValueMapping(e)) .map(transformEnumValueMapping); - enumerationMapping.enumeration = - element.enumeration.valueForSerialization ?? ''; + enumerationMapping.enumeration = new V1_PackageableElementPointer( + PackageableElementPointerType.ENUMERATION, + element.enumeration.valueForSerialization ?? '', + ); enumerationMapping.id = mappingElementIdSerializer(element.id); return enumerationMapping; }; @@ -358,7 +361,10 @@ const transformMappingStoreTestData = ( ): V1_MappingStoreTestData => { const testData = new V1_MappingStoreTestData(); testData.data = V1_transformEmbeddedData(element.data, context); - testData.store = element.store.valueForSerialization ?? ''; + testData.store = new V1_PackageableElementPointer( + PackageableElementPointerType.STORE, + element.store.valueForSerialization ?? '', + ); return testData; }; @@ -1307,8 +1313,10 @@ const transformRelationalAssociationImplementation = ( relationalMapping.stores = element.stores.map( (store) => store.valueForSerialization ?? '', ); - relationalMapping.association = - element.association.valueForSerialization ?? ''; + relationalMapping.association = new V1_PackageableElementPointer( + PackageableElementPointerType.ASSOCIATION, + element.association.valueForSerialization ?? '', + ); relationalMapping.propertyMappings = transformClassMappingPropertyMappings( element.propertyMappings, true, @@ -1326,8 +1334,10 @@ const transformFlatDataAssociationImplementation = ( flatDataAssociationMapping.stores = element.stores.map( (store) => store.valueForSerialization ?? '', ); - flatDataAssociationMapping.association = - element.association.valueForSerialization ?? ''; + flatDataAssociationMapping.association = new V1_PackageableElementPointer( + PackageableElementPointerType.ASSOCIATION, + element.association.valueForSerialization ?? '', + ); flatDataAssociationMapping.propertyMappings = transformClassMappingPropertyMappings( element.propertyMappings, @@ -1346,7 +1356,10 @@ const transformXStorelAssociationImplementation = ( xStoreMapping.stores = element.stores.map( (store) => store.valueForSerialization ?? '', ); - xStoreMapping.association = element.association.valueForSerialization ?? ''; + xStoreMapping.association = new V1_PackageableElementPointer( + PackageableElementPointerType.ASSOCIATION, + element.association.valueForSerialization ?? '', + ); xStoreMapping.propertyMappings = transformClassMappingPropertyMappings( element.propertyMappings, false, diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.ts index 17531d06ca..550d99ad94 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.ts @@ -240,7 +240,8 @@ export class V1_ElementSecondPassBuilder V1_buildFullPath(element.package, element.name), ); const uniqueStereotypes = new Set(); - profile.p_stereotypes = element.stereotypes.map((stereotype) => { + profile.p_stereotypes = element.stereotypes.map((stereotypeV) => { + const stereotype = stereotypeV.value; if (uniqueStereotypes.has(stereotype)) { const message = `Found duplicated stereotype '${stereotype}' in profile '${element.path}'`; /** @@ -258,7 +259,8 @@ export class V1_ElementSecondPassBuilder return new Stereotype(profile, stereotype); }); const uniqueTags = new Set(); - profile.p_tags = element.tags.map((tag) => { + profile.p_tags = element.tags.map((tagV) => { + const tag = tagV.value; if (uniqueTags.has(tag)) { const message = `Found duplicated tag '${tag}' in profile '${element.path}'`; /** @@ -408,7 +410,7 @@ export class V1_ElementSecondPassBuilder V1_buildFullPath(element.package, element.name), ); database.includes = element.includedStores.map((includedStore) => - this.context.resolveDatabase(includedStore), + this.context.resolveDatabase(includedStore.path), ); database.schemas = element.schemas.map((schema) => V1_buildSchema(schema, database, this.context), diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementThirdPassBuilder.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementThirdPassBuilder.ts index 5f838b3e95..e70841c042 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementThirdPassBuilder.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementThirdPassBuilder.ts @@ -132,7 +132,8 @@ export class V1_ElementThirdPassBuilder const _class = this.context.currentSubGraph.getOwnClass( V1_buildFullPath(element.package, element.name), ); - element.superTypes.forEach((type) => { + element.superTypes.forEach((pointer) => { + const type = pointer.path; // supertype `Any` will not be processed if (type !== CORE_PURE_PATH.ANY) { try { diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_AssociationMappingHelper.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_AssociationMappingHelper.ts index 9cefb02284..8d2c864a01 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_AssociationMappingHelper.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_AssociationMappingHelper.ts @@ -55,7 +55,7 @@ const buildRelationalAssociationMapping = ( ] .map((m) => m.classMappings) .flat(); - const association = context.resolveAssociation(element.association); + const association = context.resolveAssociation(element.association.path); const relationalAssociationImplementation = new RelationalAssociationImplementation( getInferredAssociationMappingId(association.value, element), @@ -92,7 +92,7 @@ const buildFlatDataAssociationMapping = ( ] .map((m) => m.classMappings) .flat(); - const association = context.resolveAssociation(element.association); + const association = context.resolveAssociation(element.association.path); const flatDataAssociationImplementation = new FlatDataAssociationImplementation( getInferredAssociationMappingId(association.value, element), @@ -129,7 +129,7 @@ const buildXStoreAssociationMapping = ( ] .map((m) => m.classMappings) .flat(); - const association = context.resolveAssociation(element.association); + const association = context.resolveAssociation(element.association.path); const xStoreAssociationImplementation = new XStoreAssociationImplementation( getInferredAssociationMappingId(association.value, element), parentMapping, diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_MappingBuilderHelper.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_MappingBuilderHelper.ts index 5bd476d53c..413360a259 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_MappingBuilderHelper.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_MappingBuilderHelper.ts @@ -154,11 +154,11 @@ export const V1_buildEnumerationMapping = ( parentMapping: Mapping, ): EnumerationMapping => { assertNonEmptyString( - srcEnumerationMapping.enumeration, + srcEnumerationMapping.enumeration.path, `Enumeration mapping 'enumeration' field is missing or empty`, ); const targetEnumeration = context.resolveEnumeration( - srcEnumerationMapping.enumeration, + srcEnumerationMapping.enumeration.path, ); const possibleSourceTypes = new Set( srcEnumerationMapping.enumValueMappings.flatMap((enumValueMapping) => @@ -246,12 +246,12 @@ const buildMappingStoreTestData = ( context: V1_GraphBuilderContext, ): StoreTestData => { const mappingStoreTestData = new StoreTestData(); - if (element.store === ModelStore.NAME) { + if (element.store.path === ModelStore.NAME) { mappingStoreTestData.store = PackageableElementExplicitReference.create( ModelStore.INSTANCE, ); } else { - mappingStoreTestData.store = context.resolveStore(element.store); + mappingStoreTestData.store = context.resolveStore(element.store.path); } mappingStoreTestData.data = V1_buildEmbeddedData(element.data, context); return mappingStoreTestData; diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_CoreSerializationHelper.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_CoreSerializationHelper.ts index c4b123a65e..4e6867b686 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_CoreSerializationHelper.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_CoreSerializationHelper.ts @@ -14,10 +14,12 @@ * limitations under the License. */ -import { primitive, createModelSchema, optional } from 'serializr'; +import { primitive, createModelSchema, optional, deserialize } from 'serializr'; import { SerializationFactory, + isString, optionalCustomUsingModelSchema, + type PlainObject, } from '@finos/legend-shared'; import { V1_Multiplicity } from '../../../model/packageableElements/domain/V1_Multiplicity.js'; import { V1_PackageableElementPointer } from '../../../model/packageableElements/V1_PackageableElement.js'; @@ -61,3 +63,14 @@ export const V1_multiplicityModelSchema = createModelSchema(V1_Multiplicity, { lowerBound: primitive(), upperBound: optional(primitive()), }); + +export const V1_serializePackageableElementPointer = ( + json: PlainObject | string, + type?: string | undefined, +): V1_PackageableElementPointer => { + // For backward compatible: see https://github.com/finos/legend-engine/pull/2621 + if (isString(json)) { + return new V1_PackageableElementPointer(type, json); + } + return deserialize(V1_packageableElementPointerModelSchema, json); +}; diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DatabaseSerializationHelper.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DatabaseSerializationHelper.ts index 55c53a169e..147a2db64a 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DatabaseSerializationHelper.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DatabaseSerializationHelper.ts @@ -97,6 +97,12 @@ import { V1_serializeDatasourceSpecification, } from './V1_ConnectionSerializationHelper.js'; import { V1_stereotypePtrModelSchema } from './V1_DomainSerializationHelper.js'; +import type { V1_PackageableElementPointer } from '../../../model/packageableElements/V1_PackageableElement.js'; +import { + V1_packageableElementPointerModelSchema, + V1_serializePackageableElementPointer, +} from './V1_CoreSerializationHelper.js'; +import { PackageableElementPointerType } from '../../../../../../../graph/MetaModelConst.js'; export const V1_DATABASE_ELEMENT_PROTOCOL_TYPE = 'relational'; @@ -547,6 +553,9 @@ const V1_setupRelationalDatabaseConnectionModelSchema = ( postProcessors: customList( (value: V1_PostProcessor) => V1_serializePostProcessor(value, plugins), (value) => V1_deserializePostProcessor(value, plugins), + { + INTERNAL__forceReturnEmptyInTest: true, + }, ), postProcessorWithParameter: customEquivalentList({ INTERNAL__forceReturnEmptyInTest: true, @@ -565,7 +574,17 @@ export const V1_setupDatabaseSerialization = ( export const V1_databaseModelSchema = createModelSchema(V1_Database, { _type: usingConstantValueSchema(V1_DATABASE_ELEMENT_PROTOCOL_TYPE), filters: list(usingModelSchema(V1_filterModelSchema)), - includedStores: list(primitive()), + includedStores: customList( + (val: V1_PackageableElementPointer) => + serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.STORE, + ), + + { INTERNAL__forceReturnEmptyInTest: true }, + ), joins: list(usingModelSchema(V1_joinModelSchema)), name: primitive(), package: primitive(), diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DomainSerializationHelper.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DomainSerializationHelper.ts index a4c53ddce2..384ae5eca0 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DomainSerializationHelper.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DomainSerializationHelper.ts @@ -25,21 +25,28 @@ import { type ModelSchema, serialize, custom, + deserialize, } from 'serializr'; import { - customEquivalentList, customList, customListWithSchema, optionalCustom, usingConstantValueSchema, usingModelSchema, + isString, + type PlainObject, } from '@finos/legend-shared'; import { V1_multiplicityModelSchema, V1_packageableElementPointerModelSchema, + V1_serializePackageableElementPointer, } from '../../../transformation/pureProtocol/serializationHelpers/V1_CoreSerializationHelper.js'; import { V1_Enumeration } from '../../../model/packageableElements/domain/V1_Enumeration.js'; -import { V1_Profile } from '../../../model/packageableElements/domain/V1_Profile.js'; +import { + V1_Profile, + V1_ProfileStereotype, + V1_ProfileTag, +} from '../../../model/packageableElements/domain/V1_Profile.js'; import { V1_Measure, V1_Unit, @@ -82,6 +89,8 @@ import { V1_deserializeGenericType, V1_GenericTypeModelSchema, } from './V1_TypeSerializationHelper.js'; +import { PackageableElementPointerType } from '../../../../../../../graph/MetaModelConst.js'; +import type { V1_PackageableElementPointer } from '../../../model/packageableElements/V1_PackageableElement.js'; export const V1_CLASS_ELEMENT_PROTOCOL_TYPE = 'class'; export const V1_PROFILE_ELEMENT_PROTOCOL_TYPE = 'profile'; @@ -118,12 +127,48 @@ export const V1_taggedValueModelSchema = createModelSchema(V1_TaggedValue, { value: primitive(), }); +const V1_ProfileStereotypeSchema = createModelSchema(V1_ProfileStereotype, { + value: primitive(), +}); + +const V1_ProfileTagSchema = createModelSchema(V1_ProfileTag, { + value: primitive(), +}); + +export const V1_serializeProfileStereotypeSchema = ( + json: PlainObject | string, +): V1_ProfileTag => { + if (isString(json)) { + return new V1_ProfileStereotype(json); + } + return deserialize(V1_ProfileStereotypeSchema, json); +}; + +export const V1_serializeProfileTagSchema = ( + json: PlainObject | string, +): V1_ProfileTag => { + if (isString(json)) { + return new V1_ProfileTag(json); + } + return deserialize(V1_ProfileTagSchema, json); +}; + export const V1_profileModelSchema = createModelSchema(V1_Profile, { _type: usingConstantValueSchema(V1_PROFILE_ELEMENT_PROTOCOL_TYPE), name: primitive(), package: primitive(), - stereotypes: list(primitive()), - tags: list(primitive()), + stereotypes: customList( + (val: V1_ProfileStereotype) => serialize(V1_ProfileStereotypeSchema, val), + (val) => V1_serializeProfileStereotypeSchema(val), + + { INTERNAL__forceReturnEmptyInTest: true }, + ), + tags: customList( + (val: V1_ProfileTag) => serialize(V1_ProfileTagSchema, val), + (val) => V1_serializeProfileTagSchema(val), + + { INTERNAL__forceReturnEmptyInTest: true }, + ), }); // ------------------------------------- Enumeration ------------------------------------- @@ -330,9 +375,17 @@ export const V1_classModelSchema = createModelSchema(V1_Class, { stereotypes: customListWithSchema(V1_stereotypePtrModelSchema, { INTERNAL__forceReturnEmptyInTest: true, }), - superTypes: customEquivalentList({ - INTERNAL__forceReturnEmptyInTest: true, - }), + superTypes: customList( + (val: V1_PackageableElementPointer) => + serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.DATA, + ), + + { INTERNAL__forceReturnEmptyInTest: true }, + ), taggedValues: customListWithSchema(V1_taggedValueModelSchema, { INTERNAL__forceReturnEmptyInTest: true, }), diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_MappingSerializationHelper.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_MappingSerializationHelper.ts index a7e757f79d..bc2e98b048 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_MappingSerializationHelper.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_MappingSerializationHelper.ts @@ -46,6 +46,7 @@ import { ATOMIC_TEST_TYPE, PRIMITIVE_TYPE, ELEMENT_PATH_DELIMITER, + PackageableElementPointerType, } from '../../../../../../../graph/MetaModelConst.js'; import { V1_Mapping } from '../../../model/packageableElements/mapping/V1_Mapping.js'; import { @@ -60,6 +61,7 @@ import { import { V1_multiplicityModelSchema, V1_packageableElementPointerModelSchema, + V1_serializePackageableElementPointer, } from '../../../transformation/pureProtocol/serializationHelpers/V1_CoreSerializationHelper.js'; import { V1_propertyPointerModelSchema } from './V1_DomainSerializationHelper.js'; import type { V1_AssociationMapping } from '../../../model/packageableElements/mapping/V1_AssociationMapping.js'; @@ -878,7 +880,14 @@ export const V1_mappingStoreTestDataModelSchema = ( (val) => V1_serializeEmbeddedDataType(val, plugins), (val) => V1_deserializeEmbeddedDataType(val, plugins), ), - store: primitive(), + store: custom( + (val) => serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.STORE, + ), + ), }); export const V1_mappingTestModelSchema = ( @@ -952,7 +961,14 @@ const relationalAssociationMappingModelschema = createModelSchema( V1_RelationalAssociationMapping, { _type: usingConstantValueSchema(V1_AssociationMappingType.RELATIONAL), - association: primitive(), + association: custom( + (val) => serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.ASSOCIATION, + ), + ), id: optional(primitive()), propertyMappings: list( custom( @@ -968,7 +984,14 @@ const flatDataAssociationMappingModelschema = createModelSchema( V1_FlatDataAssociationMapping, { _type: usingConstantValueSchema(V1_AssociationMappingType.FLAT_DATA), - association: primitive(), + association: custom( + (val) => serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.ASSOCIATION, + ), + ), id: optional(primitive()), propertyMappings: list( custom( @@ -984,7 +1007,14 @@ const xStoreAssociationMappingModelschema = createModelSchema( V1_XStoreAssociationMapping, { _type: usingConstantValueSchema(V1_AssociationMappingType.XSTORE), - association: primitive(), + association: custom( + (val) => serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.ASSOCIATION, + ), + ), id: optional(primitive()), propertyMappings: list( custom( @@ -1167,7 +1197,14 @@ const V1_enumerationMappingModelSchema = createModelSchema( ), ), ), - enumeration: primitive(), + enumeration: custom( + (val) => serialize(V1_packageableElementPointerModelSchema, val), + (val) => + V1_serializePackageableElementPointer( + val, + PackageableElementPointerType.ENUMERATION, + ), + ), id: optional(primitive()), }, ); diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_RawValueSpecificationSerializationHelper.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_RawValueSpecificationSerializationHelper.ts index 27056ebda9..a4c679cad5 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_RawValueSpecificationSerializationHelper.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_RawValueSpecificationSerializationHelper.ts @@ -23,6 +23,7 @@ import { custom, alias, optional, + SKIP, } from 'serializr'; import { type PlainObject, @@ -98,7 +99,14 @@ const V1_RawGenericTypeSchemaModelInner = createModelSchema(V1_RawGenericType, { INTERNAL__forceReturnEmptyInTest: true, }, ), - // typeVariableValues: TODO + typeVariableValues: optionalCustomList( + // TODO + (value) => SKIP, + (value) => SKIP, + { + INTERNAL__forceReturnEmptyInTest: true, + }, + ), }); const V1_RawGenericTypeSchemaModel = createModelSchema(V1_RawGenericType, { @@ -116,7 +124,14 @@ const V1_RawGenericTypeSchemaModel = createModelSchema(V1_RawGenericType, { INTERNAL__forceReturnEmptyInTest: true, }, ), - // typeVariableValues: TODO + typeVariableValues: optionalCustomList( + // TODO + (value) => SKIP, + (value) => SKIP, + { + INTERNAL__forceReturnEmptyInTest: true, + }, + ), }); const V1_deserializeRawGenericType = ( diff --git a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_TypeSerializationHelper.ts b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_TypeSerializationHelper.ts index 7d0de5ee46..c61dc5b465 100644 --- a/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_TypeSerializationHelper.ts +++ b/packages/legend-graph/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_TypeSerializationHelper.ts @@ -21,6 +21,7 @@ import { list, primitive, serialize, + SKIP, } from 'serializr'; import { V1_GenericType } from '../../../model/packageableElements/type/V1_GenericType.js'; import { V1_PackageableType } from '../../../model/packageableElements/type/V1_PackageableType.js'; @@ -109,7 +110,14 @@ export const V1_GenericTypeModelSchema = createModelSchema(V1_GenericType, { INTERNAL__forceReturnEmptyInTest: true, }, ), - // typeVariableValues: TODO + typeVariableValues: optionalCustomList( + // TODO + (value) => SKIP, + (value) => SKIP, + { + INTERNAL__forceReturnEmptyInTest: true, + }, + ), }); const appendAnyGenericType = (current: V1_GenericType): void => { diff --git a/packages/legend-graph/src/graph/MetaModelConst.ts b/packages/legend-graph/src/graph/MetaModelConst.ts index 5474292ad7..f87b8194c3 100644 --- a/packages/legend-graph/src/graph/MetaModelConst.ts +++ b/packages/legend-graph/src/graph/MetaModelConst.ts @@ -161,6 +161,9 @@ export enum PackageableElementPointerType { FILE_GENERATION = 'FILE_GENERATION', SERVICE = 'SERVICE', DATA = 'DATA', + ENUMERATION = 'ENUMERATION', + ASSOCIATION = 'ASSOCIATION', + BINDING = 'BINDING', } export enum SUPPORTED_FUNCTIONS { diff --git a/packages/legend-manual-tests/src/__tests__/roundtrip-grammar/RoundtripGrammar.engine-roundtrip-test.ts b/packages/legend-manual-tests/src/__tests__/roundtrip-grammar/RoundtripGrammar.engine-roundtrip-test.ts index a2d57ca159..df72b1f1ac 100644 --- a/packages/legend-manual-tests/src/__tests__/roundtrip-grammar/RoundtripGrammar.engine-roundtrip-test.ts +++ b/packages/legend-manual-tests/src/__tests__/roundtrip-grammar/RoundtripGrammar.engine-roundtrip-test.ts @@ -305,6 +305,7 @@ const cases: [string, string, boolean][] = fs .readdirSync(TEST_CASE_DIR) .map((caseName) => resolve(TEST_CASE_DIR, caseName)) .filter((filePath) => fs.statSync(filePath).isFile()) + // .filter((filePath) => basename(filePath) === 'DSL_PersistenceV2-basic.pure') .map((filePath) => [ testNameFrom(filePath), filePath, @@ -315,7 +316,7 @@ describe('Grammar roundtrip test', () => { test.each(cases)('%s', async (testName, filePath, isSkipped) => { if (!isSkipped) { await checkGrammarRoundtrip(testName, filePath, { - debug: false, + debug: true, }); } });