@itwin/ecschema-editing 5.2.0-dev.25 → 5.2.0-dev.28

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 (192) hide show
  1. package/lib/cjs/Differencing/Errors.js.map +1 -1
  2. package/lib/cjs/Differencing/SchemaConflicts.d.ts +2 -1
  3. package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
  4. package/lib/cjs/Differencing/SchemaConflicts.js +1 -0
  5. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  6. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  7. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  8. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
  9. package/lib/cjs/Differencing/SchemaDifferenceValidator.js +32 -4
  10. package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
  11. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
  12. package/lib/cjs/Differencing/Utils.js.map +1 -1
  13. package/lib/cjs/Editing/Constants.js.map +1 -1
  14. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  15. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  16. package/lib/cjs/Editing/Editor.js.map +1 -1
  17. package/lib/cjs/Editing/Entities.js.map +1 -1
  18. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  19. package/lib/cjs/Editing/Exception.js.map +1 -1
  20. package/lib/cjs/Editing/Formats.js.map +1 -1
  21. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  22. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  23. package/lib/cjs/Editing/Mixins.js.map +1 -1
  24. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  25. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  26. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  27. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  28. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  29. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  30. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  31. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  32. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  33. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  34. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  35. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  36. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  37. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  38. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  39. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  40. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  41. package/lib/cjs/Editing/Mutable/MutableSchemaItem.js.map +1 -1
  42. package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -1
  43. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  44. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  45. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  46. package/lib/cjs/Editing/Properties.js.map +1 -1
  47. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  48. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  49. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  50. package/lib/cjs/Editing/Structs.js.map +1 -1
  51. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  52. package/lib/cjs/Editing/Units.js.map +1 -1
  53. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  54. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  55. package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -1
  56. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  57. package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -1
  58. package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
  59. package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
  60. package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -1
  61. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  62. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  63. package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
  64. package/lib/cjs/Merging/FormatMerger.js.map +1 -1
  65. package/lib/cjs/Merging/InvertedUnitMerger.js.map +1 -1
  66. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  67. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  68. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  69. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
  70. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  71. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  72. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  73. package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
  74. package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
  75. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  76. package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
  77. package/lib/cjs/Merging/UnitMerger.js.map +1 -1
  78. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
  79. package/lib/cjs/Merging/Utils.js.map +1 -1
  80. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  81. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  82. package/lib/cjs/Validation/ECRules.js.map +1 -1
  83. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  84. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  85. package/lib/cjs/Validation/Rules.js.map +1 -1
  86. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  87. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  88. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  89. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  90. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  91. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  92. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  93. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  94. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  95. package/lib/cjs/ecschema-editing.js.map +1 -1
  96. package/lib/esm/Differencing/Errors.js.map +1 -1
  97. package/lib/esm/Differencing/SchemaConflicts.d.ts +2 -1
  98. package/lib/esm/Differencing/SchemaConflicts.d.ts.map +1 -1
  99. package/lib/esm/Differencing/SchemaConflicts.js +1 -0
  100. package/lib/esm/Differencing/SchemaConflicts.js.map +1 -1
  101. package/lib/esm/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  102. package/lib/esm/Differencing/SchemaDifference.js.map +1 -1
  103. package/lib/esm/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
  104. package/lib/esm/Differencing/SchemaDifferenceValidator.js +32 -4
  105. package/lib/esm/Differencing/SchemaDifferenceValidator.js.map +1 -1
  106. package/lib/esm/Differencing/SchemaDifferenceVisitor.js.map +1 -1
  107. package/lib/esm/Differencing/Utils.js.map +1 -1
  108. package/lib/esm/Editing/Constants.js.map +1 -1
  109. package/lib/esm/Editing/CustomAttributes.js.map +1 -1
  110. package/lib/esm/Editing/ECClasses.js.map +1 -1
  111. package/lib/esm/Editing/Editor.js.map +1 -1
  112. package/lib/esm/Editing/Entities.js.map +1 -1
  113. package/lib/esm/Editing/Enumerations.js.map +1 -1
  114. package/lib/esm/Editing/Exception.js.map +1 -1
  115. package/lib/esm/Editing/Formats.js.map +1 -1
  116. package/lib/esm/Editing/InvertedUnits.js.map +1 -1
  117. package/lib/esm/Editing/KindOfQuantities.js.map +1 -1
  118. package/lib/esm/Editing/Mixins.js.map +1 -1
  119. package/lib/esm/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  120. package/lib/esm/Editing/Mutable/MutableCAClass.js.map +1 -1
  121. package/lib/esm/Editing/Mutable/MutableClass.js.map +1 -1
  122. package/lib/esm/Editing/Mutable/MutableConstant.js.map +1 -1
  123. package/lib/esm/Editing/Mutable/MutableEntityClass.js.map +1 -1
  124. package/lib/esm/Editing/Mutable/MutableEnumeration.js.map +1 -1
  125. package/lib/esm/Editing/Mutable/MutableFormat.js.map +1 -1
  126. package/lib/esm/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  127. package/lib/esm/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  128. package/lib/esm/Editing/Mutable/MutableMixin.js.map +1 -1
  129. package/lib/esm/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  130. package/lib/esm/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  131. package/lib/esm/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  132. package/lib/esm/Editing/Mutable/MutableProperty.js.map +1 -1
  133. package/lib/esm/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  134. package/lib/esm/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  135. package/lib/esm/Editing/Mutable/MutableSchema.js.map +1 -1
  136. package/lib/esm/Editing/Mutable/MutableSchemaItem.js.map +1 -1
  137. package/lib/esm/Editing/Mutable/MutableStructProperty.js.map +1 -1
  138. package/lib/esm/Editing/Mutable/MutableUnit.js.map +1 -1
  139. package/lib/esm/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  140. package/lib/esm/Editing/Phenomena.js.map +1 -1
  141. package/lib/esm/Editing/Properties.js.map +1 -1
  142. package/lib/esm/Editing/PropertyCategories.js.map +1 -1
  143. package/lib/esm/Editing/RelationshipClasses.js.map +1 -1
  144. package/lib/esm/Editing/SchemaItems.js.map +1 -1
  145. package/lib/esm/Editing/Structs.js.map +1 -1
  146. package/lib/esm/Editing/UnitSystems.js.map +1 -1
  147. package/lib/esm/Editing/Units.js.map +1 -1
  148. package/lib/esm/Merging/ClassMerger.js.map +1 -1
  149. package/lib/esm/Merging/ConstantMerger.js.map +1 -1
  150. package/lib/esm/Merging/CustomAttributeClassMerger.js.map +1 -1
  151. package/lib/esm/Merging/CustomAttributeMerger.js.map +1 -1
  152. package/lib/esm/Merging/Edits/NameMapping.js.map +1 -1
  153. package/lib/esm/Merging/Edits/RenameEditHandler.js.map +1 -1
  154. package/lib/esm/Merging/Edits/SchemaEdits.js.map +1 -1
  155. package/lib/esm/Merging/Edits/SkipEditHandler.js.map +1 -1
  156. package/lib/esm/Merging/EntityClassMerger.js.map +1 -1
  157. package/lib/esm/Merging/EnumerationMerger.js.map +1 -1
  158. package/lib/esm/Merging/EnumeratorMerger.js.map +1 -1
  159. package/lib/esm/Merging/FormatMerger.js.map +1 -1
  160. package/lib/esm/Merging/InvertedUnitMerger.js.map +1 -1
  161. package/lib/esm/Merging/KindOfQuantityMerger.js.map +1 -1
  162. package/lib/esm/Merging/MixinMerger.js.map +1 -1
  163. package/lib/esm/Merging/PhenomenonMerger.js.map +1 -1
  164. package/lib/esm/Merging/PropertyCategoryMerger.js.map +1 -1
  165. package/lib/esm/Merging/PropertyMerger.js.map +1 -1
  166. package/lib/esm/Merging/RelationshipClassMerger.js.map +1 -1
  167. package/lib/esm/Merging/SchemaMerger.js.map +1 -1
  168. package/lib/esm/Merging/SchemaMergingVisitor.js.map +1 -1
  169. package/lib/esm/Merging/SchemaMergingWalker.js.map +1 -1
  170. package/lib/esm/Merging/SchemaReferenceMerger.js.map +1 -1
  171. package/lib/esm/Merging/StructClassMerger.js.map +1 -1
  172. package/lib/esm/Merging/UnitMerger.js.map +1 -1
  173. package/lib/esm/Merging/UnitSystemMerger.js.map +1 -1
  174. package/lib/esm/Merging/Utils.js.map +1 -1
  175. package/lib/esm/Validation/Diagnostic.js.map +1 -1
  176. package/lib/esm/Validation/DiagnosticReporter.js.map +1 -1
  177. package/lib/esm/Validation/ECRules.js.map +1 -1
  178. package/lib/esm/Validation/LoggingDiagnosticReporter.js.map +1 -1
  179. package/lib/esm/Validation/RuleSuppressionSet.js.map +1 -1
  180. package/lib/esm/Validation/Rules.js.map +1 -1
  181. package/lib/esm/Validation/SchemaChanges.js.map +1 -1
  182. package/lib/esm/Validation/SchemaCompareDiagnostics.js.map +1 -1
  183. package/lib/esm/Validation/SchemaCompareReporter.js.map +1 -1
  184. package/lib/esm/Validation/SchemaCompareResultDelegate.js.map +1 -1
  185. package/lib/esm/Validation/SchemaCompareVisitor.js.map +1 -1
  186. package/lib/esm/Validation/SchemaComparer.js.map +1 -1
  187. package/lib/esm/Validation/SchemaValidater.js.map +1 -1
  188. package/lib/esm/Validation/SchemaValidationVisitor.js.map +1 -1
  189. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  190. package/lib/esm/ecschema-editing.js.map +1 -1
  191. package/package.json +9 -9
  192. 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,OAAO,EAGL,uBAAuB,EACvB,OAAO,EACiB,aAAa,EAA6B,cAAc,GAEjF,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,YAAY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,CAAC;IACjB,CAAC;IAES,qBAAqB,CAAC,SAAwC,EAAE,eAAgC;QACxG,MAAM,CAAC,SAAS,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,SAAS,CAAC,gBAAgD,CAAC;QACvE,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AAED,SAAS,cAAc,CAAC,UAAsB;IAC5C,OAAO,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport {\r\n CustomAttribute,\r\n CustomAttributeContainerProps,\r\n DelayedPromiseWithProps,\r\n ECClass, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\r\n PrimitivePropertyProps, PrimitiveType, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, StructArrayPropertyProps,\r\n StructClass, StructPropertyProps,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { SchemaContextEditor } 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\nimport { ClassId, CustomAttributeId, ECEditingStatus, PropertyId, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\r\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\r\nimport { CreateSchemaItem, SchemaItems } from \"./SchemaItems\";\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 extends SchemaItems{\r\n\r\n protected constructor(schemaItemType: ECClassSchemaItems, schemaEditor: SchemaContextEditor) {\r\n super(schemaItemType, schemaEditor);\r\n this.schemaItemType = schemaItemType;\r\n this.properties = new Properties(this.schemaItemType, this.schemaEditor);\r\n this.arrayProperties = new ArrayProperties(this.schemaItemType, this.schemaEditor);\r\n this.primitiveProperties = new PrimitiveProperties(this.schemaItemType, this.schemaEditor);\r\n this.enumerationProperties = new EnumerationProperties(this.schemaItemType, this.schemaEditor);\r\n this.structProperties = new StructProperties(this.schemaItemType, this.schemaEditor);\r\n }\r\n\r\n protected override schemaItemType: ECClassSchemaItems;\r\n\r\n /**\r\n * Allows access for the editors itemType class instance.\r\n * It returns ECClass here, but editors for subclasses will override this to return the\r\n * appropriate subclass.\r\n */\r\n protected override get itemTypeClass(): typeof ECClass {\r\n return ECClass;\r\n }\r\n\r\n /**\r\n * Allows access for editing of base Property attributes.\r\n */\r\n public readonly properties: Properties;\r\n /**\r\n * Allows access for editing of ArrayProperty attributes.\r\n */\r\n public readonly arrayProperties: ArrayProperties;\r\n /**\r\n * Allows access for editing of PrimitiveProperty attributes.\r\n */\r\n public readonly primitiveProperties: PrimitiveProperties;\r\n /**\r\n * Allows access for editing of EnumerationProperty attributes.\r\n */\r\n public readonly enumerationProperties: EnumerationProperties;\r\n /**\r\n * Allows access for editing of StructProperty attributes.\r\n */\r\n public readonly structProperties: StructProperties;\r\n\r\n public async createClass<T extends ECClass>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, baseClassKey?: SchemaItemKey, ...args: any[]): Promise<T> {\r\n const newClass = await this.createSchemaItem(schemaKey, type, create, name, ...args);\r\n\r\n if (baseClassKey !== undefined) {\r\n if(!await this.schemaEditor.schemaContext.getSchema(baseClassKey.schemaKey)) {\r\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(baseClassKey.schemaKey));\r\n }\r\n\r\n const baseClassItem = await this.getSchemaItem(baseClassKey, this.itemTypeClass);\r\n await (newClass as ECClass as MutableClass).setBaseClass(new DelayedPromiseWithProps<SchemaItemKey, T>(baseClassKey, async () => baseClassItem as T));\r\n }\r\n\r\n return newClass;\r\n }\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<void> {\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 const mutableClass = await this.getClass(classKey);\r\n\r\n await mutableClass.createPrimitiveProperty(prefixedName, type);\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<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n await mutableClass.createPrimitiveProperty(name, type);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveProperty, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\r\n await newProperty.fromJSON(primitiveProps);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitivePropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\r\n if (enumSchemaItemKey === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(SchemaItemType.Enumeration, type.name, mutableClass.schema.schemaKey));\r\n\r\n await mutableClass.createPrimitiveProperty(name, type);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationProperty, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\r\n await newProperty.fromJSON(enumProps);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n await mutableClass.createPrimitiveArrayProperty(name, type);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\r\n await newProperty.fromJSON(primitiveProps);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreatePrimitiveArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createEnumerationArrayProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n await mutableClass.createPrimitiveArrayProperty(name, type);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createEnumerationArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, props: PrimitiveArrayPropertyProps): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\r\n await newProperty.fromJSON(props);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateEnumerationArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n await mutableClass.createStructProperty(name, type);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateStructProperty, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n const newProperty = await mutableClass.createStructProperty(name, type);\r\n await newProperty.fromJSON(structProps);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateStructPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n await mutableClass.createStructArrayProperty(name, type);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateStructArrayProperty, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\r\n await newProperty.fromJSON(structProps);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateStructArrayPropertyFromProps, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n await mutableClass.deleteProperty(name);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.DeleteProperty, new PropertyId(this.schemaItemType, classKey, name), e);\r\n }\r\n }\r\n\r\n public async delete(classKey: SchemaItemKey): Promise<void> {\r\n try {\r\n const schema = await this.getSchema(classKey.schemaKey);\r\n const ecClass = await schema.getItem(classKey.name, this.itemTypeClass);\r\n if (ecClass === undefined)\r\n return;\r\n\r\n await schema.deleteClass(ecClass.name);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.DeleteClass, new ClassId(this.schemaItemType, classKey), e);\r\n }\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<void> {\r\n try {\r\n const mutableClass = await this.getClass(classKey);\r\n mutableClass.addCustomAttribute(customAttribute);\r\n\r\n const diagnosticIterable = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\r\n\r\n const diagnostics: AnyDiagnostic[] = [];\r\n for await (const diagnostic of diagnosticIterable) {\r\n diagnostics.push(diagnostic);\r\n }\r\n\r\n if (diagnostics.length > 0) {\r\n this.removeCustomAttribute(mutableClass, customAttribute);\r\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, mutableClass), undefined, diagnostics);\r\n }\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToClass, new ClassId(this.schemaItemType, classKey), e);\r\n }\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<void> {\r\n try {\r\n const classItem = await this.getSchemaItem(itemKey, this.itemTypeClass);\r\n if (!baseClassKey) {\r\n await (classItem as MutableClass).setBaseClass(undefined);\r\n return;\r\n }\r\n\r\n if(!await this.schemaEditor.schemaContext.getSchema(baseClassKey.schemaKey)) {\r\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(baseClassKey.schemaKey));\r\n }\r\n\r\n const baseClassItem = await this.getSchemaItem(baseClassKey, this.itemTypeClass);\r\n if (classItem.baseClass !== undefined && !await baseClassItem.is(await classItem.baseClass))\r\n throw new SchemaEditingError(ECEditingStatus.InvalidBaseClass, new ClassId(this.schemaItemType, baseClassKey), undefined, undefined, `Base class ${baseClassKey.fullName} must derive from ${(await classItem.baseClass).fullName}.`);\r\n\r\n await (classItem as MutableClass).setBaseClass(new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClassKey, async () => baseClassItem));\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(this.schemaItemType, itemKey), e);\r\n }\r\n }\r\n\r\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\r\n const schema = await this.getSchema(classKey.schemaKey);\r\n\r\n const ecClass = await schema.getItem(classKey.name);\r\n if (ecClass === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new ClassId(this.schemaItemType, classKey));\r\n\r\n if(!isMutableClass(ecClass))\r\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new ClassId(this.schemaItemType, classKey));\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\r\nfunction isMutableClass(schemaItem: SchemaItem): schemaItem is MutableClass {\r\n return ECClass.isECClass(schemaItem);\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,OAAO,EAGL,uBAAuB,EACvB,OAAO,EACiB,aAAa,EAA6B,cAAc,GAEjF,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAElI,OAAO,EAAoB,WAAW,EAAE,MAAM,eAAe,CAAC;AAI9D;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,WAAW;IAExC,YAAsB,cAAkC,EAAE,YAAiC;QACzF,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;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CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AAED,SAAS,cAAc,CAAC,UAAsB;IAC5C,OAAO,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n CustomAttribute,\n CustomAttributeContainerProps,\n DelayedPromiseWithProps,\n ECClass, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\n PrimitivePropertyProps, PrimitiveType, SchemaItem, 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, SchemaId, SchemaItemId } from \"./Exception\";\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\nimport { CreateSchemaItem, SchemaItems } from \"./SchemaItems\";\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 this.properties = new Properties(this.schemaItemType, this.schemaEditor);\n this.arrayProperties = new ArrayProperties(this.schemaItemType, this.schemaEditor);\n this.primitiveProperties = new PrimitiveProperties(this.schemaItemType, this.schemaEditor);\n this.enumerationProperties = new EnumerationProperties(this.schemaItemType, this.schemaEditor);\n this.structProperties = new StructProperties(this.schemaItemType, this.schemaEditor);\n }\n\n protected override schemaItemType: ECClassSchemaItems;\n\n /**\n * Allows access for the editors itemType class instance.\n * It returns ECClass here, but editors for subclasses will override this to return the\n * appropriate subclass.\n */\n protected override get itemTypeClass(): typeof ECClass {\n return ECClass;\n }\n\n /**\n * Allows access for editing of base Property attributes.\n */\n public readonly properties: Properties;\n /**\n * Allows access for editing of ArrayProperty attributes.\n */\n public readonly arrayProperties: ArrayProperties;\n /**\n * Allows access for editing of PrimitiveProperty attributes.\n */\n public readonly primitiveProperties: PrimitiveProperties;\n /**\n * Allows access for editing of EnumerationProperty attributes.\n */\n public readonly enumerationProperties: EnumerationProperties;\n /**\n * Allows access for editing of StructProperty attributes.\n */\n public readonly structProperties: StructProperties;\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 if(!await this.schemaEditor.schemaContext.getSchema(baseClassKey.schemaKey)) {\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(baseClassKey.schemaKey));\n }\n\n const baseClassItem = await this.getSchemaItem(baseClassKey, this.itemTypeClass);\n await (newClass as ECClass as MutableClass).setBaseClass(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(classKey.name, this.itemTypeClass);\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 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(itemKey, this.itemTypeClass);\n if (!baseClassKey) {\n await (classItem as MutableClass).setBaseClass(undefined);\n return;\n }\n\n if(!await this.schemaEditor.schemaContext.getSchema(baseClassKey.schemaKey)) {\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(baseClassKey.schemaKey));\n }\n\n const baseClassItem = await this.getSchemaItem(baseClassKey, this.itemTypeClass);\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 await (classItem as MutableClass).setBaseClass(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(classKey.name);\n if (ecClass === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new ClassId(this.schemaItemType, classKey));\n\n if(!isMutableClass(ecClass))\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new ClassId(this.schemaItemType, classKey));\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\nfunction isMutableClass(schemaItem: SchemaItem): schemaItem is MutableClass {\n return ECClass.isECClass(schemaItem);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/Editing/Editor.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAmB,aAAa,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,EAA4C,cAAc,EAAa,eAAe,EAA2B,MAAM,0BAA0B,CAAC;AAE5O,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,O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a,IAAI,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,EAAE,CAAC;gBACjE,IAAI,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;oBAC5C,SAAS;gBAEX,IAAI,aAAa,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE;oBAC3D,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,wBAAwB,EAAE,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,aAAa,CAAC,IAAI,4BAA4B,KAAK,IAAI,CAAC,CAAC;YAC7L,CAAC;YACD,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,IAAI,CAAC,YAAY,aAAa,IAAI,CAAC,CAAC,WAAW,KAAK,cAAc,CAAC,aAAa,EAAE,CAAC;gBACjF,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,cAAc,EAAE,IAAI,QAAQ,CAAC,SAAS,CAAC,EAClF,IAAI,kBAAkB,CAAC,eAAe,CAAC,kBAAkB,EAAE,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACzF,CAAC;YAED,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,cAAc,EAAG,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;CACF;AAED,SAAS,gBAAgB,CAAC,IAA6B;IACrD,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAsB,CAAC,CAAC;AACxE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { CustomAttribute, ECSchemaError, ECSchemaStatus, isSupportedSchemaItemType, Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, SchemaMatchType, SupportedSchemaItemType } 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 { CustomAttributeId, ECEditingStatus, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\r\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\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 /**\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 {\r\n return this._schemaContext;\r\n }\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 * @internal\r\n */\r\n public async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\r\n const schema = await this.schemaContext.getCachedSchema(schemaKey, SchemaMatchType.Latest);\r\n if (schema === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\r\n\r\n return schema as MutableSchema;\r\n }\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 the SchemaKey of created schema.\r\n */\r\n public async createSchema(name: string, alias: string, readVersion: number, writeVersion: number, minorVersion: number): Promise<SchemaKey> {\r\n const newSchema = new Schema(this._schemaContext, name, alias, readVersion, writeVersion, minorVersion);\r\n await this._schemaContext.addSchema(newSchema);\r\n return 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<void> {\r\n try {\r\n const schema = await this.lookupSchema(schemaKey, SchemaMatchType.Exact);\r\n await schema.addReference(refSchema);\r\n\r\n const diagnostics: AnyDiagnostic[] = [];\r\n for await (const diagnostic of Rules.validateSchemaReferences(schema)) {\r\n diagnostics.push(diagnostic);\r\n }\r\n\r\n if (diagnostics.length > 0) {\r\n this.removeReference(schema, refSchema);\r\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new SchemaId(schemaKey), undefined, diagnostics);\r\n }\r\n\r\n if (!await this.schemaContext.getCachedSchema(refSchema.schemaKey)) {\r\n await this.schemaContext.addSchema(refSchema);\r\n }\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.AddSchemaReference, new SchemaId(schemaKey), e);\r\n }\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<void> {\r\n try {\r\n const schema = await this.lookupSchema(schemaKey);\r\n schema.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics: AnyDiagnostic[] = [];\r\n for await (const diagnostic of Rules.validateCustomAttributeInstance(schema, customAttribute)) {\r\n diagnostics.push(diagnostic);\r\n }\r\n\r\n if (diagnostics.length > 0) {\r\n this.removeCustomAttribute(schema, customAttribute);\r\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, schema), undefined, diagnostics);\r\n }\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToClass, new SchemaId(schemaKey), e);\r\n }\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 * @returns Resolves to the new SchemaKey containing version updates.\r\n */\r\n public async setVersion(schemaKey: SchemaKey, readVersion?: number, writeVersion?: number, minorVersion?: number): Promise<SchemaKey> {\r\n try {\r\n const schema = await this.lookupSchema(schemaKey);\r\n schema.setVersion(readVersion || schema.readVersion, writeVersion || schema.writeVersion, minorVersion || schema.minorVersion);\r\n\r\n return schema.schemaKey;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.SetSchemaVersion, new SchemaId(schemaKey), e);\r\n }\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 * @returns Resolves to the new SchemaKey containing version updates.\r\n */\r\n public async incrementMinorVersion(schemaKey: SchemaKey): Promise<SchemaKey> {\r\n try {\r\n const schema = await this.lookupSchema(schemaKey);\r\n schema.setVersion(schema.readVersion, schema.writeVersion, schema.minorVersion + 1);\r\n\r\n return schema.schemaKey;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.IncrementSchemaMinorVersion, new SchemaId(schemaKey), e);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public async lookupSchemaItem(schemaOrKey: Schema | SchemaKey, schemaItemKey: SchemaItemKey, schemaItemType: SchemaItemType): Promise<SchemaItem> {\r\n if(Schema.isSchema(schemaOrKey)) {\r\n schemaOrKey = schemaOrKey.schemaKey;\r\n }\r\n\r\n const schemaItem = await this.schemaContext.getSchemaItem(schemaItemKey);\r\n if (schemaItem === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(schemaItemType, schemaItemKey));\r\n\r\n if (schemaItemType !== schemaItem.schemaItemType)\r\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new SchemaItemId(schemaItemType, schemaItemKey));\r\n\r\n return schemaItem;\r\n }\r\n\r\n /** @internal */\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T>> {\r\n const schemaItem = await this.schemaContext.getSchemaItem(schemaItemKey);\r\n const schemaItemType = itemConstructor.schemaItemType;\r\n if(!isSchemaItemType(schemaItemType)) {\r\n // This block should never be hit, as the editor components always pass in the itemConstructor with a valid schemaItemType.\r\n throw new Error(`Invalid schema item lookup for: ${schemaItemType}`);\r\n }\r\n\r\n if (!schemaItem) {\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFoundInContext, new SchemaItemId(schemaItemType, schemaItemKey));\r\n }\r\n\r\n if (!isSupportedSchemaItemType(schemaItem.schemaItemType, itemConstructor.schemaItemType))\r\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new SchemaItemId(schemaItemType, schemaItemKey));\r\n\r\n return schemaItem as InstanceType<T>;\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 private async lookupSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<MutableSchema> {\r\n const schema = await this.schemaContext.getCachedSchema(schemaKey, matchType);\r\n if (schema === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\r\n\r\n return schema as MutableSchema;\r\n }\r\n\r\n /**\r\n * Sets the Schemas description.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n * @param description The new description to set.\r\n */\r\n public async setDescription(schemaKey: SchemaKey, description: string) {\r\n const schema = await this.lookupSchema(schemaKey)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new SchemaId(schemaKey), e);\r\n });\r\n schema.setDescription(description);\r\n }\r\n\r\n /**\r\n * Sets the Schemas display label.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n * @param label The new label to set.\r\n */\r\n public async setDisplayLabel(schemaKey: SchemaKey, label: string) {\r\n const schema = await this.lookupSchema(schemaKey)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new SchemaId(schemaKey), e);\r\n });\r\n schema.setDisplayLabel(label);\r\n }\r\n\r\n /**\r\n * Sets the Schemas alias.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n * @param alias The new alias to set.\r\n */\r\n public async setAlias(schemaKey: SchemaKey, alias: string) {\r\n const schema = await this.lookupSchema(schemaKey)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey), e);\r\n });\r\n\r\n try {\r\n for (const currentSchema of this.schemaContext.getKnownSchemas()) {\r\n if (currentSchema.schemaKey.matches(schemaKey))\r\n continue;\r\n\r\n if (currentSchema.alias.toLowerCase() === alias.toLowerCase())\r\n throw new SchemaEditingError(ECEditingStatus.SchemaAliasAlreadyExists, new SchemaId(schemaKey), undefined, undefined, `Schema ${currentSchema.name} already uses the alias '${alias}'.`);\r\n }\r\n schema.setAlias(alias);\r\n } catch(e: any) {\r\n if (e instanceof ECSchemaError && e.errorNumber === ECSchemaStatus.InvalidECName) {\r\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey),\r\n new SchemaEditingError(ECEditingStatus.InvalidSchemaAlias, new SchemaId(schemaKey)));\r\n }\r\n\r\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey), e);\r\n }\r\n }\r\n}\r\n\r\nfunction isSchemaItemType(type: SupportedSchemaItemType): type is SchemaItemType {\r\n return Object.values(SchemaItemType).includes(type as SchemaItemType);\r\n}"]}
1
+ {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/Editing/Editor.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAmB,aAAa,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,EA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MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAsB,CAAC,CAAC;AACxE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport * as Rules from \"../Validation/ECRules\";\nimport { CustomAttribute, ECSchemaError, ECSchemaStatus, isSupportedSchemaItemType, Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, SchemaMatchType, SupportedSchemaItemType } 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, SchemaItemId } 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 /**\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 {\n return this._schemaContext;\n }\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 * @internal\n */\n public async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\n const schema = await this.schemaContext.getCachedSchema(schemaKey, SchemaMatchType.Latest);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema as MutableSchema;\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 /** @internal */\n public async lookupSchemaItem(schemaOrKey: Schema | SchemaKey, schemaItemKey: SchemaItemKey, schemaItemType: SchemaItemType): Promise<SchemaItem> {\n if(Schema.isSchema(schemaOrKey)) {\n schemaOrKey = schemaOrKey.schemaKey;\n }\n\n const schemaItem = await this.schemaContext.getSchemaItem(schemaItemKey);\n if (schemaItem === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(schemaItemType, schemaItemKey));\n\n if (schemaItemType !== schemaItem.schemaItemType)\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new SchemaItemId(schemaItemType, schemaItemKey));\n\n return schemaItem;\n }\n\n /** @internal */\n public async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T>> {\n const schemaItem = await this.schemaContext.getSchemaItem(schemaItemKey);\n const schemaItemType = itemConstructor.schemaItemType;\n if(!isSchemaItemType(schemaItemType)) {\n // This block should never be hit, as the editor components always pass in the itemConstructor with a valid schemaItemType.\n throw new Error(`Invalid schema item lookup for: ${schemaItemType}`);\n }\n\n if (!schemaItem) {\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFoundInContext, new SchemaItemId(schemaItemType, schemaItemKey));\n }\n\n if (!isSupportedSchemaItemType(schemaItem.schemaItemType, itemConstructor.schemaItemType))\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new SchemaItemId(schemaItemType, schemaItemKey));\n\n return schemaItem as InstanceType<T>;\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(schemaKey, matchType);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema as MutableSchema;\n }\n\n /**\n * Sets the Schemas description.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param description The new description to set.\n */\n public async setDescription(schemaKey: SchemaKey, description: string) {\n const schema = await this.lookupSchema(schemaKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new SchemaId(schemaKey), e);\n });\n schema.setDescription(description);\n }\n\n /**\n * Sets the Schemas display label.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param label The new label to set.\n */\n public async setDisplayLabel(schemaKey: SchemaKey, label: string) {\n const schema = await this.lookupSchema(schemaKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new SchemaId(schemaKey), e);\n });\n schema.setDisplayLabel(label);\n }\n\n /**\n * Sets the Schemas alias.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param alias The new alias to set.\n */\n public async setAlias(schemaKey: SchemaKey, alias: string) {\n const schema = await this.lookupSchema(schemaKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey), e);\n });\n\n try {\n for (const currentSchema of this.schemaContext.getKnownSchemas()) {\n if (currentSchema.schemaKey.matches(schemaKey))\n continue;\n\n if (currentSchema.alias.toLowerCase() === alias.toLowerCase())\n throw new SchemaEditingError(ECEditingStatus.SchemaAliasAlreadyExists, new SchemaId(schemaKey), undefined, undefined, `Schema ${currentSchema.name} already uses the alias '${alias}'.`);\n }\n schema.setAlias(alias);\n } catch(e: any) {\n if (e instanceof ECSchemaError && e.errorNumber === ECSchemaStatus.InvalidECName) {\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey),\n new SchemaEditingError(ECEditingStatus.InvalidSchemaAlias, new SchemaId(schemaKey)));\n }\n\n throw new SchemaEditingError(ECEditingStatus.SetSchemaAlias, new SchemaId(schemaKey), e);\n }\n }\n}\n\nfunction isSchemaItemType(type: SupportedSchemaItemType): type is SchemaItemType {\n return Object.values(SchemaItemType).includes(type as SchemaItemType);\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Entities.js","sourceRoot":"","sources":["../../../src/Editing/Entities.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EACY,WAAW,EAC5B,KAAK,EAA6D,cAAc,GACjF,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE3E;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,SAAS;IACrC,IAAuB,aAAa;QAClC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACa,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,cA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C,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;YAC1I,MAAM,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,iCAAiC,EAAE,IAAI,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACxI,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport {\r\n ECClassModifier, EntityClass, EntityClassProps,\r\n Mixin, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaItemType, SchemaKey, StrengthDirection,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableEntityClass } from \"./Mutable/MutableEntityClass\";\r\nimport { NavigationProperties } from \"./Properties\";\r\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\r\n\r\n/**\r\n * @alpha\r\n * A class extending ECClasses allowing you to create schema items of type EntityClass.\r\n */\r\nexport class Entities extends ECClasses {\r\n protected override get itemTypeClass(): typeof EntityClass {\r\n return EntityClass;\r\n }\r\n\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.EntityClass, schemaEditor);\r\n }\r\n\r\n /**\r\n * Allows access for editing of NavigationProperty attributes.\r\n */\r\n public readonly navigationProperties = new NavigationProperties(SchemaItemType.EntityClass, this.schemaEditor);\r\n\r\n public async createElement(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\r\n try {\r\n const baseClass = await this.getSchemaItem(baseClassKey, EntityClass);\r\n if (!(await (baseClass).is(\"Element\", \"BisCore\"))) {\r\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElement, new ClassId(this.schemaItemType, baseClassKey));\r\n }\r\n } catch(e: any){\r\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n\r\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\r\n }\r\n\r\n public async createElementUniqueAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\r\n try {\r\n const baseClass = await this.getSchemaItem(baseClassKey, EntityClass);\r\n if (!(await (baseClass).is(\"ElementUniqueAspect\", \"BisCore\"))) {\r\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElementUniqueAspect, new ClassId(this.schemaItemType, baseClassKey));\r\n }\r\n } catch(e: any){\r\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n\r\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\r\n }\r\n\r\n public async createElementMultiAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\r\n try {\r\n const baseClass = await this.getSchemaItem(baseClassKey, EntityClass);\r\n if (!(await (baseClass).is(\"ElementMultiAspect\", \"BisCore\"))) {\r\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElementMultiAspect, new ClassId(this.schemaItemType, baseClassKey));\r\n }\r\n } catch(e: any){\r\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n\r\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, displayLabel?: string, baseClassKey?: SchemaItemKey, mixins?: Mixin[]): Promise<SchemaItemKey> {\r\n try {\r\n const newClass = await this.createClass<EntityClass>(schemaKey, this.schemaItemType, (schema) => schema.createEntityClass.bind(schema), name, baseClassKey, modifier) as MutableEntityClass;\r\n\r\n if (mixins !== undefined)\r\n mixins.forEach((m) => newClass.addMixin(m));\r\n\r\n if (displayLabel)\r\n newClass.setDisplayLabel(displayLabel);\r\n\r\n return newClass.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new ClassId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n /**\r\n * Creates an EntityClass through an EntityClassProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param entityProps a json object that will be used to populate the new EntityClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, entityProps: EntityClassProps): Promise<SchemaItemKey> {\r\n try {\r\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createEntityClass.bind(schema), entityProps);\r\n return newClass.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, entityProps.name!, schemaKey), e);\r\n }\r\n }\r\n\r\n public async addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void> {\r\n try {\r\n const entity = await this.getSchemaItem(entityKey, MutableEntityClass);\r\n const mixin = await this.getSchemaItem(mixinKey, Mixin);\r\n entity.addMixin(mixin);\r\n } catch(e: any){\r\n throw new SchemaEditingError(ECEditingStatus.AddMixin, new ClassId(SchemaItemType.EntityClass, entityKey), e);\r\n }\r\n }\r\n\r\n public async createNavigationProperty(entityKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<void> {\r\n try {\r\n const entity = await this.getSchemaItem(entityKey, MutableEntityClass);\r\n await entity.createNavigationProperty(name, relationship, direction);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationProperty, new ClassId(SchemaItemType.RelationshipClass, entityKey), e);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a Navigation Property through a NavigationPropertyProps.\r\n * @param classKey a SchemaItemKey of the Entity Class that will house the new property.\r\n * @param navigationProps a json object that will be used to populate the new Navigation Property.\r\n */\r\n public async createNavigationPropertyFromProps(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<void> {\r\n try {\r\n const entity = await this.getSchemaItem(classKey, MutableEntityClass);\r\n const property = await entity.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\r\n await property.fromJSON(navigationProps);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationPropertyFromProps, new ClassId(SchemaItemType.EntityClass, classKey), e);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Entities.js","sourceRoot":"","sources":["../../../src/Editing/Entities.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EACY,WAAW,EAC5B,KAAK,EAA6D,cAAc,GACjF,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE3E;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,SAAS;IACrC,IAAuB,aAAa;QAClC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACa,oBAA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G,MAAM,MAAM,CAAC,wBAAwB,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,gBAAgB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;YAC1I,MAAM,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,iCAAiC,EAAE,IAAI,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACxI,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n ECClassModifier, EntityClass, EntityClassProps,\n Mixin, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaItemType, SchemaKey, StrengthDirection,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableEntityClass } from \"./Mutable/MutableEntityClass\";\nimport { NavigationProperties } from \"./Properties\";\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\n\n/**\n * @alpha\n * A class extending ECClasses allowing you to create schema items of type EntityClass.\n */\nexport class Entities extends ECClasses {\n protected override get itemTypeClass(): typeof EntityClass {\n return EntityClass;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.EntityClass, schemaEditor);\n }\n\n /**\n * Allows access for editing of NavigationProperty attributes.\n */\n public readonly navigationProperties = new NavigationProperties(SchemaItemType.EntityClass, this.schemaEditor);\n\n public async createElement(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const baseClass = await this.getSchemaItem(baseClassKey, EntityClass);\n if (!(await (baseClass).is(\"Element\", \"BisCore\"))) {\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElement, new ClassId(this.schemaItemType, baseClassKey));\n }\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\n }\n\n public async createElementUniqueAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const baseClass = await this.getSchemaItem(baseClassKey, EntityClass);\n if (!(await (baseClass).is(\"ElementUniqueAspect\", \"BisCore\"))) {\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElementUniqueAspect, new ClassId(this.schemaItemType, baseClassKey));\n }\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\n }\n\n public async createElementMultiAspect(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, baseClassKey: SchemaItemKey, displayLabel?: string, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const baseClass = await this.getSchemaItem(baseClassKey, EntityClass);\n if (!(await (baseClass).is(\"ElementMultiAspect\", \"BisCore\"))) {\n throw new SchemaEditingError(ECEditingStatus.BaseClassIsNotElementMultiAspect, new ClassId(this.schemaItemType, baseClassKey));\n }\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.CreateElement, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n\n return this.create(schemaKey, name, modifier, displayLabel, baseClassKey, mixins);\n }\n\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, displayLabel?: string, baseClassKey?: SchemaItemKey, mixins?: Mixin[]): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<EntityClass>(schemaKey, this.schemaItemType, (schema) => schema.createEntityClass.bind(schema), name, baseClassKey, modifier) as MutableEntityClass;\n\n if (mixins !== undefined)\n mixins.forEach((m) => newClass.addMixin(m));\n\n if (displayLabel)\n newClass.setDisplayLabel(displayLabel);\n\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new ClassId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n /**\n * Creates an EntityClass through an EntityClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param entityProps a json object that will be used to populate the new EntityClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, entityProps: EntityClassProps): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createEntityClass.bind(schema), entityProps);\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, entityProps.name!, schemaKey), e);\n }\n }\n\n public async addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void> {\n try {\n const entity = await this.getSchemaItem(entityKey, MutableEntityClass);\n const mixin = await this.getSchemaItem(mixinKey, Mixin);\n entity.addMixin(mixin);\n } catch(e: any){\n throw new SchemaEditingError(ECEditingStatus.AddMixin, new ClassId(SchemaItemType.EntityClass, entityKey), e);\n }\n }\n\n public async createNavigationProperty(entityKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<void> {\n try {\n const entity = await this.getSchemaItem(entityKey, MutableEntityClass);\n await entity.createNavigationProperty(name, relationship, direction);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationProperty, new ClassId(SchemaItemType.RelationshipClass, entityKey), e);\n }\n }\n\n /**\n * Creates a Navigation Property through a NavigationPropertyProps.\n * @param classKey a SchemaItemKey of the Entity Class that will house the new property.\n * @param navigationProps a json object that will be used to populate the new Navigation Property.\n */\n public async createNavigationPropertyFromProps(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<void> {\n try {\n const entity = await this.getSchemaItem(classKey, MutableEntityClass);\n const property = await entity.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);\n await property.fromJSON(navigationProps);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationPropertyFromProps, new ClassId(SchemaItemType.EntityClass, classKey), e);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Enumerations.js","sourceRoot":"","sources":["../../../src/Editing/Enumerations.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAiB,WAAW,EAAkD,cAAc,EAAa,MAAM,0BAA0B,CAAC;AAGjJ,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAM5C;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C,IAAuB,aAAa;QAClC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,IAAkD,EAAE,YAAqB,EAAE,QAAkB,EAAE,WAA6B;QAClL,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAc,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAuB,CAAC;YAE9K,IAAI,SAAS,KAAK,QAAQ;gBACxB,OAAO,CAAC,WAAW,CAAC,QAAQ,CA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K,CAAC,wBAAwB,CAAC,cAA6B,EAAE,cAAsB,EAAE,WAA+B;QAC1H,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;YAE1E,MAAM,UAAU,GAAG,WAAW,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;YACnE,IAAI,UAAU,KAAK,SAAS;gBAC1B,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,sBAAsB,EAAE,IAAI,YAAY,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,CAAC;YAErH,UAAgC,CAAC,WAAW,GAAG,WAAW,CAAC;QAC9D,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,kBAAkB,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { AnyEnumerator, Enumeration, EnumerationProps, PrimitiveType, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutableEnumeration } from \"./Mutable/MutableEnumeration\";\r\nimport { ECEditingStatus, EnumeratorId, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\ntype MutableEnumerator = {\r\n -readonly [P in keyof AnyEnumerator]: AnyEnumerator[P]\r\n};\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Enumeration.\r\n */\r\nexport class Enumerations extends SchemaItems {\r\n protected override get itemTypeClass(): typeof Enumeration {\r\n return Enumeration;\r\n }\r\n\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.Enumeration, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, type: PrimitiveType.Integer | PrimitiveType.String, displayLabel?: string, isStrict?: boolean, enumerators?: AnyEnumerator[]): Promise<SchemaItemKey> {\r\n try {\r\n const newEnum = await this.createSchemaItem<Enumeration>(schemaKey, this.schemaItemType, (schema) => schema.createEnumeration.bind(schema), name, type) as MutableEnumeration;\r\n\r\n if (undefined !== isStrict)\r\n newEnum.setIsStrict(isStrict);\r\n\r\n if (undefined !== enumerators)\r\n for (const enumerator of enumerators)\r\n await this.addEnumerator(newEnum.key, enumerator);\r\n\r\n if (displayLabel)\r\n newEnum.setDisplayLabel(displayLabel);\r\n\r\n return newEnum.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n /**\r\n * Creates an Enumeration through an EnumeratorProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, enumProps: EnumerationProps): Promise<SchemaItemKey> {\r\n try {\r\n const newEnum = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createEnumeration.bind(schema), enumProps);\r\n return newEnum.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, enumProps.name!, schemaKey), e);\r\n }\r\n }\r\n\r\n public async addEnumerator(enumerationKey: SchemaItemKey, enumerator: AnyEnumerator): Promise<void> {\r\n try {\r\n const enumeration = await this.getSchemaItem(enumerationKey, Enumeration);\r\n\r\n if (enumeration.isInt && typeof (enumerator.value) !== \"number\")\r\n throw new SchemaEditingError(ECEditingStatus.InvalidEnumeratorType, new EnumeratorId(enumerator, enumeration));\r\n\r\n if (enumeration.isString && typeof (enumerator.value) !== \"string\")\r\n throw new SchemaEditingError(ECEditingStatus.InvalidEnumeratorType, new EnumeratorId(enumerator, enumeration));\r\n\r\n (enumeration as MutableEnumeration).addEnumerator(enumerator);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.AddEnumerator, new SchemaItemId(this.schemaItemType, enumerationKey), e);\r\n }\r\n }\r\n\r\n public async setEnumeratorLabel(enumerationKey: SchemaItemKey, enumeratorName: string, label: string | undefined): Promise<void> {\r\n try {\r\n const enumeration = await this.getSchemaItem(enumerationKey, Enumeration);\r\n\r\n const enumerator = enumeration.getEnumeratorByName(enumeratorName);\r\n if (enumerator === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.EnumeratorDoesNotExist, new EnumeratorId(enumeratorName, enumeration));\r\n\r\n (enumerator as MutableEnumerator).label = label;\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.SetEnumeratorLabel, new SchemaItemId(this.schemaItemType, enumerationKey), e);\r\n }\r\n }\r\n\r\n public async setEnumeratorDescription(enumerationKey: SchemaItemKey, enumeratorName: string, description: string | undefined): Promise<void> {\r\n try {\r\n const enumeration = await this.getSchemaItem(enumerationKey, Enumeration);\r\n\r\n const enumerator = enumeration.getEnumeratorByName(enumeratorName);\r\n if (enumerator === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.EnumeratorDoesNotExist, new EnumeratorId(enumeratorName, enumeration));\r\n\r\n (enumerator as MutableEnumerator).description = description;\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.SetEnumeratorLabel, new SchemaItemId(this.schemaItemType, enumerationKey), e);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Enumerations.js","sourceRoot":"","sources":["../../../src/Editing/Enumerations.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAiB,WAAW,E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E,CAAC;YACf,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,kBAAkB,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { AnyEnumerator, Enumeration, EnumerationProps, PrimitiveType, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableEnumeration } from \"./Mutable/MutableEnumeration\";\nimport { ECEditingStatus, EnumeratorId, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\ntype MutableEnumerator = {\n -readonly [P in keyof AnyEnumerator]: AnyEnumerator[P]\n};\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Enumeration.\n */\nexport class Enumerations extends SchemaItems {\n protected override get itemTypeClass(): typeof Enumeration {\n return Enumeration;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Enumeration, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, type: PrimitiveType.Integer | PrimitiveType.String, displayLabel?: string, isStrict?: boolean, enumerators?: AnyEnumerator[]): Promise<SchemaItemKey> {\n try {\n const newEnum = await this.createSchemaItem<Enumeration>(schemaKey, this.schemaItemType, (schema) => schema.createEnumeration.bind(schema), name, type) as MutableEnumeration;\n\n if (undefined !== isStrict)\n newEnum.setIsStrict(isStrict);\n\n if (undefined !== enumerators)\n for (const enumerator of enumerators)\n await this.addEnumerator(newEnum.key, enumerator);\n\n if (displayLabel)\n newEnum.setDisplayLabel(displayLabel);\n\n return newEnum.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n /**\n * Creates an Enumeration through an EnumeratorProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, enumProps: EnumerationProps): Promise<SchemaItemKey> {\n try {\n const newEnum = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createEnumeration.bind(schema), enumProps);\n return newEnum.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, enumProps.name!, schemaKey), e);\n }\n }\n\n public async addEnumerator(enumerationKey: SchemaItemKey, enumerator: AnyEnumerator): Promise<void> {\n try {\n const enumeration = await this.getSchemaItem(enumerationKey, Enumeration);\n\n if (enumeration.isInt && typeof (enumerator.value) !== \"number\")\n throw new SchemaEditingError(ECEditingStatus.InvalidEnumeratorType, new EnumeratorId(enumerator, enumeration));\n\n if (enumeration.isString && typeof (enumerator.value) !== \"string\")\n throw new SchemaEditingError(ECEditingStatus.InvalidEnumeratorType, new EnumeratorId(enumerator, enumeration));\n\n (enumeration as MutableEnumeration).addEnumerator(enumerator);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.AddEnumerator, new SchemaItemId(this.schemaItemType, enumerationKey), e);\n }\n }\n\n public async setEnumeratorLabel(enumerationKey: SchemaItemKey, enumeratorName: string, label: string | undefined): Promise<void> {\n try {\n const enumeration = await this.getSchemaItem(enumerationKey, Enumeration);\n\n const enumerator = enumeration.getEnumeratorByName(enumeratorName);\n if (enumerator === undefined)\n throw new SchemaEditingError(ECEditingStatus.EnumeratorDoesNotExist, new EnumeratorId(enumeratorName, enumeration));\n\n (enumerator as MutableEnumerator).label = label;\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetEnumeratorLabel, new SchemaItemId(this.schemaItemType, enumerationKey), e);\n }\n }\n\n public async setEnumeratorDescription(enumerationKey: SchemaItemKey, enumeratorName: string, description: string | undefined): Promise<void> {\n try {\n const enumeration = await this.getSchemaItem(enumerationKey, Enumeration);\n\n const enumerator = enumeration.getEnumeratorByName(enumeratorName);\n if (enumerator === undefined)\n throw new SchemaEditingError(ECEditingStatus.EnumeratorDoesNotExist, new EnumeratorId(enumeratorName, enumeration));\n\n (enumerator as MutableEnumerator).description = description;\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.SetEnumeratorLabel, new SchemaItemId(this.schemaItemType, enumerationKey), e);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../../src/Editing/Exception.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAA6D,aAAa,EAAE,qBAAqB,EAAE,QAAQ,EAA0B,aAAa,EAA6B,MAAM,0BAA0B,CAAC;AAEvN,aAAa;AACb,MAAM,CAAN,IAAY,eAmFX;AAnFD,WAAY,eAAe;IACzB,4FAA+B,CAAA;IAC/B,2DAAW,CAAA;IACX,4EAAyC,CAAA;IACzC,8EAAc,CAAA;IACd,sFAAkB,CAAA;IAClB,wGAA2B,CAAA;IAC3B,4FAAqB,CAAA;IACrB,kFAAgB,CAAA;IAChB,wFAAmB,CAAA;IACnB,4FAAqB,CAAA;IACrB,oHAAiC,CAAA;IACjC,kHAAgC,CAAA;IAChC,sGAA0B,CAAA;IAC1B,4FAAqB,CAAA;IACrB,wGAA2B,CAAA;IAC3B,4FAAqB,CAAA;IACrB,kFAAgB,CAAA;IAChB,8FAAsB,CAAA;IACtB,4EAAa,CAAA;IACb,sFAAkB,CAAA;IAClB,wGAA2B,CAAA;IAC3B,kGAAwB,CAAA;IACxB,eAAe;IACf,8FAAsB,CAAA;IACtB,oGAAyB,CAAA;IACzB,4EAAa,CAAA;IACb,oGAAyB,CAAA;IACzB,kGAAwB,CAAA;IACxB,0EAAY,CAA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AO,0BAA0B,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,+BAA+B,IAAI,CAAC,UAAU,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC;YACjK;gBACE,MAAM,IAAI,KAAK,CAAE,qBAAqB,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAEO,sBAAsB,CAAC,UAAyB;QACtD,IAAI,UAAU,CAAC,cAAc,KAAK,qBAAqB,CAAC,oBAAoB;YAC1E,UAAU,CAAC,cAAc,KAAK,qBAAqB,CAAC,eAAe;YACnE,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,WAAwB,EAAE,UAAkC;IACrF,IAAI,OAAM,CAAC,UAAU,CAAC,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC/E,CAAC;IAED,OAAO,OAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;AAClE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\r\nimport { AnyEnumerator, CustomAttributeContainerProps, Enumeration, PrimitiveType, primitiveTypeToString, Property, RelationshipConstraint, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/** @alpha */\r\nexport enum ECEditingStatus {\r\n EC_EDITING_ERROR_BASE = 0x30000,\r\n Unknown = 0,\r\n RuleViolation = EC_EDITING_ERROR_BASE + 1,\r\n SchemaNotFound,\r\n SchemaItemNotFound,\r\n SchemaItemNotFoundInContext,\r\n PropertyAlreadyExists,\r\n PropertyNotFound,\r\n InvalidPropertyType,\r\n BaseClassIsNotElement,\r\n BaseClassIsNotElementUniqueAspect,\r\n BaseClassIsNotElementMultiAspect,\r\n SchemaItemNameNotSpecified,\r\n InvalidSchemaItemType,\r\n SchemaItemNameAlreadyExists,\r\n InvalidEnumeratorType,\r\n InvalidBaseClass,\r\n EnumeratorDoesNotExist,\r\n InvalidECName,\r\n InvalidSchemaAlias,\r\n InvalidFormatUnitsSpecified,\r\n SchemaAliasAlreadyExists,\r\n // Outer Errors\r\n CreateSchemaItemFailed,\r\n CreateSchemaItemFromProps,\r\n CreateElement,\r\n CreateElementUniqueAspect,\r\n CreateElementMultiAspect,\r\n SetBaseClass,\r\n SetSourceConstraint,\r\n SetTargetConstraint,\r\n AddConstraintClass,\r\n RemoveConstraintClass,\r\n SetAbstractConstraint,\r\n AddCustomAttributeToConstraint,\r\n AddCustomAttributeToProperty,\r\n AddCustomAttributeToClass,\r\n CreateNavigationProperty,\r\n CreateNavigationPropertyFromProps,\r\n SetInvertsUnit,\r\n SetUnitSystem,\r\n SetDescription,\r\n SetLabel,\r\n SetIsReadOnly,\r\n SetPriority,\r\n SetCategory,\r\n SetKindOfQuantity,\r\n SetMinOccurs,\r\n SetMaxOccurs,\r\n SetExtendedTypeName,\r\n SetMinLength,\r\n SetMaxLength,\r\n SetMinValue,\r\n SetMaxValue,\r\n SetPropertyName,\r\n AddMixin,\r\n AddEnumerator,\r\n SetEnumeratorLabel,\r\n SetEnumeratorDescription,\r\n AddPresentationUnit,\r\n AddPresentationOverride,\r\n CreateFormatOverride,\r\n SetPropertyCategoryPriority,\r\n CreatePrimitiveProperty,\r\n CreatePrimitivePropertyFromProps,\r\n CreateEnumerationProperty,\r\n CreateEnumerationPropertyFromProps,\r\n CreatePrimitiveArrayProperty,\r\n CreatePrimitiveArrayPropertyFromProps,\r\n CreateEnumerationArrayProperty,\r\n CreateEnumerationArrayPropertyFromProps,\r\n CreateStructProperty,\r\n CreateStructPropertyFromProps,\r\n CreateStructArrayProperty,\r\n CreateStructArrayPropertyFromProps,\r\n DeleteProperty,\r\n DeleteClass,\r\n SetClassName,\r\n AddSchemaReference,\r\n SetSchemaVersion,\r\n IncrementSchemaMinorVersion,\r\n SetSchemaAlias\r\n}\r\n\r\n/**\r\n * A type that constrains the possible error types handled by SchemaEditingError\r\n * @alpha\r\n */\r\nexport type AnyEditingError = SchemaEditingError | Error;\r\n\r\n/**\r\n * Defines the possible property type names.\r\n * @alpha\r\n */\r\nexport enum PropertyTypeName {\r\n ArrayProperty = \"ArrayProperty\",\r\n PrimitiveProperty = \"PrimitiveProperty\",\r\n EnumerationProperty = \"EnumerationProperty\",\r\n NavigationProperty = \"NavigationProperty\",\r\n StructProperty = \"StructProperty\"\r\n}\r\n\r\n/**\r\n * Defines the possible schema type identifiers.\r\n * @alpha\r\n */\r\nexport enum SchemaTypeIdentifiers {\r\n SchemaIdentifier = \"Schema\",\r\n SchemaItemIdentifier = \"SchemaItem\",\r\n ClassIdentifier = \"Class\",\r\n PropertyIdentifier = \"Property\",\r\n EnumeratorIdentifier = \"Enumerator\",\r\n CustomAttributeIdentifier = \"CustomAttribute\",\r\n RelationshipConstraintIdentifier = \"RelationshipConstraint\"\r\n}\r\n\r\n/**\r\n * Type that constrains SchemaItemType enum to those used by EC Class types.\r\n * @alpha\r\n */\r\nexport type ECClassSchemaItems = SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.RelationshipClass | SchemaItemType.Mixin | SchemaItemType.CustomAttributeClass;\r\n\r\n/**\r\n * Type that defines the possible SchemaTypeIdentifiers for SchemaItemId classes.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemTypeIdentifier = SchemaTypeIdentifiers.SchemaItemIdentifier | SchemaTypeIdentifiers.ClassIdentifier;\r\n\r\n/**\r\n * Type that encompasses all ISchemaTypeIdentifier interfaces\r\n * @alpha\r\n */\r\nexport type AnyIdentifier = ISchemaIdentifier | ISchemaItemIdentifier | IClassIdentifier | IPropertyIdentifier | ICustomAttributeIdentifier | IRelationshipConstraintIdentifier | IEnumeratorIdentifier;\r\n\r\n/**\r\n * A base interface that defines what is needed to identity any schema type.\r\n * @alpha\r\n */\r\nexport interface ISchemaTypeIdentifier {\r\n readonly name: string;\r\n readonly schemaKey: SchemaKey;\r\n readonly typeIdentifier: SchemaTypeIdentifiers;\r\n}\r\n\r\n/**\r\n * Interface that defines the data needed to identify a Schema.\r\n * @alpha\r\n */\r\nexport interface ISchemaIdentifier extends ISchemaTypeIdentifier {\r\n readonly typeIdentifier: SchemaTypeIdentifiers.SchemaIdentifier;\r\n}\r\n\r\n/**\r\n * Interface that defines the data needed to identify a SchemaItem.\r\n * @alpha\r\n */\r\nexport interface ISchemaItemIdentifier extends ISchemaTypeIdentifier {\r\n readonly schemaItemType: SchemaItemType;\r\n readonly schemaItemKey: SchemaItemKey;\r\n readonly typeIdentifier: AnySchemaItemTypeIdentifier;\r\n}\r\n\r\n/**\r\n * Interface that defines the data needed to identify an EC Class.\r\n * @alpha\r\n */\r\nexport interface IClassIdentifier extends ISchemaTypeIdentifier {\r\n readonly schemaItemType: ECClassSchemaItems;\r\n readonly schemaItemKey: SchemaItemKey;\r\n readonly typeIdentifier: SchemaTypeIdentifiers.ClassIdentifier;\r\n}\r\n\r\n/**\r\n * Interface that defines the data needed to identify an EC Property.\r\n * @alpha\r\n */\r\nexport interface IPropertyIdentifier extends ISchemaTypeIdentifier {\r\n readonly fullName: string;\r\n readonly ecClass: ClassId;\r\n readonly typeName?: PropertyTypeName;\r\n readonly typeIdentifier: SchemaTypeIdentifiers.PropertyIdentifier;\r\n}\r\n\r\n/**\r\n * Interface that defines the data needed to identify an Enumerator.\r\n * @alpha\r\n */\r\ninterface IEnumeratorIdentifier extends ISchemaTypeIdentifier {\r\n readonly enumeratorType: string;\r\n readonly enumeration: SchemaItemKey;\r\n readonly enumerationType: string;\r\n readonly typeIdentifier: SchemaTypeIdentifiers.EnumeratorIdentifier;\r\n}\r\n\r\n/**\r\n * Interface that defines the data needed to identify a CustomAttribute.\r\n * @alpha\r\n */\r\nexport interface ICustomAttributeIdentifier extends ISchemaTypeIdentifier {\r\n readonly containerFullName: string;\r\n readonly typeIdentifier: SchemaTypeIdentifiers.CustomAttributeIdentifier;\r\n}\r\n\r\n/**\r\n * Interface that defines the data needed to identify a RelationshipConstraint.\r\n * @alpha\r\n */\r\nexport interface IRelationshipConstraintIdentifier extends ISchemaTypeIdentifier {\r\n readonly relationshipKey: SchemaItemKey;\r\n readonly typeIdentifier: SchemaTypeIdentifiers.RelationshipConstraintIdentifier;\r\n}\r\n\r\n/**\r\n * An ISchemaIdentifier implementation to identify Schemas\r\n * @alpha\r\n */\r\nexport class SchemaId implements ISchemaIdentifier {\r\n public readonly typeIdentifier = SchemaTypeIdentifiers.SchemaIdentifier;\r\n public readonly name: string;\r\n public readonly schemaKey: SchemaKey;\r\n constructor(schemaKey: SchemaKey) {\r\n this.name = schemaKey.name;\r\n this.schemaKey = schemaKey;\r\n }\r\n}\r\n\r\n/**\r\n * An ISchemItemIdentifier implementation to identify SchemaItems\r\n * @alpha\r\n */\r\nexport class SchemaItemId implements ISchemaItemIdentifier {\r\n public readonly typeIdentifier: AnySchemaItemTypeIdentifier;\r\n public readonly name: string;\r\n public readonly schemaKey: SchemaKey;\r\n public readonly schemaItemType: SchemaItemType;\r\n public readonly schemaItemKey: SchemaItemKey;\r\n\r\n constructor(schemaItemType: SchemaItemType, schemaItemKeyOrName: SchemaItemKey | string, schemaKey?: SchemaKey) {\r\n if (typeof(schemaItemKeyOrName) === \"string\") {\r\n if (!schemaKey)\r\n throw new Error(\"schemaKey if required if the specified schemaItem the name of the schema item.\");\r\n\r\n this.schemaKey = schemaKey!;\r\n this.schemaItemKey = new SchemaItemKey(schemaItemKeyOrName, schemaKey);\r\n } else {\r\n this.schemaKey = schemaItemKeyOrName.schemaKey;\r\n this.schemaItemKey = schemaItemKeyOrName;\r\n }\r\n\r\n this.schemaItemType = schemaItemType;\r\n this.name = this.schemaItemKey.fullName;\r\n this.typeIdentifier = SchemaTypeIdentifiers.SchemaItemIdentifier;\r\n }\r\n}\r\n\r\n/**\r\n * An IClassIdentifier implementation to identify Class instances.\r\n * @alpha\r\n */\r\nexport class ClassId extends SchemaItemId implements IClassIdentifier {\r\n public override readonly typeIdentifier = SchemaTypeIdentifiers.ClassIdentifier;\r\n public override readonly schemaItemType: ECClassSchemaItems;\r\n constructor(schemaItemType: ECClassSchemaItems, schemaItemKeyOrName: SchemaItemKey | string, schemaKey?: SchemaKey) {\r\n super(schemaItemType, schemaItemKeyOrName, schemaKey);\r\n this.schemaItemType = schemaItemType;\r\n }\r\n}\r\n\r\n/**\r\n * An IPropertyIdentifier implementation to identify Property instances.\r\n * @alpha\r\n */\r\nexport class PropertyId implements IPropertyIdentifier {\r\n public readonly typeIdentifier = SchemaTypeIdentifiers.PropertyIdentifier;\r\n public readonly name: string;\r\n public readonly fullName: string;\r\n public readonly ecClass: ClassId;\r\n public readonly schemaKey: SchemaKey;\r\n public readonly typeName?: PropertyTypeName;\r\n\r\n constructor(schemaItemType: ECClassSchemaItems, classKey: SchemaItemKey, property: Property | string, typeName?: PropertyTypeName) {\r\n this.name = property instanceof Property ? property.name : property;\r\n this.fullName = property instanceof Property ? property.fullName : `${classKey.name}.${property}`;\r\n this.ecClass = new ClassId(schemaItemType, classKey);\r\n this.schemaKey = classKey.schemaKey;\r\n this.typeName = typeName;\r\n }\r\n}\r\n\r\n/**\r\n * An IEnumeratorIdentifier implementation to identify Enumerator instances.\r\n * @alpha\r\n */\r\nexport class EnumeratorId implements IEnumeratorIdentifier{\r\n public readonly typeIdentifier = SchemaTypeIdentifiers.EnumeratorIdentifier;\r\n public readonly enumeration: SchemaItemKey;\r\n public readonly enumerationType: string;\r\n public readonly enumeratorType: string;\r\n public readonly name: string;\r\n public readonly schemaKey: SchemaKey;\r\n\r\n constructor(enumerator: AnyEnumerator | string, enumeration: Enumeration) {\r\n this.enumeration = enumeration.key;\r\n this.enumerationType = enumeration.type ? primitiveTypeToString(enumeration.type): \"string\";\r\n this.enumeratorType = getEnumeratorType(enumeration ?? PrimitiveType.String, enumerator);\r\n this.name = typeof(enumerator) === \"string\" ? enumerator : enumerator.name;\r\n this.schemaKey = enumeration.schema.schemaKey;\r\n }\r\n}\r\n\r\n/**\r\n * An ICustomAttributeIdentifier implementation to identify CustomAttribute instances.\r\n * @alpha\r\n */\r\nexport class CustomAttributeId implements ICustomAttributeIdentifier {\r\n public readonly typeIdentifier = SchemaTypeIdentifiers.CustomAttributeIdentifier;\r\n public readonly name: string;\r\n public readonly schemaKey: SchemaKey;\r\n public readonly containerFullName: string;\r\n constructor(name: string, container: CustomAttributeContainerProps) {\r\n this.name = name;\r\n this.schemaKey = container.schema.schemaKey;\r\n this.containerFullName = container.fullName;\r\n }\r\n}\r\n\r\n/**\r\n * An IRelationshipConstraintIdentifier implementation to identify RelationshipConstraints.\r\n * @alpha\r\n */\r\nexport class RelationshipConstraintId implements IRelationshipConstraintIdentifier {\r\n public readonly typeIdentifier = SchemaTypeIdentifiers.RelationshipConstraintIdentifier;\r\n public readonly name: string;\r\n public readonly relationshipKey: SchemaItemKey;\r\n public readonly schemaKey: SchemaKey;\r\n constructor(constraint: RelationshipConstraint) {\r\n this.name = constraint.isSource ? \"Source\" : \"Target\";\r\n this.relationshipKey = constraint.relationshipClass.key;\r\n this.schemaKey = this.relationshipKey.schemaKey;\r\n }\r\n}\r\n\r\n/**\r\n * An exception class for the ecschema-editing API. Contains identifiers for schema types involved in the\r\n * exception. An example being SchemaItemId which contains the name of the SchemaItem, SchemaItemKey, SchemaItemType, etc.\r\n * Typically will contain an innerError of type SchemaEditingError containing the identifier of the schema item that\r\n * caused the exception. The containing error instance will identify the method called (identified by the errorNumber)\r\n * and the identifier of the schema item being modified/created.\r\n * @alpha\r\n */\r\nexport class SchemaEditingError extends Error {\r\n private _ruleViolations?: AnyDiagnostic[];\r\n private _schemaKey: SchemaKey;\r\n\r\n /**\r\n * Constructs a new SchemaEditingError instance.\r\n * @param errorNumber The unique ECEditingStatus code identifying the error.\r\n * @param identifier The identifier instance containing information about the EC object involved with the exception.\r\n * @param innerError The SchemaEditingError containing the identifier of the EC object that caused the initial exception.\r\n * @param ruleViolations Will contain EC rule violations of type [[AnyDiagnostic]] for exceptions with the error code ECEditingStatus.RuleViolation.\r\n * @param message Optional error message. Most messages on automatically generated by this class based on the ECEditingStatus code.\r\n */\r\n public constructor(public readonly errorNumber: ECEditingStatus, public readonly identifier: AnyIdentifier, public readonly innerError?: AnyEditingError, ruleViolations?: AnyDiagnostic[], message?: string) {\r\n super(message);\r\n this._ruleViolations = ruleViolations;\r\n this._schemaKey = identifier.schemaKey,\r\n this.generateMessage();\r\n }\r\n\r\n /**\r\n * Gets the SchemaId instance.\r\n * @throws Error if the identifier is not an instance of SchemaId.\r\n */\r\n private get _schemaId(): SchemaId {\r\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.SchemaIdentifier)\r\n throw new Error(\"identifier is not a SchemaId.\");\r\n return this.identifier as SchemaId;\r\n }\r\n\r\n /**\r\n * Gets the SchemaItemId instance.\r\n * @throws Error if the identifier is not an instance of SchemaItemId.\r\n */\r\n private get _schemaItemId(): SchemaItemId {\r\n if (this.isSchemaItemIdentifier(this.identifier))\r\n throw new Error(\"identifier is not a SchemaItemId.\");\r\n return this.identifier as SchemaItemId;\r\n }\r\n\r\n /**\r\n * Gets the ClassId instance.\r\n * @throws Error if the identifier is not an instance of ClassId.\r\n */\r\n private get _classId(): ClassId {\r\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.ClassIdentifier)\r\n throw new Error(\"identifier is not a ClassId.\");\r\n return this.identifier as ClassId;\r\n }\r\n\r\n /**\r\n * Gets the PropertyId instance.\r\n * @throws Error if the identifier is not an instance of PropertyId.\r\n */\r\n private get _propertyId(): PropertyId {\r\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.PropertyIdentifier)\r\n throw new Error(\"identifier is not a PropertyId.\");\r\n return this.identifier;\r\n }\r\n\r\n /**\r\n * Gets the EnumeratorId instance.\r\n * @throws Error if the identifier is not an instance of EnumeratorId.\r\n */\r\n private get _enumeratorId(): EnumeratorId {\r\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.EnumeratorIdentifier)\r\n throw new Error(\"identifier is not a EnumerationId.\");\r\n return this.identifier as EnumeratorId;\r\n }\r\n\r\n /**\r\n * Gets the CustomAttributeId instance.\r\n * @throws Error if the identifier is not an instance of CustomAttributeId.\r\n */\r\n private get _customAttributeId(): CustomAttributeId {\r\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.CustomAttributeIdentifier)\r\n throw new Error(\"identifier is not a CustomAttributeId.\");\r\n return this.identifier;\r\n }\r\n\r\n /**\r\n * Gets the RelationshipConstraintId instance.\r\n * @throws Error if the identifier is not an instance of RelationshipConstraintId.\r\n */\r\n private get _relationshipConstraintId(): RelationshipConstraintId {\r\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.RelationshipConstraintIdentifier)\r\n throw new Error(\"identifier is not a RelationshipConstraintId.\");\r\n return this.identifier;\r\n }\r\n\r\n /** Gets rule violations that were reported during validation. Returns an array of [[AnyDiagnostic]] if\r\n * the errorNumber is ECEditingStatus.RuleViolation, otherwise undefined.\r\n */\r\n public get ruleViolations(): AnyDiagnostic[] | undefined {\r\n return this._ruleViolations;\r\n }\r\n\r\n /**\r\n * Returns a readable string containing the ECEditingStatus along with the error message. Any\r\n * innerError will also be appended.\r\n * @returns\r\n */\r\n public toDebugString(): string {\r\n let innerMessage = \"\";\r\n if (this.innerError) {\r\n if (this.innerError instanceof SchemaEditingError)\r\n innerMessage = ` Inner error: ${this.innerError.toDebugString()}`;\r\n else\r\n innerMessage = ` Inner error: ${this.innerError.message}`;\r\n }\r\n return this._appendMessage(`ECEditingStatus.${ECEditingStatus[this.errorNumber]}`) + innerMessage;\r\n }\r\n\r\n private generateMessage() {\r\n if (this.message)\r\n return;\r\n\r\n switch(this.errorNumber) {\r\n case ECEditingStatus.SchemaNotFound:\r\n this.message = `Schema Key ${this._schemaKey.toString(true)} could not be found in the context.`;\r\n return;\r\n case ECEditingStatus.SchemaItemNotFound:\r\n this.message = `${this._schemaItemId.schemaItemType} ${this._schemaItemId.name} could not be found in the schema ${this._schemaKey.name}.`;\r\n return;\r\n case ECEditingStatus.SchemaItemNotFoundInContext:\r\n this.message = `${this._schemaItemId.schemaItemType} ${this._schemaItemId.name} could not be found in the schema context.`;\r\n return;\r\n case ECEditingStatus.InvalidSchemaItemType:\r\n this.message = `Expected ${this._schemaItemId.name} to be of type ${this._schemaItemId.schemaItemType}.`;\r\n return;\r\n case ECEditingStatus.SchemaItemNameNotSpecified:\r\n this.message = `Could not create a new ${this._schemaItemId.schemaItemType} in schema ${this._schemaKey.name}. No name was supplied within props.`;\r\n return;\r\n case ECEditingStatus.SchemaItemNameAlreadyExists:\r\n this.message = `${this._schemaItemId.schemaItemType} ${this._schemaItemId.name} already exists in the schema ${this._schemaKey.name}.`;\r\n return;\r\n case ECEditingStatus.RuleViolation:\r\n this.message = this._getRuleViolationMessage();\r\n return;\r\n case ECEditingStatus.PropertyNotFound:\r\n this.message = `An ECProperty with the name ${this._propertyId.name} could not be found in the class ${this._propertyId.ecClass.name}.`;\r\n return;\r\n case ECEditingStatus.PropertyAlreadyExists:\r\n this.message = `An ECProperty with the name ${this._propertyId.name} already exists in the class ${this._propertyId.ecClass.name}.`;\r\n return;\r\n case ECEditingStatus.InvalidPropertyType:\r\n this.message = `Expected property ${this._propertyId.name} to be of type ${this._propertyId.typeName}.`;\r\n return;\r\n case ECEditingStatus.BaseClassIsNotElement:\r\n this.message = `Expected base class ${this._schemaItemId.name} to derive from BisCore.Element.`;\r\n return;\r\n case ECEditingStatus.BaseClassIsNotElementUniqueAspect:\r\n this.message = `Expected base class ${this._schemaItemId.name} to derive from BisCore.ElementUniqueAspect.`;\r\n return;\r\n case ECEditingStatus.BaseClassIsNotElementMultiAspect:\r\n this.message = `Expected base class ${this._schemaItemId.name} to derive from BisCore.ElementMultiAspect.`;\r\n return;\r\n case ECEditingStatus.InvalidFormatUnitsSpecified:\r\n this.message = `The specified Format unit ${this._schemaItemId.name} is not of type Unit or InvertedUnit`;\r\n return;\r\n case ECEditingStatus.InvalidEnumeratorType:\r\n this.message = `The Enumeration ${this._enumeratorId.enumeration.fullName} has type ${this._enumeratorId.enumerationType}, while Enumerator ${this._enumeratorId.name} has type ${this._enumeratorId.enumeratorType}.`;\r\n return;\r\n case ECEditingStatus.EnumeratorDoesNotExist:\r\n this.message = `Enumerator ${this._enumeratorId.name} does not exists in Enumeration ${this._enumeratorId.enumeration.name}.`;\r\n return;\r\n case ECEditingStatus.InvalidECName:\r\n this.message = `Could not rename class ${this._schemaItemId.name} because the specified name is not a valid ECName.`;\r\n return;\r\n case ECEditingStatus.InvalidSchemaAlias:\r\n this.message = `Could not set the alias for schema ${this._schemaKey.name} because the specified alias is not a valid ECName.`;\r\n return;\r\n default:\r\n this.message = this._createTaskErrorMessage();\r\n }\r\n }\r\n\r\n private _appendMessage(e: string) {\r\n return this.message ? `${e}: ${this.message}` : e;\r\n }\r\n\r\n private _getRuleViolationMessage(): string {\r\n if (!this._ruleViolations)\r\n return \"\";\r\n\r\n let violations = \"\";\r\n for (const diagnostic of this._ruleViolations) {\r\n violations += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n switch (this.identifier.typeIdentifier) {\r\n case SchemaTypeIdentifiers.SchemaIdentifier:\r\n return `Rule violations occurred from Schema ${this._schemaId.name}: ${violations}`;\r\n case SchemaTypeIdentifiers.SchemaItemIdentifier:\r\n return `Rule violations occurred from ${this._schemaItemId.schemaItemType} ${this._schemaItemId.name}: ${violations}`;\r\n case SchemaTypeIdentifiers.ClassIdentifier:\r\n return `Rule violations occurred from ${this._schemaItemId.schemaItemType} ${this._schemaItemId.name}: ${violations}`;\r\n case SchemaTypeIdentifiers.CustomAttributeIdentifier:\r\n return `Rule violations occurred from CustomAttribute ${this._customAttributeId.name}, container ${this._customAttributeId.containerFullName}: ${violations}`;\r\n case SchemaTypeIdentifiers.RelationshipConstraintIdentifier:\r\n return `Rule violations occurred from ${this._relationshipConstraintId.name} constraint of RelationshipClass ${this._relationshipConstraintId.relationshipKey.fullName}: ${violations}`;\r\n default:\r\n throw new Error (\"Invalid identifier.\");\r\n }\r\n }\r\n\r\n private _createTaskErrorMessage() {\r\n // Make sure we have an inner error or else it is not a task error\r\n if (!this.innerError)\r\n return \"\";\r\n\r\n switch (this.identifier.typeIdentifier) {\r\n case SchemaTypeIdentifiers.SchemaIdentifier:\r\n case SchemaTypeIdentifiers.SchemaItemIdentifier:\r\n case SchemaTypeIdentifiers.ClassIdentifier:\r\n case SchemaTypeIdentifiers.RelationshipConstraintIdentifier:\r\n return `While performing task '${ECEditingStatus[this.errorNumber]}' an error occurred editing ${this.identifier.typeIdentifier} ${this.identifier.name}.`;\r\n case SchemaTypeIdentifiers.PropertyIdentifier:\r\n return `While performing task '${ECEditingStatus[this.errorNumber]}' an error occurred editing ${this.identifier.typeIdentifier} ${this.identifier.fullName}.`;\r\n default:\r\n throw new Error (\"Invalid identifier.\");\r\n }\r\n }\r\n\r\n private isSchemaItemIdentifier(identifier: AnyIdentifier) {\r\n if (identifier.typeIdentifier !== SchemaTypeIdentifiers.SchemaItemIdentifier &&\r\n identifier.typeIdentifier !== SchemaTypeIdentifiers.ClassIdentifier)\r\n return true;\r\n\r\n return false;\r\n }\r\n}\r\n\r\nfunction getEnumeratorType(enumeration: Enumeration, enumerator: AnyEnumerator | string) {\r\n if (typeof(enumerator) === \"string\") {\r\n return enumeration.type ? primitiveTypeToString(enumeration.type) : \"string\";\r\n }\r\n\r\n return typeof(enumerator.value) === \"string\" ? \"string\" : \"int\";\r\n}\r\n"]}
1
+ {"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../../src/Editing/Ex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wB,EAAE,UAAkC;IACrF,IAAI,OAAM,CAAC,UAAU,CAAC,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC/E,CAAC;IAED,OAAO,OAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;AAClE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\nimport { AnyEnumerator, CustomAttributeContainerProps, Enumeration, PrimitiveType, primitiveTypeToString, Property, RelationshipConstraint, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\n\n/** @alpha */\nexport enum ECEditingStatus {\n EC_EDITING_ERROR_BASE = 0x30000,\n Unknown = 0,\n RuleViolation = EC_EDITING_ERROR_BASE + 1,\n SchemaNotFound,\n SchemaItemNotFound,\n SchemaItemNotFoundInContext,\n PropertyAlreadyExists,\n PropertyNotFound,\n InvalidPropertyType,\n BaseClassIsNotElement,\n BaseClassIsNotElementUniqueAspect,\n BaseClassIsNotElementMultiAspect,\n SchemaItemNameNotSpecified,\n InvalidSchemaItemType,\n SchemaItemNameAlreadyExists,\n InvalidEnumeratorType,\n InvalidBaseClass,\n EnumeratorDoesNotExist,\n InvalidECName,\n InvalidSchemaAlias,\n InvalidFormatUnitsSpecified,\n SchemaAliasAlreadyExists,\n // Outer Errors\n CreateSchemaItemFailed,\n CreateSchemaItemFromProps,\n CreateElement,\n CreateElementUniqueAspect,\n CreateElementMultiAspect,\n SetBaseClass,\n SetSourceConstraint,\n SetTargetConstraint,\n AddConstraintClass,\n RemoveConstraintClass,\n SetAbstractConstraint,\n AddCustomAttributeToConstraint,\n AddCustomAttributeToProperty,\n AddCustomAttributeToClass,\n CreateNavigationProperty,\n CreateNavigationPropertyFromProps,\n SetInvertsUnit,\n SetUnitSystem,\n SetDescription,\n SetLabel,\n SetIsReadOnly,\n SetPriority,\n SetCategory,\n SetKindOfQuantity,\n SetMinOccurs,\n SetMaxOccurs,\n SetExtendedTypeName,\n SetMinLength,\n SetMaxLength,\n SetMinValue,\n SetMaxValue,\n SetPropertyName,\n AddMixin,\n AddEnumerator,\n SetEnumeratorLabel,\n SetEnumeratorDescription,\n AddPresentationUnit,\n AddPresentationOverride,\n CreateFormatOverride,\n SetPropertyCategoryPriority,\n CreatePrimitiveProperty,\n CreatePrimitivePropertyFromProps,\n CreateEnumerationProperty,\n CreateEnumerationPropertyFromProps,\n CreatePrimitiveArrayProperty,\n CreatePrimitiveArrayPropertyFromProps,\n CreateEnumerationArrayProperty,\n CreateEnumerationArrayPropertyFromProps,\n CreateStructProperty,\n CreateStructPropertyFromProps,\n CreateStructArrayProperty,\n CreateStructArrayPropertyFromProps,\n DeleteProperty,\n DeleteClass,\n SetClassName,\n AddSchemaReference,\n SetSchemaVersion,\n IncrementSchemaMinorVersion,\n SetSchemaAlias\n}\n\n/**\n * A type that constrains the possible error types handled by SchemaEditingError\n * @alpha\n */\nexport type AnyEditingError = SchemaEditingError | Error;\n\n/**\n * Defines the possible property type names.\n * @alpha\n */\nexport enum PropertyTypeName {\n ArrayProperty = \"ArrayProperty\",\n PrimitiveProperty = \"PrimitiveProperty\",\n EnumerationProperty = \"EnumerationProperty\",\n NavigationProperty = \"NavigationProperty\",\n StructProperty = \"StructProperty\"\n}\n\n/**\n * Defines the possible schema type identifiers.\n * @alpha\n */\nexport enum SchemaTypeIdentifiers {\n SchemaIdentifier = \"Schema\",\n SchemaItemIdentifier = \"SchemaItem\",\n ClassIdentifier = \"Class\",\n PropertyIdentifier = \"Property\",\n EnumeratorIdentifier = \"Enumerator\",\n CustomAttributeIdentifier = \"CustomAttribute\",\n RelationshipConstraintIdentifier = \"RelationshipConstraint\"\n}\n\n/**\n * Type that constrains SchemaItemType enum to those used by EC Class types.\n * @alpha\n */\nexport type ECClassSchemaItems = SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.RelationshipClass | SchemaItemType.Mixin | SchemaItemType.CustomAttributeClass;\n\n/**\n * Type that defines the possible SchemaTypeIdentifiers for SchemaItemId classes.\n * @alpha\n */\nexport type AnySchemaItemTypeIdentifier = SchemaTypeIdentifiers.SchemaItemIdentifier | SchemaTypeIdentifiers.ClassIdentifier;\n\n/**\n * Type that encompasses all ISchemaTypeIdentifier interfaces\n * @alpha\n */\nexport type AnyIdentifier = ISchemaIdentifier | ISchemaItemIdentifier | IClassIdentifier | IPropertyIdentifier | ICustomAttributeIdentifier | IRelationshipConstraintIdentifier | IEnumeratorIdentifier;\n\n/**\n * A base interface that defines what is needed to identity any schema type.\n * @alpha\n */\nexport interface ISchemaTypeIdentifier {\n readonly name: string;\n readonly schemaKey: SchemaKey;\n readonly typeIdentifier: SchemaTypeIdentifiers;\n}\n\n/**\n * Interface that defines the data needed to identify a Schema.\n * @alpha\n */\nexport interface ISchemaIdentifier extends ISchemaTypeIdentifier {\n readonly typeIdentifier: SchemaTypeIdentifiers.SchemaIdentifier;\n}\n\n/**\n * Interface that defines the data needed to identify a SchemaItem.\n * @alpha\n */\nexport interface ISchemaItemIdentifier extends ISchemaTypeIdentifier {\n readonly schemaItemType: SchemaItemType;\n readonly schemaItemKey: SchemaItemKey;\n readonly typeIdentifier: AnySchemaItemTypeIdentifier;\n}\n\n/**\n * Interface that defines the data needed to identify an EC Class.\n * @alpha\n */\nexport interface IClassIdentifier extends ISchemaTypeIdentifier {\n readonly schemaItemType: ECClassSchemaItems;\n readonly schemaItemKey: SchemaItemKey;\n readonly typeIdentifier: SchemaTypeIdentifiers.ClassIdentifier;\n}\n\n/**\n * Interface that defines the data needed to identify an EC Property.\n * @alpha\n */\nexport interface IPropertyIdentifier extends ISchemaTypeIdentifier {\n readonly fullName: string;\n readonly ecClass: ClassId;\n readonly typeName?: PropertyTypeName;\n readonly typeIdentifier: SchemaTypeIdentifiers.PropertyIdentifier;\n}\n\n/**\n * Interface that defines the data needed to identify an Enumerator.\n * @alpha\n */\ninterface IEnumeratorIdentifier extends ISchemaTypeIdentifier {\n readonly enumeratorType: string;\n readonly enumeration: SchemaItemKey;\n readonly enumerationType: string;\n readonly typeIdentifier: SchemaTypeIdentifiers.EnumeratorIdentifier;\n}\n\n/**\n * Interface that defines the data needed to identify a CustomAttribute.\n * @alpha\n */\nexport interface ICustomAttributeIdentifier extends ISchemaTypeIdentifier {\n readonly containerFullName: string;\n readonly typeIdentifier: SchemaTypeIdentifiers.CustomAttributeIdentifier;\n}\n\n/**\n * Interface that defines the data needed to identify a RelationshipConstraint.\n * @alpha\n */\nexport interface IRelationshipConstraintIdentifier extends ISchemaTypeIdentifier {\n readonly relationshipKey: SchemaItemKey;\n readonly typeIdentifier: SchemaTypeIdentifiers.RelationshipConstraintIdentifier;\n}\n\n/**\n * An ISchemaIdentifier implementation to identify Schemas\n * @alpha\n */\nexport class SchemaId implements ISchemaIdentifier {\n public readonly typeIdentifier = SchemaTypeIdentifiers.SchemaIdentifier;\n public readonly name: string;\n public readonly schemaKey: SchemaKey;\n constructor(schemaKey: SchemaKey) {\n this.name = schemaKey.name;\n this.schemaKey = schemaKey;\n }\n}\n\n/**\n * An ISchemItemIdentifier implementation to identify SchemaItems\n * @alpha\n */\nexport class SchemaItemId implements ISchemaItemIdentifier {\n public readonly typeIdentifier: AnySchemaItemTypeIdentifier;\n public readonly name: string;\n public readonly schemaKey: SchemaKey;\n public readonly schemaItemType: SchemaItemType;\n public readonly schemaItemKey: SchemaItemKey;\n\n constructor(schemaItemType: SchemaItemType, schemaItemKeyOrName: SchemaItemKey | string, schemaKey?: SchemaKey) {\n if (typeof(schemaItemKeyOrName) === \"string\") {\n if (!schemaKey)\n throw new Error(\"schemaKey if required if the specified schemaItem the name of the schema item.\");\n\n this.schemaKey = schemaKey!;\n this.schemaItemKey = new SchemaItemKey(schemaItemKeyOrName, schemaKey);\n } else {\n this.schemaKey = schemaItemKeyOrName.schemaKey;\n this.schemaItemKey = schemaItemKeyOrName;\n }\n\n this.schemaItemType = schemaItemType;\n this.name = this.schemaItemKey.fullName;\n this.typeIdentifier = SchemaTypeIdentifiers.SchemaItemIdentifier;\n }\n}\n\n/**\n * An IClassIdentifier implementation to identify Class instances.\n * @alpha\n */\nexport class ClassId extends SchemaItemId implements IClassIdentifier {\n public override readonly typeIdentifier = SchemaTypeIdentifiers.ClassIdentifier;\n public override readonly schemaItemType: ECClassSchemaItems;\n constructor(schemaItemType: ECClassSchemaItems, schemaItemKeyOrName: SchemaItemKey | string, schemaKey?: SchemaKey) {\n super(schemaItemType, schemaItemKeyOrName, schemaKey);\n this.schemaItemType = schemaItemType;\n }\n}\n\n/**\n * An IPropertyIdentifier implementation to identify Property instances.\n * @alpha\n */\nexport class PropertyId implements IPropertyIdentifier {\n public readonly typeIdentifier = SchemaTypeIdentifiers.PropertyIdentifier;\n public readonly name: string;\n public readonly fullName: string;\n public readonly ecClass: ClassId;\n public readonly schemaKey: SchemaKey;\n public readonly typeName?: PropertyTypeName;\n\n constructor(schemaItemType: ECClassSchemaItems, classKey: SchemaItemKey, property: Property | string, typeName?: PropertyTypeName) {\n this.name = property instanceof Property ? property.name : property;\n this.fullName = property instanceof Property ? property.fullName : `${classKey.name}.${property}`;\n this.ecClass = new ClassId(schemaItemType, classKey);\n this.schemaKey = classKey.schemaKey;\n this.typeName = typeName;\n }\n}\n\n/**\n * An IEnumeratorIdentifier implementation to identify Enumerator instances.\n * @alpha\n */\nexport class EnumeratorId implements IEnumeratorIdentifier{\n public readonly typeIdentifier = SchemaTypeIdentifiers.EnumeratorIdentifier;\n public readonly enumeration: SchemaItemKey;\n public readonly enumerationType: string;\n public readonly enumeratorType: string;\n public readonly name: string;\n public readonly schemaKey: SchemaKey;\n\n constructor(enumerator: AnyEnumerator | string, enumeration: Enumeration) {\n this.enumeration = enumeration.key;\n this.enumerationType = enumeration.type ? primitiveTypeToString(enumeration.type): \"string\";\n this.enumeratorType = getEnumeratorType(enumeration ?? PrimitiveType.String, enumerator);\n this.name = typeof(enumerator) === \"string\" ? enumerator : enumerator.name;\n this.schemaKey = enumeration.schema.schemaKey;\n }\n}\n\n/**\n * An ICustomAttributeIdentifier implementation to identify CustomAttribute instances.\n * @alpha\n */\nexport class CustomAttributeId implements ICustomAttributeIdentifier {\n public readonly typeIdentifier = SchemaTypeIdentifiers.CustomAttributeIdentifier;\n public readonly name: string;\n public readonly schemaKey: SchemaKey;\n public readonly containerFullName: string;\n constructor(name: string, container: CustomAttributeContainerProps) {\n this.name = name;\n this.schemaKey = container.schema.schemaKey;\n this.containerFullName = container.fullName;\n }\n}\n\n/**\n * An IRelationshipConstraintIdentifier implementation to identify RelationshipConstraints.\n * @alpha\n */\nexport class RelationshipConstraintId implements IRelationshipConstraintIdentifier {\n public readonly typeIdentifier = SchemaTypeIdentifiers.RelationshipConstraintIdentifier;\n public readonly name: string;\n public readonly relationshipKey: SchemaItemKey;\n public readonly schemaKey: SchemaKey;\n constructor(constraint: RelationshipConstraint) {\n this.name = constraint.isSource ? \"Source\" : \"Target\";\n this.relationshipKey = constraint.relationshipClass.key;\n this.schemaKey = this.relationshipKey.schemaKey;\n }\n}\n\n/**\n * An exception class for the ecschema-editing API. Contains identifiers for schema types involved in the\n * exception. An example being SchemaItemId which contains the name of the SchemaItem, SchemaItemKey, SchemaItemType, etc.\n * Typically will contain an innerError of type SchemaEditingError containing the identifier of the schema item that\n * caused the exception. The containing error instance will identify the method called (identified by the errorNumber)\n * and the identifier of the schema item being modified/created.\n * @alpha\n */\nexport class SchemaEditingError extends Error {\n private _ruleViolations?: AnyDiagnostic[];\n private _schemaKey: SchemaKey;\n\n /**\n * Constructs a new SchemaEditingError instance.\n * @param errorNumber The unique ECEditingStatus code identifying the error.\n * @param identifier The identifier instance containing information about the EC object involved with the exception.\n * @param innerError The SchemaEditingError containing the identifier of the EC object that caused the initial exception.\n * @param ruleViolations Will contain EC rule violations of type [[AnyDiagnostic]] for exceptions with the error code ECEditingStatus.RuleViolation.\n * @param message Optional error message. Most messages on automatically generated by this class based on the ECEditingStatus code.\n */\n public constructor(public readonly errorNumber: ECEditingStatus, public readonly identifier: AnyIdentifier, public readonly innerError?: AnyEditingError, ruleViolations?: AnyDiagnostic[], message?: string) {\n super(message);\n this._ruleViolations = ruleViolations;\n this._schemaKey = identifier.schemaKey,\n this.generateMessage();\n }\n\n /**\n * Gets the SchemaId instance.\n * @throws Error if the identifier is not an instance of SchemaId.\n */\n private get _schemaId(): SchemaId {\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.SchemaIdentifier)\n throw new Error(\"identifier is not a SchemaId.\");\n return this.identifier as SchemaId;\n }\n\n /**\n * Gets the SchemaItemId instance.\n * @throws Error if the identifier is not an instance of SchemaItemId.\n */\n private get _schemaItemId(): SchemaItemId {\n if (this.isSchemaItemIdentifier(this.identifier))\n throw new Error(\"identifier is not a SchemaItemId.\");\n return this.identifier as SchemaItemId;\n }\n\n /**\n * Gets the ClassId instance.\n * @throws Error if the identifier is not an instance of ClassId.\n */\n private get _classId(): ClassId {\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.ClassIdentifier)\n throw new Error(\"identifier is not a ClassId.\");\n return this.identifier as ClassId;\n }\n\n /**\n * Gets the PropertyId instance.\n * @throws Error if the identifier is not an instance of PropertyId.\n */\n private get _propertyId(): PropertyId {\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.PropertyIdentifier)\n throw new Error(\"identifier is not a PropertyId.\");\n return this.identifier;\n }\n\n /**\n * Gets the EnumeratorId instance.\n * @throws Error if the identifier is not an instance of EnumeratorId.\n */\n private get _enumeratorId(): EnumeratorId {\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.EnumeratorIdentifier)\n throw new Error(\"identifier is not a EnumerationId.\");\n return this.identifier as EnumeratorId;\n }\n\n /**\n * Gets the CustomAttributeId instance.\n * @throws Error if the identifier is not an instance of CustomAttributeId.\n */\n private get _customAttributeId(): CustomAttributeId {\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.CustomAttributeIdentifier)\n throw new Error(\"identifier is not a CustomAttributeId.\");\n return this.identifier;\n }\n\n /**\n * Gets the RelationshipConstraintId instance.\n * @throws Error if the identifier is not an instance of RelationshipConstraintId.\n */\n private get _relationshipConstraintId(): RelationshipConstraintId {\n if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.RelationshipConstraintIdentifier)\n throw new Error(\"identifier is not a RelationshipConstraintId.\");\n return this.identifier;\n }\n\n /** Gets rule violations that were reported during validation. Returns an array of [[AnyDiagnostic]] if\n * the errorNumber is ECEditingStatus.RuleViolation, otherwise undefined.\n */\n public get ruleViolations(): AnyDiagnostic[] | undefined {\n return this._ruleViolations;\n }\n\n /**\n * Returns a readable string containing the ECEditingStatus along with the error message. Any\n * innerError will also be appended.\n * @returns\n */\n public toDebugString(): string {\n let innerMessage = \"\";\n if (this.innerError) {\n if (this.innerError instanceof SchemaEditingError)\n innerMessage = ` Inner error: ${this.innerError.toDebugString()}`;\n else\n innerMessage = ` Inner error: ${this.innerError.message}`;\n }\n return this._appendMessage(`ECEditingStatus.${ECEditingStatus[this.errorNumber]}`) + innerMessage;\n }\n\n private generateMessage() {\n if (this.message)\n return;\n\n switch(this.errorNumber) {\n case ECEditingStatus.SchemaNotFound:\n this.message = `Schema Key ${this._schemaKey.toString(true)} could not be found in the context.`;\n return;\n case ECEditingStatus.SchemaItemNotFound:\n this.message = `${this._schemaItemId.schemaItemType} ${this._schemaItemId.name} could not be found in the schema ${this._schemaKey.name}.`;\n return;\n case ECEditingStatus.SchemaItemNotFoundInContext:\n this.message = `${this._schemaItemId.schemaItemType} ${this._schemaItemId.name} could not be found in the schema context.`;\n return;\n case ECEditingStatus.InvalidSchemaItemType:\n this.message = `Expected ${this._schemaItemId.name} to be of type ${this._schemaItemId.schemaItemType}.`;\n return;\n case ECEditingStatus.SchemaItemNameNotSpecified:\n this.message = `Could not create a new ${this._schemaItemId.schemaItemType} in schema ${this._schemaKey.name}. No name was supplied within props.`;\n return;\n case ECEditingStatus.SchemaItemNameAlreadyExists:\n this.message = `${this._schemaItemId.schemaItemType} ${this._schemaItemId.name} already exists in the schema ${this._schemaKey.name}.`;\n return;\n case ECEditingStatus.RuleViolation:\n this.message = this._getRuleViolationMessage();\n return;\n case ECEditingStatus.PropertyNotFound:\n this.message = `An ECProperty with the name ${this._propertyId.name} could not be found in the class ${this._propertyId.ecClass.name}.`;\n return;\n case ECEditingStatus.PropertyAlreadyExists:\n this.message = `An ECProperty with the name ${this._propertyId.name} already exists in the class ${this._propertyId.ecClass.name}.`;\n return;\n case ECEditingStatus.InvalidPropertyType:\n this.message = `Expected property ${this._propertyId.name} to be of type ${this._propertyId.typeName}.`;\n return;\n case ECEditingStatus.BaseClassIsNotElement:\n this.message = `Expected base class ${this._schemaItemId.name} to derive from BisCore.Element.`;\n return;\n case ECEditingStatus.BaseClassIsNotElementUniqueAspect:\n this.message = `Expected base class ${this._schemaItemId.name} to derive from BisCore.ElementUniqueAspect.`;\n return;\n case ECEditingStatus.BaseClassIsNotElementMultiAspect:\n this.message = `Expected base class ${this._schemaItemId.name} to derive from BisCore.ElementMultiAspect.`;\n return;\n case ECEditingStatus.InvalidFormatUnitsSpecified:\n this.message = `The specified Format unit ${this._schemaItemId.name} is not of type Unit or InvertedUnit`;\n return;\n case ECEditingStatus.InvalidEnumeratorType:\n this.message = `The Enumeration ${this._enumeratorId.enumeration.fullName} has type ${this._enumeratorId.enumerationType}, while Enumerator ${this._enumeratorId.name} has type ${this._enumeratorId.enumeratorType}.`;\n return;\n case ECEditingStatus.EnumeratorDoesNotExist:\n this.message = `Enumerator ${this._enumeratorId.name} does not exists in Enumeration ${this._enumeratorId.enumeration.name}.`;\n return;\n case ECEditingStatus.InvalidECName:\n this.message = `Could not rename class ${this._schemaItemId.name} because the specified name is not a valid ECName.`;\n return;\n case ECEditingStatus.InvalidSchemaAlias:\n this.message = `Could not set the alias for schema ${this._schemaKey.name} because the specified alias is not a valid ECName.`;\n return;\n default:\n this.message = this._createTaskErrorMessage();\n }\n }\n\n private _appendMessage(e: string) {\n return this.message ? `${e}: ${this.message}` : e;\n }\n\n private _getRuleViolationMessage(): string {\n if (!this._ruleViolations)\n return \"\";\n\n let violations = \"\";\n for (const diagnostic of this._ruleViolations) {\n violations += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n switch (this.identifier.typeIdentifier) {\n case SchemaTypeIdentifiers.SchemaIdentifier:\n return `Rule violations occurred from Schema ${this._schemaId.name}: ${violations}`;\n case SchemaTypeIdentifiers.SchemaItemIdentifier:\n return `Rule violations occurred from ${this._schemaItemId.schemaItemType} ${this._schemaItemId.name}: ${violations}`;\n case SchemaTypeIdentifiers.ClassIdentifier:\n return `Rule violations occurred from ${this._schemaItemId.schemaItemType} ${this._schemaItemId.name}: ${violations}`;\n case SchemaTypeIdentifiers.CustomAttributeIdentifier:\n return `Rule violations occurred from CustomAttribute ${this._customAttributeId.name}, container ${this._customAttributeId.containerFullName}: ${violations}`;\n case SchemaTypeIdentifiers.RelationshipConstraintIdentifier:\n return `Rule violations occurred from ${this._relationshipConstraintId.name} constraint of RelationshipClass ${this._relationshipConstraintId.relationshipKey.fullName}: ${violations}`;\n default:\n throw new Error (\"Invalid identifier.\");\n }\n }\n\n private _createTaskErrorMessage() {\n // Make sure we have an inner error or else it is not a task error\n if (!this.innerError)\n return \"\";\n\n switch (this.identifier.typeIdentifier) {\n case SchemaTypeIdentifiers.SchemaIdentifier:\n case SchemaTypeIdentifiers.SchemaItemIdentifier:\n case SchemaTypeIdentifiers.ClassIdentifier:\n case SchemaTypeIdentifiers.RelationshipConstraintIdentifier:\n return `While performing task '${ECEditingStatus[this.errorNumber]}' an error occurred editing ${this.identifier.typeIdentifier} ${this.identifier.name}.`;\n case SchemaTypeIdentifiers.PropertyIdentifier:\n return `While performing task '${ECEditingStatus[this.errorNumber]}' an error occurred editing ${this.identifier.typeIdentifier} ${this.identifier.fullName}.`;\n default:\n throw new Error (\"Invalid identifier.\");\n }\n }\n\n private isSchemaItemIdentifier(identifier: AnyIdentifier) {\n if (identifier.typeIdentifier !== SchemaTypeIdentifiers.SchemaItemIdentifier &&\n identifier.typeIdentifier !== SchemaTypeIdentifiers.ClassIdentifier)\n return true;\n\n return false;\n }\n}\n\nfunction getEnumeratorType(enumeration: Enumeration, enumerator: AnyEnumerator | string) {\n if (typeof(enumerator) === \"string\") {\n return enumeration.type ? primitiveTypeToString(enumeration.type) : \"string\";\n }\n\n return typeof(enumerator.value) === \"string\" ? \"string\" : \"int\";\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Formats.js","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,YAAY,EAAwC,cAAc,EAAa,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIhK,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,OAAQ,SAAQ,WAAW;IACtC,IAAuB,aAAa;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAsB,EAAE,YAAqB,EAAE,KAAuB;QAC5H,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAS,SAAS,EA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O,SAAS,CAAC,GAAG,CAAC;QACvB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,sBAAsB,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,WAAkC;QACnF,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;YAClJ,OAAO,SAAS,CAAC,GAAG,CAAC;QACvB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,yBAAyB,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClJ,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { DelayedPromiseWithProps, Format, InvertedUnit, SchemaItemFormatProps, SchemaItemKey, SchemaItemType, SchemaKey, Unit } from \"@itwin/ecschema-metadata\";\r\nimport { FormatType } from \"@itwin/core-quantity\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutableFormat } from \"./Mutable/MutableFormat\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Format.\r\n */\r\nexport class Formats extends SchemaItems {\r\n protected override get itemTypeClass(): typeof Format {\r\n return Format;\r\n }\r\n\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.Format, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, formatType: FormatType, displayLabel?: string, units?: SchemaItemKey[]): Promise<SchemaItemKey> {\r\n try {\r\n const newFormat = await this.createSchemaItem<Format>(schemaKey, this.schemaItemType, (schema) => schema.createFormat.bind(schema), name) as MutableFormat;\r\n\r\n if (units !== undefined) {\r\n for (const unit of units) {\r\n const unitItem = await this.schemaEditor.schemaContext.getSchemaItem(unit);\r\n if (!unitItem) {\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFoundInContext, new SchemaItemId(SchemaItemType.Unit, unit));\r\n }\r\n\r\n if (Unit.isUnit(unitItem) ) {\r\n newFormat.addUnit(new DelayedPromiseWithProps(unitItem.key, async () => unitItem));\r\n } else if (InvertedUnit.isInvertedUnit(unitItem) ) {\r\n newFormat.addUnit(new DelayedPromiseWithProps(unitItem.key, async () => unitItem));\r\n } else {\r\n throw new SchemaEditingError(ECEditingStatus.InvalidFormatUnitsSpecified, new SchemaItemId(unitItem.schemaItemType, unitItem.key));\r\n }\r\n }\r\n }\r\n\r\n if (displayLabel)\r\n newFormat.setDisplayLabel(displayLabel);\r\n\r\n // TODO: Handle the setting of format traits, separators, etc....\r\n newFormat.setFormatType(formatType);\r\n return newFormat.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a format through a SchemaItemFormatProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, formatProps: SchemaItemFormatProps): Promise<SchemaItemKey> {\r\n try {\r\n const newFormat = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createFormat.bind(schema), formatProps);\r\n return newFormat.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, formatProps.name!, schemaKey), e);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Formats.js","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,YAAY,EAAwC,cAAc,EAAa,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIhK,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,OAAQ,SAAQ,WAAW;IACtC,IAAuB,aAAa;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAsB,EAAE,YAAqB,EAAE,KAAuB;QAC5H,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAS,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAkB,CAAC;YAE3J,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,MAAM,QAAQ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ED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,WAAkC;QACnF,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;YAClJ,OAAO,SAAS,CAAC,GAAG,CAAC;QACvB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,yBAAyB,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClJ,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, Format, InvertedUnit, SchemaItemFormatProps, SchemaItemKey, SchemaItemType, SchemaKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatType } from \"@itwin/core-quantity\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableFormat } from \"./Mutable/MutableFormat\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Format.\n */\nexport class Formats extends SchemaItems {\n protected override get itemTypeClass(): typeof Format {\n return Format;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Format, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, formatType: FormatType, displayLabel?: string, units?: SchemaItemKey[]): Promise<SchemaItemKey> {\n try {\n const newFormat = await this.createSchemaItem<Format>(schemaKey, this.schemaItemType, (schema) => schema.createFormat.bind(schema), name) as MutableFormat;\n\n if (units !== undefined) {\n for (const unit of units) {\n const unitItem = await this.schemaEditor.schemaContext.getSchemaItem(unit);\n if (!unitItem) {\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFoundInContext, new SchemaItemId(SchemaItemType.Unit, unit));\n }\n\n if (Unit.isUnit(unitItem) ) {\n newFormat.addUnit(new DelayedPromiseWithProps(unitItem.key, async () => unitItem));\n } else if (InvertedUnit.isInvertedUnit(unitItem) ) {\n newFormat.addUnit(new DelayedPromiseWithProps(unitItem.key, async () => unitItem));\n } else {\n throw new SchemaEditingError(ECEditingStatus.InvalidFormatUnitsSpecified, new SchemaItemId(unitItem.schemaItemType, unitItem.key));\n }\n }\n }\n\n if (displayLabel)\n newFormat.setDisplayLabel(displayLabel);\n\n // TODO: Handle the setting of format traits, separators, etc....\n newFormat.setFormatType(formatType);\n return newFormat.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n /**\n * Creates a format through a SchemaItemFormatProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, formatProps: SchemaItemFormatProps): Promise<SchemaItemKey> {\n try {\n const newFormat = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createFormat.bind(schema), formatProps);\n return newFormat.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, formatProps.name!, schemaKey), e);\n }\n }\n}\n"]}