@itwin/ecschema-editing 5.5.0-dev.2 → 5.5.0-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/cjs/Differencing/Errors.js.map +1 -1
  3. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  4. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  5. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  6. package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
  7. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
  8. package/lib/cjs/Differencing/Utils.js.map +1 -1
  9. package/lib/cjs/Editing/Constants.js.map +1 -1
  10. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  11. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  12. package/lib/cjs/Editing/Editor.js.map +1 -1
  13. package/lib/cjs/Editing/Entities.js.map +1 -1
  14. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  15. package/lib/cjs/Editing/Exception.js.map +1 -1
  16. package/lib/cjs/Editing/Formats.js.map +1 -1
  17. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  18. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  19. package/lib/cjs/Editing/Mixins.js.map +1 -1
  20. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  21. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  22. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  23. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  24. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  25. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  26. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  27. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  28. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  29. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  30. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  31. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  32. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  33. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  34. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  35. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  36. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  37. package/lib/cjs/Editing/Mutable/MutableSchemaItem.js.map +1 -1
  38. package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -1
  39. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  40. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  41. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  42. package/lib/cjs/Editing/Properties.js.map +1 -1
  43. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  44. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  45. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  46. package/lib/cjs/Editing/Structs.js.map +1 -1
  47. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  48. package/lib/cjs/Editing/Units.js.map +1 -1
  49. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  50. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  51. package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -1
  52. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  53. package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -1
  54. package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
  55. package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
  56. package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -1
  57. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  58. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  59. package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
  60. package/lib/cjs/Merging/FormatMerger.js.map +1 -1
  61. package/lib/cjs/Merging/InvertedUnitMerger.js.map +1 -1
  62. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  63. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  64. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  65. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
  66. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  67. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  68. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  69. package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
  70. package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
  71. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  72. package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
  73. package/lib/cjs/Merging/UnitMerger.js.map +1 -1
  74. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
  75. package/lib/cjs/Merging/Utils.js.map +1 -1
  76. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  77. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  78. package/lib/cjs/Validation/ECRules.js.map +1 -1
  79. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  80. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  81. package/lib/cjs/Validation/Rules.js.map +1 -1
  82. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  83. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  84. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  85. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  86. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  87. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  88. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  89. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  90. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  91. package/lib/cjs/ecschema-editing.js.map +1 -1
  92. package/lib/esm/Differencing/Errors.js.map +1 -1
  93. package/lib/esm/Differencing/SchemaConflicts.js.map +1 -1
  94. package/lib/esm/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  95. package/lib/esm/Differencing/SchemaDifference.js.map +1 -1
  96. package/lib/esm/Differencing/SchemaDifferenceValidator.js.map +1 -1
  97. package/lib/esm/Differencing/SchemaDifferenceVisitor.js.map +1 -1
  98. package/lib/esm/Differencing/Utils.js.map +1 -1
  99. package/lib/esm/Editing/Constants.js.map +1 -1
  100. package/lib/esm/Editing/CustomAttributes.js.map +1 -1
  101. package/lib/esm/Editing/ECClasses.js.map +1 -1
  102. package/lib/esm/Editing/Editor.js.map +1 -1
  103. package/lib/esm/Editing/Entities.js.map +1 -1
  104. package/lib/esm/Editing/Enumerations.js.map +1 -1
  105. package/lib/esm/Editing/Exception.js.map +1 -1
  106. package/lib/esm/Editing/Formats.js.map +1 -1
  107. package/lib/esm/Editing/InvertedUnits.js.map +1 -1
  108. package/lib/esm/Editing/KindOfQuantities.js.map +1 -1
  109. package/lib/esm/Editing/Mixins.js.map +1 -1
  110. package/lib/esm/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  111. package/lib/esm/Editing/Mutable/MutableCAClass.js.map +1 -1
  112. package/lib/esm/Editing/Mutable/MutableClass.js.map +1 -1
  113. package/lib/esm/Editing/Mutable/MutableConstant.js.map +1 -1
  114. package/lib/esm/Editing/Mutable/MutableEntityClass.js.map +1 -1
  115. package/lib/esm/Editing/Mutable/MutableEnumeration.js.map +1 -1
  116. package/lib/esm/Editing/Mutable/MutableFormat.js.map +1 -1
  117. package/lib/esm/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  118. package/lib/esm/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  119. package/lib/esm/Editing/Mutable/MutableMixin.js.map +1 -1
  120. package/lib/esm/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  121. package/lib/esm/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  122. package/lib/esm/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  123. package/lib/esm/Editing/Mutable/MutableProperty.js.map +1 -1
  124. package/lib/esm/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  125. package/lib/esm/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  126. package/lib/esm/Editing/Mutable/MutableSchema.js.map +1 -1
  127. package/lib/esm/Editing/Mutable/MutableSchemaItem.js.map +1 -1
  128. package/lib/esm/Editing/Mutable/MutableStructProperty.js.map +1 -1
  129. package/lib/esm/Editing/Mutable/MutableUnit.js.map +1 -1
  130. package/lib/esm/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  131. package/lib/esm/Editing/Phenomena.js.map +1 -1
  132. package/lib/esm/Editing/Properties.js.map +1 -1
  133. package/lib/esm/Editing/PropertyCategories.js.map +1 -1
  134. package/lib/esm/Editing/RelationshipClasses.js.map +1 -1
  135. package/lib/esm/Editing/SchemaItems.js.map +1 -1
  136. package/lib/esm/Editing/Structs.js.map +1 -1
  137. package/lib/esm/Editing/UnitSystems.js.map +1 -1
  138. package/lib/esm/Editing/Units.js.map +1 -1
  139. package/lib/esm/Merging/ClassMerger.js.map +1 -1
  140. package/lib/esm/Merging/ConstantMerger.js.map +1 -1
  141. package/lib/esm/Merging/CustomAttributeClassMerger.js.map +1 -1
  142. package/lib/esm/Merging/CustomAttributeMerger.js.map +1 -1
  143. package/lib/esm/Merging/Edits/NameMapping.js.map +1 -1
  144. package/lib/esm/Merging/Edits/RenameEditHandler.js.map +1 -1
  145. package/lib/esm/Merging/Edits/SchemaEdits.js.map +1 -1
  146. package/lib/esm/Merging/Edits/SkipEditHandler.js.map +1 -1
  147. package/lib/esm/Merging/EntityClassMerger.js.map +1 -1
  148. package/lib/esm/Merging/EnumerationMerger.js.map +1 -1
  149. package/lib/esm/Merging/EnumeratorMerger.js.map +1 -1
  150. package/lib/esm/Merging/FormatMerger.js.map +1 -1
  151. package/lib/esm/Merging/InvertedUnitMerger.js.map +1 -1
  152. package/lib/esm/Merging/KindOfQuantityMerger.js.map +1 -1
  153. package/lib/esm/Merging/MixinMerger.js.map +1 -1
  154. package/lib/esm/Merging/PhenomenonMerger.js.map +1 -1
  155. package/lib/esm/Merging/PropertyCategoryMerger.js.map +1 -1
  156. package/lib/esm/Merging/PropertyMerger.js.map +1 -1
  157. package/lib/esm/Merging/RelationshipClassMerger.js.map +1 -1
  158. package/lib/esm/Merging/SchemaMerger.js.map +1 -1
  159. package/lib/esm/Merging/SchemaMergingVisitor.js.map +1 -1
  160. package/lib/esm/Merging/SchemaMergingWalker.js.map +1 -1
  161. package/lib/esm/Merging/SchemaReferenceMerger.js.map +1 -1
  162. package/lib/esm/Merging/StructClassMerger.js.map +1 -1
  163. package/lib/esm/Merging/UnitMerger.js.map +1 -1
  164. package/lib/esm/Merging/UnitSystemMerger.js.map +1 -1
  165. package/lib/esm/Merging/Utils.js.map +1 -1
  166. package/lib/esm/Validation/Diagnostic.js.map +1 -1
  167. package/lib/esm/Validation/DiagnosticReporter.js.map +1 -1
  168. package/lib/esm/Validation/ECRules.js.map +1 -1
  169. package/lib/esm/Validation/LoggingDiagnosticReporter.js.map +1 -1
  170. package/lib/esm/Validation/RuleSuppressionSet.js.map +1 -1
  171. package/lib/esm/Validation/Rules.js.map +1 -1
  172. package/lib/esm/Validation/SchemaChanges.js.map +1 -1
  173. package/lib/esm/Validation/SchemaCompareDiagnostics.js.map +1 -1
  174. package/lib/esm/Validation/SchemaCompareReporter.js.map +1 -1
  175. package/lib/esm/Validation/SchemaCompareResultDelegate.js.map +1 -1
  176. package/lib/esm/Validation/SchemaCompareVisitor.js.map +1 -1
  177. package/lib/esm/Validation/SchemaComparer.js.map +1 -1
  178. package/lib/esm/Validation/SchemaValidater.js.map +1 -1
  179. package/lib/esm/Validation/SchemaValidationVisitor.js.map +1 -1
  180. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  181. package/lib/esm/ecschema-editing.js.map +1 -1
  182. package/package.json +9 -9
  183. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1 +1 @@
1
- {"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAiB,cAAc,EAAkC,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGhK,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC,IAAuB,aAAa;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6CAA6C;IAC7C,YAAmB,YAAiC;QAClD,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAyB,EAAE,UAAyB,EAAE,YAAqB;QACrJ,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAO,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAgB,CAAC;YAEnJ,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,UAA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AAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaItemUnitProps, SchemaKey, Unit, UnitSystem } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Unit.\n */\nexport class Units extends SchemaItems {\n protected override get itemTypeClass(): typeof Unit {\n return Unit;\n }\n\n // TODO: Add more setters for all attributes.\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Unit, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItem<Unit>(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name) as MutableUnit;\n\n const phenomenonItem = await this.getSchemaItem(phenomenon, Phenomenon);\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\n\n const unitSystemItem = await this.getSchemaItem(unitSystem, UnitSystem);\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\n\n await newUnit.setDefinition(definition);\n\n if (displayLabel)\n newUnit.setDisplayLabel(displayLabel);\n\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name!, schemaKey), e);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAiB,cAAc,EAAkC,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGhK,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC,IAAuB,aAAa;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6CAA6C;IAC7C,YAAmB,YAAiC;QAClD,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAyB,EAAE,UAAyB,EAAE,YAAqB;QACrJ,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAO,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAgB,CAAC;YAEnJ,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YACxE,MAAM,OAAO,CAAC,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------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaItemUnitProps, SchemaKey, Unit, UnitSystem } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Unit.\r\n */\r\nexport class Units extends SchemaItems {\r\n protected override get itemTypeClass(): typeof Unit {\r\n return Unit;\r\n }\r\n\r\n // TODO: Add more setters for all attributes.\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.Unit, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\r\n try {\r\n const newUnit = await this.createSchemaItem<Unit>(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name) as MutableUnit;\r\n\r\n const phenomenonItem = await this.getSchemaItem(phenomenon, Phenomenon);\r\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\r\n\r\n const unitSystemItem = await this.getSchemaItem(unitSystem, UnitSystem);\r\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\r\n\r\n await newUnit.setDefinition(definition);\r\n\r\n if (displayLabel)\r\n newUnit.setDisplayLabel(displayLabel);\r\n\r\n return newUnit.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey> {\r\n try {\r\n const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);\r\n return newUnit.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name!, schemaKey), e);\r\n }\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAA4B,eAAe,EAAE,kBAAkB,EAAiB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxI,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,MAA8B,EAAE,OAAsB,EAAE,IAAa;IAClI,MAAM,YAAY,GAAG,IAAoB,CAAC;IAC1C,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;QAClD,2FAA2F;QAC3F,8EAA8E;QAC9E,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,EAAE,YAAY,CAAC,CAAC;YAC/G,KAAK,cAAc,CAAC,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACrG,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,IAAI,qBAAqB,CAAC,CAAC;IAC9E,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\nimport { AnyClassItemDifference } from \"../Differencing/SchemaDifference\";\nimport { updateSchemaItemKey } from \"./Utils\";\nimport { type MutableClass } from \"../Editing/Mutable/MutableClass\";\nimport { CustomAttribute, ECClass, ECClassModifier, parseClassModifier, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport { mergeClassProperties } from \"./PropertyMerger\";\nimport { applyCustomAttributes } from \"./CustomAttributeMerger\";\n\n/**\n * Shared modify merger of all ECClass based items.\n * @internal\n */\nexport async function modifyClass(context: SchemaMergeContext, change: AnyClassItemDifference, itemKey: SchemaItemKey, item: ECClass): Promise<void> {\n const mutableClass = item as MutableClass;\n if (change.difference.label !== undefined) {\n mutableClass.setDisplayLabel(change.difference.label);\n }\n\n if (change.difference.description !== undefined) {\n mutableClass.setDescription(change.difference.description);\n }\n\n if (change.difference.hasOwnProperty(\"baseClass\")) {\n // If the entry difference have a property baseClass and it is explicitly set to undefined,\n // it is expected to remove the base class, which is not allowed in this case.\n // TODO: We should consider using null for this case.\n if(change.difference.baseClass === undefined) {\n throw new Error(`Changing the class '${item.key.name}' baseClass is not supported.`);\n }\n await setBaseClass(context, item, change.difference.baseClass, change.changeType === \"add\");\n }\n\n if (change.difference.modifier !== undefined) {\n await setClassModifier(mutableClass, change.difference.modifier);\n }\n\n if (change.difference.customAttributes !== undefined) {\n await applyCustomAttributes(context, change.difference.customAttributes as CustomAttribute[], async (ca) => {\n await context.editor.entities.addCustomAttribute(itemKey, ca);\n });\n }\n\n return mergeClassProperties(context, change, itemKey);\n}\n\nasync function setBaseClass(context: SchemaMergeContext, item: ECClass, baseClass: string, isInitial: boolean): Promise<void> {\n if (!isInitial && (item.baseClass === undefined))\n throw new Error(`Changing the class '${item.key.name}' baseClass is not supported.`);\n\n const baseClassKey = await updateSchemaItemKey(context, baseClass);\n const baseClassSetter = getBaseClassSetter(context, item);\n\n await baseClassSetter(item.key, baseClassKey);\n}\n\nasync function setClassModifier(item: MutableClass, modifierValue: string): Promise<void> {\n const modifier = parseClassModifier(modifierValue);\n if (modifier === undefined) {\n throw new Error(\"An invalid class modifier has been provided.\");\n }\n if (item.modifier === undefined || item.modifier === modifier || modifier === ECClassModifier.None) {\n item.setModifier(modifier);\n return;\n }\n throw new Error(`Changing the class '${item.name}' modifier is not supported.`);\n}\n\nfunction getBaseClassSetter(context: SchemaMergeContext, item: ECClass) {\n return async (itemKey: SchemaItemKey, baseClassKey: SchemaItemKey) => {\n switch (item.schemaItemType) {\n case SchemaItemType.CustomAttributeClass: return context.editor.customAttributes.setBaseClass(itemKey, baseClassKey);\n case SchemaItemType.EntityClass: return context.editor.entities.setBaseClass(itemKey, baseClassKey);\n case SchemaItemType.Mixin: return context.editor.mixins.setBaseClass(itemKey, baseClassKey);\n case SchemaItemType.RelationshipClass: return context.editor.relationships.setBaseClass(itemKey, baseClassKey);\n case SchemaItemType.StructClass: return context.editor.structs.setBaseClass(itemKey, baseClassKey);\n }\n throw new Error(`Changing the base class '${item.name}' is not supported.`);\n };\n}\n"]}
1
+ {"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAA4B,eAAe,EAAE,kBAAkB,EAA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BAAuB,IAAI,CAAC,IAAI,8BAA8B,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,kBAAkB,CAAC,OAA2B,EAAE,IAAa;IACpE,OAAO,KAAK,EAAE,OAAsB,EAAE,YAA2B,EAAE,EAAE;QACnE,QAAQ,IAAI,CAAC,cAAc,EAAE,CAAC;YAC5B,KAAK,cAAc,CAAC,oBAAoB,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACrH,KAAK,cAAc,CAAC,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACpG,KAAK,cAAc,CAAC,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAC5F,KAAK,cAAc,CAAC,iBAAiB,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAC/G,KAAK,cAAc,CAAC,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACrG,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,IAAI,qBAAqB,CAAC,CAAC;IAC9E,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { AnyClassItemDifference } from \"../Differencing/SchemaDifference\";\r\nimport { updateSchemaItemKey } from \"./Utils\";\r\nimport { type MutableClass } from \"../Editing/Mutable/MutableClass\";\r\nimport { CustomAttribute, ECClass, ECClassModifier, parseClassModifier, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\r\nimport { mergeClassProperties } from \"./PropertyMerger\";\r\nimport { applyCustomAttributes } from \"./CustomAttributeMerger\";\r\n\r\n/**\r\n * Shared modify merger of all ECClass based items.\r\n * @internal\r\n */\r\nexport async function modifyClass(context: SchemaMergeContext, change: AnyClassItemDifference, itemKey: SchemaItemKey, item: ECClass): Promise<void> {\r\n const mutableClass = item as MutableClass;\r\n if (change.difference.label !== undefined) {\r\n mutableClass.setDisplayLabel(change.difference.label);\r\n }\r\n\r\n if (change.difference.description !== undefined) {\r\n mutableClass.setDescription(change.difference.description);\r\n }\r\n\r\n if (change.difference.hasOwnProperty(\"baseClass\")) {\r\n // If the entry difference have a property baseClass and it is explicitly set to undefined,\r\n // it is expected to remove the base class, which is not allowed in this case.\r\n // TODO: We should consider using null for this case.\r\n if(change.difference.baseClass === undefined) {\r\n throw new Error(`Changing the class '${item.key.name}' baseClass is not supported.`);\r\n }\r\n await setBaseClass(context, item, change.difference.baseClass, change.changeType === \"add\");\r\n }\r\n\r\n if (change.difference.modifier !== undefined) {\r\n await setClassModifier(mutableClass, change.difference.modifier);\r\n }\r\n\r\n if (change.difference.customAttributes !== undefined) {\r\n await applyCustomAttributes(context, change.difference.customAttributes as CustomAttribute[], async (ca) => {\r\n await context.editor.entities.addCustomAttribute(itemKey, ca);\r\n });\r\n }\r\n\r\n return mergeClassProperties(context, change, itemKey);\r\n}\r\n\r\nasync function setBaseClass(context: SchemaMergeContext, item: ECClass, baseClass: string, isInitial: boolean): Promise<void> {\r\n if (!isInitial && (item.baseClass === undefined))\r\n throw new Error(`Changing the class '${item.key.name}' baseClass is not supported.`);\r\n\r\n const baseClassKey = await updateSchemaItemKey(context, baseClass);\r\n const baseClassSetter = getBaseClassSetter(context, item);\r\n\r\n await baseClassSetter(item.key, baseClassKey);\r\n}\r\n\r\nasync function setClassModifier(item: MutableClass, modifierValue: string): Promise<void> {\r\n const modifier = parseClassModifier(modifierValue);\r\n if (modifier === undefined) {\r\n throw new Error(\"An invalid class modifier has been provided.\");\r\n }\r\n if (item.modifier === undefined || item.modifier === modifier || modifier === ECClassModifier.None) {\r\n item.setModifier(modifier);\r\n return;\r\n }\r\n throw new Error(`Changing the class '${item.name}' modifier is not supported.`);\r\n}\r\n\r\nfunction getBaseClassSetter(context: SchemaMergeContext, item: ECClass) {\r\n return async (itemKey: SchemaItemKey, baseClassKey: SchemaItemKey) => {\r\n switch (item.schemaItemType) {\r\n case SchemaItemType.CustomAttributeClass: return context.editor.customAttributes.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.EntityClass: return context.editor.entities.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.Mixin: return context.editor.mixins.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.RelationshipClass: return context.editor.relationships.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.StructClass: return context.editor.structs.setBaseClass(itemKey, baseClassKey);\r\n }\r\n throw new Error(`Changing the base class '${item.name}' is not supported.`);\r\n };\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAiB,MAAM,0BAA0B,CAAC;AAC7H,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,MAA0B;IACvF,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAA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,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAC3F,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAC5F,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,IAAI,uBAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,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 { ConstantDifference } from \"../Differencing/SchemaDifference\";\nimport type{ MutableConstant } from \"../Editing/Mutable/MutableConstant\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { DelayedPromiseWithProps, ECSchemaError, ECSchemaStatus, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Constant into the target schema.\n * @internal\n */\nexport async function addConstant(context: SchemaMergeContext, change: ConstantDifference) {\n if (change.difference.phenomenon === undefined) {\n throw new Error(\"Constant must define phenomenon\");\n }\n if (change.difference.definition === undefined) {\n throw new Error(\"Constant must define definition\");\n }\n\n // Needs to update the reference from source to target schema.\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\n\n await context.editor.constants.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n phenomenon: change.difference.phenomenon,\n definition: change.difference.definition,\n });\n}\n\n/**\n * Merges differences to an existing Constant in the target schema.\n * @internal\n */\nexport async function modifyConstant(context: SchemaMergeContext, change: ConstantDifference, itemKey: SchemaItemKey) {\n const constant = await context.targetSchema.lookupItem(itemKey) as MutableConstant;\n if (change.difference.label !== undefined) {\n await context.editor.constants.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.constants.setDescription(itemKey, change.difference.description);\n }\n\n // Note: There are no editor methods to modify a constant.\n if (change.difference.definition !== undefined) {\n if (change.difference.definition !== \"\" && constant.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'definition' attribute.`);\n }\n constant.setDefinition(change.difference.definition);\n }\n if (change.difference.denominator !== undefined) {\n if (constant.hasDenominator && constant.denominator !== change.difference.denominator) {\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'denominator' attribute.`);\n }\n constant.setDenominator(change.difference.denominator);\n }\n if (change.difference.numerator !== undefined) {\n if (constant.hasNumerator && constant.numerator !== change.difference.numerator) {\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'numerator' attribute.`);\n }\n constant.setNumerator(change.difference.numerator);\n }\n if (change.difference.phenomenon !== undefined) {\n const lookupKey = await updateSchemaItemKey(context, change.difference.phenomenon);\n const phenomenon = await context.editor.schemaContext.getSchemaItem(lookupKey, Phenomenon);\n if (phenomenon === undefined) {\n throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);\n }\n\n constant.setPhenomenon(new DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));\n }\n}\n"]}
1
+ {"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAiB,MAAM,0BAA0B,CAAC;AAC7H,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,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AAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAC3F,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAC5F,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,IAAI,uBAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport type { ConstantDifference } from \"../Differencing/SchemaDifference\";\r\nimport type{ MutableConstant } from \"../Editing/Mutable/MutableConstant\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { DelayedPromiseWithProps, ECSchemaError, ECSchemaStatus, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new Constant into the target schema.\r\n * @internal\r\n */\r\nexport async function addConstant(context: SchemaMergeContext, change: ConstantDifference) {\r\n if (change.difference.phenomenon === undefined) {\r\n throw new Error(\"Constant must define phenomenon\");\r\n }\r\n if (change.difference.definition === undefined) {\r\n throw new Error(\"Constant must define definition\");\r\n }\r\n\r\n // Needs to update the reference from source to target schema.\r\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\r\n\r\n await context.editor.constants.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n phenomenon: change.difference.phenomenon,\r\n definition: change.difference.definition,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing Constant in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyConstant(context: SchemaMergeContext, change: ConstantDifference, itemKey: SchemaItemKey) {\r\n const constant = await context.targetSchema.lookupItem(itemKey) as MutableConstant;\r\n if (change.difference.label !== undefined) {\r\n await context.editor.constants.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if (change.difference.description !== undefined) {\r\n await context.editor.constants.setDescription(itemKey, change.difference.description);\r\n }\r\n\r\n // Note: There are no editor methods to modify a constant.\r\n if (change.difference.definition !== undefined) {\r\n if (change.difference.definition !== \"\" && constant.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'definition' attribute.`);\r\n }\r\n constant.setDefinition(change.difference.definition);\r\n }\r\n if (change.difference.denominator !== undefined) {\r\n if (constant.hasDenominator && constant.denominator !== change.difference.denominator) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'denominator' attribute.`);\r\n }\r\n constant.setDenominator(change.difference.denominator);\r\n }\r\n if (change.difference.numerator !== undefined) {\r\n if (constant.hasNumerator && constant.numerator !== change.difference.numerator) {\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'numerator' attribute.`);\r\n }\r\n constant.setNumerator(change.difference.numerator);\r\n }\r\n if (change.difference.phenomenon !== undefined) {\r\n const lookupKey = await updateSchemaItemKey(context, change.difference.phenomenon);\r\n const phenomenon = await context.editor.schemaContext.getSchemaItem(lookupKey, Phenomenon);\r\n if (phenomenon === undefined) {\r\n throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);\r\n }\r\n\r\n constant.setPhenomenon(new DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CustomAttributeClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeClassMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,iCAAiC,EAAiB,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAA2B,EAAE,MAAsC;IAC/G,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAC7E,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS;KACvC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,OAA2B,EAAE,MAAsC,EAAE,OAAsB;IAC1I,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAmB,CAAC;IAC9E,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,YAAY,KAAK,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;YACxE,MAAM,aAAa,GAAG,iCAAiC,CAAC,GAAG,YAAY,KAAK,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;YAC3G,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;YACxF,CAAC;YACD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { CustomAttributeClassDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableCAClass } from \"../Editing/Mutable/MutableCAClass\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { containerTypeToString, parseCustomAttributeContainerType, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { modifyClass } from \"./ClassMerger\";\n\n/**\n * Merges a new CustomAttribute into the target schema.\n * @internal\n */\nexport async function addCustomAttributeClass(context: SchemaMergeContext, change: CustomAttributeClassDifference) {\n if (change.difference.appliesTo === undefined) {\n throw new Error(\"appliesTo is a required property of a CustomAttributeClass but it is not set\");\n }\n\n await context.editor.customAttributes.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n appliesTo: change.difference.appliesTo,\n });\n}\n\n/**\n * Merges differences to an existing CustomAttribute in the target schema.\n * @internal\n */\nexport async function modifyCustomAttributeClass(context: SchemaMergeContext, change: CustomAttributeClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableCAClass;\n if (change.difference.appliesTo !== undefined) {\n const currentValue = containerTypeToString(item.appliesTo);\n if (currentValue !== \"\" && change.difference.appliesTo !== currentValue) {\n const containerType = parseCustomAttributeContainerType(`${currentValue}, ${change.difference.appliesTo}`);\n if (containerType === undefined) {\n throw new Error(\"An invalid custom attribute class containerType has been provided.\");\n }\n item.setAppliesTo(containerType);\n }\n }\n return modifyClass(context, change, itemKey, item);\n}\n"]}
1
+ {"version":3,"file":"CustomAttributeClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeClassMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,iCAAiC,EAAiB,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAA2B,EAAE,MAAsC;IAC/G,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAC7E,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS;KACvC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,OAA2B,EAAE,MAAsC,EAAE,OAAsB;IAC1I,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAmB,CAAC;IAC9E,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,YAAY,KAAK,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;YACxE,MAAM,aAAa,GAAG,iCAAiC,CAAC,GAAG,YAAY,KAAK,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;YAC3G,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;YACxF,CAAC;YACD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport type { CustomAttributeClassDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableCAClass } from \"../Editing/Mutable/MutableCAClass\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { containerTypeToString, parseCustomAttributeContainerType, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\n\r\n/**\r\n * Merges a new CustomAttribute into the target schema.\r\n * @internal\r\n */\r\nexport async function addCustomAttributeClass(context: SchemaMergeContext, change: CustomAttributeClassDifference) {\r\n if (change.difference.appliesTo === undefined) {\r\n throw new Error(\"appliesTo is a required property of a CustomAttributeClass but it is not set\");\r\n }\r\n\r\n await context.editor.customAttributes.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n appliesTo: change.difference.appliesTo,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing CustomAttribute in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyCustomAttributeClass(context: SchemaMergeContext, change: CustomAttributeClassDifference, itemKey: SchemaItemKey) {\r\n const item = await context.targetSchema.lookupItem(itemKey) as MutableCAClass;\r\n if (change.difference.appliesTo !== undefined) {\r\n const currentValue = containerTypeToString(item.appliesTo);\r\n if (currentValue !== \"\" && change.difference.appliesTo !== currentValue) {\r\n const containerType = parseCustomAttributeContainerType(`${currentValue}, ${change.difference.appliesTo}`);\r\n if (containerType === undefined) {\r\n throw new Error(\"An invalid custom attribute class containerType has been provided.\");\r\n }\r\n item.setAppliesTo(containerType);\r\n }\r\n }\r\n return modifyClass(context, change, itemKey, item);\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAmB,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGpG,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAIlH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA2B,EAAE,MAAiC;IACrG,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAEtF,MAAM,0BAA0B,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;IAC9G,IAAI,0BAA0B,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,+CAA+C,aAAa,CAAC,IAAI,wBAAwB,CAAC,CAAC;IAC7G,CAAC;IAED,MAAM,UAAU,GAAoB;QAClC,GAAG,MAAM,CAAC,UAAU;QACpB,SAAS,EAAE,aAAa,CAAC,QAAQ;KAClC,CA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CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,2CAA2C,OAAO,CAAC,IAAI,wBAAwB,CAAC,CAAC;QACnG,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,KAAK,SAAS;YAC1C,CAAC,CAAC,iBAAiB,CAAC,MAAM;YAC1B,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC;QAE7B,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,8BAA8B,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAA2B,EAAE,gBAAmC,EAAE,OAA8B;IAC1I,KAAK,MAAM,eAAe,IAAI,gBAAgB,EAAE,CAAC;QAC/C,MAAM,oBAAoB,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,eAAgC,EAAE,OAA8B;IACtI,eAAe,CAAC,SAAS,GAAG,MAAM,wBAAwB,CAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC,eAAe,CAAC,CAAC;AAClC,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 { CustomAttribute, CustomAttributeClass, RelationshipClass } from \"@itwin/ecschema-metadata\";\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\nimport { type CustomAttributeDifference } from \"../Differencing/SchemaDifference\";\nimport { getClassEditor, toItemKey, toPropertyKey, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\ntype CustomAttributeSetter = (customAttribute: CustomAttribute) => Promise<void>;\n\n/**\n * Merges a new CustomAttributes from Schema, items or properties into the target schema.\n * @internal\n */\nexport async function addCustomAttribute(context: SchemaMergeContext, change: CustomAttributeDifference): Promise<void> {\n if (change.difference.className === undefined) {\n throw new Error(\"CustomAttribute instance must specify className\");\n }\n const schemaItemKey = await updateSchemaItemKey(context, change.difference.className);\n\n const targetCustomAttributeClass = await context.targetSchema.lookupItem(schemaItemKey, CustomAttributeClass);\n if (targetCustomAttributeClass === undefined) {\n throw new Error(`Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`);\n }\n\n const caInstance: CustomAttribute = {\n ...change.difference,\n className: schemaItemKey.fullName,\n };\n\n if (change.appliedTo === \"Schema\") {\n await context.editor.addCustomAttribute(context.targetSchemaKey, caInstance);\n }\n if (change.appliedTo === \"SchemaItem\") {\n const itemKey = toItemKey(context, change.itemName);\n const editor = await getClassEditor(context, itemKey);\n await editor.addCustomAttribute(itemKey, caInstance);\n }\n if (change.appliedTo === \"Property\") {\n const itemKey = toItemKey(context, change.itemName);\n const [propertyName] = change.path.split(\".\");\n const propertyKey = toPropertyKey(context, change.itemName, propertyName);\n const editor = await getClassEditor(context, itemKey);\n await editor.properties.addCustomAttribute(itemKey, propertyKey.propertyName, caInstance);\n }\n if (change.appliedTo === \"RelationshipConstraint\") {\n const itemKey = toItemKey(context, change.itemName);\n const relationshipClass = await context.targetSchema.lookupItem(itemKey, RelationshipClass);\n if (relationshipClass === undefined) {\n throw new Error(`Unable to locate the relationship class ${itemKey.name} in the merged schema.`);\n }\n const constraint = change.path === \"$source\"\n ? relationshipClass.source\n : relationshipClass.target;\n\n return context.editor.relationships.addCustomAttributeToConstraint(constraint, caInstance);\n }\n}\n\n/**\n * @internal\n */\nexport async function applyCustomAttributes(context: SchemaMergeContext, customAttributes: CustomAttribute[], handler: CustomAttributeSetter): Promise<void> {\n for (const customAttribute of customAttributes) {\n await applyCustomAttribute(context, customAttribute, handler);\n }\n}\n\n/**\n * @internal\n */\nexport async function applyCustomAttribute(context: SchemaMergeContext, customAttribute: CustomAttribute, handler: CustomAttributeSetter): Promise<void> {\n customAttribute.className = await updateSchemaItemFullName(context, customAttribute.className);\n return handler(customAttribute);\n}\n"]}
1
+ {"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAmB,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGpG,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAIlH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA2B,EAAE,MAAiC;IACrG,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAEtF,MAAM,0BAA0B,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;IAC9G,IAAI,0BAA0B,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,+CAA+C,aAAa,CAAC,IAAI,wBAAwB,CAAC,CAAC;IAC7G,CAAC;IAED,MAAM,UAAU,GAAoB;QAClC,GAAG,MAAM,CAAC,UAAU;QACpB,SAAS,EAAE,aAAa,CAAC,QAAQ;KAClC,CAAC;IAEF,IAAI,MAAM,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,KAAK,YAAY,EAAE,CAA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CAAC,MAAM,CAAC;QAE7B,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,8BAA8B,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAA2B,EAAE,gBAAmC,EAAE,OAA8B;IAC1I,KAAK,MAAM,eAAe,IAAI,gBAAgB,EAAE,CAAC;QAC/C,MAAM,oBAAoB,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,eAAgC,EAAE,OAA8B;IACtI,eAAe,CAAC,SAAS,GAAG,MAAM,wBAAwB,CAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC,eAAe,CAAC,CAAC;AAClC,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 { CustomAttribute, CustomAttributeClass, RelationshipClass } from \"@itwin/ecschema-metadata\";\r\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { type CustomAttributeDifference } from \"../Differencing/SchemaDifference\";\r\nimport { getClassEditor, toItemKey, toPropertyKey, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\n\r\ntype CustomAttributeSetter = (customAttribute: CustomAttribute) => Promise<void>;\r\n\r\n/**\r\n * Merges a new CustomAttributes from Schema, items or properties into the target schema.\r\n * @internal\r\n */\r\nexport async function addCustomAttribute(context: SchemaMergeContext, change: CustomAttributeDifference): Promise<void> {\r\n if (change.difference.className === undefined) {\r\n throw new Error(\"CustomAttribute instance must specify className\");\r\n }\r\n const schemaItemKey = await updateSchemaItemKey(context, change.difference.className);\r\n\r\n const targetCustomAttributeClass = await context.targetSchema.lookupItem(schemaItemKey, CustomAttributeClass);\r\n if (targetCustomAttributeClass === undefined) {\r\n throw new Error(`Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`);\r\n }\r\n\r\n const caInstance: CustomAttribute = {\r\n ...change.difference,\r\n className: schemaItemKey.fullName,\r\n };\r\n\r\n if (change.appliedTo === \"Schema\") {\r\n await context.editor.addCustomAttribute(context.targetSchemaKey, caInstance);\r\n }\r\n if (change.appliedTo === \"SchemaItem\") {\r\n const itemKey = toItemKey(context, change.itemName);\r\n const editor = await getClassEditor(context, itemKey);\r\n await editor.addCustomAttribute(itemKey, caInstance);\r\n }\r\n if (change.appliedTo === \"Property\") {\r\n const itemKey = toItemKey(context, change.itemName);\r\n const [propertyName] = change.path.split(\".\");\r\n const propertyKey = toPropertyKey(context, change.itemName, propertyName);\r\n const editor = await getClassEditor(context, itemKey);\r\n await editor.properties.addCustomAttribute(itemKey, propertyKey.propertyName, caInstance);\r\n }\r\n if (change.appliedTo === \"RelationshipConstraint\") {\r\n const itemKey = toItemKey(context, change.itemName);\r\n const relationshipClass = await context.targetSchema.lookupItem(itemKey, RelationshipClass);\r\n if (relationshipClass === undefined) {\r\n throw new Error(`Unable to locate the relationship class ${itemKey.name} in the merged schema.`);\r\n }\r\n const constraint = change.path === \"$source\"\r\n ? relationshipClass.source\r\n : relationshipClass.target;\r\n\r\n return context.editor.relationships.addCustomAttributeToConstraint(constraint, caInstance);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function applyCustomAttributes(context: SchemaMergeContext, customAttributes: CustomAttribute[], handler: CustomAttributeSetter): Promise<void> {\r\n for (const customAttribute of customAttributes) {\r\n await applyCustomAttribute(context, customAttribute, handler);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function applyCustomAttribute(context: SchemaMergeContext, customAttribute: CustomAttribute, handler: CustomAttributeSetter): Promise<void> {\r\n customAttribute.className = await updateSchemaItemFullName(context, customAttribute.className);\r\n return handler(customAttribute);\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"NameMapping.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/NameMapping.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,MAAM,OAAO,WAAW;IACN,YAAY,CAAS;IACrB,QAAQ,CAAgB;IAExC,IAAW,QAAQ;QACjB,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;IAC1D,CAAC;IAED,YAAY,YAAoB,EAAE,QAAuB;QACvD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,WAAW;IACL,IAAI,CAA4B;IAEjD;QACE,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC9C,CAAC;IAEM,cAAc,CAAC,OAAe,EAAE,OAAe;QACpD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACtC,CAAC;IAEM,kBAAkB,CAAC,WAAmB,EAAE,OAAe;QAC5D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1C,CAAC;IAEM,cAAc,CAAC,OAAgC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAG,KAAK,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IAEM,kBAAkB,CAAC,WAAkC;QAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAG,KAAK,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\n\ninterface MappingEntry {\n readonly newName: string;\n}\n\nexport class PropertyKey {\n public readonly propertyName: string;\n public readonly classKey: SchemaItemKey;\n\n public get fullName(): string {\n return `${this.classKey.fullName}.${this.propertyName}`;\n }\n\n constructor(propertyName: string, classKey: SchemaItemKey) {\n this.propertyName = propertyName;\n this.classKey = classKey;\n }\n}\n\n/**\n * @internal\n */\nexport class NameMapping {\n private readonly _map: Map<string, MappingEntry>;\n\n constructor() {\n this._map = new Map<string, MappingEntry>();\n }\n\n public addItemMapping(itemKey: string, newName: string) {\n this._map.set(itemKey, { newName });\n }\n\n public addPropertyMapping(propertyKey: string, newName: string) {\n this._map.set(propertyKey, { newName });\n }\n\n public resolveItemKey(itemKey: Readonly<SchemaItemKey>): Readonly<SchemaItemKey> {\n const entry = this._map.get(itemKey.fullName);\n if(entry === undefined) {\n return itemKey;\n }\n\n return new SchemaItemKey(entry.newName, itemKey.schemaKey);\n }\n\n public resolvePropertyKey(propertyKey: Readonly<PropertyKey>): Readonly<PropertyKey> {\n const entry = this._map.get(propertyKey.fullName);\n if(entry === undefined) {\n return propertyKey;\n }\n\n return new PropertyKey(entry.newName, propertyKey.classKey);\n }\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AG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAG,KAAK,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\ninterface MappingEntry {\r\n readonly newName: string;\r\n}\r\n\r\nexport class PropertyKey {\r\n public readonly propertyName: string;\r\n public readonly classKey: SchemaItemKey;\r\n\r\n public get fullName(): string {\r\n return `${this.classKey.fullName}.${this.propertyName}`;\r\n }\r\n\r\n constructor(propertyName: string, classKey: SchemaItemKey) {\r\n this.propertyName = propertyName;\r\n this.classKey = classKey;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class NameMapping {\r\n private readonly _map: Map<string, MappingEntry>;\r\n\r\n constructor() {\r\n this._map = new Map<string, MappingEntry>();\r\n }\r\n\r\n public addItemMapping(itemKey: string, newName: string) {\r\n this._map.set(itemKey, { newName });\r\n }\r\n\r\n public addPropertyMapping(propertyKey: string, newName: string) {\r\n this._map.set(propertyKey, { newName });\r\n }\r\n\r\n public resolveItemKey(itemKey: Readonly<SchemaItemKey>): Readonly<SchemaItemKey> {\r\n const entry = this._map.get(itemKey.fullName);\r\n if(entry === undefined) {\r\n return itemKey;\r\n }\r\n\r\n return new SchemaItemKey(entry.newName, itemKey.schemaKey);\r\n }\r\n\r\n public resolvePropertyKey(propertyKey: Readonly<PropertyKey>): Readonly<PropertyKey> {\r\n const entry = this._map.get(propertyKey.fullName);\r\n if(entry === undefined) {\r\n return propertyKey;\r\n }\r\n\r\n return new PropertyKey(entry.newName, propertyKey.classKey);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RenameEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/RenameEditHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAMlD;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAA8B,EAAE,IAAwB;IAC9F,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAA6B,CAAC;IACrF,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACpD,OAAO;IACT,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QACnD,OAAO,KAAK,CAAC,yBAAyB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IACpI,CAAC,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,UAA+C,CAAC;IAC3E,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO;IACT,CAAC;IAED,kBAAkB,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;IAErC,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,kBAAkB,CAAC,CAAC;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IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,MAAM,oBAAoB,GAAG,MAA2C,CAAC;QACzE,oBAAoB,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1C,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*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport type { RenamePropertyEdit, RenameSchemaItemEdit } from \"./SchemaEdits\";\nimport { AnySchemaItemDifference, ClassPropertyDifference,SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\nimport { SchemaItem } from \"@itwin/ecschema-metadata\";\nimport * as Utils from \"../../Differencing/Utils\";\n\ntype Editable<T extends object> = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * @internal\n */\nexport function applyRenamePropertyEdit(result: SchemaDifferenceResult, edit: RenamePropertyEdit) {\n const [schemaName, itemName, path] = edit.key.split(\".\") as [string, string, string];\n if (!result.sourceSchemaName.startsWith(schemaName)) {\n return;\n }\n\n const difference = result.differences.find((entry) => {\n return Utils.isClassPropertyDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName && entry.path === path;\n });\n\n const propertyDifference = difference as Editable<ClassPropertyDifference>;\n if (propertyDifference === undefined) {\n return;\n }\n\n propertyDifference.path = edit.value;\n\n if (result.conflicts) {\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === propertyDifference);\n if (conflictIndex > -1) {\n result.conflicts.splice(conflictIndex, 1);\n }\n }\n}\n\n/**\n * @internal\n */\nexport function applyRenameSchemaItemEdit(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit) {\n const [schemaName, itemName] = SchemaItem.parseFullName(edit.key);\n if (!result.sourceSchemaName.startsWith(schemaName)) {\n return;\n }\n\n const difference = result.differences.find((entry) => {\n return Utils.isSchemaItemDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName;\n });\n\n const itemDifference = difference as AnySchemaItemDifference;\n if (itemDifference === undefined) {\n return;\n }\n\n renameName(itemDifference, itemName, edit.value);\n\n if (result.conflicts) {\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === itemDifference);\n if (conflictIndex > -1) {\n result.conflicts.splice(conflictIndex, 1);\n }\n }\n}\n\nfunction renameName(change: AnySchemaItemDifference, oldName: string, newName: string) {\n if (change.itemName === oldName) {\n const schemaItemDifference = change as Editable<AnySchemaItemDifference>;\n schemaItemDifference.itemName = newName;\n }\n}\n"]}
1
+ {"version":3,"file":"RenameEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/RenameEditHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAMlD;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAA8B,EAAE,IAAwB;IAC9F,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAA6B,CAAC;IACrF,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACpD,OAAO;IACT,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QACnD,OAAO,KAAK,CAAC,yBAAyB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IACpI,CAAC,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,UAA+C,CAAC;IAC3E,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO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AAU,KAAK,cAAc,CAAC,CAAC;QACjG,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,MAA+B,EAAE,OAAe,EAAE,OAAe;IACnF,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,MAAM,oBAAoB,GAAG,MAA2C,CAAC;QACzE,oBAAoB,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1C,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\n\r\nimport type { RenamePropertyEdit, RenameSchemaItemEdit } from \"./SchemaEdits\";\r\nimport { AnySchemaItemDifference, ClassPropertyDifference,SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\r\nimport { SchemaItem } from \"@itwin/ecschema-metadata\";\r\nimport * as Utils from \"../../Differencing/Utils\";\r\n\r\ntype Editable<T extends object> = {\r\n -readonly [P in keyof T]: T[P];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function applyRenamePropertyEdit(result: SchemaDifferenceResult, edit: RenamePropertyEdit) {\r\n const [schemaName, itemName, path] = edit.key.split(\".\") as [string, string, string];\r\n if (!result.sourceSchemaName.startsWith(schemaName)) {\r\n return;\r\n }\r\n\r\n const difference = result.differences.find((entry) => {\r\n return Utils.isClassPropertyDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName && entry.path === path;\r\n });\r\n\r\n const propertyDifference = difference as Editable<ClassPropertyDifference>;\r\n if (propertyDifference === undefined) {\r\n return;\r\n }\r\n\r\n propertyDifference.path = edit.value;\r\n\r\n if (result.conflicts) {\r\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === propertyDifference);\r\n if (conflictIndex > -1) {\r\n result.conflicts.splice(conflictIndex, 1);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function applyRenameSchemaItemEdit(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit) {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(edit.key);\r\n if (!result.sourceSchemaName.startsWith(schemaName)) {\r\n return;\r\n }\r\n\r\n const difference = result.differences.find((entry) => {\r\n return Utils.isSchemaItemDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName;\r\n });\r\n\r\n const itemDifference = difference as AnySchemaItemDifference;\r\n if (itemDifference === undefined) {\r\n return;\r\n }\r\n\r\n renameName(itemDifference, itemName, edit.value);\r\n\r\n if (result.conflicts) {\r\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === itemDifference);\r\n if (conflictIndex > -1) {\r\n result.conflicts.splice(conflictIndex, 1);\r\n }\r\n }\r\n}\r\n\r\nfunction renameName(change: AnySchemaItemDifference, oldName: string, newName: string) {\r\n if (change.itemName === oldName) {\r\n const schemaItemDifference = change as Editable<AnySchemaItemDifference>;\r\n schemaItemDifference.itemName = newName;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaEdits.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAKH,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uDAAqC,CAAA;IACrC,mDAAiC,CAAA;IACjC,+BAAa,CAAA;AACf,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAwCD,MAAe,MAAM;IACF,MA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,EAAE,CAAC;gBAC5C,aAAa,CAAC,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","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"]}
1
+ {"version":3,"file":"SchemaEdits.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAKH,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uDAAqC,CAAA;IACrC,mDAAiC,CAAA;IACjC,+BAAa,CAAA;AACf,CAAC,EAJW,cAAc,KAAd,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,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,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C;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,yBAAyB,CAAC,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,uBAAuB,CAAC,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,aAAa,CAAC,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","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\n\r\nimport type { ECClass, SchemaItem } from \"@itwin/ecschema-metadata\";\r\nimport type { SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\r\nimport { NameMapping } from \"./NameMapping\";\r\nimport { applyRenamePropertyEdit, applyRenameSchemaItemEdit } from \"./RenameEditHandler\";\r\nimport { applySkipEdit } from \"./SkipEditHandler\";\r\n\r\n/**\r\n * An enumeration that has all the schema edit names.\r\n * @alpha\r\n */\r\nexport enum SchemaEditType {\r\n RenameSchemaItem = \"RenameSchemaItem\",\r\n RenameProperty = \"RenameProperty\",\r\n Skip = \"Skip\",\r\n}\r\n\r\n/**\r\n * Schema edit entry to rename a schema item.\r\n * @alpha\r\n */\r\nexport interface RenameSchemaItemEdit {\r\n type: SchemaEditType.RenameSchemaItem;\r\n key: string;\r\n value: string;\r\n}\r\n\r\n/**\r\n * Schema edit entry to rename a property of a class.\r\n * @alpha\r\n */\r\nexport interface RenamePropertyEdit {\r\n type: SchemaEditType.RenameProperty;\r\n key: string;\r\n value: string;\r\n}\r\n\r\n/**\r\n * Schema edit entry to skip a certain schema element matching the given key.\r\n * @alpha\r\n */\r\nexport interface SkipEdit {\r\n type: SchemaEditType.Skip;\r\n key: string;\r\n}\r\n\r\n/**\r\n * Union for all supported edits that can be applied to a schema.\r\n * @alpha\r\n */\r\nexport type AnySchemaEdits =\r\n SkipEdit |\r\n RenameSchemaItemEdit |\r\n RenamePropertyEdit;\r\n\r\nabstract class Editor {\r\n private readonly _edits: Array<AnySchemaEdits>;\r\n\r\n constructor(edits: Array<AnySchemaEdits>) {\r\n this._edits = edits;\r\n }\r\n\r\n protected add(edit: AnySchemaEdits) {\r\n const overrideEntry = this._edits.findIndex((entry) => {\r\n return entry.type === edit.type && entry.key === edit.key;\r\n });\r\n\r\n if (overrideEntry > -1) {\r\n this._edits[overrideEntry] = edit;\r\n } else {\r\n this._edits.push(edit);\r\n }\r\n }\r\n}\r\n\r\nclass PropertyEditor extends Editor {\r\n\r\n public rename(ecClass: ECClass, propertyName: string, newName: string) {\r\n this.add({\r\n type: SchemaEditType.RenameProperty,\r\n key: `${ecClass.fullName}.${propertyName}`,\r\n value: newName,\r\n });\r\n }\r\n\r\n public skip(ecClass: ECClass, propertyName: string) {\r\n this.add({\r\n type: SchemaEditType.Skip,\r\n key: `${ecClass.fullName}.${propertyName}`,\r\n });\r\n }\r\n}\r\n\r\nclass ItemEditor extends Editor {\r\n public rename(schemaItem: SchemaItem, newName: string) {\r\n this.add({\r\n type: SchemaEditType.RenameSchemaItem,\r\n key: schemaItem.key.fullName,\r\n value: newName,\r\n });\r\n }\r\n\r\n public skip(schemaItem: SchemaItem) {\r\n this.add({\r\n type: SchemaEditType.Skip,\r\n key: schemaItem.fullName,\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class\r\n * is to support saving of edits and load them again if needed.\r\n * @alpha\r\n */\r\nexport class SchemaEdits implements Iterable<AnySchemaEdits> {\r\n private readonly _edits: Array<AnySchemaEdits>;\r\n\r\n public readonly properties: PropertyEditor;\r\n public readonly items: ItemEditor;\r\n\r\n /**\r\n * @alpha\r\n */\r\n constructor(initialize?: ReadonlyArray<AnySchemaEdits>) {\r\n this._edits = [];\r\n\r\n if (initialize) {\r\n this._edits.push(...initialize);\r\n }\r\n\r\n this.items = new ItemEditor(this._edits);\r\n this.properties = new PropertyEditor(this._edits);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public async applyTo(differenceResult: SchemaDifferenceResult, nameMapping: NameMapping): Promise<void> {\r\n for (const schemaEdit of this._edits) {\r\n if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {\r\n applyRenameSchemaItemEdit(differenceResult, schemaEdit);\r\n nameMapping.addItemMapping(schemaEdit.key, schemaEdit.value);\r\n }\r\n if (schemaEdit.type === SchemaEditType.RenameProperty) {\r\n applyRenamePropertyEdit(differenceResult, schemaEdit);\r\n nameMapping.addPropertyMapping(schemaEdit.key, schemaEdit.value);\r\n }\r\n if (schemaEdit.type === SchemaEditType.Skip) {\r\n applySkipEdit(differenceResult, schemaEdit);\r\n }\r\n }\r\n }\r\n\r\n public toJSON(): ReadonlyArray<AnySchemaEdits> {\r\n return this._edits;\r\n }\r\n\r\n public [Symbol.iterator](): Iterator<AnySchemaEdits> {\r\n return this._edits[Symbol.iterator]();\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SkipEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SkipEditHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAMH;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAA8B,EAAE,IAAc;IAC1E,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAyC,CAAC;IACrG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACpD,OAAO;IACT,CAAC;IAED,MAAM,YAAY,GAAG,QAAQ,KAAK,SAAS;QACzC,CAAC,CAAC,sBAAsB,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC;QACpD,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEtC,MAAM,kBAAkB,GAA0B,EAAE,CAAC;IACrD,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3C,kBAAkB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,sBAAsB,CAAC,MAAM,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,SAAwC,EAAE,kBAAyC;IACjH,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QACpC,IAAI,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACrD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACtC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,WAAW,EAA0B,EAAE,QAAgB;IAChF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACxC,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,sBAAsB,CAAC,EAAE,WAAW,EAA0B,EAAE,QAAgB,EAAE,QAAgB;IACzG,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACxC,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzH,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport type { AnySchemaDifference, SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\nimport type { AnySchemaDifferenceConflict } from \"../../Differencing/SchemaConflicts\";\nimport type { SkipEdit } from \"./SchemaEdits\";\n\n/**\n * Applies a skip edit to the schema differences. It basically removes all entries that\n * that are associated with the item to skip.\n * @param result The result of a schema differencing run\n * @param edit The skip edit to be applied.\n * @internal\n */\nexport function applySkipEdit(result: SchemaDifferenceResult, edit: SkipEdit) {\n const [schemaName, itemName, pathName] = edit.key.split(\".\") as [string, string, string | undefined];\n if (!result.sourceSchemaName.startsWith(schemaName)) {\n return;\n }\n\n const foundIndices = pathName !== undefined\n ? findRelatedItemEntries(result, itemName, pathName)\n : findItemEntries(result, itemName);\n\n const skippedDifferences: AnySchemaDifference[] = [];\n for (const index of foundIndices.reverse()) {\n skippedDifferences.push(...result.differences.splice(index, 1));\n }\n\n if (result.conflicts) {\n removeRelatedConflicts(result.conflicts, skippedDifferences);\n }\n}\n\nfunction removeRelatedConflicts(conflicts: AnySchemaDifferenceConflict[], skippedDifferences: AnySchemaDifference[]) {\n const indices: number[] = [];\n conflicts.forEach((conflict, index) => {\n if (skippedDifferences.includes(conflict.difference)) {\n indices.push(index);\n }\n });\n\n for (const index of indices.reverse()) {\n conflicts.splice(index, 1);\n }\n}\n\nfunction findItemEntries({ differences }: SchemaDifferenceResult, itemName: string): number[] {\n const found: number[] = [];\n differences.forEach((difference, index) => {\n if (\"itemName\" in difference && difference.itemName === itemName) {\n found.push(index);\n }\n });\n return found;\n}\n\nfunction findRelatedItemEntries({ differences }: SchemaDifferenceResult, itemName: string, pathName: string): number[] {\n const found: number[] = [];\n differences.forEach((difference, index) => {\n if (\"itemName\" in difference && difference.itemName === itemName && \"path\" in difference && difference.path === pathName) {\n found.push(index);\n }\n });\n return found;\n}\n\n"]}
1
+ {"version":3,"file":"SkipEditHandler.js","sourceRoot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,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACtC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,WAAW,EAA0B,EAAE,QAAgB;IAChF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACxC,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,sBAAsB,CAAC,EAAE,WAAW,EAA0B,EAAE,QAAgB,EAAE,QAAgB;IACzG,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACxC,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzH,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\n\r\nimport type { AnySchemaDifference, SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\r\nimport type { AnySchemaDifferenceConflict } from \"../../Differencing/SchemaConflicts\";\r\nimport type { SkipEdit } from \"./SchemaEdits\";\r\n\r\n/**\r\n * Applies a skip edit to the schema differences. It basically removes all entries that\r\n * that are associated with the item to skip.\r\n * @param result The result of a schema differencing run\r\n * @param edit The skip edit to be applied.\r\n * @internal\r\n */\r\nexport function applySkipEdit(result: SchemaDifferenceResult, edit: SkipEdit) {\r\n const [schemaName, itemName, pathName] = edit.key.split(\".\") as [string, string, string | undefined];\r\n if (!result.sourceSchemaName.startsWith(schemaName)) {\r\n return;\r\n }\r\n\r\n const foundIndices = pathName !== undefined\r\n ? findRelatedItemEntries(result, itemName, pathName)\r\n : findItemEntries(result, itemName);\r\n\r\n const skippedDifferences: AnySchemaDifference[] = [];\r\n for (const index of foundIndices.reverse()) {\r\n skippedDifferences.push(...result.differences.splice(index, 1));\r\n }\r\n\r\n if (result.conflicts) {\r\n removeRelatedConflicts(result.conflicts, skippedDifferences);\r\n }\r\n}\r\n\r\nfunction removeRelatedConflicts(conflicts: AnySchemaDifferenceConflict[], skippedDifferences: AnySchemaDifference[]) {\r\n const indices: number[] = [];\r\n conflicts.forEach((conflict, index) => {\r\n if (skippedDifferences.includes(conflict.difference)) {\r\n indices.push(index);\r\n }\r\n });\r\n\r\n for (const index of indices.reverse()) {\r\n conflicts.splice(index, 1);\r\n }\r\n}\r\n\r\nfunction findItemEntries({ differences }: SchemaDifferenceResult, itemName: string): number[] {\r\n const found: number[] = [];\r\n differences.forEach((difference, index) => {\r\n if (\"itemName\" in difference && difference.itemName === itemName) {\r\n found.push(index);\r\n }\r\n });\r\n return found;\r\n}\r\n\r\nfunction findRelatedItemEntries({ differences }: SchemaDifferenceResult, itemName: string, pathName: string): number[] {\r\n const found: number[] = [];\r\n differences.forEach((difference, index) => {\r\n if (\"itemName\" in difference && difference.itemName === itemName && \"path\" in difference && difference.path === pathName) {\r\n found.push(index);\r\n }\r\n });\r\n return found;\r\n}\r\n\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClass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CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,SAAS,CAAC,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"]}
1
+ {"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEzD;;;GAGG;AACH,MAAM,CAAC,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;AACH,MAAM,CAAC,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,mBAAmB,CAAC,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,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAAkC;IAClG,KAAI,MAAM,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,SAAS,CAAC,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":["/*---------------------------------------------------------------------------------------------\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 { MutableEntityClass } from \"../Editing/Mutable/MutableEntityClass\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\nimport { toItemKey, updateSchemaItemKey } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new EntityClass into the target schema.\r\n * @internal\r\n */\r\nexport async function addEntityClass(context: SchemaMergeContext, change: EntityClassDifference) {\r\n await 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\r\n/**\r\n * Merges differences to an existing EntityClass in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyEntityClass(context: SchemaMergeContext, change: EntityClassDifference, itemKey: SchemaItemKey) {\r\n const item = await context.targetSchema.lookupItem(itemKey) as 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 * Merges Mixins to Entity Class schema items.\r\n * @internal\r\n */\r\nexport async function addClassMixins(context: SchemaMergeContext, change: EntityClassMixinDifference): Promise<void> {\r\n for(const mixinFullName of change.difference) {\r\n const mixinKey = await updateSchemaItemKey(context, mixinFullName);\r\n const entityKey = toItemKey(context, change.itemName);\r\n await context.editor.entities.addMixin(entityKey, mixinKey);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,qBAAqB,EAAsB,MAAM,0BAA0B,CAAC;AAKrF;;;GAGG;AACH,MAAM,CAAC,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;AACH,MAAM,CAAC,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,qBAAqB,CAAC,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
+ {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,qBAAqB,EAAsB,MAAM,0BAA0B,CAAC;AAKrF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACz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,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":["/*---------------------------------------------------------------------------------------------\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, type SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport type { EnumerationDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { MutableEnumeration } from \"../Editing/Mutable/MutableEnumeration\";\r\n\r\n/**\r\n * Merges a new Enumeration into the target schema.\r\n * @internal\r\n */\r\nexport async function addEnumeration(context: SchemaMergeContext, 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 one enumerator.\");\r\n }\r\n\r\n await 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\r\n/**\r\n * Merges differences to an existing Enumeration in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyEnumeration(context: SchemaMergeContext, change: EnumerationDifference, itemKey: SchemaItemKey) {\r\n const enumeration = await context.targetSchema.lookupItem(itemKey) as 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(enumeration.type!)}\", not \"${change.difference.type}\".`);\r\n }\r\n if(change.difference.label !== undefined) {\r\n await context.editor.enumerations.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.enumerations.setDescription(itemKey, change.difference.description);\r\n }\r\n if(change.difference.isStrict !== undefined) {\r\n enumeration.setIsStrict(change.difference.isStrict);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EnumeratorMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumeratorMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpD,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,OAAO,EAAE;QACvD,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI;QAC5B,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK;QAC9B,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK;QAC9B,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW;KAC3C,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,qDAAqD,MAAM,CAAC,IAAI,yBAAyB,CAAC,CAAC;IAC7G,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAClH,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,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\";\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"]}
1
+ {"version":3,"file":"EnumeratorMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumeratorMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpD,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,OAAO,EAAE;QACvD,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI;QAC5B,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK;QAC9B,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK;QAC9B,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW;KAC3C,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,qDAAqD,MAAM,CAAC,IAAI,yBAAyB,CAAC,CAAC;IAC7G,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAClH,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,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":["/*---------------------------------------------------------------------------------------------\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 { EnumeratorDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { toItemKey } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new Enumerator into the target schema.\r\n * @internal\r\n */\r\nexport async function addEnumerator(context: SchemaMergeContext, change: EnumeratorDifference) {\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 = toItemKey(context, change.itemName);\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}\r\n\r\n/**\r\n * Merges differences to an existing Enumerator in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyEnumerator(context: SchemaMergeContext, change: EnumeratorDifference, itemKey: SchemaItemKey) {\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 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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormatMerger.js","sourceRoot":"","sources":["../../../src/Merging/FormatMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAyD,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC9I,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhH,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAA2B,EAAE,MAAwB;IACnF,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACrE,KAAK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AAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAA2B,EAAE,MAAiC,EAAE,OAAsB;IAChI,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAkB,CAAC;IAE/E,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAChE,qDAAqD;QACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACzD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC5C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,oBAAuC,EAAE,UAAkB;IACpF,IAAI,YAAY,GAAiB,YAAY,CAAC,aAAa,CAAC;IAC5D,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAC7D,CAAC,CAAC,oBAAoB;QACtB,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzC,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QACrD,MAAM,WAAW,GAAG,gBAAgB,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;QACrE,YAAY,GAAG,YAAY,GAAG,WAAW,CAAC;IAC5C,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,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 { DelayedPromiseWithProps, InvertedUnit, LazyLoadedInvertedUnit, LazyLoadedUnit, 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: [LazyLoadedUnit | LazyLoadedInvertedUnit, 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 (Unit.isUnit(formatUnit))\n units.push([new DelayedPromiseWithProps(formatUnit.key, async () => formatUnit), label]);\n else if (InvertedUnit.isInvertedUnit(formatUnit))\n units.push([new DelayedPromiseWithProps(formatUnit.key, async () => formatUnit), label]);\n else\n throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);\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].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"]}
1
+ {"version":3,"file":"FormatMerger.js","sourceRoot":"","sources":["../../../src/Merging/FormatMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAyD,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC9I,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhH,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAA2B,EAAE,MAAwB;IACnF,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,C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AC","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 { DelayedPromiseWithProps, InvertedUnit, LazyLoadedInvertedUnit, LazyLoadedUnit, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\r\nimport { FormatTraits, parseFormatTrait, parseScientificType, parseShowSignOption } from \"@itwin/core-quantity\";\r\nimport { FormatDifference, FormatUnitDifference, FormatUnitLabelDifference } from \"../Differencing/SchemaDifference\";\r\nimport { MutableFormat } from \"../Editing/Mutable/MutableFormat\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new Format into the target schema.\r\n * @internal\r\n */\r\nexport async function addFormat(context: SchemaMergeContext, change: FormatDifference) {\r\n if (change.difference.type === undefined) {\r\n throw new Error(\"Format must define type\");\r\n }\r\n\r\n if (change.difference.composite && change.difference.composite.units) {\r\n for (let index = 0; index < change.difference.composite.units.length; index++) {\r\n const compositeUnitName = await updateSchemaItemFullName(context, change.difference.composite.units[index].name);\r\n change.difference.composite.units[index] = {\r\n name: compositeUnitName,\r\n label: change.difference.composite.units[index].label,\r\n }\r\n }\r\n }\r\n\r\n await context.editor.formats.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 composite: change.difference.composite,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing Format in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyFormat(context: SchemaMergeContext, change: FormatDifference, itemKey: SchemaItemKey) {\r\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\r\n if (change.difference.type !== undefined) {\r\n throw new Error(`Changing the format '${change.itemName}' type is not supported.`);\r\n }\r\n\r\n if (change.difference.label !== undefined) {\r\n await context.editor.formats.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if (change.difference.description !== undefined) {\r\n await context.editor.formats.setDescription(itemKey, change.difference.description);\r\n }\r\n if (change.difference.precision !== undefined) {\r\n format.setPrecision(change.difference.precision);\r\n }\r\n if (change.difference.roundFactor !== undefined) {\r\n format.setRoundFactor(change.difference.roundFactor);\r\n }\r\n if (change.difference.minWidth !== undefined) {\r\n format.setMinWidth(change.difference.minWidth);\r\n }\r\n if (change.difference.showSignOption !== undefined) {\r\n const showSignOption = parseShowSignOption(change.difference.showSignOption, change.itemName);\r\n format.setShowSignOption(showSignOption);\r\n }\r\n if (change.difference.formatTraits !== undefined) {\r\n const formatTraits = parseFormatTraits(change.difference.formatTraits, change.itemName);\r\n format.setFormatTraits(formatTraits);\r\n }\r\n if (change.difference.decimalSeparator !== undefined) {\r\n format.setDecimalSeparator(change.difference.decimalSeparator);\r\n }\r\n if (change.difference.thousandSeparator !== undefined) {\r\n format.setThousandSeparator(change.difference.thousandSeparator);\r\n }\r\n if (change.difference.uomSeparator !== undefined) {\r\n format.setUomSeparator(change.difference.uomSeparator);\r\n }\r\n if (change.difference.scientificType !== undefined) {\r\n const scientificType = parseScientificType(change.difference.scientificType, change.itemName);\r\n format.setScientificType(scientificType);\r\n }\r\n if (change.difference.stationOffsetSize !== undefined) {\r\n format.setStationOffsetSize(change.difference.stationOffsetSize);\r\n }\r\n if (change.difference.stationSeparator !== undefined) {\r\n format.setStationSeparator(change.difference.stationSeparator);\r\n }\r\n if (change.difference.composite !== undefined) {\r\n if (change.difference.composite.includeZero !== undefined) {\r\n format.setIncludeZero(change.difference.composite.includeZero);\r\n }\r\n if (change.difference.composite.spacer !== undefined) {\r\n format.setSpacer(change.difference.composite.spacer);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Merges source format units into the target format\r\n * @internal\r\n*/\r\nexport async function modifyFormatUnit(context: SchemaMergeContext, change: FormatUnitDifference, itemKey: SchemaItemKey) {\r\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\r\n\r\n const units: [LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined][] = [];\r\n for (const { name, label } of change.difference) {\r\n const lookupKey = await updateSchemaItemKey(context, name);\r\n const formatUnit = await context.editor.schemaContext.getSchemaItem(lookupKey);\r\n if (Unit.isUnit(formatUnit))\r\n units.push([new DelayedPromiseWithProps(formatUnit.key, async () => formatUnit), label]);\r\n else if (InvertedUnit.isInvertedUnit(formatUnit))\r\n units.push([new DelayedPromiseWithProps(formatUnit.key, async () => formatUnit), label]);\r\n else\r\n throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);\r\n }\r\n format.setUnits(units);\r\n}\r\n\r\n/**\r\n * Overrides format unit label\r\n * @internal\r\n*/\r\nexport async function modifyFormatUnitLabel(context: SchemaMergeContext, change: FormatUnitLabelDifference, itemKey: SchemaItemKey) {\r\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\r\n\r\n if (format.units !== undefined) {\r\n const unitKey = await updateSchemaItemKey(context, change.path);\r\n /* eslint-disable @typescript-eslint/prefer-for-of */\r\n for (let index = 0; index < format.units.length; index++) {\r\n if (format.units[index][0].matches(unitKey)) {\r\n format.units[index][1] = change.difference.label;\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction parseFormatTraits(formatTraitsFromJson: string | string[], formatName: string): FormatTraits {\r\n let formatTraits: FormatTraits = FormatTraits.Uninitialized;\r\n const formatTraitIterable = Array.isArray(formatTraitsFromJson)\r\n ? formatTraitsFromJson\r\n : formatTraitsFromJson.split(/,|;|\\|/);\r\n for (const formatTraitsString of formatTraitIterable) {\r\n const formatTrait = parseFormatTrait(formatTraitsString, formatName);\r\n formatTraits = formatTraits | formatTrait;\r\n }\r\n return formatTraits;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"InvertedUnitMerger.js","sourceRoot":"","sources":["../../../src/Merging/InvertedUnitMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB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AAM,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"]}
1
+ {"version":3,"file":"InvertedUnitMerger.js","sourceRoot":"","sources":["../../../src/Merging/InvertedUnitMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,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,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACrG,MAAM,CAAC,UAAU,CAAC,WAAW,GAAG,MAAM,wBAAwB,CAAC,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;AACH,MAAM,CAAC,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":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { InvertedUnitDifference } from \"../Differencing/SchemaDifference\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { updateSchemaItemFullName } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new InvertedUnit into the target schema.\r\n * @internal\r\n */\r\nexport async function addInvertedUnit(context: SchemaMergeContext, change: InvertedUnitDifference) {\r\n if (change.difference.unitSystem === undefined) {\r\n throw new Error(\"InvertedUnit must define unitSystem\");\r\n }\r\n if (change.difference.invertsUnit === undefined) {\r\n throw new Error(\"InvertedUnit must define invertsUnit\");\r\n }\r\n\r\n change.difference.unitSystem = await updateSchemaItemFullName(context, change.difference.unitSystem);\r\n change.difference.invertsUnit = await updateSchemaItemFullName(context, change.difference.invertsUnit);\r\n\r\n await context.editor.invertedUnits.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n unitSystem: change.difference.unitSystem,\r\n invertsUnit: change.difference.invertsUnit,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing InvertedUnit in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyInvertedUnit(context: SchemaMergeContext, change: InvertedUnitDifference, itemKey: SchemaItemKey) {\r\n if (change.difference.unitSystem !== undefined) {\r\n throw new Error(`Changing the invertedUnit '${change.itemName}' unitSystem is not supported.`);\r\n }\r\n if (change.difference.invertsUnit !== undefined) {\r\n throw new Error(`Changing the invertedUnit '${change.itemName}' invertsUnit is not supported.`);\r\n }\r\n\r\n if (change.difference.label !== undefined) {\r\n await context.editor.invertedUnits.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if (change.difference.description !== undefined) {\r\n await context.editor.invertedUnits.setDescription(itemKey, change.difference.description);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,uBAAuB,EAAU,YAAY,EAA0C,cAAc,EAAiB,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACtK,OAAO,EAAE,wBAAw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AC,CAAC,CAAC,CAAC,CAAC;YACpE,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAwB,CAAC;YACnF,IAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBAClB,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC5F,IAAG,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC;gBACvC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnG,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 { DelayedPromiseWithProps, Format, InvertedUnit, LazyLoadedInvertedUnit, LazyLoadedUnit, 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<[LazyLoadedUnit | LazyLoadedInvertedUnit, 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 if(Unit.isUnit(unit))\n unitAndLabels.push([new DelayedPromiseWithProps(unit.key, async () => unit), unitOverride[1]]);\n else if(InvertedUnit.isInvertedUnit(unit))\n unitAndLabels.push([new DelayedPromiseWithProps(unit.key, async () => 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":"AAOA,OAAO,EAAE,uBAAuB,EAAU,YAAY,EAA0C,cAAc,EAAiB,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACtK,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAAgC;IACnG,IAAI,MAAM,CAAC,UAAU,CAAC,eAAe,KAA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ClB,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC5F,IAAG,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC;gBACvC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnG,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":["/*---------------------------------------------------------------------------------------------\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, KindOfQuantityPresentationFormatDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableKindOfQuantity } from \"../Editing/Mutable/MutableKindOfQuantity\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { DelayedPromiseWithProps, Format, InvertedUnit, LazyLoadedInvertedUnit, LazyLoadedUnit, OverrideFormat, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\r\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new KindOfQuantity into the target schema.\r\n * @internal\r\n */\r\nexport async function addKindOfQuantity(context: SchemaMergeContext, change: KindOfQuantityDifference) {\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 const presentationFormat = await updateOverrideFormat(context, change.difference.presentationUnits[index]);\r\n change.difference.presentationUnits[index] = presentationFormat.fullName;\r\n }\r\n } else {\r\n const presentationFormat = await updateOverrideFormat(context, change.difference.presentationUnits);\r\n change.difference.presentationUnits = presentationFormat.name;\r\n }\r\n }\r\n\r\n await 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\r\n/**\r\n * Merges differences to an existing KindOfQuantity in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyKindOfQuantity(context: SchemaMergeContext, change: KindOfQuantityDifference, itemKey: SchemaItemKey) {\r\n const kindOfQuantity = await context.targetSchema.lookupItem(itemKey) as MutableKindOfQuantity;\r\n if(change.difference.label !== undefined) {\r\n await context.editor.kindOfQuantities.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.kindOfQuantities.setDescription(itemKey, change.difference.description);\r\n }\r\n if(change.difference.relativeError !== undefined) {\r\n kindOfQuantity.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 '${change.itemName}' persistenceUnit is not supported.`);\r\n }\r\n}\r\n/**\r\n * Merges a new presentation format into the target kind of quantity\r\n * @internal\r\n*/\r\nexport async function addPresentationFormat(context: SchemaMergeContext, change: KindOfQuantityPresentationFormatDifference, itemKey: SchemaItemKey) {\r\n for (const formatString of change.difference) {\r\n const presentationFormat = await updateOverrideFormat(context, formatString);\r\n if (OverrideFormat.isOverrideFormat(presentationFormat)) {\r\n await context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, presentationFormat);\r\n } else {\r\n await context.editor.kindOfQuantities.addPresentationFormat(itemKey, presentationFormat.key);\r\n }\r\n }\r\n}\r\n\r\nasync function updateOverrideFormat(context: SchemaMergeContext, formatString: string): Promise<Format | OverrideFormat> {\r\n // https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string\r\n const match = OverrideFormat.parseFormatString(formatString);\r\n const formatKey = await updateSchemaItemKey(context, match.name);\r\n const format = await context.targetSchema.lookupItem(formatKey) as Format;\r\n\r\n if (undefined === match.precision && undefined === match.unitAndLabels)\r\n return format;\r\n\r\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\r\n if (undefined !== match.unitAndLabels) {\r\n unitAndLabels = [];\r\n for (const unitOverride of match.unitAndLabels) {\r\n const unitKey = await updateSchemaItemKey(context, unitOverride[0]);\r\n const unit = await context.targetSchema.lookupItem(unitKey) as Unit | InvertedUnit;\r\n if(Unit.isUnit(unit))\r\n unitAndLabels.push([new DelayedPromiseWithProps(unit.key, async () => unit), unitOverride[1]]);\r\n else if(InvertedUnit.isInvertedUnit(unit))\r\n unitAndLabels.push([new DelayedPromiseWithProps(unit.key, async () => unit), unitOverride[1]]);\r\n }\r\n }\r\n return context.editor.kindOfQuantities.createFormatOverride(formatKey, match.precision, unitAndLabels);\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACnE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,SAAS,EAAE,MAAM,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;KAChF,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAiB,CAAC;IAC7E,IAAG,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,SAAS,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAClF,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC;QAC3C,IAAI,YAAY,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;YACvE,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACtD,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 { MutableMixin } from \"../Editing/Mutable/MutableMixin\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\nimport { modifyClass } from \"./ClassMerger\";\n\n/**\n * Merges a new Mixin into the target schema.\n * @internal\n */\nexport async function addMixinClass(context: SchemaMergeContext, change: MixinClassDifference) {\n if (change.difference.appliesTo === undefined) {\n throw new Error(\"Mixin must define appliesTo\");\n }\n await 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\n/**\n * Merges differences to an existing Mixin in the target schema.\n * @internal\n */\nexport async function modifyMixinClass(context: SchemaMergeContext, change: MixinClassDifference, itemKey: SchemaItemKey) {\n const mixin = await context.targetSchema.lookupItem(itemKey) as MutableMixin;\n if(change.difference.appliesTo !== undefined) {\n const appliesTo = await updateSchemaItemKey(context, change.difference.appliesTo);\n const currentValue = await mixin.appliesTo;\n if (currentValue !== undefined && !appliesTo.matches(currentValue.key)) {\n throw new Error(`Changing the mixin '${change.itemName}' appliesTo is not supported.`);\n }\n }\n\n return modifyClass(context, change, itemKey, mixin);\n}\n"]}
1
+ {"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACnE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,SAAS,EAAE,MAAM,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;KAChF,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAiB,CAAC;IAC7E,IAAG,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,SAAS,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAClF,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC;QAC3C,IAAI,YAAY,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;YACvE,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACtD,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 { MutableMixin } from \"../Editing/Mutable/MutableMixin\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\n\r\n/**\r\n * Merges a new Mixin into the target schema.\r\n * @internal\r\n */\r\nexport async function addMixinClass(context: SchemaMergeContext, change: MixinClassDifference) {\r\n if (change.difference.appliesTo === undefined) {\r\n throw new Error(\"Mixin must define appliesTo\");\r\n }\r\n await 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\r\n/**\r\n * Merges differences to an existing Mixin in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyMixinClass(context: SchemaMergeContext, change: MixinClassDifference, itemKey: SchemaItemKey) {\r\n const mixin = await context.targetSchema.lookupItem(itemKey) as MutableMixin;\r\n if(change.difference.appliesTo !== undefined) {\r\n const appliesTo = await updateSchemaItemKey(context, change.difference.appliesTo);\r\n const currentValue = await mixin.appliesTo;\r\n if (currentValue !== undefined && !appliesTo.matches(currentValue.key)) {\r\n throw new Error(`Changing the mixin '${change.itemName}' appliesTo is not supported.`);\r\n }\r\n }\r\n\r\n return modifyClass(context, change, itemKey, mixin);\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAsB,MAAM,0BAA0B,CAAC;AAE7F;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,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C,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/D,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 { PhenomenonDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutablePhenomenon } from \"../Editing/Mutable/MutablePhenomenon\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECSchemaError, ECSchemaStatus, type SchemaItemKey } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new Phenomenon into the target schema.\n * @internal\n */\nexport async function addPhenomenon(context: SchemaMergeContext, change: PhenomenonDifference) {\n if (change.difference.definition === undefined) {\n throw new Error(\"Phenomenon must define definition\");\n }\n\n await 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\n/**\n * Merges differences to an existing Phenomenon in the target schema.\n * @internal\n */\nexport async function modifyPhenomenon(context: SchemaMergeContext, change: PhenomenonDifference, itemKey: SchemaItemKey) {\n const phenomenon = await context.targetSchema.lookupItem(itemKey) as MutablePhenomenon;\n if(change.difference.label !== undefined) {\n await context.editor.phenomenons.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.phenomenons.setDescription(itemKey, change.difference.description);\n }\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 ECSchemaError(ECSchemaStatus.InvalidECJson, `The Phenomenon ${change.itemName} has an invalid 'definition' attribute.`);\n\n await phenomenon.setDefinition(change.difference.definition);\n }\n}\n"]}
1
+ {"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AA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AC,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE;YACpH,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,aAAa,EAAE,kBAAkB,MAAM,CAAC,QAAQ,yCAAyC,CAAC,CAAC;QAEpI,MAAM,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport type { PhenomenonDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutablePhenomenon } from \"../Editing/Mutable/MutablePhenomenon\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { ECSchemaError, ECSchemaStatus, type SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new Phenomenon into the target schema.\r\n * @internal\r\n */\r\nexport async function addPhenomenon(context: SchemaMergeContext, change: PhenomenonDifference) {\r\n if (change.difference.definition === undefined) {\r\n throw new Error(\"Phenomenon must define definition\");\r\n }\r\n\r\n await 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\r\n/**\r\n * Merges differences to an existing Phenomenon in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyPhenomenon(context: SchemaMergeContext, change: PhenomenonDifference, itemKey: SchemaItemKey) {\r\n const phenomenon = await context.targetSchema.lookupItem(itemKey) as MutablePhenomenon;\r\n if(change.difference.label !== undefined) {\r\n await context.editor.phenomenons.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.phenomenons.setDescription(itemKey, change.difference.description);\r\n }\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 ECSchemaError(ECSchemaStatus.InvalidECJson, `The Phenomenon ${change.itemName} has an invalid 'definition' attribute.`);\r\n\r\n await phenomenon.setDefinition(change.difference.definition);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyCategoryMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAA2B,EAAE,MAAkC;IACvG,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAC/E,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;KACrC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,OAA2B,EAAE,MAAkC,EAAE,OAAsB;IAClI,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC5F,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACjG,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5C,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC3F,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 { PropertyCategoryDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new PropertyCategory into the target schema.\n * @internal\n */\nexport async function addPropertyCategory(context: SchemaMergeContext, change: PropertyCategoryDifference) {\n if (change.difference.priority === undefined) {\n throw new Error(\"PropertyCategory must define priority\");\n }\n\n await 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\n/**\n * Merges differences to an existing PropertyCategory in the target schema.\n * @internal\n */\nexport async function modifyPropertyCategory(context: SchemaMergeContext, change: PropertyCategoryDifference, itemKey: SchemaItemKey) {\n if(change.difference.label !== undefined) {\n await context.editor.propertyCategories.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.propertyCategories.setDescription(itemKey, change.difference.description);\n }\n if(change.difference.priority !== undefined) {\n await context.editor.propertyCategories.setPriority(itemKey, change.difference.priority);\n }\n}\n"]}
1
+ {"version":3,"file":"PropertyCategoryMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAA2B,EAAE,MAAkC;IACvG,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAC/E,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;KACrC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,OAA2B,EAAE,MAAkC,EAAE,OAAsB;IAClI,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC5F,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACjG,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5C,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC3F,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport type { PropertyCategoryDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new PropertyCategory into the target schema.\r\n * @internal\r\n */\r\nexport async function addPropertyCategory(context: SchemaMergeContext, change: PropertyCategoryDifference) {\r\n if (change.difference.priority === undefined) {\r\n throw new Error(\"PropertyCategory must define priority\");\r\n }\r\n\r\n await 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\r\n/**\r\n * Merges differences to an existing PropertyCategory in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyPropertyCategory(context: SchemaMergeContext, change: PropertyCategoryDifference, itemKey: SchemaItemKey) {\r\n if(change.difference.label !== undefined) {\r\n await context.editor.propertyCategories.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.propertyCategories.setDescription(itemKey, change.difference.description);\r\n }\r\n if(change.difference.priority !== undefined) {\r\n await context.editor.propertyCategories.setPriority(itemKey, change.difference.priority);\r\n }\r\n}\r\n"]}