@itwin/ecschema-editing 5.0.0-dev.5 → 5.0.0-dev.52

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 (171) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/lib/cjs/Differencing/Errors.js.map +1 -1
  3. package/lib/cjs/Differencing/SchemaConflicts.d.ts +3 -1
  4. package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
  5. package/lib/cjs/Differencing/SchemaConflicts.js +2 -0
  6. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  7. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +4 -3
  8. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
  9. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +53 -11
  10. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  11. package/lib/cjs/Differencing/SchemaDifference.d.ts +33 -4
  12. package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
  13. package/lib/cjs/Differencing/SchemaDifference.js +53 -5
  14. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  15. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts +2 -1
  16. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
  17. package/lib/cjs/Differencing/SchemaDifferenceValidator.js +71 -16
  18. package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
  19. package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts.map +1 -1
  20. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js +4 -0
  21. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
  22. package/lib/cjs/Differencing/Utils.js.map +1 -1
  23. package/lib/cjs/Editing/Constants.js.map +1 -1
  24. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  25. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  26. package/lib/cjs/Editing/ECClasses.js +4 -19
  27. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  28. package/lib/cjs/Editing/Editor.js +4 -4
  29. package/lib/cjs/Editing/Editor.js.map +1 -1
  30. package/lib/cjs/Editing/Entities.js.map +1 -1
  31. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  32. package/lib/cjs/Editing/Exception.js.map +1 -1
  33. package/lib/cjs/Editing/Formats.js.map +1 -1
  34. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  35. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  36. package/lib/cjs/Editing/Mixins.js.map +1 -1
  37. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  38. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  39. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +2 -1
  40. package/lib/cjs/Editing/Mutable/MutableClass.d.ts.map +1 -1
  41. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  42. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  43. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  44. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  45. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +8 -1
  46. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts.map +1 -1
  47. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  48. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  49. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  50. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  51. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  52. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  53. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  54. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  55. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  56. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  57. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  58. package/lib/cjs/Editing/Mutable/MutableSchemaItem.js.map +1 -1
  59. package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -1
  60. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  61. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  62. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  63. package/lib/cjs/Editing/Properties.d.ts +2 -2
  64. package/lib/cjs/Editing/Properties.js +2 -2
  65. package/lib/cjs/Editing/Properties.js.map +1 -1
  66. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  67. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  68. package/lib/cjs/Editing/RelationshipClasses.js +5 -2
  69. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  70. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  71. package/lib/cjs/Editing/Structs.js.map +1 -1
  72. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  73. package/lib/cjs/Editing/Units.js.map +1 -1
  74. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  75. package/lib/cjs/Merging/ConstantMerger.js +3 -3
  76. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  77. package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -1
  78. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  79. package/lib/cjs/Merging/CustomAttributeMerger.js +5 -9
  80. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  81. package/lib/cjs/Merging/Edits/NameMapping.d.ts +22 -0
  82. package/lib/cjs/Merging/Edits/NameMapping.d.ts.map +1 -0
  83. package/lib/cjs/Merging/Edits/NameMapping.js +51 -0
  84. package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -0
  85. package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts +1 -1
  86. package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -1
  87. package/lib/cjs/Merging/Edits/RenameEditHandler.js +1 -260
  88. package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
  89. package/lib/cjs/Merging/Edits/SchemaEdits.d.ts +9 -6
  90. package/lib/cjs/Merging/Edits/SchemaEdits.d.ts.map +1 -1
  91. package/lib/cjs/Merging/Edits/SchemaEdits.js +15 -14
  92. package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
  93. package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -1
  94. package/lib/cjs/Merging/EntityClassMerger.js +1 -2
  95. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  96. package/lib/cjs/Merging/EnumerationMerger.js +1 -1
  97. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  98. package/lib/cjs/Merging/EnumeratorMerger.d.ts.map +1 -1
  99. package/lib/cjs/Merging/EnumeratorMerger.js +2 -2
  100. package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
  101. package/lib/cjs/Merging/FormatMerger.d.ts +24 -0
  102. package/lib/cjs/Merging/FormatMerger.d.ts.map +1 -0
  103. package/lib/cjs/Merging/FormatMerger.js +138 -0
  104. package/lib/cjs/Merging/FormatMerger.js.map +1 -0
  105. package/lib/cjs/Merging/InvertedUnitMerger.d.ts +14 -0
  106. package/lib/cjs/Merging/InvertedUnitMerger.d.ts.map +1 -0
  107. package/lib/cjs/Merging/InvertedUnitMerger.js +45 -0
  108. package/lib/cjs/Merging/InvertedUnitMerger.js.map +1 -0
  109. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +1 -1
  110. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  111. package/lib/cjs/Merging/KindOfQuantityMerger.js +4 -5
  112. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  113. package/lib/cjs/Merging/MixinMerger.js +1 -1
  114. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  115. package/lib/cjs/Merging/PhenomenonMerger.js +1 -1
  116. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  117. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
  118. package/lib/cjs/Merging/PropertyMerger.js +25 -23
  119. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  120. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  121. package/lib/cjs/Merging/SchemaMerger.d.ts +5 -3
  122. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  123. package/lib/cjs/Merging/SchemaMerger.js +35 -5
  124. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  125. package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +14 -8
  126. package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
  127. package/lib/cjs/Merging/SchemaMergingVisitor.js +41 -17
  128. package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
  129. package/lib/cjs/Merging/SchemaMergingWalker.d.ts.map +1 -1
  130. package/lib/cjs/Merging/SchemaMergingWalker.js +2 -0
  131. package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
  132. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  133. package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
  134. package/lib/cjs/Merging/UnitMerger.d.ts +14 -0
  135. package/lib/cjs/Merging/UnitMerger.d.ts.map +1 -0
  136. package/lib/cjs/Merging/UnitMerger.js +62 -0
  137. package/lib/cjs/Merging/UnitMerger.js.map +1 -0
  138. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
  139. package/lib/cjs/Merging/Utils.d.ts +11 -0
  140. package/lib/cjs/Merging/Utils.d.ts.map +1 -1
  141. package/lib/cjs/Merging/Utils.js +22 -2
  142. package/lib/cjs/Merging/Utils.js.map +1 -1
  143. package/lib/cjs/Validation/Diagnostic.js +12 -16
  144. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  145. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  146. package/lib/cjs/Validation/ECRules.js.map +1 -1
  147. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  148. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  149. package/lib/cjs/Validation/Rules.js.map +1 -1
  150. package/lib/cjs/Validation/SchemaChanges.js +1 -1
  151. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  152. package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +2 -2
  153. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  154. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  155. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +1 -1
  156. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts.map +1 -1
  157. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +1 -1
  158. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  159. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts.map +1 -1
  160. package/lib/cjs/Validation/SchemaCompareVisitor.js +21 -23
  161. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  162. package/lib/cjs/Validation/SchemaComparer.d.ts +22 -1
  163. package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
  164. package/lib/cjs/Validation/SchemaComparer.js +27 -5
  165. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  166. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  167. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  168. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  169. package/lib/cjs/ecschema-editing.js.map +1 -1
  170. package/package.json +11 -11
  171. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1 +1 @@
1
- {"version":3,"file":"RenameEditHandler.js","sourceRoot":"","sources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AC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,WAAW,EAA0B,EAAE,MAAqB,EAAE,MAAqB;IAC5G,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE,CAAC;QAChC,IAAI,KAAK,CAAC,UAAU,KAAK,kCAAc,CAAC,KAAK,EAAE,CAAC;YAC9C,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,KAAK,CAAC,UAAU,KAAK,mCAAgB,CAAC,gBAAgB,EAAE,CAAC;YAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,IAAI,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBAChD,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;gBACxC,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,6BAA6B,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,uCAAuC,CAAC,KAAK,CAAC,EAAE,CAAC;YACvG,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,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 { AnyClassItemDifference, AnySchemaItemDifference, ClassPropertyDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, SchemaDifferenceResult, SchemaOtherTypes, SchemaType } from \"../../Differencing/SchemaDifference\";\r\nimport { NavigationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, RelationshipConstraintProps, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, StructArrayPropertyProps, StructPropertyProps } 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, postProcessing: (cb: () => void) => void) {\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 postProcessing(() => {\r\n renameSchemaItem(result, edit, itemDifference.schemaType);\r\n });\r\n}\r\n\r\nfunction renameSchemaItem(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit, schemaType: SchemaType) {\r\n const schemaKey = SchemaKey.parseString(result.sourceSchemaName);\r\n const [_schemaName, itemName] = SchemaItem.parseFullName(edit.key);\r\n const oldKey = new SchemaItemKey(itemName, schemaKey);\r\n const newKey = new SchemaItemKey(edit.value, schemaKey);\r\n\r\n switch (schemaType) {\r\n case SchemaItemType.CustomAttributeClass:\r\n renameCustomAttributeClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.EntityClass:\r\n renameEntityClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Enumeration:\r\n renameEnumerationName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Format:\r\n break;\r\n case SchemaItemType.InvertedUnit:\r\n break;\r\n case SchemaItemType.KindOfQuantity:\r\n renameKindOfQuantityName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Mixin:\r\n renameMixinName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Phenomenon:\r\n renamePhenomenonName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.PropertyCategory:\r\n renamePropertyCategoryName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.RelationshipClass:\r\n renameRelationshipClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.StructClass:\r\n renameStructClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Unit:\r\n break;\r\n case SchemaItemType.UnitSystem:\r\n break;\r\n }\r\n}\r\n\r\nfunction renameBaseClass(difference: AnyClassItemDifference[\"difference\"], oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n if (difference.baseClass && oldKey.matchesFullName(difference.baseClass)) {\r\n difference.baseClass = newKey.fullName;\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\r\nfunction renameRelationshipConstraint(change: RelationshipClassDifference | RelationshipConstraintClassDifference, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n if (change.schemaType === SchemaItemType.RelationshipClass) {\r\n const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];\r\n for (const props of constraintProps) {\r\n if (props) {\r\n if (props.abstractConstraint && oldKey.matchesFullName(props.abstractConstraint)) {\r\n props.abstractConstraint = newKey.fullName;\r\n }\r\n if (props.constraintClasses !== undefined) {\r\n for (let i = 0; i < props.constraintClasses.length; i++) {\r\n if (oldKey.matchesFullName(props.constraintClasses[i]))\r\n props.constraintClasses[i] = newKey.fullName;\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < change.difference.length; i++) {\r\n if (oldKey.matchesFullName(change.difference[i]))\r\n change.difference[i] = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renamePropertyCategoryName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.PropertyCategory) {\r\n renameName(entry, oldKey.name, newKey.name);\r\n }\r\n\r\n if (Utils.isClassDifference(entry) && entry.difference.properties) {\r\n for (const property of entry.difference.properties) {\r\n if (property.category && oldKey.matchesFullName(property.category)) {\r\n const props = property as Editable<typeof property>;\r\n props.category = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (entry.schemaType === SchemaOtherTypes.Property) {\r\n if (entry.difference.category && oldKey.matchesFullName(entry.difference.category)) {\r\n entry.difference.category = newKey.fullName;\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction renameKindOfQuantityName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (Utils.isClassDifference(entry) && entry.difference.properties) {\r\n for (const property of entry.difference.properties) {\r\n if (property.kindOfQuantity && oldKey.matchesFullName(property.kindOfQuantity)) {\r\n const props = property as Editable<typeof property>;\r\n props.kindOfQuantity = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (entry.schemaType === SchemaOtherTypes.Property) {\r\n if (entry.difference.kindOfQuantity && oldKey.matchesFullName(entry.difference.kindOfQuantity)) {\r\n entry.difference.kindOfQuantity = newKey.fullName;\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction renameEnumerationName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.type === \"PrimitiveProperty\" || property.type === \"PrimitiveArrayProperty\") {\r\n const props = property as Editable<PrimitivePropertyProps | PrimitiveArrayPropertyProps>;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property && (\r\n change.difference.type === \"PrimitiveProperty\" || change.difference.type === \"PrimitiveArrayProperty\"\r\n )) {\r\n const props = change.difference as Editable<PrimitivePropertyProps | PrimitiveArrayPropertyProps>;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renamePhenomenonName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.Constant || entry.schemaType === SchemaItemType.Unit) {\r\n if (entry.difference.phenomenon && oldKey.matchesFullName(entry.difference.phenomenon))\r\n entry.difference.phenomenon = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renameStructClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (change.schemaType === SchemaItemType.StructClass) {\r\n renameBaseClass(change.difference, oldKey, newKey);\r\n }\r\n\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.type === \"StructProperty\" || property.type === \"StructArrayProperty\") {\r\n const props = property as Editable<StructPropertyProps | StructArrayPropertyProps>;;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property && (\r\n change.difference.type === \"StructProperty\" || change.difference.type === \"StructArrayProperty\"\r\n )) {\r\n const props = change.difference as Editable<StructPropertyProps | StructArrayPropertyProps>;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renameCustomAttributeClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (change.schemaType === SchemaItemType.CustomAttributeClass) {\r\n renameBaseClass(change.difference, oldKey, newKey);\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.CustomAttributeInstance) {\r\n if (change.difference.className && oldKey.matchesFullName(change.difference.className)) {\r\n change.difference.className = newKey.fullName;\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property || Utils.isClassDifference(change)) {\r\n if (change.difference.customAttributes) {\r\n for (const customAttribute of change.difference.customAttributes) {\r\n if (oldKey.matchesFullName(customAttribute.className))\r\n customAttribute.className = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.customAttributes) {\r\n for (const customAttribute of property.customAttributes) {\r\n if (oldKey.matchesFullName(customAttribute.className))\r\n customAttribute.className = newKey.fullName;\r\n }\r\n }\r\n }\r\n }\r\n // https://github.com/iTwin/itwinjs-core/issues/7020\r\n /* if (change.schemaType === SchemaItemType.RelationshipClass) {\r\n const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];\r\n for (const props of constraintProps) {\r\n if (props.customAttributes !== undefined) {\r\n for (const customAttribute of props.customAttributes) {\r\n if (oldKey.matchesFullName(customAttribute.className))\r\n customAttribute.className = newKey.fullName;\r\n }\r\n }\r\n }\r\n } */\r\n }\r\n}\r\n\r\nfunction renameRelationshipClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (change.schemaType === SchemaItemType.RelationshipClass) {\r\n renameBaseClass(change.difference, oldKey, newKey);\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property && change.difference.type === \"NavigationProperty\") {\r\n const props = change.difference as Editable<NavigationPropertyProps>;\r\n if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))\r\n props.relationshipName = newKey.fullName;\r\n }\r\n\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.type === \"NavigationProperty\") {\r\n const props = property as Editable<NavigationPropertyProps>;\r\n if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))\r\n props.relationshipName = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaItemType.RelationshipClass || change.schemaType === SchemaOtherTypes.RelationshipConstraintClass) {\r\n renameRelationshipConstraint(change, oldKey, newKey);\r\n }\r\n }\r\n}\r\n\r\nfunction renameEntityClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.EntityClass) {\r\n renameName(entry, oldKey.name, newKey.name);\r\n renameBaseClass(entry.difference, oldKey, newKey);\r\n }\r\n\r\n if (entry.schemaType === SchemaItemType.Mixin) {\r\n if (entry.difference.appliesTo && oldKey.matchesFullName(entry.difference.appliesTo))\r\n entry.difference.appliesTo = newKey.fullName;\r\n }\r\n\r\n if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {\r\n renameRelationshipConstraint(entry, oldKey, newKey);\r\n }\r\n }\r\n}\r\n\r\nfunction renameMixinName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.Mixin) {\r\n renameBaseClass(entry.difference, oldKey, newKey);\r\n }\r\n\r\n if (entry.schemaType === SchemaOtherTypes.EntityClassMixin) {\r\n for (let i = 0; i < entry.difference.length; i++) {\r\n if (oldKey.matchesFullName(entry.difference[i])) {\r\n entry.difference[i] = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {\r\n renameRelationshipConstraint(entry, oldKey, newKey);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RenameEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/RenameEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAcH,0DAuBC;AAKD,8DAuBC;AA7DD,gEAAsD;AACtD,kDAAkD;AAMlD;;GAEG;AACH,SAAgB,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,yB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AS,EAAE,CAAC;QACjC,OAAO;IACT,CAAC;IAED,UAAU,CAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAEjD,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,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":["/*---------------------------------------------------------------------------------------------\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,7 +1,9 @@
1
1
  /** @packageDocumentation
2
2
  * @module Merging
3
3
  */
4
+ import type { ECClass, SchemaItem } from "@itwin/ecschema-metadata";
4
5
  import type { SchemaDifferenceResult } from "../../Differencing/SchemaDifference";
6
+ import { NameMapping } from "./NameMapping";
5
7
  /**
6
8
  * An enumeration that has all the schema edit names.
7
9
  * @alpha
@@ -48,19 +50,19 @@ declare abstract class Editor {
48
50
  protected add(edit: AnySchemaEdits): void;
49
51
  }
50
52
  declare class PropertyEditor extends Editor {
51
- rename(schemaName: string, className: string, propertyName: string, newName: string): void;
52
- skip(schemaName: string, className: string, propertyName: string): void;
53
+ rename(ecClass: ECClass, propertyName: string, newName: string): void;
54
+ skip(ecClass: ECClass, propertyName: string): void;
53
55
  }
54
56
  declare class ItemEditor extends Editor {
55
- rename(schemaName: string, itemName: string, newName: string): void;
56
- skip(schemaName: string, itemName: string): void;
57
+ rename(schemaItem: SchemaItem, newName: string): void;
58
+ skip(schemaItem: SchemaItem): void;
57
59
  }
58
60
  /**
59
61
  * Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class
60
62
  * is to support saving of edits and load them again if needed.
61
63
  * @alpha
62
64
  */
63
- export declare class SchemaEdits {
65
+ export declare class SchemaEdits implements Iterable<AnySchemaEdits> {
64
66
  private readonly _edits;
65
67
  readonly properties: PropertyEditor;
66
68
  readonly items: ItemEditor;
@@ -71,8 +73,9 @@ export declare class SchemaEdits {
71
73
  /**
72
74
  * @internal
73
75
  */
74
- applyTo(differenceResult: SchemaDifferenceResult): Promise<void>;
76
+ applyTo(differenceResult: SchemaDifferenceResult, nameMapping: NameMapping): Promise<void>;
75
77
  toJSON(): ReadonlyArray<AnySchemaEdits>;
78
+ [Symbol.iterator](): Iterator<AnySchemaEdits>;
76
79
  }
77
80
  export {};
78
81
  //# sourceMappingURL=SchemaEdits.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaEdits.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAIlF;;;GAGG;AACH,oBAAY,cAAc;IACxB,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;IACjC,IAAI,SAAS;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,cAAc,CAAC,gBAAgB,CAAC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW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AAM;CAMnD;AAED,cAAM,UAAW,SAAQ,MAAM;IACtB,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM;IAQ9C,IAAI,CAAC,UAAU,EAAE,UAAU;CAMnC;AAED;;;;GAIG;AACH,qBAAa,WAAY,YAAW,QAAQ,CAAC,cAAc,CAAC;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAE/C,SAAgB,UAAU,EAAE,cAAc,CAAC;IAC3C,SAAgB,KAAK,EAAE,UAAU,CAAC;IAElC;;OAEG;gBACS,UAAU,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC;IAWtD;;OAEG;IACU,OAAO,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBhG,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC;IAIvC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC;CAGrD"}
@@ -37,32 +37,32 @@ class Editor {
37
37
  }
38
38
  }
39
39
  class PropertyEditor extends Editor {
40
- rename(schemaName, className, propertyName, newName) {
40
+ rename(ecClass, propertyName, newName) {
41
41
  this.add({
42
42
  type: SchemaEditType.RenameProperty,
43
- key: `${schemaName}.${className}.${propertyName}`,
43
+ key: `${ecClass.fullName}.${propertyName}`,
44
44
  value: newName,
45
45
  });
46
46
  }
47
- skip(schemaName, className, propertyName) {
47
+ skip(ecClass, propertyName) {
48
48
  this.add({
49
49
  type: SchemaEditType.Skip,
50
- key: `${schemaName}.${className}.${propertyName}`,
50
+ key: `${ecClass.fullName}.${propertyName}`,
51
51
  });
52
52
  }
53
53
  }
54
54
  class ItemEditor extends Editor {
55
- rename(schemaName, itemName, newName) {
55
+ rename(schemaItem, newName) {
56
56
  this.add({
57
57
  type: SchemaEditType.RenameSchemaItem,
58
- key: `${schemaName}.${itemName}`,
58
+ key: schemaItem.key.fullName,
59
59
  value: newName,
60
60
  });
61
61
  }
62
- skip(schemaName, itemName) {
62
+ skip(schemaItem) {
63
63
  this.add({
64
64
  type: SchemaEditType.Skip,
65
- key: `${schemaName}.${itemName}`,
65
+ key: schemaItem.fullName,
66
66
  });
67
67
  }
68
68
  }
@@ -86,26 +86,27 @@ class SchemaEdits {
86
86
  /**
87
87
  * @internal
88
88
  */
89
- async applyTo(differenceResult) {
90
- const postProcessing = [];
89
+ async applyTo(differenceResult, nameMapping) {
91
90
  for (const schemaEdit of this._edits) {
92
91
  if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {
93
- (0, RenameEditHandler_1.applyRenameSchemaItemEdit)(differenceResult, schemaEdit, postProcessing.push.bind(postProcessing));
92
+ (0, RenameEditHandler_1.applyRenameSchemaItemEdit)(differenceResult, schemaEdit);
93
+ nameMapping.addItemMapping(schemaEdit.key, schemaEdit.value);
94
94
  }
95
95
  if (schemaEdit.type === SchemaEditType.RenameProperty) {
96
96
  (0, RenameEditHandler_1.applyRenamePropertyEdit)(differenceResult, schemaEdit);
97
+ nameMapping.addPropertyMapping(schemaEdit.key, schemaEdit.value);
97
98
  }
98
99
  if (schemaEdit.type === SchemaEditType.Skip) {
99
100
  (0, SkipEditHandler_1.applySkipEdit)(differenceResult, schemaEdit);
100
101
  }
101
102
  }
102
- for (const callback of postProcessing) {
103
- callback();
104
- }
105
103
  }
106
104
  toJSON() {
107
105
  return this._edits;
108
106
  }
107
+ [Symbol.iterator]() {
108
+ return this._edits[Symbol.iterator]();
109
+ }
109
110
  }
110
111
  exports.SchemaEdits = SchemaEdits;
111
112
  //# sourceMappingURL=SchemaEdits.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaEdits.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,2DAAyF;AACzF,uDAAkD;AAElD;;;GAGG;AACH,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uDAAqC,CA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CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAA,+BAAa,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,cAAc,EAAE,CAAC;YACtC,QAAQ,EAAE,CAAC;QACb,CAAC;IACH,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AA7CD,kCA6CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 { SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\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(schemaName: string, className: string, propertyName: string, newName: string) {\r\n this.add({\r\n type: SchemaEditType.RenameProperty,\r\n key: `${schemaName}.${className}.${propertyName}`,\r\n value: newName,\r\n });\r\n }\r\n\r\n public skip(schemaName: string, className: string, propertyName: string) {\r\n this.add({\r\n type: SchemaEditType.Skip,\r\n key: `${schemaName}.${className}.${propertyName}`,\r\n });\r\n }\r\n}\r\n\r\nclass ItemEditor extends Editor {\r\n public rename(schemaName: string, itemName: string, newName: string) {\r\n this.add({\r\n type: SchemaEditType.RenameSchemaItem,\r\n key: `${schemaName}.${itemName}`,\r\n value: newName,\r\n });\r\n }\r\n\r\n public skip(schemaName: string, itemName: string) {\r\n this.add({\r\n type: SchemaEditType.Skip,\r\n key: `${schemaName}.${itemName}`,\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 {\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): Promise<void> {\r\n const postProcessing: Array<() => void> = [];\r\n for (const schemaEdit of this._edits) {\r\n if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {\r\n applyRenameSchemaItemEdit(differenceResult, schemaEdit, postProcessing.push.bind(postProcessing));\r\n }\r\n if (schemaEdit.type === SchemaEditType.RenameProperty) {\r\n applyRenamePropertyEdit(differenceResult, schemaEdit);\r\n }\r\n if (schemaEdit.type === SchemaEditType.Skip) {\r\n applySkipEdit(differenceResult, schemaEdit);\r\n }\r\n }\r\n\r\n for (const callback of postProcessing) {\r\n callback();\r\n }\r\n }\r\n\r\n public toJSON(): ReadonlyArray<AnySchemaEdits> {\r\n return this._edits;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SchemaEdits.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,2DAAyF;AACzF,uDAAkD;AAElD;;;GAGG;AACH,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uDAAqC,CAAA;IACrC,mDAAiC,CAAA;IACjC,+BAAa,CAAA;AACf,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAwCD,MAAe,MAAM;IAGnB,YAAY,KAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAES,GAAG,CAAC,IAAoB;QAChC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YACpD,OAAO,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,aAAa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GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,gBAAwC,EAAE,WAAwB;QACrF,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACrC,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,gBAAgB,EAAE,CAAC;gBACxD,IAAA,6CAAyB,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;gBACxD,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YAC/D,CAAC;YACD,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc,EAAE,CAAC;gBACtD,IAAA,2CAAuB,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;gBACtD,WAAW,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YACnE,CAAC;YACD,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAA,+BAAa,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;IACH,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxC,CAAC;CACF;AA9CD,kCA8CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport type { ECClass, SchemaItem } from \"@itwin/ecschema-metadata\";\nimport type { SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\nimport { NameMapping } from \"./NameMapping\";\nimport { applyRenamePropertyEdit, applyRenameSchemaItemEdit } from \"./RenameEditHandler\";\nimport { applySkipEdit } from \"./SkipEditHandler\";\n\n/**\n * An enumeration that has all the schema edit names.\n * @alpha\n */\nexport enum SchemaEditType {\n RenameSchemaItem = \"RenameSchemaItem\",\n RenameProperty = \"RenameProperty\",\n Skip = \"Skip\",\n}\n\n/**\n * Schema edit entry to rename a schema item.\n * @alpha\n */\nexport interface RenameSchemaItemEdit {\n type: SchemaEditType.RenameSchemaItem;\n key: string;\n value: string;\n}\n\n/**\n * Schema edit entry to rename a property of a class.\n * @alpha\n */\nexport interface RenamePropertyEdit {\n type: SchemaEditType.RenameProperty;\n key: string;\n value: string;\n}\n\n/**\n * Schema edit entry to skip a certain schema element matching the given key.\n * @alpha\n */\nexport interface SkipEdit {\n type: SchemaEditType.Skip;\n key: string;\n}\n\n/**\n * Union for all supported edits that can be applied to a schema.\n * @alpha\n */\nexport type AnySchemaEdits =\n SkipEdit |\n RenameSchemaItemEdit |\n RenamePropertyEdit;\n\nabstract class Editor {\n private readonly _edits: Array<AnySchemaEdits>;\n\n constructor(edits: Array<AnySchemaEdits>) {\n this._edits = edits;\n }\n\n protected add(edit: AnySchemaEdits) {\n const overrideEntry = this._edits.findIndex((entry) => {\n return entry.type === edit.type && entry.key === edit.key;\n });\n\n if (overrideEntry > -1) {\n this._edits[overrideEntry] = edit;\n } else {\n this._edits.push(edit);\n }\n }\n}\n\nclass PropertyEditor extends Editor {\n\n public rename(ecClass: ECClass, propertyName: string, newName: string) {\n this.add({\n type: SchemaEditType.RenameProperty,\n key: `${ecClass.fullName}.${propertyName}`,\n value: newName,\n });\n }\n\n public skip(ecClass: ECClass, propertyName: string) {\n this.add({\n type: SchemaEditType.Skip,\n key: `${ecClass.fullName}.${propertyName}`,\n });\n }\n}\n\nclass ItemEditor extends Editor {\n public rename(schemaItem: SchemaItem, newName: string) {\n this.add({\n type: SchemaEditType.RenameSchemaItem,\n key: schemaItem.key.fullName,\n value: newName,\n });\n }\n\n public skip(schemaItem: SchemaItem) {\n this.add({\n type: SchemaEditType.Skip,\n key: schemaItem.fullName,\n });\n }\n}\n\n/**\n * Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class\n * is to support saving of edits and load them again if needed.\n * @alpha\n */\nexport class SchemaEdits implements Iterable<AnySchemaEdits> {\n private readonly _edits: Array<AnySchemaEdits>;\n\n public readonly properties: PropertyEditor;\n public readonly items: ItemEditor;\n\n /**\n * @alpha\n */\n constructor(initialize?: ReadonlyArray<AnySchemaEdits>) {\n this._edits = [];\n\n if (initialize) {\n this._edits.push(...initialize);\n }\n\n this.items = new ItemEditor(this._edits);\n this.properties = new PropertyEditor(this._edits);\n }\n\n /**\n * @internal\n */\n public async applyTo(differenceResult: SchemaDifferenceResult, nameMapping: NameMapping): Promise<void> {\n for (const schemaEdit of this._edits) {\n if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {\n applyRenameSchemaItemEdit(differenceResult, schemaEdit);\n nameMapping.addItemMapping(schemaEdit.key, schemaEdit.value);\n }\n if (schemaEdit.type === SchemaEditType.RenameProperty) {\n applyRenamePropertyEdit(differenceResult, schemaEdit);\n nameMapping.addPropertyMapping(schemaEdit.key, schemaEdit.value);\n }\n if (schemaEdit.type === SchemaEditType.Skip) {\n applySkipEdit(differenceResult, schemaEdit);\n }\n }\n }\n\n public toJSON(): ReadonlyArray<AnySchemaEdits> {\n return this._edits;\n }\n\n public [Symbol.iterator](): Iterator<AnySchemaEdits> {\n return this._edits[Symbol.iterator]();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SkipEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SkipEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAaH,sCAkBC;AAzBD;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,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
+ {"version":3,"file":"SkipEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SkipEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAaH,sCAkBC;AAzBD;;;;;;GAMG;AACH,SAAgB,aA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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"]}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addEntityClass = addEntityClass;
4
4
  exports.modifyEntityClass = modifyEntityClass;
5
5
  exports.addClassMixins = addClassMixins;
6
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
7
6
  const ClassMerger_1 = require("./ClassMerger");
8
7
  const Utils_1 = require("./Utils");
9
8
  /**
@@ -38,7 +37,7 @@ async function modifyEntityClass(context, change, itemKey) {
38
37
  async function addClassMixins(context, change) {
39
38
  for (const mixinFullName of change.difference) {
40
39
  const mixinKey = await (0, Utils_1.updateSchemaItemKey)(context, mixinFullName);
41
- const entityKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
40
+ const entityKey = (0, Utils_1.toItemKey)(context, change.itemName);
42
41
  await context.editor.entities.addMixin(entityKey, mixinKey);
43
42
  }
44
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAeA,wCAOC;AAMD,8CAUC;AAMD,wCAMC;AA3CD,gEAAyD;AACzD,+CAA4C;AAC5C,mCAA8C;AAE9C;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACrE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QAEjC,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAuB,CAAC;IAClF,IAAG,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1C,KAAI,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAAkC;IAClG,KAAI,MAAM,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;QAC9E,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 { 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 = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n await context.editor.entities.addMixin(entityKey, mixinKey);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAeA,wCAOC;AAMD,8CAUC;AAMD,wCAMC;AA1CD,+CAA4C;AAC5C,mCAAyD;AAEzD;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACrE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QAEjC,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAuB,CAAC;IAClF,IAAG,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1C,KAAI,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAAkC;IAClG,KAAI,MAAM,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,IAAA,iBAAS,EAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { EntityClassDifference, EntityClassMixinDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableEntityClass } from \"../Editing/Mutable/MutableEntityClass\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { modifyClass } from \"./ClassMerger\";\nimport { toItemKey, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new EntityClass into the target schema.\n * @internal\n */\nexport async function addEntityClass(context: SchemaMergeContext, change: EntityClassDifference) {\n await context.editor.entities.createFromProps(context.targetSchemaKey, {\n name: change.itemName,\n schemaItemType: change.schemaType,\n\n ...change.difference,\n });\n}\n\n/**\n * Merges differences to an existing EntityClass in the target schema.\n * @internal\n */\nexport async function modifyEntityClass(context: SchemaMergeContext, change: EntityClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableEntityClass;\n if(change.difference.mixins !== undefined) {\n for(const mixin of change.difference.mixins) {\n const mixinKey = await updateSchemaItemKey(context, mixin);\n await context.editor.entities.addMixin(itemKey, mixinKey);\n }\n }\n\n return modifyClass(context, change, itemKey, item);\n}\n\n/**\n * Merges Mixins to Entity Class schema items.\n * @internal\n */\nexport async function addClassMixins(context: SchemaMergeContext, change: EntityClassMixinDifference): Promise<void> {\n for(const mixinFullName of change.difference) {\n const mixinKey = await updateSchemaItemKey(context, mixinFullName);\n const entityKey = toItemKey(context, change.itemName);\n await context.editor.entities.addMixin(entityKey, mixinKey);\n }\n}\n"]}
@@ -19,7 +19,7 @@ async function addEnumeration(context, change) {
19
19
  throw new Error("Enumerations must define whether enumeration is strict.");
20
20
  }
21
21
  if (change.difference.enumerators === undefined) {
22
- throw new Error("Enumerations must define at least ine enumerator.");
22
+ throw new Error("Enumerations must define at least one enumerator.");
23
23
  }
24
24
  await context.editor.enumerations.createFromProps(context.targetSchemaKey, {
25
25
  ...change.difference,
@@ -1 +1 @@
1
- {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAaA,wCAmBC;AAMD,8CAcC;AApDD;;;+FAG+F;AAC/F,gEAAqF;AAKrF;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,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AAC;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 ine 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
+ {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAaA,wCAmBC;AAMD,8CAcC;AApDD;;;+FAG+F;AAC/F,gEAAqF;AAKrF;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACzE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI;QAC5B,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;QACpC,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW;KAC3C,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAuB,CAAC;IACzF,IAAG,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,IAAI,0CAA0C,IAAA,yCAAqB,EAAC,WAAW,CAAC,IAAK,CAAC,WAAW,MAAM,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,CAAC;IAC1K,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3F,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5C,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtD,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { primitiveTypeToString, type SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport type { EnumerationDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { MutableEnumeration } from \"../Editing/Mutable/MutableEnumeration\";\n\n/**\n * Merges a new Enumeration into the target schema.\n * @internal\n */\nexport async function addEnumeration(context: SchemaMergeContext, change: EnumerationDifference) {\n if (change.difference.type === undefined) {\n throw new Error(\"Enumerations must define a type property\");\n }\n if (change.difference.isStrict === undefined) {\n throw new Error(\"Enumerations must define whether enumeration is strict.\");\n }\n if (change.difference.enumerators === undefined) {\n throw new Error(\"Enumerations must define at least one enumerator.\");\n }\n\n await context.editor.enumerations.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n type: change.difference.type,\n isStrict: change.difference.isStrict,\n enumerators: change.difference.enumerators,\n });\n}\n\n/**\n * Merges differences to an existing Enumeration in the target schema.\n * @internal\n */\nexport async function modifyEnumeration(context: SchemaMergeContext, change: EnumerationDifference, itemKey: SchemaItemKey) {\n const enumeration = await context.targetSchema.lookupItem(itemKey) as MutableEnumeration;\n if(change.difference.type !== undefined) {\n throw new Error(`The Enumeration ${itemKey.name} has an incompatible type. It must be \"${primitiveTypeToString(enumeration.type!)}\", not \"${change.difference.type}\".`);\n }\n if(change.difference.label !== undefined) {\n await context.editor.enumerations.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.enumerations.setDescription(itemKey, change.difference.description);\n }\n if(change.difference.isStrict !== undefined) {\n enumeration.setIsStrict(change.difference.isStrict);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EnumeratorMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumeratorMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,iBAe5F;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,iBAUvH"}
1
+ {"version":3,"file":"EnumeratorMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumeratorMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,iBAe5F;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,iBAUvH"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addEnumerator = addEnumerator;
4
4
  exports.modifyEnumerator = modifyEnumerator;
5
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
5
+ const Utils_1 = require("./Utils");
6
6
  /**
7
7
  * Merges a new Enumerator into the target schema.
8
8
  * @internal
@@ -14,7 +14,7 @@ async function addEnumerator(context, change) {
14
14
  if (change.difference.value === undefined) {
15
15
  throw new Error("Enumerators must define a value");
16
16
  }
17
- const itemKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
17
+ const itemKey = (0, Utils_1.toItemKey)(context, change.itemName);
18
18
  await context.editor.enumerations.addEnumerator(itemKey, {
19
19
  name: change.difference.name,
20
20
  value: change.difference.value,
@@ -1 +1 @@
1
- {"version":3,"file":"EnumeratorMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumeratorMerger.ts"],"names":[],"mappings":";;AAYA,sCAeC;AAMD,4CAUC;AArCD,gEAAyD;AAEzD;;;GAGG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AAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtG,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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\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 = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n await context.editor.enumerations.addEnumerator(itemKey, {\r\n name: change.difference.name,\r\n value: change.difference.value,\r\n label: change.difference.label,\r\n description: change.difference.description,\r\n });\r\n}\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
+ {"version":3,"file":"EnumeratorMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumeratorMerger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,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"]}
@@ -0,0 +1,24 @@
1
+ import { SchemaItemKey } from "@itwin/ecschema-metadata";
2
+ import { FormatDifference, FormatUnitDifference, FormatUnitLabelDifference } from "../Differencing/SchemaDifference";
3
+ import { SchemaMergeContext } from "./SchemaMerger";
4
+ /**
5
+ * Merges a new Format into the target schema.
6
+ * @internal
7
+ */
8
+ export declare function addFormat(context: SchemaMergeContext, change: FormatDifference): Promise<void>;
9
+ /**
10
+ * Merges differences to an existing Format in the target schema.
11
+ * @internal
12
+ */
13
+ export declare function modifyFormat(context: SchemaMergeContext, change: FormatDifference, itemKey: SchemaItemKey): Promise<void>;
14
+ /**
15
+ * Merges source format units into the target format
16
+ * @internal
17
+ */
18
+ export declare function modifyFormatUnit(context: SchemaMergeContext, change: FormatUnitDifference, itemKey: SchemaItemKey): Promise<void>;
19
+ /**
20
+ * Overrides format unit label
21
+ * @internal
22
+ */
23
+ export declare function modifyFormatUnitLabel(context: SchemaMergeContext, change: FormatUnitLabelDifference, itemKey: SchemaItemKey): Promise<void>;
24
+ //# sourceMappingURL=FormatMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/FormatMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAErH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;GAGG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,gBAAgB,iBAsBpF;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa,iBAwD/G;AAED;;;EAGE;AACF,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,iBAavH;AAED;;;EAGE;AACF,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,yBAAyB,EAAE,OAAO,EAAE,aAAa,iBAYjI"}
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addFormat = addFormat;
4
+ exports.modifyFormat = modifyFormat;
5
+ exports.modifyFormatUnit = modifyFormatUnit;
6
+ exports.modifyFormatUnitLabel = modifyFormatUnitLabel;
7
+ const core_quantity_1 = require("@itwin/core-quantity");
8
+ const Utils_1 = require("./Utils");
9
+ /**
10
+ * Merges a new Format into the target schema.
11
+ * @internal
12
+ */
13
+ async function addFormat(context, change) {
14
+ if (change.difference.type === undefined) {
15
+ throw new Error("Format must define type");
16
+ }
17
+ if (change.difference.composite && change.difference.composite.units) {
18
+ for (let index = 0; index < change.difference.composite.units.length; index++) {
19
+ const compositeUnitName = await (0, Utils_1.updateSchemaItemFullName)(context, change.difference.composite.units[index].name);
20
+ change.difference.composite.units[index] = {
21
+ name: compositeUnitName,
22
+ label: change.difference.composite.units[index].label,
23
+ };
24
+ }
25
+ }
26
+ await context.editor.formats.createFromProps(context.targetSchemaKey, {
27
+ ...change.difference,
28
+ name: change.itemName,
29
+ schemaItemType: change.schemaType,
30
+ type: change.difference.type,
31
+ composite: change.difference.composite,
32
+ });
33
+ }
34
+ /**
35
+ * Merges differences to an existing Format in the target schema.
36
+ * @internal
37
+ */
38
+ async function modifyFormat(context, change, itemKey) {
39
+ const format = await context.targetSchema.lookupItem(itemKey);
40
+ if (change.difference.type !== undefined) {
41
+ throw new Error(`Changing the format '${change.itemName}' type is not supported.`);
42
+ }
43
+ if (change.difference.label !== undefined) {
44
+ await context.editor.formats.setDisplayLabel(itemKey, change.difference.label);
45
+ }
46
+ if (change.difference.description !== undefined) {
47
+ await context.editor.formats.setDescription(itemKey, change.difference.description);
48
+ }
49
+ if (change.difference.precision !== undefined) {
50
+ format.setPrecision(change.difference.precision);
51
+ }
52
+ if (change.difference.roundFactor !== undefined) {
53
+ format.setRoundFactor(change.difference.roundFactor);
54
+ }
55
+ if (change.difference.minWidth !== undefined) {
56
+ format.setMinWidth(change.difference.minWidth);
57
+ }
58
+ if (change.difference.showSignOption !== undefined) {
59
+ const showSignOption = (0, core_quantity_1.parseShowSignOption)(change.difference.showSignOption, change.itemName);
60
+ format.setShowSignOption(showSignOption);
61
+ }
62
+ if (change.difference.formatTraits !== undefined) {
63
+ const formatTraits = parseFormatTraits(change.difference.formatTraits, change.itemName);
64
+ format.setFormatTraits(formatTraits);
65
+ }
66
+ if (change.difference.decimalSeparator !== undefined) {
67
+ format.setDecimalSeparator(change.difference.decimalSeparator);
68
+ }
69
+ if (change.difference.thousandSeparator !== undefined) {
70
+ format.setThousandSeparator(change.difference.thousandSeparator);
71
+ }
72
+ if (change.difference.uomSeparator !== undefined) {
73
+ format.setUomSeparator(change.difference.uomSeparator);
74
+ }
75
+ if (change.difference.scientificType !== undefined) {
76
+ const scientificType = (0, core_quantity_1.parseScientificType)(change.difference.scientificType, change.itemName);
77
+ format.setScientificType(scientificType);
78
+ }
79
+ if (change.difference.stationOffsetSize !== undefined) {
80
+ format.setStationOffsetSize(change.difference.stationOffsetSize);
81
+ }
82
+ if (change.difference.stationSeparator !== undefined) {
83
+ format.setStationSeparator(change.difference.stationSeparator);
84
+ }
85
+ if (change.difference.composite !== undefined) {
86
+ if (change.difference.composite.includeZero !== undefined) {
87
+ format.setIncludeZero(change.difference.composite.includeZero);
88
+ }
89
+ if (change.difference.composite.spacer !== undefined) {
90
+ format.setSpacer(change.difference.composite.spacer);
91
+ }
92
+ }
93
+ }
94
+ /**
95
+ * Merges source format units into the target format
96
+ * @internal
97
+ */
98
+ async function modifyFormatUnit(context, change, itemKey) {
99
+ const format = await context.targetSchema.lookupItem(itemKey);
100
+ const units = [];
101
+ for (const { name, label } of change.difference) {
102
+ const lookupKey = await (0, Utils_1.updateSchemaItemKey)(context, name);
103
+ const formatUnit = await context.editor.schemaContext.getSchemaItem(lookupKey);
104
+ if (formatUnit === undefined) {
105
+ throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);
106
+ }
107
+ units.push([formatUnit, label]);
108
+ }
109
+ format.setUnits(units);
110
+ }
111
+ /**
112
+ * Overrides format unit label
113
+ * @internal
114
+ */
115
+ async function modifyFormatUnitLabel(context, change, itemKey) {
116
+ const format = await context.targetSchema.lookupItem(itemKey);
117
+ if (format.units !== undefined) {
118
+ const unitKey = await (0, Utils_1.updateSchemaItemKey)(context, change.path);
119
+ /* eslint-disable @typescript-eslint/prefer-for-of */
120
+ for (let index = 0; index < format.units.length; index++) {
121
+ if (format.units[index][0].key.matches(unitKey)) {
122
+ format.units[index][1] = change.difference.label;
123
+ }
124
+ }
125
+ }
126
+ }
127
+ function parseFormatTraits(formatTraitsFromJson, formatName) {
128
+ let formatTraits = core_quantity_1.FormatTraits.Uninitialized;
129
+ const formatTraitIterable = Array.isArray(formatTraitsFromJson)
130
+ ? formatTraitsFromJson
131
+ : formatTraitsFromJson.split(/,|;|\|/);
132
+ for (const formatTraitsString of formatTraitIterable) {
133
+ const formatTrait = (0, core_quantity_1.parseFormatTrait)(formatTraitsString, formatName);
134
+ formatTraits = formatTraits | formatTrait;
135
+ }
136
+ return formatTraits;
137
+ }
138
+ //# sourceMappingURL=FormatMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatMerger.js","sourceRoot":"","sources":["../../../src/Merging/FormatMerger.ts"],"names":[],"mappings":";;AAeA,8BAsBC;AAMD,oCAwDC;AAMD,4CAaC;AAMD,sDAYC;AAnID,wDAAgH;AAIhH,mCAAwE;AAExE;;;GAGG;AACI,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,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GAAG,MAAM,IAAA,2BAAmB,EAAC,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,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAChD,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,4BAAY,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,IAAA,gCAAgB,EAAC,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 { InvertedUnit, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatTraits, parseFormatTrait, parseScientificType, parseShowSignOption } from \"@itwin/core-quantity\";\nimport { FormatDifference, FormatUnitDifference, FormatUnitLabelDifference } from \"../Differencing/SchemaDifference\";\nimport { MutableFormat } from \"../Editing/Mutable/MutableFormat\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Format into the target schema.\n * @internal\n */\nexport async function addFormat(context: SchemaMergeContext, change: FormatDifference) {\n if (change.difference.type === undefined) {\n throw new Error(\"Format must define type\");\n }\n\n if (change.difference.composite && change.difference.composite.units) {\n for (let index = 0; index < change.difference.composite.units.length; index++) {\n const compositeUnitName = await updateSchemaItemFullName(context, change.difference.composite.units[index].name);\n change.difference.composite.units[index] = {\n name: compositeUnitName,\n label: change.difference.composite.units[index].label,\n }\n }\n }\n\n await context.editor.formats.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n type: change.difference.type,\n composite: change.difference.composite,\n });\n}\n\n/**\n * Merges differences to an existing Format in the target schema.\n * @internal\n */\nexport async function modifyFormat(context: SchemaMergeContext, change: FormatDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n if (change.difference.type !== undefined) {\n throw new Error(`Changing the format '${change.itemName}' type is not supported.`);\n }\n\n if (change.difference.label !== undefined) {\n await context.editor.formats.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.formats.setDescription(itemKey, change.difference.description);\n }\n if (change.difference.precision !== undefined) {\n format.setPrecision(change.difference.precision);\n }\n if (change.difference.roundFactor !== undefined) {\n format.setRoundFactor(change.difference.roundFactor);\n }\n if (change.difference.minWidth !== undefined) {\n format.setMinWidth(change.difference.minWidth);\n }\n if (change.difference.showSignOption !== undefined) {\n const showSignOption = parseShowSignOption(change.difference.showSignOption, change.itemName);\n format.setShowSignOption(showSignOption);\n }\n if (change.difference.formatTraits !== undefined) {\n const formatTraits = parseFormatTraits(change.difference.formatTraits, change.itemName);\n format.setFormatTraits(formatTraits);\n }\n if (change.difference.decimalSeparator !== undefined) {\n format.setDecimalSeparator(change.difference.decimalSeparator);\n }\n if (change.difference.thousandSeparator !== undefined) {\n format.setThousandSeparator(change.difference.thousandSeparator);\n }\n if (change.difference.uomSeparator !== undefined) {\n format.setUomSeparator(change.difference.uomSeparator);\n }\n if (change.difference.scientificType !== undefined) {\n const scientificType = parseScientificType(change.difference.scientificType, change.itemName);\n format.setScientificType(scientificType);\n }\n if (change.difference.stationOffsetSize !== undefined) {\n format.setStationOffsetSize(change.difference.stationOffsetSize);\n }\n if (change.difference.stationSeparator !== undefined) {\n format.setStationSeparator(change.difference.stationSeparator);\n }\n if (change.difference.composite !== undefined) {\n if (change.difference.composite.includeZero !== undefined) {\n format.setIncludeZero(change.difference.composite.includeZero);\n }\n if (change.difference.composite.spacer !== undefined) {\n format.setSpacer(change.difference.composite.spacer);\n }\n }\n}\n\n/**\n * Merges source format units into the target format\n * @internal\n*/\nexport async function modifyFormatUnit(context: SchemaMergeContext, change: FormatUnitDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n const units: [Unit | InvertedUnit, string | undefined][] = [];\n for (const { name, label } of change.difference) {\n const lookupKey = await updateSchemaItemKey(context, name);\n const formatUnit = await context.editor.schemaContext.getSchemaItem<Unit | InvertedUnit>(lookupKey);\n if (formatUnit === undefined) {\n throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);\n }\n units.push([formatUnit, label]);\n }\n format.setUnits(units);\n}\n\n/**\n * Overrides format unit label\n * @internal\n*/\nexport async function modifyFormatUnitLabel(context: SchemaMergeContext, change: FormatUnitLabelDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n if (format.units !== undefined) {\n const unitKey = await updateSchemaItemKey(context, change.path);\n /* eslint-disable @typescript-eslint/prefer-for-of */\n for (let index = 0; index < format.units.length; index++) {\n if (format.units[index][0].key.matches(unitKey)) {\n format.units[index][1] = change.difference.label;\n }\n }\n }\n}\n\nfunction parseFormatTraits(formatTraitsFromJson: string | string[], formatName: string): FormatTraits {\n let formatTraits: FormatTraits = FormatTraits.Uninitialized;\n const formatTraitIterable = Array.isArray(formatTraitsFromJson)\n ? formatTraitsFromJson\n : formatTraitsFromJson.split(/,|;|\\|/);\n for (const formatTraitsString of formatTraitIterable) {\n const formatTrait = parseFormatTrait(formatTraitsString, formatName);\n formatTraits = formatTraits | formatTrait;\n }\n return formatTraits;\n}\n"]}