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

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 (342) hide show
  1. package/CHANGELOG.md +73 -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/SchemaGraphUtil.js.map +1 -1
  27. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  28. package/lib/cjs/Deserialization/XmlParser.js +60 -52
  29. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  30. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +0 -5
  31. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  32. package/lib/cjs/Deserialization/XmlSerializationUtils.js +8 -17
  33. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  34. package/lib/cjs/ECName.d.ts +2 -2
  35. package/lib/cjs/ECName.js +5 -4
  36. package/lib/cjs/ECName.js.map +1 -1
  37. package/lib/cjs/ECObjects.d.ts +41 -9
  38. package/lib/cjs/ECObjects.d.ts.map +1 -1
  39. package/lib/cjs/ECObjects.js +78 -24
  40. package/lib/cjs/ECObjects.js.map +1 -1
  41. package/lib/cjs/Exception.d.ts +4 -4
  42. package/lib/cjs/Exception.d.ts.map +1 -1
  43. package/lib/cjs/Exception.js +61 -60
  44. package/lib/cjs/Exception.js.map +1 -1
  45. package/lib/cjs/Interfaces.d.ts +35 -32
  46. package/lib/cjs/Interfaces.d.ts.map +1 -1
  47. package/lib/cjs/Interfaces.js.map +1 -1
  48. package/lib/cjs/Metadata/Class.d.ts +179 -32
  49. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  50. package/lib/cjs/Metadata/Class.js +290 -88
  51. package/lib/cjs/Metadata/Class.js.map +1 -1
  52. package/lib/cjs/Metadata/Constant.d.ts +26 -10
  53. package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
  54. package/lib/cjs/Metadata/Constant.js +38 -10
  55. package/lib/cjs/Metadata/Constant.js.map +1 -1
  56. package/lib/cjs/Metadata/CustomAttribute.d.ts +2 -2
  57. package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
  58. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  59. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +21 -7
  60. package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
  61. package/lib/cjs/Metadata/CustomAttributeClass.js +28 -8
  62. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  63. package/lib/cjs/Metadata/EntityClass.d.ts +40 -11
  64. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  65. package/lib/cjs/Metadata/EntityClass.js +72 -34
  66. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  67. package/lib/cjs/Metadata/Enumeration.d.ts +30 -10
  68. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  69. package/lib/cjs/Metadata/Enumeration.js +41 -13
  70. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  71. package/lib/cjs/Metadata/Format.d.ts +65 -17
  72. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  73. package/lib/cjs/Metadata/Format.js +107 -22
  74. package/lib/cjs/Metadata/Format.js.map +1 -1
  75. package/lib/cjs/Metadata/InvertedUnit.d.ts +19 -10
  76. package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
  77. package/lib/cjs/Metadata/InvertedUnit.js +32 -15
  78. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  79. package/lib/cjs/Metadata/KindOfQuantity.d.ts +38 -18
  80. package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
  81. package/lib/cjs/Metadata/KindOfQuantity.js +90 -40
  82. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  83. package/lib/cjs/Metadata/Mixin.d.ts +31 -4
  84. package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
  85. package/lib/cjs/Metadata/Mixin.js +42 -8
  86. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  87. package/lib/cjs/Metadata/OverrideFormat.d.ts +12 -12
  88. package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
  89. package/lib/cjs/Metadata/OverrideFormat.js +36 -19
  90. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  91. package/lib/cjs/Metadata/Phenomenon.d.ts +24 -3
  92. package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
  93. package/lib/cjs/Metadata/Phenomenon.js +32 -3
  94. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  95. package/lib/cjs/Metadata/Property.d.ts +47 -25
  96. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  97. package/lib/cjs/Metadata/Property.js +128 -49
  98. package/lib/cjs/Metadata/Property.js.map +1 -1
  99. package/lib/cjs/Metadata/PropertyCategory.d.ts +20 -4
  100. package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
  101. package/lib/cjs/Metadata/PropertyCategory.js +31 -4
  102. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  103. package/lib/cjs/Metadata/RelationshipClass.d.ts +63 -27
  104. package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
  105. package/lib/cjs/Metadata/RelationshipClass.js +100 -43
  106. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  107. package/lib/cjs/Metadata/Schema.d.ts +167 -41
  108. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  109. package/lib/cjs/Metadata/Schema.js +211 -111
  110. package/lib/cjs/Metadata/Schema.js.map +1 -1
  111. package/lib/cjs/Metadata/SchemaItem.d.ts +19 -19
  112. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  113. package/lib/cjs/Metadata/SchemaItem.js +23 -21
  114. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  115. package/lib/cjs/Metadata/Unit.d.ts +24 -21
  116. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  117. package/lib/cjs/Metadata/Unit.js +40 -24
  118. package/lib/cjs/Metadata/Unit.js.map +1 -1
  119. package/lib/cjs/Metadata/UnitSystem.d.ts +17 -4
  120. package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
  121. package/lib/cjs/Metadata/UnitSystem.js +24 -4
  122. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  123. package/lib/cjs/PropertyTypes.d.ts +11 -11
  124. package/lib/cjs/PropertyTypes.d.ts.map +1 -1
  125. package/lib/cjs/PropertyTypes.js +28 -20
  126. package/lib/cjs/PropertyTypes.js.map +1 -1
  127. package/lib/cjs/SchemaFormatsProvider.d.ts +39 -0
  128. package/lib/cjs/SchemaFormatsProvider.d.ts.map +1 -0
  129. package/lib/cjs/SchemaFormatsProvider.js +146 -0
  130. package/lib/cjs/SchemaFormatsProvider.js.map +1 -0
  131. package/lib/cjs/SchemaJsonLocater.d.ts +8 -8
  132. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  133. package/lib/cjs/SchemaJsonLocater.js +7 -7
  134. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  135. package/lib/cjs/SchemaKey.d.ts +13 -7
  136. package/lib/cjs/SchemaKey.d.ts.map +1 -1
  137. package/lib/cjs/SchemaKey.js +22 -12
  138. package/lib/cjs/SchemaKey.js.map +1 -1
  139. package/lib/cjs/SchemaLoader.d.ts +5 -5
  140. package/lib/cjs/SchemaLoader.d.ts.map +1 -1
  141. package/lib/cjs/SchemaLoader.js +5 -4
  142. package/lib/cjs/SchemaLoader.js.map +1 -1
  143. package/lib/cjs/SchemaPartVisitorDelegate.d.ts +2 -2
  144. package/lib/cjs/SchemaPartVisitorDelegate.js +2 -1
  145. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  146. package/lib/cjs/UnitConversion/Graph.js +69 -65
  147. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  148. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  149. package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
  150. package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
  151. package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
  152. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  153. package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
  154. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  155. package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
  156. package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
  157. package/lib/cjs/UnitConversion/UnitTree.js +11 -1
  158. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  159. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  160. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +8 -9
  161. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  162. package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
  163. package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
  164. package/lib/cjs/Validation/SchemaWalker.js +6 -4
  165. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  166. package/lib/cjs/ecschema-metadata.d.ts +1 -0
  167. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  168. package/lib/cjs/ecschema-metadata.js +1 -0
  169. package/lib/cjs/ecschema-metadata.js.map +1 -1
  170. package/lib/cjs/utils/SchemaGraph.js +5 -6
  171. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  172. package/lib/esm/Constants.d.ts +8 -0
  173. package/lib/esm/Constants.d.ts.map +1 -1
  174. package/lib/esm/Constants.js +29 -20
  175. package/lib/esm/Constants.js.map +1 -1
  176. package/lib/esm/Context.d.ts +85 -36
  177. package/lib/esm/Context.d.ts.map +1 -1
  178. package/lib/esm/Context.js +78 -28
  179. package/lib/esm/Context.js.map +1 -1
  180. package/lib/esm/DelayedPromise.d.ts +9 -8
  181. package/lib/esm/DelayedPromise.d.ts.map +1 -1
  182. package/lib/esm/DelayedPromise.js +8 -6
  183. package/lib/esm/DelayedPromise.js.map +1 -1
  184. package/lib/esm/Deserialization/AbstractParser.js +1 -0
  185. package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
  186. package/lib/esm/Deserialization/Helper.d.ts +3 -3
  187. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  188. package/lib/esm/Deserialization/Helper.js +36 -27
  189. package/lib/esm/Deserialization/Helper.js.map +1 -1
  190. package/lib/esm/Deserialization/JsonParser.js +154 -151
  191. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  192. package/lib/esm/Deserialization/JsonProps.d.ts +47 -33
  193. package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
  194. package/lib/esm/Deserialization/JsonProps.js +3 -3
  195. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  196. package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
  197. package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
  198. package/lib/esm/Deserialization/XmlParser.js +61 -53
  199. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  200. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts +0 -5
  201. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  202. package/lib/esm/Deserialization/XmlSerializationUtils.js +9 -18
  203. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  204. package/lib/esm/ECName.d.ts +2 -2
  205. package/lib/esm/ECName.js +6 -5
  206. package/lib/esm/ECName.js.map +1 -1
  207. package/lib/esm/ECObjects.d.ts +41 -9
  208. package/lib/esm/ECObjects.d.ts.map +1 -1
  209. package/lib/esm/ECObjects.js +77 -24
  210. package/lib/esm/ECObjects.js.map +1 -1
  211. package/lib/esm/Exception.d.ts +4 -4
  212. package/lib/esm/Exception.d.ts.map +1 -1
  213. package/lib/esm/Exception.js +59 -58
  214. package/lib/esm/Exception.js.map +1 -1
  215. package/lib/esm/Interfaces.d.ts +35 -32
  216. package/lib/esm/Interfaces.d.ts.map +1 -1
  217. package/lib/esm/Interfaces.js.map +1 -1
  218. package/lib/esm/Metadata/Class.d.ts +179 -32
  219. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  220. package/lib/esm/Metadata/Class.js +292 -90
  221. package/lib/esm/Metadata/Class.js.map +1 -1
  222. package/lib/esm/Metadata/Constant.d.ts +26 -10
  223. package/lib/esm/Metadata/Constant.d.ts.map +1 -1
  224. package/lib/esm/Metadata/Constant.js +39 -11
  225. package/lib/esm/Metadata/Constant.js.map +1 -1
  226. package/lib/esm/Metadata/CustomAttribute.d.ts +2 -2
  227. package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -1
  228. package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
  229. package/lib/esm/Metadata/CustomAttributeClass.d.ts +21 -7
  230. package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
  231. package/lib/esm/Metadata/CustomAttributeClass.js +29 -9
  232. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  233. package/lib/esm/Metadata/EntityClass.d.ts +40 -11
  234. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  235. package/lib/esm/Metadata/EntityClass.js +73 -35
  236. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  237. package/lib/esm/Metadata/Enumeration.d.ts +30 -10
  238. package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
  239. package/lib/esm/Metadata/Enumeration.js +42 -14
  240. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  241. package/lib/esm/Metadata/Format.d.ts +65 -17
  242. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  243. package/lib/esm/Metadata/Format.js +108 -23
  244. package/lib/esm/Metadata/Format.js.map +1 -1
  245. package/lib/esm/Metadata/InvertedUnit.d.ts +19 -10
  246. package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
  247. package/lib/esm/Metadata/InvertedUnit.js +33 -16
  248. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  249. package/lib/esm/Metadata/KindOfQuantity.d.ts +38 -18
  250. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
  251. package/lib/esm/Metadata/KindOfQuantity.js +91 -41
  252. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  253. package/lib/esm/Metadata/Mixin.d.ts +31 -4
  254. package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
  255. package/lib/esm/Metadata/Mixin.js +44 -10
  256. package/lib/esm/Metadata/Mixin.js.map +1 -1
  257. package/lib/esm/Metadata/OverrideFormat.d.ts +12 -12
  258. package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -1
  259. package/lib/esm/Metadata/OverrideFormat.js +37 -20
  260. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  261. package/lib/esm/Metadata/Phenomenon.d.ts +24 -3
  262. package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
  263. package/lib/esm/Metadata/Phenomenon.js +33 -4
  264. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  265. package/lib/esm/Metadata/Property.d.ts +47 -25
  266. package/lib/esm/Metadata/Property.d.ts.map +1 -1
  267. package/lib/esm/Metadata/Property.js +130 -51
  268. package/lib/esm/Metadata/Property.js.map +1 -1
  269. package/lib/esm/Metadata/PropertyCategory.d.ts +20 -4
  270. package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
  271. package/lib/esm/Metadata/PropertyCategory.js +31 -4
  272. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  273. package/lib/esm/Metadata/RelationshipClass.d.ts +63 -27
  274. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
  275. package/lib/esm/Metadata/RelationshipClass.js +102 -45
  276. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  277. package/lib/esm/Metadata/Schema.d.ts +167 -41
  278. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  279. package/lib/esm/Metadata/Schema.js +212 -112
  280. package/lib/esm/Metadata/Schema.js.map +1 -1
  281. package/lib/esm/Metadata/SchemaItem.d.ts +19 -19
  282. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  283. package/lib/esm/Metadata/SchemaItem.js +25 -23
  284. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  285. package/lib/esm/Metadata/Unit.d.ts +24 -21
  286. package/lib/esm/Metadata/Unit.d.ts.map +1 -1
  287. package/lib/esm/Metadata/Unit.js +41 -25
  288. package/lib/esm/Metadata/Unit.js.map +1 -1
  289. package/lib/esm/Metadata/UnitSystem.d.ts +17 -4
  290. package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
  291. package/lib/esm/Metadata/UnitSystem.js +24 -4
  292. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  293. package/lib/esm/PropertyTypes.d.ts +11 -11
  294. package/lib/esm/PropertyTypes.d.ts.map +1 -1
  295. package/lib/esm/PropertyTypes.js +29 -21
  296. package/lib/esm/PropertyTypes.js.map +1 -1
  297. package/lib/esm/SchemaFormatsProvider.d.ts +39 -0
  298. package/lib/esm/SchemaFormatsProvider.d.ts.map +1 -0
  299. package/lib/esm/SchemaFormatsProvider.js +142 -0
  300. package/lib/esm/SchemaFormatsProvider.js.map +1 -0
  301. package/lib/esm/SchemaJsonLocater.d.ts +8 -8
  302. package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
  303. package/lib/esm/SchemaJsonLocater.js +7 -7
  304. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  305. package/lib/esm/SchemaKey.d.ts +13 -7
  306. package/lib/esm/SchemaKey.d.ts.map +1 -1
  307. package/lib/esm/SchemaKey.js +23 -13
  308. package/lib/esm/SchemaKey.js.map +1 -1
  309. package/lib/esm/SchemaLoader.d.ts +5 -5
  310. package/lib/esm/SchemaLoader.d.ts.map +1 -1
  311. package/lib/esm/SchemaLoader.js +6 -5
  312. package/lib/esm/SchemaLoader.js.map +1 -1
  313. package/lib/esm/SchemaPartVisitorDelegate.d.ts +2 -2
  314. package/lib/esm/SchemaPartVisitorDelegate.js +2 -1
  315. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  316. package/lib/esm/UnitConversion/Graph.js +69 -65
  317. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  318. package/lib/esm/UnitConversion/Parser.js.map +1 -1
  319. package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
  320. package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
  321. package/lib/esm/UnitConversion/UnitConversion.js +9 -7
  322. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  323. package/lib/esm/UnitConversion/UnitConverter.js +2 -0
  324. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  325. package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
  326. package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
  327. package/lib/esm/UnitConversion/UnitTree.js +11 -1
  328. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  329. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  330. package/lib/esm/UnitProvider/SchemaUnitProvider.js +8 -9
  331. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  332. package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
  333. package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
  334. package/lib/esm/Validation/SchemaWalker.js +6 -4
  335. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  336. package/lib/esm/ecschema-metadata.d.ts +1 -0
  337. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  338. package/lib/esm/ecschema-metadata.js +1 -0
  339. package/lib/esm/ecschema-metadata.js.map +1 -1
  340. package/lib/esm/utils/SchemaGraph.js +6 -7
  341. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  342. package/package.json +16 -14
@@ -12,6 +12,7 @@ const Helper_1 = require("../Deserialization/Helper");
12
12
  const JsonParser_1 = require("../Deserialization/JsonParser");
13
13
  const XmlParser_1 = require("../Deserialization/XmlParser");
14
14
  const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtils");
15
+ const ECObjects_1 = require("../ECObjects");
15
16
  const Exception_1 = require("../Exception");
16
17
  const SchemaKey_1 = require("../SchemaKey");
17
18
  const ECName_1 = require("../ECName");
@@ -31,12 +32,22 @@ const RelationshipClass_1 = require("./RelationshipClass");
31
32
  const SchemaItem_1 = require("./SchemaItem");
32
33
  const Unit_1 = require("./Unit");
33
34
  const UnitSystem_1 = require("./UnitSystem");
34
- const SCHEMAURL3_2_JSON = "https://dev.bentley.com/json_schemas/ec/32/ecschema";
35
- const SCHEMAURL3_2_XML = "http://www.bentley.com/schemas/Bentley.ECXML.3.2";
35
+ const Constants_1 = require("../Constants");
36
36
  /**
37
- * @beta
37
+ * @public @preview
38
38
  */
39
39
  class Schema {
40
+ static _currentECSpecVersion = "3.2";
41
+ _context;
42
+ _schemaKey;
43
+ _alias;
44
+ _label;
45
+ _description;
46
+ references;
47
+ _items;
48
+ _customAttributes;
49
+ _originalECSpecMajorVersion;
50
+ _originalECSpecMinorVersion;
40
51
  /** @internal */
41
52
  constructor(context, nameOrKey, alias, readVer, writeVer, minorVer) {
42
53
  this._schemaKey = (typeof (nameOrKey) === "string") ? new SchemaKey_1.SchemaKey(nameOrKey, new SchemaKey_1.ECVersion(readVer, writeVer, minorVer)) : nameOrKey;
@@ -47,43 +58,47 @@ class Schema {
47
58
  this._alias = alias;
48
59
  }
49
60
  else if (nameOrKey !== undefined) {
50
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Schema ${this.name} does not have the required 'alias' attribute.`);
61
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Schema ${this.name} does not have the required 'alias' attribute.`);
51
62
  }
52
63
  this._originalECSpecMajorVersion = Schema.currentECSpecMajorVersion;
53
64
  this._originalECSpecMinorVersion = Schema.currentECSpecMinorVersion;
54
65
  }
55
66
  get schemaKey() {
56
67
  if (undefined === this._schemaKey)
57
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
68
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
58
69
  return this._schemaKey;
59
70
  }
60
71
  get name() {
61
72
  if (this._schemaKey === undefined)
62
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
73
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
63
74
  return this.schemaKey.name;
64
75
  }
65
76
  get readVersion() {
66
77
  if (this._schemaKey === undefined)
67
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
78
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
68
79
  return this.schemaKey.readVersion;
69
80
  }
70
81
  get writeVersion() {
71
82
  if (this._schemaKey === undefined)
72
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
83
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
73
84
  return this.schemaKey.writeVersion;
74
85
  }
75
86
  get minorVersion() {
76
87
  if (this._schemaKey === undefined)
77
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
88
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
78
89
  return this.schemaKey.minorVersion;
79
90
  }
80
91
  get originalECSpecMajorVersion() { return this._originalECSpecMajorVersion; }
81
92
  get originalECSpecMinorVersion() { return this._originalECSpecMinorVersion; }
82
93
  static get currentECSpecMajorVersion() { return parseInt(Schema._currentECSpecVersion.split(".")[0], 10); }
83
94
  static get currentECSpecMinorVersion() { return parseInt(Schema._currentECSpecVersion.split(".")[1], 10); }
95
+ get _isECSpecVersionUnsupported() {
96
+ return (this.originalECSpecMajorVersion !== 3 || this.originalECSpecMinorVersion === undefined
97
+ || (this.originalECSpecMinorVersion < 2 || this.originalECSpecMinorVersion > Schema.currentECSpecMinorVersion));
98
+ }
84
99
  get alias() {
85
100
  if (this._alias === undefined || this._alias === null) {
86
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Schema ${this.name} does not have the required 'alias' attribute.`);
101
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Schema ${this.name} does not have the required 'alias' attribute.`);
87
102
  }
88
103
  else {
89
104
  return this._alias;
@@ -108,18 +123,19 @@ class Schema {
108
123
  if (this.name !== schemaName) {
109
124
  const newSchemaRef = this.getReferenceSync(schemaName);
110
125
  if (undefined === newSchemaRef)
111
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to find the referenced SchemaItem ${itemName}.`);
126
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to find the referenced SchemaItem ${itemName}.`);
112
127
  schemaKey = newSchemaRef.schemaKey;
113
128
  }
114
129
  return new SchemaKey_1.SchemaItemKey(itemName, schemaKey);
115
130
  }
131
+ /** @internal */
116
132
  addItem(item) {
117
133
  if (undefined !== this.getItemSync(item.name))
118
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateItem, `The SchemaItem ${item.name} cannot be added to the schema ${this.name} because it already exists`);
134
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateItem, `The SchemaItem ${item.name} cannot be added to the schema ${this.name} because it already exists`);
119
135
  this._items.set(item.name.toUpperCase(), item);
120
136
  }
121
137
  /**
122
- * @alpha
138
+ * @internal
123
139
  */
124
140
  createClass(type, name, modifier) {
125
141
  const item = new type(this, name, modifier);
@@ -129,7 +145,7 @@ class Schema {
129
145
  /**
130
146
  * Deletes a class from within this schema.
131
147
  * @param name the local (unqualified) class name, lookup is case-insensitive
132
- * @alpha
148
+ * @internal
133
149
  */
134
150
  async deleteClass(name) {
135
151
  const schemaItem = await this.getItem(name);
@@ -140,7 +156,7 @@ class Schema {
140
156
  /**
141
157
  * Deletes a class from within this schema.
142
158
  * @param name the local (unqualified) class name, lookup is case-insensitive
143
- * @alpha
159
+ * @internal
144
160
  */
145
161
  deleteClassSync(name) {
146
162
  const schemaItem = this.getItemSync(name);
@@ -150,7 +166,7 @@ class Schema {
150
166
  /**
151
167
  * Deletes a SchemaItem from within this schema.
152
168
  * @param name the local (unqualified) class name, lookup is case-insensitive
153
- * @alpha
169
+ * @internal
154
170
  */
155
171
  async deleteSchemaItem(name) {
156
172
  const schemaItem = await this.getItem(name);
@@ -161,21 +177,20 @@ class Schema {
161
177
  /**
162
178
  * Deletes a SchemaItem from within this schema.
163
179
  * @param name the local (unqualified) class name, lookup is case-insensitive
164
- * @alpha
180
+ * @internal
165
181
  */
166
182
  deleteSchemaItemSync(name) {
167
183
  const schemaItem = this.getItemSync(name);
168
184
  if (SchemaItem_1.SchemaItem.isSchemaItem(schemaItem))
169
185
  this._items.delete(name.toUpperCase());
170
186
  }
171
- /**
172
- * @alpha
173
- */
187
+ /** @internal */
174
188
  createItem(type, name) {
175
189
  const item = new type(this, name);
176
190
  this.addItem(item);
177
191
  return item;
178
192
  }
193
+ /** @internal */
179
194
  addCustomAttribute(customAttribute) {
180
195
  if (!this._customAttributes)
181
196
  this._customAttributes = new Map();
@@ -185,27 +200,33 @@ class Schema {
185
200
  * Creates a EntityClass with the provided name in this schema.
186
201
  * @param name
187
202
  * @param modifier
203
+ * @internal
188
204
  */
189
205
  async createEntityClass(name, modifier) {
190
206
  return this.createClass(EntityClass_1.EntityClass, name, modifier);
191
207
  }
208
+ /** @internal */
192
209
  createEntityClassSync(name, modifier) {
193
210
  return this.createClass(EntityClass_1.EntityClass, name, modifier);
194
211
  }
195
212
  /**
196
213
  * Creates a Mixin with the provided name in this schema.
197
214
  * @param name
215
+ * @internal
198
216
  */
199
217
  async createMixinClass(name) { return this.createClass(Mixin_1.Mixin, name); }
218
+ /** @internal */
200
219
  createMixinClassSync(name) { return this.createClass(Mixin_1.Mixin, name); }
201
220
  /**
202
221
  * Creates a StructClass with the provided name in this schema.
203
222
  * @param name
204
223
  * @param modifier
224
+ * @internal
205
225
  */
206
226
  async createStructClass(name, modifier) {
207
227
  return this.createClass(Class_1.StructClass, name, modifier);
208
228
  }
229
+ /** @internal */
209
230
  createStructClassSync(name, modifier) {
210
231
  return this.createClass(Class_1.StructClass, name, modifier);
211
232
  }
@@ -213,10 +234,12 @@ class Schema {
213
234
  * Creates a CustomAttributeClass with the provided name in this schema.
214
235
  * @param name
215
236
  * @param modifier
237
+ * @internal
216
238
  */
217
239
  async createCustomAttributeClass(name, modifier) {
218
240
  return this.createClass(CustomAttributeClass_1.CustomAttributeClass, name, modifier);
219
241
  }
242
+ /** @internal */
220
243
  createCustomAttributeClassSync(name, modifier) {
221
244
  return this.createClass(CustomAttributeClass_1.CustomAttributeClass, name, modifier);
222
245
  }
@@ -224,20 +247,26 @@ class Schema {
224
247
  * Creates a RelationshipClass with the provided name in this schema.
225
248
  * @param name
226
249
  * @param modifier
250
+ * @internal
227
251
  */
228
252
  async createRelationshipClass(name, modifier) {
229
253
  return this.createRelationshipClassSync(name, modifier);
230
254
  }
255
+ /** @internal */
231
256
  createRelationshipClassSync(name, modifier) {
232
257
  return this.createClass(RelationshipClass_1.RelationshipClass, name, modifier);
233
258
  }
234
259
  /**
235
260
  * Creates an Enumeration with the provided name in this schema.
236
261
  * @param name
262
+ * @param primitiveType
263
+ *
264
+ * @internal
237
265
  */
238
266
  async createEnumeration(name, primitiveType) {
239
267
  return this.createEnumerationSync(name, primitiveType);
240
268
  }
269
+ /** @internal */
241
270
  createEnumerationSync(name, primitiveType) {
242
271
  const item = new Enumeration_1.Enumeration(this, name, primitiveType);
243
272
  this.addItem(item);
@@ -246,97 +275,113 @@ class Schema {
246
275
  /**
247
276
  * Creates an KindOfQuantity with the provided name in this schema.
248
277
  * @param name
278
+ * @internal
249
279
  */
250
280
  async createKindOfQuantity(name) {
251
281
  return this.createKindOfQuantitySync(name);
252
282
  }
283
+ /** @internal */
253
284
  createKindOfQuantitySync(name) {
254
285
  return this.createItem(KindOfQuantity_1.KindOfQuantity, name);
255
286
  }
256
287
  /**
257
288
  * Creates a Constant with the provided name in this schema.
258
289
  * @param name
290
+ * @internal
259
291
  */
260
292
  async createConstant(name) {
261
293
  return this.createItem(Constant_1.Constant, name);
262
294
  }
295
+ /** @internal */
263
296
  createConstantSync(name) {
264
297
  return this.createItem(Constant_1.Constant, name);
265
298
  }
266
299
  /**
267
300
  * Creates a Inverted Unit with the provided name in this schema.
268
301
  * @param name
302
+ * @internal
269
303
  */
270
304
  async createInvertedUnit(name) {
271
305
  return this.createItem(InvertedUnit_1.InvertedUnit, name);
272
306
  }
307
+ /** @internal */
273
308
  createInvertedUnitSync(name) {
274
309
  return this.createItem(InvertedUnit_1.InvertedUnit, name);
275
310
  }
276
311
  /**
277
312
  * Creates an Format with the provided name in this schema.
278
313
  * @param name
314
+ * @internal
279
315
  */
280
316
  async createFormat(name) {
281
317
  return this.createItem(Format_1.Format, name);
282
318
  }
319
+ /** @internal */
283
320
  createFormatSync(name) {
284
321
  return this.createItem(Format_1.Format, name);
285
322
  }
286
323
  /**
287
324
  * Creates a UnitSystem with the provided name in this schema.
288
325
  * @param name
326
+ * @internal
289
327
  */
290
328
  async createUnitSystem(name) {
291
329
  return this.createItem(UnitSystem_1.UnitSystem, name);
292
330
  }
331
+ /** @internal */
293
332
  createUnitSystemSync(name) {
294
333
  return this.createItem(UnitSystem_1.UnitSystem, name);
295
334
  }
296
335
  /**
297
336
  * Creates a Phenomenon with the provided name in this schema.
298
337
  * @param name
338
+ * @internal
299
339
  */
300
340
  async createPhenomenon(name) {
301
341
  return this.createItem(Phenomenon_1.Phenomenon, name);
302
342
  }
343
+ /** @internal */
303
344
  createPhenomenonSync(name) {
304
345
  return this.createItem(Phenomenon_1.Phenomenon, name);
305
346
  }
306
347
  /**
307
348
  * Creates a Unit with the provided name in this schema.
308
349
  * @param name
350
+ * @internal
309
351
  */
310
352
  async createUnit(name) {
311
353
  return this.createItem(Unit_1.Unit, name);
312
354
  }
355
+ /** @internal */
313
356
  createUnitSync(name) {
314
357
  return this.createItem(Unit_1.Unit, name);
315
358
  }
316
359
  /**
317
360
  * Creates an PropertyCategory with the provided name in this schema.
318
361
  * @param name
362
+ * @internal
319
363
  */
320
364
  async createPropertyCategory(name) {
321
365
  return this.createItem(PropertyCategory_1.PropertyCategory, name);
322
366
  }
367
+ /** @internal */
323
368
  createPropertyCategorySync(name) {
324
369
  return this.createItem(PropertyCategory_1.PropertyCategory, name);
325
370
  }
326
371
  /**
327
372
  *
328
373
  * @param refSchema
374
+ * @internal
329
375
  */
330
376
  async addReference(refSchema) {
331
377
  // TODO validation of reference schema. For now just adding
332
378
  this.addReferenceSync(refSchema);
333
379
  }
380
+ /** @internal */
334
381
  addReferenceSync(refSchema) {
335
382
  this.references.push(refSchema);
336
383
  }
337
- /**
338
- * @alpha Used for schema editing.
339
- */
384
+ /** @internal */
340
385
  setContext(context) {
341
386
  this._context = context;
342
387
  }
@@ -345,34 +390,113 @@ class Schema {
345
390
  * @param readVersion The read version of the schema. If undefined, the value from the existing SchemaKey will be used.
346
391
  * @param writeVersion The write version of the schema. If undefined, the value from the existing SchemaKey will be used.
347
392
  * @param minorVersion The minor version of the schema. If undefined, the value from the existing SchemaKey will be used.
393
+ * @internal
348
394
  */
349
395
  setVersion(readVersion, writeVersion, minorVersion) {
350
396
  if (!this._schemaKey)
351
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaKey, `The schema '${this.name}' has an invalid SchemaKey.`);
397
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidSchemaKey, `The schema '${this.name}' has an invalid SchemaKey.`);
352
398
  const newVersion = new SchemaKey_1.ECVersion(readVersion ?? this._schemaKey.readVersion, writeVersion ?? this._schemaKey.writeVersion, minorVersion ?? this._schemaKey.minorVersion);
353
399
  this._schemaKey = new SchemaKey_1.SchemaKey(this._schemaKey.name, newVersion);
354
400
  }
355
401
  /**
356
- * Gets an item from within this schema. To get by full name use lookupItem instead.
357
- * @param key the local (unqualified) name, lookup is case-insensitive
402
+ * Shortcut for calling getItem with EntityClass.
403
+ * @param name The local (unqualified) name of the item to return.
404
+ * @returns The requested EntityClass or undefined if not found.
358
405
  */
359
- async getItem(name) {
360
- // this method exists so we can rewire it later when we load partial schemas, for now it is identical to the sync version
361
- return this.getItemSync(name);
362
- }
406
+ async getEntityClass(name) { return this.getItem(name, EntityClass_1.EntityClass); }
363
407
  /**
364
- * Gets an item from within this schema. To get by full name use lookupItem instead.
365
- * @param key the local (unqualified) name, lookup is case-insensitive
408
+ * Shortcut for calling getItem with Mixin.
409
+ * @param name The local (unqualified) name of the item to return.
410
+ * @returns The requested Mixin or undefined if not found.
366
411
  */
367
- getItemSync(name) {
368
- // Case-insensitive search
369
- return this._items.get(name.toUpperCase());
370
- }
412
+ async getMixin(name) { return this.getItem(name, Mixin_1.Mixin); }
413
+ /**
414
+ * Shortcut for calling getItem with StructClass.
415
+ * @param name The local (unqualified) name of the item to return.
416
+ * @returns The requested StructClass or undefined if not found.
417
+ */
418
+ async getStructClass(name) { return this.getItem(name, Class_1.StructClass); }
419
+ /**
420
+ * Shortcut for calling getItem with CustomAttributeClass.
421
+ * @param name The local (unqualified) name of the item to return.
422
+ * @returns The requested CustomAttributeClass or undefined if not found.
423
+ */
424
+ async getCustomAttributeClass(name) { return this.getItem(name, CustomAttributeClass_1.CustomAttributeClass); }
425
+ /**
426
+ * Shortcut for calling getItem with RelationshipClass.
427
+ * @param name The local (unqualified) name of the item to return.
428
+ * @returns The requested RelationshipClass or undefined if not found.
429
+ */
430
+ async getRelationshipClass(name) { return this.getItem(name, RelationshipClass_1.RelationshipClass); }
431
+ /**
432
+ * Shortcut for calling getItem with Enumeration.
433
+ * @param name The local (unqualified) name of the item to return.
434
+ * @returns The requested Enumeration or undefined if not found.
435
+ */
436
+ async getEnumeration(name) { return this.getItem(name, Enumeration_1.Enumeration); }
437
+ /**
438
+ * Shortcut for calling getItem with KindOfQuantity.
439
+ * @param name The local (unqualified) name of the item to return.
440
+ * @returns The requested KindOfQuantity or undefined if not found.
441
+ */
442
+ async getKindOfQuantity(name) { return this.getItem(name, KindOfQuantity_1.KindOfQuantity); }
443
+ /**
444
+ * Shortcut for calling getItem with PropertyCategory.
445
+ * @param name The local (unqualified) name of the item to return.
446
+ * @returns The requested PropertyCategory or undefined if not found.
447
+ */
448
+ async getPropertyCategory(name) { return this.getItem(name, PropertyCategory_1.PropertyCategory); }
449
+ /**
450
+ * Shortcut for calling getItem with Unit.
451
+ * @param name The local (unqualified) name of the item to return.
452
+ * @returns The requested Unit or undefined if not found.
453
+ */
454
+ async getUnit(name) { return this.getItem(name, Unit_1.Unit); }
455
+ /**
456
+ * Shortcut for calling getItem with InvertedUnit.
457
+ * @param name The local (unqualified) name of the item to return.
458
+ * @returns The requested InvertedUnit or undefined if not found.
459
+ */
460
+ async getInvertedUnit(name) { return this.getItem(name, InvertedUnit_1.InvertedUnit); }
461
+ /**
462
+ * Shortcut for calling getItem with Constant.
463
+ * @param name The local (unqualified) name of the item to return.
464
+ * @returns The requested Constant or undefined if not found.
465
+ */
466
+ async getConstant(name) { return this.getItem(name, Constant_1.Constant); }
467
+ /**
468
+ * Shortcut for calling getItem with Phenomenon.
469
+ * @param name The local (unqualified) name of the item to return.
470
+ * @returns The requested Phenomenon or undefined if not found.
471
+ */
472
+ async getPhenomenon(name) { return this.getItem(name, Phenomenon_1.Phenomenon); }
371
473
  /**
372
- * Attempts to find a schema item within this schema or a (directly) referenced schema
373
- * @param key The full name or a SchemaItemKey identifying the desired item.
474
+ * Shortcut for calling getItem with UnitSystem.
475
+ * @param name The local (unqualified) name of the item to return.
476
+ * @returns The requested UnitSystem or undefined if not found.
374
477
  */
375
- async lookupItem(key) {
478
+ async getUnitSystem(name) { return this.getItem(name, UnitSystem_1.UnitSystem); }
479
+ /**
480
+ * Shortcut for calling getItem with Format.
481
+ * @param name The local (unqualified) name of the item to return.
482
+ * @returns The requested Format or undefined if not found.
483
+ */
484
+ async getFormat(name) { return this.getItem(name, Format_1.Format); }
485
+ async getItem(name, itemConstructor) {
486
+ // this method exists so we can rewire it later when we load partial schemas, for now it is identical to the sync version
487
+ if (itemConstructor === undefined)
488
+ return this.getItemSync(name);
489
+ return this.getItemSync(name, itemConstructor);
490
+ }
491
+ getItemSync(name, itemConstructor) {
492
+ const value = this._items.get(name.toUpperCase());
493
+ if (value === undefined || itemConstructor === undefined)
494
+ return value;
495
+ if ((0, ECObjects_1.isSupportedSchemaItemType)(value.schemaItemType, itemConstructor.schemaItemType))
496
+ return value;
497
+ return undefined;
498
+ }
499
+ async lookupItem(key, itemConstructor) {
376
500
  let schemaName, itemName;
377
501
  if (typeof (key) === "string") {
378
502
  [schemaName, itemName] = SchemaItem_1.SchemaItem.parseFullName(key);
@@ -382,18 +506,18 @@ class Schema {
382
506
  schemaName = key.schemaName;
383
507
  }
384
508
  if (!schemaName || schemaName.toUpperCase() === this.name.toUpperCase()) {
385
- return this.getItem(itemName);
509
+ return itemConstructor
510
+ ? this.getItem(itemName, itemConstructor)
511
+ : this.getItem(itemName);
386
512
  }
387
513
  const refSchema = await this.getReference(schemaName);
388
514
  if (!refSchema)
389
515
  return undefined;
390
- return refSchema.getItem(itemName);
516
+ return itemConstructor
517
+ ? refSchema.getItem(itemName, itemConstructor)
518
+ : refSchema.getItem(itemName);
391
519
  }
392
- /**
393
- * Attempts to find a schema item within this schema or a (directly) referenced schema
394
- * @param key The full name or a SchemaItemKey identifying the desired item.
395
- */
396
- lookupItemSync(key) {
520
+ lookupItemSync(key, itemConstructor) {
397
521
  let schemaName, itemName;
398
522
  if (typeof (key) === "string") {
399
523
  [schemaName, itemName] = SchemaItem_1.SchemaItem.parseFullName(key);
@@ -403,35 +527,48 @@ class Schema {
403
527
  schemaName = key.schemaName;
404
528
  }
405
529
  if (!schemaName || schemaName.toUpperCase() === this.name.toUpperCase()) {
406
- return this.getItemSync(itemName);
530
+ return itemConstructor
531
+ ? this.getItemSync(itemName, itemConstructor)
532
+ : this.getItemSync(itemName);
407
533
  }
408
534
  const refSchema = this.getReferenceSync(schemaName);
409
535
  if (!refSchema)
410
536
  return undefined;
411
- return refSchema.getItemSync(itemName);
537
+ return itemConstructor
538
+ ? refSchema.getItemSync(itemName, itemConstructor)
539
+ : refSchema.getItemSync(itemName);
412
540
  }
413
- getItems() {
541
+ *getItems(itemConstructor) {
414
542
  if (!this._items)
415
- return new Map().values();
416
- return this._items.values();
417
- }
418
- *getClasses() {
419
- for (const [, value] of this._items) {
420
- if (Class_1.ECClass.isECClass(value))
421
- yield value;
543
+ return;
544
+ for (const item of this._items.values()) {
545
+ if (itemConstructor === undefined || (0, ECObjects_1.isSupportedSchemaItemType)(item.schemaItemType, itemConstructor.schemaItemType))
546
+ yield item;
422
547
  }
423
548
  }
549
+ /**
550
+ * Gets a referenced schema by name
551
+ * @param refSchemaName schema name to find
552
+ */
424
553
  async getReference(refSchemaName) {
425
554
  if (this.references.length === 0)
426
555
  return undefined;
427
556
  return this.references.find((ref) => ref.name.toLowerCase() === refSchemaName.toLowerCase());
428
557
  }
558
+ /**
559
+ * Gets a referenced schema by alias
560
+ * @param alias alias to find
561
+ */
429
562
  getReferenceNameByAlias(alias) {
430
563
  if (this.references.length === 0)
431
564
  return undefined;
432
565
  const schema = this.references.find((ref) => ref.alias ? ref.alias.toLowerCase() === alias.toLowerCase() : false);
433
566
  return schema ? schema.name : undefined;
434
567
  }
568
+ /**
569
+ * Gets a referenced schema by name
570
+ * @param refSchemaName schema name to find
571
+ */
435
572
  getReferenceSync(refSchemaName) {
436
573
  if (this.references.length === 0)
437
574
  return undefined;
@@ -441,10 +578,10 @@ class Schema {
441
578
  * Save this Schema's properties to an object for serializing to JSON.
442
579
  */
443
580
  toJSON() {
444
- if (!this.isECSpecVersionSupported())
445
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.NewerECSpecVersion, `The Schema '${this.name}' has an unsupported ECSpecVersion and cannot be serialized.`);
581
+ if (this._isECSpecVersionUnsupported)
582
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.NewerECSpecVersion, `The Schema '${this.name}' has an unsupported ECSpecVersion and cannot be serialized.`);
446
583
  const schemaJson = {};
447
- schemaJson.$schema = SCHEMAURL3_2_JSON; // $schema is required
584
+ schemaJson.$schema = Constants_1.ECSchemaNamespaceUris.SCHEMAURL3_2_JSON; // $schema is required
448
585
  schemaJson.name = this.name; // name is required
449
586
  schemaJson.version = this.schemaKey.version.toString(true);
450
587
  schemaJson.alias = this.alias; // alias is required
@@ -470,10 +607,10 @@ class Schema {
470
607
  * @param schemaXml An empty DOM document to which the schema will be written
471
608
  */
472
609
  async toXml(schemaXml) {
473
- if (!this.isECSpecVersionSupported())
474
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.NewerECSpecVersion, `The Schema '${this.name}' has an unsupported ECSpecVersion and cannot be serialized.`);
610
+ if (this._isECSpecVersionUnsupported)
611
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.NewerECSpecVersion, `The Schema '${this.name}' has an unsupported ECSpecVersion and cannot be serialized.`);
475
612
  const schemaMetadata = schemaXml.createElement("ECSchema");
476
- schemaMetadata.setAttribute("xmlns", SCHEMAURL3_2_XML);
613
+ schemaMetadata.setAttribute("xmlns", Constants_1.ECSchemaNamespaceUris.SCHEMAURL3_2_XML);
477
614
  schemaMetadata.setAttribute("version", this.schemaKey.version.toString());
478
615
  schemaMetadata.setAttribute("schemaName", this.name);
479
616
  schemaMetadata.setAttribute("alias", this.alias ? this.alias : "");
@@ -506,33 +643,6 @@ class Schema {
506
643
  schemaXml.appendChild(schemaMetadata);
507
644
  return schemaXml;
508
645
  }
509
- // Check if the ECSpecVersion read-version is greater than the current ECSpecVersion supported.
510
- // If a specific ECSpecVersion is given, check against that version.
511
- // If no argument is given, check against the original ECSpecVersion of the schema.
512
- isECSpecMajorVersionSupported(ecSpecMajorVersionToCheck) {
513
- // If argument is supplied, check the argument against the current ECSpecVersion supported
514
- if (ecSpecMajorVersionToCheck !== undefined)
515
- return (Schema.currentECSpecMajorVersion >= ecSpecMajorVersionToCheck);
516
- // If argument is not supplied, check against the original ECSpecVersion of the schema
517
- if (this.originalECSpecMajorVersion === undefined)
518
- return false;
519
- return (Schema.currentECSpecMajorVersion >= this.originalECSpecMajorVersion);
520
- }
521
- // Check if the full ECSpecVersion is greater than the current ECSpecVersion supported.
522
- // If a specific ECSpecVersion is given, check against that version.
523
- // If no argument is given, check against the original ECSpecVersion of the schema.
524
- isECSpecVersionSupported(ecSpecMajorVersionToCheck, ecSpecMinorVersionToCheck) {
525
- // If arguments are supplied, check the arguments against the current ECSpecVersion supported
526
- if (ecSpecMajorVersionToCheck !== undefined && ecSpecMinorVersionToCheck !== undefined) {
527
- if (!this.isECSpecMajorVersionSupported(ecSpecMajorVersionToCheck))
528
- return false;
529
- return (Schema.currentECSpecMinorVersion >= ecSpecMinorVersionToCheck);
530
- }
531
- // If arguments are not supplied, check against the original ECSpecVersion of the schema
532
- if (!this.isECSpecMajorVersionSupported() || this.originalECSpecMinorVersion === undefined)
533
- return false;
534
- return (Schema.currentECSpecMinorVersion >= this.originalECSpecMinorVersion);
535
- }
536
646
  /**
537
647
  * Loads the schema header (name, version alias, label and description) from the input SchemaProps
538
648
  */
@@ -544,12 +654,12 @@ class Schema {
544
654
  }
545
655
  else {
546
656
  if (schemaProps.name.toLowerCase() !== this.name.toLowerCase())
547
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Schema ${this.name} does not match the provided name, '${schemaProps.name}'.`);
657
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Schema ${this.name} does not match the provided name, '${schemaProps.name}'.`);
548
658
  if (this.schemaKey.version.compare(SchemaKey_1.ECVersion.fromString(schemaProps.version)))
549
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Schema ${this.name} has the version '${this.schemaKey.version}' that does not match the provided version '${schemaProps.version}'.`);
659
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Schema ${this.name} has the version '${this.schemaKey.version}' that does not match the provided version '${schemaProps.version}'.`);
550
660
  }
551
661
  if (schemaProps.$schema.match(`https://dev\\.bentley\\.com/json_schemas/ec/([0-9]+)/ecschema`) == null && schemaProps.$schema.match(`http://www\\.bentley\\.com/schemas/Bentley\\.ECXML\\.([0-9]+)`) == null)
552
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.MissingSchemaUrl, `The Schema '${this.name}' has an unsupported namespace '${schemaProps.$schema}'.`);
662
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.MissingSchemaUrl, `The Schema '${this.name}' has an unsupported namespace '${schemaProps.$schema}'.`);
553
663
  // The schema props have not been parsed. Parse the ECXml version from the $schema attribute
554
664
  let ecVersion;
555
665
  if (schemaProps.ecSpecMajorVersion === undefined || schemaProps.ecSpecMinorVersion === undefined) {
@@ -558,15 +668,15 @@ class Schema {
558
668
  else {
559
669
  ecVersion = { readVersion: schemaProps.ecSpecMajorVersion, writeVersion: schemaProps.ecSpecMinorVersion };
560
670
  }
561
- this._originalECSpecMajorVersion = ecVersion?.readVersion;
562
- this._originalECSpecMinorVersion = ecVersion?.writeVersion;
563
- if (!this.isECSpecMajorVersionSupported(ecVersion?.readVersion))
564
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.NewerECSpecVersion, `The Schema '${this.name}' has an unsupported ECVersion and cannot be loaded.`);
671
+ this._originalECSpecMajorVersion = ecVersion.readVersion;
672
+ this._originalECSpecMinorVersion = ecVersion.writeVersion;
673
+ if (ecVersion.readVersion !== 3 || (ecVersion.readVersion === 3 && ecVersion.writeVersion < 2))
674
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECVersion, `The Schema '${this.name}' has an unsupported ECVersion ${ecVersion.readVersion}.${ecVersion.writeVersion} and cannot be loaded.`);
565
675
  if (ECName_1.ECName.validate(schemaProps.alias)) {
566
676
  this._alias = schemaProps.alias;
567
677
  }
568
678
  else {
569
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Schema ${schemaProps.name} does not have the required 'alias' attribute.`);
679
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Schema ${schemaProps.name} does not have the required 'alias' attribute.`);
570
680
  }
571
681
  if (undefined !== schemaProps.label)
572
682
  this._label = schemaProps.label;
@@ -613,33 +723,23 @@ class Schema {
613
723
  const schema = object;
614
724
  return schema !== undefined && schema.schemaKey !== undefined && schema.context !== undefined;
615
725
  }
616
- /**
617
- * @alpha
618
- * Used for schema editing.
619
- */
726
+ /** @internal */
620
727
  setDisplayLabel(displayLabel) {
621
728
  this._label = displayLabel;
622
729
  }
623
- /**
624
- * @alpha
625
- * Used for schema editing.
626
- */
730
+ /** @internal */
627
731
  setDescription(description) {
628
732
  this._description = description;
629
733
  }
630
- /**
631
- * @alpha
632
- * Used for schema editing.
633
- */
734
+ /** @internal */
634
735
  setAlias(alias) {
635
736
  if (!ECName_1.ECName.validate(alias)) {
636
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECName, "The specified schema alias is invalid.");
737
+ throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECName, "The specified schema alias is invalid.");
637
738
  }
638
739
  this._alias = alias;
639
740
  }
640
741
  }
641
742
  exports.Schema = Schema;
642
- Schema._currentECSpecVersion = "3.2";
643
743
  /**
644
744
  * Hackish approach that works like a "friend class" so we can access protected members without making them public.
645
745
  * We cannot put this into Helper.ts and make it non-export, because we are importing Helper.ts from this file, and the circular import