@itwin/ecschema-metadata 5.0.0-dev.98 → 5.1.0-dev.0

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 (300) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/cjs/Constants.js.map +1 -1
  3. package/lib/cjs/Context.d.ts +3 -3
  4. package/lib/cjs/Context.d.ts.map +1 -1
  5. package/lib/cjs/Context.js +6 -6
  6. package/lib/cjs/Context.js.map +1 -1
  7. package/lib/cjs/DelayedPromise.d.ts +9 -8
  8. package/lib/cjs/DelayedPromise.d.ts.map +1 -1
  9. package/lib/cjs/DelayedPromise.js +2 -2
  10. package/lib/cjs/DelayedPromise.js.map +1 -1
  11. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  12. package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
  13. package/lib/cjs/Deserialization/Helper.js +27 -26
  14. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  15. package/lib/cjs/Deserialization/JsonParser.js +150 -150
  16. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  17. package/lib/cjs/Deserialization/JsonProps.d.ts +34 -34
  18. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  19. package/lib/cjs/Deserialization/JsonProps.js +3 -3
  20. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  21. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  22. package/lib/cjs/Deserialization/XmlParser.js +49 -49
  23. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  24. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +0 -5
  25. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  26. package/lib/cjs/Deserialization/XmlSerializationUtils.js +6 -11
  27. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  28. package/lib/cjs/ECName.d.ts +2 -2
  29. package/lib/cjs/ECName.js +4 -4
  30. package/lib/cjs/ECName.js.map +1 -1
  31. package/lib/cjs/ECObjects.d.ts +23 -11
  32. package/lib/cjs/ECObjects.d.ts.map +1 -1
  33. package/lib/cjs/ECObjects.js +47 -24
  34. package/lib/cjs/ECObjects.js.map +1 -1
  35. package/lib/cjs/Exception.d.ts +4 -4
  36. package/lib/cjs/Exception.d.ts.map +1 -1
  37. package/lib/cjs/Exception.js +60 -60
  38. package/lib/cjs/Exception.js.map +1 -1
  39. package/lib/cjs/Interfaces.d.ts +30 -34
  40. package/lib/cjs/Interfaces.d.ts.map +1 -1
  41. package/lib/cjs/Interfaces.js.map +1 -1
  42. package/lib/cjs/Metadata/Class.d.ts +107 -19
  43. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  44. package/lib/cjs/Metadata/Class.js +127 -47
  45. package/lib/cjs/Metadata/Class.js.map +1 -1
  46. package/lib/cjs/Metadata/Constant.d.ts +12 -9
  47. package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
  48. package/lib/cjs/Metadata/Constant.js +12 -9
  49. package/lib/cjs/Metadata/Constant.js.map +1 -1
  50. package/lib/cjs/Metadata/CustomAttribute.d.ts +2 -2
  51. package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
  52. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  53. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +5 -3
  54. package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
  55. package/lib/cjs/Metadata/CustomAttributeClass.js +7 -5
  56. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  57. package/lib/cjs/Metadata/EntityClass.d.ts +20 -3
  58. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  59. package/lib/cjs/Metadata/EntityClass.js +32 -14
  60. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  61. package/lib/cjs/Metadata/Enumeration.d.ts +16 -9
  62. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  63. package/lib/cjs/Metadata/Enumeration.js +20 -13
  64. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  65. package/lib/cjs/Metadata/Format.d.ts +32 -24
  66. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  67. package/lib/cjs/Metadata/Format.js +47 -27
  68. package/lib/cjs/Metadata/Format.js.map +1 -1
  69. package/lib/cjs/Metadata/InvertedUnit.d.ts +11 -7
  70. package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
  71. package/lib/cjs/Metadata/InvertedUnit.js +16 -10
  72. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  73. package/lib/cjs/Metadata/KindOfQuantity.d.ts +24 -15
  74. package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
  75. package/lib/cjs/Metadata/KindOfQuantity.js +54 -29
  76. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  77. package/lib/cjs/Metadata/Mixin.d.ts +16 -3
  78. package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
  79. package/lib/cjs/Metadata/Mixin.js +20 -7
  80. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  81. package/lib/cjs/Metadata/OverrideFormat.d.ts +12 -12
  82. package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
  83. package/lib/cjs/Metadata/OverrideFormat.js +27 -19
  84. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  85. package/lib/cjs/Metadata/Phenomenon.d.ts +10 -2
  86. package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
  87. package/lib/cjs/Metadata/Phenomenon.js +11 -3
  88. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  89. package/lib/cjs/Metadata/Property.d.ts +46 -28
  90. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  91. package/lib/cjs/Metadata/Property.js +46 -22
  92. package/lib/cjs/Metadata/Property.js.map +1 -1
  93. package/lib/cjs/Metadata/PropertyCategory.d.ts +6 -3
  94. package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
  95. package/lib/cjs/Metadata/PropertyCategory.js +12 -5
  96. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  97. package/lib/cjs/Metadata/RelationshipClass.d.ts +48 -25
  98. package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
  99. package/lib/cjs/Metadata/RelationshipClass.js +54 -34
  100. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  101. package/lib/cjs/Metadata/Schema.d.ts +50 -28
  102. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  103. package/lib/cjs/Metadata/Schema.js +64 -42
  104. package/lib/cjs/Metadata/Schema.js.map +1 -1
  105. package/lib/cjs/Metadata/SchemaItem.d.ts +10 -19
  106. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  107. package/lib/cjs/Metadata/SchemaItem.js +12 -20
  108. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  109. package/lib/cjs/Metadata/Unit.d.ts +17 -21
  110. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  111. package/lib/cjs/Metadata/Unit.js +20 -22
  112. package/lib/cjs/Metadata/Unit.js.map +1 -1
  113. package/lib/cjs/Metadata/UnitSystem.d.ts +3 -1
  114. package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
  115. package/lib/cjs/Metadata/UnitSystem.js +4 -2
  116. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  117. package/lib/cjs/PropertyTypes.d.ts +11 -11
  118. package/lib/cjs/PropertyTypes.d.ts.map +1 -1
  119. package/lib/cjs/PropertyTypes.js +28 -20
  120. package/lib/cjs/PropertyTypes.js.map +1 -1
  121. package/lib/cjs/SchemaFormatsProvider.d.ts +39 -0
  122. package/lib/cjs/SchemaFormatsProvider.d.ts.map +1 -0
  123. package/lib/cjs/SchemaFormatsProvider.js +146 -0
  124. package/lib/cjs/SchemaFormatsProvider.js.map +1 -0
  125. package/lib/cjs/SchemaJsonLocater.d.ts +5 -5
  126. package/lib/cjs/SchemaJsonLocater.js +4 -4
  127. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  128. package/lib/cjs/SchemaKey.d.ts +6 -6
  129. package/lib/cjs/SchemaKey.d.ts.map +1 -1
  130. package/lib/cjs/SchemaKey.js +9 -9
  131. package/lib/cjs/SchemaKey.js.map +1 -1
  132. package/lib/cjs/SchemaLoader.d.ts +3 -3
  133. package/lib/cjs/SchemaLoader.js +4 -4
  134. package/lib/cjs/SchemaLoader.js.map +1 -1
  135. package/lib/cjs/SchemaPartVisitorDelegate.d.ts +2 -2
  136. package/lib/cjs/SchemaPartVisitorDelegate.js +1 -1
  137. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  138. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  139. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  140. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  141. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  142. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  143. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  144. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  145. package/lib/cjs/ecschema-metadata.d.ts +2 -1
  146. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  147. package/lib/cjs/ecschema-metadata.js +1 -0
  148. package/lib/cjs/ecschema-metadata.js.map +1 -1
  149. package/lib/cjs/utils/SchemaGraph.js +3 -3
  150. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  151. package/lib/esm/Constants.js.map +1 -1
  152. package/lib/esm/Context.d.ts +3 -3
  153. package/lib/esm/Context.d.ts.map +1 -1
  154. package/lib/esm/Context.js +7 -7
  155. package/lib/esm/Context.js.map +1 -1
  156. package/lib/esm/DelayedPromise.d.ts +9 -8
  157. package/lib/esm/DelayedPromise.d.ts.map +1 -1
  158. package/lib/esm/DelayedPromise.js +2 -2
  159. package/lib/esm/DelayedPromise.js.map +1 -1
  160. package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
  161. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  162. package/lib/esm/Deserialization/Helper.js +28 -27
  163. package/lib/esm/Deserialization/Helper.js.map +1 -1
  164. package/lib/esm/Deserialization/JsonParser.js +151 -151
  165. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  166. package/lib/esm/Deserialization/JsonProps.d.ts +34 -34
  167. package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
  168. package/lib/esm/Deserialization/JsonProps.js +3 -3
  169. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  170. package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
  171. package/lib/esm/Deserialization/XmlParser.js +50 -50
  172. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  173. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts +0 -5
  174. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  175. package/lib/esm/Deserialization/XmlSerializationUtils.js +7 -12
  176. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  177. package/lib/esm/ECName.d.ts +2 -2
  178. package/lib/esm/ECName.js +5 -5
  179. package/lib/esm/ECName.js.map +1 -1
  180. package/lib/esm/ECObjects.d.ts +23 -11
  181. package/lib/esm/ECObjects.d.ts.map +1 -1
  182. package/lib/esm/ECObjects.js +48 -25
  183. package/lib/esm/ECObjects.js.map +1 -1
  184. package/lib/esm/Exception.d.ts +4 -4
  185. package/lib/esm/Exception.d.ts.map +1 -1
  186. package/lib/esm/Exception.js +58 -58
  187. package/lib/esm/Exception.js.map +1 -1
  188. package/lib/esm/Interfaces.d.ts +30 -34
  189. package/lib/esm/Interfaces.d.ts.map +1 -1
  190. package/lib/esm/Interfaces.js.map +1 -1
  191. package/lib/esm/Metadata/Class.d.ts +107 -19
  192. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  193. package/lib/esm/Metadata/Class.js +128 -48
  194. package/lib/esm/Metadata/Class.js.map +1 -1
  195. package/lib/esm/Metadata/Constant.d.ts +12 -9
  196. package/lib/esm/Metadata/Constant.d.ts.map +1 -1
  197. package/lib/esm/Metadata/Constant.js +13 -10
  198. package/lib/esm/Metadata/Constant.js.map +1 -1
  199. package/lib/esm/Metadata/CustomAttribute.d.ts +2 -2
  200. package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -1
  201. package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
  202. package/lib/esm/Metadata/CustomAttributeClass.d.ts +5 -3
  203. package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
  204. package/lib/esm/Metadata/CustomAttributeClass.js +8 -6
  205. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  206. package/lib/esm/Metadata/EntityClass.d.ts +20 -3
  207. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  208. package/lib/esm/Metadata/EntityClass.js +33 -15
  209. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  210. package/lib/esm/Metadata/Enumeration.d.ts +16 -9
  211. package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
  212. package/lib/esm/Metadata/Enumeration.js +21 -14
  213. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  214. package/lib/esm/Metadata/Format.d.ts +32 -24
  215. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  216. package/lib/esm/Metadata/Format.js +48 -28
  217. package/lib/esm/Metadata/Format.js.map +1 -1
  218. package/lib/esm/Metadata/InvertedUnit.d.ts +11 -7
  219. package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
  220. package/lib/esm/Metadata/InvertedUnit.js +17 -11
  221. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  222. package/lib/esm/Metadata/KindOfQuantity.d.ts +24 -15
  223. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
  224. package/lib/esm/Metadata/KindOfQuantity.js +55 -30
  225. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  226. package/lib/esm/Metadata/Mixin.d.ts +16 -3
  227. package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
  228. package/lib/esm/Metadata/Mixin.js +21 -8
  229. package/lib/esm/Metadata/Mixin.js.map +1 -1
  230. package/lib/esm/Metadata/OverrideFormat.d.ts +12 -12
  231. package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -1
  232. package/lib/esm/Metadata/OverrideFormat.js +28 -20
  233. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  234. package/lib/esm/Metadata/Phenomenon.d.ts +10 -2
  235. package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
  236. package/lib/esm/Metadata/Phenomenon.js +12 -4
  237. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  238. package/lib/esm/Metadata/Property.d.ts +46 -28
  239. package/lib/esm/Metadata/Property.d.ts.map +1 -1
  240. package/lib/esm/Metadata/Property.js +47 -23
  241. package/lib/esm/Metadata/Property.js.map +1 -1
  242. package/lib/esm/Metadata/PropertyCategory.d.ts +6 -3
  243. package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
  244. package/lib/esm/Metadata/PropertyCategory.js +13 -6
  245. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  246. package/lib/esm/Metadata/RelationshipClass.d.ts +48 -25
  247. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
  248. package/lib/esm/Metadata/RelationshipClass.js +55 -35
  249. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  250. package/lib/esm/Metadata/Schema.d.ts +50 -28
  251. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  252. package/lib/esm/Metadata/Schema.js +65 -43
  253. package/lib/esm/Metadata/Schema.js.map +1 -1
  254. package/lib/esm/Metadata/SchemaItem.d.ts +10 -19
  255. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  256. package/lib/esm/Metadata/SchemaItem.js +13 -21
  257. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  258. package/lib/esm/Metadata/Unit.d.ts +17 -21
  259. package/lib/esm/Metadata/Unit.d.ts.map +1 -1
  260. package/lib/esm/Metadata/Unit.js +21 -23
  261. package/lib/esm/Metadata/Unit.js.map +1 -1
  262. package/lib/esm/Metadata/UnitSystem.d.ts +3 -1
  263. package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
  264. package/lib/esm/Metadata/UnitSystem.js +5 -3
  265. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  266. package/lib/esm/PropertyTypes.d.ts +11 -11
  267. package/lib/esm/PropertyTypes.d.ts.map +1 -1
  268. package/lib/esm/PropertyTypes.js +29 -21
  269. package/lib/esm/PropertyTypes.js.map +1 -1
  270. package/lib/esm/SchemaFormatsProvider.d.ts +39 -0
  271. package/lib/esm/SchemaFormatsProvider.d.ts.map +1 -0
  272. package/lib/esm/SchemaFormatsProvider.js +142 -0
  273. package/lib/esm/SchemaFormatsProvider.js.map +1 -0
  274. package/lib/esm/SchemaJsonLocater.d.ts +5 -5
  275. package/lib/esm/SchemaJsonLocater.js +4 -4
  276. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  277. package/lib/esm/SchemaKey.d.ts +6 -6
  278. package/lib/esm/SchemaKey.d.ts.map +1 -1
  279. package/lib/esm/SchemaKey.js +10 -10
  280. package/lib/esm/SchemaKey.js.map +1 -1
  281. package/lib/esm/SchemaLoader.d.ts +3 -3
  282. package/lib/esm/SchemaLoader.js +5 -5
  283. package/lib/esm/SchemaLoader.js.map +1 -1
  284. package/lib/esm/SchemaPartVisitorDelegate.d.ts +2 -2
  285. package/lib/esm/SchemaPartVisitorDelegate.js +1 -1
  286. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  287. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  288. package/lib/esm/UnitConversion/Parser.js.map +1 -1
  289. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  290. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  291. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  292. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  293. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  294. package/lib/esm/ecschema-metadata.d.ts +2 -1
  295. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  296. package/lib/esm/ecschema-metadata.js +1 -0
  297. package/lib/esm/ecschema-metadata.js.map +1 -1
  298. package/lib/esm/utils/SchemaGraph.js +4 -4
  299. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  300. package/package.json +8 -6
@@ -0,0 +1,142 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module Metadata
7
+ */
8
+ import { SchemaContext } from "./Context";
9
+ import { SchemaItemKey, SchemaKey } from "./SchemaKey";
10
+ import { SchemaItem } from "./Metadata/SchemaItem";
11
+ import { Format } from "./Metadata/Format";
12
+ import { BeEvent } from "@itwin/core-bentley";
13
+ import { KindOfQuantity } from "./Metadata/KindOfQuantity";
14
+ import { getFormatProps } from "./Metadata/OverrideFormat";
15
+ /**
16
+ * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.
17
+ * @beta
18
+ */
19
+ export class SchemaFormatsProvider {
20
+ _context;
21
+ _unitSystem;
22
+ _formatsRetrieved = new Set();
23
+ onFormatsChanged = new BeEvent();
24
+ /**
25
+ *
26
+ * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext
27
+ * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be
28
+ * created and the locater will be added.
29
+ * @param unitSystem Used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.
30
+ */
31
+ constructor(contextOrLocater, unitSystem) {
32
+ if (contextOrLocater instanceof SchemaContext) {
33
+ this._context = contextOrLocater;
34
+ }
35
+ else {
36
+ this._context = new SchemaContext();
37
+ this._context.addLocater(contextOrLocater);
38
+ }
39
+ this._unitSystem = unitSystem;
40
+ }
41
+ get context() { return this._context; }
42
+ get unitSystem() { return this._unitSystem; }
43
+ set unitSystem(unitSystem) {
44
+ this._unitSystem = unitSystem;
45
+ this.clear();
46
+ }
47
+ clear() {
48
+ const formatsChanged = Array.from(this._formatsRetrieved);
49
+ this._formatsRetrieved.clear();
50
+ this.onFormatsChanged.raiseEvent({ formatsChanged });
51
+ }
52
+ async getKindOfQuantityFormatFromSchema(itemKey) {
53
+ const kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);
54
+ if (!kindOfQuantity) {
55
+ return undefined;
56
+ }
57
+ // Find the first presentation format that matches the provided unit system.
58
+ const unitSystemGroupNames = getUnitSystemGroupNames(this._unitSystem);
59
+ const presentationFormats = kindOfQuantity.presentationFormats;
60
+ for (const system of unitSystemGroupNames) {
61
+ for (const lazyFormat of presentationFormats) {
62
+ const format = await lazyFormat;
63
+ const unit = await (format.units && format.units[0][0]);
64
+ if (!unit) {
65
+ continue;
66
+ }
67
+ const currentUnitSystem = unit.unitSystem;
68
+ if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {
69
+ this._formatsRetrieved.add(itemKey.fullName);
70
+ return getFormatProps(format);
71
+ }
72
+ }
73
+ }
74
+ // If no matching presentation format was found, use persistence unit format if it matches unit system.
75
+ const persistenceUnit = await kindOfQuantity.persistenceUnit;
76
+ const persistenceUnitSystem = await persistenceUnit?.unitSystem;
77
+ if (persistenceUnitSystem && unitSystemGroupNames.includes(persistenceUnitSystem.name.toUpperCase())) {
78
+ this._formatsRetrieved.add(itemKey.fullName);
79
+ return getPersistenceUnitFormatProps(persistenceUnit);
80
+ }
81
+ const defaultFormat = kindOfQuantity.defaultPresentationFormat;
82
+ if (!defaultFormat) {
83
+ return undefined;
84
+ }
85
+ this._formatsRetrieved.add(itemKey.fullName);
86
+ return getFormatProps(await defaultFormat);
87
+ }
88
+ /**
89
+ * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.
90
+ * If no presentation format matches the current unit system, the persistence unit format will be retrieved if it matches the current unit system.
91
+ * Else, the default presentation format will be retrieved.
92
+ * @param name The full name of the Format or KindOfQuantity.
93
+ * @returns
94
+ */
95
+ async getFormat(name) {
96
+ const [schemaName, schemaItemName] = SchemaItem.parseFullName(name);
97
+ const schemaKey = new SchemaKey(schemaName);
98
+ const schema = await this._context.getSchema(schemaKey);
99
+ if (!schema) {
100
+ return undefined;
101
+ }
102
+ const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);
103
+ if (schema.name === "Formats") {
104
+ const format = await this._context.getSchemaItem(itemKey, Format);
105
+ if (!format) {
106
+ return undefined;
107
+ }
108
+ return format.toJSON(true);
109
+ }
110
+ return this.getKindOfQuantityFormatFromSchema(itemKey);
111
+ }
112
+ }
113
+ function getUnitSystemGroupNames(unitSystem) {
114
+ switch (unitSystem) {
115
+ case "imperial":
116
+ return ["IMPERIAL", "USCUSTOM", "INTERNATIONAL", "FINANCE"];
117
+ case "metric":
118
+ return ["SI", "METRIC", "INTERNATIONAL", "FINANCE"];
119
+ case "usCustomary":
120
+ return ["USCUSTOM", "INTERNATIONAL", "FINANCE"];
121
+ case "usSurvey":
122
+ return ["USSURVEY", "USCUSTOM", "INTERNATIONAL", "FINANCE"];
123
+ }
124
+ return [];
125
+ }
126
+ function getPersistenceUnitFormatProps(persistenceUnit) {
127
+ // Same as Format "DefaultRealU" in Formats ecschema
128
+ return {
129
+ formatTraits: ["keepSingleZero", "keepDecimalPoint", "showUnitLabel"],
130
+ precision: 6,
131
+ type: "Decimal",
132
+ composite: {
133
+ units: [
134
+ {
135
+ name: persistenceUnit.fullName,
136
+ label: persistenceUnit.label,
137
+ },
138
+ ],
139
+ },
140
+ };
141
+ }
142
+ //# sourceMappingURL=SchemaFormatsProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaFormatsProvider.js","sourceRoot":"","sources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AAC;gBACZ,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,CAAC,iCAAiC,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;CACF;AAED,SAAS,uBAAuB,CAAC,UAA0B;IACzD,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAC9D,KAAK,QAAQ;YACX,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QACtD,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAClD,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,6BAA6B,CAAC,eAAoC;IACzE,oDAAoD;IACpD,OAAO;QACL,YAAY,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,eAAe,CAAC,QAAQ;oBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B;aACF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { Format } from \"./Metadata/Format\";\r\nimport { SchemaItemFormatProps } from \"./Deserialization/JsonProps\";\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\r\nimport { getFormatProps } from \"./Metadata/OverrideFormat\";\r\nimport { FormatProps, FormatsChangedArgs, FormatsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { Unit } from \"./Metadata/Unit\";\r\nimport { InvertedUnit } from \"./Metadata/InvertedUnit\";\r\n\r\n/**\r\n * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.\r\n * @beta\r\n */\r\nexport class SchemaFormatsProvider implements FormatsProvider {\r\n private _context: SchemaContext;\r\n private _unitSystem: UnitSystemKey;\r\n private _formatsRetrieved: Set<string> = new Set();\r\n public onFormatsChanged = new BeEvent<(args: FormatsChangedArgs) => void>();\r\n /**\r\n *\r\n * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext\r\n * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be\r\n * created and the locater will be added.\r\n * @param unitSystem Used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.\r\n */\r\n constructor(contextOrLocater: ISchemaLocater, unitSystem: UnitSystemKey) {\r\n if (contextOrLocater instanceof SchemaContext) {\r\n this._context = contextOrLocater;\r\n } else {\r\n this._context = new SchemaContext();\r\n this._context.addLocater(contextOrLocater);\r\n }\r\n this._unitSystem = unitSystem;\r\n }\r\n\r\n public get context() { return this._context; }\r\n public get unitSystem() { return this._unitSystem; }\r\n\r\n public set unitSystem(unitSystem: UnitSystemKey) {\r\n this._unitSystem = unitSystem;\r\n this.clear();\r\n }\r\n\r\n private clear(): void {\r\n const formatsChanged = Array.from(this._formatsRetrieved);\r\n this._formatsRetrieved.clear();\r\n this.onFormatsChanged.raiseEvent({ formatsChanged });\r\n }\r\n\r\n private async getKindOfQuantityFormatFromSchema(itemKey: SchemaItemKey): Promise<SchemaItemFormatProps | undefined> {\r\n const kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);\r\n\r\n if (!kindOfQuantity) {\r\n return undefined;\r\n }\r\n\r\n // Find the first presentation format that matches the provided unit system.\r\n const unitSystemGroupNames = getUnitSystemGroupNames(this._unitSystem);\r\n const presentationFormats = kindOfQuantity.presentationFormats;\r\n for (const system of unitSystemGroupNames) {\r\n for (const lazyFormat of presentationFormats) {\r\n const format = await lazyFormat;\r\n const unit = await (format.units && format.units[0][0]);\r\n if (!unit) {\r\n continue;\r\n }\r\n const currentUnitSystem = unit.unitSystem;\r\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n return getFormatProps(format);\r\n }\r\n }\r\n }\r\n\r\n // If no matching presentation format was found, use persistence unit format if it matches unit system.\r\n const persistenceUnit = await kindOfQuantity.persistenceUnit;\r\n const persistenceUnitSystem = await persistenceUnit?.unitSystem;\r\n if (persistenceUnitSystem && unitSystemGroupNames.includes(persistenceUnitSystem.name.toUpperCase())) {\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n return getPersistenceUnitFormatProps(persistenceUnit!);\r\n }\r\n\r\n const defaultFormat = kindOfQuantity.defaultPresentationFormat;\r\n if (!defaultFormat) {\r\n return undefined;\r\n }\r\n this._formatsRetrieved.add(itemKey.fullName);\r\n return getFormatProps(await defaultFormat);\r\n }\r\n\r\n\r\n /**\r\n * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.\r\n * If no presentation format matches the current unit system, the persistence unit format will be retrieved if it matches the current unit system.\r\n * Else, the default presentation format will be retrieved.\r\n * @param name The full name of the Format or KindOfQuantity.\r\n * @returns\r\n */\r\n public async getFormat(name: string): Promise<SchemaItemFormatProps | undefined> {\r\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(name);\r\n const schemaKey = new SchemaKey(schemaName);\r\n const schema = await this._context.getSchema(schemaKey);\r\n if (!schema) {\r\n return undefined;\r\n }\r\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\r\n\r\n if (schema.name === \"Formats\") {\r\n const format = await this._context.getSchemaItem(itemKey, Format);\r\n if (!format) {\r\n return undefined;\r\n }\r\n return format.toJSON(true);\r\n }\r\n return this.getKindOfQuantityFormatFromSchema(itemKey);\r\n }\r\n}\r\n\r\nfunction getUnitSystemGroupNames(unitSystem?: UnitSystemKey) {\r\n switch (unitSystem) {\r\n case \"imperial\":\r\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\r\n case \"metric\":\r\n return [\"SI\", \"METRIC\", \"INTERNATIONAL\", \"FINANCE\"];\r\n case \"usCustomary\":\r\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\r\n case \"usSurvey\":\r\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\r\n }\r\n return [];\r\n}\r\n\r\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\r\n // Same as Format \"DefaultRealU\" in Formats ecschema\r\n return {\r\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\r\n precision: 6,\r\n type: \"Decimal\",\r\n composite: {\r\n units: [\r\n {\r\n name: persistenceUnit.fullName,\r\n label: persistenceUnit.label,\r\n },\r\n ],\r\n },\r\n };\r\n}"]}
@@ -7,13 +7,13 @@ import { SchemaKey } from "./SchemaKey";
7
7
  /**
8
8
  * Gets the full schema Json for the input schema name or undefined if not found
9
9
  * @throws [Error] if the schema is found but json cannot be returned
10
- * @beta
10
+ * @public @preview
11
11
  */
12
12
  export type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;
13
13
  /**
14
- * A ISchemaLocater implementation for locating and retrieving EC Schema objects using a function
14
+ * An ISchemaLocater implementation for locating and retrieving EC Schema objects using a function
15
15
  * that returns the Schema Json for a given schema name
16
- * @beta
16
+ * @public @preview
17
17
  */
18
18
  export declare class SchemaJsonLocater implements ISchemaLocater {
19
19
  private _getSchema;
@@ -22,7 +22,7 @@ export declare class SchemaJsonLocater implements ISchemaLocater {
22
22
  * @param schemaKey The [SchemaKey] that identifies the schema.
23
23
  * @param matchType The [SchemaMatchType] to used for comparing schema versions.
24
24
  * @param context The [SchemaContext] used to facilitate schema location.
25
- * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
25
+ * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.
26
26
  */
27
27
  getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;
28
28
  /**
@@ -33,7 +33,7 @@ export declare class SchemaJsonLocater implements ISchemaLocater {
33
33
  getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;
34
34
  /** Get a schema by [SchemaKey] synchronously.
35
35
  * @param schemaKey The [SchemaKey] that identifies the schema.
36
- * * @param matchType The [SchemaMatchType] to used for comparing schema versions.
36
+ * @param matchType The [SchemaMatchType] to used for comparing schema versions.
37
37
  * @param context The [SchemaContext] used to facilitate schema location.
38
38
  * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.
39
39
  */
@@ -5,9 +5,9 @@
5
5
  import { SchemaContext } from "./Context";
6
6
  import { Schema } from "./Metadata/Schema";
7
7
  /**
8
- * A ISchemaLocater implementation for locating and retrieving EC Schema objects using a function
8
+ * An ISchemaLocater implementation for locating and retrieving EC Schema objects using a function
9
9
  * that returns the Schema Json for a given schema name
10
- * @beta
10
+ * @public @preview
11
11
  */
12
12
  export class SchemaJsonLocater {
13
13
  _getSchema;
@@ -18,7 +18,7 @@ export class SchemaJsonLocater {
18
18
  * @param schemaKey The [SchemaKey] that identifies the schema.
19
19
  * @param matchType The [SchemaMatchType] to used for comparing schema versions.
20
20
  * @param context The [SchemaContext] used to facilitate schema location.
21
- * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
21
+ * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.
22
22
  */
23
23
  async getSchema(schemaKey, matchType, context) {
24
24
  await this.getSchemaInfo(schemaKey, matchType, context);
@@ -40,7 +40,7 @@ export class SchemaJsonLocater {
40
40
  }
41
41
  /** Get a schema by [SchemaKey] synchronously.
42
42
  * @param schemaKey The [SchemaKey] that identifies the schema.
43
- * * @param matchType The [SchemaMatchType] to used for comparing schema versions.
43
+ * @param matchType The [SchemaMatchType] to used for comparing schema versions.
44
44
  * @param context The [SchemaContext] used to facilitate schema location.
45
45
  * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.
46
46
  */
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaJsonLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAkB,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAU3C;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACD;IAA3B,YAA2B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAI,CAAC;IAE7D;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7F,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3E,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;YAChF,OAAO,UAAU,CAAC;QAEpB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAC,SAAoB,EAAE,UAA2B,EAAE,OAAsB;QAC5F,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,OAAO,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,IAAI,IAAI,aAAa,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\nimport { SchemaProps } from \"./Deserialization/JsonProps\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { SchemaInfo } from \"./Interfaces\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaKey } from \"./SchemaKey\";\n\n/**\n * Gets the full schema Json for the input schema name or undefined if not found\n * @throws [Error] if the schema is found but json cannot be returned\n * @beta\n */\nexport type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;\n\n/**\n * A ISchemaLocater implementation for locating and retrieving EC Schema objects using a function\n * that returns the Schema Json for a given schema name\n * @beta\n */\nexport class SchemaJsonLocater implements ISchemaLocater {\n public constructor(private _getSchema: SchemaPropsGetter) { }\n\n /** Get a schema by [SchemaKey]\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n await this.getSchemaInfo(schemaKey, matchType, context);\n return context.getCachedSchema(schemaKey, matchType);\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const schemaProps = this._getSchema(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n const schemaInfo = await Schema.startLoadingFromJson(schemaProps, context);\n if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType))\n return schemaInfo;\n\n return undefined;\n }\n\n /** Get a schema by [SchemaKey] synchronously.\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public getSchemaSync(schemaKey: SchemaKey, _matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\n const schemaProps = this._getSchema(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n return Schema.fromJsonSync(schemaProps, context || new SchemaContext());\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaJsonLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAkB,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAU3C;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACD;IAA3B,YAA2B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAI,CAAC;IAE7D;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7F,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3E,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;YAChF,OAAO,UAAU,CAAC;QAEpB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAC,SAAoB,EAAE,UAA2B,EAAE,OAAsB;QAC5F,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,OAAO,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,IAAI,IAAI,aAAa,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\r\nimport { SchemaProps } from \"./Deserialization/JsonProps\";\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { SchemaInfo } from \"./Interfaces\";\r\nimport { Schema } from \"./Metadata/Schema\";\r\nimport { SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * Gets the full schema Json for the input schema name or undefined if not found\r\n * @throws [Error] if the schema is found but json cannot be returned\r\n * @public @preview\r\n */\r\nexport type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;\r\n\r\n/**\r\n * An ISchemaLocater implementation for locating and retrieving EC Schema objects using a function\r\n * that returns the Schema Json for a given schema name\r\n * @public @preview\r\n */\r\nexport class SchemaJsonLocater implements ISchemaLocater {\r\n public constructor(private _getSchema: SchemaPropsGetter) { }\r\n\r\n /** Get a schema by [SchemaKey]\r\n * @param schemaKey The [SchemaKey] that identifies the schema.\r\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\r\n * @param context The [SchemaContext] used to facilitate schema location.\r\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\r\n await this.getSchemaInfo(schemaKey, matchType, context);\r\n return context.getCachedSchema(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\r\n const schemaProps = this._getSchema(schemaKey.name);\r\n if (!schemaProps)\r\n return undefined;\r\n\r\n const schemaInfo = await Schema.startLoadingFromJson(schemaProps, context);\r\n if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType))\r\n return schemaInfo;\r\n\r\n return undefined;\r\n }\r\n\r\n /** Get a schema by [SchemaKey] synchronously.\r\n * @param schemaKey The [SchemaKey] that identifies the schema.\r\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\r\n * @param context The [SchemaContext] used to facilitate schema location.\r\n * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public getSchemaSync(schemaKey: SchemaKey, _matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\r\n const schemaProps = this._getSchema(schemaKey.name);\r\n if (!schemaProps)\r\n return undefined;\r\n\r\n return Schema.fromJsonSync(schemaProps, context || new SchemaContext());\r\n }\r\n}\r\n"]}
@@ -4,7 +4,7 @@
4
4
  import { SchemaKeyProps } from "./Deserialization/JsonProps";
5
5
  import { SchemaMatchType } from "./ECObjects";
6
6
  /**
7
- * @beta
7
+ * @public @preview
8
8
  */
9
9
  export declare class ECVersion {
10
10
  private _read;
@@ -17,7 +17,7 @@ export declare class ECVersion {
17
17
  */
18
18
  static readonly NO_VERSION: ECVersion;
19
19
  /**
20
- * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
20
+ * The constructor will throw an ECSchemaError if any of the parameters below are above the threshold.
21
21
  * @param read Can support up to 999.
22
22
  * @param write Can support up to 999.
23
23
  * @param minor Can support up to 9999999.
@@ -47,11 +47,11 @@ export declare class ECVersion {
47
47
  }
48
48
  /**
49
49
  * The SchemaKey contains a Schemas name and version.
50
- * @beta
50
+ * @public @preview
51
51
  */
52
52
  export declare class SchemaKey {
53
53
  private _name;
54
- protected _version: ECVersion;
54
+ private _version;
55
55
  constructor(name: string, version: ECVersion);
56
56
  constructor(name: string, readVersion?: number, writeVersion?: number, minorVersion?: number);
57
57
  get version(): ECVersion;
@@ -96,11 +96,11 @@ export declare class SchemaKey {
96
96
  }
97
97
  /**
98
98
  * The SchemaItemKey contains a SchemaItem's name and SchemaKey.
99
- * @beta
99
+ * @public @preview
100
100
  */
101
101
  export declare class SchemaItemKey {
102
102
  private _name;
103
- protected _schemaKey: SchemaKey;
103
+ private _schemaKey;
104
104
  constructor(name: string, schema: SchemaKey);
105
105
  get schema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gBAElB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;IAK3C,IAAW,SAAS,cAA8B;IAClD,IAAW,IAAI,WAA8B;IAE7C,IAAW,UAAU,WAAkC;IAEvD,2DAA2D;IAC3D,IAAW,QAAQ,WAAgD;IAEnE;;;OAGG;IAEI,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO;IAUpC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAK9C"}
@@ -6,10 +6,10 @@
6
6
  * @module Metadata
7
7
  */
8
8
  import { SchemaMatchType } from "./ECObjects";
9
- import { ECObjectsError, ECObjectsStatus } from "./Exception";
9
+ import { ECSchemaError, ECSchemaStatus } from "./Exception";
10
10
  import { ECName } from "./ECName";
11
11
  /**
12
- * @beta
12
+ * @public @preview
13
13
  */
14
14
  export class ECVersion {
15
15
  _read = 0;
@@ -22,7 +22,7 @@ export class ECVersion {
22
22
  */
23
23
  static NO_VERSION = new ECVersion(0, 0, 0);
24
24
  /**
25
- * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
25
+ * The constructor will throw an ECSchemaError if any of the parameters below are above the threshold.
26
26
  * @param read Can support up to 999.
27
27
  * @param write Can support up to 999.
28
28
  * @param minor Can support up to 9999999.
@@ -36,7 +36,7 @@ export class ECVersion {
36
36
  if (undefined !== minor)
37
37
  this._minor = minor;
38
38
  if (this._read > 999 || this._read < 0 || this._write > 999 || this._write < 0 || this._minor > 9999999 || this._minor < 0)
39
- throw new ECObjectsError(ECObjectsStatus.InvalidECVersion);
39
+ throw new ECSchemaError(ECSchemaStatus.InvalidECVersion);
40
40
  }
41
41
  get read() { return this._read; }
42
42
  get write() { return this._write; }
@@ -61,11 +61,11 @@ export class ECVersion {
61
61
  static fromString(versionString) {
62
62
  const [read, write, minor] = versionString.split(".");
63
63
  if (!read)
64
- throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);
64
+ throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);
65
65
  if (!write)
66
- throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The write version is missing from version string, ${versionString}`);
66
+ throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The write version is missing from version string, ${versionString}`);
67
67
  if (!minor)
68
- throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);
68
+ throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);
69
69
  return new ECVersion(+read, +write, +minor);
70
70
  }
71
71
  /**
@@ -83,7 +83,7 @@ export class ECVersion {
83
83
  }
84
84
  /**
85
85
  * The SchemaKey contains a Schemas name and version.
86
- * @beta
86
+ * @public @preview
87
87
  */
88
88
  export class SchemaKey {
89
89
  _name;
@@ -109,7 +109,7 @@ export class SchemaKey {
109
109
  static parseString(fullName) {
110
110
  const keyPieces = fullName.split(".");
111
111
  if (keyPieces.length !== 4)
112
- throw new ECObjectsError(ECObjectsStatus.InvalidECName);
112
+ throw new ECSchemaError(ECSchemaStatus.InvalidECName);
113
113
  const schemaName = keyPieces[0];
114
114
  const readVer = Number(keyPieces[1]);
115
115
  const writeVer = Number(keyPieces[2]);
@@ -185,7 +185,7 @@ export class SchemaKey {
185
185
  }
186
186
  /**
187
187
  * The SchemaItemKey contains a SchemaItem's name and SchemaKey.
188
- * @beta
188
+ * @public @preview
189
189
  */
190
190
  export class SchemaItemKey {
191
191
  _name;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaKey.js","sourceRoot":"","sources":["../../src/SchemaKey.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;GAEG;AACH,MAAM,OAAO,SAAS;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AAI,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,KAAK,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAClD,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAE7C,IAAW,UAAU,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvD,2DAA2D;IAC3D,IAAW,QAAQ,KAAK,OAAO,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAEnE;;;OAGG;IACH,iCAAiC;IAC1B,OAAO,CAAC,GAAkB;QAC/B,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;YACxB,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,MAAM,CAAC;YAChE,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,eAAe,CAAC,IAAY;QACjC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9E,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,OAAO,aAAa,SAAS,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC;QACpG,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { SchemaKeyProps } from \"./Deserialization/JsonProps\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\nimport { ECName } from \"./ECName\";\n\n/**\n * @beta\n */\nexport class ECVersion {\n private _read: number = 0;\n private _write: number = 0;\n private _minor: number = 0;\n\n /**\n * Using a version with all zero is invalid\n * for a schema, but it can be used to indicate\n * \"no version has been specified\" when locating things\n */\n public static readonly NO_VERSION = new ECVersion(0, 0, 0);\n\n /**\n * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.\n * @param read Can support up to 999.\n * @param write Can support up to 999.\n * @param minor Can support up to 9999999.\n *\n */\n constructor(read?: number, write?: number, minor?: number) {\n if (undefined !== read)\n this._read = read;\n if (undefined !== write)\n this._write = write;\n if (undefined !== minor)\n this._minor = minor;\n\n if (this._read > 999 || this._read < 0 || this._write > 999 || this._write < 0 || this._minor > 9999999 || this._minor < 0)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion);\n }\n\n public get read() { return this._read; }\n public get write() { return this._write; }\n public get minor() { return this._minor; }\n\n /**\n * Creates a string, in the format 'RR.ww.mm', representing this ECVersion.\n * @note The default is to pad with zeroes.\n * @param padZeroes If true, the returned string will strictly follow `RR.ww.mm` and add leading zeroes if necessary.\n */\n public toString(padZeroes: boolean = true): string {\n if (!padZeroes)\n return `${this.read}.${this.write}.${this.minor}`;\n\n const padWithZeroes = (num: number) => {\n return (num < 10 ? \"0\" : \"\") + num;\n };\n\n return `${padWithZeroes(this.read)}.${padWithZeroes(this.write)}.${padWithZeroes(this.minor)}`;\n }\n\n /**\n * Given a valid version string the\n * @param versionString A valid version string of the format, 'RR.ww.mm'.\n */\n public static fromString(versionString: string): ECVersion {\n const [read, write, minor] = versionString.split(\".\");\n if (!read)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);\n\n if (!write)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The write version is missing from version string, ${versionString}`);\n\n if (!minor)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);\n\n return new ECVersion(+read, +write, +minor);\n }\n\n /**\n * Compares two schema versions.\n * @param rhs The schema to compare.\n * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.\n */\n public compare(rhv: ECVersion): number {\n if (this.read !== rhv.read)\n return this.read - rhv.read;\n\n if (this.write !== rhv.write)\n return this.write - rhv.write;\n\n return this.minor - rhv.minor;\n }\n}\n\n/**\n * The SchemaKey contains a Schemas name and version.\n * @beta\n */\nexport class SchemaKey {\n private _name: ECName;\n protected _version: ECVersion;\n // public checksum: number;\n // TODO: need to add a checksum\n\n constructor(name: string, version: ECVersion);\n constructor(name: string, readVersion?: number, writeVersion?: number, minorVersion?: number);\n constructor(name: string, readOrVersion?: number | ECVersion, writeVersion?: number, minorVersion?: number) {\n this._name = new ECName(name);\n if (readOrVersion !== undefined && typeof (readOrVersion) !== \"number\")\n this._version = readOrVersion;\n else\n this._version = new ECVersion(readOrVersion, writeVersion, minorVersion);\n }\n\n public get version() { return this._version; }\n public get name() { return this._name.name; }\n public get readVersion() { return this.version.read; }\n public get writeVersion() { return this.version.write; }\n public get minorVersion() { return this.version.minor; }\n\n /**\n * Creates a string, in the format 'RR.ww.mm', representing this SchemaKey.\n * @note The default is to pad the full name with zeroes.\n * @param padZeroes If true, the returned string will strictly follow `Name.RR.ww.mm` and add leading zeroes if necessary.\n */\n public toString(padZeroes: boolean = true) { return `${this.name}.${this.version.toString(padZeroes)}`; }\n\n public static parseString(fullName: string) {\n const keyPieces = fullName.split(\".\");\n if (keyPieces.length !== 4)\n throw new ECObjectsError(ECObjectsStatus.InvalidECName);\n\n const schemaName = keyPieces[0];\n const readVer = Number(keyPieces[1]);\n const writeVer = Number(keyPieces[2]);\n const minorVer = Number(keyPieces[3]);\n return new SchemaKey(schemaName, new ECVersion(readVer, writeVer, minorVer));\n }\n\n /**\n * Compares two schema names, case-insensitive.\n * @return True if they match; otherwise, false.\n */\n public compareByName(rhs: SchemaKey | string | undefined): boolean {\n if (undefined === rhs)\n return false;\n\n if (typeof (rhs) === \"string\")\n return rhs.toLowerCase() === this.name.toLowerCase();\n\n return rhs.name.toLowerCase() === this.name.toLowerCase();\n }\n\n /**\n * Compares two schema versions.\n * @param rhs The schema to compare.\n * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.\n */\n public compareByVersion(rhs: SchemaKey): number {\n return this.version.compare(rhs.version);\n }\n\n /**\n *\n * @param rhs The SchemaKey to compare with\n * @param matchType The match type to use for comparison.\n */\n public matches(rhs: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Exact): boolean {\n switch (matchType) {\n case SchemaMatchType.Identical:\n case SchemaMatchType.Exact:\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\n this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;\n case SchemaMatchType.LatestReadCompatible:\n if (!this.compareByName(rhs.name))\n return false;\n\n if (rhs.readVersion !== this.readVersion)\n return false;\n\n if (this.writeVersion === rhs.writeVersion)\n return this.minorVersion >= rhs.minorVersion;\n\n return this.writeVersion > rhs.writeVersion;\n case SchemaMatchType.LatestWriteCompatible:\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\n this.writeVersion === rhs.writeVersion && this.minorVersion >= rhs.minorVersion;\n case SchemaMatchType.Latest:\n return this.compareByName(rhs.name);\n default:\n return false;\n }\n }\n\n /**\n * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.\n * @param props SchemaKeyProps\n * @returns A SchemaKey object.\n */\n public static fromJSON(props: SchemaKeyProps): SchemaKey {\n return new SchemaKey(props.name, props.read, props.write, props.minor);\n }\n\n /**\n * Save this SchemaKey's properties to an object for serializing to JSON.\n */\n public toJSON(): SchemaKeyProps {\n return {\n name: this.name,\n read: this.readVersion,\n write: this.writeVersion,\n minor: this.minorVersion,\n };\n }\n}\n\n/**\n * The SchemaItemKey contains a SchemaItem's name and SchemaKey.\n * @beta\n */\nexport class SchemaItemKey {\n private _name: ECName;\n protected _schemaKey: SchemaKey;\n\n constructor(name: string, schema: SchemaKey) {\n this._name = new ECName(name);\n this._schemaKey = schema;\n }\n\n public get schemaKey() { return this._schemaKey; }\n public get name() { return this._name.name; }\n\n public get schemaName() { return this.schemaKey.name; }\n\n /** Returns the name in the format, {schemaName}.{name}. */\n public get fullName() { return `${this.schemaName}.${this.name}`; }\n\n /**\n * Checks whether this SchemaItemKey matches the one provided.\n * @param rhs The SchemaItemKey to compare to this.\n */\n // TODO: Need to add a match type\n public matches(rhs: SchemaItemKey): boolean {\n if (rhs.name !== this.name)\n return false;\n\n if (!rhs.schemaKey.matches(this.schemaKey, SchemaMatchType.Latest))\n return false;\n\n return true;\n }\n\n public matchesFullName(name: string): boolean {\n const schemaVersion = this.schemaKey.version.toString().replace(/\\./g, \"\\\\.\");\n const fullNameRegex = new RegExp(`^${this.schemaName}(\\\\.${schemaVersion})?[.:]${this.name}$`, \"i\");\n return fullNameRegex.test(name);\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaKey.js","sourceRoot":"","sources":["../../src/SchemaKey.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;GAEG;AACH,MAAM,OAAO,SAAS;IACZ,KAAK,GAAW,CAAC,CAAC;IAClB,MAAM,GAAW,CAAC,CAAC;IACnB,MAAM,GAAW,CAAC,CAAC;IAE3B;;;;OAIG;IACI,MAAM,CAAU,UAAU,GAAG,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE3D;;;;;;OAMG;IACH,YAAY,IAAa,EAAE,KAAc,EAAE,KAA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AK,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvD,2DAA2D;IAC3D,IAAW,QAAQ,KAAK,OAAO,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAEnE;;;OAGG;IACH,iCAAiC;IAC1B,OAAO,CAAC,GAAkB;QAC/B,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;YACxB,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,MAAM,CAAC;YAChE,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,eAAe,CAAC,IAAY;QACjC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9E,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,OAAO,aAAa,SAAS,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC;QACpG,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { SchemaKeyProps } from \"./Deserialization/JsonProps\";\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\r\nimport { ECName } from \"./ECName\";\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport class ECVersion {\r\n private _read: number = 0;\r\n private _write: number = 0;\r\n private _minor: number = 0;\r\n\r\n /**\r\n * Using a version with all zero is invalid\r\n * for a schema, but it can be used to indicate\r\n * \"no version has been specified\" when locating things\r\n */\r\n public static readonly NO_VERSION = new ECVersion(0, 0, 0);\r\n\r\n /**\r\n * The constructor will throw an ECSchemaError if any of the parameters below are above the threshold.\r\n * @param read Can support up to 999.\r\n * @param write Can support up to 999.\r\n * @param minor Can support up to 9999999.\r\n *\r\n */\r\n constructor(read?: number, write?: number, minor?: number) {\r\n if (undefined !== read)\r\n this._read = read;\r\n if (undefined !== write)\r\n this._write = write;\r\n if (undefined !== minor)\r\n this._minor = minor;\r\n\r\n if (this._read > 999 || this._read < 0 || this._write > 999 || this._write < 0 || this._minor > 9999999 || this._minor < 0)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECVersion);\r\n }\r\n\r\n public get read() { return this._read; }\r\n public get write() { return this._write; }\r\n public get minor() { return this._minor; }\r\n\r\n /**\r\n * Creates a string, in the format 'RR.ww.mm', representing this ECVersion.\r\n * @note The default is to pad with zeroes.\r\n * @param padZeroes If true, the returned string will strictly follow `RR.ww.mm` and add leading zeroes if necessary.\r\n */\r\n public toString(padZeroes: boolean = true): string {\r\n if (!padZeroes)\r\n return `${this.read}.${this.write}.${this.minor}`;\r\n\r\n const padWithZeroes = (num: number) => {\r\n return (num < 10 ? \"0\" : \"\") + num;\r\n };\r\n\r\n return `${padWithZeroes(this.read)}.${padWithZeroes(this.write)}.${padWithZeroes(this.minor)}`;\r\n }\r\n\r\n /**\r\n * Given a valid version string the\r\n * @param versionString A valid version string of the format, 'RR.ww.mm'.\r\n */\r\n public static fromString(versionString: string): ECVersion {\r\n const [read, write, minor] = versionString.split(\".\");\r\n if (!read)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);\r\n\r\n if (!write)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The write version is missing from version string, ${versionString}`);\r\n\r\n if (!minor)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);\r\n\r\n return new ECVersion(+read, +write, +minor);\r\n }\r\n\r\n /**\r\n * Compares two schema versions.\r\n * @param rhs The schema to compare.\r\n * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.\r\n */\r\n public compare(rhv: ECVersion): number {\r\n if (this.read !== rhv.read)\r\n return this.read - rhv.read;\r\n\r\n if (this.write !== rhv.write)\r\n return this.write - rhv.write;\r\n\r\n return this.minor - rhv.minor;\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaKey contains a Schemas name and version.\r\n * @public @preview\r\n */\r\nexport class SchemaKey {\r\n private _name: ECName;\r\n private _version: ECVersion;\r\n // public checksum: number;\r\n // TODO: need to add a checksum\r\n\r\n constructor(name: string, version: ECVersion);\r\n constructor(name: string, readVersion?: number, writeVersion?: number, minorVersion?: number);\r\n constructor(name: string, readOrVersion?: number | ECVersion, writeVersion?: number, minorVersion?: number) {\r\n this._name = new ECName(name);\r\n if (readOrVersion !== undefined && typeof (readOrVersion) !== \"number\")\r\n this._version = readOrVersion;\r\n else\r\n this._version = new ECVersion(readOrVersion, writeVersion, minorVersion);\r\n }\r\n\r\n public get version() { return this._version; }\r\n public get name() { return this._name.name; }\r\n public get readVersion() { return this.version.read; }\r\n public get writeVersion() { return this.version.write; }\r\n public get minorVersion() { return this.version.minor; }\r\n\r\n /**\r\n * Creates a string, in the format 'RR.ww.mm', representing this SchemaKey.\r\n * @note The default is to pad the full name with zeroes.\r\n * @param padZeroes If true, the returned string will strictly follow `Name.RR.ww.mm` and add leading zeroes if necessary.\r\n */\r\n public toString(padZeroes: boolean = true) { return `${this.name}.${this.version.toString(padZeroes)}`; }\r\n\r\n public static parseString(fullName: string) {\r\n const keyPieces = fullName.split(\".\");\r\n if (keyPieces.length !== 4)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECName);\r\n\r\n const schemaName = keyPieces[0];\r\n const readVer = Number(keyPieces[1]);\r\n const writeVer = Number(keyPieces[2]);\r\n const minorVer = Number(keyPieces[3]);\r\n return new SchemaKey(schemaName, new ECVersion(readVer, writeVer, minorVer));\r\n }\r\n\r\n /**\r\n * Compares two schema names, case-insensitive.\r\n * @return True if they match; otherwise, false.\r\n */\r\n public compareByName(rhs: SchemaKey | string | undefined): boolean {\r\n if (undefined === rhs)\r\n return false;\r\n\r\n if (typeof (rhs) === \"string\")\r\n return rhs.toLowerCase() === this.name.toLowerCase();\r\n\r\n return rhs.name.toLowerCase() === this.name.toLowerCase();\r\n }\r\n\r\n /**\r\n * Compares two schema versions.\r\n * @param rhs The schema to compare.\r\n * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.\r\n */\r\n public compareByVersion(rhs: SchemaKey): number {\r\n return this.version.compare(rhs.version);\r\n }\r\n\r\n /**\r\n *\r\n * @param rhs The SchemaKey to compare with\r\n * @param matchType The match type to use for comparison.\r\n */\r\n public matches(rhs: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Exact): boolean {\r\n switch (matchType) {\r\n case SchemaMatchType.Identical:\r\n case SchemaMatchType.Exact:\r\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\r\n this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;\r\n case SchemaMatchType.LatestReadCompatible:\r\n if (!this.compareByName(rhs.name))\r\n return false;\r\n\r\n if (rhs.readVersion !== this.readVersion)\r\n return false;\r\n\r\n if (this.writeVersion === rhs.writeVersion)\r\n return this.minorVersion >= rhs.minorVersion;\r\n\r\n return this.writeVersion > rhs.writeVersion;\r\n case SchemaMatchType.LatestWriteCompatible:\r\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\r\n this.writeVersion === rhs.writeVersion && this.minorVersion >= rhs.minorVersion;\r\n case SchemaMatchType.Latest:\r\n return this.compareByName(rhs.name);\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.\r\n * @param props SchemaKeyProps\r\n * @returns A SchemaKey object.\r\n */\r\n public static fromJSON(props: SchemaKeyProps): SchemaKey {\r\n return new SchemaKey(props.name, props.read, props.write, props.minor);\r\n }\r\n\r\n /**\r\n * Save this SchemaKey's properties to an object for serializing to JSON.\r\n */\r\n public toJSON(): SchemaKeyProps {\r\n return {\r\n name: this.name,\r\n read: this.readVersion,\r\n write: this.writeVersion,\r\n minor: this.minorVersion,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaItemKey contains a SchemaItem's name and SchemaKey.\r\n * @public @preview\r\n */\r\nexport class SchemaItemKey {\r\n private _name: ECName;\r\n private _schemaKey: SchemaKey;\r\n\r\n constructor(name: string, schema: SchemaKey) {\r\n this._name = new ECName(name);\r\n this._schemaKey = schema;\r\n }\r\n\r\n public get schemaKey() { return this._schemaKey; }\r\n public get name() { return this._name.name; }\r\n\r\n public get schemaName() { return this.schemaKey.name; }\r\n\r\n /** Returns the name in the format, {schemaName}.{name}. */\r\n public get fullName() { return `${this.schemaName}.${this.name}`; }\r\n\r\n /**\r\n * Checks whether this SchemaItemKey matches the one provided.\r\n * @param rhs The SchemaItemKey to compare to this.\r\n */\r\n // TODO: Need to add a match type\r\n public matches(rhs: SchemaItemKey): boolean {\r\n if (rhs.name !== this.name)\r\n return false;\r\n\r\n if (!rhs.schemaKey.matches(this.schemaKey, SchemaMatchType.Latest))\r\n return false;\r\n\r\n return true;\r\n }\r\n\r\n public matchesFullName(name: string): boolean {\r\n const schemaVersion = this.schemaKey.version.toString().replace(/\\./g, \"\\\\.\");\r\n const fullNameRegex = new RegExp(`^${this.schemaName}(\\\\.${schemaVersion})?[.:]${this.name}$`, \"i\");\r\n return fullNameRegex.test(name);\r\n }\r\n}\r\n"]}
@@ -11,19 +11,19 @@ import { SchemaPropsGetter } from "./SchemaJsonLocater";
11
11
  * ```ts
12
12
  * [[include:IModelSchemas.loadFromDb]]
13
13
  * ```
14
- * @beta
14
+ * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?
15
15
  */
16
16
  export declare class SchemaLoader {
17
17
  private _context;
18
18
  constructor(getSchema: SchemaPropsGetter);
19
19
  /** Get a schema by name
20
20
  * @param schemaName a string with the name of the schema to load.
21
- * @throws [ECObjectsError]($ecschema-metadata) if the schema is not found or cannot be loaded.
21
+ * @throws [ECSchemaError]($ecschema-metadata) if the schema is not found or cannot be loaded.
22
22
  */
23
23
  getSchema(schemaName: string): Schema;
24
24
  /** Attempts to get a schema by name
25
25
  * @param schemaName a string with the name of the schema to load.
26
- * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
26
+ * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.
27
27
  */
28
28
  tryGetSchema(schemaName: string): Schema | undefined;
29
29
  /** Gets the SchemaContext used by the loader. */
@@ -4,7 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { SchemaContext } from "./Context";
6
6
  import { SchemaMatchType } from "./ECObjects";
7
- import { ECObjectsError, ECObjectsStatus } from "./Exception";
7
+ import { ECSchemaError, ECSchemaStatus } from "./Exception";
8
8
  import { SchemaJsonLocater } from "./SchemaJsonLocater";
9
9
  import { ECVersion, SchemaKey } from "./SchemaKey";
10
10
  /**
@@ -17,7 +17,7 @@ import { ECVersion, SchemaKey } from "./SchemaKey";
17
17
  * ```ts
18
18
  * [[include:IModelSchemas.loadFromDb]]
19
19
  * ```
20
- * @beta
20
+ * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?
21
21
  */
22
22
  export class SchemaLoader {
23
23
  _context;
@@ -28,17 +28,17 @@ export class SchemaLoader {
28
28
  }
29
29
  /** Get a schema by name
30
30
  * @param schemaName a string with the name of the schema to load.
31
- * @throws [ECObjectsError]($ecschema-metadata) if the schema is not found or cannot be loaded.
31
+ * @throws [ECSchemaError]($ecschema-metadata) if the schema is not found or cannot be loaded.
32
32
  */
33
33
  getSchema(schemaName) {
34
34
  const schema = this.tryGetSchema(schemaName);
35
35
  if (!schema)
36
- throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `reading schema=${schemaName}`);
36
+ throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `reading schema=${schemaName}`);
37
37
  return schema;
38
38
  }
39
39
  /** Attempts to get a schema by name
40
40
  * @param schemaName a string with the name of the schema to load.
41
- * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
41
+ * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.
42
42
  */
43
43
  tryGetSchema(schemaName) {
44
44
  // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,YAAY;IACf,QAAQ,CAAgB;IAEhC,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,UAAkB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAEjG,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,UAAkB;QACpC,gGAAgG;QAChG,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { SchemaContext } from \"./Context\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\n\n/**\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\n *\n * ** Example **\n * ```ts\n * [[include:IModelSchemas.loadFromDb]]\n * ```\n * @beta\n */\nexport class SchemaLoader {\n private _context: SchemaContext;\n\n public constructor(getSchema: SchemaPropsGetter) {\n this._context = new SchemaContext();\n const locater = new SchemaJsonLocater(getSchema);\n this._context.addLocater(locater);\n }\n\n /** Get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECObjectsError]($ecschema-metadata) if the schema is not found or cannot be loaded.\n */\n public getSchema(schemaName: string): Schema {\n const schema = this.tryGetSchema(schemaName);\n if (!schema)\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\n\n return schema;\n }\n\n /** Attempts to get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public tryGetSchema(schemaName: string): Schema | undefined {\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\n return schema;\n }\n\n /** Gets the SchemaContext used by the loader. */\n public get context(): SchemaContext {\n return this._context;\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,YAAY;IACf,QAAQ,CAAgB;IAEhC,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,UAAkB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAE/F,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,UAAkB;QACpC,gGAAgG;QAChG,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { SchemaContext } from \"./Context\";\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\r\nimport { Schema } from \"./Metadata/Schema\";\r\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\r\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\r\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\r\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\r\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\r\n *\r\n * ** Example **\r\n * ```ts\r\n * [[include:IModelSchemas.loadFromDb]]\r\n * ```\r\n * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?\r\n */\r\nexport class SchemaLoader {\r\n private _context: SchemaContext;\r\n\r\n public constructor(getSchema: SchemaPropsGetter) {\r\n this._context = new SchemaContext();\r\n const locater = new SchemaJsonLocater(getSchema);\r\n this._context.addLocater(locater);\r\n }\r\n\r\n /** Get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [ECSchemaError]($ecschema-metadata) if the schema is not found or cannot be loaded.\r\n */\r\n public getSchema(schemaName: string): Schema {\r\n const schema = this.tryGetSchema(schemaName);\r\n if (!schema)\r\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\r\n\r\n return schema;\r\n }\r\n\r\n /** Attempts to get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public tryGetSchema(schemaName: string): Schema | undefined {\r\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\r\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\r\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema;\r\n }\r\n\r\n /** Gets the SchemaContext used by the loader. */\r\n public get context(): SchemaContext {\r\n return this._context;\r\n }\r\n}\r\n"]}
@@ -20,7 +20,7 @@ import { UnitSystem } from "./Metadata/UnitSystem";
20
20
  /**
21
21
  * Interface to allow schema traversal/deserialization workflows to visit
22
22
  * each part, item, class, etc. that exists in a given schema.
23
- * @beta
23
+ * @public @preview
24
24
  */
25
25
  export interface ISchemaPartVisitor {
26
26
  /**
@@ -240,7 +240,7 @@ export interface ISchemaPartVisitor {
240
240
  }
241
241
  /**
242
242
  * A helper class to call methods on the provided [[ISchemaPartVisitor]].
243
- * @beta
243
+ * @public @preview
244
244
  */
245
245
  export declare class SchemaPartVisitorDelegate {
246
246
  private _visitor;
@@ -12,7 +12,7 @@ function isCustomAttributeContainer(object) {
12
12
  }
13
13
  /**
14
14
  * A helper class to call methods on the provided [[ISchemaPartVisitor]].
15
- * @beta
15
+ * @public @preview
16
16
  */
17
17
  export class SchemaPartVisitorDelegate {
18
18
  _visitor;