@itwin/ecschema-editing 5.3.3 → 5.3.4

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 (183) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/cjs/Differencing/Errors.js.map +1 -1
  3. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  4. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  5. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  6. package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
  7. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
  8. package/lib/cjs/Differencing/Utils.js.map +1 -1
  9. package/lib/cjs/Editing/Constants.js.map +1 -1
  10. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  11. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  12. package/lib/cjs/Editing/Editor.js.map +1 -1
  13. package/lib/cjs/Editing/Entities.js.map +1 -1
  14. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  15. package/lib/cjs/Editing/Exception.js.map +1 -1
  16. package/lib/cjs/Editing/Formats.js.map +1 -1
  17. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  18. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  19. package/lib/cjs/Editing/Mixins.js.map +1 -1
  20. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  21. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  22. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  23. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  24. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  25. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  26. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  27. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  28. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  29. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  30. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  31. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  32. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  33. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  34. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  35. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  36. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  37. package/lib/cjs/Editing/Mutable/MutableSchemaItem.js.map +1 -1
  38. package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -1
  39. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  40. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  41. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  42. package/lib/cjs/Editing/Properties.js.map +1 -1
  43. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  44. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  45. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  46. package/lib/cjs/Editing/Structs.js.map +1 -1
  47. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  48. package/lib/cjs/Editing/Units.js.map +1 -1
  49. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  50. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  51. package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -1
  52. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  53. package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -1
  54. package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
  55. package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
  56. package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -1
  57. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  58. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  59. package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
  60. package/lib/cjs/Merging/FormatMerger.js.map +1 -1
  61. package/lib/cjs/Merging/InvertedUnitMerger.js.map +1 -1
  62. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  63. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  64. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  65. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
  66. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  67. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  68. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  69. package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
  70. package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
  71. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  72. package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
  73. package/lib/cjs/Merging/UnitMerger.js.map +1 -1
  74. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
  75. package/lib/cjs/Merging/Utils.js.map +1 -1
  76. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  77. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  78. package/lib/cjs/Validation/ECRules.js.map +1 -1
  79. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  80. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  81. package/lib/cjs/Validation/Rules.js.map +1 -1
  82. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  83. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  84. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  85. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  86. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  87. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  88. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  89. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  90. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  91. package/lib/cjs/ecschema-editing.js.map +1 -1
  92. package/lib/esm/Differencing/Errors.js.map +1 -1
  93. package/lib/esm/Differencing/SchemaConflicts.js.map +1 -1
  94. package/lib/esm/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  95. package/lib/esm/Differencing/SchemaDifference.js.map +1 -1
  96. package/lib/esm/Differencing/SchemaDifferenceValidator.js.map +1 -1
  97. package/lib/esm/Differencing/SchemaDifferenceVisitor.js.map +1 -1
  98. package/lib/esm/Differencing/Utils.js.map +1 -1
  99. package/lib/esm/Editing/Constants.js.map +1 -1
  100. package/lib/esm/Editing/CustomAttributes.js.map +1 -1
  101. package/lib/esm/Editing/ECClasses.js.map +1 -1
  102. package/lib/esm/Editing/Editor.js.map +1 -1
  103. package/lib/esm/Editing/Entities.js.map +1 -1
  104. package/lib/esm/Editing/Enumerations.js.map +1 -1
  105. package/lib/esm/Editing/Exception.js.map +1 -1
  106. package/lib/esm/Editing/Formats.js.map +1 -1
  107. package/lib/esm/Editing/InvertedUnits.js.map +1 -1
  108. package/lib/esm/Editing/KindOfQuantities.js.map +1 -1
  109. package/lib/esm/Editing/Mixins.js.map +1 -1
  110. package/lib/esm/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  111. package/lib/esm/Editing/Mutable/MutableCAClass.js.map +1 -1
  112. package/lib/esm/Editing/Mutable/MutableClass.js.map +1 -1
  113. package/lib/esm/Editing/Mutable/MutableConstant.js.map +1 -1
  114. package/lib/esm/Editing/Mutable/MutableEntityClass.js.map +1 -1
  115. package/lib/esm/Editing/Mutable/MutableEnumeration.js.map +1 -1
  116. package/lib/esm/Editing/Mutable/MutableFormat.js.map +1 -1
  117. package/lib/esm/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  118. package/lib/esm/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  119. package/lib/esm/Editing/Mutable/MutableMixin.js.map +1 -1
  120. package/lib/esm/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  121. package/lib/esm/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  122. package/lib/esm/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  123. package/lib/esm/Editing/Mutable/MutableProperty.js.map +1 -1
  124. package/lib/esm/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  125. package/lib/esm/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  126. package/lib/esm/Editing/Mutable/MutableSchema.js.map +1 -1
  127. package/lib/esm/Editing/Mutable/MutableSchemaItem.js.map +1 -1
  128. package/lib/esm/Editing/Mutable/MutableStructProperty.js.map +1 -1
  129. package/lib/esm/Editing/Mutable/MutableUnit.js.map +1 -1
  130. package/lib/esm/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  131. package/lib/esm/Editing/Phenomena.js.map +1 -1
  132. package/lib/esm/Editing/Properties.js.map +1 -1
  133. package/lib/esm/Editing/PropertyCategories.js.map +1 -1
  134. package/lib/esm/Editing/RelationshipClasses.js.map +1 -1
  135. package/lib/esm/Editing/SchemaItems.js.map +1 -1
  136. package/lib/esm/Editing/Structs.js.map +1 -1
  137. package/lib/esm/Editing/UnitSystems.js.map +1 -1
  138. package/lib/esm/Editing/Units.js.map +1 -1
  139. package/lib/esm/Merging/ClassMerger.js.map +1 -1
  140. package/lib/esm/Merging/ConstantMerger.js.map +1 -1
  141. package/lib/esm/Merging/CustomAttributeClassMerger.js.map +1 -1
  142. package/lib/esm/Merging/CustomAttributeMerger.js.map +1 -1
  143. package/lib/esm/Merging/Edits/NameMapping.js.map +1 -1
  144. package/lib/esm/Merging/Edits/RenameEditHandler.js.map +1 -1
  145. package/lib/esm/Merging/Edits/SchemaEdits.js.map +1 -1
  146. package/lib/esm/Merging/Edits/SkipEditHandler.js.map +1 -1
  147. package/lib/esm/Merging/EntityClassMerger.js.map +1 -1
  148. package/lib/esm/Merging/EnumerationMerger.js.map +1 -1
  149. package/lib/esm/Merging/EnumeratorMerger.js.map +1 -1
  150. package/lib/esm/Merging/FormatMerger.js.map +1 -1
  151. package/lib/esm/Merging/InvertedUnitMerger.js.map +1 -1
  152. package/lib/esm/Merging/KindOfQuantityMerger.js.map +1 -1
  153. package/lib/esm/Merging/MixinMerger.js.map +1 -1
  154. package/lib/esm/Merging/PhenomenonMerger.js.map +1 -1
  155. package/lib/esm/Merging/PropertyCategoryMerger.js.map +1 -1
  156. package/lib/esm/Merging/PropertyMerger.js.map +1 -1
  157. package/lib/esm/Merging/RelationshipClassMerger.js.map +1 -1
  158. package/lib/esm/Merging/SchemaMerger.js.map +1 -1
  159. package/lib/esm/Merging/SchemaMergingVisitor.js.map +1 -1
  160. package/lib/esm/Merging/SchemaMergingWalker.js.map +1 -1
  161. package/lib/esm/Merging/SchemaReferenceMerger.js.map +1 -1
  162. package/lib/esm/Merging/StructClassMerger.js.map +1 -1
  163. package/lib/esm/Merging/UnitMerger.js.map +1 -1
  164. package/lib/esm/Merging/UnitSystemMerger.js.map +1 -1
  165. package/lib/esm/Merging/Utils.js.map +1 -1
  166. package/lib/esm/Validation/Diagnostic.js.map +1 -1
  167. package/lib/esm/Validation/DiagnosticReporter.js.map +1 -1
  168. package/lib/esm/Validation/ECRules.js.map +1 -1
  169. package/lib/esm/Validation/LoggingDiagnosticReporter.js.map +1 -1
  170. package/lib/esm/Validation/RuleSuppressionSet.js.map +1 -1
  171. package/lib/esm/Validation/Rules.js.map +1 -1
  172. package/lib/esm/Validation/SchemaChanges.js.map +1 -1
  173. package/lib/esm/Validation/SchemaCompareDiagnostics.js.map +1 -1
  174. package/lib/esm/Validation/SchemaCompareReporter.js.map +1 -1
  175. package/lib/esm/Validation/SchemaCompareResultDelegate.js.map +1 -1
  176. package/lib/esm/Validation/SchemaCompareVisitor.js.map +1 -1
  177. package/lib/esm/Validation/SchemaComparer.js.map +1 -1
  178. package/lib/esm/Validation/SchemaValidater.js.map +1 -1
  179. package/lib/esm/Validation/SchemaValidationVisitor.js.map +1 -1
  180. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  181. package/lib/esm/ecschema-editing.js.map +1 -1
  182. package/package.json +9 -9
  183. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":"AAMA,OAAO,EAA+E,WAAW,EAAqD,kBAAkB,EAA0B,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAuB,MAAM,0BAA0B,CAAC;AACvT,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAElH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAYhE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAA2B,EAAE,MAA+B;IACxG,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7E,OAAO,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;QACnD,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,IAAI;KACE,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,MAA8B,EAAE,OAAsB;IAC5H,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QAC1D,MAAM,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE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K,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,+BAA+B,SAAS,CAAC,IAAI,yBAAyB,CAAC,CAAC;QAC1F,CAAC;QAED,QAAQ,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;QAExC,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3D,OAAO,aAAa,CAAC,EAAE,CAAC,QAAQ,CAAC;YAC/B,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC;YAC9F,CAAC,CAAC,WAAW,CAAC,6BAA6B,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC9F,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK;QAC7C,IAAI,aAAa,IAAI,KAAK,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9D,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,CAAC,QAAQ,iCAAiC,CAAC,CAAC;QAChG,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { AnyClassItemDifference, ClassPropertyDifference, DifferenceType } from \"../Differencing/SchemaDifference\";\nimport { AnyProperty, AnyPropertyProps, ArrayPropertyProps, CustomAttribute, ECClass, Enumeration, EnumerationPropertyProps, NavigationPropertyProps, parsePrimitiveType, PrimitivePropertyProps, RelationshipClass, SchemaItemKey, SchemaItemType, StructClass, StructPropertyProps } from \"@itwin/ecschema-metadata\";\nimport { getClassEditor, toItemKey, toPropertyKey, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\nimport { MutableProperty } from \"../Editing/Mutable/MutableProperty\";\nimport { applyCustomAttributes } from \"./CustomAttributeMerger\";\n\ntype PartialEditable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\ninterface PropertyMerger<T extends AnyPropertyProps> {\n is(property: AnyPropertyProps): property is T;\n add(context: SchemaMergeContext, itemKey: SchemaItemKey, props: PartialEditable<T>): Promise<void>;\n merge(context: SchemaMergeContext, itemKey: SchemaItemKey, property: AnyProperty, props: T): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport async function mergePropertyDifference(context: SchemaMergeContext, change: ClassPropertyDifference): Promise<void> {\n const classKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\n return mergeClassProperty(context, change, classKey, {\n ...change.difference,\n name: change.path,\n } as AnyPropertyProps);\n}\n\n/**\n * @internal\n */\nexport async function mergeClassProperties(context: SchemaMergeContext, change: AnyClassItemDifference, itemKey: SchemaItemKey): Promise<void> {\n for (const property of change.difference.properties || []) {\n await mergeClassProperty(context, change, itemKey, property);\n }\n}\n\nasync function mergeClassProperty(context: SchemaMergeContext, change: { changeType: DifferenceType }, itemKey: SchemaItemKey, property: AnyPropertyProps) {\n return change.changeType === \"add\"\n ? addClassProperty(context, itemKey, property)\n : modifyClassProperty(context, itemKey, property);\n}\n\nasync function addClassProperty(context: SchemaMergeContext, itemKey: SchemaItemKey, property: PartialEditable<AnyPropertyProps>): Promise<void> {\n const ecClass = await context.targetSchema.lookupItem(toItemKey(context, itemKey.name)) as ECClass;\n\n if (property.category !== undefined) {\n property.category = await updateSchemaItemFullName(context, property.category);\n }\n\n if (property.kindOfQuantity !== undefined) {\n property.kindOfQuantity = await updateSchemaItemFullName(context, property.kindOfQuantity);\n }\n\n await createProperty(context, ecClass.key, property);\n\n if (property.customAttributes !== undefined) {\n await applyCustomAttributes(context, property.customAttributes as CustomAttribute[], async (ca) => {\n const classEditor = await getClassEditor(context, ecClass.key);\n await classEditor.properties.addCustomAttribute(ecClass.key, property.name, ca);\n });\n }\n}\n\nasync function createProperty(context: SchemaMergeContext, itemKey: SchemaItemKey, property: PartialEditable<AnyPropertyProps>) {\n if (enumerationProperty.is(property)) {\n return enumerationProperty.add(context, itemKey, property);\n }\n if (navigationProperty.is(property)) {\n return navigationProperty.add(context, itemKey, property);\n }\n if (primitiveProperty.is(property)) {\n return primitiveProperty.add(context, itemKey, property);\n }\n if (structProperty.is(property)) {\n return structProperty.add(context, itemKey, property);\n }\n return {};\n}\n\nasync function modifyClassProperty(context: SchemaMergeContext, itemKey: SchemaItemKey, propertyProps: AnyPropertyProps): Promise<void> {\n const ecClass = await context.targetSchema.lookupItem(toItemKey(context, itemKey.name)) as ECClass;\n const propertyKey = toPropertyKey(context, itemKey.name, propertyProps.name);\n const property = await ecClass.getProperty(propertyKey.propertyName) as MutableProperty;\n\n if (property === undefined) {\n throw new Error(`Couldn't find property ${propertyKey.propertyName} on class ${ecClass.key.name}`);\n }\n\n if (propertyProps.type !== undefined) {\n throw new Error(`Changing the property '${property.fullName}' type is not supported.`);\n }\n\n const classEditor = await getClassEditor(context, ecClass);\n\n if (propertyProps.description !== undefined) {\n await classEditor.properties.setDescription(ecClass.key, property.name, propertyProps.description);\n }\n if (propertyProps.label !== undefined) {\n await classEditor.properties.setLabel(ecClass.key, property.name, propertyProps.label);\n }\n if (propertyProps.isReadOnly !== undefined) {\n await classEditor.properties.setIsReadOnly(ecClass.key, property.name, propertyProps.isReadOnly);\n }\n if (propertyProps.priority !== undefined) {\n await classEditor.properties.setPriority(ecClass.key, property.name, propertyProps.priority);\n }\n if (propertyProps.kindOfQuantity !== undefined) {\n await classEditor.properties.setKindOfQuantity(ecClass.key, property.name, await updateSchemaItemKey(context, propertyProps.kindOfQuantity));\n }\n\n if (property.isArray()) {\n await arrayProperty.merge(context, ecClass.key, property.name, propertyProps);\n }\n\n if (propertyProps.category !== undefined) {\n const categoryKey = await updateSchemaItemKey(context, propertyProps.category);\n await classEditor.properties.setCategory(ecClass.key, property.name, categoryKey);\n }\n\n if (property.isEnumeration()) {\n return enumerationProperty.merge(context, ecClass.key, property, propertyProps as any);\n }\n if (property.isNavigation()) {\n return navigationProperty.merge(context, ecClass.key, property, propertyProps as any);\n }\n if (property.isPrimitive()) {\n return primitiveProperty.merge(context, ecClass.key, property, propertyProps as any);\n }\n if (property.isStruct()) {\n return structProperty.merge(context, ecClass.key, property, propertyProps as any);\n }\n}\n\nconst arrayProperty = {\n is(property: AnyPropertyProps): boolean {\n return \"minOccurs\" in property && \"maxOccurs\" in property;\n },\n async merge(context: SchemaMergeContext, itemKey: SchemaItemKey, propertyName: string, props: ArrayPropertyProps) {\n const classEditor = await getClassEditor(context, itemKey);\n if (props.minOccurs !== undefined) {\n await classEditor.arrayProperties.setMinOccurs(itemKey, propertyName, props.minOccurs);\n }\n if (props.maxOccurs !== undefined) {\n await classEditor.arrayProperties.setMaxOccurs(itemKey, propertyName, props.maxOccurs);\n }\n },\n};\n\nconst enumerationProperty: PropertyMerger<EnumerationPropertyProps> = {\n is(property): property is EnumerationPropertyProps {\n return primitiveProperty.is(property) && property.typeName.includes(\".\");\n },\n async add(context, itemKey, property): Promise<void> {\n const enumerationKey = await updateSchemaItemKey(context, property.typeName);\n const enumerationType = await context.editor.schemaContext.getSchemaItem(enumerationKey, Enumeration);\n if (enumerationType === undefined) {\n throw new Error(`Unable to locate the enumeration class ${enumerationKey.name} in the context schema.`);\n }\n\n property.typeName = enumerationType.fullName;\n\n const classEditor = await getClassEditor(context, itemKey);\n\n arrayProperty.is(property)\n ? await classEditor.createEnumerationArrayPropertyFromProps(itemKey, property.name, enumerationType, property)\n : await classEditor.createEnumerationPropertyFromProps(itemKey, property.name, enumerationType, property);\n },\n async merge(context, itemKey, property, props) {\n if (\"enumeration\" in props && props.enumeration !== undefined) {\n throw new Error(`Changing the property '${property.fullName}' enumeration is not supported.`);\n }\n return primitiveProperty.merge(context, itemKey, property, props);\n },\n};\n\nconst navigationProperty: PropertyMerger<NavigationPropertyProps> = {\n is(property): property is NavigationPropertyProps {\n return property.type === \"NavigationProperty\";\n },\n async add(context, itemKey, property): Promise<void> {\n const relationshipKey = await updateSchemaItemKey(context, property.relationshipName);\n const relationshipType = await context.editor.schemaContext.getSchemaItem(relationshipKey, RelationshipClass);\n if (relationshipType === undefined) {\n throw new Error(`Unable to locate the relationship class ${relationshipKey.name} in the context schema.`);\n }\n\n property.relationshipName = relationshipType.fullName;\n\n const ecClass = await context.editor.schemaContext.getSchemaItem(itemKey) as ECClass;\n if (ecClass.schemaItemType === SchemaItemType.EntityClass)\n return context.editor.entities.createNavigationPropertyFromProps(ecClass.key, property);\n if (ecClass.schemaItemType === SchemaItemType.Mixin)\n return context.editor.mixins.createNavigationPropertyFromProps(ecClass.key, property);\n if (ecClass.schemaItemType === SchemaItemType.RelationshipClass)\n return context.editor.relationships.createNavigationPropertyFromProps(ecClass.key, property);\n throw new Error(`Navigation property can't be added to ${ecClass.schemaItemType}.`);\n },\n async merge(_context, _itemKey, property, props) {\n if (props.direction !== undefined) {\n throw new Error(`Changing the property '${property.fullName}' direction is not supported.`);\n }\n if (\"relationshipClass\" in props && props.relationshipClass !== undefined) {\n throw new Error(`Changing the property '${property.fullName}' relationship class is not supported.`);\n }\n },\n};\n\nconst primitiveProperty: PropertyMerger<PrimitivePropertyProps> = {\n is(property): property is PrimitivePropertyProps {\n return property.type === \"PrimitiveProperty\" || property.type === \"PrimitiveArrayProperty\";\n },\n async add(context, itemKey, property): Promise<void> {\n const propertyType = parsePrimitiveType(property.typeName);\n if (propertyType === undefined) {\n throw new Error(`Invalid property type ${property.typeName} on property ${property.name}`);\n }\n\n const classEditor = await getClassEditor(context, itemKey);\n return arrayProperty.is(property)\n ? classEditor.createPrimitiveArrayPropertyFromProps(itemKey, property.name, propertyType, property)\n : classEditor.createPrimitivePropertyFromProps(itemKey, property.name, propertyType, property);\n },\n async merge(context, itemKey, property, props) {\n if (props.typeName) {\n throw new Error(`Changing the property '${property.fullName}' primitiveType is not supported.`);\n }\n\n const classEditor = await getClassEditor(context, itemKey);\n if (props.extendedTypeName !== undefined) {\n await classEditor.primitiveProperties.setExtendedTypeName(itemKey, property.name, props.extendedTypeName);\n }\n if (props.minLength !== undefined) {\n await classEditor.primitiveProperties.setMinLength(itemKey, property.name, props.minLength);\n }\n if (props.maxLength !== undefined) {\n await classEditor.primitiveProperties.setMaxLength(itemKey, property.name, props.maxLength);\n }\n if (props.minValue !== undefined) {\n await classEditor.primitiveProperties.setMinValue(itemKey, property.name, props.minValue);\n }\n if (props.maxValue !== undefined) {\n await classEditor.primitiveProperties.setMaxValue(itemKey, property.name, props.maxValue);\n }\n },\n};\n\nconst structProperty: PropertyMerger<StructPropertyProps> = {\n is(property): property is StructPropertyProps {\n return property.type === \"StructProperty\" || property.type === \"StructArrayProperty\";\n },\n async add(context, itemKey, property): Promise<void> {\n const structKey = await updateSchemaItemKey(context, property.typeName);\n const structType = await context.editor.schemaContext.getSchemaItem(structKey, StructClass);\n if (structType === undefined) {\n throw new Error(`Unable to locate the struct ${structKey.name} in the context schema.`);\n }\n\n property.typeName = structType.fullName;\n\n const classEditor = await getClassEditor(context, itemKey);\n return arrayProperty.is(property)\n ? classEditor.createStructArrayPropertyFromProps(itemKey, property.name, structType, property)\n : classEditor.createStructPropertyFromProps(itemKey, property.name, structType, property);\n },\n async merge(_context, _itemKey, property, props) {\n if (\"structClass\" in props && props.structClass !== undefined) {\n throw new Error(`Changing the property '${property.fullName}' structClass is not supported.`);\n }\n },\n};\n"]}
1
+ {"version":3,"file":"PropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":"AAMA,OAAO,EAA+E,WAAW,EAAqD,kBAAkB,EAA0B,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAuB,MAAM,0BAA0B,CAAC;AACvT,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,wBAAwB,EAAE,mBAAmB,EAAE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AQ,EAAE,KAAK;QAC7C,IAAI,aAAa,IAAI,KAAK,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9D,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,CAAC,QAAQ,iCAAiC,CAAC,CAAC;QAChG,CAAC;IACH,CAAC;CACF,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\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { AnyClassItemDifference, ClassPropertyDifference, DifferenceType } from \"../Differencing/SchemaDifference\";\r\nimport { AnyProperty, AnyPropertyProps, ArrayPropertyProps, CustomAttribute, ECClass, Enumeration, EnumerationPropertyProps, NavigationPropertyProps, parsePrimitiveType, PrimitivePropertyProps, RelationshipClass, SchemaItemKey, SchemaItemType, StructClass, StructPropertyProps } from \"@itwin/ecschema-metadata\";\r\nimport { getClassEditor, toItemKey, toPropertyKey, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\nimport { MutableProperty } from \"../Editing/Mutable/MutableProperty\";\r\nimport { applyCustomAttributes } from \"./CustomAttributeMerger\";\r\n\r\ntype PartialEditable<T> = {\r\n -readonly [P in keyof T]: T[P];\r\n};\r\n\r\ninterface PropertyMerger<T extends AnyPropertyProps> {\r\n is(property: AnyPropertyProps): property is T;\r\n add(context: SchemaMergeContext, itemKey: SchemaItemKey, props: PartialEditable<T>): Promise<void>;\r\n merge(context: SchemaMergeContext, itemKey: SchemaItemKey, property: AnyProperty, props: T): Promise<void>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function mergePropertyDifference(context: SchemaMergeContext, change: ClassPropertyDifference): Promise<void> {\r\n const classKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n return mergeClassProperty(context, change, classKey, {\r\n ...change.difference,\r\n name: change.path,\r\n } as AnyPropertyProps);\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function mergeClassProperties(context: SchemaMergeContext, change: AnyClassItemDifference, itemKey: SchemaItemKey): Promise<void> {\r\n for (const property of change.difference.properties || []) {\r\n await mergeClassProperty(context, change, itemKey, property);\r\n }\r\n}\r\n\r\nasync function mergeClassProperty(context: SchemaMergeContext, change: { changeType: DifferenceType }, itemKey: SchemaItemKey, property: AnyPropertyProps) {\r\n return change.changeType === \"add\"\r\n ? addClassProperty(context, itemKey, property)\r\n : modifyClassProperty(context, itemKey, property);\r\n}\r\n\r\nasync function addClassProperty(context: SchemaMergeContext, itemKey: SchemaItemKey, property: PartialEditable<AnyPropertyProps>): Promise<void> {\r\n const ecClass = await context.targetSchema.lookupItem(toItemKey(context, itemKey.name)) as ECClass;\r\n\r\n if (property.category !== undefined) {\r\n property.category = await updateSchemaItemFullName(context, property.category);\r\n }\r\n\r\n if (property.kindOfQuantity !== undefined) {\r\n property.kindOfQuantity = await updateSchemaItemFullName(context, property.kindOfQuantity);\r\n }\r\n\r\n await createProperty(context, ecClass.key, property);\r\n\r\n if (property.customAttributes !== undefined) {\r\n await applyCustomAttributes(context, property.customAttributes as CustomAttribute[], async (ca) => {\r\n const classEditor = await getClassEditor(context, ecClass.key);\r\n await classEditor.properties.addCustomAttribute(ecClass.key, property.name, ca);\r\n });\r\n }\r\n}\r\n\r\nasync function createProperty(context: SchemaMergeContext, itemKey: SchemaItemKey, property: PartialEditable<AnyPropertyProps>) {\r\n if (enumerationProperty.is(property)) {\r\n return enumerationProperty.add(context, itemKey, property);\r\n }\r\n if (navigationProperty.is(property)) {\r\n return navigationProperty.add(context, itemKey, property);\r\n }\r\n if (primitiveProperty.is(property)) {\r\n return primitiveProperty.add(context, itemKey, property);\r\n }\r\n if (structProperty.is(property)) {\r\n return structProperty.add(context, itemKey, property);\r\n }\r\n return {};\r\n}\r\n\r\nasync function modifyClassProperty(context: SchemaMergeContext, itemKey: SchemaItemKey, propertyProps: AnyPropertyProps): Promise<void> {\r\n const ecClass = await context.targetSchema.lookupItem(toItemKey(context, itemKey.name)) as ECClass;\r\n const propertyKey = toPropertyKey(context, itemKey.name, propertyProps.name);\r\n const property = await ecClass.getProperty(propertyKey.propertyName) as MutableProperty;\r\n\r\n if (property === undefined) {\r\n throw new Error(`Couldn't find property ${propertyKey.propertyName} on class ${ecClass.key.name}`);\r\n }\r\n\r\n if (propertyProps.type !== undefined) {\r\n throw new Error(`Changing the property '${property.fullName}' type is not supported.`);\r\n }\r\n\r\n const classEditor = await getClassEditor(context, ecClass);\r\n\r\n if (propertyProps.description !== undefined) {\r\n await classEditor.properties.setDescription(ecClass.key, property.name, propertyProps.description);\r\n }\r\n if (propertyProps.label !== undefined) {\r\n await classEditor.properties.setLabel(ecClass.key, property.name, propertyProps.label);\r\n }\r\n if (propertyProps.isReadOnly !== undefined) {\r\n await classEditor.properties.setIsReadOnly(ecClass.key, property.name, propertyProps.isReadOnly);\r\n }\r\n if (propertyProps.priority !== undefined) {\r\n await classEditor.properties.setPriority(ecClass.key, property.name, propertyProps.priority);\r\n }\r\n if (propertyProps.kindOfQuantity !== undefined) {\r\n await classEditor.properties.setKindOfQuantity(ecClass.key, property.name, await updateSchemaItemKey(context, propertyProps.kindOfQuantity));\r\n }\r\n\r\n if (property.isArray()) {\r\n await arrayProperty.merge(context, ecClass.key, property.name, propertyProps);\r\n }\r\n\r\n if (propertyProps.category !== undefined) {\r\n const categoryKey = await updateSchemaItemKey(context, propertyProps.category);\r\n await classEditor.properties.setCategory(ecClass.key, property.name, categoryKey);\r\n }\r\n\r\n if (property.isEnumeration()) {\r\n return enumerationProperty.merge(context, ecClass.key, property, propertyProps as any);\r\n }\r\n if (property.isNavigation()) {\r\n return navigationProperty.merge(context, ecClass.key, property, propertyProps as any);\r\n }\r\n if (property.isPrimitive()) {\r\n return primitiveProperty.merge(context, ecClass.key, property, propertyProps as any);\r\n }\r\n if (property.isStruct()) {\r\n return structProperty.merge(context, ecClass.key, property, propertyProps as any);\r\n }\r\n}\r\n\r\nconst arrayProperty = {\r\n is(property: AnyPropertyProps): boolean {\r\n return \"minOccurs\" in property && \"maxOccurs\" in property;\r\n },\r\n async merge(context: SchemaMergeContext, itemKey: SchemaItemKey, propertyName: string, props: ArrayPropertyProps) {\r\n const classEditor = await getClassEditor(context, itemKey);\r\n if (props.minOccurs !== undefined) {\r\n await classEditor.arrayProperties.setMinOccurs(itemKey, propertyName, props.minOccurs);\r\n }\r\n if (props.maxOccurs !== undefined) {\r\n await classEditor.arrayProperties.setMaxOccurs(itemKey, propertyName, props.maxOccurs);\r\n }\r\n },\r\n};\r\n\r\nconst enumerationProperty: PropertyMerger<EnumerationPropertyProps> = {\r\n is(property): property is EnumerationPropertyProps {\r\n return primitiveProperty.is(property) && property.typeName.includes(\".\");\r\n },\r\n async add(context, itemKey, property): Promise<void> {\r\n const enumerationKey = await updateSchemaItemKey(context, property.typeName);\r\n const enumerationType = await context.editor.schemaContext.getSchemaItem(enumerationKey, Enumeration);\r\n if (enumerationType === undefined) {\r\n throw new Error(`Unable to locate the enumeration class ${enumerationKey.name} in the context schema.`);\r\n }\r\n\r\n property.typeName = enumerationType.fullName;\r\n\r\n const classEditor = await getClassEditor(context, itemKey);\r\n\r\n arrayProperty.is(property)\r\n ? await classEditor.createEnumerationArrayPropertyFromProps(itemKey, property.name, enumerationType, property)\r\n : await classEditor.createEnumerationPropertyFromProps(itemKey, property.name, enumerationType, property);\r\n },\r\n async merge(context, itemKey, property, props) {\r\n if (\"enumeration\" in props && props.enumeration !== undefined) {\r\n throw new Error(`Changing the property '${property.fullName}' enumeration is not supported.`);\r\n }\r\n return primitiveProperty.merge(context, itemKey, property, props);\r\n },\r\n};\r\n\r\nconst navigationProperty: PropertyMerger<NavigationPropertyProps> = {\r\n is(property): property is NavigationPropertyProps {\r\n return property.type === \"NavigationProperty\";\r\n },\r\n async add(context, itemKey, property): Promise<void> {\r\n const relationshipKey = await updateSchemaItemKey(context, property.relationshipName);\r\n const relationshipType = await context.editor.schemaContext.getSchemaItem(relationshipKey, RelationshipClass);\r\n if (relationshipType === undefined) {\r\n throw new Error(`Unable to locate the relationship class ${relationshipKey.name} in the context schema.`);\r\n }\r\n\r\n property.relationshipName = relationshipType.fullName;\r\n\r\n const ecClass = await context.editor.schemaContext.getSchemaItem(itemKey) as ECClass;\r\n if (ecClass.schemaItemType === SchemaItemType.EntityClass)\r\n return context.editor.entities.createNavigationPropertyFromProps(ecClass.key, property);\r\n if (ecClass.schemaItemType === SchemaItemType.Mixin)\r\n return context.editor.mixins.createNavigationPropertyFromProps(ecClass.key, property);\r\n if (ecClass.schemaItemType === SchemaItemType.RelationshipClass)\r\n return context.editor.relationships.createNavigationPropertyFromProps(ecClass.key, property);\r\n throw new Error(`Navigation property can't be added to ${ecClass.schemaItemType}.`);\r\n },\r\n async merge(_context, _itemKey, property, props) {\r\n if (props.direction !== undefined) {\r\n throw new Error(`Changing the property '${property.fullName}' direction is not supported.`);\r\n }\r\n if (\"relationshipClass\" in props && props.relationshipClass !== undefined) {\r\n throw new Error(`Changing the property '${property.fullName}' relationship class is not supported.`);\r\n }\r\n },\r\n};\r\n\r\nconst primitiveProperty: PropertyMerger<PrimitivePropertyProps> = {\r\n is(property): property is PrimitivePropertyProps {\r\n return property.type === \"PrimitiveProperty\" || property.type === \"PrimitiveArrayProperty\";\r\n },\r\n async add(context, itemKey, property): Promise<void> {\r\n const propertyType = parsePrimitiveType(property.typeName);\r\n if (propertyType === undefined) {\r\n throw new Error(`Invalid property type ${property.typeName} on property ${property.name}`);\r\n }\r\n\r\n const classEditor = await getClassEditor(context, itemKey);\r\n return arrayProperty.is(property)\r\n ? classEditor.createPrimitiveArrayPropertyFromProps(itemKey, property.name, propertyType, property)\r\n : classEditor.createPrimitivePropertyFromProps(itemKey, property.name, propertyType, property);\r\n },\r\n async merge(context, itemKey, property, props) {\r\n if (props.typeName) {\r\n throw new Error(`Changing the property '${property.fullName}' primitiveType is not supported.`);\r\n }\r\n\r\n const classEditor = await getClassEditor(context, itemKey);\r\n if (props.extendedTypeName !== undefined) {\r\n await classEditor.primitiveProperties.setExtendedTypeName(itemKey, property.name, props.extendedTypeName);\r\n }\r\n if (props.minLength !== undefined) {\r\n await classEditor.primitiveProperties.setMinLength(itemKey, property.name, props.minLength);\r\n }\r\n if (props.maxLength !== undefined) {\r\n await classEditor.primitiveProperties.setMaxLength(itemKey, property.name, props.maxLength);\r\n }\r\n if (props.minValue !== undefined) {\r\n await classEditor.primitiveProperties.setMinValue(itemKey, property.name, props.minValue);\r\n }\r\n if (props.maxValue !== undefined) {\r\n await classEditor.primitiveProperties.setMaxValue(itemKey, property.name, props.maxValue);\r\n }\r\n },\r\n};\r\n\r\nconst structProperty: PropertyMerger<StructPropertyProps> = {\r\n is(property): property is StructPropertyProps {\r\n return property.type === \"StructProperty\" || property.type === \"StructArrayProperty\";\r\n },\r\n async add(context, itemKey, property): Promise<void> {\r\n const structKey = await updateSchemaItemKey(context, property.typeName);\r\n const structType = await context.editor.schemaContext.getSchemaItem(structKey, StructClass);\r\n if (structType === undefined) {\r\n throw new Error(`Unable to locate the struct ${structKey.name} in the context schema.`);\r\n }\r\n\r\n property.typeName = structType.fullName;\r\n\r\n const classEditor = await getClassEditor(context, itemKey);\r\n return arrayProperty.is(property)\r\n ? classEditor.createStructArrayPropertyFromProps(itemKey, property.name, structType, property)\r\n : classEditor.createStructPropertyFromProps(itemKey, property.name, structType, property);\r\n },\r\n async merge(_context, _itemKey, property, props) {\r\n if (\"structClass\" in props && props.structClass !== undefined) {\r\n throw new Error(`Changing the property '${property.fullName}' structClass is not supported.`);\r\n }\r\n },\r\n};\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,WAAW,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AAa,EAAE,CAAC;IACvC,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC9C,iBAAiB,CAAC,IAAI,CAAC,MAAM,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO;QACL,GAAG,KAAK;QACR,kBAAkB;QAClB,iBAAiB;KAClB,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableRelationshipClass } from \"../Editing/Mutable/MutableRelationshipClass\";\nimport { locateSchemaItem, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\nimport { modifyClass } from \"./ClassMerger\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECClass, EntityClass, Mixin, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipConstraintProps, RelationshipMultiplicity, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new RelationshipClass into the target schema.\n * @internal\n */\nexport async function addRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference) {\n if (change.difference.strength === undefined) {\n throw new Error(\"RelationshipClass must define strength\");\n }\n if (change.difference.strengthDirection === undefined) {\n throw new Error(\"RelationshipClass must define strengthDirection\");\n }\n if (change.difference.source === undefined) {\n throw new Error(\"RelationshipClass must define a source constraint\");\n }\n if (change.difference.target === undefined) {\n throw new Error(\"RelationshipClass must define a target constraint\");\n }\n\n await context.editor.relationships.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n strength: change.difference.strength,\n strengthDirection: change.difference.strengthDirection,\n source: await updateRelationshipConstraintKey(context, change.difference.source),\n target: await updateRelationshipConstraintKey(context, change.difference.target),\n });\n}\n\n/**\n * Merges differences to an existing RelationshipClass in the target schema.\n * @internal\n */\nexport async function modifyRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableRelationshipClass;\n if(change.changeType === \"modify\") {\n if(change.difference.strength !== undefined) {\n if (item.strength === undefined) {\n const strength = parseStrength(change.difference.strength);\n if (strength === undefined) {\n throw new Error(`An invalid relationship class strength value '${change.difference.strength}' has been provided.`);\n }\n item.setStrength(strength);\n }\n throw new Error(`Changing the relationship '${itemKey.name}' strength is not supported.`);\n }\n if(change.difference.strengthDirection !== undefined) {\n if (item.strengthDirection === undefined) {\n const strengthDirection = parseStrengthDirection(change.difference.strengthDirection);\n if (strengthDirection === undefined) {\n throw new Error(`An invalid relationship class strengthDirection value '${change.difference.strengthDirection}' has been provided.`);\n }\n item.setStrengthDirection(strengthDirection);\n }\n throw new Error(`Changing the relationship '${itemKey.name}' strengthDirection is not supported.`);\n }\n }\n await modifyClass(context, change, itemKey, item);\n}\n\n/**\n * Merges differences of a Relationship constraint.\n * This only supports modify as the RelationshipConstraints are always set on the Relationship classes.\n * @internal\n */\nexport async function mergeRelationshipConstraint(context: SchemaMergeContext, change: RelationshipConstraintDifference) {\n if(change.changeType !== \"modify\") {\n throw new Error(\"RelationshipConstraints can only be modified.\");\n }\n\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\n const constraint = item[parseConstraint(change.path)];\n if(change.difference.roleLabel !== undefined) {\n constraint.setRoleLabel(change.difference.roleLabel);\n }\n if(change.difference.polymorphic !== undefined) {\n await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);\n }\n if(change.difference.multiplicity !== undefined) {\n if (constraint.multiplicity === undefined) {\n const multiplicity = RelationshipMultiplicity.fromString(change.difference.multiplicity);\n if (multiplicity === undefined) {\n throw new Error(`An invalid relationship constraint multiplicity value '${change.difference.multiplicity}' has been provided.`);\n }\n await context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\n }\n throw new Error(`Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.`);\n }\n if(change.difference.abstractConstraint !== undefined) {\n const itemKey = await updateSchemaItemKey(context, change.difference.abstractConstraint);\n const abstractConstraint = await context.editor.schemaContext.getSchemaItem(itemKey, ECClass);\n if (abstractConstraint === undefined || (!EntityClass.isEntityClass(abstractConstraint) && !Mixin.isMixin(abstractConstraint) && !RelationshipClass.isRelationshipClass(abstractConstraint))) {\n throw new Error(`Unable to locate the abstract constraint class ${change.difference.abstractConstraint} in the context schema.`);\n }\n return context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\n }\n return { itemKey: constraint.relationshipClass.key };\n}\n\n/**\n * Merges differences of a Relationship constraint classes.\n * @internal\n */\nexport async function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<void> {\n if(change.changeType !== \"add\") {\n throw new Error(`Change type ${change.changeType} is not supported for Relationship constraint classes.`);\n }\n\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\n const constraint = item[parseConstraint(change.path)];\n for(const constraintName of change.difference) {\n const constraintClassKey = await updateSchemaItemKey(context, constraintName);\n const constraintClass = await context.editor.schemaContext.getSchemaItem(constraintClassKey, ECClass);\n if(constraintClass === undefined || (!EntityClass.isEntityClass(constraintClass) && !Mixin.isMixin(constraintClass) && !RelationshipClass.isRelationshipClass(constraintClass))) {\n throw new Error(`Could not locate relationship constraint class ${constraintClassKey.name}`);\n }\n\n await context.editor.relationships.addConstraintClass(constraint, constraintClass);\n }\n}\n\nfunction parseConstraint(path: string): \"source\" | \"target\" {\n return path.startsWith(\"$source\")\n ? \"source\"\n : \"target\";\n}\n\nasync function updateRelationshipConstraintKey(context: SchemaMergeContext, props: RelationshipConstraintProps): Promise<RelationshipConstraintProps> {\n let abstractConstraint = props.abstractConstraint;\n if (abstractConstraint !== undefined)\n abstractConstraint = await updateSchemaItemFullName(context, abstractConstraint);\n\n const constraintClasses: string[] = [];\n for (const ecClass of props.constraintClasses) {\n constraintClasses.push(await updateSchemaItemFullName(context, ecClass));\n }\n\n return {\n ...props,\n abstractConstraint,\n constraintClasses,\n };\n}\n"]}
1
+ {"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,iBAAiB,EAA+B,wBAAwB,EAAiB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEvN;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,MAAmC;IACzG,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,OAAO,CA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CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAC/B,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,QAAQ,CAAC;AACf,CAAC;AAED,KAAK,UAAU,+BAA+B,CAAC,OAA2B,EAAE,KAAkC;IAC5G,IAAI,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC;IAClD,IAAI,kBAAkB,KAAK,SAAS;QAClC,kBAAkB,GAAG,MAAM,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IAEnF,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC9C,iBAAiB,CAAC,IAAI,CAAC,MAAM,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO;QACL,GAAG,KAAK;QACR,kBAAkB;QAClB,iBAAiB;KAClB,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\nimport type { RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableRelationshipClass } from \"../Editing/Mutable/MutableRelationshipClass\";\r\nimport { locateSchemaItem, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { ECClass, EntityClass, Mixin, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipConstraintProps, RelationshipMultiplicity, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new RelationshipClass into the target schema.\r\n * @internal\r\n */\r\nexport async function addRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference) {\r\n if (change.difference.strength === undefined) {\r\n throw new Error(\"RelationshipClass must define strength\");\r\n }\r\n if (change.difference.strengthDirection === undefined) {\r\n throw new Error(\"RelationshipClass must define strengthDirection\");\r\n }\r\n if (change.difference.source === undefined) {\r\n throw new Error(\"RelationshipClass must define a source constraint\");\r\n }\r\n if (change.difference.target === undefined) {\r\n throw new Error(\"RelationshipClass must define a target constraint\");\r\n }\r\n\r\n await context.editor.relationships.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n strength: change.difference.strength,\r\n strengthDirection: change.difference.strengthDirection,\r\n source: await updateRelationshipConstraintKey(context, change.difference.source),\r\n target: await updateRelationshipConstraintKey(context, change.difference.target),\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing RelationshipClass in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference, itemKey: SchemaItemKey) {\r\n const item = await context.targetSchema.lookupItem(itemKey) as MutableRelationshipClass;\r\n if(change.changeType === \"modify\") {\r\n if(change.difference.strength !== undefined) {\r\n if (item.strength === undefined) {\r\n const strength = parseStrength(change.difference.strength);\r\n if (strength === undefined) {\r\n throw new Error(`An invalid relationship class strength value '${change.difference.strength}' has been provided.`);\r\n }\r\n item.setStrength(strength);\r\n }\r\n throw new Error(`Changing the relationship '${itemKey.name}' strength is not supported.`);\r\n }\r\n if(change.difference.strengthDirection !== undefined) {\r\n if (item.strengthDirection === undefined) {\r\n const strengthDirection = parseStrengthDirection(change.difference.strengthDirection);\r\n if (strengthDirection === undefined) {\r\n throw new Error(`An invalid relationship class strengthDirection value '${change.difference.strengthDirection}' has been provided.`);\r\n }\r\n item.setStrengthDirection(strengthDirection);\r\n }\r\n throw new Error(`Changing the relationship '${itemKey.name}' strengthDirection is not supported.`);\r\n }\r\n }\r\n await modifyClass(context, change, itemKey, item);\r\n}\r\n\r\n/**\r\n * Merges differences of a Relationship constraint.\r\n * This only supports modify as the RelationshipConstraints are always set on the Relationship classes.\r\n * @internal\r\n */\r\nexport async function mergeRelationshipConstraint(context: SchemaMergeContext, change: RelationshipConstraintDifference) {\r\n if(change.changeType !== \"modify\") {\r\n throw new Error(\"RelationshipConstraints can only be modified.\");\r\n }\r\n\r\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\r\n const constraint = item[parseConstraint(change.path)];\r\n if(change.difference.roleLabel !== undefined) {\r\n constraint.setRoleLabel(change.difference.roleLabel);\r\n }\r\n if(change.difference.polymorphic !== undefined) {\r\n await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);\r\n }\r\n if(change.difference.multiplicity !== undefined) {\r\n if (constraint.multiplicity === undefined) {\r\n const multiplicity = RelationshipMultiplicity.fromString(change.difference.multiplicity);\r\n if (multiplicity === undefined) {\r\n throw new Error(`An invalid relationship constraint multiplicity value '${change.difference.multiplicity}' has been provided.`);\r\n }\r\n await context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\r\n }\r\n throw new Error(`Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.`);\r\n }\r\n if(change.difference.abstractConstraint !== undefined) {\r\n const itemKey = await updateSchemaItemKey(context, change.difference.abstractConstraint);\r\n const abstractConstraint = await context.editor.schemaContext.getSchemaItem(itemKey, ECClass);\r\n if (abstractConstraint === undefined || (!EntityClass.isEntityClass(abstractConstraint) && !Mixin.isMixin(abstractConstraint) && !RelationshipClass.isRelationshipClass(abstractConstraint))) {\r\n throw new Error(`Unable to locate the abstract constraint class ${change.difference.abstractConstraint} in the context schema.`);\r\n }\r\n return context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\r\n }\r\n return { itemKey: constraint.relationshipClass.key };\r\n}\r\n\r\n/**\r\n * Merges differences of a Relationship constraint classes.\r\n * @internal\r\n */\r\nexport async function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<void> {\r\n if(change.changeType !== \"add\") {\r\n throw new Error(`Change type ${change.changeType} is not supported for Relationship constraint classes.`);\r\n }\r\n\r\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\r\n const constraint = item[parseConstraint(change.path)];\r\n for(const constraintName of change.difference) {\r\n const constraintClassKey = await updateSchemaItemKey(context, constraintName);\r\n const constraintClass = await context.editor.schemaContext.getSchemaItem(constraintClassKey, ECClass);\r\n if(constraintClass === undefined || (!EntityClass.isEntityClass(constraintClass) && !Mixin.isMixin(constraintClass) && !RelationshipClass.isRelationshipClass(constraintClass))) {\r\n throw new Error(`Could not locate relationship constraint class ${constraintClassKey.name}`);\r\n }\r\n\r\n await context.editor.relationships.addConstraintClass(constraint, constraintClass);\r\n }\r\n}\r\n\r\nfunction parseConstraint(path: string): \"source\" | \"target\" {\r\n return path.startsWith(\"$source\")\r\n ? \"source\"\r\n : \"target\";\r\n}\r\n\r\nasync function updateRelationshipConstraintKey(context: SchemaMergeContext, props: RelationshipConstraintProps): Promise<RelationshipConstraintProps> {\r\n let abstractConstraint = props.abstractConstraint;\r\n if (abstractConstraint !== undefined)\r\n abstractConstraint = await updateSchemaItemFullName(context, abstractConstraint);\r\n\r\n const constraintClasses: string[] = [];\r\n for (const ecClass of props.constraintClasses) {\r\n constraintClasses.push(await updateSchemaItemFullName(context, ecClass));\r\n }\r\n\r\n return {\r\n ...props,\r\n abstractConstraint,\r\n constraintClasses,\r\n };\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAU,aAAa,EAAc,aAAa,EAAE,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OA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E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC;IACnC,CAAC;IAEe,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA2B;QACrF,OAAO,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACrE,CAAC;IAEe,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA2B;QAC/E,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAEe,KAAK,CAAC,aAAa,CAA8B,eAAuC,EAAE,cAA2B,EAAE,eAAmB;QACxJ,IAAI,aAA4B,CAAC;QACjC,IAAI,OAAO,eAAe,KAAK,QAAQ;YACrC,aAAa,GAAG,IAAI,aAAa,CAAC,cAAwB,EAAE,IAAI,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;;YAE5F,aAAa,GAAG,eAAe,CAAC;QAElC,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QACnE,IAAG,SAAS,KAAK,SAAS,EAAE,CAAC;YAC3B,aAAa,GAAG,SAA0B,CAAC;QAC7C,CAAC;QAED,IAAG,eAAe,KAAK,SAAS;YAC9B,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC7E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport { Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"../Editing/Editor\";\nimport { SchemaConflictsError } from \"../Differencing/Errors\";\nimport { getSchemaDifferences, type SchemaDifferenceResult } from \"../Differencing/SchemaDifference\";\nimport { SchemaMergingVisitor } from \"./SchemaMergingVisitor\";\nimport { SchemaMergingWalker } from \"./SchemaMergingWalker\";\nimport { SchemaEdits } from \"./Edits/SchemaEdits\";\nimport { ECEditingStatus, SchemaEditingError } from \"../Editing/Exception\";\nimport { NameMapping } from \"./Edits/NameMapping\";\n\n/**\n * Defines the context of a Schema merging run.\n * @internal\n */\nexport interface SchemaMergeContext {\n readonly targetSchema: Schema;\n readonly targetSchemaKey: SchemaKey;\n readonly sourceSchemaKey: SchemaKey;\n readonly editor: SchemaContextEditor;\n readonly nameMapping: NameMapping;\n}\n\n/**\n * Class to merge two schemas together.\n * @see [[merge]] or [[mergeSchemas]] to merge two schemas together.\n * @beta\n */\nexport class SchemaMerger {\n\n private readonly _editingContext: SchemaContext;\n\n /**\n * Constructs a new instance of the SchemaMerger object.\n * @param editingContext The schema contexts that holds the schema to be edited.\n */\n constructor(editingContext: SchemaContext) {\n this._editingContext = editingContext;\n }\n\n /**\n * Copy the SchemaItems of the source schemas to the target schema.\n * @param targetSchema The schema the SchemaItems gets merged to.\n * @param sourceSchema The schema the SchemaItems gets copied from.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @returns The merged target schema.\n * @alpha\n */\n public async mergeSchemas(targetSchema: Schema, sourceSchema: Schema, edits?: SchemaEdits): Promise<Schema> {\n return this.merge(await getSchemaDifferences(targetSchema, sourceSchema, edits), edits);\n }\n\n /**\n * Merges the schema differences into the target schema context.\n * @param differenceResult The differences that shall be applied to the target schema.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @alpha\n */\n public async merge(differenceResult: SchemaDifferenceResult, edits?: SchemaEdits): Promise<Schema> {\n const targetSchemaKey = SchemaKey.parseString(differenceResult.targetSchemaName);\n const sourceSchemaKey = SchemaKey.parseString(differenceResult.sourceSchemaName);\n\n const nameMapping = new NameMapping();\n const editor = new SchemaContextEditor(new MergingSchemaContext(this._editingContext, nameMapping));\n\n // If schema changes were provided, they'll get applied and a new SchemaDifferenceResult is returned\n // to prevent altering the differenceResult the caller passed in.\n if (edits) {\n await edits.applyTo(differenceResult = { ...differenceResult }, nameMapping);\n }\n\n if (differenceResult.conflicts && differenceResult.conflicts.length > 0) {\n throw new SchemaConflictsError(\n \"Schema's can't be merged if there are unresolved conflicts.\",\n differenceResult.conflicts,\n sourceSchemaKey,\n targetSchemaKey,\n );\n }\n\n const schema = await editor.getSchema(targetSchemaKey).catch((error: Error) => {\n if (error instanceof SchemaEditingError && error.errorNumber === ECEditingStatus.SchemaNotFound) {\n throw new Error(`The target schema '${targetSchemaKey.name}' could not be found in the editing context.`);\n }\n throw error;\n });\n\n if (!schema.isDynamic) {\n throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);\n }\n\n const visitor = new SchemaMergingVisitor({\n editor,\n targetSchema: schema,\n targetSchemaKey,\n sourceSchemaKey,\n nameMapping,\n });\n\n const walker = new SchemaMergingWalker(visitor);\n await walker.traverse(differenceResult.differences, \"add\");\n await walker.traverse(differenceResult.differences, \"modify\");\n\n return schema;\n }\n}\n\n/**\n * SchemaContext implementation that overrides certain methods to allow to apply name mappings\n * for certain schema elements during the schema merging process.\n *\n * @internal\n */\nclass MergingSchemaContext extends SchemaContext {\n private _internalContext: SchemaContext;\n private _nameMappings: NameMapping;\n\n public constructor(internalContext: SchemaContext, nameMapping: NameMapping) {\n super();\n this._internalContext = internalContext;\n this._nameMappings = nameMapping;\n }\n\n public override async getCachedSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getCachedSchema(schemaKey, matchType);\n }\n\n public override async getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getSchema(schemaKey, matchType);\n }\n\n public override async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string | SchemaItemKey, itemNameOrCtor?: string | T, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\n let schemaItemKey: SchemaItemKey;\n if (typeof schemaNameOrKey === \"string\")\n schemaItemKey = new SchemaItemKey(itemNameOrCtor as string, new SchemaKey(schemaNameOrKey));\n else\n schemaItemKey = schemaNameOrKey;\n\n const mappedKey = this._nameMappings.resolveItemKey(schemaItemKey);\n if(mappedKey !== undefined) {\n schemaItemKey = mappedKey as SchemaItemKey;\n }\n\n if(itemConstructor === undefined)\n return this._internalContext.getSchemaItem(schemaItemKey);\n\n return this._internalContext.getSchemaItem(schemaItemKey, itemConstructor);\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAU,aAAa,EAAc,aAAa,EAAE,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAA+B,MAAM,kCAAkC,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAclD;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAEN,eAAe,CAAgB;IAEhD;;;OAGG;IACH,YAAY,cAA6B;QACvC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,C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jC,IAAI,OAAO,eAAe,KAAK,QAAQ;YACrC,aAAa,GAAG,IAAI,aAAa,CAAC,cAAwB,EAAE,IAAI,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;;YAE5F,aAAa,GAAG,eAAe,CAAC;QAElC,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QACnE,IAAG,SAAS,KAAK,SAAS,EAAE,CAAC;YAC3B,aAAa,GAAG,SAA0B,CAAC;QAC7C,CAAC;QAED,IAAG,eAAe,KAAK,SAAS;YAC9B,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC7E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 Merging\r\n */\r\n\r\nimport { Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"../Editing/Editor\";\r\nimport { SchemaConflictsError } from \"../Differencing/Errors\";\r\nimport { getSchemaDifferences, type SchemaDifferenceResult } from \"../Differencing/SchemaDifference\";\r\nimport { SchemaMergingVisitor } from \"./SchemaMergingVisitor\";\r\nimport { SchemaMergingWalker } from \"./SchemaMergingWalker\";\r\nimport { SchemaEdits } from \"./Edits/SchemaEdits\";\r\nimport { ECEditingStatus, SchemaEditingError } from \"../Editing/Exception\";\r\nimport { NameMapping } from \"./Edits/NameMapping\";\r\n\r\n/**\r\n * Defines the context of a Schema merging run.\r\n * @internal\r\n */\r\nexport interface SchemaMergeContext {\r\n readonly targetSchema: Schema;\r\n readonly targetSchemaKey: SchemaKey;\r\n readonly sourceSchemaKey: SchemaKey;\r\n readonly editor: SchemaContextEditor;\r\n readonly nameMapping: NameMapping;\r\n}\r\n\r\n/**\r\n * Class to merge two schemas together.\r\n * @see [[merge]] or [[mergeSchemas]] to merge two schemas together.\r\n * @beta\r\n */\r\nexport class SchemaMerger {\r\n\r\n private readonly _editingContext: SchemaContext;\r\n\r\n /**\r\n * Constructs a new instance of the SchemaMerger object.\r\n * @param editingContext The schema contexts that holds the schema to be edited.\r\n */\r\n constructor(editingContext: SchemaContext) {\r\n this._editingContext = editingContext;\r\n }\r\n\r\n /**\r\n * Copy the SchemaItems of the source schemas to the target schema.\r\n * @param targetSchema The schema the SchemaItems gets merged to.\r\n * @param sourceSchema The schema the SchemaItems gets copied from.\r\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\r\n * @returns The merged target schema.\r\n * @alpha\r\n */\r\n public async mergeSchemas(targetSchema: Schema, sourceSchema: Schema, edits?: SchemaEdits): Promise<Schema> {\r\n return this.merge(await getSchemaDifferences(targetSchema, sourceSchema, edits), edits);\r\n }\r\n\r\n /**\r\n * Merges the schema differences into the target schema context.\r\n * @param differenceResult The differences that shall be applied to the target schema.\r\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\r\n * @alpha\r\n */\r\n public async merge(differenceResult: SchemaDifferenceResult, edits?: SchemaEdits): Promise<Schema> {\r\n const targetSchemaKey = SchemaKey.parseString(differenceResult.targetSchemaName);\r\n const sourceSchemaKey = SchemaKey.parseString(differenceResult.sourceSchemaName);\r\n\r\n const nameMapping = new NameMapping();\r\n const editor = new SchemaContextEditor(new MergingSchemaContext(this._editingContext, nameMapping));\r\n\r\n // If schema changes were provided, they'll get applied and a new SchemaDifferenceResult is returned\r\n // to prevent altering the differenceResult the caller passed in.\r\n if (edits) {\r\n await edits.applyTo(differenceResult = { ...differenceResult }, nameMapping);\r\n }\r\n\r\n if (differenceResult.conflicts && differenceResult.conflicts.length > 0) {\r\n throw new SchemaConflictsError(\r\n \"Schema's can't be merged if there are unresolved conflicts.\",\r\n differenceResult.conflicts,\r\n sourceSchemaKey,\r\n targetSchemaKey,\r\n );\r\n }\r\n\r\n const schema = await editor.getSchema(targetSchemaKey).catch((error: Error) => {\r\n if (error instanceof SchemaEditingError && error.errorNumber === ECEditingStatus.SchemaNotFound) {\r\n throw new Error(`The target schema '${targetSchemaKey.name}' could not be found in the editing context.`);\r\n }\r\n throw error;\r\n });\r\n\r\n if (!schema.isDynamic) {\r\n throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);\r\n }\r\n\r\n const visitor = new SchemaMergingVisitor({\r\n editor,\r\n targetSchema: schema,\r\n targetSchemaKey,\r\n sourceSchemaKey,\r\n nameMapping,\r\n });\r\n\r\n const walker = new SchemaMergingWalker(visitor);\r\n await walker.traverse(differenceResult.differences, \"add\");\r\n await walker.traverse(differenceResult.differences, \"modify\");\r\n\r\n return schema;\r\n }\r\n}\r\n\r\n/**\r\n * SchemaContext implementation that overrides certain methods to allow to apply name mappings\r\n * for certain schema elements during the schema merging process.\r\n *\r\n * @internal\r\n */\r\nclass MergingSchemaContext extends SchemaContext {\r\n private _internalContext: SchemaContext;\r\n private _nameMappings: NameMapping;\r\n\r\n public constructor(internalContext: SchemaContext, nameMapping: NameMapping) {\r\n super();\r\n this._internalContext = internalContext;\r\n this._nameMappings = nameMapping;\r\n }\r\n\r\n public override async getCachedSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\r\n return this._internalContext.getCachedSchema(schemaKey, matchType);\r\n }\r\n\r\n public override async getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\r\n return this._internalContext.getSchema(schemaKey, matchType);\r\n }\r\n\r\n public override async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string | SchemaItemKey, itemNameOrCtor?: string | T, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\r\n let schemaItemKey: SchemaItemKey;\r\n if (typeof schemaNameOrKey === \"string\")\r\n schemaItemKey = new SchemaItemKey(itemNameOrCtor as string, new SchemaKey(schemaNameOrKey));\r\n else\r\n schemaItemKey = schemaNameOrKey;\r\n\r\n const mappedKey = this._nameMappings.resolveItemKey(schemaItemKey);\r\n if(mappedKey !== undefined) {\r\n schemaItemKey = mappedKey as SchemaItemKey;\r\n }\r\n\r\n if(itemConstructor === undefined)\r\n return this._internalContext.getSchemaItem(schemaItemKey);\r\n\r\n return this._internalContext.getSchemaItem(schemaItemKey, itemConstructor);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACxG,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,gCAAgC,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzJ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A4B,EAAE,KAAa,EAAE,KAA4B;QAC/G,OAAO,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;YACpD,GAAG,EAAE,cAAc;YACnB,MAAM,EAAE,iBAAiB;SAC1B,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,mBAAmB,CAAC,KAAqB;QACpD,OAAO,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE;YAC3C,GAAG,EAAE,OAAO;YACZ,MAAM,EAAE,UAAU;SACnB,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,yBAAyB,CAAC,KAA2B;QAChE,OAAO,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE;YAC3C,GAAG,EAAE,aAAa;YAClB,MAAM,EAAE,gBAAgB;SACzB,CAAC,CAAC;IACL,CAAC;IAED;;;MAGE;IACK,KAAK,CAAC,+CAA+C,CAAC,KAAiD;QAC5G,QAAO,KAAK,CAAC,UAAU,EAAE,CAAC;YACxB,KAAK,KAAK,CAAC,CAAC,OAAO,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3G,CAAC;IACH,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAA4B,EAAE,SAAkD,EAAE,SAAiB;IACtH,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, \n ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, \n EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, \n FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, \n MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, \n RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, \n StructClassDifference, UnitDifference, UnitSystemDifference } from \"../Differencing/SchemaDifference\";\nimport { addConstant, modifyConstant } from \"./ConstantMerger\";\nimport { addCustomAttribute } from \"./CustomAttributeMerger\";\nimport { addCustomAttributeClass, modifyCustomAttributeClass } from \"./CustomAttributeClassMerger\";\nimport { addClassMixins, addEntityClass, modifyEntityClass } from \"./EntityClassMerger\";\nimport { addEnumeration, modifyEnumeration } from \"./EnumerationMerger\";\nimport { addEnumerator, modifyEnumerator } from \"./EnumeratorMerger\";\nimport { addKindOfQuantity, addPresentationFormat, modifyKindOfQuantity } from \"./KindOfQuantityMerger\";\nimport { addMixinClass, modifyMixinClass } from \"./MixinMerger\";\nimport { addPhenomenon, modifyPhenomenon } from \"./PhenomenonMerger\";\nimport { addPropertyCategory, modifyPropertyCategory } from \"./PropertyCategoryMerger\";\nimport { addRelationshipClass, mergeRelationshipClassConstraint, mergeRelationshipConstraint, modifyRelationshipClass } from \"./RelationshipClassMerger\";\nimport { addSchemaReferences, modifySchemaReferences } from \"./SchemaReferenceMerger\";\nimport { addStructClass, modifyStructClass } from \"./StructClassMerger\";\nimport { addUnitSystem, modifyUnitSystem } from \"./UnitSystemMerger\";\nimport { mergePropertyDifference } from \"./PropertyMerger\";\nimport { isClassDifference } from \"../Differencing/Utils\";\nimport { SchemaDifferenceVisitor } from \"../Differencing/SchemaDifferenceVisitor\";\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { toItemKey } from \"./Utils\";\nimport { addUnit, modifyUnit } from \"./UnitMerger\";\nimport { addInvertedUnit, modifyInvertedUnit } from \"./InvertedUnitMerger\";\nimport { addFormat, modifyFormat, modifyFormatUnit, modifyFormatUnitLabel } from \"./FormatMerger\";\n\n/** Definition of schema items change type handler array. */\ninterface ItemChangeTypeHandler<T extends AnySchemaDifference> {\n add: (context: SchemaMergeContext, entry: T) => Promise<void>;\n modify: (context: SchemaMergeContext, entry: T, key: SchemaItemKey) => Promise<void>;\n}\n\n/**\n * Implementation of ISchemaDifferenceVisitor that can be used to traverse schema\n * differences to call the appropriated merger methods.\n * @internal\n */\nexport class SchemaMergingVisitor implements SchemaDifferenceVisitor {\n\n private readonly _context: SchemaMergeContext;\n\n /**\n * Initializes a new instance of SchemaMergingVisitor class.\n */\n constructor(context: SchemaMergeContext) {\n this._context = context;\n }\n\n /**\n * Shared merging logic for all types of ClassItemDifference union.\n */\n private async visitClassDifference<T extends AnyClassItemDifference>(entry: T, index: number, array: AnySchemaDifference[], handler: ItemChangeTypeHandler<T>) {\n return this.visitSchemaItemDifference(entry, {\n add: async (context) => {\n // To add classes a slightly different approach is done. In fact the class entries gets processed\n // two times. The first time, a stub with the bare minimum is added to the schema. The second time,\n // the class gets completed with all properties, mixins, etc...\n if(entry.changeType === \"add\" && !await context.targetSchema.getItem(entry.itemName)) {\n await handler.add(this._context, {\n ...entry,\n difference: {\n ...entry.difference,\n // Remove everything we want to validate before setting, this is done in the second iteration.\n baseClass: undefined,\n mixins: undefined,\n properties: undefined,\n customAttributes: undefined,\n },\n });\n\n // Searches for the last class difference and adds the entry after it. That way,\n // the class is completed before class related entries get processed.\n const insertIndex = findIndexOf(array, (e) => !isClassDifference(e), index) || array.length;\n array.splice(insertIndex, 0, entry);\n\n return;\n }\n\n // Now both a modification change or the second add iteration is a modification of an existing class.\n // So, regardless of the actual change type, modify is called.\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\n },\n modify: handler.modify,\n });\n }\n\n /**\n * Visitor implementation for handling ConstantDifference.\n * @internal\n */\n public async visitConstantDifference(entry: ConstantDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addConstant,\n modify: modifyConstant,\n });\n }\n\n /**\n * Visitor implementation for handling CustomAttributeClassDifference.\n * @internal\n */\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\n return this.visitClassDifference(entry, index, array, {\n add: addCustomAttributeClass,\n modify: modifyCustomAttributeClass,\n });\n }\n\n /**\n * Visitor implementation for handling CustomAttributeDifference.\n * @internal\n */\n public async visitCustomAttributeInstanceDifference(entry: CustomAttributeDifference): Promise<void> {\n switch(entry.changeType) {\n case \"add\": return addCustomAttribute(this._context, entry);\n }\n }\n\n /**\n * Visitor implementation for handling EntityClassDifference.\n * @internal\n */\n public async visitEntityClassDifference(entry: EntityClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\n return this.visitClassDifference(entry, index, array, {\n add: addEntityClass,\n modify: modifyEntityClass,\n });\n }\n\n /**\n * Visitor implementation for handling EntityClassMixinDifference.\n * @internal\n */\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference): Promise<void> {\n switch(entry.changeType) {\n case \"add\": return addClassMixins(this._context, entry);\n }\n }\n\n /**\n * Visitor implementation for handling EnumerationDifference.\n * @internal\n */\n public async visitEnumerationDifference(entry: EnumerationDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addEnumeration,\n modify: modifyEnumeration,\n });\n }\n\n /**\n * Visitor implementation for handling EnumeratorDifference.\n * @internal\n */\n public async visitEnumeratorDifference(entry: EnumeratorDifference): Promise<void> {\n switch(entry.changeType) {\n case \"add\": return addEnumerator(this._context, entry);\n case \"modify\": return modifyEnumerator(this._context, entry, toItemKey(this._context, entry.itemName));\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(entry: FormatDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addFormat,\n modify: modifyFormat,\n });\n }\n\n /**\n * Visitor implementation for handling FormatUnitDifference.\n * @internal\n */\n public async visitFormatUnitDifference(entry: FormatUnitDifference): Promise<void> {\n switch(entry.changeType) {\n case \"modify\": return modifyFormatUnit(this._context, entry, toItemKey(this._context, entry.itemName));\n }\n }\n\n /**\n * Visitor implementation for handling FormatUnitLabelDifference.\n * @internal\n */\n public async visitFormatUnitLabelDifference(entry: FormatUnitLabelDifference): Promise<void> {\n switch(entry.changeType) {\n case \"modify\": return modifyFormatUnitLabel(this._context, entry, toItemKey(this._context, entry.itemName));\n }\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addInvertedUnit,\n modify: modifyInvertedUnit,\n });\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityDifference.\n * @internal\n */\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addKindOfQuantity,\n modify: modifyKindOfQuantity,\n });\n }\n\n /**\n * Visitor implementation for handling MixinClassDifference.\n * @internal\n */\n public async visitMixinDifference(entry: MixinClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\n return this.visitClassDifference(entry, index, array, {\n add: addMixinClass,\n modify: modifyMixinClass,\n });\n }\n\n /**\n * Visitor implementation for handling PhenomenonDifference.\n * @internal\n */\n public async visitPhenomenonDifference(entry: PhenomenonDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addPhenomenon,\n modify: modifyPhenomenon,\n });\n }\n\n /**\n * Visitor implementation for handling PropertyCategoryDifference.\n * @internal\n */\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addPropertyCategory,\n modify: modifyPropertyCategory,\n });\n }\n\n /**\n * Visitor implementation for handling ClassPropertyDifference.\n * @internal\n */\n public async visitPropertyDifference(entry: ClassPropertyDifference): Promise<void> {\n await mergePropertyDifference(this._context, entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipClassDifference.\n * @internal\n */\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\n return this.visitClassDifference(entry, index, array, {\n add: addRelationshipClass,\n modify: modifyRelationshipClass,\n });\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintClassDifference.\n * @internal\n */\n public async visitRelationshipConstraintClassDifference(entry: RelationshipConstraintClassDifference): Promise<void> {\n await mergeRelationshipClassConstraint(this._context, entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintDifference.\n * @internal\n */\n public async visitRelationshipConstraintDifference(entry: RelationshipConstraintDifference): Promise<void> {\n await mergeRelationshipConstraint(this._context, entry);\n }\n\n /**\n * Visitor implementation for handling SchemaDifference.\n * @internal\n */\n public async visitSchemaDifference({ difference }: SchemaDifference): Promise<void> {\n if (difference.label !== undefined) {\n await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);\n }\n if (difference.description !== undefined) {\n await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);\n }\n }\n\n /**\n * Shared merging logic for all types of AnySchemaItemDifference union.\n */\n private async visitSchemaItemDifference<T extends AnySchemaItemDifference>(entry: T, handler: ItemChangeTypeHandler<T>) {\n switch(entry.changeType) {\n case \"add\": {\n return handler.add(this._context, entry);\n }\n case \"modify\": {\n if(\"schemaItemType\" in entry.difference && entry.difference.schemaItemType !== entry.schemaType) {\n throw new Error(`Changing the type of item '${entry.itemName}' not supported.`);\n }\n\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\n };\n }\n }\n\n /**\n * Visitor implementation for handling SchemaReferenceDifference.\n * @internal\n */\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference): Promise<void> {\n switch(entry.changeType) {\n case \"add\": return addSchemaReferences(this._context, entry);\n case \"modify\": return modifySchemaReferences(this._context, entry);\n }\n }\n\n /**\n * Visitor implementation for handling StructClassDifference.\n * @internal\n */\n public async visitStructClassDifference(entry: StructClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\n return this.visitClassDifference(entry, index, array, {\n add: addStructClass,\n modify: modifyStructClass,\n });\n }\n\n /**\n * Visitor implementation for handling UnitDifference.\n * @internal\n */\n public async visitUnitDifference(entry: UnitDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addUnit,\n modify: modifyUnit,\n });\n }\n\n /**\n * Visitor implementation for handling UnitSystemDifference.\n * @internal\n */\n public async visitUnitSystemDifference(entry: UnitSystemDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addUnitSystem,\n modify: modifyUnitSystem,\n });\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\n * @internal\n */\n public async visitKindOfQuantityPresentationFormatDifference(entry: KindOfQuantityPresentationFormatDifference): Promise<void> {\n switch(entry.changeType) {\n case \"add\": return addPresentationFormat(this._context, entry, toItemKey(this._context, entry.itemName));\n }\n }\n}\n\n/**\n * Helper method to get the index of the first element in the array that satisfies the provided testing function.\n * @param array Array to search.\n * @param predicate Function to execute on each value in the array.\n * @param fromIndex The index to start the search at.\n * @returns An index in the array if an element passes the test; otherwise, false.\n */\nfunction findIndexOf(array: AnySchemaDifference[], predicate: (entry: AnySchemaDifference) => boolean, fromIndex: number) {\n for (let i = fromIndex; i < array.length; i++) {\n if (predicate(array[i]))\n return i;\n }\n return false;\n}\n"]}
1
+ {"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAA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AAC,+CAA+C,CAAC,KAAiD;QAC5G,QAAO,KAAK,CAAC,UAAU,EAAE,CAAC;YACxB,KAAK,KAAK,CAAC,CAAC,OAAO,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3G,CAAC;IACH,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAA4B,EAAE,SAAkD,EAAE,SAAiB;IACtH,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, \r\n ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, \r\n EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, \r\n FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, \r\n MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, \r\n RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, \r\n StructClassDifference, UnitDifference, UnitSystemDifference } from \"../Differencing/SchemaDifference\";\r\nimport { addConstant, modifyConstant } from \"./ConstantMerger\";\r\nimport { addCustomAttribute } from \"./CustomAttributeMerger\";\r\nimport { addCustomAttributeClass, modifyCustomAttributeClass } from \"./CustomAttributeClassMerger\";\r\nimport { addClassMixins, addEntityClass, modifyEntityClass } from \"./EntityClassMerger\";\r\nimport { addEnumeration, modifyEnumeration } from \"./EnumerationMerger\";\r\nimport { addEnumerator, modifyEnumerator } from \"./EnumeratorMerger\";\r\nimport { addKindOfQuantity, addPresentationFormat, modifyKindOfQuantity } from \"./KindOfQuantityMerger\";\r\nimport { addMixinClass, modifyMixinClass } from \"./MixinMerger\";\r\nimport { addPhenomenon, modifyPhenomenon } from \"./PhenomenonMerger\";\r\nimport { addPropertyCategory, modifyPropertyCategory } from \"./PropertyCategoryMerger\";\r\nimport { addRelationshipClass, mergeRelationshipClassConstraint, mergeRelationshipConstraint, modifyRelationshipClass } from \"./RelationshipClassMerger\";\r\nimport { addSchemaReferences, modifySchemaReferences } from \"./SchemaReferenceMerger\";\r\nimport { addStructClass, modifyStructClass } from \"./StructClassMerger\";\r\nimport { addUnitSystem, modifyUnitSystem } from \"./UnitSystemMerger\";\r\nimport { mergePropertyDifference } from \"./PropertyMerger\";\r\nimport { isClassDifference } from \"../Differencing/Utils\";\r\nimport { SchemaDifferenceVisitor } from \"../Differencing/SchemaDifferenceVisitor\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { toItemKey } from \"./Utils\";\r\nimport { addUnit, modifyUnit } from \"./UnitMerger\";\r\nimport { addInvertedUnit, modifyInvertedUnit } from \"./InvertedUnitMerger\";\r\nimport { addFormat, modifyFormat, modifyFormatUnit, modifyFormatUnitLabel } from \"./FormatMerger\";\r\n\r\n/** Definition of schema items change type handler array. */\r\ninterface ItemChangeTypeHandler<T extends AnySchemaDifference> {\r\n add: (context: SchemaMergeContext, entry: T) => Promise<void>;\r\n modify: (context: SchemaMergeContext, entry: T, key: SchemaItemKey) => Promise<void>;\r\n}\r\n\r\n/**\r\n * Implementation of ISchemaDifferenceVisitor that can be used to traverse schema\r\n * differences to call the appropriated merger methods.\r\n * @internal\r\n */\r\nexport class SchemaMergingVisitor implements SchemaDifferenceVisitor {\r\n\r\n private readonly _context: SchemaMergeContext;\r\n\r\n /**\r\n * Initializes a new instance of SchemaMergingVisitor class.\r\n */\r\n constructor(context: SchemaMergeContext) {\r\n this._context = context;\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of ClassItemDifference union.\r\n */\r\n private async visitClassDifference<T extends AnyClassItemDifference>(entry: T, index: number, array: AnySchemaDifference[], handler: ItemChangeTypeHandler<T>) {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: async (context) => {\r\n // To add classes a slightly different approach is done. In fact the class entries gets processed\r\n // two times. The first time, a stub with the bare minimum is added to the schema. The second time,\r\n // the class gets completed with all properties, mixins, etc...\r\n if(entry.changeType === \"add\" && !await context.targetSchema.getItem(entry.itemName)) {\r\n await handler.add(this._context, {\r\n ...entry,\r\n difference: {\r\n ...entry.difference,\r\n // Remove everything we want to validate before setting, this is done in the second iteration.\r\n baseClass: undefined,\r\n mixins: undefined,\r\n properties: undefined,\r\n customAttributes: undefined,\r\n },\r\n });\r\n\r\n // Searches for the last class difference and adds the entry after it. That way,\r\n // the class is completed before class related entries get processed.\r\n const insertIndex = findIndexOf(array, (e) => !isClassDifference(e), index) || array.length;\r\n array.splice(insertIndex, 0, entry);\r\n\r\n return;\r\n }\r\n\r\n // Now both a modification change or the second add iteration is a modification of an existing class.\r\n // So, regardless of the actual change type, modify is called.\r\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\r\n },\r\n modify: handler.modify,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ConstantDifference.\r\n * @internal\r\n */\r\n public async visitConstantDifference(entry: ConstantDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addConstant,\r\n modify: modifyConstant,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeClassDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addCustomAttributeClass,\r\n modify: modifyCustomAttributeClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeInstanceDifference(entry: CustomAttributeDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"add\": return addCustomAttribute(this._context, entry);\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassDifference(entry: EntityClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addEntityClass,\r\n modify: modifyEntityClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassMixinDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"add\": return addClassMixins(this._context, entry);\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumerationDifference.\r\n * @internal\r\n */\r\n public async visitEnumerationDifference(entry: EnumerationDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addEnumeration,\r\n modify: modifyEnumeration,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumeratorDifference.\r\n * @internal\r\n */\r\n public async visitEnumeratorDifference(entry: EnumeratorDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"add\": return addEnumerator(this._context, entry);\r\n case \"modify\": return modifyEnumerator(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatDifference.\r\n * @internal\r\n */\r\n public async visitFormatDifference(entry: FormatDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addFormat,\r\n modify: modifyFormat,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitDifference(entry: FormatUnitDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"modify\": return modifyFormatUnit(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitLabelDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitLabelDifference(entry: FormatUnitLabelDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"modify\": return modifyFormatUnitLabel(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling InvertedUnitDifference.\r\n * @internal\r\n */\r\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addInvertedUnit,\r\n modify: modifyInvertedUnit,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addKindOfQuantity,\r\n modify: modifyKindOfQuantity,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling MixinClassDifference.\r\n * @internal\r\n */\r\n public async visitMixinDifference(entry: MixinClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addMixinClass,\r\n modify: modifyMixinClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PhenomenonDifference.\r\n * @internal\r\n */\r\n public async visitPhenomenonDifference(entry: PhenomenonDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addPhenomenon,\r\n modify: modifyPhenomenon,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PropertyCategoryDifference.\r\n * @internal\r\n */\r\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addPropertyCategory,\r\n modify: modifyPropertyCategory,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ClassPropertyDifference.\r\n * @internal\r\n */\r\n public async visitPropertyDifference(entry: ClassPropertyDifference): Promise<void> {\r\n await mergePropertyDifference(this._context, entry);\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addRelationshipClass,\r\n modify: modifyRelationshipClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintClassDifference(entry: RelationshipConstraintClassDifference): Promise<void> {\r\n await mergeRelationshipClassConstraint(this._context, entry);\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintDifference(entry: RelationshipConstraintDifference): Promise<void> {\r\n await mergeRelationshipConstraint(this._context, entry);\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaDifference.\r\n * @internal\r\n */\r\n public async visitSchemaDifference({ difference }: SchemaDifference): Promise<void> {\r\n if (difference.label !== undefined) {\r\n await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);\r\n }\r\n if (difference.description !== undefined) {\r\n await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);\r\n }\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of AnySchemaItemDifference union.\r\n */\r\n private async visitSchemaItemDifference<T extends AnySchemaItemDifference>(entry: T, handler: ItemChangeTypeHandler<T>) {\r\n switch(entry.changeType) {\r\n case \"add\": {\r\n return handler.add(this._context, entry);\r\n }\r\n case \"modify\": {\r\n if(\"schemaItemType\" in entry.difference && entry.difference.schemaItemType !== entry.schemaType) {\r\n throw new Error(`Changing the type of item '${entry.itemName}' not supported.`);\r\n }\r\n\r\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaReferenceDifference.\r\n * @internal\r\n */\r\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"add\": return addSchemaReferences(this._context, entry);\r\n case \"modify\": return modifySchemaReferences(this._context, entry);\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling StructClassDifference.\r\n * @internal\r\n */\r\n public async visitStructClassDifference(entry: StructClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addStructClass,\r\n modify: modifyStructClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitDifference.\r\n * @internal\r\n */\r\n public async visitUnitDifference(entry: UnitDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addUnit,\r\n modify: modifyUnit,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitSystemDifference.\r\n * @internal\r\n */\r\n public async visitUnitSystemDifference(entry: UnitSystemDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addUnitSystem,\r\n modify: modifyUnitSystem,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityPresentationFormatDifference(entry: KindOfQuantityPresentationFormatDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"add\": return addPresentationFormat(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Helper method to get the index of the first element in the array that satisfies the provided testing function.\r\n * @param array Array to search.\r\n * @param predicate Function to execute on each value in the array.\r\n * @param fromIndex The index to start the search at.\r\n * @returns An index in the array if an element passes the test; otherwise, false.\r\n */\r\nfunction findIndexOf(array: AnySchemaDifference[], predicate: (entry: AnySchemaDifference) => boolean, fromIndex: number) {\r\n for (let i = fromIndex; i < array.length; i++) {\r\n if (predicate(array[i]))\r\n return i;\r\n }\r\n return false;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMergingWalker.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAuC,gBAAgB,EAAc,MAAM,kCAAkC,CAAC;AAErH;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,sBAAsB;IAE7D;;;;;;;OAOG;IACa,KAAK,CAAC,QAAQ,CAAC,WAAuC,EAAE,UAA2B;QAEjG,MAAM,YAAY,GAAG,CAAC,UAAsB,EAAE,EAAE;YAC9C,OAAO,CAAC,KAA0B,EAAE,EAAE;gBACpC,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU,IAAI,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;YAC7F,CAAC,CAAC;QACJ,CAAC,CAAC;QAEF,OAAO,KAAK,CAAC,QAAQ,CAAC;YACpB,wDAAwD;YACxD,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAC5D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;YAErE,+CAA+C;YAC/C,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;YAC9D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;YACpE,GAAG,WAAW,CAAC,MAAM,CAA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CAAC,iBAAiB,CAAC,CAAC;YACrE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;YACtE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;YAC5E,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,2BAA2B,CAAC,CAAC;YACjF,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAE9D,kCAAkC;YAClC,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;SAC9E,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport { SchemaDifferenceWalker } from \"../Differencing/SchemaDifferenceVisitor\";\nimport { AnySchemaDifference, DifferenceType, SchemaOtherTypes, SchemaType } from \"../Differencing/SchemaDifference\";\n\n/**\n * A walker that traverses the schema differences in a certain oder and invokes the appropriate\n * visitor method for each kind of schema difference.\n * @internal\n */\nexport class SchemaMergingWalker extends SchemaDifferenceWalker {\n\n /**\n * Traverses the schema differences and calls the appropriate method on the visitor.\n * This method overrides the derived class method to apply some ordering how the\n * differences are traversed.\n *\n * @param differences The differences to traverse.\n * @param changeType Optional type of change to filter by.\n */\n public override async traverse(differences: Array<AnySchemaDifference>, changeType?: DifferenceType): Promise<void> {\n\n const filterByType = (schemaType: SchemaType) => {\n return (entry: AnySchemaDifference) => {\n return entry.schemaType === schemaType && (!changeType || entry.changeType === changeType);\n };\n };\n\n return super.traverse([\n // First the schema related differences are traversed...\n ...differences.filter(filterByType(SchemaOtherTypes.Schema)),\n ...differences.filter(filterByType(SchemaOtherTypes.SchemaReference)),\n\n // Then the schema items (excluding classes)...\n ...differences.filter(filterByType(SchemaItemType.UnitSystem)),\n ...differences.filter(filterByType(SchemaItemType.PropertyCategory)),\n ...differences.filter(filterByType(SchemaItemType.Enumeration)),\n ...differences.filter(filterByType(SchemaOtherTypes.Enumerator)),\n ...differences.filter(filterByType(SchemaItemType.Phenomenon)),\n ...differences.filter(filterByType(SchemaItemType.Unit)),\n ...differences.filter(filterByType(SchemaItemType.InvertedUnit)),\n ...differences.filter(filterByType(SchemaItemType.Format)),\n ...differences.filter(filterByType(SchemaOtherTypes.FormatUnit)),\n ...differences.filter(filterByType(SchemaOtherTypes.FormatUnitLabel)),\n ...differences.filter(filterByType(SchemaItemType.KindOfQuantity)),\n ...differences.filter(filterByType(SchemaItemType.Constant)),\n ...differences.filter(filterByType(SchemaOtherTypes.KindOfQuantityPresentationFormat)),\n\n // Followed by classes and class related differences...\n ...differences.filter(filterByType(SchemaItemType.CustomAttributeClass)),\n ...differences.filter(filterByType(SchemaItemType.Mixin)),\n ...differences.filter(filterByType(SchemaItemType.StructClass)),\n ...differences.filter(filterByType(SchemaItemType.EntityClass)),\n ...differences.filter(filterByType(SchemaItemType.RelationshipClass)),\n ...differences.filter(filterByType(SchemaOtherTypes.EntityClassMixin)),\n ...differences.filter(filterByType(SchemaOtherTypes.RelationshipConstraint)),\n ...differences.filter(filterByType(SchemaOtherTypes.RelationshipConstraintClass)),\n ...differences.filter(filterByType(SchemaOtherTypes.Property)),\n\n // And then the custom attributes.\n ...differences.filter(filterByType(SchemaOtherTypes.CustomAttributeInstance)),\n ]);\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaMergingWalker.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAA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AClC,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;SAC9E,CAAC,CAAC;IACL,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\nimport { SchemaItemType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaDifferenceWalker } from \"../Differencing/SchemaDifferenceVisitor\";\r\nimport { AnySchemaDifference, DifferenceType, SchemaOtherTypes, SchemaType } from \"../Differencing/SchemaDifference\";\r\n\r\n/**\r\n * A walker that traverses the schema differences in a certain oder and invokes the appropriate\r\n * visitor method for each kind of schema difference.\r\n * @internal\r\n */\r\nexport class SchemaMergingWalker extends SchemaDifferenceWalker {\r\n\r\n /**\r\n * Traverses the schema differences and calls the appropriate method on the visitor.\r\n * This method overrides the derived class method to apply some ordering how the\r\n * differences are traversed.\r\n *\r\n * @param differences The differences to traverse.\r\n * @param changeType Optional type of change to filter by.\r\n */\r\n public override async traverse(differences: Array<AnySchemaDifference>, changeType?: DifferenceType): Promise<void> {\r\n\r\n const filterByType = (schemaType: SchemaType) => {\r\n return (entry: AnySchemaDifference) => {\r\n return entry.schemaType === schemaType && (!changeType || entry.changeType === changeType);\r\n };\r\n };\r\n\r\n return super.traverse([\r\n // First the schema related differences are traversed...\r\n ...differences.filter(filterByType(SchemaOtherTypes.Schema)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.SchemaReference)),\r\n\r\n // Then the schema items (excluding classes)...\r\n ...differences.filter(filterByType(SchemaItemType.UnitSystem)),\r\n ...differences.filter(filterByType(SchemaItemType.PropertyCategory)),\r\n ...differences.filter(filterByType(SchemaItemType.Enumeration)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.Enumerator)),\r\n ...differences.filter(filterByType(SchemaItemType.Phenomenon)),\r\n ...differences.filter(filterByType(SchemaItemType.Unit)),\r\n ...differences.filter(filterByType(SchemaItemType.InvertedUnit)),\r\n ...differences.filter(filterByType(SchemaItemType.Format)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.FormatUnit)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.FormatUnitLabel)),\r\n ...differences.filter(filterByType(SchemaItemType.KindOfQuantity)),\r\n ...differences.filter(filterByType(SchemaItemType.Constant)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.KindOfQuantityPresentationFormat)),\r\n\r\n // Followed by classes and class related differences...\r\n ...differences.filter(filterByType(SchemaItemType.CustomAttributeClass)),\r\n ...differences.filter(filterByType(SchemaItemType.Mixin)),\r\n ...differences.filter(filterByType(SchemaItemType.StructClass)),\r\n ...differences.filter(filterByType(SchemaItemType.EntityClass)),\r\n ...differences.filter(filterByType(SchemaItemType.RelationshipClass)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.EntityClassMixin)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.RelationshipConstraint)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.RelationshipConstraintClass)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.Property)),\r\n\r\n // And then the custom attributes.\r\n ...differences.filter(filterByType(SchemaOtherTypes.CustomAttributeInstance)),\r\n ]);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaReferenceMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaReferenceMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAU,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEzF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAA2B,EAAE,MAAiC;IACtG,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/G,MAA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C,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAC5F,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,YAAY,CAAC,MAA2B,EAAE,UAAmB,EAAE,OAAgB;IAC5F,IAAG,UAAU,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;IACtG,IAAG,MAAM,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,qBAAqB,SAAS,CAAC,QAAQ,EAAE,uCAAuC,CAAC,CAAC;IACpG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,IAAe,EAAE,KAAgB;IACpD,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC;QACrC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC;QACf,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACpB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { SchemaReferenceDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaContextEditor } from \"../Editing/Editor\";\nimport { ECVersion, Schema, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new reference to an external schema into the target schema.\n * @internal\n */\nexport async function addSchemaReferences(context: SchemaMergeContext, change: SchemaReferenceDifference) {\n const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);\n await context.editor.addSchemaReference(context.targetSchemaKey, referencedSchema);\n}\n\n/**\n * Merges differences to an existing schema references in the target schema.\n * @internal\n */\nexport async function modifySchemaReferences(context: SchemaMergeContext, change: SchemaReferenceDifference) {\n const existingSchema = await context.targetSchema.getReference(change.difference.name) as Schema;\n const [older, latest] = sortSchemas(existingSchema.schemaKey, new SchemaKey(change.difference.name, ECVersion.fromString(change.difference.version)));\n if(latest === existingSchema.schemaKey) {\n return;\n }\n\n if(!latest.matches(older, SchemaMatchType.LatestWriteCompatible)) {\n throw new Error(`Schemas references of ${change.difference.name} have incompatible versions: ${older.version} and ${latest.version}`);\n }\n\n const index = context.targetSchema.references.findIndex((reference) => reference === existingSchema);\n context.targetSchema.references.splice(index, 1);\n\n const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);\n await context.editor.addSchemaReference(context.targetSchema.schemaKey, referencedSchema);\n}\n\n/**\n * Tries to locate the Schema in the current Context\n * @param editor Current editor context.\n * @param schemaName The schema name to be looked up.\n * @param version The schemas version to beo looked up.\n * @returns The schema found in the context.\n */\nasync function locateSchema(editor: SchemaContextEditor, schemaName?: string, version?: string): Promise<Schema> {\n if(schemaName === undefined || version === undefined) {\n throw new Error(\"Schema name and version must not be undefined.\");\n }\n\n const schemaKey = new SchemaKey(schemaName, ECVersion.fromString(version));\n const schema = await editor.schemaContext.getSchema(schemaKey, SchemaMatchType.LatestWriteCompatible);\n if(schema === undefined) {\n throw new Error(`Referenced schema ${schemaKey.toString()} could not be found in target context`);\n }\n return schema;\n}\n\n/**\n * Sorts the schemas and return them in order of their versions [older, latest].\n * @param left The first schema key to be added.\n * @param right The second schema key to be added.\n * @returns The schemas in order.\n */\nfunction sortSchemas(left: SchemaKey, right: SchemaKey): [SchemaKey, SchemaKey] {\n return left.compareByVersion(right) < 0\n ? [left, right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CAAC,IAAI,EAAE,KAAK,CAAC;QACf,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACpB,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\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaReferenceDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaContextEditor } from \"../Editing/Editor\";\r\nimport { ECVersion, Schema, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new reference to an external schema into the target schema.\r\n * @internal\r\n */\r\nexport async function addSchemaReferences(context: SchemaMergeContext, change: SchemaReferenceDifference) {\r\n const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);\r\n await context.editor.addSchemaReference(context.targetSchemaKey, referencedSchema);\r\n}\r\n\r\n/**\r\n * Merges differences to an existing schema references in the target schema.\r\n * @internal\r\n */\r\nexport async function modifySchemaReferences(context: SchemaMergeContext, change: SchemaReferenceDifference) {\r\n const existingSchema = await context.targetSchema.getReference(change.difference.name) as Schema;\r\n const [older, latest] = sortSchemas(existingSchema.schemaKey, new SchemaKey(change.difference.name, ECVersion.fromString(change.difference.version)));\r\n if(latest === existingSchema.schemaKey) {\r\n return;\r\n }\r\n\r\n if(!latest.matches(older, SchemaMatchType.LatestWriteCompatible)) {\r\n throw new Error(`Schemas references of ${change.difference.name} have incompatible versions: ${older.version} and ${latest.version}`);\r\n }\r\n\r\n const index = context.targetSchema.references.findIndex((reference) => reference === existingSchema);\r\n context.targetSchema.references.splice(index, 1);\r\n\r\n const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);\r\n await context.editor.addSchemaReference(context.targetSchema.schemaKey, referencedSchema);\r\n}\r\n\r\n/**\r\n * Tries to locate the Schema in the current Context\r\n * @param editor Current editor context.\r\n * @param schemaName The schema name to be looked up.\r\n * @param version The schemas version to beo looked up.\r\n * @returns The schema found in the context.\r\n */\r\nasync function locateSchema(editor: SchemaContextEditor, schemaName?: string, version?: string): Promise<Schema> {\r\n if(schemaName === undefined || version === undefined) {\r\n throw new Error(\"Schema name and version must not be undefined.\");\r\n }\r\n\r\n const schemaKey = new SchemaKey(schemaName, ECVersion.fromString(version));\r\n const schema = await editor.schemaContext.getSchema(schemaKey, SchemaMatchType.LatestWriteCompatible);\r\n if(schema === undefined) {\r\n throw new Error(`Referenced schema ${schemaKey.toString()} could not be found in target context`);\r\n }\r\n return schema;\r\n}\r\n\r\n/**\r\n * Sorts the schemas and return them in order of their versions [older, latest].\r\n * @param left The first schema key to be added.\r\n * @param right The second schema key to be added.\r\n * @returns The schemas in order.\r\n */\r\nfunction sortSchemas(left: SchemaKey, right: SchemaKey): [SchemaKey, SchemaKey] {\r\n return left.compareByVersion(right) < 0\r\n ? [left, right]\r\n : [right, left];\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"StructClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/StructClassMerger.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACpE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAiB,CAAC;IAC5E,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { StructClassDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableClass } from \"../Editing/Mutable/MutableClass\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { modifyClass } from \"./ClassMerger\";\n\n/**\n * Merges a new StructClass into the target schema.\n * @internal\n */\nexport async function addStructClass(context: SchemaMergeContext, change: StructClassDifference) {\n await context.editor.structs.createFromProps(context.targetSchemaKey, {\n name: change.itemName,\n ...change.difference,\n });\n}\n\n/**\n * Merges differences to an existing StructClass in the target schema.\n * @internal\n */\nexport async function modifyStructClass(context: SchemaMergeContext, change: StructClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableClass;\n return modifyClass(context, change, itemKey, item);\n}\n"]}
1
+ {"version":3,"file":"StructClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/StructClassMerger.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACpE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAiB,CAAC;IAC5E,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,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\nimport type { StructClassDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableClass } from \"../Editing/Mutable/MutableClass\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\n\r\n/**\r\n * Merges a new StructClass into the target schema.\r\n * @internal\r\n */\r\nexport async function addStructClass(context: SchemaMergeContext, change: StructClassDifference) {\r\n await context.editor.structs.createFromProps(context.targetSchemaKey, {\r\n name: change.itemName,\r\n ...change.difference,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing StructClass in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyStructClass(context: SchemaMergeContext, change: StructClassDifference, itemKey: SchemaItemKey) {\r\n const item = await context.targetSchema.lookupItem(itemKey) as MutableClass;\r\n return modifyClass(context, change, itemKey, item);\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UnitMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAA2B,EAAE,MAAsB;IAC/E,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;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AK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,sBAAsB,MAAM,CAAC,QAAQ,gCAAgC,CAAC,CAAC;IACzF,CAAC;IACD,2EAA2E;IAC3E,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,sBAAsB,MAAM,CAAC,QAAQ,iCAAiC,CAAC,CAAC;IAC1F,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,sBAAsB,MAAM,CAAC,QAAQ,+BAA+B,CAAC,CAAC;IACxF,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,sBAAsB,MAAM,CAAC,QAAQ,4BAA4B,CAAC,CAAC;IACrF,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACpF,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { UnitDifference } from \"../Differencing/SchemaDifference\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { updateSchemaItemFullName } from \"./Utils\";\n\n/**\n * Merges a new Unit into the target schema.\n * @internal\n */\nexport async function addUnit(context: SchemaMergeContext, change: UnitDifference) {\n if (change.difference.phenomenon === undefined) {\n throw new Error(\"Unit must define phenomenon\");\n }\n if (change.difference.unitSystem === undefined) {\n throw new Error(\"Unit must define unitSystem\");\n }\n if (change.difference.definition === undefined) {\n throw new Error(\"Unit must define definition\");\n }\n\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\n change.difference.unitSystem = await updateSchemaItemFullName(context, change.difference.unitSystem);\n\n await context.editor.units.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n phenomenon: change.difference.phenomenon,\n unitSystem: change.difference.unitSystem,\n definition: change.difference.definition,\n });\n}\n\n/**\n * Merges differences to an existing Unit in the target schema.\n * @internal\n */\nexport async function modifyUnit(context: SchemaMergeContext, change: UnitDifference, itemKey: SchemaItemKey) {\n if (change.difference.unitSystem !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' unitSystem is not supported.`);\n }\n if (change.difference.phenomenon !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' phenomenon is not supported.`);\n }\n if (change.difference.definition !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' definition is not supported.`);\n }\n // we have consider later should we allow to change these values on merging\n if (change.difference.denominator !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' denominator is not supported.`);\n }\n if (change.difference.numerator !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' numerator is not supported.`);\n }\n if (change.difference.offset !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' offset is not supported.`);\n }\n\n if (change.difference.label !== undefined) {\n await context.editor.units.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.units.setDescription(itemKey, change.difference.description);\n }\n}\n"]}
1
+ {"version":3,"file":"UnitMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitMerger.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C,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACpF,CAAC;AACH,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\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { UnitDifference } from \"../Differencing/SchemaDifference\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { updateSchemaItemFullName } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new Unit into the target schema.\r\n * @internal\r\n */\r\nexport async function addUnit(context: SchemaMergeContext, change: UnitDifference) {\r\n if (change.difference.phenomenon === undefined) {\r\n throw new Error(\"Unit must define phenomenon\");\r\n }\r\n if (change.difference.unitSystem === undefined) {\r\n throw new Error(\"Unit must define unitSystem\");\r\n }\r\n if (change.difference.definition === undefined) {\r\n throw new Error(\"Unit must define definition\");\r\n }\r\n\r\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\r\n change.difference.unitSystem = await updateSchemaItemFullName(context, change.difference.unitSystem);\r\n\r\n await context.editor.units.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n phenomenon: change.difference.phenomenon,\r\n unitSystem: change.difference.unitSystem,\r\n definition: change.difference.definition,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing Unit in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyUnit(context: SchemaMergeContext, change: UnitDifference, itemKey: SchemaItemKey) {\r\n if (change.difference.unitSystem !== undefined) {\r\n throw new Error(`Changing the unit '${change.itemName}' unitSystem is not supported.`);\r\n }\r\n if (change.difference.phenomenon !== undefined) {\r\n throw new Error(`Changing the unit '${change.itemName}' phenomenon is not supported.`);\r\n }\r\n if (change.difference.definition !== undefined) {\r\n throw new Error(`Changing the unit '${change.itemName}' definition is not supported.`);\r\n }\r\n // we have consider later should we allow to change these values on merging\r\n if (change.difference.denominator !== undefined) {\r\n throw new Error(`Changing the unit '${change.itemName}' denominator is not supported.`);\r\n }\r\n if (change.difference.numerator !== undefined) {\r\n throw new Error(`Changing the unit '${change.itemName}' numerator is not supported.`);\r\n }\r\n if (change.difference.offset !== undefined) {\r\n throw new Error(`Changing the unit '${change.itemName}' offset is not supported.`);\r\n }\r\n\r\n if (change.difference.label !== undefined) {\r\n await context.editor.units.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if (change.difference.description !== undefined) {\r\n await context.editor.units.setDescription(itemKey, change.difference.description);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSystemMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitSystemMerger.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACxE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;KAClC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrF,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { UnitSystemDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new UnitSystem into the target schema.\n * @internal\n */\nexport async function addUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference) {\n await context.editor.unitSystems.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n });\n}\n\n/**\n * Merges differences to an existing UnitSystem in the target schema.\n * @internal\n */\nexport async function modifyUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference, itemKey: SchemaItemKey) {\n if(change.difference.label !== undefined) {\n await context.editor.unitSystems.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.unitSystems.setDescription(itemKey, change.difference.description);\n }\n}\n"]}
1
+ {"version":3,"file":"UnitSystemMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitSystemMerger.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACxE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;KAClC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrF,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC;AACH,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\nimport type { UnitSystemDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new UnitSystem into the target schema.\r\n * @internal\r\n */\r\nexport async function addUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference) {\r\n await context.editor.unitSystems.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing UnitSystem in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference, itemKey: SchemaItemKey) {\r\n if(change.difference.label !== undefined) {\r\n await context.editor.unitSystems.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.unitSystems.setDescription(itemKey, change.difference.description);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mapp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AU,cAAc,CAAC,OAA2B,EAAE,OAAgC;IAChG,MAAM,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;QAC/C,CAAC,CAAC,OAAO,CAAC,cAAc;QACxB,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC;IAEzF,QAAO,cAAc,EAAE,CAAC;QACtB,KAAK,cAAc,CAAC,WAAW;YAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjC,KAAK,cAAc,CAAC,KAAK;YACvB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAC/B,KAAK,cAAc,CAAC,WAAW;YAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,KAAK,cAAc,CAAC,oBAAoB;YACtC,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACzC,KAAK,cAAc,CAAC,iBAAiB;YACnC,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;QACtC;YACE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { ECClasses } from \"../Editing/ECClasses\";\nimport { PropertyKey } from \"./Edits/NameMapping\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECClass, ECSchemaError, ECSchemaStatus, SchemaContext, SchemaItem, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Resolves a SchemaItemKey for the given item name.\n * @internal\n */\nexport function toItemKey(context: SchemaMergeContext, itemName: string): SchemaItemKey {\n const classKey = context.nameMapping.resolveItemKey(new SchemaItemKey(itemName, context.sourceSchemaKey));\n return new SchemaItemKey(classKey.name, context.targetSchemaKey);\n}\n\n/**\n * Resolves a SchemaItemKey for the given class property name.\n * @internal\n */\nexport function toPropertyKey(context: SchemaMergeContext, itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, context.sourceSchemaKey);\n return context.nameMapping.resolvePropertyKey(new PropertyKey(propertyName, classKey));\n}\n\n/**\n * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.\n * @internal\n */\nexport async function updateSchemaItemFullName(context: SchemaMergeContext, reference: string) {\n const schemaItemKey = await updateSchemaItemKey(context, reference);\n return schemaItemKey.fullName;\n}\n\n/**\n * Updates the given reference if it refers to a SchemaItem in the source Schema and\n * returns a SchemaItemKey. If any other schema is referred the reference is not change.\n * @internal\n */\nexport async function updateSchemaItemKey(context: SchemaMergeContext, reference: string) {\n const [schemaName, itemName] = SchemaItem.parseFullName(reference);\n if (context.sourceSchemaKey.compareByName(schemaName)) {\n const schemaItemKey = toItemKey(context, itemName);\n return resolveSchemaItemKey(context.editor.schemaContext, schemaItemKey);\n }\n\n const referencedSchema = await context.targetSchema.getReference(schemaName);\n if (referencedSchema !== undefined) {\n return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, referencedSchema.schemaKey));\n }\n\n throw new Error(`Cannot locate referenced schema item ${reference}`);\n}\n\n/**\n * To support case insensitivity for schema items, the given key is checked if there\n * exists an item for it.\n * @internal\n */\nasync function resolveSchemaItemKey(schemaContext: SchemaContext, itemKey: SchemaItemKey): Promise<SchemaItemKey> {\n const item = await schemaContext.getSchemaItem(itemKey);\n if (item === undefined) {\n // If the schema item hasn't been created yet, we have to trust the given key is correctly spelled.\n return itemKey;\n }\n return item.key;\n}\n\n/**\n * @internal\n */\nexport async function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string) {\n const schemaItemKey = toItemKey(context, itemName);\n const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);\n if (schemaItem === undefined) {\n throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `${schemaType} ${schemaItemKey.fullName} not found in schema context.`);\n }\n\n return schemaItem;\n}\n\n/**\n * @internal\n */\nexport async function getClassEditor(context: SchemaMergeContext, ecClass: ECClass | SchemaItemKey): Promise<ECClasses> {\n const schemaItemType = ECClass.isECClass(ecClass)\n ? ecClass.schemaItemType\n : (await context.editor.schemaContext.getSchemaItem(ecClass, ECClass))?.schemaItemType;\n\n switch(schemaItemType) {\n case SchemaItemType.EntityClass:\n return context.editor.entities;\n case SchemaItemType.Mixin:\n return context.editor.mixins;\n case SchemaItemType.StructClass:\n return context.editor.structs;\n case SchemaItemType.CustomAttributeClass:\n return context.editor.customAttributes;\n case SchemaItemType.RelationshipClass:\n return context.editor.relationships;\n default:\n throw new Error(\"SchemaItemType not supported\");\n }\n}\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAiB,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE5I;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,OAA2B,EAAE,QAAgB;IACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAC1G,OAAO,IAAI,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,OAA2B,EAAE,QAAgB,EAAE,YAAoB;IAC/F,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACtE,OAAO,OAAO,CA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iB;YACnC,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;QACtC;YACE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;AACH,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\nimport { ECClasses } from \"../Editing/ECClasses\";\r\nimport { PropertyKey } from \"./Edits/NameMapping\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { ECClass, ECSchemaError, ECSchemaStatus, SchemaContext, SchemaItem, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Resolves a SchemaItemKey for the given item name.\r\n * @internal\r\n */\r\nexport function toItemKey(context: SchemaMergeContext, itemName: string): SchemaItemKey {\r\n const classKey = context.nameMapping.resolveItemKey(new SchemaItemKey(itemName, context.sourceSchemaKey));\r\n return new SchemaItemKey(classKey.name, context.targetSchemaKey);\r\n}\r\n\r\n/**\r\n * Resolves a SchemaItemKey for the given class property name.\r\n * @internal\r\n */\r\nexport function toPropertyKey(context: SchemaMergeContext, itemName: string, propertyName: string): PropertyKey {\r\n const classKey = new SchemaItemKey(itemName, context.sourceSchemaKey);\r\n return context.nameMapping.resolvePropertyKey(new PropertyKey(propertyName, classKey));\r\n}\r\n\r\n/**\r\n * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.\r\n * @internal\r\n */\r\nexport async function updateSchemaItemFullName(context: SchemaMergeContext, reference: string) {\r\n const schemaItemKey = await updateSchemaItemKey(context, reference);\r\n return schemaItemKey.fullName;\r\n}\r\n\r\n/**\r\n * Updates the given reference if it refers to a SchemaItem in the source Schema and\r\n * returns a SchemaItemKey. If any other schema is referred the reference is not change.\r\n * @internal\r\n */\r\nexport async function updateSchemaItemKey(context: SchemaMergeContext, reference: string) {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(reference);\r\n if (context.sourceSchemaKey.compareByName(schemaName)) {\r\n const schemaItemKey = toItemKey(context, itemName);\r\n return resolveSchemaItemKey(context.editor.schemaContext, schemaItemKey);\r\n }\r\n\r\n const referencedSchema = await context.targetSchema.getReference(schemaName);\r\n if (referencedSchema !== undefined) {\r\n return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, referencedSchema.schemaKey));\r\n }\r\n\r\n throw new Error(`Cannot locate referenced schema item ${reference}`);\r\n}\r\n\r\n/**\r\n * To support case insensitivity for schema items, the given key is checked if there\r\n * exists an item for it.\r\n * @internal\r\n */\r\nasync function resolveSchemaItemKey(schemaContext: SchemaContext, itemKey: SchemaItemKey): Promise<SchemaItemKey> {\r\n const item = await schemaContext.getSchemaItem(itemKey);\r\n if (item === undefined) {\r\n // If the schema item hasn't been created yet, we have to trust the given key is correctly spelled.\r\n return itemKey;\r\n }\r\n return item.key;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string) {\r\n const schemaItemKey = toItemKey(context, itemName);\r\n const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);\r\n if (schemaItem === undefined) {\r\n throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `${schemaType} ${schemaItemKey.fullName} not found in schema context.`);\r\n }\r\n\r\n return schemaItem;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function getClassEditor(context: SchemaMergeContext, ecClass: ECClass | SchemaItemKey): Promise<ECClasses> {\r\n const schemaItemType = ECClass.isECClass(ecClass)\r\n ? ecClass.schemaItemType\r\n : (await context.editor.schemaContext.getSchemaItem(ecClass, ECClass))?.schemaItemType;\r\n\r\n switch(schemaItemType) {\r\n case SchemaItemType.EntityClass:\r\n return context.editor.entities;\r\n case SchemaItemType.Mixin:\r\n return context.editor.mixins;\r\n case SchemaItemType.StructClass:\r\n return context.editor.structs;\r\n case SchemaItemType.CustomAttributeClass:\r\n return context.editor.customAttributes;\r\n case SchemaItemType.RelationshipClass:\r\n return context.editor.relationships;\r\n default:\r\n throw new Error(\"SchemaItemType not supported\");\r\n }\r\n}\r\n"]}