@itwin/ecschema-editing 5.0.0-dev.8 → 5.0.0-dev.82

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 (196) hide show
  1. package/CHANGELOG.md +46 -1
  2. package/lib/cjs/Differencing/Errors.js +6 -0
  3. package/lib/cjs/Differencing/Errors.js.map +1 -1
  4. package/lib/cjs/Differencing/SchemaConflicts.d.ts +3 -1
  5. package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
  6. package/lib/cjs/Differencing/SchemaConflicts.js +2 -0
  7. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  8. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +4 -3
  9. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
  10. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +57 -11
  11. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  12. package/lib/cjs/Differencing/SchemaDifference.d.ts +33 -4
  13. package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
  14. package/lib/cjs/Differencing/SchemaDifference.js +55 -5
  15. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  16. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts +2 -1
  17. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
  18. package/lib/cjs/Differencing/SchemaDifferenceValidator.js +78 -19
  19. package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
  20. package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts.map +1 -1
  21. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js +5 -0
  22. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
  23. package/lib/cjs/Editing/Constants.d.ts +2 -1
  24. package/lib/cjs/Editing/Constants.d.ts.map +1 -1
  25. package/lib/cjs/Editing/Constants.js +4 -1
  26. package/lib/cjs/Editing/Constants.js.map +1 -1
  27. package/lib/cjs/Editing/CustomAttributes.d.ts +2 -1
  28. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  29. package/lib/cjs/Editing/CustomAttributes.js +3 -0
  30. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  31. package/lib/cjs/Editing/ECClasses.d.ts +6 -0
  32. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  33. package/lib/cjs/Editing/ECClasses.js +48 -35
  34. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  35. package/lib/cjs/Editing/Editor.d.ts +2 -2
  36. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  37. package/lib/cjs/Editing/Editor.js +32 -21
  38. package/lib/cjs/Editing/Editor.js.map +1 -1
  39. package/lib/cjs/Editing/Entities.d.ts +2 -1
  40. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  41. package/lib/cjs/Editing/Entities.js +18 -14
  42. package/lib/cjs/Editing/Entities.js.map +1 -1
  43. package/lib/cjs/Editing/Enumerations.d.ts +2 -1
  44. package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
  45. package/lib/cjs/Editing/Enumerations.js +6 -3
  46. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  47. package/lib/cjs/Editing/Exception.js +35 -6
  48. package/lib/cjs/Editing/Exception.js.map +1 -1
  49. package/lib/cjs/Editing/Formats.d.ts +2 -1
  50. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  51. package/lib/cjs/Editing/Formats.js +5 -1
  52. package/lib/cjs/Editing/Formats.js.map +1 -1
  53. package/lib/cjs/Editing/InvertedUnits.d.ts +2 -1
  54. package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
  55. package/lib/cjs/Editing/InvertedUnits.js +10 -6
  56. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  57. package/lib/cjs/Editing/KindOfQuantities.d.ts +2 -1
  58. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  59. package/lib/cjs/Editing/KindOfQuantities.js +11 -7
  60. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  61. package/lib/cjs/Editing/Mixins.d.ts +2 -1
  62. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  63. package/lib/cjs/Editing/Mixins.js +13 -9
  64. package/lib/cjs/Editing/Mixins.js.map +1 -1
  65. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +2 -1
  66. package/lib/cjs/Editing/Mutable/MutableClass.d.ts.map +1 -1
  67. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  68. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +8 -1
  69. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts.map +1 -1
  70. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  71. package/lib/cjs/Editing/Phenomena.d.ts +2 -1
  72. package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
  73. package/lib/cjs/Editing/Phenomena.js +3 -0
  74. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  75. package/lib/cjs/Editing/Properties.d.ts +2 -2
  76. package/lib/cjs/Editing/Properties.d.ts.map +1 -1
  77. package/lib/cjs/Editing/Properties.js +6 -4
  78. package/lib/cjs/Editing/Properties.js.map +1 -1
  79. package/lib/cjs/Editing/PropertyCategories.d.ts +2 -1
  80. package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
  81. package/lib/cjs/Editing/PropertyCategories.js +5 -1
  82. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  83. package/lib/cjs/Editing/RelationshipClasses.d.ts +1 -0
  84. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  85. package/lib/cjs/Editing/RelationshipClasses.js +17 -10
  86. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  87. package/lib/cjs/Editing/SchemaItems.d.ts +2 -2
  88. package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
  89. package/lib/cjs/Editing/SchemaItems.js +8 -11
  90. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  91. package/lib/cjs/Editing/Structs.d.ts +2 -1
  92. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  93. package/lib/cjs/Editing/Structs.js +3 -0
  94. package/lib/cjs/Editing/Structs.js.map +1 -1
  95. package/lib/cjs/Editing/UnitSystems.d.ts +2 -1
  96. package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
  97. package/lib/cjs/Editing/UnitSystems.js +3 -0
  98. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  99. package/lib/cjs/Editing/Units.d.ts +2 -1
  100. package/lib/cjs/Editing/Units.d.ts.map +1 -1
  101. package/lib/cjs/Editing/Units.js +5 -2
  102. package/lib/cjs/Editing/Units.js.map +1 -1
  103. package/lib/cjs/Merging/ConstantMerger.js +4 -4
  104. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  105. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  106. package/lib/cjs/Merging/CustomAttributeMerger.js +7 -6
  107. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  108. package/lib/cjs/Merging/Edits/NameMapping.d.ts +22 -0
  109. package/lib/cjs/Merging/Edits/NameMapping.d.ts.map +1 -0
  110. package/lib/cjs/Merging/Edits/NameMapping.js +54 -0
  111. package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -0
  112. package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts +1 -1
  113. package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -1
  114. package/lib/cjs/Merging/Edits/RenameEditHandler.js +1 -260
  115. package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
  116. package/lib/cjs/Merging/Edits/SchemaEdits.d.ts +9 -6
  117. package/lib/cjs/Merging/Edits/SchemaEdits.d.ts.map +1 -1
  118. package/lib/cjs/Merging/Edits/SchemaEdits.js +19 -14
  119. package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
  120. package/lib/cjs/Merging/EntityClassMerger.js +1 -2
  121. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  122. package/lib/cjs/Merging/EnumerationMerger.js +1 -1
  123. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  124. package/lib/cjs/Merging/EnumeratorMerger.d.ts.map +1 -1
  125. package/lib/cjs/Merging/EnumeratorMerger.js +2 -2
  126. package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
  127. package/lib/cjs/Merging/FormatMerger.d.ts +24 -0
  128. package/lib/cjs/Merging/FormatMerger.d.ts.map +1 -0
  129. package/lib/cjs/Merging/FormatMerger.js +143 -0
  130. package/lib/cjs/Merging/FormatMerger.js.map +1 -0
  131. package/lib/cjs/Merging/InvertedUnitMerger.d.ts +14 -0
  132. package/lib/cjs/Merging/InvertedUnitMerger.d.ts.map +1 -0
  133. package/lib/cjs/Merging/InvertedUnitMerger.js +45 -0
  134. package/lib/cjs/Merging/InvertedUnitMerger.js.map +1 -0
  135. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +1 -1
  136. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  137. package/lib/cjs/Merging/KindOfQuantityMerger.js +4 -5
  138. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  139. package/lib/cjs/Merging/MixinMerger.js +1 -1
  140. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  141. package/lib/cjs/Merging/PhenomenonMerger.js +1 -1
  142. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  143. package/lib/cjs/Merging/PropertyMerger.js +28 -26
  144. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  145. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
  146. package/lib/cjs/Merging/RelationshipClassMerger.js +4 -4
  147. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  148. package/lib/cjs/Merging/SchemaMerger.d.ts +5 -3
  149. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  150. package/lib/cjs/Merging/SchemaMerger.js +40 -5
  151. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  152. package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +14 -8
  153. package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
  154. package/lib/cjs/Merging/SchemaMergingVisitor.js +42 -17
  155. package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
  156. package/lib/cjs/Merging/SchemaMergingWalker.d.ts.map +1 -1
  157. package/lib/cjs/Merging/SchemaMergingWalker.js +2 -0
  158. package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
  159. package/lib/cjs/Merging/UnitMerger.d.ts +14 -0
  160. package/lib/cjs/Merging/UnitMerger.d.ts.map +1 -0
  161. package/lib/cjs/Merging/UnitMerger.js +62 -0
  162. package/lib/cjs/Merging/UnitMerger.js.map +1 -0
  163. package/lib/cjs/Merging/Utils.d.ts +11 -0
  164. package/lib/cjs/Merging/Utils.d.ts.map +1 -1
  165. package/lib/cjs/Merging/Utils.js +23 -3
  166. package/lib/cjs/Merging/Utils.js.map +1 -1
  167. package/lib/cjs/Validation/Diagnostic.js +18 -16
  168. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  169. package/lib/cjs/Validation/DiagnosticReporter.js +3 -0
  170. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  171. package/lib/cjs/Validation/ECRules.js +1 -1
  172. package/lib/cjs/Validation/ECRules.js.map +1 -1
  173. package/lib/cjs/Validation/SchemaChanges.js +39 -69
  174. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  175. package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +2 -2
  176. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  177. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +1 -1
  178. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts.map +1 -1
  179. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +4 -1
  180. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  181. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts.map +1 -1
  182. package/lib/cjs/Validation/SchemaCompareVisitor.js +23 -23
  183. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  184. package/lib/cjs/Validation/SchemaComparer.d.ts +22 -1
  185. package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
  186. package/lib/cjs/Validation/SchemaComparer.js +30 -5
  187. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  188. package/lib/cjs/Validation/SchemaValidater.js +1 -4
  189. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  190. package/lib/cjs/Validation/SchemaValidationVisitor.js +3 -4
  191. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  192. package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
  193. package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
  194. package/lib/cjs/Validation/SchemaWalker.js +4 -0
  195. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  196. package/package.json +16 -16
@@ -1,4 +1,4 @@
1
- import { AnySchemaDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from "../Differencing/SchemaDifference";
1
+ import { AnySchemaDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from "../Differencing/SchemaDifference";
2
2
  import { SchemaDifferenceVisitor } from "../Differencing/SchemaDifferenceVisitor";
3
3
  import { SchemaMergeContext } from "./SchemaMerger";
4
4
  /**
@@ -12,10 +12,6 @@ export declare class SchemaMergingVisitor implements SchemaDifferenceVisitor {
12
12
  * Initializes a new instance of SchemaMergingVisitor class.
13
13
  */
14
14
  constructor(context: SchemaMergeContext);
15
- /**
16
- * Gets a SchemaItemKey for the given item name.
17
- */
18
- private toItemKey;
19
15
  /**
20
16
  * Shared merging logic for all types of ClassItemDifference union.
21
17
  */
@@ -59,12 +55,22 @@ export declare class SchemaMergingVisitor implements SchemaDifferenceVisitor {
59
55
  * Visitor implementation for handling FormatDifference.
60
56
  * @internal
61
57
  */
62
- visitFormatDifference(_entry: FormatDifference): Promise<void>;
58
+ visitFormatDifference(entry: FormatDifference): Promise<void>;
59
+ /**
60
+ * Visitor implementation for handling FormatUnitDifference.
61
+ * @internal
62
+ */
63
+ visitFormatUnitDifference(entry: FormatUnitDifference): Promise<void>;
64
+ /**
65
+ * Visitor implementation for handling FormatUnitLabelDifference.
66
+ * @internal
67
+ */
68
+ visitFormatUnitLabelDifference(entry: FormatUnitLabelDifference): Promise<void>;
63
69
  /**
64
70
  * Visitor implementation for handling InvertedUnitDifference.
65
71
  * @internal
66
72
  */
67
- visitInvertedUnitDifference(_entry: InvertedUnitDifference): Promise<void>;
73
+ visitInvertedUnitDifference(entry: InvertedUnitDifference): Promise<void>;
68
74
  /**
69
75
  * Visitor implementation for handling KindOfQuantityDifference.
70
76
  * @internal
@@ -128,7 +134,7 @@ export declare class SchemaMergingVisitor implements SchemaDifferenceVisitor {
128
134
  * Visitor implementation for handling UnitDifference.
129
135
  * @internal
130
136
  */
131
- visitUnitDifference(_entry: UnitDifference): Promise<void>;
137
+ visitUnitDifference(entry: UnitDifference): Promise<void>;
132
138
  /**
133
139
  * Visitor implementation for handling UnitSystemDifference.
134
140
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMergingVisitor.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":"AAIA,OAAO,EAA0B,mBAAmB,EAA2B,uBAAuB,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,0CAA0C,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,qCAAqC,EAAE,gCAAgC,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAiBxsB,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAQpD;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,uBAAuB;IAElE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAE9C;;OAEG;gBACS,OAAO,EAAE,kBAAkB;IAIvC;;OAEG;IACH,OAAO,CAAC,SAAS;IAIjB;;OAEG;YACW,oBAAoB;IAmClC;;;OAGG;IACU,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9E;;;OAGG;IACU,mCAAmC,CAAC,KAAK,EAAE,8BAA8B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnJ;;;OAGG;IACU,sCAAsC,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAA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,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjI;;;OAGG;IACU,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtE;;;OAGG;IACU,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlF;;;MAGE;IACW,+CAA+C,CAAC,KAAK,EAAE,0CAA0C,GAAG,OAAO,CAAC,IAAI,CAAC;CAK/H"}
@@ -17,25 +17,23 @@ const StructClassMerger_1 = require("./StructClassMerger");
17
17
  const UnitSystemMerger_1 = require("./UnitSystemMerger");
18
18
  const PropertyMerger_1 = require("./PropertyMerger");
19
19
  const Utils_1 = require("../Differencing/Utils");
20
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
20
+ const Utils_2 = require("./Utils");
21
+ const UnitMerger_1 = require("./UnitMerger");
22
+ const InvertedUnitMerger_1 = require("./InvertedUnitMerger");
23
+ const FormatMerger_1 = require("./FormatMerger");
21
24
  /**
22
25
  * Implementation of ISchemaDifferenceVisitor that can be used to traverse schema
23
26
  * differences to call the appropriated merger methods.
24
27
  * @internal
25
28
  */
26
29
  class SchemaMergingVisitor {
30
+ _context;
27
31
  /**
28
32
  * Initializes a new instance of SchemaMergingVisitor class.
29
33
  */
30
34
  constructor(context) {
31
35
  this._context = context;
32
36
  }
33
- /**
34
- * Gets a SchemaItemKey for the given item name.
35
- */
36
- toItemKey(itemName) {
37
- return new ecschema_metadata_1.SchemaItemKey(itemName, this._context.targetSchemaKey);
38
- }
39
37
  /**
40
38
  * Shared merging logic for all types of ClassItemDifference union.
41
39
  */
@@ -65,7 +63,7 @@ class SchemaMergingVisitor {
65
63
  }
66
64
  // Now both a modification change or the second add iteration is a modification of an existing class.
67
65
  // So, regardless of the actual change type, modify is called.
68
- return handler.modify(this._context, entry, this.toItemKey(entry.itemName));
66
+ return handler.modify(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
69
67
  },
70
68
  modify: handler.modify,
71
69
  });
@@ -135,22 +133,46 @@ class SchemaMergingVisitor {
135
133
  async visitEnumeratorDifference(entry) {
136
134
  switch (entry.changeType) {
137
135
  case "add": return (0, EnumeratorMerger_1.addEnumerator)(this._context, entry);
138
- case "modify": return (0, EnumeratorMerger_1.modifyEnumerator)(this._context, entry, this.toItemKey(entry.itemName));
136
+ case "modify": return (0, EnumeratorMerger_1.modifyEnumerator)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
139
137
  }
140
138
  }
141
139
  /**
142
140
  * Visitor implementation for handling FormatDifference.
143
141
  * @internal
144
142
  */
145
- async visitFormatDifference(_entry) {
146
- // TODO: Add merger handler...
143
+ async visitFormatDifference(entry) {
144
+ return this.visitSchemaItemDifference(entry, {
145
+ add: FormatMerger_1.addFormat,
146
+ modify: FormatMerger_1.modifyFormat,
147
+ });
148
+ }
149
+ /**
150
+ * Visitor implementation for handling FormatUnitDifference.
151
+ * @internal
152
+ */
153
+ async visitFormatUnitDifference(entry) {
154
+ switch (entry.changeType) {
155
+ case "modify": return (0, FormatMerger_1.modifyFormatUnit)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
156
+ }
157
+ }
158
+ /**
159
+ * Visitor implementation for handling FormatUnitLabelDifference.
160
+ * @internal
161
+ */
162
+ async visitFormatUnitLabelDifference(entry) {
163
+ switch (entry.changeType) {
164
+ case "modify": return (0, FormatMerger_1.modifyFormatUnitLabel)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
165
+ }
147
166
  }
148
167
  /**
149
168
  * Visitor implementation for handling InvertedUnitDifference.
150
169
  * @internal
151
170
  */
152
- async visitInvertedUnitDifference(_entry) {
153
- // TODO: Add merger handler...
171
+ async visitInvertedUnitDifference(entry) {
172
+ return this.visitSchemaItemDifference(entry, {
173
+ add: InvertedUnitMerger_1.addInvertedUnit,
174
+ modify: InvertedUnitMerger_1.modifyInvertedUnit,
175
+ });
154
176
  }
155
177
  /**
156
178
  * Visitor implementation for handling KindOfQuantityDifference.
@@ -248,7 +270,7 @@ class SchemaMergingVisitor {
248
270
  if ("schemaItemType" in entry.difference && entry.difference.schemaItemType !== entry.schemaType) {
249
271
  throw new Error(`Changing the type of item '${entry.itemName}' not supported.`);
250
272
  }
251
- return handler.modify(this._context, entry, this.toItemKey(entry.itemName));
273
+ return handler.modify(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
252
274
  }
253
275
  ;
254
276
  }
@@ -277,8 +299,11 @@ class SchemaMergingVisitor {
277
299
  * Visitor implementation for handling UnitDifference.
278
300
  * @internal
279
301
  */
280
- async visitUnitDifference(_entry) {
281
- // TODO: Add merger handler...
302
+ async visitUnitDifference(entry) {
303
+ return this.visitSchemaItemDifference(entry, {
304
+ add: UnitMerger_1.addUnit,
305
+ modify: UnitMerger_1.modifyUnit,
306
+ });
282
307
  }
283
308
  /**
284
309
  * Visitor implementation for handling UnitSystemDifference.
@@ -296,7 +321,7 @@ class SchemaMergingVisitor {
296
321
  */
297
322
  async visitKindOfQuantityPresentationFormatDifference(entry) {
298
323
  switch (entry.changeType) {
299
- case "add": return (0, KindOfQuantityMerger_1.addPresentationFormat)(this._context, entry);
324
+ case "add": return (0, KindOfQuantityMerger_1.addPresentationFormat)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
300
325
  }
301
326
  }
302
327
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":";;;AAKA,qDAA+D;AAC/D,mEAA6D;AAC7D,6EAAmG;AACnG,2DAAwF;AACxF,2DAAwE;AACxE,yDAAqE;AACrE,iEAAwG;AACxG,+CAAgE;AAChE,yDAAqE;AACrE,qEAAuF;AACvF,uEAAyJ;AACzJ,mEAAsF;AACtF,2DAAwE;AACxE,yDAAqE;AACrE,qDAA2D;AAC3D,iDAA0D;AAE1D,gEAAyD;AASzD;;;;GAIG;AACH,MA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AA0B,CAAC,KAA4B,EAAE,KAAa,EAAE,KAA4B;QAC/G,OAAO,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;YACpD,GAAG,EAAE,kCAAc;YACnB,MAAM,EAAE,qCAAiB;SAC1B,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,mBAAmB,CAAC,MAAsB;QACrD,8BAA8B;IAChC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,yBAAyB,CAAC,KAA2B;QAChE,OAAO,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE;YAC3C,GAAG,EAAE,gCAAa;YAClB,MAAM,EAAE,mCAAgB;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,IAAA,4CAAqB,EAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;CACF;AAnTD,oDAmTC;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, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, 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\";\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 * Gets a SchemaItemKey for the given item name.\n */\n private toItemKey(itemName: string): SchemaItemKey {\n return new SchemaItemKey(itemName, this._context.targetSchemaKey);\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, this.toItemKey(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, this.toItemKey(entry.itemName));\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(_entry: FormatDifference): Promise<void> {\n // TODO: Add merger handler...\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(_entry: InvertedUnitDifference): Promise<void> {\n // TODO: Add merger handler...\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, this.toItemKey(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 // TODO: Add merger handler...\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);\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,qDAA+D;AAC/D,mEAA6D;AAC7D,6EAAmG;AACnG,2DAAwF;AACxF,2DAAwE;AACxE,yDAAqE;AACrE,iEAAwG;AACxG,+CAAgE;AAChE,yDAAqE;AACrE,qEAAuF;AACvF,uEAAyJ;AACzJ,mEAAsF;AACtF,2DAAwE;AACxE,yDAAqE;AACrE,qDAA2D;AAC3D,iDAA0D;AAI1D,mCAAoC;AACpC,6CAAmD;AACnD,6DAA2E;AAC3E,iDAAkG;AAQlG;;;;GAIG;AACH,MAAa,oBAAoB;IAEd,QAAQ,CAAqB;IAE9C;;OAEG;IACH,YAAY,OAA2B;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,oBAAoB,CAAmC,KAAQ,EAAE,KAAa,EAAE,KAA4B,EAAE,OAAiC;QAC3J,OAAO,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE;YAC3C,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBACrB,iGAAiG;gBACjG,mGAAmG;gBACnG,+DAA+D;gBAC/D,IAAG,KAAK,CAAC,UAAU,KAAK,KAAK,IAAI,CAAC,MAAM,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACrF,MAAM,OAAO,CAAC,G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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 +1 @@
1
- {"version":3,"file":"SchemaMergingWalker.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAgC,MAAM,kCAAkC,CAAC;AAErH;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,sBAAsB;IAE7D;;;;;;;OAOG;IACmB,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,mBAAmB,CAAC,EAAE,UAAU,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAyCpH"}
1
+ {"version":3,"file":"SchemaMergingWalker.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAgC,MAAM,kCAAkC,CAAC;AAErH;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,sBAAsB;IAE7D;;;;;;;OAOG;IACmB,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,mBAAmB,CAAC,EAAE,UAAU,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA2CpH"}
@@ -41,6 +41,8 @@ class SchemaMergingWalker extends SchemaDifferenceVisitor_1.SchemaDifferenceWalk
41
41
  ...differences.filter(filterByType(ecschema_metadata_1.SchemaItemType.Unit)),
42
42
  ...differences.filter(filterByType(ecschema_metadata_1.SchemaItemType.InvertedUnit)),
43
43
  ...differences.filter(filterByType(ecschema_metadata_1.SchemaItemType.Format)),
44
+ ...differences.filter(filterByType(SchemaDifference_1.SchemaOtherTypes.FormatUnit)),
45
+ ...differences.filter(filterByType(SchemaDifference_1.SchemaOtherTypes.FormatUnitLabel)),
44
46
  ...differences.filter(filterByType(ecschema_metadata_1.SchemaItemType.KindOfQuantity)),
45
47
  ...differences.filter(filterByType(ecschema_metadata_1.SchemaItemType.Constant)),
46
48
  ...differences.filter(filterByType(SchemaDifference_1.SchemaOtherTypes.KindOfQuantityPresentationFormat)),
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMergingWalker.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA0D;AAC1D,qFAAiF;AACjF,uEAAqH;AAErH;;;;GAIG;AACH,MAAa,mBAAoB,SAAQ,gDAAsB;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,mCAAgB,CAAC,MAAM,CAAC,CAAC;YAC5D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,eAAe,CAAC,CAAC;YAErE,+CAA+C;YAC/C,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,UAAU,CAAC,CAAC;YAC9D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,gBAAgB,CAAC,CAAC;YACpE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,WAAW,CAAC,CAAC;YAC/D,GAAG,WAAW,CAAC,MAAM,CAA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C,YAAY,CAAC,mCAAgB,CAAC,2BAA2B,CAAC,CAAC;YACjF,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,QAAQ,CAAC,CAAC;YAE9D,kCAAkC;YAClC,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,uBAAuB,CAAC,CAAC;SAC9E,CAAC,CAAC;IACL,CAAC;CACF;AAnDD,kDAmDC","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(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,gEAA0D;AAC1D,qFAAiF;AACjF,uEAAqH;AAErH;;;;GAIG;AACH,MAAa,mBAAoB,SAAQ,gDAAsB;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;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CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,gCAAgC,CAAC,CAAC;YAEtF,uDAAuD;YACvD,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,oBAAoB,CAAC,CAAC;YACxE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,KAAK,CAAC,CAAC;YACzD,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,WAAW,CAAC,CAAC;YAC/D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,WAAW,CAAC,CAAC;YAC/D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,iBAAiB,CAAC,CAAC;YACrE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,gBAAgB,CAAC,CAAC;YACtE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,sBAAsB,CAAC,CAAC;YAC5E,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,2BAA2B,CAAC,CAAC;YACjF,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,QAAQ,CAAC,CAAC;YAE9D,kCAAkC;YAClC,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,uBAAuB,CAAC,CAAC;SAC9E,CAAC,CAAC;IACL,CAAC;CACF;AArDD,kDAqDC","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"]}
@@ -0,0 +1,14 @@
1
+ import { SchemaItemKey } from "@itwin/ecschema-metadata";
2
+ import { UnitDifference } from "../Differencing/SchemaDifference";
3
+ import { SchemaMergeContext } from "./SchemaMerger";
4
+ /**
5
+ * Merges a new Unit into the target schema.
6
+ * @internal
7
+ */
8
+ export declare function addUnit(context: SchemaMergeContext, change: UnitDifference): Promise<void>;
9
+ /**
10
+ * Merges differences to an existing Unit in the target schema.
11
+ * @internal
12
+ */
13
+ export declare function modifyUnit(context: SchemaMergeContext, change: UnitDifference, itemKey: SchemaItemKey): Promise<void>;
14
+ //# sourceMappingURL=UnitMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnitMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/UnitMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;GAGG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,cAAc,iBAsBhF;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,iBA2B3G"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addUnit = addUnit;
4
+ exports.modifyUnit = modifyUnit;
5
+ const Utils_1 = require("./Utils");
6
+ /**
7
+ * Merges a new Unit into the target schema.
8
+ * @internal
9
+ */
10
+ async function addUnit(context, change) {
11
+ if (change.difference.phenomenon === undefined) {
12
+ throw new Error("Unit must define phenomenon");
13
+ }
14
+ if (change.difference.unitSystem === undefined) {
15
+ throw new Error("Unit must define unitSystem");
16
+ }
17
+ if (change.difference.definition === undefined) {
18
+ throw new Error("Unit must define definition");
19
+ }
20
+ change.difference.phenomenon = await (0, Utils_1.updateSchemaItemFullName)(context, change.difference.phenomenon);
21
+ change.difference.unitSystem = await (0, Utils_1.updateSchemaItemFullName)(context, change.difference.unitSystem);
22
+ await context.editor.units.createFromProps(context.targetSchemaKey, {
23
+ ...change.difference,
24
+ name: change.itemName,
25
+ schemaItemType: change.schemaType,
26
+ phenomenon: change.difference.phenomenon,
27
+ unitSystem: change.difference.unitSystem,
28
+ definition: change.difference.definition,
29
+ });
30
+ }
31
+ /**
32
+ * Merges differences to an existing Unit in the target schema.
33
+ * @internal
34
+ */
35
+ async function modifyUnit(context, change, itemKey) {
36
+ if (change.difference.unitSystem !== undefined) {
37
+ throw new Error(`Changing the unit '${change.itemName}' unitSystem is not supported.`);
38
+ }
39
+ if (change.difference.phenomenon !== undefined) {
40
+ throw new Error(`Changing the unit '${change.itemName}' phenomenon is not supported.`);
41
+ }
42
+ if (change.difference.definition !== undefined) {
43
+ throw new Error(`Changing the unit '${change.itemName}' definition is not supported.`);
44
+ }
45
+ // we have consider later should we allow to change these values on merging
46
+ if (change.difference.denominator !== undefined) {
47
+ throw new Error(`Changing the unit '${change.itemName}' denominator is not supported.`);
48
+ }
49
+ if (change.difference.numerator !== undefined) {
50
+ throw new Error(`Changing the unit '${change.itemName}' numerator is not supported.`);
51
+ }
52
+ if (change.difference.offset !== undefined) {
53
+ throw new Error(`Changing the unit '${change.itemName}' offset is not supported.`);
54
+ }
55
+ if (change.difference.label !== undefined) {
56
+ await context.editor.units.setDisplayLabel(itemKey, change.difference.label);
57
+ }
58
+ if (change.difference.description !== undefined) {
59
+ await context.editor.units.setDescription(itemKey, change.difference.description);
60
+ }
61
+ }
62
+ //# sourceMappingURL=UnitMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnitMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitMerger.ts"],"names":[],"mappings":";;AAaA,0BAsBC;AAMD,gCA2BC;AA7DD,mCAAmD;AAEnD;;;GAGG;AACI,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;QAC/C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACrG,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAErG,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAClE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;QACxC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,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Ae,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,6 +1,17 @@
1
1
  import { ECClasses } from "../Editing/ECClasses";
2
+ import { PropertyKey } from "./Edits/NameMapping";
2
3
  import type { SchemaMergeContext } from "./SchemaMerger";
3
4
  import { ECClass, SchemaItem, SchemaItemKey } from "@itwin/ecschema-metadata";
5
+ /**
6
+ * Resolves a SchemaItemKey for the given item name.
7
+ * @internal
8
+ */
9
+ export declare function toItemKey(context: SchemaMergeContext, itemName: string): SchemaItemKey;
10
+ /**
11
+ * Resolves a SchemaItemKey for the given class property name.
12
+ * @internal
13
+ */
14
+ export declare function toPropertyKey(context: SchemaMergeContext, itemName: string, propertyName: string): PropertyKey;
4
15
  /**
5
16
  * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.
6
17
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAkD,UAAU,EAAE,aAAa,EAAkB,MAAM,0BAA0B,CAAC;AAE9I;;;GAGG;AACH,wBAAsB,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E,MAAM,EAAE,UAAU,EAAE,MAAM,uBAQvG;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CAmBtH"}
@@ -1,10 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toItemKey = toItemKey;
4
+ exports.toPropertyKey = toPropertyKey;
3
5
  exports.updateSchemaItemFullName = updateSchemaItemFullName;
4
6
  exports.updateSchemaItemKey = updateSchemaItemKey;
5
7
  exports.locateSchemaItem = locateSchemaItem;
6
8
  exports.getClassEditor = getClassEditor;
9
+ const NameMapping_1 = require("./Edits/NameMapping");
7
10
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
11
+ /**
12
+ * Resolves a SchemaItemKey for the given item name.
13
+ * @internal
14
+ */
15
+ function toItemKey(context, itemName) {
16
+ const classKey = context.nameMapping.resolveItemKey(new ecschema_metadata_1.SchemaItemKey(itemName, context.sourceSchemaKey));
17
+ return new ecschema_metadata_1.SchemaItemKey(classKey.name, context.targetSchemaKey);
18
+ }
19
+ /**
20
+ * Resolves a SchemaItemKey for the given class property name.
21
+ * @internal
22
+ */
23
+ function toPropertyKey(context, itemName, propertyName) {
24
+ const classKey = new ecschema_metadata_1.SchemaItemKey(itemName, context.sourceSchemaKey);
25
+ return context.nameMapping.resolvePropertyKey(new NameMapping_1.PropertyKey(propertyName, classKey));
26
+ }
8
27
  /**
9
28
  * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.
10
29
  * @internal
@@ -21,7 +40,8 @@ async function updateSchemaItemFullName(context, reference) {
21
40
  async function updateSchemaItemKey(context, reference) {
22
41
  const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(reference);
23
42
  if (context.sourceSchemaKey.compareByName(schemaName)) {
24
- return resolveSchemaItemKey(context.editor.schemaContext, new ecschema_metadata_1.SchemaItemKey(itemName, context.targetSchemaKey));
43
+ const schemaItemKey = toItemKey(context, itemName);
44
+ return resolveSchemaItemKey(context.editor.schemaContext, schemaItemKey);
25
45
  }
26
46
  const referencedSchema = await context.targetSchema.getReference(schemaName);
27
47
  if (referencedSchema !== undefined) {
@@ -46,7 +66,7 @@ async function resolveSchemaItemKey(schemaContext, itemKey) {
46
66
  * @internal
47
67
  */
48
68
  async function locateSchemaItem(context, itemName, schemaType) {
49
- const schemaItemKey = new ecschema_metadata_1.SchemaItemKey(itemName, context.targetSchemaKey);
69
+ const schemaItemKey = toItemKey(context, itemName);
50
70
  const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);
51
71
  if (schemaItem === undefined) {
52
72
  throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `${schemaType} ${schemaItemKey.fullName} not found in schema context.`);
@@ -59,7 +79,7 @@ async function locateSchemaItem(context, itemName, schemaType) {
59
79
  async function getClassEditor(context, ecClass) {
60
80
  const schemaItemType = ecschema_metadata_1.ECClass.isECClass(ecClass)
61
81
  ? ecClass.schemaItemType
62
- : (await context.editor.schemaContext.getSchemaItem(ecClass))?.schemaItemType;
82
+ : (await context.editor.schemaContext.getSchemaItem(ecClass, ecschema_metadata_1.ECClass))?.schemaItemType;
63
83
  switch (schemaItemType) {
64
84
  case ecschema_metadata_1.SchemaItemType.EntityClass:
65
85
  return context.editor.entities;
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":";;AAYA,4DAGC;AAOD,kDAYC;AAmBD,4CAQC;AAKD,wCAmBC;AA/ED,gEAA8I;AAE9I;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAAC,OAA2B,EAAE,SAAiB;IAC3F,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACpE,OAAO,aAAa,CAAC,QAAQ,CAAC;AAChC,CA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AAC,aAAa,CAAC,aAAa,CAAC,CAAC;IACnF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,GAAG,UAAU,IAAI,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;IAClI,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,OAAgC;IAChG,MAAM,cAAc,GAAG,2BAAO,CAAC,SAAS,CAAC,OAAO,CAAC;QAC/C,CAAC,CAAC,OAAO,CAAC,cAAc;QACxB,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAU,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC;IAEzF,QAAO,cAAc,EAAE,CAAC;QACtB,KAAK,kCAAc,CAAC,WAAW;YAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjC,KAAK,kCAAc,CAAC,KAAK;YACvB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAC/B,KAAK,kCAAc,CAAC,WAAW;YAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,KAAK,kCAAc,CAAC,oBAAoB;YACtC,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACzC,KAAK,kCAAc,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 type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECClass, ECObjectsError, ECObjectsStatus, SchemaContext, SchemaItem, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\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 return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, context.targetSchemaKey));\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 = new SchemaItemKey(itemName, context.targetSchemaKey);\n const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);\n if (schemaItem === undefined) {\n throw new ECObjectsError(ECObjectsStatus.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":";;AAaA,8BAGC;AAMD,sCAGC;AAMD,4DAGC;AAOD,kDAaC;AAmBD,4CAQC;AAKD,wCAmBC;AApGD,qDAAkD;AAElD,gEAA8I;AAE9I;;;GAGG;AACH,SAAgB,SAAS,CAAC,OAA2B,EAAE,QAAgB;IACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,iCAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAC1G,OAAO,IAAI,iCAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,OAA2B,EAAE,QAAgB,EAAE,YAAoB;IAC/F,MAAM,QAAQ,GAAG,IAAI,iCAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACtE,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,yBAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;AACzF,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAAC,OAA2B,EAAE,SAAiB;IAC3F,MAAM,aAAa,GAAG,MAAM,mB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AAE,QAAQ,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IACnF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,GAAG,UAAU,IAAI,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;IAClI,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,OAAgC;IAChG,MAAM,cAAc,GAAG,2BAAO,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,2BAAO,CAAC,CAAC,EAAE,cAAc,CAAC;IAEzF,QAAO,cAAc,EAAE,CAAC;QACtB,KAAK,kCAAc,CAAC,WAAW;YAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjC,KAAK,kCAAc,CAAC,KAAK;YACvB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAC/B,KAAK,kCAAc,CAAC,WAAW;YAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,KAAK,kCAAc,CAAC,oBAAoB;YACtC,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACzC,KAAK,kCAAc,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, ECObjectsError, ECObjectsStatus, 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 ECObjectsError(ECObjectsStatus.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"]}