@itwin/ecschema-metadata 5.0.0-dev.9 → 5.0.0-dev.92

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 (302) hide show
  1. package/CHANGELOG.md +51 -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 +83 -34
  7. package/lib/cjs/Context.d.ts.map +1 -1
  8. package/lib/cjs/Context.js +73 -23
  9. package/lib/cjs/Context.js.map +1 -1
  10. package/lib/cjs/DelayedPromise.js +6 -4
  11. package/lib/cjs/DelayedPromise.js.map +1 -1
  12. package/lib/cjs/Deserialization/AbstractParser.js +1 -0
  13. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  14. package/lib/cjs/Deserialization/Helper.d.ts +3 -3
  15. package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
  16. package/lib/cjs/Deserialization/Helper.js +8 -0
  17. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  18. package/lib/cjs/Deserialization/JsonParser.js +3 -0
  19. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  20. package/lib/cjs/Deserialization/JsonProps.d.ts +14 -0
  21. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  22. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  23. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  24. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  25. package/lib/cjs/Deserialization/XmlParser.js +11 -3
  26. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  27. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  28. package/lib/cjs/Deserialization/XmlSerializationUtils.js +2 -6
  29. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  30. package/lib/cjs/ECName.js +1 -0
  31. package/lib/cjs/ECName.js.map +1 -1
  32. package/lib/cjs/ECObjects.d.ts +21 -1
  33. package/lib/cjs/ECObjects.d.ts.map +1 -1
  34. package/lib/cjs/ECObjects.js +33 -2
  35. package/lib/cjs/ECObjects.js.map +1 -1
  36. package/lib/cjs/Exception.js +1 -0
  37. package/lib/cjs/Exception.js.map +1 -1
  38. package/lib/cjs/Interfaces.d.ts +10 -3
  39. package/lib/cjs/Interfaces.d.ts.map +1 -1
  40. package/lib/cjs/Interfaces.js.map +1 -1
  41. package/lib/cjs/Metadata/Class.d.ts +75 -16
  42. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  43. package/lib/cjs/Metadata/Class.js +168 -46
  44. package/lib/cjs/Metadata/Class.js.map +1 -1
  45. package/lib/cjs/Metadata/Constant.d.ts +14 -1
  46. package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
  47. package/lib/cjs/Metadata/Constant.js +27 -2
  48. package/lib/cjs/Metadata/Constant.js.map +1 -1
  49. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  50. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +16 -4
  51. package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
  52. package/lib/cjs/Metadata/CustomAttributeClass.js +22 -4
  53. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  54. package/lib/cjs/Metadata/EntityClass.d.ts +20 -8
  55. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  56. package/lib/cjs/Metadata/EntityClass.js +42 -22
  57. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  58. package/lib/cjs/Metadata/Enumeration.d.ts +14 -1
  59. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  60. package/lib/cjs/Metadata/Enumeration.js +22 -1
  61. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  62. package/lib/cjs/Metadata/Format.d.ts +41 -1
  63. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  64. package/lib/cjs/Metadata/Format.js +68 -3
  65. package/lib/cjs/Metadata/Format.js.map +1 -1
  66. package/lib/cjs/Metadata/InvertedUnit.d.ts +8 -3
  67. package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
  68. package/lib/cjs/Metadata/InvertedUnit.js +17 -6
  69. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  70. package/lib/cjs/Metadata/KindOfQuantity.d.ts +14 -3
  71. package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
  72. package/lib/cjs/Metadata/KindOfQuantity.js +43 -18
  73. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  74. package/lib/cjs/Metadata/Mixin.d.ts +15 -1
  75. package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
  76. package/lib/cjs/Metadata/Mixin.js +23 -2
  77. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  78. package/lib/cjs/Metadata/OverrideFormat.js +9 -0
  79. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  80. package/lib/cjs/Metadata/Phenomenon.d.ts +14 -1
  81. package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
  82. package/lib/cjs/Metadata/Phenomenon.js +22 -1
  83. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  84. package/lib/cjs/Metadata/Property.d.ts +5 -1
  85. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  86. package/lib/cjs/Metadata/Property.js +83 -28
  87. package/lib/cjs/Metadata/Property.js.map +1 -1
  88. package/lib/cjs/Metadata/PropertyCategory.d.ts +14 -1
  89. package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
  90. package/lib/cjs/Metadata/PropertyCategory.js +21 -1
  91. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  92. package/lib/cjs/Metadata/RelationshipClass.d.ts +15 -2
  93. package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
  94. package/lib/cjs/Metadata/RelationshipClass.js +47 -10
  95. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  96. package/lib/cjs/Metadata/Schema.d.ts +117 -13
  97. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  98. package/lib/cjs/Metadata/Schema.js +148 -70
  99. package/lib/cjs/Metadata/Schema.js.map +1 -1
  100. package/lib/cjs/Metadata/SchemaItem.d.ts +11 -2
  101. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  102. package/lib/cjs/Metadata/SchemaItem.js +12 -2
  103. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  104. package/lib/cjs/Metadata/Unit.d.ts +8 -1
  105. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  106. package/lib/cjs/Metadata/Unit.js +21 -3
  107. package/lib/cjs/Metadata/Unit.js.map +1 -1
  108. package/lib/cjs/Metadata/UnitSystem.d.ts +14 -3
  109. package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
  110. package/lib/cjs/Metadata/UnitSystem.js +21 -3
  111. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  112. package/lib/cjs/PropertyTypes.js.map +1 -1
  113. package/lib/cjs/SchemaJsonLocater.d.ts +3 -3
  114. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  115. package/lib/cjs/SchemaJsonLocater.js +3 -3
  116. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  117. package/lib/cjs/SchemaKey.d.ts +7 -1
  118. package/lib/cjs/SchemaKey.d.ts.map +1 -1
  119. package/lib/cjs/SchemaKey.js +13 -3
  120. package/lib/cjs/SchemaKey.js.map +1 -1
  121. package/lib/cjs/SchemaLoader.d.ts +2 -2
  122. package/lib/cjs/SchemaLoader.d.ts.map +1 -1
  123. package/lib/cjs/SchemaLoader.js +1 -0
  124. package/lib/cjs/SchemaLoader.js.map +1 -1
  125. package/lib/cjs/SchemaPartVisitorDelegate.js +1 -0
  126. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  127. package/lib/cjs/UnitConversion/Graph.js +69 -65
  128. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  129. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  130. package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
  131. package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
  132. package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
  133. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  134. package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
  135. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  136. package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
  137. package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
  138. package/lib/cjs/UnitConversion/UnitTree.js +11 -1
  139. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  140. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  141. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +8 -9
  142. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  143. package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
  144. package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
  145. package/lib/cjs/Validation/SchemaWalker.js +6 -4
  146. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  147. package/lib/cjs/ecschema-metadata.d.ts +1 -1
  148. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  149. package/lib/cjs/ecschema-metadata.js.map +1 -1
  150. package/lib/cjs/utils/SchemaGraph.js +2 -3
  151. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  152. package/lib/esm/Constants.d.ts +8 -0
  153. package/lib/esm/Constants.d.ts.map +1 -1
  154. package/lib/esm/Constants.js +29 -20
  155. package/lib/esm/Constants.js.map +1 -1
  156. package/lib/esm/Context.d.ts +83 -34
  157. package/lib/esm/Context.d.ts.map +1 -1
  158. package/lib/esm/Context.js +71 -21
  159. package/lib/esm/Context.js.map +1 -1
  160. package/lib/esm/DelayedPromise.js +6 -4
  161. package/lib/esm/DelayedPromise.js.map +1 -1
  162. package/lib/esm/Deserialization/AbstractParser.js +1 -0
  163. package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
  164. package/lib/esm/Deserialization/Helper.d.ts +3 -3
  165. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  166. package/lib/esm/Deserialization/Helper.js +8 -0
  167. package/lib/esm/Deserialization/Helper.js.map +1 -1
  168. package/lib/esm/Deserialization/JsonParser.js +3 -0
  169. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  170. package/lib/esm/Deserialization/JsonProps.d.ts +14 -0
  171. package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
  172. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  173. package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
  174. package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
  175. package/lib/esm/Deserialization/XmlParser.js +11 -3
  176. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  177. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  178. package/lib/esm/Deserialization/XmlSerializationUtils.js +2 -6
  179. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  180. package/lib/esm/ECName.js +1 -0
  181. package/lib/esm/ECName.js.map +1 -1
  182. package/lib/esm/ECObjects.d.ts +21 -1
  183. package/lib/esm/ECObjects.d.ts.map +1 -1
  184. package/lib/esm/ECObjects.js +31 -1
  185. package/lib/esm/ECObjects.js.map +1 -1
  186. package/lib/esm/Exception.js +1 -0
  187. package/lib/esm/Exception.js.map +1 -1
  188. package/lib/esm/Interfaces.d.ts +10 -3
  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 +75 -16
  192. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  193. package/lib/esm/Metadata/Class.js +169 -47
  194. package/lib/esm/Metadata/Class.js.map +1 -1
  195. package/lib/esm/Metadata/Constant.d.ts +14 -1
  196. package/lib/esm/Metadata/Constant.d.ts.map +1 -1
  197. package/lib/esm/Metadata/Constant.js +27 -2
  198. package/lib/esm/Metadata/Constant.js.map +1 -1
  199. package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
  200. package/lib/esm/Metadata/CustomAttributeClass.d.ts +16 -4
  201. package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
  202. package/lib/esm/Metadata/CustomAttributeClass.js +22 -4
  203. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  204. package/lib/esm/Metadata/EntityClass.d.ts +20 -8
  205. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  206. package/lib/esm/Metadata/EntityClass.js +42 -22
  207. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  208. package/lib/esm/Metadata/Enumeration.d.ts +14 -1
  209. package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
  210. package/lib/esm/Metadata/Enumeration.js +22 -1
  211. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  212. package/lib/esm/Metadata/Format.d.ts +41 -1
  213. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  214. package/lib/esm/Metadata/Format.js +68 -3
  215. package/lib/esm/Metadata/Format.js.map +1 -1
  216. package/lib/esm/Metadata/InvertedUnit.d.ts +8 -3
  217. package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
  218. package/lib/esm/Metadata/InvertedUnit.js +17 -6
  219. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  220. package/lib/esm/Metadata/KindOfQuantity.d.ts +14 -3
  221. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
  222. package/lib/esm/Metadata/KindOfQuantity.js +43 -18
  223. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  224. package/lib/esm/Metadata/Mixin.d.ts +15 -1
  225. package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
  226. package/lib/esm/Metadata/Mixin.js +24 -3
  227. package/lib/esm/Metadata/Mixin.js.map +1 -1
  228. package/lib/esm/Metadata/OverrideFormat.js +9 -0
  229. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  230. package/lib/esm/Metadata/Phenomenon.d.ts +14 -1
  231. package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
  232. package/lib/esm/Metadata/Phenomenon.js +22 -1
  233. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  234. package/lib/esm/Metadata/Property.d.ts +5 -1
  235. package/lib/esm/Metadata/Property.d.ts.map +1 -1
  236. package/lib/esm/Metadata/Property.js +84 -29
  237. package/lib/esm/Metadata/Property.js.map +1 -1
  238. package/lib/esm/Metadata/PropertyCategory.d.ts +14 -1
  239. package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
  240. package/lib/esm/Metadata/PropertyCategory.js +21 -1
  241. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  242. package/lib/esm/Metadata/RelationshipClass.d.ts +15 -2
  243. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
  244. package/lib/esm/Metadata/RelationshipClass.js +48 -11
  245. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  246. package/lib/esm/Metadata/Schema.d.ts +117 -13
  247. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  248. package/lib/esm/Metadata/Schema.js +148 -70
  249. package/lib/esm/Metadata/Schema.js.map +1 -1
  250. package/lib/esm/Metadata/SchemaItem.d.ts +11 -2
  251. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  252. package/lib/esm/Metadata/SchemaItem.js +13 -3
  253. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  254. package/lib/esm/Metadata/Unit.d.ts +8 -1
  255. package/lib/esm/Metadata/Unit.d.ts.map +1 -1
  256. package/lib/esm/Metadata/Unit.js +21 -3
  257. package/lib/esm/Metadata/Unit.js.map +1 -1
  258. package/lib/esm/Metadata/UnitSystem.d.ts +14 -3
  259. package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
  260. package/lib/esm/Metadata/UnitSystem.js +21 -3
  261. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  262. package/lib/esm/PropertyTypes.js.map +1 -1
  263. package/lib/esm/SchemaJsonLocater.d.ts +3 -3
  264. package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
  265. package/lib/esm/SchemaJsonLocater.js +3 -3
  266. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  267. package/lib/esm/SchemaKey.d.ts +7 -1
  268. package/lib/esm/SchemaKey.d.ts.map +1 -1
  269. package/lib/esm/SchemaKey.js +13 -3
  270. package/lib/esm/SchemaKey.js.map +1 -1
  271. package/lib/esm/SchemaLoader.d.ts +2 -2
  272. package/lib/esm/SchemaLoader.d.ts.map +1 -1
  273. package/lib/esm/SchemaLoader.js +1 -0
  274. package/lib/esm/SchemaLoader.js.map +1 -1
  275. package/lib/esm/SchemaPartVisitorDelegate.js +1 -0
  276. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  277. package/lib/esm/UnitConversion/Graph.js +69 -65
  278. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  279. package/lib/esm/UnitConversion/Parser.js.map +1 -1
  280. package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
  281. package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
  282. package/lib/esm/UnitConversion/UnitConversion.js +9 -7
  283. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  284. package/lib/esm/UnitConversion/UnitConverter.js +2 -0
  285. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  286. package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
  287. package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
  288. package/lib/esm/UnitConversion/UnitTree.js +11 -1
  289. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  290. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  291. package/lib/esm/UnitProvider/SchemaUnitProvider.js +8 -9
  292. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  293. package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
  294. package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
  295. package/lib/esm/Validation/SchemaWalker.js +6 -4
  296. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  297. package/lib/esm/ecschema-metadata.d.ts +1 -1
  298. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  299. package/lib/esm/ecschema-metadata.js.map +1 -1
  300. package/lib/esm/utils/SchemaGraph.js +2 -3
  301. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  302. package/package.json +14 -14
@@ -2,7 +2,7 @@
2
2
  * @module Metadata
3
3
  */
4
4
  import { SchemaItemProps } from "../Deserialization/JsonProps";
5
- import { SchemaItemType } from "../ECObjects";
5
+ import { SchemaItemType, SupportedSchemaItemType } from "../ECObjects";
6
6
  import { SchemaItemKey } from "../SchemaKey";
7
7
  import { Schema } from "./Schema";
8
8
  /**
@@ -10,7 +10,16 @@ import { Schema } from "./Schema";
10
10
  * @beta
11
11
  */
12
12
  export declare abstract class SchemaItem {
13
- readonly schemaItemType: SchemaItemType;
13
+ /**
14
+ * Get the type of item represented by this class
15
+ * @beta
16
+ */
17
+ static get schemaItemType(): SupportedSchemaItemType;
18
+ /**
19
+ * Get the type of item represented by this instance
20
+ * @beta
21
+ */
22
+ abstract get schemaItemType(): SchemaItemType;
14
23
  readonly schema: Schema;
15
24
  protected _key: SchemaItemKey;
16
25
  protected _description?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaItem.d.ts","sourceRoot":"","sources":["../../../src/Metadata/SchemaItem.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAA6B,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAa,aAAa,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO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;;MAEE;WACY,YAAY,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,UAAU;IAO7D;;;OAGG;IACH,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM;IAI9B;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,YAAY,EAAE,MAAM;IAI9C;;;OAGG;IACH,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM;CAG7C"}
@@ -8,15 +8,24 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.SchemaItem = void 0;
11
+ const Constants_1 = require("../Constants");
11
12
  const ECObjects_1 = require("../ECObjects");
12
13
  const Exception_1 = require("../Exception");
13
14
  const SchemaKey_1 = require("../SchemaKey");
14
- const SCHEMAURL3_2 = "https://dev.bentley.com/json_schemas/ec/32/schemaitem";
15
15
  /**
16
16
  * An abstract class that supplies all of the common parts of a SchemaItem.
17
17
  * @beta
18
18
  */
19
19
  class SchemaItem {
20
+ /**
21
+ * Get the type of item represented by this class
22
+ * @beta
23
+ */
24
+ static get schemaItemType() { return ECObjects_1.AbstractSchemaItemType.SchemaItem; }
25
+ schema;
26
+ _key;
27
+ _description;
28
+ _label;
20
29
  constructor(schema, name) {
21
30
  this._key = new SchemaKey_1.SchemaItemKey(name, schema.schemaKey);
22
31
  this.schema = schema;
@@ -35,7 +44,7 @@ class SchemaItem {
35
44
  toJSON(standalone = false, includeSchemaVersion = false) {
36
45
  const itemJson = {};
37
46
  if (standalone) {
38
- itemJson.$schema = SCHEMAURL3_2; // $schema is required
47
+ itemJson.$schema = Constants_1.ECSchemaNamespaceUris.SCHEMAITEMURL3_2; // $schema is required
39
48
  itemJson.schema = this.schema.name;
40
49
  itemJson.name = this.name; // name is required
41
50
  if (includeSchemaVersion) // check flag to see if we should output version
@@ -107,6 +116,7 @@ class SchemaItem {
107
116
  static equalByKey(thisSchemaItem, thatSchemaItemOrKey) {
108
117
  if (!thatSchemaItemOrKey)
109
118
  return true;
119
+ ECObjects_1.SchemaItemType.EntityClass;
110
120
  const key = SchemaItem.isSchemaItem(thatSchemaItemOrKey) ? thatSchemaItemOrKey.key : thatSchemaItemOrKey;
111
121
  return thisSchemaItem.key.matches(key);
112
122
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaItem.js","sourceRoot":"","sources":["../../../src/Metadata/SchemaItem.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,4CAAyE;AACzE,4CAA+D;AAC/D,4CAAwD;AAGxD,MAAM,YAAY,GAAG,uDAAuD,CAAC;AAE7E;;;GAGG;AACH,MAAsB,UAAU;IAO9B,YAAY,MAAc,EAAE,IAAY;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAa,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxG,IAAW,GAAG,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,IAAW,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,IAAW,WAAW,KAAK,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtD,wLAAwL;IACxL;;;;OAIG;IACI,MAAM,CAAC,aAAsB,KAAK,EAAE,uBAAgC,KAAK;QAC9E,MAAM,QAAQ,GAA6B,EAAE,CAAC;QAC9C,IAAI,UAAU,EAAE,CAAC;YACf,QAAQ,CAAC,OAAO,GAAG,YAAY,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AAM,UAAU,GAAG,MAAoB,CAAC;QAExC,OAAO,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS;eACtF,UAAU,CAAC,cAAc,KAAK,SAAS,CAAC;IACtD,CAAC;IAED;;;OAGG;IACO,OAAO,CAAC,IAAY;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAa,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACO,eAAe,CAAC,YAAoB;QAC5C,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;CACF;AAzJD,gCAyJC","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 { SchemaItemProps } from \"../Deserialization/JsonProps\";\r\nimport { SchemaItemType, schemaItemTypeToXmlString } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { ECVersion, SchemaItemKey } from \"../SchemaKey\";\r\nimport { Schema } from \"./Schema\";\r\n\r\nconst SCHEMAURL3_2 = \"https://dev.bentley.com/json_schemas/ec/32/schemaitem\";\r\n\r\n/**\r\n * An abstract class that supplies all of the common parts of a SchemaItem.\r\n * @beta\r\n */\r\nexport abstract class SchemaItem {\r\n public readonly schemaItemType!: SchemaItemType; // allow the derived classes to define their own schemaItemType\r\n public readonly schema: Schema;\r\n protected _key: SchemaItemKey;\r\n protected _description?: string;\r\n protected _label?: string;\r\n\r\n constructor(schema: Schema, name: string) {\r\n this._key = new SchemaItemKey(name, schema.schemaKey);\r\n this.schema = schema;\r\n }\r\n\r\n public get name() { return this.key.name; }\r\n public get fullName() { return this.key.schemaKey ? `${this.key.schemaName}.${this.name}` : this.name; }\r\n public get key() { return this._key; }\r\n public get label() { return this._label; }\r\n public get description() { return this._description; }\r\n\r\n // Proposal: Create protected setter methods for description and label? For UnitSystems as an example, where using createFromProps isn't that necessary and can just use basic create().\r\n /**\r\n * Save this SchemaItem's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false) {\r\n const itemJson: { [value: string]: any } = {};\r\n if (standalone) {\r\n itemJson.$schema = SCHEMAURL3_2; // $schema is required\r\n itemJson.schema = this.schema.name;\r\n itemJson.name = this.name; // name is required\r\n if (includeSchemaVersion) // check flag to see if we should output version\r\n itemJson.schemaVersion = this.key.schemaKey.version.toString();\r\n }\r\n itemJson.schemaItemType = this.schemaItemType;\r\n if (undefined !== this.label)\r\n itemJson.label = this.label;\r\n if (undefined !== this.description)\r\n itemJson.description = this.description;\r\n\r\n return itemJson as SchemaItemProps;\r\n }\r\n\r\n /** @internal */\r\n public async toXml(schemaXml: Document): Promise<Element> {\r\n const itemType = schemaItemTypeToXmlString(this.schemaItemType);\r\n const itemElement = schemaXml.createElement(itemType);\r\n itemElement.setAttribute(\"typeName\", this.name);\r\n if (undefined !== this.label)\r\n itemElement.setAttribute(\"displayLabel\", this.label);\r\n if (undefined !== this.description)\r\n itemElement.setAttribute(\"description\", this.description);\r\n\r\n // When all schema items support custom attributes they should be added here rather than in ECClass\r\n\r\n return itemElement;\r\n }\r\n\r\n public fromJSONSync(schemaItemProps: SchemaItemProps) {\r\n if (undefined !== schemaItemProps.label)\r\n this._label = schemaItemProps.label;\r\n\r\n this._description = schemaItemProps.description;\r\n\r\n if (undefined !== schemaItemProps.schema) {\r\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}.`);\r\n }\r\n\r\n if (undefined !== schemaItemProps.schemaVersion) {\r\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\r\n }\r\n }\r\n\r\n public async fromJSON(schemaItemProps: SchemaItemProps) {\r\n if (undefined !== schemaItemProps.label)\r\n this._label = schemaItemProps.label;\r\n\r\n this._description = schemaItemProps.description;\r\n\r\n if (undefined !== schemaItemProps.schema) {\r\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem ${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}`);\r\n }\r\n\r\n if (undefined !== schemaItemProps.schemaVersion) {\r\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\r\n }\r\n }\r\n\r\n /**\r\n * Parses the given full name, {schemaName}.{schemaItemName} or {schemaName}:{schemaItemName}, into two separate strings.\r\n * @note The schema name can be a schema alias.\r\n * @param fullName The full name to be parsed.\r\n * @returns A tuple of the parsed Schema name and Schema Item name. If the full name does not contain a '.' or ':', the second string in the tuple will returned the exact string pass in.\r\n */\r\n public static parseFullName(fullName: string): [string, string] {\r\n const matches = /^([a-zA-Z_]+[a-zA-Z0-9_]*(\\.\\d+\\.\\d+\\.\\d+)?)[.:]([a-zA-Z_]+[a-zA-Z0-9_]*)$/.exec(fullName);\r\n\r\n // The first match will be the full string match, the second three will be the three groups\r\n if (matches === null || matches.length !== 4)\r\n return [\"\", fullName];\r\n\r\n return [matches[1], matches[3]];\r\n }\r\n\r\n /**\r\n * Indicates if the two SchemaItem objects are equal by comparing their respective [[key]] properties.\r\n * @param thisSchemaItem The first SchemaItem.\r\n * @param thatSchemaItemOrKey The second SchemaItem or SchemaItemKey.\r\n */\r\n public static equalByKey(thisSchemaItem: SchemaItem, thatSchemaItemOrKey?: SchemaItem | SchemaItemKey): boolean {\r\n if (!thatSchemaItemOrKey)\r\n return true;\r\n\r\n const key = SchemaItem.isSchemaItem(thatSchemaItemOrKey) ? thatSchemaItemOrKey.key : thatSchemaItemOrKey;\r\n return thisSchemaItem.key.matches(key);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static isSchemaItem(object: any): object is SchemaItem {\r\n const schemaItem = object as SchemaItem;\r\n\r\n return schemaItem !== undefined && schemaItem.key !== undefined && schemaItem.schema !== undefined\r\n && schemaItem.schemaItemType !== undefined;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected setName(name: string) {\r\n this._key = new SchemaItemKey(name, this.schema.schemaKey);\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected setDisplayLabel(displayLabel: string) {\r\n this._label = displayLabel;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected setDescription(description: string) {\r\n this._description = description;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SchemaItem.js","sourceRoot":"","sources":["../../../src/Metadata/SchemaItem.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,4CAAqD;AAErD,4CAA0H;AAC1H,4CAA+D;AAC/D,4CAAwD;AAGxD;;;GAGG;AACH,MAAs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,CAAC;IACtD,CAAC;IAED;;;OAGG;IACO,OAAO,CAAC,IAAY;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAa,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACO,eAAe,CAAC,YAAoB;QAC5C,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;CACF;AAnKD,gCAmKC","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 { ECSchemaNamespaceUris } from \"../Constants\";\nimport { SchemaItemProps } from \"../Deserialization/JsonProps\";\nimport { AbstractSchemaItemType, SchemaItemType, schemaItemTypeToXmlString, SupportedSchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { ECVersion, SchemaItemKey } from \"../SchemaKey\";\nimport { Schema } from \"./Schema\";\n\n/**\n * An abstract class that supplies all of the common parts of a SchemaItem.\n * @beta\n */\nexport abstract class SchemaItem {\n /**\n * Get the type of item represented by this class\n * @beta\n */\n public static get schemaItemType(): SupportedSchemaItemType { return AbstractSchemaItemType.SchemaItem }\n\n /**\n * Get the type of item represented by this instance\n * @beta\n */\n public abstract get schemaItemType(): SchemaItemType;\n public readonly schema: Schema;\n protected _key: SchemaItemKey;\n protected _description?: string;\n protected _label?: string;\n\n constructor(schema: Schema, name: string) {\n this._key = new SchemaItemKey(name, schema.schemaKey);\n this.schema = schema;\n }\n\n public get name() { return this.key.name; }\n public get fullName() { return this.key.schemaKey ? `${this.key.schemaName}.${this.name}` : this.name; }\n public get key() { return this._key; }\n public get label() { return this._label; }\n public get description() { return this._description; }\n\n // Proposal: Create protected setter methods for description and label? For UnitSystems as an example, where using createFromProps isn't that necessary and can just use basic create().\n /**\n * Save this SchemaItem's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false) {\n const itemJson: { [value: string]: any } = {};\n if (standalone) {\n itemJson.$schema = ECSchemaNamespaceUris.SCHEMAITEMURL3_2; // $schema is required\n itemJson.schema = this.schema.name;\n itemJson.name = this.name; // name is required\n if (includeSchemaVersion) // check flag to see if we should output version\n itemJson.schemaVersion = this.key.schemaKey.version.toString();\n }\n itemJson.schemaItemType = this.schemaItemType;\n if (undefined !== this.label)\n itemJson.label = this.label;\n if (undefined !== this.description)\n itemJson.description = this.description;\n\n return itemJson as SchemaItemProps;\n }\n\n /** @internal */\n public async toXml(schemaXml: Document): Promise<Element> {\n const itemType = schemaItemTypeToXmlString(this.schemaItemType);\n const itemElement = schemaXml.createElement(itemType);\n itemElement.setAttribute(\"typeName\", this.name);\n if (undefined !== this.label)\n itemElement.setAttribute(\"displayLabel\", this.label);\n if (undefined !== this.description)\n itemElement.setAttribute(\"description\", this.description);\n\n // When all schema items support custom attributes they should be added here rather than in ECClass\n\n return itemElement;\n }\n\n public fromJSONSync(schemaItemProps: SchemaItemProps) {\n if (undefined !== schemaItemProps.label)\n this._label = schemaItemProps.label;\n\n this._description = schemaItemProps.description;\n\n if (undefined !== schemaItemProps.schema) {\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}.`);\n }\n\n if (undefined !== schemaItemProps.schemaVersion) {\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\n }\n }\n\n public async fromJSON(schemaItemProps: SchemaItemProps) {\n if (undefined !== schemaItemProps.label)\n this._label = schemaItemProps.label;\n\n this._description = schemaItemProps.description;\n\n if (undefined !== schemaItemProps.schema) {\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem ${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}`);\n }\n\n if (undefined !== schemaItemProps.schemaVersion) {\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\n }\n }\n\n /**\n * Parses the given full name, {schemaName}.{schemaItemName} or {schemaName}:{schemaItemName}, into two separate strings.\n * @note The schema name can be a schema alias.\n * @param fullName The full name to be parsed.\n * @returns A tuple of the parsed Schema name and Schema Item name. If the full name does not contain a '.' or ':', the second string in the tuple will returned the exact string pass in.\n */\n public static parseFullName(fullName: string): [string, string] {\n const matches = /^([a-zA-Z_]+[a-zA-Z0-9_]*(\\.\\d+\\.\\d+\\.\\d+)?)[.:]([a-zA-Z_]+[a-zA-Z0-9_]*)$/.exec(fullName);\n\n // The first match will be the full string match, the second three will be the three groups\n if (matches === null || matches.length !== 4)\n return [\"\", fullName];\n\n return [matches[1], matches[3]];\n }\n\n /**\n * Indicates if the two SchemaItem objects are equal by comparing their respective [[key]] properties.\n * @param thisSchemaItem The first SchemaItem.\n * @param thatSchemaItemOrKey The second SchemaItem or SchemaItemKey.\n */\n public static equalByKey(thisSchemaItem: SchemaItem, thatSchemaItemOrKey?: SchemaItem | SchemaItemKey): boolean {\n if (!thatSchemaItemOrKey)\n return true;\n SchemaItemType.EntityClass\n const key = SchemaItem.isSchemaItem(thatSchemaItemOrKey) ? thatSchemaItemOrKey.key : thatSchemaItemOrKey;\n return thisSchemaItem.key.matches(key);\n }\n\n /**\n * @internal\n */\n public static isSchemaItem(object: any): object is SchemaItem {\n const schemaItem = object as SchemaItem;\n\n return schemaItem !== undefined && schemaItem.key !== undefined && schemaItem.schema !== undefined\n && schemaItem.schemaItemType !== undefined;\n }\n\n /**\n * @alpha\n * Used for schema editing.\n */\n protected setName(name: string) {\n this._key = new SchemaItemKey(name, this.schema.schemaKey);\n }\n\n /**\n * @alpha\n * Used for schema editing.\n */\n protected setDisplayLabel(displayLabel: string) {\n this._label = displayLabel;\n }\n\n /**\n * @alpha\n * Used for schema editing.\n */\n protected setDescription(description: string) {\n this._description = description;\n }\n}\n\n"]}
@@ -12,7 +12,8 @@ import { SchemaItem } from "./SchemaItem";
12
12
  * @beta
13
13
  */
14
14
  export declare class Unit extends SchemaItem {
15
- readonly schemaItemType: SchemaItemType.Unit;
15
+ readonly schemaItemType: SchemaItemType;
16
+ static get schemaItemType(): SchemaItemType;
16
17
  protected _phenomenon?: LazyLoadedPhenomenon;
17
18
  protected _unitSystem?: LazyLoadedUnitSystem;
18
19
  protected _definition: string;
@@ -63,6 +64,12 @@ export declare class Unit extends SchemaItem {
63
64
  * Used for schema editing.
64
65
  */
65
66
  protected setDefinition(definition: string): Promise<void>;
67
+ /**
68
+ * Type assertion to check if the SchemaItem is of type Unit.
69
+ * @param item The SchemaItem to check.
70
+ * @returns The item cast to Unit if it is a Unit, undefined otherwise.
71
+ */
72
+ static assertIsUnit(item?: SchemaItem): asserts item is Unit;
66
73
  }
67
74
  /**
68
75
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"Unit.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Unit.ts"],"names":[],"mappings":"AAIA;;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oBAAoB;IAI9D;;;OAGG;cACa,aAAa,CAAC,UAAU,EAAE,MAAM;IAIhD;;;;OAIG;WACW,YAAY,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI;CAIpE;AACD;;;GAGG;AACH,8BAAsB,WAAY,SAAQ,IAAI;aACnB,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;aAC9D,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;aAC9D,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;aAChD,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -12,16 +12,25 @@ const DelayedPromise_1 = require("../DelayedPromise");
12
12
  const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtils");
13
13
  const ECObjects_1 = require("../ECObjects");
14
14
  const Exception_1 = require("../Exception");
15
+ const Phenomenon_1 = require("./Phenomenon");
15
16
  const SchemaItem_1 = require("./SchemaItem");
17
+ const UnitSystem_1 = require("./UnitSystem");
16
18
  /**
17
19
  * An abstract class that adds the ability to define Units and everything that goes with them, within an ECSchema as a
18
20
  * first-class concept is to allow the iModel to not be dependent on any hard-coded Units
19
21
  * @beta
20
22
  */
21
23
  class Unit extends SchemaItem_1.SchemaItem {
24
+ schemaItemType = Unit.schemaItemType;
25
+ static get schemaItemType() { return ECObjects_1.SchemaItemType.Unit; }
26
+ _phenomenon;
27
+ _unitSystem;
28
+ _definition;
29
+ _numerator;
30
+ _denominator;
31
+ _offset;
22
32
  constructor(schema, name) {
23
33
  super(schema, name);
24
- this.schemaItemType = ECObjects_1.SchemaItemType.Unit;
25
34
  this._definition = "";
26
35
  }
27
36
  get phenomenon() { return this._phenomenon; }
@@ -96,7 +105,7 @@ class Unit extends SchemaItem_1.SchemaItem {
96
105
  if (!phenomenonSchemaItemKey)
97
106
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);
98
107
  this._phenomenon = new DelayedPromise_1.DelayedPromiseWithProps(phenomenonSchemaItemKey, async () => {
99
- const phenom = await this.schema.lookupItem(phenomenonSchemaItemKey);
108
+ const phenom = await this.schema.lookupItem(phenomenonSchemaItemKey, Phenomenon_1.Phenomenon);
100
109
  if (undefined === phenom)
101
110
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);
102
111
  return phenom;
@@ -105,7 +114,7 @@ class Unit extends SchemaItem_1.SchemaItem {
105
114
  if (!unitSystemSchemaItemKey)
106
115
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);
107
116
  this._unitSystem = new DelayedPromise_1.DelayedPromiseWithProps(unitSystemSchemaItemKey, async () => {
108
- const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey);
117
+ const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem_1.UnitSystem);
109
118
  if (undefined === unitSystem)
110
119
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);
111
120
  return unitSystem;
@@ -151,6 +160,15 @@ class Unit extends SchemaItem_1.SchemaItem {
151
160
  async setDefinition(definition) {
152
161
  this._definition = definition;
153
162
  }
163
+ /**
164
+ * Type assertion to check if the SchemaItem is of type Unit.
165
+ * @param item The SchemaItem to check.
166
+ * @returns The item cast to Unit if it is a Unit, undefined otherwise.
167
+ */
168
+ static assertIsUnit(item) {
169
+ if (!this.isUnit(item))
170
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.Unit}' (Unit)`);
171
+ }
154
172
  }
155
173
  exports.Unit = Unit;
156
174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,yCAAyC,CAAC,CAAC;aACrH,IAAI,IAAI,CAAC,WAAW,KAAK,EAAE;YAC9B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC,UAAU,CAAC;QAE1C,IAAI,SAAS,KAAK,SAAS,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,SAAS,CAAC,SAAS,KAAK,IAAI,CAAC,UAAU;gBACzC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,SAAS,CAAC;QAC1C,CAAC;QAED,IAAI,SAAS,KAAK,SAAS,CAAC,WAAW,EAAE,CAAC;YACxC,IAAI,SAAS,CAAC,WAAW,KAAK,IAAI,CAAC,YAAY;gBAC7C,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC;QAC9C,CAAC;QAED,IAAI,SAAS,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;YACnC,IAAI,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO;gBACnC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC;QACpC,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,SAA8B;QAC3D,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,CAAC,UAAgC;QAC5D,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,CAAC,UAAgC;QAC5D,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,CAAC,UAAkB;QAC9C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;CACF;AApKD,oBAoKC;AACD;;;GAGG;AACH,MAAsB,WAAY,SAAQ,IAAI;CAK7C;AALD,kCAKC","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 { DelayedPromiseWithProps } from \"../DelayedPromise\";\r\nimport { SchemaItemUnitProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedPhenomenon, LazyLoadedUnitSystem } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { Phenomenon } from \"./Phenomenon\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\nimport { UnitSystem } from \"./UnitSystem\";\r\n\r\n/**\r\n * An abstract class that adds the ability to define Units and everything that goes with them, within an ECSchema as a\r\n * first-class concept is to allow the iModel to not be dependent on any hard-coded Units\r\n * @beta\r\n */\r\nexport class Unit extends SchemaItem {\r\n public override readonly schemaItemType!: SchemaItemType.Unit;\r\n protected _phenomenon?: LazyLoadedPhenomenon;\r\n protected _unitSystem?: LazyLoadedUnitSystem;\r\n protected _definition: string;\r\n protected _numerator?: number;\r\n protected _denominator?: number;\r\n protected _offset?: number;\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this.schemaItemType = SchemaItemType.Unit;\r\n this._definition = \"\";\r\n }\r\n\r\n public get phenomenon(): LazyLoadedPhenomenon | undefined { return this._phenomenon; }\r\n public get unitSystem(): LazyLoadedUnitSystem | undefined { return this._unitSystem; }\r\n public get definition(): string { return this._definition; }\r\n public get numerator(): number { return this._numerator ?? 1.0; }\r\n public get offset(): number { return this._offset ?? 0.0; }\r\n public get denominator(): number { return this._denominator ?? 1.0; }\r\n public get hasNumerator(): boolean { return (this._numerator !== undefined); }\r\n public get hasOffset(): boolean { return (this._offset !== undefined); }\r\n public get hasDenominator(): boolean { return (this._denominator !== undefined); }\r\n\r\n /**\r\n * Returns true if a conversion can be calculated between the input units\r\n * @alpha\r\n */\r\n public static async areCompatible(unitA: Unit, unitB: Unit): Promise<boolean> {\r\n const unitAPhenomenon = await unitA.phenomenon;\r\n const unitBPhenomenon = await unitB.phenomenon;\r\n\r\n if (!unitAPhenomenon || !unitBPhenomenon || !unitAPhenomenon.key.matches(unitBPhenomenon.key))\r\n return false;\r\n return true;\r\n }\r\n\r\n /**\r\n * @alpha\r\n */\r\n public static isUnit(object: any): object is Unit {\r\n return SchemaItem.isSchemaItem(object) && object.schemaItemType === SchemaItemType.Unit;\r\n }\r\n\r\n /**\r\n * Save this Unit's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): SchemaItemUnitProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.phenomenon = this.phenomenon!.fullName;\r\n schemaJson.unitSystem = this.unitSystem!.fullName;\r\n schemaJson.definition = this.definition;\r\n if (this.hasNumerator)\r\n schemaJson.numerator = this.numerator;\r\n if (this.hasDenominator)\r\n schemaJson.denominator = this.denominator;\r\n if (this.hasOffset)\r\n schemaJson.offset = this.offset;\r\n return schemaJson;\r\n }\r\n\r\n /** @internal */\r\n public override async toXml(schemaXml: Document): Promise<Element> {\r\n const itemElement = await super.toXml(schemaXml);\r\n\r\n const phenomenon = await this.phenomenon;\r\n if (undefined !== phenomenon) {\r\n const phenomenonName = XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);\r\n itemElement.setAttribute(\"phenomenon\", phenomenonName);\r\n }\r\n\r\n const unitSystem = await this.unitSystem;\r\n if (undefined !== unitSystem) {\r\n const unitSystemName = XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);\r\n itemElement.setAttribute(\"unitSystem\", unitSystemName);\r\n }\r\n\r\n itemElement.setAttribute(\"definition\", this.definition);\r\n if (this.hasNumerator)\r\n itemElement.setAttribute(\"numerator\", this.numerator.toString());\r\n if (this.hasDenominator)\r\n itemElement.setAttribute(\"denominator\", this.denominator.toString());\r\n if (this.hasOffset)\r\n itemElement.setAttribute(\"offset\", this.offset.toString());\r\n\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(unitProps: SchemaItemUnitProps) {\r\n super.fromJSONSync(unitProps);\r\n\r\n const phenomenonSchemaItemKey = this.schema.getSchemaItemKey(unitProps.phenomenon);\r\n if (!phenomenonSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);\r\n this._phenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenonSchemaItemKey,\r\n async () => {\r\n const phenom = await this.schema.lookupItem<Phenomenon>(phenomenonSchemaItemKey);\r\n if (undefined === phenom)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);\r\n return phenom;\r\n });\r\n\r\n const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(unitProps.unitSystem);\r\n if (!unitSystemSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);\r\n this._unitSystem = new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemSchemaItemKey,\r\n async () => {\r\n const unitSystem = await this.schema.lookupItem<UnitSystem>(unitSystemSchemaItemKey);\r\n if (undefined === unitSystem)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);\r\n return unitSystem;\r\n });\r\n\r\n if (this._definition !== \"\" && unitProps.definition.toLowerCase() !== this._definition.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Unit ${this.name} has an invalid 'definition' attribute.`);\r\n else if (this._definition === \"\")\r\n this._definition = unitProps.definition;\r\n\r\n if (undefined !== unitProps.numerator) {\r\n if (unitProps.numerator !== this._numerator)\r\n this._numerator = unitProps.numerator;\r\n }\r\n\r\n if (undefined !== unitProps.denominator) {\r\n if (unitProps.denominator !== this._denominator)\r\n this._denominator = unitProps.denominator;\r\n }\r\n\r\n if (undefined !== unitProps.offset) {\r\n if (unitProps.offset !== this._offset)\r\n this._offset = unitProps.offset;\r\n }\r\n }\r\n\r\n public override async fromJSON(unitProps: SchemaItemUnitProps) {\r\n this.fromJSONSync(unitProps);\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setPhenomenon(phenomenon: LazyLoadedPhenomenon) {\r\n this._phenomenon = phenomenon;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setUnitSystem(unitSystem: LazyLoadedUnitSystem) {\r\n this._unitSystem = unitSystem;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setDefinition(definition: string) {\r\n this._definition = definition;\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableUnit extends Unit {\r\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): Promise<void>;\r\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): Promise<void>;\r\n public abstract override setDefinition(definition: string): Promise<void>;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"Unit.js","sourceRoot":"","sources":["../../../src/Metadata/Unit.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA+D;AAG/D,6CAA0C;AAE1C,6CAA0C;AAC1C,6CAA0C;AAE1C;;;;GAIG;AACH,MAAa,IAAK,SAAQ,uBAAU;IACT,cAAc,GAAG,IAAI,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8KC;AACD;;;GAGG;AACH,MAAsB,WAAY,SAAQ,IAAI;CAK7C;AALD,kCAKC","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 { DelayedPromiseWithProps } from \"../DelayedPromise\";\r\nimport { SchemaItemUnitProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedPhenomenon, LazyLoadedUnitSystem } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { Phenomenon } from \"./Phenomenon\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\nimport { UnitSystem } from \"./UnitSystem\";\r\n\r\n/**\r\n * An abstract class that adds the ability to define Units and everything that goes with them, within an ECSchema as a\r\n * first-class concept is to allow the iModel to not be dependent on any hard-coded Units\r\n * @beta\r\n */\r\nexport class Unit extends SchemaItem {\r\n public override readonly schemaItemType = Unit.schemaItemType;\r\n public static override get schemaItemType() { return SchemaItemType.Unit; }\r\n protected _phenomenon?: LazyLoadedPhenomenon;\r\n protected _unitSystem?: LazyLoadedUnitSystem;\r\n protected _definition: string;\r\n protected _numerator?: number;\r\n protected _denominator?: number;\r\n protected _offset?: number;\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this._definition = \"\";\r\n }\r\n\r\n public get phenomenon(): LazyLoadedPhenomenon | undefined { return this._phenomenon; }\r\n public get unitSystem(): LazyLoadedUnitSystem | undefined { return this._unitSystem; }\r\n public get definition(): string { return this._definition; }\r\n public get numerator(): number { return this._numerator ?? 1.0; }\r\n public get offset(): number { return this._offset ?? 0.0; }\r\n public get denominator(): number { return this._denominator ?? 1.0; }\r\n public get hasNumerator(): boolean { return (this._numerator !== undefined); }\r\n public get hasOffset(): boolean { return (this._offset !== undefined); }\r\n public get hasDenominator(): boolean { return (this._denominator !== undefined); }\r\n\r\n /**\r\n * Returns true if a conversion can be calculated between the input units\r\n * @alpha\r\n */\r\n public static async areCompatible(unitA: Unit, unitB: Unit): Promise<boolean> {\r\n const unitAPhenomenon = await unitA.phenomenon;\r\n const unitBPhenomenon = await unitB.phenomenon;\r\n\r\n if (!unitAPhenomenon || !unitBPhenomenon || !unitAPhenomenon.key.matches(unitBPhenomenon.key))\r\n return false;\r\n return true;\r\n }\r\n\r\n /**\r\n * @alpha\r\n */\r\n public static isUnit(object: any): object is Unit {\r\n return SchemaItem.isSchemaItem(object) && object.schemaItemType === SchemaItemType.Unit;\r\n }\r\n\r\n /**\r\n * Save this Unit's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): SchemaItemUnitProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.phenomenon = this.phenomenon!.fullName;\r\n schemaJson.unitSystem = this.unitSystem!.fullName;\r\n schemaJson.definition = this.definition;\r\n if (this.hasNumerator)\r\n schemaJson.numerator = this.numerator;\r\n if (this.hasDenominator)\r\n schemaJson.denominator = this.denominator;\r\n if (this.hasOffset)\r\n schemaJson.offset = this.offset;\r\n return schemaJson;\r\n }\r\n\r\n /** @internal */\r\n public override async toXml(schemaXml: Document): Promise<Element> {\r\n const itemElement = await super.toXml(schemaXml);\r\n\r\n const phenomenon = await this.phenomenon;\r\n if (undefined !== phenomenon) {\r\n const phenomenonName = XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);\r\n itemElement.setAttribute(\"phenomenon\", phenomenonName);\r\n }\r\n\r\n const unitSystem = await this.unitSystem;\r\n if (undefined !== unitSystem) {\r\n const unitSystemName = XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);\r\n itemElement.setAttribute(\"unitSystem\", unitSystemName);\r\n }\r\n\r\n itemElement.setAttribute(\"definition\", this.definition);\r\n if (this.hasNumerator)\r\n itemElement.setAttribute(\"numerator\", this.numerator.toString());\r\n if (this.hasDenominator)\r\n itemElement.setAttribute(\"denominator\", this.denominator.toString());\r\n if (this.hasOffset)\r\n itemElement.setAttribute(\"offset\", this.offset.toString());\r\n\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(unitProps: SchemaItemUnitProps) {\r\n super.fromJSONSync(unitProps);\r\n\r\n const phenomenonSchemaItemKey = this.schema.getSchemaItemKey(unitProps.phenomenon);\r\n if (!phenomenonSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);\r\n this._phenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenonSchemaItemKey,\r\n async () => {\r\n const phenom = await this.schema.lookupItem(phenomenonSchemaItemKey, Phenomenon);\r\n if (undefined === phenom)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);\r\n return phenom;\r\n });\r\n\r\n const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(unitProps.unitSystem);\r\n if (!unitSystemSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);\r\n this._unitSystem = new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemSchemaItemKey,\r\n async () => {\r\n const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem);\r\n if (undefined === unitSystem)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);\r\n return unitSystem;\r\n });\r\n\r\n if (this._definition !== \"\" && unitProps.definition.toLowerCase() !== this._definition.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Unit ${this.name} has an invalid 'definition' attribute.`);\r\n else if (this._definition === \"\")\r\n this._definition = unitProps.definition;\r\n\r\n if (undefined !== unitProps.numerator) {\r\n if (unitProps.numerator !== this._numerator)\r\n this._numerator = unitProps.numerator;\r\n }\r\n\r\n if (undefined !== unitProps.denominator) {\r\n if (unitProps.denominator !== this._denominator)\r\n this._denominator = unitProps.denominator;\r\n }\r\n\r\n if (undefined !== unitProps.offset) {\r\n if (unitProps.offset !== this._offset)\r\n this._offset = unitProps.offset;\r\n }\r\n }\r\n\r\n public override async fromJSON(unitProps: SchemaItemUnitProps) {\r\n this.fromJSONSync(unitProps);\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setPhenomenon(phenomenon: LazyLoadedPhenomenon) {\r\n this._phenomenon = phenomenon;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setUnitSystem(unitSystem: LazyLoadedUnitSystem) {\r\n this._unitSystem = unitSystem;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setDefinition(definition: string) {\r\n this._definition = definition;\r\n }\r\n\r\n /**\r\n * Type assertion to check if the SchemaItem is of type Unit.\r\n * @param item The SchemaItem to check.\r\n * @returns The item cast to Unit if it is a Unit, undefined otherwise.\r\n */\r\n public static assertIsUnit(item?: SchemaItem): asserts item is Unit {\r\n if(!this.isUnit(item))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Unit}' (Unit)`);\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableUnit extends Unit {\r\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): Promise<void>;\r\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): Promise<void>;\r\n public abstract override setDefinition(definition: string): Promise<void>;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
@@ -2,14 +2,25 @@
2
2
  * @module Metadata
3
3
  */
4
4
  import { SchemaItemType } from "../ECObjects";
5
- import { Schema } from "./Schema";
6
5
  import { SchemaItem } from "./SchemaItem";
7
6
  /**
8
7
  * @beta
9
8
  */
10
9
  export declare class UnitSystem extends SchemaItem {
11
- readonly schemaItemType: SchemaItemType.UnitSystem;
12
- constructor(schema: Schema, name: string);
10
+ readonly schemaItemType: SchemaItemType;
11
+ static get schemaItemType(): SchemaItemType;
12
+ /**
13
+ * Type guard to check if the SchemaItem is of type UnitSystem.
14
+ * @param item The SchemaItem to check.
15
+ * @returns True if the item is a UnitSystem, false otherwise.
16
+ */
17
+ static isUnitSystem(item?: SchemaItem): item is UnitSystem;
18
+ /**
19
+ * Type assertion to check if the SchemaItem is of type UnitSystem.
20
+ * @param item The SchemaItem to check.
21
+ * @returns The item cast to UnitSystem if it is a UnitSystem, undefined otherwise.
22
+ */
23
+ static assertIsUnitSystem(item?: SchemaItem): asserts item is UnitSystem;
13
24
  }
14
25
  /**
15
26
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSystem.d.ts","sourceRoot":"","sources":["../../../src/Metadata/UnitSystem.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,SAAyB,cAAc,EAAG,cAAc,CAAC,UAAU,CAAC;gBAExD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAIzC;AAED;;;GAGG;AACH,8BAAsB,iBAAkB,SAAQ,UAAU;aAC/B,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
1
+ {"version":3,"file":"UnitSystem.d.ts","sourceRoot":"","sources":["../../../src/Metadata/UnitSystem.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,SAAyB,cAAc,iBAA6B;IACpE,WAA2B,cAAc,mBAAwC;IAEjF;;;;OAIG;WACW,YAAY,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,UAAU;IAOjE;;;;OAIG;WACW,kBAAkB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,UAAU;CAIhF;AAED;;;GAGG;AACH,8BAAsB,iBAAkB,SAAQ,UAAU;aAC/B,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -9,14 +9,32 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.MutableUnitSystem = exports.UnitSystem = void 0;
11
11
  const ECObjects_1 = require("../ECObjects");
12
+ const Exception_1 = require("../Exception");
12
13
  const SchemaItem_1 = require("./SchemaItem");
13
14
  /**
14
15
  * @beta
15
16
  */
16
17
  class UnitSystem extends SchemaItem_1.SchemaItem {
17
- constructor(schema, name) {
18
- super(schema, name);
19
- this.schemaItemType = ECObjects_1.SchemaItemType.UnitSystem;
18
+ schemaItemType = UnitSystem.schemaItemType;
19
+ static get schemaItemType() { return ECObjects_1.SchemaItemType.UnitSystem; }
20
+ /**
21
+ * Type guard to check if the SchemaItem is of type UnitSystem.
22
+ * @param item The SchemaItem to check.
23
+ * @returns True if the item is a UnitSystem, false otherwise.
24
+ */
25
+ static isUnitSystem(item) {
26
+ if (item && item.schemaItemType === ECObjects_1.SchemaItemType.UnitSystem)
27
+ return true;
28
+ return false;
29
+ }
30
+ /**
31
+ * Type assertion to check if the SchemaItem is of type UnitSystem.
32
+ * @param item The SchemaItem to check.
33
+ * @returns The item cast to UnitSystem if it is a UnitSystem, undefined otherwise.
34
+ */
35
+ static assertIsUnitSystem(item) {
36
+ if (!this.isUnitSystem(item))
37
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.UnitSystem}' (UnitSystem)`);
20
38
  }
21
39
  }
22
40
  exports.UnitSystem = UnitSystem;
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSystem.js","sourceRoot":"","sources":["../../../src/Metadata/UnitSystem.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,4CAA8C;AAE9C,6CAA0C;AAE1C;;GAEG;AACH,MAAa,UAAW,SAAQ,uBAAU;IAGxC,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,0BAAc,CAAC,UAAU,CAAC;IAClD,CAAC;CACF;AAPD,gCAOC;AAED;;;GAGG;AACH,MAAsB,iBAAkB,SAAQ,UAAU;CAEzD;AAFD,8CAEC","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 { SchemaItemType } from \"../ECObjects\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class UnitSystem extends SchemaItem {\r\n public override readonly schemaItemType!: SchemaItemType.UnitSystem;\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this.schemaItemType = SchemaItemType.UnitSystem;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n * Used for schema editing.\r\n */\r\nexport abstract class MutableUnitSystem extends UnitSystem {\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"UnitSystem.js","sourceRoot":"","sources":["../../../src/Metadata/UnitSystem.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,4CAA8C;AAC9C,4CAA+D;AAC/D,6CAA0C;AAE1C;;GAEG;AACH,MAAa,UAAW,SAAQ,uBAAU;IACf,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;IAC7D,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjF;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,IAAiB;QAC1C,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,UAAU;YAC3D,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,kBAAkB,CAAC,IAAiB;QAChD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;YAC1B,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,UAAU,gBAAgB,CAAC,CAAC;IAC5H,CAAC;CACF;AAzBD,gCAyBC;AAED;;;GAGG;AACH,MAAsB,iBAAkB,SAAQ,UAAU;CAEzD;AAFD,8CAEC","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 { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * @beta\n */\nexport class UnitSystem extends SchemaItem {\n public override readonly schemaItemType = UnitSystem.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.UnitSystem; }\n\n /**\n * Type guard to check if the SchemaItem is of type UnitSystem.\n * @param item The SchemaItem to check.\n * @returns True if the item is a UnitSystem, false otherwise.\n */\n public static isUnitSystem(item?: SchemaItem): item is UnitSystem {\n if (item && item.schemaItemType === SchemaItemType.UnitSystem)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type UnitSystem.\n * @param item The SchemaItem to check.\n * @returns The item cast to UnitSystem if it is a UnitSystem, undefined otherwise.\n */\n public static assertIsUnitSystem(item?: SchemaItem): asserts item is UnitSystem {\n if (!this.isUnitSystem(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.UnitSystem}' (UnitSystem)`);\n }\n}\n\n/**\n * @internal\n * Used for schema editing.\n */\nexport abstract class MutableUnitSystem extends UnitSystem {\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyTypes.js","sourceRoot":"","sources":["../../src/PropertyTypes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA4EH,oDAQC;AAjFD,2CAA8D;AAW9D;;GAEG;AACH,IAAY,YA4BX;AA5BD,WAAY,YAAY;IACtB,mDAAa,CAAA;IACb,+DAAmB,CAAA;IACnB,2DAAiB,CAAA;IACjB,qDAAc,CAAA;IACd,iEAAoB,CAAA;IACpB,uDAAe,CAAA;IACf,mEAAqB,CAAA;IACrB,yDAAgB,CAAA;IAChB,qEAAsB,CAAA;IACtB,sDAAc,CAAA;IACd,kEAAoB,CAAA;IACpB,wDAAe,CAAA;IACf,oEAAqB,CAAA;IACrB,gFAA2B,CAAA;IAC3B,4FAAiC,CAAA;IACjC,kDAAY,CAAA;IACZ,8DAAkB,CAAA;IAClB,wDAAe,CAAA;IACf,oEAAqB,CAAA;IACrB,wDAAe,CAAA;IACf,oEAAqB,CAAA;IACrB,sDAAc,CAA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oBAEhC,CAAA;AACH,CAAC,EAzBgB,iBAAiB,iCAAjB,iBAAiB,QAyBjC;AAED,YAAY;AACZ,SAAgB,oBAAoB,CAAC,IAAkB;IACrD,IAAI,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC;QACrC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAC5F,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC;QAClC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,gBAAgB,CAAC;IACtF,IAAI,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC;QACtC,OAAO,oBAAoB,CAAC;IAC9B,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;AAChF,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 { PrimitiveType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\n\r\n/** @beta */\r\nconst enum PropertyFlags { // eslint-disable-line no-restricted-syntax\r\n Primitive = 0x01,\r\n Struct = 0x02,\r\n Array = 0x04,\r\n Navigation = 0x08,\r\n Enumeration = 0x10,\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport enum PropertyType {\r\n Struct = 0x02, // PropertyFlags.Struct\r\n Struct_Array = 0x06, // PropertyFlags.Struct | PropertyFlags.Array\r\n Navigation = 0x08, // PropertyFlags.Navigation\r\n Binary = 0x101, // PrimitiveType.Binary\r\n Binary_Array = 0x105, // PrimitiveType.Binary | PropertyFlags.Array\r\n Boolean = 0x201, // PrimitiveType.Boolean\r\n Boolean_Array = 0x205, // PrimitiveType.Boolean | PropertyFlags.Array\r\n DateTime = 0x301, // PrimitiveType.DateTime\r\n DateTime_Array = 0x305, // PrimitiveType.DateTime | PropertyFlags.Array\r\n Double = 0x401, // PrimitiveType.Double\r\n Double_Array = 0x405, // PrimitiveType.Double | PropertyFlags.Array\r\n Integer = 0x501, // PrimitiveType.Integer\r\n Integer_Array = 0x505, // PrimitiveType.Integer | PropertyFlags.Array\r\n Integer_Enumeration = 0x511, // PrimitiveType.Integer | PropertyFlags.Enumeration\r\n Integer_Enumeration_Array = 0x515, // PrimitiveType.Integer | PropertyFlags.Enumeration | PropertyFlags.Array\r\n Long = 0x601, // PrimitiveType.Long\r\n Long_Array = 0x605, // PrimitiveType.Long | PropertyFlags.Array\r\n Point2d = 0x701, // PrimitiveType.Point2d\r\n Point2d_Array = 0x705, // PrimitiveType.Point2d | PropertyFlags.Array\r\n Point3d = 0x801, // PrimitiveType.Point3d\r\n Point3d_Array = 0x805, // PrimitiveType.Point3d | PropertyFlags.Array\r\n String = 0x901, // PrimitiveType.String\r\n String_Array = 0x905, // PrimitiveType.String | PropertyFlags.Array\r\n String_Enumeration = 0x911, // PrimitiveType.String | PropertyFlags.Enumeration\r\n String_Enumeration_Array = 0x915, // PrimitiveType.String | PropertyFlags.Enumeration | PropertyFlags.Array\r\n IGeometry = 0xA01, // PrimitiveType.IGeometry\r\n IGeometry_Array = 0xA05, // PrimitiveType.IGeometry | PropertyFlags.Array\r\n}\r\n\r\n/** @beta */\r\nexport namespace PropertyTypeUtils {\r\n export function isArray(t: PropertyType) {\r\n return (t === (PropertyFlags.Array | t));\r\n }\r\n export function isPrimitive(t: PropertyType) {\r\n return (t === (PropertyFlags.Primitive | t));\r\n }\r\n export function isStruct(t: PropertyType) {\r\n return (t === (PropertyFlags.Struct | t));\r\n }\r\n export function isNavigation(t: PropertyType) {\r\n return (t === (PropertyFlags.Navigation | t));\r\n }\r\n export function isEnumeration(t: PropertyType) {\r\n return (t === (PropertyFlags.Enumeration | t));\r\n }\r\n export function asArray(t: PropertyType): PropertyType {\r\n return t | PropertyFlags.Array;\r\n }\r\n export function getPrimitiveType(t: PropertyType): PrimitiveType {\r\n return (0xFF01 & t);\r\n }\r\n export function fromPrimitiveType(t: PrimitiveType): PropertyType {\r\n return t | 0;\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function propertyTypeToString(type: PropertyType) {\r\n if (PropertyTypeUtils.isPrimitive(type))\r\n return (PropertyTypeUtils.isArray(type)) ? \"PrimitiveArrayProperty\" : \"PrimitiveProperty\";\r\n if (PropertyTypeUtils.isStruct(type))\r\n return (PropertyTypeUtils.isArray(type)) ? \"StructArrayProperty\" : \"StructProperty\";\r\n if (PropertyTypeUtils.isNavigation(type))\r\n return \"NavigationProperty\";\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, \"Invalid propertyType\");\r\n}\r\n"]}
1
+ {"version":3,"file":"PropertyTypes.js","sourceRoot":"","sources":["../../src/PropertyTypes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA4EH,oDAQC;AAjFD,2CAA8D;AAW9D;;GAEG;AACH,IAAY,YA4BX;AA5BD,WAAY,YAAY;IACtB,mDAAa,CAAA;IACb,+DAAmB,CAAA;IACnB,2DAAiB,CAAA;IACjB,qDAAc,CAAA;IACd,iEAAoB,CAAA;IACpB,uDAAe,CAAA;IACf,mEAAqB,CAAA;IACrB,yDAAgB,CAAA;IAChB,qEAAsB,CAAA;IACtB,sDAAc,CAAA;IACd,kEAAoB,CAAA;IACpB,wDAAe,CAAA;IACf,oEAAqB,CAAA;IACrB,gFAA2B,CAAA;IAC3B,4FAAiC,CAAA;IACjC,kDAAY,CAAA;IACZ,8DAAkB,CAAA;IAClB,wDAAe,CAAA;IACf,oEAAqB,CAAA;IACrB,wDAAe,CAAA;IACf,oEAAqB,CAAA;IACrB,sDAAc,CAAA;IAC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hC,CAAA;AACH,CAAC,EAzBgB,iBAAiB,iCAAjB,iBAAiB,QAyBjC;AAED,YAAY;AACZ,SAAgB,oBAAoB,CAAC,IAAkB;IACrD,IAAI,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC;QACrC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAC5F,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC;QAClC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,gBAAgB,CAAC;IACtF,IAAI,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC;QACtC,OAAO,oBAAoB,CAAC;IAC9B,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;AAChF,CAAC","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 { PrimitiveType } from \"./ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\n\n/** @beta */\nconst enum PropertyFlags { // eslint-disable-line no-restricted-syntax\n Primitive = 0x01,\n Struct = 0x02,\n Array = 0x04,\n Navigation = 0x08,\n Enumeration = 0x10,\n}\n\n/**\n * @beta\n */\nexport enum PropertyType {\n Struct = 0x02, // PropertyFlags.Struct\n Struct_Array = 0x06, // PropertyFlags.Struct | PropertyFlags.Array\n Navigation = 0x08, // PropertyFlags.Navigation\n Binary = 0x101, // PrimitiveType.Binary\n Binary_Array = 0x105, // PrimitiveType.Binary | PropertyFlags.Array\n Boolean = 0x201, // PrimitiveType.Boolean\n Boolean_Array = 0x205, // PrimitiveType.Boolean | PropertyFlags.Array\n DateTime = 0x301, // PrimitiveType.DateTime\n DateTime_Array = 0x305, // PrimitiveType.DateTime | PropertyFlags.Array\n Double = 0x401, // PrimitiveType.Double\n Double_Array = 0x405, // PrimitiveType.Double | PropertyFlags.Array\n Integer = 0x501, // PrimitiveType.Integer\n Integer_Array = 0x505, // PrimitiveType.Integer | PropertyFlags.Array\n Integer_Enumeration = 0x511, // PrimitiveType.Integer | PropertyFlags.Enumeration\n Integer_Enumeration_Array = 0x515, // PrimitiveType.Integer | PropertyFlags.Enumeration | PropertyFlags.Array\n Long = 0x601, // PrimitiveType.Long\n Long_Array = 0x605, // PrimitiveType.Long | PropertyFlags.Array\n Point2d = 0x701, // PrimitiveType.Point2d\n Point2d_Array = 0x705, // PrimitiveType.Point2d | PropertyFlags.Array\n Point3d = 0x801, // PrimitiveType.Point3d\n Point3d_Array = 0x805, // PrimitiveType.Point3d | PropertyFlags.Array\n String = 0x901, // PrimitiveType.String\n String_Array = 0x905, // PrimitiveType.String | PropertyFlags.Array\n String_Enumeration = 0x911, // PrimitiveType.String | PropertyFlags.Enumeration\n String_Enumeration_Array = 0x915, // PrimitiveType.String | PropertyFlags.Enumeration | PropertyFlags.Array\n IGeometry = 0xA01, // PrimitiveType.IGeometry\n IGeometry_Array = 0xA05, // PrimitiveType.IGeometry | PropertyFlags.Array\n}\n\n/** @beta */\nexport namespace PropertyTypeUtils {\n export function isArray(t: PropertyType) {\n return (t === (PropertyFlags.Array | t));\n }\n export function isPrimitive(t: PropertyType) {\n return (t === (PropertyFlags.Primitive | t));\n }\n export function isStruct(t: PropertyType) {\n return (t === (PropertyFlags.Struct | t));\n }\n export function isNavigation(t: PropertyType) {\n return (t === (PropertyFlags.Navigation | t));\n }\n export function isEnumeration(t: PropertyType) {\n return (t === (PropertyFlags.Enumeration | t));\n }\n export function asArray(t: PropertyType): PropertyType {\n return t | PropertyFlags.Array;\n }\n export function getPrimitiveType(t: PropertyType): PrimitiveType {\n return (0xFF01 & t);\n }\n export function fromPrimitiveType(t: PrimitiveType): PropertyType {\n return t | 0;\n }\n}\n\n/** @beta */\nexport function propertyTypeToString(type: PropertyType) {\n if (PropertyTypeUtils.isPrimitive(type))\n return (PropertyTypeUtils.isArray(type)) ? \"PrimitiveArrayProperty\" : \"PrimitiveProperty\";\n if (PropertyTypeUtils.isStruct(type))\n return (PropertyTypeUtils.isArray(type)) ? \"StructArrayProperty\" : \"StructProperty\";\n if (PropertyTypeUtils.isNavigation(type))\n return \"NavigationProperty\";\n throw new ECObjectsError(ECObjectsStatus.InvalidType, \"Invalid propertyType\");\n}\n"]}
@@ -24,19 +24,19 @@ export declare class SchemaJsonLocater implements ISchemaLocater {
24
24
  * @param context The [SchemaContext] used to facilitate schema location.
25
25
  * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
26
26
  */
27
- getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined>;
27
+ getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;
28
28
  /**
29
29
  * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
30
30
  * @param schemaKey The SchemaKey describing the schema to get from the cache.
31
31
  * @param matchType The match type to use when locating the schema
32
32
  */
33
- getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;
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
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
  */
40
- getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, _matchType: SchemaMatchType, context: SchemaContext): T | undefined;
40
+ getSchemaSync(schemaKey: SchemaKey, _matchType: SchemaMatchType, context: SchemaContext): Schema | undefined;
41
41
  }
42
42
  //# sourceMappingURL=SchemaJsonLocater.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaJsonLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;AAEhF;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACnC,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,iBAAiB;IAExD;;;;;OAKG;IACU,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAKpJ;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAY/I;;;;;OAKG;IACI,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,CAAC,GAAG,SAAS;CAS3I"}
1
+ {"version":3,"file":"SchemaJsonLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;AAEhF;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACnC,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,iBAAiB;IAExD;;;;;OAKG;IACU,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK7H;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAYrI;;;;;OAKG;IACI,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;CAOpH"}
@@ -13,6 +13,7 @@ const Schema_1 = require("./Metadata/Schema");
13
13
  * @beta
14
14
  */
15
15
  class SchemaJsonLocater {
16
+ _getSchema;
16
17
  constructor(_getSchema) {
17
18
  this._getSchema = _getSchema;
18
19
  }
@@ -24,7 +25,7 @@ class SchemaJsonLocater {
24
25
  */
25
26
  async getSchema(schemaKey, matchType, context) {
26
27
  await this.getSchemaInfo(schemaKey, matchType, context);
27
- return await context.getCachedSchema(schemaKey, matchType);
28
+ return context.getCachedSchema(schemaKey, matchType);
28
29
  }
29
30
  /**
30
31
  * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
@@ -50,8 +51,7 @@ class SchemaJsonLocater {
50
51
  const schemaProps = this._getSchema(schemaKey.name);
51
52
  if (!schemaProps)
52
53
  return undefined;
53
- context = context ? context : new Context_1.SchemaContext();
54
- return Schema_1.Schema.fromJsonSync(schemaProps, context);
54
+ return Schema_1.Schema.fromJsonSync(schemaProps, context || new Context_1.SchemaContext());
55
55
  }
56
56
  }
57
57
  exports.SchemaJsonLocater = SchemaJsonLocater;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaJsonLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,uCAA0D;AAI1D,8CAA2C;AAU3C;;;;GAIG;AACH,MAAa,iBAAiB;IAC5B,YAA2B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAI,CAAC;IAE7D;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAmB,SAA8B,EAAE,SAA0B,EAAE,OAAsB;QACzH,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,MAAM,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAM,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAA8B,EAAE,SAA0B,EAAE,OAAsB;QAC3G,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,eAAM,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,CAAmB,SAA8B,EAAE,UAA2B,EAAE,OAAsB;QACxH,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,uBAAa,EAAE,CAAC;QAClD,OAAO,eAAM,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAM,CAAC;IACxD,CAAC;CAEF;AA9CD,8CA8CC","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 * @beta\r\n */\r\nexport type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;\r\n\r\n/**\r\n * A 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 * @beta\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 [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined> {\r\n await this.getSchemaInfo(schemaKey, matchType, context);\r\n return await context.getCachedSchema(schemaKey, matchType) as T;\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: Readonly<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<T extends Schema>(schemaKey: Readonly<SchemaKey>, _matchType: SchemaMatchType, context: SchemaContext): T | undefined {\r\n const schemaProps = this._getSchema(schemaKey.name);\r\n if (!schemaProps)\r\n return undefined;\r\n\r\n context = context ? context : new SchemaContext();\r\n return Schema.fromJsonSync(schemaProps, context) as T;\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,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CC","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"]}
@@ -10,6 +10,12 @@ export declare class ECVersion {
10
10
  private _read;
11
11
  private _write;
12
12
  private _minor;
13
+ /**
14
+ * Using a version with all zero is invalid
15
+ * for a schema, but it can be used to indicate
16
+ * "no version has been specified" when locating things
17
+ */
18
+ static readonly NO_VERSION: ECVersion;
13
19
  /**
14
20
  * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
15
21
  * @param read Can support up to 999.
@@ -76,7 +82,7 @@ export declare class SchemaKey {
76
82
  * @param rhs The SchemaKey to compare with
77
83
  * @param matchType The match type to use for comparison.
78
84
  */
79
- matches(rhs: Readonly<SchemaKey>, matchType?: SchemaMatchType): boolean;
85
+ matches(rhs: SchemaKey, matchType?: SchemaMatchType): boolean;
80
86
  /**
81
87
  * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.
82
88
  * @param props SchemaKeyProps
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaKey.d.ts","sourceRoot":"","sources":["../../src/SchemaKey.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,MAAM,CAAa;IAE3B;;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{
18
+ _read = 0;
19
+ _write = 0;
20
+ _minor = 0;
21
+ /**
22
+ * Using a version with all zero is invalid
23
+ * for a schema, but it can be used to indicate
24
+ * "no version has been specified" when locating things
25
+ */
26
+ static NO_VERSION = new ECVersion(0, 0, 0);
18
27
  /**
19
28
  * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
20
29
  * @param read Can support up to 999.
@@ -23,9 +32,6 @@ class ECVersion {
23
32
  *
24
33
  */
25
34
  constructor(read, write, minor) {
26
- this._read = 0;
27
- this._write = 0;
28
- this._minor = 0;
29
35
  if (undefined !== read)
30
36
  this._read = read;
31
37
  if (undefined !== write)
@@ -84,6 +90,8 @@ exports.ECVersion = ECVersion;
84
90
  * @beta
85
91
  */
86
92
  class SchemaKey {
93
+ _name;
94
+ _version;
87
95
  constructor(name, readOrVersion, writeVersion, minorVersion) {
88
96
  this._name = new ECName_1.ECName(name);
89
97
  if (readOrVersion !== undefined && typeof (readOrVersion) !== "number")
@@ -185,6 +193,8 @@ exports.SchemaKey = SchemaKey;
185
193
  * @beta
186
194
  */
187
195
  class SchemaItemKey {
196
+ _name;
197
+ _schemaKey;
188
198
  constructor(name, schema) {
189
199
  this._name = new ECName_1.ECName(name);
190
200
  this._schemaKey = schema;