@itwin/ecschema-editing 5.0.0-dev.8 → 5.0.0-dev.83

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 (196) hide show
  1. package/CHANGELOG.md +46 -1
  2. package/lib/cjs/Differencing/Errors.js +6 -0
  3. package/lib/cjs/Differencing/Errors.js.map +1 -1
  4. package/lib/cjs/Differencing/SchemaConflicts.d.ts +3 -1
  5. package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
  6. package/lib/cjs/Differencing/SchemaConflicts.js +2 -0
  7. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  8. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +4 -3
  9. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
  10. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +57 -11
  11. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  12. package/lib/cjs/Differencing/SchemaDifference.d.ts +33 -4
  13. package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
  14. package/lib/cjs/Differencing/SchemaDifference.js +55 -5
  15. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  16. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts +2 -1
  17. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
  18. package/lib/cjs/Differencing/SchemaDifferenceValidator.js +78 -19
  19. package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
  20. package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts.map +1 -1
  21. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js +5 -0
  22. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
  23. package/lib/cjs/Editing/Constants.d.ts +2 -1
  24. package/lib/cjs/Editing/Constants.d.ts.map +1 -1
  25. package/lib/cjs/Editing/Constants.js +4 -1
  26. package/lib/cjs/Editing/Constants.js.map +1 -1
  27. package/lib/cjs/Editing/CustomAttributes.d.ts +2 -1
  28. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  29. package/lib/cjs/Editing/CustomAttributes.js +3 -0
  30. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  31. package/lib/cjs/Editing/ECClasses.d.ts +6 -0
  32. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  33. package/lib/cjs/Editing/ECClasses.js +48 -35
  34. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  35. package/lib/cjs/Editing/Editor.d.ts +2 -2
  36. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  37. package/lib/cjs/Editing/Editor.js +32 -21
  38. package/lib/cjs/Editing/Editor.js.map +1 -1
  39. package/lib/cjs/Editing/Entities.d.ts +2 -1
  40. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  41. package/lib/cjs/Editing/Entities.js +18 -14
  42. package/lib/cjs/Editing/Entities.js.map +1 -1
  43. package/lib/cjs/Editing/Enumerations.d.ts +2 -1
  44. package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
  45. package/lib/cjs/Editing/Enumerations.js +6 -3
  46. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  47. package/lib/cjs/Editing/Exception.js +35 -6
  48. package/lib/cjs/Editing/Exception.js.map +1 -1
  49. package/lib/cjs/Editing/Formats.d.ts +2 -1
  50. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  51. package/lib/cjs/Editing/Formats.js +5 -1
  52. package/lib/cjs/Editing/Formats.js.map +1 -1
  53. package/lib/cjs/Editing/InvertedUnits.d.ts +2 -1
  54. package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
  55. package/lib/cjs/Editing/InvertedUnits.js +10 -6
  56. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  57. package/lib/cjs/Editing/KindOfQuantities.d.ts +2 -1
  58. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  59. package/lib/cjs/Editing/KindOfQuantities.js +11 -7
  60. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  61. package/lib/cjs/Editing/Mixins.d.ts +2 -1
  62. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  63. package/lib/cjs/Editing/Mixins.js +13 -9
  64. package/lib/cjs/Editing/Mixins.js.map +1 -1
  65. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +2 -1
  66. package/lib/cjs/Editing/Mutable/MutableClass.d.ts.map +1 -1
  67. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  68. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +8 -1
  69. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts.map +1 -1
  70. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  71. package/lib/cjs/Editing/Phenomena.d.ts +2 -1
  72. package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
  73. package/lib/cjs/Editing/Phenomena.js +3 -0
  74. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  75. package/lib/cjs/Editing/Properties.d.ts +2 -2
  76. package/lib/cjs/Editing/Properties.d.ts.map +1 -1
  77. package/lib/cjs/Editing/Properties.js +6 -4
  78. package/lib/cjs/Editing/Properties.js.map +1 -1
  79. package/lib/cjs/Editing/PropertyCategories.d.ts +2 -1
  80. package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
  81. package/lib/cjs/Editing/PropertyCategories.js +5 -1
  82. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  83. package/lib/cjs/Editing/RelationshipClasses.d.ts +1 -0
  84. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  85. package/lib/cjs/Editing/RelationshipClasses.js +17 -10
  86. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  87. package/lib/cjs/Editing/SchemaItems.d.ts +2 -2
  88. package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
  89. package/lib/cjs/Editing/SchemaItems.js +8 -11
  90. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  91. package/lib/cjs/Editing/Structs.d.ts +2 -1
  92. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  93. package/lib/cjs/Editing/Structs.js +3 -0
  94. package/lib/cjs/Editing/Structs.js.map +1 -1
  95. package/lib/cjs/Editing/UnitSystems.d.ts +2 -1
  96. package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
  97. package/lib/cjs/Editing/UnitSystems.js +3 -0
  98. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  99. package/lib/cjs/Editing/Units.d.ts +2 -1
  100. package/lib/cjs/Editing/Units.d.ts.map +1 -1
  101. package/lib/cjs/Editing/Units.js +5 -2
  102. package/lib/cjs/Editing/Units.js.map +1 -1
  103. package/lib/cjs/Merging/ConstantMerger.js +4 -4
  104. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  105. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  106. package/lib/cjs/Merging/CustomAttributeMerger.js +7 -6
  107. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  108. package/lib/cjs/Merging/Edits/NameMapping.d.ts +22 -0
  109. package/lib/cjs/Merging/Edits/NameMapping.d.ts.map +1 -0
  110. package/lib/cjs/Merging/Edits/NameMapping.js +54 -0
  111. package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -0
  112. package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts +1 -1
  113. package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -1
  114. package/lib/cjs/Merging/Edits/RenameEditHandler.js +1 -260
  115. package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
  116. package/lib/cjs/Merging/Edits/SchemaEdits.d.ts +9 -6
  117. package/lib/cjs/Merging/Edits/SchemaEdits.d.ts.map +1 -1
  118. package/lib/cjs/Merging/Edits/SchemaEdits.js +19 -14
  119. package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
  120. package/lib/cjs/Merging/EntityClassMerger.js +1 -2
  121. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  122. package/lib/cjs/Merging/EnumerationMerger.js +1 -1
  123. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  124. package/lib/cjs/Merging/EnumeratorMerger.d.ts.map +1 -1
  125. package/lib/cjs/Merging/EnumeratorMerger.js +2 -2
  126. package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
  127. package/lib/cjs/Merging/FormatMerger.d.ts +24 -0
  128. package/lib/cjs/Merging/FormatMerger.d.ts.map +1 -0
  129. package/lib/cjs/Merging/FormatMerger.js +143 -0
  130. package/lib/cjs/Merging/FormatMerger.js.map +1 -0
  131. package/lib/cjs/Merging/InvertedUnitMerger.d.ts +14 -0
  132. package/lib/cjs/Merging/InvertedUnitMerger.d.ts.map +1 -0
  133. package/lib/cjs/Merging/InvertedUnitMerger.js +45 -0
  134. package/lib/cjs/Merging/InvertedUnitMerger.js.map +1 -0
  135. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +1 -1
  136. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  137. package/lib/cjs/Merging/KindOfQuantityMerger.js +4 -5
  138. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  139. package/lib/cjs/Merging/MixinMerger.js +1 -1
  140. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  141. package/lib/cjs/Merging/PhenomenonMerger.js +1 -1
  142. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  143. package/lib/cjs/Merging/PropertyMerger.js +28 -26
  144. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  145. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
  146. package/lib/cjs/Merging/RelationshipClassMerger.js +4 -4
  147. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  148. package/lib/cjs/Merging/SchemaMerger.d.ts +5 -3
  149. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  150. package/lib/cjs/Merging/SchemaMerger.js +40 -5
  151. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  152. package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +14 -8
  153. package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
  154. package/lib/cjs/Merging/SchemaMergingVisitor.js +42 -17
  155. package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
  156. package/lib/cjs/Merging/SchemaMergingWalker.d.ts.map +1 -1
  157. package/lib/cjs/Merging/SchemaMergingWalker.js +2 -0
  158. package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
  159. package/lib/cjs/Merging/UnitMerger.d.ts +14 -0
  160. package/lib/cjs/Merging/UnitMerger.d.ts.map +1 -0
  161. package/lib/cjs/Merging/UnitMerger.js +62 -0
  162. package/lib/cjs/Merging/UnitMerger.js.map +1 -0
  163. package/lib/cjs/Merging/Utils.d.ts +11 -0
  164. package/lib/cjs/Merging/Utils.d.ts.map +1 -1
  165. package/lib/cjs/Merging/Utils.js +23 -3
  166. package/lib/cjs/Merging/Utils.js.map +1 -1
  167. package/lib/cjs/Validation/Diagnostic.js +18 -16
  168. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  169. package/lib/cjs/Validation/DiagnosticReporter.js +3 -0
  170. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  171. package/lib/cjs/Validation/ECRules.js +1 -1
  172. package/lib/cjs/Validation/ECRules.js.map +1 -1
  173. package/lib/cjs/Validation/SchemaChanges.js +39 -69
  174. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  175. package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +2 -2
  176. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  177. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +1 -1
  178. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts.map +1 -1
  179. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +4 -1
  180. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  181. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts.map +1 -1
  182. package/lib/cjs/Validation/SchemaCompareVisitor.js +23 -23
  183. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  184. package/lib/cjs/Validation/SchemaComparer.d.ts +22 -1
  185. package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
  186. package/lib/cjs/Validation/SchemaComparer.js +30 -5
  187. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  188. package/lib/cjs/Validation/SchemaValidater.js +1 -4
  189. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  190. package/lib/cjs/Validation/SchemaValidationVisitor.js +3 -4
  191. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  192. package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
  193. package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
  194. package/lib/cjs/Validation/SchemaWalker.js +4 -0
  195. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  196. package/package.json +16 -16
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.RelationshipClasses = void 0;
11
11
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
12
  const ECClasses_1 = require("./ECClasses");
13
+ const MutableRelationshipClass_1 = require("./Mutable/MutableRelationshipClass");
13
14
  const Rules = require("../Validation/ECRules");
14
15
  const Properties_1 = require("./Properties");
15
16
  const Exception_1 = require("./Exception");
@@ -18,13 +19,16 @@ const Exception_1 = require("./Exception");
18
19
  * A class extending ECClasses allowing you to create schema items of type RelationshipClass.
19
20
  */
20
21
  class RelationshipClasses extends ECClasses_1.ECClasses {
22
+ get itemTypeClass() {
23
+ return ecschema_metadata_1.RelationshipClass;
24
+ }
21
25
  constructor(schemaEditor) {
22
26
  super(ecschema_metadata_1.SchemaItemType.RelationshipClass, schemaEditor);
23
- /**
24
- * Allows access for editing of NavigationProperty attributes.
25
- */
26
- this.navigationProperties = new Properties_1.NavigationProperties(this.schemaItemType, this.schemaEditor);
27
27
  }
28
+ /**
29
+ * Allows access for editing of NavigationProperty attributes.
30
+ */
31
+ navigationProperties = new Properties_1.NavigationProperties(this.schemaItemType, this.schemaEditor);
28
32
  /**
29
33
  * Creates a RelationshipClass.
30
34
  * @param schemaKey a SchemaKey of the Schema that will house the new object.
@@ -51,7 +55,7 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
51
55
  * @param source The RelationshipConstraint to add.
52
56
  */
53
57
  async setSourceConstraint(relationshipKey, source) {
54
- const relationship = await this.getSchemaItem(relationshipKey)
58
+ const relationship = await this.getSchemaItem(relationshipKey, MutableRelationshipClass_1.MutableRelationshipClass)
55
59
  .catch((e) => {
56
60
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetSourceConstraint, new Exception_1.ClassId(this.schemaItemType, relationshipKey), e);
57
61
  });
@@ -63,7 +67,7 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
63
67
  * @param target The RelationshipConstraint to add.
64
68
  */
65
69
  async setTargetConstraint(relationshipKey, target) {
66
- const relationship = await this.getSchemaItem(relationshipKey)
70
+ const relationship = await this.getSchemaItem(relationshipKey, MutableRelationshipClass_1.MutableRelationshipClass)
67
71
  .catch((e) => {
68
72
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetTargetConstraint, new Exception_1.ClassId(this.schemaItemType, relationshipKey), e);
69
73
  });
@@ -91,20 +95,23 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
91
95
  * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.
92
96
  */
93
97
  async setBaseClass(itemKey, baseClassKey) {
94
- const relClass = await this.schemaEditor.schemaContext.getSchemaItem(itemKey);
98
+ const relClass = await this.schemaEditor.schemaContext.getSchemaItem(itemKey, ecschema_metadata_1.RelationshipClass)
99
+ .catch((e) => {
100
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetBaseClass, new Exception_1.ClassId(this.schemaItemType, itemKey), e);
101
+ });
95
102
  const baseClass = relClass?.baseClass;
96
103
  await super.setBaseClass(itemKey, baseClassKey);
97
104
  try {
98
105
  await this.validate(relClass);
99
106
  }
100
107
  catch (e) {
101
- relClass.baseClass = baseClass;
108
+ await relClass.setBaseClass(baseClass);
102
109
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetBaseClass, new Exception_1.ClassId(ecschema_metadata_1.SchemaItemType.RelationshipClass, itemKey), e);
103
110
  }
104
111
  }
105
112
  async createNavigationProperty(relationshipKey, name, relationship, direction) {
106
113
  try {
107
- const relationshipClass = await this.getSchemaItem(relationshipKey);
114
+ const relationshipClass = await this.getSchemaItem(relationshipKey, MutableRelationshipClass_1.MutableRelationshipClass);
108
115
  await relationshipClass.createNavigationProperty(name, relationship, direction);
109
116
  }
110
117
  catch (e) {
@@ -118,7 +125,7 @@ class RelationshipClasses extends ECClasses_1.ECClasses {
118
125
  */
119
126
  async createNavigationPropertyFromProps(relationshipKey, navigationProps) {
120
127
  try {
121
- const relationshipClass = await this.getSchemaItem(relationshipKey);
128
+ const relationshipClass = await this.getSchemaItem(relationshipKey, MutableRelationshipClass_1.MutableRelationshipClass);
122
129
  const property = await relationshipClass.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);
123
130
  await property.fromJSON(navigationProps);
124
131
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipClasses.js","sourceRoot":"","sources":["../../../src/Editing/RelationshipClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAIkC;AAElC,2CAAwC;AAExC,+CAA+C;AAE/C,6CAAoD;AACpD,2CAAwH;AAExH;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,qBAAS;IAChD,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;QAGxD;;WAEG;QACa,y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AC;QACjJ,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,wBAAoE;QACzF,IAAI,kBAA0I,CAAC;QAC/I,IAAI,eAAuC,CAAC;QAE5C,IAAI,wBAAwB,YAAY,qCAAiB,EAAE,CAAC;YAC1D,kBAAkB,GAAG,KAAK,CAAC,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;YAC1E,eAAe,GAAG,wBAAwB,CAAC,GAAG,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,kBAAkB,GAAG,KAAK,CAAC,8BAA8B,CAAC,wBAAwB,CAAC,CAAC;YACpF,eAAe,GAAG,wBAAwB,CAAC,iBAAiB,CAAC,GAAG,CAAC;QACnE,CAAC;QAED,MAAM,WAAW,GAAoB,EAAE,CAAC;QACxC,IAAI,KAAK,EAAE,MAAM,UAAU,IAAI,kBAAkB,EAAE,CAAC;YAClD,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,IAAI,wBAAwB,YAAY,qCAAiB,EAAE,CAAC;gBAC1D,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,aAAa,EAAE,IAAI,mBAAO,CAAC,kCAAc,CAAC,iBAAiB,EAAE,eAAe,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;YACtJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,aAAa,EAAE,IAAI,oCAAwB,CAAC,wBAAwB,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;YAC9I,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA3OD,kDA2OC","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, DelayedPromiseWithProps, ECClassModifier, EntityClass, LazyLoadedRelationshipConstraintClass, Mixin, NavigationPropertyProps,\n RelationshipClass, RelationshipClassProps, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, SchemaItemKey, SchemaItemType,\n SchemaKey, StrengthDirection, StrengthType,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableRelationshipClass, MutableRelationshipConstraint } from \"./Mutable/MutableRelationshipClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { AnyDiagnostic, RelationshipConstraintDiagnostic, SchemaItemDiagnostic } from \"../Validation/Diagnostic\";\nimport { NavigationProperties } from \"./Properties\";\nimport { ClassId, CustomAttributeId, ECEditingStatus, RelationshipConstraintId, SchemaEditingError } from \"./Exception\";\n\n/**\n * @alpha\n * A class extending ECClasses allowing you to create schema items of type RelationshipClass.\n */\nexport class RelationshipClasses extends ECClasses {\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.RelationshipClass, schemaEditor);\n }\n\n /**\n * Allows access for editing of NavigationProperty attributes.\n */\n public readonly navigationProperties = new NavigationProperties(this.schemaItemType, this.schemaEditor);\n\n /**\n * Creates a RelationshipClass.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param name The name of the new class.\n * @param modifier The ECClassModifier of the new class.\n * @param strength The relationship StrengthType of the class.\n * @param StrengthDirection The relationship StrengthDirection of the class.\n * @param baseClassKey An optional SchemaItemKey that specifies the base relationship class.\n */\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, strength: StrengthType, direction: StrengthDirection, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<RelationshipClass>(schemaKey, this.schemaItemType, (schema) => schema.createRelationshipClass.bind(schema), name, baseClassKey, modifier) as MutableRelationshipClass;\n\n newClass.setStrength(strength);\n newClass.setStrengthDirection(direction);\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 * Sets the source RelationshipConstraint on the relationship.\n * @param relationshipKey The SchemaItemKey for the relationship.\n * @param source The RelationshipConstraint to add.\n */\n public async setSourceConstraint(relationshipKey: SchemaItemKey, source: RelationshipConstraint): Promise<void> {\n const relationship = await this.getSchemaItem<MutableRelationshipClass>(relationshipKey)\n .catch((e) => {\n throw new SchemaEditingError(ECEditingStatus.SetSourceConstraint, new ClassId(this.schemaItemType, relationshipKey), e);\n });\n\n relationship.setSourceConstraint(source);\n }\n\n /**\n * Sets the target RelationshipConstraint on the relationship.\n * @param relationshipKey The SchemaItemKey for the relationship.\n * @param target The RelationshipConstraint to add.\n */\n public async setTargetConstraint(relationshipKey: SchemaItemKey, target: RelationshipConstraint): Promise<void> {\n const relationship = await this.getSchemaItem<MutableRelationshipClass>(relationshipKey)\n .catch((e) => {\n throw new SchemaEditingError(ECEditingStatus.SetTargetConstraint, new ClassId(this.schemaItemType, relationshipKey), e);\n });\n\n relationship.setTargetConstraint(target);\n }\n\n /**\n * Creates a RelationshipClass through a RelationshipClassProps.\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, relationshipProps: RelationshipClassProps): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createRelationshipClass.bind(schema), relationshipProps);\n\n await newClass.source.fromJSON(relationshipProps.source);\n await newClass.target.fromJSON(relationshipProps.target);\n\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, relationshipProps.name!, schemaKey), e);\n }\n }\n\n /**\n * Sets the base class of a RelationshipClass.\n * @param relationshipKey The SchemaItemKey of the RelationshipClass.\n * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.\n */\n public override async setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<void> {\n const relClass = await this.schemaEditor.schemaContext.getSchemaItem<RelationshipClass>(itemKey);\n const baseClass = relClass?.baseClass;\n\n await super.setBaseClass(itemKey, baseClassKey);\n\n try {\n await this.validate(relClass!);\n } catch(e: any) {\n relClass!.baseClass = baseClass;\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(SchemaItemType.RelationshipClass, itemKey), e);\n }\n }\n\n public async createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<void> {\n try {\n const relationshipClass = await this.getSchemaItem<MutableRelationshipClass>(relationshipKey);\n await relationshipClass.createNavigationProperty(name, relationship, direction);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationProperty, new ClassId(SchemaItemType.RelationshipClass, relationshipKey), e);\n }\n }\n\n /**\n * Creates a Navigation Property through a NavigationPropertyProps.\n * @param classKey a SchemaItemKey of the Relationship 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(relationshipKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<void> {\n try {\n const relationshipClass = await this.getSchemaItem<MutableRelationshipClass>(relationshipKey);\n const property = await relationshipClass.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.RelationshipClass, relationshipKey), e);\n }\n }\n\n public async setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.multiplicity = multiplicity;\n }\n\n public async setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.polymorphic = polymorphic;\n }\n\n public async setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.relationshipEnd = relationshipEnd;\n }\n\n public async setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<void> {\n const existing: LazyLoadedRelationshipConstraintClass | undefined = constraint.abstractConstraint;\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n\n if (undefined === abstractConstraint) {\n mutableConstraint.abstractConstraint = undefined;\n } else {\n mutableConstraint.abstractConstraint = new DelayedPromiseWithProps(abstractConstraint.key, async () => abstractConstraint);\n }\n\n try {\n await this.validate(constraint.relationshipClass);\n } catch(e: any){\n mutableConstraint.abstractConstraint = existing;\n throw new SchemaEditingError(ECEditingStatus.SetAbstractConstraint, new RelationshipConstraintId(constraint), e);\n }\n\n try {\n await this.validate(constraint);\n } catch(e: any){\n mutableConstraint.abstractConstraint = existing;\n throw new SchemaEditingError(ECEditingStatus.SetAbstractConstraint, new RelationshipConstraintId(constraint), e);\n }\n }\n\n public async addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.addClass(ecClass);\n\n try {\n await this.validate(constraint.relationshipClass);\n } catch(e: any){\n mutableConstraint.removeClass(ecClass);\n throw new SchemaEditingError(ECEditingStatus.AddConstraintClass, new RelationshipConstraintId(constraint), e);\n }\n\n try {\n await this.validate(constraint);\n } catch(e: any){\n mutableConstraint.removeClass(ecClass);\n throw new SchemaEditingError(ECEditingStatus.AddConstraintClass, new RelationshipConstraintId(constraint), e);\n }\n }\n\n public async removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.removeClass(ecClass);\n\n try{\n await this.validate(constraint);\n } catch(e: any) {\n mutableConstraint.addClass(ecClass);\n throw new SchemaEditingError(ECEditingStatus.RemoveConstraintClass, new RelationshipConstraintId(constraint), e);\n }\n }\n\n public async addCustomAttributeToConstraint(constraint: RelationshipConstraint, customAttribute: CustomAttribute): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.addCustomAttribute(customAttribute);\n\n const diagnosticIterable = Rules.validateCustomAttributeInstance(constraint, 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(constraint, customAttribute);\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToConstraint, new RelationshipConstraintId(constraint),\n new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, constraint), undefined, diagnostics));\n }\n }\n\n private async validate(relationshipOrConstraint: RelationshipClass | RelationshipConstraint): Promise<void> {\n let diagnosticIterable: AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> | AsyncIterable<RelationshipConstraintDiagnostic<any[]>>;\n let relationshipKey: SchemaItemKey | string;\n\n if (relationshipOrConstraint instanceof RelationshipClass) {\n diagnosticIterable = Rules.validateRelationship(relationshipOrConstraint);\n relationshipKey = relationshipOrConstraint.key;\n } else {\n diagnosticIterable = Rules.validateRelationshipConstraint(relationshipOrConstraint);\n relationshipKey = relationshipOrConstraint.relationshipClass.key;\n }\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of diagnosticIterable) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n if (relationshipOrConstraint instanceof RelationshipClass) {\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new ClassId(SchemaItemType.RelationshipClass, relationshipKey), undefined, diagnostics);\n } else {\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new RelationshipConstraintId(relationshipOrConstraint), undefined, diagnostics);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"RelationshipClasses.js","sourceRoot":"","sources":["../../../src/Editing/RelationshipClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAIkC;AAElC,2CAAwC;AACxC,iFAA6G;AAC7G,+CAA+C;AAE/C,6CAAoD;AACpD,2CAAwH;AAGxH;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,qBAAS;IAChD,IAAuB,aAAa;QAClC,OAAO,qCAAiB,CAAC;IAC3B,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACa,oBAAoB,GAAG,IAAI,iCAAoB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAExG;;;;;;;;OAQG;IACI,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAyB,EAAE,QAAsB,EAAE,SAA4B,EAAE,YAA4B;QACnK,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAoB,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,CAA6B,CAAC;YAE9M,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC/B,QAAQ,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;YAEzC,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE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,CAAC;QACxC,IAAI,KAAK,EAAE,MAAM,UAAU,IAAI,kBAAkB,EAAE,CAAC;YAClD,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,IAAI,wBAAwB,YAAY,qCAAiB,EAAE,CAAC;gBAC1D,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,aAAa,EAAE,IAAI,mBAAO,CAAC,kCAAc,CAAC,iBAAiB,EAAE,eAAe,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;YACtJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,aAAa,EAAE,IAAI,oCAAwB,CAAC,wBAAwB,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;YAC9I,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAlPD,kDAkPC","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, DelayedPromiseWithProps, ECClass, ECClassModifier, EntityClass, LazyLoadedRelationshipConstraintClass, Mixin, NavigationPropertyProps,\n RelationshipClass, RelationshipClassProps, RelationshipConstraint, RelationshipEnd, RelationshipMultiplicity, SchemaItemKey, SchemaItemType,\n SchemaKey, StrengthDirection, StrengthType,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableRelationshipClass, MutableRelationshipConstraint } from \"./Mutable/MutableRelationshipClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { AnyDiagnostic, RelationshipConstraintDiagnostic, SchemaItemDiagnostic } from \"../Validation/Diagnostic\";\nimport { NavigationProperties } from \"./Properties\";\nimport { ClassId, CustomAttributeId, ECEditingStatus, RelationshipConstraintId, SchemaEditingError } from \"./Exception\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\n\n/**\n * @alpha\n * A class extending ECClasses allowing you to create schema items of type RelationshipClass.\n */\nexport class RelationshipClasses extends ECClasses {\n protected override get itemTypeClass(): typeof RelationshipClass {\n return RelationshipClass;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.RelationshipClass, schemaEditor);\n }\n\n /**\n * Allows access for editing of NavigationProperty attributes.\n */\n public readonly navigationProperties = new NavigationProperties(this.schemaItemType, this.schemaEditor);\n\n /**\n * Creates a RelationshipClass.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param name The name of the new class.\n * @param modifier The ECClassModifier of the new class.\n * @param strength The relationship StrengthType of the class.\n * @param StrengthDirection The relationship StrengthDirection of the class.\n * @param baseClassKey An optional SchemaItemKey that specifies the base relationship class.\n */\n public async create(schemaKey: SchemaKey, name: string, modifier: ECClassModifier, strength: StrengthType, direction: StrengthDirection, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<RelationshipClass>(schemaKey, this.schemaItemType, (schema) => schema.createRelationshipClass.bind(schema), name, baseClassKey, modifier) as MutableRelationshipClass;\n\n newClass.setStrength(strength);\n newClass.setStrengthDirection(direction);\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 * Sets the source RelationshipConstraint on the relationship.\n * @param relationshipKey The SchemaItemKey for the relationship.\n * @param source The RelationshipConstraint to add.\n */\n public async setSourceConstraint(relationshipKey: SchemaItemKey, source: RelationshipConstraint): Promise<void> {\n const relationship = await this.getSchemaItem(relationshipKey, MutableRelationshipClass)\n .catch((e) => {\n throw new SchemaEditingError(ECEditingStatus.SetSourceConstraint, new ClassId(this.schemaItemType, relationshipKey), e);\n });\n\n relationship.setSourceConstraint(source);\n }\n\n /**\n * Sets the target RelationshipConstraint on the relationship.\n * @param relationshipKey The SchemaItemKey for the relationship.\n * @param target The RelationshipConstraint to add.\n */\n public async setTargetConstraint(relationshipKey: SchemaItemKey, target: RelationshipConstraint): Promise<void> {\n const relationship = await this.getSchemaItem(relationshipKey, MutableRelationshipClass)\n .catch((e) => {\n throw new SchemaEditingError(ECEditingStatus.SetTargetConstraint, new ClassId(this.schemaItemType, relationshipKey), e);\n });\n\n relationship.setTargetConstraint(target);\n }\n\n /**\n * Creates a RelationshipClass through a RelationshipClassProps.\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, relationshipProps: RelationshipClassProps): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createRelationshipClass.bind(schema), relationshipProps);\n\n await newClass.source.fromJSON(relationshipProps.source);\n await newClass.target.fromJSON(relationshipProps.target);\n\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, relationshipProps.name!, schemaKey), e);\n }\n }\n\n /**\n * Sets the base class of a RelationshipClass.\n * @param relationshipKey The SchemaItemKey of the RelationshipClass.\n * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.\n */\n public override async setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<void> {\n const relClass = await this.schemaEditor.schemaContext.getSchemaItem(itemKey, RelationshipClass)\n .catch((e) => {\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(this.schemaItemType, itemKey), e);\n });\n const baseClass = relClass?.baseClass;\n\n await super.setBaseClass(itemKey, baseClassKey);\n\n try {\n await this.validate(relClass!);\n } catch(e: any) {\n await (relClass! as ECClass as MutableClass).setBaseClass(baseClass);\n throw new SchemaEditingError(ECEditingStatus.SetBaseClass, new ClassId(SchemaItemType.RelationshipClass, itemKey), e);\n }\n }\n\n public async createNavigationProperty(relationshipKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<void> {\n try {\n const relationshipClass = await this.getSchemaItem(relationshipKey, MutableRelationshipClass);\n await relationshipClass.createNavigationProperty(name, relationship, direction);\n } catch(e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateNavigationProperty, new ClassId(SchemaItemType.RelationshipClass, relationshipKey), e);\n }\n }\n\n /**\n * Creates a Navigation Property through a NavigationPropertyProps.\n * @param classKey a SchemaItemKey of the Relationship 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(relationshipKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<void> {\n try {\n const relationshipClass = await this.getSchemaItem(relationshipKey, MutableRelationshipClass);\n const property = await relationshipClass.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.RelationshipClass, relationshipKey), e);\n }\n }\n\n public async setConstraintMultiplicity(constraint: RelationshipConstraint, multiplicity: RelationshipMultiplicity): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.multiplicity = multiplicity;\n }\n\n public async setConstraintPolymorphic(constraint: RelationshipConstraint, polymorphic: boolean): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.polymorphic = polymorphic;\n }\n\n public async setConstraintRelationshipEnd(constraint: RelationshipConstraint, relationshipEnd: RelationshipEnd): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.relationshipEnd = relationshipEnd;\n }\n\n public async setAbstractConstraint(constraint: RelationshipConstraint, abstractConstraint?: EntityClass | Mixin | RelationshipClass): Promise<void> {\n const existing: LazyLoadedRelationshipConstraintClass | undefined = constraint.abstractConstraint;\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n\n if (undefined === abstractConstraint) {\n mutableConstraint.abstractConstraint = undefined;\n } else {\n mutableConstraint.abstractConstraint = new DelayedPromiseWithProps(abstractConstraint.key, async () => abstractConstraint);\n }\n\n try {\n await this.validate(constraint.relationshipClass);\n } catch(e: any){\n mutableConstraint.abstractConstraint = existing;\n throw new SchemaEditingError(ECEditingStatus.SetAbstractConstraint, new RelationshipConstraintId(constraint), e);\n }\n\n try {\n await this.validate(constraint);\n } catch(e: any){\n mutableConstraint.abstractConstraint = existing;\n throw new SchemaEditingError(ECEditingStatus.SetAbstractConstraint, new RelationshipConstraintId(constraint), e);\n }\n }\n\n public async addConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.addClass(ecClass);\n\n try {\n await this.validate(constraint.relationshipClass);\n } catch(e: any){\n mutableConstraint.removeClass(ecClass);\n throw new SchemaEditingError(ECEditingStatus.AddConstraintClass, new RelationshipConstraintId(constraint), e);\n }\n\n try {\n await this.validate(constraint);\n } catch(e: any){\n mutableConstraint.removeClass(ecClass);\n throw new SchemaEditingError(ECEditingStatus.AddConstraintClass, new RelationshipConstraintId(constraint), e);\n }\n }\n\n public async removeConstraintClass(constraint: RelationshipConstraint, ecClass: EntityClass | Mixin | RelationshipClass): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.removeClass(ecClass);\n\n try{\n await this.validate(constraint);\n } catch(e: any) {\n mutableConstraint.addClass(ecClass);\n throw new SchemaEditingError(ECEditingStatus.RemoveConstraintClass, new RelationshipConstraintId(constraint), e);\n }\n }\n\n public async addCustomAttributeToConstraint(constraint: RelationshipConstraint, customAttribute: CustomAttribute): Promise<void> {\n const mutableConstraint = constraint as MutableRelationshipConstraint;\n mutableConstraint.addCustomAttribute(customAttribute);\n\n const diagnosticIterable = Rules.validateCustomAttributeInstance(constraint, 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(constraint, customAttribute);\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToConstraint, new RelationshipConstraintId(constraint),\n new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, constraint), undefined, diagnostics));\n }\n }\n\n private async validate(relationshipOrConstraint: RelationshipClass | RelationshipConstraint): Promise<void> {\n let diagnosticIterable: AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> | AsyncIterable<RelationshipConstraintDiagnostic<any[]>>;\n let relationshipKey: SchemaItemKey | string;\n\n if (relationshipOrConstraint instanceof RelationshipClass) {\n diagnosticIterable = Rules.validateRelationship(relationshipOrConstraint);\n relationshipKey = relationshipOrConstraint.key;\n } else {\n diagnosticIterable = Rules.validateRelationshipConstraint(relationshipOrConstraint);\n relationshipKey = relationshipOrConstraint.relationshipClass.key;\n }\n\n const diagnostics: AnyDiagnostic[] = [];\n for await (const diagnostic of diagnosticIterable) {\n diagnostics.push(diagnostic);\n }\n\n if (diagnostics.length > 0) {\n if (relationshipOrConstraint instanceof RelationshipClass) {\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new ClassId(SchemaItemType.RelationshipClass, relationshipKey), undefined, diagnostics);\n } else {\n throw new SchemaEditingError(ECEditingStatus.RuleViolation, new RelationshipConstraintId(relationshipOrConstraint), undefined, diagnostics);\n }\n }\n }\n}\n"]}
@@ -13,6 +13,7 @@ export type CreateSchemaItemFromProps<T extends SchemaItem> = (props: SchemaItem
13
13
  export declare abstract class SchemaItems {
14
14
  protected schemaItemType: SchemaItemType;
15
15
  protected schemaEditor: SchemaContextEditor;
16
+ protected abstract get itemTypeClass(): typeof SchemaItem;
16
17
  constructor(schemaItemType: SchemaItemType, schemaEditor: SchemaContextEditor);
17
18
  /**
18
19
  * Sets the name of the SchemaItem.
@@ -34,8 +35,7 @@ export declare abstract class SchemaItems {
34
35
  */
35
36
  setDisplayLabel(schemaItemKey: SchemaItemKey, label: string): Promise<void>;
36
37
  protected getSchema(schemaKey: SchemaKey): Promise<MutableSchema>;
37
- protected getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey, schemaItemType?: SchemaItemType): Promise<T>;
38
- protected lookupSchemaItem<T extends SchemaItem>(schemaOrKey: MutableSchema | SchemaKey, schemaItemKey: SchemaItemKey, schemaItemType?: SchemaItemType): Promise<T>;
38
+ protected getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T>>;
39
39
  protected createSchemaItem<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, ...args: any[]): Promise<T>;
40
40
  protected createSchemaItemFromProps<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, props: SchemaItemProps): Promise<T>;
41
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaItems.d.ts","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAmC,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAClJ,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,MAAM,EAAE,aAAa,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAC7H,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,KAAK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GAAG,OAAO,CAAC,aAAa,CAAC;cAQvD,aAAa,CAAC,CAAC,SAAS,OAAO,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;cAItH,gBAAgB,CAAC,CAAC,SAAS,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;cAczJ,yBAAyB,CAAC,CAAC,SAAS,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC;CAS7K"}
@@ -15,6 +15,8 @@ const Exception_1 = require("./Exception");
15
15
  * A class allowing you to edit the schema item base class.
16
16
  */
17
17
  class SchemaItems {
18
+ schemaItemType;
19
+ schemaEditor;
18
20
  constructor(schemaItemType, schemaEditor) {
19
21
  this.schemaItemType = schemaItemType;
20
22
  this.schemaEditor = schemaEditor;
@@ -28,10 +30,10 @@ class SchemaItems {
28
30
  async setName(itemKey, name) {
29
31
  try {
30
32
  const schema = await this.getSchema(itemKey.schemaKey);
31
- const ecClass = await schema.getItem(name);
33
+ const ecClass = await schema.getItem(name, this.itemTypeClass);
32
34
  if (ecClass !== undefined)
33
35
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaItemNameAlreadyExists, new Exception_1.SchemaItemId(this.schemaItemType, name, schema.schemaKey));
34
- const mutableItem = await this.getSchemaItem(itemKey);
36
+ const mutableItem = await this.getSchemaItem(itemKey, this.itemTypeClass);
35
37
  const existingName = itemKey.name;
36
38
  mutableItem.setName(name);
37
39
  // Must reset in schema item map
@@ -52,7 +54,7 @@ class SchemaItems {
52
54
  * @param description The new description to set.
53
55
  */
54
56
  async setDescription(schemaItemKey, description) {
55
- const item = await this.getSchemaItem(schemaItemKey)
57
+ const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)
56
58
  .catch((e) => {
57
59
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetDescription, new Exception_1.SchemaItemId(this.schemaItemType, schemaItemKey), e);
58
60
  });
@@ -64,7 +66,7 @@ class SchemaItems {
64
66
  * @param label The new label to set.
65
67
  */
66
68
  async setDisplayLabel(schemaItemKey, label) {
67
- const item = await this.getSchemaItem(schemaItemKey)
69
+ const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)
68
70
  .catch((e) => {
69
71
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetLabel, new Exception_1.SchemaItemId(this.schemaItemType, schemaItemKey), e);
70
72
  });
@@ -76,13 +78,8 @@ class SchemaItems {
76
78
  throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaNotFound, new Exception_1.SchemaId(schemaKey));
77
79
  return schema;
78
80
  }
79
- async getSchemaItem(schemaItemKey, schemaItemType) {
80
- schemaItemType = schemaItemType ?? this.schemaItemType;
81
- return this.schemaEditor.getSchemaItem(schemaItemKey, schemaItemType);
82
- }
83
- async lookupSchemaItem(schemaOrKey, schemaItemKey, schemaItemType) {
84
- schemaItemType = schemaItemType ?? this.schemaItemType;
85
- return this.schemaEditor.lookupSchemaItem(schemaOrKey, schemaItemKey, schemaItemType);
81
+ async getSchemaItem(schemaItemKey, itemConstructor) {
82
+ return this.schemaEditor.getSchemaItem(schemaItemKey, itemConstructor);
86
83
  }
87
84
  async createSchemaItem(schemaKey, type, create, name, ...args) {
88
85
  const schema = await this.getSchema(schemaKey);
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaItems.js","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAE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F,CAAC;QACH,CAAC;IACH,CAAC;IAES,KAAK,CAAC,yBAAyB,CAAuB,SAAoB,EAAE,IAAoB,EAAE,MAA2B,EAAE,KAAsB;QAC7J,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;YAC1B,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,0BAA0B,EAAE,IAAI,wBAAY,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;QAElH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAI,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACpF,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE9B,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA5GD,kCA4GC","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 { ECObjectsError, ECObjectsStatus, SchemaItem, SchemaItemKey, SchemaItemProps, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECEditingStatus, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\nimport { MutableSchemaItem } from \"./Mutable/MutableSchemaItem\";\n\nexport type CreateSchemaItem<T extends SchemaItem> = (schema: MutableSchema) => (name: string, ...args: any[]) => Promise<T>;\nexport type CreateSchemaItemFromProps<T extends SchemaItem> = (props: SchemaItemProps, ...args: any[]) => Promise<T>;\n\n/**\n * @internal\n * A class allowing you to edit the schema item base class.\n */\nexport abstract class SchemaItems {\n protected schemaItemType: SchemaItemType;\n protected schemaEditor: SchemaContextEditor;\n\n public constructor(schemaItemType: SchemaItemType, schemaEditor: SchemaContextEditor) {\n this.schemaItemType = schemaItemType;\n this.schemaEditor = schemaEditor;\n }\n\n /**\n * Sets the name of the SchemaItem.\n * @param itemKey The SchemaItemKey of the SchemaItem.\n * @param name The new name of the SchemaItem.\n * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name\n */\n public async setName(itemKey: SchemaItemKey, name: string): Promise<SchemaItemKey> {\n try {\n const schema = await this.getSchema(itemKey.schemaKey);\n const ecClass = await schema.getItem<MutableSchemaItem>(name);\n if (ecClass !== undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(this.schemaItemType, name, schema.schemaKey));\n\n const mutableItem = await this.getSchemaItem<MutableSchemaItem>(itemKey);\n\n const existingName = itemKey.name;\n mutableItem.setName(name);\n\n // Must reset in schema item map\n await schema.deleteSchemaItem(existingName);\n schema.addItem(mutableItem);\n return mutableItem.key;\n } catch(e: any) {\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.InvalidECName) {\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey),\n new SchemaEditingError(ECEditingStatus.InvalidECName, new SchemaItemId(this.schemaItemType, itemKey)));\n }\n\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey), e);\n }\n }\n\n /**\n * Sets the SchemaItem description.\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\n * @param description The new description to set.\n */\n public async setDescription(schemaItemKey: SchemaItemKey, description: string) {\n const item = await this.getSchemaItem<MutableSchemaItem>(schemaItemKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\n });\n item.setDescription(description);\n }\n\n /**\n * Sets the SchemaItem display label.\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\n * @param label The new label to set.\n */\n public async setDisplayLabel(schemaItemKey: SchemaItemKey, label: string) {\n const item = await this.getSchemaItem<MutableSchemaItem>(schemaItemKey)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\n });\n item.setDisplayLabel(label);\n }\n\n protected async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\n const schema = await this.schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema;\n }\n\n protected async getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey, schemaItemType?: SchemaItemType): Promise<T>{\n schemaItemType = schemaItemType ?? this.schemaItemType;\n return this.schemaEditor.getSchemaItem<T>(schemaItemKey, schemaItemType);\n }\n\n protected async lookupSchemaItem<T extends SchemaItem>(schemaOrKey: MutableSchema | SchemaKey, schemaItemKey: SchemaItemKey, schemaItemType?: SchemaItemType): Promise<T>{\n schemaItemType = schemaItemType ?? this.schemaItemType;\n return this.schemaEditor.lookupSchemaItem(schemaOrKey, schemaItemKey, schemaItemType);\n }\n\n protected async createSchemaItem<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, ...args: any[]): Promise<T> {\n const schema = await this.getSchema(schemaKey);\n try {\n const boundCreate = create(schema);\n return await boundCreate(name, ...args);\n } catch (e) {\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.DuplicateItem) {\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(type, name, schema.schemaKey));\n } else {\n throw new Error(`Failed to create class ${name} in schema ${schema.fullName}.`);\n }\n }\n }\n\n protected async createSchemaItemFromProps<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, props: SchemaItemProps): Promise<T> {\n if (props.name === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameNotSpecified, new SchemaItemId(type, \"\", schemaKey));\n\n const newItem = await this.createSchemaItem<T>(schemaKey, type, create, props.name);\n await newItem.fromJ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YAClF,CAAC;QACH,CAAC;IACH,CAAC;IAES,KAAK,CAAC,yBAAyB,CAAuB,SAAoB,EAAE,IAAoB,EAAE,MAA2B,EAAE,KAAsB;QAC7J,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;YAC1B,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,0BAA0B,EAAE,IAAI,wBAAY,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;QAElH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAI,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACpF,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE9B,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAxGD,kCAwGC","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 { ECObjectsError, ECObjectsStatus, SchemaItem, SchemaItemKey, SchemaItemProps, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECEditingStatus, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\nimport { MutableSchemaItem } from \"./Mutable/MutableSchemaItem\";\n\nexport type CreateSchemaItem<T extends SchemaItem> = (schema: MutableSchema) => (name: string, ...args: any[]) => Promise<T>;\nexport type CreateSchemaItemFromProps<T extends SchemaItem> = (props: SchemaItemProps, ...args: any[]) => Promise<T>;\n\n/**\n * @internal\n * A class allowing you to edit the schema item base class.\n */\nexport abstract class SchemaItems {\n protected schemaItemType: SchemaItemType;\n protected schemaEditor: SchemaContextEditor;\n\n protected abstract get itemTypeClass(): typeof SchemaItem;\n\n public constructor(schemaItemType: SchemaItemType, schemaEditor: SchemaContextEditor) {\n this.schemaItemType = schemaItemType;\n this.schemaEditor = schemaEditor;\n }\n\n /**\n * Sets the name of the SchemaItem.\n * @param itemKey The SchemaItemKey of the SchemaItem.\n * @param name The new name of the SchemaItem.\n * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name\n */\n public async setName(itemKey: SchemaItemKey, name: string): Promise<SchemaItemKey> {\n try {\n const schema = await this.getSchema(itemKey.schemaKey);\n const ecClass = await schema.getItem(name, this.itemTypeClass);\n if (ecClass !== undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(this.schemaItemType, name, schema.schemaKey));\n\n const mutableItem = await this.getSchemaItem(itemKey, this.itemTypeClass) as MutableSchemaItem;\n\n const existingName = itemKey.name;\n mutableItem.setName(name);\n\n // Must reset in schema item map\n await schema.deleteSchemaItem(existingName);\n schema.addItem(mutableItem);\n return mutableItem.key;\n } catch(e: any) {\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.InvalidECName) {\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey),\n new SchemaEditingError(ECEditingStatus.InvalidECName, new SchemaItemId(this.schemaItemType, itemKey)));\n }\n\n throw new SchemaEditingError(ECEditingStatus.SetClassName, new SchemaItemId(this.schemaItemType, itemKey), e);\n }\n }\n\n /**\n * Sets the SchemaItem description.\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\n * @param description The new description to set.\n */\n public async setDescription(schemaItemKey: SchemaItemKey, description: string) {\n const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\n });\n (item as MutableSchemaItem).setDescription(description);\n }\n\n /**\n * Sets the SchemaItem display label.\n * @param schemaItemKey The SchemaItemKey of the SchemaItem\n * @param label The new label to set.\n */\n public async setDisplayLabel(schemaItemKey: SchemaItemKey, label: string) {\n const item = await this.getSchemaItem(schemaItemKey, this.itemTypeClass)\n .catch((e: any) => {\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new SchemaItemId(this.schemaItemType, schemaItemKey), e);\n });\n (item as MutableSchemaItem).setDisplayLabel(label);\n }\n\n protected async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\n const schema = await this.schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\n\n return schema;\n }\n\n protected async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T>> {\n return this.schemaEditor.getSchemaItem(schemaItemKey, itemConstructor);\n }\n\n protected async createSchemaItem<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, ...args: any[]): Promise<T> {\n const schema = await this.getSchema(schemaKey);\n try {\n const boundCreate = create(schema);\n return await boundCreate(name, ...args);\n } catch (e) {\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.DuplicateItem) {\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(type, name, schema.schemaKey));\n } else {\n throw new Error(`Failed to create class ${name} in schema ${schema.fullName}.`);\n }\n }\n }\n\n protected async createSchemaItemFromProps<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, props: SchemaItemProps): Promise<T> {\n if (props.name === undefined)\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameNotSpecified, new SchemaItemId(type, \"\", schemaKey));\n\n const newItem = await this.createSchemaItem<T>(schemaKey, type, create, props.name);\n await newItem.fromJSON(props);\n\n return newItem;\n }\n}\n"]}
@@ -1,13 +1,14 @@
1
1
  /** @packageDocumentation
2
2
  * @module Editing
3
3
  */
4
- import { SchemaItemKey, SchemaKey, StructClassProps } from "@itwin/ecschema-metadata";
4
+ import { SchemaItemKey, SchemaKey, StructClass, StructClassProps } from "@itwin/ecschema-metadata";
5
5
  import { SchemaContextEditor } from "./Editor";
6
6
  import { ECClasses } from "./ECClasses";
7
7
  /**
8
8
  * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.
9
9
  */
10
10
  export declare class Structs extends ECClasses {
11
+ protected get itemTypeClass(): typeof StructClass;
11
12
  constructor(schemaEditor: SchemaContextEditor);
12
13
  create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey>;
13
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Structs.d.ts","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAe,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC;;GAEG;AACH,qBAAa,OAAQ,SAAQ,SAAS;gBACjB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAapI;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ1G"}
1
+ {"version":3,"file":"Structs.d.ts","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC;;GAEG;AACH,qBAAa,OAAQ,SAAQ,SAAS;IACpC,cAAuB,aAAa,IAAI,OAAO,WAAW,CAEzD;gBAEkB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAapI;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ1G"}
@@ -15,6 +15,9 @@ const Exception_1 = require("./Exception");
15
15
  * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.
16
16
  */
17
17
  class Structs extends ECClasses_1.ECClasses {
18
+ get itemTypeClass() {
19
+ return ecschema_metadata_1.StructClass;
20
+ }
18
21
  constructor(schemaEditor) {
19
22
  super(ecschema_metadata_1.SchemaItemType.StructClass, schemaEditor);
20
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAmH;AAEnH,2CAAwC;AAExC,2CAA2E;AAE3E;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,YAA4B;QACzG,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAc,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,CAAuB,CAAC;YAElL,IAAI,YAAY;gBACd,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAEzC,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,WAA6B;QAC9E,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;YACtJ,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7I,CAAC;IACH,CAAC;CACF;AA/BD,0BA+BC","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 { SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableStructClass } from \"./Mutable/MutableClass\";\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\n\n/**\n * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.\n */\nexport class Structs extends ECClasses {\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.StructClass, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<StructClass>(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), name, baseClassKey) as MutableStructClass;\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 a StructClass through a StructClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), structProps);\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, structProps.name!, schemaKey), e);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAmH;AAEnH,2CAAwC;AAExC,2CAA2E;AAE3E;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,IAAuB,aAAa;QAClC,OAAO,+BAAW,CAAC;IACrB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,YAA4B;QACzG,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAc,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,CAAuB,CAAC;YAElL,IAAI,YAAY;gBACd,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAEzC,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,WAA6B;QAC9E,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;YACtJ,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7I,CAAC;IACH,CAAC;CACF;AAnCD,0BAmCC","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 { SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableStructClass } from \"./Mutable/MutableClass\";\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\n\n/**\n * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.\n */\nexport class Structs extends ECClasses {\n protected override get itemTypeClass(): typeof StructClass {\n return StructClass;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.StructClass, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createClass<StructClass>(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), name, baseClassKey) as MutableStructClass;\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 a StructClass through a StructClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): Promise<SchemaItemKey> {\n try {\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), structProps);\n return newClass.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, structProps.name!, schemaKey), e);\n }\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module Editing
3
3
  */
4
- import { SchemaItemKey, SchemaKey, UnitSystemProps } from "@itwin/ecschema-metadata";
4
+ import { SchemaItemKey, SchemaKey, UnitSystem, UnitSystemProps } from "@itwin/ecschema-metadata";
5
5
  import { SchemaContextEditor } from "./Editor";
6
6
  import { SchemaItems } from "./SchemaItems";
7
7
  /**
@@ -9,6 +9,7 @@ import { SchemaItems } from "./SchemaItems";
9
9
  * A class allowing you to create schema items of type UnitSystems.
10
10
  */
11
11
  export declare class UnitSystems extends SchemaItems {
12
+ protected get itemTypeClass(): typeof UnitSystem;
12
13
  constructor(schemaEditor: SchemaContextEditor);
13
14
  create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemKey>;
14
15
  createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemKey>;
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSystems.d.ts","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAc,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACjH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAY,SAAQ,WAAW;gBACvB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAczF,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ7G"}
1
+ {"version":3,"file":"UnitSystems.d.ts","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACjH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAY,SAAQ,WAAW;IAC1C,cAAuB,aAAa,IAAI,OAAO,UAAU,CAExD;gBAEkB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAczF,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ7G"}
@@ -16,6 +16,9 @@ const SchemaItems_1 = require("./SchemaItems");
16
16
  * A class allowing you to create schema items of type UnitSystems.
17
17
  */
18
18
  class UnitSystems extends SchemaItems_1.SchemaItems {
19
+ get itemTypeClass() {
20
+ return ecschema_metadata_1.UnitSystem;
21
+ }
19
22
  constructor(schemaEditor) {
20
23
  super(ecschema_metadata_1.SchemaItemType.UnitSystem, schemaEditor);
21
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiH;AAGjH,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,WAAY,SAAQ,yBAAW;IAC1C,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB;QAE3E,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAsB,CAAC;YAE3K,IAAI,YAAY;gBACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAE9C,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC;YAC9J,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;CACF;AA3BD,kCA2BC","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 { SchemaItemKey, SchemaItemType, SchemaKey, UnitSystem, UnitSystemProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\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 UnitSystems.\n */\nexport class UnitSystems extends SchemaItems {\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.UnitSystem, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemKey> {\n\n try {\n const newUnitSystem = await this.createSchemaItem<UnitSystem>(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), name) as MutableUnitSystem;\n\n if (displayLabel)\n newUnitSystem.setDisplayLabel(displayLabel);\n\n return newUnitSystem.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemKey> {\n try {\n const newUnitSystem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), unitSystemProps);\n return newUnitSystem.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitSystemProps.name!, schemaKey), e);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiH;AAGjH,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,WAAY,SAAQ,yBAAW;IAC1C,IAAuB,aAAa;QAClC,OAAO,8BAAU,CAAC;IACpB,CAAC;IAED,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB;QAE3E,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAsB,CAAC;YAE3K,IAAI,YAAY;gBACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAE9C,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC;YAC9J,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;CACF;AA/BD,kCA+BC","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 { SchemaItemKey, SchemaItemType, SchemaKey, UnitSystem, UnitSystemProps } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\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 UnitSystems.\n */\nexport class UnitSystems extends SchemaItems {\n protected override get itemTypeClass(): typeof UnitSystem {\n return UnitSystem;\n }\n\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.UnitSystem, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemKey> {\n\n try {\n const newUnitSystem = await this.createSchemaItem<UnitSystem>(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), name) as MutableUnitSystem;\n\n if (displayLabel)\n newUnitSystem.setDisplayLabel(displayLabel);\n\n return newUnitSystem.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemKey> {\n try {\n const newUnitSystem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), unitSystemProps);\n return newUnitSystem.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitSystemProps.name!, schemaKey), e);\n }\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module Editing
3
3
  */
4
- import { SchemaItemKey, SchemaItemUnitProps, SchemaKey } from "@itwin/ecschema-metadata";
4
+ import { SchemaItemKey, SchemaItemUnitProps, SchemaKey, Unit } from "@itwin/ecschema-metadata";
5
5
  import { SchemaContextEditor } from "./Editor";
6
6
  import { SchemaItems } from "./SchemaItems";
7
7
  /**
@@ -9,6 +9,7 @@ import { SchemaItems } from "./SchemaItems";
9
9
  * A class allowing you to create schema items of type Unit.
10
10
  */
11
11
  export declare class Units extends SchemaItems {
12
+ protected get itemTypeClass(): typeof Unit;
12
13
  constructor(schemaEditor: SchemaContextEditor);
13
14
  create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey>;
14
15
  createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey>;
@@ -1 +1 @@
1
- {"version":3,"file":"Units.d.ts","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAuC,aAAa,EAAkB,mBAAmB,EAAE,SAAS,EAAoB,MAAM,0BAA0B,CAAC;AAChK,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,KAAM,SAAQ,WAAW;gBAEjB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAqBnK,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ3G"}
1
+ {"version":3,"file":"Units.d.ts","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAuC,aAAa,EAAkB,mBAAmB,EAAE,SAAS,EAAE,IAAI,EAAc,MAAM,0BAA0B,CAAC;AAChK,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,KAAM,SAAQ,WAAW;IACpC,cAAuB,aAAa,IAAI,OAAO,IAAI,CAElD;gBAGkB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAqBnK,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ3G"}
@@ -16,6 +16,9 @@ const SchemaItems_1 = require("./SchemaItems");
16
16
  * A class allowing you to create schema items of type Unit.
17
17
  */
18
18
  class Units extends SchemaItems_1.SchemaItems {
19
+ get itemTypeClass() {
20
+ return ecschema_metadata_1.Unit;
21
+ }
19
22
  // TODO: Add more setters for all attributes.
20
23
  constructor(schemaEditor) {
21
24
  super(ecschema_metadata_1.SchemaItemType.Unit, schemaEditor);
@@ -23,9 +26,9 @@ class Units extends SchemaItems_1.SchemaItems {
23
26
  async create(schemaKey, name, definition, phenomenon, unitSystem, displayLabel) {
24
27
  try {
25
28
  const newUnit = await this.createSchemaItem(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name);
26
- const phenomenonItem = await this.lookupSchemaItem(newUnit.schema.schemaKey, phenomenon, ecschema_metadata_1.SchemaItemType.Phenomenon);
29
+ const phenomenonItem = await this.getSchemaItem(phenomenon, ecschema_metadata_1.Phenomenon);
27
30
  await newUnit.setPhenomenon(new ecschema_metadata_1.DelayedPromiseWithProps(phenomenon, async () => phenomenonItem));
28
- const unitSystemItem = await this.lookupSchemaItem(newUnit.schema.schemaKey, unitSystem, ecschema_metadata_1.SchemaItemType.UnitSystem);
31
+ const unitSystemItem = await this.getSchemaItem(unitSystem, ecschema_metadata_1.UnitSystem);
29
32
  await newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystem, async () => unitSystemItem));
30
33
  await newUnit.setDefinition(definition);
31
34
  if (displayLabel)
@@ -1 +1 @@
1
- {"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAgK;AAGhK,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,KAAM,SAAQ,yBAAW;IACpC,6CAA6C;IAC7C,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAyB,EAAE,UAAyB,EAAE,YAAqB;QACrJ,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAO,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAgB,CAAC;YAEnJ,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,kCAAc,CAAC,UAAU,CAAC,CAAC;YAChI,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;YAE5H,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,kCAAc,CAAC,UAAU,CAAC,CAAC;YAChI,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;YAE5H,MAAM,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAExC,IAAI,YAAY;gBACd,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAExC,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA8B;QAC/E,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;YAC5I,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAChJ,CAAC;IACH,CAAC;CACF;AAnCD,sBAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaItemUnitProps, SchemaKey, Unit, UnitSystem } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Unit.\n */\nexport class Units extends SchemaItems {\n // TODO: Add more setters for all attributes.\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Unit, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItem<Unit>(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name) as MutableUnit;\n\n const phenomenonItem = await this.lookupSchemaItem<Phenomenon>(newUnit.schema.schemaKey, phenomenon, SchemaItemType.Phenomenon);\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\n\n const unitSystemItem = await this.lookupSchemaItem<UnitSystem>(newUnit.schema.schemaKey, unitSystem, SchemaItemType.UnitSystem);\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\n\n await newUnit.setDefinition(definition);\n\n if (displayLabel)\n newUnit.setDisplayLabel(displayLabel);\n\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name!, schemaKey), e);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAgK;AAGhK,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,KAAM,SAAQ,yBAAW;IACpC,IAAuB,aAAa;QAClC,OAAO,wBAAI,CAAC;IACd,CAAC;IAED,6CAA6C;IAC7C,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAyB,EAAE,UAAyB,EAAE,YAAqB;QACrJ,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAO,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAgB,CAAC;YAEnJ,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,8BAAU,CAAC,CAAC;YACxE,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;YAE5H,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,8BAAU,CAAC,CAAC;YACxE,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;YAE5H,MAAM,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAExC,IAAI,YAAY;gBACd,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAExC,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA8B;QAC/E,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;YAC5I,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAChJ,CAAC;IACH,CAAC;CACF;AAvCD,sBAuCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaItemUnitProps, SchemaKey, Unit, UnitSystem } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"./Editor\";\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Unit.\n */\nexport class Units extends SchemaItems {\n protected override get itemTypeClass(): typeof Unit {\n return Unit;\n }\n\n // TODO: Add more setters for all attributes.\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.Unit, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItem<Unit>(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name) as MutableUnit;\n\n const phenomenonItem = await this.getSchemaItem(phenomenon, Phenomenon);\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\n\n const unitSystemItem = await this.getSchemaItem(unitSystem, UnitSystem);\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\n\n await newUnit.setDefinition(definition);\n\n if (displayLabel)\n newUnit.setDisplayLabel(displayLabel);\n\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\n }\n }\n\n public async createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey> {\n try {\n const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);\n return newUnit.key;\n } catch (e: any) {\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name!, schemaKey), e);\n }\n }\n}\n"]}
@@ -40,25 +40,25 @@ async function modifyConstant(context, change, itemKey) {
40
40
  // Note: There are no editor methods to modify a constant.
41
41
  if (change.difference.definition !== undefined) {
42
42
  if (change.difference.definition !== "" && constant.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {
43
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `The Constant ${itemKey.name} has an invalid 'definition' attribute.`);
43
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'definition' attribute.`);
44
44
  }
45
45
  constant.setDefinition(change.difference.definition);
46
46
  }
47
47
  if (change.difference.denominator !== undefined) {
48
48
  if (constant.hasDenominator && constant.denominator !== change.difference.denominator) {
49
- throw new Error(`Failed to merged, constant denominator conflict: ${change.difference.denominator} -> ${constant.denominator}`);
49
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'denominator' attribute.`);
50
50
  }
51
51
  constant.setDenominator(change.difference.denominator);
52
52
  }
53
53
  if (change.difference.numerator !== undefined) {
54
54
  if (constant.hasNumerator && constant.numerator !== change.difference.numerator) {
55
- throw new Error(`Failed to merged, constant numerator conflict: ${change.difference.numerator} -> ${constant.numerator}`);
55
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'numerator' attribute.`);
56
56
  }
57
57
  constant.setNumerator(change.difference.numerator);
58
58
  }
59
59
  if (change.difference.phenomenon !== undefined) {
60
60
  const lookupKey = await (0, Utils_1.updateSchemaItemKey)(context, change.difference.phenomenon);
61
- const phenomenon = await context.editor.schemaContext.getSchemaItem(lookupKey);
61
+ const phenomenon = await context.editor.schemaContext.getSchemaItem(lookupKey, ecschema_metadata_1.Phenomenon);
62
62
  if (phenomenon === undefined) {
63
63
  throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);
64
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Con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AC,kDAAkD,MAAM,CAAC,UAAU,CAAC,SAAS,OAAO,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;QAC5H,CAAC;QACD,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAa,SAAS,CAAC,CAAC;QAC3F,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAC5F,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { ConstantDifference } from \"../Differencing/SchemaDifference\";\nimport type{ MutableConstant } from \"../Editing/Mutable/MutableConstant\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { DelayedPromiseWithProps, ECObjectsError, ECObjectsStatus, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Constant into the target schema.\n * @internal\n */\nexport async function addConstant(context: SchemaMergeContext, change: ConstantDifference) {\n if (change.difference.phenomenon === undefined) {\n throw new Error(\"Constant must define phenomenon\");\n }\n if (change.difference.definition === undefined) {\n throw new Error(\"Constant must define definition\");\n }\n\n // Needs to update the reference from source to target schema.\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\n\n await context.editor.constants.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n phenomenon: change.difference.phenomenon,\n definition: change.difference.definition,\n });\n}\n\n/**\n * Merges differences to an existing Constant in the target schema.\n * @internal\n */\nexport async function modifyConstant(context: SchemaMergeContext, change: ConstantDifference, itemKey: SchemaItemKey) {\n const constant = await context.targetSchema.lookupItem(itemKey) as MutableConstant;\n if (change.difference.label !== undefined) {\n await context.editor.constants.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.constants.setDescription(itemKey, change.difference.description);\n }\n\n // Note: There are no editor methods to modify a constant.\n if (change.difference.definition !== undefined) {\n if (change.difference.definition !== \"\" && constant.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${itemKey.name} has an invalid 'definition' attribute.`);\n }\n constant.setDefinition(change.difference.definition);\n }\n if (change.difference.denominator !== undefined) {\n if (constant.hasDenominator && constant.denominator !== change.difference.denominator) {\n throw new Error(`Failed to merged, constant denominator conflict: ${change.difference.denominator} -> ${constant.denominator}`);\n }\n constant.setDenominator(change.difference.denominator);\n }\n if (change.difference.numerator !== undefined) {\n if (constant.hasNumerator && constant.numerator !== change.difference.numerator) {\n throw new Error(`Failed to merged, constant numerator conflict: ${change.difference.numerator} -> ${constant.numerator}`);\n }\n constant.setNumerator(change.difference.numerator);\n }\n if (change.difference.phenomenon !== undefined) {\n const lookupKey = await updateSchemaItemKey(context, change.difference.phenomenon);\n const phenomenon = await context.editor.schemaContext.getSchemaItem<Phenomenon>(lookupKey);\n if (phenomenon === undefined) {\n throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);\n }\n\n constant.setPhenomenon(new DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));\n }\n}\n"]}
1
+ {"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAcA,kCAkBC;AAMD,wCAqCC;AApED,gEAA+H;AAC/H,mCAAwE;AAExE;;;GAGG;AACI,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,MAA0B;IACvF,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,8DAA8D;IAC9D,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAErG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACtE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;QACxC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;KACzC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA0B,EAAE,OAAsB;IAClH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAoB,CAAC;IACnF,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,OAAO,CAAC,MAAM,CAAC,SAA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AAC,UAAU,CAAC,SAAS,EAAE,CAAC;YAChF,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,gBAAgB,MAAM,CAAC,QAAQ,wCAAwC,CAAC,CAAC;QACnI,CAAC;QACD,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,8BAAU,CAAC,CAAC;QAC3F,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAC5F,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { ConstantDifference } from \"../Differencing/SchemaDifference\";\nimport type{ MutableConstant } from \"../Editing/Mutable/MutableConstant\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { DelayedPromiseWithProps, ECObjectsError, ECObjectsStatus, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Constant into the target schema.\n * @internal\n */\nexport async function addConstant(context: SchemaMergeContext, change: ConstantDifference) {\n if (change.difference.phenomenon === undefined) {\n throw new Error(\"Constant must define phenomenon\");\n }\n if (change.difference.definition === undefined) {\n throw new Error(\"Constant must define definition\");\n }\n\n // Needs to update the reference from source to target schema.\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\n\n await context.editor.constants.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n phenomenon: change.difference.phenomenon,\n definition: change.difference.definition,\n });\n}\n\n/**\n * Merges differences to an existing Constant in the target schema.\n * @internal\n */\nexport async function modifyConstant(context: SchemaMergeContext, change: ConstantDifference, itemKey: SchemaItemKey) {\n const constant = await context.targetSchema.lookupItem(itemKey) as MutableConstant;\n if (change.difference.label !== undefined) {\n await context.editor.constants.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.constants.setDescription(itemKey, change.difference.description);\n }\n\n // Note: There are no editor methods to modify a constant.\n if (change.difference.definition !== undefined) {\n if (change.difference.definition !== \"\" && constant.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'definition' attribute.`);\n }\n constant.setDefinition(change.difference.definition);\n }\n if (change.difference.denominator !== undefined) {\n if (constant.hasDenominator && constant.denominator !== change.difference.denominator) {\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'denominator' attribute.`);\n }\n constant.setDenominator(change.difference.denominator);\n }\n if (change.difference.numerator !== undefined) {\n if (constant.hasNumerator && constant.numerator !== change.difference.numerator) {\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${change.itemName} has an invalid 'numerator' attribute.`);\n }\n constant.setNumerator(change.difference.numerator);\n }\n if (change.difference.phenomenon !== undefined) {\n const lookupKey = await updateSchemaItemKey(context, change.difference.phenomenon);\n const phenomenon = await context.editor.schemaContext.getSchemaItem(lookupKey, Phenomenon);\n if (phenomenon === undefined) {\n throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);\n }\n\n constant.setPhenomenon(new DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CustomAttributeMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAA0D,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAGlF,KAAK,qBAAqB,GAAG,CAAC,eAAe,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjF;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CtH;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAI3J;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvJ"}
1
+ {"version":3,"file":"CustomAttributeMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAA2C,MAAM,0BAA0B,CAAC;AACpG,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAGlF,KAAK,qBAAqB,GAAG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