@itwin/ecschema-editing 4.7.0-dev.15 → 4.7.0-dev.16

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/lib/cjs/Differencing/Errors.js.map +1 -1
  2. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  3. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  4. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  5. package/lib/cjs/Editing/Constants.d.ts +6 -6
  6. package/lib/cjs/Editing/Constants.d.ts.map +1 -1
  7. package/lib/cjs/Editing/Constants.js +26 -31
  8. package/lib/cjs/Editing/Constants.js.map +1 -1
  9. package/lib/cjs/Editing/CustomAttributes.d.ts +3 -3
  10. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  11. package/lib/cjs/Editing/CustomAttributes.js +18 -28
  12. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  13. package/lib/cjs/Editing/ECClasses.d.ts +24 -23
  14. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  15. package/lib/cjs/Editing/ECClasses.js +126 -156
  16. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  17. package/lib/cjs/Editing/Editor.d.ts +10 -31
  18. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  19. package/lib/cjs/Editing/Editor.js +59 -43
  20. package/lib/cjs/Editing/Editor.js.map +1 -1
  21. package/lib/cjs/Editing/Entities.d.ts +9 -9
  22. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  23. package/lib/cjs/Editing/Entities.js +65 -85
  24. package/lib/cjs/Editing/Entities.js.map +1 -1
  25. package/lib/cjs/Editing/Enumerations.d.ts +6 -6
  26. package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
  27. package/lib/cjs/Editing/Enumerations.js +57 -55
  28. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  29. package/lib/cjs/Editing/Exception.d.ts +257 -0
  30. package/lib/cjs/Editing/Exception.d.ts.map +1 -0
  31. package/lib/cjs/Editing/Exception.js +426 -0
  32. package/lib/cjs/Editing/Exception.js.map +1 -0
  33. package/lib/cjs/Editing/Formats.d.ts +6 -6
  34. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  35. package/lib/cjs/Editing/Formats.js +28 -33
  36. package/lib/cjs/Editing/Formats.js.map +1 -1
  37. package/lib/cjs/Editing/InvertedUnits.d.ts +6 -6
  38. package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
  39. package/lib/cjs/Editing/InvertedUnits.js +41 -56
  40. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  41. package/lib/cjs/Editing/KindOfQuantities.d.ts +6 -6
  42. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  43. package/lib/cjs/Editing/KindOfQuantities.js +50 -57
  44. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  45. package/lib/cjs/Editing/Mixins.d.ts +5 -5
  46. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  47. package/lib/cjs/Editing/Mixins.js +43 -58
  48. package/lib/cjs/Editing/Mixins.js.map +1 -1
  49. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  50. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  51. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  52. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  53. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +1 -5
  54. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts.map +1 -1
  55. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +1 -45
  56. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  57. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  58. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  59. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  60. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  61. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  62. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  63. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  64. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  65. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  66. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  67. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  68. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  69. package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -1
  70. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  71. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  72. package/lib/cjs/Editing/Phenomena.d.ts +7 -7
  73. package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
  74. package/lib/cjs/Editing/Phenomena.js +23 -23
  75. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  76. package/lib/cjs/Editing/Properties.d.ts +7 -6
  77. package/lib/cjs/Editing/Properties.d.ts.map +1 -1
  78. package/lib/cjs/Editing/Properties.js +99 -46
  79. package/lib/cjs/Editing/Properties.js.map +1 -1
  80. package/lib/cjs/Editing/PropertyCategories.d.ts +6 -6
  81. package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
  82. package/lib/cjs/Editing/PropertyCategories.js +29 -27
  83. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  84. package/lib/cjs/Editing/RelationshipClasses.d.ts +15 -17
  85. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  86. package/lib/cjs/Editing/RelationshipClasses.js +97 -101
  87. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  88. package/lib/cjs/Editing/SchemaItems.d.ts +13 -5
  89. package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
  90. package/lib/cjs/Editing/SchemaItems.js +58 -6
  91. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  92. package/lib/cjs/Editing/Structs.d.ts +3 -3
  93. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  94. package/lib/cjs/Editing/Structs.js +17 -27
  95. package/lib/cjs/Editing/Structs.js.map +1 -1
  96. package/lib/cjs/Editing/UnitSystems.d.ts +7 -7
  97. package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
  98. package/lib/cjs/Editing/UnitSystems.js +22 -20
  99. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  100. package/lib/cjs/Editing/Units.d.ts +6 -6
  101. package/lib/cjs/Editing/Units.d.ts.map +1 -1
  102. package/lib/cjs/Editing/Units.js +26 -35
  103. package/lib/cjs/Editing/Units.js.map +1 -1
  104. package/lib/cjs/Merging/CAClassMerger.js +2 -2
  105. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  106. package/lib/cjs/Merging/ClassMerger.d.ts +1 -2
  107. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  108. package/lib/cjs/Merging/ClassMerger.js +15 -39
  109. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  110. package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
  111. package/lib/cjs/Merging/ConstantMerger.js +2 -3
  112. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  113. package/lib/cjs/Merging/CustomAttributeMerger.d.ts +4 -5
  114. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  115. package/lib/cjs/Merging/CustomAttributeMerger.js +8 -18
  116. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  117. package/lib/cjs/Merging/EntityClassMerger.d.ts +1 -2
  118. package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
  119. package/lib/cjs/Merging/EntityClassMerger.js +3 -10
  120. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  121. package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
  122. package/lib/cjs/Merging/EnumerationMerger.js +8 -10
  123. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  124. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  125. package/lib/cjs/Merging/KindOfQuantityMerger.js +2 -3
  126. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  127. package/lib/cjs/Merging/MixinMerger.js +2 -2
  128. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  129. package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -1
  130. package/lib/cjs/Merging/PhenomenonMerger.js +1 -2
  131. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  132. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -1
  133. package/lib/cjs/Merging/PropertyCategoryMerger.js +1 -2
  134. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
  135. package/lib/cjs/Merging/PropertyMerger.d.ts +2 -3
  136. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
  137. package/lib/cjs/Merging/PropertyMerger.js +21 -42
  138. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  139. package/lib/cjs/Merging/RelationshipClassMerger.d.ts +5 -3
  140. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
  141. package/lib/cjs/Merging/RelationshipClassMerger.js +19 -31
  142. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  143. package/lib/cjs/Merging/SchemaItemMerger.d.ts +3 -4
  144. package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
  145. package/lib/cjs/Merging/SchemaItemMerger.js +3 -2
  146. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  147. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  148. package/lib/cjs/Merging/SchemaMerger.js +2 -8
  149. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  150. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  151. package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -1
  152. package/lib/cjs/Merging/UnitSystemMerger.js +1 -2
  153. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
  154. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  155. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  156. package/lib/cjs/Validation/ECRules.js.map +1 -1
  157. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  158. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  159. package/lib/cjs/Validation/Rules.js.map +1 -1
  160. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  161. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  162. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  163. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  164. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  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 +9 -9
  171. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1 +1 @@
1
- {"version":3,"file":"ECClasses.js","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAOkC;AAClC,sDAA6C;AAG7C,+CAA+C;AAC/C,6CAAyH;AAIzH;;;GAGG;AACH,MAAa,SAAS;IAEpB,YAAgC,cAAkC,EAAY,aAAkC;QAAhF,mBAAc,GAAd,cAAc,CAAoB;QAAY,kBAAa,GAAb,aAAa,CAAqB;QAEhH;;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AAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AA/XD,8BA+XC","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 Editing\r\n */\r\n\r\nimport {\r\n CustomAttribute,\r\n CustomAttributeContainerProps,\r\n DelayedPromiseWithProps,\r\n ECClass, ECObjectsError, ECObjectsStatus, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\r\n PrimitivePropertyProps, PrimitiveType, SchemaItemKey, SchemaItemType, StructArrayPropertyProps,\r\n StructClass, StructPropertyProps,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutableClass } from \"./Mutable/MutableClass\";\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { ArrayProperties, EnumerationProperties, PrimitiveProperties, Properties, StructProperties } from \"./Properties\";\r\n\r\nexport type ECClassSchemaItems = SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.RelationshipClass | SchemaItemType.Mixin | SchemaItemType.CustomAttributeClass;\r\n\r\n/**\r\n * @alpha\r\n * Acts as a base class for schema class creation. Enables property creation.\r\n */\r\nexport class ECClasses {\r\n\r\n protected constructor(protected schemaItemType: ECClassSchemaItems, protected _schemaEditor: SchemaContextEditor) { }\r\n\r\n /**\r\n * Allows access for editing of base Property attributes.\r\n */\r\n public readonly properties = new Properties(this.schemaItemType, this._schemaEditor);\r\n /**\r\n * Allows access for editing of ArrayProperty attributes.\r\n */\r\n public readonly arrayProperties = new ArrayProperties(this.schemaItemType, this._schemaEditor);\r\n /**\r\n * Allows access for editing of PrimitiveProperty attributes.\r\n */\r\n public readonly primitiveProperties = new PrimitiveProperties(this.schemaItemType, this._schemaEditor);\r\n /**\r\n * Allows access for editing of EnumerationProperty attributes.\r\n */\r\n public readonly enumerationProperties = new EnumerationProperties(this.schemaItemType, this._schemaEditor);\r\n /**\r\n * Allows access for editing of StructProperty attributes.\r\n */\r\n public readonly structProperties = new StructProperties(this.schemaItemType, this._schemaEditor);\r\n\r\n /**\r\n * Creates a property on class identified by the given SchemaItemKey. This method restricts the\r\n * property type to primitives of type Double, String, DateTime and Integer.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param name The name of the new property.\r\n * @param type The PrimitiveType assigned to the new property.\r\n */\r\n public async createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n\r\n if (type !== PrimitiveType.Double && type !== PrimitiveType.String && type !== PrimitiveType.DateTime\r\n && type !== PrimitiveType.Integer)\r\n throw new Error (\"Property creation is restricted to type Double, String, DateTime, and Integer.\");\r\n\r\n if (\"\" === prefix)\r\n throw new Error(\"The specified property name prefix is invalid\");\r\n\r\n const prefixedName = `${prefix}_${name}`;\r\n\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveProperty(prefixedName, type);\r\n return { itemKey: classKey, propertyName: prefixedName };\r\n }\r\n\r\n /**\r\n * Create a primitive property on class identified by the given SchemaItemKey.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param name The name of the new property.\r\n * @param type The PrimitiveType assigned to the new property.\r\n */\r\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\r\n await newProperty.fromJSON(primitiveProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\r\n if (enumSchemaItemKey === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);\r\n\r\n await mutableClass.createPrimitiveProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\r\n await newProperty.fromJSON(enumProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveArrayProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\r\n await newProperty.fromJSON(primitiveProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createEnumerationArrayProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveArrayProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createEnumerationArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, props: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\r\n await newProperty.fromJSON(props);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createStructProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createStructProperty(name, type);\r\n await newProperty.fromJSON(structProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createStructArrayProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\r\n await newProperty.fromJSON(structProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.deleteProperty(name);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\r\n\r\n const ecClass = await schema.getItem<ECClass>(classKey.name);\r\n if (ecClass === undefined)\r\n return {};\r\n\r\n await schema.deleteClass(ecClass.name);\r\n\r\n return { itemKey: classKey };\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey\r\n * @param classKey The SchemaItemKey identifying the schema.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<SchemaItemEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n mutableClass.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\r\n\r\n const result: SchemaItemEditResults = { errorMessage: \"\" };\r\n for await (const diagnostic of diagnostics) {\r\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (result.errorMessage) {\r\n this.removeCustomAttribute(mutableClass, customAttribute);\r\n return result;\r\n }\r\n\r\n return {};\r\n }\r\n\r\n /**\r\n * Sets the name of the ECClass.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param name The new name of the class.\r\n * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name\r\n */\r\n public async setName(classKey: SchemaItemKey, name: string): Promise<SchemaItemEditResults> {\r\n let mutableClass: MutableClass;\r\n\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined) {\r\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\r\n }\r\n\r\n const ecClass = await schema.getItem<MutableClass>(name);\r\n if (ecClass !== undefined)\r\n return { errorMessage: `An EC Class with the name ${name} already exists within the schema ${schema.name}` };\r\n\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const existingName = classKey.name;\r\n mutableClass.setName(name);\r\n\r\n // Must reset in schema item map\r\n await schema.deleteClass(existingName);\r\n schema.addItem(mutableClass);\r\n\r\n return {};\r\n }\r\n\r\n /**\r\n * Sets the base class of a SchemaItem.\r\n * @param itemKey The SchemaItemKey of the Item.\r\n * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.\r\n */\r\n public async setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<SchemaItemEditResults> {\r\n const classItem = await this._schemaEditor.schemaContext.getSchemaItem<MutableClass>(itemKey);\r\n\r\n if (classItem === undefined)\r\n return { itemKey, errorMessage: `Class ${itemKey.fullName} not found in schema context.` };\r\n\r\n if (baseClassKey === undefined) {\r\n classItem.baseClass = undefined;\r\n return { itemKey };\r\n }\r\n\r\n const baseClassSchema = !baseClassKey.schemaKey.matches(itemKey.schemaKey) ? await this._schemaEditor.getSchema(baseClassKey.schemaKey) : classItem.schema;\r\n if (baseClassSchema === undefined) {\r\n return { itemKey, errorMessage: `Schema Key ${baseClassKey.schemaKey.toString(true)} not found in context` };\r\n }\r\n\r\n const baseClassItem = await baseClassSchema.lookupItem<ECClass>(baseClassKey);\r\n if (baseClassItem === undefined)\r\n return { itemKey, errorMessage: `Unable to locate base class ${baseClassKey.fullName} in schema ${baseClassSchema.fullName}.` };\r\n\r\n if (baseClassItem.schemaItemType !== classItem.schemaItemType)\r\n return { itemKey, errorMessage: `${baseClassItem.fullName} is not of type ${classItem.schemaItemType}.` };\r\n\r\n if (classItem.baseClass !== undefined && !await baseClassItem.is(await classItem.baseClass))\r\n return { itemKey, errorMessage: `Baseclass ${baseClassItem.fullName} must derive from ${classItem.baseClass.fullName}.`};\r\n\r\n classItem.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClassKey, async () => baseClassItem);\r\n return { itemKey };\r\n }\r\n\r\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema,`Schema Key ${classKey.schemaKey.toString(true)} not found in context`);\r\n\r\n const ecClass = await schema.getItem<MutableClass>(classKey.name);\r\n if (ecClass === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);\r\n\r\n switch (ecClass.schemaItemType) {\r\n case SchemaItemType.EntityClass:\r\n case SchemaItemType.Mixin:\r\n case SchemaItemType.StructClass:\r\n case SchemaItemType.CustomAttributeClass:\r\n case SchemaItemType.RelationshipClass:\r\n break;\r\n default:\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);\r\n }\r\n\r\n return ecClass;\r\n }\r\n\r\n protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\r\n assert(container.customAttributes !== undefined);\r\n const map = container.customAttributes as Map<string, CustomAttribute>;\r\n map.delete(customAttribute.className);\r\n }\r\n\r\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\r\n const derivedClasses: Array<MutableClass> = [];\r\n const schemaItems = this._schemaEditor.schemaContext.getSchemaItems();\r\n let { value, done } = schemaItems.next();\r\n while (!done) {\r\n if (await value.is(mutableClass)) {\r\n if (!mutableClass.key.matches(value.key)) {\r\n derivedClasses.push(value);\r\n }\r\n }\r\n ({ value, done } = schemaItems.next());\r\n }\r\n\r\n return derivedClasses;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ECClasses.js","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAOkC;AAClC,sDAA6C;AAG7C,+CAA+C;AAC/C,6CAAyH;AACzH,2CAAwH;AAExH,+CAA8D;AAK9D;;;GAGG;AACH,MAAa,SAAU,SAAQ,yBAAW;IAExC,YAAsB,cAAkC,EAAE,YAAiC;QACzF,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;QAMtC;;WAEG;QACa,eAAU,GAAG,IAAI,uBAAU,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACpF;;WAEG;QACa,oBAAe,GAAG,IAAI,4BAAe,CAAC,IAAI,CAAC,cAAc,EA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AAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;QACzC,OAAO,CAAC,IAAI,EAAE,CAAC;YACb,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;gBACjC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;oBACzC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;YACD,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AA9UD,8BA8UC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n CustomAttribute,\n CustomAttributeContainerProps,\n DelayedPromiseWithProps,\n ECClass, ECObjectsError, ECObjectsStatus, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\n PrimitivePropertyProps, PrimitiveType, SchemaItemKey, SchemaItemType, SchemaKey, StructArrayPropertyProps,\n StructClass, StructPropertyProps,\n} from \"@itwin/ecschema-metadata\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { ArrayProperties, EnumerationProperties, PrimitiveProperties, Properties, StructProperties } from \"./Properties\";\nimport { ClassId, CustomAttributeId, ECEditingStatus, PropertyId, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\nimport { CreateSchemaItem, SchemaItems } from \"./SchemaItems\";\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\n\nexport type ECClassSchemaItems = SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.RelationshipClass | SchemaItemType.Mixin | SchemaItemType.CustomAttributeClass;\n\n/**\n * @alpha\n * Acts as a base class for schema class creation. Enables property creation.\n */\nexport class ECClasses extends SchemaItems{\n\n protected constructor(schemaItemType: ECClassSchemaItems, schemaEditor: SchemaContextEditor) {\n super(schemaItemType, schemaEditor);\n this.schemaItemType = schemaItemType;\n }\n\n protected override schemaItemType: ECClassSchemaItems;\n\n /**\n * Allows access for editing of base Property attributes.\n */\n public readonly properties = new Properties(this.schemaItemType, this.schemaEditor);\n /**\n * Allows access for editing of ArrayProperty attributes.\n */\n public readonly arrayProperties = new ArrayProperties(this.schemaItemType, this.schemaEditor);\n /**\n * Allows access for editing of PrimitiveProperty attributes.\n */\n public readonly primitiveProperties = new PrimitiveProperties(this.schemaItemType, this.schemaEditor);\n /**\n * Allows access for editing of EnumerationProperty attributes.\n */\n public readonly enumerationProperties = new EnumerationProperties(this.schemaItemType, this.schemaEditor);\n /**\n * Allows access for editing of StructProperty attributes.\n */\n public readonly structProperties = new StructProperties(this.schemaItemType, this.schemaEditor);\n\n public async createClass<T extends ECClass>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, baseClassKey?: SchemaItemKey, ...args: any[]): Promise<T> {\n const newClass = await this.createSchemaItem(schemaKey, type, create, name, ...args);\n\n if (baseClassKey !== undefined) {\n const baseClassSchema = !baseClassKey.schemaKey.matches(newClass.schema.schemaKey) ? await this.getSchema(baseClassKey.schemaKey) : newClass.schema as MutableSchema;\n const baseClassItem = await this.lookupSchemaItem<ECClass>(baseClassSchema, baseClassKey);\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, T>(baseClassKey, async () => baseClassItem as T);\n }\n\n return newClass;\n }\n\n /**\n * Creates a property on class identified by the given SchemaItemKey. This method restricts the\n * property type to primitives of type Double, String, DateTime and Integer.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<void> {\n if (type !== PrimitiveType.Double && type !== PrimitiveType.String && type !== PrimitiveType.DateTime\n && type !== PrimitiveType.Integer)\n throw new Error (\"Property creation is restricted to type Double, String, DateTime, and Integer.\");\n\n if (\"\" === prefix)\n throw new Error(\"The specified property name prefix is invalid\");\n\n const prefixedName = `${prefix}_${name}`;\n\n const mutableClass = await this.getClass(classKey);\n\n await mutableClass.createPrimitiveProperty(prefixedName, type);\n }\n\n /**\n * Create a primitive property on class identified by the given SchemaItemKey.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createPrimitiveProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitivePropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\n if (enumSchemaItemKey === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(SchemaItemType.Enumeration, type.name, mutableClass.schema.schemaKey));\n\n await mutableClass.createPrimitiveProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(enumProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createPrimitiveArrayProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationArrayProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createPrimitiveArrayProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createEnumerationArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, props: PrimitiveArrayPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(props);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createStructProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createStructProperty(name, type);\n await newProperty.fromJSON(structProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.createStructArrayProperty(name, type);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\n await newProperty.fromJSON(structProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateStructArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n await mutableClass.deleteProperty(name);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.DeleteProperty, new PropertyId(this.schemaItemType, classKey, name), e);\n }\n }\n\n public async delete(classKey: SchemaItemKey): Promise<void> {\n try {\n const schema = await this.getSchema(classKey.schemaKey);\n const ecClass = await schema.getItem<ECClass>(classKey.name);\n if (ecClass === undefined)\n return;\n\n await schema.deleteClass(ecClass.name);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.DeleteClass, new ClassId(this.schemaItemType, classKey), e);\n }\n }\n\n /**\n * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey\n * @param classKey The SchemaItemKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<void> {\n try {\n const mutableClass = await this.getClass(classKey);\n mutableClass.addCustomAttribute(customAttribute);\n\n const diagnosticIterable = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of diagnosticIterable) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeCustomAttribute(mutableClass, customAttribute);\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, mutableClass), undefined, diagnostics);\n }\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToClass, new ClassId(this.schemaItemType, classKey), e);\n }\n }\n\n /**\n * Sets the name of the ECClass.\n * @param classKey The SchemaItemKey of the class.\n * @param name The new name of the class.\n * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name\n */\n public async setName(classKey: SchemaItemKey, name: string): Promise<SchemaItemKey> {\n try {\n const schema = await this.getSchema(classKey.schemaKey);\n const ecClass = await schema.getItem<MutableClass>(name);\n if (ecClass !== undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new ClassId(this.schemaItemType, name, schema.schemaKey));\n\n const mutableClass = await this.getClass(classKey);\n\n const existingName = classKey.name;\n mutableClass.setName(name);\n\n // Must reset in schema item map\n await schema.deleteClass(existingName);\n schema.addItem(mutableClass);\n return mutableClass.key;\n } catch(e: any) {\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.InvalidECName) {\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new ClassId(this.schemaItemType, classKey),\n new SchemaEditingError(ECEditingStatus.InvalidECName, new ClassId(this.schemaItemType, classKey)));\n }\n\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new ClassId(this.schemaItemType, classKey), e);\n }\n }\n\n /**\n * Sets the base class of a SchemaItem.\n * @param itemKey The SchemaItemKey of the Item.\n * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.\n */\n public async setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<void> {\n try {\n const classItem = await this.getSchemaItem<ECClass>(itemKey);\n if (!baseClassKey) {\n classItem.baseClass = undefined;\n return;\n }\n\n const baseClassSchema = !baseClassKey.schemaKey.matches(itemKey.schemaKey) ? await this.getSchema(baseClassKey.schemaKey) : classItem.schema as MutableSchema;\n const baseClassItem = await this.lookupSchemaItem<ECClass>(baseClassSchema, baseClassKey);\n if (classItem.baseClass !== undefined && !await baseClassItem.is(await classItem.baseClass))\n throw new SchemaEditingError(ECEditingStatus.InvalidBaseClass, new ClassId(this.schemaItemType, baseClassKey), undefined, undefined, `Base class ${baseClassKey.fullName} must derive from ${(await classItem.baseClass).fullName}.`);\n\n classItem.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClassKey, async () => baseClassItem);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(this.schemaItemType, itemKey), e);\n }\n }\n\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\n const schema = await this.getSchema(classKey.schemaKey);\n\n const ecClass = await schema.getItem<MutableClass>(classKey.name);\n if (ecClass === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new ClassId(this.schemaItemType, classKey));\n\n switch (ecClass.schemaItemType) {\n case SchemaItemType.EntityClass:\n case SchemaItemType.Mixin:\n case SchemaItemType.StructClass:\n case SchemaItemType.CustomAttributeClass:\n case SchemaItemType.RelationshipClass:\n break;\n default:\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new ClassId(this.schemaItemType, classKey));\n }\n\n return ecClass;\n }\n\n protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\n assert(container.customAttributes !== undefined);\n const map = container.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\n const derivedClasses: Array<MutableClass> = [];\n const schemaItems = this.schemaEditor.schemaContext.getSchemaItems();\n let { value, done } = schemaItems.next();\n while (!done) {\n if (await value.is(mutableClass)) {\n if (!mutableClass.key.matches(value.key)) {\n derivedClasses.push(value);\n }\n }\n ({ value, done } = schemaItems.next());\n }\n\n return derivedClasses;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module Editing
3
3
  */
4
- import { CustomAttribute, Schema, SchemaContext, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
4
+ import { CustomAttribute, Schema, SchemaContext, SchemaKey } from "@itwin/ecschema-metadata";
5
5
  import { MutableSchema } from "./Mutable/MutableSchema";
6
6
  import { Constants } from "./Constants";
7
7
  import { CustomAttributes } from "./CustomAttributes";
@@ -17,29 +17,6 @@ import { RelationshipClasses } from "./RelationshipClasses";
17
17
  import { Structs } from "./Structs";
18
18
  import { Units } from "./Units";
19
19
  import { UnitSystems } from "./UnitSystems";
20
- import { SchemaItems } from "./SchemaItems";
21
- /**
22
- * @alpha
23
- */
24
- export interface SchemaEditResults {
25
- schemaKey?: SchemaKey;
26
- errorMessage?: string;
27
- }
28
- /**
29
- * @alpha
30
- */
31
- export interface SchemaItemEditResults {
32
- itemKey?: SchemaItemKey;
33
- errorMessage?: string;
34
- }
35
- /**
36
- * @alpha
37
- */
38
- export interface PropertyEditResults {
39
- itemKey?: SchemaItemKey;
40
- propertyName?: string;
41
- errorMessage?: string;
42
- }
43
20
  /**
44
21
  * A class that allows you to edit and create schemas, classes, and items from the SchemaContext level.
45
22
  * @alpha
@@ -61,7 +38,6 @@ export declare class SchemaContextEditor {
61
38
  readonly propertyCategories: PropertyCategories;
62
39
  readonly invertedUnits: InvertedUnits;
63
40
  /** @internal */
64
- readonly schemaItems: SchemaItems;
65
41
  /**
66
42
  * Creates a new SchemaContextEditor instance.
67
43
  * @param schemaContext The SchemaContext the Editor will use to edit in.
@@ -82,35 +58,38 @@ export declare class SchemaContextEditor {
82
58
  * @param readVersion The read version number of the schema.
83
59
  * @param writeVersion The write version number of the schema.
84
60
  * @param minorVersion The minor version number of the schema.
85
- * @returns Resolves to a SchemaEditResults object.
61
+ * @returns Resolves to the SchemaKey of created schema.
86
62
  */
87
- createSchema(name: string, alias: string, readVersion: number, writeVersion: number, minorVersion: number): Promise<SchemaEditResults>;
63
+ createSchema(name: string, alias: string, readVersion: number, writeVersion: number, minorVersion: number): Promise<SchemaKey>;
88
64
  /**
89
65
  * Adds a referenced schema to the schema identified by the given SchemaKey.
90
66
  * @param schemaKey The SchemaKey identifying the schema.
91
67
  * @param refSchema The referenced schema to add.
92
68
  */
93
- addSchemaReference(schemaKey: SchemaKey, refSchema: Schema): Promise<SchemaEditResults>;
69
+ addSchemaReference(schemaKey: SchemaKey, refSchema: Schema): Promise<void>;
94
70
  /**
95
71
  * Adds a CustomAttribute instance to the schema identified by the given SchemaKey
96
72
  * @param schemaKey The SchemaKey identifying the schema.
97
73
  * @param customAttribute The CustomAttribute instance to add.
98
74
  */
99
- addCustomAttribute(schemaKey: SchemaKey, customAttribute: CustomAttribute): Promise<SchemaEditResults>;
75
+ addCustomAttribute(schemaKey: SchemaKey, customAttribute: CustomAttribute): Promise<void>;
100
76
  /**
101
77
  * Sets the schema version.
102
78
  * @param schemaKey The SchemaKey identifying the schema.
103
79
  * @param readVersion The read version of the schema. If not specified, the existing read version will be maintained.
104
80
  * @param writeVersion The write version of the schema. If not specified, the existing write version will be maintained.
105
81
  * @param minorVersion The minor version of the schema. If not specified, the existing minor version will be maintained.
82
+ * @returns Resolves to the new SchemaKey containing version updates.
106
83
  */
107
- setVersion(schemaKey: SchemaKey, readVersion?: number, writeVersion?: number, minorVersion?: number): Promise<SchemaEditResults>;
84
+ setVersion(schemaKey: SchemaKey, readVersion?: number, writeVersion?: number, minorVersion?: number): Promise<SchemaKey>;
108
85
  /**
109
86
  * Increments the minor version of a schema.
110
87
  * @param schemaKey The SchemaKey identifying the schema.
88
+ * @returns Resolves to the new SchemaKey containing version updates.
111
89
  */
112
- incrementMinorVersion(schemaKey: SchemaKey): Promise<SchemaEditResults>;
90
+ incrementMinorVersion(schemaKey: SchemaKey): Promise<SchemaKey>;
113
91
  private removeReference;
114
92
  private removeCustomAttribute;
93
+ private lookupSchema;
115
94
  }
116
95
  //# sourceMappingURL=Editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../../src/Editing/Editor.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AAC7H,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,U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,aAAa,CAAgC;IAE5D,MAAM,IAAI,OAAO,CAAC,aAAa,CAAC;IAI7C;;;MAGE;IACW,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAQhF;;;;;;;;OAQG;IACU,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAM3I;;;;OAIG;IACU,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBvF;;;;OAIG;IACU,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBtG;;;;;;;OAOG;IACU,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAWrI;;;;OAIG;IACU,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAW5E,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,qBAAqB;YAMf,YAAY;CAO3B"}
@@ -25,12 +25,14 @@ const RelationshipClasses_1 = require("./RelationshipClasses");
25
25
  const Structs_1 = require("./Structs");
26
26
  const Units_1 = require("./Units");
27
27
  const UnitSystems_1 = require("./UnitSystems");
28
- const SchemaItems_1 = require("./SchemaItems");
28
+ const Exception_1 = require("./Exception");
29
29
  /**
30
30
  * A class that allows you to edit and create schemas, classes, and items from the SchemaContext level.
31
31
  * @alpha
32
32
  */
33
33
  class SchemaContextEditor {
34
+ /** @internal */
35
+ // public readonly schemaItems = new SchemaItems(this);
34
36
  /**
35
37
  * Creates a new SchemaContextEditor instance.
36
38
  * @param schemaContext The SchemaContext the Editor will use to edit in.
@@ -50,8 +52,6 @@ class SchemaContextEditor {
50
52
  this.unitSystems = new UnitSystems_1.UnitSystems(this);
51
53
  this.propertyCategories = new PropertyCategories_1.PropertyCategories(this);
52
54
  this.invertedUnits = new InvertedUnits_1.InvertedUnits(this);
53
- /** @internal */
54
- this.schemaItems = new SchemaItems_1.SchemaItems(this);
55
55
  // TODO: Make copy
56
56
  this._schemaContext = schemaContext;
57
57
  }
@@ -65,7 +65,7 @@ class SchemaContextEditor {
65
65
  * @param schemaKey The SchemaKey identifying the schema.
66
66
  */
67
67
  async getSchema(schemaKey) {
68
- const schema = (await this.schemaContext.getCachedSchema(schemaKey, ecschema_metadata_1.SchemaMatchType.Latest));
68
+ const schema = await this.schemaContext.getCachedSchema(schemaKey, ecschema_metadata_1.SchemaMatchType.Latest);
69
69
  if (schema === undefined)
70
70
  return undefined;
71
71
  return schema;
@@ -77,12 +77,12 @@ class SchemaContextEditor {
77
77
  * @param readVersion The read version number of the schema.
78
78
  * @param writeVersion The write version number of the schema.
79
79
  * @param minorVersion The minor version number of the schema.
80
- * @returns Resolves to a SchemaEditResults object.
80
+ * @returns Resolves to the SchemaKey of created schema.
81
81
  */
82
82
  async createSchema(name, alias, readVersion, writeVersion, minorVersion) {
83
83
  const newSchema = new ecschema_metadata_1.Schema(this._schemaContext, name, alias, readVersion, writeVersion, minorVersion);
84
84
  await this._schemaContext.addSchema(newSchema);
85
- return { schemaKey: newSchema.schemaKey };
85
+ return newSchema.schemaKey;
86
86
  }
87
87
  /**
88
88
  * Adds a referenced schema to the schema identified by the given SchemaKey.
@@ -90,23 +90,24 @@ class SchemaContextEditor {
90
90
  * @param refSchema The referenced schema to add.
91
91
  */
92
92
  async addSchemaReference(schemaKey, refSchema) {
93
- const schema = (await this.schemaContext.getCachedSchema(schemaKey, ecschema_metadata_1.SchemaMatchType.Exact));
94
- if (schema === undefined)
95
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
96
- await schema.addReference(refSchema);
97
- const diagnostics = Rules.validateSchemaReferences(schema);
98
- const result = { errorMessage: "" };
99
- for await (const diagnostic of diagnostics) {
100
- result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\r\n`;
101
- }
102
- if (result.errorMessage) {
103
- this.removeReference(schema, refSchema);
104
- return result;
93
+ try {
94
+ const schema = await this.lookupSchema(schemaKey, ecschema_metadata_1.SchemaMatchType.Exact);
95
+ await schema.addReference(refSchema);
96
+ const diagnostics = [];
97
+ for await (const diagnostic of Rules.validateSchemaReferences(schema)) {
98
+ diagnostics.push(diagnostic);
99
+ }
100
+ if (diagnostics.length > 0) {
101
+ this.removeReference(schema, refSchema);
102
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.RuleViolation, new Exception_1.SchemaId(schemaKey), undefined, diagnostics);
103
+ }
104
+ if (!await this.schemaContext.getCachedSchema(refSchema.schemaKey)) {
105
+ await this.schemaContext.addSchema(refSchema);
106
+ }
105
107
  }
106
- if (!await this.schemaContext.getCachedSchema(refSchema.schemaKey)) {
107
- await this.schemaContext.addSchema(refSchema);
108
+ catch (e) {
109
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.AddSchemaReference, new Exception_1.SchemaId(schemaKey), e);
108
110
  }
109
- return {};
110
111
  }
111
112
  /**
112
113
  * Adds a CustomAttribute instance to the schema identified by the given SchemaKey
@@ -114,20 +115,21 @@ class SchemaContextEditor {
114
115
  * @param customAttribute The CustomAttribute instance to add.
115
116
  */
116
117
  async addCustomAttribute(schemaKey, customAttribute) {
117
- const schema = (await this.schemaContext.getCachedSchema(schemaKey, ecschema_metadata_1.SchemaMatchType.Latest));
118
- if (schema === undefined)
119
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
120
- schema.addCustomAttribute(customAttribute);
121
- const diagnostics = Rules.validateCustomAttributeInstance(schema, customAttribute);
122
- const result = { errorMessage: "" };
123
- for await (const diagnostic of diagnostics) {
124
- result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\r\n`;
118
+ try {
119
+ const schema = await this.lookupSchema(schemaKey);
120
+ schema.addCustomAttribute(customAttribute);
121
+ const diagnostics = [];
122
+ for await (const diagnostic of Rules.validateCustomAttributeInstance(schema, customAttribute)) {
123
+ diagnostics.push(diagnostic);
124
+ }
125
+ if (diagnostics.length > 0) {
126
+ this.removeCustomAttribute(schema, customAttribute);
127
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.RuleViolation, new Exception_1.CustomAttributeId(customAttribute.className, schema), undefined, diagnostics);
128
+ }
125
129
  }
126
- if (result.errorMessage) {
127
- this.removeCustomAttribute(schema, customAttribute);
128
- return result;
130
+ catch (e) {
131
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.AddCustomAttributeToClass, new Exception_1.SchemaId(schemaKey), e);
129
132
  }
130
- return {};
131
133
  }
132
134
  /**
133
135
  * Sets the schema version.
@@ -135,24 +137,32 @@ class SchemaContextEditor {
135
137
  * @param readVersion The read version of the schema. If not specified, the existing read version will be maintained.
136
138
  * @param writeVersion The write version of the schema. If not specified, the existing write version will be maintained.
137
139
  * @param minorVersion The minor version of the schema. If not specified, the existing minor version will be maintained.
140
+ * @returns Resolves to the new SchemaKey containing version updates.
138
141
  */
139
142
  async setVersion(schemaKey, readVersion, writeVersion, minorVersion) {
140
- const schema = (await this.schemaContext.getCachedSchema(schemaKey, ecschema_metadata_1.SchemaMatchType.Latest));
141
- if (schema === undefined)
142
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
143
- schema.setVersion(readVersion || schema.readVersion, writeVersion || schema.writeVersion, minorVersion || schema.minorVersion);
144
- return {};
143
+ try {
144
+ const schema = await this.lookupSchema(schemaKey);
145
+ schema.setVersion(readVersion || schema.readVersion, writeVersion || schema.writeVersion, minorVersion || schema.minorVersion);
146
+ return schema.schemaKey;
147
+ }
148
+ catch (e) {
149
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetSchemaVersion, new Exception_1.SchemaId(schemaKey), e);
150
+ }
145
151
  }
146
152
  /**
147
153
  * Increments the minor version of a schema.
148
154
  * @param schemaKey The SchemaKey identifying the schema.
155
+ * @returns Resolves to the new SchemaKey containing version updates.
149
156
  */
150
157
  async incrementMinorVersion(schemaKey) {
151
- const schema = (await this.schemaContext.getCachedSchema(schemaKey, ecschema_metadata_1.SchemaMatchType.Latest));
152
- if (schema === undefined)
153
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
154
- schema.setVersion(schema.readVersion, schema.writeVersion, schema.minorVersion + 1);
155
- return {};
158
+ try {
159
+ const schema = await this.lookupSchema(schemaKey);
160
+ schema.setVersion(schema.readVersion, schema.writeVersion, schema.minorVersion + 1);
161
+ return schema.schemaKey;
162
+ }
163
+ catch (e) {
164
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.IncrementSchemaMinorVersion, new Exception_1.SchemaId(schemaKey), e);
165
+ }
156
166
  }
157
167
  removeReference(schema, refSchema) {
158
168
  const index = schema.references.indexOf(refSchema);
@@ -165,6 +175,12 @@ class SchemaContextEditor {
165
175
  const map = schema.customAttributes;
166
176
  map.delete(customAttribute.className);
167
177
  }
178
+ async lookupSchema(schemaKey, matchType = ecschema_metadata_1.SchemaMatchType.Latest) {
179
+ const schema = await this.schemaContext.getCachedSchema(schemaKey, matchType);
180
+ if (schema === undefined)
181
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaNotFound, new Exception_1.SchemaId(schemaKey));
182
+ return schema;
183
+ }
168
184
  }
169
185
  exports.SchemaContextEditor = SchemaContextEditor;
170
186
  //# sourceMappingURL=Editor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/Editing/Editor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+CAA+C;AAC/C,gEAA6H;AAE7H,sDAA6C;AAC7C,2CAAw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,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAEO,qBAAqB,CAAC,MAAc,EAAE,eAAgC;QAC5E,IAAA,qBAAM,EAAC,MAAM,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC;QAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgD,CAAC;QACpE,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AAhKD,kDAgKC","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 Editing\r\n */\r\n\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { CustomAttribute, Schema, SchemaContext, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Constants } from \"./Constants\";\r\nimport { CustomAttributes } from \"./CustomAttributes\";\r\nimport { Entities } from \"./Entities\";\r\nimport { Enumerations } from \"./Enumerations\";\r\nimport { Formats } from \"./Formats\";\r\nimport { InvertedUnits } from \"./InvertedUnits\";\r\nimport { KindOfQuantities } from \"./KindOfQuantities\";\r\nimport { Mixins } from \"./Mixins\";\r\nimport { Phenomena } from \"./Phenomena\";\r\nimport { PropertyCategories } from \"./PropertyCategories\";\r\nimport { RelationshipClasses } from \"./RelationshipClasses\";\r\nimport { Structs } from \"./Structs\";\r\nimport { Units } from \"./Units\";\r\nimport { UnitSystems } from \"./UnitSystems\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\n// We can either add validation in Editor, or in the protected methods of Schema.\r\n// TODO: Add an error code so we can do something programmatic with the error.\r\n/**\r\n * @alpha\r\n */\r\nexport interface SchemaEditResults {\r\n schemaKey?: SchemaKey;\r\n errorMessage?: string;\r\n}\r\n\r\n/**\r\n * @alpha\r\n */\r\nexport interface SchemaItemEditResults {\r\n itemKey?: SchemaItemKey;\r\n errorMessage?: string;\r\n}\r\n\r\n/**\r\n * @alpha\r\n */\r\nexport interface PropertyEditResults {\r\n itemKey?: SchemaItemKey;\r\n propertyName?: string;\r\n errorMessage?: string;\r\n}\r\n\r\n/**\r\n * A class that allows you to edit and create schemas, classes, and items from the SchemaContext level.\r\n * @alpha\r\n */\r\nexport class SchemaContextEditor {\r\n private _schemaContext: SchemaContext;\r\n public readonly entities = new Entities(this);\r\n public readonly mixins = new Mixins(this);\r\n public readonly structs = new Structs(this);\r\n public readonly customAttributes = new CustomAttributes(this);\r\n public readonly relationships = new RelationshipClasses(this);\r\n public readonly constants = new Constants(this);\r\n public readonly enumerations = new Enumerations(this);\r\n public readonly formats = new Formats(this);\r\n public readonly kindOfQuantities = new KindOfQuantities(this);\r\n public readonly units = new Units(this);\r\n public readonly phenomenons = new Phenomena(this);\r\n public readonly unitSystems = new UnitSystems(this);\r\n public readonly propertyCategories = new PropertyCategories(this);\r\n public readonly invertedUnits = new InvertedUnits(this);\r\n\r\n /** @internal */\r\n public readonly schemaItems = new SchemaItems(this);\r\n\r\n /**\r\n * Creates a new SchemaContextEditor instance.\r\n * @param schemaContext The SchemaContext the Editor will use to edit in.\r\n */\r\n constructor(schemaContext: SchemaContext) {\r\n // TODO: Make copy\r\n this._schemaContext = schemaContext;\r\n }\r\n\r\n /** Allows you to get schema classes and items through regular SchemaContext methods. */\r\n public get schemaContext(): SchemaContext { return this._schemaContext; }\r\n\r\n public async finish(): Promise<SchemaContext> {\r\n return this._schemaContext;\r\n }\r\n\r\n /**\r\n * Helper method for retrieving a schema, previously added, from the SchemaContext.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n */\r\n public async getSchema(schemaKey: SchemaKey): Promise<MutableSchema | undefined> {\r\n const schema = (await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, SchemaMatchType.Latest));\r\n if (schema === undefined)\r\n return undefined;\r\n\r\n return schema;\r\n }\r\n /**\r\n * Creates a Schema with the given properties and adds it to the current schema context.\r\n * @param name The name given to the new schema.\r\n * @param alias The alias of the new schema.\r\n * @param readVersion The read version number of the schema.\r\n * @param writeVersion The write version number of the schema.\r\n * @param minorVersion The minor version number of the schema.\r\n * @returns Resolves to a SchemaEditResults object.\r\n */\r\n public async createSchema(name: string, alias: string, readVersion: number, writeVersion: number, minorVersion: number): Promise<SchemaEditResults> {\r\n const newSchema = new Schema(this._schemaContext, name, alias, readVersion, writeVersion, minorVersion);\r\n await this._schemaContext.addSchema(newSchema);\r\n return { schemaKey: newSchema.schemaKey };\r\n }\r\n\r\n /**\r\n * Adds a referenced schema to the schema identified by the given SchemaKey.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n * @param refSchema The referenced schema to add.\r\n */\r\n public async addSchemaReference(schemaKey: SchemaKey, refSchema: Schema): Promise<SchemaEditResults> {\r\n const schema = (await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, SchemaMatchType.Exact));\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n await schema.addReference(refSchema);\r\n const diagnostics = Rules.validateSchemaReferences(schema);\r\n\r\n const result: SchemaEditResults = { errorMessage: \"\" };\r\n for await (const diagnostic of diagnostics) {\r\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (result.errorMessage) {\r\n this.removeReference(schema, refSchema);\r\n return result;\r\n }\r\n\r\n if (!await this.schemaContext.getCachedSchema(refSchema.schemaKey)) {\r\n await this.schemaContext.addSchema(refSchema);\r\n }\r\n\r\n return {};\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the schema identified by the given SchemaKey\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttribute(schemaKey: SchemaKey, customAttribute: CustomAttribute): Promise<SchemaEditResults> {\r\n const schema = (await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, SchemaMatchType.Latest));\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n schema.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(schema, customAttribute);\r\n\r\n const result: SchemaEditResults = { errorMessage: \"\" };\r\n for await (const diagnostic of diagnostics) {\r\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (result.errorMessage) {\r\n this.removeCustomAttribute(schema, customAttribute);\r\n return result;\r\n }\r\n\r\n return {};\r\n }\r\n\r\n /**\r\n * Sets the schema version.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n * @param readVersion The read version of the schema. If not specified, the existing read version will be maintained.\r\n * @param writeVersion The write version of the schema. If not specified, the existing write version will be maintained.\r\n * @param minorVersion The minor version of the schema. If not specified, the existing minor version will be maintained.\r\n */\r\n public async setVersion(schemaKey: SchemaKey, readVersion?: number, writeVersion?: number, minorVersion?: number): Promise<SchemaEditResults> {\r\n const schema = (await this.schemaContext.getCachedSchema(schemaKey, SchemaMatchType.Latest));\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n schema.setVersion(readVersion || schema.readVersion, writeVersion || schema.writeVersion, minorVersion || schema.minorVersion);\r\n return {};\r\n }\r\n\r\n /**\r\n * Increments the minor version of a schema.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n */\r\n public async incrementMinorVersion(schemaKey: SchemaKey): Promise<SchemaEditResults> {\r\n const schema = (await this.schemaContext.getCachedSchema(schemaKey, SchemaMatchType.Latest));\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n schema.setVersion(schema.readVersion, schema.writeVersion, schema.minorVersion + 1);\r\n return {};\r\n }\r\n\r\n private removeReference(schema: Schema, refSchema: Schema) {\r\n const index: number = schema.references.indexOf(refSchema);\r\n if (index !== -1) {\r\n schema.references.splice(index, 1);\r\n }\r\n }\r\n\r\n private removeCustomAttribute(schema: Schema, customAttribute: CustomAttribute) {\r\n assert(schema.customAttributes !== undefined);\r\n const map = schema.customAttributes as Map<string, CustomAttribute>;\r\n map.delete(customAttribute.className);\r\n }\r\n}\r\n\r\n"]}
1
+ {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/Editing/Editor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+CAA+C;AAC/C,gEAA8G;AAE9G,sDAA6C;AAC7C,2CAAwC;AACxC,yDAAsD;AACtD,yCAAsC;AACtC,iDAA8C;AAC9C,uCAAoC;AACpC,mDAAgD;AAChD,yDAAsD;AACtD,qCAAkC;AAClC,2CAAwC;AACxC,6DAA0D;AAC1D,+DAA4D;AAC5D,uCAAoC;AACpC,mCAAgC;AAChC,+CAA4C;AAC5C,2CAA+F;AAG/F;;;GAGG;AACH,MAAa,mBAAmB;IAiB9B,gBAAgB;IAChB,uDAAuD;IAEvD;;;OAGG;IACH,YAAY,aAA4B;QAtBxB,aAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;QAC9B,WAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,CAAC;QAC1B,YAAO,GAAG,IAAI,iBAAO,CAAC,IAAI,CAAC,CAAC;QAC5B,qBAAgB,GAAG,IAAI,mCAAgB,CAAC,IAAI,CAAC,CAAC;QAC9C,kBAAa,GAAG,IAAI,yCAAmB,CAAC,IAAI,CAAC,CAAC;QAC9C,cAAS,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,CAAC;QAChC,iBA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IAAI,8BAAkB,CAAC,2BAAe,CAAC,cAAc,EAAE,IAAI,oBAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QAExF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA1KD,kDA0KC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport * as Rules from \"../Validation/ECRules\";\nimport { CustomAttribute, Schema, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { Constants } from \"./Constants\";\nimport { CustomAttributes } from \"./CustomAttributes\";\nimport { Entities } from \"./Entities\";\nimport { Enumerations } from \"./Enumerations\";\nimport { Formats } from \"./Formats\";\nimport { InvertedUnits } from \"./InvertedUnits\";\nimport { KindOfQuantities } from \"./KindOfQuantities\";\nimport { Mixins } from \"./Mixins\";\nimport { Phenomena } from \"./Phenomena\";\nimport { PropertyCategories } from \"./PropertyCategories\";\nimport { RelationshipClasses } from \"./RelationshipClasses\";\nimport { Structs } from \"./Structs\";\nimport { Units } from \"./Units\";\nimport { UnitSystems } from \"./UnitSystems\";\nimport { CustomAttributeId, ECEditingStatus, SchemaEditingError, SchemaId } from \"./Exception\";\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\n\n/**\n * A class that allows you to edit and create schemas, classes, and items from the SchemaContext level.\n * @alpha\n */\nexport class SchemaContextEditor {\n private _schemaContext: SchemaContext;\n public readonly entities = new Entities(this);\n public readonly mixins = new Mixins(this);\n public readonly structs = new Structs(this);\n public readonly customAttributes = new CustomAttributes(this);\n public readonly relationships = new RelationshipClasses(this);\n public readonly constants = new Constants(this);\n public readonly enumerations = new Enumerations(this);\n public readonly formats = new Formats(this);\n public readonly kindOfQuantities = new KindOfQuantities(this);\n public readonly units = new Units(this);\n public readonly phenomenons = new Phenomena(this);\n public readonly unitSystems = new UnitSystems(this);\n public readonly propertyCategories = new PropertyCategories(this);\n public readonly invertedUnits = new InvertedUnits(this);\n\n /** @internal */\n // public readonly schemaItems = new SchemaItems(this);\n\n /**\n * Creates a new SchemaContextEditor instance.\n * @param schemaContext The SchemaContext the Editor will use to edit in.\n */\n constructor(schemaContext: SchemaContext) {\n // TODO: Make copy\n this._schemaContext = schemaContext;\n }\n\n /** Allows you to get schema classes and items through regular SchemaContext methods. */\n public get schemaContext(): SchemaContext { return this._schemaContext; }\n\n public async finish(): Promise<SchemaContext> {\n return this._schemaContext;\n }\n\n /**\n * Helper method for retrieving a schema, previously added, from the SchemaContext.\n * @param schemaKey The SchemaKey identifying the schema.\n */\n public async getSchema(schemaKey: SchemaKey): Promise<MutableSchema | undefined> {\n const schema = await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, SchemaMatchType.Latest);\n if (schema === undefined)\n return undefined;\n\n return schema;\n }\n\n /**\n * Creates a Schema with the given properties and adds it to the current schema context.\n * @param name The name given to the new schema.\n * @param alias The alias of the new schema.\n * @param readVersion The read version number of the schema.\n * @param writeVersion The write version number of the schema.\n * @param minorVersion The minor version number of the schema.\n * @returns Resolves to the SchemaKey of created schema.\n */\n public async createSchema(name: string, alias: string, readVersion: number, writeVersion: number, minorVersion: number): Promise<SchemaKey> {\n const newSchema = new Schema(this._schemaContext, name, alias, readVersion, writeVersion, minorVersion);\n await this._schemaContext.addSchema(newSchema);\n return newSchema.schemaKey;\n }\n\n /**\n * Adds a referenced schema to the schema identified by the given SchemaKey.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param refSchema The referenced schema to add.\n */\n public async addSchemaReference(schemaKey: SchemaKey, refSchema: Schema): Promise<void> {\n try {\n const schema = await this.lookupSchema(schemaKey, SchemaMatchType.Exact);\n await schema.addReference(refSchema);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of Rules.validateSchemaReferences(schema)) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeReference(schema, refSchema);\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new SchemaId(schemaKey), undefined, diagnostics);\n }\n\n if (!await this.schemaContext.getCachedSchema(refSchema.schemaKey)) {\n await this.schemaContext.addSchema(refSchema);\n }\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddSchemaReference, new SchemaId(schemaKey), e);\n }\n }\n\n /**\n * Adds a CustomAttribute instance to the schema identified by the given SchemaKey\n * @param schemaKey The SchemaKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(schemaKey: SchemaKey, customAttribute: CustomAttribute): Promise<void> {\n try {\n const schema = await this.lookupSchema(schemaKey);\n schema.addCustomAttribute(customAttribute);\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of Rules.validateCustomAttributeInstance(schema, customAttribute)) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n this.removeCustomAttribute(schema, customAttribute);\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, schema), undefined, diagnostics);\n }\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToClass, new SchemaId(schemaKey), e);\n }\n }\n\n /**\n * Sets the schema version.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param readVersion The read version of the schema. If not specified, the existing read version will be maintained.\n * @param writeVersion The write version of the schema. If not specified, the existing write version will be maintained.\n * @param minorVersion The minor version of the schema. If not specified, the existing minor version will be maintained.\n * @returns Resolves to the new SchemaKey containing version updates.\n */\n public async setVersion(schemaKey: SchemaKey, readVersion?: number, writeVersion?: number, minorVersion?: number): Promise<SchemaKey> {\n try {\n const schema = await this.lookupSchema(schemaKey);\n schema.setVersion(readVersion || schema.readVersion, writeVersion || schema.writeVersion, minorVersion || schema.minorVersion);\n\n return schema.schemaKey;\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetSchemaVersion, new SchemaId(schemaKey), e);\n }\n }\n\n /**\n * Increments the minor version of a schema.\n * @param schemaKey The SchemaKey identifying the schema.\n * @returns Resolves to the new SchemaKey containing version updates.\n */\n public async incrementMinorVersion(schemaKey: SchemaKey): Promise<SchemaKey> {\n try {\n const schema = await this.lookupSchema(schemaKey);\n schema.setVersion(schema.readVersion, schema.writeVersion, schema.minorVersion + 1);\n\n return schema.schemaKey;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.IncrementSchemaMinorVersion, new SchemaId(schemaKey), e);\n }\n }\n\n private removeReference(schema: Schema, refSchema: Schema) {\n const index: number = schema.references.indexOf(refSchema);\n if (index !== -1) {\n schema.references.splice(index, 1);\n }\n }\n\n private removeCustomAttribute(schema: Schema, customAttribute: CustomAttribute) {\n assert(schema.customAttributes !== undefined);\n const map = schema.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n\n private async lookupSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<MutableSchema> {\n const schema = await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, matchType);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema;\n }\n}\n\n"]}
@@ -2,7 +2,7 @@
2
2
  * @module Editing
3
3
  */
4
4
  import { ECClassModifier, EntityClassProps, Mixin, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
5
- import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
5
+ import { SchemaContextEditor } from "./Editor";
6
6
  import { ECClasses } from "./ECClasses";
7
7
  import { NavigationProperties } from "./Properties";
8
8
  /**
@@ -15,23 +15,23 @@ export declare class Entities extends ECClasses {
15
15
  * Allows access for editing of NavigationProperty attributes.
16
16
  */
17
17
  readonly navigationProperties: NavigationProperties;
18
- createElement(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemEditResults>;
19
- createElementUniqueAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemEditResults>;
20
- createElementMultiAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemEditResults>;
21
- create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, displayLabel?: string, baseClassKey?: SchemaItemKey, mixins?: Mixin[]): Promise<SchemaItemEditResults>;
18
+ createElement(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey>;
19
+ createElementUniqueAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey>;
20
+ createElementMultiAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey>;
21
+ create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, displayLabel?: string, baseClassKey?: SchemaItemKey, mixins?: Mixin[]): Promise<SchemaItemKey>;
22
22
  /**
23
23
  * Creates an EntityClass through an EntityClassProps.
24
24
  * @param schemaKey a SchemaKey of the Schema that will house the new object.
25
25
  * @param entityProps a json object that will be used to populate the new EntityClass. Needs a name value passed in.
26
26
  */
27
- createFromProps(schemaKey: SchemaKey, entityProps: EntityClassProps): Promise<SchemaItemEditResults>;
28
- addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<SchemaItemEditResults>;
29
- createNavigationProperty(entityKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults>;
27
+ createFromProps(schemaKey: SchemaKey, entityProps: EntityClassProps): Promise<SchemaItemKey>;
28
+ addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void>;
29
+ createNavigationProperty(entityKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<void>;
30
30
  /**
31
31
  * Creates a Navigation Property through a NavigationPropertyProps.
32
32
  * @param classKey a SchemaItemKey of the Entity Class that will house the new property.
33
33
  * @param navigationProps a json object that will be used to populate the new Navigation Property.
34
34
  */
35
- createNavigationPropertyFromProps(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<PropertyEditResults>;
35
+ createNavigationPropertyFromProps(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<void>;
36
36
  }
37
37
  //# sourceMappingURL=Entities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Entities.d.ts","sourceRoot":"","sources":["../../../src/Editing/Entities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACoB,eAAe,EAAgD,gBAAgB,EACxG,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,aAAa,EAAkB,SAAS,EAAE,iBAAiB,EAC/G,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD;;;GAGG;AACH,qBAAa,QAAS,SAAQ,SAAS;gBAClB,YAAY,EAAE,mBAAmB;IAIpD;;OAEG;IACH,SAAgB,oBAAoB,uBAAqE;IAE5F,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,G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