@itwin/ecschema-metadata 5.0.0-dev.10 → 5.0.0-dev.102

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 (294) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/lib/cjs/Constants.d.ts +8 -0
  3. package/lib/cjs/Constants.d.ts.map +1 -1
  4. package/lib/cjs/Constants.js +30 -21
  5. package/lib/cjs/Constants.js.map +1 -1
  6. package/lib/cjs/Context.d.ts +83 -34
  7. package/lib/cjs/Context.d.ts.map +1 -1
  8. package/lib/cjs/Context.js +73 -23
  9. package/lib/cjs/Context.js.map +1 -1
  10. package/lib/cjs/DelayedPromise.js +6 -4
  11. package/lib/cjs/DelayedPromise.js.map +1 -1
  12. package/lib/cjs/Deserialization/AbstractParser.js +1 -0
  13. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  14. package/lib/cjs/Deserialization/Helper.d.ts +3 -3
  15. package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
  16. package/lib/cjs/Deserialization/Helper.js +8 -0
  17. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  18. package/lib/cjs/Deserialization/JsonParser.js +3 -0
  19. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  20. package/lib/cjs/Deserialization/JsonProps.d.ts +14 -0
  21. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  22. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  23. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  24. package/lib/cjs/Deserialization/XmlParser.js +11 -3
  25. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  26. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  27. package/lib/cjs/Deserialization/XmlSerializationUtils.js +2 -6
  28. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  29. package/lib/cjs/ECName.js +1 -0
  30. package/lib/cjs/ECName.js.map +1 -1
  31. package/lib/cjs/ECObjects.d.ts +21 -1
  32. package/lib/cjs/ECObjects.d.ts.map +1 -1
  33. package/lib/cjs/ECObjects.js +33 -2
  34. package/lib/cjs/ECObjects.js.map +1 -1
  35. package/lib/cjs/Exception.js +1 -0
  36. package/lib/cjs/Exception.js.map +1 -1
  37. package/lib/cjs/Interfaces.d.ts +10 -3
  38. package/lib/cjs/Interfaces.d.ts.map +1 -1
  39. package/lib/cjs/Interfaces.js.map +1 -1
  40. package/lib/cjs/Metadata/Class.d.ts +83 -21
  41. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  42. package/lib/cjs/Metadata/Class.js +188 -63
  43. package/lib/cjs/Metadata/Class.js.map +1 -1
  44. package/lib/cjs/Metadata/Constant.d.ts +14 -1
  45. package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
  46. package/lib/cjs/Metadata/Constant.js +27 -2
  47. package/lib/cjs/Metadata/Constant.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 +43 -23
  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 +117 -13
  95. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  96. package/lib/cjs/Metadata/Schema.js +148 -70
  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 +12 -2
  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/SchemaJsonLocater.d.ts +3 -3
  111. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  112. package/lib/cjs/SchemaJsonLocater.js +3 -3
  113. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  114. package/lib/cjs/SchemaKey.d.ts +7 -1
  115. package/lib/cjs/SchemaKey.d.ts.map +1 -1
  116. package/lib/cjs/SchemaKey.js +13 -3
  117. package/lib/cjs/SchemaKey.js.map +1 -1
  118. package/lib/cjs/SchemaLoader.d.ts +2 -2
  119. package/lib/cjs/SchemaLoader.d.ts.map +1 -1
  120. package/lib/cjs/SchemaLoader.js +1 -0
  121. package/lib/cjs/SchemaLoader.js.map +1 -1
  122. package/lib/cjs/SchemaPartVisitorDelegate.js +1 -0
  123. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  124. package/lib/cjs/UnitConversion/Graph.js +69 -65
  125. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  126. package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
  127. package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
  128. package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
  129. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  130. package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
  131. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  132. package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
  133. package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
  134. package/lib/cjs/UnitConversion/UnitTree.js +11 -1
  135. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  136. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  137. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +8 -9
  138. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  139. package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
  140. package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
  141. package/lib/cjs/Validation/SchemaWalker.js +6 -4
  142. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  143. package/lib/cjs/ecschema-metadata.d.ts +1 -1
  144. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  145. package/lib/cjs/ecschema-metadata.js.map +1 -1
  146. package/lib/cjs/utils/SchemaGraph.js +2 -3
  147. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  148. package/lib/esm/Constants.d.ts +8 -0
  149. package/lib/esm/Constants.d.ts.map +1 -1
  150. package/lib/esm/Constants.js +29 -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 +14 -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/XmlParser.d.ts.map +1 -1
  170. package/lib/esm/Deserialization/XmlParser.js +11 -3
  171. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  172. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  173. package/lib/esm/Deserialization/XmlSerializationUtils.js +2 -6
  174. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  175. package/lib/esm/ECName.js +1 -0
  176. package/lib/esm/ECName.js.map +1 -1
  177. package/lib/esm/ECObjects.d.ts +21 -1
  178. package/lib/esm/ECObjects.d.ts.map +1 -1
  179. package/lib/esm/ECObjects.js +31 -1
  180. package/lib/esm/ECObjects.js.map +1 -1
  181. package/lib/esm/Exception.js +1 -0
  182. package/lib/esm/Exception.js.map +1 -1
  183. package/lib/esm/Interfaces.d.ts +10 -3
  184. package/lib/esm/Interfaces.d.ts.map +1 -1
  185. package/lib/esm/Interfaces.js.map +1 -1
  186. package/lib/esm/Metadata/Class.d.ts +83 -21
  187. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  188. package/lib/esm/Metadata/Class.js +189 -64
  189. package/lib/esm/Metadata/Class.js.map +1 -1
  190. package/lib/esm/Metadata/Constant.d.ts +14 -1
  191. package/lib/esm/Metadata/Constant.d.ts.map +1 -1
  192. package/lib/esm/Metadata/Constant.js +27 -2
  193. package/lib/esm/Metadata/Constant.js.map +1 -1
  194. package/lib/esm/Metadata/CustomAttributeClass.d.ts +16 -4
  195. package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
  196. package/lib/esm/Metadata/CustomAttributeClass.js +22 -4
  197. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  198. package/lib/esm/Metadata/EntityClass.d.ts +20 -8
  199. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  200. package/lib/esm/Metadata/EntityClass.js +43 -23
  201. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  202. package/lib/esm/Metadata/Enumeration.d.ts +14 -1
  203. package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
  204. package/lib/esm/Metadata/Enumeration.js +22 -1
  205. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  206. package/lib/esm/Metadata/Format.d.ts +41 -1
  207. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  208. package/lib/esm/Metadata/Format.js +68 -3
  209. package/lib/esm/Metadata/Format.js.map +1 -1
  210. package/lib/esm/Metadata/InvertedUnit.d.ts +8 -3
  211. package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
  212. package/lib/esm/Metadata/InvertedUnit.js +17 -6
  213. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  214. package/lib/esm/Metadata/KindOfQuantity.d.ts +14 -3
  215. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
  216. package/lib/esm/Metadata/KindOfQuantity.js +43 -18
  217. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  218. package/lib/esm/Metadata/Mixin.d.ts +15 -1
  219. package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
  220. package/lib/esm/Metadata/Mixin.js +24 -3
  221. package/lib/esm/Metadata/Mixin.js.map +1 -1
  222. package/lib/esm/Metadata/OverrideFormat.js +9 -0
  223. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  224. package/lib/esm/Metadata/Phenomenon.d.ts +14 -1
  225. package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
  226. package/lib/esm/Metadata/Phenomenon.js +22 -1
  227. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  228. package/lib/esm/Metadata/Property.d.ts +5 -1
  229. package/lib/esm/Metadata/Property.d.ts.map +1 -1
  230. package/lib/esm/Metadata/Property.js +84 -29
  231. package/lib/esm/Metadata/Property.js.map +1 -1
  232. package/lib/esm/Metadata/PropertyCategory.d.ts +14 -1
  233. package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
  234. package/lib/esm/Metadata/PropertyCategory.js +21 -1
  235. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  236. package/lib/esm/Metadata/RelationshipClass.d.ts +15 -2
  237. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
  238. package/lib/esm/Metadata/RelationshipClass.js +48 -11
  239. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  240. package/lib/esm/Metadata/Schema.d.ts +117 -13
  241. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  242. package/lib/esm/Metadata/Schema.js +148 -70
  243. package/lib/esm/Metadata/Schema.js.map +1 -1
  244. package/lib/esm/Metadata/SchemaItem.d.ts +11 -2
  245. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  246. package/lib/esm/Metadata/SchemaItem.js +13 -3
  247. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  248. package/lib/esm/Metadata/Unit.d.ts +8 -1
  249. package/lib/esm/Metadata/Unit.d.ts.map +1 -1
  250. package/lib/esm/Metadata/Unit.js +21 -3
  251. package/lib/esm/Metadata/Unit.js.map +1 -1
  252. package/lib/esm/Metadata/UnitSystem.d.ts +14 -3
  253. package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
  254. package/lib/esm/Metadata/UnitSystem.js +21 -3
  255. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  256. package/lib/esm/SchemaJsonLocater.d.ts +3 -3
  257. package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
  258. package/lib/esm/SchemaJsonLocater.js +3 -3
  259. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  260. package/lib/esm/SchemaKey.d.ts +7 -1
  261. package/lib/esm/SchemaKey.d.ts.map +1 -1
  262. package/lib/esm/SchemaKey.js +13 -3
  263. package/lib/esm/SchemaKey.js.map +1 -1
  264. package/lib/esm/SchemaLoader.d.ts +2 -2
  265. package/lib/esm/SchemaLoader.d.ts.map +1 -1
  266. package/lib/esm/SchemaLoader.js +1 -0
  267. package/lib/esm/SchemaLoader.js.map +1 -1
  268. package/lib/esm/SchemaPartVisitorDelegate.js +1 -0
  269. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  270. package/lib/esm/UnitConversion/Graph.js +69 -65
  271. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  272. package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
  273. package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
  274. package/lib/esm/UnitConversion/UnitConversion.js +9 -7
  275. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  276. package/lib/esm/UnitConversion/UnitConverter.js +2 -0
  277. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  278. package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
  279. package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
  280. package/lib/esm/UnitConversion/UnitTree.js +11 -1
  281. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  282. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  283. package/lib/esm/UnitProvider/SchemaUnitProvider.js +8 -9
  284. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  285. package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
  286. package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
  287. package/lib/esm/Validation/SchemaWalker.js +6 -4
  288. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  289. package/lib/esm/ecschema-metadata.d.ts +1 -1
  290. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  291. package/lib/esm/ecschema-metadata.js.map +1 -1
  292. package/lib/esm/utils/SchemaGraph.js +2 -3
  293. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  294. package/package.json +14 -14
@@ -19,12 +19,14 @@ const EntityClass_1 = require("./EntityClass");
19
19
  * @beta
20
20
  */
21
21
  class Mixin extends Class_1.ECClass {
22
+ schemaItemType = Mixin.schemaItemType;
23
+ static get schemaItemType() { return ECObjects_1.SchemaItemType.Mixin; }
24
+ _appliesTo;
22
25
  get appliesTo() {
23
26
  return this._appliesTo;
24
27
  }
25
28
  constructor(schema, name) {
26
29
  super(schema, name, ECObjects_1.ECClassModifier.Abstract);
27
- this.schemaItemType = ECObjects_1.SchemaItemType.Mixin;
28
30
  }
29
31
  /**
30
32
  *
@@ -85,7 +87,7 @@ class Mixin extends Class_1.ECClass {
85
87
  if (!entityClassSchemaItemKey)
86
88
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);
87
89
  this._appliesTo = new DelayedPromise_1.DelayedPromiseWithProps(entityClassSchemaItemKey, async () => {
88
- const appliesTo = await this.schema.lookupItem(entityClassSchemaItemKey);
90
+ const appliesTo = await this.schema.lookupItem(entityClassSchemaItemKey, EntityClass_1.EntityClass);
89
91
  if (undefined === appliesTo)
90
92
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);
91
93
  return appliesTo;
@@ -102,6 +104,25 @@ class Mixin extends Class_1.ECClass {
102
104
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);
103
105
  return appliesTo.is(entityClass);
104
106
  }
107
+ /**
108
+ * Type guard to check if the SchemaItem is of type Mixin.
109
+ * @param item The SchemaItem to check.
110
+ * @returns True if the item is a Mixin, false otherwise.
111
+ */
112
+ static isMixin(item) {
113
+ if (item && item.schemaItemType === ECObjects_1.SchemaItemType.Mixin)
114
+ return true;
115
+ return false;
116
+ }
117
+ /**
118
+ * Type assertion to check if the SchemaItem is of type Mixin.
119
+ * @param item The SchemaItem to check.
120
+ * @returns The item cast to Mixin if it is a Mixin, undefined otherwise.
121
+ */
122
+ static assertIsMixin(item) {
123
+ if (!this.isMixin(item))
124
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.Mixin}' (Mixin)`);
125
+ }
105
126
  }
106
127
  exports.Mixin = Mixin;
107
128
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Mixin.js","sourceRoot":"","sources":["../../../src/Metadata/Mixin.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAAkF;AAClF,4CAA+D;AAG/D,mCAAkC;AAClC,+CAAoG;AAKpG;;;GAGG;AACH,MAAa,KAAM,SAAQ,eAAO;IAIhC,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,2BAAe,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,cAAc,GAAG,0BAAc,CAAC,KAAK,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,wBAAwB,CAAC,IAAY,EAAE,YAAwC,EAAE,SAAqC;QACpI,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,IAAA,sCAAwB,EAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAC/F,CAAC;IAES,4BAA4B,CAAC,IAAY,EAAE,YAAwC,EAAE,SAAqC;QAClI,OAAO,IAAI,CAAC,WAAW,CAAC,IAAA,0CAA4B,EAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IA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C,QAAQ,GAAG,CAAC,CAAC;QAEjH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC;QACvC,IAAI,SAAS,KAAK,SAAS;YACzB,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,WAAW,EAAE,kCAAkC,IAAI,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,CAAC;QAEtH,OAAO,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;CACF;AAtGD,sBAsGC;AACD;;;GAGG;AACH,MAAsB,YAAa,SAAQ,KAAK;CAK/C;AALD,oCAKC","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 { MixinProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { ECClassModifier, SchemaItemType, StrengthDirection } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedEntityClass } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { ECClass } from \"./Class\";\r\nimport { createNavigationProperty, createNavigationPropertySync, EntityClass } from \"./EntityClass\";\r\nimport { NavigationProperty } from \"./Property\";\r\nimport { RelationshipClass } from \"./RelationshipClass\";\r\nimport { Schema } from \"./Schema\";\r\n\r\n/**\r\n * A Typescript class representation of a Mixin.\r\n * @beta\r\n */\r\nexport class Mixin extends ECClass {\r\n public override readonly schemaItemType!: SchemaItemType.Mixin;\r\n protected _appliesTo?: LazyLoadedEntityClass;\r\n\r\n public get appliesTo(): LazyLoadedEntityClass | undefined {\r\n return this._appliesTo;\r\n }\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name, ECClassModifier.Abstract);\r\n this.schemaItemType = SchemaItemType.Mixin;\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 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 * @alpha Used for schema editing.\r\n */\r\n protected setAppliesTo(appliesTo: LazyLoadedEntityClass) {\r\n this._appliesTo = appliesTo;\r\n }\r\n /**\r\n * Save this Mixin's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): MixinProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n if (undefined !== this.appliesTo) {\r\n schemaJson.appliesTo = this.appliesTo.fullName;\r\n }\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 // When CustomAttributes are added, there must be a check to see if the ECCustomAttributes\r\n // already exist for this item before creating a new one to apply IsMixin\r\n const customAttributes = schemaXml.createElement(\"ECCustomAttributes\");\r\n const isMixinElement = schemaXml.createElement(\"IsMixin\");\r\n const coreCustomSchema = this.schema.getReferenceSync(\"CoreCustomAttributes\");\r\n if (undefined !== coreCustomSchema) {\r\n const xmlns = `CoreCustomAttributes.${coreCustomSchema.schemaKey.version.toString()}`;\r\n isMixinElement.setAttribute(\"xmlns\", xmlns);\r\n }\r\n\r\n const appliesToElement = schemaXml.createElement(\"AppliesToEntityClass\");\r\n const appliesTo = await this.appliesTo;\r\n if (undefined !== appliesTo) {\r\n const appliesToName = XmlSerializationUtils.createXmlTypedName(this.schema, appliesTo.schema, appliesTo.name);\r\n appliesToElement.textContent = appliesToName;\r\n isMixinElement.appendChild(appliesToElement);\r\n }\r\n\r\n customAttributes.appendChild(isMixinElement);\r\n itemElement.appendChild(customAttributes);\r\n\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(mixinProps: MixinProps) {\r\n super.fromJSONSync(mixinProps);\r\n const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);\r\n if (!entityClassSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\r\n this._appliesTo = new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(entityClassSchemaItemKey,\r\n async () => {\r\n const appliesTo = await this.schema.lookupItem<EntityClass>(entityClassSchemaItemKey);\r\n if (undefined === appliesTo)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\r\n return appliesTo;\r\n });\r\n }\r\n\r\n public override async fromJSON(mixinProps: MixinProps) {\r\n this.fromJSONSync(mixinProps);\r\n }\r\n\r\n public async applicableTo(entityClass: EntityClass) {\r\n if (!this.appliesTo)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);\r\n\r\n const appliesTo = await this.appliesTo;\r\n if (appliesTo === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);\r\n\r\n return appliesTo.is(entityClass);\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableMixin extends Mixin {\r\n public abstract override setAppliesTo(entityClass: LazyLoadedEntityClass): void;\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"]}
1
+ {"version":3,"file":"Mixin.js","sourceRoot":"","sources":["../../../src/Metadata/Mixin.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAAkF;AAClF,4CAA+D;AAG/D,mCAAkC;AAClC,+CAAoG;AAMpG;;;GAGG;AACH,MAAa,KAAM,SAAQ,eAAO;IACP,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;IACxD,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IAClE,UAAU,CAAyB;IAE7C,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,2BAAe,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,wBAAwB,CAAC,IAAY,EAAE,YAAwC,EAAE,SAAqC;QACpI,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,IAAA,sCAAwB,EAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAC/F,CAAC;IAES,4BAA4B,CAAC,IAAY,EAAE,YAAwC,EAAE,SAAqC;QAClI,OAAO,IAAI,CAAC,WAAW,CAAC,IAAA,0CAA4B,EAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAC7F,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,SAAgC;QACrD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IACD;;;;OAIG;IACa,MAAM,CAAC,aAAsB,KAAK,EAAE,uBAAgC,KA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,CAAC,WAAW,EAAE,kCAAkC,IAAI,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,CAAC;QAEtH,OAAO,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAC,IAAiB;QACrC,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,KAAK;YACtD,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,IAAiB;QAC3C,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACrB,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,KAAK,WAAW,CAAC,CAAC;IAClH,CAAC;CACF;AA5HD,sBA4HC;AACD;;;GAGG;AACH,MAAsB,YAAa,SAAQ,KAAK;CAK/C;AALD,oCAKC","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 { MixinProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { ECClassModifier, SchemaItemType, StrengthDirection } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedEntityClass } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { ECClass } from \"./Class\";\r\nimport { createNavigationProperty, createNavigationPropertySync, EntityClass } from \"./EntityClass\";\r\nimport { NavigationProperty } from \"./Property\";\r\nimport { RelationshipClass } from \"./RelationshipClass\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\n\r\n/**\r\n * A Typescript class representation of a Mixin.\r\n * @beta\r\n */\r\nexport class Mixin extends ECClass {\r\n public override readonly schemaItemType = Mixin.schemaItemType;\r\n public static override get schemaItemType() { return SchemaItemType.Mixin; }\r\n protected _appliesTo?: LazyLoadedEntityClass;\r\n\r\n public get appliesTo(): LazyLoadedEntityClass | undefined {\r\n return this._appliesTo;\r\n }\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name, ECClassModifier.Abstract);\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 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 * @alpha Used for schema editing.\r\n */\r\n protected setAppliesTo(appliesTo: LazyLoadedEntityClass) {\r\n this._appliesTo = appliesTo;\r\n }\r\n /**\r\n * Save this Mixin's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): MixinProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n if (undefined !== this.appliesTo) {\r\n schemaJson.appliesTo = this.appliesTo.fullName;\r\n }\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 // When CustomAttributes are added, there must be a check to see if the ECCustomAttributes\r\n // already exist for this item before creating a new one to apply IsMixin\r\n const customAttributes = schemaXml.createElement(\"ECCustomAttributes\");\r\n const isMixinElement = schemaXml.createElement(\"IsMixin\");\r\n const coreCustomSchema = this.schema.getReferenceSync(\"CoreCustomAttributes\");\r\n if (undefined !== coreCustomSchema) {\r\n const xmlns = `CoreCustomAttributes.${coreCustomSchema.schemaKey.version.toString()}`;\r\n isMixinElement.setAttribute(\"xmlns\", xmlns);\r\n }\r\n\r\n const appliesToElement = schemaXml.createElement(\"AppliesToEntityClass\");\r\n const appliesTo = await this.appliesTo;\r\n if (undefined !== appliesTo) {\r\n const appliesToName = XmlSerializationUtils.createXmlTypedName(this.schema, appliesTo.schema, appliesTo.name);\r\n appliesToElement.textContent = appliesToName;\r\n isMixinElement.appendChild(appliesToElement);\r\n }\r\n\r\n customAttributes.appendChild(isMixinElement);\r\n itemElement.appendChild(customAttributes);\r\n\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(mixinProps: MixinProps) {\r\n super.fromJSONSync(mixinProps);\r\n const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);\r\n if (!entityClassSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\r\n this._appliesTo = new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(entityClassSchemaItemKey,\r\n async () => {\r\n const appliesTo = await this.schema.lookupItem(entityClassSchemaItemKey, EntityClass);\r\n if (undefined === appliesTo)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\r\n return appliesTo;\r\n });\r\n }\r\n\r\n public override async fromJSON(mixinProps: MixinProps) {\r\n this.fromJSONSync(mixinProps);\r\n }\r\n\r\n public async applicableTo(entityClass: EntityClass) {\r\n if (!this.appliesTo)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);\r\n\r\n const appliesTo = await this.appliesTo;\r\n if (appliesTo === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);\r\n\r\n return appliesTo.is(entityClass);\r\n }\r\n\r\n /**\r\n * Type guard to check if the SchemaItem is of type Mixin.\r\n * @param item The SchemaItem to check.\r\n * @returns True if the item is a Mixin, false otherwise.\r\n */\r\n public static isMixin(item?: SchemaItem): item is Mixin {\r\n if (item && item.schemaItemType === SchemaItemType.Mixin)\r\n return true;\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Type assertion to check if the SchemaItem is of type Mixin.\r\n * @param item The SchemaItem to check.\r\n * @returns The item cast to Mixin if it is a Mixin, undefined otherwise.\r\n */\r\n public static assertIsMixin(item?: SchemaItem): asserts item is Mixin {\r\n if (!this.isMixin(item))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Mixin}' (Mixin)`);\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableMixin extends Mixin {\r\n public abstract override setAppliesTo(entityClass: LazyLoadedEntityClass): void;\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"]}
@@ -18,6 +18,15 @@ const Exception_1 = require("../Exception");
18
18
  * @beta
19
19
  */
20
20
  class OverrideFormat {
21
+ _precision;
22
+ _units;
23
+ /** The Format that this OverrideFormat is extending */
24
+ parent;
25
+ /** The name of this OverrideFormat.
26
+ *
27
+ * This should be set to the [FormatString]($docs/bis/ec/kindofquantity/#format-string) which represents the format override.
28
+ */
29
+ name;
21
30
  constructor(parent, precision, unitAndLabels) {
22
31
  this.parent = parent;
23
32
  this.name = OverrideFormat.createOverrideFormatFullName(parent, precision, unitAndLabels);
@@ -1 +1 @@
1
- {"version":3,"file":"OverrideF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5D,OAAO,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;AAC7F,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 { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { DecimalPrecision, FormatProps, formatStringRgx, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from \"@itwin/core-quantity\";\r\nimport { Format } from \"./Format\";\r\nimport { InvertedUnit } from \"./InvertedUnit\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItemOverrideFormatProps } from \"../Deserialization/JsonProps\";\r\nimport { Unit } from \"./Unit\";\r\nimport { Mutable } from \"@itwin/core-bentley\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\n\r\n/**\r\n * @beta\r\n */\r\nexport interface OverrideFormatProps {\r\n name: string;\r\n precision?: number;\r\n unitAndLabels?: Array<[string, string | undefined]>; // Tuple of [unit name | unit label]\r\n}\r\n\r\n/**\r\n * Overrides of a Format, from a Schema, and is SchemaItem that is used specifically on KindOfQuantity.\r\n * @beta\r\n */\r\nexport class OverrideFormat {\r\n private _precision?: DecimalPrecision | FractionalPrecision;\r\n private _units?: Array<[Unit | InvertedUnit, string | undefined]>;\r\n\r\n /** The Format that this OverrideFormat is extending */\r\n public readonly parent: Format;\r\n\r\n /** The name of this OverrideFormat.\r\n *\r\n * This should be set to the [FormatString]($docs/bis/ec/kindofquantity/#format-string) which represents the format override.\r\n */\r\n public readonly name: string;\r\n\r\n constructor(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[Unit | InvertedUnit, string | undefined]>) {\r\n this.parent = parent;\r\n this.name = OverrideFormat.createOverrideFormatFullName(parent, precision, unitAndLabels);\r\n this._precision = precision;\r\n this._units = unitAndLabels;\r\n }\r\n\r\n // Properties that can be overriden\r\n public get precision(): DecimalPrecision | FractionalPrecision { return (undefined === this._precision) ? this.parent.precision : this._precision; }\r\n public get units() { return (undefined === this._units) ? this.parent.units : this._units; }\r\n\r\n // Properties that cannot be overriden\r\n public get fullName(): string { return this.name; }\r\n public get roundFactor(): number { return this.parent.roundFactor; }\r\n public get type(): FormatType { return this.parent.type; }\r\n public get minWidth(): number | undefined { return this.parent.minWidth; }\r\n public get scientificType(): ScientificType | undefined { return this.parent.scientificType; }\r\n public get showSignOption(): ShowSignOption { return this.parent.showSignOption; }\r\n public get decimalSeparator(): string { return this.parent.decimalSeparator; }\r\n public get thousandSeparator(): string { return this.parent.thousandSeparator; }\r\n public get uomSeparator(): string { return this.parent.uomSeparator; }\r\n public get stationSeparator(): string { return this.parent.stationSeparator; }\r\n public get stationOffsetSize(): number | undefined { return this.parent.stationOffsetSize; }\r\n public get formatTraits(): FormatTraits { return this.parent.formatTraits; }\r\n public get spacer(): string | undefined { return this.parent.spacer; }\r\n public get includeZero(): boolean | undefined { return this.parent.includeZero; }\r\n\r\n public hasFormatTrait(formatTrait: FormatTraits) {\r\n return (this.parent.formatTraits & formatTrait) === formatTrait;\r\n }\r\n\r\n /** Returns the format string of this override in the Xml full name format.\r\n * @alpha\r\n */\r\n public fullNameXml(koqSchema: Schema): string {\r\n let fullName = XmlSerializationUtils.createXmlTypedName(koqSchema, this.parent.schema, this.parent.name);\r\n\r\n if (undefined !== this.precision)\r\n fullName += `(${this.precision.toString()})`;\r\n\r\n if (undefined === this._units)\r\n return fullName;\r\n for (const [unit, unitLabel] of this._units) {\r\n fullName += \"[\";\r\n fullName += XmlSerializationUtils.createXmlTypedName(koqSchema, unit.schema, unit.name);\r\n if (unitLabel !== undefined)\r\n fullName += `|${unitLabel}`;\r\n fullName += `]`;\r\n }\r\n return fullName;\r\n }\r\n\r\n /**\r\n * Creates a valid OverrideFormat fullName from the parent Format and overridden units.\r\n * @param parent The parent Format.\r\n * @param unitAndLabels The overridden unit and labels collection.\r\n */\r\n public static createOverrideFormatFullName(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[Unit | InvertedUnit, string | undefined]>): string {\r\n let fullName = parent.fullName;\r\n\r\n if (precision)\r\n fullName += `(${precision.toString()})`;\r\n\r\n if (undefined === unitAndLabels)\r\n return fullName;\r\n for (const [unit, unitLabel] of unitAndLabels)\r\n if (undefined === unitLabel)\r\n fullName += `[${unit.fullName}]`;\r\n else\r\n fullName += `[${unit.fullName}|${unitLabel}]`;\r\n return fullName;\r\n }\r\n\r\n /** Parses the format string into the parts that make up an Override Format\r\n * @param formatString\r\n */\r\n public static parseFormatString(formatString: string): OverrideFormatProps {\r\n const match = formatString.split(formatStringRgx); // split string based on regex groups\r\n if (undefined === match[1])\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The format string, ${formatString}, on KindOfQuantity is missing a format.`);\r\n\r\n const returnValue: OverrideFormatProps = { name: match[1] };\r\n\r\n if (undefined !== match[2] && undefined !== match[3]) {\r\n const overrideString = match[2];\r\n const tokens: string[] = [];\r\n let prevPos = 1; // Initial position is the character directly after the opening '(' in the override string.\r\n let currPos;\r\n\r\n // TODO need to include `,` as a valid search argument.\r\n while (-1 !== (currPos = overrideString.indexOf(\")\", prevPos))) {\r\n tokens.push(overrideString.substring(prevPos, currPos));\r\n prevPos = currPos + 1;\r\n }\r\n\r\n if (overrideString.length > 0 && undefined === tokens.find((token) => {\r\n return \"\" !== token; // there is at least one token that is not empty.\r\n })) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\r\n }\r\n\r\n // The first override parameter overrides the default precision of the format\r\n const precisionIndx: number = 0;\r\n\r\n if (tokens.length >= precisionIndx + 1) {\r\n if (tokens[precisionIndx].length > 0) {\r\n const precision = Number.parseInt(tokens[precisionIndx], 10);\r\n if (Number.isNaN(precision))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The format string '${formatString}' on KindOfQuantity has a precision override '${tokens[precisionIndx]}' that is not number.`);\r\n returnValue.precision = precision;\r\n }\r\n }\r\n }\r\n\r\n let i = 4;\r\n while (i < match.length - 1) { // The regex match ends with an empty last value, which causes problems when exactly 4 unit overrides as specified, so ignore this last empty value\r\n if (undefined === match[i])\r\n break;\r\n // Unit override required\r\n if (undefined === match[i + 1])\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\r\n\r\n if (undefined === returnValue.unitAndLabels)\r\n returnValue.unitAndLabels = [];\r\n\r\n if (undefined !== match[i + 2]) // matches '|'\r\n returnValue.unitAndLabels.push([match[i + 1], match[i + 3] ?? \"\"]); // add unit name and label override (if '|' matches and next value is undefined, save it as an empty string)\r\n else\r\n returnValue.unitAndLabels.push([match[i + 1], undefined]); // add unit name\r\n\r\n i += 4;\r\n }\r\n\r\n return returnValue;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static isOverrideFormat(object: any): object is OverrideFormat {\r\n const overrideFormat = object as OverrideFormat;\r\n\r\n return overrideFormat !== undefined && overrideFormat.name !== undefined && overrideFormat.parent !== undefined && overrideFormat.parent.schemaItemType === SchemaItemType.Format;\r\n }\r\n\r\n /**\r\n * Returns a JSON object that contains the specification for the OverrideFormat where the precision and units properties have been overriden.\r\n * If the precision and/or units properties have been overriden, the returned object will contain a \"name\" and a \"parent\" property.\r\n * The \"name\" property identifies the OverrideFormat object itself and the \"parent\" property identifies the Format that has been overriden.\r\n * This method is not intended for complete serialization as it does not serialize any of the schema item properties.\r\n */\r\n public getFormatProps(): SchemaItemOverrideFormatProps {\r\n const formatJson = this.parent.toJSON() as Mutable<SchemaItemOverrideFormatProps>;\r\n\r\n if (this.parent.fullName !== this.fullName) {\r\n // Update name and parent properties to distinguish it from parent Format\r\n formatJson.name = this.fullName;\r\n formatJson.parent = this.parent.fullName;\r\n }\r\n\r\n // Update Precision overriden property\r\n formatJson.precision = this.precision;\r\n\r\n if (this.units !== undefined) {\r\n // Update Units overriden property\r\n const units = [];\r\n for (const unit of this.units) {\r\n units.push({\r\n name: unit[0].fullName,\r\n label: unit[1],\r\n });\r\n }\r\n\r\n formatJson.composite = {\r\n spacer: (this.spacer !== \" \") ? this.spacer : undefined,\r\n includeZero: (this.includeZero === false) ? this.includeZero : undefined,\r\n units,\r\n };\r\n }\r\n\r\n return formatJson;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function getFormatProps(format: Format | OverrideFormat): FormatProps {\r\n return OverrideFormat.isOverrideFormat(format) ? format.getFormatProps() : format.toJSON();\r\n}\r\n"]}
1
+ {"version":3,"file":"OverrideFormat.js","sourceRoot":"","sources":["../../../src/Metadata/OverrideFormat.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAkOH,wCAEC;AAlOD,oFAAiF;AACjF,4CAA8C;AAC9C,wDAAqK;AAOrK,4CAA+D;AAW/D;;;GAGG;AACH,MAAa,cAAc;IACjB,UAAU,CAA0C;IACpD,MAAM,CAAoD;IAElE,uDAAuD;IACvC,MAAM,CAAS;IAE/B;;;OAGG;IACa,IAAI,CAAS;IAE7B,YAAY,MAAc,EAAE,SAAkD,EAAE,aAAgE;QAC9I,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,4BAA4B,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;QAC1F,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;IAC9B,CAAC;IAED,mCAAmC;IACnC,IAAW,SAAS,KAA6C,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,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,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC9B,KAAK,CAAC,IAAI,CAAC;oBACT,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ;oBACtB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;iBACf,CAAC,CAAC;YACL,CAAC;YAED,UAAU,CAAC,SAAS,GAAG;gBACrB,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;gBACvD,WAAW,EAAE,CAAC,IAAI,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;gBACxE,KAAK;aACN,CAAC;QACJ,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAnMD,wCAmMC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,MAA+B;IAC5D,OAAO,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;AAC7F,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 { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { DecimalPrecision, FormatProps, formatStringRgx, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from \"@itwin/core-quantity\";\r\nimport { Format } from \"./Format\";\r\nimport { InvertedUnit } from \"./InvertedUnit\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItemOverrideFormatProps } from \"../Deserialization/JsonProps\";\r\nimport { Unit } from \"./Unit\";\r\nimport { Mutable } from \"@itwin/core-bentley\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\n\r\n/**\r\n * @beta\r\n */\r\nexport interface OverrideFormatProps {\r\n name: string;\r\n precision?: number;\r\n unitAndLabels?: Array<[string, string | undefined]>; // Tuple of [unit name | unit label]\r\n}\r\n\r\n/**\r\n * Overrides of a Format, from a Schema, and is SchemaItem that is used specifically on KindOfQuantity.\r\n * @beta\r\n */\r\nexport class OverrideFormat {\r\n private _precision?: DecimalPrecision | FractionalPrecision;\r\n private _units?: Array<[Unit | InvertedUnit, string | undefined]>;\r\n\r\n /** The Format that this OverrideFormat is extending */\r\n public readonly parent: Format;\r\n\r\n /** The name of this OverrideFormat.\r\n *\r\n * This should be set to the [FormatString]($docs/bis/ec/kindofquantity/#format-string) which represents the format override.\r\n */\r\n public readonly name: string;\r\n\r\n constructor(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[Unit | InvertedUnit, string | undefined]>) {\r\n this.parent = parent;\r\n this.name = OverrideFormat.createOverrideFormatFullName(parent, precision, unitAndLabels);\r\n this._precision = precision;\r\n this._units = unitAndLabels;\r\n }\r\n\r\n // Properties that can be overriden\r\n public get precision(): DecimalPrecision | FractionalPrecision { return (undefined === this._precision) ? this.parent.precision : this._precision; }\r\n public get units() { return (undefined === this._units) ? this.parent.units : this._units; }\r\n\r\n // Properties that cannot be overriden\r\n public get fullName(): string { return this.name; }\r\n public get roundFactor(): number { return this.parent.roundFactor; }\r\n public get type(): FormatType { return this.parent.type; }\r\n public get minWidth(): number | undefined { return this.parent.minWidth; }\r\n public get scientificType(): ScientificType | undefined { return this.parent.scientificType; }\r\n public get showSignOption(): ShowSignOption { return this.parent.showSignOption; }\r\n public get decimalSeparator(): string { return this.parent.decimalSeparator; }\r\n public get thousandSeparator(): string { return this.parent.thousandSeparator; }\r\n public get uomSeparator(): string { return this.parent.uomSeparator; }\r\n public get stationSeparator(): string { return this.parent.stationSeparator; }\r\n public get stationOffsetSize(): number | undefined { return this.parent.stationOffsetSize; }\r\n public get formatTraits(): FormatTraits { return this.parent.formatTraits; }\r\n public get spacer(): string | undefined { return this.parent.spacer; }\r\n public get includeZero(): boolean | undefined { return this.parent.includeZero; }\r\n\r\n public hasFormatTrait(formatTrait: FormatTraits) {\r\n return (this.parent.formatTraits & formatTrait) === formatTrait;\r\n }\r\n\r\n /** Returns the format string of this override in the Xml full name format.\r\n * @alpha\r\n */\r\n public fullNameXml(koqSchema: Schema): string {\r\n let fullName = XmlSerializationUtils.createXmlTypedName(koqSchema, this.parent.schema, this.parent.name);\r\n\r\n if (undefined !== this.precision)\r\n fullName += `(${this.precision.toString()})`;\r\n\r\n if (undefined === this._units)\r\n return fullName;\r\n for (const [unit, unitLabel] of this._units) {\r\n fullName += \"[\";\r\n fullName += XmlSerializationUtils.createXmlTypedName(koqSchema, unit.schema, unit.name);\r\n if (unitLabel !== undefined)\r\n fullName += `|${unitLabel}`;\r\n fullName += `]`;\r\n }\r\n return fullName;\r\n }\r\n\r\n /**\r\n * Creates a valid OverrideFormat fullName from the parent Format and overridden units.\r\n * @param parent The parent Format.\r\n * @param unitAndLabels The overridden unit and labels collection.\r\n */\r\n public static createOverrideFormatFullName(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[Unit | InvertedUnit, string | undefined]>): string {\r\n let fullName = parent.fullName;\r\n\r\n if (precision)\r\n fullName += `(${precision.toString()})`;\r\n\r\n if (undefined === unitAndLabels)\r\n return fullName;\r\n for (const [unit, unitLabel] of unitAndLabels)\r\n if (undefined === unitLabel)\r\n fullName += `[${unit.fullName}]`;\r\n else\r\n fullName += `[${unit.fullName}|${unitLabel}]`;\r\n return fullName;\r\n }\r\n\r\n /** Parses the format string into the parts that make up an Override Format\r\n * @param formatString\r\n */\r\n public static parseFormatString(formatString: string): OverrideFormatProps {\r\n const match = formatString.split(formatStringRgx); // split string based on regex groups\r\n if (undefined === match[1])\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The format string, ${formatString}, on KindOfQuantity is missing a format.`);\r\n\r\n const returnValue: OverrideFormatProps = { name: match[1] };\r\n\r\n if (undefined !== match[2] && undefined !== match[3]) {\r\n const overrideString = match[2];\r\n const tokens: string[] = [];\r\n let prevPos = 1; // Initial position is the character directly after the opening '(' in the override string.\r\n let currPos;\r\n\r\n // TODO need to include `,` as a valid search argument.\r\n while (-1 !== (currPos = overrideString.indexOf(\")\", prevPos))) {\r\n tokens.push(overrideString.substring(prevPos, currPos));\r\n prevPos = currPos + 1;\r\n }\r\n\r\n if (overrideString.length > 0 && undefined === tokens.find((token) => {\r\n return \"\" !== token; // there is at least one token that is not empty.\r\n })) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\r\n }\r\n\r\n // The first override parameter overrides the default precision of the format\r\n const precisionIndx: number = 0;\r\n\r\n if (tokens.length >= precisionIndx + 1) {\r\n if (tokens[precisionIndx].length > 0) {\r\n const precision = Number.parseInt(tokens[precisionIndx], 10);\r\n if (Number.isNaN(precision))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The format string '${formatString}' on KindOfQuantity has a precision override '${tokens[precisionIndx]}' that is not number.`);\r\n returnValue.precision = precision;\r\n }\r\n }\r\n }\r\n\r\n let i = 4;\r\n while (i < match.length - 1) { // The regex match ends with an empty last value, which causes problems when exactly 4 unit overrides as specified, so ignore this last empty value\r\n if (undefined === match[i])\r\n break;\r\n // Unit override required\r\n if (undefined === match[i + 1])\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\r\n\r\n if (undefined === returnValue.unitAndLabels)\r\n returnValue.unitAndLabels = [];\r\n\r\n if (undefined !== match[i + 2]) // matches '|'\r\n returnValue.unitAndLabels.push([match[i + 1], match[i + 3] ?? \"\"]); // add unit name and label override (if '|' matches and next value is undefined, save it as an empty string)\r\n else\r\n returnValue.unitAndLabels.push([match[i + 1], undefined]); // add unit name\r\n\r\n i += 4;\r\n }\r\n\r\n return returnValue;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static isOverrideFormat(object: any): object is OverrideFormat {\r\n const overrideFormat = object as OverrideFormat;\r\n\r\n return overrideFormat !== undefined && overrideFormat.name !== undefined && overrideFormat.parent !== undefined && overrideFormat.parent.schemaItemType === SchemaItemType.Format;\r\n }\r\n\r\n /**\r\n * Returns a JSON object that contains the specification for the OverrideFormat where the precision and units properties have been overriden.\r\n * If the precision and/or units properties have been overriden, the returned object will contain a \"name\" and a \"parent\" property.\r\n * The \"name\" property identifies the OverrideFormat object itself and the \"parent\" property identifies the Format that has been overriden.\r\n * This method is not intended for complete serialization as it does not serialize any of the schema item properties.\r\n */\r\n public getFormatProps(): SchemaItemOverrideFormatProps {\r\n const formatJson = this.parent.toJSON() as Mutable<SchemaItemOverrideFormatProps>;\r\n\r\n if (this.parent.fullName !== this.fullName) {\r\n // Update name and parent properties to distinguish it from parent Format\r\n formatJson.name = this.fullName;\r\n formatJson.parent = this.parent.fullName;\r\n }\r\n\r\n // Update Precision overriden property\r\n formatJson.precision = this.precision;\r\n\r\n if (this.units !== undefined) {\r\n // Update Units overriden property\r\n const units = [];\r\n for (const unit of this.units) {\r\n units.push({\r\n name: unit[0].fullName,\r\n label: unit[1],\r\n });\r\n }\r\n\r\n formatJson.composite = {\r\n spacer: (this.spacer !== \" \") ? this.spacer : undefined,\r\n includeZero: (this.includeZero === false) ? this.includeZero : undefined,\r\n units,\r\n };\r\n }\r\n\r\n return formatJson;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function getFormatProps(format: Format | OverrideFormat): FormatProps {\r\n return OverrideFormat.isOverrideFormat(format) ? format.getFormatProps() : format.toJSON();\r\n}\r\n"]}
@@ -7,7 +7,8 @@ import { Schema } from "./Schema";
7
7
  import { SchemaItem } from "./SchemaItem";
8
8
  /** @beta */
9
9
  export declare class Phenomenon extends SchemaItem {
10
- readonly schemaItemType: SchemaItemType.Phenomenon;
10
+ readonly schemaItemType: SchemaItemType;
11
+ static get schemaItemType(): SchemaItemType;
11
12
  protected _definition: string;
12
13
  constructor(schema: Schema, name: string);
13
14
  get definition(): string;
@@ -22,6 +23,18 @@ export declare class Phenomenon extends SchemaItem {
22
23
  fromJSONSync(phenomenonProps: PhenomenonProps): void;
23
24
  fromJSON(phenomenonProps: PhenomenonProps): Promise<void>;
24
25
  protected setDefinition(definition: string): Promise<void>;
26
+ /**
27
+ * Type guard to check if the SchemaItem is of type Phenomenon.
28
+ * @param item The SchemaItem to check.
29
+ * @returns True if the item is a Phenomenon, false otherwise.
30
+ */
31
+ static isPhenomenon(item?: SchemaItem): item is Phenomenon;
32
+ /**
33
+ * Type assertion to check if the SchemaItem is of type Phenomenon.
34
+ * @param item The SchemaItem to check.
35
+ * @returns The item cast to Phenomenon if it is a Phenomenon, undefined otherwise.
36
+ */
37
+ static assertIsPhenomenon(item?: SchemaItem): asserts item is Phenomenon;
25
38
  }
26
39
  /**
27
40
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"Phenomenon.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Phenomenon.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,YAAY;AACZ,qBAAa,UAAW,SAAQ,UAAU;IACxC,SAAyB,cAAc,EAAG,cAAc,CAAC,UAAU,CAAC;IACpE,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;gBAElB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAMxC,IAAW,UAAU,IAAI,MAAM,CAA6B;IAE5D;;;;OAIG;IACa,MAAM,CAAC,UAAU,GAAE,OAAe,EAAE,oBAAoB,GAAE,OAAe,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IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,UAAU;IAOjE;;;;OAIG;WACW,kBAAkB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,UAAU;CAIhF;AAED;;;GAGG;AACH,8BAAsB,iBAAkB,SAAQ,UAAU;aAC/B,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;aAChD,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -13,9 +13,11 @@ const Exception_1 = require("../Exception");
13
13
  const SchemaItem_1 = require("./SchemaItem");
14
14
  /** @beta */
15
15
  class Phenomenon extends SchemaItem_1.SchemaItem {
16
+ schemaItemType = Phenomenon.schemaItemType;
17
+ static get schemaItemType() { return ECObjects_1.SchemaItemType.Phenomenon; }
18
+ _definition; // Contains a combination of Phenomena names which form this Phenomenon. Each Phenomena name is separated by a * and may have an exponent, specified using parentheses
16
19
  constructor(schema, name) {
17
20
  super(schema, name);
18
- this.schemaItemType = ECObjects_1.SchemaItemType.Phenomenon;
19
21
  this._definition = "";
20
22
  }
21
23
  get definition() { return this._definition; }
@@ -48,6 +50,25 @@ class Phenomenon extends SchemaItem_1.SchemaItem {
48
50
  async setDefinition(definition) {
49
51
  this._definition = definition;
50
52
  }
53
+ /**
54
+ * Type guard to check if the SchemaItem is of type Phenomenon.
55
+ * @param item The SchemaItem to check.
56
+ * @returns True if the item is a Phenomenon, false otherwise.
57
+ */
58
+ static isPhenomenon(item) {
59
+ if (item && item.schemaItemType === ECObjects_1.SchemaItemType.Phenomenon)
60
+ return true;
61
+ return false;
62
+ }
63
+ /**
64
+ * Type assertion to check if the SchemaItem is of type Phenomenon.
65
+ * @param item The SchemaItem to check.
66
+ * @returns The item cast to Phenomenon if it is a Phenomenon, undefined otherwise.
67
+ */
68
+ static assertIsPhenomenon(item) {
69
+ if (!this.isPhenomenon(item))
70
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.Phenomenon}' (Phenomenon)`);
71
+ }
51
72
  }
52
73
  exports.Phenomenon = Phenomenon;
53
74
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Phenomenon.js","sourceRoot":"","sources":["../../../src/Metadata/Phenomenon.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,4CAA8C;AAC9C,4CAA+D;AAE/D,6CAA0C;AAE1C,YAAY;AACZ,MAAa,UAAW,SAAQ,uBAAU;IAIxC,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,0BAAc,CAAC,UAAU,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAE5D;;;;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,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACxC,OAAO,UAAU,CAAC;IACpB,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,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACxD,OAAO,WAAW,CAAC;IACrB,CAAC;IAEe,YAAY,CAAC,eAAgC;QAC3D,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;QACpC,IAAI,IAAI,CAAC,WAAW,KAAK,EAAE,IAAI,eAAe,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE;YACxG,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,aAAa,EAAE,kBAAkB,IAAI,CAAC,IAAI,yCAAyC,CAAC,CAAC;aAC3H,IAAI,IAAI,CAAC,WAAW,KAAK,EAAE;YAC9B,IAAI,CAAC,WAAW,GAAG,eAAe,CAAC,UAAU,CAAC;IAClD,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,eAAgC;QAC7D,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,UAAkB;QAC9C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;CACF;AA7CD,gCA6CC;AAED;;;GAGG;AACH,MAAsB,iBAAkB,SAAQ,UAAU;CAGzD;AAHD,8CAGC","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 { PhenomenonProps } from \"../Deserialization/JsonProps\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\n\r\n/** @beta */\r\nexport class Phenomenon extends SchemaItem {\r\n public override readonly schemaItemType!: SchemaItemType.Phenomenon;\r\n protected _definition: string; // Contains a combination of Phenomena names which form this Phenomenon. Each Phenomena name is separated by a * and may have an exponent, specified using parentheses\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this.schemaItemType = SchemaItemType.Phenomenon;\r\n this._definition = \"\";\r\n }\r\n\r\n public get definition(): string { return this._definition; }\r\n\r\n /**\r\n * Save this Phenomenon's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): PhenomenonProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.definition = this.definition;\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 itemElement.setAttribute(\"definition\", this.definition);\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(phenomenonProps: PhenomenonProps) {\r\n super.fromJSONSync(phenomenonProps);\r\n if (this._definition !== \"\" && phenomenonProps.definition.toLowerCase() !== this._definition.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Phenomenon ${this.name} has an invalid 'definition' attribute.`);\r\n else if (this._definition === \"\")\r\n this._definition = phenomenonProps.definition;\r\n }\r\n\r\n public override async fromJSON(phenomenonProps: PhenomenonProps) {\r\n this.fromJSONSync(phenomenonProps);\r\n }\r\n\r\n protected async setDefinition(definition: string) {\r\n this._definition = definition;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutablePhenomenon extends Phenomenon {\r\n public abstract override setDefinition(definition: string): Promise<void>;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"Phenomenon.js","sourceRoot":"","sources":["../../../src/Metadata/Phenomenon.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,4CAA8C;AAC9C,4CAA+D;AAE/D,6CAA0C;AAE1C,YAAY;AACZ,MAAa,UAAW,SAAQ,uBAAU;IACf,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;IAC7D,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IACvE,WAAW,CAAS,CAAC,sKAAsK;IAErM,YAAY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,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,IAAiB;QAC1C,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,UAAU;YAC3D,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,kBAAkB,CAAC,IAAiB;QAChD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;YAC1B,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,UAAU,gBAAgB,CAAC,CAAC;IAC5H,CAAC;CACF;AAnED,gCAmEC;AAED;;;GAGG;AACH,MAAsB,iBAAkB,SAAQ,UAAU;CAGzD;AAHD,8CAGC","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 { PhenomenonProps } from \"../Deserialization/JsonProps\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\n\r\n/** @beta */\r\nexport class Phenomenon extends SchemaItem {\r\n public override readonly schemaItemType = Phenomenon.schemaItemType;\r\n public static override get schemaItemType() { return SchemaItemType.Phenomenon; }\r\n protected _definition: string; // Contains a combination of Phenomena names which form this Phenomenon. Each Phenomena name is separated by a * and may have an exponent, specified using parentheses\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this._definition = \"\";\r\n }\r\n\r\n public get definition(): string { return this._definition; }\r\n\r\n /**\r\n * Save this Phenomenon's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): PhenomenonProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.definition = this.definition;\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 itemElement.setAttribute(\"definition\", this.definition);\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(phenomenonProps: PhenomenonProps) {\r\n super.fromJSONSync(phenomenonProps);\r\n if (this._definition !== \"\" && phenomenonProps.definition.toLowerCase() !== this._definition.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Phenomenon ${this.name} has an invalid 'definition' attribute.`);\r\n else if (this._definition === \"\")\r\n this._definition = phenomenonProps.definition;\r\n }\r\n\r\n public override async fromJSON(phenomenonProps: PhenomenonProps) {\r\n this.fromJSONSync(phenomenonProps);\r\n }\r\n\r\n protected async setDefinition(definition: string) {\r\n this._definition = definition;\r\n }\r\n\r\n /**\r\n * Type guard to check if the SchemaItem is of type Phenomenon.\r\n * @param item The SchemaItem to check.\r\n * @returns True if the item is a Phenomenon, false otherwise.\r\n */\r\n public static isPhenomenon(item?: SchemaItem): item is Phenomenon {\r\n if (item && item.schemaItemType === SchemaItemType.Phenomenon)\r\n return true;\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Type assertion to check if the SchemaItem is of type Phenomenon.\r\n * @param item The SchemaItem to check.\r\n * @returns The item cast to Phenomenon if it is a Phenomenon, undefined otherwise.\r\n */\r\n public static assertIsPhenomenon(item?: SchemaItem): asserts item is Phenomenon {\r\n if (!this.isPhenomenon(item))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Phenomenon}' (Phenomenon)`);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutablePhenomenon extends Phenomenon {\r\n public abstract override setDefinition(definition: string): Promise<void>;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
@@ -10,7 +10,7 @@ import { ECClass, StructClass } from "./Class";
10
10
  import { CustomAttribute, CustomAttributeContainerProps, CustomAttributeSet } from "./CustomAttribute";
11
11
  import { KindOfQuantity } from "./KindOfQuantity";
12
12
  import { PropertyCategory } from "./PropertyCategory";
13
- import { RelationshipClass } from "./RelationshipClass";
13
+ import { type RelationshipClass } from "./RelationshipClass";
14
14
  import { Schema } from "./Schema";
15
15
  /**
16
16
  * A common abstract class for all ECProperty types.
@@ -97,6 +97,10 @@ export declare abstract class Property implements CustomAttributeContainerProps
97
97
  */
98
98
  static isProperty(object: any): object is AnyProperty;
99
99
  }
100
+ /** A callback function to process properties of an Entity
101
+ * @beta
102
+ */
103
+ export type PropertyHandler = (name: string, property: Property) => void;
100
104
  /** @beta */
101
105
  export declare abstract class PrimitiveOrEnumPropertyBase extends Property {
102
106
  protected _extendedTypeName?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Property.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Property.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACe,wBAAwB,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,gCAAgC,EACpI,sBAAsB,EAAE,aAAa,EAAE,mBAAmB,EAC3D,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAsB,aAAa,EAAyB,iBAAiB,EAA6B,MAAM,cAAc,CAAC;AAEtI,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACnJ,OAAO,EAAE,YAAY,EAA2C,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,S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MAAM,sBAAsB,GAAG,mBAAmB,GAAG,wBAAwB,CAAC;AACpF,YAAY;AACZ,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG,mBAAmB,CAAC;AACrE,YAAY;AACZ,MAAM,MAAM,WAAW,GAAG,oBAAoB,GAAG,sBAAsB,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;AAEjH;;;GAGG;AACH,8BAAsB,eAAgB,SAAQ,QAAQ;aAC3B,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;CACpF"}
@@ -15,11 +15,24 @@ const Exception_1 = require("../Exception");
15
15
  const PropertyTypes_1 = require("../PropertyTypes");
16
16
  const ECName_1 = require("../ECName");
17
17
  const CustomAttribute_1 = require("./CustomAttribute");
18
+ const Enumeration_1 = require("./Enumeration");
19
+ const KindOfQuantity_1 = require("./KindOfQuantity");
20
+ const PropertyCategory_1 = require("./PropertyCategory");
18
21
  /**
19
22
  * A common abstract class for all ECProperty types.
20
23
  * @beta
21
24
  */
22
25
  class Property {
26
+ _name;
27
+ _type;
28
+ _class; // TODO: class seems to be unused?
29
+ _description;
30
+ _label;
31
+ _isReadOnly;
32
+ _priority;
33
+ _category;
34
+ _kindOfQuantity;
35
+ _customAttributes;
23
36
  constructor(ecClass, name, type) {
24
37
  this._class = ecClass;
25
38
  this._name = new ECName_1.ECName(name);
@@ -35,9 +48,33 @@ class Property {
35
48
  get label() { return this._label; }
36
49
  get description() { return this._description; }
37
50
  get isReadOnly() { return this._isReadOnly || false; }
38
- get priority() { return this._priority || 0; }
39
- get category() { return this._category; }
40
- get kindOfQuantity() { return this._kindOfQuantity; }
51
+ get priority() {
52
+ if (this._priority === undefined) {
53
+ const baseProperty = this.class.getInheritedPropertySync(this.name);
54
+ if (undefined !== baseProperty) {
55
+ return baseProperty.priority;
56
+ }
57
+ }
58
+ return this._priority || 0;
59
+ }
60
+ get category() {
61
+ if (this._category === undefined) {
62
+ const baseProperty = this.class.getInheritedPropertySync(this.name);
63
+ if (undefined !== baseProperty) {
64
+ return baseProperty.category;
65
+ }
66
+ }
67
+ return this._category;
68
+ }
69
+ get kindOfQuantity() {
70
+ if (this._kindOfQuantity === undefined) {
71
+ const baseProperty = this.class.getInheritedPropertySync(this.name);
72
+ if (undefined !== baseProperty) {
73
+ return baseProperty.kindOfQuantity;
74
+ }
75
+ }
76
+ return this._kindOfQuantity;
77
+ }
41
78
  get propertyType() { return this._type; }
42
79
  get customAttributes() { return this._customAttributes; }
43
80
  /** Returns the name in the format 'ClassName.PropertyName'. */
@@ -45,14 +82,24 @@ class Property {
45
82
  /** Returns the schema of the class holding the property. */
46
83
  get schema() { return this._class.schema; }
47
84
  getCategorySync() {
48
- if (!this._category)
85
+ if (!this._category) {
86
+ const baseProperty = this.class.getInheritedPropertySync(this.name);
87
+ if (undefined !== baseProperty) {
88
+ return baseProperty.getCategorySync();
89
+ }
49
90
  return undefined;
50
- return this.class.schema.lookupItemSync(this._category);
91
+ }
92
+ return this.class.schema.lookupItemSync(this._category, PropertyCategory_1.PropertyCategory);
51
93
  }
52
94
  getKindOfQuantitySync() {
53
- if (!this._kindOfQuantity)
95
+ if (!this._kindOfQuantity) {
96
+ const baseProperty = this.class.getInheritedPropertySync(this.name);
97
+ if (undefined !== baseProperty) {
98
+ return baseProperty.getKindOfQuantitySync();
99
+ }
54
100
  return undefined;
55
- return this.class.schema.lookupItemSync(this._kindOfQuantity);
101
+ }
102
+ return this.class.schema.lookupItemSync(this._kindOfQuantity, KindOfQuantity_1.KindOfQuantity);
56
103
  }
57
104
  /**
58
105
  * Save this Property's properties to an object for serializing to JSON.
@@ -67,12 +114,12 @@ class Property {
67
114
  schemaJson.label = this.label;
68
115
  if (this._isReadOnly !== undefined)
69
116
  schemaJson.isReadOnly = this._isReadOnly;
70
- if (this.category !== undefined)
71
- schemaJson.category = this.category.fullName; // needs to be fully qualified name
117
+ if (this._category !== undefined)
118
+ schemaJson.category = this._category.fullName; // needs to be fully qualified name
72
119
  if (this._priority !== undefined)
73
120
  schemaJson.priority = this._priority;
74
- if (this.kindOfQuantity !== undefined)
75
- schemaJson.kindOfQuantity = this.kindOfQuantity.fullName;
121
+ if (this._kindOfQuantity !== undefined)
122
+ schemaJson.kindOfQuantity = this._kindOfQuantity.fullName;
76
123
  const customAttributes = (0, CustomAttribute_1.serializeCustomAttributes)(this.customAttributes);
77
124
  if (customAttributes !== undefined)
78
125
  schemaJson.customAttributes = customAttributes;
@@ -89,15 +136,15 @@ class Property {
89
136
  itemElement.setAttribute("displayLabel", this.label);
90
137
  if (undefined !== this.isReadOnly)
91
138
  itemElement.setAttribute("readOnly", String(this.isReadOnly));
92
- if (undefined !== this.category) {
93
- const category = await this.category;
139
+ if (undefined !== this._category) {
140
+ const category = await this._category;
94
141
  const categoryName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, category.schema, category.name);
95
142
  itemElement.setAttribute("category", categoryName);
96
143
  }
97
- if (undefined !== this.priority)
98
- itemElement.setAttribute("priority", this.priority.toString());
99
- if (undefined !== this.kindOfQuantity) {
100
- const kindOfQuantity = await this.kindOfQuantity;
144
+ if (undefined !== this._priority)
145
+ itemElement.setAttribute("priority", this._priority.toString());
146
+ if (undefined !== this._kindOfQuantity) {
147
+ const kindOfQuantity = await this._kindOfQuantity;
101
148
  const kindOfQuantityName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, kindOfQuantity.schema, kindOfQuantity.name);
102
149
  itemElement.setAttribute("kindOfQuantity", kindOfQuantityName);
103
150
  }
@@ -129,7 +176,7 @@ class Property {
129
176
  if (!propertyCategorySchemaItemKey)
130
177
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Property ${this.name} has a 'category' ("${propertyProps.category}") that cannot be found.`);
131
178
  this._category = new DelayedPromise_1.DelayedPromiseWithProps(propertyCategorySchemaItemKey, async () => {
132
- const category = await this.class.schema.lookupItem(propertyCategorySchemaItemKey);
179
+ const category = await this.class.schema.lookupItem(propertyCategorySchemaItemKey, PropertyCategory_1.PropertyCategory);
133
180
  if (undefined === category)
134
181
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Property ${this.name} has a 'category' ("${propertyProps.category}") that cannot be found.`);
135
182
  return category;
@@ -140,7 +187,7 @@ class Property {
140
187
  if (!koqSchemaItemKey)
141
188
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Property ${this.name} has a 'kindOfQuantity' ("${propertyProps.kindOfQuantity}") that cannot be found.`);
142
189
  this._kindOfQuantity = new DelayedPromise_1.DelayedPromiseWithProps(koqSchemaItemKey, async () => {
143
- const koq = await this.class.schema.lookupItem(koqSchemaItemKey);
190
+ const koq = await this.class.schema.lookupItem(koqSchemaItemKey, KindOfQuantity_1.KindOfQuantity);
144
191
  if (undefined === koq)
145
192
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Property ${this.name} has a 'kindOfQuantity' ("${propertyProps.kindOfQuantity}") that cannot be found.`);
146
193
  return koq;
@@ -230,6 +277,11 @@ class Property {
230
277
  exports.Property = Property;
231
278
  /** @beta */
232
279
  class PrimitiveOrEnumPropertyBase extends Property {
280
+ _extendedTypeName;
281
+ _minLength;
282
+ _maxLength;
283
+ _minValue;
284
+ _maxValue;
233
285
  get extendedTypeName() { return this._extendedTypeName; }
234
286
  get minLength() { return this._minLength; }
235
287
  get maxLength() { return this._maxLength; }
@@ -357,6 +409,7 @@ class PrimitiveProperty extends PrimitiveOrEnumPropertyBase {
357
409
  exports.PrimitiveProperty = PrimitiveProperty;
358
410
  /** @beta */
359
411
  class EnumerationProperty extends PrimitiveOrEnumPropertyBase {
412
+ _enumeration;
360
413
  get enumeration() { return this._enumeration; }
361
414
  /**
362
415
  * Save this EnumerationProperty's properties to an object for serializing to JSON.
@@ -380,7 +433,7 @@ class EnumerationProperty extends PrimitiveOrEnumPropertyBase {
380
433
  if (!enumSchemaItemKey)
381
434
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${enumerationPropertyProps.typeName}.`);
382
435
  this._enumeration = new DelayedPromise_1.DelayedPromiseWithProps(enumSchemaItemKey, async () => {
383
- const enumeration = await this.class.schema.lookupItem(enumSchemaItemKey);
436
+ const enumeration = await this.class.schema.lookupItem(enumSchemaItemKey, Enumeration_1.Enumeration);
384
437
  if (undefined === enumeration)
385
438
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${enumerationPropertyProps.typeName}.`);
386
439
  return enumeration;
@@ -402,6 +455,7 @@ class EnumerationProperty extends PrimitiveOrEnumPropertyBase {
402
455
  exports.EnumerationProperty = EnumerationProperty;
403
456
  /** @beta */
404
457
  class StructProperty extends Property {
458
+ _structClass;
405
459
  get structClass() { return this._structClass; }
406
460
  constructor(ecClass, name, type) {
407
461
  super(ecClass, name, PropertyTypes_1.PropertyType.Struct);
@@ -436,11 +490,15 @@ class StructProperty extends Property {
436
490
  exports.StructProperty = StructProperty;
437
491
  /** @beta */
438
492
  class NavigationProperty extends Property {
493
+ _relationshipClass;
494
+ _direction;
439
495
  get relationshipClass() { return this._relationshipClass; }
440
496
  getRelationshipClassSync() {
441
497
  if (!this._relationshipClass) // eslint-disable-line @typescript-eslint/no-misused-promises
442
498
  return undefined;
443
- return this.class.schema.lookupItemSync(this._relationshipClass);
499
+ // We cannot use the type guard here to avoid a circular dependency
500
+ const result = this.class.schema.lookupItemSync(this._relationshipClass);
501
+ return result?.schemaItemType === ECObjects_1.SchemaItemType.RelationshipClass ? result : undefined;
444
502
  }
445
503
  get direction() { return this._direction; }
446
504
  /**
@@ -472,11 +530,8 @@ exports.NavigationProperty = NavigationProperty;
472
530
  const INT32_MAX = 2147483647;
473
531
  /** @beta */
474
532
  class ArrayProperty extends Property {
475
- constructor() {
476
- super(...arguments);
477
- this._minOccurs = 0;
478
- this._maxOccurs = INT32_MAX;
479
- }
533
+ _minOccurs = 0;
534
+ _maxOccurs = INT32_MAX;
480
535
  get minOccurs() { return this._minOccurs; }
481
536
  get maxOccurs() { return this._maxOccurs; }
482
537
  /**
@@ -496,12 +551,12 @@ exports.ArrayProperty = ArrayProperty;
496
551
  // eslint-disable-next-line @typescript-eslint/naming-convention
497
552
  const ArrayPropertyMixin = (Base) => {
498
553
  return class extends Base {
554
+ _minOccurs = 0;
555
+ _maxOccurs = INT32_MAX;
499
556
  get minOccurs() { return this._minOccurs; }
500
557
  get maxOccurs() { return this._maxOccurs; }
501
558
  constructor(...args) {
502
559
  super(...args);
503
- this._minOccurs = 0;
504
- this._maxOccurs = INT32_MAX;
505
560
  this._type = PropertyTypes_1.PropertyTypeUtils.asArray(this._type);
506
561
  }
507
562
  fromJSONSync(arrayPropertyProps) {