@itwin/ecschema-editing 4.7.0-dev.8 → 4.7.0

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 (187) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/lib/cjs/Differencing/Errors.d.ts +19 -0
  3. package/lib/cjs/Differencing/Errors.d.ts.map +1 -0
  4. package/lib/cjs/Differencing/Errors.js +24 -0
  5. package/lib/cjs/Differencing/Errors.js.map +1 -0
  6. package/lib/cjs/Differencing/SchemaConflicts.d.ts +0 -14
  7. package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
  8. package/lib/cjs/Differencing/SchemaConflicts.js +1 -14
  9. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  10. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +4 -4
  11. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
  12. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +31 -31
  13. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  14. package/lib/cjs/Differencing/SchemaDifference.d.ts +1 -1
  15. package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
  16. package/lib/cjs/Differencing/SchemaDifference.js +6 -6
  17. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  18. package/lib/cjs/Editing/Constants.d.ts +6 -6
  19. package/lib/cjs/Editing/Constants.d.ts.map +1 -1
  20. package/lib/cjs/Editing/Constants.js +26 -31
  21. package/lib/cjs/Editing/Constants.js.map +1 -1
  22. package/lib/cjs/Editing/CustomAttributes.d.ts +3 -3
  23. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  24. package/lib/cjs/Editing/CustomAttributes.js +18 -28
  25. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  26. package/lib/cjs/Editing/ECClasses.d.ts +24 -23
  27. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  28. package/lib/cjs/Editing/ECClasses.js +126 -156
  29. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  30. package/lib/cjs/Editing/Editor.d.ts +10 -31
  31. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  32. package/lib/cjs/Editing/Editor.js +59 -43
  33. package/lib/cjs/Editing/Editor.js.map +1 -1
  34. package/lib/cjs/Editing/Entities.d.ts +9 -9
  35. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  36. package/lib/cjs/Editing/Entities.js +65 -85
  37. package/lib/cjs/Editing/Entities.js.map +1 -1
  38. package/lib/cjs/Editing/Enumerations.d.ts +6 -6
  39. package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
  40. package/lib/cjs/Editing/Enumerations.js +57 -55
  41. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  42. package/lib/cjs/Editing/Exception.d.ts +257 -0
  43. package/lib/cjs/Editing/Exception.d.ts.map +1 -0
  44. package/lib/cjs/Editing/Exception.js +426 -0
  45. package/lib/cjs/Editing/Exception.js.map +1 -0
  46. package/lib/cjs/Editing/Formats.d.ts +6 -6
  47. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  48. package/lib/cjs/Editing/Formats.js +28 -33
  49. package/lib/cjs/Editing/Formats.js.map +1 -1
  50. package/lib/cjs/Editing/InvertedUnits.d.ts +6 -6
  51. package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
  52. package/lib/cjs/Editing/InvertedUnits.js +41 -56
  53. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  54. package/lib/cjs/Editing/KindOfQuantities.d.ts +6 -6
  55. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  56. package/lib/cjs/Editing/KindOfQuantities.js +50 -57
  57. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  58. package/lib/cjs/Editing/Mixins.d.ts +5 -5
  59. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  60. package/lib/cjs/Editing/Mixins.js +43 -58
  61. package/lib/cjs/Editing/Mixins.js.map +1 -1
  62. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  63. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  64. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  65. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  66. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +1 -5
  67. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts.map +1 -1
  68. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +1 -45
  69. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  70. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  71. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  72. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  73. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  74. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  75. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  76. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  77. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  78. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  79. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  80. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  81. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  82. package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -1
  83. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  84. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  85. package/lib/cjs/Editing/Phenomena.d.ts +7 -7
  86. package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
  87. package/lib/cjs/Editing/Phenomena.js +23 -23
  88. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  89. package/lib/cjs/Editing/Properties.d.ts +7 -6
  90. package/lib/cjs/Editing/Properties.d.ts.map +1 -1
  91. package/lib/cjs/Editing/Properties.js +99 -46
  92. package/lib/cjs/Editing/Properties.js.map +1 -1
  93. package/lib/cjs/Editing/PropertyCategories.d.ts +6 -6
  94. package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
  95. package/lib/cjs/Editing/PropertyCategories.js +29 -27
  96. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  97. package/lib/cjs/Editing/RelationshipClasses.d.ts +15 -17
  98. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  99. package/lib/cjs/Editing/RelationshipClasses.js +97 -101
  100. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  101. package/lib/cjs/Editing/SchemaItems.d.ts +13 -5
  102. package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
  103. package/lib/cjs/Editing/SchemaItems.js +58 -6
  104. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  105. package/lib/cjs/Editing/Structs.d.ts +3 -3
  106. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  107. package/lib/cjs/Editing/Structs.js +17 -27
  108. package/lib/cjs/Editing/Structs.js.map +1 -1
  109. package/lib/cjs/Editing/UnitSystems.d.ts +7 -7
  110. package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
  111. package/lib/cjs/Editing/UnitSystems.js +22 -20
  112. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  113. package/lib/cjs/Editing/Units.d.ts +6 -6
  114. package/lib/cjs/Editing/Units.d.ts.map +1 -1
  115. package/lib/cjs/Editing/Units.js +26 -35
  116. package/lib/cjs/Editing/Units.js.map +1 -1
  117. package/lib/cjs/Merging/CAClassMerger.js +2 -2
  118. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  119. package/lib/cjs/Merging/ClassMerger.d.ts +1 -2
  120. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  121. package/lib/cjs/Merging/ClassMerger.js +15 -39
  122. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  123. package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
  124. package/lib/cjs/Merging/ConstantMerger.js +2 -3
  125. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  126. package/lib/cjs/Merging/CustomAttributeMerger.d.ts +4 -5
  127. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  128. package/lib/cjs/Merging/CustomAttributeMerger.js +8 -18
  129. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  130. package/lib/cjs/Merging/EntityClassMerger.d.ts +1 -2
  131. package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
  132. package/lib/cjs/Merging/EntityClassMerger.js +3 -10
  133. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  134. package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
  135. package/lib/cjs/Merging/EnumerationMerger.js +8 -10
  136. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  137. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  138. package/lib/cjs/Merging/KindOfQuantityMerger.js +2 -3
  139. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  140. package/lib/cjs/Merging/MixinMerger.js +2 -2
  141. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  142. package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -1
  143. package/lib/cjs/Merging/PhenomenonMerger.js +1 -2
  144. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  145. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -1
  146. package/lib/cjs/Merging/PropertyCategoryMerger.js +1 -2
  147. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
  148. package/lib/cjs/Merging/PropertyMerger.d.ts +2 -3
  149. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
  150. package/lib/cjs/Merging/PropertyMerger.js +21 -42
  151. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  152. package/lib/cjs/Merging/RelationshipClassMerger.d.ts +5 -3
  153. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
  154. package/lib/cjs/Merging/RelationshipClassMerger.js +35 -33
  155. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  156. package/lib/cjs/Merging/SchemaItemMerger.d.ts +3 -4
  157. package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
  158. package/lib/cjs/Merging/SchemaItemMerger.js +3 -2
  159. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  160. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  161. package/lib/cjs/Merging/SchemaMerger.js +8 -14
  162. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  163. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  164. package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -1
  165. package/lib/cjs/Merging/UnitSystemMerger.js +1 -2
  166. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
  167. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  168. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  169. package/lib/cjs/Validation/ECRules.js.map +1 -1
  170. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  171. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  172. package/lib/cjs/Validation/Rules.js.map +1 -1
  173. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  174. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  175. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  176. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  177. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  178. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  179. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  180. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  181. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  182. package/lib/cjs/ecschema-editing.d.ts +1 -0
  183. package/lib/cjs/ecschema-editing.d.ts.map +1 -1
  184. package/lib/cjs/ecschema-editing.js +1 -0
  185. package/lib/cjs/ecschema-editing.js.map +1 -1
  186. package/package.json +9 -9
  187. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -20,10 +20,7 @@ exports.entityClassMerger = {
20
20
  if (change.difference.mixins !== undefined) {
21
21
  for (const mixin of change.difference.mixins) {
22
22
  const mixinKey = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, mixin);
23
- const result = await context.editor.entities.addMixin(itemKey, mixinKey);
24
- if (result.errorMessage) {
25
- return result;
26
- }
23
+ await context.editor.entities.addMixin(itemKey, mixinKey);
27
24
  }
28
25
  }
29
26
  return (0, ClassMerger_1.modifyClass)(context, change, itemKey, item);
@@ -38,15 +35,11 @@ async function mergeClassMixins(context, change) {
38
35
  for (const mixinFullName of change.difference) {
39
36
  const mixinKey = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, mixinFullName);
40
37
  const entityKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
41
- const result = await context.editor.entities.addMixin(entityKey, mixinKey);
42
- if (result.errorMessage) {
43
- throw new Error(result.errorMessage);
44
- }
38
+ await context.editor.entities.addMixin(entityKey, mixinKey);
45
39
  }
46
- return {};
47
40
  }
48
41
  else {
49
- return { errorMessage: `Changing the entity class '${change.itemName}' mixins is not supported.` };
42
+ throw new Error(`Changing the entity class '${change.itemName}' mixins is not supported.`);
50
43
  }
51
44
  }
52
45
  exports.mergeClassMixins = mergeClassMixins;
@@ -1 +1 @@
1
- {"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;;AAKA,yDAAuF;AAEv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AM,SAAS,GAAG,IAAI,iCAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;YAC9E,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAC3E,IAAG,MAAM,CAAC,YAAY,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,YAAY,EAAE,8BAA8B,MAAM,CAAC,QAAQ,4BAA4B,EAAC,CAAC;IACpG,CAAC;AACH,CAAC;AAdD,4CAcC","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 SchemaItemMergerHandler, updateSchemaItemKey } from \"./SchemaItemMerger\";\nimport { type MutableEntityClass } from \"../Editing/Mutable/MutableEntityClass\";\nimport { modifyClass } from \"./ClassMerger\";\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\n\n/**\n * Defines a merge handler to merge Entity Class schema items.\n * @internal\n */\nexport const entityClassMerger: SchemaItemMergerHandler<EntityClassDifference> = {\n async add(context, change) {\n return context.editor.entities.createFromProps(context.targetSchemaKey, {\n name: change.itemName,\n schemaItemType: change.schemaType,\n\n ...change.difference,\n });\n },\n async modify(context, change, itemKey, item: MutableEntityClass) {\n if(change.difference.mixins !== undefined) {\n for(const mixin of change.difference.mixins) {\n const mixinKey = await updateSchemaItemKey(context, mixin);\n const result = await context.editor.entities.addMixin(itemKey, mixinKey);\n if(result.errorMessage) {\n return result;\n }\n }\n }\n\n return modifyClass(context, change, itemKey, item);\n },\n};\n\n/**\n * Merges Mixins to Entity Class schema items.\n * @internal\n */\nexport async function mergeClassMixins(context: SchemaMergeContext, change: EntityClassMixinDifference): Promise<SchemaItemEditResults> {\n if(change.changeType === \"add\") {\n for(const mixinFullName of change.difference) {\n const mixinKey = await updateSchemaItemKey(context, mixinFullName);\n const entityKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\n const result = await context.editor.entities.addMixin(entityKey, mixinKey);\n if(result.errorMessage) {\n throw new Error(result.errorMessage);\n }\n }\n return {};\n } else {\n return { errorMessage: `Changing the entity class '${change.itemName}' mixins is not supported.`};\n }\n}\n"]}
1
+ {"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;;AAKA,yDAAuF;AAEvF,+CAA4C;AAC5C,gEAAyD;AAGzD;;;GAGG;AACU,QAAA,iBAAiB,GAAmD;IAC/E,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YACtE,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YAEjC,GAAG,MAAM,CAAC,UAAU;SACrB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAwB;QAC7D,IAAG,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1C,KAAI,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;gBAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,sCAAmB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC3D,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC;QAED,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;CACF,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAAkC;IACpG,IAAG,MAAM,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;QAC/B,KAAI,MAAM,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YAC7C,MAAM,QAAQ,GAAG,MAAM,IAAA,sCAAmB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACnE,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;YAC9E,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,QAAQ,4BAA4B,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC;AAVD,4CAUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type EntityClassDifference, EntityClassMixinDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaItemMergerHandler, updateSchemaItemKey } from \"./SchemaItemMerger\";\r\nimport { type MutableEntityClass } from \"../Editing/Mutable/MutableEntityClass\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\n\r\n/**\r\n * Defines a merge handler to merge Entity Class schema items.\r\n * @internal\r\n */\r\nexport const entityClassMerger: SchemaItemMergerHandler<EntityClassDifference> = {\r\n async add(context, change) {\r\n return context.editor.entities.createFromProps(context.targetSchemaKey, {\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n\r\n ...change.difference,\r\n });\r\n },\r\n async modify(context, change, itemKey, item: MutableEntityClass) {\r\n if(change.difference.mixins !== undefined) {\r\n for(const mixin of change.difference.mixins) {\r\n const mixinKey = await updateSchemaItemKey(context, mixin);\r\n await context.editor.entities.addMixin(itemKey, mixinKey);\r\n }\r\n }\r\n\r\n return modifyClass(context, change, itemKey, item);\r\n },\r\n};\r\n\r\n/**\r\n * Merges Mixins to Entity Class schema items.\r\n * @internal\r\n */\r\nexport async function mergeClassMixins(context: SchemaMergeContext, change: EntityClassMixinDifference): Promise<void> {\r\n if(change.changeType === \"add\") {\r\n for(const mixinFullName of change.difference) {\r\n const mixinKey = await updateSchemaItemKey(context, mixinFullName);\r\n const entityKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n await context.editor.entities.addMixin(entityKey, mixinKey);\r\n }\r\n } else {\r\n throw new Error(`Changing the entity class '${change.itemName}' mixins is not supported.`);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EnumerationMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGlE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,uBAAuB,CAAC,qBAAqB,CAoC5E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,uBAAuB,CAAC,oBAAoB,CAgC1E,CAAC"}
1
+ {"version":3,"file":"EnumerationMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGlE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,uBAAuB,CAAC,qBAAqB,CAmC5E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,uBAAuB,CAAC,oBAAoB,CA8B1E,CAAC"}
@@ -13,13 +13,13 @@ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
13
13
  exports.enumerationMerger = {
14
14
  async add(context, change) {
15
15
  if (change.difference.type === undefined) {
16
- return { errorMessage: "Enumerations must define a type property" };
16
+ throw new Error("Enumerations must define a type property");
17
17
  }
18
18
  if (change.difference.isStrict === undefined) {
19
- return { errorMessage: "Enumerations must define whether enumeration is strict." };
19
+ throw new Error("Enumerations must define whether enumeration is strict.");
20
20
  }
21
21
  if (change.difference.enumerators === undefined) {
22
- return { errorMessage: "Enumerations must define at least ine enumerator." };
22
+ throw new Error("Enumerations must define at least ine enumerator.");
23
23
  }
24
24
  return context.editor.enumerations.createFromProps(context.targetSchemaKey, {
25
25
  ...change.difference,
@@ -32,7 +32,7 @@ exports.enumerationMerger = {
32
32
  },
33
33
  async modify(_context, change, itemKey, item) {
34
34
  if (change.difference.type !== undefined) {
35
- return { errorMessage: `The Enumeration ${itemKey.name} has an incompatible type. It must be "${(0, ecschema_metadata_1.primitiveTypeToString)(item.type)}", not "${change.difference.type}".` };
35
+ throw new Error(`The Enumeration ${itemKey.name} has an incompatible type. It must be "${(0, ecschema_metadata_1.primitiveTypeToString)(item.type)}", not "${change.difference.type}".`);
36
36
  }
37
37
  if (change.difference.label !== undefined) {
38
38
  item.setDisplayLabel(change.difference.label);
@@ -43,7 +43,6 @@ exports.enumerationMerger = {
43
43
  if (change.difference.isStrict !== undefined) {
44
44
  item.setIsStrict(change.difference.isStrict);
45
45
  }
46
- return { itemKey };
47
46
  },
48
47
  };
49
48
  /**
@@ -53,10 +52,10 @@ exports.enumerationMerger = {
53
52
  exports.enumeratorMerger = {
54
53
  async add(context, change) {
55
54
  if (change.difference.name === undefined) {
56
- return { errorMessage: "Enumerators must define a name" };
55
+ throw new Error("Enumerators must define a name");
57
56
  }
58
57
  if (change.difference.value === undefined) {
59
- return { errorMessage: "Enumerators must define a value" };
58
+ throw new Error("Enumerators must define a value");
60
59
  }
61
60
  const itemKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
62
61
  await context.editor.enumerations.addEnumerator(itemKey, {
@@ -65,11 +64,11 @@ exports.enumeratorMerger = {
65
64
  label: change.difference.label,
66
65
  description: change.difference.description,
67
66
  });
68
- return { itemKey };
67
+ return itemKey;
69
68
  },
70
69
  async modify(context, change, itemKey) {
71
70
  if (change.difference.value !== undefined) {
72
- return { errorMessage: `Failed to merge enumerator attribute, Enumerator "${change.path}" has different values.` };
71
+ throw new Error(`Failed to merge enumerator attribute, Enumerator "${change.path}" has different values.`);
73
72
  }
74
73
  if (change.difference.description !== undefined) {
75
74
  await context.editor.enumerations.setEnumeratorDescription(itemKey, change.path, change.difference.description);
@@ -77,7 +76,6 @@ exports.enumeratorMerger = {
77
76
  if (change.difference.label !== undefined) {
78
77
  await context.editor.enumerations.setEnumeratorLabel(itemKey, change.path, change.difference.label);
79
78
  }
80
- return { itemKey };
81
79
  },
82
80
  };
83
81
  //# sourceMappingURL=EnumerationMerger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAgF;AAKhF;;;GAGG;AACU,QAAA,iBAAiB,GAAmD;IAC/E,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAA6B;QAC9C,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CA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qD,MAAM,CAAC,IAAI,yBAAyB,EAAE,CAAC;QACrH,CAAC;QAED,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAClH,CAAC;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACzC,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACtG,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { primitiveTypeToString, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport type { EnumerationDifference, EnumeratorDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaItemMergerHandler } from \"./SchemaItemMerger\";\nimport type { MutableEnumeration } from \"../Editing/Mutable/MutableEnumeration\";\n\n/**\n * Defines a merge handler to merge Enumeration schema items.\n * @internal\n */\nexport const enumerationMerger: SchemaItemMergerHandler<EnumerationDifference> = {\n async add(context, change: EnumerationDifference) {\n if (change.difference.type === undefined) {\n return { errorMessage: \"Enumerations must define a type property\" };\n }\n if (change.difference.isStrict === undefined) {\n return { errorMessage: \"Enumerations must define whether enumeration is strict.\" };\n }\n if (change.difference.enumerators === undefined) {\n return { errorMessage: \"Enumerations must define at least ine enumerator.\" };\n }\n\n return 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 async modify(_context, change, itemKey, item: MutableEnumeration) {\n if(change.difference.type !== undefined) {\n return { errorMessage: `The Enumeration ${itemKey.name} has an incompatible type. It must be \"${primitiveTypeToString(item.type!)}\", not \"${change.difference.type}\".` };\n }\n if(change.difference.label !== undefined) {\n item.setDisplayLabel(change.difference.label);\n }\n if(change.difference.description !== undefined) {\n item.setDescription(change.difference.description);\n }\n if(change.difference.isStrict !== undefined) {\n item.setIsStrict(change.difference.isStrict);\n }\n return { itemKey};\n },\n};\n\n/**\n * Defines a merge handler to merge Enumeration schema items.\n * @internal\n */\nexport const enumeratorMerger: SchemaItemMergerHandler<EnumeratorDifference> = {\n async add(context, change) {\n if (change.difference.name === undefined) {\n return { errorMessage: \"Enumerators must define a name\" };\n }\n if (change.difference.value === undefined) {\n return { errorMessage: \"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 return { itemKey };\n },\n async modify(context, change, itemKey) {\n if(change.difference.value !== undefined) {\n return { errorMessage: `Failed to merge enumerator attribute, Enumerator \"${change.path}\" has different values.` };\n }\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 return { itemKey };\n },\n};\n"]}
1
+ {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAgF;AAKhF;;;GAGG;AACU,QAAA,iBAAiB,GAAmD;IAC/E,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAA6B;QAC9C,IAAI,M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,MAAM,CAAC,IAAI,yBAAyB,CAAC,CAAC;QAC7G,CAAC;QAED,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAClH,CAAC;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACzC,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACtG,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { primitiveTypeToString, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport type { EnumerationDifference, EnumeratorDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaItemMergerHandler } from \"./SchemaItemMerger\";\r\nimport type { MutableEnumeration } from \"../Editing/Mutable/MutableEnumeration\";\r\n\r\n/**\r\n * Defines a merge handler to merge Enumeration schema items.\r\n * @internal\r\n */\r\nexport const enumerationMerger: SchemaItemMergerHandler<EnumerationDifference> = {\r\n async add(context, change: EnumerationDifference) {\r\n if (change.difference.type === undefined) {\r\n throw new Error(\"Enumerations must define a type property\");\r\n }\r\n if (change.difference.isStrict === undefined) {\r\n throw new Error(\"Enumerations must define whether enumeration is strict.\");\r\n }\r\n if (change.difference.enumerators === undefined) {\r\n throw new Error(\"Enumerations must define at least ine enumerator.\");\r\n }\r\n\r\n return context.editor.enumerations.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n type: change.difference.type,\r\n isStrict: change.difference.isStrict,\r\n enumerators: change.difference.enumerators,\r\n });\r\n },\r\n async modify(_context, change, itemKey, item: MutableEnumeration) {\r\n if(change.difference.type !== undefined) {\r\n throw new Error(`The Enumeration ${itemKey.name} has an incompatible type. It must be \"${primitiveTypeToString(item.type!)}\", not \"${change.difference.type}\".`);\r\n }\r\n if(change.difference.label !== undefined) {\r\n item.setDisplayLabel(change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n item.setDescription(change.difference.description);\r\n }\r\n if(change.difference.isStrict !== undefined) {\r\n item.setIsStrict(change.difference.isStrict);\r\n }\r\n },\r\n};\r\n\r\n/**\r\n * Defines a merge handler to merge Enumeration schema items.\r\n * @internal\r\n */\r\nexport const enumeratorMerger: SchemaItemMergerHandler<EnumeratorDifference> = {\r\n async add(context, change) {\r\n if (change.difference.name === undefined) {\r\n throw new Error(\"Enumerators must define a name\");\r\n }\r\n if (change.difference.value === undefined) {\r\n throw new Error(\"Enumerators must define a value\");\r\n }\r\n\r\n const itemKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n await context.editor.enumerations.addEnumerator(itemKey, {\r\n name: change.difference.name,\r\n value: change.difference.value,\r\n label: change.difference.label,\r\n description: change.difference.description,\r\n });\r\n return itemKey;\r\n },\r\n async modify(context, change, itemKey) {\r\n if(change.difference.value !== undefined) {\r\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${change.path}\" has different values.`);\r\n }\r\n\r\n if(change.difference.description !== undefined) {\r\n await context.editor.enumerations.setEnumeratorDescription(itemKey, change.path, change.difference.description);\r\n }\r\n if(change.difference.label !== undefined) {\r\n await context.editor.enumerations.setEnumeratorLabel(itemKey, change.path, change.difference.label);\r\n }\r\n },\r\n};\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantityMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EAAE,KAAK,uBAAuB,EAA4B,MAAM,oBAAoB,CAAC;AAI5F;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,uBAAuB,CAAC,wBAAwB,CA4ClF,CAAC"}
1
+ {"version":3,"file":"KindOfQuantityMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EAAE,KAAK,uBAAuB,EAA4B,MAAM,oBAAoB,CAAC;AAI5F;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,uBAAuB,CAAC,wBAAwB,CA2ClF,CAAC"}
@@ -9,10 +9,10 @@ const SchemaItemMerger_1 = require("./SchemaItemMerger");
9
9
  exports.kindOfQuantityMerger = {
10
10
  async add(context, change) {
11
11
  if (change.difference.persistenceUnit === undefined) {
12
- return { errorMessage: "KindOfQuantity must define persistenceUnit" };
12
+ throw new Error("KindOfQuantity must define persistenceUnit");
13
13
  }
14
14
  if (change.difference.relativeError === undefined) {
15
- return { errorMessage: "KindOfQuantity must define relativeError" };
15
+ throw new Error("KindOfQuantity must define relativeError");
16
16
  }
17
17
  change.difference.persistenceUnit = await (0, SchemaItemMerger_1.updateSchemaItemFullName)(context, change.difference.persistenceUnit);
18
18
  if (change.difference.presentationUnits) {
@@ -48,7 +48,6 @@ exports.kindOfQuantityMerger = {
48
48
  // TODO: It should be checked if the unit is the same, but referring to the source schema.
49
49
  throw new Error(`Changing the kind of quantity '${itemKey.name}' persistenceUnit is not supported.`);
50
50
  }
51
- return { itemKey };
52
51
  },
53
52
  };
54
53
  async function updateOverrideFormat(context, formatString) {
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";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AAK,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,aAAa,GAAG,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE9E,MAAM,aAAa,GAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,KAAI,IAAI,KAAK,GAAC,CAAC,EAAE,KAAK,GAAE,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACtD,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClE,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACrE,CAAC;IAED,OAAO,GAAG,aAAa,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACtE,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 } from \"../Differencing/SchemaDifference\";\nimport { type SchemaItemMergerHandler, updateSchemaItemFullName } from \"./SchemaItemMerger\";\nimport { type MutableKindOfQuantity } from \"../Editing/Mutable/MutableKindOfQuantity\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\n\n/**\n * Defines a merge handler to merge KindOfQuantity schema items.\n * @internal\n */\nexport const kindOfQuantityMerger: SchemaItemMergerHandler<KindOfQuantityDifference> = {\n async add(context, change) {\n if (change.difference.persistenceUnit === undefined) {\n return { errorMessage: \"KindOfQuantity must define persistenceUnit\" };\n }\n if (change.difference.relativeError === undefined) {\n return { errorMessage: \"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 change.difference.presentationUnits[index] = await updateOverrideFormat(context, change.difference.presentationUnits[index]);\n }\n } else {\n change.difference.presentationUnits = await updateOverrideFormat(context, change.difference.presentationUnits);\n }\n }\n\n return 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 async modify(_context, change, itemKey, item: MutableKindOfQuantity) {\n if(change.difference.label !== undefined) {\n item.setDisplayLabel(change.difference.label);\n }\n if(change.difference.description !== undefined) {\n item.setDescription(change.difference.description);\n }\n if(change.difference.relativeError !== undefined) {\n item.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 return { itemKey };\n },\n};\n\nasync function updateOverrideFormat(context: SchemaMergeContext, formatString: string) {\n // https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string\n const match = formatString.match(/^([^(]+)\\((\\d+)\\)\\[(.*)\\]$/);\n if(match === null) {\n return formatString;\n }\n\n const originalFormat = match[1];\n const updatedFormat = await updateSchemaItemFullName(context, originalFormat);\n\n const unitOverrides = match[3].split(\"][\");\n for(let index=0; index< unitOverrides.length; index++) {\n const [unit, label] = unitOverrides[index].split(\"|\");\n const updatedUnit = await updateSchemaItemFullName(context, unit);\n unitOverrides[index] = `${updatedUnit}${label ? `|${label}` : \"\"}`;\n }\n\n return `${updatedFormat}(${match[2]})[${un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AAK,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,aAAa,GAAG,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE9E,MAAM,aAAa,GAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,KAAI,IAAI,KAAK,GAAC,CAAC,EAAE,KAAK,GAAE,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACtD,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClE,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACrE,CAAC;IAED,OAAO,GAAG,aAAa,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACtE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type KindOfQuantityDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaItemMergerHandler, updateSchemaItemFullName } from \"./SchemaItemMerger\";\r\nimport { type MutableKindOfQuantity } from \"../Editing/Mutable/MutableKindOfQuantity\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\n\r\n/**\r\n * Defines a merge handler to merge KindOfQuantity schema items.\r\n * @internal\r\n */\r\nexport const kindOfQuantityMerger: SchemaItemMergerHandler<KindOfQuantityDifference> = {\r\n async add(context, change) {\r\n if (change.difference.persistenceUnit === undefined) {\r\n throw new Error(\"KindOfQuantity must define persistenceUnit\");\r\n }\r\n if (change.difference.relativeError === undefined) {\r\n throw new Error(\"KindOfQuantity must define relativeError\");\r\n }\r\n change.difference.persistenceUnit = await updateSchemaItemFullName(context, change.difference.persistenceUnit);\r\n if(change.difference.presentationUnits) {\r\n if(Array.isArray(change.difference.presentationUnits)) {\r\n for(let index = 0; index < change.difference.presentationUnits.length; index++) {\r\n change.difference.presentationUnits[index] = await updateOverrideFormat(context, change.difference.presentationUnits[index]);\r\n }\r\n } else {\r\n change.difference.presentationUnits = await updateOverrideFormat(context, change.difference.presentationUnits);\r\n }\r\n }\r\n\r\n return context.editor.kindOfQuantities.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n persistenceUnit: change.difference.persistenceUnit,\r\n presentationUnits: change.difference.presentationUnits,\r\n relativeError: change.difference.relativeError,\r\n });\r\n },\r\n async modify(_context, change, itemKey, item: MutableKindOfQuantity) {\r\n if(change.difference.label !== undefined) {\r\n item.setDisplayLabel(change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n item.setDescription(change.difference.description);\r\n }\r\n if(change.difference.relativeError !== undefined) {\r\n item.setRelativeError(change.difference.relativeError);\r\n }\r\n if(change.difference.persistenceUnit !== undefined) {\r\n // TODO: It should be checked if the unit is the same, but referring to the source schema.\r\n throw new Error(`Changing the kind of quantity '${itemKey.name}' persistenceUnit is not supported.`);\r\n }\r\n },\r\n};\r\n\r\nasync function updateOverrideFormat(context: SchemaMergeContext, formatString: string) {\r\n // https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string\r\n const match = formatString.match(/^([^(]+)\\((\\d+)\\)\\[(.*)\\]$/);\r\n if(match === null) {\r\n return formatString;\r\n }\r\n\r\n const originalFormat = match[1];\r\n const updatedFormat = await updateSchemaItemFullName(context, originalFormat);\r\n\r\n const unitOverrides = match[3].split(\"][\");\r\n for(let index=0; index< unitOverrides.length; index++) {\r\n const [unit, label] = unitOverrides[index].split(\"|\");\r\n const updatedUnit = await updateSchemaItemFullName(context, unit);\r\n unitOverrides[index] = `${updatedUnit}${label ? `|${label}` : \"\"}`;\r\n }\r\n\r\n return `${updatedFormat}(${match[2]})[${unitOverrides.join(\"][\")}]`;\r\n}\r\n"]}
@@ -10,7 +10,7 @@ const ClassMerger_1 = require("./ClassMerger");
10
10
  exports.mixinClassMerger = {
11
11
  async add(context, change) {
12
12
  if (change.difference.appliesTo === undefined) {
13
- return { errorMessage: "Mixin must define appliesTo" };
13
+ throw new Error("Mixin must define appliesTo");
14
14
  }
15
15
  return context.editor.mixins.createFromProps(context.targetSchemaKey, {
16
16
  ...change.difference,
@@ -24,7 +24,7 @@ exports.mixinClassMerger = {
24
24
  const appliesTo = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, change.difference.appliesTo);
25
25
  const currentValue = await item.appliesTo;
26
26
  if (currentValue !== undefined && !appliesTo.matches(currentValue.key)) {
27
- return { errorMessage: `Changing the mixin '${itemKey.name}' appliesTo is not supported.` };
27
+ throw new Error(`Changing the mixin '${itemKey.name}' appliesTo is not supported.`);
28
28
  }
29
29
  }
30
30
  return (0, ClassMerger_1.modifyClass)(context, change, itemKey, item);
@@ -1 +1 @@
1
- {"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;;AAKA,yDAAiH;AAEjH,+CAA4C;AAE5C;;;GAGG;AACU,QAAA,gBAAgB,GAAkD;IAC7E,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC9C,OAAO,EAAE,YAAY,EAAE,6BAA6B,EAAE,CAAC;QACzD,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YACpE,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YACjC,SAAS,EAAE,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;SAChF,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAkB;QACvD,IAAG,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7C,MAAM,SAAS,GAAG,MAAM,IAAA,sCAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;YAClF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC;YAC1C,IAAI,YAAY,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvE,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,+BAA+B,EAAE,CAAC;YAC9F,CAAC;QACH,CAAC;QACD,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { type MixinClassDifference } from \"../Differencing/SchemaDifference\";\nimport { type SchemaItemMergerHandler, updateSchemaItemFullName, updateSchemaItemKey } from \"./SchemaItemMerger\";\nimport { type MutableMixin } from \"../Editing/Mutable/MutableMixin\";\nimport { modifyClass } from \"./ClassMerger\";\n\n/**\n * Defines a merge handler to merge Mixin schema items.\n * @internal\n */\nexport const mixinClassMerger: SchemaItemMergerHandler<MixinClassDifference> = {\n async add(context, change) {\n if (change.difference.appliesTo === undefined) {\n return { errorMessage: \"Mixin must define appliesTo\" };\n }\n return context.editor.mixins.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n appliesTo: await updateSchemaItemFullName(context, change.difference.appliesTo),\n });\n },\n async modify(context, change, itemKey, item: MutableMixin) {\n if(change.difference.appliesTo !== undefined) {\n const appliesTo = await updateSchemaItemKey(context, change.difference.appliesTo);\n const currentValue = await item.appliesTo;\n if (currentValue !== undefined && !appliesTo.matches(currentValue.key)) {\n return { errorMessage: `Changing the mixin '${itemKey.name}' appliesTo is not supported.` };\n }\n }\n return modifyClass(context, change, itemKey, item);\n },\n};\n\n"]}
1
+ {"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;;AAKA,yDAAiH;AAEjH,+CAA4C;AAE5C;;;GAGG;AACU,QAAA,gBAAgB,GAAkD;IAC7E,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YACpE,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YACjC,SAAS,EAAE,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;SAChF,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAkB;QACvD,IAAG,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC7C,MAAM,SAAS,GAAG,MAAM,IAAA,sCAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;YAClF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC;YAC1C,IAAI,YAAY,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvE,MAAM,IAAI,KAAK,CAAC,uBAAuB,OAAO,CAAC,IAAI,+BAA+B,CAAC,CAAC;YACtF,CAAC;QACH,CAAC;QACD,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type MixinClassDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaItemMergerHandler, updateSchemaItemFullName, updateSchemaItemKey } from \"./SchemaItemMerger\";\r\nimport { type MutableMixin } from \"../Editing/Mutable/MutableMixin\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\n\r\n/**\r\n * Defines a merge handler to merge Mixin schema items.\r\n * @internal\r\n */\r\nexport const mixinClassMerger: SchemaItemMergerHandler<MixinClassDifference> = {\r\n async add(context, change) {\r\n if (change.difference.appliesTo === undefined) {\r\n throw new Error(\"Mixin must define appliesTo\");\r\n }\r\n return context.editor.mixins.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n appliesTo: await updateSchemaItemFullName(context, change.difference.appliesTo),\r\n });\r\n },\r\n async modify(context, change, itemKey, item: MutableMixin) {\r\n if(change.difference.appliesTo !== undefined) {\r\n const appliesTo = await updateSchemaItemKey(context, change.difference.appliesTo);\r\n const currentValue = await item.appliesTo;\r\n if (currentValue !== undefined && !appliesTo.matches(currentValue.key)) {\r\n throw new Error(`Changing the mixin '${itemKey.name}' appliesTo is not supported.`);\r\n }\r\n }\r\n return modifyClass(context, change, itemKey, item);\r\n },\r\n};\r\n\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PhenomenonMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,KAAK,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAGjE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,uBAAuB,CAAC,oBAAoB,CA6B1E,CAAC"}
1
+ {"version":3,"file":"PhenomenonMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,KAAK,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAGjE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,uBAAuB,CAAC,oBAAoB,CA4B1E,CAAC"}
@@ -9,7 +9,7 @@ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
9
9
  exports.phenomenonMerger = {
10
10
  add: async (context, change) => {
11
11
  if (change.difference.definition === undefined) {
12
- return { errorMessage: "Phenomenon must define definition" };
12
+ throw new Error("Phenomenon must define definition");
13
13
  }
14
14
  return context.editor.phenomenons.createFromProps(context.targetSchemaKey, {
15
15
  ...change.difference,
@@ -31,7 +31,6 @@ exports.phenomenonMerger = {
31
31
  throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `The Phenomenon ${itemKey.name} has an invalid 'definition' attribute.`);
32
32
  await phenomenon.setDefinition(change.difference.definition);
33
33
  }
34
- return { itemKey };
35
34
  },
36
35
  };
37
36
  //# sourceMappingURL=PhenomenonMerger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":";;;AAOA,gEAA2E;AAE3E;;;GAGG;AACU,QAAA,gBAAgB,GAAkD;IAC7E,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7B,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAC/C,OAAO,EAAE,YAAY,EAAE,mCAAmC,EAAE,CAAC;QAC/D,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YACzE,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YACjC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;SACzC,CAAC,CAAC;IACL,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAA6B,EAAE,EAAE;QACzE,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACzC,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACtD,CAAC;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC/C,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3D,CAAC;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9C,kFAAkF;YAClF,IAAI,UAAU,CAAC,UAAU,KAAK,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE;gBACpH,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,kBAAkB,OAAO,CAAC,IAAI,yCAAyC,CAAC,CAAC;YAEnI,MAAM,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { type PhenomenonDifference } from \"../Differencing/SchemaDifference\";\nimport { type MutablePhenomenon } from \"../Editing/Mutable/MutablePhenomenon\";\nimport { type SchemaItemMergerHandler} from \"./SchemaItemMerger\";\nimport { ECObjectsError, ECObjectsStatus } from \"@itwin/ecschema-metadata\";\n\n/**\n * Defines a merge handler to merge Phenomenon schema items.\n * @internal\n */\nexport const phenomenonMerger: SchemaItemMergerHandler<PhenomenonDifference> = {\n add: async (context, change) => {\n if (change.difference.definition === undefined) {\n return { errorMessage: \"Phenomenon must define definition\" };\n }\n\n return context.editor.phenomenons.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n definition: change.difference.definition,\n });\n },\n modify: async (_context, change, itemKey, phenomenon: MutablePhenomenon) => {\n if(change.difference.label !== undefined) {\n phenomenon.setDisplayLabel(change.difference.label);\n }\n if(change.difference.description !== undefined) {\n phenomenon.setDescription(change.difference.description);\n }\n if(change.difference.definition !== undefined) {\n // It would be better if the validation would be part of phenomenon.setDefinition.\n if (phenomenon.definition !== \"\" && change.difference.definition.toLowerCase() !== phenomenon.definition.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Phenomenon ${itemKey.name} has an invalid 'definition' attribute.`);\n\n await phenomenon.setDefinition(change.difference.definition);\n }\n return { itemKey };\n },\n};\n"]}
1
+ {"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":";;;AAOA,gEAA2E;AAE3E;;;GAGG;AACU,QAAA,gBAAgB,GAAkD;IAC7E,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7B,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YACzE,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YACjC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;SACzC,CAAC,CAAC;IACL,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAA6B,EAAE,EAAE;QACzE,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACzC,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACtD,CAAC;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC/C,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3D,CAAC;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9C,kFAAkF;YAClF,IAAI,UAAU,CAAC,UAAU,KAAK,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE;gBACpH,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,kBAAkB,OAAO,CAAC,IAAI,yCAAyC,CAAC,CAAC;YAEnI,MAAM,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type PhenomenonDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type MutablePhenomenon } from \"../Editing/Mutable/MutablePhenomenon\";\r\nimport { type SchemaItemMergerHandler} from \"./SchemaItemMerger\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Defines a merge handler to merge Phenomenon schema items.\r\n * @internal\r\n */\r\nexport const phenomenonMerger: SchemaItemMergerHandler<PhenomenonDifference> = {\r\n add: async (context, change) => {\r\n if (change.difference.definition === undefined) {\r\n throw new Error(\"Phenomenon must define definition\");\r\n }\r\n\r\n return context.editor.phenomenons.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n definition: change.difference.definition,\r\n });\r\n },\r\n modify: async (_context, change, itemKey, phenomenon: MutablePhenomenon) => {\r\n if(change.difference.label !== undefined) {\r\n phenomenon.setDisplayLabel(change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n phenomenon.setDescription(change.difference.description);\r\n }\r\n if(change.difference.definition !== undefined) {\r\n // It would be better if the validation would be part of phenomenon.setDefinition.\r\n if (phenomenon.definition !== \"\" && change.difference.definition.toLowerCase() !== phenomenon.definition.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Phenomenon ${itemKey.name} has an invalid 'definition' attribute.`);\r\n\r\n await phenomenon.setDefinition(change.difference.definition);\r\n }\r\n },\r\n};\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyCategoryMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,uBAAuB,CAAC,0BAA0B,CA0BtF,CAAC"}
1
+ {"version":3,"file":"PropertyCategoryMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,uBAAuB,CAAC,0BAA0B,CAyBtF,CAAC"}
@@ -8,7 +8,7 @@ exports.propertyCategoryMerger = void 0;
8
8
  exports.propertyCategoryMerger = {
9
9
  async add(context, change) {
10
10
  if (change.difference.priority === undefined) {
11
- return { errorMessage: "PropertyCategory must define priority" };
11
+ throw new Error("PropertyCategory must define priority");
12
12
  }
13
13
  return context.editor.propertyCategories.createFromProps(context.targetSchemaKey, {
14
14
  ...change.difference,
@@ -28,7 +28,6 @@ exports.propertyCategoryMerger = {
28
28
  // TODO: inconsistency: setPriority does not return a result whether the priority was set successfully.
29
29
  await context.editor.propertyCategories.setPriority(itemKey, change.difference.priority);
30
30
  }
31
- return { itemKey };
32
31
  },
33
32
  };
34
33
  //# sourceMappingURL=PropertyCategoryMerger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyCategoryMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACU,QAAA,sBAAsB,GAAwD;IACzF,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC7C,OAAO,EAAE,YAAY,EAAE,uCAAuC,EAAE,CAAC;QACnE,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YAChF,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YACjC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;SACrC,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAA6B;QAClE,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACzC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC/C,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACrD,CAAC;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5C,uGAAuG;YACvG,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC3F,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { type MutablePropertyCategory } from \"../Editing/Mutable/MutablePropertyCategory\";\nimport { type PropertyCategoryDifference } from \"../Differencing/SchemaDifference\";\nimport { type SchemaItemMergerHandler } from \"./SchemaItemMerger\";\n\n/**\n * Defines a merge handler to merge PropertyCategory schema items.\n * @internal\n */\nexport const propertyCategoryMerger: SchemaItemMergerHandler<PropertyCategoryDifference> = {\n async add(context, change) {\n if (change.difference.priority === undefined) {\n return { errorMessage: \"PropertyCategory must define priority\" };\n }\n\n return context.editor.propertyCategories.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n priority: change.difference.priority,\n });\n },\n async modify(context, change, itemKey, item: MutablePropertyCategory) {\n if(change.difference.label !== undefined) {\n item.setDisplayLabel(change.difference.label);\n }\n if(change.difference.description !== undefined) {\n item.setDescription(change.difference.description);\n }\n if(change.difference.priority !== undefined) {\n // TODO: inconsistency: setPriority does not return a result whether the priority was set successfully.\n await context.editor.propertyCategories.setPriority(itemKey, change.difference.priority);\n }\n return { itemKey };\n },\n};\n"]}
1
+ {"version":3,"file":"PropertyCategoryMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACU,QAAA,sBAAsB,GAAwD;IACzF,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YAChF,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YACjC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;SACrC,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAA6B;QAClE,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACzC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC/C,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACrD,CAAC;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5C,uGAAuG;YACvG,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type MutablePropertyCategory } from \"../Editing/Mutable/MutablePropertyCategory\";\r\nimport { type PropertyCategoryDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaItemMergerHandler } from \"./SchemaItemMerger\";\r\n\r\n/**\r\n * Defines a merge handler to merge PropertyCategory schema items.\r\n * @internal\r\n */\r\nexport const propertyCategoryMerger: SchemaItemMergerHandler<PropertyCategoryDifference> = {\r\n async add(context, change) {\r\n if (change.difference.priority === undefined) {\r\n throw new Error(\"PropertyCategory must define priority\");\r\n }\r\n\r\n return context.editor.propertyCategories.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n priority: change.difference.priority,\r\n });\r\n },\r\n async modify(context, change, itemKey, item: MutablePropertyCategory) {\r\n if(change.difference.label !== undefined) {\r\n item.setDisplayLabel(change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n item.setDescription(change.difference.description);\r\n }\r\n if(change.difference.priority !== undefined) {\r\n // TODO: inconsistency: setPriority does not return a result whether the priority was set successfully.\r\n await context.editor.propertyCategories.setPriority(itemKey, change.difference.priority);\r\n }\r\n },\r\n};\r\n"]}
@@ -1,13 +1,12 @@
1
- import type { SchemaEditResults } from "../ecschema-editing";
2
1
  import type { SchemaMergeContext } from "./SchemaMerger";
3
2
  import type { ClassItemDifference, ClassPropertyDifference } from "../Differencing/SchemaDifference";
4
3
  import { SchemaItemKey } from "@itwin/ecschema-metadata";
5
4
  /**
6
5
  * @internal
7
6
  */
8
- export declare function mergePropertyDifference(context: SchemaMergeContext, change: ClassPropertyDifference): Promise<SchemaEditResults>;
7
+ export declare function mergePropertyDifference(context: SchemaMergeContext, change: ClassPropertyDifference): Promise<void>;
9
8
  /**
10
9
  * @internal
11
10
  */
12
- export declare function mergeClassProperties(context: SchemaMergeContext, change: ClassItemDifference, itemKey: SchemaItemKey): Promise<SchemaEditResults>;
11
+ export declare function mergeClassProperties(context: SchemaMergeContext, change: ClassItemDifference, itemKey: SchemaItemKey): Promise<void>;
13
12
  //# sourceMappingURL=PropertyMerger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAkB,MAAM,kCAAkC,CAAC;AACrH,OAAO,EAA8M,aAAa,EAAoD,MAAM,0BAA0B,CAAC;AAgBvT;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAMtI;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAQvJ"}
1
+ {"version":3,"file":"PropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAkB,MAAM,kCAAkC,CAAC;AACrH,OAAO,EAA8M,aAAa,EAAoD,MAAM,0BAA0B,CAAC;AAgBvT;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzH;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1I"}
@@ -20,12 +20,8 @@ exports.mergePropertyDifference = mergePropertyDifference;
20
20
  */
21
21
  async function mergeClassProperties(context, change, itemKey) {
22
22
  for (const property of change.difference.properties || []) {
23
- const result = await mergeClassProperty(context, change, itemKey, property);
24
- if (result.errorMessage) {
25
- return result;
26
- }
23
+ await mergeClassProperty(context, change, itemKey, property);
27
24
  }
28
- return {};
29
25
  }
30
26
  exports.mergeClassProperties = mergeClassProperties;
31
27
  async function mergeClassProperty(context, change, itemKey, property) {
@@ -40,26 +36,13 @@ async function addClassProperty(context, itemKey, property) {
40
36
  if (property.kindOfQuantity !== undefined) {
41
37
  property.kindOfQuantity = await (0, SchemaItemMerger_1.updateSchemaItemFullName)(context, property.kindOfQuantity);
42
38
  }
43
- const createResult = await createProperty(context, itemKey, property);
44
- if (createResult.errorMessage) {
45
- return createResult;
46
- }
39
+ await createProperty(context, itemKey, property);
47
40
  if (property.customAttributes !== undefined) {
48
- const result = await (0, CustomAttributeMerger_1.applyCustomAttributes)(context, property.customAttributes, async (ca) => {
49
- try {
50
- const classEditor = await getClassEditor(context, itemKey);
51
- await classEditor.properties.addCustomAttribute(itemKey, property.name, ca);
52
- return {};
53
- }
54
- catch (e) {
55
- return { errorMessage: e.message };
56
- }
41
+ await (0, CustomAttributeMerger_1.applyCustomAttributes)(context, property.customAttributes, async (ca) => {
42
+ const classEditor = await getClassEditor(context, itemKey);
43
+ await classEditor.properties.addCustomAttribute(itemKey, property.name, ca);
57
44
  });
58
- if (result.errorMessage) {
59
- return result;
60
- }
61
45
  }
62
- return {};
63
46
  }
64
47
  async function createProperty(context, itemKey, property) {
65
48
  if (enumerationProperty.is(property)) {
@@ -80,13 +63,13 @@ async function modifyClassProperty(context, itemKey, propertyProps) {
80
63
  const ecClass = await context.editor.schemaContext.getSchemaItem(itemKey);
81
64
  const property = await ecClass.getProperty(propertyProps.name);
82
65
  if (property === undefined) {
83
- return { errorMessage: `Couldn't find property ${propertyProps.name} on class ${itemKey.name}` };
66
+ throw new Error(`Couldn't find property ${propertyProps.name} on class ${itemKey.name}`);
84
67
  }
85
68
  if (propertyProps.type !== undefined) {
86
- return { errorMessage: `Changing the property '${property.fullName}' type is not supported.` };
69
+ throw new Error(`Changing the property '${property.fullName}' type is not supported.`);
87
70
  }
88
71
  if (propertyProps.kindOfQuantity !== undefined) {
89
- return { errorMessage: `Changing the property '${property.fullName}' kind of quantity is not supported.` };
72
+ throw new Error(`Changing the property '${property.fullName}' kind of quantity is not supported.`);
90
73
  }
91
74
  const classEditor = await getClassEditor(context, ecClass);
92
75
  if (propertyProps.description !== undefined) {
@@ -120,7 +103,6 @@ async function modifyClassProperty(context, itemKey, propertyProps) {
120
103
  if (property.isStruct()) {
121
104
  return structProperty.merge(context, itemKey, property, propertyProps);
122
105
  }
123
- return {};
124
106
  }
125
107
  async function getClassEditor(context, ecClass) {
126
108
  const schemaItemType = ecschema_metadata_1.ECClass.isECClass(ecClass)
@@ -163,17 +145,17 @@ const enumerationProperty = {
163
145
  const enumerationKey = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, property.typeName);
164
146
  const enumerationType = await context.editor.schemaContext.getSchemaItem(enumerationKey);
165
147
  if (enumerationType === undefined) {
166
- return { errorMessage: `Unable to locate the enumeration class ${enumerationKey.name} in the context schema.` };
148
+ throw new Error(`Unable to locate the enumeration class ${enumerationKey.name} in the context schema.`);
167
149
  }
168
150
  property.typeName = enumerationKey.fullName;
169
151
  const classEditor = await getClassEditor(context, itemKey);
170
- return arrayProperty.is(property)
171
- ? classEditor.createEnumerationArrayPropertyFromProps(itemKey, property.name, enumerationType, property)
172
- : classEditor.createEnumerationPropertyFromProps(itemKey, property.name, enumerationType, property);
152
+ arrayProperty.is(property)
153
+ ? await classEditor.createEnumerationArrayPropertyFromProps(itemKey, property.name, enumerationType, property)
154
+ : await classEditor.createEnumerationPropertyFromProps(itemKey, property.name, enumerationType, property);
173
155
  },
174
156
  async merge(context, itemKey, property, props) {
175
157
  if ("enumeration" in props && props.enumeration !== undefined) {
176
- return { errorMessage: `Changing the property '${property.fullName}' enumeration is not supported.` };
158
+ throw new Error(`Changing the property '${property.fullName}' enumeration is not supported.`);
177
159
  }
178
160
  return primitiveProperty.merge(context, itemKey, property, props);
179
161
  },
@@ -186,7 +168,7 @@ const navigationProperty = {
186
168
  const relationshipKey = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, property.relationshipName);
187
169
  const relationshipType = await context.editor.schemaContext.getSchemaItem(relationshipKey);
188
170
  if (relationshipType === undefined) {
189
- return { errorMessage: `Unable to locate the relationship class ${relationshipKey.name} in the context schema.` };
171
+ throw new Error(`Unable to locate the relationship class ${relationshipKey.name} in the context schema.`);
190
172
  }
191
173
  property.relationshipName = relationshipKey.fullName;
192
174
  const ecClass = await context.editor.schemaContext.getSchemaItem(itemKey);
@@ -196,16 +178,15 @@ const navigationProperty = {
196
178
  return context.editor.mixins.createNavigationPropertyFromProps(itemKey, property);
197
179
  if (ecClass.schemaItemType === ecschema_metadata_1.SchemaItemType.RelationshipClass)
198
180
  return context.editor.relationships.createNavigationPropertyFromProps(itemKey, property);
199
- return { errorMessage: `Navigation property can't be added to ${ecClass.schemaItemType}.` };
181
+ throw new Error(`Navigation property can't be added to ${ecClass.schemaItemType}.`);
200
182
  },
201
183
  async merge(_context, _itemKey, property, props) {
202
184
  if (props.direction !== undefined) {
203
- return { errorMessage: `Changing the property '${property.fullName}' direction is not supported.` };
185
+ throw new Error(`Changing the property '${property.fullName}' direction is not supported.`);
204
186
  }
205
187
  if ("relationshipClass" in props && props.relationshipClass !== undefined) {
206
- return { errorMessage: `Changing the property '${property.fullName}' relationship class is not supported.` };
188
+ throw new Error(`Changing the property '${property.fullName}' relationship class is not supported.`);
207
189
  }
208
- return {};
209
190
  },
210
191
  };
211
192
  const primitiveProperty = {
@@ -215,7 +196,7 @@ const primitiveProperty = {
215
196
  async add(context, itemKey, property) {
216
197
  const propertyType = (0, ecschema_metadata_1.parsePrimitiveType)(property.typeName);
217
198
  if (propertyType === undefined) {
218
- return { errorMessage: `Invalid property type ${property.typeName} on property ${property.name}` };
199
+ throw new Error(`Invalid property type ${property.typeName} on property ${property.name}`);
219
200
  }
220
201
  const classEditor = await getClassEditor(context, itemKey);
221
202
  return arrayProperty.is(property)
@@ -224,7 +205,7 @@ const primitiveProperty = {
224
205
  },
225
206
  async merge(context, itemKey, property, props) {
226
207
  if (props.typeName) {
227
- return { errorMessage: `Changing the property '${property.fullName}' primitiveType is not supported.` };
208
+ throw new Error(`Changing the property '${property.fullName}' primitiveType is not supported.`);
228
209
  }
229
210
  const classEditor = await getClassEditor(context, itemKey);
230
211
  if (props.extendedTypeName !== undefined) {
@@ -242,7 +223,6 @@ const primitiveProperty = {
242
223
  if (props.maxValue !== undefined) {
243
224
  await classEditor.primitiveProperties.setMaxValue(itemKey, property.name, props.maxValue);
244
225
  }
245
- return {};
246
226
  },
247
227
  };
248
228
  const structProperty = {
@@ -253,7 +233,7 @@ const structProperty = {
253
233
  const structKey = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, property.typeName);
254
234
  const structType = await context.editor.schemaContext.getSchemaItem(structKey);
255
235
  if (structType === undefined) {
256
- return { errorMessage: `Unable to locate the struct ${structKey.name} in the context schema.` };
236
+ throw new Error(`Unable to locate the struct ${structKey.name} in the context schema.`);
257
237
  }
258
238
  property.typeName = structKey.fullName;
259
239
  const classEditor = await getClassEditor(context, itemKey);
@@ -263,9 +243,8 @@ const structProperty = {
263
243
  },
264
244
  async merge(_context, _itemKey, property, props) {
265
245
  if ("structClass" in props && props.structClass !== undefined) {
266
- return { errorMessage: `Changing the property '${property.fullName}' structClass is not supported.` };
246
+ throw new Error(`Changing the property '${property.fullName}' structClass is not supported.`);
267
247
  }
268
- return {};
269
248
  },
270
249
  };
271
250
  //# sourceMappingURL=PropertyMerger.js.map