@itwin/ecschema-editing 5.0.0-dev.16 → 5.0.0-dev.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  2. package/lib/cjs/Differencing/SchemaDifference.d.ts +2 -1
  3. package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
  4. package/lib/cjs/Differencing/SchemaDifference.js +51 -5
  5. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  6. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts +2 -1
  7. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
  8. package/lib/cjs/Differencing/SchemaDifferenceValidator.js +29 -16
  9. package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
  10. package/lib/cjs/Editing/Editor.js +4 -4
  11. package/lib/cjs/Editing/Editor.js.map +1 -1
  12. package/lib/cjs/Merging/ConstantMerger.js +3 -3
  13. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  14. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  15. package/lib/cjs/Merging/CustomAttributeMerger.js +5 -9
  16. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  17. package/lib/cjs/Merging/Edits/NameMapping.d.ts +22 -0
  18. package/lib/cjs/Merging/Edits/NameMapping.d.ts.map +1 -0
  19. package/lib/cjs/Merging/Edits/NameMapping.js +51 -0
  20. package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -0
  21. package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts +1 -1
  22. package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -1
  23. package/lib/cjs/Merging/Edits/RenameEditHandler.js +1 -260
  24. package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
  25. package/lib/cjs/Merging/Edits/SchemaEdits.d.ts +9 -6
  26. package/lib/cjs/Merging/Edits/SchemaEdits.d.ts.map +1 -1
  27. package/lib/cjs/Merging/Edits/SchemaEdits.js +15 -14
  28. package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
  29. package/lib/cjs/Merging/EntityClassMerger.js +1 -2
  30. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  31. package/lib/cjs/Merging/EnumerationMerger.js +1 -1
  32. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  33. package/lib/cjs/Merging/EnumeratorMerger.d.ts.map +1 -1
  34. package/lib/cjs/Merging/EnumeratorMerger.js +2 -2
  35. package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
  36. package/lib/cjs/Merging/KindOfQuantityMerger.js +2 -2
  37. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  38. package/lib/cjs/Merging/MixinMerger.js +1 -1
  39. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  40. package/lib/cjs/Merging/PhenomenonMerger.js +1 -1
  41. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  42. package/lib/cjs/Merging/PropertyMerger.js +25 -23
  43. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  44. package/lib/cjs/Merging/SchemaMerger.d.ts +5 -3
  45. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  46. package/lib/cjs/Merging/SchemaMerger.js +35 -5
  47. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  48. package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +0 -4
  49. package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
  50. package/lib/cjs/Merging/SchemaMergingVisitor.js +4 -10
  51. package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
  52. package/lib/cjs/Merging/Utils.d.ts +11 -0
  53. package/lib/cjs/Merging/Utils.d.ts.map +1 -1
  54. package/lib/cjs/Merging/Utils.js +22 -2
  55. package/lib/cjs/Merging/Utils.js.map +1 -1
  56. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts.map +1 -1
  57. package/lib/cjs/Validation/SchemaCompareVisitor.js +21 -23
  58. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  59. package/lib/cjs/Validation/SchemaComparer.d.ts +22 -1
  60. package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
  61. package/lib/cjs/Validation/SchemaComparer.js +25 -3
  62. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  63. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaDiagnosticVisitor.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDiagnosticVisitor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,qFAA4E;AAC5E,gEAIkC;AAClC,yDAe4B;AAE5B;;;;;GAKG;AACH,MAAa,uBAAuB;IAOlC;QACE,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,yBAAyB,GAAG,EAAE,CAAC;QACpC,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,UAAyB;QACpC,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;YACxB,KAAK,6CAAkB,CAAC,WAAW;gBACjC,OAAO,IAAI,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC;YAEvD,KAAK,6CAAkB,CAAC,sBAAsB;gBAC5C,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YACtD,KAAK,6CAAkB,CAAC,oBAAoB;gBAC1C,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YAEzD,KAAK,6CAAkB,CAAC,iBAAiB;gBACvC,OAAO,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC;YAEjD,KAAK,6CAAkB,CAAC,e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C;QAEH,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,QAAQ,GAAG;gBACT,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,mCAAgB,CAAC,gCAAgC;gBAC7D,QAAQ,EAAE,GAAG,CAAC,IAAI;gBAClB,UAAU,EAAE,EAAE;aACf,CAAC;YACF,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;QACD,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;CACF;AA1aD,0DA0aC;AAED,SAAS,kBAAkB,CAAC,QAAkB,EAAE,YAAoB;IAClE,OAAO,CAAC,YAAY,KAAK,MAAM,CAAC;QAC9B,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,YAAY,KAAK,aAAa,CAAC;QAC5D,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,YAAY,KAAK,eAAe,CAAC;QAC5D,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,YAAY,KAAK,aAAa,CAAC;QACvD,CAAC,QAAQ,CAAC,YAAY,EAAE,IAAI,YAAY,KAAK,mBAAmB,CAAC,CAAC;AACtE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Differencing\r\n */\r\n\r\nimport type { AnyDiagnostic } from \"../Validation/Diagnostic\";\r\nimport { SchemaCompareCodes } from \"../Validation/SchemaCompareDiagnostics\";\r\nimport {\r\n AnyEnumerator, AnyPropertyProps, AnySchemaItem, CustomAttribute, ECClass,\r\n Enumeration, Format, KindOfQuantity, Mixin, OverrideFormat, Property, PropertyProps,\r\n RelationshipConstraint, RelationshipConstraintProps, Schema, SchemaItem,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport {\r\n type AnyClassItemDifference,\r\n type AnySchemaItemDifference,\r\n type AnySchemaItemPathDifference,\r\n type ClassPropertyDifference,\r\n type CustomAttributeDifference,\r\n type DifferenceType,\r\n type EntityClassMixinDifference,\r\n type EnumeratorDifference,\r\n type KindOfQuantityPresentationFormatDifference,\r\n type RelationshipConstraintClassDifference,\r\n type RelationshipConstraintDifference,\r\n type SchemaDifference,\r\n SchemaOtherTypes,\r\n type SchemaReferenceDifference,\r\n} from \"./SchemaDifference\";\r\n\r\n/**\r\n * The SchemaDiagnosticVisitor is a visitor implementation for diagnostic entries\r\n * from the schema comparer api. Depending on the diagnostic code, the difference\r\n * result is build together.\r\n * @internal\r\n */\r\nexport class SchemaDiagnosticVisitor {\r\n\r\n public readonly schemaDifferences: Array<SchemaDifference | SchemaReferenceDifference>;\r\n public readonly schemaItemDifferences: Array<AnySchemaItemDifference | EntityClassMixinDifference | KindOfQuantityPresentationFormatDifference>;\r\n public readonly schemaItemPathDifferences: Array<AnySchemaItemPathDifference>;\r\n public readonly customAttributeDifferences: Array<CustomAttributeDifference>;\r\n\r\n constructor() {\r\n this.schemaDifferences = [];\r\n this.schemaItemDifferences = [];\r\n this.schemaItemPathDifferences = [];\r\n this.customAttributeDifferences = [];\r\n }\r\n\r\n /**\r\n * Visitor function to process the schema change diagnostic object.\r\n * @internal\r\n */\r\n public visit(diagnostic: AnyDiagnostic) {\r\n switch (diagnostic.code) {\r\n case SchemaCompareCodes.SchemaDelta:\r\n return this.visitChangedSchemaProperties(diagnostic);\r\n\r\n case SchemaCompareCodes.SchemaReferenceMissing:\r\n return this.visitSchemaReference(diagnostic, \"add\");\r\n case SchemaCompareCodes.SchemaReferenceDelta:\r\n return this.visitSchemaReference(diagnostic, \"modify\");\r\n\r\n case SchemaCompareCodes.SchemaItemMissing:\r\n return this.visitMissingSchemaItem(diagnostic);\r\n\r\n case SchemaCompareCodes.SchemaItemDelta:\r\n case SchemaCompareCodes.ClassDelta:\r\n case SchemaCompareCodes.ConstantDelta:\r\n case SchemaCompareCodes.CustomAttributeClassDelta:\r\n case SchemaCompareCodes.FormatDelta:\r\n case SchemaCompareCodes.InvertedUnitDelta:\r\n case SchemaCompareCodes.KoqDelta:\r\n case SchemaCompareCodes.MixinDelta:\r\n case SchemaCompareCodes.PhenomenonDelta:\r\n case SchemaCompareCodes.PropertyCategoryDelta:\r\n case SchemaCompareCodes.RelationshipDelta:\r\n case SchemaCompareCodes.UnitDelta:\r\n case SchemaCompareCodes.EnumerationDelta:\r\n return this.visitChangedSchemaItem(diagnostic);\r\n\r\n case SchemaCompareCodes.EnumeratorDelta:\r\n return this.visitChangedEnumerator(diagnostic);\r\n case SchemaCompareCodes.EnumeratorMissing:\r\n return this.visitMissingEnumerator(diagnostic);\r\n\r\n case SchemaCompareCodes.BaseClassDelta:\r\n return this.visitMissingBaseClass(diagnostic);\r\n case SchemaCompareCodes.EntityMixinMissing:\r\n return this.visitMissingMixinOnClass(diagnostic);\r\n case SchemaCompareCodes.PropertyDelta:\r\n return this.visitChangedProperty(diagnostic);\r\n case SchemaCompareCodes.PropertyMissing:\r\n return this.visitMissingProperty(diagnostic);\r\n\r\n case SchemaCompareCodes.RelationshipConstraintClassMissing:\r\n return this.visitMissingRelationshipConstraintClass(diagnostic);\r\n case SchemaCompareCodes.RelationshipConstraintDelta:\r\n return this.visitChangedRelationshipConstraint(diagnostic);\r\n\r\n case SchemaCompareCodes.CustomAttributeInstanceClassMissing:\r\n return this.visitMissingCustomAttributeInstance(diagnostic);\r\n\r\n case SchemaCompareCodes.PresentationUnitMissing:\r\n return this.visitMissingPresentationUnit(diagnostic);\r\n\r\n // Currently not handled...\r\n case SchemaCompareCodes.FormatUnitMissing:\r\n case SchemaCompareCodes.UnitLabelOverrideDelta:\r\n break;\r\n }\r\n return;\r\n }\r\n\r\n private visitChangedSchemaProperties(diagnostic: AnyDiagnostic) {\r\n let modifyEntry = this.schemaDifferences.find((entry): entry is SchemaDifference => {\r\n return entry.changeType === \"modify\" && entry.schemaType === SchemaOtherTypes.Schema;\r\n });\r\n\r\n let hasChanges = false;\r\n let addEntry = false;\r\n if (modifyEntry === undefined) {\r\n addEntry = true;\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: SchemaOtherTypes.Schema,\r\n difference: {},\r\n };\r\n }\r\n\r\n // Only label and description are taken from the source schema. If the schema name or alias\r\n // differs, those are ignored for now.\r\n const [propertyName, propertyValue] = diagnostic.messageArgs as [string, any];\r\n if (propertyName === \"label\") {\r\n modifyEntry.difference.label = propertyValue;\r\n hasChanges = true;\r\n }\r\n if (propertyName === \"description\") {\r\n modifyEntry.difference.description = propertyValue;\r\n hasChanges = true;\r\n }\r\n\r\n if (addEntry && hasChanges) {\r\n this.schemaDifferences.push(modifyEntry);\r\n }\r\n }\r\n\r\n private visitMissingSchemaItem(diagnostic: AnyDiagnostic) {\r\n const schemaItem = diagnostic.ecDefinition as AnySchemaItem;\r\n\r\n this.schemaItemDifferences.push({\r\n changeType: \"add\",\r\n schemaType: schemaItem.schemaItemType,\r\n itemName: schemaItem.name,\r\n difference: schemaItem.toJSON(),\r\n });\r\n }\r\n\r\n private visitChangedSchemaItem(diagnostic: AnyDiagnostic) {\r\n const schemaItem = diagnostic.ecDefinition as AnySchemaItem;\r\n const [propertyName, sourceValue, _targetValue] = diagnostic.messageArgs as [string, unknown, unknown];\r\n if (propertyName === \"schemaItemType\") {\r\n // If the schema item type is different, the whole item is added as \"new\" item. The\r\n // difference validator will then figure whether there is a conflict with items of\r\n // of the same name.\r\n return this.visitMissingSchemaItem(diagnostic);\r\n }\r\n\r\n if (sourceValue === undefined) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.schemaItemDifferences.find((entry): entry is AnySchemaItemDifference => {\r\n return entry.changeType === \"modify\" && entry.itemName === schemaItem.name;\r\n });\r\n\r\n if (modifyEntry === undefined) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: schemaItem.schemaItemType,\r\n itemName: schemaItem.name,\r\n difference: {},\r\n } as AnySchemaItemDifference;\r\n this.schemaItemDifferences.push(modifyEntry);\r\n }\r\n\r\n // TODO: Since propertyName is type of string, the compiler complains about accepting\r\n // an unspecific string as property indexer. Casted to any as short term fix but that\r\n // needs to be handled better in future.\r\n (modifyEntry.difference as any)[propertyName] = sourceValue;\r\n }\r\n\r\n private visitMissingEnumerator(diagnostic: AnyDiagnostic) {\r\n const enumeration = diagnostic.ecDefinition as Enumeration;\r\n const [enumerator] = diagnostic.messageArgs as [AnyEnumerator];\r\n this.schemaItemPathDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.Enumerator,\r\n itemName: enumeration.name,\r\n path: \"$enumerators\",\r\n difference: enumerator,\r\n });\r\n }\r\n\r\n private lookupEnumeratorEntry(changeType: DifferenceType, item: string, enumeratorName: string) {\r\n return this.schemaItemPathDifferences.find((change) => {\r\n return change.changeType === changeType\r\n && change.schemaType === SchemaOtherTypes.Enumerator\r\n && change.itemName === item\r\n && change.path === \"$enumerators\"\r\n && change.difference.name === enumeratorName;\r\n });\r\n }\r\n\r\n private visitChangedEnumerator(diagnostic: AnyDiagnostic) {\r\n const enumeration = diagnostic.ecDefinition as Enumeration;\r\n const [enumerator, propertyName, sourceValue] = diagnostic.messageArgs as [AnyEnumerator, keyof AnyEnumerator, any];\r\n if (this.lookupEnumeratorEntry(\"add\", enumeration.name, enumerator.name)) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.schemaItemPathDifferences.find((entry): entry is EnumeratorDifference => {\r\n return entry.changeType === \"modify\" && entry.schemaType === SchemaOtherTypes.Enumerator && entry.itemName === enumeration.name && entry.path === enumerator.name;\r\n });\r\n\r\n if (modifyEntry === undefined) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: SchemaOtherTypes.Enumerator,\r\n itemName: enumeration.name,\r\n path: enumerator.name,\r\n difference: {},\r\n };\r\n this.schemaItemPathDifferences.push(modifyEntry);\r\n }\r\n\r\n if (sourceValue !== undefined) {\r\n modifyEntry.difference[propertyName] = sourceValue;\r\n }\r\n }\r\n\r\n private visitMissingProperty(diagnostic: AnyDiagnostic) {\r\n const property = diagnostic.ecDefinition as Property;\r\n this.schemaItemPathDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.Property,\r\n itemName: property.class.name,\r\n path: property.name,\r\n difference: property.toJSON() as AnyPropertyProps,\r\n });\r\n }\r\n\r\n private visitChangedProperty(diagnostic: AnyDiagnostic) {\r\n const property = diagnostic.ecDefinition as Property;\r\n const [propertyName, sourceValue] = diagnostic.messageArgs as [keyof PropertyProps, any, any];\r\n\r\n if (isPropertyTypeName(property, propertyName)) {\r\n return this.visitMissingProperty(diagnostic);\r\n }\r\n\r\n let modifyEntry = this.schemaItemPathDifferences.find((entry): entry is ClassPropertyDifference => {\r\n return entry.changeType === \"modify\" && entry.schemaType === SchemaOtherTypes.Property && entry.itemName === property.class.name && entry.path === property.name;\r\n });\r\n\r\n if (modifyEntry === undefined) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: SchemaOtherTypes.Property,\r\n itemName: property.class.name,\r\n path: property.name,\r\n difference: {},\r\n };\r\n this.schemaItemPathDifferences.push(modifyEntry);\r\n }\r\n\r\n if (propertyName !== \"name\") {\r\n modifyEntry.difference[propertyName] = sourceValue;\r\n }\r\n }\r\n\r\n private visitMissingBaseClass(diagnostic: AnyDiagnostic) {\r\n const ecClass = diagnostic.ecDefinition as ECClass;\r\n const [sourceBaseClass] = diagnostic.messageArgs as [ECClass, ECClass];\r\n\r\n let modifyEntry = this.schemaItemDifferences.find((entry): entry is AnyClassItemDifference => {\r\n return entry.changeType === \"modify\" && entry.schemaType === ecClass.schemaItemType && entry.itemName === ecClass.name;\r\n });\r\n\r\n if (modifyEntry === undefined) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: ecClass.schemaItemType,\r\n itemName: ecClass.name,\r\n difference: {},\r\n } as AnyClassItemDifference;\r\n this.schemaItemDifferences.push(modifyEntry);\r\n }\r\n\r\n modifyEntry.difference.baseClass = sourceBaseClass !== undefined ? sourceBaseClass.fullName : undefined;\r\n }\r\n\r\n private visitMissingMixinOnClass(diagnostic: AnyDiagnostic) {\r\n const ecClass = diagnostic.ecDefinition as ECClass;\r\n const [mixin] = diagnostic.messageArgs as [Mixin];\r\n\r\n let addEntry = this.schemaItemDifferences.find((entry): entry is EntityClassMixinDifference => {\r\n return entry.changeType === \"add\" && entry.schemaType === SchemaOtherTypes.EntityClassMixin && entry.itemName === ecClass.name;\r\n });\r\n\r\n if (addEntry === undefined) {\r\n addEntry = {\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.EntityClassMixin,\r\n itemName: ecClass.name,\r\n difference: [],\r\n };\r\n this.schemaItemDifferences.push(addEntry);\r\n }\r\n addEntry.difference.push(mixin.fullName);\r\n }\r\n\r\n private visitMissingRelationshipConstraintClass(diagnostic: AnyDiagnostic) {\r\n const constraint = diagnostic.ecDefinition as RelationshipConstraint;\r\n const className = constraint.relationshipClass.name;\r\n const constraintPath = constraint.isSource ? \"$source\" : \"$target\";\r\n\r\n let addEntry = this.schemaItemPathDifferences.find((entry): entry is RelationshipConstraintClassDifference => {\r\n return entry.changeType === \"add\" && entry.schemaType === SchemaOtherTypes.RelationshipConstraintClass, entry.itemName === className && entry.path === constraintPath;\r\n });\r\n\r\n if (!addEntry) {\r\n addEntry = {\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.RelationshipConstraintClass,\r\n itemName: className,\r\n path: constraintPath,\r\n difference: [],\r\n };\r\n this.schemaItemPathDifferences.push(addEntry);\r\n }\r\n\r\n const [constraintClass] = diagnostic.messageArgs as [ECClass];\r\n addEntry.difference.push(constraintClass.fullName);\r\n }\r\n\r\n private visitChangedRelationshipConstraint(diagnostic: AnyDiagnostic) {\r\n const constraint = diagnostic.ecDefinition as RelationshipConstraint;\r\n const className = constraint.relationshipClass.name;\r\n const constraintPath = constraint.isSource ? \"$source\" : \"$target\";\r\n if (this.schemaItemDifferences.find((entry) => entry.changeType === \"add\" && entry.itemName === className)) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.schemaItemPathDifferences.find((entry): entry is RelationshipConstraintDifference => {\r\n return entry.changeType === \"modify\" && entry.schemaType === SchemaOtherTypes.RelationshipConstraint && entry.itemName === className && entry.path === constraintPath;\r\n });\r\n\r\n if (modifyEntry === undefined) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: SchemaOtherTypes.RelationshipConstraint,\r\n itemName: className,\r\n path: constraintPath,\r\n difference: {},\r\n };\r\n this.schemaItemPathDifferences.push(modifyEntry);\r\n }\r\n\r\n const [propertyName, propertyValue] = diagnostic.messageArgs as [keyof RelationshipConstraintProps, any];\r\n if (propertyName === \"abstractConstraint\" && propertyValue !== undefined) {\r\n modifyEntry.difference.abstractConstraint = propertyValue;\r\n }\r\n if (propertyName === \"multiplicity\" && propertyValue !== undefined) {\r\n modifyEntry.difference.multiplicity = propertyValue;\r\n }\r\n if (propertyName === \"polymorphic\" && propertyValue !== undefined) {\r\n modifyEntry.difference.polymorphic = propertyValue;\r\n }\r\n if (propertyName === \"roleLabel\" && propertyValue !== undefined) {\r\n modifyEntry.difference.roleLabel = propertyValue;\r\n }\r\n }\r\n\r\n private visitSchemaReference(diagnostic: AnyDiagnostic, changeType: DifferenceType) {\r\n const [referencedSchema] = diagnostic.messageArgs as [Schema];\r\n this.schemaDifferences.push({\r\n changeType,\r\n schemaType: SchemaOtherTypes.SchemaReference,\r\n difference: {\r\n name: referencedSchema.name,\r\n version: referencedSchema.schemaKey.version.toString(),\r\n },\r\n });\r\n }\r\n\r\n private visitMissingCustomAttributeInstance(diagnostic: AnyDiagnostic) {\r\n const [customAttribute] = diagnostic.messageArgs as [CustomAttribute];\r\n const ecType = diagnostic.ecDefinition;\r\n if (Schema.isSchema(ecType)) {\r\n return this.customAttributeDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.CustomAttributeInstance,\r\n appliedTo: \"Schema\",\r\n difference: customAttribute,\r\n });\r\n }\r\n\r\n if (SchemaItem.isSchemaItem(ecType)) {\r\n return this.customAttributeDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.CustomAttributeInstance,\r\n appliedTo: \"SchemaItem\",\r\n itemName: ecType.name,\r\n difference: customAttribute,\r\n });\r\n }\r\n\r\n if (Property.isProperty(ecType)) {\r\n return this.customAttributeDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.CustomAttributeInstance,\r\n appliedTo: \"Property\",\r\n itemName: ecType.class.name,\r\n path: ecType.name,\r\n difference: customAttribute,\r\n });\r\n }\r\n\r\n if (RelationshipConstraint.isRelationshipConstraint(ecType)) {\r\n return this.customAttributeDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.CustomAttributeInstance,\r\n appliedTo: \"RelationshipConstraint\",\r\n itemName: ecType.relationshipClass.name,\r\n path: ecType.isSource ? \"$source\" : \"$target\",\r\n difference: customAttribute,\r\n });\r\n }\r\n return;\r\n }\r\n\r\n private visitMissingPresentationUnit(diagnostic: AnyDiagnostic) {\r\n const koq = diagnostic.ecDefinition as KindOfQuantity;\r\n const [presentationFormat] = diagnostic.messageArgs as [Format | OverrideFormat];\r\n\r\n let addEntry = this.schemaItemDifferences.find((entry): entry is KindOfQuantityPresentationFormatDifference => {\r\n return entry.changeType === \"add\" && entry.schemaType === SchemaOtherTypes.KindOfQuantityPresentationFormat\r\n && entry.itemName === koq.name;\r\n });\r\n\r\n if (addEntry === undefined) {\r\n addEntry = {\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.KindOfQuantityPresentationFormat,\r\n itemName: koq.name,\r\n difference: [],\r\n };\r\n this.schemaItemDifferences.push(addEntry);\r\n }\r\n addEntry.difference.push(presentationFormat.fullName);\r\n }\r\n}\r\n\r\nfunction isPropertyTypeName(property: Property, propertyName: string) {\r\n return (propertyName === \"type\") ||\r\n (property.isEnumeration() && propertyName === \"enumeration\") ||\r\n (property.isPrimitive() && propertyName === \"primitiveType\") ||\r\n (property.isStruct() && propertyName === \"structClass\") ||\r\n (property.isNavigation() && propertyName === \"relationshipClass\");\r\n}\r\n"]}
1
+ {"version":3,"file":"SchemaDiagnosticVisitor.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDiagnosticVisitor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,qFAA4E;AAC5E,gEAIkC;AAClC,yDAe4B;AAE5B;;;;;GAKG;AACH,MAAa,uBAAuB;IAOlC;QACE,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,yBAAyB,GAAG,EAAE,CAAC;QACpC,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,UAAyB;QACpC,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;YACxB,KAAK,6CAAkB,CAAC,WAAW;gBACjC,OAAO,IAAI,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC;YAEvD,KAAK,6CAAkB,CAAC,sBAAsB;gBAC5C,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YACtD,KAAK,6CAAkB,CAAC,oBAAoB;gBAC1C,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YAEzD,KAAK,6CAAkB,CAAC,iBAAiB;gBACvC,OAAO,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC;YAEjD,KAAK,6CAAkB,CAAC,eAAe,CAAC;YACxC,KAAK,6CAAkB,CAAC,UAAU,CAAC;YACnC,KAAK,6CAAkB,CAAC,aAAa,CAAC;YACtC,KAAK,6CAAkB,CAAC,yBAAyB,CAAC;YAClD,KAAK,6CAAkB,CAAC,WAAW,CAAC;YACpC,KAAK,6CAAkB,CAAC,iBAA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ACf,CAAC;YACF,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;QACD,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;CACF;AA1aD,0DA0aC;AAED,SAAS,kBAAkB,CAAC,QAAkB,EAAE,YAAoB;IAClE,OAAO,CAAC,YAAY,KAAK,MAAM,CAAC;QAC9B,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,YAAY,KAAK,aAAa,CAAC;QAC5D,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,YAAY,KAAK,eAAe,CAAC;QAC5D,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,YAAY,KAAK,aAAa,CAAC;QACvD,CAAC,QAAQ,CAAC,YAAY,EAAE,IAAI,YAAY,KAAK,mBAAmB,CAAC,CAAC;AACtE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Differencing\r\n */\r\n\r\nimport type { AnyDiagnostic } from \"../Validation/Diagnostic\";\r\nimport { SchemaCompareCodes } from \"../Validation/SchemaCompareDiagnostics\";\r\nimport {\r\n AnyEnumerator, AnyPropertyProps, AnySchemaItem, CustomAttribute, ECClass,\r\n Enumeration, Format, KindOfQuantity, Mixin, OverrideFormat, Property, PropertyProps,\r\n RelationshipConstraint, RelationshipConstraintProps, Schema, SchemaItem,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport {\r\n type AnyClassItemDifference,\r\n type AnySchemaItemDifference,\r\n type AnySchemaItemPathDifference,\r\n type ClassPropertyDifference,\r\n type CustomAttributeDifference,\r\n type DifferenceType,\r\n type EntityClassMixinDifference,\r\n type EnumeratorDifference,\r\n type KindOfQuantityPresentationFormatDifference,\r\n type RelationshipConstraintClassDifference,\r\n type RelationshipConstraintDifference,\r\n type SchemaDifference,\r\n SchemaOtherTypes,\r\n type SchemaReferenceDifference,\r\n} from \"./SchemaDifference\";\r\n\r\n/**\r\n * The SchemaDiagnosticVisitor is a visitor implementation for diagnostic entries\r\n * from the schema comparer api. Depending on the diagnostic code, the difference\r\n * result is build together.\r\n * @internal\r\n */\r\nexport class SchemaDiagnosticVisitor {\r\n\r\n public readonly schemaDifferences: Array<SchemaDifference | SchemaReferenceDifference>;\r\n public readonly schemaItemDifferences: Array<AnySchemaItemDifference | EntityClassMixinDifference | KindOfQuantityPresentationFormatDifference>;\r\n public readonly schemaItemPathDifferences: Array<AnySchemaItemPathDifference>;\r\n public readonly customAttributeDifferences: Array<CustomAttributeDifference>;\r\n\r\n constructor() {\r\n this.schemaDifferences = [];\r\n this.schemaItemDifferences = [];\r\n this.schemaItemPathDifferences = [];\r\n this.customAttributeDifferences = [];\r\n }\r\n\r\n /**\r\n * Visitor function to process the schema change diagnostic object.\r\n * @internal\r\n */\r\n public visit(diagnostic: AnyDiagnostic) {\r\n switch (diagnostic.code) {\r\n case SchemaCompareCodes.SchemaDelta:\r\n return this.visitChangedSchemaProperties(diagnostic);\r\n\r\n case SchemaCompareCodes.SchemaReferenceMissing:\r\n return this.visitSchemaReference(diagnostic, \"add\");\r\n case SchemaCompareCodes.SchemaReferenceDelta:\r\n return this.visitSchemaReference(diagnostic, \"modify\");\r\n\r\n case SchemaCompareCodes.SchemaItemMissing:\r\n return this.visitMissingSchemaItem(diagnostic);\r\n\r\n case SchemaCompareCodes.SchemaItemDelta:\r\n case SchemaCompareCodes.ClassDelta:\r\n case SchemaCompareCodes.ConstantDelta:\r\n case SchemaCompareCodes.CustomAttributeClassDelta:\r\n case SchemaCompareCodes.FormatDelta:\r\n case SchemaCompareCodes.InvertedUnitDelta:\r\n case SchemaCompareCodes.KoqDelta:\r\n case SchemaCompareCodes.MixinDelta:\r\n case SchemaCompareCodes.PhenomenonDelta:\r\n case SchemaCompareCodes.PropertyCategoryDelta:\r\n case SchemaCompareCodes.RelationshipDelta:\r\n case SchemaCompareCodes.UnitDelta:\r\n case SchemaCompareCodes.EnumerationDelta:\r\n return this.visitChangedSchemaItem(diagnostic);\r\n\r\n case SchemaCompareCodes.EnumeratorDelta:\r\n return this.visitChangedEnumerator(diagnostic);\r\n case SchemaCompareCodes.EnumeratorMissing:\r\n return this.visitMissingEnumerator(diagnostic);\r\n\r\n case SchemaCompareCodes.BaseClassDelta:\r\n return this.visitMissingBaseClass(diagnostic);\r\n case SchemaCompareCodes.EntityMixinMissing:\r\n return this.visitMissingMixinOnClass(diagnostic);\r\n case SchemaCompareCodes.PropertyDelta:\r\n return this.visitChangedProperty(diagnostic);\r\n case SchemaCompareCodes.PropertyMissing:\r\n return this.visitMissingProperty(diagnostic);\r\n\r\n case SchemaCompareCodes.RelationshipConstraintClassMissing:\r\n return this.visitMissingRelationshipConstraintClass(diagnostic);\r\n case SchemaCompareCodes.RelationshipConstraintDelta:\r\n return this.visitChangedRelationshipConstraint(diagnostic);\r\n\r\n case SchemaCompareCodes.CustomAttributeInstanceClassMissing:\r\n return this.visitMissingCustomAttributeInstance(diagnostic);\r\n\r\n case SchemaCompareCodes.PresentationUnitMissing:\r\n return this.visitMissingPresentationUnit(diagnostic);\r\n\r\n // Currently not handled...\r\n case SchemaCompareCodes.FormatUnitMissing:\r\n case SchemaCompareCodes.UnitLabelOverrideDelta:\r\n break;\r\n }\r\n return;\r\n }\r\n\r\n private visitChangedSchemaProperties(diagnostic: AnyDiagnostic) {\r\n let modifyEntry = this.schemaDifferences.find((entry): entry is SchemaDifference => {\r\n return entry.changeType === \"modify\" && entry.schemaType === SchemaOtherTypes.Schema;\r\n });\r\n\r\n let hasChanges = false;\r\n let addEntry = false;\r\n if (modifyEntry === undefined) {\r\n addEntry = true;\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: SchemaOtherTypes.Schema,\r\n difference: {},\r\n };\r\n }\r\n\r\n // Only label and description are taken from the source schema. If the schema name or alias\r\n // differs, those are ignored for now.\r\n const [propertyName, propertyValue] = diagnostic.messageArgs as [string, any];\r\n if (propertyName === \"label\") {\r\n modifyEntry.difference.label = propertyValue;\r\n hasChanges = true;\r\n }\r\n if (propertyName === \"description\") {\r\n modifyEntry.difference.description = propertyValue;\r\n hasChanges = true;\r\n }\r\n\r\n if (addEntry && hasChanges) {\r\n this.schemaDifferences.push(modifyEntry);\r\n }\r\n }\r\n\r\n private visitMissingSchemaItem(diagnostic: AnyDiagnostic) {\r\n const schemaItem = diagnostic.ecDefinition as AnySchemaItem;\r\n\r\n this.schemaItemDifferences.push({\r\n changeType: \"add\",\r\n schemaType: schemaItem.schemaItemType,\r\n itemName: schemaItem.name,\r\n difference: schemaItem.toJSON(),\r\n });\r\n }\r\n\r\n private visitChangedSchemaItem(diagnostic: AnyDiagnostic) {\r\n const schemaItem = diagnostic.ecDefinition as AnySchemaItem;\r\n const [propertyName, sourceValue, _targetValue] = diagnostic.messageArgs as [string, unknown, unknown];\r\n if (propertyName === \"schemaItemType\") {\r\n // If the schema item type is different, the whole item is added as \"new\" item. The\r\n // difference validator will then figure whether there is a conflict with items of\r\n // of the same name.\r\n return this.visitMissingSchemaItem(diagnostic);\r\n }\r\n\r\n if (sourceValue === undefined) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.schemaItemDifferences.find((entry): entry is AnySchemaItemDifference => {\r\n return entry.changeType === \"modify\" && entry.itemName === schemaItem.name;\r\n });\r\n\r\n if (modifyEntry === undefined) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: schemaItem.schemaItemType,\r\n itemName: schemaItem.name,\r\n difference: {},\r\n } as AnySchemaItemDifference;\r\n this.schemaItemDifferences.push(modifyEntry);\r\n }\r\n\r\n // TODO: Since propertyName is type of string, the compiler complains about accepting\r\n // an unspecific string as property indexer. Casted to any as short term fix but that\r\n // needs to be handled better in future.\r\n (modifyEntry.difference as any)[propertyName] = sourceValue;\r\n }\r\n\r\n private visitMissingEnumerator(diagnostic: AnyDiagnostic) {\r\n const enumeration = diagnostic.ecDefinition as Enumeration;\r\n const [enumerator] = diagnostic.messageArgs as [AnyEnumerator];\r\n this.schemaItemPathDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.Enumerator,\r\n itemName: enumeration.name,\r\n path: \"$enumerators\",\r\n difference: enumerator,\r\n });\r\n }\r\n\r\n private lookupEnumeratorEntry(changeType: DifferenceType, item: string, enumeratorName: string) {\r\n return this.schemaItemPathDifferences.find((change) => {\r\n return change.changeType === changeType\r\n && change.schemaType === SchemaOtherTypes.Enumerator\r\n && change.itemName === item\r\n && change.path === \"$enumerators\"\r\n && change.difference.name === enumeratorName;\r\n });\r\n }\r\n\r\n private visitChangedEnumerator(diagnostic: AnyDiagnostic) {\r\n const enumeration = diagnostic.ecDefinition as Enumeration;\r\n const [enumerator, propertyName, sourceValue] = diagnostic.messageArgs as [AnyEnumerator, keyof AnyEnumerator, any];\r\n if (this.lookupEnumeratorEntry(\"add\", enumeration.name, enumerator.name)) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.schemaItemPathDifferences.find((entry): entry is EnumeratorDifference => {\r\n return entry.changeType === \"modify\" && entry.schemaType === SchemaOtherTypes.Enumerator && entry.itemName === enumeration.name && entry.path === enumerator.name;\r\n });\r\n\r\n if (modifyEntry === undefined) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: SchemaOtherTypes.Enumerator,\r\n itemName: enumeration.name,\r\n path: enumerator.name,\r\n difference: {},\r\n };\r\n this.schemaItemPathDifferences.push(modifyEntry);\r\n }\r\n\r\n if (sourceValue !== undefined) {\r\n modifyEntry.difference[propertyName] = sourceValue;\r\n }\r\n }\r\n\r\n private visitMissingProperty(diagnostic: AnyDiagnostic) {\r\n const property = diagnostic.ecDefinition as Property;\r\n this.schemaItemPathDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.Property,\r\n itemName: property.class.name,\r\n path: property.name,\r\n difference: property.toJSON() as AnyPropertyProps,\r\n });\r\n }\r\n\r\n private visitChangedProperty(diagnostic: AnyDiagnostic) {\r\n const property = diagnostic.ecDefinition as Property;\r\n const [propertyName, sourceValue] = diagnostic.messageArgs as [keyof PropertyProps, any, any];\r\n\r\n if (isPropertyTypeName(property, propertyName)) {\r\n return this.visitMissingProperty(diagnostic);\r\n }\r\n\r\n let modifyEntry = this.schemaItemPathDifferences.find((entry): entry is ClassPropertyDifference => {\r\n return entry.changeType === \"modify\" && entry.schemaType === SchemaOtherTypes.Property && entry.itemName === property.class.name && entry.path === property.name;\r\n });\r\n\r\n if (modifyEntry === undefined) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: SchemaOtherTypes.Property,\r\n itemName: property.class.name,\r\n path: property.name,\r\n difference: {},\r\n };\r\n this.schemaItemPathDifferences.push(modifyEntry);\r\n }\r\n\r\n if (propertyName !== \"name\") {\r\n modifyEntry.difference[propertyName] = sourceValue;\r\n }\r\n }\r\n\r\n private visitMissingBaseClass(diagnostic: AnyDiagnostic) {\r\n const ecClass = diagnostic.ecDefinition as ECClass;\r\n const [sourceBaseClass] = diagnostic.messageArgs as [ECClass, ECClass];\r\n\r\n let modifyEntry = this.schemaItemDifferences.find((entry): entry is AnyClassItemDifference => {\r\n return entry.changeType === \"modify\" && entry.schemaType === ecClass.schemaItemType && entry.itemName === ecClass.name;\r\n });\r\n\r\n if (modifyEntry === undefined) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: ecClass.schemaItemType,\r\n itemName: ecClass.name,\r\n difference: {},\r\n } as AnyClassItemDifference;\r\n this.schemaItemDifferences.push(modifyEntry);\r\n }\r\n\r\n modifyEntry.difference.baseClass = sourceBaseClass !== undefined ? sourceBaseClass.fullName : undefined;\r\n }\r\n\r\n private visitMissingMixinOnClass(diagnostic: AnyDiagnostic) {\r\n const ecClass = diagnostic.ecDefinition as ECClass;\r\n const [mixin] = diagnostic.messageArgs as [Mixin];\r\n\r\n let addEntry = this.schemaItemDifferences.find((entry): entry is EntityClassMixinDifference => {\r\n return entry.changeType === \"add\" && entry.schemaType === SchemaOtherTypes.EntityClassMixin && entry.itemName === ecClass.name;\r\n });\r\n\r\n if (addEntry === undefined) {\r\n addEntry = {\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.EntityClassMixin,\r\n itemName: ecClass.name,\r\n difference: [],\r\n };\r\n this.schemaItemDifferences.push(addEntry);\r\n }\r\n addEntry.difference.push(mixin.fullName);\r\n }\r\n\r\n private visitMissingRelationshipConstraintClass(diagnostic: AnyDiagnostic) {\r\n const constraint = diagnostic.ecDefinition as RelationshipConstraint;\r\n const className = constraint.relationshipClass.name;\r\n const constraintPath = constraint.isSource ? \"$source\" : \"$target\";\r\n\r\n let addEntry = this.schemaItemPathDifferences.find((entry): entry is RelationshipConstraintClassDifference => {\r\n return entry.changeType === \"add\" && entry.schemaType === SchemaOtherTypes.RelationshipConstraintClass, entry.itemName === className && entry.path === constraintPath;\r\n });\r\n\r\n if (!addEntry) {\r\n addEntry = {\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.RelationshipConstraintClass,\r\n itemName: className,\r\n path: constraintPath,\r\n difference: [],\r\n };\r\n this.schemaItemPathDifferences.push(addEntry);\r\n }\r\n\r\n const [constraintClass] = diagnostic.messageArgs as [ECClass];\r\n addEntry.difference.push(constraintClass.fullName);\r\n }\r\n\r\n private visitChangedRelationshipConstraint(diagnostic: AnyDiagnostic) {\r\n const constraint = diagnostic.ecDefinition as RelationshipConstraint;\r\n const className = constraint.relationshipClass.name;\r\n const constraintPath = constraint.isSource ? \"$source\" : \"$target\";\r\n if (this.schemaItemDifferences.find((entry) => entry.changeType === \"add\" && entry.itemName === className)) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.schemaItemPathDifferences.find((entry): entry is RelationshipConstraintDifference => {\r\n return entry.changeType === \"modify\" && entry.schemaType === SchemaOtherTypes.RelationshipConstraint && entry.itemName === className && entry.path === constraintPath;\r\n });\r\n\r\n if (modifyEntry === undefined) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: SchemaOtherTypes.RelationshipConstraint,\r\n itemName: className,\r\n path: constraintPath,\r\n difference: {},\r\n };\r\n this.schemaItemPathDifferences.push(modifyEntry);\r\n }\r\n\r\n const [propertyName, propertyValue] = diagnostic.messageArgs as [keyof RelationshipConstraintProps, any];\r\n if (propertyName === \"abstractConstraint\" && propertyValue !== undefined) {\r\n modifyEntry.difference.abstractConstraint = propertyValue;\r\n }\r\n if (propertyName === \"multiplicity\" && propertyValue !== undefined) {\r\n modifyEntry.difference.multiplicity = propertyValue;\r\n }\r\n if (propertyName === \"polymorphic\" && propertyValue !== undefined) {\r\n modifyEntry.difference.polymorphic = propertyValue;\r\n }\r\n if (propertyName === \"roleLabel\" && propertyValue !== undefined) {\r\n modifyEntry.difference.roleLabel = propertyValue;\r\n }\r\n }\r\n\r\n private visitSchemaReference(diagnostic: AnyDiagnostic, changeType: DifferenceType) {\r\n const [referencedSchema] = diagnostic.messageArgs as [Schema];\r\n this.schemaDifferences.push({\r\n changeType,\r\n schemaType: SchemaOtherTypes.SchemaReference,\r\n difference: {\r\n name: referencedSchema.name,\r\n version: referencedSchema.schemaKey.version.toString(),\r\n },\r\n });\r\n }\r\n\r\n private visitMissingCustomAttributeInstance(diagnostic: AnyDiagnostic) {\r\n const [customAttribute] = diagnostic.messageArgs as [CustomAttribute];\r\n const ecType = diagnostic.ecDefinition;\r\n if (Schema.isSchema(ecType)) {\r\n return this.customAttributeDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.CustomAttributeInstance,\r\n appliedTo: \"Schema\",\r\n difference: customAttribute,\r\n });\r\n }\r\n\r\n if (SchemaItem.isSchemaItem(ecType)) {\r\n return this.customAttributeDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.CustomAttributeInstance,\r\n appliedTo: \"SchemaItem\",\r\n itemName: ecType.name,\r\n difference: customAttribute,\r\n });\r\n }\r\n\r\n if (Property.isProperty(ecType)) {\r\n return this.customAttributeDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.CustomAttributeInstance,\r\n appliedTo: \"Property\",\r\n itemName: ecType.class.name,\r\n path: ecType.name,\r\n difference: customAttribute,\r\n });\r\n }\r\n\r\n if (RelationshipConstraint.isRelationshipConstraint(ecType)) {\r\n return this.customAttributeDifferences.push({\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.CustomAttributeInstance,\r\n appliedTo: \"RelationshipConstraint\",\r\n itemName: ecType.relationshipClass.name,\r\n path: ecType.isSource ? \"$source\" : \"$target\",\r\n difference: customAttribute,\r\n });\r\n }\r\n return;\r\n }\r\n\r\n private visitMissingPresentationUnit(diagnostic: AnyDiagnostic) {\r\n const koq = diagnostic.ecDefinition as KindOfQuantity;\r\n const [presentationFormat] = diagnostic.messageArgs as [Format | OverrideFormat];\r\n\r\n let addEntry = this.schemaItemDifferences.find((entry): entry is KindOfQuantityPresentationFormatDifference => {\r\n return entry.changeType === \"add\" && entry.schemaType === SchemaOtherTypes.KindOfQuantityPresentationFormat\r\n && entry.itemName === koq.name;\r\n });\r\n\r\n if (addEntry === undefined) {\r\n addEntry = {\r\n changeType: \"add\",\r\n schemaType: SchemaOtherTypes.KindOfQuantityPresentationFormat,\r\n itemName: koq.name,\r\n difference: [],\r\n };\r\n this.schemaItemDifferences.push(addEntry);\r\n }\r\n addEntry.difference.push(presentationFormat.fullName);\r\n }\r\n}\r\n\r\nfunction isPropertyTypeName(property: Property, propertyName: string) {\r\n return (propertyName === \"type\") ||\r\n (property.isEnumeration() && propertyName === \"enumeration\") ||\r\n (property.isPrimitive() && propertyName === \"primitiveType\") ||\r\n (property.isStruct() && propertyName === \"structClass\") ||\r\n (property.isNavigation() && propertyName === \"relationshipClass\");\r\n}\r\n"]}
@@ -2,6 +2,7 @@
2
2
  * @module Differencing
3
3
  */
4
4
  import { AnySchemaDifferenceConflict } from "./SchemaConflicts";
5
+ import { AnySchemaEdits } from "../Merging/Edits/SchemaEdits";
5
6
  import { AnyEnumerator, AnyPropertyProps, ConstantProps, CustomAttribute, CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps, MixinProps, PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, RelationshipConstraintProps, type Schema, SchemaItemFormatProps, SchemaItemProps, SchemaItemType, SchemaItemUnitProps, SchemaReferenceProps, StructClassProps, UnitSystemProps } from "@itwin/ecschema-metadata";
6
7
  /** Utility-Type to remove possible readonly flags on the given type. */
7
8
  type PartialEditable<T> = {
@@ -323,6 +324,6 @@ export interface KindOfQuantityPresentationFormatDifference {
323
324
  * @returns An [[SchemaDifferenceResult]] object.
324
325
  * @alpha
325
326
  */
326
- export declare function getSchemaDifferences(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferenceResult>;
327
+ export declare function getSchemaDifferences(targetSchema: Schema, sourceSchema: Schema, schemaEdits?: Iterable<AnySchemaEdits>): Promise<SchemaDifferenceResult>;
327
328
  export {};
328
329
  //# sourceMappingURL=SchemaDifference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaDifference.d.ts","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAIhE,OAAO,EACL,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAC/D,yBAAyB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EACrG,UAAU,EAAE,eAAe,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,2BAA2B,EACvG,KAAK,MAAM,EAAE,qBAAqB,EAAE,eAAe,EAAE,cAAc,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAClJ,MAAM,0BAA0B,CAAC;AAGlC,wEAAwE;AACxE,KAAK,eAAe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S,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC,IAAI,CAAC,2BAA2B,EAAE,mBAAmB,CAAC,CAAC,CAAC;CAC9F;AAED;;;GAGG;AACH,MAAM,WAAW,qCAAqC;IACpD,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,2BAA2B,CAAC;IAClE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,0CAA0C;IACzD,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,gCAAgC,CAAC;IACvE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAmC9J"}
@@ -9,9 +9,12 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.SchemaOtherTypes = void 0;
11
11
  exports.getSchemaDifferences = getSchemaDifferences;
12
+ const SchemaEdits_1 = require("../Merging/Edits/SchemaEdits");
12
13
  const SchemaDiagnosticVisitor_1 = require("./SchemaDiagnosticVisitor");
13
14
  const SchemaComparer_1 = require("../Validation/SchemaComparer");
15
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
14
16
  const SchemaDifferenceValidator_1 = require("./SchemaDifferenceValidator");
17
+ const NameMapping_1 = require("../Merging/Edits/NameMapping");
15
18
  /**
16
19
  * Defines the SchemaTypes that are not SchemaItems.
17
20
  * @alpha
@@ -35,12 +38,21 @@ var SchemaOtherTypes;
35
38
  * @returns An [[SchemaDifferenceResult]] object.
36
39
  * @alpha
37
40
  */
38
- async function getSchemaDifferences(targetSchema, sourceSchema) {
39
- const changesList = [];
40
- const schemaComparer = new SchemaComparer_1.SchemaComparer({ report: changesList.push.bind(changesList) });
41
+ async function getSchemaDifferences(targetSchema, sourceSchema, schemaEdits) {
42
+ const schemaComparer = new DifferenceSchemaComparer();
43
+ if (schemaEdits) {
44
+ for (const edit of schemaEdits) {
45
+ if (edit.type === SchemaEdits_1.SchemaEditType.RenameSchemaItem) {
46
+ schemaComparer.nameMappings.addItemMapping(edit.key, edit.value);
47
+ }
48
+ if (edit.type === SchemaEdits_1.SchemaEditType.RenameProperty) {
49
+ schemaComparer.nameMappings.addPropertyMapping(edit.key, edit.value);
50
+ }
51
+ }
52
+ }
41
53
  await schemaComparer.compareSchemas(sourceSchema, targetSchema);
42
54
  const visitor = new SchemaDiagnosticVisitor_1.SchemaDiagnosticVisitor();
43
- for (const diagnostic of changesList[0].allDiagnostics) {
55
+ for (const diagnostic of schemaComparer.diagnostics) {
44
56
  visitor.visit(diagnostic);
45
57
  }
46
58
  const differences = [
@@ -49,7 +61,7 @@ async function getSchemaDifferences(targetSchema, sourceSchema) {
49
61
  ...visitor.schemaItemPathDifferences,
50
62
  ...visitor.customAttributeDifferences,
51
63
  ];
52
- const conflicts = await (0, SchemaDifferenceValidator_1.validateDifferences)(differences, targetSchema, sourceSchema);
64
+ const conflicts = await (0, SchemaDifferenceValidator_1.validateDifferences)(differences, targetSchema, sourceSchema, schemaComparer.nameMappings);
53
65
  return {
54
66
  sourceSchemaName: sourceSchema.schemaKey.toString(),
55
67
  targetSchemaName: targetSchema.schemaKey.toString(),
@@ -57,4 +69,38 @@ async function getSchemaDifferences(targetSchema, sourceSchema) {
57
69
  differences,
58
70
  };
59
71
  }
72
+ /**
73
+ * Implementation of a SchemaComparer that is used in the schema differencing process.
74
+ * It extends the SchemaComparer base class with additional functionality to store the
75
+ * name mappings of renamed schema items and properties.
76
+ *
77
+ * @internal
78
+ */
79
+ class DifferenceSchemaComparer extends SchemaComparer_1.SchemaComparer {
80
+ get diagnostics() {
81
+ return this._changes[0].allDiagnostics;
82
+ }
83
+ constructor() {
84
+ super({ report: (changes) => this._changes.push(changes) });
85
+ this._changes = [];
86
+ this.nameMappings = new NameMapping_1.NameMapping();
87
+ }
88
+ async resolveItem(item, lookupSchema) {
89
+ const classKey = this.nameMappings.resolveItemKey(item.key);
90
+ return lookupSchema.lookupItem(classKey.name);
91
+ }
92
+ async resolveProperty(propertyA, ecClass) {
93
+ const propertyKey = this.nameMappings.resolvePropertyKey(new NameMapping_1.PropertyKey(propertyA.name, propertyA.class.key));
94
+ return ecClass.getProperty(propertyKey.propertyName);
95
+ }
96
+ areEqualByName(itemKeyA, itemKeyB) {
97
+ if (itemKeyA) {
98
+ if (ecschema_metadata_1.SchemaItem.isSchemaItem(itemKeyA)) {
99
+ itemKeyA = itemKeyA.key;
100
+ }
101
+ itemKeyA = this.nameMappings.resolveItemKey(itemKeyA);
102
+ }
103
+ return super.areEqualByName(itemKeyA, itemKeyB);
104
+ }
105
+ }
60
106
  //# sourceMappingURL=SchemaDifference.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaDifference.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAoZH,oDAyBC;AA1aD,uEAAoE;AAEpE,iEAA8D;AAO9D,2EAAkE;AAsBlE;;;GAGG;AACH,IAAY,gBAUX;AAVD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,uDAAmC,CAAA;IACnC,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,uEAAmD,CAAA;IACnD,qEAAiD,CAAA;IACjD,+EAA2D,CAAA;IAC3D,yDAAqC,CAAA;IACrC,yFAAqE,CAAA;AACvE,CAAC,EAVW,gBAAgB,gCAAhB,gBAAgB,QAU3B;AA6VD;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CAAC,YAAoB,EAAE,YAAoB;IACnF,MAAM,WAAW,GAAoB,EAAE,CAAC;IACxC,MAAM,cAAc,GAAG,IAAI,+BAAc,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC1F,MAAM,cAAc,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAEhE,MAAM,OAAO,GAAG,IAAI,iDAAuB,EAAE,CAAC;IAC9C,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;QACvD,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,WAAW,GAA0B;QACzC,GAAG,OAAO,CAAC,iBAAiB;QAC5B,GAAG,OAAO,CAAC,qBAAqB;QAChC,GAAG,OAAO,CAAC,yBAAyB;QACpC,GAAG,OAAO,CAAC,0BAA0B;KACtC,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,IAAA,+CAAmB,EAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAErF,OAAO;QACL,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;QACnD,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;QACnD,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QACvD,WAAW;KACZ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Differencing\r\n */\r\n\r\nimport { AnySchemaDifferenceConflict } from \"./SchemaConflicts\";\r\nimport { SchemaDiagnosticVisitor } from \"./SchemaDiagnosticVisitor\";\r\nimport { SchemaChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\r\nimport {\r\n AnyEnumerator, AnyPropertyProps, ConstantProps, CustomAttribute,\r\n CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps,\r\n MixinProps, PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, RelationshipConstraintProps,\r\n type Schema, SchemaItemFormatProps, SchemaItemProps, SchemaItemType, SchemaItemUnitProps, SchemaReferenceProps, StructClassProps, UnitSystemProps,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { validateDifferences } from \"./SchemaDifferenceValidator\";\r\n\r\n/** Utility-Type to remove possible readonly flags on the given type. */\r\ntype PartialEditable<T> = {\r\n -readonly [P in keyof T]?: T[P];\r\n};\r\n\r\n/**\r\n * Utility-Type to simplify the expected SchemaItem props by omitting the base properties\r\n * that are not needed for the schema differencing. Also all properties are made mutable\r\n * by removing the readonly flag if present.\r\n */\r\ntype SchemaItemProperties<T extends SchemaItemProps> = {\r\n [P in keyof PartialEditable<Omit<T, keyof Omit<SchemaItemProps, \"label\" | \"description\" | \"customAttributes\">>>]: T[P]\r\n};\r\n\r\n/**\r\n * Defines the type of the difference operation.\r\n * @alpha\r\n */\r\nexport type DifferenceType = \"add\" | \"modify\";\r\n\r\n/**\r\n * Defines the SchemaTypes that are not SchemaItems.\r\n * @alpha\r\n */\r\nexport enum SchemaOtherTypes {\r\n Schema = \"Schema\",\r\n SchemaReference = \"SchemaReference\",\r\n Property = \"Property\",\r\n Enumerator = \"Enumerator\",\r\n CustomAttributeInstance = \"CustomAttributeInstance\",\r\n RelationshipConstraint = \"RelationshipConstraint\",\r\n RelationshipConstraintClass = \"RelationshipConstraintClass\",\r\n EntityClassMixin = \"EntityClassMixin\",\r\n KindOfQuantityPresentationFormat = \"KindOfQuantityPresentationFormat\",\r\n}\r\n\r\n/**\r\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\r\n * @alpha\r\n */\r\nexport type SchemaType = SchemaOtherTypes | SchemaItemType;\r\n\r\n/**\r\n * Definition of the difference result between two Schemas.\r\n * @alpha\r\n */\r\nexport interface SchemaDifferenceResult {\r\n /** Full name of the source schema */\r\n readonly sourceSchemaName: string;\r\n /** Full name of the target schema */\r\n readonly targetSchemaName: string;\r\n\r\n /** List of differences between the compared schemas. */\r\n readonly differences: AnySchemaDifference[];\r\n\r\n /** List of conflicts found while comparing the schemas. */\r\n readonly conflicts?: AnySchemaDifferenceConflict[];\r\n}\r\n\r\n/**\r\n * Union of all supported schema differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaDifference =\r\n SchemaDifference |\r\n SchemaReferenceDifference |\r\n AnySchemaItemDifference |\r\n AnySchemaItemPathDifference |\r\n EntityClassMixinDifference |\r\n CustomAttributeDifference |\r\n KindOfQuantityPresentationFormatDifference;\r\n\r\n/**\r\n * Differencing entry for changes on a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Schema;\r\n readonly difference: {\r\n label?: string;\r\n description?: string;\r\n };\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Schema References of a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaReferenceDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.SchemaReference;\r\n readonly difference: SchemaReferenceProps;\r\n}\r\n\r\n/**\r\n * Union of all supported schema item differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemDifference =\r\n AnyClassItemDifference |\r\n ConstantDifference |\r\n EnumerationDifference |\r\n FormatDifference |\r\n KindOfQuantityDifference |\r\n InvertedUnitDifference |\r\n PhenomenonDifference |\r\n PropertyCategoryDifference |\r\n UnitDifference |\r\n UnitSystemDifference;\r\n\r\n/**\r\n * Union for supported class Schema Items.\r\n * @alpha\r\n */\r\nexport type AnyClassItemDifference =\r\n EntityClassDifference |\r\n MixinClassDifference |\r\n StructClassDifference |\r\n CustomAttributeClassDifference |\r\n RelationshipClassDifference;\r\n\r\n/**\r\n * Union of all differences that have a path pointing inside a schema item.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemPathDifference =\r\n RelationshipConstraintDifference |\r\n RelationshipConstraintClassDifference |\r\n CustomAttributePropertyDifference |\r\n EnumeratorDifference |\r\n ClassPropertyDifference;\r\n\r\n/**\r\n * Internal base class for all Schema Item differencing entries.\r\n * @alpha\r\n */\r\ninterface SchemaItemDifference<T extends SchemaItemProps> {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly itemName: string;\r\n readonly difference: SchemaItemProperties<T>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Constant Schema Items.\r\n * @alpha\r\n */\r\nexport interface ConstantDifference extends SchemaItemDifference<ConstantProps> {\r\n readonly schemaType: SchemaItemType.Constant;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attribute Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeClassDifference extends SchemaItemDifference<CustomAttributeClassProps> {\r\n readonly schemaType: SchemaItemType.CustomAttributeClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Entity Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface EntityClassDifference extends SchemaItemDifference<EntityClassProps> {\r\n readonly schemaType: SchemaItemType.EntityClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Enumerator Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumerationDifference extends SchemaItemDifference<EnumerationProps> {\r\n readonly schemaType: SchemaItemType.Enumeration;\r\n}\r\n\r\n/**\r\n * Differencing entry for Kind-Of-Quantities Schema Items.\r\n * @alpha\r\n */\r\nexport interface KindOfQuantityDifference extends SchemaItemDifference<KindOfQuantityProps> {\r\n readonly schemaType: SchemaItemType.KindOfQuantity;\r\n}\r\n\r\n/**\r\n * Differencing entry for Mixin Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface MixinClassDifference extends SchemaItemDifference<MixinProps> {\r\n readonly schemaType: SchemaItemType.Mixin;\r\n}\r\n\r\n/**\r\n * Differencing entry for Phenomenon Schema Items.\r\n * @alpha\r\n */\r\nexport interface PhenomenonDifference extends SchemaItemDifference<PhenomenonProps> {\r\n readonly schemaType: SchemaItemType.Phenomenon;\r\n}\r\n\r\n/**\r\n * Differencing entry for Property Category Schema Items.\r\n * @alpha\r\n */\r\nexport interface PropertyCategoryDifference extends SchemaItemDifference<PropertyCategoryProps> {\r\n readonly schemaType: SchemaItemType.PropertyCategory;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface RelationshipClassDifference extends SchemaItemDifference<RelationshipClassProps> {\r\n readonly schemaType: SchemaItemType.RelationshipClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Struct Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface StructClassDifference extends SchemaItemDifference<StructClassProps> {\r\n readonly schemaType: SchemaItemType.StructClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit System Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitSystemDifference extends SchemaItemDifference<UnitSystemProps> {\r\n readonly schemaType: SchemaItemType.UnitSystem;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitDifference extends SchemaItemDifference<SchemaItemUnitProps> {\r\n readonly schemaType: SchemaItemType.Unit;\r\n}\r\n\r\n/**\r\n * Differencing entry for Inverted Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface InvertedUnitDifference extends SchemaItemDifference<InvertedUnitProps> {\r\n readonly schemaType: SchemaItemType.InvertedUnit;\r\n}\r\n/**\r\n * Differencing entry for Format Schema Items.\r\n * @alpha\r\n */\r\nexport interface FormatDifference extends SchemaItemDifference<SchemaItemFormatProps> {\r\n readonly schemaType: SchemaItemType.Format;\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Properties.\r\n * @alpha\r\n */\r\nexport interface ClassPropertyDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Property;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyPropertyProps>;\r\n}\r\n\r\n/**\r\n * Union of supported Custom Attribute Differences.\r\n * @alpha\r\n */\r\nexport type CustomAttributeDifference =\r\n CustomAttributeSchemaDifference |\r\n CustomAttributeSchemaItemDifference |\r\n CustomAttributePropertyDifference |\r\n CustomAttributeRelationshipConstraintDifference;\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Schema\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaItemDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"SchemaItem\";\r\n readonly itemName: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Properties.\r\n * @alpha\r\n */\r\nexport interface CustomAttributePropertyDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Property\";\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeRelationshipConstraintDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"RelationshipConstraint\";\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for changed mixins on EntityClasses.\r\n * @alpha\r\n */\r\nexport interface EntityClassMixinDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.EntityClassMixin;\r\n readonly itemName: string;\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Differencing entry for changed Enumerators on Enumerable Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumeratorDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Enumerator;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyEnumerator>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraint;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<Omit<RelationshipConstraintProps, \"constraintClasses\">>;\r\n}\r\n\r\n/**\r\n * Differencing entry for constraint classes added to Relationship Constrains.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintClassDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraintClass;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Differencing entry for presentation formats added to KindOfQuantities.\r\n * @alpha\r\n */\r\nexport interface KindOfQuantityPresentationFormatDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.KindOfQuantityPresentationFormat;\r\n readonly itemName: string;\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Creates a [[SchemaDifferenceResult]] for two given schemas.\r\n * @param targetSchema The schema the differences gets merged into.\r\n * @param sourceSchema The schema to get merged in the target.\r\n * @returns An [[SchemaDifferenceResult]] object.\r\n * @alpha\r\n */\r\nexport async function getSchemaDifferences(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferenceResult> {\r\n const changesList: SchemaChanges[] = [];\r\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\r\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\r\n\r\n const visitor = new SchemaDiagnosticVisitor();\r\n for (const diagnostic of changesList[0].allDiagnostics) {\r\n visitor.visit(diagnostic);\r\n }\r\n\r\n const differences: AnySchemaDifference[] = [\r\n ...visitor.schemaDifferences,\r\n ...visitor.schemaItemDifferences,\r\n ...visitor.schemaItemPathDifferences,\r\n ...visitor.customAttributeDifferences,\r\n ];\r\n\r\n const conflicts = await validateDifferences(differences, targetSchema, sourceSchema);\r\n\r\n return {\r\n sourceSchemaName: sourceSchema.schemaKey.toString(),\r\n targetSchemaName: targetSchema.schemaKey.toString(),\r\n conflicts: conflicts.length > 0 ? conflicts : undefined,\r\n differences,\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"SchemaDifference.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAuZH,oDAmCC;AAvbD,8DAA8E;AAC9E,uEAAoE;AAEpE,iEAA8D;AAC9D,gEAKkC;AAClC,2EAAkE;AAElE,8DAAwE;AAsBxE;;;GAGG;AACH,IAAY,gBAUX;AAVD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,uDAAmC,CAAA;IACnC,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,uEAAmD,CAAA;IACnD,qEAAiD,CAAA;IACjD,+EAA2D,CAAA;IAC3D,yDAAqC,CAAA;IACrC,yFAAqE,CAAA;AACvE,CAAC,EAVW,gBAAgB,gCAAhB,gBAAgB,QAU3B;AA6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C1B,CAAC;YACD,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,KAAK,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Differencing\r\n */\r\n\r\nimport { AnySchemaDifferenceConflict } from \"./SchemaConflicts\";\r\nimport { AnySchemaEdits, SchemaEditType } from \"../Merging/Edits/SchemaEdits\";\r\nimport { SchemaDiagnosticVisitor } from \"./SchemaDiagnosticVisitor\";\r\nimport { SchemaChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\r\nimport {\r\n AnyEnumerator, AnyProperty, AnyPropertyProps, ConstantProps, CustomAttribute,\r\n CustomAttributeClassProps, ECClass, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps,\r\n MixinProps, PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, RelationshipConstraintProps,\r\n type Schema, SchemaItem, SchemaItemFormatProps, SchemaItemKey, SchemaItemProps, SchemaItemType, SchemaItemUnitProps, SchemaReferenceProps, StructClassProps, UnitSystemProps,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { validateDifferences } from \"./SchemaDifferenceValidator\";\r\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\r\nimport { NameMapping, PropertyKey } from \"../Merging/Edits/NameMapping\";\r\n\r\n/** Utility-Type to remove possible readonly flags on the given type. */\r\ntype PartialEditable<T> = {\r\n -readonly [P in keyof T]?: T[P];\r\n};\r\n\r\n/**\r\n * Utility-Type to simplify the expected SchemaItem props by omitting the base properties\r\n * that are not needed for the schema differencing. Also all properties are made mutable\r\n * by removing the readonly flag if present.\r\n */\r\ntype SchemaItemProperties<T extends SchemaItemProps> = {\r\n [P in keyof PartialEditable<Omit<T, keyof Omit<SchemaItemProps, \"label\" | \"description\" | \"customAttributes\">>>]: T[P]\r\n};\r\n\r\n/**\r\n * Defines the type of the difference operation.\r\n * @alpha\r\n */\r\nexport type DifferenceType = \"add\" | \"modify\";\r\n\r\n/**\r\n * Defines the SchemaTypes that are not SchemaItems.\r\n * @alpha\r\n */\r\nexport enum SchemaOtherTypes {\r\n Schema = \"Schema\",\r\n SchemaReference = \"SchemaReference\",\r\n Property = \"Property\",\r\n Enumerator = \"Enumerator\",\r\n CustomAttributeInstance = \"CustomAttributeInstance\",\r\n RelationshipConstraint = \"RelationshipConstraint\",\r\n RelationshipConstraintClass = \"RelationshipConstraintClass\",\r\n EntityClassMixin = \"EntityClassMixin\",\r\n KindOfQuantityPresentationFormat = \"KindOfQuantityPresentationFormat\",\r\n}\r\n\r\n/**\r\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\r\n * @alpha\r\n */\r\nexport type SchemaType = SchemaOtherTypes | SchemaItemType;\r\n\r\n/**\r\n * Definition of the difference result between two Schemas.\r\n * @alpha\r\n */\r\nexport interface SchemaDifferenceResult {\r\n /** Full name of the source schema */\r\n readonly sourceSchemaName: string;\r\n /** Full name of the target schema */\r\n readonly targetSchemaName: string;\r\n\r\n /** List of differences between the compared schemas. */\r\n readonly differences: AnySchemaDifference[];\r\n\r\n /** List of conflicts found while comparing the schemas. */\r\n readonly conflicts?: AnySchemaDifferenceConflict[];\r\n}\r\n\r\n/**\r\n * Union of all supported schema differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaDifference =\r\n SchemaDifference |\r\n SchemaReferenceDifference |\r\n AnySchemaItemDifference |\r\n AnySchemaItemPathDifference |\r\n EntityClassMixinDifference |\r\n CustomAttributeDifference |\r\n KindOfQuantityPresentationFormatDifference;\r\n\r\n/**\r\n * Differencing entry for changes on a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Schema;\r\n readonly difference: {\r\n label?: string;\r\n description?: string;\r\n };\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Schema References of a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaReferenceDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.SchemaReference;\r\n readonly difference: SchemaReferenceProps;\r\n}\r\n\r\n/**\r\n * Union of all supported schema item differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemDifference =\r\n AnyClassItemDifference |\r\n ConstantDifference |\r\n EnumerationDifference |\r\n FormatDifference |\r\n KindOfQuantityDifference |\r\n InvertedUnitDifference |\r\n PhenomenonDifference |\r\n PropertyCategoryDifference |\r\n UnitDifference |\r\n UnitSystemDifference;\r\n\r\n/**\r\n * Union for supported class Schema Items.\r\n * @alpha\r\n */\r\nexport type AnyClassItemDifference =\r\n EntityClassDifference |\r\n MixinClassDifference |\r\n StructClassDifference |\r\n CustomAttributeClassDifference |\r\n RelationshipClassDifference;\r\n\r\n/**\r\n * Union of all differences that have a path pointing inside a schema item.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemPathDifference =\r\n RelationshipConstraintDifference |\r\n RelationshipConstraintClassDifference |\r\n CustomAttributePropertyDifference |\r\n EnumeratorDifference |\r\n ClassPropertyDifference;\r\n\r\n/**\r\n * Internal base class for all Schema Item differencing entries.\r\n * @alpha\r\n */\r\ninterface SchemaItemDifference<T extends SchemaItemProps> {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly itemName: string;\r\n readonly difference: SchemaItemProperties<T>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Constant Schema Items.\r\n * @alpha\r\n */\r\nexport interface ConstantDifference extends SchemaItemDifference<ConstantProps> {\r\n readonly schemaType: SchemaItemType.Constant;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attribute Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeClassDifference extends SchemaItemDifference<CustomAttributeClassProps> {\r\n readonly schemaType: SchemaItemType.CustomAttributeClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Entity Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface EntityClassDifference extends SchemaItemDifference<EntityClassProps> {\r\n readonly schemaType: SchemaItemType.EntityClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Enumerator Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumerationDifference extends SchemaItemDifference<EnumerationProps> {\r\n readonly schemaType: SchemaItemType.Enumeration;\r\n}\r\n\r\n/**\r\n * Differencing entry for Kind-Of-Quantities Schema Items.\r\n * @alpha\r\n */\r\nexport interface KindOfQuantityDifference extends SchemaItemDifference<KindOfQuantityProps> {\r\n readonly schemaType: SchemaItemType.KindOfQuantity;\r\n}\r\n\r\n/**\r\n * Differencing entry for Mixin Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface MixinClassDifference extends SchemaItemDifference<MixinProps> {\r\n readonly schemaType: SchemaItemType.Mixin;\r\n}\r\n\r\n/**\r\n * Differencing entry for Phenomenon Schema Items.\r\n * @alpha\r\n */\r\nexport interface PhenomenonDifference extends SchemaItemDifference<PhenomenonProps> {\r\n readonly schemaType: SchemaItemType.Phenomenon;\r\n}\r\n\r\n/**\r\n * Differencing entry for Property Category Schema Items.\r\n * @alpha\r\n */\r\nexport interface PropertyCategoryDifference extends SchemaItemDifference<PropertyCategoryProps> {\r\n readonly schemaType: SchemaItemType.PropertyCategory;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface RelationshipClassDifference extends SchemaItemDifference<RelationshipClassProps> {\r\n readonly schemaType: SchemaItemType.RelationshipClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Struct Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface StructClassDifference extends SchemaItemDifference<StructClassProps> {\r\n readonly schemaType: SchemaItemType.StructClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit System Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitSystemDifference extends SchemaItemDifference<UnitSystemProps> {\r\n readonly schemaType: SchemaItemType.UnitSystem;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitDifference extends SchemaItemDifference<SchemaItemUnitProps> {\r\n readonly schemaType: SchemaItemType.Unit;\r\n}\r\n\r\n/**\r\n * Differencing entry for Inverted Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface InvertedUnitDifference extends SchemaItemDifference<InvertedUnitProps> {\r\n readonly schemaType: SchemaItemType.InvertedUnit;\r\n}\r\n/**\r\n * Differencing entry for Format Schema Items.\r\n * @alpha\r\n */\r\nexport interface FormatDifference extends SchemaItemDifference<SchemaItemFormatProps> {\r\n readonly schemaType: SchemaItemType.Format;\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Properties.\r\n * @alpha\r\n */\r\nexport interface ClassPropertyDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Property;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyPropertyProps>;\r\n}\r\n\r\n/**\r\n * Union of supported Custom Attribute Differences.\r\n * @alpha\r\n */\r\nexport type CustomAttributeDifference =\r\n CustomAttributeSchemaDifference |\r\n CustomAttributeSchemaItemDifference |\r\n CustomAttributePropertyDifference |\r\n CustomAttributeRelationshipConstraintDifference;\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Schema\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaItemDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"SchemaItem\";\r\n readonly itemName: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Properties.\r\n * @alpha\r\n */\r\nexport interface CustomAttributePropertyDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Property\";\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeRelationshipConstraintDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"RelationshipConstraint\";\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for changed mixins on EntityClasses.\r\n * @alpha\r\n */\r\nexport interface EntityClassMixinDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.EntityClassMixin;\r\n readonly itemName: string;\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Differencing entry for changed Enumerators on Enumerable Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumeratorDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Enumerator;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyEnumerator>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraint;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<Omit<RelationshipConstraintProps, \"constraintClasses\">>;\r\n}\r\n\r\n/**\r\n * Differencing entry for constraint classes added to Relationship Constrains.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintClassDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraintClass;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Differencing entry for presentation formats added to KindOfQuantities.\r\n * @alpha\r\n */\r\nexport interface KindOfQuantityPresentationFormatDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.KindOfQuantityPresentationFormat;\r\n readonly itemName: string;\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Creates a [[SchemaDifferenceResult]] for two given schemas.\r\n * @param targetSchema The schema the differences gets merged into.\r\n * @param sourceSchema The schema to get merged in the target.\r\n * @returns An [[SchemaDifferenceResult]] object.\r\n * @alpha\r\n */\r\nexport async function getSchemaDifferences(targetSchema: Schema, sourceSchema: Schema, schemaEdits?: Iterable<AnySchemaEdits>): Promise<SchemaDifferenceResult> {\r\n const schemaComparer = new DifferenceSchemaComparer();\r\n if(schemaEdits) {\r\n for(const edit of schemaEdits) {\r\n if(edit.type === SchemaEditType.RenameSchemaItem) {\r\n schemaComparer.nameMappings.addItemMapping(edit.key, edit.value);\r\n }\r\n if(edit.type === SchemaEditType.RenameProperty) {\r\n schemaComparer.nameMappings.addPropertyMapping(edit.key, edit.value);\r\n }\r\n }\r\n }\r\n\r\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\r\n\r\n const visitor = new SchemaDiagnosticVisitor();\r\n for (const diagnostic of schemaComparer.diagnostics) {\r\n visitor.visit(diagnostic);\r\n }\r\n\r\n const differences: AnySchemaDifference[] = [\r\n ...visitor.schemaDifferences,\r\n ...visitor.schemaItemDifferences,\r\n ...visitor.schemaItemPathDifferences,\r\n ...visitor.customAttributeDifferences,\r\n ];\r\n\r\n const conflicts = await validateDifferences(differences, targetSchema, sourceSchema, schemaComparer.nameMappings);\r\n\r\n return {\r\n sourceSchemaName: sourceSchema.schemaKey.toString(),\r\n targetSchemaName: targetSchema.schemaKey.toString(),\r\n conflicts: conflicts.length > 0 ? conflicts : undefined,\r\n differences,\r\n };\r\n}\r\n\r\n/**\r\n * Implementation of a SchemaComparer that is used in the schema differencing process.\r\n * It extends the SchemaComparer base class with additional functionality to store the\r\n * name mappings of renamed schema items and properties.\r\n *\r\n * @internal\r\n */\r\nclass DifferenceSchemaComparer extends SchemaComparer {\r\n public readonly nameMappings: NameMapping;\r\n private readonly _changes: Array<SchemaChanges>;\r\n\r\n public get diagnostics(): Iterable<AnyDiagnostic> {\r\n return this._changes[0].allDiagnostics;\r\n }\r\n\r\n constructor() {\r\n super({ report: (changes) => this._changes.push(changes as SchemaChanges) });\r\n\r\n this._changes = [];\r\n this.nameMappings = new NameMapping();\r\n }\r\n\r\n public override async resolveItem<TItem extends SchemaItem>(item: SchemaItem, lookupSchema: Schema): Promise<TItem | undefined> {\r\n const classKey = this.nameMappings.resolveItemKey(item.key);\r\n return lookupSchema.lookupItem<TItem>(classKey.name);\r\n }\r\n\r\n public override async resolveProperty(propertyA: AnyProperty, ecClass: ECClass): Promise<AnyProperty | undefined> {\r\n const propertyKey = this.nameMappings.resolvePropertyKey(new PropertyKey(propertyA.name, propertyA.class.key));\r\n return ecClass.getProperty(propertyKey.propertyName) as Promise<AnyProperty | undefined>;\r\n }\r\n\r\n public override areEqualByName(itemKeyA?: Readonly<SchemaItemKey> | SchemaItem, itemKeyB?: Readonly<SchemaItemKey> | SchemaItem): boolean {\r\n if (itemKeyA) {\r\n if (SchemaItem.isSchemaItem(itemKeyA)) {\r\n itemKeyA = itemKeyA.key;\r\n }\r\n itemKeyA = this.nameMappings.resolveItemKey(itemKeyA);\r\n }\r\n return super.areEqualByName(itemKeyA, itemKeyB);\r\n }\r\n}\r\n"]}
@@ -4,6 +4,7 @@
4
4
  import { Schema } from "@itwin/ecschema-metadata";
5
5
  import { AnySchemaDifference } from "./SchemaDifference";
6
6
  import { AnySchemaDifferenceConflict } from "./SchemaConflicts";
7
+ import { NameMapping } from "../Merging/Edits/NameMapping";
7
8
  /**
8
9
  * Validates the given array of schema differences and returns a list of conflicts if the
9
10
  * validation finds violation against rules.
@@ -13,5 +14,5 @@ import { AnySchemaDifferenceConflict } from "./SchemaConflicts";
13
14
  * @returns An array of conflicts found when validating the difference.
14
15
  * @internal
15
16
  */
16
- export declare function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema): Promise<AnySchemaDifferenceConflict[]>;
17
+ export declare function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping): Promise<AnySchemaDifferenceConflict[]>;
17
18
  //# sourceMappingURL=SchemaDifferenceValidator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaDifferenceValidator.d.ts","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAqM,MAAM,EAA8C,MAAM,0BAA0B,CAAC;AACjS,OAAO,EAA0B,mBAAmB,EAA2mB,MAAM,oBAAoB,CAAC;AAC1rB,OAAO,EAAE,2BAA2B,EAAgB,MAAM,mBAAmB,CAAC;AAG9E;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,0CAOvH"}
1
+ {"version":3,"file":"SchemaDifferenceValidator.d.ts","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAqM,MAAM,EAA8C,MAAM,0BAA0B,CAAC;AACjS,OAAO,EAA0B,mBAAmB,EAA2mB,MAAM,oBAAoB,CAAC;AAC1rB,OAAO,EAAE,2BAA2B,EAAgB,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,WAAW,EAAe,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,0CAOlJ"}
@@ -11,6 +11,7 @@ exports.validateDifferences = validateDifferences;
11
11
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
12
  const SchemaConflicts_1 = require("./SchemaConflicts");
13
13
  const SchemaDifferenceVisitor_1 = require("./SchemaDifferenceVisitor");
14
+ const NameMapping_1 = require("../Merging/Edits/NameMapping");
14
15
  /**
15
16
  * Validates the given array of schema differences and returns a list of conflicts if the
16
17
  * validation finds violation against rules.
@@ -20,8 +21,8 @@ const SchemaDifferenceVisitor_1 = require("./SchemaDifferenceVisitor");
20
21
  * @returns An array of conflicts found when validating the difference.
21
22
  * @internal
22
23
  */
23
- async function validateDifferences(differences, targetSchema, sourceSchema) {
24
- const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema);
24
+ async function validateDifferences(differences, targetSchema, sourceSchema, nameMappings) {
25
+ const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema, nameMappings);
25
26
  const walker = new SchemaDifferenceVisitor_1.SchemaDifferenceWalker(visitor);
26
27
  await walker.traverse(differences);
27
28
  return visitor.conflicts;
@@ -32,14 +33,25 @@ async function validateDifferences(differences, targetSchema, sourceSchema) {
32
33
  */
33
34
  class SchemaDifferenceValidationVisitor {
34
35
  /** Initializes a new instance of SchemaDifferenceValidationVisitor class. */
35
- constructor(targetSchema, sourceSchema) {
36
+ constructor(targetSchema, sourceSchema, nameMappings) {
36
37
  this.conflicts = [];
37
38
  this._targetSchema = targetSchema;
38
39
  this._sourceSchema = sourceSchema;
40
+ this._nameMappings = nameMappings;
39
41
  }
40
42
  addConflict(conflict) {
41
43
  this.conflicts.push(conflict);
42
44
  }
45
+ async getTargetSchemaItem(name) {
46
+ const itemKey = new ecschema_metadata_1.SchemaItemKey(name, this._sourceSchema.schemaKey);
47
+ const mappedKey = this._nameMappings.resolveItemKey(itemKey);
48
+ return this._targetSchema.getItem(mappedKey.name);
49
+ }
50
+ getTargetProperty(itemName, propertyName) {
51
+ const classKey = new ecschema_metadata_1.SchemaItemKey(itemName, this._sourceSchema.schemaKey);
52
+ const propertyKey = new NameMapping_1.PropertyKey(propertyName, classKey);
53
+ return this._nameMappings.resolvePropertyKey(propertyKey);
54
+ }
43
55
  /**
44
56
  * Visitor implementation for handling SchemaDifference.
45
57
  * @internal
@@ -133,7 +145,7 @@ class SchemaDifferenceValidationVisitor {
133
145
  * Shared validation for all types of ClassItemDifference union.
134
146
  */
135
147
  async visitClassDifference(entry) {
136
- const targetClassItem = await this._targetSchema.getItem(entry.itemName);
148
+ const targetClassItem = await this.getTargetSchemaItem(entry.itemName);
137
149
  if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {
138
150
  return;
139
151
  }
@@ -164,7 +176,7 @@ class SchemaDifferenceValidationVisitor {
164
176
  * @internal
165
177
  */
166
178
  async visitConstantDifference(entry) {
167
- await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
179
+ await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));
168
180
  }
169
181
  /**
170
182
  * Visitor implementation for handling CustomAttributeClassDifference.
@@ -213,7 +225,7 @@ class SchemaDifferenceValidationVisitor {
213
225
  * @internal
214
226
  */
215
227
  async visitEnumerationDifference(entry) {
216
- const enumeration = await this._targetSchema.getItem(entry.itemName);
228
+ const enumeration = await this.getTargetSchemaItem(entry.itemName);
217
229
  if (!await this.visitSchemaItemDifference(entry, enumeration)) {
218
230
  return;
219
231
  }
@@ -237,7 +249,7 @@ class SchemaDifferenceValidationVisitor {
237
249
  if (entry.changeType !== "modify") {
238
250
  return;
239
251
  }
240
- const enumeration = await this._targetSchema.getItem(entry.itemName);
252
+ const enumeration = await this.getTargetSchemaItem(entry.itemName);
241
253
  const enumerator = enumeration.getEnumeratorByName(entry.path);
242
254
  if (!enumerator) {
243
255
  return;
@@ -257,21 +269,21 @@ class SchemaDifferenceValidationVisitor {
257
269
  * @internal
258
270
  */
259
271
  async visitFormatDifference(entry) {
260
- await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
272
+ await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));
261
273
  }
262
274
  /**
263
275
  * Visitor implementation for handling InvertedUnitDifference.
264
276
  * @internal
265
277
  */
266
278
  async visitInvertedUnitDifference(entry) {
267
- await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
279
+ await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));
268
280
  }
269
281
  /**
270
282
  * Visitor implementation for handling KindOfQuantityDifference.
271
283
  * @internal
272
284
  */
273
285
  async visitKindOfQuantityDifference(entry) {
274
- const kindOfQuantity = await this._targetSchema.getItem(entry.itemName);
286
+ const kindOfQuantity = await this.getTargetSchemaItem(entry.itemName);
275
287
  if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {
276
288
  return;
277
289
  }
@@ -299,15 +311,16 @@ class SchemaDifferenceValidationVisitor {
299
311
  * @internal
300
312
  */
301
313
  async visitPhenomenonDifference(entry) {
302
- await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
314
+ await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));
303
315
  }
304
316
  /**
305
317
  * Visitor implementation for handling ClassPropertyDifference.
306
318
  * @internal
307
319
  */
308
320
  async visitPropertyDifference(entry) {
309
- const targetClass = await this._targetSchema.getItem(entry.itemName);
310
- const targetProperty = await targetClass.getProperty(entry.path);
321
+ const targetClass = await this.getTargetSchemaItem(entry.itemName);
322
+ const propertyKey = this.getTargetProperty(entry.itemName, entry.path);
323
+ const targetProperty = await targetClass.getProperty(propertyKey.propertyName);
311
324
  const sourceClass = await this._sourceSchema.getItem(entry.itemName);
312
325
  const sourceProperty = await sourceClass.getProperty(entry.path);
313
326
  // If property shall be added but there is already a property with this name
@@ -360,7 +373,7 @@ class SchemaDifferenceValidationVisitor {
360
373
  * @internal
361
374
  */
362
375
  async visitPropertyCategoryDifference(entry) {
363
- await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
376
+ await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));
364
377
  }
365
378
  /**
366
379
  * Visitor implementation for handling RelationshipClassDifference.
@@ -393,14 +406,14 @@ class SchemaDifferenceValidationVisitor {
393
406
  * @internal
394
407
  */
395
408
  async visitUnitDifference(entry) {
396
- await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
409
+ await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));
397
410
  }
398
411
  /**
399
412
  * Visitor implementation for handling UnitSystemDifference.
400
413
  * @internal
401
414
  */
402
415
  async visitUnitSystemDifference(entry) {
403
- await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
416
+ await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));
404
417
  }
405
418
  /**
406
419
  * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.