@itwin/ecschema-metadata 5.0.0-dev.11 → 5.0.0-dev.110

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 (338) hide show
  1. package/CHANGELOG.md +61 -1
  2. package/lib/cjs/Constants.d.ts +8 -0
  3. package/lib/cjs/Constants.d.ts.map +1 -1
  4. package/lib/cjs/Constants.js +30 -21
  5. package/lib/cjs/Constants.js.map +1 -1
  6. package/lib/cjs/Context.d.ts +85 -36
  7. package/lib/cjs/Context.d.ts.map +1 -1
  8. package/lib/cjs/Context.js +79 -29
  9. package/lib/cjs/Context.js.map +1 -1
  10. package/lib/cjs/DelayedPromise.d.ts +9 -8
  11. package/lib/cjs/DelayedPromise.d.ts.map +1 -1
  12. package/lib/cjs/DelayedPromise.js +8 -6
  13. package/lib/cjs/DelayedPromise.js.map +1 -1
  14. package/lib/cjs/Deserialization/AbstractParser.js +1 -0
  15. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  16. package/lib/cjs/Deserialization/Helper.d.ts +3 -3
  17. package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
  18. package/lib/cjs/Deserialization/Helper.js +35 -26
  19. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  20. package/lib/cjs/Deserialization/JsonParser.js +153 -150
  21. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  22. package/lib/cjs/Deserialization/JsonProps.d.ts +47 -33
  23. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  24. package/lib/cjs/Deserialization/JsonProps.js +3 -3
  25. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  26. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  27. package/lib/cjs/Deserialization/XmlParser.js +60 -52
  28. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  29. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +0 -5
  30. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  31. package/lib/cjs/Deserialization/XmlSerializationUtils.js +8 -17
  32. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  33. package/lib/cjs/ECName.d.ts +2 -2
  34. package/lib/cjs/ECName.js +5 -4
  35. package/lib/cjs/ECName.js.map +1 -1
  36. package/lib/cjs/ECObjects.d.ts +41 -9
  37. package/lib/cjs/ECObjects.d.ts.map +1 -1
  38. package/lib/cjs/ECObjects.js +78 -24
  39. package/lib/cjs/ECObjects.js.map +1 -1
  40. package/lib/cjs/Exception.d.ts +4 -4
  41. package/lib/cjs/Exception.d.ts.map +1 -1
  42. package/lib/cjs/Exception.js +61 -60
  43. package/lib/cjs/Exception.js.map +1 -1
  44. package/lib/cjs/Interfaces.d.ts +35 -32
  45. package/lib/cjs/Interfaces.d.ts.map +1 -1
  46. package/lib/cjs/Interfaces.js.map +1 -1
  47. package/lib/cjs/Metadata/Class.d.ts +179 -32
  48. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  49. package/lib/cjs/Metadata/Class.js +290 -88
  50. package/lib/cjs/Metadata/Class.js.map +1 -1
  51. package/lib/cjs/Metadata/Constant.d.ts +26 -10
  52. package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
  53. package/lib/cjs/Metadata/Constant.js +38 -10
  54. package/lib/cjs/Metadata/Constant.js.map +1 -1
  55. package/lib/cjs/Metadata/CustomAttribute.d.ts +2 -2
  56. package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
  57. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  58. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +21 -7
  59. package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
  60. package/lib/cjs/Metadata/CustomAttributeClass.js +28 -8
  61. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  62. package/lib/cjs/Metadata/EntityClass.d.ts +40 -11
  63. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  64. package/lib/cjs/Metadata/EntityClass.js +72 -34
  65. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  66. package/lib/cjs/Metadata/Enumeration.d.ts +30 -10
  67. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  68. package/lib/cjs/Metadata/Enumeration.js +41 -13
  69. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  70. package/lib/cjs/Metadata/Format.d.ts +65 -17
  71. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  72. package/lib/cjs/Metadata/Format.js +107 -22
  73. package/lib/cjs/Metadata/Format.js.map +1 -1
  74. package/lib/cjs/Metadata/InvertedUnit.d.ts +19 -10
  75. package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
  76. package/lib/cjs/Metadata/InvertedUnit.js +32 -15
  77. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  78. package/lib/cjs/Metadata/KindOfQuantity.d.ts +38 -18
  79. package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
  80. package/lib/cjs/Metadata/KindOfQuantity.js +90 -40
  81. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  82. package/lib/cjs/Metadata/Mixin.d.ts +31 -4
  83. package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
  84. package/lib/cjs/Metadata/Mixin.js +42 -8
  85. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  86. package/lib/cjs/Metadata/OverrideFormat.d.ts +12 -12
  87. package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
  88. package/lib/cjs/Metadata/OverrideFormat.js +36 -19
  89. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  90. package/lib/cjs/Metadata/Phenomenon.d.ts +24 -3
  91. package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
  92. package/lib/cjs/Metadata/Phenomenon.js +32 -3
  93. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  94. package/lib/cjs/Metadata/Property.d.ts +47 -25
  95. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  96. package/lib/cjs/Metadata/Property.js +128 -49
  97. package/lib/cjs/Metadata/Property.js.map +1 -1
  98. package/lib/cjs/Metadata/PropertyCategory.d.ts +20 -4
  99. package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
  100. package/lib/cjs/Metadata/PropertyCategory.js +31 -4
  101. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  102. package/lib/cjs/Metadata/RelationshipClass.d.ts +63 -27
  103. package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
  104. package/lib/cjs/Metadata/RelationshipClass.js +100 -43
  105. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  106. package/lib/cjs/Metadata/Schema.d.ts +167 -41
  107. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  108. package/lib/cjs/Metadata/Schema.js +211 -111
  109. package/lib/cjs/Metadata/Schema.js.map +1 -1
  110. package/lib/cjs/Metadata/SchemaItem.d.ts +19 -19
  111. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  112. package/lib/cjs/Metadata/SchemaItem.js +23 -21
  113. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  114. package/lib/cjs/Metadata/Unit.d.ts +24 -21
  115. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  116. package/lib/cjs/Metadata/Unit.js +40 -24
  117. package/lib/cjs/Metadata/Unit.js.map +1 -1
  118. package/lib/cjs/Metadata/UnitSystem.d.ts +17 -4
  119. package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
  120. package/lib/cjs/Metadata/UnitSystem.js +24 -4
  121. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  122. package/lib/cjs/PropertyTypes.d.ts +11 -11
  123. package/lib/cjs/PropertyTypes.d.ts.map +1 -1
  124. package/lib/cjs/PropertyTypes.js +28 -20
  125. package/lib/cjs/PropertyTypes.js.map +1 -1
  126. package/lib/cjs/SchemaFormatsProvider.d.ts +39 -0
  127. package/lib/cjs/SchemaFormatsProvider.d.ts.map +1 -0
  128. package/lib/cjs/SchemaFormatsProvider.js +146 -0
  129. package/lib/cjs/SchemaFormatsProvider.js.map +1 -0
  130. package/lib/cjs/SchemaJsonLocater.d.ts +8 -8
  131. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  132. package/lib/cjs/SchemaJsonLocater.js +7 -7
  133. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  134. package/lib/cjs/SchemaKey.d.ts +13 -7
  135. package/lib/cjs/SchemaKey.d.ts.map +1 -1
  136. package/lib/cjs/SchemaKey.js +22 -12
  137. package/lib/cjs/SchemaKey.js.map +1 -1
  138. package/lib/cjs/SchemaLoader.d.ts +5 -5
  139. package/lib/cjs/SchemaLoader.d.ts.map +1 -1
  140. package/lib/cjs/SchemaLoader.js +5 -4
  141. package/lib/cjs/SchemaLoader.js.map +1 -1
  142. package/lib/cjs/SchemaPartVisitorDelegate.d.ts +2 -2
  143. package/lib/cjs/SchemaPartVisitorDelegate.js +2 -1
  144. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  145. package/lib/cjs/UnitConversion/Graph.js +69 -65
  146. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  147. package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
  148. package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
  149. package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
  150. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  151. package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
  152. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  153. package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
  154. package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
  155. package/lib/cjs/UnitConversion/UnitTree.js +11 -1
  156. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  157. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  158. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +8 -9
  159. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  160. package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
  161. package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
  162. package/lib/cjs/Validation/SchemaWalker.js +6 -4
  163. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  164. package/lib/cjs/ecschema-metadata.d.ts +1 -0
  165. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  166. package/lib/cjs/ecschema-metadata.js +1 -0
  167. package/lib/cjs/ecschema-metadata.js.map +1 -1
  168. package/lib/cjs/utils/SchemaGraph.js +5 -6
  169. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  170. package/lib/esm/Constants.d.ts +8 -0
  171. package/lib/esm/Constants.d.ts.map +1 -1
  172. package/lib/esm/Constants.js +29 -20
  173. package/lib/esm/Constants.js.map +1 -1
  174. package/lib/esm/Context.d.ts +85 -36
  175. package/lib/esm/Context.d.ts.map +1 -1
  176. package/lib/esm/Context.js +78 -28
  177. package/lib/esm/Context.js.map +1 -1
  178. package/lib/esm/DelayedPromise.d.ts +9 -8
  179. package/lib/esm/DelayedPromise.d.ts.map +1 -1
  180. package/lib/esm/DelayedPromise.js +8 -6
  181. package/lib/esm/DelayedPromise.js.map +1 -1
  182. package/lib/esm/Deserialization/AbstractParser.js +1 -0
  183. package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
  184. package/lib/esm/Deserialization/Helper.d.ts +3 -3
  185. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  186. package/lib/esm/Deserialization/Helper.js +36 -27
  187. package/lib/esm/Deserialization/Helper.js.map +1 -1
  188. package/lib/esm/Deserialization/JsonParser.js +154 -151
  189. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  190. package/lib/esm/Deserialization/JsonProps.d.ts +47 -33
  191. package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
  192. package/lib/esm/Deserialization/JsonProps.js +3 -3
  193. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  194. package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
  195. package/lib/esm/Deserialization/XmlParser.js +61 -53
  196. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  197. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts +0 -5
  198. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  199. package/lib/esm/Deserialization/XmlSerializationUtils.js +9 -18
  200. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  201. package/lib/esm/ECName.d.ts +2 -2
  202. package/lib/esm/ECName.js +6 -5
  203. package/lib/esm/ECName.js.map +1 -1
  204. package/lib/esm/ECObjects.d.ts +41 -9
  205. package/lib/esm/ECObjects.d.ts.map +1 -1
  206. package/lib/esm/ECObjects.js +77 -24
  207. package/lib/esm/ECObjects.js.map +1 -1
  208. package/lib/esm/Exception.d.ts +4 -4
  209. package/lib/esm/Exception.d.ts.map +1 -1
  210. package/lib/esm/Exception.js +59 -58
  211. package/lib/esm/Exception.js.map +1 -1
  212. package/lib/esm/Interfaces.d.ts +35 -32
  213. package/lib/esm/Interfaces.d.ts.map +1 -1
  214. package/lib/esm/Interfaces.js.map +1 -1
  215. package/lib/esm/Metadata/Class.d.ts +179 -32
  216. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  217. package/lib/esm/Metadata/Class.js +292 -90
  218. package/lib/esm/Metadata/Class.js.map +1 -1
  219. package/lib/esm/Metadata/Constant.d.ts +26 -10
  220. package/lib/esm/Metadata/Constant.d.ts.map +1 -1
  221. package/lib/esm/Metadata/Constant.js +39 -11
  222. package/lib/esm/Metadata/Constant.js.map +1 -1
  223. package/lib/esm/Metadata/CustomAttribute.d.ts +2 -2
  224. package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -1
  225. package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
  226. package/lib/esm/Metadata/CustomAttributeClass.d.ts +21 -7
  227. package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
  228. package/lib/esm/Metadata/CustomAttributeClass.js +29 -9
  229. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  230. package/lib/esm/Metadata/EntityClass.d.ts +40 -11
  231. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  232. package/lib/esm/Metadata/EntityClass.js +73 -35
  233. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  234. package/lib/esm/Metadata/Enumeration.d.ts +30 -10
  235. package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
  236. package/lib/esm/Metadata/Enumeration.js +42 -14
  237. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  238. package/lib/esm/Metadata/Format.d.ts +65 -17
  239. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  240. package/lib/esm/Metadata/Format.js +108 -23
  241. package/lib/esm/Metadata/Format.js.map +1 -1
  242. package/lib/esm/Metadata/InvertedUnit.d.ts +19 -10
  243. package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
  244. package/lib/esm/Metadata/InvertedUnit.js +33 -16
  245. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  246. package/lib/esm/Metadata/KindOfQuantity.d.ts +38 -18
  247. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
  248. package/lib/esm/Metadata/KindOfQuantity.js +91 -41
  249. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  250. package/lib/esm/Metadata/Mixin.d.ts +31 -4
  251. package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
  252. package/lib/esm/Metadata/Mixin.js +44 -10
  253. package/lib/esm/Metadata/Mixin.js.map +1 -1
  254. package/lib/esm/Metadata/OverrideFormat.d.ts +12 -12
  255. package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -1
  256. package/lib/esm/Metadata/OverrideFormat.js +37 -20
  257. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  258. package/lib/esm/Metadata/Phenomenon.d.ts +24 -3
  259. package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
  260. package/lib/esm/Metadata/Phenomenon.js +33 -4
  261. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  262. package/lib/esm/Metadata/Property.d.ts +47 -25
  263. package/lib/esm/Metadata/Property.d.ts.map +1 -1
  264. package/lib/esm/Metadata/Property.js +130 -51
  265. package/lib/esm/Metadata/Property.js.map +1 -1
  266. package/lib/esm/Metadata/PropertyCategory.d.ts +20 -4
  267. package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
  268. package/lib/esm/Metadata/PropertyCategory.js +31 -4
  269. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  270. package/lib/esm/Metadata/RelationshipClass.d.ts +63 -27
  271. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
  272. package/lib/esm/Metadata/RelationshipClass.js +102 -45
  273. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  274. package/lib/esm/Metadata/Schema.d.ts +167 -41
  275. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  276. package/lib/esm/Metadata/Schema.js +212 -112
  277. package/lib/esm/Metadata/Schema.js.map +1 -1
  278. package/lib/esm/Metadata/SchemaItem.d.ts +19 -19
  279. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  280. package/lib/esm/Metadata/SchemaItem.js +25 -23
  281. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  282. package/lib/esm/Metadata/Unit.d.ts +24 -21
  283. package/lib/esm/Metadata/Unit.d.ts.map +1 -1
  284. package/lib/esm/Metadata/Unit.js +41 -25
  285. package/lib/esm/Metadata/Unit.js.map +1 -1
  286. package/lib/esm/Metadata/UnitSystem.d.ts +17 -4
  287. package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
  288. package/lib/esm/Metadata/UnitSystem.js +24 -4
  289. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  290. package/lib/esm/PropertyTypes.d.ts +11 -11
  291. package/lib/esm/PropertyTypes.d.ts.map +1 -1
  292. package/lib/esm/PropertyTypes.js +29 -21
  293. package/lib/esm/PropertyTypes.js.map +1 -1
  294. package/lib/esm/SchemaFormatsProvider.d.ts +39 -0
  295. package/lib/esm/SchemaFormatsProvider.d.ts.map +1 -0
  296. package/lib/esm/SchemaFormatsProvider.js +142 -0
  297. package/lib/esm/SchemaFormatsProvider.js.map +1 -0
  298. package/lib/esm/SchemaJsonLocater.d.ts +8 -8
  299. package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
  300. package/lib/esm/SchemaJsonLocater.js +7 -7
  301. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  302. package/lib/esm/SchemaKey.d.ts +13 -7
  303. package/lib/esm/SchemaKey.d.ts.map +1 -1
  304. package/lib/esm/SchemaKey.js +23 -13
  305. package/lib/esm/SchemaKey.js.map +1 -1
  306. package/lib/esm/SchemaLoader.d.ts +5 -5
  307. package/lib/esm/SchemaLoader.d.ts.map +1 -1
  308. package/lib/esm/SchemaLoader.js +6 -5
  309. package/lib/esm/SchemaLoader.js.map +1 -1
  310. package/lib/esm/SchemaPartVisitorDelegate.d.ts +2 -2
  311. package/lib/esm/SchemaPartVisitorDelegate.js +2 -1
  312. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  313. package/lib/esm/UnitConversion/Graph.js +69 -65
  314. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  315. package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
  316. package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
  317. package/lib/esm/UnitConversion/UnitConversion.js +9 -7
  318. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  319. package/lib/esm/UnitConversion/UnitConverter.js +2 -0
  320. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  321. package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
  322. package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
  323. package/lib/esm/UnitConversion/UnitTree.js +11 -1
  324. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  325. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  326. package/lib/esm/UnitProvider/SchemaUnitProvider.js +8 -9
  327. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  328. package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
  329. package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
  330. package/lib/esm/Validation/SchemaWalker.js +6 -4
  331. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  332. package/lib/esm/ecschema-metadata.d.ts +1 -0
  333. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  334. package/lib/esm/ecschema-metadata.js +1 -0
  335. package/lib/esm/ecschema-metadata.js.map +1 -1
  336. package/lib/esm/utils/SchemaGraph.js +6 -7
  337. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  338. package/package.json +16 -14
@@ -15,19 +15,26 @@ 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");
21
22
  /**
22
23
  * A common abstract class for all of the ECClass types.
23
- * @beta
24
+ * @public @preview
24
25
  */
25
26
  class ECClass extends SchemaItem_1.SchemaItem {
27
+ /** @internal */
28
+ static get schemaItemType() { return ECObjects_1.AbstractSchemaItemType.Class; } // need this so getItem("name", ECClass) in schema works
29
+ _modifier;
30
+ _baseClass;
31
+ _derivedClasses;
32
+ _properties;
33
+ _customAttributes;
34
+ _mergedPropertyCache;
26
35
  get modifier() { return this._modifier; }
27
- get baseClass() { return this._baseClass; }
28
- set baseClass(baseClass) { this._baseClass = baseClass; }
29
- get properties() { return this._properties?.values(); }
30
36
  get customAttributes() { return this._customAttributes; }
37
+ /** @internal */
31
38
  constructor(schema, name, modifier) {
32
39
  super(schema, name);
33
40
  if (modifier)
@@ -35,75 +42,113 @@ class ECClass extends SchemaItem_1.SchemaItem {
35
42
  else
36
43
  this._modifier = ECObjects_1.ECClassModifier.None;
37
44
  }
45
+ /**
46
+ * Gets the base class if it exists, otherwise returns undefined.
47
+ */
48
+ get baseClass() {
49
+ return this._baseClass;
50
+ }
51
+ getBaseClassSync() {
52
+ if (!this.baseClass) {
53
+ return undefined;
54
+ }
55
+ return this.schema.lookupItemSync(this.baseClass, ECClass);
56
+ }
57
+ /**
58
+ * Sets the base class of the ECClass. Pass undefined to 'remove' the base class.
59
+ *
60
+ * @internal
61
+ */
62
+ async setBaseClass(baseClass) {
63
+ const oldBaseClass = this._baseClass;
64
+ this._baseClass = baseClass;
65
+ if (baseClass)
66
+ this.addDerivedClass(await baseClass, this);
67
+ else if (oldBaseClass)
68
+ this.removeDerivedClass(await oldBaseClass, this);
69
+ }
70
+ /**
71
+ * Gets the derived classes belonging to this class.
72
+ * @returns An array of ECClasses or undefined if no derived classes exist.
73
+ */
74
+ async getDerivedClasses() {
75
+ if (!this._derivedClasses || this._derivedClasses.size === 0)
76
+ return undefined;
77
+ return Array.from(await Promise.all(this._derivedClasses.values()));
78
+ }
38
79
  /**
39
80
  * Convenience method for adding an already loaded ECProperty used by create*Property methods.
40
81
  * @param prop The property to add.
41
82
  * @return The property that was added.
83
+ *
84
+ * @internal
42
85
  */
43
86
  addProperty(prop) {
44
87
  if (!this._properties)
45
88
  this._properties = new Map();
46
89
  this._properties.set(prop.name.toUpperCase(), prop);
90
+ this.cleanCache();
47
91
  return prop;
48
92
  }
49
93
  /**
50
94
  * Deletes a property from within this class.
51
95
  * @param name The property name to delete, lookup is case-insensitive
52
- * @alpha
96
+ * @internal
53
97
  */
54
98
  async deleteProperty(name) {
55
99
  if (this._properties) {
56
100
  const property = await this.getProperty(name);
57
- if (property)
101
+ if (property) {
58
102
  this._properties.delete(name.toUpperCase());
103
+ this.cleanCache();
104
+ }
59
105
  }
60
106
  }
61
107
  /**
62
108
  * Deletes a property from within this class.
63
109
  * @param name The property name to delete, lookup is case-insensitive
64
- * @alpha
110
+ * @internal
65
111
  */
66
112
  deletePropertySync(name) {
67
113
  if (this._properties) {
68
114
  const property = this.getPropertySync(name);
69
- if (property)
115
+ if (property) {
70
116
  this._properties.delete(name.toUpperCase());
117
+ this.cleanCache();
118
+ }
71
119
  }
72
120
  }
73
- getBaseClassSync() {
74
- if (!this.baseClass) {
75
- return undefined;
76
- }
77
- return this.schema.lookupItemSync(this.baseClass);
78
- }
79
121
  /**
80
- * Searches, case-insensitive, for a local ECProperty with the name provided.
81
- * @param name
122
+ * Searches, case-insensitive, for an ECProperty with given the name on this class and, by default, on
123
+ * all base classes. Set excludeInherited to 'true' to only search the local class.
124
+ * @param name The name of the property to retrieve.
125
+ * @param excludeInherited If true, excludes inherited properties from the results. Defaults to false.
82
126
  */
83
- async getProperty(name, includeInherited = false) {
127
+ async getProperty(name, excludeInherited = false) {
84
128
  if (this._properties) {
85
129
  const upperKey = name.toUpperCase();
86
130
  const property = this._properties.get(upperKey);
87
131
  if (property)
88
132
  return property;
89
133
  }
90
- if (!includeInherited) {
134
+ if (excludeInherited) {
91
135
  return undefined;
92
136
  }
93
137
  return this.getInheritedProperty(name);
94
138
  }
95
139
  /**
96
140
  * Searches, case-insensitive, for a local ECProperty with the name provided.
97
- * @param name
141
+ * @param name The name of the property to retrieve.
142
+ * @param excludeInherited If true, excludes inherited properties from the results. Defaults to false.
98
143
  */
99
- getPropertySync(name, includeInherited = false) {
144
+ getPropertySync(name, excludeInherited = false) {
100
145
  if (this._properties) {
101
146
  const upperKey = name.toUpperCase();
102
147
  const property = this._properties.get(upperKey);
103
148
  if (property)
104
149
  return property;
105
150
  }
106
- if (!includeInherited) {
151
+ if (excludeInherited) {
107
152
  return undefined;
108
153
  }
109
154
  return this.getInheritedPropertySync(name);
@@ -115,7 +160,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
115
160
  async getInheritedProperty(name) {
116
161
  if (this.baseClass) {
117
162
  const baseClassObj = await this.baseClass;
118
- return baseClassObj.getProperty(name, true);
163
+ return baseClassObj.getProperty(name);
119
164
  }
120
165
  return undefined;
121
166
  }
@@ -126,36 +171,36 @@ class ECClass extends SchemaItem_1.SchemaItem {
126
171
  getInheritedPropertySync(name) {
127
172
  const baseClassObj = this.getBaseClassSync();
128
173
  if (baseClassObj)
129
- return baseClassObj.getPropertySync(name, true);
174
+ return baseClassObj.getPropertySync(name);
130
175
  return undefined;
131
176
  }
132
177
  async createPrimitiveProperty(name, primitiveType) {
133
- if (await this.getProperty(name))
134
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
178
+ if (await this.getProperty(name, true))
179
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
135
180
  const propType = await this.loadPrimitiveType(primitiveType, this.schema);
136
181
  if (typeof (propType) === "number")
137
182
  return this.addProperty(new Property_1.PrimitiveProperty(this, name, propType));
138
183
  return this.addProperty(new Property_1.EnumerationProperty(this, name, new DelayedPromise_1.DelayedPromiseWithProps(propType.key, async () => propType)));
139
184
  }
140
185
  createPrimitivePropertySync(name, primitiveType) {
141
- if (this.getPropertySync(name))
142
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
186
+ if (this.getPropertySync(name, true))
187
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
143
188
  const propType = this.loadPrimitiveTypeSync(primitiveType, this.schema);
144
189
  if (typeof (propType) === "number")
145
190
  return this.addProperty(new Property_1.PrimitiveProperty(this, name, propType));
146
191
  return this.addProperty(new Property_1.EnumerationProperty(this, name, new DelayedPromise_1.DelayedPromiseWithProps(propType.key, async () => propType)));
147
192
  }
148
193
  async createPrimitiveArrayProperty(name, primitiveType) {
149
- if (await this.getProperty(name))
150
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
194
+ if (await this.getProperty(name, true))
195
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
151
196
  const propType = await this.loadPrimitiveType(primitiveType, this.schema);
152
197
  if (typeof (propType) === "number")
153
198
  return this.addProperty(new Property_1.PrimitiveArrayProperty(this, name, propType));
154
199
  return this.addProperty(new Property_1.EnumerationArrayProperty(this, name, new DelayedPromise_1.DelayedPromiseWithProps(propType.key, async () => propType)));
155
200
  }
156
201
  createPrimitiveArrayPropertySync(name, primitiveType) {
157
- if (this.getPropertySync(name))
158
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
202
+ if (this.getPropertySync(name, true))
203
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
159
204
  const propType = this.loadPrimitiveTypeSync(primitiveType, this.schema);
160
205
  if (typeof (propType) === "number")
161
206
  return this.addProperty(new Property_1.PrimitiveArrayProperty(this, name, propType));
@@ -165,91 +210,131 @@ class ECClass extends SchemaItem_1.SchemaItem {
165
210
  *
166
211
  * @param name The name of property to create.
167
212
  * @param structType The struct type of property to create.
213
+ *
214
+ * @internal
168
215
  */
169
216
  async createStructProperty(name, structType) {
170
- if (await this.getProperty(name))
171
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
217
+ if (await this.getProperty(name, true))
218
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
172
219
  return this.addProperty(new Property_1.StructProperty(this, name, await this.loadStructType(structType, this.schema)));
173
220
  }
174
221
  /**
175
222
  *
176
223
  * @param name The name of property to create.
177
224
  * @param structType The struct type of property to create.
225
+ *
226
+ * @internal
178
227
  */
179
228
  createStructPropertySync(name, structType) {
180
- if (this.getPropertySync(name))
181
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
229
+ if (this.getPropertySync(name, true))
230
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
182
231
  return this.addProperty(new Property_1.StructProperty(this, name, this.loadStructTypeSync(structType, this.schema)));
183
232
  }
184
233
  /**
185
234
  *
186
235
  * @param name
187
236
  * @param type
237
+ *
238
+ * @internal
188
239
  */
189
240
  async createStructArrayProperty(name, structType) {
190
- if (await this.getProperty(name))
191
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
241
+ if (await this.getProperty(name, true))
242
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
192
243
  return this.addProperty(new Property_1.StructArrayProperty(this, name, await this.loadStructType(structType, this.schema)));
193
244
  }
194
245
  /**
195
246
  *
196
247
  * @param name
197
248
  * @param type
249
+ *
250
+ * @internal
198
251
  */
199
252
  createStructArrayPropertySync(name, structType) {
200
- if (this.getPropertySync(name))
201
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
253
+ if (this.getPropertySync(name, true))
254
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
202
255
  return this.addProperty(new Property_1.StructArrayProperty(this, name, this.loadStructTypeSync(structType, this.schema)));
203
256
  }
257
+ /**
258
+ *
259
+ * @param structType
260
+ * @param schema
261
+ * @returns
262
+ *
263
+ * @internal
264
+ */
204
265
  async loadStructType(structType, schema) {
205
266
  let correctType;
206
267
  if (typeof (structType) === "string") {
207
- correctType = await schema.lookupItem(structType);
268
+ correctType = await schema.lookupItem(structType, StructClass);
208
269
  }
209
270
  else
210
271
  correctType = structType;
211
272
  if (!correctType)
212
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);
273
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);
213
274
  return correctType;
214
275
  }
276
+ /**
277
+ *
278
+ * @param structType
279
+ * @param schema
280
+ * @returns
281
+ *
282
+ * @internal
283
+ */
215
284
  loadStructTypeSync(structType, schema) {
216
285
  let correctType;
217
286
  if (typeof (structType) === "string") {
218
- correctType = schema.lookupItemSync(structType);
287
+ correctType = schema.lookupItemSync(structType, StructClass);
219
288
  }
220
289
  else
221
290
  correctType = structType;
222
291
  if (!correctType)
223
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);
292
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);
224
293
  return correctType;
225
294
  }
295
+ /**
296
+ *
297
+ * @param primitiveType
298
+ * @param schema
299
+ * @returns
300
+ *
301
+ * @internal
302
+ */
226
303
  async loadPrimitiveType(primitiveType, schema) {
227
304
  if (primitiveType === undefined)
228
305
  return ECObjects_1.PrimitiveType.Integer;
229
306
  if (typeof (primitiveType) === "string") {
230
307
  let resolvedType = (0, ECObjects_1.parsePrimitiveType)(primitiveType);
231
308
  if (!resolvedType) {
232
- resolvedType = await schema.lookupItem(primitiveType);
309
+ resolvedType = await schema.lookupItem(primitiveType, Enumeration_1.Enumeration);
233
310
  }
234
311
  if (resolvedType === undefined)
235
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
312
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
236
313
  // If resolvedType is a SchemaItem, make sure it is an Enumeration- if not, throw an error
237
314
  if (typeof (resolvedType) !== "number" && resolvedType.schemaItemType !== ECObjects_1.SchemaItemType.Enumeration)
238
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
315
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
239
316
  return resolvedType;
240
317
  }
241
318
  return primitiveType;
242
319
  }
320
+ /**
321
+ *
322
+ * @param primitiveType
323
+ * @param schema
324
+ * @returns
325
+ *
326
+ * @internal
327
+ */
243
328
  loadPrimitiveTypeSync(primitiveType, schema) {
244
329
  if (primitiveType === undefined)
245
330
  return ECObjects_1.PrimitiveType.Integer;
246
331
  if (typeof (primitiveType) === "string") {
247
332
  let resolvedType = (0, ECObjects_1.parsePrimitiveType)(primitiveType);
248
333
  if (!resolvedType) {
249
- resolvedType = schema.lookupItemSync(primitiveType);
334
+ resolvedType = schema.lookupItemSync(primitiveType, Enumeration_1.Enumeration);
250
335
  }
251
336
  if (resolvedType === undefined)
252
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
337
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
253
338
  return resolvedType;
254
339
  }
255
340
  return primitiveType;
@@ -268,7 +353,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
268
353
  if (this.baseClass !== undefined)
269
354
  schemaJson.baseClass = this.baseClass.fullName;
270
355
  if (this._properties !== undefined && this._properties.size > 0)
271
- schemaJson.properties = [...this.properties].map((prop) => prop.toJSON());
356
+ schemaJson.properties = [...this._properties.values()].map((prop) => prop.toJSON());
272
357
  const customAttributes = (0, CustomAttribute_1.serializeCustomAttributes)(this.customAttributes);
273
358
  if (customAttributes !== undefined)
274
359
  schemaJson.customAttributes = customAttributes;
@@ -286,8 +371,8 @@ class ECClass extends SchemaItem_1.SchemaItem {
286
371
  baseClassElement.textContent = baseClassName;
287
372
  itemElement.appendChild(baseClassElement);
288
373
  }
289
- if (undefined !== this.properties) {
290
- for (const prop of this.properties) {
374
+ if (undefined !== this._properties) {
375
+ for (const prop of this._properties.values()) {
291
376
  const propXml = await prop.toXml(schemaXml);
292
377
  itemElement.appendChild(propXml);
293
378
  }
@@ -310,7 +395,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
310
395
  if (Helper_1.SchemaReadHelper.isECSpecVersionNewer({ readVersion: classProps.originalECSpecMajorVersion, writeVersion: classProps.originalECSpecMinorVersion }))
311
396
  this._modifier = ECObjects_1.ECClassModifier.None;
312
397
  else
313
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidModifier, `The string '${classProps.modifier}' is not a valid ECClassModifier.`);
398
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidModifier, `The string '${classProps.modifier}' is not a valid ECClassModifier.`);
314
399
  }
315
400
  else {
316
401
  this._modifier = modifier;
@@ -319,18 +404,37 @@ class ECClass extends SchemaItem_1.SchemaItem {
319
404
  if (undefined !== classProps.baseClass) {
320
405
  const ecClassSchemaItemKey = this.schema.getSchemaItemKey(classProps.baseClass);
321
406
  if (!ecClassSchemaItemKey)
322
- 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
- });
407
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);
408
+ const baseClass = this.schema.lookupItemSync(ecClassSchemaItemKey);
409
+ let lazyBase;
410
+ if (!baseClass) {
411
+ lazyBase = new DelayedPromise_1.DelayedPromiseWithProps(ecClassSchemaItemKey, async () => {
412
+ const baseItem = await this.schema.lookupItem(ecClassSchemaItemKey);
413
+ if (undefined === baseItem || !ECClass.isECClass(baseItem))
414
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);
415
+ return baseItem;
416
+ });
417
+ }
418
+ else {
419
+ lazyBase = new DelayedPromise_1.DelayedPromiseWithProps(ecClassSchemaItemKey, async () => {
420
+ return baseClass;
421
+ });
422
+ }
423
+ this._baseClass = lazyBase;
424
+ if (!baseClass)
425
+ return;
426
+ this.addDerivedClass(baseClass, this);
329
427
  }
330
428
  }
331
429
  async fromJSON(classProps) {
332
430
  this.fromJSONSync(classProps);
333
431
  }
432
+ /**
433
+ *
434
+ * @param customAttribute
435
+ *
436
+ * @internal
437
+ */
334
438
  addCustomAttribute(customAttribute) {
335
439
  if (!this._customAttributes)
336
440
  this._customAttributes = new Map();
@@ -344,8 +448,8 @@ class ECClass extends SchemaItem_1.SchemaItem {
344
448
  const baseClasses = [this];
345
449
  const addBaseClasses = async (ecClass) => {
346
450
  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]);
451
+ for (let i = ecClass.mixins.length - 1; i >= 0; i--) {
452
+ baseClasses.push(await ecClass.mixins[i]);
349
453
  }
350
454
  }
351
455
  if (ecClass.baseClass)
@@ -361,7 +465,7 @@ class ECClass extends SchemaItem_1.SchemaItem {
361
465
  *getAllBaseClassesSync() {
362
466
  const baseClasses = [this];
363
467
  const addBaseClasses = (ecClass) => {
364
- if (ECObjects_1.SchemaItemType.EntityClass === ecClass.schemaItemType) {
468
+ if (ecClass.schemaItemType === ECObjects_1.SchemaItemType.EntityClass) { // cannot use EntityClass typeguard because of circular reference
365
469
  for (const m of Array.from(ecClass.getMixinsSync()).reverse()) {
366
470
  baseClasses.push(m);
367
471
  }
@@ -377,6 +481,15 @@ class ECClass extends SchemaItem_1.SchemaItem {
377
481
  yield baseClass;
378
482
  }
379
483
  }
484
+ /**
485
+ *
486
+ * @param target
487
+ * @param existingValues
488
+ * @param propertiesToMerge
489
+ * @param overwriteExisting
490
+ *
491
+ * @internal
492
+ */
380
493
  static mergeProperties(target, existingValues, propertiesToMerge, overwriteExisting) {
381
494
  for (const property of propertiesToMerge) {
382
495
  const upperCaseName = property.name.toUpperCase();
@@ -392,52 +505,87 @@ class ECClass extends SchemaItem_1.SchemaItem {
392
505
  }
393
506
  }
394
507
  }
395
- async buildPropertyCache(result, existingValues, resetBaseCaches = false) {
508
+ /**
509
+ *
510
+ * @param result
511
+ * @param existingValues
512
+ * @returns
513
+ *
514
+ * @internal
515
+ */
516
+ async buildPropertyCache(result, existingValues) {
396
517
  if (!existingValues) {
397
518
  existingValues = new Map();
398
519
  }
399
520
  if (this.baseClass) {
400
- ECClass.mergeProperties(result, existingValues, await (await this.baseClass).getProperties(resetBaseCaches), false);
521
+ const baseClass = await this.baseClass;
522
+ if (baseClass) {
523
+ ECClass.mergeProperties(result, existingValues, await baseClass.getProperties(), false);
524
+ }
401
525
  }
402
- if (!this.properties)
526
+ if (!this._properties)
403
527
  return;
404
- ECClass.mergeProperties(result, existingValues, [...this.properties], true);
528
+ ECClass.mergeProperties(result, existingValues, [...this._properties.values()], true);
405
529
  }
406
- buildPropertyCacheSync(result, existingValues, resetBaseCaches = false) {
530
+ /**
531
+ *
532
+ * @param result
533
+ * @param existingValues
534
+ * @returns
535
+ *
536
+ * @internal
537
+ */
538
+ buildPropertyCacheSync(result, existingValues) {
407
539
  if (!existingValues) {
408
540
  existingValues = new Map();
409
541
  }
410
542
  const baseClass = this.getBaseClassSync();
411
543
  if (baseClass) {
412
- ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(resetBaseCaches), false);
544
+ ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(), false);
413
545
  }
414
- if (!this.properties)
546
+ if (!this._properties)
415
547
  return;
416
- ECClass.mergeProperties(result, existingValues, [...this.properties], true);
548
+ ECClass.mergeProperties(result, existingValues, [...this._properties.values()], true);
417
549
  }
418
550
  /**
419
- * Iterates all properties, including the ones merged from base classes and mixins. To obtain only local properties, use the 'properties' field.
551
+ * Clears all caches on this object. This is called implicitly for this class,
552
+ * but needs to be called if derived classes have changed.
553
+ * @internal
554
+ */
555
+ cleanCache() {
556
+ this._mergedPropertyCache = undefined;
557
+ }
558
+ /**
559
+ * Returns the properties on this class and its base classes.
420
560
  * Since this is an expensive operation, results will be cached after first call.
421
- * @param resetCache if true, any previously cached results will be dropped and cache will be rebuilt
561
+ * @param excludeInherited If true, only properties defined directly on this class will be returned. Defaults to false.
562
+ * @returns An array of properties, empty array if none exist.
422
563
  */
423
- getPropertiesSync(resetCache = false) {
424
- if (!this._mergedPropertyCache || resetCache) {
564
+ getPropertiesSync(excludeInherited) {
565
+ if (excludeInherited) {
566
+ return this._properties && this._properties.size > 0 ? this._properties.values() : [];
567
+ }
568
+ if (!this._mergedPropertyCache) {
425
569
  this._mergedPropertyCache = [];
426
- this.buildPropertyCacheSync(this._mergedPropertyCache, undefined, resetCache);
570
+ this.buildPropertyCacheSync(this._mergedPropertyCache, undefined);
427
571
  }
428
572
  return this._mergedPropertyCache;
429
573
  }
430
574
  /**
431
- * Iterates all properties, including the ones merged from base classes and mixins. To obtain only local properties, use the 'properties' field.
575
+ * Quick way to check whether this class has any local properties without having to use the iterable
576
+ */
577
+ get hasLocalProperties() {
578
+ return this._properties !== undefined && this._properties.size > 0;
579
+ }
580
+ /**
581
+ * Returns the properties on this class and its base classes.
432
582
  * Since this is an expensive operation, results will be cached after first call.
433
- * @param resetCache if true, any previously cached results will be dropped and cache will be rebuilt
583
+ * @param excludeInherited If true, only properties defined directly on this class will be returned.
584
+ * @returns An array of properties, empty array if none exist.
434
585
  */
435
- async getProperties(resetCache = false) {
436
- if (!this._mergedPropertyCache || resetCache) {
437
- this._mergedPropertyCache = [];
438
- await this.buildPropertyCache(this._mergedPropertyCache, undefined, resetCache);
439
- }
440
- return this._mergedPropertyCache;
586
+ async getProperties(excludeInherited) {
587
+ // At the moment we do not lazy load properties, so this is the same as getPropertiesSync
588
+ return this.getPropertiesSync(excludeInherited);
441
589
  }
442
590
  /**
443
591
  * Retrieve all custom attributes in the current class and its bases
@@ -529,23 +677,77 @@ class ECClass extends SchemaItem_1.SchemaItem {
529
677
  object.schemaItemType === ECObjects_1.SchemaItemType.StructClass || object.schemaItemType === ECObjects_1.SchemaItemType.CustomAttributeClass;
530
678
  }
531
679
  /**
532
- * @alpha
533
680
  * A setter method for the ECClass modifier, used specifically for schema editing.
534
681
  * @param modifier
682
+ * @internal
535
683
  */
536
684
  setModifier(modifier) {
537
685
  this._modifier = modifier;
538
686
  }
687
+ /**
688
+ * Adds an ECClass to the derived class collection. This method is only intended to update the local
689
+ * cache of derived classes. For adding a class to the hierarchy, use the baseClass setter method.
690
+ * @param prop The property to add.
691
+ * @return The property that was added.
692
+ */
693
+ addDerivedClass(baseClass, derivedClass) {
694
+ if (!baseClass._derivedClasses)
695
+ baseClass._derivedClasses = new Map();
696
+ if (baseClass._derivedClasses.has(derivedClass.fullName))
697
+ return;
698
+ if (derivedClass.isSync(baseClass)) {
699
+ const promise = new DelayedPromise_1.DelayedPromiseWithProps(derivedClass.key, async () => derivedClass);
700
+ baseClass._derivedClasses.set(derivedClass.fullName, promise);
701
+ }
702
+ }
703
+ /**
704
+ * Removes an ECClass from the derived class collection. This method is only intended to update the local
705
+ * cache of derived classes. For updating the class hierarchy, use the baseClass setter method.
706
+ * @param prop The property to add.
707
+ * @return The property that was added.
708
+ */
709
+ removeDerivedClass(baseClass, derivedClass) {
710
+ if (!baseClass._derivedClasses)
711
+ return;
712
+ if (!baseClass._derivedClasses.has(derivedClass.fullName))
713
+ return;
714
+ baseClass._derivedClasses.delete(derivedClass.fullName);
715
+ }
539
716
  }
540
717
  exports.ECClass = ECClass;
541
718
  /**
542
719
  * A Typescript class representation of an ECStructClass.
543
- * @beta
720
+ * @public @preview
544
721
  */
545
722
  class StructClass extends ECClass {
546
- constructor(schema, name, modifier) {
547
- super(schema, name, modifier);
548
- this.schemaItemType = ECObjects_1.SchemaItemType.StructClass;
723
+ /**
724
+ * Get the type of item represented by this instance
725
+ */
726
+ schemaItemType = StructClass.schemaItemType;
727
+ /**
728
+ * Get the type of item represented by this class
729
+ * @internal
730
+ */
731
+ static get schemaItemType() { return ECObjects_1.SchemaItemType.StructClass; }
732
+ /**
733
+ * Type guard to check if the SchemaItem is of type StructClass.
734
+ * @param item The SchemaItem to check.
735
+ * @returns True if the item is a StructClass, false otherwise.
736
+ */
737
+ static isStructClass(item) {
738
+ if (item && item.schemaItemType === ECObjects_1.SchemaItemType.StructClass)
739
+ return true;
740
+ return false;
741
+ }
742
+ /**
743
+ * Type assertion to check if the SchemaItem is of type StructClass.
744
+ * @param item The SchemaItem to check.
745
+ * @returns The item cast to StructClass if it is a StructClass, undefined otherwise.
746
+ * @internal
747
+ */
748
+ static assertIsStructClass(item) {
749
+ if (!this.isStructClass(item))
750
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.StructClass}' (StructClass)`);
549
751
  }
550
752
  }
551
753
  exports.StructClass = StructClass;