Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle type args fixes #3705

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/soft-candles-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
'@finos/legend-extension-dsl-persistence': patch
'@finos/legend-graph': patch
---
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
};

Expand All @@ -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;
};

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Database>;
return sink;
Expand All @@ -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<Binding>;
return sink;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ import {
V1_externalFormatDataModelSchema,
V1_serializeAtomicTest,
V1_deserializeAtomicTest,
V1_packageableElementPointerModelSchema,
V1_serializePackageableElementPointer,
PackageableElementPointerType,
} from '@finos/legend-graph';
import {
type PlainObject,
Expand Down Expand Up @@ -777,15 +780,29 @@ const V1_relationalSinkModelSchema = (
): ModelSchema<V1_RelationalSink> =>
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 = (
plugins: PureProtocolProcessorPlugin[],
): ModelSchema<V1_ObjectStorageSink> =>
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 = (
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ 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';
import type { V1_Constraint } from '../../../model/packageableElements/domain/V1_Constraint.js';
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[] = [];
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
}
Loading
Loading