@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
@@ -21,6 +21,7 @@ var SchemaEditType;
21
21
  SchemaEditType["Skip"] = "Skip";
22
22
  })(SchemaEditType || (exports.SchemaEditType = SchemaEditType = {}));
23
23
  class Editor {
24
+ _edits;
24
25
  constructor(edits) {
25
26
  this._edits = edits;
26
27
  }
@@ -37,32 +38,32 @@ class Editor {
37
38
  }
38
39
  }
39
40
  class PropertyEditor extends Editor {
40
- rename(schemaName, className, propertyName, newName) {
41
+ rename(ecClass, propertyName, newName) {
41
42
  this.add({
42
43
  type: SchemaEditType.RenameProperty,
43
- key: `${schemaName}.${className}.${propertyName}`,
44
+ key: `${ecClass.fullName}.${propertyName}`,
44
45
  value: newName,
45
46
  });
46
47
  }
47
- skip(schemaName, className, propertyName) {
48
+ skip(ecClass, propertyName) {
48
49
  this.add({
49
50
  type: SchemaEditType.Skip,
50
- key: `${schemaName}.${className}.${propertyName}`,
51
+ key: `${ecClass.fullName}.${propertyName}`,
51
52
  });
52
53
  }
53
54
  }
54
55
  class ItemEditor extends Editor {
55
- rename(schemaName, itemName, newName) {
56
+ rename(schemaItem, newName) {
56
57
  this.add({
57
58
  type: SchemaEditType.RenameSchemaItem,
58
- key: `${schemaName}.${itemName}`,
59
+ key: schemaItem.key.fullName,
59
60
  value: newName,
60
61
  });
61
62
  }
62
- skip(schemaName, itemName) {
63
+ skip(schemaItem) {
63
64
  this.add({
64
65
  type: SchemaEditType.Skip,
65
- key: `${schemaName}.${itemName}`,
66
+ key: schemaItem.fullName,
66
67
  });
67
68
  }
68
69
  }
@@ -72,6 +73,9 @@ class ItemEditor extends Editor {
72
73
  * @alpha
73
74
  */
74
75
  class SchemaEdits {
76
+ _edits;
77
+ properties;
78
+ items;
75
79
  /**
76
80
  * @alpha
77
81
  */
@@ -86,26 +90,27 @@ class SchemaEdits {
86
90
  /**
87
91
  * @internal
88
92
  */
89
- async applyTo(differenceResult) {
90
- const postProcessing = [];
93
+ async applyTo(differenceResult, nameMapping) {
91
94
  for (const schemaEdit of this._edits) {
92
95
  if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {
93
- (0, RenameEditHandler_1.applyRenameSchemaItemEdit)(differenceResult, schemaEdit, postProcessing.push.bind(postProcessing));
96
+ (0, RenameEditHandler_1.applyRenameSchemaItemEdit)(differenceResult, schemaEdit);
97
+ nameMapping.addItemMapping(schemaEdit.key, schemaEdit.value);
94
98
  }
95
99
  if (schemaEdit.type === SchemaEditType.RenameProperty) {
96
100
  (0, RenameEditHandler_1.applyRenamePropertyEdit)(differenceResult, schemaEdit);
101
+ nameMapping.addPropertyMapping(schemaEdit.key, schemaEdit.value);
97
102
  }
98
103
  if (schemaEdit.type === SchemaEditType.Skip) {
99
104
  (0, SkipEditHandler_1.applySkipEdit)(differenceResult, schemaEdit);
100
105
  }
101
106
  }
102
- for (const callback of postProcessing) {
103
- callback();
104
- }
105
107
  }
106
108
  toJSON() {
107
109
  return this._edits;
108
110
  }
111
+ [Symbol.iterator]() {
112
+ return this._edits[Symbol.iterator]();
113
+ }
109
114
  }
110
115
  exports.SchemaEdits = SchemaEdits;
111
116
  //# sourceMappingURL=SchemaEdits.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaEdits.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,2DAAyF;AACzF,uDAAkD;AAElD;;;GAGG;AACH,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uDAAqC,CAAA;IACrC,mDAAiC,CAAA;IACjC,+BAAa,CAAA;AACf,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAwCD,MAAe,MAAM;IAGnB,YAAY,KAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAES,GAAG,CAAC,IAAoB;QAChC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YACpD,OAAO,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;CACF;AAED,MAAM,cAAe,SAAQ,MAAM;IAE1B,MAAM,CAAC,UAAkB,EAAE,SAAiB,EAAE,YAAoB,EAAE,OAAe;QACxF,IAAI,CAAC,GAAG,CAAC;YACP,IAAI,EAAE,cAAc,CAAC,cAAc;YACnC,GAAG,EAAE,GAAG,UAAU,IAAI,SAAS,IAAI,YAAY,EAAE;YACjD,KA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,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,gBAAgB,EAAE,CAAC;gBACxD,IAAA,6CAAyB,EAAC,gBAAgB,EAAE,UAAU,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;YACpG,CAAC;YACD,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc,EAAE,CAAC;gBACtD,IAAA,2CAAuB,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;YACxD,CAAC;YACD,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAA,+BAAa,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,cAAc,EAAE,CAAC;YACtC,QAAQ,EAAE,CAAC;QACb,CAAC;IACH,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AA7CD,kCA6CC","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 type { SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\nimport { applyRenamePropertyEdit, applyRenameSchemaItemEdit } from \"./RenameEditHandler\";\nimport { applySkipEdit } from \"./SkipEditHandler\";\n\n/**\n * An enumeration that has all the schema edit names.\n * @alpha\n */\nexport enum SchemaEditType {\n RenameSchemaItem = \"RenameSchemaItem\",\n RenameProperty = \"RenameProperty\",\n Skip = \"Skip\",\n}\n\n/**\n * Schema edit entry to rename a schema item.\n * @alpha\n */\nexport interface RenameSchemaItemEdit {\n type: SchemaEditType.RenameSchemaItem;\n key: string;\n value: string;\n}\n\n/**\n * Schema edit entry to rename a property of a class.\n * @alpha\n */\nexport interface RenamePropertyEdit {\n type: SchemaEditType.RenameProperty;\n key: string;\n value: string;\n}\n\n/**\n * Schema edit entry to skip a certain schema element matching the given key.\n * @alpha\n */\nexport interface SkipEdit {\n type: SchemaEditType.Skip;\n key: string;\n}\n\n/**\n * Union for all supported edits that can be applied to a schema.\n * @alpha\n */\nexport type AnySchemaEdits =\n SkipEdit |\n RenameSchemaItemEdit |\n RenamePropertyEdit;\n\nabstract class Editor {\n private readonly _edits: Array<AnySchemaEdits>;\n\n constructor(edits: Array<AnySchemaEdits>) {\n this._edits = edits;\n }\n\n protected add(edit: AnySchemaEdits) {\n const overrideEntry = this._edits.findIndex((entry) => {\n return entry.type === edit.type && entry.key === edit.key;\n });\n\n if (overrideEntry > -1) {\n this._edits[overrideEntry] = edit;\n } else {\n this._edits.push(edit);\n }\n }\n}\n\nclass PropertyEditor extends Editor {\n\n public rename(schemaName: string, className: string, propertyName: string, newName: string) {\n this.add({\n type: SchemaEditType.RenameProperty,\n key: `${schemaName}.${className}.${propertyName}`,\n value: newName,\n });\n }\n\n public skip(schemaName: string, className: string, propertyName: string) {\n this.add({\n type: SchemaEditType.Skip,\n key: `${schemaName}.${className}.${propertyName}`,\n });\n }\n}\n\nclass ItemEditor extends Editor {\n public rename(schemaName: string, itemName: string, newName: string) {\n this.add({\n type: SchemaEditType.RenameSchemaItem,\n key: `${schemaName}.${itemName}`,\n value: newName,\n });\n }\n\n public skip(schemaName: string, itemName: string) {\n this.add({\n type: SchemaEditType.Skip,\n key: `${schemaName}.${itemName}`,\n });\n }\n}\n\n/**\n * Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class\n * is to support saving of edits and load them again if needed.\n * @alpha\n */\nexport class SchemaEdits {\n private readonly _edits: Array<AnySchemaEdits>;\n\n public readonly properties: PropertyEditor;\n public readonly items: ItemEditor;\n\n /**\n * @alpha\n */\n constructor(initialize?: ReadonlyArray<AnySchemaEdits>) {\n this._edits = [];\n\n if (initialize) {\n this._edits.push(...initialize);\n }\n\n this.items = new ItemEditor(this._edits);\n this.properties = new PropertyEditor(this._edits);\n }\n\n /**\n * @internal\n */\n public async applyTo(differenceResult: SchemaDifferenceResult): Promise<void> {\n const postProcessing: Array<() => void> = [];\n for (const schemaEdit of this._edits) {\n if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {\n applyRenameSchemaItemEdit(differenceResult, schemaEdit, postProcessing.push.bind(postProcessing));\n }\n if (schemaEdit.type === SchemaEditType.RenameProperty) {\n applyRenamePropertyEdit(differenceResult, schemaEdit);\n }\n if (schemaEdit.type === SchemaEditType.Skip) {\n applySkipEdit(differenceResult, schemaEdit);\n }\n }\n\n for (const callback of postProcessing) {\n callback();\n }\n }\n\n public toJSON(): ReadonlyArray<AnySchemaEdits> {\n return this._edits;\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaEdits.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,2DAAyF;AACzF,uDAAkD;AAElD;;;GAGG;AACH,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uDAAqC,CAAA;IACrC,mDAAiC,CAAA;IACjC,+BAAa,CAAA;AACf,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAwCD,MAAe,MAAM;IACF,MAAM,CAAwB;IAE/C,YAAY,KAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAES,GAAG,CAAC,IAAoB;QAChC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YACpD,OAAO,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,IAAI,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C;QAClC,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,gBAAwC,EAAE,WAAwB;QACrF,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACrC,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,gBAAgB,EAAE,CAAC;gBACxD,IAAA,6CAAyB,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;gBACxD,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YAC/D,CAAC;YACD,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc,EAAE,CAAC;gBACtD,IAAA,2CAAuB,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;gBACtD,WAAW,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YACnE,CAAC;YACD,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAA,+BAAa,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;IACH,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxC,CAAC;CACF;AA9CD,kCA8CC","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 type { ECClass, SchemaItem } from \"@itwin/ecschema-metadata\";\nimport type { SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\nimport { NameMapping } from \"./NameMapping\";\nimport { applyRenamePropertyEdit, applyRenameSchemaItemEdit } from \"./RenameEditHandler\";\nimport { applySkipEdit } from \"./SkipEditHandler\";\n\n/**\n * An enumeration that has all the schema edit names.\n * @alpha\n */\nexport enum SchemaEditType {\n RenameSchemaItem = \"RenameSchemaItem\",\n RenameProperty = \"RenameProperty\",\n Skip = \"Skip\",\n}\n\n/**\n * Schema edit entry to rename a schema item.\n * @alpha\n */\nexport interface RenameSchemaItemEdit {\n type: SchemaEditType.RenameSchemaItem;\n key: string;\n value: string;\n}\n\n/**\n * Schema edit entry to rename a property of a class.\n * @alpha\n */\nexport interface RenamePropertyEdit {\n type: SchemaEditType.RenameProperty;\n key: string;\n value: string;\n}\n\n/**\n * Schema edit entry to skip a certain schema element matching the given key.\n * @alpha\n */\nexport interface SkipEdit {\n type: SchemaEditType.Skip;\n key: string;\n}\n\n/**\n * Union for all supported edits that can be applied to a schema.\n * @alpha\n */\nexport type AnySchemaEdits =\n SkipEdit |\n RenameSchemaItemEdit |\n RenamePropertyEdit;\n\nabstract class Editor {\n private readonly _edits: Array<AnySchemaEdits>;\n\n constructor(edits: Array<AnySchemaEdits>) {\n this._edits = edits;\n }\n\n protected add(edit: AnySchemaEdits) {\n const overrideEntry = this._edits.findIndex((entry) => {\n return entry.type === edit.type && entry.key === edit.key;\n });\n\n if (overrideEntry > -1) {\n this._edits[overrideEntry] = edit;\n } else {\n this._edits.push(edit);\n }\n }\n}\n\nclass PropertyEditor extends Editor {\n\n public rename(ecClass: ECClass, propertyName: string, newName: string) {\n this.add({\n type: SchemaEditType.RenameProperty,\n key: `${ecClass.fullName}.${propertyName}`,\n value: newName,\n });\n }\n\n public skip(ecClass: ECClass, propertyName: string) {\n this.add({\n type: SchemaEditType.Skip,\n key: `${ecClass.fullName}.${propertyName}`,\n });\n }\n}\n\nclass ItemEditor extends Editor {\n public rename(schemaItem: SchemaItem, newName: string) {\n this.add({\n type: SchemaEditType.RenameSchemaItem,\n key: schemaItem.key.fullName,\n value: newName,\n });\n }\n\n public skip(schemaItem: SchemaItem) {\n this.add({\n type: SchemaEditType.Skip,\n key: schemaItem.fullName,\n });\n }\n}\n\n/**\n * Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class\n * is to support saving of edits and load them again if needed.\n * @alpha\n */\nexport class SchemaEdits implements Iterable<AnySchemaEdits> {\n private readonly _edits: Array<AnySchemaEdits>;\n\n public readonly properties: PropertyEditor;\n public readonly items: ItemEditor;\n\n /**\n * @alpha\n */\n constructor(initialize?: ReadonlyArray<AnySchemaEdits>) {\n this._edits = [];\n\n if (initialize) {\n this._edits.push(...initialize);\n }\n\n this.items = new ItemEditor(this._edits);\n this.properties = new PropertyEditor(this._edits);\n }\n\n /**\n * @internal\n */\n public async applyTo(differenceResult: SchemaDifferenceResult, nameMapping: NameMapping): Promise<void> {\n for (const schemaEdit of this._edits) {\n if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {\n applyRenameSchemaItemEdit(differenceResult, schemaEdit);\n nameMapping.addItemMapping(schemaEdit.key, schemaEdit.value);\n }\n if (schemaEdit.type === SchemaEditType.RenameProperty) {\n applyRenamePropertyEdit(differenceResult, schemaEdit);\n nameMapping.addPropertyMapping(schemaEdit.key, schemaEdit.value);\n }\n if (schemaEdit.type === SchemaEditType.Skip) {\n applySkipEdit(differenceResult, schemaEdit);\n }\n }\n }\n\n public toJSON(): ReadonlyArray<AnySchemaEdits> {\n return this._edits;\n }\n\n public [Symbol.iterator](): Iterator<AnySchemaEdits> {\n return this._edits[Symbol.iterator]();\n }\n}\n"]}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addEntityClass = addEntityClass;
4
4
  exports.modifyEntityClass = modifyEntityClass;
5
5
  exports.addClassMixins = addClassMixins;
6
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
7
6
  const ClassMerger_1 = require("./ClassMerger");
8
7
  const Utils_1 = require("./Utils");
9
8
  /**
@@ -38,7 +37,7 @@ async function modifyEntityClass(context, change, itemKey) {
38
37
  async function addClassMixins(context, change) {
39
38
  for (const mixinFullName of change.difference) {
40
39
  const mixinKey = await (0, Utils_1.updateSchemaItemKey)(context, mixinFullName);
41
- const entityKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
40
+ const entityKey = (0, Utils_1.toItemKey)(context, change.itemName);
42
41
  await context.editor.entities.addMixin(entityKey, mixinKey);
43
42
  }
44
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAeA,wCAOC;AAMD,8CAUC;AAMD,wCAMC;AA3CD,gEAAyD;AACzD,+CAA4C;AAC5C,mCAA8C;AAE9C;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACrE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QAEjC,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAuB,CAAC;IAClF,IAAG,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1C,KAAI,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAAkC;IAClG,KAAI,MAAM,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;QAC9E,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9D,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 { EntityClassDifference, EntityClassMixinDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableEntityClass } from \"../Editing/Mutable/MutableEntityClass\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { modifyClass } from \"./ClassMerger\";\nimport { updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new EntityClass into the target schema.\n * @internal\n */\nexport async function addEntityClass(context: SchemaMergeContext, change: EntityClassDifference) {\n await context.editor.entities.createFromProps(context.targetSchemaKey, {\n name: change.itemName,\n schemaItemType: change.schemaType,\n\n ...change.difference,\n });\n}\n\n/**\n * Merges differences to an existing EntityClass in the target schema.\n * @internal\n */\nexport async function modifyEntityClass(context: SchemaMergeContext, change: EntityClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableEntityClass;\n if(change.difference.mixins !== undefined) {\n for(const mixin of change.difference.mixins) {\n const mixinKey = await updateSchemaItemKey(context, mixin);\n await context.editor.entities.addMixin(itemKey, mixinKey);\n }\n }\n\n return modifyClass(context, change, itemKey, item);\n}\n\n/**\n * Merges Mixins to Entity Class schema items.\n * @internal\n */\nexport async function addClassMixins(context: SchemaMergeContext, change: EntityClassMixinDifference): Promise<void> {\n for(const mixinFullName of change.difference) {\n const mixinKey = await updateSchemaItemKey(context, mixinFullName);\n const entityKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\n await context.editor.entities.addMixin(entityKey, mixinKey);\n }\n}\n"]}
1
+ {"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAeA,wCAOC;AAMD,8CAUC;AAMD,wCAMC;AA1CD,+CAA4C;AAC5C,mCAAyD;AAEzD;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACrE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QAEjC,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAuB,CAAC;IAClF,IAAG,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1C,KAAI,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAAkC;IAClG,KAAI,MAAM,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,IAAA,iBAAS,EAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9D,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 { EntityClassDifference, EntityClassMixinDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableEntityClass } from \"../Editing/Mutable/MutableEntityClass\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { modifyClass } from \"./ClassMerger\";\nimport { toItemKey, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new EntityClass into the target schema.\n * @internal\n */\nexport async function addEntityClass(context: SchemaMergeContext, change: EntityClassDifference) {\n await context.editor.entities.createFromProps(context.targetSchemaKey, {\n name: change.itemName,\n schemaItemType: change.schemaType,\n\n ...change.difference,\n });\n}\n\n/**\n * Merges differences to an existing EntityClass in the target schema.\n * @internal\n */\nexport async function modifyEntityClass(context: SchemaMergeContext, change: EntityClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableEntityClass;\n if(change.difference.mixins !== undefined) {\n for(const mixin of change.difference.mixins) {\n const mixinKey = await updateSchemaItemKey(context, mixin);\n await context.editor.entities.addMixin(itemKey, mixinKey);\n }\n }\n\n return modifyClass(context, change, itemKey, item);\n}\n\n/**\n * Merges Mixins to Entity Class schema items.\n * @internal\n */\nexport async function addClassMixins(context: SchemaMergeContext, change: EntityClassMixinDifference): Promise<void> {\n for(const mixinFullName of change.difference) {\n const mixinKey = await updateSchemaItemKey(context, mixinFullName);\n const entityKey = toItemKey(context, change.itemName);\n await context.editor.entities.addMixin(entityKey, mixinKey);\n }\n}\n"]}
@@ -19,7 +19,7 @@ async function addEnumeration(context, change) {
19
19
  throw new Error("Enumerations must define whether enumeration is strict.");
20
20
  }
21
21
  if (change.difference.enumerators === undefined) {
22
- throw new Error("Enumerations must define at least ine enumerator.");
22
+ throw new Error("Enumerations must define at least one enumerator.");
23
23
  }
24
24
  await context.editor.enumerations.createFromProps(context.targetSchemaKey, {
25
25
  ...change.difference,
@@ -1 +1 @@
1
- {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAaA,wCAmBC;AAMD,8CAcC;AApDD;;;+FAG+F;AAC/F,gEAAqF;AAKrF;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SA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AC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3F,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5C,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtD,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 { primitiveTypeToString, type SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport type { EnumerationDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { MutableEnumeration } from \"../Editing/Mutable/MutableEnumeration\";\n\n/**\n * Merges a new Enumeration into the target schema.\n * @internal\n */\nexport async function addEnumeration(context: SchemaMergeContext, change: EnumerationDifference) {\n if (change.difference.type === undefined) {\n throw new Error(\"Enumerations must define a type property\");\n }\n if (change.difference.isStrict === undefined) {\n throw new Error(\"Enumerations must define whether enumeration is strict.\");\n }\n if (change.difference.enumerators === undefined) {\n throw new Error(\"Enumerations must define at least ine enumerator.\");\n }\n\n await context.editor.enumerations.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n type: change.difference.type,\n isStrict: change.difference.isStrict,\n enumerators: change.difference.enumerators,\n });\n}\n\n/**\n * Merges differences to an existing Enumeration in the target schema.\n * @internal\n */\nexport async function modifyEnumeration(context: SchemaMergeContext, change: EnumerationDifference, itemKey: SchemaItemKey) {\n const enumeration = await context.targetSchema.lookupItem(itemKey) as MutableEnumeration;\n if(change.difference.type !== undefined) {\n throw new Error(`The Enumeration ${itemKey.name} has an incompatible type. It must be \"${primitiveTypeToString(enumeration.type!)}\", not \"${change.difference.type}\".`);\n }\n if(change.difference.label !== undefined) {\n await context.editor.enumerations.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.enumerations.setDescription(itemKey, change.difference.description);\n }\n if(change.difference.isStrict !== undefined) {\n enumeration.setIsStrict(change.difference.isStrict);\n }\n}\n"]}
1
+ {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAaA,wCAmBC;AAMD,8CAcC;AApDD;;;+FAG+F;AAC/F,gEAAqF;AAKrF;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACzE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI;QAC5B,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;QACpC,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW;KAC3C,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAuB,CAAC;IACzF,IAAG,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,IAAI,0CAA0C,IAAA,yCAAqB,EAAC,WAAW,CAAC,IAAK,CAAC,WAAW,MAAM,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,CAAC;IAC1K,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3F,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5C,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtD,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 { primitiveTypeToString, type SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport type { EnumerationDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { MutableEnumeration } from \"../Editing/Mutable/MutableEnumeration\";\n\n/**\n * Merges a new Enumeration into the target schema.\n * @internal\n */\nexport async function addEnumeration(context: SchemaMergeContext, change: EnumerationDifference) {\n if (change.difference.type === undefined) {\n throw new Error(\"Enumerations must define a type property\");\n }\n if (change.difference.isStrict === undefined) {\n throw new Error(\"Enumerations must define whether enumeration is strict.\");\n }\n if (change.difference.enumerators === undefined) {\n throw new Error(\"Enumerations must define at least one enumerator.\");\n }\n\n await context.editor.enumerations.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n type: change.difference.type,\n isStrict: change.difference.isStrict,\n enumerators: change.difference.enumerators,\n });\n}\n\n/**\n * Merges differences to an existing Enumeration in the target schema.\n * @internal\n */\nexport async function modifyEnumeration(context: SchemaMergeContext, change: EnumerationDifference, itemKey: SchemaItemKey) {\n const enumeration = await context.targetSchema.lookupItem(itemKey) as MutableEnumeration;\n if(change.difference.type !== undefined) {\n throw new Error(`The Enumeration ${itemKey.name} has an incompatible type. It must be \"${primitiveTypeToString(enumeration.type!)}\", not \"${change.difference.type}\".`);\n }\n if(change.difference.label !== undefined) {\n await context.editor.enumerations.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.enumerations.setDescription(itemKey, change.difference.description);\n }\n if(change.difference.isStrict !== undefined) {\n enumeration.setIsStrict(change.difference.isStrict);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EnumeratorMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumeratorMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,iBAe5F;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,iBAUvH"}
1
+ {"version":3,"file":"EnumeratorMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumeratorMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,iBAe5F;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,iBAUvH"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addEnumerator = addEnumerator;
4
4
  exports.modifyEnumerator = modifyEnumerator;
5
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
5
+ const Utils_1 = require("./Utils");
6
6
  /**
7
7
  * Merges a new Enumerator into the target schema.
8
8
  * @internal
@@ -14,7 +14,7 @@ async function addEnumerator(context, change) {
14
14
  if (change.difference.value === undefined) {
15
15
  throw new Error("Enumerators must define a value");
16
16
  }
17
- const itemKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
17
+ const itemKey = (0, Utils_1.toItemKey)(context, change.itemName);
18
18
  await context.editor.enumerations.addEnumerator(itemKey, {
19
19
  name: change.difference.name,
20
20
  value: change.difference.value,
@@ -1 +1 @@
1
- {"version":3,"file":"EnumeratorMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumeratorMerger.ts"],"names":[],"mappings":";;AAYA,sCAeC;AAMD,4CAUC;AArCD,gEAAyD;AAEzD;;;GAGG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AAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtG,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 { EnumeratorDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new Enumerator into the target schema.\n * @internal\n */\nexport async function addEnumerator(context: SchemaMergeContext, change: EnumeratorDifference) {\n if (change.difference.name === undefined) {\n throw new Error(\"Enumerators must define a name\");\n }\n if (change.difference.value === undefined) {\n throw new Error(\"Enumerators must define a value\");\n }\n\n const itemKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\n await context.editor.enumerations.addEnumerator(itemKey, {\n name: change.difference.name,\n value: change.difference.value,\n label: change.difference.label,\n description: change.difference.description,\n });\n}\n\n/**\n * Merges differences to an existing Enumerator in the target schema.\n * @internal\n */\nexport async function modifyEnumerator(context: SchemaMergeContext, change: EnumeratorDifference, itemKey: SchemaItemKey) {\n if(change.difference.value !== undefined) {\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${change.path}\" has different values.`);\n }\n if(change.difference.description !== undefined) {\n await context.editor.enumerations.setEnumeratorDescription(itemKey, change.path, change.difference.description);\n }\n if(change.difference.label !== undefined) {\n await context.editor.enumerations.setEnumeratorLabel(itemKey, change.path, change.difference.label);\n }\n}\n"]}
1
+ {"version":3,"file":"EnumeratorMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumeratorMerger.ts"],"names":[],"mappings":";;AAaA,sCAeC;AAMD,4CAUC;AArCD,mCAAoC;AAEpC;;;GAGG;AACI,KAAK,UAAU,aAAa,CAAC,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AAkB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtG,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 { EnumeratorDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { toItemKey } from \"./Utils\";\n\n/**\n * Merges a new Enumerator into the target schema.\n * @internal\n */\nexport async function addEnumerator(context: SchemaMergeContext, change: EnumeratorDifference) {\n if (change.difference.name === undefined) {\n throw new Error(\"Enumerators must define a name\");\n }\n if (change.difference.value === undefined) {\n throw new Error(\"Enumerators must define a value\");\n }\n\n const itemKey = toItemKey(context, change.itemName);\n await context.editor.enumerations.addEnumerator(itemKey, {\n name: change.difference.name,\n value: change.difference.value,\n label: change.difference.label,\n description: change.difference.description,\n });\n}\n\n/**\n * Merges differences to an existing Enumerator in the target schema.\n * @internal\n */\nexport async function modifyEnumerator(context: SchemaMergeContext, change: EnumeratorDifference, itemKey: SchemaItemKey) {\n if(change.difference.value !== undefined) {\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${change.path}\" has different values.`);\n }\n if(change.difference.description !== undefined) {\n await context.editor.enumerations.setEnumeratorDescription(itemKey, change.path, change.difference.description);\n }\n if(change.difference.label !== undefined) {\n await context.editor.enumerations.setEnumeratorLabel(itemKey, change.path, change.difference.label);\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { SchemaItemKey } from "@itwin/ecschema-metadata";
2
+ import { FormatDifference, FormatUnitDifference, FormatUnitLabelDifference } from "../Differencing/SchemaDifference";
3
+ import { SchemaMergeContext } from "./SchemaMerger";
4
+ /**
5
+ * Merges a new Format into the target schema.
6
+ * @internal
7
+ */
8
+ export declare function addFormat(context: SchemaMergeContext, change: FormatDifference): Promise<void>;
9
+ /**
10
+ * Merges differences to an existing Format in the target schema.
11
+ * @internal
12
+ */
13
+ export declare function modifyFormat(context: SchemaMergeContext, change: FormatDifference, itemKey: SchemaItemKey): Promise<void>;
14
+ /**
15
+ * Merges source format units into the target format
16
+ * @internal
17
+ */
18
+ export declare function modifyFormatUnit(context: SchemaMergeContext, change: FormatUnitDifference, itemKey: SchemaItemKey): Promise<void>;
19
+ /**
20
+ * Overrides format unit label
21
+ * @internal
22
+ */
23
+ export declare function modifyFormatUnitLabel(context: SchemaMergeContext, change: FormatUnitLabelDifference, itemKey: SchemaItemKey): Promise<void>;
24
+ //# sourceMappingURL=FormatMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/FormatMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAErH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;GAGG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,gBAAgB,iBAsBpF;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa,iBAwD/G;AAED;;;EAGE;AACF,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,iBAavH;AAED;;;EAGE;AACF,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,yBAAyB,EAAE,OAAO,EAAE,aAAa,iBAYjI"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addFormat = addFormat;
4
+ exports.modifyFormat = modifyFormat;
5
+ exports.modifyFormatUnit = modifyFormatUnit;
6
+ exports.modifyFormatUnitLabel = modifyFormatUnitLabel;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ const core_quantity_1 = require("@itwin/core-quantity");
13
+ const Utils_1 = require("./Utils");
14
+ /**
15
+ * Merges a new Format into the target schema.
16
+ * @internal
17
+ */
18
+ async function addFormat(context, change) {
19
+ if (change.difference.type === undefined) {
20
+ throw new Error("Format must define type");
21
+ }
22
+ if (change.difference.composite && change.difference.composite.units) {
23
+ for (let index = 0; index < change.difference.composite.units.length; index++) {
24
+ const compositeUnitName = await (0, Utils_1.updateSchemaItemFullName)(context, change.difference.composite.units[index].name);
25
+ change.difference.composite.units[index] = {
26
+ name: compositeUnitName,
27
+ label: change.difference.composite.units[index].label,
28
+ };
29
+ }
30
+ }
31
+ await context.editor.formats.createFromProps(context.targetSchemaKey, {
32
+ ...change.difference,
33
+ name: change.itemName,
34
+ schemaItemType: change.schemaType,
35
+ type: change.difference.type,
36
+ composite: change.difference.composite,
37
+ });
38
+ }
39
+ /**
40
+ * Merges differences to an existing Format in the target schema.
41
+ * @internal
42
+ */
43
+ async function modifyFormat(context, change, itemKey) {
44
+ const format = await context.targetSchema.lookupItem(itemKey);
45
+ if (change.difference.type !== undefined) {
46
+ throw new Error(`Changing the format '${change.itemName}' type is not supported.`);
47
+ }
48
+ if (change.difference.label !== undefined) {
49
+ await context.editor.formats.setDisplayLabel(itemKey, change.difference.label);
50
+ }
51
+ if (change.difference.description !== undefined) {
52
+ await context.editor.formats.setDescription(itemKey, change.difference.description);
53
+ }
54
+ if (change.difference.precision !== undefined) {
55
+ format.setPrecision(change.difference.precision);
56
+ }
57
+ if (change.difference.roundFactor !== undefined) {
58
+ format.setRoundFactor(change.difference.roundFactor);
59
+ }
60
+ if (change.difference.minWidth !== undefined) {
61
+ format.setMinWidth(change.difference.minWidth);
62
+ }
63
+ if (change.difference.showSignOption !== undefined) {
64
+ const showSignOption = (0, core_quantity_1.parseShowSignOption)(change.difference.showSignOption, change.itemName);
65
+ format.setShowSignOption(showSignOption);
66
+ }
67
+ if (change.difference.formatTraits !== undefined) {
68
+ const formatTraits = parseFormatTraits(change.difference.formatTraits, change.itemName);
69
+ format.setFormatTraits(formatTraits);
70
+ }
71
+ if (change.difference.decimalSeparator !== undefined) {
72
+ format.setDecimalSeparator(change.difference.decimalSeparator);
73
+ }
74
+ if (change.difference.thousandSeparator !== undefined) {
75
+ format.setThousandSeparator(change.difference.thousandSeparator);
76
+ }
77
+ if (change.difference.uomSeparator !== undefined) {
78
+ format.setUomSeparator(change.difference.uomSeparator);
79
+ }
80
+ if (change.difference.scientificType !== undefined) {
81
+ const scientificType = (0, core_quantity_1.parseScientificType)(change.difference.scientificType, change.itemName);
82
+ format.setScientificType(scientificType);
83
+ }
84
+ if (change.difference.stationOffsetSize !== undefined) {
85
+ format.setStationOffsetSize(change.difference.stationOffsetSize);
86
+ }
87
+ if (change.difference.stationSeparator !== undefined) {
88
+ format.setStationSeparator(change.difference.stationSeparator);
89
+ }
90
+ if (change.difference.composite !== undefined) {
91
+ if (change.difference.composite.includeZero !== undefined) {
92
+ format.setIncludeZero(change.difference.composite.includeZero);
93
+ }
94
+ if (change.difference.composite.spacer !== undefined) {
95
+ format.setSpacer(change.difference.composite.spacer);
96
+ }
97
+ }
98
+ }
99
+ /**
100
+ * Merges source format units into the target format
101
+ * @internal
102
+ */
103
+ async function modifyFormatUnit(context, change, itemKey) {
104
+ const format = await context.targetSchema.lookupItem(itemKey);
105
+ const units = [];
106
+ for (const { name, label } of change.difference) {
107
+ const lookupKey = await (0, Utils_1.updateSchemaItemKey)(context, name);
108
+ const formatUnit = await context.editor.schemaContext.getSchemaItem(lookupKey);
109
+ if (formatUnit === undefined || (!ecschema_metadata_1.Unit.isUnit(formatUnit) && !ecschema_metadata_1.InvertedUnit.isInvertedUnit(formatUnit))) {
110
+ throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);
111
+ }
112
+ units.push([formatUnit, label]);
113
+ }
114
+ format.setUnits(units);
115
+ }
116
+ /**
117
+ * Overrides format unit label
118
+ * @internal
119
+ */
120
+ async function modifyFormatUnitLabel(context, change, itemKey) {
121
+ const format = await context.targetSchema.lookupItem(itemKey);
122
+ if (format.units !== undefined) {
123
+ const unitKey = await (0, Utils_1.updateSchemaItemKey)(context, change.path);
124
+ /* eslint-disable @typescript-eslint/prefer-for-of */
125
+ for (let index = 0; index < format.units.length; index++) {
126
+ if (format.units[index][0].key.matches(unitKey)) {
127
+ format.units[index][1] = change.difference.label;
128
+ }
129
+ }
130
+ }
131
+ }
132
+ function parseFormatTraits(formatTraitsFromJson, formatName) {
133
+ let formatTraits = core_quantity_1.FormatTraits.Uninitialized;
134
+ const formatTraitIterable = Array.isArray(formatTraitsFromJson)
135
+ ? formatTraitsFromJson
136
+ : formatTraitsFromJson.split(/,|;|\|/);
137
+ for (const formatTraitsString of formatTraitIterable) {
138
+ const formatTrait = (0, core_quantity_1.parseFormatTrait)(formatTraitsString, formatName);
139
+ formatTraits = formatTraits | formatTrait;
140
+ }
141
+ return formatTraits;
142
+ }
143
+ //# sourceMappingURL=FormatMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatMerger.js","sourceRoot":"","sources":["../../../src/Merging/FormatMerger.ts"],"names":[],"mappings":";;AAeA,8BAsBC;AAMD,oCAwDC;AAMD,4CAaC;AAMD,sDAYC;AAxID;;;+FAG+F;AAC/F,gEAA6E;AAC7E,wDAAgH;AAIhH,mCAAwE;AAExE;;;GAGG;AACI,KAAK,UAAU,SAAS,CAAC,OAA2B,EAAE,MAAwB;IACnF,IAAI,MA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AAC","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 { InvertedUnit, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatTraits, parseFormatTrait, parseScientificType, parseShowSignOption } from \"@itwin/core-quantity\";\nimport { FormatDifference, FormatUnitDifference, FormatUnitLabelDifference } from \"../Differencing/SchemaDifference\";\nimport { MutableFormat } from \"../Editing/Mutable/MutableFormat\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Format into the target schema.\n * @internal\n */\nexport async function addFormat(context: SchemaMergeContext, change: FormatDifference) {\n if (change.difference.type === undefined) {\n throw new Error(\"Format must define type\");\n }\n\n if (change.difference.composite && change.difference.composite.units) {\n for (let index = 0; index < change.difference.composite.units.length; index++) {\n const compositeUnitName = await updateSchemaItemFullName(context, change.difference.composite.units[index].name);\n change.difference.composite.units[index] = {\n name: compositeUnitName,\n label: change.difference.composite.units[index].label,\n }\n }\n }\n\n await context.editor.formats.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n type: change.difference.type,\n composite: change.difference.composite,\n });\n}\n\n/**\n * Merges differences to an existing Format in the target schema.\n * @internal\n */\nexport async function modifyFormat(context: SchemaMergeContext, change: FormatDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n if (change.difference.type !== undefined) {\n throw new Error(`Changing the format '${change.itemName}' type is not supported.`);\n }\n\n if (change.difference.label !== undefined) {\n await context.editor.formats.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.formats.setDescription(itemKey, change.difference.description);\n }\n if (change.difference.precision !== undefined) {\n format.setPrecision(change.difference.precision);\n }\n if (change.difference.roundFactor !== undefined) {\n format.setRoundFactor(change.difference.roundFactor);\n }\n if (change.difference.minWidth !== undefined) {\n format.setMinWidth(change.difference.minWidth);\n }\n if (change.difference.showSignOption !== undefined) {\n const showSignOption = parseShowSignOption(change.difference.showSignOption, change.itemName);\n format.setShowSignOption(showSignOption);\n }\n if (change.difference.formatTraits !== undefined) {\n const formatTraits = parseFormatTraits(change.difference.formatTraits, change.itemName);\n format.setFormatTraits(formatTraits);\n }\n if (change.difference.decimalSeparator !== undefined) {\n format.setDecimalSeparator(change.difference.decimalSeparator);\n }\n if (change.difference.thousandSeparator !== undefined) {\n format.setThousandSeparator(change.difference.thousandSeparator);\n }\n if (change.difference.uomSeparator !== undefined) {\n format.setUomSeparator(change.difference.uomSeparator);\n }\n if (change.difference.scientificType !== undefined) {\n const scientificType = parseScientificType(change.difference.scientificType, change.itemName);\n format.setScientificType(scientificType);\n }\n if (change.difference.stationOffsetSize !== undefined) {\n format.setStationOffsetSize(change.difference.stationOffsetSize);\n }\n if (change.difference.stationSeparator !== undefined) {\n format.setStationSeparator(change.difference.stationSeparator);\n }\n if (change.difference.composite !== undefined) {\n if (change.difference.composite.includeZero !== undefined) {\n format.setIncludeZero(change.difference.composite.includeZero);\n }\n if (change.difference.composite.spacer !== undefined) {\n format.setSpacer(change.difference.composite.spacer);\n }\n }\n}\n\n/**\n * Merges source format units into the target format\n * @internal\n*/\nexport async function modifyFormatUnit(context: SchemaMergeContext, change: FormatUnitDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n const units: [Unit | InvertedUnit, string | undefined][] = [];\n for (const { name, label } of change.difference) {\n const lookupKey = await updateSchemaItemKey(context, name);\n const formatUnit = await context.editor.schemaContext.getSchemaItem(lookupKey);\n if (formatUnit === undefined || (!Unit.isUnit(formatUnit) && !InvertedUnit.isInvertedUnit(formatUnit))) {\n throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);\n }\n units.push([formatUnit, label]);\n }\n format.setUnits(units);\n}\n\n/**\n * Overrides format unit label\n * @internal\n*/\nexport async function modifyFormatUnitLabel(context: SchemaMergeContext, change: FormatUnitLabelDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n if (format.units !== undefined) {\n const unitKey = await updateSchemaItemKey(context, change.path);\n /* eslint-disable @typescript-eslint/prefer-for-of */\n for (let index = 0; index < format.units.length; index++) {\n if (format.units[index][0].key.matches(unitKey)) {\n format.units[index][1] = change.difference.label;\n }\n }\n }\n}\n\nfunction parseFormatTraits(formatTraitsFromJson: string | string[], formatName: string): FormatTraits {\n let formatTraits: FormatTraits = FormatTraits.Uninitialized;\n const formatTraitIterable = Array.isArray(formatTraitsFromJson)\n ? formatTraitsFromJson\n : formatTraitsFromJson.split(/,|;|\\|/);\n for (const formatTraitsString of formatTraitIterable) {\n const formatTrait = parseFormatTrait(formatTraitsString, formatName);\n formatTraits = formatTraits | formatTrait;\n }\n return formatTraits;\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { SchemaItemKey } from "@itwin/ecschema-metadata";
2
+ import { InvertedUnitDifference } from "../Differencing/SchemaDifference";
3
+ import { SchemaMergeContext } from "./SchemaMerger";
4
+ /**
5
+ * Merges a new InvertedUnit into the target schema.
6
+ * @internal
7
+ */
8
+ export declare function addInvertedUnit(context: SchemaMergeContext, change: InvertedUnitDifference): Promise<void>;
9
+ /**
10
+ * Merges differences to an existing InvertedUnit in the target schema.
11
+ * @internal
12
+ */
13
+ export declare function modifyInvertedUnit(context: SchemaMergeContext, change: InvertedUnitDifference, itemKey: SchemaItemKey): Promise<void>;
14
+ //# sourceMappingURL=InvertedUnitMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvertedUnitMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/InvertedUnitMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;GAGG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,sBAAsB,iBAkBhG;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE,aAAa,iBAc3H"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addInvertedUnit = addInvertedUnit;
4
+ exports.modifyInvertedUnit = modifyInvertedUnit;
5
+ const Utils_1 = require("./Utils");
6
+ /**
7
+ * Merges a new InvertedUnit into the target schema.
8
+ * @internal
9
+ */
10
+ async function addInvertedUnit(context, change) {
11
+ if (change.difference.unitSystem === undefined) {
12
+ throw new Error("InvertedUnit must define unitSystem");
13
+ }
14
+ if (change.difference.invertsUnit === undefined) {
15
+ throw new Error("InvertedUnit must define invertsUnit");
16
+ }
17
+ change.difference.unitSystem = await (0, Utils_1.updateSchemaItemFullName)(context, change.difference.unitSystem);
18
+ change.difference.invertsUnit = await (0, Utils_1.updateSchemaItemFullName)(context, change.difference.invertsUnit);
19
+ await context.editor.invertedUnits.createFromProps(context.targetSchemaKey, {
20
+ ...change.difference,
21
+ name: change.itemName,
22
+ schemaItemType: change.schemaType,
23
+ unitSystem: change.difference.unitSystem,
24
+ invertsUnit: change.difference.invertsUnit,
25
+ });
26
+ }
27
+ /**
28
+ * Merges differences to an existing InvertedUnit in the target schema.
29
+ * @internal
30
+ */
31
+ async function modifyInvertedUnit(context, change, itemKey) {
32
+ if (change.difference.unitSystem !== undefined) {
33
+ throw new Error(`Changing the invertedUnit '${change.itemName}' unitSystem is not supported.`);
34
+ }
35
+ if (change.difference.invertsUnit !== undefined) {
36
+ throw new Error(`Changing the invertedUnit '${change.itemName}' invertsUnit is not supported.`);
37
+ }
38
+ if (change.difference.label !== undefined) {
39
+ await context.editor.invertedUnits.setDisplayLabel(itemKey, change.difference.label);
40
+ }
41
+ if (change.difference.description !== undefined) {
42
+ await context.editor.invertedUnits.setDescription(itemKey, change.difference.description);
43
+ }
44
+ }
45
+ //# sourceMappingURL=InvertedUnitMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvertedUnitMerger.js","sourceRoot":"","sources":["../../../src/Merging/InvertedUnitMerger.ts"],"names":[],"mappings":";;AAaA,0CAkBC;AAMD,gDAcC;AA5CD,mCAAmD;AAEnD;;;GAGG;AACI,KAAK,UAAU,eAAe,CAAC,OAA2B,EAAE,MAA8B;IAC/F,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,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,WAAW,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAEvG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAC1E,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,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW;KAC3C,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CAAC,OAA2B,EAAE,MAA8B,EAAE,OAAsB;IAC1H,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,QAAQ,gCAAgC,CAAC,CAAC;IACjG,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,QAAQ,iCAAiC,CAAC,CAAC;IAClG,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACvF,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC5F,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 { InvertedUnitDifference } from \"../Differencing/SchemaDifference\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { updateSchemaItemFullName } from \"./Utils\";\n\n/**\n * Merges a new InvertedUnit into the target schema.\n * @internal\n */\nexport async function addInvertedUnit(context: SchemaMergeContext, change: InvertedUnitDifference) {\n if (change.difference.unitSystem === undefined) {\n throw new Error(\"InvertedUnit must define unitSystem\");\n }\n if (change.difference.invertsUnit === undefined) {\n throw new Error(\"InvertedUnit must define invertsUnit\");\n }\n\n change.difference.unitSystem = await updateSchemaItemFullName(context, change.difference.unitSystem);\n change.difference.invertsUnit = await updateSchemaItemFullName(context, change.difference.invertsUnit);\n\n await context.editor.invertedUnits.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n unitSystem: change.difference.unitSystem,\n invertsUnit: change.difference.invertsUnit,\n });\n}\n\n/**\n * Merges differences to an existing InvertedUnit in the target schema.\n * @internal\n */\nexport async function modifyInvertedUnit(context: SchemaMergeContext, change: InvertedUnitDifference, itemKey: SchemaItemKey) {\n if (change.difference.unitSystem !== undefined) {\n throw new Error(`Changing the invertedUnit '${change.itemName}' unitSystem is not supported.`);\n }\n if (change.difference.invertsUnit !== undefined) {\n throw new Error(`Changing the invertedUnit '${change.itemName}' invertsUnit is not supported.`);\n }\n\n if (change.difference.label !== undefined) {\n await context.editor.invertedUnits.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.invertedUnits.setDescription(itemKey, change.difference.description);\n }\n}\n"]}
@@ -15,5 +15,5 @@ export declare function modifyKindOfQuantity(context: SchemaMergeContext, change
15
15
  * Merges a new presentation format into the target kind of quantity
16
16
  * @internal
17
17
  */
18
- export declare function addPresentationFormat(context: SchemaMergeContext, change: KindOfQuantityPresentationFormatDifference): Promise<void>;
18
+ export declare function addPresentationFormat(context: SchemaMergeContext, change: KindOfQuantityPresentationFormatDifference, itemKey: SchemaItemKey): Promise<void>;
19
19
  //# sourceMappingURL=KindOfQuantityMerger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantityMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C,EAAE,MAAM,kCAAkC,CAAC;AAE7H,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAwC,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AAGrG;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,wBAAwB,iBA4BpG;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,wBAAwB,EAAE,OAAO,EAAE,aAAa,iBAe/H;AACD;;;EAGE;AACF,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,0CAA0C,iBAU1H"}
1
+ {"version":3,"file":"KindOfQuantityMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C,EAAE,MAAM,kCAAkC,CAAC;AAE7H,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAwC,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AAGrG;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,wBAAwB,iBA4BpG;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,wBAAwB,EAAE,OAAO,EAAE,aAAa,iBAe/H;AACD;;;EAGE;AACF,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,0CAA0C,EAAE,OAAO,EAAE,aAAa,iBASlJ"}
@@ -55,22 +55,21 @@ async function modifyKindOfQuantity(context, change, itemKey) {
55
55
  }
56
56
  if (change.difference.persistenceUnit !== undefined) {
57
57
  // TODO: It should be checked if the unit is the same, but referring to the source schema.
58
- throw new Error(`Changing the kind of quantity '${itemKey.name}' persistenceUnit is not supported.`);
58
+ throw new Error(`Changing the kind of quantity '${change.itemName}' persistenceUnit is not supported.`);
59
59
  }
60
60
  }
61
61
  /**
62
62
  * Merges a new presentation format into the target kind of quantity
63
63
  * @internal
64
64
  */
65
- async function addPresentationFormat(context, change) {
65
+ async function addPresentationFormat(context, change, itemKey) {
66
66
  for (const formatString of change.difference) {
67
- const koqKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
68
67
  const presentationFormat = await updateOverrideFormat(context, formatString);
69
68
  if (ecschema_metadata_1.OverrideFormat.isOverrideFormat(presentationFormat)) {
70
- await context.editor.kindOfQuantities.addPresentationOverrideFormat(koqKey, presentationFormat);
69
+ await context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, presentationFormat);
71
70
  }
72
71
  else {
73
- await context.editor.kindOfQuantities.addPresentationFormat(koqKey, presentationFormat.key);
72
+ await context.editor.kindOfQuantities.addPresentationFormat(itemKey, presentationFormat.key);
74
73
  }
75
74
  }
76
75
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;AAcA,8CA4BC;AAMD,oDAeC;AAKD,sDAUC;AAvED,gEAAqG;AACrG,mCAAwE;AAExE;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAAgC;IACnG,IAAI,MAAM,CAAC,UAAU,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,CAAC,UAAU,CAAC,eAAe,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IAC/G,IAAG,MAAM,CAAC,UAAU,CAAC,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,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC9F,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,YAAoB;IACnF,kEAAkE;IAClE,MAAM,KAAK,GAAG,kCAAc,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC7D,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,SAAS,CAAW,CAAC;IAE1E,IAAI,SAAS,KAAK,KAAK,CAAC,SAAS,IAAI,SAAS,KAAK,KAAK,CAAC,aAAa;QACpE,OAAO,MAAM,CAAC;IAEhB,IAAI,aAA2E,CAAC;IAChF,IAAI,SAAS,KAAK,KAAK,CAAC,aAAa,EAAE,CAAC;QACtC,aAAa,GAAG,EAAE,CAAC;QACnB,KAAK,MAAM,YAAY,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;YAC/C,MAAM,OAAO,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;YACpE,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAwB,CAAC;YACnF,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACzG,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 { KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableKindOfQuantity } from \"../Editing/Mutable/MutableKindOfQuantity\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { Format, InvertedUnit, OverrideFormat, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new KindOfQuantity into the target schema.\n * @internal\n */\nexport async function addKindOfQuantity(context: SchemaMergeContext, change: KindOfQuantityDifference) {\n if (change.difference.persistenceUnit === undefined) {\n throw new Error(\"KindOfQuantity must define persistenceUnit\");\n }\n if (change.difference.relativeError === undefined) {\n throw new Error(\"KindOfQuantity must define relativeError\");\n }\n change.difference.persistenceUnit = await updateSchemaItemFullName(context, change.difference.persistenceUnit);\n if(change.difference.presentationUnits) {\n if(Array.isArray(change.difference.presentationUnits)) {\n for(let index = 0; index < change.difference.presentationUnits.length; index++) {\n const presentationFormat = await updateOverrideFormat(context, change.difference.presentationUnits[index]);\n change.difference.presentationUnits[index] = presentationFormat.fullName;\n }\n } else {\n const presentationFormat = await updateOverrideFormat(context, change.difference.presentationUnits);\n change.difference.presentationUnits = presentationFormat.name;\n }\n }\n\n await context.editor.kindOfQuantities.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n persistenceUnit: change.difference.persistenceUnit,\n presentationUnits: change.difference.presentationUnits,\n relativeError: change.difference.relativeError,\n });\n}\n\n/**\n * Merges differences to an existing KindOfQuantity in the target schema.\n * @internal\n */\nexport async function modifyKindOfQuantity(context: SchemaMergeContext, change: KindOfQuantityDifference, itemKey: SchemaItemKey) {\n const kindOfQuantity = await context.targetSchema.lookupItem(itemKey) as MutableKindOfQuantity;\n if(change.difference.label !== undefined) {\n await context.editor.kindOfQuantities.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.kindOfQuantities.setDescription(itemKey, change.difference.description);\n }\n if(change.difference.relativeError !== undefined) {\n kindOfQuantity.setRelativeError(change.difference.relativeError);\n }\n if(change.difference.persistenceUnit !== undefined) {\n // TODO: It should be checked if the unit is the same, but referring to the source schema.\n throw new Error(`Changing the kind of quantity '${itemKey.name}' persistenceUnit is not supported.`);\n }\n}\n/**\n * Merges a new presentation format into the target kind of quantity\n * @internal\n*/\nexport async function addPresentationFormat(context: SchemaMergeContext, change: KindOfQuantityPresentationFormatDifference) {\n for (const formatString of change.difference) {\n const koqKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\n const presentationFormat = await updateOverrideFormat(context, formatString);\n if (OverrideFormat.isOverrideFormat(presentationFormat)) {\n await context.editor.kindOfQuantities.addPresentationOverrideFormat(koqKey, presentationFormat);\n } else {\n await context.editor.kindOfQuantities.addPresentationFormat(koqKey, presentationFormat.key);\n }\n }\n}\n\nasync function updateOverrideFormat(context: SchemaMergeContext, formatString: string): Promise<Format | OverrideFormat> {\n // https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string\n const match = OverrideFormat.parseFormatString(formatString);\n const formatKey = await updateSchemaItemKey(context, match.name);\n const format = await context.targetSchema.lookupItem(formatKey) as Format;\n\n if (undefined === match.precision && undefined === match.unitAndLabels)\n return format;\n\n let unitAndLabels: Array<[Unit | InvertedUnit, string | undefined]> | undefined;\n if (undefined !== match.unitAndLabels) {\n unitAndLabels = [];\n for (const unitOverride of match.unitAndLabels) {\n const unitKey = await updateSchemaItemKey(context, unitOverride[0]);\n const unit = await context.targetSchema.lookupItem(unitKey) as Unit | InvertedUnit;\n unitAndLabels.push([unit, unitOverride[1]]);\n }\n }\n return context.editor.kindOfQuantities.createFormatOverride(formatKey, match.precision, unitAndLabels);\n}\n"]}
1
+ {"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;AAcA,8CA4B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AC,CAAC,CAAC,CAAC,CAAC;YACpE,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAwB,CAAC;YACnF,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACzG,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 { KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableKindOfQuantity } from \"../Editing/Mutable/MutableKindOfQuantity\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { Format, InvertedUnit, OverrideFormat, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new KindOfQuantity into the target schema.\n * @internal\n */\nexport async function addKindOfQuantity(context: SchemaMergeContext, change: KindOfQuantityDifference) {\n if (change.difference.persistenceUnit === undefined) {\n throw new Error(\"KindOfQuantity must define persistenceUnit\");\n }\n if (change.difference.relativeError === undefined) {\n throw new Error(\"KindOfQuantity must define relativeError\");\n }\n change.difference.persistenceUnit = await updateSchemaItemFullName(context, change.difference.persistenceUnit);\n if(change.difference.presentationUnits) {\n if(Array.isArray(change.difference.presentationUnits)) {\n for(let index = 0; index < change.difference.presentationUnits.length; index++) {\n const presentationFormat = await updateOverrideFormat(context, change.difference.presentationUnits[index]);\n change.difference.presentationUnits[index] = presentationFormat.fullName;\n }\n } else {\n const presentationFormat = await updateOverrideFormat(context, change.difference.presentationUnits);\n change.difference.presentationUnits = presentationFormat.name;\n }\n }\n\n await context.editor.kindOfQuantities.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n persistenceUnit: change.difference.persistenceUnit,\n presentationUnits: change.difference.presentationUnits,\n relativeError: change.difference.relativeError,\n });\n}\n\n/**\n * Merges differences to an existing KindOfQuantity in the target schema.\n * @internal\n */\nexport async function modifyKindOfQuantity(context: SchemaMergeContext, change: KindOfQuantityDifference, itemKey: SchemaItemKey) {\n const kindOfQuantity = await context.targetSchema.lookupItem(itemKey) as MutableKindOfQuantity;\n if(change.difference.label !== undefined) {\n await context.editor.kindOfQuantities.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.kindOfQuantities.setDescription(itemKey, change.difference.description);\n }\n if(change.difference.relativeError !== undefined) {\n kindOfQuantity.setRelativeError(change.difference.relativeError);\n }\n if(change.difference.persistenceUnit !== undefined) {\n // TODO: It should be checked if the unit is the same, but referring to the source schema.\n throw new Error(`Changing the kind of quantity '${change.itemName}' persistenceUnit is not supported.`);\n }\n}\n/**\n * Merges a new presentation format into the target kind of quantity\n * @internal\n*/\nexport async function addPresentationFormat(context: SchemaMergeContext, change: KindOfQuantityPresentationFormatDifference, itemKey: SchemaItemKey) {\n for (const formatString of change.difference) {\n const presentationFormat = await updateOverrideFormat(context, formatString);\n if (OverrideFormat.isOverrideFormat(presentationFormat)) {\n await context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, presentationFormat);\n } else {\n await context.editor.kindOfQuantities.addPresentationFormat(itemKey, presentationFormat.key);\n }\n }\n}\n\nasync function updateOverrideFormat(context: SchemaMergeContext, formatString: string): Promise<Format | OverrideFormat> {\n // https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string\n const match = OverrideFormat.parseFormatString(formatString);\n const formatKey = await updateSchemaItemKey(context, match.name);\n const format = await context.targetSchema.lookupItem(formatKey) as Format;\n\n if (undefined === match.precision && undefined === match.unitAndLabels)\n return format;\n\n let unitAndLabels: Array<[Unit | InvertedUnit, string | undefined]> | undefined;\n if (undefined !== match.unitAndLabels) {\n unitAndLabels = [];\n for (const unitOverride of match.unitAndLabels) {\n const unitKey = await updateSchemaItemKey(context, unitOverride[0]);\n const unit = await context.targetSchema.lookupItem(unitKey) as Unit | InvertedUnit;\n unitAndLabels.push([unit, unitOverride[1]]);\n }\n }\n return context.editor.kindOfQuantities.createFormatOverride(formatKey, match.precision, unitAndLabels);\n}\n"]}