@itwin/ecschema-editing 5.2.0-dev.31 → 5.2.0-dev.33
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.
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js +2 -8
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +1 -1
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/esm/Differencing/SchemaDifferenceValidator.js +2 -8
- package/lib/esm/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/esm/Merging/SchemaMerger.js +1 -1
- package/lib/esm/Merging/SchemaMerger.js.map +1 -1
- package/package.json +9 -9
|
@@ -86,7 +86,7 @@ class SchemaDifferenceValidationVisitor {
|
|
|
86
86
|
}
|
|
87
87
|
const sourceSchemaKey = sourceSchemaReference.schemaKey;
|
|
88
88
|
const targetSchemaKey = targetSchemaReference.schemaKey;
|
|
89
|
-
if (
|
|
89
|
+
if (targetSchemaReference.isDynamic !== sourceSchemaReference.isDynamic) {
|
|
90
90
|
return this.addConflict({
|
|
91
91
|
code: SchemaConflicts_1.ConflictCode.ConflictingReferenceDynamic,
|
|
92
92
|
difference: entry,
|
|
@@ -95,7 +95,7 @@ class SchemaDifferenceValidationVisitor {
|
|
|
95
95
|
target: targetSchemaKey.toString(),
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
-
if (entry.changeType === "modify" && !
|
|
98
|
+
if (entry.changeType === "modify" && !targetSchemaReference.isDynamic && !areCompatible(sourceSchemaKey, targetSchemaKey)) {
|
|
99
99
|
return this.addConflict({
|
|
100
100
|
code: SchemaConflicts_1.ConflictCode.ConflictingReferenceVersion,
|
|
101
101
|
difference: entry,
|
|
@@ -535,12 +535,6 @@ function resolvePropertyTypeName(property) {
|
|
|
535
535
|
return `${prefix}${property.relationshipClass.fullName}${suffix}`;
|
|
536
536
|
return (0, ecschema_metadata_1.propertyTypeToString)(property.propertyType);
|
|
537
537
|
}
|
|
538
|
-
/**
|
|
539
|
-
* Checks if a schema is dynamic.
|
|
540
|
-
*/
|
|
541
|
-
function isDynamicSchema(schema) {
|
|
542
|
-
return schema.customAttributes !== undefined && schema.customAttributes.has("CoreCustomAttributes.DynamicSchema");
|
|
543
|
-
}
|
|
544
538
|
/**
|
|
545
539
|
* Checks if the two schemas are compatible. Since the merger will eventually take the most
|
|
546
540
|
* recent schema version, it is sufficient to check if they are write compatible in one direction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaDifferenceValidator.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAiBH,kDAOC;AAtBD,gEAAwU;AAExU,uDAA8E;AAC9E,uEAA4F;AAC5F,8DAAwE;AAExE;;;;;;;;GAQG;AACI,KAAK,UAAU,mBAAmB,CAAC,WAAkC,EAAE,YAAoB,EAAE,YAAoB,EAAE,YAAyB;IACjJ,MAAM,OAAO,GAAG,IAAI,iCAAiC,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAChG,MAAM,MAAM,GAAG,IAAI,gDAAsB,CAAC,OAAO,CAAC,CAAC;IAEnD,MAAM,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEnC,OAAO,OAAO,CAAC,SAAS,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,iCAAiC;IAErB,SAAS,CAAqC;IAC7C,aAAa,CAAS;IACtB,aAAa,CAAS;IACtB,aAAa,CAAc;IAE5C,6EAA6E;IAC7E,YAAY,YAAoB,EAAE,YAAoB,EAAE,YAAyB;QAC/E,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;I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AE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACpE,IAAI,QAAQ,CAAC,aAAa,EAAE;QAC1B,OAAO,GAAG,MAAM,GAAG,uBAAuB,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,MAAM,EAAE,CAAC;IAC9E,IAAI,QAAQ,CAAC,WAAW,EAAE;QACxB,OAAO,GAAG,MAAM,GAAG,IAAA,yCAAqB,EAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,MAAM,EAAE,CAAC;IAC9E,IAAI,QAAQ,CAAC,QAAQ,EAAE;QACrB,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC;IAC9D,IAAI,QAAQ,CAAC,YAAY,EAAE;QACzB,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC;IACpE,OAAO,IAAA,wCAAoB,EAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,MAAc;IACrC,OAAO,MAAM,CAAC,gBAAgB,KAAK,SAAS,IAAI,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AACpH,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,aAAwB,EAAE,cAAyB;IACxE,OAAO,aAAa,CAAC,OAAO,CAAC,cAAc,EAAE,mCAAe,CAAC,qBAAqB,CAAC;WAC5E,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,mCAAe,CAAC,qBAAqB,CAAC,CAAC;AACtF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Differencing\n */\n\nimport { classModifierToString, ECClass, ECClassModifier, EntityClass, Enumeration, Format, InvertedUnit, KindOfQuantity, LazyLoadedSchemaItem, Mixin, parseClassModifier, primitiveTypeToString, Property, propertyTypeToString, Schema, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType, Unit } from \"@itwin/ecschema-metadata\";\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from \"./SchemaDifference\";\nimport { AnySchemaDifferenceConflict, ConflictCode } from \"./SchemaConflicts\";\nimport { SchemaDifferenceVisitor, SchemaDifferenceWalker } from \"./SchemaDifferenceVisitor\";\nimport { NameMapping, PropertyKey } from \"../Merging/Edits/NameMapping\";\n\n/**\n * Validates the given array of schema differences and returns a list of conflicts if the\n * validation finds violation against rules.\n * @param differences An array of schema differences.\n * @param targetSchema The target schema reference.\n * @param sourceSchema The source schema reference.\n * @returns An array of conflicts found when validating the difference.\n * @internal\n */\nexport async function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema, nameMappings);\n const walker = new SchemaDifferenceWalker(visitor);\n\n await walker.traverse(differences);\n\n return visitor.conflicts;\n}\n\n/**\n * The SchemaDifferenceValidationVisitor class is an implementation of ISchemaDifferenceVisitor and\n * validates the given SchemaDifferences if the violate against some EC Rules.\n */\nclass SchemaDifferenceValidationVisitor implements SchemaDifferenceVisitor {\n\n public readonly conflicts: Array<AnySchemaDifferenceConflict>;\n private readonly _sourceSchema: Schema;\n private readonly _targetSchema: Schema;\n private readonly _nameMappings: NameMapping;\n\n /** Initializes a new instance of SchemaDifferenceValidationVisitor class. */\n constructor(targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n this.conflicts = [];\n this._targetSchema = targetSchema;\n this._sourceSchema = sourceSchema;\n this._nameMappings = nameMappings;\n }\n\n private addConflict(conflict: AnySchemaDifferenceConflict) {\n this.conflicts.push(conflict);\n }\n\n private async getTargetSchemaItem(name: string): Promise<SchemaItem | undefined> {\n const itemKey = new SchemaItemKey(name, this._sourceSchema.schemaKey);\n const mappedKey = this._nameMappings.resolveItemKey(itemKey);\n return this._targetSchema.getItem(mappedKey.name);\n }\n\n private getTargetProperty(itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, this._sourceSchema.schemaKey);\n const propertyKey = new PropertyKey(propertyName, classKey);\n return this._nameMappings.resolvePropertyKey(propertyKey);\n }\n\n /**\n * Visitor implementation for handling SchemaDifference.\n * @internal\n */\n public async visitSchemaDifference(_entry: SchemaDifference) {\n }\n\n /**\n * Visitor implementation for handling SchemaReferenceDifference.\n * @internal\n */\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference) {\n const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name) as Schema;\n const targetSchemaReferenceName = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);\n if (targetSchemaReferenceName && targetSchemaReferenceName !== sourceSchemaReference.name) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceAlias,\n difference: entry,\n source: entry.difference.name,\n target: targetSchemaReferenceName,\n description: \"Target schema already references a different schema with this alias.\",\n });\n }\n\n // The targetSchemaReference can be undefined, if the reference will be added by the source schema.\n // In this case further validation is not needed.\n const targetSchemaReference = await this._targetSchema.getReference(entry.difference.name);\n if(targetSchemaReference === undefined) {\n return;\n }\n\n const sourceSchemaKey = sourceSchemaReference.schemaKey;\n const targetSchemaKey = targetSchemaReference.schemaKey;\n\n if(isDynamicSchema(targetSchemaReference) !== isDynamicSchema(sourceSchemaReference)) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceDynamic,\n difference: entry,\n description: \"Cannot update a schema reference to or from a dynamic schema.\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n\n if(entry.changeType === \"modify\" && !isDynamicSchema(targetSchemaReference) && !areCompatible(sourceSchemaKey, targetSchemaKey)) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceVersion,\n difference: entry,\n description: \"Schema reference cannot be updated, incompatible versions\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n }\n\n /**\n * Shared schema item validation for all types of AnySchemaItemDifference union.\n */\n private async visitSchemaItemDifference(entry: AnySchemaItemDifference, targetSchemaItem: SchemaItem | undefined) {\n // If the item shall be added, but the target schema already has an item with this name,\n // will produce an ConflictingItemName conflict.\n if (entry.changeType === \"add\" && targetSchemaItem !== undefined) {\n this.addConflict({\n code: ConflictCode.ConflictingItemName,\n difference: entry,\n source: entry.schemaType,\n target: targetSchemaItem.schemaItemType,\n description: \"Target schema already contains a schema item with the name but different type.\",\n });\n return false;\n }\n\n return true;\n }\n\n /**\n * Shared base-class validation for all types of ClassItemDifference union.\n */\n private async visitBaseClassDifference(entry: AnyClassItemDifference, targetClassItem: ECClass) {\n if (\"baseClass\" in entry.difference && entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {\n return this.addConflict({\n code: ConflictCode.RemovingBaseClass,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass cannot be removed, if there has been a baseClass before.\",\n });\n }\n\n if (entry.difference.baseClass === undefined) {\n return;\n }\n\n const sourceBaseClass = await this._sourceSchema.lookupItem(entry.difference.baseClass) as ECClass;\n if (sourceBaseClass.modifier === ECClassModifier.Sealed) {\n return this.addConflict({\n code: ConflictCode.SealedBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass) || null,\n description: \"BaseClass is sealed.\",\n });\n }\n\n if (targetClassItem.baseClass && !await this.derivedFrom(sourceBaseClass, targetClassItem.baseClass)) {\n return this.addConflict({\n code: ConflictCode.ConflictingBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass is not valid, source class must derive from target.\",\n });\n }\n }\n\n /**\n * Shared validation for all types of ClassItemDifference union.\n */\n private async visitClassDifference(entry: AnyClassItemDifference) {\n const targetClassItem = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && ECClass.isECClass(targetClassItem)) {\n await this.visitClassModifierDifference(entry, targetClassItem);\n await this.visitBaseClassDifference(entry, targetClassItem);\n }\n }\n\n /**\n * Validation the modifiers of all types of ClassItemDifference union.\n */\n private async visitClassModifierDifference(entry: AnyClassItemDifference, targetClass: ECClass) {\n if (entry.difference.modifier) {\n const changedModifier = parseClassModifier(entry.difference.modifier);\n if (changedModifier !== undefined && changedModifier !== ECClassModifier.None) {\n this.addConflict({\n code: ConflictCode.ConflictingClassModifier,\n difference: entry,\n source: entry.difference.modifier,\n target: classModifierToString(targetClass.modifier),\n description: \"Class has conflicting modifiers.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling ConstantDifference.\n * @internal\n */\n public async visitConstantDifference(entry: ConstantDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling CustomAttributeClassDifference.\n * @internal\n */\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling CustomAttributeDifference.\n * @internal\n */\n public async visitCustomAttributeInstanceDifference(_entry: CustomAttributeDifference) {\n }\n\n /**\n * Visitor implementation for handling EntityClassDifference.\n * @internal\n */\n public async visitEntityClassDifference(entry: EntityClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling EntityClassMixinDifference.\n * @internal\n */\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference) {\n for (const addedMixin of entry.difference) {\n // To validate the added mixins, the instance from the source schema it fetched,\n // otherwise validation gets too complicated as the mixin must not be existing in\n // the current target schema, it could also be added to the schema.\n const sourceMixin = await this._sourceSchema.lookupItem(addedMixin) as Mixin;\n const sourceSchemaItem = await this._sourceSchema.getItem(entry.itemName) as EntityClass;\n if (sourceMixin.appliesTo && !await sourceSchemaItem.is(await sourceMixin.appliesTo)) {\n this.addConflict({\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\n difference: entry,\n source: addedMixin,\n target: undefined,\n description: \"Mixin cannot applied to this class.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumerationDifference.\n * @internal\n */\n public async visitEnumerationDifference(entry: EnumerationDifference) {\n const enumeration = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, enumeration)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && Enumeration.isEnumeration(enumeration) && enumeration.type !== undefined) {\n if (entry.difference.type) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumerationType,\n difference: entry,\n source: entry.difference.type,\n target: primitiveTypeToString(enumeration.type),\n description: \"Enumeration has a different primitive type.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumeratorDifference.\n * @internal\n */\n public async visitEnumeratorDifference(entry: EnumeratorDifference) {\n if (entry.changeType !== \"modify\") {\n return;\n }\n\n const enumeration = await this.getTargetSchemaItem(entry.itemName) as Enumeration;\n const enumerator = enumeration.getEnumeratorByName(entry.path);\n if (!enumerator) {\n return;\n }\n\n if (entry.difference.value) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumeratorValue,\n difference: entry,\n source: entry.difference.value,\n target: enumerator.value,\n description: \"Enumerators must have unique values.\",\n });\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(entry: FormatDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityDifference.\n * @internal\n */\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference) {\n const kindOfQuantity = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && KindOfQuantity.isKindOfQuantity(kindOfQuantity)) {\n if (entry.difference.persistenceUnit) {\n this.addConflict({\n code: ConflictCode.ConflictingPersistenceUnit,\n difference: entry,\n source: entry.difference.persistenceUnit,\n target: resolveLazyItemFullName(kindOfQuantity.persistenceUnit),\n description: \"Kind of Quantity has a different persistence unit.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling MixinClassDifference.\n * @internal\n */\n public async visitMixinDifference(entry: MixinClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling PhenomenonDifference.\n * @internal\n */\n public async visitPhenomenonDifference(entry: PhenomenonDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling ClassPropertyDifference.\n * @internal\n */\n public async visitPropertyDifference(entry: ClassPropertyDifference) {\n const targetClass = await this.getTargetSchemaItem(entry.itemName) as ECClass;\n const propertyKey = this.getTargetProperty(entry.itemName, entry.path);\n const targetProperty = await targetClass.getProperty(propertyKey.propertyName);\n\n const sourceClass = await this._sourceSchema.getItem(entry.itemName) as ECClass;\n const sourceProperty = await sourceClass.getProperty(entry.path) as Property;\n\n // If property shall be added but there is already a property with this name\n // in target, a ConflictingPropertyName is issued.\n if (entry.changeType === \"add\" && targetProperty !== undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyName,\n difference: entry,\n source: resolvePropertyTypeName(sourceProperty),\n target: resolvePropertyTypeName(targetProperty),\n description: \"Target class already contains a property with a different type.\",\n });\n }\n\n if (entry.changeType === \"modify\" && targetProperty !== undefined) {\n if (\"kindOfQuantity\" in entry.difference) {\n const sourceKoQ = await sourceProperty.kindOfQuantity;\n const targetKoQ = await targetProperty.kindOfQuantity;\n if(!targetKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: null,\n description: \"The kind of quantity cannot be assiged if the property did not have a kind of quantities before.\",\n });\n }\n\n if(!sourceKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The kind of quantity cannot be undefined if the property had a kind of quantities before.\",\n });\n }\n\n if (resolveLazyItemName(sourceKoQ.persistenceUnit) !== resolveLazyItemName(targetKoQ.persistenceUnit)) {\n this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantityUnit,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The property has different kind of quantities with conflicting units.\",\n });\n }\n }\n }\n }\n\n /**\n * Visitor implementation for handling PropertyCategoryDifference.\n * @internal\n */\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling RelationshipClassDifference.\n * @internal\n */\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintDifference.\n * @internal\n */\n public async visitRelationshipConstraintDifference(_entry: RelationshipConstraintDifference) {\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintClassDifference.\n * @internal\n */\n public async visitRelationshipConstraintClassDifference(_entry: RelationshipConstraintClassDifference) {\n }\n\n /**\n * Visitor implementation for handling StructClassDifference.\n * @internal\n */\n public async visitStructClassDifference(entry: StructClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling UnitDifference.\n * @internal\n */\n public async visitUnitDifference(entry: UnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling UnitSystemDifference.\n * @internal\n */\n public async visitUnitSystemDifference(entry: UnitSystemDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\n * @internal\n */\n public async visitKindOfQuantityPresentationFormatDifference(_entry: KindOfQuantityPresentationFormatDifference) {\n }\n\n /**\n * Visitor implementation for handling FormatUnitDifference.\n * @internal\n */\n public async visitFormatUnitDifference(entry: FormatUnitDifference) {\n const targetFormat = await this.getTargetSchemaItem(entry.itemName) as Format;\n\n if (targetFormat.units === undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnit,\n difference: entry,\n source: entry.difference[0].name,\n target: null,\n description: \"The unit cannot be assiged if the format did not have a unit before.\",\n });\n };\n\n const targetUnit = await targetFormat.units[0][0];\n const targetPhenomenon = InvertedUnit.isInvertedUnit(targetUnit)\n ? (await targetUnit.invertsUnit)?.phenomenon\n : targetUnit.phenomenon;\n\n const sourceUnit = await this._sourceSchema.lookupItem(entry.difference[0].name) as Unit | InvertedUnit;\n const sourcePhenomenon = InvertedUnit.isInvertedUnit(sourceUnit)\n ? (await sourceUnit.invertsUnit)?.phenomenon\n : sourceUnit.phenomenon;\n\n if (resolveLazyItemName(targetPhenomenon) !== resolveLazyItemName(sourcePhenomenon)) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnitPhenomenon,\n difference: entry,\n source: entry.difference[0].name,\n target: targetUnit.fullName,\n description: \"Format units has a different phenomenon.\",\n });\n };\n };\n\n /**\n * Visitor implementation for handling FormatUnitLabelDifference.\n * @internal\n */\n public async visitFormatUnitLabelDifference(_entry: FormatUnitLabelDifference) {\n }\n\n /**\n * Recursive synchronous function to figure whether a given class derived from\n * a class with the given baseClass name.\n */\n private async derivedFrom(ecClass: ECClass | undefined, baseClassKey: Readonly<SchemaItemKey>): Promise<boolean> {\n if (ecClass === undefined) {\n return false;\n }\n\n // First check for name which must be same in any case...\n if (ecClass.name === baseClassKey.name) {\n // ... then check if the class is in the same schema as the expected base class...\n if(ecClass.schema.name === baseClassKey.schemaName)\n return true;\n // ... if not, whether it's in the source schema, but then we expect the baseclass\n // to be in the target schema.\n if(ecClass.schema.name === this._sourceSchema.name && baseClassKey.schemaName === this._targetSchema.name)\n return true;\n }\n return this.derivedFrom(await ecClass.baseClass, baseClassKey);\n }\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemFullName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.fullName;\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.name;\n}\n\n/**\n * Helper method to resolve the type name of a property.\n * @param property The property which's type shall be resolved.\n * @returns The (full) name of the properties type.\n */\nfunction resolvePropertyTypeName(property: Property) {\n const [prefix, suffix] = property.isArray() ? [\"[\", \"]\"] : [\"\", \"\"];\n if (property.isEnumeration())\n return `${prefix}${resolveLazyItemFullName(property.enumeration)}${suffix}`;\n if (property.isPrimitive())\n return `${prefix}${primitiveTypeToString(property.primitiveType)}${suffix}`;\n if (property.isStruct())\n return `${prefix}${property.structClass.fullName}${suffix}`;\n if (property.isNavigation())\n return `${prefix}${property.relationshipClass.fullName}${suffix}`;\n return propertyTypeToString(property.propertyType);\n}\n\n/**\n * Checks if a schema is dynamic.\n */\nfunction isDynamicSchema(schema: Schema): boolean {\n return schema.customAttributes !== undefined && schema.customAttributes.has(\"CoreCustomAttributes.DynamicSchema\");\n}\n\n/**\n * Checks if the two schemas are compatible. Since the merger will eventually take the most\n * recent schema version, it is sufficient to check if they are write compatible in one direction.\n */\nfunction areCompatible(leftSchemaKey: SchemaKey, rightSchemaKey: SchemaKey): boolean {\n return leftSchemaKey.matches(rightSchemaKey, SchemaMatchType.LatestWriteCompatible)\n || rightSchemaKey.matches(leftSchemaKey, SchemaMatchType.LatestWriteCompatible);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaDifferenceValidator.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAiBH,kDAOC;AAtBD,gEAAwU;AAExU,uDAA8E;AAC9E,uEAA4F;AAC5F,8DAAwE;AAExE;;;;;;;;GAQG;AACI,KAAK,UAAU,mBAAmB,CAAC,WAAkC,EAAE,YAAoB,EAAE,YAAoB,EAAE,YAAyB;IACjJ,MAAM,OAAO,GAAG,IAAI,iCAAiC,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAChG,MAAM,MAAM,GAAG,IAAI,gDAAsB,CAAC,OAAO,CAAC,CAAC;IAEnD,MAAM,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEnC,OAAO,OAAO,CAAC,SAAS,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,iCAAiC;IAErB,SAAS,CAAqC;IAC7C,aAAa,CAAS;IACtB,aAAa,CAAS;IACtB,aAAa,CAAc;IAE5C,6EAA6E;IAC7E,YAAY,YAAoB,EAAE,YAAoB,EAAE,YAA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I,QAAQ,CAAC,IAAI,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,SAAS,uBAAuB,CAAC,QAAkB;IACjD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACpE,IAAI,QAAQ,CAAC,aAAa,EAAE;QAC1B,OAAO,GAAG,MAAM,GAAG,uBAAuB,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,MAAM,EAAE,CAAC;IAC9E,IAAI,QAAQ,CAAC,WAAW,EAAE;QACxB,OAAO,GAAG,MAAM,GAAG,IAAA,yCAAqB,EAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,MAAM,EAAE,CAAC;IAC9E,IAAI,QAAQ,CAAC,QAAQ,EAAE;QACrB,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC;IAC9D,IAAI,QAAQ,CAAC,YAAY,EAAE;QACzB,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC;IACpE,OAAO,IAAA,wCAAoB,EAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,aAAwB,EAAE,cAAyB;IACxE,OAAO,aAAa,CAAC,OAAO,CAAC,cAAc,EAAE,mCAAe,CAAC,qBAAqB,CAAC;WAC5E,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,mCAAe,CAAC,qBAAqB,CAAC,CAAC;AACtF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Differencing\n */\n\nimport { classModifierToString, ECClass, ECClassModifier, EntityClass, Enumeration, Format, InvertedUnit, KindOfQuantity, LazyLoadedSchemaItem, Mixin, parseClassModifier, primitiveTypeToString, Property, propertyTypeToString, Schema, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType, Unit } from \"@itwin/ecschema-metadata\";\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from \"./SchemaDifference\";\nimport { AnySchemaDifferenceConflict, ConflictCode } from \"./SchemaConflicts\";\nimport { SchemaDifferenceVisitor, SchemaDifferenceWalker } from \"./SchemaDifferenceVisitor\";\nimport { NameMapping, PropertyKey } from \"../Merging/Edits/NameMapping\";\n\n/**\n * Validates the given array of schema differences and returns a list of conflicts if the\n * validation finds violation against rules.\n * @param differences An array of schema differences.\n * @param targetSchema The target schema reference.\n * @param sourceSchema The source schema reference.\n * @returns An array of conflicts found when validating the difference.\n * @internal\n */\nexport async function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema, nameMappings);\n const walker = new SchemaDifferenceWalker(visitor);\n\n await walker.traverse(differences);\n\n return visitor.conflicts;\n}\n\n/**\n * The SchemaDifferenceValidationVisitor class is an implementation of ISchemaDifferenceVisitor and\n * validates the given SchemaDifferences if the violate against some EC Rules.\n */\nclass SchemaDifferenceValidationVisitor implements SchemaDifferenceVisitor {\n\n public readonly conflicts: Array<AnySchemaDifferenceConflict>;\n private readonly _sourceSchema: Schema;\n private readonly _targetSchema: Schema;\n private readonly _nameMappings: NameMapping;\n\n /** Initializes a new instance of SchemaDifferenceValidationVisitor class. */\n constructor(targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n this.conflicts = [];\n this._targetSchema = targetSchema;\n this._sourceSchema = sourceSchema;\n this._nameMappings = nameMappings;\n }\n\n private addConflict(conflict: AnySchemaDifferenceConflict) {\n this.conflicts.push(conflict);\n }\n\n private async getTargetSchemaItem(name: string): Promise<SchemaItem | undefined> {\n const itemKey = new SchemaItemKey(name, this._sourceSchema.schemaKey);\n const mappedKey = this._nameMappings.resolveItemKey(itemKey);\n return this._targetSchema.getItem(mappedKey.name);\n }\n\n private getTargetProperty(itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, this._sourceSchema.schemaKey);\n const propertyKey = new PropertyKey(propertyName, classKey);\n return this._nameMappings.resolvePropertyKey(propertyKey);\n }\n\n /**\n * Visitor implementation for handling SchemaDifference.\n * @internal\n */\n public async visitSchemaDifference(_entry: SchemaDifference) {\n }\n\n /**\n * Visitor implementation for handling SchemaReferenceDifference.\n * @internal\n */\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference) {\n const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name) as Schema;\n const targetSchemaReferenceName = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);\n if (targetSchemaReferenceName && targetSchemaReferenceName !== sourceSchemaReference.name) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceAlias,\n difference: entry,\n source: entry.difference.name,\n target: targetSchemaReferenceName,\n description: \"Target schema already references a different schema with this alias.\",\n });\n }\n\n // The targetSchemaReference can be undefined, if the reference will be added by the source schema.\n // In this case further validation is not needed.\n const targetSchemaReference = await this._targetSchema.getReference(entry.difference.name);\n if(targetSchemaReference === undefined) {\n return;\n }\n\n const sourceSchemaKey = sourceSchemaReference.schemaKey;\n const targetSchemaKey = targetSchemaReference.schemaKey;\n\n if(targetSchemaReference.isDynamic !== sourceSchemaReference.isDynamic) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceDynamic,\n difference: entry,\n description: \"Cannot update a schema reference to or from a dynamic schema.\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n\n if(entry.changeType === \"modify\" && !targetSchemaReference.isDynamic && !areCompatible(sourceSchemaKey, targetSchemaKey)) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceVersion,\n difference: entry,\n description: \"Schema reference cannot be updated, incompatible versions\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n }\n\n /**\n * Shared schema item validation for all types of AnySchemaItemDifference union.\n */\n private async visitSchemaItemDifference(entry: AnySchemaItemDifference, targetSchemaItem: SchemaItem | undefined) {\n // If the item shall be added, but the target schema already has an item with this name,\n // will produce an ConflictingItemName conflict.\n if (entry.changeType === \"add\" && targetSchemaItem !== undefined) {\n this.addConflict({\n code: ConflictCode.ConflictingItemName,\n difference: entry,\n source: entry.schemaType,\n target: targetSchemaItem.schemaItemType,\n description: \"Target schema already contains a schema item with the name but different type.\",\n });\n return false;\n }\n\n return true;\n }\n\n /**\n * Shared base-class validation for all types of ClassItemDifference union.\n */\n private async visitBaseClassDifference(entry: AnyClassItemDifference, targetClassItem: ECClass) {\n if (\"baseClass\" in entry.difference && entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {\n return this.addConflict({\n code: ConflictCode.RemovingBaseClass,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass cannot be removed, if there has been a baseClass before.\",\n });\n }\n\n if (entry.difference.baseClass === undefined) {\n return;\n }\n\n const sourceBaseClass = await this._sourceSchema.lookupItem(entry.difference.baseClass) as ECClass;\n if (sourceBaseClass.modifier === ECClassModifier.Sealed) {\n return this.addConflict({\n code: ConflictCode.SealedBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass) || null,\n description: \"BaseClass is sealed.\",\n });\n }\n\n if (targetClassItem.baseClass && !await this.derivedFrom(sourceBaseClass, targetClassItem.baseClass)) {\n return this.addConflict({\n code: ConflictCode.ConflictingBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass is not valid, source class must derive from target.\",\n });\n }\n }\n\n /**\n * Shared validation for all types of ClassItemDifference union.\n */\n private async visitClassDifference(entry: AnyClassItemDifference) {\n const targetClassItem = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && ECClass.isECClass(targetClassItem)) {\n await this.visitClassModifierDifference(entry, targetClassItem);\n await this.visitBaseClassDifference(entry, targetClassItem);\n }\n }\n\n /**\n * Validation the modifiers of all types of ClassItemDifference union.\n */\n private async visitClassModifierDifference(entry: AnyClassItemDifference, targetClass: ECClass) {\n if (entry.difference.modifier) {\n const changedModifier = parseClassModifier(entry.difference.modifier);\n if (changedModifier !== undefined && changedModifier !== ECClassModifier.None) {\n this.addConflict({\n code: ConflictCode.ConflictingClassModifier,\n difference: entry,\n source: entry.difference.modifier,\n target: classModifierToString(targetClass.modifier),\n description: \"Class has conflicting modifiers.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling ConstantDifference.\n * @internal\n */\n public async visitConstantDifference(entry: ConstantDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling CustomAttributeClassDifference.\n * @internal\n */\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling CustomAttributeDifference.\n * @internal\n */\n public async visitCustomAttributeInstanceDifference(_entry: CustomAttributeDifference) {\n }\n\n /**\n * Visitor implementation for handling EntityClassDifference.\n * @internal\n */\n public async visitEntityClassDifference(entry: EntityClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling EntityClassMixinDifference.\n * @internal\n */\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference) {\n for (const addedMixin of entry.difference) {\n // To validate the added mixins, the instance from the source schema it fetched,\n // otherwise validation gets too complicated as the mixin must not be existing in\n // the current target schema, it could also be added to the schema.\n const sourceMixin = await this._sourceSchema.lookupItem(addedMixin) as Mixin;\n const sourceSchemaItem = await this._sourceSchema.getItem(entry.itemName) as EntityClass;\n if (sourceMixin.appliesTo && !await sourceSchemaItem.is(await sourceMixin.appliesTo)) {\n this.addConflict({\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\n difference: entry,\n source: addedMixin,\n target: undefined,\n description: \"Mixin cannot applied to this class.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumerationDifference.\n * @internal\n */\n public async visitEnumerationDifference(entry: EnumerationDifference) {\n const enumeration = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, enumeration)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && Enumeration.isEnumeration(enumeration) && enumeration.type !== undefined) {\n if (entry.difference.type) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumerationType,\n difference: entry,\n source: entry.difference.type,\n target: primitiveTypeToString(enumeration.type),\n description: \"Enumeration has a different primitive type.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumeratorDifference.\n * @internal\n */\n public async visitEnumeratorDifference(entry: EnumeratorDifference) {\n if (entry.changeType !== \"modify\") {\n return;\n }\n\n const enumeration = await this.getTargetSchemaItem(entry.itemName) as Enumeration;\n const enumerator = enumeration.getEnumeratorByName(entry.path);\n if (!enumerator) {\n return;\n }\n\n if (entry.difference.value) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumeratorValue,\n difference: entry,\n source: entry.difference.value,\n target: enumerator.value,\n description: \"Enumerators must have unique values.\",\n });\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(entry: FormatDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityDifference.\n * @internal\n */\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference) {\n const kindOfQuantity = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && KindOfQuantity.isKindOfQuantity(kindOfQuantity)) {\n if (entry.difference.persistenceUnit) {\n this.addConflict({\n code: ConflictCode.ConflictingPersistenceUnit,\n difference: entry,\n source: entry.difference.persistenceUnit,\n target: resolveLazyItemFullName(kindOfQuantity.persistenceUnit),\n description: \"Kind of Quantity has a different persistence unit.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling MixinClassDifference.\n * @internal\n */\n public async visitMixinDifference(entry: MixinClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling PhenomenonDifference.\n * @internal\n */\n public async visitPhenomenonDifference(entry: PhenomenonDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling ClassPropertyDifference.\n * @internal\n */\n public async visitPropertyDifference(entry: ClassPropertyDifference) {\n const targetClass = await this.getTargetSchemaItem(entry.itemName) as ECClass;\n const propertyKey = this.getTargetProperty(entry.itemName, entry.path);\n const targetProperty = await targetClass.getProperty(propertyKey.propertyName);\n\n const sourceClass = await this._sourceSchema.getItem(entry.itemName) as ECClass;\n const sourceProperty = await sourceClass.getProperty(entry.path) as Property;\n\n // If property shall be added but there is already a property with this name\n // in target, a ConflictingPropertyName is issued.\n if (entry.changeType === \"add\" && targetProperty !== undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyName,\n difference: entry,\n source: resolvePropertyTypeName(sourceProperty),\n target: resolvePropertyTypeName(targetProperty),\n description: \"Target class already contains a property with a different type.\",\n });\n }\n\n if (entry.changeType === \"modify\" && targetProperty !== undefined) {\n if (\"kindOfQuantity\" in entry.difference) {\n const sourceKoQ = await sourceProperty.kindOfQuantity;\n const targetKoQ = await targetProperty.kindOfQuantity;\n if(!targetKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: null,\n description: \"The kind of quantity cannot be assiged if the property did not have a kind of quantities before.\",\n });\n }\n\n if(!sourceKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The kind of quantity cannot be undefined if the property had a kind of quantities before.\",\n });\n }\n\n if (resolveLazyItemName(sourceKoQ.persistenceUnit) !== resolveLazyItemName(targetKoQ.persistenceUnit)) {\n this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantityUnit,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The property has different kind of quantities with conflicting units.\",\n });\n }\n }\n }\n }\n\n /**\n * Visitor implementation for handling PropertyCategoryDifference.\n * @internal\n */\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling RelationshipClassDifference.\n * @internal\n */\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintDifference.\n * @internal\n */\n public async visitRelationshipConstraintDifference(_entry: RelationshipConstraintDifference) {\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintClassDifference.\n * @internal\n */\n public async visitRelationshipConstraintClassDifference(_entry: RelationshipConstraintClassDifference) {\n }\n\n /**\n * Visitor implementation for handling StructClassDifference.\n * @internal\n */\n public async visitStructClassDifference(entry: StructClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling UnitDifference.\n * @internal\n */\n public async visitUnitDifference(entry: UnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling UnitSystemDifference.\n * @internal\n */\n public async visitUnitSystemDifference(entry: UnitSystemDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\n * @internal\n */\n public async visitKindOfQuantityPresentationFormatDifference(_entry: KindOfQuantityPresentationFormatDifference) {\n }\n\n /**\n * Visitor implementation for handling FormatUnitDifference.\n * @internal\n */\n public async visitFormatUnitDifference(entry: FormatUnitDifference) {\n const targetFormat = await this.getTargetSchemaItem(entry.itemName) as Format;\n\n if (targetFormat.units === undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnit,\n difference: entry,\n source: entry.difference[0].name,\n target: null,\n description: \"The unit cannot be assiged if the format did not have a unit before.\",\n });\n };\n\n const targetUnit = await targetFormat.units[0][0];\n const targetPhenomenon = InvertedUnit.isInvertedUnit(targetUnit)\n ? (await targetUnit.invertsUnit)?.phenomenon\n : targetUnit.phenomenon;\n\n const sourceUnit = await this._sourceSchema.lookupItem(entry.difference[0].name) as Unit | InvertedUnit;\n const sourcePhenomenon = InvertedUnit.isInvertedUnit(sourceUnit)\n ? (await sourceUnit.invertsUnit)?.phenomenon\n : sourceUnit.phenomenon;\n\n if (resolveLazyItemName(targetPhenomenon) !== resolveLazyItemName(sourcePhenomenon)) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnitPhenomenon,\n difference: entry,\n source: entry.difference[0].name,\n target: targetUnit.fullName,\n description: \"Format units has a different phenomenon.\",\n });\n };\n };\n\n /**\n * Visitor implementation for handling FormatUnitLabelDifference.\n * @internal\n */\n public async visitFormatUnitLabelDifference(_entry: FormatUnitLabelDifference) {\n }\n\n /**\n * Recursive synchronous function to figure whether a given class derived from\n * a class with the given baseClass name.\n */\n private async derivedFrom(ecClass: ECClass | undefined, baseClassKey: Readonly<SchemaItemKey>): Promise<boolean> {\n if (ecClass === undefined) {\n return false;\n }\n\n // First check for name which must be same in any case...\n if (ecClass.name === baseClassKey.name) {\n // ... then check if the class is in the same schema as the expected base class...\n if(ecClass.schema.name === baseClassKey.schemaName)\n return true;\n // ... if not, whether it's in the source schema, but then we expect the baseclass\n // to be in the target schema.\n if(ecClass.schema.name === this._sourceSchema.name && baseClassKey.schemaName === this._targetSchema.name)\n return true;\n }\n return this.derivedFrom(await ecClass.baseClass, baseClassKey);\n }\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemFullName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.fullName;\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.name;\n}\n\n/**\n * Helper method to resolve the type name of a property.\n * @param property The property which's type shall be resolved.\n * @returns The (full) name of the properties type.\n */\nfunction resolvePropertyTypeName(property: Property) {\n const [prefix, suffix] = property.isArray() ? [\"[\", \"]\"] : [\"\", \"\"];\n if (property.isEnumeration())\n return `${prefix}${resolveLazyItemFullName(property.enumeration)}${suffix}`;\n if (property.isPrimitive())\n return `${prefix}${primitiveTypeToString(property.primitiveType)}${suffix}`;\n if (property.isStruct())\n return `${prefix}${property.structClass.fullName}${suffix}`;\n if (property.isNavigation())\n return `${prefix}${property.relationshipClass.fullName}${suffix}`;\n return propertyTypeToString(property.propertyType);\n}\n\n/**\n * Checks if the two schemas are compatible. Since the merger will eventually take the most\n * recent schema version, it is sufficient to check if they are write compatible in one direction.\n */\nfunction areCompatible(leftSchemaKey: SchemaKey, rightSchemaKey: SchemaKey): boolean {\n return leftSchemaKey.matches(rightSchemaKey, SchemaMatchType.LatestWriteCompatible)\n || rightSchemaKey.matches(leftSchemaKey, SchemaMatchType.LatestWriteCompatible);\n}\n"]}
|
|
@@ -66,7 +66,7 @@ class SchemaMerger {
|
|
|
66
66
|
}
|
|
67
67
|
throw error;
|
|
68
68
|
});
|
|
69
|
-
if (!schema.
|
|
69
|
+
if (!schema.isDynamic) {
|
|
70
70
|
throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);
|
|
71
71
|
}
|
|
72
72
|
const visitor = new SchemaMergingVisitor_1.SchemaMergingVisitor({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAwH;AACxH,8CAAwD;AACxD,mDAA8D;AAC9D,uEAAqG;AACrG,iEAA8D;AAC9D,+DAA4D;AAE5D,oDAA2E;AAC3E,qDAAkD;AAclD;;;;GAIG;AACH,MAAa,YAAY;IAEN,eAAe,CAAgB;IAEhD;;;OAGG;IACH,YAAY,cAA6B;QACvC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,YAAY,CAAC,YAAoB,EAAE,YAAoB,EAAE,KAAmB;QACvF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAA,uCAAoB,EAAC,YAAY,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,C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IAEe,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA2B;QACrF,OAAO,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACrE,CAAC;IAEe,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA2B;QAC/E,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAEe,KAAK,CAAC,aAAa,CAA8B,eAAuC,EAAE,cAA2B,EAAE,eAAmB;QACxJ,IAAI,aAA4B,CAAC;QACjC,IAAI,OAAO,eAAe,KAAK,QAAQ;YACrC,aAAa,GAAG,IAAI,iCAAa,CAAC,cAAwB,EAAE,IAAI,6BAAS,CAAC,eAAe,CAAC,CAAC,CAAC;;YAE5F,aAAa,GAAG,eAAe,CAAC;QAElC,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QACnE,IAAG,SAAS,KAAK,SAAS,EAAE,CAAC;YAC3B,aAAa,GAAG,SAA0B,CAAC;QAC7C,CAAC;QAED,IAAG,eAAe,KAAK,SAAS;YAC9B,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC7E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport { Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"../Editing/Editor\";\nimport { SchemaConflictsError } from \"../Differencing/Errors\";\nimport { getSchemaDifferences, type SchemaDifferenceResult } from \"../Differencing/SchemaDifference\";\nimport { SchemaMergingVisitor } from \"./SchemaMergingVisitor\";\nimport { SchemaMergingWalker } from \"./SchemaMergingWalker\";\nimport { SchemaEdits } from \"./Edits/SchemaEdits\";\nimport { ECEditingStatus, SchemaEditingError } from \"../Editing/Exception\";\nimport { NameMapping } from \"./Edits/NameMapping\";\n\n/**\n * Defines the context of a Schema merging run.\n * @internal\n */\nexport interface SchemaMergeContext {\n readonly targetSchema: Schema;\n readonly targetSchemaKey: SchemaKey;\n readonly sourceSchemaKey: SchemaKey;\n readonly editor: SchemaContextEditor;\n readonly nameMapping: NameMapping;\n}\n\n/**\n * Class to merge two schemas together.\n * @see [[merge]] or [[mergeSchemas]] to merge two schemas together.\n * @beta\n */\nexport class SchemaMerger {\n\n private readonly _editingContext: SchemaContext;\n\n /**\n * Constructs a new instance of the SchemaMerger object.\n * @param editingContext The schema contexts that holds the schema to be edited.\n */\n constructor(editingContext: SchemaContext) {\n this._editingContext = editingContext;\n }\n\n /**\n * Copy the SchemaItems of the source schemas to the target schema.\n * @param targetSchema The schema the SchemaItems gets merged to.\n * @param sourceSchema The schema the SchemaItems gets copied from.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @returns The merged target schema.\n * @alpha\n */\n public async mergeSchemas(targetSchema: Schema, sourceSchema: Schema, edits?: SchemaEdits): Promise<Schema> {\n return this.merge(await getSchemaDifferences(targetSchema, sourceSchema, edits), edits);\n }\n\n /**\n * Merges the schema differences into the target schema context.\n * @param differenceResult The differences that shall be applied to the target schema.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @alpha\n */\n public async merge(differenceResult: SchemaDifferenceResult, edits?: SchemaEdits): Promise<Schema> {\n const targetSchemaKey = SchemaKey.parseString(differenceResult.targetSchemaName);\n const sourceSchemaKey = SchemaKey.parseString(differenceResult.sourceSchemaName);\n\n const nameMapping = new NameMapping();\n const editor = new SchemaContextEditor(new MergingSchemaContext(this._editingContext, nameMapping));\n\n // If schema changes were provided, they'll get applied and a new SchemaDifferenceResult is returned\n // to prevent altering the differenceResult the caller passed in.\n if (edits) {\n await edits.applyTo(differenceResult = { ...differenceResult }, nameMapping);\n }\n\n if (differenceResult.conflicts && differenceResult.conflicts.length > 0) {\n throw new SchemaConflictsError(\n \"Schema's can't be merged if there are unresolved conflicts.\",\n differenceResult.conflicts,\n sourceSchemaKey,\n targetSchemaKey,\n );\n }\n\n const schema = await editor.getSchema(targetSchemaKey).catch((error: Error) => {\n if (error instanceof SchemaEditingError && error.errorNumber === ECEditingStatus.SchemaNotFound) {\n throw new Error(`The target schema '${targetSchemaKey.name}' could not be found in the editing context.`);\n }\n throw error;\n });\n\n if (!schema.isDynamic) {\n throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);\n }\n\n const visitor = new SchemaMergingVisitor({\n editor,\n targetSchema: schema,\n targetSchemaKey,\n sourceSchemaKey,\n nameMapping,\n });\n\n const walker = new SchemaMergingWalker(visitor);\n await walker.traverse(differenceResult.differences, \"add\");\n await walker.traverse(differenceResult.differences, \"modify\");\n\n return schema;\n }\n}\n\n/**\n * SchemaContext implementation that overrides certain methods to allow to apply name mappings\n * for certain schema elements during the schema merging process.\n *\n * @internal\n */\nclass MergingSchemaContext extends SchemaContext {\n private _internalContext: SchemaContext;\n private _nameMappings: NameMapping;\n\n public constructor(internalContext: SchemaContext, nameMapping: NameMapping) {\n super();\n this._internalContext = internalContext;\n this._nameMappings = nameMapping;\n }\n\n public override async getCachedSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getCachedSchema(schemaKey, matchType);\n }\n\n public override async getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getSchema(schemaKey, matchType);\n }\n\n public override async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string | SchemaItemKey, itemNameOrCtor?: string | T, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\n let schemaItemKey: SchemaItemKey;\n if (typeof schemaNameOrKey === \"string\")\n schemaItemKey = new SchemaItemKey(itemNameOrCtor as string, new SchemaKey(schemaNameOrKey));\n else\n schemaItemKey = schemaNameOrKey;\n\n const mappedKey = this._nameMappings.resolveItemKey(schemaItemKey);\n if(mappedKey !== undefined) {\n schemaItemKey = mappedKey as SchemaItemKey;\n }\n\n if(itemConstructor === undefined)\n return this._internalContext.getSchemaItem(schemaItemKey);\n\n return this._internalContext.getSchemaItem(schemaItemKey, itemConstructor);\n }\n}\n"]}
|
|
@@ -83,7 +83,7 @@ class SchemaDifferenceValidationVisitor {
|
|
|
83
83
|
}
|
|
84
84
|
const sourceSchemaKey = sourceSchemaReference.schemaKey;
|
|
85
85
|
const targetSchemaKey = targetSchemaReference.schemaKey;
|
|
86
|
-
if (
|
|
86
|
+
if (targetSchemaReference.isDynamic !== sourceSchemaReference.isDynamic) {
|
|
87
87
|
return this.addConflict({
|
|
88
88
|
code: ConflictCode.ConflictingReferenceDynamic,
|
|
89
89
|
difference: entry,
|
|
@@ -92,7 +92,7 @@ class SchemaDifferenceValidationVisitor {
|
|
|
92
92
|
target: targetSchemaKey.toString(),
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
if (entry.changeType === "modify" && !
|
|
95
|
+
if (entry.changeType === "modify" && !targetSchemaReference.isDynamic && !areCompatible(sourceSchemaKey, targetSchemaKey)) {
|
|
96
96
|
return this.addConflict({
|
|
97
97
|
code: ConflictCode.ConflictingReferenceVersion,
|
|
98
98
|
difference: entry,
|
|
@@ -532,12 +532,6 @@ function resolvePropertyTypeName(property) {
|
|
|
532
532
|
return `${prefix}${property.relationshipClass.fullName}${suffix}`;
|
|
533
533
|
return propertyTypeToString(property.propertyType);
|
|
534
534
|
}
|
|
535
|
-
/**
|
|
536
|
-
* Checks if a schema is dynamic.
|
|
537
|
-
*/
|
|
538
|
-
function isDynamicSchema(schema) {
|
|
539
|
-
return schema.customAttributes !== undefined && schema.customAttributes.has("CoreCustomAttributes.DynamicSchema");
|
|
540
|
-
}
|
|
541
535
|
/**
|
|
542
536
|
* Checks if the two schemas are compatible. Since the merger will eventually take the most
|
|
543
537
|
* recent schema version, it is sufficient to check if they are write compatible in one direction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaDifferenceValidator.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,eAAe,EAAe,WAAW,EAAU,YAAY,EAAE,cAAc,EAA+B,kBAAkB,EAAE,qBAAqB,EAAY,oBAAoB,EAAsB,aAAa,EAAa,eAAe,EAAQ,MAAM,0BAA0B,CAAC;AAExU,OAAO,EAA+B,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAA2B,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAe,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,WAAkC,EAAE,YAAoB,EAAE,YAAoB,EAAE,YAAyB;IACjJ,MAAM,OAAO,GAAG,IAAI,iCAAiC,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAChG,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAEnD,MAAM,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEnC,OAAO,OAAO,CAAC,SAAS,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,iCAAiC;IAErB,SAAS,CAAqC;IAC7C,aAAa,CAAS;IACtB,aAAa,CAAS;IACtB,aAAa,CAAc;IAE5C,6EAA6E;IAC7E,YAAY,YAAoB,EAAE,YAAoB,EAAE,YAAyB;QAC/E,IAAI,CAAC,SAAS,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S,uBAAuB,CAAC,QAAkB;IACjD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACpE,IAAI,QAAQ,CAAC,aAAa,EAAE;QAC1B,OAAO,GAAG,MAAM,GAAG,uBAAuB,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,MAAM,EAAE,CAAC;IAC9E,IAAI,QAAQ,CAAC,WAAW,EAAE;QACxB,OAAO,GAAG,MAAM,GAAG,qBAAqB,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,MAAM,EAAE,CAAC;IAC9E,IAAI,QAAQ,CAAC,QAAQ,EAAE;QACrB,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC;IAC9D,IAAI,QAAQ,CAAC,YAAY,EAAE;QACzB,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC;IACpE,OAAO,oBAAoB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,MAAc;IACrC,OAAO,MAAM,CAAC,gBAAgB,KAAK,SAAS,IAAI,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AACpH,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,aAAwB,EAAE,cAAyB;IACxE,OAAO,aAAa,CAAC,OAAO,CAAC,cAAc,EAAE,eAAe,CAAC,qBAAqB,CAAC;WAC5E,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;AACtF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Differencing\n */\n\nimport { classModifierToString, ECClass, ECClassModifier, EntityClass, Enumeration, Format, InvertedUnit, KindOfQuantity, LazyLoadedSchemaItem, Mixin, parseClassModifier, primitiveTypeToString, Property, propertyTypeToString, Schema, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType, Unit } from \"@itwin/ecschema-metadata\";\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from \"./SchemaDifference\";\nimport { AnySchemaDifferenceConflict, ConflictCode } from \"./SchemaConflicts\";\nimport { SchemaDifferenceVisitor, SchemaDifferenceWalker } from \"./SchemaDifferenceVisitor\";\nimport { NameMapping, PropertyKey } from \"../Merging/Edits/NameMapping\";\n\n/**\n * Validates the given array of schema differences and returns a list of conflicts if the\n * validation finds violation against rules.\n * @param differences An array of schema differences.\n * @param targetSchema The target schema reference.\n * @param sourceSchema The source schema reference.\n * @returns An array of conflicts found when validating the difference.\n * @internal\n */\nexport async function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema, nameMappings);\n const walker = new SchemaDifferenceWalker(visitor);\n\n await walker.traverse(differences);\n\n return visitor.conflicts;\n}\n\n/**\n * The SchemaDifferenceValidationVisitor class is an implementation of ISchemaDifferenceVisitor and\n * validates the given SchemaDifferences if the violate against some EC Rules.\n */\nclass SchemaDifferenceValidationVisitor implements SchemaDifferenceVisitor {\n\n public readonly conflicts: Array<AnySchemaDifferenceConflict>;\n private readonly _sourceSchema: Schema;\n private readonly _targetSchema: Schema;\n private readonly _nameMappings: NameMapping;\n\n /** Initializes a new instance of SchemaDifferenceValidationVisitor class. */\n constructor(targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n this.conflicts = [];\n this._targetSchema = targetSchema;\n this._sourceSchema = sourceSchema;\n this._nameMappings = nameMappings;\n }\n\n private addConflict(conflict: AnySchemaDifferenceConflict) {\n this.conflicts.push(conflict);\n }\n\n private async getTargetSchemaItem(name: string): Promise<SchemaItem | undefined> {\n const itemKey = new SchemaItemKey(name, this._sourceSchema.schemaKey);\n const mappedKey = this._nameMappings.resolveItemKey(itemKey);\n return this._targetSchema.getItem(mappedKey.name);\n }\n\n private getTargetProperty(itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, this._sourceSchema.schemaKey);\n const propertyKey = new PropertyKey(propertyName, classKey);\n return this._nameMappings.resolvePropertyKey(propertyKey);\n }\n\n /**\n * Visitor implementation for handling SchemaDifference.\n * @internal\n */\n public async visitSchemaDifference(_entry: SchemaDifference) {\n }\n\n /**\n * Visitor implementation for handling SchemaReferenceDifference.\n * @internal\n */\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference) {\n const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name) as Schema;\n const targetSchemaReferenceName = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);\n if (targetSchemaReferenceName && targetSchemaReferenceName !== sourceSchemaReference.name) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceAlias,\n difference: entry,\n source: entry.difference.name,\n target: targetSchemaReferenceName,\n description: \"Target schema already references a different schema with this alias.\",\n });\n }\n\n // The targetSchemaReference can be undefined, if the reference will be added by the source schema.\n // In this case further validation is not needed.\n const targetSchemaReference = await this._targetSchema.getReference(entry.difference.name);\n if(targetSchemaReference === undefined) {\n return;\n }\n\n const sourceSchemaKey = sourceSchemaReference.schemaKey;\n const targetSchemaKey = targetSchemaReference.schemaKey;\n\n if(isDynamicSchema(targetSchemaReference) !== isDynamicSchema(sourceSchemaReference)) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceDynamic,\n difference: entry,\n description: \"Cannot update a schema reference to or from a dynamic schema.\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n\n if(entry.changeType === \"modify\" && !isDynamicSchema(targetSchemaReference) && !areCompatible(sourceSchemaKey, targetSchemaKey)) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceVersion,\n difference: entry,\n description: \"Schema reference cannot be updated, incompatible versions\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n }\n\n /**\n * Shared schema item validation for all types of AnySchemaItemDifference union.\n */\n private async visitSchemaItemDifference(entry: AnySchemaItemDifference, targetSchemaItem: SchemaItem | undefined) {\n // If the item shall be added, but the target schema already has an item with this name,\n // will produce an ConflictingItemName conflict.\n if (entry.changeType === \"add\" && targetSchemaItem !== undefined) {\n this.addConflict({\n code: ConflictCode.ConflictingItemName,\n difference: entry,\n source: entry.schemaType,\n target: targetSchemaItem.schemaItemType,\n description: \"Target schema already contains a schema item with the name but different type.\",\n });\n return false;\n }\n\n return true;\n }\n\n /**\n * Shared base-class validation for all types of ClassItemDifference union.\n */\n private async visitBaseClassDifference(entry: AnyClassItemDifference, targetClassItem: ECClass) {\n if (\"baseClass\" in entry.difference && entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {\n return this.addConflict({\n code: ConflictCode.RemovingBaseClass,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass cannot be removed, if there has been a baseClass before.\",\n });\n }\n\n if (entry.difference.baseClass === undefined) {\n return;\n }\n\n const sourceBaseClass = await this._sourceSchema.lookupItem(entry.difference.baseClass) as ECClass;\n if (sourceBaseClass.modifier === ECClassModifier.Sealed) {\n return this.addConflict({\n code: ConflictCode.SealedBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass) || null,\n description: \"BaseClass is sealed.\",\n });\n }\n\n if (targetClassItem.baseClass && !await this.derivedFrom(sourceBaseClass, targetClassItem.baseClass)) {\n return this.addConflict({\n code: ConflictCode.ConflictingBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass is not valid, source class must derive from target.\",\n });\n }\n }\n\n /**\n * Shared validation for all types of ClassItemDifference union.\n */\n private async visitClassDifference(entry: AnyClassItemDifference) {\n const targetClassItem = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && ECClass.isECClass(targetClassItem)) {\n await this.visitClassModifierDifference(entry, targetClassItem);\n await this.visitBaseClassDifference(entry, targetClassItem);\n }\n }\n\n /**\n * Validation the modifiers of all types of ClassItemDifference union.\n */\n private async visitClassModifierDifference(entry: AnyClassItemDifference, targetClass: ECClass) {\n if (entry.difference.modifier) {\n const changedModifier = parseClassModifier(entry.difference.modifier);\n if (changedModifier !== undefined && changedModifier !== ECClassModifier.None) {\n this.addConflict({\n code: ConflictCode.ConflictingClassModifier,\n difference: entry,\n source: entry.difference.modifier,\n target: classModifierToString(targetClass.modifier),\n description: \"Class has conflicting modifiers.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling ConstantDifference.\n * @internal\n */\n public async visitConstantDifference(entry: ConstantDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling CustomAttributeClassDifference.\n * @internal\n */\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling CustomAttributeDifference.\n * @internal\n */\n public async visitCustomAttributeInstanceDifference(_entry: CustomAttributeDifference) {\n }\n\n /**\n * Visitor implementation for handling EntityClassDifference.\n * @internal\n */\n public async visitEntityClassDifference(entry: EntityClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling EntityClassMixinDifference.\n * @internal\n */\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference) {\n for (const addedMixin of entry.difference) {\n // To validate the added mixins, the instance from the source schema it fetched,\n // otherwise validation gets too complicated as the mixin must not be existing in\n // the current target schema, it could also be added to the schema.\n const sourceMixin = await this._sourceSchema.lookupItem(addedMixin) as Mixin;\n const sourceSchemaItem = await this._sourceSchema.getItem(entry.itemName) as EntityClass;\n if (sourceMixin.appliesTo && !await sourceSchemaItem.is(await sourceMixin.appliesTo)) {\n this.addConflict({\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\n difference: entry,\n source: addedMixin,\n target: undefined,\n description: \"Mixin cannot applied to this class.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumerationDifference.\n * @internal\n */\n public async visitEnumerationDifference(entry: EnumerationDifference) {\n const enumeration = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, enumeration)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && Enumeration.isEnumeration(enumeration) && enumeration.type !== undefined) {\n if (entry.difference.type) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumerationType,\n difference: entry,\n source: entry.difference.type,\n target: primitiveTypeToString(enumeration.type),\n description: \"Enumeration has a different primitive type.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumeratorDifference.\n * @internal\n */\n public async visitEnumeratorDifference(entry: EnumeratorDifference) {\n if (entry.changeType !== \"modify\") {\n return;\n }\n\n const enumeration = await this.getTargetSchemaItem(entry.itemName) as Enumeration;\n const enumerator = enumeration.getEnumeratorByName(entry.path);\n if (!enumerator) {\n return;\n }\n\n if (entry.difference.value) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumeratorValue,\n difference: entry,\n source: entry.difference.value,\n target: enumerator.value,\n description: \"Enumerators must have unique values.\",\n });\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(entry: FormatDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityDifference.\n * @internal\n */\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference) {\n const kindOfQuantity = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && KindOfQuantity.isKindOfQuantity(kindOfQuantity)) {\n if (entry.difference.persistenceUnit) {\n this.addConflict({\n code: ConflictCode.ConflictingPersistenceUnit,\n difference: entry,\n source: entry.difference.persistenceUnit,\n target: resolveLazyItemFullName(kindOfQuantity.persistenceUnit),\n description: \"Kind of Quantity has a different persistence unit.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling MixinClassDifference.\n * @internal\n */\n public async visitMixinDifference(entry: MixinClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling PhenomenonDifference.\n * @internal\n */\n public async visitPhenomenonDifference(entry: PhenomenonDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling ClassPropertyDifference.\n * @internal\n */\n public async visitPropertyDifference(entry: ClassPropertyDifference) {\n const targetClass = await this.getTargetSchemaItem(entry.itemName) as ECClass;\n const propertyKey = this.getTargetProperty(entry.itemName, entry.path);\n const targetProperty = await targetClass.getProperty(propertyKey.propertyName);\n\n const sourceClass = await this._sourceSchema.getItem(entry.itemName) as ECClass;\n const sourceProperty = await sourceClass.getProperty(entry.path) as Property;\n\n // If property shall be added but there is already a property with this name\n // in target, a ConflictingPropertyName is issued.\n if (entry.changeType === \"add\" && targetProperty !== undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyName,\n difference: entry,\n source: resolvePropertyTypeName(sourceProperty),\n target: resolvePropertyTypeName(targetProperty),\n description: \"Target class already contains a property with a different type.\",\n });\n }\n\n if (entry.changeType === \"modify\" && targetProperty !== undefined) {\n if (\"kindOfQuantity\" in entry.difference) {\n const sourceKoQ = await sourceProperty.kindOfQuantity;\n const targetKoQ = await targetProperty.kindOfQuantity;\n if(!targetKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: null,\n description: \"The kind of quantity cannot be assiged if the property did not have a kind of quantities before.\",\n });\n }\n\n if(!sourceKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The kind of quantity cannot be undefined if the property had a kind of quantities before.\",\n });\n }\n\n if (resolveLazyItemName(sourceKoQ.persistenceUnit) !== resolveLazyItemName(targetKoQ.persistenceUnit)) {\n this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantityUnit,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The property has different kind of quantities with conflicting units.\",\n });\n }\n }\n }\n }\n\n /**\n * Visitor implementation for handling PropertyCategoryDifference.\n * @internal\n */\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling RelationshipClassDifference.\n * @internal\n */\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintDifference.\n * @internal\n */\n public async visitRelationshipConstraintDifference(_entry: RelationshipConstraintDifference) {\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintClassDifference.\n * @internal\n */\n public async visitRelationshipConstraintClassDifference(_entry: RelationshipConstraintClassDifference) {\n }\n\n /**\n * Visitor implementation for handling StructClassDifference.\n * @internal\n */\n public async visitStructClassDifference(entry: StructClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling UnitDifference.\n * @internal\n */\n public async visitUnitDifference(entry: UnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling UnitSystemDifference.\n * @internal\n */\n public async visitUnitSystemDifference(entry: UnitSystemDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\n * @internal\n */\n public async visitKindOfQuantityPresentationFormatDifference(_entry: KindOfQuantityPresentationFormatDifference) {\n }\n\n /**\n * Visitor implementation for handling FormatUnitDifference.\n * @internal\n */\n public async visitFormatUnitDifference(entry: FormatUnitDifference) {\n const targetFormat = await this.getTargetSchemaItem(entry.itemName) as Format;\n\n if (targetFormat.units === undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnit,\n difference: entry,\n source: entry.difference[0].name,\n target: null,\n description: \"The unit cannot be assiged if the format did not have a unit before.\",\n });\n };\n\n const targetUnit = await targetFormat.units[0][0];\n const targetPhenomenon = InvertedUnit.isInvertedUnit(targetUnit)\n ? (await targetUnit.invertsUnit)?.phenomenon\n : targetUnit.phenomenon;\n\n const sourceUnit = await this._sourceSchema.lookupItem(entry.difference[0].name) as Unit | InvertedUnit;\n const sourcePhenomenon = InvertedUnit.isInvertedUnit(sourceUnit)\n ? (await sourceUnit.invertsUnit)?.phenomenon\n : sourceUnit.phenomenon;\n\n if (resolveLazyItemName(targetPhenomenon) !== resolveLazyItemName(sourcePhenomenon)) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnitPhenomenon,\n difference: entry,\n source: entry.difference[0].name,\n target: targetUnit.fullName,\n description: \"Format units has a different phenomenon.\",\n });\n };\n };\n\n /**\n * Visitor implementation for handling FormatUnitLabelDifference.\n * @internal\n */\n public async visitFormatUnitLabelDifference(_entry: FormatUnitLabelDifference) {\n }\n\n /**\n * Recursive synchronous function to figure whether a given class derived from\n * a class with the given baseClass name.\n */\n private async derivedFrom(ecClass: ECClass | undefined, baseClassKey: Readonly<SchemaItemKey>): Promise<boolean> {\n if (ecClass === undefined) {\n return false;\n }\n\n // First check for name which must be same in any case...\n if (ecClass.name === baseClassKey.name) {\n // ... then check if the class is in the same schema as the expected base class...\n if(ecClass.schema.name === baseClassKey.schemaName)\n return true;\n // ... if not, whether it's in the source schema, but then we expect the baseclass\n // to be in the target schema.\n if(ecClass.schema.name === this._sourceSchema.name && baseClassKey.schemaName === this._targetSchema.name)\n return true;\n }\n return this.derivedFrom(await ecClass.baseClass, baseClassKey);\n }\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemFullName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.fullName;\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.name;\n}\n\n/**\n * Helper method to resolve the type name of a property.\n * @param property The property which's type shall be resolved.\n * @returns The (full) name of the properties type.\n */\nfunction resolvePropertyTypeName(property: Property) {\n const [prefix, suffix] = property.isArray() ? [\"[\", \"]\"] : [\"\", \"\"];\n if (property.isEnumeration())\n return `${prefix}${resolveLazyItemFullName(property.enumeration)}${suffix}`;\n if (property.isPrimitive())\n return `${prefix}${primitiveTypeToString(property.primitiveType)}${suffix}`;\n if (property.isStruct())\n return `${prefix}${property.structClass.fullName}${suffix}`;\n if (property.isNavigation())\n return `${prefix}${property.relationshipClass.fullName}${suffix}`;\n return propertyTypeToString(property.propertyType);\n}\n\n/**\n * Checks if a schema is dynamic.\n */\nfunction isDynamicSchema(schema: Schema): boolean {\n return schema.customAttributes !== undefined && schema.customAttributes.has(\"CoreCustomAttributes.DynamicSchema\");\n}\n\n/**\n * Checks if the two schemas are compatible. Since the merger will eventually take the most\n * recent schema version, it is sufficient to check if they are write compatible in one direction.\n */\nfunction areCompatible(leftSchemaKey: SchemaKey, rightSchemaKey: SchemaKey): boolean {\n return leftSchemaKey.matches(rightSchemaKey, SchemaMatchType.LatestWriteCompatible)\n || rightSchemaKey.matches(leftSchemaKey, SchemaMatchType.LatestWriteCompatible);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaDifferenceValidator.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,eAAe,EAAe,WAAW,EAAU,YAAY,EAAE,cAAc,EAA+B,kBAAkB,EAAE,qBAAqB,EAAY,oBAAoB,EAAsB,aAAa,EAAa,eAAe,EAAQ,MAAM,0BAA0B,CAAC;AAExU,OAAO,EAA+B,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAA2B,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAe,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,WAAkC,EAAE,YAAoB,EAAE,YAAoB,EAAE,YAAyB;IACjJ,MAAM,OAAO,GAAG,IAAI,iCAAiC,CAAC,YAAY,EAAE,YAAY,EA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AAC,OAAO,CAAC,cAAc,EAAE,eAAe,CAAC,qBAAqB,CAAC;WAC5E,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;AACtF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Differencing\n */\n\nimport { classModifierToString, ECClass, ECClassModifier, EntityClass, Enumeration, Format, InvertedUnit, KindOfQuantity, LazyLoadedSchemaItem, Mixin, parseClassModifier, primitiveTypeToString, Property, propertyTypeToString, Schema, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType, Unit } from \"@itwin/ecschema-metadata\";\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from \"./SchemaDifference\";\nimport { AnySchemaDifferenceConflict, ConflictCode } from \"./SchemaConflicts\";\nimport { SchemaDifferenceVisitor, SchemaDifferenceWalker } from \"./SchemaDifferenceVisitor\";\nimport { NameMapping, PropertyKey } from \"../Merging/Edits/NameMapping\";\n\n/**\n * Validates the given array of schema differences and returns a list of conflicts if the\n * validation finds violation against rules.\n * @param differences An array of schema differences.\n * @param targetSchema The target schema reference.\n * @param sourceSchema The source schema reference.\n * @returns An array of conflicts found when validating the difference.\n * @internal\n */\nexport async function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema, nameMappings);\n const walker = new SchemaDifferenceWalker(visitor);\n\n await walker.traverse(differences);\n\n return visitor.conflicts;\n}\n\n/**\n * The SchemaDifferenceValidationVisitor class is an implementation of ISchemaDifferenceVisitor and\n * validates the given SchemaDifferences if the violate against some EC Rules.\n */\nclass SchemaDifferenceValidationVisitor implements SchemaDifferenceVisitor {\n\n public readonly conflicts: Array<AnySchemaDifferenceConflict>;\n private readonly _sourceSchema: Schema;\n private readonly _targetSchema: Schema;\n private readonly _nameMappings: NameMapping;\n\n /** Initializes a new instance of SchemaDifferenceValidationVisitor class. */\n constructor(targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n this.conflicts = [];\n this._targetSchema = targetSchema;\n this._sourceSchema = sourceSchema;\n this._nameMappings = nameMappings;\n }\n\n private addConflict(conflict: AnySchemaDifferenceConflict) {\n this.conflicts.push(conflict);\n }\n\n private async getTargetSchemaItem(name: string): Promise<SchemaItem | undefined> {\n const itemKey = new SchemaItemKey(name, this._sourceSchema.schemaKey);\n const mappedKey = this._nameMappings.resolveItemKey(itemKey);\n return this._targetSchema.getItem(mappedKey.name);\n }\n\n private getTargetProperty(itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, this._sourceSchema.schemaKey);\n const propertyKey = new PropertyKey(propertyName, classKey);\n return this._nameMappings.resolvePropertyKey(propertyKey);\n }\n\n /**\n * Visitor implementation for handling SchemaDifference.\n * @internal\n */\n public async visitSchemaDifference(_entry: SchemaDifference) {\n }\n\n /**\n * Visitor implementation for handling SchemaReferenceDifference.\n * @internal\n */\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference) {\n const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name) as Schema;\n const targetSchemaReferenceName = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);\n if (targetSchemaReferenceName && targetSchemaReferenceName !== sourceSchemaReference.name) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceAlias,\n difference: entry,\n source: entry.difference.name,\n target: targetSchemaReferenceName,\n description: \"Target schema already references a different schema with this alias.\",\n });\n }\n\n // The targetSchemaReference can be undefined, if the reference will be added by the source schema.\n // In this case further validation is not needed.\n const targetSchemaReference = await this._targetSchema.getReference(entry.difference.name);\n if(targetSchemaReference === undefined) {\n return;\n }\n\n const sourceSchemaKey = sourceSchemaReference.schemaKey;\n const targetSchemaKey = targetSchemaReference.schemaKey;\n\n if(targetSchemaReference.isDynamic !== sourceSchemaReference.isDynamic) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceDynamic,\n difference: entry,\n description: \"Cannot update a schema reference to or from a dynamic schema.\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n\n if(entry.changeType === \"modify\" && !targetSchemaReference.isDynamic && !areCompatible(sourceSchemaKey, targetSchemaKey)) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceVersion,\n difference: entry,\n description: \"Schema reference cannot be updated, incompatible versions\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n }\n\n /**\n * Shared schema item validation for all types of AnySchemaItemDifference union.\n */\n private async visitSchemaItemDifference(entry: AnySchemaItemDifference, targetSchemaItem: SchemaItem | undefined) {\n // If the item shall be added, but the target schema already has an item with this name,\n // will produce an ConflictingItemName conflict.\n if (entry.changeType === \"add\" && targetSchemaItem !== undefined) {\n this.addConflict({\n code: ConflictCode.ConflictingItemName,\n difference: entry,\n source: entry.schemaType,\n target: targetSchemaItem.schemaItemType,\n description: \"Target schema already contains a schema item with the name but different type.\",\n });\n return false;\n }\n\n return true;\n }\n\n /**\n * Shared base-class validation for all types of ClassItemDifference union.\n */\n private async visitBaseClassDifference(entry: AnyClassItemDifference, targetClassItem: ECClass) {\n if (\"baseClass\" in entry.difference && entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {\n return this.addConflict({\n code: ConflictCode.RemovingBaseClass,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass cannot be removed, if there has been a baseClass before.\",\n });\n }\n\n if (entry.difference.baseClass === undefined) {\n return;\n }\n\n const sourceBaseClass = await this._sourceSchema.lookupItem(entry.difference.baseClass) as ECClass;\n if (sourceBaseClass.modifier === ECClassModifier.Sealed) {\n return this.addConflict({\n code: ConflictCode.SealedBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass) || null,\n description: \"BaseClass is sealed.\",\n });\n }\n\n if (targetClassItem.baseClass && !await this.derivedFrom(sourceBaseClass, targetClassItem.baseClass)) {\n return this.addConflict({\n code: ConflictCode.ConflictingBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass is not valid, source class must derive from target.\",\n });\n }\n }\n\n /**\n * Shared validation for all types of ClassItemDifference union.\n */\n private async visitClassDifference(entry: AnyClassItemDifference) {\n const targetClassItem = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && ECClass.isECClass(targetClassItem)) {\n await this.visitClassModifierDifference(entry, targetClassItem);\n await this.visitBaseClassDifference(entry, targetClassItem);\n }\n }\n\n /**\n * Validation the modifiers of all types of ClassItemDifference union.\n */\n private async visitClassModifierDifference(entry: AnyClassItemDifference, targetClass: ECClass) {\n if (entry.difference.modifier) {\n const changedModifier = parseClassModifier(entry.difference.modifier);\n if (changedModifier !== undefined && changedModifier !== ECClassModifier.None) {\n this.addConflict({\n code: ConflictCode.ConflictingClassModifier,\n difference: entry,\n source: entry.difference.modifier,\n target: classModifierToString(targetClass.modifier),\n description: \"Class has conflicting modifiers.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling ConstantDifference.\n * @internal\n */\n public async visitConstantDifference(entry: ConstantDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling CustomAttributeClassDifference.\n * @internal\n */\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling CustomAttributeDifference.\n * @internal\n */\n public async visitCustomAttributeInstanceDifference(_entry: CustomAttributeDifference) {\n }\n\n /**\n * Visitor implementation for handling EntityClassDifference.\n * @internal\n */\n public async visitEntityClassDifference(entry: EntityClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling EntityClassMixinDifference.\n * @internal\n */\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference) {\n for (const addedMixin of entry.difference) {\n // To validate the added mixins, the instance from the source schema it fetched,\n // otherwise validation gets too complicated as the mixin must not be existing in\n // the current target schema, it could also be added to the schema.\n const sourceMixin = await this._sourceSchema.lookupItem(addedMixin) as Mixin;\n const sourceSchemaItem = await this._sourceSchema.getItem(entry.itemName) as EntityClass;\n if (sourceMixin.appliesTo && !await sourceSchemaItem.is(await sourceMixin.appliesTo)) {\n this.addConflict({\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\n difference: entry,\n source: addedMixin,\n target: undefined,\n description: \"Mixin cannot applied to this class.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumerationDifference.\n * @internal\n */\n public async visitEnumerationDifference(entry: EnumerationDifference) {\n const enumeration = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, enumeration)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && Enumeration.isEnumeration(enumeration) && enumeration.type !== undefined) {\n if (entry.difference.type) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumerationType,\n difference: entry,\n source: entry.difference.type,\n target: primitiveTypeToString(enumeration.type),\n description: \"Enumeration has a different primitive type.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumeratorDifference.\n * @internal\n */\n public async visitEnumeratorDifference(entry: EnumeratorDifference) {\n if (entry.changeType !== \"modify\") {\n return;\n }\n\n const enumeration = await this.getTargetSchemaItem(entry.itemName) as Enumeration;\n const enumerator = enumeration.getEnumeratorByName(entry.path);\n if (!enumerator) {\n return;\n }\n\n if (entry.difference.value) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumeratorValue,\n difference: entry,\n source: entry.difference.value,\n target: enumerator.value,\n description: \"Enumerators must have unique values.\",\n });\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(entry: FormatDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityDifference.\n * @internal\n */\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference) {\n const kindOfQuantity = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && KindOfQuantity.isKindOfQuantity(kindOfQuantity)) {\n if (entry.difference.persistenceUnit) {\n this.addConflict({\n code: ConflictCode.ConflictingPersistenceUnit,\n difference: entry,\n source: entry.difference.persistenceUnit,\n target: resolveLazyItemFullName(kindOfQuantity.persistenceUnit),\n description: \"Kind of Quantity has a different persistence unit.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling MixinClassDifference.\n * @internal\n */\n public async visitMixinDifference(entry: MixinClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling PhenomenonDifference.\n * @internal\n */\n public async visitPhenomenonDifference(entry: PhenomenonDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling ClassPropertyDifference.\n * @internal\n */\n public async visitPropertyDifference(entry: ClassPropertyDifference) {\n const targetClass = await this.getTargetSchemaItem(entry.itemName) as ECClass;\n const propertyKey = this.getTargetProperty(entry.itemName, entry.path);\n const targetProperty = await targetClass.getProperty(propertyKey.propertyName);\n\n const sourceClass = await this._sourceSchema.getItem(entry.itemName) as ECClass;\n const sourceProperty = await sourceClass.getProperty(entry.path) as Property;\n\n // If property shall be added but there is already a property with this name\n // in target, a ConflictingPropertyName is issued.\n if (entry.changeType === \"add\" && targetProperty !== undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyName,\n difference: entry,\n source: resolvePropertyTypeName(sourceProperty),\n target: resolvePropertyTypeName(targetProperty),\n description: \"Target class already contains a property with a different type.\",\n });\n }\n\n if (entry.changeType === \"modify\" && targetProperty !== undefined) {\n if (\"kindOfQuantity\" in entry.difference) {\n const sourceKoQ = await sourceProperty.kindOfQuantity;\n const targetKoQ = await targetProperty.kindOfQuantity;\n if(!targetKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: null,\n description: \"The kind of quantity cannot be assiged if the property did not have a kind of quantities before.\",\n });\n }\n\n if(!sourceKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The kind of quantity cannot be undefined if the property had a kind of quantities before.\",\n });\n }\n\n if (resolveLazyItemName(sourceKoQ.persistenceUnit) !== resolveLazyItemName(targetKoQ.persistenceUnit)) {\n this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantityUnit,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The property has different kind of quantities with conflicting units.\",\n });\n }\n }\n }\n }\n\n /**\n * Visitor implementation for handling PropertyCategoryDifference.\n * @internal\n */\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling RelationshipClassDifference.\n * @internal\n */\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintDifference.\n * @internal\n */\n public async visitRelationshipConstraintDifference(_entry: RelationshipConstraintDifference) {\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintClassDifference.\n * @internal\n */\n public async visitRelationshipConstraintClassDifference(_entry: RelationshipConstraintClassDifference) {\n }\n\n /**\n * Visitor implementation for handling StructClassDifference.\n * @internal\n */\n public async visitStructClassDifference(entry: StructClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling UnitDifference.\n * @internal\n */\n public async visitUnitDifference(entry: UnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling UnitSystemDifference.\n * @internal\n */\n public async visitUnitSystemDifference(entry: UnitSystemDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\n * @internal\n */\n public async visitKindOfQuantityPresentationFormatDifference(_entry: KindOfQuantityPresentationFormatDifference) {\n }\n\n /**\n * Visitor implementation for handling FormatUnitDifference.\n * @internal\n */\n public async visitFormatUnitDifference(entry: FormatUnitDifference) {\n const targetFormat = await this.getTargetSchemaItem(entry.itemName) as Format;\n\n if (targetFormat.units === undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnit,\n difference: entry,\n source: entry.difference[0].name,\n target: null,\n description: \"The unit cannot be assiged if the format did not have a unit before.\",\n });\n };\n\n const targetUnit = await targetFormat.units[0][0];\n const targetPhenomenon = InvertedUnit.isInvertedUnit(targetUnit)\n ? (await targetUnit.invertsUnit)?.phenomenon\n : targetUnit.phenomenon;\n\n const sourceUnit = await this._sourceSchema.lookupItem(entry.difference[0].name) as Unit | InvertedUnit;\n const sourcePhenomenon = InvertedUnit.isInvertedUnit(sourceUnit)\n ? (await sourceUnit.invertsUnit)?.phenomenon\n : sourceUnit.phenomenon;\n\n if (resolveLazyItemName(targetPhenomenon) !== resolveLazyItemName(sourcePhenomenon)) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnitPhenomenon,\n difference: entry,\n source: entry.difference[0].name,\n target: targetUnit.fullName,\n description: \"Format units has a different phenomenon.\",\n });\n };\n };\n\n /**\n * Visitor implementation for handling FormatUnitLabelDifference.\n * @internal\n */\n public async visitFormatUnitLabelDifference(_entry: FormatUnitLabelDifference) {\n }\n\n /**\n * Recursive synchronous function to figure whether a given class derived from\n * a class with the given baseClass name.\n */\n private async derivedFrom(ecClass: ECClass | undefined, baseClassKey: Readonly<SchemaItemKey>): Promise<boolean> {\n if (ecClass === undefined) {\n return false;\n }\n\n // First check for name which must be same in any case...\n if (ecClass.name === baseClassKey.name) {\n // ... then check if the class is in the same schema as the expected base class...\n if(ecClass.schema.name === baseClassKey.schemaName)\n return true;\n // ... if not, whether it's in the source schema, but then we expect the baseclass\n // to be in the target schema.\n if(ecClass.schema.name === this._sourceSchema.name && baseClassKey.schemaName === this._targetSchema.name)\n return true;\n }\n return this.derivedFrom(await ecClass.baseClass, baseClassKey);\n }\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemFullName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.fullName;\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.name;\n}\n\n/**\n * Helper method to resolve the type name of a property.\n * @param property The property which's type shall be resolved.\n * @returns The (full) name of the properties type.\n */\nfunction resolvePropertyTypeName(property: Property) {\n const [prefix, suffix] = property.isArray() ? [\"[\", \"]\"] : [\"\", \"\"];\n if (property.isEnumeration())\n return `${prefix}${resolveLazyItemFullName(property.enumeration)}${suffix}`;\n if (property.isPrimitive())\n return `${prefix}${primitiveTypeToString(property.primitiveType)}${suffix}`;\n if (property.isStruct())\n return `${prefix}${property.structClass.fullName}${suffix}`;\n if (property.isNavigation())\n return `${prefix}${property.relationshipClass.fullName}${suffix}`;\n return propertyTypeToString(property.propertyType);\n}\n\n/**\n * Checks if the two schemas are compatible. Since the merger will eventually take the most\n * recent schema version, it is sufficient to check if they are write compatible in one direction.\n */\nfunction areCompatible(leftSchemaKey: SchemaKey, rightSchemaKey: SchemaKey): boolean {\n return leftSchemaKey.matches(rightSchemaKey, SchemaMatchType.LatestWriteCompatible)\n || rightSchemaKey.matches(leftSchemaKey, SchemaMatchType.LatestWriteCompatible);\n}\n"]}
|
|
@@ -63,7 +63,7 @@ export class SchemaMerger {
|
|
|
63
63
|
}
|
|
64
64
|
throw error;
|
|
65
65
|
});
|
|
66
|
-
if (!schema.
|
|
66
|
+
if (!schema.isDynamic) {
|
|
67
67
|
throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);
|
|
68
68
|
}
|
|
69
69
|
const visitor = new SchemaMergingVisitor({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAU,aAAa,EAAc,aAAa,EAAE,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC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C,aAAa,CAA8B,eAAuC,EAAE,cAA2B,EAAE,eAAmB;QACxJ,IAAI,aAA4B,CAAC;QACjC,IAAI,OAAO,eAAe,KAAK,QAAQ;YACrC,aAAa,GAAG,IAAI,aAAa,CAAC,cAAwB,EAAE,IAAI,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;;YAE5F,aAAa,GAAG,eAAe,CAAC;QAElC,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QACnE,IAAG,SAAS,KAAK,SAAS,EAAE,CAAC;YAC3B,aAAa,GAAG,SAA0B,CAAC;QAC7C,CAAC;QAED,IAAG,eAAe,KAAK,SAAS;YAC9B,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC7E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport { Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"../Editing/Editor\";\nimport { SchemaConflictsError } from \"../Differencing/Errors\";\nimport { getSchemaDifferences, type SchemaDifferenceResult } from \"../Differencing/SchemaDifference\";\nimport { SchemaMergingVisitor } from \"./SchemaMergingVisitor\";\nimport { SchemaMergingWalker } from \"./SchemaMergingWalker\";\nimport { SchemaEdits } from \"./Edits/SchemaEdits\";\nimport { ECEditingStatus, SchemaEditingError } from \"../Editing/Exception\";\nimport { NameMapping } from \"./Edits/NameMapping\";\n\n/**\n * Defines the context of a Schema merging run.\n * @internal\n */\nexport interface SchemaMergeContext {\n readonly targetSchema: Schema;\n readonly targetSchemaKey: SchemaKey;\n readonly sourceSchemaKey: SchemaKey;\n readonly editor: SchemaContextEditor;\n readonly nameMapping: NameMapping;\n}\n\n/**\n * Class to merge two schemas together.\n * @see [[merge]] or [[mergeSchemas]] to merge two schemas together.\n * @beta\n */\nexport class SchemaMerger {\n\n private readonly _editingContext: SchemaContext;\n\n /**\n * Constructs a new instance of the SchemaMerger object.\n * @param editingContext The schema contexts that holds the schema to be edited.\n */\n constructor(editingContext: SchemaContext) {\n this._editingContext = editingContext;\n }\n\n /**\n * Copy the SchemaItems of the source schemas to the target schema.\n * @param targetSchema The schema the SchemaItems gets merged to.\n * @param sourceSchema The schema the SchemaItems gets copied from.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @returns The merged target schema.\n * @alpha\n */\n public async mergeSchemas(targetSchema: Schema, sourceSchema: Schema, edits?: SchemaEdits): Promise<Schema> {\n return this.merge(await getSchemaDifferences(targetSchema, sourceSchema, edits), edits);\n }\n\n /**\n * Merges the schema differences into the target schema context.\n * @param differenceResult The differences that shall be applied to the target schema.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @alpha\n */\n public async merge(differenceResult: SchemaDifferenceResult, edits?: SchemaEdits): Promise<Schema> {\n const targetSchemaKey = SchemaKey.parseString(differenceResult.targetSchemaName);\n const sourceSchemaKey = SchemaKey.parseString(differenceResult.sourceSchemaName);\n\n const nameMapping = new NameMapping();\n const editor = new SchemaContextEditor(new MergingSchemaContext(this._editingContext, nameMapping));\n\n // If schema changes were provided, they'll get applied and a new SchemaDifferenceResult is returned\n // to prevent altering the differenceResult the caller passed in.\n if (edits) {\n await edits.applyTo(differenceResult = { ...differenceResult }, nameMapping);\n }\n\n if (differenceResult.conflicts && differenceResult.conflicts.length > 0) {\n throw new SchemaConflictsError(\n \"Schema's can't be merged if there are unresolved conflicts.\",\n differenceResult.conflicts,\n sourceSchemaKey,\n targetSchemaKey,\n );\n }\n\n const schema = await editor.getSchema(targetSchemaKey).catch((error: Error) => {\n if (error instanceof SchemaEditingError && error.errorNumber === ECEditingStatus.SchemaNotFound) {\n throw new Error(`The target schema '${targetSchemaKey.name}' could not be found in the editing context.`);\n }\n throw error;\n });\n\n if (!schema.isDynamic) {\n throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);\n }\n\n const visitor = new SchemaMergingVisitor({\n editor,\n targetSchema: schema,\n targetSchemaKey,\n sourceSchemaKey,\n nameMapping,\n });\n\n const walker = new SchemaMergingWalker(visitor);\n await walker.traverse(differenceResult.differences, \"add\");\n await walker.traverse(differenceResult.differences, \"modify\");\n\n return schema;\n }\n}\n\n/**\n * SchemaContext implementation that overrides certain methods to allow to apply name mappings\n * for certain schema elements during the schema merging process.\n *\n * @internal\n */\nclass MergingSchemaContext extends SchemaContext {\n private _internalContext: SchemaContext;\n private _nameMappings: NameMapping;\n\n public constructor(internalContext: SchemaContext, nameMapping: NameMapping) {\n super();\n this._internalContext = internalContext;\n this._nameMappings = nameMapping;\n }\n\n public override async getCachedSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getCachedSchema(schemaKey, matchType);\n }\n\n public override async getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getSchema(schemaKey, matchType);\n }\n\n public override async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string | SchemaItemKey, itemNameOrCtor?: string | T, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\n let schemaItemKey: SchemaItemKey;\n if (typeof schemaNameOrKey === \"string\")\n schemaItemKey = new SchemaItemKey(itemNameOrCtor as string, new SchemaKey(schemaNameOrKey));\n else\n schemaItemKey = schemaNameOrKey;\n\n const mappedKey = this._nameMappings.resolveItemKey(schemaItemKey);\n if(mappedKey !== undefined) {\n schemaItemKey = mappedKey as SchemaItemKey;\n }\n\n if(itemConstructor === undefined)\n return this._internalContext.getSchemaItem(schemaItemKey);\n\n return this._internalContext.getSchemaItem(schemaItemKey, itemConstructor);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/ecschema-editing",
|
|
3
|
-
"version": "5.2.0-dev.
|
|
3
|
+
"version": "5.2.0-dev.33",
|
|
4
4
|
"description": "ECSchema editing and validation API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/cjs/ecschema-editing.js",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"rimraf": "^6.0.1",
|
|
43
43
|
"sinon": "^17.0.2",
|
|
44
44
|
"typescript": "~5.6.2",
|
|
45
|
-
"@itwin/
|
|
46
|
-
"@itwin/
|
|
47
|
-
"@itwin/core-common": "5.2.0-dev.
|
|
48
|
-
"@itwin/
|
|
49
|
-
"@itwin/
|
|
45
|
+
"@itwin/build-tools": "5.2.0-dev.33",
|
|
46
|
+
"@itwin/core-bentley": "5.2.0-dev.33",
|
|
47
|
+
"@itwin/core-common": "5.2.0-dev.33",
|
|
48
|
+
"@itwin/core-quantity": "5.2.0-dev.33",
|
|
49
|
+
"@itwin/ecschema-metadata": "5.2.0-dev.33"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@itwin/core-bentley": "5.2.0-dev.
|
|
53
|
-
"@itwin/core-quantity": "5.2.0-dev.
|
|
54
|
-
"@itwin/ecschema-metadata": "5.2.0-dev.
|
|
52
|
+
"@itwin/core-bentley": "5.2.0-dev.33",
|
|
53
|
+
"@itwin/core-quantity": "5.2.0-dev.33",
|
|
54
|
+
"@itwin/ecschema-metadata": "5.2.0-dev.33"
|
|
55
55
|
},
|
|
56
56
|
"nyc": {
|
|
57
57
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|