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

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 (298) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/lib/cjs/Constants.js +20 -20
  3. package/lib/cjs/Constants.js.map +1 -1
  4. package/lib/cjs/Context.d.ts +83 -34
  5. package/lib/cjs/Context.d.ts.map +1 -1
  6. package/lib/cjs/Context.js +73 -23
  7. package/lib/cjs/Context.js.map +1 -1
  8. package/lib/cjs/DelayedPromise.js +6 -4
  9. package/lib/cjs/DelayedPromise.js.map +1 -1
  10. package/lib/cjs/Deserialization/AbstractParser.js +1 -0
  11. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  12. package/lib/cjs/Deserialization/Helper.d.ts +3 -3
  13. package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
  14. package/lib/cjs/Deserialization/Helper.js +8 -0
  15. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  16. package/lib/cjs/Deserialization/JsonParser.js +3 -0
  17. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  18. package/lib/cjs/Deserialization/JsonProps.d.ts +3 -0
  19. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  20. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  21. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  22. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  23. package/lib/cjs/Deserialization/XmlParser.js +11 -3
  24. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  25. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  26. package/lib/cjs/Deserialization/XmlSerializationUtils.js +2 -6
  27. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  28. package/lib/cjs/ECName.js +1 -0
  29. package/lib/cjs/ECName.js.map +1 -1
  30. package/lib/cjs/ECObjects.d.ts +21 -1
  31. package/lib/cjs/ECObjects.d.ts.map +1 -1
  32. package/lib/cjs/ECObjects.js +33 -2
  33. package/lib/cjs/ECObjects.js.map +1 -1
  34. package/lib/cjs/Exception.js +1 -0
  35. package/lib/cjs/Exception.js.map +1 -1
  36. package/lib/cjs/Interfaces.d.ts +10 -3
  37. package/lib/cjs/Interfaces.d.ts.map +1 -1
  38. package/lib/cjs/Interfaces.js.map +1 -1
  39. package/lib/cjs/Metadata/Class.d.ts +75 -16
  40. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  41. package/lib/cjs/Metadata/Class.js +168 -46
  42. package/lib/cjs/Metadata/Class.js.map +1 -1
  43. package/lib/cjs/Metadata/Constant.d.ts +14 -1
  44. package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
  45. package/lib/cjs/Metadata/Constant.js +27 -2
  46. package/lib/cjs/Metadata/Constant.js.map +1 -1
  47. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  48. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +16 -4
  49. package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
  50. package/lib/cjs/Metadata/CustomAttributeClass.js +22 -4
  51. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  52. package/lib/cjs/Metadata/EntityClass.d.ts +20 -8
  53. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  54. package/lib/cjs/Metadata/EntityClass.js +42 -22
  55. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  56. package/lib/cjs/Metadata/Enumeration.d.ts +14 -1
  57. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  58. package/lib/cjs/Metadata/Enumeration.js +22 -1
  59. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  60. package/lib/cjs/Metadata/Format.d.ts +41 -1
  61. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  62. package/lib/cjs/Metadata/Format.js +68 -3
  63. package/lib/cjs/Metadata/Format.js.map +1 -1
  64. package/lib/cjs/Metadata/InvertedUnit.d.ts +8 -3
  65. package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
  66. package/lib/cjs/Metadata/InvertedUnit.js +17 -6
  67. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  68. package/lib/cjs/Metadata/KindOfQuantity.d.ts +14 -3
  69. package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
  70. package/lib/cjs/Metadata/KindOfQuantity.js +43 -18
  71. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  72. package/lib/cjs/Metadata/Mixin.d.ts +15 -1
  73. package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
  74. package/lib/cjs/Metadata/Mixin.js +23 -2
  75. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  76. package/lib/cjs/Metadata/OverrideFormat.js +9 -0
  77. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  78. package/lib/cjs/Metadata/Phenomenon.d.ts +14 -1
  79. package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
  80. package/lib/cjs/Metadata/Phenomenon.js +22 -1
  81. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  82. package/lib/cjs/Metadata/Property.d.ts +5 -1
  83. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  84. package/lib/cjs/Metadata/Property.js +83 -28
  85. package/lib/cjs/Metadata/Property.js.map +1 -1
  86. package/lib/cjs/Metadata/PropertyCategory.d.ts +14 -1
  87. package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
  88. package/lib/cjs/Metadata/PropertyCategory.js +21 -1
  89. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  90. package/lib/cjs/Metadata/RelationshipClass.d.ts +15 -2
  91. package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
  92. package/lib/cjs/Metadata/RelationshipClass.js +47 -10
  93. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  94. package/lib/cjs/Metadata/Schema.d.ts +116 -11
  95. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  96. package/lib/cjs/Metadata/Schema.js +135 -33
  97. package/lib/cjs/Metadata/Schema.js.map +1 -1
  98. package/lib/cjs/Metadata/SchemaItem.d.ts +11 -2
  99. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  100. package/lib/cjs/Metadata/SchemaItem.js +10 -0
  101. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  102. package/lib/cjs/Metadata/Unit.d.ts +8 -1
  103. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  104. package/lib/cjs/Metadata/Unit.js +21 -3
  105. package/lib/cjs/Metadata/Unit.js.map +1 -1
  106. package/lib/cjs/Metadata/UnitSystem.d.ts +14 -3
  107. package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
  108. package/lib/cjs/Metadata/UnitSystem.js +21 -3
  109. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  110. package/lib/cjs/PropertyTypes.js.map +1 -1
  111. package/lib/cjs/SchemaJsonLocater.d.ts +3 -3
  112. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  113. package/lib/cjs/SchemaJsonLocater.js +3 -3
  114. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  115. package/lib/cjs/SchemaKey.d.ts +7 -1
  116. package/lib/cjs/SchemaKey.d.ts.map +1 -1
  117. package/lib/cjs/SchemaKey.js +13 -3
  118. package/lib/cjs/SchemaKey.js.map +1 -1
  119. package/lib/cjs/SchemaLoader.d.ts +2 -2
  120. package/lib/cjs/SchemaLoader.d.ts.map +1 -1
  121. package/lib/cjs/SchemaLoader.js +1 -0
  122. package/lib/cjs/SchemaLoader.js.map +1 -1
  123. package/lib/cjs/SchemaPartVisitorDelegate.js +1 -0
  124. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  125. package/lib/cjs/UnitConversion/Graph.js +69 -65
  126. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  127. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  128. package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
  129. package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
  130. package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
  131. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  132. package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
  133. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  134. package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
  135. package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
  136. package/lib/cjs/UnitConversion/UnitTree.js +11 -1
  137. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  138. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  139. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +8 -9
  140. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  141. package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
  142. package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
  143. package/lib/cjs/Validation/SchemaWalker.js +6 -4
  144. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  145. package/lib/cjs/ecschema-metadata.d.ts +1 -1
  146. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  147. package/lib/cjs/ecschema-metadata.js.map +1 -1
  148. package/lib/cjs/utils/SchemaGraph.js +2 -3
  149. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  150. package/lib/esm/Constants.js +20 -20
  151. package/lib/esm/Constants.js.map +1 -1
  152. package/lib/esm/Context.d.ts +83 -34
  153. package/lib/esm/Context.d.ts.map +1 -1
  154. package/lib/esm/Context.js +71 -21
  155. package/lib/esm/Context.js.map +1 -1
  156. package/lib/esm/DelayedPromise.js +6 -4
  157. package/lib/esm/DelayedPromise.js.map +1 -1
  158. package/lib/esm/Deserialization/AbstractParser.js +1 -0
  159. package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
  160. package/lib/esm/Deserialization/Helper.d.ts +3 -3
  161. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  162. package/lib/esm/Deserialization/Helper.js +8 -0
  163. package/lib/esm/Deserialization/Helper.js.map +1 -1
  164. package/lib/esm/Deserialization/JsonParser.js +3 -0
  165. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  166. package/lib/esm/Deserialization/JsonProps.d.ts +3 -0
  167. package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
  168. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  169. package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
  170. package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
  171. package/lib/esm/Deserialization/XmlParser.js +11 -3
  172. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  173. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  174. package/lib/esm/Deserialization/XmlSerializationUtils.js +2 -6
  175. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  176. package/lib/esm/ECName.js +1 -0
  177. package/lib/esm/ECName.js.map +1 -1
  178. package/lib/esm/ECObjects.d.ts +21 -1
  179. package/lib/esm/ECObjects.d.ts.map +1 -1
  180. package/lib/esm/ECObjects.js +31 -1
  181. package/lib/esm/ECObjects.js.map +1 -1
  182. package/lib/esm/Exception.js +1 -0
  183. package/lib/esm/Exception.js.map +1 -1
  184. package/lib/esm/Interfaces.d.ts +10 -3
  185. package/lib/esm/Interfaces.d.ts.map +1 -1
  186. package/lib/esm/Interfaces.js.map +1 -1
  187. package/lib/esm/Metadata/Class.d.ts +75 -16
  188. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  189. package/lib/esm/Metadata/Class.js +169 -47
  190. package/lib/esm/Metadata/Class.js.map +1 -1
  191. package/lib/esm/Metadata/Constant.d.ts +14 -1
  192. package/lib/esm/Metadata/Constant.d.ts.map +1 -1
  193. package/lib/esm/Metadata/Constant.js +27 -2
  194. package/lib/esm/Metadata/Constant.js.map +1 -1
  195. package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
  196. package/lib/esm/Metadata/CustomAttributeClass.d.ts +16 -4
  197. package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
  198. package/lib/esm/Metadata/CustomAttributeClass.js +22 -4
  199. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  200. package/lib/esm/Metadata/EntityClass.d.ts +20 -8
  201. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  202. package/lib/esm/Metadata/EntityClass.js +42 -22
  203. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  204. package/lib/esm/Metadata/Enumeration.d.ts +14 -1
  205. package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
  206. package/lib/esm/Metadata/Enumeration.js +22 -1
  207. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  208. package/lib/esm/Metadata/Format.d.ts +41 -1
  209. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  210. package/lib/esm/Metadata/Format.js +68 -3
  211. package/lib/esm/Metadata/Format.js.map +1 -1
  212. package/lib/esm/Metadata/InvertedUnit.d.ts +8 -3
  213. package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
  214. package/lib/esm/Metadata/InvertedUnit.js +17 -6
  215. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  216. package/lib/esm/Metadata/KindOfQuantity.d.ts +14 -3
  217. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
  218. package/lib/esm/Metadata/KindOfQuantity.js +43 -18
  219. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  220. package/lib/esm/Metadata/Mixin.d.ts +15 -1
  221. package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
  222. package/lib/esm/Metadata/Mixin.js +24 -3
  223. package/lib/esm/Metadata/Mixin.js.map +1 -1
  224. package/lib/esm/Metadata/OverrideFormat.js +9 -0
  225. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  226. package/lib/esm/Metadata/Phenomenon.d.ts +14 -1
  227. package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
  228. package/lib/esm/Metadata/Phenomenon.js +22 -1
  229. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  230. package/lib/esm/Metadata/Property.d.ts +5 -1
  231. package/lib/esm/Metadata/Property.d.ts.map +1 -1
  232. package/lib/esm/Metadata/Property.js +84 -29
  233. package/lib/esm/Metadata/Property.js.map +1 -1
  234. package/lib/esm/Metadata/PropertyCategory.d.ts +14 -1
  235. package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
  236. package/lib/esm/Metadata/PropertyCategory.js +21 -1
  237. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  238. package/lib/esm/Metadata/RelationshipClass.d.ts +15 -2
  239. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
  240. package/lib/esm/Metadata/RelationshipClass.js +48 -11
  241. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  242. package/lib/esm/Metadata/Schema.d.ts +116 -11
  243. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  244. package/lib/esm/Metadata/Schema.js +135 -33
  245. package/lib/esm/Metadata/Schema.js.map +1 -1
  246. package/lib/esm/Metadata/SchemaItem.d.ts +11 -2
  247. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  248. package/lib/esm/Metadata/SchemaItem.js +11 -1
  249. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  250. package/lib/esm/Metadata/Unit.d.ts +8 -1
  251. package/lib/esm/Metadata/Unit.d.ts.map +1 -1
  252. package/lib/esm/Metadata/Unit.js +21 -3
  253. package/lib/esm/Metadata/Unit.js.map +1 -1
  254. package/lib/esm/Metadata/UnitSystem.d.ts +14 -3
  255. package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
  256. package/lib/esm/Metadata/UnitSystem.js +21 -3
  257. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  258. package/lib/esm/PropertyTypes.js.map +1 -1
  259. package/lib/esm/SchemaJsonLocater.d.ts +3 -3
  260. package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
  261. package/lib/esm/SchemaJsonLocater.js +3 -3
  262. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  263. package/lib/esm/SchemaKey.d.ts +7 -1
  264. package/lib/esm/SchemaKey.d.ts.map +1 -1
  265. package/lib/esm/SchemaKey.js +13 -3
  266. package/lib/esm/SchemaKey.js.map +1 -1
  267. package/lib/esm/SchemaLoader.d.ts +2 -2
  268. package/lib/esm/SchemaLoader.d.ts.map +1 -1
  269. package/lib/esm/SchemaLoader.js +1 -0
  270. package/lib/esm/SchemaLoader.js.map +1 -1
  271. package/lib/esm/SchemaPartVisitorDelegate.js +1 -0
  272. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  273. package/lib/esm/UnitConversion/Graph.js +69 -65
  274. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  275. package/lib/esm/UnitConversion/Parser.js.map +1 -1
  276. package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
  277. package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
  278. package/lib/esm/UnitConversion/UnitConversion.js +9 -7
  279. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  280. package/lib/esm/UnitConversion/UnitConverter.js +2 -0
  281. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  282. package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
  283. package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
  284. package/lib/esm/UnitConversion/UnitTree.js +11 -1
  285. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  286. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  287. package/lib/esm/UnitProvider/SchemaUnitProvider.js +8 -9
  288. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  289. package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
  290. package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
  291. package/lib/esm/Validation/SchemaWalker.js +6 -4
  292. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  293. package/lib/esm/ecschema-metadata.d.ts +1 -1
  294. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  295. package/lib/esm/ecschema-metadata.js.map +1 -1
  296. package/lib/esm/utils/SchemaGraph.js +2 -3
  297. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  298. package/package.json +14 -14
@@ -11,7 +11,8 @@ import { SchemaItem } from "./SchemaItem";
11
11
  * @beta
12
12
  */
13
13
  export declare class Constant extends SchemaItem {
14
- readonly schemaItemType: SchemaItemType.Constant;
14
+ readonly schemaItemType: SchemaItemType;
15
+ static get schemaItemType(): SchemaItemType;
15
16
  protected _phenomenon?: LazyLoadedPhenomenon;
16
17
  protected _definition: string;
17
18
  protected _numerator?: number;
@@ -50,6 +51,18 @@ export declare class Constant extends SchemaItem {
50
51
  * @alpha Used in schema editing.
51
52
  */
52
53
  protected setDenominator(denominator: number): void;
54
+ /**
55
+ * Type guard to check if the SchemaItem is of type Constant.
56
+ * @param item The SchemaItem to check.
57
+ * @returns True if the item is a Constant, false otherwise.
58
+ */
59
+ static isConstant(item?: SchemaItem): item is Constant;
60
+ /**
61
+ * Type assertion to check if the SchemaItem is of type Constant.
62
+ * @param item The SchemaItem to check.
63
+ * @returns The item cast to Constant if it is a Constant, undefined otherwise.
64
+ */
65
+ static assertIsConstant(item?: SchemaItem): asserts item is Constant;
53
66
  }
54
67
  /**
55
68
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"Constant.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Constant.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EAAE,MAAM,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e,GAAG,aAAa;IAYzG,gBAAgB;IACM,KAAK,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBlD,YAAY,CAAC,aAAa,EAAE,aAAa;IA8BnC,QAAQ,CAAC,aAAa,EAAE,aAAa;IAI3D;;;OAGG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,oBAAoB;IAIxD;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM;IAI1C;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM;IAIxC;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM;IAI5C;;;;OAIG;WACW,UAAU,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,QAAQ;IAO7D;;;;OAIG;WACW,gBAAgB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ;CAI5E;AACD;;;GAGG;AACH,8BAAsB,eAAgB,SAAQ,QAAQ;aAC3B,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;aACrD,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;aACvC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;aACrC,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;aACzC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -9,15 +9,21 @@ import { DelayedPromiseWithProps } from "../DelayedPromise";
9
9
  import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils";
10
10
  import { SchemaItemType } from "../ECObjects";
11
11
  import { ECObjectsError, ECObjectsStatus } from "../Exception";
12
+ import { Phenomenon } from "./Phenomenon";
12
13
  import { SchemaItem } from "./SchemaItem";
13
14
  /**
14
15
  * A Constant is a specific type of Unit that represents a number.
15
16
  * @beta
16
17
  */
17
18
  export class Constant extends SchemaItem {
19
+ schemaItemType = Constant.schemaItemType;
20
+ static get schemaItemType() { return SchemaItemType.Constant; }
21
+ _phenomenon;
22
+ _definition;
23
+ _numerator;
24
+ _denominator;
18
25
  constructor(schema, name) {
19
26
  super(schema, name);
20
- this.schemaItemType = SchemaItemType.Constant;
21
27
  this._definition = "";
22
28
  }
23
29
  get phenomenon() { return this._phenomenon; }
@@ -63,7 +69,7 @@ export class Constant extends SchemaItem {
63
69
  if (!schemaItemKey)
64
70
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);
65
71
  this._phenomenon = new DelayedPromiseWithProps(schemaItemKey, async () => {
66
- const phenom = await this.schema.lookupItem(schemaItemKey);
72
+ const phenom = await this.schema.lookupItem(schemaItemKey, Phenomenon);
67
73
  if (undefined === phenom)
68
74
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);
69
75
  return phenom;
@@ -109,6 +115,25 @@ export class Constant extends SchemaItem {
109
115
  setDenominator(denominator) {
110
116
  this._denominator = denominator;
111
117
  }
118
+ /**
119
+ * Type guard to check if the SchemaItem is of type Constant.
120
+ * @param item The SchemaItem to check.
121
+ * @returns True if the item is a Constant, false otherwise.
122
+ */
123
+ static isConstant(item) {
124
+ if (item && item.schemaItemType === SchemaItemType.Constant)
125
+ return true;
126
+ return false;
127
+ }
128
+ /**
129
+ * Type assertion to check if the SchemaItem is of type Constant.
130
+ * @param item The SchemaItem to check.
131
+ * @returns The item cast to Constant if it is a Constant, undefined otherwise.
132
+ */
133
+ static assertIsConstant(item) {
134
+ if (!this.isConstant(item))
135
+ throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Constant}' (Constant)`);
136
+ }
112
137
  }
113
138
  /**
114
139
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"Constant.js","sourceRoot":"","sources":["../../../src/Metadata/Constant.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;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CAAC;IACnC,CAAC;IAED;;;OAGG;IACO,aAAa,CAAC,UAAgC;QACtD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,aAAa,CAAC,UAAkB;QACxC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,SAAiB;QACtC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,eAAgB,SAAQ,QAAQ;CAMrD","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 { ConstantProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedPhenomenon } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { Phenomenon } from \"./Phenomenon\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\n\r\n/**\r\n * A Constant is a specific type of Unit that represents a number.\r\n * @beta\r\n */\r\nexport class Constant extends SchemaItem {\r\n public override readonly schemaItemType!: SchemaItemType.Constant;\r\n protected _phenomenon?: LazyLoadedPhenomenon;\r\n protected _definition: string;\r\n protected _numerator?: number;\r\n protected _denominator?: number;\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this.schemaItemType = SchemaItemType.Constant;\r\n this._definition = \"\";\r\n }\r\n\r\n public get phenomenon(): LazyLoadedPhenomenon | undefined { return this._phenomenon; }\r\n public get definition(): string { return this._definition; }\r\n public get numerator(): number { return this._numerator ?? 1.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 hasDenominator(): boolean { return (this._denominator !== undefined); }\r\n\r\n /**\r\n * Save this Constants 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): ConstantProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n if (this.phenomenon !== undefined)\r\n schemaJson.phenomenon = this.phenomenon.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 return schemaJson as ConstantProps;\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 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\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 return itemElement;\r\n }\r\n\r\n public override fromJSONSync(constantProps: ConstantProps) {\r\n super.fromJSONSync(constantProps);\r\n\r\n const schemaItemKey = this.schema.getSchemaItemKey(constantProps.phenomenon);\r\n if (!schemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\r\n this._phenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(schemaItemKey,\r\n async () => {\r\n const phenom = await this.schema.lookupItem<Phenomenon>(schemaItemKey);\r\n if (undefined === phenom)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\r\n return phenom;\r\n });\r\n\r\n if (this._definition !== \"\" && constantProps.definition.toLowerCase() !== this._definition.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${this.name} has an invalid 'definition' attribute.`);\r\n else if (this._definition === \"\")\r\n this._definition = constantProps.definition;\r\n\r\n if (undefined !== constantProps.numerator) {\r\n if (constantProps.numerator !== this._numerator)\r\n this._numerator = constantProps.numerator;\r\n }\r\n\r\n if (undefined !== constantProps.denominator) {\r\n if (constantProps.denominator !== this._denominator)\r\n this._denominator = constantProps.denominator;\r\n }\r\n }\r\n\r\n public override async fromJSON(constantProps: ConstantProps) {\r\n this.fromJSONSync(constantProps);\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n * @param phenomenon A LazyLoadedPhenomenon.\r\n */\r\n protected setPhenomenon(phenomenon: LazyLoadedPhenomenon) {\r\n this._phenomenon = phenomenon;\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n */\r\n protected setDefinition(definition: string) {\r\n this._definition = definition;\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n */\r\n protected setNumerator(numerator: number) {\r\n this._numerator = numerator;\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n */\r\n protected setDenominator(denominator: number) {\r\n this._denominator = denominator;\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableConstant extends Constant {\r\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): void;\r\n public abstract override setDefinition(definition: string): void;\r\n public abstract override setNumerator(numerator: number): void;\r\n public abstract override setDenominator(denominator: number): void;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"Constant.js","sourceRoot":"","sources":["../../../src/Metadata/Constant.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,UAAU;IACb,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;IAC3D,MAAM,KAAc,cAAc,KAAK,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrE,WAAW,CAAwB;IACnC,WAAW,CAAS;IACpB,UAAU,CAAU;IACpB,YAAY,CAAU;IAEhC,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,IAAW,UAAU,KAAuC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACtF,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5D,IAAW,SAAS,KAAa,OAAO,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC,CAAC;IACjE,IAAW,WAAW,KAAa,OAAO,IAAI,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC,CAAC;IACrE,IAAW,YAAY,KAAc,OAAO,CAAC,IAAI,CAAC,UAAU,KA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---------------------------------------------------------------------------------------------\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 { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { ConstantProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedPhenomenon } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { Phenomenon } from \"./Phenomenon\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Constant is a specific type of Unit that represents a number.\n * @beta\n */\nexport class Constant extends SchemaItem {\n public override readonly schemaItemType = Constant.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.Constant; }\n protected _phenomenon?: LazyLoadedPhenomenon;\n protected _definition: string;\n protected _numerator?: number;\n protected _denominator?: number;\n\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this._definition = \"\";\n }\n\n public get phenomenon(): LazyLoadedPhenomenon | undefined { return this._phenomenon; }\n public get definition(): string { return this._definition; }\n public get numerator(): number { return this._numerator ?? 1.0; }\n public get denominator(): number { return this._denominator ?? 1.0; }\n public get hasNumerator(): boolean { return (this._numerator !== undefined); }\n public get hasDenominator(): boolean { return (this._denominator !== undefined); }\n\n /**\n * Save this Constants 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 override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): ConstantProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.phenomenon !== undefined)\n schemaJson.phenomenon = this.phenomenon.fullName;\n schemaJson.definition = this.definition;\n if (this.hasNumerator)\n schemaJson.numerator = this.numerator;\n if (this.hasDenominator)\n schemaJson.denominator = this.denominator;\n return schemaJson as ConstantProps;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"definition\", this.definition);\n if (this.hasNumerator)\n itemElement.setAttribute(\"numerator\", this.numerator.toString());\n if (this.hasDenominator)\n itemElement.setAttribute(\"denominator\", this.denominator.toString());\n\n const phenomenon = await this.phenomenon;\n if (undefined !== phenomenon) {\n const phenomenonName = XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);\n itemElement.setAttribute(\"phenomenon\", phenomenonName);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(constantProps: ConstantProps) {\n super.fromJSONSync(constantProps);\n\n const schemaItemKey = this.schema.getSchemaItemKey(constantProps.phenomenon);\n if (!schemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\n this._phenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(schemaItemKey,\n async () => {\n const phenom = await this.schema.lookupItem(schemaItemKey, Phenomenon);\n if (undefined === phenom)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${constantProps.phenomenon}.`);\n return phenom;\n });\n\n if (this._definition !== \"\" && constantProps.definition.toLowerCase() !== this._definition.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${this.name} has an invalid 'definition' attribute.`);\n else if (this._definition === \"\")\n this._definition = constantProps.definition;\n\n if (undefined !== constantProps.numerator) {\n if (constantProps.numerator !== this._numerator)\n this._numerator = constantProps.numerator;\n }\n\n if (undefined !== constantProps.denominator) {\n if (constantProps.denominator !== this._denominator)\n this._denominator = constantProps.denominator;\n }\n }\n\n public override async fromJSON(constantProps: ConstantProps) {\n this.fromJSONSync(constantProps);\n }\n\n /**\n * @alpha Used in schema editing.\n * @param phenomenon A LazyLoadedPhenomenon.\n */\n protected setPhenomenon(phenomenon: LazyLoadedPhenomenon) {\n this._phenomenon = phenomenon;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDefinition(definition: string) {\n this._definition = definition;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setNumerator(numerator: number) {\n this._numerator = numerator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDenominator(denominator: number) {\n this._denominator = denominator;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type Constant.\n * @param item The SchemaItem to check.\n * @returns True if the item is a Constant, false otherwise.\n */\n public static isConstant(item?: SchemaItem): item is Constant {\n if (item && item.schemaItemType === SchemaItemType.Constant)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Constant.\n * @param item The SchemaItem to check.\n * @returns The item cast to Constant if it is a Constant, undefined otherwise.\n */\n public static assertIsConstant(item?: SchemaItem): asserts item is Constant {\n if (!this.isConstant(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Constant}' (Constant)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableConstant extends Constant {\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): void;\n public abstract override setDefinition(definition: string): void;\n public abstract override setNumerator(numerator: number): void;\n public abstract override setDenominator(denominator: number): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CustomAttribute.js","sourceRoot":"","sources":["../../../src/Metadata/CustomAttribute.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAwBH,gBAAgB;AAChB,MAAM,UAAU,yBAAyB,CAAC,gBAAgD;IACxF,IAAI,SAAS,KAAK,gBAAgB,EAAE,CAAC,CAAC,gCAAgC;QACpE,MAAM,UAAU,GAAU,EAAE,CAAC;QAC7B,KAAK,MAAM,CAAC,EAAE,eAAe,CAAC,IAAI,gBAAgB,EAAE,CAAC;YACnD,MAAM,SAAS,GAA6B,EAAE,CAAC;YAC/C,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE;gBACjD,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACzC,SAAS,CAAC,YAAY,CAAC,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;YACtD,CAAC,CAAC,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,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 { Schema } from \"./Schema\";\r\n\r\n/** @beta */\r\nexport interface CustomAttribute {\r\n className: string;\r\n [propName: string]: any;\r\n}\r\n\r\n/** @internal */\r\nexport interface CustomAttributeSet {\r\n [Symbol.iterator]: () => IterableIterator<[string, CustomAttribute]>;\r\n has(className: string): boolean;\r\n get(className: string): CustomAttribute | undefined;\r\n}\r\n\r\n/** @beta */\r\nexport interface CustomAttributeContainerProps {\r\n customAttributes?: CustomAttributeSet;\r\n fullName: string;\r\n schema: Schema;\r\n}\r\n\r\n/** @internal */\r\nexport function serializeCustomAttributes(customAttributes: CustomAttributeSet | undefined): any[] | undefined {\r\n if (undefined !== customAttributes) { // custom attributes is optional\r\n const attributes: any[] = [];\r\n for (const [, customAttribute] of customAttributes) {\r\n const attribute: { [value: string]: any } = {};\r\n Object.keys(customAttribute).map((property: any) => {\r\n const propertyName = property.toString();\r\n attribute[propertyName] = customAttribute[property];\r\n });\r\n attributes.push(attribute);\r\n }\r\n return (attributes.length > 0) ? attributes : undefined;\r\n }\r\n return undefined;\r\n}\r\n"]}
1
+ {"version":3,"file":"CustomAttribute.js","sourceRoot":"","sources":["../../../src/Metadata/CustomAttribute.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAwBH,gBAAgB;AAChB,MAAM,UAAU,yBAAyB,CAAC,gBAAgD;IACxF,IAAI,SAAS,KAAK,gBAAgB,EAAE,CAAC,CAAC,gCAAgC;QACpE,MAAM,UAAU,GAAU,EAAE,CAAC;QAC7B,KAAK,MAAM,CAAC,EAAE,eAAe,CAAC,IAAI,gBAAgB,EAAE,CAAC;YACnD,MAAM,SAAS,GAA6B,EAAE,CAAC;YAC/C,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE;gBACjD,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACzC,SAAS,CAAC,YAAY,CAAC,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;YACtD,CAAC,CAAC,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,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 { Schema } from \"./Schema\";\n\n/** @beta */\nexport interface CustomAttribute {\n className: string;\n [propName: string]: any;\n}\n\n/** @internal */\nexport interface CustomAttributeSet {\n [Symbol.iterator]: () => IterableIterator<[string, CustomAttribute]>;\n has(className: string): boolean;\n get(className: string): CustomAttribute | undefined;\n}\n\n/** @beta */\nexport interface CustomAttributeContainerProps {\n customAttributes?: CustomAttributeSet;\n fullName: string;\n schema: Schema;\n}\n\n/** @internal */\nexport function serializeCustomAttributes(customAttributes: CustomAttributeSet | undefined): any[] | undefined {\n if (undefined !== customAttributes) { // custom attributes is optional\n const attributes: any[] = [];\n for (const [, customAttribute] of customAttributes) {\n const attribute: { [value: string]: any } = {};\n Object.keys(customAttribute).map((property: any) => {\n const propertyName = property.toString();\n attribute[propertyName] = customAttribute[property];\n });\n attributes.push(attribute);\n }\n return (attributes.length > 0) ? attributes : undefined;\n }\n return undefined;\n}\n"]}
@@ -2,22 +2,22 @@
2
2
  * @module Metadata
3
3
  */
4
4
  import { CustomAttributeClassProps } from "../Deserialization/JsonProps";
5
- import { CustomAttributeContainerType, ECClassModifier, SchemaItemType } from "../ECObjects";
5
+ import { CustomAttributeContainerType, SchemaItemType } from "../ECObjects";
6
6
  import { ECClass } from "./Class";
7
- import { Schema } from "./Schema";
7
+ import { SchemaItem } from "./SchemaItem";
8
8
  /**
9
9
  * A Typescript class representation of an ECCustomAttributeClass.
10
10
  * @beta
11
11
  */
12
12
  export declare class CustomAttributeClass extends ECClass {
13
- readonly schemaItemType: SchemaItemType.CustomAttributeClass;
13
+ readonly schemaItemType: SchemaItemType;
14
+ static get schemaItemType(): SchemaItemType;
14
15
  protected _appliesTo?: CustomAttributeContainerType;
15
16
  /**
16
17
  * @deprecated in 4.8 use [[appliesTo]]
17
18
  * */
18
19
  get containerType(): CustomAttributeContainerType;
19
20
  get appliesTo(): CustomAttributeContainerType;
20
- constructor(schema: Schema, name: string, modifier?: ECClassModifier);
21
21
  /**
22
22
  * Save this CustomAttributeClasses properties to an object for serializing to JSON.
23
23
  * @param standalone Serialization includes only this object (as opposed to the full schema).
@@ -32,6 +32,18 @@ export declare class CustomAttributeClass extends ECClass {
32
32
  * @alpha Used in schema editing.
33
33
  */
34
34
  protected setAppliesTo(containerType: CustomAttributeContainerType): void;
35
+ /**
36
+ * Type guard to check if the SchemaItem is of type CustomAttributeClass.
37
+ * @param item The SchemaItem to check.
38
+ * @returns True if the item is a CustomAttributeClass, false otherwise.
39
+ */
40
+ static isCustomAttributeClass(item?: SchemaItem): item is CustomAttributeClass;
41
+ /**
42
+ * Type assertion to check if the SchemaItem is of type CustomAttributeClass.
43
+ * @param item The SchemaItem to check.
44
+ * @returns The item cast to CustomAttributeClass if it is a CustomAttributeClass, undefined otherwise.
45
+ */
46
+ static assertIsCustomAttributeClass(item?: SchemaItem): asserts item is CustomAttributeClass;
35
47
  }
36
48
  /**
37
49
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"CustomAttributeClass.d.ts","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EACkB,4BAA4B,EAAE,eAAe,EAAqC,cAAc,EACxH,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,OAAO;IAC/C,SAAyB,cAAc,EAAG,cAAc,CAAC,oBAAoB,CAAC;IAC9E,SAAS,CAAC,UAAU,CAAC,EAAE,4BAA4B,CAAC;IAEpD;;SAEK;IACL,IAAW,aAAa,IAAI,4BAA4B,CAEvD;IAED,IAAW,SAAS,IAAI,4BAA4B,CAInD;gBAEW,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe;IAKpE;;;;OAIG;IACa,MAAM,CAAC,UAAU,GAAE,OAAe,EAAE,oBAAoB,GAAE,OAAe,GAAG,yBAAyB;IAMrH,gBAAgB;IACM,KAAK,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,C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AIG;WACW,sBAAsB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,oBAAoB;IAOrF;;;;OAIG;WACW,4BAA4B,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,oBAAoB;CAIpG;AACD;;;GAGG;AACH,8BAAsB,cAAe,SAAQ,oBAAoB;aACtC,YAAY,CAAC,aAAa,EAAE,4BAA4B,GAAG,IAAI;aAC/D,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -13,6 +13,9 @@ import { ECClass } from "./Class";
13
13
  * @beta
14
14
  */
15
15
  export class CustomAttributeClass extends ECClass {
16
+ schemaItemType = CustomAttributeClass.schemaItemType;
17
+ static get schemaItemType() { return SchemaItemType.CustomAttributeClass; }
18
+ _appliesTo;
16
19
  /**
17
20
  * @deprecated in 4.8 use [[appliesTo]]
18
21
  * */
@@ -24,10 +27,6 @@ export class CustomAttributeClass extends ECClass {
24
27
  throw new ECObjectsError(ECObjectsStatus.InvalidContainerType, `The CustomAttributeClass ${this.name} does not have a CustomAttributeContainerType.`);
25
28
  return this._appliesTo;
26
29
  }
27
- constructor(schema, name, modifier) {
28
- super(schema, name, modifier);
29
- this.schemaItemType = SchemaItemType.CustomAttributeClass;
30
- }
31
30
  /**
32
31
  * Save this CustomAttributeClasses properties to an object for serializing to JSON.
33
32
  * @param standalone Serialization includes only this object (as opposed to the full schema).
@@ -60,6 +59,25 @@ export class CustomAttributeClass extends ECClass {
60
59
  setAppliesTo(containerType) {
61
60
  this._appliesTo = containerType;
62
61
  }
62
+ /**
63
+ * Type guard to check if the SchemaItem is of type CustomAttributeClass.
64
+ * @param item The SchemaItem to check.
65
+ * @returns True if the item is a CustomAttributeClass, false otherwise.
66
+ */
67
+ static isCustomAttributeClass(item) {
68
+ if (item && item.schemaItemType === SchemaItemType.CustomAttributeClass)
69
+ return true;
70
+ return false;
71
+ }
72
+ /**
73
+ * Type assertion to check if the SchemaItem is of type CustomAttributeClass.
74
+ * @param item The SchemaItem to check.
75
+ * @returns The item cast to CustomAttributeClass if it is a CustomAttributeClass, undefined otherwise.
76
+ */
77
+ static assertIsCustomAttributeClass(item) {
78
+ if (!this.isCustomAttributeClass(item))
79
+ throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.CustomAttributeClass}' (CustomAttributeClass)`);
80
+ }
63
81
  }
64
82
  /**
65
83
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"CustomAttributeClass.js","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EACL,qBAAqB,EAAiD,iCAAiC,EAAE,cAAc,GACxH,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,OAAO;IAI/C;;SAEK;IACL,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAW,SAAS;QAClB,IAAI,SAAS,KAAK,IAAI,CAAC,UAAU;YAC/B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,oBAAoB,EAAE,4BAA4B,IAAI,CAAC,IAAI,gDAAgD,CAAC,CAAC;QACxJ,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,YAAY,MAAc,EAAE,IAAY,EAAE,QAA0B;QAClE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC,oBAAoB,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACa,MAAM,CAAC,aAAsB,KAAK,EAAE,uBAAgC,KAAK;QACvF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,oBAAoB,CAAQ,CAAC;QACzE,UAAU,CAAC,SAAS,GAAG,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7D,OAAO,UAAuC,CAAC;IACjD,CAAC;IAED,gBAAgB;IACA,KAAK,CAAC,KAAK,CAAC,SAAmB;QAC7C,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACjD,WAAW,CAAC,YAAY,CAAC,WAAW,EAAE,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QAC7E,OAAO,WAAW,CAAC;IACrB,CAAC;IAEe,YAAY,CAAC,oBAA+C;QAC1E,KAAK,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;QACzC,MAAM,SAAS,GAAG,iCAAiC,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;QACpF,IAAI,SAAS,KAAK,SAAS;YACzB,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,oBAAoB,EAAE,GAAG,SAAS,+CAA+C,CAAC,CAAC;QAC9H,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,oBAA+C;QAC5E,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,aAA2C;QAChE,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC;IAClC,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,cAAe,SAAQ,oBAAoB;CAGhE","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 { CustomAttributeClassProps } from \"../Deserialization/JsonProps\";\r\nimport {\r\n containerTypeToString, CustomAttributeContainerType, ECClassModifier, parseCustomAttributeContainerType, SchemaItemType,\r\n} from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { ECClass } from \"./Class\";\r\nimport { Schema } from \"./Schema\";\r\n\r\n/**\r\n * A Typescript class representation of an ECCustomAttributeClass.\r\n * @beta\r\n */\r\nexport class CustomAttributeClass extends ECClass {\r\n public override readonly schemaItemType!: SchemaItemType.CustomAttributeClass;\r\n protected _appliesTo?: CustomAttributeContainerType;\r\n\r\n /**\r\n * @deprecated in 4.8 use [[appliesTo]]\r\n * */\r\n public get containerType(): CustomAttributeContainerType {\r\n return this.appliesTo;\r\n }\r\n\r\n public get appliesTo(): CustomAttributeContainerType {\r\n if (undefined === this._appliesTo)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidContainerType, `The CustomAttributeClass ${this.name} does not have a CustomAttributeContainerType.`);\r\n return this._appliesTo;\r\n }\r\n\r\n constructor(schema: Schema, name: string, modifier?: ECClassModifier) {\r\n super(schema, name, modifier);\r\n this.schemaItemType = SchemaItemType.CustomAttributeClass;\r\n }\r\n\r\n /**\r\n * Save this CustomAttributeClasses 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): CustomAttributeClassProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.appliesTo = containerTypeToString(this.appliesTo);\r\n return schemaJson as CustomAttributeClassProps;\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 itemElement.setAttribute(\"appliesTo\", containerTypeToString(this.appliesTo));\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(customAttributeProps: CustomAttributeClassProps) {\r\n super.fromJSONSync(customAttributeProps);\r\n const appliesTo = parseCustomAttributeContainerType(customAttributeProps.appliesTo);\r\n if (undefined === appliesTo)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidContainerType, `${appliesTo} is not a valid CustomAttributeContainerType.`);\r\n this._appliesTo = appliesTo;\r\n }\r\n\r\n public override async fromJSON(customAttributeProps: CustomAttributeClassProps) {\r\n this.fromJSONSync(customAttributeProps);\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n */\r\n protected setAppliesTo(containerType: CustomAttributeContainerType) {\r\n this._appliesTo = containerType;\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for Schema editing.\r\n */\r\nexport abstract class MutableCAClass extends CustomAttributeClass {\r\n public abstract override setAppliesTo(containerType: CustomAttributeContainerType): void;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"CustomAttributeClass.js","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EACL,qBAAqB,EAAgC,iCAAiC,EAAE,cAAc,GACvG,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,OAAO;IACtB,cAAc,GAAG,oBAAoB,CAAC,cAAc,CAAC;IACvE,MAAM,KAAc,cAAc,KAAK,OAAO,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAC;IACjF,UAAU,CAAgC;IAEpD;;SAEK;IACL,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAW,SAAS;QAClB,IAAI,SAAS,KAAK,IAAI,CAAC,UAAU;YAC/B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,oBAAoB,EAAE,4BAA4B,IAAI,CAAC,IAAI,gDAAgD,CAA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AC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,4BAA4B,CAAC,IAAiB;QAC1D,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC;YACpC,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,oBAAoB,0BAA0B,CAAC,CAAC;IAChJ,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,cAAe,SAAQ,oBAAoB;CAGhE","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 { CustomAttributeClassProps } from \"../Deserialization/JsonProps\";\nimport {\n containerTypeToString, CustomAttributeContainerType, parseCustomAttributeContainerType, SchemaItemType,\n} from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { ECClass } from \"./Class\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of an ECCustomAttributeClass.\n * @beta\n */\nexport class CustomAttributeClass extends ECClass {\n public override readonly schemaItemType = CustomAttributeClass.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.CustomAttributeClass; }\n protected _appliesTo?: CustomAttributeContainerType;\n\n /**\n * @deprecated in 4.8 use [[appliesTo]]\n * */\n public get containerType(): CustomAttributeContainerType {\n return this.appliesTo;\n }\n\n public get appliesTo(): CustomAttributeContainerType {\n if (undefined === this._appliesTo)\n throw new ECObjectsError(ECObjectsStatus.InvalidContainerType, `The CustomAttributeClass ${this.name} does not have a CustomAttributeContainerType.`);\n return this._appliesTo;\n }\n\n /**\n * Save this CustomAttributeClasses 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 override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): CustomAttributeClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.appliesTo = containerTypeToString(this.appliesTo);\n return schemaJson as CustomAttributeClassProps;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"appliesTo\", containerTypeToString(this.appliesTo));\n return itemElement;\n }\n\n public override fromJSONSync(customAttributeProps: CustomAttributeClassProps) {\n super.fromJSONSync(customAttributeProps);\n const appliesTo = parseCustomAttributeContainerType(customAttributeProps.appliesTo);\n if (undefined === appliesTo)\n throw new ECObjectsError(ECObjectsStatus.InvalidContainerType, `${appliesTo} is not a valid CustomAttributeContainerType.`);\n this._appliesTo = appliesTo;\n }\n\n public override async fromJSON(customAttributeProps: CustomAttributeClassProps) {\n this.fromJSONSync(customAttributeProps);\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setAppliesTo(containerType: CustomAttributeContainerType) {\n this._appliesTo = containerType;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type CustomAttributeClass.\n * @param item The SchemaItem to check.\n * @returns True if the item is a CustomAttributeClass, false otherwise.\n */\n public static isCustomAttributeClass(item?: SchemaItem): item is CustomAttributeClass {\n if (item && item.schemaItemType === SchemaItemType.CustomAttributeClass)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type CustomAttributeClass.\n * @param item The SchemaItem to check.\n * @returns The item cast to CustomAttributeClass if it is a CustomAttributeClass, undefined otherwise.\n */\n public static assertIsCustomAttributeClass(item?: SchemaItem): asserts item is CustomAttributeClass {\n if (!this.isCustomAttributeClass(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.CustomAttributeClass}' (CustomAttributeClass)`);\n }\n}\n/**\n * @internal\n * An abstract class used for Schema editing.\n */\nexport abstract class MutableCAClass extends CustomAttributeClass {\n public abstract override setAppliesTo(containerType: CustomAttributeContainerType): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
@@ -2,21 +2,21 @@
2
2
  * @module Metadata
3
3
  */
4
4
  import { EntityClassProps } from "../Deserialization/JsonProps";
5
- import { ECClassModifier, SchemaItemType, StrengthDirection } from "../ECObjects";
6
- import { LazyLoadedMixin } from "../Interfaces";
5
+ import { SchemaItemType, StrengthDirection } from "../ECObjects";
6
+ import { HasMixins, LazyLoadedMixin } from "../Interfaces";
7
7
  import { ECClass } from "./Class";
8
8
  import { Mixin } from "./Mixin";
9
9
  import { AnyProperty, NavigationProperty, Property } from "./Property";
10
10
  import { RelationshipClass } from "./RelationshipClass";
11
- import { Schema } from "./Schema";
11
+ import { SchemaItem } from "./SchemaItem";
12
12
  /**
13
13
  * A Typescript class representation of an ECEntityClass.
14
14
  * @beta
15
15
  */
16
- export declare class EntityClass extends ECClass {
17
- readonly schemaItemType: SchemaItemType.EntityClass;
16
+ export declare class EntityClass extends ECClass implements HasMixins {
17
+ readonly schemaItemType: SchemaItemType;
18
+ static get schemaItemType(): SchemaItemType;
18
19
  protected _mixins?: LazyLoadedMixin[];
19
- constructor(schema: Schema, name: string, modifier?: ECClassModifier);
20
20
  get mixins(): LazyLoadedMixin[];
21
21
  getMixinsSync(): Iterable<Mixin>;
22
22
  /**
@@ -34,8 +34,8 @@ export declare class EntityClass extends ECClass {
34
34
  * @param name The name of the property to find.
35
35
  */
36
36
  getInheritedPropertySync(name: string): Property | undefined;
37
- protected buildPropertyCache(result: Property[], existingValues?: Map<string, number>, resetBaseCaches?: boolean): Promise<void>;
38
- protected buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>, resetBaseCaches?: boolean): void;
37
+ protected buildPropertyCache(result: Property[], existingValues?: Map<string, number>): Promise<void>;
38
+ protected buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>): void;
39
39
  /**
40
40
  *
41
41
  * @param name
@@ -60,6 +60,18 @@ export declare class EntityClass extends ECClass {
60
60
  toXml(schemaXml: Document): Promise<Element>;
61
61
  fromJSON(entityClassProps: EntityClassProps): Promise<void>;
62
62
  fromJSONSync(entityClassProps: EntityClassProps): void;
63
+ /**
64
+ * Type guard to check if the SchemaItem is of type EntityClass.
65
+ * @param item The SchemaItem to check.
66
+ * @returns True if the item is an EntityClass, false otherwise.
67
+ */
68
+ static isEntityClass(item?: SchemaItem): item is EntityClass;
69
+ /**
70
+ * Type assertion to check if the SchemaItem is of type EntityClass.
71
+ * @param item The SchemaItem to check.
72
+ * @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.
73
+ */
74
+ static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass;
63
75
  }
64
76
  /**
65
77
  * Hackish approach that works like a "friend class" so we can access protected members without making them public.
@@ -1 +1 @@
1
- {"version":3,"file":"EntityClass.d.ts","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAAE,eAAe,EAA0B,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE1G,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;GAGG;AACH,qBAAa,WAAY,SAAQ,OAAO;IACtC,SAAyB,cAAc,EAAG,cAAc,CAAC,WAAW,CAAC;IACrE,SAAS,CAAC,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;gBAE1B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,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E,MAAM,GAAG,iBAAiB,GAAG,kBAAkB,CAsBhL"}
@@ -10,16 +10,17 @@ import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils"
10
10
  import { parseStrengthDirection, SchemaItemType } from "../ECObjects";
11
11
  import { ECObjectsError, ECObjectsStatus } from "../Exception";
12
12
  import { ECClass } from "./Class";
13
+ import { Mixin } from "./Mixin";
13
14
  import { NavigationProperty } from "./Property";
15
+ import { RelationshipClass } from "./RelationshipClass";
14
16
  /**
15
17
  * A Typescript class representation of an ECEntityClass.
16
18
  * @beta
17
19
  */
18
20
  export class EntityClass extends ECClass {
19
- constructor(schema, name, modifier) {
20
- super(schema, name, modifier);
21
- this.schemaItemType = SchemaItemType.EntityClass;
22
- }
21
+ schemaItemType = EntityClass.schemaItemType;
22
+ static get schemaItemType() { return SchemaItemType.EntityClass; }
23
+ _mixins;
23
24
  get mixins() {
24
25
  if (!this._mixins)
25
26
  return [];
@@ -29,7 +30,7 @@ export class EntityClass extends ECClass {
29
30
  if (!this._mixins)
30
31
  return function* () { }(); // empty iterable
31
32
  for (const mixin of this._mixins) {
32
- const mObj = this.schema.lookupItemSync(mixin);
33
+ const mObj = this.schema.lookupItemSync(mixin, Mixin);
33
34
  if (mObj) {
34
35
  yield mObj;
35
36
  }
@@ -73,7 +74,7 @@ export class EntityClass extends ECClass {
73
74
  }
74
75
  for (const mixin of this._mixins) {
75
76
  const mObj = this.schema.lookupItemSync(mixin);
76
- if (mObj) {
77
+ if (mObj && ECClass.isECClass(mObj)) {
77
78
  const result = mObj.getPropertySync(name, true);
78
79
  if (result) {
79
80
  return result;
@@ -82,34 +83,34 @@ export class EntityClass extends ECClass {
82
83
  }
83
84
  return undefined;
84
85
  }
85
- async buildPropertyCache(result, existingValues, resetBaseCaches = false) {
86
+ async buildPropertyCache(result, existingValues) {
86
87
  if (!existingValues) {
87
88
  existingValues = new Map();
88
89
  }
89
- if (this.baseClass) {
90
- ECClass.mergeProperties(result, existingValues, await (await this.baseClass).getProperties(resetBaseCaches), false);
90
+ const baseClass = await this.baseClass;
91
+ if (baseClass) {
92
+ ECClass.mergeProperties(result, existingValues, await baseClass.getProperties(), false);
91
93
  }
92
94
  for (const mixin of this.mixins) {
93
- ECClass.mergeProperties(result, existingValues, await (await mixin).getProperties(resetBaseCaches), false);
95
+ const resolvedMixin = await mixin;
96
+ ECClass.mergeProperties(result, existingValues, await resolvedMixin.getProperties(), false);
94
97
  }
95
- if (!this.properties)
96
- return;
97
- ECClass.mergeProperties(result, existingValues, [...this.properties], true);
98
+ const localProps = await this.getProperties(true);
99
+ ECClass.mergeProperties(result, existingValues, localProps, true);
98
100
  }
99
- buildPropertyCacheSync(result, existingValues, resetBaseCaches = false) {
101
+ buildPropertyCacheSync(result, existingValues) {
100
102
  if (!existingValues) {
101
103
  existingValues = new Map();
102
104
  }
103
105
  const baseClass = this.getBaseClassSync();
104
106
  if (baseClass) {
105
- ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(resetBaseCaches), false);
107
+ ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(), false);
106
108
  }
107
109
  for (const mixin of this.getMixinsSync()) {
108
- ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(resetBaseCaches), false);
110
+ ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(), false);
109
111
  }
110
- if (!this.properties)
111
- return;
112
- ECClass.mergeProperties(result, existingValues, [...this.properties], true);
112
+ const localProps = this.getPropertiesSync(true);
113
+ ECClass.mergeProperties(result, existingValues, localProps, true);
113
114
  }
114
115
  /**
115
116
  *
@@ -164,7 +165,7 @@ export class EntityClass extends ECClass {
164
165
  if (!mixinSchemaItemKey)
165
166
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
166
167
  this._mixins.push(new DelayedPromiseWithProps(mixinSchemaItemKey, async () => {
167
- const mixin = await this.schema.lookupItem(mixinSchemaItemKey);
168
+ const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin);
168
169
  if (undefined === mixin)
169
170
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
170
171
  return mixin;
@@ -172,6 +173,25 @@ export class EntityClass extends ECClass {
172
173
  }
173
174
  }
174
175
  }
176
+ /**
177
+ * Type guard to check if the SchemaItem is of type EntityClass.
178
+ * @param item The SchemaItem to check.
179
+ * @returns True if the item is an EntityClass, false otherwise.
180
+ */
181
+ static isEntityClass(item) {
182
+ if (item && item.schemaItemType === SchemaItemType.EntityClass)
183
+ return true;
184
+ return false;
185
+ }
186
+ /**
187
+ * Type assertion to check if the SchemaItem is of type EntityClass.
188
+ * @param item The SchemaItem to check.
189
+ * @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.
190
+ */
191
+ static assertIsEntityClass(item) {
192
+ if (!this.isEntityClass(item))
193
+ throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.EntityClass}' (EntityClass)`);
194
+ }
175
195
  }
176
196
  /**
177
197
  * Hackish approach that works like a "friend class" so we can access protected members without making them public.
@@ -185,7 +205,7 @@ export async function createNavigationProperty(ecClass, name, relationship, dire
185
205
  throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
186
206
  let resolvedRelationship;
187
207
  if (typeof (relationship) === "string") {
188
- resolvedRelationship = await ecClass.schema.lookupItem(relationship);
208
+ resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass);
189
209
  }
190
210
  else
191
211
  resolvedRelationship = relationship;
@@ -206,7 +226,7 @@ export function createNavigationPropertySync(ecClass, name, relationship, direct
206
226
  throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
207
227
  let resolvedRelationship;
208
228
  if (typeof (relationship) === "string") {
209
- resolvedRelationship = ecClass.schema.lookupItemSync(relationship);
229
+ resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass);
210
230
  }
211
231
  else
212
232
  resolvedRelationship = relationship;
@@ -1 +1 @@
1
- {"version":3,"file":"EntityClass.js","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAmB,sBAAsB,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAe,kBAAkB,EAAY,MAAM,YAAY,CAAC;AAIvE;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO;IAItC,YAAY,MAAc,EAAE,IAAY,EAAE,QAA0B;QAClE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC,WAAW,CAAC;IACnD,CAAC;IAED,IAAW,MAAM;QACf,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,OAAO,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,CAAC,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,OAAO,QAAQ,CAAC,MAAuB,CAAC,EAAE,CAAC,CAAC,iBAAiB;QAE/D,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAQ,KAAK,CAAC,CAAC;YACtD,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,IAAI,CAAC;YACb,CAAC;QACH,CAAC;IACH,CAA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B,GAAG,IAAI,uBAAuB,CAAC,oBAAoB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC;IACjH,OAAO,IAAI,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC5E,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 { DelayedPromiseWithProps } from \"../DelayedPromise\";\r\nimport { EntityClassProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { ECClassModifier, parseStrengthDirection, SchemaItemType, StrengthDirection } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedMixin } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { ECClass } from \"./Class\";\r\nimport { Mixin } from \"./Mixin\";\r\nimport { AnyProperty, NavigationProperty, Property } from \"./Property\";\r\nimport { RelationshipClass } from \"./RelationshipClass\";\r\nimport { Schema } from \"./Schema\";\r\n\r\n/**\r\n * A Typescript class representation of an ECEntityClass.\r\n * @beta\r\n */\r\nexport class EntityClass extends ECClass {\r\n public override readonly schemaItemType!: SchemaItemType.EntityClass;\r\n protected _mixins?: LazyLoadedMixin[];\r\n\r\n constructor(schema: Schema, name: string, modifier?: ECClassModifier) {\r\n super(schema, name, modifier);\r\n this.schemaItemType = SchemaItemType.EntityClass;\r\n }\r\n\r\n public get mixins(): LazyLoadedMixin[] {\r\n if (!this._mixins)\r\n return [];\r\n return this._mixins;\r\n }\r\n\r\n public *getMixinsSync(): Iterable<Mixin> {\r\n if (!this._mixins)\r\n return function* (): Iterable<Mixin> { }(); // empty iterable\r\n\r\n for (const mixin of this._mixins) {\r\n const mObj = this.schema.lookupItemSync<Mixin>(mixin);\r\n if (mObj) {\r\n yield mObj;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @param mixin\r\n */\r\n protected addMixin(mixin: Mixin) {\r\n if (!this._mixins)\r\n this._mixins = [];\r\n\r\n this._mixins.push(new DelayedPromiseWithProps(mixin.key, async () => mixin));\r\n return;\r\n }\r\n\r\n /**\r\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\r\n * @param name The name of the property to find.\r\n */\r\n public override async getInheritedProperty(name: string): Promise<AnyProperty | undefined> {\r\n let inheritedProperty = await super.getInheritedProperty(name);\r\n\r\n if (!inheritedProperty && this._mixins) {\r\n const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));\r\n mixinProps.some((prop) => {\r\n inheritedProperty = prop as AnyProperty;\r\n return inheritedProperty !== undefined;\r\n });\r\n }\r\n\r\n return inheritedProperty as AnyProperty | undefined;\r\n }\r\n\r\n /**\r\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\r\n * @param name The name of the property to find.\r\n */\r\n public override getInheritedPropertySync(name: string): Property | undefined {\r\n const inheritedProperty = super.getInheritedPropertySync(name);\r\n if (inheritedProperty)\r\n return inheritedProperty;\r\n\r\n if (!this._mixins) {\r\n return undefined;\r\n }\r\n\r\n for (const mixin of this._mixins) {\r\n const mObj = this.schema.lookupItemSync<ECClass>(mixin);\r\n if (mObj) {\r\n const result = mObj.getPropertySync(name, true);\r\n if (result) {\r\n return result;\r\n }\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n protected override async buildPropertyCache(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): Promise<void> {\r\n if (!existingValues) {\r\n existingValues = new Map<string, number>();\r\n }\r\n\r\n if (this.baseClass) {\r\n ECClass.mergeProperties(result, existingValues, await (await this.baseClass).getProperties(resetBaseCaches), false);\r\n }\r\n\r\n for (const mixin of this.mixins) {\r\n ECClass.mergeProperties(result, existingValues, await (await mixin).getProperties(resetBaseCaches), false);\r\n }\r\n\r\n if (!this.properties)\r\n return;\r\n\r\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\r\n }\r\n\r\n protected override buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): void {\r\n if (!existingValues) {\r\n existingValues = new Map<string, number>();\r\n }\r\n\r\n const baseClass = this.getBaseClassSync();\r\n if (baseClass) {\r\n ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(resetBaseCaches), false);\r\n }\r\n\r\n for (const mixin of this.getMixinsSync()) {\r\n ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(resetBaseCaches), false);\r\n }\r\n\r\n if (!this.properties)\r\n return;\r\n\r\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param relationship\r\n * @param direction\r\n */\r\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\r\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param relationship\r\n * @param direction\r\n */\r\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\r\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\r\n }\r\n\r\n /**\r\n * Save this EntityClass' 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): EntityClassProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n if (this.mixins.length > 0)\r\n schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);\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 for (const mixin of this.getMixinsSync()) {\r\n const mixinElement = schemaXml.createElement(\"BaseClass\");\r\n const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);\r\n mixinElement.textContent = mixinName;\r\n itemElement.appendChild(mixinElement);\r\n }\r\n return itemElement;\r\n }\r\n\r\n public override async fromJSON(entityClassProps: EntityClassProps) {\r\n this.fromJSONSync(entityClassProps);\r\n }\r\n\r\n public override fromJSONSync(entityClassProps: EntityClassProps) {\r\n super.fromJSONSync(entityClassProps);\r\n\r\n if (undefined !== entityClassProps.mixins) {\r\n if (!this._mixins)\r\n this._mixins = [];\r\n for (const name of entityClassProps.mixins) {\r\n const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);\r\n if (!mixinSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\r\n this._mixins.push(new DelayedPromiseWithProps<SchemaItemKey, Mixin>(mixinSchemaItemKey,\r\n async () => {\r\n const mixin = await this.schema.lookupItem<Mixin>(mixinSchemaItemKey);\r\n if (undefined === mixin)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\r\n return mixin;\r\n }));\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\r\n * @internal\r\n */\r\nexport abstract class MutableEntityClass extends EntityClass {\r\n public abstract override addMixin(mixin: Mixin): any;\r\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\r\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n\r\n/** @internal */\r\nexport async function createNavigationProperty(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\r\n if (await ecClass.getProperty(name))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\r\n\r\n let resolvedRelationship: RelationshipClass | undefined;\r\n if (typeof (relationship) === \"string\") {\r\n resolvedRelationship = await ecClass.schema.lookupItem<RelationshipClass>(relationship);\r\n } else\r\n resolvedRelationship = relationship;\r\n\r\n if (!resolvedRelationship)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\r\n\r\n if (typeof (direction) === \"string\") {\r\n const tmpDirection = parseStrengthDirection(direction);\r\n if (undefined === tmpDirection)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\r\n direction = tmpDirection;\r\n }\r\n\r\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\r\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\r\n}\r\n\r\n/** @internal */\r\nexport function createNavigationPropertySync(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\r\n if (ecClass.getPropertySync(name))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\r\n\r\n let resolvedRelationship: RelationshipClass | undefined;\r\n if (typeof (relationship) === \"string\") {\r\n resolvedRelationship = ecClass.schema.lookupItemSync<RelationshipClass>(relationship);\r\n } else\r\n resolvedRelationship = relationship;\r\n\r\n if (!resolvedRelationship)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\r\n\r\n if (typeof (direction) === \"string\") {\r\n const tmpDirection = parseStrengthDirection(direction);\r\n if (undefined === tmpDirection)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\r\n direction = tmpDirection;\r\n }\r\n\r\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\r\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\r\n}\r\n"]}
1
+ {"version":3,"file":"EntityClass.js","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAe,kBAAkB,EAAY,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO;IACb,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IAC9D,MAAM,KAAc,cAAc,KAAK,OAAO,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC;IACxE,OAAO,CAAqB;IAEtC,IAAW,MAAM;QACf,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,OAAO,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,CAAC,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,OAAO,QAAQ,CAAC,MAAuB,CAAC,EAAE,CA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AAC,CAAC;IAElJ,IAAI,oBAAmD,CAAC;IACxD,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,QAAQ,EAAE,CAAC;QACvC,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IACxF,CAAC;;QACC,oBAAoB,GAAG,YAAY,CAAC;IAEtC,IAAI,CAAC,oBAAoB;QACvB,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,WAAW,EAAE,mCAAmC,YAAY,8CAA8C,CAAC,CAAC,CAAE,2DAA2D;IAEpN,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,YAAY,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,SAAS,KAAK,YAAY;YAC5B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,wBAAwB,EAAE,mCAAmC,SAAS,qCAAqC,CAAC,CAAC;QACxJ,SAAS,GAAG,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,gBAAgB,GAAG,IAAI,uBAAuB,CAAC,oBAAoB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC;IACjH,OAAO,IAAI,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC5E,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 { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { EntityClassProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { parseStrengthDirection, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { HasMixins, LazyLoadedMixin } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { Mixin } from \"./Mixin\";\nimport { AnyProperty, NavigationProperty, Property } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of an ECEntityClass.\n * @beta\n */\nexport class EntityClass extends ECClass implements HasMixins {\n public override readonly schemaItemType = EntityClass.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.EntityClass; }\n protected _mixins?: LazyLoadedMixin[];\n\n public get mixins(): LazyLoadedMixin[] {\n if (!this._mixins)\n return [];\n return this._mixins;\n }\n\n public *getMixinsSync(): Iterable<Mixin> {\n if (!this._mixins)\n return function* (): Iterable<Mixin> { }(); // empty iterable\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin, Mixin);\n if (mObj) {\n yield mObj;\n }\n }\n }\n\n /**\n *\n * @param mixin\n */\n protected addMixin(mixin: Mixin) {\n if (!this._mixins)\n this._mixins = [];\n\n this._mixins.push(new DelayedPromiseWithProps(mixin.key, async () => mixin));\n return;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override async getInheritedProperty(name: string): Promise<AnyProperty | undefined> {\n let inheritedProperty = await super.getInheritedProperty(name);\n\n if (!inheritedProperty && this._mixins) {\n const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));\n mixinProps.some((prop) => {\n inheritedProperty = prop as AnyProperty;\n return inheritedProperty !== undefined;\n });\n }\n\n return inheritedProperty as AnyProperty | undefined;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override getInheritedPropertySync(name: string): Property | undefined {\n const inheritedProperty = super.getInheritedPropertySync(name);\n if (inheritedProperty)\n return inheritedProperty;\n\n if (!this._mixins) {\n return undefined;\n }\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin);\n if (mObj && ECClass.isECClass(mObj)) {\n const result = mObj.getPropertySync(name, true);\n if (result) {\n return result;\n }\n }\n }\n\n return undefined;\n }\n\n protected override async buildPropertyCache(result: Property[], existingValues?: Map<string, number>): Promise<void> {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n const baseClass = await this.baseClass;\n if(baseClass) {\n ECClass.mergeProperties(result, existingValues, await baseClass.getProperties(), false);\n }\n\n for (const mixin of this.mixins) {\n const resolvedMixin = await mixin;\n ECClass.mergeProperties(result, existingValues, await resolvedMixin.getProperties(), false);\n }\n\n const localProps = await this.getProperties(true);\n ECClass.mergeProperties(result, existingValues, localProps, true);\n }\n\n protected override buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>): void {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n const baseClass = this.getBaseClassSync();\n if (baseClass) {\n ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(), false);\n }\n\n for (const mixin of this.getMixinsSync()) {\n ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(), false);\n }\n\n const localProps = this.getPropertiesSync(true);\n ECClass.mergeProperties(result, existingValues, localProps, true);\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n */\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * Save this EntityClass' 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 override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EntityClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.mixins.length > 0)\n schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n for (const mixin of this.getMixinsSync()) {\n const mixinElement = schemaXml.createElement(\"BaseClass\");\n const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);\n mixinElement.textContent = mixinName;\n itemElement.appendChild(mixinElement);\n }\n return itemElement;\n }\n\n public override async fromJSON(entityClassProps: EntityClassProps) {\n this.fromJSONSync(entityClassProps);\n }\n\n public override fromJSONSync(entityClassProps: EntityClassProps) {\n super.fromJSONSync(entityClassProps);\n\n if (undefined !== entityClassProps.mixins) {\n if (!this._mixins)\n this._mixins = [];\n for (const name of entityClassProps.mixins) {\n const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);\n if (!mixinSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n this._mixins.push(new DelayedPromiseWithProps<SchemaItemKey, Mixin>(mixinSchemaItemKey,\n async () => {\n const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin);\n if (undefined === mixin)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n return mixin;\n }));\n }\n }\n }\n\n /**\n * Type guard to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns True if the item is an EntityClass, false otherwise.\n */\n public static isEntityClass(item?: SchemaItem): item is EntityClass {\n if (item && item.schemaItemType === SchemaItemType.EntityClass)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.\n */\n public static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass {\n if(!this.isEntityClass(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.EntityClass}' (EntityClass)`);\n }\n}\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableEntityClass extends EntityClass {\n public abstract override addMixin(mixin: Mixin): any;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n\n/** @internal */\nexport async function createNavigationProperty(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n if (await ecClass.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n\n/** @internal */\nexport function createNavigationPropertySync(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n if (ecClass.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n"]}