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