@itwin/ecschema-metadata 5.0.0-dev.8 → 5.0.0-dev.82

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 (274) hide show
  1. package/CHANGELOG.md +46 -1
  2. package/lib/cjs/Constants.js +20 -20
  3. package/lib/cjs/Constants.js.map +1 -1
  4. package/lib/cjs/Context.d.ts +60 -20
  5. package/lib/cjs/Context.d.ts.map +1 -1
  6. package/lib/cjs/Context.js +43 -19
  7. package/lib/cjs/Context.js.map +1 -1
  8. package/lib/cjs/DelayedPromise.js +6 -4
  9. package/lib/cjs/DelayedPromise.js.map +1 -1
  10. package/lib/cjs/Deserialization/AbstractParser.js +1 -0
  11. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  12. package/lib/cjs/Deserialization/Helper.d.ts +3 -3
  13. package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
  14. package/lib/cjs/Deserialization/Helper.js +8 -0
  15. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  16. package/lib/cjs/Deserialization/JsonParser.js +3 -0
  17. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  18. package/lib/cjs/Deserialization/JsonProps.d.ts +3 -0
  19. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  20. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  21. package/lib/cjs/Deserialization/XmlParser.js +11 -1
  22. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  23. package/lib/cjs/ECName.js +1 -0
  24. package/lib/cjs/ECName.js.map +1 -1
  25. package/lib/cjs/ECObjects.d.ts +21 -1
  26. package/lib/cjs/ECObjects.d.ts.map +1 -1
  27. package/lib/cjs/ECObjects.js +34 -2
  28. package/lib/cjs/ECObjects.js.map +1 -1
  29. package/lib/cjs/Exception.js +1 -0
  30. package/lib/cjs/Exception.js.map +1 -1
  31. package/lib/cjs/Interfaces.d.ts +10 -3
  32. package/lib/cjs/Interfaces.d.ts.map +1 -1
  33. package/lib/cjs/Interfaces.js.map +1 -1
  34. package/lib/cjs/Metadata/Class.d.ts +53 -5
  35. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  36. package/lib/cjs/Metadata/Class.js +118 -19
  37. package/lib/cjs/Metadata/Class.js.map +1 -1
  38. package/lib/cjs/Metadata/Constant.d.ts +14 -1
  39. package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
  40. package/lib/cjs/Metadata/Constant.js +27 -2
  41. package/lib/cjs/Metadata/Constant.js.map +1 -1
  42. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +16 -4
  43. package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
  44. package/lib/cjs/Metadata/CustomAttributeClass.js +22 -4
  45. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  46. package/lib/cjs/Metadata/EntityClass.d.ts +18 -6
  47. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  48. package/lib/cjs/Metadata/EntityClass.js +29 -9
  49. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  50. package/lib/cjs/Metadata/Enumeration.d.ts +14 -1
  51. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  52. package/lib/cjs/Metadata/Enumeration.js +22 -1
  53. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  54. package/lib/cjs/Metadata/Format.d.ts +41 -1
  55. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  56. package/lib/cjs/Metadata/Format.js +68 -3
  57. package/lib/cjs/Metadata/Format.js.map +1 -1
  58. package/lib/cjs/Metadata/InvertedUnit.d.ts +8 -3
  59. package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
  60. package/lib/cjs/Metadata/InvertedUnit.js +17 -6
  61. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  62. package/lib/cjs/Metadata/KindOfQuantity.d.ts +14 -3
  63. package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
  64. package/lib/cjs/Metadata/KindOfQuantity.js +43 -18
  65. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  66. package/lib/cjs/Metadata/Mixin.d.ts +15 -1
  67. package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
  68. package/lib/cjs/Metadata/Mixin.js +23 -2
  69. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  70. package/lib/cjs/Metadata/OverrideFormat.js +9 -0
  71. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  72. package/lib/cjs/Metadata/Phenomenon.d.ts +14 -1
  73. package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
  74. package/lib/cjs/Metadata/Phenomenon.js +22 -1
  75. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  76. package/lib/cjs/Metadata/Property.d.ts +1 -1
  77. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  78. package/lib/cjs/Metadata/Property.js +83 -28
  79. package/lib/cjs/Metadata/Property.js.map +1 -1
  80. package/lib/cjs/Metadata/PropertyCategory.d.ts +14 -1
  81. package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
  82. package/lib/cjs/Metadata/PropertyCategory.js +21 -1
  83. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  84. package/lib/cjs/Metadata/RelationshipClass.d.ts +15 -2
  85. package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
  86. package/lib/cjs/Metadata/RelationshipClass.js +47 -10
  87. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  88. package/lib/cjs/Metadata/Schema.d.ts +116 -11
  89. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  90. package/lib/cjs/Metadata/Schema.js +135 -33
  91. package/lib/cjs/Metadata/Schema.js.map +1 -1
  92. package/lib/cjs/Metadata/SchemaItem.d.ts +11 -2
  93. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  94. package/lib/cjs/Metadata/SchemaItem.js +10 -0
  95. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  96. package/lib/cjs/Metadata/Unit.d.ts +8 -1
  97. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  98. package/lib/cjs/Metadata/Unit.js +21 -3
  99. package/lib/cjs/Metadata/Unit.js.map +1 -1
  100. package/lib/cjs/Metadata/UnitSystem.d.ts +14 -3
  101. package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
  102. package/lib/cjs/Metadata/UnitSystem.js +21 -3
  103. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  104. package/lib/cjs/SchemaJsonLocater.d.ts +3 -3
  105. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  106. package/lib/cjs/SchemaJsonLocater.js +3 -3
  107. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  108. package/lib/cjs/SchemaKey.d.ts +7 -1
  109. package/lib/cjs/SchemaKey.d.ts.map +1 -1
  110. package/lib/cjs/SchemaKey.js +13 -3
  111. package/lib/cjs/SchemaKey.js.map +1 -1
  112. package/lib/cjs/SchemaLoader.d.ts +2 -2
  113. package/lib/cjs/SchemaLoader.d.ts.map +1 -1
  114. package/lib/cjs/SchemaLoader.js +1 -0
  115. package/lib/cjs/SchemaLoader.js.map +1 -1
  116. package/lib/cjs/SchemaPartVisitorDelegate.js +1 -0
  117. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  118. package/lib/cjs/UnitConversion/Graph.js +69 -65
  119. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  120. package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
  121. package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
  122. package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
  123. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  124. package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
  125. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  126. package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
  127. package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
  128. package/lib/cjs/UnitConversion/UnitTree.js +11 -1
  129. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  130. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +6 -3
  131. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  132. package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
  133. package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
  134. package/lib/cjs/Validation/SchemaWalker.js +4 -0
  135. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  136. package/lib/cjs/utils/SchemaGraph.js +2 -3
  137. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  138. package/lib/esm/Constants.js +20 -20
  139. package/lib/esm/Constants.js.map +1 -1
  140. package/lib/esm/Context.d.ts +60 -20
  141. package/lib/esm/Context.d.ts.map +1 -1
  142. package/lib/esm/Context.js +41 -17
  143. package/lib/esm/Context.js.map +1 -1
  144. package/lib/esm/DelayedPromise.js +6 -4
  145. package/lib/esm/DelayedPromise.js.map +1 -1
  146. package/lib/esm/Deserialization/AbstractParser.js +1 -0
  147. package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
  148. package/lib/esm/Deserialization/Helper.d.ts +3 -3
  149. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  150. package/lib/esm/Deserialization/Helper.js +8 -0
  151. package/lib/esm/Deserialization/Helper.js.map +1 -1
  152. package/lib/esm/Deserialization/JsonParser.js +3 -0
  153. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  154. package/lib/esm/Deserialization/JsonProps.d.ts +3 -0
  155. package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
  156. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  157. package/lib/esm/Deserialization/XmlParser.js +11 -1
  158. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  159. package/lib/esm/ECName.js +1 -0
  160. package/lib/esm/ECName.js.map +1 -1
  161. package/lib/esm/ECObjects.d.ts +21 -1
  162. package/lib/esm/ECObjects.d.ts.map +1 -1
  163. package/lib/esm/ECObjects.js +32 -1
  164. package/lib/esm/ECObjects.js.map +1 -1
  165. package/lib/esm/Exception.js +1 -0
  166. package/lib/esm/Exception.js.map +1 -1
  167. package/lib/esm/Interfaces.d.ts +10 -3
  168. package/lib/esm/Interfaces.d.ts.map +1 -1
  169. package/lib/esm/Interfaces.js.map +1 -1
  170. package/lib/esm/Metadata/Class.d.ts +53 -5
  171. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  172. package/lib/esm/Metadata/Class.js +119 -20
  173. package/lib/esm/Metadata/Class.js.map +1 -1
  174. package/lib/esm/Metadata/Constant.d.ts +14 -1
  175. package/lib/esm/Metadata/Constant.d.ts.map +1 -1
  176. package/lib/esm/Metadata/Constant.js +27 -2
  177. package/lib/esm/Metadata/Constant.js.map +1 -1
  178. package/lib/esm/Metadata/CustomAttributeClass.d.ts +16 -4
  179. package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
  180. package/lib/esm/Metadata/CustomAttributeClass.js +22 -4
  181. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  182. package/lib/esm/Metadata/EntityClass.d.ts +18 -6
  183. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  184. package/lib/esm/Metadata/EntityClass.js +29 -9
  185. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  186. package/lib/esm/Metadata/Enumeration.d.ts +14 -1
  187. package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
  188. package/lib/esm/Metadata/Enumeration.js +22 -1
  189. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  190. package/lib/esm/Metadata/Format.d.ts +41 -1
  191. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  192. package/lib/esm/Metadata/Format.js +68 -3
  193. package/lib/esm/Metadata/Format.js.map +1 -1
  194. package/lib/esm/Metadata/InvertedUnit.d.ts +8 -3
  195. package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
  196. package/lib/esm/Metadata/InvertedUnit.js +17 -6
  197. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  198. package/lib/esm/Metadata/KindOfQuantity.d.ts +14 -3
  199. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
  200. package/lib/esm/Metadata/KindOfQuantity.js +43 -18
  201. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  202. package/lib/esm/Metadata/Mixin.d.ts +15 -1
  203. package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
  204. package/lib/esm/Metadata/Mixin.js +24 -3
  205. package/lib/esm/Metadata/Mixin.js.map +1 -1
  206. package/lib/esm/Metadata/OverrideFormat.js +9 -0
  207. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  208. package/lib/esm/Metadata/Phenomenon.d.ts +14 -1
  209. package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
  210. package/lib/esm/Metadata/Phenomenon.js +22 -1
  211. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  212. package/lib/esm/Metadata/Property.d.ts +1 -1
  213. package/lib/esm/Metadata/Property.d.ts.map +1 -1
  214. package/lib/esm/Metadata/Property.js +84 -29
  215. package/lib/esm/Metadata/Property.js.map +1 -1
  216. package/lib/esm/Metadata/PropertyCategory.d.ts +14 -1
  217. package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
  218. package/lib/esm/Metadata/PropertyCategory.js +21 -1
  219. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  220. package/lib/esm/Metadata/RelationshipClass.d.ts +15 -2
  221. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
  222. package/lib/esm/Metadata/RelationshipClass.js +48 -11
  223. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  224. package/lib/esm/Metadata/Schema.d.ts +116 -11
  225. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  226. package/lib/esm/Metadata/Schema.js +135 -33
  227. package/lib/esm/Metadata/Schema.js.map +1 -1
  228. package/lib/esm/Metadata/SchemaItem.d.ts +11 -2
  229. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  230. package/lib/esm/Metadata/SchemaItem.js +11 -1
  231. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  232. package/lib/esm/Metadata/Unit.d.ts +8 -1
  233. package/lib/esm/Metadata/Unit.d.ts.map +1 -1
  234. package/lib/esm/Metadata/Unit.js +21 -3
  235. package/lib/esm/Metadata/Unit.js.map +1 -1
  236. package/lib/esm/Metadata/UnitSystem.d.ts +14 -3
  237. package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
  238. package/lib/esm/Metadata/UnitSystem.js +21 -3
  239. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  240. package/lib/esm/SchemaJsonLocater.d.ts +3 -3
  241. package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
  242. package/lib/esm/SchemaJsonLocater.js +3 -3
  243. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  244. package/lib/esm/SchemaKey.d.ts +7 -1
  245. package/lib/esm/SchemaKey.d.ts.map +1 -1
  246. package/lib/esm/SchemaKey.js +13 -3
  247. package/lib/esm/SchemaKey.js.map +1 -1
  248. package/lib/esm/SchemaLoader.d.ts +2 -2
  249. package/lib/esm/SchemaLoader.d.ts.map +1 -1
  250. package/lib/esm/SchemaLoader.js +1 -0
  251. package/lib/esm/SchemaLoader.js.map +1 -1
  252. package/lib/esm/SchemaPartVisitorDelegate.js +1 -0
  253. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  254. package/lib/esm/UnitConversion/Graph.js +69 -65
  255. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  256. package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
  257. package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
  258. package/lib/esm/UnitConversion/UnitConversion.js +9 -7
  259. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  260. package/lib/esm/UnitConversion/UnitConverter.js +2 -0
  261. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  262. package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
  263. package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
  264. package/lib/esm/UnitConversion/UnitTree.js +11 -1
  265. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  266. package/lib/esm/UnitProvider/SchemaUnitProvider.js +6 -3
  267. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  268. package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
  269. package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
  270. package/lib/esm/Validation/SchemaWalker.js +4 -0
  271. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  272. package/lib/esm/utils/SchemaGraph.js +2 -3
  273. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  274. package/package.json +14 -14
@@ -15,6 +15,7 @@ const ECObjects_1 = require("../ECObjects");
15
15
  const Exception_1 = require("../Exception");
16
16
  const SchemaKey_1 = require("../SchemaKey");
17
17
  const CustomAttribute_1 = require("./CustomAttribute");
18
+ const Enumeration_1 = require("./Enumeration");
18
19
  const Property_1 = require("./Property");
19
20
  const SchemaItem_1 = require("./SchemaItem");
20
21
  const Helper_1 = require("../Deserialization/Helper");
@@ -23,9 +24,14 @@ const Helper_1 = require("../Deserialization/Helper");
23
24
  * @beta
24
25
  */
25
26
  class ECClass extends SchemaItem_1.SchemaItem {
27
+ static get schemaItemType() { return ECObjects_1.AbstractSchemaItemType.Class; } // need this so getItem("name", ECClass) in schema works
28
+ _modifier;
29
+ _baseClass;
30
+ _derivedClasses;
31
+ _properties;
32
+ _customAttributes;
33
+ _mergedPropertyCache;
26
34
  get modifier() { return this._modifier; }
27
- get baseClass() { return this._baseClass; }
28
- set baseClass(baseClass) { this._baseClass = baseClass; }
29
35
  get properties() { return this._properties?.values(); }
30
36
  get customAttributes() { return this._customAttributes; }
31
37
  constructor(schema, name, modifier) {
@@ -35,6 +41,32 @@ class ECClass extends SchemaItem_1.SchemaItem {
35
41
  else
36
42
  this._modifier = ECObjects_1.ECClassModifier.None;
37
43
  }
44
+ /**
45
+ * Gets the base class if it exists, otherwise returns undefined.
46
+ */
47
+ get baseClass() {
48
+ return this._baseClass;
49
+ }
50
+ /**
51
+ * Sets the base class of the ECClass. Pass undefined to 'remove' the base class.
52
+ */
53
+ async setBaseClass(baseClass) {
54
+ const oldBaseClass = this._baseClass;
55
+ this._baseClass = baseClass;
56
+ if (baseClass)
57
+ this.addDerivedClass(await baseClass, this);
58
+ else if (oldBaseClass)
59
+ this.removeDerivedClass(await oldBaseClass, this);
60
+ }
61
+ /**
62
+ * Gets the derived classes belonging to this class.
63
+ * @returns An array of ECClasses or undefined if no derived classes exist.
64
+ */
65
+ async getDerivedClasses() {
66
+ if (!this._derivedClasses || this._derivedClasses.size === 0)
67
+ return undefined;
68
+ return Array.from(await Promise.all(this._derivedClasses.values()));
69
+ }
38
70
  /**
39
71
  * Convenience method for adding an already loaded ECProperty used by create*Property methods.
40
72
  * @param prop The property to add.
@@ -74,7 +106,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
74
106
  if (!this.baseClass) {
75
107
  return undefined;
76
108
  }
77
- return this.schema.lookupItemSync(this.baseClass);
109
+ return this.schema.lookupItemSync(this.baseClass, ECClass);
78
110
  }
79
111
  /**
80
112
  * Searches, case-insensitive, for a local ECProperty with the name provided.
@@ -204,7 +236,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
204
236
  async loadStructType(structType, schema) {
205
237
  let correctType;
206
238
  if (typeof (structType) === "string") {
207
- correctType = await schema.lookupItem(structType);
239
+ correctType = await schema.lookupItem(structType, StructClass);
208
240
  }
209
241
  else
210
242
  correctType = structType;
@@ -215,7 +247,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
215
247
  loadStructTypeSync(structType, schema) {
216
248
  let correctType;
217
249
  if (typeof (structType) === "string") {
218
- correctType = schema.lookupItemSync(structType);
250
+ correctType = schema.lookupItemSync(structType, StructClass);
219
251
  }
220
252
  else
221
253
  correctType = structType;
@@ -229,7 +261,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
229
261
  if (typeof (primitiveType) === "string") {
230
262
  let resolvedType = (0, ECObjects_1.parsePrimitiveType)(primitiveType);
231
263
  if (!resolvedType) {
232
- resolvedType = await schema.lookupItem(primitiveType);
264
+ resolvedType = await schema.lookupItem(primitiveType, Enumeration_1.Enumeration);
233
265
  }
234
266
  if (resolvedType === undefined)
235
267
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
@@ -246,7 +278,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
246
278
  if (typeof (primitiveType) === "string") {
247
279
  let resolvedType = (0, ECObjects_1.parsePrimitiveType)(primitiveType);
248
280
  if (!resolvedType) {
249
- resolvedType = schema.lookupItemSync(primitiveType);
281
+ resolvedType = schema.lookupItemSync(primitiveType, Enumeration_1.Enumeration);
250
282
  }
251
283
  if (resolvedType === undefined)
252
284
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
@@ -320,12 +352,25 @@ class ECClass extends SchemaItem_1.SchemaItem {
320
352
  const ecClassSchemaItemKey = this.schema.getSchemaItemKey(classProps.baseClass);
321
353
  if (!ecClassSchemaItemKey)
322
354
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);
323
- this._baseClass = new DelayedPromise_1.DelayedPromiseWithProps(ecClassSchemaItemKey, async () => {
324
- const baseClass = await this.schema.lookupItem(ecClassSchemaItemKey);
325
- if (undefined === baseClass)
326
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);
327
- return baseClass;
328
- });
355
+ const baseClass = this.schema.lookupItemSync(ecClassSchemaItemKey);
356
+ let lazyBase;
357
+ if (!baseClass) {
358
+ lazyBase = new DelayedPromise_1.DelayedPromiseWithProps(ecClassSchemaItemKey, async () => {
359
+ const baseItem = await this.schema.lookupItem(ecClassSchemaItemKey);
360
+ if (undefined === baseItem || !ECClass.isECClass(baseItem))
361
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);
362
+ return baseItem;
363
+ });
364
+ }
365
+ else {
366
+ lazyBase = new DelayedPromise_1.DelayedPromiseWithProps(ecClassSchemaItemKey, async () => {
367
+ return baseClass;
368
+ });
369
+ }
370
+ this._baseClass = lazyBase;
371
+ if (!baseClass)
372
+ return;
373
+ this.addDerivedClass(baseClass, this);
329
374
  }
330
375
  }
331
376
  async fromJSON(classProps) {
@@ -344,8 +389,8 @@ class ECClass extends SchemaItem_1.SchemaItem {
344
389
  const baseClasses = [this];
345
390
  const addBaseClasses = async (ecClass) => {
346
391
  if (ECObjects_1.SchemaItemType.EntityClass === ecClass.schemaItemType) {
347
- for (let i = (ecClass).mixins.length - 1; i >= 0; i--) {
348
- baseClasses.push(await (ecClass).mixins[i]);
392
+ for (let i = ecClass.mixins.length - 1; i >= 0; i--) {
393
+ baseClasses.push(await ecClass.mixins[i]);
349
394
  }
350
395
  }
351
396
  if (ecClass.baseClass)
@@ -361,7 +406,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
361
406
  *getAllBaseClassesSync() {
362
407
  const baseClasses = [this];
363
408
  const addBaseClasses = (ecClass) => {
364
- if (ECObjects_1.SchemaItemType.EntityClass === ecClass.schemaItemType) {
409
+ if (ecClass.schemaItemType === ECObjects_1.SchemaItemType.EntityClass) { // cannot use EntityClass typeguard because of circular reference
365
410
  for (const m of Array.from(ecClass.getMixinsSync()).reverse()) {
366
411
  baseClasses.push(m);
367
412
  }
@@ -536,6 +581,35 @@ class ECClass extends SchemaItem_1.SchemaItem {
536
581
  setModifier(modifier) {
537
582
  this._modifier = modifier;
538
583
  }
584
+ /**
585
+ * Adds an ECClass to the derived class collection. This method is only intended to update the local
586
+ * cache of derived classes. For adding a class to the hierarchy, use the baseClass setter method.
587
+ * @param prop The property to add.
588
+ * @return The property that was added.
589
+ */
590
+ addDerivedClass(baseClass, derivedClass) {
591
+ if (!baseClass._derivedClasses)
592
+ baseClass._derivedClasses = new Map();
593
+ if (baseClass._derivedClasses.has(derivedClass.fullName))
594
+ return;
595
+ if (derivedClass.isSync(baseClass)) {
596
+ const promise = new DelayedPromise_1.DelayedPromiseWithProps(derivedClass.key, async () => derivedClass);
597
+ baseClass._derivedClasses.set(derivedClass.fullName, promise);
598
+ }
599
+ }
600
+ /**
601
+ * Removes an ECClass from the derived class collection. This method is only intended to update the local
602
+ * cache of derived classes. For updating the class hierarchy, use the baseClass setter method.
603
+ * @param prop The property to add.
604
+ * @return The property that was added.
605
+ */
606
+ removeDerivedClass(baseClass, derivedClass) {
607
+ if (!baseClass._derivedClasses)
608
+ return;
609
+ if (!baseClass._derivedClasses.has(derivedClass.fullName))
610
+ return;
611
+ baseClass._derivedClasses.delete(derivedClass.fullName);
612
+ }
539
613
  }
540
614
  exports.ECClass = ECClass;
541
615
  /**
@@ -543,9 +617,34 @@ exports.ECClass = ECClass;
543
617
  * @beta
544
618
  */
545
619
  class StructClass extends ECClass {
546
- constructor(schema, name, modifier) {
547
- super(schema, name, modifier);
548
- this.schemaItemType = ECObjects_1.SchemaItemType.StructClass;
620
+ /**
621
+ * Get the type of item represented by this instance
622
+ * @beta
623
+ */
624
+ schemaItemType = StructClass.schemaItemType;
625
+ /**
626
+ * Get the type of item represented by this class
627
+ * @beta
628
+ */
629
+ static get schemaItemType() { return ECObjects_1.SchemaItemType.StructClass; }
630
+ /**
631
+ * Type guard to check if the SchemaItem is of type StructClass.
632
+ * @param item The SchemaItem to check.
633
+ * @returns True if the item is a StructClass, false otherwise.
634
+ */
635
+ static isStructClass(item) {
636
+ if (item && item.schemaItemType === ECObjects_1.SchemaItemType.StructClass)
637
+ return true;
638
+ return false;
639
+ }
640
+ /**
641
+ * Type assertion to check if the SchemaItem is of type StructClass.
642
+ * @param item The SchemaItem to check.
643
+ * @returns The item cast to StructClass if it is a StructClass, undefined otherwise.
644
+ */
645
+ static assertIsStructClass(item) {
646
+ if (!this.isStructClass(item))
647
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.StructClass}' (StructClass)`);
549
648
  }
550
649
  }
551
650
  exports.StructClass = StructClass;
@@ -1 +1 @@
1
- {"version":3,"file":"Class.js","sourceRoot":"","sources":["../../../src/Metadata/Class.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA6I;AAC7I,4CAA+D;AAE/D,4CAAwD;AACxD,uDAAkI;AAElI,yCAEoB;AAEpB,6CAA0C;AAC1C,sDAA4E;AAE5E;;;GAGG;AACH,MAAsB,OAAQ,SAAQ,uBAAU;IAO9C,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAChD,IAAW,SAAS,KAAoC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjF,IAAW,SAAS,CAAC,SAAwC,IAAI,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/F,IAAW,UAAU,KAA6C,OAAO,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IACtG,IAAW,gBAAgB,KAAqC,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAEhG,YAAY,MAAc,EAAE,IAAY,EAAE,QAA0B;QAClE,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAEpB,IAAI,QAAQ;YACV,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;;YAE1B,IAAI,CAAC,SAAS,GAAG,2BAAe,CAAC,IAAI,CAA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G,QAAQ,CAAC;IAC5B,CAAC;CACF;AAtpBD,0BAspBC;AAED;;;GAGG;AACH,MAAa,WAAY,SAAQ,OAAO;IAGtC,YAAY,MAAc,EAAE,IAAY,EAAE,QAA0B;QAClE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,0BAAc,CAAC,WAAW,CAAC;IACnD,CAAC;CACF;AAPD,kCAOC;AAED;;;GAGG;AACH,MAAsB,kBAAmB,SAAQ,WAAW;CAE3D;AAFD,gDAEC;AAED;;;GAGG;AACH,MAAsB,YAAa,SAAQ,OAAO;CA4BjD;AA5BD,oCA4BC","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 Metadata\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { ClassProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { classModifierToString, ECClassModifier, parseClassModifier, parsePrimitiveType, PrimitiveType, SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { AnyClass, LazyLoadedECClass } from \"../Interfaces\";\nimport { SchemaItemKey, SchemaKey } from \"../SchemaKey\";\nimport { CustomAttribute, CustomAttributeContainerProps, CustomAttributeSet, serializeCustomAttributes } from \"./CustomAttribute\";\nimport { Enumeration } from \"./Enumeration\";\nimport {\n EnumerationArrayProperty, EnumerationProperty, PrimitiveArrayProperty, PrimitiveProperty, Property, StructArrayProperty, StructProperty,\n} from \"./Property\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { ECSpecVersion, SchemaReadHelper } from \"../Deserialization/Helper\";\n\n/**\n * A common abstract class for all of the ECClass types.\n * @beta\n */\nexport abstract class ECClass extends SchemaItem implements CustomAttributeContainerProps {\n protected _modifier: ECClassModifier;\n protected _baseClass?: LazyLoadedECClass;\n protected _properties?: Map<string, Property>;\n private _customAttributes?: Map<string, CustomAttribute>;\n private _mergedPropertyCache?: Property[];\n\n public get modifier() { return this._modifier; }\n public get baseClass(): LazyLoadedECClass | undefined { return this._baseClass; }\n public set baseClass(baseClass: LazyLoadedECClass | undefined) { this._baseClass = baseClass; }\n public get properties(): IterableIterator<Property> | undefined { return this._properties?.values(); }\n public get customAttributes(): CustomAttributeSet | undefined { return this._customAttributes; }\n\n constructor(schema: Schema, name: string, modifier?: ECClassModifier) {\n super(schema, name);\n\n if (modifier)\n this._modifier = modifier;\n else\n this._modifier = ECClassModifier.None;\n }\n\n /**\n * Convenience method for adding an already loaded ECProperty used by create*Property methods.\n * @param prop The property to add.\n * @return The property that was added.\n */\n protected addProperty<T extends Property>(prop: T): T {\n if (!this._properties)\n this._properties = new Map<string, Property>();\n\n this._properties.set(prop.name.toUpperCase(), prop);\n return prop;\n }\n\n /**\n * Deletes a property from within this class.\n * @param name The property name to delete, lookup is case-insensitive\n * @alpha\n */\n protected async deleteProperty(name: string): Promise<void> {\n if (this._properties) {\n const property = await this.getProperty(name);\n if (property)\n this._properties.delete(name.toUpperCase());\n }\n }\n\n /**\n * Deletes a property from within this class.\n * @param name The property name to delete, lookup is case-insensitive\n * @alpha\n */\n protected deletePropertySync(name: string): void {\n if (this._properties) {\n const property = this.getPropertySync(name);\n if (property)\n this._properties.delete(name.toUpperCase());\n }\n }\n\n public getBaseClassSync(): ECClass | undefined {\n if (!this.baseClass) {\n return undefined;\n }\n\n return this.schema.lookupItemSync<ECClass>(this.baseClass);\n }\n\n /**\n * Searches, case-insensitive, for a local ECProperty with the name provided.\n * @param name\n */\n public async getProperty(name: string, includeInherited: boolean = false): Promise<Property | undefined> {\n if (this._properties) {\n const upperKey = name.toUpperCase();\n const property = this._properties.get(upperKey);\n if (property)\n return property;\n }\n\n if (!includeInherited) {\n return undefined;\n }\n\n return this.getInheritedProperty(name);\n }\n\n /**\n * Searches, case-insensitive, for a local ECProperty with the name provided.\n * @param name\n */\n public getPropertySync(name: string, includeInherited: boolean = false): Property | undefined {\n if (this._properties) {\n const upperKey = name.toUpperCase();\n const property = this._properties.get(upperKey);\n if (property)\n return property;\n }\n\n if (!includeInherited) {\n return undefined;\n }\n\n return this.getInheritedPropertySync(name);\n }\n\n /**\n * Searches the base class, if one exists, for the property with the name provided.\n * @param name The name of the inherited property to find.\n */\n public async getInheritedProperty(name: string): Promise<Property | undefined> {\n if (this.baseClass) {\n const baseClassObj = await this.baseClass;\n return baseClassObj.getProperty(name, true);\n }\n\n return undefined;\n }\n\n /**\n * Searches the base class, if one exists, for the property with the name provided.\n * @param name The name of the inherited property to find.\n */\n public getInheritedPropertySync(name: string): Property | undefined {\n const baseClassObj = this.getBaseClassSync();\n if (baseClassObj)\n return baseClassObj.getPropertySync(name, true);\n\n return undefined;\n }\n\n /**\n * Creates a PrimitiveECProperty.\n * @param name The name of property to create.\n * @param primitiveType The primitive type of property to create. If not provided the default is PrimitiveType.Integer\n * @throws ECObjectsStatus DuplicateProperty: thrown if a property with the same name already exists in the class.\n */\n protected async createPrimitiveProperty(name: string, primitiveType: PrimitiveType): Promise<PrimitiveProperty>;\n protected async createPrimitiveProperty(name: string, primitiveType: Enumeration): Promise<EnumerationProperty>;\n protected async createPrimitiveProperty(name: string, primitiveType?: string | PrimitiveType | Enumeration): Promise<Property> {\n if (await this.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n const propType = await this.loadPrimitiveType(primitiveType, this.schema);\n if (typeof (propType) === \"number\")\n return this.addProperty(new PrimitiveProperty(this, name, propType));\n\n return this.addProperty(new EnumerationProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));\n }\n\n /**\n * Creates a PrimitiveECProperty.\n * @param name The name of property to create.\n * @param primitiveType The primitive type of property to create. If not provided the default is PrimitiveType.Integer\n * @throws ECObjectsStatus DuplicateProperty: thrown if a property with the same name already exists in the class.\n */\n protected createPrimitivePropertySync(name: string, primitiveType: PrimitiveType): PrimitiveProperty;\n protected createPrimitivePropertySync(name: string, primitiveType: Enumeration): EnumerationProperty;\n protected createPrimitivePropertySync(name: string, primitiveType?: string | PrimitiveType | Enumeration): Property {\n if (this.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n const propType = this.loadPrimitiveTypeSync(primitiveType, this.schema);\n if (typeof (propType) === \"number\")\n return this.addProperty(new PrimitiveProperty(this, name, propType));\n\n return this.addProperty(new EnumerationProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));\n }\n\n /**\n * Creates a PrimitiveArrayECProperty.\n * @param name The name of property to create.\n * @param primitiveType The primitive type of property to create. If not provided the default is PrimitiveType.Integer\n */\n protected async createPrimitiveArrayProperty(name: string, primitiveType: PrimitiveType): Promise<PrimitiveArrayProperty>;\n protected async createPrimitiveArrayProperty(name: string, primitiveType: Enumeration): Promise<EnumerationArrayProperty>;\n protected async createPrimitiveArrayProperty(name: string, primitiveType?: string | PrimitiveType | Enumeration): Promise<Property> {\n if (await this.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n const propType = await this.loadPrimitiveType(primitiveType, this.schema);\n if (typeof (propType) === \"number\")\n return this.addProperty(new PrimitiveArrayProperty(this, name, propType));\n\n return this.addProperty(new EnumerationArrayProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));\n }\n\n /**\n * Creates a PrimitiveArrayECProperty.\n * @param name The name of property to create.\n * @param primitiveType The primitive type of property to create. If not provided the default is PrimitiveType.Integer\n */\n protected createPrimitiveArrayPropertySync(name: string, primitiveType: PrimitiveType): PrimitiveArrayProperty;\n protected createPrimitiveArrayPropertySync(name: string, primitiveType: Enumeration): EnumerationArrayProperty;\n protected createPrimitiveArrayPropertySync(name: string, primitiveType?: string | PrimitiveType | Enumeration): Property {\n if (this.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n const propType = this.loadPrimitiveTypeSync(primitiveType, this.schema);\n if (typeof (propType) === \"number\")\n return this.addProperty(new PrimitiveArrayProperty(this, name, propType));\n\n return this.addProperty(new EnumerationArrayProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));\n }\n\n /**\n *\n * @param name The name of property to create.\n * @param structType The struct type of property to create.\n */\n protected async createStructProperty(name: string, structType: string | StructClass): Promise<StructProperty> {\n if (await this.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n return this.addProperty(new StructProperty(this, name, await this.loadStructType(structType, this.schema)));\n }\n\n /**\n *\n * @param name The name of property to create.\n * @param structType The struct type of property to create.\n */\n protected createStructPropertySync(name: string, structType: string | StructClass): StructProperty {\n if (this.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n return this.addProperty(new StructProperty(this, name, this.loadStructTypeSync(structType, this.schema)));\n }\n\n /**\n *\n * @param name\n * @param type\n */\n protected async createStructArrayProperty(name: string, structType: string | StructClass): Promise<StructArrayProperty> {\n if (await this.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n return this.addProperty(new StructArrayProperty(this, name, await this.loadStructType(structType, this.schema)));\n }\n\n /**\n *\n * @param name\n * @param type\n */\n protected createStructArrayPropertySync(name: string, structType: string | StructClass): StructArrayProperty {\n if (this.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n return this.addProperty(new StructArrayProperty(this, name, this.loadStructTypeSync(structType, this.schema)));\n }\n\n protected async loadStructType(structType: string | StructClass | undefined, schema: Schema): Promise<StructClass> {\n let correctType: StructClass | undefined;\n if (typeof (structType) === \"string\") {\n correctType = await schema.lookupItem<StructClass>(structType);\n } else\n correctType = structType;\n\n if (!correctType)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);\n\n return correctType;\n }\n\n protected loadStructTypeSync(structType: string | StructClass | undefined, schema: Schema): StructClass {\n let correctType: StructClass | undefined;\n if (typeof (structType) === \"string\") {\n correctType = schema.lookupItemSync<StructClass>(structType);\n } else\n correctType = structType;\n\n if (!correctType)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);\n\n return correctType;\n }\n\n protected async loadPrimitiveType(primitiveType: string | PrimitiveType | Enumeration | undefined, schema: Schema): Promise<PrimitiveType | Enumeration> {\n if (primitiveType === undefined)\n return PrimitiveType.Integer;\n\n if (typeof (primitiveType) === \"string\") {\n let resolvedType: (PrimitiveType | Enumeration | undefined) = parsePrimitiveType(primitiveType);\n if (!resolvedType) {\n resolvedType = await schema.lookupItem<Enumeration>(primitiveType);\n }\n\n if (resolvedType === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);\n\n // If resolvedType is a SchemaItem, make sure it is an Enumeration- if not, throw an error\n if (typeof (resolvedType) !== \"number\" && resolvedType.schemaItemType !== SchemaItemType.Enumeration)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);\n\n return resolvedType;\n }\n\n return primitiveType;\n }\n\n protected loadPrimitiveTypeSync(primitiveType: string | PrimitiveType | Enumeration | undefined, schema: Schema): PrimitiveType | Enumeration {\n if (primitiveType === undefined)\n return PrimitiveType.Integer;\n\n if (typeof (primitiveType) === \"string\") {\n let resolvedType: (PrimitiveType | Enumeration | undefined) = parsePrimitiveType(primitiveType);\n if (!resolvedType) {\n resolvedType = schema.lookupItemSync<Enumeration>(primitiveType);\n }\n\n if (resolvedType === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);\n\n return resolvedType;\n }\n\n return primitiveType;\n }\n\n /**\n * Save this Classes properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): ClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n const isMixin = SchemaItemType.Mixin === this.schemaItemType;\n const isRelationship = SchemaItemType.RelationshipClass === this.schemaItemType;\n if (!isMixin && (ECClassModifier.None !== this.modifier || isRelationship))\n schemaJson.modifier = classModifierToString(this.modifier);\n if (this.baseClass !== undefined)\n schemaJson.baseClass = this.baseClass.fullName;\n if (this._properties !== undefined && this._properties.size > 0)\n schemaJson.properties = [...this.properties!].map((prop) => prop.toJSON());\n\n const customAttributes = serializeCustomAttributes(this.customAttributes);\n if (customAttributes !== undefined)\n schemaJson.customAttributes = customAttributes;\n return schemaJson as ClassProps;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n if (undefined !== this.modifier)\n itemElement.setAttribute(\"modifier\", classModifierToString(this.modifier));\n\n if (undefined !== this.baseClass) {\n const baseClass = await this.baseClass;\n const baseClassElement = schemaXml.createElement(\"BaseClass\");\n const baseClassName = XmlSerializationUtils.createXmlTypedName(this.schema, baseClass.schema, baseClass.name);\n baseClassElement.textContent = baseClassName;\n itemElement.appendChild(baseClassElement);\n }\n\n if (undefined !== this.properties) {\n for (const prop of this.properties) {\n const propXml = await prop.toXml(schemaXml);\n itemElement.appendChild(propXml);\n }\n }\n\n if (this._customAttributes) {\n const caContainerElement = schemaXml.createElement(\"ECCustomAttributes\");\n for (const [name, attribute] of this._customAttributes) {\n const caElement = await XmlSerializationUtils.writeCustomAttribute(name, attribute, schemaXml, this.schema);\n caContainerElement.appendChild(caElement);\n }\n itemElement.appendChild(caContainerElement);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(classProps: ClassProps) {\n super.fromJSONSync(classProps);\n\n if (undefined !== classProps.modifier) {\n const modifier = parseClassModifier(classProps.modifier);\n if (undefined === modifier) {\n if (SchemaReadHelper.isECSpecVersionNewer({readVersion: classProps.originalECSpecMajorVersion, writeVersion: classProps.originalECSpecMinorVersion} as ECSpecVersion))\n this._modifier = ECClassModifier.None;\n else\n throw new ECObjectsError(ECObjectsStatus.InvalidModifier, `The string '${classProps.modifier}' is not a valid ECClassModifier.`);\n } else {\n this._modifier = modifier;\n }\n }\n\n if (undefined !== classProps.baseClass) {\n const ecClassSchemaItemKey = this.schema.getSchemaItemKey(classProps.baseClass);\n if (!ecClassSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);\n this._baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(ecClassSchemaItemKey,\n async () => {\n const baseClass = await this.schema.lookupItem<ECClass>(ecClassSchemaItemKey);\n if (undefined === baseClass)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);\n return baseClass;\n });\n }\n }\n\n public override async fromJSON(classProps: ClassProps): Promise<void> {\n this.fromJSONSync(classProps);\n }\n\n protected addCustomAttribute(customAttribute: CustomAttribute) {\n if (!this._customAttributes)\n this._customAttributes = new Map<string, CustomAttribute>();\n\n this._customAttributes.set(customAttribute.className, customAttribute);\n }\n\n /**\n * Iterates (recursively) over all base classes and mixins, in \"property override\" order.\n * This is essentially a depth-first traversal through the inheritance tree.\n */\n public async *getAllBaseClasses(): AsyncIterableIterator<ECClass> {\n const baseClasses: ECClass[] = [this];\n const addBaseClasses = async (ecClass: AnyClass) => {\n if (SchemaItemType.EntityClass === ecClass.schemaItemType) {\n for (let i = (ecClass).mixins.length - 1; i >= 0; i--) {\n baseClasses.push(await (ecClass).mixins[i]);\n }\n }\n\n if (ecClass.baseClass)\n baseClasses.push(await ecClass.baseClass);\n };\n\n while (baseClasses.length > 0) {\n const baseClass = baseClasses.pop() as AnyClass;\n await addBaseClasses(baseClass);\n if (baseClass !== this)\n yield baseClass as ECClass;\n }\n }\n\n public *getAllBaseClassesSync(): Iterable<AnyClass> {\n const baseClasses: ECClass[] = [this];\n const addBaseClasses = (ecClass: AnyClass) => {\n if (SchemaItemType.EntityClass === ecClass.schemaItemType) {\n for (const m of Array.from(ecClass.getMixinsSync()).reverse()) {\n baseClasses.push(m);\n }\n }\n\n const baseClass = ecClass.getBaseClassSync();\n if (baseClass)\n baseClasses.push(baseClass);\n };\n\n while (baseClasses.length > 0) {\n const baseClass = baseClasses.pop() as AnyClass;\n addBaseClasses(baseClass);\n if (baseClass !== this)\n yield baseClass;\n }\n }\n\n protected static mergeProperties(target: Property[], existingValues: Map<string, number>, propertiesToMerge: Property[], overwriteExisting: boolean) {\n for (const property of propertiesToMerge) {\n const upperCaseName = property.name.toUpperCase();\n const existing = existingValues.get(upperCaseName);\n if (existing !== undefined) {\n if (overwriteExisting) {\n target[existing] = property;\n }\n } else {\n existingValues.set(upperCaseName, target.length);\n target.push(property);\n }\n }\n }\n\n protected async buildPropertyCache(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): Promise<void> {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n if (this.baseClass) {\n ECClass.mergeProperties(result, existingValues, await (await this.baseClass).getProperties(resetBaseCaches), false);\n }\n\n if (!this.properties)\n return;\n\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\n }\n\n protected buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): void {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n const baseClass = this.getBaseClassSync();\n if (baseClass) {\n ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(resetBaseCaches), false);\n }\n\n if (!this.properties)\n return;\n\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\n }\n\n /**\n * Iterates all properties, including the ones merged from base classes and mixins. To obtain only local properties, use the 'properties' field.\n * Since this is an expensive operation, results will be cached after first call.\n * @param resetCache if true, any previously cached results will be dropped and cache will be rebuilt\n */\n public getPropertiesSync(resetCache: boolean = false): Property[] {\n if (!this._mergedPropertyCache || resetCache) {\n this._mergedPropertyCache = [];\n this.buildPropertyCacheSync(this._mergedPropertyCache, undefined, resetCache);\n }\n\n return this._mergedPropertyCache;\n }\n\n /**\n * Iterates all properties, including the ones merged from base classes and mixins. To obtain only local properties, use the 'properties' field.\n * Since this is an expensive operation, results will be cached after first call.\n * @param resetCache if true, any previously cached results will be dropped and cache will be rebuilt\n */\n public async getProperties(resetCache: boolean = false): Promise<Property[]> {\n if (!this._mergedPropertyCache || resetCache) {\n this._mergedPropertyCache = [];\n await this.buildPropertyCache(this._mergedPropertyCache, undefined, resetCache);\n }\n\n return this._mergedPropertyCache;\n }\n\n /**\n * Retrieve all custom attributes in the current class and its bases\n * This is the async version of getCustomAttributesSync()\n */\n public async getCustomAttributes(): Promise<CustomAttributeSet> {\n return this.getCustomAttributesSync();\n }\n\n /**\n * Retrieve all custom attributes in the current class and its bases.\n */\n public getCustomAttributesSync(): CustomAttributeSet {\n let customAttributes: Map<string, CustomAttribute> | undefined = this._customAttributes;\n if (undefined === customAttributes) {\n customAttributes = new Map<string, CustomAttribute>();\n }\n\n this.traverseBaseClassesSync((ecClass: ECClass) => {\n if (undefined === ecClass.customAttributes)\n return false;\n\n for (const [className, customAttribute] of ecClass.customAttributes) {\n if (customAttributes.has(className))\n continue;\n customAttributes.set(className, customAttribute);\n }\n\n return false;\n });\n\n return customAttributes;\n }\n\n /**\n * Asynchronously traverses through the inheritance tree, using depth-first traversal, calling the given callback\n * function for each base class encountered.\n * @param callback The function to call for each base class in the hierarchy.\n * @param arg An argument that will be passed as the second parameter to the callback function.\n */\n public async traverseBaseClasses(callback: (ecClass: ECClass, arg?: any) => boolean, arg?: any): Promise<boolean> {\n for await (const baseClass of this.getAllBaseClasses()) {\n if (callback(baseClass, arg))\n return true;\n }\n\n return false;\n }\n\n /**\n * Synchronously traverses through the inheritance tree, using depth-first traversal, calling the given callback\n * function for each base class encountered.\n * @param callback The function to call for each base class in the hierarchy.\n * @param arg An argument that will be passed as the second parameter to the callback function.\n */\n public traverseBaseClassesSync(callback: (ecClass: ECClass, arg?: any) => boolean, arg?: any): boolean {\n const baseClasses = this.getAllBaseClassesSync();\n if (!baseClasses)\n return false;\n\n for (const baseClass of baseClasses) {\n if (callback(baseClass, arg))\n return true;\n }\n\n return false;\n }\n\n /**\n * Indicates if the targetClass is of this type.\n * @param targetClass The ECClass or ECClass name to check.\n * @param schemaName The schema name. Required if targetClass is the ECClass name.\n */\n public async is(targetClass: string, schemaName: string): Promise<boolean>;\n public async is(targetClass: ECClass): Promise<boolean>;\n public async is(targetClass: ECClass | string, schemaName?: string): Promise<boolean> {\n if (schemaName !== undefined) {\n assert(typeof (targetClass) === \"string\", \"Expected targetClass of type string because schemaName was specified\");\n\n const key = new SchemaItemKey(targetClass, new SchemaKey(schemaName));\n if (SchemaItem.equalByKey(this, key))\n return true;\n\n return this.traverseBaseClasses((thisSchemaItem, thatSchemaItemOrKey) => SchemaItem.equalByKey(thisSchemaItem, thatSchemaItemOrKey), key);\n } else {\n assert(ECClass.isECClass(targetClass), \"Expected targetClass to be of type ECClass\");\n\n if (SchemaItem.equalByKey(this, targetClass))\n return true;\n\n return this.traverseBaseClasses((thisSchemaItem, thatSchemaItemOrKey) => SchemaItem.equalByKey(thisSchemaItem, thatSchemaItemOrKey), targetClass);\n }\n }\n\n /**\n * A synchronous version of the [[ECClass.is]], indicating if the targetClass is of this type.\n * @param targetClass The class to check.\n */\n public isSync(targetClass: ECClass): boolean {\n if (SchemaItem.equalByKey(this, targetClass))\n return true;\n\n return this.traverseBaseClassesSync((thisSchemaItem, thatSchemaItemOrKey) => SchemaItem.equalByKey(thisSchemaItem, thatSchemaItemOrKey), targetClass);\n }\n\n /**\n * @internal\n */\n public static isECClass(object: any): object is ECClass {\n if (!SchemaItem.isSchemaItem(object))\n return false;\n\n return object.schemaItemType === SchemaItemType.EntityClass || object.schemaItemType === SchemaItemType.Mixin || object.schemaItemType === SchemaItemType.RelationshipClass ||\n object.schemaItemType === SchemaItemType.StructClass || object.schemaItemType === SchemaItemType.CustomAttributeClass;\n }\n\n /**\n * @alpha\n * A setter method for the ECClass modifier, used specifically for schema editing.\n * @param modifier\n */\n protected setModifier(modifier: ECClassModifier) {\n this._modifier = modifier;\n }\n}\n\n/**\n * A Typescript class representation of an ECStructClass.\n * @beta\n */\nexport class StructClass extends ECClass {\n public override readonly schemaItemType!: SchemaItemType.StructClass;\n\n constructor(schema: Schema, name: string, modifier?: ECClassModifier) {\n super(schema, name, modifier);\n this.schemaItemType = SchemaItemType.StructClass;\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableStructClass extends StructClass {\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableClass extends ECClass {\n public abstract override addCustomAttribute(customAttribute: CustomAttribute): void;\n public abstract override setModifier(modifier: ECClassModifier): void;\n public abstract override setName(name: string): void;\n public abstract override createPrimitiveProperty(name: string, primitiveType: PrimitiveType): Promise<PrimitiveProperty>;\n public abstract override createPrimitiveProperty(name: string, primitiveType: Enumeration): Promise<EnumerationProperty>;\n public abstract override createPrimitiveProperty(name: string, primitiveType?: string | PrimitiveType | Enumeration): Promise<Property>;\n\n public abstract override createPrimitivePropertySync(name: string, primitiveType: PrimitiveType): PrimitiveProperty;\n public abstract override createPrimitivePropertySync(name: string, primitiveType: Enumeration): EnumerationProperty;\n public abstract override createPrimitivePropertySync(name: string, primitiveType?: string | PrimitiveType | Enumeration): Property;\n\n public abstract override createPrimitiveArrayProperty(name: string, primitiveType: PrimitiveType): Promise<PrimitiveArrayProperty>;\n public abstract override createPrimitiveArrayProperty(name: string, primitiveType: Enumeration): Promise<EnumerationArrayProperty>;\n public abstract override createPrimitiveArrayProperty(name: string, primitiveType?: string | PrimitiveType | Enumeration): Promise<Property>;\n\n public abstract override createPrimitiveArrayPropertySync(name: string, primitiveType: PrimitiveType): PrimitiveArrayProperty;\n public abstract override createPrimitiveArrayPropertySync(name: string, primitiveType: Enumeration): EnumerationArrayProperty;\n public abstract override createPrimitiveArrayPropertySync(name: string, primitiveType?: string | PrimitiveType | Enumeration): Property;\n\n public abstract override createStructProperty(name: string, structType: string | StructClass): Promise<StructProperty>;\n public abstract override createStructPropertySync(name: string, structType: string | StructClass): StructProperty;\n\n public abstract override createStructArrayProperty(name: string, structType: string | StructClass): Promise<StructArrayProperty>;\n public abstract override createStructArrayPropertySync(name: string, structType: string | StructClass): StructArrayProperty;\n\n public abstract override deleteProperty(name: string): Promise<void>;\n public abstract override deletePropertySync(name: string): void;\n}\n"]}
1
+ {"version":3,"file":"Class.js","sourceRoot":"","sources":["../../../src/Metadata/Class.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8L;AAC9L,4CAA+D;AAE/D,4CAAwD;AACxD,uDAAkI;AAClI,+CAA4C;AAC5C,yCAEoB;AAEpB,6CAA0C;AAC1C,sDAA4E;AAE5E;;;GAGG;AACH,MAAsB,OAAQ,SAAQ,uBAAU;IACvC,MAAM,KAAc,cAAc,KAA8B,OAAO,kCAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,wDAAwD;IAC5J,SAAS,CAAkB;IAC3B,UAAU,CAAqB;IAC/B,eAAe,CAAkC;IACjD,WAAW,CAAy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,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;CACF;AA1uBD,0BA0uBC;AAED;;;GAGG;AACH,MAAa,WAAY,SAAQ,OAAO;IACtC;;;OAGG;IACsB,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IAErE;;;OAGG;IACI,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,WAAW,CAAC,CAAC,CAAC;IAClF;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,IAAiB;QAC3C,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,WAAW;YAC5D,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAiB;QACjD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YAC3B,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,WAAW,iBAAiB,CAAC,CAAC;IAC9H,CAAC;CACF;AAjCD,kCAiCC;AAED;;;GAGG;AACH,MAAsB,kBAAmB,SAAQ,WAAW;CAE3D;AAFD,gDAEC;AAED;;;GAGG;AACH,MAAsB,YAAa,SAAQ,OAAO;CA6BjD;AA7BD,oCA6BC","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 Metadata\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { ClassProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { AbstractSchemaItemType, classModifierToString, ECClassModifier, parseClassModifier, parsePrimitiveType, PrimitiveType, SchemaItemType, SupportedSchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { AnyClass, HasMixins, LazyLoadedECClass } from \"../Interfaces\";\nimport { SchemaItemKey, SchemaKey } from \"../SchemaKey\";\nimport { CustomAttribute, CustomAttributeContainerProps, CustomAttributeSet, serializeCustomAttributes } from \"./CustomAttribute\";\nimport { Enumeration } from \"./Enumeration\";\nimport {\n EnumerationArrayProperty, EnumerationProperty, PrimitiveArrayProperty, PrimitiveProperty, Property, StructArrayProperty, StructProperty,\n} from \"./Property\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { ECSpecVersion, SchemaReadHelper } from \"../Deserialization/Helper\";\n\n/**\n * A common abstract class for all of the ECClass types.\n * @beta\n */\nexport abstract class ECClass extends SchemaItem implements CustomAttributeContainerProps {\n public static override get schemaItemType(): SupportedSchemaItemType { return AbstractSchemaItemType.Class; } // need this so getItem(\"name\", ECClass) in schema works\n protected _modifier: ECClassModifier;\n protected _baseClass?: LazyLoadedECClass;\n protected _derivedClasses?: Map<string, LazyLoadedECClass>;\n protected _properties?: Map<string, Property>;\n private _customAttributes?: Map<string, CustomAttribute>;\n private _mergedPropertyCache?: Property[];\n\n public get modifier() { return this._modifier; }\n public get properties(): IterableIterator<Property> | undefined { return this._properties?.values(); }\n public get customAttributes(): CustomAttributeSet | undefined { return this._customAttributes; }\n\n constructor(schema: Schema, name: string, modifier?: ECClassModifier) {\n super(schema, name);\n\n if (modifier)\n this._modifier = modifier;\n else\n this._modifier = ECClassModifier.None;\n }\n\n /**\n * Gets the base class if it exists, otherwise returns undefined.\n */\n public get baseClass(): LazyLoadedECClass | undefined {\n return this._baseClass;\n }\n\n /**\n * Sets the base class of the ECClass. Pass undefined to 'remove' the base class.\n */\n protected async setBaseClass(baseClass: LazyLoadedECClass | undefined) {\n const oldBaseClass = this._baseClass;\n this._baseClass = baseClass;\n\n if (baseClass)\n this.addDerivedClass(await baseClass, this);\n else if (oldBaseClass)\n this.removeDerivedClass(await oldBaseClass, this);\n }\n\n /**\n * Gets the derived classes belonging to this class.\n * @returns An array of ECClasses or undefined if no derived classes exist.\n */\n public async getDerivedClasses(): Promise<ECClass [] | undefined> {\n if (!this._derivedClasses || this._derivedClasses.size === 0)\n return undefined;\n\n return Array.from(await Promise.all(this._derivedClasses.values()));\n }\n\n /**\n * Convenience method for adding an already loaded ECProperty used by create*Property methods.\n * @param prop The property to add.\n * @return The property that was added.\n */\n protected addProperty<T extends Property>(prop: T): T {\n if (!this._properties)\n this._properties = new Map<string, Property>();\n\n this._properties.set(prop.name.toUpperCase(), prop);\n return prop;\n }\n\n /**\n * Deletes a property from within this class.\n * @param name The property name to delete, lookup is case-insensitive\n * @alpha\n */\n protected async deleteProperty(name: string): Promise<void> {\n if (this._properties) {\n const property = await this.getProperty(name);\n if (property)\n this._properties.delete(name.toUpperCase());\n }\n }\n\n /**\n * Deletes a property from within this class.\n * @param name The property name to delete, lookup is case-insensitive\n * @alpha\n */\n protected deletePropertySync(name: string): void {\n if (this._properties) {\n const property = this.getPropertySync(name);\n if (property)\n this._properties.delete(name.toUpperCase());\n }\n }\n\n public getBaseClassSync(): ECClass | undefined {\n if (!this.baseClass) {\n return undefined;\n }\n\n return this.schema.lookupItemSync(this.baseClass, ECClass);\n }\n\n /**\n * Searches, case-insensitive, for a local ECProperty with the name provided.\n * @param name\n */\n public async getProperty(name: string, includeInherited: boolean = false): Promise<Property | undefined> {\n if (this._properties) {\n const upperKey = name.toUpperCase();\n const property = this._properties.get(upperKey);\n if (property)\n return property;\n }\n\n if (!includeInherited) {\n return undefined;\n }\n\n return this.getInheritedProperty(name);\n }\n\n /**\n * Searches, case-insensitive, for a local ECProperty with the name provided.\n * @param name\n */\n public getPropertySync(name: string, includeInherited: boolean = false): Property | undefined {\n if (this._properties) {\n const upperKey = name.toUpperCase();\n const property = this._properties.get(upperKey);\n if (property)\n return property;\n }\n\n if (!includeInherited) {\n return undefined;\n }\n\n return this.getInheritedPropertySync(name);\n }\n\n /**\n * Searches the base class, if one exists, for the property with the name provided.\n * @param name The name of the inherited property to find.\n */\n public async getInheritedProperty(name: string): Promise<Property | undefined> {\n if (this.baseClass) {\n const baseClassObj = await this.baseClass;\n return baseClassObj.getProperty(name, true);\n }\n\n return undefined;\n }\n\n /**\n * Searches the base class, if one exists, for the property with the name provided.\n * @param name The name of the inherited property to find.\n */\n public getInheritedPropertySync(name: string): Property | undefined {\n const baseClassObj = this.getBaseClassSync();\n if (baseClassObj)\n return baseClassObj.getPropertySync(name, true);\n\n return undefined;\n }\n\n /**\n * Creates a PrimitiveECProperty.\n * @param name The name of property to create.\n * @param primitiveType The primitive type of property to create. If not provided the default is PrimitiveType.Integer\n * @throws ECObjectsStatus DuplicateProperty: thrown if a property with the same name already exists in the class.\n */\n protected async createPrimitiveProperty(name: string, primitiveType: PrimitiveType): Promise<PrimitiveProperty>;\n protected async createPrimitiveProperty(name: string, primitiveType: Enumeration): Promise<EnumerationProperty>;\n protected async createPrimitiveProperty(name: string, primitiveType?: string | PrimitiveType | Enumeration): Promise<Property> {\n if (await this.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n const propType = await this.loadPrimitiveType(primitiveType, this.schema);\n if (typeof (propType) === \"number\")\n return this.addProperty(new PrimitiveProperty(this, name, propType));\n\n return this.addProperty(new EnumerationProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));\n }\n\n /**\n * Creates a PrimitiveECProperty.\n * @param name The name of property to create.\n * @param primitiveType The primitive type of property to create. If not provided the default is PrimitiveType.Integer\n * @throws ECObjectsStatus DuplicateProperty: thrown if a property with the same name already exists in the class.\n */\n protected createPrimitivePropertySync(name: string, primitiveType: PrimitiveType): PrimitiveProperty;\n protected createPrimitivePropertySync(name: string, primitiveType: Enumeration): EnumerationProperty;\n protected createPrimitivePropertySync(name: string, primitiveType?: string | PrimitiveType | Enumeration): Property {\n if (this.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n const propType = this.loadPrimitiveTypeSync(primitiveType, this.schema);\n if (typeof (propType) === \"number\")\n return this.addProperty(new PrimitiveProperty(this, name, propType));\n\n return this.addProperty(new EnumerationProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));\n }\n\n /**\n * Creates a PrimitiveArrayECProperty.\n * @param name The name of property to create.\n * @param primitiveType The primitive type of property to create. If not provided the default is PrimitiveType.Integer\n */\n protected async createPrimitiveArrayProperty(name: string, primitiveType: PrimitiveType): Promise<PrimitiveArrayProperty>;\n protected async createPrimitiveArrayProperty(name: string, primitiveType: Enumeration): Promise<EnumerationArrayProperty>;\n protected async createPrimitiveArrayProperty(name: string, primitiveType?: string | PrimitiveType | Enumeration): Promise<Property> {\n if (await this.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n const propType = await this.loadPrimitiveType(primitiveType, this.schema);\n if (typeof (propType) === \"number\")\n return this.addProperty(new PrimitiveArrayProperty(this, name, propType));\n\n return this.addProperty(new EnumerationArrayProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));\n }\n\n /**\n * Creates a PrimitiveArrayECProperty.\n * @param name The name of property to create.\n * @param primitiveType The primitive type of property to create. If not provided the default is PrimitiveType.Integer\n */\n protected createPrimitiveArrayPropertySync(name: string, primitiveType: PrimitiveType): PrimitiveArrayProperty;\n protected createPrimitiveArrayPropertySync(name: string, primitiveType: Enumeration): EnumerationArrayProperty;\n protected createPrimitiveArrayPropertySync(name: string, primitiveType?: string | PrimitiveType | Enumeration): Property {\n if (this.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n const propType = this.loadPrimitiveTypeSync(primitiveType, this.schema);\n if (typeof (propType) === \"number\")\n return this.addProperty(new PrimitiveArrayProperty(this, name, propType));\n\n return this.addProperty(new EnumerationArrayProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));\n }\n\n /**\n *\n * @param name The name of property to create.\n * @param structType The struct type of property to create.\n */\n protected async createStructProperty(name: string, structType: string | StructClass): Promise<StructProperty> {\n if (await this.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n return this.addProperty(new StructProperty(this, name, await this.loadStructType(structType, this.schema)));\n }\n\n /**\n *\n * @param name The name of property to create.\n * @param structType The struct type of property to create.\n */\n protected createStructPropertySync(name: string, structType: string | StructClass): StructProperty {\n if (this.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n return this.addProperty(new StructProperty(this, name, this.loadStructTypeSync(structType, this.schema)));\n }\n\n /**\n *\n * @param name\n * @param type\n */\n protected async createStructArrayProperty(name: string, structType: string | StructClass): Promise<StructArrayProperty> {\n if (await this.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n return this.addProperty(new StructArrayProperty(this, name, await this.loadStructType(structType, this.schema)));\n }\n\n /**\n *\n * @param name\n * @param type\n */\n protected createStructArrayPropertySync(name: string, structType: string | StructClass): StructArrayProperty {\n if (this.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);\n\n return this.addProperty(new StructArrayProperty(this, name, this.loadStructTypeSync(structType, this.schema)));\n }\n\n protected async loadStructType(structType: string | StructClass | undefined, schema: Schema): Promise<StructClass> {\n let correctType: StructClass | undefined;\n if (typeof (structType) === \"string\") {\n correctType = await schema.lookupItem(structType, StructClass);\n } else\n correctType = structType;\n\n if (!correctType)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);\n\n return correctType;\n }\n\n protected loadStructTypeSync(structType: string | StructClass | undefined, schema: Schema): StructClass {\n let correctType: StructClass | undefined;\n if (typeof (structType) === \"string\") {\n correctType = schema.lookupItemSync(structType, StructClass);\n } else\n correctType = structType;\n\n if (!correctType)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);\n\n return correctType;\n }\n\n protected async loadPrimitiveType(primitiveType: string | PrimitiveType | Enumeration | undefined, schema: Schema): Promise<PrimitiveType | Enumeration> {\n if (primitiveType === undefined)\n return PrimitiveType.Integer;\n\n if (typeof (primitiveType) === \"string\") {\n let resolvedType: (PrimitiveType | Enumeration | undefined) = parsePrimitiveType(primitiveType);\n if (!resolvedType) {\n resolvedType = await schema.lookupItem(primitiveType, Enumeration);\n }\n\n if (resolvedType === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);\n\n // If resolvedType is a SchemaItem, make sure it is an Enumeration- if not, throw an error\n if (typeof (resolvedType) !== \"number\" && resolvedType.schemaItemType !== SchemaItemType.Enumeration)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);\n\n return resolvedType;\n }\n\n return primitiveType;\n }\n\n protected loadPrimitiveTypeSync(primitiveType: string | PrimitiveType | Enumeration | undefined, schema: Schema): PrimitiveType | Enumeration {\n if (primitiveType === undefined)\n return PrimitiveType.Integer;\n\n if (typeof (primitiveType) === \"string\") {\n let resolvedType: (PrimitiveType | Enumeration | undefined) = parsePrimitiveType(primitiveType);\n if (!resolvedType) {\n resolvedType = schema.lookupItemSync(primitiveType, Enumeration);\n }\n\n if (resolvedType === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);\n\n return resolvedType;\n }\n\n return primitiveType;\n }\n\n /**\n * Save this Classes properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): ClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n const isMixin = SchemaItemType.Mixin === this.schemaItemType;\n const isRelationship = SchemaItemType.RelationshipClass === this.schemaItemType;\n if (!isMixin && (ECClassModifier.None !== this.modifier || isRelationship))\n schemaJson.modifier = classModifierToString(this.modifier);\n if (this.baseClass !== undefined)\n schemaJson.baseClass = this.baseClass.fullName;\n if (this._properties !== undefined && this._properties.size > 0)\n schemaJson.properties = [...this.properties!].map((prop) => prop.toJSON());\n\n const customAttributes = serializeCustomAttributes(this.customAttributes);\n if (customAttributes !== undefined)\n schemaJson.customAttributes = customAttributes;\n return schemaJson as ClassProps;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n if (undefined !== this.modifier)\n itemElement.setAttribute(\"modifier\", classModifierToString(this.modifier));\n\n if (undefined !== this.baseClass) {\n const baseClass = await this.baseClass;\n const baseClassElement = schemaXml.createElement(\"BaseClass\");\n const baseClassName = XmlSerializationUtils.createXmlTypedName(this.schema, baseClass.schema, baseClass.name);\n baseClassElement.textContent = baseClassName;\n itemElement.appendChild(baseClassElement);\n }\n\n if (undefined !== this.properties) {\n for (const prop of this.properties) {\n const propXml = await prop.toXml(schemaXml);\n itemElement.appendChild(propXml);\n }\n }\n\n if (this._customAttributes) {\n const caContainerElement = schemaXml.createElement(\"ECCustomAttributes\");\n for (const [name, attribute] of this._customAttributes) {\n const caElement = await XmlSerializationUtils.writeCustomAttribute(name, attribute, schemaXml, this.schema);\n caContainerElement.appendChild(caElement);\n }\n itemElement.appendChild(caContainerElement);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(classProps: ClassProps) {\n super.fromJSONSync(classProps);\n\n if (undefined !== classProps.modifier) {\n const modifier = parseClassModifier(classProps.modifier);\n if (undefined === modifier) {\n if (SchemaReadHelper.isECSpecVersionNewer({ readVersion: classProps.originalECSpecMajorVersion, writeVersion: classProps.originalECSpecMinorVersion } as ECSpecVersion))\n this._modifier = ECClassModifier.None;\n else\n throw new ECObjectsError(ECObjectsStatus.InvalidModifier, `The string '${classProps.modifier}' is not a valid ECClassModifier.`);\n } else {\n this._modifier = modifier;\n }\n }\n\n if (undefined !== classProps.baseClass) {\n const ecClassSchemaItemKey = this.schema.getSchemaItemKey(classProps.baseClass);\n if (!ecClassSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);\n\n const baseClass = this.schema.lookupItemSync(ecClassSchemaItemKey);\n\n let lazyBase: LazyLoadedECClass;\n if (!baseClass) {\n lazyBase = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(ecClassSchemaItemKey,\n async () => {\n const baseItem = await this.schema.lookupItem(ecClassSchemaItemKey);\n if (undefined === baseItem || !ECClass.isECClass(baseItem))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);\n return baseItem;\n });\n } else {\n lazyBase = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(ecClassSchemaItemKey,\n async () => {\n return baseClass as ECClass;\n });\n }\n\n this._baseClass = lazyBase;\n\n if (!baseClass)\n return;\n\n this.addDerivedClass(baseClass as ECClass, this);\n }\n }\n\n public override async fromJSON(classProps: ClassProps): Promise<void> {\n this.fromJSONSync(classProps);\n }\n\n protected addCustomAttribute(customAttribute: CustomAttribute) {\n if (!this._customAttributes)\n this._customAttributes = new Map<string, CustomAttribute>();\n\n this._customAttributes.set(customAttribute.className, customAttribute);\n }\n\n /**\n * Iterates (recursively) over all base classes and mixins, in \"property override\" order.\n * This is essentially a depth-first traversal through the inheritance tree.\n */\n public async *getAllBaseClasses(): AsyncIterableIterator<ECClass> {\n const baseClasses: ECClass[] = [this];\n const addBaseClasses = async (ecClass: AnyClass) => {\n if (SchemaItemType.EntityClass === ecClass.schemaItemType) {\n for (let i = (ecClass as HasMixins).mixins.length - 1; i >= 0; i--) {\n baseClasses.push(await (ecClass as HasMixins).mixins[i]);\n }\n }\n\n if (ecClass.baseClass)\n baseClasses.push(await ecClass.baseClass);\n };\n\n while (baseClasses.length > 0) {\n const baseClass = baseClasses.pop() as AnyClass;\n await addBaseClasses(baseClass);\n if (baseClass !== this)\n yield baseClass as ECClass;\n }\n }\n\n public *getAllBaseClassesSync(): Iterable<AnyClass> {\n const baseClasses: ECClass[] = [this];\n const addBaseClasses = (ecClass: AnyClass) => {\n if (ecClass.schemaItemType === SchemaItemType.EntityClass) { // cannot use EntityClass typeguard because of circular reference\n for (const m of Array.from((ecClass as HasMixins).getMixinsSync()).reverse()) {\n baseClasses.push(m);\n }\n }\n\n const baseClass = ecClass.getBaseClassSync();\n if (baseClass)\n baseClasses.push(baseClass);\n };\n\n while (baseClasses.length > 0) {\n const baseClass = baseClasses.pop() as AnyClass;\n addBaseClasses(baseClass);\n if (baseClass !== this)\n yield baseClass;\n }\n }\n\n protected static mergeProperties(target: Property[], existingValues: Map<string, number>, propertiesToMerge: Property[], overwriteExisting: boolean) {\n for (const property of propertiesToMerge) {\n const upperCaseName = property.name.toUpperCase();\n const existing = existingValues.get(upperCaseName);\n if (existing !== undefined) {\n if (overwriteExisting) {\n target[existing] = property;\n }\n } else {\n existingValues.set(upperCaseName, target.length);\n target.push(property);\n }\n }\n }\n\n protected async buildPropertyCache(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): Promise<void> {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n if (this.baseClass) {\n ECClass.mergeProperties(result, existingValues, await (await this.baseClass).getProperties(resetBaseCaches), false);\n }\n\n if (!this.properties)\n return;\n\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\n }\n\n protected buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): void {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n const baseClass = this.getBaseClassSync();\n if (baseClass) {\n ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(resetBaseCaches), false);\n }\n\n if (!this.properties)\n return;\n\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\n }\n\n /**\n * Iterates all properties, including the ones merged from base classes and mixins. To obtain only local properties, use the 'properties' field.\n * Since this is an expensive operation, results will be cached after first call.\n * @param resetCache if true, any previously cached results will be dropped and cache will be rebuilt\n */\n public getPropertiesSync(resetCache: boolean = false): Property[] {\n if (!this._mergedPropertyCache || resetCache) {\n this._mergedPropertyCache = [];\n this.buildPropertyCacheSync(this._mergedPropertyCache, undefined, resetCache);\n }\n\n return this._mergedPropertyCache;\n }\n\n /**\n * Iterates all properties, including the ones merged from base classes and mixins. To obtain only local properties, use the 'properties' field.\n * Since this is an expensive operation, results will be cached after first call.\n * @param resetCache if true, any previously cached results will be dropped and cache will be rebuilt\n */\n public async getProperties(resetCache: boolean = false): Promise<Property[]> {\n if (!this._mergedPropertyCache || resetCache) {\n this._mergedPropertyCache = [];\n await this.buildPropertyCache(this._mergedPropertyCache, undefined, resetCache);\n }\n\n return this._mergedPropertyCache;\n }\n\n /**\n * Retrieve all custom attributes in the current class and its bases\n * This is the async version of getCustomAttributesSync()\n */\n public async getCustomAttributes(): Promise<CustomAttributeSet> {\n return this.getCustomAttributesSync();\n }\n\n /**\n * Retrieve all custom attributes in the current class and its bases.\n */\n public getCustomAttributesSync(): CustomAttributeSet {\n let customAttributes: Map<string, CustomAttribute> | undefined = this._customAttributes;\n if (undefined === customAttributes) {\n customAttributes = new Map<string, CustomAttribute>();\n }\n\n this.traverseBaseClassesSync((ecClass: ECClass) => {\n if (undefined === ecClass.customAttributes)\n return false;\n\n for (const [className, customAttribute] of ecClass.customAttributes) {\n if (customAttributes.has(className))\n continue;\n customAttributes.set(className, customAttribute);\n }\n\n return false;\n });\n\n return customAttributes;\n }\n\n /**\n * Asynchronously traverses through the inheritance tree, using depth-first traversal, calling the given callback\n * function for each base class encountered.\n * @param callback The function to call for each base class in the hierarchy.\n * @param arg An argument that will be passed as the second parameter to the callback function.\n */\n public async traverseBaseClasses(callback: (ecClass: ECClass, arg?: any) => boolean, arg?: any): Promise<boolean> {\n for await (const baseClass of this.getAllBaseClasses()) {\n if (callback(baseClass, arg))\n return true;\n }\n\n return false;\n }\n\n /**\n * Synchronously traverses through the inheritance tree, using depth-first traversal, calling the given callback\n * function for each base class encountered.\n * @param callback The function to call for each base class in the hierarchy.\n * @param arg An argument that will be passed as the second parameter to the callback function.\n */\n public traverseBaseClassesSync(callback: (ecClass: ECClass, arg?: any) => boolean, arg?: any): boolean {\n const baseClasses = this.getAllBaseClassesSync();\n if (!baseClasses)\n return false;\n\n for (const baseClass of baseClasses) {\n if (callback(baseClass, arg))\n return true;\n }\n\n return false;\n }\n\n /**\n * Indicates if the targetClass is of this type.\n * @param targetClass The ECClass or ECClass name to check.\n * @param schemaName The schema name. Required if targetClass is the ECClass name.\n */\n public async is(targetClass: string, schemaName: string): Promise<boolean>;\n public async is(targetClass: ECClass): Promise<boolean>;\n public async is(targetClass: ECClass | string, schemaName?: string): Promise<boolean> {\n if (schemaName !== undefined) {\n assert(typeof (targetClass) === \"string\", \"Expected targetClass of type string because schemaName was specified\");\n\n const key = new SchemaItemKey(targetClass, new SchemaKey(schemaName));\n if (SchemaItem.equalByKey(this, key))\n return true;\n\n return this.traverseBaseClasses((thisSchemaItem, thatSchemaItemOrKey) => SchemaItem.equalByKey(thisSchemaItem, thatSchemaItemOrKey), key);\n } else {\n assert(ECClass.isECClass(targetClass), \"Expected targetClass to be of type ECClass\");\n\n if (SchemaItem.equalByKey(this, targetClass))\n return true;\n\n return this.traverseBaseClasses((thisSchemaItem, thatSchemaItemOrKey) => SchemaItem.equalByKey(thisSchemaItem, thatSchemaItemOrKey), targetClass);\n }\n }\n\n /**\n * A synchronous version of the [[ECClass.is]], indicating if the targetClass is of this type.\n * @param targetClass The class to check.\n */\n public isSync(targetClass: ECClass): boolean {\n if (SchemaItem.equalByKey(this, targetClass))\n return true;\n\n return this.traverseBaseClassesSync((thisSchemaItem, thatSchemaItemOrKey) => SchemaItem.equalByKey(thisSchemaItem, thatSchemaItemOrKey), targetClass);\n }\n\n /**\n * @internal\n */\n public static isECClass(object: any): object is ECClass {\n if (!SchemaItem.isSchemaItem(object))\n return false;\n\n return object.schemaItemType === SchemaItemType.EntityClass || object.schemaItemType === SchemaItemType.Mixin || object.schemaItemType === SchemaItemType.RelationshipClass ||\n object.schemaItemType === SchemaItemType.StructClass || object.schemaItemType === SchemaItemType.CustomAttributeClass;\n }\n\n /**\n * @alpha\n * A setter method for the ECClass modifier, used specifically for schema editing.\n * @param modifier\n */\n protected setModifier(modifier: ECClassModifier) {\n this._modifier = modifier;\n }\n\n /**\n * Adds an ECClass to the derived class collection. This method is only intended to update the local\n * cache of derived classes. For adding a class to the hierarchy, use the baseClass setter method.\n * @param prop The property to add.\n * @return The property that was added.\n */\n private addDerivedClass(baseClass: ECClass, derivedClass: ECClass) {\n if (!baseClass._derivedClasses)\n baseClass._derivedClasses = new Map<string, LazyLoadedECClass>();\n\n if (baseClass._derivedClasses.has(derivedClass.fullName))\n return;\n\n if (derivedClass.isSync(baseClass)) {\n const promise = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(derivedClass.key, async () => derivedClass);\n baseClass._derivedClasses.set(derivedClass.fullName, promise);\n }\n }\n\n /**\n * Removes an ECClass from the derived class collection. This method is only intended to update the local\n * cache of derived classes. For updating the class hierarchy, use the baseClass setter method.\n * @param prop The property to add.\n * @return The property that was added.\n */\n private removeDerivedClass(baseClass: ECClass, derivedClass: ECClass) {\n if (!baseClass._derivedClasses)\n return;\n\n if (!baseClass._derivedClasses.has(derivedClass.fullName))\n return;\n\n baseClass._derivedClasses.delete(derivedClass.fullName);\n }\n}\n\n/**\n * A Typescript class representation of an ECStructClass.\n * @beta\n */\nexport class StructClass extends ECClass {\n /**\n * Get the type of item represented by this instance\n * @beta\n */\n public override readonly schemaItemType = StructClass.schemaItemType;\n\n /**\n * Get the type of item represented by this class\n * @beta\n */\n public static override get schemaItemType() { return SchemaItemType.StructClass; }\n /**\n * Type guard to check if the SchemaItem is of type StructClass.\n * @param item The SchemaItem to check.\n * @returns True if the item is a StructClass, false otherwise.\n */\n public static isStructClass(item?: SchemaItem): item is StructClass {\n if (item && item.schemaItemType === SchemaItemType.StructClass)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type StructClass.\n * @param item The SchemaItem to check.\n * @returns The item cast to StructClass if it is a StructClass, undefined otherwise.\n */\n public static assertIsStructClass(item?: SchemaItem): asserts item is StructClass {\n if (!this.isStructClass(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.StructClass}' (StructClass)`);\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableStructClass extends StructClass {\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableClass extends ECClass {\n public abstract override setBaseClass(baseClass: LazyLoadedECClass | undefined): Promise<void>;\n public abstract override addCustomAttribute(customAttribute: CustomAttribute): void;\n public abstract override setModifier(modifier: ECClassModifier): void;\n public abstract override setName(name: string): void;\n public abstract override createPrimitiveProperty(name: string, primitiveType: PrimitiveType): Promise<PrimitiveProperty>;\n public abstract override createPrimitiveProperty(name: string, primitiveType: Enumeration): Promise<EnumerationProperty>;\n public abstract override createPrimitiveProperty(name: string, primitiveType?: string | PrimitiveType | Enumeration): Promise<Property>;\n\n public abstract override createPrimitivePropertySync(name: string, primitiveType: PrimitiveType): PrimitiveProperty;\n public abstract override createPrimitivePropertySync(name: string, primitiveType: Enumeration): EnumerationProperty;\n public abstract override createPrimitivePropertySync(name: string, primitiveType?: string | PrimitiveType | Enumeration): Property;\n\n public abstract override createPrimitiveArrayProperty(name: string, primitiveType: PrimitiveType): Promise<PrimitiveArrayProperty>;\n public abstract override createPrimitiveArrayProperty(name: string, primitiveType: Enumeration): Promise<EnumerationArrayProperty>;\n public abstract override createPrimitiveArrayProperty(name: string, primitiveType?: string | PrimitiveType | Enumeration): Promise<Property>;\n\n public abstract override createPrimitiveArrayPropertySync(name: string, primitiveType: PrimitiveType): PrimitiveArrayProperty;\n public abstract override createPrimitiveArrayPropertySync(name: string, primitiveType: Enumeration): EnumerationArrayProperty;\n public abstract override createPrimitiveArrayPropertySync(name: string, primitiveType?: string | PrimitiveType | Enumeration): Property;\n\n public abstract override createStructProperty(name: string, structType: string | StructClass): Promise<StructProperty>;\n public abstract override createStructPropertySync(name: string, structType: string | StructClass): StructProperty;\n\n public abstract override createStructArrayProperty(name: string, structType: string | StructClass): Promise<StructArrayProperty>;\n public abstract override createStructArrayPropertySync(name: string, structType: string | StructClass): StructArrayProperty;\n\n public abstract override deleteProperty(name: string): Promise<void>;\n public abstract override deletePropertySync(name: string): void;\n}\n"]}
@@ -11,7 +11,8 @@ import { SchemaItem } from "./SchemaItem";
11
11
  * @beta
12
12
  */
13
13
  export declare class Constant extends SchemaItem {
14
- readonly schemaItemType: SchemaItemType.Constant;
14
+ readonly schemaItemType: SchemaItemType;
15
+ static get schemaItemType(): SchemaItemType;
15
16
  protected _phenomenon?: LazyLoadedPhenomenon;
16
17
  protected _definition: string;
17
18
  protected _numerator?: number;
@@ -50,6 +51,18 @@ export declare class Constant extends SchemaItem {
50
51
  * @alpha Used in schema editing.
51
52
  */
52
53
  protected setDenominator(denominator: number): void;
54
+ /**
55
+ * Type guard to check if the SchemaItem is of type Constant.
56
+ * @param item The SchemaItem to check.
57
+ * @returns True if the item is a Constant, false otherwise.
58
+ */
59
+ static isConstant(item?: SchemaItem): item is Constant;
60
+ /**
61
+ * Type assertion to check if the SchemaItem is of type Constant.
62
+ * @param item The SchemaItem to check.
63
+ * @returns The item cast to Constant if it is a Constant, undefined otherwise.
64
+ */
65
+ static assertIsConstant(item?: SchemaItem): asserts item is Constant;
53
66
  }
54
67
  /**
55
68
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"Constant.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Constant.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,qBAAa,QAAS,SAAQ,UAAU;IACtC,SAAyB,cAAc,EAAG,cAAc,CAAC,QAAQ,CAAC;IAClE,SAAS,CAAC,WAAW,CAAC,EAAE,oBAAoB,CAAC;IAC7C,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;gBAEpB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAMxC,IAAW,UAAU,IAAI,oBAAoB,GAAG,SAAS,CAA6B;IACtF,IAAW,UAAU,IAAI,MAAM,CAA6B;IAC5D,IAAW,SAAS,IAAI,MAAM,CAAmC;IACjE,IAAW,WAAW,IAAI,MAAM,CAAqC;IACrE,IAAW,YAAY,IAAI,OAAO,CAA4C;IAC9E,IAAW,cAAc,IAAI,OAAO,CAA8C;IAElF;;;;OAIG;IACa,MAAM,CAAC,UAAU,GAAE,OAAe,EAAE,oBAAoB,GAAE,OAAe,GAAG,aAAa;IAYzG,gBAAgB;IACM,KAAK,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBlD,YAAY,CAAC,aAAa,EAAE,aAAa;IA8BnC,QAA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AY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -12,15 +12,21 @@ const DelayedPromise_1 = require("../DelayedPromise");
12
12
  const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtils");
13
13
  const ECObjects_1 = require("../ECObjects");
14
14
  const Exception_1 = require("../Exception");
15
+ const Phenomenon_1 = require("./Phenomenon");
15
16
  const SchemaItem_1 = require("./SchemaItem");
16
17
  /**
17
18
  * A Constant is a specific type of Unit that represents a number.
18
19
  * @beta
19
20
  */
20
21
  class Constant extends SchemaItem_1.SchemaItem {
22
+ schemaItemType = Constant.schemaItemType;
23
+ static get schemaItemType() { return ECObjects_1.SchemaItemType.Constant; }
24
+ _phenomenon;
25
+ _definition;
26
+ _numerator;
27
+ _denominator;
21
28
  constructor(schema, name) {
22
29
  super(schema, name);
23
- this.schemaItemType = ECObjects_1.SchemaItemType.Constant;
24
30
  this._definition = "";
25
31
  }
26
32
  get phenomenon() { return this._phenomenon; }
@@ -66,7 +72,7 @@ class Constant extends SchemaItem_1.SchemaItem {
66
72
  if (!schemaItemKey)
67
73
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);
68
74
  this._phenomenon = new DelayedPromise_1.DelayedPromiseWithProps(schemaItemKey, async () => {
69
- const phenom = await this.schema.lookupItem(schemaItemKey);
75
+ const phenom = await this.schema.lookupItem(schemaItemKey, Phenomenon_1.Phenomenon);
70
76
  if (undefined === phenom)
71
77
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);
72
78
  return phenom;
@@ -112,6 +118,25 @@ class Constant extends SchemaItem_1.SchemaItem {
112
118
  setDenominator(denominator) {
113
119
  this._denominator = denominator;
114
120
  }
121
+ /**
122
+ * Type guard to check if the SchemaItem is of type Constant.
123
+ * @param item The SchemaItem to check.
124
+ * @returns True if the item is a Constant, false otherwise.
125
+ */
126
+ static isConstant(item) {
127
+ if (item && item.schemaItemType === ECObjects_1.SchemaItemType.Constant)
128
+ return true;
129
+ return false;
130
+ }
131
+ /**
132
+ * Type assertion to check if the SchemaItem is of type Constant.
133
+ * @param item The SchemaItem to check.
134
+ * @returns The item cast to Constant if it is a Constant, undefined otherwise.
135
+ */
136
+ static assertIsConstant(item) {
137
+ if (!this.isConstant(item))
138
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.Constant}' (Constant)`);
139
+ }
115
140
  }
116
141
  exports.Constant = Constant;
117
142
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Constant.js","sourceRoot":"","sources":["../../../src/Metadata/Constant.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA+D;AAK/D,6CAA0C;AAE1C;;;GAGG;AACH,MAAa,QAAS,SAAQ,uBAAU;IAOtC,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,0BAAc,CAAC,QAAQ,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,IAAW,UAAU,KAAuC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACtF,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5D,IAAW,SAAS,KAAa,OAAO,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC,CAAC;IACjE,IAAW,WAAW,KAAa,OAAO,IAAI,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC,CAAC;IACrE,IAAW,YAAY,KAAc,OAAO,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC;IAC9E,IAAW,cAAc,KAAc,OAAO,CA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AAa,CAAC,SAAS,CAAC;QAC9C,CAAC;QAED,IAAI,SAAS,KAAK,aAAa,CAAC,WAAW,EAAE,CAAC;YAC5C,IAAI,aAAa,CAAC,WAAW,KAAK,IAAI,CAAC,YAAY;gBACjD,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC,WAAW,CAAC;QAClD,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,aAA4B;QACzD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACO,aAAa,CAAC,UAAgC;QACtD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,aAAa,CAAC,UAAkB;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,SAAiB;QACtC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;CACF;AArHD,4BAqHC;AACD;;;GAGG;AACH,MAAsB,eAAgB,SAAQ,QAAQ;CAMrD;AAND,0CAMC","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 Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { ConstantProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedPhenomenon } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { Phenomenon } from \"./Phenomenon\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Constant is a specific type of Unit that represents a number.\n * @beta\n */\nexport class Constant extends SchemaItem {\n public override readonly schemaItemType!: SchemaItemType.Constant;\n protected _phenomenon?: LazyLoadedPhenomenon;\n protected _definition: string;\n protected _numerator?: number;\n protected _denominator?: number;\n\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this.schemaItemType = SchemaItemType.Constant;\n this._definition = \"\";\n }\n\n public get phenomenon(): LazyLoadedPhenomenon | undefined { return this._phenomenon; }\n public get definition(): string { return this._definition; }\n public get numerator(): number { return this._numerator ?? 1.0; }\n public get denominator(): number { return this._denominator ?? 1.0; }\n public get hasNumerator(): boolean { return (this._numerator !== undefined); }\n public get hasDenominator(): boolean { return (this._denominator !== undefined); }\n\n /**\n * Save this Constants properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): ConstantProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.phenomenon !== undefined)\n schemaJson.phenomenon = this.phenomenon.fullName;\n schemaJson.definition = this.definition;\n if (this.hasNumerator)\n schemaJson.numerator = this.numerator;\n if (this.hasDenominator)\n schemaJson.denominator = this.denominator;\n return schemaJson as ConstantProps;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"definition\", this.definition);\n if (this.hasNumerator)\n itemElement.setAttribute(\"numerator\", this.numerator.toString());\n if (this.hasDenominator)\n itemElement.setAttribute(\"denominator\", this.denominator.toString());\n\n const phenomenon = await this.phenomenon;\n if (undefined !== phenomenon) {\n const phenomenonName = XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);\n itemElement.setAttribute(\"phenomenon\", phenomenonName);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(constantProps: ConstantProps) {\n super.fromJSONSync(constantProps);\n\n const schemaItemKey = this.schema.getSchemaItemKey(constantProps.phenomenon);\n if (!schemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\n this._phenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(schemaItemKey,\n async () => {\n const phenom = await this.schema.lookupItem<Phenomenon>(schemaItemKey);\n if (undefined === phenom)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\n return phenom;\n });\n\n if (this._definition !== \"\" && constantProps.definition.toLowerCase() !== this._definition.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${this.name} has an invalid 'definition' attribute.`);\n else if (this._definition === \"\")\n this._definition = constantProps.definition;\n\n if (undefined !== constantProps.numerator) {\n if (constantProps.numerator !== this._numerator)\n this._numerator = constantProps.numerator;\n }\n\n if (undefined !== constantProps.denominator) {\n if (constantProps.denominator !== this._denominator)\n this._denominator = constantProps.denominator;\n }\n }\n\n public override async fromJSON(constantProps: ConstantProps) {\n this.fromJSONSync(constantProps);\n }\n\n /**\n * @alpha Used in schema editing.\n * @param phenomenon A LazyLoadedPhenomenon.\n */\n protected setPhenomenon(phenomenon: LazyLoadedPhenomenon) {\n this._phenomenon = phenomenon;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDefinition(definition: string) {\n this._definition = definition;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setNumerator(numerator: number) {\n this._numerator = numerator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDenominator(denominator: number) {\n this._denominator = denominator;\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableConstant extends Constant {\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): void;\n public abstract override setDefinition(definition: string): void;\n public abstract override setNumerator(numerator: number): void;\n public abstract override setDenominator(denominator: number): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
1
+ {"version":3,"file":"Constant.js","sourceRoot":"","sources":["../../../src/Metadata/Constant.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA+D;AAG/D,6CAA0C;AAE1C,6CAA0C;AAE1C;;;GAGG;AACH,MAAa,QAAS,SAAQ,uBAAU;IACb,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;IAC3D,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrE,WAAW,CAAwB;IACnC,WAAW,CAAS;IACpB,UAAU,CAAU;IACpB,YAAY,CAAU;IAEhC,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,IAAW,UAAU,KAAuC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACtF,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5D,IAAW,SAAS,KAAa,OAAO,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC,CAAC;IACjE,IAAW,WAAW,KAAa,OAAO,IAAI,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC,CAAC;IACrE,IAAW,YAAY,KAAc,OAAO,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC;IAC9E,IAAW,cAAc,KAAc,OAAO,CAAC,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC;IAElF;;;;OAIG;IACa,MAAM,CAAC,aAAsB,KAAK,EAAE,uBAAgC,KAAK;QACvF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,oBAAoB,CAAQ,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,WAAW,CAAC;QAClD,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,aAA4B;QACzD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACO,aAAa,CAAC,UAAgC;QACtD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,aAAa,CAAC,UAAkB;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,SAAiB;QACtC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,IAAiB;QACxC,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,QAAQ;YACzD,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAAC,IAAiB;QAC9C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACxB,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,QAAQ,cAAc,CAAC,CAAC;IACxH,CAAC;CACF;AA3ID,4BA2IC;AACD;;;GAGG;AACH,MAAsB,eAAgB,SAAQ,QAAQ;CAMrD;AAND,0CAMC","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 Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { ConstantProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedPhenomenon } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { Phenomenon } from \"./Phenomenon\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Constant is a specific type of Unit that represents a number.\n * @beta\n */\nexport class Constant extends SchemaItem {\n public override readonly schemaItemType = Constant.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.Constant; }\n protected _phenomenon?: LazyLoadedPhenomenon;\n protected _definition: string;\n protected _numerator?: number;\n protected _denominator?: number;\n\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this._definition = \"\";\n }\n\n public get phenomenon(): LazyLoadedPhenomenon | undefined { return this._phenomenon; }\n public get definition(): string { return this._definition; }\n public get numerator(): number { return this._numerator ?? 1.0; }\n public get denominator(): number { return this._denominator ?? 1.0; }\n public get hasNumerator(): boolean { return (this._numerator !== undefined); }\n public get hasDenominator(): boolean { return (this._denominator !== undefined); }\n\n /**\n * Save this Constants properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): ConstantProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.phenomenon !== undefined)\n schemaJson.phenomenon = this.phenomenon.fullName;\n schemaJson.definition = this.definition;\n if (this.hasNumerator)\n schemaJson.numerator = this.numerator;\n if (this.hasDenominator)\n schemaJson.denominator = this.denominator;\n return schemaJson as ConstantProps;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"definition\", this.definition);\n if (this.hasNumerator)\n itemElement.setAttribute(\"numerator\", this.numerator.toString());\n if (this.hasDenominator)\n itemElement.setAttribute(\"denominator\", this.denominator.toString());\n\n const phenomenon = await this.phenomenon;\n if (undefined !== phenomenon) {\n const phenomenonName = XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);\n itemElement.setAttribute(\"phenomenon\", phenomenonName);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(constantProps: ConstantProps) {\n super.fromJSONSync(constantProps);\n\n const schemaItemKey = this.schema.getSchemaItemKey(constantProps.phenomenon);\n if (!schemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\n this._phenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(schemaItemKey,\n async () => {\n const phenom = await this.schema.lookupItem(schemaItemKey, Phenomenon);\n if (undefined === phenom)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\n return phenom;\n });\n\n if (this._definition !== \"\" && constantProps.definition.toLowerCase() !== this._definition.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${this.name} has an invalid 'definition' attribute.`);\n else if (this._definition === \"\")\n this._definition = constantProps.definition;\n\n if (undefined !== constantProps.numerator) {\n if (constantProps.numerator !== this._numerator)\n this._numerator = constantProps.numerator;\n }\n\n if (undefined !== constantProps.denominator) {\n if (constantProps.denominator !== this._denominator)\n this._denominator = constantProps.denominator;\n }\n }\n\n public override async fromJSON(constantProps: ConstantProps) {\n this.fromJSONSync(constantProps);\n }\n\n /**\n * @alpha Used in schema editing.\n * @param phenomenon A LazyLoadedPhenomenon.\n */\n protected setPhenomenon(phenomenon: LazyLoadedPhenomenon) {\n this._phenomenon = phenomenon;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDefinition(definition: string) {\n this._definition = definition;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setNumerator(numerator: number) {\n this._numerator = numerator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDenominator(denominator: number) {\n this._denominator = denominator;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type Constant.\n * @param item The SchemaItem to check.\n * @returns True if the item is a Constant, false otherwise.\n */\n public static isConstant(item?: SchemaItem): item is Constant {\n if (item && item.schemaItemType === SchemaItemType.Constant)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Constant.\n * @param item The SchemaItem to check.\n * @returns The item cast to Constant if it is a Constant, undefined otherwise.\n */\n public static assertIsConstant(item?: SchemaItem): asserts item is Constant {\n if (!this.isConstant(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Constant}' (Constant)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableConstant extends Constant {\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): void;\n public abstract override setDefinition(definition: string): void;\n public abstract override setNumerator(numerator: number): void;\n public abstract override setDenominator(denominator: number): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}