@itwin/ecschema-editing 4.4.0-dev.3 → 4.4.0-dev.30

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 (151) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/lib/cjs/Editing/Constants.js.map +1 -1
  3. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  4. package/lib/cjs/Editing/ECClasses.d.ts +2 -0
  5. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  6. package/lib/cjs/Editing/ECClasses.js +28 -0
  7. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  8. package/lib/cjs/Editing/Editor.d.ts +1 -1
  9. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  10. package/lib/cjs/Editing/Editor.js +1 -1
  11. package/lib/cjs/Editing/Editor.js.map +1 -1
  12. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  13. package/lib/cjs/Editing/Entities.js +8 -6
  14. package/lib/cjs/Editing/Entities.js.map +1 -1
  15. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  16. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  17. package/lib/cjs/Editing/Formats.js +2 -0
  18. package/lib/cjs/Editing/Formats.js.map +1 -1
  19. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  20. package/lib/cjs/Editing/KindOfQuantities.d.ts +1 -0
  21. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  22. package/lib/cjs/Editing/KindOfQuantities.js +20 -0
  23. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  24. package/lib/cjs/Editing/Mixins.js.map +1 -1
  25. package/lib/cjs/Editing/Mutable/MutableArrayProperty.d.ts +10 -0
  26. package/lib/cjs/Editing/Mutable/MutableArrayProperty.d.ts.map +1 -0
  27. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js +16 -0
  28. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -0
  29. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  30. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +2 -0
  31. package/lib/cjs/Editing/Mutable/MutableClass.d.ts.map +1 -1
  32. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  33. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  34. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  35. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  36. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  37. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  38. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +2 -1
  39. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -1
  40. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  41. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  42. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  43. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.d.ts +13 -0
  44. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.d.ts.map +1 -0
  45. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js +16 -0
  46. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -0
  47. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +6 -1
  48. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts.map +1 -1
  49. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  50. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  51. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +9 -1
  52. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts.map +1 -1
  53. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  54. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  55. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  56. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  57. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  58. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  59. package/lib/cjs/Editing/RelationshipClasses.d.ts +33 -2
  60. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  61. package/lib/cjs/Editing/RelationshipClasses.js +148 -22
  62. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  63. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  64. package/lib/cjs/Editing/Structs.js.map +1 -1
  65. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  66. package/lib/cjs/Editing/Units.js.map +1 -1
  67. package/lib/cjs/Merging/AnyPropertyMerger.d.ts +15 -0
  68. package/lib/cjs/Merging/AnyPropertyMerger.d.ts.map +1 -0
  69. package/lib/cjs/Merging/AnyPropertyMerger.js +71 -0
  70. package/lib/cjs/Merging/AnyPropertyMerger.js.map +1 -0
  71. package/lib/cjs/Merging/ArrayPropertyMerger.d.ts +32 -0
  72. package/lib/cjs/Merging/ArrayPropertyMerger.d.ts.map +1 -0
  73. package/lib/cjs/Merging/ArrayPropertyMerger.js +143 -0
  74. package/lib/cjs/Merging/ArrayPropertyMerger.js.map +1 -0
  75. package/lib/cjs/Merging/CAClassMerger.d.ts +6 -8
  76. package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
  77. package/lib/cjs/Merging/CAClassMerger.js +27 -10
  78. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  79. package/lib/cjs/Merging/ClassMerger.d.ts +14 -6
  80. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  81. package/lib/cjs/Merging/ClassMerger.js +133 -35
  82. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  83. package/lib/cjs/Merging/ClassPropertyMerger.d.ts +16 -0
  84. package/lib/cjs/Merging/ClassPropertyMerger.d.ts.map +1 -0
  85. package/lib/cjs/Merging/ClassPropertyMerger.js +90 -0
  86. package/lib/cjs/Merging/ClassPropertyMerger.js.map +1 -0
  87. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  88. package/lib/cjs/Merging/CustomAttributeMerger.d.ts +21 -0
  89. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -0
  90. package/lib/cjs/Merging/CustomAttributeMerger.js +51 -0
  91. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -0
  92. package/lib/cjs/Merging/EntityClassMerger.d.ts +11 -0
  93. package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -0
  94. package/lib/cjs/Merging/EntityClassMerger.js +26 -0
  95. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -0
  96. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  97. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +15 -0
  98. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -0
  99. package/lib/cjs/Merging/KindOfQuantityMerger.js +66 -0
  100. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -0
  101. package/lib/cjs/Merging/MixinMerger.d.ts +11 -0
  102. package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -0
  103. package/lib/cjs/Merging/MixinMerger.js +38 -0
  104. package/lib/cjs/Merging/MixinMerger.js.map +1 -0
  105. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts +24 -0
  106. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts.map +1 -0
  107. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js +106 -0
  108. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js.map +1 -0
  109. package/lib/cjs/Merging/SchemaItemFactory.d.ts.map +1 -1
  110. package/lib/cjs/Merging/SchemaItemFactory.js +10 -0
  111. package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -1
  112. package/lib/cjs/Merging/SchemaItemMerger.d.ts +2 -1
  113. package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
  114. package/lib/cjs/Merging/SchemaItemMerger.js +11 -4
  115. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  116. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  117. package/lib/cjs/Merging/SchemaMerger.js +16 -3
  118. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  119. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  120. package/lib/cjs/Merging/StructClassMerger.d.ts +10 -0
  121. package/lib/cjs/Merging/StructClassMerger.d.ts.map +1 -0
  122. package/lib/cjs/Merging/StructClassMerger.js +13 -0
  123. package/lib/cjs/Merging/StructClassMerger.js.map +1 -0
  124. package/lib/cjs/Merging/StructPropertyMerger.d.ts +11 -0
  125. package/lib/cjs/Merging/StructPropertyMerger.d.ts.map +1 -0
  126. package/lib/cjs/Merging/StructPropertyMerger.js +47 -0
  127. package/lib/cjs/Merging/StructPropertyMerger.js.map +1 -0
  128. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  129. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  130. package/lib/cjs/Validation/ECRules.d.ts +13 -3
  131. package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
  132. package/lib/cjs/Validation/ECRules.js +30 -11
  133. package/lib/cjs/Validation/ECRules.js.map +1 -1
  134. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  135. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  136. package/lib/cjs/Validation/Rules.js.map +1 -1
  137. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  138. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  139. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  140. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +1 -1
  141. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts.map +1 -1
  142. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +2 -4
  143. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  144. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  145. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  146. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  147. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  148. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  149. package/lib/cjs/ecschema-editing.js.map +1 -1
  150. package/package.json +15 -15
  151. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1 +1 @@
1
- {"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAsE;AACtE,oFAAoF;AACpF,kGAAkG;AAClG,gEAAkE;AAClE,+DAAwG;AACxG,yDAAsD;AAEtD;;GAEG;AACH,MAAqB,WAAY,SAAQ,mCAAyB;IAE7C,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAe,EAAE,MAAoB;QAC1F,2FAA2F;QAC3F,uDAAuD;QACvD,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;QAEpE,KAAI,MAAM,cAAc,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE;YAC3D,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;SAC7D;IACH,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,OAAsB,EAAE,MAAe,EAAE,eAAgC;QACtG,IAAI,eAAe,KAAK,SAAS,EAAE;YACjC,MAAM,CAAC,eAAe,EAAE,eAAe,CAAC,GAAG,eAAe,CAAC,UAAU,CAAC,WAAkC,CAAC;YACzG,IAAI,eAAe,KAAK,SAAS,EAAE;g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AU,EAAE,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;aAErJ;iBAAM;gBACL,MAAM,KAAK,CAAC,oBAAoB,cAAc,CAAC,UAAU,gCAAgC,CAAC,CAAC;aAC5F;SACF;IACH,CAAC;CACF;AA/CD,8BA+CC","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 { ECClass, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { BaseClassDelta, ChangeType, ClassChanges, PropertyChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class ClassMerger extends SchemaItemMerger<ECClass> {\r\n\r\n protected override async merge(itemKey: SchemaItemKey, source: ECClass, change: ClassChanges) {\r\n // This applies to all type of classes regardless if they are Entities, Structs, Mixins,...\r\n // all can have properties that required to get merged.\r\n await this.mergeBaseClasses(itemKey, source, change.baseClassDelta);\r\n\r\n for(const propertyChange of change.propertyChanges.values()) {\r\n await this.mergeProperties(itemKey, source, propertyChange);\r\n }\r\n }\r\n\r\n private async mergeBaseClasses(itemKey: SchemaItemKey, source: ECClass, baseClassChange?: BaseClassDelta) {\r\n if (baseClassChange !== undefined) {\r\n const [sourceBaseClass, targetBaseClass] = baseClassChange.diagnostic.messageArgs! as [ECClass, ECClass];\r\n if (targetBaseClass === undefined) {\r\n\r\n const baseClassKey = sourceBaseClass.schema.schemaKey.matches(source.schema.schemaKey)\r\n ? new SchemaItemKey(sourceBaseClass.name, itemKey.schemaKey)\r\n : sourceBaseClass.key;\r\n\r\n await this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\r\n } else {\r\n throw new Error(`Failed to merge base class '${sourceBaseClass.name}': not supported case`);\r\n }\r\n }\r\n }\r\n\r\n private async mergeProperties(itemKey: SchemaItemKey, source: ECClass, propertyChange: PropertyChanges) {\r\n if (propertyChange.propertyMissing?.changeType === ChangeType.Missing) {\r\n\r\n const property = await source.getProperty(propertyChange.ecTypeName);\r\n if (property === undefined) {\r\n throw Error(`Property '${propertyChange.ecTypeName}' not found in class ${source.name}`);\r\n }\r\n\r\n if (property.isPrimitive()) {\r\n const primitiveProps = property.toJSON();\r\n property.isArray()\r\n ? await this.context.editor.entities.createPrimitiveArrayPropertyFromProps(itemKey, propertyChange.ecTypeName, property.primitiveType, primitiveProps)\r\n : await this.context.editor.entities.createPrimitivePropertyFromProps(itemKey, propertyChange.ecTypeName, property.primitiveType, primitiveProps);\r\n\r\n } else {\r\n throw Error(`Failed to merge '${propertyChange.ecTypeName}' property: not supported type`);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAiJ;AAIjJ,+DAAgI;AAChI,+DAA4D;AAC5D,mEAAgE;AAEhE;;GAEG;AACH,MAAa,WAAW;IAGtB,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAES,KAAK,CAAC,MAAM,CAAC,UAAqB,EAAE,OAAe;QAC3D,OAAO,EAAE,YAAY,EAAE,GAAG,IAAA,0CAAsB,EAAC,OAAO,CAAC,cAAc,CAAC,iCAAiC,EAAC,CAAC;IAC7G,CAAC;IAES,KAAK,CAAC,QAAQ,CAAC,OAAsB,EAAE,KAAY;QAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,KAAK,CAAC,IAAI,SAAS,OAAO,CAAC,IAAI,6BAA6B,EAAE,CAAC;IACzG,CAAC;IAES,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACpH,MAAM,YAAY,GAAG,OAAkC,CAAC;QACxD,QAAO,aAAa,EAAE;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E,EAAE,UAAU,CAAC,CAAC;gBACtG,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;oBACtC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;iBACvC;aACF;YAED,MAAM,MAAM,CAAC,0BAA0B,CAAC,aAAa,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC;YACpF,IAAI,YAAY,GAAI,MAAM,yCAAmB,CAAC,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;YACpH,IAAI,YAAY,CAAC,YAAY,KAAK,SAAS,EAAE;gBAC3C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;aAC5C;YAED,0BAA0B;YAC1B,YAAY,GAAG,MAAM,IAAA,6CAAqB,EAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;gBAC9G,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YAC9E,CAAC,CAAC,CAAC;YAEH,IAAI,YAAY,CAAC,YAAY,KAAK,SAAS,EAAE;gBAC3C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;aAC5C;SACF;IACH,CAAC;CACF;AAnKD,kCAmKC","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 { ECClass, ECClassModifier, Mixin, parseClassModifier, SchemaItemKey, schemaItemTypeToString, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { MutableClass } from \"../Editing/Mutable/MutableClass\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { BaseClassDelta, ChangeType, ClassChanges, EntityMixinChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\nimport { ClassPropertyMerger } from \"./ClassPropertyMerger\";\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\n\n/**\n * @internal\n */\nexport class ClassMerger<TClass extends ECClass> {\n protected readonly context: SchemaMergeContext;\n\n constructor(context: SchemaMergeContext) {\n this.context = context;\n }\n\n protected async create(_schemaKey: SchemaKey, ecClass: TClass): Promise<SchemaItemEditResults> {\n return { errorMessage: `${schemaItemTypeToString(ecClass.schemaItemType)} class type is not implemented.`};\n }\n\n protected async addMixin(itemKey: SchemaItemKey, mixin: Mixin): Promise<SchemaItemEditResults> {\n return { errorMessage: `Adding mixin '${mixin.name}' to '${itemKey.name}' class is not implemented.` };\n }\n\n protected async mergeAttributes(ecClass: TClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n const mutableClass = ecClass as unknown as MutableClass;\n switch(attributeName) {\n case \"schemaItemType\":\n if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {\n return { errorMessage: `Changing the class '${ecClass.name}' type is not supported.` };\n }\n return true;\n\n case \"label\":\n mutableClass.setDisplayLabel(attributeNewValue);\n return true;\n\n case \"description\":\n mutableClass.setDescription(attributeNewValue);\n return true;\n\n case \"modifier\":\n const modifier = parseClassModifier(attributeNewValue);\n if (modifier === undefined) {\n return { errorMessage: \"An invalid class modifier has been provided.\" };\n }\n\n if (attributeOldValue === undefined || modifier === ECClassModifier.None) {\n mutableClass.setModifier(modifier);\n return true;\n }\n return { errorMessage: `Changing the class '${ecClass.name}' modifier is not supported.` };\n }\n return false;\n }\n\n protected isSchemaItemEditResults(obj: any): obj is SchemaItemEditResults {\n return typeof obj === \"object\" && \"errorMessage\" in obj;\n }\n\n private async setBaseClass(itemKey: SchemaItemKey, baseClassDelta: BaseClassDelta, changeType?: ChangeType): Promise<SchemaItemEditResults> {\n const [sourceBaseClass, targetBaseClass] = baseClassDelta.diagnostic.messageArgs! as [ECClass, ECClass];\n if (sourceBaseClass !== undefined) {\n const baseClassKey = new SchemaItemKey(sourceBaseClass.name, sourceBaseClass.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : sourceBaseClass.schema.schemaKey);\n\n if (changeType === ChangeType.Missing && targetBaseClass === undefined) {\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\n }\n\n if (targetBaseClass !== undefined) {\n const baseClass = await this.context.targetSchema.lookupItem<ECClass>(baseClassKey);\n if (baseClass === undefined) {\n return { errorMessage: `'${baseClassKey.name}' class could not be located in the merged schema.`};\n }\n if (await baseClass.is(targetBaseClass)) {\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\n }\n }\n }\n return { errorMessage: `Changing the class '${itemKey.name}' baseClass is not supported.`};\n }\n\n private async addMixins(itemKey: SchemaItemKey, entityMixinChanges: Iterable<EntityMixinChanges>, changeType?: ChangeType): Promise<SchemaItemEditResults> {\n if (changeType === ChangeType.Missing) {\n for (const entityMixinChange of entityMixinChanges) {\n for (const change of entityMixinChange.entityMixinChange) {\n const mixins = change.diagnostic.messageArgs! as unknown as [Mixin];\n for (const mixin of mixins) {\n const result = await this.addMixin(itemKey, mixin);\n if (result.errorMessage !== undefined) {\n return result;\n }\n }\n }\n }\n return {};\n }\n return { errorMessage: `Changing the class '${itemKey.name}' mixins is not supported.`};\n }\n\n private async mergeAttributeValueChanges(itemKey: SchemaItemKey, propertyValueChanges: PropertyValueChange[]) {\n if (propertyValueChanges.length === 0) {\n return;\n }\n\n const targetItem = await this.context.targetSchema.lookupItem<TClass>(itemKey);\n if (targetItem === undefined) {\n throw new Error(`'${itemKey.name}' class could not be located in the merged schema.`);\n }\n\n for (const change of propertyValueChanges) {\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\n const results = await this.mergeAttributes(targetItem, attributeName, attributeNewValue, attributeOldValue);\n if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n }\n }\n\n public static async mergeChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>) {\n const merger = new this(context);\n\n for (const change of classChanges) {\n const sourceItem = (await change.schema.getItem<ECClass>(change.ecTypeName))!;\n let targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\n const changeType = change.schemaItemMissing?.changeType;\n\n if (changeType === ChangeType.Missing) {\n\n if (await context.targetSchema.lookupItem<ECClass>(targetItemKey) !== undefined) {\n throw new Error(`Merged schema already contains a class '${change.ecTypeName}'.`);\n }\n\n const results = await merger.create(context.targetSchema.schemaKey, sourceItem);\n if (results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n targetItemKey = results.itemKey!;\n }\n\n if (change.baseClassDelta !== undefined) {\n const results = await merger.setBaseClass(targetItemKey, change.baseClassDelta, changeType);\n if (results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n }\n\n if (change.entityMixinChanges.size > 0) {\n const results = await merger.addMixins(targetItemKey, change.entityMixinChanges.values(), changeType);\n if (results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n }\n\n await merger.mergeAttributeValueChanges(targetItemKey, change.propertyValueChanges);\n let mergeResults = await ClassPropertyMerger.mergeChanges(context, targetItemKey, change.propertyChanges.values());\n if (mergeResults.errorMessage !== undefined) {\n throw new Error(mergeResults.errorMessage);\n }\n\n // merge custom attributes\n mergeResults = await mergeCustomAttributes(merger.context, change.customAttributeChanges.values(), async (ca) => {\n return merger.context.editor.entities.addCustomAttribute(targetItemKey, ca);\n });\n\n if (mergeResults.errorMessage !== undefined) {\n throw new Error(mergeResults.errorMessage);\n }\n }\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { SchemaItemKey } from "@itwin/ecschema-metadata";
2
+ import { PropertyEditResults, SchemaItemEditResults } from "../Editing/Editor";
3
+ import { PropertyChanges } from "../Validation/SchemaChanges";
4
+ import { SchemaMergeContext } from "./SchemaMerger";
5
+ /**
6
+ * @internal
7
+ */
8
+ export declare class ClassPropertyMerger {
9
+ protected readonly context: SchemaMergeContext;
10
+ constructor(context: SchemaMergeContext);
11
+ private getPropertyMerger;
12
+ protected isPropertyEditResults(obj: any): obj is PropertyEditResults;
13
+ private mergeAttributeValueChanges;
14
+ static mergeChanges(context: SchemaMergeContext, classKey: SchemaItemKey, propertyChanges: Iterable<PropertyChanges>): Promise<SchemaItemEditResults>;
15
+ }
16
+ //# sourceMappingURL=ClassPropertyMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClassPropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ClassPropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2C,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAc,eAAe,EAAuB,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAOpD;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAEnC,OAAO,EAAE,kBAAkB;IAIvC,OAAO,CAAC,iBAAiB;IAsBzB,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,mBAAmB;YAIvD,0BAA0B;WAepB,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAmCnK"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassPropertyMerger = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
9
+ const SchemaChanges_1 = require("../Validation/SchemaChanges");
10
+ const StructPropertyMerger_1 = require("./StructPropertyMerger");
11
+ const ArrayPropertyMerger_1 = require("./ArrayPropertyMerger");
12
+ const PrimitiveOrEnumPropertyMerger_1 = require("./PrimitiveOrEnumPropertyMerger");
13
+ const CustomAttributeMerger_1 = require("./CustomAttributeMerger");
14
+ /**
15
+ * @internal
16
+ */
17
+ class ClassPropertyMerger {
18
+ constructor(context) {
19
+ this.context = context;
20
+ }
21
+ getPropertyMerger(property) {
22
+ if (property.isEnumeration()) {
23
+ if (property.isArray()) {
24
+ return new ArrayPropertyMerger_1.EnumerationArrayPropertyMerger(this.context);
25
+ }
26
+ return new PrimitiveOrEnumPropertyMerger_1.EnumerationPropertyMerger(this.context);
27
+ }
28
+ if (property.isPrimitive()) {
29
+ if (property.isArray()) {
30
+ return new ArrayPropertyMerger_1.PrimitiveArraPropertyMerger(this.context);
31
+ }
32
+ return new PrimitiveOrEnumPropertyMerger_1.PrimitivePropertyMerger(this.context);
33
+ }
34
+ if (property.isStruct()) {
35
+ if (property.isArray()) {
36
+ return new ArrayPropertyMerger_1.StructArrayPropertyMerger(this.context);
37
+ }
38
+ return new StructPropertyMerger_1.StructPropertyMerger(this.context);
39
+ }
40
+ throw new Error(`Unsupported Property Type: ${(0, ecschema_metadata_1.propertyTypeToString)(property.propertyType)}`);
41
+ }
42
+ isPropertyEditResults(obj) {
43
+ return typeof obj === "object" && "errorMessage" in obj;
44
+ }
45
+ async mergeAttributeValueChanges(targetProperty, propertyValueChanges) {
46
+ if (propertyValueChanges.length === 0)
47
+ return;
48
+ const merger = this.getPropertyMerger(targetProperty);
49
+ for (const change of propertyValueChanges) {
50
+ const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs;
51
+ const results = await merger.mergeAttributes(targetProperty, attributeName, attributeNewValue, attributeOldValue);
52
+ if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
53
+ throw new Error(results.errorMessage);
54
+ }
55
+ }
56
+ }
57
+ static async mergeChanges(context, classKey, propertyChanges) {
58
+ const merger = new this(context);
59
+ for (const change of propertyChanges) {
60
+ const targetItem = await context.targetSchema.lookupItem(classKey);
61
+ if (targetItem === undefined) {
62
+ return { errorMessage: `'${classKey.name}' class could not be located in the merged schema.` };
63
+ }
64
+ if (change.propertyMissing?.changeType === SchemaChanges_1.ChangeType.Missing) {
65
+ const sourceProperty = change.propertyMissing.diagnostic.ecDefinition;
66
+ if (await targetItem.getProperty(change.ecTypeName) !== undefined) {
67
+ return { errorMessage: `Merged schema already contains a class '${classKey.name}' property '${change.ecTypeName}'.` };
68
+ }
69
+ const propertyMerger = merger.getPropertyMerger(sourceProperty);
70
+ const results = await propertyMerger.createFromProps(classKey, sourceProperty);
71
+ if (results.errorMessage !== undefined) {
72
+ return { errorMessage: results.errorMessage };
73
+ }
74
+ }
75
+ else {
76
+ const targetProperty = (await targetItem.getProperty(change.ecTypeName));
77
+ await merger.mergeAttributeValueChanges(targetProperty, change.propertyValueChanges);
78
+ }
79
+ const mergeResults = await (0, CustomAttributeMerger_1.mergeCustomAttributes)(merger.context, change.customAttributeChanges.values(), async (ca) => {
80
+ return merger.context.editor.entities.addCustomAttributeToProperty(classKey, change.ecTypeName, ca);
81
+ });
82
+ if (mergeResults.errorMessage !== undefined) {
83
+ return { errorMessage: mergeResults.errorMessage };
84
+ }
85
+ }
86
+ return { itemKey: classKey };
87
+ }
88
+ }
89
+ exports.ClassPropertyMerger = ClassPropertyMerger;
90
+ //# sourceMappingURL=ClassPropertyMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClassPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAkG;AAEl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,cAAc,GAAI,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;gBACjE,MAAM,OAAO,GAAI,MAAM,cAAc,CAAC,eAAe,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;gBAChF,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;oBACtC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAC,CAAC;iBAC9C;aACF;iBAAM;gBACL,MAAM,cAAc,GAAG,CAAC,MAAM,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAE,CAAC;gBAC1E,MAAM,MAAM,CAAC,0BAA0B,CAAC,cAAc,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC;aACtF;YAED,MAAM,YAAY,GAAG,MAAM,IAAA,6CAAqB,EAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;gBACpH,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACtG,CAAC,CAAC,CAAC;YAEH,IAAI,YAAY,CAAC,YAAY,KAAK,SAAS,EAAE;gBAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,YAAY,EAAC,CAAC;aACnD;SACF;QACD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACF;AAnFD,kDAmFC","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 { ECClass, Property, propertyTypeToString, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { PropertyEditResults, SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ChangeType, PropertyChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { StructPropertyMerger } from \"./StructPropertyMerger\";\nimport { EnumerationArrayPropertyMerger, PrimitiveArraPropertyMerger, StructArrayPropertyMerger } from \"./ArrayPropertyMerger\";\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\nimport { EnumerationPropertyMerger, PrimitivePropertyMerger } from \"./PrimitiveOrEnumPropertyMerger\";\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\n\n/**\n * @internal\n */\nexport class ClassPropertyMerger {\n protected readonly context: SchemaMergeContext;\n\n constructor(context: SchemaMergeContext) {\n this.context = context;\n }\n\n private getPropertyMerger(property: Property): AnyPropertyMerger<Property> {\n if (property.isEnumeration()) {\n if (property.isArray()) {\n return new EnumerationArrayPropertyMerger(this.context);\n }\n return new EnumerationPropertyMerger(this.context);\n }\n if (property.isPrimitive()) {\n if (property.isArray()) {\n return new PrimitiveArraPropertyMerger(this.context);\n }\n return new PrimitivePropertyMerger(this.context);\n }\n if (property.isStruct()) {\n if (property.isArray()) {\n return new StructArrayPropertyMerger(this.context);\n }\n return new StructPropertyMerger(this.context);\n }\n throw new Error(`Unsupported Property Type: ${propertyTypeToString(property.propertyType)}`);\n }\n\n protected isPropertyEditResults(obj: any): obj is PropertyEditResults {\n return typeof obj === \"object\" && \"errorMessage\" in obj;\n }\n\n private async mergeAttributeValueChanges(targetProperty: Property, propertyValueChanges: PropertyValueChange[]) {\n if (propertyValueChanges.length === 0)\n return;\n\n const merger = this.getPropertyMerger(targetProperty);\n\n for (const change of propertyValueChanges) {\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\n const results = await merger.mergeAttributes(targetProperty, attributeName, attributeNewValue, attributeOldValue);\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n }\n }\n\n public static async mergeChanges(context: SchemaMergeContext, classKey: SchemaItemKey, propertyChanges: Iterable<PropertyChanges>): Promise<SchemaItemEditResults> {\n const merger = new this(context);\n\n for (const change of propertyChanges) {\n const targetItem = await context.targetSchema.lookupItem<ECClass>(classKey);\n if (targetItem === undefined) {\n return { errorMessage: `'${classKey.name}' class could not be located in the merged schema.`};\n }\n\n if (change.propertyMissing?.changeType === ChangeType.Missing) {\n const sourceProperty = change.propertyMissing.diagnostic.ecDefinition as unknown as Property;\n if (await targetItem.getProperty(change.ecTypeName) !== undefined) {\n return { errorMessage: `Merged schema already contains a class '${classKey.name}' property '${change.ecTypeName}'.`};\n }\n\n const propertyMerger = merger.getPropertyMerger(sourceProperty);\n const results = await propertyMerger.createFromProps(classKey, sourceProperty);\n if (results.errorMessage !== undefined) {\n return { errorMessage: results.errorMessage};\n }\n } else {\n const targetProperty = (await targetItem.getProperty(change.ecTypeName))!;\n await merger.mergeAttributeValueChanges(targetProperty, change.propertyValueChanges);\n }\n\n const mergeResults = await mergeCustomAttributes(merger.context, change.customAttributeChanges.values(), async (ca) => {\n return merger.context.editor.entities.addCustomAttributeToProperty(classKey, change.ecTypeName, ca);\n });\n\n if (mergeResults.errorMessage !== undefined) {\n return { errorMessage: mergeResults.errorMessage};\n }\n }\n return { itemKey: classKey };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAsE;AACtE,oFAAoF;AACpF,kGAAkG;AAClG,gEAAgE;AAChE,yDAA6E;AAE7E;;GAEG;AACH,MAAqB,eAAgB,SAAQ,mCAA0B;IACrE;;OAEG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,UAAU,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;gBAChD,2EAA2E;gBAC3E,2EAA2E;gBAC3E,+EAA+E;gBAC/E,iEAAiE;gBACjE,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAClF,IAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACvE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,cAAc,EAAE,CAAC;iBACxD;gBACD,OAAO,kBAAkB,CAAC;YAC5B,CAAC;YACD,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE;oBACtE,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;iBACjG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;oBAC1E,MAAM,IAAI,KAAK,CAAC,oDAAoD,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","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 { Constant, SchemaItem } from \"@itwin/ecschema-metadata\";\r\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class ConstantsMerger extends SchemaItemMerger<Constant> {\r\n /**\r\n * Creates the property value resolver for [[Constant]] items.\r\n */\r\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<Constant>> {\r\n return {\r\n phenomenon: (phenomenonFullName, targetItemKey) => {\r\n // There are two options, either the phenomenon was referenced from another\r\n // schema or it is defined in the same schema as the constant to be merged.\r\n // In the latter case, the changes would report a different property value that\r\n // refers to the source schema. So that needs to be changed here.\r\n const [schemaName, phenomenonName] = SchemaItem.parseFullName(phenomenonFullName);\r\n if(this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\r\n return `${targetItemKey.schemaName}.${phenomenonName}`;\r\n }\r\n return phenomenonFullName;\r\n },\r\n numerator: (value, targetItemKey) => {\r\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\r\n if(item !== undefined && item.hasNumerator && item.numerator !== value) {\r\n throw new Error(`Failed to merged, constant numerator conflict: ${value} -> ${item.numerator}`);\r\n }\r\n return value;\r\n },\r\n denominator: (value, targetItemKey) => {\r\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\r\n if(item !== undefined && item.hasDenominator && item.denominator !== value) {\r\n throw new Error(`Failed to merged, constant denominator conflict: ${value} -> ${item.denominator}`);\r\n }\r\n return value;\r\n },\r\n };\r\n }\r\n}\r\n\r\n"]}
1
+ {"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAsE;AACtE,oFAAoF;AACpF,kGAAkG;AAClG,gEAAgE;AAChE,yDAA6E;AAE7E;;GAEG;AACH,MAAqB,eAAgB,SAAQ,mCAA0B;IACrE;;OAEG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,UAAU,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;gBAChD,2EAA2E;gBAC3E,2EAA2E;gBAC3E,+EAA+E;gBAC/E,iEAAiE;gBACjE,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAClF,IAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACvE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,cAAc,EAAE,CAAC;iBACxD;gBACD,OAAO,kBAAkB,CAAC;YAC5B,CAAC;YACD,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE;oBACtE,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;iBACjG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;oBAC1E,MAAM,IAAI,KAAK,CAAC,oDAAoD,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","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 { Constant, SchemaItem } from \"@itwin/ecschema-metadata\";\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\n\n/**\n * @internal\n */\nexport default class ConstantsMerger extends SchemaItemMerger<Constant> {\n /**\n * Creates the property value resolver for [[Constant]] items.\n */\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<Constant>> {\n return {\n phenomenon: (phenomenonFullName, targetItemKey) => {\n // There are two options, either the phenomenon was referenced from another\n // schema or it is defined in the same schema as the constant to be merged.\n // In the latter case, the changes would report a different property value that\n // refers to the source schema. So that needs to be changed here.\n const [schemaName, phenomenonName] = SchemaItem.parseFullName(phenomenonFullName);\n if(this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\n return `${targetItemKey.schemaName}.${phenomenonName}`;\n }\n return phenomenonFullName;\n },\n numerator: (value, targetItemKey) => {\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\n if(item !== undefined && item.hasNumerator && item.numerator !== value) {\n throw new Error(`Failed to merged, constant numerator conflict: ${value} -> ${item.numerator}`);\n }\n return value;\n },\n denominator: (value, targetItemKey) => {\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\n if(item !== undefined && item.hasDenominator && item.denominator !== value) {\n throw new Error(`Failed to merged, constant denominator conflict: ${value} -> ${item.denominator}`);\n }\n return value;\n },\n };\n }\n}\n\n"]}
@@ -0,0 +1,21 @@
1
+ /** @packageDocumentation
2
+ * @module Merging
3
+ */
4
+ import { CustomAttribute } from "@itwin/ecschema-metadata";
5
+ import { CustomAttributeContainerChanges } from "../Validation/SchemaChanges";
6
+ import { SchemaMergeContext } from "./SchemaMerger";
7
+ interface EditResults {
8
+ errorMessage?: string;
9
+ }
10
+ /**
11
+ * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass
12
+ * a scope (Class, Property, Schema) specific handler.
13
+ * @param mergeContext The current schema merging context.
14
+ * @param changes An iterable with custom attribute changes.
15
+ * @param callback The callback to add the custom attribute with a scope specific editor.
16
+ * @returns A EditResults object.
17
+ * @internal
18
+ */
19
+ export declare function mergeCustomAttributes(mergeContext: SchemaMergeContext, changes: Iterable<CustomAttributeContainerChanges>, callback: (customAttribute: CustomAttribute) => Promise<EditResults>): Promise<EditResults>;
20
+ export {};
21
+ //# sourceMappingURL=CustomAttributeMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomAttributeMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAA8D,MAAM,0BAA0B,CAAC;AACvH,OAAO,EAAc,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAE,QAAQ,CAAC,+BAA+B,CAAC,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CA6B5N"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Merging
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.mergeCustomAttributes = void 0;
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ const SchemaChanges_1 = require("../Validation/SchemaChanges");
13
+ /**
14
+ * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass
15
+ * a scope (Class, Property, Schema) specific handler.
16
+ * @param mergeContext The current schema merging context.
17
+ * @param changes An iterable with custom attribute changes.
18
+ * @param callback The callback to add the custom attribute with a scope specific editor.
19
+ * @returns A EditResults object.
20
+ * @internal
21
+ */
22
+ async function mergeCustomAttributes(mergeContext, changes, callback) {
23
+ for (const customAttributeContainerChange of changes) {
24
+ for (const change of customAttributeContainerChange.customAttributeChanges) {
25
+ if (change.changeType === SchemaChanges_1.ChangeType.Missing) {
26
+ const [sourceCustomAttribute] = change.diagnostic.messageArgs;
27
+ const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(sourceCustomAttribute.className);
28
+ const schemaItemKey = new ecschema_metadata_1.SchemaItemKey(itemName, mergeContext.sourceSchema.schemaKey.compareByName(schemaName)
29
+ ? mergeContext.targetSchema.schemaKey
30
+ : new ecschema_metadata_1.SchemaKey(schemaName));
31
+ const targetCustomAttribute = await mergeContext.targetSchema.lookupItem(schemaItemKey);
32
+ if (targetCustomAttribute === undefined) {
33
+ return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.` };
34
+ }
35
+ const results = await callback({
36
+ ...sourceCustomAttribute,
37
+ className: targetCustomAttribute.fullName,
38
+ });
39
+ if (results.errorMessage !== undefined) {
40
+ return { errorMessage: results.errorMessage };
41
+ }
42
+ }
43
+ else {
44
+ return { errorMessage: `Changes of Custom Attribute ${customAttributeContainerChange.ecTypeName} on ${mergeContext.targetSchema.name} merge is not implemented.` };
45
+ }
46
+ }
47
+ }
48
+ return {};
49
+ }
50
+ exports.mergeCustomAttributes = mergeCustomAttributes;
51
+ //# sourceMappingURL=CustomAttributeMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAuH;AACvH,+DAA0F;AAO1F;;;;;;;;GAQG;AACI,KAAK,UAAU,qBAAqB,CAAC,YAA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AE,CAAC;AACZ,CAAC;AA7BD,sDA6BC","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 { CustomAttribute, CustomAttributeClass, SchemaItem, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ChangeType, CustomAttributeContainerChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\n\ninterface EditResults {\n errorMessage?: string;\n}\n\n/**\n * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass\n * a scope (Class, Property, Schema) specific handler.\n * @param mergeContext The current schema merging context.\n * @param changes An iterable with custom attribute changes.\n * @param callback The callback to add the custom attribute with a scope specific editor.\n * @returns A EditResults object.\n * @internal\n */\nexport async function mergeCustomAttributes(mergeContext: SchemaMergeContext, changes: Iterable<CustomAttributeContainerChanges>, callback: (customAttribute: CustomAttribute) => Promise<EditResults>): Promise<EditResults> {\n for (const customAttributeContainerChange of changes) {\n for (const change of customAttributeContainerChange.customAttributeChanges) {\n if (change.changeType === ChangeType.Missing) {\n const [sourceCustomAttribute] = change.diagnostic.messageArgs as [CustomAttribute];\n const [schemaName, itemName] = SchemaItem.parseFullName(sourceCustomAttribute.className);\n const schemaItemKey = new SchemaItemKey(itemName, mergeContext.sourceSchema.schemaKey.compareByName(schemaName)\n ? mergeContext.targetSchema.schemaKey\n : new SchemaKey(schemaName),\n );\n const targetCustomAttribute = await mergeContext.targetSchema.lookupItem<CustomAttributeClass>(schemaItemKey);\n if (targetCustomAttribute === undefined) {\n return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`};\n }\n\n const results = await callback({\n ...sourceCustomAttribute,\n className: targetCustomAttribute.fullName,\n });\n\n if (results.errorMessage !== undefined) {\n return { errorMessage: results.errorMessage };\n }\n } else {\n return { errorMessage: `Changes of Custom Attribute ${customAttributeContainerChange.ecTypeName} on ${mergeContext.targetSchema.name} merge is not implemented.`};\n }\n }\n }\n return {};\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { EntityClass, Mixin, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
2
+ import { ClassMerger } from "./ClassMerger";
3
+ import { SchemaItemEditResults } from "../Editing/Editor";
4
+ /**
5
+ * @internal
6
+ */
7
+ export default class EntityClassMerger extends ClassMerger<EntityClass> {
8
+ protected create(schemaKey: SchemaKey, ecClass: EntityClass): Promise<SchemaItemEditResults>;
9
+ protected addMixin(itemKey: SchemaItemKey, mixin: Mixin): Promise<SchemaItemEditResults>;
10
+ }
11
+ //# sourceMappingURL=EntityClassMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW,CAAC,WAAW,CAAC;cAC5C,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAIlF,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,qBAAqB,CAAC;CASxG"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*---------------------------------------------------------------------------------------------
4
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
+ * See LICENSE.md in the project root for license terms and full copyright notice.
6
+ *--------------------------------------------------------------------------------------------*/
7
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
8
+ const ClassMerger_1 = require("./ClassMerger");
9
+ /**
10
+ * @internal
11
+ */
12
+ class EntityClassMerger extends ClassMerger_1.ClassMerger {
13
+ async create(schemaKey, ecClass) {
14
+ return this.context.editor.entities.create(schemaKey, ecClass.name, ecClass.modifier);
15
+ }
16
+ async addMixin(itemKey, mixin) {
17
+ const mixinKey = new ecschema_metadata_1.SchemaItemKey(mixin.name, mixin.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)
18
+ ? this.context.targetSchema.schemaKey
19
+ : mixin.schema.schemaKey);
20
+ // addMixin should return results instead of throwing exception
21
+ await this.context.editor.entities.addMixin(itemKey, mixinKey);
22
+ return {};
23
+ }
24
+ }
25
+ exports.default = EntityClassMerger;
26
+ //# sourceMappingURL=EntityClassMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAwF;AACxF,+CAA4C;AAG5C;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,yBAAwB;IAClD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAoB;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxF,CAAC;IAEkB,KAAK,CAAC,QAAQ,CAAC,OAAsB,EAAE,KAAY;QACpE,MAAM,QAAQ,GAAG,IAAI,iCAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC;YAChH,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE5B,+DAA+D;QAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC/D,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAdD,oCAcC","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 { EntityClass, Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ClassMerger } from \"./ClassMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\n\n/**\n * @internal\n */\nexport default class EntityClassMerger extends ClassMerger<EntityClass> {\n protected override async create(schemaKey: SchemaKey, ecClass: EntityClass): Promise<SchemaItemEditResults> {\n return this.context.editor.entities.create(schemaKey, ecClass.name, ecClass.modifier);\n }\n\n protected override async addMixin(itemKey: SchemaItemKey, mixin: Mixin): Promise<SchemaItemEditResults> {\n const mixinKey = new SchemaItemKey(mixin.name, mixin.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : mixin.schema.schemaKey);\n\n // addMixin should return results instead of throwing exception\n await this.context.editor.entities.addMixin(itemKey, mixinKey);\n return {};\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAKA,+DAA6E;AAC7E,yDAAsD;AAItD;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,mCAA6B;IAE1E,qDAAqD;IACrD,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAC1C,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAmB,EAA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CAAC,CAAC;SACxE;QACD,IAAG,YAAY,KAAK,aAAa,IAAI,KAAK,KAAK,SAAS,EAAE;YACxD,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9E;IACH,CAAC;CACF;AApDD,oCAoDC","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 { AnyEnumerator, Enumeration, SchemaItemKey} from \"@itwin/ecschema-metadata\";\r\nimport { ChangeType, EnumerationChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\r\n\r\ntype EnumeratorDeltaArgs = [AnyEnumerator, keyof AnyEnumerator, string | undefined];\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class EnumerationMerger extends SchemaItemMerger<Enumeration> {\r\n\r\n /** Shorthand property to the enumerations editor. */\r\n private get _editor() {\r\n return this.context.editor.enumerations;\r\n }\r\n\r\n protected override async merge(itemKey: SchemaItemKey, source: Enumeration, changes: EnumerationChanges) {\r\n for (const enumeratorChange of changes.enumeratorChanges.values()) {\r\n // In case the enumerator entry does not exist in the target enumeration the\r\n // enumeratorMissing property is set and\r\n if (enumeratorChange.enumeratorMissing?.changeType === ChangeType.Missing) {\r\n\r\n const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);\r\n if (enumerator === undefined) {\r\n throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in class ${source.fullName}`);\r\n }\r\n\r\n // Enumerators are plain javascript objects with out any references to other\r\n // instances or a schema. That allows to simply copy them over.\r\n await this._editor.addEnumerator(itemKey, enumerator);\r\n\r\n // Since every missing enumerator has delta changes for ech property, the loop\r\n // must call continue here to avoid having all properties checked and set again.\r\n continue;\r\n }\r\n\r\n // For changes where the enumerators differ, the enumeratorDeltas property is\r\n // filled. This allows to change individual enumerator entries. This is only\r\n // allowed for labels and descriptions, all other deltas would throw an error.\r\n for(const enumeratorDelta of enumeratorChange.enumeratorDeltas) {\r\n await this.mergeEnumeratorChanges(itemKey, enumeratorDelta.diagnostic.messageArgs! as EnumeratorDeltaArgs);\r\n }\r\n }\r\n }\r\n\r\n private async mergeEnumeratorChanges(itemKey: SchemaItemKey, [enumerator, propertyName, value]: EnumeratorDeltaArgs) {\r\n // In case an enumerator has the same name but different value, the enumerator\r\n // cannot be merged to keep integrity for the existing schema users.\r\n if(propertyName === \"value\") {\r\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${enumerator.name}\" has different values.`);\r\n }\r\n\r\n // For the other two properties they shall only be merged if the source value is\r\n // set. In case they'd be undefined, the current enumerators value shall be kept.\r\n if(propertyName === \"label\" && value !== undefined) {\r\n await this._editor.setEnumeratorLabel(itemKey, enumerator.name, value);\r\n }\r\n if(propertyName === \"description\" && value !== undefined) {\r\n await this._editor.setEnumeratorDescription(itemKey, enumerator.name, value);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAKA,+DAA6E;AAC7E,yDAAsD;AAItD;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,mCAA6B;IAE1E,qDAAqD;IACrD,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAC1C,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAmB,EAAE,OAA2B;QACrG,KAAK,MAAM,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE;YACjE,4EAA4E;YAC5E,wCAAwC;YACxC,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAEzE,MAAM,UAAU,GAAG,MAAM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":["/*---------------------------------------------------------------------------------------------\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 { AnyEnumerator, Enumeration, SchemaItemKey} from \"@itwin/ecschema-metadata\";\nimport { ChangeType, EnumerationChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\n\ntype EnumeratorDeltaArgs = [AnyEnumerator, keyof AnyEnumerator, string | undefined];\n\n/**\n * @internal\n */\nexport default class EnumerationMerger extends SchemaItemMerger<Enumeration> {\n\n /** Shorthand property to the enumerations editor. */\n private get _editor() {\n return this.context.editor.enumerations;\n }\n\n protected override async merge(itemKey: SchemaItemKey, source: Enumeration, changes: EnumerationChanges) {\n for (const enumeratorChange of changes.enumeratorChanges.values()) {\n // In case the enumerator entry does not exist in the target enumeration the\n // enumeratorMissing property is set and\n if (enumeratorChange.enumeratorMissing?.changeType === ChangeType.Missing) {\n\n const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);\n if (enumerator === undefined) {\n throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in class ${source.fullName}`);\n }\n\n // Enumerators are plain javascript objects with out any references to other\n // instances or a schema. That allows to simply copy them over.\n await this._editor.addEnumerator(itemKey, enumerator);\n\n // Since every missing enumerator has delta changes for ech property, the loop\n // must call continue here to avoid having all properties checked and set again.\n continue;\n }\n\n // For changes where the enumerators differ, the enumeratorDeltas property is\n // filled. This allows to change individual enumerator entries. This is only\n // allowed for labels and descriptions, all other deltas would throw an error.\n for(const enumeratorDelta of enumeratorChange.enumeratorDeltas) {\n await this.mergeEnumeratorChanges(itemKey, enumeratorDelta.diagnostic.messageArgs! as EnumeratorDeltaArgs);\n }\n }\n }\n\n private async mergeEnumeratorChanges(itemKey: SchemaItemKey, [enumerator, propertyName, value]: EnumeratorDeltaArgs) {\n // In case an enumerator has the same name but different value, the enumerator\n // cannot be merged to keep integrity for the existing schema users.\n if(propertyName === \"value\") {\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${enumerator.name}\" has different values.`);\n }\n\n // For the other two properties they shall only be merged if the source value is\n // set. In case they'd be undefined, the current enumerators value shall be kept.\n if(propertyName === \"label\" && value !== undefined) {\n await this._editor.setEnumeratorLabel(itemKey, enumerator.name, value);\n }\n if(propertyName === \"description\" && value !== undefined) {\n await this._editor.setEnumeratorDescription(itemKey, enumerator.name, value);\n }\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { KindOfQuantity, SchemaItemKey } from "@itwin/ecschema-metadata";
2
+ import { PropertyValueResolver, SchemaItemMerger } from "./SchemaItemMerger";
3
+ import { KindOfQuantityChanges } from "../Validation/SchemaChanges";
4
+ /**
5
+ * @internal
6
+ */
7
+ export default class KindOfQuantityMerger extends SchemaItemMerger<KindOfQuantity> {
8
+ protected merge(itemKey: SchemaItemKey, source: KindOfQuantity, changes: KindOfQuantityChanges): Promise<void>;
9
+ /**
10
+ *
11
+ * Creates the property value resolver for [[KindOfQuantity]] items.
12
+ */
13
+ protected createPropertyValueResolver(): Promise<PropertyValueResolver<KindOfQuantity>>;
14
+ }
15
+ //# sourceMappingURL=KindOfQuantityMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KindOfQuantityMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwB,cAAc,EAA8B,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AACjI,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,gBAAgB,CAAC,cAAc,CAAC;cAEvD,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB;IAmC7G;;;OAGG;cACsB,2BAA2B,IAAI,OAAO,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;CAcvG"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*---------------------------------------------------------------------------------------------
4
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
+ * See LICENSE.md in the project root for license terms and full copyright notice.
6
+ *--------------------------------------------------------------------------------------------*/
7
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
8
+ const SchemaItemMerger_1 = require("./SchemaItemMerger");
9
+ /**
10
+ * @internal
11
+ */
12
+ class KindOfQuantityMerger extends SchemaItemMerger_1.SchemaItemMerger {
13
+ async merge(itemKey, source, changes) {
14
+ for (const presentationUnitChange of changes.presentationUnitChanges.values()) {
15
+ for (const change of presentationUnitChange.presentationUnitChange) {
16
+ const format = change.diagnostic.messageArgs[0];
17
+ const isDefault = source.defaultPresentationFormat === format;
18
+ if (ecschema_metadata_1.OverrideFormat.isOverrideFormat(format)) {
19
+ const parentFormat = await this.lookup(format.parent);
20
+ if (parentFormat === undefined) {
21
+ throw new Error(`Unable to locate the format class ${format.parent.name} in the merged schema.`);
22
+ }
23
+ const unitAndLabels = [];
24
+ if (format.units !== undefined) {
25
+ for (const [unit, label] of format.units) {
26
+ const targetUnit = await this.lookup(unit);
27
+ if (targetUnit === undefined) {
28
+ throw new Error(`Unable to locate the unit class ${unit.name} in the merged schema.`);
29
+ }
30
+ unitAndLabels.push([targetUnit, label]);
31
+ }
32
+ }
33
+ const overrideFormat = await this.context.editor.kindOfQuantities.createFormatOverride(itemKey, parentFormat.key, format.precision, unitAndLabels);
34
+ await this.context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, overrideFormat, isDefault);
35
+ }
36
+ else {
37
+ const targetFormat = await this.lookup(format);
38
+ if (targetFormat === undefined) {
39
+ throw new Error(`Unable to locate the format class ${format.name} in the merged schema.`);
40
+ }
41
+ await this.context.editor.kindOfQuantities.addPresentationFormat(itemKey, targetFormat.key, isDefault);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ /**
47
+ *
48
+ * Creates the property value resolver for [[KindOfQuantity]] items.
49
+ */
50
+ async createPropertyValueResolver() {
51
+ return {
52
+ persistenceUnit: (newValue, targetItemKey, oldValue) => {
53
+ if (oldValue !== undefined && oldValue !== newValue) {
54
+ throw new Error(`Changing the kind of quantity '${targetItemKey.name}' persistenceUnit is not supported.`);
55
+ }
56
+ const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(newValue);
57
+ if (this.context.targetSchema.getReferenceSync(schemaName) === undefined) {
58
+ return `${targetItemKey.schemaName}.${itemName}`;
59
+ }
60
+ return newValue;
61
+ },
62
+ };
63
+ }
64
+ }
65
+ exports.default = KindOfQuantityMerger;
66
+ //# sourceMappingURL=KindOfQuantityMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAiI;AACjI,yDAA6E;AAG7E;;GAEG;AACH,MAAqB,oBAAqB,SAAQ,mCAAgC;IAE7D,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAsB,EAAE,OAA8B;QAC3G,KAAK,MAAM,sBAAsB,IAAI,OAAO,CAAC,uBAAuB,CAAC,MAAM,EAAE,EAAE;YAC7E,KAAK,MAAM,MAAM,IAAI,sBAAsB,CAAC,sBAAsB,EAAE;gBAClE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,WAAY,CAAC,CAAC,CAAC,CAAC;gBACjD,MAAM,SAAS,GAAG,MAAM,CAAC,yBAAyB,KAAK,MAAM,CAAC;gBAE9D,IAAI,kCAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE;oBAC3C,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAS,MAAM,CAAC,MAAM,CAA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AC;iBACxG;aACF;SACF;IACH,CAAC;IAED;;;OAGG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,eAAe,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE;gBACrD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,QAAQ,EAAE;oBACnD,MAAM,IAAI,KAAK,CAAC,kCAAkC,aAAa,CAAC,IAAI,qCAAqC,CAAC,CAAC;iBAC5G;gBACD,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAClE,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACxE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;iBAClD;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAvDD,uCAuDC","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 { Format, InvertedUnit, KindOfQuantity, OverrideFormat, SchemaItem, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\nimport { KindOfQuantityChanges } from \"../Validation/SchemaChanges\";\n\n/**\n * @internal\n */\nexport default class KindOfQuantityMerger extends SchemaItemMerger<KindOfQuantity> {\n\n protected override async merge(itemKey: SchemaItemKey, source: KindOfQuantity, changes: KindOfQuantityChanges) {\n for (const presentationUnitChange of changes.presentationUnitChanges.values()) {\n for (const change of presentationUnitChange.presentationUnitChange) {\n const format = change.diagnostic.messageArgs![0];\n const isDefault = source.defaultPresentationFormat === format;\n\n if (OverrideFormat.isOverrideFormat(format)) {\n const parentFormat = await this.lookup<Format>(format.parent);\n if (parentFormat === undefined) {\n throw new Error(`Unable to locate the format class ${format.parent.name} in the merged schema.`);\n }\n\n const unitAndLabels: Array<[Unit | InvertedUnit, string | undefined]> | undefined = [];\n if (format.units !== undefined) {\n for (const [unit, label] of format.units) {\n const targetUnit = await this.lookup<Unit | InvertedUnit>(unit);\n if (targetUnit === undefined) {\n throw new Error(`Unable to locate the unit class ${unit.name} in the merged schema.`);\n }\n unitAndLabels.push([targetUnit, label]);\n }\n }\n const overrideFormat = await this.context.editor.kindOfQuantities.createFormatOverride(itemKey, parentFormat.key, format.precision, unitAndLabels);\n await this.context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, overrideFormat, isDefault);\n } else {\n const targetFormat = await this.lookup<Format>(format);\n if (targetFormat === undefined) {\n throw new Error(`Unable to locate the format class ${format.name} in the merged schema.`);\n }\n await this.context.editor.kindOfQuantities.addPresentationFormat(itemKey, targetFormat.key, isDefault);\n }\n }\n }\n }\n\n /**\n *\n * Creates the property value resolver for [[KindOfQuantity]] items.\n */\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<KindOfQuantity>> {\n return {\n persistenceUnit: (newValue, targetItemKey, oldValue) => {\n if (oldValue !== undefined && oldValue !== newValue) {\n throw new Error(`Changing the kind of quantity '${targetItemKey.name}' persistenceUnit is not supported.`);\n }\n const [schemaName, itemName] = SchemaItem.parseFullName(newValue);\n if (this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\n return `${targetItemKey.schemaName}.${itemName}`;\n }\n return newValue;\n },\n };\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { Mixin, SchemaKey } from "@itwin/ecschema-metadata";
2
+ import { SchemaItemEditResults } from "../Editing/Editor";
3
+ import { ClassMerger } from "./ClassMerger";
4
+ /**
5
+ * @internal
6
+ */
7
+ export default class MixinMerger extends ClassMerger<Mixin> {
8
+ protected create(schemaKey: SchemaKey, ecClass: Mixin): Promise<SchemaItemEditResults>;
9
+ protected mergeAttributes(ecClass: Mixin, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean>;
10
+ }
11
+ //# sourceMappingURL=MixinMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MixinMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAiB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,KAAK,CAAC;cAEhC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAW5E,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC;CAe1K"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*---------------------------------------------------------------------------------------------
4
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
+ * See LICENSE.md in the project root for license terms and full copyright notice.
6
+ *--------------------------------------------------------------------------------------------*/
7
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
8
+ const ClassMerger_1 = require("./ClassMerger");
9
+ /**
10
+ * @internal
11
+ */
12
+ class MixinMerger extends ClassMerger_1.ClassMerger {
13
+ async create(schemaKey, ecClass) {
14
+ if (ecClass.appliesTo === undefined) {
15
+ return { errorMessage: `The Mixin ${ecClass.fullName} is missing the required 'appliesTo' attribute.` };
16
+ }
17
+ const appliesTo = new ecschema_metadata_1.SchemaItemKey(ecClass.appliesTo.name, this.context.sourceSchema.schemaKey.matches(ecClass.appliesTo.schemaKey)
18
+ ? this.context.targetSchema.schemaKey
19
+ : ecClass.appliesTo.schemaKey);
20
+ return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);
21
+ }
22
+ async mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue) {
23
+ const results = await super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);
24
+ if (results === true || this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {
25
+ return results;
26
+ }
27
+ switch (attributeName) {
28
+ case "appliesTo":
29
+ if (attributeOldValue !== undefined) {
30
+ return { errorMessage: `Changing the mixin '${ecClass.name}' appliesTo is not supported.` };
31
+ }
32
+ return true;
33
+ }
34
+ return false;
35
+ }
36
+ }
37
+ exports.default = MixinMerger;
38
+ //# sourceMappingURL=MixinMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA2E;AAE3E,+CAA4C;AAE5C;;GAEG;AACH,MAAqB,WAAY,SAAQ,yBAAkB;IAEtC,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAc;QAClE,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE;YACnC,OAAO,EAAE,YAAY,EAAE,aAAa,OAAO,CAAC,QAAQ,iDAAiD,EAAE,CAAC;SACzG;QAED,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC;YAClI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/E,CAAC;IAEkB,KAAK,CAAC,eAAe,CAAC,OAAc,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QAC5H,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC1G,IAAI,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACnG,OAAO,OAAO,CAAC;SAChB;QAED,QAAO,aAAa,EAAE;YACpB,KAAK,WAAW;gBACd,IAAI,iBAAiB,KAAK,SAAS,EAAE;oBACnC,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,+BAA+B,EAAE,CAAC;iBAC7F;gBACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA5BD,8BA4BC","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 { Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ClassMerger } from \"./ClassMerger\";\n\n/**\n * @internal\n */\nexport default class MixinMerger extends ClassMerger<Mixin> {\n\n protected override async create(schemaKey: SchemaKey, ecClass: Mixin): Promise<SchemaItemEditResults> {\n if (ecClass.appliesTo === undefined) {\n return { errorMessage: `The Mixin ${ecClass.fullName} is missing the required 'appliesTo' attribute.` };\n }\n\n const appliesTo = new SchemaItemKey(ecClass.appliesTo.name, this.context.sourceSchema.schemaKey.matches(ecClass.appliesTo.schemaKey)\n ? this.context.targetSchema.schemaKey\n : ecClass.appliesTo.schemaKey);\n return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);\n }\n\n protected override async mergeAttributes(ecClass: Mixin, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n const results = await super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n switch(attributeName) {\n case \"appliesTo\":\n if (attributeOldValue !== undefined) {\n return { errorMessage: `Changing the mixin '${ecClass.name}' appliesTo is not supported.` };\n }\n return true;\n }\n return false;\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { EnumerationProperty, PrimitiveOrEnumPropertyBase, PrimitiveProperty, SchemaItemKey } from "@itwin/ecschema-metadata";
2
+ import { AnyPropertyMerger } from "./AnyPropertyMerger";
3
+ import { PropertyEditResults } from "../Editing/Editor";
4
+ /**
5
+ * @internal
6
+ */
7
+ declare abstract class PrimitiveOrEnumPropertyMerger<TPrimitiveOrEnumPropertyBase extends PrimitiveOrEnumPropertyBase> extends AnyPropertyMerger<TPrimitiveOrEnumPropertyBase> {
8
+ mergeAttributes(property: TPrimitiveOrEnumPropertyBase, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean>;
9
+ }
10
+ /**
11
+ * @internal
12
+ */
13
+ export declare class PrimitivePropertyMerger extends PrimitiveOrEnumPropertyMerger<PrimitiveProperty> {
14
+ createFromProps(classKey: SchemaItemKey, property: PrimitiveProperty): Promise<PropertyEditResults>;
15
+ }
16
+ /**
17
+ * @internal
18
+ */
19
+ export declare class EnumerationPropertyMerger extends PrimitiveOrEnumPropertyMerger<EnumerationProperty> {
20
+ mergeAttributes(property: EnumerationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean>;
21
+ createFromProps(classKey: SchemaItemKey, property: EnumerationProperty): Promise<PropertyEditResults>;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=PrimitiveOrEnumPropertyMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimitiveOrEnumPropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PrimitiveOrEnumPropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,mBAAmB,EAA4B,2BAA2B,EAAE,iBAAiB,EAA0B,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC7L,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD;;GAEG;AACH,uBAAe,6BAA6B,CAAC,4BAA4B,SAAS,2BAA2B,CAAE,SAAQ,iBAAiB,CAAC,4BAA4B,CAAC;IAC9I,eAAe,CAAC,QAAQ,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC;CA+B7L;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,6BAA6B,CAAC,iBAAiB,CAAC;IACrE,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAY1H;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,6BAA6B,CAAC,mBAAmB,CAAC;IACzE,eAAe,CAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC;IAiB7J,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA2B5H"}